Skip to content

Instantly share code, notes, and snippets.

@justinas
Created July 1, 2024 19:15
Show Gist options
  • Save justinas/9f3bb9cec262b08c8dfa2d52b269ab7c to your computer and use it in GitHub Desktop.
Save justinas/9f3bb9cec262b08c8dfa2d52b269ab7c to your computer and use it in GitHub Desktop.
// Generated by the V compiler
var $global = (new Function("return this"))();
function $ref(value) { if (value instanceof $ref) { return value; } this.val = value; }
$ref.prototype.valueOf = function() { return this.val; }
const $os = require("os");
const $process = process;
function checkDefine(key) {
if (globalThis.hasOwnProperty(key)) { return !!globalThis[key]; } return false;
}
function BreakException() {}
function ContinueException() {}
function ReturnException(val) { this.val = val; }
function Array_rune_arr_eq(a,b) {
if (a.arr.length != b.arr.length) {
return new bool(false);
}
for (let i = 0; i < a.len; ++i) {
if (!vEq(a.arr.get(new int(i)),b.arr.get(new int(i)))) {
return new bool(false);
}
}
return new bool(true);
}
function Array_int_contains(a,v) {
for (let i = 0; i < a.len; ++i) {
if (vEq(a.arr.get(new int(i)),v)) {
return new bool(true);
}
}
return new bool(false);
}
function compare_RepIndex_by_idx(a,b) {
if (a.val.idx.valueOf() < b.val.idx.valueOf()) return -1;
else return 1;
}
function Array_string_index(a, v) {
let pelem = a.arr;
for (let i = 0; i < pelem.arr.length; ++i) {
if (pelem.get(new int(i)).str == v.str) {
return new int(i);
}
}
return new int(-1);
}
function time__Duration_alias_eq(a,b) {
return new bool(vEq(a,b));
}
function Array_string_contains(a,v) {
for (let i = 0; i < a.len; ++i) {
if (a.arr.get(new int(i)).str == v.str) {
return new bool(true);
}
}
return new bool(false);
}
function time__FormatTime_str(it) { /* gen_str_for_enum */
switch(it) {
case time__FormatTime.hhmm12: return new string("hhmm12");
case time__FormatTime.hhmm24: return new string("hhmm24");
case time__FormatTime.hhmmss12: return new string("hhmmss12");
case time__FormatTime.hhmmss24: return new string("hhmmss24");
case time__FormatTime.hhmmss24_milli: return new string("hhmmss24_milli");
case time__FormatTime.hhmmss24_micro: return new string("hhmmss24_micro");
case time__FormatTime.hhmmss24_nano: return new string("hhmmss24_nano");
case time__FormatTime.no_time: return new string("no_time");
default: return new string("unknown enum value");
}
}
function time__FormatDate_str(it) { /* gen_str_for_enum */
switch(it) {
case time__FormatDate.ddmmyy: return new string("ddmmyy");
case time__FormatDate.ddmmyyyy: return new string("ddmmyyyy");
case time__FormatDate.mmddyy: return new string("mmddyy");
case time__FormatDate.mmddyyyy: return new string("mmddyyyy");
case time__FormatDate.mmmd: return new string("mmmd");
case time__FormatDate.mmmdd: return new string("mmmdd");
case time__FormatDate.mmmddyy: return new string("mmmddyy");
case time__FormatDate.mmmddyyyy: return new string("mmmddyyyy");
case time__FormatDate.no_date: return new string("no_date");
case time__FormatDate.yyyymmdd: return new string("yyyymmdd");
case time__FormatDate.yymmdd: return new string("yymmdd");
default: return new string("unknown enum value");
}
}
function Array_u8_str(a) { return indent_Array_u8_str(a, 0);}
function indent_Array_u8_str(a, indent_count) {
let sb = strings__new_builder(a.len * 10);
strings__Builder_write_string(sb, new string("["));
for (let i = 0; i < a.len; ++i) {
let it = a.arr.get(new int(i));
strings__Builder_write_string(sb, new string(""));
let x = u8_str_escaped( it);
strings__Builder_write_string(sb, x);
if (i < a.len-1) {
strings__Builder_write_string(sb, new string(", "));
}
}
strings__Builder_write_string(sb, new string("]"));
let res = strings__Builder_str(sb);
return res;
}
let wasmExportObject;
const loadRoutine = async () => {
}
// https://www.npmjs.com/package/fast-deep-equal - 3/3/2021
const envHasBigInt64Array = typeof BigInt64Array !== 'undefined';
function vEq(a, b) {
if (a === b) return true;
if (a && b && typeof a == 'object' && typeof b == 'object') {
if (a.constructor !== b.constructor) return false;
// we want to convert all V types to JS for comparison.
if ('$toJS' in a)
a = a.$toJS();
if ('$toJS' in b)
b = b.$toJS();
var length, i, keys;
if (Array.isArray(a)) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0;)
if (!vEq(a[i], b[i])) return false;
return true;
}
if (typeof Map != 'undefined') {
if ((a instanceof Map) && (b instanceof Map)) {
if (a.size !== b.size) return false;
for (i of a.entries())
if (!b.has(i[0])) return false;
for (i of a.entries())
if (!vEq(i[1], b.get(i[0]))) return false;
return true;
}
if ((a instanceof Set) && (b instanceof Set)) {
if (a.size !== b.size) return false;
for (i of a.entries())
if (!b.has(i[0])) return false;
return true;
}
}
if (typeof ArrayBuffer != 'undefined') {
if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0;)
if (a[i] !== b[i]) return false;
return true;
}
}
if (typeof RegExp != 'undefined') {
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
}
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
keys = Object.keys(a);
length = keys.length;
if (length !== Object.keys(b).length) return false;
for (i = length; i-- !== 0;)
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
for (i = length; i-- !== 0;) {
var key = keys[i];
if (!vEq(a[key], b[key])) return false;
}
return true;
}
// true if both NaN, false otherwise
return a!==a && b!==b;
};
function $sortComparator(a, b)
{
a = a.$toJS();
b = b.$toJS();
if (a > b) return 1;
if (a < b) return -1;
return 0;
}
/** @namespace strings */
function strings__Builder(val) { return val; }
/**
* @function
* @param {int} initial_size
* @returns {strings__Builder}
*/
function strings__new_builder(initial_size) {
try {
return new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)}));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u8} data
* @returns {void}
*/
function strings__Builder_write_byte(b, data) {
b = new $ref(b)
try {
array_push(b.valueOf(),data,false);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function strings__Builder_clear(b) {
b = new $ref(b)
try {
/** @type {strings__Builder} */
b.val = new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)})).val;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u8} data
* @returns {void}
*/
function strings__Builder_write_u8(b, data) {
b = new $ref(b)
try {
array_push(b.valueOf(),data,false);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_u8} data
* @returns {int}
*/
function strings__Builder_write(b, data) {
b = new $ref(b)
try {
if ((new bool(data.len.valueOf() == new int(0).valueOf())).valueOf()) {
const _tmp1 = new _option({});
_tmp1.state = new u8(0);_tmp1.data = new int(0)
return _tmp1;}
array_push(b.valueOf(),data.arr.arr,true);
const _tmp2 = new _option({});
_tmp2.state = new u8(0);_tmp2.data = data.len
return _tmp2;} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} n
* @returns {u8}
*/
function strings__Builder_byte_at(b, n) {
b = new $ref(b)
try {
{
return b.valueOf().arr.get(new int(n.valueOf()));
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} s
* @returns {void}
*/
function strings__Builder_write_string(b, s) {
b = new $ref(b)
try {
if ((new bool(s.valueOf() == new string("").valueOf())).valueOf()) {
return;
}
for (const c of s.str.split('').map(c => new u8(c))) {
try {
array_push(b.valueOf(),c,false);
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} s
* @returns {void}
*/
function strings__Builder_writeln(b, s) {
b = new $ref(b)
try {
if ((new bool(s.valueOf() != new string("").valueOf())).valueOf()) {
strings__Builder_write_string(b.valueOf(),s);
}
array_push(b.valueOf(),new int(10),false);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function strings__Builder_str(b) {
b = new $ref(b)
try {
/** @type {string} */
const s = new string(new string(""));
for (const c of b.val.arr.arr)
s.str += String.fromCharCode(+c)
array_trim(b.valueOf(),new int(0));
return s;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} n
* @returns {string}
*/
function strings__Builder_cut_last(b, n) {
b = new $ref(b)
try {
/** @type {int} */
const cut_pos = new int(new int( b.val.len.valueOf() - n.valueOf()));
/** @type {strings__Builder} */
const x = array_slice(b.valueOf(),cut_pos, b.valueOf().len);
/** @type {string} */
const res = new string(array_bytestr(x,));
array_trim(b.valueOf(),cut_pos);
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} pos
* @returns {void}
*/
function strings__Builder_go_back_to(b, pos) {
b = new $ref(b)
try {
array_trim(b.valueOf(),pos);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} n
* @returns {void}
*/
function strings__Builder_go_back(b, n) {
b = new $ref(b)
try {
array_trim(b.valueOf(),new int( b.val.len.valueOf() - n.valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} pos
* @returns {string}
*/
function strings__Builder_cut_to(b, pos) {
b = new $ref(b)
try {
if ((new bool(pos.valueOf() > b.val.len.valueOf())).valueOf()) {
return new string("");
}
return strings__Builder_cut_last(b.valueOf(),new int( b.val.len.valueOf() - pos.valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_rune} runes
* @returns {void}
*/
function strings__Builder_write_runes(b, runes) {
b = new $ref(b)
try {
for (const r of runes) {
try {
/** @type {string} */
const res = new string(rune_str(r));
res.str = String.fromCharCode(r.val)
array_push(b.valueOf(),string_bytes(res,).arr.arr,true);
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} n
* @returns {string}
*/
function strings__Builder_after(b, n) {
b = new $ref(b)
try {
if ((new bool(n.valueOf() >= b.val.len.valueOf())).valueOf()) {
return new string("");
}
/** @type {strings__Builder} */
const x = array_slice(b.valueOf(),n, b.val.len);
return array_bytestr(x,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} n
* @returns {string}
*/
function strings__Builder_last_n(b, n) {
b = new $ref(b)
try {
if ((new bool(n.valueOf() >= b.val.len.valueOf())).valueOf()) {
return new string("");
}
/** @type {strings__Builder} */
const x = array_slice(b.valueOf(),new int( b.val.len.valueOf() - n.valueOf()), b.val.len);
return array_bytestr(x,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace strings */
/* [inline] */
/**
* @function
* @param {u16} a
* @param {u16} b
* @param {u16} c
* @returns {u16}
*/
function strings__min(a, b, c) {
try {
/** @type {u16} */
let m = new u16(a);
if ((new bool(b.valueOf() < m.valueOf())).valueOf()) {
/** @type {u16} */
m = new u16(b);
}
if ((new bool(c.valueOf() < m.valueOf())).valueOf()) {
/** @type {u16} */
m = new u16(c);
}
return m;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [direct_array_access] */
/**
* @function
* @param {string} a
* @param {string} b
* @returns {int}
*/
function strings__levenshtein_distance(a, b) {
try {
if ((new bool(a.len.valueOf() == new int(0).valueOf())).valueOf()) {
return b.len;
}
if ((new bool(b.len.valueOf() == new int(0).valueOf())).valueOf()) {
return a.len;
}
if ((new bool(a.valueOf() == b.valueOf())).valueOf()) {
return new int(0);
}
/** @type {Array_u16} */
let row = new array(new array_buffer({arr: (function(length) {
const _tmp3 = [];
for (let it = 0; it < length; it++) {
_tmp3.push(new u16(index));
};
return _tmp3;
})(new int( a.len.valueOf() + new int(1).valueOf())),len: new int(new int( a.len.valueOf() + new int(1).valueOf())), cap: new int(new int( a.len.valueOf() + new int(1).valueOf()))}));
for (let i = new int(new int(1)); +new bool(i.valueOf() < new int( b.len.valueOf() + new int(1).valueOf()).valueOf()); i.val ++) {
try {
let prev = new u16(new u16(i)); for (let j = new int(new int(1)); +new bool(j.valueOf() < new int( a.len.valueOf() + new int(1).valueOf()).valueOf()); j.val ++) {
try {
let current = new u16(row.arr.get(new int(new int( j.valueOf() - new int(1).valueOf()).valueOf()))); if ((new bool(new u8(b.str.charCodeAt(new int( i.valueOf() - new int(1).valueOf()))).valueOf() != new u8(a.str.charCodeAt(new int( j.valueOf() - new int(1).valueOf()))).valueOf())).valueOf()) {
current = new u16(strings__min(new u16( row.arr.get(new int(new int( j.valueOf() - new int(1).valueOf()).valueOf())).valueOf() + new int(1).valueOf()), new u16( prev.valueOf() + new int(1).valueOf()), new u16( row.arr.get(new int(j.valueOf())).valueOf() + new int(1).valueOf()))); }
row.arr.set(new int(new int( j.valueOf() - new int(1).valueOf()).valueOf()),new u16(prev)); prev = new u16(current); } catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {u16} */
row.arr.set(new int(a.len.valueOf()),new u16(prev));
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return row.arr.get(new int(a.len.valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} a
* @param {string} b
* @returns {f32}
*/
function strings__levenshtein_distance_percentage(a, b) {
try {
/** @type {int} */
const d = new int(strings__levenshtein_distance(a, b));
/** @type {int} */
const l = new int(((new bool(a.len.valueOf() >= b.len.valueOf())).valueOf() ? a.len : b.len));
return new f32( (new f32( new f32(1.00).valueOf() - new f32( new f32(d).valueOf() / new f32(l).valueOf()).valueOf())).valueOf() * new f32(100.00).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} s1
* @param {string} s2
* @returns {f32}
*/
function strings__dice_coefficient(s1, s2) {
try {
if ((new bool( new bool(s1.len.valueOf() == new int(0).valueOf()).valueOf() || new bool(s2.len.valueOf() == new int(0).valueOf()).valueOf())).valueOf()) {
return new f32(0.0);
}
if ((new bool(s1.valueOf() == s2.valueOf())).valueOf()) {
return new f32(1.0);
}
if ((new bool( new bool(s1.len.valueOf() < new int(2).valueOf()).valueOf() || new bool(s2.len.valueOf() < new int(2).valueOf()).valueOf())).valueOf()) {
return new f32(0.0);
}
/** @type {string} */
const a = new string(((new bool(s1.len.valueOf() > s2.len.valueOf())).valueOf() ? s1 : s2));
/** @type {string} */
const b = new string(((new bool(a.valueOf() == s1.valueOf())).valueOf() ? s2 : s1));
/** @type {Map_string_int} */
let first_bigrams = new map(
{});
for (let i = new int(0); i < new int( a.len.valueOf() - new int(1).valueOf()); i = new int(i + 1)) {
try {
/** @type {string} */
const bigram = new string(string_slice(a,i, new int_literal( i.valueOf() + new int(2).valueOf())));
/** @type {int} */
const q = new int(((first_bigrams.has(bigram.$toJS())).valueOf() ? new int( first_bigrams.get(bigram.$toJS()).valueOf() + new int(1).valueOf()) : new int(1)));
/** @type {int} */
first_bigrams.length++;
first_bigrams.map[bigram.$toJS()] = new int(q);
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {int} */
let intersection_size = new int(new int(0));
for (let i = new int(0); i < new int( b.len.valueOf() - new int(1).valueOf()); i = new int(i + 1)) {
try {
/** @type {string} */
const bigram = new string(string_slice(b,i, new int_literal( i.valueOf() + new int(2).valueOf())));
/** @type {int} */
const count = new int(((first_bigrams.has(bigram.$toJS())).valueOf() ? first_bigrams.get(bigram.$toJS()) : new int(0)));
if ((new bool(count.valueOf() > new int(0).valueOf())).valueOf()) {
/** @type {int} */
first_bigrams.length++;
first_bigrams.map[bigram.$toJS()] = new int(new int( count.valueOf() - new int(1).valueOf()));
intersection_size.val ++;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return new f32( (new f32( new f32(2.0).valueOf() * new f32(intersection_size).valueOf())).valueOf() / (new f32( new f32( new f32(a.len).valueOf() + new f32(b.len).valueOf()).valueOf() - new int(2).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace strings */
/**
* @function
* @param {u8} c
* @param {int} n
* @returns {string}
*/
function strings__repeat(c, n) {
try {
if ((new bool(n.valueOf() <= new int(0).valueOf())).valueOf()) {
return new string("");
}
/** @type {Array_u8} */
const arr = array_repeat(new array(new array_buffer({arr: [new u8(c)], len: new int(1), cap: new int(1)})),n);
return array_bytestr(arr,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} s
* @param {int} n
* @returns {string}
*/
function strings__repeat_string(s, n) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str = s.str.repeat(n.valueOf())
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace strings */
/**
* @function
* @param {string} input
* @param {u8} start
* @param {u8} end
* @returns {string}
*/
function strings__find_between_pair_u8(input, start, end) {
try {
/** @type {int} */
let marks = new int(new int(0));
/** @type {int} */
let start_index = new int(new int(-1));
for (const [i, b] of Array.from(input.str.split('').entries(), ([i, b]) => [i, new u8(b)])) {
try {
if ((new bool(b.valueOf() == start.valueOf())).valueOf()) {
if ((new bool(start_index.valueOf() == new int(-1).valueOf())).valueOf()) {
/** @type {int} */
start_index = new int(new int( i.valueOf() + new int(1).valueOf()));
}
marks.val ++;
continue;
}
if ((new bool(start_index.valueOf() > new int(0).valueOf())).valueOf()) {
if ((new bool(b.valueOf() == end.valueOf())).valueOf()) {
marks.val --;
if ((new bool(marks.valueOf() == new int(0).valueOf())).valueOf()) {
return string_slice(input,start_index, i);
}
}
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return new string("");
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} input
* @param {rune} start
* @param {rune} end
* @returns {string}
*/
function strings__find_between_pair_rune(input, start, end) {
try {
/** @type {int} */
let marks = new int(new int(0));
/** @type {int} */
let start_index = new int(new int(-1));
/** @type {Array_rune} */
const runes = string_runes(input,);
for (const [i, r] of runes.entries()) {
try {
if ((new bool(r.valueOf() == start.valueOf())).valueOf()) {
if ((new bool(start_index.valueOf() == new int(-1).valueOf())).valueOf()) {
/** @type {int} */
start_index = new int(new int( i.valueOf() + new int(1).valueOf()));
}
marks.val ++;
continue;
}
if ((new bool(start_index.valueOf() > new int(0).valueOf())).valueOf()) {
if ((new bool(r.valueOf() == end.valueOf())).valueOf()) {
marks.val --;
if ((new bool(marks.valueOf() == new int(0).valueOf())).valueOf()) {
return Array_rune_string(array_slice(runes,start_index, i),);
}
}
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return new string("");
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} input
* @param {string} start
* @param {string} end
* @returns {string}
*/
function strings__find_between_pair_string(input, start, end) {
try {
/** @type {int} */
let start_index = new int(new int(-1));
/** @type {int} */
let marks = new int(new int(0));
/** @type {Array_rune} */
const start_runes = string_runes(start,);
/** @type {Array_rune} */
const end_runes = string_runes(end,);
/** @type {Array_rune} */
const runes = string_runes(input,);
/** @type {int} */
let i = new int(new int(0));
for (; +new bool(i.valueOf() < runes.len.valueOf()); i.val ++) {
try {
let start_slice = array_slice(runes,i, new int( i.valueOf() + start_runes.len.valueOf())); if ((new bool(Array_rune_arr_eq(start_slice, start_runes))).valueOf()) {
i = new int(new int( new int( i.valueOf() + start_runes.len.valueOf()).valueOf() - new int(1).valueOf())); if ((new bool(start_index.valueOf() < new int(0).valueOf())).valueOf()) {
start_index = new int(new int( i.valueOf() + new int(1).valueOf())); }
marks.val ++;
continue;
}
if ((new bool(start_index.valueOf() > new int(0).valueOf())).valueOf()) {
let end_slice = array_slice(runes,i, new int( i.valueOf() + end_runes.len.valueOf())); if ((new bool(Array_rune_arr_eq(end_slice, end_runes))).valueOf()) {
marks.val --;
if ((new bool(marks.valueOf() == new int(0).valueOf())).valueOf()) {
return Array_rune_string(array_slice(runes,start_index, i),);
}
i = new int(new int( new int( i.valueOf() + end_runes.len.valueOf()).valueOf() - new int(1).valueOf())); continue;
}
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return new string("");
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} s
* @returns {Array_string}
*/
function strings__split_capital(s) {
try {
/** @type {Array_string} */
let res = new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)}));
/** @type {int} */
let word_start = new int(new int(0));
for (const [idx, c] of Array.from(s.str.split('').entries(), ([idx, c]) => [idx, new u8(c)])) {
try {
if ((u8_is_capital(c,)).valueOf()) {
if ((new bool(word_start.valueOf() != idx.valueOf())).valueOf()) {
array_push(res,string_slice(s,word_start, idx),false);
}
/** @type {int} */
word_start = new int(idx);
continue;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
if ((new bool(word_start.valueOf() != s.len.valueOf())).valueOf()) {
array_push(res,string_slice(s,word_start, s.len),false);
}
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace math.bits */
/** @constant {u32} */
let math__bits__de_bruijn32 = undefined;
/** @constant {Array_fixed_u8_32} */
let math__bits__de_bruijn32tab = undefined;
/** @constant {u64} */
let math__bits__de_bruijn64 = undefined;
/** @constant {Array_fixed_u8_64} */
let math__bits__de_bruijn64tab = undefined;
/** @constant {u64} */
let math__bits__m0 = undefined;
/** @constant {u64} */
let math__bits__m1 = undefined;
/** @constant {u64} */
let math__bits__m2 = undefined;
/** @constant {u64} */
let math__bits__m3 = undefined;
/** @constant {u64} */
let math__bits__m4 = undefined;
/**
* @function
* @param {u8} x
* @returns {int}
*/
function math__bits__leading_zeros_8(x) {
try {
return new int( new int(8).valueOf() - math__bits__len_8(x).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u16} x
* @returns {int}
*/
function math__bits__leading_zeros_16(x) {
try {
return new int( new int(16).valueOf() - math__bits__len_16(x).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} x
* @returns {int}
*/
function math__bits__leading_zeros_32(x) {
try {
return new int( new int(32).valueOf() - math__bits__len_32(x).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} x
* @returns {int}
*/
function math__bits__leading_zeros_64(x) {
try {
return new int( new int(64).valueOf() - math__bits__len_64(x).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u8} x
* @returns {int}
*/
function math__bits__trailing_zeros_8(x) {
try {
return new int(math__bits__ntz_8_tab.arr.get(new int(x.valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u16} x
* @returns {int}
*/
function math__bits__trailing_zeros_16(x) {
try {
if ((new bool(x.valueOf() == new int(0).valueOf())).valueOf()) {
return new int(16);
}
return new int(math__bits__de_bruijn32tab.arr.get(new int(new u32( new u32( new u32(new u16( x.valueOf() & -x.val .valueOf())).valueOf() * math__bits__de_bruijn32.valueOf()).valueOf() >> (new int(27)).valueOf()).valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} x
* @returns {int}
*/
function math__bits__trailing_zeros_32(x) {
try {
if ((new bool(x.valueOf() == new int(0).valueOf())).valueOf()) {
return new int(32);
}
return new int(math__bits__de_bruijn32tab.arr.get(new int(new u32( new u32( (new u32( x.valueOf() & -x.val .valueOf())).valueOf() * math__bits__de_bruijn32.valueOf()).valueOf() >> (new int(27)).valueOf()).valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} x
* @returns {int}
*/
function math__bits__trailing_zeros_64(x) {
try {
if ((new bool(x.valueOf() == new int(0).valueOf())).valueOf()) {
return new int(64);
}
return new int(math__bits__de_bruijn64tab.arr.get(new int(new u64( BigInt(new u64( BigInt((new u64( BigInt(x.valueOf()) & BigInt(-x.val .valueOf()))).valueOf()) * BigInt(math__bits__de_bruijn64.valueOf())).valueOf()) >> BigInt((new int(58)).valueOf())).valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u8} x
* @returns {int}
*/
function math__bits__ones_count_8(x) {
try {
return new int(math__bits__pop_8_tab.arr.get(new int(x.valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u16} x
* @returns {int}
*/
function math__bits__ones_count_16(x) {
try {
return new int(new u8( math__bits__pop_8_tab.arr.get(new int(new u16( x.valueOf() >> new int(8).valueOf()).valueOf())).valueOf() + math__bits__pop_8_tab.arr.get(new int(new u16( x.valueOf() & new int(0xff).valueOf()).valueOf())).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} x
* @returns {int}
*/
function math__bits__ones_count_32(x) {
try {
return new int(new u8( new u8( new u8( math__bits__pop_8_tab.arr.get(new int(new u32( x.valueOf() >> new int(24).valueOf()).valueOf())).valueOf() + math__bits__pop_8_tab.arr.get(new int(new u32( new u32( x.valueOf() >> new int(16).valueOf()).valueOf() & new int(0xff).valueOf()).valueOf())).valueOf()).valueOf() + math__bits__pop_8_tab.arr.get(new int(new u32( new u32( x.valueOf() >> new int(8).valueOf()).valueOf() & new int(0xff).valueOf()).valueOf())).valueOf()).valueOf() + math__bits__pop_8_tab.arr.get(new int(new u32( x.valueOf() & new int(0xff).valueOf()).valueOf())).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} x
* @returns {int}
*/
function math__bits__ones_count_64(x) {
try {
/** @type {u64} */
let y = new u64(new u64( BigInt((new u64( BigInt(new u64( BigInt(x.valueOf()) >> BigInt(new u64(BigInt(1n)).valueOf())).valueOf()) & BigInt((new u64( BigInt(math__bits__m0.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) + BigInt((new u64( BigInt(x.valueOf()) & BigInt((new u64( BigInt(math__bits__m0.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf())));
/** @type {u64} */
y = new u64(new u64( BigInt((new u64( BigInt(new u64( BigInt(y.valueOf()) >> BigInt(new u64(BigInt(2n)).valueOf())).valueOf()) & BigInt((new u64( BigInt(math__bits__m1.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) + BigInt((new u64( BigInt(y.valueOf()) & BigInt((new u64( BigInt(math__bits__m1.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf())));
/** @type {u64} */
y = new u64(new u64( BigInt((new u64( BigInt((new u64( BigInt(y.valueOf()) >> BigInt(new int(4).valueOf()))).valueOf()) + BigInt(y.valueOf()))).valueOf()) & BigInt((new u64( BigInt(math__bits__m2.valueOf()) & BigInt(max_u64.valueOf()))).valueOf())));
/** @type {u64} */
y.val = y + new u64(new u64( BigInt(y.valueOf()) >> BigInt(new int(8).valueOf())));
/** @type {u64} */
y.val = y + new u64(new u64( BigInt(y.valueOf()) >> BigInt(new int(16).valueOf())));
/** @type {u64} */
y.val = y + new u64(new u64( BigInt(y.valueOf()) >> BigInt(new int(32).valueOf())));
return new int( new int(y).valueOf() & (new int_literal( (new int(128)).valueOf() - new int(1).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @constant {u8} */
let math__bits__n8 = undefined;
/** @constant {u16} */
let math__bits__n16 = undefined;
/** @constant {u32} */
let math__bits__n32 = undefined;
/** @constant {u64} */
let math__bits__n64 = undefined;
/* [inline] */
/**
* @function
* @param {u8} x
* @param {int} k
* @returns {u8}
*/
function math__bits__rotate_left_8(x, k) {
try {
/** @type {u8} */
const s = new u8(new u8( new u8(k).valueOf() & (new u8( math__bits__n8.valueOf() - new int(1).valueOf())).valueOf()));
return new u8( (new u8( x.valueOf() << s.valueOf())).valueOf() | (new u8( x.valueOf() >> (new u8( math__bits__n8.valueOf() - s.valueOf())).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u16} x
* @param {int} k
* @returns {u16}
*/
function math__bits__rotate_left_16(x, k) {
try {
/** @type {u16} */
const s = new u16(new u16( new u16(k).valueOf() & (new u16( math__bits__n16.valueOf() - new int(1).valueOf())).valueOf()));
return new u16( (new u16( x.valueOf() << s.valueOf())).valueOf() | (new u16( x.valueOf() >> (new u16( math__bits__n16.valueOf() - s.valueOf())).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u32} x
* @param {int} k
* @returns {u32}
*/
function math__bits__rotate_left_32(x, k) {
try {
/** @type {u32} */
const s = new u32(new u32( new u32(k).valueOf() & (new u32( math__bits__n32.valueOf() - new int(1).valueOf())).valueOf()));
return new u32( (new u32( x.valueOf() << s.valueOf())).valueOf() | (new u32( x.valueOf() >> (new u32( math__bits__n32.valueOf() - s.valueOf())).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u64} x
* @param {int} k
* @returns {u64}
*/
function math__bits__rotate_left_64(x, k) {
try {
/** @type {u64} */
const s = new u64(new u64( BigInt(new u64(k).valueOf()) & BigInt((new u64( BigInt(math__bits__n64.valueOf()) - BigInt(new u64(BigInt(1n)).valueOf()))).valueOf())));
return new u64( BigInt((new u64( BigInt(x.valueOf()) << BigInt(s.valueOf()))).valueOf()) | BigInt((new u64( BigInt(x.valueOf()) >> BigInt((new u64( BigInt(math__bits__n64.valueOf()) - BigInt(s.valueOf()))).valueOf()))).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u8} x
* @returns {u8}
*/
function math__bits__reverse_8(x) {
try {
return math__bits__rev_8_tab.arr.get(new int(x.valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u16} x
* @returns {u16}
*/
function math__bits__reverse_16(x) {
try {
return new u16( new u16(math__bits__rev_8_tab.arr.get(new int(new u16( x.valueOf() >> new int(8).valueOf()).valueOf()))).valueOf() | (new u16( new u16(math__bits__rev_8_tab.arr.get(new int(new u16( x.valueOf() & new int(0xff).valueOf()).valueOf()))).valueOf() << new int(8).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u32} x
* @returns {u32}
*/
function math__bits__reverse_32(x) {
try {
/** @type {u64} */
let y = new u64((new u64( BigInt((new u64( BigInt(new u32( x.valueOf() >> new int(1).valueOf()).valueOf()) & BigInt((new u64( BigInt(math__bits__m0.valueOf()) & BigInt(max_u32.valueOf()))).valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(x.valueOf()) & BigInt((new u64( BigInt(math__bits__m0.valueOf()) & BigInt(max_u32.valueOf()))).valueOf()))).valueOf()) << BigInt(new int(1).valueOf()))).valueOf()))));
/** @type {u64} */
y = new u64((new u64( BigInt((new u64( BigInt(new u64( BigInt(y.valueOf()) >> BigInt(new int(2).valueOf())).valueOf()) & BigInt((new u64( BigInt(math__bits__m1.valueOf()) & BigInt(max_u32.valueOf()))).valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(y.valueOf()) & BigInt((new u64( BigInt(math__bits__m1.valueOf()) & BigInt(max_u32.valueOf()))).valueOf()))).valueOf()) << BigInt(new int(2).valueOf()))).valueOf()))));
/** @type {u64} */
y = new u64((new u64( BigInt((new u64( BigInt(new u64( BigInt(y.valueOf()) >> BigInt(new int(4).valueOf())).valueOf()) & BigInt((new u64( BigInt(math__bits__m2.valueOf()) & BigInt(max_u32.valueOf()))).valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(y.valueOf()) & BigInt((new u64( BigInt(math__bits__m2.valueOf()) & BigInt(max_u32.valueOf()))).valueOf()))).valueOf()) << BigInt(new int(4).valueOf()))).valueOf()))));
return math__bits__reverse_bytes_32(new u32(y));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u64} x
* @returns {u64}
*/
function math__bits__reverse_64(x) {
try {
/** @type {u64} */
let y = new u64((new u64( BigInt((new u64( BigInt(new u64( BigInt(x.valueOf()) >> BigInt(new u64(BigInt(1n)).valueOf())).valueOf()) & BigInt((new u64( BigInt(math__bits__m0.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(x.valueOf()) & BigInt((new u64( BigInt(math__bits__m0.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) << BigInt(new int(1).valueOf()))).valueOf()))));
/** @type {u64} */
y = new u64((new u64( BigInt((new u64( BigInt(new u64( BigInt(y.valueOf()) >> BigInt(new u64(BigInt(2n)).valueOf())).valueOf()) & BigInt((new u64( BigInt(math__bits__m1.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(y.valueOf()) & BigInt((new u64( BigInt(math__bits__m1.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) << BigInt(new int(2).valueOf()))).valueOf()))));
/** @type {u64} */
y = new u64((new u64( BigInt((new u64( BigInt(new u64( BigInt(y.valueOf()) >> BigInt(new u64(BigInt(4n)).valueOf())).valueOf()) & BigInt((new u64( BigInt(math__bits__m2.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(y.valueOf()) & BigInt((new u64( BigInt(math__bits__m2.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) << BigInt(new int(4).valueOf()))).valueOf()))));
return math__bits__reverse_bytes_64(y);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u16} x
* @returns {u16}
*/
function math__bits__reverse_bytes_16(x) {
try {
return new u16( (new u16( x.valueOf() >> new int(8).valueOf())).valueOf() | (new u16( x.valueOf() << new int(8).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u32} x
* @returns {u32}
*/
function math__bits__reverse_bytes_32(x) {
try {
/** @type {u64} */
const y = new u64((new u64( BigInt((new u64( BigInt(new u32( x.valueOf() >> new int(8).valueOf()).valueOf()) & BigInt((new u64( BigInt(math__bits__m3.valueOf()) & BigInt(max_u32.valueOf()))).valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(x.valueOf()) & BigInt((new u64( BigInt(math__bits__m3.valueOf()) & BigInt(max_u32.valueOf()))).valueOf()))).valueOf()) << BigInt(new int(8).valueOf()))).valueOf()))));
return new u32(new u64( BigInt((new u64( BigInt(y.valueOf()) >> BigInt(new int(16).valueOf()))).valueOf()) | BigInt((new u64( BigInt(y.valueOf()) << BigInt(new int(16).valueOf()))).valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u64} x
* @returns {u64}
*/
function math__bits__reverse_bytes_64(x) {
try {
/** @type {u64} */
let y = new u64((new u64( BigInt((new u64( BigInt(new u64( BigInt(x.valueOf()) >> BigInt(new u64(BigInt(8n)).valueOf())).valueOf()) & BigInt((new u64( BigInt(math__bits__m3.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(x.valueOf()) & BigInt((new u64( BigInt(math__bits__m3.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) << BigInt(new u64(BigInt(8n)).valueOf()))).valueOf()))));
/** @type {u64} */
y = new u64((new u64( BigInt((new u64( BigInt(new u64( BigInt(y.valueOf()) >> BigInt(new u64(BigInt(16n)).valueOf())).valueOf()) & BigInt((new u64( BigInt(math__bits__m4.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(y.valueOf()) & BigInt((new u64( BigInt(math__bits__m4.valueOf()) & BigInt(max_u64.valueOf()))).valueOf()))).valueOf()) << BigInt(new u64(BigInt(16n)).valueOf()))).valueOf()))));
return new u64( BigInt((new u64( BigInt(y.valueOf()) >> BigInt(new int(32).valueOf()))).valueOf()) | BigInt((new u64( BigInt(y.valueOf()) << BigInt(new int(32).valueOf()))).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u8} x
* @returns {int}
*/
function math__bits__len_8(x) {
try {
return new int(math__bits__len_8_tab.arr.get(new int(x.valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u16} x
* @returns {int}
*/
function math__bits__len_16(x) {
try {
/** @type {u16} */
let y = new u16(x);
/** @type {int} */
let n = new int(new int(0));
if ((new bool(y.valueOf() >= new int(256).valueOf())).valueOf()) {
/** @type {u16} */
y.val = Math.floor(y >> new u16(new int(8)));
/** @type {int} */
n = new int(new int(8));
}
return new int( n.valueOf() + new int(math__bits__len_8_tab.arr.get(new int(y.valueOf()))).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} x
* @returns {int}
*/
function math__bits__len_32(x) {
try {
/** @type {u32} */
let y = new u32(x);
/** @type {int} */
let n = new int(new int(0));
if ((new bool(y.valueOf() >= (new int(65536)).valueOf())).valueOf()) {
/** @type {u32} */
y.val = Math.floor(y >> new u32(new int(16)));
/** @type {int} */
n = new int(new int(16));
}
if ((new bool(y.valueOf() >= (new int(256)).valueOf())).valueOf()) {
/** @type {u32} */
y.val = Math.floor(y >> new u32(new int(8)));
/** @type {int} */
n.val = Math.floor(n + new int(new int(8)));
}
return new int( n.valueOf() + new int(math__bits__len_8_tab.arr.get(new int(y.valueOf()))).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} x
* @returns {int}
*/
function math__bits__len_64(x) {
try {
/** @type {u64} */
let y = new u64(x);
/** @type {int} */
let n = new int(new int(0));
if ((new bool(y.valueOf() >= new u64( BigInt(new u64(BigInt(1n)).valueOf()) << BigInt(new u64(BigInt(32n)).valueOf())).valueOf())).valueOf()) {
/** @type {u64} */
y.val = y >> new u64(new int(32));
/** @type {int} */
n = new int(new int(32));
}
if ((new bool(y.valueOf() >= new u64( BigInt(new u64(BigInt(1n)).valueOf()) << BigInt(new u64(BigInt(16n)).valueOf())).valueOf())).valueOf()) {
/** @type {u64} */
y.val = y >> new u64(new int(16));
/** @type {int} */
n.val = Math.floor(n + new int(new int(16)));
}
if ((new bool(y.valueOf() >= new u64( BigInt(new u64(BigInt(1n)).valueOf()) << BigInt(new u64(BigInt(8n)).valueOf())).valueOf())).valueOf()) {
/** @type {u64} */
y.val = y >> new u64(new int(8));
/** @type {int} */
n.val = Math.floor(n + new int(new int(8)));
}
return new int( n.valueOf() + new int(math__bits__len_8_tab.arr.get(new int(y.valueOf()))).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} x
* @param {u32} y
* @param {u32} carry
* @returns {multi_return_u32_u32}
*/
function math__bits__add_32(x, y, carry) {
try {
/** @type {u64} */
const sum64 = new u64(new u64( BigInt(new u64( BigInt(new u64(x).valueOf()) + BigInt(new u64(y).valueOf())).valueOf()) + BigInt(new u64(carry).valueOf())));
/** @type {u32} */
const sum = new u32(new u32(sum64));
/** @type {u32} */
const carry_out = new u32(new u32(new u64( BigInt(sum64.valueOf()) >> BigInt(new int(32).valueOf()))));
return [sum, carry_out];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} x
* @param {u64} y
* @param {u64} carry
* @returns {multi_return_u64_u64}
*/
function math__bits__add_64(x, y, carry) {
try {
/** @type {u64} */
const sum = new u64(new u64( BigInt(new u64( BigInt(x.valueOf()) + BigInt(y.valueOf())).valueOf()) + BigInt(carry.valueOf())));
/** @type {u64} */
const carry_out = new u64(new u64( BigInt((new u64( BigInt((new u64( BigInt(x.valueOf()) & BigInt(y.valueOf()))).valueOf()) | BigInt((new u64( BigInt((new u64( BigInt(x.valueOf()) | BigInt(y.valueOf()))).valueOf()) & BigInt(~sum.val .valueOf()))).valueOf()))).valueOf()) >> BigInt(new int(63).valueOf())));
return [sum, carry_out];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} x
* @param {u32} y
* @param {u32} borrow
* @returns {multi_return_u32_u32}
*/
function math__bits__sub_32(x, y, borrow) {
try {
/** @type {u32} */
const diff = new u32(new u32( new u32( x.valueOf() - y.valueOf()).valueOf() - borrow.valueOf()));
/** @type {u32} */
const borrow_out = new u32(new u32( (new u32( (new u32( ~x.val .valueOf() & y.valueOf())).valueOf() | (new u32( ~(new u32( x.valueOf() ^ y.valueOf())).val .valueOf() & diff.valueOf())).valueOf())).valueOf() >> new int(31).valueOf()));
return [diff, borrow_out];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} x
* @param {u64} y
* @param {u64} borrow
* @returns {multi_return_u64_u64}
*/
function math__bits__sub_64(x, y, borrow) {
try {
/** @type {u64} */
const diff = new u64(new u64( BigInt(new u64( BigInt(x.valueOf()) - BigInt(y.valueOf())).valueOf()) - BigInt(borrow.valueOf())));
/** @type {u64} */
const borrow_out = new u64(new u64( BigInt((new u64( BigInt((new u64( BigInt(~x.val .valueOf()) & BigInt(y.valueOf()))).valueOf()) | BigInt((new u64( BigInt(~(new u64( BigInt(x.valueOf()) ^ BigInt(y.valueOf()))).val .valueOf()) & BigInt(diff.valueOf()))).valueOf()))).valueOf()) >> BigInt(new int(63).valueOf())));
return [diff, borrow_out];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @constant {u64} */
let math__bits__two32 = undefined;
/** @constant {u64} */
let math__bits__mask32 = undefined;
/** @constant {string} */
const math__bits__overflow_error = new string("Overflow Error");
/** @constant {string} */
const math__bits__divide_error = new string("Divide Error");
/**
* @function
* @param {u32} x
* @param {u32} y
* @returns {multi_return_u32_u32}
*/
function math__bits__mul_32(x, y) {
try {
/** @type {u64} */
const tmp = new u64(new u64( BigInt(new u64(x).valueOf()) * BigInt(new u64(y).valueOf())));
/** @type {u32} */
const hi = new u32(new u32(new u64( BigInt(tmp.valueOf()) >> BigInt(new int(32).valueOf()))));
/** @type {u32} */
const lo = new u32(new u32(tmp));
return [hi, lo];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} x
* @param {u64} y
* @returns {multi_return_u64_u64}
*/
function math__bits__mul_64(x, y) {
try {
/** @type {u64} */
const x0 = new u64(new u64( BigInt(x.valueOf()) & BigInt(math__bits__mask32.valueOf())));
/** @type {u64} */
const x1 = new u64(new u64( BigInt(x.valueOf()) >> BigInt(new int(32).valueOf())));
/** @type {u64} */
const y0 = new u64(new u64( BigInt(y.valueOf()) & BigInt(math__bits__mask32.valueOf())));
/** @type {u64} */
const y1 = new u64(new u64( BigInt(y.valueOf()) >> BigInt(new int(32).valueOf())));
/** @type {u64} */
const w0 = new u64(new u64( BigInt(x0.valueOf()) * BigInt(y0.valueOf())));
/** @type {u64} */
const t = new u64(new u64( BigInt(new u64( BigInt(x1.valueOf()) * BigInt(y0.valueOf())).valueOf()) + BigInt((new u64( BigInt(w0.valueOf()) >> BigInt(new int(32).valueOf()))).valueOf())));
/** @type {u64} */
let w1 = new u64(new u64( BigInt(t.valueOf()) & BigInt(math__bits__mask32.valueOf())));
/** @type {u64} */
const w2 = new u64(new u64( BigInt(t.valueOf()) >> BigInt(new int(32).valueOf())));
/** @type {u64} */
w1.val = w1 + new u64(new u64( BigInt(x0.valueOf()) * BigInt(y1.valueOf())));
/** @type {u64} */
const hi = new u64(new u64( BigInt(new u64( BigInt(new u64( BigInt(x1.valueOf()) * BigInt(y1.valueOf())).valueOf()) + BigInt(w2.valueOf())).valueOf()) + BigInt((new u64( BigInt(w1.valueOf()) >> BigInt(new int(32).valueOf()))).valueOf())));
/** @type {u64} */
const lo = new u64(new u64( BigInt(x.valueOf()) * BigInt(y.valueOf())));
return [hi, lo];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} hi
* @param {u32} lo
* @param {u32} y
* @returns {multi_return_u32_u32}
*/
function math__bits__div_32(hi, lo, y) {
try {
if ((new bool( new bool(y.valueOf() != new int(0).valueOf()).valueOf() && new bool(y.valueOf() <= hi.valueOf()).valueOf())).valueOf()) {
builtin__panic (math__bits__overflow_error);
}
/** @type {u64} */
const z = new u64(new u64( BigInt((new u64( BigInt(new u64(hi).valueOf()) << BigInt(new int(32).valueOf()))).valueOf()) | BigInt(new u64(lo).valueOf())));
/** @type {u32} */
const quo = new u32(new u32(new u64( BigInt(z.valueOf()) / BigInt(new u64(y).valueOf()))));
/** @type {u32} */
const rem = new u32(new u32(new u64( BigInt(z.valueOf()) % BigInt(new u64(y).valueOf()))));
return [quo, rem];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} hi
* @param {u64} lo
* @param {u64} y1
* @returns {multi_return_u64_u64}
*/
function math__bits__div_64(hi, lo, y1) {
try {
/** @type {u64} */
let y = new u64(y1);
if ((new bool(y.valueOf() == new int(0).valueOf())).valueOf()) {
builtin__panic (math__bits__overflow_error);
}
if ((new bool(y.valueOf() <= hi.valueOf())).valueOf()) {
builtin__panic (math__bits__overflow_error);
}
/** @type {u32} */
const s = new u32(new u32(math__bits__leading_zeros_64(y)));
/** @type {u64} */
y.val = y << new u64(s);
/** @type {u64} */
const yn1 = new u64(new u64( BigInt(y.valueOf()) >> BigInt(new int(32).valueOf())));
/** @type {u64} */
const yn0 = new u64(new u64( BigInt(y.valueOf()) & BigInt(math__bits__mask32.valueOf())));
/** @type {u64} */
const ss1 = new u64((new u64( BigInt(hi.valueOf()) << BigInt(s.valueOf()))));
/** @type {u32} */
const xxx = new u32(new u32( new int(64).valueOf() - s.valueOf()));
/** @type {u64} */
let ss2 = new u64(new u64( BigInt(lo.valueOf()) >> BigInt(xxx.valueOf())));
if ((new bool(xxx.valueOf() == new int(64).valueOf())).valueOf()) {
/** @type {u64} */
ss2 = new u64(new int(0));
}
/** @type {u64} */
const un32 = new u64(new u64( BigInt(ss1.valueOf()) | BigInt(ss2.valueOf())));
/** @type {u64} */
const un10 = new u64(new u64( BigInt(lo.valueOf()) << BigInt(s.valueOf())));
/** @type {u64} */
const un1 = new u64(new u64( BigInt(un10.valueOf()) >> BigInt(new int(32).valueOf())));
/** @type {u64} */
const un0 = new u64(new u64( BigInt(un10.valueOf()) & BigInt(math__bits__mask32.valueOf())));
/** @type {u64} */
let q1 = new u64(new u64( BigInt(un32.valueOf()) / BigInt(yn1.valueOf())));
/** @type {u64} */
let rhat = new u64(new u64( BigInt(un32.valueOf()) - BigInt((new u64( BigInt(q1.valueOf()) * BigInt(yn1.valueOf()))).valueOf())));
while (+new bool( new bool(q1.valueOf() >= math__bits__two32.valueOf()).valueOf() || new bool((new u64( BigInt(q1.valueOf()) * BigInt(yn0.valueOf()))).valueOf() > (new u64( BigInt((new u64( BigInt(math__bits__two32.valueOf()) * BigInt(rhat.valueOf()))).valueOf()) + BigInt(un1.valueOf()))).valueOf()).valueOf())) {
try {
q1.val --;
/** @type {u64} */
rhat.val = rhat + new u64(yn1);
if ((new bool(rhat.valueOf() >= math__bits__two32.valueOf())).valueOf()) {
break;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {u64} */
const un21 = new u64(new u64( BigInt((new u64( BigInt(un32.valueOf()) * BigInt(math__bits__two32.valueOf()))).valueOf()) + BigInt((new u64( BigInt(un1.valueOf()) - BigInt((new u64( BigInt(q1.valueOf()) * BigInt(y.valueOf()))).valueOf()))).valueOf())));
/** @type {u64} */
let q0 = new u64(new u64( BigInt(un21.valueOf()) / BigInt(yn1.valueOf())));
/** @type {u64} */
rhat = new u64(new u64( BigInt(un21.valueOf()) - BigInt(new u64( BigInt(q0.valueOf()) * BigInt(yn1.valueOf())).valueOf())));
while (+new bool( new bool(q0.valueOf() >= math__bits__two32.valueOf()).valueOf() || new bool((new u64( BigInt(q0.valueOf()) * BigInt(yn0.valueOf()))).valueOf() > (new u64( BigInt((new u64( BigInt(math__bits__two32.valueOf()) * BigInt(rhat.valueOf()))).valueOf()) + BigInt(un0.valueOf()))).valueOf()).valueOf())) {
try {
q0.val --;
/** @type {u64} */
rhat.val = rhat + new u64(yn1);
if ((new bool(rhat.valueOf() >= math__bits__two32.valueOf())).valueOf()) {
break;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {u64} */
const qq = new u64((new u64( BigInt((new u64( BigInt(q1.valueOf()) * BigInt(math__bits__two32.valueOf()))).valueOf()) + BigInt(q0.valueOf()))));
/** @type {u64} */
const rr = new u64(new u64( BigInt((new u64( BigInt(new u64( BigInt((new u64( BigInt(un21.valueOf()) * BigInt(math__bits__two32.valueOf()))).valueOf()) + BigInt(un0.valueOf())).valueOf()) - BigInt((new u64( BigInt(q0.valueOf()) * BigInt(y.valueOf()))).valueOf()))).valueOf()) >> BigInt(s.valueOf())));
return [qq, rr];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} hi
* @param {u32} lo
* @param {u32} y
* @returns {u32}
*/
function math__bits__rem_32(hi, lo, y) {
try {
return new u32(new u64( BigInt((new u64( BigInt((new u64( BigInt(new u64(hi).valueOf()) << BigInt(new int(32).valueOf()))).valueOf()) | BigInt(new u64(lo).valueOf()))).valueOf()) % BigInt(new u64(y).valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} hi
* @param {u64} lo
* @param {u64} y
* @returns {u64}
*/
function math__bits__rem_64(hi, lo, y) {
try {
let [, rem] = math__bits__div_64(new u64( BigInt(hi.valueOf()) % BigInt(y.valueOf())), lo, y);
return rem;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {f64} x
* @returns {multi_return_f64_int}
*/
function math__bits__normalize(x) {
try {
/** @type {f64} */
const smallest_normal = new f64(new f32(2.2250738585072014e-308));
if ((new bool((((new bool(x.valueOf() > new f32(0.0).valueOf())).valueOf() ? x : -x.val )).valueOf() < smallest_normal.valueOf())).valueOf()) {
return [new f64( BigInt(x.valueOf()) * BigInt((new u64( BigInt(new u64(BigInt(1n)).valueOf()) << BigInt(new u64(BigInt(52n)).valueOf()))).valueOf())), new int(-52)];
}
return [x, new int(0)];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace math.bits */
/** @constant {Array_fixed_u8_256} */
let math__bits__ntz_8_tab = undefined;
/** @constant {Array_fixed_u8_256} */
let math__bits__pop_8_tab = undefined;
/** @constant {Array_fixed_u8_256} */
let math__bits__rev_8_tab = undefined;
/** @constant {Array_fixed_u8_256} */
let math__bits__len_8_tab = undefined;
/** @namespace math.bits */
/**
* @function
* @param {f32} f
* @returns {u32}
*/
function math__bits__f32_bits(f) {
try {
/** @type {u32} */
const p = new u32(new int(0));
let buffer = new ArrayBuffer(4)
let floatArr = new Float32Array(buffer)
floatArr[0] = f.val
let uintArr = new Uint32Array(buffer)
p.val = uintArr[0]
return p;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} b
* @returns {f32}
*/
function math__bits__f32_from_bits(b) {
try {
/** @type {f32} */
const p = new f32(new f32(0.0));
let buffer = new ArrayBuffer(4)
let floatArr = new Float32Array(buffer)
let uintArr = new Uint32Array(buffer)
uintArr[0] = Number(b.val)
p.val = floatArr[0]
return p;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {f64} f
* @returns {u64}
*/
function math__bits__f64_bits(f) {
try {
/** @type {u64} */
const p = new u64(new u64(BigInt(0n)));
let buffer = new ArrayBuffer(8)
let floatArr = new Float64Array(buffer)
floatArr[0] = f.val
let uintArr = new BigUint64Array(buffer)
p.val = uintArr[0]
return p;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} b
* @returns {f64}
*/
function math__bits__f64_from_bits(b) {
try {
/** @type {f64} */
const p = new f64(new f32(0.0));
let buffer = new ArrayBuffer(8)
let floatArr = new Float64Array(buffer)
let uintArr = new BigUint64Array(buffer)
uintArr[0] = b.val
p.val = floatArr[0]
return p;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace math.bits */
/* [inline] */
/**
* @function
* @param {f32} f
* @returns {u32}
*/
function math__bits__pure_v_but_overridden_by_js_f32_bits(f) {
try {
/** @type {u32} */
const p = new u32((new $ref(new u32(new $ref(f)))).valueOf());
return p;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u32} b
* @returns {f32}
*/
function math__bits__pure_v_but_overridden_by_js_f32_from_bits(b) {
try {
/** @type {f32} */
const p = new f32((new $ref(new f32(new $ref(b)))).valueOf());
return p;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {f64} f
* @returns {u64}
*/
function math__bits__pure_v_but_overridden_by_js_f64_bits(f) {
try {
/** @type {u64} */
const p = new u64((new $ref(new u64(new $ref(f)))).valueOf());
return p;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u64} b
* @returns {f64}
*/
function math__bits__pure_v_but_overridden_by_js_f64_from_bits(b) {
try {
/** @type {f64} */
const p = new f64((new $ref(new f64(new $ref(b)))).valueOf());
return p;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace builtin */
function i8(val) { if (val === undefined) { val = new Number(0); }this.val = Math.floor(Number(val) & 0xffffffff) }
i8.prototype = {
val: new Number(0),
valueOf() { return Number(this.val) },
toString() { return this.valueOf().toString() },
$toJS() { return +this },
};
function i8__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function i16(val) { if (val === undefined) { val = new Number(0); }this.val = Math.floor(Number(val) & 0xffffffff) }
i16.prototype = {
val: new Number(0),
valueOf() { return Number(this.val) },
toString() { return this.valueOf().toString() },
$toJS() { return +this },
};
function i16__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function int(val) { if (val === undefined) { val = new Number(0); }this.val = Math.floor(Number(val) & 0xffffffff) }
int.prototype = {
val: new Number(0),
valueOf() { return Number(this.val) },
toString() { return this.valueOf().toString() },
$toJS() { return +this },
};
function int__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function i64(val) { if (val === undefined) { val = BigInt(0); }this.val = BigInt.asIntN(64,BigInt(val)) }
i64.prototype = {
val: BigInt(0),
valueOf() { return this.val },
toString() { return this.val.toString() },
$toJS() { return this.val },
};
function i64__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function u8(val) { if (val === undefined) { val = new Number(0); }if (typeof(val) == "string") { this.val = val.charCodeAt() } else if (val instanceof string) { this.val = val.str.charCodeAt(); } else { this.val = Math.round(Number(val)) } }
u8.prototype = {
val: new Number(0),
valueOf() { return this.val | 0 },
toString() { return new string(this.val + "") },
$toJS() { return +this },
};
function u8__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function u16(val) { if (val === undefined) { val = new Number(0); }this.val = Math.floor(Number(val) & 0xffff) >>> 0 }
u16.prototype = {
val: new Number(0),
valueOf() { return Number(this.val) },
toString() { return this.valueOf().toString() },
$toJS() { return +this },
};
function u16__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function u32(val) { if (val === undefined) { val = new Number(0); }this.val = Math.floor(Number(val) & 0xffffffff) >>> 0 }
u32.prototype = {
val: new Number(0),
valueOf() { return Number(this.val) },
toString() { return this.valueOf().toString() },
$toJS() { return +this },
};
function u32__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function u64(val) { if (val === undefined) { val = BigInt(0); }this.val = BigInt.asUintN(64,BigInt(val)) }
u64.prototype = {
val: BigInt(0),
valueOf() { return this.val },
toString() { return this.val.toString() },
$toJS() { return this.val },
};
function u64__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function f32(val) { if (val === undefined) { val = new Number(0); }this.val = Number(val) }
f32.prototype = {
val: new Number(0),
valueOf() { return this.val },
toString() { return this.val.toString() },
$toJS() { return +this },
};
function f32__eq(self,other) { return self.val === other.val; }
function f64(val) { if (val === undefined) { val = new Number(0); }this.val = Number(val) }
f64.prototype = {
val: new Number(0),
valueOf() { return this.val },
toString() { return this.val.toString() },
$toJS() { return +this },
};
function f64__eq(self,other) { return self.val === other.val; }
function int_literal(val) { if (val === undefined) { val = new Number(0); }this.val = Math.floor(Number(val) & 0xffffffff) }
int_literal.prototype = {
val: new Number(0),
valueOf() { return Number(this.val) },
toString() { return this.valueOf().toString() },
$toJS() { return +this },
};
function int_literal__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function float_literal(val) { if (val === undefined) { val = new Number(0); }this.val = Number(val) }
float_literal.prototype = {
val: new Number(0),
valueOf() { return this.val },
toString() { return this.val.toString() },
$toJS() { return +this },
};
function float_literal__eq(self,other) { return self.val === other.val; }
function bool(val) { if (val === undefined) { val = new Boolean(false); }this.val = val instanceof bool ? val.val : +val !== 0 }
bool.prototype = {
val: new Boolean(false),
valueOf() { return this.val },
toString() { return this.val.toString() },
$toJS() { return +this != 0 },
};
function bool__eq(self,other) { return new bool(self.val === other.valueOf()); }
function string(str) { if (str === undefined) { str = new String(""); }this.str = str.toString(); this.len = this.str.length }
string.prototype = {
str: new String(""),
valueOf() { return this.str },
toString() { return this.str },
$toJS() { return this.str },
};
function string__eq(self,other) { return new bool(self.str === other.str); }
function map(map) { if (map === undefined) { map = new map({}); }this.map = map; this.length = 0; }
map.prototype = {
map: new map({}),
valueOf() { return this },
toString() { return this.map.toString() },
$toJS() { return this.map },
};
function map__eq(self,other) { return new bool(vEq(self, other)); }
function array(arr) { if (arr === undefined) { arr = new array_buffer({}); }this.arr = arr
if (arr.index_start.val != 0 || arr.has_slice.val) { v_makeSlice(this); } }
array.prototype = {
arr: new array_buffer({}),
valueOf() { return this },
toString() { return JSON.stringify(this.arr.map(it => it.valueOf())) },
$toJS() { return this.arr },
};
function array__eq(self,other) { return new bool(vEq(self, other)); }
function rune(val) { if (val === undefined) { val = new Number(0); }val = val.valueOf(); if (typeof val == "string") {this.val = val.charCodeAt();} else if (val instanceof string) { this.val = val.str.charCodeAt(); } else { this.val = val | 0 } }
rune.prototype = {
val: new Number(0),
valueOf() { return this.val | 0 },
toString() { return new string(this.val + "") },
$toJS() { return +this },
};
function rune__eq(self,other) { return new bool(self.valueOf() === other.valueOf()); }
function any(any) { if (any === undefined) { any = null; }this.val = any }
any.prototype = {
any: null,
valueOf() { return this.val },
toString() { return "&" + this.val },
$toJS() { return this.val.$toJS() },
};
function any__eq(self,other) { return new bool(self == other); }
function voidptr(val) { if (val === undefined) { val = null; }this.val = val; }
voidptr.prototype = {
val: null,
valueOf() { return this },
toString() { return "voidptr(" + this.val + ")" },
$toJS() { return this.val },
};
function voidptr__eq(self,other) { return this.val === other.val; }
Object.defineProperty(array.prototype,"len", { get: function() {return new int(this.arr.arr.length);}, set: function(l) { this.arr.arr.length = l.valueOf(); } });
Object.defineProperty(map.prototype,"len", { get: function() {return new int(this.length);}, set: function(l) { } });
Object.defineProperty(array.prototype,"length", { get: function() {return new int(this.arr.arr.length);}, set: function(l) { this.arr.arr.length = l.valueOf(); } });
/**
* @constructor
* @param {{arr?: Array, index_start?: int, len?: int, cap?: int, has_slice?: bool}} init
*/
function array_buffer({ arr = undefined, index_start = new int(0), len = new int(0), cap = new int(0), has_slice = new bool(false) }) {
this.arr = arr
this.index_start = index_start
this.len = len
this.cap = cap
this.has_slice = has_slice
};
array_buffer.prototype = {
...Object.prototype,
...RegExp.prototype,
...Any.prototype,
toString() {
return `array_buffer { arr: ${this["arr"].toString()} , index_start: ${this["index_start"].toString()} , len: ${this["len"].toString()} , cap: ${this["cap"].toString()} , has_slice: ${this["has_slice"].toString()} }`
},
/** @type {Array} */
arr: undefined,
/** @type {int} */
index_start: new int(0),
/** @type {int} */
len: new int(0),
/** @type {int} */
cap: new int(0),
/** @type {bool} */
has_slice: new bool(false),
$toJS() { return this; }
};
/**
* @function
* @returns {void}
*/
function array_buffer_make_copy(a) {
a = new $ref(a)
try {
if ((new bool( new bool(a.val.index_start.valueOf() != new int(0).valueOf()).valueOf() || a.val.has_slice.valueOf())).valueOf()) {
/** @type {Array} */
let new_arr = makeEmptyJSArray();
for (let i = new int(0); i < a.val.len; i = new int(i + 1)) {
try {
new_arr.push(a.val.get(i))
/** @type {int} */
let x = new int(i);
/** @type {int} */
x = new int(x);
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {Array} */
new_arr = new_arr;
a.val.arr = new_arr
a.val.index_start = new int(0)
a.val.has_slice = new bool(false)
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
array_buffer.prototype.make_copy = function() { return array_buffer_make_copy(this) }
/**
* @function
* @param {int} ix
* @returns {voidptr}
*/
function array_buffer_get(a, ix) {
try {
/** @type {voidptr} */
let res = null;
res = a.arr[a.index_start.val + ix.val];
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} ix
* @param {voidptr} val
* @returns {void}
*/
function array_buffer_set(a, ix, val) {
a = new $ref(a)
try {
a.val.arr[a.val.index_start.valueOf() + ix.valueOf()] = val;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
array_buffer.prototype.get = function(ix) { return array_buffer_get(this,ix);}
array_buffer.prototype.set = function(ix,val) { array_buffer_set(this,ix,val); }
/**
* @function
* @param {array} arr
* @param {anon_fn_voidptr_voidptr__int} comparator
* @returns {void}
*/
function v_sort(arr, comparator) {
arr = new $ref(arr)
try {
/** @type {bool} */
let need_iter = new bool(new bool(true));
while (+need_iter) {
try {
/** @type {bool} */
need_iter = new bool(new bool(false));
for (let i = new int(new int(1)); +new bool(i.valueOf() < arr.val.len.valueOf()); i.val ++) {
try {
if ((new bool(comparator(arr.valueOf().arr.get(new int(i.valueOf())), arr.valueOf().arr.get(new int(new int( i.valueOf() - new int(1).valueOf()).valueOf()))).valueOf() != new int(1).valueOf())).valueOf()) {
let tmp = arr.valueOf().arr.get(new int(i.valueOf())); arr.valueOf().arr.set(new int(i.valueOf()),arr.valueOf().arr.get(new int(new int( i.valueOf() - new int(1).valueOf()).valueOf()))); arr.valueOf().arr.set(new int(new int( i.valueOf() - new int(1).valueOf()).valueOf()),tmp); need_iter = new bool(new bool(true)); }
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} index
* @returns {void}
*/
function array_trim(a, index) {
a = new $ref(a)
try {
if ((new bool(index.valueOf() < a.val.len.valueOf())).valueOf()) {
/** @type {int} */
a.val.len = new int(index);
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
function flatIntoArray(target, source, sourceLength, targetIndex, depth) {
"use strict";
for (var sourceIndex = 0; sourceIndex < sourceLength; ++sourceIndex) {
if (sourceIndex in source) {
var element = source[sourceIndex];
if (depth > 0 && Array.isArray(element))
targetIndex = flatIntoArray(target, element, element.length, targetIndex, depth - 1);
else {
target[targetIndex] = element;
++targetIndex;
}
}
}
return targetIndex;
}
function flatArray(target,depth) {
var array = target
var length = array.length;
var depthNum = 1;
if (depth !== undefined)
depthNum = +depth
var result = []
flatIntoArray(result, array, length, 0, depthNum);
return result;
}
/* [unsafe] */
/**
* @function
* @param {int} count
* @param {int} depth
* @returns {array}
*/
function array_repeat_to_depth(a, count, depth) {
try {
if ((new bool(count.valueOf() < new int(0).valueOf())).valueOf()) {
builtin__panic (new string(`array.repeat: count is negative: ${int_str(count)}`));
}
/** @type {array} */
let arr = empty_array();
if ((new bool(a.len.valueOf() > new int(0).valueOf())).valueOf()) {
for (let _tmp4 = new int(0); _tmp4 < count; _tmp4 = new int(_tmp4 + 1)) {
try {
for (let i = new int(0); i < a.len; i = new int(i + 1)) {
try {
if ((new bool(depth.valueOf() > new int(0).valueOf())).valueOf()) {
} else {
array_push(arr,array_buffer_get(a.arr,i));
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
}
return arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {voidptr}
*/
function array_last(a) {
try {
/** @type {voidptr} */
let res = null;
res = a.arr.get(new int(a.len-1));
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} ix
* @returns {voidptr}
*/
function array_get(a, ix) {
try {
/** @type {voidptr} */
let result = null;
result = a.arr.get(ix)
return result;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} count
* @returns {array}
*/
function array_repeat(a, count) {
try {
{
return array_repeat_to_depth(a,count, new int(0));
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
function makeEmptyArray() { return new array(new array_buffer({ arr: [], len: new int(0), index_start: new int(0), cap: new int(0) })); }
function makeEmptyJSArray() { return new Array(); }
/**
* @function
* @returns {array}
*/
function empty_array() {
try {
return makeEmptyArray();
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} i
* @returns {void}
*/
function array_set_len(a, i) {
a = new $ref(a)
try {
a.arr.arr.length=i
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {voidptr} compare
* @returns {void}
*/
function array_sort_with_compare(a, compare) {
a = new $ref(a)
try {
v_sort(a, compare);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {voidptr} compare
* @returns {void}
*/
function array_sort_with_compare_old(a, compare) {
a = new $ref(a)
try {
a.val.arr.arr.sort(compare)
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function array_sort(a) {
a = new $ref(a)
try {
a.val.arr.arr.sort($sortComparator)
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} v
* @returns {int}
*/
function array_index(a, v) {
try {
for (let i = new int(0); i < a.len; i = new int(i + 1)) {
try {
if (a.arr.get(i).toString() == v.toString())
{
return i;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return new int(-1);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} start
* @param {int} end
* @returns {array}
*/
function array_slice(a, start, end) {
try {
/** @type {array} */
let result = a;
let slice = a.arr.arr.slice(start,end)
result = new array(new array_buffer({arr: a.arr.arr, len: new int(slice.length),cap: new int(slice.length),index_start: new int(start),has_slice: new bool(true)}))
a.arr.has_slice = true
return result;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} i
* @param {voidptr} val
* @returns {void}
*/
function array_insert(a, i, val) {
a = new $ref(a)
try {
a.val.arr.make_copy()
a.val.arr.arr.splice(i,0,val)
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} i
* @param {voidptr} val
* @param {int} size
* @returns {void}
*/
function array_insert_many(a, i, val, size) {
a = new $ref(a)
try {
a.val.arr.arr.splice(i,0,...val.arr.slice(0,+size))
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {voidptr} val
* @returns {void}
*/
function array_push(a, val) {
a = new $ref(a)
try {
a.val.arr.make_copy()
if (arguments[2] && arguments[2].valueOf()) {a.val.arr.arr.push(...val)} else {
a.val.arr.arr.push(val)
}
a.val.arr.len.val += 1
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {array} arr
* @param {anon_fn_voidptr__bool} callback
* @returns {array}
*/
function v_filter(arr, callback) {
try {
/** @type {array} */
let filtered = empty_array();
for (let i = new int(new int(0)); +new bool(i.valueOf() < arr.arr.len.valueOf()); i.val ++) {
try {
if ((callback(array_buffer_get(arr.arr,i))).valueOf()) {
array_push(filtered,array_buffer_get(arr.arr,i));
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return filtered;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {array} arr
* @param {anon_fn_voidptr__voidptr} callback
* @returns {array}
*/
function v_map(arr, callback) {
try {
/** @type {array} */
let mapped = empty_array();
for (let i = new int(new int(0)); +new bool(i.valueOf() < arr.arr.len.valueOf()); i.val ++) {
try {
array_push(mapped,callback(array_buffer_get(arr.arr,i)));
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return mapped;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @constructor
* @param {{ix?: int, end?: int, arr?: Array}} init
*/
function array_iterator({ ix = new int(0), end = new int(0), arr = undefined }) {
this.ix = ix
this.end = end
this.arr = arr
};
array_iterator.prototype = {
...Object.prototype,
...RegExp.prototype,
...Any.prototype,
toString() {
return `array_iterator { ix: ${this["ix"].toString()} , end: ${this["end"].toString()} , arr: ${this["arr"].toString()} }`
},
/** @type {int} */
ix: new int(0),
/** @type {int} */
end: new int(0),
/** @type {Array} */
arr: undefined,
$toJS() { return this; }
};
array_iterator.prototype.next = function () {
if (this.ix.val < this.end.val) {
this.ix.val++;
return {done: false, value: this.arr.arr.get(new int(this.ix.val-1))}
} else {
return {done: true, value: undefined}
}
}
array_iterator.prototype[Symbol.iterator] = function () { return this; }
array.prototype[Symbol.iterator] = function () { return new array_iterator({ix: new int(0),end: new int(this.arr.len),arr: this}); }
array.prototype.entries = function () { let result = []; for (let key = this.arr.index_start.val;key < this.arr.len.val;key++) { result.push([new int(key), this.arr.get(new int(key))]); } return result[Symbol.iterator](); }
array.prototype.map = function(callback) { return v_map(this,callback); }
array.prototype.filter = function(callback) { return v_filter(this,callback); }
Object.defineProperty(array.prototype,'cap',{ get: function () { return this.len; } })
array.prototype.any = function (value) {
let val ;if (typeof value == 'function') { val = function (x) { return value(x); } } else { val = function (x) { return vEq(x,value); } }
for (let i = 0;i < this.arr.arr.length;i++)
if (val(this.arr.get(i)))
return true;
return false;
}
array.prototype.all = function (value) {
let val ;if (typeof value == 'function') { val = function (x) { return value(x); } } else { val = function (x) { return vEq(x,value); } }
for (let i = 0;i < this.arr.arr.length;i++)
if (!val(this.arr.get(i)))
return false;
return true;
}
function v_makeSlice(array) { Object.defineProperty(array,'len', {get: function() { return this.arr.len; }, set: function(l) { this.arr.len = l; }}) }
/**
* @function
* @param {int} i
* @returns {void}
*/
function array_delete(a, i) {
a = new $ref(a)
try {
array_delete_many(a.valueOf(),i, new int(1));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {array} dst
* @param {array} src
* @param {int} count
* @returns {void}
*/
function arr_copy(dst, src, count) {
dst = new $ref(dst)
try {
for (let i = new int(new int(0)); +new bool(i.valueOf() < count.valueOf()); i.val ++) {
try {
array_buffer_set(dst.val.arr,i, array_buffer_get(src.arr,i));
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} i
* @param {int} size
* @returns {void}
*/
function array_delete_many(a, i, size) {
a = new $ref(a)
try {
a.val.arr.make_copy()
a.val.arr.arr.splice(i.valueOf(),size.valueOf())
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {voidptr} val
* @returns {void}
*/
function array_prepend(a, val) {
a = new $ref(a)
try {
array_insert(a.valueOf(),new int(0), val);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [unsafe] */
/**
* @function
* @param {voidptr} val
* @param {int} size
* @returns {void}
*/
function array_prepend_many(a, val, size) {
a = new $ref(a)
try {
array_insert_many(a.valueOf(),new int(0), val, size);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {array}
*/
function array_reverse(a) {
try {
/** @type {array} */
let res = empty_array();
res.arr.arr = Array.from(a.arr).reverse()
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function array_reverse_in_place(a) {
a = new $ref(a)
try {
a.val.arr.arr.reverse()
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
array.prototype.$includes = function (elem) { return this.arr.arr.find(function(e) { return vEq(elem,e); }) !== undefined;}
/**
* @function
* @returns {void}
*/
function array_clear(a) {
a = new $ref(a)
try {
a.val.arr.make_copy()
a.val.arr.arr.clear()
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {anon_fn_int_int__int} iter
* @param {int} accum_start
* @returns {int}
*/
function array_reduce(a, iter, accum_start) {
try {
/** @type {int} */
let accum_ = new int(accum_start);
for (let i = new int(0); i < a.len; i = new int(i + 1)) {
try {
/** @type {int} */
accum_ = new int(iter(accum_, array_get(a,i)));
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return accum_;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {voidptr}
*/
function array_pop(a) {
a = new $ref(a)
try {
/** @type {voidptr} */
let res = null;
a.val.arr.make_copy()
res = a.val.arr.arr.pop()
a.val.arr.len.val -= 1
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {voidptr}
*/
function array_first(a) {
try {
/** @type {voidptr} */
let res = null;
res = a.arr.get(new int(0))
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
array.prototype.toString = function () {
let res = "["
for (let i = 0; i < this.arr.arr.length;i++) {
res += this.arr.get(i).toString();
if (i != this.arr.arr.length-1)
res += ', '
}
res += ']'
return res;
}
/**
* @function
* @param {voidptr} key
* @returns {bool}
*/
function array_contains(a, key) {
try {
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function array_delete_last(a) {
a = new $ref(a)
try {
a.val.arr.arr.pop();
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [unsafe] */
/**
* @function
* @returns {void}
*/
function array_free(a) {
a = new $ref(a)
try {
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function array_bytestr(a) {
try {
/** @type {string} */
const res = new string(new string(""));
for (let i = 0;i < a.arr.len.valueOf();i++) res.str += String.fromCharCode(a.arr.get(new int(i)))
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function Array_string_str(a) {
try {
/** @type {strings__Builder} */
let sb = strings__new_builder(new int( a.len.valueOf() * new int(3).valueOf()));
strings__Builder_write_string(sb,new string("["));
for (let i = new int(0); i < a.len; i = new int(i + 1)) {
try {
/** @type {string} */
const val = new string(a.arr.get(new int(i.valueOf())));
strings__Builder_write_string(sb,new string("'"));
strings__Builder_write_string(sb,val);
strings__Builder_write_string(sb,new string("'"));
if ((new bool(i.valueOf() < new int( a.len.valueOf() - new int(1).valueOf()).valueOf())).valueOf()) {
strings__Builder_write_string(sb,new string(", "));
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
strings__Builder_write_string(sb,new string("]"));
/** @type {string} */
const res = new string(strings__Builder_str(new $ref(sb)));
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {Array}
*/
function array_to_js_array(a) {
try {
/** @type {Array} */
const tmp = Array.prototype.constructor();
for (let i = new int(0); i < a.len; i = new int(i + 1)) {
try {
tmp.push(array_buffer_get(a.arr,i));
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return tmp;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {Array}
*/
function array_to_number_array(a) {
try {
/** @type {Array} */
const tmp = Array.prototype.constructor();
for (let i = new int(0); i < a.len; i = new int(i + 1)) {
try {
/** @type {voidptr} */
const elem = array_buffer_get(a.arr,i);
const _tmp5 = elem;
tmp.push(Number(elem.valueOf()));
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return tmp;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_u8} arr
* @returns {Uint8Array}
*/
function uint8_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp6 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {Uint8Array} */
let uint_arr = new Uint8Array();
uint_arr = new Uint8Array(tmp)
return uint_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_u16} arr
* @returns {Uint16Array}
*/
function uint16_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp7 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {Uint16Array} */
let uint_arr = new Uint16Array();
uint_arr = new Uint16Array(tmp)
return uint_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_u32} arr
* @returns {Uint32Array}
*/
function uint32_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp8 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {Uint32Array} */
let uint_arr = new Uint32Array();
uint_arr = new Uint32Array(tmp)
return uint_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_i8} arr
* @returns {Int8Array}
*/
function int8_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp9 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {Int8Array} */
let int_arr = new Int8Array();
int_arr = new Int8Array(tmp)
return int_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_i16} arr
* @returns {Int16Array}
*/
function int16_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp10 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {Int16Array} */
let int_arr = new Int16Array();
int_arr = new Int16Array(tmp)
return int_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_int} arr
* @returns {Int32Array}
*/
function int32_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp11 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {Int32Array} */
let int_arr = new Int32Array();
int_arr = new Int32Array(tmp)
return int_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_i64} arr
* @returns {BigInt64Array}
*/
function int64_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp12 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {BigInt64Array} */
let int_arr = new BigInt64Array();
int_arr = new BigInt64Array(tmp)
return int_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_u64} arr
* @returns {BigUint64Array}
*/
function uint64_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp13 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {BigUint64Array} */
let int_arr = new BigUint64Array();
int_arr = new BigUint64Array(tmp)
return int_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_f32} arr
* @returns {Float32Array}
*/
function float32_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp14 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {Float32Array} */
let float_arr = new Float32Array();
float_arr = new Float32Array(tmp)
return float_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_f64} arr
* @returns {Float64Array}
*/
function float64_array(arr) {
try {
let tmp = new Array();
for (const elem of arr) {
try {
const _tmp15 = elem;
tmp.push(elem.val)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {Float64Array} */
let float_arr = new Float64Array();
float_arr = new Float64Array(tmp)
return float_arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace builtin */
/* [noreturn] */
/**
* @function
* @param {any} s
* @returns {void}
*/
function js_throw(s) {
try {
throw s
while (true) {
try {
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
let globalPrint, globalWrite;
if (false)
{
globalPrint = globalThis.print
globalWrite = (typeof globalThis.write === 'function')? write: globalThis.print
}
/**
* @function
* @returns {void}
*/
function flush_stdout() {
try {
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function flush_stderr() {
try {
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} s
* @returns {void}
*/
function builtin__println(s) {
try {
if (false)
{
globalPrint(s.str)
}
else
{
console.log(s.str)
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} s
* @returns {void}
*/
function builtin__print(s) {
try {
if (true)
{
$process.stdout.write(s.str)
}
else if (false)
{
globalWrite(s.str)
}
else
{
builtin__panic (new string("Cannot `print` in a browser, use `println` instead"));
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} s
* @returns {void}
*/
function builtin__eprintln(s) {
try {
if (false)
{
globalPrint(s.str)
}
else
{
console.error(s.str)
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} s
* @returns {void}
*/
function builtin__eprint(s) {
try {
if (true)
{
$process.stderr.write(s.str)
}
else
{
builtin__panic (new string("Cannot `eprint` in a browser, use `println` instead"));
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [noreturn] */
/**
* @function
* @param {int} c
* @returns {void}
*/
function builtin__exit(c) {
try {
process.exit(c);
js_throw(new string(`exit(${int_str(c)})`));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {voidptr} data
* @param {Option} option
* @returns {void}
*/
function opt_ok(data, option) {
try {
option.state = 0
option.err = none__
option.data = data
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} opt
* @returns {string}
*/
function unwrap(opt) {
try {
/** @type {Option} */
let o = new Option({});
o = opt
if ((new bool(o.state.valueOf() != new int(0).valueOf())).valueOf()) {
js_throw(o.err);
}
/** @type {string} */
let res = new string(new string(""));
res = opt.data
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function js_stacktrace() {
try {
/** @type {string} */
const stacktrace = new string(new string(""));
let err = new TypeError();
err.name = 'stacktrace: '
stacktrace.str = err.stack
return stacktrace;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function print_backtrace() {
try {
builtin__println (js_stacktrace());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {voidptr} val
* @returns {bool}
*/
function builtin__isnil(val) {
try {
/** @type {bool} */
const res = new bool(new bool(false));
if (typeof val == 'function') { res.val = false; } else {
val = val instanceof voidptr ? val.valueOf().val : val;
res.val = val === null || val === undefined || val === false || val === 0 || val === BigInt(0) || (val instanceof int ? val.val == 0 : false)
}
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function float_literal_str(f) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str += f.valueOf()
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace builtin */
/**
* @function
* @returns {void}
*/
function any_toString(a) {
try {
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [noreturn] */
/**
* @function
* @param {string} s
* @returns {void}
*/
function builtin__panic(s) {
try {
builtin__eprintln (new string(`V panic: ${s}\n${js_stacktrace()}`));
builtin__exit(new int(1));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @interface IError
* @typedef IError
* @property {() => string} msg
* @property {() => int} code
*/
function IError (arg) { return new $ref(arg); }
/**
* @function
* @returns {string}
*/
function IError_str(err) {
try {
let _tmp16 = undefined;
if (err.val instanceof None__) {
_tmp16 = new string("none");
}
else if (err.val instanceof Error) {
_tmp16 = Error_msg(err.valueOf(),);
}
else if (err.val instanceof MessageError) {
_tmp16 = MessageError_str(err.val);
}
else {
/** @type {bool} */
const old_error_style = new bool(new bool(new voidptr(new $ref(err.msg.str)).valueOf() != new voidptr(new $ref(err.code.str)).valueOf()));
_tmp16 = ((old_error_style).valueOf() ? new string(`${IError_type_name(err,)}: ${err.msg}`) : new string(`${IError_type_name(err,)}: ${err.msg()}`))
}
return _tmp16;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @constructor
* @param {{}} init
*/
function Error({ }) {
};
Error.prototype = {
...Object.prototype,
...RegExp.prototype,
...Any.prototype,
toString() {
return `Error {}`
},
$toJS() { return this; }
};
/**
* @function
* @returns {string}
*/
function Error_msg(err) {
try {
return new string("");
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {int}
*/
function Error_code(err) {
try {
return new int(0);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @constructor
* @param {{msg?: string, code?: int}} init
*/
function MessageError({ msg = new string(""), code = new int(0) }) {
this.msg = msg
this.code = code
};
MessageError.prototype = {
...Object.prototype,
...RegExp.prototype,
...Any.prototype,
toString() {
return `MessageError { msg: "${this["msg"].toString()}", code: ${this["code"].toString()} }`
},
/** @type {string} */
msg: new string(""),
/** @type {int} */
code: new int(0),
$toJS() { return this; }
};
/**
* @function
* @returns {string}
*/
function MessageError_str(err) {
try {
return err.msg;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function MessageError_msg(err) {
try {
return err.msg;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {int}
*/
function MessageError_code(err) {
try {
return err.code;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @constant {IError} */
let none__ = undefined;
/**
* @constructor
* @param {{}} init
*/
function None__({ }) {
};
None__.prototype = {
...Error.prototype,
...Object.prototype,
...RegExp.prototype,
...Any.prototype,
toString() {
return `None__ {}`
},
$toJS() { return this; }
};
/**
* @function
* @returns {string}
*/
function None___str(_) {
try {
return new string("none");
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @constructor
* @param {{state?: u8, err?: IError}} init
*/
function Option({ state = new u8(0), err = none__ }) {
this.state = state
this.err = err
};
Option.prototype = {
...Object.prototype,
...RegExp.prototype,
...Any.prototype,
toString() {
return `Option { state: ${this["state"].toString()} , err: ${this["err"].toString()} }`
},
/** @type {u8} */
state: new u8(0),
/** @type {IError} */
err: undefined,
$toJS() { return this; }
};
/**
* @function
* @returns {string}
*/
function Option_str(o) {
try {
if ((new bool(o.state.valueOf() == new int(0).valueOf())).valueOf()) {
return new string("Option{ ok }");
}
if ((new bool(o.state.valueOf() == new int(1).valueOf())).valueOf()) {
return new string("Option{ none }");
}
return new string(`Option{ error: "${IError_str(o.err)}" }`);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @constructor
* @param {{state?: u8, err?: IError}} init
*/
function _option({ state = new u8(0), err = none__ }) {
this.state = state
this.err = err
};
_option.prototype = {
...Object.prototype,
...RegExp.prototype,
...Any.prototype,
toString() {
return `_option { state: ${this["state"].toString()} , err: ${this["err"].toString()} }`
},
/** @type {u8} */
state: new u8(0),
/** @type {IError} */
err: undefined,
$toJS() { return this; }
};
/**
* @function
* @returns {string}
*/
function _option_str(o) {
try {
if ((new bool(o.state.valueOf() == new int(0).valueOf())).valueOf()) {
return new string("Option{ ok }");
}
if ((new bool(o.state.valueOf() == new int(1).valueOf())).valueOf()) {
return new string("Option{ none }");
}
return new string(`Option{ error: "${IError_str(o.err)}" }`);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} x
* @returns {void}
*/
function trace_error(x) {
try {
builtin__eprintln (new string(`> ${"trace_error"} | ${x}`));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {string} message
* @returns {IError}
*/
function error(message) {
try {
return new $ref((function() {
let _tmp17 = new MessageError({});
_tmp17.msg = message;
return _tmp17;
})()
);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {string} message
* @param {int} code
* @returns {IError}
*/
function error_with_code(message, code) {
try {
return new $ref((function() {
let _tmp18 = new MessageError({});
_tmp18.msg = message;
_tmp18.code = code;
return _tmp18;
})()
);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [unsafe] */
/**
* @function
* @param {voidptr} ptr
* @returns {void}
*/
function free(ptr) {
try {
const _tmp19 = ptr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace builtin */
/**
* @function
* @returns {bool}
*/
function u8_is_space(b) {
try {
/** @type {bool} */
let result = new bool(new bool(false));
result.val = /^\s*$/.test(String.fromCharCode(b))
return result;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function u8_str(c) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str = c.val.toString()
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function u8_ascii_str(c) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str = String.fromCharCode(c.val)
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} count
* @returns {string}
*/
function u8_repeat(c, count) {
try {
/** @type {string} */
let res = new string(new string(""));
for (let _tmp20 = new int(0); _tmp20 < count; _tmp20 = new int(_tmp20 + 1)) {
try {
/** @type {string} */
res.str = res + new string(u8_ascii_str(c,));
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {bool}
*/
function u8_is_digit(c) {
try {
return new bool( new bool(c.valueOf() >= new u8('0').valueOf()).valueOf() && new bool(c.valueOf() <= new u8('9').valueOf()).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {bool}
*/
function u8_is_hex_digit(c) {
try {
return new bool( new bool( u8_is_digit(c,).valueOf() || (new bool( new bool(c.valueOf() >= new u8('a').valueOf()).valueOf() && new bool(c.valueOf() <= new u8('f').valueOf()).valueOf())).valueOf()).valueOf() || (new bool( new bool(c.valueOf() >= new u8('A').valueOf()).valueOf() && new bool(c.valueOf() <= new u8('F').valueOf()).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {bool}
*/
function u8_is_oct_digit(c) {
try {
return new bool( new bool(c.valueOf() >= new u8('0').valueOf()).valueOf() && new bool(c.valueOf() <= new u8('7').valueOf()).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {bool}
*/
function u8_is_bin_digit(c) {
try {
return new bool( new bool(c.valueOf() == new u8('0').valueOf()).valueOf() || new bool(c.valueOf() == new u8('1').valueOf()).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {bool}
*/
function u8_is_letter(c) {
try {
return new bool( (new bool( new bool(c.valueOf() >= new u8('a').valueOf()).valueOf() && new bool(c.valueOf() <= new u8('z').valueOf()).valueOf())).valueOf() || (new bool( new bool(c.valueOf() >= new u8('A').valueOf()).valueOf() && new bool(c.valueOf() <= new u8('Z').valueOf()).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {bool}
*/
function u8_is_alnum(c) {
try {
return new bool( new bool( (new bool( new bool(c.valueOf() >= new u8('a').valueOf()).valueOf() && new bool(c.valueOf() <= new u8('z').valueOf()).valueOf())).valueOf() || (new bool( new bool(c.valueOf() >= new u8('A').valueOf()).valueOf() && new bool(c.valueOf() <= new u8('Z').valueOf()).valueOf())).valueOf()).valueOf() || (new bool( new bool(c.valueOf() >= new u8('0').valueOf()).valueOf() && new bool(c.valueOf() <= new u8('9').valueOf()).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {bool}
*/
function u8_is_capital(c) {
try {
return new bool( new bool(c.valueOf() >= new u8('A').valueOf()).valueOf() && new bool(c.valueOf() <= new u8('Z').valueOf()).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function u8_str_escaped(b) {
try {
/** @type {string} */
let str = new string(new string(""));
if (vEq(b,new int(0))) {
/** @type {string} */
str = new string(new string((function() { let s = String();
s += String.fromCharCode(96);
s += String.fromCharCode(92);
s += String.fromCharCode(48);
s += String.fromCharCode(96);
return s; })()
));
}
else if (vEq(b,new int(7))) {
/** @type {string} */
str = new string(new string((function() { let s = String();
s += String.fromCharCode(96);
s += String.fromCharCode(92);
s += String.fromCharCode(97);
s += String.fromCharCode(96);
return s; })()
));
}
else if (vEq(b,new int(8))) {
/** @type {string} */
str = new string(new string((function() { let s = String();
s += String.fromCharCode(96);
s += String.fromCharCode(92);
s += String.fromCharCode(98);
s += String.fromCharCode(96);
return s; })()
));
}
else if (vEq(b,new int(9))) {
/** @type {string} */
str = new string(new string((function() { let s = String();
s += String.fromCharCode(96);
s += String.fromCharCode(92);
s += String.fromCharCode(116);
s += String.fromCharCode(96);
return s; })()
));
}
else if (vEq(b,new int(10))) {
/** @type {string} */
str = new string(new string((function() { let s = String();
s += String.fromCharCode(96);
s += String.fromCharCode(92);
s += String.fromCharCode(110);
s += String.fromCharCode(96);
return s; })()
));
}
else if (vEq(b,new int(11))) {
/** @type {string} */
str = new string(new string((function() { let s = String();
s += String.fromCharCode(96);
s += String.fromCharCode(92);
s += String.fromCharCode(118);
s += String.fromCharCode(96);
return s; })()
));
}
else if (vEq(b,new int(12))) {
/** @type {string} */
str = new string(new string((function() { let s = String();
s += String.fromCharCode(96);
s += String.fromCharCode(92);
s += String.fromCharCode(102);
s += String.fromCharCode(96);
return s; })()
));
}
else if (vEq(b,new int(13))) {
/** @type {string} */
str = new string(new string((function() { let s = String();
s += String.fromCharCode(96);
s += String.fromCharCode(92);
s += String.fromCharCode(114);
s += String.fromCharCode(96);
return s; })()
));
}
else if (vEq(b,new int(27))) {
/** @type {string} */
str = new string(new string((function() { let s = String();
s += String.fromCharCode(96);
s += String.fromCharCode(92);
s += String.fromCharCode(101);
s += String.fromCharCode(96);
return s; })()
));
}
else if ((b >= new int(32) && b <= new int(126))) {
/** @type {string} */
str = new string(u8_ascii_str(b,));
}
else {
/** @type {string} */
str = new string(new string( new string("0x").valueOf() + u8_hex(b,).valueOf()));
};
return str;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace builtin */
/**
* @function
* @returns {string}
*/
function f32_str(x) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str = x.val + ''
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function f64_str(x) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str = x.val + ''
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace builtin */
function byte(val) { return val; }
/** @constant {i8} */
let min_i8 = undefined;
/** @constant {i8} */
let max_i8 = undefined;
/** @constant {i16} */
let min_i16 = undefined;
/** @constant {i16} */
let max_i16 = undefined;
/** @constant {i32} */
let min_i32 = undefined;
/** @constant {i32} */
let max_i32 = undefined;
/** @constant {i32} */
let min_int = undefined;
/** @constant {i32} */
let max_int = undefined;
/** @constant {i64} */
let min_i64 = undefined;
/** @constant {i64} */
let max_i64 = undefined;
/** @constant {u8} */
let min_u8 = undefined;
/** @constant {u8} */
let max_u8 = undefined;
/** @constant {u16} */
let min_u16 = undefined;
/** @constant {u16} */
let max_u16 = undefined;
/** @constant {u32} */
let min_u32 = undefined;
/** @constant {u32} */
let max_u32 = undefined;
/** @constant {u64} */
let min_u64 = undefined;
/** @constant {u64} */
let max_u64 = undefined;
/**
* @function
* @returns {string}
*/
function i8_str(i) {
try {
/** @type {string} */
let res = new string(new string(""));
res.str = i.val.toString()
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function i16_str(i) {
try {
/** @type {string} */
let res = new string(new string(""));
res.str = i.val.toString()
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function u16_str(i) {
try {
/** @type {string} */
let res = new string(new string(""));
res.str = i.val.toString()
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function int_str(i) {
try {
/** @type {string} */
let res = new string(new string(""));
res = new string( i+'' )
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function i64_str(i) {
try {
/** @type {string} */
let res = new string(new string(""));
res = new string( i + '')
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function u32_str(i) {
try {
/** @type {string} */
let res = new string(new string(""));
res = new string( i + '')
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function u64_str(i) {
try {
/** @type {string} */
let res = new string(new string(""));
res = new string( i + '')
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function bool_str(i) {
try {
/** @type {string} */
let res = new string(new string(""));
res = new string( i + '')
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function any_str(i) {
try {
/** @type {string} */
let res = new string(new string(""));
res = new string( i.toString() )
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function int_literal_str(i) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str = i.val.toString()
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function u64_hex(x) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str = x.val.toString(16)
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function u64_hex_full(x) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str = x.val.toString(16)
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function i64_hex(x) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str = x.val.toString(16)
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function u32_hex(x) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str = x.val.toString(16)
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function u16_hex(x) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str = x.val.toString(16)
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function i8_hex(x) {
try {
/** @type {string} */
let res = new string(new string(""));
res.str = x.val.toString(16)
if ((new bool(res.len.valueOf() < new int(2).valueOf())).valueOf()) {
/** @type {string} */
res = new string(new string( new string("0").valueOf() + res.valueOf()));
}
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function i16_hex(x) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str = x.val.toString(16)
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function int_hex(x) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str = x.val.toString(16)
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function int_literal_hex(x) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str = x.val.toString(16)
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function u8_hex(x) {
try {
/** @type {string} */
let res = new string(new string(""));
res.str = x.val.toString(16)
if ((new bool(res.len.valueOf() < new int(2).valueOf())).valueOf()) {
/** @type {string} */
res = new string(new string( new string("0").valueOf() + res.valueOf()));
}
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function Array_u8_hex(b) {
try {
/** @type {string} */
let hex = new string(new string(""));
for (const i of b) {
try {
/** @type {u8} */
let z = new u8(i);
/** @type {u8} */
z = new u8(z);
let n0 = i.val >> 4
hex.str += n0 < 10 ? String.fromCharCode(n0) : String.fromCharCode(n0 + 87)
let n1 = i.val & 0xF
hex.str += n1 < 10 ? String.fromCharCode(n1) : String.fromCharCode(n1 + 87)
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return hex;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function int_hex2(i) {
try {
return new string( new string("0x").valueOf() + int_hex(i,).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function i8_hex2(i) {
try {
return new string( new string("0x").valueOf() + i8_hex(i,).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function i16_hex2(i) {
try {
return new string( new string("0x").valueOf() + i16_hex(i,).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function i64_hex2(i) {
try {
return new string( new string("0x").valueOf() + i64_hex(i,).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function u8_hex2(i) {
try {
return new string( new string("0x").valueOf() + u8_hex(i,).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function u16_hex2(i) {
try {
return new string( new string("0x").valueOf() + u16_hex(i,).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function u32_hex2(i) {
try {
return new string( new string("0x").valueOf() + u32_hex(i,).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function u64_hex2(i) {
try {
return new string( new string("0x").valueOf() + u64_hex(i,).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace builtin */
function Any(val) { return val; }
/**
* @function
* @param {Any} x
* @returns {bool}
*/
function js_is_null(x) {
try {
/** @type {bool} */
const res = new bool(new bool(false));
res.val = x === null
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Any} x
* @returns {bool}
*/
function js_is_undefined(x) {
try {
/** @type {bool} */
const res = new bool(new bool(false));
res.val = x === undefined
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {Any}
*/
function js_null() {
try {
/** @type {Any} */
let obj = new Any();
obj = null;
return obj;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {Any}
*/
function js_undefined() {
try {
/** @type {Any} */
let obj = new Any();
obj = undefined;
return obj;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_JS__String} arr
* @returns {int}
*/
function native_str_arr_len(arr) {
try {
/** @type {int} */
const len = new int(new int(0));
len = arr.length
return len;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace builtin */
/** @namespace builtin */
/**
* @function
* @returns {node_process}
*/
function js_node_process() {
try {
return process
return {};
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace builtin */
/**
* @function
* @param {Any} key
* @param {Any} val
* @returns {void}
*/
function map_internal_set(m, key, val) {
m = new $ref(m)
try {
if ('$toJS' in key) key = key.$toJS();
if (!(key in m.val.map)) m.val.length++;
m.val.map[key] = val
const _tmp21 = key;
const _tmp22 = val;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Any} key
* @returns {Any}
*/
function map_internal_get(m, key) {
m = new $ref(m)
try {
/** @type {Any} */
let val = new Any(null);
if (typeof key != "string" && '$toJS' in key) key = key.$toJS();
val = m.val.map[key]
const _tmp23 = key;
return val;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
map.prototype.get = function (key) { return map_internal_get(this,key); }
map.prototype.set = function(key,val) { map_internal_set(this,key,val); }
map.prototype.has = function (key) { if (typeof key != "string" && '$toJS' in key) { key = key.$toJS() } return key in this.map; }
/* [unsafe] */
/**
* @function
* @param {Any} key
* @returns {void}
*/
function map_delete(m, key) {
m = new $ref(m)
try {
let k = '$toJS' in key ? key.$toJS() : key;
if (delete m.val.map[k]) { m.val.length--; };
const _tmp24 = key;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function map_free(m) {
m = new $ref(m)
try {
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
map.prototype.toString = function () {
function fmtKey(key) { return typeof key == 'string' ? '\'' + key + '\'' : key}
let res = '{'
for (const entry of this) {
res += fmtKey(entry[0]) + ': ' + entry[0];
}
res += '}'
return res;
}
map.prototype.getOrSet = function (key, init) { if (this.map.has(key)) { return this.map.get(key); } else { this.map.set(key,init); return init; } }
/** @namespace builtin */
/**
* @constructor
* @param {{promise?: Promise}} init
*/
function _v_Promise({ promise }) {
this.promise = promise
};
_v_Promise.prototype = {
toString() {
return `_v_Promise { promise: ${this["promise"].toString()} }`
},
/** @type {Promise} */
$toJS() { return this; }
};
/**
* @function
* @param {anon_fn_js__any} on_fulfilled
* @param {anon_fn_js__any} on_rejected
* @returns {void}
*/
function Promise_T_JS__Any_then_T_Any(p, on_fulfilled, on_rejected) {
try {
p.promise.then(on_fulfilled, on_rejected);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {anon_fn_js__any} callback
* @returns {Promise_T_JS__Any}
*/
function Promise_T_JS__Any_catch_T_Any(p, callback) {
try {
/** @type {Promise} */
const promise = p.promise.v_catch(callback);
return (function() {
let _tmp25 = new _v_Promise({});
_tmp25.promise = promise;
return _tmp25;
})()
;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Any} error
* @returns {Promise_T_JS__Any}
*/
function promise_reject(error) {
try {
/** @type {Promise} */
const promise = Promise.reject(error);
return (function() {
let _tmp26 = new Promise[JS__Any]({});
_tmp26.promise = promise;
return _tmp26;
})()
;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace builtin */
/**
* @function
* @returns {string}
*/
function Array_rune_string(ra) {
try {
/** @type {strings__Builder} */
let sb = strings__new_builder(ra.len);
strings__Builder_write_runes(sb,ra);
/** @type {string} */
const res = new string(strings__Builder_str(new $ref(sb)));
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} count
* @returns {string}
*/
function rune_repeat(c, count) {
try {
if ((new bool(count.valueOf() < new int(0).valueOf())).valueOf()) {
builtin__panic (new string(`rune.repeat: count is negative: ${int_str(count)}`));
} else if ((new bool(count.valueOf() == new int(0).valueOf())).valueOf()) {
return new string("");
} else if ((new bool(count.valueOf() == new int(1).valueOf())).valueOf()) {
return rune_str(c);
}
/** @type {string} */
const res = new string(new string(""));
res.str = String.fromCharCode(Number(c.val))
return string_repeat(res,count);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function rune_str(c) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str = String.fromCharCode(Number(c.val))
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace builtin */
/**
* @function
* @returns {Array_rune}
*/
function string_runes(s) {
try {
/** @type {Array_rune} */
let runes = new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)}));
for (let i = new int(new int(0)); +new bool(i.valueOf() < s.len.valueOf()); i.val ++) {
try {
let r = new rune(new u8('0')); r = new rune(s.str[i.val].charCodeAt())
array_push(runes,r,false);
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return runes;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} a
* @param {int} b
* @returns {string}
*/
function string_slice(s, a, b) {
try {
return new string(s.str.slice(Number(a.$toJS()), Number(b.$toJS())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} start
* @param {int} end
* @returns {string}
*/
function string_substr(s, start, end) {
try {
return string_slice(s,start, end);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} dot
* @returns {string}
*/
function string_after(s, dot) {
try {
return new string(s.str.slice(Number(new int( new int(s.str.lastIndexOf(dot.str)).valueOf() + new int(1).valueOf()).$toJS()), s.str.length));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u8} dot
* @returns {string}
*/
function string_after_char(s, dot) {
try {
return s;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} dot
* @returns {string}
*/
function string_all_after(s, dot) {
try {
/** @type {int} */
const pos = new int(((new bool(dot.len.valueOf() == new int(0).valueOf())).valueOf() ? new int(-1) : new int(s.str.indexOf(dot.str))));
if ((new bool(pos.valueOf() == new int(-1).valueOf())).valueOf()) {
return string_clone(s,);
}
return string_slice(s,new int( pos.valueOf() + dot.len.valueOf()), s.len);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} dot
* @returns {string}
*/
function string_all_after_last(s, dot) {
try {
/** @type {int} */
const pos = new int(((new bool(dot.len.valueOf() == new int(0).valueOf())).valueOf() ? new int(-1) : new int(s.str.lastIndexOf(dot.str))));
if ((new bool(pos.valueOf() == new int(-1).valueOf())).valueOf()) {
return string_clone(s,);
}
return string_slice(s,new int( pos.valueOf() + dot.len.valueOf()), s.len);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} dot
* @returns {string}
*/
function string_all_before(s, dot) {
try {
/** @type {int} */
const pos = new int(((new bool(dot.len.valueOf() == new int(0).valueOf())).valueOf() ? new int(-1) : new int(s.str.indexOf(dot.str))));
if ((new bool(pos.valueOf() == new int(-1).valueOf())).valueOf()) {
return string_clone(s,);
}
return string_slice(s,new int(0), pos);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} dot
* @returns {string}
*/
function string_all_before_last(s, dot) {
try {
/** @type {int} */
const pos = new int(((new bool(dot.len.valueOf() == new int(0).valueOf())).valueOf() ? new int(-1) : new int(s.str.lastIndexOf(dot.str))));
if ((new bool(pos.valueOf() == new int(-1).valueOf())).valueOf()) {
return string_clone(s,);
}
return string_slice(s,new int(0), pos);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {bool}
*/
function string_bool(s) {
try {
return new bool(s.valueOf() == new string("true").valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} dot
* @returns {Array_string}
*/
function string_split(s, dot) {
try {
/** @type {Array} */
const tmparr = s.str.split(dot.str).map((function () {
return function (it) {
/** @type {string} */
const res = new string(new string(""));
res.str = it
return res;
}})()
);
const _tmp27 = tmparr;
/** @type {Array_string} */
let arr = new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)}));
arr = new array(new array_buffer({arr: tmparr,index_start: new int(0),len: new int(tmparr.length)}))
return arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} delim
* @returns {Array_string}
*/
function string_split_any(s, delim) {
try {
if ((new bool(delim.len.valueOf() == new int(0).valueOf())).valueOf()) {
return string_split(s,delim);
}
/** @type {string} */
let pattern = new string(delim);
if ((string_contains(pattern,new string("\\"))).valueOf()) {
/** @type {string} */
pattern = new string(string_replace(pattern,new string("\\"), new string("")));
/** @type {string} */
pattern = new string(`${pattern}\\\\`);
}
/** @type {string} */
pattern = new string(string_replace(pattern,new string("]"), new string("\\]")));
/** @type {RegExp} */
let regexp = new RegExp();
regexp = new RegExp('[' + pattern.str + ']', 'g')
/** @type {Array} */
const tmparr = s.str.split(regexp).map((function () {
return function (it) {
/** @type {string} */
const res = new string(new string(""));
res.str = it
return res;
}})()
);
const _tmp28 = tmparr;
/** @type {Array_string} */
let arr = new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)}));
arr = new array(new array_buffer({arr: tmparr,index_start: new int(0),len: new int(tmparr.length)}))
if (s.len > 0 && pattern.str.includes(s.str[s.len - 1])) {
array_pop(arr,);
}
return arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {Array_u8}
*/
function string_bytes(s) {
try {
/** @type {string} */
const sep = new string(new string(""));
/** @type {Array} */
const tmparr = s.str.split(sep.str).map((function () {
return function (it) {
return new Any(new u8(it.charCodeAt(Number(new int(0).$toJS()))));
}})()
);
const _tmp29 = tmparr;
/** @type {Array_u8} */
let arr = new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)}));
arr = new array(new array_buffer({arr: tmparr,index_start: new int(0),len: new int(tmparr.length)}))
return arr;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function string_capitalize(s) {
try {
/** @type {string} */
const part = new string(new string(s.str.slice(Number(new int(1).$toJS()), s.str.length)));
return new string(s.str.charAt(Number(new int(0).$toJS())).toUpperCase().concat(part.str));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function string_clone(s) {
try {
return new string(s.str);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} substr
* @returns {bool}
*/
function string_contains(s, substr) {
try {
return new bool(s.str.includes(substr.str));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} chars
* @returns {bool}
*/
function string_contains_any(s, chars) {
try {
/** @type {string} */
const sep = new string(new string(""));
/** @type {Array} */
const res = chars.str.split(sep.str);
for (let i = new int(0); i < new int(res.length); i = new int(i + 1)) {
try {
if ((new bool(s.str.includes(res.at(Number(i.$toJS()))))).valueOf()) {
return new bool(true);
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return new bool(false);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} chars
* @returns {bool}
*/
function string_contains_only(s, chars) {
try {
if ((new bool(chars.len.valueOf() == new int(0).valueOf())).valueOf()) {
return new bool(false);
}
for (const ch of s.str.split('').map(c => new u8(c))) {
try {
/** @type {int} */
let res = new int(new int(0));
for (const c of chars.str.split('').map(c => new u8(c))) {
try {
if ((new bool(ch.valueOf() == c.valueOf())).valueOf()) {
res.val ++;
break;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
if ((new bool(res.valueOf() == new int(0).valueOf())).valueOf()) {
return new bool(false);
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return new bool(true);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_string} chars
* @returns {bool}
*/
function string_contains_any_substr(s, chars) {
try {
if ((new bool(chars.len.valueOf() == new int(0).valueOf())).valueOf()) {
return new bool(true);
}
for (const x of chars) {
try {
if ((new bool(s.str.includes(x.str))).valueOf()) {
return new bool(true);
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return new bool(false);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} substr
* @returns {int}
*/
function string_count(s, substr) {
try {
/** @type {Array} */
const arr = s.str.split(substr.str);
/** @type {int} */
const len = new int(new int(arr.length));
if ((new bool(len.valueOf() == new int(0).valueOf())).valueOf()) {
return new int(0);
} else {
return new int( len.valueOf() - new int(1).valueOf());
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} p
* @returns {bool}
*/
function string_ends_with(s, p) {
try {
/** @type {bool} */
let res = new bool(new bool(false));
res.val = s.str.endsWith(p.str)
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} p
* @returns {bool}
*/
function string_starts_with(s, p) {
try {
return new bool(s.str.startsWith(p.str));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {Array_string}
*/
function string_fields(s) {
try {
/** @type {Array_string} */
let res = new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)}));
/** @type {int} */
let word_start = new int(new int(0));
/** @type {int} */
let word_len = new int(new int(0));
/** @type {bool} */
let is_in_word = new bool(new bool(false));
/** @type {bool} */
let is_space = new bool(new bool(false));
for (const [i, c] of Array.from(s.str.split('').entries(), ([i, c]) => [i, new u8(c)])) {
try {
/** @type {bool} */
is_space = new bool((Array_int_contains(new array(new array_buffer({arr: [new int(new int(32)), new int(new int(9)), new int(new int(10))], len: new int(3), cap: new int(3)})),c)));
if ((!is_space.val ).valueOf()) {
word_len.val ++;
}
if ((new bool( !is_in_word.val .valueOf() && !is_space.val .valueOf())).valueOf()) {
/** @type {int} */
word_start = new int(i);
/** @type {bool} */
is_in_word = new bool(new bool(true));
continue;
}
if ((new bool( is_space.valueOf() && is_in_word.valueOf())).valueOf()) {
array_push(res,string_slice(s,word_start, new int( word_start.valueOf() + word_len.valueOf())),false);
/** @type {bool} */
is_in_word = new bool(new bool(false));
/** @type {int} */
word_len = new int(new int(0));
/** @type {int} */
word_start = new int(new int(0));
continue;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
if ((new bool( is_in_word.valueOf() && new bool(word_len.valueOf() > new int(0).valueOf()).valueOf())).valueOf()) {
array_push(res,string_slice(s,word_start, s.len),false);
}
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} start
* @param {string} end
* @returns {string}
*/
function string_find_between(s, start, end) {
try {
return new string(s.str.slice(Number(new int( new int(s.str.indexOf(start.str)).valueOf() + new int(1).valueOf()).$toJS()), s.str.indexOf(end.str)));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function string_free(s) {
s = new $ref(s)
try {
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {int}
*/
function string_hash(s) {
try {
/** @type {u32} */
let h = new u32(new int(0));
if ((new bool( new bool(h.valueOf() == new int(0).valueOf()).valueOf() && new bool(s.len.valueOf() > new int(0).valueOf()).valueOf())).valueOf()) {
for (const c of s.str.split('').map(c => new u8(c))) {
try {
/** @type {u32} */
h = new u32(new u32( new u32( h.valueOf() * new int(31).valueOf()).valueOf() + new u32(c).valueOf()));
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
}
return new int(h);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {int}
*/
function string_int(s) {
try {
/** @type {int} */
const res = new int(new int(0));
if (typeof(s) == "string") { res.val = parseInt(s) }
else { res.val = parseInt(s.str) }
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {i64}
*/
function string_i64(s) {
try {
return new i64(parseInt(s.str));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {i8}
*/
function string_i8(s) {
try {
return new i8(parseInt(s.str));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {i16}
*/
function string_i16(s) {
try {
return new i16(parseInt(s.str));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {f32}
*/
function string_f32(s) {
try {
return new f32(parseFloat(s.str));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {f64}
*/
function string_f64(s) {
try {
return new f64(parseFloat(s.str));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {u16}
*/
function string_u16(s) {
try {
return new u16(parseInt(s.str));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {u32}
*/
function string_u32(s) {
try {
return new u32(parseInt(s.str));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {u64}
*/
function string_u64(s) {
try {
return new u64(parseInt(s.str));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {u64}
*/
function string_u8(s) {
try {
/** @type {u8} */
const res = new u8(new int(0));
res.val = u8(JS.parseInt(s.str))
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [direct_array_access] */
/**
* @function
* @param {string} cutset
* @returns {string}
*/
function string_trim_right(s, cutset) {
try {
if ((new bool( new bool(s.valueOf() == new string("").valueOf()).valueOf() || new bool(cutset.valueOf() == new string("").valueOf()).valueOf())).valueOf()) {
return string_clone(s,);
}
/** @type {int} */
let pos = new int(new int( s.len.valueOf() - new int(1).valueOf()));
while (+new bool(pos.valueOf() >= new int(0).valueOf())) {
try {
/** @type {bool} */
let found = new bool(new bool(false));
for (const cs of cutset.str.split('').map(c => new u8(c))) {
try {
if ((new bool(new u8(s.str.charCodeAt(pos)).valueOf() == cs.valueOf())).valueOf()) {
/** @type {bool} */
found = new bool(new bool(true));
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
if ((!found.val ).valueOf()) {
break;
}
pos.val --;
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
if ((new bool(pos.valueOf() < new int(0).valueOf())).valueOf()) {
return new string("");
}
return string_slice(s,new int(0), new int( pos.valueOf() + new int(1).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [direct_array_access] */
/**
* @function
* @param {string} cutset
* @returns {string}
*/
function string_trim_left(s, cutset) {
try {
if ((new bool( new bool(s.valueOf() == new string("").valueOf()).valueOf() || new bool(cutset.valueOf() == new string("").valueOf()).valueOf())).valueOf()) {
return string_clone(s,);
}
/** @type {int} */
let pos = new int(new int(0));
while (+new bool(pos.valueOf() < s.len.valueOf())) {
try {
/** @type {bool} */
let found = new bool(new bool(false));
for (const cs of cutset.str.split('').map(c => new u8(c))) {
try {
if ((new bool(new u8(s.str.charCodeAt(pos)).valueOf() == cs.valueOf())).valueOf()) {
/** @type {bool} */
found = new bool(new bool(true));
break;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
if ((!found.val ).valueOf()) {
break;
}
pos.val ++;
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return string_slice(s,pos, s.len);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} str
* @returns {string}
*/
function string_trim_string_left(s, str) {
try {
if ((string_starts_with(s,str)).valueOf()) {
return string_slice(s,str.len, s.len);
}
return string_clone(s,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} str
* @returns {string}
*/
function string_trim_string_right(s, str) {
try {
if ((string_ends_with(s,str)).valueOf()) {
return string_slice(s,new int(0), new int( s.len.valueOf() - str.len.valueOf()));
}
return string_clone(s,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} a
* @param {string} b
* @returns {int}
*/
function compare_strings(a, b) {
a = new $ref(a)
b = new $ref(b)
try {
if ((new bool(a.valueOf().valueOf() < b.valueOf().valueOf())).valueOf()) {
return new int(-1);
}
if ((new bool(a.valueOf().valueOf() > b.valueOf().valueOf())).valueOf()) {
return new int(1);
}
return new int(0);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} a
* @param {string} b
* @returns {int}
*/
function compare_strings_reverse(a, b) {
a = new $ref(a)
b = new $ref(b)
try {
if ((new bool(a.valueOf().valueOf() < b.valueOf().valueOf())).valueOf()) {
return new int(1);
}
if ((new bool(a.valueOf().valueOf() > b.valueOf().valueOf())).valueOf()) {
return new int(-1);
}
return new int(0);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} a
* @param {string} b
* @returns {int}
*/
function compare_strings_by_len(a, b) {
a = new $ref(a)
b = new $ref(b)
try {
if ((new bool(a.val.len.valueOf() < b.val.len.valueOf())).valueOf()) {
return new int(-1);
}
if ((new bool(a.val.len.valueOf() > b.val.len.valueOf())).valueOf()) {
return new int(1);
}
return new int(0);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} a
* @param {string} b
* @returns {int}
*/
function compare_lower_strings(a, b) {
a = new $ref(a)
b = new $ref(b)
try {
/** @type {string} */
const aa = new string(string_to_lower(a.valueOf(),));
/** @type {string} */
const bb = new string(string_to_lower(b.valueOf(),));
return compare_strings(new $ref(aa), new $ref(bb));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} idx
* @returns {u8}
*/
function string_at(s, idx) {
try {
/** @type {u8} */
let result = new u8(new int(0));
result = new u8(s.str.charCodeAt(result))
return result;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function string_to_lower(s) {
try {
/** @type {string} */
let result = new string(new string(""));
let str = s.str.toLowerCase()
result = new string(str)
return result;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} old_sub
* @param {string} new_sub
* @returns {string}
*/
function string_replace(s, old_sub, new_sub) {
try {
/** @type {string} */
let result = new string(new string(""));
result = new string( s.str.replaceAll(old_sub.str, new_sub.str) )
return result;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function string_to_upper(s) {
try {
/** @type {string} */
let result = new string(new string(""));
let str = s.str.toUpperCase()
result = new string(str)
return result;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function Array_string_sort(s) {
s = new $ref(s)
try {
array_sort_with_compare(s.valueOf(),compare_strings);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function Array_string_sort_ignore_case(s) {
s = new $ref(s)
try {
array_sort_with_compare(s.valueOf(),compare_lower_strings);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function Array_string_sort_by_len(s) {
s = new $ref(s)
try {
array_sort_with_compare(s.valueOf(),compare_strings_by_len);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function string_str(s) {
try {
return string_clone(s,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} count
* @returns {string}
*/
function string_repeat(s, count) {
try {
/** @type {string} */
let result = new string(new string(""));
result = new string(s.str.repeat(count))
return result;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
function string_iterator(string) { this.stringIteratorFieldIndex = 0; this.stringIteratorIteratedString = string.str; }
string_iterator.prototype.next = function next() {
var done = true;
var value = undefined;
var position = this.stringIteratorFieldIndex;
if (position !== -1) {
var string = this.stringIteratorIteratedString;
var length = string.length >>> 0;
if (position >= length) {
this.stringIteratorFieldIndex = -1;
} else {
done = false;
var first = string.charCodeAt(position);
if (first < 0xD800 || first > 0xDBFF || position + 1 === length)
value = new u8(string[position]);
else {
value = new u8(string[position]+string[position+1])
}
this.stringIteratorFieldIndex = position + value.length;
}
}
return {
value, done
}
}
string.prototype[Symbol.iterator] = function () { return new string_iterator(this) }
/**
* @function
* @returns {string}
*/
function string_strip_margin(s) {
try {
return string_strip_margin_custom(s,new u8('|'));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [direct_array_access] */
/**
* @function
* @param {u8} del
* @returns {string}
*/
function string_strip_margin_custom(s, del) {
try {
/** @type {u8} */
let sep = new u8(del);
if ((u8_is_space(sep,)).valueOf()) {
builtin__eprintln (new string("Warning: `strip_margin` cannot use white-space as a delimiter"));
builtin__eprintln (new string(" Defaulting to `|`"));
/** @type {u8} */
sep = new u8(new u8('|'));
}
/** @type {Array_u8} */
let ret = new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)}));
ret = new array()
/** @type {int} */
let count = new int(new int(0));
for (let i = new int(new int(0)); +new bool(i.valueOf() < s.len.valueOf()); i.val ++) {
try {
if (((Array_int_contains(new array(new array_buffer({arr: [new int(new int(10)), new int(new int(13))], len: new int(2), cap: new int(2)})),new u8(s.str.charCodeAt(i))))).valueOf()) {
{
ret.arr.set(new int(count.valueOf()),new u8(new u8(s.str.charCodeAt(i)))); }
count.val ++;
if ((new bool( new bool( new bool(new u8(s.str.charCodeAt(i)).valueOf() == new int(13).valueOf()).valueOf() && new bool(i.valueOf() < new int( s.len.valueOf() - new int(1).valueOf()).valueOf()).valueOf()).valueOf() && new bool(new u8(s.str.charCodeAt(new int( i.valueOf() + new int(1).valueOf()))).valueOf() == new int(10).valueOf()).valueOf())).valueOf()) {
{
ret.arr.set(new int(count.valueOf()),new u8(new u8(s.str.charCodeAt(new int( i.valueOf() + new int(1).valueOf()))))); }
count.val ++;
i.val ++;
}
while (+new bool(new u8(s.str.charCodeAt(i)).valueOf() != sep.valueOf())) {
try {
i.val ++;
if ((new bool(i.valueOf() >= s.len.valueOf())).valueOf()) {
break;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} else {
{
ret.arr.set(new int(count.valueOf()),new u8(new u8(s.str.charCodeAt(i)))); }
count.val ++;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {string} */
let result = new string(new string(""));
for (let x of ret.arr) result.str += String.fromCharCode(x.val)
return result;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [direct_array_access] */
/**
* @function
* @param {string} delim
* @param {int} nth
* @returns {Array_string}
*/
function string_split_nth(s, delim, nth) {
try {
/** @type {Array_string} */
let res = new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)}));
/** @type {int} */
let i = new int(new int(0));
if (vEq(delim.len,new int(0))) {
/** @type {int} */
i = new int(new int(1));
for (const ch of s.str.split('').map(c => new u8(c))) {
try {
if ((new bool( new bool(nth.valueOf() > new int(0).valueOf()).valueOf() && new bool(i.valueOf() >= nth.valueOf()).valueOf())).valueOf()) {
array_push(res,string_slice(s,i, s.len),false);
break;
}
array_push(res,u8_str(ch),false);
i.val ++;
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return res;
}
else if (vEq(delim.len,new int(1))) {
/** @type {int} */
let start = new int(new int(0));
/** @type {u8} */
const delim_byte = new u8(new u8(delim.str.charCodeAt(new int(0))));
while (+new bool(i.valueOf() < s.len.valueOf())) {
try {
if ((new bool(new u8(s.str.charCodeAt(i)).valueOf() == delim_byte.valueOf())).valueOf()) {
/** @type {bool} */
const was_last = new bool(new bool( new bool(nth.valueOf() > new int(0).valueOf()).valueOf() && new bool(res.len.valueOf() == new int( nth.valueOf() - new int(1).valueOf()).valueOf()).valueOf()));
if ((was_last).valueOf()) {
break;
}
/** @type {string} */
const val = new string(string_slice(s,start, i));
array_push(res,val,false);
/** @type {int} */
start = new int(new int( i.valueOf() + delim.len.valueOf()));
/** @type {int} */
i = new int(start);
} else {
i.val ++;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
if ((new bool( new bool(nth.valueOf() < new int(1).valueOf()).valueOf() || new bool(res.len.valueOf() < nth.valueOf()).valueOf())).valueOf()) {
array_push(res,string_slice(s,start, s.len),false);
}
return res;
}
else {
/** @type {int} */
let start = new int(new int(0));
while (+new bool(i.valueOf() <= s.len.valueOf())) {
try {
/** @type {bool} */
const is_delim = new bool(new bool( new bool(new int( i.valueOf() + delim.len.valueOf()).valueOf() <= s.len.valueOf()).valueOf() && new bool(string_slice(s,i, new int( i.valueOf() + delim.len.valueOf())).valueOf() == delim.valueOf()).valueOf()));
if ((is_delim).valueOf()) {
/** @type {bool} */
const was_last = new bool(new bool( new bool(nth.valueOf() > new int(0).valueOf()).valueOf() && new bool(res.len.valueOf() == new int( nth.valueOf() - new int(1).valueOf()).valueOf()).valueOf()));
if ((was_last).valueOf()) {
break;
}
/** @type {string} */
const val = new string(string_slice(s,start, i));
array_push(res,val,false);
/** @type {int} */
start = new int(new int( i.valueOf() + delim.len.valueOf()));
/** @type {int} */
i = new int(start);
} else {
i.val ++;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
if ((new bool( new bool(nth.valueOf() < new int(1).valueOf()).valueOf() || new bool(res.len.valueOf() < nth.valueOf()).valueOf())).valueOf()) {
array_push(res,string_slice(s,start, s.len),false);
}
return res;
};
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @constructor
* @param {{idx?: int, val_idx?: int}} init
*/
function RepIndex({ idx = new int(0), val_idx = new int(0) }) {
this.idx = idx
this.val_idx = val_idx
};
RepIndex.prototype = {
...Object.prototype,
...RegExp.prototype,
...Any.prototype,
toString() {
return `RepIndex { idx: ${this["idx"].toString()} , val_idx: ${this["val_idx"].toString()} }`
},
/** @type {int} */
idx: new int(0),
/** @type {int} */
val_idx: new int(0),
$toJS() { return this; }
};
/* [direct_array_access] */
/**
* @function
* @param {Array_string} vals
* @returns {string}
*/
function string_replace_each(s, vals) {
try {
if ((new bool( new bool(s.len.valueOf() == new int(0).valueOf()).valueOf() || new bool(vals.len.valueOf() == new int(0).valueOf()).valueOf())).valueOf()) {
return string_clone(s,);
}
if ((new bool(new int( vals.len.valueOf() % new int(2).valueOf()).valueOf() != new int(0).valueOf())).valueOf()) {
builtin__eprintln (new string("string.replace_each(): odd number of strings"));
return string_clone(s,);
}
/** @type {Array_RepIndex} */
let idxs = new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)}));
/** @type {int} */
let idx = new int(new int(0));
/** @type {int} */
let new_len = new int(s.len);
/** @type {string} */
const s_ = new string(string_clone(s,));
function setCharAt(str,index,chr) {
if(index > str.length-1) return str;
return str.substring(0,index) + chr + str.substring(index+1);
}
for (let rep_i = new int(new int(0)); +new bool(rep_i.valueOf() < vals.len.valueOf()); rep_i = new int(new int( rep_i.valueOf() + new int(2).valueOf()))) {
try {
let rep = new string(vals.arr.get(new int(rep_i.valueOf()))); let with_ = new string(vals.arr.get(new int(new int( rep_i.valueOf() + new int(1).valueOf()).valueOf()))); with_ = new string(with_); while (true) {
try {
idx = new int(string_index_after(s_,rep, idx)); if ((new bool(idx.valueOf() == new int(-1).valueOf())).valueOf()) {
break;
}
for (let i = new int(0); i < rep.len; i = new int(i + 1)) {
try {
/** @type {int} */
let j_ = new int(i);
/** @type {int} */
j_ = new int(j_);
s_.str = setCharAt(s_.str,idx + i, String.fromCharCode(127))
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {RepIndex} */
const rep_idx = (function() {
let _tmp30 = new RepIndex({});
_tmp30.idx = new int(0);
_tmp30.val_idx = new int(0);
return _tmp30;
})()
;
rep_idx.idx = idx.val
rep_idx.val_idx = new int(rep_i.val)
array_push(idxs,rep_idx,false);
/** @type {int} */
idx.val = Math.floor(idx + new int(rep.len));
/** @type {int} */
new_len.val = Math.floor(new_len + new int(new int( with_.len.valueOf() - rep.len.valueOf())));
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
if ((new bool(idxs.len.valueOf() == new int(0).valueOf())).valueOf()) {
return string_clone(s,);
}
v_sort(idxs,compare_RepIndex_by_idx);
/** @type {string} */
let b = new string(new string(""));
for (let i = 0; i < new_len.val;i++) b.str += String.fromCharCode(127)
/** @type {int} */
new_len = new int(new_len);
/** @type {int} */
let idx_pos = new int(new int(0));
/** @type {RepIndex} */
let cur_idx = idxs.arr.get(new int(idx_pos.valueOf()));
/** @type {int} */
let b_i = new int(new int(0));
for (let i = new int(new int(0)); +new bool(i.valueOf() < s.len.valueOf()); i.val ++) {
try {
if ((new bool(i.valueOf() == cur_idx.idx.valueOf())).valueOf()) {
let rep = new string(vals.arr.get(new int(cur_idx.val_idx.valueOf()))); let with_ = new string(vals.arr.get(new int(new int( cur_idx.val_idx.valueOf() + new int(1).valueOf()).valueOf()))); for (let j = new int(0); j < with_.len; j = new int(j + 1)) {
try {
/** @type {int} */
let j_ = new int(j);
/** @type {int} */
j_ = new int(j_);
b.str = setCharAt(b.str,b_i, with_.str[j])
b_i.val ++;
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {int} */
i.val = Math.floor(i + new int(new int( rep.len.valueOf() - new int(1).valueOf())));
idx_pos.val ++;
if ((new bool(idx_pos.valueOf() < idxs.len.valueOf())).valueOf()) {
/** @type {RepIndex} */
cur_idx = idxs.arr.get(new int(idx_pos.valueOf()));
}
} else {
b.str = setCharAt(b.str,b_i,s.str[i]) //b.str[b_i] = s.str[i]
b_i.val ++;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return b;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} p
* @returns {int}
*/
function string_index_last_(s, p) {
try {
if ((new bool( new bool(p.len.valueOf() > s.len.valueOf()).valueOf() || new bool(p.len.valueOf() == new int(0).valueOf()).valueOf())).valueOf()) {
return new int(-1);
}
/** @type {int} */
let i = new int(new int( s.len.valueOf() - p.len.valueOf()));
while (+new bool(i.valueOf() >= new int(0).valueOf())) {
try {
/** @type {int} */
let j = new int(new int(0));
while (+new bool( new bool(j.valueOf() < p.len.valueOf()).valueOf() && new bool(new u8(s.str.charCodeAt(new int( i.valueOf() + j.valueOf()))).valueOf() == new u8(p.str.charCodeAt(j)).valueOf()).valueOf())) {
try {
j.val ++;
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
if ((new bool(j.valueOf() == p.len.valueOf())).valueOf()) {
return i;
}
i.val --;
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return new int(-1);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [deprecated] */
/**
* @function
* @deprecated
* @param {string} needle
* @returns {int}
*/
function string_index_last(s, needle) {
try {
const _tmp31 = new _option({});
_tmp31.state = new u8(0);_tmp31.data = (function(){
try {
return unwrap(string_last_index(s,needle))
} catch(err) {
}
})()
return _tmp31;} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {string} needle
* @returns {int}
*/
function string_last_index(s, needle) {
try {
/** @type {int} */
const idx = new int(string_index_last_(s,needle));
if ((new bool(idx.valueOf() == new int(-1).valueOf())).valueOf()) {
return new Option({ state: new u8(2),err: none__});
}
const _tmp32 = new _option({});
_tmp32.state = new u8(0);_tmp32.data = idx
return _tmp32;} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [deprecated] */
/* [deprecated_after] */
/* [inline] */
/**
* @function
* @deprecated
* @param {u8} c
* @returns {int}
*/
function string_index_u8_last(s, c) {
try {
return string_last_index_u8(s,c);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [direct_array_access] */
/**
* @function
* @param {u8} c
* @returns {int}
*/
function string_last_index_u8(s, c) {
try {
for (let i = new int(new int( s.len.valueOf() - new int(1).valueOf())); +new bool(i.valueOf() >= new int(0).valueOf()); i.val --) {
try {
if ((new bool(new u8(s.str.charCodeAt(i)).valueOf() == c.valueOf())).valueOf()) {
return i;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return new int(-1);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function string_trim_space(s) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str = s.str.trim()
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} p
* @param {int} start
* @returns {int}
*/
function string_index_after(s, p, start) {
try {
if ((new bool(p.len.valueOf() > s.len.valueOf())).valueOf()) {
return new int(-1);
}
/** @type {int} */
let strt = new int(start);
if ((new bool(start.valueOf() < new int(0).valueOf())).valueOf()) {
/** @type {int} */
strt = new int(new int(0));
}
if ((new bool(start.valueOf() >= s.len.valueOf())).valueOf()) {
return new int(-1);
}
/** @type {int} */
let i = new int(strt);
while (+new bool(i.valueOf() < s.len.valueOf())) {
try {
/** @type {int} */
let j = new int(new int(0));
/** @type {int} */
let ii = new int(i);
while (+new bool( new bool(j.valueOf() < p.len.valueOf()).valueOf() && new bool(new u8(s.str.charCodeAt(ii)).valueOf() == new u8(p.str.charCodeAt(j)).valueOf()).valueOf())) {
try {
j.val ++;
ii.val ++;
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
if ((new bool(j.valueOf() == p.len.valueOf())).valueOf()) {
return i;
}
i.val ++;
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return new int(-1);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {Array_string}
*/
function string_split_into_lines(s) {
try {
/** @type {Array_string} */
let res = new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)}));
if ((new bool(s.len.valueOf() == new int(0).valueOf())).valueOf()) {
return res;
}
res.arr.arr = s.str.split(/\r?\n|\r/)
if (res.arr.arr[res.arr.arr.length-1] == "") res.arr.arr.pop();
res.arr.len = new int(res.arr.arr.length);
res.arr.cap = new int(res.arr.arr.length);
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} rep
* @param {string} with_
* @returns {string}
*/
function string_replace_once(s, rep, with_) {
try {
/** @type {string} */
const s2 = new string(new string(""));
s2.val = s.str.replace(rep.str,with_.str)
return s2;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function string_title(s) {
try {
/** @type {Array_string} */
const words = string_split(s,new string(" "));
/** @type {Array_string} */
let tit = new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)}));
for (const word of words) {
try {
array_push(tit,string_capitalize(word,),false);
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {string} */
const title = new string(Array_string_join(tit,new string(" ")));
return title;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} chars
* @returns {int}
*/
function string_index_any(s, chars) {
try {
for (const [i, ss] of Array.from(s.str.split('').entries(), ([i, ss]) => [i, new u8(ss)])) {
try {
for (const c of chars.str.split('').map(c => new u8(c))) {
try {
if ((new bool(c.valueOf() == ss.valueOf())).valueOf()) {
return i;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return new int(-1);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} max
* @returns {string}
*/
function string_limit(s, max) {
try {
/** @type {Array_rune} */
const u = string_runes(s,);
if ((new bool(u.len.valueOf() <= max.valueOf())).valueOf()) {
return string_clone(s,);
}
return Array_rune_string(array_slice(u,new int(0), max),);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {bool}
*/
function string_is_title(s) {
try {
/** @type {Array_string} */
const words = string_split(s,new string(" "));
for (const word of words) {
try {
if ((!string_is_capital(word,).val ).valueOf()) {
return new bool(false);
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return new bool(true);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [direct_array_access] */
/**
* @function
* @returns {bool}
*/
function string_is_capital(s) {
try {
if ((new bool( new bool(s.len.valueOf() == new int(0).valueOf()).valueOf() || !(new bool( new bool(new u8(s.str.charCodeAt(new int(0))).valueOf() >= new u8('A').valueOf()).valueOf() && new bool(new u8(s.str.charCodeAt(new int(0))).valueOf() <= new u8('Z').valueOf()).valueOf())).val .valueOf())).valueOf()) {
return new bool(false);
}
for (let i = new int(1); i < s.len; i = new int(i + 1)) {
try {
if ((new bool( new bool(new u8(s.str.charCodeAt(i)).valueOf() >= new u8('A').valueOf()).valueOf() && new bool(new u8(s.str.charCodeAt(i)).valueOf() <= new u8('Z').valueOf()).valueOf())).valueOf()) {
return new bool(false);
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return new bool(true);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [direct_array_access] */
/**
* @function
* @returns {bool}
*/
function string_starts_with_capital(s) {
try {
if ((new bool( new bool(s.len.valueOf() == new int(0).valueOf()).valueOf() || !u8_is_capital(new u8(s.str.charCodeAt(new int(0))),).val .valueOf())).valueOf()) {
return new bool(false);
}
return new bool(true);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {bool}
*/
function string_is_upper(s) {
try {
/** @type {bool} */
const res = new bool(new bool(false));
res.val = s.str == s.str.toUpperCase() && s.str != s.str.toLowerCase()
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {bool}
*/
function string_is_lower(s) {
try {
/** @type {bool} */
const res = new bool(new bool(false));
res.val = s.str == s.str.toLowerCase() && s.str != s.str.toUpperCase()
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function string_reverse(s) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str = [...s.str].reverse().join('')
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} cutset
* @returns {string}
*/
function string_trim(s, cutset) {
try {
if ((new bool( new bool(s.valueOf() == new string("").valueOf()).valueOf() || new bool(cutset.valueOf() == new string("").valueOf()).valueOf())).valueOf()) {
return string_clone(s,);
}
/** @type {int} */
let pos_left = new int(new int(0));
/** @type {int} */
let pos_right = new int(new int( s.len.valueOf() - new int(1).valueOf()));
/** @type {bool} */
let cs_match = new bool(new bool(true));
while (+new bool( new bool( new bool(pos_left.valueOf() <= s.len.valueOf()).valueOf() && new bool(pos_right.valueOf() >= new int(-1).valueOf()).valueOf()).valueOf() && cs_match.valueOf())) {
try {
/** @type {bool} */
cs_match = new bool(new bool(false));
for (const cs of cutset.str.split('').map(c => new u8(c))) {
try {
if ((new bool(new u8(s.str.charCodeAt(pos_left)).valueOf() == cs.valueOf())).valueOf()) {
pos_left.val ++;
/** @type {bool} */
cs_match = new bool(new bool(true));
break;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
for (const cs of cutset.str.split('').map(c => new u8(c))) {
try {
if ((new bool(new u8(s.str.charCodeAt(pos_right)).valueOf() == cs.valueOf())).valueOf()) {
pos_right.val --;
/** @type {bool} */
cs_match = new bool(new bool(true));
break;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
if ((new bool(pos_left.valueOf() > pos_right.valueOf())).valueOf()) {
return new string("");
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return string_substr(s,pos_left, new int( pos_right.valueOf() + new int(1).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} sep
* @returns {string}
*/
function Array_string_join(s, sep) {
try {
/** @type {string} */
let res = new string(new string(""));
for (const [i, str] of s.entries()) {
try {
/** @type {string} */
res.str = res + new string(str);
if ((new bool(i.valueOf() != new int( s.len.valueOf() - new int(1).valueOf()).valueOf())).valueOf()) {
/** @type {string} */
res.str = res + new string(sep);
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
Object.defineProperty(string.prototype,"len", { get: function() {return new int(new TextEncoder().encode(this.str).length);}, set: function(l) {/* ignore */ } });
/**
* @function
* @param {string} search
* @returns {int}
*/
function string_index(s, search) {
try {
/** @type {int} */
const res = new int(new int(0));
res.val = s.str.indexOf(search)
if ((new bool(res.valueOf() == new int(-1).valueOf())).valueOf()) {
return new Option({ state: new u8(2),err: none__});
}
const _tmp33 = new _option({});
_tmp33.state = new u8(0);_tmp33.data = res
return _tmp33;} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {int}
*/
function string_utf32_code(_rune) {
try {
/** @type {int} */
const res = new int(new int(0));
res.val = s.str.charCodeAt()
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {String} jsstr
* @returns {string}
*/
function tos(jsstr) {
try {
/** @type {string} */
const res = new string(new string(""));
res.str = jsstr
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} a
* @returns {int}
*/
function string_compare(s, a) {
try {
/** @type {int} */
const min_len = new int(((new bool(s.len.valueOf() < a.len.valueOf())).valueOf() ? s.len : a.len));
for (let i = new int(0); i < min_len; i = new int(i + 1)) {
try {
if ((new bool(new u8(s.str.charCodeAt(i)).valueOf() < new u8(a.str.charCodeAt(i)).valueOf())).valueOf()) {
return new int(-1);
}
if ((new bool(new u8(s.str.charCodeAt(i)).valueOf() > new u8(a.str.charCodeAt(i)).valueOf())).valueOf()) {
return new int(1);
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
if ((new bool(s.len.valueOf() < a.len.valueOf())).valueOf()) {
return new int(-1);
}
if ((new bool(s.len.valueOf() > a.len.valueOf())).valueOf()) {
return new int(1);
}
return new int(0);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace builtin */
/**
* @function
* @param {string} s
* @returns {int}
*/
function utf8_str_visible_length(s) {
try {
/** @type {int} */
const res = new int(new int(0));
res.val = s.str.length;
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} s
* @returns {int}
*/
function utf8_str_len(s) {
try {
return s.len;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u8} b
* @returns {int}
*/
function utf8_char_len(b) {
try {
return new int_literal( (new int_literal( (new u8( new int(0xe5000000).valueOf() >> (new u8( (new u8( b.valueOf() >> new int(3).valueOf())).valueOf() & new int(0x1e).valueOf())).valueOf())).valueOf() & new int(3).valueOf())).valueOf() + new int(1).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace time */
/**
* @function
* @param {int} year
* @param {int} month
* @param {int} day
* @returns {int}
*/
function time__days_from_unix_epoch(year, month, day) {
try {
/** @type {int} */
const y = new int(((new bool(month.valueOf() <= new int(2).valueOf())).valueOf() ? new int( year.valueOf() - new int(1).valueOf()) : year));
/** @type {int} */
const era = new int(new int( y.valueOf() / new int(400).valueOf()));
/** @type {int} */
const year_of_the_era = new int(new int( y.valueOf() - new int( era.valueOf() * new int(400).valueOf()).valueOf()));
/** @type {int} */
const day_of_year = new int(new int( new int( new int( (new int( new int( new int(153).valueOf() * (new int( month.valueOf() + (((new bool(month.valueOf() > new int(2).valueOf())).valueOf() ? new int(-3) : new int(9))).valueOf())).valueOf()).valueOf() + new int(2).valueOf())).valueOf() / new int(5).valueOf()).valueOf() + day.valueOf()).valueOf() - new int(1).valueOf()));
/** @type {int} */
const day_of_the_era = new int(new int( new int( new int( new int( year_of_the_era.valueOf() * new int(365).valueOf()).valueOf() + new int( year_of_the_era.valueOf() / new int(4).valueOf()).valueOf()).valueOf() - new int( year_of_the_era.valueOf() / new int(100).valueOf()).valueOf()).valueOf() + day_of_year.valueOf()));
return new int( new int( new int( era.valueOf() * new int(146097).valueOf()).valueOf() + day_of_the_era.valueOf()).valueOf() - new int(719468).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {int}
*/
function time__Time_days_from_unix_epoch(t) {
try {
return time__days_from_unix_epoch(t.year, t.month, t.day);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} days
* @returns {time__Time}
*/
function time__date_from_days_after_unix_epoch(days) {
try {
let [year, month, day] = time__calculate_date_from_day_offset(new i64(days));
return (function() {
let _tmp34 = new time__Time({});
_tmp34.year = year;
_tmp34.month = month;
_tmp34.day = day;
return _tmp34;
})()
;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace time */
/**
* @constructor
* @param {{datetime?: string, format?: string, current_pos_datetime?: int}} init
*/
function time__DateTimeParser({ datetime = new string(""), format = new string(""), current_pos_datetime = new int(0) }) {
this.datetime = datetime
this.format = format
this.current_pos_datetime = current_pos_datetime
};
time__DateTimeParser.prototype = {
toString() {
return `time__DateTimeParser { datetime: "${this["datetime"].toString()}", format: "${this["format"].toString()}", current_pos_datetime: ${this["current_pos_datetime"].toString()} }`
},
/** @type {string} */
datetime: new string(""),
/** @type {string} */
format: new string(""),
/** @type {int} */
current_pos_datetime: new int(0),
$toJS() { return this; }
};
/**
* @function
* @param {string} datetime
* @param {string} format
* @returns {time__DateTimeParser}
*/
function time__new_date_time_parser(datetime, format) {
try {
return (function() {
let _tmp35 = new time__DateTimeParser({});
_tmp35.datetime = datetime;
_tmp35.format = format;
return _tmp35;
})()
;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} length
* @returns {string}
*/
function time__DateTimeParser_next(p, length) {
p = new $ref(p)
try {
if ((new bool(new int( p.val.current_pos_datetime.valueOf() + length.valueOf()).valueOf() > p.val.datetime.len.valueOf())).valueOf()) {
return error(new string("end of string"));
}
/** @type {string} */
const val = new string(string_slice(p.val.datetime,p.val.current_pos_datetime, new int( p.val.current_pos_datetime.valueOf() + length.valueOf())));
/** @type {int} */
p.val.current_pos_datetime.val = Math.floor(p.val.current_pos_datetime + new int(length));
return val;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} length
* @returns {string}
*/
function time__DateTimeParser_peek(p, length) {
p = new $ref(p)
try {
if ((new bool(new int( p.val.current_pos_datetime.valueOf() + length.valueOf()).valueOf() > p.val.datetime.len.valueOf())).valueOf()) {
return error(new string("end of string"));
}
return string_slice(p.val.datetime,p.val.current_pos_datetime, new int( p.val.current_pos_datetime.valueOf() + length.valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} length
* @returns {int}
*/
function time__DateTimeParser_must_be_int(p, length) {
p = new $ref(p)
try {
/** @type {string} */
const val = new string(time__DateTimeParser_next(p.valueOf(),length));
if ((!string_contains_only(val,new string("0123456789")).val ).valueOf()) {
return error(new string(`expected int, found: ${val}`));
}
return string_int(val,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} min
* @param {int} max
* @param {bool} allow_leading_zero
* @returns {int}
*/
function time__DateTimeParser_must_be_int_with_minimum_length(p, min, max, allow_leading_zero) {
p = new $ref(p)
try {
/** @type {int} */
let length = new int(new int( new int( max.valueOf() + new int(1).valueOf()).valueOf() - min.valueOf()));
/** @type {string} */
let val = new string(new string(""));
for (let _tmp36 = new int(0); _tmp36 < length; _tmp36 = new int(_tmp36 + 1)) {
try {
/** @type {string} */
const tok = new string(time__DateTimeParser_peek(p.valueOf(),new int(1)));
if ((!string_contains_only(tok,new string("0123456789")).val ).valueOf()) {
break;
}
time__DateTimeParser_next(p.valueOf(),new int(1));
/** @type {string} */
val.str = val + new string(tok);
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
if ((new bool(val.len.valueOf() < min.valueOf())).valueOf()) {
return error(new string(`expected int with a minimum length of ${int_str(min)}, found: ${int_str(val.len)}`));
}
if ((new bool( !allow_leading_zero.val .valueOf() && string_starts_with(val,new string("0")).valueOf())).valueOf()) {
return error(new string("0 is not allowed for this format"));
}
return string_int(val,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} must
* @returns {void}
*/
function time__DateTimeParser_must_be_string(p, must) {
p = new $ref(p)
try {
/** @type {string} */
const val = new string(time__DateTimeParser_next(p.valueOf(),must.len));
if ((new bool(val.valueOf() != must.valueOf())).valueOf()) {
return error(new string(`invalid string: "${val}"!="${must}" at: ${int_str(p.val.current_pos_datetime)}`));
}
return;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_string} oneof
* @returns {string}
*/
function time__DateTimeParser_must_be_string_one_of(p, oneof) {
p = new $ref(p)
try {
for (const must of oneof) {
try {
/** @type {string} */
const val = new string(time__DateTimeParser_peek(p.valueOf(),must.len));
if ((new bool(val.valueOf() == must.valueOf())).valueOf()) {
return must;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return error(new string(`invalid string: must be one of ${Array_string_str(oneof)}, at: ${int_str(p.val.current_pos_datetime)}`));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {int}
*/
function time__DateTimeParser_must_be_valid_month(p) {
p = new $ref(p)
try {
for (const v of time__long_months) {
try {
if ((new bool(new int( p.val.current_pos_datetime.valueOf() + v.len.valueOf()).valueOf() < p.val.datetime.len.valueOf())).valueOf()) {
/** @type {string} */
const month_name = new string(string_slice(p.val.datetime,p.val.current_pos_datetime, new int( p.val.current_pos_datetime.valueOf() + v.len.valueOf())));
if ((new bool(v.valueOf() == month_name.valueOf())).valueOf()) {
/** @type {int} */
p.val.current_pos_datetime.val = Math.floor(p.val.current_pos_datetime + new int(v.len));
return new int( Array_string_index(time__long_months,month_name).valueOf() + new int(1).valueOf());
}
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return time__error_invalid_time(new int(0), new string(`invalid month name, at: ${int_str(p.val.current_pos_datetime)}`));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {int}
*/
function time__DateTimeParser_must_be_valid_three_letter_month(p) {
p = new $ref(p)
try {
if ((new bool(new int( p.val.current_pos_datetime.valueOf() + new int(3).valueOf()).valueOf() < p.val.datetime.len.valueOf())).valueOf()) {
/** @type {string} */
const letters = new string(string_slice(p.val.datetime,p.val.current_pos_datetime, new int( p.val.current_pos_datetime.valueOf() + new int(3).valueOf())));
for (let m = new int(new int(1)); +new bool(m.valueOf() <= time__long_months.len.valueOf()); m.val ++) {
try {
if ((new bool(string_slice(time__months_string,new int( (new int( m.valueOf() - new int(1).valueOf())).valueOf() * new int(3).valueOf()), new int( m.valueOf() * new int(3).valueOf())).valueOf() == letters.valueOf())).valueOf()) {
p.val.current_pos_datetime.val = Math.floor(p.val.current_pos_datetime + new int(new int(3))); return m;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
}
return time__error_invalid_time(new int(0), new string(`invalid three letter month, at: ${int_str(p.val.current_pos_datetime)}`));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} letters
* @returns {string}
*/
function time__DateTimeParser_must_be_valid_week_day(p, letters) {
p = new $ref(p)
try {
/** @type {string} */
const val = new string(time__DateTimeParser_next(p.valueOf(),letters));
return time__error_invalid_time(new int(0), new string(`invalid month name, at: ${int_str(p.val.current_pos_datetime)}`));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} s
* @returns {Array_string}
*/
function time__extract_tokens(s) {
try {
/** @type {Array_string} */
let tokens = new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)}));
/** @type {string} */
let current = new string(new string(""));
for (const r of s.str.split('').map(c => new u8(c))) {
try {
if ((new bool( string_contains_only(current,u8_ascii_str(r,)).valueOf() || new bool(current.valueOf() == new string("").valueOf()).valueOf())).valueOf()) {
/** @type {string} */
current.str = current + new string(u8_ascii_str(r,));
} else {
array_push(tokens,current,false);
/** @type {string} */
current = new string(u8_ascii_str(r,));
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
if ((new bool(current.valueOf() != new string("").valueOf())).valueOf()) {
array_push(tokens,current,false);
}
return tokens;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {time__Time}
*/
function time__DateTimeParser_parse(p) {
p = new $ref(p)
try {
/** @type {int} */
let year_ = new int(new int(0));
/** @type {int} */
let month_ = new int(new int(0));
/** @type {int} */
let day_in_month = new int(new int(0));
/** @type {int} */
let hour_ = new int(new int(0));
/** @type {int} */
let minute_ = new int(new int(0));
/** @type {int} */
let second_ = new int(new int(0));
/** @type {Array_string} */
const tokens = time__extract_tokens(p.val.format);
for (const token of tokens) {
try {
if (token.str === new string("YYYY").str) {
/** @type {int} */
year_ = new int(time__DateTimeParser_must_be_int(p.valueOf(),new int(4)));
}
else if (token.str === new string("YY").str) {
/** @type {int} */
year_ = new int(new int( new int( new int( time__now().year.valueOf() / new int(100).valueOf()).valueOf() * new int(100).valueOf()).valueOf() + time__DateTimeParser_must_be_int(p.valueOf(),new int(2)).valueOf()));
}
else if (token.str === new string("M").str) {
/** @type {int} */
month_ = new int(time__DateTimeParser_must_be_int_with_minimum_length(p.valueOf(),new int(1), new int(2), new bool(false)));
if ((new bool( new bool(month_.valueOf() < new int(1).valueOf()).valueOf() || new bool(month_.valueOf() > new int(12).valueOf()).valueOf())).valueOf()) {
return time__error_invalid_time(new int(0), new string("month must be between 1 and 12"));
}
}
else if (token.str === new string("MM").str) {
/** @type {int} */
month_ = new int(time__DateTimeParser_must_be_int(p.valueOf(),new int(2)));
if ((new bool( new bool(month_.valueOf() < new int(1).valueOf()).valueOf() || new bool(month_.valueOf() > new int(12).valueOf()).valueOf())).valueOf()) {
return time__error_invalid_time(new int(0), new string("month must be between 01 and 12"));
}
}
else if (token.str === new string("MMM").str) {
/** @type {int} */
month_ = new int(time__DateTimeParser_must_be_valid_three_letter_month(p.valueOf(),));
}
else if (token.str === new string("MMMM").str) {
/** @type {int} */
month_ = new int(time__DateTimeParser_must_be_valid_month(p.valueOf(),));
}
else if (token.str === new string("D").str) {
/** @type {int} */
day_in_month = new int(time__DateTimeParser_must_be_int_with_minimum_length(p.valueOf(),new int(1), new int(2), new bool(false)));
if ((new bool( new bool(day_in_month.valueOf() < new int(1).valueOf()).valueOf() || new bool(day_in_month.valueOf() > new int(31).valueOf()).valueOf())).valueOf()) {
return time__error_invalid_time(new int(0), new string("day must be between 1 and 31"));
}
}
else if (token.str === new string("DD").str) {
/** @type {int} */
day_in_month = new int(time__DateTimeParser_must_be_int(p.valueOf(),new int(2)));
if ((new bool( new bool(day_in_month.valueOf() < new int(1).valueOf()).valueOf() || new bool(day_in_month.valueOf() > new int(31).valueOf()).valueOf())).valueOf()) {
return time__error_invalid_time(new int(0), new string("day must be between 01 and 31"));
}
}
else if (token.str === new string("H").str) {
/** @type {int} */
hour_ = new int(time__DateTimeParser_must_be_int_with_minimum_length(p.valueOf(),new int(1), new int(2), new bool(true)));
if ((new bool( new bool(hour_.valueOf() < new int(0).valueOf()).valueOf() || new bool(hour_.valueOf() > new int(23).valueOf()).valueOf())).valueOf()) {
return time__error_invalid_time(new int(0), new string("hour must be between 0 and 23"));
}
}
else if (token.str === new string("HH").str) {
/** @type {int} */
hour_ = new int(time__DateTimeParser_must_be_int(p.valueOf(),new int(2)));
if ((new bool( new bool(hour_.valueOf() < new int(0).valueOf()).valueOf() || new bool(hour_.valueOf() > new int(23).valueOf()).valueOf())).valueOf()) {
return time__error_invalid_time(new int(0), new string("hour must be between 00 and 23"));
}
}
else if (token.str === new string("h").str) {
/** @type {int} */
hour_ = new int(time__DateTimeParser_must_be_int_with_minimum_length(p.valueOf(),new int(1), new int(2), new bool(true)));
if ((new bool( new bool(hour_.valueOf() < new int(0).valueOf()).valueOf() || new bool(hour_.valueOf() > new int(23).valueOf()).valueOf())).valueOf()) {
return time__error_invalid_time(new int(0), new string("hour must be between 0 and 23"));
}
}
else if (token.str === new string("hh").str) {
/** @type {int} */
hour_ = new int(time__DateTimeParser_must_be_int(p.valueOf(),new int(2)));
if ((new bool( new bool(hour_.valueOf() < new int(0).valueOf()).valueOf() || new bool(hour_.valueOf() > new int(23).valueOf()).valueOf())).valueOf()) {
return time__error_invalid_time(new int(0), new string("hour must be between 00 and 23"));
}
}
else if (token.str === new string("k").str) {
/** @type {int} */
hour_ = new int(time__DateTimeParser_must_be_int(p.valueOf(),new int(1)));
if ((new bool( new bool(hour_.valueOf() < new int(0).valueOf()).valueOf() || new bool(hour_.valueOf() > new int(23).valueOf()).valueOf())).valueOf()) {
return time__error_invalid_time(new int(0), new string("hour must be between 0 and 23"));
}
}
else if (token.str === new string("kk").str) {
/** @type {int} */
hour_ = new int(time__DateTimeParser_must_be_int(p.valueOf(),new int(2)));
if ((new bool( new bool(hour_.valueOf() < new int(0).valueOf()).valueOf() || new bool(hour_.valueOf() > new int(23).valueOf()).valueOf())).valueOf()) {
return time__error_invalid_time(new int(0), new string("hour must be between 00 and 23"));
}
}
else if (token.str === new string("m").str) {
/** @type {int} */
minute_ = new int(time__DateTimeParser_must_be_int(p.valueOf(),new int(1)));
if ((new bool( new bool(minute_.valueOf() < new int(0).valueOf()).valueOf() || new bool(minute_.valueOf() > new int(59).valueOf()).valueOf())).valueOf()) {
return time__error_invalid_time(new int(0), new string("minute must be between 0 and 59"));
}
}
else if (token.str === new string("mm").str) {
/** @type {int} */
minute_ = new int(time__DateTimeParser_must_be_int(p.valueOf(),new int(2)));
if ((new bool( new bool(minute_.valueOf() < new int(0).valueOf()).valueOf() || new bool(minute_.valueOf() > new int(59).valueOf()).valueOf())).valueOf()) {
return time__error_invalid_time(new int(0), new string("minute must be between 00 and 59"));
}
}
else if (token.str === new string("s").str) {
/** @type {int} */
second_ = new int(time__DateTimeParser_must_be_int(p.valueOf(),new int(1)));
if ((new bool( new bool(second_.valueOf() < new int(0).valueOf()).valueOf() || new bool(second_.valueOf() > new int(59).valueOf()).valueOf())).valueOf()) {
return time__error_invalid_time(new int(0), new string("second must be between 0 and 59"));
}
}
else if (token.str === new string("ss").str) {
/** @type {int} */
second_ = new int(time__DateTimeParser_must_be_int(p.valueOf(),new int(2)));
if ((new bool( new bool(second_.valueOf() < new int(0).valueOf()).valueOf() || new bool(second_.valueOf() > new int(59).valueOf()).valueOf())).valueOf()) {
return time__error_invalid_time(new int(0), new string("second must be between 00 and 59"));
}
}
else {
time__DateTimeParser_must_be_string(p.valueOf(),token);
};
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
if ((new bool(month_.valueOf() == new int(2).valueOf())).valueOf()) {
/** @type {int} */
const feb_days_in_year = new int(((time__is_leap_year(year_)).valueOf() ? new int(29) : new int(28)));
if ((new bool(day_in_month.valueOf() > feb_days_in_year.valueOf())).valueOf()) {
return time__error_invalid_time(new int(0), new string("February has only 28 days in the given year"));
}
} else if ((new bool( new bool(day_in_month.valueOf() == new int(31).valueOf()).valueOf() && !(Array_int_contains(new array(new array_buffer({arr: [new int(new int(1)), new int(new int(3)), new int(new int(5)), new int(new int(7)), new int(new int(8)), new int(new int(10)), new int(new int(12))], len: new int(7), cap: new int(7)})),month_).valueOf()).valueOf())).valueOf()) {
/** @type {string} */
const month_name = new string(time__Time_custom_format((function() {
let _tmp37 = new time__Time({});
_tmp37.month = month_;
return _tmp37;
})()
,new string("MMMM")));
return time__error_invalid_time(new int(0), new string(`${month_name} has only 30 days`));
}
return time__new((function() {
let _tmp38 = new time__Time({});
_tmp38.year = year_;
_tmp38.month = month_;
_tmp38.day = day_in_month;
_tmp38.hour = hour_;
_tmp38.minute = minute_;
_tmp38.second = second_;
return _tmp38;
})()
);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace time */
function time__Duration(val) { return val; }
/** @constant {time__Duration} */
let time__nanosecond = undefined;
/** @constant {time__Duration} */
let time__microsecond = undefined;
/** @constant {time__Duration} */
let time__millisecond = undefined;
/** @constant {time__Duration} */
let time__second = undefined;
/** @constant {time__Duration} */
let time__minute = undefined;
/** @constant {time__Duration} */
let time__hour = undefined;
/** @constant {time__Duration} */
let time__infinite = undefined;
/**
* @function
* @returns {i64}
*/
function time__Duration_nanoseconds(d) {
try {
return new i64(d);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {i64}
*/
function time__Duration_microseconds(d) {
try {
return new i64( BigInt(new i64(d).valueOf()) / BigInt(time__microsecond.valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {i64}
*/
function time__Duration_milliseconds(d) {
try {
return new i64( BigInt(new i64(d).valueOf()) / BigInt(time__millisecond.valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {f64}
*/
function time__Duration_seconds(d) {
try {
return new f64( new f64(d).valueOf() / new f64(time__second).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {f64}
*/
function time__Duration_minutes(d) {
try {
return new f64( new f64(d).valueOf() / new f64(time__minute).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {f64}
*/
function time__Duration_hours(d) {
try {
return new f64( new f64(d).valueOf() / new f64(time__hour).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {f64}
*/
function time__Duration_days(d) {
try {
return new f64( new f64(d).valueOf() / new f64(new i64( BigInt(time__hour.valueOf()) * BigInt(new int(24).valueOf()))).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function time__Duration_str(d) {
try {
if ((new bool(time__Duration_alias_eq(d, time__infinite))).valueOf()) {
return new string("inf");
}
/** @type {string} */
let sign = new string(new string(""));
/** @type {i64} */
let t = new i64(new i64(d));
if ((new bool(t.valueOf() < new int(0).valueOf())).valueOf()) {
/** @type {string} */
sign = new string(new string("-"));
/** @type {i64} */
t = new i64(-t.val );
}
/** @type {i64} */
const hr = new i64(new i64( BigInt(t.valueOf()) / BigInt(time__hour.valueOf())));
/** @type {i64} */
t.val = t - new i64(new i64( BigInt(hr.valueOf()) * BigInt(time__hour.valueOf())));
/** @type {i64} */
const min = new i64(new i64( BigInt(t.valueOf()) / BigInt(time__minute.valueOf())));
/** @type {i64} */
t.val = t - new i64(new i64( BigInt(min.valueOf()) * BigInt(time__minute.valueOf())));
/** @type {i64} */
const sec = new i64(new i64( BigInt(t.valueOf()) / BigInt(time__second.valueOf())));
/** @type {i64} */
t.val = t - new i64(new i64( BigInt(sec.valueOf()) * BigInt(time__second.valueOf())));
/** @type {i64} */
const ms = new i64(new i64( BigInt(t.valueOf()) / BigInt(time__millisecond.valueOf())));
/** @type {i64} */
t.val = t - new i64(new i64( BigInt(ms.valueOf()) * BigInt(time__millisecond.valueOf())));
/** @type {i64} */
const us = new i64(new i64( BigInt(t.valueOf()) / BigInt(time__microsecond.valueOf())));
/** @type {i64} */
t.val = t - new i64(new i64( BigInt(us.valueOf()) * BigInt(time__microsecond.valueOf())));
/** @type {i64} */
const ns = new i64(t);
return ((vEq(new bool(true),new bool(hr.valueOf() > new int(0).valueOf())))? (new string(`${sign}${i64_str(hr)}:${i64_str(min)}:${i64_str(sec)}`)) : (vEq(new bool(true),new bool(min.valueOf() > new int(0).valueOf())))? (new string(`${sign}${i64_str(min)}:${i64_str(sec)}.${i64_str(ms)}`)) : (vEq(new bool(true),new bool(sec.valueOf() > new int(0).valueOf())))? (new string(`${sign}${i64_str(sec)}.${i64_str(ms)}s`)) : (vEq(new bool(true),new bool(ms.valueOf() > new int(0).valueOf())))? (new string(`${sign}${i64_str(ms)}.${i64_str(us)}ms`)) : (vEq(new bool(true),new bool(us.valueOf() > new int(0).valueOf())))? (new string(`${sign}${i64_str(us)}.${i64_str(ns)}us`)) : (new string(`${sign}${i64_str(ns)}ns`)));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function time__Duration_debug(d) {
try {
/** @type {Array_string} */
let res = new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)}));
/** @type {i64} */
let x = new i64(new i64(d));
/** @type {string} */
let sign = new string(new string(""));
if ((new bool(x.valueOf() < new int(0).valueOf())).valueOf()) {
/** @type {string} */
sign = new string(new string("- "));
/** @type {i64} */
x = new i64(-x.val );
}
let _tmp39 = new map(
{
[new string("days").$toJS()]: new int_literal( BigInt(new int(24).valueOf()) * BigInt(time__hour.valueOf())),
[new string("h").$toJS()]: time__hour,
[new string("m").$toJS()]: time__minute,
[new string("s").$toJS()]: time__second,
[new string("ms").$toJS()]: time__millisecond,
[new string("us").$toJS()]: time__microsecond
});
for (var _tmp40 in _tmp39.map) {
let v = _tmp39.map[_tmp40];
let label = _tmp40;
try {
if ((new bool(x.valueOf() > v.valueOf())).valueOf()) {
/** @type {i64} */
const xx = new i64(new i64( BigInt(x.valueOf()) / BigInt(v.valueOf())));
/** @type {i64} */
x = new i64(new i64( BigInt(x.valueOf()) % BigInt(v.valueOf())));
array_push(res,new string( i64_str(xx).valueOf() + label.valueOf()),false);
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
if ((new bool(x.valueOf() > new int(0).valueOf())).valueOf()) {
array_push(res,new string(`${i64_str(x)}ns`),false);
}
return new string(`Duration: ${sign}${Array_string_join(res,new string(", "))}`);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace time */
/* [direct_array_access] */
/**
* @function
* @param {int} value
* @param {Array_u8} arr
* @param {int} size
* @returns {void}
*/
function time__int_to_byte_array_no_pad(value, arr, size) {
arr = new $ref(arr)
try {
/** @type {int} */
let num = new int(value);
if ((new bool( new bool(size.valueOf() <= new int(0).valueOf()).valueOf() || new bool(num.valueOf() < new int(0).valueOf()).valueOf())).valueOf()) {
return;
}
/** @type {int} */
let i = new int(new int( size.valueOf() - new int(1).valueOf()));
while (+new bool( new bool(num.valueOf() > new int(0).valueOf()).valueOf() && new bool(i.valueOf() >= new int(0).valueOf()).valueOf())) {
try {
/** @type {u8} */
arr.valueOf().arr.set(new int(i.valueOf()),new u8(new int( (new int( num.valueOf() % new int(10).valueOf())).valueOf() + new u8('0').valueOf())));
/** @type {int} */
num.val = Math.floor(num / new int(new int(10)));
i.val --;
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [manualfree] */
/**
* @function
* @returns {string}
*/
function time__Time_format(t) {
try {
/** @type {Array_u8} */
let buf = new array(new array_buffer({arr: [new u8(new u8(new u8('0'))), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('-')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('-')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8(' ')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8(':')), new u8(new u8('0')), new u8(new u8('0'))], len: new int(16), cap: new int(16)}));
time__int_to_byte_array_no_pad(t.year, buf, new int(4));
time__int_to_byte_array_no_pad(t.month, buf, new int(7));
time__int_to_byte_array_no_pad(t.day, buf, new int(10));
time__int_to_byte_array_no_pad(t.hour, buf, new int(13));
time__int_to_byte_array_no_pad(t.minute, buf, new int(16));
(function defer() {
array_free(buf,);
})();
return array_bytestr(buf,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [manualfree] */
/**
* @function
* @returns {string}
*/
function time__Time_format_ss(t) {
try {
/** @type {Array_u8} */
let buf = new array(new array_buffer({arr: [new u8(new u8(new u8('0'))), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('-')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('-')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8(' ')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8(':')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8(':')), new u8(new u8('0')), new u8(new u8('0'))], len: new int(19), cap: new int(19)}));
time__int_to_byte_array_no_pad(t.year, buf, new int(4));
time__int_to_byte_array_no_pad(t.month, buf, new int(7));
time__int_to_byte_array_no_pad(t.day, buf, new int(10));
time__int_to_byte_array_no_pad(t.hour, buf, new int(13));
time__int_to_byte_array_no_pad(t.minute, buf, new int(16));
time__int_to_byte_array_no_pad(t.second, buf, new int(19));
(function defer() {
array_free(buf,);
})();
return array_bytestr(buf,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [manualfree] */
/**
* @function
* @returns {string}
*/
function time__Time_format_ss_milli(t) {
try {
/** @type {Array_u8} */
let buf = new array(new array_buffer({arr: [new u8(new u8(new u8('0'))), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('-')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('-')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8(' ')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8(':')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8(':')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('.')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0'))], len: new int(23), cap: new int(23)}));
time__int_to_byte_array_no_pad(t.year, buf, new int(4));
time__int_to_byte_array_no_pad(t.month, buf, new int(7));
time__int_to_byte_array_no_pad(t.day, buf, new int(10));
time__int_to_byte_array_no_pad(t.hour, buf, new int(13));
time__int_to_byte_array_no_pad(t.minute, buf, new int(16));
time__int_to_byte_array_no_pad(t.second, buf, new int(19));
/** @type {int} */
const millis = new int(new int( t.nanosecond.valueOf() / new int(1000000).valueOf()));
time__int_to_byte_array_no_pad(millis, buf, new int(23));
(function defer() {
array_free(buf,);
})();
return array_bytestr(buf,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [manualfree] */
/**
* @function
* @returns {string}
*/
function time__Time_format_ss_micro(t) {
try {
/** @type {Array_u8} */
let buf = new array(new array_buffer({arr: [new u8(new u8(new u8('0'))), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('-')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('-')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8(' ')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8(':')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8(':')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('.')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0'))], len: new int(26), cap: new int(26)}));
time__int_to_byte_array_no_pad(t.year, buf, new int(4));
time__int_to_byte_array_no_pad(t.month, buf, new int(7));
time__int_to_byte_array_no_pad(t.day, buf, new int(10));
time__int_to_byte_array_no_pad(t.hour, buf, new int(13));
time__int_to_byte_array_no_pad(t.minute, buf, new int(16));
time__int_to_byte_array_no_pad(t.second, buf, new int(19));
/** @type {int} */
const micros = new int(new int( t.nanosecond.valueOf() / new int(1000).valueOf()));
time__int_to_byte_array_no_pad(micros, buf, new int(26));
(function defer() {
array_free(buf,);
})();
return array_bytestr(buf,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [manualfree] */
/**
* @function
* @returns {string}
*/
function time__Time_format_ss_nano(t) {
try {
/** @type {Array_u8} */
let buf = new array(new array_buffer({arr: [new u8(new u8(new u8('0'))), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('-')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('-')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8(' ')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8(':')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8(':')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('.')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0'))], len: new int(29), cap: new int(29)}));
time__int_to_byte_array_no_pad(t.year, buf, new int(4));
time__int_to_byte_array_no_pad(t.month, buf, new int(7));
time__int_to_byte_array_no_pad(t.day, buf, new int(10));
time__int_to_byte_array_no_pad(t.hour, buf, new int(13));
time__int_to_byte_array_no_pad(t.minute, buf, new int(16));
time__int_to_byte_array_no_pad(t.second, buf, new int(19));
time__int_to_byte_array_no_pad(t.nanosecond, buf, new int(29));
(function defer() {
array_free(buf,);
})();
return array_bytestr(buf,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [manualfree] */
/* [markused] */
/**
* @function
* @returns {string}
*/
function time__Time_format_rfc3339(t) {
try {
/** @type {Array_u8} */
let buf = new array(new array_buffer({arr: [new u8(new u8(new u8('0'))), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('-')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('-')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('T')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8(':')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8(':')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('.')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('Z'))], len: new int(24), cap: new int(24)}));
/** @type {time__Time} */
const t_ = time__time_with_unix(t);
if ((t_.is_local).valueOf()) {
/** @type {time__Time} */
const utc_time = time__Time_local_to_utc(t_,);
time__int_to_byte_array_no_pad(utc_time.year, buf, new int(4));
time__int_to_byte_array_no_pad(utc_time.month, buf, new int(7));
time__int_to_byte_array_no_pad(utc_time.day, buf, new int(10));
time__int_to_byte_array_no_pad(utc_time.hour, buf, new int(13));
time__int_to_byte_array_no_pad(utc_time.minute, buf, new int(16));
time__int_to_byte_array_no_pad(utc_time.second, buf, new int(19));
time__int_to_byte_array_no_pad(new int( utc_time.nanosecond.valueOf() / new int(1000000).valueOf()), buf, new int(23));
} else {
time__int_to_byte_array_no_pad(t_.year, buf, new int(4));
time__int_to_byte_array_no_pad(t_.month, buf, new int(7));
time__int_to_byte_array_no_pad(t_.day, buf, new int(10));
time__int_to_byte_array_no_pad(t_.hour, buf, new int(13));
time__int_to_byte_array_no_pad(t_.minute, buf, new int(16));
time__int_to_byte_array_no_pad(t_.second, buf, new int(19));
time__int_to_byte_array_no_pad(new int( t_.nanosecond.valueOf() / new int(1000000).valueOf()), buf, new int(23));
}
(function defer() {
array_free(buf,);
})();
return array_bytestr(buf,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [manualfree] */
/**
* @function
* @returns {string}
*/
function time__Time_format_rfc3339_nano(t) {
try {
/** @type {Array_u8} */
let buf = new array(new array_buffer({arr: [new u8(new u8(new u8('0'))), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('-')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('-')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('T')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8(':')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8(':')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('.')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8('Z'))], len: new int(30), cap: new int(30)}));
/** @type {time__Time} */
const t_ = time__time_with_unix(t);
if ((t_.is_local).valueOf()) {
/** @type {time__Time} */
const utc_time = time__Time_local_to_utc(t_,);
time__int_to_byte_array_no_pad(utc_time.year, buf, new int(4));
time__int_to_byte_array_no_pad(utc_time.month, buf, new int(7));
time__int_to_byte_array_no_pad(utc_time.day, buf, new int(10));
time__int_to_byte_array_no_pad(utc_time.hour, buf, new int(13));
time__int_to_byte_array_no_pad(utc_time.minute, buf, new int(16));
time__int_to_byte_array_no_pad(utc_time.second, buf, new int(19));
time__int_to_byte_array_no_pad(utc_time.nanosecond, buf, new int(29));
} else {
time__int_to_byte_array_no_pad(t_.year, buf, new int(4));
time__int_to_byte_array_no_pad(t_.month, buf, new int(7));
time__int_to_byte_array_no_pad(t_.day, buf, new int(10));
time__int_to_byte_array_no_pad(t_.hour, buf, new int(13));
time__int_to_byte_array_no_pad(t_.minute, buf, new int(16));
time__int_to_byte_array_no_pad(t_.second, buf, new int(19));
time__int_to_byte_array_no_pad(t_.nanosecond, buf, new int(29));
}
(function defer() {
array_free(buf,);
})();
return array_bytestr(buf,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [manualfree] */
/**
* @function
* @returns {string}
*/
function time__Time_hhmm(t) {
try {
/** @type {Array_u8} */
let buf = new array(new array_buffer({arr: [new u8(new u8(new u8('0'))), new u8(new u8('0')), new u8(new u8(':')), new u8(new u8('0')), new u8(new u8('0'))], len: new int(5), cap: new int(5)}));
time__int_to_byte_array_no_pad(t.hour, buf, new int(2));
time__int_to_byte_array_no_pad(t.minute, buf, new int(5));
(function defer() {
array_free(buf,);
})();
return array_bytestr(buf,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [manualfree] */
/**
* @function
* @returns {string}
*/
function time__Time_hhmmss(t) {
try {
/** @type {Array_u8} */
let buf = new array(new array_buffer({arr: [new u8(new u8(new u8('0'))), new u8(new u8('0')), new u8(new u8(':')), new u8(new u8('0')), new u8(new u8('0')), new u8(new u8(':')), new u8(new u8('0')), new u8(new u8('0'))], len: new int(8), cap: new int(8)}));
time__int_to_byte_array_no_pad(t.hour, buf, new int(2));
time__int_to_byte_array_no_pad(t.minute, buf, new int(5));
time__int_to_byte_array_no_pad(t.second, buf, new int(8));
(function defer() {
array_free(buf,);
})();
return array_bytestr(buf,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function time__Time_hhmm12(t) {
try {
return time__Time_get_fmt_time_str(t,time__FormatTime.hhmm12);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function time__Time_ymmdd(t) {
try {
return time__Time_get_fmt_date_str(t,time__FormatDelimiter.hyphen, time__FormatDate.yyyymmdd);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function time__Time_ddmmy(t) {
try {
return time__Time_get_fmt_date_str(t,time__FormatDelimiter.dot, time__FormatDate.ddmmyyyy);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function time__Time_md(t) {
try {
return time__Time_get_fmt_date_str(t,time__FormatDelimiter.space, time__FormatDate.mmmd);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} n
* @returns {string}
*/
function time__ordinal_suffix(n) {
try {
if ((new bool( new bool(n.valueOf() > new int(3).valueOf()).valueOf() && new bool(n.valueOf() < new int(21).valueOf()).valueOf())).valueOf()) {
return new string(`${int_str(n)}th`);
}
let _tmp41 = new int( n.valueOf() % new int(10).valueOf());
if (vEq(_tmp41,new int(1))) {
return new string(`${int_str(n)}st`);
}
else if (vEq(_tmp41,new int(2))) {
return new string(`${int_str(n)}nd`);
}
else if (vEq(_tmp41,new int(3))) {
return new string(`${int_str(n)}rd`);
}
else {
return new string(`${int_str(n)}th`);
};
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @constant {Array_string} */
let time__tokens_2 = undefined;
/** @constant {Array_string} */
let time__tokens_3 = undefined;
/** @constant {Array_string} */
let time__tokens_4 = undefined;
/**
* @function
* @param {string} s
* @returns {string}
*/
function time__Time_custom_format(t, s) {
try {
/** @type {Array_string} */
let tokens = new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)}));
for (let i = new int(new int(0)); +new bool(i.valueOf() < s.len.valueOf()); ) {
try {
for (let j = new int(new int(4)); +new bool(j.valueOf() > new int(0).valueOf()); j.val --) {
try {
if ((new bool(i.valueOf() > new int( s.len.valueOf() - j.valueOf()).valueOf())).valueOf()) {
continue;
}
if ((new bool( new bool( new bool( new bool(j.valueOf() == new int(1).valueOf()).valueOf() || (new bool( new bool(j.valueOf() == new int(2).valueOf()).valueOf() && (Array_string_contains(time__tokens_2,string_slice(s,i, new int( i.valueOf() + j.valueOf())))).valueOf())).valueOf()).valueOf() || (new bool( new bool(j.valueOf() == new int(3).valueOf()).valueOf() && (Array_string_contains(time__tokens_3,string_slice(s,i, new int( i.valueOf() + j.valueOf())))).valueOf())).valueOf()).valueOf() || (new bool( new bool(j.valueOf() == new int(4).valueOf()).valueOf() && (Array_string_contains(time__tokens_4,string_slice(s,i, new int( i.valueOf() + j.valueOf())))).valueOf())).valueOf())).valueOf()) {
array_push(tokens,string_slice(s,i, new int( i.valueOf() + j.valueOf())),false);
i.val = Math.floor(i + new int((new int( j.valueOf() - new int(1).valueOf())))); break;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
i.val ++;
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {strings__Builder} */
let sb = strings__new_builder(new int(128));
for (const token of tokens) {
try {
if (token.str === new string("M").str) {
strings__Builder_write_string(sb,int_str(t.month));
}
else if (token.str === new string("MM").str) {
strings__Builder_write_string(sb,new string(`${int_str(t.month)}`));
}
else if (token.str === new string("Mo").str) {
strings__Builder_write_string(sb,time__ordinal_suffix(t.month));
}
else if (token.str === new string("MMM").str) {
strings__Builder_write_string(sb,string_slice(time__long_months.arr.get(new int(new int( t.month.valueOf() - new int(1).valueOf()).valueOf())),new int(0), new int(3)));
}
else if (token.str === new string("MMMM").str) {
strings__Builder_write_string(sb,time__long_months.arr.get(new int(new int( t.month.valueOf() - new int(1).valueOf()).valueOf())));
}
else if (token.str === new string("D").str) {
strings__Builder_write_string(sb,int_str(t.day));
}
else if (token.str === new string("DD").str) {
strings__Builder_write_string(sb,new string(`${int_str(t.day)}`));
}
else if (token.str === new string("Do").str) {
strings__Builder_write_string(sb,time__ordinal_suffix(t.day));
}
else if (token.str === new string("DDD").str) {
strings__Builder_write_string(sb,int_str((new int( new int( t.day.valueOf() + time__days_before.arr.get(new int(new int( t.month.valueOf() - new int(1).valueOf()).valueOf())).valueOf()).valueOf() + new int(time__is_leap_year(t.year)).valueOf()))));
}
else if (token.str === new string("DDDD").str) {
strings__Builder_write_string(sb,new string(`${int_str(new int( new int( t.day.valueOf() + time__days_before.arr.get(new int(new int( t.month.valueOf() - new int(1).valueOf()).valueOf())).valueOf()).valueOf() + new int(time__is_leap_year(t.year)).valueOf()))}`));
}
else if (token.str === new string("DDDo").str) {
strings__Builder_write_string(sb,time__ordinal_suffix(new int( new int( t.day.valueOf() + time__days_before.arr.get(new int(new int( t.month.valueOf() - new int(1).valueOf()).valueOf())).valueOf()).valueOf() + new int(time__is_leap_year(t.year)).valueOf())));
}
else if (token.str === new string("d").str) {
strings__Builder_write_string(sb,int_str(time__Time_day_of_week(t,)));
}
else if (token.str === new string("dd").str) {
strings__Builder_write_string(sb,string_slice(time__long_days.arr.get(new int(new int( time__Time_day_of_week(t,).valueOf() - new int(1).valueOf()).valueOf())),new int(0), new int(2)));
}
else if (token.str === new string("ddd").str) {
strings__Builder_write_string(sb,string_slice(time__long_days.arr.get(new int(new int( time__Time_day_of_week(t,).valueOf() - new int(1).valueOf()).valueOf())),new int(0), new int(3)));
}
else if (token.str === new string("dddd").str) {
strings__Builder_write_string(sb,time__long_days.arr.get(new int(new int( time__Time_day_of_week(t,).valueOf() - new int(1).valueOf()).valueOf())));
}
else if (token.str === new string("YY").str) {
strings__Builder_write_string(sb,string_slice(int_str(t.year),new int(2), new int(4)));
}
else if (token.str === new string("YYYY").str) {
strings__Builder_write_string(sb,int_str(t.year));
}
else if (token.str === new string("H").str) {
strings__Builder_write_string(sb,int_str(t.hour));
}
else if (token.str === new string("HH").str) {
strings__Builder_write_string(sb,new string(`${int_str(t.hour)}`));
}
else if (token.str === new string("h").str) {
/** @type {int} */
const h = new int(new int( new int( (new int( t.hour.valueOf() + new int(11).valueOf())).valueOf() % new int(12).valueOf()).valueOf() + new int(1).valueOf()));
strings__Builder_write_string(sb,int_str(h));
}
else if (token.str === new string("hh").str) {
/** @type {int} */
const h = new int(new int( new int( (new int( t.hour.valueOf() + new int(11).valueOf())).valueOf() % new int(12).valueOf()).valueOf() + new int(1).valueOf()));
strings__Builder_write_string(sb,new string(`${int_str(h)}`));
}
else if (token.str === new string("i").str) {
/** @type {int} */
const h = new int(((new bool(t.hour.valueOf() > new int(12).valueOf())).valueOf() ? new int( t.hour.valueOf() - new int(12).valueOf()) : t.hour));
strings__Builder_write_string(sb,int_str(h));
}
else if (token.str === new string("ii").str) {
/** @type {int} */
const h = new int(((new bool(t.hour.valueOf() > new int(12).valueOf())).valueOf() ? new int( t.hour.valueOf() - new int(12).valueOf()) : t.hour));
strings__Builder_write_string(sb,new string(`${int_str(h)}`));
}
else if (token.str === new string("m").str) {
strings__Builder_write_string(sb,int_str(t.minute));
}
else if (token.str === new string("mm").str) {
strings__Builder_write_string(sb,new string(`${int_str(t.minute)}`));
}
else if (token.str === new string("s").str) {
strings__Builder_write_string(sb,int_str(t.second));
}
else if (token.str === new string("ss").str) {
strings__Builder_write_string(sb,new string(`${int_str(t.second)}`));
}
else if (token.str === new string("k").str) {
strings__Builder_write_string(sb,int_str((new int( t.hour.valueOf() + new int(1).valueOf()))));
}
else if (token.str === new string("kk").str) {
strings__Builder_write_string(sb,new string(`${int_str((new int( t.hour.valueOf() + new int(1).valueOf())))}`));
}
else if (token.str === new string("w").str) {
strings__Builder_write_string(sb,new string(`${f64_str(time__mceil(new int( (new int( new int( t.day.valueOf() + time__days_before.arr.get(new int(new int( t.month.valueOf() - new int(1).valueOf()).valueOf())).valueOf()).valueOf() + new int(time__is_leap_year(t.year)).valueOf())).valueOf() / new int(7).valueOf())))}`));
}
else if (token.str === new string("ww").str) {
strings__Builder_write_string(sb,new string(`${f64_str(time__mceil(new int( (new int( new int( t.day.valueOf() + time__days_before.arr.get(new int(new int( t.month.valueOf() - new int(1).valueOf()).valueOf())).valueOf()).valueOf() + new int(time__is_leap_year(t.year)).valueOf())).valueOf() / new int(7).valueOf())))}`));
}
else if (token.str === new string("wo").str) {
strings__Builder_write_string(sb,time__ordinal_suffix(new int(time__mceil(new int( (new int( new int( t.day.valueOf() + time__days_before.arr.get(new int(new int( t.month.valueOf() - new int(1).valueOf()).valueOf())).valueOf()).valueOf() + new int(time__is_leap_year(t.year)).valueOf())).valueOf() / new int(7).valueOf())))));
}
else if (token.str === new string("Q").str) {
strings__Builder_write_string(sb,new string(`${int_str(new int( (new int( t.month.valueOf() % new int(4).valueOf())).valueOf() + new int(1).valueOf()))}`));
}
else if (token.str === new string("QQ").str) {
strings__Builder_write_string(sb,new string(`${int_str(new int( (new int( t.month.valueOf() % new int(4).valueOf())).valueOf() + new int(1).valueOf()))}`));
}
else if (token.str === new string("Qo").str) {
strings__Builder_write_string(sb,time__ordinal_suffix(new int( (new int( t.month.valueOf() % new int(4).valueOf())).valueOf() + new int(1).valueOf())));
}
else if (token.str === new string("c").str) {
strings__Builder_write_string(sb,new string(`${int_str(new int( time__Time_day_of_week(t,).valueOf() + new int(1).valueOf()))}`));
}
else if (token.str === new string("N").str) {
strings__Builder_write_string(sb,new string("AD"));
}
else if (token.str === new string("NN").str) {
strings__Builder_write_string(sb,new string("Anno Domini"));
}
else if (token.str === new string("Z").str) {
/** @type {int} */
let hours = new int(new int( time__offset().valueOf() / time__seconds_per_hour.valueOf()));
if ((new bool(hours.valueOf() >= new int(0).valueOf())).valueOf()) {
strings__Builder_write_string(sb,new string(`+${int_str(hours)}`));
} else {
/** @type {int} */
hours = new int(-hours.val );
strings__Builder_write_string(sb,new string(`-${int_str(hours)}`));
}
}
else if (token.str === new string("ZZ").str) {
/** @type {int} */
let hours = new int(new int( time__offset().valueOf() / time__seconds_per_hour.valueOf()));
if ((new bool(hours.valueOf() >= new int(0).valueOf())).valueOf()) {
strings__Builder_write_string(sb,new string(`+${int_str(hours)}00`));
} else {
/** @type {int} */
hours = new int(-hours.val );
strings__Builder_write_string(sb,new string(`-${int_str(hours)}00`));
}
}
else if (token.str === new string("ZZZ").str) {
/** @type {int} */
let hours = new int(new int( time__offset().valueOf() / time__seconds_per_hour.valueOf()));
if ((new bool(hours.valueOf() >= new int(0).valueOf())).valueOf()) {
strings__Builder_write_string(sb,new string(`+${int_str(hours)}:00`));
} else {
/** @type {int} */
hours = new int(-hours.val );
strings__Builder_write_string(sb,new string(`-${int_str(hours)}:00`));
}
}
else if (token.str === new string("a").str) {
if ((new bool(t.hour.valueOf() < new int(12).valueOf())).valueOf()) {
strings__Builder_write_string(sb,new string("am"));
} else {
strings__Builder_write_string(sb,new string("pm"));
}
}
else if (token.str === new string("A").str) {
if ((new bool(t.hour.valueOf() < new int(12).valueOf())).valueOf()) {
strings__Builder_write_string(sb,new string("AM"));
} else {
strings__Builder_write_string(sb,new string("PM"));
}
}
else {
strings__Builder_write_string(sb,token);
};
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return strings__Builder_str(new $ref(sb));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function time__Time_clean(t) {
try {
/** @type {time__Time} */
const znow = time__now();
if ((new bool( new bool( new bool(t.month.valueOf() == znow.month.valueOf()).valueOf() && new bool(t.year.valueOf() == znow.year.valueOf()).valueOf()).valueOf() && new bool(t.day.valueOf() == znow.day.valueOf()).valueOf())).valueOf()) {
return time__Time_get_fmt_time_str(t,time__FormatTime.hhmm24);
}
if ((new bool(t.year.valueOf() == znow.year.valueOf())).valueOf()) {
return time__Time_get_fmt_str(t,time__FormatDelimiter.space, time__FormatTime.hhmm24, time__FormatDate.mmmd);
}
return time__Time_format(t,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function time__Time_clean12(t) {
try {
/** @type {time__Time} */
const znow = time__now();
if ((new bool( new bool( new bool(t.month.valueOf() == znow.month.valueOf()).valueOf() && new bool(t.year.valueOf() == znow.year.valueOf()).valueOf()).valueOf() && new bool(t.day.valueOf() == znow.day.valueOf()).valueOf())).valueOf()) {
return time__Time_get_fmt_time_str(t,time__FormatTime.hhmm12);
}
if ((new bool(t.year.valueOf() == znow.year.valueOf())).valueOf()) {
return time__Time_get_fmt_str(t,time__FormatDelimiter.space, time__FormatTime.hhmm12, time__FormatDate.mmmd);
}
return time__Time_format(t,);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {time__FormatTime} fmt_time
* @returns {string}
*/
function time__Time_get_fmt_time_str(t, fmt_time) {
try {
if ((new bool(fmt_time.valueOf() == time__FormatTime.no_time.valueOf())).valueOf()) {
return new string("");
}
/** @type {string} */
const tp = new string(((new bool(t.hour.valueOf() > new int(11).valueOf())).valueOf() ? new string("p.m.") : new string("a.m.")));
/** @type {int} */
const hour_ = new int(((new bool(t.hour.valueOf() > new int(12).valueOf())).valueOf() ? new int( t.hour.valueOf() - new int(12).valueOf()) : (new bool(t.hour.valueOf() == new int(0).valueOf())).valueOf() ? new int(12) : t.hour));
let _tmp42 = undefined;
switch (fmt_time) {
case time__FormatTime.hhmm12:
{
_tmp42 = new string(`${int_str(hour_)}:${int_str(t.minute)} ${tp}`);
} break;
case time__FormatTime.hhmm24:
{
_tmp42 = new string(`${int_str(t.hour)}:${int_str(t.minute)}`);
} break;
case time__FormatTime.hhmmss12:
{
_tmp42 = new string(`${int_str(hour_)}:${int_str(t.minute)}:${int_str(t.second)} ${tp}`);
} break;
case time__FormatTime.hhmmss24:
{
_tmp42 = new string(`${int_str(t.hour)}:${int_str(t.minute)}:${int_str(t.second)}`);
} break;
case time__FormatTime.hhmmss24_milli:
{
_tmp42 = new string(`${int_str(t.hour)}:${int_str(t.minute)}:${int_str(t.second)}.${int_str((new int( t.nanosecond.valueOf() / new int(1000000).valueOf())))}`);
} break;
case time__FormatTime.hhmmss24_micro:
{
_tmp42 = new string(`${int_str(t.hour)}:${int_str(t.minute)}:${int_str(t.second)}.${int_str((new int( t.nanosecond.valueOf() / new int(1000).valueOf())))}`);
} break;
case time__FormatTime.hhmmss24_nano:
{
_tmp42 = new string(`${int_str(t.hour)}:${int_str(t.minute)}:${int_str(t.second)}.${int_str(t.nanosecond)}`);
} break;
default:
{
_tmp42 = new string(`unknown enumeration ${time__FormatTime_str(fmt_time)}`);
} break;
}
return _tmp42;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {time__FormatDelimiter} fmt_dlmtr
* @param {time__FormatDate} fmt_date
* @returns {string}
*/
function time__Time_get_fmt_date_str(t, fmt_dlmtr, fmt_date) {
try {
if ((new bool(fmt_date.valueOf() == time__FormatDate.no_date.valueOf())).valueOf()) {
return new string("");
}
/** @type {string} */
const month = new string(time__Time_smonth(t,));
/** @type {string} */
const year = new string(`${int_str((new int( t.year.valueOf() % new int(100).valueOf())))}`);
let _tmp43 = undefined;
switch (fmt_date) {
case time__FormatDate.ddmmyy:
{
_tmp43 = `${int_str(t.day)}|${int_str(t.month)}|${year}`;
} break;
case time__FormatDate.ddmmyyyy:
{
_tmp43 = `${int_str(t.day)}|${int_str(t.month)}|${int_str(t.year)}`;
} break;
case time__FormatDate.mmddyy:
{
_tmp43 = `${int_str(t.month)}|${int_str(t.day)}|${year}`;
} break;
case time__FormatDate.mmddyyyy:
{
_tmp43 = `${int_str(t.month)}|${int_str(t.day)}|${int_str(t.year)}`;
} break;
case time__FormatDate.mmmd:
{
_tmp43 = `${month}|${int_str(t.day)}`;
} break;
case time__FormatDate.mmmdd:
{
_tmp43 = `${month}|${int_str(t.day)}`;
} break;
case time__FormatDate.mmmddyy:
{
_tmp43 = `${month}|${int_str(t.day)}|${year}`;
} break;
case time__FormatDate.mmmddyyyy:
{
_tmp43 = `${month}|${int_str(t.day)}|${int_str(t.year)}`;
} break;
case time__FormatDate.yyyymmdd:
{
_tmp43 = `${int_str(t.year)}|${int_str(t.month)}|${int_str(t.day)}`;
} break;
case time__FormatDate.yymmdd:
{
_tmp43 = `${year}|${int_str(t.month)}|${int_str(t.day)}`;
} break;
default:
{
_tmp43 = `unknown enumeration ${time__FormatDate_str(fmt_date)}`;
} break;
}
/** @type {string} */
let res = new string(_tmp43);
/** @type {string} */
const del = new string(((vEq(fmt_dlmtr,time__FormatDelimiter.dot))? (new string(".")) : (vEq(fmt_dlmtr,time__FormatDelimiter.hyphen))? (new string("-")) : (vEq(fmt_dlmtr,time__FormatDelimiter.slash))? (new string("/")) : (vEq(fmt_dlmtr,time__FormatDelimiter.space))? (new string(" ")) : (new string(""))));
/** @type {string} */
res = new string(string_replace(res,new string("|"), del));
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {time__FormatDelimiter} fmt_dlmtr
* @param {time__FormatTime} fmt_time
* @param {time__FormatDate} fmt_date
* @returns {string}
*/
function time__Time_get_fmt_str(t, fmt_dlmtr, fmt_time, fmt_date) {
try {
if ((new bool(fmt_date.valueOf() == time__FormatDate.no_date.valueOf())).valueOf()) {
if ((new bool(fmt_time.valueOf() == time__FormatTime.no_time.valueOf())).valueOf()) {
return new string("");
} else {
return time__Time_get_fmt_time_str(t,fmt_time);
}
} else {
if ((new bool(fmt_time.valueOf() != time__FormatTime.no_time.valueOf())).valueOf()) {
/** @type {string} */
const dstr = new string(time__Time_get_fmt_date_str(t,fmt_dlmtr, fmt_date));
/** @type {string} */
const tstr = new string(time__Time_get_fmt_time_str(t,fmt_time));
return new string(`${dstr} ${tstr}`);
} else {
return time__Time_get_fmt_date_str(t,fmt_dlmtr, fmt_date);
}
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function time__Time_utc_string(t) {
try {
/** @type {string} */
const day_str = new string(time__Time_weekday_str(t,));
/** @type {string} */
const month_str = new string(time__Time_smonth(t,));
/** @type {string} */
const utc_string = new string(`${day_str}, ${int_str(t.day)} ${month_str} ${int_str(t.year)} ${int_str(t.hour)}:${int_str(t.minute)}:${int_str(t.second)} UTC`);
return utc_string;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function time__Time_http_header_string(t) {
try {
/** @type {string} */
const day_str = new string(time__Time_weekday_str(t,));
/** @type {string} */
const month_str = new string(time__Time_smonth(t,));
/** @type {string} */
const http_header_string = new string(`${day_str}, ${int_str(t.day)} ${month_str} ${int_str(t.year)} ${int_str(t.hour)}:${int_str(t.minute)}:${int_str(t.second)} GMT`);
return http_header_string;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {f64} x
* @returns {f64}
*/
function time__mceil(x) {
try {
if ((new bool(x.valueOf() > new int(0).valueOf())).valueOf()) {
return new int( new int(1).valueOf() + new int(x).valueOf());
}
if ((new bool(x.valueOf() < new int(0).valueOf())).valueOf()) {
return -new int(-x.val ).val ;
}
return new int(0);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace time */
/* [inline] */
/**
* @function
* @param {time__Time} t2
* @returns {bool}
*/
function time__Time__eq(t1, t2) {
try {
return new bool( new bool(time__Time_unix(t1,).valueOf() == time__Time_unix(t2,).valueOf()).valueOf() && new bool(t1.nanosecond.valueOf() == t2.nanosecond.valueOf()).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {time__Time} t2
* @returns {bool}
*/
function time__Time__lt(t1, t2) {
try {
return new bool( new bool(time__Time_unix(t1,).valueOf() < time__Time_unix(t2,).valueOf()).valueOf() || (new bool( new bool(time__Time_unix(t1,).valueOf() == time__Time_unix(t2,).valueOf()).valueOf() && new bool(t1.nanosecond.valueOf() < t2.nanosecond.valueOf()).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {time__Time} rhs
* @returns {time__Duration}
*/
function time__Time__minus(lhs, rhs) {
try {
/** @type {i64} */
const unixs = new i64(new i64( BigInt(new i64(new i64( BigInt(time__Time_unix(lhs,).valueOf()) - BigInt(time__Time_unix(rhs,).valueOf()))).valueOf()) * BigInt(time__second.valueOf())));
/** @type {int} */
const nanos = new int(new int( lhs.nanosecond.valueOf() - rhs.nanosecond.valueOf()));
return new i64( BigInt(unixs.valueOf()) + BigInt(nanos.valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace time */
/**
* @function
* @param {string} s
* @returns {time__Time}
*/
function time__parse(s) {
try {
/** @type {time__Time} */
let res = new time__Time({});
let date = new Date(s.str)
res.year.val = date.getFullYear()
res.month.val = date.getMonth()
res.day.val = date.getDay()
res.hour.val = date.getHours()
res.minute.val = date.getMinutes()
res.second.val = date.getSeconds()
res.microsecond.val = date.getMilliseconds() * 1000
res.unix.val = (date.getTime() / 1000).toFixed(0)
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} s
* @returns {time__Time}
*/
function time__parse_iso8601(s) {
try {
return time__parse(s);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace time */
/**
* @constructor
* @param {{code?: int, message?: string}} init
*/
function time__TimeParseError({ code = new int(0), message = new string("") }) {
this.code = code
this.message = message
};
time__TimeParseError.prototype = {
...Error.prototype,
toString() {
return `time__TimeParseError { code: ${this["code"].toString()} , message: "${this["message"].toString()}"}`
},
/** @type {int} */
code: new int(0),
/** @type {string} */
message: new string(""),
$toJS() { return this; }
};
/**
* @function
* @returns {string}
*/
function time__TimeParseError_msg(err) {
try {
return new string(`Invalid time format code: ${int_str(err.code)}, error: ${err.message}`);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} code
* @param {string} message
* @returns {IError}
*/
function time__error_invalid_time(code, message) {
try {
return (function() {
let _tmp44 = new time__TimeParseError({});
_tmp44.code = code;
_tmp44.message = message;
return _tmp44;
})()
;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace time */
/* [params] */
/**
* @constructor
* @param {{auto_start?: bool}} init
*/
function time__StopWatchOptions({ auto_start = new bool(true) }) {
this.auto_start = auto_start
};
time__StopWatchOptions.prototype = {
toString() {
return `time__StopWatchOptions { auto_start: ${this["auto_start"].toString()} }`
},
/** @type {bool} */
auto_start: new bool(false),
$toJS() { return this; }
};
/**
* @constructor
* @param {{elapsed?: u64, start?: u64, end?: u64}} init
*/
function time__StopWatch({ elapsed = new u64(0), start = new u64(0), end = new u64(0) }) {
this.elapsed = elapsed
this.start = start
this.end = end
};
time__StopWatch.prototype = {
toString() {
return `time__StopWatch { elapsed: ${this["elapsed"].toString()} , start: ${this["start"].toString()} , end: ${this["end"].toString()} }`
},
/** @type {u64} */
elapsed: new u64(0),
/** @type {u64} */
start: new u64(0),
/** @type {u64} */
end: new u64(0),
$toJS() { return this; }
};
/**
* @function
* @param {time__StopWatchOptions} opts
* @returns {time__StopWatch}
*/
function time__new_stopwatch(opts) {
try {
/** @type {u64} */
let initial = new u64(new u64(BigInt(0n)));
if ((opts.auto_start).valueOf()) {
/** @type {u64} */
initial = new u64(time__sys_mono_now());
}
return (function() {
let _tmp45 = new time__StopWatch({});
_tmp45.elapsed = new int(0);
_tmp45.start = initial;
_tmp45.end = new int(0);
return _tmp45;
})()
;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function time__StopWatch_start(t) {
t = new $ref(t)
try {
/** @type {u64} */
t.val.start = new u64(time__sys_mono_now());
/** @type {u64} */
t.val.end = new u64(new int(0));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function time__StopWatch_restart(t) {
t = new $ref(t)
try {
/** @type {u64} */
t.val.start = new u64(time__sys_mono_now());
/** @type {u64} */
t.val.end = new u64(new int(0));
/** @type {u64} */
t.val.elapsed = new u64(new int(0));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function time__StopWatch_stop(t) {
t = new $ref(t)
try {
/** @type {u64} */
t.val.end = new u64(time__sys_mono_now());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {void}
*/
function time__StopWatch_pause(t) {
t = new $ref(t)
try {
if ((new bool(t.val.start.valueOf() > new int(0).valueOf())).valueOf()) {
if ((new bool(t.val.end.valueOf() == new int(0).valueOf())).valueOf()) {
/** @type {u64} */
t.val.elapsed.val = t.val.elapsed + new u64(new u64( BigInt(time__sys_mono_now().valueOf()) - BigInt(t.val.start.valueOf())));
} else {
/** @type {u64} */
t.val.elapsed.val = t.val.elapsed + new u64(new u64( BigInt(t.val.end.valueOf()) - BigInt(t.val.start.valueOf())));
}
}
/** @type {u64} */
t.val.start = new u64(new int(0));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {time__Duration}
*/
function time__StopWatch_elapsed(t) {
try {
if ((new bool(t.start.valueOf() > new int(0).valueOf())).valueOf()) {
if ((new bool(t.end.valueOf() == new int(0).valueOf())).valueOf()) {
return new time__Duration(new i64(new u64( BigInt(new u64( BigInt(time__sys_mono_now().valueOf()) - BigInt(t.start.valueOf())).valueOf()) + BigInt(t.elapsed.valueOf()))));
} else {
return new time__Duration(new i64(new u64( BigInt(new u64( BigInt(t.end.valueOf()) - BigInt(t.start.valueOf())).valueOf()) + BigInt(t.elapsed.valueOf()))));
}
}
return new time__Duration(new i64(t.elapsed));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace time */
/**
* @function
* @returns {time__Time}
*/
function time__now() {
try {
/** @type {time__Time} */
let res = new time__Time({});
let date = new Date()
res.year.val = date.getFullYear()
res.month.val = date.getMonth()
res.day.val = date.getDay()
res.hour.val = date.getHours()
res.minute.val = date.getMinutes()
res.second.val = date.getSeconds()
res.microsecond.val = date.getMilliseconds() * 1000
res.unix.val = (date.getTime() / 1000).toFixed(0)
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {time__Time}
*/
function time__utc() {
try {
/** @type {time__Time} */
let res = new time__Time({});
let date = new Date()
res.year.val = date.getUTCFullYear()
res.month.val = date.getUTCMonth()
res.day.val = date.getUTCDay()
res.hour.val = date.getUTCHours()
res.minute.val = date.getUTCMinutes()
res.second.val = date.getUTCSeconds()
res.microsecond.val = date.getUTCMilliseconds() * 1000
res.unix.val = (date.getTime() / 1000).toFixed(0)
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {time__Time}
*/
function time__Time_local(t) {
try {
return t;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {time__Duration} dur
* @returns {void}
*/
function time__sleep(dur) {
try {
let now = new Date().getTime()
let toWait = BigInt(dur.val) / BigInt(time__millisecond)
while (new Date().getTime() < now + Number(toWait)) {}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [deprecated] */
/* [deprecated_after] */
/**
* @function
* @deprecated
* @param {time__Time} t
* @returns {time__Time}
*/
function time__new_time(t) {
try {
return time__time_with_unix(t);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {time__Time} t
* @returns {time__Time}
*/
function time__time_with_unix(t) {
try {
if ((new bool(t.unix.valueOf() != new int(0).valueOf())).valueOf()) {
return t;
}
/** @type {time__Time} */
let res = new time__Time({});
res.year.val = t.year.val
res.month.val = t.month.val
res.day.val = t.day.val
res.hour.val = t.hour.val
res.minute.val = t.minute.val
res.second.val = t.second.val
res.microsecond.val = t.microsecond.val
res.unix.val = t.unix.val
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {i64}
*/
function time__ticks() {
try {
/** @type {i64} */
const t = new i64(new i64(BigInt(0n)));
t.val = BigInt(new Date().getTime())
return t;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace time */
/** @constant {string} */
const time__days_string = new string("MonTueWedThuFriSatSun");
/** @constant {Array_fixed_string_7} */
let time__long_days = undefined;
/** @constant {Array_fixed_int_12} */
let time__month_days = undefined;
/** @constant {string} */
const time__months_string = new string("JanFebMarAprMayJunJulAugSepOctNovDec");
/** @constant {Array_string} */
let time__long_months = undefined;
/** @constant {i64} */
let time__absolute_zero_year = undefined;
/** @constant {int} */
const time__seconds_per_minute = new int(60);
/** @constant {int} */
let time__seconds_per_hour = undefined;
/** @constant {int} */
let time__seconds_per_day = undefined;
/** @constant {int} */
let time__seconds_per_week = undefined;
/** @constant {int} */
let time__days_per_400_years = undefined;
/** @constant {int} */
let time__days_per_100_years = undefined;
/** @constant {int} */
let time__days_per_4_years = undefined;
/** @constant {int} */
const time__days_in_year = new int(365);
/** @constant {Array_fixed_int_13} */
let time__days_before = undefined;
/**
* @constructor
* @param {{unix?: i64, year?: int, month?: int, day?: int, hour?: int, minute?: int, second?: int, nanosecond?: int, is_local?: bool, microsecond?: int}} init
*/
function time__Time({ unix = new i64(0), year = new int(0), month = new int(0), day = new int(0), hour = new int(0), minute = new int(0), second = new int(0), nanosecond = new int(0), is_local = new bool(false), microsecond = new int(0) }) {
this.unix = unix
this.year = year
this.month = month
this.day = day
this.hour = hour
this.minute = minute
this.second = second
this.nanosecond = nanosecond
this.is_local = is_local
this.microsecond = microsecond
};
time__Time.prototype = {
toString() {
return `time__Time { unix: ${this["unix"].toString()} , year: ${this["year"].toString()} , month: ${this["month"].toString()} , day: ${this["day"].toString()} , hour: ${this["hour"].toString()} , minute: ${this["minute"].toString()} , second: ${this["second"].toString()} , nanosecond: ${this["nanosecond"].toString()} , is_local: ${this["is_local"].toString()} , microsecond: ${this["microsecond"].toString()} }`
},
/** @type {i64} */
unix: new i64(0),
/** @type {int} */
year: new int(0),
/** @type {int} */
month: new int(0),
/** @type {int} */
day: new int(0),
/** @type {int} */
hour: new int(0),
/** @type {int} */
minute: new int(0),
/** @type {int} */
second: new int(0),
/** @type {int} */
nanosecond: new int(0),
/** @type {bool} */
is_local: new bool(false),
/** @type {int} */
microsecond: new int(0),
$toJS() { return this; }
};
/** @enum {number} */
const time__FormatTime = {
hhmm12: 0,
hhmm24: 1,
hhmmss12: 2,
hhmmss24: 3,
hhmmss24_milli: 4,
hhmmss24_micro: 5,
hhmmss24_nano: 6,
no_time: 7,
};
/** @enum {number} */
const time__FormatDate = {
ddmmyy: 0,
ddmmyyyy: 1,
mmddyy: 2,
mmddyyyy: 3,
mmmd: 4,
mmmdd: 5,
mmmddyy: 6,
mmmddyyyy: 7,
no_date: 8,
yyyymmdd: 9,
yymmdd: 10,
};
/** @enum {number} */
const time__FormatDelimiter = {
dot: 0,
hyphen: 1,
slash: 2,
space: 3,
no_delimiter: 4,
};
/**
* @function
* @param {time__Time} t
* @returns {time__Time}
*/
function time__Time__static__new(t) {
try {
return time__time_with_unix(t);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {time__Time} t
* @returns {time__Time}
*/
function time__new(t) {
try {
return time__time_with_unix(t);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function time__Time_smonth(t) {
t = new $ref(t)
try {
if ((new bool( new bool(t.val.month.valueOf() <= new int(0).valueOf()).valueOf() || new bool(t.val.month.valueOf() > new int(12).valueOf()).valueOf())).valueOf()) {
return new string("---");
}
/** @type {int} */
const i = new int(new int( t.val.month.valueOf() - new int(1).valueOf()));
return string_slice(time__months_string,new int( i.valueOf() * new int(3).valueOf()), new int( (new int( i.valueOf() + new int(1).valueOf())).valueOf() * new int(3).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {i64}
*/
function time__Time_unix(t) {
t = new $ref(t)
try {
return time__time_with_unix(t).unix;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {i64}
*/
function time__Time_unix_milli(t) {
t = new $ref(t)
try {
return new i64( BigInt(new i64( BigInt(time__Time_unix(t.valueOf(),).valueOf()) * BigInt(new int(1000).valueOf())).valueOf()) + BigInt((new i64( BigInt(new i64(t.val.nanosecond).valueOf()) / BigInt(new int(1000000).valueOf()))).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {i64}
*/
function time__Time_unix_micro(t) {
t = new $ref(t)
try {
return new i64( BigInt(new i64( BigInt(time__Time_unix(t.valueOf(),).valueOf()) * BigInt(new int(1000000).valueOf())).valueOf()) + BigInt((new i64( BigInt(new i64(t.val.nanosecond).valueOf()) / BigInt(new int(1000).valueOf()))).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {i64}
*/
function time__Time_unix_nano(t) {
t = new $ref(t)
try {
return new i64( BigInt(new i64( BigInt(time__Time_unix(t.valueOf(),).valueOf()) * BigInt(new int(1000000000).valueOf())).valueOf()) + BigInt(new i64(t.val.nanosecond).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [deprecated] */
/* [deprecated_after] */
/**
* @function
* @deprecated
* @returns {i64}
*/
function time__Time_unix_time(t) {
t = new $ref(t)
try {
return time__Time_unix(t.valueOf(),);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [deprecated] */
/* [deprecated_after] */
/**
* @function
* @deprecated
* @returns {i64}
*/
function time__Time_unix_time_milli(t) {
t = new $ref(t)
try {
return time__Time_unix_milli(t.valueOf(),);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [deprecated] */
/* [deprecated_after] */
/**
* @function
* @deprecated
* @returns {i64}
*/
function time__Time_unix_time_micro(t) {
t = new $ref(t)
try {
return time__Time_unix_micro(t.valueOf(),);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [deprecated] */
/* [deprecated_after] */
/**
* @function
* @deprecated
* @returns {i64}
*/
function time__Time_unix_time_nano(t) {
t = new $ref(t)
try {
return time__Time_unix_nano(t.valueOf(),);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {time__Duration} duration_in_nanosecond
* @returns {time__Time}
*/
function time__Time_add(t, duration_in_nanosecond) {
t = new $ref(t)
try {
/** @type {i64} */
let increased_time_nanosecond = new i64(new i64( BigInt(new i64(t.val.nanosecond).valueOf()) + BigInt(time__Duration_nanoseconds(duration_in_nanosecond,).valueOf())));
/** @type {i64} */
let increased_time_second = new i64(new i64( BigInt(time__Time_unix(t.valueOf(),).valueOf()) + BigInt((new i64( BigInt(increased_time_nanosecond.valueOf()) / BigInt(time__second.valueOf()))).valueOf())));
/** @type {i64} */
increased_time_nanosecond = new i64(new i64( BigInt(increased_time_nanosecond.valueOf()) % BigInt(time__second.valueOf())));
if ((new bool(increased_time_nanosecond.valueOf() < new int(0).valueOf())).valueOf()) {
increased_time_second.val --;
/** @type {i64} */
increased_time_nanosecond.val = increased_time_nanosecond + new i64(time__second);
}
/** @type {time__Time} */
const res = time__unix_nanosecond(increased_time_second, new int(increased_time_nanosecond));
return ((t.val.is_local).valueOf() ? time__Time_as_local(res,) : res);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} seconds
* @returns {time__Time}
*/
function time__Time_add_seconds(t, seconds) {
t = new $ref(t)
try {
return time__Time_add(time__time_with_unix(t),new int( BigInt(seconds.valueOf()) * BigInt(time__second.valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} days
* @returns {time__Time}
*/
function time__Time_add_days(t, days) {
t = new $ref(t)
try {
return time__Time_add(time__time_with_unix(t),new int( BigInt(new int( days.valueOf() * new int(24).valueOf()).valueOf()) * BigInt(time__hour.valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {time__Time} t
* @returns {time__Duration}
*/
function time__since(t) {
try {
return time__Time__minus(time__now(), t);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function time__Time_relative(t) {
t = new $ref(t)
try {
/** @type {time__Time} */
const znow = time__now();
/** @type {i64} */
let secs = new i64(new i64( BigInt(znow.unix.valueOf()) - BigInt(time__Time_unix(t.valueOf(),).valueOf())));
/** @type {string} */
let prefix = new string(new string(""));
/** @type {string} */
let suffix = new string(new string(""));
if ((new bool(secs.valueOf() < new int(0).valueOf())).valueOf()) {
/** @type {i64} */
secs.val = secs * new i64(new int(-1));
/** @type {string} */
prefix = new string(new string("in "));
} else {
/** @type {string} */
suffix = new string(new string(" ago"));
}
if ((new bool(secs.valueOf() < new int_literal( time__seconds_per_minute.valueOf() / new int(2).valueOf()).valueOf())).valueOf()) {
return new string("now");
}
if ((new bool(secs.valueOf() < time__seconds_per_hour.valueOf())).valueOf()) {
/** @type {i64} */
const m = new i64(new i64( BigInt(secs.valueOf()) / BigInt(time__seconds_per_minute.valueOf())));
if ((new bool(m.valueOf() == new int(1).valueOf())).valueOf()) {
return new string(`${prefix}1 minute${suffix}`);
}
return new string(`${prefix}${i64_str(m)} minutes${suffix}`);
}
if ((new bool(secs.valueOf() < new int_literal( time__seconds_per_hour.valueOf() * new int(24).valueOf()).valueOf())).valueOf()) {
/** @type {i64} */
const h = new i64(new i64( BigInt(secs.valueOf()) / BigInt(time__seconds_per_hour.valueOf())));
if ((new bool(h.valueOf() == new int(1).valueOf())).valueOf()) {
return new string(`${prefix}1 hour${suffix}`);
}
return new string(`${prefix}${i64_str(h)} hours${suffix}`);
}
if ((new bool(secs.valueOf() < new int_literal( new int_literal( time__seconds_per_hour.valueOf() * new int(24).valueOf()).valueOf() * new int(7).valueOf()).valueOf())).valueOf()) {
/** @type {i64} */
const d = new i64(new i64( BigInt(new i64( BigInt(secs.valueOf()) / BigInt(time__seconds_per_hour.valueOf())).valueOf()) / BigInt(new int(24).valueOf())));
if ((new bool(d.valueOf() == new int(1).valueOf())).valueOf()) {
return new string(`${prefix}1 day${suffix}`);
}
return new string(`${prefix}${i64_str(d)} days${suffix}`);
}
if ((new bool(secs.valueOf() < new int_literal( new int_literal( time__seconds_per_hour.valueOf() * new int(24).valueOf()).valueOf() * time__days_in_year.valueOf()).valueOf())).valueOf()) {
if ((new bool(prefix.valueOf() == new string("in ").valueOf())).valueOf()) {
return new string(`on ${time__Time_md(t.valueOf(),)}`);
}
return new string(`last ${time__Time_md(t.valueOf(),)}`);
}
/** @type {i64} */
const y = new i64(new i64( BigInt(new i64( BigInt(new i64( BigInt(secs.valueOf()) / BigInt(time__seconds_per_hour.valueOf())).valueOf()) / BigInt(new int(24).valueOf())).valueOf()) / BigInt(time__days_in_year.valueOf())));
if ((new bool(y.valueOf() == new int(1).valueOf())).valueOf()) {
return new string(`${prefix}1 year${suffix}`);
}
return new string(`${prefix}${i64_str(y)} years${suffix}`);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function time__Time_relative_short(t) {
t = new $ref(t)
try {
/** @type {time__Time} */
const znow = time__now();
/** @type {i64} */
let secs = new i64(new i64( BigInt(znow.unix.valueOf()) - BigInt(time__Time_unix(t.valueOf(),).valueOf())));
/** @type {string} */
let prefix = new string(new string(""));
/** @type {string} */
let suffix = new string(new string(""));
if ((new bool(secs.valueOf() < new int(0).valueOf())).valueOf()) {
/** @type {i64} */
secs.val = secs * new i64(new int(-1));
/** @type {string} */
prefix = new string(new string("in "));
} else {
/** @type {string} */
suffix = new string(new string(" ago"));
}
if ((new bool(secs.valueOf() < new int_literal( time__seconds_per_minute.valueOf() / new int(2).valueOf()).valueOf())).valueOf()) {
return new string("now");
}
if ((new bool(secs.valueOf() < time__seconds_per_hour.valueOf())).valueOf()) {
/** @type {i64} */
const m = new i64(new i64( BigInt(secs.valueOf()) / BigInt(time__seconds_per_minute.valueOf())));
if ((new bool(m.valueOf() == new int(1).valueOf())).valueOf()) {
return new string(`${prefix}1m${suffix}`);
}
return new string(`${prefix}${i64_str(m)}m${suffix}`);
}
if ((new bool(secs.valueOf() < new int_literal( time__seconds_per_hour.valueOf() * new int(24).valueOf()).valueOf())).valueOf()) {
/** @type {i64} */
const h = new i64(new i64( BigInt(secs.valueOf()) / BigInt(time__seconds_per_hour.valueOf())));
if ((new bool(h.valueOf() == new int(1).valueOf())).valueOf()) {
return new string(`${prefix}1h${suffix}`);
}
return new string(`${prefix}${i64_str(h)}h${suffix}`);
}
if ((new bool(secs.valueOf() < new int_literal( new int_literal( time__seconds_per_hour.valueOf() * new int(24).valueOf()).valueOf() * time__days_in_year.valueOf()).valueOf())).valueOf()) {
/** @type {i64} */
const d = new i64(new i64( BigInt(new i64( BigInt(secs.valueOf()) / BigInt(time__seconds_per_hour.valueOf())).valueOf()) / BigInt(new int(24).valueOf())));
if ((new bool(d.valueOf() == new int(1).valueOf())).valueOf()) {
return new string(`${prefix}1d${suffix}`);
}
return new string(`${prefix}${i64_str(d)}d${suffix}`);
}
/** @type {i64} */
const y = new i64(new i64( BigInt(new i64( BigInt(new i64( BigInt(secs.valueOf()) / BigInt(time__seconds_per_hour.valueOf())).valueOf()) / BigInt(new int(24).valueOf())).valueOf()) / BigInt(time__days_in_year.valueOf())));
if ((new bool(y.valueOf() == new int(1).valueOf())).valueOf()) {
return new string(`${prefix}1y${suffix}`);
}
return new string(`${prefix}${i64_str(y)}y${suffix}`);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} y
* @param {int} m
* @param {int} d
* @returns {int}
*/
function time__day_of_week(y, m, d) {
try {
/** @type {Array_int} */
const t = new array(new array_buffer({arr: [new int(new int(0)), new int(new int(3)), new int(new int(2)), new int(new int(5)), new int(new int(0)), new int(new int(3)), new int(new int(5)), new int(new int(1)), new int(new int(4)), new int(new int(6)), new int(new int(2)), new int(new int(4))], len: new int(12), cap: new int(12)}));
/** @type {int} */
let sy = new int(y);
if ((new bool(m.valueOf() < new int(3).valueOf())).valueOf()) {
/** @type {int} */
sy = new int(new int( sy.valueOf() - new int(1).valueOf()));
}
return new int( new int( (new int( new int( new int( new int( new int( new int( sy.valueOf() + new int( sy.valueOf() / new int(4).valueOf()).valueOf()).valueOf() - new int( sy.valueOf() / new int(100).valueOf()).valueOf()).valueOf() + new int( sy.valueOf() / new int(400).valueOf()).valueOf()).valueOf() + t.arr.get(new int(new int( m.valueOf() - new int(1).valueOf()).valueOf())).valueOf()).valueOf() + d.valueOf()).valueOf() - new int(1).valueOf())).valueOf() % new int(7).valueOf()).valueOf() + new int(1).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {int}
*/
function time__Time_day_of_week(t) {
t = new $ref(t)
try {
return time__day_of_week(t.val.year, t.val.month, t.val.day);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {int}
*/
function time__Time_year_day(t) {
t = new $ref(t)
try {
/** @type {int} */
const yday = new int(new int( t.val.day.valueOf() + time__days_before.arr.get(new int(new int( t.val.month.valueOf() - new int(1).valueOf()).valueOf())).valueOf()));
if ((new bool( time__is_leap_year(t.val.year).valueOf() && new bool(t.val.month.valueOf() > new int(2).valueOf()).valueOf())).valueOf()) {
return new int( yday.valueOf() + new int(1).valueOf());
}
return yday;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function time__Time_weekday_str(t) {
t = new $ref(t)
try {
/** @type {int} */
const i = new int(new int( time__Time_day_of_week(t.valueOf(),).valueOf() - new int(1).valueOf()));
return string_slice(time__long_days.arr.get(new int(i.valueOf())),new int(0), new int(3));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function time__Time_long_weekday_str(t) {
t = new $ref(t)
try {
/** @type {int} */
const i = new int(new int( time__Time_day_of_week(t.valueOf(),).valueOf() - new int(1).valueOf()));
return time__long_days.arr.get(new int(i.valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} year
* @returns {bool}
*/
function time__is_leap_year(year) {
try {
return new bool( new bool(new int( year.valueOf() % new int(4).valueOf()).valueOf() == new int(0).valueOf()).valueOf() && (new bool( new bool(new int( year.valueOf() % new int(100).valueOf()).valueOf() != new int(0).valueOf()).valueOf() || new bool(new int( year.valueOf() % new int(400).valueOf()).valueOf() == new int(0).valueOf()).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} month
* @param {int} year
* @returns {int}
*/
function time__days_in_month(month, year) {
try {
if ((new bool( new bool(month.valueOf() > new int(12).valueOf()).valueOf() || new bool(month.valueOf() < new int(1).valueOf()).valueOf())).valueOf()) {
return error(new string(`Invalid month: ${int_str(month)}`));
}
/** @type {int} */
const extra = new int(((new bool( new bool(month.valueOf() == new int(2).valueOf()).valueOf() && time__is_leap_year(year).valueOf())).valueOf() ? new int(1) : new int(0)));
/** @type {int} */
const res = new int(new int( time__month_days.arr.get(new int(new int( month.valueOf() - new int(1).valueOf()).valueOf())).valueOf() + extra.valueOf()));
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function time__Time_debug(t) {
t = new $ref(t)
try {
return new string(`Time{ year: ${int_str(t.val.year)} month: ${int_str(t.val.month)} day: ${int_str(t.val.day)} hour: ${int_str(t.val.hour)} minute: ${int_str(t.val.minute)} second: ${int_str(t.val.second)} nanosecond: ${int_str(t.val.nanosecond)} unix: ${i64_str(t.val.unix)} }`);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {int}
*/
function time__offset() {
try {
/** @type {time__Time} */
const t = time__utc();
/** @type {time__Time} */
const local = time__Time_local(t,);
return new int(new i64( BigInt(local.unix.valueOf()) - BigInt(t.unix.valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {time__Time}
*/
function time__Time_local_to_utc(t) {
t = new $ref(t)
try {
if ((!t.val.is_local.val ).valueOf()) {
return t;
}
return (function() {
let _tmp46 = new time__Time({});
_tmp46.is_local = new bool(false);
return _tmp46;
})()
;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {time__Time}
*/
function time__Time_utc_to_local(u) {
u = new $ref(u)
try {
if ((u.val.is_local).valueOf()) {
return u;
}
return (function() {
let _tmp47 = new time__Time({});
_tmp47.is_local = new bool(true);
return _tmp47;
})()
;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {time__Time}
*/
function time__Time_as_local(t) {
t = new $ref(t)
try {
return (function() {
let _tmp48 = new time__Time({});
_tmp48.is_local = new bool(true);
return _tmp48;
})()
;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {time__Time}
*/
function time__Time_as_utc(t) {
t = new $ref(t)
try {
return (function() {
let _tmp49 = new time__Time({});
_tmp49.is_local = new bool(false);
return _tmp49;
})()
;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {bool}
*/
function time__Time_is_utc(t) {
t = new $ref(t)
try {
return !t.val.is_local.val ;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace time */
var $timeOff = 0;
var $seen = 0
function $sys_mono_new_Date() {
var t = Date.now()
if (t < $seen)
$timeOff += ($seen - t)
$seen = t
return t + $timeOff
}
/**
* @function
* @returns {u64}
*/
function time__sys_mono_now() {
try {
if (false)
{
/** @type {u64} */
let res = new u64(new u64(BigInt(0n)));
res = new u64(Math.floor(window.performance.now() * 1000000))
return res;
}
else if (true)
{
/** @type {u64} */
let res = new u64(new u64(BigInt(0n)));
res.val = $process.hrtime.bigint()
return res;
}
else
{
/** @type {u64} */
let res = new u64(new u64(BigInt(0n)));
res = new u64($sys_mono_new_Date() * 1000000)
return res;
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace time */
/**
* @function
* @param {i64} epoch
* @returns {time__Time}
*/
function time__unix(epoch) {
try {
/** @type {i64} */
let day_offset = new i64(new i64( BigInt(epoch.valueOf()) / BigInt(time__seconds_per_day.valueOf())));
if ((new bool(new i64( BigInt(epoch.valueOf()) % BigInt(time__seconds_per_day.valueOf())).valueOf() < new int(0).valueOf())).valueOf()) {
day_offset.val --;
}
let [year, month, day] = time__calculate_date_from_day_offset(day_offset);
let [hr, min, sec] = time__calculate_time_from_second_offset(new i64( BigInt(epoch.valueOf()) % BigInt(time__seconds_per_day.valueOf())));
return (function() {
let _tmp50 = new time__Time({});
_tmp50.year = year;
_tmp50.month = month;
_tmp50.day = day;
_tmp50.hour = hr;
_tmp50.minute = min;
_tmp50.second = sec;
_tmp50.unix = epoch;
return _tmp50;
})()
;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [deprecated] */
/* [deprecated_after] */
/**
* @function
* @deprecated
* @param {i64} epoch
* @param {int} microsecond
* @returns {time__Time}
*/
function time__unix2(epoch, microsecond) {
try {
return time__unix_nanosecond(epoch, new int( microsecond.valueOf() * new int(1000).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {i64} epoch
* @param {int} microsecond
* @returns {time__Time}
*/
function time__unix_microsecond(epoch, microsecond) {
try {
return time__unix_nanosecond(epoch, new int( microsecond.valueOf() * new int(1000).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {i64} abs_unix_timestamp
* @param {int} nanosecond
* @returns {time__Time}
*/
function time__unix_nanosecond(abs_unix_timestamp, nanosecond) {
try {
/** @type {i64} */
let day_offset = new i64(new i64( BigInt(abs_unix_timestamp.valueOf()) / BigInt(time__seconds_per_day.valueOf())));
if ((new bool(new i64( BigInt(abs_unix_timestamp.valueOf()) % BigInt(time__seconds_per_day.valueOf())).valueOf() < new int(0).valueOf())).valueOf()) {
day_offset.val --;
}
let [year, month, day] = time__calculate_date_from_day_offset(day_offset);
let [hour_, minute_, second_] = time__calculate_time_from_second_offset(new i64( BigInt(abs_unix_timestamp.valueOf()) % BigInt(time__seconds_per_day.valueOf())));
return (function() {
let _tmp51 = new time__Time({});
_tmp51.year = year;
_tmp51.month = month;
_tmp51.day = day;
_tmp51.hour = hour_;
_tmp51.minute = minute_;
_tmp51.second = second_;
_tmp51.nanosecond = nanosecond;
_tmp51.unix = abs_unix_timestamp;
return _tmp51;
})()
;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {i64} day_offset_
* @returns {multi_return_int_int_int}
*/
function time__calculate_date_from_day_offset(day_offset_) {
try {
/** @type {i64} */
let day_offset = new i64(day_offset_);
/** @type {i64} */
day_offset.val = day_offset + new i64(new int(719468));
/** @type {int} */
let era = new int(new int(0));
if ((new bool(day_offset.valueOf() >= new int(0).valueOf())).valueOf()) {
/** @type {int} */
era = new int(new int(new i64( BigInt(day_offset.valueOf()) / BigInt(time__days_per_400_years.valueOf()))));
} else {
/** @type {int} */
era = new int(new int(new i64( BigInt((new i64( BigInt(new i64( BigInt(day_offset.valueOf()) - BigInt(time__days_per_400_years.valueOf())).valueOf()) - BigInt(new int(1).valueOf()))).valueOf()) / BigInt(time__days_per_400_years.valueOf()))));
}
/** @type {i64} */
const day_of_era = new i64(new i64( BigInt(day_offset.valueOf()) - BigInt(new int( era.valueOf() * time__days_per_400_years.valueOf()).valueOf())));
/** @type {i64} */
const year_of_era = new i64(new i64( BigInt((new i64( BigInt(new i64( BigInt(new i64( BigInt(day_of_era.valueOf()) - BigInt(new i64( BigInt(day_of_era.valueOf()) / BigInt((new int_literal( time__days_per_4_years.valueOf() - new int(1).valueOf())).valueOf())).valueOf())).valueOf()) + BigInt(new i64( BigInt(day_of_era.valueOf()) / BigInt(time__days_per_100_years.valueOf())).valueOf())).valueOf()) - BigInt(new i64( BigInt(day_of_era.valueOf()) / BigInt((new int_literal( time__days_per_400_years.valueOf() - new int(1).valueOf())).valueOf())).valueOf()))).valueOf()) / BigInt(time__days_in_year.valueOf())));
/** @type {int} */
let year = new int(new int(new i64( BigInt(year_of_era.valueOf()) + BigInt(new int( era.valueOf() * new int(400).valueOf()).valueOf()))));
/** @type {i64} */
const day_of_year = new i64(new i64( BigInt(day_of_era.valueOf()) - BigInt((new i64( BigInt(new i64( BigInt(new i64( BigInt(time__days_in_year.valueOf()) * BigInt(year_of_era.valueOf())).valueOf()) + BigInt(new i64( BigInt(year_of_era.valueOf()) / BigInt(new int(4).valueOf())).valueOf())).valueOf()) - BigInt(new i64( BigInt(year_of_era.valueOf()) / BigInt(new int(100).valueOf())).valueOf()))).valueOf())));
/** @type {i64} */
const month_position = new i64(new i64( BigInt((new i64( BigInt(new i64( BigInt(new int(5).valueOf()) * BigInt(day_of_year.valueOf())).valueOf()) + BigInt(new int(2).valueOf()))).valueOf()) / BigInt(new int(153).valueOf())));
/** @type {int} */
const day = new int(new int(new i64( BigInt(new i64( BigInt(day_of_year.valueOf()) - BigInt(new i64( BigInt((new i64( BigInt(new i64( BigInt(new int(153).valueOf()) * BigInt(month_position.valueOf())).valueOf()) + BigInt(new int(2).valueOf()))).valueOf()) / BigInt(new int(5).valueOf())).valueOf())).valueOf()) + BigInt(new int(1).valueOf()))));
/** @type {int} */
let month = new int(new int(month_position));
if ((new bool(month_position.valueOf() < new int(10).valueOf())).valueOf()) {
/** @type {int} */
month.val = Math.floor(month + new int(new int(3)));
} else {
/** @type {int} */
month.val = Math.floor(month - new int(new int(9)));
}
if ((new bool(month.valueOf() <= new int(2).valueOf())).valueOf()) {
/** @type {int} */
year.val = Math.floor(year + new int(new int(1)));
}
return [year, month, day];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {i64} second_offset_
* @returns {multi_return_int_int_int}
*/
function time__calculate_time_from_second_offset(second_offset_) {
try {
/** @type {i64} */
let second_offset = new i64(second_offset_);
if ((new bool(second_offset.valueOf() < new int(0).valueOf())).valueOf()) {
/** @type {i64} */
second_offset.val = second_offset + new i64(time__seconds_per_day);
}
/** @type {i64} */
const hour_ = new i64(new i64( BigInt(second_offset.valueOf()) / BigInt(time__seconds_per_hour.valueOf())));
/** @type {i64} */
second_offset.val = second_offset % new i64(time__seconds_per_hour);
/** @type {i64} */
const minute_ = new i64(new i64( BigInt(second_offset.valueOf()) / BigInt(time__seconds_per_minute.valueOf())));
/** @type {i64} */
second_offset.val = second_offset % new i64(time__seconds_per_minute);
return [new int(hour_), new int(minute_), new int(second_offset)];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace sync.threads */
/** @namespace rand.constants */
/** @constant {u64} */
let rand__constants__lower_mask = undefined;
/** @constant {u32} */
let rand__constants__max_u32 = undefined;
/** @constant {u64} */
let rand__constants__max_u64 = undefined;
/** @constant {u32} */
let rand__constants__u31_mask = undefined;
/** @constant {u64} */
let rand__constants__u63_mask = undefined;
/** @constant {u32} */
let rand__constants__ieee754_mantissa_f32_mask = undefined;
/** @constant {u64} */
let rand__constants__ieee754_mantissa_f64_mask = undefined;
/** @constant {f64} */
let rand__constants__reciprocal_2_23rd = undefined;
/** @constant {f64} */
let rand__constants__reciprocal_2_52nd = undefined;
/** @namespace rand.buffer */
/**
* @constructor
* @param {{bytes_left?: int, buffer?: u64}} init
*/
function rand__buffer__PRNGBuffer({ bytes_left = new int(0), buffer = new u64(0) }) {
this.bytes_left = bytes_left
this.buffer = buffer
};
rand__buffer__PRNGBuffer.prototype = {
toString() {
return `rand__buffer__PRNGBuffer { bytes_left: ${this["bytes_left"].toString()} , buffer: ${this["buffer"].toString()} }`
},
/** @type {int} */
bytes_left: new int(0),
/** @type {u64} */
buffer: new u64(0),
$toJS() { return this; }
};
/** @namespace hash */
/**
* @interface hash__Hasher
* @typedef hash__Hasher
* @property {(b: Array_u8) => Array_u8} sum
* @property {() => int} size
* @property {() => int} block_size
*/
function hash__Hasher (arg) { return new $ref(arg); }
/**
* @interface hash__Hash32er
* @typedef hash__Hash32er
* @property {() => u32} sum32
*/
function hash__Hash32er (arg) { return new $ref(arg); }
/**
* @interface hash__Hash64er
* @typedef hash__Hash64er
* @property {() => u64} sum64
*/
function hash__Hash64er (arg) { return new $ref(arg); }
/** @namespace hash */
/**
* @function
* @param {string} s
* @param {u64} key
* @returns {u64}
*/
function hash__sum64_string(s, key) {
try {
builtin__panic (new string("not yet implemented"));
return new int(0);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace hash */
/** @constant {u64} */
let hash__wyp0 = undefined;
/** @constant {u64} */
let hash__wyp1 = undefined;
/** @constant {u64} */
let hash__wyp2 = undefined;
/** @constant {u64} */
let hash__wyp3 = undefined;
/** @constant {u64} */
let hash__wyp4 = undefined;
/* [inline] */
/**
* @function
* @param {u64} v
* @param {u32} k
* @returns {u64}
*/
function hash__wyrotr(v, k) {
try {
return new u64( BigInt((new u64( BigInt(v.valueOf()) >> BigInt(k.valueOf()))).valueOf()) | BigInt((new u64( BigInt(v.valueOf()) << BigInt((new u32( new int(64).valueOf() - k.valueOf())).valueOf()))).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u64} a
* @param {u64} b
* @returns {u64}
*/
function hash__wymum(a, b) {
try {
/** @type {u32} */
const mask32 = new u32(new int(4294967295));
/** @type {u64} */
const x0 = new u64(new u64( BigInt(a.valueOf()) & BigInt(mask32.valueOf())));
/** @type {u64} */
const x1 = new u64(new u64( BigInt(a.valueOf()) >> BigInt(new int(32).valueOf())));
/** @type {u64} */
const y0 = new u64(new u64( BigInt(b.valueOf()) & BigInt(mask32.valueOf())));
/** @type {u64} */
const y1 = new u64(new u64( BigInt(b.valueOf()) >> BigInt(new int(32).valueOf())));
/** @type {u64} */
const w0 = new u64(new u64( BigInt(x0.valueOf()) * BigInt(y0.valueOf())));
/** @type {u64} */
const t = new u64(new u64( BigInt(new u64( BigInt(x1.valueOf()) * BigInt(y0.valueOf())).valueOf()) + BigInt((new u64( BigInt(w0.valueOf()) >> BigInt(new int(32).valueOf()))).valueOf())));
/** @type {u64} */
let w1 = new u64(new u64( BigInt(t.valueOf()) & BigInt(mask32.valueOf())));
/** @type {u64} */
const w2 = new u64(new u64( BigInt(t.valueOf()) >> BigInt(new int(32).valueOf())));
/** @type {u64} */
w1.val = w1 + new u64(new u64( BigInt(x0.valueOf()) * BigInt(y1.valueOf())));
/** @type {u64} */
const hi = new u64(new u64( BigInt(new u64( BigInt(new u64( BigInt(x1.valueOf()) * BigInt(y1.valueOf())).valueOf()) + BigInt(w2.valueOf())).valueOf()) + BigInt((new u64( BigInt(w1.valueOf()) >> BigInt(new int(32).valueOf()))).valueOf())));
/** @type {u64} */
const lo = new u64(new u64( BigInt(a.valueOf()) * BigInt(b.valueOf())));
return new u64( BigInt(hi.valueOf()) ^ BigInt(lo.valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u8} p
* @param {u64} k
* @returns {u64}
*/
function hash__wyr3(p, k) {
p = new $ref(p)
try {
{
return new u64( BigInt(new u64( BigInt((new u64( BigInt(new u64(p.valueOf().arr.get(new int(new int(0).valueOf()))).valueOf()) << BigInt(new int(16).valueOf()))).valueOf()) | BigInt((new u64( BigInt(new u64(p.valueOf().arr.get(new int(new u64( BigInt(k.valueOf()) >> BigInt(new int(1).valueOf())).valueOf()))).valueOf()) << BigInt(new int(8).valueOf()))).valueOf())).valueOf()) | BigInt(new u64(p.valueOf().arr.get(new int(new u64( BigInt(k.valueOf()) - BigInt(new int(1).valueOf())).valueOf()))).valueOf()));
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u8} p
* @returns {u64}
*/
function hash__wyr4(p) {
p = new $ref(p)
try {
{
return new u32( new u32( new u32( new u32(p.valueOf().arr.get(new int(new int(0).valueOf()))).valueOf() | (new u32( new u32(p.valueOf().arr.get(new int(new int(1).valueOf()))).valueOf() << new int(8).valueOf())).valueOf()).valueOf() | (new u32( new u32(p.valueOf().arr.get(new int(new int(2).valueOf()))).valueOf() << new int(16).valueOf())).valueOf()).valueOf() | (new u32( new u32(p.valueOf().arr.get(new int(new int(3).valueOf()))).valueOf() << new int(24).valueOf())).valueOf());
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u8} p
* @returns {u64}
*/
function hash__wyr8(p) {
p = new $ref(p)
try {
{
return new u64( BigInt(new u64( BigInt(new u64( BigInt(new u64( BigInt(new u64( BigInt(new u64( BigInt(new u64( BigInt(new u64(p.valueOf().arr.get(new int(new int(0).valueOf()))).valueOf()) | BigInt((new u64( BigInt(new u64(p.valueOf().arr.get(new int(new int(1).valueOf()))).valueOf()) << BigInt(new int(8).valueOf()))).valueOf())).valueOf()) | BigInt((new u64( BigInt(new u64(p.valueOf().arr.get(new int(new int(2).valueOf()))).valueOf()) << BigInt(new int(16).valueOf()))).valueOf())).valueOf()) | BigInt((new u64( BigInt(new u64(p.valueOf().arr.get(new int(new int(3).valueOf()))).valueOf()) << BigInt(new int(24).valueOf()))).valueOf())).valueOf()) | BigInt((new u64( BigInt(new u64(p.valueOf().arr.get(new int(new int(4).valueOf()))).valueOf()) << BigInt(new int(32).valueOf()))).valueOf())).valueOf()) | BigInt((new u64( BigInt(new u64(p.valueOf().arr.get(new int(new int(5).valueOf()))).valueOf()) << BigInt(new int(40).valueOf()))).valueOf())).valueOf()) | BigInt((new u64( BigInt(new u64(p.valueOf().arr.get(new int(new int(6).valueOf()))).valueOf()) << BigInt(new int(48).valueOf()))).valueOf())).valueOf()) | BigInt((new u64( BigInt(new u64(p.valueOf().arr.get(new int(new int(7).valueOf()))).valueOf()) << BigInt(new int(56).valueOf()))).valueOf()));
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace rand.seed */
/* [inline] */
/**
* @function
* @param {u32} prev
* @returns {u32}
*/
function rand__seed__nr_next(prev) {
try {
return new u32( new u32( prev.valueOf() * new int(1664525).valueOf()).valueOf() + new int(1013904223).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} count
* @returns {Array_u32}
*/
function rand__seed__time_seed_array(count) {
try {
/** @type {u64} */
const ctime = new u64(time__sys_mono_now());
/** @type {u32} */
let seed = new u32(new u32(new u64( BigInt(new u64( BigInt(ctime.valueOf()) >> BigInt(new int(32).valueOf())).valueOf()) ^ BigInt((new u64( BigInt(ctime.valueOf()) & BigInt(new int(0x00000000FFFFFFFF).valueOf()))).valueOf()))));
/** @type {Array_u32} */
let seed_data = new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)}));
for (let _tmp52 = new int(0); _tmp52 < count; _tmp52 = new int(_tmp52 + 1)) {
try {
/** @type {u32} */
seed = new u32(rand__seed__nr_next(seed));
array_push(seed_data,rand__seed__nr_next(seed),false);
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return seed_data;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [manualfree] */
/**
* @function
* @returns {u32}
*/
function rand__seed__time_seed_32() {
try {
/** @type {Array_u32} */
const sa = rand__seed__time_seed_array(new int(1));
/** @type {u32} */
const res = new u32(sa.arr.get(new int(new int(0).valueOf())));
array_free(sa,);
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [manualfree] */
/**
* @function
* @returns {u64}
*/
function rand__seed__time_seed_64() {
try {
/** @type {Array_u32} */
const seed_data = rand__seed__time_seed_array(new int(2));
/** @type {u64} */
const lower = new u64(new u64(seed_data.arr.get(new int(new int(0).valueOf()))));
/** @type {u64} */
const upper = new u64(new u64(seed_data.arr.get(new int(new int(1).valueOf()))));
array_free(seed_data,);
/** @type {u64} */
const res = new u64(new u64( BigInt(lower.valueOf()) | BigInt((new u64( BigInt(upper.valueOf()) << BigInt(new int(32).valueOf()))).valueOf())));
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace rand.pcg32 */
/** @constant {int} */
const rand__pcg32__seed_len = new int(4);
/**
* @constructor
* @param {{state?: u64, inc?: u64}} init
*/
function rand__pcg32__PCG32RNG({ state = new u64( BigInt(new u64(BigInt(0x853c49e6748fea9bn)).valueOf()) ^ BigInt(rand__seed__time_seed_64().valueOf())), inc = new u64( BigInt(new u64(BigInt(0xda3e39cb94b95bdbn)).valueOf()) ^ BigInt(rand__seed__time_seed_64().valueOf())) }) {
this.state = state
this.inc = inc
};
rand__pcg32__PCG32RNG.prototype = {
...rand__buffer__PRNGBuffer.prototype,
toString() {
return `rand__pcg32__PCG32RNG { state: ${this["state"].toString()} , inc: ${this["inc"].toString()} }`
},
/** @type {u64} */
state: new u64(0),
/** @type {u64} */
inc: new u64(0),
$toJS() { return this; }
};
/**
* @function
* @param {Array_u32} seed_data
* @returns {void}
*/
function rand__pcg32__PCG32RNG_seed(rng, seed_data) {
rng = new $ref(rng)
try {
if ((new bool(seed_data.len.valueOf() != new int(4).valueOf())).valueOf()) {
builtin__eprintln (new string("PCG32RNG needs 4 u32s to be seeded. First two the initial state and the last two the stream/step. Both in little endian format: [lower, higher]."));
builtin__exit(new int(1));
}
/** @type {u64} */
const init_state = new u64(new u64( BigInt(new u64(seed_data.arr.get(new int(new int(0).valueOf()))).valueOf()) | BigInt((new u64( BigInt(new u64(seed_data.arr.get(new int(new int(1).valueOf()))).valueOf()) << BigInt(new int(32).valueOf()))).valueOf())));
/** @type {u64} */
const init_seq = new u64(new u64( BigInt(new u64(seed_data.arr.get(new int(new int(2).valueOf()))).valueOf()) | BigInt((new u64( BigInt(new u64(seed_data.arr.get(new int(new int(3).valueOf()))).valueOf()) << BigInt(new int(32).valueOf()))).valueOf())));
/** @type {u64} */
rng.val.state = new u64(new u64(BigInt(0n)));
/** @type {u64} */
rng.val.inc = new u64(new u64( BigInt((new u64( BigInt(init_seq.valueOf()) << BigInt(new u64(BigInt(1n)).valueOf()))).valueOf()) | BigInt(new u64(BigInt(1n)).valueOf())));
rand__pcg32__PCG32RNG_u32(rng.valueOf(),);
/** @type {u64} */
rng.val.state.val = rng.val.state + new u64(init_state);
rand__pcg32__PCG32RNG_u32(rng.valueOf(),);
/** @type {int} */
rng.val.bytes_left = new int(new int(0));
/** @type {u64} */
rng.val.buffer = new u64(new int(0));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {u8}
*/
function rand__pcg32__PCG32RNG_u8(rng) {
rng = new $ref(rng)
try {
if ((new bool(rng.val.bytes_left.valueOf() >= new int(1).valueOf())).valueOf()) {
/** @type {int} */
rng.val.bytes_left.val = Math.floor(rng.val.bytes_left - new int(new int(1)));
/** @type {u8} */
const value = new u8(new u8(rng.val.buffer));
/** @type {u64} */
rng.val.buffer.val = rng.val.buffer >> new u64(new int(8));
return value;
}
/** @type {u64} */
rng.val.buffer = new u64(rand__pcg32__PCG32RNG_u32(rng.valueOf(),));
/** @type {int} */
rng.val.bytes_left = new int(new int(3));
/** @type {u8} */
const value = new u8(new u8(rng.val.buffer));
/** @type {u64} */
rng.val.buffer.val = rng.val.buffer >> new u64(new int(8));
return value;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {u16}
*/
function rand__pcg32__PCG32RNG_u16(rng) {
rng = new $ref(rng)
try {
if ((new bool(rng.val.bytes_left.valueOf() >= new int(2).valueOf())).valueOf()) {
/** @type {int} */
rng.val.bytes_left.val = Math.floor(rng.val.bytes_left - new int(new int(2)));
/** @type {u16} */
const value = new u16(new u16(rng.val.buffer));
/** @type {u64} */
rng.val.buffer.val = rng.val.buffer >> new u64(new int(16));
return value;
}
/** @type {u32} */
const ans = new u32(rand__pcg32__PCG32RNG_u32(rng.valueOf(),));
/** @type {u64} */
rng.val.buffer = new u64(new u32( ans.valueOf() >> new int(16).valueOf()));
/** @type {int} */
rng.val.bytes_left = new int(new int(2));
return new u16(ans);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {u32}
*/
function rand__pcg32__PCG32RNG_u32(rng) {
rng = new $ref(rng)
try {
/** @type {u64} */
const oldstate = new u64(rng.val.state);
/** @type {u64} */
rng.val.state = new u64(new u64( BigInt(new u64( BigInt(oldstate.valueOf()) * BigInt((new int(6364136223846793005)).valueOf())).valueOf()) + BigInt(rng.val.inc.valueOf())));
/** @type {u32} */
const xorshifted = new u32(new u32(new u64( BigInt((new u64( BigInt((new u64( BigInt(oldstate.valueOf()) >> BigInt(new u64(BigInt(18n)).valueOf()))).valueOf()) ^ BigInt(oldstate.valueOf()))).valueOf()) >> BigInt(new u64(BigInt(27n)).valueOf()))));
/** @type {u32} */
const rot = new u32(new u32(new u64( BigInt(oldstate.valueOf()) >> BigInt(new u64(BigInt(59n)).valueOf()))));
return new u32( (new u32( xorshifted.valueOf() >> rot.valueOf())).valueOf() | (new u32( xorshifted.valueOf() << (new u32( (-rot.val ).valueOf() & new int(31).valueOf())).valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {u64}
*/
function rand__pcg32__PCG32RNG_u64(rng) {
rng = new $ref(rng)
try {
return new u64( BigInt(new u64(rand__pcg32__PCG32RNG_u32(rng.valueOf(),)).valueOf()) | BigInt((new u64( BigInt(new u64(rand__pcg32__PCG32RNG_u32(rng.valueOf(),)).valueOf()) << BigInt(new int(32).valueOf()))).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {int}
*/
function rand__pcg32__PCG32RNG_block_size(rng) {
rng = new $ref(rng)
try {
return new int(32);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [unsafe] */
/**
* @function
* @returns {void}
*/
function rand__pcg32__PCG32RNG_free(rng) {
rng = new $ref(rng)
try {
free(rng);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace rand.config */
/* [params] */
/**
* @constructor
* @param {{seed_?: Array_u32}} init
*/
function rand__config__PRNGConfigStruct({ seed_ = rand__seed__time_seed_array(new int(2)) }) {
this.seed_ = seed_
};
rand__config__PRNGConfigStruct.prototype = {
toString() {
return `rand__config__PRNGConfigStruct { seed_: ${this["seed_"].toString()} }`
},
/** @type {Array_u32} */
seed_: empty_array(),
$toJS() { return this; }
};
/* [params] */
/**
* @constructor
* @param {{mu?: f64, sigma?: f64}} init
*/
function rand__config__NormalConfigStruct({ mu = new f32(0.0), sigma = new f32(1.0) }) {
this.mu = mu
this.sigma = sigma
};
rand__config__NormalConfigStruct.prototype = {
toString() {
return `rand__config__NormalConfigStruct { mu: ${this["mu"].toString()} , sigma: ${this["sigma"].toString()} }`
},
/** @type {f64} */
mu: new f64(0),
/** @type {f64} */
sigma: new f64(0),
$toJS() { return this; }
};
/* [params] */
/**
* @constructor
* @param {{start?: int, end?: int}} init
*/
function rand__config__ShuffleConfigStruct({ start = new int(0), end = new int(0) }) {
this.start = start
this.end = end
};
rand__config__ShuffleConfigStruct.prototype = {
toString() {
return `rand__config__ShuffleConfigStruct { start: ${this["start"].toString()} , end: ${this["end"].toString()} }`
},
/** @type {int} */
start: new int(0),
/** @type {int} */
end: new int(0),
$toJS() { return this; }
};
/** @namespace rand.wyrand */
/**
* @function
* @returns {void}
*/
function rand__wyrand__WyRandRNG_free(r) {
r = new $ref(r)
try {
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace rand.wyrand */
/** @constant {u64} */
let rand__wyrand__wyp0 = undefined;
/** @constant {u64} */
let rand__wyrand__wyp1 = undefined;
/** @constant {int} */
const rand__wyrand__seed_len = new int(2);
/**
* @constructor
* @param {{state?: u64, bytes_left?: int, buffer?: u64}} init
*/
function rand__wyrand__WyRandRNG({ state = rand__seed__time_seed_64(), bytes_left = new int(0), buffer = new u64(0) }) {
this.state = state
this.bytes_left = bytes_left
this.buffer = buffer
};
rand__wyrand__WyRandRNG.prototype = {
...rand__buffer__PRNGBuffer.prototype,
toString() {
return `rand__wyrand__WyRandRNG { state: ${this["state"].toString()} , bytes_left: ${this["bytes_left"].toString()} , buffer: ${this["buffer"].toString()} }`
},
/** @type {u64} */
state: new u64(0),
/** @type {int} */
bytes_left: new int(0),
/** @type {u64} */
buffer: new u64(0),
$toJS() { return this; }
};
/**
* @function
* @param {Array_u32} seed_data
* @returns {void}
*/
function rand__wyrand__WyRandRNG_seed(rng, seed_data) {
rng = new $ref(rng)
try {
if ((new bool(seed_data.len.valueOf() != new int(2).valueOf())).valueOf()) {
builtin__eprintln (new string("WyRandRNG needs 2 32-bit unsigned integers as the seed."));
builtin__exit(new int(1));
}
/** @type {u64} */
rng.val.state = new u64(new u64( BigInt(seed_data.arr.get(new int(new int(0).valueOf())).valueOf()) | BigInt((new u64( BigInt(new u64(seed_data.arr.get(new int(new int(1).valueOf()))).valueOf()) << BigInt(new int(32).valueOf()))).valueOf())));
/** @type {int} */
rng.val.bytes_left = new int(new int(0));
/** @type {u64} */
rng.val.buffer = new u64(new int(0));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {u8}
*/
function rand__wyrand__WyRandRNG_u8(rng) {
rng = new $ref(rng)
try {
if ((new bool(rng.val.bytes_left.valueOf() >= new int(1).valueOf())).valueOf()) {
/** @type {int} */
rng.val.bytes_left.val = Math.floor(rng.val.bytes_left - new int(new int(1)));
/** @type {u8} */
const value = new u8(new u8(rng.val.buffer));
/** @type {u64} */
rng.val.buffer.val = rng.val.buffer >> new u64(new int(8));
return value;
}
/** @type {u64} */
rng.val.buffer = new u64(rand__wyrand__WyRandRNG_u64(rng.valueOf(),));
/** @type {int} */
rng.val.bytes_left = new int(new int(7));
/** @type {u8} */
const value = new u8(new u8(rng.val.buffer));
/** @type {u64} */
rng.val.buffer.val = rng.val.buffer >> new u64(new int(8));
return value;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {u16}
*/
function rand__wyrand__WyRandRNG_u16(rng) {
rng = new $ref(rng)
try {
if ((new bool(rng.val.bytes_left.valueOf() >= new int(2).valueOf())).valueOf()) {
/** @type {int} */
rng.val.bytes_left.val = Math.floor(rng.val.bytes_left - new int(new int(2)));
/** @type {u16} */
const value = new u16(new u16(rng.val.buffer));
/** @type {u64} */
rng.val.buffer.val = rng.val.buffer >> new u64(new int(16));
return value;
}
/** @type {u64} */
const ans = new u64(rand__wyrand__WyRandRNG_u64(rng.valueOf(),));
/** @type {u64} */
rng.val.buffer = new u64(new u64( BigInt(ans.valueOf()) >> BigInt(new int(16).valueOf())));
/** @type {int} */
rng.val.bytes_left = new int(new int(6));
return new u16(ans);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {u32}
*/
function rand__wyrand__WyRandRNG_u32(rng) {
rng = new $ref(rng)
try {
if ((new bool(rng.val.bytes_left.valueOf() >= new int(4).valueOf())).valueOf()) {
/** @type {int} */
rng.val.bytes_left.val = Math.floor(rng.val.bytes_left - new int(new int(4)));
/** @type {u32} */
const value = new u32(new u32(rng.val.buffer));
/** @type {u64} */
rng.val.buffer.val = rng.val.buffer >> new u64(new int(32));
return value;
}
/** @type {u64} */
const ans = new u64(rand__wyrand__WyRandRNG_u64(rng.valueOf(),));
/** @type {u64} */
rng.val.buffer = new u64(new u64( BigInt(ans.valueOf()) >> BigInt(new int(32).valueOf())));
/** @type {int} */
rng.val.bytes_left = new int(new int(4));
return new u32(ans);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {u64}
*/
function rand__wyrand__WyRandRNG_u64(rng) {
rng = new $ref(rng)
try {
{
/** @type {u64} */
let seed1 = new u64(rng.val.state);
/** @type {u64} */
seed1.val = seed1 + new u64(rand__wyrand__wyp0);
/** @type {u64} */
rng.val.state = new u64(seed1);
return hash__wymum(new u64( BigInt(seed1.valueOf()) ^ BigInt(rand__wyrand__wyp1.valueOf())), seed1);
}
return new int(0);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {int}
*/
function rand__wyrand__WyRandRNG_block_size(rng) {
rng = new $ref(rng)
try {
return new int(64);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace rand */
/** @constant {f64} */
const rand__sqrt2 = new f32(1.41421356237309504880168872420969807856967187537694807317667974);
/* [inline] */
/**
* @function
* @param {f64} a
* @returns {f64}
*/
function rand__msqrt(a) {
try {
if ((new bool(a.valueOf() == new int(0).valueOf())).valueOf()) {
return a;
}
/** @type {f64} */
let x = new f64(a);
let [z, ex] = rand__frexp(x);
/** @type {f64} */
const w = new f64(x);
/** @type {f64} */
x = new f64(new f64( new f32(4.173075996388649989089e-1).valueOf() + new f64( new f32(5.9016206709064458299663e-1).valueOf() * z.valueOf()).valueOf()));
if ((new bool((new int( ex.valueOf() & new int(1).valueOf())).valueOf() != new int(0).valueOf())).valueOf()) {
/** @type {f64} */
x.val = Math.floor(x * new f64(rand__sqrt2));
}
/** @type {f64} */
x = new f64(rand__scalbn(x, new int( ex.valueOf() >> new int(1).valueOf())));
/** @type {f64} */
x = new f64(new f64( new f32(0.5).valueOf() * (new f64( x.valueOf() + new f64( w.valueOf() / x.valueOf()).valueOf())).valueOf()));
/** @type {f64} */
x = new f64(new f64( new f32(0.5).valueOf() * (new f64( x.valueOf() + new f64( w.valueOf() / x.valueOf()).valueOf())).valueOf()));
/** @type {f64} */
x = new f64(new f64( new f32(0.5).valueOf() * (new f64( x.valueOf() + new f64( w.valueOf() / x.valueOf()).valueOf())).valueOf()));
return x;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {f64} a
* @returns {f64}
*/
function rand__mlog(a) {
try {
/** @type {f64} */
const ln2_lo = new f64(new f32(1.90821492927058770002e-10));
/** @type {f64} */
const ln2_hi = new f64(new f32(0.693147180369123816490));
/** @type {f64} */
const l1 = new f64(new f32(0.6666666666666735130));
/** @type {f64} */
const l2 = new f64(new f32(0.3999999999940941908));
/** @type {f64} */
const l3 = new f64(new f32(0.2857142874366239149));
/** @type {f64} */
const l4 = new f64(new f32(0.2222219843214978396));
/** @type {f64} */
const l5 = new f64(new f32(0.1818357216161805012));
/** @type {f64} */
const l6 = new f64(new f32(0.1531383769920937332));
/** @type {f64} */
const l7 = new f64(new f32(0.1479819860511658591));
/** @type {f64} */
const x = new f64(a);
let [f1, ki] = rand__frexp(x);
if ((new bool(f1.valueOf() < new f64(new float_literal( rand__sqrt2.valueOf() / new int(2).valueOf())).valueOf())).valueOf()) {
/** @type {f64} */
f1.val = Math.floor(f1 * new f64(new int(2)));
ki.val --;
}
/** @type {f64} */
const f = new f64(new f64( f1.valueOf() - new int(1).valueOf()));
/** @type {f64} */
const k = new f64(new f64(ki));
/** @type {f64} */
const s = new f64(new f64( f.valueOf() / (new f64( new int(2).valueOf() + f.valueOf())).valueOf()));
/** @type {f64} */
const s2 = new f64(new f64( s.valueOf() * s.valueOf()));
/** @type {f64} */
const s4 = new f64(new f64( s2.valueOf() * s2.valueOf()));
/** @type {f64} */
const t1 = new f64(new f64( s2.valueOf() * (new f64( l1.valueOf() + new f64( s4.valueOf() * (new f64( l3.valueOf() + new f64( s4.valueOf() * (new f64( l5.valueOf() + new f64( s4.valueOf() * l7.valueOf()).valueOf())).valueOf()).valueOf())).valueOf()).valueOf())).valueOf()));
/** @type {f64} */
const t2 = new f64(new f64( s4.valueOf() * (new f64( l2.valueOf() + new f64( s4.valueOf() * (new f64( l4.valueOf() + new f64( s4.valueOf() * l6.valueOf()).valueOf())).valueOf()).valueOf())).valueOf()));
/** @type {f64} */
const r = new f64(new f64( t1.valueOf() + t2.valueOf()));
/** @type {f64} */
const hfsq = new f64(new f64( new f64( new f32(0.5).valueOf() * f.valueOf()).valueOf() * f.valueOf()));
return new f64( new f64( k.valueOf() * ln2_hi.valueOf()).valueOf() - (new f64( (new f64( hfsq.valueOf() - (new f64( new f64( s.valueOf() * (new f64( hfsq.valueOf() + r.valueOf())).valueOf()).valueOf() + new f64( k.valueOf() * ln2_lo.valueOf()).valueOf())).valueOf())).valueOf() - f.valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {f64} x
* @returns {multi_return_f64_int}
*/
function rand__frexp(x) {
try {
/** @type {u64} */
let y = new u64(rand__f64_bits(x));
/** @type {int} */
const ee = new int(new int(new u64( BigInt((new u64( BigInt(y.valueOf()) >> BigInt(new int(52).valueOf()))).valueOf()) & BigInt(new int(0x7ff).valueOf()))));
if ((new bool(ee.valueOf() == new int(0).valueOf())).valueOf()) {
if ((new bool(x.valueOf() != new f32(0.0).valueOf())).valueOf()) {
/** @type {f64} */
const x1p64 = new f64(rand__f64_from_bits(new u64(BigInt(0x43f0000000000000n))));
let [z, e_] = rand__frexp(new f64( x.valueOf() * x1p64.valueOf()));
return [z, new int( e_.valueOf() - new int(64).valueOf())];
}
return [x, new int(0)];
} else if ((new bool(ee.valueOf() == new int(0x7ff).valueOf())).valueOf()) {
return [x, new int(0)];
}
/** @type {int} */
const e_ = new int(new int( ee.valueOf() - new int(0x3fe).valueOf()));
/** @type {u64} */
y.val = y & new u64(new u64(BigInt(0x800fffffffffffffn)));
/** @type {u64} */
y.val = y | new u64(new u64(BigInt(0x3fe0000000000000n)));
return [rand__f64_from_bits(y), e_];
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {f64} x
* @param {int} n_
* @returns {f64}
*/
function rand__scalbn(x, n_) {
try {
/** @type {int} */
let n = new int(n_);
/** @type {f64} */
const x1p1023 = new f64(rand__f64_from_bits(new u64(BigInt(0x7fe0000000000000n))));
/** @type {f64} */
const x1p53 = new f64(rand__f64_from_bits(new u64(BigInt(0x4340000000000000n))));
/** @type {f64} */
const x1p_1022 = new f64(rand__f64_from_bits(new u64(BigInt(0x0010000000000000n))));
/** @type {f64} */
let y = new f64(x);
if ((new bool(n.valueOf() > new int(1023).valueOf())).valueOf()) {
/** @type {f64} */
y.val = Math.floor(y * new f64(x1p1023));
/** @type {int} */
n.val = Math.floor(n - new int(new int(1023)));
if ((new bool(n.valueOf() > new int(1023).valueOf())).valueOf()) {
/** @type {f64} */
y.val = Math.floor(y * new f64(x1p1023));
/** @type {int} */
n.val = Math.floor(n - new int(new int(1023)));
if ((new bool(n.valueOf() > new int(1023).valueOf())).valueOf()) {
/** @type {int} */
n = new int(new int(1023));
}
}
} else if ((new bool(n.valueOf() < new int(-1022).valueOf())).valueOf()) {
/** @type {f64} */
y.val = Math.floor(y * new f64(new f64( x1p_1022.valueOf() * x1p53.valueOf())));
/** @type {int} */
n.val = Math.floor(n + new int(new int(969)));
if ((new bool(n.valueOf() < new int(-1022).valueOf())).valueOf()) {
/** @type {f64} */
y.val = Math.floor(y * new f64(new f64( x1p_1022.valueOf() * x1p53.valueOf())));
/** @type {int} */
n.val = Math.floor(n + new int(new int(969)));
if ((new bool(n.valueOf() < new int(-1022).valueOf())).valueOf()) {
/** @type {int} */
n = new int(new int(-1022));
}
}
}
return new f64( y.valueOf() * rand__f64_from_bits(new u64( BigInt(new u64((new int( new int(0x3ff).valueOf() + n.valueOf()))).valueOf()) << BigInt(new int(52).valueOf()))).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u64} b
* @returns {f64}
*/
function rand__f64_from_bits(b) {
try {
return (new $ref(new f64(new $ref(b)))).valueOf();
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {f64} f
* @returns {u64}
*/
function rand__f64_bits(f) {
try {
return (new $ref(new u64(new $ref(f)))).valueOf();
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace rand */
/**
* @function
* @returns {void}
*/
function rand__init() {
try {
/** @type {rand__PRNG} */
default_rng.val = rand__new_default(new rand__config__PRNGConfigStruct({})).val;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {rand__PRNG} rng
* @param {string} charset
* @param {Array_u8} buf
* @returns {void}
*/
function rand__internal_fill_buffer_from_set(rng, charset, buf) {
buf = new $ref(buf)
try {
builtin__panic (new string("todo"));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {rand__PRNG} rng
* @param {string} charset
* @param {int} len
* @returns {string}
*/
function rand__internal_string_from_set(rng, charset, len) {
try {
/** @type {string} */
const result = new string(new string(""));
const characters = charset.str;
const charactersLength = characters.length;
for (let i = 0;i < len.val;i++)
result.str += characters.charAt(Math.random() * charactersLength);
return result;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @constant {string} */
const rand__ulid_encoding = new string("0123456789ABCDEFGHJKMNPQRSTVWXYZ");
/**
* @function
* @param {rand__PRNG} rng
* @param {u64} unix_time_milli
* @returns {string}
*/
function rand__internal_ulid_at_millisecond(rng, unix_time_milli) {
try {
/** @type {Array_u8} */
let buf = new array(new array_buffer({arr: [], len: new int(0), cap: new int(0)}));
/** @type {u64} */
let t = new u64(unix_time_milli);
/** @type {int} */
let i = new int(new int(9));
while (+new bool(i.valueOf() >= new int(0).valueOf())) {
try {
/** @type {u8} */
buf.arr.set(new int(i.valueOf()),new u8(new u8(rand__ulid_encoding.str.charCodeAt(new int(new u64( BigInt(t.valueOf()) & BigInt(new int(0x1f).valueOf())))))));
/** @type {u64} */
t = new u64(new u64( BigInt(t.valueOf()) >> BigInt(new int(5).valueOf())));
i.val --;
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {u64} */
let x = new u64(rng.valueOf().u64());
/** @type {int} */
i = new int(new int(10));
while (+new bool(i.valueOf() < new int(19).valueOf())) {
try {
/** @type {u8} */
buf.arr.set(new int(i.valueOf()),new u8(new u8(rand__ulid_encoding.str.charCodeAt(new int(new u64( BigInt(x.valueOf()) & BigInt(new int(0x1f).valueOf())))))));
/** @type {u64} */
x = new u64(new u64( BigInt(x.valueOf()) >> BigInt(new int(5).valueOf())));
i.val ++;
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {u64} */
x = new u64(rng.valueOf().u64());
while (+new bool(i.valueOf() < new int(26).valueOf())) {
try {
/** @type {u8} */
buf.arr.set(new int(i.valueOf()),new u8(new u8(rand__ulid_encoding.str.charCodeAt(new int(new u64( BigInt(x.valueOf()) & BigInt(new int(0x1f).valueOf())))))));
/** @type {u64} */
x = new u64(new u64( BigInt(x.valueOf()) >> BigInt(new int(5).valueOf())));
i.val ++;
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {string} */
const res = new string(new string(""));
builtin__println (Array_u8_str(buf));
res.str = buf.arr.arr.map(String.fromCharCode).join('')
return res;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {rand__PRNG} rng
* @param {Array_u8} buf
* @returns {void}
*/
function rand__read_internal(rng, buf) {
buf = new $ref(buf)
try {
for (let i = new int(0); i < buf.val.len; i = new int(i + 1)) {
try {
/** @type {u8} */
buf.valueOf().arr.set(new int(i.valueOf()),new u8(rng.valueOf().u8()));
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace rand */
/**
* @interface rand__PRNG
* @typedef rand__PRNG
* @property {(seed_data: Array_u32) => void} seed
* @property {() => u8} u8
* @property {() => u16} u16
* @property {() => u32} u32
* @property {() => u64} u64
* @property {() => int} block_size
* @property {() => void} free
*/
function rand__PRNG (arg) { return new $ref(arg); }
/* [inline] */
/**
* @function
* @param {int} bytes_needed
* @returns {Array_u8}
*/
function rand__PRNG_bytes(rng, bytes_needed) {
try {
if ((new bool(bytes_needed.valueOf() < new int(0).valueOf())).valueOf()) {
return error(new string("can not read < 0 random bytes"));
}
/** @type {Array_u8} */
let buffer = new array(new array_buffer({arr: (function(length) {
const _tmp53 = [];
for (let it = 0; it < length; it++) {
_tmp53.push(new u8(0));
};
return _tmp53;
})(bytes_needed),len: new int(bytes_needed), cap: new int(bytes_needed)}));
rand__read_internal(rng, buffer);
return buffer;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_u8} buf
* @returns {void}
*/
function rand__PRNG_read(rng, buf) {
buf = new $ref(buf)
try {
rand__read_internal(rng, buf);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u32} max
* @returns {u32}
*/
function rand__PRNG_u32n(rng, max) {
try {
if ((new bool(max.valueOf() == new int(0).valueOf())).valueOf()) {
return error(new string("max must be positive integer"));
}
/** @type {int} */
const bit_len = new int(math__bits__len_32(max));
if (((new bool(bit_len.valueOf() == new int(32).valueOf()))).valueOf()) {
while (true) {
try {
/** @type {u32} */
const value = new u32(rng.valueOf().u32());
if ((new bool(value.valueOf() < max.valueOf())).valueOf()) {
return value;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} else {
/** @type {u32} */
const mask = new u32((((new bool(bit_len.valueOf() == new int(31).valueOf()))).valueOf() ? new int(0x7FFFFFFF) : new u32( (new u32( new int(1).valueOf() << (new int( bit_len.valueOf() + new int(1).valueOf())).valueOf())).valueOf() - new int(1).valueOf())));
while (true) {
try {
/** @type {u32} */
const value = new u32(new u32( rng.valueOf().u32().valueOf() & mask.valueOf()));
if ((new bool(value.valueOf() < max.valueOf())).valueOf()) {
return value;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
}
return new int(0);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u64} max
* @returns {u64}
*/
function rand__PRNG_u64n(rng, max) {
try {
if ((new bool(max.valueOf() == new int(0).valueOf())).valueOf()) {
return error(new string("max must be positive integer"));
}
/** @type {int} */
const bit_len = new int(math__bits__len_64(max));
if (((new bool(bit_len.valueOf() == new int(64).valueOf()))).valueOf()) {
while (true) {
try {
/** @type {u64} */
const value = new u64(rng.valueOf().u64());
if ((new bool(value.valueOf() < max.valueOf())).valueOf()) {
return value;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
} else {
/** @type {u64} */
const mask = new u64((((new bool(bit_len.valueOf() == new int(63).valueOf()))).valueOf() ? new u64(BigInt(0x7FFFFFFFFFFFFFFFn)) : new u64( BigInt((new u64( BigInt(new u64(BigInt(1n)).valueOf()) << BigInt((new int( bit_len.valueOf() + new int(1).valueOf())).valueOf()))).valueOf()) - BigInt(new int(1).valueOf()))));
while (true) {
try {
/** @type {u64} */
const value = new u64(new u64( BigInt(rng.valueOf().u64().valueOf()) & BigInt(mask.valueOf())));
if ((new bool(value.valueOf() < max.valueOf())).valueOf()) {
return value;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
}
return new u64(BigInt(0n));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u32} min
* @param {u32} max
* @returns {u32}
*/
function rand__PRNG_u32_in_range(rng, min, max) {
try {
if ((new bool(max.valueOf() <= min.valueOf())).valueOf()) {
return error(new string("max must be greater than min"));
}
return new u32( min.valueOf() + rand__PRNG_u32n(rng.valueOf(),new u32( max.valueOf() - min.valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {u64} min
* @param {u64} max
* @returns {u64}
*/
function rand__PRNG_u64_in_range(rng, min, max) {
try {
if ((new bool(max.valueOf() <= min.valueOf())).valueOf()) {
return error(new string("max must be greater than min"));
}
return new u64( BigInt(min.valueOf()) + BigInt(rand__PRNG_u64n(rng.valueOf(),new u64( BigInt(max.valueOf()) - BigInt(min.valueOf()))).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {i8}
*/
function rand__PRNG_i8(rng) {
try {
return new i8(rng.valueOf().u8());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {i16}
*/
function rand__PRNG_i16(rng) {
try {
return new i16(rng.valueOf().u16());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {int}
*/
function rand__PRNG_int(rng) {
try {
return new int(rng.valueOf().u32());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {i64}
*/
function rand__PRNG_i64(rng) {
try {
return new i64(rng.valueOf().u64());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {int}
*/
function rand__PRNG_int31(rng) {
try {
return new int(new u32( rng.valueOf().u32().valueOf() & rand__constants__u31_mask.valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {i64}
*/
function rand__PRNG_int63(rng) {
try {
return new i64(new u64( BigInt(rng.valueOf().u64().valueOf()) & BigInt(rand__constants__u63_mask.valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {int} max
* @returns {int}
*/
function rand__PRNG_intn(rng, max) {
try {
if ((new bool(max.valueOf() <= new int(0).valueOf())).valueOf()) {
return error(new string("max has to be positive."));
}
return new int(rand__PRNG_u32n(rng.valueOf(),new u32(max)));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {i64} max
* @returns {i64}
*/
function rand__PRNG_i64n(rng, max) {
try {
if ((new bool(max.valueOf() <= new int(0).valueOf())).valueOf()) {
return error(new string("max has to be positive."));
}
return new i64(rand__PRNG_u64n(rng.valueOf(),new u64(max)));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {int} min
* @param {int} max
* @returns {int}
*/
function rand__PRNG_int_in_range(rng, min, max) {
try {
if ((new bool(max.valueOf() <= min.valueOf())).valueOf()) {
return error(new string("max must be greater than min"));
}
return new int( min.valueOf() + rand__PRNG_intn(rng.valueOf(),new int( max.valueOf() - min.valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {i64} min
* @param {i64} max
* @returns {i64}
*/
function rand__PRNG_i64_in_range(rng, min, max) {
try {
if ((new bool(max.valueOf() <= min.valueOf())).valueOf()) {
return error(new string("max must be greater than min"));
}
return new i64( BigInt(min.valueOf()) + BigInt(rand__PRNG_i64n(rng.valueOf(),new i64( BigInt(max.valueOf()) - BigInt(min.valueOf()))).valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {f32}
*/
function rand__PRNG_f32(rng) {
try {
return new f32(new f64( (new u32( rng.valueOf().u32().valueOf() >> new int(9).valueOf())).valueOf() * rand__constants__reciprocal_2_23rd.valueOf()));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {f32}
*/
function rand__PRNG_f32cp(rng) {
try {
/** @type {u32} */
let x = new u32(rng.valueOf().u32());
/** @type {u32} */
let exp = new u32(new int(126));
/** @type {u32} */
let mask = new u32(new u32( new int(1).valueOf() << new int(31).valueOf()));
if (((new bool(x.valueOf() == new int(0).valueOf()))).valueOf()) {
/** @type {u32} */
x = new u32(rng.valueOf().u32());
/** @type {u32} */
exp.val = Math.floor(exp - new u32(new int(31)));
}
while (true) {
try {
if ((new bool(new u32( x.valueOf() & mask.valueOf()).valueOf() != new int(0).valueOf())).valueOf()) {
/** @type {u32} */
mask.val = Math.floor(mask >> new u32(new int(1)));
/** @type {u32} */
exp.val = Math.floor(exp - new u32(new int(1)));
} else {
break;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
if ((new bool(exp.valueOf() < (new int(118)).valueOf())).valueOf()) {
/** @type {u32} */
x = new u32(rng.valueOf().u32());
}
/** @type {u32} */
x = new u32(new u32( (new u32( exp.valueOf() << new int(23).valueOf())).valueOf() | new u32( (new u32( x.valueOf() >> new int(8).valueOf())).valueOf() & rand__constants__ieee754_mantissa_f32_mask.valueOf()).valueOf()));
return math__bits__f32_from_bits(x);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {f64}
*/
function rand__PRNG_f64(rng) {
try {
return new f64(new f64( BigInt((new u64( BigInt(rng.valueOf().u64().valueOf()) >> BigInt(new int(12).valueOf()))).valueOf()) * BigInt(rand__constants__reciprocal_2_52nd.valueOf())));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @returns {f64}
*/
function rand__PRNG_f64cp(rng) {
try {
/** @type {u64} */
let x = new u64(rng.valueOf().u64());
/** @type {u64} */
let exp = new u64(new u64(BigInt(1022n)));
/** @type {u64} */
let mask = new u64(new u64( BigInt(new u64(BigInt(1n)).valueOf()) << BigInt(new int(63).valueOf())));
/** @type {u32} */
let bitcount = new u32(new int(0));
if (((new bool(x.valueOf() == new int(0).valueOf()))).valueOf()) {
/** @type {u64} */
x = new u64(rng.valueOf().u64());
/** @type {u64} */
exp.val = exp - new u64(new int(31));
}
while (true) {
try {
if ((new bool(new u64( BigInt(x.valueOf()) & BigInt(mask.valueOf())).valueOf() != new int(0).valueOf())).valueOf()) {
/** @type {u64} */
mask.val = mask >> new u64(new int(1));
/** @type {u32} */
bitcount.val = Math.floor(bitcount + new u32(new int(1)));
} else {
break;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
/** @type {u64} */
exp.val = exp - new u64(bitcount);
if ((new bool(bitcount.valueOf() > new int(11).valueOf())).valueOf()) {
/** @type {u64} */
x = new u64(rng.valueOf().u64());
}
/** @type {u64} */
x = new u64(new u64( BigInt((new u64( BigInt(exp.valueOf()) << BigInt(new int(52).valueOf()))).valueOf()) | BigInt((new u64( BigInt(x.valueOf()) & BigInt(rand__constants__ieee754_mantissa_f64_mask.valueOf()))).valueOf())));
return math__bits__f64_from_bits(x);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {f32} max
* @returns {f32}
*/
function rand__PRNG_f32n(rng, max) {
try {
if ((new bool(max.valueOf() < new int(0).valueOf())).valueOf()) {
return error(new string("max has to be non-negative."));
}
return new f32( rand__PRNG_f32(rng.valueOf(),).valueOf() * max.valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {f64} max
* @returns {f64}
*/
function rand__PRNG_f64n(rng, max) {
try {
if ((new bool(max.valueOf() < new int(0).valueOf())).valueOf()) {
return error(new string("max has to be non-negative."));
}
return new f64( rand__PRNG_f64(rng.valueOf(),).valueOf() * max.valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {f32} min
* @param {f32} max
* @returns {f32}
*/
function rand__PRNG_f32_in_range(rng, min, max) {
try {
if ((new bool(max.valueOf() < min.valueOf())).valueOf()) {
return error(new string("max must be greater than or equal to min"));
}
return new f32( min.valueOf() + rand__PRNG_f32n(rng.valueOf(),new f32( max.valueOf() - min.valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {f64} min
* @param {f64} max
* @returns {f64}
*/
function rand__PRNG_f64_in_range(rng, min, max) {
try {
if ((new bool(max.valueOf() < min.valueOf())).valueOf()) {
return error(new string("max must be greater than or equal to min"));
}
return new f64( min.valueOf() + rand__PRNG_f64n(rng.valueOf(),new f64( max.valueOf() - min.valueOf())).valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {string}
*/
function rand__PRNG_ulid(rng) {
try {
return rand__internal_ulid_at_millisecond(rng, new u64(time__Time_unix_milli(time__utc(),)));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} unix_time_milli
* @returns {string}
*/
function rand__PRNG_ulid_at_millisecond(rng, unix_time_milli) {
try {
return rand__internal_ulid_at_millisecond(rng, unix_time_milli);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} charset
* @param {int} len
* @returns {string}
*/
function rand__PRNG_string_from_set(rng, charset, len) {
try {
return rand__internal_string_from_set(rng, charset, len);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} len
* @returns {string}
*/
function rand__PRNG_string(rng, len) {
try {
return rand__internal_string_from_set(rng, rand__english_letters, len);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} len
* @returns {string}
*/
function rand__PRNG_hex(rng, len) {
try {
return rand__internal_string_from_set(rng, rand__hex_chars, len);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} len
* @returns {string}
*/
function rand__PRNG_ascii(rng, len) {
try {
return rand__internal_string_from_set(rng, rand__ascii_chars, len);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {string} charset
* @param {Array_u8} buf
* @returns {void}
*/
function rand__PRNG_fill_buffer_from_set(rng, charset, buf) {
buf = new $ref(buf)
try {
rand__internal_fill_buffer_from_set(rng, charset, buf);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {f64} p
* @returns {bool}
*/
function rand__PRNG_bernoulli(rng, p) {
try {
if ((new bool( new bool(p.valueOf() < new int(0).valueOf()).valueOf() || new bool(p.valueOf() > new int(1).valueOf()).valueOf())).valueOf()) {
return error(new string(`${f64_str(p)} is not a valid probability value.`));
}
return new bool(rand__PRNG_f64(rng.valueOf(),).valueOf() <= p.valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {rand__config__NormalConfigStruct} conf
* @returns {f64}
*/
function rand__PRNG_normal(rng, conf) {
try {
let [x, ] = rand__PRNG_normal_pair(rng.valueOf(),conf);
return x;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {rand__config__NormalConfigStruct} conf
* @returns {multi_return_f64_f64}
*/
function rand__PRNG_normal_pair(rng, conf) {
try {
if ((new bool(conf.sigma.valueOf() <= new int(0).valueOf())).valueOf()) {
return error(new string("Standard deviation must be positive"));
}
while (true) {
try {
/** @type {f64} */
const u = new f64(rand__PRNG_f64_in_range(rng.valueOf(),new int(-1), new int(1)));
/** @type {f64} */
const v = new f64(rand__PRNG_f64_in_range(rng.valueOf(),new int(-1), new int(1)));
/** @type {f64} */
const s = new f64(new f64( new f64( u.valueOf() * u.valueOf()).valueOf() + new f64( v.valueOf() * v.valueOf()).valueOf()));
if ((new bool( new bool(s.valueOf() >= new int(1).valueOf()).valueOf() || new bool(s.valueOf() == new int(0).valueOf()).valueOf())).valueOf()) {
continue;
}
/** @type {f64} */
const t = new f64(rand__msqrt(new f64( new f64( new int(-2).valueOf() * rand__mlog(s).valueOf()).valueOf() / s.valueOf())));
/** @type {f64} */
const x = new f64(new f64( conf.mu.valueOf() + new f64( new f64( conf.sigma.valueOf() * t.valueOf()).valueOf() * u.valueOf()).valueOf()));
/** @type {f64} */
const y = new f64(new f64( conf.mu.valueOf() + new f64( new f64( conf.sigma.valueOf() * t.valueOf()).valueOf() * v.valueOf()).valueOf()));
return [x, y];
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return error(new string("Implementation error. Please file an issue."));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} n
* @param {f64} p
* @returns {int}
*/
function rand__PRNG_binomial(rng, n, p) {
try {
if ((new bool( new bool(p.valueOf() < new int(0).valueOf()).valueOf() || new bool(p.valueOf() > new int(1).valueOf()).valueOf())).valueOf()) {
return error(new string(`${f64_str(p)} is not a valid probability value.`));
}
/** @type {int} */
let count = new int(new int(0));
for (let _tmp54 = new int(0); _tmp54 < n; _tmp54 = new int(_tmp54 + 1)) {
try {
if ((rand__PRNG_bernoulli(rng.valueOf(),p)).valueOf()) {
count.val ++;
}
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
return count;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {f64} lambda
* @returns {f64}
*/
function rand__PRNG_exponential(rng, lambda) {
try {
if ((new bool(lambda.valueOf() <= new int(0).valueOf())).valueOf()) {
builtin__panic (new string("The rate (lambda) must be positive."));
}
return new f64( -rand__mlog(rand__PRNG_f64(rng.valueOf(),)).val .valueOf() / lambda.valueOf());
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
Object.defineProperty($global,"default_rng", {
configurable: false,
enumerable: true ,
writable: true,
value: new $ref({})
}
); // global
/* [manualfree] */
/**
* @function
* @param {rand__config__PRNGConfigStruct} config_
* @returns {rand__PRNG}
*/
function rand__new_default(config_) {
try {
/** @type {rand__wyrand__WyRandRNG} */
let rng = new $ref(new rand__wyrand__WyRandRNG({}));
rand__wyrand__WyRandRNG_seed(rng.valueOf(),config_.seed_);
array_free(config_.seed_,);
return new $ref(new rand__PRNG(rng));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {rand__PRNG}
*/
function rand__get_current_rng() {
try {
return default_rng;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {rand__PRNG} rng
* @returns {void}
*/
function rand__set_rng(rng) {
try {
/** @type {rand__PRNG} */
default_rng.val = rng.val;
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_u32} seed
* @returns {void}
*/
function rand__seed(seed) {
try {
default_rng.valueOf().seed(seed);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {u8}
*/
function rand__u8() {
try {
return default_rng.valueOf().u8();
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {u16}
*/
function rand__u16() {
try {
return default_rng.valueOf().u16();
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {u32}
*/
function rand__u32() {
try {
return default_rng.valueOf().u32();
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {u64}
*/
function rand__u64() {
try {
return default_rng.valueOf().u64();
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} max
* @returns {u32}
*/
function rand__u32n(max) {
try {
return rand__PRNG_u32n(default_rng.valueOf(),max);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} max
* @returns {u64}
*/
function rand__u64n(max) {
try {
return rand__PRNG_u64n(default_rng.valueOf(),max);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u32} min
* @param {u32} max
* @returns {u32}
*/
function rand__u32_in_range(min, max) {
try {
return rand__PRNG_u32_in_range(default_rng.valueOf(),min, max);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} min
* @param {u64} max
* @returns {u64}
*/
function rand__u64_in_range(min, max) {
try {
return rand__PRNG_u64_in_range(default_rng.valueOf(),min, max);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {i16}
*/
function rand__i16() {
try {
return rand__PRNG_i16(default_rng.valueOf(),);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {int}
*/
function rand__int() {
try {
return rand__PRNG_int(default_rng.valueOf(),);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} max
* @returns {int}
*/
function rand__intn(max) {
try {
return rand__PRNG_intn(default_rng.valueOf(),max);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} min
* @param {int} max
* @returns {int}
*/
function rand__int_in_range(min, max) {
try {
return rand__PRNG_int_in_range(default_rng.valueOf(),min, max);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {int}
*/
function rand__int31() {
try {
return rand__PRNG_int31(default_rng.valueOf(),);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {i64}
*/
function rand__i64() {
try {
return rand__PRNG_i64(default_rng.valueOf(),);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {i64} max
* @returns {i64}
*/
function rand__i64n(max) {
try {
return rand__PRNG_i64n(default_rng.valueOf(),max);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {i64} min
* @param {i64} max
* @returns {i64}
*/
function rand__i64_in_range(min, max) {
try {
return rand__PRNG_i64_in_range(default_rng.valueOf(),min, max);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {i64}
*/
function rand__int63() {
try {
return rand__PRNG_int63(default_rng.valueOf(),);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {f32}
*/
function rand__f32() {
try {
return rand__PRNG_f32(default_rng.valueOf(),);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {f32}
*/
function rand__f32cp() {
try {
return rand__PRNG_f32cp(default_rng.valueOf(),);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {f64}
*/
function rand__f64() {
try {
return rand__PRNG_f64(default_rng.valueOf(),);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @returns {f64}
*/
function rand__f64cp() {
try {
return rand__PRNG_f64cp(default_rng.valueOf(),);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {f32} max
* @returns {f32}
*/
function rand__f32n(max) {
try {
return rand__PRNG_f32n(default_rng.valueOf(),max);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {f64} max
* @returns {f64}
*/
function rand__f64n(max) {
try {
return rand__PRNG_f64n(default_rng.valueOf(),max);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {f32} min
* @param {f32} max
* @returns {f32}
*/
function rand__f32_in_range(min, max) {
try {
return rand__PRNG_f32_in_range(default_rng.valueOf(),min, max);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {f64} min
* @param {f64} max
* @returns {f64}
*/
function rand__f64_in_range(min, max) {
try {
return rand__PRNG_f64_in_range(default_rng.valueOf(),min, max);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} bytes_needed
* @returns {Array_u8}
*/
function rand__bytes(bytes_needed) {
try {
return rand__PRNG_bytes(default_rng.valueOf(),bytes_needed);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {Array_u8} buf
* @returns {void}
*/
function rand__read(buf) {
buf = new $ref(buf)
try {
rand__read_internal(default_rng, buf);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @constant {string} */
const rand__english_letters = new string("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
/** @constant {string} */
const rand__hex_chars = new string("abcdef0123456789");
/** @constant {string} */
const rand__ascii_chars = new string("!\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\^_`abcdefghijklmnopqrstuvwxyz{|}~");
/**
* @function
* @returns {string}
*/
function rand__ulid() {
try {
return rand__PRNG_ulid(default_rng.valueOf(),);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {u64} unix_time_milli
* @returns {string}
*/
function rand__ulid_at_millisecond(unix_time_milli) {
try {
return rand__PRNG_ulid_at_millisecond(default_rng.valueOf(),unix_time_milli);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {string} charset
* @param {int} len
* @returns {string}
*/
function rand__string_from_set(charset, len) {
try {
return rand__PRNG_string_from_set(default_rng.valueOf(),charset, len);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* [inline] */
/**
* @function
* @param {string} charset
* @param {Array_u8} buf
* @returns {void}
*/
function rand__fill_buffer_from_set(charset, buf) {
buf = new $ref(buf)
try {
rand__PRNG_fill_buffer_from_set(default_rng.valueOf(),charset, buf);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} len
* @returns {string}
*/
function rand__string(len) {
try {
return rand__string_from_set(rand__english_letters, len);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} len
* @returns {string}
*/
function rand__hex(len) {
try {
return rand__string_from_set(rand__hex_chars, len);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} len
* @returns {string}
*/
function rand__ascii(len) {
try {
return rand__string_from_set(rand__ascii_chars, len);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {f64} p
* @returns {bool}
*/
function rand__bernoulli(p) {
try {
return rand__PRNG_bernoulli(default_rng.valueOf(),p);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {rand__config__NormalConfigStruct} config_
* @returns {f64}
*/
function rand__normal(config_) {
try {
return rand__PRNG_normal(default_rng.valueOf(),config_);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {rand__config__NormalConfigStruct} config_
* @returns {multi_return_f64_f64}
*/
function rand__normal_pair(config_) {
try {
return rand__PRNG_normal_pair(default_rng.valueOf(),config_);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {int} n
* @param {f64} p
* @returns {int}
*/
function rand__binomial(n, p) {
try {
return rand__PRNG_binomial(default_rng.valueOf(),n, p);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/**
* @function
* @param {f64} lambda
* @returns {f64}
*/
function rand__exponential(lambda) {
try {
return rand__PRNG_exponential(default_rng.valueOf(),lambda);
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/** @namespace main */
/**
* @function
* @param {int} i
* @returns {void}
*/
function main__run(i) {
try {
builtin__println (new string(`hello from thread ${int_str(i)}`));
/** @type {rand__PRNG} */
let rng = new $ref(new rand__PRNG(new rand__pcg32__PCG32RNG({})));
rng.valueOf().seed(rand__seed__time_seed_array(rand__pcg32__seed_len));
/** @type {i64} */
const duration = new i64(rand__PRNG_i64_in_range(rng.valueOf(),new int(100000), new int(1000000)));
time__sleep(duration);
builtin__println (new string(`goodbye from thread ${int_str(i)}`));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
/* program entry point */
async function js_main() {
try {
for (let i = new int(new int(0)); +new bool(i.valueOf() < new int(10).valueOf()); i.val ++) {
try {
new _v_Promise({promise: new Promise(function(resolve){
resolve(main__run(i));})});
;
} catch (e) {
if (e instanceof BreakException) { break; }
else if (e instanceof ContinueException) { continue; }
else { throw e; } }
}
time__sleep(new int(10000000));
} catch (e) {
if (e instanceof ReturnException) { return e.val; }
throw e;
}
}
None__.prototype.msg = function() {
return IError_msg(this)
}
None__.prototype.code = function() {
return IError_code(this)
}
None__.prototype.str = function() {
return None___str(this)
}
Error.prototype.msg = function() {
return Error_msg(this)
}
Error.prototype.code = function() {
return Error_code(this)
}
Error.prototype.str = function() {
return IError_str(this)
}
MessageError.prototype.msg = function() {
return MessageError_msg(this)
}
MessageError.prototype.code = function() {
return MessageError_code(this)
}
MessageError.prototype.str = function() {
return MessageError_str(this)
}
time__TimeParseError.prototype.msg = function() {
return time__TimeParseError_msg(this)
}
time__TimeParseError.prototype.code = function() {
return IError_code(this)
}
time__TimeParseError.prototype.str = function() {
return IError_str(this)
}
rand__pcg32__PCG32RNG.prototype.seed = function(seed_data) {
return rand__pcg32__PCG32RNG_seed(this,seed_data)
}
rand__pcg32__PCG32RNG.prototype.u8 = function() {
return rand__pcg32__PCG32RNG_u8(this)
}
rand__pcg32__PCG32RNG.prototype.u16 = function() {
return rand__pcg32__PCG32RNG_u16(this)
}
rand__pcg32__PCG32RNG.prototype.u32 = function() {
return rand__pcg32__PCG32RNG_u32(this)
}
rand__pcg32__PCG32RNG.prototype.u64 = function() {
return rand__pcg32__PCG32RNG_u64(this)
}
rand__pcg32__PCG32RNG.prototype.block_size = function() {
return rand__pcg32__PCG32RNG_block_size(this)
}
rand__pcg32__PCG32RNG.prototype.free = function() {
return rand__pcg32__PCG32RNG_free(this)
}
rand__pcg32__PCG32RNG.prototype.bytes = function(bytes_needed) {
return rand__PRNG_bytes(this,bytes_needed)
}
rand__pcg32__PCG32RNG.prototype.read = function(buf) {
return rand__PRNG_read(this,buf)
}
rand__pcg32__PCG32RNG.prototype.u32n = function(max) {
return rand__PRNG_u32n(this,max)
}
rand__pcg32__PCG32RNG.prototype.u64n = function(max) {
return rand__PRNG_u64n(this,max)
}
rand__pcg32__PCG32RNG.prototype.u32_in_range = function(min,max) {
return rand__PRNG_u32_in_range(this,min,max)
}
rand__pcg32__PCG32RNG.prototype.u64_in_range = function(min,max) {
return rand__PRNG_u64_in_range(this,min,max)
}
rand__pcg32__PCG32RNG.prototype.i8 = function() {
return rand__PRNG_i8(this)
}
rand__pcg32__PCG32RNG.prototype.i16 = function() {
return rand__PRNG_i16(this)
}
rand__pcg32__PCG32RNG.prototype.int = function() {
return rand__PRNG_int(this)
}
rand__pcg32__PCG32RNG.prototype.i64 = function() {
return rand__PRNG_i64(this)
}
rand__pcg32__PCG32RNG.prototype.int31 = function() {
return rand__PRNG_int31(this)
}
rand__pcg32__PCG32RNG.prototype.int63 = function() {
return rand__PRNG_int63(this)
}
rand__pcg32__PCG32RNG.prototype.intn = function(max) {
return rand__PRNG_intn(this,max)
}
rand__pcg32__PCG32RNG.prototype.i64n = function(max) {
return rand__PRNG_i64n(this,max)
}
rand__pcg32__PCG32RNG.prototype.int_in_range = function(min,max) {
return rand__PRNG_int_in_range(this,min,max)
}
rand__pcg32__PCG32RNG.prototype.i64_in_range = function(min,max) {
return rand__PRNG_i64_in_range(this,min,max)
}
rand__pcg32__PCG32RNG.prototype.f32 = function() {
return rand__PRNG_f32(this)
}
rand__pcg32__PCG32RNG.prototype.f32cp = function() {
return rand__PRNG_f32cp(this)
}
rand__pcg32__PCG32RNG.prototype.f64 = function() {
return rand__PRNG_f64(this)
}
rand__pcg32__PCG32RNG.prototype.f64cp = function() {
return rand__PRNG_f64cp(this)
}
rand__pcg32__PCG32RNG.prototype.f32n = function(max) {
return rand__PRNG_f32n(this,max)
}
rand__pcg32__PCG32RNG.prototype.f64n = function(max) {
return rand__PRNG_f64n(this,max)
}
rand__pcg32__PCG32RNG.prototype.f32_in_range = function(min,max) {
return rand__PRNG_f32_in_range(this,min,max)
}
rand__pcg32__PCG32RNG.prototype.f64_in_range = function(min,max) {
return rand__PRNG_f64_in_range(this,min,max)
}
rand__pcg32__PCG32RNG.prototype.ulid = function() {
return rand__PRNG_ulid(this)
}
rand__pcg32__PCG32RNG.prototype.ulid_at_millisecond = function(unix_time_milli) {
return rand__PRNG_ulid_at_millisecond(this,unix_time_milli)
}
rand__pcg32__PCG32RNG.prototype.string_from_set = function(charset,len) {
return rand__PRNG_string_from_set(this,charset,len)
}
rand__pcg32__PCG32RNG.prototype.string = function(len) {
return rand__PRNG_string(this,len)
}
rand__pcg32__PCG32RNG.prototype.hex = function(len) {
return rand__PRNG_hex(this,len)
}
rand__pcg32__PCG32RNG.prototype.ascii = function(len) {
return rand__PRNG_ascii(this,len)
}
rand__pcg32__PCG32RNG.prototype.fill_buffer_from_set = function(charset,buf) {
return rand__PRNG_fill_buffer_from_set(this,charset,buf)
}
rand__pcg32__PCG32RNG.prototype.bernoulli = function(p) {
return rand__PRNG_bernoulli(this,p)
}
rand__pcg32__PCG32RNG.prototype.normal = function(conf) {
return rand__PRNG_normal(this,conf)
}
rand__pcg32__PCG32RNG.prototype.normal_pair = function(conf) {
return rand__PRNG_normal_pair(this,conf)
}
rand__pcg32__PCG32RNG.prototype.binomial = function(n,p) {
return rand__PRNG_binomial(this,n,p)
}
rand__pcg32__PCG32RNG.prototype.exponential = function(lambda) {
return rand__PRNG_exponential(this,lambda)
}
rand__pcg32__PCG32RNG.prototype.shuffle = function(a,config_) {
return rand__PRNG_shuffle(this,a,config_)
}
rand__pcg32__PCG32RNG.prototype.shuffle_clone = function(a,config_) {
return rand__PRNG_shuffle_clone(this,a,config_)
}
rand__pcg32__PCG32RNG.prototype.choose = function(array,k) {
return rand__PRNG_choose(this,array,k)
}
rand__pcg32__PCG32RNG.prototype.element = function(array) {
return rand__PRNG_element(this,array)
}
rand__pcg32__PCG32RNG.prototype.sample = function(array,k) {
return rand__PRNG_sample(this,array,k)
}
rand__wyrand__WyRandRNG.prototype.seed = function(seed_data) {
return rand__wyrand__WyRandRNG_seed(this,seed_data)
}
rand__wyrand__WyRandRNG.prototype.u8 = function() {
return rand__wyrand__WyRandRNG_u8(this)
}
rand__wyrand__WyRandRNG.prototype.u16 = function() {
return rand__wyrand__WyRandRNG_u16(this)
}
rand__wyrand__WyRandRNG.prototype.u32 = function() {
return rand__wyrand__WyRandRNG_u32(this)
}
rand__wyrand__WyRandRNG.prototype.u64 = function() {
return rand__wyrand__WyRandRNG_u64(this)
}
rand__wyrand__WyRandRNG.prototype.block_size = function() {
return rand__wyrand__WyRandRNG_block_size(this)
}
rand__wyrand__WyRandRNG.prototype.free = function() {
return rand__wyrand__WyRandRNG_free(this)
}
rand__wyrand__WyRandRNG.prototype.bytes = function(bytes_needed) {
return rand__PRNG_bytes(this,bytes_needed)
}
rand__wyrand__WyRandRNG.prototype.read = function(buf) {
return rand__PRNG_read(this,buf)
}
rand__wyrand__WyRandRNG.prototype.u32n = function(max) {
return rand__PRNG_u32n(this,max)
}
rand__wyrand__WyRandRNG.prototype.u64n = function(max) {
return rand__PRNG_u64n(this,max)
}
rand__wyrand__WyRandRNG.prototype.u32_in_range = function(min,max) {
return rand__PRNG_u32_in_range(this,min,max)
}
rand__wyrand__WyRandRNG.prototype.u64_in_range = function(min,max) {
return rand__PRNG_u64_in_range(this,min,max)
}
rand__wyrand__WyRandRNG.prototype.i8 = function() {
return rand__PRNG_i8(this)
}
rand__wyrand__WyRandRNG.prototype.i16 = function() {
return rand__PRNG_i16(this)
}
rand__wyrand__WyRandRNG.prototype.int = function() {
return rand__PRNG_int(this)
}
rand__wyrand__WyRandRNG.prototype.i64 = function() {
return rand__PRNG_i64(this)
}
rand__wyrand__WyRandRNG.prototype.int31 = function() {
return rand__PRNG_int31(this)
}
rand__wyrand__WyRandRNG.prototype.int63 = function() {
return rand__PRNG_int63(this)
}
rand__wyrand__WyRandRNG.prototype.intn = function(max) {
return rand__PRNG_intn(this,max)
}
rand__wyrand__WyRandRNG.prototype.i64n = function(max) {
return rand__PRNG_i64n(this,max)
}
rand__wyrand__WyRandRNG.prototype.int_in_range = function(min,max) {
return rand__PRNG_int_in_range(this,min,max)
}
rand__wyrand__WyRandRNG.prototype.i64_in_range = function(min,max) {
return rand__PRNG_i64_in_range(this,min,max)
}
rand__wyrand__WyRandRNG.prototype.f32 = function() {
return rand__PRNG_f32(this)
}
rand__wyrand__WyRandRNG.prototype.f32cp = function() {
return rand__PRNG_f32cp(this)
}
rand__wyrand__WyRandRNG.prototype.f64 = function() {
return rand__PRNG_f64(this)
}
rand__wyrand__WyRandRNG.prototype.f64cp = function() {
return rand__PRNG_f64cp(this)
}
rand__wyrand__WyRandRNG.prototype.f32n = function(max) {
return rand__PRNG_f32n(this,max)
}
rand__wyrand__WyRandRNG.prototype.f64n = function(max) {
return rand__PRNG_f64n(this,max)
}
rand__wyrand__WyRandRNG.prototype.f32_in_range = function(min,max) {
return rand__PRNG_f32_in_range(this,min,max)
}
rand__wyrand__WyRandRNG.prototype.f64_in_range = function(min,max) {
return rand__PRNG_f64_in_range(this,min,max)
}
rand__wyrand__WyRandRNG.prototype.ulid = function() {
return rand__PRNG_ulid(this)
}
rand__wyrand__WyRandRNG.prototype.ulid_at_millisecond = function(unix_time_milli) {
return rand__PRNG_ulid_at_millisecond(this,unix_time_milli)
}
rand__wyrand__WyRandRNG.prototype.string_from_set = function(charset,len) {
return rand__PRNG_string_from_set(this,charset,len)
}
rand__wyrand__WyRandRNG.prototype.string = function(len) {
return rand__PRNG_string(this,len)
}
rand__wyrand__WyRandRNG.prototype.hex = function(len) {
return rand__PRNG_hex(this,len)
}
rand__wyrand__WyRandRNG.prototype.ascii = function(len) {
return rand__PRNG_ascii(this,len)
}
rand__wyrand__WyRandRNG.prototype.fill_buffer_from_set = function(charset,buf) {
return rand__PRNG_fill_buffer_from_set(this,charset,buf)
}
rand__wyrand__WyRandRNG.prototype.bernoulli = function(p) {
return rand__PRNG_bernoulli(this,p)
}
rand__wyrand__WyRandRNG.prototype.normal = function(conf) {
return rand__PRNG_normal(this,conf)
}
rand__wyrand__WyRandRNG.prototype.normal_pair = function(conf) {
return rand__PRNG_normal_pair(this,conf)
}
rand__wyrand__WyRandRNG.prototype.binomial = function(n,p) {
return rand__PRNG_binomial(this,n,p)
}
rand__wyrand__WyRandRNG.prototype.exponential = function(lambda) {
return rand__PRNG_exponential(this,lambda)
}
rand__wyrand__WyRandRNG.prototype.shuffle = function(a,config_) {
return rand__PRNG_shuffle(this,a,config_)
}
rand__wyrand__WyRandRNG.prototype.shuffle_clone = function(a,config_) {
return rand__PRNG_shuffle_clone(this,a,config_)
}
rand__wyrand__WyRandRNG.prototype.choose = function(array,k) {
return rand__PRNG_choose(this,array,k)
}
rand__wyrand__WyRandRNG.prototype.element = function(array) {
return rand__PRNG_element(this,array)
}
rand__wyrand__WyRandRNG.prototype.sample = function(array,k) {
return rand__PRNG_sample(this,array,k)
}
// Initializations for module strings
// Initializations for module math.bits
math__bits__de_bruijn32 = new int(0x077CB531);
math__bits__de_bruijn32tab = new array(new array_buffer({arr: [new u8(new int(0)), new u8(new int(1)), new u8(new int(28)), new u8(new int(2)), new u8(new int(29)), new u8(new int(14)), new u8(new int(24)), new u8(new int(3)), new u8(new int(30)), new u8(new int(22)), new u8(new int(20)), new u8(new int(15)), new u8(new int(25)), new u8(new int(17)), new u8(new int(4)), new u8(new int(8)), new u8(new int(31)), new u8(new int(27)), new u8(new int(13)), new u8(new int(23)), new u8(new int(21)), new u8(new int(19)), new u8(new int(16)), new u8(new int(7)), new u8(new int(26)), new u8(new int(12)), new u8(new int(18)), new u8(new int(6)), new u8(new int(11)), new u8(new int(5)), new u8(new int(10)), new u8(new int(9))], len: new int(32), cap: new int(32)}));
math__bits__de_bruijn64 = new u64(BigInt(0x03f79d71b4ca8b09n));
math__bits__de_bruijn64tab = new array(new array_buffer({arr: [new u8(new int(0)), new u8(new int(1)), new u8(new int(56)), new u8(new int(2)), new u8(new int(57)), new u8(new int(49)), new u8(new int(28)), new u8(new int(3)), new u8(new int(61)), new u8(new int(58)), new u8(new int(42)), new u8(new int(50)), new u8(new int(38)), new u8(new int(29)), new u8(new int(17)), new u8(new int(4)), new u8(new int(62)), new u8(new int(47)), new u8(new int(59)), new u8(new int(36)), new u8(new int(45)), new u8(new int(43)), new u8(new int(51)), new u8(new int(22)), new u8(new int(53)), new u8(new int(39)), new u8(new int(33)), new u8(new int(30)), new u8(new int(24)), new u8(new int(18)), new u8(new int(12)), new u8(new int(5)), new u8(new int(63)), new u8(new int(55)), new u8(new int(48)), new u8(new int(27)), new u8(new int(60)), new u8(new int(41)), new u8(new int(37)), new u8(new int(16)), new u8(new int(46)), new u8(new int(35)), new u8(new int(44)), new u8(new int(21)), new u8(new int(52)), new u8(new int(32)), new u8(new int(23)), new u8(new int(11)), new u8(new int(54)), new u8(new int(26)), new u8(new int(40)), new u8(new int(15)), new u8(new int(34)), new u8(new int(20)), new u8(new int(31)), new u8(new int(10)), new u8(new int(25)), new u8(new int(14)), new u8(new int(19)), new u8(new int(9)), new u8(new int(13)), new u8(new int(8)), new u8(new int(7)), new u8(new int(6))], len: new int(64), cap: new int(64)}));
math__bits__m0 = new u64(BigInt(0x5555555555555555n));
math__bits__m1 = new u64(BigInt(0x3333333333333333n));
math__bits__m2 = new u64(BigInt(0x0f0f0f0f0f0f0f0fn));
math__bits__m3 = new u64(BigInt(0x00ff00ff00ff00ffn));
math__bits__m4 = new u64(BigInt(0x0000ffff0000ffffn));
math__bits__n8 = new int(8);
math__bits__n16 = new int(16);
math__bits__n32 = new int(32);
math__bits__n64 = new u64(BigInt(64n));
math__bits__two32 = new u64(BigInt(0x100000000n));
math__bits__mask32 = new u64( BigInt(math__bits__two32.valueOf()) - BigInt(new int(1).valueOf()));
math__bits__ntz_8_tab = new array(new array_buffer({arr: [new u8(new int(0x08)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x03)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x04)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x03)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x05)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x03)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x04)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x03)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x06)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x03)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x04)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x03)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x05)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x03)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x04)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x03)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x07)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x03)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x04)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x03)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x05)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x03)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x04)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x03)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x06)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x03)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x04)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x03)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x05)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x03)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x04)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x03)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00)), new u8(new int(0x02)), new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x00))], len: new int(256), cap: new int(256)}));
math__bits__pop_8_tab = new array(new array_buffer({arr: [new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x01)), new u8(new int(0x02)), new u8(new int(0x01)), new u8(new int(0x02)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x01)), new u8(new int(0x02)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x01)), new u8(new int(0x02)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x01)), new u8(new int(0x02)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x01)), new u8(new int(0x02)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x07)), new u8(new int(0x01)), new u8(new int(0x02)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x07)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x07)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x07)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x07)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x07)), new u8(new int(0x06)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x08))], len: new int(256), cap: new int(256)}));
math__bits__rev_8_tab = new array(new array_buffer({arr: [new u8(new int(0x00)), new u8(new int(0x80)), new u8(new int(0x40)), new u8(new int(0xc0)), new u8(new int(0x20)), new u8(new int(0xa0)), new u8(new int(0x60)), new u8(new int(0xe0)), new u8(new int(0x10)), new u8(new int(0x90)), new u8(new int(0x50)), new u8(new int(0xd0)), new u8(new int(0x30)), new u8(new int(0xb0)), new u8(new int(0x70)), new u8(new int(0xf0)), new u8(new int(0x08)), new u8(new int(0x88)), new u8(new int(0x48)), new u8(new int(0xc8)), new u8(new int(0x28)), new u8(new int(0xa8)), new u8(new int(0x68)), new u8(new int(0xe8)), new u8(new int(0x18)), new u8(new int(0x98)), new u8(new int(0x58)), new u8(new int(0xd8)), new u8(new int(0x38)), new u8(new int(0xb8)), new u8(new int(0x78)), new u8(new int(0xf8)), new u8(new int(0x04)), new u8(new int(0x84)), new u8(new int(0x44)), new u8(new int(0xc4)), new u8(new int(0x24)), new u8(new int(0xa4)), new u8(new int(0x64)), new u8(new int(0xe4)), new u8(new int(0x14)), new u8(new int(0x94)), new u8(new int(0x54)), new u8(new int(0xd4)), new u8(new int(0x34)), new u8(new int(0xb4)), new u8(new int(0x74)), new u8(new int(0xf4)), new u8(new int(0x0c)), new u8(new int(0x8c)), new u8(new int(0x4c)), new u8(new int(0xcc)), new u8(new int(0x2c)), new u8(new int(0xac)), new u8(new int(0x6c)), new u8(new int(0xec)), new u8(new int(0x1c)), new u8(new int(0x9c)), new u8(new int(0x5c)), new u8(new int(0xdc)), new u8(new int(0x3c)), new u8(new int(0xbc)), new u8(new int(0x7c)), new u8(new int(0xfc)), new u8(new int(0x02)), new u8(new int(0x82)), new u8(new int(0x42)), new u8(new int(0xc2)), new u8(new int(0x22)), new u8(new int(0xa2)), new u8(new int(0x62)), new u8(new int(0xe2)), new u8(new int(0x12)), new u8(new int(0x92)), new u8(new int(0x52)), new u8(new int(0xd2)), new u8(new int(0x32)), new u8(new int(0xb2)), new u8(new int(0x72)), new u8(new int(0xf2)), new u8(new int(0x0a)), new u8(new int(0x8a)), new u8(new int(0x4a)), new u8(new int(0xca)), new u8(new int(0x2a)), new u8(new int(0xaa)), new u8(new int(0x6a)), new u8(new int(0xea)), new u8(new int(0x1a)), new u8(new int(0x9a)), new u8(new int(0x5a)), new u8(new int(0xda)), new u8(new int(0x3a)), new u8(new int(0xba)), new u8(new int(0x7a)), new u8(new int(0xfa)), new u8(new int(0x06)), new u8(new int(0x86)), new u8(new int(0x46)), new u8(new int(0xc6)), new u8(new int(0x26)), new u8(new int(0xa6)), new u8(new int(0x66)), new u8(new int(0xe6)), new u8(new int(0x16)), new u8(new int(0x96)), new u8(new int(0x56)), new u8(new int(0xd6)), new u8(new int(0x36)), new u8(new int(0xb6)), new u8(new int(0x76)), new u8(new int(0xf6)), new u8(new int(0x0e)), new u8(new int(0x8e)), new u8(new int(0x4e)), new u8(new int(0xce)), new u8(new int(0x2e)), new u8(new int(0xae)), new u8(new int(0x6e)), new u8(new int(0xee)), new u8(new int(0x1e)), new u8(new int(0x9e)), new u8(new int(0x5e)), new u8(new int(0xde)), new u8(new int(0x3e)), new u8(new int(0xbe)), new u8(new int(0x7e)), new u8(new int(0xfe)), new u8(new int(0x01)), new u8(new int(0x81)), new u8(new int(0x41)), new u8(new int(0xc1)), new u8(new int(0x21)), new u8(new int(0xa1)), new u8(new int(0x61)), new u8(new int(0xe1)), new u8(new int(0x11)), new u8(new int(0x91)), new u8(new int(0x51)), new u8(new int(0xd1)), new u8(new int(0x31)), new u8(new int(0xb1)), new u8(new int(0x71)), new u8(new int(0xf1)), new u8(new int(0x09)), new u8(new int(0x89)), new u8(new int(0x49)), new u8(new int(0xc9)), new u8(new int(0x29)), new u8(new int(0xa9)), new u8(new int(0x69)), new u8(new int(0xe9)), new u8(new int(0x19)), new u8(new int(0x99)), new u8(new int(0x59)), new u8(new int(0xd9)), new u8(new int(0x39)), new u8(new int(0xb9)), new u8(new int(0x79)), new u8(new int(0xf9)), new u8(new int(0x05)), new u8(new int(0x85)), new u8(new int(0x45)), new u8(new int(0xc5)), new u8(new int(0x25)), new u8(new int(0xa5)), new u8(new int(0x65)), new u8(new int(0xe5)), new u8(new int(0x15)), new u8(new int(0x95)), new u8(new int(0x55)), new u8(new int(0xd5)), new u8(new int(0x35)), new u8(new int(0xb5)), new u8(new int(0x75)), new u8(new int(0xf5)), new u8(new int(0x0d)), new u8(new int(0x8d)), new u8(new int(0x4d)), new u8(new int(0xcd)), new u8(new int(0x2d)), new u8(new int(0xad)), new u8(new int(0x6d)), new u8(new int(0xed)), new u8(new int(0x1d)), new u8(new int(0x9d)), new u8(new int(0x5d)), new u8(new int(0xdd)), new u8(new int(0x3d)), new u8(new int(0xbd)), new u8(new int(0x7d)), new u8(new int(0xfd)), new u8(new int(0x03)), new u8(new int(0x83)), new u8(new int(0x43)), new u8(new int(0xc3)), new u8(new int(0x23)), new u8(new int(0xa3)), new u8(new int(0x63)), new u8(new int(0xe3)), new u8(new int(0x13)), new u8(new int(0x93)), new u8(new int(0x53)), new u8(new int(0xd3)), new u8(new int(0x33)), new u8(new int(0xb3)), new u8(new int(0x73)), new u8(new int(0xf3)), new u8(new int(0x0b)), new u8(new int(0x8b)), new u8(new int(0x4b)), new u8(new int(0xcb)), new u8(new int(0x2b)), new u8(new int(0xab)), new u8(new int(0x6b)), new u8(new int(0xeb)), new u8(new int(0x1b)), new u8(new int(0x9b)), new u8(new int(0x5b)), new u8(new int(0xdb)), new u8(new int(0x3b)), new u8(new int(0xbb)), new u8(new int(0x7b)), new u8(new int(0xfb)), new u8(new int(0x07)), new u8(new int(0x87)), new u8(new int(0x47)), new u8(new int(0xc7)), new u8(new int(0x27)), new u8(new int(0xa7)), new u8(new int(0x67)), new u8(new int(0xe7)), new u8(new int(0x17)), new u8(new int(0x97)), new u8(new int(0x57)), new u8(new int(0xd7)), new u8(new int(0x37)), new u8(new int(0xb7)), new u8(new int(0x77)), new u8(new int(0xf7)), new u8(new int(0x0f)), new u8(new int(0x8f)), new u8(new int(0x4f)), new u8(new int(0xcf)), new u8(new int(0x2f)), new u8(new int(0xaf)), new u8(new int(0x6f)), new u8(new int(0xef)), new u8(new int(0x1f)), new u8(new int(0x9f)), new u8(new int(0x5f)), new u8(new int(0xdf)), new u8(new int(0x3f)), new u8(new int(0xbf)), new u8(new int(0x7f)), new u8(new int(0xff))], len: new int(256), cap: new int(256)}));
math__bits__len_8_tab = new array(new array_buffer({arr: [new u8(new int(0x00)), new u8(new int(0x01)), new u8(new int(0x02)), new u8(new int(0x02)), new u8(new int(0x03)), new u8(new int(0x03)), new u8(new int(0x03)), new u8(new int(0x03)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x04)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x05)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x06)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x07)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08)), new u8(new int(0x08))], len: new int(256), cap: new int(256)}));
// Initializations for module builtin
none__ = new IError(new $ref(new None__({})));
min_i8 = new int(-128);
max_i8 = new int(127);
min_i16 = new int(-32768);
max_i16 = new int(32767);
min_i32 = new int(-2147483648);
max_i32 = new int(2147483647);
min_int = min_i32;
max_int = max_i32;
min_i64 = new i64(new int_literal( new int(-9223372036854775807).valueOf() - new int(1).valueOf()));
max_i64 = new i64(BigInt(9223372036854775807n));
min_u8 = new int(0);
max_u8 = new int(255);
min_u16 = new int(0);
max_u16 = new int(65535);
min_u32 = new int(0);
max_u32 = new int(4294967295);
min_u64 = new u64(BigInt(0n));
max_u64 = new u64(BigInt(18446744073709551615n));
// Initializations for module time
time__nanosecond = new time__Duration(new int(1));
time__microsecond = new time__Duration(new int_literal( BigInt(new int(1000).valueOf()) * BigInt(time__nanosecond.valueOf())));
time__millisecond = new time__Duration(new int_literal( BigInt(new int(1000).valueOf()) * BigInt(time__microsecond.valueOf())));
time__second = new time__Duration(new int_literal( BigInt(new int(1000).valueOf()) * BigInt(time__millisecond.valueOf())));
time__minute = new time__Duration(new int_literal( BigInt(new int(60).valueOf()) * BigInt(time__second.valueOf())));
time__hour = new time__Duration(new int_literal( BigInt(new int(60).valueOf()) * BigInt(time__minute.valueOf())));
time__infinite = new time__Duration(new i64(BigInt(9223372036854775807n)));
time__tokens_2 = new array(new array_buffer({arr: [new string(new string("MM")), new string(new string("Mo")), new string(new string("DD")), new string(new string("Do")), new string(new string("YY")), new string(new string("ss")), new string(new string("kk")), new string(new string("NN")), new string(new string("mm")), new string(new string("hh")), new string(new string("HH")), new string(new string("ii")), new string(new string("ZZ")), new string(new string("dd")), new string(new string("Qo")), new string(new string("QQ")), new string(new string("wo")), new string(new string("ww"))], len: new int(18), cap: new int(18)}));
time__tokens_3 = new array(new array_buffer({arr: [new string(new string("MMM")), new string(new string("DDD")), new string(new string("ZZZ")), new string(new string("ddd"))], len: new int(4), cap: new int(4)}));
time__tokens_4 = new array(new array_buffer({arr: [new string(new string("MMMM")), new string(new string("DDDD")), new string(new string("DDDo")), new string(new string("dddd")), new string(new string("YYYY"))], len: new int(5), cap: new int(5)}));
time__long_days = new array(new array_buffer({arr: [new string(new string("Monday")), new string(new string("Tuesday")), new string(new string("Wednesday")), new string(new string("Thursday")), new string(new string("Friday")), new string(new string("Saturday")), new string(new string("Sunday"))], len: new int(7), cap: new int(7)}));
time__month_days = new array(new array_buffer({arr: [new int(new int(31)), new int(new int(28)), new int(new int(31)), new int(new int(30)), new int(new int(31)), new int(new int(30)), new int(new int(31)), new int(new int(31)), new int(new int(30)), new int(new int(31)), new int(new int(30)), new int(new int(31))], len: new int(12), cap: new int(12)}));
time__long_months = new array(new array_buffer({arr: [new string(new string("January")), new string(new string("February")), new string(new string("March")), new string(new string("April")), new string(new string("May")), new string(new string("June")), new string(new string("July")), new string(new string("August")), new string(new string("September")), new string(new string("October")), new string(new string("November")), new string(new string("December"))], len: new int(12), cap: new int(12)}));
time__absolute_zero_year = new i64(BigInt(-292277022399n));
time__seconds_per_hour = new int_literal( new int(60).valueOf() * time__seconds_per_minute.valueOf());
time__seconds_per_day = new int_literal( new int(24).valueOf() * time__seconds_per_hour.valueOf());
time__seconds_per_week = new int_literal( new int(7).valueOf() * time__seconds_per_day.valueOf());
time__days_per_400_years = new int_literal( new int_literal( time__days_in_year.valueOf() * new int(400).valueOf()).valueOf() + new int(97).valueOf());
time__days_per_100_years = new int_literal( new int_literal( time__days_in_year.valueOf() * new int(100).valueOf()).valueOf() + new int(24).valueOf());
time__days_per_4_years = new int_literal( new int_literal( time__days_in_year.valueOf() * new int(4).valueOf()).valueOf() + new int(1).valueOf());
time__days_before = new array(new array_buffer({arr: [new int(new int(0)), new int(new int(31)), new int(new int(59)), new int(new int(90)), new int(new int(120)), new int(new int(151)), new int(new int(181)), new int(new int(212)), new int(new int(243)), new int(new int(273)), new int(new int(304)), new int(new int(334)), new int(new int(365))], len: new int(13), cap: new int(13)}));
// Initializations for module sync.threads
// Initializations for module rand.constants
rand__constants__lower_mask = new u64(BigInt(0x00000000FFFFFFFFn));
rand__constants__max_u32 = new int(0xFFFFFFFF);
rand__constants__max_u64 = new u64(BigInt(0xFFFFFFFFFFFFFFFFn));
rand__constants__u31_mask = new int(0x7FFFFFFF);
rand__constants__u63_mask = new u64(BigInt(0x7FFFFFFFFFFFFFFFn));
rand__constants__ieee754_mantissa_f32_mask = new u32( (new u32( new int(1).valueOf() << new int(23).valueOf())).valueOf() - new int(1).valueOf());
rand__constants__ieee754_mantissa_f64_mask = new u64( BigInt((new u64( BigInt(new u64(BigInt(1n)).valueOf()) << BigInt(new int(52).valueOf()))).valueOf()) - BigInt(new int(1).valueOf()));
rand__constants__reciprocal_2_23rd = new f64( new f32(1.0).valueOf() / new f64(new u32( new int(1).valueOf() << new int(23).valueOf())).valueOf());
rand__constants__reciprocal_2_52nd = new f64( new f32(1.0).valueOf() / new f64(new u64( BigInt(new u64(BigInt(1n)).valueOf()) << BigInt(new int(52).valueOf()))).valueOf());
// Initializations for module rand.buffer
// Initializations for module hash
hash__wyp0 = new u64(BigInt(0xa0761d6478bd642fn));
hash__wyp1 = new u64(BigInt(0xe7037ed1a0b428dbn));
hash__wyp2 = new u64(BigInt(0x8ebc6af09c88c6e3n));
hash__wyp3 = new u64(BigInt(0x589965cc75374cc3n));
hash__wyp4 = new u64(BigInt(0x1d8e4e27c47d124fn));
// Initializations for module rand.seed
// Initializations for module rand.pcg32
// Initializations for module rand.config
// Initializations for module rand.wyrand
rand__wyrand__wyp0 = new u64(BigInt(0xa0761d6478bd642fn));
rand__wyrand__wyp1 = new u64(BigInt(0xe7037ed1a0b428dbn));
// Initializations for module rand
rand__init();
// Initializations for module main
loadRoutine().then(_ => js_main());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment