diff --git a/dist/lips.js b/dist/lips.js index 678d53ab..81277433 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sat, 23 Dec 2023 13:40:35 +0000 + * build: Sat, 23 Dec 2023 13:43:06 +0000 */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : @@ -5799,38 +5799,27 @@ * The rationalize algorithm is by Per M.A. Bothner, Alan Bawden and Marc Feeley. * source: Kawa, C-Gambit * - * Build time: Sat, 23 Dec 2023 13:40:35 +0000 + * Build time: Sat, 23 Dec 2023 13:43:06 +0000 */ var _excluded = ["token"], - _excluded2 = ["stderr", "stdin", "stdout", "command_line"]; - + _excluded2 = ["stderr", "stdin", "stdout", "command_line"]; function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } - function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } - function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } - function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } - function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } - function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } - function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } - function _asyncIterator(iterable) { var method, async, sync, retry = 2; for ("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;) { if (async && null != (method = iterable[async])) return method.call(iterable); if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable)); async = "@@asyncIterator", sync = "@@iterator"; } throw new TypeError("Object is not async iterable"); } - function AsyncFromSyncIterator(s) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var done = r.done; return Promise.resolve(r.value).then(function (value) { return { value: value, done: done }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(s) { this.s = s, this.n = s.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, "return": function _return(value) { var ret = this.s["return"]; return void 0 === ret ? Promise.resolve({ value: value, done: !0 }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments)); }, "throw": function _throw(value) { var thr = this.s["return"]; return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(s); } - var root = typeof global !== 'undefined' ? global : self; - if (!root.fetch) { root.fetch = unfetch; - } // ------------------------------------------------------------------------- + } + + // ------------------------------------------------------------------------- // :: typechecking maps // ------------------------------------------------------------------------- - - var type_mapping = { 'pair': Pair, 'symbol': LSymbol, @@ -5848,151 +5837,123 @@ 'string': LString, 'native-symbol': Symbol }; - var type_constants = new Map([[NaN, 'NaN'], [null, 'null']]); // ------------------------------------------------------------------------- + var type_constants = new Map([[NaN, 'NaN'], [null, 'null']]); + // ------------------------------------------------------------------------- var fs, path$2, nodeRequire; var BN = root.BN; - /* eslint-disable */ + /* eslint-disable */ /* istanbul ignore next */ - function contentLoaded(win, fn) { var done = false, - top = true, - doc = win.document, - root = doc.documentElement, - modern = doc.addEventListener, - add = modern ? 'addEventListener' : 'attachEvent', - rem = modern ? 'removeEventListener' : 'detachEvent', - pre = modern ? '' : 'on', - init = function init(e) { - if (e.type == 'readystatechange' && doc.readyState != 'complete') return; - (e.type == 'load' ? win : doc)[rem](pre + e.type, init, false); - if (!done && (done = true)) fn.call(win, e.type || e); - }, - poll = function poll() { - try { - root.doScroll('left'); - } catch (e) { - setTimeout(poll, 50); - return; - } - - init('poll'); - }; - + top = true, + doc = win.document, + root = doc.documentElement, + modern = doc.addEventListener, + add = modern ? 'addEventListener' : 'attachEvent', + rem = modern ? 'removeEventListener' : 'detachEvent', + pre = modern ? '' : 'on', + init = function init(e) { + if (e.type == 'readystatechange' && doc.readyState != 'complete') return; + (e.type == 'load' ? win : doc)[rem](pre + e.type, init, false); + if (!done && (done = true)) fn.call(win, e.type || e); + }, + poll = function poll() { + try { + root.doScroll('left'); + } catch (e) { + setTimeout(poll, 50); + return; + } + init('poll'); + }; if (doc.readyState == 'complete') fn.call(win, 'lazy');else { if (!modern && root.doScroll) { try { top = !win.frameElement; } catch (e) {} - if (top) poll(); } - doc[add](pre + 'DOMContentLoaded', init, false); doc[add](pre + 'readystatechange', init, false); win[add](pre + 'load', init, false); } - } // ------------------------------------------------------------------------- - + } + // ------------------------------------------------------------------------- /* eslint-disable */ - /* istanbul ignore next */ - - function log(x) { var regex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; var literal = arguments[1] === true; - function msg(x) { if (!is_debug()) { return; } - var value = global_env.get('repr')(x); - if (regex === null || regex instanceof RegExp && regex.test(value)) { console.log(global_env.get('type')(x) + ": " + value); } - if (literal) { console.log(x); } } - if (is_promise(x)) { x.then(msg); } else { msg(x); } - return x; - } // ---------------------------------------------------------------------- - + } + // ---------------------------------------------------------------------- /* istanbul ignore next */ - - function is_debug() { return user_env && user_env.get('DEBUG', { throwError: false }); } /* eslint-enable */ - /* eslint-disable max-len */ // functions generate regexes to match number rational, integer, complex, complex+rational - - function num_mnemicic_re(mnemonic) { return mnemonic ? "(?:#".concat(mnemonic, "(?:#[ie])?|#[ie]#").concat(mnemonic, ")") : '(?:#[ie])?'; } - function gen_rational_re(mnemonic, range) { return "".concat(num_mnemicic_re(mnemonic), "[+-]?").concat(range, "+/").concat(range, "+"); - } // TODO: float complex - - + } + // TODO: float complex function gen_complex_re(mnemonic, range) { // [+-]i have (?=..) so it don't match +i from +inf.0 return "".concat(num_mnemicic_re(mnemonic), "(?:[+-]?(?:").concat(range, "+/").concat(range, "+|nan.0|inf.0|").concat(range, "+))?(?:[+-]i|[+-]?(?:").concat(range, "+/").concat(range, "+|").concat(range, "+|nan.0|inf.0)i)(?=[()[\\]\\s]|$)"); } - function gen_integer_re(mnemonic, range) { return "".concat(num_mnemicic_re(mnemonic), "[+-]?").concat(range, "+"); } - var re_re = /^#\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimyus]*)$/; - var float_stre = '(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+)(?:[eE][-+]?[0-9]+)?)|[0-9]+\\.)'; // TODO: extend to ([+-]1/2|float)([+-]1/2|float) - + var float_stre = '(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+)(?:[eE][-+]?[0-9]+)?)|[0-9]+\\.)'; + // TODO: extend to ([+-]1/2|float)([+-]1/2|float) var complex_float_stre = "(?:#[ie])?(?:[+-]?(?:[0-9]+/[0-9]+|nan.0|inf.0|".concat(float_stre, "|[+-]?[0-9]+))?(?:").concat(float_stre, "|[+-](?:[0-9]+/[0-9]+|[0-9]+|nan.0|inf.0))i"); var float_re = new RegExp("^(#[ie])?".concat(float_stre, "$"), 'i'); - function make_complex_match_re(mnemonic, range) { // complex need special treatment of 10e+1i when it's hex or decimal var neg = mnemonic === 'x' ? "(?!\\+|".concat(range, ")") : "(?!\\.|".concat(range, ")"); var fl = ''; - if (mnemonic === '') { fl = '(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))'; } - return new RegExp("^((?:(?:".concat(fl, "|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(range, "+/").concat(range, "+(?!").concat(range, ")|[+-]?").concat(range, "+)").concat(neg, ")?)(").concat(fl, "|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(range, "+/").concat(range, "+|[+-]?").concat(range, "+|[+-])i$"), 'i'); } - var complex_list_re = function () { var result = {}; [[10, '', '[0-9]'], [16, 'x', '[0-9a-fA-F]'], [8, 'o', '[0-7]'], [2, 'b', '[01]']].forEach(function (_ref) { var _ref2 = _slicedToArray(_ref, 3), - radix = _ref2[0], - mnemonic = _ref2[1], - range = _ref2[2]; - + radix = _ref2[0], + mnemonic = _ref2[1], + range = _ref2[2]; result[radix] = make_complex_match_re(mnemonic, range); }); return result; }(); - var characters = { 'alarm': '\x07', 'backspace': '\x08', @@ -6036,22 +5997,19 @@ 'si': '\x0f', 'us': '\x1f', 'del': '\x7f' - }; // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- // :: ref: https://github.com/bestiejs/punycode.js/blob/master/punycode.js // ------------------------------------------------------------------------- - function ucs2decode(string) { var output = []; var counter = 0; var length = string.length; - while (counter < length) { var value = string.charCodeAt(counter++); - if (value >= 0xD800 && value <= 0xDBFF && counter < length) { // It's a high surrogate, and there is a next character. var extra = string.charCodeAt(counter++); - if ((extra & 0xFC00) === 0xDC00) { // Low surrogate. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); @@ -6065,55 +6023,46 @@ output.push(value); } } - return output; - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- var character_symbols = Object.keys(characters).join('|'); var char_sre_re = "#\\\\(?:x[0-9a-f]+|".concat(character_symbols, "|[\\s\\S])"); - var char_re = new RegExp("^".concat(char_sre_re, "$"), 'i'); // Complex with (int) (float) (rational) - + var char_re = new RegExp("^".concat(char_sre_re, "$"), 'i'); + // Complex with (int) (float) (rational) function make_num_stre(fn) { - var ranges = [['o', '[0-7]'], ['x', '[0-9a-fA-F]'], ['b', '[01]'], ['d', '[0-9]'], ['', '[0-9]']]; // float exception that don't accept mnemonics - + var ranges = [['o', '[0-7]'], ['x', '[0-9a-fA-F]'], ['b', '[01]'], ['d', '[0-9]'], ['', '[0-9]']]; + // float exception that don't accept mnemonics var result = ranges.map(function (_ref3) { var _ref4 = _slicedToArray(_ref3, 2), - m = _ref4[0], - range = _ref4[1]; - + m = _ref4[0], + range = _ref4[1]; return fn(m, range); }).join('|'); - if (fn === gen_complex_re) { result = complex_float_stre + '|' + result; } - return result; } - function make_type_re(fn) { return new RegExp('^(?:' + make_num_stre(fn) + ')$', 'i'); } - var complex_re = make_type_re(gen_complex_re); var rational_re = make_type_re(gen_rational_re); - var int_re = make_type_re(gen_integer_re); // regexes with full range but without mnemonics for string->number + var int_re = make_type_re(gen_integer_re); + // regexes with full range but without mnemonics for string->number var int_bare_re = new RegExp('^(?:' + gen_integer_re('', '[0-9a-f]') + ')$', 'i'); var rational_bare_re = new RegExp('^(?:' + gen_rational_re('', '[0-9a-f]') + ')$', 'i'); var complex_bare_re = new RegExp('^(?:' + gen_complex_re('', '[0-9a-f]') + ')$', 'i'); var complex_bare_match_re = make_complex_match_re('', '[0-9a-fA-F]'); var pre_num_parse_re = /((?:#[xodbie]){0,2})(.*)/i; /* eslint-enable */ - function num_pre_parse(arg) { var parts = arg.match(pre_num_parse_re); var options = {}; - if (parts[1]) { var type = parts[1].replace(/#/g, '').toLowerCase().split(''); - if (type.includes('x')) { options.radix = 16; } else if (type.includes('o')) { @@ -6123,21 +6072,17 @@ } else if (type.includes('d')) { options.radix = 10; } - if (type.includes('i')) { options.inexact = true; } - if (type.includes('e')) { options.exact = true; } } - options.number = parts[2]; return options; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function parse_rational(arg) { var radix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10; var parse = num_pre_parse(arg); @@ -6146,57 +6091,44 @@ num: LNumber([parts[0], parse.radix || radix]), denom: LNumber([parts[1], parse.radix || radix]) }); - if (parse.inexact) { return num.valueOf(); } else { return num; } - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function parse_integer(arg) { var radix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10; var parse = num_pre_parse(arg); - if (parse.inexact) { return LFloat(parseInt(parse.number, parse.radix || radix)); } - return LNumber([parse.number, parse.radix || radix]); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function parse_character(arg) { var m = arg.match(/#\\x([0-9a-f]+)$/i); - var _char; - if (m) { var ord = parseInt(m[1], 16); _char = String.fromCodePoint(ord); } else { m = arg.match(/#\\(.+)$/); - if (m) { _char = m[1]; } } - if (_char) { return LCharacter(_char); } - throw new Error('Parse: invalid character'); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function parse_complex(arg) { var radix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10; - function parse_num(n) { var value; - if (n === '+') { value = LNumber(1); } else if (n === '-') { @@ -6211,11 +6143,9 @@ }); } else if (n.match(float_re)) { var _float = parse_float(n); - if (parse.exact) { return _float.toRational(); } - return _float; } else if (n.match(/nan.0$/)) { return LNumber(NaN); @@ -6223,104 +6153,82 @@ if (n[0] === '-') { return LNumber(Number.NEGATIVE_INFINITY); } - return LNumber(Number.POSITIVE_INFINITY); } else { throw new Error('Internal Parser Error'); } - if (parse.inexact) { return LFloat(value.valueOf()); } - return value; } - var parse = num_pre_parse(arg); radix = parse.radix || radix; var parts; var bare_match = parse.number.match(complex_bare_match_re); - if (radix !== 10 && bare_match) { parts = bare_match; } else { parts = parse.number.match(complex_list_re[radix]); } - var re, im; im = parse_num(parts[2]); - if (parts[1]) { re = parse_num(parts[1]); } else { re = LNumber(0); } - if (im.cmp(0) === 0 && im.__type__ === 'bigint') { return re; } - return LComplex({ im: im, re: re }); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function is_int(value) { return parseInt(value.toString(), 10) === value; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function parse_big_int(str) { var num_match = str.match(/^(([-+]?[0-9]*)(?:\.([0-9]+))?)e([-+]?[0-9]+)/i); - if (num_match) { var exponent = parseInt(num_match[4], 10); var mantisa; // = parseFloat(num_match[1]); - var digits = num_match[1].replace(/[-+]?([0-9]*)\..+$/, '$1').length; var decimal_points = num_match[3] && num_match[3].length; - if (digits < Math.abs(exponent)) { mantisa = LNumber([num_match[1].replace(/\./, ''), 10]); - if (decimal_points) { exponent -= decimal_points; } } } - return { exponent: exponent, mantisa: mantisa }; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function parse_float(arg) { var parse = num_pre_parse(arg); var value = parseFloat(parse.number); var simple_number = (parse.number.match(/\.0$/) || !parse.number.match(/\./)) && !parse.number.match(/e/i); - if (!parse.inexact) { if (parse.exact && simple_number) { return LNumber(value); - } // positive big num that eval to int e.g.: 1.2e+20 - - + } + // positive big num that eval to int e.g.: 1.2e+20 if (is_int(value) && parse.number.match(/e\+?[0-9]/i)) { return LNumber(value); - } // calculate big int and big fraction by hand - it don't fit into JS float - - + } + // calculate big int and big fraction by hand - it don't fit into JS float var _parse_big_int = parse_big_int(parse.number), - mantisa = _parse_big_int.mantisa, - exponent = _parse_big_int.exponent; - + mantisa = _parse_big_int.mantisa, + exponent = _parse_big_int.exponent; if (mantisa !== undefined && exponent !== undefined) { var factor = LNumber(10).pow(LNumber(Math.abs(exponent))); - if (parse.exact && exponent < 0) { return LRational({ num: mantisa, @@ -6331,38 +6239,30 @@ } } } - value = LFloat(value); - if (parse.exact) { return value.toRational(); } - return value; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function parse_string(string) { // handle non JSON escapes and skip unicode escape \u (even partial) string = string.replace(/\\x([0-9a-f]+);/ig, function (_, hex) { return "\\u" + hex.padStart(4, '0'); }).replace(/\n/g, '\\n'); // in LIPS strings can be multiline - var m = string.match(/(\\*)(\\x[0-9A-F])/i); - if (m && m[1].length % 2 === 0) { throw new Error("Invalid string literal, unclosed ".concat(m[2])); } - try { return LString(JSON.parse(string)); } catch (e) { var msg = e.message.replace(/in JSON /, '').replace(/.*Error: /, ''); throw new Error("Invalid string literal: ".concat(msg)); } - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function parse_symbol(arg) { if (arg.match(/^\|.*\|$/)) { arg = arg.replace(/(^\|)|(\|$)/g, ''); @@ -6377,35 +6277,28 @@ return chars[chr] || chr; }); } - return new LSymbol(arg); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function parse_argument(arg) { if (constants.hasOwnProperty(arg)) { return constants[arg]; } - if (arg.match(/^"[\s\S]*"$/)) { return parse_string(arg); } else if (arg[0] === '#') { var regex = arg.match(re_re); - if (regex) { return new RegExp(regex[1], regex[2]); } else if (arg.match(char_re)) { return parse_character(arg); - } // characters with more than one codepoint - - + } + // characters with more than one codepoint var m = arg.match(/#\\(.+)/); - if (m && ucs2decode(m[1]).length === 1) { return parse_character(arg); } } - if (arg.match(/[0-9a-f]|[+-]i/i)) { if (arg.match(int_re)) { return parse_integer(arg); @@ -6417,145 +6310,115 @@ return parse_complex(arg); } } - if (arg.match(/^#[iexobd]/)) { throw new Error('Invalid numeric constant: ' + arg); } - return parse_symbol(arg); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function is_atom_string(str) { return !(['(', ')', '[', ']'].includes(str) || specials.names().includes(str)); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function is_symbol_string(str) { return is_atom_string(str) && !(str.match(re_re) || str.match(/^"[\s\S]*"$/) || str.match(int_re) || str.match(float_re) || str.match(complex_re) || str.match(rational_re) || str.match(char_re) || ['#t', '#f', 'nil', 'true', 'false'].includes(str)); - } // ---------------------------------------------------------------------- - - - var string_re = /"(?:\\[\S\s]|[^"])*"?/g; // ---------------------------------------------------------------------- - + } + // ---------------------------------------------------------------------- + var string_re = /"(?:\\[\S\s]|[^"])*"?/g; + // ---------------------------------------------------------------------- function escape_regex(str) { if (typeof str === 'string') { var special = /([-\\^$[\]()+{}?*.|])/g; return str.replace(special, '\\$1'); } - return str; - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // Stack used in balanced function // TODO: use it in parser // ---------------------------------------------------------------------- - - function Stack() { this.data = []; } - Stack.prototype.push = function (item) { this.data.push(item); }; - Stack.prototype.top = function () { return this.data[this.data.length - 1]; }; - Stack.prototype.pop = function () { return this.data.pop(); }; - Stack.prototype.is_empty = function () { return !this.data.length; - }; // ---------------------------------------------------------------------- - - + }; + // ---------------------------------------------------------------------- function tokens(str) { if (str instanceof LString) { str = str.valueOf(); } - var lexer = new Lexer(str, { whitespace: true }); var result = []; - while (true) { var token = lexer.peek(true); - if (token === eof) { break; } - result.push(token); lexer.skip(); } - return result; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function multiline_formatter(meta) { var token = meta.token, - rest = _objectWithoutProperties(meta, _excluded); - + rest = _objectWithoutProperties(meta, _excluded); if (token.match(/^"[\s\S]*"$/) && token.match(/\n/)) { var re = new RegExp('^ {1,' + (meta.col + 1) + '}', 'mg'); token = token.replace(re, ''); } - return _objectSpread({ token: token }, rest); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function Thunk(fn) { var cont = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {}; this.fn = fn; this.cont = cont; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- Thunk.prototype.toString = function () { return '#'; - }; // ---------------------------------------------------------------------- - - + }; + // ---------------------------------------------------------------------- function trampoline(fn) { return function () { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } - return unwind(fn.apply(this, args)); }; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function unwind(result) { while (result instanceof Thunk) { var thunk = result; result = result.fn(); - if (!(result instanceof Thunk)) { thunk.cont(); } } - return result; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function tokenize(str) { var meta = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - if (str instanceof LString) { str = str.toString(); } - if (meta) { return tokens(str); } else { @@ -6564,24 +6427,20 @@ if (token.token === '#\\ ') { return token.token; } - return token.token.trim(); }).filter(function (token) { return token && !token.match(/^;/) && !token.match(/^#\|[\s\S]*\|#$/); }); return strip_s_comments(result); } - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function strip_s_comments(tokens) { var s_count = 0; var s_start = null; var remove_list = []; - for (var i = 0; i < tokens.length; ++i) { var token = tokens[i]; - if (token === '#;') { if (['(', '['].includes(tokens[i + 1])) { s_count = 1; @@ -6589,195 +6448,158 @@ } else { remove_list.push([i, i + 2]); } - i += 1; continue; } - if (s_start !== null) { if ([')', ']'].includes(token)) { s_count--; } else if (['(', '['].includes(token)) { s_count++; } - if (s_count === 0) { remove_list.push([s_start, i + 1]); s_start = null; } } } - tokens = tokens.slice(); remove_list.reverse(); - for (var _i = 0, _remove_list = remove_list; _i < _remove_list.length; _i++) { var _remove_list$_i = _slicedToArray(_remove_list[_i], 2), - begin = _remove_list$_i[0], - end = _remove_list$_i[1]; - + begin = _remove_list$_i[0], + end = _remove_list$_i[1]; tokens.splice(begin, end - begin); } - return tokens; - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // Detect if object is ES6 Symbol that work with polyfills // ---------------------------------------------------------------------- - - function isSymbol(x) { return _typeof(x) === 'symbol' || _typeof(x) === 'object' && Object.prototype.toString.call(x) === '[object Symbol]'; - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // :: LSymbol constructor // ---------------------------------------------------------------------- - - function LSymbol(name) { if (typeof this !== 'undefined' && this.constructor !== LSymbol || typeof this === 'undefined') { return new LSymbol(name); } - if (name instanceof LString) { name = name.valueOf(); } - if (LSymbol.list[name] instanceof LSymbol) { return LSymbol.list[name]; } - this.__name__ = name; - if (typeof name === 'string') { LSymbol.list[name] = this; } } - LSymbol.list = {}; LSymbol.literal = Symbol["for"]('__literal__'); - LSymbol.object = Symbol["for"]('__object__'); // ---------------------------------------------------------------------- - + LSymbol.object = Symbol["for"]('__object__'); + // ---------------------------------------------------------------------- LSymbol.is = function (symbol, name) { return symbol instanceof LSymbol && (name instanceof LSymbol && symbol.__name__ === name.__name__ || typeof name === 'string' && symbol.__name__ === name || name instanceof RegExp && name.test(symbol.__name__)); - }; // ---------------------------------------------------------------------- - - + }; + // ---------------------------------------------------------------------- LSymbol.prototype.toString = function (quote) { //return '#'; if (isSymbol(this.__name__)) { return symbol_to_string(this.__name__); } - - var str = this.valueOf(); // those special characters can be normal symbol when printed - + var str = this.valueOf(); + // those special characters can be normal symbol when printed if (quote && str.match(/(^;|[\s()[\]'])/)) { return "|".concat(str, "|"); } - return str; }; - LSymbol.prototype.literal = function () { if (this.is_gensym()) { return this[LSymbol.literal]; } - return this.valueOf(); }; - LSymbol.prototype.serialize = function () { if (LString.isString(this.__name__)) { return this.__name__; } - return [symbol_to_string(this.__name__)]; }; - LSymbol.prototype.valueOf = function () { return this.__name__.valueOf(); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LSymbol.prototype.is_gensym = function () { return is_gensym(this.__name__); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- function symbol_to_string(obj) { return obj.toString().replace(/^Symbol\(([^)]+)\)/, '$1'); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function is_gensym(symbol) { if (_typeof(symbol) === 'symbol') { return !!symbol.toString().match(/^Symbol\(#:/); } - return false; - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- var gensym = function () { var count = 0; - function with_props(name, sym) { var symbol = new LSymbol(sym); hidden_prop(symbol, '__literal__', name); return symbol; } - return function () { var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - if (name instanceof LSymbol) { if (name.is_gensym()) { return name; } - name = name.valueOf(); } - if (is_gensym(name)) { // don't do double gynsyms in nested syntax-rules return LSymbol(name); - } // use ES6 symbol as name for lips symbol (they are unique) - - + } + // use ES6 symbol as name for lips symbol (they are unique) if (name !== null) { return with_props(name, Symbol("#:".concat(name))); } - count++; return with_props(count, Symbol("#:g".concat(count))); }; - }(); // ---------------------------------------------------------------------- + }(); + // ---------------------------------------------------------------------- // Class used to escape promises: feature #54 // ---------------------------------------------------------------------- - - function QuotedPromise(promise) { var _this = this; - var internal = { pending: true, rejected: false, fulfilled: false, reason: undefined, type: undefined - }; // then added to __promise__ is needed otherwise rejection + }; + // then added to __promise__ is needed otherwise rejection // will give UnhandledPromiseRejectionWarning in Node.js - promise = promise.then(function (v) { internal.type = type(v); internal.fulfilled = true; internal.pending = false; return v; - }); // promise without catch, used for valueOf - for rejecting + }); + // promise without catch, used for valueOf - for rejecting // that should throw an error when used with await - read_only(this, '_promise', promise, { hidden: true }); - if (is_function(promise["catch"])) { // prevent exception on unhandled rejecting when using // '>(Promise.reject (new Error "zonk")) in REPL @@ -6787,7 +6609,6 @@ internal.reason = err; }); } - Object.keys(internal).forEach(function (name) { Object.defineProperty(_this, "__".concat(name, "__"), { enumerable: true, @@ -6796,96 +6617,78 @@ } }); }); - read_only(this, '__promise__', promise); // prevent resolving when returned from real promise #153 - + read_only(this, '__promise__', promise); + // prevent resolving when returned from real promise #153 this.then = false; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- QuotedPromise.prototype.then = function (fn) { return new QuotedPromise(this.valueOf().then(fn)); - }; // ---------------------------------------------------------------------- - - + }; + // ---------------------------------------------------------------------- QuotedPromise.prototype["catch"] = function (fn) { return new QuotedPromise(this.valueOf()["catch"](fn)); - }; // ---------------------------------------------------------------------- - - + }; + // ---------------------------------------------------------------------- QuotedPromise.prototype.valueOf = function () { if (!this._promise) { throw new Error('QuotedPromise: invalid promise created'); } - return this._promise; - }; // ---------------------------------------------------------------------- - - + }; + // ---------------------------------------------------------------------- QuotedPromise.prototype.toString = function () { if (this.__pending__) { return QuotedPromise.pending_str; } - if (this.__rejected__) { return QuotedPromise.rejected_str; } - return "#"); }; - QuotedPromise.pending_str = '#'; - QuotedPromise.rejected_str = '#'; // ---------------------------------------------------------------------- + QuotedPromise.rejected_str = '#'; + // ---------------------------------------------------------------------- // wrapper over Promise.all that ignore quoted promises // ---------------------------------------------------------------------- - function promise_all(arg) { if (Array.isArray(arg)) { return Promise.all(escape_quoted_promises(arg)).then(unescape_quoted_promises); } - return arg; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function escape_quoted_promises(array) { // using loops for performance var escaped = new Array(array.length), - i = array.length; - + i = array.length; while (i--) { var value = array[i]; - if (value instanceof QuotedPromise) { escaped[i] = new Value(value); } else { escaped[i] = value; } } - return escaped; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function unescape_quoted_promises(array) { var unescaped = new Array(array.length), - i = array.length; - + i = array.length; while (i--) { var value = array[i]; - if (value instanceof Value) { unescaped[i] = value.valueOf(); } else { unescaped[i] = value; } } - return unescaped; - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // :: Parser macros transformers // ---------------------------------------------------------------------- - - var specials = { LITERAL: Symbol["for"]('literal'), SPLICE: Symbol["for"]('splice'), @@ -6902,9 +6705,7 @@ // events are used in Lexer dynamic rules off: function off(name) { var _this2 = this; - var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; - if (Array.isArray(name)) { name.forEach(function (name) { return _this2.off(name, fn); @@ -6919,7 +6720,6 @@ }, on: function on(name, fn) { var _this3 = this; - if (Array.isArray(name)) { name.forEach(function (name) { return _this3.on(name, fn); @@ -6934,7 +6734,6 @@ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } - if (this.__events__[name]) { this.__events__[name].forEach(function (fn) { return fn.apply(void 0, args); @@ -6956,20 +6755,16 @@ __events__: {}, __list__: {} }; - function is_special(token) { return specials.names().includes(token); } - function is_builtin(token) { return specials.__builtins__.includes(token); } - function is_literal(special) { return specials.type(special) === specials.LITERAL; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- var defined_specials = [["'", new LSymbol('quote'), specials.LITERAL], ['`', new LSymbol('quasiquote'), specials.LITERAL], [',@', new LSymbol('unquote-splicing'), specials.LITERAL], [',', new LSymbol('unquote'), specials.LITERAL], ["'>", new LSymbol('quote-promise'), specials.LITERAL]]; var builtins = defined_specials.map(function (arr) { return arr[0]; @@ -6981,15 +6776,14 @@ }); defined_specials.forEach(function (_ref5) { var _ref6 = _slicedToArray(_ref5, 3), - seq = _ref6[0], - symbol = _ref6[1], - type = _ref6[2]; - + seq = _ref6[0], + symbol = _ref6[1], + type = _ref6[2]; specials.append(seq, symbol, type); - }); // ---------------------------------------------------------------------- + }); + // ---------------------------------------------------------------------- // :: Finite State Machine based incremental Lexer // ---------------------------------------------------------------------- - /* Lexer debugger var DEBUG = false; function log(...args) { @@ -6998,20 +6792,16 @@ } } */ - var Lexer = /*#__PURE__*/function () { function Lexer(input) { var _this4 = this; - var _ref7 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - _ref7$whitespace = _ref7.whitespace, - whitespace = _ref7$whitespace === void 0 ? false : _ref7$whitespace; - + _ref7$whitespace = _ref7.whitespace, + whitespace = _ref7$whitespace === void 0 ? false : _ref7$whitespace; _classCallCheck(this, Lexer); - read_only(this, '__input__', input.replace(/\r/g, '')); - var internals = {}; // hide internals from introspection - + var internals = {}; + // hide internals from introspection ['_i', '_whitespace', '_col', '_newline', '_line', '_state', '_next', '_token', '_prev_char'].forEach(function (name) { Object.defineProperty(_this4, name, { configurable: false, @@ -7029,7 +6819,6 @@ this._state = this._next = this._token = null; this._prev_char = ''; } - _createClass(Lexer, [{ key: "get", value: function get(name) { @@ -7044,14 +6833,11 @@ key: "token", value: function token() { var meta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - if (meta) { var line = this._line; - if (this._whitespace && this._token === '\n') { --line; } - return { token: this._token, col: this._col, @@ -7059,29 +6845,23 @@ line: line }; } - return this._token; } }, { key: "peek", value: function peek() { var meta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; - if (this._i >= this.__input__.length) { return eof; } - if (this._token) { return this.token(meta); } - var found = this.next_token(); - if (found) { this._token = this.__input__.substring(this._i, this._next); return this.token(meta); } - return eof; } }, { @@ -7096,23 +6876,18 @@ key: "read_line", value: function read_line() { var len = this.__input__.length; - if (this._i >= len) { return eof; } - for (var i = this._i; i < len; ++i) { var _char2 = this.__input__[i]; - if (_char2 === '\n') { var line = this.__input__.substring(this._i, i); - this._i = i + 1; ++this._line; return line; } } - return this.read_rest(); } }, { @@ -7126,25 +6901,18 @@ key: "read_string", value: function read_string(num) { var len = this.__input__.length; - if (this._i >= len) { return eof; } - if (num + this._i >= len) { return this.read_rest(); } - var end = this._i + num; - var result = this.__input__.substring(this._i, end); - var found = result.match(/\n/g); - if (found) { this._line += found.length; } - this._i = end; return result; } @@ -7154,14 +6922,12 @@ if (this._i >= this.__input__.length) { return eof; } - return LCharacter(this.__input__[this._i]); } }, { key: "read_char", value: function read_char() { var _char3 = this.peek_char(); - this.skip_char(); return _char3; } @@ -7177,36 +6943,29 @@ key: "match_rule", value: function match_rule(rule) { var _ref8 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - prev_char = _ref8.prev_char, - _char4 = _ref8["char"], - next_char = _ref8.next_char; - + prev_char = _ref8.prev_char, + _char4 = _ref8["char"], + next_char = _ref8.next_char; var _rule = _slicedToArray(rule, 4), - re = _rule[0], - prev_re = _rule[1], - next_re = _rule[2], - state = _rule[3]; - + re = _rule[0], + prev_re = _rule[1], + next_re = _rule[2], + state = _rule[3]; if (rule.length !== 5) { throw new Error("Lexer: Invalid rule of length ".concat(rule.length)); } - if (!_char4.match(re)) { return false; } - if (!match_or_null(prev_re, prev_char)) { return false; } - if (!match_or_null(next_re, next_char)) { return false; } - if (state !== this._state) { return false; } - return true; } }, { @@ -7215,32 +6974,26 @@ if (this._i >= this.__input__.length) { return false; } - var start = true; - loop: for (var i = this._i, len = this.__input__.length; i < len; ++i) { var _char5 = this.__input__[i]; var prev_char = this.__input__[i - 1] || ''; var next_char = this.__input__[i + 1] || ''; - if (_char5 === '\n') { ++this._line; var newline = this._newline; - if (this._state === null) { // keep beginning of the newline to calculate col // we don't want to check inside the token (e.g. strings) this._newline = i + 1; } - if (this._whitespace && this._state === null) { this._next = i + 1; this._col = this._i - newline; return true; } - } // skip leading spaces - - + } + // skip leading spaces if (start && this._state === null && _char5.match(/\s/)) { if (this._whitespace) { if (!next_char.match(/\s/)) { @@ -7255,16 +7008,12 @@ continue; } } - start = false; - var _iterator4 = _createForOfIteratorHelper(Lexer.rules), - _step4; - + _step4; try { for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { var rule = _step4.value; - if (this.match_rule(rule, { prev_char: prev_char, "char": _char5, @@ -7273,14 +7022,12 @@ // change state to null if end of the token var next_state = rule[rule.length - 1]; this._state = next_state; - if (this._state === null) { this._next = i + 1; this._col = this._i - this._newline; return true; - } // token is activated - - + } + // token is activated continue loop; } } @@ -7289,54 +7036,42 @@ } finally { _iterator4.f(); } - if (this._state !== null) { // collect char in token continue loop; - } // no rule for token - - + } + // no rule for token var line = this.__input__.split('\n')[this._line]; - throw new Error("Invalid Syntax at line ".concat(this._line, "\n").concat(line)); } } }]); - return Lexer; }(); // ---------------------------------------------------------------------- // TODO: cache the rules creation or whole list // ---------------------------------------------------------------------- - - Lexer.symbol_rule = function symbol_rule(string, symbol) { var rules = Lexer.literal_rule(string, symbol, Lexer.boundary, /\S/); return rules.concat([[/\S/, /\S/, Lexer.boundary, null, null], [/\S/, /\S/, null, null, Lexer.symbol], [/\S/, null, Lexer.boundary, Lexer.symbol, null]]); - }; // ---------------------------------------------------------------------- + }; + // ---------------------------------------------------------------------- // State rule for literal symbol // ---------------------------------------------------------------------- - - Lexer.literal_rule = function literal_rule(string, symbol) { var p_re = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; var n_re = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; - if (string.length === 0) { throw new Error('Lexer: invalid literal rule'); } - if (string.length === 1) { return [[string, p_re, n_re, null, null]]; } - var rules = []; - for (var i = 0, len = string.length; i < len; ++i) { var rule = []; rule.push(string[i]); rule.push(string[i - 1] || p_re); rule.push(string[i + 1] || n_re); - if (i === 0) { rule.push(null); rule.push(symbol); @@ -7347,14 +7082,11 @@ rule.push(symbol); rule.push(symbol); } - rules.push(rule); } - return rules; - }; // ---------------------------------------------------------------------- - - + }; + // ---------------------------------------------------------------------- Lexer.string = Symbol["for"]('string'); Lexer.string_escape = Symbol["for"]('string_escape'); Lexer.symbol = Symbol["for"]('symbol'); @@ -7368,61 +7100,69 @@ Lexer.b_comment = Symbol["for"]('b_comment'); Lexer.i_comment = Symbol["for"]('i_comment'); Lexer.l_datum = Symbol["for"]('l_datum'); - Lexer.dot = Symbol["for"]('dot'); // ---------------------------------------------------------------------- - - Lexer.boundary = /^$|[\s()[\]']/; // ---------------------------------------------------------------------- - - Lexer._rules = [// char_re prev_re next_re from_state to_state + Lexer.dot = Symbol["for"]('dot'); + // ---------------------------------------------------------------------- + Lexer.boundary = /^$|[\s()[\]']/; + // ---------------------------------------------------------------------- + Lexer._rules = [ + // char_re prev_re next_re from_state to_state // null as to_state mean that is single char token // string - [/"/, null, null, Lexer.string, null], [/"/, null, null, null, Lexer.string], [/"/, null, null, Lexer.string_escape, Lexer.string], [/\\/, null, null, Lexer.string, Lexer.string_escape], [/./, /\\/, null, Lexer.string_escape, Lexer.string], // hash special symbols, lexer don't need to distinguish those + [/"/, null, null, Lexer.string, null], [/"/, null, null, null, Lexer.string], [/"/, null, null, Lexer.string_escape, Lexer.string], [/\\/, null, null, Lexer.string, Lexer.string_escape], [/./, /\\/, null, Lexer.string_escape, Lexer.string], + // hash special symbols, lexer don't need to distinguish those // we only care if it's not pick up by vectors literals - [/#/, null, /[bdxoeitf]/i, null, Lexer.symbol], // characters - [/#/, null, /\\/, null, Lexer.character], [/\\/, /#/, /\s/, Lexer.character, Lexer.character], [/\\/, /#/, /[()[\]]/, Lexer.character, Lexer.character], [/\s/, /\\/, null, Lexer.character, null], [/\S/, null, Lexer.boundary, Lexer.character, null], // regex - [/#/, Lexer.boundary, /\//, null, Lexer.regex_init], [/./, /\//, null, Lexer.regex_init, Lexer.regex], [/[ \t]/, null, null, Lexer.regex, Lexer.regex], [/\[/, null, null, Lexer.regex, Lexer.regex_class], [/\]/, /[^\\]/, null, Lexer.regex_class, Lexer.regex], [/[()[\]]/, null, null, Lexer.regex, Lexer.regex], [/\//, /\\/, null, Lexer.regex, Lexer.regex], [/\//, /[^#]/, Lexer.boundary, Lexer.regex, null], [/[gimyus]/, /\//, Lexer.boundary, Lexer.regex, null], [/[gimyus]/, /\//, /[gimyus]/, Lexer.regex, Lexer.regex], [/[gimyus]/, /[gimyus]/, Lexer.boundary, Lexer.regex, null], // comment - [/;/, /^$|[^#]/, null, null, Lexer.comment], [/[\s\S]/, null, /\n/, Lexer.comment, null], [/\s/, null, null, Lexer.comment, Lexer.comment], // block comment - [/#/, null, /\|/, null, Lexer.b_comment], [/\s/, null, null, Lexer.b_comment, Lexer.b_comment], [/#/, /\|/, null, Lexer.b_comment, null], // inline commentss - [/#/, null, /;/, null, Lexer.i_comment], [/;/, /#/, null, Lexer.i_comment, null], // datum label - [/#/, null, /[0-9]/, null, Lexer.l_datum], [/=/, /[0-9]/, null, Lexer.l_datum, null], [/#/, /[0-9]/, null, Lexer.l_datum, null], // for dot comma `(a .,b) - [/\./, Lexer.boundary, /,/, null, null], // block symbols - [/\|/, null, null, null, Lexer.b_symbol], [/\s/, null, null, Lexer.b_symbol, Lexer.b_symbol], [/\|/, null, Lexer.boundary, Lexer.b_symbol, null]]; // ---------------------------------------------------------------------- - - Lexer._brackets = [[/[()[\]]/, null, null, null, null]]; // ---------------------------------------------------------------------- + [/#/, null, /[bdxoeitf]/i, null, Lexer.symbol], + // characters + [/#/, null, /\\/, null, Lexer.character], [/\\/, /#/, /\s/, Lexer.character, Lexer.character], [/\\/, /#/, /[()[\]]/, Lexer.character, Lexer.character], [/\s/, /\\/, null, Lexer.character, null], [/\S/, null, Lexer.boundary, Lexer.character, null], + // regex + [/#/, Lexer.boundary, /\//, null, Lexer.regex_init], [/./, /\//, null, Lexer.regex_init, Lexer.regex], [/[ \t]/, null, null, Lexer.regex, Lexer.regex], [/\[/, null, null, Lexer.regex, Lexer.regex_class], [/\]/, /[^\\]/, null, Lexer.regex_class, Lexer.regex], [/[()[\]]/, null, null, Lexer.regex, Lexer.regex], [/\//, /\\/, null, Lexer.regex, Lexer.regex], [/\//, /[^#]/, Lexer.boundary, Lexer.regex, null], [/[gimyus]/, /\//, Lexer.boundary, Lexer.regex, null], [/[gimyus]/, /\//, /[gimyus]/, Lexer.regex, Lexer.regex], [/[gimyus]/, /[gimyus]/, Lexer.boundary, Lexer.regex, null], + // comment + [/;/, /^$|[^#]/, null, null, Lexer.comment], [/[\s\S]/, null, /\n/, Lexer.comment, null], [/\s/, null, null, Lexer.comment, Lexer.comment], + // block comment + [/#/, null, /\|/, null, Lexer.b_comment], [/\s/, null, null, Lexer.b_comment, Lexer.b_comment], [/#/, /\|/, null, Lexer.b_comment, null], + // inline commentss + [/#/, null, /;/, null, Lexer.i_comment], [/;/, /#/, null, Lexer.i_comment, null], + // datum label + [/#/, null, /[0-9]/, null, Lexer.l_datum], [/=/, /[0-9]/, null, Lexer.l_datum, null], [/#/, /[0-9]/, null, Lexer.l_datum, null], + // for dot comma `(a .,b) + [/\./, Lexer.boundary, /,/, null, null], + // block symbols + [/\|/, null, null, null, Lexer.b_symbol], [/\s/, null, null, Lexer.b_symbol, Lexer.b_symbol], [/\|/, null, Lexer.boundary, Lexer.b_symbol, null]]; + // ---------------------------------------------------------------------- + Lexer._brackets = [[/[()[\]]/, null, null, null, null]]; + // ---------------------------------------------------------------------- // :: symbols should be matched last // ---------------------------------------------------------------------- - - Lexer._symbol_rules = [[/\S/, Lexer.boundary, Lexer.boundary, null, null], [/\S/, Lexer.boundary, null, null, Lexer.symbol], [/\S/, null, Lexer.boundary, null, null], [/\S/, null, null, null, Lexer.symbol], [/\S/, null, Lexer.boundary, Lexer.symbol, null]]; // ---------------------------------------------------------------------- + Lexer._symbol_rules = [[/\S/, Lexer.boundary, Lexer.boundary, null, null], [/\S/, Lexer.boundary, null, null, Lexer.symbol], [/\S/, null, Lexer.boundary, null, null], [/\S/, null, null, null, Lexer.symbol], [/\S/, null, Lexer.boundary, Lexer.symbol, null]]; + // ---------------------------------------------------------------------- // :: Dynamic getter or Lexer state rules, parser uses this // :: so user code can modify Lexer using syntax extensions // ---------------------------------------------------------------------- - Lexer._cache = { valid: false, rules: null - }; // ---------------------------------------------------------------------- - + }; + // ---------------------------------------------------------------------- specials.on(['remove', 'append'], function () { Lexer._cache.valid = false; Lexer._cache.rules = null; - }); // ---------------------------------------------------------------------- - + }); + // ---------------------------------------------------------------------- Object.defineProperty(Lexer, 'rules', { get: function get() { if (Lexer._cache.valid) { return Lexer._cache.rules; } - var tokens = specials.names().sort(function (a, b) { return b.length - a.length || a.localeCompare(b); }); var special_rules = tokens.reduce(function (acc, token) { var _specials$get = specials.get(token), - type = _specials$get.type, - special_symbol = _specials$get.symbol; - + type = _specials$get.type, + special_symbol = _specials$get.symbol; var rules; - var symbol; // we need distinct symbols_ for syntax extensions - + var symbol; + // we need distinct symbols_ for syntax extensions if (token[0] === '#') { if (token.length === 1) { symbol = Symbol["for"](token); @@ -7432,44 +7172,38 @@ } else { symbol = special_symbol; } - if (type === specials.SYMBOL) { rules = Lexer.symbol_rule(token, symbol); } else { rules = Lexer.literal_rule(token, symbol); } - return acc.concat(rules); }, []); Lexer._cache.rules = Lexer._rules.concat(Lexer._brackets, special_rules, Lexer._symbol_rules); Lexer._cache.valid = true; return Lexer._cache.rules; } - }); // ---------------------------------------------------------------------- - - function match_or_null(re, _char6) { + }); + // ---------------------------------------------------------------------- + function match_or_null(re, _char6) { return re === null || _char6.match(re); - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // :: Parser inspired by BiwaScheme // :: ref: https://github.com/biwascheme/biwascheme/blob/master/src/system/parser.js // ---------------------------------------------------------------------- - - var Parser = /*#__PURE__*/function () { function Parser(arg) { var _ref9 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - env = _ref9.env, - _ref9$meta = _ref9.meta, - meta = _ref9$meta === void 0 ? false : _ref9$meta, - _ref9$formatter = _ref9.formatter, - formatter = _ref9$formatter === void 0 ? multiline_formatter : _ref9$formatter; - + env = _ref9.env, + _ref9$meta = _ref9.meta, + meta = _ref9$meta === void 0 ? false : _ref9$meta, + _ref9$formatter = _ref9.formatter, + formatter = _ref9$formatter === void 0 ? multiline_formatter : _ref9$formatter; _classCallCheck(this, Parser); - if (arg instanceof LString) { arg = arg.toString(); } - read_only(this, '_formatter', formatter, { hidden: true }); @@ -7477,8 +7211,8 @@ read_only(this, '__env__', env); read_only(this, '_meta', meta, { hidden: true - }); // datum labels - + }); + // datum labels read_only(this, '_refs', [], { hidden: true }); @@ -7488,7 +7222,6 @@ hidden: true }); } - _createClass(Parser, [{ key: "resolve", value: function resolve(name) { @@ -7505,63 +7238,46 @@ while (1) { switch (_context.prev = _context.next) { case 0: - token = this.__lexer__.peek(true); - if (!(token === eof)) { _context.next = 4; break; } - return _context.abrupt("return", eof); - case 4: if (!this.is_comment(token.token)) { _context.next = 7; break; } - this.skip(); return _context.abrupt("continue", 0); - case 7: if (!(token.token === '#;')) { _context.next = 14; break; } - this.skip(); - if (!(this.__lexer__.peek() === eof)) { _context.next = 11; break; } - throw new Error('Lexer: syntax error eof found after comment'); - case 11: _context.next = 13; return this._read_object(); - case 13: return _context.abrupt("continue", 0); - case 14: return _context.abrupt("break", 17); - case 17: token = this._formatter(token); - if (!this._meta) { _context.next = 20; break; } - return _context.abrupt("return", token); - case 20: return _context.abrupt("return", token.token); - case 21: case "end": return _context.stop(); @@ -7569,11 +7285,9 @@ } }, _callee, this); })); - function peek() { return _peek.apply(this, arguments); } - return peek; }() }, { @@ -7597,12 +7311,10 @@ case 0: _context2.next = 2; return this.peek(); - case 2: token = _context2.sent; this.skip(); return _context2.abrupt("return", token); - case 5: case "end": return _context2.stop(); @@ -7610,11 +7322,9 @@ } }, _callee2, this); })); - function read() { return _read.apply(this, arguments); } - return read; }() }, { @@ -7633,22 +7343,18 @@ key: "is_open", value: function is_open(token) { var result = ['(', '['].includes(token); - if (result) { this._state.parentheses++; } - return result; } }, { key: "is_close", value: function is_close(token) { var result = [')', ']'].includes(token); - if (result) { this._state.parentheses--; } - return result; } }, { @@ -7661,71 +7367,54 @@ switch (_context3.prev = _context3.next) { case 0: head = _nil, prev = head; - case 1: - _context3.next = 4; return this.peek(); - case 4: token = _context3.sent; - if (!(token === eof)) { _context3.next = 7; break; } - return _context3.abrupt("break", 27); - case 7: if (!this.is_close(token)) { _context3.next = 10; break; } - this.skip(); return _context3.abrupt("break", 27); - case 10: if (!(token === '.' && head !== _nil)) { _context3.next = 17; break; } - this.skip(); _context3.next = 14; return this._read_object(); - case 14: prev.cdr = _context3.sent; _context3.next = 25; break; - case 17: _context3.t0 = Pair; _context3.next = 20; return this._read_object(); - case 20: _context3.t1 = _context3.sent; _context3.t2 = _nil; cur = new _context3.t0(_context3.t1, _context3.t2); - if (head === _nil) { head = cur; } else { prev.cdr = cur; } - prev = cur; - case 25: _context3.next = 1; break; - case 27: return _context3.abrupt("return", head); - case 28: case "end": return _context3.stop(); @@ -7733,11 +7422,9 @@ } }, _callee3, this); })); - function read_list() { return _read_list.apply(this, arguments); } - return read_list; }() }, { @@ -7751,20 +7438,15 @@ case 0: _context4.next = 2; return this.read(); - case 2: token = _context4.sent; - if (!(token === eof)) { _context4.next = 5; break; } - throw new Error('Parser: Expected token eof found'); - case 5: return _context4.abrupt("return", parse_argument(token)); - case 6: case "end": return _context4.stop(); @@ -7772,11 +7454,9 @@ } }, _callee4, this); })); - function read_value() { return _read_value.apply(this, arguments); } - return read_value; }() }, { @@ -7793,8 +7473,8 @@ throw e; } }); - } // public API that handle R7RS datum labels - + } + // public API that handle R7RS datum labels }, { key: "read_object", value: function () { @@ -7807,24 +7487,18 @@ this.reset(); _context5.next = 3; return this._read_object(); - case 3: object = _context5.sent; - if (object instanceof DatumReference) { object = object.valueOf(); } - if (!this._refs.length) { _context5.next = 7; break; } - return _context5.abrupt("return", this._resolve_object(object)); - case 7: return _context5.abrupt("return", object); - case 8: case "end": return _context5.stop(); @@ -7832,11 +7506,9 @@ } }, _callee5, this); })); - function read_object() { return _read_object2.apply(this, arguments); } - return read_object; }() }, { @@ -7858,7 +7530,6 @@ value: function () { var _resolve_object2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(object) { var _this5 = this; - var result; return _regeneratorRuntime.wrap(function _callee6$(_context6) { while (1) { @@ -7868,34 +7539,27 @@ _context6.next = 2; break; } - return _context6.abrupt("return", object.map(function (item) { return _this5._resolve_object(item); })); - case 2: if (!is_plain_object(object)) { _context6.next = 6; break; } - result = {}; Object.keys(object).forEach(function (key) { result[key] = _this5._resolve_object(object[key]); }); return _context6.abrupt("return", result); - case 6: if (!(object instanceof Pair)) { _context6.next = 8; break; } - return _context6.abrupt("return", this._resolve_pair(object)); - case 8: return _context6.abrupt("return", object); - case 9: case "end": return _context6.stop(); @@ -7903,11 +7567,9 @@ } }, _callee6, this); })); - function _resolve_object(_x3) { return _resolve_object2.apply(this, arguments); } - return _resolve_object; }() }, { @@ -7922,43 +7584,33 @@ _context7.next = 15; break; } - if (!(pair.car instanceof DatumReference)) { _context7.next = 7; break; } - _context7.next = 4; return pair.car.valueOf(); - case 4: pair.car = _context7.sent; _context7.next = 8; break; - case 7: this._resolve_pair(pair.car); - case 8: if (!(pair.cdr instanceof DatumReference)) { _context7.next = 14; break; } - _context7.next = 11; return pair.cdr.valueOf(); - case 11: pair.cdr = _context7.sent; _context7.next = 15; break; - case 14: this._resolve_pair(pair.cdr); - case 15: return _context7.abrupt("return", pair); - case 16: case "end": return _context7.stop(); @@ -7966,11 +7618,9 @@ } }, _callee7, this); })); - function _resolve_pair(_x4) { return _resolve_pair2.apply(this, arguments); } - return _resolve_pair; }() }, { @@ -7984,23 +7634,18 @@ case 0: _context8.next = 2; return this.peek(); - case 2: token = _context8.sent; - if (!(token === eof)) { _context8.next = 5; break; } - return _context8.abrupt("return", token); - case 5: if (!is_special(token)) { _context8.next = 39; break; } - // Built-in parser extensions are mapping short symbols to longer symbols // that can be function or macro. Parser doesn't care // if it's not built-in and the extension can be macro or function. @@ -8013,132 +7658,98 @@ this.skip(); _context8.next = 11; return this._read_object(); - case 11: object = _context8.sent; - if (builtin) { _context8.next = 26; break; } - extension = this.__env__.get(special.symbol); - if (!(typeof extension === 'function')) { _context8.next = 26; break; } - if (!is_literal(token)) { _context8.next = 19; break; } - return _context8.abrupt("return", extension.call(this.__env__, object)); - case 19: if (!(object === _nil)) { _context8.next = 23; break; } - return _context8.abrupt("return", extension.apply(this.__env__)); - case 23: if (!(object instanceof Pair)) { _context8.next = 25; break; } - return _context8.abrupt("return", extension.apply(this.__env__, object.to_array(false))); - case 25: throw new Error('Parse Error: Invalid parser extension ' + "invocation ".concat(special.symbol)); - case 26: if (is_literal(token)) { expr = new Pair(special.symbol, new Pair(object, _nil)); } else { expr = new Pair(special.symbol, object); - } // Built-in parser extensions just expand into lists like 'x ==> (quote x) - - + } + // Built-in parser extensions just expand into lists like 'x ==> (quote x) if (!builtin) { _context8.next = 29; break; } - return _context8.abrupt("return", expr); - case 29: if (!(extension instanceof Macro)) { _context8.next = 38; break; } - _context8.next = 32; return this.evaluate(expr); - case 32: result = _context8.sent; - if (!(result instanceof Pair || result instanceof LSymbol)) { _context8.next = 35; break; } - return _context8.abrupt("return", Pair.fromArray([LSymbol('quote'), result])); - case 35: return _context8.abrupt("return", result); - case 38: throw new Error('Parse Error: invalid parser extension: ' + special.symbol); - case 39: ref = this.match_datum_ref(token); - if (!(ref !== null)) { _context8.next = 45; break; } - this.skip(); - if (!this._refs[ref]) { _context8.next = 44; break; } - return _context8.abrupt("return", new DatumReference(ref, this._refs[ref])); - case 44: throw new Error("Parse Error: invalid datum label #".concat(ref, "#")); - case 45: ref_label = this.match_datum_label(token); - if (!(ref_label !== null)) { _context8.next = 52; break; } - this.skip(); this._refs[ref_label] = this._read_object(); return _context8.abrupt("return", this._refs[ref_label]); - case 52: if (!this.is_open(token)) { _context8.next = 57; break; } - this.skip(); return _context8.abrupt("return", this.read_list()); - case 57: return _context8.abrupt("return", this.read_value()); - case 58: case "end": return _context8.stop(); @@ -8146,37 +7757,29 @@ } }, _callee8, this); })); - function _read_object() { return _read_object3.apply(this, arguments); } - return _read_object; }() }]); - return Parser; }(); // ---------------------------------------------------------------------- // :: Parser helper that handles circular list structures // :: using datum labels // ---------------------------------------------------------------------- - - var DatumReference = /*#__PURE__*/function () { function DatumReference(name, data) { _classCallCheck(this, DatumReference); - this.name = name; this.data = data; } - _createClass(DatumReference, [{ key: "valueOf", value: function valueOf() { return this.data; } }]); - return DatumReference; }(); // ---------------------------------------------------------------------- // :: Tokens are the array of strings from tokenizer @@ -8185,13 +7788,9 @@ // :: or macro assigned to symbol, this function is async because // :: it evaluates the code, from parser extensions, that may return a promise. // ---------------------------------------------------------------------- - - function parse(_x, _x2) { return _parse.apply(this, arguments); } // ---------------------------------------------------------------------- - - function _parse() { _parse = _wrapAsyncGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(arg, env) { var parser, expr; @@ -8208,38 +7807,28 @@ env = user_env; } } - parser = new Parser(arg, { env: env }); - case 2: - _context9.next = 5; return _awaitAsyncGenerator(parser.read_object()); - case 5: expr = _context9.sent; - if (!parser.balanced()) { parser.ballancing_error(expr); } - if (!(expr === eof)) { _context9.next = 9; break; } - return _context9.abrupt("break", 13); - case 9: _context9.next = 11; return expr; - case 11: _context9.next = 2; break; - case 13: case "end": return _context9.stop(); @@ -8249,66 +7838,53 @@ })); return _parse.apply(this, arguments); } - function unpromise(value) { var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (x) { return x; }; var error = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; - if (is_promise(value)) { var ret = value.then(fn); - if (error === null) { return ret; } else { return ret["catch"](error); } } - if (value instanceof Array) { return unpromise_array(value, fn, error); } - if (is_plain_object(value)) { return unpromise_object(value, fn, error); } - return fn(value); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function unpromise_array(array, fn, error) { if (array.find(is_promise)) { return unpromise(promise_all(array), function (arr) { if (Object.isFrozen(array)) { Object.freeze(arr); } - return fn(arr); }, error); } - return fn(array); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function unpromise_object(object, fn, error) { var keys = Object.keys(object); var values = [], - anyPromise = []; + anyPromise = []; var i = keys.length; - while (i--) { var key = keys[i]; var value = object[key]; values[i] = value; - if (is_promise(value)) { anyPromise.push(value); } } - if (anyPromise.length) { return unpromise(promise_all(values), function (values) { var result = {}; @@ -8316,45 +7892,36 @@ var key = keys[i]; result[key] = value; }); - if (Object.isFrozen(object)) { Object.freeze(result); } - return result; }, error); } - return fn(object); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function read_only(object, property, value) { var _ref10 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}, - _ref10$hidden = _ref10.hidden, - hidden = _ref10$hidden === void 0 ? false : _ref10$hidden; - + _ref10$hidden = _ref10.hidden, + hidden = _ref10$hidden === void 0 ? false : _ref10$hidden; Object.defineProperty(object, property, { value: value, configurable: true, enumerable: !hidden }); - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // :: Function similar to Array.from that work on async iterators // ---------------------------------------------------------------------- - - function uniterate_async(_x5) { return _uniterate_async.apply(this, arguments); } // ---------------------------------------------------------------------- // :: Function that return matcher function that match string against string // ---------------------------------------------------------------------- - - function _uniterate_async() { _uniterate_async = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(object) { var result, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, item; - return _regeneratorRuntime.wrap(function _callee22$(_context22) { while (1) { switch (_context22.prev = _context22.next) { @@ -8364,66 +7931,50 @@ _didIteratorError = false; _context22.prev = 3; _iterator = _asyncIterator(object); - case 5: _context22.next = 7; return _iterator.next(); - case 7: if (!(_iteratorAbruptCompletion = !(_step = _context22.sent).done)) { _context22.next = 13; break; } - item = _step.value; result.push(item); - case 10: _iteratorAbruptCompletion = false; _context22.next = 5; break; - case 13: _context22.next = 19; break; - case 15: _context22.prev = 15; _context22.t0 = _context22["catch"](3); _didIteratorError = true; _iteratorError = _context22.t0; - case 19: _context22.prev = 19; _context22.prev = 20; - if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) { _context22.next = 24; break; } - _context22.next = 24; return _iterator["return"](); - case 24: _context22.prev = 24; - if (!_didIteratorError) { _context22.next = 27; break; } - throw _iteratorError; - case 27: return _context22.finish(24); - case 28: return _context22.finish(19); - case 29: return _context22.abrupt("return", result); - case 30: case "end": return _context22.stop(); @@ -8433,7 +7984,6 @@ })); return _uniterate_async.apply(this, arguments); } - function matcher(name, arg) { if (arg instanceof RegExp) { return function (x) { @@ -8443,15 +7993,13 @@ // it will always be function return arg; } - throw new Error('Invalid matcher'); - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // :: Documentation decorator to LIPS functions if lines starts with : // :: they are ignored (not trimmed) otherwise it trims so // :: so you can have indent in source code // ---------------------------------------------------------------------- - - function doc(name, fn, doc, dump) { if (typeof name !== 'string') { fn = arguments[0]; @@ -8459,7 +8007,6 @@ dump = arguments[2]; name = null; } - if (doc) { if (dump) { fn.__doc__ = doc; @@ -8467,88 +8014,71 @@ fn.__doc__ = trim_lines(doc); } } - if (name) { fn.__name__ = name; } else if (fn.name && !is_lambda(fn)) { fn.__name__ = fn.name; } - return fn; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function trim_lines(string) { return string.split('\n').map(function (line) { return line.trim(); }).join('\n'); - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // return last S-Expression // @param tokens - array of tokens (objects from tokenizer or strings) // @param sexp - number of expression to look behind // ---------------------------------------------------------------------- - - function previousSexp(tokens) { var sexp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; var i = tokens.length; - if (sexp <= 0) { throw Error("previousSexp: Invalid argument sexp = ".concat(sexp)); } - outer: while (sexp-- && i >= 0) { var count = 1; - while (count > 0) { var token = tokens[--i]; - if (!token) { break outer; } - if (token === '(' || token.token === '(') { count--; } else if (token === ')' || token.token === ')') { count++; } } - i--; } - return tokens.slice(i + 1); - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // :: Find the number of spaces in line // ---------------------------------------------------------------------- - - function lineIndent(tokens) { if (!tokens || !tokens.length) { return 0; } - var i = tokens.length; - if (tokens[i - 1].token === '\n') { return 0; } - while (--i) { if (tokens[i].token === '\n') { var token = (tokens[i + 1] || {}).token; - if (token) { return token.length; } } } - return 0; - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // :: Token based pattern matching (used by formatter) // ---------------------------------------------------------------------- - /* Function nested_pattern(pattern) { return pattern instanceof Array || @@ -8556,11 +8086,8 @@ } */ // ---------------------------------------------------------------------- - - function match(pattern, input) { return inner_match(pattern, input) === input.length; - function inner_match(pattern, input) { /* function empty_match() { @@ -8581,14 +8108,11 @@ */ function get_first_match(patterns, input) { var _iterator5 = _createForOfIteratorHelper(patterns), - _step5; - + _step5; try { for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) { var _p = _step5.value; - var _m = inner_match(_p, input); - if (_m !== -1) { return _m; } @@ -8598,57 +8122,44 @@ } finally { _iterator5.f(); } - return -1; } - function not_symbol_match() { return pattern[p] === Symbol["for"]('symbol') && !is_symbol_string(input[i]); } - function match_next() { var next_pattern = pattern[p + 1]; var next_input = input[i + 1]; - if (next_pattern !== undefined && next_input !== undefined) { return inner_match([next_pattern], [next_input]); } } - var p = 0; var glob = {}; - for (var i = 0; i < input.length; ++i) { if (typeof pattern[p] === 'undefined') { return i; } - if (pattern[p] instanceof Pattern) { var m; - if (['+', '*'].includes(pattern[p].flag)) { while (i < input.length) { m = get_first_match(pattern[p].patterns, input.slice(i)); - if (m === -1) { break; } - i += m; } - i -= 1; p++; continue; } else if (pattern[p].flag === '?') { m = get_first_match(pattern[p].patterns, input.slice(i)); - if (m === -1) { i -= 2; // if not found use same test on same input again } else { p++; } - continue; } } else if (pattern[p] instanceof RegExp) { @@ -8662,14 +8173,13 @@ } else if (_typeof(pattern[p]) === 'symbol') { if (pattern[p] === Symbol["for"]('*')) { // ignore S-expressions inside for case when next pattern is ) - glob[p] = glob[p] || 0; //var zero_match = empty_match(); - + glob[p] = glob[p] || 0; + //var zero_match = empty_match(); if (['(', '['].includes(input[i])) { glob[p]++; } else if ([')', ']'].includes(input[i])) { glob[p]--; } - if (typeof pattern[p + 1] !== 'undefined' && glob[p] === 0 && match_next() === -1 || glob[p] > 0) { continue; } @@ -8678,67 +8188,56 @@ } } else if (pattern[p] instanceof Array) { var inc = inner_match(pattern[p], input.slice(i)); - if (inc === -1 || inc + i > input.length) { // if no more input it's not match return -1; } - i += inc - 1; p++; continue; } else { return -1; } - p++; } - if (pattern.length !== p) { // if there are still patterns it's not match return -1; } - return input.length; } - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // :: Code formatter class // :: based on http://community.schemewiki.org/?scheme-style // :: and GNU Emacs scheme mode // :: it rely on meta data from tokenizer function // ---------------------------------------------------------------------- - - function Formatter(code) { this.__code__ = code.replace(/\r/g, ''); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- Formatter.defaults = { offset: 0, indent: 2, exceptions: { - specials: [ - /* eslint-disable max-len */ + specials: [/* eslint-disable max-len */ /^(?:#:)?(?:define(?:-values|-syntax|-macro|-class|-record-type)?|(?:call-with-(?:input-file|output-file|port))|lambda|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax|\*)?)$/ - /* eslint-enable */ - ], + /* eslint-enable */], shift: { 1: ['&', '#'] } } }; - Formatter.match = match; // ---------------------------------------------------------------------- + Formatter.match = match; + // ---------------------------------------------------------------------- // :: Return indent for next line // ---------------------------------------------------------------------- - Formatter.prototype._options = function _options(options) { var defaults = Formatter.defaults; - if (typeof options === 'undefined') { return Object.assign({}, defaults); } - var exceptions = options && options.exceptions || {}; var specials = exceptions.specials || []; var shift = exceptions.shift || { @@ -8752,39 +8251,32 @@ }) } }); - }; // ---------------------------------------------------------------------- - - + }; + // ---------------------------------------------------------------------- Formatter.prototype.indent = function indent(options) { var tokens = tokenize(this.__code__, true); return this._indent(tokens, options); - }; // ---------------------------------------------------------------------- - - + }; + // ---------------------------------------------------------------------- Formatter.exception_shift = function (token, settings) { function match(list) { if (!list.length) { return false; } - if (list.indexOf(token) !== -1) { return true; } else { var regexes = list.filter(function (s) { return s instanceof RegExp; }); - if (!regexes.length) { return false; } - var _iterator6 = _createForOfIteratorHelper(regexes), - _step6; - + _step6; try { for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) { var re = _step6.value; - if (token.match(re)) { return true; } @@ -8795,48 +8287,37 @@ _iterator6.f(); } } - return false; } - if (match(settings.exceptions.specials)) { return settings.indent; } - var shift = settings.exceptions.shift; - for (var _i2 = 0, _Object$entries = Object.entries(shift); _i2 < _Object$entries.length; _i2++) { var _Object$entries$_i = _slicedToArray(_Object$entries[_i2], 2), - indent = _Object$entries$_i[0], - tokens = _Object$entries$_i[1]; - + indent = _Object$entries$_i[0], + tokens = _Object$entries$_i[1]; if (match(tokens)) { return +indent; } } - return -1; - }; // ---------------------------------------------------------------------- - - + }; + // ---------------------------------------------------------------------- Formatter.prototype._indent = function _indent(tokens, options) { var settings = this._options(options); - var spaces = lineIndent(tokens); - var sexp = previousSexp(tokens); // one character before S-Expression - + var sexp = previousSexp(tokens); + // one character before S-Expression var before_sexpr = tokens[tokens.length - sexp.length - 1]; var last = tokens[tokens.length - 1]; - if (last.token.match(/^"[\S\s]+[^"]$/)) { return spaces + settings.indent; } - if (sexp && sexp.length) { if (sexp[0].line > 0) { settings.offset = 0; } - if (sexp.toString() === tokens.toString() && balanced(sexp)) { return settings.offset + sexp[0].col; } else if (sexp.length === 1) { @@ -8844,19 +8325,15 @@ } else { // search for token before S-Expression for case like #(10 or &(:x var exception = -1; - if (before_sexpr) { var shift = Formatter.exception_shift(before_sexpr.token, settings); - if (shift !== -1) { exception = shift; } } - if (exception === -1) { exception = Formatter.exception_shift(sexp[1].token, settings); } - if (exception !== -1) { return settings.offset + sexp[0].col + exception; } else if (sexp[0].line < sexp[1].line) { @@ -8865,16 +8342,13 @@ if (sexp[1].token === '(' || sexp[1].token === '[') { return settings.offset + sexp[1].col; } - return settings.offset + sexp[3].col; } else if (sexp[0].line === sexp[1].line) { return settings.offset + settings.indent + sexp[0].col; } else { var next_tokens = sexp.slice(2); - for (var i = 0; i < next_tokens.length; ++i) { var token = next_tokens[i]; - if (token.token.trim()) { return token.col; } @@ -8884,86 +8358,74 @@ } else { return 0; } - return spaces + settings.indent; - }; // ---------------------------------------------------------------------- - - + }; + // ---------------------------------------------------------------------- function Ahead(pattern) { this.pattern = pattern; - } // TODO: make it print - - + } + // TODO: make it print Ahead.prototype.toString = function () { return "#"); - }; // ---------------------------------------------------------------------- - - + }; + // ---------------------------------------------------------------------- Ahead.prototype.match = function (string) { return string.match(this.pattern); - }; // ---------------------------------------------------------------------- + }; + // ---------------------------------------------------------------------- // Pattern has any number of patterns that it matches using OR operator // Pattern is in form of array with regular expressions // ---------------------------------------------------------------------- - - function Pattern() { for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { args[_key3] = arguments[_key3]; } - var flag = args.pop(); this.patterns = args; this.flag = flag; } - Pattern.prototype.toString = function () { var patterns = this.patterns.map(function (x) { return toString(x); }).join('|'); return "#"); - }; // ---------------------------------------------------------------------- - - + }; + // ---------------------------------------------------------------------- Formatter.Pattern = Pattern; Formatter.Ahead = Ahead; var p_o = /^[[(]$/; var p_e = /^[\])]$/; var not_p = /[^()[\]]/; - var not_close = new Ahead(/[^)\]]/); //const open = new Ahead(/[([]/); - + var not_close = new Ahead(/[^)\]]/); + //const open = new Ahead(/[([]/); var glob = Symbol["for"]('*'); var sexp_or_atom = new Pattern([p_o, glob, p_e], [not_p], '+'); var sexp = new Pattern([p_o, glob, p_e], '+'); var symbol = new Pattern([Symbol["for"]('symbol')], '?'); var symbols = new Pattern([Symbol["for"]('symbol')], '*'); var identifiers = [p_o, symbols, p_e]; - var let_value = new Pattern([p_o, Symbol["for"]('symbol'), glob, p_e], '+'); // rules for breaking S-Expressions into lines - + var let_value = new Pattern([p_o, Symbol["for"]('symbol'), glob, p_e], '+'); + // rules for breaking S-Expressions into lines var def_lambda_re = keywords_re('define', 'lambda', 'define-macro', 'syntax-rules'); /* eslint-disable max-len */ - var non_def = /^(?!.*\b(?:[()[\]]|define(?:-macro)?|let(?:\*|rec|-env|-syntax|)?|lambda|syntax-rules)\b).*$/; /* eslint-enable */ - - var let_re = /^(?:#:)?(let(?:\*|rec|-env|-syntax)?)$/; // match keyword if it's normal token or gensym (prefixed with #:) - + var let_re = /^(?:#:)?(let(?:\*|rec|-env|-syntax)?)$/; + // match keyword if it's normal token or gensym (prefixed with #:) function keywords_re() { for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { args[_key4] = arguments[_key4]; } - return new RegExp("^(?:#:)?(?:".concat(args.join('|'), ")$")); - } // line breaking rules - - - Formatter.rules = [[[sexp], 0, not_close], [[p_o, keywords_re('begin', 'cond-expand')], 1], [[p_o, let_re, symbol, p_o, let_value, p_e], 1], [[p_o, let_re, symbol, sexp_or_atom], 1, not_close], [[p_o, let_re, p_o, let_value], 1, not_close], //--[[p_o, keywords_re('define-syntax'), /.+/], 1], - [[p_o, non_def, new Pattern([/[^()[\]]/], '+'), sexp], 1, not_close], [[p_o, sexp], 1, not_close], [[p_o, not_p, sexp], 1, not_close], [[p_o, keywords_re('lambda', 'if'), not_p], 1, not_close], [[p_o, keywords_re('while'), not_p, sexp], 1, not_close], [[p_o, keywords_re('if'), not_p, glob], 1], [[p_o, def_lambda_re, identifiers], 0, not_close], [[p_o, def_lambda_re, identifiers, string_re], 0, not_close], [[p_o, def_lambda_re, identifiers, string_re, sexp], 0, not_close], [[p_o, def_lambda_re, identifiers, sexp], 0, not_close]]; // ---------------------------------------------------------------------- - + } + // line breaking rules + Formatter.rules = [[[sexp], 0, not_close], [[p_o, keywords_re('begin', 'cond-expand')], 1], [[p_o, let_re, symbol, p_o, let_value, p_e], 1], [[p_o, let_re, symbol, sexp_or_atom], 1, not_close], [[p_o, let_re, p_o, let_value], 1, not_close], + //--[[p_o, keywords_re('define-syntax'), /.+/], 1], + [[p_o, non_def, new Pattern([/[^()[\]]/], '+'), sexp], 1, not_close], [[p_o, sexp], 1, not_close], [[p_o, not_p, sexp], 1, not_close], [[p_o, keywords_re('lambda', 'if'), not_p], 1, not_close], [[p_o, keywords_re('while'), not_p, sexp], 1, not_close], [[p_o, keywords_re('if'), not_p, glob], 1], [[p_o, def_lambda_re, identifiers], 0, not_close], [[p_o, def_lambda_re, identifiers, string_re], 0, not_close], [[p_o, def_lambda_re, identifiers, string_re, sexp], 0, not_close], [[p_o, def_lambda_re, identifiers, sexp], 0, not_close]]; + // ---------------------------------------------------------------------- Formatter.prototype["break"] = function () { - var code = this.__code__.replace(/\n[ \t]*/g, '\n ').replace(/^\s+/, ''); // function that work when calling tokenize with meta data or not - - + var code = this.__code__.replace(/\n[ \t]*/g, '\n ').replace(/^\s+/, ''); + // function that work when calling tokenize with meta data or not var token = function token(t) { if (t.token.match(string_re) || t.token.match(re_re)) { return t.token; @@ -8971,54 +8433,46 @@ return t.token.replace(/\s+/, ' '); } }; - var first_token_index = function first_token_index(tokens) { for (var i = tokens.length; i--;) { var _token = tokens[i]; - if (_token.trim() && !is_special(_token)) { return tokens.length - i - 1; } } - }; // Tokenize is part of the parser/lexer that split code into tokens and includes + }; + // Tokenize is part of the parser/lexer that split code into tokens and includes // meta data like number of column or line - - var tokens = tokenize(code, true).map(token).filter(function (t) { return t !== '\n'; }); var rules = Formatter.rules; - outer: for (var i = 1; i < tokens.length; ++i) { if (!tokens[i].trim()) { continue; } - var sub = tokens.slice(0, i); var sexp = {}; rules.map(function (b) { return b[1]; }).forEach(function (count) { - count = count.valueOf(); // some patterns require to check what was before like + count = count.valueOf(); + // some patterns require to check what was before like // if inside let binding - if (count > 0 && !sexp[count]) { sexp[count] = previousSexp(sub, count); } }); - var _iterator7 = _createForOfIteratorHelper(rules), - _step7; - + _step7; try { for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) { var _step7$value = _slicedToArray(_step7.value, 3), - pattern = _step7$value[0], - count = _step7$value[1], - ext = _step7$value[2]; - - count = count.valueOf(); // 0 count mean ignore the previous S-Expression - + pattern = _step7$value[0], + count = _step7$value[1], + ext = _step7$value[2]; + count = count.valueOf(); + // 0 count mean ignore the previous S-Expression var test_sexp = count > 0 ? sexp[count] : sub; var input = test_sexp.filter(function (t) { return t.trim() && !is_special(t); @@ -9028,10 +8482,8 @@ var next = tokens.slice(i).find(function (t) { return t.trim() && !is_special(t); }); - if (m && (ext instanceof Ahead && ext.match(next) || !ext)) { var index = i - inc; - if (tokens[index] !== '\n') { if (!tokens[index].trim()) { tokens[index] = '\n'; @@ -9040,7 +8492,6 @@ i++; } } - i += inc; continue outer; } @@ -9051,48 +8502,37 @@ _iterator7.f(); } } - this.__code__ = tokens.join(''); return this; - }; // ---------------------------------------------------------------------- - - + }; + // ---------------------------------------------------------------------- Formatter.prototype._spaces = function (i) { return new Array(i + 1).join(' '); - }; // ---------------------------------------------------------------------- + }; + // ---------------------------------------------------------------------- // :: Auto formatting of code, it requires to have newlines // ---------------------------------------------------------------------- - - Formatter.prototype.format = function format(options) { // prepare code with single space after newline // so we have space token to align var code = this.__code__.replace(/[ \t]*\n[ \t]*/g, '\n '); - var tokens = tokenize(code, true); - var settings = this._options(options); - var indent = 0; var offset = 0; - for (var i = 0; i < tokens.length; ++i) { var token = tokens[i]; - if (token.token === '\n') { indent = this._indent(tokens.slice(0, i), settings); offset += indent; - if (tokens[i + 1]) { - tokens[i + 1].token = this._spaces(indent); // because we have single space as initial indent - + tokens[i + 1].token = this._spaces(indent); + // because we have single space as initial indent indent--; offset--; - for (var j = i + 2; j < tokens.length; ++j) { tokens[j].offset += offset; tokens[j].col += indent; - if (tokens[j].token === '\n') { // ++i is called after the loop i = j - 1; @@ -9102,7 +8542,6 @@ } } } - return tokens.map(function (token) { if (token.token.match(string_re)) { if (token.token.match(/\n/)) { @@ -9113,28 +8552,23 @@ })).join('\n'); } } - return token.token; }).join(''); - }; // ---------------------------------------------------------------------- + }; + // ---------------------------------------------------------------------- // :: Flatten nested arrays // :: ref: https://stackoverflow.com/a/27282907/387194 // ---------------------------------------------------------------------- - - function flatten(array, mutable) { var toString = Object.prototype.toString; var arrayTypeStr = '[object Array]'; var result = []; var nodes = mutable && array || array.slice(); var node; - if (!array.length) { return result; } - node = nodes.pop(); - do { if (toString.call(node) === arrayTypeStr) { nodes.push.apply(nodes, node); @@ -9142,79 +8576,60 @@ result.push(node); } } while (nodes.length && (node = nodes.pop()) !== undefined); - result.reverse(); // we reverse result to restore the original order - return result; - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // :: Nil constructor with only once instance // ---------------------------------------------------------------------- - - function Nil() {} - Nil.prototype.toString = function () { return '()'; }; - Nil.prototype.valueOf = function () { return undefined; }; - Nil.prototype.serialize = function () { return 0; }; - Nil.prototype.to_object = function () { return {}; }; - Nil.prototype.append = function (x) { return new Pair(x, _nil); }; - Nil.prototype.to_array = function () { return []; }; - - var _nil = new Nil(); // ---------------------------------------------------------------------- + var _nil = new Nil(); + // ---------------------------------------------------------------------- // :: Pair constructor // ---------------------------------------------------------------------- - - function Pair(car, cdr) { if (typeof this !== 'undefined' && this.constructor !== Pair || typeof this === 'undefined') { return new Pair(car, cdr); } - this.car = car; this.cdr = cdr; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function to_array(name, deep) { return function recur(list) { typecheck(name, list, ['pair', 'nil']); - if (list === _nil) { return []; } - var result = []; var node = list; - while (true) { if (node instanceof Pair) { if (node.haveCycles('cdr')) { break; } - var car = node.car; - if (deep && car instanceof Pair) { car = this.get(name).call(this, car); } - result.push(car); node = node.cdr; } else if (node === _nil) { @@ -9223,34 +8638,27 @@ throw new Error("".concat(name, ": can't convert improper list")); } } - return result; }; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- Pair.prototype.flatten = function () { return Pair.fromArray(flatten(this.to_array())); - }; // ---------------------------------------------------------------------- - - + }; + // ---------------------------------------------------------------------- Pair.prototype.length = function () { var len = 0; var node = this; - while (true) { if (!node || node === _nil || !(node instanceof Pair) || node.haveCycles('cdr')) { break; } - len++; node = node.cdr; } - return len; - }; // ---------------------------------------------------------------------- - - + }; + // ---------------------------------------------------------------------- Pair.match = function (obj, item) { if (obj instanceof LSymbol) { return LSymbol.is(obj, item); @@ -9265,64 +8673,53 @@ return Pair.match(x, item); }); } - return false; - }; // ---------------------------------------------------------------------- - - + }; + // ---------------------------------------------------------------------- Pair.prototype.find = function (item) { return Pair.match(this, item); - }; // ---------------------------------------------------------------------- - + }; + // ---------------------------------------------------------------------- Pair.prototype.clone = function () { var deep = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; var visited = new Map(); - function clone(node) { if (node instanceof Pair) { if (visited.has(node)) { return visited.get(node); } - var pair = new Pair(); visited.set(node, pair); - if (deep) { pair.car = clone(node.car); } else { pair.car = node.car; } - pair.cdr = clone(node.cdr); pair[__cycles__] = node[__cycles__]; return pair; } - return node; } - return clone(this); - }; // ---------------------------------------------------------------------- - + }; + // ---------------------------------------------------------------------- Pair.prototype.last_pair = function () { var node = this; - while (true) { if (node.cdr === _nil) { return node; } - node = node.cdr; } - }; // ---------------------------------------------------------------------- - + }; + // ---------------------------------------------------------------------- Pair.prototype.to_array = function () { var deep = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; var result = []; - if (this.car instanceof Pair) { if (deep) { result.push(this.car.to_array()); @@ -9332,43 +8729,33 @@ } else { result.push(this.car.valueOf()); } - if (this.cdr instanceof Pair) { result = result.concat(this.cdr.to_array()); } - return result; - }; // ---------------------------------------------------------------------- - + }; + // ---------------------------------------------------------------------- Pair.fromArray = function (array) { var deep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; var quote = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - if (array instanceof Pair || quote && array instanceof Array && array[__data__]) { return array; } - if (deep === false) { var list = _nil; - for (var _i3 = array.length; _i3--;) { list = new Pair(array[_i3], list); } - return list; } - if (array.length && !(array instanceof Array)) { array = _toConsumableArray(array); } - var result = _nil; var i = array.length; - while (i--) { var car = array[i]; - if (car instanceof Array) { car = Pair.fromArray(car, deep, quote); } else if (typeof car === 'string') { @@ -9376,78 +8763,67 @@ } else if (typeof car === 'number' && !Number.isNaN(car)) { car = LNumber(car); } - result = new Pair(car, result); } - return result; - }; // ---------------------------------------------------------------------- + }; + + // ---------------------------------------------------------------------- // By default to_object was created to create JavaScript objects, // so it uses valueOf to get native values. // Literal parameter was a hack to allow creating LComplex from LIPS code // ---------------------------------------------------------------------- - - Pair.prototype.to_object = function () { var literal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; var node = this; var result = {}; - while (true) { if (node instanceof Pair && node.car instanceof Pair) { var pair = node.car; var name = pair.car; - if (name instanceof LSymbol) { name = name.__name__; } - if (name instanceof LString) { name = name.valueOf(); } - var cdr = pair.cdr; - if (cdr instanceof Pair) { cdr = cdr.to_object(literal); } - if (is_native(cdr)) { if (!literal) { cdr = cdr.valueOf(); } } - result[name] = cdr; node = node.cdr; } else { break; } } - return result; - }; // ---------------------------------------------------------------------- - + }; + // ---------------------------------------------------------------------- Pair.fromPairs = function (array) { return array.reduce(function (list, pair) { return new Pair(new Pair(new LSymbol(pair[0]), pair[1]), list); }, _nil); - }; // ---------------------------------------------------------------------- - + }; + // ---------------------------------------------------------------------- Pair.fromObject = function (obj) { var array = Object.keys(obj).map(function (key) { return [key, obj[key]]; }); return Pair.fromPairs(array); - }; // ---------------------------------------------------------------------- - + }; + // ---------------------------------------------------------------------- Pair.prototype.reduce = function (fn) { var node = this; var result = _nil; - while (true) { if (node !== _nil) { result = fn(result, node.car); @@ -9456,61 +8832,49 @@ break; } } - return result; - }; // ---------------------------------------------------------------------- - + }; + // ---------------------------------------------------------------------- Pair.prototype.reverse = function () { if (this.haveCycles()) { throw new Error("You can't reverse list that have cycles"); } - var node = this; var prev = _nil; - while (node !== _nil) { var next = node.cdr; node.cdr = prev; prev = node; node = next; } - return prev; - }; // ---------------------------------------------------------------------- - + }; + // ---------------------------------------------------------------------- Pair.prototype.transform = function (fn) { - function recur(pair) { if (pair instanceof Pair) { if (pair.replace) { delete pair.replace; return pair; } - var car = fn(pair.car); - if (car instanceof Pair) { car = recur(car); } - var cdr = fn(pair.cdr); - if (cdr instanceof Pair) { cdr = recur(cdr); } - return new Pair(car, cdr); } - return pair; } - return recur(this); - }; // ---------------------------------------------------------------------- - + }; + // ---------------------------------------------------------------------- Pair.prototype.map = function (fn) { if (typeof this.car !== 'undefined') { return new Pair(fn(this.car), this.cdr === _nil ? _nil : this.cdr.map(fn)); @@ -9518,141 +8882,114 @@ return _nil; } }; - - var repr = new Map(); // ---------------------------------------------------------------------- - + var repr = new Map(); + // ---------------------------------------------------------------------- function is_plain_object(object) { return object && _typeof(object) === 'object' && object.constructor === Object; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- var props = Object.getOwnPropertyNames(Array.prototype); var array_methods = []; props.forEach(function (x) { array_methods.push(Array[x], Array.prototype[x]); - }); // ---------------------------------------------------------------------- - + }); + // ---------------------------------------------------------------------- function is_array_method(x) { x = unbind(x); return array_methods.includes(x); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function is_lips_function(x) { return is_function(x) && (is_lambda(x) || x.__doc__); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function user_repr(obj) { var constructor = obj.constructor || Object; var plain_object = is_plain_object(obj); var iterator = is_function(obj[Symbol.asyncIterator]) || is_function(obj[Symbol.iterator]); var fn; - if (repr.has(constructor)) { fn = repr.get(constructor); } else { repr.forEach(function (value, key) { - key = unbind(key); // if key is Object it should only work for plain_object + key = unbind(key); + // if key is Object it should only work for plain_object // because otherwise it will match every object // we don't use instanceof so it don't work for subclasses - if (obj.constructor === key && (key === Object && plain_object && !iterator || key !== Object)) { fn = value; } }); } - return fn; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- var str_mapping = new Map(); [[true, '#t'], [false, '#f'], [null, 'null'], [undefined, '#']].forEach(function (_ref11) { var _ref12 = _slicedToArray(_ref11, 2), - key = _ref12[0], - value = _ref12[1]; - + key = _ref12[0], + value = _ref12[1]; str_mapping.set(key, value); - }); // ---------------------------------------------------------------------- + }); + // ---------------------------------------------------------------------- // :: Debug function that can be used with JSON.stringify // :: that will show symbols // ---------------------------------------------------------------------- - /* istanbul ignore next */ - function symbolize(obj) { if (obj && _typeof(obj) === 'object') { var result = {}; - var _symbols = Object.getOwnPropertySymbols(obj); - _symbols.forEach(function (key) { var name = key.toString().replace(/Symbol\(([^)]+)\)/, '$1'); result[name] = toString(obj[key]); }); - var _props = Object.getOwnPropertyNames(obj); - _props.forEach(function (key) { var o = obj[key]; - if (o && _typeof(o) === 'object' && o.constructor === Object) { result[key] = symbolize(o); } else { result[key] = toString(o); } }); - return result; } - return obj; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function get_props(obj) { return Object.keys(obj).concat(Object.getOwnPropertySymbols(obj)); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function has_own_function(obj, name) { return obj.hasOwnProperty(name) && is_function(obj.toString); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function function_to_string(fn) { if (is_native_function(fn)) { return '#'; } - var constructor = fn.prototype && fn.prototype.constructor; - if (is_function(constructor) && is_lambda(constructor)) { if (fn[__class__] && constructor.hasOwnProperty('__name__')) { var name = constructor.__name__; - if (LString.isString(name)) { name = name.toString(); return "#"); } - return '#'; } } - if (fn.hasOwnProperty('__name__')) { var _name = fn.__name__; - if (_typeof(_name) === 'symbol') { _name = symbol_to_string(_name); } - if (typeof _name === 'string') { return "#"); } } - if (has_own_function(fn, 'toString')) { return fn.toString(); } else if (fn.name && !is_lambda(fn)) { @@ -9660,134 +8997,109 @@ } else { return '#'; } - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // Instances extracted to make cyclomatic complexity of toString smaller - - - var instances = new Map(); // ---------------------------------------------------------------------- - + var instances = new Map(); + // ---------------------------------------------------------------------- [[Error, function (e) { return e.message; }], [Pair, function (pair, _ref13) { var quote = _ref13.quote, - skip_cycles = _ref13.skip_cycles, - pair_args = _ref13.pair_args; - + skip_cycles = _ref13.skip_cycles, + pair_args = _ref13.pair_args; // make sure that repr directly after update set the cycle ref if (!skip_cycles) { pair.markCycles(); } - return pair.toString.apply(pair, [quote].concat(_toConsumableArray(pair_args))); }], [LCharacter, function (chr, _ref14) { var quote = _ref14.quote; - if (quote) { return chr.toString(); } - return chr.valueOf(); }], [LString, function (str, _ref15) { var quote = _ref15.quote; str = str.toString(); - if (quote) { return JSON.stringify(str).replace(/\\n/g, '\n'); } - return str; }], [RegExp, function (re) { return '#' + re.toString(); }]].forEach(function (_ref16) { var _ref17 = _slicedToArray(_ref16, 2), - cls = _ref17[0], - fn = _ref17[1]; - + cls = _ref17[0], + fn = _ref17[1]; instances.set(cls, fn); - }); // ---------------------------------------------------------------------- - - var native_types = [LSymbol, LNumber, Macro, Values, InputPort, OutputPort, Environment, QuotedPromise]; // ---------------------------------------------------------------------- - + }); + // ---------------------------------------------------------------------- + var native_types = [LSymbol, LNumber, Macro, Values, InputPort, OutputPort, Environment, QuotedPromise]; + // ---------------------------------------------------------------------- function toString(obj, quote, skip_cycles) { if (typeof jQuery !== 'undefined' && obj instanceof jQuery.fn.init) { return '#'; } - if (str_mapping.has(obj)) { return str_mapping.get(obj); } - if (is_prototype(obj)) { return '#'; } - if (obj) { var cls = obj.constructor; - if (instances.has(cls)) { for (var _len5 = arguments.length, pair_args = new Array(_len5 > 3 ? _len5 - 3 : 0), _key5 = 3; _key5 < _len5; _key5++) { pair_args[_key5 - 3] = arguments[_key5]; } - return instances.get(cls)(obj, { quote: quote, skip_cycles: skip_cycles, pair_args: pair_args }); } - } // standard objects that have toString - - + } + // standard objects that have toString var _iterator8 = _createForOfIteratorHelper(native_types), - _step8; - + _step8; try { for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) { var _type2 = _step8.value; - if (obj instanceof _type2) { return obj.toString(quote); } - } // constants - + } + // constants } catch (err) { _iterator8.e(err); } finally { _iterator8.f(); } - if ([_nil, eof].includes(obj)) { return obj.toString(); } - if (is_function(obj)) { return function_to_string(obj); } - if (obj === root) { return '#'; } - if (obj === null) { return 'null'; } - if (_typeof(obj) === 'object') { var constructor = obj.constructor; - if (!constructor) { // This is case of fs.constants in Node.js that is null constructor object. // This object can be handled like normal objects that have properties constructor = Object; } - var name; - if (typeof constructor.__class__ === 'string') { name = constructor.__class__; } else { var fn = user_repr(obj); - if (fn) { if (is_function(fn)) { return fn(obj, quote); @@ -9795,15 +9107,12 @@ throw new Error('toString: Invalid repr value'); } } - name = constructor.name; - } // user defined representation - - + } + // user defined representation if (is_function(obj.toString) && is_lambda(obj.toString)) { return obj.toString().valueOf(); } - if (type(obj) === 'instance') { if (is_lambda(constructor) && constructor.__name__) { name = constructor.__name__.valueOf(); @@ -9811,93 +9120,74 @@ name = 'instance'; } } - if (is_iterator(obj, Symbol.iterator)) { if (name) { return "#"); } - return '#'; } - if (is_iterator(obj, Symbol.asyncIterator)) { if (name) { return "#"); } - return '#'; } - if (name !== '') { return '#<' + name + '>'; } - return '#'; } - if (typeof obj !== 'string') { return obj.toString(); } - return obj; - } // ---------------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------------- function is_prototype(obj) { return obj && _typeof(obj) === 'object' && obj.hasOwnProperty && obj.hasOwnProperty("constructor") && typeof obj.constructor === "function" && obj.constructor.prototype === obj; - } // ---------------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------------- Pair.prototype.markCycles = function () { markCycles(this); return this; - }; // ---------------------------------------------------------------------------- - + }; + // ---------------------------------------------------------------------------- Pair.prototype.haveCycles = function () { var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - if (!name) { return this.haveCycles('car') || this.haveCycles('cdr'); } - return !!(this[__cycles__] && this[__cycles__][name]); - }; // ---------------------------------------------------------------------------- - + }; + // ---------------------------------------------------------------------------- function markCycles(pair) { var seen_pairs = []; var cycles = []; var refs = []; - function visit(pair) { if (!seen_pairs.includes(pair)) { seen_pairs.push(pair); } } - function set(node, type, child, parents) { if (child instanceof Pair) { if (parents.includes(child)) { if (!refs.includes(child)) { refs.push(child); } - if (!node[__cycles__]) { node[__cycles__] = {}; } - node[__cycles__][type] = child; - if (!cycles.includes(node)) { cycles.push(node); } - return true; } } } - var detect = trampoline(function detect_thunk(pair, parents) { if (pair instanceof Pair) { delete pair.ref; @@ -9906,11 +9196,9 @@ parents.push(pair); var car = set(pair, 'car', pair.car, parents); var cdr = set(pair, 'cdr', pair.cdr, parents); - if (!car) { detect(pair.car, parents.slice()); } - if (!cdr) { return new Thunk(function () { return detect_thunk(pair.cdr, parents.slice()); @@ -9918,14 +9206,12 @@ } } }); - function mark_node(node, type) { if (node[__cycles__][type] instanceof Pair) { var count = ref_nodes.indexOf(node[__cycles__][type]); node[__cycles__][type] = "#".concat(count, "#"); } } - detect(pair, []); var ref_nodes = seen_pairs.filter(function (node) { return refs.includes(node); @@ -9937,34 +9223,28 @@ mark_node(node, 'car'); mark_node(node, 'cdr'); }); - } // ---------------------------------------------------------------------- - + } + // ---------------------------------------------------------------------- Pair.prototype.toString = function (quote) { var _ref18 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - _ref18$nested = _ref18.nested, - nested = _ref18$nested === void 0 ? false : _ref18$nested; - + _ref18$nested = _ref18.nested, + nested = _ref18$nested === void 0 ? false : _ref18$nested; var arr = []; - if (this[__ref__]) { arr.push(this[__ref__] + '('); } else if (!nested) { arr.push('('); } - var value; - if (this[__cycles__] && this[__cycles__].car) { value = this[__cycles__].car; } else { value = toString(this.car, quote, true); } - if (value !== undefined) { arr.push(value); } - if (this.cdr instanceof Pair) { if (this[__cycles__] && this[__cycles__].cdr) { arr.push(' . '); @@ -9975,7 +9255,6 @@ } else { arr.push(' '); } - var cdr = this.cdr.toString(quote, { nested: true }); @@ -9984,31 +9263,26 @@ } else if (this.cdr !== _nil) { arr = arr.concat([' . ', toString(this.cdr, quote, true)]); } - if (!nested || this[__ref__]) { arr.push(')'); } - return arr.join(''); - }; // ---------------------------------------------------------------------- - + }; + // ---------------------------------------------------------------------- Pair.prototype.set = function (prop, value) { this[prop] = value; - if (value instanceof Pair) { this.markCycles(); } - }; // ---------------------------------------------------------------------- - + }; + // ---------------------------------------------------------------------- Pair.prototype.append = function (arg) { if (arg instanceof Array) { return this.append(Pair.fromArray(arg)); } - var p = this; - if (p.car === undefined) { if (arg instanceof Pair) { this.car = arg.car; @@ -10024,28 +9298,23 @@ break; } } - p.cdr = arg; } - return this; - }; // ---------------------------------------------------------------------- - - + }; + // ---------------------------------------------------------------------- Pair.prototype.serialize = function () { return [this.car, this.cdr]; - }; // ---------------------------------------------------------------------- + }; + // ---------------------------------------------------------------------- // :: List iterator (for do-iterator macro) // ---------------------------------------------------------------------- - - Pair.prototype[Symbol.iterator] = function () { var node = this; return { next: function next() { var cur = node; node = cur.cdr; - if (cur === _nil) { return { value: undefined, @@ -10059,42 +9328,34 @@ } } }; - }; // ---------------------------------------------------------------------- + }; + // ---------------------------------------------------------------------- // :: abs that work on BigInt // ---------------------------------------------------------------------- - - function abs(x) { return x < 0 ? -x : x; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function seq_compare(fn, args) { var _args11 = _toArray(args), - a = _args11[0], - rest = _args11.slice(1); - + a = _args11[0], + rest = _args11.slice(1); while (rest.length > 0) { var _rest = rest, - _rest2 = _slicedToArray(_rest, 1), - b = _rest2[0]; - + _rest2 = _slicedToArray(_rest, 1), + b = _rest2[0]; if (!fn(a, b)) { return false; } - var _rest3 = rest; - var _rest4 = _toArray(_rest3); - a = _rest4[0]; rest = _rest4.slice(1); } - return true; - } // ---------------------------------------------------------------------- - + } + // ---------------------------------------------------------------------- function equal(x, y) { if (is_function(x)) { return is_function(y) && unbind(x) === unbind(y); @@ -10102,82 +9363,65 @@ if (!(y instanceof LNumber)) { return false; } - var _type3; - if (x.__type__ === y.__type__) { if (x.__type__ === 'complex') { _type3 = x.__im__.__type__ === y.__im__.__type__ && x.__re__.__type__ === y.__re__.__type__; } else { _type3 = true; } - if (_type3 && x.cmp(y) === 0) { if (x.valueOf() === 0) { return Object.is(x.valueOf(), y.valueOf()); } - return true; } } - return false; } else if (typeof x === 'number') { if (typeof y !== 'number') { return false; } - if (Number.isNaN(x)) { return Number.isNaN(y); } - if (x === Number.NEGATIVE_INFINITY) { return y === Number.NEGATIVE_INFINITY; } - if (x === Number.POSITIVE_INFINITY) { return y === Number.POSITIVE_INFINITY; } - return equal(LNumber(x), LNumber(y)); } else if (x instanceof LCharacter) { if (!(y instanceof LCharacter)) { return false; } - return x.__char__ === y.__char__; } else { return x === y; } - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function same_atom(a, b) { if (type(a) !== type(b)) { return false; } - if (!is_atom(a)) { return false; } - if (a instanceof RegExp) { return a.source === b.source; } - if (a instanceof LString) { return a.valueOf() === b.valueOf(); } - return equal(a, b); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function is_atom(obj) { return obj instanceof LSymbol || LString.isString(obj) || obj === _nil || obj === null || obj instanceof LCharacter || obj instanceof LNumber || obj === true || obj === false; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- var truncate = function () { if (Math.trunc) { return Math.trunc; @@ -10192,19 +9436,16 @@ } }; } - }(); // ---------------------------------------------------------------------- + }(); + // ---------------------------------------------------------------------- // :: Macro constructor // ---------------------------------------------------------------------- - - function Macro(name, fn, doc, dump) { if (typeof this !== 'undefined' && this.constructor !== Macro || typeof this === 'undefined') { return new Macro(name, fn); } - typecheck('Macro', name, 'string', 1); typecheck('Macro', fn, 'function', 2); - if (doc) { if (dump) { this.__doc__ = doc; @@ -10212,49 +9453,41 @@ this.__doc__ = trim_lines(doc); } } - this.__name__ = name; this.__fn__ = fn; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- Macro.defmacro = function (name, fn, doc, dump) { var macro = new Macro(name, fn, doc, dump); macro.__defmacro__ = true; return macro; - }; // ---------------------------------------------------------------------- - - + }; + // ---------------------------------------------------------------------- Macro.prototype.invoke = function (code, _ref19, macro_expand) { var env = _ref19.env, - dynamic_scope = _ref19.dynamic_scope, - error = _ref19.error; + dynamic_scope = _ref19.dynamic_scope, + error = _ref19.error; var args = { dynamic_scope: dynamic_scope, error: error, macro_expand: macro_expand }; - var result = this.__fn__.call(env, code, args, this.__name__); - - return result; //return macro_expand ? quote(result) : result; - }; // ---------------------------------------------------------------------- - - + return result; + //return macro_expand ? quote(result) : result; + }; + // ---------------------------------------------------------------------- Macro.prototype.toString = function () { return "#"); - }; // ---------------------------------------------------------------------- - - - var macro = 'define-macro'; // ---------------------------------------------------------------------- - + }; + // ---------------------------------------------------------------------- + var macro = 'define-macro'; + // ---------------------------------------------------------------------- var recur_guard = -10000; - function macro_expand(single) { return /*#__PURE__*/function () { var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(code, args) { var env, bindings, let_macros, lambda, define, is_let_macro, is_procedure, is_lambda, proc_bindings, let_binding, is_macro, expand_let_binding, _expand_let_binding, traverse, _traverse; - return _regeneratorRuntime.wrap(function _callee12$(_context12) { while (1) { switch (_context12.prev = _context12.next) { @@ -10262,7 +9495,6 @@ _traverse = function _traverse3() { _traverse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(node, n, env) { var name, value, is_let, is_binding, second, code, result, _result, expr, scope, car, cdr, pair; - return _regeneratorRuntime.wrap(function _callee11$(_context11) { while (1) { switch (_context11.prev = _context11.next) { @@ -10271,14 +9503,11 @@ _context11.next = 50; break; } - if (!node[__data__]) { _context11.next = 3; break; } - return _context11.abrupt("return", node); - case 3: name = node.car.valueOf(); value = env.get(node.car, { @@ -10286,30 +9515,24 @@ }); is_let = is_let_macro(node.car); is_binding = is_let || is_procedure(value, node) || is_lambda(value); - if (!(is_binding && node.cdr.car instanceof Pair)) { _context11.next = 28; break; } - if (!is_let) { _context11.next = 15; break; } - bindings = let_binding(node.cdr.car); _context11.next = 12; return expand_let_binding(node.cdr.car, n); - case 12: second = _context11.sent; _context11.next = 17; break; - case 15: bindings = proc_bindings(node.cdr.car); second = node.cdr.car; - case 17: _context11.t0 = Pair; _context11.t1 = node.car; @@ -10317,125 +9540,94 @@ _context11.t3 = second; _context11.next = 23; return traverse(node.cdr.cdr, n, env); - case 23: _context11.t4 = _context11.sent; _context11.t5 = new _context11.t2(_context11.t3, _context11.t4); return _context11.abrupt("return", new _context11.t0(_context11.t1, _context11.t5)); - case 28: if (!is_macro(name, value)) { _context11.next = 50; break; } - code = value instanceof Syntax ? node : node.cdr; _context11.next = 32; return value.invoke(code, _objectSpread(_objectSpread({}, args), {}, { env: env }), true); - case 32: result = _context11.sent; - if (!(value instanceof Syntax)) { _context11.next = 41; break; } - _result = result, expr = _result.expr, scope = _result.scope; - if (!(expr instanceof Pair)) { _context11.next = 40; break; } - if (!(n !== -1 && n <= 1 || n < recur_guard)) { _context11.next = 38; break; } - return _context11.abrupt("return", expr); - case 38: if (n !== -1) { n = n - 1; } - return _context11.abrupt("return", traverse(expr, n, scope)); - case 40: result = expr; - case 41: if (!(result instanceof LSymbol)) { _context11.next = 43; break; } - return _context11.abrupt("return", quote(result)); - case 43: if (!(result instanceof Pair)) { _context11.next = 48; break; } - if (!(n !== -1 && n <= 1 || n < recur_guard)) { _context11.next = 46; break; } - return _context11.abrupt("return", result); - case 46: if (n !== -1) { n = n - 1; } - return _context11.abrupt("return", traverse(result, n, env)); - case 48: if (!is_atom(result)) { _context11.next = 50; break; } - return _context11.abrupt("return", result); - case 50: // TODO: CYCLE DETECT car = node.car; - if (!(car instanceof Pair)) { _context11.next = 55; break; } - _context11.next = 54; return traverse(car, n, env); - case 54: car = _context11.sent; - case 55: cdr = node.cdr; - if (!(cdr instanceof Pair)) { _context11.next = 60; break; } - _context11.next = 59; return traverse(cdr, n, env); - case 59: cdr = _context11.sent; - case 60: pair = new Pair(car, cdr); return _context11.abrupt("return", pair); - case 62: case "end": return _context11.stop(); @@ -10445,11 +9637,9 @@ })); return _traverse.apply(this, arguments); }; - traverse = function _traverse2(_x10, _x11, _x12) { return _traverse.apply(this, arguments); }; - _expand_let_binding = function _expand_let_binding3() { _expand_let_binding = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(node, n) { var pair; @@ -10461,9 +9651,7 @@ _context10.next = 2; break; } - return _context10.abrupt("return", _nil); - case 2: pair = node.car; _context10.t0 = Pair; @@ -10471,17 +9659,14 @@ _context10.t2 = pair.car; _context10.next = 8; return traverse(pair.cdr, n, env); - case 8: _context10.t3 = _context10.sent; _context10.t4 = new _context10.t1(_context10.t2, _context10.t3); _context10.next = 12; return expand_let_binding(node.cdr); - case 12: _context10.t5 = _context10.sent; return _context10.abrupt("return", new _context10.t0(_context10.t4, _context10.t5)); - case 14: case "end": return _context10.stop(); @@ -10491,100 +9676,79 @@ })); return _expand_let_binding.apply(this, arguments); }; - expand_let_binding = function _expand_let_binding2(_x8, _x9) { return _expand_let_binding.apply(this, arguments); }; - is_macro = function _is_macro(name, value) { return value instanceof Macro && value.__defmacro__ && !bindings.includes(name); }; - let_binding = function _let_binding(node) { return [].concat(_toConsumableArray(bindings), _toConsumableArray(node.to_array(false).map(function (node) { if (node instanceof Pair) { return node.car.valueOf(); } - throw new Error('macroexpand: Invalid let binding'); }))); }; - proc_bindings = function _proc_bindings(node) { var names = []; - while (true) { if (node !== _nil) { if (node instanceof LSymbol) { names.push(node.valueOf()); break; } - names.push(node.car.valueOf()); node = node.cdr; } else { break; } } - return [].concat(_toConsumableArray(bindings), names); }; - is_lambda = function _is_lambda(value) { return value === lambda; }; - is_procedure = function _is_procedure(value, node) { return value === define && node.cdr.car instanceof Pair; }; - is_let_macro = function _is_let_macro(symbol) { var name = symbol.valueOf(); return let_macros.includes(name); }; - env = args['env'] = this; bindings = []; let_macros = ['let', 'let*', 'letrec']; lambda = global_env.get('lambda'); - define = global_env.get('define'); - + define = global_env.get('define'); //var this.__code__ = code; if (!(code.cdr instanceof Pair && LNumber.isNumber(code.cdr.car))) { _context12.next = 21; break; } - _context12.t0 = quote; _context12.next = 19; return traverse(code, code.cdr.car.valueOf(), env); - case 19: _context12.t1 = _context12.sent.car; return _context12.abrupt("return", (0, _context12.t0)(_context12.t1)); - case 21: if (!single) { _context12.next = 27; break; } - _context12.t2 = quote; _context12.next = 25; return traverse(code, 1, env); - case 25: _context12.t3 = _context12.sent.car; return _context12.abrupt("return", (0, _context12.t2)(_context12.t3)); - case 27: _context12.t4 = quote; _context12.next = 30; return traverse(code, -1, env); - case 30: _context12.t5 = _context12.sent.car; return _context12.abrupt("return", (0, _context12.t4)(_context12.t5)); - case 32: case "end": return _context12.stop(); @@ -10592,30 +9756,26 @@ } }, _callee12, this); })); - return function (_x6, _x7) { return _ref20.apply(this, arguments); }; }(); - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // TODO: Don't put Syntax as Macro they are not runtime // ---------------------------------------------------------------------- - - function Syntax(fn, env) { this.__env__ = env; - this.__fn__ = fn; // allow macroexpand - + this.__fn__ = fn; + // allow macroexpand this.__defmacro__ = true; } - - Syntax.__merge_env__ = Symbol["for"]('merge'); // ---------------------------------------------------------------------- - + Syntax.__merge_env__ = Symbol["for"]('merge'); + // ---------------------------------------------------------------------- Syntax.prototype = Object.create(Macro.prototype); - Syntax.prototype.invoke = function (code, _ref21, macro_expand) { var error = _ref21.error, - env = _ref21.env; + env = _ref21.env; var args = { error: error, env: env, @@ -10624,41 +9784,32 @@ }; return this.__fn__.call(env, code, args, this.__name__ || 'syntax'); }; - Syntax.prototype.constructor = Syntax; - Syntax.prototype.toString = function () { if (this.__name__) { return "#"); } - return '#'; }; - - Syntax.className = 'syntax'; // ---------------------------------------------------------------------- + Syntax.className = 'syntax'; + // ---------------------------------------------------------------------- // :: TODO: SRFI-139 // ---------------------------------------------------------------------- - var Parameter = /*#__PURE__*/function (_Syntax) { _inherits(Parameter, _Syntax); - var _super = _createSuper(Parameter); - function Parameter() { _classCallCheck(this, Parameter); - return _super.apply(this, arguments); } - return _createClass(Parameter); }(Syntax); - - Syntax.Parameter = Parameter; // ---------------------------------------------------------------------- + Syntax.Parameter = Parameter; + // ---------------------------------------------------------------------- // :: for usage in syntax-rule when pattern match it will return // :: list of bindings from code that match the pattern // :: TODO detect cycles // ---------------------------------------------------------------------- - function extract_patterns(pattern, code, symbols, ellipsis_symbol) { var scope = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {}; var bindings = { @@ -10670,21 +9821,19 @@ symbols: {} }; var expansion = scope.expansion, - define = scope.define; // pattern_names parameter is used to distinguish + define = scope.define; + // pattern_names parameter is used to distinguish // multiple matches of ((x ...) ...) against ((1 2 3) (1 2 3)) // in loop we add x to the list so we know that this is not // duplicated ellipsis symbol - function log(x) { /* istanbul ignore next */ if (is_debug()) { console.log(x); } } - log(symbols); /* eslint-disable complexity */ - function traverse(pattern, code) { var pattern_names = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; var ellipsis = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; @@ -10692,41 +9841,32 @@ code: code && toString(code, true), pattern: pattern && toString(pattern, true) }); - if (is_atom(pattern) && !(pattern instanceof LSymbol)) { return same_atom(pattern, code); } - if (pattern instanceof LSymbol && symbols.includes(pattern.literal())) { // TODO: literal() may be SLOW - var ref = expansion.ref(code); // shadowing the identifier works only with lambda and let - + var ref = expansion.ref(code); + // shadowing the identifier works only with lambda and let if (LSymbol.is(code, pattern)) { if (typeof ref === 'undefined') { return true; } - return ref === define || ref === global_env; } - return false; - } // pattern (a b (x ...)) and (x ...) match nil - - + } + // pattern (a b (x ...)) and (x ...) match nil if (pattern instanceof Pair && pattern.car instanceof Pair && pattern.car.cdr instanceof Pair && LSymbol.is(pattern.car.cdr.car, ellipsis_symbol)) { log('>> 0'); - if (code === _nil) { log({ pattern: pattern.toString() }); - if (pattern.car.car instanceof LSymbol) { if (pattern.car.cdr instanceof Pair && LSymbol.is(pattern.car.cdr.car, ellipsis_symbol)) { var _name2 = pattern.car.car.valueOf(); - var last = pattern.last_pair(); - if (LSymbol.is(last.car, ellipsis_symbol)) { bindings['...'].symbols[_name2] = null; return true; @@ -10734,18 +9874,14 @@ return false; } } - var name = pattern.car.car.valueOf(); - if (bindings['...'].symbols[name]) { throw new Error('syntax: named ellipsis can only ' + 'appear onces'); } - bindings['...'].symbols[name] = code; } } } - if (pattern instanceof Pair && pattern.cdr instanceof Pair && LSymbol.is(pattern.cdr.car, ellipsis_symbol)) { // pattern (... ???) - SRFI-46 if (pattern.cdr.cdr !== _nil) { @@ -10754,33 +9890,25 @@ var list_len = pattern.cdr.cdr.length(); var code_len = code.length(); var list = code; - while (code_len - 1 > list_len) { list = list.cdr; code_len--; } - var rest = list.cdr; list.cdr = _nil; - if (!traverse(pattern.cdr.cdr, rest, pattern_names, ellipsis)) { return false; } } } - if (pattern.car instanceof LSymbol) { var _name3 = pattern.car.__name__; - if (bindings['...'].symbols[_name3] && !pattern_names.includes(_name3) && !ellipsis) { throw new Error('syntax: named ellipsis can only appear onces'); } - log('>> 1'); - if (code === _nil) { log('>> 2'); - if (ellipsis) { log('NIL'); bindings['...'].symbols[_name3] = _nil; @@ -10790,17 +9918,14 @@ } } else if (code instanceof Pair && (code.car instanceof Pair || code.car === _nil)) { log('>> 3 ' + ellipsis); - if (ellipsis) { if (bindings['...'].symbols[_name3]) { var node = bindings['...'].symbols[_name3]; - if (node === _nil) { node = new Pair(_nil, new Pair(code, _nil)); } else { node = node.append(new Pair(code, _nil)); } - bindings['...'].symbols[_name3] = node; } else { bindings['...'].symbols[_name3] = new Pair(code, _nil); @@ -10811,84 +9936,65 @@ } } else { log('>> 6'); - if (code instanceof Pair) { log('>> 7 ' + ellipsis); pattern_names.push(_name3); - if (!bindings['...'].symbols[_name3]) { bindings['...'].symbols[_name3] = new Pair(code, _nil); } else { var _node = bindings['...'].symbols[_name3]; bindings['...'].symbols[_name3] = _node.append(new Pair(code, _nil)); } - log({ IIIIII: bindings['...'].symbols[_name3].toString() }); } else { log('>> 8'); - return false; //bindings['...'].symbols[name] = code; + return false; + //bindings['...'].symbols[name] = code; } } - return true; } else if (pattern.car instanceof Pair) { var names = _toConsumableArray(pattern_names); - if (code === _nil) { log('>> 9'); bindings['...'].lists.push(_nil); return true; } - log('>> 10'); var _node2 = code; - while (_node2 instanceof Pair) { if (!traverse(pattern.car, _node2.car, names, true)) { return false; } - _node2 = _node2.cdr; } - return true; } - return false; } - if (pattern instanceof LSymbol) { if (LSymbol.is(pattern, ellipsis_symbol)) { throw new Error('syntax: invalid usage of ellipsis'); } - log('>> 11'); var _name4 = pattern.__name__; - if (symbols.includes(_name4)) { return true; } - log({ name: _name4, ellipsis: ellipsis }); - if (ellipsis) { bindings['...'].symbols[_name4] = bindings['...'].symbols[_name4] || []; - bindings['...'].symbols[_name4].push(code); } - bindings.symbols[_name4] = code; - if (!bindings.symbols[_name4]) ; - return true; } - if (pattern instanceof Pair && code instanceof Pair) { log('>> 12'); log({ @@ -10896,43 +10002,34 @@ code: code && code.toString(), pattern: pattern.toString() }); - if (code.cdr === _nil) { // last item in in call using in recursive calls on // last element of the list // case of pattern (p . rest) and code (0) var rest_pattern = pattern.car instanceof LSymbol && pattern.cdr instanceof LSymbol; - if (rest_pattern) { // fix for SRFI-26 in recursive call of (b) ==> (<> . x) // where <> is symbol if (!traverse(pattern.car, code.car, pattern_names, ellipsis)) { return false; } - log('>> 12 | 1'); - var _name5 = pattern.cdr.valueOf(); - if (!(_name5 in bindings.symbols)) { bindings.symbols[_name5] = _nil; } - _name5 = pattern.car.valueOf(); - if (!(_name5 in bindings.symbols)) { bindings.symbols[_name5] = code.car; } - return true; } } - log({ pattern: pattern.toString(), code: code.toString() - }); // case (x y) ===> (var0 var1 ... warn) where var1 match nil - + }); + // case (x y) ===> (var0 var1 ... warn) where var1 match nil if (pattern.cdr instanceof Pair && pattern.car instanceof LSymbol && pattern.cdr.cdr instanceof Pair && pattern.cdr.car instanceof LSymbol && LSymbol.is(pattern.cdr.cdr.car, ellipsis_symbol) && pattern.cdr.cdr.cdr instanceof Pair && !LSymbol.is(pattern.cdr.cdr.cdr.car, ellipsis_symbol) && traverse(pattern.car, code.car, pattern_names, ellipsis) && traverse(pattern.cdr.cdr.cdr, code.cdr, pattern_names, ellipsis)) { var _name6 = pattern.cdr.car.__name__; log({ @@ -10940,17 +10037,13 @@ code: code.car.toString(), name: _name6 }); - if (symbols.includes(_name6)) { return true; } - bindings['...'].symbols[_name6] = null; return true; } - log('recur'); - if (traverse(pattern.car, code.car, pattern_names, ellipsis) && traverse(pattern.cdr, code.cdr, pattern_names, ellipsis)) { return true; } @@ -10966,82 +10059,67 @@ } } /* eslint-enable complexity */ - - if (traverse(pattern, code)) { return bindings; } - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // :: This function is called after syntax-rules macro is evaluated // :: and if there are any gensyms added by macro they need to restored // :: to original symbols // ---------------------------------------------------------------------- - - function clear_gensyms(node, gensyms) { function traverse(node) { if (node instanceof Pair) { if (!gensyms.length) { return node; } - var car = traverse(node.car); - var cdr = traverse(node.cdr); // TODO: check if it's safe to modify the list + var cdr = traverse(node.cdr); + // TODO: check if it's safe to modify the list // some funky modify of code can happen in macro - return new Pair(car, cdr); } else if (node instanceof LSymbol) { var replacement = gensyms.find(function (gensym) { return gensym.gensym === node; }); - if (replacement) { return LSymbol(replacement.name); } - return node; } else { return node; } } - return traverse(node); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function transform_syntax() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var bindings = options.bindings, - expr = options.expr, - scope = options.scope, - symbols = options.symbols, - names = options.names, - ellipsis_symbol = options.ellipsis; + expr = options.expr, + scope = options.scope, + symbols = options.symbols, + names = options.names, + ellipsis_symbol = options.ellipsis; var gensyms = {}; - function valid_symbol(symbol) { if (symbol instanceof LSymbol) { return true; } - return ['string', 'symbol'].includes(_typeof(symbol)); } - function transform(symbol) { if (!valid_symbol(symbol)) { var t = type(symbol); throw new Error("syntax: internal error, need symbol got ".concat(t)); } - var name = symbol.valueOf(); - if (name === ellipsis_symbol) { throw new Error('syntax: internal error, ellipis not transformed'); - } // symbols are gensyms from nested syntax-rules - - + } + // symbols are gensyms from nested syntax-rules var n_type = _typeof(name); - if (['string', 'symbol'].includes(n_type)) { if (name in bindings.symbols) { return bindings.symbols[name]; @@ -11049,7 +10127,6 @@ // calling method on pattern symbol #83 var parts = name.split('.'); var first = parts[0]; - if (first in bindings.symbols) { return Pair.fromArray([LSymbol('.'), bindings.symbols[first]].concat(parts.slice(1).map(function (x) { return LString(x); @@ -11057,113 +10134,92 @@ } } } - if (symbols.includes(name)) { return LSymbol(name); } - return rename(name); } - function log(x) { /* istanbul ignore next */ if (is_debug()) { console.log(x); } } - function rename(name) { if (!gensyms[name]) { var ref = scope.ref(name); var gensym_name = gensym(name); - if (ref) { var value = scope.get(name); scope.set(gensym_name, value); } else { var _value = scope.get(name, { throwError: false - }); // value is not in scope, but it's JavaScript object - - + }); + // value is not in scope, but it's JavaScript object if (typeof _value !== 'undefined') { scope.set(gensym_name, _value); } - } // keep names so they can be restored after evaluation + } + // keep names so they can be restored after evaluation // if there are free symbols as output // kind of hack - - names.push({ name: name, gensym: gensym_name }); - gensyms[name] = gensym_name; // we need to check if name is a string, because it can be + gensyms[name] = gensym_name; + // we need to check if name is a string, because it can be // gensym from nested syntax-rules - if (typeof name === 'string' && name.match(/\./)) { var _name$split$filter = name.split('.').filter(Boolean), - _name$split$filter2 = _toArray(_name$split$filter), - first = _name$split$filter2[0], - rest = _name$split$filter2.slice(1); // save JavaScript dot notation for Env::get - - + _name$split$filter2 = _toArray(_name$split$filter), + first = _name$split$filter2[0], + rest = _name$split$filter2.slice(1); + // save JavaScript dot notation for Env::get if (gensyms[first]) { hidden_prop(gensym_name, '__object__', [gensyms[first]].concat(_toConsumableArray(rest))); } } } - return gensyms[name]; } - function transform_ellipsis_expr(expr, bindings, state) { var next = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function () {}; var nested = state.nested; log(' ==> ' + expr.toString(true)); log(bindings); - if (expr instanceof LSymbol) { var name = expr.valueOf(); log('[t 1'); - if (bindings[name]) { if (bindings[name] instanceof Pair) { var _bindings$name = bindings[name], - car = _bindings$name.car, - cdr = _bindings$name.cdr; - + car = _bindings$name.car, + cdr = _bindings$name.cdr; if (nested) { var caar = car.car, - cadr = car.cdr; - + cadr = car.cdr; if (cadr !== _nil) { next(name, new Pair(cadr, _nil)); } - return caar; } - if (cdr !== _nil) { next(name, cdr); } - return car; } else if (bindings[name] instanceof Array) { next(name, bindings[name].slice(1)); return bindings[name][0]; } } - return transform(name); } - if (expr instanceof Pair) { if (expr.car instanceof LSymbol && expr.cdr instanceof Pair && LSymbol.is(expr.cdr.car, ellipsis_symbol)) { log('[t 2'); - var _name7 = expr.car.valueOf(); - var item = bindings[_name7]; log({ expr: expr.toString(true), @@ -11171,28 +10227,24 @@ bindings: bindings, item: item }); - if (item === null) { return; } else if (item) { log({ b: bindings[_name7].toString() }); - if (item instanceof Pair) { log('[t 2 Pair ' + nested); log({ ______: item.toString() }); var _car = item.car, - _cdr = item.cdr; - + _cdr = item.cdr; if (nested) { if (_cdr !== _nil) { log('|| next 1'); next(_name7, _cdr); } - log({ car: _car.toString() }); @@ -11202,7 +10254,6 @@ log('|| next 2'); next(_name7, new Pair(_car.cdr, _cdr)); } - log({ car: _car.car.toString() }); @@ -11210,17 +10261,14 @@ } } else if (item instanceof Array) { log('[t 2 Array ' + nested); - if (nested) { next(_name7, item.slice(1)); return Pair.fromArray(item); } else { var _rest5 = item.slice(1); - if (_rest5.length) { next(_name7, _rest5); } - return item[0]; } } else { @@ -11228,47 +10276,36 @@ } } } - log('[t 3 recur ' + expr.toString()); var head = transform_ellipsis_expr(expr.car, bindings, state, next); var rest = transform_ellipsis_expr(expr.cdr, bindings, state, next); return new Pair(head, rest); } - return expr; } - function have_binding(biding, skip_nulls) { var values = Object.values(biding); var symbols = Object.getOwnPropertySymbols(biding); - if (symbols.length) { values.push.apply(values, _toConsumableArray(symbols.map(function (x) { return biding[x]; }))); } - return values.length && values.every(function (x) { if (x === null) { return !skip_nulls; } - return x instanceof Pair || x === _nil || x instanceof Array && x.length; }); } - function get_names(object) { return Object.keys(object).concat(Object.getOwnPropertySymbols(object)); } /* eslint-disable complexity */ - - function traverse(expr) { var _ref22 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - disabled = _ref22.disabled; - + disabled = _ref22.disabled; log('traverse>> ' + toString(expr)); - if (expr instanceof Pair) { // escape ellispsis from R7RS e.g. (... ...) if (!disabled && expr.car instanceof Pair && LSymbol.is(expr.car.car, ellipsis_symbol)) { @@ -11276,14 +10313,12 @@ disabled: true }); } - if (expr.cdr instanceof Pair && LSymbol.is(expr.cdr.car, ellipsis_symbol) && !disabled) { log('>> 1'); - var _symbols2 = bindings['...'].symbols; // skip expand list of pattern was (x y ... z) + var _symbols2 = bindings['...'].symbols; + // skip expand list of pattern was (x y ... z) // and code was (x z) so y == null - var values = Object.values(_symbols2); - if (values.length && values.every(function (x) { return x === null; })) { @@ -11291,16 +10326,14 @@ disabled: disabled }); } - - var keys = get_names(_symbols2); // case of list as first argument ((x . y) ...) or (x ... ...) + var keys = get_names(_symbols2); + // case of list as first argument ((x . y) ...) or (x ... ...) // we need to recursively process the list // if we have pattern (_ (x y z ...) ...) and code (foo (1 2) (1 2)) // x an y will be arrays of [1 1] and [2 2] and z will be array // of rest, x will also have it's own mapping to 1 and y to 2 // in case of usage outside of ellipsis list e.g.: (x y) - var is_spread = expr.car instanceof LSymbol && LSymbol.is(expr.cdr.cdr.car, ellipsis_symbol); - if (expr.car instanceof Pair || is_spread) { // lists is free ellipsis on pairs ((???) ...) // TODO: will this work in every case? Do we need to handle @@ -11308,41 +10341,31 @@ if (bindings['...'].lists[0] === _nil) { return _nil; } - var new_expr = expr.car; - if (is_spread) { new_expr = new Pair(expr.car, new Pair(expr.cdr.car, _nil)); } - log('>> 2'); var result; - if (keys.length) { log('>> 2 (a)'); - var _bind = _objectSpread({}, _symbols2); - result = _nil; - var _loop = function _loop() { if (!have_binding(_bind)) { return "break"; } - var new_bind = {}; - var next = function next(key, value) { // ellipsis decide it what should be the next value // there are two cases ((a . b) ...) and (a ...) new_bind[key] = value; }; - var car = transform_ellipsis_expr(new_expr, _bind, { nested: true - }, next); // undefined can be null caused by null binding + }, next); + // undefined can be null caused by null binding // on empty ellipsis - if (car !== undefined) { if (is_spread) { if (result === _nil) { @@ -11354,61 +10377,46 @@ result = new Pair(car, result); } } - _bind = new_bind; }; - while (true) { var _ret = _loop(); - if (_ret === "break") break; } - if (result !== _nil && !is_spread) { result = result.reverse(); - } // case of (list) ... (rest code) - - + } + // case of (list) ... (rest code) if (expr.cdr.cdr !== _nil && !LSymbol.is(expr.cdr.cdr.car, ellipsis_symbol)) { var _rest6 = traverse(expr.cdr.cdr, { disabled: disabled }); - return result.append(_rest6); } - return result; } else { log('>> 3'); var car = transform_ellipsis_expr(expr.car, _symbols2, { nested: true }); - if (car) { return new Pair(car, _nil); } - return _nil; } } else if (expr.car instanceof LSymbol) { log('>> 4'); - if (LSymbol.is(expr.cdr.cdr.car, ellipsis_symbol)) { // case (x ... ...) log('>> 4 (a)'); } else { log('>> 4 (b)'); - } // case: (x ...) - - + } + // case: (x ...) var name = expr.car.__name__; - var _bind2 = _defineProperty({}, name, _symbols2[name]); - var _is_null = _symbols2[name] === null; - var _result2 = _nil; - var _loop2 = function _loop2() { if (!have_binding(_bind2, true)) { log({ @@ -11416,74 +10424,58 @@ }); return "break"; } - var new_bind = {}; - var next = function next(key, value) { new_bind[key] = value; }; - var value = transform_ellipsis_expr(expr, _bind2, { nested: false }, next); log({ value: value.toString() }); - if (typeof value !== 'undefined') { _result2 = new Pair(value, _result2); } - _bind2 = new_bind; }; - while (true) { var _ret2 = _loop2(); - if (_ret2 === "break") break; } - if (_result2 !== _nil) { _result2 = _result2.reverse(); - } // case if (x ... y ...) second spread is not processed + } + // case if (x ... y ...) second spread is not processed // and (??? . x) last symbol // by ellipsis transformation - - if (expr.cdr instanceof Pair) { if (expr.cdr.cdr instanceof Pair || expr.cdr.cdr instanceof LSymbol) { var node = traverse(expr.cdr.cdr, { disabled: disabled }); - if (_is_null) { return node; } - log('<<<< 1'); - _result2.append(node); } } - log('<<<< 2'); return _result2; } } - var head = traverse(expr.car, { disabled: disabled }); var rest; var is_syntax; - if (expr.car instanceof LSymbol) { var value = scope.get(expr.car, { throwError: false }); is_syntax = value instanceof Macro && value.__name__ === 'syntax-rules'; } - if (is_syntax) { if (expr.cdr.car instanceof LSymbol) { rest = new Pair(traverse(expr.cdr.car, { @@ -11496,14 +10488,12 @@ disabled: disabled })); } - log('REST >>>> ' + rest.toString()); } else { rest = traverse(expr.cdr, { disabled: disabled }); } - log({ a: true, car: toString(expr.car), @@ -11513,150 +10503,118 @@ }); return new Pair(head, rest); } - if (expr instanceof LSymbol) { if (disabled && LSymbol.is(expr, ellipsis_symbol)) { return expr; } - var _symbols3 = Object.keys(bindings['...'].symbols); - var _name8 = expr.literal(); // TODO: slow - - if (_symbols3.includes(_name8)) { var msg = "missing ellipsis symbol next to name `".concat(_name8, "'"); throw new Error("syntax-rules: ".concat(msg)); } - var _value2 = transform(expr); - if (typeof _value2 !== 'undefined') { return _value2; } } - return expr; } - return traverse(expr, {}); - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // :: Check for nullish values // ---------------------------------------------------------------------- - - function is_null(value) { return is_undef(value) || value === _nil || value === null; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function is_function(o) { return typeof o === 'function' && typeof o.bind === 'function'; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function is_continuation(o) { return o instanceof Continuation; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function is_callable(o) { return is_function(o) || is_continuation(o); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function is_promise(o) { if (o instanceof QuotedPromise) { return false; } - if (o instanceof Promise) { return true; } - return o && is_function(o.then); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function is_undef(value) { return typeof value === 'undefined'; - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // :: Function utilities // ---------------------------------------------------------------------- - - function box(object) { // We only need to box lips data and arrays. Object don't need // to be boxed, but values from objects will be boxed when accessed. switch (_typeof(object)) { case 'string': return LString(object); - case 'bigint': return LNumber(object); - case 'number': if (Number.isNaN(object)) { return nan; } else { return LNumber(object); } - } - return object; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function map_object(object, fn) { var props = Object.getOwnPropertyNames(object); var symbols = Object.getOwnPropertySymbols(object); props.concat(symbols).forEach(function (key) { - var value = fn(object[key]); // check if property is read only, happen with webpack + var value = fn(object[key]); + // check if property is read only, happen with webpack // and __esModule, it can happen for other properties as well - var descriptor = Object.getOwnPropertyDescriptor(object, key); - if (!descriptor || descriptor.writable && object[key] !== value) { object[key] = value; } }); return object; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function unbox(object) { // LCharacter is unboxable #233 var lips_type = [LString, LNumber].some(function (x) { return object instanceof x; }); - if (lips_type) { return object.valueOf(); } - if (object instanceof Array) { return object.map(unbox); } - if (object instanceof QuotedPromise) { delete object.then; } - if (is_plain_object(object)) { return map_object(object, unbox); } - return object; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function patch_value(value, context) { if (value instanceof Pair) { value.markCycles(); return quote(value); } - if (is_function(value)) { // original function can be restored using unbind function // only real JS function require to be bound @@ -11664,44 +10622,37 @@ return bind(value, context); } } - return box(value); - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // :: Function gets original function that was binded with props // ---------------------------------------------------------------------- - - function unbind(obj) { if (is_bound(obj)) { return obj[__fn__]; } - return obj; - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // :: Function binds with context that can be optionally unbind // :: get original function with unbind // ---------------------------------------------------------------------- - - function bind(fn, context) { if (fn[Symbol["for"]('__bound__')]) { return fn; } - var bound = fn.bind(context); var props = Object.getOwnPropertyNames(fn); - var _iterator9 = _createForOfIteratorHelper(props), - _step9; - + _step9; try { for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) { var prop = _step9.value; - if (filter_fn_names(prop)) { try { bound[prop] = fn[prop]; - } catch (e) {// ignore error from express.js while accessing bodyParser + } catch (e) { + // ignore error from express.js while accessing bodyParser } } } @@ -11710,101 +10661,76 @@ } finally { _iterator9.f(); } - hidden_prop(bound, '__fn__', fn); hidden_prop(bound, '__context__', context); hidden_prop(bound, '__bound__', true); - if (is_native_function(fn)) { hidden_prop(bound, '__native__', true); } - if (is_plain_object(context) && is_lambda(fn)) { hidden_prop(bound, '__method__', true); } - bound.valueOf = function () { return fn; }; - return bound; - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // Function used to check if function should not get unboxed arguments, // so you can call Object.getPrototypeOf for lips data types // this is case, see dir function and #73 // ---------------------------------------------------------------------- - - function is_object_bound(obj) { return is_bound(obj) && obj[Symbol["for"]('__context__')] === Object; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function is_bound(obj) { return !!(is_function(obj) && obj[__fn__]); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function lips_context(obj) { if (is_function(obj)) { var context = obj[__context__]; - if (context && (context === lips || context.constructor && context.constructor.__class__)) { return true; } } - return false; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function is_port(obj) { return obj instanceof InputPort || obj instanceof OutputPort; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function is_port_method(obj) { if (is_function(obj)) { if (is_port(obj[__context__])) { return true; } } - return false; - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // Hidden props // ---------------------------------------------------------------------- - - var __context__ = Symbol["for"]('__context__'); - var __fn__ = Symbol["for"]('__fn__'); - var __data__ = Symbol["for"]('__data__'); - var __ref__ = Symbol["for"]('__ref__'); - var __cycles__ = Symbol["for"]('__cycles__'); - var __class__ = Symbol["for"]('__class__'); - var __method__ = Symbol["for"]('__method__'); - var __prototype__ = Symbol["for"]('__prototype__'); - - var __lambda__ = Symbol["for"]('__lambda__'); // ---------------------------------------------------------------------- + var __lambda__ = Symbol["for"]('__lambda__'); + // ---------------------------------------------------------------------- // :: Function bind fn with context but it also move all props // :: mostly used for Object function // ---------------------------------------------------------------------- - - var exluded_names = ['name', 'length', 'caller', 'callee', 'arguments', 'prototype']; - function filter_fn_names(name) { return !exluded_names.includes(name); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function hidden_prop(obj, name, value) { Object.defineProperty(obj, Symbol["for"](name), { get: function get() { @@ -11814,9 +10740,8 @@ configurable: false, enumerable: false }); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function set_fn_length(fn, length) { try { Object.defineProperty(fn, 'length', { @@ -11834,67 +10759,54 @@ var wrapper = new Function("f", "return function(".concat(args, ") {\n return f.apply(this, arguments);\n };")); return wrapper(fn); } - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function is_lambda(obj) { return obj && obj[__lambda__]; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function is_method(obj) { return obj && obj[__method__]; - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function is_raw_lambda(fn) { return is_lambda(fn) && !fn[__prototype__] && !is_method(fn) && !is_port_method(fn); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function is_native_function(fn) { var _native = Symbol["for"]('__native__'); - return is_function(fn) && fn.toString().match(/\{\s*\[native code\]\s*\}/) && (fn.name.match(/^bound /) && fn[_native] === true || !fn.name.match(/^bound /) && !fn[_native]); - } // ---------------------------------------------------------------------- + } + // ---------------------------------------------------------------------- // :: function that return macro for let, let* and letrec // ---------------------------------------------------------------------- - - function let_macro(symbol) { var name; - switch (symbol) { case Symbol["for"]('letrec'): name = 'letrec'; break; - case Symbol["for"]('let'): name = 'let'; break; - case Symbol["for"]('let*'): name = 'let*'; break; - default: throw new Error('Invalid let_macro value'); } - return Macro.defmacro(name, function (code, options) { var dynamic_scope = options.dynamic_scope, - error = options.error, - macro_expand = options.macro_expand; - var args; // named let: + error = options.error, + macro_expand = options.macro_expand; + var args; + // named let: // (let iter ((x 10)) (iter (- x 1))) -> (let* ((iter (lambda (x) ... - if (code.car instanceof LSymbol) { if (!(code.cdr.car instanceof Pair || code.cdr.car === _nil)) { throw new Error('let require list of pairs'); } - var params; - if (code.cdr.car === _nil) { args = _nil; params = _nil; @@ -11906,7 +10818,6 @@ return pair.cdr.car; }); } - return Pair.fromArray([LSymbol('letrec'), [[code.car, Pair(LSymbol('lambda'), Pair(params, code.cdr.cdr))]], Pair(code.car, args)]); } else if (macro_expand) { // Macro.defmacro are special macros that should return lips code @@ -11914,20 +10825,16 @@ // macroexpand to prevent evaluation of code in normal let return; } - var self = this; args = global_env.get('list->array')(code.car); var env = self.inherit(name); var values, var_body_env; - if (name === 'let*') { var_body_env = env; } else if (name === 'let') { values = []; // collect potential promises } - var i = 0; - function exec() { var output = new Pair(new LSymbol('begin'), code.cdr); return _evaluate(output, { @@ -11936,14 +10843,11 @@ error: error }); } - return function loop() { var pair = args[i++]; - if (dynamic_scope) { dynamic_scope = name === 'let*' ? env : self; } - if (!pair) { // resolve all promises if (values && values.length) { @@ -11951,7 +10855,6 @@ return x.value; }); var promises = v.filter(is_promise); - if (promises.length) { return promise_all(v).then(function (arr) { for (var i = 0, len = arr.length; i < len; ++i) { @@ -11960,13 +10863,12 @@ }).then(exec); } else { var _iterator10 = _createForOfIteratorHelper(values), - _step10; - + _step10; try { for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) { var _step10$value = _step10.value, - _name9 = _step10$value.name, - _value3 = _step10$value.value; + _name9 = _step10$value.name, + _value3 = _step10$value.value; env.set(_name9, _value3); } } catch (err) { @@ -11976,7 +10878,6 @@ } } } - return exec(); } else { if (name === 'let') { @@ -11984,17 +10885,14 @@ } else if (name === 'letrec') { var_body_env = env; } - var value = _evaluate(pair.cdr.car, { env: var_body_env, dynamic_scope: dynamic_scope, error: error }); - if (name === 'let*') { var_body_env = env = var_body_env.inherit('let*[' + i + ']'); } - if (values) { values.push({ name: pair.car, @@ -12010,24 +10908,19 @@ } }(); }); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function pararel(name, fn) { return new Macro(name, function (code) { var _ref23 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - dynamic_scope = _ref23.dynamic_scope, - error = _ref23.error; - + dynamic_scope = _ref23.dynamic_scope, + error = _ref23.error; var env = this; - if (dynamic_scope) { dynamic_scope = this; } - var node = code; var results = []; - while (node instanceof Pair) { results.push(_evaluate(node.car, { env: env, @@ -12036,37 +10929,30 @@ })); node = node.cdr; } - var havePromises = results.filter(is_promise).length; - if (havePromises) { return promise_all(results).then(fn.bind(this)); } else { return fn.call(this, results); } }); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function guard_math_call(fn) { for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) { args[_key6 - 1] = arguments[_key6]; } - args.forEach(function (arg) { typecheck('', arg, 'number'); }); return fn.apply(void 0, args); - } // ---------------------------------------------------------------------- - - + } + // ---------------------------------------------------------------------- function pipe() { var _this6 = this; - for (var _len7 = arguments.length, fns = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) { fns[_key7] = arguments[_key7]; } - fns.forEach(function (fn, i) { typecheck('pipe', fn, 'function', i + 1); }); @@ -12074,136 +10960,112 @@ for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) { args[_key8] = arguments[_key8]; } - return fns.reduce(function (args, f) { return [f.apply(_this6, args)]; }, args)[0]; }; - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function compose() { for (var _len9 = arguments.length, fns = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) { fns[_key9] = arguments[_key9]; } - fns.forEach(function (fn, i) { typecheck('compose', fn, 'function', i + 1); }); return pipe.apply(void 0, _toConsumableArray(fns.reverse())); - } // ------------------------------------------------------------------------- + } + // ------------------------------------------------------------------------- // :: fold functions generator // ------------------------------------------------------------------------- - - function fold(name, fold) { var self = this; return function recur(fn, init) { typecheck(name, fn, 'function'); - for (var _len10 = arguments.length, lists = new Array(_len10 > 2 ? _len10 - 2 : 0), _key10 = 2; _key10 < _len10; _key10++) { lists[_key10 - 2] = arguments[_key10]; } - if (lists.some(is_null)) { if (typeof init === 'number') { return LNumber(init); } - return init; } else { return fold.call.apply(fold, [self, recur, fn, init].concat(lists)); } }; - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function limit_math_op(n, fn) { // + 1 so it include function in guard_math_call return limit(n + 1, curry(guard_math_call, fn)); - } // ------------------------------------------------------------------------- + } + // ------------------------------------------------------------------------- // :: some functional magic // ------------------------------------------------------------------------- - - var single_math_op = curry(limit_math_op, 1); - var binary_math_op = curry(limit_math_op, 2); // ------------------------------------------------------------------------- - + var binary_math_op = curry(limit_math_op, 2); + // ------------------------------------------------------------------------- function reduce_math_op(fn) { var init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; return function () { for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) { args[_key11] = arguments[_key11]; } - if (init !== null) { args = [init].concat(_toConsumableArray(args)); } - return args.reduce(binary_math_op(fn)); }; - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function curry(fn) { for (var _len12 = arguments.length, init_args = new Array(_len12 > 1 ? _len12 - 1 : 0), _key12 = 1; _key12 < _len12; _key12++) { init_args[_key12 - 1] = arguments[_key12]; } - typecheck('curry', fn, 'function'); var len = fn.length; return function () { var args = init_args.slice(); - function call() { for (var _len13 = arguments.length, more_args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) { more_args[_key13] = arguments[_key13]; } - args = args.concat(more_args); - if (args.length >= len) { return fn.apply(this, args); } else { return call; } } - return call.apply(this, arguments); }; - } // ------------------------------------------------------------------------- + } + // ------------------------------------------------------------------------- // return function with limited number of arguments - - function limit(n, fn) { typecheck('limit', fn, 'function', 2); return function () { for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) { args[_key14] = arguments[_key14]; } - return fn.apply(void 0, _toConsumableArray(args.slice(0, n))); }; - } // ------------------------------------------------------------------------- + } + // ------------------------------------------------------------------------- // :: Character object representation // ------------------------------------------------------------------------- - - function LCharacter(_char7) { if (typeof this !== 'undefined' && !(this instanceof LCharacter) || typeof this === 'undefined') { return new LCharacter(_char7); } - if (_char7 instanceof LString) { _char7 = _char7.valueOf(); } - var name; - if (Array.from(_char7).length > 1) { // this is name _char7 = _char7.toLowerCase(); - if (LCharacter.__names__[_char7]) { name = _char7; _char7 = LCharacter.__names__[_char7]; @@ -12215,12 +11077,10 @@ } else { name = LCharacter.__rev_names__[_char7]; } - Object.defineProperty(this, '__char__', { value: _char7, enumerable: true }); - if (name) { Object.defineProperty(this, '__name__', { value: name, @@ -12228,38 +11088,31 @@ }); } } - LCharacter.__names__ = characters; LCharacter.__rev_names__ = {}; Object.keys(LCharacter.__names__).forEach(function (key) { var value = LCharacter.__names__[key]; LCharacter.__rev_names__[value] = key; }); - LCharacter.prototype.toUpperCase = function () { return LCharacter(this.__char__.toUpperCase()); }; - LCharacter.prototype.toLowerCase = function () { return LCharacter(this.__char__.toLowerCase()); }; - LCharacter.prototype.toString = function () { return '#\\' + (this.__name__ || this.__char__); }; - LCharacter.prototype.valueOf = LCharacter.prototype.serialize = function () { return this.__char__; - }; // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- // :: String wrapper that handle copy and in place change // ------------------------------------------------------------------------- - - function LString(string) { if (typeof this !== 'undefined' && !(this instanceof LString) || typeof this === 'undefined') { return new LString(string); } - if (string instanceof Array) { this.__string__ = string.map(function (x, i) { typecheck('LString', x, 'character', i + 1); @@ -12269,27 +11122,21 @@ this.__string__ = string.valueOf(); } } - { var ignore = ['length', 'constructor']; - var _keys = Object.getOwnPropertyNames(String.prototype).filter(function (name) { return !ignore.includes(name); }); - var wrap = function wrap(fn) { return function () { for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) { args[_key15] = arguments[_key15]; } - return fn.apply(this.__string__, args); }; }; - var _iterator11 = _createForOfIteratorHelper(_keys), - _step11; - + _step11; try { for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) { var key = _step11.value; @@ -12303,29 +11150,24 @@ } LString.prototype[Symbol.iterator] = /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() { var chars, _i4, _chars, _char8; - return _regeneratorRuntime.wrap(function _callee13$(_context13) { while (1) { switch (_context13.prev = _context13.next) { case 0: chars = Array.from(this.__string__); _i4 = 0, _chars = chars; - case 2: if (!(_i4 < _chars.length)) { _context13.next = 9; break; } - _char8 = _chars[_i4]; _context13.next = 6; return LCharacter(_char8); - case 6: _i4++; _context13.next = 2; break; - case 9: case "end": return _context13.stop(); @@ -12333,25 +11175,20 @@ } }, _callee13, this); }); - LString.prototype.serialize = function () { return this.valueOf(); }; - LString.isString = function (x) { return x instanceof LString || typeof x === 'string'; }; - LString.prototype.get = function (n) { typecheck('LString::get', n, 'number'); return Array.from(this.__string__)[n.valueOf()]; }; - LString.prototype.cmp = function (string) { typecheck('LString::cmp', string, 'string'); var a = this.valueOf(); var b = string.valueOf(); - if (a < b) { return -1; } else if (a === b) { @@ -12360,152 +11197,116 @@ return 1; } }; - LString.prototype.lower = function () { return LString(this.__string__.toLowerCase()); }; - LString.prototype.upper = function () { return LString(this.__string__.toUpperCase()); }; - LString.prototype.set = function (n, _char9) { typecheck('LString::set', n, 'number'); typecheck('LString::set', _char9, ['string', 'character']); n = n.valueOf(); - if (_char9 instanceof LCharacter) { _char9 = _char9.__char__; } - var string = []; - if (n > 0) { string.push(this.__string__.substring(0, n)); } - string.push(_char9); - if (n < this.__string__.length - 1) { string.push(this.__string__.substring(n + 1)); } - this.__string__ = string.join(''); }; - Object.defineProperty(LString.prototype, "length", { get: function get() { return this.__string__.length; } }); - LString.prototype.clone = function () { return LString(this.valueOf()); }; - LString.prototype.fill = function (_char10) { typecheck('LString::fill', _char10, ['string', 'character']); - if (_char10 instanceof LCharacter) { _char10 = _char10.toString(); } - var len = this.__string__.length; this.__string__ = new Array(len + 1).join(_char10); - }; // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- // :: Number wrapper that handle BigNumbers // ------------------------------------------------------------------------- - - function LNumber(n) { var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - if (n instanceof LNumber) { return n; } - if (typeof this !== 'undefined' && !(this instanceof LNumber) || typeof this === 'undefined') { return new LNumber(n, force); } - if (typeof n === 'undefined') { throw new Error('Invalid LNumber constructor call'); } - var _type = LNumber.getType(n); - if (LNumber.types[_type]) { return LNumber.types[_type](n, force); } - var parsable = n instanceof Array && LString.isString(n[0]) && LNumber.isNumber(n[1]); - if (n instanceof LNumber) { return LNumber(n.value); } - if (!LNumber.isNumber(n) && !parsable) { throw new Error("You can't create LNumber from ".concat(type(n))); - } // prevent infinite loop https://github.com/indutny/bn.js/issues/186 - - + } + // prevent infinite loop https://github.com/indutny/bn.js/issues/186 if (n === null) { n = 0; } - var value; - if (parsable) { var _n = n, - _n2 = _slicedToArray(_n, 2), - str = _n2[0], - radix = _n2[1]; - + _n2 = _slicedToArray(_n, 2), + str = _n2[0], + radix = _n2[1]; if (str instanceof LString) { str = str.valueOf(); } - if (radix instanceof LNumber) { radix = radix.valueOf(); } - var sign = str.match(/^([+-])/); var minus = false; - if (sign) { str = str.replace(/^[+-]/, ''); - if (sign[1] === '-') { minus = true; } } } - if (Number.isNaN(n)) { return LFloat(n); } else if (typeof BigInt !== 'undefined') { if (typeof n !== 'bigint') { if (parsable) { - var prefix; // default number base (radix) supported by BigInt constructor - + var prefix; + // default number base (radix) supported by BigInt constructor switch (radix) { case 8: prefix = '0o'; break; - case 16: prefix = '0x'; break; - case 2: prefix = '0b'; break; - case 10: prefix = ''; break; } - if (typeof prefix === 'undefined') { // non standard radix we convert by hand var n_radix = BigInt(radix); @@ -12520,29 +11321,25 @@ } else { value = BigInt(n); } - if (minus) { value *= BigInt(-1); } } else { value = n; } - return LBigInteger(value, true); } else if (typeof BN !== 'undefined' && !(n instanceof BN)) { if (n instanceof Array) { return LBigInteger(_construct(BN, _toConsumableArray(n))); } - return LBigInteger(new BN(n)); } else if (parsable) { this.constant(parseInt(str, radix), 'integer'); } else { this.constant(n, 'integer'); } - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- LNumber.prototype.constant = function (value, type) { Object.defineProperty(this, '__value__', { value: value, @@ -12552,179 +11349,143 @@ value: type, enumerable: true }); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.types = { "float": function float(n) { return new LFloat(n); }, complex: function complex(n) { var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - if (!LNumber.isComplex(n)) { n = { im: 0, re: n }; } - return new LComplex(n, force); }, rational: function rational(n) { var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - if (!LNumber.isRational(n)) { n = { num: n, denom: 1 }; } - return new LRational(n, force); } - }; // ------------------------------------------------------------------------- - + }; + // ------------------------------------------------------------------------- LNumber.prototype.serialize = function () { return this.__value__; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.prototype.isNaN = function () { return Number.isNaN(this.__value__); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.prototype.gcd = function (b) { // ref: https://rosettacode.org/wiki/Greatest_common_divisor#JavaScript var a = this.abs(); b = b.abs(); - if (b.cmp(a) === 1) { var temp = a; a = b; b = temp; } - while (true) { a = a.rem(b); - if (a.cmp(0) === 0) { return b; } - b = b.rem(a); - if (b.cmp(0) === 0) { return a; } } - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.isFloat = function isFloat(n) { return n instanceof LFloat || Number(n) === n && n % 1 !== 0; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.isNumber = function (n) { return n instanceof LNumber || LNumber.isNative(n) || LNumber.isBN(n); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.isComplex = function (n) { if (!n) { return false; } - var ret = n instanceof LComplex || (LNumber.isNumber(n.im) || Number.isNaN(n.im)) && (LNumber.isNumber(n.re) || Number.isNaN(n.re)); return ret; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.isRational = function (n) { if (!n) { return false; } - return n instanceof LRational || LNumber.isNumber(n.num) && LNumber.isNumber(n.denom); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.isInteger = function (n) { if (!(LNumber.isNative(n) || n instanceof LNumber)) { return false; } - if (LNumber.isFloat(n)) { return false; } - if (LNumber.isRational(n)) { return false; } - if (LNumber.isComplex(n)) { return false; } - return true; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.isNative = function (n) { return typeof n === 'bigint' || typeof n === 'number'; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.isBigInteger = function (n) { return n instanceof LBigInteger || typeof n === 'bigint' || LNumber.isBN(n); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.isBN = function (n) { return typeof BN !== 'undefined' && n instanceof BN; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.getArgsType = function (a, b) { if (a instanceof LFloat || b instanceof LFloat) { return LFloat; } - if (a instanceof LBigInteger || b instanceof LBigInteger) { return LBigInteger; } - return LNumber; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.prototype.toString = function (radix) { if (Number.isNaN(this.__value__)) { return '+nan.0'; } - if (radix > 2 && radix < 36) { return this.__value__.toString(radix); } - return this.__value__.toString(); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.prototype.asType = function (n) { var _type = LNumber.getType(this); - return LNumber.types[_type] ? LNumber.types[_type](n) : LNumber(n); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.prototype.isBigNumber = function () { return typeof this.__value__ === 'bigint' || typeof BN !== 'undefined' && !(this.value instanceof BN); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- ['floor', 'ceil', 'round'].forEach(function (fn) { LNumber.prototype[fn] = function () { if (this["float"] || LNumber.isFloat(this.__value__)) { @@ -12733,24 +11494,22 @@ return LNumber(Math[fn](this.valueOf())); } }; - }); // ------------------------------------------------------------------------- - + }); + // ------------------------------------------------------------------------- LNumber.prototype.valueOf = function () { if (LNumber.isNative(this.__value__)) { return Number(this.__value__); } else if (LNumber.isBN(this.__value__)) { return this.__value__.toNumber(); } - }; // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- // Type coercion matrix // ------------------------------------------------------------------------- - - var matrix = function () { var i = function i(a, b) { return [a, b]; }; - return { bigint: { bigint: i, @@ -12813,15 +11572,13 @@ rational: complex('rational'), complex: function complex(a, b) { var _LNumber$coerce = LNumber.coerce(a.__re__, b.__re__), - _LNumber$coerce2 = _slicedToArray(_LNumber$coerce, 2), - a_re = _LNumber$coerce2[0], - b_re = _LNumber$coerce2[1]; - + _LNumber$coerce2 = _slicedToArray(_LNumber$coerce, 2), + a_re = _LNumber$coerce2[0], + b_re = _LNumber$coerce2[1]; var _LNumber$coerce3 = LNumber.coerce(a.__im__, b.__im__), - _LNumber$coerce4 = _slicedToArray(_LNumber$coerce3, 2), - a_im = _LNumber$coerce4[0], - b_im = _LNumber$coerce4[1]; - + _LNumber$coerce4 = _slicedToArray(_LNumber$coerce3, 2), + a_im = _LNumber$coerce4[0], + b_im = _LNumber$coerce4[1]; return [{ im: a_im, re: a_re @@ -12859,7 +11616,6 @@ } } }; - function complex(type) { return function (a, b) { return [{ @@ -12871,76 +11627,61 @@ }]; }; } - }(); // ------------------------------------------------------------------------- - - + }(); + // ------------------------------------------------------------------------- function coerce(type_a, type_b, a, b) { return matrix[type_a][type_b](a, b); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- LNumber.coerce = function (a, b) { var a_type = LNumber.getType(a); var b_type = LNumber.getType(b); - if (!matrix[a_type]) { throw new Error("LNumber::coerce unknown lhs type ".concat(a_type)); } else if (!matrix[a_type][b_type]) { throw new Error("LNumber::coerce unknown rhs type ".concat(b_type)); } - var tmp = matrix[a_type][b_type](a, b); return tmp.map(function (n) { return LNumber(n, true); }); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.prototype.coerce = function (n) { if (!(typeof n === 'number' || n instanceof LNumber)) { throw new Error("LNumber: you can't coerce ".concat(type(n))); } - if (typeof n === 'number') { n = LNumber(n); } - return LNumber.coerce(this, n); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.getType = function (n) { if (n instanceof LNumber) { return n.__type__; } - if (LNumber.isFloat(n)) { return 'float'; } - if (LNumber.isComplex(n)) { return 'complex'; } - if (LNumber.isRational(n)) { return 'rational'; } - if (typeof n === 'number') { return 'integer'; } - if (typeof BigInt !== 'undefined' && typeof n !== 'bigint' || typeof BN !== 'undefined' && !(n instanceof BN)) { return 'bigint'; } - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.prototype.isFloat = function () { return !!(LNumber.isFloat(this.__value__) || this["float"]); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- var mapping = { 'add': '+', 'sub': '-', @@ -12956,12 +11697,11 @@ var rev_mapping = {}; Object.keys(mapping).forEach(function (key) { rev_mapping[mapping[key]] = key; - LNumber.prototype[key] = function (n) { return this.op(mapping[key], n); }; - }); // ------------------------------------------------------------------------- - + }); + // ------------------------------------------------------------------------- LNumber._ops = { '*': function _(a, b) { return a * b; @@ -12973,7 +11713,6 @@ if (typeof b === 'undefined') { return -a; } - return a - b; }, '/': function _(a, b) { @@ -12997,37 +11736,30 @@ '<<': function _(a, b) { return a << b; } - }; // ------------------------------------------------------------------------- - + }; + // ------------------------------------------------------------------------- LNumber.prototype.op = function (op, n) { if (typeof n === 'undefined') { return LNumber(LNumber._ops[op](this.valueOf())); } - if (typeof n === 'number') { n = LNumber(n); } - if (Number.isNaN(this.__value__) && !LNumber.isComplex(n) || !LNumber.isComplex(this) && Number.isNaN(n.__value__)) { return LNumber(NaN); } - var _this$coerce = this.coerce(n), - _this$coerce2 = _slicedToArray(_this$coerce, 2), - a = _this$coerce2[0], - b = _this$coerce2[1]; - + _this$coerce2 = _slicedToArray(_this$coerce, 2), + a = _this$coerce2[0], + b = _this$coerce2[1]; if (a._op) { return a._op(op, b); } - return LNumber(LNumber._ops[op](a, b)); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.prototype.sqrt = function () { var value = this.valueOf(); - if (this.cmp(0) < 0) { var im = Math.sqrt(-value); return LComplex({ @@ -13035,39 +11767,33 @@ im: im }); } - return LNumber(Math.sqrt(value)); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- var pow = function pow(a, b) { var e = typeof a === 'bigint' ? BigInt(1) : 1; return new Array(Number(b)).fill(0).reduce(function (x) { return x * a; }, e); - }; // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- // use native exponential operator if possible (it's way faster) // ------------------------------------------------------------------------- - - var exp_op = new Function('a,b', 'return a ** b'); - try { if (exp_op(2, 2) === 4) { pow = exp_op; } - } catch (e) {// ignore - } // ------------------------------------------------------------------------- - - + } catch (e) { + // ignore + } + // ------------------------------------------------------------------------- LNumber.prototype.pow = function (n) { var value; - var _this$coerce3 = this.coerce(n), - _this$coerce4 = _slicedToArray(_this$coerce3, 2), - a = _this$coerce4[0], - b = _this$coerce4[1]; - + _this$coerce4 = _slicedToArray(_this$coerce3, 2), + a = _this$coerce4[0], + b = _this$coerce4[1]; if (LNumber.isNative(a.__value__) && LNumber.isNative(b.__value__)) { value = pow(a.__value__, b.__value__); } else if (LNumber.isBN(a.__value__) && LNumber.isBN(b.__value__)) { @@ -13075,14 +11801,11 @@ } else if (a.pow) { return a.pow(b); } - return LNumber(value); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.prototype.abs = function () { var value = this.__value__; - if (LNumber.isNative(this.__value__)) { if (value < 0) { value = -value; @@ -13090,35 +11813,29 @@ } else if (LNumber.isBN(value)) { value.iabs(); } - return new LNumber(value); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.prototype.isOdd = function () { if (LNumber.isNative(this.__value__)) { if (this.isBigNumber()) { return this.__value__ % BigInt(2) === BigInt(1); } - return this.__value__ % 2 === 1; } else if (LNumber.isBN(this.__value__)) { return this.__value__.isOdd(); } - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.prototype.isEven = function () { return !this.isOdd(); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LNumber.prototype.cmp = function (n) { var _this$coerce5 = this.coerce(n), - _this$coerce6 = _slicedToArray(_this$coerce5, 2), - a = _this$coerce6[0], - b = _this$coerce6[1]; - + _this$coerce6 = _slicedToArray(_this$coerce5, 2), + a = _this$coerce6[0], + b = _this$coerce6[1]; function cmp(a, b) { if (a.__value__ < b.__value__) { return -1; @@ -13128,7 +11845,6 @@ return 1; } } - if (a.__type__ === 'bigint') { if (LNumber.isNative(a.__value__)) { return cmp(a, b); @@ -13138,25 +11854,21 @@ } else if (a instanceof LFloat) { return cmp(a, b); } - }; // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- // :: COMPLEX TYPE // ------------------------------------------------------------------------- - - function LComplex(n) { var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - if (typeof this !== 'undefined' && !(this instanceof LComplex) || typeof this === 'undefined') { return new LComplex(n, force); } - if (n instanceof LComplex) { return LComplex({ im: n.__im__, re: n.__re__ }); } - if (LNumber.isNumber(n) && force) { if (!force) { return Number(n); @@ -13165,16 +11877,14 @@ var msg = "Invalid constructor call for LComplex expect &(:im :re ) object but got ".concat(toString(n)); throw new Error(msg); } - var im = n.im instanceof LNumber ? n.im : LNumber(n.im); var re = n.re instanceof LNumber ? n.re : LNumber(n.re); this.constant(im, re); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- LComplex.prototype = Object.create(LNumber.prototype); - LComplex.prototype.constructor = LComplex; // ------------------------------------------------------------------------- - + LComplex.prototype.constructor = LComplex; + // ------------------------------------------------------------------------- LComplex.prototype.constant = function (im, re) { Object.defineProperty(this, '__im__', { value: im, @@ -13188,17 +11898,15 @@ value: 'complex', enumerable: true }); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LComplex.prototype.serialize = function () { return { re: this.__re__, im: this.__im__ }; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LComplex.prototype.toRational = function (n) { if (LNumber.isFloat(this.__im__) && LNumber.isFloat(this.__re__)) { var im = LFloat(this.__im__).toRational(n); @@ -13208,16 +11916,13 @@ re: re }); } - return this; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LComplex.prototype.pow = function (n) { throw new Error('Not yet implemented'); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LComplex.prototype.add = function (n) { return this.complex_op('add', n, function (a_re, b_re, a_im, b_im) { return { @@ -13225,57 +11930,49 @@ im: a_im.add(b_im) }; }); - }; // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- // :: factor is used in / and modulus // ------------------------------------------------------------------------- - - LComplex.prototype.factor = function () { // fix rounding when calculating (/ 1.0 1/10+1/10i) if (this.__im__ instanceof LFloat || this.__im__ instanceof LFloat) { var re = this.__re__, - im = this.__im__; + im = this.__im__; var x, y; - if (re instanceof LFloat) { x = re.toRational().mul(re.toRational()); } else { x = re.mul(re); } - if (im instanceof LFloat) { y = im.toRational().mul(im.toRational()); } else { y = im.mul(im); } - return x.add(y); } else { return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__)); } - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LComplex.prototype.modulus = function () { return this.factor().sqrt(); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LComplex.prototype.conjugate = function () { return LComplex({ re: this.__re__, im: this.__im__.sub() }); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LComplex.prototype.sqrt = function () { - var r = this.modulus(); // code based ok Kawa Scheme source code (file DComplex.java) + var r = this.modulus(); + // code based ok Kawa Scheme source code (file DComplex.java) // Copyright (c) 1997 Per M.A. Bothner. // Released under MIT License - var re, im; - if (r.cmp(0) === 0) { re = im = r; } else if (this.__re__.cmp(0) === 1) { @@ -13283,31 +11980,24 @@ im = this.__im__.div(re).div(2); } else { im = LFloat(0.5).mul(r.sub(this.__re__)).sqrt(); - if (this.__im__.cmp(0) === -1) { im = im.sub(); } - re = this.__im__.div(im).div(2); } - return LComplex({ im: im, re: re }); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LComplex.prototype.div = function (n) { if (LNumber.isNumber(n) && !LNumber.isComplex(n)) { if (!(n instanceof LNumber)) { n = LNumber(n); } - var _re = this.__re__.div(n); - var _im = this.__im__.div(n); - return LComplex({ re: _re, im: _im @@ -13315,42 +12005,32 @@ } else if (!LNumber.isComplex(n)) { throw new Error('[LComplex::div] Invalid value'); } - if (this.cmp(n) === 0) { var _this$coerce7 = this.coerce(n), - _this$coerce8 = _slicedToArray(_this$coerce7, 2), - _a = _this$coerce8[0], - _b = _this$coerce8[1]; - + _this$coerce8 = _slicedToArray(_this$coerce7, 2), + _a = _this$coerce8[0], + _b = _this$coerce8[1]; var ret = _a.__im__.div(_b.__im__); - return ret.coerce(_b.__re__)[0]; } - var _this$coerce9 = this.coerce(n), - _this$coerce10 = _slicedToArray(_this$coerce9, 2), - a = _this$coerce10[0], - b = _this$coerce10[1]; - + _this$coerce10 = _slicedToArray(_this$coerce9, 2), + a = _this$coerce10[0], + b = _this$coerce10[1]; var denom = b.factor(); var conj = b.conjugate(); var num = a.mul(conj); - if (!LNumber.isComplex(num)) { return num.div(denom); } - var re = num.__re__.op('/', denom); - var im = num.__im__.op('/', denom); - return LComplex({ re: re, im: im }); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LComplex.prototype.sub = function (n) { return this.complex_op('sub', n, function (a_re, b_re, a_im, b_im) { return { @@ -13358,9 +12038,8 @@ im: a_im.sub(b_im) }; }); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LComplex.prototype.mul = function (n) { return this.complex_op('mul', n, function (a_re, b_re, a_im, b_im) { var ret = { @@ -13369,37 +12048,28 @@ }; return ret; }); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LComplex.prototype.complex_op = function (name, n, fn) { var _this7 = this; - var calc = function calc(re, im) { var result = fn(_this7.__re__, re, _this7.__im__, im); - if ('im' in result && 're' in result) { if (result.im.cmp(0) === 0) { return result.re; } - return LComplex(result, true); } - return result; }; - if (typeof n === 'undefined') { return calc(); } - if (LNumber.isNumber(n) && !LNumber.isComplex(n)) { if (!(n instanceof LNumber)) { n = LNumber(n); } - var _im2 = n.asType(0); - n = { __im__: _im2, __re__: n @@ -13407,176 +12077,140 @@ } else if (!LNumber.isComplex(n)) { throw new Error("[LComplex::".concat(name, "] Invalid value")); } - var re = n.__re__ instanceof LNumber ? n.__re__ : this.__re__.asType(n.__re__); var im = n.__im__ instanceof LNumber ? n.__im__ : this.__im__.asType(n.__im__); return calc(re, im); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LComplex._op = { '+': 'add', '-': 'sub', '*': 'mul', '/': 'div' - }; // ------------------------------------------------------------------------- - + }; + // ------------------------------------------------------------------------- LComplex.prototype._op = function (op, n) { var fn = LComplex._op[op]; return this[fn](n); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LComplex.prototype.cmp = function (n) { var _this$coerce11 = this.coerce(n), - _this$coerce12 = _slicedToArray(_this$coerce11, 2), - a = _this$coerce12[0], - b = _this$coerce12[1]; - + _this$coerce12 = _slicedToArray(_this$coerce11, 2), + a = _this$coerce12[0], + b = _this$coerce12[1]; var _a$__re__$coerce = a.__re__.coerce(b.__re__), - _a$__re__$coerce2 = _slicedToArray(_a$__re__$coerce, 2), - re_a = _a$__re__$coerce2[0], - re_b = _a$__re__$coerce2[1]; - + _a$__re__$coerce2 = _slicedToArray(_a$__re__$coerce, 2), + re_a = _a$__re__$coerce2[0], + re_b = _a$__re__$coerce2[1]; var re_cmp = re_a.cmp(re_b); - if (re_cmp !== 0) { return re_cmp; } else { var _a$__im__$coerce = a.__im__.coerce(b.__im__), - _a$__im__$coerce2 = _slicedToArray(_a$__im__$coerce, 2), - im_a = _a$__im__$coerce2[0], - im_b = _a$__im__$coerce2[1]; - + _a$__im__$coerce2 = _slicedToArray(_a$__im__$coerce, 2), + im_a = _a$__im__$coerce2[0], + im_b = _a$__im__$coerce2[1]; return im_a.cmp(im_b); } - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LComplex.prototype.valueOf = function () { return [this.__re__, this.__im__].map(function (x) { return x.valueOf(); }); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LComplex.prototype.toString = function () { var result; - if (this.__re__.cmp(0) !== 0) { result = [toString(this.__re__)]; } else { result = []; - } // NaN and inf already have sign - - + } + // NaN and inf already have sign var im = this.__im__.valueOf(); - var inf = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY].includes(im); var im_str = toString(this.__im__); - if (!inf && !Number.isNaN(im)) { var zero_check = this.__im__.cmp(0); - if (zero_check < 0 || zero_check === 0 && this.__im__._minus) { result.push('-'); } else { result.push('+'); } - im_str = im_str.replace(/^-/, ''); } - result.push(im_str); result.push('i'); return result.join(''); - }; // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- // :: FLOAT TYPE // ------------------------------------------------------------------------- - - function LFloat(n) { if (typeof this !== 'undefined' && !(this instanceof LFloat) || typeof this === 'undefined') { return new LFloat(n); } - if (!LNumber.isNumber(n)) { throw new Error('Invalid constructor call for LFloat'); } - if (n instanceof LNumber) { return LFloat(n.valueOf()); } - if (typeof n === 'number') { if (Object.is(n, -0)) { Object.defineProperty(this, '_minus', { value: true }); } - this.constant(n, 'float'); } - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- LFloat.prototype = Object.create(LNumber.prototype); - LFloat.prototype.constructor = LFloat; // ------------------------------------------------------------------------- - + LFloat.prototype.constructor = LFloat; + // ------------------------------------------------------------------------- LFloat.prototype.toString = function () { if (this.__value__ === Number.NEGATIVE_INFINITY) { return '-inf.0'; } - if (this.__value__ === Number.POSITIVE_INFINITY) { return '+inf.0'; } - if (Number.isNaN(this.__value__)) { return '+nan.0'; } - var str = this.__value__.toString(); - if (!LNumber.isFloat(this.__value__) && !str.match(/e/i)) { var result = str + '.0'; return this._minus ? '-' + result : result; } - return str.replace(/^([0-9]+)e/, '$1.0e'); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LFloat.prototype._op = function (op, n) { if (n instanceof LNumber) { n = n.__value__; } - var fn = LNumber._ops[op]; - if (op === '/' && this.__value__ === 0 && n === 0) { return NaN; } - return LFloat(fn(this.__value__, n)); - }; // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- // same approximation as in guile scheme - - LFloat.prototype.toRational = function () { var n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - if (n === null) { return toRational(this.__value__.valueOf()); } - return approxRatio(n.valueOf())(this.__value__.valueOf()); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LFloat.prototype.sqrt = function () { var value = this.valueOf(); - if (this.cmp(0) < 0) { var im = LFloat(Math.sqrt(-value)); return LComplex({ @@ -13584,59 +12218,48 @@ im: im }); } - return LFloat(Math.sqrt(value)); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LFloat.prototype.abs = function () { var value = this.valueOf(); - if (value < 0) { value = -value; } - return LFloat(value); - }; // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- // ref: https://rosettacode.org/wiki/Convert_decimal_number_to_rational // ------------------------------------------------------------------------- - - var toRational = approxRatio(1e-10); - function approxRatio(eps) { return function (n) { var gcde = function gcde(e, x, y) { - var _gcd = function _gcd(a, b) { - return b < e ? a : _gcd(b, a % b); - }; - - if (Number.isNaN(x) || Number.isNaN(y)) { - return NaN; - } - - return _gcd(Math.abs(x), Math.abs(y)); - }, - c = gcde(eps ? eps : 1 / 10000, 1, n); - + var _gcd = function _gcd(a, b) { + return b < e ? a : _gcd(b, a % b); + }; + if (Number.isNaN(x) || Number.isNaN(y)) { + return NaN; + } + return _gcd(Math.abs(x), Math.abs(y)); + }, + c = gcde(eps ? eps : 1 / 10000, 1, n); return LRational({ num: Math.floor(n / c), denom: Math.floor(1 / c) }); }; - } // ------------------------------------------------------------------------- + } + // ------------------------------------------------------------------------- // :: Source: Kawa gnu.math.RatNum.java // :: This algorithm is by Alan Bawden. It has been transcribed // :: with permission from Kawa copyright M.A. Bothner. // :: which was transcribed from from C-Gambit, copyright Marc Feeley. // ------------------------------------------------------------------------- - - function rationalize(x, y) { var a = x.sub(y); var b = x.add(y); var result; - if (a.cmp(b) > 0) { result = simplest_rational2(b, a); } else if (b.cmp(a) <= 0) { @@ -13648,19 +12271,15 @@ } else { result = LNumber(0); } - if (LNumber.isFloat(y) || LNumber.isFloat(x)) { return LFloat(result); } - return result; - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function simplest_rational2(x, y) { var fx = LNumber(x).floor(); var fy = LNumber(y).floor(); - if (x.cmp(fx) < 1) { return fx; } else if (fx.cmp(fy) === 0) { @@ -13670,22 +12289,17 @@ } else { return fx.add(LNumber(1)); } - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function LRational(n) { var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - if (typeof this !== 'undefined' && !(this instanceof LRational) || typeof this === 'undefined') { return new LRational(n, force); } - if (!LNumber.isRational(n)) { throw new Error('Invalid constructor call for LRational'); } - var num, denom; - if (n instanceof LRational) { num = LNumber(n.__num__); denom = LNumber(n.__denom__); @@ -13693,22 +12307,18 @@ num = LNumber(n.num); denom = LNumber(n.denom); } - if (!force && denom.cmp(0) !== 0) { var is_integer = num.op('%', denom).cmp(0) === 0; - if (is_integer) { return LNumber(num.div(denom)); } } - this.constant(num, denom); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- LRational.prototype = Object.create(LNumber.prototype); - LRational.prototype.constructor = LRational; // ------------------------------------------------------------------------- - + LRational.prototype.constructor = LRational; + // ------------------------------------------------------------------------- LRational.prototype.constant = function (num, denom) { Object.defineProperty(this, '__num__', { value: num, @@ -13722,103 +12332,78 @@ value: 'rational', enumerable: true }); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LRational.prototype.serialize = function () { return { num: this.__num__, denom: this.__denom__ }; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LRational.prototype.pow = function (n) { var cmp = n.cmp(0); - if (cmp === 0) { return LNumber(1); } - if (cmp === -1) { n = n.sub(); - var num = this.__denom__.pow(n); - var denom = this.__num__.pow(n); - return LRational({ num: num, denom: denom }); } - var result = this; n = n.valueOf(); - while (n > 1) { result = result.mul(this); n--; } - return result; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LRational.prototype.sqrt = function () { var num = this.__num__.sqrt(); - var denom = this.__denom__.sqrt(); - if (num instanceof LFloat || denom instanceof LFloat) { return num.div(denom); } - return LRational({ num: num, denom: denom }); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LRational.prototype.abs = function () { var num = this.__num__; var denom = this.__denom__; - if (num.cmp(0) === -1) { num = num.sub(); } - if (denom.cmp(0) !== 1) { denom = denom.sub(); } - return LRational({ num: num, denom: denom }); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LRational.prototype.cmp = function (n) { return LNumber(this.valueOf(), true).cmp(n); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LRational.prototype.toString = function () { var gcd = this.__num__.gcd(this.__denom__); - var num, denom; - if (gcd.cmp(1) !== 0) { num = this.__num__.div(gcd); - if (num instanceof LRational) { num = LNumber(num.valueOf(true)); } - denom = this.__denom__.div(gcd); - if (denom instanceof LRational) { denom = LNumber(denom.valueOf(true)); } @@ -13826,9 +12411,7 @@ num = this.__num__; denom = this.__denom__; } - var minus = this.cmp(0) < 0; - if (minus) { if (num.abs().cmp(denom.abs()) === 0) { return num.toString(); @@ -13836,130 +12419,102 @@ } else if (num.cmp(denom) === 0) { return num.toString(); } - return num.toString() + '/' + denom.toString(); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LRational.prototype.valueOf = function (exact) { if (this.__denom__.cmp(0) === 0) { if (this.__num__.cmp(0) < 0) { return Number.NEGATIVE_INFINITY; } - return Number.POSITIVE_INFINITY; } - if (exact) { return LNumber._ops['/'](this.__num__.value, this.__denom__.value); } - return LFloat(this.__num__.valueOf()).div(this.__denom__.valueOf()); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LRational.prototype.mul = function (n) { if (!(n instanceof LNumber)) { n = LNumber(n); // handle (--> 1/2 (mul 2)) } - if (LNumber.isRational(n)) { var num = this.__num__.mul(n.__num__); - var denom = this.__denom__.mul(n.__denom__); - return LRational({ num: num, denom: denom }); } - var _LNumber$coerce5 = LNumber.coerce(this, n), - _LNumber$coerce6 = _slicedToArray(_LNumber$coerce5, 2), - a = _LNumber$coerce6[0], - b = _LNumber$coerce6[1]; - + _LNumber$coerce6 = _slicedToArray(_LNumber$coerce5, 2), + a = _LNumber$coerce6[0], + b = _LNumber$coerce6[1]; return a.mul(b); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LRational.prototype.div = function (n) { if (!(n instanceof LNumber)) { n = LNumber(n); // handle (--> 1/2 (div 2)) } - if (LNumber.isRational(n)) { var num = this.__num__.mul(n.__denom__); - var denom = this.__denom__.mul(n.__num__); - return LRational({ num: num, denom: denom }); } - var _LNumber$coerce7 = LNumber.coerce(this, n), - _LNumber$coerce8 = _slicedToArray(_LNumber$coerce7, 2), - a = _LNumber$coerce8[0], - b = _LNumber$coerce8[1]; - + _LNumber$coerce8 = _slicedToArray(_LNumber$coerce7, 2), + a = _LNumber$coerce8[0], + b = _LNumber$coerce8[1]; var ret = a.div(b); return ret; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LRational.prototype._op = function (op, n) { return this[rev_mapping[op]](n); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LRational.prototype.sub = function (n) { if (typeof n === 'undefined') { return this.mul(-1); } - if (!(n instanceof LNumber)) { n = LNumber(n); // handle (--> 1/2 (sub 1)) } - if (LNumber.isRational(n)) { var num = n.__num__.sub(); - var denom = n.__denom__; return this.add(LRational({ num: num, denom: denom })); } - if (!(n instanceof LNumber)) { n = LNumber(n).sub(); } else { n = n.sub(); } - var _LNumber$coerce9 = LNumber.coerce(this, n), - _LNumber$coerce10 = _slicedToArray(_LNumber$coerce9, 2), - a = _LNumber$coerce10[0], - b = _LNumber$coerce10[1]; - + _LNumber$coerce10 = _slicedToArray(_LNumber$coerce9, 2), + a = _LNumber$coerce10[0], + b = _LNumber$coerce10[1]; return a.add(b); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LRational.prototype.add = function (n) { if (!(n instanceof LNumber)) { n = LNumber(n); // handle (--> 1/2 (add 1)) } - if (LNumber.isRational(n)) { var a_denom = this.__denom__; var b_denom = n.__denom__; var a_num = this.__num__; var b_num = n.__num__; var denom, num; - if (a_denom !== b_denom) { num = b_denom.mul(a_num).add(b_num.mul(a_denom)); denom = a_denom.mul(b_denom); @@ -13967,49 +12522,40 @@ num = a_num.add(b_num); denom = a_denom; } - return LRational({ num: num, denom: denom }); } - if (LNumber.isFloat(n)) { return LFloat(this.valueOf()).add(n); } - var _LNumber$coerce11 = LNumber.coerce(this, n), - _LNumber$coerce12 = _slicedToArray(_LNumber$coerce11, 2), - a = _LNumber$coerce12[0], - b = _LNumber$coerce12[1]; - + _LNumber$coerce12 = _slicedToArray(_LNumber$coerce11, 2), + a = _LNumber$coerce12[0], + b = _LNumber$coerce12[1]; return a.add(b); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- function LBigInteger(n, _native2) { if (typeof this !== 'undefined' && !(this instanceof LBigInteger) || typeof this === 'undefined') { return new LBigInteger(n, _native2); } - if (n instanceof LBigInteger) { return LBigInteger(n.__value__, n._native); } - if (!LNumber.isBigInteger(n)) { throw new Error('Invalid constructor call for LBigInteger'); } - this.constant(n, 'bigint'); Object.defineProperty(this, '_native', { value: _native2 }); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- LBigInteger.prototype = Object.create(LNumber.prototype); - LBigInteger.prototype.constructor = LBigInteger; // ------------------------------------------------------------------------- - + LBigInteger.prototype.constructor = LBigInteger; + // ------------------------------------------------------------------------- LBigInteger.bn_op = { '+': 'iadd', '-': 'isub', @@ -14022,79 +12568,63 @@ '<<': 'ishrn', '>>': 'ishln' }; - LBigInteger.prototype.serialize = function () { return this.__value__.toString(); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LBigInteger.prototype._op = function (op, n) { if (typeof n === 'undefined') { if (LNumber.isBN(this.__value__)) { op = LBigInteger.bn_op[op]; return LBigInteger(this.__value__.clone()[op](), false); } - return LBigInteger(LNumber._ops[op](this.__value__), true); } - if (LNumber.isBN(this.__value__) && LNumber.isBN(n.__value__)) { op = LBigInteger.bn_op[op]; return LBigInteger(this.__value__.clone()[op](n), false); } - var ret = LNumber._ops[op](this.__value__, n.__value__); - if (op === '/') { var is_integer = this.op('%', n).cmp(0) === 0; - if (is_integer) { return LNumber(ret); } - return LRational({ num: this, denom: n }); - } // use native calculation because it's real bigint value - - + } + // use native calculation because it's real bigint value return LBigInteger(ret, true); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- LBigInteger.prototype.sqrt = function () { var value; var minus = this.cmp(0) < 0; - if (LNumber.isNative(this.__value__)) { value = LNumber(Math.sqrt(minus ? -this.valueOf() : this.valueOf())); } else if (LNumber.isBN(this.__value__)) { value = minus ? this.__value__.neg().sqrt() : this.__value__.sqrt(); } - if (minus) { return LComplex({ re: 0, im: value }); } - return value; - }; // ------------------------------------------------------------------------- - - - LNumber.NaN = LNumber(NaN); // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- + LNumber.NaN = LNumber(NaN); + // ------------------------------------------------------------------------- // :: Port abstraction - read should be a function that return next line // ------------------------------------------------------------------------- - function InputPort(read) { var _this8 = this; - if (typeof this !== 'undefined' && !(this instanceof InputPort) || typeof this === 'undefined') { return new InputPort(read); } - typecheck('InputPort', read, 'function'); read_only(this, '__type__', text_port); var parser; @@ -14119,19 +12649,15 @@ _context14.next = 5; break; } - _context14.next = 3; return _this8._read(); - case 3: line = _context14.sent; parser = new Parser(line, { env: _this8 }); - case 5: return _context14.abrupt("return", _this8.__parser__); - case 6: case "end": return _context14.stop(); @@ -14139,14 +12665,11 @@ } }, _callee14); }))); - this.char_ready = function () { return !!this.__parser__ && this.__parser__.__lexer__.peek() !== eof; }; - this._make_defaults(); } - InputPort.prototype._make_defaults = function () { this.read = this._with_parser(function (parser) { return parser.read_object(); @@ -14160,42 +12683,34 @@ this.read_string = this._with_parser(function (parser, number) { if (!LNumber.isInteger(number)) { var _type4 = LNumber.getType(number); - typeErrorMessage('read-string', _type4, 'integer'); } - return parser.__lexer__.read_string(number.valueOf()); }); this.peek_char = this._with_parser(function (parser) { return parser.__lexer__.peek_char(); }); }; - InputPort.prototype._with_init_parser = function (make_parser, fn) { var self = this; return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() { var parser, - _len16, - args, - _key16, - _args17 = arguments; - + _len16, + args, + _key16, + _args17 = arguments; return _regeneratorRuntime.wrap(function _callee15$(_context15) { while (1) { switch (_context15.prev = _context15.next) { case 0: _context15.next = 2; return make_parser.call(self); - case 2: parser = _context15.sent; - for (_len16 = _args17.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) { args[_key16] = _args17[_key16]; } - return _context15.abrupt("return", fn.apply(void 0, [parser].concat(args))); - case 5: case "end": return _context15.stop(); @@ -14204,48 +12719,39 @@ }, _callee15); })); }; - InputPort.prototype.is_open = function () { return this._with_parser !== null; }; - InputPort.prototype.close = function () { var _this9 = this; - - this.__parser__ = null; // make content garbage collected, we assign null, + this.__parser__ = null; + // make content garbage collected, we assign null, // because the value is in prototype - this._with_parser = null; ['read', 'close', 'read_char', 'peek-char', 'read_line'].forEach(function (name) { _this9[name] = function () { throw new Error('input-port: port is closed'); }; }); - this.char_ready = function () { return false; }; }; - InputPort.prototype.toString = function () { return '#'; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- function OutputPort(write) { if (typeof this !== 'undefined' && !(this instanceof OutputPort) || typeof this === 'undefined') { return new OutputPort(write); } - typecheck('OutputPort', write, 'function'); read_only(this, '__type__', text_port); this.write = write; } - OutputPort.prototype.is_open = function () { return this._closed !== true; }; - OutputPort.prototype.close = function () { Object.defineProperty(this, '_closed', { get: function get() { @@ -14255,33 +12761,25 @@ configurable: false, enumerable: false }); - this.write = function () { throw new Error('output-port: port is closed'); }; }; - - OutputPort.prototype.flush = function () {// do nothing + OutputPort.prototype.flush = function () { + // do nothing }; - OutputPort.prototype.toString = function () { return '#'; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- var BufferedOutputPort = /*#__PURE__*/function (_OutputPort) { _inherits(BufferedOutputPort, _OutputPort); - var _super2 = _createSuper(BufferedOutputPort); - function BufferedOutputPort(fn) { var _this10; - _classCallCheck(this, BufferedOutputPort); - _this10 = _super2.call(this, function () { var _this11; - return (_this11 = _this10)._write.apply(_this11, arguments); }); typecheck('BufferedOutputPort', fn, 'function'); @@ -14293,13 +12791,11 @@ }); return _this10; } - _createClass(BufferedOutputPort, [{ key: "flush", value: function flush() { if (this._buffer.length) { this._fn(this._buffer.join('')); - this._buffer.length = 0; } } @@ -14307,17 +12803,14 @@ key: "_write", value: function _write() { var _this12 = this; - for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) { args[_key17] = arguments[_key17]; } - if (args.length) { args.forEach(function (arg) { _this12._buffer.push(arg); }); var last_value = this._buffer[this._buffer.length - 1]; - if (last_value.match(/\n$/)) { this._buffer[this._buffer.length - 1] = last_value.replace(/\n$/, ''); this.flush(); @@ -14325,68 +12818,53 @@ } } }]); - return BufferedOutputPort; }(OutputPort); // ------------------------------------------------------------------------- - - function OutputStringPort(toString) { var _this13 = this; - if (typeof this !== 'undefined' && !(this instanceof OutputStringPort) || typeof this === 'undefined') { return new OutputStringPort(toString); } - typecheck('OutputStringPort', toString, 'function'); read_only(this, '__type__', text_port); read_only(this, '__buffer__', []); - this.write = function (x) { if (!LString.isString(x)) { x = toString(x); } else { x = x.valueOf(); } - _this13.__buffer__.push(x); }; } - OutputStringPort.prototype = Object.create(OutputPort.prototype); OutputStringPort.prototype.constructor = OutputStringPort; - OutputStringPort.prototype.toString = function () { return '#'; }; - OutputStringPort.prototype.valueOf = function () { return this.__buffer__.map(function (x) { return x.valueOf(); }).join(''); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- function OutputFilePort(filename, fd) { var _this14 = this; - if (typeof this !== 'undefined' && !(this instanceof OutputFilePort) || typeof this === 'undefined') { return new OutputFilePort(filename, fd); } - typecheck('OutputFilePort', filename, 'string'); read_only(this, '__filename__', filename); read_only(this, '_fd', fd.valueOf(), { hidden: true }); read_only(this, '__type__', text_port); - this.write = function (x) { if (!LString.isString(x)) { x = toString(x); } else { x = x.valueOf(); } - _this14.fs().write(_this14._fd, x, function (err) { if (err) { throw err; @@ -14394,25 +12872,19 @@ }); }; } - OutputFilePort.prototype = Object.create(OutputPort.prototype); OutputFilePort.prototype.constructor = OutputFilePort; - OutputFilePort.prototype.fs = function () { if (!this._fs) { this._fs = this.internal('fs'); } - return this._fs; }; - OutputFilePort.prototype.internal = function (name) { return user_env.get('**internal-env**').get(name); }; - OutputFilePort.prototype.close = function () { var _this15 = this; - return new Promise(function (resolve, reject) { _this15.fs().close(_this15._fd, function (err) { if (err) { @@ -14427,19 +12899,15 @@ }); }); }; - OutputFilePort.prototype.toString = function () { return "#"); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- function InputStringPort(string, env) { var _this16 = this; - if (typeof this !== 'undefined' && !(this instanceof InputStringPort) || typeof this === 'undefined') { return new InputStringPort(string); } - typecheck('InputStringPort', string, 'string'); env = env || global_env; string = string.valueOf(); @@ -14449,31 +12917,24 @@ env: env }); } - return _this16.__parser__; }); read_only(this, '__type__', text_port); - this._make_defaults(); } - InputStringPort.prototype.char_ready = function () { return true; }; - InputStringPort.prototype = Object.create(InputPort.prototype); InputStringPort.prototype.constructor = InputStringPort; - InputStringPort.prototype.toString = function () { return "#"; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- function InputByteVectorPort(bytevectors) { if (typeof this !== 'undefined' && !(this instanceof InputByteVectorPort) || typeof this === 'undefined') { return new InputByteVectorPort(bytevectors); } - typecheck('InputByteVectorPort', bytevectors, 'uint8array'); read_only(this, '__vector__', bytevectors); read_only(this, '__type__', binary_port); @@ -14485,108 +12946,84 @@ }, set: function set(value) { typecheck('InputByteVectorPort::__index__', value, 'number'); - if (value instanceof LNumber) { value = value.valueOf(); } - if (typeof value === 'bigint') { value = Number(value); } - if (Math.floor(value) !== value) { throw new Error('InputByteVectorPort::__index__ value is ' + 'not integer'); } - index = value; } }); } - InputByteVectorPort.prototype = Object.create(InputPort.prototype); InputByteVectorPort.prototype.constructor = InputByteVectorPort; - InputByteVectorPort.prototype.toString = function () { return "#"; }; - InputByteVectorPort.prototype.close = function () { var _this17 = this; - read_only(this, '__vector__', _nil); ['read_u8', 'close', 'peek_u8', 'read_u8_vector'].forEach(function (name) { _this17[name] = function () { throw new Error('Input-binary-port: port is closed'); }; }); - this.char_ready = function () { return false; }; }; - InputByteVectorPort.prototype.u8_ready = function () { return true; }; - InputByteVectorPort.prototype.peek_u8 = function () { if (this.__index__ >= this.__vector__.length) { return eof; } - return this.__vector__[this.__index__]; }; - InputByteVectorPort.prototype.skip = function () { if (this.__index__ <= this.__vector__.length) { ++this.__index__; } }; - InputByteVectorPort.prototype.read_u8 = function () { var _byte = this.peek_u8(); - this.skip(); return _byte; }; - InputByteVectorPort.prototype.read_u8_vector = function (len) { if (typeof len === 'undefined') { len = this.__vector__.length; } else if (len > this.__index__ + this.__vector__.length) { len = this.__index__ + this.__vector__.length; } - if (this.peek_u8() === eof) { return eof; } - return this.__vector__.slice(this.__index__, len); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- function OutputByteVectorPort() { if (typeof this !== 'undefined' && !(this instanceof OutputByteVectorPort) || typeof this === 'undefined') { return new OutputByteVectorPort(); } - read_only(this, '__type__', binary_port); read_only(this, '_buffer', [], { hidden: true }); - this.write = function (x) { typecheck('write', x, ['number', 'uint8array']); - if (LNumber.isNumber(x)) { this._buffer.push(x.valueOf()); } else { var _this$_buffer; - (_this$_buffer = this._buffer).push.apply(_this$_buffer, _toConsumableArray(Array.from(x))); } }; - Object.defineProperty(this, '__buffer__', { enumerable: true, get: function get() { @@ -14594,83 +13031,66 @@ } }); } - OutputByteVectorPort.prototype = Object.create(OutputPort.prototype); OutputByteVectorPort.prototype.constructor = OutputByteVectorPort; - OutputByteVectorPort.prototype.close = function () { OutputPort.prototype.close.call(this); read_only(this, '_buffer', null, { hidden: true }); }; - OutputByteVectorPort.prototype._close_guard = function () { if (this._closed) { throw new Error('output-port: binary port is closed'); } }; - OutputByteVectorPort.prototype.write_u8 = function (_byte2) { typecheck('OutputByteVectorPort::write_u8', _byte2, 'number'); this.write(_byte2); }; - OutputByteVectorPort.prototype.write_u8_vector = function (vector) { typecheck('OutputByteVectorPort::write_u8_vector', vector, 'uint8array'); this.write(vector); }; - OutputByteVectorPort.prototype.toString = function () { return '#'; }; - OutputByteVectorPort.prototype.valueOf = function () { return this.__buffer__; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- function InputFilePort(content, filename) { if (typeof this !== 'undefined' && !(this instanceof InputFilePort) || typeof this === 'undefined') { return new InputFilePort(content, filename); } - InputStringPort.call(this, content); typecheck('InputFilePort', filename, 'string'); read_only(this, '__filename__', filename); } - InputFilePort.prototype = Object.create(InputStringPort.prototype); InputFilePort.prototype.constructor = InputFilePort; - InputFilePort.prototype.toString = function () { return "#"); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- function InputBinaryFilePort(content, filename) { if (typeof this !== 'undefined' && !(this instanceof InputBinaryFilePort) || typeof this === 'undefined') { return new InputBinaryFilePort(content, filename); } - InputByteVectorPort.call(this, content); typecheck('InputBinaryFilePort', filename, 'string'); read_only(this, '__filename__', filename); } - InputBinaryFilePort.prototype = Object.create(InputByteVectorPort.prototype); InputBinaryFilePort.prototype.constructor = InputBinaryFilePort; - InputBinaryFilePort.prototype.toString = function () { return "#"); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- function OutputBinaryFilePort(filename, fd) { if (typeof this !== 'undefined' && !(this instanceof OutputBinaryFilePort) || typeof this === 'undefined') { return new OutputBinaryFilePort(filename, fd); } - typecheck('OutputBinaryFilePort', filename, 'string'); read_only(this, '__filename__', filename); read_only(this, '_fd', fd.valueOf(), { @@ -14678,27 +13098,21 @@ }); read_only(this, '__type__', binary_port); var fs, Buffer; - this.write = function (x) { var _this18 = this; - typecheck('write', x, ['number', 'uint8array']); var buffer; - if (!fs) { fs = this.internal('fs'); } - if (!Buffer) { Buffer = this.internal('Buffer'); } - if (LNumber.isNumber(x)) { buffer = Buffer.from([x.valueOf()]); } else { buffer = Buffer.from(Array.from(x)); } - return new Promise(function (resolve, reject) { fs.write(_this18._fd, buffer, function (err) { if (err) { @@ -14710,45 +13124,36 @@ }); }; } - OutputBinaryFilePort.prototype = Object.create(OutputFilePort.prototype); OutputBinaryFilePort.prototype.constructor = OutputBinaryFilePort; - OutputBinaryFilePort.prototype.write_u8 = function (_byte3) { typecheck('OutputByteVectorPort::write_u8', _byte3, 'number'); this.write(_byte3); }; - OutputBinaryFilePort.prototype.write_u8_vector = function (vector) { typecheck('OutputByteVectorPort::write_u8_vector', vector, 'uint8array'); this.write(vector); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- var binary_port = Symbol["for"]('binary'); var text_port = Symbol["for"]('text'); var eof = new EOF(); - function EOF() {} - EOF.prototype.toString = function () { return '#'; - }; // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- // Simpler way to create interpreter with interaction-environment // ------------------------------------------------------------------------- - - function Interpreter(name) { var _this19 = this; - var _ref26 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - stderr = _ref26.stderr, - stdin = _ref26.stdin, - stdout = _ref26.stdout, - _ref26$command_line = _ref26.command_line, - command_line = _ref26$command_line === void 0 ? null : _ref26$command_line, - obj = _objectWithoutProperties(_ref26, _excluded2); - + stderr = _ref26.stderr, + stdin = _ref26.stdin, + stdout = _ref26.stdout, + _ref26$command_line = _ref26.command_line, + command_line = _ref26$command_line === void 0 ? null : _ref26$command_line, + obj = _objectWithoutProperties(_ref26, _excluded2); if (typeof this !== 'undefined' && !(this instanceof Interpreter) || typeof this === 'undefined') { return new Interpreter(name, _objectSpread({ stdin: stdin, @@ -14757,90 +13162,72 @@ command_line: command_line }, obj)); } - if (typeof name === 'undefined') { name = 'anonymous'; } - this.__env__ = user_env.inherit(name, obj); - this.__env__.set('parent.frame', doc('parent.frame', function () { return _this19.__env__; }, global_env.__env__['parent.frame'].__doc__)); - var defaults_name = '**interaction-environment-defaults**'; this.set(defaults_name, get_props(obj).concat(defaults_name)); var inter = internal_env.inherit("internal-".concat(name)); - if (is_port(stdin)) { inter.set('stdin', stdin); } - if (is_port(stderr)) { inter.set('stderr', stderr); } - if (is_port(stdout)) { inter.set('stdout', stdout); } - inter.set('command-line', command_line); set_interaction_env(this.__env__, inter); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- Interpreter.prototype.exec = function (code) { var dynamic = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var env = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; typecheck('Interpreter::exec', code, ['string', 'array'], 1); - typecheck('Interpreter::exec', dynamic, 'boolean', 2); // simple solution to overwrite this variable in each interpreter + typecheck('Interpreter::exec', dynamic, 'boolean', 2); + // simple solution to overwrite this variable in each interpreter // before evaluation of user code - global_env.set('**interaction-environment**', this.__env__); - if (env === null) { env = this.__env__; } - return exec(code, env, dynamic ? env : false); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- Interpreter.prototype.get = function (value) { var result = this.__env__.get(value); - if (is_function(result)) { return result.bind(this.__env__); } - return result; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- Interpreter.prototype.set = function (name, value) { return this.__env__.set(name, value); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- Interpreter.prototype.constant = function (name, value) { return this.__env__.constant(name, value); - }; // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- // Lips Exception used in error function // ------------------------------------------------------------------------- - - function LipsError(message, args) { this.name = 'LipsError'; this.message = message; this.args = args; this.stack = new Error().stack; } - LipsError.prototype = new Error(); - LipsError.prototype.constructor = LipsError; // ------------------------------------------------------------------------- + LipsError.prototype.constructor = LipsError; + // ------------------------------------------------------------------------- // :: Environment constructor (parent and name arguments are optional) // ------------------------------------------------------------------------- - function Environment(obj, parent, name) { if (arguments.length === 1) { if (_typeof(arguments[0]) === 'object') { @@ -14852,258 +13239,207 @@ name = arguments[0]; } } - this.__docs__ = new Map(); this.__env__ = obj; this.__parent__ = parent; this.__name__ = name || 'anonymous'; - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- Environment.prototype.list = function () { return get_props(this.__env__); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- Environment.prototype.fs = function () { return this.get('**fs**'); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- Environment.prototype.unset = function (name) { if (name instanceof LSymbol) { name = name.valueOf(); } - if (name instanceof LString) { name = name.valueOf(); } - delete this.__env__[name]; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- Environment.prototype.inherit = function (name) { var obj = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - if (_typeof(name) === "object") { obj = name; } - if (!name || _typeof(name) === "object") { name = 'child of ' + (this.__name__ || 'unknown'); } - return new Environment(obj || {}, this, name); - }; // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- // :: Lookup function for variable doc strings // ------------------------------------------------------------------------- - - Environment.prototype.doc = function (name) { var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; var dump = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - if (name instanceof LSymbol) { name = name.__name__; } - if (name instanceof LString) { name = name.valueOf(); } - if (value) { if (!dump) { value = trim_lines(value); } - this.__docs__.set(name, value); - return this; } - if (this.__docs__.has(name)) { return this.__docs__.get(name); } - if (this.__parent__) { return this.__parent__.doc(name); } - }; // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- // :: Function creates frame environment for usage in functions // :: frames are used to it's easier to find environments of the functions // :: in scope chain, they are dummy environments just for lookup // ------------------------------------------------------------------------- - - Environment.prototype.newFrame = function (fn, args) { var frame = this.inherit('__frame__'); frame.set('parent.frame', doc('parent.frame', function () { var n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; n = n.valueOf(); var scope = frame.__parent__; - if (!(scope instanceof Environment)) { return _nil; } - if (n <= 0) { return scope; } - var parent_frame = scope.get('parent.frame'); return parent_frame(n - 1); }, global_env.__env__['parent.frame'].__doc__)); args.callee = fn; frame.set('arguments', args); return frame; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- Environment.prototype._lookup = function (symbol) { if (symbol instanceof LSymbol) { symbol = symbol.__name__; } - if (symbol instanceof LString) { symbol = symbol.valueOf(); } - if (this.__env__.hasOwnProperty(symbol)) { return Value(this.__env__[symbol]); } - if (this.__parent__) { return this.__parent__._lookup(symbol); } - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- Environment.prototype.toString = function () { return '#'; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- Environment.prototype.clone = function () { var _this20 = this; - // duplicate refs - var env = {}; // TODO: duplicated Symbols - + var env = {}; + // TODO: duplicated Symbols Object.keys(this.__env__).forEach(function (key) { env[key] = _this20.__env__[key]; }); return new Environment(env, this.__parent__, this.__name__); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- Environment.prototype.merge = function (env) { var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'merge'; typecheck('Environment::merge', env, 'environment'); return this.inherit(name, env.__env__); - }; // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- // Value returned in lookup if found value in env and in promise_all // ------------------------------------------------------------------------- - - function Value(value) { if (typeof this !== 'undefined' && !(this instanceof Value) || typeof this === 'undefined') { return new Value(value); } - this.value = value; - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- Value.isUndefined = function (x) { return x instanceof Value && typeof x.value === 'undefined'; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- Value.prototype.valueOf = function () { return this.value; - }; // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- // :: Different object than value used as object for (values) // ------------------------------------------------------------------------- - - function Values(values) { if (values.length) { if (values.length === 1) { return values[0]; } } - if (typeof this !== 'undefined' && !(this instanceof Values) || typeof this === 'undefined') { return new Values(values); } - this.__values__ = values; } - Values.prototype.toString = function () { return this.__values__.map(function (x) { return toString(x); }).join('\n'); }; - Values.prototype.valueOf = function () { return this.__values__; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- Environment.prototype.get = function (symbol) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; // we keep original environment as context for bind // so print will get user stdout typecheck('Environment::get', symbol, ['symbol', 'string']); var _options$throwError = options.throwError, - throwError = _options$throwError === void 0 ? true : _options$throwError; + throwError = _options$throwError === void 0 ? true : _options$throwError; var name = symbol; - if (name instanceof LSymbol || name instanceof LString) { name = name.valueOf(); } - var value = this._lookup(name); - if (value instanceof Value) { if (Value.isUndefined(value)) { return undefined; } - return patch_value(value.valueOf()); } - var parts; - if (symbol instanceof LSymbol && symbol[LSymbol.object]) { // dot notation symbols from syntax-rules that are gensyms parts = symbol[LSymbol.object]; } else if (typeof name === 'string') { parts = name.split('.').filter(Boolean); } - if (parts && parts.length > 0) { var _parts = parts, - _parts2 = _toArray(_parts), - first = _parts2[0], - rest = _parts2.slice(1); - + _parts2 = _toArray(_parts), + first = _parts2[0], + rest = _parts2.slice(1); value = this._lookup(first); - if (rest.length) { try { if (value instanceof Value) { value = value.valueOf(); } else { value = get(root, first); - if (is_function(value)) { value = unbind(value); } } - if (typeof value !== 'undefined') { // object accessor return get.apply(void 0, [value].concat(_toConsumableArray(rest))); @@ -15114,55 +13450,42 @@ } else if (value instanceof Value) { return patch_value(value.valueOf()); } - value = get(root, name); } - if (typeof value !== 'undefined') { return value; } - if (throwError) { throw new Error("Unbound variable `" + name.toString() + "'"); } - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- Environment.prototype.set = function (name, value) { var doc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; typecheck('Environment::set', name, ['string', 'symbol']); - if (LNumber.isNumber(value)) { value = LNumber(value); } - if (name instanceof LSymbol) { name = name.__name__; } - if (name instanceof LString) { name = name.valueOf(); } - this.__env__[name] = value; - if (doc) { this.doc(name, doc, true); } - return this; - }; // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- // For internal use only // ------------------------------------------------------------------------- - - Environment.prototype.constant = function (name, value) { var _this21 = this; - if (this.__env__.hasOwnProperty(name)) { throw new Error("Environment::constant: ".concat(name, " already exists")); } - if (arguments.length === 1 && is_plain_object(arguments[0])) { var obj = arguments[0]; Object.keys(obj).forEach(function (key) { @@ -15174,82 +13497,65 @@ enumerable: true }); } - return this; - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- Environment.prototype.has = function (name) { return this.__env__.hasOwnProperty(name); - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- Environment.prototype.ref = function (name) { var env = this; - while (true) { if (!env) { break; } - if (env.has(name)) { return env; } - env = env.__parent__; } - }; // ------------------------------------------------------------------------- - - + }; + // ------------------------------------------------------------------------- Environment.prototype.parents = function () { var env = this; var result = []; - while (env) { result.unshift(env); env = env.__parent__; } - return result; - }; // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- // :: Quote function used to pause evaluation from Macro // ------------------------------------------------------------------------- - - function quote(value) { if (is_promise(value)) { return value.then(quote); } - if (value instanceof Pair || value instanceof LSymbol) { value[__data__] = true; } - return value; - } // ------------------------------------------------------------------------- - - - var native_lambda = parse(tokenize("(lambda ()\n \"[native code]\"\n (throw \"Invalid Invocation\"))"))[0]; // ------------------------------------------------------------------------------- - + } + // ------------------------------------------------------------------------------- + var native_lambda = parse(tokenize("(lambda ()\n \"[native code]\"\n (throw \"Invalid Invocation\"))"))[0]; + // ------------------------------------------------------------------------------- var get = doc('get', function get(object) { var value; - for (var _len18 = arguments.length, args = new Array(_len18 > 1 ? _len18 - 1 : 0), _key18 = 1; _key18 < _len18; _key18++) { args[_key18 - 1] = arguments[_key18]; } - var len = args.length; - while (args.length) { // if arg is symbol someone probably want to get __fn__ from binded function if (is_function(object) && _typeof(args[0]) !== 'symbol') { object = unbind(object); } - var arg = args.shift(); - var name = unbox(arg); // the value was set to false to prevent resolving + var name = unbox(arg); + // the value was set to false to prevent resolving // by Real Promises #153 - if (name === 'then' && object instanceof QuotedPromise) { value = QuotedPromise.prototype.then; } else if (name === '__code__' && is_function(object) && typeof object.__code__ === 'undefined') { @@ -15257,55 +13563,45 @@ } else { value = object[name]; } - if (typeof value === 'undefined') { if (args.length) { throw new Error("Try to get ".concat(args[0], " from undefined")); } - return value; } else { var context; - if (args.length - 1 < len) { context = object; } - value = patch_value(value, context); } - object = value; } - return value; - }, "(. obj . args)\n (get obj . args)\n\n This function uses an object as a base and keeps using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS it\n will be weakly bound (can be rebound), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . doesn't work everywhere, e.g. you can't\n pass it as an argument."); // ------------------------------------------------------------------------- + }, "(. obj . args)\n (get obj . args)\n\n This function uses an object as a base and keeps using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS it\n will be weakly bound (can be rebound), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . doesn't work everywhere, e.g. you can't\n pass it as an argument."); + // ------------------------------------------------------------------------- // Function gets internal protected data // ------------------------------------------------------------------------- - function internal(env, name) { var internal_env = interaction(env, '**internal-env**'); return internal_env.get(name); - } // ------------------------------------------------------------------------- + } + // ------------------------------------------------------------------------- // Get variable from interaction environment // ------------------------------------------------------------------------- - - function interaction(env, name) { var interaction_env = env.get('**interaction-environment**'); return interaction_env.get(name); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- var internal_env = new Environment({ stdout: new BufferedOutputPort(function () { var _console; - (_console = console).log.apply(_console, arguments); }), // ------------------------------------------------------------------ stderr: new BufferedOutputPort(function () { var _console2; - (_console2 = console).error.apply(_console2, arguments); }), 'command-line': [], @@ -15317,8 +13613,8 @@ 'letter-unicode-regex': /(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/, 'numeral-unicode-regex': /(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDEC0-\uDEC9\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/, 'space-unicode-regex': /[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/ - }, undefined, 'internal'); // ------------------------------------------------------------------------- - + }, undefined, 'internal'); + // ------------------------------------------------------------------------- var nan = LNumber(NaN); var constants = { 'true': true, @@ -15333,8 +13629,8 @@ 'NaN': nan, '+nan.0': nan, '-nan.0': nan - }; // ------------------------------------------------------------------------- - + }; + // ------------------------------------------------------------------------- var global_env = new Environment({ eof: eof, undefined: undefined, @@ -15342,33 +13638,27 @@ // --------------------------------------------------------------------- 'peek-char': doc('peek-char', function () { var port = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - if (port === null) { port = internal(this, 'stdin'); } - typecheck_text_port('peek-char', port, 'input-port'); return port.peek_char(); }, "(peek-char port)\n\n This function reads and returns a character from the string\n port, or, if there is no more data in the string port, it\n returns an EOF."), // ------------------------------------------------------------------ 'read-line': doc('read-line', function () { var port = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - if (port === null) { port = internal(this, 'stdin'); } - typecheck_text_port('read-line', port, 'input-port'); return port.read_line(); }, "(read-line port)\n\n This function reads and returns the next line from the input\n port."), // ------------------------------------------------------------------ 'read-char': doc('read-char', function () { var port = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - if (port === null) { port = internal(this, 'stdin'); } - typecheck_text_port('read-char', port, 'input-port'); return port.read_char(); }, "(read-char port)\n\n This function reads and returns the next character from the\n input port."), @@ -15376,97 +13666,77 @@ read: doc('read', /*#__PURE__*/function () { var _read2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() { var arg, - _iteratorAbruptCompletion2, - _didIteratorError2, - _iteratorError2, - _iterator2, - _step2, - value, - port, - _args18 = arguments; - + _iteratorAbruptCompletion2, + _didIteratorError2, + _iteratorError2, + _iterator2, + _step2, + value, + port, + _args18 = arguments; return _regeneratorRuntime.wrap(function _callee16$(_context16) { while (1) { switch (_context16.prev = _context16.next) { case 0: arg = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : null; - if (!LString.isString(arg)) { _context16.next = 30; break; } - _iteratorAbruptCompletion2 = false; _didIteratorError2 = false; _context16.prev = 4; _iterator2 = _asyncIterator(parse(arg, this)); - case 6: _context16.next = 8; return _iterator2.next(); - case 8: if (!(_iteratorAbruptCompletion2 = !(_step2 = _context16.sent).done)) { _context16.next = 14; break; } - value = _step2.value; return _context16.abrupt("return", value); - case 11: _iteratorAbruptCompletion2 = false; _context16.next = 6; break; - case 14: _context16.next = 20; break; - case 16: _context16.prev = 16; _context16.t0 = _context16["catch"](4); _didIteratorError2 = true; _iteratorError2 = _context16.t0; - case 20: _context16.prev = 20; _context16.prev = 21; - if (!(_iteratorAbruptCompletion2 && _iterator2["return"] != null)) { _context16.next = 25; break; } - _context16.next = 25; return _iterator2["return"](); - case 25: _context16.prev = 25; - if (!_didIteratorError2) { _context16.next = 28; break; } - throw _iteratorError2; - case 28: return _context16.finish(25); - case 29: return _context16.finish(20); - case 30: if (arg === null) { port = internal(this, 'stdin'); } else { port = arg; } - typecheck_text_port('read', port, 'input-port'); return _context16.abrupt("return", port.read.call(this)); - case 33: case "end": return _context16.stop(); @@ -15474,11 +13744,9 @@ } }, _callee16, this, [[4, 16, 20, 30], [21,, 25, 29]]); })); - function read() { return _read2.apply(this, arguments); } - return read; }(), "(read [string])\n\n This function, if used with a string, will parse it and\n return the LIPS code, if there is any. If called with a\n port, it will parse the next item from the port. If called\n without an input, it will read a string from standard input\n (using the browser's prompt or a user defined input method)\n and calls itself with that string. This function can be used\n together with `eval` to evaluate code from a string."), // ------------------------------------------------------------------ @@ -15489,18 +13757,15 @@ } else { global_env.get('write').call(global_env, arg); } - global_env.get('newline').call(global_env); }, "(pprint expression)\n\n This function will pretty print its input to stdout. If it is called\n with a non-list, it will just call the print function on its\n input."), // ------------------------------------------------------------------ print: doc('print', function print() { var display = global_env.get('display'); var newline = global_env.get('newline'); - for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) { args[_key19] = arguments[_key19]; } - args.forEach(function (arg) { display.call(global_env, arg); newline.call(global_env); @@ -15511,27 +13776,22 @@ for (var _len20 = arguments.length, args = new Array(_len20 > 1 ? _len20 - 1 : 0), _key20 = 1; _key20 < _len20; _key20++) { args[_key20 - 1] = arguments[_key20]; } - typecheck('format', str, 'string'); var re = /(~[as%~])/g; var m = str.match(/(~[as])/g); - if (m && m.length > args.length) { throw new Error('Not enough arguments'); } - var i = 0; var repr = global_env.get('repr'); str = str.replace(re, function (x) { var chr = x[1]; - if (chr === '~') { return '~'; } else if (chr === '%') { return '\n'; } else { var arg = args[i++]; - if (chr === 'a') { return repr(arg); } else { @@ -15540,23 +13800,19 @@ } }); m = str.match(/~([\S])/); - if (m) { throw new Error("format: Unrecognized escape sequence ".concat(m[1])); } - return str; }, "(format string n1 n2 ...)\n\n This function accepts a string template and replaces any\n escape sequences in its inputs:\n\n * ~a value as if printed with `display`\n * ~s value as if printed with `write`\n * ~% newline character\n * ~~ literal tilde '~'\n\n If there are missing inputs or other escape characters it\n will error."), // ------------------------------------------------------------------ display: doc('display', function display(arg) { var port = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; - if (port === null) { port = internal(this, 'stdout'); } else { typecheck('display', port, 'output-port'); } - var value = global_env.get('repr')(arg); port.write.call(global_env, value); }, "(display string [port])\n\n This function outputs the string to the standard output or\n the port if given. No newline."), @@ -15564,11 +13820,9 @@ 'display-error': doc('display-error', function error() { var port = internal(this, 'stderr'); var repr = global_env.get('repr'); - for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) { args[_key21] = arguments[_key21]; } - var value = args.map(repr).join(' '); port.write.call(global_env, value); global_env.get('newline')(port); @@ -15578,57 +13832,44 @@ if (!is_function(a)) { return false; } - if (!is_function(b)) { return false; } - return unbind(a) === unbind(b); }, "(%same-functions a b)\n\n A helper function that checks if the two input functions are\n the same."), // ------------------------------------------------------------------ help: doc(new Macro('help', function (code, _ref27) { var dynamic_scope = _ref27.dynamic_scope, - error = _ref27.error; + error = _ref27.error; var symbol; - if (code.car instanceof LSymbol) { symbol = code.car; } else if (code.car instanceof Pair && code.car.car instanceof LSymbol) { symbol = code.car.car; } else { var env = this; - if (dynamic_scope) { dynamic_scope = this; } - var ret = _evaluate(code.car, { env: env, error: error, dynamic_scope: dynamic_scope }); - if (ret && ret.__doc__) { return ret.__doc__; } - return; } - var __doc__; - var value = this.get(symbol); __doc__ = value && value.__doc__; - if (__doc__) { return __doc__; } - var ref = this.ref(symbol); - if (ref) { __doc__ = ref.doc(symbol); - if (__doc__) { return __doc__; } @@ -15651,98 +13892,78 @@ // ------------------------------------------------------------------ 'set!': doc(new Macro('set!', function (code) { var _this22 = this; - var _ref28 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - dynamic_scope = _ref28.dynamic_scope, - error = _ref28.error; - + dynamic_scope = _ref28.dynamic_scope, + error = _ref28.error; if (dynamic_scope) { dynamic_scope = this; } - var env = this; var ref; - var value = _evaluate(code.cdr.car, { env: this, dynamic_scope: dynamic_scope, error: error }); - value = resolve_promises(value); - function set(object, key, value) { if (is_promise(object)) { return object.then(function (key) { return set(object, key, value); }); } - if (is_promise(key)) { return key.then(function (key) { return set(object, key, value); }); } - if (is_promise(value)) { return value.then(function (value) { return set(object, key, value); }); } - env.get('set-obj!').call(env, object, key, value); return value; } - if (code.car instanceof Pair && LSymbol.is(code.car.car, '.')) { var second = code.car.cdr.car; var third = code.car.cdr.cdr.car; - var object = _evaluate(second, { env: this, dynamic_scope: dynamic_scope, error: error }); - var key = _evaluate(third, { env: this, dynamic_scope: dynamic_scope, error: error }); - return set(object, key, value); } - if (!(code.car instanceof LSymbol)) { throw new Error('set! first argument need to be a symbol or ' + 'dot accessor that evaluate to object.'); } - var symbol = code.car.valueOf(); - ref = this.ref(code.car.__name__); // we don't return value because we only care about sync of set value + ref = this.ref(code.car.__name__); + // we don't return value because we only care about sync of set value // when value is a promise - return unpromise(value, function (value) { if (!ref) { // case (set! fn.toString (lambda () "xxx")) var parts = symbol.split('.'); - if (parts.length > 1) { var key = parts.pop(); var name = parts.join('.'); - var obj = _this22.get(name, { throwError: false }); - if (obj) { set(obj, key, value); return; } } - throw new Error('Unbound variable `' + symbol + '\''); } - ref.set(symbol, value); }); }), "(set! name value)\n\n Macro that can be used to set the value of the variable or slot (mutate it).\n set! searches the scope chain until it finds first non empty slot and sets it."), @@ -15751,10 +13972,8 @@ if (!(code.car instanceof LSymbol)) { throw new Error('unset! first argument need to be a symbol or ' + 'dot accessor that evaluate to object.'); } - var symbol = code.car; var ref = this.ref(symbol); - if (ref) { delete ref.__env__[symbol.__name__]; } @@ -15779,11 +13998,9 @@ load: doc('load', function load(file, env) { typecheck('load', file, 'string'); var g_env = this; - if (g_env.__name__ === '__frame__') { g_env = g_env.__parent__; } - if (!(env instanceof Environment)) { if (g_env === global_env) { // this is used for let-env + load @@ -15792,21 +14009,17 @@ } else { env = this.get('**interaction-environment**'); } - } // TODO: move **module-path** to internal env - - + } + // TODO: move **module-path** to internal env var PATH = '**module-path**'; var module_path = global_env.get(PATH, { throwError: false }); file = file.valueOf(); - if (!file.match(/.[^.]+$/)) { file += '.scm'; } - var IS_BIN = file.match(/\.xcb$/); - function run(code) { if (IS_BIN) { code = unserialize_bin(code); @@ -15814,17 +14027,13 @@ if (type(code) === 'buffer') { code = code.toString(); } - code = code.replace(/^#!.*/, ''); - if (code.match(/^\{/)) { code = unserialize(code); } } - return exec(code, env); } - function fetch(file) { return root.fetch(file).then(function (res) { return IS_BIN ? res.arrayBuffer() : res.text(); @@ -15832,54 +14041,43 @@ if (IS_BIN) { code = new Uint8Array(code); } - return code; }); } - if (is_node()) { return new Promise( /*#__PURE__*/function () { var _ref29 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(resolve, reject) { var path, cmd, _args19; - return _regeneratorRuntime.wrap(function _callee17$(_context17) { while (1) { switch (_context17.prev = _context17.next) { case 0: path = nodeRequire('path'); - if (!module_path) { _context17.next = 6; break; } - module_path = module_path.valueOf(); file = path.join(module_path, file); _context17.next = 12; break; - case 6: cmd = g_env.get('command-line', { throwError: false }); - if (!cmd) { _context17.next = 11; break; } - _context17.next = 10; return cmd(); - case 10: _args19 = _context17.sent; - case 11: if (_args19 && _args19 !== _nil) { process.cwd(); file = path.join(path.dirname(_args19.car.valueOf()), file); } - case 12: global_env.set(PATH, path.dirname(file)); nodeRequire('fs').readFile(file, function (err, data) { @@ -15897,7 +14095,6 @@ } } }); - case 14: case "end": return _context17.stop(); @@ -15905,18 +14102,15 @@ } }, _callee17); })); - return function (_x13, _x14) { return _ref29.apply(this, arguments); }; }()); } - if (module_path) { module_path = module_path.valueOf(); file = module_path + '/' + file.replace(/^\.?\/?/, ''); } - return fetch(file).then(function (code) { global_env.set(PATH, file.replace(/\/[^/]*$/, '')); return run(code); @@ -15928,55 +14122,44 @@ 'do': doc(new Macro('do', /*#__PURE__*/function () { var _ref30 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(code, _ref31) { var dynamic_scope, error, self, scope, vars, test, body, eval_args, node, item, _loop3; - return _regeneratorRuntime.wrap(function _callee19$(_context19) { while (1) { switch (_context19.prev = _context19.next) { case 0: dynamic_scope = _ref31.dynamic_scope, error = _ref31.error; self = this; - if (dynamic_scope) { dynamic_scope = self; } - scope = self.inherit('do'); vars = code.car; test = code.cdr.car; body = code.cdr.cdr; - if (body !== _nil) { body = new Pair(LSymbol('begin'), body); } - eval_args = { env: self, dynamic_scope: dynamic_scope, error: error }; node = vars; - case 10: if (!(node !== _nil)) { _context19.next = 21; break; } - item = node.car; _context19.t0 = scope; _context19.t1 = item.car; _context19.next = 16; return _evaluate(item.cdr.car, eval_args); - case 16: _context19.t2 = _context19.sent; - _context19.t0.set.call(_context19.t0, _context19.t1, _context19.t2); - node = node.cdr; _context19.next = 10; break; - case 21: eval_args = { env: scope, @@ -15985,7 +14168,6 @@ }; _loop3 = /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() { var node, next, _item, value, symbols; - return _regeneratorRuntime.wrap(function _callee18$(_context18) { while (1) { switch (_context18.prev = _context18.next) { @@ -15994,45 +14176,35 @@ _context18.next = 3; break; } - _context18.next = 3; return lips.evaluate(body, eval_args); - case 3: node = vars; next = {}; - case 5: if (!(node !== _nil)) { _context18.next = 15; break; } - _item = node.car; - if (!(_item.cdr.cdr !== _nil)) { _context18.next = 12; break; } - _context18.next = 10; return _evaluate(_item.cdr.cdr.car, eval_args); - case 10: value = _context18.sent; next[_item.car.valueOf()] = value; - case 12: node = node.cdr; _context18.next = 5; break; - case 15: symbols = Object.getOwnPropertySymbols(next); Object.keys(next).concat(symbols).forEach(function (key) { scope.set(key, next[key]); }); - case 17: case "end": return _context18.stop(); @@ -16040,37 +14212,28 @@ } }, _callee18); }); - case 23: _context19.next = 25; return _evaluate(test.car, eval_args); - case 25: _context19.t3 = _context19.sent; - if (!(_context19.t3 === false)) { _context19.next = 30; break; } - return _context19.delegateYield(_loop3(), "t4", 28); - case 28: _context19.next = 23; break; - case 30: if (!(test.cdr !== _nil)) { _context19.next = 34; break; } - _context19.next = 33; return _evaluate(test.cdr.car, eval_args); - case 33: return _context19.abrupt("return", _context19.sent); - case 34: case "end": return _context19.stop(); @@ -16078,7 +14241,6 @@ } }, _callee19, this); })); - return function (_x15, _x16) { return _ref30.apply(this, arguments); }; @@ -16086,14 +14248,11 @@ // ------------------------------------------------------------------ 'if': doc(new Macro('if', function (code, _ref32) { var dynamic_scope = _ref32.dynamic_scope, - error = _ref32.error; - + error = _ref32.error; if (dynamic_scope) { dynamic_scope = this; } - var env = this; - var resolve = function resolve(cond) { if (cond === false) { return _evaluate(code.cdr.cdr.car, { @@ -16109,32 +14268,27 @@ }); } }; - if (code === _nil) { throw new Error('too few expressions for `if`'); } - var cond = _evaluate(code.car, { env: env, dynamic_scope: dynamic_scope, error: error }); - return unpromise(cond, resolve); }), "(if cond true-expr false-expr)\n\n Macro that evaluates cond expression and if the value is true, it\n evaluates and returns true-expression, if not it evaluates and returns\n false-expression."), // ------------------------------------------------------------------ 'let-env': new Macro('let-env', function (code) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var dynamic_scope = options.dynamic_scope, - error = options.error; + error = options.error; typecheck('let-env', code, 'pair'); - var ret = _evaluate(code.car, { env: this, dynamic_scope: dynamic_scope, error: error }); - return unpromise(ret, function (value) { typecheck('let-env', value, 'environment'); return _evaluate(Pair(LSymbol('begin'), code.cdr), { @@ -16160,19 +14314,15 @@ 'begin': doc(new Macro('begin', function (code, options) { var args = Object.assign({}, options); var arr = global_env.get('list->array')(code); - if (args.dynamic_scope) { args.dynamic_scope = this; } - args.env = this; var result; return function loop() { if (arr.length) { var code = arr.shift(); - var ret = _evaluate(code, args); - return unpromise(ret, function (value) { result = value; return loop(); @@ -16185,26 +14335,22 @@ // ------------------------------------------------------------------ 'ignore': new Macro('ignore', function (code, _ref33) { var dynamic_scope = _ref33.dynamic_scope, - error = _ref33.error; + error = _ref33.error; var args = { env: this, error: error }; - if (dynamic_scope) { args.dynamic_scope = this; } - _evaluate(new Pair(new LSymbol('begin'), code), args); }, "(ignore . body)\n\n Macro that will evaluate the expression and swallow any promises that may\n be created. It will discard any value that may be returned by the last body\n expression. The code should have side effects and/or when it's promise\n it should resolve to undefined."), // ------------------------------------------------------------------ 'call/cc': doc(Macro.defmacro('call/cc', function (code) { var eval_args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var args = _objectSpread({ env: this }, eval_args); - return unpromise(_evaluate(code.car, args), function (result) { if (is_function(result)) { return result(new Continuation(null)); @@ -16214,7 +14360,6 @@ // ------------------------------------------------------------------ define: doc(Macro.defmacro('define', function (code, eval_args) { var env = this; - if (code.car instanceof Pair && code.car.car instanceof LSymbol) { var new_code = new Pair(new LSymbol("define"), new Pair(code.car.car, new Pair(new Pair(new LSymbol("lambda"), new Pair(code.car.cdr, code.cdr))))); return new_code; @@ -16222,60 +14367,47 @@ // prevent evaluation in macroexpand return; } - if (eval_args.dynamic_scope) { eval_args.dynamic_scope = this; } - eval_args.env = env; var value = code.cdr.car; var new_expr; - if (value instanceof Pair) { value = _evaluate(value, eval_args); new_expr = true; } else if (value instanceof LSymbol) { value = env.get(value); } - typecheck('define', code.car, 'symbol'); return unpromise(value, function (value) { if (env.__name__ === Syntax.__merge_env__) { env = env.__parent__; } - if (new_expr && (is_function(value) && is_lambda(value) || value instanceof Syntax)) { value.__name__ = code.car.valueOf(); - if (value.__name__ instanceof LString) { value.__name__ = value.__name__.valueOf(); } } - var __doc__; - if (code.cdr.cdr instanceof Pair && LString.isString(code.cdr.cdr.car)) { __doc__ = code.cdr.cdr.car.valueOf(); } - env.set(code.car, value, __doc__, true); }); }), "(define name expression)\n (define name expression \"doc string\")\n (define (function-name . args) . body)\n\n Macro for defining values. It can be used to define variables,\n or functions. If the first argument is list it will create a function\n with name being first element of the list. This form expands to\n `(define function-name (lambda args body))`"), // ------------------------------------------------------------------ 'set-obj!': doc('set-obj!', function (obj, key, value) { var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; - var obj_type = _typeof(obj); - if (is_null(obj) || obj_type !== 'object' && obj_type !== 'function') { var msg = typeErrorMessage('set-obj!', type(obj), ['object', 'function']); throw new Error(msg); } - typecheck('set-obj!', key, ['string', 'symbol', 'number']); obj = unbind(obj); key = key.valueOf(); - if (arguments.length === 2) { delete obj[key]; } else if (is_prototype(obj) && is_function(value)) { @@ -16286,7 +14418,6 @@ } else { obj[key] = value && !is_prototype(value) ? value.valueOf() : value; } - if (props) { var _value4 = obj[key]; Object.defineProperty(obj, key, _objectSpread(_objectSpread({}, options), {}, { @@ -16303,7 +14434,6 @@ for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) { args[_key22] = arguments[_key22]; } - return Values(args); }, "(values a1 a2 ...)\n\n If called with more then one element it will create a special\n Values object that can be used in the call-with-values function."), // ------------------------------------------------------------------ @@ -16311,11 +14441,9 @@ typecheck('call-with-values', producer, 'function', 1); typecheck('call-with-values', consumer, 'function', 2); var maybe = producer(); - if (maybe instanceof Values) { return consumer.apply(void 0, _toConsumableArray(maybe.valueOf())); } - return consumer(maybe); }, "(call-with-values producer consumer)\n\n Calls the producer procedure with no arguments, then calls the\n consumer procedure with the returned value as an argument -- unless\n the returned value is a special Values object created by (values), if it is\n the values are unpacked and the consumer is called with multiple arguments."), // ------------------------------------------------------------------ @@ -16323,7 +14451,6 @@ if (this.__name__ === '__frame__') { return this.__parent__; } - return this; }, "(current-environment)\n\n Function that returns the current environment (they're first-class objects!)"), // ------------------------------------------------------------------ @@ -16333,7 +14460,6 @@ // ------------------------------------------------------------------ 'eval': doc('eval', function (code, env) { var _this23 = this; - env = env || this.get('current-environment').call(this); return _evaluate(code, { env: env, @@ -16341,7 +14467,6 @@ error: function error(e) { var error = global_env.get('display-error'); error.call(_this23, e.message); - if (e.code) { var stack = e.code.map(function (line, i) { return "[".concat(i + 1, "]: ").concat(line); @@ -16354,21 +14479,17 @@ // ------------------------------------------------------------------ lambda: new Macro('lambda', function (code) { var _ref34 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - dynamic_scope = _ref34.dynamic_scope, - error = _ref34.error; - + dynamic_scope = _ref34.dynamic_scope, + error = _ref34.error; var self = this; - var __doc__; - if (code.cdr instanceof Pair && LString.isString(code.cdr.car) && code.cdr.cdr !== _nil) { __doc__ = code.cdr.car.valueOf(); } - function lambda() { - var env; // this is function calling env + var env; + // this is function calling env // self is lexical scope when function was defined - if (dynamic_scope) { if (!(this instanceof Environment)) { env = self; @@ -16378,12 +14499,10 @@ } else { env = self; } - env = env.inherit('lambda'); var name = code.car; var i = 0; var value; - if (typeof this !== 'undefined' && !(this instanceof Environment)) { if (this && !this.__instance__) { Object.defineProperty(this, '__instance__', { @@ -16395,15 +14514,12 @@ configurable: false }); } - env.set('this', this); - } // arguments and arguments.callee inside lambda function - - + } + // arguments and arguments.callee inside lambda function for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) { args[_key23] = arguments[_key23]; } - if (this instanceof Environment) { var options = { throwError: false @@ -16413,12 +14529,10 @@ } else { // this case is for lambda as callback function in JS; e.g. setTimeout var _args = args.slice(); - _args.callee = lambda; _args.env = env; env.set('arguments', _args); } - if (name instanceof LSymbol || name !== _nil) { while (true) { if (name.car !== _nil) { @@ -16432,20 +14546,16 @@ env.__env__[name.car.__name__] = value; } } - if (name.cdr === _nil) { break; } - i++; name = name.cdr; } } - if (dynamic_scope) { dynamic_scope = env; } - var rest = __doc__ ? code.cdr.cdr : code.cdr; var output = new Pair(new LSymbol('begin'), rest); return _evaluate(output, { @@ -16454,16 +14564,13 @@ error: error }); } - var length = code.car instanceof Pair ? code.car.length() : null; lambda.__code__ = new Pair(new LSymbol('lambda'), code); lambda[__lambda__] = true; - if (!(code.car instanceof Pair)) { return doc(lambda, __doc__, true); // variable arguments - } // wrap and decorate with __doc__ - - + } + // wrap and decorate with __doc__ return doc(set_fn_length(lambda, length), __doc__, true); }, "(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n The lambda macro creates a new anonymous function. If the first element of\n the body is a string and there is more elements the string is used as the\n documentation string, that can be read using (help fn)."), 'macroexpand': new Macro('macroexpand', macro_expand()), @@ -16471,27 +14578,21 @@ // ------------------------------------------------------------------ 'define-macro': doc(new Macro(macro, function (macro, _ref35) { var dynamic_scope = _ref35.dynamic_scope, - error = _ref35.error; - + error = _ref35.error; if (macro.car instanceof Pair && macro.car.car instanceof LSymbol) { var name = macro.car.car.__name__; - var __doc__; - if (LString.isString(macro.cdr.car) && macro.cdr.cdr instanceof Pair) { __doc__ = macro.cdr.car.valueOf(); } - var makro_instance = Macro.defmacro(name, function (code) { var env = new Environment({}, this, 'defmacro'); var name = macro.car.cdr; var arg = code; - while (true) { if (name === _nil) { break; } - if (name instanceof LSymbol) { env.__env__[name.__name__] = arg; break; @@ -16502,32 +14603,26 @@ if (arg.car instanceof Pair) { arg.car[__data__] = true; } - env.__env__[name.car.__name__] = arg.car; } } - if (name.cdr === _nil) { break; } - if (arg !== _nil) { arg = arg.cdr; } - name = name.cdr; } - if (dynamic_scope) { dynamic_scope = env; } - var eval_args = { env: env, dynamic_scope: dynamic_scope, error: error - }; // evaluate macro - + }; + // evaluate macro if (macro.cdr instanceof Pair) { // this eval will return lips code var rest = __doc__ ? macro.cdr.cdr : macro.cdr; @@ -16538,7 +14633,6 @@ if (_typeof(result) === 'object') { delete result[__data__]; } - return result; }); } @@ -16550,67 +14644,53 @@ // ------------------------------------------------------------------ 'syntax-rules': new Macro('syntax-rules', function (macro, options) { var dynamic_scope = options.dynamic_scope, - error = options.error; + error = options.error; var env = this; - function get_identifiers(node) { var symbols = []; - while (node !== _nil) { var x = node.car; symbols.push(x.valueOf()); node = node.cdr; } - return symbols; } - function validate_identifiers(node) { while (node !== _nil) { var x = node.car; - if (!(x instanceof LSymbol)) { throw new Error('syntax-rules: wrong identifier'); } - node = node.cdr; } } - if (macro.car instanceof LSymbol) { validate_identifiers(macro.cdr.car); } else { validate_identifiers(macro.car); } - var syntax = new Syntax(function (code, _ref36) { var macro_expand = _ref36.macro_expand; var scope = env.inherit('syntax'); - if (dynamic_scope) { dynamic_scope = scope; } - - var var_scope = this; // for macros that define variables used in macro (2 levels nestting) - + var var_scope = this; + // for macros that define variables used in macro (2 levels nestting) if (var_scope.__name__ === Syntax.__merge_env__) { // copy refs for defined gynsyms var _props2 = Object.getOwnPropertySymbols(var_scope.__env__); - _props2.forEach(function (symbol) { var_scope.__parent__.set(symbol, var_scope.__env__[symbol]); }); - var_scope = var_scope.__parent__; } - var eval_args = { env: scope, dynamic_scope: dynamic_scope, error: error }; var ellipsis, rules, symbols; - if (macro.car instanceof LSymbol) { ellipsis = macro.car; symbols = get_identifiers(macro.cdr.car); @@ -16620,7 +14700,6 @@ symbols = get_identifiers(macro.car); rules = macro.cdr; } - try { while (rules !== _nil) { var rule = rules.car.car; @@ -16630,16 +14709,14 @@ expansion: this, define: env }); - if (bindings) { /* istanbul ignore next */ if (is_debug()) { console.log(JSON.stringify(symbolize(bindings), true, 2)); console.log('PATTERN: ' + rule.toString(true)); console.log('MACRO: ' + code.toString(true)); - } // name is modified in transform_syntax - - + } + // name is modified in transform_syntax var names = []; var new_expr = transform_syntax({ bindings: bindings, @@ -16651,38 +14728,31 @@ ellipsis: ellipsis }); log('OUPUT>>> ' + new_expr.toString()); - if (new_expr) { expr = new_expr; } - var new_env = var_scope.merge(scope, Syntax.__merge_env__); - if (macro_expand) { return { expr: expr, scope: new_env }; } - var result = _evaluate(expr, _objectSpread(_objectSpread({}, eval_args), {}, { env: new_env - })); // Hack: update the result if there are generated + })); + // Hack: update the result if there are generated // gensyms that should be literal symbols // TODO: maybe not the part move when literal elisps may // be generated, maybe they will need to be mark somehow - - return clear_gensyms(result, names); } - rules = rules.cdr; } } catch (e) { e.message += " in macro: ".concat(macro.toString(true)); throw e; } - throw new Error("Invalid Syntax ".concat(code.toString(true))); }, env); syntax.__code__ = macro; @@ -16701,53 +14771,43 @@ // ------------------------------------------------------------------ quasiquote: Macro.defmacro('quasiquote', function (arg, env) { var dynamic_scope = env.dynamic_scope, - error = env.error; - var self = this; //var max_unquote = 1; - + error = env.error; + var self = this; + //var max_unquote = 1; if (dynamic_scope) { dynamic_scope = self; - } // ----------------------------------------------------------------- - - + } + // ----------------------------------------------------------------- function is_struct(value) { return value instanceof Pair || is_plain_object(value) || Array.isArray(value); - } // ----------------------------------------------------------------- - - + } + // ----------------------------------------------------------------- function resolve_pair(pair, fn) { var test = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : is_struct; - if (pair instanceof Pair) { var car = pair.car; var cdr = pair.cdr; - if (test(car)) { car = fn(car); } - if (test(cdr)) { cdr = fn(cdr); } - if (is_promise(car) || is_promise(cdr)) { return promise_all([car, cdr]).then(function (_ref37) { var _ref38 = _slicedToArray(_ref37, 2), - car = _ref38[0], - cdr = _ref38[1]; - + car = _ref38[0], + cdr = _ref38[1]; return new Pair(car, cdr); }); } else { return new Pair(car, cdr); } } - return pair; - } // ----------------------------------------------------------------- - - + } + // ----------------------------------------------------------------- function join(eval_pair, value) { - if (eval_pair instanceof Pair) { if (value !== _nil) { eval_pair.append(value); @@ -16755,28 +14815,23 @@ } else { eval_pair = new Pair(eval_pair, value); } - return eval_pair; - } // ----------------------------------------------------------------- - - + } + // ----------------------------------------------------------------- function unquoted_arr(arr) { return !!arr.filter(function (value) { return value instanceof Pair && LSymbol.is(value.car, /^(unquote|unquote-splicing)$/); }).length; - } // ----------------------------------------------------------------- - - + } + // ----------------------------------------------------------------- function quote_vector(arr, unquote_cnt, max_unq) { return arr.reduce(function (acc, x) { if (!(x instanceof Pair)) { acc.push(x); return acc; } - if (LSymbol.is(x.car, 'unquote-splicing')) { var result; - if (unquote_cnt + 1 < max_unq) { result = recur(x.cdr, unquote_cnt + 1, max_unq); } else { @@ -16786,33 +14841,26 @@ error: error }); } - if (!(result instanceof Pair)) { throw new Error("Expecting list ".concat(type(x), " found")); } - return acc.concat(result.to_array()); } - acc.push(recur(x, unquote_cnt, max_unq)); return acc; }, []); - } // ----------------------------------------------------------------- - - + } + // ----------------------------------------------------------------- function quote_object(object, unquote_cnt, max_unq) { var result = {}; unquote_cnt++; Object.keys(object).forEach(function (key) { var value = object[key]; - if (value instanceof Pair) { if (LSymbol.is(value.car, 'unquote-splicing')) { throw new Error("You can't call `unquote-splicing` " + "inside object"); } - var output; - if (unquote_cnt < max_unq) { output = recur(value.cdr.car, unquote_cnt, max_unq); } else { @@ -16822,26 +14870,21 @@ error: error }); } - result[key] = output; } else { result[key] = value; } }); - if (Object.isFrozen(object)) { Object.freeze(result); } - return result; - } // ----------------------------------------------------------------- - - + } + // ----------------------------------------------------------------- function unquote_splice(pair, unquote_cnt, max_unq) { if (unquote_cnt < max_unq) { return new Pair(new Pair(pair.car.car, recur(pair.car.cdr, unquote_cnt, max_unq)), _nil); } - var lists = []; return function next(node) { var value = _evaluate(node.car, { @@ -16849,13 +14892,10 @@ dynamic_scope: dynamic_scope, error: error }); - lists.push(value); - if (node.cdr instanceof Pair) { return next(node.cdr); } - return unpromise(lists, function (arr) { if (arr.some(function (x) { return !(x instanceof Pair); @@ -16863,23 +14903,19 @@ if (pair.cdr instanceof Pair && LSymbol.is(pair.cdr.car, '.') && pair.cdr.cdr instanceof Pair && pair.cdr.cdr.cdr === _nil) { return pair.cdr.cdr.car; } - if (!(pair.cdr === _nil || pair.cdr instanceof Pair)) { var msg = "You can't splice atom inside list"; throw new Error(msg); } - if (arr.length > 1) { var _msg = "You can't splice multiple atoms inside list"; throw new Error(_msg); } - if (!(pair.cdr instanceof Pair && arr[0] === _nil)) { return arr[0]; } - } // don't create Cycles - - + } + // don't create Cycles arr = arr.map(function (eval_pair) { if (splices.has(eval_pair)) { return eval_pair.clone(); @@ -16889,20 +14925,16 @@ } }); var value = recur(pair.cdr, 0, 1); - if (value === _nil && arr[0] === _nil) { return undefined; } - return unpromise(value, function (value) { if (arr[0] === _nil) { return value; } - if (arr.length === 1) { return join(arr[0], value); } - var result = arr.reduce(function (result, eval_pair) { return join(result, eval_pair); }); @@ -16910,18 +14942,15 @@ }); }); }(pair.car.cdr); - } // ----------------------------------------------------------------- - - + } + // ----------------------------------------------------------------- var splices = new Set(); - function recur(pair, unquote_cnt, max_unq) { if (pair instanceof Pair) { if (pair.car instanceof Pair) { if (LSymbol.is(pair.car.car, 'unquote-splicing')) { return unquote_splice(pair, unquote_cnt + 1, max_unq); } - if (LSymbol.is(pair.car.car, 'unquote')) { // + 2 - one for unquote and one for unquote splicing if (unquote_cnt + 2 === max_unq && pair.car.cdr instanceof Pair && pair.car.cdr.car instanceof Pair && LSymbol.is(pair.car.cdr.car.car, 'unquote-splicing')) { @@ -16935,7 +14964,6 @@ if (node === _nil) { return Pair.fromArray(result); } - return unpromise(_evaluate(node.car, { env: self, dynamic_scope: dynamic_scope, @@ -16954,27 +14982,21 @@ } } } - if (LSymbol.is(pair.car, 'quasiquote')) { var cdr = recur(pair.cdr, unquote_cnt, max_unq + 1); return new Pair(pair.car, cdr); } - if (LSymbol.is(pair.car, 'quote')) { return new Pair(pair.car, recur(pair.cdr, unquote_cnt, max_unq)); } - if (LSymbol.is(pair.car, 'unquote')) { unquote_cnt++; - if (unquote_cnt < max_unq) { return new Pair(new LSymbol('unquote'), recur(pair.cdr, unquote_cnt, max_unq)); } - if (unquote_cnt > max_unq) { throw new Error("You can't call `unquote` outside " + "of quasiquote"); } - if (pair.cdr instanceof Pair) { if (pair.cdr.cdr !== _nil) { if (pair.cdr.car instanceof Pair) { @@ -16982,20 +15004,18 @@ // this part was duplicated in previous section // if (LSymbol.is(pair.car.car, 'unquote')) { // so this probably can be removed - var _result3 = []; // evaluate all values in unquote - + var _result3 = []; + // evaluate all values in unquote return function recur(node) { if (node === _nil) { return Pair.fromArray(_result3); } - return unpromise(_evaluate(node.car, { env: self, dynamic_scope: dynamic_scope, error: error }), function (next) { _result3.push(next); - return recur(node.cdr); }); }(pair.cdr); @@ -17013,7 +15033,6 @@ return pair.cdr; } } - return resolve_pair(pair, function (pair) { return recur(pair, unquote_cnt, max_unq); }); @@ -17022,38 +15041,30 @@ } else if (pair instanceof Array) { return quote_vector(pair, unquote_cnt, max_unq); } - return pair; - } // ----------------------------------------------------------------- - - + } + // ----------------------------------------------------------------- function clear(node) { if (node instanceof Pair) { delete node[__data__]; - if (!node.haveCycles('car')) { clear(node.car); } - if (!node.haveCycles('cdr')) { clear(node.cdr); } } - } // ----------------------------------------------------------------- - - + } + // ----------------------------------------------------------------- if (is_plain_object(arg.car) && !unquoted_arr(Object.values(arg.car))) { return quote(arg.car); } - if (Array.isArray(arg.car) && !unquoted_arr(arg.car)) { return quote(arg.car); } - if (arg.car instanceof Pair && !arg.car.find('unquote') && !arg.car.find('unquote-splicing') && !arg.car.find('quasiquote')) { return quote(arg.car); } - var x = recur(arg.car, 0, 1); return unpromise(x, function (value) { // clear nested data for tests @@ -17069,16 +15080,13 @@ // ------------------------------------------------------------------ append: doc('append', function append() { var _global_env$get; - for (var _len24 = arguments.length, items = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) { items[_key24] = arguments[_key24]; } - items = items.map(function (item) { if (item instanceof Pair) { return item.clone(); } - return item; }); return (_global_env$get = global_env.get('append!')).call.apply(_global_env$get, [this].concat(_toConsumableArray(items))); @@ -17086,41 +15094,32 @@ // ------------------------------------------------------------------ 'append!': doc('append!', function () { var is_list = global_env.get('list?'); - for (var _len25 = arguments.length, items = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) { items[_key25] = arguments[_key25]; } - return items.reduce(function (acc, item) { typecheck('append!', acc, ['nil', 'pair']); - if ((item instanceof Pair || item === _nil) && !is_list(item)) { throw new Error('append!: Invalid argument, value is not a list'); } - if (is_null(item)) { return acc; } - if (acc === _nil) { if (item === _nil) { return _nil; } - return item; } - return acc.append(item); }, _nil); }, "(append! arg1 ...)\n\n Destructive version of append, it can modify the lists in place. It returns\n a new list where each argument is appended to the end. It may modify\n lists added as arguments."), // ------------------------------------------------------------------ reverse: doc('reverse', function reverse(arg) { typecheck('reverse', arg, ['array', 'pair', 'nil']); - if (arg === _nil) { return _nil; } - if (arg instanceof Pair) { var arr = global_env.get('list->array')(arg).reverse(); return global_env.get('array->list')(arr); @@ -17134,20 +15133,16 @@ nth: doc('nth', function nth(index, obj) { typecheck('nth', index, 'number'); typecheck('nth', obj, ['array', 'pair']); - if (obj instanceof Pair) { var node = obj; var count = 0; - while (count < index) { if (!node.cdr || node.cdr === _nil || node.haveCycles('cdr')) { return _nil; } - node = node.cdr; count++; } - return node.car; } else if (obj instanceof Array) { return obj[index]; @@ -17160,7 +15155,6 @@ for (var _len26 = arguments.length, args = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) { args[_key26] = arguments[_key26]; } - return args.reverse().reduce(function (list, item) { return new Pair(item, list); }, _nil); @@ -17177,7 +15171,6 @@ for (var _len27 = arguments.length, args = new Array(_len27), _key27 = 0; _key27 < _len27; _key27++) { args[_key27] = arguments[_key27]; } - args.forEach(function (arg, i) { return typecheck('concat', arg, 'string', i + 1); }); @@ -17227,20 +15220,17 @@ // ------------------------------------------------------------------ env: doc('env', function env(env) { env = env || this; - var names = Object.keys(env.__env__).map(LSymbol); // TODO: get symbols - + var names = Object.keys(env.__env__).map(LSymbol); + // TODO: get symbols var result; - if (names.length) { result = Pair.fromArray(names); } else { result = _nil; } - if (env.__parent__ instanceof Environment) { return global_env.get('env')(env.__parent__).append(result); } - return result; }, "(env)\n (env obj)\n\n Function that returns a list of names (functions, macros and variables)\n that are bound in the current environment or one of its parents."), // ------------------------------------------------------------------ @@ -17248,11 +15238,9 @@ for (var _len28 = arguments.length, args = new Array(_len28 > 1 ? _len28 - 1 : 0), _key28 = 1; _key28 < _len28; _key28++) { args[_key28 - 1] = arguments[_key28]; } - var instance = _construct(unbind(obj), _toConsumableArray(args.map(function (x) { return unbox(x); }))); - return instance; }, "(new obj . args)\n\n Function that creates new JavaScript instance of an object."), // ------------------------------------------------------------------ @@ -17287,7 +15275,6 @@ if (a instanceof LSymbol || a instanceof LString || a instanceof LNumber) { a = a.valueOf(); } - return a in unbox(b); }, "(in key value)\n\n Function that uses the Javascript \"in\" operator to check if key is\n a valid property in the value."), // ------------------------------------------------------------------ @@ -17307,11 +15294,9 @@ if (type(value) !== 'number') { return false; } - if (value instanceof LNumber) { return value.isFloat(); } - return LNumber.isFloat(value); }, "(real? number)\n\n Predicate that tests if value is a real number (not complex)."), // ------------------------------------------------------------------ @@ -17369,7 +15354,6 @@ for (var _len29 = arguments.length, args = new Array(_len29 > 1 ? _len29 - 1 : 0), _key29 = 1; _key29 < _len29; _key29++) { args[_key29 - 1] = arguments[_key29]; } - typecheck('apply', fn, 'function', 1); var last = args.pop(); typecheck('apply', last, ['pair', 'nil'], args.length + 2); @@ -17381,11 +15365,9 @@ if (!obj || obj === _nil) { return 0; } - if (obj instanceof Pair) { return obj.length(); } - if ("length" in obj) { return obj.length; } @@ -17397,50 +15379,40 @@ typecheck('string->number', radix, 'number', 2); arg = arg.valueOf(); radix = radix.valueOf(); - if (arg.match(rational_bare_re) || arg.match(rational_re)) { return parse_rational(arg, radix); } else if (arg.match(complex_bare_re) || arg.match(complex_re)) { return parse_complex(arg, radix); } else { var valid_bare = radix === 10 && !arg.match(/e/i) || radix === 16; - if (arg.match(int_bare_re) && valid_bare || arg.match(int_re)) { return parse_integer(arg, radix); } - if (arg.match(float_re)) { return parse_float(arg); } } - return false; }, "(string->number number [radix])\n\n Function that parses a string into a number."), // ------------------------------------------------------------------ 'try': doc(new Macro('try', function (code, _ref39) { var _this24 = this; - var dynamic_scope = _ref39.dynamic_scope, - _error = _ref39.error; + _error = _ref39.error; return new Promise(function (resolve, reject) { var catch_clause, finally_clause; - if (LSymbol.is(code.cdr.car.car, 'catch')) { catch_clause = code.cdr.car; - if (code.cdr.cdr instanceof Pair && LSymbol.is(code.cdr.cdr.car.car, 'finally')) { finally_clause = code.cdr.cdr.car; } } else if (LSymbol.is(code.cdr.car.car, 'finally')) { finally_clause = code.cdr.car; } - if (!(finally_clause || catch_clause)) { throw new Error('try: invalid syntax'); } - var _next = resolve; - if (finally_clause) { _next = function next(result, cont) { // prevent infinite loop when finally throw exception @@ -17450,23 +15422,19 @@ }); }; } - var args = { env: _this24, error: function error(e) { var env = _this24.inherit('try'); - if (catch_clause) { env.set(catch_clause.cdr.car.car, e); var args = { env: env, error: _error }; - if (dynamic_scope) { args.dynamic_scope = _this24; } - unpromise(_evaluate(new Pair(new LSymbol('begin'), catch_clause.cdr.cdr), args), function (result) { _next(result, resolve); }); @@ -17475,13 +15443,10 @@ } } }; - if (dynamic_scope) { args.dynamic_scope = _this24; } - var result = _evaluate(code.car, args); - if (is_promise(result)) { result.then(function (result) { _next(result, resolve); @@ -17502,38 +15467,31 @@ find: doc('find', function find(arg, list) { typecheck('find', arg, ['regex', 'function']); typecheck('find', list, ['pair', 'nil']); - if (is_null(list)) { return _nil; } - var fn = matcher('find', arg); return unpromise(fn(list.car), function (value) { if (value && value !== _nil) { return list.car; } - return find(arg, list.cdr); }); }, "(find fn list)\n (find regex list)\n\n Higher-order function that finds the first value for which fn return true.\n If called with a regex it will create a matcher function."), // ------------------------------------------------------------------ 'for-each': doc('for-each', function (fn) { var _global_env$get2; - typecheck('for-each', fn, 'function'); - for (var _len30 = arguments.length, lists = new Array(_len30 > 1 ? _len30 - 1 : 0), _key30 = 1; _key30 < _len30; _key30++) { lists[_key30 - 1] = arguments[_key30]; } - lists.forEach(function (arg, i) { typecheck('for-each', arg, ['pair', 'nil'], i + 1); - }); // we need to use call(this because babel transpile this code into: + }); + // we need to use call(this because babel transpile this code into: // var ret = map.apply(void 0, [fn].concat(lists)); // it don't work with weakBind - var ret = (_global_env$get2 = global_env.get('map')).call.apply(_global_env$get2, [this, fn].concat(lists)); - if (is_promise(ret)) { return ret.then(function () {}); } @@ -17541,31 +15499,26 @@ // ------------------------------------------------------------------ map: doc('map', function map(fn) { var _this25 = this; - for (var _len31 = arguments.length, lists = new Array(_len31 > 1 ? _len31 - 1 : 0), _key31 = 1; _key31 < _len31; _key31++) { lists[_key31 - 1] = arguments[_key31]; } - typecheck('map', fn, 'function'); var is_list = global_env.get('list?'); lists.forEach(function (arg, i) { - typecheck('map', arg, ['pair', 'nil'], i + 1); // detect cycles - + typecheck('map', arg, ['pair', 'nil'], i + 1); + // detect cycles if (arg instanceof Pair && !is_list.call(_this25, arg)) { throw new Error("map: argument ".concat(i + 1, " is not a list")); } }); - if (lists.length === 0) { return _nil; } - if (lists.some(function (x) { return x === _nil; })) { return _nil; } - var args = lists.map(function (l) { return l.car; }); @@ -17583,20 +15536,16 @@ // ------------------------------------------------------------------ 'list?': doc('list?', function (obj) { var node = obj; - while (true) { if (node === _nil) { return true; } - if (!(node instanceof Pair)) { return false; } - if (node.haveCycles('cdr')) { return false; } - node = node.cdr; } }, "(list? obj)\n\n Predicate that tests if value is a proper linked list structure.\n The car of each pair can be any value. It returns false on cyclic lists.\""), @@ -17604,7 +15553,6 @@ some: doc('some', function some(fn, list) { typecheck('some', fn, 'function'); typecheck('some', list, ['pair', 'nil']); - if (is_null(list)) { return false; } else { @@ -17618,18 +15566,15 @@ for (var _len32 = arguments.length, lists = new Array(_len32 > 3 ? _len32 - 3 : 0), _key32 = 3; _key32 < _len32; _key32++) { lists[_key32 - 3] = arguments[_key32]; } - typecheck('fold', fn, 'function'); lists.forEach(function (arg, i) { typecheck('fold', arg, ['pair', 'nil'], i + 1); }); - if (lists.some(function (x) { return x === _nil; })) { return init; } - var value = fold.call.apply(fold, [this, fn, init].concat(_toConsumableArray(lists.map(function (l) { return l.cdr; })))); @@ -17644,22 +15589,18 @@ for (var _len33 = arguments.length, keys = new Array(_len33), _key33 = 0; _key33 < _len33; _key33++) { keys[_key33] = arguments[_key33]; } - return function (obj) { keys = keys.map(function (x) { return x instanceof LSymbol ? x.__name__ : x; }); - if (keys.length === 0) { return _nil; } else if (keys.length === 1) { var _keys2 = keys, - _keys3 = _slicedToArray(_keys2, 1), - _key34 = _keys3[0]; - + _keys3 = _slicedToArray(_keys2, 1), + _key34 = _keys3[0]; return obj[_key34]; } - var result = {}; keys.forEach(function (key) { result[key] = obj[key]; @@ -17670,22 +15611,18 @@ // ------------------------------------------------------------------ reduce: doc('reduce', fold('reduce', function (reduce, fn, init) { var _this26 = this; - for (var _len34 = arguments.length, lists = new Array(_len34 > 3 ? _len34 - 3 : 0), _key35 = 3; _key35 < _len34; _key35++) { lists[_key35 - 3] = arguments[_key35]; } - typecheck('reduce', fn, 'function'); lists.forEach(function (arg, i) { typecheck('reduce', arg, ['pair', 'nil'], i + 1); }); - if (lists.some(function (x) { return x === _nil; })) { return init; } - return unpromise(fn.apply(void 0, _toConsumableArray(lists.map(function (l) { return l.car; })).concat([init])), function (value) { @@ -17706,14 +15643,11 @@ if (value && value !== _nil) { result.push(item); } - return loop(++i); } - if (i === array.length) { return Pair.fromArray(result); } - var item = array[i]; return unpromise(fn(item), next); }(0); @@ -17729,7 +15663,6 @@ for (var _len35 = arguments.length, args = new Array(_len35), _key36 = 0; _key36 < _len35; _key36++) { args[_key36] = arguments[_key36]; } - typecheck_args('lcm', args, 'number'); return args.reduce(function (result, item) { return result.gcd(item); @@ -17740,23 +15673,18 @@ for (var _len36 = arguments.length, args = new Array(_len36), _key37 = 0; _key37 < _len36; _key37++) { args[_key37] = arguments[_key37]; } - - typecheck_args('lcm', args, 'number'); // ref: https://rosettacode.org/wiki/Least_common_multiple#JavaScript - + typecheck_args('lcm', args, 'number'); + // ref: https://rosettacode.org/wiki/Least_common_multiple#JavaScript var n = args.length, - a = abs(args[0]); - + a = abs(args[0]); for (var i = 1; i < n; i++) { var b = abs(args[i]), - c = a; - + c = a; while (a && b) { a > b ? a %= b : b %= a; } - a = abs(c * args[i]) / (a + b); } - return LNumber(a); }, "(lcm n1 n2 ...)\n\n Function that returns the least common multiple of the arguments."), // ------------------------------------------------------------------ @@ -17781,17 +15709,13 @@ for (var _len37 = arguments.length, args = new Array(_len37), _key38 = 0; _key38 < _len37; _key38++) { args[_key38] = arguments[_key38]; } - if (args.length === 0) { throw new Error('-: procedure require at least one argument'); } - typecheck_args('-', args, 'number'); - if (args.length === 1) { return LNumber(args[0]).sub(); } - if (args.length) { return args.reduce(binary_math_op(function (a, b) { return LNumber(a).sub(b); @@ -17803,17 +15727,13 @@ for (var _len38 = arguments.length, args = new Array(_len38), _key39 = 0; _key39 < _len38; _key39++) { args[_key39] = arguments[_key39]; } - if (args.length === 0) { throw new Error('/: procedure require at least one argument'); } - typecheck_args('/', args, 'number'); - if (args.length === 1) { return LNumber(1).div(args[0]); } - return args.reduce(binary_math_op(function (a, b) { return LNumber(a).div(b); })); @@ -17825,15 +15745,12 @@ // ------------------------------------------------------------------ truncate: doc('truncate', function (n) { typecheck('truncate', n, 'number'); - if (LNumber.isFloat(n)) { if (n instanceof LNumber) { n = n.valueOf(); } - return LFloat(truncate(n)); } - return n; }, "(truncate n)\n\n Function that returns the integer part (floor) of a real number."), // ------------------------------------------------------------------ @@ -17844,11 +15761,9 @@ '**': doc('**', binary_math_op(function (a, b) { a = LNumber(a); b = LNumber(b); - if (b.cmp(0) === -1) { return LFloat(1).div(a).pow(b.sub()); } - return a.pow(b); }), "(** a b)\n\n Function that calculates number a to to the power of b."), // ------------------------------------------------------------------ @@ -17870,7 +15785,6 @@ for (var _len39 = arguments.length, args = new Array(_len39), _key40 = 0; _key40 < _len39; _key40++) { args[_key40] = arguments[_key40]; } - typecheck_args('==', args, 'number'); return seq_compare(function (a, b) { return LNumber(a).cmp(b) === 0; @@ -17881,7 +15795,6 @@ for (var _len40 = arguments.length, args = new Array(_len40), _key41 = 0; _key41 < _len40; _key41++) { args[_key41] = arguments[_key41]; } - typecheck_args('>', args, 'number'); return seq_compare(function (a, b) { return LNumber(a).cmp(b) === 1; @@ -17892,7 +15805,6 @@ for (var _len41 = arguments.length, args = new Array(_len41), _key42 = 0; _key42 < _len41; _key42++) { args[_key42] = arguments[_key42]; } - typecheck_args('<', args, 'number'); return seq_compare(function (a, b) { return LNumber(a).cmp(b) === -1; @@ -17903,7 +15815,6 @@ for (var _len42 = arguments.length, args = new Array(_len42), _key43 = 0; _key43 < _len42; _key43++) { args[_key43] = arguments[_key43]; } - typecheck_args('<=', args, 'number'); return seq_compare(function (a, b) { return [0, -1].includes(LNumber(a).cmp(b)); @@ -17914,7 +15825,6 @@ for (var _len43 = arguments.length, args = new Array(_len43), _key44 = 0; _key44 < _len43; _key44++) { args[_key44] = arguments[_key44]; } - typecheck_args('>=', args, 'number'); return seq_compare(function (a, b) { return [0, 1].includes(LNumber(a).cmp(b)); @@ -17925,30 +15835,25 @@ // ------------------------------------------------------------------ or: doc(new Macro('or', function (code, _ref40) { var dynamic_scope = _ref40.dynamic_scope, - error = _ref40.error; + error = _ref40.error; var args = global_env.get('list->array')(code); var self = this; - if (dynamic_scope) { dynamic_scope = self; } - if (!args.length) { return false; } - var result; return function loop() { function next(value) { result = value; - if (result !== false) { return result; } else { return loop(); } } - if (!args.length) { if (result !== false) { return result; @@ -17957,13 +15862,11 @@ } } else { var arg = args.shift(); - var value = _evaluate(arg, { env: self, dynamic_scope: dynamic_scope, error: error }); - return unpromise(value, next); } }(); @@ -17971,32 +15874,26 @@ // ------------------------------------------------------------------ and: doc(new Macro('and', function (code) { var _ref41 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - dynamic_scope = _ref41.dynamic_scope, - error = _ref41.error; - + dynamic_scope = _ref41.dynamic_scope, + error = _ref41.error; var args = global_env.get('list->array')(code); var self = this; - if (dynamic_scope) { dynamic_scope = self; } - if (!args.length) { return true; } - var result; return function loop() { function next(value) { result = value; - if (result === false) { return false; } else { return loop(); } } - if (!args.length) { if (result !== false) { return result; @@ -18005,13 +15902,11 @@ } } else { var arg = args.shift(); - var value = _evaluate(arg, { env: self, dynamic_scope: dynamic_scope, error: error }); - return unpromise(value, next); } }(); @@ -18036,22 +15931,20 @@ if (is_null(value)) { return true; } - return !value; }, "(not object)\n\n Function that returns the Boolean negation of its argument.") }, undefined, 'global'); - var user_env = global_env.inherit('user-env'); // ------------------------------------------------------------------------- - + var user_env = global_env.inherit('user-env'); + // ------------------------------------------------------------------------- function set_interaction_env(interaction, internal) { interaction.constant('**internal-env**', internal); interaction.doc('**internal-env**', "**internal-env**\n\n Constant used to hide stdin, stdout and stderr so they don't interfere\n with variables with the same name. Constants are an internal type\n of variable that can't be redefined, defining a variable with the same name\n will throw an error."); global_env.set('**interaction-environment**', interaction); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- set_interaction_env(user_env, internal_env); - global_env.doc('**interaction-environment**', "**interaction-environment**\n\n Internal dynamic, global variable used to find interpreter environment.\n It's used so the read and write functions can locate **internal-env**\n that contains the references to stdin, stdout and stderr."); // ------------------------------------------------------------------------- - + global_env.doc('**interaction-environment**', "**interaction-environment**\n\n Internal dynamic, global variable used to find interpreter environment.\n It's used so the read and write functions can locate **internal-env**\n that contains the references to stdin, stdout and stderr."); + // ------------------------------------------------------------------------- (function () { var map = { ceil: 'ceiling' @@ -18060,53 +15953,45 @@ var name = map[fn] ? map[fn] : fn; global_env.set(name, doc(name, function (value) { typecheck(name, value, 'number'); - if (value instanceof LNumber) { return value[fn](); } }, "(".concat(name, " number)\n\n Function that calculates the ").concat(name, " of a number."))); }); - })(); // ------------------------------------------------------------------------- + })(); + // ------------------------------------------------------------------------- // ref: https://stackoverflow.com/a/4331218/387194 - - function allPossibleCases(arr) { if (arr.length === 1) { return arr[0]; } else { - var result = []; // recur with the rest of array - + var result = []; + // recur with the rest of array var allCasesOfRest = allPossibleCases(arr.slice(1)); - for (var i = 0; i < allCasesOfRest.length; i++) { for (var j = 0; j < arr[0].length; j++) { result.push(arr[0][j] + allCasesOfRest[i]); } } - return result; } - } // ------------------------------------------------------------------------- - + } + // ------------------------------------------------------------------------- function combinations(input, start, end) { var result = []; - for (var i = start; i <= end; ++i) { var input_arr = []; - for (var j = 0; j < i; ++j) { input_arr.push(input); } - result = result.concat(allPossibleCases(input_arr)); } - return result; - } // ------------------------------------------------------------------------- - // cadr caddr cadadr etc. - + } + // ------------------------------------------------------------------------- + // cadr caddr cadadr etc. combinations(['d', 'a'], 2, 5).forEach(function (spec) { var s = spec.split(''); var chars = s.slice().reverse(); @@ -18117,7 +16002,6 @@ global_env.set(name, doc(name, function (arg) { return chars.reduce(function (list, type) { typecheck(name, list, 'pair'); - if (type === 'a') { return list.car; } else { @@ -18125,63 +16009,54 @@ } }, arg); }, "(".concat(name, " arg)\n\n Function that calculates ").concat(code))); - }); // ----------------------------------------------------------------------------- - + }); + // ----------------------------------------------------------------------------- function reversseFind(dir, fn) { var parts = dir.split(path$2.sep).filter(Boolean); - for (var i = parts.length; i--;) { var _path; - var p = (_path = path$2).join.apply(_path, ['/'].concat(_toConsumableArray(parts.slice(0, i + 1)))); - if (fn(p)) { return p; } } - } // ----------------------------------------------------------------------------- - + } + // ----------------------------------------------------------------------------- function nodeModuleFind(dir) { return reversseFind(dir, function (dir) { return fs.existsSync(path$2.join(dir, 'node_modules')); }); - } // ------------------------------------------------------------------------- - + } + // ------------------------------------------------------------------------- function is_node() { return typeof global !== 'undefined' && global.global === global; - } // ------------------------------------------------------------------------- - + } + // ------------------------------------------------------------------------- function node_specific() { return _node_specific.apply(this, arguments); } // ------------------------------------------------------------------------- - - function _node_specific() { _node_specific = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23() { var _yield$import, createRequire, moduleURL, __dirname, __filename; - return _regeneratorRuntime.wrap(function _callee23$(_context23) { while (1) { switch (_context23.prev = _context23.next) { case 0: _context23.next = 2; return Promise.resolve().then(function () { return empty$1; }); - case 2: _yield$import = _context23.sent; createRequire = _yield$import.createRequire; nodeRequire = createRequire((typeof document === 'undefined' && typeof location === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : typeof document === 'undefined' ? location.href : (document.currentScript && document.currentScript.src || new URL('lips.js', document.baseURI).href))); _context23.next = 7; return Promise.resolve().then(function () { return empty$1; }); - case 7: fs = _context23.sent; _context23.next = 10; return Promise.resolve().then(function () { return path$1; }); - case 10: path$2 = _context23.sent; global_env.set('global', global); @@ -18191,26 +16066,24 @@ __dirname = path$2.dirname(moduleURL.pathname); __filename = path$2.basename(moduleURL.pathname); global_env.set('__dirname', __dirname); - global_env.set('__filename', __filename); // --------------------------------------------------------------------- - + global_env.set('__filename', __filename); + // --------------------------------------------------------------------- global_env.set('require.resolve', doc('require.resolve', function (path) { typecheck('require.resolve', path, 'string'); var name = path.valueOf(); return nodeRequire.resolve(name); - }, "(require.resolve path)\n\n Returns the path relative to the current module.\n\n Only available when LIPS is running under Node.js.")); // --------------------------------------------------------------------- - + }, "(require.resolve path)\n\n Returns the path relative to the current module.\n\n Only available when LIPS is running under Node.js.")); + // --------------------------------------------------------------------- global_env.set('require', doc('require', function (module) { typecheck('require', module, 'string'); module = module.valueOf(); var root = process.cwd(); var value; - try { if (module.match(/^\s*\./)) { value = nodeRequire(path$2.join(root, module)); } else { var dir = nodeModuleFind(root); - if (dir) { value = nodeRequire(path$2.join(dir, 'node_modules', module)); } else { @@ -18220,10 +16093,8 @@ } catch (e) { value = nodeRequire(module); } - return patch_value(value, global); }, "(require module)\n\n Function used inside Node.js to import a module.")); - case 21: case "end": return _context23.stop(); @@ -18233,7 +16104,6 @@ })); return _node_specific.apply(this, arguments); } - if (is_node()) { node_specific(); } else if (typeof window !== 'undefined' && window === root) { @@ -18244,21 +16114,17 @@ global_env.set('self', self); global_env.set('window', undefined); global_env.set('global', undefined); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function typeErrorMessage(fn, got, expected) { var position = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; var postfix = fn ? " in expression `".concat(fn, "`") : ''; - if (position !== null) { postfix += " (argument ".concat(position, ")"); } - if (is_function(expected)) { return "Invalid type: got ".concat(got).concat(postfix); } - if (expected instanceof Array) { if (expected.length === 1) { var first = expected[0].toLowerCase(); @@ -18268,188 +16134,148 @@ expected = expected.slice(0, -1).join(', ') + ' or ' + last; } } - return "Expecting ".concat(expected, ", got ").concat(got).concat(postfix); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function typecheck_args(fn, args, expected) { args.forEach(function (arg, i) { typecheck(fn, arg, expected, i + 1); }); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function typecheck_text_port(fn, arg, type) { typecheck(fn, arg, type); - if (arg.__type__ === binary_port) { throw new Error(typeErrorMessage(fn, 'binary-port', 'textual-port')); } - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function typecheck(fn, arg, expected) { var position = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; fn = fn.valueOf(); var arg_type = type(arg).toLowerCase(); - if (is_function(expected)) { if (!expected(arg)) { throw new Error(typeErrorMessage(fn, arg_type, expected, position)); } - return; } - var match = false; - if (expected instanceof Pair) { expected = expected.to_array(); } - if (expected instanceof Array) { expected = expected.map(function (x) { return x.valueOf(); }); } - if (expected instanceof Array) { expected = expected.map(function (x) { return x.valueOf().toLowerCase(); }); - if (expected.includes(arg_type)) { match = true; } } else { expected = expected.valueOf().toLowerCase(); } - if (!match && arg_type !== expected) { throw new Error(typeErrorMessage(fn, arg_type, expected, position)); } - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function self_evaluated(obj) { var type = _typeof(obj); - return ['string', 'function'].includes(type) || _typeof(obj) === 'symbol' || obj instanceof QuotedPromise || obj instanceof LSymbol || obj instanceof LNumber || obj instanceof LString || obj instanceof RegExp; - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function is_native(obj) { return obj instanceof LNumber || obj instanceof LString || obj instanceof LCharacter; - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function has_own_symbol(obj, symbol) { if (obj === null) { return false; } - return _typeof(obj) === 'object' && symbol in Object.getOwnPropertySymbols(obj); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function is_iterator(obj, symbol) { if (has_own_symbol(obj, symbol) || has_own_symbol(obj.__proto__, symbol)) { return is_function(obj[symbol]); } - } // ------------------------------------------------------------------------- - + } + // ------------------------------------------------------------------------- function memoize(fn) { var memo = new WeakMap(); return function (arg) { var result = memo.get(arg); - if (!result) { result = fn(arg); } - return result; }; - } // ------------------------------------------------------------------------- - + } + // ------------------------------------------------------------------------- /* eslint-disable no-func-assign */ - - type = memoize(type); /* eslint-enable no-func-assign */ // ------------------------------------------------------------------------- - function type(obj) { var t = type_constants.get(obj); - if (t) { return t; } - if (_typeof(obj) === 'object') { for (var _i5 = 0, _Object$entries2 = Object.entries(type_mapping); _i5 < _Object$entries2.length; _i5++) { var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i5], 2), - _key45 = _Object$entries2$_i[0], - value = _Object$entries2$_i[1]; - + _key45 = _Object$entries2$_i[0], + value = _Object$entries2$_i[1]; if (obj instanceof value) { return _key45; } } - if (obj.__instance__) { obj.__instance__ = false; - if (obj.__instance__) { if (is_function(obj.toType)) { return obj.toType(); } - return 'instance'; } } - if (obj.constructor) { if (obj.constructor.__class__) { return obj.constructor.__class__; } - if (obj.constructor === Object) { if (is_iterator(obj, Symbol.iterator)) { return 'iterator'; } - if (is_iterator(obj, Symbol.asyncIterator)) { return 'async-iterator'; } } - if (obj.constructor.name === '') { return 'object'; } - return obj.constructor.name.toLowerCase(); } } - return _typeof(obj); - } // ------------------------------------------------------------------------- + } + // ------------------------------------------------------------------------- // :; wrap tree of Promises with single Promise or return argument as is // :: if tree have no Promises // ------------------------------------------------------------------------- - - function resolve_promises(arg) { var promises = []; traverse(arg); - if (promises.length) { return resolve(arg); } - return arg; - function traverse(node) { if (is_promise(node)) { promises.push(node); @@ -18457,7 +16283,6 @@ if (!node.haveCycles('car')) { traverse(node.car); } - if (!node.haveCycles('cdr')) { traverse(node.cdr); } @@ -18465,11 +16290,9 @@ node.forEach(traverse); } } - function promise(_x17) { return _promise.apply(this, arguments); } - function _promise() { _promise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(node) { var pair; @@ -18478,52 +16301,39 @@ switch (_context20.prev = _context20.next) { case 0: _context20.t0 = Pair; - if (!node.haveCycles('car')) { _context20.next = 5; break; } - _context20.t1 = node.car; _context20.next = 8; break; - case 5: _context20.next = 7; return resolve(node.car); - case 7: _context20.t1 = _context20.sent; - case 8: _context20.t2 = _context20.t1; - if (!node.haveCycles('cdr')) { _context20.next = 13; break; } - _context20.t3 = node.cdr; _context20.next = 16; break; - case 13: _context20.next = 15; return resolve(node.cdr); - case 15: _context20.t3 = _context20.sent; - case 16: _context20.t4 = _context20.t3; pair = new _context20.t0(_context20.t2, _context20.t4); - if (node[__data__]) { pair[__data__] = true; } - return _context20.abrupt("return", pair); - case 20: case "end": return _context20.stop(); @@ -18533,33 +16343,27 @@ })); return _promise.apply(this, arguments); } - function resolve(node) { if (node instanceof Array) { return promise_all(node.map(resolve)); } - if (node instanceof Pair && promises.length) { return promise(node); } - return node; } - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function evaluate_args(rest, _ref42) { var env = _ref42.env, - dynamic_scope = _ref42.dynamic_scope, - error = _ref42.error; + dynamic_scope = _ref42.dynamic_scope, + error = _ref42.error; var args = []; var node = rest; markCycles(node); - function next() { return args; } - return function loop() { if (node instanceof Pair) { var arg = _evaluate(node.car, { @@ -18567,24 +16371,19 @@ dynamic_scope: dynamic_scope, error: error }); - if (dynamic_scope) { arg = unpromise(arg, function (arg) { if (is_native_function(arg)) { return arg.bind(dynamic_scope); } - return arg; }); } - return unpromise(resolve_promises(arg), function (arg) { args.push(arg); - if (node.haveCycles('cdr')) { return next(); } - node = node.cdr; return loop(); }); @@ -18594,31 +16393,26 @@ throw new Error('Syntax Error: improper list found in apply'); } }(); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function evaluate_syntax(macro, code, eval_args) { var value = macro.invoke(code, eval_args); return unpromise(resolve_promises(value), function (value) { if (value instanceof Pair) { value.markCycles(); } - return quote(value); }); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function evaluate_macro(macro, code, eval_args) { function finalize(result) { if (result instanceof Pair) { result.markCycles(); return result; } - return quote(result); } - var value = macro.invoke(code, eval_args); return unpromise(resolve_promises(value), function ret(value) { if (!value || value && value[__data__] || self_evaluated(value)) { @@ -18627,66 +16421,53 @@ return unpromise(_evaluate(value, eval_args), finalize); } }); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function prepare_fn_args(fn, args) { if (is_bound(fn) && !is_object_bound(fn) && (!lips_context(fn) || is_port_method(fn))) { args = args.map(unbox); } - if (!is_raw_lambda(fn) && args.some(is_lips_function) && !is_lips_function(fn) && !is_array_method(fn)) { // we unbox values from callback functions #76 // calling map on array should not unbox the value var result = [], - i = args.length; - + i = args.length; var _loop4 = function _loop4() { var arg = args[i]; - if (is_lips_function(arg)) { wrapper = function wrapper() { for (var _len44 = arguments.length, args = new Array(_len44), _key46 = 0; _key46 < _len44; _key46++) { args[_key46] = arguments[_key46]; } - return unpromise(arg.apply(this, args), unbox); }; // make wrapper work like output of bind - - hidden_prop(wrapper, '__bound__', true); - hidden_prop(wrapper, '__fn__', arg); // copy prototype from function to wrapper + hidden_prop(wrapper, '__fn__', arg); + // copy prototype from function to wrapper // so this work when calling new from JavaScript // case of Preact that pass LIPS class as argument // to h function - wrapper.prototype = arg.prototype; result[i] = wrapper; } else { result[i] = arg; } }; - while (i--) { var wrapper; - _loop4(); } - args = result; } - return args; - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function apply(fn, args) { var _ref43 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, - env = _ref43.env, - dynamic_scope = _ref43.dynamic_scope, - _ref43$error = _ref43.error, - error = _ref43$error === void 0 ? function () {} : _ref43$error; - + env = _ref43.env, + dynamic_scope = _ref43.dynamic_scope, + _ref43$error = _ref43.error, + error = _ref43$error === void 0 ? function () {} : _ref43$error; args = evaluate_args(args, { env: env, dynamic_scope: dynamic_scope, @@ -18698,11 +16479,8 @@ // normal functions are bound to their contexts fn = unbind(fn); } - args = prepare_fn_args(fn, args); - var _args = args.slice(); - var scope = (dynamic_scope || env).newFrame(fn, _args); var result = resolve_promises(fn.apply(scope, args)); return unpromise(result, function (result) { @@ -18710,22 +16488,18 @@ result.markCycles(); return quote(result); } - return box(result); }, error); }); - } // ------------------------------------------------------------------------- + } + // ------------------------------------------------------------------------- // :: Continuations object from call/cc // ------------------------------------------------------------------------- - - var Continuation = /*#__PURE__*/function () { function Continuation(k) { _classCallCheck(this, Continuation); - this.__value__ = k; } - _createClass(Continuation, [{ key: "invoke", value: function invoke() { @@ -18739,21 +16513,16 @@ return '#'; } }]); - return Continuation; }(); // ------------------------------------------------------------------------- - - - var noop = function noop() {}; // ------------------------------------------------------------------------- - - + var noop = function noop() {}; + // ------------------------------------------------------------------------- function _evaluate(code) { var _ref44 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - env = _ref44.env, - dynamic_scope = _ref44.dynamic_scope, - _ref44$error = _ref44.error, - error = _ref44$error === void 0 ? noop : _ref44$error; - + env = _ref44.env, + dynamic_scope = _ref44.dynamic_scope, + _ref44$error = _ref44.error, + error = _ref44$error === void 0 ? noop : _ref44$error; try { if (dynamic_scope === true) { env = dynamic_scope = env || global_env; @@ -18762,49 +16531,40 @@ } else { env = env || global_env; } - var eval_args = { env: env, dynamic_scope: dynamic_scope, error: error }; var value; - if (is_null(code)) { return code; } - if (code instanceof LSymbol) { return env.get(code); } - if (!(code instanceof Pair)) { return code; } - var first = code.car; var rest = code.cdr; - if (first instanceof Pair) { value = resolve_promises(_evaluate(first, eval_args)); - if (is_promise(value)) { return value.then(function (value) { return _evaluate(new Pair(value, code.cdr), eval_args); - }); // else is later in code + }); + // else is later in code } else if (!is_callable(value)) { throw new Error(type(value) + ' ' + env.get('repr')(value) + ' is not callable while evaluating ' + code.toString()); } } - if (first instanceof LSymbol) { value = env.get(first); } else if (is_function(first)) { value = first; } - var result; - if (value instanceof Syntax) { result = evaluate_syntax(value, code, eval_args); } else if (value instanceof Macro) { @@ -18818,13 +16578,11 @@ throw new Error("".concat(type(first), " ").concat(value, " is not a function")); } else { return code; - } // escape promise feature #54 - - + } + // escape promise feature #54 var __promise__ = env.get(Symbol["for"]('__promise__'), { throwError: false }); - if (__promise__ === true && is_promise(result)) { // fix #139 evaluate the code inside the promise that is not data. // When promise is not quoted it happen automatically, when returning @@ -18833,32 +16591,28 @@ if (result instanceof Pair && !value[__data__]) { return _evaluate(result, eval_args); } - return result; }); return new QuotedPromise(result); } - return result; } catch (e) { error && error.call(env, e, code); } - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- var compile = exec_collect(function (code) { return code; - }); // ------------------------------------------------------------------------- - + }); + // ------------------------------------------------------------------------- var exec = exec_collect(function (code, value) { return value; - }); // ------------------------------------------------------------------------- - + }); + // ------------------------------------------------------------------------- function exec_collect(collect_callback) { return /*#__PURE__*/function () { var _exec_lambda = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(arg, env, dynamic_scope) { var results, input, _iteratorAbruptCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, code, value; - return _regeneratorRuntime.wrap(function _callee21$(_context21) { while (1) { switch (_context21.prev = _context21.next) { @@ -18870,24 +16624,20 @@ } else { env = env || user_env; } - results = []; input = Array.isArray(arg) ? arg : parse(arg); _iteratorAbruptCompletion3 = false; _didIteratorError3 = false; _context21.prev = 5; _iterator3 = _asyncIterator(input); - case 7: _context21.next = 9; return _iterator3.next(); - case 9: if (!(_iteratorAbruptCompletion3 = !(_step3 = _context21.sent).done)) { _context21.next = 27; break; } - code = _step3.value; value = _evaluate(code, { env: env, @@ -18895,93 +16645,72 @@ error: function error(e, code) { if (e && e.message) { if (e.message.match(/^Error:/)) { - var re = /^(Error:)\s*([^:]+:\s*)/; // clean duplicated Error: added by JS - + var re = /^(Error:)\s*([^:]+:\s*)/; + // clean duplicated Error: added by JS e.message = e.message.replace(re, '$1 $2'); } - if (code) { // LIPS stack trace if (!(e.__code__ instanceof Array)) { e.__code__ = []; } - e.__code__.push(code.toString(true)); } } - throw e; } }); - if (is_promise(value)) { _context21.next = 16; break; } - results.push(collect_callback(code, value)); _context21.next = 24; break; - case 16: _context21.t0 = results; _context21.t1 = collect_callback; _context21.t2 = code; _context21.next = 21; return value; - case 21: _context21.t3 = _context21.sent; _context21.t4 = (0, _context21.t1)(_context21.t2, _context21.t3); - _context21.t0.push.call(_context21.t0, _context21.t4); - case 24: _iteratorAbruptCompletion3 = false; _context21.next = 7; break; - case 27: _context21.next = 33; break; - case 29: _context21.prev = 29; _context21.t5 = _context21["catch"](5); _didIteratorError3 = true; _iteratorError3 = _context21.t5; - case 33: _context21.prev = 33; _context21.prev = 34; - if (!(_iteratorAbruptCompletion3 && _iterator3["return"] != null)) { _context21.next = 38; break; } - _context21.next = 38; return _iterator3["return"](); - case 38: _context21.prev = 38; - if (!_didIteratorError3) { _context21.next = 41; break; } - throw _iteratorError3; - case 41: return _context21.finish(38); - case 42: return _context21.finish(33); - case 43: return _context21.abrupt("return", results); - case 44: case "end": return _context21.stop(); @@ -18989,23 +16718,19 @@ } }, _callee21, null, [[5, 29, 33, 43], [34,, 38, 42]]); })); - function exec_lambda(_x18, _x19, _x20) { return _exec_lambda.apply(this, arguments); } - return exec_lambda; }(); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function balanced(code) { var maching_pairs = { '[': ']', '(': ')' }; var tokens; - if (typeof code === 'string') { tokens = tokenize(code); } else { @@ -19013,29 +16738,24 @@ return x && x.token ? x.token : x; }); } - var open_tokens = Object.keys(maching_pairs); var brackets = Object.values(maching_pairs).concat(open_tokens); tokens = tokens.filter(function (token) { return brackets.includes(token); }); var stack = new Stack(); - var _iterator12 = _createForOfIteratorHelper(tokens), - _step12; - + _step12; try { for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) { var token = _step12.value; - if (open_tokens.includes(token)) { stack.push(token); } else if (!stack.is_empty()) { // closing token - var last = stack.top(); // last on stack need to match - + var last = stack.top(); + // last on stack need to match var closing_token = maching_pairs[last]; - if (token === closing_token) { stack.pop(); } else { @@ -19051,17 +16771,15 @@ } finally { _iterator12.f(); } - return stack.is_empty(); - } // ------------------------------------------------------------------------- - + } + // ------------------------------------------------------------------------- function fworker(fn) { // ref: https://stackoverflow.com/a/10372280/387194 var str = '(' + fn.toString() + ')()'; var URL = window.URL || window.webkitURL; var blob; - try { blob = new Blob([str], { type: 'application/javascript' @@ -19073,46 +16791,40 @@ blob.append(str); blob = blob.getBlob(); } - return new root.Worker(URL.createObjectURL(blob)); - } // ------------------------------------------------------------------------- - + } + // ------------------------------------------------------------------------- function is_dev() { return lips.version.match(/^(\{\{VER\}\}|DEV)$/); - } // ------------------------------------------------------------------------- - + } + // ------------------------------------------------------------------------- function get_current_script() { if (is_node()) { return; } - var script; - if (document.currentScript) { script = document.currentScript; } else { var scripts = document.querySelectorAll('script'); - if (!scripts.length) { return; } - script = scripts[scripts.length - 1]; } - var url = script.getAttribute('src'); return url; - } // ------------------------------------------------------------------------- - + } - var current_script = get_current_script(); // ------------------------------------------------------------------------- + // ------------------------------------------------------------------------- + var current_script = get_current_script(); + // ------------------------------------------------------------------------- function bootstrap() { var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; var std = 'dist/std.xcb'; - if (url === '') { if (current_script) { url = current_script.replace(/[^/]*$/, 'std.xcb'); @@ -19122,26 +16834,22 @@ url = "https://cdn.jsdelivr.net/npm/@jcubic/lips@".concat(lips.version, "/").concat(std); } } - var load = global_env.get('load'); return load.call(user_env, url, global_env); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function Worker(url) { this.url = url; var worker = this.worker = fworker(function () { var interpreter; - var init; // string, numbers, booleans - + var init; + // string, numbers, booleans self.addEventListener('message', function (response) { var data = response.data; var id = data.id; - if (data.type !== 'RPC' || id === null) { return; } - function send_result(result) { self.postMessage({ id: id, @@ -19149,7 +16857,6 @@ result: result }); } - function send_error(message) { self.postMessage({ id: id, @@ -19157,13 +16864,11 @@ error: message }); } - if (data.method === 'eval') { if (!init) { send_error('Worker RPC: LIPS not initialized, call init first'); return; } - init.then(function () { // we can use ES6 inside function that's converted to blob var code = data.params[0]; @@ -19179,7 +16884,6 @@ }); } else if (data.method === 'init') { var url = data.params[0]; - if (typeof url !== 'string') { send_error('Worker RPC: url is not a string'); } else { @@ -19193,23 +16897,19 @@ } }); }); - this.rpc = function () { var id = 0; return function rpc(method, params) { var _id = ++id; - return new Promise(function (resolve, reject) { worker.addEventListener('message', function handler(response) { var data = response.data; - if (data && data.type === 'RPC' && data.id === _id) { if (data.error) { reject(data.error); } else { resolve(data.result); } - worker.removeEventListener('message', handler); } }); @@ -19222,40 +16922,35 @@ }); }; }(); - this.rpc('init', [url])["catch"](function (error) { console.error(error); }); - this.exec = function (code) { var dynamic = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; return this.rpc('eval', [code, dynamic]); }; - } // ------------------------------------------------------------------------- + } + + // ------------------------------------------------------------------------- // :: Serialization // ------------------------------------------------------------------------- - - var serialization_map = { 'pair': function pair(_ref45) { var _ref46 = _slicedToArray(_ref45, 2), - car = _ref46[0], - cdr = _ref46[1]; - + car = _ref46[0], + cdr = _ref46[1]; return Pair(car, cdr); }, 'number': function number(value) { if (LString.isString(value)) { return LNumber([value, 10]); } - return LNumber(value); }, 'regex': function regex(_ref47) { var _ref48 = _slicedToArray(_ref47, 2), - pattern = _ref48[0], - flag = _ref48[1]; - + pattern = _ref48[0], + flag = _ref48[1]; return new RegExp(pattern, flag); }, 'nil': function nil() { @@ -19270,33 +16965,27 @@ }, 'string': LString, 'character': LCharacter - }; // ------------------------------------------------------------------------- + }; + // ------------------------------------------------------------------------- // class mapping to create smaller JSON - var available_class = Object.keys(serialization_map); var class_map = {}; - for (var _i6 = 0, _Object$entries3 = Object.entries(available_class); _i6 < _Object$entries3.length; _i6++) { var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i6], 2), - i = _Object$entries3$_i[0], - cls = _Object$entries3$_i[1]; - + i = _Object$entries3$_i[0], + cls = _Object$entries3$_i[1]; class_map[cls] = +i; } - function mangle_name(name) { return class_map[name]; } - function resolve_name(i) { return available_class[i]; - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function serialize(data) { return JSON.stringify(data, function (key, value) { var v0 = this[key]; - if (v0) { if (v0 instanceof RegExp) { return { @@ -19304,9 +16993,7 @@ '#': [v0.source, v0.flags] }; } - var cls = mangle_name(v0.constructor.__class__); - if (!is_undef(cls)) { return { '@': cls, @@ -19314,31 +17001,27 @@ }; } } - return value; }); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- function unserialize(string) { return JSON.parse(string, function (_, object) { if (object && _typeof(object) === 'object') { if (!is_undef(object['@'])) { var cls = resolve_name(object['@']); - if (serialization_map[cls]) { return serialization_map[cls](object['#']); } } } - return object; }); - } // ------------------------------------------------------------------------- + } + + // ------------------------------------------------------------------------- // binary serialization using CBOR binary data format // ------------------------------------------------------------------------- - - var cbor = function () { var types = { 'pair': Pair, @@ -19349,31 +17032,25 @@ 'nil': _nil.constructor, 'regex': RegExp }; - function serializer(Class, fn) { return { deserialize: fn, Class: Class }; } - var encoder = new Encoder(); var cbor_serialization_map = {}; - for (var _i7 = 0, _Object$entries4 = Object.entries(serialization_map); _i7 < _Object$entries4.length; _i7++) { var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i7], 2), - name = _Object$entries4$_i[0], - fn = _Object$entries4$_i[1]; - + name = _Object$entries4$_i[0], + fn = _Object$entries4$_i[1]; var Class = types[name]; cbor_serialization_map[name] = serializer(Class, fn); - } // add CBOR data mapping - - + } + // add CBOR data mapping var tag = 43311; Object.keys(cbor_serialization_map).forEach(function (type) { var data = cbor_serialization_map[type]; - if (typeof data === 'function') { var _Class = data; addExtension({ @@ -19388,7 +17065,7 @@ }); } else { var deserialize = data.deserialize, - _Class2 = data.Class; + _Class2 = data.Class; addExtension({ Class: _Class2, tag: tag, @@ -19396,7 +17073,6 @@ if (instance instanceof RegExp) { return _encode2([instance.source, instance.flags]); } - _encode2(instance.serialize()); }, decode: function decode(data) { @@ -19404,18 +17080,16 @@ } }); } - tag++; }); return encoder; - }(); // ------------------------------------------------------------------------- - + }(); + // ------------------------------------------------------------------------- function merge_uint8_array() { for (var _len45 = arguments.length, args = new Array(_len45), _key47 = 0; _key47 < _len45; _key47++) { args[_key47] = arguments[_key47]; } - if (args.length > 1) { var len = args.reduce(function (acc, arr) { return acc + arr.length; @@ -19430,26 +17104,25 @@ } else if (args.length) { return args[0]; } - } // ------------------------------------------------------------------------- - + } + // ------------------------------------------------------------------------- function encode_magic() { var VERSION = 1; var encoder = new TextEncoder('utf-8'); return encoder.encode("LIPS".concat(VERSION.toString().padStart(3, ' '))); - } // ------------------------------------------------------------------------- - + } - var MAGIC_LENGTH = 7; // ------------------------------------------------------------------------- + // ------------------------------------------------------------------------- + var MAGIC_LENGTH = 7; + // ------------------------------------------------------------------------- function decode_magic(obj) { var decoder = new TextDecoder('utf-8'); var prefix = decoder.decode(obj.slice(0, MAGIC_LENGTH)); var name = prefix.substring(0, 4); - if (name === 'LIPS') { var m = prefix.match(/^(....).*([0-9]+)$/); - if (m) { return { type: m[1], @@ -19457,27 +17130,25 @@ }; } } - return { type: 'unknown' }; - } // ------------------------------------------------------------------------- - + } + // ------------------------------------------------------------------------- function serialize_bin(obj) { var magic = encode_magic(); var payload = cbor.encode(obj); return merge_uint8_array(magic, pack_1(payload, { magic: false })); - } // ------------------------------------------------------------------------- - + } + // ------------------------------------------------------------------------- function unserialize_bin(data) { var _decode_magic = decode_magic(data), - type = _decode_magic.type, - version = _decode_magic.version; - + type = _decode_magic.type, + version = _decode_magic.version; if (type === 'LIPS' && version === 1) { var arr = unpack_1(data.slice(MAGIC_LENGTH), { magic: false @@ -19486,28 +17157,25 @@ } else { throw new Error("Invalid file format ".concat(type)); } - } // ------------------------------------------------------------------------- - + } + // ------------------------------------------------------------------------- function execError(e) { console.error(e.message || e); - if (e.code) { console.error(e.code.map(function (line, i) { return "[".concat(i + 1, "]: ").concat(line); })); } - } // ------------------------------------------------------------------------- - + } + // ------------------------------------------------------------------------- function init() { var lips_mimes = ['text/x-lips', 'text/x-scheme']; var bootstrapped; - function load(script) { return new Promise(function (resolve) { var src = script.getAttribute('src'); - if (src) { return fetch(src).then(function (res) { return res.text(); @@ -19523,21 +17191,17 @@ } }); } - function loop() { return new Promise(function (resolve) { var scripts = Array.from(document.querySelectorAll('script')); return function loop() { var script = scripts.shift(); - if (!script) { resolve(); } else { var type = script.getAttribute('type'); - if (lips_mimes.includes(type)) { var bootstrap_attr = script.getAttribute('bootstrap'); - if (!bootstrapped && typeof bootstrap_attr === 'string') { return bootstrap(bootstrap_attr).then(function () { return load(script); @@ -19548,19 +17212,16 @@ } else if (type && type.match(/lips|lisp/)) { console.warn('Expecting ' + lips_mimes.join(' or ') + ' found ' + type); } - return loop(); } }(); }); } - if (!window.document) { return Promise.resolve(); } else if (currentScript) { var script = currentScript; var bootstrap_attr = script.getAttribute('bootstrap'); - if (typeof bootstrap_attr === 'string') { return bootstrap(bootstrap_attr).then(function () { bootstrapped = true; @@ -19568,42 +17229,33 @@ }); } } - return loop(); - } // this can't be in init function, because it need to be in script context - - - var currentScript = typeof window !== 'undefined' && window.document && document.currentScript; // ------------------------------------------------------------------------- - + } + // this can't be in init function, because it need to be in script context + var currentScript = typeof window !== 'undefined' && window.document && document.currentScript; + // ------------------------------------------------------------------------- if (typeof window !== 'undefined') { contentLoaded(window, init); - } // ------------------------------------------------------------------------- - - + } + // ------------------------------------------------------------------------- var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sat, 23 Dec 2023 13:40:35 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Sat, 23 Dec 2023 13:43:06 +0000' == '{{' + 'DATE}}'; can be removed // but disabling Tree-shaking is adding lot of not used code so we use this // hack instead - var date = LString('Sat, 23 Dec 2023 13:40:35 +0000').valueOf(); - + var date = LString('Sat, 23 Dec 2023 13:43:06 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); - var _format = function _format(x) { return x.toString().padStart(2, '0'); }; - var _year = _date.getFullYear(); - var _build = [_year, _format(_date.getMonth() + 1), _format(_date.getDate())].join('-'); - var banner = "\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter 1.0.0-beta.17 (".concat(_build, ") \nCopyright (c) 2018-").concat(_year, " Jakub T. Jankiewicz\n\nType (env) to see environment with functions macros and variables. You can also\nuse (help name) to display help for specific function or macro, (apropos name)\nto display list of matched names in environment and (dir object) to list\nproperties of an object.\n").replace(/^.*\n/, ''); return banner; - }(); // ------------------------------------------------------------------------- + }(); + // ------------------------------------------------------------------------- // to be used with string function when code is minified // ------------------------------------------------------------------------- - - read_only(Ahead, '__class__', 'ahead'); read_only(Pair, '__class__', 'pair'); read_only(Nil, '__class__', 'nil'); @@ -19626,12 +17278,12 @@ read_only(LCharacter, '__class__', 'character'); read_only(LSymbol, '__class__', 'symbol'); read_only(LString, '__class__', 'string'); - read_only(QuotedPromise, '__class__', 'promise'); // ------------------------------------------------------------------------- - + read_only(QuotedPromise, '__class__', 'promise'); + // ------------------------------------------------------------------------- var lips = { version: '1.0.0-beta.17', banner: banner, - date: 'Sat, 23 Dec 2023 13:40:35 +0000', + date: 'Sat, 23 Dec 2023 13:43:06 +0000', exec: exec, // unwrap async generator into Promise parse: compose(uniterate_async, parse), @@ -19684,7 +17336,7 @@ LCharacter: LCharacter, LString: LString, rationalize: rationalize - }; // so it work when used with webpack where it will be not global + }; global_env.set('lips', lips); var empty = {}; diff --git a/dist/lips.min.js b/dist/lips.min.js index 6c70bd89..a0ad61e3 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sat, 23 Dec 2023 13:40:35 +0000 + * build: Sat, 23 Dec 2023 13:43:06 +0000 */ (function(e,t){typeof exports==="object"&&typeof module!=="undefined"?module.exports=t():typeof define==="function"&&define.amd?define(t):(e=typeof globalThis!=="undefined"?globalThis:e||self,e.lips=t())})(this,function(){"use strict";function i(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function o(e,t){o=Object.setPrototypeOf||function e(t,r){t.__proto__=r;return t};return o(e,t)}function n(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true}catch(e){return false}}function p(e,t,r){if(n()){p=Reflect.construct}else{p=function e(t,r,n){var i=[null];i.push.apply(i,r);var u=Function.bind.apply(t,i);var a=new u;if(n)o(a,n.prototype);return a}}return p.apply(null,arguments)}function u(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});Object.defineProperty(e,"prototype",{writable:false});if(t)o(e,t)}function _(e){"@babel/helpers - typeof";return _="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_(e)}function a(e,t){if(t&&(_(t)==="object"||typeof t==="function")){return t}else if(t!==void 0){throw new TypeError("Derived constructors may only return object or undefined")}return i(e)}function c(e){c=Object.setPrototypeOf?Object.getPrototypeOf:function e(t){return t.__proto__||Object.getPrototypeOf(t)};return c(e)}function r(e){if(Array.isArray(e))return e}function t(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function f(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,n=new Array(t);r=0)continue;r[i]=e[i]}return r}function F(e,t){if(e==null)return{};var r=x(e,t);var n,i;if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;r[n]=e[n]}}return r}function k(e,t){var r=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(r==null)return;var n=[];var i=true;var u=false;var a,o;try{for(r=r.call(e);!(i=(a=r.next()).done);i=true){n.push(a.value);if(t&&n.length===t)break}}catch(e){u=true;o=e}finally{try{if(!i&&r["return"]!=null)r["return"]()}finally{if(u)throw o}}return n}function j(e,t){return r(e)||k(e,t)||l(e,t)||d()}function I(e){this.wrapped=e}function P(e){return new I(e)}function N(u){var a,o;function e(n,i){return new Promise(function(e,t){var r={key:n,arg:i,resolve:e,reject:t,next:null};if(o){o=o.next=r}else{a=o=r;s(n,i)}})}function s(t,e){try{var r=u[t](e);var n=r.value;var i=n instanceof I;Promise.resolve(i?n.wrapped:n).then(function(e){if(i){s(t==="return"?"return":"next",e);return}c(r.done?"return":"normal",e)},function(e){s("throw",e)})}catch(e){c("throw",e)}}function c(e,t){switch(e){case"return":a.resolve({value:t,done:true});break;case"throw":a.reject(t);break;default:a.resolve({value:t,done:false});break}a=a.next;if(a){s(a.key,a.arg)}else{o=null}}this._invoke=e;if(typeof u["return"]!=="function"){this["return"]=undefined}}N.prototype[typeof Symbol==="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this};N.prototype.next=function(e){return this._invoke("next",e)};N.prototype["throw"]=function(e){return this._invoke("throw",e)};N.prototype["return"]=function(e){return this._invoke("return",e)};function e(e){return function(){return new N(e.apply(this,arguments))}}function R(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}var T={exports:{}};var V={exports:{}};(function(e){var t=function(a){var e=Object.prototype;var f=e.hasOwnProperty;var s;var o=typeof Symbol==="function"?Symbol:{};var i=o.iterator||"@@iterator";var c=o.asyncIterator||"@@asyncIterator";var p=o.toStringTag||"@@toStringTag";function r(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true});return e[t]}try{r({},"")}catch(e){r=function(e,t,r){return e[t]=r}}function _(e,t,r,n){var i=t&&t.prototype instanceof g?t:g;var u=Object.create(i.prototype);var a=new O(n||[]);u._invoke=x(e,r,a);return u}a.wrap=_;function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}var v="suspendedStart";var y="suspendedYield";var m="executing";var l="completed";var h={};function g(){}function n(){}function t(){}var b={};r(b,i,function(){return this});var w=Object.getPrototypeOf;var D=w&&w(w(S([])));if(D&&D!==e&&f.call(D,i)){b=D}var u=t.prototype=g.prototype=Object.create(b);n.prototype=t;r(u,"constructor",t);r(t,"constructor",n);n.displayName=r(t,p,"GeneratorFunction");function E(e){["next","throw","return"].forEach(function(t){r(e,t,function(e){return this._invoke(t,e)})})}a.isGeneratorFunction=function(e){var t=typeof e==="function"&&e.constructor;return t?t===n||(t.displayName||t.name)==="GeneratorFunction":false};a.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,t)}else{e.__proto__=t;r(e,p,"GeneratorFunction")}e.prototype=Object.create(u);return e};a.awrap=function(e){return{__await:e}};function A(o,s){function c(e,t,r,n){var i=d(o[e],o,t);if(i.type==="throw"){n(i.arg)}else{var u=i.arg;var a=u.value;if(a&&typeof a==="object"&&f.call(a,"__await")){return s.resolve(a.__await).then(function(e){c("next",e,r,n)},function(e){c("throw",e,r,n)})}return s.resolve(a).then(function(e){u.value=e;r(u)},function(e){return c("throw",e,r,n)})}}var t;function e(r,n){function e(){return new s(function(e,t){c(r,n,e,t)})}return t=t?t.then(e,e):e()}this._invoke=e}E(A.prototype);r(A.prototype,c,function(){return this});a.AsyncIterator=A;a.async=function(e,t,r,n,i){if(i===void 0)i=Promise;var u=new A(_(e,t,r,n),i);return a.isGeneratorFunction(t)?u:u.next().then(function(e){return e.done?e.value:u.next()})};function x(a,o,s){var c=v;return function e(t,r){if(c===m){throw new Error("Generator is already running")}if(c===l){if(t==="throw"){throw r}return B()}s.method=t;s.arg=r;while(true){var n=s.delegate;if(n){var i=F(n,s);if(i){if(i===h)continue;return i}}if(s.method==="next"){s.sent=s._sent=s.arg}else if(s.method==="throw"){if(c===v){c=l;throw s.arg}s.dispatchException(s.arg)}else if(s.method==="return"){s.abrupt("return",s.arg)}c=m;var u=d(a,o,s);if(u.type==="normal"){c=s.done?l:y;if(u.arg===h){continue}return{value:u.arg,done:s.done}}else if(u.type==="throw"){c=l;s.method="throw";s.arg=u.arg}}}}function F(e,t){var r=e.iterator[t.method];if(r===s){t.delegate=null;if(t.method==="throw"){if(e.iterator["return"]){t.method="return";t.arg=s;F(e,t);if(t.method==="throw"){return h}}t.method="throw";t.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=d(r,e.iterator,t.arg);if(n.type==="throw"){t.method="throw";t.arg=n.arg;t.delegate=null;return h}var i=n.arg;if(!i){t.method="throw";t.arg=new TypeError("iterator result is not an object");t.delegate=null;return h}if(i.done){t[e.resultName]=i.value;t.next=e.nextLoc;if(t.method!=="return"){t.method="next";t.arg=s}}else{return i}t.delegate=null;return h}E(u);r(u,p,"Generator");r(u,i,function(){return this});r(u,"toString",function(){return"[object Generator]"});function k(e){var t={tryLoc:e[0]};if(1 in e){t.catchLoc=e[1]}if(2 in e){t.finallyLoc=e[2];t.afterLoc=e[3]}this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal";delete t.arg;e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(k,this);this.reset(true)}a.keys=function(r){var n=[];for(var e in r){n.push(e)}n.reverse();return function e(){while(n.length){var t=n.pop();if(t in r){e.value=t;e.done=false;return e}}e.done=true;return e}};function S(t){if(t){var e=t[i];if(e){return e.call(t)}if(typeof t.next==="function"){return t}if(!isNaN(t.length)){var r=-1,n=function e(){while(++r=0;--t){var i=this.tryEntries[t];var u=i.completion;if(i.tryLoc==="root"){return e("end")}if(i.tryLoc<=this.prev){var a=f.call(i,"catchLoc");var o=f.call(i,"finallyLoc");if(a&&o){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&f.call(n,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e){this.complete(r.completion,r.afterLoc);C(r);return h}}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if(n.type==="throw"){var i=n.arg;C(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){this.delegate={iterator:S(e),resultName:t,nextLoc:r};if(this.method==="next"){this.arg=s}return h}};return a}(e.exports);try{regeneratorRuntime=t}catch(e){if(typeof globalThis==="object"){globalThis.regeneratorRuntime=t}else{Function("r","regeneratorRuntime = r")(t)}}})(V);(function(e){e.exports=V.exports})(T);var z=R(T.exports);var $=typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{};var J=[];var K=[];var G=typeof Uint8Array!=="undefined"?Uint8Array:Array;var H=false;function W(){H=true;var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var t=0,r=e.length;t0){throw new Error("Invalid string. Length must be a multiple of 4")}u=e[o-2]==="="?2:e[o-1]==="="?1:0;a=new G(o*3/4-u);n=u>0?o-4:o;var s=0;for(t=0,r=0;t>16&255;a[s++]=i>>8&255;a[s++]=i&255}if(u===2){i=K[e.charCodeAt(t)]<<2|K[e.charCodeAt(t+1)]>>4;a[s++]=i&255}else if(u===1){i=K[e.charCodeAt(t)]<<10|K[e.charCodeAt(t+1)]<<4|K[e.charCodeAt(t+2)]>>2;a[s++]=i>>8&255;a[s++]=i&255}return a}function Z(e){return J[e>>18&63]+J[e>>12&63]+J[e>>6&63]+J[e&63]}function X(e,t,r){var n;var i=[];for(var u=t;us?s:o+a))}if(n===1){t=e[r-1];i+=J[t>>2];i+=J[t<<4&63];i+="=="}else if(n===2){t=(e[r-2]<<8)+e[r-1];i+=J[t>>10];i+=J[t>>4&63];i+=J[t<<2&63];i+="="}u.push(i);return u.join("")}function te(e,t,r,n,f){var i,u;var l=f*8-n-1;var h=(1<>1;var a=-7;var o=r?f-1:0;var s=r?-1:1;var c=e[t+o];o+=s;i=c&(1<<-a)-1;c>>=-a;a+=l;for(;a>0;i=i*256+e[t+o],o+=s,a-=8){}u=i&(1<<-a)-1;i>>=-a;a+=n;for(;a>0;u=u*256+e[t+o],o+=s,a-=8){}if(i===0){i=1-p}else if(i===h){return u?NaN:(c?-1:1)*Infinity}else{u=u+Math.pow(2,n);i=i-p}return(c?-1:1)*u*Math.pow(2,i-n)}function re(e,t,f,l,r,h){var n,i,u;var a=h*8-r-1;var o=(1<>1;var p=r===23?Math.pow(2,-24)-Math.pow(2,-77):0;var c=l?0:h-1;var _=l?1:-1;var d=t<0||t===0&&1/t<0?1:0;t=Math.abs(t);if(isNaN(t)||t===Infinity){i=isNaN(t)?1:0;n=o}else{n=Math.floor(Math.log(t)/Math.LN2);if(t*(u=Math.pow(2,-n))<1){n--;u*=2}if(n+s>=1){t+=p/u}else{t+=p*Math.pow(2,1-s)}if(t*u>=2){n++;u/=2}if(n+s>=o){i=0;n=o}else if(n+s>=1){i=(t*u-1)*Math.pow(2,r);n=n+s}else{i=t*Math.pow(2,s-1)*Math.pow(2,r);n=0}}for(;r>=8;e[f+c]=i&255,c+=_,i/=256,r-=8){}n=n<0;e[f+c]=n&255,c+=_,n/=256,a-=8){}e[f+c-_]|=d*128}var ne={}.toString;var ie=Array.isArray||function(e){return ne.call(e)=="[object Array]"}; /*! @@ -83,5 +83,5 @@ * The rationalize algorithm is by Per M.A. Bothner, Alan Bawden and Marc Feeley. * source: Kawa, C-Gambit * - * Build time: Sat, 23 Dec 2023 13:40:35 +0000 - */var sn=["token"],cn=["stderr","stdin","stdout","command_line"];function fn(i){var u=ln();return function e(){var t=c(i),r;if(u){var n=c(this).constructor;r=Reflect.construct(t,arguments,n)}else{r=t.apply(this,arguments)}return a(this,r)}}function ln(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true}catch(e){return false}}function hn(t,e){var r=typeof Symbol!=="undefined"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=pn(t))||e&&t&&typeof t.length==="number"){if(r)t=r;var n=0;var i=function e(){};return{s:i,n:function e(){if(n>=t.length)return{done:true};return{done:false,value:t[n++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u=true,a=false,o;return{s:function e(){r=r.call(t)},n:function e(){var t=r.next();u=t.done;return t},e:function e(t){a=true;o=t},f:function e(){try{if(!u&&r["return"]!=null)r["return"]()}finally{if(a)throw o}}}}function pn(e,t){if(!e)return;if(typeof e==="string")return _n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor)r=e.constructor.name;if(r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return _n(e,t)}function _n(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,n=new Array(t);r1&&arguments[1]!==undefined?arguments[1]:null;var n=arguments[1]===true;function t(e){if(!Cn()){return}var t=qo.get("repr")(e);if(r===null||r instanceof RegExp&&r.test(t)){console.log(qo.get("type")(e)+": "+t)}if(n){console.log(e)}}if(ra(e)){e.then(t)}else{t(e)}return e}function Cn(){return Yo&&Yo.get("DEBUG",{throwError:false})}function On(e){return e?"(?:#".concat(e,"(?:#[ie])?|#[ie]#").concat(e,")"):"(?:#[ie])?"}function Sn(e,t){return"".concat(On(e),"[+-]?").concat(t,"+/").concat(t,"+")}function Bn(e,t){return"".concat(On(e),"(?:[+-]?(?:").concat(t,"+/").concat(t,"+|nan.0|inf.0|").concat(t,"+))?(?:[+-]i|[+-]?(?:").concat(t,"+/").concat(t,"+|").concat(t,"+|nan.0|inf.0)i)(?=[()[\\]\\s]|$)")}function jn(e,t){return"".concat(On(e),"[+-]?").concat(t,"+")}var In=/^#\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimyus]*)$/;var Pn="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+)(?:[eE][-+]?[0-9]+)?)|[0-9]+\\.)";var Nn="(?:#[ie])?(?:[+-]?(?:[0-9]+/[0-9]+|nan.0|inf.0|".concat(Pn,"|[+-]?[0-9]+))?(?:").concat(Pn,"|[+-](?:[0-9]+/[0-9]+|[0-9]+|nan.0|inf.0))i");var Rn=new RegExp("^(#[ie])?".concat(Pn,"$"),"i");function Tn(e,t){var r=e==="x"?"(?!\\+|".concat(t,")"):"(?!\\.|".concat(t,")");var n="";if(e===""){n="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(n,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(t,"+/").concat(t,"+(?!").concat(t,")|[+-]?").concat(t,"+)").concat(r,")?)(").concat(n,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(t,"+/").concat(t,"+|[+-]?").concat(t,"+|[+-])i$"),"i")}var Ln=function(){var u={};[[10,"","[0-9]"],[16,"x","[0-9a-fA-F]"],[8,"o","[0-7]"],[2,"b","[01]"]].forEach(function(e){var t=j(e,3),r=t[0],n=t[1],i=t[2];u[r]=Tn(n,i)});return u}();var Un={alarm:"",backspace:"\b",delete:"",escape:"",newline:"\n",null:"\0",return:"\r",space:" ",tab:"\t",dle:"",soh:"",dc1:"",stx:"",dc2:"",etx:"",dc3:"",eot:"",dc4:"",enq:"",nak:"",ack:"",syn:"",bel:"",etb:"",bs:"\b",can:"",ht:"\t",em:"",lf:"\n",sub:"",vt:"\v",esc:"",ff:"\f",fs:"",cr:"\r",gs:"",so:"",rs:"",si:"",us:"",del:""};function Mn(e){var t=[];var r=0;var n=e.length;while(r=55296&&i<=56319&&r1&&arguments[1]!==undefined?arguments[1]:10;var r=ei(e);var n=r.number.split("/");var i=fo({num:C([n[0],r.radix||t]),denom:C([n[1],r.radix||t])});if(r.inexact){return i.valueOf()}else{return i}}function ri(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;var r=ei(e);if(r.inexact){return uo(parseInt(r.number,r.radix||t))}return C([r.number,r.radix||t])}function ni(e){var t=e.match(/#\\x([0-9a-f]+)$/i);var r;if(t){var n=parseInt(t[1],16);r=String.fromCodePoint(n)}else{t=e.match(/#\\(.+)$/);if(t){r=t[1]}}if(r){return za(r)}throw new Error("Parse: invalid character")}function ii(e){var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;function t(e){var t;if(e==="+"){t=C(1)}else if(e==="-"){t=C(-1)}else if(e.match(Hn)){t=C([e,i])}else if(e.match(Wn)){var r=e.split("/");t=fo({num:C([r[0],i]),denom:C([r[1],i])})}else if(e.match(Rn)){var n=oi(e);if(u.exact){return n.toRational()}return n}else if(e.match(/nan.0$/)){return C(NaN)}else if(e.match(/inf.0$/)){if(e[0]==="-"){return C(Number.NEGATIVE_INFINITY)}return C(Number.POSITIVE_INFINITY)}else{throw new Error("Internal Parser Error")}if(u.inexact){return uo(t.valueOf())}return t}var u=ei(e);i=u.radix||i;var r;var n=u.number.match(Zn);if(i!==10&&n){r=n}else{r=u.number.match(Ln[i])}var a,o;o=t(r[2]);if(r[1]){a=t(r[1])}else{a=C(0)}if(o.cmp(0)===0&&o.__type__==="bigint"){return a}return io({im:o,re:a})}function ui(e){return parseInt(e.toString(),10)===e}function ai(e){var t=e.match(/^(([-+]?[0-9]*)(?:\.([0-9]+))?)e([-+]?[0-9]+)/i);if(t){var r=parseInt(t[4],10);var n;var i=t[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var u=t[3]&&t[3].length;if(i0){return C(u).mul(o)}}}r=uo(r);if(t.exact){return r.toRational()}return r}function si(e){e=e.replace(/\\x([0-9a-f]+);/gi,function(e,t){return"\\u"+t.padStart(4,"0")}).replace(/\n/g,"\\n");var t=e.match(/(\\*)(\\x[0-9A-F])/i);if(t&&t[1].length%2===0){throw new Error("Invalid string literal, unclosed ".concat(t[2]))}try{return $a(JSON.parse(e))}catch(e){var r=e.message.replace(/in JSON /,"").replace(/.*Error: /,"");throw new Error("Invalid string literal: ".concat(r))}}function ci(e){if(e.match(/^\|.*\|$/)){e=e.replace(/(^\|)|(\|$)/g,"");var r={t:"\t",r:"\r",n:"\n"};e=e.replace(/\\(x[^;]+);/g,function(e,t){return String.fromCharCode(parseInt("0"+t,16))}).replace(/\\(.)/g,function(e,t){return r[t]||t})}return new L(e)}function fi(e){if(Mo.hasOwnProperty(e)){return Mo[e]}if(e.match(/^"[\s\S]*"$/)){return si(e)}else if(e[0]==="#"){var t=e.match(In);if(t){return new RegExp(t[1],t[2])}else if(e.match(Vn)){return ni(e)}var r=e.match(/#\\(.+)/);if(r&&Mn(r[1]).length===1){return ni(e)}}if(e.match(/[0-9a-f]|[+-]i/i)){if(e.match(Gn)){return ri(e)}else if(e.match(Rn)){return oi(e)}else if(e.match(Kn)){return ti(e)}else if(e.match(Jn)){return ii(e)}}if(e.match(/^#[iexobd]/)){throw new Error("Invalid numeric constant: "+e)}return ci(e)}function li(e){return!(["(",")","[","]"].includes(e)||Bi.names().includes(e))}function hi(e){return li(e)&&!(e.match(In)||e.match(/^"[\s\S]*"$/)||e.match(Gn)||e.match(Rn)||e.match(Jn)||e.match(Kn)||e.match(Vn)||["#t","#f","nil","true","false"].includes(e))}var pi=/"(?:\\[\S\s]|[^"])*"?/g;function _i(e){if(typeof e==="string"){var t=/([-\\^$[\]()+{}?*.|])/g;return e.replace(t,"\\$1")}return e}function di(){this.data=[]}di.prototype.push=function(e){this.data.push(e)};di.prototype.top=function(){return this.data[this.data.length-1]};di.prototype.pop=function(){return this.data.pop()};di.prototype.is_empty=function(){return!this.data.length};function vi(e){if(e instanceof $a){e=e.valueOf()}var t=new s(e,{whitespace:true});var r=[];while(true){var n=t.peek(true);if(n===Fo){break}r.push(n);t.skip()}return r}function yi(e){var t=e.token,r=F(e,sn);if(t.match(/^"[\s\S]*"$/)&&t.match(/\n/)){var n=new RegExp("^ {1,"+(e.col+1)+"}","mg");t=t.replace(n,"")}return vn({token:t},r)}function mi(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};this.fn=e;this.cont=t}mi.prototype.toString=function(){return"#"};function gi(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r1&&arguments[1]!==undefined?arguments[1]:false;if(e instanceof $a){e=e.toString()}if(t){return vi(e)}else{var r=vi(e).map(function(e){if(e.token==="#\\ "){return e.token}return e.token.trim()}).filter(function(e){return e&&!e.match(/^;/)&&!e.match(/^#\|[\s\S]*\|#$/)});return Di(r)}}function Di(e){var t=0;var r=null;var n=[];for(var i=0;i0&&arguments[0]!==undefined?arguments[0]:null;if(e instanceof L){if(e.is_gensym()){return e}e=e.valueOf()}if(xi(e)){return L(e)}if(e!==null){return r(e,Symbol("#:".concat(e)))}t++;return r(t,Symbol("#:g".concat(t)))}}();function ki(e){var r=this;var n={pending:true,rejected:false,fulfilled:false,reason:undefined,type:undefined};e=e.then(function(e){n.type=us(e);n.fulfilled=true;n.pending=false;return e});$i(this,"_promise",e,{hidden:true});if(Xu(e["catch"])){e=e["catch"](function(e){n.rejected=true;n.pending=false;n.reason=e})}Object.keys(n).forEach(function(t){Object.defineProperty(r,"__".concat(t,"__"),{enumerable:true,get:function e(){return n[t]}})});$i(this,"__promise__",e);this.then=false}ki.prototype.then=function(e){return new ki(this.valueOf().then(e))};ki.prototype["catch"]=function(e){return new ki(this.valueOf()["catch"](e))};ki.prototype.valueOf=function(){if(!this._promise){throw new Error("QuotedPromise: invalid promise created")}return this._promise};ki.prototype.toString=function(){if(this.__pending__){return ki.pending_str}if(this.__rejected__){return ki.rejected_str}return"#")};ki.pending_str="#";ki.rejected_str="#";function Ci(e){if(Array.isArray(e)){return Promise.all(Oi(e)).then(Si)}return e}function Oi(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof ki){t[r]=new Bo(n)}else{t[r]=n}}return t}function Si(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof Bo){t[r]=n.valueOf()}else{t[r]=n}}return t}var Bi={LITERAL:Symbol["for"]("literal"),SPLICE:Symbol["for"]("splice"),SYMBOL:Symbol["for"]("symbol"),names:function e(){return Object.keys(this.__list__)},type:function e(t){return this.get(t).type},get:function e(t){return this.__list__[t]},off:function e(t){var r=this;var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(Array.isArray(t)){t.forEach(function(e){return r.off(e,n)})}else if(n===null){delete this.__events__[t]}else{this.__events__=this.__events__.filter(function(e){return e!==n})}},on:function e(t,r){var n=this;if(Array.isArray(t)){t.forEach(function(e){return n.on(e,r)})}else if(!this.__events__[t]){this.__events__[t]=[r]}else{this.__events__[t].push(r)}},trigger:function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i",new L("quote-promise"),Bi.LITERAL]];var Ri=Ni.map(function(e){return e[0]});Object.freeze(Ri);Object.defineProperty(Bi,"__builtins__",{writable:false,value:Ri});Ni.forEach(function(e){var t=j(e,3),r=t[0],n=t[1],i=t[2];Bi.append(r,n,i)});var s=function(){function p(e){var t=this;var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},n=r.whitespace,i=n===void 0?false:n;D(this,p);$i(this,"__input__",e.replace(/\r/g,""));var u={};["_i","_whitespace","_col","_newline","_line","_state","_next","_token","_prev_char"].forEach(function(r){Object.defineProperty(t,r,{configurable:false,enumerable:false,get:function e(){return u[r]},set:function e(t){u[r]=t}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}A(p,[{key:"get",value:function e(t){return this.__internal[t]}},{key:"set",value:function e(t,r){this.__internal[t]=r}},{key:"token",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(t){var r=this._line;if(this._whitespace&&this._token==="\n"){--r}return{token:this._token,col:this._col,offset:this._i,line:r}}return this._token}},{key:"peek",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(this._i>=this.__input__.length){return Fo}if(this._token){return this.token(t)}var r=this.next_token();if(r){this._token=this.__input__.substring(this._i,this._next);return this.token(t)}return Fo}},{key:"skip",value:function e(){if(this._next!==null){this._token=null;this._i=this._next}}},{key:"read_line",value:function e(){var t=this.__input__.length;if(this._i>=t){return Fo}for(var r=this._i;r=r){return Fo}if(t+this._i>=r){return this.read_rest()}var n=this._i+t;var i=this.__input__.substring(this._i,n);var u=i.match(/\n/g);if(u){this._line+=u.length}this._i=n;return i}},{key:"peek_char",value:function e(){if(this._i>=this.__input__.length){return Fo}return za(this.__input__[this._i])}},{key:"read_char",value:function e(){var t=this.peek_char();this.skip_char();return t}},{key:"skip_char",value:function e(){if(this._i1&&arguments[1]!==undefined?arguments[1]:{},r=t.prev_char,n=t["char"],i=t.next_char;var u=j(e,4),a=u[0],o=u[1],s=u[2],f=u[3];if(e.length!==5){throw new Error("Lexer: Invalid rule of length ".concat(e.length))}if(!n.match(a)){return false}if(!Ti(o,r)){return false}if(!Ti(s,i)){return false}if(f!==this._state){return false}return true}},{key:"next_token",value:function f(){if(this._i>=this.__input__.length){return false}var e=true;e:for(var t=this._i,r=this.__input__.length;t2&&arguments[2]!==undefined?arguments[2]:null;var i=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;if(t.length===0){throw new Error("Lexer: invalid literal rule")}if(t.length===1){return[[t,n,i,null,null]]}var u=[];for(var a=0,o=t.length;a1&&arguments[1]!==undefined?arguments[1]:{},r=t.env,n=t.meta,i=n===void 0?false:n,u=t.formatter,a=u===void 0?yi:u;D(this,o);if(e instanceof $a){e=e.toString()}$i(this,"_formatter",a,{hidden:true});$i(this,"__lexer__",new s(e));$i(this,"__env__",r);$i(this,"_meta",i,{hidden:true});$i(this,"_refs",[],{hidden:true});$i(this,"_state",{parentheses:0},{hidden:true})}A(o,[{key:"resolve",value:function e(t){return this.__env__&&this.__env__.get(t,{throwError:false})}},{key:"peek",value:function(){var e=B(z.mark(function e(){var r;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:r=this.__lexer__.peek(true);if(!(r===Fo)){t.next=4;break}return t.abrupt("return",Fo);case 4:if(!this.is_comment(r.token)){t.next=7;break}this.skip();return t.abrupt("continue",0);case 7:if(!(r.token==="#;")){t.next=14;break}this.skip();if(!(this.__lexer__.peek()===Fo)){t.next=11;break}throw new Error("Lexer: syntax error eof found after comment");case 11:t.next=13;return this._read_object();case 13:return t.abrupt("continue",0);case 14:return t.abrupt("break",17);case 17:r=this._formatter(r);if(!this._meta){t.next=20;break}return t.abrupt("return",r);case 20:return t.abrupt("return",r.token);case 21:case"end":return t.stop()}}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"reset",value:function e(){this._refs.length=0}},{key:"skip",value:function e(){this.__lexer__.skip()}},{key:"read",value:function(){var e=B(z.mark(function e(){var r;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:t.next=2;return this.peek();case 2:r=t.sent;this.skip();return t.abrupt("return",r);case 5:case"end":return t.stop()}}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"match_datum_label",value:function e(t){var r=t.match(/^#([0-9]+)=$/);return r&&r[1]}},{key:"match_datum_ref",value:function e(t){var r=t.match(/^#([0-9]+)#$/);return r&&r[1]}},{key:"is_open",value:function e(t){var r=["(","["].includes(t);if(r){this._state.parentheses++}return r}},{key:"is_close",value:function e(t){var r=[")","]"].includes(t);if(r){this._state.parentheses--}return r}},{key:"read_list",value:function(){var e=B(z.mark(function e(){var r,n,i,u;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:r=U,n=r;case 1:t.next=4;return this.peek();case 4:i=t.sent;if(!(i===Fo)){t.next=7;break}return t.abrupt("break",27);case 7:if(!this.is_close(i)){t.next=10;break}this.skip();return t.abrupt("break",27);case 10:if(!(i==="."&&r!==U)){t.next=17;break}this.skip();t.next=14;return this._read_object();case 14:n.cdr=t.sent;t.next=25;break;case 17:t.t0=M;t.next=20;return this._read_object();case 20:t.t1=t.sent;t.t2=U;u=new t.t0(t.t1,t.t2);if(r===U){r=u}else{n.cdr=u}n=u;case 25:t.next=1;break;case 27:return t.abrupt("return",r);case 28:case"end":return t.stop()}}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"read_value",value:function(){var e=B(z.mark(function e(){var r;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:t.next=2;return this.read();case 2:r=t.sent;if(!(r===Fo)){t.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return t.abrupt("return",fi(r));case 6:case"end":return t.stop()}}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"is_comment",value:function e(t){return t.match(/^;/)||t.match(/^#\|/)&&t.match(/\|#$/)}},{key:"evaluate",value:function e(t){return _s(t,{env:this.__env__,error:function e(t){throw t}})}},{key:"read_object",value:function(){var e=B(z.mark(function e(){var r;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:this.reset();t.next=3;return this._read_object();case 3:r=t.sent;if(r instanceof Ui){r=r.valueOf()}if(!this._refs.length){t.next=7;break}return t.abrupt("return",this._resolve_object(r));case 7:return t.abrupt("return",r);case 8:case"end":return t.stop()}}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"balanced",value:function e(){return this._state.parentheses===0}},{key:"ballancing_error",value:function e(t){var r=this._state.parentheses;var n=new Error("Parser: expected parenthesis but eof found");var i=new RegExp("\\){".concat(r,"}$"));n.__code__=[t.toString().replace(i,"")];throw n}},{key:"_resolve_object",value:function(){var t=B(z.mark(function e(r){var n=this;var i;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!Array.isArray(r)){t.next=2;break}return t.abrupt("return",r.map(function(e){return n._resolve_object(e)}));case 2:if(!wu(r)){t.next=6;break}i={};Object.keys(r).forEach(function(e){i[e]=n._resolve_object(r[e])});return t.abrupt("return",i);case 6:if(!(r instanceof M)){t.next=8;break}return t.abrupt("return",this._resolve_pair(r));case 8:return t.abrupt("return",r);case 9:case"end":return t.stop()}}},e,this)}));function e(e){return t.apply(this,arguments)}return e}()},{key:"_resolve_pair",value:function(){var t=B(z.mark(function e(r){return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!(r instanceof M)){t.next=15;break}if(!(r.car instanceof Ui)){t.next=7;break}t.next=4;return r.car.valueOf();case 4:r.car=t.sent;t.next=8;break;case 7:this._resolve_pair(r.car);case 8:if(!(r.cdr instanceof Ui)){t.next=14;break}t.next=11;return r.cdr.valueOf();case 11:r.cdr=t.sent;t.next=15;break;case 14:this._resolve_pair(r.cdr);case 15:return t.abrupt("return",r);case 16:case"end":return t.stop()}}},e,this)}));function e(e){return t.apply(this,arguments)}return e}()},{key:"_read_object",value:function(){var e=B(z.mark(function e(){var r,n,i,u,a,o,s,c,f;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:t.next=2;return this.peek();case 2:r=t.sent;if(!(r===Fo)){t.next=5;break}return t.abrupt("return",r);case 5:if(!ji(r)){t.next=39;break}n=Bi.get(r);i=Ii(r);this.skip();t.next=11;return this._read_object();case 11:a=t.sent;if(i){t.next=26;break}o=this.__env__.get(n.symbol);if(!(typeof o==="function")){t.next=26;break}if(!Pi(r)){t.next=19;break}return t.abrupt("return",o.call(this.__env__,a));case 19:if(!(a===U)){t.next=23;break}return t.abrupt("return",o.apply(this.__env__));case 23:if(!(a instanceof M)){t.next=25;break}return t.abrupt("return",o.apply(this.__env__,a.to_array(false)));case 25:throw new Error("Parse Error: Invalid parser extension "+"invocation ".concat(n.symbol));case 26:if(Pi(r)){u=new M(n.symbol,new M(a,U))}else{u=new M(n.symbol,a)}if(!i){t.next=29;break}return t.abrupt("return",u);case 29:if(!(o instanceof Vu)){t.next=38;break}t.next=32;return this.evaluate(u);case 32:s=t.sent;if(!(s instanceof M||s instanceof L)){t.next=35;break}return t.abrupt("return",M.fromArray([L("quote"),s]));case 35:return t.abrupt("return",s);case 38:throw new Error("Parse Error: invalid parser extension: "+n.symbol);case 39:c=this.match_datum_ref(r);if(!(c!==null)){t.next=45;break}this.skip();if(!this._refs[c]){t.next=44;break}return t.abrupt("return",new Ui(c,this._refs[c]));case 44:throw new Error("Parse Error: invalid datum label #".concat(c,"#"));case 45:f=this.match_datum_label(r);if(!(f!==null)){t.next=52;break}this.skip();this._refs[f]=this._read_object();return t.abrupt("return",this._refs[f]);case 52:if(!this.is_open(r)){t.next=57;break}this.skip();return t.abrupt("return",this.read_list());case 57:return t.abrupt("return",this.read_value());case 58:case"end":return t.stop()}}},e,this)}));function t(){return e.apply(this,arguments)}return t}()}]);return o}();var Ui=function(){function r(e,t){D(this,r);this.name=e;this.data=t}A(r,[{key:"valueOf",value:function e(){return this.data}}]);return r}();function Mi(e,t){return qi.apply(this,arguments)}function qi(){qi=e(z.mark(function e(r,n){var i,u;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!n){if(qo){n=qo.get("**interaction-environment**",{throwError:false})}else{n=Yo}}i=new Li(r,{env:n});case 2:t.next=5;return P(i.read_object());case 5:u=t.sent;if(!i.balanced()){i.ballancing_error(u)}if(!(u===Fo)){t.next=9;break}return t.abrupt("break",13);case 9:t.next=11;return u;case 11:t.next=2;break;case 13:case"end":return t.stop()}}},e)}));return qi.apply(this,arguments)}function Yi(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(e){return e};var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;if(ra(e)){var n=e.then(t);if(r===null){return n}else{return n["catch"](r)}}if(e instanceof Array){return Vi(e,t,r)}if(wu(e)){return zi(e,t,r)}return t(e)}function Vi(t,r,e){if(t.find(ra)){return Yi(Ci(t),function(e){if(Object.isFrozen(t)){Object.freeze(e)}return r(e)},e)}return r(t)}function zi(t,e,r){var i=Object.keys(t);var n=[],u=[];var a=i.length;while(a--){var o=i[a];var s=t[o];n[a]=s;if(ra(s)){u.push(s)}}if(u.length){return Yi(Ci(n),function(e){var n={};e.forEach(function(e,t){var r=i[t];n[r]=e});if(Object.isFrozen(t)){Object.freeze(n)}return n},r)}return e(t)}function $i(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},i=n.hidden,u=i===void 0?false:i;Object.defineProperty(e,t,{value:r,configurable:true,enumerable:!u})}function Ji(e){return Ki.apply(this,arguments)}function Ki(){Ki=B(z.mark(function e(r){var n,i,u,a,o,s,c;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:n=[];i=false;u=false;t.prev=3;o=yn(r);case 5:t.next=7;return o.next();case 7:if(!(i=!(s=t.sent).done)){t.next=13;break}c=s.value;n.push(c);case 10:i=false;t.next=5;break;case 13:t.next=19;break;case 15:t.prev=15;t.t0=t["catch"](3);u=true;a=t.t0;case 19:t.prev=19;t.prev=20;if(!(i&&o["return"]!=null)){t.next=24;break}t.next=24;return o["return"]();case 24:t.prev=24;if(!u){t.next=27;break}throw a;case 27:return t.finish(24);case 28:return t.finish(19);case 29:return t.abrupt("return",n);case 30:case"end":return t.stop()}}},e,null,[[3,15,19,29],[20,,24,28]])}));return Ki.apply(this,arguments)}function Gi(e,t){if(t instanceof RegExp){return function(e){return String(e).match(t)}}else if(Xu(t)){return t}throw new Error("Invalid matcher")}function y(e,t,r,n){if(typeof e!=="string"){t=arguments[0];r=arguments[1];n=arguments[2];e=null}if(r){if(n){t.__doc__=r}else{t.__doc__=Hi(r)}}if(e){t.__name__=e}else if(t.name&&!Ca(t)){t.__name__=t.name}return t}function Hi(e){return e.split("\n").map(function(e){return e.trim()}).join("\n")}function Wi(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;var r=e.length;if(t<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(t))}e:while(t--&&r>=0){var n=1;while(n>0){var i=e[--r];if(!i){break e}if(i==="("||i.token==="("){n--}else if(i===")"||i.token===")"){n++}}r--}return e.slice(r+1)}function Qi(e){if(!e||!e.length){return 0}var t=e.length;if(e[t-1].token==="\n"){return 0}while(--t){if(e[t].token==="\n"){var r=(e[t+1]||{}).token;if(r){return r.length}}}return 0}function Zi(e,t){return f(e,t)===t.length;function f(r,n){function e(e,t){var r=hn(e),n;try{for(r.s();!(n=r.n()).done;){var i=n.value;var u=f(i,t);if(u!==-1){return u}}}catch(e){r.e(e)}finally{r.f()}return-1}function t(){return r[u]===Symbol["for"]("symbol")&&!hi(n[o])}function i(){var e=r[u+1];var t=n[o+1];if(e!==undefined&&t!==undefined){return f([e],[t])}}var u=0;var a={};for(var o=0;o0){continue}}else if(t()){return-1}}else if(r[u]instanceof Array){var c=f(r[u],n.slice(o));if(c===-1||c+o>n.length){return-1}o+=c-1;u++;continue}else{return-1}u++}if(r.length!==u){return-1}return n.length}}function Xi(e){this.__code__=e.replace(/\r/g,"")}Xi.defaults={offset:0,indent:2,exceptions:{specials:[/^(?:#:)?(?:define(?:-values|-syntax|-macro|-class|-record-type)?|(?:call-with-(?:input-file|output-file|port))|lambda|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax|\*)?)$/],shift:{1:["&","#"]}}};Xi.match=Zi;Xi.prototype._options=function e(t){var r=Xi.defaults;if(typeof t==="undefined"){return Object.assign({},r)}var n=t&&t.exceptions||{};var i=n.specials||[];var u=n.shift||{1:[]};return vn(vn(vn({},r),t),{},{exceptions:{specials:[].concat(q(r.exceptions.specials),q(i)),shift:vn(vn({},u),{},{1:[].concat(q(r.exceptions.shift[1]),q(u[1]))})}})};Xi.prototype.indent=function e(t){var r=wi(this.__code__,true);return this._indent(r,t)};Xi.exception_shift=function(u,e){function t(e){if(!e.length){return false}if(e.indexOf(u)!==-1){return true}else{var t=e.filter(function(e){return e instanceof RegExp});if(!t.length){return false}var r=hn(t),n;try{for(r.s();!(n=r.n()).done;){var i=n.value;if(u.match(i)){return true}}}catch(e){r.e(e)}finally{r.f()}}return false}if(t(e.exceptions.specials)){return e.indent}var r=e.exceptions.shift;for(var n=0,i=Object.entries(r);n0){t.offset=0}if(n.toString()===e.toString()&&ms(n)){return t.offset+n[0].col}else if(n.length===1){return t.offset+n[0].col+1}else{var u=-1;if(i){var a=Xi.exception_shift(i.token,t);if(a!==-1){u=a}}if(u===-1){u=Xi.exception_shift(n[1].token,t)}if(u!==-1){return t.offset+n[0].col+u}else if(n[0].line3&&n[1].line===n[3].line){if(n[1].token==="("||n[1].token==="["){return t.offset+n[1].col}return t.offset+n[3].col}else if(n[0].line===n[1].line){return t.offset+t.indent+n[0].col}else{var o=n.slice(2);for(var s=0;s")};eu.prototype.match=function(e){return e.match(this.pattern)};function tu(){for(var e=arguments.length,t=new Array(e),r=0;r")};Xi.Pattern=tu;Xi.Ahead=eu;var ru=/^[[(]$/;var nu=/^[\])]$/;var iu=/[^()[\]]/;var uu=new eu(/[^)\]]/);var au=Symbol["for"]("*");var ou=new tu([ru,au,nu],[iu],"+");var su=new tu([ru,au,nu],"+");var cu=new tu([Symbol["for"]("symbol")],"?");var fu=new tu([Symbol["for"]("symbol")],"*");var lu=[ru,fu,nu];var hu=new tu([ru,Symbol["for"]("symbol"),au,nu],"+");var pu=vu("define","lambda","define-macro","syntax-rules");var _u=/^(?!.*\b(?:[()[\]]|define(?:-macro)?|let(?:\*|rec|-env|-syntax|)?|lambda|syntax-rules)\b).*$/;var du=/^(?:#:)?(let(?:\*|rec|-env|-syntax)?)$/;function vu(){for(var e=arguments.length,t=new Array(e),r=0;r0&&!i[e]){i[e]=Wi(n,e)}});var u=hn(t),p;try{for(u.s();!(p=u.n()).done;){var a=j(p.value,3),_=a[0],o=a[1],s=a[2];o=o.valueOf();var d=o>0?i[o]:n;var v=d.filter(function(e){return e.trim()&&!ji(e)});var y=h(d);var m=Zi(_,v);var g=e.slice(r).find(function(e){return e.trim()&&!ji(e)});if(m&&(s instanceof eu&&s.match(g)||!s)){var c=r-y;if(e[c]!=="\n"){if(!e[c].trim()){e[c]="\n"}else{e.splice(c,0,"\n");r++}}r+=y;continue e}}}catch(e){u.e(e)}finally{u.f()}}this.__code__=e.join("");return this};Xi.prototype._spaces=function(e){return new Array(e+1).join(" ")};Xi.prototype.format=function c(e){var t=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var r=wi(t,true);var n=this._options(e);var i=0;var u=0;for(var a=0;a0&&arguments[0]!==undefined?arguments[0]:true;var n=new Map;function i(e){if(e instanceof M){if(n.has(e)){return n.get(e)}var t=new M;n.set(e,t);if(r){t.car=i(e.car)}else{t.car=e.car}t.cdr=i(e.cdr);t[ga]=e[ga];return t}return e}return i(this)};M.prototype.last_pair=function(){var e=this;while(true){if(e.cdr===U){return e}e=e.cdr}};M.prototype.to_array=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var t=[];if(this.car instanceof M){if(e){t.push(this.car.to_array())}else{t.push(this.car)}}else{t.push(this.car.valueOf())}if(this.cdr instanceof M){t=t.concat(this.cdr.to_array())}return t};M.fromArray=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;if(e instanceof M||r&&e instanceof Array&&e[ya]){return e}if(t===false){var n=U;for(var i=e.length;i--;){n=new M(e[i],n)}return n}if(e.length&&!(e instanceof Array)){e=q(e)}var u=U;var a=e.length;while(a--){var o=e[a];if(o instanceof Array){o=M.fromArray(o,t,r)}else if(typeof o==="string"){o=$a(o)}else if(typeof o==="number"&&!Number.isNaN(o)){o=C(o)}u=new M(o,u)}return u};M.prototype.to_object=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var t=this;var r={};while(true){if(t instanceof M&&t.car instanceof M){var n=t.car;var i=n.car;if(i instanceof L){i=i.__name__}if(i instanceof $a){i=i.valueOf()}var u=n.cdr;if(u instanceof M){u=u.to_object(e)}if(ts(u)){if(!e){u=u.valueOf()}}r[i]=u;t=t.cdr}else{break}}return r};M.fromPairs=function(e){return e.reduce(function(e,t){return new M(new M(new L(t[0]),t[1]),e)},U)};M.fromObject=function(t){var e=Object.keys(t).map(function(e){return[e,t[e]]});return M.fromPairs(e)};M.prototype.reduce=function(e){var t=this;var r=U;while(true){if(t!==U){r=e(r,t.car);t=t.cdr}else{break}}return r};M.prototype.reverse=function(){if(this.haveCycles()){throw new Error("You can't reverse list that have cycles")}var e=this;var t=U;while(e!==U){var r=e.cdr;e.cdr=t;t=e;e=r}return t};M.prototype.transform=function(n){function i(e){if(e instanceof M){if(e.replace){delete e.replace;return e}var t=n(e.car);if(t instanceof M){t=i(t)}var r=n(e.cdr);if(r instanceof M){r=i(r)}return new M(t,r)}return e}return i(this)};M.prototype.map=function(e){if(typeof this.car!=="undefined"){return new M(e(this.car),this.cdr===U?U:this.cdr.map(e))}else{return U}};var bu=new Map;function wu(e){return e&&_(e)==="object"&&e.constructor===Object}var Du=Object.getOwnPropertyNames(Array.prototype);var Eu=[];Du.forEach(function(e){Eu.push(Array[e],Array.prototype[e])});function Au(e){e=sa(e);return Eu.includes(e)}function xu(e){return Xu(e)&&(Ca(e)||e.__doc__)}function Fu(r){var e=r.constructor||Object;var n=wu(r);var i=Xu(r[Symbol.asyncIterator])||Xu(r[Symbol.iterator]);var u;if(bu.has(e)){u=bu.get(e)}else{bu.forEach(function(e,t){t=sa(t);if(r.constructor===t&&(t===Object&&n&&!i||t!==Object)){u=e}})}return u}var ku=new Map;[[true,"#t"],[false,"#f"],[null,"null"],[undefined,"#"]].forEach(function(e){var t=j(e,2),r=t[0],n=t[1];ku.set(r,n)});function Cu(r){if(r&&_(r)==="object"){var n={};var e=Object.getOwnPropertySymbols(r);e.forEach(function(e){var t=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");n[t]=Pu(r[e])});var t=Object.getOwnPropertyNames(r);t.forEach(function(e){var t=r[e];if(t&&_(t)==="object"&&t.constructor===Object){n[e]=Cu(t)}else{n[e]=Pu(t)}});return n}return r}function Ou(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function Su(e,t){return e.hasOwnProperty(t)&&Xu(e.toString)}function Bu(e){if(Ba(e)){return"#"}var t=e.prototype&&e.prototype.constructor;if(Xu(t)&&Ca(t)){if(e[ba]&&t.hasOwnProperty("__name__")){var r=t.__name__;if($a.isString(r)){r=r.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_(n)==="symbol"){n=Ai(n)}if(typeof n==="string"){return"#")}}if(Su(e,"toString")){return e.toString()}else if(e.name&&!Ca(e)){return"#")}else{return"#"}}var ju=new Map;[[Error,function(e){return e.message}],[M,function(e,t){var r=t.quote,n=t.skip_cycles,i=t.pair_args;if(!n){e.markCycles()}return e.toString.apply(e,[r].concat(q(i)))}],[za,function(e,t){var r=t.quote;if(r){return e.toString()}return e.valueOf()}],[$a,function(e,t){var r=t.quote;e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var t=j(e,2),r=t[0],n=t[1];ju.set(r,n)});var Iu=[L,C,Vu,jo,ho,po,So,ki];function Pu(e,t,c){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(ku.has(e)){return ku.get(e)}if(Nu(e)){return"#"}if(e){var r=e.constructor;if(ju.has(r)){for(var n=arguments.length,f=new Array(n>3?n-3:0),i=3;i"}if(e===null){return"null"}if(_(e)==="object"){var a=e.constructor;if(!a){a=Object}var o;if(typeof a.__class__==="string"){o=a.__class__}else{var s=Fu(e);if(s){if(Xu(s)){return s(e,t)}else{throw new Error("toString: Invalid repr value")}}o=a.name}if(Xu(e.toString)&&Ca(e.toString)){return e.toString().valueOf()}if(us(e)==="instance"){if(Ca(a)&&a.__name__){o=a.__name__.valueOf()}else if(!Ba(a)){o="instance"}}if(ns(e,Symbol.iterator)){if(o){return"#")}return"#"}if(ns(e,Symbol.asyncIterator)){if(o){return"#")}return"#"}if(o!==""){return"#<"+o+">"}return"#"}if(typeof e!=="string"){return e.toString()}return e}function Nu(e){return e&&_(e)==="object"&&e.hasOwnProperty&&e.hasOwnProperty("constructor")&&typeof e.constructor==="function"&&e.constructor.prototype===e}M.prototype.markCycles=function(){Ru(this);return this};M.prototype.haveCycles=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(!e){return this.haveCycles("car")||this.haveCycles("cdr")}return!!(this[ga]&&this[ga][e])};function Ru(e){var t=[];var i=[];var u=[];function a(e){if(!t.includes(e)){t.push(e)}}function o(e,t,r,n){if(r instanceof M){if(n.includes(r)){if(!u.includes(r)){u.push(r)}if(!e[ga]){e[ga]={}}e[ga][t]=r;if(!i.includes(e)){i.push(e)}return true}}}var s=gi(function e(t,r){if(t instanceof M){delete t.ref;delete t[ga];a(t);r.push(t);var n=o(t,"car",t.car,r);var i=o(t,"cdr",t.cdr,r);if(!n){s(t.car,r.slice())}if(!i){return new mi(function(){return e(t.cdr,r.slice())})}}});function r(e,t){if(e[ga][t]instanceof M){var r=n.indexOf(e[ga][t]);e[ga][t]="#".concat(r,"#")}}s(e,[]);var n=t.filter(function(e){return u.includes(e)});n.forEach(function(e,t){e[ma]="#".concat(t,"=")});i.forEach(function(e){r(e,"car");r(e,"cdr")})}M.prototype.toString=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=t.nested,n=r===void 0?false:r;var i=[];if(this[ma]){i.push(this[ma]+"(")}else if(!n){i.push("(")}var u;if(this[ga]&&this[ga].car){u=this[ga].car}else{u=Pu(this.car,e,true)}if(u!==undefined){i.push(u)}if(this.cdr instanceof M){if(this[ga]&&this[ga].cdr){i.push(" . ");i.push(this[ga].cdr)}else{if(this.cdr[ma]){i.push(" . ")}else{i.push(" ")}var a=this.cdr.toString(e,{nested:true});i.push(a)}}else if(this.cdr!==U){i=i.concat([" . ",Pu(this.cdr,e,true)])}if(!n||this[ma]){i.push(")")}return i.join("")};M.prototype.set=function(e,t){this[e]=t;if(t instanceof M){this.markCycles()}};M.prototype.append=function(e){if(e instanceof Array){return this.append(M.fromArray(e))}var t=this;if(t.car===undefined){if(e instanceof M){this.car=e.car;this.cdr=e.cdr}else{this.car=e}}else if(e!==U){while(true){if(t instanceof M&&t.cdr!==U){t=t.cdr}else{break}}t.cdr=e}return this};M.prototype.serialize=function(){return[this.car,this.cdr]};M.prototype[Symbol.iterator]=function(){var r=this;return{next:function e(){var t=r;r=t.cdr;if(t===U){return{value:undefined,done:true}}else{return{value:t.car,done:false}}}}};function Tu(e){return e<0?-e:e}function Lu(e,t){var r=m(t),n=r[0],i=r.slice(1);while(i.length>0){var u=i,a=j(u,1),o=a[0];if(!e(n,o)){return false}var s=i;var c=m(s);n=c[0];i=c.slice(1)}return true}function Uu(e,t){if(Xu(e)){return Xu(t)&&sa(e)===sa(t)}else if(e instanceof C){if(!(t instanceof C)){return false}var r;if(e.__type__===t.__type__){if(e.__type__==="complex"){r=e.__im__.__type__===t.__im__.__type__&&e.__re__.__type__===t.__re__.__type__}else{r=true}if(r&&e.cmp(t)===0){if(e.valueOf()===0){return Object.is(e.valueOf(),t.valueOf())}return true}}return false}else if(typeof e==="number"){if(typeof t!=="number"){return false}if(Number.isNaN(e)){return Number.isNaN(t)}if(e===Number.NEGATIVE_INFINITY){return t===Number.NEGATIVE_INFINITY}if(e===Number.POSITIVE_INFINITY){return t===Number.POSITIVE_INFINITY}return Uu(C(e),C(t))}else if(e instanceof za){if(!(t instanceof za)){return false}return e.__char__===t.__char__}else{return e===t}}function Mu(e,t){if(us(e)!==us(t)){return false}if(!qu(e)){return false}if(e instanceof RegExp){return e.source===t.source}if(e instanceof $a){return e.valueOf()===t.valueOf()}return Uu(e,t)}function qu(e){return e instanceof L||$a.isString(e)||e===U||e===null||e instanceof za||e instanceof C||e===true||e===false}var Yu=function(){if(Math.trunc){return Math.trunc}else{return function(e){if(e===0){return 0}else if(e<0){return Math.ceil(e)}else{return Math.floor(e)}}}}();function Vu(e,t,r,n){if(typeof this!=="undefined"&&this.constructor!==Vu||typeof this==="undefined"){return new Vu(e,t)}h("Macro",e,"string",1);h("Macro",t,"function",2);if(r){if(n){this.__doc__=r}else{this.__doc__=Hi(r)}}this.__name__=e;this.__fn__=t}Vu.defmacro=function(e,t,r,n){var i=new Vu(e,t,r,n);i.__defmacro__=true;return i};Vu.prototype.invoke=function(e,t,r){var n=t.env,i=t.dynamic_scope,u=t.error;var a={dynamic_scope:i,error:u,macro_expand:r};var o=this.__fn__.call(n,e,a,this.__name__);return o};Vu.prototype.toString=function(){return"#")};var zu="define-macro";var $u=-1e4;function Ju(c){return function(){var r=B(z.mark(function e(r,m){var u,g,n,i,s,D,E,A,x,F,k,b,a,w,o;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:o=function e(){o=B(z.mark(function e(r,n,i){var h,u,a,p,o,_,s,d,c,v,f,l,y;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!(r instanceof M&&r.car instanceof L)){t.next=50;break}if(!r[ya]){t.next=3;break}return t.abrupt("return",r);case 3:h=r.car.valueOf();u=i.get(r.car,{throwError:false});a=D(r.car);p=a||E(u,r)||A(u);if(!(p&&r.cdr.car instanceof M)){t.next=28;break}if(!a){t.next=15;break}g=F(r.cdr.car);t.next=12;return b(r.cdr.car,n);case 12:o=t.sent;t.next=17;break;case 15:g=x(r.cdr.car);o=r.cdr.car;case 17:t.t0=M;t.t1=r.car;t.t2=M;t.t3=o;t.next=23;return w(r.cdr.cdr,n,i);case 23:t.t4=t.sent;t.t5=new t.t2(t.t3,t.t4);return t.abrupt("return",new t.t0(t.t1,t.t5));case 28:if(!k(h,u)){t.next=50;break}_=u instanceof Ku?r:r.cdr;t.next=32;return u.invoke(_,vn(vn({},m),{},{env:i}),true);case 32:s=t.sent;if(!(u instanceof Ku)){t.next=41;break}d=s,c=d.expr,v=d.scope;if(!(c instanceof M)){t.next=40;break}if(!(n!==-1&&n<=1||n<$u)){t.next=38;break}return t.abrupt("return",c);case 38:if(n!==-1){n=n-1}return t.abrupt("return",w(c,n,v));case 40:s=c;case 41:if(!(s instanceof L)){t.next=43;break}return t.abrupt("return",Io(s));case 43:if(!(s instanceof M)){t.next=48;break}if(!(n!==-1&&n<=1||n<$u)){t.next=46;break}return t.abrupt("return",s);case 46:if(n!==-1){n=n-1}return t.abrupt("return",w(s,n,i));case 48:if(!qu(s)){t.next=50;break}return t.abrupt("return",s);case 50:f=r.car;if(!(f instanceof M)){t.next=55;break}t.next=54;return w(f,n,i);case 54:f=t.sent;case 55:l=r.cdr;if(!(l instanceof M)){t.next=60;break}t.next=59;return w(l,n,i);case 59:l=t.sent;case 60:y=new M(f,l);return t.abrupt("return",y);case 62:case"end":return t.stop()}}},e)}));return o.apply(this,arguments)};w=function e(t,r,n){return o.apply(this,arguments)};a=function e(){a=B(z.mark(function e(r,n){var i;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!(r===U)){t.next=2;break}return t.abrupt("return",U);case 2:i=r.car;t.t0=M;t.t1=M;t.t2=i.car;t.next=8;return w(i.cdr,n,u);case 8:t.t3=t.sent;t.t4=new t.t1(t.t2,t.t3);t.next=12;return b(r.cdr);case 12:t.t5=t.sent;return t.abrupt("return",new t.t0(t.t4,t.t5));case 14:case"end":return t.stop()}}},e)}));return a.apply(this,arguments)};b=function e(t,r){return a.apply(this,arguments)};k=function e(t,r){return r instanceof Vu&&r.__defmacro__&&!g.includes(t)};F=function e(t){return[].concat(q(g),q(t.to_array(false).map(function(e){if(e instanceof M){return e.car.valueOf()}throw new Error("macroexpand: Invalid let binding")})))};x=function e(t){var r=[];while(true){if(t!==U){if(t instanceof L){r.push(t.valueOf());break}r.push(t.car.valueOf());t=t.cdr}else{break}}return[].concat(q(g),r)};A=function e(t){return t===i};E=function e(t,r){return t===s&&r.cdr.car instanceof M};D=function e(t){var r=t.valueOf();return n.includes(r)};u=m["env"]=this;g=[];n=["let","let*","letrec"];i=qo.get("lambda");s=qo.get("define");if(!(r.cdr instanceof M&&C.isNumber(r.cdr.car))){t.next=21;break}t.t0=Io;t.next=19;return w(r,r.cdr.car.valueOf(),u);case 19:t.t1=t.sent.car;return t.abrupt("return",(0,t.t0)(t.t1));case 21:if(!c){t.next=27;break}t.t2=Io;t.next=25;return w(r,1,u);case 25:t.t3=t.sent.car;return t.abrupt("return",(0,t.t2)(t.t3));case 27:t.t4=Io;t.next=30;return w(r,-1,u);case 30:t.t5=t.sent.car;return t.abrupt("return",(0,t.t4)(t.t5));case 32:case"end":return t.stop()}}},e,this)}));return function(e,t){return r.apply(this,arguments)}}()}function Ku(e,t){this.__env__=t;this.__fn__=e;this.__defmacro__=true}Ku.__merge_env__=Symbol["for"]("merge");Ku.prototype=Object.create(Vu.prototype);Ku.prototype.invoke=function(e,t,r){var n=t.error,i=t.env;var u={error:n,env:i,dynamic_scope:this.__env__,macro_expand:r};return this.__fn__.call(i,e,u,this.__name__||"syntax")};Ku.prototype.constructor=Ku;Ku.prototype.toString=function(){if(this.__name__){return"#")}return"#"};Ku.className="syntax";var Gu=function(e){u(r,e);var t=fn(r);function r(){D(this,r);return t.apply(this,arguments)}return A(r)}(Ku);Ku.Parameter=Gu;function Hu(e,t,w,D){var r=arguments.length>4&&arguments[4]!==undefined?arguments[4]:{};var E={"...":{symbols:{},lists:[]},symbols:{}};var A=r.expansion,k=r.define;function x(e){if(Cn()){console.log(e)}}x(w);function F(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;x({code:t&&Pu(t,true),pattern:e&&Pu(e,true)});if(qu(e)&&!(e instanceof L)){return Mu(e,t)}if(e instanceof L&&w.includes(e.literal())){var c=A.ref(t);if(L.is(t,e)){if(typeof c==="undefined"){return true}return c===k||c===qo}return false}if(e instanceof M&&e.car instanceof M&&e.car.cdr instanceof M&&L.is(e.car.cdr.car,D)){x(">> 0");if(t===U){x({pattern:e.toString()});if(e.car.car instanceof L){if(e.car.cdr instanceof M&&L.is(e.car.cdr.car,D)){var f=e.car.car.valueOf();var l=e.last_pair();if(L.is(l.car,D)){E["..."].symbols[f]=null;return true}else{return false}}var h=e.car.car.valueOf();if(E["..."].symbols[h]){throw new Error("syntax: named ellipsis can only "+"appear onces")}E["..."].symbols[h]=t}}}if(e instanceof M&&e.cdr instanceof M&&L.is(e.cdr.car,D)){if(e.cdr.cdr!==U){if(e.cdr.cdr instanceof M){var p=e.cdr.cdr.length();var _=t.length();var i=t;while(_-1>p){i=i.cdr;_--}var d=i.cdr;i.cdr=U;if(!F(e.cdr.cdr,d,r,n)){return false}}}if(e.car instanceof L){var u=e.car.__name__;if(E["..."].symbols[u]&&!r.includes(u)&&!n){throw new Error("syntax: named ellipsis can only appear onces")}x(">> 1");if(t===U){x(">> 2");if(n){x("NIL");E["..."].symbols[u]=U}else{x("NULL");E["..."].symbols[u]=null}}else if(t instanceof M&&(t.car instanceof M||t.car===U)){x(">> 3 "+n);if(n){if(E["..."].symbols[u]){var a=E["..."].symbols[u];if(a===U){a=new M(U,new M(t,U))}else{a=a.append(new M(t,U))}E["..."].symbols[u]=a}else{E["..."].symbols[u]=new M(t,U)}}else{x(">> 4");E["..."].symbols[u]=new M(t,U)}}else{x(">> 6");if(t instanceof M){x(">> 7 "+n);r.push(u);if(!E["..."].symbols[u]){E["..."].symbols[u]=new M(t,U)}else{var v=E["..."].symbols[u];E["..."].symbols[u]=v.append(new M(t,U))}x({IIIIII:E["..."].symbols[u].toString()})}else{x(">> 8");return false}}return true}else if(e.car instanceof M){var y=q(r);if(t===U){x(">> 9");E["..."].lists.push(U);return true}x(">> 10");var m=t;while(m instanceof M){if(!F(e.car,m.car,y,true)){return false}m=m.cdr}return true}return false}if(e instanceof L){if(L.is(e,D)){throw new Error("syntax: invalid usage of ellipsis")}x(">> 11");var o=e.__name__;if(w.includes(o)){return true}x({name:o,ellipsis:n});if(n){E["..."].symbols[o]=E["..."].symbols[o]||[];E["..."].symbols[o].push(t)}E.symbols[o]=t;if(!E.symbols[o]);return true}if(e instanceof M&&t instanceof M){x(">> 12");x({a:12,code:t&&t.toString(),pattern:e.toString()});if(t.cdr===U){var g=e.car instanceof L&&e.cdr instanceof L;if(g){if(!F(e.car,t.car,r,n)){return false}x(">> 12 | 1");var s=e.cdr.valueOf();if(!(s in E.symbols)){E.symbols[s]=U}s=e.car.valueOf();if(!(s in E.symbols)){E.symbols[s]=t.car}return true}}x({pattern:e.toString(),code:t.toString()});if(e.cdr instanceof M&&e.car instanceof L&&e.cdr.cdr instanceof M&&e.cdr.car instanceof L&&L.is(e.cdr.cdr.car,D)&&e.cdr.cdr.cdr instanceof M&&!L.is(e.cdr.cdr.cdr.car,D)&&F(e.car,t.car,r,n)&&F(e.cdr.cdr.cdr,t.cdr,r,n)){var b=e.cdr.car.__name__;x({pattern:e.car.toString(),code:t.car.toString(),name:b});if(w.includes(b)){return true}E["..."].symbols[b]=null;return true}x("recur");if(F(e.car,t.car,r,n)&&F(e.cdr,t.cdr,r,n)){return true}}else if(e===U&&(t===U||t===undefined)){return true}else if(e.car instanceof M&&L.is(e.car.car,D)){throw new Error("syntax: invalid usage of ellipsis")}else{return false}}if(F(e,t)){return E}}function Wu(e,i){function u(t){if(t instanceof M){if(!i.length){return t}var e=u(t.car);var r=u(t.cdr);return new M(e,r)}else if(t instanceof L){var n=i.find(function(e){return e.gensym===t});if(n){return L(n.name)}return t}else{return t}}return u(e)}function Qu(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var O=e.bindings,t=e.expr,S=e.scope,a=e.symbols,f=e.names,B=e.ellipsis;var c={};function o(e){if(e instanceof L){return true}return["string","symbol"].includes(_(e))}function j(e){if(!o(e)){var t=us(e);throw new Error("syntax: internal error, need symbol got ".concat(t))}var r=e.valueOf();if(r===B){throw new Error("syntax: internal error, ellipis not transformed")}var n=_(r);if(["string","symbol"].includes(n)){if(r in O.symbols){return O.symbols[r]}else if(n==="string"&&r.match(/\./)){var i=r.split(".");var u=i[0];if(u in O.symbols){return M.fromArray([L("."),O.symbols[u]].concat(i.slice(1).map(function(e){return $a(e)})))}}}if(a.includes(r)){return L(r)}return s(r)}function I(e){if(Cn()){console.log(e)}}function s(e){if(!c[e]){var t=S.ref(e);var r=Fi(e);if(t){var n=S.get(e);S.set(r,n)}else{var i=S.get(e,{throwError:false});if(typeof i!=="undefined"){S.set(r,i)}}f.push({name:e,gensym:r});c[e]=r;if(typeof e==="string"&&e.match(/\./)){var u=e.split(".").filter(Boolean),a=m(u),o=a[0],s=a.slice(1);if(c[o]){Fa(r,"__object__",[c[o]].concat(q(s)))}}}return c[e]}function P(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:function(){};var i=r.nested;I(" ==> "+e.toString(true));I(t);if(e instanceof L){var u=e.valueOf();I("[t 1");if(t[u]){if(t[u]instanceof M){var c=t[u],f=c.car,l=c.cdr;if(i){var h=f.car,p=f.cdr;if(p!==U){n(u,new M(p,U))}return h}if(l!==U){n(u,l)}return f}else if(t[u]instanceof Array){n(u,t[u].slice(1));return t[u][0]}}return j(u)}if(e instanceof M){if(e.car instanceof L&&e.cdr instanceof M&&L.is(e.cdr.car,B)){I("[t 2");var a=e.car.valueOf();var o=t[a];I({expr:e.toString(true),name:a,bindings:t,item:o});if(o===null){return}else if(o){I({b:t[a].toString()});if(o instanceof M){I("[t 2 Pair "+i);I({______:o.toString()});var s=o.car,_=o.cdr;if(i){if(_!==U){I("|| next 1");n(a,_)}I({car:s.toString()});return s}else{if(s.cdr!==U){I("|| next 2");n(a,new M(s.cdr,_))}I({car:s.car.toString()});return s.car}}else if(o instanceof Array){I("[t 2 Array "+i);if(i){n(a,o.slice(1));return M.fromArray(o)}else{var d=o.slice(1);if(d.length){n(a,d)}return o[0]}}else{return o}}}I("[t 3 recur "+e.toString());var v=P(e.car,t,r,n);var y=P(e.cdr,t,r,n);return new M(v,y)}return e}function R(t,r){var e=Object.values(t);var n=Object.getOwnPropertySymbols(t);if(n.length){e.push.apply(e,q(n.map(function(e){return t[e]})))}return e.length&&e.every(function(e){if(e===null){return!r}return e instanceof M||e===U||e instanceof Array&&e.length})}function T(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function N(i){var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},e=n.disabled;I("traverse>> "+Pu(i));if(i instanceof M){if(!e&&i.car instanceof M&&L.is(i.car.car,B)){return N(i.car.cdr,{disabled:true})}if(i.cdr instanceof M&&L.is(i.cdr.car,B)&&!e){I(">> 1");var t=O["..."].symbols;var f=Object.values(t);if(f.length&&f.every(function(e){return e===null})){return N(i.cdr.cdr,{disabled:e})}var l=T(t);var u=i.car instanceof L&&L.is(i.cdr.cdr.car,B);if(i.car instanceof M||u){if(O["..."].lists[0]===U){return U}var h=i.car;if(u){h=new M(i.car,new M(i.cdr.car,U))}I(">> 2");var a;if(l.length){I(">> 2 (a)");var o=vn({},t);a=U;var p=function e(){if(!R(o)){return"break"}var n={};var t=function e(t,r){n[t]=r};var r=P(h,o,{nested:true},t);if(r!==undefined){if(u){if(a===U){a=r}else{a=a.append(r)}}else{a=new M(r,a)}}o=n};while(true){var _=p();if(_==="break")break}if(a!==U&&!u){a=a.reverse()}if(i.cdr.cdr!==U&&!L.is(i.cdr.cdr.car,B)){var d=N(i.cdr.cdr,{disabled:e});return a.append(d)}return a}else{I(">> 3");var v=P(i.car,t,{nested:true});if(v){return new M(v,U)}return U}}else if(i.car instanceof L){I(">> 4");if(L.is(i.cdr.cdr.car,B)){I(">> 4 (a)")}else{I(">> 4 (b)")}var y=i.car.__name__;var s=Y({},y,t[y]);var m=t[y]===null;var c=U;var g=function e(){if(!R(s,true)){I({bind:s});return"break"}var n={};var t=function e(t,r){n[t]=r};var r=P(i,s,{nested:false},t);I({value:r.toString()});if(typeof r!=="undefined"){c=new M(r,c)}s=n};while(true){var b=g();if(b==="break")break}if(c!==U){c=c.reverse()}if(i.cdr instanceof M){if(i.cdr.cdr instanceof M||i.cdr.cdr instanceof L){var w=N(i.cdr.cdr,{disabled:e});if(m){return w}I("<<<< 1");c.append(w)}}I("<<<< 2");return c}}var D=N(i.car,{disabled:e});var r;var E;if(i.car instanceof L){var A=S.get(i.car,{throwError:false});E=A instanceof Vu&&A.__name__==="syntax-rules"}if(E){if(i.cdr.car instanceof L){r=new M(N(i.cdr.car,{disabled:e}),new M(i.cdr.cdr.car,N(i.cdr.cdr.cdr,{disabled:e})))}else{r=new M(i.cdr.car,N(i.cdr.cdr,{disabled:e}))}I("REST >>>> "+r.toString())}else{r=N(i.cdr,{disabled:e})}I({a:true,car:Pu(i.car),cdr:Pu(i.cdr),head:Pu(D),rest:Pu(r)});return new M(D,r)}if(i instanceof L){if(e&&L.is(i,B)){return i}var x=Object.keys(O["..."].symbols);var F=i.literal();if(x.includes(F)){var k="missing ellipsis symbol next to name `".concat(F,"'");throw new Error("syntax-rules: ".concat(k))}var C=j(i);if(typeof C!=="undefined"){return C}}return i}return N(t,{})}function Zu(e){return na(e)||e===U||e===null}function Xu(e){return typeof e==="function"&&typeof e.bind==="function"}function ea(e){return e instanceof hs}function ta(e){return Xu(e)||ea(e)}function ra(e){if(e instanceof ki){return false}if(e instanceof Promise){return true}return e&&Xu(e.then)}function na(e){return typeof e==="undefined"}function ia(e){switch(_(e)){case"string":return $a(e);case"bigint":return C(e);case"number":if(Number.isNaN(e)){return Uo}else{return C(e)}}return e}function ua(n,i){var e=Object.getOwnPropertyNames(n);var t=Object.getOwnPropertySymbols(n);e.concat(t).forEach(function(e){var t=i(n[e]);var r=Object.getOwnPropertyDescriptor(n,e);if(!r||r.writable&&n[e]!==t){n[e]=t}});return n}function aa(t){var e=[$a,C].some(function(e){return t instanceof e});if(e){return t.valueOf()}if(t instanceof Array){return t.map(aa)}if(t instanceof ki){delete t.then}if(wu(t)){return ua(t,aa)}return t}function oa(e,t){if(e instanceof M){e.markCycles();return Io(e)}if(Xu(e)){if(t){return ca(e,t)}}return ia(e)}function sa(e){if(la(e)){return e[va]}return e}function ca(e,t){if(e[Symbol["for"]("__bound__")]){return e}var r=e.bind(t);var n=Object.getOwnPropertyNames(e);var i=hn(n),u;try{for(i.s();!(u=i.n()).done;){var a=u.value;if(xa(a)){try{r[a]=e[a]}catch(e){}}}}catch(e){i.e(e)}finally{i.f()}Fa(r,"__fn__",e);Fa(r,"__context__",t);Fa(r,"__bound__",true);if(Ba(e)){Fa(r,"__native__",true)}if(wu(t)&&Ca(e)){Fa(r,"__method__",true)}r.valueOf=function(){return e};return r}function fa(e){return la(e)&&e[Symbol["for"]("__context__")]===Object}function la(e){return!!(Xu(e)&&e[va])}function ha(e){if(Xu(e)){var t=e[da];if(t&&(t===Gs||t.constructor&&t.constructor.__class__)){return true}}return false}function pa(e){return e instanceof ho||e instanceof po}function _a(e){if(Xu(e)){if(pa(e[da])){return true}}return false}var da=Symbol["for"]("__context__");var va=Symbol["for"]("__fn__");var ya=Symbol["for"]("__data__");var ma=Symbol["for"]("__ref__");var ga=Symbol["for"]("__cycles__");var ba=Symbol["for"]("__class__");var wa=Symbol["for"]("__method__");var Da=Symbol["for"]("__prototype__");var Ea=Symbol["for"]("__lambda__");var Aa=["name","length","caller","callee","arguments","prototype"];function xa(e){return!Aa.includes(e)}function Fa(e,t,r){Object.defineProperty(e,Symbol["for"](t),{get:function e(){return r},set:function e(){},configurable:false,enumerable:false})}function ka(t,r){try{Object.defineProperty(t,"length",{get:function e(){return r}});return t}catch(e){var n=new Array(r).fill(0).map(function(e,t){return"a"+t}).join(",");var i=new Function("f","return function(".concat(n,") {\n return f.apply(this, arguments);\n };"));return i(t)}}function Ca(e){return e&&e[Ea]}function Oa(e){return e&&e[wa]}function Sa(e){return Ca(e)&&!e[Da]&&!Oa(e)&&!_a(e)}function Ba(e){var t=Symbol["for"]("__native__");return Xu(e)&&e.toString().match(/\{\s*\[native code\]\s*\}/)&&(e.name.match(/^bound /)&&e[t]===true||!e.name.match(/^bound /)&&!e[t])}function ja(e){var g;switch(e){case Symbol["for"]("letrec"):g="letrec";break;case Symbol["for"]("let"):g="let";break;case Symbol["for"]("let*"):g="let*";break;default:throw new Error("Invalid let_macro value")}return Vu.defmacro(g,function(t,e){var f=e.dynamic_scope,l=e.error,n=e.macro_expand;var h;if(t.car instanceof L){if(!(t.cdr.car instanceof M||t.cdr.car===U)){throw new Error("let require list of pairs")}var r;if(t.cdr.car===U){h=U;r=U}else{r=t.cdr.car.map(function(e){return e.car});h=t.cdr.car.map(function(e){return e.cdr.car})}return M.fromArray([L("letrec"),[[t.car,M(L("lambda"),M(r,t.cdr.cdr))]],M(t.car,h)])}else if(n){return}var p=this;h=qo.get("list->array")(t.car);var _=p.inherit(g);var d,v;if(g==="let*"){v=_}else if(g==="let"){d=[]}var y=0;function m(){var e=new M(new L("begin"),t.cdr);return _s(e,{env:_,dynamic_scope:f,error:l})}return function t(){var r=h[y++];if(f){f=g==="let*"?_:p}if(!r){if(d&&d.length){var e=d.map(function(e){return e.value});var n=e.filter(ra);if(n.length){return Ci(e).then(function(e){for(var t=0,r=e.length;t1&&arguments[1]!==undefined?arguments[1]:{},r=t.dynamic_scope,n=t.error;var i=this;if(r){r=this}var u=e;var a=[];while(u instanceof M){a.push(_s(u.car,{env:i,dynamic_scope:r,error:n}));u=u.cdr}var o=a.filter(ra).length;if(o){return Ci(a).then(s.bind(this))}else{return s.call(this,a)}})}function Pa(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n2?n-2:0),u=2;u1&&arguments[1]!==undefined?arguments[1]:null;return function(){for(var e=arguments.length,t=new Array(e),r=0;r1?e-1:0),r=1;r=a){return u.apply(this,n)}else{return i}}return i.apply(this,arguments)}}function Va(n,i){h("limit",i,"function",2);return function(){for(var e=arguments.length,t=new Array(e),r=0;r1){e=e.toLowerCase();if(za.__names__[e]){t=e;e=za.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{t=za.__rev_names__[e]}Object.defineProperty(this,"__char__",{value:e,enumerable:true});if(t){Object.defineProperty(this,"__name__",{value:t,enumerable:true})}}za.__names__=Un;za.__rev_names__={};Object.keys(za.__names__).forEach(function(e){var t=za.__names__[e];za.__rev_names__[t]=e});za.prototype.toUpperCase=function(){return za(this.__char__.toUpperCase())};za.prototype.toLowerCase=function(){return za(this.__char__.toLowerCase())};za.prototype.toString=function(){return"#\\"+(this.__name__||this.__char__)};za.prototype.valueOf=za.prototype.serialize=function(){return this.__char__};function $a(e){if(typeof this!=="undefined"&&!(this instanceof $a)||typeof this==="undefined"){return new $a(e)}if(e instanceof Array){this.__string__=e.map(function(e,t){h("LString",e,"character",t+1);return e.toString()}).join("")}else{this.__string__=e.valueOf()}}{var Ja=["length","constructor"];var Ka=Object.getOwnPropertyNames(String.prototype).filter(function(e){return!Ja.includes(e)});var Ga=function e(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r0){r.push(this.__string__.substring(0,e))}r.push(t);if(e1&&arguments[1]!==undefined?arguments[1]:false;if(e instanceof C){return e}if(typeof this!=="undefined"&&!(this instanceof C)||typeof this==="undefined"){return new C(e,t)}if(typeof e==="undefined"){throw new Error("Invalid LNumber constructor call")}var r=C.getType(e);if(C.types[r]){return C.types[r](e,t)}var n=e instanceof Array&&$a.isString(e[0])&&C.isNumber(e[1]);if(e instanceof C){return C(e.value)}if(!C.isNumber(e)&&!n){throw new Error("You can't create LNumber from ".concat(us(e)))}if(e===null){e=0}var i;if(n){var c=e,u=j(c,2),a=u[0],o=u[1];if(a instanceof $a){a=a.valueOf()}if(o instanceof C){o=o.valueOf()}var f=a.match(/^([+-])/);var l=false;if(f){a=a.replace(/^[+-]/,"");if(f[1]==="-"){l=true}}}if(Number.isNaN(e)){return uo(e)}else if(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(n){var s;switch(o){case 8:s="0o";break;case 16:s="0x";break;case 2:s="0b";break;case 10:s="";break}if(typeof s==="undefined"){var h=BigInt(o);i=q(a).map(function(e,t){return BigInt(parseInt(e,o))*ro(h,BigInt(t))}).reduce(function(e,t){return e+t})}else{i=BigInt(s+a)}}else{i=BigInt(e)}if(l){i*=BigInt(-1)}}else{i=e}return lo(i,true)}else if(typeof xn!=="undefined"&&!(e instanceof xn)){if(e instanceof Array){return lo(p(xn,q(e)))}return lo(new xn(e))}else if(n){this.constant(parseInt(a,o),"integer")}else{this.constant(e,"integer")}}C.prototype.constant=function(e,t){Object.defineProperty(this,"__value__",{value:e,enumerable:true});Object.defineProperty(this,"__type__",{value:t,enumerable:true})};C.types={float:function e(t){return new uo(t)},complex:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!C.isComplex(t)){t={im:0,re:t}}return new io(t,r)},rational:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!C.isRational(t)){t={num:t,denom:1}}return new fo(t,r)}};C.prototype.serialize=function(){return this.__value__};C.prototype.isNaN=function(){return Number.isNaN(this.__value__)};C.prototype.gcd=function(e){var t=this.abs();e=e.abs();if(e.cmp(t)===1){var r=t;t=e;e=r}while(true){t=t.rem(e);if(t.cmp(0)===0){return e}e=e.rem(t);if(e.cmp(0)===0){return t}}};C.isFloat=function e(t){return t instanceof uo||Number(t)===t&&t%1!==0};C.isNumber=function(e){return e instanceof C||C.isNative(e)||C.isBN(e)};C.isComplex=function(e){if(!e){return false}var t=e instanceof io||(C.isNumber(e.im)||Number.isNaN(e.im))&&(C.isNumber(e.re)||Number.isNaN(e.re));return t};C.isRational=function(e){if(!e){return false}return e instanceof fo||C.isNumber(e.num)&&C.isNumber(e.denom)};C.isInteger=function(e){if(!(C.isNative(e)||e instanceof C)){return false}if(C.isFloat(e)){return false}if(C.isRational(e)){return false}if(C.isComplex(e)){return false}return true};C.isNative=function(e){return typeof e==="bigint"||typeof e==="number"};C.isBigInteger=function(e){return e instanceof lo||typeof e==="bigint"||C.isBN(e)};C.isBN=function(e){return typeof xn!=="undefined"&&e instanceof xn};C.getArgsType=function(e,t){if(e instanceof uo||t instanceof uo){return uo}if(e instanceof lo||t instanceof lo){return lo}return C};C.prototype.toString=function(e){if(Number.isNaN(this.__value__)){return"+nan.0"}if(e>2&&e<36){return this.__value__.toString(e)}return this.__value__.toString()};C.prototype.asType=function(e){var t=C.getType(this);return C.types[t]?C.types[t](e):C(e)};C.prototype.isBigNumber=function(){return typeof this.__value__==="bigint"||typeof xn!=="undefined"&&!(this.value instanceof xn)};["floor","ceil","round"].forEach(function(e){C.prototype[e]=function(){if(this["float"]||C.isFloat(this.__value__)){return C(Math[e](this.__value__))}else{return C(Math[e](this.valueOf()))}}});C.prototype.valueOf=function(){if(C.isNative(this.__value__)){return Number(this.__value__)}else if(C.isBN(this.__value__)){return this.__value__.toNumber()}};var Za=function(){var e=function e(t,r){return[t,r]};return{bigint:{bigint:e,float:function e(t,r){return[uo(t.valueOf()),r]},rational:function e(t,r){return[{num:t,denom:1},r]},complex:function e(t,r){return[{im:0,re:t},r]}},integer:{integer:e,float:function e(t,r){return[uo(t.valueOf()),r]},rational:function e(t,r){return[{num:t,denom:1},r]},complex:function e(t,r){return[{im:0,re:t},r]}},float:{bigint:function e(t,r){return[t,r&&uo(r.valueOf())]},integer:function e(t,r){return[t,r&&uo(r.valueOf())]},float:e,rational:function e(t,r){return[t,r&&uo(r.valueOf())]},complex:function e(t,r){return[{re:t,im:uo(0)},r]}},complex:{bigint:t("bigint"),integer:t("integer"),float:t("float"),rational:t("rational"),complex:function f(e,t){var r=C.coerce(e.__re__,t.__re__),n=j(r,2),i=n[0],u=n[1];var a=C.coerce(e.__im__,t.__im__),o=j(a,2),s=o[0],c=o[1];return[{im:s,re:i},{im:c,re:u}]}},rational:{bigint:function e(t,r){return[t,r&&{num:r,denom:1}]},integer:function e(t,r){return[t,r&&{num:r,denom:1}]},float:function e(t,r){return[uo(t.valueOf()),r]},rational:e,complex:function e(t,r){return[{im:Xa(t.__type__,r.__im__.__type__,0)[0],re:Xa(t.__type__,r.__re__.__type__,t)[0]},{im:Xa(t.__type__,r.__im__.__type__,r.__im__)[0],re:Xa(t.__type__,r.__re__.__type__,r.__re__)[0]}]}}};function t(r){return function(e,t){return[{im:Xa(r,e.__im__.__type__,0,e.__im__)[1],re:Xa(r,e.__re__.__type__,0,e.__re__)[1]},{im:Xa(r,e.__im__.__type__,0,0)[1],re:Xa(r,t.__type__,0,t)[1]}]}}}();function Xa(e,t,r,n){return Za[e][t](r,n)}C.coerce=function(e,t){var r=C.getType(e);var n=C.getType(t);if(!Za[r]){throw new Error("LNumber::coerce unknown lhs type ".concat(r))}else if(!Za[r][n]){throw new Error("LNumber::coerce unknown rhs type ".concat(n))}var i=Za[r][n](e,t);return i.map(function(e){return C(e,true)})};C.prototype.coerce=function(e){if(!(typeof e==="number"||e instanceof C)){throw new Error("LNumber: you can't coerce ".concat(us(e)))}if(typeof e==="number"){e=C(e)}return C.coerce(this,e)};C.getType=function(e){if(e instanceof C){return e.__type__}if(C.isFloat(e)){return"float"}if(C.isComplex(e)){return"complex"}if(C.isRational(e)){return"rational"}if(typeof e==="number"){return"integer"}if(typeof BigInt!=="undefined"&&typeof e!=="bigint"||typeof xn!=="undefined"&&!(e instanceof xn)){return"bigint"}};C.prototype.isFloat=function(){return!!(C.isFloat(this.__value__)||this["float"])};var eo={add:"+",sub:"-",mul:"*",div:"/",rem:"%",or:"|",and:"&",neg:"~",shl:">>",shr:"<<"};var to={};Object.keys(eo).forEach(function(t){to[eo[t]]=t;C.prototype[t]=function(e){return this.op(eo[t],e)}});C._ops={"*":function e(t,r){return t*r},"+":function e(t,r){return t+r},"-":function e(t,r){if(typeof r==="undefined"){return-t}return t-r},"/":function e(t,r){return t/r},"%":function e(t,r){return t%r},"|":function e(t,r){return t|r},"&":function e(t,r){return t&r},"~":function e(t){return~t},">>":function e(t,r){return t>>r},"<<":function e(t,r){return t<1&&arguments[1]!==undefined?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof io)||typeof this==="undefined"){return new io(e,t)}if(e instanceof io){return io({im:e.__im__,re:e.__re__})}if(C.isNumber(e)&&t){if(!t){return Number(e)}}else if(!C.isComplex(e)){var r="Invalid constructor call for LComplex expect &(:im :re ) object but got ".concat(Pu(e));throw new Error(r)}var n=e.im instanceof C?e.im:C(e.im);var i=e.re instanceof C?e.re:C(e.re);this.constant(n,i)}io.prototype=Object.create(C.prototype);io.prototype.constructor=io;io.prototype.constant=function(e,t){Object.defineProperty(this,"__im__",{value:e,enumerable:true});Object.defineProperty(this,"__re__",{value:t,enumerable:true});Object.defineProperty(this,"__type__",{value:"complex",enumerable:true})};io.prototype.serialize=function(){return{re:this.__re__,im:this.__im__}};io.prototype.toRational=function(e){if(C.isFloat(this.__im__)&&C.isFloat(this.__re__)){var t=uo(this.__im__).toRational(e);var r=uo(this.__re__).toRational(e);return io({im:t,re:r})}return this};io.prototype.pow=function(e){throw new Error("Not yet implemented")};io.prototype.add=function(e){return this.complex_op("add",e,function(e,t,r,n){return{re:e.add(t),im:r.add(n)}})};io.prototype.factor=function(){if(this.__im__ instanceof uo||this.__im__ instanceof uo){var e=this.__re__,t=this.__im__;var r,n;if(e instanceof uo){r=e.toRational().mul(e.toRational())}else{r=e.mul(e)}if(t instanceof uo){n=t.toRational().mul(t.toRational())}else{n=t.mul(t)}return r.add(n)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};io.prototype.modulus=function(){return this.factor().sqrt()};io.prototype.conjugate=function(){return io({re:this.__re__,im:this.__im__.sub()})};io.prototype.sqrt=function(){var e=this.modulus();var t,r;if(e.cmp(0)===0){t=r=e}else if(this.__re__.cmp(0)===1){t=uo(.5).mul(e.add(this.__re__)).sqrt();r=this.__im__.div(t).div(2)}else{r=uo(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){r=r.sub()}t=this.__im__.div(r).div(2)}return io({im:r,re:t})};io.prototype.div=function(e){if(C.isNumber(e)&&!C.isComplex(e)){if(!(e instanceof C)){e=C(e)}var t=this.__re__.div(e);var r=this.__im__.div(e);return io({re:t,im:r})}else if(!C.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}if(this.cmp(e)===0){var n=this.coerce(e),i=j(n,2),f=i[0],u=i[1];var l=f.__im__.div(u.__im__);return l.coerce(u.__re__)[0]}var h=this.coerce(e),a=j(h,2),p=a[0],o=a[1];var s=o.factor();var _=o.conjugate();var c=p.mul(_);if(!C.isComplex(c)){return c.div(s)}var d=c.__re__.op("/",s);var v=c.__im__.op("/",s);return io({re:d,im:v})};io.prototype.sub=function(e){return this.complex_op("sub",e,function(e,t,r,n){return{re:e.sub(t),im:r.sub(n)}})};io.prototype.mul=function(e){return this.complex_op("mul",e,function(e,t,r,n){var i={re:e.mul(t).sub(r.mul(n)),im:e.mul(n).add(t.mul(r))};return i})};io.prototype.complex_op=function(e,t,i){var u=this;var r=function e(t,r){var n=i(u.__re__,t,u.__im__,r);if("im"in n&&"re"in n){if(n.im.cmp(0)===0){return n.re}return io(n,true)}return n};if(typeof t==="undefined"){return r()}if(C.isNumber(t)&&!C.isComplex(t)){if(!(t instanceof C)){t=C(t)}var n=t.asType(0);t={__im__:n,__re__:t}}else if(!C.isComplex(t)){throw new Error("[LComplex::".concat(e,"] Invalid value"))}var a=t.__re__ instanceof C?t.__re__:this.__re__.asType(t.__re__);var o=t.__im__ instanceof C?t.__im__:this.__im__.asType(t.__im__);return r(a,o)};io._op={"+":"add","-":"sub","*":"mul","/":"div"};io.prototype._op=function(e,t){var r=io._op[e];return this[r](t)};io.prototype.cmp=function(e){var t=this.coerce(e),r=j(t,2),n=r[0],i=r[1];var u=n.__re__.coerce(i.__re__),a=j(u,2),o=a[0],f=a[1];var s=o.cmp(f);if(s!==0){return s}else{var l=n.__im__.coerce(i.__im__),c=j(l,2),h=c[0],p=c[1];return h.cmp(p)}};io.prototype.valueOf=function(){return[this.__re__,this.__im__].map(function(e){return e.valueOf()})};io.prototype.toString=function(){var e;if(this.__re__.cmp(0)!==0){e=[Pu(this.__re__)]}else{e=[]}var t=this.__im__.valueOf();var r=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(t);var n=Pu(this.__im__);if(!r&&!Number.isNaN(t)){var i=this.__im__.cmp(0);if(i<0||i===0&&this.__im__._minus){e.push("-")}else{e.push("+")}n=n.replace(/^-/,"")}e.push(n);e.push("i");return e.join("")};function uo(e){if(typeof this!=="undefined"&&!(this instanceof uo)||typeof this==="undefined"){return new uo(e)}if(!C.isNumber(e)){throw new Error("Invalid constructor call for LFloat")}if(e instanceof C){return uo(e.valueOf())}if(typeof e==="number"){if(Object.is(e,-0)){Object.defineProperty(this,"_minus",{value:true})}this.constant(e,"float")}}uo.prototype=Object.create(C.prototype);uo.prototype.constructor=uo;uo.prototype.toString=function(){if(this.__value__===Number.NEGATIVE_INFINITY){return"-inf.0"}if(this.__value__===Number.POSITIVE_INFINITY){return"+inf.0"}if(Number.isNaN(this.__value__)){return"+nan.0"}var e=this.__value__.toString();if(!C.isFloat(this.__value__)&&!e.match(/e/i)){var t=e+".0";return this._minus?"-"+t:t}return e.replace(/^([0-9]+)e/,"$1.0e")};uo.prototype._op=function(e,t){if(t instanceof C){t=t.__value__}var r=C._ops[e];if(e==="/"&&this.__value__===0&&t===0){return NaN}return uo(r(this.__value__,t))};uo.prototype.toRational=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){return ao(this.__value__.valueOf())}return oo(e.valueOf())(this.__value__.valueOf())};uo.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){var t=uo(Math.sqrt(-e));return io({re:0,im:t})}return uo(Math.sqrt(e))};uo.prototype.abs=function(){var e=this.valueOf();if(e<0){e=-e}return uo(e)};var ao=oo(1e-10);function oo(n){return function(e){var t=function e(n,t,r){var i=function e(t,r){return r0){i=co(n,r)}else if(n.cmp(r)<=0){i=r}else if(r.cmp(0)>0){i=co(r,n)}else if(t.cmp(0)<0){i=C(co(n.sub(),r.sub())).sub()}else{i=C(0)}if(C.isFloat(t)||C.isFloat(e)){return uo(i)}return i}function co(e,t){var r=C(e).floor();var n=C(t).floor();if(e.cmp(r)<1){return r}else if(r.cmp(n)===0){var i=C(1).div(t.sub(n));var u=C(1).div(e.sub(r));return r.add(C(1).div(co(i,u)))}else{return r.add(C(1))}}function fo(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof fo)||typeof this==="undefined"){return new fo(e,t)}if(!C.isRational(e)){throw new Error("Invalid constructor call for LRational")}var r,n;if(e instanceof fo){r=C(e.__num__);n=C(e.__denom__)}else{r=C(e.num);n=C(e.denom)}if(!t&&n.cmp(0)!==0){var i=r.op("%",n).cmp(0)===0;if(i){return C(r.div(n))}}this.constant(r,n)}fo.prototype=Object.create(C.prototype);fo.prototype.constructor=fo;fo.prototype.constant=function(e,t){Object.defineProperty(this,"__num__",{value:e,enumerable:true});Object.defineProperty(this,"__denom__",{value:t,enumerable:true});Object.defineProperty(this,"__type__",{value:"rational",enumerable:true})};fo.prototype.serialize=function(){return{num:this.__num__,denom:this.__denom__}};fo.prototype.pow=function(e){var t=e.cmp(0);if(t===0){return C(1)}if(t===-1){e=e.sub();var r=this.__denom__.pow(e);var n=this.__num__.pow(e);return fo({num:r,denom:n})}var i=this;e=e.valueOf();while(e>1){i=i.mul(this);e--}return i};fo.prototype.sqrt=function(){var e=this.__num__.sqrt();var t=this.__denom__.sqrt();if(e instanceof uo||t instanceof uo){return e.div(t)}return fo({num:e,denom:t})};fo.prototype.abs=function(){var e=this.__num__;var t=this.__denom__;if(e.cmp(0)===-1){e=e.sub()}if(t.cmp(0)!==1){t=t.sub()}return fo({num:e,denom:t})};fo.prototype.cmp=function(e){return C(this.valueOf(),true).cmp(e)};fo.prototype.toString=function(){var e=this.__num__.gcd(this.__denom__);var t,r;if(e.cmp(1)!==0){t=this.__num__.div(e);if(t instanceof fo){t=C(t.valueOf(true))}r=this.__denom__.div(e);if(r instanceof fo){r=C(r.valueOf(true))}}else{t=this.__num__;r=this.__denom__}var n=this.cmp(0)<0;if(n){if(t.abs().cmp(r.abs())===0){return t.toString()}}else if(t.cmp(r)===0){return t.toString()}return t.toString()+"/"+r.toString()};fo.prototype.valueOf=function(e){if(this.__denom__.cmp(0)===0){if(this.__num__.cmp(0)<0){return Number.NEGATIVE_INFINITY}return Number.POSITIVE_INFINITY}if(e){return C._ops["/"](this.__num__.value,this.__denom__.value)}return uo(this.__num__.valueOf()).div(this.__denom__.valueOf())};fo.prototype.mul=function(e){if(!(e instanceof C)){e=C(e)}if(C.isRational(e)){var t=this.__num__.mul(e.__num__);var r=this.__denom__.mul(e.__denom__);return fo({num:t,denom:r})}var n=C.coerce(this,e),i=j(n,2),u=i[0],a=i[1];return u.mul(a)};fo.prototype.div=function(e){if(!(e instanceof C)){e=C(e)}if(C.isRational(e)){var t=this.__num__.mul(e.__denom__);var r=this.__denom__.mul(e.__num__);return fo({num:t,denom:r})}var n=C.coerce(this,e),i=j(n,2),u=i[0],a=i[1];var o=u.div(a);return o};fo.prototype._op=function(e,t){return this[to[e]](t)};fo.prototype.sub=function(e){if(typeof e==="undefined"){return this.mul(-1)}if(!(e instanceof C)){e=C(e)}if(C.isRational(e)){var t=e.__num__.sub();var r=e.__denom__;return this.add(fo({num:t,denom:r}))}if(!(e instanceof C)){e=C(e).sub()}else{e=e.sub()}var n=C.coerce(this,e),i=j(n,2),u=i[0],a=i[1];return u.add(a)};fo.prototype.add=function(e){if(!(e instanceof C)){e=C(e)}if(C.isRational(e)){var t=this.__denom__;var r=e.__denom__;var n=this.__num__;var i=e.__num__;var u,a;if(t!==r){a=r.mul(n).add(i.mul(t));u=t.mul(r)}else{a=n.add(i);u=t}return fo({num:a,denom:u})}if(C.isFloat(e)){return uo(this.valueOf()).add(e)}var o=C.coerce(this,e),s=j(o,2),c=s[0],f=s[1];return c.add(f)};function lo(e,t){if(typeof this!=="undefined"&&!(this instanceof lo)||typeof this==="undefined"){return new lo(e,t)}if(e instanceof lo){return lo(e.__value__,e._native)}if(!C.isBigInteger(e)){throw new Error("Invalid constructor call for LBigInteger")}this.constant(e,"bigint");Object.defineProperty(this,"_native",{value:t})}lo.prototype=Object.create(C.prototype);lo.prototype.constructor=lo;lo.bn_op={"+":"iadd","-":"isub","*":"imul","/":"idiv","%":"imod","|":"ior","&":"iand","~":"inot","<<":"ishrn",">>":"ishln"};lo.prototype.serialize=function(){return this.__value__.toString()};lo.prototype._op=function(e,t){if(typeof t==="undefined"){if(C.isBN(this.__value__)){e=lo.bn_op[e];return lo(this.__value__.clone()[e](),false)}return lo(C._ops[e](this.__value__),true)}if(C.isBN(this.__value__)&&C.isBN(t.__value__)){e=lo.bn_op[e];return lo(this.__value__.clone()[e](t),false)}var r=C._ops[e](this.__value__,t.__value__);if(e==="/"){var n=this.op("%",t).cmp(0)===0;if(n){return C(r)}return fo({num:this,denom:t})}return lo(r,true)};lo.prototype.sqrt=function(){var e;var t=this.cmp(0)<0;if(C.isNative(this.__value__)){e=C(Math.sqrt(t?-this.valueOf():this.valueOf()))}else if(C.isBN(this.__value__)){e=t?this.__value__.neg().sqrt():this.__value__.sqrt()}if(t){return io({re:0,im:e})}return e};C.NaN=C(NaN);function ho(e){var n=this;if(typeof this!=="undefined"&&!(this instanceof ho)||typeof this==="undefined"){return new ho(e)}h("InputPort",e,"function");$i(this,"__type__",xo);var i;Object.defineProperty(this,"__parser__",{enumerable:true,get:function e(){return i},set:function e(t){h("InputPort::__parser__",t,"parser");i=t}});this._read=e;this._with_parser=this._with_init_parser.bind(this,B(z.mark(function e(){var r;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(n.char_ready()){t.next=5;break}t.next=3;return n._read();case 3:r=t.sent;i=new Li(r,{env:n});case 5:return t.abrupt("return",n.__parser__);case 6:case"end":return t.stop()}}},e)})));this.char_ready=function(){return!!this.__parser__&&this.__parser__.__lexer__.peek()!==Fo};this._make_defaults()}ho.prototype._make_defaults=function(){this.read=this._with_parser(function(e){return e.read_object()});this.read_line=this._with_parser(function(e){return e.__lexer__.read_line()});this.read_char=this._with_parser(function(e){return e.__lexer__.read_char()});this.read_string=this._with_parser(function(e,t){if(!C.isInteger(t)){var r=C.getType(t);Qo("read-string",r,"integer")}return e.__lexer__.read_string(t.valueOf())});this.peek_char=this._with_parser(function(e){return e.__lexer__.peek_char()})};ho.prototype._with_init_parser=function(o,s){var c=this;return B(z.mark(function e(){var r,n,i,u,a=arguments;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:t.next=2;return o.call(c);case 2:r=t.sent;for(n=a.length,i=new Array(n),u=0;u"};function po(e){if(typeof this!=="undefined"&&!(this instanceof po)||typeof this==="undefined"){return new po(e)}h("OutputPort",e,"function");$i(this,"__type__",xo);this.write=e}po.prototype.is_open=function(){return this._closed!==true};po.prototype.close=function(){Object.defineProperty(this,"_closed",{get:function e(){return true},set:function e(){},configurable:false,enumerable:false});this.write=function(){throw new Error("output-port: port is closed")}};po.prototype.flush=function(){};po.prototype.toString=function(){return"#"};var _o=function(e){u(n,e);var r=fn(n);function n(e){var t;D(this,n);t=r.call(this,function(){var e;return(e=t)._write.apply(e,arguments)});h("BufferedOutputPort",e,"function");$i(i(t),"_fn",e,{hidden:true});$i(i(t),"_buffer",[],{hidden:true});return t}A(n,[{key:"flush",value:function e(){if(this._buffer.length){this._fn(this._buffer.join(""));this._buffer.length=0}}},{key:"_write",value:function e(){var t=this;for(var r=arguments.length,n=new Array(r),i=0;i"};vo.prototype.valueOf=function(){return this.__buffer__.map(function(e){return e.valueOf()}).join("")};function yo(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof yo)||typeof this==="undefined"){return new yo(e,t)}h("OutputFilePort",e,"string");$i(this,"__filename__",e);$i(this,"_fd",t.valueOf(),{hidden:true});$i(this,"__type__",xo);this.write=function(e){if(!$a.isString(e)){e=Pu(e)}else{e=e.valueOf()}r.fs().write(r._fd,e,function(e){if(e){throw e}})}}yo.prototype=Object.create(po.prototype);yo.prototype.constructor=yo;yo.prototype.fs=function(){if(!this._fs){this._fs=this.internal("fs")}return this._fs};yo.prototype.internal=function(e){return Yo.get("**internal-env**").get(e)};yo.prototype.close=function(){var n=this;return new Promise(function(t,r){n.fs().close(n._fd,function(e){if(e){r(e)}else{$i(n,"_fd",null,{hidden:true});po.prototype.close.call(n);t()}})})};yo.prototype.toString=function(){return"#")};function mo(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof mo)||typeof this==="undefined"){return new mo(e)}h("InputStringPort",e,"string");t=t||qo;e=e.valueOf();this._with_parser=this._with_init_parser.bind(this,function(){if(!r.__parser__){r.__parser__=new Li(e,{env:t})}return r.__parser__});$i(this,"__type__",xo);this._make_defaults()}mo.prototype.char_ready=function(){return true};mo.prototype=Object.create(ho.prototype);mo.prototype.constructor=mo;mo.prototype.toString=function(){return"#"};function go(e){if(typeof this!=="undefined"&&!(this instanceof go)||typeof this==="undefined"){return new go(e)}h("InputByteVectorPort",e,"uint8array");$i(this,"__vector__",e);$i(this,"__type__",Ao);var r=0;Object.defineProperty(this,"__index__",{enumerable:true,get:function e(){return r},set:function e(t){h("InputByteVectorPort::__index__",t,"number");if(t instanceof C){t=t.valueOf()}if(typeof t==="bigint"){t=Number(t)}if(Math.floor(t)!==t){throw new Error("InputByteVectorPort::__index__ value is "+"not integer")}r=t}})}go.prototype=Object.create(ho.prototype);go.prototype.constructor=go;go.prototype.toString=function(){return"#"};go.prototype.close=function(){var t=this;$i(this,"__vector__",U);["read_u8","close","peek_u8","read_u8_vector"].forEach(function(e){t[e]=function(){throw new Error("Input-binary-port: port is closed")}});this.char_ready=function(){return false}};go.prototype.u8_ready=function(){return true};go.prototype.peek_u8=function(){if(this.__index__>=this.__vector__.length){return Fo}return this.__vector__[this.__index__]};go.prototype.skip=function(){if(this.__index__<=this.__vector__.length){++this.__index__}};go.prototype.read_u8=function(){var e=this.peek_u8();this.skip();return e};go.prototype.read_u8_vector=function(e){if(typeof e==="undefined"){e=this.__vector__.length}else if(e>this.__index__+this.__vector__.length){e=this.__index__+this.__vector__.length}if(this.peek_u8()===Fo){return Fo}return this.__vector__.slice(this.__index__,e)};function bo(){if(typeof this!=="undefined"&&!(this instanceof bo)||typeof this==="undefined"){return new bo}$i(this,"__type__",Ao);$i(this,"_buffer",[],{hidden:true});this.write=function(e){h("write",e,["number","uint8array"]);if(C.isNumber(e)){this._buffer.push(e.valueOf())}else{var t;(t=this._buffer).push.apply(t,q(Array.from(e)))}};Object.defineProperty(this,"__buffer__",{enumerable:true,get:function e(){return Uint8Array.from(this._buffer)}})}bo.prototype=Object.create(po.prototype);bo.prototype.constructor=bo;bo.prototype.close=function(){po.prototype.close.call(this);$i(this,"_buffer",null,{hidden:true})};bo.prototype._close_guard=function(){if(this._closed){throw new Error("output-port: binary port is closed")}};bo.prototype.write_u8=function(e){h("OutputByteVectorPort::write_u8",e,"number");this.write(e)};bo.prototype.write_u8_vector=function(e){h("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};bo.prototype.toString=function(){return"#"};bo.prototype.valueOf=function(){return this.__buffer__};function wo(e,t){if(typeof this!=="undefined"&&!(this instanceof wo)||typeof this==="undefined"){return new wo(e,t)}mo.call(this,e);h("InputFilePort",t,"string");$i(this,"__filename__",t)}wo.prototype=Object.create(mo.prototype);wo.prototype.constructor=wo;wo.prototype.toString=function(){return"#")};function Do(e,t){if(typeof this!=="undefined"&&!(this instanceof Do)||typeof this==="undefined"){return new Do(e,t)}go.call(this,e);h("InputBinaryFilePort",t,"string");$i(this,"__filename__",t)}Do.prototype=Object.create(go.prototype);Do.prototype.constructor=Do;Do.prototype.toString=function(){return"#")};function Eo(e,t){if(typeof this!=="undefined"&&!(this instanceof Eo)||typeof this==="undefined"){return new Eo(e,t)}h("OutputBinaryFilePort",e,"string");$i(this,"__filename__",e);$i(this,"_fd",t.valueOf(),{hidden:true});$i(this,"__type__",Ao);var u,r;this.write=function(e){var n=this;h("write",e,["number","uint8array"]);var i;if(!u){u=this.internal("fs")}if(!r){r=this.internal("Buffer")}if(C.isNumber(e)){i=r.from([e.valueOf()])}else{i=r.from(Array.from(e))}return new Promise(function(t,r){u.write(n._fd,i,function(e){if(e){r(e)}else{t()}})})}}Eo.prototype=Object.create(yo.prototype);Eo.prototype.constructor=Eo;Eo.prototype.write_u8=function(e){h("OutputByteVectorPort::write_u8",e,"number");this.write(e)};Eo.prototype.write_u8_vector=function(e){h("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};var Ao=Symbol["for"]("binary");var xo=Symbol["for"]("text");var Fo=new ko;function ko(){}ko.prototype.toString=function(){return"#"};function Co(e){var c=this;var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=t.stderr,n=t.stdin,i=t.stdout,u=t.command_line,a=u===void 0?null:u,o=F(t,cn);if(typeof this!=="undefined"&&!(this instanceof Co)||typeof this==="undefined"){return new Co(e,vn({stdin:n,stdout:i,stderr:r,command_line:a},o))}if(typeof e==="undefined"){e="anonymous"}this.__env__=Yo.inherit(e,o);this.__env__.set("parent.frame",y("parent.frame",function(){return c.__env__},qo.__env__["parent.frame"].__doc__));var f="**interaction-environment-defaults**";this.set(f,Ou(o).concat(f));var s=Lo.inherit("internal-".concat(e));if(pa(n)){s.set("stdin",n)}if(pa(r)){s.set("stderr",r)}if(pa(i)){s.set("stdout",i)}s.set("command-line",a);Vo(this.__env__,s)}Co.prototype.exec=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;h("Interpreter::exec",e,["string","array"],1);h("Interpreter::exec",t,"boolean",2);qo.set("**interaction-environment**",this.__env__);if(r===null){r=this.__env__}return vs(e,r,t?r:false)};Co.prototype.get=function(e){var t=this.__env__.get(e);if(Xu(t)){return t.bind(this.__env__)}return t};Co.prototype.set=function(e,t){return this.__env__.set(e,t)};Co.prototype.constant=function(e,t){return this.__env__.constant(e,t)};function Oo(e,t){this.name="LipsError";this.message=e;this.args=t;this.stack=(new Error).stack}Oo.prototype=new Error;Oo.prototype.constructor=Oo;function So(e,t,r){if(arguments.length===1){if(_(arguments[0])==="object"){e=arguments[0];t=null}else if(typeof arguments[0]==="string"){e={};t=null;r=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=t;this.__name__=r||"anonymous"}So.prototype.list=function(){return Ou(this.__env__)};So.prototype.fs=function(){return this.get("**fs**")};So.prototype.unset=function(e){if(e instanceof L){e=e.valueOf()}if(e instanceof $a){e=e.valueOf()}delete this.__env__[e]};So.prototype.inherit=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(_(e)==="object"){t=e}if(!e||_(e)==="object"){e="child of "+(this.__name__||"unknown")}return new So(t||{},this,e)};So.prototype.doc=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;if(e instanceof L){e=e.__name__}if(e instanceof $a){e=e.valueOf()}if(t){if(!r){t=Hi(t)}this.__docs__.set(e,t);return this}if(this.__docs__.has(e)){return this.__docs__.get(e)}if(this.__parent__){return this.__parent__.doc(e)}};So.prototype.newFrame=function(e,t){var n=this.inherit("__frame__");n.set("parent.frame",y("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:1;e=e.valueOf();var t=n.__parent__;if(!(t instanceof So)){return U}if(e<=0){return t}var r=t.get("parent.frame");return r(e-1)},qo.__env__["parent.frame"].__doc__));t.callee=e;n.set("arguments",t);return n};So.prototype._lookup=function(e){if(e instanceof L){e=e.__name__}if(e instanceof $a){e=e.valueOf()}if(this.__env__.hasOwnProperty(e)){return Bo(this.__env__[e])}if(this.__parent__){return this.__parent__._lookup(e)}};So.prototype.toString=function(){return"#"};So.prototype.clone=function(){var t=this;var r={};Object.keys(this.__env__).forEach(function(e){r[e]=t.__env__[e]});return new So(r,this.__parent__,this.__name__)};So.prototype.merge=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"merge";h("Environment::merge",e,"environment");return this.inherit(t,e.__env__)};function Bo(e){if(typeof this!=="undefined"&&!(this instanceof Bo)||typeof this==="undefined"){return new Bo(e)}this.value=e}Bo.isUndefined=function(e){return e instanceof Bo&&typeof e.value==="undefined"};Bo.prototype.valueOf=function(){return this.value};function jo(e){if(e.length){if(e.length===1){return e[0]}}if(typeof this!=="undefined"&&!(this instanceof jo)||typeof this==="undefined"){return new jo(e)}this.__values__=e}jo.prototype.toString=function(){return this.__values__.map(function(e){return Pu(e)}).join("\n")};jo.prototype.valueOf=function(){return this.__values__};So.prototype.get=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};h("Environment::get",e,["symbol","string"]);var r=t.throwError,c=r===void 0?true:r;var n=e;if(n instanceof L||n instanceof $a){n=n.valueOf()}var i=this._lookup(n);if(i instanceof Bo){if(Bo.isUndefined(i)){return undefined}return oa(i.valueOf())}var u;if(e instanceof L&&e[L.object]){u=e[L.object]}else if(typeof n==="string"){u=n.split(".").filter(Boolean)}if(u&&u.length>0){var f=u,a=m(f),o=a[0],s=a.slice(1);i=this._lookup(o);if(s.length){try{if(i instanceof Bo){i=i.valueOf()}else{i=No(gn,o);if(Xu(i)){i=sa(i)}}if(typeof i!=="undefined"){return No.apply(void 0,[i].concat(q(s)))}}catch(e){throw e}}else if(i instanceof Bo){return oa(i.valueOf())}i=No(gn,n)}if(typeof i!=="undefined"){return i}if(c){throw new Error("Unbound variable `"+n.toString()+"'")}};So.prototype.set=function(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;h("Environment::set",e,["string","symbol"]);if(C.isNumber(t)){t=C(t)}if(e instanceof L){e=e.__name__}if(e instanceof $a){e=e.valueOf()}this.__env__[e]=t;if(r){this.doc(e,r,true)}return this};So.prototype.constant=function(t,e){var r=this;if(this.__env__.hasOwnProperty(t)){throw new Error("Environment::constant: ".concat(t," already exists"))}if(arguments.length===1&&wu(arguments[0])){var n=arguments[0];Object.keys(n).forEach(function(e){r.constant(t,n[e])})}else{Object.defineProperty(this.__env__,t,{value:e,enumerable:true})}return this};So.prototype.has=function(e){return this.__env__.hasOwnProperty(e)};So.prototype.ref=function(e){var t=this;while(true){if(!t){break}if(t.has(e)){return t}t=t.__parent__}};So.prototype.parents=function(){var e=this;var t=[];while(e){t.unshift(e);e=e.__parent__}return t};function Io(e){if(ra(e)){return e.then(Io)}if(e instanceof M||e instanceof L){e[ya]=true}return e}var Po=Mi(wi('(lambda ()\n "[native code]"\n (throw "Invalid Invocation"))'))[0];var No=y("get",function c(e){var t;for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=Ro(this,"stdin")}Xo("peek-char",e,"input-port");return e.peek_char()},"(peek-char port)\n\n This function reads and returns a character from the string\n port, or, if there is no more data in the string port, it\n returns an EOF."),"read-line":y("read-line",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=Ro(this,"stdin")}Xo("read-line",e,"input-port");return e.read_line()},"(read-line port)\n\n This function reads and returns the next line from the input\n port."),"read-char":y("read-char",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=Ro(this,"stdin")}Xo("read-char",e,"input-port");return e.read_char()},"(read-char port)\n\n This function reads and returns the next character from the\n input port."),read:y("read",function(){var e=B(z.mark(function e(){var r,n,i,u,a,o,s,c,f=arguments;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:r=f.length>0&&f[0]!==undefined?f[0]:null;if(!$a.isString(r)){t.next=30;break}n=false;i=false;t.prev=4;a=yn(Mi(r,this));case 6:t.next=8;return a.next();case 8:if(!(n=!(o=t.sent).done)){t.next=14;break}s=o.value;return t.abrupt("return",s);case 11:n=false;t.next=6;break;case 14:t.next=20;break;case 16:t.prev=16;t.t0=t["catch"](4);i=true;u=t.t0;case 20:t.prev=20;t.prev=21;if(!(n&&a["return"]!=null)){t.next=25;break}t.next=25;return a["return"]();case 25:t.prev=25;if(!i){t.next=28;break}throw u;case 28:return t.finish(25);case 29:return t.finish(20);case 30:if(r===null){c=Ro(this,"stdin")}else{c=r}Xo("read",c,"input-port");return t.abrupt("return",c.read.call(this));case 33:case"end":return t.stop()}}},e,this,[[4,16,20,30],[21,,25,29]])}));function t(){return e.apply(this,arguments)}return t}(),"(read [string])\n\n This function, if used with a string, will parse it and\n return the LIPS code, if there is any. If called with a\n port, it will parse the next item from the port. If called\n without an input, it will read a string from standard input\n (using the browser's prompt or a user defined input method)\n and calls itself with that string. This function can be used\n together with `eval` to evaluate code from a string."),pprint:y("pprint",function e(t){if(t instanceof M){t=new Gs.Formatter(t.toString(true))["break"]().format();qo.get("display").call(qo,t)}else{qo.get("write").call(qo,t)}qo.get("newline").call(qo)},"(pprint expression)\n\n This function will pretty print its input to stdout. If it is called\n with a non-list, it will just call the print function on its\n input."),print:y("print",function e(){var t=qo.get("display");var r=qo.get("newline");for(var n=arguments.length,i=new Array(n),u=0;u1?r-1:0),i=1;in.length){throw new Error("Not enough arguments")}var o=0;var s=qo.get("repr");t=t.replace(u,function(e){var t=e[1];if(t==="~"){return"~"}else if(t==="%"){return"\n"}else{var r=n[o++];if(t==="a"){return s(r)}else{return s(r,true)}}});a=t.match(/~([\S])/);if(a){throw new Error("format: Unrecognized escape sequence ".concat(a[1]))}return t},"(format string n1 n2 ...)\n\n This function accepts a string template and replaces any\n escape sequences in its inputs:\n\n * ~a value as if printed with `display`\n * ~s value as if printed with `write`\n * ~% newline character\n * ~~ literal tilde '~'\n\n If there are missing inputs or other escape characters it\n will error."),display:y("display",function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(r===null){r=Ro(this,"stdout")}else{h("display",r,"output-port")}var n=qo.get("repr")(t);r.write.call(qo,n)},"(display string [port])\n\n This function outputs the string to the standard output or\n the port if given. No newline."),"display-error":y("display-error",function e(){var t=Ro(this,"stderr");var r=qo.get("repr");for(var n=arguments.length,i=new Array(n),u=0;u1&&arguments[1]!==undefined?arguments[1]:{},r=t.dynamic_scope,n=t.error;if(r){r=this}var i=this;var u;var a=_s(e.cdr.car,{env:this,dynamic_scope:r,error:n});a=as(a);function o(t,r,n){if(ra(t)){return t.then(function(e){return o(t,e,n)})}if(ra(r)){return r.then(function(e){return o(t,e,n)})}if(ra(n)){return n.then(function(e){return o(t,r,e)})}i.get("set-obj!").call(i,t,r,n);return n}if(e.car instanceof M&&L.is(e.car.car,".")){var f=e.car.cdr.car;var l=e.car.cdr.cdr.car;var h=_s(f,{env:this,dynamic_scope:r,error:n});var p=_s(l,{env:this,dynamic_scope:r,error:n});return o(h,p,a)}if(!(e.car instanceof L)){throw new Error("set! first argument need to be a symbol or "+"dot accessor that evaluate to object.")}var s=e.car.valueOf();u=this.ref(e.car.__name__);return Yi(a,function(e){if(!u){var t=s.split(".");if(t.length>1){var r=t.pop();var n=t.join(".");var i=c.get(n,{throwError:false});if(i){o(i,r,e);return}}throw new Error("Unbound variable `"+s+"'")}u.set(s,e)})}),"(set! name value)\n\n Macro that can be used to set the value of the variable or slot (mutate it).\n set! searches the scope chain until it finds first non empty slot and sets it."),"unset!":y(new Vu("set!",function(e){if(!(e.car instanceof L)){throw new Error("unset! first argument need to be a symbol or "+"dot accessor that evaluate to object.")}var t=e.car;var r=this.ref(t);if(r){delete r.__env__[t.__name__]}}),"(unset! name)\n\n Function to delete the specified name from environment.\n Trying to access the name afterwards will error."),"set-car!":y("set-car!",function(e,t){h("set-car!",e,"pair");e.car=t},"(set-car! obj value)\n\n Function that sets the car (first item) of the list/pair to specified value.\n The old value is lost."),"set-cdr!":y("set-cdr!",function(e,t){h("set-cdr!",e,"pair");e.cdr=t},"(set-cdr! obj value)\n\n Function that sets the cdr (tail) of the list/pair to specified value.\n It will destroy the list. The old tail is lost."),"empty?":y("empty?",function(e){return typeof e==="undefined"||e===U},"(empty? object)\n\n Function that returns #t if value is nil (an empty list) or undefined."),gensym:y("gensym",Fi,"(gensym)\n\n Generates a unique symbol that is not bound anywhere,\n to use with macros as meta name."),load:y("load",function e(o,t){h("load",o,"string");var s=this;if(s.__name__==="__frame__"){s=s.__parent__}if(!(t instanceof So)){if(s===qo){t=s}else{t=this.get("**interaction-environment**")}}var c="**module-path**";var f=qo.get(c,{throwError:false});o=o.valueOf();if(!o.match(/.[^.]+$/)){o+=".scm"}var r=o.match(/\.xcb$/);function l(e){if(r){e=Vs(e)}else{if(us(e)==="buffer"){e=e.toString()}e=e.replace(/^#!.*/,"");if(e.match(/^\{/)){e=Rs(e)}}return vs(e,t)}function n(e){return gn.fetch(e).then(function(e){return r?e.arrayBuffer():e.text()}).then(function(e){if(r){e=new Uint8Array(e)}return e})}if(Go()){return new Promise(function(){var r=B(z.mark(function e(r,n){var i,u,a;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:i=An("path");if(!f){t.next=6;break}f=f.valueOf();o=i.join(f,o);t.next=12;break;case 6:u=s.get("command-line",{throwError:false});if(!u){t.next=11;break}t.next=10;return u();case 10:a=t.sent;case 11:if(a&&a!==U){process.cwd();o=i.join(i.dirname(a.car.valueOf()),o)}case 12:qo.set(c,i.dirname(o));An("fs").readFile(o,function(e,t){if(e){n(e);qo.set(c,f)}else{try{l(t).then(function(){r();qo.set(c,f)})["catch"](n)}catch(e){n(e)}}});case 14:case"end":return t.stop()}}},e)}));return function(e,t){return r.apply(this,arguments)}}())}if(f){f=f.valueOf();o=f+"/"+o.replace(/^\.?\/?/,"")}return n(o).then(function(e){qo.set(c,o.replace(/\/[^/]*$/,""));return l(e)}).then(function(){})["finally"](function(){qo.set(c,f)})},"(load filename)\n (load filename environment)\n\n Fetches the file (from disk or network) and evaluates its content as LIPS code.\n If the second argument is provided and it's an environment the evaluation\n will happen in that environment."),do:y(new Vu("do",function(){var r=B(z.mark(function e(r,h){var n,i,u,o,s,a,c,f,l,p,_;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:n=h.dynamic_scope,i=h.error;u=this;if(n){n=u}o=u.inherit("do");s=r.car;a=r.cdr.car;c=r.cdr.cdr;if(c!==U){c=new M(L("begin"),c)}f={env:u,dynamic_scope:n,error:i};l=s;case 10:if(!(l!==U)){t.next=21;break}p=l.car;t.t0=o;t.t1=p.car;t.next=16;return _s(p.cdr.car,f);case 16:t.t2=t.sent;t.t0.set.call(t.t0,t.t1,t.t2);l=l.cdr;t.next=10;break;case 21:f={env:o,dynamic_scope:n,error:i};_=z.mark(function e(){var r,n,i,u,a;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!(c!==U)){t.next=3;break}t.next=3;return Gs.evaluate(c,f);case 3:r=s;n={};case 5:if(!(r!==U)){t.next=15;break}i=r.car;if(!(i.cdr.cdr!==U)){t.next=12;break}t.next=10;return _s(i.cdr.cdr.car,f);case 10:u=t.sent;n[i.car.valueOf()]=u;case 12:r=r.cdr;t.next=5;break;case 15:a=Object.getOwnPropertySymbols(n);Object.keys(n).concat(a).forEach(function(e){o.set(e,n[e])});case 17:case"end":return t.stop()}}},e)});case 23:t.next=25;return _s(a.car,f);case 25:t.t3=t.sent;if(!(t.t3===false)){t.next=30;break}return t.delegateYield(_(),"t4",28);case 28:t.next=23;break;case 30:if(!(a.cdr!==U)){t.next=34;break}t.next=33;return _s(a.cdr.car,f);case 33:return t.abrupt("return",t.sent);case 34:case"end":return t.stop()}}},e,this)}));return function(e,t){return r.apply(this,arguments)}}()),"(do (( )) (test return) . body)\n\n Iteration macro that evaluates the expression body in scope of the variables.\n On each loop it changes the variables according to the expression and runs\n test to check if the loop should continue. If test is a single value, the macro\n will return undefined. If the test is a pair of expressions the macro will\n evaluate and return the second expression after the loop exits."),if:y(new Vu("if",function(r,e){var n=e.dynamic_scope,i=e.error;if(n){n=this}var u=this;var t=function e(t){if(t===false){return _s(r.cdr.cdr.car,{env:u,dynamic_scope:n,error:i})}else{return _s(r.cdr.car,{env:u,dynamic_scope:n,error:i})}};if(r===U){throw new Error("too few expressions for `if`")}var a=_s(r.car,{env:u,dynamic_scope:n,error:i});return Yi(a,t)}),"(if cond true-expr false-expr)\n\n Macro that evaluates cond expression and if the value is true, it\n evaluates and returns true-expression, if not it evaluates and returns\n false-expression."),"let-env":new Vu("let-env",function(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=e.dynamic_scope,n=e.error;h("let-env",t,"pair");var i=_s(t.car,{env:this,dynamic_scope:r,error:n});return Yi(i,function(e){h("let-env",e,"environment");return _s(M(L("begin"),t.cdr),{env:e,dynamic_scope:r,error:n})})},"(let-env env . body)\n\n Special macro that evaluates body in context of given environment\n object."),letrec:y(ja(Symbol["for"]("letrec")),"(letrec ((a value-a) (b value-b) ...) . body)\n\n Macro that creates a new environment, then evaluates and assigns values to\n names and then evaluates the body in context of that environment.\n Values are evaluated sequentially and the next value can access the\n previous values/names."),"letrec*":y(ja(Symbol["for"]("letrec")),"(letrec* ((a value-a) (b value-b) ...) . body)\n\n Same as letrec but the order of execution of the binding is guaranteed,\n so you can use recursive code as well as referencing the previous binding.\n\n In LIPS both letrec and letrec* behave the same."),"let*":y(ja(Symbol["for"]("let*")),"(let* ((a value-a) (b value-b) ...) . body)\n\n Macro similar to `let`, but the subsequent bindings after the first\n are evaluated in the environment including the previous let variables,\n so you can define one variable, and use it in the next's definition."),let:y(ja(Symbol["for"]("let")),"(let ((a value-a) (b value-b) ...) . body)\n\n Macro that creates a new environment, then evaluates and assigns values to names,\n and then evaluates the body in context of that environment. Values are evaluated\n sequentially but you can't access previous values/names when the next are\n evaluated. You can only get them in the body of the let expression. (If you want\n to define multiple variables and use them in each other's definitions, use\n `let*`.)"),"begin*":y(Ia("begin*",function(e){return e.pop()}),"(begin* . body)\n\n This macro is a parallel version of begin. It evaluates each expression\n in the body and if it's a promise it will await it in parallel and return\n the value of the last expression (i.e. it uses Promise.all())."),begin:y(new Vu("begin",function(e,t){var n=Object.assign({},t);var i=qo.get("list->array")(e);if(n.dynamic_scope){n.dynamic_scope=this}n.env=this;var u;return function t(){if(i.length){var e=i.shift();var r=_s(e,n);return Yi(r,function(e){u=e;return t()})}else{return u}}()}),"(begin . args)\n\n Macro that runs a list of expressions in order and returns the value\n of the last one. It can be used in places where you can only have a\n single expression, like (if)."),ignore:new Vu("ignore",function(e,t){var r=t.dynamic_scope,n=t.error;var i={env:this,error:n};if(r){i.dynamic_scope=this}_s(new M(new L("begin"),e),i)},"(ignore . body)\n\n Macro that will evaluate the expression and swallow any promises that may\n be created. It will discard any value that may be returned by the last body\n expression. The code should have side effects and/or when it's promise\n it should resolve to undefined."),"call/cc":y(Vu.defmacro("call/cc",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=vn({env:this},t);return Yi(_s(e.car,r),function(e){if(Xu(e)){return e(new hs(null))}})}),"(call/cc proc)\n\n Call-with-current-continuation.\n\n NOT SUPPORTED BY LIPS RIGHT NOW"),define:y(Vu.defmacro("define",function(r,e){var n=this;if(r.car instanceof M&&r.car.car instanceof L){var t=new M(new L("define"),new M(r.car.car,new M(new M(new L("lambda"),new M(r.car.cdr,r.cdr)))));return t}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=n;var i=r.cdr.car;var u;if(i instanceof M){i=_s(i,e);u=true}else if(i instanceof L){i=n.get(i)}h("define",r.car,"symbol");return Yi(i,function(e){if(n.__name__===Ku.__merge_env__){n=n.__parent__}if(u&&(Xu(e)&&Ca(e)||e instanceof Ku)){e.__name__=r.car.valueOf();if(e.__name__ instanceof $a){e.__name__=e.__name__.valueOf()}}var t;if(r.cdr.cdr instanceof M&&$a.isString(r.cdr.cdr.car)){t=r.cdr.cdr.car.valueOf()}n.set(r.car,e,t,true)})}),'(define name expression)\n (define name expression "doc string")\n (define (function-name . args) . body)\n\n Macro for defining values. It can be used to define variables,\n or functions. If the first argument is list it will create a function\n with name being first element of the list. This form expands to\n `(define function-name (lambda args body))`'),"set-obj!":y("set-obj!",function(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var i=_(e);if(Zu(e)||i!=="object"&&i!=="function"){var u=Qo("set-obj!",us(e),["object","function"]);throw new Error(u)}h("set-obj!",t,["string","symbol","number"]);e=sa(e);t=t.valueOf();if(arguments.length===2){delete e[t]}else if(Nu(e)&&Xu(r)){e[t]=sa(r);e[t][Da]=true}else if(Xu(r)||ts(r)||r===U){e[t]=r}else{e[t]=r&&!Nu(r)?r.valueOf():r}if(Du){var a=e[t];Object.defineProperty(e,t,vn(vn({},n),{},{value:a}))}},"(set-obj! obj key value)\n (set-obj! obj key value props)\n\n Function set a property of a JavaScript object. props should be a vector of pairs,\n passed to Object.defineProperty."),"null-environment":y("null-environment",function(){return qo.inherit("null")},"(null-environment)\n\n Returns a clean environment with only the standard library."),values:y("values",function e(){for(var t=arguments.length,r=new Array(t),n=0;n1&&arguments[1]!==undefined?arguments[1]:{},h=e.dynamic_scope,p=e.error;var _=this;var d;if(l.cdr instanceof M&&$a.isString(l.cdr.car)&&l.cdr.cdr!==U){d=l.cdr.car.valueOf()}function v(){var e;if(h){if(!(this instanceof So)){e=_}else{e=this}}else{e=_}e=e.inherit("lambda");var t=l.car;var r=0;var n;if(typeof this!=="undefined"&&!(this instanceof So)){if(this&&!this.__instance__){Object.defineProperty(this,"__instance__",{enumerable:false,get:function e(){return true},set:function e(){},configurable:false})}e.set("this",this)}for(var i=arguments.length,u=new Array(i),a=0;a>> "+c.toString());if(c){o=c}var d=r.merge(t,Ku.__merge_env__);if(l){return{expr:o,scope:d}}var v=_s(o,vn(vn({},p),{},{env:d}));return Wu(v,_)}i=i.cdr}}catch(e){e.message+=" in macro: ".concat(y.toString(true));throw e}throw new Error("Invalid Syntax ".concat(e.toString(true)))},b);r.__code__=y;return r},"(syntax-rules () (pattern expression) ...)\n\n Base of hygienic macros, it will return a new syntax expander\n that works like Lisp macros."),quote:y(new Vu("quote",function(e){return Io(e.car)}),"(quote expression) or 'expression\n\n Macro that returns a single LIPS expression as data (it won't evaluate the\n argument). It will return a list if put in front of LIPS code.\n And if put in front of a symbol it will return the symbol itself, not the value\n bound to that name."),"unquote-splicing":y("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code) or ,@code\n\n Special form used in the quasiquote macro. It evaluates the expression inside and\n splices the list into quasiquote's result. If it is not the last element of the\n expression, the computed value must be a pair."),unquote:y("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code) or ,code\n\n Special form used in the quasiquote macro. It evaluates the expression inside and\n substitutes the value into quasiquote's result."),quasiquote:Vu.defmacro("quasiquote",function(e,t){var o=t.dynamic_scope,s=t.error;var c=this;if(o){o=c}function a(e){return e instanceof M||wu(e)||Array.isArray(e)}function h(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:a;if(e instanceof M){var n=e.car;var i=e.cdr;if(r(n)){n=t(n)}if(r(i)){i=t(i)}if(ra(n)||ra(i)){return Ci([n,i]).then(function(e){var t=j(e,2),r=t[0],n=t[1];return new M(r,n)})}else{return new M(n,i)}}return e}function u(e,t){if(e instanceof M){if(t!==U){e.append(t)}}else{e=new M(e,t)}return e}function r(e){return!!e.filter(function(e){return e instanceof M&&L.is(e.car,/^(unquote|unquote-splicing)$/)}).length}function p(e,n,i){return e.reduce(function(e,t){if(!(t instanceof M)){e.push(t);return e}if(L.is(t.car,"unquote-splicing")){var r;if(n+11){var t="You can't splice multiple atoms inside list";throw new Error(t)}if(!(i.cdr instanceof M&&r[0]===U)){return r[0]}}r=r.map(function(e){if(d.has(e)){return e.clone()}else{d.add(e);return e}});var n=l(i.cdr,0,1);if(n===U&&r[0]===U){return undefined}return Yi(n,function(e){if(r[0]===U){return e}if(r.length===1){return u(r[0],e)}var t=r.reduce(function(e,t){return u(e,t)});return u(t,e)})})}(i.car.cdr)}var d=new Set;function l(e,t,r){if(e instanceof M){if(e.car instanceof M){if(L.is(e.car.car,"unquote-splicing")){return f(e,t+1,r)}if(L.is(e.car.car,"unquote")){if(t+2===r&&e.car.cdr instanceof M&&e.car.cdr.car instanceof M&&L.is(e.car.cdr.car.car,"unquote-splicing")){var n=e.car.cdr;return new M(new M(new L("unquote"),f(n,t+2,r)),U)}else if(e.car.cdr instanceof M&&e.car.cdr.cdr!==U){if(e.car.cdr.car instanceof M){var i=[];return function t(r){if(r===U){return M.fromArray(i)}return Yi(_s(r.car,{env:c,dynamic_scope:o,error:s}),function(e){i.push(e);return t(r.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}}if(L.is(e.car,"quasiquote")){var u=l(e.cdr,t,r+1);return new M(e.car,u)}if(L.is(e.car,"quote")){return new M(e.car,l(e.cdr,t,r))}if(L.is(e.car,"unquote")){t++;if(tr){throw new Error("You can't call `unquote` outside "+"of quasiquote")}if(e.cdr instanceof M){if(e.cdr.cdr!==U){if(e.cdr.car instanceof M){var a=[];return function t(r){if(r===U){return M.fromArray(a)}return Yi(_s(r.car,{env:c,dynamic_scope:o,error:s}),function(e){a.push(e);return t(r.cdr)})}(e.cdr)}else{return e.cdr}}else{return _s(e.cdr.car,{env:c,dynamic_scope:o,error:s})}}else{return e.cdr}}return h(e,function(e){return l(e,t,r)})}else if(wu(e)){return _(e,t,r)}else if(e instanceof Array){return p(e,t,r)}return e}function n(e){if(e instanceof M){delete e[ya];if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}}if(wu(e.car)&&!r(Object.values(e.car))){return Io(e.car)}if(Array.isArray(e.car)&&!r(e.car)){return Io(e.car)}if(e.car instanceof M&&!e.car.find("unquote")&&!e.car.find("unquote-splicing")&&!e.car.find("quasiquote")){return Io(e.car)}var i=l(e.car,0,1);return Yi(i,function(e){n(e);return Io(e)})},"(quasiquote list)\n\n Similar macro to `quote` but inside it you can use special expressions (unquote\n x) abbreviated to ,x that will evaluate x and insert its value verbatim or\n (unquote-splicing x) abbreviated to ,@x that will evaluate x and splice the value\n into the result. Best used with macros but it can be used outside."),clone:y("clone",function e(t){h("clone",t,"pair");return t.clone()},"(clone list)\n\n Function that returns a clone of the list, that does not share any pairs with the\n original, so the clone can be safely mutated without affecting the original."),append:y("append",function e(){var t;for(var r=arguments.length,n=new Array(r),i=0;iarray")(t).reverse();return qo.get("array->list")(r)}else if(!(t instanceof Array)){throw new Error(Qo("reverse",us(t),"array or pair"))}else{return t.reverse()}},"(reverse list)\n\n Function that reverses the list or array. If value is not a list\n or array it will error."),nth:y("nth",function e(t,r){h("nth",t,"number");h("nth",r,["array","pair"]);if(r instanceof M){var n=r;var i=0;while(iarray")(r).join(t)},"(join separator list)\n\n Function that returns a string by joining elements of the list using separator."),split:y("split",function e(t,r){h("split",t,["regex","string"]);h("split",r,"string");return qo.get("array->list")(r.split(t))},"(split separator string)\n\n Function that creates a list by splitting string by separator which can\n be a string or regular expression."),replace:y("replace",function e(t,r,n){h("replace",t,["regex","string"]);h("replace",r,["string","function"]);h("replace",n,"string");return n.replace(t,r)},"(replace pattern replacement string)\n\n Function that changes pattern to replacement inside string. Pattern can be a\n string or regex and replacement can be function or string. See Javascript\n String.replace()."),match:y("match",function e(t,r){h("match",t,["regex","string"]);h("match",r,"string");var n=r.match(t);return n?qo.get("array->list")(n):false},"(match pattern string)\n\n Function that returns a match object from JavaScript as a list or #f if\n no match."),search:y("search",function e(t,r){h("search",t,["regex","string"]);h("search",r,"string");return r.search(t)},"(search pattern string)\n\n Function that returns the first found index of the pattern inside a string."),repr:y("repr",function e(t,r){return Pu(t,r)},"(repr obj)\n\n Function that returns a LIPS code representation of the object as a string."),"escape-regex":y("escape-regex",function(e){h("escape-regex",e,"string");return _i(e.valueOf())},"(escape-regex string)\n\n Function that returns a new string where all special operators used in regex,\n are escaped with backslashes so they can be used in the RegExp constructor\n to match a literal string."),env:y("env",function e(e){e=e||this;var t=Object.keys(e.__env__).map(L);var r;if(t.length){r=M.fromArray(t)}else{r=U}if(e.__parent__ instanceof So){return qo.get("env")(e.__parent__).append(r)}return r},"(env)\n (env obj)\n\n Function that returns a list of names (functions, macros and variables)\n that are bound in the current environment or one of its parents."),new:y("new",function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n2&&arguments[2]!==undefined?arguments[2]:Bi.LITERAL;h("set-special!",e,"string",1);h("set-special!",t,"symbol",2);Bi.append(e.valueOf(),t,r)},'(set-special! symbol name [type])\n\n Add a special symbol to the list of transforming operators by the parser.\n e.g.: `(add-special! "#" \'x)` will allow to use `#(1 2 3)` and it will be\n transformed into (x (1 2 3)) so you can write x macro that will process\n the list. 3rd argument is optional, and it can be one of two values:\n lips.specials.LITERAL, which is the default behavior, or\n lips.specials.SPLICE which causes the value to be unpacked into the expression.\n This can be used for e.g. to make `#(1 2 3)` into (x 1 2 3) that is needed\n by # that defines vectors.'),get:No,".":No,unbind:y(sa,"(unbind fn)\n\n Function that removes the weak 'this' binding from a function so you\n can get properties from the actual function object."),type:y(us,"(type object)\n\n Function that returns the type of an object as string."),debugger:y("debugger",function(){debugger},'(debugger)\n\n Function that triggers the JavaScript debugger (e.g. the browser devtools)\n using the "debugger;" statement. If a debugger is not running this\n function does nothing.'),in:y("in",function(e,t){if(e instanceof L||e instanceof $a||e instanceof C){e=e.valueOf()}return e in aa(t)},'(in key value)\n\n Function that uses the Javascript "in" operator to check if key is\n a valid property in the value.'),instanceof:y("instanceof",function(e,t){return t instanceof sa(e)},"(instanceof type obj)\n\n Predicate that tests if the obj is an instance of type."),"prototype?":y("prototype?",Nu,"(prototype? obj)\n\n Predicate that tests if value is a valid JavaScript prototype,\n i.e. calling (new) with it will not throw ' is not a constructor'."),"macro?":y("macro?",function(e){return e instanceof Vu},"(macro? expression)\n\n Predicate that tests if value is a macro."),"function?":y("function?",Xu,"(function? expression)\n\n Predicate that tests if value is a callable function."),"real?":y("real?",function(e){if(us(e)!=="number"){return false}if(e instanceof C){return e.isFloat()}return C.isFloat(e)},"(real? number)\n\n Predicate that tests if value is a real number (not complex)."),"number?":y("number?",function(e){return Number.isNaN(e)||C.isNumber(e)},"(number? expression)\n\n Predicate that tests if value is a number or NaN value."),"string?":y("string?",function(e){return $a.isString(e)},"(string? expression)\n\n Predicate that tests if value is a string."),"pair?":y("pair?",function(e){return e instanceof M},"(pair? expression)\n\n Predicate that tests if value is a pair or list structure."),"regex?":y("regex?",function(e){return e instanceof RegExp},"(regex? expression)\n\n Predicate that tests if value is a regular expression."),"null?":y("null?",function(e){return Zu(e)},"(null? expression)\n\n Predicate that tests if value is null-ish (i.e. undefined, nil, or\n Javascript null)."),"boolean?":y("boolean?",function(e){return typeof e==="boolean"},"(boolean? expression)\n\n Predicate that tests if value is a boolean (#t or #f)."),"symbol?":y("symbol?",function(e){return e instanceof L},"(symbol? expression)\n\n Predicate that tests if value is a LIPS symbol."),"array?":y("array?",function(e){return e instanceof Array},"(array? expression)\n\n Predicate that tests if value is an array."),"object?":y("object?",function(e){return e!==U&&e!==null&&!(e instanceof za)&&!(e instanceof RegExp)&&!(e instanceof $a)&&!(e instanceof M)&&!(e instanceof C)&&_(e)==="object"&&!(e instanceof Array)},"(object? expression)\n\n Predicate that tests if value is an plain object (not another LIPS type)."),flatten:y("flatten",function e(t){h("flatten",t,"pair");return t.flatten()},"(flatten list)\n\n Returns a shallow list from tree structure (pairs)."),"array->list":y("array->list",function(e){h("array->list",e,"array");return M.fromArray(e)},"(array->list array)\n\n Function that converts a JavaScript array to a LIPS cons list."),"tree->array":y("tree->array",gu("tree->array",true),"(tree->array list)\n\n Function that converts a LIPS cons tree structure into a JavaScript array."),"list->array":y("list->array",gu("list->array"),"(list->array list)\n\n Function that converts a LIPS list into a JavaScript array."),apply:y("apply",function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;iarray").call(this,u));return t.apply(this,fs(t,n))},"(apply fn list)\n\n Function that calls fn with the list of arguments."),length:y("length",function e(t){if(!t||t===U){return 0}if(t instanceof M){return t.length()}if("length"in t){return t.length}},'(length expression)\n\n Function that returns the length of the object. The object can be a LIPS\n list or any object that has a "length" property. Returns undefined if the\n length could not be found.'),"string->number":y("string->number",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;h("string->number",e,"string",1);h("string->number",t,"number",2);e=e.valueOf();t=t.valueOf();if(e.match(Wn)||e.match(Kn)){return ti(e,t)}else if(e.match(Qn)||e.match(Jn)){return ii(e,t)}else{var r=t===10&&!e.match(/e/i)||t===16;if(e.match(Hn)&&r||e.match(Gn)){return ri(e,t)}if(e.match(Rn)){return oi(e)}}return false},"(string->number number [radix])\n\n Function that parses a string into a number."),try:y(new Vu("try",function(t,e){var c=this;var f=e.dynamic_scope,l=e.error;return new Promise(function(i,n){var u,a;if(L.is(t.cdr.car.car,"catch")){u=t.cdr.car;if(t.cdr.cdr instanceof M&&L.is(t.cdr.cdr.car.car,"finally")){a=t.cdr.cdr.car}}else if(L.is(t.cdr.car.car,"finally")){a=t.cdr.car}if(!(a||u)){throw new Error("try: invalid syntax")}var o=i;if(a){o=function e(t,r){o=n;Yi(_s(new M(new L("begin"),a.cdr),s),function(){r(t)})}}var s={env:c,error:function e(t){var r=c.inherit("try");if(u){r.set(u.cdr.car.car,t);var n={env:r,error:l};if(f){n.dynamic_scope=c}Yi(_s(new M(new L("begin"),u.cdr.cdr),n),function(e){o(e,i)})}else{o(t,l)}}};if(f){s.dynamic_scope=c}var e=_s(t.car,s);if(ra(e)){e.then(function(e){o(e,i)})["catch"](s.error)}else{o(e,i)}})}),"(try expr (catch (e) code))\n (try expr (catch (e) code) (finally code))\n (try expr (finally code))\n\n Macro that executes expr and catches any exceptions thrown. If catch is provided\n it's executed when an error is thrown. If finally is provided it's always\n executed at the end."),raise:y("raise",function(e){throw e},"(raise obj)\n\n Throws the object verbatim (no wrapping an a new Error)."),throw:y("throw",function(e){throw new Error(e)},"(throw string)\n\n Throws a new exception."),find:y("find",function t(r,n){h("find",r,["regex","function"]);h("find",n,["pair","nil"]);if(Zu(n)){return U}var e=Gi("find",r);return Yi(e(n.car),function(e){if(e&&e!==U){return n.car}return t(r,n.cdr)})},"(find fn list)\n (find regex list)\n\n Higher-order function that finds the first value for which fn return true.\n If called with a regex it will create a matcher function."),"for-each":y("for-each",function(e){var t;h("for-each",e,"function");for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i1?t-1:0),u=1;u3?n-3:0),u=3;u3?i-3:0),a=3;aarray")(r);var u=[];var a=Gi("filter",t);return function t(r){function e(e){if(e&&e!==U){u.push(n)}return t(++r)}if(r===i.length){return M.fromArray(u)}var n=i[r];return Yi(a(n),e)}(0)},"(filter fn list)\n (filter regex list)\n\n Higher-order function that calls `fn` for each element of the list\n and return a new list for only those elements for which fn returns\n a truthy value. If called with a regex it will create a matcher function."),compose:y(Ra,"(compose . fns)\n\n Higher-order function that creates a new function that applies all functions\n from right to left and returns the last value. Reverse of pipe.\n e.g.:\n ((compose (curry + 2) (curry * 3)) 10) --\x3e (+ 2 (* 3 10)) --\x3e 32"),pipe:y(Na,"(pipe . fns)\n\n Higher-order function that creates a new function that applies all functions\n from left to right and returns the last value. Reverse of compose.\n e.g.:\n ((pipe (curry + 2) (curry * 3)) 10) --\x3e (* 3 (+ 2 10)) --\x3e 36"),curry:y(Ya,"(curry fn . args)\n\n Higher-order function that creates a curried version of the function.\n The result function will have partially applied arguments and it\n will keep returning one-argument functions until all arguments are provided,\n then it calls the original function with the accumulated arguments.\n\n e.g.:\n (define (add a b c d) (+ a b c d))\n (define add1 (curry add 1))\n (define add12 (add 2))\n (display (add12 3 4))"),gcd:y("gcd",function e(){for(var t=arguments.length,r=new Array(t),n=0;no?u%=o:o%=u}u=Tu(s*r[a])/(u+o)}return C(u)},"(lcm n1 n2 ...)\n\n Function that returns the least common multiple of the arguments."),"odd?":y("odd?",Ua(function(e){return C(e).isOdd()}),"(odd? number)\n\n Checks if number is odd."),"even?":y("even?",Ua(function(e){return C(e).isEven()}),"(even? number)\n\n Checks if number is even."),"*":y("*",qa(function(e,t){return C(e).mul(t)},C(1)),"(* . numbers)\n\n Multiplies all numbers passed as arguments. If single value is passed\n it will return that value."),"+":y("+",qa(function(e,t){return C(e).add(t)},C(0)),"(+ . numbers)\n\n Sums all numbers passed as arguments. If single value is passed it will\n return that value."),"-":y("-",function(){for(var e=arguments.length,t=new Array(e),r=0;r":y(">",function(){for(var e=arguments.length,t=new Array(e),r=0;r",t,"number");return Lu(function(e,t){return C(e).cmp(t)===1},t)},"(> x1 x2 x3 ...)\n\n Function that compares its numerical arguments and checks if they are\n monotonically decreasing, i.e. x1 > x2 and x2 > x3 and so on."),"<":y("<",function(){for(var e=arguments.length,t=new Array(e),r=0;r=":y(">=",function(){for(var e=arguments.length,t=new Array(e),r=0;r=",t,"number");return Lu(function(e,t){return[0,1].includes(C(e).cmp(t))},t)},"(>= x1 x2 ...)\n\n Function that compares its numerical arguments and checks if they are\n monotonically nonincreasing, i.e. x1 >= x2 and x2 >= x3 and so on."),"eq?":y("eq?",Uu,"(eq? a b)\n\n Function that compares two values if they are identical."),or:y(new Vu("or",function(e,t){var i=t.dynamic_scope,u=t.error;var a=qo.get("list->array")(e);var o=this;if(i){i=o}if(!a.length){return false}var s;return function t(){function e(e){s=e;if(s!==false){return s}else{return t()}}if(!a.length){if(s!==false){return s}else{return false}}else{var r=a.shift();var n=_s(r,{env:o,dynamic_scope:i,error:u});return Yi(n,e)}}()}),"(or . expressions)\n\n Macro that executes the values one by one and returns the first that is\n a truthy value. If there are no expressions that evaluate to true it\n returns false."),and:y(new Vu("and",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},i=t.dynamic_scope,u=t.error;var a=qo.get("list->array")(e);var o=this;if(i){i=o}if(!a.length){return true}var s;return function t(){function e(e){s=e;if(s===false){return false}else{return t()}}if(!a.length){if(s!==false){return s}else{return false}}else{var r=a.shift();var n=_s(r,{env:o,dynamic_scope:i,error:u});return Yi(n,e)}}()}),"(and . expressions)\n\n Macro that evaluates each expression in sequence and if any value returns false\n it will stop and return false. If each value returns true it will return the\n last value. If it's called without arguments it will return true."),"|":y("|",function(e,t){return C(e).or(t)},"(| a b)\n\n Function that calculates the bitwise or operation."),"&":y("&",function(e,t){return C(e).and(t)},"(& a b)\n\n Function that calculates the bitwise and operation."),"~":y("~",function(e){return C(e).neg()},"(~ number)\n\n Function that calculates the bitwise inverse (flip all the bits)."),">>":y(">>",function(e,t){return C(e).shr(t)},"(>> a b)\n\n Function that right shifts the value a by value b bits."),"<<":y("<<",function(e,t){return C(e).shl(t)},"(<< a b)\n\n Function that left shifts the value a by value b bits."),not:y("not",function e(t){if(Zu(t)){return true}return!t},"(not object)\n\n Function that returns the Boolean negation of its argument.")},undefined,"global");var Yo=qo.inherit("user-env");function Vo(e,t){e.constant("**internal-env**",t);e.doc("**internal-env**","**internal-env**\n\n Constant used to hide stdin, stdout and stderr so they don't interfere\n with variables with the same name. Constants are an internal type\n of variable that can't be redefined, defining a variable with the same name\n will throw an error.");qo.set("**interaction-environment**",e)}Vo(Yo,Lo);qo.doc("**interaction-environment**","**interaction-environment**\n\n Internal dynamic, global variable used to find interpreter environment.\n It's used so the read and write functions can locate **internal-env**\n that contains the references to stdin, stdout and stderr.");(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(t){var r=e[t]?e[t]:t;qo.set(r,y(r,function(e){h(r,e,"number");if(e instanceof C){return e[t]()}},"(".concat(r," number)\n\n Function that calculates the ").concat(r," of a number.")))})})();function zo(e){if(e.length===1){return e[0]}else{var t=[];var r=zo(e.slice(1));for(var n=0;n3&&arguments[3]!==undefined?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(n!==null){i+=" (argument ".concat(n,")")}if(Xu(r)){return"Invalid type: got ".concat(t).concat(i)}if(r instanceof Array){if(r.length===1){var u=r[0].toLowerCase();r="a"+("aeiou".includes(u)?"n ":" ")+r[0]}else{var a=r[r.length-1];r=r.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(r,", got ").concat(t).concat(i)}function Zo(r,e,n){e.forEach(function(e,t){h(r,e,n,t+1)})}function Xo(e,t,r){h(e,t,r);if(t.__type__===Ao){throw new Error(Qo(e,"binary-port","textual-port"))}}function h(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;e=e.valueOf();var i=us(t).toLowerCase();if(Xu(r)){if(!r(t)){throw new Error(Qo(e,i,r,n))}return}var u=false;if(r instanceof M){r=r.to_array()}if(r instanceof Array){r=r.map(function(e){return e.valueOf()})}if(r instanceof Array){r=r.map(function(e){return e.valueOf().toLowerCase()});if(r.includes(i)){u=true}}else{r=r.valueOf().toLowerCase()}if(!u&&i!==r){throw new Error(Qo(e,i,r,n))}}function es(e){var t=_(e);return["string","function"].includes(t)||_(e)==="symbol"||e instanceof ki||e instanceof L||e instanceof C||e instanceof $a||e instanceof RegExp}function ts(e){return e instanceof C||e instanceof $a||e instanceof za}function rs(e,t){if(e===null){return false}return _(e)==="object"&&t in Object.getOwnPropertySymbols(e)}function ns(e,t){if(rs(e,t)||rs(e.__proto__,t)){return Xu(e[t])}}function is(r){var n=new WeakMap;return function(e){var t=n.get(e);if(!t){t=r(e)}return t}}us=is(us);function us(e){var t=wn.get(e);if(t){return t}if(_(e)==="object"){for(var r=0,n=Object.entries(bn);r2&&arguments[2]!==undefined?arguments[2]:{},u=t.env,a=t.dynamic_scope,r=t.error,o=r===void 0?function(){}:r;e=os(e,{env:u,dynamic_scope:a,error:o});return Yi(e,function(e){if(Sa(i)){i=sa(i)}e=fs(i,e);var t=e.slice();var r=(a||u).newFrame(i,t);var n=as(i.apply(r,e));return Yi(n,function(e){if(e instanceof M){e.markCycles();return Io(e)}return ia(e)},o)})}var hs=function(){function t(e){D(this,t);this.__value__=e}A(t,[{key:"invoke",value:function e(){if(this.__value__===null){throw new Error("Continuations are not implemented yet")}}},{key:"toString",value:function e(){return"#"}}]);return t}();var ps=function e(){};function _s(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=e.env,n=e.dynamic_scope,c=e.error,i=c===void 0?ps:c;try{if(n===true){r=n=r||qo}else if(r===true){r=n=qo}else{r=r||qo}var u={env:r,dynamic_scope:n,error:i};var a;if(Zu(t)){return t}if(t instanceof L){return r.get(t)}if(!(t instanceof M)){return t}var o=t.car;var f=t.cdr;if(o instanceof M){a=as(_s(o,u));if(ra(a)){return a.then(function(e){return _s(new M(e,t.cdr),u)})}else if(!ta(a)){throw new Error(us(a)+" "+r.get("repr")(a)+" is not callable while evaluating "+t.toString())}}if(o instanceof L){a=r.get(o)}else if(Xu(o)){a=o}var s;if(a instanceof Ku){s=ss(a,t,u)}else if(a instanceof Vu){s=cs(a,f,u)}else if(Xu(a)){s=ls(a,f,u)}else if(ea(a)){s=a.invoke()}else if(t instanceof M){a=o&&o.toString();throw new Error("".concat(us(o)," ").concat(a," is not a function"))}else{return t}var l=r.get(Symbol["for"]("__promise__"),{throwError:false});if(l===true&&ra(s)){s=s.then(function(e){if(e instanceof M&&!a[ya]){return _s(e,u)}return e});return new ki(s)}return s}catch(e){i&&i.call(r,e,t)}}var ds=ys(function(e){return e});var vs=ys(function(e,t){return t});function ys(_){return function(){var n=B(z.mark(function e(r,n,i){var u,a,o,s,h,c,p,f,l;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(i===true){n=i=n||Yo}else if(n===true){n=i=Yo}else{n=n||Yo}u=[];a=Array.isArray(r)?r:Mi(r);o=false;s=false;t.prev=5;c=yn(a);case 7:t.next=9;return c.next();case 9:if(!(o=!(p=t.sent).done)){t.next=27;break}f=p.value;l=_s(f,{env:n,dynamic_scope:i,error:function e(t,r){if(t&&t.message){if(t.message.match(/^Error:/)){var n=/^(Error:)\s*([^:]+:\s*)/;t.message=t.message.replace(n,"$1 $2")}if(r){if(!(t.__code__ instanceof Array)){t.__code__=[]}t.__code__.push(r.toString(true))}}throw t}});if(ra(l)){t.next=16;break}u.push(_(f,l));t.next=24;break;case 16:t.t0=u;t.t1=_;t.t2=f;t.next=21;return l;case 21:t.t3=t.sent;t.t4=(0,t.t1)(t.t2,t.t3);t.t0.push.call(t.t0,t.t4);case 24:o=false;t.next=7;break;case 27:t.next=33;break;case 29:t.prev=29;t.t5=t["catch"](5);s=true;h=t.t5;case 33:t.prev=33;t.prev=34;if(!(o&&c["return"]!=null)){t.next=38;break}t.next=38;return c["return"]();case 38:t.prev=38;if(!s){t.next=41;break}throw h;case 41:return t.finish(38);case 42:return t.finish(33);case 43:return t.abrupt("return",u);case 44:case"end":return t.stop()}}},e,null,[[5,29,33,43],[34,,38,42]])}));function e(e,t,r){return n.apply(this,arguments)}return e}()}function ms(e){var t={"[":"]","(":")"};var r;if(typeof e==="string"){r=wi(e)}else{r=e.map(function(e){return e&&e.token?e.token:e})}var n=Object.keys(t);var i=Object.values(t).concat(n);r=r.filter(function(e){return i.includes(e)});var u=new di;var a=hn(r),o;try{for(a.s();!(o=a.n()).done;){var s=o.value;if(n.includes(s)){u.push(s)}else if(!u.is_empty()){var f=u.top();var c=t[f];if(s===c){u.pop()}else{throw new Error("Syntax error: missing closing ".concat(c))}}else{throw new Error("Syntax error: not matched closing ".concat(s))}}}catch(e){a.e(e)}finally{a.f()}return u.is_empty()}function gs(e){var t="("+e.toString()+")()";var r=window.URL||window.webkitURL;var n;try{n=new Blob([t],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;n=new i;n.append(t);n=n.getBlob()}return new gn.Worker(r.createObjectURL(n))}function bs(){return Gs.version.match(/^(\{\{VER\}\}|DEV)$/)}function ws(){if(Go()){return}var e;if(document.currentScript){e=document.currentScript}else{var t=document.querySelectorAll("script");if(!t.length){return}e=t[t.length-1]}var r=e.getAttribute("src");return r}var Ds=ws();function Es(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";var t="dist/std.xcb";if(e===""){if(Ds){e=Ds.replace(/[^/]*$/,"std.xcb")}else if(bs()){e="https://cdn.jsdelivr.net/gh/jcubic/lips@devel/".concat(t)}else{e="https://cdn.jsdelivr.net/npm/@jcubic/lips@".concat(Gs.version,"/").concat(t)}}var r=qo.get("load");return r.call(Yo,e,qo)}function As(e){this.url=e;var a=this.worker=gs(function(){var a;var o;self.addEventListener("message",function(e){var r=e.data;var t=r.id;if(r.type!=="RPC"||t===null){return}function n(e){self.postMessage({id:t,type:"RPC",result:e})}function i(e){self.postMessage({id:t,type:"RPC",error:e})}if(r.method==="eval"){if(!o){i("Worker RPC: LIPS not initialized, call init first");return}o.then(function(){var e=r.params[0];var t=r.params[1];a.exec(e,t).then(function(e){e=e.map(function(e){return e&&e.valueOf()});n(e)})["catch"](function(e){i(e)})})}else if(r.method==="init"){var u=r.params[0];if(typeof u!=="string"){i("Worker RPC: url is not a string")}else{importScripts("".concat(u,"/dist/lips.min.js"));a=new Gs.Interpreter("worker");o=Es(u);o.then(function(){n(true)})}}})});this.rpc=function(){var n=0;return function e(t,r){var u=++n;return new Promise(function(n,i){a.addEventListener("message",function e(t){var r=t.data;if(r&&r.type==="RPC"&&r.id===u){if(r.error){i(r.error)}else{n(r.result)}a.removeEventListener("message",e)}});a.postMessage({type:"RPC",method:t,id:u,params:r})})}}();this.rpc("init",[e])["catch"](function(e){console.error(e)});this.exec=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;return this.rpc("eval",[e,t])}}var xs={pair:function e(t){var r=j(t,2),n=r[0],i=r[1];return M(n,i)},number:function e(t){if($a.isString(t)){return C([t,10])}return C(t)},regex:function e(t){var r=j(t,2),n=r[0],i=r[1];return new RegExp(n,i)},nil:function e(){return U},symbol:function e(t){if($a.isString(t)){return L(t)}else if(Array.isArray(t)){return L(Symbol["for"](t[0]))}},string:$a,character:za};var Fs=Object.keys(xs);var ks={};for(var Cs=0,Os=Object.entries(Fs);Cs1){var n=t.reduce(function(e,t){return e+t.length},0);var i=new Uint8Array(n);var u=0;t.forEach(function(e){i.set(e,u);u+=e.length});return i}else if(t.length){return t[0]}}function Us(){var e=1;var t=new TextEncoder("utf-8");return t.encode("LIPS".concat(e.toString().padStart(3," ")))}var Ms=7;function qs(e){var t=new TextDecoder("utf-8");var r=t.decode(e.slice(0,Ms));var n=r.substring(0,4);if(n==="LIPS"){var i=r.match(/^(....).*([0-9]+)$/);if(i){return{type:i[1],version:Number(i[2])}}}return{type:"unknown"}}function Ys(e){var t=Us();var r=Ts.encode(e);return Ls(t,un(r,{magic:false}))}function Vs(e){var t=qs(e),r=t.type,n=t.version;if(r==="LIPS"&&n===1){var i=an(e.slice(Ms),{magic:false});return Ts.decode(i)}else{throw new Error("Invalid file format ".concat(r))}}function zs(e){console.error(e.message||e);if(e.code){console.error(e.code.map(function(e,t){return"[".concat(t+1,"]: ").concat(e)}))}}function $s(){var a=["text/x-lips","text/x-scheme"];var o;function s(r){return new Promise(function(t){var e=r.getAttribute("src");if(e){return fetch(e).then(function(e){return e.text()}).then(vs).then(t)["catch"](function(e){zs(e);t()})}else{return vs(r.innerHTML).then(t)["catch"](function(e){zs(e);t()})}})}function e(){return new Promise(function(i){var u=Array.from(document.querySelectorAll("script"));return function e(){var t=u.shift();if(!t){i()}else{var r=t.getAttribute("type");if(a.includes(r)){var n=t.getAttribute("bootstrap");if(!o&&typeof n==="string"){return Es(n).then(function(){return s(t)}).then(e)}else{return s(t).then(e)}}else if(r&&r.match(/lips|lisp/)){console.warn("Expecting "+a.join(" or ")+" found "+r)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(Js){var t=Js;var r=t.getAttribute("bootstrap");if(typeof r==="string"){return Es(r).then(function(){o=true;return e()})}}return e()}var Js=typeof window!=="undefined"&&window.document&&document.currentScript;if(typeof window!=="undefined"){Fn(window,$s)}var Ks=function(){var e=$a("Sat, 23 Dec 2023 13:40:35 +0000").valueOf();var t=e==="{{"+"DATE}}"?new Date:new Date(e);var r=function e(t){return t.toString().padStart(2,"0")};var n=t.getFullYear();var i=[n,r(t.getMonth()+1),r(t.getDate())].join("-");var u="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter 1.0.0-beta.17 (".concat(i,") \nCopyright (c) 2018-").concat(n," Jakub T. Jankiewicz\n\nType (env) to see environment with functions macros and variables. You can also\nuse (help name) to display help for specific function or macro, (apropos name)\nto display list of matched names in environment and (dir object) to list\nproperties of an object.\n").replace(/^.*\n/,"");return u}();$i(eu,"__class__","ahead");$i(M,"__class__","pair");$i(mu,"__class__","nil");$i(tu,"__class__","pattern");$i(Xi,"__class__","formatter");$i(Vu,"__class__","macro");$i(Ku,"__class__","syntax");$i(So,"__class__","environment");$i(ho,"__class__","input-port");$i(po,"__class__","output-port");$i(_o,"__class__","output-port");$i(vo,"__class__","output-string-port");$i(mo,"__class__","input-string-port");$i(wo,"__class__","input-file-port");$i(yo,"__class__","output-file-port");$i(Oo,"__class__","lips-error");[C,io,fo,uo,lo].forEach(function(e){$i(e,"__class__","number")});$i(za,"__class__","character");$i(L,"__class__","symbol");$i($a,"__class__","string");$i(ki,"__class__","promise");var Gs={version:"1.0.0-beta.17",banner:Ks,date:"Sat, 23 Dec 2023 13:40:35 +0000",exec:vs,parse:Ra(Ji,Mi),tokenize:wi,evaluate:_s,compile:ds,serialize:Ns,unserialize:Rs,serialize_bin:Ys,unserialize_bin:Vs,bootstrap:Es,Environment:So,env:Yo,Worker:As,Interpreter:Co,balanced_parenthesis:ms,balancedParenthesis:ms,balanced:ms,Macro:Vu,Syntax:Ku,Pair:M,Values:jo,QuotedPromise:ki,Error:Oo,quote:Io,InputPort:ho,OutputPort:po,BufferedOutputPort:_o,InputFilePort:wo,OutputFilePort:yo,InputStringPort:mo,OutputStringPort:vo,InputByteVectorPort:go,OutputByteVectorPort:bo,InputBinaryFilePort:Do,OutputBinaryFilePort:Eo,Formatter:Xi,Parser:Li,Lexer:s,specials:Bi,repr:bu,nil:U,eof:Fo,LSymbol:L,LNumber:C,LFloat:uo,LComplex:io,LRational:fo,LBigInteger:lo,LCharacter:za,LString:$a,rationalize:so};qo.set("lips",Gs);var Hs={};var Ws=Object.freeze({__proto__:null,default:Hs});function Qs(e,t){var r=0;for(var n=e.length-1;n>=0;n--){var i=e[n];if(i==="."){e.splice(n,1)}else if(i===".."){e.splice(n,1);r++}else if(r){e.splice(n,1);r--}}if(t){for(;r--;r){e.unshift("..")}}return e}var Zs=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var Xs=function(e){return Zs.exec(e).slice(1)};function ec(){var e="",t=false;for(var r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:"/";if(typeof n!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!n){continue}e=n+"/"+e;t=n.charAt(0)==="/"}e=Qs(lc(e.split("/"),function(e){return!!e}),!t).join("/");return(t?"/":"")+e||"."}function tc(e){var t=rc(e),r=hc(e,-1)==="/";e=Qs(lc(e.split("/"),function(e){return!!e}),!t).join("/");if(!e&&!t){e="."}if(e&&r){e+="/"}return(t?"/":"")+e}function rc(e){return e.charAt(0)==="/"}function nc(){var e=Array.prototype.slice.call(arguments,0);return tc(lc(e,function(e,t){if(typeof e!=="string"){throw new TypeError("Arguments to path.join must be strings")}return e}).join("/"))}function ic(e,t){e=ec(e).substr(1);t=ec(t).substr(1);function r(e){var t=0;for(;t=0;r--){if(e[r]!=="")break}if(t>r)return[];return e.slice(t,r-t+1)}var n=r(e.split("/"));var i=r(t.split("/"));var u=Math.min(n.length,i.length);var a=u;for(var o=0;o=t.length)return{done:true};return{done:false,value:t[n++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u=true,a=false,o;return{s:function e(){r=r.call(t)},n:function e(){var t=r.next();u=t.done;return t},e:function e(t){a=true;o=t},f:function e(){try{if(!u&&r["return"]!=null)r["return"]()}finally{if(a)throw o}}}}function pn(e,t){if(!e)return;if(typeof e==="string")return _n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor)r=e.constructor.name;if(r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return _n(e,t)}function _n(e,t){if(t==null||t>e.length)t=e.length;for(var r=0,n=new Array(t);r1&&arguments[1]!==undefined?arguments[1]:null;var n=arguments[1]===true;function t(e){if(!Cn()){return}var t=qo.get("repr")(e);if(r===null||r instanceof RegExp&&r.test(t)){console.log(qo.get("type")(e)+": "+t)}if(n){console.log(e)}}if(ra(e)){e.then(t)}else{t(e)}return e}function Cn(){return Yo&&Yo.get("DEBUG",{throwError:false})}function On(e){return e?"(?:#".concat(e,"(?:#[ie])?|#[ie]#").concat(e,")"):"(?:#[ie])?"}function Sn(e,t){return"".concat(On(e),"[+-]?").concat(t,"+/").concat(t,"+")}function Bn(e,t){return"".concat(On(e),"(?:[+-]?(?:").concat(t,"+/").concat(t,"+|nan.0|inf.0|").concat(t,"+))?(?:[+-]i|[+-]?(?:").concat(t,"+/").concat(t,"+|").concat(t,"+|nan.0|inf.0)i)(?=[()[\\]\\s]|$)")}function jn(e,t){return"".concat(On(e),"[+-]?").concat(t,"+")}var In=/^#\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimyus]*)$/;var Pn="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+)(?:[eE][-+]?[0-9]+)?)|[0-9]+\\.)";var Nn="(?:#[ie])?(?:[+-]?(?:[0-9]+/[0-9]+|nan.0|inf.0|".concat(Pn,"|[+-]?[0-9]+))?(?:").concat(Pn,"|[+-](?:[0-9]+/[0-9]+|[0-9]+|nan.0|inf.0))i");var Rn=new RegExp("^(#[ie])?".concat(Pn,"$"),"i");function Tn(e,t){var r=e==="x"?"(?!\\+|".concat(t,")"):"(?!\\.|".concat(t,")");var n="";if(e===""){n="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(n,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(t,"+/").concat(t,"+(?!").concat(t,")|[+-]?").concat(t,"+)").concat(r,")?)(").concat(n,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(t,"+/").concat(t,"+|[+-]?").concat(t,"+|[+-])i$"),"i")}var Ln=function(){var u={};[[10,"","[0-9]"],[16,"x","[0-9a-fA-F]"],[8,"o","[0-7]"],[2,"b","[01]"]].forEach(function(e){var t=j(e,3),r=t[0],n=t[1],i=t[2];u[r]=Tn(n,i)});return u}();var Un={alarm:"",backspace:"\b",delete:"",escape:"",newline:"\n",null:"\0",return:"\r",space:" ",tab:"\t",dle:"",soh:"",dc1:"",stx:"",dc2:"",etx:"",dc3:"",eot:"",dc4:"",enq:"",nak:"",ack:"",syn:"",bel:"",etb:"",bs:"\b",can:"",ht:"\t",em:"",lf:"\n",sub:"",vt:"\v",esc:"",ff:"\f",fs:"",cr:"\r",gs:"",so:"",rs:"",si:"",us:"",del:""};function Mn(e){var t=[];var r=0;var n=e.length;while(r=55296&&i<=56319&&r1&&arguments[1]!==undefined?arguments[1]:10;var r=ei(e);var n=r.number.split("/");var i=fo({num:C([n[0],r.radix||t]),denom:C([n[1],r.radix||t])});if(r.inexact){return i.valueOf()}else{return i}}function ri(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;var r=ei(e);if(r.inexact){return uo(parseInt(r.number,r.radix||t))}return C([r.number,r.radix||t])}function ni(e){var t=e.match(/#\\x([0-9a-f]+)$/i);var r;if(t){var n=parseInt(t[1],16);r=String.fromCodePoint(n)}else{t=e.match(/#\\(.+)$/);if(t){r=t[1]}}if(r){return za(r)}throw new Error("Parse: invalid character")}function ii(e){var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;function t(e){var t;if(e==="+"){t=C(1)}else if(e==="-"){t=C(-1)}else if(e.match(Hn)){t=C([e,i])}else if(e.match(Wn)){var r=e.split("/");t=fo({num:C([r[0],i]),denom:C([r[1],i])})}else if(e.match(Rn)){var n=oi(e);if(u.exact){return n.toRational()}return n}else if(e.match(/nan.0$/)){return C(NaN)}else if(e.match(/inf.0$/)){if(e[0]==="-"){return C(Number.NEGATIVE_INFINITY)}return C(Number.POSITIVE_INFINITY)}else{throw new Error("Internal Parser Error")}if(u.inexact){return uo(t.valueOf())}return t}var u=ei(e);i=u.radix||i;var r;var n=u.number.match(Zn);if(i!==10&&n){r=n}else{r=u.number.match(Ln[i])}var a,o;o=t(r[2]);if(r[1]){a=t(r[1])}else{a=C(0)}if(o.cmp(0)===0&&o.__type__==="bigint"){return a}return io({im:o,re:a})}function ui(e){return parseInt(e.toString(),10)===e}function ai(e){var t=e.match(/^(([-+]?[0-9]*)(?:\.([0-9]+))?)e([-+]?[0-9]+)/i);if(t){var r=parseInt(t[4],10);var n;var i=t[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var u=t[3]&&t[3].length;if(i0){return C(u).mul(o)}}}r=uo(r);if(t.exact){return r.toRational()}return r}function si(e){e=e.replace(/\\x([0-9a-f]+);/gi,function(e,t){return"\\u"+t.padStart(4,"0")}).replace(/\n/g,"\\n");var t=e.match(/(\\*)(\\x[0-9A-F])/i);if(t&&t[1].length%2===0){throw new Error("Invalid string literal, unclosed ".concat(t[2]))}try{return $a(JSON.parse(e))}catch(e){var r=e.message.replace(/in JSON /,"").replace(/.*Error: /,"");throw new Error("Invalid string literal: ".concat(r))}}function ci(e){if(e.match(/^\|.*\|$/)){e=e.replace(/(^\|)|(\|$)/g,"");var r={t:"\t",r:"\r",n:"\n"};e=e.replace(/\\(x[^;]+);/g,function(e,t){return String.fromCharCode(parseInt("0"+t,16))}).replace(/\\(.)/g,function(e,t){return r[t]||t})}return new L(e)}function fi(e){if(Mo.hasOwnProperty(e)){return Mo[e]}if(e.match(/^"[\s\S]*"$/)){return si(e)}else if(e[0]==="#"){var t=e.match(In);if(t){return new RegExp(t[1],t[2])}else if(e.match(Vn)){return ni(e)}var r=e.match(/#\\(.+)/);if(r&&Mn(r[1]).length===1){return ni(e)}}if(e.match(/[0-9a-f]|[+-]i/i)){if(e.match(Gn)){return ri(e)}else if(e.match(Rn)){return oi(e)}else if(e.match(Kn)){return ti(e)}else if(e.match(Jn)){return ii(e)}}if(e.match(/^#[iexobd]/)){throw new Error("Invalid numeric constant: "+e)}return ci(e)}function li(e){return!(["(",")","[","]"].includes(e)||Bi.names().includes(e))}function hi(e){return li(e)&&!(e.match(In)||e.match(/^"[\s\S]*"$/)||e.match(Gn)||e.match(Rn)||e.match(Jn)||e.match(Kn)||e.match(Vn)||["#t","#f","nil","true","false"].includes(e))}var pi=/"(?:\\[\S\s]|[^"])*"?/g;function _i(e){if(typeof e==="string"){var t=/([-\\^$[\]()+{}?*.|])/g;return e.replace(t,"\\$1")}return e}function di(){this.data=[]}di.prototype.push=function(e){this.data.push(e)};di.prototype.top=function(){return this.data[this.data.length-1]};di.prototype.pop=function(){return this.data.pop()};di.prototype.is_empty=function(){return!this.data.length};function vi(e){if(e instanceof $a){e=e.valueOf()}var t=new s(e,{whitespace:true});var r=[];while(true){var n=t.peek(true);if(n===Fo){break}r.push(n);t.skip()}return r}function yi(e){var t=e.token,r=F(e,sn);if(t.match(/^"[\s\S]*"$/)&&t.match(/\n/)){var n=new RegExp("^ {1,"+(e.col+1)+"}","mg");t=t.replace(n,"")}return vn({token:t},r)}function mi(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};this.fn=e;this.cont=t}mi.prototype.toString=function(){return"#"};function gi(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r1&&arguments[1]!==undefined?arguments[1]:false;if(e instanceof $a){e=e.toString()}if(t){return vi(e)}else{var r=vi(e).map(function(e){if(e.token==="#\\ "){return e.token}return e.token.trim()}).filter(function(e){return e&&!e.match(/^;/)&&!e.match(/^#\|[\s\S]*\|#$/)});return Di(r)}}function Di(e){var t=0;var r=null;var n=[];for(var i=0;i0&&arguments[0]!==undefined?arguments[0]:null;if(e instanceof L){if(e.is_gensym()){return e}e=e.valueOf()}if(xi(e)){return L(e)}if(e!==null){return r(e,Symbol("#:".concat(e)))}t++;return r(t,Symbol("#:g".concat(t)))}}();function ki(e){var r=this;var n={pending:true,rejected:false,fulfilled:false,reason:undefined,type:undefined};e=e.then(function(e){n.type=us(e);n.fulfilled=true;n.pending=false;return e});$i(this,"_promise",e,{hidden:true});if(Xu(e["catch"])){e=e["catch"](function(e){n.rejected=true;n.pending=false;n.reason=e})}Object.keys(n).forEach(function(t){Object.defineProperty(r,"__".concat(t,"__"),{enumerable:true,get:function e(){return n[t]}})});$i(this,"__promise__",e);this.then=false}ki.prototype.then=function(e){return new ki(this.valueOf().then(e))};ki.prototype["catch"]=function(e){return new ki(this.valueOf()["catch"](e))};ki.prototype.valueOf=function(){if(!this._promise){throw new Error("QuotedPromise: invalid promise created")}return this._promise};ki.prototype.toString=function(){if(this.__pending__){return ki.pending_str}if(this.__rejected__){return ki.rejected_str}return"#")};ki.pending_str="#";ki.rejected_str="#";function Ci(e){if(Array.isArray(e)){return Promise.all(Oi(e)).then(Si)}return e}function Oi(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof ki){t[r]=new Bo(n)}else{t[r]=n}}return t}function Si(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof Bo){t[r]=n.valueOf()}else{t[r]=n}}return t}var Bi={LITERAL:Symbol["for"]("literal"),SPLICE:Symbol["for"]("splice"),SYMBOL:Symbol["for"]("symbol"),names:function e(){return Object.keys(this.__list__)},type:function e(t){return this.get(t).type},get:function e(t){return this.__list__[t]},off:function e(t){var r=this;var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(Array.isArray(t)){t.forEach(function(e){return r.off(e,n)})}else if(n===null){delete this.__events__[t]}else{this.__events__=this.__events__.filter(function(e){return e!==n})}},on:function e(t,r){var n=this;if(Array.isArray(t)){t.forEach(function(e){return n.on(e,r)})}else if(!this.__events__[t]){this.__events__[t]=[r]}else{this.__events__[t].push(r)}},trigger:function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i",new L("quote-promise"),Bi.LITERAL]];var Ri=Ni.map(function(e){return e[0]});Object.freeze(Ri);Object.defineProperty(Bi,"__builtins__",{writable:false,value:Ri});Ni.forEach(function(e){var t=j(e,3),r=t[0],n=t[1],i=t[2];Bi.append(r,n,i)});var s=function(){function p(e){var t=this;var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},n=r.whitespace,i=n===void 0?false:n;D(this,p);$i(this,"__input__",e.replace(/\r/g,""));var u={};["_i","_whitespace","_col","_newline","_line","_state","_next","_token","_prev_char"].forEach(function(r){Object.defineProperty(t,r,{configurable:false,enumerable:false,get:function e(){return u[r]},set:function e(t){u[r]=t}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}A(p,[{key:"get",value:function e(t){return this.__internal[t]}},{key:"set",value:function e(t,r){this.__internal[t]=r}},{key:"token",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(t){var r=this._line;if(this._whitespace&&this._token==="\n"){--r}return{token:this._token,col:this._col,offset:this._i,line:r}}return this._token}},{key:"peek",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(this._i>=this.__input__.length){return Fo}if(this._token){return this.token(t)}var r=this.next_token();if(r){this._token=this.__input__.substring(this._i,this._next);return this.token(t)}return Fo}},{key:"skip",value:function e(){if(this._next!==null){this._token=null;this._i=this._next}}},{key:"read_line",value:function e(){var t=this.__input__.length;if(this._i>=t){return Fo}for(var r=this._i;r=r){return Fo}if(t+this._i>=r){return this.read_rest()}var n=this._i+t;var i=this.__input__.substring(this._i,n);var u=i.match(/\n/g);if(u){this._line+=u.length}this._i=n;return i}},{key:"peek_char",value:function e(){if(this._i>=this.__input__.length){return Fo}return za(this.__input__[this._i])}},{key:"read_char",value:function e(){var t=this.peek_char();this.skip_char();return t}},{key:"skip_char",value:function e(){if(this._i1&&arguments[1]!==undefined?arguments[1]:{},r=t.prev_char,n=t["char"],i=t.next_char;var u=j(e,4),a=u[0],o=u[1],s=u[2],f=u[3];if(e.length!==5){throw new Error("Lexer: Invalid rule of length ".concat(e.length))}if(!n.match(a)){return false}if(!Ti(o,r)){return false}if(!Ti(s,i)){return false}if(f!==this._state){return false}return true}},{key:"next_token",value:function f(){if(this._i>=this.__input__.length){return false}var e=true;e:for(var t=this._i,r=this.__input__.length;t2&&arguments[2]!==undefined?arguments[2]:null;var i=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;if(t.length===0){throw new Error("Lexer: invalid literal rule")}if(t.length===1){return[[t,n,i,null,null]]}var u=[];for(var a=0,o=t.length;a1&&arguments[1]!==undefined?arguments[1]:{},r=t.env,n=t.meta,i=n===void 0?false:n,u=t.formatter,a=u===void 0?yi:u;D(this,o);if(e instanceof $a){e=e.toString()}$i(this,"_formatter",a,{hidden:true});$i(this,"__lexer__",new s(e));$i(this,"__env__",r);$i(this,"_meta",i,{hidden:true});$i(this,"_refs",[],{hidden:true});$i(this,"_state",{parentheses:0},{hidden:true})}A(o,[{key:"resolve",value:function e(t){return this.__env__&&this.__env__.get(t,{throwError:false})}},{key:"peek",value:function(){var e=B(z.mark(function e(){var r;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:r=this.__lexer__.peek(true);if(!(r===Fo)){t.next=4;break}return t.abrupt("return",Fo);case 4:if(!this.is_comment(r.token)){t.next=7;break}this.skip();return t.abrupt("continue",0);case 7:if(!(r.token==="#;")){t.next=14;break}this.skip();if(!(this.__lexer__.peek()===Fo)){t.next=11;break}throw new Error("Lexer: syntax error eof found after comment");case 11:t.next=13;return this._read_object();case 13:return t.abrupt("continue",0);case 14:return t.abrupt("break",17);case 17:r=this._formatter(r);if(!this._meta){t.next=20;break}return t.abrupt("return",r);case 20:return t.abrupt("return",r.token);case 21:case"end":return t.stop()}}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"reset",value:function e(){this._refs.length=0}},{key:"skip",value:function e(){this.__lexer__.skip()}},{key:"read",value:function(){var e=B(z.mark(function e(){var r;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:t.next=2;return this.peek();case 2:r=t.sent;this.skip();return t.abrupt("return",r);case 5:case"end":return t.stop()}}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"match_datum_label",value:function e(t){var r=t.match(/^#([0-9]+)=$/);return r&&r[1]}},{key:"match_datum_ref",value:function e(t){var r=t.match(/^#([0-9]+)#$/);return r&&r[1]}},{key:"is_open",value:function e(t){var r=["(","["].includes(t);if(r){this._state.parentheses++}return r}},{key:"is_close",value:function e(t){var r=[")","]"].includes(t);if(r){this._state.parentheses--}return r}},{key:"read_list",value:function(){var e=B(z.mark(function e(){var r,n,i,u;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:r=U,n=r;case 1:t.next=4;return this.peek();case 4:i=t.sent;if(!(i===Fo)){t.next=7;break}return t.abrupt("break",27);case 7:if(!this.is_close(i)){t.next=10;break}this.skip();return t.abrupt("break",27);case 10:if(!(i==="."&&r!==U)){t.next=17;break}this.skip();t.next=14;return this._read_object();case 14:n.cdr=t.sent;t.next=25;break;case 17:t.t0=M;t.next=20;return this._read_object();case 20:t.t1=t.sent;t.t2=U;u=new t.t0(t.t1,t.t2);if(r===U){r=u}else{n.cdr=u}n=u;case 25:t.next=1;break;case 27:return t.abrupt("return",r);case 28:case"end":return t.stop()}}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"read_value",value:function(){var e=B(z.mark(function e(){var r;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:t.next=2;return this.read();case 2:r=t.sent;if(!(r===Fo)){t.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return t.abrupt("return",fi(r));case 6:case"end":return t.stop()}}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"is_comment",value:function e(t){return t.match(/^;/)||t.match(/^#\|/)&&t.match(/\|#$/)}},{key:"evaluate",value:function e(t){return _s(t,{env:this.__env__,error:function e(t){throw t}})}},{key:"read_object",value:function(){var e=B(z.mark(function e(){var r;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:this.reset();t.next=3;return this._read_object();case 3:r=t.sent;if(r instanceof Ui){r=r.valueOf()}if(!this._refs.length){t.next=7;break}return t.abrupt("return",this._resolve_object(r));case 7:return t.abrupt("return",r);case 8:case"end":return t.stop()}}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},{key:"balanced",value:function e(){return this._state.parentheses===0}},{key:"ballancing_error",value:function e(t){var r=this._state.parentheses;var n=new Error("Parser: expected parenthesis but eof found");var i=new RegExp("\\){".concat(r,"}$"));n.__code__=[t.toString().replace(i,"")];throw n}},{key:"_resolve_object",value:function(){var t=B(z.mark(function e(r){var n=this;var i;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!Array.isArray(r)){t.next=2;break}return t.abrupt("return",r.map(function(e){return n._resolve_object(e)}));case 2:if(!wu(r)){t.next=6;break}i={};Object.keys(r).forEach(function(e){i[e]=n._resolve_object(r[e])});return t.abrupt("return",i);case 6:if(!(r instanceof M)){t.next=8;break}return t.abrupt("return",this._resolve_pair(r));case 8:return t.abrupt("return",r);case 9:case"end":return t.stop()}}},e,this)}));function e(e){return t.apply(this,arguments)}return e}()},{key:"_resolve_pair",value:function(){var t=B(z.mark(function e(r){return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!(r instanceof M)){t.next=15;break}if(!(r.car instanceof Ui)){t.next=7;break}t.next=4;return r.car.valueOf();case 4:r.car=t.sent;t.next=8;break;case 7:this._resolve_pair(r.car);case 8:if(!(r.cdr instanceof Ui)){t.next=14;break}t.next=11;return r.cdr.valueOf();case 11:r.cdr=t.sent;t.next=15;break;case 14:this._resolve_pair(r.cdr);case 15:return t.abrupt("return",r);case 16:case"end":return t.stop()}}},e,this)}));function e(e){return t.apply(this,arguments)}return e}()},{key:"_read_object",value:function(){var e=B(z.mark(function e(){var r,n,i,u,a,o,s,c,f;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:t.next=2;return this.peek();case 2:r=t.sent;if(!(r===Fo)){t.next=5;break}return t.abrupt("return",r);case 5:if(!ji(r)){t.next=39;break}n=Bi.get(r);i=Ii(r);this.skip();t.next=11;return this._read_object();case 11:a=t.sent;if(i){t.next=26;break}o=this.__env__.get(n.symbol);if(!(typeof o==="function")){t.next=26;break}if(!Pi(r)){t.next=19;break}return t.abrupt("return",o.call(this.__env__,a));case 19:if(!(a===U)){t.next=23;break}return t.abrupt("return",o.apply(this.__env__));case 23:if(!(a instanceof M)){t.next=25;break}return t.abrupt("return",o.apply(this.__env__,a.to_array(false)));case 25:throw new Error("Parse Error: Invalid parser extension "+"invocation ".concat(n.symbol));case 26:if(Pi(r)){u=new M(n.symbol,new M(a,U))}else{u=new M(n.symbol,a)}if(!i){t.next=29;break}return t.abrupt("return",u);case 29:if(!(o instanceof Vu)){t.next=38;break}t.next=32;return this.evaluate(u);case 32:s=t.sent;if(!(s instanceof M||s instanceof L)){t.next=35;break}return t.abrupt("return",M.fromArray([L("quote"),s]));case 35:return t.abrupt("return",s);case 38:throw new Error("Parse Error: invalid parser extension: "+n.symbol);case 39:c=this.match_datum_ref(r);if(!(c!==null)){t.next=45;break}this.skip();if(!this._refs[c]){t.next=44;break}return t.abrupt("return",new Ui(c,this._refs[c]));case 44:throw new Error("Parse Error: invalid datum label #".concat(c,"#"));case 45:f=this.match_datum_label(r);if(!(f!==null)){t.next=52;break}this.skip();this._refs[f]=this._read_object();return t.abrupt("return",this._refs[f]);case 52:if(!this.is_open(r)){t.next=57;break}this.skip();return t.abrupt("return",this.read_list());case 57:return t.abrupt("return",this.read_value());case 58:case"end":return t.stop()}}},e,this)}));function t(){return e.apply(this,arguments)}return t}()}]);return o}();var Ui=function(){function r(e,t){D(this,r);this.name=e;this.data=t}A(r,[{key:"valueOf",value:function e(){return this.data}}]);return r}();function Mi(e,t){return qi.apply(this,arguments)}function qi(){qi=e(z.mark(function e(r,n){var i,u;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!n){if(qo){n=qo.get("**interaction-environment**",{throwError:false})}else{n=Yo}}i=new Li(r,{env:n});case 2:t.next=5;return P(i.read_object());case 5:u=t.sent;if(!i.balanced()){i.ballancing_error(u)}if(!(u===Fo)){t.next=9;break}return t.abrupt("break",13);case 9:t.next=11;return u;case 11:t.next=2;break;case 13:case"end":return t.stop()}}},e)}));return qi.apply(this,arguments)}function Yi(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(e){return e};var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;if(ra(e)){var n=e.then(t);if(r===null){return n}else{return n["catch"](r)}}if(e instanceof Array){return Vi(e,t,r)}if(wu(e)){return zi(e,t,r)}return t(e)}function Vi(t,r,e){if(t.find(ra)){return Yi(Ci(t),function(e){if(Object.isFrozen(t)){Object.freeze(e)}return r(e)},e)}return r(t)}function zi(t,e,r){var i=Object.keys(t);var n=[],u=[];var a=i.length;while(a--){var o=i[a];var s=t[o];n[a]=s;if(ra(s)){u.push(s)}}if(u.length){return Yi(Ci(n),function(e){var n={};e.forEach(function(e,t){var r=i[t];n[r]=e});if(Object.isFrozen(t)){Object.freeze(n)}return n},r)}return e(t)}function $i(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},i=n.hidden,u=i===void 0?false:i;Object.defineProperty(e,t,{value:r,configurable:true,enumerable:!u})}function Ji(e){return Ki.apply(this,arguments)}function Ki(){Ki=B(z.mark(function e(r){var n,i,u,a,o,s,c;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:n=[];i=false;u=false;t.prev=3;o=yn(r);case 5:t.next=7;return o.next();case 7:if(!(i=!(s=t.sent).done)){t.next=13;break}c=s.value;n.push(c);case 10:i=false;t.next=5;break;case 13:t.next=19;break;case 15:t.prev=15;t.t0=t["catch"](3);u=true;a=t.t0;case 19:t.prev=19;t.prev=20;if(!(i&&o["return"]!=null)){t.next=24;break}t.next=24;return o["return"]();case 24:t.prev=24;if(!u){t.next=27;break}throw a;case 27:return t.finish(24);case 28:return t.finish(19);case 29:return t.abrupt("return",n);case 30:case"end":return t.stop()}}},e,null,[[3,15,19,29],[20,,24,28]])}));return Ki.apply(this,arguments)}function Gi(e,t){if(t instanceof RegExp){return function(e){return String(e).match(t)}}else if(Xu(t)){return t}throw new Error("Invalid matcher")}function y(e,t,r,n){if(typeof e!=="string"){t=arguments[0];r=arguments[1];n=arguments[2];e=null}if(r){if(n){t.__doc__=r}else{t.__doc__=Hi(r)}}if(e){t.__name__=e}else if(t.name&&!Ca(t)){t.__name__=t.name}return t}function Hi(e){return e.split("\n").map(function(e){return e.trim()}).join("\n")}function Wi(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;var r=e.length;if(t<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(t))}e:while(t--&&r>=0){var n=1;while(n>0){var i=e[--r];if(!i){break e}if(i==="("||i.token==="("){n--}else if(i===")"||i.token===")"){n++}}r--}return e.slice(r+1)}function Qi(e){if(!e||!e.length){return 0}var t=e.length;if(e[t-1].token==="\n"){return 0}while(--t){if(e[t].token==="\n"){var r=(e[t+1]||{}).token;if(r){return r.length}}}return 0}function Zi(e,t){return f(e,t)===t.length;function f(r,n){function e(e,t){var r=hn(e),n;try{for(r.s();!(n=r.n()).done;){var i=n.value;var u=f(i,t);if(u!==-1){return u}}}catch(e){r.e(e)}finally{r.f()}return-1}function t(){return r[u]===Symbol["for"]("symbol")&&!hi(n[o])}function i(){var e=r[u+1];var t=n[o+1];if(e!==undefined&&t!==undefined){return f([e],[t])}}var u=0;var a={};for(var o=0;o0){continue}}else if(t()){return-1}}else if(r[u]instanceof Array){var c=f(r[u],n.slice(o));if(c===-1||c+o>n.length){return-1}o+=c-1;u++;continue}else{return-1}u++}if(r.length!==u){return-1}return n.length}}function Xi(e){this.__code__=e.replace(/\r/g,"")}Xi.defaults={offset:0,indent:2,exceptions:{specials:[/^(?:#:)?(?:define(?:-values|-syntax|-macro|-class|-record-type)?|(?:call-with-(?:input-file|output-file|port))|lambda|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax|\*)?)$/],shift:{1:["&","#"]}}};Xi.match=Zi;Xi.prototype._options=function e(t){var r=Xi.defaults;if(typeof t==="undefined"){return Object.assign({},r)}var n=t&&t.exceptions||{};var i=n.specials||[];var u=n.shift||{1:[]};return vn(vn(vn({},r),t),{},{exceptions:{specials:[].concat(q(r.exceptions.specials),q(i)),shift:vn(vn({},u),{},{1:[].concat(q(r.exceptions.shift[1]),q(u[1]))})}})};Xi.prototype.indent=function e(t){var r=wi(this.__code__,true);return this._indent(r,t)};Xi.exception_shift=function(u,e){function t(e){if(!e.length){return false}if(e.indexOf(u)!==-1){return true}else{var t=e.filter(function(e){return e instanceof RegExp});if(!t.length){return false}var r=hn(t),n;try{for(r.s();!(n=r.n()).done;){var i=n.value;if(u.match(i)){return true}}}catch(e){r.e(e)}finally{r.f()}}return false}if(t(e.exceptions.specials)){return e.indent}var r=e.exceptions.shift;for(var n=0,i=Object.entries(r);n0){t.offset=0}if(n.toString()===e.toString()&&ms(n)){return t.offset+n[0].col}else if(n.length===1){return t.offset+n[0].col+1}else{var u=-1;if(i){var a=Xi.exception_shift(i.token,t);if(a!==-1){u=a}}if(u===-1){u=Xi.exception_shift(n[1].token,t)}if(u!==-1){return t.offset+n[0].col+u}else if(n[0].line3&&n[1].line===n[3].line){if(n[1].token==="("||n[1].token==="["){return t.offset+n[1].col}return t.offset+n[3].col}else if(n[0].line===n[1].line){return t.offset+t.indent+n[0].col}else{var o=n.slice(2);for(var s=0;s")};eu.prototype.match=function(e){return e.match(this.pattern)};function tu(){for(var e=arguments.length,t=new Array(e),r=0;r")};Xi.Pattern=tu;Xi.Ahead=eu;var ru=/^[[(]$/;var nu=/^[\])]$/;var iu=/[^()[\]]/;var uu=new eu(/[^)\]]/);var au=Symbol["for"]("*");var ou=new tu([ru,au,nu],[iu],"+");var su=new tu([ru,au,nu],"+");var cu=new tu([Symbol["for"]("symbol")],"?");var fu=new tu([Symbol["for"]("symbol")],"*");var lu=[ru,fu,nu];var hu=new tu([ru,Symbol["for"]("symbol"),au,nu],"+");var pu=vu("define","lambda","define-macro","syntax-rules");var _u=/^(?!.*\b(?:[()[\]]|define(?:-macro)?|let(?:\*|rec|-env|-syntax|)?|lambda|syntax-rules)\b).*$/;var du=/^(?:#:)?(let(?:\*|rec|-env|-syntax)?)$/;function vu(){for(var e=arguments.length,t=new Array(e),r=0;r0&&!i[e]){i[e]=Wi(n,e)}});var u=hn(t),p;try{for(u.s();!(p=u.n()).done;){var a=j(p.value,3),_=a[0],o=a[1],s=a[2];o=o.valueOf();var d=o>0?i[o]:n;var v=d.filter(function(e){return e.trim()&&!ji(e)});var y=h(d);var m=Zi(_,v);var g=e.slice(r).find(function(e){return e.trim()&&!ji(e)});if(m&&(s instanceof eu&&s.match(g)||!s)){var c=r-y;if(e[c]!=="\n"){if(!e[c].trim()){e[c]="\n"}else{e.splice(c,0,"\n");r++}}r+=y;continue e}}}catch(e){u.e(e)}finally{u.f()}}this.__code__=e.join("");return this};Xi.prototype._spaces=function(e){return new Array(e+1).join(" ")};Xi.prototype.format=function c(e){var t=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var r=wi(t,true);var n=this._options(e);var i=0;var u=0;for(var a=0;a0&&arguments[0]!==undefined?arguments[0]:true;var n=new Map;function i(e){if(e instanceof M){if(n.has(e)){return n.get(e)}var t=new M;n.set(e,t);if(r){t.car=i(e.car)}else{t.car=e.car}t.cdr=i(e.cdr);t[ga]=e[ga];return t}return e}return i(this)};M.prototype.last_pair=function(){var e=this;while(true){if(e.cdr===U){return e}e=e.cdr}};M.prototype.to_array=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var t=[];if(this.car instanceof M){if(e){t.push(this.car.to_array())}else{t.push(this.car)}}else{t.push(this.car.valueOf())}if(this.cdr instanceof M){t=t.concat(this.cdr.to_array())}return t};M.fromArray=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;if(e instanceof M||r&&e instanceof Array&&e[ya]){return e}if(t===false){var n=U;for(var i=e.length;i--;){n=new M(e[i],n)}return n}if(e.length&&!(e instanceof Array)){e=q(e)}var u=U;var a=e.length;while(a--){var o=e[a];if(o instanceof Array){o=M.fromArray(o,t,r)}else if(typeof o==="string"){o=$a(o)}else if(typeof o==="number"&&!Number.isNaN(o)){o=C(o)}u=new M(o,u)}return u};M.prototype.to_object=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var t=this;var r={};while(true){if(t instanceof M&&t.car instanceof M){var n=t.car;var i=n.car;if(i instanceof L){i=i.__name__}if(i instanceof $a){i=i.valueOf()}var u=n.cdr;if(u instanceof M){u=u.to_object(e)}if(ts(u)){if(!e){u=u.valueOf()}}r[i]=u;t=t.cdr}else{break}}return r};M.fromPairs=function(e){return e.reduce(function(e,t){return new M(new M(new L(t[0]),t[1]),e)},U)};M.fromObject=function(t){var e=Object.keys(t).map(function(e){return[e,t[e]]});return M.fromPairs(e)};M.prototype.reduce=function(e){var t=this;var r=U;while(true){if(t!==U){r=e(r,t.car);t=t.cdr}else{break}}return r};M.prototype.reverse=function(){if(this.haveCycles()){throw new Error("You can't reverse list that have cycles")}var e=this;var t=U;while(e!==U){var r=e.cdr;e.cdr=t;t=e;e=r}return t};M.prototype.transform=function(n){function i(e){if(e instanceof M){if(e.replace){delete e.replace;return e}var t=n(e.car);if(t instanceof M){t=i(t)}var r=n(e.cdr);if(r instanceof M){r=i(r)}return new M(t,r)}return e}return i(this)};M.prototype.map=function(e){if(typeof this.car!=="undefined"){return new M(e(this.car),this.cdr===U?U:this.cdr.map(e))}else{return U}};var bu=new Map;function wu(e){return e&&_(e)==="object"&&e.constructor===Object}var Du=Object.getOwnPropertyNames(Array.prototype);var Eu=[];Du.forEach(function(e){Eu.push(Array[e],Array.prototype[e])});function Au(e){e=sa(e);return Eu.includes(e)}function xu(e){return Xu(e)&&(Ca(e)||e.__doc__)}function Fu(r){var e=r.constructor||Object;var n=wu(r);var i=Xu(r[Symbol.asyncIterator])||Xu(r[Symbol.iterator]);var u;if(bu.has(e)){u=bu.get(e)}else{bu.forEach(function(e,t){t=sa(t);if(r.constructor===t&&(t===Object&&n&&!i||t!==Object)){u=e}})}return u}var ku=new Map;[[true,"#t"],[false,"#f"],[null,"null"],[undefined,"#"]].forEach(function(e){var t=j(e,2),r=t[0],n=t[1];ku.set(r,n)});function Cu(r){if(r&&_(r)==="object"){var n={};var e=Object.getOwnPropertySymbols(r);e.forEach(function(e){var t=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");n[t]=Pu(r[e])});var t=Object.getOwnPropertyNames(r);t.forEach(function(e){var t=r[e];if(t&&_(t)==="object"&&t.constructor===Object){n[e]=Cu(t)}else{n[e]=Pu(t)}});return n}return r}function Ou(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function Su(e,t){return e.hasOwnProperty(t)&&Xu(e.toString)}function Bu(e){if(Ba(e)){return"#"}var t=e.prototype&&e.prototype.constructor;if(Xu(t)&&Ca(t)){if(e[ba]&&t.hasOwnProperty("__name__")){var r=t.__name__;if($a.isString(r)){r=r.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_(n)==="symbol"){n=Ai(n)}if(typeof n==="string"){return"#")}}if(Su(e,"toString")){return e.toString()}else if(e.name&&!Ca(e)){return"#")}else{return"#"}}var ju=new Map;[[Error,function(e){return e.message}],[M,function(e,t){var r=t.quote,n=t.skip_cycles,i=t.pair_args;if(!n){e.markCycles()}return e.toString.apply(e,[r].concat(q(i)))}],[za,function(e,t){var r=t.quote;if(r){return e.toString()}return e.valueOf()}],[$a,function(e,t){var r=t.quote;e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var t=j(e,2),r=t[0],n=t[1];ju.set(r,n)});var Iu=[L,C,Vu,jo,ho,po,So,ki];function Pu(e,t,c){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(ku.has(e)){return ku.get(e)}if(Nu(e)){return"#"}if(e){var r=e.constructor;if(ju.has(r)){for(var n=arguments.length,f=new Array(n>3?n-3:0),i=3;i"}if(e===null){return"null"}if(_(e)==="object"){var a=e.constructor;if(!a){a=Object}var o;if(typeof a.__class__==="string"){o=a.__class__}else{var s=Fu(e);if(s){if(Xu(s)){return s(e,t)}else{throw new Error("toString: Invalid repr value")}}o=a.name}if(Xu(e.toString)&&Ca(e.toString)){return e.toString().valueOf()}if(us(e)==="instance"){if(Ca(a)&&a.__name__){o=a.__name__.valueOf()}else if(!Ba(a)){o="instance"}}if(ns(e,Symbol.iterator)){if(o){return"#")}return"#"}if(ns(e,Symbol.asyncIterator)){if(o){return"#")}return"#"}if(o!==""){return"#<"+o+">"}return"#"}if(typeof e!=="string"){return e.toString()}return e}function Nu(e){return e&&_(e)==="object"&&e.hasOwnProperty&&e.hasOwnProperty("constructor")&&typeof e.constructor==="function"&&e.constructor.prototype===e}M.prototype.markCycles=function(){Ru(this);return this};M.prototype.haveCycles=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(!e){return this.haveCycles("car")||this.haveCycles("cdr")}return!!(this[ga]&&this[ga][e])};function Ru(e){var t=[];var i=[];var u=[];function a(e){if(!t.includes(e)){t.push(e)}}function o(e,t,r,n){if(r instanceof M){if(n.includes(r)){if(!u.includes(r)){u.push(r)}if(!e[ga]){e[ga]={}}e[ga][t]=r;if(!i.includes(e)){i.push(e)}return true}}}var s=gi(function e(t,r){if(t instanceof M){delete t.ref;delete t[ga];a(t);r.push(t);var n=o(t,"car",t.car,r);var i=o(t,"cdr",t.cdr,r);if(!n){s(t.car,r.slice())}if(!i){return new mi(function(){return e(t.cdr,r.slice())})}}});function r(e,t){if(e[ga][t]instanceof M){var r=n.indexOf(e[ga][t]);e[ga][t]="#".concat(r,"#")}}s(e,[]);var n=t.filter(function(e){return u.includes(e)});n.forEach(function(e,t){e[ma]="#".concat(t,"=")});i.forEach(function(e){r(e,"car");r(e,"cdr")})}M.prototype.toString=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=t.nested,n=r===void 0?false:r;var i=[];if(this[ma]){i.push(this[ma]+"(")}else if(!n){i.push("(")}var u;if(this[ga]&&this[ga].car){u=this[ga].car}else{u=Pu(this.car,e,true)}if(u!==undefined){i.push(u)}if(this.cdr instanceof M){if(this[ga]&&this[ga].cdr){i.push(" . ");i.push(this[ga].cdr)}else{if(this.cdr[ma]){i.push(" . ")}else{i.push(" ")}var a=this.cdr.toString(e,{nested:true});i.push(a)}}else if(this.cdr!==U){i=i.concat([" . ",Pu(this.cdr,e,true)])}if(!n||this[ma]){i.push(")")}return i.join("")};M.prototype.set=function(e,t){this[e]=t;if(t instanceof M){this.markCycles()}};M.prototype.append=function(e){if(e instanceof Array){return this.append(M.fromArray(e))}var t=this;if(t.car===undefined){if(e instanceof M){this.car=e.car;this.cdr=e.cdr}else{this.car=e}}else if(e!==U){while(true){if(t instanceof M&&t.cdr!==U){t=t.cdr}else{break}}t.cdr=e}return this};M.prototype.serialize=function(){return[this.car,this.cdr]};M.prototype[Symbol.iterator]=function(){var r=this;return{next:function e(){var t=r;r=t.cdr;if(t===U){return{value:undefined,done:true}}else{return{value:t.car,done:false}}}}};function Tu(e){return e<0?-e:e}function Lu(e,t){var r=m(t),n=r[0],i=r.slice(1);while(i.length>0){var u=i,a=j(u,1),o=a[0];if(!e(n,o)){return false}var s=i;var c=m(s);n=c[0];i=c.slice(1)}return true}function Uu(e,t){if(Xu(e)){return Xu(t)&&sa(e)===sa(t)}else if(e instanceof C){if(!(t instanceof C)){return false}var r;if(e.__type__===t.__type__){if(e.__type__==="complex"){r=e.__im__.__type__===t.__im__.__type__&&e.__re__.__type__===t.__re__.__type__}else{r=true}if(r&&e.cmp(t)===0){if(e.valueOf()===0){return Object.is(e.valueOf(),t.valueOf())}return true}}return false}else if(typeof e==="number"){if(typeof t!=="number"){return false}if(Number.isNaN(e)){return Number.isNaN(t)}if(e===Number.NEGATIVE_INFINITY){return t===Number.NEGATIVE_INFINITY}if(e===Number.POSITIVE_INFINITY){return t===Number.POSITIVE_INFINITY}return Uu(C(e),C(t))}else if(e instanceof za){if(!(t instanceof za)){return false}return e.__char__===t.__char__}else{return e===t}}function Mu(e,t){if(us(e)!==us(t)){return false}if(!qu(e)){return false}if(e instanceof RegExp){return e.source===t.source}if(e instanceof $a){return e.valueOf()===t.valueOf()}return Uu(e,t)}function qu(e){return e instanceof L||$a.isString(e)||e===U||e===null||e instanceof za||e instanceof C||e===true||e===false}var Yu=function(){if(Math.trunc){return Math.trunc}else{return function(e){if(e===0){return 0}else if(e<0){return Math.ceil(e)}else{return Math.floor(e)}}}}();function Vu(e,t,r,n){if(typeof this!=="undefined"&&this.constructor!==Vu||typeof this==="undefined"){return new Vu(e,t)}h("Macro",e,"string",1);h("Macro",t,"function",2);if(r){if(n){this.__doc__=r}else{this.__doc__=Hi(r)}}this.__name__=e;this.__fn__=t}Vu.defmacro=function(e,t,r,n){var i=new Vu(e,t,r,n);i.__defmacro__=true;return i};Vu.prototype.invoke=function(e,t,r){var n=t.env,i=t.dynamic_scope,u=t.error;var a={dynamic_scope:i,error:u,macro_expand:r};var o=this.__fn__.call(n,e,a,this.__name__);return o};Vu.prototype.toString=function(){return"#")};var zu="define-macro";var $u=-1e4;function Ju(c){return function(){var r=B(z.mark(function e(r,m){var u,g,n,i,s,D,E,A,x,F,k,b,a,w,o;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:o=function e(){o=B(z.mark(function e(r,n,i){var h,u,a,p,o,_,s,d,c,v,f,l,y;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!(r instanceof M&&r.car instanceof L)){t.next=50;break}if(!r[ya]){t.next=3;break}return t.abrupt("return",r);case 3:h=r.car.valueOf();u=i.get(r.car,{throwError:false});a=D(r.car);p=a||E(u,r)||A(u);if(!(p&&r.cdr.car instanceof M)){t.next=28;break}if(!a){t.next=15;break}g=F(r.cdr.car);t.next=12;return b(r.cdr.car,n);case 12:o=t.sent;t.next=17;break;case 15:g=x(r.cdr.car);o=r.cdr.car;case 17:t.t0=M;t.t1=r.car;t.t2=M;t.t3=o;t.next=23;return w(r.cdr.cdr,n,i);case 23:t.t4=t.sent;t.t5=new t.t2(t.t3,t.t4);return t.abrupt("return",new t.t0(t.t1,t.t5));case 28:if(!k(h,u)){t.next=50;break}_=u instanceof Ku?r:r.cdr;t.next=32;return u.invoke(_,vn(vn({},m),{},{env:i}),true);case 32:s=t.sent;if(!(u instanceof Ku)){t.next=41;break}d=s,c=d.expr,v=d.scope;if(!(c instanceof M)){t.next=40;break}if(!(n!==-1&&n<=1||n<$u)){t.next=38;break}return t.abrupt("return",c);case 38:if(n!==-1){n=n-1}return t.abrupt("return",w(c,n,v));case 40:s=c;case 41:if(!(s instanceof L)){t.next=43;break}return t.abrupt("return",Io(s));case 43:if(!(s instanceof M)){t.next=48;break}if(!(n!==-1&&n<=1||n<$u)){t.next=46;break}return t.abrupt("return",s);case 46:if(n!==-1){n=n-1}return t.abrupt("return",w(s,n,i));case 48:if(!qu(s)){t.next=50;break}return t.abrupt("return",s);case 50:f=r.car;if(!(f instanceof M)){t.next=55;break}t.next=54;return w(f,n,i);case 54:f=t.sent;case 55:l=r.cdr;if(!(l instanceof M)){t.next=60;break}t.next=59;return w(l,n,i);case 59:l=t.sent;case 60:y=new M(f,l);return t.abrupt("return",y);case 62:case"end":return t.stop()}}},e)}));return o.apply(this,arguments)};w=function e(t,r,n){return o.apply(this,arguments)};a=function e(){a=B(z.mark(function e(r,n){var i;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!(r===U)){t.next=2;break}return t.abrupt("return",U);case 2:i=r.car;t.t0=M;t.t1=M;t.t2=i.car;t.next=8;return w(i.cdr,n,u);case 8:t.t3=t.sent;t.t4=new t.t1(t.t2,t.t3);t.next=12;return b(r.cdr);case 12:t.t5=t.sent;return t.abrupt("return",new t.t0(t.t4,t.t5));case 14:case"end":return t.stop()}}},e)}));return a.apply(this,arguments)};b=function e(t,r){return a.apply(this,arguments)};k=function e(t,r){return r instanceof Vu&&r.__defmacro__&&!g.includes(t)};F=function e(t){return[].concat(q(g),q(t.to_array(false).map(function(e){if(e instanceof M){return e.car.valueOf()}throw new Error("macroexpand: Invalid let binding")})))};x=function e(t){var r=[];while(true){if(t!==U){if(t instanceof L){r.push(t.valueOf());break}r.push(t.car.valueOf());t=t.cdr}else{break}}return[].concat(q(g),r)};A=function e(t){return t===i};E=function e(t,r){return t===s&&r.cdr.car instanceof M};D=function e(t){var r=t.valueOf();return n.includes(r)};u=m["env"]=this;g=[];n=["let","let*","letrec"];i=qo.get("lambda");s=qo.get("define");if(!(r.cdr instanceof M&&C.isNumber(r.cdr.car))){t.next=21;break}t.t0=Io;t.next=19;return w(r,r.cdr.car.valueOf(),u);case 19:t.t1=t.sent.car;return t.abrupt("return",(0,t.t0)(t.t1));case 21:if(!c){t.next=27;break}t.t2=Io;t.next=25;return w(r,1,u);case 25:t.t3=t.sent.car;return t.abrupt("return",(0,t.t2)(t.t3));case 27:t.t4=Io;t.next=30;return w(r,-1,u);case 30:t.t5=t.sent.car;return t.abrupt("return",(0,t.t4)(t.t5));case 32:case"end":return t.stop()}}},e,this)}));return function(e,t){return r.apply(this,arguments)}}()}function Ku(e,t){this.__env__=t;this.__fn__=e;this.__defmacro__=true}Ku.__merge_env__=Symbol["for"]("merge");Ku.prototype=Object.create(Vu.prototype);Ku.prototype.invoke=function(e,t,r){var n=t.error,i=t.env;var u={error:n,env:i,dynamic_scope:this.__env__,macro_expand:r};return this.__fn__.call(i,e,u,this.__name__||"syntax")};Ku.prototype.constructor=Ku;Ku.prototype.toString=function(){if(this.__name__){return"#")}return"#"};Ku.className="syntax";var Gu=function(e){u(r,e);var t=fn(r);function r(){D(this,r);return t.apply(this,arguments)}return A(r)}(Ku);Ku.Parameter=Gu;function Hu(e,t,w,D){var r=arguments.length>4&&arguments[4]!==undefined?arguments[4]:{};var E={"...":{symbols:{},lists:[]},symbols:{}};var A=r.expansion,k=r.define;function x(e){if(Cn()){console.log(e)}}x(w);function F(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;x({code:t&&Pu(t,true),pattern:e&&Pu(e,true)});if(qu(e)&&!(e instanceof L)){return Mu(e,t)}if(e instanceof L&&w.includes(e.literal())){var c=A.ref(t);if(L.is(t,e)){if(typeof c==="undefined"){return true}return c===k||c===qo}return false}if(e instanceof M&&e.car instanceof M&&e.car.cdr instanceof M&&L.is(e.car.cdr.car,D)){x(">> 0");if(t===U){x({pattern:e.toString()});if(e.car.car instanceof L){if(e.car.cdr instanceof M&&L.is(e.car.cdr.car,D)){var f=e.car.car.valueOf();var l=e.last_pair();if(L.is(l.car,D)){E["..."].symbols[f]=null;return true}else{return false}}var h=e.car.car.valueOf();if(E["..."].symbols[h]){throw new Error("syntax: named ellipsis can only "+"appear onces")}E["..."].symbols[h]=t}}}if(e instanceof M&&e.cdr instanceof M&&L.is(e.cdr.car,D)){if(e.cdr.cdr!==U){if(e.cdr.cdr instanceof M){var p=e.cdr.cdr.length();var _=t.length();var i=t;while(_-1>p){i=i.cdr;_--}var d=i.cdr;i.cdr=U;if(!F(e.cdr.cdr,d,r,n)){return false}}}if(e.car instanceof L){var u=e.car.__name__;if(E["..."].symbols[u]&&!r.includes(u)&&!n){throw new Error("syntax: named ellipsis can only appear onces")}x(">> 1");if(t===U){x(">> 2");if(n){x("NIL");E["..."].symbols[u]=U}else{x("NULL");E["..."].symbols[u]=null}}else if(t instanceof M&&(t.car instanceof M||t.car===U)){x(">> 3 "+n);if(n){if(E["..."].symbols[u]){var a=E["..."].symbols[u];if(a===U){a=new M(U,new M(t,U))}else{a=a.append(new M(t,U))}E["..."].symbols[u]=a}else{E["..."].symbols[u]=new M(t,U)}}else{x(">> 4");E["..."].symbols[u]=new M(t,U)}}else{x(">> 6");if(t instanceof M){x(">> 7 "+n);r.push(u);if(!E["..."].symbols[u]){E["..."].symbols[u]=new M(t,U)}else{var v=E["..."].symbols[u];E["..."].symbols[u]=v.append(new M(t,U))}x({IIIIII:E["..."].symbols[u].toString()})}else{x(">> 8");return false}}return true}else if(e.car instanceof M){var y=q(r);if(t===U){x(">> 9");E["..."].lists.push(U);return true}x(">> 10");var m=t;while(m instanceof M){if(!F(e.car,m.car,y,true)){return false}m=m.cdr}return true}return false}if(e instanceof L){if(L.is(e,D)){throw new Error("syntax: invalid usage of ellipsis")}x(">> 11");var o=e.__name__;if(w.includes(o)){return true}x({name:o,ellipsis:n});if(n){E["..."].symbols[o]=E["..."].symbols[o]||[];E["..."].symbols[o].push(t)}E.symbols[o]=t;if(!E.symbols[o]);return true}if(e instanceof M&&t instanceof M){x(">> 12");x({a:12,code:t&&t.toString(),pattern:e.toString()});if(t.cdr===U){var g=e.car instanceof L&&e.cdr instanceof L;if(g){if(!F(e.car,t.car,r,n)){return false}x(">> 12 | 1");var s=e.cdr.valueOf();if(!(s in E.symbols)){E.symbols[s]=U}s=e.car.valueOf();if(!(s in E.symbols)){E.symbols[s]=t.car}return true}}x({pattern:e.toString(),code:t.toString()});if(e.cdr instanceof M&&e.car instanceof L&&e.cdr.cdr instanceof M&&e.cdr.car instanceof L&&L.is(e.cdr.cdr.car,D)&&e.cdr.cdr.cdr instanceof M&&!L.is(e.cdr.cdr.cdr.car,D)&&F(e.car,t.car,r,n)&&F(e.cdr.cdr.cdr,t.cdr,r,n)){var b=e.cdr.car.__name__;x({pattern:e.car.toString(),code:t.car.toString(),name:b});if(w.includes(b)){return true}E["..."].symbols[b]=null;return true}x("recur");if(F(e.car,t.car,r,n)&&F(e.cdr,t.cdr,r,n)){return true}}else if(e===U&&(t===U||t===undefined)){return true}else if(e.car instanceof M&&L.is(e.car.car,D)){throw new Error("syntax: invalid usage of ellipsis")}else{return false}}if(F(e,t)){return E}}function Wu(e,i){function u(t){if(t instanceof M){if(!i.length){return t}var e=u(t.car);var r=u(t.cdr);return new M(e,r)}else if(t instanceof L){var n=i.find(function(e){return e.gensym===t});if(n){return L(n.name)}return t}else{return t}}return u(e)}function Qu(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var O=e.bindings,t=e.expr,S=e.scope,a=e.symbols,f=e.names,B=e.ellipsis;var c={};function o(e){if(e instanceof L){return true}return["string","symbol"].includes(_(e))}function j(e){if(!o(e)){var t=us(e);throw new Error("syntax: internal error, need symbol got ".concat(t))}var r=e.valueOf();if(r===B){throw new Error("syntax: internal error, ellipis not transformed")}var n=_(r);if(["string","symbol"].includes(n)){if(r in O.symbols){return O.symbols[r]}else if(n==="string"&&r.match(/\./)){var i=r.split(".");var u=i[0];if(u in O.symbols){return M.fromArray([L("."),O.symbols[u]].concat(i.slice(1).map(function(e){return $a(e)})))}}}if(a.includes(r)){return L(r)}return s(r)}function I(e){if(Cn()){console.log(e)}}function s(e){if(!c[e]){var t=S.ref(e);var r=Fi(e);if(t){var n=S.get(e);S.set(r,n)}else{var i=S.get(e,{throwError:false});if(typeof i!=="undefined"){S.set(r,i)}}f.push({name:e,gensym:r});c[e]=r;if(typeof e==="string"&&e.match(/\./)){var u=e.split(".").filter(Boolean),a=m(u),o=a[0],s=a.slice(1);if(c[o]){Fa(r,"__object__",[c[o]].concat(q(s)))}}}return c[e]}function P(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:function(){};var i=r.nested;I(" ==> "+e.toString(true));I(t);if(e instanceof L){var u=e.valueOf();I("[t 1");if(t[u]){if(t[u]instanceof M){var c=t[u],f=c.car,l=c.cdr;if(i){var h=f.car,p=f.cdr;if(p!==U){n(u,new M(p,U))}return h}if(l!==U){n(u,l)}return f}else if(t[u]instanceof Array){n(u,t[u].slice(1));return t[u][0]}}return j(u)}if(e instanceof M){if(e.car instanceof L&&e.cdr instanceof M&&L.is(e.cdr.car,B)){I("[t 2");var a=e.car.valueOf();var o=t[a];I({expr:e.toString(true),name:a,bindings:t,item:o});if(o===null){return}else if(o){I({b:t[a].toString()});if(o instanceof M){I("[t 2 Pair "+i);I({______:o.toString()});var s=o.car,_=o.cdr;if(i){if(_!==U){I("|| next 1");n(a,_)}I({car:s.toString()});return s}else{if(s.cdr!==U){I("|| next 2");n(a,new M(s.cdr,_))}I({car:s.car.toString()});return s.car}}else if(o instanceof Array){I("[t 2 Array "+i);if(i){n(a,o.slice(1));return M.fromArray(o)}else{var d=o.slice(1);if(d.length){n(a,d)}return o[0]}}else{return o}}}I("[t 3 recur "+e.toString());var v=P(e.car,t,r,n);var y=P(e.cdr,t,r,n);return new M(v,y)}return e}function R(t,r){var e=Object.values(t);var n=Object.getOwnPropertySymbols(t);if(n.length){e.push.apply(e,q(n.map(function(e){return t[e]})))}return e.length&&e.every(function(e){if(e===null){return!r}return e instanceof M||e===U||e instanceof Array&&e.length})}function T(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function N(i){var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},e=n.disabled;I("traverse>> "+Pu(i));if(i instanceof M){if(!e&&i.car instanceof M&&L.is(i.car.car,B)){return N(i.car.cdr,{disabled:true})}if(i.cdr instanceof M&&L.is(i.cdr.car,B)&&!e){I(">> 1");var t=O["..."].symbols;var f=Object.values(t);if(f.length&&f.every(function(e){return e===null})){return N(i.cdr.cdr,{disabled:e})}var l=T(t);var u=i.car instanceof L&&L.is(i.cdr.cdr.car,B);if(i.car instanceof M||u){if(O["..."].lists[0]===U){return U}var h=i.car;if(u){h=new M(i.car,new M(i.cdr.car,U))}I(">> 2");var a;if(l.length){I(">> 2 (a)");var o=vn({},t);a=U;var p=function e(){if(!R(o)){return"break"}var n={};var t=function e(t,r){n[t]=r};var r=P(h,o,{nested:true},t);if(r!==undefined){if(u){if(a===U){a=r}else{a=a.append(r)}}else{a=new M(r,a)}}o=n};while(true){var _=p();if(_==="break")break}if(a!==U&&!u){a=a.reverse()}if(i.cdr.cdr!==U&&!L.is(i.cdr.cdr.car,B)){var d=N(i.cdr.cdr,{disabled:e});return a.append(d)}return a}else{I(">> 3");var v=P(i.car,t,{nested:true});if(v){return new M(v,U)}return U}}else if(i.car instanceof L){I(">> 4");if(L.is(i.cdr.cdr.car,B)){I(">> 4 (a)")}else{I(">> 4 (b)")}var y=i.car.__name__;var s=Y({},y,t[y]);var m=t[y]===null;var c=U;var g=function e(){if(!R(s,true)){I({bind:s});return"break"}var n={};var t=function e(t,r){n[t]=r};var r=P(i,s,{nested:false},t);I({value:r.toString()});if(typeof r!=="undefined"){c=new M(r,c)}s=n};while(true){var b=g();if(b==="break")break}if(c!==U){c=c.reverse()}if(i.cdr instanceof M){if(i.cdr.cdr instanceof M||i.cdr.cdr instanceof L){var w=N(i.cdr.cdr,{disabled:e});if(m){return w}I("<<<< 1");c.append(w)}}I("<<<< 2");return c}}var D=N(i.car,{disabled:e});var r;var E;if(i.car instanceof L){var A=S.get(i.car,{throwError:false});E=A instanceof Vu&&A.__name__==="syntax-rules"}if(E){if(i.cdr.car instanceof L){r=new M(N(i.cdr.car,{disabled:e}),new M(i.cdr.cdr.car,N(i.cdr.cdr.cdr,{disabled:e})))}else{r=new M(i.cdr.car,N(i.cdr.cdr,{disabled:e}))}I("REST >>>> "+r.toString())}else{r=N(i.cdr,{disabled:e})}I({a:true,car:Pu(i.car),cdr:Pu(i.cdr),head:Pu(D),rest:Pu(r)});return new M(D,r)}if(i instanceof L){if(e&&L.is(i,B)){return i}var x=Object.keys(O["..."].symbols);var F=i.literal();if(x.includes(F)){var k="missing ellipsis symbol next to name `".concat(F,"'");throw new Error("syntax-rules: ".concat(k))}var C=j(i);if(typeof C!=="undefined"){return C}}return i}return N(t,{})}function Zu(e){return na(e)||e===U||e===null}function Xu(e){return typeof e==="function"&&typeof e.bind==="function"}function ea(e){return e instanceof hs}function ta(e){return Xu(e)||ea(e)}function ra(e){if(e instanceof ki){return false}if(e instanceof Promise){return true}return e&&Xu(e.then)}function na(e){return typeof e==="undefined"}function ia(e){switch(_(e)){case"string":return $a(e);case"bigint":return C(e);case"number":if(Number.isNaN(e)){return Uo}else{return C(e)}}return e}function ua(n,i){var e=Object.getOwnPropertyNames(n);var t=Object.getOwnPropertySymbols(n);e.concat(t).forEach(function(e){var t=i(n[e]);var r=Object.getOwnPropertyDescriptor(n,e);if(!r||r.writable&&n[e]!==t){n[e]=t}});return n}function aa(t){var e=[$a,C].some(function(e){return t instanceof e});if(e){return t.valueOf()}if(t instanceof Array){return t.map(aa)}if(t instanceof ki){delete t.then}if(wu(t)){return ua(t,aa)}return t}function oa(e,t){if(e instanceof M){e.markCycles();return Io(e)}if(Xu(e)){if(t){return ca(e,t)}}return ia(e)}function sa(e){if(la(e)){return e[va]}return e}function ca(e,t){if(e[Symbol["for"]("__bound__")]){return e}var r=e.bind(t);var n=Object.getOwnPropertyNames(e);var i=hn(n),u;try{for(i.s();!(u=i.n()).done;){var a=u.value;if(xa(a)){try{r[a]=e[a]}catch(e){}}}}catch(e){i.e(e)}finally{i.f()}Fa(r,"__fn__",e);Fa(r,"__context__",t);Fa(r,"__bound__",true);if(Ba(e)){Fa(r,"__native__",true)}if(wu(t)&&Ca(e)){Fa(r,"__method__",true)}r.valueOf=function(){return e};return r}function fa(e){return la(e)&&e[Symbol["for"]("__context__")]===Object}function la(e){return!!(Xu(e)&&e[va])}function ha(e){if(Xu(e)){var t=e[da];if(t&&(t===Gs||t.constructor&&t.constructor.__class__)){return true}}return false}function pa(e){return e instanceof ho||e instanceof po}function _a(e){if(Xu(e)){if(pa(e[da])){return true}}return false}var da=Symbol["for"]("__context__");var va=Symbol["for"]("__fn__");var ya=Symbol["for"]("__data__");var ma=Symbol["for"]("__ref__");var ga=Symbol["for"]("__cycles__");var ba=Symbol["for"]("__class__");var wa=Symbol["for"]("__method__");var Da=Symbol["for"]("__prototype__");var Ea=Symbol["for"]("__lambda__");var Aa=["name","length","caller","callee","arguments","prototype"];function xa(e){return!Aa.includes(e)}function Fa(e,t,r){Object.defineProperty(e,Symbol["for"](t),{get:function e(){return r},set:function e(){},configurable:false,enumerable:false})}function ka(t,r){try{Object.defineProperty(t,"length",{get:function e(){return r}});return t}catch(e){var n=new Array(r).fill(0).map(function(e,t){return"a"+t}).join(",");var i=new Function("f","return function(".concat(n,") {\n return f.apply(this, arguments);\n };"));return i(t)}}function Ca(e){return e&&e[Ea]}function Oa(e){return e&&e[wa]}function Sa(e){return Ca(e)&&!e[Da]&&!Oa(e)&&!_a(e)}function Ba(e){var t=Symbol["for"]("__native__");return Xu(e)&&e.toString().match(/\{\s*\[native code\]\s*\}/)&&(e.name.match(/^bound /)&&e[t]===true||!e.name.match(/^bound /)&&!e[t])}function ja(e){var g;switch(e){case Symbol["for"]("letrec"):g="letrec";break;case Symbol["for"]("let"):g="let";break;case Symbol["for"]("let*"):g="let*";break;default:throw new Error("Invalid let_macro value")}return Vu.defmacro(g,function(t,e){var f=e.dynamic_scope,l=e.error,n=e.macro_expand;var h;if(t.car instanceof L){if(!(t.cdr.car instanceof M||t.cdr.car===U)){throw new Error("let require list of pairs")}var r;if(t.cdr.car===U){h=U;r=U}else{r=t.cdr.car.map(function(e){return e.car});h=t.cdr.car.map(function(e){return e.cdr.car})}return M.fromArray([L("letrec"),[[t.car,M(L("lambda"),M(r,t.cdr.cdr))]],M(t.car,h)])}else if(n){return}var p=this;h=qo.get("list->array")(t.car);var _=p.inherit(g);var d,v;if(g==="let*"){v=_}else if(g==="let"){d=[]}var y=0;function m(){var e=new M(new L("begin"),t.cdr);return _s(e,{env:_,dynamic_scope:f,error:l})}return function t(){var r=h[y++];if(f){f=g==="let*"?_:p}if(!r){if(d&&d.length){var e=d.map(function(e){return e.value});var n=e.filter(ra);if(n.length){return Ci(e).then(function(e){for(var t=0,r=e.length;t1&&arguments[1]!==undefined?arguments[1]:{},r=t.dynamic_scope,n=t.error;var i=this;if(r){r=this}var u=e;var a=[];while(u instanceof M){a.push(_s(u.car,{env:i,dynamic_scope:r,error:n}));u=u.cdr}var o=a.filter(ra).length;if(o){return Ci(a).then(s.bind(this))}else{return s.call(this,a)}})}function Pa(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n2?n-2:0),u=2;u1&&arguments[1]!==undefined?arguments[1]:null;return function(){for(var e=arguments.length,t=new Array(e),r=0;r1?e-1:0),r=1;r=a){return u.apply(this,n)}else{return i}}return i.apply(this,arguments)}}function Va(n,i){h("limit",i,"function",2);return function(){for(var e=arguments.length,t=new Array(e),r=0;r1){e=e.toLowerCase();if(za.__names__[e]){t=e;e=za.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{t=za.__rev_names__[e]}Object.defineProperty(this,"__char__",{value:e,enumerable:true});if(t){Object.defineProperty(this,"__name__",{value:t,enumerable:true})}}za.__names__=Un;za.__rev_names__={};Object.keys(za.__names__).forEach(function(e){var t=za.__names__[e];za.__rev_names__[t]=e});za.prototype.toUpperCase=function(){return za(this.__char__.toUpperCase())};za.prototype.toLowerCase=function(){return za(this.__char__.toLowerCase())};za.prototype.toString=function(){return"#\\"+(this.__name__||this.__char__)};za.prototype.valueOf=za.prototype.serialize=function(){return this.__char__};function $a(e){if(typeof this!=="undefined"&&!(this instanceof $a)||typeof this==="undefined"){return new $a(e)}if(e instanceof Array){this.__string__=e.map(function(e,t){h("LString",e,"character",t+1);return e.toString()}).join("")}else{this.__string__=e.valueOf()}}{var Ja=["length","constructor"];var Ka=Object.getOwnPropertyNames(String.prototype).filter(function(e){return!Ja.includes(e)});var Ga=function e(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r0){r.push(this.__string__.substring(0,e))}r.push(t);if(e1&&arguments[1]!==undefined?arguments[1]:false;if(e instanceof C){return e}if(typeof this!=="undefined"&&!(this instanceof C)||typeof this==="undefined"){return new C(e,t)}if(typeof e==="undefined"){throw new Error("Invalid LNumber constructor call")}var r=C.getType(e);if(C.types[r]){return C.types[r](e,t)}var n=e instanceof Array&&$a.isString(e[0])&&C.isNumber(e[1]);if(e instanceof C){return C(e.value)}if(!C.isNumber(e)&&!n){throw new Error("You can't create LNumber from ".concat(us(e)))}if(e===null){e=0}var i;if(n){var c=e,u=j(c,2),a=u[0],o=u[1];if(a instanceof $a){a=a.valueOf()}if(o instanceof C){o=o.valueOf()}var f=a.match(/^([+-])/);var l=false;if(f){a=a.replace(/^[+-]/,"");if(f[1]==="-"){l=true}}}if(Number.isNaN(e)){return uo(e)}else if(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(n){var s;switch(o){case 8:s="0o";break;case 16:s="0x";break;case 2:s="0b";break;case 10:s="";break}if(typeof s==="undefined"){var h=BigInt(o);i=q(a).map(function(e,t){return BigInt(parseInt(e,o))*ro(h,BigInt(t))}).reduce(function(e,t){return e+t})}else{i=BigInt(s+a)}}else{i=BigInt(e)}if(l){i*=BigInt(-1)}}else{i=e}return lo(i,true)}else if(typeof xn!=="undefined"&&!(e instanceof xn)){if(e instanceof Array){return lo(p(xn,q(e)))}return lo(new xn(e))}else if(n){this.constant(parseInt(a,o),"integer")}else{this.constant(e,"integer")}}C.prototype.constant=function(e,t){Object.defineProperty(this,"__value__",{value:e,enumerable:true});Object.defineProperty(this,"__type__",{value:t,enumerable:true})};C.types={float:function e(t){return new uo(t)},complex:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!C.isComplex(t)){t={im:0,re:t}}return new io(t,r)},rational:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!C.isRational(t)){t={num:t,denom:1}}return new fo(t,r)}};C.prototype.serialize=function(){return this.__value__};C.prototype.isNaN=function(){return Number.isNaN(this.__value__)};C.prototype.gcd=function(e){var t=this.abs();e=e.abs();if(e.cmp(t)===1){var r=t;t=e;e=r}while(true){t=t.rem(e);if(t.cmp(0)===0){return e}e=e.rem(t);if(e.cmp(0)===0){return t}}};C.isFloat=function e(t){return t instanceof uo||Number(t)===t&&t%1!==0};C.isNumber=function(e){return e instanceof C||C.isNative(e)||C.isBN(e)};C.isComplex=function(e){if(!e){return false}var t=e instanceof io||(C.isNumber(e.im)||Number.isNaN(e.im))&&(C.isNumber(e.re)||Number.isNaN(e.re));return t};C.isRational=function(e){if(!e){return false}return e instanceof fo||C.isNumber(e.num)&&C.isNumber(e.denom)};C.isInteger=function(e){if(!(C.isNative(e)||e instanceof C)){return false}if(C.isFloat(e)){return false}if(C.isRational(e)){return false}if(C.isComplex(e)){return false}return true};C.isNative=function(e){return typeof e==="bigint"||typeof e==="number"};C.isBigInteger=function(e){return e instanceof lo||typeof e==="bigint"||C.isBN(e)};C.isBN=function(e){return typeof xn!=="undefined"&&e instanceof xn};C.getArgsType=function(e,t){if(e instanceof uo||t instanceof uo){return uo}if(e instanceof lo||t instanceof lo){return lo}return C};C.prototype.toString=function(e){if(Number.isNaN(this.__value__)){return"+nan.0"}if(e>2&&e<36){return this.__value__.toString(e)}return this.__value__.toString()};C.prototype.asType=function(e){var t=C.getType(this);return C.types[t]?C.types[t](e):C(e)};C.prototype.isBigNumber=function(){return typeof this.__value__==="bigint"||typeof xn!=="undefined"&&!(this.value instanceof xn)};["floor","ceil","round"].forEach(function(e){C.prototype[e]=function(){if(this["float"]||C.isFloat(this.__value__)){return C(Math[e](this.__value__))}else{return C(Math[e](this.valueOf()))}}});C.prototype.valueOf=function(){if(C.isNative(this.__value__)){return Number(this.__value__)}else if(C.isBN(this.__value__)){return this.__value__.toNumber()}};var Za=function(){var e=function e(t,r){return[t,r]};return{bigint:{bigint:e,float:function e(t,r){return[uo(t.valueOf()),r]},rational:function e(t,r){return[{num:t,denom:1},r]},complex:function e(t,r){return[{im:0,re:t},r]}},integer:{integer:e,float:function e(t,r){return[uo(t.valueOf()),r]},rational:function e(t,r){return[{num:t,denom:1},r]},complex:function e(t,r){return[{im:0,re:t},r]}},float:{bigint:function e(t,r){return[t,r&&uo(r.valueOf())]},integer:function e(t,r){return[t,r&&uo(r.valueOf())]},float:e,rational:function e(t,r){return[t,r&&uo(r.valueOf())]},complex:function e(t,r){return[{re:t,im:uo(0)},r]}},complex:{bigint:t("bigint"),integer:t("integer"),float:t("float"),rational:t("rational"),complex:function f(e,t){var r=C.coerce(e.__re__,t.__re__),n=j(r,2),i=n[0],u=n[1];var a=C.coerce(e.__im__,t.__im__),o=j(a,2),s=o[0],c=o[1];return[{im:s,re:i},{im:c,re:u}]}},rational:{bigint:function e(t,r){return[t,r&&{num:r,denom:1}]},integer:function e(t,r){return[t,r&&{num:r,denom:1}]},float:function e(t,r){return[uo(t.valueOf()),r]},rational:e,complex:function e(t,r){return[{im:Xa(t.__type__,r.__im__.__type__,0)[0],re:Xa(t.__type__,r.__re__.__type__,t)[0]},{im:Xa(t.__type__,r.__im__.__type__,r.__im__)[0],re:Xa(t.__type__,r.__re__.__type__,r.__re__)[0]}]}}};function t(r){return function(e,t){return[{im:Xa(r,e.__im__.__type__,0,e.__im__)[1],re:Xa(r,e.__re__.__type__,0,e.__re__)[1]},{im:Xa(r,e.__im__.__type__,0,0)[1],re:Xa(r,t.__type__,0,t)[1]}]}}}();function Xa(e,t,r,n){return Za[e][t](r,n)}C.coerce=function(e,t){var r=C.getType(e);var n=C.getType(t);if(!Za[r]){throw new Error("LNumber::coerce unknown lhs type ".concat(r))}else if(!Za[r][n]){throw new Error("LNumber::coerce unknown rhs type ".concat(n))}var i=Za[r][n](e,t);return i.map(function(e){return C(e,true)})};C.prototype.coerce=function(e){if(!(typeof e==="number"||e instanceof C)){throw new Error("LNumber: you can't coerce ".concat(us(e)))}if(typeof e==="number"){e=C(e)}return C.coerce(this,e)};C.getType=function(e){if(e instanceof C){return e.__type__}if(C.isFloat(e)){return"float"}if(C.isComplex(e)){return"complex"}if(C.isRational(e)){return"rational"}if(typeof e==="number"){return"integer"}if(typeof BigInt!=="undefined"&&typeof e!=="bigint"||typeof xn!=="undefined"&&!(e instanceof xn)){return"bigint"}};C.prototype.isFloat=function(){return!!(C.isFloat(this.__value__)||this["float"])};var eo={add:"+",sub:"-",mul:"*",div:"/",rem:"%",or:"|",and:"&",neg:"~",shl:">>",shr:"<<"};var to={};Object.keys(eo).forEach(function(t){to[eo[t]]=t;C.prototype[t]=function(e){return this.op(eo[t],e)}});C._ops={"*":function e(t,r){return t*r},"+":function e(t,r){return t+r},"-":function e(t,r){if(typeof r==="undefined"){return-t}return t-r},"/":function e(t,r){return t/r},"%":function e(t,r){return t%r},"|":function e(t,r){return t|r},"&":function e(t,r){return t&r},"~":function e(t){return~t},">>":function e(t,r){return t>>r},"<<":function e(t,r){return t<1&&arguments[1]!==undefined?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof io)||typeof this==="undefined"){return new io(e,t)}if(e instanceof io){return io({im:e.__im__,re:e.__re__})}if(C.isNumber(e)&&t){if(!t){return Number(e)}}else if(!C.isComplex(e)){var r="Invalid constructor call for LComplex expect &(:im :re ) object but got ".concat(Pu(e));throw new Error(r)}var n=e.im instanceof C?e.im:C(e.im);var i=e.re instanceof C?e.re:C(e.re);this.constant(n,i)}io.prototype=Object.create(C.prototype);io.prototype.constructor=io;io.prototype.constant=function(e,t){Object.defineProperty(this,"__im__",{value:e,enumerable:true});Object.defineProperty(this,"__re__",{value:t,enumerable:true});Object.defineProperty(this,"__type__",{value:"complex",enumerable:true})};io.prototype.serialize=function(){return{re:this.__re__,im:this.__im__}};io.prototype.toRational=function(e){if(C.isFloat(this.__im__)&&C.isFloat(this.__re__)){var t=uo(this.__im__).toRational(e);var r=uo(this.__re__).toRational(e);return io({im:t,re:r})}return this};io.prototype.pow=function(e){throw new Error("Not yet implemented")};io.prototype.add=function(e){return this.complex_op("add",e,function(e,t,r,n){return{re:e.add(t),im:r.add(n)}})};io.prototype.factor=function(){if(this.__im__ instanceof uo||this.__im__ instanceof uo){var e=this.__re__,t=this.__im__;var r,n;if(e instanceof uo){r=e.toRational().mul(e.toRational())}else{r=e.mul(e)}if(t instanceof uo){n=t.toRational().mul(t.toRational())}else{n=t.mul(t)}return r.add(n)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};io.prototype.modulus=function(){return this.factor().sqrt()};io.prototype.conjugate=function(){return io({re:this.__re__,im:this.__im__.sub()})};io.prototype.sqrt=function(){var e=this.modulus();var t,r;if(e.cmp(0)===0){t=r=e}else if(this.__re__.cmp(0)===1){t=uo(.5).mul(e.add(this.__re__)).sqrt();r=this.__im__.div(t).div(2)}else{r=uo(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){r=r.sub()}t=this.__im__.div(r).div(2)}return io({im:r,re:t})};io.prototype.div=function(e){if(C.isNumber(e)&&!C.isComplex(e)){if(!(e instanceof C)){e=C(e)}var t=this.__re__.div(e);var r=this.__im__.div(e);return io({re:t,im:r})}else if(!C.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}if(this.cmp(e)===0){var n=this.coerce(e),i=j(n,2),f=i[0],u=i[1];var l=f.__im__.div(u.__im__);return l.coerce(u.__re__)[0]}var h=this.coerce(e),a=j(h,2),p=a[0],o=a[1];var s=o.factor();var _=o.conjugate();var c=p.mul(_);if(!C.isComplex(c)){return c.div(s)}var d=c.__re__.op("/",s);var v=c.__im__.op("/",s);return io({re:d,im:v})};io.prototype.sub=function(e){return this.complex_op("sub",e,function(e,t,r,n){return{re:e.sub(t),im:r.sub(n)}})};io.prototype.mul=function(e){return this.complex_op("mul",e,function(e,t,r,n){var i={re:e.mul(t).sub(r.mul(n)),im:e.mul(n).add(t.mul(r))};return i})};io.prototype.complex_op=function(e,t,i){var u=this;var r=function e(t,r){var n=i(u.__re__,t,u.__im__,r);if("im"in n&&"re"in n){if(n.im.cmp(0)===0){return n.re}return io(n,true)}return n};if(typeof t==="undefined"){return r()}if(C.isNumber(t)&&!C.isComplex(t)){if(!(t instanceof C)){t=C(t)}var n=t.asType(0);t={__im__:n,__re__:t}}else if(!C.isComplex(t)){throw new Error("[LComplex::".concat(e,"] Invalid value"))}var a=t.__re__ instanceof C?t.__re__:this.__re__.asType(t.__re__);var o=t.__im__ instanceof C?t.__im__:this.__im__.asType(t.__im__);return r(a,o)};io._op={"+":"add","-":"sub","*":"mul","/":"div"};io.prototype._op=function(e,t){var r=io._op[e];return this[r](t)};io.prototype.cmp=function(e){var t=this.coerce(e),r=j(t,2),n=r[0],i=r[1];var u=n.__re__.coerce(i.__re__),a=j(u,2),o=a[0],f=a[1];var s=o.cmp(f);if(s!==0){return s}else{var l=n.__im__.coerce(i.__im__),c=j(l,2),h=c[0],p=c[1];return h.cmp(p)}};io.prototype.valueOf=function(){return[this.__re__,this.__im__].map(function(e){return e.valueOf()})};io.prototype.toString=function(){var e;if(this.__re__.cmp(0)!==0){e=[Pu(this.__re__)]}else{e=[]}var t=this.__im__.valueOf();var r=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(t);var n=Pu(this.__im__);if(!r&&!Number.isNaN(t)){var i=this.__im__.cmp(0);if(i<0||i===0&&this.__im__._minus){e.push("-")}else{e.push("+")}n=n.replace(/^-/,"")}e.push(n);e.push("i");return e.join("")};function uo(e){if(typeof this!=="undefined"&&!(this instanceof uo)||typeof this==="undefined"){return new uo(e)}if(!C.isNumber(e)){throw new Error("Invalid constructor call for LFloat")}if(e instanceof C){return uo(e.valueOf())}if(typeof e==="number"){if(Object.is(e,-0)){Object.defineProperty(this,"_minus",{value:true})}this.constant(e,"float")}}uo.prototype=Object.create(C.prototype);uo.prototype.constructor=uo;uo.prototype.toString=function(){if(this.__value__===Number.NEGATIVE_INFINITY){return"-inf.0"}if(this.__value__===Number.POSITIVE_INFINITY){return"+inf.0"}if(Number.isNaN(this.__value__)){return"+nan.0"}var e=this.__value__.toString();if(!C.isFloat(this.__value__)&&!e.match(/e/i)){var t=e+".0";return this._minus?"-"+t:t}return e.replace(/^([0-9]+)e/,"$1.0e")};uo.prototype._op=function(e,t){if(t instanceof C){t=t.__value__}var r=C._ops[e];if(e==="/"&&this.__value__===0&&t===0){return NaN}return uo(r(this.__value__,t))};uo.prototype.toRational=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){return ao(this.__value__.valueOf())}return oo(e.valueOf())(this.__value__.valueOf())};uo.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){var t=uo(Math.sqrt(-e));return io({re:0,im:t})}return uo(Math.sqrt(e))};uo.prototype.abs=function(){var e=this.valueOf();if(e<0){e=-e}return uo(e)};var ao=oo(1e-10);function oo(n){return function(e){var t=function e(n,t,r){var i=function e(t,r){return r0){i=co(n,r)}else if(n.cmp(r)<=0){i=r}else if(r.cmp(0)>0){i=co(r,n)}else if(t.cmp(0)<0){i=C(co(n.sub(),r.sub())).sub()}else{i=C(0)}if(C.isFloat(t)||C.isFloat(e)){return uo(i)}return i}function co(e,t){var r=C(e).floor();var n=C(t).floor();if(e.cmp(r)<1){return r}else if(r.cmp(n)===0){var i=C(1).div(t.sub(n));var u=C(1).div(e.sub(r));return r.add(C(1).div(co(i,u)))}else{return r.add(C(1))}}function fo(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof fo)||typeof this==="undefined"){return new fo(e,t)}if(!C.isRational(e)){throw new Error("Invalid constructor call for LRational")}var r,n;if(e instanceof fo){r=C(e.__num__);n=C(e.__denom__)}else{r=C(e.num);n=C(e.denom)}if(!t&&n.cmp(0)!==0){var i=r.op("%",n).cmp(0)===0;if(i){return C(r.div(n))}}this.constant(r,n)}fo.prototype=Object.create(C.prototype);fo.prototype.constructor=fo;fo.prototype.constant=function(e,t){Object.defineProperty(this,"__num__",{value:e,enumerable:true});Object.defineProperty(this,"__denom__",{value:t,enumerable:true});Object.defineProperty(this,"__type__",{value:"rational",enumerable:true})};fo.prototype.serialize=function(){return{num:this.__num__,denom:this.__denom__}};fo.prototype.pow=function(e){var t=e.cmp(0);if(t===0){return C(1)}if(t===-1){e=e.sub();var r=this.__denom__.pow(e);var n=this.__num__.pow(e);return fo({num:r,denom:n})}var i=this;e=e.valueOf();while(e>1){i=i.mul(this);e--}return i};fo.prototype.sqrt=function(){var e=this.__num__.sqrt();var t=this.__denom__.sqrt();if(e instanceof uo||t instanceof uo){return e.div(t)}return fo({num:e,denom:t})};fo.prototype.abs=function(){var e=this.__num__;var t=this.__denom__;if(e.cmp(0)===-1){e=e.sub()}if(t.cmp(0)!==1){t=t.sub()}return fo({num:e,denom:t})};fo.prototype.cmp=function(e){return C(this.valueOf(),true).cmp(e)};fo.prototype.toString=function(){var e=this.__num__.gcd(this.__denom__);var t,r;if(e.cmp(1)!==0){t=this.__num__.div(e);if(t instanceof fo){t=C(t.valueOf(true))}r=this.__denom__.div(e);if(r instanceof fo){r=C(r.valueOf(true))}}else{t=this.__num__;r=this.__denom__}var n=this.cmp(0)<0;if(n){if(t.abs().cmp(r.abs())===0){return t.toString()}}else if(t.cmp(r)===0){return t.toString()}return t.toString()+"/"+r.toString()};fo.prototype.valueOf=function(e){if(this.__denom__.cmp(0)===0){if(this.__num__.cmp(0)<0){return Number.NEGATIVE_INFINITY}return Number.POSITIVE_INFINITY}if(e){return C._ops["/"](this.__num__.value,this.__denom__.value)}return uo(this.__num__.valueOf()).div(this.__denom__.valueOf())};fo.prototype.mul=function(e){if(!(e instanceof C)){e=C(e)}if(C.isRational(e)){var t=this.__num__.mul(e.__num__);var r=this.__denom__.mul(e.__denom__);return fo({num:t,denom:r})}var n=C.coerce(this,e),i=j(n,2),u=i[0],a=i[1];return u.mul(a)};fo.prototype.div=function(e){if(!(e instanceof C)){e=C(e)}if(C.isRational(e)){var t=this.__num__.mul(e.__denom__);var r=this.__denom__.mul(e.__num__);return fo({num:t,denom:r})}var n=C.coerce(this,e),i=j(n,2),u=i[0],a=i[1];var o=u.div(a);return o};fo.prototype._op=function(e,t){return this[to[e]](t)};fo.prototype.sub=function(e){if(typeof e==="undefined"){return this.mul(-1)}if(!(e instanceof C)){e=C(e)}if(C.isRational(e)){var t=e.__num__.sub();var r=e.__denom__;return this.add(fo({num:t,denom:r}))}if(!(e instanceof C)){e=C(e).sub()}else{e=e.sub()}var n=C.coerce(this,e),i=j(n,2),u=i[0],a=i[1];return u.add(a)};fo.prototype.add=function(e){if(!(e instanceof C)){e=C(e)}if(C.isRational(e)){var t=this.__denom__;var r=e.__denom__;var n=this.__num__;var i=e.__num__;var u,a;if(t!==r){a=r.mul(n).add(i.mul(t));u=t.mul(r)}else{a=n.add(i);u=t}return fo({num:a,denom:u})}if(C.isFloat(e)){return uo(this.valueOf()).add(e)}var o=C.coerce(this,e),s=j(o,2),c=s[0],f=s[1];return c.add(f)};function lo(e,t){if(typeof this!=="undefined"&&!(this instanceof lo)||typeof this==="undefined"){return new lo(e,t)}if(e instanceof lo){return lo(e.__value__,e._native)}if(!C.isBigInteger(e)){throw new Error("Invalid constructor call for LBigInteger")}this.constant(e,"bigint");Object.defineProperty(this,"_native",{value:t})}lo.prototype=Object.create(C.prototype);lo.prototype.constructor=lo;lo.bn_op={"+":"iadd","-":"isub","*":"imul","/":"idiv","%":"imod","|":"ior","&":"iand","~":"inot","<<":"ishrn",">>":"ishln"};lo.prototype.serialize=function(){return this.__value__.toString()};lo.prototype._op=function(e,t){if(typeof t==="undefined"){if(C.isBN(this.__value__)){e=lo.bn_op[e];return lo(this.__value__.clone()[e](),false)}return lo(C._ops[e](this.__value__),true)}if(C.isBN(this.__value__)&&C.isBN(t.__value__)){e=lo.bn_op[e];return lo(this.__value__.clone()[e](t),false)}var r=C._ops[e](this.__value__,t.__value__);if(e==="/"){var n=this.op("%",t).cmp(0)===0;if(n){return C(r)}return fo({num:this,denom:t})}return lo(r,true)};lo.prototype.sqrt=function(){var e;var t=this.cmp(0)<0;if(C.isNative(this.__value__)){e=C(Math.sqrt(t?-this.valueOf():this.valueOf()))}else if(C.isBN(this.__value__)){e=t?this.__value__.neg().sqrt():this.__value__.sqrt()}if(t){return io({re:0,im:e})}return e};C.NaN=C(NaN);function ho(e){var n=this;if(typeof this!=="undefined"&&!(this instanceof ho)||typeof this==="undefined"){return new ho(e)}h("InputPort",e,"function");$i(this,"__type__",xo);var i;Object.defineProperty(this,"__parser__",{enumerable:true,get:function e(){return i},set:function e(t){h("InputPort::__parser__",t,"parser");i=t}});this._read=e;this._with_parser=this._with_init_parser.bind(this,B(z.mark(function e(){var r;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(n.char_ready()){t.next=5;break}t.next=3;return n._read();case 3:r=t.sent;i=new Li(r,{env:n});case 5:return t.abrupt("return",n.__parser__);case 6:case"end":return t.stop()}}},e)})));this.char_ready=function(){return!!this.__parser__&&this.__parser__.__lexer__.peek()!==Fo};this._make_defaults()}ho.prototype._make_defaults=function(){this.read=this._with_parser(function(e){return e.read_object()});this.read_line=this._with_parser(function(e){return e.__lexer__.read_line()});this.read_char=this._with_parser(function(e){return e.__lexer__.read_char()});this.read_string=this._with_parser(function(e,t){if(!C.isInteger(t)){var r=C.getType(t);Qo("read-string",r,"integer")}return e.__lexer__.read_string(t.valueOf())});this.peek_char=this._with_parser(function(e){return e.__lexer__.peek_char()})};ho.prototype._with_init_parser=function(o,s){var c=this;return B(z.mark(function e(){var r,n,i,u,a=arguments;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:t.next=2;return o.call(c);case 2:r=t.sent;for(n=a.length,i=new Array(n),u=0;u"};function po(e){if(typeof this!=="undefined"&&!(this instanceof po)||typeof this==="undefined"){return new po(e)}h("OutputPort",e,"function");$i(this,"__type__",xo);this.write=e}po.prototype.is_open=function(){return this._closed!==true};po.prototype.close=function(){Object.defineProperty(this,"_closed",{get:function e(){return true},set:function e(){},configurable:false,enumerable:false});this.write=function(){throw new Error("output-port: port is closed")}};po.prototype.flush=function(){};po.prototype.toString=function(){return"#"};var _o=function(e){u(n,e);var r=fn(n);function n(e){var t;D(this,n);t=r.call(this,function(){var e;return(e=t)._write.apply(e,arguments)});h("BufferedOutputPort",e,"function");$i(i(t),"_fn",e,{hidden:true});$i(i(t),"_buffer",[],{hidden:true});return t}A(n,[{key:"flush",value:function e(){if(this._buffer.length){this._fn(this._buffer.join(""));this._buffer.length=0}}},{key:"_write",value:function e(){var t=this;for(var r=arguments.length,n=new Array(r),i=0;i"};vo.prototype.valueOf=function(){return this.__buffer__.map(function(e){return e.valueOf()}).join("")};function yo(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof yo)||typeof this==="undefined"){return new yo(e,t)}h("OutputFilePort",e,"string");$i(this,"__filename__",e);$i(this,"_fd",t.valueOf(),{hidden:true});$i(this,"__type__",xo);this.write=function(e){if(!$a.isString(e)){e=Pu(e)}else{e=e.valueOf()}r.fs().write(r._fd,e,function(e){if(e){throw e}})}}yo.prototype=Object.create(po.prototype);yo.prototype.constructor=yo;yo.prototype.fs=function(){if(!this._fs){this._fs=this.internal("fs")}return this._fs};yo.prototype.internal=function(e){return Yo.get("**internal-env**").get(e)};yo.prototype.close=function(){var n=this;return new Promise(function(t,r){n.fs().close(n._fd,function(e){if(e){r(e)}else{$i(n,"_fd",null,{hidden:true});po.prototype.close.call(n);t()}})})};yo.prototype.toString=function(){return"#")};function mo(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof mo)||typeof this==="undefined"){return new mo(e)}h("InputStringPort",e,"string");t=t||qo;e=e.valueOf();this._with_parser=this._with_init_parser.bind(this,function(){if(!r.__parser__){r.__parser__=new Li(e,{env:t})}return r.__parser__});$i(this,"__type__",xo);this._make_defaults()}mo.prototype.char_ready=function(){return true};mo.prototype=Object.create(ho.prototype);mo.prototype.constructor=mo;mo.prototype.toString=function(){return"#"};function go(e){if(typeof this!=="undefined"&&!(this instanceof go)||typeof this==="undefined"){return new go(e)}h("InputByteVectorPort",e,"uint8array");$i(this,"__vector__",e);$i(this,"__type__",Ao);var r=0;Object.defineProperty(this,"__index__",{enumerable:true,get:function e(){return r},set:function e(t){h("InputByteVectorPort::__index__",t,"number");if(t instanceof C){t=t.valueOf()}if(typeof t==="bigint"){t=Number(t)}if(Math.floor(t)!==t){throw new Error("InputByteVectorPort::__index__ value is "+"not integer")}r=t}})}go.prototype=Object.create(ho.prototype);go.prototype.constructor=go;go.prototype.toString=function(){return"#"};go.prototype.close=function(){var t=this;$i(this,"__vector__",U);["read_u8","close","peek_u8","read_u8_vector"].forEach(function(e){t[e]=function(){throw new Error("Input-binary-port: port is closed")}});this.char_ready=function(){return false}};go.prototype.u8_ready=function(){return true};go.prototype.peek_u8=function(){if(this.__index__>=this.__vector__.length){return Fo}return this.__vector__[this.__index__]};go.prototype.skip=function(){if(this.__index__<=this.__vector__.length){++this.__index__}};go.prototype.read_u8=function(){var e=this.peek_u8();this.skip();return e};go.prototype.read_u8_vector=function(e){if(typeof e==="undefined"){e=this.__vector__.length}else if(e>this.__index__+this.__vector__.length){e=this.__index__+this.__vector__.length}if(this.peek_u8()===Fo){return Fo}return this.__vector__.slice(this.__index__,e)};function bo(){if(typeof this!=="undefined"&&!(this instanceof bo)||typeof this==="undefined"){return new bo}$i(this,"__type__",Ao);$i(this,"_buffer",[],{hidden:true});this.write=function(e){h("write",e,["number","uint8array"]);if(C.isNumber(e)){this._buffer.push(e.valueOf())}else{var t;(t=this._buffer).push.apply(t,q(Array.from(e)))}};Object.defineProperty(this,"__buffer__",{enumerable:true,get:function e(){return Uint8Array.from(this._buffer)}})}bo.prototype=Object.create(po.prototype);bo.prototype.constructor=bo;bo.prototype.close=function(){po.prototype.close.call(this);$i(this,"_buffer",null,{hidden:true})};bo.prototype._close_guard=function(){if(this._closed){throw new Error("output-port: binary port is closed")}};bo.prototype.write_u8=function(e){h("OutputByteVectorPort::write_u8",e,"number");this.write(e)};bo.prototype.write_u8_vector=function(e){h("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};bo.prototype.toString=function(){return"#"};bo.prototype.valueOf=function(){return this.__buffer__};function wo(e,t){if(typeof this!=="undefined"&&!(this instanceof wo)||typeof this==="undefined"){return new wo(e,t)}mo.call(this,e);h("InputFilePort",t,"string");$i(this,"__filename__",t)}wo.prototype=Object.create(mo.prototype);wo.prototype.constructor=wo;wo.prototype.toString=function(){return"#")};function Do(e,t){if(typeof this!=="undefined"&&!(this instanceof Do)||typeof this==="undefined"){return new Do(e,t)}go.call(this,e);h("InputBinaryFilePort",t,"string");$i(this,"__filename__",t)}Do.prototype=Object.create(go.prototype);Do.prototype.constructor=Do;Do.prototype.toString=function(){return"#")};function Eo(e,t){if(typeof this!=="undefined"&&!(this instanceof Eo)||typeof this==="undefined"){return new Eo(e,t)}h("OutputBinaryFilePort",e,"string");$i(this,"__filename__",e);$i(this,"_fd",t.valueOf(),{hidden:true});$i(this,"__type__",Ao);var u,r;this.write=function(e){var n=this;h("write",e,["number","uint8array"]);var i;if(!u){u=this.internal("fs")}if(!r){r=this.internal("Buffer")}if(C.isNumber(e)){i=r.from([e.valueOf()])}else{i=r.from(Array.from(e))}return new Promise(function(t,r){u.write(n._fd,i,function(e){if(e){r(e)}else{t()}})})}}Eo.prototype=Object.create(yo.prototype);Eo.prototype.constructor=Eo;Eo.prototype.write_u8=function(e){h("OutputByteVectorPort::write_u8",e,"number");this.write(e)};Eo.prototype.write_u8_vector=function(e){h("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};var Ao=Symbol["for"]("binary");var xo=Symbol["for"]("text");var Fo=new ko;function ko(){}ko.prototype.toString=function(){return"#"};function Co(e){var c=this;var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=t.stderr,n=t.stdin,i=t.stdout,u=t.command_line,a=u===void 0?null:u,o=F(t,cn);if(typeof this!=="undefined"&&!(this instanceof Co)||typeof this==="undefined"){return new Co(e,vn({stdin:n,stdout:i,stderr:r,command_line:a},o))}if(typeof e==="undefined"){e="anonymous"}this.__env__=Yo.inherit(e,o);this.__env__.set("parent.frame",y("parent.frame",function(){return c.__env__},qo.__env__["parent.frame"].__doc__));var f="**interaction-environment-defaults**";this.set(f,Ou(o).concat(f));var s=Lo.inherit("internal-".concat(e));if(pa(n)){s.set("stdin",n)}if(pa(r)){s.set("stderr",r)}if(pa(i)){s.set("stdout",i)}s.set("command-line",a);Vo(this.__env__,s)}Co.prototype.exec=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;h("Interpreter::exec",e,["string","array"],1);h("Interpreter::exec",t,"boolean",2);qo.set("**interaction-environment**",this.__env__);if(r===null){r=this.__env__}return vs(e,r,t?r:false)};Co.prototype.get=function(e){var t=this.__env__.get(e);if(Xu(t)){return t.bind(this.__env__)}return t};Co.prototype.set=function(e,t){return this.__env__.set(e,t)};Co.prototype.constant=function(e,t){return this.__env__.constant(e,t)};function Oo(e,t){this.name="LipsError";this.message=e;this.args=t;this.stack=(new Error).stack}Oo.prototype=new Error;Oo.prototype.constructor=Oo;function So(e,t,r){if(arguments.length===1){if(_(arguments[0])==="object"){e=arguments[0];t=null}else if(typeof arguments[0]==="string"){e={};t=null;r=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=t;this.__name__=r||"anonymous"}So.prototype.list=function(){return Ou(this.__env__)};So.prototype.fs=function(){return this.get("**fs**")};So.prototype.unset=function(e){if(e instanceof L){e=e.valueOf()}if(e instanceof $a){e=e.valueOf()}delete this.__env__[e]};So.prototype.inherit=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(_(e)==="object"){t=e}if(!e||_(e)==="object"){e="child of "+(this.__name__||"unknown")}return new So(t||{},this,e)};So.prototype.doc=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;if(e instanceof L){e=e.__name__}if(e instanceof $a){e=e.valueOf()}if(t){if(!r){t=Hi(t)}this.__docs__.set(e,t);return this}if(this.__docs__.has(e)){return this.__docs__.get(e)}if(this.__parent__){return this.__parent__.doc(e)}};So.prototype.newFrame=function(e,t){var n=this.inherit("__frame__");n.set("parent.frame",y("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:1;e=e.valueOf();var t=n.__parent__;if(!(t instanceof So)){return U}if(e<=0){return t}var r=t.get("parent.frame");return r(e-1)},qo.__env__["parent.frame"].__doc__));t.callee=e;n.set("arguments",t);return n};So.prototype._lookup=function(e){if(e instanceof L){e=e.__name__}if(e instanceof $a){e=e.valueOf()}if(this.__env__.hasOwnProperty(e)){return Bo(this.__env__[e])}if(this.__parent__){return this.__parent__._lookup(e)}};So.prototype.toString=function(){return"#"};So.prototype.clone=function(){var t=this;var r={};Object.keys(this.__env__).forEach(function(e){r[e]=t.__env__[e]});return new So(r,this.__parent__,this.__name__)};So.prototype.merge=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"merge";h("Environment::merge",e,"environment");return this.inherit(t,e.__env__)};function Bo(e){if(typeof this!=="undefined"&&!(this instanceof Bo)||typeof this==="undefined"){return new Bo(e)}this.value=e}Bo.isUndefined=function(e){return e instanceof Bo&&typeof e.value==="undefined"};Bo.prototype.valueOf=function(){return this.value};function jo(e){if(e.length){if(e.length===1){return e[0]}}if(typeof this!=="undefined"&&!(this instanceof jo)||typeof this==="undefined"){return new jo(e)}this.__values__=e}jo.prototype.toString=function(){return this.__values__.map(function(e){return Pu(e)}).join("\n")};jo.prototype.valueOf=function(){return this.__values__};So.prototype.get=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};h("Environment::get",e,["symbol","string"]);var r=t.throwError,c=r===void 0?true:r;var n=e;if(n instanceof L||n instanceof $a){n=n.valueOf()}var i=this._lookup(n);if(i instanceof Bo){if(Bo.isUndefined(i)){return undefined}return oa(i.valueOf())}var u;if(e instanceof L&&e[L.object]){u=e[L.object]}else if(typeof n==="string"){u=n.split(".").filter(Boolean)}if(u&&u.length>0){var f=u,a=m(f),o=a[0],s=a.slice(1);i=this._lookup(o);if(s.length){try{if(i instanceof Bo){i=i.valueOf()}else{i=No(gn,o);if(Xu(i)){i=sa(i)}}if(typeof i!=="undefined"){return No.apply(void 0,[i].concat(q(s)))}}catch(e){throw e}}else if(i instanceof Bo){return oa(i.valueOf())}i=No(gn,n)}if(typeof i!=="undefined"){return i}if(c){throw new Error("Unbound variable `"+n.toString()+"'")}};So.prototype.set=function(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;h("Environment::set",e,["string","symbol"]);if(C.isNumber(t)){t=C(t)}if(e instanceof L){e=e.__name__}if(e instanceof $a){e=e.valueOf()}this.__env__[e]=t;if(r){this.doc(e,r,true)}return this};So.prototype.constant=function(t,e){var r=this;if(this.__env__.hasOwnProperty(t)){throw new Error("Environment::constant: ".concat(t," already exists"))}if(arguments.length===1&&wu(arguments[0])){var n=arguments[0];Object.keys(n).forEach(function(e){r.constant(t,n[e])})}else{Object.defineProperty(this.__env__,t,{value:e,enumerable:true})}return this};So.prototype.has=function(e){return this.__env__.hasOwnProperty(e)};So.prototype.ref=function(e){var t=this;while(true){if(!t){break}if(t.has(e)){return t}t=t.__parent__}};So.prototype.parents=function(){var e=this;var t=[];while(e){t.unshift(e);e=e.__parent__}return t};function Io(e){if(ra(e)){return e.then(Io)}if(e instanceof M||e instanceof L){e[ya]=true}return e}var Po=Mi(wi('(lambda ()\n "[native code]"\n (throw "Invalid Invocation"))'))[0];var No=y("get",function c(e){var t;for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=Ro(this,"stdin")}Xo("peek-char",e,"input-port");return e.peek_char()},"(peek-char port)\n\n This function reads and returns a character from the string\n port, or, if there is no more data in the string port, it\n returns an EOF."),"read-line":y("read-line",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=Ro(this,"stdin")}Xo("read-line",e,"input-port");return e.read_line()},"(read-line port)\n\n This function reads and returns the next line from the input\n port."),"read-char":y("read-char",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=Ro(this,"stdin")}Xo("read-char",e,"input-port");return e.read_char()},"(read-char port)\n\n This function reads and returns the next character from the\n input port."),read:y("read",function(){var e=B(z.mark(function e(){var r,n,i,u,a,o,s,c,f=arguments;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:r=f.length>0&&f[0]!==undefined?f[0]:null;if(!$a.isString(r)){t.next=30;break}n=false;i=false;t.prev=4;a=yn(Mi(r,this));case 6:t.next=8;return a.next();case 8:if(!(n=!(o=t.sent).done)){t.next=14;break}s=o.value;return t.abrupt("return",s);case 11:n=false;t.next=6;break;case 14:t.next=20;break;case 16:t.prev=16;t.t0=t["catch"](4);i=true;u=t.t0;case 20:t.prev=20;t.prev=21;if(!(n&&a["return"]!=null)){t.next=25;break}t.next=25;return a["return"]();case 25:t.prev=25;if(!i){t.next=28;break}throw u;case 28:return t.finish(25);case 29:return t.finish(20);case 30:if(r===null){c=Ro(this,"stdin")}else{c=r}Xo("read",c,"input-port");return t.abrupt("return",c.read.call(this));case 33:case"end":return t.stop()}}},e,this,[[4,16,20,30],[21,,25,29]])}));function t(){return e.apply(this,arguments)}return t}(),"(read [string])\n\n This function, if used with a string, will parse it and\n return the LIPS code, if there is any. If called with a\n port, it will parse the next item from the port. If called\n without an input, it will read a string from standard input\n (using the browser's prompt or a user defined input method)\n and calls itself with that string. This function can be used\n together with `eval` to evaluate code from a string."),pprint:y("pprint",function e(t){if(t instanceof M){t=new Gs.Formatter(t.toString(true))["break"]().format();qo.get("display").call(qo,t)}else{qo.get("write").call(qo,t)}qo.get("newline").call(qo)},"(pprint expression)\n\n This function will pretty print its input to stdout. If it is called\n with a non-list, it will just call the print function on its\n input."),print:y("print",function e(){var t=qo.get("display");var r=qo.get("newline");for(var n=arguments.length,i=new Array(n),u=0;u1?r-1:0),i=1;in.length){throw new Error("Not enough arguments")}var o=0;var s=qo.get("repr");t=t.replace(u,function(e){var t=e[1];if(t==="~"){return"~"}else if(t==="%"){return"\n"}else{var r=n[o++];if(t==="a"){return s(r)}else{return s(r,true)}}});a=t.match(/~([\S])/);if(a){throw new Error("format: Unrecognized escape sequence ".concat(a[1]))}return t},"(format string n1 n2 ...)\n\n This function accepts a string template and replaces any\n escape sequences in its inputs:\n\n * ~a value as if printed with `display`\n * ~s value as if printed with `write`\n * ~% newline character\n * ~~ literal tilde '~'\n\n If there are missing inputs or other escape characters it\n will error."),display:y("display",function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(r===null){r=Ro(this,"stdout")}else{h("display",r,"output-port")}var n=qo.get("repr")(t);r.write.call(qo,n)},"(display string [port])\n\n This function outputs the string to the standard output or\n the port if given. No newline."),"display-error":y("display-error",function e(){var t=Ro(this,"stderr");var r=qo.get("repr");for(var n=arguments.length,i=new Array(n),u=0;u1&&arguments[1]!==undefined?arguments[1]:{},r=t.dynamic_scope,n=t.error;if(r){r=this}var i=this;var u;var a=_s(e.cdr.car,{env:this,dynamic_scope:r,error:n});a=as(a);function o(t,r,n){if(ra(t)){return t.then(function(e){return o(t,e,n)})}if(ra(r)){return r.then(function(e){return o(t,e,n)})}if(ra(n)){return n.then(function(e){return o(t,r,e)})}i.get("set-obj!").call(i,t,r,n);return n}if(e.car instanceof M&&L.is(e.car.car,".")){var f=e.car.cdr.car;var l=e.car.cdr.cdr.car;var h=_s(f,{env:this,dynamic_scope:r,error:n});var p=_s(l,{env:this,dynamic_scope:r,error:n});return o(h,p,a)}if(!(e.car instanceof L)){throw new Error("set! first argument need to be a symbol or "+"dot accessor that evaluate to object.")}var s=e.car.valueOf();u=this.ref(e.car.__name__);return Yi(a,function(e){if(!u){var t=s.split(".");if(t.length>1){var r=t.pop();var n=t.join(".");var i=c.get(n,{throwError:false});if(i){o(i,r,e);return}}throw new Error("Unbound variable `"+s+"'")}u.set(s,e)})}),"(set! name value)\n\n Macro that can be used to set the value of the variable or slot (mutate it).\n set! searches the scope chain until it finds first non empty slot and sets it."),"unset!":y(new Vu("set!",function(e){if(!(e.car instanceof L)){throw new Error("unset! first argument need to be a symbol or "+"dot accessor that evaluate to object.")}var t=e.car;var r=this.ref(t);if(r){delete r.__env__[t.__name__]}}),"(unset! name)\n\n Function to delete the specified name from environment.\n Trying to access the name afterwards will error."),"set-car!":y("set-car!",function(e,t){h("set-car!",e,"pair");e.car=t},"(set-car! obj value)\n\n Function that sets the car (first item) of the list/pair to specified value.\n The old value is lost."),"set-cdr!":y("set-cdr!",function(e,t){h("set-cdr!",e,"pair");e.cdr=t},"(set-cdr! obj value)\n\n Function that sets the cdr (tail) of the list/pair to specified value.\n It will destroy the list. The old tail is lost."),"empty?":y("empty?",function(e){return typeof e==="undefined"||e===U},"(empty? object)\n\n Function that returns #t if value is nil (an empty list) or undefined."),gensym:y("gensym",Fi,"(gensym)\n\n Generates a unique symbol that is not bound anywhere,\n to use with macros as meta name."),load:y("load",function e(o,t){h("load",o,"string");var s=this;if(s.__name__==="__frame__"){s=s.__parent__}if(!(t instanceof So)){if(s===qo){t=s}else{t=this.get("**interaction-environment**")}}var c="**module-path**";var f=qo.get(c,{throwError:false});o=o.valueOf();if(!o.match(/.[^.]+$/)){o+=".scm"}var r=o.match(/\.xcb$/);function l(e){if(r){e=Vs(e)}else{if(us(e)==="buffer"){e=e.toString()}e=e.replace(/^#!.*/,"");if(e.match(/^\{/)){e=Rs(e)}}return vs(e,t)}function n(e){return gn.fetch(e).then(function(e){return r?e.arrayBuffer():e.text()}).then(function(e){if(r){e=new Uint8Array(e)}return e})}if(Go()){return new Promise(function(){var r=B(z.mark(function e(r,n){var i,u,a;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:i=An("path");if(!f){t.next=6;break}f=f.valueOf();o=i.join(f,o);t.next=12;break;case 6:u=s.get("command-line",{throwError:false});if(!u){t.next=11;break}t.next=10;return u();case 10:a=t.sent;case 11:if(a&&a!==U){process.cwd();o=i.join(i.dirname(a.car.valueOf()),o)}case 12:qo.set(c,i.dirname(o));An("fs").readFile(o,function(e,t){if(e){n(e);qo.set(c,f)}else{try{l(t).then(function(){r();qo.set(c,f)})["catch"](n)}catch(e){n(e)}}});case 14:case"end":return t.stop()}}},e)}));return function(e,t){return r.apply(this,arguments)}}())}if(f){f=f.valueOf();o=f+"/"+o.replace(/^\.?\/?/,"")}return n(o).then(function(e){qo.set(c,o.replace(/\/[^/]*$/,""));return l(e)}).then(function(){})["finally"](function(){qo.set(c,f)})},"(load filename)\n (load filename environment)\n\n Fetches the file (from disk or network) and evaluates its content as LIPS code.\n If the second argument is provided and it's an environment the evaluation\n will happen in that environment."),do:y(new Vu("do",function(){var r=B(z.mark(function e(r,h){var n,i,u,o,s,a,c,f,l,p,_;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:n=h.dynamic_scope,i=h.error;u=this;if(n){n=u}o=u.inherit("do");s=r.car;a=r.cdr.car;c=r.cdr.cdr;if(c!==U){c=new M(L("begin"),c)}f={env:u,dynamic_scope:n,error:i};l=s;case 10:if(!(l!==U)){t.next=21;break}p=l.car;t.t0=o;t.t1=p.car;t.next=16;return _s(p.cdr.car,f);case 16:t.t2=t.sent;t.t0.set.call(t.t0,t.t1,t.t2);l=l.cdr;t.next=10;break;case 21:f={env:o,dynamic_scope:n,error:i};_=z.mark(function e(){var r,n,i,u,a;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!(c!==U)){t.next=3;break}t.next=3;return Gs.evaluate(c,f);case 3:r=s;n={};case 5:if(!(r!==U)){t.next=15;break}i=r.car;if(!(i.cdr.cdr!==U)){t.next=12;break}t.next=10;return _s(i.cdr.cdr.car,f);case 10:u=t.sent;n[i.car.valueOf()]=u;case 12:r=r.cdr;t.next=5;break;case 15:a=Object.getOwnPropertySymbols(n);Object.keys(n).concat(a).forEach(function(e){o.set(e,n[e])});case 17:case"end":return t.stop()}}},e)});case 23:t.next=25;return _s(a.car,f);case 25:t.t3=t.sent;if(!(t.t3===false)){t.next=30;break}return t.delegateYield(_(),"t4",28);case 28:t.next=23;break;case 30:if(!(a.cdr!==U)){t.next=34;break}t.next=33;return _s(a.cdr.car,f);case 33:return t.abrupt("return",t.sent);case 34:case"end":return t.stop()}}},e,this)}));return function(e,t){return r.apply(this,arguments)}}()),"(do (( )) (test return) . body)\n\n Iteration macro that evaluates the expression body in scope of the variables.\n On each loop it changes the variables according to the expression and runs\n test to check if the loop should continue. If test is a single value, the macro\n will return undefined. If the test is a pair of expressions the macro will\n evaluate and return the second expression after the loop exits."),if:y(new Vu("if",function(r,e){var n=e.dynamic_scope,i=e.error;if(n){n=this}var u=this;var t=function e(t){if(t===false){return _s(r.cdr.cdr.car,{env:u,dynamic_scope:n,error:i})}else{return _s(r.cdr.car,{env:u,dynamic_scope:n,error:i})}};if(r===U){throw new Error("too few expressions for `if`")}var a=_s(r.car,{env:u,dynamic_scope:n,error:i});return Yi(a,t)}),"(if cond true-expr false-expr)\n\n Macro that evaluates cond expression and if the value is true, it\n evaluates and returns true-expression, if not it evaluates and returns\n false-expression."),"let-env":new Vu("let-env",function(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=e.dynamic_scope,n=e.error;h("let-env",t,"pair");var i=_s(t.car,{env:this,dynamic_scope:r,error:n});return Yi(i,function(e){h("let-env",e,"environment");return _s(M(L("begin"),t.cdr),{env:e,dynamic_scope:r,error:n})})},"(let-env env . body)\n\n Special macro that evaluates body in context of given environment\n object."),letrec:y(ja(Symbol["for"]("letrec")),"(letrec ((a value-a) (b value-b) ...) . body)\n\n Macro that creates a new environment, then evaluates and assigns values to\n names and then evaluates the body in context of that environment.\n Values are evaluated sequentially and the next value can access the\n previous values/names."),"letrec*":y(ja(Symbol["for"]("letrec")),"(letrec* ((a value-a) (b value-b) ...) . body)\n\n Same as letrec but the order of execution of the binding is guaranteed,\n so you can use recursive code as well as referencing the previous binding.\n\n In LIPS both letrec and letrec* behave the same."),"let*":y(ja(Symbol["for"]("let*")),"(let* ((a value-a) (b value-b) ...) . body)\n\n Macro similar to `let`, but the subsequent bindings after the first\n are evaluated in the environment including the previous let variables,\n so you can define one variable, and use it in the next's definition."),let:y(ja(Symbol["for"]("let")),"(let ((a value-a) (b value-b) ...) . body)\n\n Macro that creates a new environment, then evaluates and assigns values to names,\n and then evaluates the body in context of that environment. Values are evaluated\n sequentially but you can't access previous values/names when the next are\n evaluated. You can only get them in the body of the let expression. (If you want\n to define multiple variables and use them in each other's definitions, use\n `let*`.)"),"begin*":y(Ia("begin*",function(e){return e.pop()}),"(begin* . body)\n\n This macro is a parallel version of begin. It evaluates each expression\n in the body and if it's a promise it will await it in parallel and return\n the value of the last expression (i.e. it uses Promise.all())."),begin:y(new Vu("begin",function(e,t){var n=Object.assign({},t);var i=qo.get("list->array")(e);if(n.dynamic_scope){n.dynamic_scope=this}n.env=this;var u;return function t(){if(i.length){var e=i.shift();var r=_s(e,n);return Yi(r,function(e){u=e;return t()})}else{return u}}()}),"(begin . args)\n\n Macro that runs a list of expressions in order and returns the value\n of the last one. It can be used in places where you can only have a\n single expression, like (if)."),ignore:new Vu("ignore",function(e,t){var r=t.dynamic_scope,n=t.error;var i={env:this,error:n};if(r){i.dynamic_scope=this}_s(new M(new L("begin"),e),i)},"(ignore . body)\n\n Macro that will evaluate the expression and swallow any promises that may\n be created. It will discard any value that may be returned by the last body\n expression. The code should have side effects and/or when it's promise\n it should resolve to undefined."),"call/cc":y(Vu.defmacro("call/cc",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=vn({env:this},t);return Yi(_s(e.car,r),function(e){if(Xu(e)){return e(new hs(null))}})}),"(call/cc proc)\n\n Call-with-current-continuation.\n\n NOT SUPPORTED BY LIPS RIGHT NOW"),define:y(Vu.defmacro("define",function(r,e){var n=this;if(r.car instanceof M&&r.car.car instanceof L){var t=new M(new L("define"),new M(r.car.car,new M(new M(new L("lambda"),new M(r.car.cdr,r.cdr)))));return t}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=n;var i=r.cdr.car;var u;if(i instanceof M){i=_s(i,e);u=true}else if(i instanceof L){i=n.get(i)}h("define",r.car,"symbol");return Yi(i,function(e){if(n.__name__===Ku.__merge_env__){n=n.__parent__}if(u&&(Xu(e)&&Ca(e)||e instanceof Ku)){e.__name__=r.car.valueOf();if(e.__name__ instanceof $a){e.__name__=e.__name__.valueOf()}}var t;if(r.cdr.cdr instanceof M&&$a.isString(r.cdr.cdr.car)){t=r.cdr.cdr.car.valueOf()}n.set(r.car,e,t,true)})}),'(define name expression)\n (define name expression "doc string")\n (define (function-name . args) . body)\n\n Macro for defining values. It can be used to define variables,\n or functions. If the first argument is list it will create a function\n with name being first element of the list. This form expands to\n `(define function-name (lambda args body))`'),"set-obj!":y("set-obj!",function(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var i=_(e);if(Zu(e)||i!=="object"&&i!=="function"){var u=Qo("set-obj!",us(e),["object","function"]);throw new Error(u)}h("set-obj!",t,["string","symbol","number"]);e=sa(e);t=t.valueOf();if(arguments.length===2){delete e[t]}else if(Nu(e)&&Xu(r)){e[t]=sa(r);e[t][Da]=true}else if(Xu(r)||ts(r)||r===U){e[t]=r}else{e[t]=r&&!Nu(r)?r.valueOf():r}if(Du){var a=e[t];Object.defineProperty(e,t,vn(vn({},n),{},{value:a}))}},"(set-obj! obj key value)\n (set-obj! obj key value props)\n\n Function set a property of a JavaScript object. props should be a vector of pairs,\n passed to Object.defineProperty."),"null-environment":y("null-environment",function(){return qo.inherit("null")},"(null-environment)\n\n Returns a clean environment with only the standard library."),values:y("values",function e(){for(var t=arguments.length,r=new Array(t),n=0;n1&&arguments[1]!==undefined?arguments[1]:{},h=e.dynamic_scope,p=e.error;var _=this;var d;if(l.cdr instanceof M&&$a.isString(l.cdr.car)&&l.cdr.cdr!==U){d=l.cdr.car.valueOf()}function v(){var e;if(h){if(!(this instanceof So)){e=_}else{e=this}}else{e=_}e=e.inherit("lambda");var t=l.car;var r=0;var n;if(typeof this!=="undefined"&&!(this instanceof So)){if(this&&!this.__instance__){Object.defineProperty(this,"__instance__",{enumerable:false,get:function e(){return true},set:function e(){},configurable:false})}e.set("this",this)}for(var i=arguments.length,u=new Array(i),a=0;a>> "+c.toString());if(c){o=c}var d=r.merge(t,Ku.__merge_env__);if(l){return{expr:o,scope:d}}var v=_s(o,vn(vn({},p),{},{env:d}));return Wu(v,_)}i=i.cdr}}catch(e){e.message+=" in macro: ".concat(y.toString(true));throw e}throw new Error("Invalid Syntax ".concat(e.toString(true)))},b);r.__code__=y;return r},"(syntax-rules () (pattern expression) ...)\n\n Base of hygienic macros, it will return a new syntax expander\n that works like Lisp macros."),quote:y(new Vu("quote",function(e){return Io(e.car)}),"(quote expression) or 'expression\n\n Macro that returns a single LIPS expression as data (it won't evaluate the\n argument). It will return a list if put in front of LIPS code.\n And if put in front of a symbol it will return the symbol itself, not the value\n bound to that name."),"unquote-splicing":y("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code) or ,@code\n\n Special form used in the quasiquote macro. It evaluates the expression inside and\n splices the list into quasiquote's result. If it is not the last element of the\n expression, the computed value must be a pair."),unquote:y("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code) or ,code\n\n Special form used in the quasiquote macro. It evaluates the expression inside and\n substitutes the value into quasiquote's result."),quasiquote:Vu.defmacro("quasiquote",function(e,t){var o=t.dynamic_scope,s=t.error;var c=this;if(o){o=c}function a(e){return e instanceof M||wu(e)||Array.isArray(e)}function h(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:a;if(e instanceof M){var n=e.car;var i=e.cdr;if(r(n)){n=t(n)}if(r(i)){i=t(i)}if(ra(n)||ra(i)){return Ci([n,i]).then(function(e){var t=j(e,2),r=t[0],n=t[1];return new M(r,n)})}else{return new M(n,i)}}return e}function u(e,t){if(e instanceof M){if(t!==U){e.append(t)}}else{e=new M(e,t)}return e}function r(e){return!!e.filter(function(e){return e instanceof M&&L.is(e.car,/^(unquote|unquote-splicing)$/)}).length}function p(e,n,i){return e.reduce(function(e,t){if(!(t instanceof M)){e.push(t);return e}if(L.is(t.car,"unquote-splicing")){var r;if(n+11){var t="You can't splice multiple atoms inside list";throw new Error(t)}if(!(i.cdr instanceof M&&r[0]===U)){return r[0]}}r=r.map(function(e){if(d.has(e)){return e.clone()}else{d.add(e);return e}});var n=l(i.cdr,0,1);if(n===U&&r[0]===U){return undefined}return Yi(n,function(e){if(r[0]===U){return e}if(r.length===1){return u(r[0],e)}var t=r.reduce(function(e,t){return u(e,t)});return u(t,e)})})}(i.car.cdr)}var d=new Set;function l(e,t,r){if(e instanceof M){if(e.car instanceof M){if(L.is(e.car.car,"unquote-splicing")){return f(e,t+1,r)}if(L.is(e.car.car,"unquote")){if(t+2===r&&e.car.cdr instanceof M&&e.car.cdr.car instanceof M&&L.is(e.car.cdr.car.car,"unquote-splicing")){var n=e.car.cdr;return new M(new M(new L("unquote"),f(n,t+2,r)),U)}else if(e.car.cdr instanceof M&&e.car.cdr.cdr!==U){if(e.car.cdr.car instanceof M){var i=[];return function t(r){if(r===U){return M.fromArray(i)}return Yi(_s(r.car,{env:c,dynamic_scope:o,error:s}),function(e){i.push(e);return t(r.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}}if(L.is(e.car,"quasiquote")){var u=l(e.cdr,t,r+1);return new M(e.car,u)}if(L.is(e.car,"quote")){return new M(e.car,l(e.cdr,t,r))}if(L.is(e.car,"unquote")){t++;if(tr){throw new Error("You can't call `unquote` outside "+"of quasiquote")}if(e.cdr instanceof M){if(e.cdr.cdr!==U){if(e.cdr.car instanceof M){var a=[];return function t(r){if(r===U){return M.fromArray(a)}return Yi(_s(r.car,{env:c,dynamic_scope:o,error:s}),function(e){a.push(e);return t(r.cdr)})}(e.cdr)}else{return e.cdr}}else{return _s(e.cdr.car,{env:c,dynamic_scope:o,error:s})}}else{return e.cdr}}return h(e,function(e){return l(e,t,r)})}else if(wu(e)){return _(e,t,r)}else if(e instanceof Array){return p(e,t,r)}return e}function n(e){if(e instanceof M){delete e[ya];if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}}if(wu(e.car)&&!r(Object.values(e.car))){return Io(e.car)}if(Array.isArray(e.car)&&!r(e.car)){return Io(e.car)}if(e.car instanceof M&&!e.car.find("unquote")&&!e.car.find("unquote-splicing")&&!e.car.find("quasiquote")){return Io(e.car)}var i=l(e.car,0,1);return Yi(i,function(e){n(e);return Io(e)})},"(quasiquote list)\n\n Similar macro to `quote` but inside it you can use special expressions (unquote\n x) abbreviated to ,x that will evaluate x and insert its value verbatim or\n (unquote-splicing x) abbreviated to ,@x that will evaluate x and splice the value\n into the result. Best used with macros but it can be used outside."),clone:y("clone",function e(t){h("clone",t,"pair");return t.clone()},"(clone list)\n\n Function that returns a clone of the list, that does not share any pairs with the\n original, so the clone can be safely mutated without affecting the original."),append:y("append",function e(){var t;for(var r=arguments.length,n=new Array(r),i=0;iarray")(t).reverse();return qo.get("array->list")(r)}else if(!(t instanceof Array)){throw new Error(Qo("reverse",us(t),"array or pair"))}else{return t.reverse()}},"(reverse list)\n\n Function that reverses the list or array. If value is not a list\n or array it will error."),nth:y("nth",function e(t,r){h("nth",t,"number");h("nth",r,["array","pair"]);if(r instanceof M){var n=r;var i=0;while(iarray")(r).join(t)},"(join separator list)\n\n Function that returns a string by joining elements of the list using separator."),split:y("split",function e(t,r){h("split",t,["regex","string"]);h("split",r,"string");return qo.get("array->list")(r.split(t))},"(split separator string)\n\n Function that creates a list by splitting string by separator which can\n be a string or regular expression."),replace:y("replace",function e(t,r,n){h("replace",t,["regex","string"]);h("replace",r,["string","function"]);h("replace",n,"string");return n.replace(t,r)},"(replace pattern replacement string)\n\n Function that changes pattern to replacement inside string. Pattern can be a\n string or regex and replacement can be function or string. See Javascript\n String.replace()."),match:y("match",function e(t,r){h("match",t,["regex","string"]);h("match",r,"string");var n=r.match(t);return n?qo.get("array->list")(n):false},"(match pattern string)\n\n Function that returns a match object from JavaScript as a list or #f if\n no match."),search:y("search",function e(t,r){h("search",t,["regex","string"]);h("search",r,"string");return r.search(t)},"(search pattern string)\n\n Function that returns the first found index of the pattern inside a string."),repr:y("repr",function e(t,r){return Pu(t,r)},"(repr obj)\n\n Function that returns a LIPS code representation of the object as a string."),"escape-regex":y("escape-regex",function(e){h("escape-regex",e,"string");return _i(e.valueOf())},"(escape-regex string)\n\n Function that returns a new string where all special operators used in regex,\n are escaped with backslashes so they can be used in the RegExp constructor\n to match a literal string."),env:y("env",function e(e){e=e||this;var t=Object.keys(e.__env__).map(L);var r;if(t.length){r=M.fromArray(t)}else{r=U}if(e.__parent__ instanceof So){return qo.get("env")(e.__parent__).append(r)}return r},"(env)\n (env obj)\n\n Function that returns a list of names (functions, macros and variables)\n that are bound in the current environment or one of its parents."),new:y("new",function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n2&&arguments[2]!==undefined?arguments[2]:Bi.LITERAL;h("set-special!",e,"string",1);h("set-special!",t,"symbol",2);Bi.append(e.valueOf(),t,r)},'(set-special! symbol name [type])\n\n Add a special symbol to the list of transforming operators by the parser.\n e.g.: `(add-special! "#" \'x)` will allow to use `#(1 2 3)` and it will be\n transformed into (x (1 2 3)) so you can write x macro that will process\n the list. 3rd argument is optional, and it can be one of two values:\n lips.specials.LITERAL, which is the default behavior, or\n lips.specials.SPLICE which causes the value to be unpacked into the expression.\n This can be used for e.g. to make `#(1 2 3)` into (x 1 2 3) that is needed\n by # that defines vectors.'),get:No,".":No,unbind:y(sa,"(unbind fn)\n\n Function that removes the weak 'this' binding from a function so you\n can get properties from the actual function object."),type:y(us,"(type object)\n\n Function that returns the type of an object as string."),debugger:y("debugger",function(){debugger},'(debugger)\n\n Function that triggers the JavaScript debugger (e.g. the browser devtools)\n using the "debugger;" statement. If a debugger is not running this\n function does nothing.'),in:y("in",function(e,t){if(e instanceof L||e instanceof $a||e instanceof C){e=e.valueOf()}return e in aa(t)},'(in key value)\n\n Function that uses the Javascript "in" operator to check if key is\n a valid property in the value.'),instanceof:y("instanceof",function(e,t){return t instanceof sa(e)},"(instanceof type obj)\n\n Predicate that tests if the obj is an instance of type."),"prototype?":y("prototype?",Nu,"(prototype? obj)\n\n Predicate that tests if value is a valid JavaScript prototype,\n i.e. calling (new) with it will not throw ' is not a constructor'."),"macro?":y("macro?",function(e){return e instanceof Vu},"(macro? expression)\n\n Predicate that tests if value is a macro."),"function?":y("function?",Xu,"(function? expression)\n\n Predicate that tests if value is a callable function."),"real?":y("real?",function(e){if(us(e)!=="number"){return false}if(e instanceof C){return e.isFloat()}return C.isFloat(e)},"(real? number)\n\n Predicate that tests if value is a real number (not complex)."),"number?":y("number?",function(e){return Number.isNaN(e)||C.isNumber(e)},"(number? expression)\n\n Predicate that tests if value is a number or NaN value."),"string?":y("string?",function(e){return $a.isString(e)},"(string? expression)\n\n Predicate that tests if value is a string."),"pair?":y("pair?",function(e){return e instanceof M},"(pair? expression)\n\n Predicate that tests if value is a pair or list structure."),"regex?":y("regex?",function(e){return e instanceof RegExp},"(regex? expression)\n\n Predicate that tests if value is a regular expression."),"null?":y("null?",function(e){return Zu(e)},"(null? expression)\n\n Predicate that tests if value is null-ish (i.e. undefined, nil, or\n Javascript null)."),"boolean?":y("boolean?",function(e){return typeof e==="boolean"},"(boolean? expression)\n\n Predicate that tests if value is a boolean (#t or #f)."),"symbol?":y("symbol?",function(e){return e instanceof L},"(symbol? expression)\n\n Predicate that tests if value is a LIPS symbol."),"array?":y("array?",function(e){return e instanceof Array},"(array? expression)\n\n Predicate that tests if value is an array."),"object?":y("object?",function(e){return e!==U&&e!==null&&!(e instanceof za)&&!(e instanceof RegExp)&&!(e instanceof $a)&&!(e instanceof M)&&!(e instanceof C)&&_(e)==="object"&&!(e instanceof Array)},"(object? expression)\n\n Predicate that tests if value is an plain object (not another LIPS type)."),flatten:y("flatten",function e(t){h("flatten",t,"pair");return t.flatten()},"(flatten list)\n\n Returns a shallow list from tree structure (pairs)."),"array->list":y("array->list",function(e){h("array->list",e,"array");return M.fromArray(e)},"(array->list array)\n\n Function that converts a JavaScript array to a LIPS cons list."),"tree->array":y("tree->array",gu("tree->array",true),"(tree->array list)\n\n Function that converts a LIPS cons tree structure into a JavaScript array."),"list->array":y("list->array",gu("list->array"),"(list->array list)\n\n Function that converts a LIPS list into a JavaScript array."),apply:y("apply",function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;iarray").call(this,u));return t.apply(this,fs(t,n))},"(apply fn list)\n\n Function that calls fn with the list of arguments."),length:y("length",function e(t){if(!t||t===U){return 0}if(t instanceof M){return t.length()}if("length"in t){return t.length}},'(length expression)\n\n Function that returns the length of the object. The object can be a LIPS\n list or any object that has a "length" property. Returns undefined if the\n length could not be found.'),"string->number":y("string->number",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;h("string->number",e,"string",1);h("string->number",t,"number",2);e=e.valueOf();t=t.valueOf();if(e.match(Wn)||e.match(Kn)){return ti(e,t)}else if(e.match(Qn)||e.match(Jn)){return ii(e,t)}else{var r=t===10&&!e.match(/e/i)||t===16;if(e.match(Hn)&&r||e.match(Gn)){return ri(e,t)}if(e.match(Rn)){return oi(e)}}return false},"(string->number number [radix])\n\n Function that parses a string into a number."),try:y(new Vu("try",function(t,e){var c=this;var f=e.dynamic_scope,l=e.error;return new Promise(function(i,n){var u,a;if(L.is(t.cdr.car.car,"catch")){u=t.cdr.car;if(t.cdr.cdr instanceof M&&L.is(t.cdr.cdr.car.car,"finally")){a=t.cdr.cdr.car}}else if(L.is(t.cdr.car.car,"finally")){a=t.cdr.car}if(!(a||u)){throw new Error("try: invalid syntax")}var o=i;if(a){o=function e(t,r){o=n;Yi(_s(new M(new L("begin"),a.cdr),s),function(){r(t)})}}var s={env:c,error:function e(t){var r=c.inherit("try");if(u){r.set(u.cdr.car.car,t);var n={env:r,error:l};if(f){n.dynamic_scope=c}Yi(_s(new M(new L("begin"),u.cdr.cdr),n),function(e){o(e,i)})}else{o(t,l)}}};if(f){s.dynamic_scope=c}var e=_s(t.car,s);if(ra(e)){e.then(function(e){o(e,i)})["catch"](s.error)}else{o(e,i)}})}),"(try expr (catch (e) code))\n (try expr (catch (e) code) (finally code))\n (try expr (finally code))\n\n Macro that executes expr and catches any exceptions thrown. If catch is provided\n it's executed when an error is thrown. If finally is provided it's always\n executed at the end."),raise:y("raise",function(e){throw e},"(raise obj)\n\n Throws the object verbatim (no wrapping an a new Error)."),throw:y("throw",function(e){throw new Error(e)},"(throw string)\n\n Throws a new exception."),find:y("find",function t(r,n){h("find",r,["regex","function"]);h("find",n,["pair","nil"]);if(Zu(n)){return U}var e=Gi("find",r);return Yi(e(n.car),function(e){if(e&&e!==U){return n.car}return t(r,n.cdr)})},"(find fn list)\n (find regex list)\n\n Higher-order function that finds the first value for which fn return true.\n If called with a regex it will create a matcher function."),"for-each":y("for-each",function(e){var t;h("for-each",e,"function");for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i1?t-1:0),u=1;u3?n-3:0),u=3;u3?i-3:0),a=3;aarray")(r);var u=[];var a=Gi("filter",t);return function t(r){function e(e){if(e&&e!==U){u.push(n)}return t(++r)}if(r===i.length){return M.fromArray(u)}var n=i[r];return Yi(a(n),e)}(0)},"(filter fn list)\n (filter regex list)\n\n Higher-order function that calls `fn` for each element of the list\n and return a new list for only those elements for which fn returns\n a truthy value. If called with a regex it will create a matcher function."),compose:y(Ra,"(compose . fns)\n\n Higher-order function that creates a new function that applies all functions\n from right to left and returns the last value. Reverse of pipe.\n e.g.:\n ((compose (curry + 2) (curry * 3)) 10) --\x3e (+ 2 (* 3 10)) --\x3e 32"),pipe:y(Na,"(pipe . fns)\n\n Higher-order function that creates a new function that applies all functions\n from left to right and returns the last value. Reverse of compose.\n e.g.:\n ((pipe (curry + 2) (curry * 3)) 10) --\x3e (* 3 (+ 2 10)) --\x3e 36"),curry:y(Ya,"(curry fn . args)\n\n Higher-order function that creates a curried version of the function.\n The result function will have partially applied arguments and it\n will keep returning one-argument functions until all arguments are provided,\n then it calls the original function with the accumulated arguments.\n\n e.g.:\n (define (add a b c d) (+ a b c d))\n (define add1 (curry add 1))\n (define add12 (add 2))\n (display (add12 3 4))"),gcd:y("gcd",function e(){for(var t=arguments.length,r=new Array(t),n=0;no?u%=o:o%=u}u=Tu(s*r[a])/(u+o)}return C(u)},"(lcm n1 n2 ...)\n\n Function that returns the least common multiple of the arguments."),"odd?":y("odd?",Ua(function(e){return C(e).isOdd()}),"(odd? number)\n\n Checks if number is odd."),"even?":y("even?",Ua(function(e){return C(e).isEven()}),"(even? number)\n\n Checks if number is even."),"*":y("*",qa(function(e,t){return C(e).mul(t)},C(1)),"(* . numbers)\n\n Multiplies all numbers passed as arguments. If single value is passed\n it will return that value."),"+":y("+",qa(function(e,t){return C(e).add(t)},C(0)),"(+ . numbers)\n\n Sums all numbers passed as arguments. If single value is passed it will\n return that value."),"-":y("-",function(){for(var e=arguments.length,t=new Array(e),r=0;r":y(">",function(){for(var e=arguments.length,t=new Array(e),r=0;r",t,"number");return Lu(function(e,t){return C(e).cmp(t)===1},t)},"(> x1 x2 x3 ...)\n\n Function that compares its numerical arguments and checks if they are\n monotonically decreasing, i.e. x1 > x2 and x2 > x3 and so on."),"<":y("<",function(){for(var e=arguments.length,t=new Array(e),r=0;r=":y(">=",function(){for(var e=arguments.length,t=new Array(e),r=0;r=",t,"number");return Lu(function(e,t){return[0,1].includes(C(e).cmp(t))},t)},"(>= x1 x2 ...)\n\n Function that compares its numerical arguments and checks if they are\n monotonically nonincreasing, i.e. x1 >= x2 and x2 >= x3 and so on."),"eq?":y("eq?",Uu,"(eq? a b)\n\n Function that compares two values if they are identical."),or:y(new Vu("or",function(e,t){var i=t.dynamic_scope,u=t.error;var a=qo.get("list->array")(e);var o=this;if(i){i=o}if(!a.length){return false}var s;return function t(){function e(e){s=e;if(s!==false){return s}else{return t()}}if(!a.length){if(s!==false){return s}else{return false}}else{var r=a.shift();var n=_s(r,{env:o,dynamic_scope:i,error:u});return Yi(n,e)}}()}),"(or . expressions)\n\n Macro that executes the values one by one and returns the first that is\n a truthy value. If there are no expressions that evaluate to true it\n returns false."),and:y(new Vu("and",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},i=t.dynamic_scope,u=t.error;var a=qo.get("list->array")(e);var o=this;if(i){i=o}if(!a.length){return true}var s;return function t(){function e(e){s=e;if(s===false){return false}else{return t()}}if(!a.length){if(s!==false){return s}else{return false}}else{var r=a.shift();var n=_s(r,{env:o,dynamic_scope:i,error:u});return Yi(n,e)}}()}),"(and . expressions)\n\n Macro that evaluates each expression in sequence and if any value returns false\n it will stop and return false. If each value returns true it will return the\n last value. If it's called without arguments it will return true."),"|":y("|",function(e,t){return C(e).or(t)},"(| a b)\n\n Function that calculates the bitwise or operation."),"&":y("&",function(e,t){return C(e).and(t)},"(& a b)\n\n Function that calculates the bitwise and operation."),"~":y("~",function(e){return C(e).neg()},"(~ number)\n\n Function that calculates the bitwise inverse (flip all the bits)."),">>":y(">>",function(e,t){return C(e).shr(t)},"(>> a b)\n\n Function that right shifts the value a by value b bits."),"<<":y("<<",function(e,t){return C(e).shl(t)},"(<< a b)\n\n Function that left shifts the value a by value b bits."),not:y("not",function e(t){if(Zu(t)){return true}return!t},"(not object)\n\n Function that returns the Boolean negation of its argument.")},undefined,"global");var Yo=qo.inherit("user-env");function Vo(e,t){e.constant("**internal-env**",t);e.doc("**internal-env**","**internal-env**\n\n Constant used to hide stdin, stdout and stderr so they don't interfere\n with variables with the same name. Constants are an internal type\n of variable that can't be redefined, defining a variable with the same name\n will throw an error.");qo.set("**interaction-environment**",e)}Vo(Yo,Lo);qo.doc("**interaction-environment**","**interaction-environment**\n\n Internal dynamic, global variable used to find interpreter environment.\n It's used so the read and write functions can locate **internal-env**\n that contains the references to stdin, stdout and stderr.");(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(t){var r=e[t]?e[t]:t;qo.set(r,y(r,function(e){h(r,e,"number");if(e instanceof C){return e[t]()}},"(".concat(r," number)\n\n Function that calculates the ").concat(r," of a number.")))})})();function zo(e){if(e.length===1){return e[0]}else{var t=[];var r=zo(e.slice(1));for(var n=0;n3&&arguments[3]!==undefined?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(n!==null){i+=" (argument ".concat(n,")")}if(Xu(r)){return"Invalid type: got ".concat(t).concat(i)}if(r instanceof Array){if(r.length===1){var u=r[0].toLowerCase();r="a"+("aeiou".includes(u)?"n ":" ")+r[0]}else{var a=r[r.length-1];r=r.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(r,", got ").concat(t).concat(i)}function Zo(r,e,n){e.forEach(function(e,t){h(r,e,n,t+1)})}function Xo(e,t,r){h(e,t,r);if(t.__type__===Ao){throw new Error(Qo(e,"binary-port","textual-port"))}}function h(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;e=e.valueOf();var i=us(t).toLowerCase();if(Xu(r)){if(!r(t)){throw new Error(Qo(e,i,r,n))}return}var u=false;if(r instanceof M){r=r.to_array()}if(r instanceof Array){r=r.map(function(e){return e.valueOf()})}if(r instanceof Array){r=r.map(function(e){return e.valueOf().toLowerCase()});if(r.includes(i)){u=true}}else{r=r.valueOf().toLowerCase()}if(!u&&i!==r){throw new Error(Qo(e,i,r,n))}}function es(e){var t=_(e);return["string","function"].includes(t)||_(e)==="symbol"||e instanceof ki||e instanceof L||e instanceof C||e instanceof $a||e instanceof RegExp}function ts(e){return e instanceof C||e instanceof $a||e instanceof za}function rs(e,t){if(e===null){return false}return _(e)==="object"&&t in Object.getOwnPropertySymbols(e)}function ns(e,t){if(rs(e,t)||rs(e.__proto__,t)){return Xu(e[t])}}function is(r){var n=new WeakMap;return function(e){var t=n.get(e);if(!t){t=r(e)}return t}}us=is(us);function us(e){var t=wn.get(e);if(t){return t}if(_(e)==="object"){for(var r=0,n=Object.entries(bn);r2&&arguments[2]!==undefined?arguments[2]:{},u=t.env,a=t.dynamic_scope,r=t.error,o=r===void 0?function(){}:r;e=os(e,{env:u,dynamic_scope:a,error:o});return Yi(e,function(e){if(Sa(i)){i=sa(i)}e=fs(i,e);var t=e.slice();var r=(a||u).newFrame(i,t);var n=as(i.apply(r,e));return Yi(n,function(e){if(e instanceof M){e.markCycles();return Io(e)}return ia(e)},o)})}var hs=function(){function t(e){D(this,t);this.__value__=e}A(t,[{key:"invoke",value:function e(){if(this.__value__===null){throw new Error("Continuations are not implemented yet")}}},{key:"toString",value:function e(){return"#"}}]);return t}();var ps=function e(){};function _s(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=e.env,n=e.dynamic_scope,c=e.error,i=c===void 0?ps:c;try{if(n===true){r=n=r||qo}else if(r===true){r=n=qo}else{r=r||qo}var u={env:r,dynamic_scope:n,error:i};var a;if(Zu(t)){return t}if(t instanceof L){return r.get(t)}if(!(t instanceof M)){return t}var o=t.car;var f=t.cdr;if(o instanceof M){a=as(_s(o,u));if(ra(a)){return a.then(function(e){return _s(new M(e,t.cdr),u)})}else if(!ta(a)){throw new Error(us(a)+" "+r.get("repr")(a)+" is not callable while evaluating "+t.toString())}}if(o instanceof L){a=r.get(o)}else if(Xu(o)){a=o}var s;if(a instanceof Ku){s=ss(a,t,u)}else if(a instanceof Vu){s=cs(a,f,u)}else if(Xu(a)){s=ls(a,f,u)}else if(ea(a)){s=a.invoke()}else if(t instanceof M){a=o&&o.toString();throw new Error("".concat(us(o)," ").concat(a," is not a function"))}else{return t}var l=r.get(Symbol["for"]("__promise__"),{throwError:false});if(l===true&&ra(s)){s=s.then(function(e){if(e instanceof M&&!a[ya]){return _s(e,u)}return e});return new ki(s)}return s}catch(e){i&&i.call(r,e,t)}}var ds=ys(function(e){return e});var vs=ys(function(e,t){return t});function ys(_){return function(){var n=B(z.mark(function e(r,n,i){var u,a,o,s,h,c,p,f,l;return z.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(i===true){n=i=n||Yo}else if(n===true){n=i=Yo}else{n=n||Yo}u=[];a=Array.isArray(r)?r:Mi(r);o=false;s=false;t.prev=5;c=yn(a);case 7:t.next=9;return c.next();case 9:if(!(o=!(p=t.sent).done)){t.next=27;break}f=p.value;l=_s(f,{env:n,dynamic_scope:i,error:function e(t,r){if(t&&t.message){if(t.message.match(/^Error:/)){var n=/^(Error:)\s*([^:]+:\s*)/;t.message=t.message.replace(n,"$1 $2")}if(r){if(!(t.__code__ instanceof Array)){t.__code__=[]}t.__code__.push(r.toString(true))}}throw t}});if(ra(l)){t.next=16;break}u.push(_(f,l));t.next=24;break;case 16:t.t0=u;t.t1=_;t.t2=f;t.next=21;return l;case 21:t.t3=t.sent;t.t4=(0,t.t1)(t.t2,t.t3);t.t0.push.call(t.t0,t.t4);case 24:o=false;t.next=7;break;case 27:t.next=33;break;case 29:t.prev=29;t.t5=t["catch"](5);s=true;h=t.t5;case 33:t.prev=33;t.prev=34;if(!(o&&c["return"]!=null)){t.next=38;break}t.next=38;return c["return"]();case 38:t.prev=38;if(!s){t.next=41;break}throw h;case 41:return t.finish(38);case 42:return t.finish(33);case 43:return t.abrupt("return",u);case 44:case"end":return t.stop()}}},e,null,[[5,29,33,43],[34,,38,42]])}));function e(e,t,r){return n.apply(this,arguments)}return e}()}function ms(e){var t={"[":"]","(":")"};var r;if(typeof e==="string"){r=wi(e)}else{r=e.map(function(e){return e&&e.token?e.token:e})}var n=Object.keys(t);var i=Object.values(t).concat(n);r=r.filter(function(e){return i.includes(e)});var u=new di;var a=hn(r),o;try{for(a.s();!(o=a.n()).done;){var s=o.value;if(n.includes(s)){u.push(s)}else if(!u.is_empty()){var f=u.top();var c=t[f];if(s===c){u.pop()}else{throw new Error("Syntax error: missing closing ".concat(c))}}else{throw new Error("Syntax error: not matched closing ".concat(s))}}}catch(e){a.e(e)}finally{a.f()}return u.is_empty()}function gs(e){var t="("+e.toString()+")()";var r=window.URL||window.webkitURL;var n;try{n=new Blob([t],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;n=new i;n.append(t);n=n.getBlob()}return new gn.Worker(r.createObjectURL(n))}function bs(){return Gs.version.match(/^(\{\{VER\}\}|DEV)$/)}function ws(){if(Go()){return}var e;if(document.currentScript){e=document.currentScript}else{var t=document.querySelectorAll("script");if(!t.length){return}e=t[t.length-1]}var r=e.getAttribute("src");return r}var Ds=ws();function Es(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";var t="dist/std.xcb";if(e===""){if(Ds){e=Ds.replace(/[^/]*$/,"std.xcb")}else if(bs()){e="https://cdn.jsdelivr.net/gh/jcubic/lips@devel/".concat(t)}else{e="https://cdn.jsdelivr.net/npm/@jcubic/lips@".concat(Gs.version,"/").concat(t)}}var r=qo.get("load");return r.call(Yo,e,qo)}function As(e){this.url=e;var a=this.worker=gs(function(){var a;var o;self.addEventListener("message",function(e){var r=e.data;var t=r.id;if(r.type!=="RPC"||t===null){return}function n(e){self.postMessage({id:t,type:"RPC",result:e})}function i(e){self.postMessage({id:t,type:"RPC",error:e})}if(r.method==="eval"){if(!o){i("Worker RPC: LIPS not initialized, call init first");return}o.then(function(){var e=r.params[0];var t=r.params[1];a.exec(e,t).then(function(e){e=e.map(function(e){return e&&e.valueOf()});n(e)})["catch"](function(e){i(e)})})}else if(r.method==="init"){var u=r.params[0];if(typeof u!=="string"){i("Worker RPC: url is not a string")}else{importScripts("".concat(u,"/dist/lips.min.js"));a=new Gs.Interpreter("worker");o=Es(u);o.then(function(){n(true)})}}})});this.rpc=function(){var n=0;return function e(t,r){var u=++n;return new Promise(function(n,i){a.addEventListener("message",function e(t){var r=t.data;if(r&&r.type==="RPC"&&r.id===u){if(r.error){i(r.error)}else{n(r.result)}a.removeEventListener("message",e)}});a.postMessage({type:"RPC",method:t,id:u,params:r})})}}();this.rpc("init",[e])["catch"](function(e){console.error(e)});this.exec=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;return this.rpc("eval",[e,t])}}var xs={pair:function e(t){var r=j(t,2),n=r[0],i=r[1];return M(n,i)},number:function e(t){if($a.isString(t)){return C([t,10])}return C(t)},regex:function e(t){var r=j(t,2),n=r[0],i=r[1];return new RegExp(n,i)},nil:function e(){return U},symbol:function e(t){if($a.isString(t)){return L(t)}else if(Array.isArray(t)){return L(Symbol["for"](t[0]))}},string:$a,character:za};var Fs=Object.keys(xs);var ks={};for(var Cs=0,Os=Object.entries(Fs);Cs1){var n=t.reduce(function(e,t){return e+t.length},0);var i=new Uint8Array(n);var u=0;t.forEach(function(e){i.set(e,u);u+=e.length});return i}else if(t.length){return t[0]}}function Us(){var e=1;var t=new TextEncoder("utf-8");return t.encode("LIPS".concat(e.toString().padStart(3," ")))}var Ms=7;function qs(e){var t=new TextDecoder("utf-8");var r=t.decode(e.slice(0,Ms));var n=r.substring(0,4);if(n==="LIPS"){var i=r.match(/^(....).*([0-9]+)$/);if(i){return{type:i[1],version:Number(i[2])}}}return{type:"unknown"}}function Ys(e){var t=Us();var r=Ts.encode(e);return Ls(t,un(r,{magic:false}))}function Vs(e){var t=qs(e),r=t.type,n=t.version;if(r==="LIPS"&&n===1){var i=an(e.slice(Ms),{magic:false});return Ts.decode(i)}else{throw new Error("Invalid file format ".concat(r))}}function zs(e){console.error(e.message||e);if(e.code){console.error(e.code.map(function(e,t){return"[".concat(t+1,"]: ").concat(e)}))}}function $s(){var a=["text/x-lips","text/x-scheme"];var o;function s(r){return new Promise(function(t){var e=r.getAttribute("src");if(e){return fetch(e).then(function(e){return e.text()}).then(vs).then(t)["catch"](function(e){zs(e);t()})}else{return vs(r.innerHTML).then(t)["catch"](function(e){zs(e);t()})}})}function e(){return new Promise(function(i){var u=Array.from(document.querySelectorAll("script"));return function e(){var t=u.shift();if(!t){i()}else{var r=t.getAttribute("type");if(a.includes(r)){var n=t.getAttribute("bootstrap");if(!o&&typeof n==="string"){return Es(n).then(function(){return s(t)}).then(e)}else{return s(t).then(e)}}else if(r&&r.match(/lips|lisp/)){console.warn("Expecting "+a.join(" or ")+" found "+r)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(Js){var t=Js;var r=t.getAttribute("bootstrap");if(typeof r==="string"){return Es(r).then(function(){o=true;return e()})}}return e()}var Js=typeof window!=="undefined"&&window.document&&document.currentScript;if(typeof window!=="undefined"){Fn(window,$s)}var Ks=function(){var e=$a("Sat, 23 Dec 2023 13:43:06 +0000").valueOf();var t=e==="{{"+"DATE}}"?new Date:new Date(e);var r=function e(t){return t.toString().padStart(2,"0")};var n=t.getFullYear();var i=[n,r(t.getMonth()+1),r(t.getDate())].join("-");var u="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter 1.0.0-beta.17 (".concat(i,") \nCopyright (c) 2018-").concat(n," Jakub T. Jankiewicz\n\nType (env) to see environment with functions macros and variables. You can also\nuse (help name) to display help for specific function or macro, (apropos name)\nto display list of matched names in environment and (dir object) to list\nproperties of an object.\n").replace(/^.*\n/,"");return u}();$i(eu,"__class__","ahead");$i(M,"__class__","pair");$i(mu,"__class__","nil");$i(tu,"__class__","pattern");$i(Xi,"__class__","formatter");$i(Vu,"__class__","macro");$i(Ku,"__class__","syntax");$i(So,"__class__","environment");$i(ho,"__class__","input-port");$i(po,"__class__","output-port");$i(_o,"__class__","output-port");$i(vo,"__class__","output-string-port");$i(mo,"__class__","input-string-port");$i(wo,"__class__","input-file-port");$i(yo,"__class__","output-file-port");$i(Oo,"__class__","lips-error");[C,io,fo,uo,lo].forEach(function(e){$i(e,"__class__","number")});$i(za,"__class__","character");$i(L,"__class__","symbol");$i($a,"__class__","string");$i(ki,"__class__","promise");var Gs={version:"1.0.0-beta.17",banner:Ks,date:"Sat, 23 Dec 2023 13:43:06 +0000",exec:vs,parse:Ra(Ji,Mi),tokenize:wi,evaluate:_s,compile:ds,serialize:Ns,unserialize:Rs,serialize_bin:Ys,unserialize_bin:Vs,bootstrap:Es,Environment:So,env:Yo,Worker:As,Interpreter:Co,balanced_parenthesis:ms,balancedParenthesis:ms,balanced:ms,Macro:Vu,Syntax:Ku,Pair:M,Values:jo,QuotedPromise:ki,Error:Oo,quote:Io,InputPort:ho,OutputPort:po,BufferedOutputPort:_o,InputFilePort:wo,OutputFilePort:yo,InputStringPort:mo,OutputStringPort:vo,InputByteVectorPort:go,OutputByteVectorPort:bo,InputBinaryFilePort:Do,OutputBinaryFilePort:Eo,Formatter:Xi,Parser:Li,Lexer:s,specials:Bi,repr:bu,nil:U,eof:Fo,LSymbol:L,LNumber:C,LFloat:uo,LComplex:io,LRational:fo,LBigInteger:lo,LCharacter:za,LString:$a,rationalize:so};qo.set("lips",Gs);var Hs={};var Ws=Object.freeze({__proto__:null,default:Hs});function Qs(e,t){var r=0;for(var n=e.length-1;n>=0;n--){var i=e[n];if(i==="."){e.splice(n,1)}else if(i===".."){e.splice(n,1);r++}else if(r){e.splice(n,1);r--}}if(t){for(;r--;r){e.unshift("..")}}return e}var Zs=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var Xs=function(e){return Zs.exec(e).slice(1)};function ec(){var e="",t=false;for(var r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:"/";if(typeof n!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!n){continue}e=n+"/"+e;t=n.charAt(0)==="/"}e=Qs(lc(e.split("/"),function(e){return!!e}),!t).join("/");return(t?"/":"")+e||"."}function tc(e){var t=rc(e),r=hc(e,-1)==="/";e=Qs(lc(e.split("/"),function(e){return!!e}),!t).join("/");if(!e&&!t){e="."}if(e&&r){e+="/"}return(t?"/":"")+e}function rc(e){return e.charAt(0)==="/"}function nc(){var e=Array.prototype.slice.call(arguments,0);return tc(lc(e,function(e,t){if(typeof e!=="string"){throw new TypeError("Arguments to path.join must be strings")}return e}).join("/"))}function ic(e,t){e=ec(e).substr(1);t=ec(t).substr(1);function r(e){var t=0;for(;t=0;r--){if(e[r]!=="")break}if(t>r)return[];return e.slice(t,r-t+1)}var n=r(e.split("/"));var i=r(t.split("/"));var u=Math.min(n.length,i.length);var a=u;for(var o=0;o=6.9.0" @@ -118,59 +119,16 @@ "url": "https://opencollective.com/babel" } }, - "node_modules/@babel/core/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/core/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/generator": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.17.0.tgz", - "integrity": "sha512-I3Omiv6FGOC29dtlZhkfXO6pgkmukJSlT26QjVvS1DGZe/NzSVCPG41X0tS21oZkJYlovfj9qDWgKP+Cn4bXxw==", + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.6.tgz", + "integrity": "sha512-qrSfCYxYQB5owCmGLbl8XRpX1ytXlpueOb0N0UmQwA073KZxejgQTzAmJezxvpwQD9uGtK2shHdi55QT+MbjIw==", "dev": true, "dependencies": { - "@babel/types": "^7.17.0", - "jsesc": "^2.5.1", - "source-map": "^0.5.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/generator/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/generator/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" + "@babel/types": "^7.23.6", + "@jridgewell/gen-mapping": "^0.3.2", + "@jridgewell/trace-mapping": "^0.3.17", + "jsesc": "^2.5.1" }, "engines": { "node": ">=6.9.0" @@ -188,28 +146,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/helper-annotate-as-pure/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-annotate-as-pure/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/helper-builder-binary-assignment-operator-visitor": { "version": "7.16.7", "resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.16.7.tgz", @@ -223,28 +159,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/helper-builder-binary-assignment-operator-visitor/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-builder-binary-assignment-operator-visitor/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/helper-compilation-targets": { "version": "7.16.7", "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.16.7.tgz", @@ -320,35 +234,10 @@ } }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.16.7.tgz", - "integrity": "sha512-SLLb0AAn6PkUeAfKJCCOl9e1R53pQlGAfc4y4XuMRZfqeMYLE0dM1LMhqbGAlGQY0lfw5/ohoYWAe9V1yibRag==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", "dev": true, - "dependencies": { - "@babel/types": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-environment-visitor/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-environment-visitor/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, "engines": { "node": ">=6.9.0" } @@ -365,127 +254,26 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/helper-explode-assignable-expression/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-explode-assignable-expression/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/helper-function-name": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.16.7.tgz", - "integrity": "sha512-QfDfEnIUyyBSR3HtrtGECuZ6DAyCkYFp7GHl75vFtTnn6pjKeK0T1DB5lLkFvBea8MdaiUABx3osbgLyInoejA==", - "dev": true, - "dependencies": { - "@babel/helper-get-function-arity": "^7.16.7", - "@babel/template": "^7.16.7", - "@babel/types": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-function-name/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-function-name/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-get-function-arity": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.16.7.tgz", - "integrity": "sha512-flc+RLSOBXzNzVhcLu6ujeHUrD6tANAOU5ojrRx/as+tbzf8+stUCj7+IfRRoAbEZqj/ahXEMsjhOhgeZsrnTw==", - "dev": true, - "dependencies": { - "@babel/types": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-get-function-arity/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-get-function-arity/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-hoist-variables": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.7.tgz", - "integrity": "sha512-m04d/0Op34H5v7pbZw6pSKP7weA6lsMvfiIAMeIvkY/R4xQtBSMFEigu9QTZ2qB/9l22vsxtM8a+Q8CzD255fg==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz", + "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==", "dev": true, "dependencies": { - "@babel/types": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-hoist-variables/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-hoist-variables/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -503,28 +291,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/helper-member-expression-to-functions/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-member-expression-to-functions/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/helper-module-imports": { "version": "7.15.4", "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.15.4.tgz", @@ -568,28 +334,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/helper-module-transforms/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-transforms/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/helper-optimise-call-expression": { "version": "7.16.7", "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.16.7.tgz", @@ -602,28 +346,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/helper-optimise-call-expression/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-optimise-call-expression/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/helper-plugin-utils": { "version": "7.16.7", "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.16.7.tgz", @@ -647,28 +369,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/helper-remap-async-to-generator/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-remap-async-to-generator/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/helper-replace-supers": { "version": "7.16.7", "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.16.7.tgz", @@ -685,28 +385,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/helper-replace-supers/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-replace-supers/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/helper-simple-access": { "version": "7.16.7", "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.16.7.tgz", @@ -719,28 +397,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/helper-simple-access/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-simple-access/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/helper-skip-transparent-expression-wrappers": { "version": "7.16.0", "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.16.0.tgz", @@ -753,66 +409,31 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/helper-skip-transparent-expression-wrappers/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-skip-transparent-expression-wrappers/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/helper-split-export-declaration": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.7.tgz", - "integrity": "sha512-xbWoy/PFoxSWazIToT9Sif+jJTlrMcndIsaOKvTA6u7QEo7ilkRZpjew18/W3c7nm8fXdUDXh02VXTbZ0pGDNw==", + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", "dev": true, "dependencies": { - "@babel/types": "^7.16.7" + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/helper-split-export-declaration/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-split-export-declaration/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", + "node_modules/@babel/helper-string-parser": { + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz", + "integrity": "sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==", "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.15.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz", - "integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "dev": true, "engines": { "node": ">=6.9.0" @@ -842,28 +463,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/helper-wrap-function/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-wrap-function/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/helpers": { "version": "7.17.2", "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.17.2.tgz", @@ -878,55 +477,24 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/helpers/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helpers/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/highlight": { - "version": "7.16.10", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.16.10.tgz", - "integrity": "sha512-5FnTQLSLswEj6IkgVw5KusNUUFY9ZGqe/TRFnP/BKYHYgfh7tc+C7mwiy95/yNP7Dh9x580Vv8r7u7ZfTBFxdw==", + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.23.4.tgz", + "integrity": "sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "chalk": "^2.0.0", + "@babel/helper-validator-identifier": "^7.22.20", + "chalk": "^2.4.2", "js-tokens": "^4.0.0" }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/highlight/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/parser": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.17.0.tgz", - "integrity": "sha512-VKXSCQx5D8S04ej+Dqsr1CzYvvWgf20jIw2D+YhQCrIlr2UZGaDds23Y0xg75/skOxpLCRpUZvk/1EAVkGoDOw==", + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.6.tgz", + "integrity": "sha512-Z2uID7YJ7oNvAI20O9X0bblw7Qqs8Q2hFy0R9tAfnfLkp5MW0UH9eUvnDSnFwKZ0AvgS1ucqR4KzvVHgnke1VQ==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -1451,28 +1019,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/plugin-transform-async-to-generator/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/plugin-transform-async-to-generator/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/plugin-transform-block-scoped-functions": { "version": "7.16.7", "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.16.7.tgz", @@ -1718,15 +1264,6 @@ "@babel/core": "^7.0.0-0" } }, - "node_modules/@babel/plugin-transform-modules-systemjs/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/plugin-transform-modules-umd": { "version": "7.16.7", "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.16.7.tgz", @@ -1881,28 +1418,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/plugin-transform-runtime/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/plugin-transform-runtime/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/plugin-transform-shorthand-properties": { "version": "7.16.7", "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.16.7.tgz", @@ -2098,28 +1613,6 @@ "@babel/core": "^7.0.0-0" } }, - "node_modules/@babel/preset-env/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/preset-env/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/preset-modules": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.5.tgz", @@ -2162,91 +1655,48 @@ } }, "node_modules/@babel/template": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.16.7.tgz", - "integrity": "sha512-I8j/x8kHUrbYRTUxXrrMbfCa7jxkE7tZre39x3kjr9hvI82cK1FfqLygotcWN5kdPGWcLdWMHpSBavse5tWw3w==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.16.7", - "@babel/parser": "^7.16.7", - "@babel/types": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/template/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/template/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.17.0.tgz", - "integrity": "sha512-fpFIXvqD6kC7c7PUNnZ0Z8cQXlarCLtCUpt2S1Dx7PjoRtCFffvOkHHSom+m5HIxMZn5bIBVb71lhabcmjEsqg==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.16.7", - "@babel/generator": "^7.17.0", - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-function-name": "^7.16.7", - "@babel/helper-hoist-variables": "^7.16.7", - "@babel/helper-split-export-declaration": "^7.16.7", - "@babel/parser": "^7.17.0", - "@babel/types": "^7.17.0", - "debug": "^4.1.0", + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.6.tgz", + "integrity": "sha512-czastdK1e8YByZqezMPFiZ8ahwVMh/ESl9vPgvgdB9AmFMGP5jfpFax74AQgl5zj4XHzqeYAg2l8PuUeRS1MgQ==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.23.5", + "@babel/generator": "^7.23.6", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", + "@babel/helper-hoist-variables": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/parser": "^7.23.6", + "@babel/types": "^7.23.6", + "debug": "^4.3.1", "globals": "^11.1.0" }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/traverse/node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/traverse/node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/types": { - "version": "7.15.6", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.15.6.tgz", - "integrity": "sha512-BPU+7QhqNjmWyDO0/vitH/CuhpV8ZmK1wpKva8nuyNF5MJfuRNWMc+hc14+u9xT93kvykMdncrJT19h74uB1Ig==", + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.6.tgz", + "integrity": "sha512-+uarb83brBzPKN38NX1MkB6vb6+mwvR6amUulqAE7ccQw1pEl+bCia9TbdG1lsnFP7lZySvUn37CHyXQdfTwzg==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.14.9", + "@babel/helper-string-parser": "^7.23.4", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" }, "engines": { @@ -2455,29 +1905,52 @@ "resolved": "https://registry.npmjs.org/@jcubic/lily/-/lily-0.3.0.tgz", "integrity": "sha512-4z6p4jLGSthc8gQ7wu4nHfGYn/IgCKFr+7hjuf80VdXUs7sm029mZGGDpS8sb29PVZWUBvMMTBCVGFhH2nN4Vw==" }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", + "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@jridgewell/resolve-uri": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.5.tgz", - "integrity": "sha512-VPeQ7+wH0itvQxnG+lIzWgkysKIr3L9sslimFW55rHMdGu/qCQ5z5h9zq4gI8uBtqkpHhsF4Z/OwExufUCThew==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", + "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", "dev": true, "engines": { "node": ">=6.0.0" } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.11", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.11.tgz", - "integrity": "sha512-Fg32GrJo61m+VqYSdRSjRXMjQ06j8YIYfcTqndLYVAaHmroZHLJZCydsWBOTDqXS2v+mjxohBWEMfg97GXmYQg==", + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", "dev": true }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.4.tgz", - "integrity": "sha512-vFv9ttIedivx0ux3QSjhgtCVjPZd5l46ZOMDSCwnH1yUO2e964gO8LZGyv2QkqcgR6TnBU1v+1IFqmeoG+0UJQ==", + "version": "0.3.20", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz", + "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==", "dev": true, "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" } }, "node_modules/@mermaid-js/mermaid-cli": { @@ -2814,7 +2287,7 @@ "node_modules/ansi-styles/node_modules/color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", "dev": true }, "node_modules/anymatch": { @@ -3894,9 +3367,9 @@ } }, "node_modules/babel-preset-env/node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "dev": true, "bin": { "semver": "bin/semver" @@ -4181,34 +3654,37 @@ } }, "node_modules/browserslist": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.19.1.tgz", - "integrity": "sha512-u2tbbG5PdKRTUoctO3NBD8FQ5HdPh1ZXPHzp1rwaa5jTc+RV9/+RlWiAIKmjRPQF+xbGM9Kklj5bZQFa2s/38A==", + "version": "4.22.2", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.2.tgz", + "integrity": "sha512-0UgcrvQmBDvZHFGdYUehrCNIazki7/lUP3kkoi/r3YB2amZbFM9J43ZRkJTXBUZK4gmx56+Sqk9+Vs9mwZx9+A==", "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], "dependencies": { - "caniuse-lite": "^1.0.30001286", - "electron-to-chromium": "^1.4.17", - "escalade": "^3.1.1", - "node-releases": "^2.0.1", - "picocolors": "^1.0.0" + "caniuse-lite": "^1.0.30001565", + "electron-to-chromium": "^1.4.601", + "node-releases": "^2.0.14", + "update-browserslist-db": "^1.0.13" }, "bin": { "browserslist": "cli.js" }, "engines": { "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" } }, - "node_modules/browserslist/node_modules/electron-to-chromium": { - "version": "1.4.68", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.68.tgz", - "integrity": "sha512-cId+QwWrV8R1UawO6b9BR1hnkJ4EJPCPAr4h315vliHUtVUJDk39Sg1PMNnaWKfj5x+93ssjeJ9LKL6r8LaMiA==", - "dev": true - }, "node_modules/buffer": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", @@ -4436,9 +3912,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001564", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001564.tgz", - "integrity": "sha512-DqAOf+rhof+6GVx1y+xzbFPeOumfQnhYzVnZD6LAXijR77yPtm9mfOcqOnT3mpnJiZVT+kwLAFnRlZcIz+c6bg==", + "version": "1.0.30001571", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001571.tgz", + "integrity": "sha512-tYq/6MoXhdezDLFZuCO/TKboTzuQ/xR5cFdgXPfDtM7/kchBO3b4VWghE/OAi/DV7tTdhmLjZiZBZi1fA/GheQ==", "dev": true, "funding": [ { @@ -4768,9 +4244,9 @@ } }, "node_modules/concordance/node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -4809,28 +4285,18 @@ "hasInstallScript": true }, "node_modules/core-js-compat": { - "version": "3.21.0", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.21.0.tgz", - "integrity": "sha512-OSXseNPSK2OPJa6GdtkMz/XxeXx8/CJvfhQWTqd6neuUraujcL4jVsjkLQz1OWnax8xVQJnRPe0V2jqNWORA+A==", + "version": "3.34.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.34.0.tgz", + "integrity": "sha512-4ZIyeNbW/Cn1wkMMDy+mvrRUxrwFNjKwbhCfQpDd+eLgYipDqp8oGFGtLmhh18EDPKA0g3VUBYOxQGGwvWLVpA==", "dev": true, "dependencies": { - "browserslist": "^4.19.1", - "semver": "7.0.0" + "browserslist": "^4.22.2" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/core-js" } }, - "node_modules/core-js-compat/node_modules/semver": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", - "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - } - }, "node_modules/core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -5129,9 +4595,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.3.876", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.876.tgz", - "integrity": "sha512-a6LR4738psrubCtGx5HxM/gNlrIsh4eFTNnokgOqvQo81GWd07lLcOjITkAXn2y4lIp18vgS+DGnehj+/oEAxQ==", + "version": "1.4.616", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.616.tgz", + "integrity": "sha512-1n7zWYh8eS0L9Uy+GskE0lkBUNK83cXTVJI0pU3mGprFsbfSdAc15VTFbo+A+Bq4pwstmL30AVcEU3Fo463lNg==", "dev": true }, "node_modules/emittery": { @@ -5980,7 +5446,7 @@ "node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true, "engines": { "node": ">=4" @@ -6965,9 +6431,9 @@ } }, "node_modules/node-releases": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.2.tgz", - "integrity": "sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg==", + "version": "2.0.14", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", + "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==", "dev": true }, "node_modules/nofilter": { @@ -8172,9 +7638,9 @@ "dev": true }, "node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -8289,15 +7755,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/sourcemap-codec": { "version": "1.4.8", "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", @@ -8714,6 +8171,36 @@ "node": ">=4" } }, + "node_modules/update-browserslist-db": { + "version": "1.0.13", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", + "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -8835,9 +8322,9 @@ "dev": true }, "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -9004,12 +8491,13 @@ } }, "@babel/code-frame": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz", - "integrity": "sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg==", + "version": "7.23.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.5.tgz", + "integrity": "sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA==", "dev": true, "requires": { - "@babel/highlight": "^7.16.7" + "@babel/highlight": "^7.23.4", + "chalk": "^2.4.2" } }, "@babel/compat-data": { @@ -9039,53 +8527,18 @@ "gensync": "^1.0.0-beta.2", "json5": "^2.1.2", "semver": "^6.3.0" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } } }, "@babel/generator": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.17.0.tgz", - "integrity": "sha512-I3Omiv6FGOC29dtlZhkfXO6pgkmukJSlT26QjVvS1DGZe/NzSVCPG41X0tS21oZkJYlovfj9qDWgKP+Cn4bXxw==", + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.6.tgz", + "integrity": "sha512-qrSfCYxYQB5owCmGLbl8XRpX1ytXlpueOb0N0UmQwA073KZxejgQTzAmJezxvpwQD9uGtK2shHdi55QT+MbjIw==", "dev": true, "requires": { - "@babel/types": "^7.17.0", - "jsesc": "^2.5.1", - "source-map": "^0.5.0" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } + "@babel/types": "^7.23.6", + "@jridgewell/gen-mapping": "^0.3.2", + "@jridgewell/trace-mapping": "^0.3.17", + "jsesc": "^2.5.1" } }, "@babel/helper-annotate-as-pure": { @@ -9095,52 +8548,16 @@ "dev": true, "requires": { "@babel/types": "^7.16.7" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } } }, "@babel/helper-builder-binary-assignment-operator-visitor": { "version": "7.16.7", "resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.16.7.tgz", "integrity": "sha512-C6FdbRaxYjwVu/geKW4ZeQ0Q31AftgRcdSnZ5/jsH6BzCJbtvXvhpfkbkThYSuutZA7nCXpPR6AD9zd1dprMkA==", - "dev": true, - "requires": { - "@babel/helper-explode-assignable-expression": "^7.16.7", - "@babel/types": "^7.16.7" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } + "dev": true, + "requires": { + "@babel/helper-explode-assignable-expression": "^7.16.7", + "@babel/types": "^7.16.7" } }, "@babel/helper-compilation-targets": { @@ -9197,31 +8614,10 @@ } }, "@babel/helper-environment-visitor": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.16.7.tgz", - "integrity": "sha512-SLLb0AAn6PkUeAfKJCCOl9e1R53pQlGAfc4y4XuMRZfqeMYLE0dM1LMhqbGAlGQY0lfw5/ohoYWAe9V1yibRag==", - "dev": true, - "requires": { - "@babel/types": "^7.16.7" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } - } + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", + "dev": true }, "@babel/helper-explode-assignable-expression": { "version": "7.16.7", @@ -9230,107 +8626,25 @@ "dev": true, "requires": { "@babel/types": "^7.16.7" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } } }, "@babel/helper-function-name": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.16.7.tgz", - "integrity": "sha512-QfDfEnIUyyBSR3HtrtGECuZ6DAyCkYFp7GHl75vFtTnn6pjKeK0T1DB5lLkFvBea8MdaiUABx3osbgLyInoejA==", - "dev": true, - "requires": { - "@babel/helper-get-function-arity": "^7.16.7", - "@babel/template": "^7.16.7", - "@babel/types": "^7.16.7" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } - } - }, - "@babel/helper-get-function-arity": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.16.7.tgz", - "integrity": "sha512-flc+RLSOBXzNzVhcLu6ujeHUrD6tANAOU5ojrRx/as+tbzf8+stUCj7+IfRRoAbEZqj/ahXEMsjhOhgeZsrnTw==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", "dev": true, "requires": { - "@babel/types": "^7.16.7" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" } }, "@babel/helper-hoist-variables": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.7.tgz", - "integrity": "sha512-m04d/0Op34H5v7pbZw6pSKP7weA6lsMvfiIAMeIvkY/R4xQtBSMFEigu9QTZ2qB/9l22vsxtM8a+Q8CzD255fg==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz", + "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==", "dev": true, "requires": { - "@babel/types": "^7.16.7" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } + "@babel/types": "^7.22.5" } }, "@babel/helper-member-expression-to-functions": { @@ -9340,24 +8654,6 @@ "dev": true, "requires": { "@babel/types": "^7.16.7" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } } }, "@babel/helper-module-imports": { @@ -9393,22 +8689,6 @@ "requires": { "@babel/types": "^7.16.7" } - }, - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } } } }, @@ -9419,24 +8699,6 @@ "dev": true, "requires": { "@babel/types": "^7.16.7" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } } }, "@babel/helper-plugin-utils": { @@ -9454,24 +8716,6 @@ "@babel/helper-annotate-as-pure": "^7.16.7", "@babel/helper-wrap-function": "^7.16.8", "@babel/types": "^7.16.8" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } } }, "@babel/helper-replace-supers": { @@ -9485,24 +8729,6 @@ "@babel/helper-optimise-call-expression": "^7.16.7", "@babel/traverse": "^7.16.7", "@babel/types": "^7.16.7" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } } }, "@babel/helper-simple-access": { @@ -9512,24 +8738,6 @@ "dev": true, "requires": { "@babel/types": "^7.16.7" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } } }, "@babel/helper-skip-transparent-expression-wrappers": { @@ -9539,57 +8747,27 @@ "dev": true, "requires": { "@babel/types": "^7.16.0" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } } }, "@babel/helper-split-export-declaration": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.7.tgz", - "integrity": "sha512-xbWoy/PFoxSWazIToT9Sif+jJTlrMcndIsaOKvTA6u7QEo7ilkRZpjew18/W3c7nm8fXdUDXh02VXTbZ0pGDNw==", + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", "dev": true, "requires": { - "@babel/types": "^7.16.7" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } + "@babel/types": "^7.22.5" } }, + "@babel/helper-string-parser": { + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz", + "integrity": "sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==", + "dev": true + }, "@babel/helper-validator-identifier": { - "version": "7.15.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz", - "integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "dev": true }, "@babel/helper-validator-option": { @@ -9608,24 +8786,6 @@ "@babel/template": "^7.16.7", "@babel/traverse": "^7.16.8", "@babel/types": "^7.16.8" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } } }, "@babel/helpers": { @@ -9637,49 +8797,23 @@ "@babel/template": "^7.16.7", "@babel/traverse": "^7.17.0", "@babel/types": "^7.17.0" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } } }, "@babel/highlight": { - "version": "7.16.10", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.16.10.tgz", - "integrity": "sha512-5FnTQLSLswEj6IkgVw5KusNUUFY9ZGqe/TRFnP/BKYHYgfh7tc+C7mwiy95/yNP7Dh9x580Vv8r7u7ZfTBFxdw==", + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.23.4.tgz", + "integrity": "sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "chalk": "^2.0.0", + "@babel/helper-validator-identifier": "^7.22.20", + "chalk": "^2.4.2", "js-tokens": "^4.0.0" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - } } }, "@babel/parser": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.17.0.tgz", - "integrity": "sha512-VKXSCQx5D8S04ej+Dqsr1CzYvvWgf20jIw2D+YhQCrIlr2UZGaDds23Y0xg75/skOxpLCRpUZvk/1EAVkGoDOw==", + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.6.tgz", + "integrity": "sha512-Z2uID7YJ7oNvAI20O9X0bblw7Qqs8Q2hFy0R9tAfnfLkp5MW0UH9eUvnDSnFwKZ0AvgS1ucqR4KzvVHgnke1VQ==", "dev": true }, "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { @@ -10023,22 +9157,6 @@ "requires": { "@babel/types": "^7.16.7" } - }, - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } } } }, @@ -10195,14 +9313,6 @@ "@babel/helper-plugin-utils": "^7.16.7", "@babel/helper-validator-identifier": "^7.16.7", "babel-plugin-dynamic-import-node": "^2.3.3" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - } } }, "@babel/plugin-transform-modules-umd": { @@ -10301,22 +9411,6 @@ "requires": { "@babel/types": "^7.16.7" } - }, - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } } } }, @@ -10465,24 +9559,6 @@ "babel-plugin-polyfill-regenerator": "^0.3.0", "core-js-compat": "^3.20.2", "semver": "^6.3.0" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } } }, "@babel/preset-modules": { @@ -10518,77 +9594,42 @@ } }, "@babel/template": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.16.7.tgz", - "integrity": "sha512-I8j/x8kHUrbYRTUxXrrMbfCa7jxkE7tZre39x3kjr9hvI82cK1FfqLygotcWN5kdPGWcLdWMHpSBavse5tWw3w==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", "dev": true, "requires": { - "@babel/code-frame": "^7.16.7", - "@babel/parser": "^7.16.7", - "@babel/types": "^7.16.7" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" } }, "@babel/traverse": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.17.0.tgz", - "integrity": "sha512-fpFIXvqD6kC7c7PUNnZ0Z8cQXlarCLtCUpt2S1Dx7PjoRtCFffvOkHHSom+m5HIxMZn5bIBVb71lhabcmjEsqg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.16.7", - "@babel/generator": "^7.17.0", - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-function-name": "^7.16.7", - "@babel/helper-hoist-variables": "^7.16.7", - "@babel/helper-split-export-declaration": "^7.16.7", - "@babel/parser": "^7.17.0", - "@babel/types": "^7.17.0", - "debug": "^4.1.0", + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.6.tgz", + "integrity": "sha512-czastdK1e8YByZqezMPFiZ8ahwVMh/ESl9vPgvgdB9AmFMGP5jfpFax74AQgl5zj4XHzqeYAg2l8PuUeRS1MgQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.23.5", + "@babel/generator": "^7.23.6", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", + "@babel/helper-hoist-variables": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/parser": "^7.23.6", + "@babel/types": "^7.23.6", + "debug": "^4.3.1", "globals": "^11.1.0" - }, - "dependencies": { - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "to-fast-properties": "^2.0.0" - } - } } }, "@babel/types": { - "version": "7.15.6", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.15.6.tgz", - "integrity": "sha512-BPU+7QhqNjmWyDO0/vitH/CuhpV8ZmK1wpKva8nuyNF5MJfuRNWMc+hc14+u9xT93kvykMdncrJT19h74uB1Ig==", + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.6.tgz", + "integrity": "sha512-+uarb83brBzPKN38NX1MkB6vb6+mwvR6amUulqAE7ccQw1pEl+bCia9TbdG1lsnFP7lZySvUn37CHyXQdfTwzg==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.14.9", + "@babel/helper-string-parser": "^7.23.4", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" } }, @@ -10730,26 +9771,43 @@ "resolved": "https://registry.npmjs.org/@jcubic/lily/-/lily-0.3.0.tgz", "integrity": "sha512-4z6p4jLGSthc8gQ7wu4nHfGYn/IgCKFr+7hjuf80VdXUs7sm029mZGGDpS8sb29PVZWUBvMMTBCVGFhH2nN4Vw==" }, + "@jridgewell/gen-mapping": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", + "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "dev": true, + "requires": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, "@jridgewell/resolve-uri": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.5.tgz", - "integrity": "sha512-VPeQ7+wH0itvQxnG+lIzWgkysKIr3L9sslimFW55rHMdGu/qCQ5z5h9zq4gI8uBtqkpHhsF4Z/OwExufUCThew==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", + "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", + "dev": true + }, + "@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", "dev": true }, "@jridgewell/sourcemap-codec": { - "version": "1.4.11", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.11.tgz", - "integrity": "sha512-Fg32GrJo61m+VqYSdRSjRXMjQ06j8YIYfcTqndLYVAaHmroZHLJZCydsWBOTDqXS2v+mjxohBWEMfg97GXmYQg==", + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", "dev": true }, "@jridgewell/trace-mapping": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.4.tgz", - "integrity": "sha512-vFv9ttIedivx0ux3QSjhgtCVjPZd5l46ZOMDSCwnH1yUO2e964gO8LZGyv2QkqcgR6TnBU1v+1IFqmeoG+0UJQ==", + "version": "0.3.20", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz", + "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==", "dev": true, "requires": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" } }, "@mermaid-js/mermaid-cli": { @@ -10999,7 +10057,7 @@ "color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", "dev": true } } @@ -11985,9 +11043,9 @@ } }, "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "dev": true } } @@ -12247,24 +11305,15 @@ } }, "browserslist": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.19.1.tgz", - "integrity": "sha512-u2tbbG5PdKRTUoctO3NBD8FQ5HdPh1ZXPHzp1rwaa5jTc+RV9/+RlWiAIKmjRPQF+xbGM9Kklj5bZQFa2s/38A==", + "version": "4.22.2", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.2.tgz", + "integrity": "sha512-0UgcrvQmBDvZHFGdYUehrCNIazki7/lUP3kkoi/r3YB2amZbFM9J43ZRkJTXBUZK4gmx56+Sqk9+Vs9mwZx9+A==", "dev": true, "requires": { - "caniuse-lite": "^1.0.30001286", - "electron-to-chromium": "^1.4.17", - "escalade": "^3.1.1", - "node-releases": "^2.0.1", - "picocolors": "^1.0.0" - }, - "dependencies": { - "electron-to-chromium": { - "version": "1.4.68", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.68.tgz", - "integrity": "sha512-cId+QwWrV8R1UawO6b9BR1hnkJ4EJPCPAr4h315vliHUtVUJDk39Sg1PMNnaWKfj5x+93ssjeJ9LKL6r8LaMiA==", - "dev": true - } + "caniuse-lite": "^1.0.30001565", + "electron-to-chromium": "^1.4.601", + "node-releases": "^2.0.14", + "update-browserslist-db": "^1.0.13" } }, "buffer": { @@ -12416,9 +11465,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001564", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001564.tgz", - "integrity": "sha512-DqAOf+rhof+6GVx1y+xzbFPeOumfQnhYzVnZD6LAXijR77yPtm9mfOcqOnT3mpnJiZVT+kwLAFnRlZcIz+c6bg==", + "version": "1.0.30001571", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001571.tgz", + "integrity": "sha512-tYq/6MoXhdezDLFZuCO/TKboTzuQ/xR5cFdgXPfDtM7/kchBO3b4VWghE/OAi/DV7tTdhmLjZiZBZi1fA/GheQ==", "dev": true }, "caseless": { @@ -12665,9 +11714,9 @@ }, "dependencies": { "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, "requires": { "lru-cache": "^6.0.0" @@ -12697,21 +11746,12 @@ "dev": true }, "core-js-compat": { - "version": "3.21.0", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.21.0.tgz", - "integrity": "sha512-OSXseNPSK2OPJa6GdtkMz/XxeXx8/CJvfhQWTqd6neuUraujcL4jVsjkLQz1OWnax8xVQJnRPe0V2jqNWORA+A==", + "version": "3.34.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.34.0.tgz", + "integrity": "sha512-4ZIyeNbW/Cn1wkMMDy+mvrRUxrwFNjKwbhCfQpDd+eLgYipDqp8oGFGtLmhh18EDPKA0g3VUBYOxQGGwvWLVpA==", "dev": true, "requires": { - "browserslist": "^4.19.1", - "semver": "7.0.0" - }, - "dependencies": { - "semver": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", - "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", - "dev": true - } + "browserslist": "^4.22.2" } }, "core-util-is": { @@ -12942,9 +11982,9 @@ } }, "electron-to-chromium": { - "version": "1.3.876", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.876.tgz", - "integrity": "sha512-a6LR4738psrubCtGx5HxM/gNlrIsh4eFTNnokgOqvQo81GWd07lLcOjITkAXn2y4lIp18vgS+DGnehj+/oEAxQ==", + "version": "1.4.616", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.616.tgz", + "integrity": "sha512-1n7zWYh8eS0L9Uy+GskE0lkBUNK83cXTVJI0pU3mGprFsbfSdAc15VTFbo+A+Bq4pwstmL30AVcEU3Fo463lNg==", "dev": true }, "emittery": { @@ -13569,7 +12609,7 @@ "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true }, "has-symbols": { @@ -14302,9 +13342,9 @@ } }, "node-releases": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.2.tgz", - "integrity": "sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg==", + "version": "2.0.14", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", + "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==", "dev": true }, "nofilter": { @@ -15194,9 +14234,9 @@ "dev": true }, "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true }, "serialize-error": { @@ -15273,12 +14313,6 @@ } } }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - }, "sourcemap-codec": { "version": "1.4.8", "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", @@ -15597,6 +14631,16 @@ "integrity": "sha512-5Zfuy9q/DFr4tfO7ZPeVXb1aPoeQSdeFMLpYuFebehDAhbuevLs5yxSZmIFN1tP5F9Wl4IpJrYojg85/zgyZHQ==", "dev": true }, + "update-browserslist-db": { + "version": "1.0.13", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", + "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==", + "dev": true, + "requires": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + } + }, "uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -15698,9 +14742,9 @@ "dev": true }, "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true }, "wrap-ansi": {