diff --git a/.babelrc b/.babelrc index 50a67e466..0084d9cf1 100755 --- a/.babelrc +++ b/.babelrc @@ -1,6 +1,8 @@ { "presets": [ "@babel/preset-env" ], "plugins": [ - ["@babel/plugin-proposal-unicode-property-regex", { "useUnicodeFlag": true } ] - ] + ["@babel/plugin-proposal-unicode-property-regex", { "useUnicodeFlag": true } ], + "@babel/plugin-transform-async-to-generator" + ], + "exclude": "node_modules/**" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e9f5fbd4..1998684da 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 1.0.0-beta.18 ### Breaking * change undocumented arguments to `lips.exec` into an object +* change default export into named exports in ES Module ### Features * add R7RS `guard` macro * add R7RS `parameterize` and `make-parameter` diff --git a/README.md b/README.md index 5de07be4a..e99849520 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.17.3-blue.svg)](https://www.npmjs.com/package/@jcubic/lips) ![1.0.0 Complete](https://img.shields.io/github/milestones/progress-percent/jcubic/lips/1?label=1.0.0%20Complete) [![Build and test](https://github.com/jcubic/lips/actions/workflows/build.yaml/badge.svg?branch=devel&event=push)](https://github.com/jcubic/lips/actions/workflows/build.yaml) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&2e7e0b1862a2305e742516ca7b9b78fa)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&0d64da01024c8309dbef946ddb8c1571)](https://coveralls.io/github/jcubic/lips?branch=devel) [![Join Gitter Chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jcubic/lips) ![NPM Download Count](https://img.shields.io/npm/dm/@jcubic/lips) ![JSDelivr Download count](https://img.shields.io/jsdelivr/npm/hm/@jcubic/lips) diff --git a/bin/lips.js b/bin/lips.js index 8d6497772..732ecce17 100755 --- a/bin/lips.js +++ b/bin/lips.js @@ -9,12 +9,7 @@ const options = lily(process.argv.slice(2), { boolean }); const quiet = options.q || options.quiet; -import lips from '../src/lips.js'; -import lips_dist from '../dist/lips.esm.js'; - -const { version, date } = lips_dist; - -const { +import { exec, compile, parse, @@ -35,7 +30,9 @@ const { env, banner, InputPort, - OutputPort } = lips; + OutputPort +} from '../src/lips.js'; +import { version, date } from '../dist/lips.esm.js'; import fs from 'fs'; import os from 'os'; diff --git a/dist/lips.esm.js b/dist/lips.esm.js index 5d5a9306c..7567e7e00 100644 --- a/dist/lips.esm.js +++ b/dist/lips.esm.js @@ -5796,7 +5796,7 @@ function unfetch(e,n){return n=n||{},new Promise(function(t,r){var s=new XMLHttp * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Mon, 15 Jan 2024 12:39:38 +0000 + * build: Mon, 15 Jan 2024 14:02:37 +0000 */ var _excluded = ["token"], _excluded2 = ["env"], @@ -7821,11 +7821,11 @@ var DatumReference = /*#__PURE__*/function () { // :: 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(_x, _x2) { + return _parse2.apply(this, arguments); } // ---------------------------------------------------------------------- -function _parse() { - _parse = _wrapAsyncGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(arg, env) { +function _parse2() { + _parse2 = _wrapAsyncGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(arg, env) { var parser, prev, expr; return _regeneratorRuntime.wrap(function _callee9$(_context9) { while (1) { @@ -7870,7 +7870,7 @@ function _parse() { } }, _callee9); })); - return _parse.apply(this, arguments); + return _parse2.apply(this, arguments); } function unpromise(value) { var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (x) { @@ -7954,9 +7954,9 @@ function uniterate_async(_x5) { // :: Function that return matcher function that match string against string // ---------------------------------------------------------------------- function _uniterate_async() { - _uniterate_async = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(object) { + _uniterate_async = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(object) { var result, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, item; - return _regeneratorRuntime.wrap(function _callee22$(_context22) { + return _regeneratorRuntime.wrap(function _callee21$(_context22) { while (1) { switch (_context22.prev = _context22.next) { case 0: @@ -8014,7 +8014,7 @@ function _uniterate_async() { return _context22.stop(); } } - }, _callee22, null, [[3, 15, 19, 29], [20,, 24, 28]]); + }, _callee21, null, [[3, 15, 19, 29], [20,, 24, 28]]); })); return _uniterate_async.apply(this, arguments); } @@ -13623,7 +13623,7 @@ function quote(value) { 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; @@ -13772,7 +13772,7 @@ var global_env = new Environment({ _iteratorAbruptCompletion2 = false; _didIteratorError2 = false; _context16.prev = 5; - _iterator2 = _asyncIterator(parse(arg, env)); + _iterator2 = _asyncIterator(_parse(arg, env)); case 7: _context16.next = 9; return _iterator2.next(); @@ -14223,9 +14223,9 @@ var global_env = new Environment({ }, "(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': doc(new Macro('do', /*#__PURE__*/function () { - var _ref31 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(code, _ref32) { + var _ref31 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(code, _ref32) { var use_dynamic, error, self, dynamic_env, scope, vars, test, body, eval_args, node, item, _loop3; - return _regeneratorRuntime.wrap(function _callee19$(_context19) { + return _regeneratorRuntime.wrap(function _callee18$(_context19) { while (1) { switch (_context19.prev = _context19.next) { case 0: @@ -14268,9 +14268,9 @@ var global_env = new Environment({ dynamic_env: dynamic_env, error: error }; - _loop3 = /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() { + _loop3 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop3() { var node, next, _item, value, symbols; - return _regeneratorRuntime.wrap(function _callee18$(_context18) { + return _regeneratorRuntime.wrap(function _loop3$(_context18) { while (1) { switch (_context18.prev = _context18.next) { case 0: @@ -14312,7 +14312,7 @@ var global_env = new Environment({ return _context18.stop(); } } - }, _callee18); + }, _loop3); }); case 23: _context19.next = 25; @@ -14341,7 +14341,7 @@ var global_env = new Environment({ return _context19.stop(); } } - }, _callee19, this); + }, _callee18, this); })); return function (_x15, _x16) { return _ref31.apply(this, arguments); @@ -16191,14 +16191,14 @@ function node_specific() { } // ------------------------------------------------------------------------- /* c8 ignore next 11 */ function _node_specific() { - _node_specific = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23() { + _node_specific = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22() { var _yield$import, createRequire, moduleURL, __dirname, __filename; - return _regeneratorRuntime.wrap(function _callee23$(_context23) { + return _regeneratorRuntime.wrap(function _callee22$(_context23) { while (1) { switch (_context23.prev = _context23.next) { case 0: _context23.next = 2; - return Promise.resolve().then(function () { return empty$1; }); + return import('mod' + 'ule'); case 2: _yield$import = _context23.sent; createRequire = _yield$import.createRequire; @@ -16252,7 +16252,7 @@ function _node_specific() { return _context23.stop(); } } - }, _callee23); + }, _callee22); })); return _node_specific.apply(this, arguments); } @@ -16449,9 +16449,9 @@ function resolve_promises(arg) { return _promise.apply(this, arguments); } function _promise() { - _promise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(node) { + _promise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(node) { var pair; - return _regeneratorRuntime.wrap(function _callee20$(_context20) { + return _regeneratorRuntime.wrap(function _callee19$(_context20) { while (1) { switch (_context20.prev = _context20.next) { case 0: @@ -16494,7 +16494,7 @@ function resolve_promises(arg) { return _context20.stop(); } } - }, _callee20); + }, _callee19); })); return _promise.apply(this, arguments); } @@ -16906,7 +16906,7 @@ var exec = exec_collect(function (code, value) { // ------------------------------------------------------------------------- function exec_collect(collect_callback) { return /*#__PURE__*/function () { - var _exec_lambda = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(arg) { + var _exec_lambda = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(arg) { var _ref47, env, dynamic_env, @@ -16921,7 +16921,7 @@ function exec_collect(collect_callback) { code, value, _args24 = arguments; - return _regeneratorRuntime.wrap(function _callee21$(_context21) { + return _regeneratorRuntime.wrap(function _callee20$(_context21) { while (1) { switch (_context21.prev = _context21.next) { case 0: @@ -16935,7 +16935,7 @@ function exec_collect(collect_callback) { env = env || user_env; } results = []; - input = Array.isArray(arg) ? arg : parse(arg); + input = Array.isArray(arg) ? arg : _parse(arg); _iteratorAbruptCompletion3 = false; _didIteratorError3 = false; _context21.prev = 7; @@ -17019,7 +17019,7 @@ function exec_collect(collect_callback) { return _context21.stop(); } } - }, _callee21, null, [[7, 27, 31, 41], [32,, 36, 40]]); + }, _callee20, null, [[7, 27, 31, 41], [32,, 36, 40]]); })); function exec_lambda(_x19) { return _exec_lambda.apply(this, arguments); @@ -17546,10 +17546,10 @@ if (typeof window !== 'undefined') { // ------------------------------------------------------------------------- var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Mon, 15 Jan 2024 12:39:38 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Mon, 15 Jan 2024 14:02:37 +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('Mon, 15 Jan 2024 12:39:38 +0000').valueOf(); + var date = LString('Mon, 15 Jan 2024 14:02:37 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); var _format = function _format(x) { return x.toString().padStart(2, '0'); @@ -17587,13 +17587,17 @@ read_only(LString, '__class__', 'string'); read_only(QuotedPromise, '__class__', 'promise'); read_only(Parameter, '__class__', 'parameter'); // ------------------------------------------------------------------------- +var version = 'DEV'; +var date = 'Mon, 15 Jan 2024 14:02:37 +0000'; + +// unwrap async generator into Promise +var parse = compose(uniterate_async, _parse); var lips = { - version: 'DEV', + version: version, banner: banner, - date: 'Mon, 15 Jan 2024 12:39:38 +0000', + date: date, exec: exec, - // unwrap async generator into Promise - parse: compose(uniterate_async, parse), + parse: parse, tokenize: tokenize, evaluate: _evaluate, compile: compile, @@ -17902,4 +17906,4 @@ var path$1 = /*#__PURE__*/Object.freeze({ 'default': path }); -export { lips as default }; +export { BufferedOutputPort, Environment, LipsError as Error, Formatter, InputBinaryFilePort, InputByteVectorPort, InputFilePort, InputPort, InputStringPort, Interpreter, LBigInteger, LCharacter, LComplex, LFloat, LNumber, LRational, LString, LSymbol, Lexer, Macro, OutputBinaryFilePort, OutputByteVectorPort, OutputFilePort, OutputPort, OutputStringPort, Pair, Parameter, Parser, QuotedPromise, Syntax, Values, Worker, balanced, balanced as balancedParenthesis, balanced as balanced_parenthesis, banner, bootstrap, compile, date, user_env as env, eof, _evaluate as evaluate, exec, _nil as nil, parse, quote, rationalize, repr, serialize, serialize_bin, specials, tokenize, unserialize, unserialize_bin, version }; diff --git a/dist/lips.esm.min.js b/dist/lips.esm.min.js index 5ef7737a5..3a2bcf435 100644 --- a/dist/lips.esm.min.js +++ b/dist/lips.esm.min.js @@ -1,10 +1,10 @@ -function _classApplyDescriptorGet(e,t){if(t.get){return t.get.call(e)}return t.value}function _classExtractFieldDescriptor(e,t,r){if(!t.has(e)){throw new TypeError("attempted to "+r+" private field on non-instance")}return t.get(e)}function _classPrivateFieldGet(e,t){var r=_classExtractFieldDescriptor(e,t,"get");return _classApplyDescriptorGet(e,r)}function _classApplyDescriptorSet(e,t,r){if(t.set){t.set.call(e,r)}else{if(!t.writable){throw new TypeError("attempted to set read only private field")}t.value=r}}function _classPrivateFieldSet(e,t,r){var n=_classExtractFieldDescriptor(e,t,"set");_classApplyDescriptorSet(e,n,r);return r}function _assertThisInitialized(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function _setPrototypeOf(e,t){_setPrototypeOf=Object.setPrototypeOf||function e(t,r){t.__proto__=r;return t};return _setPrototypeOf(e,t)}function _isNativeReflectConstruct$1(){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 _construct(e,t,r){if(_isNativeReflectConstruct$1()){_construct=Reflect.construct}else{_construct=function e(t,r,n){var i=[null];i.push.apply(i,r);var a=Function.bind.apply(t,i);var o=new a;if(n)_setPrototypeOf(o,n.prototype);return o}}return _construct.apply(null,arguments)}function _inherits(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)_setPrototypeOf(e,t)}function _typeof(e){"@babel/helpers - typeof";return _typeof="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},_typeof(e)}function _possibleConstructorReturn(e,t){if(t&&(_typeof(t)==="object"||typeof t==="function")){return t}else if(t!==void 0){throw new TypeError("Derived constructors may only return object or undefined")}return _assertThisInitialized(e)}function _getPrototypeOf(e){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function e(t){return t.__proto__||Object.getPrototypeOf(t)};return _getPrototypeOf(e)}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArray(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function _arrayLikeToArray$1(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 _objectWithoutProperties(e,t){if(e==null)return{};var r=_objectWithoutPropertiesLoose(e,t);var n,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;r[n]=e[n]}}return r}function _iterableToArrayLimit(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 a=false;var o,u;try{for(r=r.call(e);!(i=(o=r.next()).done);i=true){n.push(o.value);if(t&&n.length===t)break}}catch(e){a=true;u=e}finally{try{if(!i&&r["return"]!=null)r["return"]()}finally{if(a)throw u}}return n}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray$1(e,t)||_nonIterableRest()}function _AwaitValue(e){this.wrapped=e}function _awaitAsyncGenerator(e){return new _AwaitValue(e)}function AsyncGenerator(a){var o,u;function e(n,i){return new Promise(function(e,t){var r={key:n,arg:i,resolve:e,reject:t,next:null};if(u){u=u.next=r}else{o=u=r;s(n,i)}})}function s(t,e){try{var r=a[t](e);var n=r.value;var i=n instanceof _AwaitValue;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":o.resolve({value:t,done:true});break;case"throw":o.reject(t);break;default:o.resolve({value:t,done:false});break}o=o.next;if(o){s(o.key,o.arg)}else{u=null}}this._invoke=e;if(typeof a["return"]!=="function"){this["return"]=undefined}}AsyncGenerator.prototype[typeof Symbol==="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this};AsyncGenerator.prototype.next=function(e){return this._invoke("next",e)};AsyncGenerator.prototype["throw"]=function(e){return this._invoke("throw",e)};AsyncGenerator.prototype["return"]=function(e){return this._invoke("return",e)};function _wrapAsyncGenerator(e){return function(){return new AsyncGenerator(e.apply(this,arguments))}}function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}var regenerator={exports:{}};var runtime={exports:{}};(function(e){var t=function(o){var e=Object.prototype;var l=e.hasOwnProperty;var s;var u=typeof Symbol==="function"?Symbol:{};var i=u.iterator||"@@iterator";var c=u.asyncIterator||"@@asyncIterator";var p=u.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 h(e,t,r,n){var i=t&&t.prototype instanceof g?t:g;var a=Object.create(i.prototype);var o=new F(n||[]);a._invoke=L(e,r,o);return a}o.wrap=h;function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}var m="suspendedStart";var y="suspendedYield";var v="executing";var f="completed";var _={};function g(){}function n(){}function t(){}var b={};r(b,i,function(){return this});var w=Object.getPrototypeOf;var D=w&&w(w(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var a=t.prototype=g.prototype=Object.create(b);n.prototype=t;r(a,"constructor",t);r(t,"constructor",n);n.displayName=r(t,p,"GeneratorFunction");function x(e){["next","throw","return"].forEach(function(t){r(e,t,function(e){return this._invoke(t,e)})})}o.isGeneratorFunction=function(e){var t=typeof e==="function"&&e.constructor;return t?t===n||(t.displayName||t.name)==="GeneratorFunction":false};o.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,t)}else{e.__proto__=t;r(e,p,"GeneratorFunction")}e.prototype=Object.create(a);return e};o.awrap=function(e){return{__await:e}};function E(u,s){function c(e,t,r,n){var i=d(u[e],u,t);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var o=a.value;if(o&&typeof o==="object"&&l.call(o,"__await")){return s.resolve(o.__await).then(function(e){c("next",e,r,n)},function(e){c("throw",e,r,n)})}return s.resolve(o).then(function(e){a.value=e;r(a)},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}x(E.prototype);r(E.prototype,c,function(){return this});o.AsyncIterator=E;o.async=function(e,t,r,n,i){if(i===void 0)i=Promise;var a=new E(h(e,t,r,n),i);return o.isGeneratorFunction(t)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function L(o,u,s){var c=m;return function e(t,r){if(c===v){throw new Error("Generator is already running")}if(c===f){if(t==="throw"){throw r}return C()}s.method=t;s.arg=r;while(true){var n=s.delegate;if(n){var i=A(n,s);if(i){if(i===_)continue;return i}}if(s.method==="next"){s.sent=s._sent=s.arg}else if(s.method==="throw"){if(c===m){c=f;throw s.arg}s.dispatchException(s.arg)}else if(s.method==="return"){s.abrupt("return",s.arg)}c=v;var a=d(o,u,s);if(a.type==="normal"){c=s.done?f:y;if(a.arg===_){continue}return{value:a.arg,done:s.done}}else if(a.type==="throw"){c=f;s.method="throw";s.arg=a.arg}}}}function A(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;A(e,t);if(t.method==="throw"){return _}}t.method="throw";t.arg=new TypeError("The iterator does not provide a 'throw' method")}return _}var n=d(r,e.iterator,t.arg);if(n.type==="throw"){t.method="throw";t.arg=n.arg;t.delegate=null;return _}var i=n.arg;if(!i){t.method="throw";t.arg=new TypeError("iterator result is not an object");t.delegate=null;return _}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 _}x(a);r(a,p,"Generator");r(a,i,function(){return this});r(a,"toString",function(){return"[object Generator]"});function S(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 k(e){var t=e.completion||{};t.type="normal";delete t.arg;e.completion=t}function F(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(S,this);this.reset(true)}o.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 P(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 a=i.completion;if(i.tryLoc==="root"){return e("end")}if(i.tryLoc<=this.prev){var o=l.call(i,"catchLoc");var u=l.call(i,"finallyLoc");if(o&&u){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e){this.complete(r.completion,r.afterLoc);k(r);return _}}},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;k(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){this.delegate={iterator:P(e),resultName:t,nextLoc:r};if(this.method==="next"){this.arg=s}return _}};return o}(e.exports);try{regeneratorRuntime=t}catch(e){if(typeof globalThis==="object"){globalThis.regeneratorRuntime=t}else{Function("r","regeneratorRuntime = r")(t)}}})(runtime);(function(e){e.exports=runtime.exports})(regenerator);var _regeneratorRuntime=getDefaultExportFromCjs(regenerator.exports);var global$1=typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{};var lookup=[];var revLookup=[];var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var inited=false;function init$1(){inited=true;var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var t=0,r=e.length;t0){throw new Error("Invalid string. Length must be a multiple of 4")}a=e[u-2]==="="?2:e[u-1]==="="?1:0;o=new Arr(u*3/4-a);n=a>0?u-4:u;var s=0;for(t=0,r=0;t>16&255;o[s++]=i>>8&255;o[s++]=i&255}if(a===2){i=revLookup[e.charCodeAt(t)]<<2|revLookup[e.charCodeAt(t+1)]>>4;o[s++]=i&255}else if(a===1){i=revLookup[e.charCodeAt(t)]<<10|revLookup[e.charCodeAt(t+1)]<<4|revLookup[e.charCodeAt(t+2)]>>2;o[s++]=i>>8&255;o[s++]=i&255}return o}function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[e&63]}function encodeChunk(e,t,r){var n;var i=[];for(var a=t;as?s:u+o))}if(n===1){t=e[r-1];i+=lookup[t>>2];i+=lookup[t<<4&63];i+="=="}else if(n===2){t=(e[r-2]<<8)+e[r-1];i+=lookup[t>>10];i+=lookup[t>>4&63];i+=lookup[t<<2&63];i+="="}a.push(i);return a.join("")}function read$1(e,t,r,n,l){var i,a;var f=l*8-n-1;var _=(1<>1;var o=-7;var u=r?l-1:0;var s=r?-1:1;var c=e[t+u];u+=s;i=c&(1<<-o)-1;c>>=-o;o+=f;for(;o>0;i=i*256+e[t+u],u+=s,o-=8){}a=i&(1<<-o)-1;i>>=-o;o+=n;for(;o>0;a=a*256+e[t+u],u+=s,o-=8){}if(i===0){i=1-p}else if(i===_){return a?NaN:(c?-1:1)*Infinity}else{a=a+Math.pow(2,n);i=i-p}return(c?-1:1)*a*Math.pow(2,i-n)}function write(e,t,l,f,r,_){var n,i,a;var o=_*8-r-1;var u=(1<>1;var p=r===23?Math.pow(2,-24)-Math.pow(2,-77):0;var c=f?0:_-1;var h=f?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=u}else{n=Math.floor(Math.log(t)/Math.LN2);if(t*(a=Math.pow(2,-n))<1){n--;a*=2}if(n+s>=1){t+=p/a}else{t+=p*Math.pow(2,1-s)}if(t*a>=2){n++;a/=2}if(n+s>=u){i=0;n=u}else if(n+s>=1){i=(t*a-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[l+c]=i&255,c+=h,i/=256,r-=8){}n=n<0;e[l+c]=n&255,c+=h,n/=256,o-=8){}e[l+c-h]|=d*128}var toString$1={}.toString;var isArray=Array.isArray||function(e){return toString$1.call(e)=="[object Array]"}; +function _classApplyDescriptorGet(e,t){if(t.get){return t.get.call(e)}return t.value}function _classExtractFieldDescriptor(e,t,r){if(!t.has(e)){throw new TypeError("attempted to "+r+" private field on non-instance")}return t.get(e)}function _classPrivateFieldGet(e,t){var r=_classExtractFieldDescriptor(e,t,"get");return _classApplyDescriptorGet(e,r)}function _classApplyDescriptorSet(e,t,r){if(t.set){t.set.call(e,r)}else{if(!t.writable){throw new TypeError("attempted to set read only private field")}t.value=r}}function _classPrivateFieldSet(e,t,r){var n=_classExtractFieldDescriptor(e,t,"set");_classApplyDescriptorSet(e,n,r);return r}function _assertThisInitialized(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function _setPrototypeOf(e,t){_setPrototypeOf=Object.setPrototypeOf||function e(t,r){t.__proto__=r;return t};return _setPrototypeOf(e,t)}function _isNativeReflectConstruct$1(){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 _construct(e,t,r){if(_isNativeReflectConstruct$1()){_construct=Reflect.construct}else{_construct=function e(t,r,n){var i=[null];i.push.apply(i,r);var a=Function.bind.apply(t,i);var o=new a;if(n)_setPrototypeOf(o,n.prototype);return o}}return _construct.apply(null,arguments)}function _inherits(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)_setPrototypeOf(e,t)}function _typeof(e){"@babel/helpers - typeof";return _typeof="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},_typeof(e)}function _possibleConstructorReturn(e,t){if(t&&(_typeof(t)==="object"||typeof t==="function")){return t}else if(t!==void 0){throw new TypeError("Derived constructors may only return object or undefined")}return _assertThisInitialized(e)}function _getPrototypeOf(e){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function e(t){return t.__proto__||Object.getPrototypeOf(t)};return _getPrototypeOf(e)}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArray(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function _arrayLikeToArray$1(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 _objectWithoutProperties(e,t){if(e==null)return{};var r=_objectWithoutPropertiesLoose(e,t);var n,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;r[n]=e[n]}}return r}function _iterableToArrayLimit(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 a=false;var o,u;try{for(r=r.call(e);!(i=(o=r.next()).done);i=true){n.push(o.value);if(t&&n.length===t)break}}catch(e){a=true;u=e}finally{try{if(!i&&r["return"]!=null)r["return"]()}finally{if(a)throw u}}return n}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray$1(e,t)||_nonIterableRest()}function _AwaitValue(e){this.wrapped=e}function _awaitAsyncGenerator(e){return new _AwaitValue(e)}function AsyncGenerator(a){var o,u;function e(n,i){return new Promise(function(e,t){var r={key:n,arg:i,resolve:e,reject:t,next:null};if(u){u=u.next=r}else{o=u=r;s(n,i)}})}function s(t,e){try{var r=a[t](e);var n=r.value;var i=n instanceof _AwaitValue;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":o.resolve({value:t,done:true});break;case"throw":o.reject(t);break;default:o.resolve({value:t,done:false});break}o=o.next;if(o){s(o.key,o.arg)}else{u=null}}this._invoke=e;if(typeof a["return"]!=="function"){this["return"]=undefined}}AsyncGenerator.prototype[typeof Symbol==="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this};AsyncGenerator.prototype.next=function(e){return this._invoke("next",e)};AsyncGenerator.prototype["throw"]=function(e){return this._invoke("throw",e)};AsyncGenerator.prototype["return"]=function(e){return this._invoke("return",e)};function _wrapAsyncGenerator(e){return function(){return new AsyncGenerator(e.apply(this,arguments))}}function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}var regenerator={exports:{}};var runtime={exports:{}};(function(e){var t=function(o){var e=Object.prototype;var l=e.hasOwnProperty;var s;var u=typeof Symbol==="function"?Symbol:{};var i=u.iterator||"@@iterator";var c=u.asyncIterator||"@@asyncIterator";var p=u.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 h(e,t,r,n){var i=t&&t.prototype instanceof g?t:g;var a=Object.create(i.prototype);var o=new k(n||[]);a._invoke=L(e,r,o);return a}o.wrap=h;function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}var m="suspendedStart";var y="suspendedYield";var v="executing";var f="completed";var _={};function g(){}function n(){}function t(){}var b={};r(b,i,function(){return this});var w=Object.getPrototypeOf;var D=w&&w(w(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var a=t.prototype=g.prototype=Object.create(b);n.prototype=t;r(a,"constructor",t);r(t,"constructor",n);n.displayName=r(t,p,"GeneratorFunction");function x(e){["next","throw","return"].forEach(function(t){r(e,t,function(e){return this._invoke(t,e)})})}o.isGeneratorFunction=function(e){var t=typeof e==="function"&&e.constructor;return t?t===n||(t.displayName||t.name)==="GeneratorFunction":false};o.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,t)}else{e.__proto__=t;r(e,p,"GeneratorFunction")}e.prototype=Object.create(a);return e};o.awrap=function(e){return{__await:e}};function E(u,s){function c(e,t,r,n){var i=d(u[e],u,t);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var o=a.value;if(o&&typeof o==="object"&&l.call(o,"__await")){return s.resolve(o.__await).then(function(e){c("next",e,r,n)},function(e){c("throw",e,r,n)})}return s.resolve(o).then(function(e){a.value=e;r(a)},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}x(E.prototype);r(E.prototype,c,function(){return this});o.AsyncIterator=E;o.async=function(e,t,r,n,i){if(i===void 0)i=Promise;var a=new E(h(e,t,r,n),i);return o.isGeneratorFunction(t)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function L(o,u,s){var c=m;return function e(t,r){if(c===v){throw new Error("Generator is already running")}if(c===f){if(t==="throw"){throw r}return C()}s.method=t;s.arg=r;while(true){var n=s.delegate;if(n){var i=A(n,s);if(i){if(i===_)continue;return i}}if(s.method==="next"){s.sent=s._sent=s.arg}else if(s.method==="throw"){if(c===m){c=f;throw s.arg}s.dispatchException(s.arg)}else if(s.method==="return"){s.abrupt("return",s.arg)}c=v;var a=d(o,u,s);if(a.type==="normal"){c=s.done?f:y;if(a.arg===_){continue}return{value:a.arg,done:s.done}}else if(a.type==="throw"){c=f;s.method="throw";s.arg=a.arg}}}}function A(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;A(e,t);if(t.method==="throw"){return _}}t.method="throw";t.arg=new TypeError("The iterator does not provide a 'throw' method")}return _}var n=d(r,e.iterator,t.arg);if(n.type==="throw"){t.method="throw";t.arg=n.arg;t.delegate=null;return _}var i=n.arg;if(!i){t.method="throw";t.arg=new TypeError("iterator result is not an object");t.delegate=null;return _}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 _}x(a);r(a,p,"Generator");r(a,i,function(){return this});r(a,"toString",function(){return"[object Generator]"});function S(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 F(e){var t=e.completion||{};t.type="normal";delete t.arg;e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(S,this);this.reset(true)}o.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 P(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 a=i.completion;if(i.tryLoc==="root"){return e("end")}if(i.tryLoc<=this.prev){var o=l.call(i,"catchLoc");var u=l.call(i,"finallyLoc");if(o&&u){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e){this.complete(r.completion,r.afterLoc);F(r);return _}}},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;F(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){this.delegate={iterator:P(e),resultName:t,nextLoc:r};if(this.method==="next"){this.arg=s}return _}};return o}(e.exports);try{regeneratorRuntime=t}catch(e){if(typeof globalThis==="object"){globalThis.regeneratorRuntime=t}else{Function("r","regeneratorRuntime = r")(t)}}})(runtime);(function(e){e.exports=runtime.exports})(regenerator);var _regeneratorRuntime=getDefaultExportFromCjs(regenerator.exports);var global$1=typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{};var lookup=[];var revLookup=[];var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var inited=false;function init$1(){inited=true;var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var t=0,r=e.length;t0){throw new Error("Invalid string. Length must be a multiple of 4")}a=e[u-2]==="="?2:e[u-1]==="="?1:0;o=new Arr(u*3/4-a);n=a>0?u-4:u;var s=0;for(t=0,r=0;t>16&255;o[s++]=i>>8&255;o[s++]=i&255}if(a===2){i=revLookup[e.charCodeAt(t)]<<2|revLookup[e.charCodeAt(t+1)]>>4;o[s++]=i&255}else if(a===1){i=revLookup[e.charCodeAt(t)]<<10|revLookup[e.charCodeAt(t+1)]<<4|revLookup[e.charCodeAt(t+2)]>>2;o[s++]=i>>8&255;o[s++]=i&255}return o}function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[e&63]}function encodeChunk(e,t,r){var n;var i=[];for(var a=t;as?s:u+o))}if(n===1){t=e[r-1];i+=lookup[t>>2];i+=lookup[t<<4&63];i+="=="}else if(n===2){t=(e[r-2]<<8)+e[r-1];i+=lookup[t>>10];i+=lookup[t>>4&63];i+=lookup[t<<2&63];i+="="}a.push(i);return a.join("")}function read$1(e,t,r,n,l){var i,a;var f=l*8-n-1;var _=(1<>1;var o=-7;var u=r?l-1:0;var s=r?-1:1;var c=e[t+u];u+=s;i=c&(1<<-o)-1;c>>=-o;o+=f;for(;o>0;i=i*256+e[t+u],u+=s,o-=8){}a=i&(1<<-o)-1;i>>=-o;o+=n;for(;o>0;a=a*256+e[t+u],u+=s,o-=8){}if(i===0){i=1-p}else if(i===_){return a?NaN:(c?-1:1)*Infinity}else{a=a+Math.pow(2,n);i=i-p}return(c?-1:1)*a*Math.pow(2,i-n)}function write(e,t,l,f,r,_){var n,i,a;var o=_*8-r-1;var u=(1<>1;var p=r===23?Math.pow(2,-24)-Math.pow(2,-77):0;var c=f?0:_-1;var h=f?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=u}else{n=Math.floor(Math.log(t)/Math.LN2);if(t*(a=Math.pow(2,-n))<1){n--;a*=2}if(n+s>=1){t+=p/a}else{t+=p*Math.pow(2,1-s)}if(t*a>=2){n++;a/=2}if(n+s>=u){i=0;n=u}else if(n+s>=1){i=(t*a-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[l+c]=i&255,c+=h,i/=256,r-=8){}n=n<0;e[l+c]=n&255,c+=h,n/=256,o-=8){}e[l+c-h]|=d*128}var toString$1={}.toString;var isArray=Array.isArray||function(e){return toString$1.call(e)=="[object Array]"}; /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT - */var INSPECT_MAX_BYTES=50;Buffer$1.TYPED_ARRAY_SUPPORT=global$1.TYPED_ARRAY_SUPPORT!==undefined?global$1.TYPED_ARRAY_SUPPORT:true;kMaxLength();function kMaxLength(){return Buffer$1.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(e,t){if(kMaxLength()=kMaxLength()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength().toString(16)+" bytes")}return e|0}Buffer$1.isBuffer=isBuffer;function internalIsBuffer(e){return!!(e!=null&&e._isBuffer)}Buffer$1.compare=function e(t,r){if(!internalIsBuffer(t)||!internalIsBuffer(r)){throw new TypeError("Arguments must be Buffers")}if(t===r)return 0;var n=t.length;var i=r.length;for(var a=0,o=Math.min(n,i);a>>1;case"base64":return base64ToBytes(e).length;default:if(n)return utf8ToBytes(e).length;t=(""+t).toLowerCase();n=true}}}Buffer$1.byteLength=byteLength;function slowToString(e,t,r){var n=false;if(t===undefined||t<0){t=0}if(t>this.length){return""}if(r===undefined||r>this.length){r=this.length}if(r<=0){return""}r>>>=0;t>>>=0;if(r<=t){return""}if(!e)e="utf8";while(true){switch(e){case"hex":return hexSlice(this,t,r);case"utf8":case"utf-8":return utf8Slice(this,t,r);case"ascii":return asciiSlice(this,t,r);case"latin1":case"binary":return latin1Slice(this,t,r);case"base64":return base64Slice(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();n=true}}}Buffer$1.prototype._isBuffer=true;function swap(e,t,r){var n=e[t];e[t]=e[r];e[r]=n}Buffer$1.prototype.swap16=function e(){var t=this.length;if(t%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var r=0;r0){t=this.toString("hex",0,r).match(/.{2}/g).join(" ");if(this.length>r)t+=" ... "}return""};Buffer$1.prototype.compare=function l(e,t,r,n,i){if(!internalIsBuffer(e)){throw new TypeError("Argument must be a Buffer")}if(t===undefined){t=0}if(r===undefined){r=e?e.length:0}if(n===undefined){n=0}if(i===undefined){i=this.length}if(t<0||r>e.length||n<0||i>this.length){throw new RangeError("out of range index")}if(n>=i&&t>=r){return 0}if(n>=i){return-1}if(t>=r){return 1}t>>>=0;r>>>=0;n>>>=0;i>>>=0;if(this===e)return 0;var a=i-n;var o=r-t;var f=Math.min(a,o);var u=this.slice(n,i);var s=e.slice(t,r);for(var c=0;c2147483647){r=2147483647}else if(r<-2147483648){r=-2147483648}r=+r;if(isNaN(r)){r=i?0:e.length-1}if(r<0)r=e.length+r;if(r>=e.length){if(i)return-1;else r=e.length-1}else if(r<0){if(i)r=0;else return-1}if(typeof t==="string"){t=Buffer$1.from(t,n)}if(internalIsBuffer(t)){if(t.length===0){return-1}return arrayIndexOf(e,t,r,n,i)}else if(typeof t==="number"){t=t&255;if(Buffer$1.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf==="function"){if(i){return Uint8Array.prototype.indexOf.call(e,t,r)}else{return Uint8Array.prototype.lastIndexOf.call(e,t,r)}}return arrayIndexOf(e,[t],r,n,i)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,r,n,l){var i=1;var a=e.length;var o=t.length;if(n!==undefined){n=String(n).toLowerCase();if(n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le"){if(e.length<2||t.length<2){return-1}i=2;a/=2;o/=2;r/=2}}function u(e,t){if(i===1){return e[t]}else{return e.readUInt16BE(t*i)}}var s;if(l){var c=-1;for(s=r;sa)r=a-o;for(s=r;s>=0;s--){var f=true;for(var _=0;_i){n=i}}var a=t.length;if(a%2!==0)throw new TypeError("Invalid hex string");if(n>a/2){n=a/2}for(var o=0;oa)n=a;if(t.length>0&&(n<0||r<0)||r>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!i)i="utf8";var o=false;for(;;){switch(i){case"hex":return hexWrite(this,t,r,n);case"utf8":case"utf-8":return utf8Write(this,t,r,n);case"ascii":return asciiWrite(this,t,r,n);case"latin1":case"binary":return latin1Write(this,t,r,n);case"base64":return base64Write(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,t,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase();o=true}}};Buffer$1.prototype.toJSON=function e(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(e,t,r){if(t===0&&r===e.length){return fromByteArray(e)}else{return fromByteArray(e.slice(t,r))}}function utf8Slice(e,l,t){t=Math.min(e.length,t);var r=[];var n=l;while(n239?4:i>223?3:i>191?2:1;if(n+o<=t){var u,s,f,c;switch(o){case 1:if(i<128){a=i}break;case 2:u=e[n+1];if((u&192)===128){c=(i&31)<<6|u&63;if(c>127){a=c}}break;case 3:u=e[n+1];s=e[n+2];if((u&192)===128&&(s&192)===128){c=(i&15)<<12|(u&63)<<6|s&63;if(c>2047&&(c<55296||c>57343)){a=c}}break;case 4:u=e[n+1];s=e[n+2];f=e[n+3];if((u&192)===128&&(s&192)===128&&(f&192)===128){c=(i&15)<<18|(u&63)<<12|(s&63)<<6|f&63;if(c>65535&&c<1114112){a=c}}}}if(a===null){a=65533;o=1}else if(a>65535){a-=65536;r.push(a>>>10&1023|55296);a=56320|a&1023}r.push(a);n+=o}return decodeCodePointsArray(r)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(e){var t=e.length;if(t<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,e)}var r="";var n=0;while(nn)r=n;var i="";for(var a=t;an){t=n}if(r<0){r+=n;if(r<0)r=0}else if(r>n){r=n}if(rr)throw new RangeError("Trying to access beyond buffer length")}Buffer$1.prototype.readUIntLE=function e(t,r,n){t=t|0;r=r|0;if(!n)checkOffset(t,r,this.length);var i=this[t];var a=1;var o=0;while(++o0&&(a*=256)){i+=this[t+--r]*a}return i};Buffer$1.prototype.readUInt8=function e(t,r){if(!r)checkOffset(t,1,this.length);return this[t]};Buffer$1.prototype.readUInt16LE=function e(t,r){if(!r)checkOffset(t,2,this.length);return this[t]|this[t+1]<<8};Buffer$1.prototype.readUInt16BE=function e(t,r){if(!r)checkOffset(t,2,this.length);return this[t]<<8|this[t+1]};Buffer$1.prototype.readUInt32LE=function e(t,r){if(!r)checkOffset(t,4,this.length);return(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};Buffer$1.prototype.readUInt32BE=function e(t,r){if(!r)checkOffset(t,4,this.length);return this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};Buffer$1.prototype.readIntLE=function e(t,r,n){t=t|0;r=r|0;if(!n)checkOffset(t,r,this.length);var i=this[t];var a=1;var o=0;while(++o=a)i-=Math.pow(2,8*r);return i};Buffer$1.prototype.readIntBE=function e(t,r,n){t=t|0;r=r|0;if(!n)checkOffset(t,r,this.length);var i=r;var a=1;var o=this[t+--i];while(i>0&&(a*=256)){o+=this[t+--i]*a}a*=128;if(o>=a)o-=Math.pow(2,8*r);return o};Buffer$1.prototype.readInt8=function e(t,r){if(!r)checkOffset(t,1,this.length);if(!(this[t]&128))return this[t];return(255-this[t]+1)*-1};Buffer$1.prototype.readInt16LE=function e(t,r){if(!r)checkOffset(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};Buffer$1.prototype.readInt16BE=function e(t,r){if(!r)checkOffset(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};Buffer$1.prototype.readInt32LE=function e(t,r){if(!r)checkOffset(t,4,this.length);return this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};Buffer$1.prototype.readInt32BE=function e(t,r){if(!r)checkOffset(t,4,this.length);return this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};Buffer$1.prototype.readFloatLE=function e(t,r){if(!r)checkOffset(t,4,this.length);return read$1(this,t,true,23,4)};Buffer$1.prototype.readFloatBE=function e(t,r){if(!r)checkOffset(t,4,this.length);return read$1(this,t,false,23,4)};Buffer$1.prototype.readDoubleLE=function e(t,r){if(!r)checkOffset(t,8,this.length);return read$1(this,t,true,52,8)};Buffer$1.prototype.readDoubleBE=function e(t,r){if(!r)checkOffset(t,8,this.length);return read$1(this,t,false,52,8)};function checkInt(e,t,r,n,i,a){if(!internalIsBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}Buffer$1.prototype.writeUIntLE=function e(t,r,n,i){t=+t;r=r|0;n=n|0;if(!i){var a=Math.pow(2,8*n)-1;checkInt(this,t,r,n,a,0)}var o=1;var u=0;this[r]=t&255;while(++u=0&&(u*=256)){this[r+o]=t/u&255}return r+n};Buffer$1.prototype.writeUInt8=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,1,255,0);if(!Buffer$1.TYPED_ARRAY_SUPPORT)t=Math.floor(t);this[r]=t&255;return r+1};function objectWriteUInt16(e,t,r,n){if(t<0)t=65535+t+1;for(var i=0,a=Math.min(e.length-r,2);i>>(n?i:1-i)*8}}Buffer$1.prototype.writeUInt16LE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,2,65535,0);if(Buffer$1.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8}else{objectWriteUInt16(this,t,r,true)}return r+2};Buffer$1.prototype.writeUInt16BE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,2,65535,0);if(Buffer$1.TYPED_ARRAY_SUPPORT){this[r]=t>>>8;this[r+1]=t&255}else{objectWriteUInt16(this,t,r,false)}return r+2};function objectWriteUInt32(e,t,r,n){if(t<0)t=4294967295+t+1;for(var i=0,a=Math.min(e.length-r,4);i>>(n?i:3-i)*8&255}}Buffer$1.prototype.writeUInt32LE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,4,4294967295,0);if(Buffer$1.TYPED_ARRAY_SUPPORT){this[r+3]=t>>>24;this[r+2]=t>>>16;this[r+1]=t>>>8;this[r]=t&255}else{objectWriteUInt32(this,t,r,true)}return r+4};Buffer$1.prototype.writeUInt32BE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,4,4294967295,0);if(Buffer$1.TYPED_ARRAY_SUPPORT){this[r]=t>>>24;this[r+1]=t>>>16;this[r+2]=t>>>8;this[r+3]=t&255}else{objectWriteUInt32(this,t,r,false)}return r+4};Buffer$1.prototype.writeIntLE=function e(t,r,n,i){t=+t;r=r|0;if(!i){var a=Math.pow(2,8*n-1);checkInt(this,t,r,n,a-1,-a)}var o=0;var u=1;var s=0;this[r]=t&255;while(++o>0)-s&255}return r+n};Buffer$1.prototype.writeIntBE=function e(t,r,n,i){t=+t;r=r|0;if(!i){var a=Math.pow(2,8*n-1);checkInt(this,t,r,n,a-1,-a)}var o=n-1;var u=1;var s=0;this[r+o]=t&255;while(--o>=0&&(u*=256)){if(t<0&&s===0&&this[r+o+1]!==0){s=1}this[r+o]=(t/u>>0)-s&255}return r+n};Buffer$1.prototype.writeInt8=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,1,127,-128);if(!Buffer$1.TYPED_ARRAY_SUPPORT)t=Math.floor(t);if(t<0)t=255+t+1;this[r]=t&255;return r+1};Buffer$1.prototype.writeInt16LE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,2,32767,-32768);if(Buffer$1.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8}else{objectWriteUInt16(this,t,r,true)}return r+2};Buffer$1.prototype.writeInt16BE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,2,32767,-32768);if(Buffer$1.TYPED_ARRAY_SUPPORT){this[r]=t>>>8;this[r+1]=t&255}else{objectWriteUInt16(this,t,r,false)}return r+2};Buffer$1.prototype.writeInt32LE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,4,2147483647,-2147483648);if(Buffer$1.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8;this[r+2]=t>>>16;this[r+3]=t>>>24}else{objectWriteUInt32(this,t,r,true)}return r+4};Buffer$1.prototype.writeInt32BE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,4,2147483647,-2147483648);if(t<0)t=4294967295+t+1;if(Buffer$1.TYPED_ARRAY_SUPPORT){this[r]=t>>>24;this[r+1]=t>>>16;this[r+2]=t>>>8;this[r+3]=t&255}else{objectWriteUInt32(this,t,r,false)}return r+4};function checkIEEE754(e,t,r,n,i,a){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(e,t,r,n,i){if(!i){checkIEEE754(e,t,r,4)}write(e,t,r,n,23,4);return r+4}Buffer$1.prototype.writeFloatLE=function e(t,r,n){return writeFloat(this,t,r,true,n)};Buffer$1.prototype.writeFloatBE=function e(t,r,n){return writeFloat(this,t,r,false,n)};function writeDouble(e,t,r,n,i){if(!i){checkIEEE754(e,t,r,8)}write(e,t,r,n,52,8);return r+8}Buffer$1.prototype.writeDoubleLE=function e(t,r,n){return writeDouble(this,t,r,true,n)};Buffer$1.prototype.writeDoubleBE=function e(t,r,n){return writeDouble(this,t,r,false,n)};Buffer$1.prototype.copy=function e(t,r,n,i){if(!n)n=0;if(!i&&i!==0)i=this.length;if(r>=t.length)r=t.length;if(!r)r=0;if(i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");if(i>this.length)i=this.length;if(t.length-r=0;--o){t[o+r]=this[o+n]}}else if(a<1e3||!Buffer$1.TYPED_ARRAY_SUPPORT){for(o=0;o>>0;n=n===undefined?this.length:n>>>0;if(!t)t=0;var o;if(typeof t==="number"){for(o=r;o55295&&r<57344){if(!i){if(r>56319){if((t-=3)>-1)a.push(239,191,189);continue}else if(o+1===n){if((t-=3)>-1)a.push(239,191,189);continue}i=r;continue}if(r<56320){if((t-=3)>-1)a.push(239,191,189);i=r;continue}r=(i-55296<<10|r-56320)+65536}else if(i){if((t-=3)>-1)a.push(239,191,189)}i=null;if(r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else{throw new Error("Invalid code point")}}return a}function asciiToBytes(e){var t=[];for(var r=0;r>8;i=r%256;a.push(i);a.push(n)}return a}function base64ToBytes(e){return toByteArray(base64clean(e))}function blitBuffer(e,t,r,n){for(var i=0;i=t.length||i>=e.length)break;t[i+r]=e[i]}return i}function isnan(e){return e!==e}function isBuffer(e){return e!=null&&(!!e._isBuffer||isFastBuffer(e)||isSlowBuffer(e))}function isFastBuffer(e){return!!e.constructor&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)}function isSlowBuffer(e){return typeof e.readFloatLE==="function"&&typeof e.slice==="function"&&isFastBuffer(e.slice(0,0))}let decoder;try{decoder=new TextDecoder}catch(error){}let src;let srcEnd;let position$1=0;const LEGACY_RECORD_INLINE_ID=105;const RECORD_DEFINITIONS_ID=57342;const RECORD_INLINE_ID=57343;const BUNDLED_STRINGS_ID=57337;const PACKED_REFERENCE_TAG_ID=6;const STOP_CODE={};let currentDecoder={};let currentStructures;let srcString;let srcStringStart=0;let srcStringEnd=0;let bundledStrings$1;let referenceMap;let currentExtensions=[];let currentExtensionRanges=[];let packedValues;let dataView;let restoreMapsAsObject;let defaultOptions={useRecords:false,mapsAsObjects:true};let sequentialMode=false;let inlineObjectReadThreshold=2;try{new Function("")}catch(error){inlineObjectReadThreshold=Infinity}class Decoder{constructor(r){if(r){if((r.keyMap||r._keyMap)&&!r.useRecords){r.useRecords=false;r.mapsAsObjects=true}if(r.useRecords===false&&r.mapsAsObjects===undefined)r.mapsAsObjects=true;if(r.getStructures)r.getShared=r.getStructures;if(r.getShared&&!r.structures)(r.structures=[]).uninitialized=true;if(r.keyMap){this.mapKey=new Map;for(let[e,t]of Object.entries(r.keyMap))this.mapKey.set(t,e)}}Object.assign(this,r)}decodeKey(e){return this.keyMap?this.mapKey.get(e)||e:e}encodeKey(e){return this.keyMap&&this.keyMap.hasOwnProperty(e)?this.keyMap[e]:e}encodeKeys(r){if(!this._keyMap)return r;let n=new Map;for(let[e,t]of Object.entries(r))n.set(this._keyMap.hasOwnProperty(e)?this._keyMap[e]:e,t);return n}decodeKeys(e){if(!this._keyMap||e.constructor.name!="Map")return e;if(!this._mapKey){this._mapKey=new Map;for(let[e,t]of Object.entries(this._keyMap))this._mapKey.set(t,e)}let r={};e.forEach((e,t)=>r[safeKey(this._mapKey.has(t)?this._mapKey.get(t):t)]=e);return r}mapDecode(e,t){let r=this.decode(e);if(this._keyMap){switch(r.constructor.name){case"Array":return r.map(e=>this.decodeKeys(e))}}return r}decode(t,e){if(src){return saveState(()=>{clearSource();return this?this.decode(t,e):Decoder.prototype.decode.call(defaultOptions,t,e)})}srcEnd=e>-1?e:t.length;position$1=0;srcStringEnd=0;srcString=null;bundledStrings$1=null;src=t;try{dataView=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(e){src=null;if(t instanceof Uint8Array)throw e;throw new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Decoder){currentDecoder=this;packedValues=this.sharedValues&&(this.pack?new Array(this.maxPrivatePackedValues||16).concat(this.sharedValues):this.sharedValues);if(this.structures){currentStructures=this.structures;return checkedRead()}else if(!currentStructures||currentStructures.length>0){currentStructures=[]}}else{currentDecoder=defaultOptions;if(!currentStructures||currentStructures.length>0)currentStructures=[];packedValues=null}return checkedRead()}decodeMultiple(r,n){let i,a=0;try{let e=r.length;sequentialMode=true;let t=this?this.decode(r,e):defaultDecoder.decode(r,e);if(n){if(n(t)===false){return}while(position$1=bundledStrings$1.postBundlePosition){let e=new Error("Unexpected bundle position");e.incomplete=true;throw e}position$1=bundledStrings$1.postBundlePosition;bundledStrings$1=null}if(position$1==srcEnd){currentStructures=null;src=null;if(referenceMap)referenceMap=null}else if(position$1>srcEnd){let e=new Error("Unexpected end of CBOR data");e.incomplete=true;throw e}else if(!sequentialMode){throw new Error("Data read, but end of buffer not reached")}return e}catch(e){clearSource();if(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")){e.incomplete=true}throw e}}function read(){let n=src[position$1++];let i=n>>5;n=n&31;if(n>23){switch(n){case 24:n=src[position$1++];break;case 25:if(i==7){return getFloat16()}n=dataView.getUint16(position$1);position$1+=2;break;case 26:if(i==7){let t=dataView.getFloat32(position$1);if(currentDecoder.useFloat32>2){let e=mult10[(src[position$1]&127)<<1|src[position$1+1]>>7];position$1+=4;return(e*t+(t>0?.5:-.5)>>0)/e}position$1+=4;return t}n=dataView.getUint32(position$1);position$1+=4;break;case 27:if(i==7){let e=dataView.getFloat64(position$1);position$1+=8;return e}if(i>1){if(dataView.getUint32(position$1)>0)throw new Error("JavaScript does not support arrays, maps, or strings with length over 4294967295");n=dataView.getUint32(position$1+4)}else if(currentDecoder.int64AsNumber){n=dataView.getUint32(position$1)*4294967296;n+=dataView.getUint32(position$1+4)}else n=dataView.getBigUint64(position$1);position$1+=8;break;case 31:switch(i){case 2:case 3:throw new Error("Indefinite length not supported for byte or text strings");case 4:let e=[];let t,r=0;while((t=read())!=STOP_CODE){e[r++]=t}return i==4?e:i==3?e.join(""):Buffer$1.concat(e);case 5:let n;if(currentDecoder.mapsAsObjects){let e={};if(currentDecoder.keyMap)while((n=read())!=STOP_CODE)e[safeKey(currentDecoder.decodeKey(n))]=read();else while((n=read())!=STOP_CODE)e[safeKey(n)]=read();return e}else{if(restoreMapsAsObject){currentDecoder.mapsAsObjects=true;restoreMapsAsObject=false}let e=new Map;if(currentDecoder.keyMap)while((n=read())!=STOP_CODE)e.set(currentDecoder.decodeKey(n),read());else while((n=read())!=STOP_CODE)e.set(n,read());return e}case 7:return STOP_CODE;default:throw new Error("Invalid major type for indefinite length "+i)}default:throw new Error("Unknown token "+n)}}switch(i){case 0:return n;case 1:return~n;case 2:return readBin(n);case 3:if(srcStringEnd>=position$1){return srcString.slice(position$1-srcStringStart,(position$1+=n)-srcStringStart)}if(srcStringEnd==0&&srcEnd<140&&n<32){let e=n<16?shortStringInJS(n):longStringInJS(n);if(e!=null)return e}return readFixedString(n);case 4:let t=new Array(n);for(let e=0;e=BUNDLED_STRINGS_ID){let e=currentStructures[n&8191];if(e){if(!e.read)e.read=createStructureReader(e);return e.read()}if(n<65536){if(n==RECORD_INLINE_ID){let e=readJustLength();let t=read();let r=read();recordDefinition(t,r);let n={};if(currentDecoder.keyMap)for(let t=2;t23){switch(t){case 24:t=src[position$1++];break;case 25:t=dataView.getUint16(position$1);position$1+=2;break;case 26:t=dataView.getUint32(position$1);position$1+=4;break;default:throw new Error("Expected array header, but got "+src[position$1-1])}}let r=this.compiledReader;while(r){if(r.propertyCount===t)return r(read);r=r.next}if(this.slowReads++>=inlineObjectReadThreshold){let e=this.length==t?this:this.slice(0,t);r=currentDecoder.keyMap?new Function("r","return {"+e.map(e=>currentDecoder.decodeKey(e)).map(e=>validName.test(e)?safeKey(e)+":r()":"["+JSON.stringify(e)+"]:r()").join(",")+"}"):new Function("r","return {"+e.map(e=>validName.test(e)?safeKey(e)+":r()":"["+JSON.stringify(e)+"]:r()").join(",")+"}");if(this.compiledReader)r.next=this.compiledReader;r.propertyCount=t;this.compiledReader=r;return r(read)}let n={};if(currentDecoder.keyMap)for(let e=0;e64&&decoder)return decoder.decode(src.subarray(position$1,position$1+=e));const r=position$1+e;const n=[];t="";while(position$165535){e-=65536;n.push(e>>>10&1023|55296);e=56320|e&1023}n.push(e)}else{n.push(i)}if(n.length>=4096){t+=fromCharCode.apply(String,n);n.length=0}}if(n.length>0){t+=fromCharCode.apply(String,n)}return t}let fromCharCode=String.fromCharCode;function longStringInJS(t){let r=position$1;let n=new Array(t);for(let e=0;e0){position$1=r;return}n[e]=i}return fromCharCode.apply(String,n)}function shortStringInJS(d){if(d<4){if(d<2){if(d===0)return"";else{let e=src[position$1++];if((e&128)>1){position$1-=1;return}return fromCharCode(e)}}else{let e=src[position$1++];let t=src[position$1++];if((e&128)>0||(t&128)>0){position$1-=2;return}if(d<3)return fromCharCode(e,t);let r=src[position$1++];if((r&128)>0){position$1-=3;return}return fromCharCode(e,t,r)}}else{let f=src[position$1++];let _=src[position$1++];let p=src[position$1++];let h=src[position$1++];if((f&128)>0||(_&128)>0||(p&128)>0||(h&128)>0){position$1-=4;return}if(d<6){if(d===4)return fromCharCode(f,_,p,h);else{let e=src[position$1++];if((e&128)>0){position$1-=5;return}return fromCharCode(f,_,p,h,e)}}else if(d<8){let e=src[position$1++];let t=src[position$1++];if((e&128)>0||(t&128)>0){position$1-=6;return}if(d<7)return fromCharCode(f,_,p,h,e,t);let r=src[position$1++];if((r&128)>0){position$1-=7;return}return fromCharCode(f,_,p,h,e,t,r)}else{let u=src[position$1++];let s=src[position$1++];let c=src[position$1++];let l=src[position$1++];if((u&128)>0||(s&128)>0||(c&128)>0||(l&128)>0){position$1-=8;return}if(d<10){if(d===8)return fromCharCode(f,_,p,h,u,s,c,l);else{let e=src[position$1++];if((e&128)>0){position$1-=9;return}return fromCharCode(f,_,p,h,u,s,c,l,e)}}else if(d<12){let e=src[position$1++];let t=src[position$1++];if((e&128)>0||(t&128)>0){position$1-=10;return}if(d<11)return fromCharCode(f,_,p,h,u,s,c,l,e,t);let r=src[position$1++];if((r&128)>0){position$1-=11;return}return fromCharCode(f,_,p,h,u,s,c,l,e,t,r)}else{let n=src[position$1++];let i=src[position$1++];let a=src[position$1++];let o=src[position$1++];if((n&128)>0||(i&128)>0||(a&128)>0||(o&128)>0){position$1-=12;return}if(d<14){if(d===12)return fromCharCode(f,_,p,h,u,s,c,l,n,i,a,o);else{let e=src[position$1++];if((e&128)>0){position$1-=13;return}return fromCharCode(f,_,p,h,u,s,c,l,n,i,a,o,e)}}else{let e=src[position$1++];let t=src[position$1++];if((e&128)>0||(t&128)>0){position$1-=14;return}if(d<15)return fromCharCode(f,_,p,h,u,s,c,l,n,i,a,o,e,t);let r=src[position$1++];if((r&128)>0){position$1-=15;return}return fromCharCode(f,_,p,h,u,s,c,l,n,i,a,o,e,t,r)}}}}}function readBin(e){return currentDecoder.copyBuffers?Uint8Array.prototype.slice.call(src,position$1,position$1+=e):src.subarray(position$1,position$1+=e)}let f32Array=new Float32Array(1);let u8Array=new Uint8Array(f32Array.buffer,0,4);function getFloat16(){let t=src[position$1++];let r=src[position$1++];let e=(t&127)>>2;if(e===31){if(r||t&3)return NaN;return t&128?-Infinity:Infinity}if(e===0){let e=((t&3)<<8|r)/(1<<24);return t&128?-e:e}u8Array[3]=t&128|(e>>1)+56;u8Array[2]=(t&7)<<5|r>>3;u8Array[1]=r<<5;u8Array[0]=0;return f32Array[0]}new Array(4096);class Tag{constructor(e,t){this.value=e;this.tag=t}}currentExtensions[0]=e=>{return new Date(e)};currentExtensions[1]=e=>{return new Date(Math.round(e*1e3))};currentExtensions[2]=r=>{let n=BigInt(0);for(let e=0,t=r.byteLength;e{return BigInt(-1)-currentExtensions[2](e)};currentExtensions[4]=e=>{return+(e[1]+"e"+e[0])};currentExtensions[5]=e=>{return e[1]*Math.exp(e[0]*Math.log(2))};const recordDefinition=(e,t)=>{e=e-57344;let r=currentStructures[e];if(r&&r.isShared){(currentStructures.restoreStructures||(currentStructures.restoreStructures=[]))[e]=r}currentStructures[e]=t;t.read=createStructureReader(t)};currentExtensions[LEGACY_RECORD_INLINE_ID]=r=>{let e=r.length;let n=r[1];recordDefinition(r[0],n);let i={};for(let t=2;t{if(bundledStrings$1)return bundledStrings$1[0].slice(bundledStrings$1.position0,bundledStrings$1.position0+=e);return new Tag(e,14)};currentExtensions[15]=e=>{if(bundledStrings$1)return bundledStrings$1[1].slice(bundledStrings$1.position1,bundledStrings$1.position1+=e);return new Tag(e,15)};let glbl={Error:Error,RegExp:RegExp};currentExtensions[27]=e=>{return(glbl[e[0]]||Error)(e[1],e[2])};const packedTable=e=>{if(src[position$1++]!=132)throw new Error("Packed values structure must be followed by a 4 element array");let t=e();packedValues=packedValues?t.concat(packedValues.slice(t.length)):t;packedValues.prefixes=e();packedValues.suffixes=e();return e()};packedTable.handlesRead=true;currentExtensions[51]=packedTable;currentExtensions[PACKED_REFERENCE_TAG_ID]=e=>{if(!packedValues){if(currentDecoder.getShared)loadShared();else return new Tag(e,PACKED_REFERENCE_TAG_ID)}if(typeof e=="number")return packedValues[16+(e>=0?2*e:-2*e-1)];throw new Error("No support for non-integer packed references yet")};currentExtensions[28]=e=>{if(!referenceMap){referenceMap=new Map;referenceMap.id=0}let t=referenceMap.id++;let r=src[position$1];let n;if(r>>5==4)n=[];else n={};let i={target:n};referenceMap.set(t,i);let a=e();if(i.used)return Object.assign(n,a);i.target=a;return a};currentExtensions[28].handlesRead=true;currentExtensions[29]=e=>{let t=referenceMap.get(e);t.used=true;return t.target};currentExtensions[258]=e=>new Set(e);(currentExtensions[259]=e=>{if(currentDecoder.mapsAsObjects){currentDecoder.mapsAsObjects=false;restoreMapsAsObject=true}return e()}).handlesRead=true;function combine(e,t){if(typeof e==="string")return e+t;if(e instanceof Array)return e.concat(t);return Object.assign({},e,t)}function getPackedValues(){if(!packedValues){if(currentDecoder.getShared)loadShared();else throw new Error("No packed values available")}return packedValues}const SHARED_DATA_TAG_ID=1399353956;currentExtensionRanges.push((e,t)=>{if(e>=225&&e<=255)return combine(getPackedValues().prefixes[e-224],t);if(e>=28704&&e<=32767)return combine(getPackedValues().prefixes[e-28672],t);if(e>=1879052288&&e<=2147483647)return combine(getPackedValues().prefixes[e-1879048192],t);if(e>=216&&e<=223)return combine(t,getPackedValues().suffixes[e-216]);if(e>=27647&&e<=28671)return combine(t,getPackedValues().suffixes[e-27639]);if(e>=1811940352&&e<=1879048191)return combine(t,getPackedValues().suffixes[e-1811939328]);if(e==SHARED_DATA_TAG_ID){return{packedValues:packedValues,structures:currentStructures.slice(0),version:t}}if(e==55799)return t});const isLittleEndianMachine$1=new Uint8Array(new Uint16Array([1]).buffer)[0]==1;const typedArrays=[Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array=="undefined"?{name:"BigUint64Array"}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array=="undefined"?{name:"BigInt64Array"}:BigInt64Array,Float32Array,Float64Array];const typedArrayTags=[64,68,69,70,71,72,77,78,79,85,86];for(let e=0;e{if(!u)throw new Error("Could not find typed array for code "+s);return new u(Uint8Array.prototype.slice.call(e,0).buffer)}:e=>{if(!u)throw new Error("Could not find typed array for code "+s);let t=new DataView(e.buffer,e.byteOffset,e.byteLength);let r=e.length>>a;let n=new u(r);let i=t[c];for(let e=0;e23){switch(e){case 24:e=src[position$1++];break;case 25:e=dataView.getUint16(position$1);position$1+=2;break;case 26:e=dataView.getUint32(position$1);position$1+=4;break}}return e}function loadShared(){if(currentDecoder.getShared){let e=saveState(()=>{src=null;return currentDecoder.getShared()})||{};let t=e.structures||[];currentDecoder.sharedVersion=e.version;packedValues=currentDecoder.sharedValues=e.packedValues;if(currentStructures===true)currentDecoder.structures=currentStructures=t;else currentStructures.splice.apply(currentStructures,[0,t.length].concat(t))}}function saveState(e){let t=srcEnd;let r=position$1;let n=srcStringStart;let i=srcStringEnd;let a=srcString;let o=referenceMap;let u=bundledStrings$1;let s=new Uint8Array(src.slice(0,srcEnd));let c=currentStructures;let l=currentDecoder;let f=sequentialMode;let _=e();srcEnd=t;position$1=r;srcStringStart=n;srcStringEnd=i;srcString=a;referenceMap=o;bundledStrings$1=u;src=s;sequentialMode=f;currentStructures=c;currentDecoder=l;dataView=new DataView(src.buffer,src.byteOffset,src.byteLength);return _}function clearSource(){src=null;referenceMap=null;currentStructures=null}function addExtension$1(e){currentExtensions[e.tag]=e.decode}const mult10=new Array(147);for(let e=0;e<256;e++){mult10[e]=+("1e"+Math.floor(45.15-e*.30103))}let defaultDecoder=new Decoder({useRecords:false});defaultDecoder.decode;defaultDecoder.decodeMultiple;let textEncoder;try{textEncoder=new TextEncoder}catch(error){}let extensions,extensionClasses;const Buffer=typeof globalThis==="object"&&globalThis.Buffer;const hasNodeBuffer=typeof Buffer!=="undefined";const ByteArrayAllocate=hasNodeBuffer?Buffer.allocUnsafeSlow:Uint8Array;const ByteArray=hasNodeBuffer?Buffer:Uint8Array;const MAX_STRUCTURES=256;const MAX_BUFFER_SIZE=hasNodeBuffer?4294967296:2144337920;let throwOnIterable;let target;let targetView;let position=0;let safeEnd;let bundledStrings=null;const MAX_BUNDLE_SIZE=61440;const hasNonLatin=/[\u0080-\uFFFF]/;const RECORD_SYMBOL=Symbol("record-id");class Encoder extends Decoder{constructor(r){super(r);this.offset=0;let s;let o;let h;let l;let n;r=r||{};let c=ByteArray.prototype.utf8Write?function(e,t,r){return target.utf8Write(e,t,r)}:textEncoder&&textEncoder.encodeInto?function(e,t){return textEncoder.encodeInto(e,target.subarray(t)).written}:false;let a=this;let e=r.structures||r.saveStructures;let f=r.maxSharedStructures;if(f==null)f=e?128:0;if(f>8190)throw new Error("Maximum maxSharedStructure is 8190");let u=r.sequential;if(u){f=0}if(!this.structures)this.structures=[];if(this.saveStructures)this.saveShared=this.saveStructures;let d,m,y=r.sharedValues;let i;if(y){i=Object.create(null);for(let e=0,t=y.length;ethis.encodeKeys(e));break}}return this.encode(e,t)};this.encode=function(t,e){if(!target){target=new ByteArrayAllocate(8192);targetView=new DataView(target.buffer,0,8192);position=0}safeEnd=target.length-10;if(safeEnd-position<2048){target=new ByteArrayAllocate(target.length);targetView=new DataView(target.buffer,0,target.length);safeEnd=target.length-10;position=0}else if(e===REUSE_BUFFER_MODE)position=position+7&2147483640;s=position;if(a.useSelfDescribedHeader){targetView.setUint32(position,3654940416);position+=3}n=a.structuredClone?new Map:null;if(a.bundleStrings&&typeof t!=="string"){bundledStrings=[];bundledStrings.size=Infinity}else bundledStrings=null;o=a.structures;if(o){if(o.uninitialized){let e=a.getShared()||{};a.structures=o=e.structures||[];a.sharedVersion=e.version;let r=a.sharedValues=e.packedValues;if(r){i={};for(let e=0,t=r.length;ef&&!u)e=f;if(!o.transitions){o.transitions=Object.create(null);for(let a=0;a0){target[position++]=216;target[position++]=51;writeArrayHeader(4);let r=e.values;p(r);writeArrayHeader(0);writeArrayHeader(0);m=Object.create(i||null);for(let e=0,t=r.length;esafeEnd)w(position);a.offset=position;let e=insertIds(target.subarray(s,position),n.idsToInsert);n=null;return e}if(e&REUSE_BUFFER_MODE){target.start=s;target.end=position;return target}return target.subarray(s,position)}finally{if(o){if(g<10)g++;if(o.length>f)o.length=f;if(v>1e4){o.transitions=null;g=0;v=0;if(_.length>0)_=[]}else if(_.length>0&&!u){for(let e=0,t=_.length;ef){a.structures=a.structures.slice(0,f)}let e=target.subarray(s,position);if(a.updateSharedData()===false)return a.encode(t);return e}if(e&RESET_BUFFER_MODE)position=s}};this.findCommonStringsToPack=()=>{d=new Map;if(!i)i=Object.create(null);return e=>{let r=e&&e.threshold||4;let n=this.pack?e.maxPrivatePackedValues||16:0;if(!y)y=this.sharedValues=[];for(let[e,t]of d){if(t.count>r){i[e]=n++;y.push(e);h=true}}while(this.saveShared&&this.updateSharedData()===false){}d=null}};const p=o=>{if(position>safeEnd)target=w(position);var e=typeof o;var u;if(e==="string"){if(m){let e=m[o];if(e>=0){if(e<16)target[position++]=e+224;else{target[position++]=198;if(e&1)p(15-e>>1);else p(e-16>>1)}return}else if(d&&!r.pack){let e=d.get(o);if(e)e.count++;else d.set(o,{count:1})}}let i=o.length;if(bundledStrings&&i>=4&&i<1024){if((bundledStrings.size+=i)>MAX_BUNDLE_SIZE){let e;let t=(bundledStrings[0]?bundledStrings[0].length*3+bundledStrings[1].length:0)+10;if(position+t>safeEnd)target=w(position+t);target[position++]=217;target[position++]=223;target[position++]=249;target[position++]=bundledStrings.position?132:130;target[position++]=26;e=position-s;position+=4;if(bundledStrings.position){writeBundles(s,p)}bundledStrings=["",""];bundledStrings.size=0;bundledStrings.position=e}let e=hasNonLatin.test(o);bundledStrings[e?0:1]+=o;target[position++]=e?206:207;p(i);return}let a;if(i<32){a=1}else if(i<256){a=2}else if(i<65536){a=3}else{a=5}let e=i*3;if(position+e>safeEnd)target=w(position+e);if(i<64||!c){let e,t,r,n=position+a;for(e=0;e>6|192;target[n++]=t&63|128}else if((t&64512)===55296&&((r=o.charCodeAt(e+1))&64512)===56320){t=65536+((t&1023)<<10)+(r&1023);e++;target[n++]=t>>18|240;target[n++]=t>>12&63|128;target[n++]=t>>6&63|128;target[n++]=t&63|128}else{target[n++]=t>>12|224;target[n++]=t>>6&63|128;target[n++]=t&63|128}}u=n-position-a}else{u=c(o,position+a,e)}if(u<24){target[position++]=96|u}else if(u<256){if(a<2){target.copyWithin(position+2,position+1,position+1+u)}target[position++]=120;target[position++]=u}else if(u<65536){if(a<3){target.copyWithin(position+3,position+2,position+2+u)}target[position++]=121;target[position++]=u>>8;target[position++]=u&255}else{if(a<5){target.copyWithin(position+5,position+3,position+3+u)}target[position++]=122;targetView.setUint32(position,u);position+=4}position+=u}else if(e==="number"){if(!this.alwaysUseFloat&&o>>>0===o){if(o<24){target[position++]=o}else if(o<256){target[position++]=24;target[position++]=o}else if(o<65536){target[position++]=25;target[position++]=o>>8;target[position++]=o&255}else{target[position++]=26;targetView.setUint32(position,o);position+=4}}else if(!this.alwaysUseFloat&&o>>0===o){if(o>=-24){target[position++]=31-o}else if(o>=-256){target[position++]=56;target[position++]=~o}else if(o>=-65536){target[position++]=57;targetView.setUint16(position,~o);position+=2}else{target[position++]=58;targetView.setUint32(position,~o);position+=4}}else{let t;if((t=this.useFloat32)>0&&o<4294967296&&o>=-2147483648){target[position++]=250;targetView.setFloat32(position,o);let e;if(t<4||(e=o*mult10[(target[position]&127)<<1|target[position+1]>>7])>>0===e){position+=4;return}else position--}target[position++]=251;targetView.setFloat64(position,o);position+=8}}else if(e==="object"){if(!o)target[position++]=246;else{if(n){let t=n.get(o);if(t){target[position++]=216;target[position++]=29;target[position++]=25;if(!t.references){let e=n.idsToInsert||(n.idsToInsert=[]);t.references=[];e.push(t)}t.references.push(position-s);position+=2;return}else n.set(o,{offset:position-s})}let e=o.constructor;if(e===Object){b(o,true)}else if(e===Array){u=o.length;if(u<24){target[position++]=128|u}else{writeArrayHeader(u)}for(let e=0;e>8;target[position++]=u&255}else{target[position++]=186;targetView.setUint32(position,u);position+=4}if(a.keyMap){for(let[e,t]of o){p(a.encodeKey(e));p(t)}}else{for(let[e,t]of o){p(e);p(t)}}}else{for(let r=0,e=extensions.length;r>8;target[position++]=t&255}else if(t>-1){target[position++]=218;targetView.setUint32(position,t);position+=4}e.encode.call(this,o,p,w);return}}if(o[Symbol.iterator]){if(throwOnIterable){let e=new Error("Iterable should be serialized as iterator");e.iteratorNotHandled=true;throw e}target[position++]=159;for(let e of o){p(e)}target[position++]=255;return}if(o[Symbol.asyncIterator]||isBlob(o)){let e=new Error("Iterable/blob should be serialized as iterator");e.iteratorNotHandled=true;throw e}if(this.useToJSON&&o.toJSON){const t=o.toJSON();if(t!==o)return p(t)}b(o,!o.hasOwnProperty)}}}else if(e==="boolean"){target[position++]=o?245:244}else if(e==="bigint"){if(o=0){target[position++]=27;targetView.setBigUint64(position,o)}else if(o>-(BigInt(1)<{let t=Object.keys(e);let r=Object.values(e);let n=t.length;if(n<24){target[position++]=160|n}else if(n<256){target[position++]=184;target[position++]=n}else if(n<65536){target[position++]=185;target[position++]=n>>8;target[position++]=n&255}else{target[position++]=186;targetView.setUint32(position,n);position+=4}if(a.keyMap){for(let e=0;e{target[position++]=185;let e=position-s;position+=2;let n=0;if(a.keyMap){for(let e in t)if(r||t.hasOwnProperty(e)){p(a.encodeKey(e));p(t[e]);n++}}else{for(let e in t)if(r||t.hasOwnProperty(e)){p(e);p(t[e]);n++}}target[e+++s]=n>>8;target[e+s]=n&255}:(t,r)=>{let n,i=l.transitions||(l.transitions=Object.create(null));let a=0;let o=0;let u;let s;if(this.keyMap){s=Object.keys(t).map(e=>this.encodeKey(e));o=s.length;for(let t=0;t>8|224;target[position++]=c&255}else{if(!s)s=i.__keys__||(i.__keys__=Object.keys(t));if(u===undefined){c=l.nextId++;if(!c){c=0;l.nextId=1}if(c>=MAX_STRUCTURES){l.nextId=(c=f)+1}}else{c=u}l[c]=s;if(c>8|224;target[position++]=c&255;i=l.transitions;for(let e=0;e=MAX_STRUCTURES-f)_.shift()[RECORD_SYMBOL]=undefined;_.push(i);writeArrayHeader(o+2);p(57344+c);p(s);if(r===null)return;for(let e in t)if(r||t.hasOwnProperty(e))p(t[e]);return}}if(o<24){target[position++]=128|o}else{writeArrayHeader(o)}if(r===null)return;for(let e in t)if(r||t.hasOwnProperty(e))p(t[e])};const w=e=>{let t;if(e>16777216){if(e-s>MAX_BUFFER_SIZE)throw new Error("Encoded buffer would be larger than maximum buffer size");t=Math.min(MAX_BUFFER_SIZE,Math.round(Math.max((e-s)*(e>67108864?1.25:2),4194304)/4096)*4096)}else t=(Math.max(e-s<<2,target.length-1)>>12)+1<<12;let r=new ByteArrayAllocate(t);targetView=new DataView(r.buffer,0,t);if(target.copy)target.copy(r,0,s,e);else r.set(target.slice(s,e));position-=s;s=0;safeEnd=r.length-10;return target=r};let D=100;let x=1e3;this.encodeAsIterable=function(e,t){return S(e,t,E)};this.encodeAsAsyncIterable=function(e,t){return S(e,t,k)};function*E(n,i,e){let t=n.constructor;if(t===Object){let r=a.useRecords!==false;if(r)b(n,null);else writeEntityLength(Object.keys(n).length,160);for(let t in n){let e=n[t];if(!r)p(t);if(e&&typeof e==="object"){if(i[t])yield*E(e,i[t]);else yield*L(e,i,t)}else p(e)}}else if(t===Array){let e=n.length;writeArrayHeader(e);for(let t=0;tD)){if(i.element)yield*E(e,i.element);else yield*L(e,i,"element")}else p(e)}}else if(n[Symbol.iterator]){target[position++]=159;for(let e of n){if(e&&(typeof e==="object"||position-s>D)){if(i.element)yield*E(e,i.element);else yield*L(e,i,"element")}else p(e)}target[position++]=255}else if(isBlob(n)){writeEntityLength(n.size,64);yield target.subarray(s,position);yield n;A()}else if(n[Symbol.asyncIterator]){target[position++]=159;yield target.subarray(s,position);yield n;A();target[position++]=255}else{p(n)}if(e&&position>s)yield target.subarray(s,position);else if(position-s>D){yield target.subarray(s,position);A()}}function*L(t,r,n){let i=position-s;try{p(t);if(position-s>D){yield target.subarray(s,position);A()}}catch(e){if(e.iteratorNotHandled){r[n]={};position=s+i;yield*E.call(this,t,r[n])}else throw e}}function A(){D=x;a.encode(null,THROW_ON_ITERABLE)}function S(e,t,r){if(t&&t.chunkThreshold)D=x=t.chunkThreshold;else D=100;if(e&&typeof e==="object"){a.encode(null,THROW_ON_ITERABLE);return r(e,a.iterateProperties||(a.iterateProperties={}),true)}return[a.encode(e)]}async function*k(e,t){for(let r of E(e,t,true)){let e=r.constructor;if(e===ByteArray||e===Uint8Array)yield r;else if(isBlob(r)){let e=r.stream().getReader();let t;while(!(t=await e.read()).done){yield t.value}}else if(r[Symbol.asyncIterator]){for await(let e of r){A();if(e)yield*k(e,t.async||(t.async={}));else yield a.encode(e)}}else{yield r}}}}useBuffer(e){target=e;targetView=new DataView(target.buffer,target.byteOffset,target.byteLength);position=0}clearSharedData(){if(this.structures)this.structures=[];if(this.sharedValues)this.sharedValues=undefined}updateSharedData(){let t=this.sharedVersion||0;this.sharedVersion=t+1;let e=this.structures.slice(0);let r=new SharedData(e,this.sharedValues,this.sharedVersion);let n=this.saveShared(r,e=>(e&&e.version||0)==t);if(n===false){r=this.getShared()||{};this.structures=r.structures||[];this.sharedValues=r.packedValues;this.sharedVersion=r.version;this.structures.nextId=this.structures.length}else{e.forEach((e,t)=>this.structures[t]=e)}return n}}function writeEntityLength(e,t){if(e<24)target[position++]=t|e;else if(e<256){target[position++]=t|24;target[position++]=e}else if(e<65536){target[position++]=t|25;target[position++]=e>>8;target[position++]=e&255}else{target[position++]=t|26;targetView.setUint32(position,e);position+=4}}class SharedData{constructor(e,t,r){this.structures=e;this.packedValues=t;this.version=r}}function writeArrayHeader(e){if(e<24)target[position++]=128|e;else if(e<256){target[position++]=152;target[position++]=e}else if(e<65536){target[position++]=153;target[position++]=e>>8;target[position++]=e&255}else{target[position++]=154;targetView.setUint32(position,e);position+=4}}const BlobConstructor=typeof Blob==="undefined"?function(){}:Blob;function isBlob(e){if(e instanceof BlobConstructor)return true;let t=e[Symbol.toStringTag];return t==="Blob"||t==="File"}function findRepetitiveStrings(r,n){switch(typeof r){case"string":if(r.length>3){if(n.objectMap[r]>-1||n.values.length>=n.maxValues)return;let e=n.get(r);if(e){if(++e.count==2){n.values.push(r)}}else{n.set(r,{count:1});if(n.samplingPackedValues){let e=n.samplingPackedValues.get(r);if(e)e.count++;else n.samplingPackedValues.set(r,{count:1})}}}break;case"object":if(r){if(r instanceof Array){for(let e=0,t=r.length;e=0&&r<4294967296){target[position++]=26;targetView.setUint32(position,r);position+=4}else{target[position++]=251;targetView.setFloat64(position,r);position+=8}}},{tag:258,encode(e,t){let r=Array.from(e);t(r)}},{tag:27,encode(e,t){t([e.name,e.message])}},{tag:27,encode(e,t){t(["RegExp",e.source,e.flags])}},{getTag(e){return e.tag},encode(e,t){t(e.value)}},{encode(e,t,r){writeBuffer(e,r)}},{getTag(e){if(e.constructor===Uint8Array){if(this.tagUint8Array||hasNodeBuffer&&this.tagUint8Array!==false)return 64}},encode(e,t,r){writeBuffer(e,r)}},typedArrayEncoder(68,1),typedArrayEncoder(69,2),typedArrayEncoder(70,4),typedArrayEncoder(71,8),typedArrayEncoder(72,1),typedArrayEncoder(77,2),typedArrayEncoder(78,4),typedArrayEncoder(79,8),typedArrayEncoder(85,4),typedArrayEncoder(86,8),{encode(t,n){let e=t.packedValues||[];let r=t.structures||[];if(e.values.length>0){target[position++]=216;target[position++]=51;writeArrayHeader(4);let r=e.values;n(r);writeArrayHeader(0);writeArrayHeader(0);packedObjectMap=Object.create(sharedPackedObjectMap||null);for(let e=0,t=r.length;e1)e-=4;return{tag:e,encode:function e(t,r){let n=t.byteLength;let i=t.byteOffset||0;let a=t.buffer||t;r(hasNodeBuffer?Buffer.from(a,i,n):new Uint8Array(a,i,n))}}}function writeBuffer(e,t){let r=e.byteLength;if(r<24){target[position++]=64+r}else if(r<256){target[position++]=88;target[position++]=r}else if(r<65536){target[position++]=89;target[position++]=r>>8;target[position++]=r&255}else{target[position++]=90;targetView.setUint32(position,r);position+=4}if(position+r>=target.length){t(position+r)}target.set(e.buffer?e:new Uint8Array(e),position);position+=r}function insertIds(n,e){let r;let i=e.length*2;let a=n.length-i;e.sort((e,t)=>e.offset>t.offset?1:-1);for(let r=0;r>8;n[e]=r&255}}while(r=e.pop()){let e=r.offset;n.copyWithin(e+i,e,a);i-=2;let t=e+i;n[t++]=216;n[t++]=28;a=e}return n}function writeBundles(e,t){targetView.setUint32(bundledStrings.position+e,position-bundledStrings.position-e+1);let r=bundledStrings;bundledStrings=null;t(r[0]);t(r[1])}function addExtension(e){if(e.Class){if(!e.encode)throw new Error("Extension has no encode function");extensionClasses.unshift(e.Class);extensions.unshift(e)}addExtension$1(e)}let defaultEncoder=new Encoder({useRecords:false});defaultEncoder.encode;defaultEncoder.encodeAsIterable;defaultEncoder.encodeAsAsyncIterable;const REUSE_BUFFER_MODE=512;const RESET_BUFFER_MODE=1024;const THROW_ON_ITERABLE=2048;var lzjbPack={}; + */var INSPECT_MAX_BYTES=50;Buffer$1.TYPED_ARRAY_SUPPORT=global$1.TYPED_ARRAY_SUPPORT!==undefined?global$1.TYPED_ARRAY_SUPPORT:true;kMaxLength();function kMaxLength(){return Buffer$1.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(e,t){if(kMaxLength()=kMaxLength()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength().toString(16)+" bytes")}return e|0}Buffer$1.isBuffer=isBuffer;function internalIsBuffer(e){return!!(e!=null&&e._isBuffer)}Buffer$1.compare=function e(t,r){if(!internalIsBuffer(t)||!internalIsBuffer(r)){throw new TypeError("Arguments must be Buffers")}if(t===r)return 0;var n=t.length;var i=r.length;for(var a=0,o=Math.min(n,i);a>>1;case"base64":return base64ToBytes(e).length;default:if(n)return utf8ToBytes(e).length;t=(""+t).toLowerCase();n=true}}}Buffer$1.byteLength=byteLength;function slowToString(e,t,r){var n=false;if(t===undefined||t<0){t=0}if(t>this.length){return""}if(r===undefined||r>this.length){r=this.length}if(r<=0){return""}r>>>=0;t>>>=0;if(r<=t){return""}if(!e)e="utf8";while(true){switch(e){case"hex":return hexSlice(this,t,r);case"utf8":case"utf-8":return utf8Slice(this,t,r);case"ascii":return asciiSlice(this,t,r);case"latin1":case"binary":return latin1Slice(this,t,r);case"base64":return base64Slice(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();n=true}}}Buffer$1.prototype._isBuffer=true;function swap(e,t,r){var n=e[t];e[t]=e[r];e[r]=n}Buffer$1.prototype.swap16=function e(){var t=this.length;if(t%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var r=0;r0){t=this.toString("hex",0,r).match(/.{2}/g).join(" ");if(this.length>r)t+=" ... "}return""};Buffer$1.prototype.compare=function l(e,t,r,n,i){if(!internalIsBuffer(e)){throw new TypeError("Argument must be a Buffer")}if(t===undefined){t=0}if(r===undefined){r=e?e.length:0}if(n===undefined){n=0}if(i===undefined){i=this.length}if(t<0||r>e.length||n<0||i>this.length){throw new RangeError("out of range index")}if(n>=i&&t>=r){return 0}if(n>=i){return-1}if(t>=r){return 1}t>>>=0;r>>>=0;n>>>=0;i>>>=0;if(this===e)return 0;var a=i-n;var o=r-t;var f=Math.min(a,o);var u=this.slice(n,i);var s=e.slice(t,r);for(var c=0;c2147483647){r=2147483647}else if(r<-2147483648){r=-2147483648}r=+r;if(isNaN(r)){r=i?0:e.length-1}if(r<0)r=e.length+r;if(r>=e.length){if(i)return-1;else r=e.length-1}else if(r<0){if(i)r=0;else return-1}if(typeof t==="string"){t=Buffer$1.from(t,n)}if(internalIsBuffer(t)){if(t.length===0){return-1}return arrayIndexOf(e,t,r,n,i)}else if(typeof t==="number"){t=t&255;if(Buffer$1.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf==="function"){if(i){return Uint8Array.prototype.indexOf.call(e,t,r)}else{return Uint8Array.prototype.lastIndexOf.call(e,t,r)}}return arrayIndexOf(e,[t],r,n,i)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,r,n,l){var i=1;var a=e.length;var o=t.length;if(n!==undefined){n=String(n).toLowerCase();if(n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le"){if(e.length<2||t.length<2){return-1}i=2;a/=2;o/=2;r/=2}}function u(e,t){if(i===1){return e[t]}else{return e.readUInt16BE(t*i)}}var s;if(l){var c=-1;for(s=r;sa)r=a-o;for(s=r;s>=0;s--){var f=true;for(var _=0;_i){n=i}}var a=t.length;if(a%2!==0)throw new TypeError("Invalid hex string");if(n>a/2){n=a/2}for(var o=0;oa)n=a;if(t.length>0&&(n<0||r<0)||r>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!i)i="utf8";var o=false;for(;;){switch(i){case"hex":return hexWrite(this,t,r,n);case"utf8":case"utf-8":return utf8Write(this,t,r,n);case"ascii":return asciiWrite(this,t,r,n);case"latin1":case"binary":return latin1Write(this,t,r,n);case"base64":return base64Write(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,t,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase();o=true}}};Buffer$1.prototype.toJSON=function e(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(e,t,r){if(t===0&&r===e.length){return fromByteArray(e)}else{return fromByteArray(e.slice(t,r))}}function utf8Slice(e,l,t){t=Math.min(e.length,t);var r=[];var n=l;while(n239?4:i>223?3:i>191?2:1;if(n+o<=t){var u,s,f,c;switch(o){case 1:if(i<128){a=i}break;case 2:u=e[n+1];if((u&192)===128){c=(i&31)<<6|u&63;if(c>127){a=c}}break;case 3:u=e[n+1];s=e[n+2];if((u&192)===128&&(s&192)===128){c=(i&15)<<12|(u&63)<<6|s&63;if(c>2047&&(c<55296||c>57343)){a=c}}break;case 4:u=e[n+1];s=e[n+2];f=e[n+3];if((u&192)===128&&(s&192)===128&&(f&192)===128){c=(i&15)<<18|(u&63)<<12|(s&63)<<6|f&63;if(c>65535&&c<1114112){a=c}}}}if(a===null){a=65533;o=1}else if(a>65535){a-=65536;r.push(a>>>10&1023|55296);a=56320|a&1023}r.push(a);n+=o}return decodeCodePointsArray(r)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(e){var t=e.length;if(t<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,e)}var r="";var n=0;while(nn)r=n;var i="";for(var a=t;an){t=n}if(r<0){r+=n;if(r<0)r=0}else if(r>n){r=n}if(rr)throw new RangeError("Trying to access beyond buffer length")}Buffer$1.prototype.readUIntLE=function e(t,r,n){t=t|0;r=r|0;if(!n)checkOffset(t,r,this.length);var i=this[t];var a=1;var o=0;while(++o0&&(a*=256)){i+=this[t+--r]*a}return i};Buffer$1.prototype.readUInt8=function e(t,r){if(!r)checkOffset(t,1,this.length);return this[t]};Buffer$1.prototype.readUInt16LE=function e(t,r){if(!r)checkOffset(t,2,this.length);return this[t]|this[t+1]<<8};Buffer$1.prototype.readUInt16BE=function e(t,r){if(!r)checkOffset(t,2,this.length);return this[t]<<8|this[t+1]};Buffer$1.prototype.readUInt32LE=function e(t,r){if(!r)checkOffset(t,4,this.length);return(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};Buffer$1.prototype.readUInt32BE=function e(t,r){if(!r)checkOffset(t,4,this.length);return this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};Buffer$1.prototype.readIntLE=function e(t,r,n){t=t|0;r=r|0;if(!n)checkOffset(t,r,this.length);var i=this[t];var a=1;var o=0;while(++o=a)i-=Math.pow(2,8*r);return i};Buffer$1.prototype.readIntBE=function e(t,r,n){t=t|0;r=r|0;if(!n)checkOffset(t,r,this.length);var i=r;var a=1;var o=this[t+--i];while(i>0&&(a*=256)){o+=this[t+--i]*a}a*=128;if(o>=a)o-=Math.pow(2,8*r);return o};Buffer$1.prototype.readInt8=function e(t,r){if(!r)checkOffset(t,1,this.length);if(!(this[t]&128))return this[t];return(255-this[t]+1)*-1};Buffer$1.prototype.readInt16LE=function e(t,r){if(!r)checkOffset(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};Buffer$1.prototype.readInt16BE=function e(t,r){if(!r)checkOffset(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};Buffer$1.prototype.readInt32LE=function e(t,r){if(!r)checkOffset(t,4,this.length);return this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};Buffer$1.prototype.readInt32BE=function e(t,r){if(!r)checkOffset(t,4,this.length);return this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};Buffer$1.prototype.readFloatLE=function e(t,r){if(!r)checkOffset(t,4,this.length);return read$1(this,t,true,23,4)};Buffer$1.prototype.readFloatBE=function e(t,r){if(!r)checkOffset(t,4,this.length);return read$1(this,t,false,23,4)};Buffer$1.prototype.readDoubleLE=function e(t,r){if(!r)checkOffset(t,8,this.length);return read$1(this,t,true,52,8)};Buffer$1.prototype.readDoubleBE=function e(t,r){if(!r)checkOffset(t,8,this.length);return read$1(this,t,false,52,8)};function checkInt(e,t,r,n,i,a){if(!internalIsBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}Buffer$1.prototype.writeUIntLE=function e(t,r,n,i){t=+t;r=r|0;n=n|0;if(!i){var a=Math.pow(2,8*n)-1;checkInt(this,t,r,n,a,0)}var o=1;var u=0;this[r]=t&255;while(++u=0&&(u*=256)){this[r+o]=t/u&255}return r+n};Buffer$1.prototype.writeUInt8=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,1,255,0);if(!Buffer$1.TYPED_ARRAY_SUPPORT)t=Math.floor(t);this[r]=t&255;return r+1};function objectWriteUInt16(e,t,r,n){if(t<0)t=65535+t+1;for(var i=0,a=Math.min(e.length-r,2);i>>(n?i:1-i)*8}}Buffer$1.prototype.writeUInt16LE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,2,65535,0);if(Buffer$1.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8}else{objectWriteUInt16(this,t,r,true)}return r+2};Buffer$1.prototype.writeUInt16BE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,2,65535,0);if(Buffer$1.TYPED_ARRAY_SUPPORT){this[r]=t>>>8;this[r+1]=t&255}else{objectWriteUInt16(this,t,r,false)}return r+2};function objectWriteUInt32(e,t,r,n){if(t<0)t=4294967295+t+1;for(var i=0,a=Math.min(e.length-r,4);i>>(n?i:3-i)*8&255}}Buffer$1.prototype.writeUInt32LE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,4,4294967295,0);if(Buffer$1.TYPED_ARRAY_SUPPORT){this[r+3]=t>>>24;this[r+2]=t>>>16;this[r+1]=t>>>8;this[r]=t&255}else{objectWriteUInt32(this,t,r,true)}return r+4};Buffer$1.prototype.writeUInt32BE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,4,4294967295,0);if(Buffer$1.TYPED_ARRAY_SUPPORT){this[r]=t>>>24;this[r+1]=t>>>16;this[r+2]=t>>>8;this[r+3]=t&255}else{objectWriteUInt32(this,t,r,false)}return r+4};Buffer$1.prototype.writeIntLE=function e(t,r,n,i){t=+t;r=r|0;if(!i){var a=Math.pow(2,8*n-1);checkInt(this,t,r,n,a-1,-a)}var o=0;var u=1;var s=0;this[r]=t&255;while(++o>0)-s&255}return r+n};Buffer$1.prototype.writeIntBE=function e(t,r,n,i){t=+t;r=r|0;if(!i){var a=Math.pow(2,8*n-1);checkInt(this,t,r,n,a-1,-a)}var o=n-1;var u=1;var s=0;this[r+o]=t&255;while(--o>=0&&(u*=256)){if(t<0&&s===0&&this[r+o+1]!==0){s=1}this[r+o]=(t/u>>0)-s&255}return r+n};Buffer$1.prototype.writeInt8=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,1,127,-128);if(!Buffer$1.TYPED_ARRAY_SUPPORT)t=Math.floor(t);if(t<0)t=255+t+1;this[r]=t&255;return r+1};Buffer$1.prototype.writeInt16LE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,2,32767,-32768);if(Buffer$1.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8}else{objectWriteUInt16(this,t,r,true)}return r+2};Buffer$1.prototype.writeInt16BE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,2,32767,-32768);if(Buffer$1.TYPED_ARRAY_SUPPORT){this[r]=t>>>8;this[r+1]=t&255}else{objectWriteUInt16(this,t,r,false)}return r+2};Buffer$1.prototype.writeInt32LE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,4,2147483647,-2147483648);if(Buffer$1.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8;this[r+2]=t>>>16;this[r+3]=t>>>24}else{objectWriteUInt32(this,t,r,true)}return r+4};Buffer$1.prototype.writeInt32BE=function e(t,r,n){t=+t;r=r|0;if(!n)checkInt(this,t,r,4,2147483647,-2147483648);if(t<0)t=4294967295+t+1;if(Buffer$1.TYPED_ARRAY_SUPPORT){this[r]=t>>>24;this[r+1]=t>>>16;this[r+2]=t>>>8;this[r+3]=t&255}else{objectWriteUInt32(this,t,r,false)}return r+4};function checkIEEE754(e,t,r,n,i,a){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(e,t,r,n,i){if(!i){checkIEEE754(e,t,r,4)}write(e,t,r,n,23,4);return r+4}Buffer$1.prototype.writeFloatLE=function e(t,r,n){return writeFloat(this,t,r,true,n)};Buffer$1.prototype.writeFloatBE=function e(t,r,n){return writeFloat(this,t,r,false,n)};function writeDouble(e,t,r,n,i){if(!i){checkIEEE754(e,t,r,8)}write(e,t,r,n,52,8);return r+8}Buffer$1.prototype.writeDoubleLE=function e(t,r,n){return writeDouble(this,t,r,true,n)};Buffer$1.prototype.writeDoubleBE=function e(t,r,n){return writeDouble(this,t,r,false,n)};Buffer$1.prototype.copy=function e(t,r,n,i){if(!n)n=0;if(!i&&i!==0)i=this.length;if(r>=t.length)r=t.length;if(!r)r=0;if(i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");if(i>this.length)i=this.length;if(t.length-r=0;--o){t[o+r]=this[o+n]}}else if(a<1e3||!Buffer$1.TYPED_ARRAY_SUPPORT){for(o=0;o>>0;n=n===undefined?this.length:n>>>0;if(!t)t=0;var o;if(typeof t==="number"){for(o=r;o55295&&r<57344){if(!i){if(r>56319){if((t-=3)>-1)a.push(239,191,189);continue}else if(o+1===n){if((t-=3)>-1)a.push(239,191,189);continue}i=r;continue}if(r<56320){if((t-=3)>-1)a.push(239,191,189);i=r;continue}r=(i-55296<<10|r-56320)+65536}else if(i){if((t-=3)>-1)a.push(239,191,189)}i=null;if(r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else{throw new Error("Invalid code point")}}return a}function asciiToBytes(e){var t=[];for(var r=0;r>8;i=r%256;a.push(i);a.push(n)}return a}function base64ToBytes(e){return toByteArray(base64clean(e))}function blitBuffer(e,t,r,n){for(var i=0;i=t.length||i>=e.length)break;t[i+r]=e[i]}return i}function isnan(e){return e!==e}function isBuffer(e){return e!=null&&(!!e._isBuffer||isFastBuffer(e)||isSlowBuffer(e))}function isFastBuffer(e){return!!e.constructor&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)}function isSlowBuffer(e){return typeof e.readFloatLE==="function"&&typeof e.slice==="function"&&isFastBuffer(e.slice(0,0))}let decoder;try{decoder=new TextDecoder}catch(error){}let src;let srcEnd;let position$1=0;const LEGACY_RECORD_INLINE_ID=105;const RECORD_DEFINITIONS_ID=57342;const RECORD_INLINE_ID=57343;const BUNDLED_STRINGS_ID=57337;const PACKED_REFERENCE_TAG_ID=6;const STOP_CODE={};let currentDecoder={};let currentStructures;let srcString;let srcStringStart=0;let srcStringEnd=0;let bundledStrings$1;let referenceMap;let currentExtensions=[];let currentExtensionRanges=[];let packedValues;let dataView;let restoreMapsAsObject;let defaultOptions={useRecords:false,mapsAsObjects:true};let sequentialMode=false;let inlineObjectReadThreshold=2;try{new Function("")}catch(error){inlineObjectReadThreshold=Infinity}class Decoder{constructor(r){if(r){if((r.keyMap||r._keyMap)&&!r.useRecords){r.useRecords=false;r.mapsAsObjects=true}if(r.useRecords===false&&r.mapsAsObjects===undefined)r.mapsAsObjects=true;if(r.getStructures)r.getShared=r.getStructures;if(r.getShared&&!r.structures)(r.structures=[]).uninitialized=true;if(r.keyMap){this.mapKey=new Map;for(let[e,t]of Object.entries(r.keyMap))this.mapKey.set(t,e)}}Object.assign(this,r)}decodeKey(e){return this.keyMap?this.mapKey.get(e)||e:e}encodeKey(e){return this.keyMap&&this.keyMap.hasOwnProperty(e)?this.keyMap[e]:e}encodeKeys(r){if(!this._keyMap)return r;let n=new Map;for(let[e,t]of Object.entries(r))n.set(this._keyMap.hasOwnProperty(e)?this._keyMap[e]:e,t);return n}decodeKeys(e){if(!this._keyMap||e.constructor.name!="Map")return e;if(!this._mapKey){this._mapKey=new Map;for(let[e,t]of Object.entries(this._keyMap))this._mapKey.set(t,e)}let r={};e.forEach((e,t)=>r[safeKey(this._mapKey.has(t)?this._mapKey.get(t):t)]=e);return r}mapDecode(e,t){let r=this.decode(e);if(this._keyMap){switch(r.constructor.name){case"Array":return r.map(e=>this.decodeKeys(e))}}return r}decode(t,e){if(src){return saveState(()=>{clearSource();return this?this.decode(t,e):Decoder.prototype.decode.call(defaultOptions,t,e)})}srcEnd=e>-1?e:t.length;position$1=0;srcStringEnd=0;srcString=null;bundledStrings$1=null;src=t;try{dataView=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(e){src=null;if(t instanceof Uint8Array)throw e;throw new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Decoder){currentDecoder=this;packedValues=this.sharedValues&&(this.pack?new Array(this.maxPrivatePackedValues||16).concat(this.sharedValues):this.sharedValues);if(this.structures){currentStructures=this.structures;return checkedRead()}else if(!currentStructures||currentStructures.length>0){currentStructures=[]}}else{currentDecoder=defaultOptions;if(!currentStructures||currentStructures.length>0)currentStructures=[];packedValues=null}return checkedRead()}decodeMultiple(r,n){let i,a=0;try{let e=r.length;sequentialMode=true;let t=this?this.decode(r,e):defaultDecoder.decode(r,e);if(n){if(n(t)===false){return}while(position$1=bundledStrings$1.postBundlePosition){let e=new Error("Unexpected bundle position");e.incomplete=true;throw e}position$1=bundledStrings$1.postBundlePosition;bundledStrings$1=null}if(position$1==srcEnd){currentStructures=null;src=null;if(referenceMap)referenceMap=null}else if(position$1>srcEnd){let e=new Error("Unexpected end of CBOR data");e.incomplete=true;throw e}else if(!sequentialMode){throw new Error("Data read, but end of buffer not reached")}return e}catch(e){clearSource();if(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")){e.incomplete=true}throw e}}function read(){let n=src[position$1++];let i=n>>5;n=n&31;if(n>23){switch(n){case 24:n=src[position$1++];break;case 25:if(i==7){return getFloat16()}n=dataView.getUint16(position$1);position$1+=2;break;case 26:if(i==7){let t=dataView.getFloat32(position$1);if(currentDecoder.useFloat32>2){let e=mult10[(src[position$1]&127)<<1|src[position$1+1]>>7];position$1+=4;return(e*t+(t>0?.5:-.5)>>0)/e}position$1+=4;return t}n=dataView.getUint32(position$1);position$1+=4;break;case 27:if(i==7){let e=dataView.getFloat64(position$1);position$1+=8;return e}if(i>1){if(dataView.getUint32(position$1)>0)throw new Error("JavaScript does not support arrays, maps, or strings with length over 4294967295");n=dataView.getUint32(position$1+4)}else if(currentDecoder.int64AsNumber){n=dataView.getUint32(position$1)*4294967296;n+=dataView.getUint32(position$1+4)}else n=dataView.getBigUint64(position$1);position$1+=8;break;case 31:switch(i){case 2:case 3:throw new Error("Indefinite length not supported for byte or text strings");case 4:let e=[];let t,r=0;while((t=read())!=STOP_CODE){e[r++]=t}return i==4?e:i==3?e.join(""):Buffer$1.concat(e);case 5:let n;if(currentDecoder.mapsAsObjects){let e={};if(currentDecoder.keyMap)while((n=read())!=STOP_CODE)e[safeKey(currentDecoder.decodeKey(n))]=read();else while((n=read())!=STOP_CODE)e[safeKey(n)]=read();return e}else{if(restoreMapsAsObject){currentDecoder.mapsAsObjects=true;restoreMapsAsObject=false}let e=new Map;if(currentDecoder.keyMap)while((n=read())!=STOP_CODE)e.set(currentDecoder.decodeKey(n),read());else while((n=read())!=STOP_CODE)e.set(n,read());return e}case 7:return STOP_CODE;default:throw new Error("Invalid major type for indefinite length "+i)}default:throw new Error("Unknown token "+n)}}switch(i){case 0:return n;case 1:return~n;case 2:return readBin(n);case 3:if(srcStringEnd>=position$1){return srcString.slice(position$1-srcStringStart,(position$1+=n)-srcStringStart)}if(srcStringEnd==0&&srcEnd<140&&n<32){let e=n<16?shortStringInJS(n):longStringInJS(n);if(e!=null)return e}return readFixedString(n);case 4:let t=new Array(n);for(let e=0;e=BUNDLED_STRINGS_ID){let e=currentStructures[n&8191];if(e){if(!e.read)e.read=createStructureReader(e);return e.read()}if(n<65536){if(n==RECORD_INLINE_ID){let e=readJustLength();let t=read();let r=read();recordDefinition(t,r);let n={};if(currentDecoder.keyMap)for(let t=2;t23){switch(t){case 24:t=src[position$1++];break;case 25:t=dataView.getUint16(position$1);position$1+=2;break;case 26:t=dataView.getUint32(position$1);position$1+=4;break;default:throw new Error("Expected array header, but got "+src[position$1-1])}}let r=this.compiledReader;while(r){if(r.propertyCount===t)return r(read);r=r.next}if(this.slowReads++>=inlineObjectReadThreshold){let e=this.length==t?this:this.slice(0,t);r=currentDecoder.keyMap?new Function("r","return {"+e.map(e=>currentDecoder.decodeKey(e)).map(e=>validName.test(e)?safeKey(e)+":r()":"["+JSON.stringify(e)+"]:r()").join(",")+"}"):new Function("r","return {"+e.map(e=>validName.test(e)?safeKey(e)+":r()":"["+JSON.stringify(e)+"]:r()").join(",")+"}");if(this.compiledReader)r.next=this.compiledReader;r.propertyCount=t;this.compiledReader=r;return r(read)}let n={};if(currentDecoder.keyMap)for(let e=0;e64&&decoder)return decoder.decode(src.subarray(position$1,position$1+=e));const r=position$1+e;const n=[];t="";while(position$165535){e-=65536;n.push(e>>>10&1023|55296);e=56320|e&1023}n.push(e)}else{n.push(i)}if(n.length>=4096){t+=fromCharCode.apply(String,n);n.length=0}}if(n.length>0){t+=fromCharCode.apply(String,n)}return t}let fromCharCode=String.fromCharCode;function longStringInJS(t){let r=position$1;let n=new Array(t);for(let e=0;e0){position$1=r;return}n[e]=i}return fromCharCode.apply(String,n)}function shortStringInJS(d){if(d<4){if(d<2){if(d===0)return"";else{let e=src[position$1++];if((e&128)>1){position$1-=1;return}return fromCharCode(e)}}else{let e=src[position$1++];let t=src[position$1++];if((e&128)>0||(t&128)>0){position$1-=2;return}if(d<3)return fromCharCode(e,t);let r=src[position$1++];if((r&128)>0){position$1-=3;return}return fromCharCode(e,t,r)}}else{let f=src[position$1++];let _=src[position$1++];let p=src[position$1++];let h=src[position$1++];if((f&128)>0||(_&128)>0||(p&128)>0||(h&128)>0){position$1-=4;return}if(d<6){if(d===4)return fromCharCode(f,_,p,h);else{let e=src[position$1++];if((e&128)>0){position$1-=5;return}return fromCharCode(f,_,p,h,e)}}else if(d<8){let e=src[position$1++];let t=src[position$1++];if((e&128)>0||(t&128)>0){position$1-=6;return}if(d<7)return fromCharCode(f,_,p,h,e,t);let r=src[position$1++];if((r&128)>0){position$1-=7;return}return fromCharCode(f,_,p,h,e,t,r)}else{let u=src[position$1++];let s=src[position$1++];let c=src[position$1++];let l=src[position$1++];if((u&128)>0||(s&128)>0||(c&128)>0||(l&128)>0){position$1-=8;return}if(d<10){if(d===8)return fromCharCode(f,_,p,h,u,s,c,l);else{let e=src[position$1++];if((e&128)>0){position$1-=9;return}return fromCharCode(f,_,p,h,u,s,c,l,e)}}else if(d<12){let e=src[position$1++];let t=src[position$1++];if((e&128)>0||(t&128)>0){position$1-=10;return}if(d<11)return fromCharCode(f,_,p,h,u,s,c,l,e,t);let r=src[position$1++];if((r&128)>0){position$1-=11;return}return fromCharCode(f,_,p,h,u,s,c,l,e,t,r)}else{let n=src[position$1++];let i=src[position$1++];let a=src[position$1++];let o=src[position$1++];if((n&128)>0||(i&128)>0||(a&128)>0||(o&128)>0){position$1-=12;return}if(d<14){if(d===12)return fromCharCode(f,_,p,h,u,s,c,l,n,i,a,o);else{let e=src[position$1++];if((e&128)>0){position$1-=13;return}return fromCharCode(f,_,p,h,u,s,c,l,n,i,a,o,e)}}else{let e=src[position$1++];let t=src[position$1++];if((e&128)>0||(t&128)>0){position$1-=14;return}if(d<15)return fromCharCode(f,_,p,h,u,s,c,l,n,i,a,o,e,t);let r=src[position$1++];if((r&128)>0){position$1-=15;return}return fromCharCode(f,_,p,h,u,s,c,l,n,i,a,o,e,t,r)}}}}}function readBin(e){return currentDecoder.copyBuffers?Uint8Array.prototype.slice.call(src,position$1,position$1+=e):src.subarray(position$1,position$1+=e)}let f32Array=new Float32Array(1);let u8Array=new Uint8Array(f32Array.buffer,0,4);function getFloat16(){let t=src[position$1++];let r=src[position$1++];let e=(t&127)>>2;if(e===31){if(r||t&3)return NaN;return t&128?-Infinity:Infinity}if(e===0){let e=((t&3)<<8|r)/(1<<24);return t&128?-e:e}u8Array[3]=t&128|(e>>1)+56;u8Array[2]=(t&7)<<5|r>>3;u8Array[1]=r<<5;u8Array[0]=0;return f32Array[0]}new Array(4096);class Tag{constructor(e,t){this.value=e;this.tag=t}}currentExtensions[0]=e=>{return new Date(e)};currentExtensions[1]=e=>{return new Date(Math.round(e*1e3))};currentExtensions[2]=r=>{let n=BigInt(0);for(let e=0,t=r.byteLength;e{return BigInt(-1)-currentExtensions[2](e)};currentExtensions[4]=e=>{return+(e[1]+"e"+e[0])};currentExtensions[5]=e=>{return e[1]*Math.exp(e[0]*Math.log(2))};const recordDefinition=(e,t)=>{e=e-57344;let r=currentStructures[e];if(r&&r.isShared){(currentStructures.restoreStructures||(currentStructures.restoreStructures=[]))[e]=r}currentStructures[e]=t;t.read=createStructureReader(t)};currentExtensions[LEGACY_RECORD_INLINE_ID]=r=>{let e=r.length;let n=r[1];recordDefinition(r[0],n);let i={};for(let t=2;t{if(bundledStrings$1)return bundledStrings$1[0].slice(bundledStrings$1.position0,bundledStrings$1.position0+=e);return new Tag(e,14)};currentExtensions[15]=e=>{if(bundledStrings$1)return bundledStrings$1[1].slice(bundledStrings$1.position1,bundledStrings$1.position1+=e);return new Tag(e,15)};let glbl={Error:Error,RegExp:RegExp};currentExtensions[27]=e=>{return(glbl[e[0]]||Error)(e[1],e[2])};const packedTable=e=>{if(src[position$1++]!=132)throw new Error("Packed values structure must be followed by a 4 element array");let t=e();packedValues=packedValues?t.concat(packedValues.slice(t.length)):t;packedValues.prefixes=e();packedValues.suffixes=e();return e()};packedTable.handlesRead=true;currentExtensions[51]=packedTable;currentExtensions[PACKED_REFERENCE_TAG_ID]=e=>{if(!packedValues){if(currentDecoder.getShared)loadShared();else return new Tag(e,PACKED_REFERENCE_TAG_ID)}if(typeof e=="number")return packedValues[16+(e>=0?2*e:-2*e-1)];throw new Error("No support for non-integer packed references yet")};currentExtensions[28]=e=>{if(!referenceMap){referenceMap=new Map;referenceMap.id=0}let t=referenceMap.id++;let r=src[position$1];let n;if(r>>5==4)n=[];else n={};let i={target:n};referenceMap.set(t,i);let a=e();if(i.used)return Object.assign(n,a);i.target=a;return a};currentExtensions[28].handlesRead=true;currentExtensions[29]=e=>{let t=referenceMap.get(e);t.used=true;return t.target};currentExtensions[258]=e=>new Set(e);(currentExtensions[259]=e=>{if(currentDecoder.mapsAsObjects){currentDecoder.mapsAsObjects=false;restoreMapsAsObject=true}return e()}).handlesRead=true;function combine(e,t){if(typeof e==="string")return e+t;if(e instanceof Array)return e.concat(t);return Object.assign({},e,t)}function getPackedValues(){if(!packedValues){if(currentDecoder.getShared)loadShared();else throw new Error("No packed values available")}return packedValues}const SHARED_DATA_TAG_ID=1399353956;currentExtensionRanges.push((e,t)=>{if(e>=225&&e<=255)return combine(getPackedValues().prefixes[e-224],t);if(e>=28704&&e<=32767)return combine(getPackedValues().prefixes[e-28672],t);if(e>=1879052288&&e<=2147483647)return combine(getPackedValues().prefixes[e-1879048192],t);if(e>=216&&e<=223)return combine(t,getPackedValues().suffixes[e-216]);if(e>=27647&&e<=28671)return combine(t,getPackedValues().suffixes[e-27639]);if(e>=1811940352&&e<=1879048191)return combine(t,getPackedValues().suffixes[e-1811939328]);if(e==SHARED_DATA_TAG_ID){return{packedValues:packedValues,structures:currentStructures.slice(0),version:t}}if(e==55799)return t});const isLittleEndianMachine$1=new Uint8Array(new Uint16Array([1]).buffer)[0]==1;const typedArrays=[Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array=="undefined"?{name:"BigUint64Array"}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array=="undefined"?{name:"BigInt64Array"}:BigInt64Array,Float32Array,Float64Array];const typedArrayTags=[64,68,69,70,71,72,77,78,79,85,86];for(let e=0;e{if(!u)throw new Error("Could not find typed array for code "+s);return new u(Uint8Array.prototype.slice.call(e,0).buffer)}:e=>{if(!u)throw new Error("Could not find typed array for code "+s);let t=new DataView(e.buffer,e.byteOffset,e.byteLength);let r=e.length>>a;let n=new u(r);let i=t[c];for(let e=0;e23){switch(e){case 24:e=src[position$1++];break;case 25:e=dataView.getUint16(position$1);position$1+=2;break;case 26:e=dataView.getUint32(position$1);position$1+=4;break}}return e}function loadShared(){if(currentDecoder.getShared){let e=saveState(()=>{src=null;return currentDecoder.getShared()})||{};let t=e.structures||[];currentDecoder.sharedVersion=e.version;packedValues=currentDecoder.sharedValues=e.packedValues;if(currentStructures===true)currentDecoder.structures=currentStructures=t;else currentStructures.splice.apply(currentStructures,[0,t.length].concat(t))}}function saveState(e){let t=srcEnd;let r=position$1;let n=srcStringStart;let i=srcStringEnd;let a=srcString;let o=referenceMap;let u=bundledStrings$1;let s=new Uint8Array(src.slice(0,srcEnd));let c=currentStructures;let l=currentDecoder;let f=sequentialMode;let _=e();srcEnd=t;position$1=r;srcStringStart=n;srcStringEnd=i;srcString=a;referenceMap=o;bundledStrings$1=u;src=s;sequentialMode=f;currentStructures=c;currentDecoder=l;dataView=new DataView(src.buffer,src.byteOffset,src.byteLength);return _}function clearSource(){src=null;referenceMap=null;currentStructures=null}function addExtension$1(e){currentExtensions[e.tag]=e.decode}const mult10=new Array(147);for(let e=0;e<256;e++){mult10[e]=+("1e"+Math.floor(45.15-e*.30103))}let defaultDecoder=new Decoder({useRecords:false});defaultDecoder.decode;defaultDecoder.decodeMultiple;let textEncoder;try{textEncoder=new TextEncoder}catch(error){}let extensions,extensionClasses;const Buffer=typeof globalThis==="object"&&globalThis.Buffer;const hasNodeBuffer=typeof Buffer!=="undefined";const ByteArrayAllocate=hasNodeBuffer?Buffer.allocUnsafeSlow:Uint8Array;const ByteArray=hasNodeBuffer?Buffer:Uint8Array;const MAX_STRUCTURES=256;const MAX_BUFFER_SIZE=hasNodeBuffer?4294967296:2144337920;let throwOnIterable;let target;let targetView;let position=0;let safeEnd;let bundledStrings=null;const MAX_BUNDLE_SIZE=61440;const hasNonLatin=/[\u0080-\uFFFF]/;const RECORD_SYMBOL=Symbol("record-id");class Encoder extends Decoder{constructor(r){super(r);this.offset=0;let s;let o;let h;let l;let n;r=r||{};let c=ByteArray.prototype.utf8Write?function(e,t,r){return target.utf8Write(e,t,r)}:textEncoder&&textEncoder.encodeInto?function(e,t){return textEncoder.encodeInto(e,target.subarray(t)).written}:false;let a=this;let e=r.structures||r.saveStructures;let f=r.maxSharedStructures;if(f==null)f=e?128:0;if(f>8190)throw new Error("Maximum maxSharedStructure is 8190");let u=r.sequential;if(u){f=0}if(!this.structures)this.structures=[];if(this.saveStructures)this.saveShared=this.saveStructures;let d,m,y=r.sharedValues;let i;if(y){i=Object.create(null);for(let e=0,t=y.length;ethis.encodeKeys(e));break}}return this.encode(e,t)};this.encode=function(t,e){if(!target){target=new ByteArrayAllocate(8192);targetView=new DataView(target.buffer,0,8192);position=0}safeEnd=target.length-10;if(safeEnd-position<2048){target=new ByteArrayAllocate(target.length);targetView=new DataView(target.buffer,0,target.length);safeEnd=target.length-10;position=0}else if(e===REUSE_BUFFER_MODE)position=position+7&2147483640;s=position;if(a.useSelfDescribedHeader){targetView.setUint32(position,3654940416);position+=3}n=a.structuredClone?new Map:null;if(a.bundleStrings&&typeof t!=="string"){bundledStrings=[];bundledStrings.size=Infinity}else bundledStrings=null;o=a.structures;if(o){if(o.uninitialized){let e=a.getShared()||{};a.structures=o=e.structures||[];a.sharedVersion=e.version;let r=a.sharedValues=e.packedValues;if(r){i={};for(let e=0,t=r.length;ef&&!u)e=f;if(!o.transitions){o.transitions=Object.create(null);for(let a=0;a0){target[position++]=216;target[position++]=51;writeArrayHeader(4);let r=e.values;p(r);writeArrayHeader(0);writeArrayHeader(0);m=Object.create(i||null);for(let e=0,t=r.length;esafeEnd)w(position);a.offset=position;let e=insertIds(target.subarray(s,position),n.idsToInsert);n=null;return e}if(e&REUSE_BUFFER_MODE){target.start=s;target.end=position;return target}return target.subarray(s,position)}finally{if(o){if(g<10)g++;if(o.length>f)o.length=f;if(v>1e4){o.transitions=null;g=0;v=0;if(_.length>0)_=[]}else if(_.length>0&&!u){for(let e=0,t=_.length;ef){a.structures=a.structures.slice(0,f)}let e=target.subarray(s,position);if(a.updateSharedData()===false)return a.encode(t);return e}if(e&RESET_BUFFER_MODE)position=s}};this.findCommonStringsToPack=()=>{d=new Map;if(!i)i=Object.create(null);return e=>{let r=e&&e.threshold||4;let n=this.pack?e.maxPrivatePackedValues||16:0;if(!y)y=this.sharedValues=[];for(let[e,t]of d){if(t.count>r){i[e]=n++;y.push(e);h=true}}while(this.saveShared&&this.updateSharedData()===false){}d=null}};const p=o=>{if(position>safeEnd)target=w(position);var e=typeof o;var u;if(e==="string"){if(m){let e=m[o];if(e>=0){if(e<16)target[position++]=e+224;else{target[position++]=198;if(e&1)p(15-e>>1);else p(e-16>>1)}return}else if(d&&!r.pack){let e=d.get(o);if(e)e.count++;else d.set(o,{count:1})}}let i=o.length;if(bundledStrings&&i>=4&&i<1024){if((bundledStrings.size+=i)>MAX_BUNDLE_SIZE){let e;let t=(bundledStrings[0]?bundledStrings[0].length*3+bundledStrings[1].length:0)+10;if(position+t>safeEnd)target=w(position+t);target[position++]=217;target[position++]=223;target[position++]=249;target[position++]=bundledStrings.position?132:130;target[position++]=26;e=position-s;position+=4;if(bundledStrings.position){writeBundles(s,p)}bundledStrings=["",""];bundledStrings.size=0;bundledStrings.position=e}let e=hasNonLatin.test(o);bundledStrings[e?0:1]+=o;target[position++]=e?206:207;p(i);return}let a;if(i<32){a=1}else if(i<256){a=2}else if(i<65536){a=3}else{a=5}let e=i*3;if(position+e>safeEnd)target=w(position+e);if(i<64||!c){let e,t,r,n=position+a;for(e=0;e>6|192;target[n++]=t&63|128}else if((t&64512)===55296&&((r=o.charCodeAt(e+1))&64512)===56320){t=65536+((t&1023)<<10)+(r&1023);e++;target[n++]=t>>18|240;target[n++]=t>>12&63|128;target[n++]=t>>6&63|128;target[n++]=t&63|128}else{target[n++]=t>>12|224;target[n++]=t>>6&63|128;target[n++]=t&63|128}}u=n-position-a}else{u=c(o,position+a,e)}if(u<24){target[position++]=96|u}else if(u<256){if(a<2){target.copyWithin(position+2,position+1,position+1+u)}target[position++]=120;target[position++]=u}else if(u<65536){if(a<3){target.copyWithin(position+3,position+2,position+2+u)}target[position++]=121;target[position++]=u>>8;target[position++]=u&255}else{if(a<5){target.copyWithin(position+5,position+3,position+3+u)}target[position++]=122;targetView.setUint32(position,u);position+=4}position+=u}else if(e==="number"){if(!this.alwaysUseFloat&&o>>>0===o){if(o<24){target[position++]=o}else if(o<256){target[position++]=24;target[position++]=o}else if(o<65536){target[position++]=25;target[position++]=o>>8;target[position++]=o&255}else{target[position++]=26;targetView.setUint32(position,o);position+=4}}else if(!this.alwaysUseFloat&&o>>0===o){if(o>=-24){target[position++]=31-o}else if(o>=-256){target[position++]=56;target[position++]=~o}else if(o>=-65536){target[position++]=57;targetView.setUint16(position,~o);position+=2}else{target[position++]=58;targetView.setUint32(position,~o);position+=4}}else{let t;if((t=this.useFloat32)>0&&o<4294967296&&o>=-2147483648){target[position++]=250;targetView.setFloat32(position,o);let e;if(t<4||(e=o*mult10[(target[position]&127)<<1|target[position+1]>>7])>>0===e){position+=4;return}else position--}target[position++]=251;targetView.setFloat64(position,o);position+=8}}else if(e==="object"){if(!o)target[position++]=246;else{if(n){let t=n.get(o);if(t){target[position++]=216;target[position++]=29;target[position++]=25;if(!t.references){let e=n.idsToInsert||(n.idsToInsert=[]);t.references=[];e.push(t)}t.references.push(position-s);position+=2;return}else n.set(o,{offset:position-s})}let e=o.constructor;if(e===Object){b(o,true)}else if(e===Array){u=o.length;if(u<24){target[position++]=128|u}else{writeArrayHeader(u)}for(let e=0;e>8;target[position++]=u&255}else{target[position++]=186;targetView.setUint32(position,u);position+=4}if(a.keyMap){for(let[e,t]of o){p(a.encodeKey(e));p(t)}}else{for(let[e,t]of o){p(e);p(t)}}}else{for(let r=0,e=extensions.length;r>8;target[position++]=t&255}else if(t>-1){target[position++]=218;targetView.setUint32(position,t);position+=4}e.encode.call(this,o,p,w);return}}if(o[Symbol.iterator]){if(throwOnIterable){let e=new Error("Iterable should be serialized as iterator");e.iteratorNotHandled=true;throw e}target[position++]=159;for(let e of o){p(e)}target[position++]=255;return}if(o[Symbol.asyncIterator]||isBlob(o)){let e=new Error("Iterable/blob should be serialized as iterator");e.iteratorNotHandled=true;throw e}if(this.useToJSON&&o.toJSON){const t=o.toJSON();if(t!==o)return p(t)}b(o,!o.hasOwnProperty)}}}else if(e==="boolean"){target[position++]=o?245:244}else if(e==="bigint"){if(o=0){target[position++]=27;targetView.setBigUint64(position,o)}else if(o>-(BigInt(1)<{let t=Object.keys(e);let r=Object.values(e);let n=t.length;if(n<24){target[position++]=160|n}else if(n<256){target[position++]=184;target[position++]=n}else if(n<65536){target[position++]=185;target[position++]=n>>8;target[position++]=n&255}else{target[position++]=186;targetView.setUint32(position,n);position+=4}if(a.keyMap){for(let e=0;e{target[position++]=185;let e=position-s;position+=2;let n=0;if(a.keyMap){for(let e in t)if(r||t.hasOwnProperty(e)){p(a.encodeKey(e));p(t[e]);n++}}else{for(let e in t)if(r||t.hasOwnProperty(e)){p(e);p(t[e]);n++}}target[e+++s]=n>>8;target[e+s]=n&255}:(t,r)=>{let n,i=l.transitions||(l.transitions=Object.create(null));let a=0;let o=0;let u;let s;if(this.keyMap){s=Object.keys(t).map(e=>this.encodeKey(e));o=s.length;for(let t=0;t>8|224;target[position++]=c&255}else{if(!s)s=i.__keys__||(i.__keys__=Object.keys(t));if(u===undefined){c=l.nextId++;if(!c){c=0;l.nextId=1}if(c>=MAX_STRUCTURES){l.nextId=(c=f)+1}}else{c=u}l[c]=s;if(c>8|224;target[position++]=c&255;i=l.transitions;for(let e=0;e=MAX_STRUCTURES-f)_.shift()[RECORD_SYMBOL]=undefined;_.push(i);writeArrayHeader(o+2);p(57344+c);p(s);if(r===null)return;for(let e in t)if(r||t.hasOwnProperty(e))p(t[e]);return}}if(o<24){target[position++]=128|o}else{writeArrayHeader(o)}if(r===null)return;for(let e in t)if(r||t.hasOwnProperty(e))p(t[e])};const w=e=>{let t;if(e>16777216){if(e-s>MAX_BUFFER_SIZE)throw new Error("Encoded buffer would be larger than maximum buffer size");t=Math.min(MAX_BUFFER_SIZE,Math.round(Math.max((e-s)*(e>67108864?1.25:2),4194304)/4096)*4096)}else t=(Math.max(e-s<<2,target.length-1)>>12)+1<<12;let r=new ByteArrayAllocate(t);targetView=new DataView(r.buffer,0,t);if(target.copy)target.copy(r,0,s,e);else r.set(target.slice(s,e));position-=s;s=0;safeEnd=r.length-10;return target=r};let D=100;let x=1e3;this.encodeAsIterable=function(e,t){return S(e,t,E)};this.encodeAsAsyncIterable=function(e,t){return S(e,t,F)};function*E(n,i,e){let t=n.constructor;if(t===Object){let r=a.useRecords!==false;if(r)b(n,null);else writeEntityLength(Object.keys(n).length,160);for(let t in n){let e=n[t];if(!r)p(t);if(e&&typeof e==="object"){if(i[t])yield*E(e,i[t]);else yield*L(e,i,t)}else p(e)}}else if(t===Array){let e=n.length;writeArrayHeader(e);for(let t=0;tD)){if(i.element)yield*E(e,i.element);else yield*L(e,i,"element")}else p(e)}}else if(n[Symbol.iterator]){target[position++]=159;for(let e of n){if(e&&(typeof e==="object"||position-s>D)){if(i.element)yield*E(e,i.element);else yield*L(e,i,"element")}else p(e)}target[position++]=255}else if(isBlob(n)){writeEntityLength(n.size,64);yield target.subarray(s,position);yield n;A()}else if(n[Symbol.asyncIterator]){target[position++]=159;yield target.subarray(s,position);yield n;A();target[position++]=255}else{p(n)}if(e&&position>s)yield target.subarray(s,position);else if(position-s>D){yield target.subarray(s,position);A()}}function*L(t,r,n){let i=position-s;try{p(t);if(position-s>D){yield target.subarray(s,position);A()}}catch(e){if(e.iteratorNotHandled){r[n]={};position=s+i;yield*E.call(this,t,r[n])}else throw e}}function A(){D=x;a.encode(null,THROW_ON_ITERABLE)}function S(e,t,r){if(t&&t.chunkThreshold)D=x=t.chunkThreshold;else D=100;if(e&&typeof e==="object"){a.encode(null,THROW_ON_ITERABLE);return r(e,a.iterateProperties||(a.iterateProperties={}),true)}return[a.encode(e)]}async function*F(e,t){for(let r of E(e,t,true)){let e=r.constructor;if(e===ByteArray||e===Uint8Array)yield r;else if(isBlob(r)){let e=r.stream().getReader();let t;while(!(t=await e.read()).done){yield t.value}}else if(r[Symbol.asyncIterator]){for await(let e of r){A();if(e)yield*F(e,t.async||(t.async={}));else yield a.encode(e)}}else{yield r}}}}useBuffer(e){target=e;targetView=new DataView(target.buffer,target.byteOffset,target.byteLength);position=0}clearSharedData(){if(this.structures)this.structures=[];if(this.sharedValues)this.sharedValues=undefined}updateSharedData(){let t=this.sharedVersion||0;this.sharedVersion=t+1;let e=this.structures.slice(0);let r=new SharedData(e,this.sharedValues,this.sharedVersion);let n=this.saveShared(r,e=>(e&&e.version||0)==t);if(n===false){r=this.getShared()||{};this.structures=r.structures||[];this.sharedValues=r.packedValues;this.sharedVersion=r.version;this.structures.nextId=this.structures.length}else{e.forEach((e,t)=>this.structures[t]=e)}return n}}function writeEntityLength(e,t){if(e<24)target[position++]=t|e;else if(e<256){target[position++]=t|24;target[position++]=e}else if(e<65536){target[position++]=t|25;target[position++]=e>>8;target[position++]=e&255}else{target[position++]=t|26;targetView.setUint32(position,e);position+=4}}class SharedData{constructor(e,t,r){this.structures=e;this.packedValues=t;this.version=r}}function writeArrayHeader(e){if(e<24)target[position++]=128|e;else if(e<256){target[position++]=152;target[position++]=e}else if(e<65536){target[position++]=153;target[position++]=e>>8;target[position++]=e&255}else{target[position++]=154;targetView.setUint32(position,e);position+=4}}const BlobConstructor=typeof Blob==="undefined"?function(){}:Blob;function isBlob(e){if(e instanceof BlobConstructor)return true;let t=e[Symbol.toStringTag];return t==="Blob"||t==="File"}function findRepetitiveStrings(r,n){switch(typeof r){case"string":if(r.length>3){if(n.objectMap[r]>-1||n.values.length>=n.maxValues)return;let e=n.get(r);if(e){if(++e.count==2){n.values.push(r)}}else{n.set(r,{count:1});if(n.samplingPackedValues){let e=n.samplingPackedValues.get(r);if(e)e.count++;else n.samplingPackedValues.set(r,{count:1})}}}break;case"object":if(r){if(r instanceof Array){for(let e=0,t=r.length;e=0&&r<4294967296){target[position++]=26;targetView.setUint32(position,r);position+=4}else{target[position++]=251;targetView.setFloat64(position,r);position+=8}}},{tag:258,encode(e,t){let r=Array.from(e);t(r)}},{tag:27,encode(e,t){t([e.name,e.message])}},{tag:27,encode(e,t){t(["RegExp",e.source,e.flags])}},{getTag(e){return e.tag},encode(e,t){t(e.value)}},{encode(e,t,r){writeBuffer(e,r)}},{getTag(e){if(e.constructor===Uint8Array){if(this.tagUint8Array||hasNodeBuffer&&this.tagUint8Array!==false)return 64}},encode(e,t,r){writeBuffer(e,r)}},typedArrayEncoder(68,1),typedArrayEncoder(69,2),typedArrayEncoder(70,4),typedArrayEncoder(71,8),typedArrayEncoder(72,1),typedArrayEncoder(77,2),typedArrayEncoder(78,4),typedArrayEncoder(79,8),typedArrayEncoder(85,4),typedArrayEncoder(86,8),{encode(t,n){let e=t.packedValues||[];let r=t.structures||[];if(e.values.length>0){target[position++]=216;target[position++]=51;writeArrayHeader(4);let r=e.values;n(r);writeArrayHeader(0);writeArrayHeader(0);packedObjectMap=Object.create(sharedPackedObjectMap||null);for(let e=0,t=r.length;e1)e-=4;return{tag:e,encode:function e(t,r){let n=t.byteLength;let i=t.byteOffset||0;let a=t.buffer||t;r(hasNodeBuffer?Buffer.from(a,i,n):new Uint8Array(a,i,n))}}}function writeBuffer(e,t){let r=e.byteLength;if(r<24){target[position++]=64+r}else if(r<256){target[position++]=88;target[position++]=r}else if(r<65536){target[position++]=89;target[position++]=r>>8;target[position++]=r&255}else{target[position++]=90;targetView.setUint32(position,r);position+=4}if(position+r>=target.length){t(position+r)}target.set(e.buffer?e:new Uint8Array(e),position);position+=r}function insertIds(n,e){let r;let i=e.length*2;let a=n.length-i;e.sort((e,t)=>e.offset>t.offset?1:-1);for(let r=0;r>8;n[e]=r&255}}while(r=e.pop()){let e=r.offset;n.copyWithin(e+i,e,a);i-=2;let t=e+i;n[t++]=216;n[t++]=28;a=e}return n}function writeBundles(e,t){targetView.setUint32(bundledStrings.position+e,position-bundledStrings.position-e+1);let r=bundledStrings;bundledStrings=null;t(r[0]);t(r[1])}function addExtension(e){if(e.Class){if(!e.encode)throw new Error("Extension has no encode function");extensionClasses.unshift(e.Class);extensions.unshift(e)}addExtension$1(e)}let defaultEncoder=new Encoder({useRecords:false});defaultEncoder.encode;defaultEncoder.encodeAsIterable;defaultEncoder.encodeAsAsyncIterable;const REUSE_BUFFER_MODE=512;const RESET_BUFFER_MODE=1024;const THROW_ON_ITERABLE=2048;var lzjbPack={}; /**@license * * No Dependency fast and small LZJB Compression for Browser and Node @@ -47,5 +47,5 @@ function _classApplyDescriptorGet(e,t){if(t.get){return t.get.call(e)}return t.v * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Mon, 15 Jan 2024 12:39:38 +0000 - */var _excluded=["token"],_excluded2=["env"],_excluded3=["stderr","stdin","stdout","command_line"],_excluded4=["use_dynamic"],_excluded5=["use_dynamic"],_excluded6=["env","dynamic_env","use_dynamic","error"];function _classPrivateFieldInitSpec(e,t,r){_checkPrivateRedeclaration(e,t);t.set(e,r)}function _checkPrivateRedeclaration(e,t){if(t.has(e)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}function _createSuper(i){var a=_isNativeReflectConstruct();return function e(){var t=_getPrototypeOf(i),r;if(a){var n=_getPrototypeOf(this).constructor;r=Reflect.construct(t,arguments,n)}else{r=t.apply(this,arguments)}return _possibleConstructorReturn(this,r)}}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(t,e){var r=typeof Symbol!=="undefined"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=_unsupportedIterableToArray(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 a=true,o=false,u;return{s:function e(){r=r.call(t)},n:function e(){var t=r.next();a=t.done;return t},e:function e(t){o=true;u=t},f:function e(){try{if(!a&&r["return"]!=null)r["return"]()}finally{if(o)throw u}}}}function _unsupportedIterableToArray(e,t){if(!e)return;if(typeof e==="string")return _arrayLikeToArray(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 _arrayLikeToArray(e,t)}function _arrayLikeToArray(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(!is_debug()){return}var t=global_env.get("repr")(e);if(r===null||r instanceof RegExp&&r.test(t)){console.log(global_env.get("type")(e)+": "+t)}if(n){console.log(e)}}if(is_promise(e)){e.then(t)}else{t(e)}return e}function is_debug(){return user_env&&user_env.get("DEBUG",{throwError:false})}function num_mnemicic_re(e){return e?"(?:#".concat(e,"(?:#[ie])?|#[ie]#").concat(e,")"):"(?:#[ie])?"}function gen_rational_re(e,t){return"".concat(num_mnemicic_re(e),"[+-]?").concat(t,"+/").concat(t,"+")}function gen_complex_re(e,t){return"".concat(num_mnemicic_re(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 gen_integer_re(e,t){return"".concat(num_mnemicic_re(e),"[+-]?").concat(t,"+")}var re_re=/^#\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimyus]*)$/;var float_stre="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+)(?:[eE][-+]?[0-9]+)?)|[0-9]+\\.)";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(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 complex_list_re=function(){var a={};[[10,"","[0-9]"],[16,"x","[0-9a-fA-F]"],[8,"o","[0-7]"],[2,"b","[01]"]].forEach(function(e){var t=_slicedToArray(e,3),r=t[0],n=t[1],i=t[2];a[r]=make_complex_match_re(n,i)});return a}();var characters={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 ucs2decode(e){var t=[];var r=0;var n=e.length;while(r=55296&&i<=56319&&r1&&arguments[1]!==undefined?arguments[1]:10;var r=num_pre_parse(e);var n=r.number.split("/");var i=LRational({num:LNumber([n[0],r.radix||t]),denom:LNumber([n[1],r.radix||t])});if(r.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;var r=num_pre_parse(e);if(r.inexact){return LFloat(parseInt(r.number,r.radix||t))}return LNumber([r.number,r.radix||t])}function parse_character(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 LCharacter(r)}throw new Error("Parse: invalid character")}function parse_complex(e){var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;function t(e){var t;if(e==="+"){t=LNumber(1)}else if(e==="-"){t=LNumber(-1)}else if(e.match(int_bare_re)){t=LNumber([e,i])}else if(e.match(rational_bare_re)){var r=e.split("/");t=LRational({num:LNumber([r[0],i]),denom:LNumber([r[1],i])})}else if(e.match(float_re)){var n=parse_float(e);if(a.exact){return n.toRational()}return n}else if(e.match(/nan.0$/)){return LNumber(NaN)}else if(e.match(/inf.0$/)){if(e[0]==="-"){return LNumber(Number.NEGATIVE_INFINITY)}return LNumber(Number.POSITIVE_INFINITY)}else{throw new Error("Internal Parser Error")}if(a.inexact){return LFloat(t.valueOf())}return t}var a=num_pre_parse(e);i=a.radix||i;var r;var n=a.number.match(complex_bare_match_re);if(i!==10&&n){r=n}else{r=a.number.match(complex_list_re[i])}var o,u;u=t(r[2]);if(r[1]){o=t(r[1])}else{o=LNumber(0)}if(u.cmp(0)===0&&u.__type__==="bigint"){return o}return LComplex({im:u,re:o})}function is_int(e){return parseInt(e.toString(),10)===e}function parse_big_int(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 a=t[3]&&t[3].length;if(i0){return LNumber(a).mul(u)}}}r=LFloat(r);if(t.exact){return r.toRational()}return r}function parse_string(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 LString(JSON.parse(e))}catch(e){var r=e.message.replace(/in JSON /,"").replace(/.*Error: /,"");throw new Error("Invalid string literal: ".concat(r))}}function parse_symbol(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 LSymbol(e)}function parse_argument(e){if(constants.hasOwnProperty(e)){return constants[e]}if(e.match(/^"[\s\S]*"$/)){return parse_string(e)}else if(e[0]==="#"){var t=e.match(re_re);if(t){return new RegExp(t[1],t[2])}else if(e.match(char_re)){return parse_character(e)}var r=e.match(/#\\(.+)/);if(r&&ucs2decode(r[1]).length===1){return parse_character(e)}}if(e.match(/[0-9a-f]|[+-]i/i)){if(e.match(int_re)){return parse_integer(e)}else if(e.match(float_re)){return parse_float(e)}else if(e.match(rational_re)){return parse_rational(e)}else if(e.match(complex_re)){return parse_complex(e)}}if(e.match(/^#[iexobd]/)){throw new Error("Invalid numeric constant: "+e)}return parse_symbol(e)}function is_atom_string(e){return!(["(",")","[","]"].includes(e)||specials.names().includes(e))}function is_symbol_string(e){return is_atom_string(e)&&!(e.match(re_re)||e.match(/^"[\s\S]*"$/)||e.match(int_re)||e.match(float_re)||e.match(complex_re)||e.match(rational_re)||e.match(char_re)||["#t","#f","nil","true","false"].includes(e))}var string_re=/"(?:\\[\S\s]|[^"])*"?/g;function escape_regex(e){if(typeof e==="string"){var t=/([-\\^$[\]()+{}?*.|])/g;return e.replace(t,"\\$1")}return e}function Stack(){this.data=[]}Stack.prototype.push=function(e){this.data.push(e)};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(e){if(e instanceof LString){e=e.valueOf()}var t=new Lexer(e,{whitespace:true});var r=[];while(true){var n=t.peek(true);if(n===eof){break}r.push(n);t.skip()}return r}function multiline_formatter(e){var t=e.token,r=_objectWithoutProperties(e,_excluded);if(t.match(/^"[\s\S]*"$/)&&t.match(/\n/)){var n=new RegExp("^ {1,"+(e.col+1)+"}","mg");t=t.replace(n,"")}return _objectSpread({token:t},r)}function Thunk(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};this.fn=e;this.cont=t}Thunk.prototype.toString=function(){return"#"};function trampoline(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r1&&arguments[1]!==undefined?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(t){return tokens(e)}else{var r=tokens(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 strip_s_comments(r)}}function strip_s_comments(e){var t=0;var r=null;var n=[];for(var i=0;i0&&arguments[0]!==undefined?arguments[0]:null;if(e instanceof LSymbol){if(e.is_gensym()){return e}e=e.valueOf()}if(is_gensym(e)){return LSymbol(e)}if(e!==null){return r(e,Symbol("#:".concat(e)))}t++;return r(t,Symbol("#:g".concat(t)))}}();function QuotedPromise(e){var r=this;var n={pending:true,rejected:false,fulfilled:false,reason:undefined,type:undefined};e=e.then(function(e){n.type=type(e);n.fulfilled=true;n.pending=false;return e});read_only(this,"_promise",e,{hidden:true});if(is_function(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]}})});read_only(this,"__promise__",e);this.then=false}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.valueOf().then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.valueOf()["catch"](e))};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="#";function promise_all(e){if(Array.isArray(e)){return Promise.all(escape_quoted_promises(e)).then(unescape_quoted_promises)}return e}function escape_quoted_promises(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof QuotedPromise){t[r]=new Value(n)}else{t[r]=n}}return t}function unescape_quoted_promises(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof Value){t[r]=n.valueOf()}else{t[r]=n}}return t}var specials={LITERAL:Symbol["for"]("literal"),SPLICE:Symbol["for"]("splice"),SYMBOL:Symbol["for"]("symbol"),names:function e(){return Object.keys(this.__list__)},type:function e(t){try{return this.get(t).type}catch(e){console.log({name:t});console.log(e);return null}},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 LSymbol("quote-promise"),specials.LITERAL]];var builtins=defined_specials.map(function(e){return e[0]});Object.freeze(builtins);Object.defineProperty(specials,"__builtins__",{writable:false,value:builtins});defined_specials.forEach(function(e){var t=_slicedToArray(e,3),r=t[0],n=t[1],i=t[2];specials.append(r,n,i)});var Lexer=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;_classCallCheck(this,p);read_only(this,"__input__",e.replace(/\r/g,""));var a={};["_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 a[r]},set:function e(t){a[r]=t}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}_createClass(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 eof}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 eof}},{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 eof}for(var r=this._i;r=r){return eof}if(t+this._i>=r){return this.read_rest()}var n=this._i+t;var i=this.__input__.substring(this._i,n);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=n;return i}},{key:"peek_char",value:function e(){if(this._i>=this.__input__.length){return eof}return LCharacter(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 a=_slicedToArray(e,4),o=a[0],u=a[1],s=a[2],l=a[3];if(e.length!==5){throw new Error("Lexer: Invalid rule of length ".concat(e.length))}if(!n.match(o)){return false}if(!match_or_null(u,r)){return false}if(!match_or_null(s,i)){return false}if(l!==this._state){return false}return true}},{key:"next_token",value:function l(){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 a=[];for(var o=0,u=t.length;o1&&arguments[1]!==undefined?arguments[1]:{},r=t.env,n=t.meta,i=n===void 0?false:n,a=t.formatter,o=a===void 0?multiline_formatter:a;_classCallCheck(this,u);if(e instanceof LString){e=e.toString()}read_only(this,"_formatter",o,{hidden:true});read_only(this,"__lexer__",new Lexer(e));read_only(this,"__env__",r);read_only(this,"_meta",i,{hidden:true});read_only(this,"_refs",[],{hidden:true});read_only(this,"_state",{parentheses:0},{hidden:true})}_createClass(u,[{key:"resolve",value:function e(t){return this.__env__&&this.__env__.get(t,{throwError:false})}},{key:"peek",value:function(){var e=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:r=this.__lexer__.peek(true);if(!(r===eof)){t.next=4;break}return t.abrupt("return",eof);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()===eof)){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=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.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=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r,n,i,a;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:r=_nil,n=r;case 1:t.next=4;return this.peek();case 4:i=t.sent;if(!(i===eof)){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!==_nil)){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=Pair;t.next=20;return this._read_object();case 20:t.t1=t.sent;t.t2=_nil;a=new t.t0(t.t1,t.t2);if(r===_nil){r=a}else{n.cdr=a}n=a;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=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.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===eof)){t.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return t.abrupt("return",parse_argument(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 _evaluate(t,{env:this.__env__,error:function e(t){throw t}})}},{key:"read_object",value:function(){var e=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.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 DatumReference){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,r){var n=this._state.parentheses;var i;if(n<0){i=new Error("Parser: unexpected parenthesis");i.__code__=[r.toString()+")"]}else{i=new Error("Parser: expected parenthesis but eof found");var a=new RegExp("\\){".concat(n,"}$"));i.__code__=[t.toString().replace(a,"")]}throw i}},{key:"_resolve_object",value:function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function e(r){var n=this;var i;return _regeneratorRuntime.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(!is_plain_object(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 Pair)){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=_asyncToGenerator(_regeneratorRuntime.mark(function e(r){return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!(r instanceof Pair)){t.next=15;break}if(!(r.car instanceof DatumReference)){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 DatumReference)){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=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r,n,_,i,a,o,u,s,c,l,f;return _regeneratorRuntime.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===eof)){t.next=5;break}return t.abrupt("return",r);case 5:if(!is_special(r)){t.next=38;break}n=specials.get(r);_=is_builtin(r);this.skip();a=is_symbol_extension(r);if(!a){t.next=14;break}t.t0=undefined;t.next=17;break;case 14:t.next=16;return this._read_object();case 16:t.t0=t.sent;case 17:o=t.t0;if(_){t.next=25;break}u=this.__env__.get(n.symbol);if(!(typeof u==="function")){t.next=25;break}if(is_literal(r)){s=[o]}else if(o===_nil){s=[]}else if(o instanceof Pair){s=o.to_array(false)}if(!(s||a)){t.next=24;break}return t.abrupt("return",call_function(u,a?[]:s,{env:this.__env__,dynamic_env:this.__env__,use_dynamic:false}));case 24:throw new Error("Parse Error: Invalid parser extension "+"invocation ".concat(n.symbol));case 25:if(is_literal(r)){i=new Pair(n.symbol,new Pair(o,_nil))}else{i=new Pair(n.symbol,o)}if(!_){t.next=28;break}return t.abrupt("return",i);case 28:if(!(u instanceof Macro)){t.next=37;break}t.next=31;return this.evaluate(i);case 31:c=t.sent;if(!(c instanceof Pair||c instanceof LSymbol)){t.next=34;break}return t.abrupt("return",Pair.fromArray([LSymbol("quote"),c]));case 34:return t.abrupt("return",c);case 37:throw new Error("Parse Error: invalid parser extension: "+n.symbol);case 38:l=this.match_datum_ref(r);if(!(l!==null)){t.next=44;break}this.skip();if(!this._refs[l]){t.next=43;break}return t.abrupt("return",new DatumReference(l,this._refs[l]));case 43:throw new Error("Parse Error: invalid datum label #".concat(l,"#"));case 44:f=this.match_datum_label(r);if(!(f!==null)){t.next=51;break}this.skip();this._refs[f]=this._read_object();return t.abrupt("return",this._refs[f]);case 51:if(!this.is_close(r)){t.next=55;break}this.skip();t.next=61;break;case 55:if(!this.is_open(r)){t.next=60;break}this.skip();return t.abrupt("return",this.read_list());case 60:return t.abrupt("return",this.read_value());case 61:case"end":return t.stop()}}},e,this)}));function t(){return e.apply(this,arguments)}return t}()}]);return u}();var DatumReference=function(){function r(e,t){_classCallCheck(this,r);this.name=e;this.data=t}_createClass(r,[{key:"valueOf",value:function e(){return this.data}}]);return r}();function parse(e,t){return _parse.apply(this,arguments)}function _parse(){_parse=_wrapAsyncGenerator(_regeneratorRuntime.mark(function e(r,n){var i,a,o;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!n){if(global_env){n=global_env.get("**interaction-environment**",{throwError:false})}else{n=user_env}}i=new Parser(r,{env:n});case 3:t.next=6;return _awaitAsyncGenerator(i.read_object());case 6:o=t.sent;if(!i.balanced()){i.ballancing_error(o,a)}if(!(o===eof)){t.next=10;break}return t.abrupt("break",15);case 10:a=o;t.next=13;return o;case 13:t.next=3;break;case 15:case"end":return t.stop()}}},e)}));return _parse.apply(this,arguments)}function unpromise(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(is_promise(e)){var n=e.then(t);if(r===null){return n}else{return n["catch"](r)}}if(e instanceof Array){return unpromise_array(e,t,r)}if(is_plain_object(e)){return unpromise_object(e,t,r)}return t(e)}function unpromise_array(t,r,e){if(t.find(is_promise)){return unpromise(promise_all(t),function(e){if(Object.isFrozen(t)){Object.freeze(e)}return r(e)},e)}return r(t)}function unpromise_object(t,e,r){var i=Object.keys(t);var n=[],a=[];var o=i.length;while(o--){var u=i[o];var s=t[u];n[o]=s;if(is_promise(s)){a.push(s)}}if(a.length){return unpromise(promise_all(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 read_only(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},i=n.hidden,a=i===void 0?false:i;Object.defineProperty(e,t,{value:r,configurable:true,enumerable:!a})}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=_asyncToGenerator(_regeneratorRuntime.mark(function e(r){var n,i,a,o,u,s,c;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:n=[];i=false;a=false;t.prev=3;u=_asyncIterator(r);case 5:t.next=7;return u.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);a=true;o=t.t0;case 19:t.prev=19;t.prev=20;if(!(i&&u["return"]!=null)){t.next=24;break}t.next=24;return u["return"]();case 24:t.prev=24;if(!a){t.next=27;break}throw o;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 _uniterate_async.apply(this,arguments)}function matcher(e,t){if(t instanceof RegExp){return function(e){return String(e).match(t)}}else if(is_function(t)){return t}throw new Error("Invalid matcher")}function doc(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__=trim_lines(r)}}if(e){t.__name__=e}else if(t.name&&!is_lambda(t)){t.__name__=t.name}return t}function trim_lines(e){return e.split("\n").map(function(e){return e.trim()}).join("\n")}function previousSexp(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 lineIndent(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 match(e,t){return l(e,t)===t.length;function l(r,n){function e(e,t){var r=_createForOfIteratorHelper(e),n;try{for(r.s();!(n=r.n()).done;){var i=n.value;var a=l(i,t);if(a!==-1){return a}}}catch(e){r.e(e)}finally{r.f()}return-1}function t(){return r[a]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function i(){var e=r[a+1];var t=n[u+1];if(e!==undefined&&t!==undefined){return l([e],[t])}}var a=0;var o={};for(var u=0;u0){continue}}else if(t()){return-1}}else if(r[a]instanceof Array){var c=l(r[a],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;a++;continue}else{return-1}a++}if(r.length!==a){return-1}return n.length}}function Formatter(e){this.__code__=e.replace(/\r/g,"")}Formatter.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:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(t){var r=Formatter.defaults;if(typeof t==="undefined"){return Object.assign({},r)}var n=t&&t.exceptions||{};var i=n.specials||[];var a=n.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},r),t),{},{exceptions:{specials:[].concat(_toConsumableArray(r.exceptions.specials),_toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(_toConsumableArray(r.exceptions.shift[1]),_toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(t){var r=tokenize(this.__code__,true);return this._indent(r,t)};Formatter.exception_shift=function(a,e){function t(e){if(!e.length){return false}if(e.indexOf(a)!==-1){return true}else{var t=e.filter(function(e){return e instanceof RegExp});if(!t.length){return false}var r=_createForOfIteratorHelper(t),n;try{for(r.s();!(n=r.n()).done;){var i=n.value;if(a.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()&&balanced(n)){return t.offset+n[0].col}else if(n.length===1){return t.offset+n[0].col+1}else{var a=-1;if(i){var o=Formatter.exception_shift(i.token,t);if(o!==-1){a=o}}if(a===-1){a=Formatter.exception_shift(n[1].token,t)}if(a!==-1){return t.offset+n[0].col+a}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 u=n.slice(2);for(var s=0;s")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,t=new Array(e),r=0;r")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/^[[(]$/;var p_e=/^[\])]$/;var not_p=/[^()[\]]/;var not_close=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],"+");var def_lambda_re=keywords_re("define","lambda","define-macro","syntax-rules");var non_def=/^(?!.*\b(?:[()[\]]|define(?:-macro)?|let(?:\*|rec|-env|-syntax|)?|lambda|syntax-rules)\b).*$/;var let_re=/^(?:#:)?(let(?:\*|rec|-env|-syntax)?)$/;function keywords_re(){for(var e=arguments.length,t=new Array(e),r=0;r0&&!i[e]){i[e]=previousSexp(n,e)}});var a=_createForOfIteratorHelper(t),p;try{for(a.s();!(p=a.n()).done;){var o=_slicedToArray(p.value,3),h=o[0],u=o[1],s=o[2];u=u.valueOf();var d=u>0?i[u]:n;var m=d.filter(function(e){return e.trim()&&!is_special(e)});var y=_(d);var v=match(h,m);var g=e.slice(r).find(function(e){return e.trim()&&!is_special(e)});if(v&&(s instanceof Ahead&&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){a.e(e)}finally{a.f()}}this.__code__=e.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function c(e){var t=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var r=tokenize(t,true);var n=this._options(e);var i=0;var a=0;for(var o=0;o0){n=Math.floor(t()*r);r--;var i=[e[n],e[r]];e[r]=i[0];e[n]=i[1]}return e}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(e){return new Pair(e,_nil)};Nil.prototype.to_array=function(){return[]};var _nil=new Nil;function Pair(e,t){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,t)}this.car=e;this.cdr=t}function to_array(a,o){return function e(t){typecheck(a,t,["pair","nil"]);if(t===_nil){return[]}var r=[];var n=t;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(o&&i instanceof Pair){i=this.get(a).call(this,i)}r.push(i);n=n.cdr}else if(n===_nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return r}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.to_array()))};Pair.prototype.length=function(){var e=0;var t=this;while(true){if(!t||t===_nil||!(t instanceof Pair)||t.haveCycles("cdr")){break}e++;t=t.cdr}return e};Pair.match=function(e,t){if(e instanceof LSymbol){return LSymbol.is(e,t)}else if(e instanceof Pair){return Pair.match(e.car,t)||Pair.match(e.cdr,t)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,t)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,t)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var r=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var n=new Map;function i(e){if(e instanceof Pair){if(n.has(e)){return n.get(e)}var t=new Pair;n.set(e,t);if(r){t.car=i(e.car)}else{t.car=e.car}t.cdr=i(e.cdr);t[__cycles__]=e[__cycles__];return t}return e}return i(this)};Pair.prototype.last_pair=function(){var e=this;while(true){if(e.cdr===_nil){return e}e=e.cdr}};Pair.prototype.to_array=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var t=[];if(this.car instanceof Pair){if(e){t.push(this.car.to_array())}else{t.push(this.car)}}else{t.push(this.car.valueOf())}if(this.cdr instanceof Pair){t=t.concat(this.cdr.to_array(e))}return t};Pair.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 Pair||r&&e instanceof Array&&e[__data__]){return e}if(t===false){var n=_nil;for(var i=e.length;i--;){n=new Pair(e[i],n)}return n}if(e.length&&!(e instanceof Array)){e=_toConsumableArray(e)}var a=_nil;var o=e.length;while(o--){var u=e[o];if(u instanceof Array){u=Pair.fromArray(u,t,r)}else if(typeof u==="string"){u=LString(u)}else if(typeof u==="number"&&!Number.isNaN(u)){u=LNumber(u)}a=new Pair(u,a)}return a};Pair.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 Pair&&t.car instanceof Pair){var n=t.car;var i=n.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=n.cdr;if(a instanceof Pair){a=a.to_object(e)}if(is_native(a)){if(!e){a=a.valueOf()}}r[i]=a;t=t.cdr}else{break}}return r};Pair.fromPairs=function(e){return e.reduce(function(e,t){return new Pair(new Pair(new LSymbol(t[0]),t[1]),e)},_nil)};Pair.fromObject=function(t){var e=Object.keys(t).map(function(e){return[e,t[e]]});return Pair.fromPairs(e)};Pair.prototype.reduce=function(e){var t=this;var r=_nil;while(true){if(t!==_nil){r=e(r,t.car);t=t.cdr}else{break}}return r};Pair.prototype.reverse=function(){if(this.haveCycles()){throw new Error("You can't reverse list that have cycles")}var e=this;var t=_nil;while(e!==_nil){var r=e.cdr;e.cdr=t;t=e;e=r}return t};Pair.prototype.transform=function(n){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var t=n(e.car);if(t instanceof Pair){t=i(t)}var r=n(e.cdr);if(r instanceof Pair){r=i(r)}return new Pair(t,r)}return e}return i(this)};Pair.prototype.map=function(e){if(typeof this.car!=="undefined"){return new Pair(e(this.car),this.cdr===_nil?_nil:this.cdr.map(e))}else{return _nil}};var repr=new Map;function is_plain_object(e){return e&&_typeof(e)==="object"&&e.constructor===Object}var props=Object.getOwnPropertyNames(Array.prototype);var array_methods=[];props.forEach(function(e){array_methods.push(Array[e],Array.prototype[e])});function is_array_method(e){e=unbind(e);return array_methods.includes(e)}function is_lips_function(e){return is_function(e)&&(is_lambda(e)||e.__doc__)}function user_repr(r){var e=r.constructor||Object;var n=is_plain_object(r);var i=is_function(r[Symbol.asyncIterator])||is_function(r[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,t){t=unbind(t);if(r.constructor===t&&(t===Object&&n&&!i||t!==Object)){a=e}})}return a}var str_mapping=new Map;[[true,"#t"],[false,"#f"],[null,"null"],[undefined,"#"]].forEach(function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];str_mapping.set(r,n)});function symbolize(r){if(r&&_typeof(r)==="object"){var n={};var e=Object.getOwnPropertySymbols(r);e.forEach(function(e){var t=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");n[t]=toString(r[e])});var t=Object.getOwnPropertyNames(r);t.forEach(function(e){var t=r[e];if(t&&_typeof(t)==="object"&&t.constructor===Object){n[e]=symbolize(t)}else{n[e]=toString(t)}});return n}return r}function get_props(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function has_own_function(e,t){return e.hasOwnProperty(t)&&is_function(e.toString)}function function_to_string(e){if(is_native_function(e)){return"#"}var t=e.prototype&&e.prototype.constructor;if(is_function(t)&&is_lambda(t)){if(e[__class__]&&t.hasOwnProperty("__name__")){var r=t.__name__;if(LString.isString(r)){r=r.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!is_lambda(e)){return"#")}else{return"#"}}var instances=new Map;[[Error,function(e){return e.message}],[Pair,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(_toConsumableArray(i)))}],[LCharacter,function(e,t){var r=t.quote;if(r){return e.toString()}return e.valueOf()}],[LString,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=_slicedToArray(e,2),r=t[0],n=t[1];instances.set(r,n)});var native_types=[LSymbol,LNumber,Macro,Values,InputPort,OutputPort,Environment,QuotedPromise];function toString(e,t,c){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(is_prototype(e)){return"#"}if(e){var r=e.constructor;if(instances.has(r)){for(var n=arguments.length,l=new Array(n>3?n-3:0),i=3;i"}if(e===null){return"null"}if(_typeof(e)==="object"){var o=e.constructor;if(!o){o=Object}var u;if(typeof o.__class__==="string"){u=o.__class__}else{var s=user_repr(e);if(s){if(is_function(s)){return s(e,t)}else{throw new Error("toString: Invalid repr value")}}u=o.name}if(is_function(e.toString)&&is_lambda(e.toString)){return e.toString().valueOf()}if(type(e)==="instance"){if(is_lambda(o)&&o.__name__){u=o.__name__.valueOf()}else if(!is_native_function(o)){u="instance"}}if(is_iterator(e,Symbol.iterator)){if(u){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(u){return"#")}return"#"}if(u!==""){return"#<"+u+">"}return"#"}if(typeof e!=="string"){return e.toString()}return e}function is_prototype(e){return e&&_typeof(e)==="object"&&e.hasOwnProperty&&e.hasOwnProperty("constructor")&&typeof e.constructor==="function"&&e.constructor.prototype===e}Pair.prototype.markCycles=function(){markCycles(this);return this};Pair.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[__cycles__]&&this[__cycles__][e])};function markCycles(e){var t=[];var i=[];var a=[];function o(e){if(!t.includes(e)){t.push(e)}}function u(e,t,r,n){if(r instanceof Pair){if(n.includes(r)){if(!a.includes(r)){a.push(r)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][t]=r;if(!i.includes(e)){i.push(e)}return true}}}var s=trampoline(function e(t,r){if(t instanceof Pair){delete t.ref;delete t[__cycles__];o(t);r.push(t);var n=u(t,"car",t.car,r);var i=u(t,"cdr",t.cdr,r);if(!n){s(t.car,r.slice())}if(!i){return new Thunk(function(){return e(t.cdr,r.slice())})}}});function r(e,t){if(e[__cycles__][t]instanceof Pair){var r=n.indexOf(e[__cycles__][t]);e[__cycles__][t]="#".concat(r,"#")}}s(e,[]);var n=t.filter(function(e){return a.includes(e)});n.forEach(function(e,t){e[__ref__]="#".concat(t,"=")});i.forEach(function(e){r(e,"car");r(e,"cdr")})}Pair.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[__ref__]){i.push(this[__ref__]+"(")}else if(!n){i.push("(")}var a;if(this[__cycles__]&&this[__cycles__].car){a=this[__cycles__].car}else{a=toString(this.car,e,true)}if(a!==undefined){i.push(a)}if(this.cdr instanceof Pair){if(this[__cycles__]&&this[__cycles__].cdr){i.push(" . ");i.push(this[__cycles__].cdr)}else{if(this.cdr[__ref__]){i.push(" . ")}else{i.push(" ")}var o=this.cdr.toString(e,{nested:true});i.push(o)}}else if(this.cdr!==_nil){i=i.concat([" . ",toString(this.cdr,e,true)])}if(!n||this[__ref__]){i.push(")")}return i.join("")};Pair.prototype.set=function(e,t){this[e]=t;if(t instanceof Pair){this.markCycles()}};Pair.prototype.append=function(e){if(e instanceof Array){return this.append(Pair.fromArray(e))}var t=this;if(t.car===undefined){if(e instanceof Pair){this.car=e.car;this.cdr=e.cdr}else{this.car=e}}else if(e!==_nil){while(true){if(t instanceof Pair&&t.cdr!==_nil){t=t.cdr}else{break}}t.cdr=e}return this};Pair.prototype.serialize=function(){return[this.car,this.cdr]};Pair.prototype[Symbol.iterator]=function(){var r=this;return{next:function e(){var t=r;r=t.cdr;if(t===_nil){return{value:undefined,done:true}}else{return{value:t.car,done:false}}}}};function abs(e){return e<0?-e:e}function seq_compare(e,t){var r=_toArray(t),n=r[0],i=r.slice(1);while(i.length>0){var a=i,o=_slicedToArray(a,1),u=o[0];if(!e(n,u)){return false}var s=i;var c=_toArray(s);n=c[0];i=c.slice(1)}return true}function equal(e,t){if(is_function(e)){return is_function(t)&&unbind(e)===unbind(t)}else if(e instanceof LNumber){if(!(t instanceof LNumber)){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 equal(LNumber(e),LNumber(t))}else if(e instanceof LCharacter){if(!(t instanceof LCharacter)){return false}return e.__char__===t.__char__}else{return e===t}}function same_atom(e,t){if(type(e)!==type(t)){return false}if(!is_atom(e)){return false}if(e instanceof RegExp){return e.source===t.source}if(e instanceof LString){return e.valueOf()===t.valueOf()}return equal(e,t)}function is_atom(e){return e instanceof LSymbol||LString.isString(e)||e===_nil||e===null||e instanceof LCharacter||e instanceof LNumber||e===true||e===false}var truncate=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 Macro(e,t,r,n){if(typeof this!=="undefined"&&this.constructor!==Macro||typeof this==="undefined"){return new Macro(e,t)}typecheck("Macro",e,"string",1);typecheck("Macro",t,"function",2);if(r){if(n){this.__doc__=r}else{this.__doc__=trim_lines(r)}}this.__name__=e;this.__fn__=t}Macro.defmacro=function(e,t,r,n){var i=new Macro(e,t,r,n);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,t,r){var n=t.env,i=_objectWithoutProperties(t,_excluded2);var a=_objectSpread(_objectSpread({},i),{},{macro_expand:r});var o=this.__fn__.call(n,e,a,this.__name__);return o};Macro.prototype.toString=function(){return"#")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(c){return function(){var r=_asyncToGenerator(_regeneratorRuntime.mark(function e(r,v){var a,g,n,i,s,D,x,E,L,A,S,b,o,w,u;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:u=function e(){u=_asyncToGenerator(_regeneratorRuntime.mark(function e(r,n,i){var _,a,o,p,u,h,s,d,c,m,l,f,y;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!(r instanceof Pair&&r.car instanceof LSymbol)){t.next=50;break}if(!r[__data__]){t.next=3;break}return t.abrupt("return",r);case 3:_=r.car.valueOf();a=i.get(r.car,{throwError:false});o=D(r.car);p=o||x(a,r)||E(a);if(!(p&&r.cdr.car instanceof Pair)){t.next=28;break}if(!o){t.next=15;break}g=A(r.cdr.car);t.next=12;return b(r.cdr.car,n);case 12:u=t.sent;t.next=17;break;case 15:g=L(r.cdr.car);u=r.cdr.car;case 17:t.t0=Pair;t.t1=r.car;t.t2=Pair;t.t3=u;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(!S(_,a)){t.next=50;break}h=a instanceof Syntax?r:r.cdr;t.next=32;return a.invoke(h,_objectSpread(_objectSpread({},v),{},{env:i}),true);case 32:s=t.sent;if(!(a instanceof Syntax)){t.next=41;break}d=s,c=d.expr,m=d.scope;if(!(c instanceof Pair)){t.next=40;break}if(!(n!==-1&&n<=1||n")}return"#"};Syntax.className="syntax";var SyntaxParameter=function(e){_inherits(r,e);var t=_createSuper(r);function r(){_classCallCheck(this,r);return t.apply(this,arguments)}return _createClass(r)}(Syntax);Syntax.Parameter=SyntaxParameter;function extract_patterns(e,t,w,D){var r=arguments.length>4&&arguments[4]!==undefined?arguments[4]:{};var x={"...":{symbols:{},lists:[]},symbols:{}};var E=r.expansion,S=r.define;function L(e){if(is_debug()){console.log(e)}}L(w);function A(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;L({code:t&&toString(t,true),pattern:e&&toString(e,true)});if(is_atom(e)&&!(e instanceof LSymbol)){return same_atom(e,t)}if(e instanceof LSymbol&&w.includes(e.literal())){var c=E.ref(t);if(LSymbol.is(t,e)){if(typeof c==="undefined"){return true}return c===S||c===global_env}return false}if(e instanceof Pair&&e.car instanceof Pair&&e.car.cdr instanceof Pair&&LSymbol.is(e.car.cdr.car,D)){L(">> 0");if(t===_nil){L({pattern:e.toString()});if(e.car.car instanceof LSymbol){if(e.car.cdr instanceof Pair&&LSymbol.is(e.car.cdr.car,D)){var l=e.car.car.valueOf();var f=e.last_pair();if(LSymbol.is(f.car,D)){x["..."].symbols[l]=null;return true}else{return false}}var _=e.car.car.valueOf();if(x["..."].symbols[_]){throw new Error("syntax: named ellipsis can only "+"appear onces")}x["..."].symbols[_]=t}}}if(e instanceof Pair&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,D)){if(e.cdr.cdr!==_nil){if(e.cdr.cdr instanceof Pair){var p=e.cdr.cdr.length();var h=t.length();var i=t;while(h-1>p){i=i.cdr;h--}var d=i.cdr;i.cdr=_nil;if(!A(e.cdr.cdr,d,r,n)){return false}}}if(e.car instanceof LSymbol){var a=e.car.__name__;if(x["..."].symbols[a]&&!r.includes(a)&&!n){throw new Error("syntax: named ellipsis can only appear onces")}L(">> 1");if(t===_nil){L(">> 2");if(n){L("NIL");x["..."].symbols[a]=_nil}else{L("NULL");x["..."].symbols[a]=null}}else if(t instanceof Pair&&(t.car instanceof Pair||t.car===_nil)){L(">> 3 "+n);if(n){if(x["..."].symbols[a]){var o=x["..."].symbols[a];if(o===_nil){o=new Pair(_nil,new Pair(t,_nil))}else{o=o.append(new Pair(t,_nil))}x["..."].symbols[a]=o}else{x["..."].symbols[a]=new Pair(t,_nil)}}else{L(">> 4");x["..."].symbols[a]=new Pair(t,_nil)}}else{L(">> 6");if(t instanceof Pair){L(">> 7 "+n);r.push(a);if(!x["..."].symbols[a]){x["..."].symbols[a]=new Pair(t,_nil)}else{var m=x["..."].symbols[a];x["..."].symbols[a]=m.append(new Pair(t,_nil))}L({IIIIII:x["..."].symbols[a].toString()})}else{L(">> 8");return false}}return true}else if(e.car instanceof Pair){var y=_toConsumableArray(r);if(t===_nil){L(">> 9");x["..."].lists.push(_nil);return true}L(">> 10");var v=t;while(v instanceof Pair){if(!A(e.car,v.car,y,true)){return false}v=v.cdr}return true}return false}if(e instanceof LSymbol){if(LSymbol.is(e,D)){throw new Error("syntax: invalid usage of ellipsis")}L(">> 11");var u=e.__name__;if(w.includes(u)){return true}L({name:u,ellipsis:n});if(n){x["..."].symbols[u]=x["..."].symbols[u]||[];x["..."].symbols[u].push(t)}x.symbols[u]=t;if(!x.symbols[u]);return true}if(e instanceof Pair&&t instanceof Pair){L(">> 12");L({a:12,code:t&&t.toString(),pattern:e.toString()});if(t.cdr===_nil){var g=e.car instanceof LSymbol&&e.cdr instanceof LSymbol;if(g){if(!A(e.car,t.car,r,n)){return false}L(">> 12 | 1");var s=e.cdr.valueOf();if(!(s in x.symbols)){x.symbols[s]=_nil}s=e.car.valueOf();if(!(s in x.symbols)){x.symbols[s]=t.car}return true}}L({pattern:e.toString(),code:t.toString()});if(e.cdr instanceof Pair&&e.car instanceof LSymbol&&e.cdr.cdr instanceof Pair&&e.cdr.car instanceof LSymbol&&LSymbol.is(e.cdr.cdr.car,D)&&e.cdr.cdr.cdr instanceof Pair&&!LSymbol.is(e.cdr.cdr.cdr.car,D)&&A(e.car,t.car,r,n)&&A(e.cdr.cdr.cdr,t.cdr,r,n)){var b=e.cdr.car.__name__;L({pattern:e.car.toString(),code:t.car.toString(),name:b});if(w.includes(b)){return true}x["..."].symbols[b]=null;return true}L("recur");if(A(e.car,t.car,r,n)&&A(e.cdr,t.cdr,r,n)){return true}}else if(e===_nil&&(t===_nil||t===undefined)){return true}else if(e.car instanceof Pair&&LSymbol.is(e.car.car,D)){throw new Error("syntax: invalid usage of ellipsis")}else{return false}}if(A(e,t)){return x}}function clear_gensyms(e,i){function a(t){if(t instanceof Pair){if(!i.length){return t}var e=a(t.car);var r=a(t.cdr);return new Pair(e,r)}else if(t instanceof LSymbol){var n=i.find(function(e){return e.gensym===t});if(n){return LSymbol(n.name)}return t}else{return t}}return a(e)}function transform_syntax(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var F=e.bindings,t=e.expr,P=e.scope,o=e.symbols,l=e.names,C=e.ellipsis;var c={};function u(e){if(e instanceof LSymbol){return true}return["string","symbol"].includes(_typeof(e))}function B(e){if(!u(e)){var t=type(e);throw new Error("syntax: internal error, need symbol got ".concat(t))}var r=e.valueOf();if(r===C){throw new Error("syntax: internal error, ellipis not transformed")}var n=_typeof(r);if(["string","symbol"].includes(n)){if(r in F.symbols){return F.symbols[r]}else if(n==="string"&&r.match(/\./)){var i=r.split(".");var a=i[0];if(a in F.symbols){return Pair.fromArray([LSymbol("."),F.symbols[a]].concat(i.slice(1).map(function(e){return LString(e)})))}}}if(o.includes(r)){return LSymbol(r)}return s(r)}function O(e){if(is_debug()){console.log(e)}}function s(e){if(!c[e]){var t=P.ref(e);var r=gensym(e);if(t){var n=P.get(e);P.set(r,n)}else{var i=P.get(e,{throwError:false});if(typeof i!=="undefined"){P.set(r,i)}}l.push({name:e,gensym:r});c[e]=r;if(typeof e==="string"&&e.match(/\./)){var a=e.split(".").filter(Boolean),o=_toArray(a),u=o[0],s=o.slice(1);if(c[u]){hidden_prop(r,"__object__",[c[u]].concat(_toConsumableArray(s)))}}}return c[e]}function I(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:function(){};var i=r.nested;O(" ==> "+e.toString(true));O(t);if(e instanceof LSymbol){var a=e.valueOf();O("[t 1");if(t[a]){if(t[a]instanceof Pair){var c=t[a],l=c.car,f=c.cdr;if(i){var _=l.car,p=l.cdr;if(p!==_nil){n(a,new Pair(p,_nil))}return _}if(f!==_nil){n(a,f)}return l}else if(t[a]instanceof Array){n(a,t[a].slice(1));return t[a][0]}}return B(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,C)){O("[t 2");var o=e.car.valueOf();var u=t[o];O({expr:e.toString(true),name:o,bindings:t,item:u});if(u===null){return}else if(u){O({b:t[o].toString()});if(u instanceof Pair){O("[t 2 Pair "+i);O({______:u.toString()});var s=u.car,h=u.cdr;if(i){if(h!==_nil){O("|| next 1");n(o,h)}O({car:s.toString()});return s}else{if(s.cdr!==_nil){O("|| next 2");n(o,new Pair(s.cdr,h))}O({car:s.car.toString()});return s.car}}else if(u instanceof Array){O("[t 2 Array "+i);if(i){n(o,u.slice(1));return Pair.fromArray(u)}else{var d=u.slice(1);if(d.length){n(o,d)}return u[0]}}else{return u}}}O("[t 3 recur "+e.toString());var m=I(e.car,t,r,n);var y=I(e.cdr,t,r,n);return new Pair(m,y)}return e}function j(t,r){var e=Object.values(t);var n=Object.getOwnPropertySymbols(t);if(n.length){e.push.apply(e,_toConsumableArray(n.map(function(e){return t[e]})))}return e.length&&e.every(function(e){if(e===null){return!r}return e instanceof Pair||e===_nil||e instanceof Array&&e.length})}function R(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;O("traverse>> "+toString(i));if(i instanceof Pair){if(!e&&i.car instanceof Pair&&LSymbol.is(i.car.car,C)){return N(i.car.cdr,{disabled:true})}if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,C)&&!e){O(">> 1");var t=F["..."].symbols;var l=Object.values(t);if(l.length&&l.every(function(e){return e===null})){return N(i.cdr.cdr,{disabled:e})}var f=R(t);var a=i.car instanceof LSymbol&&LSymbol.is(i.cdr.cdr.car,C);if(i.car instanceof Pair||a){if(F["..."].lists[0]===_nil){return _nil}var _=i.car;if(a){_=new Pair(i.car,new Pair(i.cdr.car,_nil))}O(">> 2");var o;if(f.length){O(">> 2 (a)");var u=_objectSpread({},t);o=_nil;var p=function e(){if(!j(u)){return"break"}var n={};var t=function e(t,r){n[t]=r};var r=I(_,u,{nested:true},t);if(r!==undefined){if(a){if(o===_nil){o=r}else{o=o.append(r)}}else{o=new Pair(r,o)}}u=n};while(true){var h=p();if(h==="break")break}if(o!==_nil&&!a){o=o.reverse()}if(i.cdr.cdr!==_nil&&!LSymbol.is(i.cdr.cdr.car,C)){var d=N(i.cdr.cdr,{disabled:e});return o.append(d)}return o}else{O(">> 3");var m=I(i.car,t,{nested:true});if(m){return new Pair(m,_nil)}return _nil}}else if(i.car instanceof LSymbol){O(">> 4");if(LSymbol.is(i.cdr.cdr.car,C)){O(">> 4 (a)")}else{O(">> 4 (b)")}var y=i.car.__name__;var s=_defineProperty({},y,t[y]);var v=t[y]===null;var c=_nil;var g=function e(){if(!j(s,true)){O({bind:s});return"break"}var n={};var t=function e(t,r){n[t]=r};var r=I(i,s,{nested:false},t);O({value:r.toString()});if(typeof r!=="undefined"){c=new Pair(r,c)}s=n};while(true){var b=g();if(b==="break")break}if(c!==_nil){c=c.reverse()}if(i.cdr instanceof Pair){if(i.cdr.cdr instanceof Pair||i.cdr.cdr instanceof LSymbol){var w=N(i.cdr.cdr,{disabled:e});if(v){return w}O("<<<< 1");c.append(w)}}O("<<<< 2");return c}}var D=N(i.car,{disabled:e});var r;var x;if(i.car instanceof LSymbol){var E=P.get(i.car,{throwError:false});x=E instanceof Macro&&E.__name__==="syntax-rules"}if(x){if(i.cdr.car instanceof LSymbol){r=new Pair(N(i.cdr.car,{disabled:e}),new Pair(i.cdr.cdr.car,N(i.cdr.cdr.cdr,{disabled:e})))}else{r=new Pair(i.cdr.car,N(i.cdr.cdr,{disabled:e}))}O("REST >>>> "+r.toString())}else{r=N(i.cdr,{disabled:e})}O({a:true,car:toString(i.car),cdr:toString(i.cdr),head:toString(D),rest:toString(r)});return new Pair(D,r)}if(i instanceof LSymbol){if(e&&LSymbol.is(i,C)){return i}var L=Object.keys(F["..."].symbols);var A=i.literal();if(L.includes(A)){var S="missing ellipsis symbol next to name `".concat(A,"'");throw new Error("syntax-rules: ".concat(S))}var k=B(i);if(typeof k!=="undefined"){return k}}return i}return N(t,{})}function is_null(e){return is_undef(e)||e===_nil||e===null}function is_function(e){return typeof e==="function"&&typeof e.bind==="function"}function is_continuation(e){return e instanceof Continuation}function is_context(e){return e instanceof LambdaContext}function is_parameter(e){return e instanceof Parameter}function is_pair(e){return e instanceof Pair}function is_env(e){return e instanceof Environment}function is_callable(e){return is_function(e)||is_continuation(e)||is_parameter(e)}function is_promise(e){if(e instanceof QuotedPromise){return false}if(e instanceof Promise){return true}return e&&is_function(e.then)}function is_undef(e){return typeof e==="undefined"}function box(e){switch(_typeof(e)){case"string":return LString(e);case"bigint":return LNumber(e);case"number":if(Number.isNaN(e)){return nan}else{return LNumber(e)}}return e}function map_object(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 unbox(t){var e=[LString,LNumber].some(function(e){return t instanceof e});if(e){return t.valueOf()}if(t instanceof Array){return t.map(unbox)}if(t instanceof QuotedPromise){delete t.then}if(is_plain_object(t)){return map_object(t,unbox)}return t}function patch_value(e,t){if(e instanceof Pair){e.markCycles();return quote(e)}if(is_function(e)){if(t){return bind(e,t)}}return box(e)}function unbind(e){if(is_bound(e)){return e[__fn__]}return e}function bind(e,t){if(e[Symbol["for"]("__bound__")]){return e}var r=e.bind(t);var n=Object.getOwnPropertyNames(e);var i=_createForOfIteratorHelper(n),a;try{for(i.s();!(a=i.n()).done;){var o=a.value;if(filter_fn_names(o)){try{r[o]=e[o]}catch(e){}}}}catch(e){i.e(e)}finally{i.f()}hidden_prop(r,"__fn__",e);hidden_prop(r,"__context__",t);hidden_prop(r,"__bound__",true);if(is_native_function(e)){hidden_prop(r,"__native__",true)}if(is_plain_object(t)&&is_lambda(e)){hidden_prop(r,"__method__",true)}r.valueOf=function(){return e};return r}function is_object_bound(e){return is_bound(e)&&e[Symbol["for"]("__context__")]===Object}function is_bound(e){return!!(is_function(e)&&e[__fn__])}function lips_context(e){if(is_function(e)){var t=e[__context__];if(t&&(t===lips||t.constructor&&t.constructor.__class__)){return true}}return false}function is_port(e){return e instanceof InputPort||e instanceof OutputPort}function is_port_method(e){if(is_function(e)){if(is_port(e[__context__])){return true}}return false}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 exluded_names=["name","length","caller","callee","arguments","prototype"];function filter_fn_names(e){return!exluded_names.includes(e)}function hidden_prop(e,t,r){Object.defineProperty(e,Symbol["for"](t),{get:function e(){return r},set:function e(){},configurable:false,enumerable:false})}function set_fn_length(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 is_lambda(e){return e&&e[__lambda__]}function is_method(e){return e&&e[__method__]}function is_raw_lambda(e){return is_lambda(e)&&!e[__prototype__]&&!is_method(e)&&!is_port_method(e)}function is_native_function(e){var t=Symbol["for"]("__native__");return is_function(e)&&e.toString().match(/\{\s*\[native code\]\s*\}/)&&(e.name.match(/^bound /)&&e[t]===true||!e.name.match(/^bound /)&&!e[t])}function let_macro(e){var b;switch(e){case Symbol["for"]("letrec"):b="letrec";break;case Symbol["for"]("let"):b="let";break;case Symbol["for"]("let*"):b="let*";break;default:throw new Error("Invalid let_macro value")}return Macro.defmacro(b,function(t,e){var l=e.dynamic_env;var f=e.error,n=e.macro_expand,y=e.use_dynamic;var _;if(t.car instanceof LSymbol){if(!(t.cdr.car instanceof Pair||t.cdr.car===_nil)){throw new Error("let require list of pairs")}var r;if(t.cdr.car===_nil){_=_nil;r=_nil}else{r=t.cdr.car.map(function(e){return e.car});_=t.cdr.car.map(function(e){return e.cdr.car})}return Pair.fromArray([LSymbol("letrec"),[[t.car,Pair(LSymbol("lambda"),Pair(r,t.cdr.cdr))]],Pair(t.car,_)])}else if(n){return}var p=this;_=global_env.get("list->array")(t.car);var h=p.inherit(b);var d,m;if(b==="let*"){m=h}else if(b==="let"){d=[]}var v=0;function g(){var e=new Pair(new LSymbol("begin"),t.cdr);return _evaluate(e,{env:h,dynamic_env:h,use_dynamic:y,error:f})}return function t(){var r=_[v++];l=b==="let*"?h:p;if(!r){if(d&&d.length){var e=d.map(function(e){return e.value});var n=e.filter(is_promise);if(n.length){return promise_all(e).then(function(e){for(var t=0,r=e.length;t1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=t.error;var i=this;var a=this;var o=[];var u=e;while(u instanceof Pair){o.push(_evaluate(u.car,{env:i,dynamic_env:a,use_dynamic:r,error:n}));u=u.cdr}var s=o.filter(is_promise).length;if(s){return promise_all(o).then(c.bind(this))}else{return c.call(this,o)}})}function guard_math_call(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n2?n-2:0),a=2;a1&&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=o){return a.apply(this,n)}else{return i}}return i.apply(this,arguments)}}function limit(n,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,t=new Array(e),r=0;r1){e=e.toLowerCase();if(LCharacter.__names__[e]){t=e;e=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{t=LCharacter.__rev_names__[e]}Object.defineProperty(this,"__char__",{value:e,enumerable:true});if(t){Object.defineProperty(this,"__name__",{value:t,enumerable:true})}}LCharacter.__names__=characters;LCharacter.__rev_names__={};Object.keys(LCharacter.__names__).forEach(function(e){var t=LCharacter.__names__[e];LCharacter.__rev_names__[t]=e});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__};function LString(e){if(typeof this!=="undefined"&&!(this instanceof LString)||typeof this==="undefined"){return new LString(e)}if(e instanceof Array){this.__string__=e.map(function(e,t){typecheck("LString",e,"character",t+1);return e.toString()}).join("")}else{this.__string__=e.valueOf()}}{var ignore=["length","constructor"];var _keys=Object.getOwnPropertyNames(String.prototype).filter(function(e){return!ignore.includes(e)});var wrap=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 LNumber){return e}if(typeof this!=="undefined"&&!(this instanceof LNumber)||typeof this==="undefined"){return new LNumber(e,t)}if(typeof e==="undefined"){throw new Error("Invalid LNumber constructor call")}var r=LNumber.getType(e);if(LNumber.types[r]){return LNumber.types[r](e,t)}var n=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!n){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(n){var c=e,a=_slicedToArray(c,2),o=a[0],u=a[1];if(o instanceof LString){o=o.valueOf()}if(u instanceof LNumber){u=u.valueOf()}var l=o.match(/^([+-])/);var f=false;if(l){o=o.replace(/^[+-]/,"");if(l[1]==="-"){f=true}}}if(Number.isNaN(e)){return LFloat(e)}else if(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(n){var s;switch(u){case 8:s="0o";break;case 16:s="0x";break;case 2:s="0b";break;case 10:s="";break}if(typeof s==="undefined"){var _=BigInt(u);i=_toConsumableArray(o).map(function(e,t){return BigInt(parseInt(e,u))*pow(_,BigInt(t))}).reduce(function(e,t){return e+t})}else{i=BigInt(s+o)}}else{i=BigInt(e)}if(f){i*=BigInt(-1)}}else{i=e}return LBigInteger(i,true)}else if(typeof BN!=="undefined"&&!(e instanceof BN)){if(e instanceof Array){return LBigInteger(_construct(BN,_toConsumableArray(e)))}return LBigInteger(new BN(e))}else if(n){this.constant(parseInt(o,u),"integer")}else{this.constant(e,"integer")}}LNumber.prototype.constant=function(e,t){Object.defineProperty(this,"__value__",{value:e,enumerable:true});Object.defineProperty(this,"__type__",{value:t,enumerable:true})};LNumber.types={float:function e(t){return new LFloat(t)},complex:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!LNumber.isComplex(t)){t={im:0,re:t}}return new LComplex(t,r)},rational:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!LNumber.isRational(t)){t={num:t,denom:1}}return new LRational(t,r)}};LNumber.prototype.serialize=function(){return this.__value__};LNumber.prototype.isNaN=function(){return Number.isNaN(this.__value__)};LNumber.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}}};LNumber.isFloat=function e(t){return t instanceof LFloat||Number(t)===t&&t%1!==0};LNumber.isNumber=function(e){return e instanceof LNumber||LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){if(!e){return false}var t=e instanceof LComplex||(LNumber.isNumber(e.im)||Number.isNaN(e.im))&&(LNumber.isNumber(e.re)||Number.isNaN(e.re));return t};LNumber.isRational=function(e){if(!e){return false}return e instanceof LRational||LNumber.isNumber(e.num)&&LNumber.isNumber(e.denom)};LNumber.isInteger=function(e){if(!(LNumber.isNative(e)||e instanceof LNumber)){return false}if(LNumber.isFloat(e)){return false}if(LNumber.isRational(e)){return false}if(LNumber.isComplex(e)){return false}return true};LNumber.isNative=function(e){return typeof e==="bigint"||typeof e==="number"};LNumber.isBigInteger=function(e){return e instanceof LBigInteger||typeof e==="bigint"||LNumber.isBN(e)};LNumber.isBN=function(e){return typeof BN!=="undefined"&&e instanceof BN};LNumber.getArgsType=function(e,t){if(e instanceof LFloat||t instanceof LFloat){return LFloat}if(e instanceof LBigInteger||t instanceof LBigInteger){return LBigInteger}return LNumber};LNumber.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()};LNumber.prototype.asType=function(e){var t=LNumber.getType(this);return LNumber.types[t]?LNumber.types[t](e):LNumber(e)};LNumber.prototype.isBigNumber=function(){return typeof this.__value__==="bigint"||typeof BN!=="undefined"&&!(this.value instanceof BN)};["floor","ceil","round"].forEach(function(e){LNumber.prototype[e]=function(){if(this["float"]||LNumber.isFloat(this.__value__)){return LNumber(Math[e](this.__value__))}else{return LNumber(Math[e](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()}};var matrix=function(){var e=function e(t,r){return[t,r]};return{bigint:{bigint:e,float:function e(t,r){return[LFloat(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[LFloat(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&&LFloat(r.valueOf())]},integer:function e(t,r){return[t,r&&LFloat(r.valueOf())]},float:e,rational:function e(t,r){return[t,r&&LFloat(r.valueOf())]},complex:function e(t,r){return[{re:t,im:LFloat(0)},r]}},complex:{bigint:t("bigint"),integer:t("integer"),float:t("float"),rational:t("rational"),complex:function l(e,t){var r=LNumber.coerce(e.__re__,t.__re__),n=_slicedToArray(r,2),i=n[0],a=n[1];var o=LNumber.coerce(e.__im__,t.__im__),u=_slicedToArray(o,2),s=u[0],c=u[1];return[{im:s,re:i},{im:c,re:a}]}},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[LFloat(t.valueOf()),r]},rational:e,complex:function e(t,r){return[{im:coerce(t.__type__,r.__im__.__type__,0)[0],re:coerce(t.__type__,r.__re__.__type__,t)[0]},{im:coerce(t.__type__,r.__im__.__type__,r.__im__)[0],re:coerce(t.__type__,r.__re__.__type__,r.__re__)[0]}]}}};function t(r){return function(e,t){return[{im:coerce(r,e.__im__.__type__,0,e.__im__)[1],re:coerce(r,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(r,e.__im__.__type__,0,0)[1],re:coerce(r,t.__type__,0,t)[1]}]}}}();function coerce(e,t,r,n){return matrix[e][t](r,n)}LNumber.coerce=function(e,t){var r=LNumber.getType(e);var n=LNumber.getType(t);if(!matrix[r]){throw new Error("LNumber::coerce unknown lhs type ".concat(r))}else if(!matrix[r][n]){throw new Error("LNumber::coerce unknown rhs type ".concat(n))}var i=matrix[r][n](e,t);return i.map(function(e){return LNumber(e,true)})};LNumber.prototype.coerce=function(e){if(!(typeof e==="number"||e instanceof LNumber)){throw new Error("LNumber: you can't coerce ".concat(type(e)))}if(typeof e==="number"){e=LNumber(e)}return LNumber.coerce(this,e)};LNumber.getType=function(e){if(e instanceof LNumber){return e.__type__}if(LNumber.isFloat(e)){return"float"}if(LNumber.isComplex(e)){return"complex"}if(LNumber.isRational(e)){return"rational"}if(typeof e==="number"){return"integer"}if(typeof BigInt!=="undefined"&&typeof e!=="bigint"||typeof BN!=="undefined"&&!(e instanceof BN)){return"bigint"}};LNumber.prototype.isFloat=function(){return!!(LNumber.isFloat(this.__value__)||this["float"])};var mapping={add:"+",sub:"-",mul:"*",div:"/",rem:"%",or:"|",and:"&",neg:"~",shl:">>",shr:"<<"};var rev_mapping={};Object.keys(mapping).forEach(function(t){rev_mapping[mapping[t]]=t;LNumber.prototype[t]=function(e){return this.op(mapping[t],e)}});LNumber._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 LComplex)||typeof this==="undefined"){return new LComplex(e,t)}if(e instanceof LComplex){return LComplex({im:e.__im__,re:e.__re__})}if(LNumber.isNumber(e)&&t){if(!t){return Number(e)}}else if(!LNumber.isComplex(e)){var r="Invalid constructor call for LComplex expect &(:im :re ) object but got ".concat(toString(e));throw new Error(r)}var n=e.im instanceof LNumber?e.im:LNumber(e.im);var i=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,i)}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.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})};LComplex.prototype.serialize=function(){return{re:this.__re__,im:this.__im__}};LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var t=LFloat(this.__im__).toRational(e);var r=LFloat(this.__re__).toRational(e);return LComplex({im:t,re:r})}return this};LComplex.prototype.pow=function(e){throw new Error("Not yet implemented")};LComplex.prototype.add=function(e){return this.complex_op("add",e,function(e,t,r,n){return{re:e.add(t),im:r.add(n)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,t=this.__im__;var r,n;if(e instanceof LFloat){r=e.toRational().mul(e.toRational())}else{r=e.mul(e)}if(t instanceof LFloat){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__))}};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 e=this.modulus();var t,r;if(e.cmp(0)===0){t=r=e}else if(this.__re__.cmp(0)===1){t=LFloat(.5).mul(e.add(this.__re__)).sqrt();r=this.__im__.div(t).div(2)}else{r=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){r=r.sub()}t=this.__im__.div(r).div(2)}return LComplex({im:r,re:t})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var t=this.__re__.div(e);var r=this.__im__.div(e);return LComplex({re:t,im:r})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}if(this.cmp(e)===0){var n=this.coerce(e),i=_slicedToArray(n,2),l=i[0],a=i[1];var f=l.__im__.div(a.__im__);return f.coerce(a.__re__)[0]}var _=this.coerce(e),o=_slicedToArray(_,2),p=o[0],u=o[1];var s=u.factor();var h=u.conjugate();var c=p.mul(h);if(!LNumber.isComplex(c)){return c.div(s)}var d=c.__re__.op("/",s);var m=c.__im__.op("/",s);return LComplex({re:d,im:m})};LComplex.prototype.sub=function(e){return this.complex_op("sub",e,function(e,t,r,n){return{re:e.sub(t),im:r.sub(n)}})};LComplex.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})};LComplex.prototype.complex_op=function(e,t,i){var a=this;var r=function e(t,r){var n=i(a.__re__,t,a.__im__,r);if("im"in n&&"re"in n){if(n.im.cmp(0)===0){return n.re}return LComplex(n,true)}return n};if(typeof t==="undefined"){return r()}if(LNumber.isNumber(t)&&!LNumber.isComplex(t)){if(!(t instanceof LNumber)){t=LNumber(t)}var n=t.asType(0);t={__im__:n,__re__:t}}else if(!LNumber.isComplex(t)){throw new Error("[LComplex::".concat(e,"] Invalid value"))}var o=t.__re__ instanceof LNumber?t.__re__:this.__re__.asType(t.__re__);var u=t.__im__ instanceof LNumber?t.__im__:this.__im__.asType(t.__im__);return r(o,u)};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,t){var r=LComplex._op[e];return this[r](t)};LComplex.prototype.cmp=function(e){var t=this.coerce(e),r=_slicedToArray(t,2),n=r[0],i=r[1];var a=n.__re__.coerce(i.__re__),o=_slicedToArray(a,2),u=o[0],l=o[1];var s=u.cmp(l);if(s!==0){return s}else{var f=n.__im__.coerce(i.__im__),c=_slicedToArray(f,2),_=c[0],p=c[1];return _.cmp(p)}};LComplex.prototype.valueOf=function(){return[this.__re__,this.__im__].map(function(e){return e.valueOf()})};LComplex.prototype.toString=function(){var e;if(this.__re__.cmp(0)!==0){e=[toString(this.__re__)]}else{e=[]}var t=this.__im__.valueOf();var r=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(t);var n=toString(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 LFloat(e){if(typeof this!=="undefined"&&!(this instanceof LFloat)||typeof this==="undefined"){return new LFloat(e)}if(!LNumber.isNumber(e)){throw new Error("Invalid constructor call for LFloat")}if(e instanceof LNumber){return LFloat(e.valueOf())}if(typeof e==="number"){if(Object.is(e,-0)){Object.defineProperty(this,"_minus",{value:true})}this.constant(e,"float")}}LFloat.prototype=Object.create(LNumber.prototype);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 e=this.__value__.toString();if(!LNumber.isFloat(this.__value__)&&!e.match(/e/i)){var t=e+".0";return this._minus?"-"+t:t}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,t){if(t instanceof LNumber){t=t.__value__}var r=LNumber._ops[e];if(e==="/"&&this.__value__===0&&t===0){return NaN}return LFloat(r(this.__value__,t))};LFloat.prototype.toRational=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){return toRational(this.__value__.valueOf())}return approxRatio(e.valueOf())(this.__value__.valueOf())};LFloat.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){var t=LFloat(Math.sqrt(-e));return LComplex({re:0,im:t})}return LFloat(Math.sqrt(e))};LFloat.prototype.abs=function(){var e=this.valueOf();if(e<0){e=-e}return LFloat(e)};var toRational=approxRatio(1e-10);function approxRatio(n){return function(e){var t=function e(n,t,r){var i=function e(t,r){return r0){i=simplest_rational2(n,r)}else if(n.cmp(r)<=0){i=r}else if(r.cmp(0)>0){i=simplest_rational2(r,n)}else if(t.cmp(0)<0){i=LNumber(simplest_rational2(n.sub(),r.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(t)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,t){var r=LNumber(e).floor();var n=LNumber(t).floor();if(e.cmp(r)<1){return r}else if(r.cmp(n)===0){var i=LNumber(1).div(t.sub(n));var a=LNumber(1).div(e.sub(r));return r.add(LNumber(1).div(simplest_rational2(i,a)))}else{return r.add(LNumber(1))}}function LRational(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof LRational)||typeof this==="undefined"){return new LRational(e,t)}if(!LNumber.isRational(e)){throw new Error("Invalid constructor call for LRational")}var r,n;if(e instanceof LRational){r=LNumber(e.__num__);n=LNumber(e.__denom__)}else{r=LNumber(e.num);n=LNumber(e.denom)}if(!t&&n.cmp(0)!==0){var i=r.op("%",n).cmp(0)===0;if(i){return LNumber(r.div(n))}}this.constant(r,n)}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.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})};LRational.prototype.serialize=function(){return{num:this.__num__,denom:this.__denom__}};LRational.prototype.pow=function(e){var t=e.cmp(0);if(t===0){return LNumber(1)}if(t===-1){e=e.sub();var r=this.__denom__.pow(e);var n=this.__num__.pow(e);return LRational({num:r,denom:n})}var i=this;e=e.valueOf();while(e>1){i=i.mul(this);e--}return i};LRational.prototype.sqrt=function(){var e=this.__num__.sqrt();var t=this.__denom__.sqrt();if(e instanceof LFloat||t instanceof LFloat){return e.div(t)}return LRational({num:e,denom:t})};LRational.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 LRational({num:e,denom:t})};LRational.prototype.cmp=function(e){return LNumber(this.valueOf(),true).cmp(e)};LRational.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 LRational){t=LNumber(t.valueOf(true))}r=this.__denom__.div(e);if(r instanceof LRational){r=LNumber(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()};LRational.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 LNumber._ops["/"](this.__num__.value,this.__denom__.value)}return LFloat(this.__num__.valueOf()).div(this.__denom__.valueOf())};LRational.prototype.mul=function(e){if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var t=this.__num__.mul(e.__num__);var r=this.__denom__.mul(e.__denom__);return LRational({num:t,denom:r})}var n=LNumber.coerce(this,e),i=_slicedToArray(n,2),a=i[0],o=i[1];return a.mul(o)};LRational.prototype.div=function(e){if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var t=this.__num__.mul(e.__denom__);var r=this.__denom__.mul(e.__num__);return LRational({num:t,denom:r})}var n=LNumber.coerce(this,e),i=_slicedToArray(n,2),a=i[0],o=i[1];var u=a.div(o);return u};LRational.prototype._op=function(e,t){return this[rev_mapping[e]](t)};LRational.prototype.sub=function(e){if(typeof e==="undefined"){return this.mul(-1)}if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var t=e.__num__.sub();var r=e.__denom__;return this.add(LRational({num:t,denom:r}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var n=LNumber.coerce(this,e),i=_slicedToArray(n,2),a=i[0],o=i[1];return a.add(o)};LRational.prototype.add=function(e){if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var t=this.__denom__;var r=e.__denom__;var n=this.__num__;var i=e.__num__;var a,o;if(t!==r){o=r.mul(n).add(i.mul(t));a=t.mul(r)}else{o=n.add(i);a=t}return LRational({num:o,denom:a})}if(LNumber.isFloat(e)){return LFloat(this.valueOf()).add(e)}var u=LNumber.coerce(this,e),s=_slicedToArray(u,2),c=s[0],l=s[1];return c.add(l)};function LBigInteger(e,t){if(typeof this!=="undefined"&&!(this instanceof LBigInteger)||typeof this==="undefined"){return new LBigInteger(e,t)}if(e instanceof LBigInteger){return LBigInteger(e.__value__,e._native)}if(!LNumber.isBigInteger(e)){throw new Error("Invalid constructor call for LBigInteger")}this.constant(e,"bigint");Object.defineProperty(this,"_native",{value:t})}LBigInteger.prototype=Object.create(LNumber.prototype);LBigInteger.prototype.constructor=LBigInteger;LBigInteger.bn_op={"+":"iadd","-":"isub","*":"imul","/":"idiv","%":"imod","|":"ior","&":"iand","~":"inot","<<":"ishrn",">>":"ishln"};LBigInteger.prototype.serialize=function(){return this.__value__.toString()};LBigInteger.prototype._op=function(e,t){if(typeof t==="undefined"){if(LNumber.isBN(this.__value__)){e=LBigInteger.bn_op[e];return LBigInteger(this.__value__.clone()[e](),false)}return LBigInteger(LNumber._ops[e](this.__value__),true)}if(LNumber.isBN(this.__value__)&&LNumber.isBN(t.__value__)){e=LBigInteger.bn_op[e];return LBigInteger(this.__value__.clone()[e](t),false)}var r=LNumber._ops[e](this.__value__,t.__value__);if(e==="/"){var n=this.op("%",t).cmp(0)===0;if(n){return LNumber(r)}return LRational({num:this,denom:t})}return LBigInteger(r,true)};LBigInteger.prototype.sqrt=function(){var e;var t=this.cmp(0)<0;if(LNumber.isNative(this.__value__)){e=LNumber(Math.sqrt(t?-this.valueOf():this.valueOf()))}else if(LNumber.isBN(this.__value__)){e=t?this.__value__.neg().sqrt():this.__value__.sqrt()}if(t){return LComplex({re:0,im:e})}return e};LNumber.NaN=LNumber(NaN);function InputPort(e){var n=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");read_only(this,"__type__",text_port);var i;Object.defineProperty(this,"__parser__",{enumerable:true,get:function e(){return i},set:function e(t){typecheck("InputPort::__parser__",t,"parser");i=t}});this._read=e;this._with_parser=this._with_init_parser.bind(this,_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.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 Parser(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()!==eof};this._make_defaults()}InputPort.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(!LNumber.isInteger(t)){var r=LNumber.getType(t);typeErrorMessage("read-string",r,"integer")}return e.__lexer__.read_string(t.valueOf())});this.peek_char=this._with_parser(function(e){return e.__lexer__.peek_char()})};InputPort.prototype._with_init_parser=function(u,s){var c=this;return _asyncToGenerator(_regeneratorRuntime.mark(function e(){var r,n,i,a,o=arguments;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:t.next=2;return u.call(c);case 2:r=t.sent;for(n=o.length,i=new Array(n),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");read_only(this,"__type__",text_port);this.write=e}OutputPort.prototype.is_open=function(){return this._closed!==true};OutputPort.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")}};OutputPort.prototype.flush=function(){};OutputPort.prototype.toString=function(){return"#"};var BufferedOutputPort=function(e){_inherits(n,e);var r=_createSuper(n);function n(e){var t;_classCallCheck(this,n);t=r.call(this,function(){var e;return(e=t)._write.apply(e,arguments)});typecheck("BufferedOutputPort",e,"function");read_only(_assertThisInitialized(t),"_fn",e,{hidden:true});read_only(_assertThisInitialized(t),"_buffer",[],{hidden:true});return t}_createClass(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"};OutputStringPort.prototype.valueOf=function(){return this.__buffer__.map(function(e){return e.valueOf()}).join("")};function OutputFilePort(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,t)}typecheck("OutputFilePort",e,"string");read_only(this,"__filename__",e);read_only(this,"_fd",t.valueOf(),{hidden:true});read_only(this,"__type__",text_port);this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}r.fs().write(r._fd,e,function(e){if(e){throw e}})}}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(e){return user_env.get("**internal-env**").get(e)};OutputFilePort.prototype.close=function(){var n=this;return new Promise(function(t,r){n.fs().close(n._fd,function(e){if(e){r(e)}else{read_only(n,"_fd",null,{hidden:true});OutputPort.prototype.close.call(n);t()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof InputStringPort)||typeof this==="undefined"){return new InputStringPort(e)}typecheck("InputStringPort",e,"string");t=t||global_env;e=e.valueOf();this._with_parser=this._with_init_parser.bind(this,function(){if(!r.__parser__){r.__parser__=new Parser(e,{env:t})}return r.__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(e){if(typeof this!=="undefined"&&!(this instanceof InputByteVectorPort)||typeof this==="undefined"){return new InputByteVectorPort(e)}typecheck("InputByteVectorPort",e,"uint8array");read_only(this,"__vector__",e);read_only(this,"__type__",binary_port);var r=0;Object.defineProperty(this,"__index__",{enumerable:true,get:function e(){return r},set:function e(t){typecheck("InputByteVectorPort::__index__",t,"number");if(t instanceof LNumber){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}})}InputByteVectorPort.prototype=Object.create(InputPort.prototype);InputByteVectorPort.prototype.constructor=InputByteVectorPort;InputByteVectorPort.prototype.toString=function(){return"#"};InputByteVectorPort.prototype.close=function(){var t=this;read_only(this,"__vector__",_nil);["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}};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 e=this.peek_u8();this.skip();return e};InputByteVectorPort.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()===eof){return eof}return this.__vector__.slice(this.__index__,e)};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(e){typecheck("write",e,["number","uint8array"]);if(LNumber.isNumber(e)){this._buffer.push(e.valueOf())}else{var t;(t=this._buffer).push.apply(t,_toConsumableArray(Array.from(e)))}};Object.defineProperty(this,"__buffer__",{enumerable:true,get:function e(){return Uint8Array.from(this._buffer)}})}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(e){typecheck("OutputByteVectorPort::write_u8",e,"number");this.write(e)};OutputByteVectorPort.prototype.write_u8_vector=function(e){typecheck("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};OutputByteVectorPort.prototype.toString=function(){return"#"};OutputByteVectorPort.prototype.valueOf=function(){return this.__buffer__};function InputFilePort(e,t){if(typeof this!=="undefined"&&!(this instanceof InputFilePort)||typeof this==="undefined"){return new InputFilePort(e,t)}InputStringPort.call(this,e);typecheck("InputFilePort",t,"string");read_only(this,"__filename__",t)}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};function InputBinaryFilePort(e,t){if(typeof this!=="undefined"&&!(this instanceof InputBinaryFilePort)||typeof this==="undefined"){return new InputBinaryFilePort(e,t)}InputByteVectorPort.call(this,e);typecheck("InputBinaryFilePort",t,"string");read_only(this,"__filename__",t)}InputBinaryFilePort.prototype=Object.create(InputByteVectorPort.prototype);InputBinaryFilePort.prototype.constructor=InputBinaryFilePort;InputBinaryFilePort.prototype.toString=function(){return"#")};function OutputBinaryFilePort(e,t){var i=this;if(typeof this!=="undefined"&&!(this instanceof OutputBinaryFilePort)||typeof this==="undefined"){return new OutputBinaryFilePort(e,t)}typecheck("OutputBinaryFilePort",e,"string");read_only(this,"__filename__",e);read_only(this,"_fd",t.valueOf(),{hidden:true});read_only(this,"__type__",binary_port);var a,r;this.write=function(e){typecheck("write",e,["number","uint8array"]);var n;if(!a){a=i.internal("fs")}if(!r){r=i.internal("Buffer")}if(LNumber.isNumber(e)){n=r.from([e.valueOf()])}else{n=r.from(Array.from(e))}return new Promise(function(t,r){a.write(i._fd,n,function(e){if(e){r(e)}else{t()}})})}}OutputBinaryFilePort.prototype=Object.create(OutputFilePort.prototype);OutputBinaryFilePort.prototype.constructor=OutputBinaryFilePort;OutputBinaryFilePort.prototype.write_u8=function(e){typecheck("OutputByteVectorPort::write_u8",e,"number");this.write(e)};OutputBinaryFilePort.prototype.write_u8_vector=function(e){typecheck("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#"};function Interpreter(e){var c=this;var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=t.stderr,n=t.stdin,i=t.stdout,a=t.command_line,o=a===void 0?null:a,u=_objectWithoutProperties(t,_excluded3);if(typeof this!=="undefined"&&!(this instanceof Interpreter)||typeof this==="undefined"){return new Interpreter(e,_objectSpread({stdin:n,stdout:i,stderr:r,command_line:o},u))}if(typeof e==="undefined"){e="anonymous"}this.__env__=user_env.inherit(e,u);this.__env__.set("parent.frame",doc("parent.frame",function(){return c.__env__},global_env.__env__["parent.frame"].__doc__));var l="**interaction-environment-defaults**";this.set(l,get_props(u).concat(l));var s=internal_env.inherit("internal-".concat(e));if(is_port(n)){s.set("stdin",n)}if(is_port(r)){s.set("stderr",r)}if(is_port(i)){s.set("stdout",i)}s.set("command-line",o);set_interaction_env(this.__env__,s)}Interpreter.prototype.exec=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=t.use_dynamic,n=r===void 0?false:r,i=t.dynamic_env,a=t.env;typecheck("Interpreter::exec",e,["string","array"],1);typecheck("Interpreter::exec",n,"boolean",2);if(!a){a=this.__env__}if(!i){i=a}global_env.set("**interaction-environment**",this.__env__);return exec(e,{env:a,dynamic_env:i,use_dynamic:n})};Interpreter.prototype.get=function(e){var t=this.__env__.get(e);if(is_function(t)){return t.bind(this.__env__)}return t};Interpreter.prototype.set=function(e,t){return this.__env__.set(e,t)};Interpreter.prototype.constant=function(e,t){return this.__env__.constant(e,t)};function LipsError(e,t){this.name="LipsError";this.message=e;this.args=t;this.stack=(new Error).stack}LipsError.prototype=new Error;LipsError.prototype.constructor=LipsError;function Environment(e,t,r){if(arguments.length===1){if(_typeof(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"}Environment.prototype.list=function(){return get_props(this.__env__)};Environment.prototype.fs=function(){return this.get("**fs**")};Environment.prototype.unset=function(e){if(e instanceof LSymbol){e=e.valueOf()}if(e instanceof LString){e=e.valueOf()}delete this.__env__[e]};Environment.prototype.inherit=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(_typeof(e)==="object"){t=e}if(!e||_typeof(e)==="object"){e="child of "+(this.__name__||"unknown")}return new Environment(t||{},this,e)};Environment.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 LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(t){if(!r){t=trim_lines(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)}};Environment.prototype.new_frame=function(e,t){var n=this.inherit("__frame__");n.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:1;e=e.valueOf();var t=n.__parent__;if(!is_env(t)){return _nil}if(e<=0){return t}var r=t.get("parent.frame");return r(e-1)},global_env.__env__["parent.frame"].__doc__));t.callee=e;n.set("arguments",t);return n};Environment.prototype._lookup=function(e){if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(this.__env__.hasOwnProperty(e)){return Value(this.__env__[e])}if(this.__parent__){return this.__parent__._lookup(e)}};Environment.prototype.toString=function(){return"#"};Environment.prototype.clone=function(){var t=this;var r={};Object.keys(this.__env__).forEach(function(e){r[e]=t.__env__[e]});return new Environment(r,this.__parent__,this.__name__)};Environment.prototype.merge=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"merge";typecheck("Environment::merge",e,"environment");return this.inherit(t,e.__env__)};function Value(e){if(typeof this!=="undefined"&&!(this instanceof Value)||typeof this==="undefined"){return new Value(e)}this.value=e}Value.isUndefined=function(e){return e instanceof Value&&typeof e.value==="undefined"};Value.prototype.valueOf=function(){return this.value};function Values(e){if(e.length){if(e.length===1){return e[0]}}if(typeof this!=="undefined"&&!(this instanceof Values)||typeof this==="undefined"){return new Values(e)}this.__values__=e}Values.prototype.toString=function(){return this.__values__.map(function(e){return toString(e)}).join("\n")};Values.prototype.valueOf=function(){return this.__values__};Environment.prototype.get=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};typecheck("Environment::get",e,["symbol","string"]);var r=t.throwError,c=r===void 0?true:r;var n=e;if(n instanceof LSymbol||n instanceof LString){n=n.valueOf()}var i=this._lookup(n);if(i instanceof Value){if(Value.isUndefined(i)){return undefined}return patch_value(i.valueOf())}var a;if(e instanceof LSymbol&&e[LSymbol.object]){a=e[LSymbol.object]}else if(typeof n==="string"){a=n.split(".").filter(Boolean)}if(a&&a.length>0){var l=a,o=_toArray(l),u=o[0],s=o.slice(1);i=this._lookup(u);if(s.length){try{if(i instanceof Value){i=i.valueOf()}else{i=get(root,u);if(is_function(i)){i=unbind(i)}}if(typeof i!=="undefined"){return get.apply(void 0,[i].concat(_toConsumableArray(s)))}}catch(e){throw e}}else if(i instanceof Value){return patch_value(i.valueOf())}i=get(root,n)}if(typeof i!=="undefined"){return i}if(c){throw new Error("Unbound variable `"+n.toString()+"'")}};Environment.prototype.set=function(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;typecheck("Environment::set",e,["string","symbol"]);if(LNumber.isNumber(t)){t=LNumber(t)}if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}this.__env__[e]=t;if(r){this.doc(e,r,true)}return this};Environment.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&&is_plain_object(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};Environment.prototype.has=function(e){return this.__env__.hasOwnProperty(e)};Environment.prototype.ref=function(e){var t=this;while(true){if(!t){break}if(t.has(e)){return t}t=t.__parent__}};Environment.prototype.parents=function(){var e=this;var t=[];while(e){t.unshift(e);e=e.__parent__}return t};function quote(e){if(is_promise(e)){return e.then(quote)}if(e instanceof Pair||e instanceof LSymbol){e[__data__]=true}return e}var native_lambda=parse(tokenize('(lambda ()\n "[native code]"\n (throw "Invalid Invocation"))'))[0];var get=doc("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=internal(this,"stdin")}typecheck_text_port("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":doc("read-line",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=internal(this,"stdin")}typecheck_text_port("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":doc("read-char",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=internal(this,"stdin")}typecheck_text_port("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:doc("read",function(){var e=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r,n,i,a,o,u,s,c,l,f=arguments;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:r=f.length>0&&f[0]!==undefined?f[0]:null;n=this.env;if(!LString.isString(r)){t.next=31;break}i=false;a=false;t.prev=5;u=_asyncIterator(parse(r,n));case 7:t.next=9;return u.next();case 9:if(!(i=!(s=t.sent).done)){t.next=15;break}c=s.value;return t.abrupt("return",c);case 12:i=false;t.next=7;break;case 15:t.next=21;break;case 17:t.prev=17;t.t0=t["catch"](5);a=true;o=t.t0;case 21:t.prev=21;t.prev=22;if(!(i&&u["return"]!=null)){t.next=26;break}t.next=26;return u["return"]();case 26:t.prev=26;if(!a){t.next=29;break}throw o;case 29:return t.finish(26);case 30:return t.finish(21);case 31:if(r===null){l=internal(n,"stdin")}else{l=r}typecheck_text_port("read",l,"input-port");return t.abrupt("return",l.read.call(n));case 34:case"end":return t.stop()}}},e,this,[[5,17,21,31],[22,,26,30]])}));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:doc("pprint",function e(t){if(t instanceof Pair){t=new lips.Formatter(t.toString(true))["break"]().format();global_env.get("display").call(global_env,t)}else{global_env.get("write").call(global_env,t)}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 e(){var t=global_env.get("display");var r=global_env.get("newline");var n=this.use_dynamic;var i=global_env;var a=global_env;for(var o=arguments.length,u=new Array(o),s=0;s1?r-1:0),i=1;in.length){throw new Error("Not enough arguments")}var u=0;var s=global_env.get("repr");t=t.replace(a,function(e){var t=e[1];if(t==="~"){return"~"}else if(t==="%"){return"\n"}else{var r=n[u++];if(t==="a"){return s(r)}else{return s(r,true)}}});o=t.match(/~([\S])/);if(o){throw new Error("format: Unrecognized escape sequence ".concat(o[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:doc("display",function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(r===null){r=internal(this,"stdout")}else{typecheck("display",r,"output-port")}var n=t;if(!(r instanceof OutputBinaryFilePort)){n=global_env.get("repr")(t)}r.write.call(global_env,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":doc("display-error",function e(){var t=internal(this,"stderr");var r=global_env.get("repr");for(var n=arguments.length,i=new Array(n),a=0;a1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,l=_objectWithoutProperties(t,_excluded4);var n=this;var i=this;var a;var f=_objectSpread(_objectSpread({},l),{},{env:this,dynamic_env:n,use_dynamic:r});var o=_evaluate(e.cdr.car,f);o=resolve_promises(o);function u(t,r,n){if(is_promise(t)){return t.then(function(e){return u(t,e,n)})}if(is_promise(r)){return r.then(function(e){return u(t,e,n)})}if(is_promise(n)){return n.then(function(e){return u(t,r,e)})}i.get("set-obj!").call(i,t,r,n);return n}if(e.car instanceof Pair&&LSymbol.is(e.car.car,".")){var _=e.car.cdr.car;var p=e.car.cdr.cdr.car;var h=_evaluate(_,{env:this,dynamic_env:n,use_dynamic:r,error:error});var d=_evaluate(p,{env:this,dynamic_env:n,use_dynamic:r,error:error});return u(h,d,o)}if(!(e.car instanceof LSymbol)){throw new Error("set! first argument need to be a symbol or "+"dot accessor that evaluate to object.")}var s=e.car.valueOf();a=this.ref(e.car.__name__);return unpromise(o,function(e){if(!a){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){u(i,r,e);return}}throw new Error("Unbound variable `"+s+"'")}a.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!":doc(new Macro("set!",function(e){if(!(e.car instanceof LSymbol)){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!":doc("set-car!",function(e,t){typecheck("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!":doc("set-cdr!",function(e,t){typecheck("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?":doc("empty?",function(e){return typeof e==="undefined"||e===_nil},"(empty? object)\n\n Function that returns #t if value is nil (an empty list) or undefined."),gensym:doc("gensym",gensym,"(gensym)\n\n Generates a unique symbol that is not bound anywhere,\n to use with macros as meta name."),load:doc("load",function e(u,t){typecheck("load",u,"string");var s=this;if(s.__name__==="__frame__"){s=s.__parent__}if(!(t instanceof Environment)){if(s===global_env){t=s}else{t=this.get("**interaction-environment**")}}var c="**module-path**";var l=global_env.get(c,{throwError:false});u=u.valueOf();if(!u.match(/.[^.]+$/)){u+=".scm"}var r=u.match(/\.xcb$/);function f(e){if(r){e=unserialize_bin(e)}else{if(type(e)==="buffer"){e=e.toString()}e=e.replace(/^#!.*/,"");if(e.match(/^\{/)){e=unserialize(e)}}return exec(e,{env:t})}function n(e){return root.fetch(e).then(function(e){return r?e.arrayBuffer():e.text()}).then(function(e){if(r){e=new Uint8Array(e)}return e})}if(is_node()){return new Promise(function(){var r=_asyncToGenerator(_regeneratorRuntime.mark(function e(r,n){var i,a,o;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:i=nodeRequire("path");if(!l){t.next=6;break}l=l.valueOf();u=i.join(l,u);t.next=12;break;case 6:a=s.get("command-line",{throwError:false});if(!a){t.next=11;break}t.next=10;return a();case 10:o=t.sent;case 11:if(o&&o!==_nil){process.cwd();u=i.join(i.dirname(o.car.valueOf()),u)}case 12:global_env.set(c,i.dirname(u));nodeRequire("fs").readFile(u,function(e,t){if(e){n(e);global_env.set(c,l)}else{try{f(t).then(function(){r();global_env.set(c,l)})["catch"](n)}catch(e){n(e)}}});case 14:case"end":return t.stop()}}},e)}));return function(e,t){return r.apply(this,arguments)}}())}if(l){l=l.valueOf();u=l+"/"+u.replace(/^\.?\/?/,"")}return n(u).then(function(e){global_env.set(c,u.replace(/\/[^/]*$/,""));return f(e)}).then(function(){})["finally"](function(){global_env.set(c,l)})},"(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:doc(new Macro("do",function(){var r=_asyncToGenerator(_regeneratorRuntime.mark(function e(r,_){var p,n,i,a,u,s,o,c,l,f,h,d;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:p=_.use_dynamic,n=_.error;i=this;a=i;u=i.inherit("do");s=r.car;o=r.cdr.car;c=r.cdr.cdr;if(c!==_nil){c=new Pair(LSymbol("begin"),c)}l={env:i,dynamic_env:a,use_dynamic:p,error:n};f=s;case 10:if(!(f!==_nil)){t.next=21;break}h=f.car;t.t0=u;t.t1=h.car;t.next=16;return _evaluate(h.cdr.car,l);case 16:t.t2=t.sent;t.t0.set.call(t.t0,t.t1,t.t2);f=f.cdr;t.next=10;break;case 21:l={env:u,dynamic_env:a,error:n};d=_regeneratorRuntime.mark(function e(){var r,n,i,a,o;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!(c!==_nil)){t.next=3;break}t.next=3;return lips.evaluate(c,l);case 3:r=s;n={};case 5:if(!(r!==_nil)){t.next=15;break}i=r.car;if(!(i.cdr.cdr!==_nil)){t.next=12;break}t.next=10;return _evaluate(i.cdr.cdr.car,l);case 10:a=t.sent;n[i.car.valueOf()]=a;case 12:r=r.cdr;t.next=5;break;case 15:o=Object.getOwnPropertySymbols(n);Object.keys(n).concat(o).forEach(function(e){u.set(e,n[e])});case 17:case"end":return t.stop()}}},e)});case 23:t.next=25;return _evaluate(o.car,l);case 25:t.t3=t.sent;if(!(t.t3===false)){t.next=30;break}return t.delegateYield(d(),"t4",28);case 28:t.next=23;break;case 30:if(!(o.cdr!==_nil)){t.next=34;break}t.next=33;return _evaluate(o.cdr.car,l);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:doc(new Macro("if",function(r,e){var t=e.error,n=e.use_dynamic;var i=this;var a=this;var o={env:a,dynamic_env:i,use_dynamic:n,error:t};var u=function e(t){if(t===false){return _evaluate(r.cdr.cdr.car,o)}else{return _evaluate(r.cdr.car,o)}};if(r===_nil){throw new Error("too few expressions for `if`")}var s=_evaluate(r.car,o);return unpromise(s,u)}),"(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(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=e.dynamic_env,n=e.use_dynamic,i=e.error;typecheck("let-env",t,"pair");var a=_evaluate(t.car,{env:this,dynamic_env:r,error:i,use_dynamic:n});return unpromise(a,function(e){typecheck("let-env",e,"environment");return _evaluate(Pair(LSymbol("begin"),t.cdr),{env:e,dynamic_env:r,error:i})})},"(let-env env . body)\n\n Special macro that evaluates body in context of given environment\n object."),letrec:doc(let_macro(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*":doc(let_macro(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*":doc(let_macro(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:doc(let_macro(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*":doc(parallel("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())."),shuffle:doc(function(e){typecheck("shuffle",e,["pair","nil","array"]);var t=global_env.get("random");if(e===_nil){return _nil}if(Array.isArray(e)){return shuffle(e.slice(),t)}var r=global_env.get("list->array")(e);r=shuffle(r,t);return global_env.get("array->list")(r)},"(shuffle obj)\n\n Order items in vector or list in random order."),begin:doc(new Macro("begin",function(e,t){var n=_objectSpread(_objectSpread({},t),{},{env:this});var i=global_env.get("list->array")(e);var a;return function t(){if(i.length){var e=i.shift();var r=_evaluate(e,n);return unpromise(r,function(e){a=e;return t()})}else{return a}}()}),"(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 Macro("ignore",function(e,t){var r=_objectSpread(_objectSpread({},t),{},{env:this,dynamic_env:this});_evaluate(new Pair(new LSymbol("begin"),e),r)},"(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(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=_objectSpread({env:this},t);return unpromise(_evaluate(e.car,r),function(e){if(is_function(e)){return e(new Continuation(null))}})}),"(call/cc proc)\n\n Call-with-current-continuation.\n\n NOT SUPPORTED BY LIPS RIGHT NOW"),parameterize:doc(new Macro("parameterize",function(t,e){var i=e.dynamic_env;var a=i.inherit("parameterize").new_frame(null,{});var o=_objectSpread(_objectSpread({},e),{},{env:this});var u=t.car;if(!is_pair(u)){var r=type(u);throw new Error("Invalid syntax for parameterize expecting pair got ".concat(r))}function s(){var e=new Pair(new LSymbol("begin"),t.cdr);return _evaluate(e,_objectSpread(_objectSpread({},o),{},{dynamic_env:a}))}return function r(){var e=u.car;var n=e.car.valueOf();return unpromise(_evaluate(e.cdr.car,o),function(e){var t=i.get(n,{throwError:false});if(!is_parameter(t)){throw new Error("Unknown parameter ".concat(n))}a.set(n,t.inherit(e));if(!is_null(u.cdr)){u=u.cdr;return r()}else{return s()}})}()}),"(parameterize ((name value) ...)\n\n Macro that change the dynamic variable created by make-parameter."),"make-parameter":doc(new Macro("make-parameter",function(e,t){t.dynamic_env;var r=_evaluate(e.car,t);var n;if(e.cdr.car instanceof Pair){n=_evaluate(e.cdr.car,t)}return new Parameter(r,n)}),"(make-parameter init converter)\n\n Function creates new dynamic variable that can be custimized with parameterize\n macro. The value should be assigned to a variable e.g.:\n\n (define radix (make-parameter 10))\n\n The result value is a procedure that return the value of dynamic variable."),define:doc(Macro.defmacro("define",function(r,e){var n=this;if(r.car instanceof Pair&&r.car.car instanceof LSymbol){var t=new Pair(new LSymbol("define"),new Pair(r.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(r.car.cdr,r.cdr)))));return t}else if(e.macro_expand){return}e.dynamic_env=this;e.env=n;var i=r.cdr.car;var a;if(i instanceof Pair){i=_evaluate(i,e);a=true}else if(i instanceof LSymbol){i=n.get(i)}typecheck("define",r.car,"symbol");return unpromise(i,function(e){if(n.__name__===Syntax.__merge_env__){n=n.__parent__}if(a&&(is_function(e)&&is_lambda(e)||e instanceof Syntax||is_parameter(e))){e.__name__=r.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var t;if(r.cdr.cdr instanceof Pair&&LString.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!":doc("set-obj!",function(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var i=_typeof(e);if(is_null(e)||i!=="object"&&i!=="function"){var a=typeErrorMessage("set-obj!",type(e),["object","function"]);throw new Error(a)}typecheck("set-obj!",t,["string","symbol","number"]);e=unbind(e);t=t.valueOf();if(arguments.length===2){delete e[t]}else if(is_prototype(e)&&is_function(r)){e[t]=unbind(r);e[t][__prototype__]=true}else if(is_function(r)||is_native(r)||r===_nil){e[t]=r}else{e[t]=r&&!is_prototype(r)?r.valueOf():r}if(props){var o=e[t];Object.defineProperty(e,t,_objectSpread(_objectSpread({},n),{},{value:o}))}},"(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":doc("null-environment",function(){return global_env.inherit("null")},"(null-environment)\n\n Returns a clean environment with only the standard library."),values:doc("values",function e(){for(var t=arguments.length,r=new Array(t),n=0;n1&&arguments[1]!==undefined?arguments[1]:{},m=e.use_dynamic,y=e.error;var v=this;var g;if(d.cdr instanceof Pair&&LString.isString(d.cdr.car)&&d.cdr.cdr!==_nil){g=d.cdr.car.valueOf()}function b(){var c=is_context(this)?this:{dynamic_env:v},r=c.dynamic_env;var n=v.inherit("lambda");r=r.inherit("lambda");if(this&&!is_context(this)){if(this&&!this.__instance__){Object.defineProperty(this,"__instance__",{enumerable:false,get:function e(){return true},set:function e(){},configurable:false})}n.set("this",this)}for(var e=arguments.length,t=new Array(e),i=0;i>> "+c.toString());if(c){u=c}var m=r.merge(t,Syntax.__merge_env__);if(f){return{expr:u,scope:m}}var y=_evaluate(u,_objectSpread(_objectSpread({},h),{},{env:m}));return clear_gensyms(y,d)}i=i.cdr}}catch(e){e.message+=" in macro: ".concat(v.toString(true));throw e}throw new Error("Invalid Syntax ".concat(e.toString(true)))},w);r.__code__=v;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:doc(new Macro("quote",function(e){return quote(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":doc("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:doc("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:Macro.defmacro("quasiquote",function(e,t){var u=t.use_dynamic,s=t.error;var c=this;var l=c;function o(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function _(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:o;if(e instanceof Pair){var n=e.car;var i=e.cdr;if(r(n)){n=t(n)}if(r(i)){i=t(i)}if(is_promise(n)||is_promise(i)){return promise_all([n,i]).then(function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];return new Pair(r,n)})}else{return new Pair(n,i)}}return e}function a(e,t){if(e instanceof Pair){if(t!==_nil){e.append(t)}}else{e=new Pair(e,t)}return e}function r(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,/^(unquote|unquote-splicing)$/)}).length}function p(e,n,i){return e.reduce(function(e,t){if(!(t instanceof Pair)){e.push(t);return e}if(LSymbol.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 Pair&&r[0]===_nil)){return r[0]}}r=r.map(function(e){if(m.has(e)){return e.clone()}else{m.add(e);return e}});var n=f(i.cdr,0,1);if(n===_nil&&r[0]===_nil){return undefined}return unpromise(n,function(e){if(r[0]===_nil){return e}if(r.length===1){return a(r[0],e)}var t=r.reduce(function(e,t){return a(e,t)});return a(t,e)})})}(i.car.cdr)}var m=new Set;function f(e,t,r){if(e instanceof Pair){if(e.car instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return d(e,t+1,r)}if(LSymbol.is(e.car.car,"unquote")){if(t+2===r&&e.car.cdr instanceof Pair&&e.car.cdr.car instanceof Pair&&LSymbol.is(e.car.cdr.car.car,"unquote-splicing")){var n=e.car.cdr;return new Pair(new Pair(new LSymbol("unquote"),d(n,t+2,r)),_nil)}else if(e.car.cdr instanceof Pair&&e.car.cdr.cdr!==_nil){if(e.car.cdr.car instanceof Pair){var i=[];return function t(r){if(r===_nil){return Pair.fromArray(i)}return unpromise(_evaluate(r.car,{env:c,dynamic_env:l,use_dynamic:u,error:s}),function(e){i.push(e);return t(r.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}}if(LSymbol.is(e.car,"quasiquote")){var a=f(e.cdr,t,r+1);return new Pair(e.car,a)}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,f(e.cdr,t,r))}if(LSymbol.is(e.car,"unquote")){t++;if(tr){throw new Error("You can't call `unquote` outside "+"of quasiquote")}if(e.cdr instanceof Pair){if(e.cdr.cdr!==_nil){if(e.cdr.car instanceof Pair){var o=[];return function t(r){if(r===_nil){return Pair.fromArray(o)}return unpromise(_evaluate(r.car,{env:c,dynamic_env:l,use_dynamic:u,error:s}),function(e){o.push(e);return t(r.cdr)})}(e.cdr)}else{return e.cdr}}else{return _evaluate(e.cdr.car,{env:c,dynamic_env:l,error:s})}}else{return e.cdr}}return _(e,function(e){return f(e,t,r)})}else if(is_plain_object(e)){return h(e,t,r)}else if(e instanceof Array){return p(e,t,r)}return e}function n(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}}if(is_plain_object(e.car)&&!r(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!r(e.car)){return quote(e.car)}if(e.car instanceof Pair&&!e.car.find("unquote")&&!e.car.find("unquote-splicing")&&!e.car.find("quasiquote")){return quote(e.car)}var i=f(e.car,0,1);return unpromise(i,function(e){n(e);return quote(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:doc("clone",function e(t){typecheck("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:doc("append",function e(){var t;for(var r=arguments.length,n=new Array(r),i=0;iarray")(t).reverse();return global_env.get("array->list")(r)}else if(Array.isArray(t)){return t.reverse()}else{throw new Error(typeErrorMessage("reverse",type(t),"array or pair"))}},"(reverse list)\n\n Function that reverses the list or array. If value is not a list\n or array it will error."),nth:doc("nth",function e(t,r){typecheck("nth",t,"number");typecheck("nth",r,["array","pair"]);if(r instanceof Pair){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:doc("split",function e(t,r){typecheck("split",t,["regex","string"]);typecheck("split",r,"string");return global_env.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:doc("replace",function e(t,r,n){typecheck("replace",t,["regex","string"]);typecheck("replace",r,["string","function"]);typecheck("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:doc("match",function e(t,r){typecheck("match",t,["regex","string"]);typecheck("match",r,"string");var n=r.match(t);return n?global_env.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:doc("search",function e(t,r){typecheck("search",t,["regex","string"]);typecheck("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:doc("repr",function e(t,r){return toString(t,r)},"(repr obj)\n\n Function that returns a LIPS code representation of the object as a string."),"escape-regex":doc("escape-regex",function(e){typecheck("escape-regex",e,"string");return escape_regex(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:doc("env",function e(e){e=e||this.env;var t=Object.keys(e.__env__).map(LSymbol);var r;if(t.length){r=Pair.fromArray(t)}else{r=_nil}if(e.__parent__ instanceof Environment){return global_env.get("env").call(this,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:doc("new",function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n2&&arguments[2]!==undefined?arguments[2]:specials.LITERAL;typecheck("set-special!",e,"string",1);typecheck("set-special!",t,"symbol",2);specials.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:get,".":get,unbind:doc(unbind,"(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:doc(type,"(type object)\n\n Function that returns the type of an object as string."),debugger:doc("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:doc("in",function(e,t){if(e instanceof LSymbol||e instanceof LString||e instanceof LNumber){e=e.valueOf()}return e in unbox(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:doc("instanceof",function(e,t){return t instanceof unbind(e)},"(instanceof type obj)\n\n Predicate that tests if the obj is an instance of type."),"prototype?":doc("prototype?",is_prototype,"(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?":doc("macro?",function(e){return e instanceof Macro},"(macro? expression)\n\n Predicate that tests if value is a macro."),"function?":doc("function?",is_function,"(function? expression)\n\n Predicate that tests if value is a callable function."),"real?":doc("real?",function(e){if(type(e)!=="number"){return false}if(e instanceof LNumber){return e.isFloat()}return LNumber.isFloat(e)},"(real? number)\n\n Predicate that tests if value is a real number (not complex)."),"number?":doc("number?",function(e){return Number.isNaN(e)||LNumber.isNumber(e)},"(number? expression)\n\n Predicate that tests if value is a number or NaN value."),"string?":doc("string?",function(e){return LString.isString(e)},"(string? expression)\n\n Predicate that tests if value is a string."),"pair?":doc("pair?",function(e){return e instanceof Pair},"(pair? expression)\n\n Predicate that tests if value is a pair or list structure."),"regex?":doc("regex?",function(e){return e instanceof RegExp},"(regex? expression)\n\n Predicate that tests if value is a regular expression."),"null?":doc("null?",function(e){return is_null(e)},"(null? expression)\n\n Predicate that tests if value is null-ish (i.e. undefined, nil, or\n Javascript null)."),"boolean?":doc("boolean?",function(e){return typeof e==="boolean"},"(boolean? expression)\n\n Predicate that tests if value is a boolean (#t or #f)."),"symbol?":doc("symbol?",function(e){return e instanceof LSymbol},"(symbol? expression)\n\n Predicate that tests if value is a LIPS symbol."),"array?":doc("array?",function(e){return e instanceof Array},"(array? expression)\n\n Predicate that tests if value is an array."),"object?":doc("object?",function(e){return e!==_nil&&e!==null&&!(e instanceof LCharacter)&&!(e instanceof RegExp)&&!(e instanceof LString)&&!(e instanceof Pair)&&!(e instanceof LNumber)&&_typeof(e)==="object"&&!(e instanceof Array)},"(object? expression)\n\n Predicate that tests if value is an plain object (not another LIPS type)."),flatten:doc("flatten",function e(t){typecheck("flatten",t,"pair");return t.flatten()},"(flatten list)\n\n Returns a shallow list from tree structure (pairs)."),"array->list":doc("array->list",function(e){typecheck("array->list",e,"array");return Pair.fromArray(e)},"(array->list array)\n\n Function that converts a JavaScript array to a LIPS cons list."),"tree->array":doc("tree->array",to_array("tree->array",true),"(tree->array list)\n\n Function that converts a LIPS cons tree structure into a JavaScript array."),"list->array":doc("list->array",to_array("list->array"),"(list->array list)\n\n Function that converts a LIPS list into a JavaScript array."),apply:doc("apply",function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;iarray").call(this,a));return t.apply(this,prepare_fn_args(t,n))},"(apply fn list)\n\n Function that calls fn with the list of arguments."),length:doc("length",function e(t){if(!t||t===_nil){return 0}if(t instanceof Pair){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":doc("string->number",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;typecheck("string->number",e,"string",1);typecheck("string->number",t,"number",2);e=e.valueOf();t=t.valueOf();if(e.match(rational_bare_re)||e.match(rational_re)){return parse_rational(e,t)}else if(e.match(complex_bare_re)||e.match(complex_re)){return parse_complex(e,t)}else{var r=t===10&&!e.match(/e/i)||t===16;if(e.match(int_bare_re)&&r||e.match(int_re)){return parse_integer(e,t)}if(e.match(float_re)){return parse_float(e)}}return false},"(string->number number [radix])\n\n Function that parses a string into a number."),try:doc(new Macro("try",function(t,e){var c=this;var r=e.use_dynamic,l=e.error;return new Promise(function(n,i){var a,o;if(LSymbol.is(t.cdr.car.car,"catch")){a=t.cdr.car;if(t.cdr.cdr instanceof Pair&&LSymbol.is(t.cdr.cdr.car.car,"finally")){o=t.cdr.cdr.car}}else if(LSymbol.is(t.cdr.car.car,"finally")){o=t.cdr.car}if(!(o||a)){throw new Error("try: invalid syntax")}var u=n;if(o){u=function e(t,r){u=i;unpromise(_evaluate(new Pair(new LSymbol("begin"),o.cdr),s),function(){r(t)})}}var s={env:c,use_dynamic:r,dynamic_env:c,error:function(t){function e(e){return t.apply(this,arguments)}e.toString=function(){return t.toString()};return e}(function(e){var t=c.inherit("try");if(a){t.set(a.cdr.car.car,e);var r={env:t,error:l};r.dynamic_env=c;unpromise(_evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),r),function(e){u(e,n)})}else{u(e,l)}})};var e=_evaluate(t.car,s);if(is_promise(e)){e.then(function(e){u(e,n)})["catch"](s.error)}else{u(e,n)}})}),"(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:doc("raise",function(e){throw e},"(raise obj)\n\n Throws the object verbatim (no wrapping an a new Error)."),throw:doc("throw",function(e){throw new Error(e)},"(throw string)\n\n Throws a new exception."),find:doc("find",function t(r,n){typecheck("find",r,["regex","function"]);typecheck("find",n,["pair","nil"]);if(is_null(n)){return _nil}var e=matcher("find",r);return unpromise(e(n.car),function(e){if(e&&e!==_nil){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":doc("for-each",function(e){var t;typecheck("for-each",e,"function");for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i1?t-1:0),a=1;a3?n-3:0),a=3;a3?i-3:0),o=3;oarray")(r);var a=[];var o=matcher("filter",t);return function t(r){function e(e){if(e&&e!==_nil){a.push(n)}return t(++r)}if(r===i.length){return Pair.fromArray(a)}var n=i[r];return unpromise(o(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:doc(compose,"(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:doc(pipe,"(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:doc(curry,"(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:doc("gcd",function e(){for(var t=arguments.length,r=new Array(t),n=0;nu?a%=u:u%=a}a=abs(s*r[o])/(a+u)}return LNumber(a)},"(lcm n1 n2 ...)\n\n Function that returns the least common multiple of the arguments."),"odd?":doc("odd?",single_math_op(function(e){return LNumber(e).isOdd()}),"(odd? number)\n\n Checks if number is odd."),"even?":doc("even?",single_math_op(function(e){return LNumber(e).isEven()}),"(even? number)\n\n Checks if number is even."),"*":doc("*",reduce_math_op(function(e,t){return LNumber(e).mul(t)},LNumber(1)),"(* . numbers)\n\n Multiplies all numbers passed as arguments. If single value is passed\n it will return that value."),"+":doc("+",reduce_math_op(function(e,t){return LNumber(e).add(t)},LNumber(0)),"(+ . numbers)\n\n Sums all numbers passed as arguments. If single value is passed it will\n return that value."),"-":doc("-",function(){for(var e=arguments.length,t=new Array(e),r=0;r":doc(">",function(){for(var e=arguments.length,t=new Array(e),r=0;r",t,"number");return seq_compare(function(e,t){return LNumber(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."),"<":doc("<",function(){for(var e=arguments.length,t=new Array(e),r=0;r=":doc(">=",function(){for(var e=arguments.length,t=new Array(e),r=0;r=",t,"number");return seq_compare(function(e,t){return[0,1].includes(LNumber(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?":doc("eq?",equal,"(eq? a b)\n\n Function that compares two values if they are identical."),or:doc(new Macro("or",function(e,t){var i=t.use_dynamic,a=t.error;var o=global_env.get("list->array")(e);var u=this;var s=u;if(!o.length){return false}var c;return function t(){function e(e){c=e;if(c!==false){return c}else{return t()}}if(!o.length){if(c!==false){return c}else{return false}}else{var r=o.shift();var n=_evaluate(r,{env:u,dynamic_env:s,use_dynamic:i,error:a});return unpromise(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:doc(new Macro("and",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=t.error;var i=global_env.get("list->array")(e);var a=this;var o=a;if(!i.length){return true}var u;var s={env:a,dynamic_env:o,use_dynamic:r,error:n};return function t(){function e(e){u=e;if(u===false){return false}else{return t()}}if(!i.length){if(u!==false){return u}else{return false}}else{var r=i.shift();return unpromise(_evaluate(r,s),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."),"|":doc("|",function(e,t){return LNumber(e).or(t)},"(| a b)\n\n Function that calculates the bitwise or operation."),"&":doc("&",function(e,t){return LNumber(e).and(t)},"(& a b)\n\n Function that calculates the bitwise and operation."),"~":doc("~",function(e){return LNumber(e).neg()},"(~ number)\n\n Function that calculates the bitwise inverse (flip all the bits)."),">>":doc(">>",function(e,t){return LNumber(e).shr(t)},"(>> a b)\n\n Function that right shifts the value a by value b bits."),"<<":doc("<<",function(e,t){return LNumber(e).shl(t)},"(<< a b)\n\n Function that left shifts the value a by value b bits."),not:doc("not",function e(t){if(is_null(t)){return true}return!t},"(not object)\n\n Function that returns the Boolean negation of its argument.")},undefined,"global");var user_env=global_env.inherit("user-env");function set_interaction_env(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.");global_env.set("**interaction-environment**",e)}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.");(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(t){var r=e[t]?e[t]:t;global_env.set(r,doc(r,function(e){typecheck(r,e,"number");if(e instanceof LNumber){return e[t]()}},"(".concat(r," number)\n\n Function that calculates the ").concat(r," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var t=[];var r=allPossibleCases(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(is_function(r)){return"Invalid type: got ".concat(t).concat(i)}if(r instanceof Array){if(r.length===1){var a=r[0].toLowerCase();r="a"+("aeiou".includes(a)?"n ":" ")+r[0]}else{var o=r[r.length-1];r=r.slice(0,-1).join(", ")+" or "+o}}return"Expecting ".concat(r,", got ").concat(t).concat(i)}function typecheck_args(r,e,n){e.forEach(function(e,t){typecheck(r,e,n,t+1)})}function typecheck_text_port(e,t,r){typecheck(e,t,r);if(t.__type__===binary_port){throw new Error(typeErrorMessage(e,"binary-port","textual-port"))}}function typecheck(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;e=e.valueOf();var i=type(t).toLowerCase();if(is_function(r)){if(!r(t)){throw new Error(typeErrorMessage(e,i,r,n))}return}var a=false;if(r instanceof Pair){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)){a=true}}else{r=r.valueOf().toLowerCase()}if(!a&&i!==r){throw new Error(typeErrorMessage(e,i,r,n))}}function self_evaluated(e){var t=_typeof(e);return["string","function"].includes(t)||_typeof(e)==="symbol"||e instanceof QuotedPromise||e instanceof LSymbol||e instanceof LNumber||e instanceof LString||e instanceof RegExp}function is_native(e){return e instanceof LNumber||e instanceof LString||e instanceof LCharacter}function has_own_symbol(e,t){if(e===null){return false}return _typeof(e)==="object"&&t in Object.getOwnPropertySymbols(e)}function is_iterator(e,t){if(has_own_symbol(e,t)||has_own_symbol(e.__proto__,t)){return is_function(e[t])}}function memoize(r){var n=new WeakMap;return function(e){var t=n.get(e);if(!t){t=r(e)}return t}}type=memoize(type);function type(e){var t=type_constants.get(e);if(t){return t}if(_typeof(e)==="object"){for(var r=0,n=Object.entries(type_mapping);r2&&arguments[2]!==undefined?arguments[2]:{},n=r.env,i=r.dynamic_env,a=r.use_dynamic;var o=n===null||n===void 0?void 0:n.new_frame(e,t);var u=i===null||i===void 0?void 0:i.new_frame(e,t);var s=new LambdaContext({env:o,use_dynamic:a,dynamic_env:u});return resolve_promises(e.apply(s,t))}function apply(n,e){var t=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},i=t.env,a=t.dynamic_env,o=t.use_dynamic,r=t.error,u=r===void 0?function(){}:r;e=evaluate_args(e,{env:i,dynamic_env:a,error:u,use_dynamic:o});return unpromise(e,function(e){if(is_raw_lambda(n)){n=unbind(n)}e=prepare_fn_args(n,e);var t=e.slice();var r=call_function(n,t,{env:i,dynamic_env:a,use_dynamic:o});return unpromise(r,function(e){if(e instanceof Pair){e.markCycles();return quote(e)}return box(e)},u)})}var _p_name__=new WeakMap;var Parameter=function(){function n(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;_classCallCheck(this,n);_defineProperty(this,"__value__",void 0);_defineProperty(this,"__fn__",void 0);_classPrivateFieldInitSpec(this,_p_name__,{writable:true,value:void 0});this.__value__=e;if(t){if(!is_function(t)){throw new Error("Section argument to Parameter need to be function "+"".concat(type(t)," given"))}this.__fn__=t}if(r){_classPrivateFieldSet(this,_p_name__,r)}}_createClass(n,[{key:"__name__",get:function e(){return _classPrivateFieldGet(this,_p_name__)},set:function e(t){_classPrivateFieldSet(this,_p_name__,t);if(this.__fn__){this.__fn__.__name__="fn-".concat(t)}}},{key:"invoke",value:function e(){if(is_function(this.__fn__)){return this.__fn__(this.__value__)}return this.__value__}},{key:"inherit",value:function e(t){return new n(t,this.__fn__,this.__name__)}}]);return n}();var LambdaContext=function(){function t(e){_classCallCheck(this,t);_defineProperty(this,"env",void 0);_defineProperty(this,"dynamic_env",void 0);_defineProperty(this,"use_dynamic",void 0);Object.assign(this,e)}_createClass(t,[{key:"__name__",get:function e(){return this.env.__name__}},{key:"__parent__",get:function e(){return this.env.__parent__}},{key:"get",value:function e(){var t;return(t=this.env).get.apply(t,arguments)}}]);return t}();function search_param(e,t){var r=e.get(t.__name__,{throwError:false});if(is_parameter(r)&&r!==t){return r}var n=user_env.get("**interaction-environment**");while(true){var i=e.get("parent.frame",{throwError:false});e=i(0);if(e===n){break}r=e.get(t.__name__,{throwError:false});if(is_parameter(r)&&r!==t){return r}}return t}var Continuation=function(){function t(e){_classCallCheck(this,t);_defineProperty(this,"__value__",void 0);this.__value__=e}_createClass(t,[{key:"invoke",value:function e(){if(this.__value__===null){throw new Error("Continuations are not implemented yet")}}}]);return t}();var noop=function e(){};function _evaluate(u){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},s=e.env,c=e.dynamic_env,l=e.use_dynamic,t=e.error,f=t===void 0?noop:t,r=_objectWithoutProperties(e,_excluded6);return function(e){try{if(!is_env(c)){c=s===true?user_env:s||user_env}if(l){s=c}else if(s===true){s=user_env}else{s=s||global_env}var t={env:s,dynamic_env:c,use_dynamic:l,error:f};var r;if(is_null(u)){return u}if(u instanceof LSymbol){return s.get(u)}if(!(u instanceof Pair)){return u}var n=u.car;var e=u.cdr;if(n instanceof Pair){r=resolve_promises(_evaluate(n,t));if(is_promise(r)){return r.then(function(e){if(!is_callable(e)){throw new Error(type(e)+" "+s.get("repr")(e)+" is not callable while evaluating "+u.toString())}return _evaluate(new Pair(e,u.cdr),t)})}else if(!is_callable(r)){throw new Error(type(r)+" "+s.get("repr")(r)+" is not callable while evaluating "+u.toString())}}if(n instanceof LSymbol){r=s.get(n)}else if(is_function(n)){r=n}var i;if(r instanceof Syntax){i=evaluate_syntax(r,u,t)}else if(r instanceof Macro){i=evaluate_macro(r,e,t)}else if(is_function(r)){i=apply(r,e,t)}else if(is_parameter(r)){var a=search_param(c,r);if(is_null(u.cdr)){i=a.invoke()}else{return unpromise(_evaluate(u.cdr.car,t),function(e){a.__value__=e})}}else if(is_continuation(r)){i=r.invoke()}else if(u instanceof Pair){r=n&&n.toString();throw new Error("".concat(type(n)," ").concat(r," is not a function"))}else{return u}var o=s.get(Symbol["for"]("__promise__"),{throwError:false});if(o===true&&is_promise(i)){i=i.then(function(e){if(e instanceof Pair&&!r[__data__]){return _evaluate(e,t)}return e});return new QuotedPromise(i)}return i}catch(e){f&&f.call(s,e,u)}}(r)}var compile=exec_collect(function(e){return e});var exec=exec_collect(function(e,t){return t});function exec_collect(y){return function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function e(r){var n,i,a,_,o,p,u,s,h,c,d,l,m,f=arguments;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:n=f.length>1&&f[1]!==undefined?f[1]:{},i=n.env,a=n.dynamic_env,_=n.use_dynamic;if(!is_env(a)){a=i===true?user_env:i||user_env}if(i===true){i=user_env}else{i=i||user_env}o=[];p=Array.isArray(r)?r:parse(r);u=false;s=false;t.prev=7;c=_asyncIterator(p);case 9:t.next=11;return c.next();case 11:if(!(u=!(d=t.sent).done)){t.next=25;break}l=d.value;m=_evaluate(l,{env:i,dynamic_env:a,use_dynamic:_,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}});t.t0=o;t.t1=y;t.t2=l;t.next=19;return m;case 19:t.t3=t.sent;t.t4=(0,t.t1)(t.t2,t.t3);t.t0.push.call(t.t0,t.t4);case 22:u=false;t.next=9;break;case 25:t.next=31;break;case 27:t.prev=27;t.t5=t["catch"](7);s=true;h=t.t5;case 31:t.prev=31;t.prev=32;if(!(u&&c["return"]!=null)){t.next=36;break}t.next=36;return c["return"]();case 36:t.prev=36;if(!s){t.next=39;break}throw h;case 39:return t.finish(36);case 40:return t.finish(31);case 41:return t.abrupt("return",o);case 42:case"end":return t.stop()}}},e,null,[[7,27,31,41],[32,,36,40]])}));function e(e){return t.apply(this,arguments)}return e}()}function balanced(e){var t={"[":"]","(":")"};var r;if(typeof e==="string"){r=tokenize(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 a=new Stack;var o=_createForOfIteratorHelper(r),u;try{for(o.s();!(u=o.n()).done;){var s=u.value;if(n.includes(s)){a.push(s)}else if(!a.is_empty()){var l=a.top();var c=t[l];if(s===c){a.pop()}else{throw new Error("Syntax error: missing closing ".concat(c))}}else{throw new Error("Syntax error: not matched closing ".concat(s))}}}catch(e){o.e(e)}finally{o.f()}return a.is_empty()}function fworker(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 root.Worker(r.createObjectURL(n))}function is_dev(){return lips.version.match(/^(\{\{VER\}\}|DEV)$/)}function get_current_script(){if(is_node()){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 current_script=get_current_script();function bootstrap(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";var t="dist/std.xcb";if(e===""){if(current_script){e=current_script.replace(/[^/]*$/,"std.xcb")}else if(is_dev()){e="https://cdn.jsdelivr.net/gh/jcubic/lips@devel/".concat(t)}else{e="https://cdn.jsdelivr.net/npm/@jcubic/lips@".concat(lips.version,"/").concat(t)}}var r=global_env.get("load");return r.call(user_env,e,global_env)}function Worker(e){this.url=e;var o=this.worker=fworker(function(){var o;var u;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(!u){i("Worker RPC: LIPS not initialized, call init first");return}u.then(function(){var e=r.params[0];var t=r.params[1];o.exec(e,{use_dynamic: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 a=r.params[0];if(typeof a!=="string"){i("Worker RPC: url is not a string")}else{importScripts("".concat(a,"/dist/lips.min.js"));o=new lips.Interpreter("worker");u=bootstrap(a);u.then(function(){n(true)})}}})});this.rpc=function(){var n=0;return function e(t,r){var a=++n;return new Promise(function(n,i){o.addEventListener("message",function e(t){var r=t.data;if(r&&r.type==="RPC"&&r.id===a){if(r.error){i(r.error)}else{n(r.result)}o.removeEventListener("message",e)}});o.postMessage({type:"RPC",method:t,id:a,params:r})})}}();this.rpc("init",[e])["catch"](function(e){console.error(e)});this.exec=function(e,t){var r=t.use_dynamic,n=r===void 0?false:r;return this.rpc("eval",[e,n])}}var serialization_map={pair:function e(t){var r=_slicedToArray(t,2),n=r[0],i=r[1];return Pair(n,i)},number:function e(t){if(LString.isString(t)){return LNumber([t,10])}return LNumber(t)},regex:function e(t){var r=_slicedToArray(t,2),n=r[0],i=r[1];return new RegExp(n,i)},nil:function e(){return _nil},symbol:function e(t){if(LString.isString(t)){return LSymbol(t)}else if(Array.isArray(t)){return LSymbol(Symbol["for"](t[0]))}},string:LString,character:LCharacter};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];class_map[cls]=+i}function mangle_name(e){return class_map[e]}function resolve_name(e){return available_class[e]}function serialize(e){return JSON.stringify(e,function(e,t){var r=this[e];if(r){if(r instanceof RegExp){return{"@":mangle_name("regex"),"#":[r.source,r.flags]}}var n=mangle_name(r.constructor.__class__);if(!is_undef(n)){return{"@":n,"#":r.serialize()}}}return t})}function unserialize(e){return JSON.parse(e,function(e,t){if(t&&_typeof(t)==="object"){if(!is_undef(t["@"])){var r=resolve_name(t["@"]);if(serialization_map[r]){return serialization_map[r](t["#"])}}}return t})}var cbor=function(){var e={pair:Pair,symbol:LSymbol,number:LNumber,string:LString,character:LCharacter,nil:_nil.constructor,regex:RegExp};function t(e,t){return{deserialize:t,Class:e}}var r=new Encoder;var a={};for(var n=0,i=Object.entries(serialization_map);n1){var n=t.reduce(function(e,t){return e+t.length},0);var i=new Uint8Array(n);var a=0;t.forEach(function(e){i.set(e,a);a+=e.length});return i}else if(t.length){return t[0]}}function encode_magic(){var e=1;var t=new TextEncoder("utf-8");return t.encode("LIPS".concat(e.toString().padStart(3," ")))}var MAGIC_LENGTH=7;function decode_magic(e){var t=new TextDecoder("utf-8");var r=t.decode(e.slice(0,MAGIC_LENGTH));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 serialize_bin(e){var t=encode_magic();var r=cbor.encode(e);return merge_uint8_array(t,pack_1(r,{magic:false}))}function unserialize_bin(e){var t=decode_magic(e),r=t.type,n=t.version;if(r==="LIPS"&&n===1){var i=unpack_1(e.slice(MAGIC_LENGTH),{magic:false});return cbor.decode(i)}else{throw new Error("Invalid file format ".concat(r))}}function execError(e){console.error(e.message||e);if(e.code){console.error(e.code.map(function(e,t){return"[".concat(t+1,"]: ").concat(e)}))}}function init(){var o=["text/x-lips","text/x-scheme"];var u;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(exec).then(t)["catch"](function(e){execError(e);t()})}else{return exec(r.innerHTML).then(t)["catch"](function(e){execError(e);t()})}})}function e(){return new Promise(function(i){var a=Array.from(document.querySelectorAll("script"));return function e(){var t=a.shift();if(!t){i()}else{var r=t.getAttribute("type");if(o.includes(r)){var n=t.getAttribute("bootstrap");if(!u&&typeof n==="string"){return bootstrap(n).then(function(){return s(t)}).then(e)}else{return s(t).then(e)}}else if(r&&r.match(/lips|lisp/)){console.warn("Expecting "+o.join(" or ")+" found "+r)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var t=currentScript;var r=t.getAttribute("bootstrap");if(typeof r==="string"){return bootstrap(r).then(function(){u=true;return e()})}}return e()}var currentScript=typeof window!=="undefined"&&window.document&&document.currentScript;if(typeof window!=="undefined"){contentLoaded(window,init)}var banner=function(){var e=LString("Mon, 15 Jan 2024 12:39:38 +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 a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".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 a}();read_only(Ahead,"__class__","ahead");read_only(Pair,"__class__","pair");read_only(Nil,"__class__","nil");read_only(Pattern,"__class__","pattern");read_only(Formatter,"__class__","formatter");read_only(Macro,"__class__","macro");read_only(Syntax,"__class__","syntax");read_only(Environment,"__class__","environment");read_only(InputPort,"__class__","input-port");read_only(OutputPort,"__class__","output-port");read_only(BufferedOutputPort,"__class__","output-port");read_only(OutputStringPort,"__class__","output-string-port");read_only(InputStringPort,"__class__","input-string-port");read_only(InputFilePort,"__class__","input-file-port");read_only(OutputFilePort,"__class__","output-file-port");read_only(LipsError,"__class__","lips-error");[LNumber,LComplex,LRational,LFloat,LBigInteger].forEach(function(e){read_only(e,"__class__","number")});read_only(LCharacter,"__class__","character");read_only(LSymbol,"__class__","symbol");read_only(LString,"__class__","string");read_only(QuotedPromise,"__class__","promise");read_only(Parameter,"__class__","parameter");var lips={version:"DEV",banner:banner,date:"Mon, 15 Jan 2024 12:39:38 +0000",exec:exec,parse:compose(uniterate_async,parse),tokenize:tokenize,evaluate:_evaluate,compile:compile,serialize:serialize,unserialize:unserialize,serialize_bin:serialize_bin,unserialize_bin:unserialize_bin,bootstrap:bootstrap,Environment:Environment,env:user_env,Worker:Worker,Interpreter:Interpreter,balanced_parenthesis:balanced,balancedParenthesis:balanced,balanced:balanced,Macro:Macro,Syntax:Syntax,Pair:Pair,Values:Values,QuotedPromise:QuotedPromise,Error:LipsError,quote:quote,InputPort:InputPort,OutputPort:OutputPort,BufferedOutputPort:BufferedOutputPort,InputFilePort:InputFilePort,OutputFilePort:OutputFilePort,InputStringPort:InputStringPort,OutputStringPort:OutputStringPort,InputByteVectorPort:InputByteVectorPort,OutputByteVectorPort:OutputByteVectorPort,InputBinaryFilePort:InputBinaryFilePort,OutputBinaryFilePort:OutputBinaryFilePort,Formatter:Formatter,Parser:Parser,Lexer:Lexer,specials:specials,repr:repr,nil:_nil,eof:eof,LSymbol:LSymbol,LNumber:LNumber,LFloat:LFloat,LComplex:LComplex,LRational:LRational,LBigInteger:LBigInteger,LCharacter:LCharacter,LString:LString,Parameter:Parameter,rationalize:rationalize};global_env.set("lips",lips);var empty={};var empty$1=Object.freeze({__proto__:null,default:empty});function normalizeArray(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 splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var splitPath=function(e){return splitPathRe.exec(e).slice(1)};function resolve(){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=normalizeArray(filter(e.split("/"),function(e){return!!e}),!t).join("/");return(t?"/":"")+e||"."}function normalize(e){var t=isAbsolute(e),r=substr(e,-1)==="/";e=normalizeArray(filter(e.split("/"),function(e){return!!e}),!t).join("/");if(!e&&!t){e="."}if(e&&r){e+="/"}return(t?"/":"")+e}function isAbsolute(e){return e.charAt(0)==="/"}function join(){var e=Array.prototype.slice.call(arguments,0);return normalize(filter(e,function(e,t){if(typeof e!=="string"){throw new TypeError("Arguments to path.join must be strings")}return e}).join("/"))}function relative(e,t){e=resolve(e).substr(1);t=resolve(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 a=Math.min(n.length,i.length);var o=a;for(var u=0;u=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 a=true,o=false,u;return{s:function e(){r=r.call(t)},n:function e(){var t=r.next();a=t.done;return t},e:function e(t){o=true;u=t},f:function e(){try{if(!a&&r["return"]!=null)r["return"]()}finally{if(o)throw u}}}}function _unsupportedIterableToArray(e,t){if(!e)return;if(typeof e==="string")return _arrayLikeToArray(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 _arrayLikeToArray(e,t)}function _arrayLikeToArray(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(!is_debug()){return}var t=global_env.get("repr")(e);if(r===null||r instanceof RegExp&&r.test(t)){console.log(global_env.get("type")(e)+": "+t)}if(n){console.log(e)}}if(is_promise(e)){e.then(t)}else{t(e)}return e}function is_debug(){return user_env&&user_env.get("DEBUG",{throwError:false})}function num_mnemicic_re(e){return e?"(?:#".concat(e,"(?:#[ie])?|#[ie]#").concat(e,")"):"(?:#[ie])?"}function gen_rational_re(e,t){return"".concat(num_mnemicic_re(e),"[+-]?").concat(t,"+/").concat(t,"+")}function gen_complex_re(e,t){return"".concat(num_mnemicic_re(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 gen_integer_re(e,t){return"".concat(num_mnemicic_re(e),"[+-]?").concat(t,"+")}var re_re=/^#\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimyus]*)$/;var float_stre="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+)(?:[eE][-+]?[0-9]+)?)|[0-9]+\\.)";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(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 complex_list_re=function(){var a={};[[10,"","[0-9]"],[16,"x","[0-9a-fA-F]"],[8,"o","[0-7]"],[2,"b","[01]"]].forEach(function(e){var t=_slicedToArray(e,3),r=t[0],n=t[1],i=t[2];a[r]=make_complex_match_re(n,i)});return a}();var characters={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 ucs2decode(e){var t=[];var r=0;var n=e.length;while(r=55296&&i<=56319&&r1&&arguments[1]!==undefined?arguments[1]:10;var r=num_pre_parse(e);var n=r.number.split("/");var i=LRational({num:LNumber([n[0],r.radix||t]),denom:LNumber([n[1],r.radix||t])});if(r.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;var r=num_pre_parse(e);if(r.inexact){return LFloat(parseInt(r.number,r.radix||t))}return LNumber([r.number,r.radix||t])}function parse_character(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 LCharacter(r)}throw new Error("Parse: invalid character")}function parse_complex(e){var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;function t(e){var t;if(e==="+"){t=LNumber(1)}else if(e==="-"){t=LNumber(-1)}else if(e.match(int_bare_re)){t=LNumber([e,i])}else if(e.match(rational_bare_re)){var r=e.split("/");t=LRational({num:LNumber([r[0],i]),denom:LNumber([r[1],i])})}else if(e.match(float_re)){var n=parse_float(e);if(a.exact){return n.toRational()}return n}else if(e.match(/nan.0$/)){return LNumber(NaN)}else if(e.match(/inf.0$/)){if(e[0]==="-"){return LNumber(Number.NEGATIVE_INFINITY)}return LNumber(Number.POSITIVE_INFINITY)}else{throw new Error("Internal Parser Error")}if(a.inexact){return LFloat(t.valueOf())}return t}var a=num_pre_parse(e);i=a.radix||i;var r;var n=a.number.match(complex_bare_match_re);if(i!==10&&n){r=n}else{r=a.number.match(complex_list_re[i])}var o,u;u=t(r[2]);if(r[1]){o=t(r[1])}else{o=LNumber(0)}if(u.cmp(0)===0&&u.__type__==="bigint"){return o}return LComplex({im:u,re:o})}function is_int(e){return parseInt(e.toString(),10)===e}function parse_big_int(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 a=t[3]&&t[3].length;if(i0){return LNumber(a).mul(u)}}}r=LFloat(r);if(t.exact){return r.toRational()}return r}function parse_string(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 LString(JSON.parse(e))}catch(e){var r=e.message.replace(/in JSON /,"").replace(/.*Error: /,"");throw new Error("Invalid string literal: ".concat(r))}}function parse_symbol(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 LSymbol(e)}function parse_argument(e){if(constants.hasOwnProperty(e)){return constants[e]}if(e.match(/^"[\s\S]*"$/)){return parse_string(e)}else if(e[0]==="#"){var t=e.match(re_re);if(t){return new RegExp(t[1],t[2])}else if(e.match(char_re)){return parse_character(e)}var r=e.match(/#\\(.+)/);if(r&&ucs2decode(r[1]).length===1){return parse_character(e)}}if(e.match(/[0-9a-f]|[+-]i/i)){if(e.match(int_re)){return parse_integer(e)}else if(e.match(float_re)){return parse_float(e)}else if(e.match(rational_re)){return parse_rational(e)}else if(e.match(complex_re)){return parse_complex(e)}}if(e.match(/^#[iexobd]/)){throw new Error("Invalid numeric constant: "+e)}return parse_symbol(e)}function is_atom_string(e){return!(["(",")","[","]"].includes(e)||specials.names().includes(e))}function is_symbol_string(e){return is_atom_string(e)&&!(e.match(re_re)||e.match(/^"[\s\S]*"$/)||e.match(int_re)||e.match(float_re)||e.match(complex_re)||e.match(rational_re)||e.match(char_re)||["#t","#f","nil","true","false"].includes(e))}var string_re=/"(?:\\[\S\s]|[^"])*"?/g;function escape_regex(e){if(typeof e==="string"){var t=/([-\\^$[\]()+{}?*.|])/g;return e.replace(t,"\\$1")}return e}function Stack(){this.data=[]}Stack.prototype.push=function(e){this.data.push(e)};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(e){if(e instanceof LString){e=e.valueOf()}var t=new Lexer(e,{whitespace:true});var r=[];while(true){var n=t.peek(true);if(n===eof){break}r.push(n);t.skip()}return r}function multiline_formatter(e){var t=e.token,r=_objectWithoutProperties(e,_excluded);if(t.match(/^"[\s\S]*"$/)&&t.match(/\n/)){var n=new RegExp("^ {1,"+(e.col+1)+"}","mg");t=t.replace(n,"")}return _objectSpread({token:t},r)}function Thunk(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};this.fn=e;this.cont=t}Thunk.prototype.toString=function(){return"#"};function trampoline(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r1&&arguments[1]!==undefined?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(t){return tokens(e)}else{var r=tokens(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 strip_s_comments(r)}}function strip_s_comments(e){var t=0;var r=null;var n=[];for(var i=0;i0&&arguments[0]!==undefined?arguments[0]:null;if(e instanceof LSymbol){if(e.is_gensym()){return e}e=e.valueOf()}if(is_gensym(e)){return LSymbol(e)}if(e!==null){return r(e,Symbol("#:".concat(e)))}t++;return r(t,Symbol("#:g".concat(t)))}}();function QuotedPromise(e){var r=this;var n={pending:true,rejected:false,fulfilled:false,reason:undefined,type:undefined};e=e.then(function(e){n.type=type(e);n.fulfilled=true;n.pending=false;return e});read_only(this,"_promise",e,{hidden:true});if(is_function(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]}})});read_only(this,"__promise__",e);this.then=false}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.valueOf().then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.valueOf()["catch"](e))};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="#";function promise_all(e){if(Array.isArray(e)){return Promise.all(escape_quoted_promises(e)).then(unescape_quoted_promises)}return e}function escape_quoted_promises(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof QuotedPromise){t[r]=new Value(n)}else{t[r]=n}}return t}function unescape_quoted_promises(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof Value){t[r]=n.valueOf()}else{t[r]=n}}return t}var specials={LITERAL:Symbol["for"]("literal"),SPLICE:Symbol["for"]("splice"),SYMBOL:Symbol["for"]("symbol"),names:function e(){return Object.keys(this.__list__)},type:function e(t){try{return this.get(t).type}catch(e){console.log({name:t});console.log(e);return null}},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 LSymbol("quote-promise"),specials.LITERAL]];var builtins=defined_specials.map(function(e){return e[0]});Object.freeze(builtins);Object.defineProperty(specials,"__builtins__",{writable:false,value:builtins});defined_specials.forEach(function(e){var t=_slicedToArray(e,3),r=t[0],n=t[1],i=t[2];specials.append(r,n,i)});var Lexer=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;_classCallCheck(this,p);read_only(this,"__input__",e.replace(/\r/g,""));var a={};["_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 a[r]},set:function e(t){a[r]=t}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}_createClass(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 eof}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 eof}},{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 eof}for(var r=this._i;r=r){return eof}if(t+this._i>=r){return this.read_rest()}var n=this._i+t;var i=this.__input__.substring(this._i,n);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=n;return i}},{key:"peek_char",value:function e(){if(this._i>=this.__input__.length){return eof}return LCharacter(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 a=_slicedToArray(e,4),o=a[0],u=a[1],s=a[2],l=a[3];if(e.length!==5){throw new Error("Lexer: Invalid rule of length ".concat(e.length))}if(!n.match(o)){return false}if(!match_or_null(u,r)){return false}if(!match_or_null(s,i)){return false}if(l!==this._state){return false}return true}},{key:"next_token",value:function l(){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 a=[];for(var o=0,u=t.length;o1&&arguments[1]!==undefined?arguments[1]:{},r=t.env,n=t.meta,i=n===void 0?false:n,a=t.formatter,o=a===void 0?multiline_formatter:a;_classCallCheck(this,u);if(e instanceof LString){e=e.toString()}read_only(this,"_formatter",o,{hidden:true});read_only(this,"__lexer__",new Lexer(e));read_only(this,"__env__",r);read_only(this,"_meta",i,{hidden:true});read_only(this,"_refs",[],{hidden:true});read_only(this,"_state",{parentheses:0},{hidden:true})}_createClass(u,[{key:"resolve",value:function e(t){return this.__env__&&this.__env__.get(t,{throwError:false})}},{key:"peek",value:function(){var e=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:r=this.__lexer__.peek(true);if(!(r===eof)){t.next=4;break}return t.abrupt("return",eof);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()===eof)){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=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.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=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r,n,i,a;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:r=_nil,n=r;case 1:t.next=4;return this.peek();case 4:i=t.sent;if(!(i===eof)){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!==_nil)){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=Pair;t.next=20;return this._read_object();case 20:t.t1=t.sent;t.t2=_nil;a=new t.t0(t.t1,t.t2);if(r===_nil){r=a}else{n.cdr=a}n=a;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=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.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===eof)){t.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return t.abrupt("return",parse_argument(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 _evaluate(t,{env:this.__env__,error:function e(t){throw t}})}},{key:"read_object",value:function(){var e=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.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 DatumReference){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,r){var n=this._state.parentheses;var i;if(n<0){i=new Error("Parser: unexpected parenthesis");i.__code__=[r.toString()+")"]}else{i=new Error("Parser: expected parenthesis but eof found");var a=new RegExp("\\){".concat(n,"}$"));i.__code__=[t.toString().replace(a,"")]}throw i}},{key:"_resolve_object",value:function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function e(r){var n=this;var i;return _regeneratorRuntime.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(!is_plain_object(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 Pair)){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=_asyncToGenerator(_regeneratorRuntime.mark(function e(r){return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!(r instanceof Pair)){t.next=15;break}if(!(r.car instanceof DatumReference)){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 DatumReference)){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=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r,n,_,i,a,o,u,s,c,l,f;return _regeneratorRuntime.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===eof)){t.next=5;break}return t.abrupt("return",r);case 5:if(!is_special(r)){t.next=38;break}n=specials.get(r);_=is_builtin(r);this.skip();a=is_symbol_extension(r);if(!a){t.next=14;break}t.t0=undefined;t.next=17;break;case 14:t.next=16;return this._read_object();case 16:t.t0=t.sent;case 17:o=t.t0;if(_){t.next=25;break}u=this.__env__.get(n.symbol);if(!(typeof u==="function")){t.next=25;break}if(is_literal(r)){s=[o]}else if(o===_nil){s=[]}else if(o instanceof Pair){s=o.to_array(false)}if(!(s||a)){t.next=24;break}return t.abrupt("return",call_function(u,a?[]:s,{env:this.__env__,dynamic_env:this.__env__,use_dynamic:false}));case 24:throw new Error("Parse Error: Invalid parser extension "+"invocation ".concat(n.symbol));case 25:if(is_literal(r)){i=new Pair(n.symbol,new Pair(o,_nil))}else{i=new Pair(n.symbol,o)}if(!_){t.next=28;break}return t.abrupt("return",i);case 28:if(!(u instanceof Macro)){t.next=37;break}t.next=31;return this.evaluate(i);case 31:c=t.sent;if(!(c instanceof Pair||c instanceof LSymbol)){t.next=34;break}return t.abrupt("return",Pair.fromArray([LSymbol("quote"),c]));case 34:return t.abrupt("return",c);case 37:throw new Error("Parse Error: invalid parser extension: "+n.symbol);case 38:l=this.match_datum_ref(r);if(!(l!==null)){t.next=44;break}this.skip();if(!this._refs[l]){t.next=43;break}return t.abrupt("return",new DatumReference(l,this._refs[l]));case 43:throw new Error("Parse Error: invalid datum label #".concat(l,"#"));case 44:f=this.match_datum_label(r);if(!(f!==null)){t.next=51;break}this.skip();this._refs[f]=this._read_object();return t.abrupt("return",this._refs[f]);case 51:if(!this.is_close(r)){t.next=55;break}this.skip();t.next=61;break;case 55:if(!this.is_open(r)){t.next=60;break}this.skip();return t.abrupt("return",this.read_list());case 60:return t.abrupt("return",this.read_value());case 61:case"end":return t.stop()}}},e,this)}));function t(){return e.apply(this,arguments)}return t}()}]);return u}();var DatumReference=function(){function r(e,t){_classCallCheck(this,r);this.name=e;this.data=t}_createClass(r,[{key:"valueOf",value:function e(){return this.data}}]);return r}();function _parse(e,t){return _parse2.apply(this,arguments)}function _parse2(){_parse2=_wrapAsyncGenerator(_regeneratorRuntime.mark(function e(r,n){var i,a,o;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!n){if(global_env){n=global_env.get("**interaction-environment**",{throwError:false})}else{n=user_env}}i=new Parser(r,{env:n});case 3:t.next=6;return _awaitAsyncGenerator(i.read_object());case 6:o=t.sent;if(!i.balanced()){i.ballancing_error(o,a)}if(!(o===eof)){t.next=10;break}return t.abrupt("break",15);case 10:a=o;t.next=13;return o;case 13:t.next=3;break;case 15:case"end":return t.stop()}}},e)}));return _parse2.apply(this,arguments)}function unpromise(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(is_promise(e)){var n=e.then(t);if(r===null){return n}else{return n["catch"](r)}}if(e instanceof Array){return unpromise_array(e,t,r)}if(is_plain_object(e)){return unpromise_object(e,t,r)}return t(e)}function unpromise_array(t,r,e){if(t.find(is_promise)){return unpromise(promise_all(t),function(e){if(Object.isFrozen(t)){Object.freeze(e)}return r(e)},e)}return r(t)}function unpromise_object(t,e,r){var i=Object.keys(t);var n=[],a=[];var o=i.length;while(o--){var u=i[o];var s=t[u];n[o]=s;if(is_promise(s)){a.push(s)}}if(a.length){return unpromise(promise_all(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 read_only(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},i=n.hidden,a=i===void 0?false:i;Object.defineProperty(e,t,{value:r,configurable:true,enumerable:!a})}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=_asyncToGenerator(_regeneratorRuntime.mark(function e(r){var n,i,a,o,u,s,c;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:n=[];i=false;a=false;t.prev=3;u=_asyncIterator(r);case 5:t.next=7;return u.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);a=true;o=t.t0;case 19:t.prev=19;t.prev=20;if(!(i&&u["return"]!=null)){t.next=24;break}t.next=24;return u["return"]();case 24:t.prev=24;if(!a){t.next=27;break}throw o;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 _uniterate_async.apply(this,arguments)}function matcher(e,t){if(t instanceof RegExp){return function(e){return String(e).match(t)}}else if(is_function(t)){return t}throw new Error("Invalid matcher")}function doc(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__=trim_lines(r)}}if(e){t.__name__=e}else if(t.name&&!is_lambda(t)){t.__name__=t.name}return t}function trim_lines(e){return e.split("\n").map(function(e){return e.trim()}).join("\n")}function previousSexp(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 lineIndent(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 match(e,t){return l(e,t)===t.length;function l(r,n){function e(e,t){var r=_createForOfIteratorHelper(e),n;try{for(r.s();!(n=r.n()).done;){var i=n.value;var a=l(i,t);if(a!==-1){return a}}}catch(e){r.e(e)}finally{r.f()}return-1}function t(){return r[a]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function i(){var e=r[a+1];var t=n[u+1];if(e!==undefined&&t!==undefined){return l([e],[t])}}var a=0;var o={};for(var u=0;u0){continue}}else if(t()){return-1}}else if(r[a]instanceof Array){var c=l(r[a],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;a++;continue}else{return-1}a++}if(r.length!==a){return-1}return n.length}}function Formatter(e){this.__code__=e.replace(/\r/g,"")}Formatter.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:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(t){var r=Formatter.defaults;if(typeof t==="undefined"){return Object.assign({},r)}var n=t&&t.exceptions||{};var i=n.specials||[];var a=n.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},r),t),{},{exceptions:{specials:[].concat(_toConsumableArray(r.exceptions.specials),_toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(_toConsumableArray(r.exceptions.shift[1]),_toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(t){var r=tokenize(this.__code__,true);return this._indent(r,t)};Formatter.exception_shift=function(a,e){function t(e){if(!e.length){return false}if(e.indexOf(a)!==-1){return true}else{var t=e.filter(function(e){return e instanceof RegExp});if(!t.length){return false}var r=_createForOfIteratorHelper(t),n;try{for(r.s();!(n=r.n()).done;){var i=n.value;if(a.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()&&balanced(n)){return t.offset+n[0].col}else if(n.length===1){return t.offset+n[0].col+1}else{var a=-1;if(i){var o=Formatter.exception_shift(i.token,t);if(o!==-1){a=o}}if(a===-1){a=Formatter.exception_shift(n[1].token,t)}if(a!==-1){return t.offset+n[0].col+a}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 u=n.slice(2);for(var s=0;s")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,t=new Array(e),r=0;r")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/^[[(]$/;var p_e=/^[\])]$/;var not_p=/[^()[\]]/;var not_close=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],"+");var def_lambda_re=keywords_re("define","lambda","define-macro","syntax-rules");var non_def=/^(?!.*\b(?:[()[\]]|define(?:-macro)?|let(?:\*|rec|-env|-syntax|)?|lambda|syntax-rules)\b).*$/;var let_re=/^(?:#:)?(let(?:\*|rec|-env|-syntax)?)$/;function keywords_re(){for(var e=arguments.length,t=new Array(e),r=0;r0&&!i[e]){i[e]=previousSexp(n,e)}});var a=_createForOfIteratorHelper(t),p;try{for(a.s();!(p=a.n()).done;){var o=_slicedToArray(p.value,3),h=o[0],u=o[1],s=o[2];u=u.valueOf();var d=u>0?i[u]:n;var m=d.filter(function(e){return e.trim()&&!is_special(e)});var y=_(d);var v=match(h,m);var g=e.slice(r).find(function(e){return e.trim()&&!is_special(e)});if(v&&(s instanceof Ahead&&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){a.e(e)}finally{a.f()}}this.__code__=e.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function c(e){var t=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var r=tokenize(t,true);var n=this._options(e);var i=0;var a=0;for(var o=0;o0){n=Math.floor(t()*r);r--;var i=[e[n],e[r]];e[r]=i[0];e[n]=i[1]}return e}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(e){return new Pair(e,_nil)};Nil.prototype.to_array=function(){return[]};var _nil=new Nil;function Pair(e,t){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,t)}this.car=e;this.cdr=t}function to_array(a,o){return function e(t){typecheck(a,t,["pair","nil"]);if(t===_nil){return[]}var r=[];var n=t;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(o&&i instanceof Pair){i=this.get(a).call(this,i)}r.push(i);n=n.cdr}else if(n===_nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return r}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.to_array()))};Pair.prototype.length=function(){var e=0;var t=this;while(true){if(!t||t===_nil||!(t instanceof Pair)||t.haveCycles("cdr")){break}e++;t=t.cdr}return e};Pair.match=function(e,t){if(e instanceof LSymbol){return LSymbol.is(e,t)}else if(e instanceof Pair){return Pair.match(e.car,t)||Pair.match(e.cdr,t)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,t)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,t)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var r=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var n=new Map;function i(e){if(e instanceof Pair){if(n.has(e)){return n.get(e)}var t=new Pair;n.set(e,t);if(r){t.car=i(e.car)}else{t.car=e.car}t.cdr=i(e.cdr);t[__cycles__]=e[__cycles__];return t}return e}return i(this)};Pair.prototype.last_pair=function(){var e=this;while(true){if(e.cdr===_nil){return e}e=e.cdr}};Pair.prototype.to_array=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var t=[];if(this.car instanceof Pair){if(e){t.push(this.car.to_array())}else{t.push(this.car)}}else{t.push(this.car.valueOf())}if(this.cdr instanceof Pair){t=t.concat(this.cdr.to_array(e))}return t};Pair.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 Pair||r&&e instanceof Array&&e[__data__]){return e}if(t===false){var n=_nil;for(var i=e.length;i--;){n=new Pair(e[i],n)}return n}if(e.length&&!(e instanceof Array)){e=_toConsumableArray(e)}var a=_nil;var o=e.length;while(o--){var u=e[o];if(u instanceof Array){u=Pair.fromArray(u,t,r)}else if(typeof u==="string"){u=LString(u)}else if(typeof u==="number"&&!Number.isNaN(u)){u=LNumber(u)}a=new Pair(u,a)}return a};Pair.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 Pair&&t.car instanceof Pair){var n=t.car;var i=n.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=n.cdr;if(a instanceof Pair){a=a.to_object(e)}if(is_native(a)){if(!e){a=a.valueOf()}}r[i]=a;t=t.cdr}else{break}}return r};Pair.fromPairs=function(e){return e.reduce(function(e,t){return new Pair(new Pair(new LSymbol(t[0]),t[1]),e)},_nil)};Pair.fromObject=function(t){var e=Object.keys(t).map(function(e){return[e,t[e]]});return Pair.fromPairs(e)};Pair.prototype.reduce=function(e){var t=this;var r=_nil;while(true){if(t!==_nil){r=e(r,t.car);t=t.cdr}else{break}}return r};Pair.prototype.reverse=function(){if(this.haveCycles()){throw new Error("You can't reverse list that have cycles")}var e=this;var t=_nil;while(e!==_nil){var r=e.cdr;e.cdr=t;t=e;e=r}return t};Pair.prototype.transform=function(n){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var t=n(e.car);if(t instanceof Pair){t=i(t)}var r=n(e.cdr);if(r instanceof Pair){r=i(r)}return new Pair(t,r)}return e}return i(this)};Pair.prototype.map=function(e){if(typeof this.car!=="undefined"){return new Pair(e(this.car),this.cdr===_nil?_nil:this.cdr.map(e))}else{return _nil}};var repr=new Map;function is_plain_object(e){return e&&_typeof(e)==="object"&&e.constructor===Object}var props=Object.getOwnPropertyNames(Array.prototype);var array_methods=[];props.forEach(function(e){array_methods.push(Array[e],Array.prototype[e])});function is_array_method(e){e=unbind(e);return array_methods.includes(e)}function is_lips_function(e){return is_function(e)&&(is_lambda(e)||e.__doc__)}function user_repr(r){var e=r.constructor||Object;var n=is_plain_object(r);var i=is_function(r[Symbol.asyncIterator])||is_function(r[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,t){t=unbind(t);if(r.constructor===t&&(t===Object&&n&&!i||t!==Object)){a=e}})}return a}var str_mapping=new Map;[[true,"#t"],[false,"#f"],[null,"null"],[undefined,"#"]].forEach(function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];str_mapping.set(r,n)});function symbolize(r){if(r&&_typeof(r)==="object"){var n={};var e=Object.getOwnPropertySymbols(r);e.forEach(function(e){var t=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");n[t]=toString(r[e])});var t=Object.getOwnPropertyNames(r);t.forEach(function(e){var t=r[e];if(t&&_typeof(t)==="object"&&t.constructor===Object){n[e]=symbolize(t)}else{n[e]=toString(t)}});return n}return r}function get_props(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function has_own_function(e,t){return e.hasOwnProperty(t)&&is_function(e.toString)}function function_to_string(e){if(is_native_function(e)){return"#"}var t=e.prototype&&e.prototype.constructor;if(is_function(t)&&is_lambda(t)){if(e[__class__]&&t.hasOwnProperty("__name__")){var r=t.__name__;if(LString.isString(r)){r=r.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!is_lambda(e)){return"#")}else{return"#"}}var instances=new Map;[[Error,function(e){return e.message}],[Pair,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(_toConsumableArray(i)))}],[LCharacter,function(e,t){var r=t.quote;if(r){return e.toString()}return e.valueOf()}],[LString,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=_slicedToArray(e,2),r=t[0],n=t[1];instances.set(r,n)});var native_types=[LSymbol,LNumber,Macro,Values,InputPort,OutputPort,Environment,QuotedPromise];function toString(e,t,c){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(is_prototype(e)){return"#"}if(e){var r=e.constructor;if(instances.has(r)){for(var n=arguments.length,l=new Array(n>3?n-3:0),i=3;i"}if(e===null){return"null"}if(_typeof(e)==="object"){var o=e.constructor;if(!o){o=Object}var u;if(typeof o.__class__==="string"){u=o.__class__}else{var s=user_repr(e);if(s){if(is_function(s)){return s(e,t)}else{throw new Error("toString: Invalid repr value")}}u=o.name}if(is_function(e.toString)&&is_lambda(e.toString)){return e.toString().valueOf()}if(type(e)==="instance"){if(is_lambda(o)&&o.__name__){u=o.__name__.valueOf()}else if(!is_native_function(o)){u="instance"}}if(is_iterator(e,Symbol.iterator)){if(u){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(u){return"#")}return"#"}if(u!==""){return"#<"+u+">"}return"#"}if(typeof e!=="string"){return e.toString()}return e}function is_prototype(e){return e&&_typeof(e)==="object"&&e.hasOwnProperty&&e.hasOwnProperty("constructor")&&typeof e.constructor==="function"&&e.constructor.prototype===e}Pair.prototype.markCycles=function(){markCycles(this);return this};Pair.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[__cycles__]&&this[__cycles__][e])};function markCycles(e){var t=[];var i=[];var a=[];function o(e){if(!t.includes(e)){t.push(e)}}function u(e,t,r,n){if(r instanceof Pair){if(n.includes(r)){if(!a.includes(r)){a.push(r)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][t]=r;if(!i.includes(e)){i.push(e)}return true}}}var s=trampoline(function e(t,r){if(t instanceof Pair){delete t.ref;delete t[__cycles__];o(t);r.push(t);var n=u(t,"car",t.car,r);var i=u(t,"cdr",t.cdr,r);if(!n){s(t.car,r.slice())}if(!i){return new Thunk(function(){return e(t.cdr,r.slice())})}}});function r(e,t){if(e[__cycles__][t]instanceof Pair){var r=n.indexOf(e[__cycles__][t]);e[__cycles__][t]="#".concat(r,"#")}}s(e,[]);var n=t.filter(function(e){return a.includes(e)});n.forEach(function(e,t){e[__ref__]="#".concat(t,"=")});i.forEach(function(e){r(e,"car");r(e,"cdr")})}Pair.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[__ref__]){i.push(this[__ref__]+"(")}else if(!n){i.push("(")}var a;if(this[__cycles__]&&this[__cycles__].car){a=this[__cycles__].car}else{a=toString(this.car,e,true)}if(a!==undefined){i.push(a)}if(this.cdr instanceof Pair){if(this[__cycles__]&&this[__cycles__].cdr){i.push(" . ");i.push(this[__cycles__].cdr)}else{if(this.cdr[__ref__]){i.push(" . ")}else{i.push(" ")}var o=this.cdr.toString(e,{nested:true});i.push(o)}}else if(this.cdr!==_nil){i=i.concat([" . ",toString(this.cdr,e,true)])}if(!n||this[__ref__]){i.push(")")}return i.join("")};Pair.prototype.set=function(e,t){this[e]=t;if(t instanceof Pair){this.markCycles()}};Pair.prototype.append=function(e){if(e instanceof Array){return this.append(Pair.fromArray(e))}var t=this;if(t.car===undefined){if(e instanceof Pair){this.car=e.car;this.cdr=e.cdr}else{this.car=e}}else if(e!==_nil){while(true){if(t instanceof Pair&&t.cdr!==_nil){t=t.cdr}else{break}}t.cdr=e}return this};Pair.prototype.serialize=function(){return[this.car,this.cdr]};Pair.prototype[Symbol.iterator]=function(){var r=this;return{next:function e(){var t=r;r=t.cdr;if(t===_nil){return{value:undefined,done:true}}else{return{value:t.car,done:false}}}}};function abs(e){return e<0?-e:e}function seq_compare(e,t){var r=_toArray(t),n=r[0],i=r.slice(1);while(i.length>0){var a=i,o=_slicedToArray(a,1),u=o[0];if(!e(n,u)){return false}var s=i;var c=_toArray(s);n=c[0];i=c.slice(1)}return true}function equal(e,t){if(is_function(e)){return is_function(t)&&unbind(e)===unbind(t)}else if(e instanceof LNumber){if(!(t instanceof LNumber)){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 equal(LNumber(e),LNumber(t))}else if(e instanceof LCharacter){if(!(t instanceof LCharacter)){return false}return e.__char__===t.__char__}else{return e===t}}function same_atom(e,t){if(type(e)!==type(t)){return false}if(!is_atom(e)){return false}if(e instanceof RegExp){return e.source===t.source}if(e instanceof LString){return e.valueOf()===t.valueOf()}return equal(e,t)}function is_atom(e){return e instanceof LSymbol||LString.isString(e)||e===_nil||e===null||e instanceof LCharacter||e instanceof LNumber||e===true||e===false}var truncate=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 Macro(e,t,r,n){if(typeof this!=="undefined"&&this.constructor!==Macro||typeof this==="undefined"){return new Macro(e,t)}typecheck("Macro",e,"string",1);typecheck("Macro",t,"function",2);if(r){if(n){this.__doc__=r}else{this.__doc__=trim_lines(r)}}this.__name__=e;this.__fn__=t}Macro.defmacro=function(e,t,r,n){var i=new Macro(e,t,r,n);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,t,r){var n=t.env,i=_objectWithoutProperties(t,_excluded2);var a=_objectSpread(_objectSpread({},i),{},{macro_expand:r});var o=this.__fn__.call(n,e,a,this.__name__);return o};Macro.prototype.toString=function(){return"#")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(c){return function(){var r=_asyncToGenerator(_regeneratorRuntime.mark(function e(r,v){var a,g,n,i,s,D,x,E,L,A,S,b,o,w,u;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:u=function e(){u=_asyncToGenerator(_regeneratorRuntime.mark(function e(r,n,i){var _,a,o,p,u,h,s,d,c,m,l,f,y;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!(r instanceof Pair&&r.car instanceof LSymbol)){t.next=50;break}if(!r[__data__]){t.next=3;break}return t.abrupt("return",r);case 3:_=r.car.valueOf();a=i.get(r.car,{throwError:false});o=D(r.car);p=o||x(a,r)||E(a);if(!(p&&r.cdr.car instanceof Pair)){t.next=28;break}if(!o){t.next=15;break}g=A(r.cdr.car);t.next=12;return b(r.cdr.car,n);case 12:u=t.sent;t.next=17;break;case 15:g=L(r.cdr.car);u=r.cdr.car;case 17:t.t0=Pair;t.t1=r.car;t.t2=Pair;t.t3=u;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(!S(_,a)){t.next=50;break}h=a instanceof Syntax?r:r.cdr;t.next=32;return a.invoke(h,_objectSpread(_objectSpread({},v),{},{env:i}),true);case 32:s=t.sent;if(!(a instanceof Syntax)){t.next=41;break}d=s,c=d.expr,m=d.scope;if(!(c instanceof Pair)){t.next=40;break}if(!(n!==-1&&n<=1||n")}return"#"};Syntax.className="syntax";var SyntaxParameter=function(e){_inherits(r,e);var t=_createSuper(r);function r(){_classCallCheck(this,r);return t.apply(this,arguments)}return _createClass(r)}(Syntax);Syntax.Parameter=SyntaxParameter;function extract_patterns(e,t,w,D){var r=arguments.length>4&&arguments[4]!==undefined?arguments[4]:{};var x={"...":{symbols:{},lists:[]},symbols:{}};var E=r.expansion,S=r.define;function L(e){if(is_debug()){console.log(e)}}L(w);function A(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;L({code:t&&toString(t,true),pattern:e&&toString(e,true)});if(is_atom(e)&&!(e instanceof LSymbol)){return same_atom(e,t)}if(e instanceof LSymbol&&w.includes(e.literal())){var c=E.ref(t);if(LSymbol.is(t,e)){if(typeof c==="undefined"){return true}return c===S||c===global_env}return false}if(e instanceof Pair&&e.car instanceof Pair&&e.car.cdr instanceof Pair&&LSymbol.is(e.car.cdr.car,D)){L(">> 0");if(t===_nil){L({pattern:e.toString()});if(e.car.car instanceof LSymbol){if(e.car.cdr instanceof Pair&&LSymbol.is(e.car.cdr.car,D)){var l=e.car.car.valueOf();var f=e.last_pair();if(LSymbol.is(f.car,D)){x["..."].symbols[l]=null;return true}else{return false}}var _=e.car.car.valueOf();if(x["..."].symbols[_]){throw new Error("syntax: named ellipsis can only "+"appear onces")}x["..."].symbols[_]=t}}}if(e instanceof Pair&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,D)){if(e.cdr.cdr!==_nil){if(e.cdr.cdr instanceof Pair){var p=e.cdr.cdr.length();var h=t.length();var i=t;while(h-1>p){i=i.cdr;h--}var d=i.cdr;i.cdr=_nil;if(!A(e.cdr.cdr,d,r,n)){return false}}}if(e.car instanceof LSymbol){var a=e.car.__name__;if(x["..."].symbols[a]&&!r.includes(a)&&!n){throw new Error("syntax: named ellipsis can only appear onces")}L(">> 1");if(t===_nil){L(">> 2");if(n){L("NIL");x["..."].symbols[a]=_nil}else{L("NULL");x["..."].symbols[a]=null}}else if(t instanceof Pair&&(t.car instanceof Pair||t.car===_nil)){L(">> 3 "+n);if(n){if(x["..."].symbols[a]){var o=x["..."].symbols[a];if(o===_nil){o=new Pair(_nil,new Pair(t,_nil))}else{o=o.append(new Pair(t,_nil))}x["..."].symbols[a]=o}else{x["..."].symbols[a]=new Pair(t,_nil)}}else{L(">> 4");x["..."].symbols[a]=new Pair(t,_nil)}}else{L(">> 6");if(t instanceof Pair){L(">> 7 "+n);r.push(a);if(!x["..."].symbols[a]){x["..."].symbols[a]=new Pair(t,_nil)}else{var m=x["..."].symbols[a];x["..."].symbols[a]=m.append(new Pair(t,_nil))}L({IIIIII:x["..."].symbols[a].toString()})}else{L(">> 8");return false}}return true}else if(e.car instanceof Pair){var y=_toConsumableArray(r);if(t===_nil){L(">> 9");x["..."].lists.push(_nil);return true}L(">> 10");var v=t;while(v instanceof Pair){if(!A(e.car,v.car,y,true)){return false}v=v.cdr}return true}return false}if(e instanceof LSymbol){if(LSymbol.is(e,D)){throw new Error("syntax: invalid usage of ellipsis")}L(">> 11");var u=e.__name__;if(w.includes(u)){return true}L({name:u,ellipsis:n});if(n){x["..."].symbols[u]=x["..."].symbols[u]||[];x["..."].symbols[u].push(t)}x.symbols[u]=t;if(!x.symbols[u]);return true}if(e instanceof Pair&&t instanceof Pair){L(">> 12");L({a:12,code:t&&t.toString(),pattern:e.toString()});if(t.cdr===_nil){var g=e.car instanceof LSymbol&&e.cdr instanceof LSymbol;if(g){if(!A(e.car,t.car,r,n)){return false}L(">> 12 | 1");var s=e.cdr.valueOf();if(!(s in x.symbols)){x.symbols[s]=_nil}s=e.car.valueOf();if(!(s in x.symbols)){x.symbols[s]=t.car}return true}}L({pattern:e.toString(),code:t.toString()});if(e.cdr instanceof Pair&&e.car instanceof LSymbol&&e.cdr.cdr instanceof Pair&&e.cdr.car instanceof LSymbol&&LSymbol.is(e.cdr.cdr.car,D)&&e.cdr.cdr.cdr instanceof Pair&&!LSymbol.is(e.cdr.cdr.cdr.car,D)&&A(e.car,t.car,r,n)&&A(e.cdr.cdr.cdr,t.cdr,r,n)){var b=e.cdr.car.__name__;L({pattern:e.car.toString(),code:t.car.toString(),name:b});if(w.includes(b)){return true}x["..."].symbols[b]=null;return true}L("recur");if(A(e.car,t.car,r,n)&&A(e.cdr,t.cdr,r,n)){return true}}else if(e===_nil&&(t===_nil||t===undefined)){return true}else if(e.car instanceof Pair&&LSymbol.is(e.car.car,D)){throw new Error("syntax: invalid usage of ellipsis")}else{return false}}if(A(e,t)){return x}}function clear_gensyms(e,i){function a(t){if(t instanceof Pair){if(!i.length){return t}var e=a(t.car);var r=a(t.cdr);return new Pair(e,r)}else if(t instanceof LSymbol){var n=i.find(function(e){return e.gensym===t});if(n){return LSymbol(n.name)}return t}else{return t}}return a(e)}function transform_syntax(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var k=e.bindings,t=e.expr,P=e.scope,o=e.symbols,l=e.names,C=e.ellipsis;var c={};function u(e){if(e instanceof LSymbol){return true}return["string","symbol"].includes(_typeof(e))}function B(e){if(!u(e)){var t=type(e);throw new Error("syntax: internal error, need symbol got ".concat(t))}var r=e.valueOf();if(r===C){throw new Error("syntax: internal error, ellipis not transformed")}var n=_typeof(r);if(["string","symbol"].includes(n)){if(r in k.symbols){return k.symbols[r]}else if(n==="string"&&r.match(/\./)){var i=r.split(".");var a=i[0];if(a in k.symbols){return Pair.fromArray([LSymbol("."),k.symbols[a]].concat(i.slice(1).map(function(e){return LString(e)})))}}}if(o.includes(r)){return LSymbol(r)}return s(r)}function O(e){if(is_debug()){console.log(e)}}function s(e){if(!c[e]){var t=P.ref(e);var r=gensym(e);if(t){var n=P.get(e);P.set(r,n)}else{var i=P.get(e,{throwError:false});if(typeof i!=="undefined"){P.set(r,i)}}l.push({name:e,gensym:r});c[e]=r;if(typeof e==="string"&&e.match(/\./)){var a=e.split(".").filter(Boolean),o=_toArray(a),u=o[0],s=o.slice(1);if(c[u]){hidden_prop(r,"__object__",[c[u]].concat(_toConsumableArray(s)))}}}return c[e]}function I(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:function(){};var i=r.nested;O(" ==> "+e.toString(true));O(t);if(e instanceof LSymbol){var a=e.valueOf();O("[t 1");if(t[a]){if(t[a]instanceof Pair){var c=t[a],l=c.car,f=c.cdr;if(i){var _=l.car,p=l.cdr;if(p!==_nil){n(a,new Pair(p,_nil))}return _}if(f!==_nil){n(a,f)}return l}else if(t[a]instanceof Array){n(a,t[a].slice(1));return t[a][0]}}return B(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,C)){O("[t 2");var o=e.car.valueOf();var u=t[o];O({expr:e.toString(true),name:o,bindings:t,item:u});if(u===null){return}else if(u){O({b:t[o].toString()});if(u instanceof Pair){O("[t 2 Pair "+i);O({______:u.toString()});var s=u.car,h=u.cdr;if(i){if(h!==_nil){O("|| next 1");n(o,h)}O({car:s.toString()});return s}else{if(s.cdr!==_nil){O("|| next 2");n(o,new Pair(s.cdr,h))}O({car:s.car.toString()});return s.car}}else if(u instanceof Array){O("[t 2 Array "+i);if(i){n(o,u.slice(1));return Pair.fromArray(u)}else{var d=u.slice(1);if(d.length){n(o,d)}return u[0]}}else{return u}}}O("[t 3 recur "+e.toString());var m=I(e.car,t,r,n);var y=I(e.cdr,t,r,n);return new Pair(m,y)}return e}function j(t,r){var e=Object.values(t);var n=Object.getOwnPropertySymbols(t);if(n.length){e.push.apply(e,_toConsumableArray(n.map(function(e){return t[e]})))}return e.length&&e.every(function(e){if(e===null){return!r}return e instanceof Pair||e===_nil||e instanceof Array&&e.length})}function R(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;O("traverse>> "+toString(i));if(i instanceof Pair){if(!e&&i.car instanceof Pair&&LSymbol.is(i.car.car,C)){return N(i.car.cdr,{disabled:true})}if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,C)&&!e){O(">> 1");var t=k["..."].symbols;var l=Object.values(t);if(l.length&&l.every(function(e){return e===null})){return N(i.cdr.cdr,{disabled:e})}var f=R(t);var a=i.car instanceof LSymbol&&LSymbol.is(i.cdr.cdr.car,C);if(i.car instanceof Pair||a){if(k["..."].lists[0]===_nil){return _nil}var _=i.car;if(a){_=new Pair(i.car,new Pair(i.cdr.car,_nil))}O(">> 2");var o;if(f.length){O(">> 2 (a)");var u=_objectSpread({},t);o=_nil;var p=function e(){if(!j(u)){return"break"}var n={};var t=function e(t,r){n[t]=r};var r=I(_,u,{nested:true},t);if(r!==undefined){if(a){if(o===_nil){o=r}else{o=o.append(r)}}else{o=new Pair(r,o)}}u=n};while(true){var h=p();if(h==="break")break}if(o!==_nil&&!a){o=o.reverse()}if(i.cdr.cdr!==_nil&&!LSymbol.is(i.cdr.cdr.car,C)){var d=N(i.cdr.cdr,{disabled:e});return o.append(d)}return o}else{O(">> 3");var m=I(i.car,t,{nested:true});if(m){return new Pair(m,_nil)}return _nil}}else if(i.car instanceof LSymbol){O(">> 4");if(LSymbol.is(i.cdr.cdr.car,C)){O(">> 4 (a)")}else{O(">> 4 (b)")}var y=i.car.__name__;var s=_defineProperty({},y,t[y]);var v=t[y]===null;var c=_nil;var g=function e(){if(!j(s,true)){O({bind:s});return"break"}var n={};var t=function e(t,r){n[t]=r};var r=I(i,s,{nested:false},t);O({value:r.toString()});if(typeof r!=="undefined"){c=new Pair(r,c)}s=n};while(true){var b=g();if(b==="break")break}if(c!==_nil){c=c.reverse()}if(i.cdr instanceof Pair){if(i.cdr.cdr instanceof Pair||i.cdr.cdr instanceof LSymbol){var w=N(i.cdr.cdr,{disabled:e});if(v){return w}O("<<<< 1");c.append(w)}}O("<<<< 2");return c}}var D=N(i.car,{disabled:e});var r;var x;if(i.car instanceof LSymbol){var E=P.get(i.car,{throwError:false});x=E instanceof Macro&&E.__name__==="syntax-rules"}if(x){if(i.cdr.car instanceof LSymbol){r=new Pair(N(i.cdr.car,{disabled:e}),new Pair(i.cdr.cdr.car,N(i.cdr.cdr.cdr,{disabled:e})))}else{r=new Pair(i.cdr.car,N(i.cdr.cdr,{disabled:e}))}O("REST >>>> "+r.toString())}else{r=N(i.cdr,{disabled:e})}O({a:true,car:toString(i.car),cdr:toString(i.cdr),head:toString(D),rest:toString(r)});return new Pair(D,r)}if(i instanceof LSymbol){if(e&&LSymbol.is(i,C)){return i}var L=Object.keys(k["..."].symbols);var A=i.literal();if(L.includes(A)){var S="missing ellipsis symbol next to name `".concat(A,"'");throw new Error("syntax-rules: ".concat(S))}var F=B(i);if(typeof F!=="undefined"){return F}}return i}return N(t,{})}function is_null(e){return is_undef(e)||e===_nil||e===null}function is_function(e){return typeof e==="function"&&typeof e.bind==="function"}function is_continuation(e){return e instanceof Continuation}function is_context(e){return e instanceof LambdaContext}function is_parameter(e){return e instanceof Parameter}function is_pair(e){return e instanceof Pair}function is_env(e){return e instanceof Environment}function is_callable(e){return is_function(e)||is_continuation(e)||is_parameter(e)}function is_promise(e){if(e instanceof QuotedPromise){return false}if(e instanceof Promise){return true}return e&&is_function(e.then)}function is_undef(e){return typeof e==="undefined"}function box(e){switch(_typeof(e)){case"string":return LString(e);case"bigint":return LNumber(e);case"number":if(Number.isNaN(e)){return nan}else{return LNumber(e)}}return e}function map_object(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 unbox(t){var e=[LString,LNumber].some(function(e){return t instanceof e});if(e){return t.valueOf()}if(t instanceof Array){return t.map(unbox)}if(t instanceof QuotedPromise){delete t.then}if(is_plain_object(t)){return map_object(t,unbox)}return t}function patch_value(e,t){if(e instanceof Pair){e.markCycles();return quote(e)}if(is_function(e)){if(t){return bind(e,t)}}return box(e)}function unbind(e){if(is_bound(e)){return e[__fn__]}return e}function bind(e,t){if(e[Symbol["for"]("__bound__")]){return e}var r=e.bind(t);var n=Object.getOwnPropertyNames(e);var i=_createForOfIteratorHelper(n),a;try{for(i.s();!(a=i.n()).done;){var o=a.value;if(filter_fn_names(o)){try{r[o]=e[o]}catch(e){}}}}catch(e){i.e(e)}finally{i.f()}hidden_prop(r,"__fn__",e);hidden_prop(r,"__context__",t);hidden_prop(r,"__bound__",true);if(is_native_function(e)){hidden_prop(r,"__native__",true)}if(is_plain_object(t)&&is_lambda(e)){hidden_prop(r,"__method__",true)}r.valueOf=function(){return e};return r}function is_object_bound(e){return is_bound(e)&&e[Symbol["for"]("__context__")]===Object}function is_bound(e){return!!(is_function(e)&&e[__fn__])}function lips_context(e){if(is_function(e)){var t=e[__context__];if(t&&(t===lips||t.constructor&&t.constructor.__class__)){return true}}return false}function is_port(e){return e instanceof InputPort||e instanceof OutputPort}function is_port_method(e){if(is_function(e)){if(is_port(e[__context__])){return true}}return false}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 exluded_names=["name","length","caller","callee","arguments","prototype"];function filter_fn_names(e){return!exluded_names.includes(e)}function hidden_prop(e,t,r){Object.defineProperty(e,Symbol["for"](t),{get:function e(){return r},set:function e(){},configurable:false,enumerable:false})}function set_fn_length(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 is_lambda(e){return e&&e[__lambda__]}function is_method(e){return e&&e[__method__]}function is_raw_lambda(e){return is_lambda(e)&&!e[__prototype__]&&!is_method(e)&&!is_port_method(e)}function is_native_function(e){var t=Symbol["for"]("__native__");return is_function(e)&&e.toString().match(/\{\s*\[native code\]\s*\}/)&&(e.name.match(/^bound /)&&e[t]===true||!e.name.match(/^bound /)&&!e[t])}function let_macro(e){var b;switch(e){case Symbol["for"]("letrec"):b="letrec";break;case Symbol["for"]("let"):b="let";break;case Symbol["for"]("let*"):b="let*";break;default:throw new Error("Invalid let_macro value")}return Macro.defmacro(b,function(t,e){var l=e.dynamic_env;var f=e.error,n=e.macro_expand,y=e.use_dynamic;var _;if(t.car instanceof LSymbol){if(!(t.cdr.car instanceof Pair||t.cdr.car===_nil)){throw new Error("let require list of pairs")}var r;if(t.cdr.car===_nil){_=_nil;r=_nil}else{r=t.cdr.car.map(function(e){return e.car});_=t.cdr.car.map(function(e){return e.cdr.car})}return Pair.fromArray([LSymbol("letrec"),[[t.car,Pair(LSymbol("lambda"),Pair(r,t.cdr.cdr))]],Pair(t.car,_)])}else if(n){return}var p=this;_=global_env.get("list->array")(t.car);var h=p.inherit(b);var d,m;if(b==="let*"){m=h}else if(b==="let"){d=[]}var v=0;function g(){var e=new Pair(new LSymbol("begin"),t.cdr);return _evaluate(e,{env:h,dynamic_env:h,use_dynamic:y,error:f})}return function t(){var r=_[v++];l=b==="let*"?h:p;if(!r){if(d&&d.length){var e=d.map(function(e){return e.value});var n=e.filter(is_promise);if(n.length){return promise_all(e).then(function(e){for(var t=0,r=e.length;t1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=t.error;var i=this;var a=this;var o=[];var u=e;while(u instanceof Pair){o.push(_evaluate(u.car,{env:i,dynamic_env:a,use_dynamic:r,error:n}));u=u.cdr}var s=o.filter(is_promise).length;if(s){return promise_all(o).then(c.bind(this))}else{return c.call(this,o)}})}function guard_math_call(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n2?n-2:0),a=2;a1&&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=o){return a.apply(this,n)}else{return i}}return i.apply(this,arguments)}}function limit(n,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,t=new Array(e),r=0;r1){e=e.toLowerCase();if(LCharacter.__names__[e]){t=e;e=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{t=LCharacter.__rev_names__[e]}Object.defineProperty(this,"__char__",{value:e,enumerable:true});if(t){Object.defineProperty(this,"__name__",{value:t,enumerable:true})}}LCharacter.__names__=characters;LCharacter.__rev_names__={};Object.keys(LCharacter.__names__).forEach(function(e){var t=LCharacter.__names__[e];LCharacter.__rev_names__[t]=e});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__};function LString(e){if(typeof this!=="undefined"&&!(this instanceof LString)||typeof this==="undefined"){return new LString(e)}if(e instanceof Array){this.__string__=e.map(function(e,t){typecheck("LString",e,"character",t+1);return e.toString()}).join("")}else{this.__string__=e.valueOf()}}{var ignore=["length","constructor"];var _keys=Object.getOwnPropertyNames(String.prototype).filter(function(e){return!ignore.includes(e)});var wrap=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 LNumber){return e}if(typeof this!=="undefined"&&!(this instanceof LNumber)||typeof this==="undefined"){return new LNumber(e,t)}if(typeof e==="undefined"){throw new Error("Invalid LNumber constructor call")}var r=LNumber.getType(e);if(LNumber.types[r]){return LNumber.types[r](e,t)}var n=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!n){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(n){var c=e,a=_slicedToArray(c,2),o=a[0],u=a[1];if(o instanceof LString){o=o.valueOf()}if(u instanceof LNumber){u=u.valueOf()}var l=o.match(/^([+-])/);var f=false;if(l){o=o.replace(/^[+-]/,"");if(l[1]==="-"){f=true}}}if(Number.isNaN(e)){return LFloat(e)}else if(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(n){var s;switch(u){case 8:s="0o";break;case 16:s="0x";break;case 2:s="0b";break;case 10:s="";break}if(typeof s==="undefined"){var _=BigInt(u);i=_toConsumableArray(o).map(function(e,t){return BigInt(parseInt(e,u))*pow(_,BigInt(t))}).reduce(function(e,t){return e+t})}else{i=BigInt(s+o)}}else{i=BigInt(e)}if(f){i*=BigInt(-1)}}else{i=e}return LBigInteger(i,true)}else if(typeof BN!=="undefined"&&!(e instanceof BN)){if(e instanceof Array){return LBigInteger(_construct(BN,_toConsumableArray(e)))}return LBigInteger(new BN(e))}else if(n){this.constant(parseInt(o,u),"integer")}else{this.constant(e,"integer")}}LNumber.prototype.constant=function(e,t){Object.defineProperty(this,"__value__",{value:e,enumerable:true});Object.defineProperty(this,"__type__",{value:t,enumerable:true})};LNumber.types={float:function e(t){return new LFloat(t)},complex:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!LNumber.isComplex(t)){t={im:0,re:t}}return new LComplex(t,r)},rational:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!LNumber.isRational(t)){t={num:t,denom:1}}return new LRational(t,r)}};LNumber.prototype.serialize=function(){return this.__value__};LNumber.prototype.isNaN=function(){return Number.isNaN(this.__value__)};LNumber.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}}};LNumber.isFloat=function e(t){return t instanceof LFloat||Number(t)===t&&t%1!==0};LNumber.isNumber=function(e){return e instanceof LNumber||LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){if(!e){return false}var t=e instanceof LComplex||(LNumber.isNumber(e.im)||Number.isNaN(e.im))&&(LNumber.isNumber(e.re)||Number.isNaN(e.re));return t};LNumber.isRational=function(e){if(!e){return false}return e instanceof LRational||LNumber.isNumber(e.num)&&LNumber.isNumber(e.denom)};LNumber.isInteger=function(e){if(!(LNumber.isNative(e)||e instanceof LNumber)){return false}if(LNumber.isFloat(e)){return false}if(LNumber.isRational(e)){return false}if(LNumber.isComplex(e)){return false}return true};LNumber.isNative=function(e){return typeof e==="bigint"||typeof e==="number"};LNumber.isBigInteger=function(e){return e instanceof LBigInteger||typeof e==="bigint"||LNumber.isBN(e)};LNumber.isBN=function(e){return typeof BN!=="undefined"&&e instanceof BN};LNumber.getArgsType=function(e,t){if(e instanceof LFloat||t instanceof LFloat){return LFloat}if(e instanceof LBigInteger||t instanceof LBigInteger){return LBigInteger}return LNumber};LNumber.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()};LNumber.prototype.asType=function(e){var t=LNumber.getType(this);return LNumber.types[t]?LNumber.types[t](e):LNumber(e)};LNumber.prototype.isBigNumber=function(){return typeof this.__value__==="bigint"||typeof BN!=="undefined"&&!(this.value instanceof BN)};["floor","ceil","round"].forEach(function(e){LNumber.prototype[e]=function(){if(this["float"]||LNumber.isFloat(this.__value__)){return LNumber(Math[e](this.__value__))}else{return LNumber(Math[e](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()}};var matrix=function(){var e=function e(t,r){return[t,r]};return{bigint:{bigint:e,float:function e(t,r){return[LFloat(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[LFloat(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&&LFloat(r.valueOf())]},integer:function e(t,r){return[t,r&&LFloat(r.valueOf())]},float:e,rational:function e(t,r){return[t,r&&LFloat(r.valueOf())]},complex:function e(t,r){return[{re:t,im:LFloat(0)},r]}},complex:{bigint:t("bigint"),integer:t("integer"),float:t("float"),rational:t("rational"),complex:function l(e,t){var r=LNumber.coerce(e.__re__,t.__re__),n=_slicedToArray(r,2),i=n[0],a=n[1];var o=LNumber.coerce(e.__im__,t.__im__),u=_slicedToArray(o,2),s=u[0],c=u[1];return[{im:s,re:i},{im:c,re:a}]}},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[LFloat(t.valueOf()),r]},rational:e,complex:function e(t,r){return[{im:coerce(t.__type__,r.__im__.__type__,0)[0],re:coerce(t.__type__,r.__re__.__type__,t)[0]},{im:coerce(t.__type__,r.__im__.__type__,r.__im__)[0],re:coerce(t.__type__,r.__re__.__type__,r.__re__)[0]}]}}};function t(r){return function(e,t){return[{im:coerce(r,e.__im__.__type__,0,e.__im__)[1],re:coerce(r,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(r,e.__im__.__type__,0,0)[1],re:coerce(r,t.__type__,0,t)[1]}]}}}();function coerce(e,t,r,n){return matrix[e][t](r,n)}LNumber.coerce=function(e,t){var r=LNumber.getType(e);var n=LNumber.getType(t);if(!matrix[r]){throw new Error("LNumber::coerce unknown lhs type ".concat(r))}else if(!matrix[r][n]){throw new Error("LNumber::coerce unknown rhs type ".concat(n))}var i=matrix[r][n](e,t);return i.map(function(e){return LNumber(e,true)})};LNumber.prototype.coerce=function(e){if(!(typeof e==="number"||e instanceof LNumber)){throw new Error("LNumber: you can't coerce ".concat(type(e)))}if(typeof e==="number"){e=LNumber(e)}return LNumber.coerce(this,e)};LNumber.getType=function(e){if(e instanceof LNumber){return e.__type__}if(LNumber.isFloat(e)){return"float"}if(LNumber.isComplex(e)){return"complex"}if(LNumber.isRational(e)){return"rational"}if(typeof e==="number"){return"integer"}if(typeof BigInt!=="undefined"&&typeof e!=="bigint"||typeof BN!=="undefined"&&!(e instanceof BN)){return"bigint"}};LNumber.prototype.isFloat=function(){return!!(LNumber.isFloat(this.__value__)||this["float"])};var mapping={add:"+",sub:"-",mul:"*",div:"/",rem:"%",or:"|",and:"&",neg:"~",shl:">>",shr:"<<"};var rev_mapping={};Object.keys(mapping).forEach(function(t){rev_mapping[mapping[t]]=t;LNumber.prototype[t]=function(e){return this.op(mapping[t],e)}});LNumber._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 LComplex)||typeof this==="undefined"){return new LComplex(e,t)}if(e instanceof LComplex){return LComplex({im:e.__im__,re:e.__re__})}if(LNumber.isNumber(e)&&t){if(!t){return Number(e)}}else if(!LNumber.isComplex(e)){var r="Invalid constructor call for LComplex expect &(:im :re ) object but got ".concat(toString(e));throw new Error(r)}var n=e.im instanceof LNumber?e.im:LNumber(e.im);var i=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,i)}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.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})};LComplex.prototype.serialize=function(){return{re:this.__re__,im:this.__im__}};LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var t=LFloat(this.__im__).toRational(e);var r=LFloat(this.__re__).toRational(e);return LComplex({im:t,re:r})}return this};LComplex.prototype.pow=function(e){throw new Error("Not yet implemented")};LComplex.prototype.add=function(e){return this.complex_op("add",e,function(e,t,r,n){return{re:e.add(t),im:r.add(n)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,t=this.__im__;var r,n;if(e instanceof LFloat){r=e.toRational().mul(e.toRational())}else{r=e.mul(e)}if(t instanceof LFloat){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__))}};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 e=this.modulus();var t,r;if(e.cmp(0)===0){t=r=e}else if(this.__re__.cmp(0)===1){t=LFloat(.5).mul(e.add(this.__re__)).sqrt();r=this.__im__.div(t).div(2)}else{r=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){r=r.sub()}t=this.__im__.div(r).div(2)}return LComplex({im:r,re:t})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var t=this.__re__.div(e);var r=this.__im__.div(e);return LComplex({re:t,im:r})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}if(this.cmp(e)===0){var n=this.coerce(e),i=_slicedToArray(n,2),l=i[0],a=i[1];var f=l.__im__.div(a.__im__);return f.coerce(a.__re__)[0]}var _=this.coerce(e),o=_slicedToArray(_,2),p=o[0],u=o[1];var s=u.factor();var h=u.conjugate();var c=p.mul(h);if(!LNumber.isComplex(c)){return c.div(s)}var d=c.__re__.op("/",s);var m=c.__im__.op("/",s);return LComplex({re:d,im:m})};LComplex.prototype.sub=function(e){return this.complex_op("sub",e,function(e,t,r,n){return{re:e.sub(t),im:r.sub(n)}})};LComplex.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})};LComplex.prototype.complex_op=function(e,t,i){var a=this;var r=function e(t,r){var n=i(a.__re__,t,a.__im__,r);if("im"in n&&"re"in n){if(n.im.cmp(0)===0){return n.re}return LComplex(n,true)}return n};if(typeof t==="undefined"){return r()}if(LNumber.isNumber(t)&&!LNumber.isComplex(t)){if(!(t instanceof LNumber)){t=LNumber(t)}var n=t.asType(0);t={__im__:n,__re__:t}}else if(!LNumber.isComplex(t)){throw new Error("[LComplex::".concat(e,"] Invalid value"))}var o=t.__re__ instanceof LNumber?t.__re__:this.__re__.asType(t.__re__);var u=t.__im__ instanceof LNumber?t.__im__:this.__im__.asType(t.__im__);return r(o,u)};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,t){var r=LComplex._op[e];return this[r](t)};LComplex.prototype.cmp=function(e){var t=this.coerce(e),r=_slicedToArray(t,2),n=r[0],i=r[1];var a=n.__re__.coerce(i.__re__),o=_slicedToArray(a,2),u=o[0],l=o[1];var s=u.cmp(l);if(s!==0){return s}else{var f=n.__im__.coerce(i.__im__),c=_slicedToArray(f,2),_=c[0],p=c[1];return _.cmp(p)}};LComplex.prototype.valueOf=function(){return[this.__re__,this.__im__].map(function(e){return e.valueOf()})};LComplex.prototype.toString=function(){var e;if(this.__re__.cmp(0)!==0){e=[toString(this.__re__)]}else{e=[]}var t=this.__im__.valueOf();var r=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(t);var n=toString(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 LFloat(e){if(typeof this!=="undefined"&&!(this instanceof LFloat)||typeof this==="undefined"){return new LFloat(e)}if(!LNumber.isNumber(e)){throw new Error("Invalid constructor call for LFloat")}if(e instanceof LNumber){return LFloat(e.valueOf())}if(typeof e==="number"){if(Object.is(e,-0)){Object.defineProperty(this,"_minus",{value:true})}this.constant(e,"float")}}LFloat.prototype=Object.create(LNumber.prototype);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 e=this.__value__.toString();if(!LNumber.isFloat(this.__value__)&&!e.match(/e/i)){var t=e+".0";return this._minus?"-"+t:t}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,t){if(t instanceof LNumber){t=t.__value__}var r=LNumber._ops[e];if(e==="/"&&this.__value__===0&&t===0){return NaN}return LFloat(r(this.__value__,t))};LFloat.prototype.toRational=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){return toRational(this.__value__.valueOf())}return approxRatio(e.valueOf())(this.__value__.valueOf())};LFloat.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){var t=LFloat(Math.sqrt(-e));return LComplex({re:0,im:t})}return LFloat(Math.sqrt(e))};LFloat.prototype.abs=function(){var e=this.valueOf();if(e<0){e=-e}return LFloat(e)};var toRational=approxRatio(1e-10);function approxRatio(n){return function(e){var t=function e(n,t,r){var i=function e(t,r){return r0){i=simplest_rational2(n,r)}else if(n.cmp(r)<=0){i=r}else if(r.cmp(0)>0){i=simplest_rational2(r,n)}else if(t.cmp(0)<0){i=LNumber(simplest_rational2(n.sub(),r.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(t)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,t){var r=LNumber(e).floor();var n=LNumber(t).floor();if(e.cmp(r)<1){return r}else if(r.cmp(n)===0){var i=LNumber(1).div(t.sub(n));var a=LNumber(1).div(e.sub(r));return r.add(LNumber(1).div(simplest_rational2(i,a)))}else{return r.add(LNumber(1))}}function LRational(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof LRational)||typeof this==="undefined"){return new LRational(e,t)}if(!LNumber.isRational(e)){throw new Error("Invalid constructor call for LRational")}var r,n;if(e instanceof LRational){r=LNumber(e.__num__);n=LNumber(e.__denom__)}else{r=LNumber(e.num);n=LNumber(e.denom)}if(!t&&n.cmp(0)!==0){var i=r.op("%",n).cmp(0)===0;if(i){return LNumber(r.div(n))}}this.constant(r,n)}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.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})};LRational.prototype.serialize=function(){return{num:this.__num__,denom:this.__denom__}};LRational.prototype.pow=function(e){var t=e.cmp(0);if(t===0){return LNumber(1)}if(t===-1){e=e.sub();var r=this.__denom__.pow(e);var n=this.__num__.pow(e);return LRational({num:r,denom:n})}var i=this;e=e.valueOf();while(e>1){i=i.mul(this);e--}return i};LRational.prototype.sqrt=function(){var e=this.__num__.sqrt();var t=this.__denom__.sqrt();if(e instanceof LFloat||t instanceof LFloat){return e.div(t)}return LRational({num:e,denom:t})};LRational.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 LRational({num:e,denom:t})};LRational.prototype.cmp=function(e){return LNumber(this.valueOf(),true).cmp(e)};LRational.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 LRational){t=LNumber(t.valueOf(true))}r=this.__denom__.div(e);if(r instanceof LRational){r=LNumber(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()};LRational.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 LNumber._ops["/"](this.__num__.value,this.__denom__.value)}return LFloat(this.__num__.valueOf()).div(this.__denom__.valueOf())};LRational.prototype.mul=function(e){if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var t=this.__num__.mul(e.__num__);var r=this.__denom__.mul(e.__denom__);return LRational({num:t,denom:r})}var n=LNumber.coerce(this,e),i=_slicedToArray(n,2),a=i[0],o=i[1];return a.mul(o)};LRational.prototype.div=function(e){if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var t=this.__num__.mul(e.__denom__);var r=this.__denom__.mul(e.__num__);return LRational({num:t,denom:r})}var n=LNumber.coerce(this,e),i=_slicedToArray(n,2),a=i[0],o=i[1];var u=a.div(o);return u};LRational.prototype._op=function(e,t){return this[rev_mapping[e]](t)};LRational.prototype.sub=function(e){if(typeof e==="undefined"){return this.mul(-1)}if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var t=e.__num__.sub();var r=e.__denom__;return this.add(LRational({num:t,denom:r}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var n=LNumber.coerce(this,e),i=_slicedToArray(n,2),a=i[0],o=i[1];return a.add(o)};LRational.prototype.add=function(e){if(!(e instanceof LNumber)){e=LNumber(e)}if(LNumber.isRational(e)){var t=this.__denom__;var r=e.__denom__;var n=this.__num__;var i=e.__num__;var a,o;if(t!==r){o=r.mul(n).add(i.mul(t));a=t.mul(r)}else{o=n.add(i);a=t}return LRational({num:o,denom:a})}if(LNumber.isFloat(e)){return LFloat(this.valueOf()).add(e)}var u=LNumber.coerce(this,e),s=_slicedToArray(u,2),c=s[0],l=s[1];return c.add(l)};function LBigInteger(e,t){if(typeof this!=="undefined"&&!(this instanceof LBigInteger)||typeof this==="undefined"){return new LBigInteger(e,t)}if(e instanceof LBigInteger){return LBigInteger(e.__value__,e._native)}if(!LNumber.isBigInteger(e)){throw new Error("Invalid constructor call for LBigInteger")}this.constant(e,"bigint");Object.defineProperty(this,"_native",{value:t})}LBigInteger.prototype=Object.create(LNumber.prototype);LBigInteger.prototype.constructor=LBigInteger;LBigInteger.bn_op={"+":"iadd","-":"isub","*":"imul","/":"idiv","%":"imod","|":"ior","&":"iand","~":"inot","<<":"ishrn",">>":"ishln"};LBigInteger.prototype.serialize=function(){return this.__value__.toString()};LBigInteger.prototype._op=function(e,t){if(typeof t==="undefined"){if(LNumber.isBN(this.__value__)){e=LBigInteger.bn_op[e];return LBigInteger(this.__value__.clone()[e](),false)}return LBigInteger(LNumber._ops[e](this.__value__),true)}if(LNumber.isBN(this.__value__)&&LNumber.isBN(t.__value__)){e=LBigInteger.bn_op[e];return LBigInteger(this.__value__.clone()[e](t),false)}var r=LNumber._ops[e](this.__value__,t.__value__);if(e==="/"){var n=this.op("%",t).cmp(0)===0;if(n){return LNumber(r)}return LRational({num:this,denom:t})}return LBigInteger(r,true)};LBigInteger.prototype.sqrt=function(){var e;var t=this.cmp(0)<0;if(LNumber.isNative(this.__value__)){e=LNumber(Math.sqrt(t?-this.valueOf():this.valueOf()))}else if(LNumber.isBN(this.__value__)){e=t?this.__value__.neg().sqrt():this.__value__.sqrt()}if(t){return LComplex({re:0,im:e})}return e};LNumber.NaN=LNumber(NaN);function InputPort(e){var n=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");read_only(this,"__type__",text_port);var i;Object.defineProperty(this,"__parser__",{enumerable:true,get:function e(){return i},set:function e(t){typecheck("InputPort::__parser__",t,"parser");i=t}});this._read=e;this._with_parser=this._with_init_parser.bind(this,_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r;return _regeneratorRuntime.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 Parser(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()!==eof};this._make_defaults()}InputPort.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(!LNumber.isInteger(t)){var r=LNumber.getType(t);typeErrorMessage("read-string",r,"integer")}return e.__lexer__.read_string(t.valueOf())});this.peek_char=this._with_parser(function(e){return e.__lexer__.peek_char()})};InputPort.prototype._with_init_parser=function(u,s){var c=this;return _asyncToGenerator(_regeneratorRuntime.mark(function e(){var r,n,i,a,o=arguments;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:t.next=2;return u.call(c);case 2:r=t.sent;for(n=o.length,i=new Array(n),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");read_only(this,"__type__",text_port);this.write=e}OutputPort.prototype.is_open=function(){return this._closed!==true};OutputPort.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")}};OutputPort.prototype.flush=function(){};OutputPort.prototype.toString=function(){return"#"};var BufferedOutputPort=function(e){_inherits(n,e);var r=_createSuper(n);function n(e){var t;_classCallCheck(this,n);t=r.call(this,function(){var e;return(e=t)._write.apply(e,arguments)});typecheck("BufferedOutputPort",e,"function");read_only(_assertThisInitialized(t),"_fn",e,{hidden:true});read_only(_assertThisInitialized(t),"_buffer",[],{hidden:true});return t}_createClass(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"};OutputStringPort.prototype.valueOf=function(){return this.__buffer__.map(function(e){return e.valueOf()}).join("")};function OutputFilePort(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,t)}typecheck("OutputFilePort",e,"string");read_only(this,"__filename__",e);read_only(this,"_fd",t.valueOf(),{hidden:true});read_only(this,"__type__",text_port);this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}r.fs().write(r._fd,e,function(e){if(e){throw e}})}}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(e){return user_env.get("**internal-env**").get(e)};OutputFilePort.prototype.close=function(){var n=this;return new Promise(function(t,r){n.fs().close(n._fd,function(e){if(e){r(e)}else{read_only(n,"_fd",null,{hidden:true});OutputPort.prototype.close.call(n);t()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof InputStringPort)||typeof this==="undefined"){return new InputStringPort(e)}typecheck("InputStringPort",e,"string");t=t||global_env;e=e.valueOf();this._with_parser=this._with_init_parser.bind(this,function(){if(!r.__parser__){r.__parser__=new Parser(e,{env:t})}return r.__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(e){if(typeof this!=="undefined"&&!(this instanceof InputByteVectorPort)||typeof this==="undefined"){return new InputByteVectorPort(e)}typecheck("InputByteVectorPort",e,"uint8array");read_only(this,"__vector__",e);read_only(this,"__type__",binary_port);var r=0;Object.defineProperty(this,"__index__",{enumerable:true,get:function e(){return r},set:function e(t){typecheck("InputByteVectorPort::__index__",t,"number");if(t instanceof LNumber){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}})}InputByteVectorPort.prototype=Object.create(InputPort.prototype);InputByteVectorPort.prototype.constructor=InputByteVectorPort;InputByteVectorPort.prototype.toString=function(){return"#"};InputByteVectorPort.prototype.close=function(){var t=this;read_only(this,"__vector__",_nil);["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}};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 e=this.peek_u8();this.skip();return e};InputByteVectorPort.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()===eof){return eof}return this.__vector__.slice(this.__index__,e)};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(e){typecheck("write",e,["number","uint8array"]);if(LNumber.isNumber(e)){this._buffer.push(e.valueOf())}else{var t;(t=this._buffer).push.apply(t,_toConsumableArray(Array.from(e)))}};Object.defineProperty(this,"__buffer__",{enumerable:true,get:function e(){return Uint8Array.from(this._buffer)}})}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(e){typecheck("OutputByteVectorPort::write_u8",e,"number");this.write(e)};OutputByteVectorPort.prototype.write_u8_vector=function(e){typecheck("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};OutputByteVectorPort.prototype.toString=function(){return"#"};OutputByteVectorPort.prototype.valueOf=function(){return this.__buffer__};function InputFilePort(e,t){if(typeof this!=="undefined"&&!(this instanceof InputFilePort)||typeof this==="undefined"){return new InputFilePort(e,t)}InputStringPort.call(this,e);typecheck("InputFilePort",t,"string");read_only(this,"__filename__",t)}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};function InputBinaryFilePort(e,t){if(typeof this!=="undefined"&&!(this instanceof InputBinaryFilePort)||typeof this==="undefined"){return new InputBinaryFilePort(e,t)}InputByteVectorPort.call(this,e);typecheck("InputBinaryFilePort",t,"string");read_only(this,"__filename__",t)}InputBinaryFilePort.prototype=Object.create(InputByteVectorPort.prototype);InputBinaryFilePort.prototype.constructor=InputBinaryFilePort;InputBinaryFilePort.prototype.toString=function(){return"#")};function OutputBinaryFilePort(e,t){var i=this;if(typeof this!=="undefined"&&!(this instanceof OutputBinaryFilePort)||typeof this==="undefined"){return new OutputBinaryFilePort(e,t)}typecheck("OutputBinaryFilePort",e,"string");read_only(this,"__filename__",e);read_only(this,"_fd",t.valueOf(),{hidden:true});read_only(this,"__type__",binary_port);var a,r;this.write=function(e){typecheck("write",e,["number","uint8array"]);var n;if(!a){a=i.internal("fs")}if(!r){r=i.internal("Buffer")}if(LNumber.isNumber(e)){n=r.from([e.valueOf()])}else{n=r.from(Array.from(e))}return new Promise(function(t,r){a.write(i._fd,n,function(e){if(e){r(e)}else{t()}})})}}OutputBinaryFilePort.prototype=Object.create(OutputFilePort.prototype);OutputBinaryFilePort.prototype.constructor=OutputBinaryFilePort;OutputBinaryFilePort.prototype.write_u8=function(e){typecheck("OutputByteVectorPort::write_u8",e,"number");this.write(e)};OutputBinaryFilePort.prototype.write_u8_vector=function(e){typecheck("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#"};function Interpreter(e){var c=this;var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=t.stderr,n=t.stdin,i=t.stdout,a=t.command_line,o=a===void 0?null:a,u=_objectWithoutProperties(t,_excluded3);if(typeof this!=="undefined"&&!(this instanceof Interpreter)||typeof this==="undefined"){return new Interpreter(e,_objectSpread({stdin:n,stdout:i,stderr:r,command_line:o},u))}if(typeof e==="undefined"){e="anonymous"}this.__env__=user_env.inherit(e,u);this.__env__.set("parent.frame",doc("parent.frame",function(){return c.__env__},global_env.__env__["parent.frame"].__doc__));var l="**interaction-environment-defaults**";this.set(l,get_props(u).concat(l));var s=internal_env.inherit("internal-".concat(e));if(is_port(n)){s.set("stdin",n)}if(is_port(r)){s.set("stderr",r)}if(is_port(i)){s.set("stdout",i)}s.set("command-line",o);set_interaction_env(this.__env__,s)}Interpreter.prototype.exec=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=t.use_dynamic,n=r===void 0?false:r,i=t.dynamic_env,a=t.env;typecheck("Interpreter::exec",e,["string","array"],1);typecheck("Interpreter::exec",n,"boolean",2);if(!a){a=this.__env__}if(!i){i=a}global_env.set("**interaction-environment**",this.__env__);return exec(e,{env:a,dynamic_env:i,use_dynamic:n})};Interpreter.prototype.get=function(e){var t=this.__env__.get(e);if(is_function(t)){return t.bind(this.__env__)}return t};Interpreter.prototype.set=function(e,t){return this.__env__.set(e,t)};Interpreter.prototype.constant=function(e,t){return this.__env__.constant(e,t)};function LipsError(e,t){this.name="LipsError";this.message=e;this.args=t;this.stack=(new Error).stack}LipsError.prototype=new Error;LipsError.prototype.constructor=LipsError;function Environment(e,t,r){if(arguments.length===1){if(_typeof(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"}Environment.prototype.list=function(){return get_props(this.__env__)};Environment.prototype.fs=function(){return this.get("**fs**")};Environment.prototype.unset=function(e){if(e instanceof LSymbol){e=e.valueOf()}if(e instanceof LString){e=e.valueOf()}delete this.__env__[e]};Environment.prototype.inherit=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(_typeof(e)==="object"){t=e}if(!e||_typeof(e)==="object"){e="child of "+(this.__name__||"unknown")}return new Environment(t||{},this,e)};Environment.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 LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(t){if(!r){t=trim_lines(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)}};Environment.prototype.new_frame=function(e,t){var n=this.inherit("__frame__");n.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:1;e=e.valueOf();var t=n.__parent__;if(!is_env(t)){return _nil}if(e<=0){return t}var r=t.get("parent.frame");return r(e-1)},global_env.__env__["parent.frame"].__doc__));t.callee=e;n.set("arguments",t);return n};Environment.prototype._lookup=function(e){if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(this.__env__.hasOwnProperty(e)){return Value(this.__env__[e])}if(this.__parent__){return this.__parent__._lookup(e)}};Environment.prototype.toString=function(){return"#"};Environment.prototype.clone=function(){var t=this;var r={};Object.keys(this.__env__).forEach(function(e){r[e]=t.__env__[e]});return new Environment(r,this.__parent__,this.__name__)};Environment.prototype.merge=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"merge";typecheck("Environment::merge",e,"environment");return this.inherit(t,e.__env__)};function Value(e){if(typeof this!=="undefined"&&!(this instanceof Value)||typeof this==="undefined"){return new Value(e)}this.value=e}Value.isUndefined=function(e){return e instanceof Value&&typeof e.value==="undefined"};Value.prototype.valueOf=function(){return this.value};function Values(e){if(e.length){if(e.length===1){return e[0]}}if(typeof this!=="undefined"&&!(this instanceof Values)||typeof this==="undefined"){return new Values(e)}this.__values__=e}Values.prototype.toString=function(){return this.__values__.map(function(e){return toString(e)}).join("\n")};Values.prototype.valueOf=function(){return this.__values__};Environment.prototype.get=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};typecheck("Environment::get",e,["symbol","string"]);var r=t.throwError,c=r===void 0?true:r;var n=e;if(n instanceof LSymbol||n instanceof LString){n=n.valueOf()}var i=this._lookup(n);if(i instanceof Value){if(Value.isUndefined(i)){return undefined}return patch_value(i.valueOf())}var a;if(e instanceof LSymbol&&e[LSymbol.object]){a=e[LSymbol.object]}else if(typeof n==="string"){a=n.split(".").filter(Boolean)}if(a&&a.length>0){var l=a,o=_toArray(l),u=o[0],s=o.slice(1);i=this._lookup(u);if(s.length){try{if(i instanceof Value){i=i.valueOf()}else{i=get(root,u);if(is_function(i)){i=unbind(i)}}if(typeof i!=="undefined"){return get.apply(void 0,[i].concat(_toConsumableArray(s)))}}catch(e){throw e}}else if(i instanceof Value){return patch_value(i.valueOf())}i=get(root,n)}if(typeof i!=="undefined"){return i}if(c){throw new Error("Unbound variable `"+n.toString()+"'")}};Environment.prototype.set=function(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;typecheck("Environment::set",e,["string","symbol"]);if(LNumber.isNumber(t)){t=LNumber(t)}if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}this.__env__[e]=t;if(r){this.doc(e,r,true)}return this};Environment.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&&is_plain_object(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};Environment.prototype.has=function(e){return this.__env__.hasOwnProperty(e)};Environment.prototype.ref=function(e){var t=this;while(true){if(!t){break}if(t.has(e)){return t}t=t.__parent__}};Environment.prototype.parents=function(){var e=this;var t=[];while(e){t.unshift(e);e=e.__parent__}return t};function quote(e){if(is_promise(e)){return e.then(quote)}if(e instanceof Pair||e instanceof LSymbol){e[__data__]=true}return e}var native_lambda=_parse(tokenize('(lambda ()\n "[native code]"\n (throw "Invalid Invocation"))'))[0];var get=doc("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=internal(this,"stdin")}typecheck_text_port("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":doc("read-line",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=internal(this,"stdin")}typecheck_text_port("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":doc("read-char",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=internal(this,"stdin")}typecheck_text_port("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:doc("read",function(){var e=_asyncToGenerator(_regeneratorRuntime.mark(function e(){var r,n,i,a,o,u,s,c,l,f=arguments;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:r=f.length>0&&f[0]!==undefined?f[0]:null;n=this.env;if(!LString.isString(r)){t.next=31;break}i=false;a=false;t.prev=5;u=_asyncIterator(_parse(r,n));case 7:t.next=9;return u.next();case 9:if(!(i=!(s=t.sent).done)){t.next=15;break}c=s.value;return t.abrupt("return",c);case 12:i=false;t.next=7;break;case 15:t.next=21;break;case 17:t.prev=17;t.t0=t["catch"](5);a=true;o=t.t0;case 21:t.prev=21;t.prev=22;if(!(i&&u["return"]!=null)){t.next=26;break}t.next=26;return u["return"]();case 26:t.prev=26;if(!a){t.next=29;break}throw o;case 29:return t.finish(26);case 30:return t.finish(21);case 31:if(r===null){l=internal(n,"stdin")}else{l=r}typecheck_text_port("read",l,"input-port");return t.abrupt("return",l.read.call(n));case 34:case"end":return t.stop()}}},e,this,[[5,17,21,31],[22,,26,30]])}));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:doc("pprint",function e(t){if(t instanceof Pair){t=new lips.Formatter(t.toString(true))["break"]().format();global_env.get("display").call(global_env,t)}else{global_env.get("write").call(global_env,t)}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 e(){var t=global_env.get("display");var r=global_env.get("newline");var n=this.use_dynamic;var i=global_env;var a=global_env;for(var o=arguments.length,u=new Array(o),s=0;s1?r-1:0),i=1;in.length){throw new Error("Not enough arguments")}var u=0;var s=global_env.get("repr");t=t.replace(a,function(e){var t=e[1];if(t==="~"){return"~"}else if(t==="%"){return"\n"}else{var r=n[u++];if(t==="a"){return s(r)}else{return s(r,true)}}});o=t.match(/~([\S])/);if(o){throw new Error("format: Unrecognized escape sequence ".concat(o[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:doc("display",function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(r===null){r=internal(this,"stdout")}else{typecheck("display",r,"output-port")}var n=t;if(!(r instanceof OutputBinaryFilePort)){n=global_env.get("repr")(t)}r.write.call(global_env,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":doc("display-error",function e(){var t=internal(this,"stderr");var r=global_env.get("repr");for(var n=arguments.length,i=new Array(n),a=0;a1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,l=_objectWithoutProperties(t,_excluded4);var n=this;var i=this;var a;var f=_objectSpread(_objectSpread({},l),{},{env:this,dynamic_env:n,use_dynamic:r});var o=_evaluate(e.cdr.car,f);o=resolve_promises(o);function u(t,r,n){if(is_promise(t)){return t.then(function(e){return u(t,e,n)})}if(is_promise(r)){return r.then(function(e){return u(t,e,n)})}if(is_promise(n)){return n.then(function(e){return u(t,r,e)})}i.get("set-obj!").call(i,t,r,n);return n}if(e.car instanceof Pair&&LSymbol.is(e.car.car,".")){var _=e.car.cdr.car;var p=e.car.cdr.cdr.car;var h=_evaluate(_,{env:this,dynamic_env:n,use_dynamic:r,error:error});var d=_evaluate(p,{env:this,dynamic_env:n,use_dynamic:r,error:error});return u(h,d,o)}if(!(e.car instanceof LSymbol)){throw new Error("set! first argument need to be a symbol or "+"dot accessor that evaluate to object.")}var s=e.car.valueOf();a=this.ref(e.car.__name__);return unpromise(o,function(e){if(!a){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){u(i,r,e);return}}throw new Error("Unbound variable `"+s+"'")}a.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!":doc(new Macro("set!",function(e){if(!(e.car instanceof LSymbol)){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!":doc("set-car!",function(e,t){typecheck("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!":doc("set-cdr!",function(e,t){typecheck("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?":doc("empty?",function(e){return typeof e==="undefined"||e===_nil},"(empty? object)\n\n Function that returns #t if value is nil (an empty list) or undefined."),gensym:doc("gensym",gensym,"(gensym)\n\n Generates a unique symbol that is not bound anywhere,\n to use with macros as meta name."),load:doc("load",function e(u,t){typecheck("load",u,"string");var s=this;if(s.__name__==="__frame__"){s=s.__parent__}if(!(t instanceof Environment)){if(s===global_env){t=s}else{t=this.get("**interaction-environment**")}}var c="**module-path**";var l=global_env.get(c,{throwError:false});u=u.valueOf();if(!u.match(/.[^.]+$/)){u+=".scm"}var r=u.match(/\.xcb$/);function f(e){if(r){e=unserialize_bin(e)}else{if(type(e)==="buffer"){e=e.toString()}e=e.replace(/^#!.*/,"");if(e.match(/^\{/)){e=unserialize(e)}}return exec(e,{env:t})}function n(e){return root.fetch(e).then(function(e){return r?e.arrayBuffer():e.text()}).then(function(e){if(r){e=new Uint8Array(e)}return e})}if(is_node()){return new Promise(function(){var r=_asyncToGenerator(_regeneratorRuntime.mark(function e(r,n){var i,a,o;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:i=nodeRequire("path");if(!l){t.next=6;break}l=l.valueOf();u=i.join(l,u);t.next=12;break;case 6:a=s.get("command-line",{throwError:false});if(!a){t.next=11;break}t.next=10;return a();case 10:o=t.sent;case 11:if(o&&o!==_nil){process.cwd();u=i.join(i.dirname(o.car.valueOf()),u)}case 12:global_env.set(c,i.dirname(u));nodeRequire("fs").readFile(u,function(e,t){if(e){n(e);global_env.set(c,l)}else{try{f(t).then(function(){r();global_env.set(c,l)})["catch"](n)}catch(e){n(e)}}});case 14:case"end":return t.stop()}}},e)}));return function(e,t){return r.apply(this,arguments)}}())}if(l){l=l.valueOf();u=l+"/"+u.replace(/^\.?\/?/,"")}return n(u).then(function(e){global_env.set(c,u.replace(/\/[^/]*$/,""));return f(e)}).then(function(){})["finally"](function(){global_env.set(c,l)})},"(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:doc(new Macro("do",function(){var r=_asyncToGenerator(_regeneratorRuntime.mark(function e(r,_){var p,n,i,a,u,s,o,c,l,f,h,d;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:p=_.use_dynamic,n=_.error;i=this;a=i;u=i.inherit("do");s=r.car;o=r.cdr.car;c=r.cdr.cdr;if(c!==_nil){c=new Pair(LSymbol("begin"),c)}l={env:i,dynamic_env:a,use_dynamic:p,error:n};f=s;case 10:if(!(f!==_nil)){t.next=21;break}h=f.car;t.t0=u;t.t1=h.car;t.next=16;return _evaluate(h.cdr.car,l);case 16:t.t2=t.sent;t.t0.set.call(t.t0,t.t1,t.t2);f=f.cdr;t.next=10;break;case 21:l={env:u,dynamic_env:a,error:n};d=_regeneratorRuntime.mark(function e(){var r,n,i,a,o;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!(c!==_nil)){t.next=3;break}t.next=3;return lips.evaluate(c,l);case 3:r=s;n={};case 5:if(!(r!==_nil)){t.next=15;break}i=r.car;if(!(i.cdr.cdr!==_nil)){t.next=12;break}t.next=10;return _evaluate(i.cdr.cdr.car,l);case 10:a=t.sent;n[i.car.valueOf()]=a;case 12:r=r.cdr;t.next=5;break;case 15:o=Object.getOwnPropertySymbols(n);Object.keys(n).concat(o).forEach(function(e){u.set(e,n[e])});case 17:case"end":return t.stop()}}},e)});case 23:t.next=25;return _evaluate(o.car,l);case 25:t.t3=t.sent;if(!(t.t3===false)){t.next=30;break}return t.delegateYield(d(),"t4",28);case 28:t.next=23;break;case 30:if(!(o.cdr!==_nil)){t.next=34;break}t.next=33;return _evaluate(o.cdr.car,l);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:doc(new Macro("if",function(r,e){var t=e.error,n=e.use_dynamic;var i=this;var a=this;var o={env:a,dynamic_env:i,use_dynamic:n,error:t};var u=function e(t){if(t===false){return _evaluate(r.cdr.cdr.car,o)}else{return _evaluate(r.cdr.car,o)}};if(r===_nil){throw new Error("too few expressions for `if`")}var s=_evaluate(r.car,o);return unpromise(s,u)}),"(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(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=e.dynamic_env,n=e.use_dynamic,i=e.error;typecheck("let-env",t,"pair");var a=_evaluate(t.car,{env:this,dynamic_env:r,error:i,use_dynamic:n});return unpromise(a,function(e){typecheck("let-env",e,"environment");return _evaluate(Pair(LSymbol("begin"),t.cdr),{env:e,dynamic_env:r,error:i})})},"(let-env env . body)\n\n Special macro that evaluates body in context of given environment\n object."),letrec:doc(let_macro(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*":doc(let_macro(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*":doc(let_macro(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:doc(let_macro(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*":doc(parallel("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())."),shuffle:doc(function(e){typecheck("shuffle",e,["pair","nil","array"]);var t=global_env.get("random");if(e===_nil){return _nil}if(Array.isArray(e)){return shuffle(e.slice(),t)}var r=global_env.get("list->array")(e);r=shuffle(r,t);return global_env.get("array->list")(r)},"(shuffle obj)\n\n Order items in vector or list in random order."),begin:doc(new Macro("begin",function(e,t){var n=_objectSpread(_objectSpread({},t),{},{env:this});var i=global_env.get("list->array")(e);var a;return function t(){if(i.length){var e=i.shift();var r=_evaluate(e,n);return unpromise(r,function(e){a=e;return t()})}else{return a}}()}),"(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 Macro("ignore",function(e,t){var r=_objectSpread(_objectSpread({},t),{},{env:this,dynamic_env:this});_evaluate(new Pair(new LSymbol("begin"),e),r)},"(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(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=_objectSpread({env:this},t);return unpromise(_evaluate(e.car,r),function(e){if(is_function(e)){return e(new Continuation(null))}})}),"(call/cc proc)\n\n Call-with-current-continuation.\n\n NOT SUPPORTED BY LIPS RIGHT NOW"),parameterize:doc(new Macro("parameterize",function(t,e){var i=e.dynamic_env;var a=i.inherit("parameterize").new_frame(null,{});var o=_objectSpread(_objectSpread({},e),{},{env:this});var u=t.car;if(!is_pair(u)){var r=type(u);throw new Error("Invalid syntax for parameterize expecting pair got ".concat(r))}function s(){var e=new Pair(new LSymbol("begin"),t.cdr);return _evaluate(e,_objectSpread(_objectSpread({},o),{},{dynamic_env:a}))}return function r(){var e=u.car;var n=e.car.valueOf();return unpromise(_evaluate(e.cdr.car,o),function(e){var t=i.get(n,{throwError:false});if(!is_parameter(t)){throw new Error("Unknown parameter ".concat(n))}a.set(n,t.inherit(e));if(!is_null(u.cdr)){u=u.cdr;return r()}else{return s()}})}()}),"(parameterize ((name value) ...)\n\n Macro that change the dynamic variable created by make-parameter."),"make-parameter":doc(new Macro("make-parameter",function(e,t){t.dynamic_env;var r=_evaluate(e.car,t);var n;if(e.cdr.car instanceof Pair){n=_evaluate(e.cdr.car,t)}return new Parameter(r,n)}),"(make-parameter init converter)\n\n Function creates new dynamic variable that can be custimized with parameterize\n macro. The value should be assigned to a variable e.g.:\n\n (define radix (make-parameter 10))\n\n The result value is a procedure that return the value of dynamic variable."),define:doc(Macro.defmacro("define",function(r,e){var n=this;if(r.car instanceof Pair&&r.car.car instanceof LSymbol){var t=new Pair(new LSymbol("define"),new Pair(r.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(r.car.cdr,r.cdr)))));return t}else if(e.macro_expand){return}e.dynamic_env=this;e.env=n;var i=r.cdr.car;var a;if(i instanceof Pair){i=_evaluate(i,e);a=true}else if(i instanceof LSymbol){i=n.get(i)}typecheck("define",r.car,"symbol");return unpromise(i,function(e){if(n.__name__===Syntax.__merge_env__){n=n.__parent__}if(a&&(is_function(e)&&is_lambda(e)||e instanceof Syntax||is_parameter(e))){e.__name__=r.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var t;if(r.cdr.cdr instanceof Pair&&LString.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!":doc("set-obj!",function(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var i=_typeof(e);if(is_null(e)||i!=="object"&&i!=="function"){var a=typeErrorMessage("set-obj!",type(e),["object","function"]);throw new Error(a)}typecheck("set-obj!",t,["string","symbol","number"]);e=unbind(e);t=t.valueOf();if(arguments.length===2){delete e[t]}else if(is_prototype(e)&&is_function(r)){e[t]=unbind(r);e[t][__prototype__]=true}else if(is_function(r)||is_native(r)||r===_nil){e[t]=r}else{e[t]=r&&!is_prototype(r)?r.valueOf():r}if(props){var o=e[t];Object.defineProperty(e,t,_objectSpread(_objectSpread({},n),{},{value:o}))}},"(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":doc("null-environment",function(){return global_env.inherit("null")},"(null-environment)\n\n Returns a clean environment with only the standard library."),values:doc("values",function e(){for(var t=arguments.length,r=new Array(t),n=0;n1&&arguments[1]!==undefined?arguments[1]:{},m=e.use_dynamic,y=e.error;var v=this;var g;if(d.cdr instanceof Pair&&LString.isString(d.cdr.car)&&d.cdr.cdr!==_nil){g=d.cdr.car.valueOf()}function b(){var c=is_context(this)?this:{dynamic_env:v},r=c.dynamic_env;var n=v.inherit("lambda");r=r.inherit("lambda");if(this&&!is_context(this)){if(this&&!this.__instance__){Object.defineProperty(this,"__instance__",{enumerable:false,get:function e(){return true},set:function e(){},configurable:false})}n.set("this",this)}for(var e=arguments.length,t=new Array(e),i=0;i>> "+c.toString());if(c){u=c}var m=r.merge(t,Syntax.__merge_env__);if(f){return{expr:u,scope:m}}var y=_evaluate(u,_objectSpread(_objectSpread({},h),{},{env:m}));return clear_gensyms(y,d)}i=i.cdr}}catch(e){e.message+=" in macro: ".concat(v.toString(true));throw e}throw new Error("Invalid Syntax ".concat(e.toString(true)))},w);r.__code__=v;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:doc(new Macro("quote",function(e){return quote(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":doc("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:doc("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:Macro.defmacro("quasiquote",function(e,t){var u=t.use_dynamic,s=t.error;var c=this;var l=c;function o(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function _(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:o;if(e instanceof Pair){var n=e.car;var i=e.cdr;if(r(n)){n=t(n)}if(r(i)){i=t(i)}if(is_promise(n)||is_promise(i)){return promise_all([n,i]).then(function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];return new Pair(r,n)})}else{return new Pair(n,i)}}return e}function a(e,t){if(e instanceof Pair){if(t!==_nil){e.append(t)}}else{e=new Pair(e,t)}return e}function r(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,/^(unquote|unquote-splicing)$/)}).length}function p(e,n,i){return e.reduce(function(e,t){if(!(t instanceof Pair)){e.push(t);return e}if(LSymbol.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 Pair&&r[0]===_nil)){return r[0]}}r=r.map(function(e){if(m.has(e)){return e.clone()}else{m.add(e);return e}});var n=f(i.cdr,0,1);if(n===_nil&&r[0]===_nil){return undefined}return unpromise(n,function(e){if(r[0]===_nil){return e}if(r.length===1){return a(r[0],e)}var t=r.reduce(function(e,t){return a(e,t)});return a(t,e)})})}(i.car.cdr)}var m=new Set;function f(e,t,r){if(e instanceof Pair){if(e.car instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return d(e,t+1,r)}if(LSymbol.is(e.car.car,"unquote")){if(t+2===r&&e.car.cdr instanceof Pair&&e.car.cdr.car instanceof Pair&&LSymbol.is(e.car.cdr.car.car,"unquote-splicing")){var n=e.car.cdr;return new Pair(new Pair(new LSymbol("unquote"),d(n,t+2,r)),_nil)}else if(e.car.cdr instanceof Pair&&e.car.cdr.cdr!==_nil){if(e.car.cdr.car instanceof Pair){var i=[];return function t(r){if(r===_nil){return Pair.fromArray(i)}return unpromise(_evaluate(r.car,{env:c,dynamic_env:l,use_dynamic:u,error:s}),function(e){i.push(e);return t(r.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}}if(LSymbol.is(e.car,"quasiquote")){var a=f(e.cdr,t,r+1);return new Pair(e.car,a)}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,f(e.cdr,t,r))}if(LSymbol.is(e.car,"unquote")){t++;if(tr){throw new Error("You can't call `unquote` outside "+"of quasiquote")}if(e.cdr instanceof Pair){if(e.cdr.cdr!==_nil){if(e.cdr.car instanceof Pair){var o=[];return function t(r){if(r===_nil){return Pair.fromArray(o)}return unpromise(_evaluate(r.car,{env:c,dynamic_env:l,use_dynamic:u,error:s}),function(e){o.push(e);return t(r.cdr)})}(e.cdr)}else{return e.cdr}}else{return _evaluate(e.cdr.car,{env:c,dynamic_env:l,error:s})}}else{return e.cdr}}return _(e,function(e){return f(e,t,r)})}else if(is_plain_object(e)){return h(e,t,r)}else if(e instanceof Array){return p(e,t,r)}return e}function n(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}}if(is_plain_object(e.car)&&!r(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!r(e.car)){return quote(e.car)}if(e.car instanceof Pair&&!e.car.find("unquote")&&!e.car.find("unquote-splicing")&&!e.car.find("quasiquote")){return quote(e.car)}var i=f(e.car,0,1);return unpromise(i,function(e){n(e);return quote(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:doc("clone",function e(t){typecheck("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:doc("append",function e(){var t;for(var r=arguments.length,n=new Array(r),i=0;iarray")(t).reverse();return global_env.get("array->list")(r)}else if(Array.isArray(t)){return t.reverse()}else{throw new Error(typeErrorMessage("reverse",type(t),"array or pair"))}},"(reverse list)\n\n Function that reverses the list or array. If value is not a list\n or array it will error."),nth:doc("nth",function e(t,r){typecheck("nth",t,"number");typecheck("nth",r,["array","pair"]);if(r instanceof Pair){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:doc("split",function e(t,r){typecheck("split",t,["regex","string"]);typecheck("split",r,"string");return global_env.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:doc("replace",function e(t,r,n){typecheck("replace",t,["regex","string"]);typecheck("replace",r,["string","function"]);typecheck("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:doc("match",function e(t,r){typecheck("match",t,["regex","string"]);typecheck("match",r,"string");var n=r.match(t);return n?global_env.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:doc("search",function e(t,r){typecheck("search",t,["regex","string"]);typecheck("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:doc("repr",function e(t,r){return toString(t,r)},"(repr obj)\n\n Function that returns a LIPS code representation of the object as a string."),"escape-regex":doc("escape-regex",function(e){typecheck("escape-regex",e,"string");return escape_regex(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:doc("env",function e(e){e=e||this.env;var t=Object.keys(e.__env__).map(LSymbol);var r;if(t.length){r=Pair.fromArray(t)}else{r=_nil}if(e.__parent__ instanceof Environment){return global_env.get("env").call(this,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:doc("new",function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n2&&arguments[2]!==undefined?arguments[2]:specials.LITERAL;typecheck("set-special!",e,"string",1);typecheck("set-special!",t,"symbol",2);specials.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:get,".":get,unbind:doc(unbind,"(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:doc(type,"(type object)\n\n Function that returns the type of an object as string."),debugger:doc("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:doc("in",function(e,t){if(e instanceof LSymbol||e instanceof LString||e instanceof LNumber){e=e.valueOf()}return e in unbox(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:doc("instanceof",function(e,t){return t instanceof unbind(e)},"(instanceof type obj)\n\n Predicate that tests if the obj is an instance of type."),"prototype?":doc("prototype?",is_prototype,"(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?":doc("macro?",function(e){return e instanceof Macro},"(macro? expression)\n\n Predicate that tests if value is a macro."),"function?":doc("function?",is_function,"(function? expression)\n\n Predicate that tests if value is a callable function."),"real?":doc("real?",function(e){if(type(e)!=="number"){return false}if(e instanceof LNumber){return e.isFloat()}return LNumber.isFloat(e)},"(real? number)\n\n Predicate that tests if value is a real number (not complex)."),"number?":doc("number?",function(e){return Number.isNaN(e)||LNumber.isNumber(e)},"(number? expression)\n\n Predicate that tests if value is a number or NaN value."),"string?":doc("string?",function(e){return LString.isString(e)},"(string? expression)\n\n Predicate that tests if value is a string."),"pair?":doc("pair?",function(e){return e instanceof Pair},"(pair? expression)\n\n Predicate that tests if value is a pair or list structure."),"regex?":doc("regex?",function(e){return e instanceof RegExp},"(regex? expression)\n\n Predicate that tests if value is a regular expression."),"null?":doc("null?",function(e){return is_null(e)},"(null? expression)\n\n Predicate that tests if value is null-ish (i.e. undefined, nil, or\n Javascript null)."),"boolean?":doc("boolean?",function(e){return typeof e==="boolean"},"(boolean? expression)\n\n Predicate that tests if value is a boolean (#t or #f)."),"symbol?":doc("symbol?",function(e){return e instanceof LSymbol},"(symbol? expression)\n\n Predicate that tests if value is a LIPS symbol."),"array?":doc("array?",function(e){return e instanceof Array},"(array? expression)\n\n Predicate that tests if value is an array."),"object?":doc("object?",function(e){return e!==_nil&&e!==null&&!(e instanceof LCharacter)&&!(e instanceof RegExp)&&!(e instanceof LString)&&!(e instanceof Pair)&&!(e instanceof LNumber)&&_typeof(e)==="object"&&!(e instanceof Array)},"(object? expression)\n\n Predicate that tests if value is an plain object (not another LIPS type)."),flatten:doc("flatten",function e(t){typecheck("flatten",t,"pair");return t.flatten()},"(flatten list)\n\n Returns a shallow list from tree structure (pairs)."),"array->list":doc("array->list",function(e){typecheck("array->list",e,"array");return Pair.fromArray(e)},"(array->list array)\n\n Function that converts a JavaScript array to a LIPS cons list."),"tree->array":doc("tree->array",to_array("tree->array",true),"(tree->array list)\n\n Function that converts a LIPS cons tree structure into a JavaScript array."),"list->array":doc("list->array",to_array("list->array"),"(list->array list)\n\n Function that converts a LIPS list into a JavaScript array."),apply:doc("apply",function e(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;iarray").call(this,a));return t.apply(this,prepare_fn_args(t,n))},"(apply fn list)\n\n Function that calls fn with the list of arguments."),length:doc("length",function e(t){if(!t||t===_nil){return 0}if(t instanceof Pair){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":doc("string->number",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;typecheck("string->number",e,"string",1);typecheck("string->number",t,"number",2);e=e.valueOf();t=t.valueOf();if(e.match(rational_bare_re)||e.match(rational_re)){return parse_rational(e,t)}else if(e.match(complex_bare_re)||e.match(complex_re)){return parse_complex(e,t)}else{var r=t===10&&!e.match(/e/i)||t===16;if(e.match(int_bare_re)&&r||e.match(int_re)){return parse_integer(e,t)}if(e.match(float_re)){return parse_float(e)}}return false},"(string->number number [radix])\n\n Function that parses a string into a number."),try:doc(new Macro("try",function(t,e){var c=this;var r=e.use_dynamic,l=e.error;return new Promise(function(n,i){var a,o;if(LSymbol.is(t.cdr.car.car,"catch")){a=t.cdr.car;if(t.cdr.cdr instanceof Pair&&LSymbol.is(t.cdr.cdr.car.car,"finally")){o=t.cdr.cdr.car}}else if(LSymbol.is(t.cdr.car.car,"finally")){o=t.cdr.car}if(!(o||a)){throw new Error("try: invalid syntax")}var u=n;if(o){u=function e(t,r){u=i;unpromise(_evaluate(new Pair(new LSymbol("begin"),o.cdr),s),function(){r(t)})}}var s={env:c,use_dynamic:r,dynamic_env:c,error:function(t){function e(e){return t.apply(this,arguments)}e.toString=function(){return t.toString()};return e}(function(e){var t=c.inherit("try");if(a){t.set(a.cdr.car.car,e);var r={env:t,error:l};r.dynamic_env=c;unpromise(_evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),r),function(e){u(e,n)})}else{u(e,l)}})};var e=_evaluate(t.car,s);if(is_promise(e)){e.then(function(e){u(e,n)})["catch"](s.error)}else{u(e,n)}})}),"(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:doc("raise",function(e){throw e},"(raise obj)\n\n Throws the object verbatim (no wrapping an a new Error)."),throw:doc("throw",function(e){throw new Error(e)},"(throw string)\n\n Throws a new exception."),find:doc("find",function t(r,n){typecheck("find",r,["regex","function"]);typecheck("find",n,["pair","nil"]);if(is_null(n)){return _nil}var e=matcher("find",r);return unpromise(e(n.car),function(e){if(e&&e!==_nil){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":doc("for-each",function(e){var t;typecheck("for-each",e,"function");for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i1?t-1:0),a=1;a3?n-3:0),a=3;a3?i-3:0),o=3;oarray")(r);var a=[];var o=matcher("filter",t);return function t(r){function e(e){if(e&&e!==_nil){a.push(n)}return t(++r)}if(r===i.length){return Pair.fromArray(a)}var n=i[r];return unpromise(o(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:doc(compose,"(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:doc(pipe,"(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:doc(curry,"(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:doc("gcd",function e(){for(var t=arguments.length,r=new Array(t),n=0;nu?a%=u:u%=a}a=abs(s*r[o])/(a+u)}return LNumber(a)},"(lcm n1 n2 ...)\n\n Function that returns the least common multiple of the arguments."),"odd?":doc("odd?",single_math_op(function(e){return LNumber(e).isOdd()}),"(odd? number)\n\n Checks if number is odd."),"even?":doc("even?",single_math_op(function(e){return LNumber(e).isEven()}),"(even? number)\n\n Checks if number is even."),"*":doc("*",reduce_math_op(function(e,t){return LNumber(e).mul(t)},LNumber(1)),"(* . numbers)\n\n Multiplies all numbers passed as arguments. If single value is passed\n it will return that value."),"+":doc("+",reduce_math_op(function(e,t){return LNumber(e).add(t)},LNumber(0)),"(+ . numbers)\n\n Sums all numbers passed as arguments. If single value is passed it will\n return that value."),"-":doc("-",function(){for(var e=arguments.length,t=new Array(e),r=0;r":doc(">",function(){for(var e=arguments.length,t=new Array(e),r=0;r",t,"number");return seq_compare(function(e,t){return LNumber(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."),"<":doc("<",function(){for(var e=arguments.length,t=new Array(e),r=0;r=":doc(">=",function(){for(var e=arguments.length,t=new Array(e),r=0;r=",t,"number");return seq_compare(function(e,t){return[0,1].includes(LNumber(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?":doc("eq?",equal,"(eq? a b)\n\n Function that compares two values if they are identical."),or:doc(new Macro("or",function(e,t){var i=t.use_dynamic,a=t.error;var o=global_env.get("list->array")(e);var u=this;var s=u;if(!o.length){return false}var c;return function t(){function e(e){c=e;if(c!==false){return c}else{return t()}}if(!o.length){if(c!==false){return c}else{return false}}else{var r=o.shift();var n=_evaluate(r,{env:u,dynamic_env:s,use_dynamic:i,error:a});return unpromise(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:doc(new Macro("and",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=t.error;var i=global_env.get("list->array")(e);var a=this;var o=a;if(!i.length){return true}var u;var s={env:a,dynamic_env:o,use_dynamic:r,error:n};return function t(){function e(e){u=e;if(u===false){return false}else{return t()}}if(!i.length){if(u!==false){return u}else{return false}}else{var r=i.shift();return unpromise(_evaluate(r,s),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."),"|":doc("|",function(e,t){return LNumber(e).or(t)},"(| a b)\n\n Function that calculates the bitwise or operation."),"&":doc("&",function(e,t){return LNumber(e).and(t)},"(& a b)\n\n Function that calculates the bitwise and operation."),"~":doc("~",function(e){return LNumber(e).neg()},"(~ number)\n\n Function that calculates the bitwise inverse (flip all the bits)."),">>":doc(">>",function(e,t){return LNumber(e).shr(t)},"(>> a b)\n\n Function that right shifts the value a by value b bits."),"<<":doc("<<",function(e,t){return LNumber(e).shl(t)},"(<< a b)\n\n Function that left shifts the value a by value b bits."),not:doc("not",function e(t){if(is_null(t)){return true}return!t},"(not object)\n\n Function that returns the Boolean negation of its argument.")},undefined,"global");var user_env=global_env.inherit("user-env");function set_interaction_env(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.");global_env.set("**interaction-environment**",e)}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.");(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(t){var r=e[t]?e[t]:t;global_env.set(r,doc(r,function(e){typecheck(r,e,"number");if(e instanceof LNumber){return e[t]()}},"(".concat(r," number)\n\n Function that calculates the ").concat(r," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var t=[];var r=allPossibleCases(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(is_function(r)){return"Invalid type: got ".concat(t).concat(i)}if(r instanceof Array){if(r.length===1){var a=r[0].toLowerCase();r="a"+("aeiou".includes(a)?"n ":" ")+r[0]}else{var o=r[r.length-1];r=r.slice(0,-1).join(", ")+" or "+o}}return"Expecting ".concat(r,", got ").concat(t).concat(i)}function typecheck_args(r,e,n){e.forEach(function(e,t){typecheck(r,e,n,t+1)})}function typecheck_text_port(e,t,r){typecheck(e,t,r);if(t.__type__===binary_port){throw new Error(typeErrorMessage(e,"binary-port","textual-port"))}}function typecheck(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;e=e.valueOf();var i=type(t).toLowerCase();if(is_function(r)){if(!r(t)){throw new Error(typeErrorMessage(e,i,r,n))}return}var a=false;if(r instanceof Pair){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)){a=true}}else{r=r.valueOf().toLowerCase()}if(!a&&i!==r){throw new Error(typeErrorMessage(e,i,r,n))}}function self_evaluated(e){var t=_typeof(e);return["string","function"].includes(t)||_typeof(e)==="symbol"||e instanceof QuotedPromise||e instanceof LSymbol||e instanceof LNumber||e instanceof LString||e instanceof RegExp}function is_native(e){return e instanceof LNumber||e instanceof LString||e instanceof LCharacter}function has_own_symbol(e,t){if(e===null){return false}return _typeof(e)==="object"&&t in Object.getOwnPropertySymbols(e)}function is_iterator(e,t){if(has_own_symbol(e,t)||has_own_symbol(e.__proto__,t)){return is_function(e[t])}}function memoize(r){var n=new WeakMap;return function(e){var t=n.get(e);if(!t){t=r(e)}return t}}type=memoize(type);function type(e){var t=type_constants.get(e);if(t){return t}if(_typeof(e)==="object"){for(var r=0,n=Object.entries(type_mapping);r2&&arguments[2]!==undefined?arguments[2]:{},n=r.env,i=r.dynamic_env,a=r.use_dynamic;var o=n===null||n===void 0?void 0:n.new_frame(e,t);var u=i===null||i===void 0?void 0:i.new_frame(e,t);var s=new LambdaContext({env:o,use_dynamic:a,dynamic_env:u});return resolve_promises(e.apply(s,t))}function apply(n,e){var t=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},i=t.env,a=t.dynamic_env,o=t.use_dynamic,r=t.error,u=r===void 0?function(){}:r;e=evaluate_args(e,{env:i,dynamic_env:a,error:u,use_dynamic:o});return unpromise(e,function(e){if(is_raw_lambda(n)){n=unbind(n)}e=prepare_fn_args(n,e);var t=e.slice();var r=call_function(n,t,{env:i,dynamic_env:a,use_dynamic:o});return unpromise(r,function(e){if(e instanceof Pair){e.markCycles();return quote(e)}return box(e)},u)})}var _p_name__=new WeakMap;var Parameter=function(){function n(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;_classCallCheck(this,n);_defineProperty(this,"__value__",void 0);_defineProperty(this,"__fn__",void 0);_classPrivateFieldInitSpec(this,_p_name__,{writable:true,value:void 0});this.__value__=e;if(t){if(!is_function(t)){throw new Error("Section argument to Parameter need to be function "+"".concat(type(t)," given"))}this.__fn__=t}if(r){_classPrivateFieldSet(this,_p_name__,r)}}_createClass(n,[{key:"__name__",get:function e(){return _classPrivateFieldGet(this,_p_name__)},set:function e(t){_classPrivateFieldSet(this,_p_name__,t);if(this.__fn__){this.__fn__.__name__="fn-".concat(t)}}},{key:"invoke",value:function e(){if(is_function(this.__fn__)){return this.__fn__(this.__value__)}return this.__value__}},{key:"inherit",value:function e(t){return new n(t,this.__fn__,this.__name__)}}]);return n}();var LambdaContext=function(){function t(e){_classCallCheck(this,t);_defineProperty(this,"env",void 0);_defineProperty(this,"dynamic_env",void 0);_defineProperty(this,"use_dynamic",void 0);Object.assign(this,e)}_createClass(t,[{key:"__name__",get:function e(){return this.env.__name__}},{key:"__parent__",get:function e(){return this.env.__parent__}},{key:"get",value:function e(){var t;return(t=this.env).get.apply(t,arguments)}}]);return t}();function search_param(e,t){var r=e.get(t.__name__,{throwError:false});if(is_parameter(r)&&r!==t){return r}var n=user_env.get("**interaction-environment**");while(true){var i=e.get("parent.frame",{throwError:false});e=i(0);if(e===n){break}r=e.get(t.__name__,{throwError:false});if(is_parameter(r)&&r!==t){return r}}return t}var Continuation=function(){function t(e){_classCallCheck(this,t);_defineProperty(this,"__value__",void 0);this.__value__=e}_createClass(t,[{key:"invoke",value:function e(){if(this.__value__===null){throw new Error("Continuations are not implemented yet")}}}]);return t}();var noop=function e(){};function _evaluate(u){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},s=e.env,c=e.dynamic_env,l=e.use_dynamic,t=e.error,f=t===void 0?noop:t,r=_objectWithoutProperties(e,_excluded6);return function(e){try{if(!is_env(c)){c=s===true?user_env:s||user_env}if(l){s=c}else if(s===true){s=user_env}else{s=s||global_env}var t={env:s,dynamic_env:c,use_dynamic:l,error:f};var r;if(is_null(u)){return u}if(u instanceof LSymbol){return s.get(u)}if(!(u instanceof Pair)){return u}var n=u.car;var e=u.cdr;if(n instanceof Pair){r=resolve_promises(_evaluate(n,t));if(is_promise(r)){return r.then(function(e){if(!is_callable(e)){throw new Error(type(e)+" "+s.get("repr")(e)+" is not callable while evaluating "+u.toString())}return _evaluate(new Pair(e,u.cdr),t)})}else if(!is_callable(r)){throw new Error(type(r)+" "+s.get("repr")(r)+" is not callable while evaluating "+u.toString())}}if(n instanceof LSymbol){r=s.get(n)}else if(is_function(n)){r=n}var i;if(r instanceof Syntax){i=evaluate_syntax(r,u,t)}else if(r instanceof Macro){i=evaluate_macro(r,e,t)}else if(is_function(r)){i=apply(r,e,t)}else if(is_parameter(r)){var a=search_param(c,r);if(is_null(u.cdr)){i=a.invoke()}else{return unpromise(_evaluate(u.cdr.car,t),function(e){a.__value__=e})}}else if(is_continuation(r)){i=r.invoke()}else if(u instanceof Pair){r=n&&n.toString();throw new Error("".concat(type(n)," ").concat(r," is not a function"))}else{return u}var o=s.get(Symbol["for"]("__promise__"),{throwError:false});if(o===true&&is_promise(i)){i=i.then(function(e){if(e instanceof Pair&&!r[__data__]){return _evaluate(e,t)}return e});return new QuotedPromise(i)}return i}catch(e){f&&f.call(s,e,u)}}(r)}var compile=exec_collect(function(e){return e});var exec=exec_collect(function(e,t){return t});function exec_collect(y){return function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function e(r){var n,i,a,_,o,p,u,s,h,c,d,l,m,f=arguments;return _regeneratorRuntime.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:n=f.length>1&&f[1]!==undefined?f[1]:{},i=n.env,a=n.dynamic_env,_=n.use_dynamic;if(!is_env(a)){a=i===true?user_env:i||user_env}if(i===true){i=user_env}else{i=i||user_env}o=[];p=Array.isArray(r)?r:_parse(r);u=false;s=false;t.prev=7;c=_asyncIterator(p);case 9:t.next=11;return c.next();case 11:if(!(u=!(d=t.sent).done)){t.next=25;break}l=d.value;m=_evaluate(l,{env:i,dynamic_env:a,use_dynamic:_,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}});t.t0=o;t.t1=y;t.t2=l;t.next=19;return m;case 19:t.t3=t.sent;t.t4=(0,t.t1)(t.t2,t.t3);t.t0.push.call(t.t0,t.t4);case 22:u=false;t.next=9;break;case 25:t.next=31;break;case 27:t.prev=27;t.t5=t["catch"](7);s=true;h=t.t5;case 31:t.prev=31;t.prev=32;if(!(u&&c["return"]!=null)){t.next=36;break}t.next=36;return c["return"]();case 36:t.prev=36;if(!s){t.next=39;break}throw h;case 39:return t.finish(36);case 40:return t.finish(31);case 41:return t.abrupt("return",o);case 42:case"end":return t.stop()}}},e,null,[[7,27,31,41],[32,,36,40]])}));function e(e){return t.apply(this,arguments)}return e}()}function balanced(e){var t={"[":"]","(":")"};var r;if(typeof e==="string"){r=tokenize(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 a=new Stack;var o=_createForOfIteratorHelper(r),u;try{for(o.s();!(u=o.n()).done;){var s=u.value;if(n.includes(s)){a.push(s)}else if(!a.is_empty()){var l=a.top();var c=t[l];if(s===c){a.pop()}else{throw new Error("Syntax error: missing closing ".concat(c))}}else{throw new Error("Syntax error: not matched closing ".concat(s))}}}catch(e){o.e(e)}finally{o.f()}return a.is_empty()}function fworker(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 root.Worker(r.createObjectURL(n))}function is_dev(){return lips.version.match(/^(\{\{VER\}\}|DEV)$/)}function get_current_script(){if(is_node()){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 current_script=get_current_script();function bootstrap(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";var t="dist/std.xcb";if(e===""){if(current_script){e=current_script.replace(/[^/]*$/,"std.xcb")}else if(is_dev()){e="https://cdn.jsdelivr.net/gh/jcubic/lips@devel/".concat(t)}else{e="https://cdn.jsdelivr.net/npm/@jcubic/lips@".concat(lips.version,"/").concat(t)}}var r=global_env.get("load");return r.call(user_env,e,global_env)}function Worker(e){this.url=e;var o=this.worker=fworker(function(){var o;var u;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(!u){i("Worker RPC: LIPS not initialized, call init first");return}u.then(function(){var e=r.params[0];var t=r.params[1];o.exec(e,{use_dynamic: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 a=r.params[0];if(typeof a!=="string"){i("Worker RPC: url is not a string")}else{importScripts("".concat(a,"/dist/lips.min.js"));o=new lips.Interpreter("worker");u=bootstrap(a);u.then(function(){n(true)})}}})});this.rpc=function(){var n=0;return function e(t,r){var a=++n;return new Promise(function(n,i){o.addEventListener("message",function e(t){var r=t.data;if(r&&r.type==="RPC"&&r.id===a){if(r.error){i(r.error)}else{n(r.result)}o.removeEventListener("message",e)}});o.postMessage({type:"RPC",method:t,id:a,params:r})})}}();this.rpc("init",[e])["catch"](function(e){console.error(e)});this.exec=function(e,t){var r=t.use_dynamic,n=r===void 0?false:r;return this.rpc("eval",[e,n])}}var serialization_map={pair:function e(t){var r=_slicedToArray(t,2),n=r[0],i=r[1];return Pair(n,i)},number:function e(t){if(LString.isString(t)){return LNumber([t,10])}return LNumber(t)},regex:function e(t){var r=_slicedToArray(t,2),n=r[0],i=r[1];return new RegExp(n,i)},nil:function e(){return _nil},symbol:function e(t){if(LString.isString(t)){return LSymbol(t)}else if(Array.isArray(t)){return LSymbol(Symbol["for"](t[0]))}},string:LString,character:LCharacter};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];class_map[cls]=+i}function mangle_name(e){return class_map[e]}function resolve_name(e){return available_class[e]}function serialize(e){return JSON.stringify(e,function(e,t){var r=this[e];if(r){if(r instanceof RegExp){return{"@":mangle_name("regex"),"#":[r.source,r.flags]}}var n=mangle_name(r.constructor.__class__);if(!is_undef(n)){return{"@":n,"#":r.serialize()}}}return t})}function unserialize(e){return JSON.parse(e,function(e,t){if(t&&_typeof(t)==="object"){if(!is_undef(t["@"])){var r=resolve_name(t["@"]);if(serialization_map[r]){return serialization_map[r](t["#"])}}}return t})}var cbor=function(){var e={pair:Pair,symbol:LSymbol,number:LNumber,string:LString,character:LCharacter,nil:_nil.constructor,regex:RegExp};function t(e,t){return{deserialize:t,Class:e}}var r=new Encoder;var a={};for(var n=0,i=Object.entries(serialization_map);n1){var n=t.reduce(function(e,t){return e+t.length},0);var i=new Uint8Array(n);var a=0;t.forEach(function(e){i.set(e,a);a+=e.length});return i}else if(t.length){return t[0]}}function encode_magic(){var e=1;var t=new TextEncoder("utf-8");return t.encode("LIPS".concat(e.toString().padStart(3," ")))}var MAGIC_LENGTH=7;function decode_magic(e){var t=new TextDecoder("utf-8");var r=t.decode(e.slice(0,MAGIC_LENGTH));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 serialize_bin(e){var t=encode_magic();var r=cbor.encode(e);return merge_uint8_array(t,pack_1(r,{magic:false}))}function unserialize_bin(e){var t=decode_magic(e),r=t.type,n=t.version;if(r==="LIPS"&&n===1){var i=unpack_1(e.slice(MAGIC_LENGTH),{magic:false});return cbor.decode(i)}else{throw new Error("Invalid file format ".concat(r))}}function execError(e){console.error(e.message||e);if(e.code){console.error(e.code.map(function(e,t){return"[".concat(t+1,"]: ").concat(e)}))}}function init(){var o=["text/x-lips","text/x-scheme"];var u;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(exec).then(t)["catch"](function(e){execError(e);t()})}else{return exec(r.innerHTML).then(t)["catch"](function(e){execError(e);t()})}})}function e(){return new Promise(function(i){var a=Array.from(document.querySelectorAll("script"));return function e(){var t=a.shift();if(!t){i()}else{var r=t.getAttribute("type");if(o.includes(r)){var n=t.getAttribute("bootstrap");if(!u&&typeof n==="string"){return bootstrap(n).then(function(){return s(t)}).then(e)}else{return s(t).then(e)}}else if(r&&r.match(/lips|lisp/)){console.warn("Expecting "+o.join(" or ")+" found "+r)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var t=currentScript;var r=t.getAttribute("bootstrap");if(typeof r==="string"){return bootstrap(r).then(function(){u=true;return e()})}}return e()}var currentScript=typeof window!=="undefined"&&window.document&&document.currentScript;if(typeof window!=="undefined"){contentLoaded(window,init)}var banner=function(){var e=LString("Mon, 15 Jan 2024 14:02:37 +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 a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".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 a}();read_only(Ahead,"__class__","ahead");read_only(Pair,"__class__","pair");read_only(Nil,"__class__","nil");read_only(Pattern,"__class__","pattern");read_only(Formatter,"__class__","formatter");read_only(Macro,"__class__","macro");read_only(Syntax,"__class__","syntax");read_only(Environment,"__class__","environment");read_only(InputPort,"__class__","input-port");read_only(OutputPort,"__class__","output-port");read_only(BufferedOutputPort,"__class__","output-port");read_only(OutputStringPort,"__class__","output-string-port");read_only(InputStringPort,"__class__","input-string-port");read_only(InputFilePort,"__class__","input-file-port");read_only(OutputFilePort,"__class__","output-file-port");read_only(LipsError,"__class__","lips-error");[LNumber,LComplex,LRational,LFloat,LBigInteger].forEach(function(e){read_only(e,"__class__","number")});read_only(LCharacter,"__class__","character");read_only(LSymbol,"__class__","symbol");read_only(LString,"__class__","string");read_only(QuotedPromise,"__class__","promise");read_only(Parameter,"__class__","parameter");var version="DEV";var date="Mon, 15 Jan 2024 14:02:37 +0000";var parse=compose(uniterate_async,_parse);var lips={version:version,banner:banner,date:date,exec:exec,parse:parse,tokenize:tokenize,evaluate:_evaluate,compile:compile,serialize:serialize,unserialize:unserialize,serialize_bin:serialize_bin,unserialize_bin:unserialize_bin,bootstrap:bootstrap,Environment:Environment,env:user_env,Worker:Worker,Interpreter:Interpreter,balanced_parenthesis:balanced,balancedParenthesis:balanced,balanced:balanced,Macro:Macro,Syntax:Syntax,Pair:Pair,Values:Values,QuotedPromise:QuotedPromise,Error:LipsError,quote:quote,InputPort:InputPort,OutputPort:OutputPort,BufferedOutputPort:BufferedOutputPort,InputFilePort:InputFilePort,OutputFilePort:OutputFilePort,InputStringPort:InputStringPort,OutputStringPort:OutputStringPort,InputByteVectorPort:InputByteVectorPort,OutputByteVectorPort:OutputByteVectorPort,InputBinaryFilePort:InputBinaryFilePort,OutputBinaryFilePort:OutputBinaryFilePort,Formatter:Formatter,Parser:Parser,Lexer:Lexer,specials:specials,repr:repr,nil:_nil,eof:eof,LSymbol:LSymbol,LNumber:LNumber,LFloat:LFloat,LComplex:LComplex,LRational:LRational,LBigInteger:LBigInteger,LCharacter:LCharacter,LString:LString,Parameter:Parameter,rationalize:rationalize};global_env.set("lips",lips);var empty={};var empty$1=Object.freeze({__proto__:null,default:empty});function normalizeArray(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 splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var splitPath=function(e){return splitPathRe.exec(e).slice(1)};function resolve(){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=normalizeArray(filter(e.split("/"),function(e){return!!e}),!t).join("/");return(t?"/":"")+e||"."}function normalize(e){var t=isAbsolute(e),r=substr(e,-1)==="/";e=normalizeArray(filter(e.split("/"),function(e){return!!e}),!t).join("/");if(!e&&!t){e="."}if(e&&r){e+="/"}return(t?"/":"")+e}function isAbsolute(e){return e.charAt(0)==="/"}function join(){var e=Array.prototype.slice.call(arguments,0);return normalize(filter(e,function(e,t){if(typeof e!=="string"){throw new TypeError("Arguments to path.join must be strings")}return e}).join("/"))}function relative(e,t){e=resolve(e).substr(1);t=resolve(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 a=Math.min(n.length,i.length);var o=a;for(var u=0;u 1 && arguments[1] !== undefined ? arguments[1] : function (x) { @@ -7960,9 +7960,9 @@ // :: Function that return matcher function that match string against string // ---------------------------------------------------------------------- function _uniterate_async() { - _uniterate_async = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(object) { + _uniterate_async = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(object) { var result, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, item; - return _regeneratorRuntime.wrap(function _callee22$(_context22) { + return _regeneratorRuntime.wrap(function _callee21$(_context22) { while (1) { switch (_context22.prev = _context22.next) { case 0: @@ -8020,7 +8020,7 @@ return _context22.stop(); } } - }, _callee22, null, [[3, 15, 19, 29], [20,, 24, 28]]); + }, _callee21, null, [[3, 15, 19, 29], [20,, 24, 28]]); })); return _uniterate_async.apply(this, arguments); } @@ -13629,7 +13629,7 @@ 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; @@ -13778,7 +13778,7 @@ _iteratorAbruptCompletion2 = false; _didIteratorError2 = false; _context16.prev = 5; - _iterator2 = _asyncIterator(parse(arg, env)); + _iterator2 = _asyncIterator(_parse(arg, env)); case 7: _context16.next = 9; return _iterator2.next(); @@ -14229,9 +14229,9 @@ }, "(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': doc(new Macro('do', /*#__PURE__*/function () { - var _ref31 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(code, _ref32) { + var _ref31 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(code, _ref32) { var use_dynamic, error, self, dynamic_env, scope, vars, test, body, eval_args, node, item, _loop3; - return _regeneratorRuntime.wrap(function _callee19$(_context19) { + return _regeneratorRuntime.wrap(function _callee18$(_context19) { while (1) { switch (_context19.prev = _context19.next) { case 0: @@ -14274,9 +14274,9 @@ dynamic_env: dynamic_env, error: error }; - _loop3 = /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() { + _loop3 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop3() { var node, next, _item, value, symbols; - return _regeneratorRuntime.wrap(function _callee18$(_context18) { + return _regeneratorRuntime.wrap(function _loop3$(_context18) { while (1) { switch (_context18.prev = _context18.next) { case 0: @@ -14318,7 +14318,7 @@ return _context18.stop(); } } - }, _callee18); + }, _loop3); }); case 23: _context19.next = 25; @@ -14347,7 +14347,7 @@ return _context19.stop(); } } - }, _callee19, this); + }, _callee18, this); })); return function (_x15, _x16) { return _ref31.apply(this, arguments); @@ -16197,14 +16197,14 @@ } // ------------------------------------------------------------------------- /* c8 ignore next 11 */ function _node_specific() { - _node_specific = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23() { + _node_specific = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22() { var _yield$import, createRequire, moduleURL, __dirname, __filename; - return _regeneratorRuntime.wrap(function _callee23$(_context23) { + return _regeneratorRuntime.wrap(function _callee22$(_context23) { while (1) { switch (_context23.prev = _context23.next) { case 0: _context23.next = 2; - return Promise.resolve().then(function () { return empty$1; }); + return import('mod' + 'ule'); case 2: _yield$import = _context23.sent; createRequire = _yield$import.createRequire; @@ -16258,7 +16258,7 @@ return _context23.stop(); } } - }, _callee23); + }, _callee22); })); return _node_specific.apply(this, arguments); } @@ -16455,9 +16455,9 @@ return _promise.apply(this, arguments); } function _promise() { - _promise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(node) { + _promise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(node) { var pair; - return _regeneratorRuntime.wrap(function _callee20$(_context20) { + return _regeneratorRuntime.wrap(function _callee19$(_context20) { while (1) { switch (_context20.prev = _context20.next) { case 0: @@ -16500,7 +16500,7 @@ return _context20.stop(); } } - }, _callee20); + }, _callee19); })); return _promise.apply(this, arguments); } @@ -16912,7 +16912,7 @@ // ------------------------------------------------------------------------- function exec_collect(collect_callback) { return /*#__PURE__*/function () { - var _exec_lambda = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(arg) { + var _exec_lambda = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(arg) { var _ref47, env, dynamic_env, @@ -16927,7 +16927,7 @@ code, value, _args24 = arguments; - return _regeneratorRuntime.wrap(function _callee21$(_context21) { + return _regeneratorRuntime.wrap(function _callee20$(_context21) { while (1) { switch (_context21.prev = _context21.next) { case 0: @@ -16941,7 +16941,7 @@ env = env || user_env; } results = []; - input = Array.isArray(arg) ? arg : parse(arg); + input = Array.isArray(arg) ? arg : _parse(arg); _iteratorAbruptCompletion3 = false; _didIteratorError3 = false; _context21.prev = 7; @@ -17025,7 +17025,7 @@ return _context21.stop(); } } - }, _callee21, null, [[7, 27, 31, 41], [32,, 36, 40]]); + }, _callee20, null, [[7, 27, 31, 41], [32,, 36, 40]]); })); function exec_lambda(_x19) { return _exec_lambda.apply(this, arguments); @@ -17552,10 +17552,10 @@ // ------------------------------------------------------------------------- var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Mon, 15 Jan 2024 12:39:38 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Mon, 15 Jan 2024 14:02:37 +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('Mon, 15 Jan 2024 12:39:38 +0000').valueOf(); + var date = LString('Mon, 15 Jan 2024 14:02:37 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); var _format = function _format(x) { return x.toString().padStart(2, '0'); @@ -17593,13 +17593,17 @@ read_only(QuotedPromise, '__class__', 'promise'); read_only(Parameter, '__class__', 'parameter'); // ------------------------------------------------------------------------- + var version = 'DEV'; + var date = 'Mon, 15 Jan 2024 14:02:37 +0000'; + + // unwrap async generator into Promise + var parse = compose(uniterate_async, _parse); var lips = { - version: 'DEV', + version: version, banner: banner, - date: 'Mon, 15 Jan 2024 12:39:38 +0000', + date: date, exec: exec, - // unwrap async generator into Promise - parse: compose(uniterate_async, parse), + parse: parse, tokenize: tokenize, evaluate: _evaluate, compile: compile, @@ -17908,6 +17912,62 @@ 'default': path }); - return lips; + exports.BufferedOutputPort = BufferedOutputPort; + exports.Environment = Environment; + exports.Error = LipsError; + exports.Formatter = Formatter; + exports.InputBinaryFilePort = InputBinaryFilePort; + exports.InputByteVectorPort = InputByteVectorPort; + exports.InputFilePort = InputFilePort; + exports.InputPort = InputPort; + exports.InputStringPort = InputStringPort; + exports.Interpreter = Interpreter; + exports.LBigInteger = LBigInteger; + exports.LCharacter = LCharacter; + exports.LComplex = LComplex; + exports.LFloat = LFloat; + exports.LNumber = LNumber; + exports.LRational = LRational; + exports.LString = LString; + exports.LSymbol = LSymbol; + exports.Lexer = Lexer; + exports.Macro = Macro; + exports.OutputBinaryFilePort = OutputBinaryFilePort; + exports.OutputByteVectorPort = OutputByteVectorPort; + exports.OutputFilePort = OutputFilePort; + exports.OutputPort = OutputPort; + exports.OutputStringPort = OutputStringPort; + exports.Pair = Pair; + exports.Parameter = Parameter; + exports.Parser = Parser; + exports.QuotedPromise = QuotedPromise; + exports.Syntax = Syntax; + exports.Values = Values; + exports.Worker = Worker; + exports.balanced = balanced; + exports.balancedParenthesis = balanced; + exports.balanced_parenthesis = balanced; + exports.banner = banner; + exports.bootstrap = bootstrap; + exports.compile = compile; + exports.date = date; + exports.env = user_env; + exports.eof = eof; + exports.evaluate = _evaluate; + exports.exec = exec; + exports.nil = _nil; + exports.parse = parse; + exports.quote = quote; + exports.rationalize = rationalize; + exports.repr = repr; + exports.serialize = serialize; + exports.serialize_bin = serialize_bin; + exports.specials = specials; + exports.tokenize = tokenize; + exports.unserialize = unserialize; + exports.unserialize_bin = unserialize_bin; + exports.version = version; + + Object.defineProperty(exports, '__esModule', { value: true }); })); diff --git a/dist/lips.min.js b/dist/lips.min.js index bcfc92238..aa0aebc91 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -1,10 +1,10 @@ -(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 n(e,t){if(t.get){return t.get.call(e)}return t.value}function i(e,t,r){if(!t.has(e)){throw new TypeError("attempted to "+r+" private field on non-instance")}return t.get(e)}function t(e,t){var r=i(e,t,"get");return n(e,r)}function u(e,t,r){if(t.set){t.set.call(e,r)}else{if(!t.writable){throw new TypeError("attempted to set read only private field")}t.value=r}}function a(e,t,r){var n=i(e,t,"set");u(e,n,r);return r}function o(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function c(e,t){c=Object.setPrototypeOf||function e(t,r){t.__proto__=r;return t};return c(e,t)}function f(){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(f()){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)c(a,n.prototype);return a}}return p.apply(null,arguments)}function _(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)c(e,t)}function d(e){"@babel/helpers - typeof";return d="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},d(e)}function m(e,t){if(t&&(d(t)==="object"||typeof t==="function")){return t}else if(t!==void 0){throw new TypeError("Derived constructors may only return object or undefined")}return o(e)}function g(e){g=Object.setPrototypeOf?Object.getPrototypeOf:function e(t){return t.__proto__||Object.getPrototypeOf(t)};return g(e)}function r(e){if(Array.isArray(e))return e}function b(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function w(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 R(e,t){if(e==null)return{};var r=N(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 T(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 Y(e,t){return r(e)||T(e,t)||D(e,t)||E()}function V(e){this.wrapped=e}function z(e){return new V(e)}function $(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 V;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}}$.prototype[typeof Symbol==="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this};$.prototype.next=function(e){return this._invoke("next",e)};$.prototype["throw"]=function(e){return this._invoke("throw",e)};$.prototype["return"]=function(e){return this._invoke("return",e)};function e(e){return function(){return new $(e.apply(this,arguments))}}function J(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}var K={exports:{}};var G={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)}}})(G);(function(e){e.exports=G.exports})(K);var H=J(K.exports);var W=typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{};var Q=[];var Z=[];var X=typeof Uint8Array!=="undefined"?Uint8Array:Array;var ee=false;function te(){ee=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 X(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=Z[e.charCodeAt(t)]<<2|Z[e.charCodeAt(t+1)]>>4;a[s++]=i&255}else if(u===1){i=Z[e.charCodeAt(t)]<<10|Z[e.charCodeAt(t+1)]<<4|Z[e.charCodeAt(t+2)]>>2;a[s++]=i>>8&255;a[s++]=i&255}return a}function ne(e){return Q[e>>18&63]+Q[e>>12&63]+Q[e>>6&63]+Q[e&63]}function ie(e,t,r){var n;var i=[];for(var u=t;us?s:o+a))}if(n===1){t=e[r-1];i+=Q[t>>2];i+=Q[t<<4&63];i+="=="}else if(n===2){t=(e[r-2]<<8)+e[r-1];i+=Q[t>>10];i+=Q[t>>4&63];i+=Q[t<<2&63];i+="="}u.push(i);return u.join("")}function ae(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 oe(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 se={}.toString;var ce=Array.isArray||function(e){return se.call(e)=="[object Array]"}; +(function(e,t){typeof exports==="object"&&typeof module!=="undefined"?t(exports):typeof define==="function"&&define.amd?define(["exports"],t):(e=typeof globalThis!=="undefined"?globalThis:e||self,t(e.lips={}))})(this,function(e){"use strict";function n(e,t){if(t.get){return t.get.call(e)}return t.value}function i(e,t,r){if(!t.has(e)){throw new TypeError("attempted to "+r+" private field on non-instance")}return t.get(e)}function t(e,t){var r=i(e,t,"get");return n(e,r)}function u(e,t,r){if(t.set){t.set.call(e,r)}else{if(!t.writable){throw new TypeError("attempted to set read only private field")}t.value=r}}function a(e,t,r){var n=i(e,t,"set");u(e,n,r);return r}function o(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function c(e,t){c=Object.setPrototypeOf||function e(t,r){t.__proto__=r;return t};return c(e,t)}function f(){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(f()){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)c(a,n.prototype);return a}}return p.apply(null,arguments)}function _(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)c(e,t)}function d(e){"@babel/helpers - typeof";return d="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},d(e)}function m(e,t){if(t&&(d(t)==="object"||typeof t==="function")){return t}else if(t!==void 0){throw new TypeError("Derived constructors may only return object or undefined")}return o(e)}function g(e){g=Object.setPrototypeOf?Object.getPrototypeOf:function e(t){return t.__proto__||Object.getPrototypeOf(t)};return g(e)}function r(e){if(Array.isArray(e))return e}function b(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function w(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 R(e,t){if(e==null)return{};var r=N(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 T(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 z(e,t){return r(e)||T(e,t)||D(e,t)||E()}function V(e){this.wrapped=e}function Y(e){return new V(e)}function $(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 V;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}}$.prototype[typeof Symbol==="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this};$.prototype.next=function(e){return this._invoke("next",e)};$.prototype["throw"]=function(e){return this._invoke("throw",e)};$.prototype["return"]=function(e){return this._invoke("return",e)};function J(e){return function(){return new $(e.apply(this,arguments))}}function K(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}var G={exports:{}};var H={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)}}})(H);(function(e){e.exports=H.exports})(G);var W=K(G.exports);var Q=typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{};var Z=[];var X=[];var ee=typeof Uint8Array!=="undefined"?Uint8Array:Array;var te=false;function re(){te=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 ee(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=X[e.charCodeAt(t)]<<2|X[e.charCodeAt(t+1)]>>4;a[s++]=i&255}else if(u===1){i=X[e.charCodeAt(t)]<<10|X[e.charCodeAt(t+1)]<<4|X[e.charCodeAt(t+2)]>>2;a[s++]=i>>8&255;a[s++]=i&255}return a}function ie(e){return Z[e>>18&63]+Z[e>>12&63]+Z[e>>6&63]+Z[e&63]}function ue(e,t,r){var n;var i=[];for(var u=t;us?s:o+a))}if(n===1){t=e[r-1];i+=Z[t>>2];i+=Z[t<<4&63];i+="=="}else if(n===2){t=(e[r-2]<<8)+e[r-1];i+=Z[t>>10];i+=Z[t>>4&63];i+=Z[t<<2&63];i+="="}u.push(i);return u.join("")}function oe(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 se(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 ce={}.toString;var fe=Array.isArray||function(e){return ce.call(e)=="[object Array]"}; /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT - */var fe=50;pe.TYPED_ARRAY_SUPPORT=W.TYPED_ARRAY_SUPPORT!==undefined?W.TYPED_ARRAY_SUPPORT:true;le();function le(){return pe.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function he(e,t){if(le()=le()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+le().toString(16)+" bytes")}return e|0}pe.isBuffer=at;function Ee(e){return!!(e!=null&&e._isBuffer)}pe.compare=function e(t,r){if(!Ee(t)||!Ee(r)){throw new TypeError("Arguments must be Buffers")}if(t===r)return 0;var n=t.length;var i=r.length;for(var u=0,a=Math.min(n,i);u>>1;case"base64":return nt(e).length;default:if(n)return et(e).length;t=(""+t).toLowerCase();n=true}}}pe.byteLength=Ae;function xe(e,t,r){var n=false;if(t===undefined||t<0){t=0}if(t>this.length){return""}if(r===undefined||r>this.length){r=this.length}if(r<=0){return""}r>>>=0;t>>>=0;if(r<=t){return""}if(!e)e="utf8";while(true){switch(e){case"hex":return qe(this,t,r);case"utf8":case"utf-8":return Re(this,t,r);case"ascii":return Ue(this,t,r);case"latin1":case"binary":return Me(this,t,r);case"base64":return Ne(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ye(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();n=true}}}pe.prototype._isBuffer=true;function Fe(e,t,r){var n=e[t];e[t]=e[r];e[r]=n}pe.prototype.swap16=function e(){var t=this.length;if(t%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var r=0;r0){t=this.toString("hex",0,r).match(/.{2}/g).join(" ");if(this.length>r)t+=" ... "}return""};pe.prototype.compare=function f(e,t,r,n,i){if(!Ee(e)){throw new TypeError("Argument must be a Buffer")}if(t===undefined){t=0}if(r===undefined){r=e?e.length:0}if(n===undefined){n=0}if(i===undefined){i=this.length}if(t<0||r>e.length||n<0||i>this.length){throw new RangeError("out of range index")}if(n>=i&&t>=r){return 0}if(n>=i){return-1}if(t>=r){return 1}t>>>=0;r>>>=0;n>>>=0;i>>>=0;if(this===e)return 0;var u=i-n;var a=r-t;var l=Math.min(u,a);var o=this.slice(n,i);var s=e.slice(t,r);for(var c=0;c2147483647){r=2147483647}else if(r<-2147483648){r=-2147483648}r=+r;if(isNaN(r)){r=i?0:e.length-1}if(r<0)r=e.length+r;if(r>=e.length){if(i)return-1;else r=e.length-1}else if(r<0){if(i)r=0;else return-1}if(typeof t==="string"){t=pe.from(t,n)}if(Ee(t)){if(t.length===0){return-1}return Ce(e,t,r,n,i)}else if(typeof t==="number"){t=t&255;if(pe.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf==="function"){if(i){return Uint8Array.prototype.indexOf.call(e,t,r)}else{return Uint8Array.prototype.lastIndexOf.call(e,t,r)}}return Ce(e,[t],r,n,i)}throw new TypeError("val must be string, number or Buffer")}function Ce(e,t,r,n,f){var i=1;var u=e.length;var a=t.length;if(n!==undefined){n=String(n).toLowerCase();if(n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le"){if(e.length<2||t.length<2){return-1}i=2;u/=2;a/=2;r/=2}}function o(e,t){if(i===1){return e[t]}else{return e.readUInt16BE(t*i)}}var s;if(f){var c=-1;for(s=r;su)r=u-a;for(s=r;s>=0;s--){var l=true;for(var h=0;hi){n=i}}var u=t.length;if(u%2!==0)throw new TypeError("Invalid hex string");if(n>u/2){n=u/2}for(var a=0;au)n=u;if(t.length>0&&(n<0||r<0)||r>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!i)i="utf8";var a=false;for(;;){switch(i){case"hex":return Oe(this,t,r,n);case"utf8":case"utf-8":return Se(this,t,r,n);case"ascii":return Be(this,t,r,n);case"latin1":case"binary":return je(this,t,r,n);case"base64":return Ie(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Pe(this,t,r,n);default:if(a)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase();a=true}}};pe.prototype.toJSON=function e(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Ne(e,t,r){if(t===0&&r===e.length){return ue(e)}else{return ue(e.slice(t,r))}}function Re(e,f,t){t=Math.min(e.length,t);var r=[];var n=f;while(n239?4:i>223?3:i>191?2:1;if(n+a<=t){var o,s,l,c;switch(a){case 1:if(i<128){u=i}break;case 2:o=e[n+1];if((o&192)===128){c=(i&31)<<6|o&63;if(c>127){u=c}}break;case 3:o=e[n+1];s=e[n+2];if((o&192)===128&&(s&192)===128){c=(i&15)<<12|(o&63)<<6|s&63;if(c>2047&&(c<55296||c>57343)){u=c}}break;case 4:o=e[n+1];s=e[n+2];l=e[n+3];if((o&192)===128&&(s&192)===128&&(l&192)===128){c=(i&15)<<18|(o&63)<<12|(s&63)<<6|l&63;if(c>65535&&c<1114112){u=c}}}}if(u===null){u=65533;a=1}else if(u>65535){u-=65536;r.push(u>>>10&1023|55296);u=56320|u&1023}r.push(u);n+=a}return Le(r)}var Te=4096;function Le(e){var t=e.length;if(t<=Te){return String.fromCharCode.apply(String,e)}var r="";var n=0;while(nn)r=n;var i="";for(var u=t;un){t=n}if(r<0){r+=n;if(r<0)r=0}else if(r>n){r=n}if(rr)throw new RangeError("Trying to access beyond buffer length")}pe.prototype.readUIntLE=function e(t,r,n){t=t|0;r=r|0;if(!n)Ve(t,r,this.length);var i=this[t];var u=1;var a=0;while(++a0&&(u*=256)){i+=this[t+--r]*u}return i};pe.prototype.readUInt8=function e(t,r){if(!r)Ve(t,1,this.length);return this[t]};pe.prototype.readUInt16LE=function e(t,r){if(!r)Ve(t,2,this.length);return this[t]|this[t+1]<<8};pe.prototype.readUInt16BE=function e(t,r){if(!r)Ve(t,2,this.length);return this[t]<<8|this[t+1]};pe.prototype.readUInt32LE=function e(t,r){if(!r)Ve(t,4,this.length);return(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};pe.prototype.readUInt32BE=function e(t,r){if(!r)Ve(t,4,this.length);return this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};pe.prototype.readIntLE=function e(t,r,n){t=t|0;r=r|0;if(!n)Ve(t,r,this.length);var i=this[t];var u=1;var a=0;while(++a=u)i-=Math.pow(2,8*r);return i};pe.prototype.readIntBE=function e(t,r,n){t=t|0;r=r|0;if(!n)Ve(t,r,this.length);var i=r;var u=1;var a=this[t+--i];while(i>0&&(u*=256)){a+=this[t+--i]*u}u*=128;if(a>=u)a-=Math.pow(2,8*r);return a};pe.prototype.readInt8=function e(t,r){if(!r)Ve(t,1,this.length);if(!(this[t]&128))return this[t];return(255-this[t]+1)*-1};pe.prototype.readInt16LE=function e(t,r){if(!r)Ve(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};pe.prototype.readInt16BE=function e(t,r){if(!r)Ve(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};pe.prototype.readInt32LE=function e(t,r){if(!r)Ve(t,4,this.length);return this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};pe.prototype.readInt32BE=function e(t,r){if(!r)Ve(t,4,this.length);return this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};pe.prototype.readFloatLE=function e(t,r){if(!r)Ve(t,4,this.length);return ae(this,t,true,23,4)};pe.prototype.readFloatBE=function e(t,r){if(!r)Ve(t,4,this.length);return ae(this,t,false,23,4)};pe.prototype.readDoubleLE=function e(t,r){if(!r)Ve(t,8,this.length);return ae(this,t,true,52,8)};pe.prototype.readDoubleBE=function e(t,r){if(!r)Ve(t,8,this.length);return ae(this,t,false,52,8)};function ze(e,t,r,n,i,u){if(!Ee(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}pe.prototype.writeUIntLE=function e(t,r,n,i){t=+t;r=r|0;n=n|0;if(!i){var u=Math.pow(2,8*n)-1;ze(this,t,r,n,u,0)}var a=1;var o=0;this[r]=t&255;while(++o=0&&(o*=256)){this[r+a]=t/o&255}return r+n};pe.prototype.writeUInt8=function e(t,r,n){t=+t;r=r|0;if(!n)ze(this,t,r,1,255,0);if(!pe.TYPED_ARRAY_SUPPORT)t=Math.floor(t);this[r]=t&255;return r+1};function $e(e,t,r,n){if(t<0)t=65535+t+1;for(var i=0,u=Math.min(e.length-r,2);i>>(n?i:1-i)*8}}pe.prototype.writeUInt16LE=function e(t,r,n){t=+t;r=r|0;if(!n)ze(this,t,r,2,65535,0);if(pe.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8}else{$e(this,t,r,true)}return r+2};pe.prototype.writeUInt16BE=function e(t,r,n){t=+t;r=r|0;if(!n)ze(this,t,r,2,65535,0);if(pe.TYPED_ARRAY_SUPPORT){this[r]=t>>>8;this[r+1]=t&255}else{$e(this,t,r,false)}return r+2};function Je(e,t,r,n){if(t<0)t=4294967295+t+1;for(var i=0,u=Math.min(e.length-r,4);i>>(n?i:3-i)*8&255}}pe.prototype.writeUInt32LE=function e(t,r,n){t=+t;r=r|0;if(!n)ze(this,t,r,4,4294967295,0);if(pe.TYPED_ARRAY_SUPPORT){this[r+3]=t>>>24;this[r+2]=t>>>16;this[r+1]=t>>>8;this[r]=t&255}else{Je(this,t,r,true)}return r+4};pe.prototype.writeUInt32BE=function e(t,r,n){t=+t;r=r|0;if(!n)ze(this,t,r,4,4294967295,0);if(pe.TYPED_ARRAY_SUPPORT){this[r]=t>>>24;this[r+1]=t>>>16;this[r+2]=t>>>8;this[r+3]=t&255}else{Je(this,t,r,false)}return r+4};pe.prototype.writeIntLE=function e(t,r,n,i){t=+t;r=r|0;if(!i){var u=Math.pow(2,8*n-1);ze(this,t,r,n,u-1,-u)}var a=0;var o=1;var s=0;this[r]=t&255;while(++a>0)-s&255}return r+n};pe.prototype.writeIntBE=function e(t,r,n,i){t=+t;r=r|0;if(!i){var u=Math.pow(2,8*n-1);ze(this,t,r,n,u-1,-u)}var a=n-1;var o=1;var s=0;this[r+a]=t&255;while(--a>=0&&(o*=256)){if(t<0&&s===0&&this[r+a+1]!==0){s=1}this[r+a]=(t/o>>0)-s&255}return r+n};pe.prototype.writeInt8=function e(t,r,n){t=+t;r=r|0;if(!n)ze(this,t,r,1,127,-128);if(!pe.TYPED_ARRAY_SUPPORT)t=Math.floor(t);if(t<0)t=255+t+1;this[r]=t&255;return r+1};pe.prototype.writeInt16LE=function e(t,r,n){t=+t;r=r|0;if(!n)ze(this,t,r,2,32767,-32768);if(pe.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8}else{$e(this,t,r,true)}return r+2};pe.prototype.writeInt16BE=function e(t,r,n){t=+t;r=r|0;if(!n)ze(this,t,r,2,32767,-32768);if(pe.TYPED_ARRAY_SUPPORT){this[r]=t>>>8;this[r+1]=t&255}else{$e(this,t,r,false)}return r+2};pe.prototype.writeInt32LE=function e(t,r,n){t=+t;r=r|0;if(!n)ze(this,t,r,4,2147483647,-2147483648);if(pe.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8;this[r+2]=t>>>16;this[r+3]=t>>>24}else{Je(this,t,r,true)}return r+4};pe.prototype.writeInt32BE=function e(t,r,n){t=+t;r=r|0;if(!n)ze(this,t,r,4,2147483647,-2147483648);if(t<0)t=4294967295+t+1;if(pe.TYPED_ARRAY_SUPPORT){this[r]=t>>>24;this[r+1]=t>>>16;this[r+2]=t>>>8;this[r+3]=t&255}else{Je(this,t,r,false)}return r+4};function Ke(e,t,r,n,i,u){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ge(e,t,r,n,i){if(!i){Ke(e,t,r,4)}oe(e,t,r,n,23,4);return r+4}pe.prototype.writeFloatLE=function e(t,r,n){return Ge(this,t,r,true,n)};pe.prototype.writeFloatBE=function e(t,r,n){return Ge(this,t,r,false,n)};function He(e,t,r,n,i){if(!i){Ke(e,t,r,8)}oe(e,t,r,n,52,8);return r+8}pe.prototype.writeDoubleLE=function e(t,r,n){return He(this,t,r,true,n)};pe.prototype.writeDoubleBE=function e(t,r,n){return He(this,t,r,false,n)};pe.prototype.copy=function e(t,r,n,i){if(!n)n=0;if(!i&&i!==0)i=this.length;if(r>=t.length)r=t.length;if(!r)r=0;if(i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");if(i>this.length)i=this.length;if(t.length-r=0;--a){t[a+r]=this[a+n]}}else if(u<1e3||!pe.TYPED_ARRAY_SUPPORT){for(a=0;a>>0;n=n===undefined?this.length:n>>>0;if(!t)t=0;var a;if(typeof t==="number"){for(a=r;a55295&&r<57344){if(!i){if(r>56319){if((t-=3)>-1)u.push(239,191,189);continue}else if(a+1===n){if((t-=3)>-1)u.push(239,191,189);continue}i=r;continue}if(r<56320){if((t-=3)>-1)u.push(239,191,189);i=r;continue}r=(i-55296<<10|r-56320)+65536}else if(i){if((t-=3)>-1)u.push(239,191,189)}i=null;if(r<128){if((t-=1)<0)break;u.push(r)}else if(r<2048){if((t-=2)<0)break;u.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;u.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;u.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else{throw new Error("Invalid code point")}}return u}function tt(e){var t=[];for(var r=0;r>8;i=r%256;u.push(i);u.push(n)}return u}function nt(e){return re(Qe(e))}function it(e,t,r,n){for(var i=0;i=t.length||i>=e.length)break;t[i+r]=e[i]}return i}function ut(e){return e!==e}function at(e){return e!=null&&(!!e._isBuffer||ot(e)||st(e))}function ot(e){return!!e.constructor&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)}function st(e){return typeof e.readFloatLE==="function"&&typeof e.slice==="function"&&ot(e.slice(0,0))}let ct;try{ct=new TextDecoder}catch(e){}let ft;let lt;let v=0;const ht=105;const pt=57342;const _t=57343;const dt=57337;const vt=6;const yt={};let mt={};let gt;let bt;let wt=0;let Dt=0;let Et;let At;let xt=[];let Ft=[];let kt;let Ct;let Ot;let St={useRecords:false,mapsAsObjects:true};let Bt=false;let jt=2;try{new Function("")}catch(e){jt=Infinity}class It{constructor(r){if(r){if((r.keyMap||r._keyMap)&&!r.useRecords){r.useRecords=false;r.mapsAsObjects=true}if(r.useRecords===false&&r.mapsAsObjects===undefined)r.mapsAsObjects=true;if(r.getStructures)r.getShared=r.getStructures;if(r.getShared&&!r.structures)(r.structures=[]).uninitialized=true;if(r.keyMap){this.mapKey=new Map;for(let[e,t]of Object.entries(r.keyMap))this.mapKey.set(t,e)}}Object.assign(this,r)}decodeKey(e){return this.keyMap?this.mapKey.get(e)||e:e}encodeKey(e){return this.keyMap&&this.keyMap.hasOwnProperty(e)?this.keyMap[e]:e}encodeKeys(r){if(!this._keyMap)return r;let n=new Map;for(let[e,t]of Object.entries(r))n.set(this._keyMap.hasOwnProperty(e)?this._keyMap[e]:e,t);return n}decodeKeys(e){if(!this._keyMap||e.constructor.name!="Map")return e;if(!this._mapKey){this._mapKey=new Map;for(let[e,t]of Object.entries(this._keyMap))this._mapKey.set(t,e)}let r={};e.forEach((e,t)=>r[Lt(this._mapKey.has(t)?this._mapKey.get(t):t)]=e);return r}mapDecode(e,t){let r=this.decode(e);if(this._keyMap){switch(r.constructor.name){case"Array":return r.map(e=>this.decodeKeys(e))}}return r}decode(t,e){if(ft){return sr(()=>{cr();return this?this.decode(t,e):It.prototype.decode.call(St,t,e)})}lt=e>-1?e:t.length;v=0;Dt=0;bt=null;Et=null;ft=t;try{Ct=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(e){ft=null;if(t instanceof Uint8Array)throw e;throw new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof It){mt=this;kt=this.sharedValues&&(this.pack?new Array(this.maxPrivatePackedValues||16).concat(this.sharedValues):this.sharedValues);if(this.structures){gt=this.structures;return Pt()}else if(!gt||gt.length>0){gt=[]}}else{mt=St;if(!gt||gt.length>0)gt=[];kt=null}return Pt()}decodeMultiple(r,n){let i,u=0;try{let e=r.length;Bt=true;let t=this?this.decode(r,e):hr.decode(r,e);if(n){if(n(t)===false){return}while(v=Et.postBundlePosition){let e=new Error("Unexpected bundle position");e.incomplete=true;throw e}v=Et.postBundlePosition;Et=null}if(v==lt){gt=null;ft=null;if(At)At=null}else if(v>lt){let e=new Error("Unexpected end of CBOR data");e.incomplete=true;throw e}else if(!Bt){throw new Error("Data read, but end of buffer not reached")}return e}catch(e){cr();if(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")){e.incomplete=true}throw e}}function Nt(){let n=ft[v++];let i=n>>5;n=n&31;if(n>23){switch(n){case 24:n=ft[v++];break;case 25:if(i==7){return Kt()}n=Ct.getUint16(v);v+=2;break;case 26:if(i==7){let t=Ct.getFloat32(v);if(mt.useFloat32>2){let e=lr[(ft[v]&127)<<1|ft[v+1]>>7];v+=4;return(e*t+(t>0?.5:-.5)>>0)/e}v+=4;return t}n=Ct.getUint32(v);v+=4;break;case 27:if(i==7){let e=Ct.getFloat64(v);v+=8;return e}if(i>1){if(Ct.getUint32(v)>0)throw new Error("JavaScript does not support arrays, maps, or strings with length over 4294967295");n=Ct.getUint32(v+4)}else if(mt.int64AsNumber){n=Ct.getUint32(v)*4294967296;n+=Ct.getUint32(v+4)}else n=Ct.getBigUint64(v);v+=8;break;case 31:switch(i){case 2:case 3:throw new Error("Indefinite length not supported for byte or text strings");case 4:let e=[];let t,r=0;while((t=Nt())!=yt){e[r++]=t}return i==4?e:i==3?e.join(""):pe.concat(e);case 5:let n;if(mt.mapsAsObjects){let e={};if(mt.keyMap)while((n=Nt())!=yt)e[Lt(mt.decodeKey(n))]=Nt();else while((n=Nt())!=yt)e[Lt(n)]=Nt();return e}else{if(Ot){mt.mapsAsObjects=true;Ot=false}let e=new Map;if(mt.keyMap)while((n=Nt())!=yt)e.set(mt.decodeKey(n),Nt());else while((n=Nt())!=yt)e.set(n,Nt());return e}case 7:return yt;default:throw new Error("Invalid major type for indefinite length "+i)}default:throw new Error("Unknown token "+n)}}switch(i){case 0:return n;case 1:return~n;case 2:return zt(n);case 3:if(Dt>=v){return bt.slice(v-wt,(v+=n)-wt)}if(Dt==0&<<140&&n<32){let e=n<16?Vt(n):Yt(n);if(e!=null)return e}return Ut(n);case 4:let t=new Array(n);for(let e=0;e=dt){let e=gt[n&8191];if(e){if(!e.read)e.read=Tt(e);return e.read()}if(n<65536){if(n==_t){let e=ar();let t=Nt();let r=Nt();Ht(t,r);let n={};if(mt.keyMap)for(let t=2;t23){switch(t){case 24:t=ft[v++];break;case 25:t=Ct.getUint16(v);v+=2;break;case 26:t=Ct.getUint32(v);v+=4;break;default:throw new Error("Expected array header, but got "+ft[v-1])}}let r=this.compiledReader;while(r){if(r.propertyCount===t)return r(Nt);r=r.next}if(this.slowReads++>=jt){let e=this.length==t?this:this.slice(0,t);r=mt.keyMap?new Function("r","return {"+e.map(e=>mt.decodeKey(e)).map(e=>Rt.test(e)?Lt(e)+":r()":"["+JSON.stringify(e)+"]:r()").join(",")+"}"):new Function("r","return {"+e.map(e=>Rt.test(e)?Lt(e)+":r()":"["+JSON.stringify(e)+"]:r()").join(",")+"}");if(this.compiledReader)r.next=this.compiledReader;r.propertyCount=t;this.compiledReader=r;return r(Nt)}let n={};if(mt.keyMap)for(let e=0;e64&&ct)return ct.decode(ft.subarray(v,v+=e));const r=v+e;const n=[];t="";while(v65535){e-=65536;n.push(e>>>10&1023|55296);e=56320|e&1023}n.push(e)}else{n.push(i)}if(n.length>=4096){t+=qt.apply(String,n);n.length=0}}if(n.length>0){t+=qt.apply(String,n)}return t}let qt=String.fromCharCode;function Yt(t){let r=v;let n=new Array(t);for(let e=0;e0){v=r;return}n[e]=i}return qt.apply(String,n)}function Vt(d){if(d<4){if(d<2){if(d===0)return"";else{let e=ft[v++];if((e&128)>1){v-=1;return}return qt(e)}}else{let e=ft[v++];let t=ft[v++];if((e&128)>0||(t&128)>0){v-=2;return}if(d<3)return qt(e,t);let r=ft[v++];if((r&128)>0){v-=3;return}return qt(e,t,r)}}else{let l=ft[v++];let h=ft[v++];let p=ft[v++];let _=ft[v++];if((l&128)>0||(h&128)>0||(p&128)>0||(_&128)>0){v-=4;return}if(d<6){if(d===4)return qt(l,h,p,_);else{let e=ft[v++];if((e&128)>0){v-=5;return}return qt(l,h,p,_,e)}}else if(d<8){let e=ft[v++];let t=ft[v++];if((e&128)>0||(t&128)>0){v-=6;return}if(d<7)return qt(l,h,p,_,e,t);let r=ft[v++];if((r&128)>0){v-=7;return}return qt(l,h,p,_,e,t,r)}else{let o=ft[v++];let s=ft[v++];let c=ft[v++];let f=ft[v++];if((o&128)>0||(s&128)>0||(c&128)>0||(f&128)>0){v-=8;return}if(d<10){if(d===8)return qt(l,h,p,_,o,s,c,f);else{let e=ft[v++];if((e&128)>0){v-=9;return}return qt(l,h,p,_,o,s,c,f,e)}}else if(d<12){let e=ft[v++];let t=ft[v++];if((e&128)>0||(t&128)>0){v-=10;return}if(d<11)return qt(l,h,p,_,o,s,c,f,e,t);let r=ft[v++];if((r&128)>0){v-=11;return}return qt(l,h,p,_,o,s,c,f,e,t,r)}else{let n=ft[v++];let i=ft[v++];let u=ft[v++];let a=ft[v++];if((n&128)>0||(i&128)>0||(u&128)>0||(a&128)>0){v-=12;return}if(d<14){if(d===12)return qt(l,h,p,_,o,s,c,f,n,i,u,a);else{let e=ft[v++];if((e&128)>0){v-=13;return}return qt(l,h,p,_,o,s,c,f,n,i,u,a,e)}}else{let e=ft[v++];let t=ft[v++];if((e&128)>0||(t&128)>0){v-=14;return}if(d<15)return qt(l,h,p,_,o,s,c,f,n,i,u,a,e,t);let r=ft[v++];if((r&128)>0){v-=15;return}return qt(l,h,p,_,o,s,c,f,n,i,u,a,e,t,r)}}}}}function zt(e){return mt.copyBuffers?Uint8Array.prototype.slice.call(ft,v,v+=e):ft.subarray(v,v+=e)}let $t=new Float32Array(1);let Jt=new Uint8Array($t.buffer,0,4);function Kt(){let t=ft[v++];let r=ft[v++];let e=(t&127)>>2;if(e===31){if(r||t&3)return NaN;return t&128?-Infinity:Infinity}if(e===0){let e=((t&3)<<8|r)/(1<<24);return t&128?-e:e}Jt[3]=t&128|(e>>1)+56;Jt[2]=(t&7)<<5|r>>3;Jt[1]=r<<5;Jt[0]=0;return $t[0]}new Array(4096);class Gt{constructor(e,t){this.value=e;this.tag=t}}xt[0]=e=>{return new Date(e)};xt[1]=e=>{return new Date(Math.round(e*1e3))};xt[2]=r=>{let n=BigInt(0);for(let e=0,t=r.byteLength;e{return BigInt(-1)-xt[2](e)};xt[4]=e=>{return+(e[1]+"e"+e[0])};xt[5]=e=>{return e[1]*Math.exp(e[0]*Math.log(2))};const Ht=(e,t)=>{e=e-57344;let r=gt[e];if(r&&r.isShared){(gt.restoreStructures||(gt.restoreStructures=[]))[e]=r}gt[e]=t;t.read=Tt(t)};xt[ht]=r=>{let e=r.length;let n=r[1];Ht(r[0],n);let i={};for(let t=2;t{if(Et)return Et[0].slice(Et.position0,Et.position0+=e);return new Gt(e,14)};xt[15]=e=>{if(Et)return Et[1].slice(Et.position1,Et.position1+=e);return new Gt(e,15)};let Wt={Error:Error,RegExp:RegExp};xt[27]=e=>{return(Wt[e[0]]||Error)(e[1],e[2])};const Qt=e=>{if(ft[v++]!=132)throw new Error("Packed values structure must be followed by a 4 element array");let t=e();kt=kt?t.concat(kt.slice(t.length)):t;kt.prefixes=e();kt.suffixes=e();return e()};Qt.handlesRead=true;xt[51]=Qt;xt[vt]=e=>{if(!kt){if(mt.getShared)or();else return new Gt(e,vt)}if(typeof e=="number")return kt[16+(e>=0?2*e:-2*e-1)];throw new Error("No support for non-integer packed references yet")};xt[28]=e=>{if(!At){At=new Map;At.id=0}let t=At.id++;let r=ft[v];let n;if(r>>5==4)n=[];else n={};let i={target:n};At.set(t,i);let u=e();if(i.used)return Object.assign(n,u);i.target=u;return u};xt[28].handlesRead=true;xt[29]=e=>{let t=At.get(e);t.used=true;return t.target};xt[258]=e=>new Set(e);(xt[259]=e=>{if(mt.mapsAsObjects){mt.mapsAsObjects=false;Ot=true}return e()}).handlesRead=true;function Zt(e,t){if(typeof e==="string")return e+t;if(e instanceof Array)return e.concat(t);return Object.assign({},e,t)}function Xt(){if(!kt){if(mt.getShared)or();else throw new Error("No packed values available")}return kt}const er=1399353956;Ft.push((e,t)=>{if(e>=225&&e<=255)return Zt(Xt().prefixes[e-224],t);if(e>=28704&&e<=32767)return Zt(Xt().prefixes[e-28672],t);if(e>=1879052288&&e<=2147483647)return Zt(Xt().prefixes[e-1879048192],t);if(e>=216&&e<=223)return Zt(t,Xt().suffixes[e-216]);if(e>=27647&&e<=28671)return Zt(t,Xt().suffixes[e-27639]);if(e>=1811940352&&e<=1879048191)return Zt(t,Xt().suffixes[e-1811939328]);if(e==er){return{packedValues:kt,structures:gt.slice(0),version:t}}if(e==55799)return t});const tr=new Uint8Array(new Uint16Array([1]).buffer)[0]==1;const rr=[Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array=="undefined"?{name:"BigUint64Array"}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array=="undefined"?{name:"BigInt64Array"}:BigInt64Array,Float32Array,Float64Array];const nr=[64,68,69,70,71,72,77,78,79,85,86];for(let e=0;e{if(!o)throw new Error("Could not find typed array for code "+s);return new o(Uint8Array.prototype.slice.call(e,0).buffer)}:e=>{if(!o)throw new Error("Could not find typed array for code "+s);let t=new DataView(e.buffer,e.byteOffset,e.byteLength);let r=e.length>>u;let n=new o(r);let i=t[c];for(let e=0;e23){switch(e){case 24:e=ft[v++];break;case 25:e=Ct.getUint16(v);v+=2;break;case 26:e=Ct.getUint32(v);v+=4;break}}return e}function or(){if(mt.getShared){let e=sr(()=>{ft=null;return mt.getShared()})||{};let t=e.structures||[];mt.sharedVersion=e.version;kt=mt.sharedValues=e.packedValues;if(gt===true)mt.structures=gt=t;else gt.splice.apply(gt,[0,t.length].concat(t))}}function sr(e){let t=lt;let r=v;let n=wt;let i=Dt;let u=bt;let a=At;let o=Et;let s=new Uint8Array(ft.slice(0,lt));let c=gt;let f=mt;let l=Bt;let h=e();lt=t;v=r;wt=n;Dt=i;bt=u;At=a;Et=o;ft=s;Bt=l;gt=c;mt=f;Ct=new DataView(ft.buffer,ft.byteOffset,ft.byteLength);return h}function cr(){ft=null;At=null;gt=null}function fr(e){xt[e.tag]=e.decode}const lr=new Array(147);for(let e=0;e<256;e++){lr[e]=+("1e"+Math.floor(45.15-e*.30103))}let hr=new It({useRecords:false});hr.decode;hr.decodeMultiple;let pr;try{pr=new TextEncoder}catch(e){}let _r,dr;const vr=typeof globalThis==="object"&&globalThis.Buffer;const yr=typeof vr!=="undefined";const mr=yr?vr.allocUnsafeSlow:Uint8Array;const gr=yr?vr:Uint8Array;const br=256;const wr=yr?4294967296:2144337920;let Dr;let O;let Er;let S=0;let Ar;let xr=null;const Fr=61440;const kr=/[\u0080-\uFFFF]/;const Cr=Symbol("record-id");class Or extends It{constructor(r){super(r);this.offset=0;let s;let a;let _;let f;let n;r=r||{};let c=gr.prototype.utf8Write?function(e,t,r){return O.utf8Write(e,t,r)}:pr&&pr.encodeInto?function(e,t){return pr.encodeInto(e,O.subarray(t)).written}:false;let u=this;let e=r.structures||r.saveStructures;let l=r.maxSharedStructures;if(l==null)l=e?128:0;if(l>8190)throw new Error("Maximum maxSharedStructure is 8190");let o=r.sequential;if(o){l=0}if(!this.structures)this.structures=[];if(this.saveStructures)this.saveShared=this.saveStructures;let d,v,y=r.sharedValues;let i;if(y){i=Object.create(null);for(let e=0,t=y.length;ethis.encodeKeys(e));break}}return this.encode(e,t)};this.encode=function(t,e){if(!O){O=new mr(8192);Er=new DataView(O.buffer,0,8192);S=0}Ar=O.length-10;if(Ar-S<2048){O=new mr(O.length);Er=new DataView(O.buffer,0,O.length);Ar=O.length-10;S=0}else if(e===Vr)S=S+7&2147483640;s=S;if(u.useSelfDescribedHeader){Er.setUint32(S,3654940416);S+=3}n=u.structuredClone?new Map:null;if(u.bundleStrings&&typeof t!=="string"){xr=[];xr.size=Infinity}else xr=null;a=u.structures;if(a){if(a.uninitialized){let e=u.getShared()||{};u.structures=a=e.structures||[];u.sharedVersion=e.version;let r=u.sharedValues=e.packedValues;if(r){i={};for(let e=0,t=r.length;el&&!o)e=l;if(!a.transitions){a.transitions=Object.create(null);for(let u=0;u0){O[S++]=216;O[S++]=51;jr(4);let r=e.values;p(r);jr(0);jr(0);v=Object.create(i||null);for(let e=0,t=r.length;eAr)w(S);u.offset=S;let e=Ur(O.subarray(s,S),n.idsToInsert);n=null;return e}if(e&Vr){O.start=s;O.end=S;return O}return O.subarray(s,S)}finally{if(a){if(g<10)g++;if(a.length>l)a.length=l;if(m>1e4){a.transitions=null;g=0;m=0;if(h.length>0)h=[]}else if(h.length>0&&!o){for(let e=0,t=h.length;el){u.structures=u.structures.slice(0,l)}let e=O.subarray(s,S);if(u.updateSharedData()===false)return u.encode(t);return e}if(e&zr)S=s}};this.findCommonStringsToPack=()=>{d=new Map;if(!i)i=Object.create(null);return e=>{let r=e&&e.threshold||4;let n=this.pack?e.maxPrivatePackedValues||16:0;if(!y)y=this.sharedValues=[];for(let[e,t]of d){if(t.count>r){i[e]=n++;y.push(e);_=true}}while(this.saveShared&&this.updateSharedData()===false){}d=null}};const p=a=>{if(S>Ar)O=w(S);var e=typeof a;var o;if(e==="string"){if(v){let e=v[a];if(e>=0){if(e<16)O[S++]=e+224;else{O[S++]=198;if(e&1)p(15-e>>1);else p(e-16>>1)}return}else if(d&&!r.pack){let e=d.get(a);if(e)e.count++;else d.set(a,{count:1})}}let i=a.length;if(xr&&i>=4&&i<1024){if((xr.size+=i)>Fr){let e;let t=(xr[0]?xr[0].length*3+xr[1].length:0)+10;if(S+t>Ar)O=w(S+t);O[S++]=217;O[S++]=223;O[S++]=249;O[S++]=xr.position?132:130;O[S++]=26;e=S-s;S+=4;if(xr.position){Mr(s,p)}xr=["",""];xr.size=0;xr.position=e}let e=kr.test(a);xr[e?0:1]+=a;O[S++]=e?206:207;p(i);return}let u;if(i<32){u=1}else if(i<256){u=2}else if(i<65536){u=3}else{u=5}let e=i*3;if(S+e>Ar)O=w(S+e);if(i<64||!c){let e,t,r,n=S+u;for(e=0;e>6|192;O[n++]=t&63|128}else if((t&64512)===55296&&((r=a.charCodeAt(e+1))&64512)===56320){t=65536+((t&1023)<<10)+(r&1023);e++;O[n++]=t>>18|240;O[n++]=t>>12&63|128;O[n++]=t>>6&63|128;O[n++]=t&63|128}else{O[n++]=t>>12|224;O[n++]=t>>6&63|128;O[n++]=t&63|128}}o=n-S-u}else{o=c(a,S+u,e)}if(o<24){O[S++]=96|o}else if(o<256){if(u<2){O.copyWithin(S+2,S+1,S+1+o)}O[S++]=120;O[S++]=o}else if(o<65536){if(u<3){O.copyWithin(S+3,S+2,S+2+o)}O[S++]=121;O[S++]=o>>8;O[S++]=o&255}else{if(u<5){O.copyWithin(S+5,S+3,S+3+o)}O[S++]=122;Er.setUint32(S,o);S+=4}S+=o}else if(e==="number"){if(!this.alwaysUseFloat&&a>>>0===a){if(a<24){O[S++]=a}else if(a<256){O[S++]=24;O[S++]=a}else if(a<65536){O[S++]=25;O[S++]=a>>8;O[S++]=a&255}else{O[S++]=26;Er.setUint32(S,a);S+=4}}else if(!this.alwaysUseFloat&&a>>0===a){if(a>=-24){O[S++]=31-a}else if(a>=-256){O[S++]=56;O[S++]=~a}else if(a>=-65536){O[S++]=57;Er.setUint16(S,~a);S+=2}else{O[S++]=58;Er.setUint32(S,~a);S+=4}}else{let t;if((t=this.useFloat32)>0&&a<4294967296&&a>=-2147483648){O[S++]=250;Er.setFloat32(S,a);let e;if(t<4||(e=a*lr[(O[S]&127)<<1|O[S+1]>>7])>>0===e){S+=4;return}else S--}O[S++]=251;Er.setFloat64(S,a);S+=8}}else if(e==="object"){if(!a)O[S++]=246;else{if(n){let t=n.get(a);if(t){O[S++]=216;O[S++]=29;O[S++]=25;if(!t.references){let e=n.idsToInsert||(n.idsToInsert=[]);t.references=[];e.push(t)}t.references.push(S-s);S+=2;return}else n.set(a,{offset:S-s})}let e=a.constructor;if(e===Object){b(a,true)}else if(e===Array){o=a.length;if(o<24){O[S++]=128|o}else{jr(o)}for(let e=0;e>8;O[S++]=o&255}else{O[S++]=186;Er.setUint32(S,o);S+=4}if(u.keyMap){for(let[e,t]of a){p(u.encodeKey(e));p(t)}}else{for(let[e,t]of a){p(e);p(t)}}}else{for(let r=0,e=_r.length;r>8;O[S++]=t&255}else if(t>-1){O[S++]=218;Er.setUint32(S,t);S+=4}e.encode.call(this,a,p,w);return}}if(a[Symbol.iterator]){if(Dr){let e=new Error("Iterable should be serialized as iterator");e.iteratorNotHandled=true;throw e}O[S++]=159;for(let e of a){p(e)}O[S++]=255;return}if(a[Symbol.asyncIterator]||Pr(a)){let e=new Error("Iterable/blob should be serialized as iterator");e.iteratorNotHandled=true;throw e}if(this.useToJSON&&a.toJSON){const t=a.toJSON();if(t!==a)return p(t)}b(a,!a.hasOwnProperty)}}}else if(e==="boolean"){O[S++]=a?245:244}else if(e==="bigint"){if(a=0){O[S++]=27;Er.setBigUint64(S,a)}else if(a>-(BigInt(1)<{let t=Object.keys(e);let r=Object.values(e);let n=t.length;if(n<24){O[S++]=160|n}else if(n<256){O[S++]=184;O[S++]=n}else if(n<65536){O[S++]=185;O[S++]=n>>8;O[S++]=n&255}else{O[S++]=186;Er.setUint32(S,n);S+=4}if(u.keyMap){for(let e=0;e{O[S++]=185;let e=S-s;S+=2;let n=0;if(u.keyMap){for(let e in t)if(r||t.hasOwnProperty(e)){p(u.encodeKey(e));p(t[e]);n++}}else{for(let e in t)if(r||t.hasOwnProperty(e)){p(e);p(t[e]);n++}}O[e+++s]=n>>8;O[e+s]=n&255}:(t,r)=>{let n,i=f.transitions||(f.transitions=Object.create(null));let u=0;let a=0;let o;let s;if(this.keyMap){s=Object.keys(t).map(e=>this.encodeKey(e));a=s.length;for(let t=0;t>8|224;O[S++]=c&255}else{if(!s)s=i.__keys__||(i.__keys__=Object.keys(t));if(o===undefined){c=f.nextId++;if(!c){c=0;f.nextId=1}if(c>=br){f.nextId=(c=l)+1}}else{c=o}f[c]=s;if(c>8|224;O[S++]=c&255;i=f.transitions;for(let e=0;e=br-l)h.shift()[Cr]=undefined;h.push(i);jr(a+2);p(57344+c);p(s);if(r===null)return;for(let e in t)if(r||t.hasOwnProperty(e))p(t[e]);return}}if(a<24){O[S++]=128|a}else{jr(a)}if(r===null)return;for(let e in t)if(r||t.hasOwnProperty(e))p(t[e])};const w=e=>{let t;if(e>16777216){if(e-s>wr)throw new Error("Encoded buffer would be larger than maximum buffer size");t=Math.min(wr,Math.round(Math.max((e-s)*(e>67108864?1.25:2),4194304)/4096)*4096)}else t=(Math.max(e-s<<2,O.length-1)>>12)+1<<12;let r=new mr(t);Er=new DataView(r.buffer,0,t);if(O.copy)O.copy(r,0,s,e);else r.set(O.slice(s,e));S-=s;s=0;Ar=r.length-10;return O=r};let D=100;let E=1e3;this.encodeAsIterable=function(e,t){return k(e,t,A)};this.encodeAsAsyncIterable=function(e,t){return k(e,t,C)};function*A(n,i,e){let t=n.constructor;if(t===Object){let r=u.useRecords!==false;if(r)b(n,null);else Sr(Object.keys(n).length,160);for(let t in n){let e=n[t];if(!r)p(t);if(e&&typeof e==="object"){if(i[t])yield*A(e,i[t]);else yield*x(e,i,t)}else p(e)}}else if(t===Array){let e=n.length;jr(e);for(let t=0;tD)){if(i.element)yield*A(e,i.element);else yield*x(e,i,"element")}else p(e)}}else if(n[Symbol.iterator]){O[S++]=159;for(let e of n){if(e&&(typeof e==="object"||S-s>D)){if(i.element)yield*A(e,i.element);else yield*x(e,i,"element")}else p(e)}O[S++]=255}else if(Pr(n)){Sr(n.size,64);yield O.subarray(s,S);yield n;F()}else if(n[Symbol.asyncIterator]){O[S++]=159;yield O.subarray(s,S);yield n;F();O[S++]=255}else{p(n)}if(e&&S>s)yield O.subarray(s,S);else if(S-s>D){yield O.subarray(s,S);F()}}function*x(t,r,n){let i=S-s;try{p(t);if(S-s>D){yield O.subarray(s,S);F()}}catch(e){if(e.iteratorNotHandled){r[n]={};S=s+i;yield*A.call(this,t,r[n])}else throw e}}function F(){D=E;u.encode(null,$r)}function k(e,t,r){if(t&&t.chunkThreshold)D=E=t.chunkThreshold;else D=100;if(e&&typeof e==="object"){u.encode(null,$r);return r(e,u.iterateProperties||(u.iterateProperties={}),true)}return[u.encode(e)]}async function*C(e,t){for(let r of A(e,t,true)){let e=r.constructor;if(e===gr||e===Uint8Array)yield r;else if(Pr(r)){let e=r.stream().getReader();let t;while(!(t=await e.read()).done){yield t.value}}else if(r[Symbol.asyncIterator]){for await(let e of r){F();if(e)yield*C(e,t.async||(t.async={}));else yield u.encode(e)}}else{yield r}}}}useBuffer(e){O=e;Er=new DataView(O.buffer,O.byteOffset,O.byteLength);S=0}clearSharedData(){if(this.structures)this.structures=[];if(this.sharedValues)this.sharedValues=undefined}updateSharedData(){let t=this.sharedVersion||0;this.sharedVersion=t+1;let e=this.structures.slice(0);let r=new Br(e,this.sharedValues,this.sharedVersion);let n=this.saveShared(r,e=>(e&&e.version||0)==t);if(n===false){r=this.getShared()||{};this.structures=r.structures||[];this.sharedValues=r.packedValues;this.sharedVersion=r.version;this.structures.nextId=this.structures.length}else{e.forEach((e,t)=>this.structures[t]=e)}return n}}function Sr(e,t){if(e<24)O[S++]=t|e;else if(e<256){O[S++]=t|24;O[S++]=e}else if(e<65536){O[S++]=t|25;O[S++]=e>>8;O[S++]=e&255}else{O[S++]=t|26;Er.setUint32(S,e);S+=4}}class Br{constructor(e,t,r){this.structures=e;this.packedValues=t;this.version=r}}function jr(e){if(e<24)O[S++]=128|e;else if(e<256){O[S++]=152;O[S++]=e}else if(e<65536){O[S++]=153;O[S++]=e>>8;O[S++]=e&255}else{O[S++]=154;Er.setUint32(S,e);S+=4}}const Ir=typeof Blob==="undefined"?function(){}:Blob;function Pr(e){if(e instanceof Ir)return true;let t=e[Symbol.toStringTag];return t==="Blob"||t==="File"}function Nr(r,n){switch(typeof r){case"string":if(r.length>3){if(n.objectMap[r]>-1||n.values.length>=n.maxValues)return;let e=n.get(r);if(e){if(++e.count==2){n.values.push(r)}}else{n.set(r,{count:1});if(n.samplingPackedValues){let e=n.samplingPackedValues.get(r);if(e)e.count++;else n.samplingPackedValues.set(r,{count:1})}}}break;case"object":if(r){if(r instanceof Array){for(let e=0,t=r.length;e=0&&r<4294967296){O[S++]=26;Er.setUint32(S,r);S+=4}else{O[S++]=251;Er.setFloat64(S,r);S+=8}}},{tag:258,encode(e,t){let r=Array.from(e);t(r)}},{tag:27,encode(e,t){t([e.name,e.message])}},{tag:27,encode(e,t){t(["RegExp",e.source,e.flags])}},{getTag(e){return e.tag},encode(e,t){t(e.value)}},{encode(e,t,r){Lr(e,r)}},{getTag(e){if(e.constructor===Uint8Array){if(this.tagUint8Array||yr&&this.tagUint8Array!==false)return 64}},encode(e,t,r){Lr(e,r)}},Tr(68,1),Tr(69,2),Tr(70,4),Tr(71,8),Tr(72,1),Tr(77,2),Tr(78,4),Tr(79,8),Tr(85,4),Tr(86,8),{encode(t,n){let e=t.packedValues||[];let r=t.structures||[];if(e.values.length>0){O[S++]=216;O[S++]=51;jr(4);let r=e.values;n(r);jr(0);jr(0);packedObjectMap=Object.create(sharedPackedObjectMap||null);for(let e=0,t=r.length;e1)e-=4;return{tag:e,encode:function e(t,r){let n=t.byteLength;let i=t.byteOffset||0;let u=t.buffer||t;r(yr?vr.from(u,i,n):new Uint8Array(u,i,n))}}}function Lr(e,t){let r=e.byteLength;if(r<24){O[S++]=64+r}else if(r<256){O[S++]=88;O[S++]=r}else if(r<65536){O[S++]=89;O[S++]=r>>8;O[S++]=r&255}else{O[S++]=90;Er.setUint32(S,r);S+=4}if(S+r>=O.length){t(S+r)}O.set(e.buffer?e:new Uint8Array(e),S);S+=r}function Ur(n,e){let r;let i=e.length*2;let u=n.length-i;e.sort((e,t)=>e.offset>t.offset?1:-1);for(let r=0;r>8;n[e]=r&255}}while(r=e.pop()){let e=r.offset;n.copyWithin(e+i,e,u);i-=2;let t=e+i;n[t++]=216;n[t++]=28;u=e}return n}function Mr(e,t){Er.setUint32(xr.position+e,S-xr.position-e+1);let r=xr;xr=null;t(r[0]);t(r[1])}function qr(e){if(e.Class){if(!e.encode)throw new Error("Extension has no encode function");dr.unshift(e.Class);_r.unshift(e)}fr(e)}let Yr=new Or({useRecords:false});Yr.encode;Yr.encodeAsIterable;Yr.encodeAsAsyncIterable;const Vr=512;const zr=1024;const $r=2048;var Jr={}; + */var le=50;_e.TYPED_ARRAY_SUPPORT=Q.TYPED_ARRAY_SUPPORT!==undefined?Q.TYPED_ARRAY_SUPPORT:true;he();function he(){return _e.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function pe(e,t){if(he()=he()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+he().toString(16)+" bytes")}return e|0}_e.isBuffer=ot;function Ae(e){return!!(e!=null&&e._isBuffer)}_e.compare=function e(t,r){if(!Ae(t)||!Ae(r)){throw new TypeError("Arguments must be Buffers")}if(t===r)return 0;var n=t.length;var i=r.length;for(var u=0,a=Math.min(n,i);u>>1;case"base64":return it(e).length;default:if(n)return tt(e).length;t=(""+t).toLowerCase();n=true}}}_e.byteLength=xe;function Fe(e,t,r){var n=false;if(t===undefined||t<0){t=0}if(t>this.length){return""}if(r===undefined||r>this.length){r=this.length}if(r<=0){return""}r>>>=0;t>>>=0;if(r<=t){return""}if(!e)e="utf8";while(true){switch(e){case"hex":return ze(this,t,r);case"utf8":case"utf-8":return Te(this,t,r);case"ascii":return Me(this,t,r);case"latin1":case"binary":return qe(this,t,r);case"base64":return Re(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ve(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();n=true}}}_e.prototype._isBuffer=true;function ke(e,t,r){var n=e[t];e[t]=e[r];e[r]=n}_e.prototype.swap16=function e(){var t=this.length;if(t%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var r=0;r0){t=this.toString("hex",0,r).match(/.{2}/g).join(" ");if(this.length>r)t+=" ... "}return""};_e.prototype.compare=function f(e,t,r,n,i){if(!Ae(e)){throw new TypeError("Argument must be a Buffer")}if(t===undefined){t=0}if(r===undefined){r=e?e.length:0}if(n===undefined){n=0}if(i===undefined){i=this.length}if(t<0||r>e.length||n<0||i>this.length){throw new RangeError("out of range index")}if(n>=i&&t>=r){return 0}if(n>=i){return-1}if(t>=r){return 1}t>>>=0;r>>>=0;n>>>=0;i>>>=0;if(this===e)return 0;var u=i-n;var a=r-t;var l=Math.min(u,a);var o=this.slice(n,i);var s=e.slice(t,r);for(var c=0;c2147483647){r=2147483647}else if(r<-2147483648){r=-2147483648}r=+r;if(isNaN(r)){r=i?0:e.length-1}if(r<0)r=e.length+r;if(r>=e.length){if(i)return-1;else r=e.length-1}else if(r<0){if(i)r=0;else return-1}if(typeof t==="string"){t=_e.from(t,n)}if(Ae(t)){if(t.length===0){return-1}return Oe(e,t,r,n,i)}else if(typeof t==="number"){t=t&255;if(_e.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf==="function"){if(i){return Uint8Array.prototype.indexOf.call(e,t,r)}else{return Uint8Array.prototype.lastIndexOf.call(e,t,r)}}return Oe(e,[t],r,n,i)}throw new TypeError("val must be string, number or Buffer")}function Oe(e,t,r,n,f){var i=1;var u=e.length;var a=t.length;if(n!==undefined){n=String(n).toLowerCase();if(n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le"){if(e.length<2||t.length<2){return-1}i=2;u/=2;a/=2;r/=2}}function o(e,t){if(i===1){return e[t]}else{return e.readUInt16BE(t*i)}}var s;if(f){var c=-1;for(s=r;su)r=u-a;for(s=r;s>=0;s--){var l=true;for(var h=0;hi){n=i}}var u=t.length;if(u%2!==0)throw new TypeError("Invalid hex string");if(n>u/2){n=u/2}for(var a=0;au)n=u;if(t.length>0&&(n<0||r<0)||r>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!i)i="utf8";var a=false;for(;;){switch(i){case"hex":return Se(this,t,r,n);case"utf8":case"utf-8":return Be(this,t,r,n);case"ascii":return je(this,t,r,n);case"latin1":case"binary":return Ie(this,t,r,n);case"base64":return Pe(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ne(this,t,r,n);default:if(a)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase();a=true}}};_e.prototype.toJSON=function e(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Re(e,t,r){if(t===0&&r===e.length){return ae(e)}else{return ae(e.slice(t,r))}}function Te(e,f,t){t=Math.min(e.length,t);var r=[];var n=f;while(n239?4:i>223?3:i>191?2:1;if(n+a<=t){var o,s,l,c;switch(a){case 1:if(i<128){u=i}break;case 2:o=e[n+1];if((o&192)===128){c=(i&31)<<6|o&63;if(c>127){u=c}}break;case 3:o=e[n+1];s=e[n+2];if((o&192)===128&&(s&192)===128){c=(i&15)<<12|(o&63)<<6|s&63;if(c>2047&&(c<55296||c>57343)){u=c}}break;case 4:o=e[n+1];s=e[n+2];l=e[n+3];if((o&192)===128&&(s&192)===128&&(l&192)===128){c=(i&15)<<18|(o&63)<<12|(s&63)<<6|l&63;if(c>65535&&c<1114112){u=c}}}}if(u===null){u=65533;a=1}else if(u>65535){u-=65536;r.push(u>>>10&1023|55296);u=56320|u&1023}r.push(u);n+=a}return Ue(r)}var Le=4096;function Ue(e){var t=e.length;if(t<=Le){return String.fromCharCode.apply(String,e)}var r="";var n=0;while(nn)r=n;var i="";for(var u=t;un){t=n}if(r<0){r+=n;if(r<0)r=0}else if(r>n){r=n}if(rr)throw new RangeError("Trying to access beyond buffer length")}_e.prototype.readUIntLE=function e(t,r,n){t=t|0;r=r|0;if(!n)Ye(t,r,this.length);var i=this[t];var u=1;var a=0;while(++a0&&(u*=256)){i+=this[t+--r]*u}return i};_e.prototype.readUInt8=function e(t,r){if(!r)Ye(t,1,this.length);return this[t]};_e.prototype.readUInt16LE=function e(t,r){if(!r)Ye(t,2,this.length);return this[t]|this[t+1]<<8};_e.prototype.readUInt16BE=function e(t,r){if(!r)Ye(t,2,this.length);return this[t]<<8|this[t+1]};_e.prototype.readUInt32LE=function e(t,r){if(!r)Ye(t,4,this.length);return(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};_e.prototype.readUInt32BE=function e(t,r){if(!r)Ye(t,4,this.length);return this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};_e.prototype.readIntLE=function e(t,r,n){t=t|0;r=r|0;if(!n)Ye(t,r,this.length);var i=this[t];var u=1;var a=0;while(++a=u)i-=Math.pow(2,8*r);return i};_e.prototype.readIntBE=function e(t,r,n){t=t|0;r=r|0;if(!n)Ye(t,r,this.length);var i=r;var u=1;var a=this[t+--i];while(i>0&&(u*=256)){a+=this[t+--i]*u}u*=128;if(a>=u)a-=Math.pow(2,8*r);return a};_e.prototype.readInt8=function e(t,r){if(!r)Ye(t,1,this.length);if(!(this[t]&128))return this[t];return(255-this[t]+1)*-1};_e.prototype.readInt16LE=function e(t,r){if(!r)Ye(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};_e.prototype.readInt16BE=function e(t,r){if(!r)Ye(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};_e.prototype.readInt32LE=function e(t,r){if(!r)Ye(t,4,this.length);return this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};_e.prototype.readInt32BE=function e(t,r){if(!r)Ye(t,4,this.length);return this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};_e.prototype.readFloatLE=function e(t,r){if(!r)Ye(t,4,this.length);return oe(this,t,true,23,4)};_e.prototype.readFloatBE=function e(t,r){if(!r)Ye(t,4,this.length);return oe(this,t,false,23,4)};_e.prototype.readDoubleLE=function e(t,r){if(!r)Ye(t,8,this.length);return oe(this,t,true,52,8)};_e.prototype.readDoubleBE=function e(t,r){if(!r)Ye(t,8,this.length);return oe(this,t,false,52,8)};function $e(e,t,r,n,i,u){if(!Ae(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}_e.prototype.writeUIntLE=function e(t,r,n,i){t=+t;r=r|0;n=n|0;if(!i){var u=Math.pow(2,8*n)-1;$e(this,t,r,n,u,0)}var a=1;var o=0;this[r]=t&255;while(++o=0&&(o*=256)){this[r+a]=t/o&255}return r+n};_e.prototype.writeUInt8=function e(t,r,n){t=+t;r=r|0;if(!n)$e(this,t,r,1,255,0);if(!_e.TYPED_ARRAY_SUPPORT)t=Math.floor(t);this[r]=t&255;return r+1};function Je(e,t,r,n){if(t<0)t=65535+t+1;for(var i=0,u=Math.min(e.length-r,2);i>>(n?i:1-i)*8}}_e.prototype.writeUInt16LE=function e(t,r,n){t=+t;r=r|0;if(!n)$e(this,t,r,2,65535,0);if(_e.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8}else{Je(this,t,r,true)}return r+2};_e.prototype.writeUInt16BE=function e(t,r,n){t=+t;r=r|0;if(!n)$e(this,t,r,2,65535,0);if(_e.TYPED_ARRAY_SUPPORT){this[r]=t>>>8;this[r+1]=t&255}else{Je(this,t,r,false)}return r+2};function Ke(e,t,r,n){if(t<0)t=4294967295+t+1;for(var i=0,u=Math.min(e.length-r,4);i>>(n?i:3-i)*8&255}}_e.prototype.writeUInt32LE=function e(t,r,n){t=+t;r=r|0;if(!n)$e(this,t,r,4,4294967295,0);if(_e.TYPED_ARRAY_SUPPORT){this[r+3]=t>>>24;this[r+2]=t>>>16;this[r+1]=t>>>8;this[r]=t&255}else{Ke(this,t,r,true)}return r+4};_e.prototype.writeUInt32BE=function e(t,r,n){t=+t;r=r|0;if(!n)$e(this,t,r,4,4294967295,0);if(_e.TYPED_ARRAY_SUPPORT){this[r]=t>>>24;this[r+1]=t>>>16;this[r+2]=t>>>8;this[r+3]=t&255}else{Ke(this,t,r,false)}return r+4};_e.prototype.writeIntLE=function e(t,r,n,i){t=+t;r=r|0;if(!i){var u=Math.pow(2,8*n-1);$e(this,t,r,n,u-1,-u)}var a=0;var o=1;var s=0;this[r]=t&255;while(++a>0)-s&255}return r+n};_e.prototype.writeIntBE=function e(t,r,n,i){t=+t;r=r|0;if(!i){var u=Math.pow(2,8*n-1);$e(this,t,r,n,u-1,-u)}var a=n-1;var o=1;var s=0;this[r+a]=t&255;while(--a>=0&&(o*=256)){if(t<0&&s===0&&this[r+a+1]!==0){s=1}this[r+a]=(t/o>>0)-s&255}return r+n};_e.prototype.writeInt8=function e(t,r,n){t=+t;r=r|0;if(!n)$e(this,t,r,1,127,-128);if(!_e.TYPED_ARRAY_SUPPORT)t=Math.floor(t);if(t<0)t=255+t+1;this[r]=t&255;return r+1};_e.prototype.writeInt16LE=function e(t,r,n){t=+t;r=r|0;if(!n)$e(this,t,r,2,32767,-32768);if(_e.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8}else{Je(this,t,r,true)}return r+2};_e.prototype.writeInt16BE=function e(t,r,n){t=+t;r=r|0;if(!n)$e(this,t,r,2,32767,-32768);if(_e.TYPED_ARRAY_SUPPORT){this[r]=t>>>8;this[r+1]=t&255}else{Je(this,t,r,false)}return r+2};_e.prototype.writeInt32LE=function e(t,r,n){t=+t;r=r|0;if(!n)$e(this,t,r,4,2147483647,-2147483648);if(_e.TYPED_ARRAY_SUPPORT){this[r]=t&255;this[r+1]=t>>>8;this[r+2]=t>>>16;this[r+3]=t>>>24}else{Ke(this,t,r,true)}return r+4};_e.prototype.writeInt32BE=function e(t,r,n){t=+t;r=r|0;if(!n)$e(this,t,r,4,2147483647,-2147483648);if(t<0)t=4294967295+t+1;if(_e.TYPED_ARRAY_SUPPORT){this[r]=t>>>24;this[r+1]=t>>>16;this[r+2]=t>>>8;this[r+3]=t&255}else{Ke(this,t,r,false)}return r+4};function Ge(e,t,r,n,i,u){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function He(e,t,r,n,i){if(!i){Ge(e,t,r,4)}se(e,t,r,n,23,4);return r+4}_e.prototype.writeFloatLE=function e(t,r,n){return He(this,t,r,true,n)};_e.prototype.writeFloatBE=function e(t,r,n){return He(this,t,r,false,n)};function We(e,t,r,n,i){if(!i){Ge(e,t,r,8)}se(e,t,r,n,52,8);return r+8}_e.prototype.writeDoubleLE=function e(t,r,n){return We(this,t,r,true,n)};_e.prototype.writeDoubleBE=function e(t,r,n){return We(this,t,r,false,n)};_e.prototype.copy=function e(t,r,n,i){if(!n)n=0;if(!i&&i!==0)i=this.length;if(r>=t.length)r=t.length;if(!r)r=0;if(i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");if(i>this.length)i=this.length;if(t.length-r=0;--a){t[a+r]=this[a+n]}}else if(u<1e3||!_e.TYPED_ARRAY_SUPPORT){for(a=0;a>>0;n=n===undefined?this.length:n>>>0;if(!t)t=0;var a;if(typeof t==="number"){for(a=r;a55295&&r<57344){if(!i){if(r>56319){if((t-=3)>-1)u.push(239,191,189);continue}else if(a+1===n){if((t-=3)>-1)u.push(239,191,189);continue}i=r;continue}if(r<56320){if((t-=3)>-1)u.push(239,191,189);i=r;continue}r=(i-55296<<10|r-56320)+65536}else if(i){if((t-=3)>-1)u.push(239,191,189)}i=null;if(r<128){if((t-=1)<0)break;u.push(r)}else if(r<2048){if((t-=2)<0)break;u.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;u.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;u.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else{throw new Error("Invalid code point")}}return u}function rt(e){var t=[];for(var r=0;r>8;i=r%256;u.push(i);u.push(n)}return u}function it(e){return ne(Ze(e))}function ut(e,t,r,n){for(var i=0;i=t.length||i>=e.length)break;t[i+r]=e[i]}return i}function at(e){return e!==e}function ot(e){return e!=null&&(!!e._isBuffer||st(e)||ct(e))}function st(e){return!!e.constructor&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)}function ct(e){return typeof e.readFloatLE==="function"&&typeof e.slice==="function"&&st(e.slice(0,0))}let ft;try{ft=new TextDecoder}catch(e){}let lt;let ht;let v=0;const pt=105;const _t=57342;const dt=57343;const vt=57337;const yt=6;const mt={};let gt={};let bt;let wt;let Dt=0;let Et=0;let At;let xt;let Ft=[];let kt=[];let Ct;let Ot;let St;let Bt={useRecords:false,mapsAsObjects:true};let jt=false;let It=2;try{new Function("")}catch(e){It=Infinity}class Pt{constructor(r){if(r){if((r.keyMap||r._keyMap)&&!r.useRecords){r.useRecords=false;r.mapsAsObjects=true}if(r.useRecords===false&&r.mapsAsObjects===undefined)r.mapsAsObjects=true;if(r.getStructures)r.getShared=r.getStructures;if(r.getShared&&!r.structures)(r.structures=[]).uninitialized=true;if(r.keyMap){this.mapKey=new Map;for(let[e,t]of Object.entries(r.keyMap))this.mapKey.set(t,e)}}Object.assign(this,r)}decodeKey(e){return this.keyMap?this.mapKey.get(e)||e:e}encodeKey(e){return this.keyMap&&this.keyMap.hasOwnProperty(e)?this.keyMap[e]:e}encodeKeys(r){if(!this._keyMap)return r;let n=new Map;for(let[e,t]of Object.entries(r))n.set(this._keyMap.hasOwnProperty(e)?this._keyMap[e]:e,t);return n}decodeKeys(e){if(!this._keyMap||e.constructor.name!="Map")return e;if(!this._mapKey){this._mapKey=new Map;for(let[e,t]of Object.entries(this._keyMap))this._mapKey.set(t,e)}let r={};e.forEach((e,t)=>r[Ut(this._mapKey.has(t)?this._mapKey.get(t):t)]=e);return r}mapDecode(e,t){let r=this.decode(e);if(this._keyMap){switch(r.constructor.name){case"Array":return r.map(e=>this.decodeKeys(e))}}return r}decode(t,e){if(lt){return cr(()=>{fr();return this?this.decode(t,e):Pt.prototype.decode.call(Bt,t,e)})}ht=e>-1?e:t.length;v=0;Et=0;wt=null;At=null;lt=t;try{Ot=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(e){lt=null;if(t instanceof Uint8Array)throw e;throw new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Pt){gt=this;Ct=this.sharedValues&&(this.pack?new Array(this.maxPrivatePackedValues||16).concat(this.sharedValues):this.sharedValues);if(this.structures){bt=this.structures;return Nt()}else if(!bt||bt.length>0){bt=[]}}else{gt=Bt;if(!bt||bt.length>0)bt=[];Ct=null}return Nt()}decodeMultiple(r,n){let i,u=0;try{let e=r.length;jt=true;let t=this?this.decode(r,e):pr.decode(r,e);if(n){if(n(t)===false){return}while(v=At.postBundlePosition){let e=new Error("Unexpected bundle position");e.incomplete=true;throw e}v=At.postBundlePosition;At=null}if(v==ht){bt=null;lt=null;if(xt)xt=null}else if(v>ht){let e=new Error("Unexpected end of CBOR data");e.incomplete=true;throw e}else if(!jt){throw new Error("Data read, but end of buffer not reached")}return e}catch(e){fr();if(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")){e.incomplete=true}throw e}}function Rt(){let n=lt[v++];let i=n>>5;n=n&31;if(n>23){switch(n){case 24:n=lt[v++];break;case 25:if(i==7){return Gt()}n=Ot.getUint16(v);v+=2;break;case 26:if(i==7){let t=Ot.getFloat32(v);if(gt.useFloat32>2){let e=hr[(lt[v]&127)<<1|lt[v+1]>>7];v+=4;return(e*t+(t>0?.5:-.5)>>0)/e}v+=4;return t}n=Ot.getUint32(v);v+=4;break;case 27:if(i==7){let e=Ot.getFloat64(v);v+=8;return e}if(i>1){if(Ot.getUint32(v)>0)throw new Error("JavaScript does not support arrays, maps, or strings with length over 4294967295");n=Ot.getUint32(v+4)}else if(gt.int64AsNumber){n=Ot.getUint32(v)*4294967296;n+=Ot.getUint32(v+4)}else n=Ot.getBigUint64(v);v+=8;break;case 31:switch(i){case 2:case 3:throw new Error("Indefinite length not supported for byte or text strings");case 4:let e=[];let t,r=0;while((t=Rt())!=mt){e[r++]=t}return i==4?e:i==3?e.join(""):_e.concat(e);case 5:let n;if(gt.mapsAsObjects){let e={};if(gt.keyMap)while((n=Rt())!=mt)e[Ut(gt.decodeKey(n))]=Rt();else while((n=Rt())!=mt)e[Ut(n)]=Rt();return e}else{if(St){gt.mapsAsObjects=true;St=false}let e=new Map;if(gt.keyMap)while((n=Rt())!=mt)e.set(gt.decodeKey(n),Rt());else while((n=Rt())!=mt)e.set(n,Rt());return e}case 7:return mt;default:throw new Error("Invalid major type for indefinite length "+i)}default:throw new Error("Unknown token "+n)}}switch(i){case 0:return n;case 1:return~n;case 2:return $t(n);case 3:if(Et>=v){return wt.slice(v-Dt,(v+=n)-Dt)}if(Et==0&&ht<140&&n<32){let e=n<16?Yt(n):Vt(n);if(e!=null)return e}return Mt(n);case 4:let t=new Array(n);for(let e=0;e=vt){let e=bt[n&8191];if(e){if(!e.read)e.read=Lt(e);return e.read()}if(n<65536){if(n==dt){let e=or();let t=Rt();let r=Rt();Wt(t,r);let n={};if(gt.keyMap)for(let t=2;t23){switch(t){case 24:t=lt[v++];break;case 25:t=Ot.getUint16(v);v+=2;break;case 26:t=Ot.getUint32(v);v+=4;break;default:throw new Error("Expected array header, but got "+lt[v-1])}}let r=this.compiledReader;while(r){if(r.propertyCount===t)return r(Rt);r=r.next}if(this.slowReads++>=It){let e=this.length==t?this:this.slice(0,t);r=gt.keyMap?new Function("r","return {"+e.map(e=>gt.decodeKey(e)).map(e=>Tt.test(e)?Ut(e)+":r()":"["+JSON.stringify(e)+"]:r()").join(",")+"}"):new Function("r","return {"+e.map(e=>Tt.test(e)?Ut(e)+":r()":"["+JSON.stringify(e)+"]:r()").join(",")+"}");if(this.compiledReader)r.next=this.compiledReader;r.propertyCount=t;this.compiledReader=r;return r(Rt)}let n={};if(gt.keyMap)for(let e=0;e64&&ft)return ft.decode(lt.subarray(v,v+=e));const r=v+e;const n=[];t="";while(v65535){e-=65536;n.push(e>>>10&1023|55296);e=56320|e&1023}n.push(e)}else{n.push(i)}if(n.length>=4096){t+=zt.apply(String,n);n.length=0}}if(n.length>0){t+=zt.apply(String,n)}return t}let zt=String.fromCharCode;function Vt(t){let r=v;let n=new Array(t);for(let e=0;e0){v=r;return}n[e]=i}return zt.apply(String,n)}function Yt(d){if(d<4){if(d<2){if(d===0)return"";else{let e=lt[v++];if((e&128)>1){v-=1;return}return zt(e)}}else{let e=lt[v++];let t=lt[v++];if((e&128)>0||(t&128)>0){v-=2;return}if(d<3)return zt(e,t);let r=lt[v++];if((r&128)>0){v-=3;return}return zt(e,t,r)}}else{let l=lt[v++];let h=lt[v++];let p=lt[v++];let _=lt[v++];if((l&128)>0||(h&128)>0||(p&128)>0||(_&128)>0){v-=4;return}if(d<6){if(d===4)return zt(l,h,p,_);else{let e=lt[v++];if((e&128)>0){v-=5;return}return zt(l,h,p,_,e)}}else if(d<8){let e=lt[v++];let t=lt[v++];if((e&128)>0||(t&128)>0){v-=6;return}if(d<7)return zt(l,h,p,_,e,t);let r=lt[v++];if((r&128)>0){v-=7;return}return zt(l,h,p,_,e,t,r)}else{let o=lt[v++];let s=lt[v++];let c=lt[v++];let f=lt[v++];if((o&128)>0||(s&128)>0||(c&128)>0||(f&128)>0){v-=8;return}if(d<10){if(d===8)return zt(l,h,p,_,o,s,c,f);else{let e=lt[v++];if((e&128)>0){v-=9;return}return zt(l,h,p,_,o,s,c,f,e)}}else if(d<12){let e=lt[v++];let t=lt[v++];if((e&128)>0||(t&128)>0){v-=10;return}if(d<11)return zt(l,h,p,_,o,s,c,f,e,t);let r=lt[v++];if((r&128)>0){v-=11;return}return zt(l,h,p,_,o,s,c,f,e,t,r)}else{let n=lt[v++];let i=lt[v++];let u=lt[v++];let a=lt[v++];if((n&128)>0||(i&128)>0||(u&128)>0||(a&128)>0){v-=12;return}if(d<14){if(d===12)return zt(l,h,p,_,o,s,c,f,n,i,u,a);else{let e=lt[v++];if((e&128)>0){v-=13;return}return zt(l,h,p,_,o,s,c,f,n,i,u,a,e)}}else{let e=lt[v++];let t=lt[v++];if((e&128)>0||(t&128)>0){v-=14;return}if(d<15)return zt(l,h,p,_,o,s,c,f,n,i,u,a,e,t);let r=lt[v++];if((r&128)>0){v-=15;return}return zt(l,h,p,_,o,s,c,f,n,i,u,a,e,t,r)}}}}}function $t(e){return gt.copyBuffers?Uint8Array.prototype.slice.call(lt,v,v+=e):lt.subarray(v,v+=e)}let Jt=new Float32Array(1);let Kt=new Uint8Array(Jt.buffer,0,4);function Gt(){let t=lt[v++];let r=lt[v++];let e=(t&127)>>2;if(e===31){if(r||t&3)return NaN;return t&128?-Infinity:Infinity}if(e===0){let e=((t&3)<<8|r)/(1<<24);return t&128?-e:e}Kt[3]=t&128|(e>>1)+56;Kt[2]=(t&7)<<5|r>>3;Kt[1]=r<<5;Kt[0]=0;return Jt[0]}new Array(4096);class Ht{constructor(e,t){this.value=e;this.tag=t}}Ft[0]=e=>{return new Date(e)};Ft[1]=e=>{return new Date(Math.round(e*1e3))};Ft[2]=r=>{let n=BigInt(0);for(let e=0,t=r.byteLength;e{return BigInt(-1)-Ft[2](e)};Ft[4]=e=>{return+(e[1]+"e"+e[0])};Ft[5]=e=>{return e[1]*Math.exp(e[0]*Math.log(2))};const Wt=(e,t)=>{e=e-57344;let r=bt[e];if(r&&r.isShared){(bt.restoreStructures||(bt.restoreStructures=[]))[e]=r}bt[e]=t;t.read=Lt(t)};Ft[pt]=r=>{let e=r.length;let n=r[1];Wt(r[0],n);let i={};for(let t=2;t{if(At)return At[0].slice(At.position0,At.position0+=e);return new Ht(e,14)};Ft[15]=e=>{if(At)return At[1].slice(At.position1,At.position1+=e);return new Ht(e,15)};let Qt={Error:Error,RegExp:RegExp};Ft[27]=e=>{return(Qt[e[0]]||Error)(e[1],e[2])};const Zt=e=>{if(lt[v++]!=132)throw new Error("Packed values structure must be followed by a 4 element array");let t=e();Ct=Ct?t.concat(Ct.slice(t.length)):t;Ct.prefixes=e();Ct.suffixes=e();return e()};Zt.handlesRead=true;Ft[51]=Zt;Ft[yt]=e=>{if(!Ct){if(gt.getShared)sr();else return new Ht(e,yt)}if(typeof e=="number")return Ct[16+(e>=0?2*e:-2*e-1)];throw new Error("No support for non-integer packed references yet")};Ft[28]=e=>{if(!xt){xt=new Map;xt.id=0}let t=xt.id++;let r=lt[v];let n;if(r>>5==4)n=[];else n={};let i={target:n};xt.set(t,i);let u=e();if(i.used)return Object.assign(n,u);i.target=u;return u};Ft[28].handlesRead=true;Ft[29]=e=>{let t=xt.get(e);t.used=true;return t.target};Ft[258]=e=>new Set(e);(Ft[259]=e=>{if(gt.mapsAsObjects){gt.mapsAsObjects=false;St=true}return e()}).handlesRead=true;function Xt(e,t){if(typeof e==="string")return e+t;if(e instanceof Array)return e.concat(t);return Object.assign({},e,t)}function er(){if(!Ct){if(gt.getShared)sr();else throw new Error("No packed values available")}return Ct}const tr=1399353956;kt.push((e,t)=>{if(e>=225&&e<=255)return Xt(er().prefixes[e-224],t);if(e>=28704&&e<=32767)return Xt(er().prefixes[e-28672],t);if(e>=1879052288&&e<=2147483647)return Xt(er().prefixes[e-1879048192],t);if(e>=216&&e<=223)return Xt(t,er().suffixes[e-216]);if(e>=27647&&e<=28671)return Xt(t,er().suffixes[e-27639]);if(e>=1811940352&&e<=1879048191)return Xt(t,er().suffixes[e-1811939328]);if(e==tr){return{packedValues:Ct,structures:bt.slice(0),version:t}}if(e==55799)return t});const rr=new Uint8Array(new Uint16Array([1]).buffer)[0]==1;const nr=[Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array=="undefined"?{name:"BigUint64Array"}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array=="undefined"?{name:"BigInt64Array"}:BigInt64Array,Float32Array,Float64Array];const ir=[64,68,69,70,71,72,77,78,79,85,86];for(let e=0;e{if(!o)throw new Error("Could not find typed array for code "+s);return new o(Uint8Array.prototype.slice.call(e,0).buffer)}:e=>{if(!o)throw new Error("Could not find typed array for code "+s);let t=new DataView(e.buffer,e.byteOffset,e.byteLength);let r=e.length>>u;let n=new o(r);let i=t[c];for(let e=0;e23){switch(e){case 24:e=lt[v++];break;case 25:e=Ot.getUint16(v);v+=2;break;case 26:e=Ot.getUint32(v);v+=4;break}}return e}function sr(){if(gt.getShared){let e=cr(()=>{lt=null;return gt.getShared()})||{};let t=e.structures||[];gt.sharedVersion=e.version;Ct=gt.sharedValues=e.packedValues;if(bt===true)gt.structures=bt=t;else bt.splice.apply(bt,[0,t.length].concat(t))}}function cr(e){let t=ht;let r=v;let n=Dt;let i=Et;let u=wt;let a=xt;let o=At;let s=new Uint8Array(lt.slice(0,ht));let c=bt;let f=gt;let l=jt;let h=e();ht=t;v=r;Dt=n;Et=i;wt=u;xt=a;At=o;lt=s;jt=l;bt=c;gt=f;Ot=new DataView(lt.buffer,lt.byteOffset,lt.byteLength);return h}function fr(){lt=null;xt=null;bt=null}function lr(e){Ft[e.tag]=e.decode}const hr=new Array(147);for(let e=0;e<256;e++){hr[e]=+("1e"+Math.floor(45.15-e*.30103))}let pr=new Pt({useRecords:false});pr.decode;pr.decodeMultiple;let _r;try{_r=new TextEncoder}catch(e){}let dr,vr;const yr=typeof globalThis==="object"&&globalThis.Buffer;const mr=typeof yr!=="undefined";const gr=mr?yr.allocUnsafeSlow:Uint8Array;const br=mr?yr:Uint8Array;const wr=256;const Dr=mr?4294967296:2144337920;let Er;let O;let Ar;let S=0;let xr;let Fr=null;const kr=61440;const Cr=/[\u0080-\uFFFF]/;const Or=Symbol("record-id");class Sr extends Pt{constructor(r){super(r);this.offset=0;let s;let a;let _;let f;let n;r=r||{};let c=br.prototype.utf8Write?function(e,t,r){return O.utf8Write(e,t,r)}:_r&&_r.encodeInto?function(e,t){return _r.encodeInto(e,O.subarray(t)).written}:false;let u=this;let e=r.structures||r.saveStructures;let l=r.maxSharedStructures;if(l==null)l=e?128:0;if(l>8190)throw new Error("Maximum maxSharedStructure is 8190");let o=r.sequential;if(o){l=0}if(!this.structures)this.structures=[];if(this.saveStructures)this.saveShared=this.saveStructures;let d,v,y=r.sharedValues;let i;if(y){i=Object.create(null);for(let e=0,t=y.length;ethis.encodeKeys(e));break}}return this.encode(e,t)};this.encode=function(t,e){if(!O){O=new gr(8192);Ar=new DataView(O.buffer,0,8192);S=0}xr=O.length-10;if(xr-S<2048){O=new gr(O.length);Ar=new DataView(O.buffer,0,O.length);xr=O.length-10;S=0}else if(e===Yr)S=S+7&2147483640;s=S;if(u.useSelfDescribedHeader){Ar.setUint32(S,3654940416);S+=3}n=u.structuredClone?new Map:null;if(u.bundleStrings&&typeof t!=="string"){Fr=[];Fr.size=Infinity}else Fr=null;a=u.structures;if(a){if(a.uninitialized){let e=u.getShared()||{};u.structures=a=e.structures||[];u.sharedVersion=e.version;let r=u.sharedValues=e.packedValues;if(r){i={};for(let e=0,t=r.length;el&&!o)e=l;if(!a.transitions){a.transitions=Object.create(null);for(let u=0;u0){O[S++]=216;O[S++]=51;Ir(4);let r=e.values;p(r);Ir(0);Ir(0);v=Object.create(i||null);for(let e=0,t=r.length;exr)w(S);u.offset=S;let e=Mr(O.subarray(s,S),n.idsToInsert);n=null;return e}if(e&Yr){O.start=s;O.end=S;return O}return O.subarray(s,S)}finally{if(a){if(g<10)g++;if(a.length>l)a.length=l;if(m>1e4){a.transitions=null;g=0;m=0;if(h.length>0)h=[]}else if(h.length>0&&!o){for(let e=0,t=h.length;el){u.structures=u.structures.slice(0,l)}let e=O.subarray(s,S);if(u.updateSharedData()===false)return u.encode(t);return e}if(e&$r)S=s}};this.findCommonStringsToPack=()=>{d=new Map;if(!i)i=Object.create(null);return e=>{let r=e&&e.threshold||4;let n=this.pack?e.maxPrivatePackedValues||16:0;if(!y)y=this.sharedValues=[];for(let[e,t]of d){if(t.count>r){i[e]=n++;y.push(e);_=true}}while(this.saveShared&&this.updateSharedData()===false){}d=null}};const p=a=>{if(S>xr)O=w(S);var e=typeof a;var o;if(e==="string"){if(v){let e=v[a];if(e>=0){if(e<16)O[S++]=e+224;else{O[S++]=198;if(e&1)p(15-e>>1);else p(e-16>>1)}return}else if(d&&!r.pack){let e=d.get(a);if(e)e.count++;else d.set(a,{count:1})}}let i=a.length;if(Fr&&i>=4&&i<1024){if((Fr.size+=i)>kr){let e;let t=(Fr[0]?Fr[0].length*3+Fr[1].length:0)+10;if(S+t>xr)O=w(S+t);O[S++]=217;O[S++]=223;O[S++]=249;O[S++]=Fr.position?132:130;O[S++]=26;e=S-s;S+=4;if(Fr.position){qr(s,p)}Fr=["",""];Fr.size=0;Fr.position=e}let e=Cr.test(a);Fr[e?0:1]+=a;O[S++]=e?206:207;p(i);return}let u;if(i<32){u=1}else if(i<256){u=2}else if(i<65536){u=3}else{u=5}let e=i*3;if(S+e>xr)O=w(S+e);if(i<64||!c){let e,t,r,n=S+u;for(e=0;e>6|192;O[n++]=t&63|128}else if((t&64512)===55296&&((r=a.charCodeAt(e+1))&64512)===56320){t=65536+((t&1023)<<10)+(r&1023);e++;O[n++]=t>>18|240;O[n++]=t>>12&63|128;O[n++]=t>>6&63|128;O[n++]=t&63|128}else{O[n++]=t>>12|224;O[n++]=t>>6&63|128;O[n++]=t&63|128}}o=n-S-u}else{o=c(a,S+u,e)}if(o<24){O[S++]=96|o}else if(o<256){if(u<2){O.copyWithin(S+2,S+1,S+1+o)}O[S++]=120;O[S++]=o}else if(o<65536){if(u<3){O.copyWithin(S+3,S+2,S+2+o)}O[S++]=121;O[S++]=o>>8;O[S++]=o&255}else{if(u<5){O.copyWithin(S+5,S+3,S+3+o)}O[S++]=122;Ar.setUint32(S,o);S+=4}S+=o}else if(e==="number"){if(!this.alwaysUseFloat&&a>>>0===a){if(a<24){O[S++]=a}else if(a<256){O[S++]=24;O[S++]=a}else if(a<65536){O[S++]=25;O[S++]=a>>8;O[S++]=a&255}else{O[S++]=26;Ar.setUint32(S,a);S+=4}}else if(!this.alwaysUseFloat&&a>>0===a){if(a>=-24){O[S++]=31-a}else if(a>=-256){O[S++]=56;O[S++]=~a}else if(a>=-65536){O[S++]=57;Ar.setUint16(S,~a);S+=2}else{O[S++]=58;Ar.setUint32(S,~a);S+=4}}else{let t;if((t=this.useFloat32)>0&&a<4294967296&&a>=-2147483648){O[S++]=250;Ar.setFloat32(S,a);let e;if(t<4||(e=a*hr[(O[S]&127)<<1|O[S+1]>>7])>>0===e){S+=4;return}else S--}O[S++]=251;Ar.setFloat64(S,a);S+=8}}else if(e==="object"){if(!a)O[S++]=246;else{if(n){let t=n.get(a);if(t){O[S++]=216;O[S++]=29;O[S++]=25;if(!t.references){let e=n.idsToInsert||(n.idsToInsert=[]);t.references=[];e.push(t)}t.references.push(S-s);S+=2;return}else n.set(a,{offset:S-s})}let e=a.constructor;if(e===Object){b(a,true)}else if(e===Array){o=a.length;if(o<24){O[S++]=128|o}else{Ir(o)}for(let e=0;e>8;O[S++]=o&255}else{O[S++]=186;Ar.setUint32(S,o);S+=4}if(u.keyMap){for(let[e,t]of a){p(u.encodeKey(e));p(t)}}else{for(let[e,t]of a){p(e);p(t)}}}else{for(let r=0,e=dr.length;r>8;O[S++]=t&255}else if(t>-1){O[S++]=218;Ar.setUint32(S,t);S+=4}e.encode.call(this,a,p,w);return}}if(a[Symbol.iterator]){if(Er){let e=new Error("Iterable should be serialized as iterator");e.iteratorNotHandled=true;throw e}O[S++]=159;for(let e of a){p(e)}O[S++]=255;return}if(a[Symbol.asyncIterator]||Nr(a)){let e=new Error("Iterable/blob should be serialized as iterator");e.iteratorNotHandled=true;throw e}if(this.useToJSON&&a.toJSON){const t=a.toJSON();if(t!==a)return p(t)}b(a,!a.hasOwnProperty)}}}else if(e==="boolean"){O[S++]=a?245:244}else if(e==="bigint"){if(a=0){O[S++]=27;Ar.setBigUint64(S,a)}else if(a>-(BigInt(1)<{let t=Object.keys(e);let r=Object.values(e);let n=t.length;if(n<24){O[S++]=160|n}else if(n<256){O[S++]=184;O[S++]=n}else if(n<65536){O[S++]=185;O[S++]=n>>8;O[S++]=n&255}else{O[S++]=186;Ar.setUint32(S,n);S+=4}if(u.keyMap){for(let e=0;e{O[S++]=185;let e=S-s;S+=2;let n=0;if(u.keyMap){for(let e in t)if(r||t.hasOwnProperty(e)){p(u.encodeKey(e));p(t[e]);n++}}else{for(let e in t)if(r||t.hasOwnProperty(e)){p(e);p(t[e]);n++}}O[e+++s]=n>>8;O[e+s]=n&255}:(t,r)=>{let n,i=f.transitions||(f.transitions=Object.create(null));let u=0;let a=0;let o;let s;if(this.keyMap){s=Object.keys(t).map(e=>this.encodeKey(e));a=s.length;for(let t=0;t>8|224;O[S++]=c&255}else{if(!s)s=i.__keys__||(i.__keys__=Object.keys(t));if(o===undefined){c=f.nextId++;if(!c){c=0;f.nextId=1}if(c>=wr){f.nextId=(c=l)+1}}else{c=o}f[c]=s;if(c>8|224;O[S++]=c&255;i=f.transitions;for(let e=0;e=wr-l)h.shift()[Or]=undefined;h.push(i);Ir(a+2);p(57344+c);p(s);if(r===null)return;for(let e in t)if(r||t.hasOwnProperty(e))p(t[e]);return}}if(a<24){O[S++]=128|a}else{Ir(a)}if(r===null)return;for(let e in t)if(r||t.hasOwnProperty(e))p(t[e])};const w=e=>{let t;if(e>16777216){if(e-s>Dr)throw new Error("Encoded buffer would be larger than maximum buffer size");t=Math.min(Dr,Math.round(Math.max((e-s)*(e>67108864?1.25:2),4194304)/4096)*4096)}else t=(Math.max(e-s<<2,O.length-1)>>12)+1<<12;let r=new gr(t);Ar=new DataView(r.buffer,0,t);if(O.copy)O.copy(r,0,s,e);else r.set(O.slice(s,e));S-=s;s=0;xr=r.length-10;return O=r};let D=100;let E=1e3;this.encodeAsIterable=function(e,t){return k(e,t,A)};this.encodeAsAsyncIterable=function(e,t){return k(e,t,C)};function*A(n,i,e){let t=n.constructor;if(t===Object){let r=u.useRecords!==false;if(r)b(n,null);else Br(Object.keys(n).length,160);for(let t in n){let e=n[t];if(!r)p(t);if(e&&typeof e==="object"){if(i[t])yield*A(e,i[t]);else yield*x(e,i,t)}else p(e)}}else if(t===Array){let e=n.length;Ir(e);for(let t=0;tD)){if(i.element)yield*A(e,i.element);else yield*x(e,i,"element")}else p(e)}}else if(n[Symbol.iterator]){O[S++]=159;for(let e of n){if(e&&(typeof e==="object"||S-s>D)){if(i.element)yield*A(e,i.element);else yield*x(e,i,"element")}else p(e)}O[S++]=255}else if(Nr(n)){Br(n.size,64);yield O.subarray(s,S);yield n;F()}else if(n[Symbol.asyncIterator]){O[S++]=159;yield O.subarray(s,S);yield n;F();O[S++]=255}else{p(n)}if(e&&S>s)yield O.subarray(s,S);else if(S-s>D){yield O.subarray(s,S);F()}}function*x(t,r,n){let i=S-s;try{p(t);if(S-s>D){yield O.subarray(s,S);F()}}catch(e){if(e.iteratorNotHandled){r[n]={};S=s+i;yield*A.call(this,t,r[n])}else throw e}}function F(){D=E;u.encode(null,Jr)}function k(e,t,r){if(t&&t.chunkThreshold)D=E=t.chunkThreshold;else D=100;if(e&&typeof e==="object"){u.encode(null,Jr);return r(e,u.iterateProperties||(u.iterateProperties={}),true)}return[u.encode(e)]}async function*C(e,t){for(let r of A(e,t,true)){let e=r.constructor;if(e===br||e===Uint8Array)yield r;else if(Nr(r)){let e=r.stream().getReader();let t;while(!(t=await e.read()).done){yield t.value}}else if(r[Symbol.asyncIterator]){for await(let e of r){F();if(e)yield*C(e,t.async||(t.async={}));else yield u.encode(e)}}else{yield r}}}}useBuffer(e){O=e;Ar=new DataView(O.buffer,O.byteOffset,O.byteLength);S=0}clearSharedData(){if(this.structures)this.structures=[];if(this.sharedValues)this.sharedValues=undefined}updateSharedData(){let t=this.sharedVersion||0;this.sharedVersion=t+1;let e=this.structures.slice(0);let r=new jr(e,this.sharedValues,this.sharedVersion);let n=this.saveShared(r,e=>(e&&e.version||0)==t);if(n===false){r=this.getShared()||{};this.structures=r.structures||[];this.sharedValues=r.packedValues;this.sharedVersion=r.version;this.structures.nextId=this.structures.length}else{e.forEach((e,t)=>this.structures[t]=e)}return n}}function Br(e,t){if(e<24)O[S++]=t|e;else if(e<256){O[S++]=t|24;O[S++]=e}else if(e<65536){O[S++]=t|25;O[S++]=e>>8;O[S++]=e&255}else{O[S++]=t|26;Ar.setUint32(S,e);S+=4}}class jr{constructor(e,t,r){this.structures=e;this.packedValues=t;this.version=r}}function Ir(e){if(e<24)O[S++]=128|e;else if(e<256){O[S++]=152;O[S++]=e}else if(e<65536){O[S++]=153;O[S++]=e>>8;O[S++]=e&255}else{O[S++]=154;Ar.setUint32(S,e);S+=4}}const Pr=typeof Blob==="undefined"?function(){}:Blob;function Nr(e){if(e instanceof Pr)return true;let t=e[Symbol.toStringTag];return t==="Blob"||t==="File"}function Rr(r,n){switch(typeof r){case"string":if(r.length>3){if(n.objectMap[r]>-1||n.values.length>=n.maxValues)return;let e=n.get(r);if(e){if(++e.count==2){n.values.push(r)}}else{n.set(r,{count:1});if(n.samplingPackedValues){let e=n.samplingPackedValues.get(r);if(e)e.count++;else n.samplingPackedValues.set(r,{count:1})}}}break;case"object":if(r){if(r instanceof Array){for(let e=0,t=r.length;e=0&&r<4294967296){O[S++]=26;Ar.setUint32(S,r);S+=4}else{O[S++]=251;Ar.setFloat64(S,r);S+=8}}},{tag:258,encode(e,t){let r=Array.from(e);t(r)}},{tag:27,encode(e,t){t([e.name,e.message])}},{tag:27,encode(e,t){t(["RegExp",e.source,e.flags])}},{getTag(e){return e.tag},encode(e,t){t(e.value)}},{encode(e,t,r){Ur(e,r)}},{getTag(e){if(e.constructor===Uint8Array){if(this.tagUint8Array||mr&&this.tagUint8Array!==false)return 64}},encode(e,t,r){Ur(e,r)}},Lr(68,1),Lr(69,2),Lr(70,4),Lr(71,8),Lr(72,1),Lr(77,2),Lr(78,4),Lr(79,8),Lr(85,4),Lr(86,8),{encode(t,n){let e=t.packedValues||[];let r=t.structures||[];if(e.values.length>0){O[S++]=216;O[S++]=51;Ir(4);let r=e.values;n(r);Ir(0);Ir(0);packedObjectMap=Object.create(sharedPackedObjectMap||null);for(let e=0,t=r.length;e1)e-=4;return{tag:e,encode:function e(t,r){let n=t.byteLength;let i=t.byteOffset||0;let u=t.buffer||t;r(mr?yr.from(u,i,n):new Uint8Array(u,i,n))}}}function Ur(e,t){let r=e.byteLength;if(r<24){O[S++]=64+r}else if(r<256){O[S++]=88;O[S++]=r}else if(r<65536){O[S++]=89;O[S++]=r>>8;O[S++]=r&255}else{O[S++]=90;Ar.setUint32(S,r);S+=4}if(S+r>=O.length){t(S+r)}O.set(e.buffer?e:new Uint8Array(e),S);S+=r}function Mr(n,e){let r;let i=e.length*2;let u=n.length-i;e.sort((e,t)=>e.offset>t.offset?1:-1);for(let r=0;r>8;n[e]=r&255}}while(r=e.pop()){let e=r.offset;n.copyWithin(e+i,e,u);i-=2;let t=e+i;n[t++]=216;n[t++]=28;u=e}return n}function qr(e,t){Ar.setUint32(Fr.position+e,S-Fr.position-e+1);let r=Fr;Fr=null;t(r[0]);t(r[1])}function zr(e){if(e.Class){if(!e.encode)throw new Error("Extension has no encode function");vr.unshift(e.Class);dr.unshift(e)}lr(e)}let Vr=new Sr({useRecords:false});Vr.encode;Vr.encodeAsIterable;Vr.encodeAsAsyncIterable;const Yr=512;const $r=1024;const Jr=2048;var Kr={}; /**@license * * No Dependency fast and small LZJB Compression for Browser and Node @@ -13,7 +13,7 @@ * Released under BSD-3-Clause License * * build: Wed, 27 Oct 2021 10:43:10 GMT - */Object.defineProperty(Jr,"__esModule",{value:true});const Kr=8,Gr=6,Hr=3,Wr=(1<r-Wr){t[i++]=e[n++];continue}l=(e[n]+13^e[n+1]-13^e[n+2])&Zr-1;s=n-h[l]&Qr;h[l]=n;u=n-s;if(u>=0&&u!=n&&e[n]==e[u]&&e[n+1]==e[u+1]&&e[n+2]==e[u+2]){t[f]|=a;for(o=Hr;o>Kr;t[i++]=s;n+=o}else{t[i++]=e[n++]}}console.assert(e.length>=n);return i}function en(e,t,r){t=t|0;var n=0,i=0,u=0,a=0,o=1<<(Kr-1|0),s=0,c=0;while(n>(Kr-Gr|0))+Hr|0;c=(e[n]<4){r[i]=r[u];i=i+1|0;u=u+1|0;r[i]=r[u];i=i+1|0;u=u+1|0;r[i]=r[u];i=i+1|0;u=u+1|0;r[i]=r[u];i=i+1|0;u=u+1|0;s=s-4|0}while(s>0){r[i]=r[u];i=i+1|0;u=u+1|0;s=s-1|0}}}else{r[i]=e[n];i=i+1|0;n=n+1|0}}return i}function tn(){const e=new TextEncoder("utf-8");return e.encode(rn)}const rn="@lzjb";const nn=tn();function un(...e){if(e.length>1){const r=e.reduce((e,t)=>e+t.length,0);const n=new Uint8Array(r);let t=0;e.forEach(e=>{n.set(e,t);t+=e.length});return n}else if(e.length){return e[0]}}function an(t){const e=Math.ceil(Math.log2(t)/8);const r=new Uint8Array(e);for(let e=0;e=0;e--){r=r*256+t[e]}return r}function sn(e,{magic:t=true}={}){const r=new Uint8Array(Math.max(e.length*1.5|0,16*1024));const n=Xr(e,r);const i=an(e.length);const u=[Uint8Array.of(i.length),i,r.slice(0,n)];if(t){u.unshift(nn)}return un(...u)}function cn(t,{magic:e=true}={}){if(e){const e=new TextDecoder("utf-8");const s=e.decode(t.slice(0,nn.length));if(s!==rn){throw new Error("Invalid magic value")}}const r=e?nn.length:0;const n=t[r];const i=r+1;const u=r+n+1;const a=on(t.slice(i,u));t=t.slice(u);const o=new Uint8Array(a);en(t,t.length,o);return o}var fn=Jr.pack=sn;var ln=Jr.unpack=cn;function hn(s,c){return c=c||{},new Promise(function(e,t){var r=new XMLHttpRequest,n=[],i=[],u={},a=function(){return{ok:2==(r.status/100|0),statusText:r.statusText,status:r.status,url:r.responseURL,text:function(){return Promise.resolve(r.responseText)},json:function(){return Promise.resolve(r.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([r.response]))},clone:a,headers:{keys:function(){return n},entries:function(){return i},get:function(e){return u[e.toLowerCase()]},has:function(e){return e.toLowerCase()in u}}}};for(var o in r.open(c.method||"get",s,!0),r.onload=function(){r.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,t,r){n.push(t=t.toLowerCase()),i.push([t,r]),u[t]=u[t]?u[t]+","+r:r}),e(a())},r.onerror=t,r.withCredentials="include"==c.credentials,c.headers)r.setRequestHeader(o,c.headers[o]);r.send(c.body||null)})} + */Object.defineProperty(Kr,"__esModule",{value:true});const Gr=8,Hr=6,Wr=3,Qr=(1<r-Qr){t[i++]=e[n++];continue}l=(e[n]+13^e[n+1]-13^e[n+2])&Xr-1;s=n-h[l]&Zr;h[l]=n;u=n-s;if(u>=0&&u!=n&&e[n]==e[u]&&e[n+1]==e[u+1]&&e[n+2]==e[u+2]){t[f]|=a;for(o=Wr;o>Gr;t[i++]=s;n+=o}else{t[i++]=e[n++]}}console.assert(e.length>=n);return i}function tn(e,t,r){t=t|0;var n=0,i=0,u=0,a=0,o=1<<(Gr-1|0),s=0,c=0;while(n>(Gr-Hr|0))+Wr|0;c=(e[n]<4){r[i]=r[u];i=i+1|0;u=u+1|0;r[i]=r[u];i=i+1|0;u=u+1|0;r[i]=r[u];i=i+1|0;u=u+1|0;r[i]=r[u];i=i+1|0;u=u+1|0;s=s-4|0}while(s>0){r[i]=r[u];i=i+1|0;u=u+1|0;s=s-1|0}}}else{r[i]=e[n];i=i+1|0;n=n+1|0}}return i}function rn(){const e=new TextEncoder("utf-8");return e.encode(nn)}const nn="@lzjb";const un=rn();function an(...e){if(e.length>1){const r=e.reduce((e,t)=>e+t.length,0);const n=new Uint8Array(r);let t=0;e.forEach(e=>{n.set(e,t);t+=e.length});return n}else if(e.length){return e[0]}}function on(t){const e=Math.ceil(Math.log2(t)/8);const r=new Uint8Array(e);for(let e=0;e=0;e--){r=r*256+t[e]}return r}function cn(e,{magic:t=true}={}){const r=new Uint8Array(Math.max(e.length*1.5|0,16*1024));const n=en(e,r);const i=on(e.length);const u=[Uint8Array.of(i.length),i,r.slice(0,n)];if(t){u.unshift(un)}return an(...u)}function fn(t,{magic:e=true}={}){if(e){const e=new TextDecoder("utf-8");const s=e.decode(t.slice(0,un.length));if(s!==nn){throw new Error("Invalid magic value")}}const r=e?un.length:0;const n=t[r];const i=r+1;const u=r+n+1;const a=sn(t.slice(i,u));t=t.slice(u);const o=new Uint8Array(a);tn(t,t.length,o);return o}var ln=Kr.pack=cn;var hn=Kr.unpack=fn;function pn(s,c){return c=c||{},new Promise(function(e,t){var r=new XMLHttpRequest,n=[],i=[],u={},a=function(){return{ok:2==(r.status/100|0),statusText:r.statusText,status:r.status,url:r.responseURL,text:function(){return Promise.resolve(r.responseText)},json:function(){return Promise.resolve(r.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([r.response]))},clone:a,headers:{keys:function(){return n},entries:function(){return i},get:function(e){return u[e.toLowerCase()]},has:function(e){return e.toLowerCase()in u}}}};for(var o in r.open(c.method||"get",s,!0),r.onload=function(){r.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,t,r){n.push(t=t.toLowerCase()),i.push([t,r]),u[t]=u[t]?u[t]+","+r:r}),e(a())},r.onerror=t,r.withCredentials="include"==c.credentials,c.headers)r.setRequestHeader(o,c.headers[o]);r.send(c.body||null)})} /**@license * __ __ __ * / / \ \ _ _ ___ ___ \ \ @@ -47,5 +47,5 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Mon, 15 Jan 2024 12:39:38 +0000 - */var pn=["token"],_n=["env"],dn=["stderr","stdin","stdout","command_line"],vn=["use_dynamic"],yn=["use_dynamic"],mn=["env","dynamic_env","use_dynamic","error"];function gn(e,t,r){bn(e,t);t.set(e,r)}function bn(e,t){if(t.has(e)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}function wn(i){var u=Dn();return function e(){var t=g(i),r;if(u){var n=g(this).constructor;r=Reflect.construct(t,arguments,n)}else{r=t.apply(this,arguments)}return m(this,r)}}function Dn(){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 En(t,e){var r=typeof Symbol!=="undefined"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=An(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 An(e,t){if(!e)return;if(typeof e==="string")return xn(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 xn(e,t)}function xn(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(!Un()){return}var t=is.get("repr")(e);if(r===null||r instanceof RegExp&&r.test(t)){console.log(is.get("type")(e)+": "+t)}if(n){console.log(e)}}if(ga(e)){e.then(t)}else{t(e)}return e}function Un(){return us&&us.get("DEBUG",{throwError:false})}function Mn(e){return e?"(?:#".concat(e,"(?:#[ie])?|#[ie]#").concat(e,")"):"(?:#[ie])?"}function qn(e,t){return"".concat(Mn(e),"[+-]?").concat(t,"+/").concat(t,"+")}function Yn(e,t){return"".concat(Mn(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 Vn(e,t){return"".concat(Mn(e),"[+-]?").concat(t,"+")}var zn=/^#\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimyus]*)$/;var $n="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+)(?:[eE][-+]?[0-9]+)?)|[0-9]+\\.)";var Jn="(?:#[ie])?(?:[+-]?(?:[0-9]+/[0-9]+|nan.0|inf.0|".concat($n,"|[+-]?[0-9]+))?(?:").concat($n,"|[+-](?:[0-9]+/[0-9]+|[0-9]+|nan.0|inf.0))i");var Kn=new RegExp("^(#[ie])?".concat($n,"$"),"i");function Gn(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 Hn=function(){var u={};[[10,"","[0-9]"],[16,"x","[0-9a-fA-F]"],[8,"o","[0-7]"],[2,"b","[01]"]].forEach(function(e){var t=Y(e,3),r=t[0],n=t[1],i=t[2];u[r]=Gn(n,i)});return u}();var Wn={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 Qn(e){var t=[];var r=0;var n=e.length;while(r=55296&&i<=56319&&r1&&arguments[1]!==undefined?arguments[1]:10;var r=li(e);var n=r.number.split("/");var i=Co({num:y([n[0],r.radix||t]),denom:y([n[1],r.radix||t])});if(r.inexact){return i.valueOf()}else{return i}}function pi(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;var r=li(e);if(r.inexact){return Eo(parseInt(r.number,r.radix||t))}return y([r.number,r.radix||t])}function _i(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 oo(r)}throw new Error("Parse: invalid character")}function di(e){var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;function t(e){var t;if(e==="+"){t=y(1)}else if(e==="-"){t=y(-1)}else if(e.match(ai)){t=y([e,i])}else if(e.match(oi)){var r=e.split("/");t=Co({num:y([r[0],i]),denom:y([r[1],i])})}else if(e.match(Kn)){var n=mi(e);if(u.exact){return n.toRational()}return n}else if(e.match(/nan.0$/)){return y(NaN)}else if(e.match(/inf.0$/)){if(e[0]==="-"){return y(Number.NEGATIVE_INFINITY)}return y(Number.POSITIVE_INFINITY)}else{throw new Error("Internal Parser Error")}if(u.inexact){return Eo(t.valueOf())}return t}var u=li(e);i=u.radix||i;var r;var n=u.number.match(ci);if(i!==10&&n){r=n}else{r=u.number.match(Hn[i])}var a,o;o=t(r[2]);if(r[1]){a=t(r[1])}else{a=y(0)}if(o.cmp(0)===0&&o.__type__==="bigint"){return a}return Do({im:o,re:a})}function vi(e){return parseInt(e.toString(),10)===e}function yi(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 y(u).mul(o)}}}r=Eo(r);if(t.exact){return r.toRational()}return r}function gi(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 so(JSON.parse(e))}catch(e){var r=e.message.replace(/in JSON /,"").replace(/.*Error: /,"");throw new Error("Invalid string literal: ".concat(r))}}function bi(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 wi(e){if(ns.hasOwnProperty(e)){return ns[e]}if(e.match(/^"[\s\S]*"$/)){return gi(e)}else if(e[0]==="#"){var t=e.match(zn);if(t){return new RegExp(t[1],t[2])}else if(e.match(ei)){return _i(e)}var r=e.match(/#\\(.+)/);if(r&&Qn(r[1]).length===1){return _i(e)}}if(e.match(/[0-9a-f]|[+-]i/i)){if(e.match(ui)){return pi(e)}else if(e.match(Kn)){return mi(e)}else if(e.match(ii)){return hi(e)}else if(e.match(ni)){return di(e)}}if(e.match(/^#[iexobd]/)){throw new Error("Invalid numeric constant: "+e)}return bi(e)}function Di(e){return!(["(",")","[","]"].includes(e)||Yi.names().includes(e))}function Ei(e){return Di(e)&&!(e.match(zn)||e.match(/^"[\s\S]*"$/)||e.match(ui)||e.match(Kn)||e.match(ni)||e.match(ii)||e.match(ei)||["#t","#f","nil","true","false"].includes(e))}var Ai=/"(?:\\[\S\s]|[^"])*"?/g;function xi(e){if(typeof e==="string"){var t=/([-\\^$[\]()+{}?*.|])/g;return e.replace(t,"\\$1")}return e}function Fi(){this.data=[]}Fi.prototype.push=function(e){this.data.push(e)};Fi.prototype.top=function(){return this.data[this.data.length-1]};Fi.prototype.pop=function(){return this.data.pop()};Fi.prototype.is_empty=function(){return!this.data.length};function ki(e){if(e instanceof so){e=e.valueOf()}var t=new s(e,{whitespace:true});var r=[];while(true){var n=t.peek(true);if(n===Vo){break}r.push(n);t.skip()}return r}function Ci(e){var t=e.token,r=R(e,pn);if(t.match(/^"[\s\S]*"$/)&&t.match(/\n/)){var n=new RegExp("^ {1,"+(e.col+1)+"}","mg");t=t.replace(n,"")}return kn({token:t},r)}function Oi(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};this.fn=e;this.cont=t}Oi.prototype.toString=function(){return"#"};function Si(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r1&&arguments[1]!==undefined?arguments[1]:false;if(e instanceof so){e=e.toString()}if(t){return ki(e)}else{var r=ki(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 Ii(r)}}function Ii(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(Ri(e)){return L(e)}if(e!==null){return r(e,Symbol("#:".concat(e)))}t++;return r(t,Symbol("#:g".concat(t)))}}();function Li(e){var r=this;var n={pending:true,rejected:false,fulfilled:false,reason:undefined,type:undefined};e=e.then(function(e){n.type=Ds(e);n.fulfilled=true;n.pending=false;return e});nu(this,"_promise",e,{hidden:true});if(ha(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]}})});nu(this,"__promise__",e);this.then=false}Li.prototype.then=function(e){return new Li(this.valueOf().then(e))};Li.prototype["catch"]=function(e){return new Li(this.valueOf()["catch"](e))};Li.prototype.valueOf=function(){if(!this._promise){throw new Error("QuotedPromise: invalid promise created")}return this._promise};Li.prototype.toString=function(){if(this.__pending__){return Li.pending_str}if(this.__rejected__){return Li.rejected_str}return"#")};Li.pending_str="#";Li.rejected_str="#";function Ui(e){if(Array.isArray(e)){return Promise.all(Mi(e)).then(qi)}return e}function Mi(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof Li){t[r]=new Go(n)}else{t[r]=n}}return t}function qi(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof Go){t[r]=n.valueOf()}else{t[r]=n}}return t}var Yi={LITERAL:Symbol["for"]("literal"),SPLICE:Symbol["for"]("splice"),SYMBOL:Symbol["for"]("symbol"),names:function e(){return Object.keys(this.__list__)},type:function e(t){try{return this.get(t).type}catch(e){console.log({name:t});console.log(e);return null}},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"),Yi.LITERAL]];var Gi=Ki.map(function(e){return e[0]});Object.freeze(Gi);Object.defineProperty(Yi,"__builtins__",{writable:false,value:Gi});Ki.forEach(function(e){var t=Y(e,3),r=t[0],n=t[1],i=t[2];Yi.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;j(this,p);nu(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=""}P(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 Vo}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 Vo}},{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 Vo}for(var r=this._i;r=r){return Vo}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 Vo}return oo(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=Y(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(!Hi(o,r)){return false}if(!Hi(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?Ci:u;j(this,o);if(e instanceof so){e=e.toString()}nu(this,"_formatter",a,{hidden:true});nu(this,"__lexer__",new s(e));nu(this,"__env__",r);nu(this,"_meta",i,{hidden:true});nu(this,"_refs",[],{hidden:true});nu(this,"_state",{parentheses:0},{hidden:true})}P(o,[{key:"resolve",value:function e(t){return this.__env__&&this.__env__.get(t,{throwError:false})}},{key:"peek",value:function(){var e=B(H.mark(function e(){var r;return H.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:r=this.__lexer__.peek(true);if(!(r===Vo)){t.next=4;break}return t.abrupt("return",Vo);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()===Vo)){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(H.mark(function e(){var r;return H.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(H.mark(function e(){var r,n,i,u;return H.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===Vo)){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(H.mark(function e(){var r;return H.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===Vo)){t.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return t.abrupt("return",wi(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 Rs(t,{env:this.__env__,error:function e(t){throw t}})}},{key:"read_object",value:function(){var e=B(H.mark(function e(){var r;return H.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 Qi){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,r){var n=this._state.parentheses;var i;if(n<0){i=new Error("Parser: unexpected parenthesis");i.__code__=[r.toString()+")"]}else{i=new Error("Parser: expected parenthesis but eof found");var u=new RegExp("\\){".concat(n,"}$"));i.__code__=[t.toString().replace(u,"")]}throw i}},{key:"_resolve_object",value:function(){var t=B(H.mark(function e(r){var n=this;var i;return H.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(!Pu(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(H.mark(function e(r){return H.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 Qi)){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 Qi)){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(H.mark(function e(){var r,n,h,i,u,a,o,s,c,f,l;return H.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===Vo)){t.next=5;break}return t.abrupt("return",r);case 5:if(!Vi(r)){t.next=38;break}n=Yi.get(r);h=zi(r);this.skip();u=Ji(r);if(!u){t.next=14;break}t.t0=undefined;t.next=17;break;case 14:t.next=16;return this._read_object();case 16:t.t0=t.sent;case 17:a=t.t0;if(h){t.next=25;break}o=this.__env__.get(n.symbol);if(!(typeof o==="function")){t.next=25;break}if($i(r)){s=[a]}else if(a===U){s=[]}else if(a instanceof M){s=a.to_array(false)}if(!(s||u)){t.next=24;break}return t.abrupt("return",Cs(o,u?[]:s,{env:this.__env__,dynamic_env:this.__env__,use_dynamic:false}));case 24:throw new Error("Parse Error: Invalid parser extension "+"invocation ".concat(n.symbol));case 25:if($i(r)){i=new M(n.symbol,new M(a,U))}else{i=new M(n.symbol,a)}if(!h){t.next=28;break}return t.abrupt("return",i);case 28:if(!(o instanceof ra)){t.next=37;break}t.next=31;return this.evaluate(i);case 31:c=t.sent;if(!(c instanceof M||c instanceof L)){t.next=34;break}return t.abrupt("return",M.fromArray([L("quote"),c]));case 34:return t.abrupt("return",c);case 37:throw new Error("Parse Error: invalid parser extension: "+n.symbol);case 38:f=this.match_datum_ref(r);if(!(f!==null)){t.next=44;break}this.skip();if(!this._refs[f]){t.next=43;break}return t.abrupt("return",new Qi(f,this._refs[f]));case 43:throw new Error("Parse Error: invalid datum label #".concat(f,"#"));case 44:l=this.match_datum_label(r);if(!(l!==null)){t.next=51;break}this.skip();this._refs[l]=this._read_object();return t.abrupt("return",this._refs[l]);case 51:if(!this.is_close(r)){t.next=55;break}this.skip();t.next=61;break;case 55:if(!this.is_open(r)){t.next=60;break}this.skip();return t.abrupt("return",this.read_list());case 60:return t.abrupt("return",this.read_value());case 61:case"end":return t.stop()}}},e,this)}));function t(){return e.apply(this,arguments)}return t}()}]);return o}();var Qi=function(){function r(e,t){j(this,r);this.name=e;this.data=t}P(r,[{key:"valueOf",value:function e(){return this.data}}]);return r}();function Zi(e,t){return Xi.apply(this,arguments)}function Xi(){Xi=e(H.mark(function e(r,n){var i,u,a;return H.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!n){if(is){n=is.get("**interaction-environment**",{throwError:false})}else{n=us}}i=new Wi(r,{env:n});case 3:t.next=6;return z(i.read_object());case 6:a=t.sent;if(!i.balanced()){i.ballancing_error(a,u)}if(!(a===Vo)){t.next=10;break}return t.abrupt("break",15);case 10:u=a;t.next=13;return a;case 13:t.next=3;break;case 15:case"end":return t.stop()}}},e)}));return Xi.apply(this,arguments)}function eu(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(ga(e)){var n=e.then(t);if(r===null){return n}else{return n["catch"](r)}}if(e instanceof Array){return tu(e,t,r)}if(Pu(e)){return ru(e,t,r)}return t(e)}function tu(t,r,e){if(t.find(ga)){return eu(Ui(t),function(e){if(Object.isFrozen(t)){Object.freeze(e)}return r(e)},e)}return r(t)}function ru(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(ga(s)){u.push(s)}}if(u.length){return eu(Ui(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 nu(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 iu(e){return uu.apply(this,arguments)}function uu(){uu=B(H.mark(function e(r){var n,i,u,a,o,s,c;return H.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:n=[];i=false;u=false;t.prev=3;o=Cn(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 uu.apply(this,arguments)}function au(e,t){if(t instanceof RegExp){return function(e){return String(e).match(t)}}else if(ha(t)){return t}throw new Error("Invalid matcher")}function l(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__=ou(r)}}if(e){t.__name__=e}else if(t.name&&!$a(t)){t.__name__=t.name}return t}function ou(e){return e.split("\n").map(function(e){return e.trim()}).join("\n")}function su(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 cu(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 fu(e,t){return f(e,t)===t.length;function f(r,n){function e(e,t){var r=En(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")&&!Ei(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 lu(e){this.__code__=e.replace(/\r/g,"")}lu.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:["&","#"]}}};lu.match=fu;lu.prototype._options=function e(t){var r=lu.defaults;if(typeof t==="undefined"){return Object.assign({},r)}var n=t&&t.exceptions||{};var i=n.specials||[];var u=n.shift||{1:[]};return kn(kn(kn({},r),t),{},{exceptions:{specials:[].concat(C(r.exceptions.specials),C(i)),shift:kn(kn({},u),{},{1:[].concat(C(r.exceptions.shift[1]),C(u[1]))})}})};lu.prototype.indent=function e(t){var r=ji(this.__code__,true);return this._indent(r,t)};lu.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=En(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=lu.exception_shift(i.token,t);if(a!==-1){u=a}}if(u===-1){u=lu.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")};hu.prototype.match=function(e){return e.match(this.pattern)};function pu(){for(var e=arguments.length,t=new Array(e),r=0;r")};lu.Pattern=pu;lu.Ahead=hu;var _u=/^[[(]$/;var du=/^[\])]$/;var vu=/[^()[\]]/;var yu=new hu(/[^)\]]/);var mu=Symbol["for"]("*");var gu=new pu([_u,mu,du],[vu],"+");var bu=new pu([_u,mu,du],"+");var wu=new pu([Symbol["for"]("symbol")],"?");var Du=new pu([Symbol["for"]("symbol")],"*");var Eu=[_u,Du,du];var Au=new pu([_u,Symbol["for"]("symbol"),mu,du],"+");var xu=Cu("define","lambda","define-macro","syntax-rules");var Fu=/^(?!.*\b(?:[()[\]]|define(?:-macro)?|let(?:\*|rec|-env|-syntax|)?|lambda|syntax-rules)\b).*$/;var ku=/^(?:#:)?(let(?:\*|rec|-env|-syntax)?)$/;function Cu(){for(var e=arguments.length,t=new Array(e),r=0;r0&&!i[e]){i[e]=su(n,e)}});var u=En(t),p;try{for(u.s();!(p=u.n()).done;){var a=Y(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()&&!Vi(e)});var y=h(d);var m=fu(_,v);var g=e.slice(r).find(function(e){return e.trim()&&!Vi(e)});if(m&&(s instanceof hu&&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};lu.prototype._spaces=function(e){return new Array(e+1).join(" ")};lu.prototype.format=function c(e){var t=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var r=ji(t,true);var n=this._options(e);var i=0;var u=0;for(var a=0;a0){n=Math.floor(t()*r);r--;var i=[e[n],e[r]];e[r]=i[0];e[n]=i[1]}return e}function Bu(){}Bu.prototype.toString=function(){return"()"};Bu.prototype.valueOf=function(){return undefined};Bu.prototype.serialize=function(){return 0};Bu.prototype.to_object=function(){return{}};Bu.prototype.append=function(e){return new M(e,U)};Bu.prototype.to_array=function(){return[]};var U=new Bu;function M(e,t){if(typeof this!=="undefined"&&this.constructor!==M||typeof this==="undefined"){return new M(e,t)}this.car=e;this.cdr=t}function ju(u,a){return function e(t){h(u,t,["pair","nil"]);if(t===U){return[]}var r=[];var n=t;while(true){if(n instanceof M){if(n.haveCycles("cdr")){break}var i=n.car;if(a&&i instanceof M){i=this.get(u).call(this,i)}r.push(i);n=n.cdr}else if(n===U){break}else{throw new Error("".concat(u,": can't convert improper list"))}}return r}}M.prototype.flatten=function(){return M.fromArray(Ou(this.to_array()))};M.prototype.length=function(){var e=0;var t=this;while(true){if(!t||t===U||!(t instanceof M)||t.haveCycles("cdr")){break}e++;t=t.cdr}return e};M.match=function(e,t){if(e instanceof L){return L.is(e,t)}else if(e instanceof M){return M.match(e.car,t)||M.match(e.cdr,t)}else if(Array.isArray(e)){return e.some(function(e){return M.match(e,t)})}else if(Pu(e)){return Object.values(e).some(function(e){return M.match(e,t)})}return false};M.prototype.find=function(e){return M.match(this,e)};M.prototype.clone=function(){var r=arguments.length>0&&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[Ra]=e[Ra];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(e))}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[Pa]){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=C(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=so(o)}else if(typeof o==="number"&&!Number.isNaN(o)){o=y(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 so){i=i.valueOf()}var u=n.cdr;if(u instanceof M){u=u.to_object(e)}if(ms(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 Iu=new Map;function Pu(e){return e&&d(e)==="object"&&e.constructor===Object}var Nu=Object.getOwnPropertyNames(Array.prototype);var Ru=[];Nu.forEach(function(e){Ru.push(Array[e],Array.prototype[e])});function Tu(e){e=xa(e);return Ru.includes(e)}function Lu(e){return ha(e)&&($a(e)||e.__doc__)}function Uu(r){var e=r.constructor||Object;var n=Pu(r);var i=ha(r[Symbol.asyncIterator])||ha(r[Symbol.iterator]);var u;if(Iu.has(e)){u=Iu.get(e)}else{Iu.forEach(function(e,t){t=xa(t);if(r.constructor===t&&(t===Object&&n&&!i||t!==Object)){u=e}})}return u}var Mu=new Map;[[true,"#t"],[false,"#f"],[null,"null"],[undefined,"#"]].forEach(function(e){var t=Y(e,2),r=t[0],n=t[1];Mu.set(r,n)});function qu(r){if(r&&d(r)==="object"){var n={};var e=Object.getOwnPropertySymbols(r);e.forEach(function(e){var t=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");n[t]=Ku(r[e])});var t=Object.getOwnPropertyNames(r);t.forEach(function(e){var t=r[e];if(t&&d(t)==="object"&&t.constructor===Object){n[e]=qu(t)}else{n[e]=Ku(t)}});return n}return r}function Yu(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function Vu(e,t){return e.hasOwnProperty(t)&&ha(e.toString)}function zu(e){if(Ga(e)){return"#"}var t=e.prototype&&e.prototype.constructor;if(ha(t)&&$a(t)){if(e[Ta]&&t.hasOwnProperty("__name__")){var r=t.__name__;if(so.isString(r)){r=r.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(d(n)==="symbol"){n=Ni(n)}if(typeof n==="string"){return"#")}}if(Vu(e,"toString")){return e.toString()}else if(e.name&&!$a(e)){return"#")}else{return"#"}}var $u=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(C(i)))}],[oo,function(e,t){var r=t.quote;if(r){return e.toString()}return e.valueOf()}],[so,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=Y(e,2),r=t[0],n=t[1];$u.set(r,n)});var Ju=[L,y,ra,Ho,So,Bo,Ko,Li];function Ku(e,t,c){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(Mu.has(e)){return Mu.get(e)}if(Gu(e)){return"#"}if(e){var r=e.constructor;if($u.has(r)){for(var n=arguments.length,f=new Array(n>3?n-3:0),i=3;i"}if(e===null){return"null"}if(d(e)==="object"){var a=e.constructor;if(!a){a=Object}var o;if(typeof a.__class__==="string"){o=a.__class__}else{var s=Uu(e);if(s){if(ha(s)){return s(e,t)}else{throw new Error("toString: Invalid repr value")}}o=a.name}if(ha(e.toString)&&$a(e.toString)){return e.toString().valueOf()}if(Ds(e)==="instance"){if($a(a)&&a.__name__){o=a.__name__.valueOf()}else if(!Ga(a)){o="instance"}}if(bs(e,Symbol.iterator)){if(o){return"#")}return"#"}if(bs(e,Symbol.asyncIterator)){if(o){return"#")}return"#"}if(o!==""){return"#<"+o+">"}return"#"}if(typeof e!=="string"){return e.toString()}return e}function Gu(e){return e&&d(e)==="object"&&e.hasOwnProperty&&e.hasOwnProperty("constructor")&&typeof e.constructor==="function"&&e.constructor.prototype===e}M.prototype.markCycles=function(){Hu(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[Ra]&&this[Ra][e])};function Hu(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[Ra]){e[Ra]={}}e[Ra][t]=r;if(!i.includes(e)){i.push(e)}return true}}}var s=Si(function e(t,r){if(t instanceof M){delete t.ref;delete t[Ra];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 Oi(function(){return e(t.cdr,r.slice())})}}});function r(e,t){if(e[Ra][t]instanceof M){var r=n.indexOf(e[Ra][t]);e[Ra][t]="#".concat(r,"#")}}s(e,[]);var n=t.filter(function(e){return u.includes(e)});n.forEach(function(e,t){e[Na]="#".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[Na]){i.push(this[Na]+"(")}else if(!n){i.push("(")}var u;if(this[Ra]&&this[Ra].car){u=this[Ra].car}else{u=Ku(this.car,e,true)}if(u!==undefined){i.push(u)}if(this.cdr instanceof M){if(this[Ra]&&this[Ra].cdr){i.push(" . ");i.push(this[Ra].cdr)}else{if(this.cdr[Na]){i.push(" . ")}else{i.push(" ")}var a=this.cdr.toString(e,{nested:true});i.push(a)}}else if(this.cdr!==U){i=i.concat([" . ",Ku(this.cdr,e,true)])}if(!n||this[Na]){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 Wu(e){return e<0?-e:e}function Qu(e,t){var r=A(t),n=r[0],i=r.slice(1);while(i.length>0){var u=i,a=Y(u,1),o=a[0];if(!e(n,o)){return false}var s=i;var c=A(s);n=c[0];i=c.slice(1)}return true}function Zu(e,t){if(ha(e)){return ha(t)&&xa(e)===xa(t)}else if(e instanceof y){if(!(t instanceof y)){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 Zu(y(e),y(t))}else if(e instanceof oo){if(!(t instanceof oo)){return false}return e.__char__===t.__char__}else{return e===t}}function Xu(e,t){if(Ds(e)!==Ds(t)){return false}if(!ea(e)){return false}if(e instanceof RegExp){return e.source===t.source}if(e instanceof so){return e.valueOf()===t.valueOf()}return Zu(e,t)}function ea(e){return e instanceof L||so.isString(e)||e===U||e===null||e instanceof oo||e instanceof y||e===true||e===false}var ta=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 ra(e,t,r,n){if(typeof this!=="undefined"&&this.constructor!==ra||typeof this==="undefined"){return new ra(e,t)}h("Macro",e,"string",1);h("Macro",t,"function",2);if(r){if(n){this.__doc__=r}else{this.__doc__=ou(r)}}this.__name__=e;this.__fn__=t}ra.defmacro=function(e,t,r,n){var i=new ra(e,t,r,n);i.__defmacro__=true;return i};ra.prototype.invoke=function(e,t,r){var n=t.env,i=R(t,_n);var u=kn(kn({},i),{},{macro_expand:r});var a=this.__fn__.call(n,e,u,this.__name__);return a};ra.prototype.toString=function(){return"#")};var na="define-macro";var ia=-1e4;function ua(c){return function(){var r=B(H.mark(function e(r,m){var u,g,n,i,s,D,E,A,x,F,k,b,a,w,o;return H.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:o=function e(){o=B(H.mark(function e(r,n,i){var h,u,a,p,o,_,s,d,c,v,f,l,y;return H.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[Pa]){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 aa?r:r.cdr;t.next=32;return u.invoke(_,kn(kn({},m),{},{env:i}),true);case 32:s=t.sent;if(!(u instanceof aa)){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")}return"#"};aa.className="syntax";var oa=function(e){_(r,e);var t=wn(r);function r(){j(this,r);return t.apply(this,arguments)}return P(r)}(aa);aa.Parameter=oa;function sa(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(Un()){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&&Ku(t,true),pattern:e&&Ku(e,true)});if(ea(e)&&!(e instanceof L)){return Xu(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===is}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=C(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 ca(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 fa(){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(d(e))}function j(e){if(!o(e)){var t=Ds(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=d(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 so(e)})))}}}if(a.includes(r)){return L(r)}return s(r)}function I(e){if(Un()){console.log(e)}}function s(e){if(!c[e]){var t=S.ref(e);var r=Ti(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=A(u),o=a[0],s=a.slice(1);if(c[o]){Va(r,"__object__",[c[o]].concat(C(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,C(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>> "+Ku(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=kn({},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=q({},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 ra&&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:Ku(i.car),cdr:Ku(i.cdr),head:Ku(D),rest:Ku(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 la(e){return ba(e)||e===U||e===null}function ha(e){return typeof e==="function"&&typeof e.bind==="function"}function pa(e){return e instanceof Ps}function _a(e){return e instanceof js}function da(e){return e instanceof Bs}function va(e){return e instanceof M}function ya(e){return e instanceof Ko}function ma(e){return ha(e)||pa(e)||da(e)}function ga(e){if(e instanceof Li){return false}if(e instanceof Promise){return true}return e&&ha(e.then)}function ba(e){return typeof e==="undefined"}function wa(e){switch(d(e)){case"string":return so(e);case"bigint":return y(e);case"number":if(Number.isNaN(e)){return rs}else{return y(e)}}return e}function Da(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 Ea(t){var e=[so,y].some(function(e){return t instanceof e});if(e){return t.valueOf()}if(t instanceof Array){return t.map(Ea)}if(t instanceof Li){delete t.then}if(Pu(t)){return Da(t,Ea)}return t}function Aa(e,t){if(e instanceof M){e.markCycles();return Wo(e)}if(ha(e)){if(t){return Fa(e,t)}}return wa(e)}function xa(e){if(Ca(e)){return e[Ia]}return e}function Fa(e,t){if(e[Symbol["for"]("__bound__")]){return e}var r=e.bind(t);var n=Object.getOwnPropertyNames(e);var i=En(n),u;try{for(i.s();!(u=i.n()).done;){var a=u.value;if(Ya(a)){try{r[a]=e[a]}catch(e){}}}}catch(e){i.e(e)}finally{i.f()}Va(r,"__fn__",e);Va(r,"__context__",t);Va(r,"__bound__",true);if(Ga(e)){Va(r,"__native__",true)}if(Pu(t)&&$a(e)){Va(r,"__method__",true)}r.valueOf=function(){return e};return r}function ka(e){return Ca(e)&&e[Symbol["for"]("__context__")]===Object}function Ca(e){return!!(ha(e)&&e[Ia])}function Oa(e){if(ha(e)){var t=e[ja];if(t&&(t===vc||t.constructor&&t.constructor.__class__)){return true}}return false}function Sa(e){return e instanceof So||e instanceof Bo}function Ba(e){if(ha(e)){if(Sa(e[ja])){return true}}return false}var ja=Symbol["for"]("__context__");var Ia=Symbol["for"]("__fn__");var Pa=Symbol["for"]("__data__");var Na=Symbol["for"]("__ref__");var Ra=Symbol["for"]("__cycles__");var Ta=Symbol["for"]("__class__");var La=Symbol["for"]("__method__");var Ua=Symbol["for"]("__prototype__");var Ma=Symbol["for"]("__lambda__");var qa=["name","length","caller","callee","arguments","prototype"];function Ya(e){return!qa.includes(e)}function Va(e,t,r){Object.defineProperty(e,Symbol["for"](t),{get:function e(){return r},set:function e(){},configurable:false,enumerable:false})}function za(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 $a(e){return e&&e[Ma]}function Ja(e){return e&&e[La]}function Ka(e){return $a(e)&&!e[Ua]&&!Ja(e)&&!Ba(e)}function Ga(e){var t=Symbol["for"]("__native__");return ha(e)&&e.toString().match(/\{\s*\[native code\]\s*\}/)&&(e.name.match(/^bound /)&&e[t]===true||!e.name.match(/^bound /)&&!e[t])}function Ha(e){var b;switch(e){case Symbol["for"]("letrec"):b="letrec";break;case Symbol["for"]("let"):b="let";break;case Symbol["for"]("let*"):b="let*";break;default:throw new Error("Invalid let_macro value")}return ra.defmacro(b,function(t,e){var f=e.dynamic_env;var l=e.error,n=e.macro_expand,y=e.use_dynamic;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=is.get("list->array")(t.car);var _=p.inherit(b);var d,v;if(b==="let*"){v=_}else if(b==="let"){d=[]}var m=0;function g(){var e=new M(new L("begin"),t.cdr);return Rs(e,{env:_,dynamic_env:_,use_dynamic:y,error:l})}return function t(){var r=h[m++];f=b==="let*"?_:p;if(!r){if(d&&d.length){var e=d.map(function(e){return e.value});var n=e.filter(ga);if(n.length){return Ui(e).then(function(e){for(var t=0,r=e.length;t1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=t.error;var i=this;var u=this;var a=[];var o=e;while(o instanceof M){a.push(Rs(o.car,{env:i,dynamic_env:u,use_dynamic:r,error:n}));o=o.cdr}var s=a.filter(ga).length;if(s){return Ui(a).then(c.bind(this))}else{return c.call(this,a)}})}function Qa(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 ao(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(oo.__names__[e]){t=e;e=oo.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{t=oo.__rev_names__[e]}Object.defineProperty(this,"__char__",{value:e,enumerable:true});if(t){Object.defineProperty(this,"__name__",{value:t,enumerable:true})}}oo.__names__=Wn;oo.__rev_names__={};Object.keys(oo.__names__).forEach(function(e){var t=oo.__names__[e];oo.__rev_names__[t]=e});oo.prototype.toUpperCase=function(){return oo(this.__char__.toUpperCase())};oo.prototype.toLowerCase=function(){return oo(this.__char__.toLowerCase())};oo.prototype.toString=function(){return"#\\"+(this.__name__||this.__char__)};oo.prototype.valueOf=oo.prototype.serialize=function(){return this.__char__};function so(e){if(typeof this!=="undefined"&&!(this instanceof so)||typeof this==="undefined"){return new so(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 co=["length","constructor"];var fo=Object.getOwnPropertyNames(String.prototype).filter(function(e){return!co.includes(e)});var lo=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 y){return e}if(typeof this!=="undefined"&&!(this instanceof y)||typeof this==="undefined"){return new y(e,t)}if(typeof e==="undefined"){throw new Error("Invalid LNumber constructor call")}var r=y.getType(e);if(y.types[r]){return y.types[r](e,t)}var n=e instanceof Array&&so.isString(e[0])&&y.isNumber(e[1]);if(e instanceof y){return y(e.value)}if(!y.isNumber(e)&&!n){throw new Error("You can't create LNumber from ".concat(Ds(e)))}if(e===null){e=0}var i;if(n){var c=e,u=Y(c,2),a=u[0],o=u[1];if(a instanceof so){a=a.valueOf()}if(o instanceof y){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 Eo(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=C(a).map(function(e,t){return BigInt(parseInt(e,o))*bo(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 Oo(i,true)}else if(typeof Rn!=="undefined"&&!(e instanceof Rn)){if(e instanceof Array){return Oo(p(Rn,C(e)))}return Oo(new Rn(e))}else if(n){this.constant(parseInt(a,o),"integer")}else{this.constant(e,"integer")}}y.prototype.constant=function(e,t){Object.defineProperty(this,"__value__",{value:e,enumerable:true});Object.defineProperty(this,"__type__",{value:t,enumerable:true})};y.types={float:function e(t){return new Eo(t)},complex:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!y.isComplex(t)){t={im:0,re:t}}return new Do(t,r)},rational:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!y.isRational(t)){t={num:t,denom:1}}return new Co(t,r)}};y.prototype.serialize=function(){return this.__value__};y.prototype.isNaN=function(){return Number.isNaN(this.__value__)};y.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}}};y.isFloat=function e(t){return t instanceof Eo||Number(t)===t&&t%1!==0};y.isNumber=function(e){return e instanceof y||y.isNative(e)||y.isBN(e)};y.isComplex=function(e){if(!e){return false}var t=e instanceof Do||(y.isNumber(e.im)||Number.isNaN(e.im))&&(y.isNumber(e.re)||Number.isNaN(e.re));return t};y.isRational=function(e){if(!e){return false}return e instanceof Co||y.isNumber(e.num)&&y.isNumber(e.denom)};y.isInteger=function(e){if(!(y.isNative(e)||e instanceof y)){return false}if(y.isFloat(e)){return false}if(y.isRational(e)){return false}if(y.isComplex(e)){return false}return true};y.isNative=function(e){return typeof e==="bigint"||typeof e==="number"};y.isBigInteger=function(e){return e instanceof Oo||typeof e==="bigint"||y.isBN(e)};y.isBN=function(e){return typeof Rn!=="undefined"&&e instanceof Rn};y.getArgsType=function(e,t){if(e instanceof Eo||t instanceof Eo){return Eo}if(e instanceof Oo||t instanceof Oo){return Oo}return y};y.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()};y.prototype.asType=function(e){var t=y.getType(this);return y.types[t]?y.types[t](e):y(e)};y.prototype.isBigNumber=function(){return typeof this.__value__==="bigint"||typeof Rn!=="undefined"&&!(this.value instanceof Rn)};["floor","ceil","round"].forEach(function(e){y.prototype[e]=function(){if(this["float"]||y.isFloat(this.__value__)){return y(Math[e](this.__value__))}else{return y(Math[e](this.valueOf()))}}});y.prototype.valueOf=function(){if(y.isNative(this.__value__)){return Number(this.__value__)}else if(y.isBN(this.__value__)){return this.__value__.toNumber()}};var vo=function(){var e=function e(t,r){return[t,r]};return{bigint:{bigint:e,float:function e(t,r){return[Eo(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[Eo(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&&Eo(r.valueOf())]},integer:function e(t,r){return[t,r&&Eo(r.valueOf())]},float:e,rational:function e(t,r){return[t,r&&Eo(r.valueOf())]},complex:function e(t,r){return[{re:t,im:Eo(0)},r]}},complex:{bigint:t("bigint"),integer:t("integer"),float:t("float"),rational:t("rational"),complex:function f(e,t){var r=y.coerce(e.__re__,t.__re__),n=Y(r,2),i=n[0],u=n[1];var a=y.coerce(e.__im__,t.__im__),o=Y(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[Eo(t.valueOf()),r]},rational:e,complex:function e(t,r){return[{im:yo(t.__type__,r.__im__.__type__,0)[0],re:yo(t.__type__,r.__re__.__type__,t)[0]},{im:yo(t.__type__,r.__im__.__type__,r.__im__)[0],re:yo(t.__type__,r.__re__.__type__,r.__re__)[0]}]}}};function t(r){return function(e,t){return[{im:yo(r,e.__im__.__type__,0,e.__im__)[1],re:yo(r,e.__re__.__type__,0,e.__re__)[1]},{im:yo(r,e.__im__.__type__,0,0)[1],re:yo(r,t.__type__,0,t)[1]}]}}}();function yo(e,t,r,n){return vo[e][t](r,n)}y.coerce=function(e,t){var r=y.getType(e);var n=y.getType(t);if(!vo[r]){throw new Error("LNumber::coerce unknown lhs type ".concat(r))}else if(!vo[r][n]){throw new Error("LNumber::coerce unknown rhs type ".concat(n))}var i=vo[r][n](e,t);return i.map(function(e){return y(e,true)})};y.prototype.coerce=function(e){if(!(typeof e==="number"||e instanceof y)){throw new Error("LNumber: you can't coerce ".concat(Ds(e)))}if(typeof e==="number"){e=y(e)}return y.coerce(this,e)};y.getType=function(e){if(e instanceof y){return e.__type__}if(y.isFloat(e)){return"float"}if(y.isComplex(e)){return"complex"}if(y.isRational(e)){return"rational"}if(typeof e==="number"){return"integer"}if(typeof BigInt!=="undefined"&&typeof e!=="bigint"||typeof Rn!=="undefined"&&!(e instanceof Rn)){return"bigint"}};y.prototype.isFloat=function(){return!!(y.isFloat(this.__value__)||this["float"])};var mo={add:"+",sub:"-",mul:"*",div:"/",rem:"%",or:"|",and:"&",neg:"~",shl:">>",shr:"<<"};var go={};Object.keys(mo).forEach(function(t){go[mo[t]]=t;y.prototype[t]=function(e){return this.op(mo[t],e)}});y._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 Do)||typeof this==="undefined"){return new Do(e,t)}if(e instanceof Do){return Do({im:e.__im__,re:e.__re__})}if(y.isNumber(e)&&t){if(!t){return Number(e)}}else if(!y.isComplex(e)){var r="Invalid constructor call for LComplex expect &(:im :re ) object but got ".concat(Ku(e));throw new Error(r)}var n=e.im instanceof y?e.im:y(e.im);var i=e.re instanceof y?e.re:y(e.re);this.constant(n,i)}Do.prototype=Object.create(y.prototype);Do.prototype.constructor=Do;Do.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})};Do.prototype.serialize=function(){return{re:this.__re__,im:this.__im__}};Do.prototype.toRational=function(e){if(y.isFloat(this.__im__)&&y.isFloat(this.__re__)){var t=Eo(this.__im__).toRational(e);var r=Eo(this.__re__).toRational(e);return Do({im:t,re:r})}return this};Do.prototype.pow=function(e){throw new Error("Not yet implemented")};Do.prototype.add=function(e){return this.complex_op("add",e,function(e,t,r,n){return{re:e.add(t),im:r.add(n)}})};Do.prototype.factor=function(){if(this.__im__ instanceof Eo||this.__im__ instanceof Eo){var e=this.__re__,t=this.__im__;var r,n;if(e instanceof Eo){r=e.toRational().mul(e.toRational())}else{r=e.mul(e)}if(t instanceof Eo){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__))}};Do.prototype.modulus=function(){return this.factor().sqrt()};Do.prototype.conjugate=function(){return Do({re:this.__re__,im:this.__im__.sub()})};Do.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=Eo(.5).mul(e.add(this.__re__)).sqrt();r=this.__im__.div(t).div(2)}else{r=Eo(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){r=r.sub()}t=this.__im__.div(r).div(2)}return Do({im:r,re:t})};Do.prototype.div=function(e){if(y.isNumber(e)&&!y.isComplex(e)){if(!(e instanceof y)){e=y(e)}var t=this.__re__.div(e);var r=this.__im__.div(e);return Do({re:t,im:r})}else if(!y.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}if(this.cmp(e)===0){var n=this.coerce(e),i=Y(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=Y(h,2),p=a[0],o=a[1];var s=o.factor();var _=o.conjugate();var c=p.mul(_);if(!y.isComplex(c)){return c.div(s)}var d=c.__re__.op("/",s);var v=c.__im__.op("/",s);return Do({re:d,im:v})};Do.prototype.sub=function(e){return this.complex_op("sub",e,function(e,t,r,n){return{re:e.sub(t),im:r.sub(n)}})};Do.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})};Do.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 Do(n,true)}return n};if(typeof t==="undefined"){return r()}if(y.isNumber(t)&&!y.isComplex(t)){if(!(t instanceof y)){t=y(t)}var n=t.asType(0);t={__im__:n,__re__:t}}else if(!y.isComplex(t)){throw new Error("[LComplex::".concat(e,"] Invalid value"))}var a=t.__re__ instanceof y?t.__re__:this.__re__.asType(t.__re__);var o=t.__im__ instanceof y?t.__im__:this.__im__.asType(t.__im__);return r(a,o)};Do._op={"+":"add","-":"sub","*":"mul","/":"div"};Do.prototype._op=function(e,t){var r=Do._op[e];return this[r](t)};Do.prototype.cmp=function(e){var t=this.coerce(e),r=Y(t,2),n=r[0],i=r[1];var u=n.__re__.coerce(i.__re__),a=Y(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=Y(l,2),h=c[0],p=c[1];return h.cmp(p)}};Do.prototype.valueOf=function(){return[this.__re__,this.__im__].map(function(e){return e.valueOf()})};Do.prototype.toString=function(){var e;if(this.__re__.cmp(0)!==0){e=[Ku(this.__re__)]}else{e=[]}var t=this.__im__.valueOf();var r=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(t);var n=Ku(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 Eo(e){if(typeof this!=="undefined"&&!(this instanceof Eo)||typeof this==="undefined"){return new Eo(e)}if(!y.isNumber(e)){throw new Error("Invalid constructor call for LFloat")}if(e instanceof y){return Eo(e.valueOf())}if(typeof e==="number"){if(Object.is(e,-0)){Object.defineProperty(this,"_minus",{value:true})}this.constant(e,"float")}}Eo.prototype=Object.create(y.prototype);Eo.prototype.constructor=Eo;Eo.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(!y.isFloat(this.__value__)&&!e.match(/e/i)){var t=e+".0";return this._minus?"-"+t:t}return e.replace(/^([0-9]+)e/,"$1.0e")};Eo.prototype._op=function(e,t){if(t instanceof y){t=t.__value__}var r=y._ops[e];if(e==="/"&&this.__value__===0&&t===0){return NaN}return Eo(r(this.__value__,t))};Eo.prototype.toRational=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){return Ao(this.__value__.valueOf())}return xo(e.valueOf())(this.__value__.valueOf())};Eo.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){var t=Eo(Math.sqrt(-e));return Do({re:0,im:t})}return Eo(Math.sqrt(e))};Eo.prototype.abs=function(){var e=this.valueOf();if(e<0){e=-e}return Eo(e)};var Ao=xo(1e-10);function xo(n){return function(e){var t=function e(n,t,r){var i=function e(t,r){return r0){i=ko(n,r)}else if(n.cmp(r)<=0){i=r}else if(r.cmp(0)>0){i=ko(r,n)}else if(t.cmp(0)<0){i=y(ko(n.sub(),r.sub())).sub()}else{i=y(0)}if(y.isFloat(t)||y.isFloat(e)){return Eo(i)}return i}function ko(e,t){var r=y(e).floor();var n=y(t).floor();if(e.cmp(r)<1){return r}else if(r.cmp(n)===0){var i=y(1).div(t.sub(n));var u=y(1).div(e.sub(r));return r.add(y(1).div(ko(i,u)))}else{return r.add(y(1))}}function Co(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof Co)||typeof this==="undefined"){return new Co(e,t)}if(!y.isRational(e)){throw new Error("Invalid constructor call for LRational")}var r,n;if(e instanceof Co){r=y(e.__num__);n=y(e.__denom__)}else{r=y(e.num);n=y(e.denom)}if(!t&&n.cmp(0)!==0){var i=r.op("%",n).cmp(0)===0;if(i){return y(r.div(n))}}this.constant(r,n)}Co.prototype=Object.create(y.prototype);Co.prototype.constructor=Co;Co.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})};Co.prototype.serialize=function(){return{num:this.__num__,denom:this.__denom__}};Co.prototype.pow=function(e){var t=e.cmp(0);if(t===0){return y(1)}if(t===-1){e=e.sub();var r=this.__denom__.pow(e);var n=this.__num__.pow(e);return Co({num:r,denom:n})}var i=this;e=e.valueOf();while(e>1){i=i.mul(this);e--}return i};Co.prototype.sqrt=function(){var e=this.__num__.sqrt();var t=this.__denom__.sqrt();if(e instanceof Eo||t instanceof Eo){return e.div(t)}return Co({num:e,denom:t})};Co.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 Co({num:e,denom:t})};Co.prototype.cmp=function(e){return y(this.valueOf(),true).cmp(e)};Co.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 Co){t=y(t.valueOf(true))}r=this.__denom__.div(e);if(r instanceof Co){r=y(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()};Co.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 y._ops["/"](this.__num__.value,this.__denom__.value)}return Eo(this.__num__.valueOf()).div(this.__denom__.valueOf())};Co.prototype.mul=function(e){if(!(e instanceof y)){e=y(e)}if(y.isRational(e)){var t=this.__num__.mul(e.__num__);var r=this.__denom__.mul(e.__denom__);return Co({num:t,denom:r})}var n=y.coerce(this,e),i=Y(n,2),u=i[0],a=i[1];return u.mul(a)};Co.prototype.div=function(e){if(!(e instanceof y)){e=y(e)}if(y.isRational(e)){var t=this.__num__.mul(e.__denom__);var r=this.__denom__.mul(e.__num__);return Co({num:t,denom:r})}var n=y.coerce(this,e),i=Y(n,2),u=i[0],a=i[1];var o=u.div(a);return o};Co.prototype._op=function(e,t){return this[go[e]](t)};Co.prototype.sub=function(e){if(typeof e==="undefined"){return this.mul(-1)}if(!(e instanceof y)){e=y(e)}if(y.isRational(e)){var t=e.__num__.sub();var r=e.__denom__;return this.add(Co({num:t,denom:r}))}if(!(e instanceof y)){e=y(e).sub()}else{e=e.sub()}var n=y.coerce(this,e),i=Y(n,2),u=i[0],a=i[1];return u.add(a)};Co.prototype.add=function(e){if(!(e instanceof y)){e=y(e)}if(y.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 Co({num:a,denom:u})}if(y.isFloat(e)){return Eo(this.valueOf()).add(e)}var o=y.coerce(this,e),s=Y(o,2),c=s[0],f=s[1];return c.add(f)};function Oo(e,t){if(typeof this!=="undefined"&&!(this instanceof Oo)||typeof this==="undefined"){return new Oo(e,t)}if(e instanceof Oo){return Oo(e.__value__,e._native)}if(!y.isBigInteger(e)){throw new Error("Invalid constructor call for LBigInteger")}this.constant(e,"bigint");Object.defineProperty(this,"_native",{value:t})}Oo.prototype=Object.create(y.prototype);Oo.prototype.constructor=Oo;Oo.bn_op={"+":"iadd","-":"isub","*":"imul","/":"idiv","%":"imod","|":"ior","&":"iand","~":"inot","<<":"ishrn",">>":"ishln"};Oo.prototype.serialize=function(){return this.__value__.toString()};Oo.prototype._op=function(e,t){if(typeof t==="undefined"){if(y.isBN(this.__value__)){e=Oo.bn_op[e];return Oo(this.__value__.clone()[e](),false)}return Oo(y._ops[e](this.__value__),true)}if(y.isBN(this.__value__)&&y.isBN(t.__value__)){e=Oo.bn_op[e];return Oo(this.__value__.clone()[e](t),false)}var r=y._ops[e](this.__value__,t.__value__);if(e==="/"){var n=this.op("%",t).cmp(0)===0;if(n){return y(r)}return Co({num:this,denom:t})}return Oo(r,true)};Oo.prototype.sqrt=function(){var e;var t=this.cmp(0)<0;if(y.isNative(this.__value__)){e=y(Math.sqrt(t?-this.valueOf():this.valueOf()))}else if(y.isBN(this.__value__)){e=t?this.__value__.neg().sqrt():this.__value__.sqrt()}if(t){return Do({re:0,im:e})}return e};y.NaN=y(NaN);function So(e){var n=this;if(typeof this!=="undefined"&&!(this instanceof So)||typeof this==="undefined"){return new So(e)}h("InputPort",e,"function");nu(this,"__type__",Yo);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(H.mark(function e(){var r;return H.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 Wi(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()!==Vo};this._make_defaults()}So.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(!y.isInteger(t)){var r=y.getType(t);_s("read-string",r,"integer")}return e.__lexer__.read_string(t.valueOf())});this.peek_char=this._with_parser(function(e){return e.__lexer__.peek_char()})};So.prototype._with_init_parser=function(o,s){var c=this;return B(H.mark(function e(){var r,n,i,u,a=arguments;return H.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 Bo(e){if(typeof this!=="undefined"&&!(this instanceof Bo)||typeof this==="undefined"){return new Bo(e)}h("OutputPort",e,"function");nu(this,"__type__",Yo);this.write=e}Bo.prototype.is_open=function(){return this._closed!==true};Bo.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")}};Bo.prototype.flush=function(){};Bo.prototype.toString=function(){return"#"};var jo=function(e){_(n,e);var r=wn(n);function n(e){var t;j(this,n);t=r.call(this,function(){var e;return(e=t)._write.apply(e,arguments)});h("BufferedOutputPort",e,"function");nu(o(t),"_fn",e,{hidden:true});nu(o(t),"_buffer",[],{hidden:true});return t}P(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"};Io.prototype.valueOf=function(){return this.__buffer__.map(function(e){return e.valueOf()}).join("")};function Po(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof Po)||typeof this==="undefined"){return new Po(e,t)}h("OutputFilePort",e,"string");nu(this,"__filename__",e);nu(this,"_fd",t.valueOf(),{hidden:true});nu(this,"__type__",Yo);this.write=function(e){if(!so.isString(e)){e=Ku(e)}else{e=e.valueOf()}r.fs().write(r._fd,e,function(e){if(e){throw e}})}}Po.prototype=Object.create(Bo.prototype);Po.prototype.constructor=Po;Po.prototype.fs=function(){if(!this._fs){this._fs=this.internal("fs")}return this._fs};Po.prototype.internal=function(e){return us.get("**internal-env**").get(e)};Po.prototype.close=function(){var n=this;return new Promise(function(t,r){n.fs().close(n._fd,function(e){if(e){r(e)}else{nu(n,"_fd",null,{hidden:true});Bo.prototype.close.call(n);t()}})})};Po.prototype.toString=function(){return"#")};function No(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof No)||typeof this==="undefined"){return new No(e)}h("InputStringPort",e,"string");t=t||is;e=e.valueOf();this._with_parser=this._with_init_parser.bind(this,function(){if(!r.__parser__){r.__parser__=new Wi(e,{env:t})}return r.__parser__});nu(this,"__type__",Yo);this._make_defaults()}No.prototype.char_ready=function(){return true};No.prototype=Object.create(So.prototype);No.prototype.constructor=No;No.prototype.toString=function(){return"#"};function Ro(e){if(typeof this!=="undefined"&&!(this instanceof Ro)||typeof this==="undefined"){return new Ro(e)}h("InputByteVectorPort",e,"uint8array");nu(this,"__vector__",e);nu(this,"__type__",qo);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 y){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}})}Ro.prototype=Object.create(So.prototype);Ro.prototype.constructor=Ro;Ro.prototype.toString=function(){return"#"};Ro.prototype.close=function(){var t=this;nu(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}};Ro.prototype.u8_ready=function(){return true};Ro.prototype.peek_u8=function(){if(this.__index__>=this.__vector__.length){return Vo}return this.__vector__[this.__index__]};Ro.prototype.skip=function(){if(this.__index__<=this.__vector__.length){++this.__index__}};Ro.prototype.read_u8=function(){var e=this.peek_u8();this.skip();return e};Ro.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()===Vo){return Vo}return this.__vector__.slice(this.__index__,e)};function To(){if(typeof this!=="undefined"&&!(this instanceof To)||typeof this==="undefined"){return new To}nu(this,"__type__",qo);nu(this,"_buffer",[],{hidden:true});this.write=function(e){h("write",e,["number","uint8array"]);if(y.isNumber(e)){this._buffer.push(e.valueOf())}else{var t;(t=this._buffer).push.apply(t,C(Array.from(e)))}};Object.defineProperty(this,"__buffer__",{enumerable:true,get:function e(){return Uint8Array.from(this._buffer)}})}To.prototype=Object.create(Bo.prototype);To.prototype.constructor=To;To.prototype.close=function(){Bo.prototype.close.call(this);nu(this,"_buffer",null,{hidden:true})};To.prototype._close_guard=function(){if(this._closed){throw new Error("output-port: binary port is closed")}};To.prototype.write_u8=function(e){h("OutputByteVectorPort::write_u8",e,"number");this.write(e)};To.prototype.write_u8_vector=function(e){h("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};To.prototype.toString=function(){return"#"};To.prototype.valueOf=function(){return this.__buffer__};function Lo(e,t){if(typeof this!=="undefined"&&!(this instanceof Lo)||typeof this==="undefined"){return new Lo(e,t)}No.call(this,e);h("InputFilePort",t,"string");nu(this,"__filename__",t)}Lo.prototype=Object.create(No.prototype);Lo.prototype.constructor=Lo;Lo.prototype.toString=function(){return"#")};function Uo(e,t){if(typeof this!=="undefined"&&!(this instanceof Uo)||typeof this==="undefined"){return new Uo(e,t)}Ro.call(this,e);h("InputBinaryFilePort",t,"string");nu(this,"__filename__",t)}Uo.prototype=Object.create(Ro.prototype);Uo.prototype.constructor=Uo;Uo.prototype.toString=function(){return"#")};function Mo(e,t){var i=this;if(typeof this!=="undefined"&&!(this instanceof Mo)||typeof this==="undefined"){return new Mo(e,t)}h("OutputBinaryFilePort",e,"string");nu(this,"__filename__",e);nu(this,"_fd",t.valueOf(),{hidden:true});nu(this,"__type__",qo);var u,r;this.write=function(e){h("write",e,["number","uint8array"]);var n;if(!u){u=i.internal("fs")}if(!r){r=i.internal("Buffer")}if(y.isNumber(e)){n=r.from([e.valueOf()])}else{n=r.from(Array.from(e))}return new Promise(function(t,r){u.write(i._fd,n,function(e){if(e){r(e)}else{t()}})})}}Mo.prototype=Object.create(Po.prototype);Mo.prototype.constructor=Mo;Mo.prototype.write_u8=function(e){h("OutputByteVectorPort::write_u8",e,"number");this.write(e)};Mo.prototype.write_u8_vector=function(e){h("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};var qo=Symbol["for"]("binary");var Yo=Symbol["for"]("text");var Vo=new zo;function zo(){}zo.prototype.toString=function(){return"#"};function $o(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=R(t,dn);if(typeof this!=="undefined"&&!(this instanceof $o)||typeof this==="undefined"){return new $o(e,kn({stdin:n,stdout:i,stderr:r,command_line:a},o))}if(typeof e==="undefined"){e="anonymous"}this.__env__=us.inherit(e,o);this.__env__.set("parent.frame",l("parent.frame",function(){return c.__env__},is.__env__["parent.frame"].__doc__));var f="**interaction-environment-defaults**";this.set(f,Yu(o).concat(f));var s=ts.inherit("internal-".concat(e));if(Sa(n)){s.set("stdin",n)}if(Sa(r)){s.set("stderr",r)}if(Sa(i)){s.set("stdout",i)}s.set("command-line",a);as(this.__env__,s)}$o.prototype.exec=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=t.use_dynamic,n=r===void 0?false:r,i=t.dynamic_env,u=t.env;h("Interpreter::exec",e,["string","array"],1);h("Interpreter::exec",n,"boolean",2);if(!u){u=this.__env__}if(!i){i=u}is.set("**interaction-environment**",this.__env__);return Ls(e,{env:u,dynamic_env:i,use_dynamic:n})};$o.prototype.get=function(e){var t=this.__env__.get(e);if(ha(t)){return t.bind(this.__env__)}return t};$o.prototype.set=function(e,t){return this.__env__.set(e,t)};$o.prototype.constant=function(e,t){return this.__env__.constant(e,t)};function Jo(e,t){this.name="LipsError";this.message=e;this.args=t;this.stack=(new Error).stack}Jo.prototype=new Error;Jo.prototype.constructor=Jo;function Ko(e,t,r){if(arguments.length===1){if(d(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"}Ko.prototype.list=function(){return Yu(this.__env__)};Ko.prototype.fs=function(){return this.get("**fs**")};Ko.prototype.unset=function(e){if(e instanceof L){e=e.valueOf()}if(e instanceof so){e=e.valueOf()}delete this.__env__[e]};Ko.prototype.inherit=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(d(e)==="object"){t=e}if(!e||d(e)==="object"){e="child of "+(this.__name__||"unknown")}return new Ko(t||{},this,e)};Ko.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 so){e=e.valueOf()}if(t){if(!r){t=ou(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)}};Ko.prototype.new_frame=function(e,t){var n=this.inherit("__frame__");n.set("parent.frame",l("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:1;e=e.valueOf();var t=n.__parent__;if(!ya(t)){return U}if(e<=0){return t}var r=t.get("parent.frame");return r(e-1)},is.__env__["parent.frame"].__doc__));t.callee=e;n.set("arguments",t);return n};Ko.prototype._lookup=function(e){if(e instanceof L){e=e.__name__}if(e instanceof so){e=e.valueOf()}if(this.__env__.hasOwnProperty(e)){return Go(this.__env__[e])}if(this.__parent__){return this.__parent__._lookup(e)}};Ko.prototype.toString=function(){return"#"};Ko.prototype.clone=function(){var t=this;var r={};Object.keys(this.__env__).forEach(function(e){r[e]=t.__env__[e]});return new Ko(r,this.__parent__,this.__name__)};Ko.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 Go(e){if(typeof this!=="undefined"&&!(this instanceof Go)||typeof this==="undefined"){return new Go(e)}this.value=e}Go.isUndefined=function(e){return e instanceof Go&&typeof e.value==="undefined"};Go.prototype.valueOf=function(){return this.value};function Ho(e){if(e.length){if(e.length===1){return e[0]}}if(typeof this!=="undefined"&&!(this instanceof Ho)||typeof this==="undefined"){return new Ho(e)}this.__values__=e}Ho.prototype.toString=function(){return this.__values__.map(function(e){return Ku(e)}).join("\n")};Ho.prototype.valueOf=function(){return this.__values__};Ko.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 so){n=n.valueOf()}var i=this._lookup(n);if(i instanceof Go){if(Go.isUndefined(i)){return undefined}return Aa(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=A(f),o=a[0],s=a.slice(1);i=this._lookup(o);if(s.length){try{if(i instanceof Go){i=i.valueOf()}else{i=Zo(Sn,o);if(ha(i)){i=xa(i)}}if(typeof i!=="undefined"){return Zo.apply(void 0,[i].concat(C(s)))}}catch(e){throw e}}else if(i instanceof Go){return Aa(i.valueOf())}i=Zo(Sn,n)}if(typeof i!=="undefined"){return i}if(c){throw new Error("Unbound variable `"+n.toString()+"'")}};Ko.prototype.set=function(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;h("Environment::set",e,["string","symbol"]);if(y.isNumber(t)){t=y(t)}if(e instanceof L){e=e.__name__}if(e instanceof so){e=e.valueOf()}this.__env__[e]=t;if(r){this.doc(e,r,true)}return this};Ko.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&&Pu(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};Ko.prototype.has=function(e){return this.__env__.hasOwnProperty(e)};Ko.prototype.ref=function(e){var t=this;while(true){if(!t){break}if(t.has(e)){return t}t=t.__parent__}};Ko.prototype.parents=function(){var e=this;var t=[];while(e){t.unshift(e);e=e.__parent__}return t};function Wo(e){if(ga(e)){return e.then(Wo)}if(e instanceof M||e instanceof L){e[Pa]=true}return e}var Qo=Zi(ji('(lambda ()\n "[native code]"\n (throw "Invalid Invocation"))'))[0];var Zo=l("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=Xo(this,"stdin")}vs("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":l("read-line",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=Xo(this,"stdin")}vs("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":l("read-char",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=Xo(this,"stdin")}vs("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:l("read",function(){var e=B(H.mark(function e(){var r,n,i,u,a,o,s,c,f,l=arguments;return H.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:r=l.length>0&&l[0]!==undefined?l[0]:null;n=this.env;if(!so.isString(r)){t.next=31;break}i=false;u=false;t.prev=5;o=Cn(Zi(r,n));case 7:t.next=9;return o.next();case 9:if(!(i=!(s=t.sent).done)){t.next=15;break}c=s.value;return t.abrupt("return",c);case 12:i=false;t.next=7;break;case 15:t.next=21;break;case 17:t.prev=17;t.t0=t["catch"](5);u=true;a=t.t0;case 21:t.prev=21;t.prev=22;if(!(i&&o["return"]!=null)){t.next=26;break}t.next=26;return o["return"]();case 26:t.prev=26;if(!u){t.next=29;break}throw a;case 29:return t.finish(26);case 30:return t.finish(21);case 31:if(r===null){f=Xo(n,"stdin")}else{f=r}vs("read",f,"input-port");return t.abrupt("return",f.read.call(n));case 34:case"end":return t.stop()}}},e,this,[[5,17,21,31],[22,,26,30]])}));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:l("pprint",function e(t){if(t instanceof M){t=new vc.Formatter(t.toString(true))["break"]().format();is.get("display").call(is,t)}else{is.get("write").call(is,t)}is.get("newline").call(is)},"(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:l("print",function e(){var t=is.get("display");var r=is.get("newline");var n=this.use_dynamic;var i=is;var u=is;for(var a=arguments.length,o=new Array(a),s=0;s1?r-1:0),i=1;in.length){throw new Error("Not enough arguments")}var o=0;var s=is.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:l("display",function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(r===null){r=Xo(this,"stdout")}else{h("display",r,"output-port")}var n=t;if(!(r instanceof Mo)){n=is.get("repr")(t)}r.write.call(is,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":l("display-error",function e(){var t=Xo(this,"stderr");var r=is.get("repr");for(var n=arguments.length,i=new Array(n),u=0;u1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,f=R(t,vn);var n=this;var i=this;var u;var l=kn(kn({},f),{},{env:this,dynamic_env:n,use_dynamic:r});var a=Rs(e.cdr.car,l);a=Es(a);function o(t,r,n){if(ga(t)){return t.then(function(e){return o(t,e,n)})}if(ga(r)){return r.then(function(e){return o(t,e,n)})}if(ga(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 h=e.car.cdr.car;var p=e.car.cdr.cdr.car;var _=Rs(h,{env:this,dynamic_env:n,use_dynamic:r,error:error});var d=Rs(p,{env:this,dynamic_env:n,use_dynamic:r,error:error});return o(_,d,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 eu(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!":l(new ra("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!":l("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!":l("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?":l("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:l("gensym",Ti,"(gensym)\n\n Generates a unique symbol that is not bound anywhere,\n to use with macros as meta name."),load:l("load",function e(o,t){h("load",o,"string");var s=this;if(s.__name__==="__frame__"){s=s.__parent__}if(!(t instanceof Ko)){if(s===is){t=s}else{t=this.get("**interaction-environment**")}}var c="**module-path**";var f=is.get(c,{throwError:false});o=o.valueOf();if(!o.match(/.[^.]+$/)){o+=".scm"}var r=o.match(/\.xcb$/);function l(e){if(r){e=lc(e)}else{if(Ds(e)==="buffer"){e=e.toString()}e=e.replace(/^#!.*/,"");if(e.match(/^\{/)){e=ic(e)}}return Ls(e,{env:t})}function n(e){return Sn.fetch(e).then(function(e){return r?e.arrayBuffer():e.text()}).then(function(e){if(r){e=new Uint8Array(e)}return e})}if(ls()){return new Promise(function(){var r=B(H.mark(function e(r,n){var i,u,a;return H.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:i=Nn("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:is.set(c,i.dirname(o));Nn("fs").readFile(o,function(e,t){if(e){n(e);is.set(c,f)}else{try{l(t).then(function(){r();is.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){is.set(c,o.replace(/\/[^/]*$/,""));return l(e)}).then(function(){})["finally"](function(){is.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:l(new ra("do",function(){var r=B(H.mark(function e(r,h){var p,n,i,u,o,s,a,c,f,l,_,d;return H.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:p=h.use_dynamic,n=h.error;i=this;u=i;o=i.inherit("do");s=r.car;a=r.cdr.car;c=r.cdr.cdr;if(c!==U){c=new M(L("begin"),c)}f={env:i,dynamic_env:u,use_dynamic:p,error:n};l=s;case 10:if(!(l!==U)){t.next=21;break}_=l.car;t.t0=o;t.t1=_.car;t.next=16;return Rs(_.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_env:u,error:n};d=H.mark(function e(){var r,n,i,u,a;return H.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!(c!==U)){t.next=3;break}t.next=3;return vc.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 Rs(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 Rs(a.car,f);case 25:t.t3=t.sent;if(!(t.t3===false)){t.next=30;break}return t.delegateYield(d(),"t4",28);case 28:t.next=23;break;case 30:if(!(a.cdr!==U)){t.next=34;break}t.next=33;return Rs(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:l(new ra("if",function(r,e){var t=e.error,n=e.use_dynamic;var i=this;var u=this;var a={env:u,dynamic_env:i,use_dynamic:n,error:t};var o=function e(t){if(t===false){return Rs(r.cdr.cdr.car,a)}else{return Rs(r.cdr.car,a)}};if(r===U){throw new Error("too few expressions for `if`")}var s=Rs(r.car,a);return eu(s,o)}),"(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 ra("let-env",function(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=e.dynamic_env,n=e.use_dynamic,i=e.error;h("let-env",t,"pair");var u=Rs(t.car,{env:this,dynamic_env:r,error:i,use_dynamic:n});return eu(u,function(e){h("let-env",e,"environment");return Rs(M(L("begin"),t.cdr),{env:e,dynamic_env:r,error:i})})},"(let-env env . body)\n\n Special macro that evaluates body in context of given environment\n object."),letrec:l(Ha(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*":l(Ha(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*":l(Ha(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:l(Ha(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*":l(Wa("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())."),shuffle:l(function(e){h("shuffle",e,["pair","nil","array"]);var t=is.get("random");if(e===U){return U}if(Array.isArray(e)){return Su(e.slice(),t)}var r=is.get("list->array")(e);r=Su(r,t);return is.get("array->list")(r)},"(shuffle obj)\n\n Order items in vector or list in random order."),begin:l(new ra("begin",function(e,t){var n=kn(kn({},t),{},{env:this});var i=is.get("list->array")(e);var u;return function t(){if(i.length){var e=i.shift();var r=Rs(e,n);return eu(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 ra("ignore",function(e,t){var r=kn(kn({},t),{},{env:this,dynamic_env:this});Rs(new M(new L("begin"),e),r)},"(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":l(ra.defmacro("call/cc",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=kn({env:this},t);return eu(Rs(e.car,r),function(e){if(ha(e)){return e(new Ps(null))}})}),"(call/cc proc)\n\n Call-with-current-continuation.\n\n NOT SUPPORTED BY LIPS RIGHT NOW"),parameterize:l(new ra("parameterize",function(t,e){var i=e.dynamic_env;var u=i.inherit("parameterize").new_frame(null,{});var a=kn(kn({},e),{},{env:this});var o=t.car;if(!va(o)){var r=Ds(o);throw new Error("Invalid syntax for parameterize expecting pair got ".concat(r))}function s(){var e=new M(new L("begin"),t.cdr);return Rs(e,kn(kn({},a),{},{dynamic_env:u}))}return function r(){var e=o.car;var n=e.car.valueOf();return eu(Rs(e.cdr.car,a),function(e){var t=i.get(n,{throwError:false});if(!da(t)){throw new Error("Unknown parameter ".concat(n))}u.set(n,t.inherit(e));if(!la(o.cdr)){o=o.cdr;return r()}else{return s()}})}()}),"(parameterize ((name value) ...)\n\n Macro that change the dynamic variable created by make-parameter."),"make-parameter":l(new ra("make-parameter",function(e,t){t.dynamic_env;var r=Rs(e.car,t);var n;if(e.cdr.car instanceof M){n=Rs(e.cdr.car,t)}return new Bs(r,n)}),"(make-parameter init converter)\n\n Function creates new dynamic variable that can be custimized with parameterize\n macro. The value should be assigned to a variable e.g.:\n\n (define radix (make-parameter 10))\n\n The result value is a procedure that return the value of dynamic variable."),define:l(ra.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}e.dynamic_env=this;e.env=n;var i=r.cdr.car;var u;if(i instanceof M){i=Rs(i,e);u=true}else if(i instanceof L){i=n.get(i)}h("define",r.car,"symbol");return eu(i,function(e){if(n.__name__===aa.__merge_env__){n=n.__parent__}if(u&&(ha(e)&&$a(e)||e instanceof aa||da(e))){e.__name__=r.car.valueOf();if(e.__name__ instanceof so){e.__name__=e.__name__.valueOf()}}var t;if(r.cdr.cdr instanceof M&&so.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!":l("set-obj!",function(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var i=d(e);if(la(e)||i!=="object"&&i!=="function"){var u=_s("set-obj!",Ds(e),["object","function"]);throw new Error(u)}h("set-obj!",t,["string","symbol","number"]);e=xa(e);t=t.valueOf();if(arguments.length===2){delete e[t]}else if(Gu(e)&&ha(r)){e[t]=xa(r);e[t][Ua]=true}else if(ha(r)||ms(r)||r===U){e[t]=r}else{e[t]=r&&!Gu(r)?r.valueOf():r}if(Nu){var a=e[t];Object.defineProperty(e,t,kn(kn({},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":l("null-environment",function(){return is.inherit("null")},"(null-environment)\n\n Returns a clean environment with only the standard library."),values:l("values",function e(){for(var t=arguments.length,r=new Array(t),n=0;n1&&arguments[1]!==undefined?arguments[1]:{},v=e.use_dynamic,y=e.error;var m=this;var g;if(d.cdr instanceof M&&so.isString(d.cdr.car)&&d.cdr.cdr!==U){g=d.cdr.car.valueOf()}function b(){var c=_a(this)?this:{dynamic_env:m},r=c.dynamic_env;var n=m.inherit("lambda");r=r.inherit("lambda");if(this&&!_a(this)){if(this&&!this.__instance__){Object.defineProperty(this,"__instance__",{enumerable:false,get:function e(){return true},set:function e(){},configurable:false})}n.set("this",this)}for(var e=arguments.length,t=new Array(e),i=0;i>> "+c.toString());if(c){o=c}var v=r.merge(t,aa.__merge_env__);if(l){return{expr:o,scope:v}}var y=Rs(o,kn(kn({},_),{},{env:v}));return ca(y,d)}i=i.cdr}}catch(e){e.message+=" in macro: ".concat(m.toString(true));throw e}throw new Error("Invalid Syntax ".concat(e.toString(true)))},w);r.__code__=m;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:l(new ra("quote",function(e){return Wo(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":l("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:l("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:ra.defmacro("quasiquote",function(e,t){var o=t.use_dynamic,s=t.error;var c=this;var f=c;function a(e){return e instanceof M||Pu(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(ga(n)||ga(i)){return Ui([n,i]).then(function(e){var t=Y(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(v.has(e)){return e.clone()}else{v.add(e);return e}});var n=l(i.cdr,0,1);if(n===U&&r[0]===U){return undefined}return eu(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 v=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 d(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"),d(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 eu(Rs(r.car,{env:c,dynamic_env:f,use_dynamic: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 eu(Rs(r.car,{env:c,dynamic_env:f,use_dynamic:o,error:s}),function(e){a.push(e);return t(r.cdr)})}(e.cdr)}else{return e.cdr}}else{return Rs(e.cdr.car,{env:c,dynamic_env:f,error:s})}}else{return e.cdr}}return h(e,function(e){return l(e,t,r)})}else if(Pu(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[Pa];if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}}if(Pu(e.car)&&!r(Object.values(e.car))){return Wo(e.car)}if(Array.isArray(e.car)&&!r(e.car)){return Wo(e.car)}if(e.car instanceof M&&!e.car.find("unquote")&&!e.car.find("unquote-splicing")&&!e.car.find("quasiquote")){return Wo(e.car)}var i=l(e.car,0,1);return eu(i,function(e){n(e);return Wo(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:l("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:l("append",function e(){var t;for(var r=arguments.length,n=new Array(r),i=0;iarray")(t).reverse();return is.get("array->list")(r)}else if(Array.isArray(t)){return t.reverse()}else{throw new Error(_s("reverse",Ds(t),"array or pair"))}},"(reverse list)\n\n Function that reverses the list or array. If value is not a list\n or array it will error."),nth:l("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:l("split",function e(t,r){h("split",t,["regex","string"]);h("split",r,"string");return is.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:l("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:l("match",function e(t,r){h("match",t,["regex","string"]);h("match",r,"string");var n=r.match(t);return n?is.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:l("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:l("repr",function e(t,r){return Ku(t,r)},"(repr obj)\n\n Function that returns a LIPS code representation of the object as a string."),"escape-regex":l("escape-regex",function(e){h("escape-regex",e,"string");return xi(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:l("env",function e(e){e=e||this.env;var t=Object.keys(e.__env__).map(L);var r;if(t.length){r=M.fromArray(t)}else{r=U}if(e.__parent__ instanceof Ko){return is.get("env").call(this,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:l("new",function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n2&&arguments[2]!==undefined?arguments[2]:Yi.LITERAL;h("set-special!",e,"string",1);h("set-special!",t,"symbol",2);Yi.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:Zo,".":Zo,unbind:l(xa,"(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:l(Ds,"(type object)\n\n Function that returns the type of an object as string."),debugger:l("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:l("in",function(e,t){if(e instanceof L||e instanceof so||e instanceof y){e=e.valueOf()}return e in Ea(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:l("instanceof",function(e,t){return t instanceof xa(e)},"(instanceof type obj)\n\n Predicate that tests if the obj is an instance of type."),"prototype?":l("prototype?",Gu,"(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?":l("macro?",function(e){return e instanceof ra},"(macro? expression)\n\n Predicate that tests if value is a macro."),"function?":l("function?",ha,"(function? expression)\n\n Predicate that tests if value is a callable function."),"real?":l("real?",function(e){if(Ds(e)!=="number"){return false}if(e instanceof y){return e.isFloat()}return y.isFloat(e)},"(real? number)\n\n Predicate that tests if value is a real number (not complex)."),"number?":l("number?",function(e){return Number.isNaN(e)||y.isNumber(e)},"(number? expression)\n\n Predicate that tests if value is a number or NaN value."),"string?":l("string?",function(e){return so.isString(e)},"(string? expression)\n\n Predicate that tests if value is a string."),"pair?":l("pair?",function(e){return e instanceof M},"(pair? expression)\n\n Predicate that tests if value is a pair or list structure."),"regex?":l("regex?",function(e){return e instanceof RegExp},"(regex? expression)\n\n Predicate that tests if value is a regular expression."),"null?":l("null?",function(e){return la(e)},"(null? expression)\n\n Predicate that tests if value is null-ish (i.e. undefined, nil, or\n Javascript null)."),"boolean?":l("boolean?",function(e){return typeof e==="boolean"},"(boolean? expression)\n\n Predicate that tests if value is a boolean (#t or #f)."),"symbol?":l("symbol?",function(e){return e instanceof L},"(symbol? expression)\n\n Predicate that tests if value is a LIPS symbol."),"array?":l("array?",function(e){return e instanceof Array},"(array? expression)\n\n Predicate that tests if value is an array."),"object?":l("object?",function(e){return e!==U&&e!==null&&!(e instanceof oo)&&!(e instanceof RegExp)&&!(e instanceof so)&&!(e instanceof M)&&!(e instanceof y)&&d(e)==="object"&&!(e instanceof Array)},"(object? expression)\n\n Predicate that tests if value is an plain object (not another LIPS type)."),flatten:l("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":l("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":l("tree->array",ju("tree->array",true),"(tree->array list)\n\n Function that converts a LIPS cons tree structure into a JavaScript array."),"list->array":l("list->array",ju("list->array"),"(list->array list)\n\n Function that converts a LIPS list into a JavaScript array."),apply:l("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,ks(t,n))},"(apply fn list)\n\n Function that calls fn with the list of arguments."),length:l("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":l("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(oi)||e.match(ii)){return hi(e,t)}else if(e.match(si)||e.match(ni)){return di(e,t)}else{var r=t===10&&!e.match(/e/i)||t===16;if(e.match(ai)&&r||e.match(ui)){return pi(e,t)}if(e.match(Kn)){return mi(e)}}return false},"(string->number number [radix])\n\n Function that parses a string into a number."),try:l(new ra("try",function(t,e){var c=this;var r=e.use_dynamic,f=e.error;return new Promise(function(n,i){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=n;if(a){o=function e(t,r){o=i;eu(Rs(new M(new L("begin"),a.cdr),s),function(){r(t)})}}var s={env:c,use_dynamic:r,dynamic_env:c,error:function(t){function e(e){return t.apply(this,arguments)}e.toString=function(){return t.toString()};return e}(function(e){var t=c.inherit("try");if(u){t.set(u.cdr.car.car,e);var r={env:t,error:f};r.dynamic_env=c;eu(Rs(new M(new L("begin"),u.cdr.cdr),r),function(e){o(e,n)})}else{o(e,f)}})};var e=Rs(t.car,s);if(ga(e)){e.then(function(e){o(e,n)})["catch"](s.error)}else{o(e,n)}})}),"(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:l("raise",function(e){throw e},"(raise obj)\n\n Throws the object verbatim (no wrapping an a new Error)."),throw:l("throw",function(e){throw new Error(e)},"(throw string)\n\n Throws a new exception."),find:l("find",function t(r,n){h("find",r,["regex","function"]);h("find",n,["pair","nil"]);if(la(n)){return U}var e=au("find",r);return eu(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":l("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=au("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 eu(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:l(Xa,"(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:l(Za,"(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:l(uo,"(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:l("gcd",function e(){for(var t=arguments.length,r=new Array(t),n=0;no?u%=o:o%=u}u=Wu(s*r[a])/(u+o)}return y(u)},"(lcm n1 n2 ...)\n\n Function that returns the least common multiple of the arguments."),"odd?":l("odd?",ro(function(e){return y(e).isOdd()}),"(odd? number)\n\n Checks if number is odd."),"even?":l("even?",ro(function(e){return y(e).isEven()}),"(even? number)\n\n Checks if number is even."),"*":l("*",io(function(e,t){return y(e).mul(t)},y(1)),"(* . numbers)\n\n Multiplies all numbers passed as arguments. If single value is passed\n it will return that value."),"+":l("+",io(function(e,t){return y(e).add(t)},y(0)),"(+ . numbers)\n\n Sums all numbers passed as arguments. If single value is passed it will\n return that value."),"-":l("-",function(){for(var e=arguments.length,t=new Array(e),r=0;r":l(">",function(){for(var e=arguments.length,t=new Array(e),r=0;r",t,"number");return Qu(function(e,t){return y(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."),"<":l("<",function(){for(var e=arguments.length,t=new Array(e),r=0;r=":l(">=",function(){for(var e=arguments.length,t=new Array(e),r=0;r=",t,"number");return Qu(function(e,t){return[0,1].includes(y(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?":l("eq?",Zu,"(eq? a b)\n\n Function that compares two values if they are identical."),or:l(new ra("or",function(e,t){var i=t.use_dynamic,u=t.error;var a=is.get("list->array")(e);var o=this;var s=o;if(!a.length){return false}var c;return function t(){function e(e){c=e;if(c!==false){return c}else{return t()}}if(!a.length){if(c!==false){return c}else{return false}}else{var r=a.shift();var n=Rs(r,{env:o,dynamic_env:s,use_dynamic:i,error:u});return eu(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:l(new ra("and",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=t.error;var i=is.get("list->array")(e);var u=this;var a=u;if(!i.length){return true}var o;var s={env:u,dynamic_env:a,use_dynamic:r,error:n};return function t(){function e(e){o=e;if(o===false){return false}else{return t()}}if(!i.length){if(o!==false){return o}else{return false}}else{var r=i.shift();return eu(Rs(r,s),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."),"|":l("|",function(e,t){return y(e).or(t)},"(| a b)\n\n Function that calculates the bitwise or operation."),"&":l("&",function(e,t){return y(e).and(t)},"(& a b)\n\n Function that calculates the bitwise and operation."),"~":l("~",function(e){return y(e).neg()},"(~ number)\n\n Function that calculates the bitwise inverse (flip all the bits)."),">>":l(">>",function(e,t){return y(e).shr(t)},"(>> a b)\n\n Function that right shifts the value a by value b bits."),"<<":l("<<",function(e,t){return y(e).shl(t)},"(<< a b)\n\n Function that left shifts the value a by value b bits."),not:l("not",function e(t){if(la(t)){return true}return!t},"(not object)\n\n Function that returns the Boolean negation of its argument.")},undefined,"global");var us=is.inherit("user-env");function as(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.");is.set("**interaction-environment**",e)}as(us,ts);is.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;is.set(r,l(r,function(e){h(r,e,"number");if(e instanceof y){return e[t]()}},"(".concat(r," number)\n\n Function that calculates the ").concat(r," of a number.")))})})();function os(e){if(e.length===1){return e[0]}else{var t=[];var r=os(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(ha(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 ds(r,e,n){e.forEach(function(e,t){h(r,e,n,t+1)})}function vs(e,t,r){h(e,t,r);if(t.__type__===qo){throw new Error(_s(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=Ds(t).toLowerCase();if(ha(r)){if(!r(t)){throw new Error(_s(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(_s(e,i,r,n))}}function ys(e){var t=d(e);return["string","function"].includes(t)||d(e)==="symbol"||e instanceof Li||e instanceof L||e instanceof y||e instanceof so||e instanceof RegExp}function ms(e){return e instanceof y||e instanceof so||e instanceof oo}function gs(e,t){if(e===null){return false}return d(e)==="object"&&t in Object.getOwnPropertySymbols(e)}function bs(e,t){if(gs(e,t)||gs(e.__proto__,t)){return ha(e[t])}}function ws(r){var n=new WeakMap;return function(e){var t=n.get(e);if(!t){t=r(e)}return t}}Ds=ws(Ds);function Ds(e){var t=jn.get(e);if(t){return t}if(d(e)==="object"){for(var r=0,n=Object.entries(Bn);r2&&arguments[2]!==undefined?arguments[2]:{},n=r.env,i=r.dynamic_env,u=r.use_dynamic;var a=n===null||n===void 0?void 0:n.new_frame(e,t);var o=i===null||i===void 0?void 0:i.new_frame(e,t);var s=new js({env:a,use_dynamic:u,dynamic_env:o});return Es(e.apply(s,t))}function Os(n,e){var t=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},i=t.env,u=t.dynamic_env,a=t.use_dynamic,r=t.error,o=r===void 0?function(){}:r;e=As(e,{env:i,dynamic_env:u,error:o,use_dynamic:a});return eu(e,function(e){if(Ka(n)){n=xa(n)}e=ks(n,e);var t=e.slice();var r=Cs(n,t,{env:i,dynamic_env:u,use_dynamic:a});return eu(r,function(e){if(e instanceof M){e.markCycles();return Wo(e)}return wa(e)},o)})}var Ss=new WeakMap;var Bs=function(){function n(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;j(this,n);q(this,"__value__",void 0);q(this,"__fn__",void 0);gn(this,Ss,{writable:true,value:void 0});this.__value__=e;if(t){if(!ha(t)){throw new Error("Section argument to Parameter need to be function "+"".concat(Ds(t)," given"))}this.__fn__=t}if(r){a(this,Ss,r)}}P(n,[{key:"__name__",get:function e(){return t(this,Ss)},set:function e(t){a(this,Ss,t);if(this.__fn__){this.__fn__.__name__="fn-".concat(t)}}},{key:"invoke",value:function e(){if(ha(this.__fn__)){return this.__fn__(this.__value__)}return this.__value__}},{key:"inherit",value:function e(t){return new n(t,this.__fn__,this.__name__)}}]);return n}();var js=function(){function t(e){j(this,t);q(this,"env",void 0);q(this,"dynamic_env",void 0);q(this,"use_dynamic",void 0);Object.assign(this,e)}P(t,[{key:"__name__",get:function e(){return this.env.__name__}},{key:"__parent__",get:function e(){return this.env.__parent__}},{key:"get",value:function e(){var t;return(t=this.env).get.apply(t,arguments)}}]);return t}();function Is(e,t){var r=e.get(t.__name__,{throwError:false});if(da(r)&&r!==t){return r}var n=us.get("**interaction-environment**");while(true){var i=e.get("parent.frame",{throwError:false});e=i(0);if(e===n){break}r=e.get(t.__name__,{throwError:false});if(da(r)&&r!==t){return r}}return t}var Ps=function(){function t(e){j(this,t);q(this,"__value__",void 0);this.__value__=e}P(t,[{key:"invoke",value:function e(){if(this.__value__===null){throw new Error("Continuations are not implemented yet")}}}]);return t}();var Ns=function e(){};function Rs(o){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},s=e.env,c=e.dynamic_env,f=e.use_dynamic,t=e.error,l=t===void 0?Ns:t,r=R(e,mn);return function(e){try{if(!ya(c)){c=s===true?us:s||us}if(f){s=c}else if(s===true){s=us}else{s=s||is}var t={env:s,dynamic_env:c,use_dynamic:f,error:l};var r;if(la(o)){return o}if(o instanceof L){return s.get(o)}if(!(o instanceof M)){return o}var n=o.car;var e=o.cdr;if(n instanceof M){r=Es(Rs(n,t));if(ga(r)){return r.then(function(e){if(!ma(e)){throw new Error(Ds(e)+" "+s.get("repr")(e)+" is not callable while evaluating "+o.toString())}return Rs(new M(e,o.cdr),t)})}else if(!ma(r)){throw new Error(Ds(r)+" "+s.get("repr")(r)+" is not callable while evaluating "+o.toString())}}if(n instanceof L){r=s.get(n)}else if(ha(n)){r=n}var i;if(r instanceof aa){i=xs(r,o,t)}else if(r instanceof ra){i=Fs(r,e,t)}else if(ha(r)){i=Os(r,e,t)}else if(da(r)){var u=Is(c,r);if(la(o.cdr)){i=u.invoke()}else{return eu(Rs(o.cdr.car,t),function(e){u.__value__=e})}}else if(pa(r)){i=r.invoke()}else if(o instanceof M){r=n&&n.toString();throw new Error("".concat(Ds(n)," ").concat(r," is not a function"))}else{return o}var a=s.get(Symbol["for"]("__promise__"),{throwError:false});if(a===true&&ga(i)){i=i.then(function(e){if(e instanceof M&&!r[Pa]){return Rs(e,t)}return e});return new Li(i)}return i}catch(e){l&&l.call(s,e,o)}}(r)}var Ts=Us(function(e){return e});var Ls=Us(function(e,t){return t});function Us(y){return function(){var t=B(H.mark(function e(r){var n,i,u,h,a,p,o,s,_,c,d,f,v,l=arguments;return H.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:n=l.length>1&&l[1]!==undefined?l[1]:{},i=n.env,u=n.dynamic_env,h=n.use_dynamic;if(!ya(u)){u=i===true?us:i||us}if(i===true){i=us}else{i=i||us}a=[];p=Array.isArray(r)?r:Zi(r);o=false;s=false;t.prev=7;c=Cn(p);case 9:t.next=11;return c.next();case 11:if(!(o=!(d=t.sent).done)){t.next=25;break}f=d.value;v=Rs(f,{env:i,dynamic_env:u,use_dynamic:h,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}});t.t0=a;t.t1=y;t.t2=f;t.next=19;return v;case 19:t.t3=t.sent;t.t4=(0,t.t1)(t.t2,t.t3);t.t0.push.call(t.t0,t.t4);case 22:o=false;t.next=9;break;case 25:t.next=31;break;case 27:t.prev=27;t.t5=t["catch"](7);s=true;_=t.t5;case 31:t.prev=31;t.prev=32;if(!(o&&c["return"]!=null)){t.next=36;break}t.next=36;return c["return"]();case 36:t.prev=36;if(!s){t.next=39;break}throw _;case 39:return t.finish(36);case 40:return t.finish(31);case 41:return t.abrupt("return",a);case 42:case"end":return t.stop()}}},e,null,[[7,27,31,41],[32,,36,40]])}));function e(e){return t.apply(this,arguments)}return e}()}function Ms(e){var t={"[":"]","(":")"};var r;if(typeof e==="string"){r=ji(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 Fi;var a=En(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 qs(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 Sn.Worker(r.createObjectURL(n))}function Ys(){return vc.version.match(/^(\{\{VER\}\}|DEV)$/)}function Vs(){if(ls()){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 zs=Vs();function $s(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";var t="dist/std.xcb";if(e===""){if(zs){e=zs.replace(/[^/]*$/,"std.xcb")}else if(Ys()){e="https://cdn.jsdelivr.net/gh/jcubic/lips@devel/".concat(t)}else{e="https://cdn.jsdelivr.net/npm/@jcubic/lips@".concat(vc.version,"/").concat(t)}}var r=is.get("load");return r.call(us,e,is)}function Js(e){this.url=e;var a=this.worker=qs(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,{use_dynamic: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 vc.Interpreter("worker");o=$s(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,t){var r=t.use_dynamic,n=r===void 0?false:r;return this.rpc("eval",[e,n])}}var Ks={pair:function e(t){var r=Y(t,2),n=r[0],i=r[1];return M(n,i)},number:function e(t){if(so.isString(t)){return y([t,10])}return y(t)},regex:function e(t){var r=Y(t,2),n=r[0],i=r[1];return new RegExp(n,i)},nil:function e(){return U},symbol:function e(t){if(so.isString(t)){return L(t)}else if(Array.isArray(t)){return L(Symbol["for"](t[0]))}},string:so,character:oo};var Gs=Object.keys(Ks);var Hs={};for(var Ws=0,Qs=Object.entries(Gs);Ws1){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 oc(){var e=1;var t=new TextEncoder("utf-8");return t.encode("LIPS".concat(e.toString().padStart(3," ")))}var sc=7;function cc(e){var t=new TextDecoder("utf-8");var r=t.decode(e.slice(0,sc));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 fc(e){var t=oc();var r=uc.encode(e);return ac(t,fn(r,{magic:false}))}function lc(e){var t=cc(e),r=t.type,n=t.version;if(r==="LIPS"&&n===1){var i=ln(e.slice(sc),{magic:false});return uc.decode(i)}else{throw new Error("Invalid file format ".concat(r))}}function hc(e){console.error(e.message||e);if(e.code){console.error(e.code.map(function(e,t){return"[".concat(t+1,"]: ").concat(e)}))}}function pc(){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(Ls).then(t)["catch"](function(e){hc(e);t()})}else{return Ls(r.innerHTML).then(t)["catch"](function(e){hc(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 $s(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(_c){var t=_c;var r=t.getAttribute("bootstrap");if(typeof r==="string"){return $s(r).then(function(){o=true;return e()})}}return e()}var _c=typeof window!=="undefined"&&window.document&&document.currentScript;if(typeof window!=="undefined"){Tn(window,pc)}var dc=function(){var e=so("Mon, 15 Jan 2024 12:39:38 +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 DEV (".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}();nu(hu,"__class__","ahead");nu(M,"__class__","pair");nu(Bu,"__class__","nil");nu(pu,"__class__","pattern");nu(lu,"__class__","formatter");nu(ra,"__class__","macro");nu(aa,"__class__","syntax");nu(Ko,"__class__","environment");nu(So,"__class__","input-port");nu(Bo,"__class__","output-port");nu(jo,"__class__","output-port");nu(Io,"__class__","output-string-port");nu(No,"__class__","input-string-port");nu(Lo,"__class__","input-file-port");nu(Po,"__class__","output-file-port");nu(Jo,"__class__","lips-error");[y,Do,Co,Eo,Oo].forEach(function(e){nu(e,"__class__","number")});nu(oo,"__class__","character");nu(L,"__class__","symbol");nu(so,"__class__","string");nu(Li,"__class__","promise");nu(Bs,"__class__","parameter");var vc={version:"DEV",banner:dc,date:"Mon, 15 Jan 2024 12:39:38 +0000",exec:Ls,parse:Xa(iu,Zi),tokenize:ji,evaluate:Rs,compile:Ts,serialize:nc,unserialize:ic,serialize_bin:fc,unserialize_bin:lc,bootstrap:$s,Environment:Ko,env:us,Worker:Js,Interpreter:$o,balanced_parenthesis:Ms,balancedParenthesis:Ms,balanced:Ms,Macro:ra,Syntax:aa,Pair:M,Values:Ho,QuotedPromise:Li,Error:Jo,quote:Wo,InputPort:So,OutputPort:Bo,BufferedOutputPort:jo,InputFilePort:Lo,OutputFilePort:Po,InputStringPort:No,OutputStringPort:Io,InputByteVectorPort:Ro,OutputByteVectorPort:To,InputBinaryFilePort:Uo,OutputBinaryFilePort:Mo,Formatter:lu,Parser:Wi,Lexer:s,specials:Yi,repr:Iu,nil:U,eof:Vo,LSymbol:L,LNumber:y,LFloat:Eo,LComplex:Do,LRational:Co,LBigInteger:Oo,LCharacter:oo,LString:so,Parameter:Bs,rationalize:Fo};is.set("lips",vc);var yc={};var mc=Object.freeze({__proto__:null,default:yc});function gc(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 bc=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var wc=function(e){return bc.exec(e).slice(1)};function Dc(){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=gc(Ic(e.split("/"),function(e){return!!e}),!t).join("/");return(t?"/":"")+e||"."}function Ec(e){var t=Ac(e),r=Pc(e,-1)==="/";e=gc(Ic(e.split("/"),function(e){return!!e}),!t).join("/");if(!e&&!t){e="."}if(e&&r){e+="/"}return(t?"/":"")+e}function Ac(e){return e.charAt(0)==="/"}function xc(){var e=Array.prototype.slice.call(arguments,0);return Ec(Ic(e,function(e,t){if(typeof e!=="string"){throw new TypeError("Arguments to path.join must be strings")}return e}).join("/"))}function Fc(e,t){e=Dc(e).substr(1);t=Dc(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 xn(e,t){if(!e)return;if(typeof e==="string")return Fn(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 Fn(e,t)}function Fn(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(!Mn()){return}var t=us.get("repr")(e);if(r===null||r instanceof RegExp&&r.test(t)){console.log(us.get("type")(e)+": "+t)}if(n){console.log(e)}}if(ba(e)){e.then(t)}else{t(e)}return e}function Mn(){return as&&as.get("DEBUG",{throwError:false})}function qn(e){return e?"(?:#".concat(e,"(?:#[ie])?|#[ie]#").concat(e,")"):"(?:#[ie])?"}function zn(e,t){return"".concat(qn(e),"[+-]?").concat(t,"+/").concat(t,"+")}function Vn(e,t){return"".concat(qn(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 Yn(e,t){return"".concat(qn(e),"[+-]?").concat(t,"+")}var $n=/^#\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimyus]*)$/;var Jn="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+)(?:[eE][-+]?[0-9]+)?)|[0-9]+\\.)";var Kn="(?:#[ie])?(?:[+-]?(?:[0-9]+/[0-9]+|nan.0|inf.0|".concat(Jn,"|[+-]?[0-9]+))?(?:").concat(Jn,"|[+-](?:[0-9]+/[0-9]+|[0-9]+|nan.0|inf.0))i");var Gn=new RegExp("^(#[ie])?".concat(Jn,"$"),"i");function Hn(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 Wn=function(){var u={};[[10,"","[0-9]"],[16,"x","[0-9a-fA-F]"],[8,"o","[0-7]"],[2,"b","[01]"]].forEach(function(e){var t=z(e,3),r=t[0],n=t[1],i=t[2];u[r]=Hn(n,i)});return u}();var Qn={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 Zn(e){var t=[];var r=0;var n=e.length;while(r=55296&&i<=56319&&r1&&arguments[1]!==undefined?arguments[1]:10;var r=hi(e);var n=r.number.split("/");var i=Oo({num:y([n[0],r.radix||t]),denom:y([n[1],r.radix||t])});if(r.inexact){return i.valueOf()}else{return i}}function _i(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;var r=hi(e);if(r.inexact){return Ao(parseInt(r.number,r.radix||t))}return y([r.number,r.radix||t])}function di(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 so(r)}throw new Error("Parse: invalid character")}function vi(e){var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;function t(e){var t;if(e==="+"){t=y(1)}else if(e==="-"){t=y(-1)}else if(e.match(oi)){t=y([e,i])}else if(e.match(si)){var r=e.split("/");t=Oo({num:y([r[0],i]),denom:y([r[1],i])})}else if(e.match(Gn)){var n=gi(e);if(u.exact){return n.toRational()}return n}else if(e.match(/nan.0$/)){return y(NaN)}else if(e.match(/inf.0$/)){if(e[0]==="-"){return y(Number.NEGATIVE_INFINITY)}return y(Number.POSITIVE_INFINITY)}else{throw new Error("Internal Parser Error")}if(u.inexact){return Ao(t.valueOf())}return t}var u=hi(e);i=u.radix||i;var r;var n=u.number.match(fi);if(i!==10&&n){r=n}else{r=u.number.match(Wn[i])}var a,o;o=t(r[2]);if(r[1]){a=t(r[1])}else{a=y(0)}if(o.cmp(0)===0&&o.__type__==="bigint"){return a}return Eo({im:o,re:a})}function yi(e){return parseInt(e.toString(),10)===e}function mi(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 y(u).mul(o)}}}r=Ao(r);if(t.exact){return r.toRational()}return r}function bi(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 co(JSON.parse(e))}catch(e){var r=e.message.replace(/in JSON /,"").replace(/.*Error: /,"");throw new Error("Invalid string literal: ".concat(r))}}function wi(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 Di(e){if(is.hasOwnProperty(e)){return is[e]}if(e.match(/^"[\s\S]*"$/)){return bi(e)}else if(e[0]==="#"){var t=e.match($n);if(t){return new RegExp(t[1],t[2])}else if(e.match(ti)){return di(e)}var r=e.match(/#\\(.+)/);if(r&&Zn(r[1]).length===1){return di(e)}}if(e.match(/[0-9a-f]|[+-]i/i)){if(e.match(ai)){return _i(e)}else if(e.match(Gn)){return gi(e)}else if(e.match(ui)){return pi(e)}else if(e.match(ii)){return vi(e)}}if(e.match(/^#[iexobd]/)){throw new Error("Invalid numeric constant: "+e)}return wi(e)}function Ei(e){return!(["(",")","[","]"].includes(e)||Vi.names().includes(e))}function Ai(e){return Ei(e)&&!(e.match($n)||e.match(/^"[\s\S]*"$/)||e.match(ai)||e.match(Gn)||e.match(ii)||e.match(ui)||e.match(ti)||["#t","#f","nil","true","false"].includes(e))}var xi=/"(?:\\[\S\s]|[^"])*"?/g;function Fi(e){if(typeof e==="string"){var t=/([-\\^$[\]()+{}?*.|])/g;return e.replace(t,"\\$1")}return e}function ki(){this.data=[]}ki.prototype.push=function(e){this.data.push(e)};ki.prototype.top=function(){return this.data[this.data.length-1]};ki.prototype.pop=function(){return this.data.pop()};ki.prototype.is_empty=function(){return!this.data.length};function Ci(e){if(e instanceof co){e=e.valueOf()}var t=new s(e,{whitespace:true});var r=[];while(true){var n=t.peek(true);if(n===Yo){break}r.push(n);t.skip()}return r}function Oi(e){var t=e.token,r=R(e,_n);if(t.match(/^"[\s\S]*"$/)&&t.match(/\n/)){var n=new RegExp("^ {1,"+(e.col+1)+"}","mg");t=t.replace(n,"")}return Cn({token:t},r)}function Si(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};this.fn=e;this.cont=t}Si.prototype.toString=function(){return"#"};function Bi(n){return function(){for(var e=arguments.length,t=new Array(e),r=0;r1&&arguments[1]!==undefined?arguments[1]:false;if(e instanceof co){e=e.toString()}if(t){return Ci(e)}else{var r=Ci(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 Pi(r)}}function Pi(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(Ti(e)){return L(e)}if(e!==null){return r(e,Symbol("#:".concat(e)))}t++;return r(t,Symbol("#:g".concat(t)))}}();function Ui(e){var r=this;var n={pending:true,rejected:false,fulfilled:false,reason:undefined,type:undefined};e=e.then(function(e){n.type=Es(e);n.fulfilled=true;n.pending=false;return e});iu(this,"_promise",e,{hidden:true});if(pa(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]}})});iu(this,"__promise__",e);this.then=false}Ui.prototype.then=function(e){return new Ui(this.valueOf().then(e))};Ui.prototype["catch"]=function(e){return new Ui(this.valueOf()["catch"](e))};Ui.prototype.valueOf=function(){if(!this._promise){throw new Error("QuotedPromise: invalid promise created")}return this._promise};Ui.prototype.toString=function(){if(this.__pending__){return Ui.pending_str}if(this.__rejected__){return Ui.rejected_str}return"#")};Ui.pending_str="#";Ui.rejected_str="#";function Mi(e){if(Array.isArray(e)){return Promise.all(qi(e)).then(zi)}return e}function qi(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof Ui){t[r]=new Ho(n)}else{t[r]=n}}return t}function zi(e){var t=new Array(e.length),r=e.length;while(r--){var n=e[r];if(n instanceof Ho){t[r]=n.valueOf()}else{t[r]=n}}return t}var Vi={LITERAL:Symbol["for"]("literal"),SPLICE:Symbol["for"]("splice"),SYMBOL:Symbol["for"]("symbol"),names:function e(){return Object.keys(this.__list__)},type:function e(t){try{return this.get(t).type}catch(e){console.log({name:t});console.log(e);return null}},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"),Vi.LITERAL]];var Hi=Gi.map(function(e){return e[0]});Object.freeze(Hi);Object.defineProperty(Vi,"__builtins__",{writable:false,value:Hi});Gi.forEach(function(e){var t=z(e,3),r=t[0],n=t[1],i=t[2];Vi.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;j(this,p);iu(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=""}P(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 Yo}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 Yo}},{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 Yo}for(var r=this._i;r=r){return Yo}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 Yo}return so(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=z(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(!Wi(o,r)){return false}if(!Wi(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?Oi:u;j(this,o);if(e instanceof co){e=e.toString()}iu(this,"_formatter",a,{hidden:true});iu(this,"__lexer__",new s(e));iu(this,"__env__",r);iu(this,"_meta",i,{hidden:true});iu(this,"_refs",[],{hidden:true});iu(this,"_state",{parentheses:0},{hidden:true})}P(o,[{key:"resolve",value:function e(t){return this.__env__&&this.__env__.get(t,{throwError:false})}},{key:"peek",value:function(){var e=B(W.mark(function e(){var r;return W.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:r=this.__lexer__.peek(true);if(!(r===Yo)){t.next=4;break}return t.abrupt("return",Yo);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()===Yo)){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(W.mark(function e(){var r;return W.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(W.mark(function e(){var r,n,i,u;return W.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===Yo)){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(W.mark(function e(){var r;return W.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===Yo)){t.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return t.abrupt("return",Di(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 Ts(t,{env:this.__env__,error:function e(t){throw t}})}},{key:"read_object",value:function(){var e=B(W.mark(function e(){var r;return W.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 Zi){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,r){var n=this._state.parentheses;var i;if(n<0){i=new Error("Parser: unexpected parenthesis");i.__code__=[r.toString()+")"]}else{i=new Error("Parser: expected parenthesis but eof found");var u=new RegExp("\\){".concat(n,"}$"));i.__code__=[t.toString().replace(u,"")]}throw i}},{key:"_resolve_object",value:function(){var t=B(W.mark(function e(r){var n=this;var i;return W.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(!Nu(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(W.mark(function e(r){return W.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 Zi)){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 Zi)){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(W.mark(function e(){var r,n,h,i,u,a,o,s,c,f,l;return W.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===Yo)){t.next=5;break}return t.abrupt("return",r);case 5:if(!Yi(r)){t.next=38;break}n=Vi.get(r);h=$i(r);this.skip();u=Ki(r);if(!u){t.next=14;break}t.t0=undefined;t.next=17;break;case 14:t.next=16;return this._read_object();case 16:t.t0=t.sent;case 17:a=t.t0;if(h){t.next=25;break}o=this.__env__.get(n.symbol);if(!(typeof o==="function")){t.next=25;break}if(Ji(r)){s=[a]}else if(a===U){s=[]}else if(a instanceof M){s=a.to_array(false)}if(!(s||u)){t.next=24;break}return t.abrupt("return",Os(o,u?[]:s,{env:this.__env__,dynamic_env:this.__env__,use_dynamic:false}));case 24:throw new Error("Parse Error: Invalid parser extension "+"invocation ".concat(n.symbol));case 25:if(Ji(r)){i=new M(n.symbol,new M(a,U))}else{i=new M(n.symbol,a)}if(!h){t.next=28;break}return t.abrupt("return",i);case 28:if(!(o instanceof na)){t.next=37;break}t.next=31;return this.evaluate(i);case 31:c=t.sent;if(!(c instanceof M||c instanceof L)){t.next=34;break}return t.abrupt("return",M.fromArray([L("quote"),c]));case 34:return t.abrupt("return",c);case 37:throw new Error("Parse Error: invalid parser extension: "+n.symbol);case 38:f=this.match_datum_ref(r);if(!(f!==null)){t.next=44;break}this.skip();if(!this._refs[f]){t.next=43;break}return t.abrupt("return",new Zi(f,this._refs[f]));case 43:throw new Error("Parse Error: invalid datum label #".concat(f,"#"));case 44:l=this.match_datum_label(r);if(!(l!==null)){t.next=51;break}this.skip();this._refs[l]=this._read_object();return t.abrupt("return",this._refs[l]);case 51:if(!this.is_close(r)){t.next=55;break}this.skip();t.next=61;break;case 55:if(!this.is_open(r)){t.next=60;break}this.skip();return t.abrupt("return",this.read_list());case 60:return t.abrupt("return",this.read_value());case 61:case"end":return t.stop()}}},e,this)}));function t(){return e.apply(this,arguments)}return t}()}]);return o}();var Zi=function(){function r(e,t){j(this,r);this.name=e;this.data=t}P(r,[{key:"valueOf",value:function e(){return this.data}}]);return r}();function Xi(e,t){return eu.apply(this,arguments)}function eu(){eu=J(W.mark(function e(r,n){var i,u,a;return W.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!n){if(us){n=us.get("**interaction-environment**",{throwError:false})}else{n=as}}i=new Qi(r,{env:n});case 3:t.next=6;return Y(i.read_object());case 6:a=t.sent;if(!i.balanced()){i.ballancing_error(a,u)}if(!(a===Yo)){t.next=10;break}return t.abrupt("break",15);case 10:u=a;t.next=13;return a;case 13:t.next=3;break;case 15:case"end":return t.stop()}}},e)}));return eu.apply(this,arguments)}function tu(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(ba(e)){var n=e.then(t);if(r===null){return n}else{return n["catch"](r)}}if(e instanceof Array){return ru(e,t,r)}if(Nu(e)){return nu(e,t,r)}return t(e)}function ru(t,r,e){if(t.find(ba)){return tu(Mi(t),function(e){if(Object.isFrozen(t)){Object.freeze(e)}return r(e)},e)}return r(t)}function nu(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(ba(s)){u.push(s)}}if(u.length){return tu(Mi(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 iu(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 uu(e){return au.apply(this,arguments)}function au(){au=B(W.mark(function e(r){var n,i,u,a,o,s,c;return W.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:n=[];i=false;u=false;t.prev=3;o=On(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 au.apply(this,arguments)}function ou(e,t){if(t instanceof RegExp){return function(e){return String(e).match(t)}}else if(pa(t)){return t}throw new Error("Invalid matcher")}function l(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__=su(r)}}if(e){t.__name__=e}else if(t.name&&!Ja(t)){t.__name__=t.name}return t}function su(e){return e.split("\n").map(function(e){return e.trim()}).join("\n")}function cu(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 fu(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 lu(e,t){return f(e,t)===t.length;function f(r,n){function e(e,t){var r=An(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")&&!Ai(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 hu(e){this.__code__=e.replace(/\r/g,"")}hu.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:["&","#"]}}};hu.match=lu;hu.prototype._options=function e(t){var r=hu.defaults;if(typeof t==="undefined"){return Object.assign({},r)}var n=t&&t.exceptions||{};var i=n.specials||[];var u=n.shift||{1:[]};return Cn(Cn(Cn({},r),t),{},{exceptions:{specials:[].concat(C(r.exceptions.specials),C(i)),shift:Cn(Cn({},u),{},{1:[].concat(C(r.exceptions.shift[1]),C(u[1]))})}})};hu.prototype.indent=function e(t){var r=Ii(this.__code__,true);return this._indent(r,t)};hu.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=An(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()&&qs(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=hu.exception_shift(i.token,t);if(a!==-1){u=a}}if(u===-1){u=hu.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")};pu.prototype.match=function(e){return e.match(this.pattern)};function _u(){for(var e=arguments.length,t=new Array(e),r=0;r")};hu.Pattern=_u;hu.Ahead=pu;var du=/^[[(]$/;var vu=/^[\])]$/;var yu=/[^()[\]]/;var mu=new pu(/[^)\]]/);var gu=Symbol["for"]("*");var bu=new _u([du,gu,vu],[yu],"+");var wu=new _u([du,gu,vu],"+");var Du=new _u([Symbol["for"]("symbol")],"?");var Eu=new _u([Symbol["for"]("symbol")],"*");var Au=[du,Eu,vu];var xu=new _u([du,Symbol["for"]("symbol"),gu,vu],"+");var Fu=Ou("define","lambda","define-macro","syntax-rules");var ku=/^(?!.*\b(?:[()[\]]|define(?:-macro)?|let(?:\*|rec|-env|-syntax|)?|lambda|syntax-rules)\b).*$/;var Cu=/^(?:#:)?(let(?:\*|rec|-env|-syntax)?)$/;function Ou(){for(var e=arguments.length,t=new Array(e),r=0;r0&&!i[e]){i[e]=cu(n,e)}});var u=An(t),p;try{for(u.s();!(p=u.n()).done;){var a=z(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()&&!Yi(e)});var y=h(d);var m=lu(_,v);var g=e.slice(r).find(function(e){return e.trim()&&!Yi(e)});if(m&&(s instanceof pu&&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};hu.prototype._spaces=function(e){return new Array(e+1).join(" ")};hu.prototype.format=function c(e){var t=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var r=Ii(t,true);var n=this._options(e);var i=0;var u=0;for(var a=0;a0){n=Math.floor(t()*r);r--;var i=[e[n],e[r]];e[r]=i[0];e[n]=i[1]}return e}function ju(){}ju.prototype.toString=function(){return"()"};ju.prototype.valueOf=function(){return undefined};ju.prototype.serialize=function(){return 0};ju.prototype.to_object=function(){return{}};ju.prototype.append=function(e){return new M(e,U)};ju.prototype.to_array=function(){return[]};var U=new ju;function M(e,t){if(typeof this!=="undefined"&&this.constructor!==M||typeof this==="undefined"){return new M(e,t)}this.car=e;this.cdr=t}function Iu(u,a){return function e(t){h(u,t,["pair","nil"]);if(t===U){return[]}var r=[];var n=t;while(true){if(n instanceof M){if(n.haveCycles("cdr")){break}var i=n.car;if(a&&i instanceof M){i=this.get(u).call(this,i)}r.push(i);n=n.cdr}else if(n===U){break}else{throw new Error("".concat(u,": can't convert improper list"))}}return r}}M.prototype.flatten=function(){return M.fromArray(Su(this.to_array()))};M.prototype.length=function(){var e=0;var t=this;while(true){if(!t||t===U||!(t instanceof M)||t.haveCycles("cdr")){break}e++;t=t.cdr}return e};M.match=function(e,t){if(e instanceof L){return L.is(e,t)}else if(e instanceof M){return M.match(e.car,t)||M.match(e.cdr,t)}else if(Array.isArray(e)){return e.some(function(e){return M.match(e,t)})}else if(Nu(e)){return Object.values(e).some(function(e){return M.match(e,t)})}return false};M.prototype.find=function(e){return M.match(this,e)};M.prototype.clone=function(){var r=arguments.length>0&&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[Ta]=e[Ta];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(e))}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[Na]){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=C(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=co(o)}else if(typeof o==="number"&&!Number.isNaN(o)){o=y(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 co){i=i.valueOf()}var u=n.cdr;if(u instanceof M){u=u.to_object(e)}if(gs(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 Pu=new Map;function Nu(e){return e&&d(e)==="object"&&e.constructor===Object}var Ru=Object.getOwnPropertyNames(Array.prototype);var Tu=[];Ru.forEach(function(e){Tu.push(Array[e],Array.prototype[e])});function Lu(e){e=Fa(e);return Tu.includes(e)}function Uu(e){return pa(e)&&(Ja(e)||e.__doc__)}function Mu(r){var e=r.constructor||Object;var n=Nu(r);var i=pa(r[Symbol.asyncIterator])||pa(r[Symbol.iterator]);var u;if(Pu.has(e)){u=Pu.get(e)}else{Pu.forEach(function(e,t){t=Fa(t);if(r.constructor===t&&(t===Object&&n&&!i||t!==Object)){u=e}})}return u}var qu=new Map;[[true,"#t"],[false,"#f"],[null,"null"],[undefined,"#"]].forEach(function(e){var t=z(e,2),r=t[0],n=t[1];qu.set(r,n)});function zu(r){if(r&&d(r)==="object"){var n={};var e=Object.getOwnPropertySymbols(r);e.forEach(function(e){var t=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");n[t]=Gu(r[e])});var t=Object.getOwnPropertyNames(r);t.forEach(function(e){var t=r[e];if(t&&d(t)==="object"&&t.constructor===Object){n[e]=zu(t)}else{n[e]=Gu(t)}});return n}return r}function Vu(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}function Yu(e,t){return e.hasOwnProperty(t)&&pa(e.toString)}function $u(e){if(Ha(e)){return"#"}var t=e.prototype&&e.prototype.constructor;if(pa(t)&&Ja(t)){if(e[La]&&t.hasOwnProperty("__name__")){var r=t.__name__;if(co.isString(r)){r=r.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(d(n)==="symbol"){n=Ri(n)}if(typeof n==="string"){return"#")}}if(Yu(e,"toString")){return e.toString()}else if(e.name&&!Ja(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(C(i)))}],[so,function(e,t){var r=t.quote;if(r){return e.toString()}return e.valueOf()}],[co,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=z(e,2),r=t[0],n=t[1];Ju.set(r,n)});var Ku=[L,y,na,Wo,Bo,jo,Go,Ui];function Gu(e,t,c){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(qu.has(e)){return qu.get(e)}if(Hu(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(d(e)==="object"){var a=e.constructor;if(!a){a=Object}var o;if(typeof a.__class__==="string"){o=a.__class__}else{var s=Mu(e);if(s){if(pa(s)){return s(e,t)}else{throw new Error("toString: Invalid repr value")}}o=a.name}if(pa(e.toString)&&Ja(e.toString)){return e.toString().valueOf()}if(Es(e)==="instance"){if(Ja(a)&&a.__name__){o=a.__name__.valueOf()}else if(!Ha(a)){o="instance"}}if(ws(e,Symbol.iterator)){if(o){return"#")}return"#"}if(ws(e,Symbol.asyncIterator)){if(o){return"#")}return"#"}if(o!==""){return"#<"+o+">"}return"#"}if(typeof e!=="string"){return e.toString()}return e}function Hu(e){return e&&d(e)==="object"&&e.hasOwnProperty&&e.hasOwnProperty("constructor")&&typeof e.constructor==="function"&&e.constructor.prototype===e}M.prototype.markCycles=function(){Wu(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[Ta]&&this[Ta][e])};function Wu(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[Ta]){e[Ta]={}}e[Ta][t]=r;if(!i.includes(e)){i.push(e)}return true}}}var s=Bi(function e(t,r){if(t instanceof M){delete t.ref;delete t[Ta];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 Si(function(){return e(t.cdr,r.slice())})}}});function r(e,t){if(e[Ta][t]instanceof M){var r=n.indexOf(e[Ta][t]);e[Ta][t]="#".concat(r,"#")}}s(e,[]);var n=t.filter(function(e){return u.includes(e)});n.forEach(function(e,t){e[Ra]="#".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[Ra]){i.push(this[Ra]+"(")}else if(!n){i.push("(")}var u;if(this[Ta]&&this[Ta].car){u=this[Ta].car}else{u=Gu(this.car,e,true)}if(u!==undefined){i.push(u)}if(this.cdr instanceof M){if(this[Ta]&&this[Ta].cdr){i.push(" . ");i.push(this[Ta].cdr)}else{if(this.cdr[Ra]){i.push(" . ")}else{i.push(" ")}var a=this.cdr.toString(e,{nested:true});i.push(a)}}else if(this.cdr!==U){i=i.concat([" . ",Gu(this.cdr,e,true)])}if(!n||this[Ra]){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 Qu(e){return e<0?-e:e}function Zu(e,t){var r=A(t),n=r[0],i=r.slice(1);while(i.length>0){var u=i,a=z(u,1),o=a[0];if(!e(n,o)){return false}var s=i;var c=A(s);n=c[0];i=c.slice(1)}return true}function Xu(e,t){if(pa(e)){return pa(t)&&Fa(e)===Fa(t)}else if(e instanceof y){if(!(t instanceof y)){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 Xu(y(e),y(t))}else if(e instanceof so){if(!(t instanceof so)){return false}return e.__char__===t.__char__}else{return e===t}}function ea(e,t){if(Es(e)!==Es(t)){return false}if(!ta(e)){return false}if(e instanceof RegExp){return e.source===t.source}if(e instanceof co){return e.valueOf()===t.valueOf()}return Xu(e,t)}function ta(e){return e instanceof L||co.isString(e)||e===U||e===null||e instanceof so||e instanceof y||e===true||e===false}var ra=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 na(e,t,r,n){if(typeof this!=="undefined"&&this.constructor!==na||typeof this==="undefined"){return new na(e,t)}h("Macro",e,"string",1);h("Macro",t,"function",2);if(r){if(n){this.__doc__=r}else{this.__doc__=su(r)}}this.__name__=e;this.__fn__=t}na.defmacro=function(e,t,r,n){var i=new na(e,t,r,n);i.__defmacro__=true;return i};na.prototype.invoke=function(e,t,r){var n=t.env,i=R(t,dn);var u=Cn(Cn({},i),{},{macro_expand:r});var a=this.__fn__.call(n,e,u,this.__name__);return a};na.prototype.toString=function(){return"#")};var ia="define-macro";var ua=-1e4;function aa(c){return function(){var r=B(W.mark(function e(r,m){var u,g,n,i,s,D,E,A,x,F,k,b,a,w,o;return W.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:o=function e(){o=B(W.mark(function e(r,n,i){var h,u,a,p,o,_,s,d,c,v,f,l,y;return W.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[Na]){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 oa?r:r.cdr;t.next=32;return u.invoke(_,Cn(Cn({},m),{},{env:i}),true);case 32:s=t.sent;if(!(u instanceof oa)){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")}return"#"};oa.className="syntax";var sa=function(e){_(r,e);var t=Dn(r);function r(){j(this,r);return t.apply(this,arguments)}return P(r)}(oa);oa.Parameter=sa;function ca(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(Mn()){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&&Gu(t,true),pattern:e&&Gu(e,true)});if(ta(e)&&!(e instanceof L)){return ea(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===us}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=C(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 fa(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 la(){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(d(e))}function j(e){if(!o(e)){var t=Es(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=d(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 co(e)})))}}}if(a.includes(r)){return L(r)}return s(r)}function I(e){if(Mn()){console.log(e)}}function s(e){if(!c[e]){var t=S.ref(e);var r=Li(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=A(u),o=a[0],s=a.slice(1);if(c[o]){Ya(r,"__object__",[c[o]].concat(C(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,C(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>> "+Gu(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=Cn({},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=q({},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 na&&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:Gu(i.car),cdr:Gu(i.cdr),head:Gu(D),rest:Gu(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 ha(e){return wa(e)||e===U||e===null}function pa(e){return typeof e==="function"&&typeof e.bind==="function"}function _a(e){return e instanceof Ns}function da(e){return e instanceof Is}function va(e){return e instanceof js}function ya(e){return e instanceof M}function ma(e){return e instanceof Go}function ga(e){return pa(e)||_a(e)||va(e)}function ba(e){if(e instanceof Ui){return false}if(e instanceof Promise){return true}return e&&pa(e.then)}function wa(e){return typeof e==="undefined"}function Da(e){switch(d(e)){case"string":return co(e);case"bigint":return y(e);case"number":if(Number.isNaN(e)){return ns}else{return y(e)}}return e}function Ea(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=[co,y].some(function(e){return t instanceof e});if(e){return t.valueOf()}if(t instanceof Array){return t.map(Aa)}if(t instanceof Ui){delete t.then}if(Nu(t)){return Ea(t,Aa)}return t}function xa(e,t){if(e instanceof M){e.markCycles();return Qo(e)}if(pa(e)){if(t){return ka(e,t)}}return Da(e)}function Fa(e){if(Oa(e)){return e[Pa]}return e}function ka(e,t){if(e[Symbol["for"]("__bound__")]){return e}var r=e.bind(t);var n=Object.getOwnPropertyNames(e);var i=An(n),u;try{for(i.s();!(u=i.n()).done;){var a=u.value;if(Va(a)){try{r[a]=e[a]}catch(e){}}}}catch(e){i.e(e)}finally{i.f()}Ya(r,"__fn__",e);Ya(r,"__context__",t);Ya(r,"__bound__",true);if(Ha(e)){Ya(r,"__native__",true)}if(Nu(t)&&Ja(e)){Ya(r,"__method__",true)}r.valueOf=function(){return e};return r}function Ca(e){return Oa(e)&&e[Symbol["for"]("__context__")]===Object}function Oa(e){return!!(pa(e)&&e[Pa])}function Sa(e){if(pa(e)){var t=e[Ia];if(t&&(t===bc||t.constructor&&t.constructor.__class__)){return true}}return false}function Ba(e){return e instanceof Bo||e instanceof jo}function ja(e){if(pa(e)){if(Ba(e[Ia])){return true}}return false}var Ia=Symbol["for"]("__context__");var Pa=Symbol["for"]("__fn__");var Na=Symbol["for"]("__data__");var Ra=Symbol["for"]("__ref__");var Ta=Symbol["for"]("__cycles__");var La=Symbol["for"]("__class__");var Ua=Symbol["for"]("__method__");var Ma=Symbol["for"]("__prototype__");var qa=Symbol["for"]("__lambda__");var za=["name","length","caller","callee","arguments","prototype"];function Va(e){return!za.includes(e)}function Ya(e,t,r){Object.defineProperty(e,Symbol["for"](t),{get:function e(){return r},set:function e(){},configurable:false,enumerable:false})}function $a(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 Ja(e){return e&&e[qa]}function Ka(e){return e&&e[Ua]}function Ga(e){return Ja(e)&&!e[Ma]&&!Ka(e)&&!ja(e)}function Ha(e){var t=Symbol["for"]("__native__");return pa(e)&&e.toString().match(/\{\s*\[native code\]\s*\}/)&&(e.name.match(/^bound /)&&e[t]===true||!e.name.match(/^bound /)&&!e[t])}function Wa(e){var b;switch(e){case Symbol["for"]("letrec"):b="letrec";break;case Symbol["for"]("let"):b="let";break;case Symbol["for"]("let*"):b="let*";break;default:throw new Error("Invalid let_macro value")}return na.defmacro(b,function(t,e){var f=e.dynamic_env;var l=e.error,n=e.macro_expand,y=e.use_dynamic;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=us.get("list->array")(t.car);var _=p.inherit(b);var d,v;if(b==="let*"){v=_}else if(b==="let"){d=[]}var m=0;function g(){var e=new M(new L("begin"),t.cdr);return Ts(e,{env:_,dynamic_env:_,use_dynamic:y,error:l})}return function t(){var r=h[m++];f=b==="let*"?_:p;if(!r){if(d&&d.length){var e=d.map(function(e){return e.value});var n=e.filter(ba);if(n.length){return Mi(e).then(function(e){for(var t=0,r=e.length;t1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=t.error;var i=this;var u=this;var a=[];var o=e;while(o instanceof M){a.push(Ts(o.car,{env:i,dynamic_env:u,use_dynamic:r,error:n}));o=o.cdr}var s=a.filter(ba).length;if(s){return Mi(a).then(c.bind(this))}else{return c.call(this,a)}})}function Za(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 oo(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(so.__names__[e]){t=e;e=so.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{t=so.__rev_names__[e]}Object.defineProperty(this,"__char__",{value:e,enumerable:true});if(t){Object.defineProperty(this,"__name__",{value:t,enumerable:true})}}so.__names__=Qn;so.__rev_names__={};Object.keys(so.__names__).forEach(function(e){var t=so.__names__[e];so.__rev_names__[t]=e});so.prototype.toUpperCase=function(){return so(this.__char__.toUpperCase())};so.prototype.toLowerCase=function(){return so(this.__char__.toLowerCase())};so.prototype.toString=function(){return"#\\"+(this.__name__||this.__char__)};so.prototype.valueOf=so.prototype.serialize=function(){return this.__char__};function co(e){if(typeof this!=="undefined"&&!(this instanceof co)||typeof this==="undefined"){return new co(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 fo=["length","constructor"];var lo=Object.getOwnPropertyNames(String.prototype).filter(function(e){return!fo.includes(e)});var ho=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 y){return e}if(typeof this!=="undefined"&&!(this instanceof y)||typeof this==="undefined"){return new y(e,t)}if(typeof e==="undefined"){throw new Error("Invalid LNumber constructor call")}var r=y.getType(e);if(y.types[r]){return y.types[r](e,t)}var n=e instanceof Array&&co.isString(e[0])&&y.isNumber(e[1]);if(e instanceof y){return y(e.value)}if(!y.isNumber(e)&&!n){throw new Error("You can't create LNumber from ".concat(Es(e)))}if(e===null){e=0}var i;if(n){var c=e,u=z(c,2),a=u[0],o=u[1];if(a instanceof co){a=a.valueOf()}if(o instanceof y){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 Ao(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=C(a).map(function(e,t){return BigInt(parseInt(e,o))*wo(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 So(i,true)}else if(typeof Tn!=="undefined"&&!(e instanceof Tn)){if(e instanceof Array){return So(p(Tn,C(e)))}return So(new Tn(e))}else if(n){this.constant(parseInt(a,o),"integer")}else{this.constant(e,"integer")}}y.prototype.constant=function(e,t){Object.defineProperty(this,"__value__",{value:e,enumerable:true});Object.defineProperty(this,"__type__",{value:t,enumerable:true})};y.types={float:function e(t){return new Ao(t)},complex:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!y.isComplex(t)){t={im:0,re:t}}return new Eo(t,r)},rational:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(!y.isRational(t)){t={num:t,denom:1}}return new Oo(t,r)}};y.prototype.serialize=function(){return this.__value__};y.prototype.isNaN=function(){return Number.isNaN(this.__value__)};y.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}}};y.isFloat=function e(t){return t instanceof Ao||Number(t)===t&&t%1!==0};y.isNumber=function(e){return e instanceof y||y.isNative(e)||y.isBN(e)};y.isComplex=function(e){if(!e){return false}var t=e instanceof Eo||(y.isNumber(e.im)||Number.isNaN(e.im))&&(y.isNumber(e.re)||Number.isNaN(e.re));return t};y.isRational=function(e){if(!e){return false}return e instanceof Oo||y.isNumber(e.num)&&y.isNumber(e.denom)};y.isInteger=function(e){if(!(y.isNative(e)||e instanceof y)){return false}if(y.isFloat(e)){return false}if(y.isRational(e)){return false}if(y.isComplex(e)){return false}return true};y.isNative=function(e){return typeof e==="bigint"||typeof e==="number"};y.isBigInteger=function(e){return e instanceof So||typeof e==="bigint"||y.isBN(e)};y.isBN=function(e){return typeof Tn!=="undefined"&&e instanceof Tn};y.getArgsType=function(e,t){if(e instanceof Ao||t instanceof Ao){return Ao}if(e instanceof So||t instanceof So){return So}return y};y.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()};y.prototype.asType=function(e){var t=y.getType(this);return y.types[t]?y.types[t](e):y(e)};y.prototype.isBigNumber=function(){return typeof this.__value__==="bigint"||typeof Tn!=="undefined"&&!(this.value instanceof Tn)};["floor","ceil","round"].forEach(function(e){y.prototype[e]=function(){if(this["float"]||y.isFloat(this.__value__)){return y(Math[e](this.__value__))}else{return y(Math[e](this.valueOf()))}}});y.prototype.valueOf=function(){if(y.isNative(this.__value__)){return Number(this.__value__)}else if(y.isBN(this.__value__)){return this.__value__.toNumber()}};var yo=function(){var e=function e(t,r){return[t,r]};return{bigint:{bigint:e,float:function e(t,r){return[Ao(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[Ao(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&&Ao(r.valueOf())]},integer:function e(t,r){return[t,r&&Ao(r.valueOf())]},float:e,rational:function e(t,r){return[t,r&&Ao(r.valueOf())]},complex:function e(t,r){return[{re:t,im:Ao(0)},r]}},complex:{bigint:t("bigint"),integer:t("integer"),float:t("float"),rational:t("rational"),complex:function f(e,t){var r=y.coerce(e.__re__,t.__re__),n=z(r,2),i=n[0],u=n[1];var a=y.coerce(e.__im__,t.__im__),o=z(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[Ao(t.valueOf()),r]},rational:e,complex:function e(t,r){return[{im:mo(t.__type__,r.__im__.__type__,0)[0],re:mo(t.__type__,r.__re__.__type__,t)[0]},{im:mo(t.__type__,r.__im__.__type__,r.__im__)[0],re:mo(t.__type__,r.__re__.__type__,r.__re__)[0]}]}}};function t(r){return function(e,t){return[{im:mo(r,e.__im__.__type__,0,e.__im__)[1],re:mo(r,e.__re__.__type__,0,e.__re__)[1]},{im:mo(r,e.__im__.__type__,0,0)[1],re:mo(r,t.__type__,0,t)[1]}]}}}();function mo(e,t,r,n){return yo[e][t](r,n)}y.coerce=function(e,t){var r=y.getType(e);var n=y.getType(t);if(!yo[r]){throw new Error("LNumber::coerce unknown lhs type ".concat(r))}else if(!yo[r][n]){throw new Error("LNumber::coerce unknown rhs type ".concat(n))}var i=yo[r][n](e,t);return i.map(function(e){return y(e,true)})};y.prototype.coerce=function(e){if(!(typeof e==="number"||e instanceof y)){throw new Error("LNumber: you can't coerce ".concat(Es(e)))}if(typeof e==="number"){e=y(e)}return y.coerce(this,e)};y.getType=function(e){if(e instanceof y){return e.__type__}if(y.isFloat(e)){return"float"}if(y.isComplex(e)){return"complex"}if(y.isRational(e)){return"rational"}if(typeof e==="number"){return"integer"}if(typeof BigInt!=="undefined"&&typeof e!=="bigint"||typeof Tn!=="undefined"&&!(e instanceof Tn)){return"bigint"}};y.prototype.isFloat=function(){return!!(y.isFloat(this.__value__)||this["float"])};var go={add:"+",sub:"-",mul:"*",div:"/",rem:"%",or:"|",and:"&",neg:"~",shl:">>",shr:"<<"};var bo={};Object.keys(go).forEach(function(t){bo[go[t]]=t;y.prototype[t]=function(e){return this.op(go[t],e)}});y._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 Eo)||typeof this==="undefined"){return new Eo(e,t)}if(e instanceof Eo){return Eo({im:e.__im__,re:e.__re__})}if(y.isNumber(e)&&t){if(!t){return Number(e)}}else if(!y.isComplex(e)){var r="Invalid constructor call for LComplex expect &(:im :re ) object but got ".concat(Gu(e));throw new Error(r)}var n=e.im instanceof y?e.im:y(e.im);var i=e.re instanceof y?e.re:y(e.re);this.constant(n,i)}Eo.prototype=Object.create(y.prototype);Eo.prototype.constructor=Eo;Eo.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})};Eo.prototype.serialize=function(){return{re:this.__re__,im:this.__im__}};Eo.prototype.toRational=function(e){if(y.isFloat(this.__im__)&&y.isFloat(this.__re__)){var t=Ao(this.__im__).toRational(e);var r=Ao(this.__re__).toRational(e);return Eo({im:t,re:r})}return this};Eo.prototype.pow=function(e){throw new Error("Not yet implemented")};Eo.prototype.add=function(e){return this.complex_op("add",e,function(e,t,r,n){return{re:e.add(t),im:r.add(n)}})};Eo.prototype.factor=function(){if(this.__im__ instanceof Ao||this.__im__ instanceof Ao){var e=this.__re__,t=this.__im__;var r,n;if(e instanceof Ao){r=e.toRational().mul(e.toRational())}else{r=e.mul(e)}if(t instanceof Ao){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__))}};Eo.prototype.modulus=function(){return this.factor().sqrt()};Eo.prototype.conjugate=function(){return Eo({re:this.__re__,im:this.__im__.sub()})};Eo.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=Ao(.5).mul(e.add(this.__re__)).sqrt();r=this.__im__.div(t).div(2)}else{r=Ao(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){r=r.sub()}t=this.__im__.div(r).div(2)}return Eo({im:r,re:t})};Eo.prototype.div=function(e){if(y.isNumber(e)&&!y.isComplex(e)){if(!(e instanceof y)){e=y(e)}var t=this.__re__.div(e);var r=this.__im__.div(e);return Eo({re:t,im:r})}else if(!y.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}if(this.cmp(e)===0){var n=this.coerce(e),i=z(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=z(h,2),p=a[0],o=a[1];var s=o.factor();var _=o.conjugate();var c=p.mul(_);if(!y.isComplex(c)){return c.div(s)}var d=c.__re__.op("/",s);var v=c.__im__.op("/",s);return Eo({re:d,im:v})};Eo.prototype.sub=function(e){return this.complex_op("sub",e,function(e,t,r,n){return{re:e.sub(t),im:r.sub(n)}})};Eo.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})};Eo.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 Eo(n,true)}return n};if(typeof t==="undefined"){return r()}if(y.isNumber(t)&&!y.isComplex(t)){if(!(t instanceof y)){t=y(t)}var n=t.asType(0);t={__im__:n,__re__:t}}else if(!y.isComplex(t)){throw new Error("[LComplex::".concat(e,"] Invalid value"))}var a=t.__re__ instanceof y?t.__re__:this.__re__.asType(t.__re__);var o=t.__im__ instanceof y?t.__im__:this.__im__.asType(t.__im__);return r(a,o)};Eo._op={"+":"add","-":"sub","*":"mul","/":"div"};Eo.prototype._op=function(e,t){var r=Eo._op[e];return this[r](t)};Eo.prototype.cmp=function(e){var t=this.coerce(e),r=z(t,2),n=r[0],i=r[1];var u=n.__re__.coerce(i.__re__),a=z(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=z(l,2),h=c[0],p=c[1];return h.cmp(p)}};Eo.prototype.valueOf=function(){return[this.__re__,this.__im__].map(function(e){return e.valueOf()})};Eo.prototype.toString=function(){var e;if(this.__re__.cmp(0)!==0){e=[Gu(this.__re__)]}else{e=[]}var t=this.__im__.valueOf();var r=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(t);var n=Gu(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 Ao(e){if(typeof this!=="undefined"&&!(this instanceof Ao)||typeof this==="undefined"){return new Ao(e)}if(!y.isNumber(e)){throw new Error("Invalid constructor call for LFloat")}if(e instanceof y){return Ao(e.valueOf())}if(typeof e==="number"){if(Object.is(e,-0)){Object.defineProperty(this,"_minus",{value:true})}this.constant(e,"float")}}Ao.prototype=Object.create(y.prototype);Ao.prototype.constructor=Ao;Ao.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(!y.isFloat(this.__value__)&&!e.match(/e/i)){var t=e+".0";return this._minus?"-"+t:t}return e.replace(/^([0-9]+)e/,"$1.0e")};Ao.prototype._op=function(e,t){if(t instanceof y){t=t.__value__}var r=y._ops[e];if(e==="/"&&this.__value__===0&&t===0){return NaN}return Ao(r(this.__value__,t))};Ao.prototype.toRational=function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){return xo(this.__value__.valueOf())}return Fo(e.valueOf())(this.__value__.valueOf())};Ao.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){var t=Ao(Math.sqrt(-e));return Eo({re:0,im:t})}return Ao(Math.sqrt(e))};Ao.prototype.abs=function(){var e=this.valueOf();if(e<0){e=-e}return Ao(e)};var xo=Fo(1e-10);function Fo(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=y(Co(n.sub(),r.sub())).sub()}else{i=y(0)}if(y.isFloat(t)||y.isFloat(e)){return Ao(i)}return i}function Co(e,t){var r=y(e).floor();var n=y(t).floor();if(e.cmp(r)<1){return r}else if(r.cmp(n)===0){var i=y(1).div(t.sub(n));var u=y(1).div(e.sub(r));return r.add(y(1).div(Co(i,u)))}else{return r.add(y(1))}}function Oo(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(typeof this!=="undefined"&&!(this instanceof Oo)||typeof this==="undefined"){return new Oo(e,t)}if(!y.isRational(e)){throw new Error("Invalid constructor call for LRational")}var r,n;if(e instanceof Oo){r=y(e.__num__);n=y(e.__denom__)}else{r=y(e.num);n=y(e.denom)}if(!t&&n.cmp(0)!==0){var i=r.op("%",n).cmp(0)===0;if(i){return y(r.div(n))}}this.constant(r,n)}Oo.prototype=Object.create(y.prototype);Oo.prototype.constructor=Oo;Oo.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})};Oo.prototype.serialize=function(){return{num:this.__num__,denom:this.__denom__}};Oo.prototype.pow=function(e){var t=e.cmp(0);if(t===0){return y(1)}if(t===-1){e=e.sub();var r=this.__denom__.pow(e);var n=this.__num__.pow(e);return Oo({num:r,denom:n})}var i=this;e=e.valueOf();while(e>1){i=i.mul(this);e--}return i};Oo.prototype.sqrt=function(){var e=this.__num__.sqrt();var t=this.__denom__.sqrt();if(e instanceof Ao||t instanceof Ao){return e.div(t)}return Oo({num:e,denom:t})};Oo.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 Oo({num:e,denom:t})};Oo.prototype.cmp=function(e){return y(this.valueOf(),true).cmp(e)};Oo.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 Oo){t=y(t.valueOf(true))}r=this.__denom__.div(e);if(r instanceof Oo){r=y(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()};Oo.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 y._ops["/"](this.__num__.value,this.__denom__.value)}return Ao(this.__num__.valueOf()).div(this.__denom__.valueOf())};Oo.prototype.mul=function(e){if(!(e instanceof y)){e=y(e)}if(y.isRational(e)){var t=this.__num__.mul(e.__num__);var r=this.__denom__.mul(e.__denom__);return Oo({num:t,denom:r})}var n=y.coerce(this,e),i=z(n,2),u=i[0],a=i[1];return u.mul(a)};Oo.prototype.div=function(e){if(!(e instanceof y)){e=y(e)}if(y.isRational(e)){var t=this.__num__.mul(e.__denom__);var r=this.__denom__.mul(e.__num__);return Oo({num:t,denom:r})}var n=y.coerce(this,e),i=z(n,2),u=i[0],a=i[1];var o=u.div(a);return o};Oo.prototype._op=function(e,t){return this[bo[e]](t)};Oo.prototype.sub=function(e){if(typeof e==="undefined"){return this.mul(-1)}if(!(e instanceof y)){e=y(e)}if(y.isRational(e)){var t=e.__num__.sub();var r=e.__denom__;return this.add(Oo({num:t,denom:r}))}if(!(e instanceof y)){e=y(e).sub()}else{e=e.sub()}var n=y.coerce(this,e),i=z(n,2),u=i[0],a=i[1];return u.add(a)};Oo.prototype.add=function(e){if(!(e instanceof y)){e=y(e)}if(y.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 Oo({num:a,denom:u})}if(y.isFloat(e)){return Ao(this.valueOf()).add(e)}var o=y.coerce(this,e),s=z(o,2),c=s[0],f=s[1];return c.add(f)};function So(e,t){if(typeof this!=="undefined"&&!(this instanceof So)||typeof this==="undefined"){return new So(e,t)}if(e instanceof So){return So(e.__value__,e._native)}if(!y.isBigInteger(e)){throw new Error("Invalid constructor call for LBigInteger")}this.constant(e,"bigint");Object.defineProperty(this,"_native",{value:t})}So.prototype=Object.create(y.prototype);So.prototype.constructor=So;So.bn_op={"+":"iadd","-":"isub","*":"imul","/":"idiv","%":"imod","|":"ior","&":"iand","~":"inot","<<":"ishrn",">>":"ishln"};So.prototype.serialize=function(){return this.__value__.toString()};So.prototype._op=function(e,t){if(typeof t==="undefined"){if(y.isBN(this.__value__)){e=So.bn_op[e];return So(this.__value__.clone()[e](),false)}return So(y._ops[e](this.__value__),true)}if(y.isBN(this.__value__)&&y.isBN(t.__value__)){e=So.bn_op[e];return So(this.__value__.clone()[e](t),false)}var r=y._ops[e](this.__value__,t.__value__);if(e==="/"){var n=this.op("%",t).cmp(0)===0;if(n){return y(r)}return Oo({num:this,denom:t})}return So(r,true)};So.prototype.sqrt=function(){var e;var t=this.cmp(0)<0;if(y.isNative(this.__value__)){e=y(Math.sqrt(t?-this.valueOf():this.valueOf()))}else if(y.isBN(this.__value__)){e=t?this.__value__.neg().sqrt():this.__value__.sqrt()}if(t){return Eo({re:0,im:e})}return e};y.NaN=y(NaN);function Bo(e){var n=this;if(typeof this!=="undefined"&&!(this instanceof Bo)||typeof this==="undefined"){return new Bo(e)}h("InputPort",e,"function");iu(this,"__type__",Vo);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(W.mark(function e(){var r;return W.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 Qi(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()!==Yo};this._make_defaults()}Bo.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(!y.isInteger(t)){var r=y.getType(t);ds("read-string",r,"integer")}return e.__lexer__.read_string(t.valueOf())});this.peek_char=this._with_parser(function(e){return e.__lexer__.peek_char()})};Bo.prototype._with_init_parser=function(o,s){var c=this;return B(W.mark(function e(){var r,n,i,u,a=arguments;return W.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 jo(e){if(typeof this!=="undefined"&&!(this instanceof jo)||typeof this==="undefined"){return new jo(e)}h("OutputPort",e,"function");iu(this,"__type__",Vo);this.write=e}jo.prototype.is_open=function(){return this._closed!==true};jo.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")}};jo.prototype.flush=function(){};jo.prototype.toString=function(){return"#"};var Io=function(e){_(n,e);var r=Dn(n);function n(e){var t;j(this,n);t=r.call(this,function(){var e;return(e=t)._write.apply(e,arguments)});h("BufferedOutputPort",e,"function");iu(o(t),"_fn",e,{hidden:true});iu(o(t),"_buffer",[],{hidden:true});return t}P(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"};Po.prototype.valueOf=function(){return this.__buffer__.map(function(e){return e.valueOf()}).join("")};function No(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof No)||typeof this==="undefined"){return new No(e,t)}h("OutputFilePort",e,"string");iu(this,"__filename__",e);iu(this,"_fd",t.valueOf(),{hidden:true});iu(this,"__type__",Vo);this.write=function(e){if(!co.isString(e)){e=Gu(e)}else{e=e.valueOf()}r.fs().write(r._fd,e,function(e){if(e){throw e}})}}No.prototype=Object.create(jo.prototype);No.prototype.constructor=No;No.prototype.fs=function(){if(!this._fs){this._fs=this.internal("fs")}return this._fs};No.prototype.internal=function(e){return as.get("**internal-env**").get(e)};No.prototype.close=function(){var n=this;return new Promise(function(t,r){n.fs().close(n._fd,function(e){if(e){r(e)}else{iu(n,"_fd",null,{hidden:true});jo.prototype.close.call(n);t()}})})};No.prototype.toString=function(){return"#")};function Ro(e,t){var r=this;if(typeof this!=="undefined"&&!(this instanceof Ro)||typeof this==="undefined"){return new Ro(e)}h("InputStringPort",e,"string");t=t||us;e=e.valueOf();this._with_parser=this._with_init_parser.bind(this,function(){if(!r.__parser__){r.__parser__=new Qi(e,{env:t})}return r.__parser__});iu(this,"__type__",Vo);this._make_defaults()}Ro.prototype.char_ready=function(){return true};Ro.prototype=Object.create(Bo.prototype);Ro.prototype.constructor=Ro;Ro.prototype.toString=function(){return"#"};function To(e){if(typeof this!=="undefined"&&!(this instanceof To)||typeof this==="undefined"){return new To(e)}h("InputByteVectorPort",e,"uint8array");iu(this,"__vector__",e);iu(this,"__type__",zo);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 y){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}})}To.prototype=Object.create(Bo.prototype);To.prototype.constructor=To;To.prototype.toString=function(){return"#"};To.prototype.close=function(){var t=this;iu(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}};To.prototype.u8_ready=function(){return true};To.prototype.peek_u8=function(){if(this.__index__>=this.__vector__.length){return Yo}return this.__vector__[this.__index__]};To.prototype.skip=function(){if(this.__index__<=this.__vector__.length){++this.__index__}};To.prototype.read_u8=function(){var e=this.peek_u8();this.skip();return e};To.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()===Yo){return Yo}return this.__vector__.slice(this.__index__,e)};function Lo(){if(typeof this!=="undefined"&&!(this instanceof Lo)||typeof this==="undefined"){return new Lo}iu(this,"__type__",zo);iu(this,"_buffer",[],{hidden:true});this.write=function(e){h("write",e,["number","uint8array"]);if(y.isNumber(e)){this._buffer.push(e.valueOf())}else{var t;(t=this._buffer).push.apply(t,C(Array.from(e)))}};Object.defineProperty(this,"__buffer__",{enumerable:true,get:function e(){return Uint8Array.from(this._buffer)}})}Lo.prototype=Object.create(jo.prototype);Lo.prototype.constructor=Lo;Lo.prototype.close=function(){jo.prototype.close.call(this);iu(this,"_buffer",null,{hidden:true})};Lo.prototype._close_guard=function(){if(this._closed){throw new Error("output-port: binary port is closed")}};Lo.prototype.write_u8=function(e){h("OutputByteVectorPort::write_u8",e,"number");this.write(e)};Lo.prototype.write_u8_vector=function(e){h("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};Lo.prototype.toString=function(){return"#"};Lo.prototype.valueOf=function(){return this.__buffer__};function Uo(e,t){if(typeof this!=="undefined"&&!(this instanceof Uo)||typeof this==="undefined"){return new Uo(e,t)}Ro.call(this,e);h("InputFilePort",t,"string");iu(this,"__filename__",t)}Uo.prototype=Object.create(Ro.prototype);Uo.prototype.constructor=Uo;Uo.prototype.toString=function(){return"#")};function Mo(e,t){if(typeof this!=="undefined"&&!(this instanceof Mo)||typeof this==="undefined"){return new Mo(e,t)}To.call(this,e);h("InputBinaryFilePort",t,"string");iu(this,"__filename__",t)}Mo.prototype=Object.create(To.prototype);Mo.prototype.constructor=Mo;Mo.prototype.toString=function(){return"#")};function qo(e,t){var i=this;if(typeof this!=="undefined"&&!(this instanceof qo)||typeof this==="undefined"){return new qo(e,t)}h("OutputBinaryFilePort",e,"string");iu(this,"__filename__",e);iu(this,"_fd",t.valueOf(),{hidden:true});iu(this,"__type__",zo);var u,r;this.write=function(e){h("write",e,["number","uint8array"]);var n;if(!u){u=i.internal("fs")}if(!r){r=i.internal("Buffer")}if(y.isNumber(e)){n=r.from([e.valueOf()])}else{n=r.from(Array.from(e))}return new Promise(function(t,r){u.write(i._fd,n,function(e){if(e){r(e)}else{t()}})})}}qo.prototype=Object.create(No.prototype);qo.prototype.constructor=qo;qo.prototype.write_u8=function(e){h("OutputByteVectorPort::write_u8",e,"number");this.write(e)};qo.prototype.write_u8_vector=function(e){h("OutputByteVectorPort::write_u8_vector",e,"uint8array");this.write(e)};var zo=Symbol["for"]("binary");var Vo=Symbol["for"]("text");var Yo=new $o;function $o(){}$o.prototype.toString=function(){return"#"};function Jo(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=R(t,vn);if(typeof this!=="undefined"&&!(this instanceof Jo)||typeof this==="undefined"){return new Jo(e,Cn({stdin:n,stdout:i,stderr:r,command_line:a},o))}if(typeof e==="undefined"){e="anonymous"}this.__env__=as.inherit(e,o);this.__env__.set("parent.frame",l("parent.frame",function(){return c.__env__},us.__env__["parent.frame"].__doc__));var f="**interaction-environment-defaults**";this.set(f,Vu(o).concat(f));var s=rs.inherit("internal-".concat(e));if(Ba(n)){s.set("stdin",n)}if(Ba(r)){s.set("stderr",r)}if(Ba(i)){s.set("stdout",i)}s.set("command-line",a);os(this.__env__,s)}Jo.prototype.exec=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=t.use_dynamic,n=r===void 0?false:r,i=t.dynamic_env,u=t.env;h("Interpreter::exec",e,["string","array"],1);h("Interpreter::exec",n,"boolean",2);if(!u){u=this.__env__}if(!i){i=u}us.set("**interaction-environment**",this.__env__);return Us(e,{env:u,dynamic_env:i,use_dynamic:n})};Jo.prototype.get=function(e){var t=this.__env__.get(e);if(pa(t)){return t.bind(this.__env__)}return t};Jo.prototype.set=function(e,t){return this.__env__.set(e,t)};Jo.prototype.constant=function(e,t){return this.__env__.constant(e,t)};function Ko(e,t){this.name="LipsError";this.message=e;this.args=t;this.stack=(new Error).stack}Ko.prototype=new Error;Ko.prototype.constructor=Ko;function Go(e,t,r){if(arguments.length===1){if(d(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"}Go.prototype.list=function(){return Vu(this.__env__)};Go.prototype.fs=function(){return this.get("**fs**")};Go.prototype.unset=function(e){if(e instanceof L){e=e.valueOf()}if(e instanceof co){e=e.valueOf()}delete this.__env__[e]};Go.prototype.inherit=function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(d(e)==="object"){t=e}if(!e||d(e)==="object"){e="child of "+(this.__name__||"unknown")}return new Go(t||{},this,e)};Go.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 co){e=e.valueOf()}if(t){if(!r){t=su(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)}};Go.prototype.new_frame=function(e,t){var n=this.inherit("__frame__");n.set("parent.frame",l("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:1;e=e.valueOf();var t=n.__parent__;if(!ma(t)){return U}if(e<=0){return t}var r=t.get("parent.frame");return r(e-1)},us.__env__["parent.frame"].__doc__));t.callee=e;n.set("arguments",t);return n};Go.prototype._lookup=function(e){if(e instanceof L){e=e.__name__}if(e instanceof co){e=e.valueOf()}if(this.__env__.hasOwnProperty(e)){return Ho(this.__env__[e])}if(this.__parent__){return this.__parent__._lookup(e)}};Go.prototype.toString=function(){return"#"};Go.prototype.clone=function(){var t=this;var r={};Object.keys(this.__env__).forEach(function(e){r[e]=t.__env__[e]});return new Go(r,this.__parent__,this.__name__)};Go.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 Ho(e){if(typeof this!=="undefined"&&!(this instanceof Ho)||typeof this==="undefined"){return new Ho(e)}this.value=e}Ho.isUndefined=function(e){return e instanceof Ho&&typeof e.value==="undefined"};Ho.prototype.valueOf=function(){return this.value};function Wo(e){if(e.length){if(e.length===1){return e[0]}}if(typeof this!=="undefined"&&!(this instanceof Wo)||typeof this==="undefined"){return new Wo(e)}this.__values__=e}Wo.prototype.toString=function(){return this.__values__.map(function(e){return Gu(e)}).join("\n")};Wo.prototype.valueOf=function(){return this.__values__};Go.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 co){n=n.valueOf()}var i=this._lookup(n);if(i instanceof Ho){if(Ho.isUndefined(i)){return undefined}return xa(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=A(f),o=a[0],s=a.slice(1);i=this._lookup(o);if(s.length){try{if(i instanceof Ho){i=i.valueOf()}else{i=Xo(Bn,o);if(pa(i)){i=Fa(i)}}if(typeof i!=="undefined"){return Xo.apply(void 0,[i].concat(C(s)))}}catch(e){throw e}}else if(i instanceof Ho){return xa(i.valueOf())}i=Xo(Bn,n)}if(typeof i!=="undefined"){return i}if(c){throw new Error("Unbound variable `"+n.toString()+"'")}};Go.prototype.set=function(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;h("Environment::set",e,["string","symbol"]);if(y.isNumber(t)){t=y(t)}if(e instanceof L){e=e.__name__}if(e instanceof co){e=e.valueOf()}this.__env__[e]=t;if(r){this.doc(e,r,true)}return this};Go.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&&Nu(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};Go.prototype.has=function(e){return this.__env__.hasOwnProperty(e)};Go.prototype.ref=function(e){var t=this;while(true){if(!t){break}if(t.has(e)){return t}t=t.__parent__}};Go.prototype.parents=function(){var e=this;var t=[];while(e){t.unshift(e);e=e.__parent__}return t};function Qo(e){if(ba(e)){return e.then(Qo)}if(e instanceof M||e instanceof L){e[Na]=true}return e}var Zo=Xi(Ii('(lambda ()\n "[native code]"\n (throw "Invalid Invocation"))'))[0];var Xo=l("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=es(this,"stdin")}ys("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":l("read-line",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=es(this,"stdin")}ys("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":l("read-char",function(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(e===null){e=es(this,"stdin")}ys("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:l("read",function(){var e=B(W.mark(function e(){var r,n,i,u,a,o,s,c,f,l=arguments;return W.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:r=l.length>0&&l[0]!==undefined?l[0]:null;n=this.env;if(!co.isString(r)){t.next=31;break}i=false;u=false;t.prev=5;o=On(Xi(r,n));case 7:t.next=9;return o.next();case 9:if(!(i=!(s=t.sent).done)){t.next=15;break}c=s.value;return t.abrupt("return",c);case 12:i=false;t.next=7;break;case 15:t.next=21;break;case 17:t.prev=17;t.t0=t["catch"](5);u=true;a=t.t0;case 21:t.prev=21;t.prev=22;if(!(i&&o["return"]!=null)){t.next=26;break}t.next=26;return o["return"]();case 26:t.prev=26;if(!u){t.next=29;break}throw a;case 29:return t.finish(26);case 30:return t.finish(21);case 31:if(r===null){f=es(n,"stdin")}else{f=r}ys("read",f,"input-port");return t.abrupt("return",f.read.call(n));case 34:case"end":return t.stop()}}},e,this,[[5,17,21,31],[22,,26,30]])}));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:l("pprint",function e(t){if(t instanceof M){t=new bc.Formatter(t.toString(true))["break"]().format();us.get("display").call(us,t)}else{us.get("write").call(us,t)}us.get("newline").call(us)},"(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:l("print",function e(){var t=us.get("display");var r=us.get("newline");var n=this.use_dynamic;var i=us;var u=us;for(var a=arguments.length,o=new Array(a),s=0;s1?r-1:0),i=1;in.length){throw new Error("Not enough arguments")}var o=0;var s=us.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:l("display",function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(r===null){r=es(this,"stdout")}else{h("display",r,"output-port")}var n=t;if(!(r instanceof qo)){n=us.get("repr")(t)}r.write.call(us,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":l("display-error",function e(){var t=es(this,"stderr");var r=us.get("repr");for(var n=arguments.length,i=new Array(n),u=0;u1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,f=R(t,yn);var n=this;var i=this;var u;var l=Cn(Cn({},f),{},{env:this,dynamic_env:n,use_dynamic:r});var a=Ts(e.cdr.car,l);a=As(a);function o(t,r,n){if(ba(t)){return t.then(function(e){return o(t,e,n)})}if(ba(r)){return r.then(function(e){return o(t,e,n)})}if(ba(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 h=e.car.cdr.car;var p=e.car.cdr.cdr.car;var _=Ts(h,{env:this,dynamic_env:n,use_dynamic:r,error:error});var d=Ts(p,{env:this,dynamic_env:n,use_dynamic:r,error:error});return o(_,d,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 tu(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!":l(new na("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!":l("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!":l("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?":l("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:l("gensym",Li,"(gensym)\n\n Generates a unique symbol that is not bound anywhere,\n to use with macros as meta name."),load:l("load",function e(o,t){h("load",o,"string");var s=this;if(s.__name__==="__frame__"){s=s.__parent__}if(!(t instanceof Go)){if(s===us){t=s}else{t=this.get("**interaction-environment**")}}var c="**module-path**";var f=us.get(c,{throwError:false});o=o.valueOf();if(!o.match(/.[^.]+$/)){o+=".scm"}var r=o.match(/\.xcb$/);function l(e){if(r){e=hc(e)}else{if(Es(e)==="buffer"){e=e.toString()}e=e.replace(/^#!.*/,"");if(e.match(/^\{/)){e=uc(e)}}return Us(e,{env:t})}function n(e){return Bn.fetch(e).then(function(e){return r?e.arrayBuffer():e.text()}).then(function(e){if(r){e=new Uint8Array(e)}return e})}if(hs()){return new Promise(function(){var r=B(W.mark(function e(r,n){var i,u,a;return W.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:i=Rn("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:us.set(c,i.dirname(o));Rn("fs").readFile(o,function(e,t){if(e){n(e);us.set(c,f)}else{try{l(t).then(function(){r();us.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){us.set(c,o.replace(/\/[^/]*$/,""));return l(e)}).then(function(){})["finally"](function(){us.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:l(new na("do",function(){var r=B(W.mark(function e(r,h){var p,n,i,u,o,s,a,c,f,l,_,d;return W.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:p=h.use_dynamic,n=h.error;i=this;u=i;o=i.inherit("do");s=r.car;a=r.cdr.car;c=r.cdr.cdr;if(c!==U){c=new M(L("begin"),c)}f={env:i,dynamic_env:u,use_dynamic:p,error:n};l=s;case 10:if(!(l!==U)){t.next=21;break}_=l.car;t.t0=o;t.t1=_.car;t.next=16;return Ts(_.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_env:u,error:n};d=W.mark(function e(){var r,n,i,u,a;return W.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:if(!(c!==U)){t.next=3;break}t.next=3;return bc.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 Ts(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 Ts(a.car,f);case 25:t.t3=t.sent;if(!(t.t3===false)){t.next=30;break}return t.delegateYield(d(),"t4",28);case 28:t.next=23;break;case 30:if(!(a.cdr!==U)){t.next=34;break}t.next=33;return Ts(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:l(new na("if",function(r,e){var t=e.error,n=e.use_dynamic;var i=this;var u=this;var a={env:u,dynamic_env:i,use_dynamic:n,error:t};var o=function e(t){if(t===false){return Ts(r.cdr.cdr.car,a)}else{return Ts(r.cdr.car,a)}};if(r===U){throw new Error("too few expressions for `if`")}var s=Ts(r.car,a);return tu(s,o)}),"(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 na("let-env",function(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=e.dynamic_env,n=e.use_dynamic,i=e.error;h("let-env",t,"pair");var u=Ts(t.car,{env:this,dynamic_env:r,error:i,use_dynamic:n});return tu(u,function(e){h("let-env",e,"environment");return Ts(M(L("begin"),t.cdr),{env:e,dynamic_env:r,error:i})})},"(let-env env . body)\n\n Special macro that evaluates body in context of given environment\n object."),letrec:l(Wa(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*":l(Wa(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*":l(Wa(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:l(Wa(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*":l(Qa("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())."),shuffle:l(function(e){h("shuffle",e,["pair","nil","array"]);var t=us.get("random");if(e===U){return U}if(Array.isArray(e)){return Bu(e.slice(),t)}var r=us.get("list->array")(e);r=Bu(r,t);return us.get("array->list")(r)},"(shuffle obj)\n\n Order items in vector or list in random order."),begin:l(new na("begin",function(e,t){var n=Cn(Cn({},t),{},{env:this});var i=us.get("list->array")(e);var u;return function t(){if(i.length){var e=i.shift();var r=Ts(e,n);return tu(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 na("ignore",function(e,t){var r=Cn(Cn({},t),{},{env:this,dynamic_env:this});Ts(new M(new L("begin"),e),r)},"(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":l(na.defmacro("call/cc",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var r=Cn({env:this},t);return tu(Ts(e.car,r),function(e){if(pa(e)){return e(new Ns(null))}})}),"(call/cc proc)\n\n Call-with-current-continuation.\n\n NOT SUPPORTED BY LIPS RIGHT NOW"),parameterize:l(new na("parameterize",function(t,e){var i=e.dynamic_env;var u=i.inherit("parameterize").new_frame(null,{});var a=Cn(Cn({},e),{},{env:this});var o=t.car;if(!ya(o)){var r=Es(o);throw new Error("Invalid syntax for parameterize expecting pair got ".concat(r))}function s(){var e=new M(new L("begin"),t.cdr);return Ts(e,Cn(Cn({},a),{},{dynamic_env:u}))}return function r(){var e=o.car;var n=e.car.valueOf();return tu(Ts(e.cdr.car,a),function(e){var t=i.get(n,{throwError:false});if(!va(t)){throw new Error("Unknown parameter ".concat(n))}u.set(n,t.inherit(e));if(!ha(o.cdr)){o=o.cdr;return r()}else{return s()}})}()}),"(parameterize ((name value) ...)\n\n Macro that change the dynamic variable created by make-parameter."),"make-parameter":l(new na("make-parameter",function(e,t){t.dynamic_env;var r=Ts(e.car,t);var n;if(e.cdr.car instanceof M){n=Ts(e.cdr.car,t)}return new js(r,n)}),"(make-parameter init converter)\n\n Function creates new dynamic variable that can be custimized with parameterize\n macro. The value should be assigned to a variable e.g.:\n\n (define radix (make-parameter 10))\n\n The result value is a procedure that return the value of dynamic variable."),define:l(na.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}e.dynamic_env=this;e.env=n;var i=r.cdr.car;var u;if(i instanceof M){i=Ts(i,e);u=true}else if(i instanceof L){i=n.get(i)}h("define",r.car,"symbol");return tu(i,function(e){if(n.__name__===oa.__merge_env__){n=n.__parent__}if(u&&(pa(e)&&Ja(e)||e instanceof oa||va(e))){e.__name__=r.car.valueOf();if(e.__name__ instanceof co){e.__name__=e.__name__.valueOf()}}var t;if(r.cdr.cdr instanceof M&&co.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!":l("set-obj!",function(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var i=d(e);if(ha(e)||i!=="object"&&i!=="function"){var u=ds("set-obj!",Es(e),["object","function"]);throw new Error(u)}h("set-obj!",t,["string","symbol","number"]);e=Fa(e);t=t.valueOf();if(arguments.length===2){delete e[t]}else if(Hu(e)&&pa(r)){e[t]=Fa(r);e[t][Ma]=true}else if(pa(r)||gs(r)||r===U){e[t]=r}else{e[t]=r&&!Hu(r)?r.valueOf():r}if(Ru){var a=e[t];Object.defineProperty(e,t,Cn(Cn({},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":l("null-environment",function(){return us.inherit("null")},"(null-environment)\n\n Returns a clean environment with only the standard library."),values:l("values",function e(){for(var t=arguments.length,r=new Array(t),n=0;n1&&arguments[1]!==undefined?arguments[1]:{},v=e.use_dynamic,y=e.error;var m=this;var g;if(d.cdr instanceof M&&co.isString(d.cdr.car)&&d.cdr.cdr!==U){g=d.cdr.car.valueOf()}function b(){var c=da(this)?this:{dynamic_env:m},r=c.dynamic_env;var n=m.inherit("lambda");r=r.inherit("lambda");if(this&&!da(this)){if(this&&!this.__instance__){Object.defineProperty(this,"__instance__",{enumerable:false,get:function e(){return true},set:function e(){},configurable:false})}n.set("this",this)}for(var e=arguments.length,t=new Array(e),i=0;i>> "+c.toString());if(c){o=c}var v=r.merge(t,oa.__merge_env__);if(l){return{expr:o,scope:v}}var y=Ts(o,Cn(Cn({},_),{},{env:v}));return fa(y,d)}i=i.cdr}}catch(e){e.message+=" in macro: ".concat(m.toString(true));throw e}throw new Error("Invalid Syntax ".concat(e.toString(true)))},w);r.__code__=m;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:l(new na("quote",function(e){return Qo(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":l("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:l("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:na.defmacro("quasiquote",function(e,t){var o=t.use_dynamic,s=t.error;var c=this;var f=c;function a(e){return e instanceof M||Nu(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(ba(n)||ba(i)){return Mi([n,i]).then(function(e){var t=z(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(v.has(e)){return e.clone()}else{v.add(e);return e}});var n=l(i.cdr,0,1);if(n===U&&r[0]===U){return undefined}return tu(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 v=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 d(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"),d(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 tu(Ts(r.car,{env:c,dynamic_env:f,use_dynamic: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 tu(Ts(r.car,{env:c,dynamic_env:f,use_dynamic:o,error:s}),function(e){a.push(e);return t(r.cdr)})}(e.cdr)}else{return e.cdr}}else{return Ts(e.cdr.car,{env:c,dynamic_env:f,error:s})}}else{return e.cdr}}return h(e,function(e){return l(e,t,r)})}else if(Nu(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[Na];if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}}if(Nu(e.car)&&!r(Object.values(e.car))){return Qo(e.car)}if(Array.isArray(e.car)&&!r(e.car)){return Qo(e.car)}if(e.car instanceof M&&!e.car.find("unquote")&&!e.car.find("unquote-splicing")&&!e.car.find("quasiquote")){return Qo(e.car)}var i=l(e.car,0,1);return tu(i,function(e){n(e);return Qo(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:l("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:l("append",function e(){var t;for(var r=arguments.length,n=new Array(r),i=0;iarray")(t).reverse();return us.get("array->list")(r)}else if(Array.isArray(t)){return t.reverse()}else{throw new Error(ds("reverse",Es(t),"array or pair"))}},"(reverse list)\n\n Function that reverses the list or array. If value is not a list\n or array it will error."),nth:l("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:l("split",function e(t,r){h("split",t,["regex","string"]);h("split",r,"string");return us.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:l("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:l("match",function e(t,r){h("match",t,["regex","string"]);h("match",r,"string");var n=r.match(t);return n?us.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:l("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:l("repr",function e(t,r){return Gu(t,r)},"(repr obj)\n\n Function that returns a LIPS code representation of the object as a string."),"escape-regex":l("escape-regex",function(e){h("escape-regex",e,"string");return Fi(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:l("env",function e(e){e=e||this.env;var t=Object.keys(e.__env__).map(L);var r;if(t.length){r=M.fromArray(t)}else{r=U}if(e.__parent__ instanceof Go){return us.get("env").call(this,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:l("new",function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n2&&arguments[2]!==undefined?arguments[2]:Vi.LITERAL;h("set-special!",e,"string",1);h("set-special!",t,"symbol",2);Vi.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:Xo,".":Xo,unbind:l(Fa,"(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:l(Es,"(type object)\n\n Function that returns the type of an object as string."),debugger:l("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:l("in",function(e,t){if(e instanceof L||e instanceof co||e instanceof y){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:l("instanceof",function(e,t){return t instanceof Fa(e)},"(instanceof type obj)\n\n Predicate that tests if the obj is an instance of type."),"prototype?":l("prototype?",Hu,"(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?":l("macro?",function(e){return e instanceof na},"(macro? expression)\n\n Predicate that tests if value is a macro."),"function?":l("function?",pa,"(function? expression)\n\n Predicate that tests if value is a callable function."),"real?":l("real?",function(e){if(Es(e)!=="number"){return false}if(e instanceof y){return e.isFloat()}return y.isFloat(e)},"(real? number)\n\n Predicate that tests if value is a real number (not complex)."),"number?":l("number?",function(e){return Number.isNaN(e)||y.isNumber(e)},"(number? expression)\n\n Predicate that tests if value is a number or NaN value."),"string?":l("string?",function(e){return co.isString(e)},"(string? expression)\n\n Predicate that tests if value is a string."),"pair?":l("pair?",function(e){return e instanceof M},"(pair? expression)\n\n Predicate that tests if value is a pair or list structure."),"regex?":l("regex?",function(e){return e instanceof RegExp},"(regex? expression)\n\n Predicate that tests if value is a regular expression."),"null?":l("null?",function(e){return ha(e)},"(null? expression)\n\n Predicate that tests if value is null-ish (i.e. undefined, nil, or\n Javascript null)."),"boolean?":l("boolean?",function(e){return typeof e==="boolean"},"(boolean? expression)\n\n Predicate that tests if value is a boolean (#t or #f)."),"symbol?":l("symbol?",function(e){return e instanceof L},"(symbol? expression)\n\n Predicate that tests if value is a LIPS symbol."),"array?":l("array?",function(e){return e instanceof Array},"(array? expression)\n\n Predicate that tests if value is an array."),"object?":l("object?",function(e){return e!==U&&e!==null&&!(e instanceof so)&&!(e instanceof RegExp)&&!(e instanceof co)&&!(e instanceof M)&&!(e instanceof y)&&d(e)==="object"&&!(e instanceof Array)},"(object? expression)\n\n Predicate that tests if value is an plain object (not another LIPS type)."),flatten:l("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":l("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":l("tree->array",Iu("tree->array",true),"(tree->array list)\n\n Function that converts a LIPS cons tree structure into a JavaScript array."),"list->array":l("list->array",Iu("list->array"),"(list->array list)\n\n Function that converts a LIPS list into a JavaScript array."),apply:l("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,Cs(t,n))},"(apply fn list)\n\n Function that calls fn with the list of arguments."),length:l("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":l("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(si)||e.match(ui)){return pi(e,t)}else if(e.match(ci)||e.match(ii)){return vi(e,t)}else{var r=t===10&&!e.match(/e/i)||t===16;if(e.match(oi)&&r||e.match(ai)){return _i(e,t)}if(e.match(Gn)){return gi(e)}}return false},"(string->number number [radix])\n\n Function that parses a string into a number."),try:l(new na("try",function(t,e){var c=this;var r=e.use_dynamic,f=e.error;return new Promise(function(n,i){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=n;if(a){o=function e(t,r){o=i;tu(Ts(new M(new L("begin"),a.cdr),s),function(){r(t)})}}var s={env:c,use_dynamic:r,dynamic_env:c,error:function(t){function e(e){return t.apply(this,arguments)}e.toString=function(){return t.toString()};return e}(function(e){var t=c.inherit("try");if(u){t.set(u.cdr.car.car,e);var r={env:t,error:f};r.dynamic_env=c;tu(Ts(new M(new L("begin"),u.cdr.cdr),r),function(e){o(e,n)})}else{o(e,f)}})};var e=Ts(t.car,s);if(ba(e)){e.then(function(e){o(e,n)})["catch"](s.error)}else{o(e,n)}})}),"(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:l("raise",function(e){throw e},"(raise obj)\n\n Throws the object verbatim (no wrapping an a new Error)."),throw:l("throw",function(e){throw new Error(e)},"(throw string)\n\n Throws a new exception."),find:l("find",function t(r,n){h("find",r,["regex","function"]);h("find",n,["pair","nil"]);if(ha(n)){return U}var e=ou("find",r);return tu(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":l("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=ou("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 tu(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:l(eo,"(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:l(Xa,"(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:l(ao,"(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:l("gcd",function e(){for(var t=arguments.length,r=new Array(t),n=0;no?u%=o:o%=u}u=Qu(s*r[a])/(u+o)}return y(u)},"(lcm n1 n2 ...)\n\n Function that returns the least common multiple of the arguments."),"odd?":l("odd?",no(function(e){return y(e).isOdd()}),"(odd? number)\n\n Checks if number is odd."),"even?":l("even?",no(function(e){return y(e).isEven()}),"(even? number)\n\n Checks if number is even."),"*":l("*",uo(function(e,t){return y(e).mul(t)},y(1)),"(* . numbers)\n\n Multiplies all numbers passed as arguments. If single value is passed\n it will return that value."),"+":l("+",uo(function(e,t){return y(e).add(t)},y(0)),"(+ . numbers)\n\n Sums all numbers passed as arguments. If single value is passed it will\n return that value."),"-":l("-",function(){for(var e=arguments.length,t=new Array(e),r=0;r":l(">",function(){for(var e=arguments.length,t=new Array(e),r=0;r",t,"number");return Zu(function(e,t){return y(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."),"<":l("<",function(){for(var e=arguments.length,t=new Array(e),r=0;r=":l(">=",function(){for(var e=arguments.length,t=new Array(e),r=0;r=",t,"number");return Zu(function(e,t){return[0,1].includes(y(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?":l("eq?",Xu,"(eq? a b)\n\n Function that compares two values if they are identical."),or:l(new na("or",function(e,t){var i=t.use_dynamic,u=t.error;var a=us.get("list->array")(e);var o=this;var s=o;if(!a.length){return false}var c;return function t(){function e(e){c=e;if(c!==false){return c}else{return t()}}if(!a.length){if(c!==false){return c}else{return false}}else{var r=a.shift();var n=Ts(r,{env:o,dynamic_env:s,use_dynamic:i,error:u});return tu(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:l(new na("and",function(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},r=t.use_dynamic,n=t.error;var i=us.get("list->array")(e);var u=this;var a=u;if(!i.length){return true}var o;var s={env:u,dynamic_env:a,use_dynamic:r,error:n};return function t(){function e(e){o=e;if(o===false){return false}else{return t()}}if(!i.length){if(o!==false){return o}else{return false}}else{var r=i.shift();return tu(Ts(r,s),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."),"|":l("|",function(e,t){return y(e).or(t)},"(| a b)\n\n Function that calculates the bitwise or operation."),"&":l("&",function(e,t){return y(e).and(t)},"(& a b)\n\n Function that calculates the bitwise and operation."),"~":l("~",function(e){return y(e).neg()},"(~ number)\n\n Function that calculates the bitwise inverse (flip all the bits)."),">>":l(">>",function(e,t){return y(e).shr(t)},"(>> a b)\n\n Function that right shifts the value a by value b bits."),"<<":l("<<",function(e,t){return y(e).shl(t)},"(<< a b)\n\n Function that left shifts the value a by value b bits."),not:l("not",function e(t){if(ha(t)){return true}return!t},"(not object)\n\n Function that returns the Boolean negation of its argument.")},undefined,"global");var as=us.inherit("user-env");function os(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.");us.set("**interaction-environment**",e)}os(as,rs);us.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;us.set(r,l(r,function(e){h(r,e,"number");if(e instanceof y){return e[t]()}},"(".concat(r," number)\n\n Function that calculates the ").concat(r," of a number.")))})})();function ss(e){if(e.length===1){return e[0]}else{var t=[];var r=ss(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(pa(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 vs(r,e,n){e.forEach(function(e,t){h(r,e,n,t+1)})}function ys(e,t,r){h(e,t,r);if(t.__type__===zo){throw new Error(ds(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=Es(t).toLowerCase();if(pa(r)){if(!r(t)){throw new Error(ds(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(ds(e,i,r,n))}}function ms(e){var t=d(e);return["string","function"].includes(t)||d(e)==="symbol"||e instanceof Ui||e instanceof L||e instanceof y||e instanceof co||e instanceof RegExp}function gs(e){return e instanceof y||e instanceof co||e instanceof so}function bs(e,t){if(e===null){return false}return d(e)==="object"&&t in Object.getOwnPropertySymbols(e)}function ws(e,t){if(bs(e,t)||bs(e.__proto__,t)){return pa(e[t])}}function Ds(r){var n=new WeakMap;return function(e){var t=n.get(e);if(!t){t=r(e)}return t}}Es=Ds(Es);function Es(e){var t=In.get(e);if(t){return t}if(d(e)==="object"){for(var r=0,n=Object.entries(jn);r2&&arguments[2]!==undefined?arguments[2]:{},n=r.env,i=r.dynamic_env,u=r.use_dynamic;var a=n===null||n===void 0?void 0:n.new_frame(e,t);var o=i===null||i===void 0?void 0:i.new_frame(e,t);var s=new Is({env:a,use_dynamic:u,dynamic_env:o});return As(e.apply(s,t))}function Ss(n,e){var t=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},i=t.env,u=t.dynamic_env,a=t.use_dynamic,r=t.error,o=r===void 0?function(){}:r;e=xs(e,{env:i,dynamic_env:u,error:o,use_dynamic:a});return tu(e,function(e){if(Ga(n)){n=Fa(n)}e=Cs(n,e);var t=e.slice();var r=Os(n,t,{env:i,dynamic_env:u,use_dynamic:a});return tu(r,function(e){if(e instanceof M){e.markCycles();return Qo(e)}return Da(e)},o)})}var Bs=new WeakMap;var js=function(){function n(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;j(this,n);q(this,"__value__",void 0);q(this,"__fn__",void 0);bn(this,Bs,{writable:true,value:void 0});this.__value__=e;if(t){if(!pa(t)){throw new Error("Section argument to Parameter need to be function "+"".concat(Es(t)," given"))}this.__fn__=t}if(r){a(this,Bs,r)}}P(n,[{key:"__name__",get:function e(){return t(this,Bs)},set:function e(t){a(this,Bs,t);if(this.__fn__){this.__fn__.__name__="fn-".concat(t)}}},{key:"invoke",value:function e(){if(pa(this.__fn__)){return this.__fn__(this.__value__)}return this.__value__}},{key:"inherit",value:function e(t){return new n(t,this.__fn__,this.__name__)}}]);return n}();var Is=function(){function t(e){j(this,t);q(this,"env",void 0);q(this,"dynamic_env",void 0);q(this,"use_dynamic",void 0);Object.assign(this,e)}P(t,[{key:"__name__",get:function e(){return this.env.__name__}},{key:"__parent__",get:function e(){return this.env.__parent__}},{key:"get",value:function e(){var t;return(t=this.env).get.apply(t,arguments)}}]);return t}();function Ps(e,t){var r=e.get(t.__name__,{throwError:false});if(va(r)&&r!==t){return r}var n=as.get("**interaction-environment**");while(true){var i=e.get("parent.frame",{throwError:false});e=i(0);if(e===n){break}r=e.get(t.__name__,{throwError:false});if(va(r)&&r!==t){return r}}return t}var Ns=function(){function t(e){j(this,t);q(this,"__value__",void 0);this.__value__=e}P(t,[{key:"invoke",value:function e(){if(this.__value__===null){throw new Error("Continuations are not implemented yet")}}}]);return t}();var Rs=function e(){};function Ts(o){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},s=e.env,c=e.dynamic_env,f=e.use_dynamic,t=e.error,l=t===void 0?Rs:t,r=R(e,gn);return function(e){try{if(!ma(c)){c=s===true?as:s||as}if(f){s=c}else if(s===true){s=as}else{s=s||us}var t={env:s,dynamic_env:c,use_dynamic:f,error:l};var r;if(ha(o)){return o}if(o instanceof L){return s.get(o)}if(!(o instanceof M)){return o}var n=o.car;var e=o.cdr;if(n instanceof M){r=As(Ts(n,t));if(ba(r)){return r.then(function(e){if(!ga(e)){throw new Error(Es(e)+" "+s.get("repr")(e)+" is not callable while evaluating "+o.toString())}return Ts(new M(e,o.cdr),t)})}else if(!ga(r)){throw new Error(Es(r)+" "+s.get("repr")(r)+" is not callable while evaluating "+o.toString())}}if(n instanceof L){r=s.get(n)}else if(pa(n)){r=n}var i;if(r instanceof oa){i=Fs(r,o,t)}else if(r instanceof na){i=ks(r,e,t)}else if(pa(r)){i=Ss(r,e,t)}else if(va(r)){var u=Ps(c,r);if(ha(o.cdr)){i=u.invoke()}else{return tu(Ts(o.cdr.car,t),function(e){u.__value__=e})}}else if(_a(r)){i=r.invoke()}else if(o instanceof M){r=n&&n.toString();throw new Error("".concat(Es(n)," ").concat(r," is not a function"))}else{return o}var a=s.get(Symbol["for"]("__promise__"),{throwError:false});if(a===true&&ba(i)){i=i.then(function(e){if(e instanceof M&&!r[Na]){return Ts(e,t)}return e});return new Ui(i)}return i}catch(e){l&&l.call(s,e,o)}}(r)}var Ls=Ms(function(e){return e});var Us=Ms(function(e,t){return t});function Ms(y){return function(){var t=B(W.mark(function e(r){var n,i,u,h,a,p,o,s,_,c,d,f,v,l=arguments;return W.wrap(function e(t){while(1){switch(t.prev=t.next){case 0:n=l.length>1&&l[1]!==undefined?l[1]:{},i=n.env,u=n.dynamic_env,h=n.use_dynamic;if(!ma(u)){u=i===true?as:i||as}if(i===true){i=as}else{i=i||as}a=[];p=Array.isArray(r)?r:Xi(r);o=false;s=false;t.prev=7;c=On(p);case 9:t.next=11;return c.next();case 11:if(!(o=!(d=t.sent).done)){t.next=25;break}f=d.value;v=Ts(f,{env:i,dynamic_env:u,use_dynamic:h,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}});t.t0=a;t.t1=y;t.t2=f;t.next=19;return v;case 19:t.t3=t.sent;t.t4=(0,t.t1)(t.t2,t.t3);t.t0.push.call(t.t0,t.t4);case 22:o=false;t.next=9;break;case 25:t.next=31;break;case 27:t.prev=27;t.t5=t["catch"](7);s=true;_=t.t5;case 31:t.prev=31;t.prev=32;if(!(o&&c["return"]!=null)){t.next=36;break}t.next=36;return c["return"]();case 36:t.prev=36;if(!s){t.next=39;break}throw _;case 39:return t.finish(36);case 40:return t.finish(31);case 41:return t.abrupt("return",a);case 42:case"end":return t.stop()}}},e,null,[[7,27,31,41],[32,,36,40]])}));function e(e){return t.apply(this,arguments)}return e}()}function qs(e){var t={"[":"]","(":")"};var r;if(typeof e==="string"){r=Ii(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 ki;var a=An(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 zs(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 Bn.Worker(r.createObjectURL(n))}function Vs(){return bc.version.match(/^(\{\{VER\}\}|DEV)$/)}function Ys(){if(hs()){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 $s=Ys();function Js(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";var t="dist/std.xcb";if(e===""){if($s){e=$s.replace(/[^/]*$/,"std.xcb")}else if(Vs()){e="https://cdn.jsdelivr.net/gh/jcubic/lips@devel/".concat(t)}else{e="https://cdn.jsdelivr.net/npm/@jcubic/lips@".concat(bc.version,"/").concat(t)}}var r=us.get("load");return r.call(as,e,us)}function Ks(e){this.url=e;var a=this.worker=zs(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,{use_dynamic: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 bc.Interpreter("worker");o=Js(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,t){var r=t.use_dynamic,n=r===void 0?false:r;return this.rpc("eval",[e,n])}}var Gs={pair:function e(t){var r=z(t,2),n=r[0],i=r[1];return M(n,i)},number:function e(t){if(co.isString(t)){return y([t,10])}return y(t)},regex:function e(t){var r=z(t,2),n=r[0],i=r[1];return new RegExp(n,i)},nil:function e(){return U},symbol:function e(t){if(co.isString(t)){return L(t)}else if(Array.isArray(t)){return L(Symbol["for"](t[0]))}},string:co,character:so};var Hs=Object.keys(Gs);var Ws={};for(var Qs=0,Zs=Object.entries(Hs);Qs1){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 sc(){var e=1;var t=new TextEncoder("utf-8");return t.encode("LIPS".concat(e.toString().padStart(3," ")))}var cc=7;function fc(e){var t=new TextDecoder("utf-8");var r=t.decode(e.slice(0,cc));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 lc(e){var t=sc();var r=ac.encode(e);return oc(t,ln(r,{magic:false}))}function hc(e){var t=fc(e),r=t.type,n=t.version;if(r==="LIPS"&&n===1){var i=hn(e.slice(cc),{magic:false});return ac.decode(i)}else{throw new Error("Invalid file format ".concat(r))}}function pc(e){console.error(e.message||e);if(e.code){console.error(e.code.map(function(e,t){return"[".concat(t+1,"]: ").concat(e)}))}}function _c(){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(Us).then(t)["catch"](function(e){pc(e);t()})}else{return Us(r.innerHTML).then(t)["catch"](function(e){pc(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 Js(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(dc){var t=dc;var r=t.getAttribute("bootstrap");if(typeof r==="string"){return Js(r).then(function(){o=true;return e()})}}return e()}var dc=typeof window!=="undefined"&&window.document&&document.currentScript;if(typeof window!=="undefined"){Ln(window,_c)}var vc=function(){var e=co("Mon, 15 Jan 2024 14:02:37 +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 DEV (".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}();iu(pu,"__class__","ahead");iu(M,"__class__","pair");iu(ju,"__class__","nil");iu(_u,"__class__","pattern");iu(hu,"__class__","formatter");iu(na,"__class__","macro");iu(oa,"__class__","syntax");iu(Go,"__class__","environment");iu(Bo,"__class__","input-port");iu(jo,"__class__","output-port");iu(Io,"__class__","output-port");iu(Po,"__class__","output-string-port");iu(Ro,"__class__","input-string-port");iu(Uo,"__class__","input-file-port");iu(No,"__class__","output-file-port");iu(Ko,"__class__","lips-error");[y,Eo,Oo,Ao,So].forEach(function(e){iu(e,"__class__","number")});iu(so,"__class__","character");iu(L,"__class__","symbol");iu(co,"__class__","string");iu(Ui,"__class__","promise");iu(js,"__class__","parameter");var yc="DEV";var mc="Mon, 15 Jan 2024 14:02:37 +0000";var gc=eo(uu,Xi);var bc={version:yc,banner:vc,date:mc,exec:Us,parse:gc,tokenize:Ii,evaluate:Ts,compile:Ls,serialize:ic,unserialize:uc,serialize_bin:lc,unserialize_bin:hc,bootstrap:Js,Environment:Go,env:as,Worker:Ks,Interpreter:Jo,balanced_parenthesis:qs,balancedParenthesis:qs,balanced:qs,Macro:na,Syntax:oa,Pair:M,Values:Wo,QuotedPromise:Ui,Error:Ko,quote:Qo,InputPort:Bo,OutputPort:jo,BufferedOutputPort:Io,InputFilePort:Uo,OutputFilePort:No,InputStringPort:Ro,OutputStringPort:Po,InputByteVectorPort:To,OutputByteVectorPort:Lo,InputBinaryFilePort:Mo,OutputBinaryFilePort:qo,Formatter:hu,Parser:Qi,Lexer:s,specials:Vi,repr:Pu,nil:U,eof:Yo,LSymbol:L,LNumber:y,LFloat:Ao,LComplex:Eo,LRational:Oo,LBigInteger:So,LCharacter:so,LString:co,Parameter:js,rationalize:ko};us.set("lips",bc);var wc={};var Dc=Object.freeze({__proto__:null,default:wc});function Ec(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 Ac=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var xc=function(e){return Ac.exec(e).slice(1)};function Fc(){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=Ec(Tc(e.split("/"),function(e){return!!e}),!t).join("/");return(t?"/":"")+e||"."}function kc(e){var t=Cc(e),r=Lc(e,-1)==="/";e=Ec(Tc(e.split("/"),function(e){return!!e}),!t).join("/");if(!e&&!t){e="."}if(e&&r){e+="/"}return(t?"/":"")+e}function Cc(e){return e.charAt(0)==="/"}function Oc(){var e=Array.prototype.slice.call(arguments,0);return kc(Tc(e,function(e,t){if(typeof e!=="string"){throw new TypeError("Arguments to path.join must be strings")}return e}).join("/"))}function Sc(e,t){e=Fc(e).substr(1);t=Fc(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 'everything.js' + }, + ...base() + }, + { + output: { + name: "lips", + file: "dist/lips.cjs", + format: "cjs", manualChunks: () => 'everything.js' }, ...base() @@ -59,9 +63,6 @@ export default [ name: "lips", file: "dist/lips.esm.js", format: "esm", - globals: { - "@babel/runtime/regenerator": "regeneratorRuntime" - }, manualChunks: () => 'everything.js' }, ...base() diff --git a/src/lips.js b/src/lips.js index 8a55c7179..2654d6f88 100644 --- a/src/lips.js +++ b/src/lips.js @@ -1696,7 +1696,7 @@ class DatumReference { // :: or macro assigned to symbol, this function is async because // :: it evaluates the code, from parser extensions, that may return a promise. // ---------------------------------------------------------------------- -async function* parse(arg, env) { +async function* _parse(arg, env) { if (!env) { if (global_env) { env = global_env.get('**interaction-environment**', { @@ -6946,7 +6946,7 @@ Unquote.prototype.toString = function() { return '#'; }; // ------------------------------------------------------------------------------- -var native_lambda = parse(tokenize(`(lambda () +var native_lambda = _parse(tokenize(`(lambda () "[native code]" (throw "Invalid Invocation"))`))[0]; // ------------------------------------------------------------------------------- @@ -7087,7 +7087,7 @@ var global_env = new Environment({ read: doc('read', async function read(arg = null) { const { env } = this; if (LString.isString(arg)) { - for await (let value of parse(arg, env)) { + for await (let value of _parse(arg, env)) { return value; } } @@ -9672,7 +9672,7 @@ function is_node() { // ------------------------------------------------------------------------- async function node_specific() { - const { createRequire } = await import('module'); + const { createRequire } = await import('mod' + 'ule'); nodeRequire = createRequire(import.meta.url); fs = await import('fs'); path = await import('path'); @@ -10275,7 +10275,7 @@ function exec_collect(collect_callback) { env = env || user_env; } var results = []; - var input = Array.isArray(arg) ? arg : parse(arg); + var input = Array.isArray(arg) ? arg : _parse(arg); for await (let code of input) { const value = evaluate(code, { env, @@ -10837,13 +10837,86 @@ read_only(LString, '__class__', 'string'); read_only(QuotedPromise, '__class__', 'promise'); read_only(Parameter, '__class__', 'parameter'); // ------------------------------------------------------------------------- +const version = '{{VER}}'; +const date = '{{DATE}}'; + +// unwrap async generator into Promise +const parse = compose(uniterate_async, _parse); + +export { + version, + banner, + date, + exec, + parse, + tokenize, + evaluate, + compile, + + serialize, + unserialize, + + serialize_bin, + unserialize_bin, + + bootstrap, + + Environment, + user_env as env, + + Worker, + + Interpreter, + balanced as balanced_parenthesis, + balanced as balancedParenthesis, + balanced, + + Macro, + Syntax, + Pair, + Values, + QuotedPromise, + LipsError as Error, + + quote, + + InputPort, + OutputPort, + BufferedOutputPort, + InputFilePort, + OutputFilePort, + InputStringPort, + OutputStringPort, + InputByteVectorPort, + OutputByteVectorPort, + InputBinaryFilePort, + OutputBinaryFilePort, + + Formatter, + Parser, + Lexer, + specials, + repr, + nil, + eof, + + LSymbol, + LNumber, + LFloat, + LComplex, + LRational, + LBigInteger, + LCharacter, + LString, + Parameter, + rationalize +}; const lips = { - version: '{{VER}}', + version, banner, - date: '{{DATE}}', + date, exec, - // unwrap async generator into Promise - parse: compose(uniterate_async, parse), + parse, tokenize, evaluate, compile, @@ -10906,6 +10979,4 @@ const lips = { Parameter, rationalize }; -// so it work when used with webpack where it will be not global -export default lips; global_env.set('lips', lips); diff --git a/tests/test.js b/tests/test.js index ad2ab74b2..63beb483e 100644 --- a/tests/test.js +++ b/tests/test.js @@ -14,7 +14,7 @@ import { promisify } from 'util'; import fs from 'fs'; import util from 'util'; -import lips from '../src/lips.js'; +import { exec } from '../src/lips.js'; const readDir = promisify(fs.readdir); const readFile = promisify(fs.readFile); @@ -35,13 +35,13 @@ get_files().then(filenames => { return Promise.all(filenames.map(function(file) { return readFile(`tests/${file}`, 'utf8'); })).then(async function (files) { - await lips.exec(` + await exec(` (let-env lips.env.__parent__ (load "./dist/std.xcb") (load "./tests/helpers/helpers.scm")) (define test (require "ava")) `); - return lips.exec(files.join('\n\n')); + return exec(files.join('\n\n')); }).catch(e => { console.error(e.message); console.error(e.stack);