not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3887 lines
134 KiB

  1. var ρσ_iterator_symbol = (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") ? Symbol.iterator : "iterator-Symbol-5d0927e5554349048cf0e3762a228256";
  2. var ρσ_kwargs_symbol = (typeof Symbol === "function") ? Symbol("kwargs-object") : "kwargs-object-Symbol-5d0927e5554349048cf0e3762a228256";
  3. var ρσ_cond_temp, ρσ_expr_temp, ρσ_last_exception;
  4. var ρσ_object_counter = 0;
  5. var ρσ_len;
  6. function ρσ_bool(val) {
  7. return !!val;
  8. };
  9. if (!ρσ_bool.__argnames__) Object.defineProperties(ρσ_bool, {
  10. __argnames__ : {value: ["val"]}
  11. });
  12. function ρσ_print() {
  13. var parts;
  14. if (typeof console === "object") {
  15. parts = [];
  16. for (var i = 0; i < arguments.length; i++) {
  17. parts.push(ρσ_str(arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i]));
  18. }
  19. console.log(parts.join(" "));
  20. }
  21. };
  22. function ρσ_int(val, base) {
  23. var ans;
  24. ans = parseInt(val, base || 10);
  25. if (isNaN(ans)) {
  26. throw new ValueError("Invalid literal for int with base " + (base || 10) + ": " + val);
  27. }
  28. return ans;
  29. };
  30. if (!ρσ_int.__argnames__) Object.defineProperties(ρσ_int, {
  31. __argnames__ : {value: ["val", "base"]}
  32. });
  33. function ρσ_float() {
  34. var ans;
  35. ans = parseFloat.apply(null, arguments);
  36. if (isNaN(ans)) {
  37. throw new ValueError("Could not convert string to float: " + arguments[0]);
  38. }
  39. return ans;
  40. };
  41. function ρσ_arraylike_creator() {
  42. var names;
  43. names = "Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" ");
  44. if (typeof HTMLCollection === "function") {
  45. names = names.concat("HTMLCollection NodeList NamedNodeMap TouchList".split(" "));
  46. }
  47. return (function() {
  48. var ρσ_anonfunc = function (x) {
  49. if (Array.isArray(x) || typeof x === "string" || names.indexOf(Object.prototype.toString.call(x).slice(8, -1)) > -1) {
  50. return true;
  51. }
  52. return false;
  53. };
  54. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  55. __argnames__ : {value: ["x"]}
  56. });
  57. return ρσ_anonfunc;
  58. })();
  59. };
  60. function options_object(f) {
  61. return function () {
  62. if (typeof arguments[arguments.length - 1] === "object") {
  63. arguments[ρσ_bound_index(arguments.length - 1, arguments)][ρσ_kwargs_symbol] = true;
  64. }
  65. return f.apply(this, arguments);
  66. };
  67. };
  68. if (!options_object.__argnames__) Object.defineProperties(options_object, {
  69. __argnames__ : {value: ["f"]}
  70. });
  71. function ρσ_id(x) {
  72. return x.ρσ_object_id;
  73. };
  74. if (!ρσ_id.__argnames__) Object.defineProperties(ρσ_id, {
  75. __argnames__ : {value: ["x"]}
  76. });
  77. function ρσ_dir(item) {
  78. var arr;
  79. arr = ρσ_list_decorate([]);
  80. for (var i in item) {
  81. arr.push(i);
  82. }
  83. return arr;
  84. };
  85. if (!ρσ_dir.__argnames__) Object.defineProperties(ρσ_dir, {
  86. __argnames__ : {value: ["item"]}
  87. });
  88. function ρσ_ord(x) {
  89. var ans, second;
  90. ans = x.charCodeAt(0);
  91. if (55296 <= ans && ans <= 56319) {
  92. second = x.charCodeAt(1);
  93. if (56320 <= second && second <= 57343) {
  94. return (ans - 55296) * 1024 + second - 56320 + 65536;
  95. }
  96. throw new TypeError("string is missing the low surrogate char");
  97. }
  98. return ans;
  99. };
  100. if (!ρσ_ord.__argnames__) Object.defineProperties(ρσ_ord, {
  101. __argnames__ : {value: ["x"]}
  102. });
  103. function ρσ_chr(code) {
  104. if (code <= 65535) {
  105. return String.fromCharCode(code);
  106. }
  107. code -= 65536;
  108. return String.fromCharCode(55296 + (code >> 10), 56320 + (code & 1023));
  109. };
  110. if (!ρσ_chr.__argnames__) Object.defineProperties(ρσ_chr, {
  111. __argnames__ : {value: ["code"]}
  112. });
  113. function ρσ_callable(x) {
  114. return typeof x === "function";
  115. };
  116. if (!ρσ_callable.__argnames__) Object.defineProperties(ρσ_callable, {
  117. __argnames__ : {value: ["x"]}
  118. });
  119. function ρσ_bin(x) {
  120. var ans;
  121. if (typeof x !== "number" || x % 1 !== 0) {
  122. throw new TypeError("integer required");
  123. }
  124. ans = x.toString(2);
  125. if (ans[0] === "-") {
  126. ans = "-" + "0b" + ans.slice(1);
  127. } else {
  128. ans = "0b" + ans;
  129. }
  130. return ans;
  131. };
  132. if (!ρσ_bin.__argnames__) Object.defineProperties(ρσ_bin, {
  133. __argnames__ : {value: ["x"]}
  134. });
  135. function ρσ_hex(x) {
  136. var ans;
  137. if (typeof x !== "number" || x % 1 !== 0) {
  138. throw new TypeError("integer required");
  139. }
  140. ans = x.toString(16);
  141. if (ans[0] === "-") {
  142. ans = "-" + "0x" + ans.slice(1);
  143. } else {
  144. ans = "0x" + ans;
  145. }
  146. return ans;
  147. };
  148. if (!ρσ_hex.__argnames__) Object.defineProperties(ρσ_hex, {
  149. __argnames__ : {value: ["x"]}
  150. });
  151. function ρσ_enumerate(iterable) {
  152. var ans, iterator;
  153. ans = {"_i":-1};
  154. ans[ρσ_iterator_symbol] = function () {
  155. return this;
  156. };
  157. if (ρσ_arraylike(iterable)) {
  158. ans["next"] = function () {
  159. this._i += 1;
  160. if (this._i < iterable.length) {
  161. return {'done':false, 'value':[this._i, iterable[this._i]]};
  162. }
  163. return {'done':true};
  164. };
  165. return ans;
  166. }
  167. if (typeof iterable[ρσ_iterator_symbol] === "function") {
  168. iterator = (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol]();
  169. ans["_iterator"] = iterator;
  170. ans["next"] = function () {
  171. var r;
  172. r = this._iterator.next();
  173. if (r.done) {
  174. return {'done':true};
  175. }
  176. this._i += 1;
  177. return {'done':false, 'value':[this._i, r.value]};
  178. };
  179. return ans;
  180. }
  181. return ρσ_enumerate(Object.keys(iterable));
  182. };
  183. if (!ρσ_enumerate.__argnames__) Object.defineProperties(ρσ_enumerate, {
  184. __argnames__ : {value: ["iterable"]}
  185. });
  186. function ρσ_reversed(iterable) {
  187. var ans;
  188. if (ρσ_arraylike(iterable)) {
  189. ans = {"_i": iterable.length};
  190. ans["next"] = function () {
  191. this._i -= 1;
  192. if (this._i > -1) {
  193. return {'done':false, 'value':iterable[this._i]};
  194. }
  195. return {'done':true};
  196. };
  197. ans[ρσ_iterator_symbol] = function () {
  198. return this;
  199. };
  200. return ans;
  201. }
  202. throw new TypeError("reversed() can only be called on arrays or strings");
  203. };
  204. if (!ρσ_reversed.__argnames__) Object.defineProperties(ρσ_reversed, {
  205. __argnames__ : {value: ["iterable"]}
  206. });
  207. function ρσ_iter(iterable) {
  208. var ans;
  209. if (typeof iterable[ρσ_iterator_symbol] === "function") {
  210. return (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol]();
  211. }
  212. if (ρσ_arraylike(iterable)) {
  213. ans = {"_i":-1};
  214. ans[ρσ_iterator_symbol] = function () {
  215. return this;
  216. };
  217. ans["next"] = function () {
  218. this._i += 1;
  219. if (this._i < iterable.length) {
  220. return {'done':false, 'value':iterable[this._i]};
  221. }
  222. return {'done':true};
  223. };
  224. return ans;
  225. }
  226. return ρσ_iter(Object.keys(iterable));
  227. };
  228. if (!ρσ_iter.__argnames__) Object.defineProperties(ρσ_iter, {
  229. __argnames__ : {value: ["iterable"]}
  230. });
  231. function ρσ_range_next(step, length) {
  232. var ρσ_unpack;
  233. this._i += step;
  234. this._idx += 1;
  235. if (this._idx >= length) {
  236. ρσ_unpack = [this.__i, -1];
  237. this._i = ρσ_unpack[0];
  238. this._idx = ρσ_unpack[1];
  239. return {'done':true};
  240. }
  241. return {'done':false, 'value':this._i};
  242. };
  243. if (!ρσ_range_next.__argnames__) Object.defineProperties(ρσ_range_next, {
  244. __argnames__ : {value: ["step", "length"]}
  245. });
  246. function ρσ_range(start, stop, step) {
  247. var length, ans;
  248. if (arguments.length <= 1) {
  249. stop = start || 0;
  250. start = 0;
  251. }
  252. step = arguments[2] || 1;
  253. length = Math.max(Math.ceil((stop - start) / step), 0);
  254. ans = {start:start, step:step, stop:stop};
  255. ans[ρσ_iterator_symbol] = function () {
  256. var it;
  257. it = {"_i": start - step, "_idx": -1};
  258. it.next = ρσ_range_next.bind(it, step, length);
  259. it[ρσ_iterator_symbol] = function () {
  260. return this;
  261. };
  262. return it;
  263. };
  264. ans.count = (function() {
  265. var ρσ_anonfunc = function (val) {
  266. if (!this._cached) {
  267. this._cached = list(this);
  268. }
  269. return this._cached.count(val);
  270. };
  271. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  272. __argnames__ : {value: ["val"]}
  273. });
  274. return ρσ_anonfunc;
  275. })();
  276. ans.index = (function() {
  277. var ρσ_anonfunc = function (val) {
  278. if (!this._cached) {
  279. this._cached = list(this);
  280. }
  281. return this._cached.index(val);
  282. };
  283. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  284. __argnames__ : {value: ["val"]}
  285. });
  286. return ρσ_anonfunc;
  287. })();
  288. if (typeof Proxy === "function") {
  289. ans = new Proxy(ans, (function(){
  290. var ρσ_d = {};
  291. ρσ_d["get"] = (function() {
  292. var ρσ_anonfunc = function (obj, prop) {
  293. var iprop;
  294. if (typeof prop === "string") {
  295. iprop = parseInt(prop);
  296. if (!isNaN(iprop)) {
  297. prop = iprop;
  298. }
  299. }
  300. if (typeof prop === "number") {
  301. if (!obj._cached) {
  302. obj._cached = list(obj);
  303. }
  304. return (ρσ_expr_temp = obj._cached)[(typeof prop === "number" && prop < 0) ? ρσ_expr_temp.length + prop : prop];
  305. }
  306. return obj[(typeof prop === "number" && prop < 0) ? obj.length + prop : prop];
  307. };
  308. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  309. __argnames__ : {value: ["obj", "prop"]}
  310. });
  311. return ρσ_anonfunc;
  312. })();
  313. return ρσ_d;
  314. }).call(this));
  315. }
  316. return ans;
  317. };
  318. if (!ρσ_range.__argnames__) Object.defineProperties(ρσ_range, {
  319. __argnames__ : {value: ["start", "stop", "step"]}
  320. });
  321. function ρσ_getattr(obj, name, defval) {
  322. var ret;
  323. try {
  324. ret = obj[(typeof name === "number" && name < 0) ? obj.length + name : name];
  325. } catch (ρσ_Exception) {
  326. ρσ_last_exception = ρσ_Exception;
  327. if (ρσ_Exception instanceof TypeError) {
  328. if (defval === undefined) {
  329. throw new AttributeError("The attribute " + name + " is not present");
  330. }
  331. return defval;
  332. } else {
  333. throw ρσ_Exception;
  334. }
  335. }
  336. if (ret === undefined && !(name in obj)) {
  337. if (defval === undefined) {
  338. throw new AttributeError("The attribute " + name + " is not present");
  339. }
  340. ret = defval;
  341. }
  342. return ret;
  343. };
  344. if (!ρσ_getattr.__argnames__) Object.defineProperties(ρσ_getattr, {
  345. __argnames__ : {value: ["obj", "name", "defval"]}
  346. });
  347. function ρσ_setattr(obj, name, value) {
  348. obj[(typeof name === "number" && name < 0) ? obj.length + name : name] = value;
  349. };
  350. if (!ρσ_setattr.__argnames__) Object.defineProperties(ρσ_setattr, {
  351. __argnames__ : {value: ["obj", "name", "value"]}
  352. });
  353. function ρσ_hasattr(obj, name) {
  354. return name in obj;
  355. };
  356. if (!ρσ_hasattr.__argnames__) Object.defineProperties(ρσ_hasattr, {
  357. __argnames__ : {value: ["obj", "name"]}
  358. });
  359. ρσ_len = function () {
  360. function len(obj) {
  361. if (ρσ_arraylike(obj)) {
  362. return obj.length;
  363. }
  364. if (typeof obj.__len__ === "function") {
  365. return obj.__len__();
  366. }
  367. if (obj instanceof Set || obj instanceof Map) {
  368. return obj.size;
  369. }
  370. return Object.keys(obj).length;
  371. };
  372. if (!len.__argnames__) Object.defineProperties(len, {
  373. __argnames__ : {value: ["obj"]}
  374. });
  375. function len5(obj) {
  376. if (ρσ_arraylike(obj)) {
  377. return obj.length;
  378. }
  379. if (typeof obj.__len__ === "function") {
  380. return obj.__len__();
  381. }
  382. return Object.keys(obj).length;
  383. };
  384. if (!len5.__argnames__) Object.defineProperties(len5, {
  385. __argnames__ : {value: ["obj"]}
  386. });
  387. return (typeof Set === "function" && typeof Map === "function") ? len : len5;
  388. }();
  389. function ρσ_get_module(name) {
  390. return ρσ_modules[(typeof name === "number" && name < 0) ? ρσ_modules.length + name : name];
  391. };
  392. if (!ρσ_get_module.__argnames__) Object.defineProperties(ρσ_get_module, {
  393. __argnames__ : {value: ["name"]}
  394. });
  395. function ρσ_pow(x, y, z) {
  396. var ans;
  397. ans = Math.pow(x, y);
  398. if (z !== undefined) {
  399. ans %= z;
  400. }
  401. return ans;
  402. };
  403. if (!ρσ_pow.__argnames__) Object.defineProperties(ρσ_pow, {
  404. __argnames__ : {value: ["x", "y", "z"]}
  405. });
  406. function ρσ_type(x) {
  407. return x.constructor;
  408. };
  409. if (!ρσ_type.__argnames__) Object.defineProperties(ρσ_type, {
  410. __argnames__ : {value: ["x"]}
  411. });
  412. function ρσ_divmod(x, y) {
  413. var d;
  414. if (y === 0) {
  415. throw new ZeroDivisionError("integer division or modulo by zero");
  416. }
  417. d = Math.floor(x / y);
  418. return [d, x - d * y];
  419. };
  420. if (!ρσ_divmod.__argnames__) Object.defineProperties(ρσ_divmod, {
  421. __argnames__ : {value: ["x", "y"]}
  422. });
  423. function ρσ_max() {
  424. var kwargs = arguments[arguments.length-1];
  425. if (kwargs === null || typeof kwargs !== "object" || kwargs [ρσ_kwargs_symbol] !== true) kwargs = {};
  426. var args = Array.prototype.slice.call(arguments, 0);
  427. if (kwargs !== null && typeof kwargs === "object" && kwargs [ρσ_kwargs_symbol] === true) args.pop();
  428. var args, x;
  429. if (args.length === 0) {
  430. if (kwargs.defval !== undefined) {
  431. return kwargs.defval;
  432. }
  433. throw new TypeError("expected at least one argument");
  434. }
  435. if (args.length === 1) {
  436. args = args[0];
  437. }
  438. if (kwargs.key) {
  439. args = (function() {
  440. var ρσ_Iter = ρσ_Iterable(args), ρσ_Result = [], x;
  441. for (var ρσ_Index = 0; ρσ_Index < ρσ_Iter.length; ρσ_Index++) {
  442. x = ρσ_Iter[ρσ_Index];
  443. ρσ_Result.push(kwargs.key(x));
  444. }
  445. ρσ_Result = ρσ_list_constructor(ρσ_Result);
  446. return ρσ_Result;
  447. })();
  448. }
  449. if (!Array.isArray(args)) {
  450. args = list(args);
  451. }
  452. if (args.length) {
  453. return this.apply(null, args);
  454. }
  455. if (kwargs.defval !== undefined) {
  456. return kwargs.defval;
  457. }
  458. throw new TypeError("expected at least one argument");
  459. };
  460. if (!ρσ_max.__handles_kwarg_interpolation__) Object.defineProperties(ρσ_max, {
  461. __handles_kwarg_interpolation__ : {value: true}
  462. });
  463. var abs = Math.abs, max = ρσ_max.bind(Math.max), min = ρσ_max.bind(Math.min), bool = ρσ_bool, type = ρσ_type;
  464. var float = ρσ_float, int = ρσ_int, arraylike = ρσ_arraylike_creator(), ρσ_arraylike = arraylike;
  465. var print = ρσ_print, id = ρσ_id, get_module = ρσ_get_module, pow = ρσ_pow, divmod = ρσ_divmod;
  466. var dir = ρσ_dir, ord = ρσ_ord, chr = ρσ_chr, bin = ρσ_bin, hex = ρσ_hex, callable = ρσ_callable;
  467. var enumerate = ρσ_enumerate, iter = ρσ_iter, reversed = ρσ_reversed, len = ρσ_len;
  468. var range = ρσ_range, getattr = ρσ_getattr, setattr = ρσ_setattr, hasattr = ρσ_hasattr;function ρσ_equals(a, b) {
  469. var ρσ_unpack, akeys, bkeys, key;
  470. if (a === b) {
  471. return true;
  472. }
  473. if (a && typeof a.__eq__ === "function") {
  474. return a.__eq__(b);
  475. }
  476. if (b && typeof b.__eq__ === "function") {
  477. return b.__eq__(a);
  478. }
  479. if (ρσ_arraylike(a) && ρσ_arraylike(b)) {
  480. if ((a.length !== b.length && (typeof a.length !== "object" || ρσ_not_equals(a.length, b.length)))) {
  481. return false;
  482. }
  483. for (var i=0; i < a.length; i++) {
  484. if (!((a[(typeof i === "number" && i < 0) ? a.length + i : i] === b[(typeof i === "number" && i < 0) ? b.length + i : i] || typeof a[(typeof i === "number" && i < 0) ? a.length + i : i] === "object" && ρσ_equals(a[(typeof i === "number" && i < 0) ? a.length + i : i], b[(typeof i === "number" && i < 0) ? b.length + i : i])))) {
  485. return false;
  486. }
  487. }
  488. return true;
  489. }
  490. if (typeof a === "object" && typeof b === "object" && a !== null && b !== null && (a.constructor === Object && b.constructor === Object || Object.getPrototypeOf(a) === null && Object.getPrototypeOf(b) === null)) {
  491. ρσ_unpack = [Object.keys(a), Object.keys(b)];
  492. akeys = ρσ_unpack[0];
  493. bkeys = ρσ_unpack[1];
  494. if (akeys.length !== bkeys.length) {
  495. return false;
  496. }
  497. for (var j=0; j < akeys.length; j++) {
  498. key = akeys[(typeof j === "number" && j < 0) ? akeys.length + j : j];
  499. if (!((a[(typeof key === "number" && key < 0) ? a.length + key : key] === b[(typeof key === "number" && key < 0) ? b.length + key : key] || typeof a[(typeof key === "number" && key < 0) ? a.length + key : key] === "object" && ρσ_equals(a[(typeof key === "number" && key < 0) ? a.length + key : key], b[(typeof key === "number" && key < 0) ? b.length + key : key])))) {
  500. return false;
  501. }
  502. }
  503. return true;
  504. }
  505. return false;
  506. };
  507. if (!ρσ_equals.__argnames__) Object.defineProperties(ρσ_equals, {
  508. __argnames__ : {value: ["a", "b"]}
  509. });
  510. function ρσ_not_equals(a, b) {
  511. if (a === b) {
  512. return false;
  513. }
  514. if (a && typeof a.__ne__ === "function") {
  515. return a.__ne__(b);
  516. }
  517. if (b && typeof b.__ne__ === "function") {
  518. return b.__ne__(a);
  519. }
  520. return !ρσ_equals(a, b);
  521. };
  522. if (!ρσ_not_equals.__argnames__) Object.defineProperties(ρσ_not_equals, {
  523. __argnames__ : {value: ["a", "b"]}
  524. });
  525. var equals = ρσ_equals;
  526. function ρσ_list_extend(iterable) {
  527. var start, iterator, result;
  528. if (Array.isArray(iterable) || typeof iterable === "string") {
  529. start = this.length;
  530. this.length += iterable.length;
  531. for (var i = 0; i < iterable.length; i++) {
  532. (ρσ_expr_temp = this)[ρσ_bound_index(start + i, ρσ_expr_temp)] = iterable[(typeof i === "number" && i < 0) ? iterable.length + i : i];
  533. }
  534. } else {
  535. iterator = (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol]();
  536. result = iterator.next();
  537. while (!result.done) {
  538. this.push(result.value);
  539. result = iterator.next();
  540. }
  541. }
  542. };
  543. if (!ρσ_list_extend.__argnames__) Object.defineProperties(ρσ_list_extend, {
  544. __argnames__ : {value: ["iterable"]}
  545. });
  546. function ρσ_list_index(val, start, stop) {
  547. var idx;
  548. start = start || 0;
  549. if (start < 0) {
  550. start = this.length + start;
  551. }
  552. if (start < 0) {
  553. throw new ValueError(val + " is not in list");
  554. }
  555. if (stop === undefined) {
  556. idx = this.indexOf(val, start);
  557. if (idx === -1) {
  558. throw new ValueError(val + " is not in list");
  559. }
  560. return idx;
  561. }
  562. if (stop < 0) {
  563. stop = this.length + stop;
  564. }
  565. for (var i = start; i < stop; i++) {
  566. if (((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === val || typeof (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === "object" && ρσ_equals((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i], val))) {
  567. return i;
  568. }
  569. }
  570. throw new ValueError(val + " is not in list");
  571. };
  572. if (!ρσ_list_index.__argnames__) Object.defineProperties(ρσ_list_index, {
  573. __argnames__ : {value: ["val", "start", "stop"]}
  574. });
  575. function ρσ_list_pop(index) {
  576. var ans;
  577. if (this.length === 0) {
  578. throw new IndexError("list is empty");
  579. }
  580. ans = this.splice(index, 1);
  581. if (!ans.length) {
  582. throw new IndexError("pop index out of range");
  583. }
  584. return ans[0];
  585. };
  586. if (!ρσ_list_pop.__argnames__) Object.defineProperties(ρσ_list_pop, {
  587. __argnames__ : {value: ["index"]}
  588. });
  589. function ρσ_list_remove(value) {
  590. var idx;
  591. idx = this.indexOf(value);
  592. if (idx === -1) {
  593. throw new ValueError(value + " not in list");
  594. }
  595. this.splice(idx, 1);
  596. };
  597. if (!ρσ_list_remove.__argnames__) Object.defineProperties(ρσ_list_remove, {
  598. __argnames__ : {value: ["value"]}
  599. });
  600. function ρσ_list_to_string() {
  601. return "[" + this.join(", ") + "]";
  602. };
  603. function ρσ_list_insert(index, val) {
  604. if (index < 0) {
  605. index += this.length;
  606. }
  607. index = min(this.length, max(index, 0));
  608. if (index === 0) {
  609. this.unshift(val);
  610. return;
  611. }
  612. for (var i = this.length; i > index; i--) {
  613. (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] = (ρσ_expr_temp = this)[ρσ_bound_index(i - 1, ρσ_expr_temp)];
  614. }
  615. (ρσ_expr_temp = this)[(typeof index === "number" && index < 0) ? ρσ_expr_temp.length + index : index] = val;
  616. };
  617. if (!ρσ_list_insert.__argnames__) Object.defineProperties(ρσ_list_insert, {
  618. __argnames__ : {value: ["index", "val"]}
  619. });
  620. function ρσ_list_copy() {
  621. return ρσ_list_constructor(this);
  622. };
  623. function ρσ_list_clear() {
  624. this.length = 0;
  625. };
  626. function ρσ_list_as_array() {
  627. return Array.prototype.slice.call(this);
  628. };
  629. function ρσ_list_count(value) {
  630. return this.reduce((function() {
  631. var ρσ_anonfunc = function (n, val) {
  632. return n + (val === value);
  633. };
  634. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  635. __argnames__ : {value: ["n", "val"]}
  636. });
  637. return ρσ_anonfunc;
  638. })(), 0);
  639. };
  640. if (!ρσ_list_count.__argnames__) Object.defineProperties(ρσ_list_count, {
  641. __argnames__ : {value: ["value"]}
  642. });
  643. function ρσ_list_sort_key(value) {
  644. var t;
  645. t = typeof value;
  646. if (t === "string" || t === "number") {
  647. return value;
  648. }
  649. return value.toString();
  650. };
  651. if (!ρσ_list_sort_key.__argnames__) Object.defineProperties(ρσ_list_sort_key, {
  652. __argnames__ : {value: ["value"]}
  653. });
  654. function ρσ_list_sort_cmp(a, b, ap, bp) {
  655. if (a < b) {
  656. return -1;
  657. }
  658. if (a > b) {
  659. return 1;
  660. }
  661. return ap - bp;
  662. };
  663. if (!ρσ_list_sort_cmp.__argnames__) Object.defineProperties(ρσ_list_sort_cmp, {
  664. __argnames__ : {value: ["a", "b", "ap", "bp"]}
  665. });
  666. function ρσ_list_sort() {
  667. var key = (arguments[0] === undefined || ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? ρσ_list_sort.__defaults__.key : arguments[0];
  668. var reverse = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? ρσ_list_sort.__defaults__.reverse : arguments[1];
  669. var ρσ_kwargs_obj = arguments[arguments.length-1];
  670. if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {};
  671. if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "key")){
  672. key = ρσ_kwargs_obj.key;
  673. }
  674. if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "reverse")){
  675. reverse = ρσ_kwargs_obj.reverse;
  676. }
  677. var mult, keymap, posmap, k;
  678. key = key || ρσ_list_sort_key;
  679. mult = (reverse) ? -1 : 1;
  680. keymap = dict();
  681. posmap = dict();
  682. for (var i=0; i < this.length; i++) {
  683. k = (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i];
  684. keymap.set(k, key(k));
  685. posmap.set(k, i);
  686. }
  687. this.sort((function() {
  688. var ρσ_anonfunc = function (a, b) {
  689. return mult * ρσ_list_sort_cmp(keymap.get(a), keymap.get(b), posmap.get(a), posmap.get(b));
  690. };
  691. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  692. __argnames__ : {value: ["a", "b"]}
  693. });
  694. return ρσ_anonfunc;
  695. })());
  696. };
  697. if (!ρσ_list_sort.__defaults__) Object.defineProperties(ρσ_list_sort, {
  698. __defaults__ : {value: {key:null, reverse:false}},
  699. __handles_kwarg_interpolation__ : {value: true},
  700. __argnames__ : {value: ["key", "reverse"]}
  701. });
  702. function ρσ_list_concat() {
  703. var ans;
  704. ans = Array.prototype.concat.apply(this, arguments);
  705. ρσ_list_decorate(ans);
  706. return ans;
  707. };
  708. function ρσ_list_slice() {
  709. var ans;
  710. ans = Array.prototype.slice.apply(this, arguments);
  711. ρσ_list_decorate(ans);
  712. return ans;
  713. };
  714. function ρσ_list_iterator(value) {
  715. var self;
  716. self = this;
  717. return (function(){
  718. var ρσ_d = {};
  719. ρσ_d["_i"] = -1;
  720. ρσ_d["_list"] = self;
  721. ρσ_d["next"] = function () {
  722. this._i += 1;
  723. if (this._i >= this._list.length) {
  724. return (function(){
  725. var ρσ_d = {};
  726. ρσ_d["done"] = true;
  727. return ρσ_d;
  728. }).call(this);
  729. }
  730. return (function(){
  731. var ρσ_d = {};
  732. ρσ_d["done"] = false;
  733. ρσ_d["value"] = (ρσ_expr_temp = this._list)[ρσ_bound_index(this._i, ρσ_expr_temp)];
  734. return ρσ_d;
  735. }).call(this);
  736. };
  737. return ρσ_d;
  738. }).call(this);
  739. };
  740. if (!ρσ_list_iterator.__argnames__) Object.defineProperties(ρσ_list_iterator, {
  741. __argnames__ : {value: ["value"]}
  742. });
  743. function ρσ_list_len() {
  744. return this.length;
  745. };
  746. function ρσ_list_contains(val) {
  747. for (var i = 0; i < this.length; i++) {
  748. if (((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === val || typeof (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === "object" && ρσ_equals((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i], val))) {
  749. return true;
  750. }
  751. }
  752. return false;
  753. };
  754. if (!ρσ_list_contains.__argnames__) Object.defineProperties(ρσ_list_contains, {
  755. __argnames__ : {value: ["val"]}
  756. });
  757. function ρσ_list_eq(other) {
  758. if (!ρσ_arraylike(other)) {
  759. return false;
  760. }
  761. if ((this.length !== other.length && (typeof this.length !== "object" || ρσ_not_equals(this.length, other.length)))) {
  762. return false;
  763. }
  764. for (var i = 0; i < this.length; i++) {
  765. if (!(((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === other[(typeof i === "number" && i < 0) ? other.length + i : i] || typeof (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === "object" && ρσ_equals((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i], other[(typeof i === "number" && i < 0) ? other.length + i : i])))) {
  766. return false;
  767. }
  768. }
  769. return true;
  770. };
  771. if (!ρσ_list_eq.__argnames__) Object.defineProperties(ρσ_list_eq, {
  772. __argnames__ : {value: ["other"]}
  773. });
  774. function ρσ_list_decorate(ans) {
  775. ans.append = Array.prototype.push;
  776. ans.toString = ρσ_list_to_string;
  777. ans.inspect = ρσ_list_to_string;
  778. ans.extend = ρσ_list_extend;
  779. ans.index = ρσ_list_index;
  780. ans.pypop = ρσ_list_pop;
  781. ans.remove = ρσ_list_remove;
  782. ans.insert = ρσ_list_insert;
  783. ans.copy = ρσ_list_copy;
  784. ans.clear = ρσ_list_clear;
  785. ans.count = ρσ_list_count;
  786. ans.concat = ρσ_list_concat;
  787. ans.pysort = ρσ_list_sort;
  788. ans.slice = ρσ_list_slice;
  789. ans.as_array = ρσ_list_as_array;
  790. ans.__len__ = ρσ_list_len;
  791. ans.__contains__ = ρσ_list_contains;
  792. ans.__eq__ = ρσ_list_eq;
  793. ans.constructor = ρσ_list_constructor;
  794. if (typeof ans[ρσ_iterator_symbol] !== "function") {
  795. ans[ρσ_iterator_symbol] = ρσ_list_iterator;
  796. }
  797. return ans;
  798. };
  799. if (!ρσ_list_decorate.__argnames__) Object.defineProperties(ρσ_list_decorate, {
  800. __argnames__ : {value: ["ans"]}
  801. });
  802. function ρσ_list_constructor(iterable) {
  803. var ans, iterator, result;
  804. if (iterable === undefined) {
  805. ans = [];
  806. } else if (ρσ_arraylike(iterable)) {
  807. ans = new Array(iterable.length);
  808. for (var i = 0; i < iterable.length; i++) {
  809. ans[(typeof i === "number" && i < 0) ? ans.length + i : i] = iterable[(typeof i === "number" && i < 0) ? iterable.length + i : i];
  810. }
  811. } else if (typeof iterable[ρσ_iterator_symbol] === "function") {
  812. iterator = (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol]();
  813. ans = ρσ_list_decorate([]);
  814. result = iterator.next();
  815. while (!result.done) {
  816. ans.push(result.value);
  817. result = iterator.next();
  818. }
  819. } else if (typeof iterable === "number") {
  820. ans = new Array(iterable);
  821. } else {
  822. ans = Object.keys(iterable);
  823. }
  824. return ρσ_list_decorate(ans);
  825. };
  826. if (!ρσ_list_constructor.__argnames__) Object.defineProperties(ρσ_list_constructor, {
  827. __argnames__ : {value: ["iterable"]}
  828. });
  829. ρσ_list_constructor.__name__ = "list";
  830. var list = ρσ_list_constructor, list_wrap = ρσ_list_decorate;
  831. function sorted() {
  832. var iterable = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0];
  833. var key = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? sorted.__defaults__.key : arguments[1];
  834. var reverse = (arguments[2] === undefined || ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? sorted.__defaults__.reverse : arguments[2];
  835. var ρσ_kwargs_obj = arguments[arguments.length-1];
  836. if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {};
  837. if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "key")){
  838. key = ρσ_kwargs_obj.key;
  839. }
  840. if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "reverse")){
  841. reverse = ρσ_kwargs_obj.reverse;
  842. }
  843. var ans;
  844. ans = ρσ_list_constructor(iterable);
  845. ans.pysort(key, reverse);
  846. return ans;
  847. };
  848. if (!sorted.__defaults__) Object.defineProperties(sorted, {
  849. __defaults__ : {value: {key:null, reverse:false}},
  850. __handles_kwarg_interpolation__ : {value: true},
  851. __argnames__ : {value: ["iterable", "key", "reverse"]}
  852. });
  853. var ρσ_global_object_id = 0, ρσ_set_implementation;
  854. function ρσ_set_keyfor(x) {
  855. var t, ans;
  856. t = typeof x;
  857. if (t === "string" || t === "number" || t === "boolean") {
  858. return "_" + t[0] + x;
  859. }
  860. if (x === null) {
  861. return "__!@#$0";
  862. }
  863. ans = x.ρσ_hash_key_prop;
  864. if (ans === undefined) {
  865. ans = "_!@#$" + (++ρσ_global_object_id);
  866. Object.defineProperty(x, "ρσ_hash_key_prop", (function(){
  867. var ρσ_d = {};
  868. ρσ_d["value"] = ans;
  869. return ρσ_d;
  870. }).call(this));
  871. }
  872. return ans;
  873. };
  874. if (!ρσ_set_keyfor.__argnames__) Object.defineProperties(ρσ_set_keyfor, {
  875. __argnames__ : {value: ["x"]}
  876. });
  877. function ρσ_set_polyfill() {
  878. this._store = {};
  879. this.size = 0;
  880. };
  881. ρσ_set_polyfill.prototype.add = (function() {
  882. var ρσ_anonfunc = function (x) {
  883. var key;
  884. key = ρσ_set_keyfor(x);
  885. if (!Object.prototype.hasOwnProperty.call(this._store, key)) {
  886. this.size += 1;
  887. (ρσ_expr_temp = this._store)[(typeof key === "number" && key < 0) ? ρσ_expr_temp.length + key : key] = x;
  888. }
  889. return this;
  890. };
  891. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  892. __argnames__ : {value: ["x"]}
  893. });
  894. return ρσ_anonfunc;
  895. })();
  896. ρσ_set_polyfill.prototype.clear = (function() {
  897. var ρσ_anonfunc = function (x) {
  898. this._store = {};
  899. this.size = 0;
  900. };
  901. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  902. __argnames__ : {value: ["x"]}
  903. });
  904. return ρσ_anonfunc;
  905. })();
  906. ρσ_set_polyfill.prototype.delete = (function() {
  907. var ρσ_anonfunc = function (x) {
  908. var key;
  909. key = ρσ_set_keyfor(x);
  910. if (Object.prototype.hasOwnProperty.call(this._store, key)) {
  911. this.size -= 1;
  912. delete this._store[key];
  913. return true;
  914. }
  915. return false;
  916. };
  917. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  918. __argnames__ : {value: ["x"]}
  919. });
  920. return ρσ_anonfunc;
  921. })();
  922. ρσ_set_polyfill.prototype.has = (function() {
  923. var ρσ_anonfunc = function (x) {
  924. return Object.prototype.hasOwnProperty.call(this._store, ρσ_set_keyfor(x));
  925. };
  926. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  927. __argnames__ : {value: ["x"]}
  928. });
  929. return ρσ_anonfunc;
  930. })();
  931. ρσ_set_polyfill.prototype.values = (function() {
  932. var ρσ_anonfunc = function (x) {
  933. var ans;
  934. ans = {'_keys': Object.keys(this._store), '_i':-1, '_s':this._store};
  935. ans[ρσ_iterator_symbol] = function () {
  936. return this;
  937. };
  938. ans["next"] = function () {
  939. this._i += 1;
  940. if (this._i >= this._keys.length) {
  941. return {'done': true};
  942. }
  943. return {'done':false, 'value':this._s[this._keys[this._i]]};
  944. };
  945. return ans;
  946. };
  947. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  948. __argnames__ : {value: ["x"]}
  949. });
  950. return ρσ_anonfunc;
  951. })();
  952. if (typeof Set !== "function" || typeof Set.prototype.delete !== "function") {
  953. ρσ_set_implementation = ρσ_set_polyfill;
  954. } else {
  955. ρσ_set_implementation = Set;
  956. }
  957. function ρσ_set(iterable) {
  958. var ans, s, iterator, result, keys;
  959. if (this instanceof ρσ_set) {
  960. this.jsset = new ρσ_set_implementation;
  961. ans = this;
  962. if (iterable === undefined) {
  963. return ans;
  964. }
  965. s = ans.jsset;
  966. if (ρσ_arraylike(iterable)) {
  967. for (var i = 0; i < iterable.length; i++) {
  968. s.add(iterable[(typeof i === "number" && i < 0) ? iterable.length + i : i]);
  969. }
  970. } else if (typeof iterable[ρσ_iterator_symbol] === "function") {
  971. iterator = (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol]();
  972. result = iterator.next();
  973. while (!result.done) {
  974. s.add(result.value);
  975. result = iterator.next();
  976. }
  977. } else {
  978. keys = Object.keys(iterable);
  979. for (var j=0; j < keys.length; j++) {
  980. s.add(keys[(typeof j === "number" && j < 0) ? keys.length + j : j]);
  981. }
  982. }
  983. return ans;
  984. } else {
  985. return new ρσ_set(iterable);
  986. }
  987. };
  988. if (!ρσ_set.__argnames__) Object.defineProperties(ρσ_set, {
  989. __argnames__ : {value: ["iterable"]}
  990. });
  991. ρσ_set.prototype.__name__ = "set";
  992. Object.defineProperties(ρσ_set.prototype, (function(){
  993. var ρσ_d = {};
  994. ρσ_d["length"] = (function(){
  995. var ρσ_d = {};
  996. ρσ_d["get"] = function () {
  997. return this.jsset.size;
  998. };
  999. return ρσ_d;
  1000. }).call(this);
  1001. ρσ_d["size"] = (function(){
  1002. var ρσ_d = {};
  1003. ρσ_d["get"] = function () {
  1004. return this.jsset.size;
  1005. };
  1006. return ρσ_d;
  1007. }).call(this);
  1008. return ρσ_d;
  1009. }).call(this));
  1010. ρσ_set.prototype.__len__ = function () {
  1011. return this.jsset.size;
  1012. };
  1013. ρσ_set.prototype.has = ρσ_set.prototype.__contains__ = (function() {
  1014. var ρσ_anonfunc = function (x) {
  1015. return this.jsset.has(x);
  1016. };
  1017. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1018. __argnames__ : {value: ["x"]}
  1019. });
  1020. return ρσ_anonfunc;
  1021. })();
  1022. ρσ_set.prototype.add = (function() {
  1023. var ρσ_anonfunc = function (x) {
  1024. this.jsset.add(x);
  1025. };
  1026. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1027. __argnames__ : {value: ["x"]}
  1028. });
  1029. return ρσ_anonfunc;
  1030. })();
  1031. ρσ_set.prototype.clear = function () {
  1032. this.jsset.clear();
  1033. };
  1034. ρσ_set.prototype.copy = function () {
  1035. return ρσ_set(this);
  1036. };
  1037. ρσ_set.prototype.discard = (function() {
  1038. var ρσ_anonfunc = function (x) {
  1039. this.jsset.delete(x);
  1040. };
  1041. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1042. __argnames__ : {value: ["x"]}
  1043. });
  1044. return ρσ_anonfunc;
  1045. })();
  1046. ρσ_set.prototype[ρσ_iterator_symbol] = function () {
  1047. return this.jsset.values();
  1048. };
  1049. ρσ_set.prototype.difference = function () {
  1050. var ans, s, iterator, r, x, has;
  1051. ans = new ρσ_set;
  1052. s = ans.jsset;
  1053. iterator = this.jsset.values();
  1054. r = iterator.next();
  1055. while (!r.done) {
  1056. x = r.value;
  1057. has = false;
  1058. for (var i = 0; i < arguments.length; i++) {
  1059. if (arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i].has(x)) {
  1060. has = true;
  1061. break;
  1062. }
  1063. }
  1064. if (!has) {
  1065. s.add(x);
  1066. }
  1067. r = iterator.next();
  1068. }
  1069. return ans;
  1070. };
  1071. ρσ_set.prototype.difference_update = function () {
  1072. var s, remove, iterator, r, x;
  1073. s = this.jsset;
  1074. remove = [];
  1075. iterator = s.values();
  1076. r = iterator.next();
  1077. while (!r.done) {
  1078. x = r.value;
  1079. for (var i = 0; i < arguments.length; i++) {
  1080. if (arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i].has(x)) {
  1081. remove.push(x);
  1082. break;
  1083. }
  1084. }
  1085. r = iterator.next();
  1086. }
  1087. for (var j = 0; j < remove.length; j++) {
  1088. s.delete(remove[(typeof j === "number" && j < 0) ? remove.length + j : j]);
  1089. }
  1090. };
  1091. ρσ_set.prototype.intersection = function () {
  1092. var ans, s, iterator, r, x, has;
  1093. ans = new ρσ_set;
  1094. s = ans.jsset;
  1095. iterator = this.jsset.values();
  1096. r = iterator.next();
  1097. while (!r.done) {
  1098. x = r.value;
  1099. has = true;
  1100. for (var i = 0; i < arguments.length; i++) {
  1101. if (!arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i].has(x)) {
  1102. has = false;
  1103. break;
  1104. }
  1105. }
  1106. if (has) {
  1107. s.add(x);
  1108. }
  1109. r = iterator.next();
  1110. }
  1111. return ans;
  1112. };
  1113. ρσ_set.prototype.intersection_update = function () {
  1114. var s, remove, iterator, r, x;
  1115. s = this.jsset;
  1116. remove = [];
  1117. iterator = s.values();
  1118. r = iterator.next();
  1119. while (!r.done) {
  1120. x = r.value;
  1121. for (var i = 0; i < arguments.length; i++) {
  1122. if (!arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i].has(x)) {
  1123. remove.push(x);
  1124. break;
  1125. }
  1126. }
  1127. r = iterator.next();
  1128. }
  1129. for (var j = 0; j < remove.length; j++) {
  1130. s.delete(remove[(typeof j === "number" && j < 0) ? remove.length + j : j]);
  1131. }
  1132. };
  1133. ρσ_set.prototype.isdisjoint = (function() {
  1134. var ρσ_anonfunc = function (other) {
  1135. var iterator, r, x;
  1136. iterator = this.jsset.values();
  1137. r = iterator.next();
  1138. while (!r.done) {
  1139. x = r.value;
  1140. if (other.has(x)) {
  1141. return false;
  1142. }
  1143. r = iterator.next();
  1144. }
  1145. return true;
  1146. };
  1147. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1148. __argnames__ : {value: ["other"]}
  1149. });
  1150. return ρσ_anonfunc;
  1151. })();
  1152. ρσ_set.prototype.issubset = (function() {
  1153. var ρσ_anonfunc = function (other) {
  1154. var iterator, r, x;
  1155. iterator = this.jsset.values();
  1156. r = iterator.next();
  1157. while (!r.done) {
  1158. x = r.value;
  1159. if (!other.has(x)) {
  1160. return false;
  1161. }
  1162. r = iterator.next();
  1163. }
  1164. return true;
  1165. };
  1166. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1167. __argnames__ : {value: ["other"]}
  1168. });
  1169. return ρσ_anonfunc;
  1170. })();
  1171. ρσ_set.prototype.issuperset = (function() {
  1172. var ρσ_anonfunc = function (other) {
  1173. var s, iterator, r, x;
  1174. s = this.jsset;
  1175. iterator = other.jsset.values();
  1176. r = iterator.next();
  1177. while (!r.done) {
  1178. x = r.value;
  1179. if (!s.has(x)) {
  1180. return false;
  1181. }
  1182. r = iterator.next();
  1183. }
  1184. return true;
  1185. };
  1186. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1187. __argnames__ : {value: ["other"]}
  1188. });
  1189. return ρσ_anonfunc;
  1190. })();
  1191. ρσ_set.prototype.pop = function () {
  1192. var iterator, r;
  1193. iterator = this.jsset.values();
  1194. r = iterator.next();
  1195. if (r.done) {
  1196. throw new KeyError("pop from an empty set");
  1197. }
  1198. this.jsset.delete(r.value);
  1199. return r.value;
  1200. };
  1201. ρσ_set.prototype.remove = (function() {
  1202. var ρσ_anonfunc = function (x) {
  1203. if (!this.jsset.delete(x)) {
  1204. throw new KeyError(x.toString());
  1205. }
  1206. };
  1207. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1208. __argnames__ : {value: ["x"]}
  1209. });
  1210. return ρσ_anonfunc;
  1211. })();
  1212. ρσ_set.prototype.symmetric_difference = (function() {
  1213. var ρσ_anonfunc = function (other) {
  1214. return this.union(other).difference(this.intersection(other));
  1215. };
  1216. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1217. __argnames__ : {value: ["other"]}
  1218. });
  1219. return ρσ_anonfunc;
  1220. })();
  1221. ρσ_set.prototype.symmetric_difference_update = (function() {
  1222. var ρσ_anonfunc = function (other) {
  1223. var common;
  1224. common = this.intersection(other);
  1225. this.update(other);
  1226. this.difference_update(common);
  1227. };
  1228. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1229. __argnames__ : {value: ["other"]}
  1230. });
  1231. return ρσ_anonfunc;
  1232. })();
  1233. ρσ_set.prototype.union = function () {
  1234. var ans;
  1235. ans = ρσ_set(this);
  1236. ans.update.apply(ans, arguments);
  1237. return ans;
  1238. };
  1239. ρσ_set.prototype.update = function () {
  1240. var s, iterator, r;
  1241. s = this.jsset;
  1242. for (var i=0; i < arguments.length; i++) {
  1243. iterator = arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i][ρσ_iterator_symbol]();
  1244. r = iterator.next();
  1245. while (!r.done) {
  1246. s.add(r.value);
  1247. r = iterator.next();
  1248. }
  1249. }
  1250. };
  1251. ρσ_set.prototype.toString = ρσ_set.prototype.inspect = function () {
  1252. return "{" + list(this).join(", ") + "}";
  1253. };
  1254. ρσ_set.prototype.__eq__ = (function() {
  1255. var ρσ_anonfunc = function (other) {
  1256. var iterator, r;
  1257. if (!other instanceof this.constructor) {
  1258. return false;
  1259. }
  1260. if (other.size !== this.size) {
  1261. return false;
  1262. }
  1263. if (other.size === 0) {
  1264. return true;
  1265. }
  1266. iterator = other[ρσ_iterator_symbol]();
  1267. r = iterator.next();
  1268. while (!r.done) {
  1269. if (!this.has(r.value)) {
  1270. return false;
  1271. }
  1272. r = iterator.next();
  1273. }
  1274. return true;
  1275. };
  1276. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1277. __argnames__ : {value: ["other"]}
  1278. });
  1279. return ρσ_anonfunc;
  1280. })();
  1281. function ρσ_set_wrap(x) {
  1282. var ans;
  1283. ans = new ρσ_set;
  1284. ans.jsset = x;
  1285. return ans;
  1286. };
  1287. if (!ρσ_set_wrap.__argnames__) Object.defineProperties(ρσ_set_wrap, {
  1288. __argnames__ : {value: ["x"]}
  1289. });
  1290. var set = ρσ_set, set_wrap = ρσ_set_wrap;
  1291. var ρσ_dict_implementation;
  1292. function ρσ_dict_polyfill() {
  1293. this._store = {};
  1294. this.size = 0;
  1295. };
  1296. ρσ_dict_polyfill.prototype.set = (function() {
  1297. var ρσ_anonfunc = function (x, value) {
  1298. var key;
  1299. key = ρσ_set_keyfor(x);
  1300. if (!Object.prototype.hasOwnProperty.call(this._store, key)) {
  1301. this.size += 1;
  1302. }
  1303. (ρσ_expr_temp = this._store)[(typeof key === "number" && key < 0) ? ρσ_expr_temp.length + key : key] = [x, value];
  1304. return this;
  1305. };
  1306. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1307. __argnames__ : {value: ["x", "value"]}
  1308. });
  1309. return ρσ_anonfunc;
  1310. })();
  1311. ρσ_dict_polyfill.prototype.clear = (function() {
  1312. var ρσ_anonfunc = function (x) {
  1313. this._store = {};
  1314. this.size = 0;
  1315. };
  1316. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1317. __argnames__ : {value: ["x"]}
  1318. });
  1319. return ρσ_anonfunc;
  1320. })();
  1321. ρσ_dict_polyfill.prototype.delete = (function() {
  1322. var ρσ_anonfunc = function (x) {
  1323. var key;
  1324. key = ρσ_set_keyfor(x);
  1325. if (Object.prototype.hasOwnProperty.call(this._store, key)) {
  1326. this.size -= 1;
  1327. delete this._store[key];
  1328. return true;
  1329. }
  1330. return false;
  1331. };
  1332. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1333. __argnames__ : {value: ["x"]}
  1334. });
  1335. return ρσ_anonfunc;
  1336. })();
  1337. ρσ_dict_polyfill.prototype.has = (function() {
  1338. var ρσ_anonfunc = function (x) {
  1339. return Object.prototype.hasOwnProperty.call(this._store, ρσ_set_keyfor(x));
  1340. };
  1341. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1342. __argnames__ : {value: ["x"]}
  1343. });
  1344. return ρσ_anonfunc;
  1345. })();
  1346. ρσ_dict_polyfill.prototype.get = (function() {
  1347. var ρσ_anonfunc = function (x) {
  1348. try {
  1349. return (ρσ_expr_temp = this._store)[ρσ_bound_index(ρσ_set_keyfor(x), ρσ_expr_temp)][1];
  1350. } catch (ρσ_Exception) {
  1351. ρσ_last_exception = ρσ_Exception;
  1352. if (ρσ_Exception instanceof TypeError) {
  1353. return undefined;
  1354. } else {
  1355. throw ρσ_Exception;
  1356. }
  1357. }
  1358. };
  1359. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1360. __argnames__ : {value: ["x"]}
  1361. });
  1362. return ρσ_anonfunc;
  1363. })();
  1364. ρσ_dict_polyfill.prototype.values = (function() {
  1365. var ρσ_anonfunc = function (x) {
  1366. var ans;
  1367. ans = {'_keys': Object.keys(this._store), '_i':-1, '_s':this._store};
  1368. ans[ρσ_iterator_symbol] = function () {
  1369. return this;
  1370. };
  1371. ans["next"] = function () {
  1372. this._i += 1;
  1373. if (this._i >= this._keys.length) {
  1374. return {'done': true};
  1375. }
  1376. return {'done':false, 'value':this._s[this._keys[this._i]][1]};
  1377. };
  1378. return ans;
  1379. };
  1380. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1381. __argnames__ : {value: ["x"]}
  1382. });
  1383. return ρσ_anonfunc;
  1384. })();
  1385. ρσ_dict_polyfill.prototype.keys = (function() {
  1386. var ρσ_anonfunc = function (x) {
  1387. var ans;
  1388. ans = {'_keys': Object.keys(this._store), '_i':-1, '_s':this._store};
  1389. ans[ρσ_iterator_symbol] = function () {
  1390. return this;
  1391. };
  1392. ans["next"] = function () {
  1393. this._i += 1;
  1394. if (this._i >= this._keys.length) {
  1395. return {'done': true};
  1396. }
  1397. return {'done':false, 'value':this._s[this._keys[this._i]][0]};
  1398. };
  1399. return ans;
  1400. };
  1401. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1402. __argnames__ : {value: ["x"]}
  1403. });
  1404. return ρσ_anonfunc;
  1405. })();
  1406. ρσ_dict_polyfill.prototype.entries = (function() {
  1407. var ρσ_anonfunc = function (x) {
  1408. var ans;
  1409. ans = {'_keys': Object.keys(this._store), '_i':-1, '_s':this._store};
  1410. ans[ρσ_iterator_symbol] = function () {
  1411. return this;
  1412. };
  1413. ans["next"] = function () {
  1414. this._i += 1;
  1415. if (this._i >= this._keys.length) {
  1416. return {'done': true};
  1417. }
  1418. return {'done':false, 'value':this._s[this._keys[this._i]]};
  1419. };
  1420. return ans;
  1421. };
  1422. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1423. __argnames__ : {value: ["x"]}
  1424. });
  1425. return ρσ_anonfunc;
  1426. })();
  1427. if (typeof Map !== "function" || typeof Map.prototype.delete !== "function") {
  1428. ρσ_dict_implementation = ρσ_dict_polyfill;
  1429. } else {
  1430. ρσ_dict_implementation = Map;
  1431. }
  1432. function ρσ_dict() {
  1433. var iterable = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0];
  1434. var kw = arguments[arguments.length-1];
  1435. if (kw === null || typeof kw !== "object" || kw [ρσ_kwargs_symbol] !== true) kw = {};
  1436. if (this instanceof ρσ_dict) {
  1437. this.jsmap = new ρσ_dict_implementation;
  1438. if (iterable !== undefined) {
  1439. this.update(iterable);
  1440. }
  1441. this.update(kw);
  1442. return this;
  1443. } else {
  1444. return ρσ_interpolate_kwargs_constructor.call(Object.create(ρσ_dict.prototype), false, ρσ_dict, [iterable].concat([ρσ_desugar_kwargs(kw)]));
  1445. }
  1446. };
  1447. if (!ρσ_dict.__handles_kwarg_interpolation__) Object.defineProperties(ρσ_dict, {
  1448. __handles_kwarg_interpolation__ : {value: true},
  1449. __argnames__ : {value: ["iterable"]}
  1450. });
  1451. ρσ_dict.prototype.__name__ = "dict";
  1452. Object.defineProperties(ρσ_dict.prototype, (function(){
  1453. var ρσ_d = {};
  1454. ρσ_d["length"] = (function(){
  1455. var ρσ_d = {};
  1456. ρσ_d["get"] = function () {
  1457. return this.jsmap.size;
  1458. };
  1459. return ρσ_d;
  1460. }).call(this);
  1461. ρσ_d["size"] = (function(){
  1462. var ρσ_d = {};
  1463. ρσ_d["get"] = function () {
  1464. return this.jsmap.size;
  1465. };
  1466. return ρσ_d;
  1467. }).call(this);
  1468. return ρσ_d;
  1469. }).call(this));
  1470. ρσ_dict.prototype.__len__ = function () {
  1471. return this.jsmap.size;
  1472. };
  1473. ρσ_dict.prototype.has = ρσ_dict.prototype.__contains__ = (function() {
  1474. var ρσ_anonfunc = function (x) {
  1475. return this.jsmap.has(x);
  1476. };
  1477. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1478. __argnames__ : {value: ["x"]}
  1479. });
  1480. return ρσ_anonfunc;
  1481. })();
  1482. ρσ_dict.prototype.set = ρσ_dict.prototype.__setitem__ = (function() {
  1483. var ρσ_anonfunc = function (key, value) {
  1484. this.jsmap.set(key, value);
  1485. };
  1486. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1487. __argnames__ : {value: ["key", "value"]}
  1488. });
  1489. return ρσ_anonfunc;
  1490. })();
  1491. ρσ_dict.prototype.__delitem__ = (function() {
  1492. var ρσ_anonfunc = function (key) {
  1493. this.jsmap.delete(key);
  1494. };
  1495. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1496. __argnames__ : {value: ["key"]}
  1497. });
  1498. return ρσ_anonfunc;
  1499. })();
  1500. ρσ_dict.prototype.clear = function () {
  1501. this.jsmap.clear();
  1502. };
  1503. ρσ_dict.prototype.copy = function () {
  1504. return ρσ_dict(this);
  1505. };
  1506. ρσ_dict.prototype.keys = function () {
  1507. return this.jsmap.keys();
  1508. };
  1509. ρσ_dict.prototype.values = function () {
  1510. return this.jsmap.values();
  1511. };
  1512. ρσ_dict.prototype.items = ρσ_dict.prototype.entries = function () {
  1513. return this.jsmap.entries();
  1514. };
  1515. ρσ_dict.prototype[ρσ_iterator_symbol] = function () {
  1516. return this.jsmap.keys();
  1517. };
  1518. ρσ_dict.prototype.__getitem__ = (function() {
  1519. var ρσ_anonfunc = function (key) {
  1520. var ans;
  1521. ans = this.jsmap.get(key);
  1522. if (ans === undefined && !this.jsmap.has(key)) {
  1523. throw new KeyError(key + "");
  1524. }
  1525. return ans;
  1526. };
  1527. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1528. __argnames__ : {value: ["key"]}
  1529. });
  1530. return ρσ_anonfunc;
  1531. })();
  1532. ρσ_dict.prototype.get = (function() {
  1533. var ρσ_anonfunc = function (key, defval) {
  1534. var ans;
  1535. ans = this.jsmap.get(key);
  1536. if (ans === undefined && !this.jsmap.has(key)) {
  1537. return (defval === undefined) ? null : defval;
  1538. }
  1539. return ans;
  1540. };
  1541. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1542. __argnames__ : {value: ["key", "defval"]}
  1543. });
  1544. return ρσ_anonfunc;
  1545. })();
  1546. ρσ_dict.prototype.set_default = (function() {
  1547. var ρσ_anonfunc = function (key, defval) {
  1548. var j;
  1549. j = this.jsmap;
  1550. if (!j.has(key)) {
  1551. j.set(key, defval);
  1552. return defval;
  1553. }
  1554. return j.get(key);
  1555. };
  1556. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1557. __argnames__ : {value: ["key", "defval"]}
  1558. });
  1559. return ρσ_anonfunc;
  1560. })();
  1561. ρσ_dict.fromkeys = ρσ_dict.prototype.fromkeys = (function() {
  1562. var ρσ_anonfunc = function () {
  1563. var iterable = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0];
  1564. var value = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? ρσ_anonfunc.__defaults__.value : arguments[1];
  1565. var ρσ_kwargs_obj = arguments[arguments.length-1];
  1566. if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {};
  1567. if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "value")){
  1568. value = ρσ_kwargs_obj.value;
  1569. }
  1570. var ans, iterator, r;
  1571. ans = ρσ_dict();
  1572. iterator = iter(iterable);
  1573. r = iterator.next();
  1574. while (!r.done) {
  1575. ans.set(r.value, value);
  1576. r = iterator.next();
  1577. }
  1578. return ans;
  1579. };
  1580. if (!ρσ_anonfunc.__defaults__) Object.defineProperties(ρσ_anonfunc, {
  1581. __defaults__ : {value: {value:null}},
  1582. __handles_kwarg_interpolation__ : {value: true},
  1583. __argnames__ : {value: ["iterable", "value"]}
  1584. });
  1585. return ρσ_anonfunc;
  1586. })();
  1587. ρσ_dict.prototype.pop = (function() {
  1588. var ρσ_anonfunc = function (key, defval) {
  1589. var ans;
  1590. ans = this.jsmap.get(key);
  1591. if (ans === undefined && !this.jsmap.has(key)) {
  1592. if (defval === undefined) {
  1593. throw new KeyError(key);
  1594. }
  1595. return defval;
  1596. }
  1597. this.jsmap.delete(key);
  1598. return ans;
  1599. };
  1600. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1601. __argnames__ : {value: ["key", "defval"]}
  1602. });
  1603. return ρσ_anonfunc;
  1604. })();
  1605. ρσ_dict.prototype.popitem = function () {
  1606. var r;
  1607. r = this.jsmap.entries().next();
  1608. if (r.done) {
  1609. throw new KeyError("dict is empty");
  1610. }
  1611. this.jsmap.delete(r.value[0]);
  1612. return r.value;
  1613. };
  1614. ρσ_dict.prototype.update = function () {
  1615. var m, iterable, iterator, result, keys;
  1616. if (arguments.length === 0) {
  1617. return;
  1618. }
  1619. m = this.jsmap;
  1620. iterable = arguments[0];
  1621. if (Array.isArray(iterable)) {
  1622. for (var i = 0; i < iterable.length; i++) {
  1623. m.set(iterable[(typeof i === "number" && i < 0) ? iterable.length + i : i][0], iterable[(typeof i === "number" && i < 0) ? iterable.length + i : i][1]);
  1624. }
  1625. } else if (iterable instanceof ρσ_dict) {
  1626. iterator = iterable.items();
  1627. result = iterator.next();
  1628. while (!result.done) {
  1629. m.set(result.value[0], result.value[1]);
  1630. result = iterator.next();
  1631. }
  1632. } else if (typeof Map === "function" && iterable instanceof Map) {
  1633. iterator = iterable.entries();
  1634. result = iterator.next();
  1635. while (!result.done) {
  1636. m.set(result.value[0], result.value[1]);
  1637. result = iterator.next();
  1638. }
  1639. } else if (typeof iterable[ρσ_iterator_symbol] === "function") {
  1640. iterator = iterable[ρσ_iterator_symbol]();
  1641. result = iterator.next();
  1642. while (!result.done) {
  1643. m.set(result.value[0], result.value[1]);
  1644. result = iterator.next();
  1645. }
  1646. } else {
  1647. keys = Object.keys(iterable);
  1648. for (var j=0; j < keys.length; j++) {
  1649. if (keys[(typeof j === "number" && j < 0) ? keys.length + j : j] !== ρσ_iterator_symbol) {
  1650. m.set(keys[(typeof j === "number" && j < 0) ? keys.length + j : j], iterable[ρσ_bound_index(keys[(typeof j === "number" && j < 0) ? keys.length + j : j], iterable)]);
  1651. }
  1652. }
  1653. }
  1654. if (arguments.length > 1) {
  1655. ρσ_dict.prototype.update.call(this, arguments[1]);
  1656. }
  1657. };
  1658. ρσ_dict.prototype.toString = ρσ_dict.prototype.inspect = ρσ_dict.prototype.__str__ = ρσ_dict.prototype.__repr__ = function () {
  1659. var entries, iterator, r;
  1660. entries = [];
  1661. iterator = this.jsmap.entries();
  1662. r = iterator.next();
  1663. while (!r.done) {
  1664. entries.push(ρσ_repr(r.value[0]) + ": " + ρσ_repr(r.value[1]));
  1665. r = iterator.next();
  1666. }
  1667. return "{" + entries.join(", ") + "}";
  1668. };
  1669. ρσ_dict.prototype.__eq__ = (function() {
  1670. var ρσ_anonfunc = function (other) {
  1671. var iterator, r, x;
  1672. if (!(other instanceof this.constructor)) {
  1673. return false;
  1674. }
  1675. if (other.size !== this.size) {
  1676. return false;
  1677. }
  1678. if (other.size === 0) {
  1679. return true;
  1680. }
  1681. iterator = other.items();
  1682. r = iterator.next();
  1683. while (!r.done) {
  1684. x = this.jsmap.get(r.value[0]);
  1685. if (x === undefined && !this.jsmap.has(r.value[0]) || x !== r.value[1]) {
  1686. return false;
  1687. }
  1688. r = iterator.next();
  1689. }
  1690. return true;
  1691. };
  1692. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1693. __argnames__ : {value: ["other"]}
  1694. });
  1695. return ρσ_anonfunc;
  1696. })();
  1697. ρσ_dict.prototype.as_object = (function() {
  1698. var ρσ_anonfunc = function (other) {
  1699. var ans, iterator, r;
  1700. ans = {};
  1701. iterator = this.jsmap.entries();
  1702. r = iterator.next();
  1703. while (!r.done) {
  1704. ans[ρσ_bound_index(r.value[0], ans)] = r.value[1];
  1705. r = iterator.next();
  1706. }
  1707. return ans;
  1708. };
  1709. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1710. __argnames__ : {value: ["other"]}
  1711. });
  1712. return ρσ_anonfunc;
  1713. })();
  1714. function ρσ_dict_wrap(x) {
  1715. var ans;
  1716. ans = new ρσ_dict;
  1717. ans.jsmap = x;
  1718. return ans;
  1719. };
  1720. if (!ρσ_dict_wrap.__argnames__) Object.defineProperties(ρσ_dict_wrap, {
  1721. __argnames__ : {value: ["x"]}
  1722. });
  1723. var dict = ρσ_dict, dict_wrap = ρσ_dict_wrap;var NameError;
  1724. NameError = ReferenceError;
  1725. function Exception() {
  1726. if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
  1727. Exception.prototype.__init__.apply(this, arguments);
  1728. }
  1729. ρσ_extends(Exception, Error);
  1730. Exception.prototype.__init__ = function __init__(message) {
  1731. var self = this;
  1732. self.message = message;
  1733. self.stack = (new Error).stack;
  1734. self.name = self.constructor.name;
  1735. };
  1736. if (!Exception.prototype.__init__.__argnames__) Object.defineProperties(Exception.prototype.__init__, {
  1737. __argnames__ : {value: ["message"]}
  1738. });
  1739. Exception.__argnames__ = Exception.prototype.__init__.__argnames__;
  1740. Exception.__handles_kwarg_interpolation__ = Exception.prototype.__init__.__handles_kwarg_interpolation__;
  1741. Exception.prototype.__repr__ = function __repr__() {
  1742. var self = this;
  1743. return self.name + ": " + self.message;
  1744. };
  1745. if (!Exception.prototype.__repr__.__argnames__) Object.defineProperties(Exception.prototype.__repr__, {
  1746. __argnames__ : {value: []}
  1747. });
  1748. Exception.prototype.__str__ = function __str__ () {
  1749. if(Error.prototype.__str__) return Error.prototype.__str__.call(this);
  1750. return this.__repr__();
  1751. };
  1752. Object.defineProperty(Exception.prototype, "__bases__", {value: [Error]});
  1753. function AttributeError() {
  1754. if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
  1755. AttributeError.prototype.__init__.apply(this, arguments);
  1756. }
  1757. ρσ_extends(AttributeError, Exception);
  1758. AttributeError.prototype.__init__ = function __init__ () {
  1759. Exception.prototype.__init__ && Exception.prototype.__init__.apply(this, arguments);
  1760. };
  1761. AttributeError.prototype.__repr__ = function __repr__ () {
  1762. if(Exception.prototype.__repr__) return Exception.prototype.__repr__.call(this);
  1763. return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">";
  1764. };
  1765. AttributeError.prototype.__str__ = function __str__ () {
  1766. if(Exception.prototype.__str__) return Exception.prototype.__str__.call(this);
  1767. return this.__repr__();
  1768. };
  1769. Object.defineProperty(AttributeError.prototype, "__bases__", {value: [Exception]});
  1770. function IndexError() {
  1771. if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
  1772. IndexError.prototype.__init__.apply(this, arguments);
  1773. }
  1774. ρσ_extends(IndexError, Exception);
  1775. IndexError.prototype.__init__ = function __init__ () {
  1776. Exception.prototype.__init__ && Exception.prototype.__init__.apply(this, arguments);
  1777. };
  1778. IndexError.prototype.__repr__ = function __repr__ () {
  1779. if(Exception.prototype.__repr__) return Exception.prototype.__repr__.call(this);
  1780. return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">";
  1781. };
  1782. IndexError.prototype.__str__ = function __str__ () {
  1783. if(Exception.prototype.__str__) return Exception.prototype.__str__.call(this);
  1784. return this.__repr__();
  1785. };
  1786. Object.defineProperty(IndexError.prototype, "__bases__", {value: [Exception]});
  1787. function KeyError() {
  1788. if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
  1789. KeyError.prototype.__init__.apply(this, arguments);
  1790. }
  1791. ρσ_extends(KeyError, Exception);
  1792. KeyError.prototype.__init__ = function __init__ () {
  1793. Exception.prototype.__init__ && Exception.prototype.__init__.apply(this, arguments);
  1794. };
  1795. KeyError.prototype.__repr__ = function __repr__ () {
  1796. if(Exception.prototype.__repr__) return Exception.prototype.__repr__.call(this);
  1797. return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">";
  1798. };
  1799. KeyError.prototype.__str__ = function __str__ () {
  1800. if(Exception.prototype.__str__) return Exception.prototype.__str__.call(this);
  1801. return this.__repr__();
  1802. };
  1803. Object.defineProperty(KeyError.prototype, "__bases__", {value: [Exception]});
  1804. function ValueError() {
  1805. if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
  1806. ValueError.prototype.__init__.apply(this, arguments);
  1807. }
  1808. ρσ_extends(ValueError, Exception);
  1809. ValueError.prototype.__init__ = function __init__ () {
  1810. Exception.prototype.__init__ && Exception.prototype.__init__.apply(this, arguments);
  1811. };
  1812. ValueError.prototype.__repr__ = function __repr__ () {
  1813. if(Exception.prototype.__repr__) return Exception.prototype.__repr__.call(this);
  1814. return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">";
  1815. };
  1816. ValueError.prototype.__str__ = function __str__ () {
  1817. if(Exception.prototype.__str__) return Exception.prototype.__str__.call(this);
  1818. return this.__repr__();
  1819. };
  1820. Object.defineProperty(ValueError.prototype, "__bases__", {value: [Exception]});
  1821. function UnicodeDecodeError() {
  1822. if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
  1823. UnicodeDecodeError.prototype.__init__.apply(this, arguments);
  1824. }
  1825. ρσ_extends(UnicodeDecodeError, Exception);
  1826. UnicodeDecodeError.prototype.__init__ = function __init__ () {
  1827. Exception.prototype.__init__ && Exception.prototype.__init__.apply(this, arguments);
  1828. };
  1829. UnicodeDecodeError.prototype.__repr__ = function __repr__ () {
  1830. if(Exception.prototype.__repr__) return Exception.prototype.__repr__.call(this);
  1831. return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">";
  1832. };
  1833. UnicodeDecodeError.prototype.__str__ = function __str__ () {
  1834. if(Exception.prototype.__str__) return Exception.prototype.__str__.call(this);
  1835. return this.__repr__();
  1836. };
  1837. Object.defineProperty(UnicodeDecodeError.prototype, "__bases__", {value: [Exception]});
  1838. function AssertionError() {
  1839. if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
  1840. AssertionError.prototype.__init__.apply(this, arguments);
  1841. }
  1842. ρσ_extends(AssertionError, Exception);
  1843. AssertionError.prototype.__init__ = function __init__ () {
  1844. Exception.prototype.__init__ && Exception.prototype.__init__.apply(this, arguments);
  1845. };
  1846. AssertionError.prototype.__repr__ = function __repr__ () {
  1847. if(Exception.prototype.__repr__) return Exception.prototype.__repr__.call(this);
  1848. return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">";
  1849. };
  1850. AssertionError.prototype.__str__ = function __str__ () {
  1851. if(Exception.prototype.__str__) return Exception.prototype.__str__.call(this);
  1852. return this.__repr__();
  1853. };
  1854. Object.defineProperty(AssertionError.prototype, "__bases__", {value: [Exception]});
  1855. function ZeroDivisionError() {
  1856. if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter});
  1857. ZeroDivisionError.prototype.__init__.apply(this, arguments);
  1858. }
  1859. ρσ_extends(ZeroDivisionError, Exception);
  1860. ZeroDivisionError.prototype.__init__ = function __init__ () {
  1861. Exception.prototype.__init__ && Exception.prototype.__init__.apply(this, arguments);
  1862. };
  1863. ZeroDivisionError.prototype.__repr__ = function __repr__ () {
  1864. if(Exception.prototype.__repr__) return Exception.prototype.__repr__.call(this);
  1865. return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">";
  1866. };
  1867. ZeroDivisionError.prototype.__str__ = function __str__ () {
  1868. if(Exception.prototype.__str__) return Exception.prototype.__str__.call(this);
  1869. return this.__repr__();
  1870. };
  1871. Object.defineProperty(ZeroDivisionError.prototype, "__bases__", {value: [Exception]});
  1872. var ρσ_in, ρσ_desugar_kwargs, ρσ_exists;
  1873. function ρσ_eslice(arr, step, start, end) {
  1874. var is_string;
  1875. if (typeof arr === "string" || arr instanceof String) {
  1876. is_string = true;
  1877. arr = arr.split("");
  1878. }
  1879. if (step < 0) {
  1880. step = -step;
  1881. arr = arr.slice().reverse();
  1882. if (typeof start !== "undefined") {
  1883. start = arr.length - start - 1;
  1884. }
  1885. if (typeof end !== "undefined") {
  1886. end = arr.length - end - 1;
  1887. }
  1888. }
  1889. if (typeof start === "undefined") {
  1890. start = 0;
  1891. }
  1892. if (typeof end === "undefined") {
  1893. end = arr.length;
  1894. }
  1895. arr = arr.slice(start, end).filter((function() {
  1896. var ρσ_anonfunc = function (e, i) {
  1897. return i % step === 0;
  1898. };
  1899. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  1900. __argnames__ : {value: ["e", "i"]}
  1901. });
  1902. return ρσ_anonfunc;
  1903. })());
  1904. if (is_string) {
  1905. arr = arr.join("");
  1906. }
  1907. return arr;
  1908. };
  1909. if (!ρσ_eslice.__argnames__) Object.defineProperties(ρσ_eslice, {
  1910. __argnames__ : {value: ["arr", "step", "start", "end"]}
  1911. });
  1912. function ρσ_delslice(arr, step, start, end) {
  1913. var is_string, ρσ_unpack, indices;
  1914. if (typeof arr === "string" || arr instanceof String) {
  1915. is_string = true;
  1916. arr = arr.split("");
  1917. }
  1918. if (step < 0) {
  1919. if (typeof start === "undefined") {
  1920. start = arr.length;
  1921. }
  1922. if (typeof end === "undefined") {
  1923. end = 0;
  1924. }
  1925. ρσ_unpack = [end, start, -step];
  1926. start = ρσ_unpack[0];
  1927. end = ρσ_unpack[1];
  1928. step = ρσ_unpack[2];
  1929. }
  1930. if (typeof start === "undefined") {
  1931. start = 0;
  1932. }
  1933. if (typeof end === "undefined") {
  1934. end = arr.length;
  1935. }
  1936. if (step === 1) {
  1937. arr.splice(start, end - start);
  1938. } else {
  1939. if (end > start) {
  1940. indices = [];
  1941. for (var i = start; i < end; i += step) {
  1942. indices.push(i);
  1943. }
  1944. for (var i = indices.length - 1; i >= 0; i--) {
  1945. arr.splice(indices[(typeof i === "number" && i < 0) ? indices.length + i : i], 1);
  1946. }
  1947. }
  1948. }
  1949. if (is_string) {
  1950. arr = arr.join("");
  1951. }
  1952. return arr;
  1953. };
  1954. if (!ρσ_delslice.__argnames__) Object.defineProperties(ρσ_delslice, {
  1955. __argnames__ : {value: ["arr", "step", "start", "end"]}
  1956. });
  1957. function ρσ_flatten(arr) {
  1958. var ans, value;
  1959. ans = ρσ_list_decorate([]);
  1960. for (var i=0; i < arr.length; i++) {
  1961. value = arr[(typeof i === "number" && i < 0) ? arr.length + i : i];
  1962. if (Array.isArray(value)) {
  1963. ans = ans.concat(ρσ_flatten(value));
  1964. } else {
  1965. ans.push(value);
  1966. }
  1967. }
  1968. return ans;
  1969. };
  1970. if (!ρσ_flatten.__argnames__) Object.defineProperties(ρσ_flatten, {
  1971. __argnames__ : {value: ["arr"]}
  1972. });
  1973. function ρσ_unpack_asarray(num, iterable) {
  1974. var ans, iterator, result;
  1975. if (ρσ_arraylike(iterable)) {
  1976. return iterable;
  1977. }
  1978. ans = [];
  1979. if (typeof iterable[ρσ_iterator_symbol] === "function") {
  1980. iterator = (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol]();
  1981. result = iterator.next();
  1982. while (!result.done && ans.length < num) {
  1983. ans.push(result.value);
  1984. result = iterator.next();
  1985. }
  1986. }
  1987. return ans;
  1988. };
  1989. if (!ρσ_unpack_asarray.__argnames__) Object.defineProperties(ρσ_unpack_asarray, {
  1990. __argnames__ : {value: ["num", "iterable"]}
  1991. });
  1992. function ρσ_extends(child, parent) {
  1993. child.prototype = Object.create(parent.prototype);
  1994. child.prototype.constructor = child;
  1995. };
  1996. if (!ρσ_extends.__argnames__) Object.defineProperties(ρσ_extends, {
  1997. __argnames__ : {value: ["child", "parent"]}
  1998. });
  1999. ρσ_in = function () {
  2000. if (typeof Map === "function" && typeof Set === "function") {
  2001. return (function() {
  2002. var ρσ_anonfunc = function (val, arr) {
  2003. if (typeof arr === "string") {
  2004. return arr.indexOf(val) !== -1;
  2005. }
  2006. if (typeof arr.__contains__ === "function") {
  2007. return arr.__contains__(val);
  2008. }
  2009. if (arr instanceof Map || arr instanceof Set) {
  2010. return arr.has(val);
  2011. }
  2012. if (ρσ_arraylike(arr)) {
  2013. return ρσ_list_contains.call(arr, val);
  2014. }
  2015. return Object.prototype.hasOwnProperty.call(arr, val);
  2016. };
  2017. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  2018. __argnames__ : {value: ["val", "arr"]}
  2019. });
  2020. return ρσ_anonfunc;
  2021. })();
  2022. }
  2023. return (function() {
  2024. var ρσ_anonfunc = function (val, arr) {
  2025. if (typeof arr === "string") {
  2026. return arr.indexOf(val) !== -1;
  2027. }
  2028. if (typeof arr.__contains__ === "function") {
  2029. return arr.__contains__(val);
  2030. }
  2031. if (ρσ_arraylike(arr)) {
  2032. return ρσ_list_contains.call(arr, val);
  2033. }
  2034. return Object.prototype.hasOwnProperty.call(arr, val);
  2035. };
  2036. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  2037. __argnames__ : {value: ["val", "arr"]}
  2038. });
  2039. return ρσ_anonfunc;
  2040. })();
  2041. }();
  2042. function ρσ_Iterable(iterable) {
  2043. var iterator, ans, result;
  2044. if (ρσ_arraylike(iterable)) {
  2045. return iterable;
  2046. }
  2047. if (typeof iterable[ρσ_iterator_symbol] === "function") {
  2048. iterator = (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol]();
  2049. ans = ρσ_list_decorate([]);
  2050. result = iterator.next();
  2051. while (!result.done) {
  2052. ans.push(result.value);
  2053. result = iterator.next();
  2054. }
  2055. return ans;
  2056. }
  2057. return Object.keys(iterable);
  2058. };
  2059. if (!ρσ_Iterable.__argnames__) Object.defineProperties(ρσ_Iterable, {
  2060. __argnames__ : {value: ["iterable"]}
  2061. });
  2062. ρσ_desugar_kwargs = function () {
  2063. if (typeof Object.assign === "function") {
  2064. return function () {
  2065. var ans;
  2066. ans = Object.create(null);
  2067. ans[ρσ_kwargs_symbol] = true;
  2068. for (var i = 0; i < arguments.length; i++) {
  2069. Object.assign(ans, arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i]);
  2070. }
  2071. return ans;
  2072. };
  2073. }
  2074. return function () {
  2075. var ans, keys;
  2076. ans = Object.create(null);
  2077. ans[ρσ_kwargs_symbol] = true;
  2078. for (var i = 0; i < arguments.length; i++) {
  2079. keys = Object.keys(arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i]);
  2080. for (var j = 0; j < keys.length; j++) {
  2081. ans[ρσ_bound_index(keys[(typeof j === "number" && j < 0) ? keys.length + j : j], ans)] = (ρσ_expr_temp = arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i])[ρσ_bound_index(keys[(typeof j === "number" && j < 0) ? keys.length + j : j], ρσ_expr_temp)];
  2082. }
  2083. }
  2084. return ans;
  2085. };
  2086. }();
  2087. function ρσ_interpolate_kwargs(f, supplied_args) {
  2088. var has_prop, kwobj, args, prop;
  2089. if (!f.__argnames__) {
  2090. return f.apply(this, supplied_args);
  2091. }
  2092. has_prop = Object.prototype.hasOwnProperty;
  2093. kwobj = supplied_args.pop();
  2094. if (f.__handles_kwarg_interpolation__) {
  2095. args = new Array(Math.max(supplied_args.length, f.__argnames__.length) + 1);
  2096. args[args.length-1] = kwobj;
  2097. for (var i = 0; i < args.length - 1; i++) {
  2098. if (i < f.__argnames__.length) {
  2099. prop = (ρσ_expr_temp = f.__argnames__)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i];
  2100. if (has_prop.call(kwobj, prop)) {
  2101. args[(typeof i === "number" && i < 0) ? args.length + i : i] = kwobj[(typeof prop === "number" && prop < 0) ? kwobj.length + prop : prop];
  2102. delete kwobj[prop];
  2103. } else if (i < supplied_args.length) {
  2104. args[(typeof i === "number" && i < 0) ? args.length + i : i] = supplied_args[(typeof i === "number" && i < 0) ? supplied_args.length + i : i];
  2105. }
  2106. } else {
  2107. args[(typeof i === "number" && i < 0) ? args.length + i : i] = supplied_args[(typeof i === "number" && i < 0) ? supplied_args.length + i : i];
  2108. }
  2109. }
  2110. return f.apply(this, args);
  2111. }
  2112. for (var i = 0; i < f.__argnames__.length; i++) {
  2113. prop = (ρσ_expr_temp = f.__argnames__)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i];
  2114. if (has_prop.call(kwobj, prop)) {
  2115. supplied_args[(typeof i === "number" && i < 0) ? supplied_args.length + i : i] = kwobj[(typeof prop === "number" && prop < 0) ? kwobj.length + prop : prop];
  2116. }
  2117. }
  2118. return f.apply(this, supplied_args);
  2119. };
  2120. if (!ρσ_interpolate_kwargs.__argnames__) Object.defineProperties(ρσ_interpolate_kwargs, {
  2121. __argnames__ : {value: ["f", "supplied_args"]}
  2122. });
  2123. function ρσ_interpolate_kwargs_constructor(apply, f, supplied_args) {
  2124. if (apply) {
  2125. f.apply(this, supplied_args);
  2126. } else {
  2127. ρσ_interpolate_kwargs.call(this, f, supplied_args);
  2128. }
  2129. return this;
  2130. };
  2131. if (!ρσ_interpolate_kwargs_constructor.__argnames__) Object.defineProperties(ρσ_interpolate_kwargs_constructor, {
  2132. __argnames__ : {value: ["apply", "f", "supplied_args"]}
  2133. });
  2134. function ρσ_getitem(obj, key) {
  2135. if (obj.__getitem__) {
  2136. return obj.__getitem__(key);
  2137. }
  2138. if (typeof key === "number" && key < 0) {
  2139. key += obj.length;
  2140. }
  2141. return obj[(typeof key === "number" && key < 0) ? obj.length + key : key];
  2142. };
  2143. if (!ρσ_getitem.__argnames__) Object.defineProperties(ρσ_getitem, {
  2144. __argnames__ : {value: ["obj", "key"]}
  2145. });
  2146. function ρσ_setitem(obj, key, val) {
  2147. if (obj.__setitem__) {
  2148. obj.__setitem__(key, val);
  2149. } else {
  2150. if (typeof key === "number" && key < 0) {
  2151. key += obj.length;
  2152. }
  2153. obj[(typeof key === "number" && key < 0) ? obj.length + key : key] = val;
  2154. }
  2155. };
  2156. if (!ρσ_setitem.__argnames__) Object.defineProperties(ρσ_setitem, {
  2157. __argnames__ : {value: ["obj", "key", "val"]}
  2158. });
  2159. function ρσ_delitem(obj, key) {
  2160. if (obj.__delitem__) {
  2161. obj.__delitem__(key);
  2162. } else if (typeof obj.splice === "function") {
  2163. obj.splice(key, 1);
  2164. } else {
  2165. if (typeof key === "number" && key < 0) {
  2166. key += obj.length;
  2167. }
  2168. delete obj[key];
  2169. }
  2170. };
  2171. if (!ρσ_delitem.__argnames__) Object.defineProperties(ρσ_delitem, {
  2172. __argnames__ : {value: ["obj", "key"]}
  2173. });
  2174. function ρσ_bound_index(idx, arr) {
  2175. if (typeof idx === "number" && idx < 0) {
  2176. idx += arr.length;
  2177. }
  2178. return idx;
  2179. };
  2180. if (!ρσ_bound_index.__argnames__) Object.defineProperties(ρσ_bound_index, {
  2181. __argnames__ : {value: ["idx", "arr"]}
  2182. });
  2183. function ρσ_splice(arr, val, start, end) {
  2184. start = start || 0;
  2185. if (start < 0) {
  2186. start += arr.length;
  2187. }
  2188. if (end === undefined) {
  2189. end = arr.length;
  2190. }
  2191. if (end < 0) {
  2192. end += arr.length;
  2193. }
  2194. Array.prototype.splice.apply(arr, [start, end - start].concat(val));
  2195. };
  2196. if (!ρσ_splice.__argnames__) Object.defineProperties(ρσ_splice, {
  2197. __argnames__ : {value: ["arr", "val", "start", "end"]}
  2198. });
  2199. ρσ_exists = (function(){
  2200. var ρσ_d = {};
  2201. ρσ_d["n"] = (function() {
  2202. var ρσ_anonfunc = function (expr) {
  2203. return expr !== undefined && expr !== null;
  2204. };
  2205. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  2206. __argnames__ : {value: ["expr"]}
  2207. });
  2208. return ρσ_anonfunc;
  2209. })();
  2210. ρσ_d["d"] = (function() {
  2211. var ρσ_anonfunc = function (expr) {
  2212. if (expr === undefined || expr === null) {
  2213. return Object.create(null);
  2214. }
  2215. return expr;
  2216. };
  2217. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  2218. __argnames__ : {value: ["expr"]}
  2219. });
  2220. return ρσ_anonfunc;
  2221. })();
  2222. ρσ_d["c"] = (function() {
  2223. var ρσ_anonfunc = function (expr) {
  2224. if (typeof expr === "function") {
  2225. return expr;
  2226. }
  2227. return function () {
  2228. return undefined;
  2229. };
  2230. };
  2231. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  2232. __argnames__ : {value: ["expr"]}
  2233. });
  2234. return ρσ_anonfunc;
  2235. })();
  2236. ρσ_d["g"] = (function() {
  2237. var ρσ_anonfunc = function (expr) {
  2238. if (expr === undefined || expr === null || typeof expr.__getitem__ !== "function") {
  2239. return (function(){
  2240. var ρσ_d = {};
  2241. ρσ_d["__getitem__"] = function () {
  2242. return undefined;
  2243. };
  2244. return ρσ_d;
  2245. }).call(this);
  2246. }
  2247. };
  2248. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  2249. __argnames__ : {value: ["expr"]}
  2250. });
  2251. return ρσ_anonfunc;
  2252. })();
  2253. ρσ_d["e"] = (function() {
  2254. var ρσ_anonfunc = function (expr, alt) {
  2255. return (expr === undefined || expr === null) ? alt : expr;
  2256. };
  2257. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  2258. __argnames__ : {value: ["expr", "alt"]}
  2259. });
  2260. return ρσ_anonfunc;
  2261. })();
  2262. return ρσ_d;
  2263. }).call(this);
  2264. function ρσ_mixin() {
  2265. var seen, resolved_props, p, target, props, name;
  2266. seen = Object.create(null);
  2267. seen.__argnames__ = seen.__handles_kwarg_interpolation__ = seen.__init__ = seen.__annotations__ = seen.__doc__ = seen.__bind_methods__ = seen.__bases__ = seen.constructor = seen.__class__ = true;
  2268. resolved_props = {};
  2269. p = target = arguments[0].prototype;
  2270. while (p && p !== Object.prototype) {
  2271. props = Object.getOwnPropertyNames(p);
  2272. for (var i = 0; i < props.length; i++) {
  2273. seen[ρσ_bound_index(props[(typeof i === "number" && i < 0) ? props.length + i : i], seen)] = true;
  2274. }
  2275. p = Object.getPrototypeOf(p);
  2276. }
  2277. for (var c = 1; c < arguments.length; c++) {
  2278. p = arguments[(typeof c === "number" && c < 0) ? arguments.length + c : c].prototype;
  2279. while (p && p !== Object.prototype) {
  2280. props = Object.getOwnPropertyNames(p);
  2281. for (var i = 0; i < props.length; i++) {
  2282. name = props[(typeof i === "number" && i < 0) ? props.length + i : i];
  2283. if (seen[(typeof name === "number" && name < 0) ? seen.length + name : name]) {
  2284. continue;
  2285. }
  2286. seen[(typeof name === "number" && name < 0) ? seen.length + name : name] = true;
  2287. resolved_props[(typeof name === "number" && name < 0) ? resolved_props.length + name : name] = Object.getOwnPropertyDescriptor(p, name);
  2288. }
  2289. p = Object.getPrototypeOf(p);
  2290. }
  2291. }
  2292. Object.defineProperties(target, resolved_props);
  2293. };
  2294. function ρσ_instanceof() {
  2295. var obj, bases, q, cls, p;
  2296. obj = arguments[0];
  2297. bases = "";
  2298. if (obj && obj.constructor && obj.constructor.prototype) {
  2299. bases = obj.constructor.prototype.__bases__ || "";
  2300. }
  2301. for (var i = 1; i < arguments.length; i++) {
  2302. q = arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i];
  2303. if (obj instanceof q) {
  2304. return true;
  2305. }
  2306. if ((q === Array || q === ρσ_list_constructor) && Array.isArray(obj)) {
  2307. return true;
  2308. }
  2309. if (q === ρσ_str && (typeof obj === "string" || obj instanceof String)) {
  2310. return true;
  2311. }
  2312. if (bases.length > 1) {
  2313. for (var c = 1; c < bases.length; c++) {
  2314. cls = bases[(typeof c === "number" && c < 0) ? bases.length + c : c];
  2315. while (cls) {
  2316. if (q === cls) {
  2317. return true;
  2318. }
  2319. p = Object.getPrototypeOf(cls.prototype);
  2320. if (!p) {
  2321. break;
  2322. }
  2323. cls = p.constructor;
  2324. }
  2325. }
  2326. }
  2327. }
  2328. return false;
  2329. };
  2330. function sum(iterable, start) {
  2331. var ans, iterator, r;
  2332. if (Array.isArray(iterable)) {
  2333. return iterable.reduce((function() {
  2334. var ρσ_anonfunc = function (prev, cur) {
  2335. return prev + cur;
  2336. };
  2337. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  2338. __argnames__ : {value: ["prev", "cur"]}
  2339. });
  2340. return ρσ_anonfunc;
  2341. })(), start || 0);
  2342. }
  2343. ans = start || 0;
  2344. iterator = iter(iterable);
  2345. r = iterator.next();
  2346. while (!r.done) {
  2347. ans += r.value;
  2348. r = iterator.next();
  2349. }
  2350. return ans;
  2351. };
  2352. if (!sum.__argnames__) Object.defineProperties(sum, {
  2353. __argnames__ : {value: ["iterable", "start"]}
  2354. });
  2355. function map() {
  2356. var iterators, func, args, ans;
  2357. iterators = new Array(arguments.length - 1);
  2358. func = arguments[0];
  2359. args = new Array(arguments.length - 1);
  2360. for (var i = 1; i < arguments.length; i++) {
  2361. iterators[ρσ_bound_index(i - 1, iterators)] = iter(arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i]);
  2362. }
  2363. ans = {'_func':func, '_iterators':iterators, '_args':args};
  2364. ans[ρσ_iterator_symbol] = function () {
  2365. return this;
  2366. };
  2367. ans["next"] = function () {
  2368. var r;
  2369. for (var i = 0; i < this._iterators.length; i++) {
  2370. r = (ρσ_expr_temp = this._iterators)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i].next();
  2371. if (r.done) {
  2372. return {'done':true};
  2373. }
  2374. (ρσ_expr_temp = this._args)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] = r.value;
  2375. }
  2376. return {'done':false, 'value':this._func.apply(undefined, this._args)};
  2377. };
  2378. return ans;
  2379. };
  2380. function filter(func_or_none, iterable) {
  2381. var func, ans;
  2382. func = (func_or_none === null) ? ρσ_bool : func_or_none;
  2383. ans = {'_func':func, '_iterator':ρσ_iter(iterable)};
  2384. ans[ρσ_iterator_symbol] = function () {
  2385. return this;
  2386. };
  2387. ans["next"] = function () {
  2388. var r;
  2389. r = this._iterator.next();
  2390. while (!r.done) {
  2391. if (this._func(r.value)) {
  2392. return r;
  2393. }
  2394. r = this._iterator.next();
  2395. }
  2396. return {'done':true};
  2397. };
  2398. return ans;
  2399. };
  2400. if (!filter.__argnames__) Object.defineProperties(filter, {
  2401. __argnames__ : {value: ["func_or_none", "iterable"]}
  2402. });
  2403. function zip() {
  2404. var iterators, ans;
  2405. iterators = new Array(arguments.length);
  2406. for (var i = 0; i < arguments.length; i++) {
  2407. iterators[(typeof i === "number" && i < 0) ? iterators.length + i : i] = iter(arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i]);
  2408. }
  2409. ans = {'_iterators':iterators};
  2410. ans[ρσ_iterator_symbol] = function () {
  2411. return this;
  2412. };
  2413. ans["next"] = function () {
  2414. var args, r;
  2415. args = new Array(this._iterators.length);
  2416. for (var i = 0; i < this._iterators.length; i++) {
  2417. r = (ρσ_expr_temp = this._iterators)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i].next();
  2418. if (r.done) {
  2419. return {'done':true};
  2420. }
  2421. args[(typeof i === "number" && i < 0) ? args.length + i : i] = r.value;
  2422. }
  2423. return {'done':false, 'value':args};
  2424. };
  2425. return ans;
  2426. };
  2427. function any(iterable) {
  2428. var i;
  2429. var ρσ_Iter0 = ρσ_Iterable(iterable);
  2430. for (var ρσ_Index0 = 0; ρσ_Index0 < ρσ_Iter0.length; ρσ_Index0++) {
  2431. i = ρσ_Iter0[ρσ_Index0];
  2432. if (i) {
  2433. return true;
  2434. }
  2435. }
  2436. return false;
  2437. };
  2438. if (!any.__argnames__) Object.defineProperties(any, {
  2439. __argnames__ : {value: ["iterable"]}
  2440. });
  2441. function all(iterable) {
  2442. var i;
  2443. var ρσ_Iter1 = ρσ_Iterable(iterable);
  2444. for (var ρσ_Index1 = 0; ρσ_Index1 < ρσ_Iter1.length; ρσ_Index1++) {
  2445. i = ρσ_Iter1[ρσ_Index1];
  2446. if (!i) {
  2447. return false;
  2448. }
  2449. }
  2450. return true;
  2451. };
  2452. if (!all.__argnames__) Object.defineProperties(all, {
  2453. __argnames__ : {value: ["iterable"]}
  2454. });
  2455. var define_str_func, ρσ_unpack, ρσ_orig_split, ρσ_orig_replace;
  2456. function ρσ_repr_js_builtin(x, as_array) {
  2457. var ans, b, keys, key;
  2458. ans = [];
  2459. b = "{}";
  2460. if (as_array) {
  2461. b = "[]";
  2462. for (var i = 0; i < x.length; i++) {
  2463. ans.push(ρσ_repr(x[(typeof i === "number" && i < 0) ? x.length + i : i]));
  2464. }
  2465. } else {
  2466. keys = Object.keys(x);
  2467. for (var k = 0; k < keys.length; k++) {
  2468. key = keys[(typeof k === "number" && k < 0) ? keys.length + k : k];
  2469. ans.push(JSON.stringify(key) + ":" + ρσ_repr(x[(typeof key === "number" && key < 0) ? x.length + key : key]));
  2470. }
  2471. }
  2472. return b[0] + ans.join(", ") + b[1];
  2473. };
  2474. if (!ρσ_repr_js_builtin.__argnames__) Object.defineProperties(ρσ_repr_js_builtin, {
  2475. __argnames__ : {value: ["x", "as_array"]}
  2476. });
  2477. function ρσ_html_element_to_string(elem) {
  2478. var attrs, val, attr, ans;
  2479. attrs = [];
  2480. var ρσ_Iter0 = ρσ_Iterable(elem.attributes);
  2481. for (var ρσ_Index0 = 0; ρσ_Index0 < ρσ_Iter0.length; ρσ_Index0++) {
  2482. attr = ρσ_Iter0[ρσ_Index0];
  2483. if (attr.specified) {
  2484. val = attr.value;
  2485. if (val.length > 10) {
  2486. val = val.slice(0, 15) + "...";
  2487. }
  2488. val = JSON.stringify(val);
  2489. attrs.push("" + ρσ_str.format("{}", attr.name) + "=" + ρσ_str.format("{}", val) + "");
  2490. }
  2491. }
  2492. attrs = (attrs.length) ? " " + attrs.join(" ") : "";
  2493. ans = "<" + ρσ_str.format("{}", elem.tagName) + "" + ρσ_str.format("{}", attrs) + ">";
  2494. return ans;
  2495. };
  2496. if (!ρσ_html_element_to_string.__argnames__) Object.defineProperties(ρσ_html_element_to_string, {
  2497. __argnames__ : {value: ["elem"]}
  2498. });
  2499. function ρσ_repr(x) {
  2500. var ans, name;
  2501. if (x === null) {
  2502. return "None";
  2503. }
  2504. if (x === undefined) {
  2505. return "undefined";
  2506. }
  2507. ans = x;
  2508. if (typeof x.__repr__ === "function") {
  2509. ans = x.__repr__();
  2510. } else if (x === true || x === false) {
  2511. ans = (x) ? "True" : "False";
  2512. } else if (Array.isArray(x)) {
  2513. ans = ρσ_repr_js_builtin(x, true);
  2514. } else if (typeof x === "function") {
  2515. ans = x.toString();
  2516. } else if (typeof x === "object" && !x.toString) {
  2517. ans = ρσ_repr_js_builtin(x);
  2518. } else {
  2519. name = Object.prototype.toString.call(x).slice(8, -1);
  2520. if (ρσ_not_equals("Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".indexOf(name), -1)) {
  2521. return name + "([" + x.map((function() {
  2522. var ρσ_anonfunc = function (i) {
  2523. return str.format("0x{:02x}", i);
  2524. };
  2525. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  2526. __argnames__ : {value: ["i"]}
  2527. });
  2528. return ρσ_anonfunc;
  2529. })()).join(", ") + "])";
  2530. }
  2531. if (typeof HTMLElement !== "undefined" && x instanceof HTMLElement) {
  2532. ans = ρσ_html_element_to_string(x);
  2533. } else {
  2534. ans = (typeof x.toString === "function") ? x.toString() : x;
  2535. }
  2536. if (ans === "[object Object]") {
  2537. return ρσ_repr_js_builtin(x);
  2538. }
  2539. try {
  2540. ans = JSON.stringify(x);
  2541. } catch (ρσ_Exception) {
  2542. ρσ_last_exception = ρσ_Exception;
  2543. {
  2544. }
  2545. }
  2546. }
  2547. return ans + "";
  2548. };
  2549. if (!ρσ_repr.__argnames__) Object.defineProperties(ρσ_repr, {
  2550. __argnames__ : {value: ["x"]}
  2551. });
  2552. function ρσ_str(x) {
  2553. var ans, name;
  2554. if (x === null) {
  2555. return "None";
  2556. }
  2557. if (x === undefined) {
  2558. return "undefined";
  2559. }
  2560. ans = x;
  2561. if (typeof x.__str__ === "function") {
  2562. ans = x.__str__();
  2563. } else if (typeof x.__repr__ === "function") {
  2564. ans = x.__repr__();
  2565. } else if (x === true || x === false) {
  2566. ans = (x) ? "True" : "False";
  2567. } else if (Array.isArray(x)) {
  2568. ans = ρσ_repr_js_builtin(x, true);
  2569. } else if (typeof x.toString === "function") {
  2570. name = Object.prototype.toString.call(x).slice(8, -1);
  2571. if (ρσ_not_equals("Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".indexOf(name), -1)) {
  2572. return name + "([" + x.map((function() {
  2573. var ρσ_anonfunc = function (i) {
  2574. return str.format("0x{:02x}", i);
  2575. };
  2576. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  2577. __argnames__ : {value: ["i"]}
  2578. });
  2579. return ρσ_anonfunc;
  2580. })()).join(", ") + "])";
  2581. }
  2582. if (typeof HTMLElement !== "undefined" && x instanceof HTMLElement) {
  2583. ans = ρσ_html_element_to_string(x);
  2584. } else {
  2585. ans = x.toString();
  2586. }
  2587. if (ans === "[object Object]") {
  2588. ans = ρσ_repr_js_builtin(x);
  2589. }
  2590. } else if (typeof x === "object" && !x.toString) {
  2591. ans = ρσ_repr_js_builtin(x);
  2592. }
  2593. return ans + "";
  2594. };
  2595. if (!ρσ_str.__argnames__) Object.defineProperties(ρσ_str, {
  2596. __argnames__ : {value: ["x"]}
  2597. });
  2598. define_str_func = (function() {
  2599. var ρσ_anonfunc = function (name, func) {
  2600. var f;
  2601. (ρσ_expr_temp = ρσ_str.prototype)[(typeof name === "number" && name < 0) ? ρσ_expr_temp.length + name : name] = func;
  2602. ρσ_str[(typeof name === "number" && name < 0) ? ρσ_str.length + name : name] = f = func.call.bind(func);
  2603. if (func.__argnames__) {
  2604. Object.defineProperty(f, "__argnames__", (function(){
  2605. var ρσ_d = {};
  2606. ρσ_d["value"] = ['string'].concat(func.__argnames__);
  2607. return ρσ_d;
  2608. }).call(this));
  2609. }
  2610. };
  2611. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  2612. __argnames__ : {value: ["name", "func"]}
  2613. });
  2614. return ρσ_anonfunc;
  2615. })();
  2616. ρσ_unpack = [String.prototype.split.call.bind(String.prototype.split), String.prototype.replace.call.bind(String.prototype.replace)];
  2617. ρσ_orig_split = ρσ_unpack[0];
  2618. ρσ_orig_replace = ρσ_unpack[1];
  2619. define_str_func("format", function () {
  2620. var template, args, kwargs, explicit, implicit, idx, split, ans, pos, in_brace, markup, ch;
  2621. template = this;
  2622. if (template === undefined) {
  2623. throw new TypeError("Template is required");
  2624. }
  2625. args = Array.prototype.slice.call(arguments);
  2626. kwargs = {};
  2627. if (args[args.length-1] && args[args.length-1][ρσ_kwargs_symbol] !== undefined) {
  2628. kwargs = args[args.length-1];
  2629. args = args.slice(0, -1);
  2630. }
  2631. explicit = implicit = false;
  2632. idx = 0;
  2633. split = ρσ_orig_split;
  2634. if (ρσ_str.format._template_resolve_pat === undefined) {
  2635. ρσ_str.format._template_resolve_pat = /[.\[]/;
  2636. }
  2637. function resolve(arg, object) {
  2638. var ρσ_unpack, first, key, rest, ans;
  2639. if (!arg) {
  2640. return object;
  2641. }
  2642. ρσ_unpack = [arg[0], arg.slice(1)];
  2643. first = ρσ_unpack[0];
  2644. arg = ρσ_unpack[1];
  2645. key = split(arg, ρσ_str.format._template_resolve_pat, 1)[0];
  2646. rest = arg.slice(key.length);
  2647. ans = (first === "[") ? object[ρσ_bound_index(key.slice(0, -1), object)] : getattr(object, key);
  2648. if (ans === undefined) {
  2649. throw new KeyError((first === "[") ? key.slice(0, -1) : key);
  2650. }
  2651. return resolve(rest, ans);
  2652. };
  2653. if (!resolve.__argnames__) Object.defineProperties(resolve, {
  2654. __argnames__ : {value: ["arg", "object"]}
  2655. });
  2656. function resolve_format_spec(format_spec) {
  2657. if (ρσ_str.format._template_resolve_fs_pat === undefined) {
  2658. ρσ_str.format._template_resolve_fs_pat = /[{]([a-zA-Z0-9_]+)[}]/g;
  2659. }
  2660. return format_spec.replace(ρσ_str.format._template_resolve_fs_pat, (function() {
  2661. var ρσ_anonfunc = function (match, key) {
  2662. if (!Object.prototype.hasOwnProperty.call(kwargs, key)) {
  2663. return "";
  2664. }
  2665. return "" + kwargs[(typeof key === "number" && key < 0) ? kwargs.length + key : key];
  2666. };
  2667. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  2668. __argnames__ : {value: ["match", "key"]}
  2669. });
  2670. return ρσ_anonfunc;
  2671. })());
  2672. };
  2673. if (!resolve_format_spec.__argnames__) Object.defineProperties(resolve_format_spec, {
  2674. __argnames__ : {value: ["format_spec"]}
  2675. });
  2676. function set_comma(ans, comma) {
  2677. var sep;
  2678. if (comma !== ",") {
  2679. sep = 1234;
  2680. sep = sep.toLocaleString(undefined, {useGrouping: true})[1];
  2681. ans = str.replace(ans, sep, comma);
  2682. }
  2683. return ans;
  2684. };
  2685. if (!set_comma.__argnames__) Object.defineProperties(set_comma, {
  2686. __argnames__ : {value: ["ans", "comma"]}
  2687. });
  2688. function safe_comma(value, comma) {
  2689. try {
  2690. return set_comma(value.toLocaleString(undefined, {useGrouping: true}), comma);
  2691. } catch (ρσ_Exception) {
  2692. ρσ_last_exception = ρσ_Exception;
  2693. {
  2694. return value.toString(10);
  2695. }
  2696. }
  2697. };
  2698. if (!safe_comma.__argnames__) Object.defineProperties(safe_comma, {
  2699. __argnames__ : {value: ["value", "comma"]}
  2700. });
  2701. function safe_fixed(value, precision, comma) {
  2702. if (!comma) {
  2703. return value.toFixed(precision);
  2704. }
  2705. try {
  2706. return set_comma(value.toLocaleString(undefined, {useGrouping: true, minimumFractionDigits: precision, maximumFractionDigits: precision}), comma);
  2707. } catch (ρσ_Exception) {
  2708. ρσ_last_exception = ρσ_Exception;
  2709. {
  2710. return value.toFixed(precision);
  2711. }
  2712. }
  2713. };
  2714. if (!safe_fixed.__argnames__) Object.defineProperties(safe_fixed, {
  2715. __argnames__ : {value: ["value", "precision", "comma"]}
  2716. });
  2717. function apply_formatting(value, format_spec) {
  2718. var ρσ_unpack, fill, align, sign, fhash, zeropad, width, comma, precision, ftype, is_numeric, is_int, lftype, code, prec, exp, nval, is_positive, left, right;
  2719. if (format_spec.indexOf("{") !== -1) {
  2720. format_spec = resolve_format_spec(format_spec);
  2721. }
  2722. if (ρσ_str.format._template_format_pat === undefined) {
  2723. ρσ_str.format._template_format_pat = /([^{}](?=[<>=^]))?([<>=^])?([-+\x20])?(\#)?(0)?(\d+)?([,_])?(?:\.(\d+))?([bcdeEfFgGnosxX%])?/;
  2724. }
  2725. try {
  2726. ρσ_unpack = format_spec.match(ρσ_str.format._template_format_pat).slice(1);
  2727. ρσ_unpack = ρσ_unpack_asarray(9, ρσ_unpack);
  2728. fill = ρσ_unpack[0];
  2729. align = ρσ_unpack[1];
  2730. sign = ρσ_unpack[2];
  2731. fhash = ρσ_unpack[3];
  2732. zeropad = ρσ_unpack[4];
  2733. width = ρσ_unpack[5];
  2734. comma = ρσ_unpack[6];
  2735. precision = ρσ_unpack[7];
  2736. ftype = ρσ_unpack[8];
  2737. } catch (ρσ_Exception) {
  2738. ρσ_last_exception = ρσ_Exception;
  2739. if (ρσ_Exception instanceof TypeError) {
  2740. return value;
  2741. } else {
  2742. throw ρσ_Exception;
  2743. }
  2744. }
  2745. if (zeropad) {
  2746. fill = fill || "0";
  2747. align = align || "=";
  2748. } else {
  2749. fill = fill || " ";
  2750. align = align || ">";
  2751. }
  2752. is_numeric = Number(value) === value;
  2753. is_int = is_numeric && value % 1 === 0;
  2754. precision = parseInt(precision, 10);
  2755. lftype = (ftype || "").toLowerCase();
  2756. if (ftype === "n") {
  2757. is_numeric = true;
  2758. if (is_int) {
  2759. if (comma) {
  2760. throw new ValueError("Cannot specify ',' with 'n'");
  2761. }
  2762. value = parseInt(value, 10).toLocaleString();
  2763. } else {
  2764. value = parseFloat(value).toLocaleString();
  2765. }
  2766. } else if (['b', 'c', 'd', 'o', 'x'].indexOf(lftype) !== -1) {
  2767. value = parseInt(value, 10);
  2768. is_numeric = true;
  2769. if (!isNaN(value)) {
  2770. if (ftype === "b") {
  2771. value = (value >>> 0).toString(2);
  2772. if (fhash) {
  2773. value = "0b" + value;
  2774. }
  2775. } else if (ftype === "c") {
  2776. if (value > 65535) {
  2777. code = value - 65536;
  2778. value = String.fromCharCode(55296 + (code >> 10), 56320 + (code & 1023));
  2779. } else {
  2780. value = String.fromCharCode(value);
  2781. }
  2782. } else if (ftype === "d") {
  2783. if (comma) {
  2784. value = safe_comma(value, comma);
  2785. } else {
  2786. value = value.toString(10);
  2787. }
  2788. } else if (ftype === "o") {
  2789. value = value.toString(8);
  2790. if (fhash) {
  2791. value = "0o" + value;
  2792. }
  2793. } else if (lftype === "x") {
  2794. value = value.toString(16);
  2795. value = (ftype === "x") ? value.toLowerCase() : value.toUpperCase();
  2796. if (fhash) {
  2797. value = "0x" + value;
  2798. }
  2799. }
  2800. }
  2801. } else if (['e','f','g','%'].indexOf(lftype) !== -1) {
  2802. is_numeric = true;
  2803. value = parseFloat(value);
  2804. prec = (isNaN(precision)) ? 6 : precision;
  2805. if (lftype === "e") {
  2806. value = value.toExponential(prec);
  2807. value = (ftype === "E") ? value.toUpperCase() : value.toLowerCase();
  2808. } else if (lftype === "f") {
  2809. value = safe_fixed(value, prec, comma);
  2810. value = (ftype === "F") ? value.toUpperCase() : value.toLowerCase();
  2811. } else if (lftype === "%") {
  2812. value *= 100;
  2813. value = safe_fixed(value, prec, comma) + "%";
  2814. } else if (lftype === "g") {
  2815. prec = max(1, prec);
  2816. exp = parseInt(split(value.toExponential(prec - 1).toLowerCase(), "e")[1], 10);
  2817. if (-4 <= exp && exp < prec) {
  2818. value = safe_fixed(value, prec - 1 - exp, comma);
  2819. } else {
  2820. value = value.toExponential(prec - 1);
  2821. }
  2822. value = value.replace(/0+$/g, "");
  2823. if (value[value.length-1] === ".") {
  2824. value = value.slice(0, -1);
  2825. }
  2826. if (ftype === "G") {
  2827. value = value.toUpperCase();
  2828. }
  2829. }
  2830. } else {
  2831. if (comma) {
  2832. value = parseInt(value, 10);
  2833. if (isNaN(value)) {
  2834. throw new ValueError("Must use numbers with , or _");
  2835. }
  2836. value = safe_comma(value, comma);
  2837. }
  2838. value += "";
  2839. if (!isNaN(precision)) {
  2840. value = value.slice(0, precision);
  2841. }
  2842. }
  2843. value += "";
  2844. if (is_numeric && sign) {
  2845. nval = Number(value);
  2846. is_positive = !isNaN(nval) && nval >= 0;
  2847. if (is_positive && (sign === " " || sign === "+")) {
  2848. value = sign + value;
  2849. }
  2850. }
  2851. function repeat(char, num) {
  2852. return (new Array(num+1)).join(char);
  2853. };
  2854. if (!repeat.__argnames__) Object.defineProperties(repeat, {
  2855. __argnames__ : {value: ["char", "num"]}
  2856. });
  2857. if (is_numeric && width && width[0] === "0") {
  2858. width = width.slice(1);
  2859. ρσ_unpack = ["0", "="];
  2860. fill = ρσ_unpack[0];
  2861. align = ρσ_unpack[1];
  2862. }
  2863. width = parseInt(width || "-1", 10);
  2864. if (isNaN(width)) {
  2865. throw new ValueError("Invalid width specification: " + width);
  2866. }
  2867. if (fill && value.length < width) {
  2868. if (align === "<") {
  2869. value = value + repeat(fill, width - value.length);
  2870. } else if (align === ">") {
  2871. value = repeat(fill, width - value.length) + value;
  2872. } else if (align === "^") {
  2873. left = Math.floor((width - value.length) / 2);
  2874. right = width - left - value.length;
  2875. value = repeat(fill, left) + value + repeat(fill, right);
  2876. } else if (align === "=") {
  2877. if (ρσ_in(value[0], "+- ")) {
  2878. value = value[0] + repeat(fill, width - value.length) + value.slice(1);
  2879. } else {
  2880. value = repeat(fill, width - value.length) + value;
  2881. }
  2882. } else {
  2883. throw new ValueError("Unrecognized alignment: " + align);
  2884. }
  2885. }
  2886. return value;
  2887. };
  2888. if (!apply_formatting.__argnames__) Object.defineProperties(apply_formatting, {
  2889. __argnames__ : {value: ["value", "format_spec"]}
  2890. });
  2891. function parse_markup(markup) {
  2892. var key, transformer, format_spec, pos, state, ch;
  2893. key = transformer = format_spec = "";
  2894. pos = 0;
  2895. state = 0;
  2896. while (pos < markup.length) {
  2897. ch = markup[(typeof pos === "number" && pos < 0) ? markup.length + pos : pos];
  2898. if (state === 0) {
  2899. if (ch === "!") {
  2900. state = 1;
  2901. } else if (ch === ":") {
  2902. state = 2;
  2903. } else {
  2904. key += ch;
  2905. }
  2906. } else if (state === 1) {
  2907. if (ch === ":") {
  2908. state = 2;
  2909. } else {
  2910. transformer += ch;
  2911. }
  2912. } else {
  2913. format_spec += ch;
  2914. }
  2915. pos += 1;
  2916. }
  2917. return [key, transformer, format_spec];
  2918. };
  2919. if (!parse_markup.__argnames__) Object.defineProperties(parse_markup, {
  2920. __argnames__ : {value: ["markup"]}
  2921. });
  2922. function render_markup(markup) {
  2923. var ρσ_unpack, key, transformer, format_spec, lkey, nvalue, object, ans;
  2924. ρσ_unpack = parse_markup(markup);
  2925. ρσ_unpack = ρσ_unpack_asarray(3, ρσ_unpack);
  2926. key = ρσ_unpack[0];
  2927. transformer = ρσ_unpack[1];
  2928. format_spec = ρσ_unpack[2];
  2929. if (transformer && ['a', 'r', 's'].indexOf(transformer) === -1) {
  2930. throw new ValueError("Unknown conversion specifier: " + transformer);
  2931. }
  2932. lkey = key.length && split(key, /[.\[]/, 1)[0];
  2933. if (lkey) {
  2934. explicit = true;
  2935. if (implicit) {
  2936. throw new ValueError("cannot switch from automatic field numbering to manual field specification");
  2937. }
  2938. nvalue = parseInt(lkey);
  2939. object = (isNaN(nvalue)) ? kwargs[(typeof lkey === "number" && lkey < 0) ? kwargs.length + lkey : lkey] : args[(typeof nvalue === "number" && nvalue < 0) ? args.length + nvalue : nvalue];
  2940. if (object === undefined) {
  2941. if (isNaN(nvalue)) {
  2942. throw new KeyError(lkey);
  2943. }
  2944. throw new IndexError(lkey);
  2945. }
  2946. object = resolve(key.slice(lkey.length), object);
  2947. } else {
  2948. implicit = true;
  2949. if (explicit) {
  2950. throw new ValueError("cannot switch from manual field specification to automatic field numbering");
  2951. }
  2952. if (idx >= args.length) {
  2953. throw new IndexError("Not enough arguments to match template: " + template);
  2954. }
  2955. object = args[(typeof idx === "number" && idx < 0) ? args.length + idx : idx];
  2956. idx += 1;
  2957. }
  2958. if (typeof object === "function") {
  2959. object = object();
  2960. }
  2961. ans = "" + object;
  2962. if (format_spec) {
  2963. ans = apply_formatting(ans, format_spec);
  2964. }
  2965. return ans;
  2966. };
  2967. if (!render_markup.__argnames__) Object.defineProperties(render_markup, {
  2968. __argnames__ : {value: ["markup"]}
  2969. });
  2970. ans = "";
  2971. pos = 0;
  2972. in_brace = 0;
  2973. markup = "";
  2974. while (pos < template.length) {
  2975. ch = template[(typeof pos === "number" && pos < 0) ? template.length + pos : pos];
  2976. if (in_brace) {
  2977. if (ch === "{") {
  2978. in_brace += 1;
  2979. markup += "{";
  2980. } else if (ch === "}") {
  2981. in_brace -= 1;
  2982. if (in_brace > 0) {
  2983. markup += "}";
  2984. } else {
  2985. ans += render_markup(markup);
  2986. }
  2987. } else {
  2988. markup += ch;
  2989. }
  2990. } else {
  2991. if (ch === "{") {
  2992. if (template[ρσ_bound_index(pos + 1, template)] === "{") {
  2993. pos += 1;
  2994. ans += "{";
  2995. } else {
  2996. in_brace = 1;
  2997. markup = "";
  2998. }
  2999. } else {
  3000. ans += ch;
  3001. if (ch === "}" && template[ρσ_bound_index(pos + 1, template)] === "}") {
  3002. pos += 1;
  3003. }
  3004. }
  3005. }
  3006. pos += 1;
  3007. }
  3008. if (in_brace) {
  3009. throw new ValueError("expected '}' before end of string");
  3010. }
  3011. return ans;
  3012. });
  3013. define_str_func("capitalize", function () {
  3014. var string;
  3015. string = this;
  3016. if (string) {
  3017. string = string[0].toUpperCase() + string.slice(1).toLowerCase();
  3018. }
  3019. return string;
  3020. });
  3021. define_str_func("center", (function() {
  3022. var ρσ_anonfunc = function (width, fill) {
  3023. var left, right;
  3024. left = Math.floor((width - this.length) / 2);
  3025. right = width - left - this.length;
  3026. fill = fill || " ";
  3027. return new Array(left+1).join(fill) + this + new Array(right+1).join(fill);
  3028. };
  3029. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3030. __argnames__ : {value: ["width", "fill"]}
  3031. });
  3032. return ρσ_anonfunc;
  3033. })());
  3034. define_str_func("count", (function() {
  3035. var ρσ_anonfunc = function (needle, start, end) {
  3036. var string, ρσ_unpack, pos, step, ans;
  3037. string = this;
  3038. start = start || 0;
  3039. end = end || string.length;
  3040. if (start < 0 || end < 0) {
  3041. string = string.slice(start, end);
  3042. ρσ_unpack = [0, string.length];
  3043. start = ρσ_unpack[0];
  3044. end = ρσ_unpack[1];
  3045. }
  3046. pos = start;
  3047. step = needle.length;
  3048. if (!step) {
  3049. return 0;
  3050. }
  3051. ans = 0;
  3052. while (pos !== -1) {
  3053. pos = string.indexOf(needle, pos);
  3054. if (pos !== -1) {
  3055. ans += 1;
  3056. pos += step;
  3057. }
  3058. }
  3059. return ans;
  3060. };
  3061. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3062. __argnames__ : {value: ["needle", "start", "end"]}
  3063. });
  3064. return ρσ_anonfunc;
  3065. })());
  3066. define_str_func("endswith", (function() {
  3067. var ρσ_anonfunc = function (suffixes, start, end) {
  3068. var string, q;
  3069. string = this;
  3070. start = start || 0;
  3071. if (typeof suffixes === "string") {
  3072. suffixes = [suffixes];
  3073. }
  3074. if (end !== undefined) {
  3075. string = string.slice(0, end);
  3076. }
  3077. for (var i = 0; i < suffixes.length; i++) {
  3078. q = suffixes[(typeof i === "number" && i < 0) ? suffixes.length + i : i];
  3079. if (string.indexOf(q, Math.max(start, string.length - q.length)) !== -1) {
  3080. return true;
  3081. }
  3082. }
  3083. return false;
  3084. };
  3085. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3086. __argnames__ : {value: ["suffixes", "start", "end"]}
  3087. });
  3088. return ρσ_anonfunc;
  3089. })());
  3090. define_str_func("startswith", (function() {
  3091. var ρσ_anonfunc = function (prefixes, start, end) {
  3092. var prefix;
  3093. start = start || 0;
  3094. if (typeof prefixes === "string") {
  3095. prefixes = [prefixes];
  3096. }
  3097. for (var i = 0; i < prefixes.length; i++) {
  3098. prefix = prefixes[(typeof i === "number" && i < 0) ? prefixes.length + i : i];
  3099. end = (end === undefined) ? this.length : end;
  3100. if (end - start >= prefix.length && prefix === this.slice(start, start + prefix.length)) {
  3101. return true;
  3102. }
  3103. }
  3104. return false;
  3105. };
  3106. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3107. __argnames__ : {value: ["prefixes", "start", "end"]}
  3108. });
  3109. return ρσ_anonfunc;
  3110. })());
  3111. define_str_func("find", (function() {
  3112. var ρσ_anonfunc = function (needle, start, end) {
  3113. var ans;
  3114. while (start < 0) {
  3115. start += this.length;
  3116. }
  3117. ans = this.indexOf(needle, start);
  3118. if (end !== undefined && ans !== -1) {
  3119. while (end < 0) {
  3120. end += this.length;
  3121. }
  3122. if (ans >= end - needle.length) {
  3123. return -1;
  3124. }
  3125. }
  3126. return ans;
  3127. };
  3128. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3129. __argnames__ : {value: ["needle", "start", "end"]}
  3130. });
  3131. return ρσ_anonfunc;
  3132. })());
  3133. define_str_func("rfind", (function() {
  3134. var ρσ_anonfunc = function (needle, start, end) {
  3135. var ans;
  3136. while (end < 0) {
  3137. end += this.length;
  3138. }
  3139. ans = this.lastIndexOf(needle, end - 1);
  3140. if (start !== undefined && ans !== -1) {
  3141. while (start < 0) {
  3142. start += this.length;
  3143. }
  3144. if (ans < start) {
  3145. return -1;
  3146. }
  3147. }
  3148. return ans;
  3149. };
  3150. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3151. __argnames__ : {value: ["needle", "start", "end"]}
  3152. });
  3153. return ρσ_anonfunc;
  3154. })());
  3155. define_str_func("index", (function() {
  3156. var ρσ_anonfunc = function (needle, start, end) {
  3157. var ans;
  3158. ans = ρσ_str.prototype.find.apply(this, arguments);
  3159. if (ans === -1) {
  3160. throw new ValueError("substring not found");
  3161. }
  3162. return ans;
  3163. };
  3164. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3165. __argnames__ : {value: ["needle", "start", "end"]}
  3166. });
  3167. return ρσ_anonfunc;
  3168. })());
  3169. define_str_func("rindex", (function() {
  3170. var ρσ_anonfunc = function (needle, start, end) {
  3171. var ans;
  3172. ans = ρσ_str.prototype.rfind.apply(this, arguments);
  3173. if (ans === -1) {
  3174. throw new ValueError("substring not found");
  3175. }
  3176. return ans;
  3177. };
  3178. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3179. __argnames__ : {value: ["needle", "start", "end"]}
  3180. });
  3181. return ρσ_anonfunc;
  3182. })());
  3183. define_str_func("islower", function () {
  3184. return this.length > 0 && this.toLowerCase() === this.toString();
  3185. });
  3186. define_str_func("isupper", function () {
  3187. return this.length > 0 && this.toUpperCase() === this.toString();
  3188. });
  3189. define_str_func("isspace", function () {
  3190. return this.length > 0 && /^\s+$/.test(this);
  3191. });
  3192. define_str_func("join", (function() {
  3193. var ρσ_anonfunc = function (iterable) {
  3194. var ans, r;
  3195. if (Array.isArray(iterable)) {
  3196. return iterable.join(this);
  3197. }
  3198. ans = "";
  3199. r = iterable.next();
  3200. while (!r.done) {
  3201. if (ans) {
  3202. ans += this;
  3203. }
  3204. ans += r.value;
  3205. r = iterable.next();
  3206. }
  3207. return ans;
  3208. };
  3209. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3210. __argnames__ : {value: ["iterable"]}
  3211. });
  3212. return ρσ_anonfunc;
  3213. })());
  3214. define_str_func("ljust", (function() {
  3215. var ρσ_anonfunc = function (width, fill) {
  3216. var string;
  3217. string = this;
  3218. if (width > string.length) {
  3219. fill = fill || " ";
  3220. string += new Array(width - string.length + 1).join(fill);
  3221. }
  3222. return string;
  3223. };
  3224. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3225. __argnames__ : {value: ["width", "fill"]}
  3226. });
  3227. return ρσ_anonfunc;
  3228. })());
  3229. define_str_func("rjust", (function() {
  3230. var ρσ_anonfunc = function (width, fill) {
  3231. var string;
  3232. string = this;
  3233. if (width > string.length) {
  3234. fill = fill || " ";
  3235. string = new Array(width - string.length + 1).join(fill) + string;
  3236. }
  3237. return string;
  3238. };
  3239. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3240. __argnames__ : {value: ["width", "fill"]}
  3241. });
  3242. return ρσ_anonfunc;
  3243. })());
  3244. define_str_func("lower", function () {
  3245. return this.toLowerCase();
  3246. });
  3247. define_str_func("upper", function () {
  3248. return this.toUpperCase();
  3249. });
  3250. define_str_func("lstrip", (function() {
  3251. var ρσ_anonfunc = function (chars) {
  3252. var string, pos;
  3253. string = this;
  3254. pos = 0;
  3255. chars = chars || ρσ_str.whitespace;
  3256. while (chars.indexOf(string[(typeof pos === "number" && pos < 0) ? string.length + pos : pos]) !== -1) {
  3257. pos += 1;
  3258. }
  3259. if (pos) {
  3260. string = string.slice(pos);
  3261. }
  3262. return string;
  3263. };
  3264. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3265. __argnames__ : {value: ["chars"]}
  3266. });
  3267. return ρσ_anonfunc;
  3268. })());
  3269. define_str_func("rstrip", (function() {
  3270. var ρσ_anonfunc = function (chars) {
  3271. var string, pos;
  3272. string = this;
  3273. pos = string.length - 1;
  3274. chars = chars || ρσ_str.whitespace;
  3275. while (chars.indexOf(string[(typeof pos === "number" && pos < 0) ? string.length + pos : pos]) !== -1) {
  3276. pos -= 1;
  3277. }
  3278. if (pos < string.length - 1) {
  3279. string = string.slice(0, pos + 1);
  3280. }
  3281. return string;
  3282. };
  3283. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3284. __argnames__ : {value: ["chars"]}
  3285. });
  3286. return ρσ_anonfunc;
  3287. })());
  3288. define_str_func("strip", (function() {
  3289. var ρσ_anonfunc = function (chars) {
  3290. return ρσ_str.prototype.lstrip.call(ρσ_str.prototype.rstrip.call(this, chars), chars);
  3291. };
  3292. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3293. __argnames__ : {value: ["chars"]}
  3294. });
  3295. return ρσ_anonfunc;
  3296. })());
  3297. define_str_func("partition", (function() {
  3298. var ρσ_anonfunc = function (sep) {
  3299. var idx;
  3300. idx = this.indexOf(sep);
  3301. if (idx === -1) {
  3302. return [this, "", ""];
  3303. }
  3304. return [this.slice(0, idx), sep, this.slice(idx + sep.length)];
  3305. };
  3306. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3307. __argnames__ : {value: ["sep"]}
  3308. });
  3309. return ρσ_anonfunc;
  3310. })());
  3311. define_str_func("rpartition", (function() {
  3312. var ρσ_anonfunc = function (sep) {
  3313. var idx;
  3314. idx = this.lastIndexOf(sep);
  3315. if (idx === -1) {
  3316. return ["", "", this];
  3317. }
  3318. return [this.slice(0, idx), sep, this.slice(idx + sep.length)];
  3319. };
  3320. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3321. __argnames__ : {value: ["sep"]}
  3322. });
  3323. return ρσ_anonfunc;
  3324. })());
  3325. define_str_func("replace", (function() {
  3326. var ρσ_anonfunc = function (old, repl, count) {
  3327. var string, pos, idx;
  3328. string = this;
  3329. if (count === 1) {
  3330. return ρσ_orig_replace(string, old, repl);
  3331. }
  3332. if (count < 1) {
  3333. return string;
  3334. }
  3335. count = count || Number.MAX_VALUE;
  3336. pos = 0;
  3337. while (count > 0) {
  3338. count -= 1;
  3339. idx = string.indexOf(old, pos);
  3340. if (idx === -1) {
  3341. break;
  3342. }
  3343. pos = idx + repl.length;
  3344. string = string.slice(0, idx) + repl + string.slice(idx + old.length);
  3345. }
  3346. return string;
  3347. };
  3348. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3349. __argnames__ : {value: ["old", "repl", "count"]}
  3350. });
  3351. return ρσ_anonfunc;
  3352. })());
  3353. define_str_func("split", (function() {
  3354. var ρσ_anonfunc = function (sep, maxsplit) {
  3355. var split, ans, extra, parts;
  3356. if (maxsplit === 0) {
  3357. return ρσ_list_decorate([ this ]);
  3358. }
  3359. split = ρσ_orig_split;
  3360. if (sep === undefined || sep === null) {
  3361. if (maxsplit > 0) {
  3362. ans = split(this, /(\s+)/);
  3363. extra = "";
  3364. parts = [];
  3365. for (var i = 0; i < ans.length; i++) {
  3366. if (parts.length >= maxsplit + 1) {
  3367. extra += ans[(typeof i === "number" && i < 0) ? ans.length + i : i];
  3368. } else if (i % 2 === 0) {
  3369. parts.push(ans[(typeof i === "number" && i < 0) ? ans.length + i : i]);
  3370. }
  3371. }
  3372. parts[parts.length-1] += extra;
  3373. ans = parts;
  3374. } else {
  3375. ans = split(this, /\s+/);
  3376. }
  3377. } else {
  3378. if (sep === "") {
  3379. throw new ValueError("empty separator");
  3380. }
  3381. ans = split(this, sep);
  3382. if (maxsplit > 0 && ans.length > maxsplit) {
  3383. extra = ans.slice(maxsplit).join(sep);
  3384. ans = ans.slice(0, maxsplit);
  3385. ans.push(extra);
  3386. }
  3387. }
  3388. return ρσ_list_decorate(ans);
  3389. };
  3390. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3391. __argnames__ : {value: ["sep", "maxsplit"]}
  3392. });
  3393. return ρσ_anonfunc;
  3394. })());
  3395. define_str_func("rsplit", (function() {
  3396. var ρσ_anonfunc = function (sep, maxsplit) {
  3397. var split, ans, is_space, pos, current, spc, ch, end, idx;
  3398. if (!maxsplit) {
  3399. return ρσ_str.prototype.split.call(this, sep);
  3400. }
  3401. split = ρσ_orig_split;
  3402. if (sep === undefined || sep === null) {
  3403. if (maxsplit > 0) {
  3404. ans = [];
  3405. is_space = /\s/;
  3406. pos = this.length - 1;
  3407. current = "";
  3408. while (pos > -1 && maxsplit > 0) {
  3409. spc = false;
  3410. ch = (ρσ_expr_temp = this)[(typeof pos === "number" && pos < 0) ? ρσ_expr_temp.length + pos : pos];
  3411. while (pos > -1 && is_space.test(ch)) {
  3412. spc = true;
  3413. ch = this[--pos];
  3414. }
  3415. if (spc) {
  3416. if (current) {
  3417. ans.push(current);
  3418. maxsplit -= 1;
  3419. }
  3420. current = ch;
  3421. } else {
  3422. current += ch;
  3423. }
  3424. pos -= 1;
  3425. }
  3426. ans.push(this.slice(0, pos + 1) + current);
  3427. ans.reverse();
  3428. } else {
  3429. ans = split(this, /\s+/);
  3430. }
  3431. } else {
  3432. if (sep === "") {
  3433. throw new ValueError("empty separator");
  3434. }
  3435. ans = [];
  3436. pos = end = this.length;
  3437. while (pos > -1 && maxsplit > 0) {
  3438. maxsplit -= 1;
  3439. idx = this.lastIndexOf(sep, pos);
  3440. if (idx === -1) {
  3441. break;
  3442. }
  3443. ans.push(this.slice(idx + sep.length, end));
  3444. pos = idx - 1;
  3445. end = idx;
  3446. }
  3447. ans.push(this.slice(0, end));
  3448. ans.reverse();
  3449. }
  3450. return ρσ_list_decorate(ans);
  3451. };
  3452. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3453. __argnames__ : {value: ["sep", "maxsplit"]}
  3454. });
  3455. return ρσ_anonfunc;
  3456. })());
  3457. define_str_func("splitlines", (function() {
  3458. var ρσ_anonfunc = function (keepends) {
  3459. var split, parts, ans;
  3460. split = ρσ_orig_split;
  3461. if (keepends) {
  3462. parts = split(this, /((?:\r?\n)|\r)/);
  3463. ans = [];
  3464. for (var i = 0; i < parts.length; i++) {
  3465. if (i % 2 === 0) {
  3466. ans.push(parts[(typeof i === "number" && i < 0) ? parts.length + i : i]);
  3467. } else {
  3468. ans[ans.length-1] += parts[(typeof i === "number" && i < 0) ? parts.length + i : i];
  3469. }
  3470. }
  3471. } else {
  3472. ans = split(this, /(?:\r?\n)|\r/);
  3473. }
  3474. return ρσ_list_decorate(ans);
  3475. };
  3476. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3477. __argnames__ : {value: ["keepends"]}
  3478. });
  3479. return ρσ_anonfunc;
  3480. })());
  3481. define_str_func("swapcase", function () {
  3482. var ans, a, b;
  3483. ans = new Array(this.length);
  3484. for (var i = 0; i < ans.length; i++) {
  3485. a = (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i];
  3486. b = a.toLowerCase();
  3487. if (a === b) {
  3488. b = a.toUpperCase();
  3489. }
  3490. ans[(typeof i === "number" && i < 0) ? ans.length + i : i] = b;
  3491. }
  3492. return ans.join("");
  3493. });
  3494. define_str_func("zfill", (function() {
  3495. var ρσ_anonfunc = function (width) {
  3496. var string;
  3497. string = this;
  3498. if (width > string.length) {
  3499. string = new Array(width - string.length + 1).join("0") + string;
  3500. }
  3501. return string;
  3502. };
  3503. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3504. __argnames__ : {value: ["width"]}
  3505. });
  3506. return ρσ_anonfunc;
  3507. })());
  3508. ρσ_str.uchrs = (function() {
  3509. var ρσ_anonfunc = function (string, with_positions) {
  3510. return (function(){
  3511. var ρσ_d = {};
  3512. ρσ_d["_string"] = string;
  3513. ρσ_d["_pos"] = 0;
  3514. ρσ_d[ρσ_iterator_symbol] = function () {
  3515. return this;
  3516. };
  3517. ρσ_d["next"] = function () {
  3518. var length, pos, value, ans, extra;
  3519. length = this._string.length;
  3520. if (this._pos >= length) {
  3521. return (function(){
  3522. var ρσ_d = {};
  3523. ρσ_d["done"] = true;
  3524. return ρσ_d;
  3525. }).call(this);
  3526. }
  3527. pos = this._pos;
  3528. value = this._string.charCodeAt(this._pos++);
  3529. ans = "\ufffd";
  3530. if (55296 <= value && value <= 56319) {
  3531. if (this._pos < length) {
  3532. extra = this._string.charCodeAt(this._pos++);
  3533. if ((extra & 56320) === 56320) {
  3534. ans = String.fromCharCode(value, extra);
  3535. }
  3536. }
  3537. } else if ((value & 56320) !== 56320) {
  3538. ans = String.fromCharCode(value);
  3539. }
  3540. if (with_positions) {
  3541. return (function(){
  3542. var ρσ_d = {};
  3543. ρσ_d["done"] = false;
  3544. ρσ_d["value"] = ρσ_list_decorate([ pos, ans ]);
  3545. return ρσ_d;
  3546. }).call(this);
  3547. } else {
  3548. return (function(){
  3549. var ρσ_d = {};
  3550. ρσ_d["done"] = false;
  3551. ρσ_d["value"] = ans;
  3552. return ρσ_d;
  3553. }).call(this);
  3554. }
  3555. };
  3556. return ρσ_d;
  3557. }).call(this);
  3558. };
  3559. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3560. __argnames__ : {value: ["string", "with_positions"]}
  3561. });
  3562. return ρσ_anonfunc;
  3563. })();
  3564. ρσ_str.uslice = (function() {
  3565. var ρσ_anonfunc = function (string, start, end) {
  3566. var items, iterator, r;
  3567. items = [];
  3568. iterator = ρσ_str.uchrs(string);
  3569. r = iterator.next();
  3570. while (!r.done) {
  3571. items.push(r.value);
  3572. r = iterator.next();
  3573. }
  3574. return items.slice(start || 0, (end === undefined) ? items.length : end).join("");
  3575. };
  3576. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3577. __argnames__ : {value: ["string", "start", "end"]}
  3578. });
  3579. return ρσ_anonfunc;
  3580. })();
  3581. ρσ_str.ulen = (function() {
  3582. var ρσ_anonfunc = function (string) {
  3583. var iterator, r, ans;
  3584. iterator = ρσ_str.uchrs(string);
  3585. r = iterator.next();
  3586. ans = 0;
  3587. while (!r.done) {
  3588. r = iterator.next();
  3589. ans += 1;
  3590. }
  3591. return ans;
  3592. };
  3593. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3594. __argnames__ : {value: ["string"]}
  3595. });
  3596. return ρσ_anonfunc;
  3597. })();
  3598. ρσ_str.ascii_lowercase = "abcdefghijklmnopqrstuvwxyz";
  3599. ρσ_str.ascii_uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  3600. ρσ_str.ascii_letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  3601. ρσ_str.digits = "0123456789";
  3602. ρσ_str.punctuation = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
  3603. ρσ_str.printable = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\u000b\f";
  3604. ρσ_str.whitespace = " \t\n\r\u000b\f";
  3605. define_str_func = undefined;
  3606. var str = ρσ_str, repr = ρσ_repr;;
  3607. var ρσ_modules = {};
  3608. ρσ_modules.pythonize = {};
  3609. (function(){
  3610. var __name__ = "pythonize";
  3611. function strings() {
  3612. var string_funcs, exclude, name;
  3613. string_funcs = set("capitalize strip lstrip rstrip islower isupper isspace lower upper swapcase center count endswith startswith find rfind index rindex format join ljust rjust partition rpartition replace split rsplit splitlines zfill".split(" "));
  3614. if (!arguments.length) {
  3615. exclude = (function(){
  3616. var s = ρσ_set();
  3617. s.jsset.add("split");
  3618. s.jsset.add("replace");
  3619. return s;
  3620. })();
  3621. } else if (arguments[0]) {
  3622. exclude = Array.prototype.slice.call(arguments);
  3623. } else {
  3624. exclude = null;
  3625. }
  3626. if (exclude) {
  3627. string_funcs = string_funcs.difference(set(exclude));
  3628. }
  3629. var ρσ_Iter0 = ρσ_Iterable(string_funcs);
  3630. for (var ρσ_Index0 = 0; ρσ_Index0 < ρσ_Iter0.length; ρσ_Index0++) {
  3631. name = ρσ_Iter0[ρσ_Index0];
  3632. (ρσ_expr_temp = String.prototype)[(typeof name === "number" && name < 0) ? ρσ_expr_temp.length + name : name] = (ρσ_expr_temp = ρσ_str.prototype)[(typeof name === "number" && name < 0) ? ρσ_expr_temp.length + name : name];
  3633. }
  3634. };
  3635. ρσ_modules.pythonize.strings = strings;
  3636. })();
  3637. var __name__ = "__main__";
  3638. var strings = ρσ_modules.pythonize.strings;
  3639. strings();
  3640. function input() {
  3641. var args = Array.prototype.slice.call(arguments, 0);
  3642. if (arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) args.pop();
  3643. return prompt(args);
  3644. };
  3645. if (!input.__handles_kwarg_interpolation__) Object.defineProperties(input, {
  3646. __handles_kwarg_interpolation__ : {value: true}
  3647. });
  3648. function clearScreen() {
  3649. var color = (arguments[0] === undefined || ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? clearScreen.__defaults__.color : arguments[0];
  3650. var ρσ_kwargs_obj = arguments[arguments.length-1];
  3651. if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {};
  3652. if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "color")){
  3653. color = ρσ_kwargs_obj.color;
  3654. }
  3655. function clearScreenAsync() {
  3656. var element;
  3657. element = document.getElementById("__terminal__");
  3658. if (element) {
  3659. element.innerHTML = "";
  3660. }
  3661. };
  3662. if (color) {
  3663. document.body.style.backgroundColor = color;
  3664. }
  3665. setTimeout(clearScreenAsync);
  3666. };
  3667. if (!clearScreen.__defaults__) Object.defineProperties(clearScreen, {
  3668. __defaults__ : {value: {color:null}},
  3669. __handles_kwarg_interpolation__ : {value: true},
  3670. __argnames__ : {value: ["color"]}
  3671. });
  3672. function onKeyUp(e) {
  3673. if ((e.keyCode === 13 || typeof e.keyCode === "object" && ρσ_equals(e.keyCode, 13))) {
  3674. e.target.dispatchEvent(new Event("submit"));
  3675. }
  3676. };
  3677. if (!onKeyUp.__argnames__) Object.defineProperties(onKeyUp, {
  3678. __argnames__ : {value: ["e"]}
  3679. });
  3680. function inputAsync() {
  3681. var cb = (arguments[0] === undefined || ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? inputAsync.__defaults__.cb : arguments[0];
  3682. var ρσ_kwargs_obj = arguments[arguments.length-1];
  3683. if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {};
  3684. if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "cb")){
  3685. cb = ρσ_kwargs_obj.cb;
  3686. }
  3687. var el;
  3688. el = document.createElement("input");
  3689. el.className = "__terminal__";
  3690. el.onsubmit = (function() {
  3691. var ρσ_anonfunc = function (e) {
  3692. if (cb) {
  3693. if (ρσ_in(cb(el.value), ρσ_list_decorate([ undefined, true ]))) {
  3694. e.target.parentNode.removeChild(el);
  3695. }
  3696. }
  3697. function scrolldown() {
  3698. document.body.scrollTop = document.body.scrollHeight;
  3699. };
  3700. setTimeout(scrolldown);
  3701. };
  3702. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3703. __argnames__ : {value: ["e"]}
  3704. });
  3705. return ρσ_anonfunc;
  3706. })();
  3707. el.onkeyup = onKeyUp;
  3708. document.body.appendChild(el);
  3709. el.focus();
  3710. return el;
  3711. };
  3712. if (!inputAsync.__defaults__) Object.defineProperties(inputAsync, {
  3713. __defaults__ : {value: {cb:null}},
  3714. __handles_kwarg_interpolation__ : {value: true},
  3715. __argnames__ : {value: ["cb"]}
  3716. });
  3717. function ρσ_print() {
  3718. var kwargs = arguments[arguments.length-1];
  3719. if (kwargs === null || typeof kwargs !== "object" || kwargs [ρσ_kwargs_symbol] !== true) kwargs = {};
  3720. var args = Array.prototype.slice.call(arguments, 0);
  3721. if (kwargs !== null && typeof kwargs === "object" && kwargs [ρσ_kwargs_symbol] === true) args.pop();
  3722. var end, sep;
  3723. end = "\n";
  3724. sep = " ";
  3725. if (ρσ_in("end", kwargs)) {
  3726. end = kwargs["end"];
  3727. }
  3728. function printAsync() {
  3729. var element, addition, previous;
  3730. element = document.getElementById("__terminal__");
  3731. if (element) {
  3732. addition = sep.join((function() {
  3733. var ρσ_Iter = ρσ_Iterable(args), ρσ_Result = [], arg;
  3734. for (var ρσ_Index = 0; ρσ_Index < ρσ_Iter.length; ρσ_Index++) {
  3735. arg = ρσ_Iter[ρσ_Index];
  3736. ρσ_Result.push(arg);
  3737. }
  3738. ρσ_Result = ρσ_list_constructor(ρσ_Result);
  3739. return ρσ_Result;
  3740. })()) + end;
  3741. previous = element.innerHTML;
  3742. element.innerHTML = previous + addition.replace("\n", "<br>");
  3743. element.scrollTop = element.scrollHeight;
  3744. } else {
  3745. console.log(sep.join((function() {
  3746. var ρσ_Iter = ρσ_Iterable(args), ρσ_Result = [], arg;
  3747. for (var ρσ_Index = 0; ρσ_Index < ρσ_Iter.length; ρσ_Index++) {
  3748. arg = ρσ_Iter[ρσ_Index];
  3749. ρσ_Result.push(str(arg));
  3750. }
  3751. ρσ_Result = ρσ_list_constructor(ρσ_Result);
  3752. return ρσ_Result;
  3753. })()));
  3754. }
  3755. };
  3756. setTimeout(printAsync);
  3757. };
  3758. if (!ρσ_print.__handles_kwarg_interpolation__) Object.defineProperties(ρσ_print, {
  3759. __handles_kwarg_interpolation__ : {value: true}
  3760. });
  3761. window.onerror = (function() {
  3762. var ρσ_anonfunc = function (e) {
  3763. print(e);
  3764. };
  3765. if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {
  3766. __argnames__ : {value: ["e"]}
  3767. });
  3768. return ρσ_anonfunc;
  3769. })();