#!/usr/bin/env node "use strict"; function require( path ){ return $node[ path ] }; var $node = $node || {} void function( module ) { var exports = module.exports = this; function require( id ) { return $node[ id.replace( /^.\// , "../" ) ] }; ; "use strict"; Error.stackTraceLimit = 50; var $; (function ($) { })($ || ($ = {})); module.exports = $; ; $node[ "../mam.ts" ] = $node[ "../mam.ts" ] = module.exports }.call( {} , {} ) ; "use strict" var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if ((d = decorators[i])) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var $ = ( typeof module === 'object' ) ? ( module['export'+'s'] = globalThis ) : globalThis $.$$ = $ ; "use strict"; var $; (function ($) { $.$mol_ambient_ref = Symbol('$mol_ambient_ref'); function $mol_ambient(overrides) { return Object.setPrototypeOf(overrides, this || $); } $.$mol_ambient = $mol_ambient; })($ || ($ = {})); ; "use strict"; var $; (function ($) { const instances = new WeakSet(); function $mol_delegate(proto, target) { const proxy = new Proxy(proto, { get: (_, field) => { const obj = target(); let val = Reflect.get(obj, field); if (typeof val === 'function') { val = val.bind(obj); } return val; }, has: (_, field) => Reflect.has(target(), field), set: (_, field, value) => Reflect.set(target(), field, value), getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field), ownKeys: () => Reflect.ownKeys(target()), getPrototypeOf: () => Reflect.getPrototypeOf(target()), setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor), isExtensible: () => Reflect.isExtensible(target()), preventExtensions: () => Reflect.preventExtensions(target()), apply: (_, self, args) => Reflect.apply(target(), self, args), construct: (_, args, retarget) => Reflect.construct(target(), args, retarget), defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr), deleteProperty: (_, field) => Reflect.deleteProperty(target(), field), }); instances.add(proxy); return proxy; } $.$mol_delegate = $mol_delegate; Reflect.defineProperty($mol_delegate, Symbol.hasInstance, { value: (obj) => instances.has(obj), }); })($ || ($ = {})); ; "use strict"; var $; (function ($) { $.$mol_owning_map = new WeakMap(); function $mol_owning_allow(having) { try { if (!having) return false; if (typeof having !== 'object' && typeof having !== 'function') return false; if (having instanceof $mol_delegate) return false; if (typeof having['destructor'] !== 'function') return false; return true; } catch { return false; } } $.$mol_owning_allow = $mol_owning_allow; function $mol_owning_get(having, Owner) { if (!$mol_owning_allow(having)) return null; while (true) { const owner = $.$mol_owning_map.get(having); if (!owner) return owner; if (!Owner) return owner; if (owner instanceof Owner) return owner; having = owner; } } $.$mol_owning_get = $mol_owning_get; function $mol_owning_check(owner, having) { if (!$mol_owning_allow(having)) return false; if ($.$mol_owning_map.get(having) !== owner) return false; return true; } $.$mol_owning_check = $mol_owning_check; function $mol_owning_catch(owner, having) { if (!$mol_owning_allow(having)) return false; if ($.$mol_owning_map.get(having)) return false; $.$mol_owning_map.set(having, owner); return true; } $.$mol_owning_catch = $mol_owning_catch; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_fail(error) { throw error; } $.$mol_fail = $mol_fail; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_fail_hidden(error) { throw error; } $.$mol_fail_hidden = $mol_fail_hidden; })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { const named = new WeakSet(); function $mol_func_name(func) { let name = func.name; if (name?.length > 1) return name; if (named.has(func)) return name; for (let key in this) { try { if (this[key] !== func) continue; name = key; Object.defineProperty(func, 'name', { value: name }); break; } catch { } } named.add(func); return name; } $.$mol_func_name = $mol_func_name; function $mol_func_name_from(target, source) { Object.defineProperty(target, 'name', { value: source.name }); return target; } $.$mol_func_name_from = $mol_func_name_from; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_object2 { static $ = $; [Symbol.toStringTag]; [$mol_ambient_ref] = null; get $() { if (this[$mol_ambient_ref]) return this[$mol_ambient_ref]; const owner = $mol_owning_get(this); return this[$mol_ambient_ref] = owner?.$ || $mol_object2.$; } set $(next) { if (this[$mol_ambient_ref]) $mol_fail_hidden(new Error('Context already defined')); this[$mol_ambient_ref] = next; } static create(init) { const obj = new this; if (init) init(obj); return obj; } static [Symbol.toPrimitive]() { return this.toString(); } static toString() { return this[Symbol.toStringTag] || this.$.$mol_func_name(this); } static toJSON() { return this.toString(); } destructor() { } static destructor() { } toString() { return this[Symbol.toStringTag] || this.constructor.name + '<>'; } } $.$mol_object2 = $mol_object2; })($ || ($ = {})); ; "use strict"; var $; (function ($_1) { let $$; (function ($$) { let $; })($$ = $_1.$$ || ($_1.$$ = {})); $_1.$mol_object_field = Symbol('$mol_object_field'); class $mol_object extends $mol_object2 { static make(config) { return super.create(obj => { for (let key in config) obj[key] = config[key]; }); } } $_1.$mol_object = $mol_object; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_guid(length = 8, exists = () => false) { for (;;) { let id = Math.random().toString(36).substring(2, length + 2).toUpperCase(); if (exists(id)) continue; return id; } } $.$mol_guid = $mol_guid; })($ || ($ = {})); ; "use strict"; var $; (function ($) { let $mol_wire_cursor; (function ($mol_wire_cursor) { $mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale"; $mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt"; $mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh"; $mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final"; })($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_wire_pub extends Object { constructor(id = `$mol_wire_pub:${$mol_guid()}`) { super(); this[Symbol.toStringTag] = id; } [Symbol.toStringTag]; data = []; static get [Symbol.species]() { return Array; } sub_from = 0; get sub_list() { const res = []; for (let i = this.sub_from; i < this.data.length; i += 2) { res.push(this.data[i]); } return res; } get sub_empty() { return this.sub_from === this.data.length; } sub_on(sub, pub_pos) { const pos = this.data.length; this.data.push(sub, pub_pos); return pos; } sub_off(sub_pos) { if (!(sub_pos < this.data.length)) { $mol_fail(new Error(`Wrong pos ${sub_pos}`)); } const end = this.data.length - 2; if (sub_pos !== end) { this.peer_move(end, sub_pos); } this.data.length = end; if (end === this.sub_from) this.reap(); } reap() { } promote() { $mol_wire_auto()?.track_next(this); } fresh() { } complete() { } get incompleted() { return false; } emit(quant = $mol_wire_cursor.stale) { for (let i = this.sub_from; i < this.data.length; i += 2) { ; this.data[i].absorb(quant, this.data[i + 1]); } } peer_move(from_pos, to_pos) { const peer = this.data[from_pos]; const self_pos = this.data[from_pos + 1]; this.data[to_pos] = peer; this.data[to_pos + 1] = self_pos; peer.peer_repos(self_pos, to_pos); } peer_repos(peer_pos, self_pos) { this.data[peer_pos + 1] = self_pos; } } $.$mol_wire_pub = $mol_wire_pub; })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { $.$mol_wire_auto_sub = null; function $mol_wire_auto(next = $.$mol_wire_auto_sub) { return $.$mol_wire_auto_sub = next; } $.$mol_wire_auto = $mol_wire_auto; $.$mol_wire_affected = []; })($ || ($ = {})); ; "use strict"; var $; (function ($) { $['devtoolsFormatters'] ||= []; function $mol_dev_format_register(config) { $['devtoolsFormatters'].push(config); } $.$mol_dev_format_register = $mol_dev_format_register; $.$mol_dev_format_head = Symbol('$mol_dev_format_head'); $.$mol_dev_format_body = Symbol('$mol_dev_format_body'); $mol_dev_format_register({ header: (val, config = false) => { if (config) return null; if (!val) return null; if ($.$mol_dev_format_head in val) { try { return val[$.$mol_dev_format_head](); } catch (error) { return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), ''); } } if (typeof val === 'function') { return $mol_dev_format_native(val); } if (Symbol.toStringTag in val) { return $mol_dev_format_native(val); } return null; }, hasBody: val => val[$.$mol_dev_format_body], body: val => val[$.$mol_dev_format_body](), }); function $mol_dev_format_native(obj) { if (typeof obj === 'undefined') return $.$mol_dev_format_shade('undefined'); return [ 'object', { object: obj, config: true, }, ]; } $.$mol_dev_format_native = $mol_dev_format_native; function $mol_dev_format_auto(obj) { if (obj == null) return $.$mol_dev_format_shade(String(obj)); return [ 'object', { object: obj, config: false, }, ]; } $.$mol_dev_format_auto = $mol_dev_format_auto; function $mol_dev_format_element(element, style, ...content) { const styles = []; for (let key in style) styles.push(`${key} : ${style[key]}`); return [ element, { style: styles.join(' ; '), }, ...content, ]; } $.$mol_dev_format_element = $mol_dev_format_element; function $mol_dev_format_span(style, ...content) { return $mol_dev_format_element('span', { ...style, }, ...content); } $.$mol_dev_format_span = $mol_dev_format_span; $.$mol_dev_format_div = $mol_dev_format_element.bind(null, 'div'); $.$mol_dev_format_ol = $mol_dev_format_element.bind(null, 'ol'); $.$mol_dev_format_li = $mol_dev_format_element.bind(null, 'li'); $.$mol_dev_format_table = $mol_dev_format_element.bind(null, 'table'); $.$mol_dev_format_tr = $mol_dev_format_element.bind(null, 'tr'); $.$mol_dev_format_td = $mol_dev_format_element.bind(null, 'td'); $.$mol_dev_format_accent = $mol_dev_format_span.bind(null, { 'color': 'magenta', }); $.$mol_dev_format_strong = $mol_dev_format_span.bind(null, { 'font-weight': 'bold', }); $.$mol_dev_format_string = $mol_dev_format_span.bind(null, { 'color': 'green', }); $.$mol_dev_format_shade = $mol_dev_format_span.bind(null, { 'color': 'gray', }); $.$mol_dev_format_indent = $.$mol_dev_format_div.bind(null, { 'margin-left': '13px' }); })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_wire_pub_sub extends $mol_wire_pub { pub_from = 0; cursor = $mol_wire_cursor.stale; get temp() { return false; } get pub_list() { const res = []; const max = this.cursor >= 0 ? this.cursor : this.sub_from; for (let i = this.pub_from; i < max; i += 2) { if (this.data[i]) res.push(this.data[i]); } return res; } track_on() { this.cursor = this.pub_from; const sub = $mol_wire_auto(); $mol_wire_auto(this); return sub; } promote() { if (this.cursor >= this.pub_from) { $mol_fail(new Error('Circular subscription')); } super.promote(); } track_next(pub) { if (this.cursor < 0) $mol_fail(new Error('Promo to non begun sub')); if (this.cursor < this.sub_from) { const next = this.data[this.cursor]; if (pub === undefined) return next ?? null; if (next === pub) { this.cursor += 2; return next; } if (next) { if (this.sub_from < this.data.length) { this.peer_move(this.sub_from, this.data.length); } this.peer_move(this.cursor, this.sub_from); this.sub_from += 2; } } else { if (pub === undefined) return null; if (this.sub_from < this.data.length) { this.peer_move(this.sub_from, this.data.length); } this.sub_from += 2; } this.data[this.cursor] = pub; this.data[this.cursor + 1] = pub.sub_on(this, this.cursor); this.cursor += 2; return pub; } track_off(sub) { $mol_wire_auto(sub); if (this.cursor < 0) { $mol_fail(new Error('End of non begun sub')); } for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) { const pub = this.data[cursor]; pub.fresh(); } this.cursor = $mol_wire_cursor.fresh; } pub_off(sub_pos) { this.data[sub_pos] = undefined; this.data[sub_pos + 1] = undefined; } destructor() { for (let cursor = this.data.length - 2; cursor >= this.sub_from; cursor -= 2) { const sub = this.data[cursor]; const pos = this.data[cursor + 1]; sub.pub_off(pos); } this.data.length = this.sub_from; this.cursor = this.pub_from; this.track_cut(); this.cursor = $mol_wire_cursor.final; } track_cut() { if (this.cursor < this.pub_from) { $mol_fail(new Error('Cut of non begun sub')); } let end = this.data.length; for (let cursor = this.cursor; cursor < this.sub_from; cursor += 2) { const pub = this.data[cursor]; pub?.sub_off(this.data[cursor + 1]); end -= 2; if (this.sub_from <= end) this.peer_move(end, cursor); } this.data.length = end; this.sub_from = this.cursor; } complete() { } complete_pubs() { const limit = this.cursor < 0 ? this.sub_from : this.cursor; for (let cursor = this.pub_from; cursor < limit; cursor += 2) { const pub = this.data[cursor]; if (pub?.incompleted) return; } for (let cursor = this.pub_from; cursor < limit; cursor += 2) { const pub = this.data[cursor]; pub?.complete(); } } absorb(quant = $mol_wire_cursor.stale, pos = -1) { if (this.cursor === $mol_wire_cursor.final) return; if (this.cursor >= quant) return; this.cursor = quant; this.emit($mol_wire_cursor.doubt); } [$mol_dev_format_head]() { return $mol_dev_format_native(this); } get pub_empty() { return this.sub_from === this.pub_from; } } $.$mol_wire_pub_sub = $mol_wire_pub_sub; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_after_tick extends $mol_object2 { task; static promise = null; cancelled = false; constructor(task) { super(); this.task = task; if (!$mol_after_tick.promise) $mol_after_tick.promise = Promise.resolve().then(() => { $mol_after_tick.promise = null; }); $mol_after_tick.promise.then(() => { if (this.cancelled) return; task(); }); } destructor() { this.cancelled = true; } } $.$mol_after_tick = $mol_after_tick; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_promise_like(val) { try { return val && typeof val === 'object' && 'then' in val && typeof val.then === 'function'; } catch { return false; } } $.$mol_promise_like = $mol_promise_like; })($ || ($ = {})); ; "use strict"; var $; (function ($) { const wrappers = new WeakMap(); class $mol_wire_fiber extends $mol_wire_pub_sub { task; host; static warm = true; static planning = new Set(); static reaping = new Set(); static plan_task = null; static plan() { if (this.plan_task) return; this.plan_task = new $mol_after_tick(() => { try { this.sync(); } finally { $mol_wire_fiber.plan_task = null; } }); } static sync() { while (this.planning.size) { for (const fiber of this.planning) { this.planning.delete(fiber); if (fiber.cursor >= 0) continue; if (fiber.cursor === $mol_wire_cursor.final) continue; fiber.fresh(); } } while (this.reaping.size) { const fibers = this.reaping; this.reaping = new Set; for (const fiber of fibers) { if (!fiber.sub_empty) continue; fiber.destructor(); } } } cache = undefined; get args() { return this.data.slice(0, this.pub_from); } result() { if ($mol_promise_like(this.cache)) return; if (this.cache instanceof Error) return; return this.cache; } get incompleted() { return $mol_promise_like(this.cache); } field() { return this.task.name + '()'; } constructor(id, task, host, args) { super(id); this.task = task; this.host = host; if (args) this.data.push(...args); this.pub_from = this.sub_from = args?.length ?? 0; } plan() { $mol_wire_fiber.planning.add(this); $mol_wire_fiber.plan(); return this; } reap() { $mol_wire_fiber.reaping.add(this); $mol_wire_fiber.plan(); } toString() { return this[Symbol.toStringTag]; } toJSON() { return this[Symbol.toStringTag]; } [$mol_dev_format_head]() { const cursor = { [$mol_wire_cursor.stale]: '🔴', [$mol_wire_cursor.doubt]: '🟡', [$mol_wire_cursor.fresh]: '🟢', [$mol_wire_cursor.final]: '🔵', }[this.cursor] ?? this.cursor.toString(); return $mol_dev_format_div({}, $mol_owning_check(this, this.cache) ? $mol_dev_format_auto({ [$mol_dev_format_head]: () => $mol_dev_format_shade(cursor), [$mol_dev_format_body]: () => $mol_dev_format_native(this), }) : $mol_dev_format_shade($mol_dev_format_native(this), cursor), $mol_dev_format_auto(this.cache)); } get $() { return (this.host ?? this.task)['$']; } emit(quant = $mol_wire_cursor.stale) { if (this.sub_empty) this.plan(); else super.emit(quant); } fresh() { if (this.cursor === $mol_wire_cursor.fresh) return; if (this.cursor === $mol_wire_cursor.final) return; check: if (this.cursor === $mol_wire_cursor.doubt) { for (let i = this.pub_from; i < this.sub_from; i += 2) { ; this.data[i]?.fresh(); if (this.cursor !== $mol_wire_cursor.doubt) break check; } this.cursor = $mol_wire_cursor.fresh; return; } const bu = this.track_on(); let result; try { switch (this.pub_from) { case 0: result = this.task.call(this.host); break; case 1: result = this.task.call(this.host, this.data[0]); break; default: result = this.task.call(this.host, ...this.args); break; } if ($mol_promise_like(result)) { if (wrappers.has(result)) { result = wrappers.get(result).then(a => a); } else { const put = (res) => { if (this.cache === result) this.put(res); return res; }; wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) })); wrappers.set(result, result); const error = new Error(`Promise in ${this}`); Object.defineProperty(result, 'stack', { get: () => error.stack }); } } } catch (error) { if (error instanceof Error || $mol_promise_like(error)) { result = error; } else { result = new Error(String(error), { cause: error }); } if ($mol_promise_like(result)) { if (wrappers.has(result)) { result = wrappers.get(result); } else { wrappers.set(result, result = Object.assign(result.finally(() => { if (this.cache === result) this.absorb(); }), { destructor: result.destructor || (() => { }) })); const error = new Error(`Promise in ${this}`); Object.defineProperty(result, 'stack', { get: () => error.stack }); } } } if (!$mol_promise_like(result)) { this.track_cut(); } this.track_off(bu); this.put(result); return this; } refresh() { this.cursor = $mol_wire_cursor.stale; this.fresh(); } sync() { if (!$mol_wire_fiber.warm) { return this.result(); } this.promote(); this.fresh(); if (this.cache instanceof Error) { return $mol_fail_hidden(this.cache); } if ($mol_promise_like(this.cache)) { return $mol_fail_hidden(this.cache); } return this.cache; } async async_raw() { while (true) { this.fresh(); if (this.cache instanceof Error) { $mol_fail_hidden(this.cache); } if (!$mol_promise_like(this.cache)) return this.cache; await Promise.race([this.cache, this.step()]); if (!$mol_promise_like(this.cache)) return this.cache; if (this.cursor === $mol_wire_cursor.final) { await new Promise(() => { }); } } } async() { const promise = this.async_raw(); if (!promise.destructor) promise.destructor = () => this.destructor(); return promise; } step() { return new Promise(done => { const sub = new $mol_wire_pub_sub; const prev = sub.track_on(); sub.track_next(this); sub.track_off(prev); sub.absorb = () => { done(null); setTimeout(() => sub.destructor()); }; }); } destructor() { super.destructor(); if (!$mol_owning_check(this, this.cache)) return; try { this.cache.destructor(); } catch (result) { if ($mol_promise_like(result)) { const error = new Error(`Promise in ${this}.destructor()`); Object.defineProperty(result, 'stack', { get: () => error.stack }); } $mol_fail_hidden(result); } } } $.$mol_wire_fiber = $mol_wire_fiber; })($ || ($ = {})); ; "use strict"; var $; (function ($) { $.$mol_key_store = new WeakMap(); const TypedArray = Object.getPrototypeOf(Uint8Array); function $mol_key(value) { if (typeof value === 'bigint') return value.toString() + 'n'; if (typeof value === 'symbol') return value.description; if (!value) return JSON.stringify(value); if (typeof value !== 'object' && typeof value !== 'function') return JSON.stringify(value); return JSON.stringify(value, (field, value) => { if (typeof value === 'bigint') return value.toString() + 'n'; if (typeof value === 'symbol') return value.description; if (!value) return value; if (typeof value !== 'object' && typeof value !== 'function') return value; if (Array.isArray(value)) return value; const proto = Reflect.getPrototypeOf(value); if (!proto) return value; if (Reflect.getPrototypeOf(proto) === null) return value; if ('toJSON' in value) return value; if (value instanceof RegExp) return value.toString(); if (value instanceof TypedArray) return [...value]; let key = $.$mol_key_store.get(value); if (key) return key; key = $mol_guid(); $.$mol_key_store.set(value, key); return key; }); } $.$mol_key = $mol_key; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_after_frame extends $mol_object2 { task; static _promise = null; static get promise() { if (this._promise) return this._promise; return this._promise = new Promise(done => { const complete = () => { this._promise = null; done(); }; if (typeof requestAnimationFrame === 'function') { requestAnimationFrame(complete); } else { setTimeout(complete, 16); } }); } cancelled = false; promise; constructor(task) { super(); this.task = task; this.promise = $mol_after_frame.promise.then(() => { if (this.cancelled) return; task(); }); } destructor() { this.cancelled = true; } } $.$mol_after_frame = $mol_after_frame; })($ || ($ = {})); ; "use strict"; var $; (function ($) { $.$mol_compare_deep_cache = new WeakMap(); function $mol_compare_deep(left, right) { if (Object.is(left, right)) return true; if (left === null) return false; if (right === null) return false; if (typeof left !== 'object') return false; if (typeof right !== 'object') return false; const left_proto = Reflect.getPrototypeOf(left); const right_proto = Reflect.getPrototypeOf(right); if (left_proto !== right_proto) return false; if (left instanceof Boolean) return Object.is(left.valueOf(), right['valueOf']()); if (left instanceof Number) return Object.is(left.valueOf(), right['valueOf']()); if (left instanceof String) return Object.is(left.valueOf(), right['valueOf']()); if (left instanceof Date) return Object.is(left.valueOf(), right['valueOf']()); if (left instanceof RegExp) return left.source === right.source && left.flags === right.flags; if (left instanceof Error) return left.message === right.message && left.stack === right.stack; let left_cache = $.$mol_compare_deep_cache.get(left); if (left_cache) { const right_cache = left_cache.get(right); if (typeof right_cache === 'boolean') return right_cache; } else { left_cache = new WeakMap(); $.$mol_compare_deep_cache.set(left, left_cache); } left_cache.set(right, true); let result; try { if (!left_proto) result = compare_pojo(left, right); else if (!Reflect.getPrototypeOf(left_proto)) result = compare_pojo(left, right); else if (Symbol.toPrimitive in left) result = compare_primitive(left, right); else if (Array.isArray(left)) result = compare_array(left, right); else if (left instanceof Set) result = compare_set(left, right); else if (left instanceof Map) result = compare_map(left, right); else if (ArrayBuffer.isView(left)) result = compare_buffer(left, right); else if (Symbol.iterator in left) result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]()); else result = false; } finally { left_cache.set(right, result); } return result; } $.$mol_compare_deep = $mol_compare_deep; function compare_array(left, right) { const len = left.length; if (len !== right.length) return false; for (let i = 0; i < len; ++i) { if (!$mol_compare_deep(left[i], right[i])) return false; } return true; } function compare_buffer(left, right) { const len = left.byteLength; if (len !== right.byteLength) return false; if (left instanceof DataView) return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, right.byteOffset, right.byteLength)); for (let i = 0; i < len; ++i) { if (left[i] !== right[i]) return false; } return true; } function compare_iterator(left, right) { while (true) { const left_next = left.next(); const right_next = right.next(); if (left_next.done !== right_next.done) return false; if (left_next.done) break; if (!$mol_compare_deep(left_next.value, right_next.value)) return false; } return true; } function compare_set(left, right) { if (left.size !== right.size) return false; return compare_iterator(left.values(), right.values()); } function compare_map(left, right) { if (left.size !== right.size) return false; return compare_iterator(left.keys(), right.keys()) && compare_iterator(left.values(), right.values()); } function compare_pojo(left, right) { const left_keys = Object.getOwnPropertyNames(left); const right_keys = Object.getOwnPropertyNames(right); if (!compare_array(left_keys, right_keys)) return false; for (let key of left_keys) { if (!$mol_compare_deep(left[key], right[key])) return false; } const left_syms = Object.getOwnPropertySymbols(left); const right_syms = Object.getOwnPropertySymbols(right); if (!compare_array(left_syms, right_syms)) return false; for (let key of left_syms) { if (!$mol_compare_deep(left[key], right[key])) return false; } return true; } function compare_primitive(left, right) { return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default')); } })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_log3_area_lazy(event) { const self = this; const stack = self.$mol_log3_stack; const deep = stack.length; let logged = false; stack.push(() => { logged = true; self.$mol_log3_area.call(self, event); }); return () => { if (logged) self.console.groupEnd(); if (stack.length > deep) stack.length = deep; }; } $.$mol_log3_area_lazy = $mol_log3_area_lazy; $.$mol_log3_stack = []; })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { function $mol_log3_web_make(level, color) { return function $mol_log3_logger(event) { const pending = this.$mol_log3_stack.pop(); if (pending) pending(); let tpl = '%c'; const chunks = Object.entries(event); for (let i = 0; i < chunks.length; ++i) { tpl += (typeof chunks[i][1] === 'string') ? '%s: %s\n' : '%s: %o\n'; } const style = `color:${color};font-weight:bolder`; this.console[level](tpl.trim(), style, ...[].concat(...chunks)); const self = this; return () => self.console.groupEnd(); }; } $.$mol_log3_web_make = $mol_log3_web_make; $.$mol_log3_come = $mol_log3_web_make('info', 'royalblue'); $.$mol_log3_done = $mol_log3_web_make('info', 'forestgreen'); $.$mol_log3_fail = $mol_log3_web_make('error', 'orangered'); $.$mol_log3_warn = $mol_log3_web_make('warn', 'goldenrod'); $.$mol_log3_rise = $mol_log3_web_make('log', 'magenta'); $.$mol_log3_area = $mol_log3_web_make('group', 'cyan'); })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_wire_task extends $mol_wire_fiber { static getter(task) { return function $mol_wire_task_get(host, args) { const sub = $mol_wire_auto(); const existen = sub?.track_next(); reuse: if (existen) { if (!existen.temp) break reuse; if (existen.host !== host) break reuse; if (existen.task !== task) break reuse; if (!$mol_compare_deep(existen.args, args)) break reuse; return existen; } const key = (host?.[Symbol.toStringTag] ?? host) + ('.' + task.name + '<#>'); const next = new $mol_wire_task(key, task, host, args); if (existen?.temp) { $$.$mol_log3_warn({ place: '$mol_wire_task', message: `Non idempotency`, sub, pubs: [...sub?.pub_list ?? [], existen], next, hint: 'Ignore it', }); } return next; }; } get temp() { return true; } complete() { if ($mol_promise_like(this.cache)) return; this.destructor(); } put(next) { const prev = this.cache; this.cache = next; if ($mol_promise_like(next)) { this.cursor = $mol_wire_cursor.fresh; if (next !== prev) this.emit(); if ($mol_owning_catch(this, next)) { try { next[Symbol.toStringTag] = this[Symbol.toStringTag]; } catch { Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] }); } } return next; } this.cursor = $mol_wire_cursor.final; if (this.sub_empty) this.destructor(); else if (next !== prev) this.emit(); return next; } } $.$mol_wire_task = $mol_wire_task; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_wire_method(host, field, descr) { if (!descr) descr = Reflect.getOwnPropertyDescriptor(host, field); const orig = descr?.value ?? host[field]; const sup = Reflect.getPrototypeOf(host); if (typeof sup[field] === 'function') { Object.defineProperty(orig, 'name', { value: sup[field].name }); } const temp = $mol_wire_task.getter(orig); const value = function (...args) { const fiber = temp(this ?? null, args); return fiber.sync(); }; Object.defineProperty(value, 'name', { value: orig.name + ' ' }); Object.assign(value, { orig }); const descr2 = { ...descr, value }; Reflect.defineProperty(host, field, descr2); return descr2; } $.$mol_wire_method = $mol_wire_method; })($ || ($ = {})); ; "use strict"; ; "use strict"; ; "use strict"; var $; (function ($) { const catched = new WeakMap(); function $mol_fail_catch(error) { if (typeof error !== 'object') return false; if ($mol_promise_like(error)) $mol_fail_hidden(error); if (catched.get(error)) return false; catched.set(error, true); return true; } $.$mol_fail_catch = $mol_fail_catch; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_fail_log(error) { if ($mol_promise_like(error)) return false; if (!$mol_fail_catch(error)) return false; console.error(error); return true; } $.$mol_fail_log = $mol_fail_log; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_wire_atom extends $mol_wire_fiber { static solo(host, task) { const field = task.name + '()'; const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value; if (existen) return existen; const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host); const key = prefix + ('.' + task.name + '<>'); const fiber = new $mol_wire_atom(key, task, host, []); (host ?? task)[field] = fiber; return fiber; } static plex(host, task, key) { const field = task.name + '()'; let dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value; const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host); const key_str = $mol_key(key); if (dict) { const existen = dict.get(key_str); if (existen) return existen; } else { dict = (host ?? task)[field] = new Map(); } const id = prefix + ('.' + task.name) + ('<' + key_str.replace(/^"|"$/g, "'") + '>'); const fiber = new $mol_wire_atom(id, task, host, [key]); dict.set(key_str, fiber); return fiber; } static watching = new Set(); static watcher = null; static watch() { $mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch); for (const atom of $mol_wire_atom.watching) { if (atom.cursor === $mol_wire_cursor.final) { $mol_wire_atom.watching.delete(atom); } else { atom.cursor = $mol_wire_cursor.stale; atom.fresh(); } } } watch() { if (!$mol_wire_atom.watcher) { $mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch); } $mol_wire_atom.watching.add(this); } resync(args) { return this.put(this.task.call(this.host, ...args)); } once() { return this.sync(); } channel() { return Object.assign((next) => { if (next !== undefined) return this.resync([...this.args, next]); if (!$mol_wire_fiber.warm) return this.result(); if ($mol_wire_auto()?.temp) { return this.once(); } else { return this.sync(); } }, { atom: this }); } destructor() { super.destructor(); if (this.pub_from === 0) { ; (this.host ?? this.task)[this.field()] = null; } else { ; (this.host ?? this.task)[this.field()].delete($mol_key(this.args[0])); } } put(next) { const prev = this.cache; update: if (next !== prev) { try { if ($mol_compare_deep(prev, next)) break update; } catch (error) { $mol_fail_log(error); } if ($mol_owning_check(this, prev)) { prev.destructor(); } if ($mol_owning_catch(this, next)) { try { next[Symbol.toStringTag] = this[Symbol.toStringTag]; } catch { Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] }); } } if (!this.sub_empty) this.emit(); } this.cache = next; this.cursor = $mol_wire_cursor.fresh; if ($mol_promise_like(next)) return next; this.complete_pubs(); return next; } } __decorate([ $mol_wire_method ], $mol_wire_atom.prototype, "resync", null); __decorate([ $mol_wire_method ], $mol_wire_atom.prototype, "once", null); $.$mol_wire_atom = $mol_wire_atom; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_wire_solo(host, field, descr) { if (!descr) descr = Reflect.getOwnPropertyDescriptor(host, field); const orig = descr?.value ?? host[field]; const sup = Reflect.getPrototypeOf(host); if (typeof sup[field] === 'function') { Object.defineProperty(orig, 'name', { value: sup[field].name }); } const descr2 = { ...descr, value: function (...args) { let atom = $mol_wire_atom.solo(this, orig); if ((args.length === 0) || (args[0] === undefined)) { if (!$mol_wire_fiber.warm) return atom.result(); if ($mol_wire_auto()?.temp) { return atom.once(); } else { return atom.sync(); } } return atom.resync(args); } }; Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' }); Reflect.defineProperty(descr2.value, 'length', { value: orig.length }); Object.assign(descr2.value, { orig }); Reflect.defineProperty(host, field, descr2); return descr2; } $.$mol_wire_solo = $mol_wire_solo; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_wire_plex(host, field, descr) { if (!descr) descr = Reflect.getOwnPropertyDescriptor(host, field); const orig = descr?.value ?? host[field]; const sup = Reflect.getPrototypeOf(host); if (typeof sup[field] === 'function') { Object.defineProperty(orig, 'name', { value: sup[field].name }); } const descr2 = { ...descr, value: function (...args) { let atom = $mol_wire_atom.plex(this, orig, args[0]); if ((args.length === 1) || (args[1] === undefined)) { if (!$mol_wire_fiber.warm) return atom.result(); if ($mol_wire_auto()?.temp) { return atom.once(); } else { return atom.sync(); } } return atom.resync(args); } }; Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' }); Reflect.defineProperty(descr2.value, 'length', { value: orig.length }); Object.assign(descr2.value, { orig }); Reflect.defineProperty(host, field, descr2); return descr2; } $.$mol_wire_plex = $mol_wire_plex; })($ || ($ = {})); ; "use strict"; var $; (function ($) { $.$mol_mem = $mol_wire_solo; $.$mol_mem_key = $mol_wire_plex; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_window extends $mol_object { static size() { this.resizes(); return { width: self.innerWidth, height: self.innerHeight, }; } static resizes(next) { return next; } } __decorate([ $mol_mem ], $mol_window, "size", null); __decorate([ $mol_mem ], $mol_window, "resizes", null); $.$mol_window = $mol_window; self.addEventListener('resize', event => $mol_window.resizes(event)); })($ || ($ = {})); ; "use strict"; var $; (function ($) { })($ || ($ = {})); ; "use strict"; var $; (function ($) { $.$mol_dom_context = self; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_view_selection extends $mol_object { static focused(next, notify) { const parents = []; let element = next?.[0] ?? $mol_dom_context.document.activeElement; while (element?.shadowRoot) { element = element.shadowRoot.activeElement; } while (element) { parents.push(element); const parent = element.parentNode; if (parent instanceof ShadowRoot) element = parent.host; else element = parent; } if (!next || notify) return parents; new $mol_after_tick(() => { const element = this.focused()[0]; if (element) element.focus(); else $mol_dom_context.blur(); }); return parents; } } __decorate([ $mol_mem ], $mol_view_selection, "focused", null); $.$mol_view_selection = $mol_view_selection; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_maybe(value) { return (value == null) ? [] : [value]; } $.$mol_maybe = $mol_maybe; })($ || ($ = {})); ; "use strict"; var $; (function ($) { $.$mol_dom = $mol_dom_context; })($ || ($ = {})); ; "use strict"; var $; (function ($) { let $mol_keyboard_code; (function ($mol_keyboard_code) { $mol_keyboard_code[$mol_keyboard_code["backspace"] = 8] = "backspace"; $mol_keyboard_code[$mol_keyboard_code["tab"] = 9] = "tab"; $mol_keyboard_code[$mol_keyboard_code["enter"] = 13] = "enter"; $mol_keyboard_code[$mol_keyboard_code["shift"] = 16] = "shift"; $mol_keyboard_code[$mol_keyboard_code["ctrl"] = 17] = "ctrl"; $mol_keyboard_code[$mol_keyboard_code["alt"] = 18] = "alt"; $mol_keyboard_code[$mol_keyboard_code["pause"] = 19] = "pause"; $mol_keyboard_code[$mol_keyboard_code["capsLock"] = 20] = "capsLock"; $mol_keyboard_code[$mol_keyboard_code["escape"] = 27] = "escape"; $mol_keyboard_code[$mol_keyboard_code["space"] = 32] = "space"; $mol_keyboard_code[$mol_keyboard_code["pageUp"] = 33] = "pageUp"; $mol_keyboard_code[$mol_keyboard_code["pageDown"] = 34] = "pageDown"; $mol_keyboard_code[$mol_keyboard_code["end"] = 35] = "end"; $mol_keyboard_code[$mol_keyboard_code["home"] = 36] = "home"; $mol_keyboard_code[$mol_keyboard_code["left"] = 37] = "left"; $mol_keyboard_code[$mol_keyboard_code["up"] = 38] = "up"; $mol_keyboard_code[$mol_keyboard_code["right"] = 39] = "right"; $mol_keyboard_code[$mol_keyboard_code["down"] = 40] = "down"; $mol_keyboard_code[$mol_keyboard_code["insert"] = 45] = "insert"; $mol_keyboard_code[$mol_keyboard_code["delete"] = 46] = "delete"; $mol_keyboard_code[$mol_keyboard_code["key0"] = 48] = "key0"; $mol_keyboard_code[$mol_keyboard_code["key1"] = 49] = "key1"; $mol_keyboard_code[$mol_keyboard_code["key2"] = 50] = "key2"; $mol_keyboard_code[$mol_keyboard_code["key3"] = 51] = "key3"; $mol_keyboard_code[$mol_keyboard_code["key4"] = 52] = "key4"; $mol_keyboard_code[$mol_keyboard_code["key5"] = 53] = "key5"; $mol_keyboard_code[$mol_keyboard_code["key6"] = 54] = "key6"; $mol_keyboard_code[$mol_keyboard_code["key7"] = 55] = "key7"; $mol_keyboard_code[$mol_keyboard_code["key8"] = 56] = "key8"; $mol_keyboard_code[$mol_keyboard_code["key9"] = 57] = "key9"; $mol_keyboard_code[$mol_keyboard_code["A"] = 65] = "A"; $mol_keyboard_code[$mol_keyboard_code["B"] = 66] = "B"; $mol_keyboard_code[$mol_keyboard_code["C"] = 67] = "C"; $mol_keyboard_code[$mol_keyboard_code["D"] = 68] = "D"; $mol_keyboard_code[$mol_keyboard_code["E"] = 69] = "E"; $mol_keyboard_code[$mol_keyboard_code["F"] = 70] = "F"; $mol_keyboard_code[$mol_keyboard_code["G"] = 71] = "G"; $mol_keyboard_code[$mol_keyboard_code["H"] = 72] = "H"; $mol_keyboard_code[$mol_keyboard_code["I"] = 73] = "I"; $mol_keyboard_code[$mol_keyboard_code["J"] = 74] = "J"; $mol_keyboard_code[$mol_keyboard_code["K"] = 75] = "K"; $mol_keyboard_code[$mol_keyboard_code["L"] = 76] = "L"; $mol_keyboard_code[$mol_keyboard_code["M"] = 77] = "M"; $mol_keyboard_code[$mol_keyboard_code["N"] = 78] = "N"; $mol_keyboard_code[$mol_keyboard_code["O"] = 79] = "O"; $mol_keyboard_code[$mol_keyboard_code["P"] = 80] = "P"; $mol_keyboard_code[$mol_keyboard_code["Q"] = 81] = "Q"; $mol_keyboard_code[$mol_keyboard_code["R"] = 82] = "R"; $mol_keyboard_code[$mol_keyboard_code["S"] = 83] = "S"; $mol_keyboard_code[$mol_keyboard_code["T"] = 84] = "T"; $mol_keyboard_code[$mol_keyboard_code["U"] = 85] = "U"; $mol_keyboard_code[$mol_keyboard_code["V"] = 86] = "V"; $mol_keyboard_code[$mol_keyboard_code["W"] = 87] = "W"; $mol_keyboard_code[$mol_keyboard_code["X"] = 88] = "X"; $mol_keyboard_code[$mol_keyboard_code["Y"] = 89] = "Y"; $mol_keyboard_code[$mol_keyboard_code["Z"] = 90] = "Z"; $mol_keyboard_code[$mol_keyboard_code["metaLeft"] = 91] = "metaLeft"; $mol_keyboard_code[$mol_keyboard_code["metaRight"] = 92] = "metaRight"; $mol_keyboard_code[$mol_keyboard_code["select"] = 93] = "select"; $mol_keyboard_code[$mol_keyboard_code["numpad0"] = 96] = "numpad0"; $mol_keyboard_code[$mol_keyboard_code["numpad1"] = 97] = "numpad1"; $mol_keyboard_code[$mol_keyboard_code["numpad2"] = 98] = "numpad2"; $mol_keyboard_code[$mol_keyboard_code["numpad3"] = 99] = "numpad3"; $mol_keyboard_code[$mol_keyboard_code["numpad4"] = 100] = "numpad4"; $mol_keyboard_code[$mol_keyboard_code["numpad5"] = 101] = "numpad5"; $mol_keyboard_code[$mol_keyboard_code["numpad6"] = 102] = "numpad6"; $mol_keyboard_code[$mol_keyboard_code["numpad7"] = 103] = "numpad7"; $mol_keyboard_code[$mol_keyboard_code["numpad8"] = 104] = "numpad8"; $mol_keyboard_code[$mol_keyboard_code["numpad9"] = 105] = "numpad9"; $mol_keyboard_code[$mol_keyboard_code["multiply"] = 106] = "multiply"; $mol_keyboard_code[$mol_keyboard_code["add"] = 107] = "add"; $mol_keyboard_code[$mol_keyboard_code["subtract"] = 109] = "subtract"; $mol_keyboard_code[$mol_keyboard_code["decimal"] = 110] = "decimal"; $mol_keyboard_code[$mol_keyboard_code["divide"] = 111] = "divide"; $mol_keyboard_code[$mol_keyboard_code["F1"] = 112] = "F1"; $mol_keyboard_code[$mol_keyboard_code["F2"] = 113] = "F2"; $mol_keyboard_code[$mol_keyboard_code["F3"] = 114] = "F3"; $mol_keyboard_code[$mol_keyboard_code["F4"] = 115] = "F4"; $mol_keyboard_code[$mol_keyboard_code["F5"] = 116] = "F5"; $mol_keyboard_code[$mol_keyboard_code["F6"] = 117] = "F6"; $mol_keyboard_code[$mol_keyboard_code["F7"] = 118] = "F7"; $mol_keyboard_code[$mol_keyboard_code["F8"] = 119] = "F8"; $mol_keyboard_code[$mol_keyboard_code["F9"] = 120] = "F9"; $mol_keyboard_code[$mol_keyboard_code["F10"] = 121] = "F10"; $mol_keyboard_code[$mol_keyboard_code["F11"] = 122] = "F11"; $mol_keyboard_code[$mol_keyboard_code["F12"] = 123] = "F12"; $mol_keyboard_code[$mol_keyboard_code["numLock"] = 144] = "numLock"; $mol_keyboard_code[$mol_keyboard_code["scrollLock"] = 145] = "scrollLock"; $mol_keyboard_code[$mol_keyboard_code["semicolon"] = 186] = "semicolon"; $mol_keyboard_code[$mol_keyboard_code["equals"] = 187] = "equals"; $mol_keyboard_code[$mol_keyboard_code["comma"] = 188] = "comma"; $mol_keyboard_code[$mol_keyboard_code["dash"] = 189] = "dash"; $mol_keyboard_code[$mol_keyboard_code["period"] = 190] = "period"; $mol_keyboard_code[$mol_keyboard_code["forwardSlash"] = 191] = "forwardSlash"; $mol_keyboard_code[$mol_keyboard_code["graveAccent"] = 192] = "graveAccent"; $mol_keyboard_code[$mol_keyboard_code["bracketOpen"] = 219] = "bracketOpen"; $mol_keyboard_code[$mol_keyboard_code["slashBack"] = 220] = "slashBack"; $mol_keyboard_code[$mol_keyboard_code["slashBackLeft"] = 226] = "slashBackLeft"; $mol_keyboard_code[$mol_keyboard_code["bracketClose"] = 221] = "bracketClose"; $mol_keyboard_code[$mol_keyboard_code["quoteSingle"] = 222] = "quoteSingle"; })($mol_keyboard_code = $.$mol_keyboard_code || ($.$mol_keyboard_code = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { if ($mol_dom_context.document) { function focus(event) { const target = event.target; if (target?.shadowRoot) watch(target.shadowRoot); $mol_view_selection.focused($mol_maybe(target), 'notify'); } function watch(root) { root.removeEventListener('focus', focus, true); root.addEventListener('focus', focus, true); } watch($mol_dom_context.document); $mol_dom.document.addEventListener('keydown', event => { if (!event.altKey) return; const self = $mol_view_selection.focused()[0]; if (!self) return; switch (event.keyCode) { case $mol_keyboard_code.down: var vert = 1, hor = 0; break; case $mol_keyboard_code.up: var vert = -1, hor = 0; break; case $mol_keyboard_code.left: var hor = -1, vert = 0; break; case $mol_keyboard_code.right: var hor = 1, vert = 0; break; default: return; } event.preventDefault(); const self_rect = self.getBoundingClientRect(); const center_hor = (self_rect.left + self_rect.right) / 2; const center_vert = (self_rect.top + self_rect.bottom) / 2; const all = [...$mol_dom.document.querySelectorAll(':where( [role="button"], [role="checkbox"], input, button, a ):not([disabled])')] .map(el => { const rect = el.getBoundingClientRect(); const dist = (Math.max(0, center_hor - rect.right) + Math.max(0, rect.left - center_hor)) * vert * vert + (Math.max(0, center_vert - rect.bottom) + Math.max(0, rect.top - center_vert)) * hor * hor; return [el, rect, dist]; }) .filter(([el, rect]) => { if (el === self) return false; if (vert > 0 && rect.top < self_rect.bottom) return false; if (vert < 0 && rect.bottom > self_rect.top) return false; if (hor > 0 && rect.left < self_rect.right) return false; if (hor < 0 && rect.right > self_rect.left) return false; return true; }) .sort(([, one, dist1], [, two, dist2]) => { return (dist1 - dist2) || ((one.top - two.top) * vert + (one.left - two.left) * hor); }); const target = all[0]?.[0]; target?.focus(); }); } })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_wrapper extends $mol_object2 { static wrap; static run(task) { return this.func(task)(); } static func(func) { return this.wrap(func); } static get class() { return (Class) => { const construct = (target, args) => new Class(...args); const handler = { construct: this.func(construct) }; handler[Symbol.toStringTag] = Class.name + '#'; return new Proxy(Class, handler); }; } static get method() { return (obj, name, descr) => { descr.value = this.func(descr.value); return descr; }; } static get field() { return (obj, name, descr) => { descr.get = descr.set = this.func(descr.get); return descr; }; } } $.$mol_wrapper = $mol_wrapper; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_memo extends $mol_wrapper { static wrap(task) { const store = new WeakMap(); const fun = function (next) { if (next === undefined && store.has(this)) return store.get(this); const val = task.call(this, next) ?? next; store.set(this, val); return val; }; Reflect.defineProperty(fun, 'name', { value: task.name + ' ' }); return fun; } } $.$mol_memo = $mol_memo; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_dom_qname(name) { return name.replace(/\W/g, '').replace(/^(?=\d+)/, '_'); } $.$mol_dom_qname = $mol_dom_qname; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_wire_probe(task, def) { const warm = $mol_wire_fiber.warm; try { $mol_wire_fiber.warm = false; const res = task(); if (res === undefined) return def; return res; } finally { $mol_wire_fiber.warm = warm; } } $.$mol_wire_probe = $mol_wire_probe; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_wire_watch() { const atom = $mol_wire_auto(); if (atom instanceof $mol_wire_atom) { atom.watch(); } else { $mol_fail(new Error('Atom is required for watching')); } } $.$mol_wire_watch = $mol_wire_watch; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_const(value) { const getter = (() => value); getter['()'] = value; getter[Symbol.toStringTag] = value; getter[$mol_dev_format_head] = () => $mol_dev_format_span({}, '()=> ', $mol_dev_format_auto(value)); return getter; } $.$mol_const = $mol_const; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_wire_solid() { let current = $mol_wire_auto(); if (current.temp) current = current.host; if (current.reap !== nothing) { current?.sub_on(sub, sub.data.length); } current.reap = nothing; } $.$mol_wire_solid = $mol_wire_solid; const nothing = () => { }; const sub = new $mol_wire_pub_sub; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_dom_render_attributes(el, attrs) { for (let name in attrs) { let val = attrs[name]; if (val === undefined) { continue; } else if (val === null || val === false) { if (!el.hasAttribute(name)) continue; el.removeAttribute(name); } else { const str = String(val); if (el.getAttribute(name) === str) continue; el.setAttribute(name, str); } } } $.$mol_dom_render_attributes = $mol_dom_render_attributes; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_dom_render_events(el, events, passive = false) { for (let name in events) { el.addEventListener(name, events[name], { passive }); } } $.$mol_dom_render_events = $mol_dom_render_events; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_dom_render_styles(el, styles) { for (let name in styles) { let val = styles[name]; const style = el.style; const kebab = (name) => name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase()); if (typeof val === 'number') { style.setProperty(kebab(name), `${val}px`); } else { style.setProperty(kebab(name), val); } } } $.$mol_dom_render_styles = $mol_dom_render_styles; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_dom_render_children(el, childNodes) { const node_set = new Set(childNodes); let nextNode = el.firstChild; for (let view of childNodes) { if (view == null) continue; if (view instanceof $mol_dom_context.Node) { while (true) { if (!nextNode) { el.appendChild(view); break; } if (nextNode == view) { nextNode = nextNode.nextSibling; break; } else { if (node_set.has(nextNode)) { el.insertBefore(view, nextNode); break; } else { const nn = nextNode.nextSibling; el.removeChild(nextNode); nextNode = nn; } } } } else { if (nextNode && nextNode.nodeName === '#text') { const str = String(view); if (nextNode.nodeValue !== str) nextNode.nodeValue = str; nextNode = nextNode.nextSibling; } else { const textNode = $mol_dom_context.document.createTextNode(String(view)); el.insertBefore(textNode, nextNode); } } } while (nextNode) { const currNode = nextNode; nextNode = currNode.nextSibling; el.removeChild(currNode); } } $.$mol_dom_render_children = $mol_dom_render_children; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_dom_render_fields(el, fields) { for (let key in fields) { const val = fields[key]; if (val === undefined) continue; if (val === el[key]) continue; el[key] = val; } } $.$mol_dom_render_fields = $mol_dom_render_fields; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_wire_async(obj) { let fiber; const temp = $mol_wire_task.getter(obj); return new Proxy(obj, { get(obj, field) { const val = obj[field]; if (typeof val !== 'function') return val; let fiber; const temp = $mol_wire_task.getter(val); return function $mol_wire_async(...args) { fiber?.destructor(); fiber = temp(obj, args); return fiber.async(); }; }, apply(obj, self, args) { fiber?.destructor(); fiber = temp(self, args); return fiber.async(); }, }); } $.$mol_wire_async = $mol_wire_async; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_after_timeout extends $mol_object2 { delay; task; id; constructor(delay, task) { super(); this.delay = delay; this.task = task; this.id = setTimeout(task, delay); } destructor() { clearTimeout(this.id); } } $.$mol_after_timeout = $mol_after_timeout; })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { function $mol_style_attach(id, text) { const doc = $mol_dom_context.document; if (!doc) return null; const elid = `$mol_style_attach:${id}`; let el = doc.getElementById(elid); if (!el) { el = doc.createElement('style'); el.id = elid; doc.head.appendChild(el); } if (el.innerHTML != text) el.innerHTML = text; return el; } $.$mol_style_attach = $mol_style_attach; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_promise extends Promise { done; fail; constructor(executor) { let done; let fail; super((d, f) => { done = d; fail = f; executor?.(d, f); }); this.done = done; this.fail = fail; } } $.$mol_promise = $mol_promise; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_promise_blocker extends $mol_promise { static [Symbol.toStringTag] = '$mol_promise_blocker'; } $.$mol_promise_blocker = $mol_promise_blocker; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_decor { value; constructor(value) { this.value = value; } prefix() { return ''; } valueOf() { return this.value; } postfix() { return ''; } toString() { return `${this.prefix()}${this.valueOf()}${this.postfix()}`; } } $.$mol_decor = $mol_decor; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_style_unit extends $mol_decor { literal; constructor(value, literal) { super(value); this.literal = literal; } postfix() { return this.literal; } static per(value) { return `${value}%`; } static px(value) { return `${value}px`; } static mm(value) { return `${value}mm`; } static cm(value) { return `${value}cm`; } static Q(value) { return `${value}Q`; } static in(value) { return `${value}in`; } static pc(value) { return `${value}pc`; } static pt(value) { return `${value}pt`; } static cap(value) { return `${value}cap`; } static ch(value) { return `${value}ch`; } static em(value) { return `${value}em`; } static rem(value) { return `${value}rem`; } static ex(value) { return `${value}ex`; } static ic(value) { return `${value}ic`; } static lh(value) { return `${value}lh`; } static rlh(value) { return `${value}rlh`; } static vh(value) { return `${value}vh`; } static vw(value) { return `${value}vw`; } static vi(value) { return `${value}vi`; } static vb(value) { return `${value}vb`; } static vmin(value) { return `${value}vmin`; } static vmax(value) { return `${value}vmax`; } static deg(value) { return `${value}deg`; } static rad(value) { return `${value}rad`; } static grad(value) { return `${value}grad`; } static turn(value) { return `${value}turn`; } static s(value) { return `${value}s`; } static ms(value) { return `${value}ms`; } } $.$mol_style_unit = $mol_style_unit; })($ || ($ = {})); ; "use strict"; var $; (function ($) { const { per } = $mol_style_unit; class $mol_style_func extends $mol_decor { name; constructor(name, value) { super(value); this.name = name; } prefix() { return this.name + '('; } postfix() { return ')'; } static linear_gradient(value) { return new $mol_style_func('linear-gradient', value); } static calc(value) { return new $mol_style_func('calc', value); } static vary(name, defaultValue) { return new $mol_style_func('var', defaultValue ? [name, defaultValue] : name); } static url(href) { return new $mol_style_func('url', JSON.stringify(href)); } static hsla(hue, saturation, lightness, alpha) { return new $mol_style_func('hsla', [hue, per(saturation), per(lightness), alpha]); } static clamp(min, mid, max) { return new $mol_style_func('clamp', [min, mid, max]); } static rgba(red, green, blue, alpha) { return new $mol_style_func('rgba', [red, green, blue, alpha]); } static scale(zoom) { return new $mol_style_func('scale', [zoom]); } static linear(...breakpoints) { return new $mol_style_func("linear", breakpoints.map((e) => Array.isArray(e) ? String(e[0]) + " " + (typeof e[1] === "number" ? e[1] + "%" : e[1].toString()) : String(e))); } static cubic_bezier(x1, y1, x2, y2) { return new $mol_style_func('cubic-bezier', [x1, y1, x2, y2]); } static steps(value, step_position) { return new $mol_style_func('steps', [value, step_position]); } static blur(value) { return new $mol_style_func('blur', value ?? ""); } static brightness(value) { return new $mol_style_func('brightness', value ?? ""); } static contrast(value) { return new $mol_style_func('contrast', value ?? ""); } static drop_shadow(color, x_offset, y_offset, blur_radius) { return new $mol_style_func("drop-shadow", blur_radius ? [color, x_offset, y_offset, blur_radius] : [color, x_offset, y_offset]); } static grayscale(value) { return new $mol_style_func('grayscale', value ?? ""); } static hue_rotate(value) { return new $mol_style_func('hue-rotate', value ?? ""); } static invert(value) { return new $mol_style_func('invert', value ?? ""); } static opacity(value) { return new $mol_style_func('opacity', value ?? ""); } static sepia(value) { return new $mol_style_func('sepia', value ?? ""); } static saturate(value) { return new $mol_style_func('saturate', value ?? ""); } } $.$mol_style_func = $mol_style_func; })($ || ($ = {})); ; "use strict"; ; "use strict"; ; "use strict"; var $; (function ($) { function $mol_style_prop(prefix, keys) { const record = keys.reduce((rec, key) => { rec[key] = $mol_style_func.vary(`--${prefix}_${key}`); return rec; }, {}); return record; } $.$mol_style_prop = $mol_style_prop; })($ || ($ = {})); ; "use strict"; var $; (function ($) { $.$mol_theme = $mol_style_prop('mol_theme', [ 'back', 'hover', 'card', 'current', 'special', 'text', 'control', 'shade', 'line', 'focus', 'field', 'image', 'spirit', ]); })($ || ($ = {})); ; "use strict"; var $; (function ($) { $mol_style_attach("mol/theme/theme.css", ":root {\n\t--mol_theme_hue: 240deg;\n\t--mol_theme_hue_spread: 90deg;\n\tcolor-scheme: dark light;\n}\n\n:where([mol_theme]) {\n\tcolor: var(--mol_theme_text);\n\tfill: var(--mol_theme_text);\n\tbackground-color: var(--mol_theme_back);\n}\n\t\n:root, [mol_theme=\"$mol_theme_dark\"], :where([mol_theme=\"$mol_theme_dark\"]) [mol_theme] {\n\n\t--mol_theme_luma: -1;\n\t--mol_theme_image: invert(1) hue-rotate( 180deg );\n\t--mol_theme_spirit: hsl( 0deg, 0%, 0%, .75 );\n\n\t--mol_theme_back: hsl( var(--mol_theme_hue), 20%, 10% );\n\t--mol_theme_card: hsl( var(--mol_theme_hue), 50%, 20%, .25 );\n\t--mol_theme_field: hsl( var(--mol_theme_hue), 50%, 8%, .25 );\n\t--mol_theme_hover: hsl( var(--mol_theme_hue), 0%, 50%, .1 );\n\t\n\t--mol_theme_text: hsl( var(--mol_theme_hue), 0%, 80% );\n\t--mol_theme_shade: hsl( var(--mol_theme_hue), 0%, 60%, 1 );\n\t--mol_theme_line: hsl( var(--mol_theme_hue), 0%, 50%, .25 );\n\t--mol_theme_focus: hsl( calc( var(--mol_theme_hue) + 180deg ), 100%, 65% );\n\t\n\t--mol_theme_control: hsl( var(--mol_theme_hue), 60%, 65% );\n\t--mol_theme_current: hsl( calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ), 60%, 65% );\n\t--mol_theme_special: hsl( calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ), 60%, 65% );\n\n} @supports( color: oklch( 0% 0 0deg ) ) {\n:root, [mol_theme=\"$mol_theme_dark\"], :where([mol_theme=\"$mol_theme_dark\"]) [mol_theme] {\n\t\n\t--mol_theme_back: oklch( 20% .03 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 30% .05 var(--mol_theme_hue) / .25 );\n\t--mol_theme_field: oklch( 15% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_hover: oklch( 70% 0 var(--mol_theme_hue) / .1 );\n\t\n\t--mol_theme_text: oklch( 80% 0 var(--mol_theme_hue) );\n\t--mol_theme_shade: oklch( 60% 0 var(--mol_theme_hue) );\n\t--mol_theme_line: oklch( 60% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_focus: oklch( 80% .2 calc( var(--mol_theme_hue) + 180deg ) );\n\t\n\t--mol_theme_control: oklch( 70% .1 var(--mol_theme_hue) );\n\t--mol_theme_current: oklch( 70% .2 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_special: oklch( 70% .2 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\n} }\n\n[mol_theme=\"$mol_theme_light\"], :where([mol_theme=\"$mol_theme_light\"]) [mol_theme] {\n\t\n\t--mol_theme_luma: 1;\n\t--mol_theme_image: none;\n\t--mol_theme_spirit: hsl( 0deg, 0%, 100%, .75 );\n\t\n\t--mol_theme_back: hsl( var(--mol_theme_hue), 20%, 92% );\n\t--mol_theme_card: hsl( var(--mol_theme_hue), 50%, 100%, .5 );\n\t--mol_theme_field: hsl( var(--mol_theme_hue), 50%, 100%, .75 );\n\t--mol_theme_hover: hsl( var(--mol_theme_hue), 0%, 50%, .1 );\n\t\n\t--mol_theme_text: hsl( var(--mol_theme_hue), 0%, 0% );\n\t--mol_theme_shade: hsl( var(--mol_theme_hue), 0%, 40%, 1 );\n\t--mol_theme_line: hsl( var(--mol_theme_hue), 0%, 50%, .25 );\n\t--mol_theme_focus: hsl( calc( var(--mol_theme_hue) + 180deg ), 100%, 40% );\n\t\n\t--mol_theme_control: hsl( var(--mol_theme_hue), 80%, 30% );\n\t--mol_theme_current: hsl( calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ), 80%, 30% );\n\t--mol_theme_special: hsl( calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ), 80%, 30% );\n\n} @supports( color: oklch( 0% 0 0deg ) ) {\n[mol_theme=\"$mol_theme_light\"], :where([mol_theme=\"$mol_theme_light\"]) [mol_theme] {\n\t--mol_theme_back: oklch( 92% .01 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 99% .01 var(--mol_theme_hue) / .5 );\n\t--mol_theme_field: oklch( 100% 0 var(--mol_theme_hue) / .5 );\n\t--mol_theme_hover: oklch( 70% 0 var(--mol_theme_hue) / .1 );\n\t\n\t--mol_theme_text: oklch( 20% 0 var(--mol_theme_hue) );\n\t--mol_theme_shade: oklch( 60% 0 var(--mol_theme_hue) );\n\t--mol_theme_line: oklch( 50% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_focus: oklch( 60% .2 calc( var(--mol_theme_hue) + 180deg ) );\n\t\n\t--mol_theme_control: oklch( 40% .15 var(--mol_theme_hue) );\n\t--mol_theme_current: oklch( 50% .2 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_special: oklch( 50% .2 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\n} }\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_base\"] {\n\t--mol_theme_back: oklch( 25% .075 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 35% .1 var(--mol_theme_hue) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_base\"] {\n\t--mol_theme_back: oklch( 85% .075 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 98% .03 var(--mol_theme_hue) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_current\"] {\n\t--mol_theme_back: oklch( 25% .05 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 35% .1 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_current\"] {\n\t--mol_theme_back: oklch( 85% .05 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_special\"] {\n\t--mol_theme_back: oklch( 25% .05 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 35% .1 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_special\"] {\n\t--mol_theme_back: oklch( 85% .05 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_accent\"] {\n\t--mol_theme_back: oklch( 35% .1 calc( var(--mol_theme_hue) + 180deg ) );\n\t--mol_theme_card: oklch( 45% .15 calc( var(--mol_theme_hue) + 180deg ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_accent\"] {\n\t--mol_theme_back: oklch( 83% .1 calc( var(--mol_theme_hue) + 180deg ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) + 180deg ) / .25 );\n}\n\n"); })($ || ($ = {})); ; "use strict"; var $; (function ($) { $.$mol_gap = $mol_style_prop('mol_gap', [ 'block', 'text', 'round', 'space', 'blur', ]); })($ || ($ = {})); ; "use strict"; var $; (function ($) { $mol_style_attach("mol/gap/gap.css", ":root {\n\t--mol_gap_block: .75rem;\n\t--mol_gap_text: .5rem .75rem;\n\t--mol_gap_round: .25rem;\n\t--mol_gap_space: .25rem;\n\t--mol_gap_blur: .5rem;\n}\n"); })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_view_visible_width() { return $mol_window.size().width; } $.$mol_view_visible_width = $mol_view_visible_width; function $mol_view_visible_height() { return $mol_window.size().height; } $.$mol_view_visible_height = $mol_view_visible_height; function $mol_view_state_key(suffix) { return suffix; } $.$mol_view_state_key = $mol_view_state_key; class $mol_view extends $mol_object { static Root(id) { return new this; } autorun() { try { this.dom_tree(); document.title = this.title(); } catch (error) { $mol_fail_log(error); } } static autobind() { const nodes = $mol_dom_context.document.querySelectorAll('[mol_view_root]:not([mol_view_root=""])'); for (let i = nodes.length - 1; i >= 0; --i) { const name = nodes.item(i).getAttribute('mol_view_root'); const View = $[name]; if (!View) { console.error(`Can not attach view. Class not found: ${name}`); continue; } const view = View.Root(i); view.dom_node(nodes.item(i)); view.autorun(); } } title() { return this.toString().match(/.*\.(\w+)/)?.[1] ?? this.toString(); } focused(next) { let node = this.dom_node(); const value = $mol_view_selection.focused(next === undefined ? undefined : (next ? [node] : [])); return value.indexOf(node) !== -1; } state_key(suffix = '') { return this.$.$mol_view_state_key(suffix); } dom_name() { return $mol_dom_qname(this.constructor.toString()) || 'div'; } dom_name_space() { return 'http://www.w3.org/1999/xhtml'; } sub() { return []; } sub_visible() { return this.sub(); } minimal_width() { let min = 0; try { const sub = this.sub(); if (!sub) return 0; sub.forEach(view => { if (view instanceof $mol_view) { min = Math.max(min, view.minimal_width()); } }); } catch (error) { $mol_fail_log(error); return 24; } return min; } maximal_width() { return this.minimal_width(); } minimal_height() { let min = 0; try { for (const view of this.sub() ?? []) { if (view instanceof $mol_view) { min = Math.max(min, view.minimal_height()); } } } catch (error) { $mol_fail_log(error); return 24; } return min; } static watchers = new Set(); view_rect() { if ($mol_wire_probe(() => this.view_rect()) === undefined) { $mol_wire_watch(); return null; } else { const { width, height, left, right, top, bottom } = this.dom_node().getBoundingClientRect(); return { width, height, left, right, top, bottom }; } } dom_id() { return this.toString().replace(//g, ')').replaceAll(/"/g, "'"); } dom_node_external(next) { const node = next ?? $mol_dom_context.document.createElementNS(this.dom_name_space(), this.dom_name()); const id = this.dom_id(); node.setAttribute('id', id); node.toString = $mol_const('<#' + id + '>'); return node; } dom_node(next) { $mol_wire_solid(); const node = this.dom_node_external(next); $mol_dom_render_attributes(node, this.attr_static()); const events = this.event_async(); $mol_dom_render_events(node, events); return node; } dom_final() { this.render(); const sub = this.sub_visible(); if (!sub) return; for (const el of sub) { if (el && typeof el === 'object' && 'dom_final' in el) { el['dom_final'](); } } return this.dom_node(); } dom_tree(next) { const node = this.dom_node(next); render: try { $mol_dom_render_attributes(node, { mol_view_error: null }); try { this.render(); } finally { for (let plugin of this.plugins()) { if (plugin instanceof $mol_plugin) { plugin.dom_tree(); } } } } catch (error) { $mol_fail_log(error); const mol_view_error = $mol_promise_like(error) ? error.constructor[Symbol.toStringTag] ?? 'Promise' : error.name || error.constructor.name; $mol_dom_render_attributes(node, { mol_view_error }); if ($mol_promise_like(error)) break render; try { const message = error.message || error; node.innerText = message.replace(/^|$/mg, '\xA0\xA0'); } catch { } } try { this.auto(); } catch (error) { $mol_fail_log(error); } return node; } dom_node_actual() { const node = this.dom_node(); $mol_dom_render_styles(node, this.style_size()); const attr = this.attr(); const style = this.style(); $mol_dom_render_attributes(node, attr); $mol_dom_render_styles(node, style); return node; } auto() { return null; } render() { const node = this.dom_node_actual(); const sub = this.sub_visible(); if (!sub) return; const nodes = sub.map(child => { if (child == null) return null; return (child instanceof $mol_view) ? child.dom_node() : child instanceof $mol_dom_context.Node ? child : String(child); }); $mol_dom_render_children(node, nodes); for (const el of sub) if (el && typeof el === 'object' && 'dom_tree' in el) el['dom_tree'](); $mol_dom_render_fields(node, this.field()); } static view_classes() { const proto = this.prototype; let current = proto; const classes = []; while (current) { if (current.constructor.name !== classes.at(-1)?.name) { classes.push(current.constructor); } if (!(current instanceof $mol_view)) break; current = Object.getPrototypeOf(current); } return classes; } static _view_names; static view_names(suffix) { let cache = Reflect.getOwnPropertyDescriptor(this, '_view_names')?.value; if (!cache) cache = this._view_names = new Map; const cached = cache.get(suffix); if (cached) return cached; const names = []; const suffix2 = '_' + suffix[0].toLowerCase() + suffix.substring(1); for (const Class of this.view_classes()) { if (suffix in Class.prototype) names.push(this.$.$mol_func_name(Class) + suffix2); else break; } cache.set(suffix, names); return names; } view_names_owned() { const names = []; let owner = $mol_owning_get(this); if (!(owner?.host instanceof $mol_view)) return names; const suffix = owner.task.name.trim(); const suffix2 = '_' + suffix[0].toLowerCase() + suffix.substring(1); names.push(...owner.host.constructor.view_names(suffix)); for (let prefix of owner.host.view_names_owned()) { names.push(prefix + suffix2); } return names; } view_names() { const names = new Set(); for (let name of this.view_names_owned()) names.add(name); for (let Class of this.constructor.view_classes()) { const name = this.$.$mol_func_name(Class); if (name) names.add(name); } return names; } theme(next = null) { return next; } attr_static() { let attrs = {}; for (let name of this.view_names()) attrs[name.replace(/\$/g, '').replace(/^(?=\d)/, '_').toLowerCase()] = ''; return attrs; } attr() { return { mol_theme: this.theme() ?? undefined, }; } style_size() { return { minHeight: this.minimal_height(), minWidth: this.minimal_width(), }; } style() { return {}; } field() { return {}; } event() { return {}; } event_async() { return { ...$mol_wire_async(this.event()) }; } plugins() { return []; } [$mol_dev_format_head]() { return $mol_dev_format_span({}, $mol_dev_format_native(this)); } *view_find(check, path = []) { if (path.length === 0 && check(this)) return yield [this]; try { const checked = new Set(); const sub = this.sub(); for (const item of sub) { if (!(item instanceof $mol_view)) continue; if (!check(item)) continue; checked.add(item); yield [...path, this, item]; } for (const item of sub) { if (!(item instanceof $mol_view)) continue; if (checked.has(item)) continue; yield* item.view_find(check, [...path, this]); } } catch (error) { if ($mol_promise_like(error)) $mol_fail_hidden(error); $mol_fail_log(error); } } force_render(path) { const kids = this.sub(); const index = kids.findIndex(item => { if (item instanceof $mol_view) { return path.has(item); } else { return false; } }); if (index >= 0) { kids[index].force_render(path); } } ensure_visible(view, align = "start") { const path = this.view_find(v => v === view).next().value; this.force_render(new Set(path)); try { this.dom_final(); } finally { view.dom_node().scrollIntoView({ block: align }); } } bring() { const win = this.$.$mol_dom_context; if (win.parent !== win.self && !win.document.hasFocus()) return; new this.$.$mol_after_timeout(0, () => { this.focused(true); }); } destructor() { const node = $mol_wire_probe(() => this.dom_node()); if (!node) return; const events = $mol_wire_probe(() => this.event_async()); if (!events) return; for (let event_name in events) { node.removeEventListener(event_name, events[event_name]); } } } __decorate([ $mol_mem ], $mol_view.prototype, "autorun", null); __decorate([ $mol_mem ], $mol_view.prototype, "title", null); __decorate([ $mol_mem ], $mol_view.prototype, "focused", null); __decorate([ $mol_memo.method ], $mol_view.prototype, "dom_name", null); __decorate([ $mol_mem ], $mol_view.prototype, "minimal_width", null); __decorate([ $mol_mem ], $mol_view.prototype, "minimal_height", null); __decorate([ $mol_mem ], $mol_view.prototype, "view_rect", null); __decorate([ $mol_memo.method ], $mol_view.prototype, "dom_id", null); __decorate([ $mol_mem ], $mol_view.prototype, "dom_node", null); __decorate([ $mol_mem ], $mol_view.prototype, "dom_final", null); __decorate([ $mol_mem ], $mol_view.prototype, "dom_tree", null); __decorate([ $mol_mem ], $mol_view.prototype, "dom_node_actual", null); __decorate([ $mol_mem ], $mol_view.prototype, "render", null); __decorate([ $mol_memo.method ], $mol_view.prototype, "view_names_owned", null); __decorate([ $mol_memo.method ], $mol_view.prototype, "view_names", null); __decorate([ $mol_mem ], $mol_view.prototype, "theme", null); __decorate([ $mol_mem ], $mol_view.prototype, "event_async", null); __decorate([ $mol_mem_key ], $mol_view, "Root", null); __decorate([ $mol_mem ], $mol_view, "autobind", null); __decorate([ $mol_memo.method ], $mol_view, "view_classes", null); $.$mol_view = $mol_view; })($ || ($ = {})); ; "use strict"; var $; (function ($) { $mol_style_attach("mol/view/view/view.css", "[mol_view] {\n\ttransition-property: height, width, min-height, min-width, max-width, max-height, transform;\n\ttransition-duration: .2s;\n\ttransition-timing-function: ease-out;\n\t-webkit-appearance: none;\n\tbox-sizing: border-box;\n\tdisplay: flex;\n\tflex-shrink: 0;\n\tcontain: style;\n\tscrollbar-color: var(--mol_theme_line) transparent;\n\tscrollbar-width: thin;\n}\t\n\n[mol_view]::selection {\n\tbackground: var(--mol_theme_line);\n}\t\n\n[mol_view]::-webkit-scrollbar {\n\twidth: .25rem;\n\theight: .25rem;\n}\n\n[mol_view]::-webkit-scrollbar-corner {\n\tbackground-color: var(--mol_theme_line);\n}\n\n[mol_view]::-webkit-scrollbar-track {\n\tbackground-color: transparent;\n}\n\n[mol_view]::-webkit-scrollbar-thumb {\n\tbackground-color: var(--mol_theme_line);\n\tborder-radius: var(--mol_gap_round);\n}\n\n[mol_view] > * {\n\tword-break: inherit;\n}\n\n[mol_view_root] {\n\tmargin: 0;\n\tpadding: 0;\n\twidth: 100%;\n\theight: 100%;\n\tbox-sizing: border-box;\n\tfont-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n\tfont-size: 1rem;\n\tline-height: 1.5rem;\n\tbackground: var(--mol_theme_back);\n\tcolor: var(--mol_theme_text);\n\tcontain: unset; /** Fixes bg ignoring when applied to body on Chrome */\n\ttab-size: 4;\n\toverscroll-behavior: contain; /** Disable navigation gestures **/\n}\n\n@media print {\n\t[mol_view_root] {\n\t\theight: auto;\n\t}\n}\n[mol_view][mol_view_error]:not([mol_view_error=\"Promise\"], [mol_view_error=\"$mol_promise_blocker\"]) {\n\tbackground-image: repeating-linear-gradient(\n\t\t-45deg,\n\t\t#f92323,\n\t\t#f92323 .5rem,\n\t\t#ff3d3d .5rem,\n\t\t#ff3d3d 1.5rem\n\t);\n\tcolor: black;\n\talign-items: center;\n\tjustify-content: center;\n}\n\n@keyframes mol_view_wait {\n\tfrom {\n\t\topacity: .25;\n\t}\n\t20% {\n\t\topacity: .75;\n\t}\n\tto {\n\t\topacity: .25;\n\t}\n}\n\n:where([mol_view][mol_view_error=\"$mol_promise_blocker\"]),\n:where([mol_view][mol_view_error=\"Promise\"]) {\n\tbackground: var(--mol_theme_hover);\n}\n\n[mol_view][mol_view_error=\"Promise\"] {\n\tanimation: mol_view_wait 1s steps(20,end) infinite;\n}\n"); })($ || ($ = {})); ; "use strict"; var $; (function ($) { $mol_dom_context.document?.addEventListener('DOMContentLoaded', () => $mol_view.autobind(), { once: true }); })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_plugin extends $mol_view { dom_node_external(next) { return next ?? $mol_owning_get(this).host.dom_node(); } render() { this.dom_node_actual(); } } $.$mol_plugin = $mol_plugin; })($ || ($ = {})); ; ($.$mol_scroll) = class $mol_scroll extends ($.$mol_view) { tabindex(){ return -1; } event_scroll(next){ if(next !== undefined) return next; return null; } scroll_top(next){ if(next !== undefined) return next; return 0; } scroll_left(next){ if(next !== undefined) return next; return 0; } attr(){ return {...(super.attr()), "tabindex": (this.tabindex())}; } event(){ return {...(super.event()), "scroll": (next) => (this.event_scroll(next))}; } }; ($mol_mem(($.$mol_scroll.prototype), "event_scroll")); ($mol_mem(($.$mol_scroll.prototype), "scroll_top")); ($mol_mem(($.$mol_scroll.prototype), "scroll_left")); ; "use strict"; var $; (function ($) { class $mol_dom_listener extends $mol_object { _node; _event; _handler; _config; constructor(_node, _event, _handler, _config = { passive: true }) { super(); this._node = _node; this._event = _event; this._handler = _handler; this._config = _config; this._node.addEventListener(this._event, this._handler, this._config); } destructor() { this._node.removeEventListener(this._event, this._handler, this._config); super.destructor(); } } $.$mol_dom_listener = $mol_dom_listener; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_print extends $mol_object { static before() { return new $mol_dom_listener(this.$.$mol_dom_context, 'beforeprint', () => { this.active(true); }); } static after() { return new $mol_dom_listener(this.$.$mol_dom_context, 'afterprint', () => { this.active(false); }); } static active(next) { this.before(); this.after(); return next || false; } } __decorate([ $mol_mem ], $mol_print, "before", null); __decorate([ $mol_mem ], $mol_print, "after", null); __decorate([ $mol_mem ], $mol_print, "active", null); $.$mol_print = $mol_print; })($ || ($ = {})); ; "use strict"; ; "use strict"; ; "use strict"; ; "use strict"; ; "use strict"; var $; (function ($) { function $mol_style_sheet(Component, config0) { let rules = []; const block = $mol_dom_qname($mol_ambient({}).$mol_func_name(Component)); const kebab = (name) => name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase()); const make_class = (prefix, path, config) => { const props = []; const selector = (prefix, path) => { if (path.length === 0) return prefix || `[${block}]`; let res = `[${block}_${path.join('_')}]`; if (prefix) res = prefix + ' :where(' + res + ')'; return res; }; for (const key of Object.keys(config).reverse()) { if (/^(--)?[a-z]/.test(key)) { const addProp = (keys, val) => { if (Array.isArray(val)) { if (val[0] && [Array, Object].includes(val[0].constructor)) { val = val.map(v => { return Object.entries(v).map(([n, a]) => { if (a === true) return kebab(n); if (a === false) return null; return String(a); }).filter(Boolean).join(' '); }).join(','); } else { val = val.join(' '); } props.push(`\t${keys.join('-')}: ${val};\n`); } else if (val.constructor === Object) { for (let suffix of Object.keys(val).reverse()) { addProp([...keys, kebab(suffix)], val[suffix]); } } else { props.push(`\t${keys.join('-')}: ${val};\n`); } }; addProp([kebab(key)], config[key]); } else if (/^[A-Z]/.test(key)) { make_class(prefix, [...path, key.toLowerCase()], config[key]); } else if (key[0] === '$') { make_class(selector(prefix, path) + ' :where([' + $mol_dom_qname(key) + '])', [], config[key]); } else if (key === '>') { const types = config[key]; for (let type of Object.keys(types).reverse()) { make_class(selector(prefix, path) + ' > :where([' + $mol_dom_qname(type) + '])', [], types[type]); } } else if (key === '@') { const attrs = config[key]; for (let name of Object.keys(attrs).reverse()) { for (let val in attrs[name]) { make_class(selector(prefix, path) + ':where([' + name + '=' + JSON.stringify(val) + '])', [], attrs[name][val]); } } } else if (key === '@media') { const media = config[key]; for (let query of Object.keys(media).reverse()) { rules.push('}\n'); make_class(prefix, path, media[query]); rules.push(`${key} ${query} {\n`); } } else if (key[0] === '[' && key[key.length - 1] === ']') { const attr = key.slice(1, -1); const vals = config[key]; for (let val of Object.keys(vals).reverse()) { make_class(selector(prefix, path) + ':where([' + attr + '=' + JSON.stringify(val) + '])', [], vals[val]); } } else { make_class(selector(prefix, path) + key, [], config[key]); } } if (props.length) { rules.push(`${selector(prefix, path)} {\n${props.reverse().join('')}}\n`); } }; make_class('', [], config0); return rules.reverse().join(''); } $.$mol_style_sheet = $mol_style_sheet; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_style_define(Component, config) { return $mol_style_attach(Component.name, $mol_style_sheet(Component, config)); } $.$mol_style_define = $mol_style_define; })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_scroll extends $.$mol_scroll { scroll_top(next, cache) { const el = this.dom_node(); if (next !== undefined && !cache) el.scrollTop = next; return el.scrollTop; } scroll_left(next, cache) { const el = this.dom_node(); if (next !== undefined && !cache) el.scrollLeft = next; return el.scrollLeft; } event_scroll(next) { const el = this.dom_node(); this.scroll_left(el.scrollLeft, 'cache'); this.scroll_top(el.scrollTop, 'cache'); } minimal_height() { return this.$.$mol_print.active() ? null : 0; } minimal_width() { return this.$.$mol_print.active() ? null : 0; } } __decorate([ $mol_mem ], $mol_scroll.prototype, "scroll_top", null); __decorate([ $mol_mem ], $mol_scroll.prototype, "scroll_left", null); $$.$mol_scroll = $mol_scroll; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { var $$; (function ($$) { const { per, rem, px } = $mol_style_unit; $mol_style_define($mol_scroll, { display: 'grid', overflow: 'auto', flex: { direction: 'column', grow: 1, shrink: 1, }, outline: 'none', align: { self: 'stretch', items: 'flex-start', }, boxSizing: 'border-box', willChange: 'scroll-position', scroll: { padding: [rem(.75), 0], }, maxHeight: per(100), maxWidth: per(100), webkitOverflowScrolling: 'touch', contain: 'content', '>': { $mol_view: { gridArea: '1/1', }, }, '::before': { display: 'none', }, '::after': { display: 'none', }, '::-webkit-scrollbar': { width: rem(.25), height: rem(.25), }, '@media': { 'print': { overflow: 'hidden', contain: 'none', maxHeight: 'unset', }, }, }); })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; ($.$mol_book2) = class $mol_book2 extends ($.$mol_scroll) { pages_deep(){ return []; } pages(){ return (this.pages_deep()); } Placeholder(){ const obj = new this.$.$mol_view(); return obj; } placeholders(){ return [(this.Placeholder())]; } menu_title(){ return ""; } sub(){ return [...(this.pages()), ...(this.placeholders())]; } minimal_width(){ return 0; } Gap(id){ const obj = new this.$.$mol_view(); (obj.title) = () => (""); return obj; } }; ($mol_mem(($.$mol_book2.prototype), "Placeholder")); ($mol_mem_key(($.$mol_book2.prototype), "Gap")); ; "use strict"; var $; (function ($) { $.$mol_mem_cached = $mol_wire_probe; })($ || ($ = {})); ; "use strict"; var $; (function ($) { $.$mol_layer = $mol_style_prop('mol_layer', [ 'hover', 'focus', 'speck', 'float', 'popup', ]); })($ || ($ = {})); ; "use strict"; var $; (function ($) { $mol_style_attach("mol/layer/layer.css", ":root {\n\t--mol_layer_hover: 1;\n\t--mol_layer_focus: 2;\n\t--mol_layer_speck: 3;\n\t--mol_layer_float: 4;\n\t--mol_layer_popup: 5;\n}\n"); })($ || ($ = {})); ; "use strict"; ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_book2 extends $.$mol_book2 { pages_deep() { let result = []; for (const subpage of this.pages()) { if (subpage instanceof $mol_book2) result = [...result, ...subpage.pages_deep()]; else result.push(subpage); } return result; } title() { return this.pages_deep().map(page => { try { return page?.title(); } catch (error) { $mol_fail_log(error); } }).reverse().filter(Boolean).join(' | '); } menu_title() { return this.pages_deep()[0]?.title() || this.title(); } sub() { const placeholders = this.placeholders(); const next = this.pages_deep().filter(Boolean); const prev = $mol_mem_cached(() => this.sub())?.filter(page => !placeholders.includes(page)) ?? []; for (let i = 1; i; ++i) { const p = prev[prev.length - i]; const n = next[next.length - i]; if (!n) break; if (p === n) continue; new this.$.$mol_after_tick(() => { const b = this.dom_node(); const p = n.dom_node(); b.scroll({ left: p.offsetLeft + p.offsetWidth - b.offsetWidth, behavior: 'smooth', }); }); break; } return [...next, ...placeholders]; } bring() { const pages = this.pages_deep(); if (pages.length) pages[pages.length - 1].bring(); else super.bring(); } } __decorate([ $mol_mem ], $mol_book2.prototype, "pages_deep", null); __decorate([ $mol_mem ], $mol_book2.prototype, "sub", null); $$.$mol_book2 = $mol_book2; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { $mol_style_attach("mol/book2/book2.view.css", "[mol_book2] {\n\tdisplay: flex;\n\tflex-flow: row nowrap;\n\talign-items: stretch;\n\tflex: 1 1 auto;\n\talign-self: stretch;\n\tmargin: 0;\n\t/* box-shadow: 0 0 0 1px var(--mol_theme_line); */\n\t/* transform: translateZ(0); */\n\ttransition: none;\n\tscroll-snap-type: x mandatory;\n\t/* padding: 0 1px;\n\tscroll-padding: 0 1px;\n\tgap: 1px; */\n}\n\n[mol_book2] > * {\n/* \tflex: none; */\n\tscroll-snap-stop: always;\n\tscroll-snap-align: end;\n\tposition: relative;\n\tmin-height: 100%;\n\tmax-height: 100%;\n\tmax-width: 100%;\n\tflex-shrink: 0;\n\tbox-shadow: inset 0 0 0 1px var(--mol_theme_field);\n}\n\n[mol_book2] > *:not(:first-of-type):before,\n[mol_book2] > *:not(:last-of-type)::after {\n\tcontent: '';\n\tposition: absolute;\n\ttop: 1.5rem;\n\twidth: 3px;\n\theight: 1rem;\n\tbackground: linear-gradient(\n\t\tto bottom,\n\t\tvar(--mol_theme_special) 0%,\n\t\tvar(--mol_theme_special) 14%,\n\t\ttransparent 15%,\n\t\ttransparent 42%,\n\t\tvar(--mol_theme_special) 43%,\n\t\tvar(--mol_theme_special) 57%,\n\t\ttransparent 58%,\n\t\ttransparent 85%,\n\t\tvar(--mol_theme_special) 86%,\n\t\tvar(--mol_theme_special) 100%\n\t);\n\topacity: .5;\n\tz-index: var(--mol_layer_speck);\n}\n[mol_book2] > *:not(:first-of-type):before {\n\tleft: -3px;\n}\n[mol_book2] > *:not(:last-of-type)::after {\n\tright: -3px;\n}\n\n:where([mol_book2]) > * {\n\tbackground-color: var(--mol_theme_card);\n\t/* box-shadow: 0 0 0 1px var(--mol_theme_back); */\n}\n\n[mol_book2] > [mol_book2] {\n\tdisplay: contents;\n}\n\n[mol_book2] > *:first-child {\n\tscroll-snap-align: start;\n}\n\n[mol_book2] > [mol_view] {\n\ttransform: none; /* prevent content clipping */\n}\n\n[mol_book2_placeholder] {\n\tflex: 1 1 0;\n\tbackground: none;\n}\n\n[mol_book2_gap] {\n\tbackground: none;\n\tflex-grow: 1;\n\tscroll-snap-align: none;\n\tmargin-right: -1px;\n\tbox-shadow: none;\n}\n\n[mol_book2_gap]::before,\n[mol_book2_gap]::after {\n\tdisplay: none;\n}\n"); })($ || ($ = {})); ; ($.$mol_pop) = class $mol_pop extends ($.$mol_view) { Anchor(){ return null; } align(){ return "bottom_center"; } bubble_content(){ return []; } height_max(){ return 9999; } Bubble(){ const obj = new this.$.$mol_pop_bubble(); (obj.align) = () => ((this.align())); (obj.content) = () => ((this.bubble_content())); (obj.height_max) = () => ((this.height_max())); return obj; } showed(next){ if(next !== undefined) return next; return false; } align_vert(){ return ""; } align_hor(){ return ""; } prefer(){ return "vert"; } sub(){ return [(this.Anchor())]; } sub_visible(){ return [(this.Anchor()), (this.Bubble())]; } }; ($mol_mem(($.$mol_pop.prototype), "Bubble")); ($mol_mem(($.$mol_pop.prototype), "showed")); ($.$mol_pop_bubble) = class $mol_pop_bubble extends ($.$mol_view) { content(){ return []; } height_max(){ return 9999; } align(){ return ""; } sub(){ return (this.content()); } style(){ return {...(super.style()), "maxHeight": (this.height_max())}; } attr(){ return { ...(super.attr()), "mol_pop_align": (this.align()), "tabindex": 0 }; } }; ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_pop extends $.$mol_pop { showed(next = false) { this.focused(); return next; } sub_visible() { return [ this.Anchor(), ...this.showed() ? [this.Bubble()] : [], ]; } height_max() { const viewport = this.$.$mol_window.size(); const rect_bubble = this.view_rect(); const align = this.align_vert(); if (align === 'bottom') return (viewport.height - rect_bubble.bottom) * .66; if (align === 'top') return rect_bubble.top * .66; return 0; } align() { switch (this.prefer()) { case 'hor': return `${this.align_hor()}_${this.align_vert()}`; case 'vert': return `${this.align_vert()}_${this.align_hor()}`; default: return this.prefer(); } } align_vert() { const viewport = this.view_port(); const rect_pop = this.view_rect(); if (!rect_pop) return 'suspense'; return rect_pop.top > (viewport.top + viewport.height / 2) ? 'top' : 'bottom'; } align_hor() { const viewport = this.view_port(); const rect_pop = this.view_rect(); if (!rect_pop) return 'suspense'; return rect_pop.left > (viewport.left + viewport.width / 2) ? 'left' : 'right'; } View_port() { const view = new $mol_view; view.dom_node = () => { let node = this.dom_node(); while (node = node.offsetParent) { if (this.$.$mol_dom_context.getComputedStyle(node).overflow !== 'visible') return node; } return this.$.$mol_dom_context.document.documentElement; }; return view; } view_port() { return this.View_port().view_rect() ?? { ...this.$.$mol_window.size(), left: 0, top: 0 }; } } __decorate([ $mol_mem ], $mol_pop.prototype, "showed", null); __decorate([ $mol_mem ], $mol_pop.prototype, "sub_visible", null); __decorate([ $mol_mem ], $mol_pop.prototype, "height_max", null); __decorate([ $mol_mem ], $mol_pop.prototype, "align", null); __decorate([ $mol_mem ], $mol_pop.prototype, "align_vert", null); __decorate([ $mol_mem ], $mol_pop.prototype, "align_hor", null); __decorate([ $mol_mem ], $mol_pop.prototype, "View_port", null); __decorate([ $mol_mem ], $mol_pop.prototype, "view_port", null); $$.$mol_pop = $mol_pop; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { $mol_style_attach("mol/pop/pop.view.css", "[mol_pop] {\n\tposition: relative;\n\tdisplay: inline-flex;\n}\n\n[mol_pop_bubble] {\n\tbox-shadow: 0 0 1rem hsla(0,0%,0%,.5);\n\tborder-radius: var(--mol_gap_round);\n\tposition: absolute;\n\tz-index: var(--mol_layer_popup);\n\tbackground: var(--mol_theme_back);\n\tmax-width: none;\n\tmax-height: none;\n\t/* overflow: hidden;\n\toverflow-y: scroll;\n\toverflow-y: overlay; */\n\tword-break: normal;\n\twidth: max-content;\n\t/* height: max-content; */\n\tflex-direction: column;\n\tmax-width: 80vw;\n\tmax-height: 80vw;\n\tcontain: paint;\n\ttransition-property: opacity;\n}\n\n:where( [mol_pop_bubble] > * ) {\n\tbackground: var(--mol_theme_card);\n}\n\n[mol_pop_bubble][mol_scroll] {\n\tbackground: var(--mol_theme_back);\n}\n\n[mol_pop_bubble]:focus {\n\toutline: none;\n}\n\n[mol_pop_align=\"suspense_suspense\"] {\n\topacity: 0;\n}\n\n[mol_pop_align=\"left_top\"] {\n\ttransform: translate(-100%);\n\tleft: 0;\n\tbottom: 0;\n}\n\n[mol_pop_align=\"left_center\"] {\n\ttransform: translate(-100%, -50%);\n\tleft: 0;\n\ttop: 50%;\n}\n\n[mol_pop_align=\"left_bottom\"] {\n\ttransform: translate(-100%);\n\tleft: 0;\n\ttop: 0;\n}\n\n[mol_pop_align=\"right_top\"] {\n\ttransform: translate(100%);\n\tright: 0;\n\tbottom: 0;\n}\n\n[mol_pop_align=\"right_center\"] {\n\ttransform: translate(100%, -50%);\n\tright: 0;\n\ttop: 50%;\n}\n\n[mol_pop_align=\"right_bottom\"] {\n\ttransform: translate(100%);\n\tright: 0;\n\ttop: 0;\n}\n\n[mol_pop_align=\"center\"] {\n\tleft: 50%;\n\ttop: 50%;\n\ttransform: translate(-50%, -50%);\n}\n\n[mol_pop_align=\"top_left\"] {\n\tright: 0;\n\tbottom: 100%;\n}\n\n[mol_pop_align=\"top_center\"] {\n\ttransform: translate(-50%);\n\tleft: 50%;\n\tbottom: 100%;\n}\n\n[mol_pop_align=\"top_right\"] {\n\tleft: 0;\n\tbottom: 100%;\n}\n\n[mol_pop_align=\"bottom_left\"] {\n\tright: 0;\n\ttop: 100%;\n}\n\n[mol_pop_align=\"bottom_center\"] {\n\ttransform: translate(-50%);\n\tleft: 50%;\n\ttop: 100%;\n}\n\n[mol_pop_align=\"bottom_right\"] {\n\tleft: 0;\n\ttop: 100%;\n}\n"); })($ || ($ = {})); ; ($.$mol_hotkey) = class $mol_hotkey extends ($.$mol_plugin) { keydown(next){ if(next !== undefined) return next; return null; } event(){ return {...(super.event()), "keydown": (next) => (this.keydown(next))}; } key(){ return {}; } mod_ctrl(){ return false; } mod_alt(){ return false; } mod_shift(){ return false; } }; ($mol_mem(($.$mol_hotkey.prototype), "keydown")); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_hotkey extends $.$mol_hotkey { key() { return super.key(); } keydown(event) { if (!event) return; if (event.defaultPrevented) return; let name = $mol_keyboard_code[event.keyCode]; if (this.mod_ctrl() !== (event.ctrlKey || event.metaKey)) return; if (this.mod_alt() !== event.altKey) return; if (this.mod_shift() !== event.shiftKey) return; const handle = this.key()[name]; if (handle) handle(event); } } $$.$mol_hotkey = $mol_hotkey; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; ($.$mol_nav) = class $mol_nav extends ($.$mol_plugin) { event_key(next){ if(next !== undefined) return next; return null; } cycle(next){ if(next !== undefined) return next; return false; } mod_ctrl(){ return false; } mod_shift(){ return false; } mod_alt(){ return false; } keys_x(next){ if(next !== undefined) return next; return []; } keys_y(next){ if(next !== undefined) return next; return []; } current_x(next){ if(next !== undefined) return next; return null; } current_y(next){ if(next !== undefined) return next; return null; } event_up(next){ if(next !== undefined) return next; return null; } event_down(next){ if(next !== undefined) return next; return null; } event_left(next){ if(next !== undefined) return next; return null; } event_right(next){ if(next !== undefined) return next; return null; } event(){ return {...(super.event()), "keydown": (next) => (this.event_key(next))}; } }; ($mol_mem(($.$mol_nav.prototype), "event_key")); ($mol_mem(($.$mol_nav.prototype), "cycle")); ($mol_mem(($.$mol_nav.prototype), "keys_x")); ($mol_mem(($.$mol_nav.prototype), "keys_y")); ($mol_mem(($.$mol_nav.prototype), "current_x")); ($mol_mem(($.$mol_nav.prototype), "current_y")); ($mol_mem(($.$mol_nav.prototype), "event_up")); ($mol_mem(($.$mol_nav.prototype), "event_down")); ($mol_mem(($.$mol_nav.prototype), "event_left")); ($mol_mem(($.$mol_nav.prototype), "event_right")); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_nav extends $.$mol_nav { event_key(event) { if (!event) return event; if (event.defaultPrevented) return; if (this.mod_ctrl() && !event.ctrlKey) return; if (this.mod_shift() && !event.shiftKey) return; if (this.mod_alt() && !event.altKey) return; switch (event.keyCode) { case $mol_keyboard_code.up: return this.event_up(event); case $mol_keyboard_code.down: return this.event_down(event); case $mol_keyboard_code.left: return this.event_left(event); case $mol_keyboard_code.right: return this.event_right(event); case $mol_keyboard_code.pageUp: return this.event_up(event); case $mol_keyboard_code.pageDown: return this.event_down(event); } } event_up(event) { if (!event) return event; const keys = this.keys_y(); if (keys.length < 1) return; const index_y = this.index_y(); const index_old = index_y === null ? 0 : index_y; const index_new = (index_old + keys.length - 1) % keys.length; event.preventDefault(); if (index_old === 0 && !this.cycle()) return; this.current_y(this.keys_y()[index_new]); } event_down(event) { if (!event) return event; const keys = this.keys_y(); if (keys.length < 1) return; const index_y = this.index_y(); const index_old = index_y === null ? keys.length - 1 : index_y; const index_new = (index_old + 1) % keys.length; event.preventDefault(); if (index_new === 0 && !this.cycle()) return; this.current_y(this.keys_y()[index_new]); } event_left(event) { if (!event) return event; const keys = this.keys_x(); if (keys.length < 1) return; const index_x = this.index_x(); const index_old = index_x === null ? 0 : index_x; const index_new = (index_old + keys.length - 1) % keys.length; event.preventDefault(); if (index_old === 0 && !this.cycle()) return; this.current_x(this.keys_x()[index_new]); } event_right(event) { if (!event) return event; const keys = this.keys_x(); if (keys.length < 1) return; const index_x = this.index_x(); const index_old = index_x === null ? keys.length - 1 : index_x; const index_new = (index_old + 1) % keys.length; event.preventDefault(); if (index_new === 0 && !this.cycle()) return; this.current_x(this.keys_x()[index_new]); } index_y() { let index = this.keys_y().indexOf(this.current_y()); if (index < 0) return null; return index; } index_x() { let index = this.keys_x().indexOf(this.current_x()); if (index < 0) return null; return index; } } $$.$mol_nav = $mol_nav; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { $.$mol_mem_persist = $mol_wire_solid; })($ || ($ = {})); ; "use strict"; var $; (function ($) { const factories = new WeakMap(); function factory(val) { let make = factories.get(val); if (make) return make; make = $mol_func_name_from((...args) => new val(...args), val); factories.set(val, make); return make; } const getters = new WeakMap(); function get_prop(host, field) { let props = getters.get(host); let get_val = props?.[field]; if (get_val) return get_val; get_val = (next) => { if (next !== undefined) host[field] = next; return host[field]; }; Object.defineProperty(get_val, 'name', { value: field }); if (!props) { props = {}; getters.set(host, props); } props[field] = get_val; return get_val; } function $mol_wire_sync(obj) { return new Proxy(obj, { get(obj, field) { let val = obj[field]; const temp = $mol_wire_task.getter(typeof val === 'function' ? val : get_prop(obj, field)); if (typeof val !== 'function') return temp(obj, []).sync(); return function $mol_wire_sync(...args) { const fiber = temp(obj, args); return fiber.sync(); }; }, set(obj, field, next) { const temp = $mol_wire_task.getter(get_prop(obj, field)); temp(obj, [next]).sync(); return true; }, construct(obj, args) { const temp = $mol_wire_task.getter(factory(obj)); return temp(obj, args).sync(); }, apply(obj, self, args) { const temp = $mol_wire_task.getter(obj); return temp(self, args).sync(); }, }); } $.$mol_wire_sync = $mol_wire_sync; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_storage extends $mol_object2 { static native() { return this.$.$mol_dom_context.navigator.storage ?? { persisted: async () => false, persist: async () => false, estimate: async () => ({}), getDirectory: async () => null, }; } static persisted(next, cache) { $mol_mem_persist(); if (cache) return Boolean(next); const native = this.native(); if (next && !$mol_mem_cached(() => this.persisted())) { native.persist().then(actual => { setTimeout(() => this.persisted(actual, 'cache'), 5000); if (actual) this.$.$mol_log3_done({ place: `$mol_storage`, message: `Persist: Yes` }); else this.$.$mol_log3_fail({ place: `$mol_storage`, message: `Persist: No` }); }); } return next ?? $mol_wire_sync(native).persisted(); } static estimate() { return $mol_wire_sync(this.native() ?? {}).estimate(); } static dir() { return $mol_wire_sync(this.native()).getDirectory(); } } __decorate([ $mol_mem ], $mol_storage, "native", null); __decorate([ $mol_mem ], $mol_storage, "persisted", null); $.$mol_storage = $mol_storage; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_state_local extends $mol_object { static 'native()'; static native() { if (this['native()']) return this['native()']; check: try { const native = $mol_dom_context.localStorage; if (!native) break check; native.setItem('', ''); native.removeItem(''); return this['native()'] = native; } catch (error) { console.warn(error); } return this['native()'] = { getItem(key) { return this[':' + key]; }, setItem(key, value) { this[':' + key] = value; }, removeItem(key) { this[':' + key] = void 0; } }; } static changes(next) { return next; } static value(key, next) { this.changes(); if (next === void 0) return JSON.parse(this.native().getItem(key) || 'null'); if (next === null) { this.native().removeItem(key); } else { this.native().setItem(key, JSON.stringify(next)); this.$.$mol_storage.persisted(true); } return next; } prefix() { return ''; } value(key, next) { return $mol_state_local.value(this.prefix() + '.' + key, next); } } __decorate([ $mol_mem ], $mol_state_local, "changes", null); __decorate([ $mol_mem_key ], $mol_state_local, "value", null); $.$mol_state_local = $mol_state_local; })($ || ($ = {})); ; "use strict"; var $; (function ($) { self.addEventListener('storage', event => $.$mol_state_local.changes(event)); })($ || ($ = {})); ; "use strict"; var $; (function ($) { $.$mol_action = $mol_wire_method; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_lock extends $mol_object { promise = null; async wait() { let next = () => { }; let destructed = false; const task = $mol_wire_auto(); if (!task) return next; const destructor = task.destructor.bind(task); task.destructor = () => { destructor(); destructed = true; next(); }; let promise; do { promise = this.promise; await promise; if (destructed) return next; } while (promise !== this.promise); this.promise = new Promise(done => { next = done; }); return next; } grab() { return $mol_wire_sync(this).wait(); } } $.$mol_lock = $mol_lock; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_compare_array(a, b) { if (a === b) return true; if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false; if (a.length !== b.length) return false; for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false; return true; } $.$mol_compare_array = $mol_compare_array; })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { const decoders = {}; function $mol_charset_decode(buffer, encoding = 'utf8') { let decoder = decoders[encoding]; if (!decoder) decoder = decoders[encoding] = new TextDecoder(encoding); return decoder.decode(buffer); } $.$mol_charset_decode = $mol_charset_decode; })($ || ($ = {})); ; "use strict"; ; "use strict"; var $node = $node || {}; ; "use strict"; var $; (function ($) { const TextEncoder = globalThis.TextEncoder ?? $node.util.TextEncoder; const encoder = new TextEncoder(); function $mol_charset_encode(value) { return encoder.encode(value); } $.$mol_charset_encode = $mol_charset_encode; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_file_transaction extends $mol_object { path() { return ''; } modes() { return []; } write(options) { return 0; } read() { return new Uint8Array(); } truncate(size) { } close() { } destructor() { this.close(); } } $.$mol_file_transaction = $mol_file_transaction; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_file_transaction_web extends $mol_file_transaction { write(options) { throw new Error('Not implemented'); } truncate(size) { throw new Error('Not implemented'); } read() { throw new Error('Not implemented'); } close() { throw new Error('Not implemented'); } } $.$mol_file_transaction_web = $mol_file_transaction_web; $.$mol_file_transaction = $mol_file_transaction_web; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_file_base extends $mol_object { static absolute(path) { return this.make({ path: $mol_const(path) }); } static relative(path) { throw new Error('Not implemented yet'); } static base = ''; path() { return '.'; } parent() { return this.resolve('..'); } exists_cut() { return this.exists(); } root() { const path = this.path(); const base = this.constructor.base; return base.startsWith(path) || this == this.parent(); } stat(next, virt) { const path = this.path(); const parent = this.parent(); if (!this.root()) { parent.version(); } parent.watcher(); if (virt) return next ?? null; return next ?? this.info(path); } static changed = new Set; static frame = null; static changed_add(type, path) { if (/([\/\\]\.|___$)/.test(path)) return; const file = this.relative(path.at(-1) === '/' ? path.slice(0, -1) : path); this.changed.add(file); if (!this.watching) return; this.frame?.destructor(); this.frame = new this.$.$mol_after_timeout(this.watch_debounce(), () => { if (!this.watching) return; this.watching = false; $mol_wire_async(this).flush(); }); } static watch_debounce() { return 500; } static flush() { for (const file of this.changed) { const parent = file.parent(); try { if ($mol_wire_probe(() => parent.sub())) parent.sub(null); file.reset(); } catch (error) { if ($mol_fail_catch(error)) $mol_fail_log(error); } } this.changed.clear(); this.watching = true; } static watching = true; static lock = new $mol_lock; static watch_off(path) { this.watching = false; this.flush(); this.watching = false; this.changed.add(this.absolute(path)); } static unwatched(side_effect, affected_dir) { const unlock = this.lock.grab(); this.watch_off(affected_dir); try { const result = side_effect(); this.flush(); unlock(); return result; } catch (e) { if (!$mol_promise_like(e)) { this.flush(); unlock(); } $mol_fail_hidden(e); } } reset() { this.stat(null); } modified() { return this.stat()?.mtime ?? null; } version() { const next = this.stat()?.mtime.getTime().toString(36).toUpperCase() ?? ''; return next; } info(path) { return null; } ensure() { } drop() { } copy(to) { } read() { return new Uint8Array; } write(buffer) { } kids() { return []; } readable(opts) { return new ReadableStream; } writable(opts) { return new WritableStream; } buffer(next) { let readed = new Uint8Array(); if (next === undefined) { if (this.version()) readed = this.read(); } const prev = $mol_mem_cached(() => this.buffer()); const changed = prev === undefined || !$mol_compare_array(prev, next ?? readed); if (prev !== undefined && changed) { this.$.$mol_log3_rise({ place: `$mol_file_node.buffer()`, message: 'Changed', path: this.relate(), }); } if (next === undefined) return changed ? readed : prev; if (!changed && this.exists()) return prev; this.parent().exists(true); this.stat(this.stat_make(next.length), 'virt'); this.write(next); return next; } stat_make(size) { const now = new Date(); return { type: 'file', size, atime: now, mtime: now, ctime: now, }; } clone(to) { if (!this.exists()) return null; const target = this.constructor.absolute(to); try { this.version(); target.parent().exists(true); this.copy(to); target.reset(); return target; } catch (error) { if ($mol_fail_catch(error)) { console.error(error); } } return null; } watcher() { return { destructor() { } }; } exists(next) { const exists = Boolean(this.stat()); if (next === undefined) return exists; if (next === exists) return exists; if (next) { this.parent().exists(true); this.ensure(); } else { this.drop(); } this.reset(); return next; } type() { return this.stat()?.type ?? ''; } name() { return this.path().replace(/^.*\//, ''); } ext() { const match = /((?:\.\w+)+)$/.exec(this.path()); return match ? match[1].substring(1) : ''; } text(next, virt) { if (next !== undefined) this.exists(); return this.text_int(next, virt); } text_int(next, virt) { if (virt) { this.stat(this.stat_make(0), 'virt'); return next; } if (next === undefined) { return $mol_charset_decode(this.buffer()); } else { const buffer = $mol_charset_encode(next); this.buffer(buffer); return next; } } sub(reset) { if (!this.exists()) return []; if (this.type() !== 'dir') return []; this.version(); return this.kids().filter(file => file.exists()); } resolve(path) { throw new Error('implement'); } relate(base = this.constructor.relative('.')) { const base_path = base.path(); const path = this.path(); return path.startsWith(base_path) ? path.slice(base_path.length) : path; } find(include, exclude) { const found = []; const sub = this.sub(); for (const child of sub) { const child_path = child.path(); if (exclude && child_path.match(exclude)) continue; if (!include || child_path.match(include)) found.push(child); if (child.type() === 'dir') { const sub_child = child.find(include, exclude); for (const child of sub_child) found.push(child); } } return found; } size() { switch (this.type()) { case 'file': return this.stat()?.size ?? 0; default: return 0; } } toJSON() { return this.path(); } open(...modes) { return this.$.$mol_file_transaction.make({ path: () => this.path(), modes: () => modes }); } } __decorate([ $mol_action ], $mol_file_base.prototype, "exists_cut", null); __decorate([ $mol_mem ], $mol_file_base.prototype, "stat", null); __decorate([ $mol_mem ], $mol_file_base.prototype, "modified", null); __decorate([ $mol_mem ], $mol_file_base.prototype, "version", null); __decorate([ $mol_mem_key ], $mol_file_base.prototype, "readable", null); __decorate([ $mol_mem_key ], $mol_file_base.prototype, "writable", null); __decorate([ $mol_mem ], $mol_file_base.prototype, "buffer", null); __decorate([ $mol_action ], $mol_file_base.prototype, "stat_make", null); __decorate([ $mol_mem_key ], $mol_file_base.prototype, "clone", null); __decorate([ $mol_mem ], $mol_file_base.prototype, "exists", null); __decorate([ $mol_mem ], $mol_file_base.prototype, "type", null); __decorate([ $mol_mem ], $mol_file_base.prototype, "text_int", null); __decorate([ $mol_mem ], $mol_file_base.prototype, "sub", null); __decorate([ $mol_mem ], $mol_file_base.prototype, "size", null); __decorate([ $mol_action ], $mol_file_base.prototype, "open", null); __decorate([ $mol_mem_key ], $mol_file_base, "absolute", null); __decorate([ $mol_action ], $mol_file_base, "flush", null); __decorate([ $mol_action ], $mol_file_base, "watch_off", null); $.$mol_file_base = $mol_file_base; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_file extends $mol_file_base { } $.$mol_file = $mol_file; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_dom_parse(text, type = 'application/xhtml+xml') { const parser = new $mol_dom_context.DOMParser(); const doc = parser.parseFromString(text, type); const error = doc.getElementsByTagName('parsererror'); if (error.length) throw new Error(error[0].textContent); return doc; } $.$mol_dom_parse = $mol_dom_parse; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_fetch_response extends $mol_object2 { native; constructor(native) { super(); this.native = native; } status() { const types = ['unknown', 'inform', 'success', 'redirect', 'wrong', 'failed']; return types[Math.floor(this.native.status / 100)]; } code() { return this.native.status; } message() { return this.native.statusText || `HTTP Error ${this.code()}`; } headers() { return this.native.headers; } mime() { return this.headers().get('content-type'); } stream() { return this.native.body; } text() { const buffer = this.buffer(); const native = this.native; const mime = native.headers.get('content-type') || ''; const [, charset] = /charset=(.*)/.exec(mime) || [, 'utf-8']; const decoder = new TextDecoder(charset); return decoder.decode(buffer); } json() { return $mol_wire_sync(this.native).json(); } blob() { return $mol_wire_sync(this.native).blob(); } buffer() { return $mol_wire_sync(this.native).arrayBuffer(); } xml() { return $mol_dom_parse(this.text(), 'application/xml'); } xhtml() { return $mol_dom_parse(this.text(), 'application/xhtml+xml'); } html() { return $mol_dom_parse(this.text(), 'text/html'); } } __decorate([ $mol_action ], $mol_fetch_response.prototype, "stream", null); __decorate([ $mol_action ], $mol_fetch_response.prototype, "text", null); __decorate([ $mol_action ], $mol_fetch_response.prototype, "xml", null); __decorate([ $mol_action ], $mol_fetch_response.prototype, "xhtml", null); __decorate([ $mol_action ], $mol_fetch_response.prototype, "html", null); $.$mol_fetch_response = $mol_fetch_response; class $mol_fetch extends $mol_object2 { static request(input, init = {}) { const controller = new AbortController(); let done = false; const promise = fetch(input, { ...init, signal: controller.signal, }).finally(() => { done = true; }); return Object.assign(promise, { destructor: () => { if (!done && !controller.signal.aborted) controller.abort(); }, }); } static response(input, init) { return new $mol_fetch_response($mol_wire_sync(this).request(input, init)); } static success(input, init) { const response = this.response(input, init); if (response.status() === 'success') return response; throw new Error(response.message(), { cause: response }); } static stream(input, init) { return this.success(input, init).stream(); } static text(input, init) { return this.success(input, init).text(); } static json(input, init) { return this.success(input, init).json(); } static blob(input, init) { return this.success(input, init).blob(); } static buffer(input, init) { return this.success(input, init).buffer(); } static xml(input, init) { return this.success(input, init).xml(); } static xhtml(input, init) { return this.success(input, init).xhtml(); } static html(input, init) { return this.success(input, init).html(); } } __decorate([ $mol_action ], $mol_fetch, "response", null); __decorate([ $mol_action ], $mol_fetch, "success", null); __decorate([ $mol_action ], $mol_fetch, "stream", null); __decorate([ $mol_action ], $mol_fetch, "text", null); __decorate([ $mol_action ], $mol_fetch, "json", null); __decorate([ $mol_action ], $mol_fetch, "blob", null); __decorate([ $mol_action ], $mol_fetch, "buffer", null); __decorate([ $mol_action ], $mol_fetch, "xml", null); __decorate([ $mol_action ], $mol_fetch, "xhtml", null); __decorate([ $mol_action ], $mol_fetch, "html", null); $.$mol_fetch = $mol_fetch; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_file_webdav extends $mol_file_base { static relative(path) { return this.absolute(new URL(path, this.base).toString()); } resolve(path) { let res = this.path() + '/' + path; while (true) { let prev = res; res = res.replace(/\/[^\/.]+\/\.\.\//, '/'); if (prev === res) break; } res = res.replace(/\/\.\.\/?$/, ''); if (res === this.path()) return this; return this.constructor.absolute(res); } static headers() { return {}; } headers() { return this.constructor.headers(); } fetch(init) { return this.$.$mol_fetch.success(this.path(), { ...init, headers: { ...this.headers(), ...init.headers, } }); } read() { try { const response = this.fetch({}); return new Uint8Array(response.buffer()); } catch (error) { if (error instanceof Error && error.cause instanceof $mol_fetch_response && error.cause.native.status === 404) return new Uint8Array; $mol_fail_hidden(error); } } write(body) { this.fetch({ method: 'PUT', body }); } ensure() { this.fetch({ method: 'MKCOL' }); } drop() { this.fetch({ method: 'DELETE' }); } copy(to) { this.fetch({ method: 'COPY', headers: { Destination: to } }); } kids() { const response = this.fetch({ method: 'PROPFIND' }); const xml = response.xml(); const result = []; for (const multistatus of xml.childNodes) { if (multistatus.nodeName !== 'D:multistatus') continue; for (const response of multistatus.childNodes) { let path; if (response.nodeName === 'D:href') path = response.textContent ?? ''; if (!path) continue; if (response.nodeName !== 'D:propstat') continue; const stat = webdav_stat(response); const file = this.resolve(path); file.stat(stat, 'virt'); result.push(file); } } return result; } readable(opts) { return this.fetch({ headers: !opts.start ? {} : { 'Range': `bytes=${opts.start}-${opts.end ?? ''}` } }).stream() || $mol_fail(new Error('Not found')); } info() { return this.kids().at(0)?.stat() ?? null; } } __decorate([ $mol_mem_key ], $mol_file_webdav.prototype, "readable", null); $.$mol_file_webdav = $mol_file_webdav; function webdav_stat(prop_stat) { const now = new Date(); const stat = { type: 'file', size: 0, atime: now, mtime: now, ctime: now, }; for (const prop of prop_stat.childNodes) { if (prop.nodeName !== 'D:prop') continue; for (const value of prop.childNodes) { const name = value.nodeName; const text = value.textContent ?? ''; if (name === 'D:getcontenttype') { stat.type = text.endsWith('directory') ? 'dir' : 'file'; } if (name === 'D:getcontentlength') { stat.size = Number(value.textContent || '0'); if (Number.isNaN(stat.size)) stat.size = 0; } if (name === 'D:getlastmodified') stat.mtime = stat.atime = new Date(text); if (name === 'D:creationdate') stat.ctime = new Date(text); } } return stat; } })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_file_web extends $mol_file_webdav { static base = $mol_dom_context.document?.currentScript ? new URL('.', $mol_dom_context.document.currentScript['src']).toString() : ''; version() { return '1'; } info() { try { const response = this.fetch({ method: 'HEAD' }); const headers = response.headers(); let size = Number(headers.get('Content-Length')); if (Number.isNaN(size)) size = 0; const last = headers.get('Last-Modified'); const mtime = last ? new Date(last) : new Date(); return { type: 'file', size, mtime, atime: mtime, ctime: mtime, }; } catch (error) { if (error instanceof Error && error.cause instanceof $mol_fetch_response && error.cause.native.status === 404) return null; $mol_fail_hidden(error); } } } $.$mol_file_web = $mol_file_web; $.$mol_file = $mol_file_web; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_locale extends $mol_object { static lang_default() { return 'en'; } static lang(next) { return this.$.$mol_state_local.value('locale', next) || $mol_dom_context.navigator.language.replace(/-.*/, '') || this.lang_default(); } static source(lang) { return JSON.parse(this.$.$mol_file.relative(`web.locale=${lang}.json`).text().toString()); } static texts(lang, next) { if (next) return next; try { return this.source(lang).valueOf(); } catch (error) { if ($mol_fail_catch(error)) { const def = this.lang_default(); if (lang === def) throw error; } } return {}; } static text(key) { const lang = this.lang(); const target = this.texts(lang)[key]; if (target) return target; this.warn(key); const en = this.texts('en')[key]; if (!en) return key; return en; } static warn(key) { console.warn(`Not translated to "${this.lang()}": ${key}`); return null; } } __decorate([ $mol_mem ], $mol_locale, "lang_default", null); __decorate([ $mol_mem ], $mol_locale, "lang", null); __decorate([ $mol_mem_key ], $mol_locale, "source", null); __decorate([ $mol_mem_key ], $mol_locale, "texts", null); __decorate([ $mol_mem_key ], $mol_locale, "text", null); __decorate([ $mol_mem_key ], $mol_locale, "warn", null); $.$mol_locale = $mol_locale; })($ || ($ = {})); ; ($.$mol_string) = class $mol_string extends ($.$mol_view) { selection_watcher(){ return null; } error_report(){ return null; } disabled(){ return false; } value(next){ if(next !== undefined) return next; return ""; } value_changed(next){ return (this.value(next)); } hint(){ return ""; } hint_visible(){ return (this.hint()); } spellcheck(){ return true; } autocomplete_native(){ return ""; } selection_end(){ return 0; } selection_start(){ return 0; } keyboard(){ return "text"; } enter(){ return "go"; } length_max(){ return +Infinity; } type(next){ if(next !== undefined) return next; return "text"; } event_change(next){ if(next !== undefined) return next; return null; } submit_with_ctrl(){ return false; } submit(next){ if(next !== undefined) return next; return null; } Submit(){ const obj = new this.$.$mol_hotkey(); (obj.mod_ctrl) = () => ((this.submit_with_ctrl())); (obj.key) = () => ({"enter": (next) => (this.submit(next))}); return obj; } dom_name(){ return "input"; } enabled(){ return true; } minimal_height(){ return 40; } autocomplete(){ return false; } selection(next){ if(next !== undefined) return next; return [0, 0]; } auto(){ return [(this.selection_watcher()), (this.error_report())]; } field(){ return { ...(super.field()), "disabled": (this.disabled()), "value": (this.value_changed()), "placeholder": (this.hint_visible()), "spellcheck": (this.spellcheck()), "autocomplete": (this.autocomplete_native()), "selectionEnd": (this.selection_end()), "selectionStart": (this.selection_start()), "inputMode": (this.keyboard()), "enterkeyhint": (this.enter()) }; } attr(){ return { ...(super.attr()), "maxlength": (this.length_max()), "type": (this.type()) }; } event(){ return {...(super.event()), "input": (next) => (this.event_change(next))}; } plugins(){ return [(this.Submit())]; } }; ($mol_mem(($.$mol_string.prototype), "value")); ($mol_mem(($.$mol_string.prototype), "type")); ($mol_mem(($.$mol_string.prototype), "event_change")); ($mol_mem(($.$mol_string.prototype), "submit")); ($mol_mem(($.$mol_string.prototype), "Submit")); ($mol_mem(($.$mol_string.prototype), "selection")); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_string extends $.$mol_string { event_change(next) { if (!next) return; const el = this.dom_node(); const from = el.selectionStart; const to = el.selectionEnd; try { el.value = this.value_changed(el.value); } catch (error) { const el = this.dom_node(); if (error instanceof Error) { el.setCustomValidity(error.message); el.reportValidity(); } $mol_fail_hidden(error); } if (to === null) return; el.selectionEnd = to; el.selectionStart = from; this.selection_change(next); } error_report() { try { if (this.focused()) this.value(); } catch (error) { const el = this.dom_node(); if (error instanceof Error) { el.setCustomValidity(error.message); el.reportValidity(); } } } hint_visible() { return (this.enabled() ? this.hint() : '') || ' '; } disabled() { return !this.enabled(); } autocomplete_native() { return this.autocomplete() ? 'on' : 'off'; } selection_watcher() { return new $mol_dom_listener(this.$.$mol_dom_context.document, 'selectionchange', $mol_wire_async(event => this.selection_change(event))); } selection_change(event) { const el = this.dom_node(); if (el !== this.$.$mol_dom_context.document.activeElement) return; const [from, to] = this.selection([ el.selectionStart, el.selectionEnd, ]); el.selectionEnd = to; el.selectionStart = from; if (to !== from && el.selectionEnd === el.selectionStart) { el.selectionEnd = to; } } selection_start() { const el = this.dom_node(); if (!this.focused()) return undefined; if (el.selectionStart == null) return undefined; return this.selection()[0]; } selection_end() { const el = this.dom_node(); if (!this.focused()) return undefined; if (el.selectionEnd == null) return undefined; return this.selection()[1]; } } __decorate([ $mol_action ], $mol_string.prototype, "event_change", null); __decorate([ $mol_mem ], $mol_string.prototype, "error_report", null); __decorate([ $mol_mem ], $mol_string.prototype, "selection_watcher", null); $$.$mol_string = $mol_string; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { $mol_style_attach("mol/string/string.view.css", "[mol_string] {\n\tbox-sizing: border-box;\n\toutline-offset: 0;\n\tborder: none;\n\tborder-radius: var(--mol_gap_round);\n\twhite-space: pre-line;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\tpadding: var(--mol_gap_text);\n\ttext-align: left;\n\tposition: relative;\n\tfont: inherit;\n\tflex: 1 1 auto;\n\tbackground: transparent;\n\tmin-width: 0;\n\tcolor: inherit;\n\tbackground: var(--mol_theme_field);\n}\n\n[mol_string]:disabled:not(:placeholder-shown) {\n\tbackground-color: transparent;\n\tcolor: var(--mol_theme_text);\n}\n\n[mol_string]:where(:not(:disabled)) {\n\tbox-shadow: inset 0 0 0 1px var(--mol_theme_line);\n}\n\n[mol_string]:where(:not(:disabled)):hover {\n\tbox-shadow: inset 0 0 0 2px var(--mol_theme_line);\n\tz-index: var(--mol_layer_hover);\n}\n\n[mol_string]:focus {\n\toutline: none;\n\tz-index: var(--mol_layer_focus);\n\tcolor: var(--mol_theme_text);\n\tbox-shadow: inset 0 0 0 1px var(--mol_theme_focus);\n}\n\n[mol_string]::placeholder {\n\tcolor: var(--mol_theme_shade);\n}\n\n[mol_string]::-ms-clear {\n\tdisplay: none;\n}\n"); })($ || ($ = {})); ; ($.$mol_svg) = class $mol_svg extends ($.$mol_view) { dom_name(){ return "svg"; } dom_name_space(){ return "http://www.w3.org/2000/svg"; } font_size(){ return 16; } font_family(){ return ""; } style_size(){ return {}; } }; ; "use strict"; var $; (function ($) { class $mol_state_time extends $mol_object { static task(precision, reset) { if (precision) { return new $mol_after_timeout(precision, () => this.task(precision, null)); } else { return new $mol_after_frame(() => this.task(precision, null)); } } static now(precision) { this.task(precision); return Date.now(); } } __decorate([ $mol_mem_key ], $mol_state_time, "task", null); __decorate([ $mol_mem_key ], $mol_state_time, "now", null); $.$mol_state_time = $mol_state_time; })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_svg extends $.$mol_svg { computed_style() { const win = this.$.$mol_dom_context; const style = win.getComputedStyle(this.dom_node()); if (!style['font-size']) $mol_state_time.now(0); return style; } font_size() { return parseInt(this.computed_style()['font-size']) || 16; } font_family() { return this.computed_style()['font-family']; } } __decorate([ $mol_mem ], $mol_svg.prototype, "computed_style", null); __decorate([ $mol_mem ], $mol_svg.prototype, "font_size", null); __decorate([ $mol_mem ], $mol_svg.prototype, "font_family", null); $$.$mol_svg = $mol_svg; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; ($.$mol_svg_root) = class $mol_svg_root extends ($.$mol_svg) { view_box(){ return "0 0 100 100"; } aspect(){ return "xMidYMid"; } dom_name(){ return "svg"; } attr(){ return { ...(super.attr()), "viewBox": (this.view_box()), "preserveAspectRatio": (this.aspect()) }; } }; ; "use strict"; var $; (function ($) { $mol_style_attach("mol/svg/root/root.view.css", "[mol_svg_root] {\n\toverflow: hidden;\n}\n"); })($ || ($ = {})); ; "use strict"; ; ($.$mol_svg_path) = class $mol_svg_path extends ($.$mol_svg) { geometry(){ return ""; } dom_name(){ return "path"; } attr(){ return {...(super.attr()), "d": (this.geometry())}; } }; ; "use strict"; ; ($.$mol_icon) = class $mol_icon extends ($.$mol_svg_root) { path(){ return ""; } Path(){ const obj = new this.$.$mol_svg_path(); (obj.geometry) = () => ((this.path())); return obj; } view_box(){ return "0 0 24 24"; } minimal_width(){ return 16; } minimal_height(){ return 16; } sub(){ return [(this.Path())]; } }; ($mol_mem(($.$mol_icon.prototype), "Path")); ; "use strict"; var $; (function ($) { $mol_style_attach("mol/icon/icon.view.css", "[mol_icon] {\n\tfill: currentColor;\n\tstroke: none;\n\twidth: 1em;\n\theight: 1.5em;\n\tflex: 0 0 auto;\n\tvertical-align: top;\n\tdisplay: inline-block;\n\tfilter: drop-shadow(0px 1px 1px var(--mol_theme_back));\n\ttransform-origin: center;\n}\n\n[mol_icon_path] {\n\ttransform-origin: center;\n}\n"); })($ || ($ = {})); ; "use strict"; ; ($.$mol_icon_close) = class $mol_icon_close extends ($.$mol_icon) { path(){ return "M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"; } }; ; "use strict"; ; ($.$mol_speck) = class $mol_speck extends ($.$mol_view) { theme(){ return "$mol_theme_accent"; } value(){ return null; } minimal_width(){ return 12; } attr(){ return {...(super.attr()), "mol_theme": (this.theme())}; } style(){ return {...(super.style()), "minHeight": "1em"}; } sub(){ return [(this.value())]; } }; ; "use strict"; var $; (function ($) { $mol_style_attach("mol/speck/speck.view.css", "[mol_speck] {\n\tfont-size: .75rem;\n\tborder-radius: 1rem;\n\tmargin: -0.5rem -0.2rem;\n\talign-self: flex-start;\n\tmin-height: 1em;\n\tvertical-align: sub;\n\tpadding: 0 .2rem;\n\tposition: absolute;\n\tz-index: var(--mol_layer_speck);\n\ttext-align: center;\n\tline-height: .9;\n\tdisplay: inline-block;\n\twhite-space: nowrap;\n\ttext-overflow: ellipsis;\n\tuser-select: none;\n\tbox-shadow: 0 0 3px rgba(0,0,0,.5);\n}\n"); })($ || ($ = {})); ; "use strict"; ; ($.$mol_button) = class $mol_button extends ($.$mol_view) { event_activate(next){ if(next !== undefined) return next; return null; } clicks(next){ if(next !== undefined) return next; return null; } event_key_press(next){ if(next !== undefined) return next; return null; } disabled(){ return false; } tab_index(){ return 0; } hint(){ return ""; } hint_safe(){ return (this.hint()); } error(){ return ""; } enabled(){ return true; } click(next){ if(next !== undefined) return next; return null; } event_click(next){ if(next !== undefined) return next; return null; } event(){ return { ...(super.event()), "click": (next) => (this.event_activate(next)), "dblclick": (next) => (this.clicks(next)), "keydown": (next) => (this.event_key_press(next)) }; } attr(){ return { ...(super.attr()), "disabled": (this.disabled()), "role": "button", "tabindex": (this.tab_index()), "title": (this.hint_safe()) }; } sub(){ return [(this.title())]; } Speck(){ const obj = new this.$.$mol_speck(); (obj.value) = () => ((this.error())); return obj; } }; ($mol_mem(($.$mol_button.prototype), "event_activate")); ($mol_mem(($.$mol_button.prototype), "clicks")); ($mol_mem(($.$mol_button.prototype), "event_key_press")); ($mol_mem(($.$mol_button.prototype), "click")); ($mol_mem(($.$mol_button.prototype), "event_click")); ($mol_mem(($.$mol_button.prototype), "Speck")); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_button extends $.$mol_button { status(next = [null]) { return next; } disabled() { return !this.enabled(); } event_activate(next) { if (!next) return; if (!this.enabled()) return; try { this.event_click(next); this.click(next); this.status([null]); } catch (error) { Promise.resolve().then(() => this.status([error])); $mol_fail_hidden(error); } } event_key_press(event) { if (event.keyCode === $mol_keyboard_code.enter) { return this.event_activate(event); } } tab_index() { return this.enabled() ? super.tab_index() : -1; } error() { const [error] = this.status(); if (!error) return ''; if (error instanceof Promise) { return $mol_fail_hidden(error); } return String(error.message ?? error); } hint_safe() { try { return this.hint(); } catch (error) { $mol_fail_log(error); return ''; } } sub_visible() { return [ ...this.error() ? [this.Speck()] : [], ...this.sub(), ]; } } __decorate([ $mol_mem ], $mol_button.prototype, "status", null); $$.$mol_button = $mol_button; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { $mol_style_attach("mol/button/button.view.css", "[mol_button] {\n\tborder: none;\n\tfont: inherit;\n\tdisplay: inline-flex;\n\tflex-shrink: 0;\n\ttext-decoration: inherit;\n\tcursor: inherit;\n\tposition: relative;\n\tbox-sizing: border-box;\n\tword-break: normal;\n\tcursor: default;\n\tuser-select: none;\n\tborder-radius: var(--mol_gap_round);\n\tbackground: transparent;\n\tcolor: inherit;\n}\n\n[mol_button]:where(:not(:disabled)):hover {\n\tz-index: var(--mol_layer_hover);\n}\n\n[mol_button]:focus {\n\toutline: none;\n\tz-index: var(--mol_layer_focus);\n}\n"); })($ || ($ = {})); ; ($.$mol_button_typed) = class $mol_button_typed extends ($.$mol_button) { minimal_height(){ return 40; } minimal_width(){ return 40; } }; ; "use strict"; var $; (function ($) { $mol_style_attach("mol/button/typed/typed.view.css", "[mol_button_typed] {\n\talign-content: center;\n\talign-items: center;\n\tpadding: var(--mol_gap_text);\n\tborder-radius: var(--mol_gap_round);\n\tgap: var(--mol_gap_space);\n\tuser-select: none;\n\tcursor: pointer;\n}\n\n[mol_button_typed][disabled] {\n\tpointer-events: none;\n}\n\n[mol_button_typed]:hover ,\n[mol_button_typed]:focus-visible {\n\tbox-shadow: inset 0 0 0 10rem var(--mol_theme_hover);\n}\n\n[mol_button_typed]:active {\n\tcolor: var(--mol_theme_focus);\n}\n\n"); })($ || ($ = {})); ; "use strict"; ; ($.$mol_button_minor) = class $mol_button_minor extends ($.$mol_button_typed) {}; ; "use strict"; var $; (function ($) { $mol_style_attach("mol/button/minor/minor.view.css", "[mol_button_minor] {\n\tcolor: var(--mol_theme_control);\n}\n\n[mol_button_minor][disabled] {\n\tcolor: var(--mol_theme_shade);\n}\n"); })($ || ($ = {})); ; "use strict"; ; ($.$mol_list) = class $mol_list extends ($.$mol_view) { rows(){ return []; } gap_before(){ return 0; } gap_after(){ return 0; } render_visible_only(){ return true; } render_over(){ return 0; } sub(){ return (this.rows()); } Empty(){ const obj = new this.$.$mol_view(); return obj; } Gap_before(){ const obj = new this.$.$mol_view(); (obj.style) = () => ({"paddingTop": (this.gap_before())}); return obj; } Gap_after(){ const obj = new this.$.$mol_view(); (obj.style) = () => ({"paddingTop": (this.gap_after())}); return obj; } item_height_min(id){ return 1; } item_width_min(id){ return 1; } view_window(){ return [0, 0]; } }; ($mol_mem(($.$mol_list.prototype), "Empty")); ($mol_mem(($.$mol_list.prototype), "Gap_before")); ($mol_mem(($.$mol_list.prototype), "Gap_after")); ; "use strict"; var $; (function ($) { let cache = null; function $mol_support_css_overflow_anchor() { return cache ?? (cache = this.$mol_dom_context.CSS?.supports('overflow-anchor:auto') ?? false); } $.$mol_support_css_overflow_anchor = $mol_support_css_overflow_anchor; })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_list extends $.$mol_list { sub() { const rows = this.rows(); return (rows.length === 0) ? [this.Empty()] : rows; } render_visible_only() { return this.$.$mol_support_css_overflow_anchor(); } view_window(next) { const kids = this.sub(); if (kids.length < 3) return [0, kids.length]; if (this.$.$mol_print.active()) return [0, kids.length]; const rect = this.view_rect(); if (next) return next; let [min, max] = $mol_mem_cached(() => this.view_window()) ?? [0, 0]; let max2 = max = Math.min(max, kids.length); let min2 = min = Math.max(0, Math.min(min, max - 1)); const anchoring = this.render_visible_only(); const window_height = this.$.$mol_window.size().height + 40; const over = Math.ceil(window_height * this.render_over()); const limit_top = -over; const limit_bottom = window_height + over; const gap_before = $mol_mem_cached(() => this.gap_before()) ?? 0; const gap_after = $mol_mem_cached(() => this.gap_after()) ?? 0; let top = Math.ceil(rect?.top ?? 0) + gap_before; let bottom = Math.ceil(rect?.bottom ?? 0) - gap_after; if (top <= limit_top && bottom >= limit_bottom) { return [min2, max2]; } if (anchoring && ((bottom < limit_top) || (top > limit_bottom))) { min = 0; top = Math.ceil(rect?.top ?? 0); while (min < (kids.length - 1)) { const height = this.item_height_min(min); if (top + height >= limit_top) break; top += height; ++min; } min2 = min; max2 = max = min; bottom = top; } let top2 = top; let bottom2 = bottom; if (anchoring && (top < limit_top) && (bottom < limit_bottom) && (max < kids.length)) { min2 = max; top2 = bottom; } if ((bottom > limit_bottom) && (top > limit_top) && (min > 0)) { max2 = min; bottom2 = top; } while (anchoring && ((top2 > limit_top) && (min2 > 0))) { --min2; top2 -= this.item_height_min(min2); } while (bottom2 < limit_bottom && max2 < kids.length) { bottom2 += this.item_height_min(max2); ++max2; } return [min2, max2]; } item_height_min(index) { try { return this.sub()[index]?.minimal_height() ?? 0; } catch (error) { $mol_fail_log(error); return 0; } } row_width_min(index) { try { return this.sub()[index]?.minimal_width() ?? 0; } catch (error) { $mol_fail_log(error); return 0; } } gap_before() { let gap = 0; const skipped = this.view_window()[0]; for (let i = 0; i < skipped; ++i) gap += this.item_height_min(i); return gap; } gap_after() { let gap = 0; const from = this.view_window()[1]; const to = this.sub().length; for (let i = from; i < to; ++i) gap += this.item_height_min(i); return gap; } sub_visible() { return [ ...this.gap_before() ? [this.Gap_before()] : [], ...this.sub().slice(...this.view_window()), ...this.gap_after() ? [this.Gap_after()] : [], ]; } minimal_height() { let height = 0; const len = this.sub().length; for (let i = 0; i < len; ++i) height += this.item_height_min(i); return height; } minimal_width() { let width = 0; const len = this.sub().length; for (let i = 0; i < len; ++i) width = Math.max(width, this.item_width_min(i)); return width; } force_render(path) { const kids = this.rows(); const index = kids.findIndex(item => path.has(item)); if (index >= 0) { const win = this.view_window(); if (index < win[0] || index >= win[1]) { this.view_window([this.render_visible_only() ? index : 0, index + 1]); } kids[index].force_render(path); } } } __decorate([ $mol_mem ], $mol_list.prototype, "sub", null); __decorate([ $mol_mem ], $mol_list.prototype, "view_window", null); __decorate([ $mol_mem ], $mol_list.prototype, "gap_before", null); __decorate([ $mol_mem ], $mol_list.prototype, "gap_after", null); __decorate([ $mol_mem ], $mol_list.prototype, "sub_visible", null); __decorate([ $mol_mem ], $mol_list.prototype, "minimal_height", null); __decorate([ $mol_mem ], $mol_list.prototype, "minimal_width", null); $$.$mol_list = $mol_list; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { $mol_style_attach("mol/list/list.view.css", "[mol_list] {\n\twill-change: contents;\n\tdisplay: flex;\n\tflex-direction: column;\n\tflex-shrink: 0;\n\tmax-width: 100%;\n\t/* display: flex;\n\talign-items: stretch;\n\talign-content: stretch; */\n\ttransition: none;\n\tmin-height: 1.5rem;\n}\n\n[mol_list_gap_before] ,\n[mol_list_gap_after] {\n\tdisplay: block !important;\n\tflex: none;\n\ttransition: none;\n\toverflow-anchor: none;\n}\n"); })($ || ($ = {})); ; ($.$mol_paragraph) = class $mol_paragraph extends ($.$mol_view) { line_height(){ return 24; } letter_width(){ return 7; } width_limit(){ return +Infinity; } row_width(){ return 0; } sub(){ return [(this.title())]; } }; ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_paragraph extends $.$mol_paragraph { maximal_width() { let width = 0; const letter = this.letter_width(); for (const kid of this.sub()) { if (!kid) continue; if (kid instanceof $mol_view) { width += kid.maximal_width(); } else if (typeof kid !== 'object') { width += String(kid).length * letter; } } return width; } width_limit() { return this.$.$mol_window.size().width; } minimal_width() { return this.letter_width(); } row_width() { return Math.max(Math.min(this.width_limit(), this.maximal_width()), this.letter_width()); } minimal_height() { return Math.max(1, Math.ceil(this.maximal_width() / this.row_width())) * this.line_height(); } } __decorate([ $mol_mem ], $mol_paragraph.prototype, "maximal_width", null); __decorate([ $mol_mem ], $mol_paragraph.prototype, "row_width", null); __decorate([ $mol_mem ], $mol_paragraph.prototype, "minimal_height", null); $$.$mol_paragraph = $mol_paragraph; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { $mol_style_attach("mol/paragraph/paragraph.view.css", ":where([mol_paragraph]) {\n\tmargin: 0;\n\tmax-width: 100%;\n}\n"); })($ || ($ = {})); ; ($.$mol_dimmer) = class $mol_dimmer extends ($.$mol_paragraph) { parts(){ return []; } string(id){ return ""; } haystack(){ return ""; } needle(){ return ""; } sub(){ return (this.parts()); } Low(id){ const obj = new this.$.$mol_paragraph(); (obj.sub) = () => ([(this.string(id))]); return obj; } High(id){ const obj = new this.$.$mol_paragraph(); (obj.sub) = () => ([(this.string(id))]); return obj; } }; ($mol_mem_key(($.$mol_dimmer.prototype), "Low")); ($mol_mem_key(($.$mol_dimmer.prototype), "High")); ; "use strict"; ; "use strict"; ; "use strict"; ; "use strict"; ; "use strict"; var $; (function ($) { class $mol_regexp extends RegExp { groups; constructor(source, flags = 'gsu', groups = []) { super(source, flags); this.groups = groups; } *[Symbol.matchAll](str) { const index = this.lastIndex; this.lastIndex = 0; try { while (this.lastIndex < str.length) { const found = this.exec(str); if (!found) break; yield found; } } finally { this.lastIndex = index; } } [Symbol.match](str) { const res = [...this[Symbol.matchAll](str)].filter(r => r.groups).map(r => r[0]); if (!res.length) return null; return res; } [Symbol.split](str) { const res = []; let token_last = null; for (let token of this[Symbol.matchAll](str)) { if (token.groups && (token_last ? token_last.groups : true)) res.push(''); res.push(token[0]); token_last = token; } if (!res.length) res.push(''); return res; } test(str) { return Boolean(str.match(this)); } exec(str) { const from = this.lastIndex; if (from >= str.length) return null; const res = super.exec(str); if (res === null) { this.lastIndex = str.length; if (!str) return null; return Object.assign([str.slice(from)], { index: from, input: str, }); } if (from === this.lastIndex) { $mol_fail(new Error('Captured empty substring')); } const groups = {}; const skipped = str.slice(from, this.lastIndex - res[0].length); if (skipped) { this.lastIndex = this.lastIndex - res[0].length; return Object.assign([skipped], { index: from, input: res.input, }); } for (let i = 0; i < this.groups.length; ++i) { const group = this.groups[i]; groups[group] = groups[group] || res[i + 1] || ''; } return Object.assign(res, { groups }); } generate(params) { return null; } get native() { return new RegExp(this.source, this.flags); } static repeat(source, min = 0, max = Number.POSITIVE_INFINITY) { const regexp = $mol_regexp.from(source); const upper = Number.isFinite(max) ? max : ''; const str = `(?:${regexp.source}){${min},${upper}}?`; const regexp2 = new $mol_regexp(str, regexp.flags, regexp.groups); regexp2.generate = params => { const res = regexp.generate(params); if (res) return res; if (min > 0) return res; return ''; }; return regexp2; } static repeat_greedy(source, min = 0, max = Number.POSITIVE_INFINITY) { const regexp = $mol_regexp.from(source); const upper = Number.isFinite(max) ? max : ''; const str = `(?:${regexp.source}){${min},${upper}}`; const regexp2 = new $mol_regexp(str, regexp.flags, regexp.groups); regexp2.generate = params => { const res = regexp.generate(params); if (res) return res; if (min > 0) return res; return ''; }; return regexp2; } static vary(sources) { const groups = []; const chunks = sources.map(source => { const regexp = $mol_regexp.from(source); groups.push(...regexp.groups); return regexp.source; }); return new $mol_regexp(`(?:${chunks.join('|')})`, '', groups); } static optional(source) { return $mol_regexp.repeat_greedy(source, 0, 1); } static force_after(source) { const regexp = $mol_regexp.from(source); return new $mol_regexp(`(?=${regexp.source})`, regexp.flags, regexp.groups); } static forbid_after(source) { const regexp = $mol_regexp.from(source); return new $mol_regexp(`(?!${regexp.source})`, regexp.flags, regexp.groups); } static from(source, { ignoreCase, multiline } = { ignoreCase: false, multiline: false, }) { let flags = 'gsu'; if (multiline) flags += 'm'; if (ignoreCase) flags += 'i'; if (typeof source === 'number') { const src = `\\u{${source.toString(16)}}`; const regexp = new $mol_regexp(src, flags); regexp.generate = () => src; return regexp; } if (typeof source === 'string') { const src = source.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); const regexp = new $mol_regexp(src, flags); regexp.generate = () => source; return regexp; } else if (source instanceof $mol_regexp) { const regexp = new $mol_regexp(source.source, flags, source.groups); regexp.generate = params => source.generate(params); return regexp; } if (source instanceof RegExp) { const test = new RegExp('|' + source.source); const groups = Array.from({ length: test.exec('').length - 1 }, (_, i) => String(i + 1)); const regexp = new $mol_regexp(source.source, source.flags, groups); regexp.generate = () => ''; return regexp; } if (Array.isArray(source)) { const patterns = source.map(src => Array.isArray(src) ? $mol_regexp.optional(src) : $mol_regexp.from(src)); const chunks = patterns.map(pattern => pattern.source); const groups = []; let index = 0; for (const pattern of patterns) { for (let group of pattern.groups) { if (Number(group) >= 0) { groups.push(String(index++)); } else { groups.push(group); } } } const regexp = new $mol_regexp(chunks.join(''), flags, groups); regexp.generate = params => { let res = ''; for (const pattern of patterns) { let sub = pattern.generate(params); if (sub === null) return ''; res += sub; } return res; }; return regexp; } else { const groups = []; const chunks = Object.keys(source).map(name => { groups.push(name); const regexp = $mol_regexp.from(source[name]); groups.push(...regexp.groups); return `(${regexp.source})`; }); const regexp = new $mol_regexp(`(?:${chunks.join('|')})`, flags, groups); const validator = new RegExp('^' + regexp.source + '$', flags); regexp.generate = (params) => { for (let option in source) { if (option in params) { if (typeof params[option] === 'boolean') { if (!params[option]) continue; } else { const str = String(params[option]); if (str.match(validator)) return str; $mol_fail(new Error(`Wrong param: ${option}=${str}`)); } } else { if (typeof source[option] !== 'object') continue; } const res = $mol_regexp.from(source[option]).generate(params); if (res) return res; } return null; }; return regexp; } } static unicode_only(...category) { return new $mol_regexp(`\\p{${category.join('=')}}`); } static unicode_except(...category) { return new $mol_regexp(`\\P{${category.join('=')}}`); } static char_range(from, to) { return new $mol_regexp(`${$mol_regexp.from(from).source}-${$mol_regexp.from(to).source}`); } static char_only(...allowed) { const regexp = allowed.map(f => $mol_regexp.from(f).source).join(''); return new $mol_regexp(`[${regexp}]`); } static char_except(...forbidden) { const regexp = forbidden.map(f => $mol_regexp.from(f).source).join(''); return new $mol_regexp(`[^${regexp}]`); } static decimal_only = $mol_regexp.from(/\d/gsu); static decimal_except = $mol_regexp.from(/\D/gsu); static latin_only = $mol_regexp.from(/\w/gsu); static latin_except = $mol_regexp.from(/\W/gsu); static space_only = $mol_regexp.from(/\s/gsu); static space_except = $mol_regexp.from(/\S/gsu); static word_break_only = $mol_regexp.from(/\b/gsu); static word_break_except = $mol_regexp.from(/\B/gsu); static tab = $mol_regexp.from(/\t/gsu); static slash_back = $mol_regexp.from(/\\/gsu); static nul = $mol_regexp.from(/\0/gsu); static char_any = $mol_regexp.from(/./gsu); static begin = $mol_regexp.from(/^/gsu); static end = $mol_regexp.from(/$/gsu); static or = $mol_regexp.from(/|/gsu); static line_end = $mol_regexp.from({ win_end: [['\r'], '\n'], mac_end: '\r', }); } $.$mol_regexp = $mol_regexp; })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_dimmer extends $.$mol_dimmer { parts() { const needle = this.needle(); if (needle.length < 2) return [this.haystack()]; let chunks = []; let strings = this.strings(); for (let index = 0; index < strings.length; index++) { if (strings[index] === '') continue; chunks.push((index % 2) ? this.High(index) : this.Low(index)); } return chunks; } strings() { const options = this.needle().split(/\s+/g).filter(Boolean); if (!options.length) return [this.haystack()]; const variants = { ...options }; const regexp = $mol_regexp.from({ needle: variants }, { ignoreCase: true }); return this.haystack().split(regexp); } string(index) { return this.strings()[index]; } *view_find(check, path = []) { if (check(this, this.haystack())) { yield [...path, this]; } } } __decorate([ $mol_mem ], $mol_dimmer.prototype, "strings", null); $$.$mol_dimmer = $mol_dimmer; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { $mol_style_attach("mol/dimmer/dimmer.view.css", "[mol_dimmer] {\n\tdisplay: block;\n\tmax-width: 100%;\n}\n\n[mol_dimmer_low] {\n\tdisplay: inline;\n\topacity: 0.8;\n}\n\n[mol_dimmer_high] {\n\tdisplay: inline;\n\tcolor: var(--mol_theme_focus);\n\ttext-shadow: 0 0;\n}\n"); })($ || ($ = {})); ; ($.$mol_search) = class $mol_search extends ($.$mol_pop) { clear(next){ if(next !== undefined) return next; return null; } Hotkey(){ const obj = new this.$.$mol_hotkey(); (obj.key) = () => ({"escape": (next) => (this.clear(next))}); return obj; } nav_components(){ return []; } nav_focused(next){ if(next !== undefined) return next; return null; } Nav(){ const obj = new this.$.$mol_nav(); (obj.keys_y) = () => ((this.nav_components())); (obj.current_y) = (next) => ((this.nav_focused(next))); return obj; } suggests_showed(next){ if(next !== undefined) return next; return false; } query(next){ if(next !== undefined) return next; return ""; } hint(){ return (this.$.$mol_locale.text("$mol_search_hint")); } submit(next){ if(next !== undefined) return next; return null; } enabled(){ return true; } keyboard(){ return "search"; } enter(){ return "search"; } bring(){ return (this.Query().bring()); } Query(){ const obj = new this.$.$mol_string(); (obj.value) = (next) => ((this.query(next))); (obj.hint) = () => ((this.hint())); (obj.submit) = (next) => ((this.submit(next))); (obj.enabled) = () => ((this.enabled())); (obj.keyboard) = () => ((this.keyboard())); (obj.enter) = () => ((this.enter())); return obj; } Clear_icon(){ const obj = new this.$.$mol_icon_close(); return obj; } Clear(){ const obj = new this.$.$mol_button_minor(); (obj.hint) = () => ((this.$.$mol_locale.text("$mol_search_Clear_hint"))); (obj.enabled) = () => ((this.enabled())); (obj.click) = (next) => ((this.clear(next))); (obj.sub) = () => ([(this.Clear_icon())]); return obj; } anchor_content(){ return [(this.Query()), (this.Clear())]; } menu_items(){ return []; } Menu(){ const obj = new this.$.$mol_list(); (obj.rows) = () => ((this.menu_items())); return obj; } Bubble_pane(){ const obj = new this.$.$mol_scroll(); (obj.sub) = () => ([(this.Menu())]); return obj; } suggest_select(id, next){ if(next !== undefined) return next; return null; } suggest_label(id){ return ""; } Suggest_label(id){ const obj = new this.$.$mol_dimmer(); (obj.haystack) = () => ((this.suggest_label(id))); (obj.needle) = () => ((this.query())); return obj; } suggest_content(id){ return [(this.Suggest_label(id))]; } suggests(){ return []; } plugins(){ return [ ...(super.plugins()), (this.Hotkey()), (this.Nav()) ]; } showed(next){ return (this.suggests_showed(next)); } align_hor(){ return "right"; } Anchor(){ const obj = new this.$.$mol_view(); (obj.sub) = () => ((this.anchor_content())); return obj; } bubble_content(){ return [(this.Bubble_pane())]; } Suggest(id){ const obj = new this.$.$mol_button_minor(); (obj.click) = (next) => ((this.suggest_select(id, next))); (obj.sub) = () => ((this.suggest_content(id))); return obj; } }; ($mol_mem(($.$mol_search.prototype), "clear")); ($mol_mem(($.$mol_search.prototype), "Hotkey")); ($mol_mem(($.$mol_search.prototype), "nav_focused")); ($mol_mem(($.$mol_search.prototype), "Nav")); ($mol_mem(($.$mol_search.prototype), "suggests_showed")); ($mol_mem(($.$mol_search.prototype), "query")); ($mol_mem(($.$mol_search.prototype), "submit")); ($mol_mem(($.$mol_search.prototype), "Query")); ($mol_mem(($.$mol_search.prototype), "Clear_icon")); ($mol_mem(($.$mol_search.prototype), "Clear")); ($mol_mem(($.$mol_search.prototype), "Menu")); ($mol_mem(($.$mol_search.prototype), "Bubble_pane")); ($mol_mem_key(($.$mol_search.prototype), "suggest_select")); ($mol_mem_key(($.$mol_search.prototype), "Suggest_label")); ($mol_mem(($.$mol_search.prototype), "Anchor")); ($mol_mem_key(($.$mol_search.prototype), "Suggest")); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_search extends $.$mol_search { anchor_content() { return [ this.Query(), ...this.query() ? [this.Clear()] : [], ]; } suggests_showed(next = true) { this.query(); if (!this.focused()) return false; return next; } suggest_selected(next) { if (next === undefined) return; this.query(next); this.Query().focused(true); } nav_components() { return [ this.Query(), ...this.menu_items(), ]; } nav_focused(component) { if (!this.focused()) return null; if (component == null) { for (let comp of this.nav_components()) { if (comp && comp.focused()) return comp; } return null; } if (this.suggests_showed()) { this.ensure_visible(component, "center"); component.focused(true); } return component; } suggest_label(key) { return key; } menu_items() { return this.suggests().map((suggest) => this.Suggest(suggest)); } suggest_select(id, event) { this.query(id); this.Query().selection([id.length, id.length]); this.Query().focused(true); } clear(event) { this.query(''); } } __decorate([ $mol_mem ], $mol_search.prototype, "anchor_content", null); __decorate([ $mol_mem ], $mol_search.prototype, "suggests_showed", null); __decorate([ $mol_mem ], $mol_search.prototype, "nav_focused", null); __decorate([ $mol_mem ], $mol_search.prototype, "menu_items", null); $$.$mol_search = $mol_search; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { $mol_style_attach("mol/search/search.view.css", "[mol_search] {\n\talign-self: flex-start;\n\tflex: auto;\n}\n\n[mol_search_anchor] {\n\tflex: 1 1 auto;\n}\n\n[mol_search_query] {\n\tflex-grow: 1;\n}\n\n[mol_search_menu] {\n\tmin-height: .75rem;\n\tdisplay: flex;\n}\n\n[mol_search_suggest] {\n\ttext-align: left;\n}\n\n[mol_search_suggest_label_high] {\n\tcolor: var(--mol_theme_shade);\n\ttext-shadow: none;\n}\n"); })($ || ($ = {})); ; ($.$mol_link) = class $mol_link extends ($.$mol_view) { uri_toggle(){ return ""; } hint(){ return ""; } hint_safe(){ return (this.hint()); } target(){ return "_self"; } file_name(){ return ""; } current(){ return false; } relation(){ return ""; } event_click(next){ if(next !== undefined) return next; return null; } click(next){ return (this.event_click(next)); } uri(){ return ""; } dom_name(){ return "a"; } uri_off(){ return ""; } uri_native(){ return null; } external(){ return false; } attr(){ return { ...(super.attr()), "href": (this.uri_toggle()), "title": (this.hint_safe()), "target": (this.target()), "download": (this.file_name()), "mol_link_current": (this.current()), "rel": (this.relation()) }; } sub(){ return [(this.title())]; } arg(){ return {}; } event(){ return {...(super.event()), "click": (next) => (this.click(next))}; } }; ($mol_mem(($.$mol_link.prototype), "event_click")); ; "use strict"; ; "use strict"; var $; (function ($) { class $mol_state_arg extends $mol_object { prefix; static href(next) { if (next === undefined) { next = $mol_dom_context.location.href; } else if (!/^about:srcdoc/.test(next)) { new $mol_after_frame(() => { const next = this.href(); const prev = $mol_dom_context.location.href; if (next === prev) return; const history = $mol_dom_context.history; history.replaceState(history.state, $mol_dom_context.document.title, next); }); } if ($mol_dom_context.parent !== $mol_dom_context.self) { $mol_dom_context.parent.postMessage(['hashchange', next], '*'); } return next; } static href_normal() { return this.link({}); } static href_absolute() { return new URL(this.href(), $mol_dom_context.location.href).toString(); } static dict(next) { var href = this.href(next && this.make_link(next)).split(/#!?/)[1] || ''; var chunks = href.split(this.separator); var params = {}; chunks.forEach(chunk => { if (!chunk) return; var vals = chunk.split('=').map(decodeURIComponent); params[vals.shift()] = vals.join('='); }); return params; } static dict_cut(except) { const dict = this.dict(); const cut = {}; for (const key in dict) { if (except.indexOf(key) >= 0) break; cut[key] = dict[key]; } return cut; } static value(key, next) { const nextDict = (next === void 0) ? void 0 : { ...this.dict(), [key]: next }; const next2 = this.dict(nextDict)[key]; return (next2 == null) ? null : next2; } static link(next) { return this.make_link({ ...this.dict_cut(Object.keys(next)), ...next, }); } static prolog = '!'; static separator = '/'; static make_link(next) { const chunks = []; for (let key in next) { if (null == next[key]) continue; const val = next[key]; chunks.push([key].concat(val ? [val] : []).map(this.encode).join('=')); } return new URL('#' + this.prolog + chunks.join(this.separator), this.href_absolute()).toString(); } static commit() { $mol_dom.history.pushState($mol_dom.history.state, $mol_dom.document.title, this.href()); } static go(next) { $mol_dom_context.location.href = this.link(next); } static encode(str) { return encodeURIComponent(str).replace(/\(/g, '%28').replace(/\)/g, '%29'); } constructor(prefix = '') { super(); this.prefix = prefix; } value(key, next) { return this.constructor.value(this.prefix + key, next); } sub(postfix) { return new this.constructor(this.prefix + postfix + '.'); } link(next) { var prefix = this.prefix; var dict = {}; for (var key in next) { dict[prefix + key] = next[key]; } return this.constructor.link(dict); } } __decorate([ $mol_mem ], $mol_state_arg, "href", null); __decorate([ $mol_mem ], $mol_state_arg, "href_normal", null); __decorate([ $mol_mem ], $mol_state_arg, "href_absolute", null); __decorate([ $mol_mem ], $mol_state_arg, "dict", null); __decorate([ $mol_mem_key ], $mol_state_arg, "dict_cut", null); __decorate([ $mol_mem_key ], $mol_state_arg, "value", null); __decorate([ $mol_mem_key ], $mol_state_arg, "make_link", null); __decorate([ $mol_action ], $mol_state_arg, "commit", null); __decorate([ $mol_action ], $mol_state_arg, "go", null); $.$mol_state_arg = $mol_state_arg; function $mol_state_arg_change() { $mol_state_arg.href($mol_dom_context.location.href); } self.addEventListener('hashchange', $mol_state_arg_change); })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_link extends $.$mol_link { uri_toggle() { return this.current() ? this.uri_off() : this.uri(); } uri() { return new this.$.$mol_state_arg(this.state_key()).link(this.arg()); } uri_off() { const arg2 = {}; for (let i in this.arg()) arg2[i] = null; return new this.$.$mol_state_arg(this.state_key()).link(arg2); } uri_native() { const base = this.$.$mol_state_arg.href(); return new URL(this.uri(), base); } current() { const base = this.$.$mol_state_arg.href_normal(); const target = this.uri_native().toString(); if (base === target) return true; const args = this.arg(); const keys = Object.keys(args).filter(key => args[key] != null); if (keys.length === 0) return false; for (const key of keys) { if (this.$.$mol_state_arg.value(key) != args[key]) return false; } return true; } file_name() { return null; } minimal_height() { return Math.max(super.minimal_height(), 24); } external() { return this.uri_native().origin !== $mol_dom_context.location.origin; } target() { return this.external() ? '_blank' : '_self'; } hint_safe() { try { return this.hint(); } catch (error) { $mol_fail_log(error); return ''; } } } __decorate([ $mol_mem ], $mol_link.prototype, "uri_toggle", null); __decorate([ $mol_mem ], $mol_link.prototype, "uri", null); __decorate([ $mol_mem ], $mol_link.prototype, "uri_off", null); __decorate([ $mol_mem ], $mol_link.prototype, "uri_native", null); __decorate([ $mol_mem ], $mol_link.prototype, "current", null); $$.$mol_link = $mol_link; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { const { rem } = $mol_style_unit; $mol_style_define($mol_link, { textDecoration: 'none', color: $mol_theme.control, stroke: 'currentcolor', cursor: 'pointer', padding: $mol_gap.text, boxSizing: 'border-box', position: 'relative', minWidth: rem(2.5), gap: $mol_gap.space, border: { radius: $mol_gap.round, }, ':hover': { background: { color: $mol_theme.hover, }, }, ':focus': { outline: 'none', }, ':focus-visible': { outline: 'none', background: { color: $mol_theme.hover, } }, ':active': { color: $mol_theme.focus, }, '@': { mol_link_current: { 'true': { color: $mol_theme.current, textShadow: '0 0', } } }, }); })($ || ($ = {})); ; ($.$mol_page) = class $mol_page extends ($.$mol_view) { tabindex(){ return -1; } Logo(){ return null; } title_content(){ return [(this.Logo()), (this.title())]; } Title(){ const obj = new this.$.$mol_view(); (obj.dom_name) = () => ("h1"); (obj.sub) = () => ((this.title_content())); return obj; } tools(){ return []; } Tools(){ const obj = new this.$.$mol_view(); (obj.sub) = () => ((this.tools())); return obj; } head(){ return [(this.Title()), (this.Tools())]; } Head(){ const obj = new this.$.$mol_view(); (obj.minimal_height) = () => (64); (obj.dom_name) = () => ("header"); (obj.sub) = () => ((this.head())); return obj; } body_scroll_top(next){ return (this.Body().scroll_top(next)); } body(){ return []; } Body_content(){ const obj = new this.$.$mol_view(); (obj.sub) = () => ((this.body())); return obj; } body_content(){ return [(this.Body_content())]; } Body(){ const obj = new this.$.$mol_scroll(); (obj.sub) = () => ((this.body_content())); return obj; } foot(){ return []; } Foot(){ const obj = new this.$.$mol_view(); (obj.dom_name) = () => ("footer"); (obj.sub) = () => ((this.foot())); return obj; } dom_name(){ return "article"; } attr(){ return {...(super.attr()), "tabIndex": (this.tabindex())}; } sub(){ return [ (this.Head()), (this.Body()), (this.Foot()) ]; } }; ($mol_mem(($.$mol_page.prototype), "Title")); ($mol_mem(($.$mol_page.prototype), "Tools")); ($mol_mem(($.$mol_page.prototype), "Head")); ($mol_mem(($.$mol_page.prototype), "Body_content")); ($mol_mem(($.$mol_page.prototype), "Body")); ($mol_mem(($.$mol_page.prototype), "Foot")); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { const { per, rem } = $mol_style_unit; const { hsla, blur } = $mol_style_func; $mol_style_define($mol_page, { display: 'flex', flex: { basis: 'auto', direction: 'column', }, position: 'relative', alignSelf: 'stretch', maxWidth: per(100), maxHeight: per(100), boxSizing: 'border-box', color: $mol_theme.text, ':focus': { outline: 'none', }, Head: { display: 'flex', flexWrap: 'wrap', justifyContent: 'flex-end', flex: 'none', position: 'relative', margin: 0, minHeight: rem(4), padding: $mol_gap.block, background: { color: $mol_theme.card, }, border: { radius: $mol_gap.round, }, box: { shadow: [ [0, `-0.5rem`, `0.5rem`, `-0.5rem`, hsla(0, 0, 0, .25)], [0, `0.5rem`, `0.5rem`, `-0.5rem`, hsla(0, 0, 0, .25)], ], }, zIndex: 2, '@media': { 'print': { box: { shadow: [[0, `1px`, 0, 0, hsla(0, 0, 0, .25)]], }, }, }, }, Title: { minHeight: rem(2), margin: 0, padding: $mol_gap.text, gap: $mol_gap.text, wordBreak: 'normal', textShadow: '0 0', font: { size: 'inherit', weight: 'normal', }, flex: { grow: 1, shrink: 1, basis: 'auto', }, }, Tools: { flex: { basis: 'auto', grow: 0, shrink: 1, }, display: 'flex', justifyContent: 'flex-end', alignItems: 'flex-start', flexWrap: 'wrap', '@media': { 'print': { display: 'none', }, }, }, Body: { flex: { grow: 1000, shrink: 1, basis: per(100), }, }, Body_content: { padding: $mol_gap.block, flex: { direction: 'column', shrink: 1, grow: 1, }, justify: { self: 'stretch', }, }, Foot: { display: 'flex', justifyContent: 'space-between', flex: 'none', margin: 0, background: { color: $mol_theme.card, }, border: { radius: $mol_gap.round, }, box: { shadow: [ [0, `-0.5rem`, `0.5rem`, `-0.5rem`, hsla(0, 0, 0, .25)], [0, `0.5rem`, `0.5rem`, `-0.5rem`, hsla(0, 0, 0, .25)], ], }, zIndex: 1, padding: $mol_gap.block, ':empty': { display: 'none', }, }, }); })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; ($.$mol_book2_catalog) = class $mol_book2_catalog extends ($.$mol_book2) { Menu_title(){ return (this.Menu().Title()); } menu_title(){ return ""; } Menu_tools(){ return (this.Menu().Tools()); } Menu_logo(){ return null; } menu_head(){ return [(this.Menu_title()), (this.Menu_tools())]; } menu_filter(next){ if(next !== undefined) return next; return ""; } Menu_filter(){ const obj = new this.$.$mol_search(); (obj.query) = (next) => ((this.menu_filter(next))); return obj; } Menu_links_empty(){ const obj = new this.$.$mol_view(); return obj; } arg(id){ return {}; } menu_link_arg(id){ return (this.arg(id)); } spread_title(id){ return ""; } Menu_link_title(id){ const obj = new this.$.$mol_dimmer(); (obj.needle) = () => ((this.menu_filter())); (obj.haystack) = () => ((this.spread_title(id))); return obj; } menu_link_content(id){ return [(this.Menu_link_title(id))]; } Menu_link(id){ const obj = new this.$.$mol_link(); (obj.arg) = () => ((this.menu_link_arg(id))); (obj.sub) = () => ((this.menu_link_content(id))); return obj; } menu_item_content(id){ return [(this.Menu_link(id))]; } Menu_item(id){ const obj = new this.$.$mol_view(); (obj.sub) = () => ((this.menu_item_content(id))); return obj; } menu_links(){ return [(this.Menu_item("0"))]; } Menu_links(){ const obj = new this.$.$mol_list(); (obj.Empty) = () => ((this.Menu_links_empty())); (obj.rows) = () => ((this.menu_links())); return obj; } menu_body(){ return [(this.Menu_filter()), (this.Menu_links())]; } menu_foot(){ return []; } Menu(){ const obj = new this.$.$mol_page(); (obj.title) = () => ((this.menu_title())); (obj.Logo) = () => ((this.Menu_logo())); (obj.tools) = () => ([...(this.menu_tools()), ...(this.addon_tools())]); (obj.head) = () => ((this.menu_head())); (obj.body) = () => ((this.menu_body())); (obj.foot) = () => ((this.menu_foot())); return obj; } spread_close_arg(){ return {}; } Spread_close_icon(){ const obj = new this.$.$mol_icon_close(); return obj; } param(){ return ""; } spread(next){ if(next !== undefined) return next; return ""; } spreads(){ return {}; } Spread(id){ const obj = new this.$.$mol_view(); return obj; } Spread_default(){ return null; } spread_ids(){ return []; } menu_filter_enabled(){ return false; } spread_ids_filtered(){ return []; } spread_current(){ return null; } menu_tools(){ return []; } addon_tools(){ return []; } pages(){ return [(this.Menu())]; } Spread_close(){ const obj = new this.$.$mol_link(); (obj.arg) = () => ((this.spread_close_arg())); (obj.hint) = () => ((this.$.$mol_locale.text("$mol_book2_catalog_Spread_close_hint"))); (obj.sub) = () => ([(this.Spread_close_icon())]); return obj; } }; ($mol_mem(($.$mol_book2_catalog.prototype), "menu_filter")); ($mol_mem(($.$mol_book2_catalog.prototype), "Menu_filter")); ($mol_mem(($.$mol_book2_catalog.prototype), "Menu_links_empty")); ($mol_mem_key(($.$mol_book2_catalog.prototype), "Menu_link_title")); ($mol_mem_key(($.$mol_book2_catalog.prototype), "Menu_link")); ($mol_mem_key(($.$mol_book2_catalog.prototype), "Menu_item")); ($mol_mem(($.$mol_book2_catalog.prototype), "Menu_links")); ($mol_mem(($.$mol_book2_catalog.prototype), "Menu")); ($mol_mem(($.$mol_book2_catalog.prototype), "Spread_close_icon")); ($mol_mem(($.$mol_book2_catalog.prototype), "spread")); ($mol_mem_key(($.$mol_book2_catalog.prototype), "Spread")); ($mol_mem(($.$mol_book2_catalog.prototype), "Spread_close")); ; "use strict"; var $; (function ($) { function $mol_match_text(query, values) { const tags = query.toLowerCase().trim().split(/\s+/).filter(tag => tag); if (tags.length === 0) return () => true; return (variant) => { const vals = values(variant); return tags.every(tag => vals.some(val => val.toLowerCase().indexOf(tag) >= 0)); }; } $.$mol_match_text = $mol_match_text; })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_book2_catalog extends $.$mol_book2_catalog { spread_current() { return this.spread() === '' ? this.Spread_default() : this.Spread(this.spread()); } pages() { const spread = this.spread_current(); return [ this.Menu(), ...spread ? spread instanceof $mol_book2 ? spread.pages_deep() : [spread] : [], ]; } auto() { const spread = this.spread_current(); if (spread instanceof $mol_book2) spread.auto(); } spread_ids() { return Object.keys(this.spreads()); } menu_body() { return [ ...this.menu_filter_enabled() ? [this.Menu_filter()] : [], this.Menu_links(), ]; } menu_filter_enabled() { return this.spread_ids().length >= 10; } menu_links() { return this.spread_ids_filtered() .map(spread => this.Menu_item(spread)); } spread_ids_filtered() { return this.spread_ids() .filter($mol_match_text(this.menu_filter(), spread => [this.spread_title(spread)])); } Spread(id) { return this.spreads()[id]; } Spread_default() { return this.spreads()['']; } spread(next) { return this.$.$mol_state_arg.value(this.param(), next) ?? ''; } arg(spread) { return { [this.param()]: spread || null }; } spread_close_arg() { return { [this.param()]: null }; } spread_title(spread) { const page = this.Spread(spread); return page instanceof $mol_book2 && page.menu_title() || page.title() || spread; } spread_current_book() { const spread = this.spread_current(); return spread instanceof $mol_book2 ? spread : null; } placeholders() { const spread_placeholders = this.spread_current_book()?.placeholders() ?? []; return spread_placeholders.length ? spread_placeholders : super.placeholders(); } } __decorate([ $mol_mem ], $mol_book2_catalog.prototype, "pages", null); __decorate([ $mol_mem ], $mol_book2_catalog.prototype, "spread_ids", null); __decorate([ $mol_mem ], $mol_book2_catalog.prototype, "menu_body", null); __decorate([ $mol_mem ], $mol_book2_catalog.prototype, "menu_links", null); __decorate([ $mol_mem ], $mol_book2_catalog.prototype, "spread_ids_filtered", null); __decorate([ $mol_mem ], $mol_book2_catalog.prototype, "spread", null); __decorate([ $mol_mem ], $mol_book2_catalog.prototype, "placeholders", null); $$.$mol_book2_catalog = $mol_book2_catalog; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { var $$; (function ($$) { $mol_style_define($mol_book2_catalog, { Menu_filter: { flex: { shrink: 0, grow: 0, }, alignSelf: 'stretch', }, Menu_item: { align: { items: 'flex-start', }, }, Menu_link: { flex: { grow: 1, shrink: 1, wrap: 'wrap', }, }, }); })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; ($.$mol_theme_auto) = class $mol_theme_auto extends ($.$mol_plugin) { dark(){ return "$mol_theme_dark"; } theme(){ return (this.dark()); } light(){ return "$mol_theme_light"; } attr(){ return {"mol_theme": (this.theme())}; } }; ; "use strict"; var $; (function ($) { class $mol_media extends $mol_object2 { static match(query, next) { if (next !== undefined) return next; const res = this.$.$mol_dom_context.matchMedia?.(query) ?? {}; res.onchange = () => this.match(query, res.matches); return res.matches; } } __decorate([ $mol_mem_key ], $mol_media, "match", null); $.$mol_media = $mol_media; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function parse(theme) { if (theme === 'true') return true; if (theme === 'false') return false; return null; } function $mol_lights(next) { const arg = parse(this.$mol_state_arg.value('mol_lights')); const base = this.$mol_media.match('(prefers-color-scheme: light)'); if (next === undefined) { return arg ?? this.$mol_state_local.value('$mol_lights') ?? base; } else { if (arg === null) { this.$mol_state_local.value('$mol_lights', next === base ? null : next); } else { this.$mol_state_arg.value('mol_lights', String(next)); } return next; } } $.$mol_lights = $mol_lights; })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_theme_auto extends $.$mol_theme_auto { theme() { return this.$.$mol_lights() ? this.light() : this.dark(); } } $$.$mol_theme_auto = $mol_theme_auto; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; ($.$mol_check) = class $mol_check extends ($.$mol_button_minor) { checked(next){ if(next !== undefined) return next; return false; } aria_checked(){ return "false"; } aria_role(){ return "checkbox"; } Icon(){ return null; } title(){ return ""; } Title(){ const obj = new this.$.$mol_view(); (obj.sub) = () => ([(this.title())]); return obj; } label(){ return [(this.Title())]; } attr(){ return { ...(super.attr()), "mol_check_checked": (this.checked()), "aria-checked": (this.aria_checked()), "role": (this.aria_role()) }; } sub(){ return [(this.Icon()), (this.label())]; } }; ($mol_mem(($.$mol_check.prototype), "checked")); ($mol_mem(($.$mol_check.prototype), "Title")); ; "use strict"; var $; (function ($) { $mol_style_attach("mol/check/check.css", "[mol_check] {\n\tflex: 0 0 auto;\n\tjustify-content: flex-start;\n\talign-content: center;\n\t/* align-items: flex-start; */\n\tborder: none;\n\tfont-weight: inherit;\n\tbox-shadow: none;\n\ttext-align: left;\n\tdisplay: inline-flex;\n\tflex-wrap: nowrap;\n}\n\n[mol_check_title] {\n\tflex-shrink: 1;\n}\n"); })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_check extends $.$mol_check { click(next) { if (next?.defaultPrevented) return; this.checked(!this.checked()); if (next) next.preventDefault(); } sub() { return [ ...$mol_maybe(this.Icon()), ...this.label(), ]; } label() { return this.title() ? super.label() : []; } aria_checked() { return String(this.checked()); } } $$.$mol_check = $mol_check; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; ($.$mol_check_icon) = class $mol_check_icon extends ($.$mol_check) {}; ; "use strict"; var $; (function ($) { $mol_style_attach("mol/check/icon/icon.view.css", "[mol_check_icon]:where([mol_check_checked]) {\n\tcolor: var(--mol_theme_current);\n}\n"); })($ || ($ = {})); ; "use strict"; ; ($.$mol_icon_brightness_4) = class $mol_icon_brightness_4 extends ($.$mol_icon) { path(){ return "M12,18C11.11,18 10.26,17.8 9.5,17.45C11.56,16.5 13,14.42 13,12C13,9.58 11.56,7.5 9.5,6.55C10.26,6.2 11.11,6 12,6A6,6 0 0,1 18,12A6,6 0 0,1 12,18M20,8.69V4H15.31L12,0.69L8.69,4H4V8.69L0.69,12L4,15.31V20H8.69L12,23.31L15.31,20H20V15.31L23.31,12L20,8.69Z"; } }; ; "use strict"; ; ($.$mol_lights_toggle) = class $mol_lights_toggle extends ($.$mol_check_icon) { Lights_icon(){ const obj = new this.$.$mol_icon_brightness_4(); return obj; } lights(next){ if(next !== undefined) return next; return false; } Icon(){ return (this.Lights_icon()); } hint(){ return (this.$.$mol_locale.text("$mol_lights_toggle_hint")); } checked(next){ return (this.lights(next)); } }; ($mol_mem(($.$mol_lights_toggle.prototype), "Lights_icon")); ($mol_mem(($.$mol_lights_toggle.prototype), "lights")); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_lights_toggle extends $.$mol_lights_toggle { lights(next) { return this.$.$mol_lights(next); } } $$.$mol_lights_toggle = $mol_lights_toggle; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; ($.$mol_icon_share) = class $mol_icon_share extends ($.$mol_icon) { path(){ return "M21,12L14,5V9C7,10 4,15 3,20C5.5,16.5 9,14.9 14,14.9V19L21,12Z"; } }; ; "use strict"; ; ($.$mol_icon_share_variant) = class $mol_icon_share_variant extends ($.$mol_icon) { path(){ return "M18,16.08C17.24,16.08 16.56,16.38 16.04,16.85L8.91,12.7C8.96,12.47 9,12.24 9,12C9,11.76 8.96,11.53 8.91,11.3L15.96,7.19C16.5,7.69 17.21,8 18,8A3,3 0 0,0 21,5A3,3 0 0,0 18,2A3,3 0 0,0 15,5C15,5.24 15.04,5.47 15.09,5.7L8.04,9.81C7.5,9.31 6.79,9 6,9A3,3 0 0,0 3,12A3,3 0 0,0 6,15C6.79,15 7.5,14.69 8.04,14.19L15.16,18.34C15.11,18.55 15.08,18.77 15.08,19C15.08,20.61 16.39,21.91 18,21.91C19.61,21.91 20.92,20.61 20.92,19A2.92,2.92 0 0,0 18,16.08Z"; } }; ; "use strict"; ; ($.$mol_button_share) = class $mol_button_share extends ($.$mol_button_minor) { Icon(){ const obj = new this.$.$mol_icon_share_variant(); return obj; } title(){ return ""; } uri(){ return ""; } capture(){ return null; } hint(){ return (this.$.$mol_locale.text("$mol_button_share_hint")); } sub(){ return [(this.Icon()), (this.title())]; } }; ($mol_mem(($.$mol_button_share.prototype), "Icon")); ; "use strict"; ; "use strict"; var $; (function ($) { $.$mol_jsx_prefix = ''; $.$mol_jsx_crumbs = ''; $.$mol_jsx_booked = null; $.$mol_jsx_document = { getElementById: () => null, createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name), createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(), }; $.$mol_jsx_frag = ''; function $mol_jsx(Elem, props, ...childNodes) { const id = props && props.id || ''; const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix; const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs; if (Elem && $.$mol_jsx_booked) { if ($.$mol_jsx_booked.has(id)) { $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`)); } else { $.$mol_jsx_booked.add(id); } } let node = guid ? $.$mol_jsx_document.getElementById(guid) : null; if ($.$mol_jsx_prefix) { const prefix_ext = $.$mol_jsx_prefix; const booked_ext = $.$mol_jsx_booked; const crumbs_ext = $.$mol_jsx_crumbs; for (const field in props) { const func = props[field]; if (typeof func !== 'function') continue; const wrapper = function (...args) { const prefix = $.$mol_jsx_prefix; const booked = $.$mol_jsx_booked; const crumbs = $.$mol_jsx_crumbs; try { $.$mol_jsx_prefix = prefix_ext; $.$mol_jsx_booked = booked_ext; $.$mol_jsx_crumbs = crumbs_ext; return func.call(this, ...args); } finally { $.$mol_jsx_prefix = prefix; $.$mol_jsx_booked = booked; $.$mol_jsx_crumbs = crumbs; } }; $mol_func_name_from(wrapper, func); props[field] = wrapper; } } if (typeof Elem !== 'string') { if ('prototype' in Elem) { const view = node && node[String(Elem)] || new Elem; Object.assign(view, props); view[Symbol.toStringTag] = guid; view.childNodes = childNodes; if (!view.ownerDocument) view.ownerDocument = $.$mol_jsx_document; view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem); node = view.valueOf(); node[String(Elem)] = view; return node; } else { const prefix = $.$mol_jsx_prefix; const booked = $.$mol_jsx_booked; const crumbs = $.$mol_jsx_crumbs; try { $.$mol_jsx_prefix = guid; $.$mol_jsx_booked = new Set; $.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem); return Elem(props, ...childNodes); } finally { $.$mol_jsx_prefix = prefix; $.$mol_jsx_booked = booked; $.$mol_jsx_crumbs = crumbs; } } } if (!node) { node = Elem ? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem) : $.$mol_jsx_document.createDocumentFragment(); } $mol_dom_render_children(node, [].concat(...childNodes)); if (!Elem) return node; if (guid) node.id = guid; for (const key in props) { if (key === 'id') continue; if (typeof props[key] === 'string') { if (typeof node[key] === 'string') node[key] = props[key]; node.setAttribute(key, props[key]); } else if (props[key] && typeof props[key] === 'object' && Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) { if (typeof node[key] === 'object') { Object.assign(node[key], props[key]); continue; } } else { node[key] = props[key]; } } if ($.$mol_jsx_crumbs) node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self; return node; } $.$mol_jsx = $mol_jsx; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_dom_serialize(node) { const serializer = new $mol_dom_context.XMLSerializer; return serializer.serializeToString(node); } $.$mol_dom_serialize = $mol_dom_serialize; })($ || ($ = {})); ; "use strict"; var $; (function ($) { async function $mol_dom_capture_svg(el) { function restyle(el, styles) { for (let i = 0; i < styles.length; ++i) { const prop = styles[i]; el.style[prop] = styles[prop]; } } function clone(el) { const re = el.cloneNode(); if (el instanceof HTMLImageElement && !/^(data|blob):/.test(el.src)) { const canvas = $mol_jsx("canvas", { width: el.naturalWidth, height: el.naturalHeight }); const context = canvas.getContext('2d'); context.drawImage(el, 0, 0); try { ; re.src = canvas.toDataURL(); } catch (error) { $mol_fail_log(error); } } if (re instanceof HTMLInputElement) { re.setAttribute('value', el.value); if (el.checked) re.setAttribute('checked', ''); } if (re instanceof HTMLTextAreaElement) { re.setAttribute('value', el.value); } const styles = $mol_dom_context.getComputedStyle(el); restyle(re, styles); const before = $mol_dom_context.getComputedStyle(el, ':before'); if (before.content[0] === '"') { const kid = $mol_jsx("span", null, JSON.parse(before.content)); restyle(kid, before); re.appendChild(kid); } for (const kid of el.childNodes) { const dup = (kid.nodeType === kid.ELEMENT_NODE) ? clone(kid) : kid.cloneNode(); re.appendChild(dup); } const after = $mol_dom_context.getComputedStyle(el, ':after'); if (after.content[0] === '"') { const kid = $mol_jsx("span", null, JSON.parse(after.content)); restyle(kid, after); re.appendChild(kid); } return re; } const { width, height } = el.getBoundingClientRect(); return $mol_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: `0 0 ${width} ${height}`, width: String(width), height: String(height) }, $mol_jsx("foreignObject", { xmlns: "http://www.w3.org/2000/svg", width: String(width), height: String(height) }, clone(el))); } $.$mol_dom_capture_svg = $mol_dom_capture_svg; async function $mol_dom_capture_image(el) { const xml = $mol_dom_serialize(await $mol_dom_capture_svg(el)); const uri = 'data:image/svg+xml,' + encodeURIComponent(xml); const image = $mol_jsx("img", { src: uri }); await wait_load(image); return image; } $.$mol_dom_capture_image = $mol_dom_capture_image; async function $mol_dom_capture_canvas(el) { const image = await $mol_dom_capture_image(el); const canvas = $mol_jsx("canvas", { width: image.width, height: image.height }); const context = canvas.getContext('2d'); context.drawImage(image, 0, 0); return canvas; } $.$mol_dom_capture_canvas = $mol_dom_capture_canvas; function wait_load(el) { return new Promise((done, fail) => { el.onload = () => done(el); el.onerror = fail; }); } })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_button_share extends $.$mol_button_share { capture() { return this.$.$mol_dom_context.document.body; } uri() { return this.$.$mol_state_arg.href(); } async click() { const title = this.title(); const url = this.uri() ?? undefined; const files = []; let el = this.capture(); if (el) { if (el instanceof $mol_view) el = el.dom_tree(); const canvas = await $mol_dom_capture_canvas(el); const blob = await new Promise(done => canvas.toBlob(done)); const file = new File([blob], title + '.png', { type: blob.type }); files.push(file); } await this.$.$mol_dom_context.navigator.share({ title, files, url }); } } $$.$mol_button_share = $mol_button_share; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; ($.$mol_labeler) = class $mol_labeler extends ($.$mol_list) { label(){ return [(this.title())]; } Label(){ const obj = new this.$.$mol_view(); (obj.minimal_height) = () => (32); (obj.sub) = () => ((this.label())); return obj; } content(){ return []; } Content(){ const obj = new this.$.$mol_view(); (obj.minimal_height) = () => (24); (obj.sub) = () => ((this.content())); return obj; } rows(){ return [(this.Label()), (this.Content())]; } }; ($mol_mem(($.$mol_labeler.prototype), "Label")); ($mol_mem(($.$mol_labeler.prototype), "Content")); ; "use strict"; var $; (function ($) { $mol_style_attach("mol/labeler/labeler.view.css", "[mol_labeler] {\n\tdisplay: flex;\n\tflex-direction: column;\n\talign-items: stretch;\n\tcursor: inherit;\n}\n\n[mol_labeler_label] {\n\tmin-height: 2rem;\n\tcolor: var(--mol_theme_shade);\n\tpadding: .5rem .75rem 0;\n\tgap: 0 var(--mol_gap_block);\n\tflex-wrap: wrap;\n}\n\n[mol_labeler_content] {\n\tdisplay: flex;\n\tpadding: var(--mol_gap_text);\n}\n"); })($ || ($ = {})); ; "use strict"; ; ($.$hd_canary_app_profile) = class $hd_canary_app_profile extends ($.$mol_page) { profile_name(next){ if(next !== undefined) return next; return ""; } Current_name_string(){ const obj = new this.$.$mol_string(); (obj.value) = (next) => ((this.profile_name(next))); return obj; } Current_profile_name_labeler(){ const obj = new this.$.$mol_labeler(); (obj.title) = () => ("Ваше имя:"); (obj.content) = () => ([(this.Current_name_string())]); return obj; } Current_profile(){ const obj = new this.$.$mol_labeler(); (obj.title) = () => ("Текущий профиль"); (obj.content) = () => ([(this.Current_profile_name_labeler())]); return obj; } title(){ return (this.$.$mol_locale.text("$hd_canary_app_profile_title")); } key_size(){ return 144; } bid_pass_long(){ return (this.$.$mol_locale.text("$hd_canary_app_profile_bid_pass_long")); } attr(){ return {...(super.attr()), "mol_theme": "$mol_theme_special"}; } body(){ return [(this.Current_profile())]; } }; ($mol_mem(($.$hd_canary_app_profile.prototype), "profile_name")); ($mol_mem(($.$hd_canary_app_profile.prototype), "Current_name_string")); ($mol_mem(($.$hd_canary_app_profile.prototype), "Current_profile_name_labeler")); ($mol_mem(($.$hd_canary_app_profile.prototype), "Current_profile")); ; "use strict"; ; "use strict"; var $; (function ($) { function $mol_base64_encode(src) { throw new Error('Not implemented'); } $.$mol_base64_encode = $mol_base64_encode; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function binary_string(bytes) { let binary = ''; if (typeof bytes !== 'string') { for (const byte of bytes) binary += String.fromCharCode(byte); } else { binary = unescape(encodeURIComponent(bytes)); } return binary; } function $mol_base64_encode_web(str) { return $mol_dom_context.btoa(binary_string(str)); } $.$mol_base64_encode_web = $mol_base64_encode_web; $.$mol_base64_encode = $mol_base64_encode_web; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_base64_decode(base64) { throw new Error('Not implemented'); } $.$mol_base64_decode = $mol_base64_decode; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_base64_decode_web(base64Str) { return new Uint8Array($mol_dom_context.atob(base64Str).split('').map(c => c.charCodeAt(0))); } $.$mol_base64_decode_web = $mol_base64_decode_web; $.$mol_base64_decode = $mol_base64_decode_web; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_base64_ae_encode(buffer) { return $mol_base64_encode(buffer).replace(/\+/g, 'æ').replace(/\//g, 'Æ').replace(/=/g, ''); } $.$mol_base64_ae_encode = $mol_base64_ae_encode; function $mol_base64_ae_decode(str) { return $mol_base64_decode(str.replace(/æ/g, '+').replace(/Æ/g, '/')); } $.$mol_base64_ae_decode = $mol_base64_ae_decode; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_buffer extends DataView { [Symbol.toStringTag] = this.constructor.name + '<>'; static from(array) { if (typeof array === 'number') array = new Uint8Array(array); if (typeof array === 'string') array = $mol_base64_ae_decode(array); return new this(array.buffer, array.byteOffset, array.byteLength); } static toString() { return $$.$mol_func_name(this); } getUint48(offset, LE = false) { if (offset % 4) { return this.getUint16(offset, LE) + this.getUint32(offset + 2, LE) * 2 ** 16; } else { return this.getUint32(offset, LE) + this.getUint16(offset + 4, LE) * 2 ** 32; } } setUint48(offset, value, LE = false) { if (offset % 4) { this.setUint16(offset, value & ((1 << 16) - 1), LE); this.setUint32(offset + 2, (value / 2 ** 16) | 0, LE); } else { this.setUint32(offset, value | 0, LE); this.setUint16(offset + 4, (value / 2 ** 32) | 0, LE); } } int8(offset, next) { if (next === undefined) return this.getInt8(offset); if (next >= -(2 ** 7) && next < 2 ** 7) return this.setInt8(offset, next), next; $mol_fail(new Error(`Wrong int8 value ${next}`)); } uint8(offset, next) { if (next === undefined) return this.getUint8(offset); if (next >= 0 && next < 2 ** 8) return this.setUint8(offset, next), next; $mol_fail(new Error(`Wrong uint8 value ${next}`)); } int16(offset, next) { if (next === undefined) return this.getInt16(offset, true); if (next >= -(2 ** 15) && next < 2 ** 15) return this.setInt16(offset, next, true), next; $mol_fail(new Error(`Wrong int16 value ${next}`)); } uint16(offset, next) { if (next === undefined) return this.getUint16(offset, true); if (next >= 0 && next < 2 ** 16) return this.setUint16(offset, next, true), next; $mol_fail(new Error(`Wrong uint16 value ${next}`)); } int32(offset, next) { if (next === undefined) return this.getInt32(offset, true); if (next >= -(2 ** 31) && next < 2 ** 31) return this.setInt32(offset, next, true), next; $mol_fail(new Error(`Wrong int32 value ${next}`)); } uint32(offset, next) { if (next === undefined) return this.getUint32(offset, true); if (next >= 0 && next < 2 ** 32) return this.setUint32(offset, next, true), next; $mol_fail(new Error(`Wrong uint32 value ${next}`)); } int64(offset, next) { if (next === undefined) return this.getBigInt64(offset, true); if (next >= -(2n ** 63n) && next < 2n ** 63n) return this.setBigInt64(offset, next, true), next; $mol_fail(new Error(`Wrong int64 value ${next}`)); } uint48(offset, next) { if (next === undefined) return this.getUint48(offset, true); if (next >= 0 && next < 2 ** 48) return this.setUint48(offset, next, true), next; $mol_fail(new Error(`Wrong uint48 value ${next}`)); } uint64(offset, next) { if (next === undefined) return this.getBigUint64(offset, true); if (next >= 0n && next < 2n ** 64n) return this.setBigUint64(offset, next, true), next; $mol_fail(new Error(`Wrong uint64 value ${next}`)); } float32(offset, next) { if (next !== undefined) this.setFloat32(offset, next, true); return this.getFloat32(offset, true); } float64(offset, next) { if (next !== undefined) this.setFloat64(offset, next, true); return this.getFloat64(offset, true); } asArray() { return new Uint8Array(this.buffer, this.byteOffset, this.byteLength); } toString() { return $mol_base64_ae_encode(this.asArray()); } } $.$mol_buffer = $mol_buffer; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_base64_url_encode(buffer) { return $mol_base64_encode(buffer).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); } $.$mol_base64_url_encode = $mol_base64_url_encode; function $mol_base64_url_decode(str) { return $mol_base64_decode(str.replace(/-/g, '+').replace(/_/g, '/')); } $.$mol_base64_url_decode = $mol_base64_url_decode; })($ || ($ = {})); ; "use strict"; var $; (function ($) { $.$mol_crypto_native = crypto; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_crypto_restack(error) { error = new Error(error instanceof Error ? error.message : String(error), { cause: error }); $mol_fail_hidden(error); } $.$mol_crypto_restack = $mol_crypto_restack; })($ || ($ = {})); ; "use strict"; var $; (function ($) { const ecdsa = { name: 'ECDSA', hash: 'SHA-1', namedCurve: "P-256", }; const ecdh = { name: "ECDH", namedCurve: "P-256" }; const jwk = { crv: 'P-256', ext: true, kty: 'EC' }; class $mol_crypto_key extends $mol_buffer { static from(serial) { if (typeof serial === 'string') { serial = new Uint8Array([ ...$mol_base64_url_decode(serial.slice(0, 43)), ...$mol_base64_url_decode(serial.slice(43, 86)), ...$mol_base64_url_decode(serial.slice(86, 129)), ]); } return super.from(serial); } toString() { const arr = this.asArray(); return $mol_base64_url_encode(arr.subarray(0, 32)) + $mol_base64_url_encode(arr.subarray(32, 64)) + $mol_base64_url_encode(arr.subarray(64)); } } __decorate([ $mol_memo.method ], $mol_crypto_key.prototype, "toString", null); $.$mol_crypto_key = $mol_crypto_key; class $mol_crypto_key_public extends $mol_crypto_key { static size_str = 86; static size_bin = 64; async native() { const str = this.toString(); return $mol_crypto_native.subtle.importKey('jwk', { crv: "P-256", ext: true, key_ops: ['verify'], kty: "EC", x: str.slice(0, 43), y: str.slice(43, 86), }, ecdsa, Boolean('extractable'), ['verify']).catch($mol_crypto_restack); } async native_derive() { const serial = this.toString(); return await $mol_crypto_native.subtle.importKey('jwk', { ...jwk, key_ops: [], x: serial.slice(0, 43), y: serial.slice(43, 86), }, ecdh, true, []).catch($mol_crypto_restack); } async verify(data, sign) { return await $mol_crypto_native.subtle.verify(ecdsa, await this.native(), sign, data).catch($mol_crypto_restack); } } __decorate([ $mol_memo.method ], $mol_crypto_key_public.prototype, "native", null); __decorate([ $mol_memo.method ], $mol_crypto_key_public.prototype, "native_derive", null); $.$mol_crypto_key_public = $mol_crypto_key_public; class $mol_crypto_key_private extends $mol_crypto_key { static size_str = 129; static size_bin = 96; static size_sign = 64; static async generate() { const pair = await $mol_crypto_native.subtle.generateKey(ecdsa, Boolean('extractable'), ['sign', 'verify']).catch($mol_crypto_restack); const { x, y, d } = await $mol_crypto_native.subtle.exportKey('jwk', pair.privateKey).catch($mol_crypto_restack); return this.from(x + y + d); } async native() { const str = this.toString(); return await $mol_crypto_native.subtle.importKey('jwk', { crv: "P-256", ext: true, key_ops: ['sign'], kty: "EC", x: str.slice(0, 43), y: str.slice(43, 86), d: str.slice(86, 129), }, ecdsa, Boolean('extractable'), ['sign']).catch($mol_crypto_restack); } async native_derive() { const serial = this.toString(); return $mol_crypto_native.subtle.importKey('jwk', { ...jwk, key_ops: ['deriveKey', 'deriveBits'], x: serial.slice(0, 43), y: serial.slice(43, 86), d: serial.slice(86, 129), }, ecdh, Boolean('extractable'), ['deriveKey', 'deriveBits']).catch($mol_crypto_restack); } public() { return new $mol_crypto_key_public(this.asArray().slice(0, 64).buffer); } async sign(data) { return new Uint8Array(await $mol_crypto_native.subtle.sign(ecdsa, await this.native(), data).catch($mol_crypto_restack)); } } __decorate([ $mol_memo.method ], $mol_crypto_key_private.prototype, "native", null); __decorate([ $mol_memo.method ], $mol_crypto_key_private.prototype, "native_derive", null); __decorate([ $mol_memo.method ], $mol_crypto_key_private.prototype, "public", null); $.$mol_crypto_key_private = $mol_crypto_key_private; })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { function $mol_data_tagged(config) { return config; } $.$mol_data_tagged = $mol_data_tagged; })($ || ($ = {})); ; "use strict"; var $; (function ($) { $.$hyoo_crus_ref = $mol_data_tagged({ $hyoo_crus_ref: (val) => { if (typeof val === 'string') val = Symbol.for(val.replace(/_+$/, '')); if (/^(([a-zæA-ZÆ0-9]{8})?_){0,3}([a-zæA-ZÆ0-9]{8})?$/.test(val.description)) return val; $mol_fail(new Error(`Wrong ref (${val.description})`)); } }).$hyoo_crus_ref; function $hyoo_crus_ref_check(val) { try { $.$hyoo_crus_ref(val); return val; } catch { return ''; } } $.$hyoo_crus_ref_check = $hyoo_crus_ref_check; function $hyoo_crus_ref_lord(ref) { return $.$hyoo_crus_ref(ref.description.split('_').slice(0, 2).join('_')); } $.$hyoo_crus_ref_lord = $hyoo_crus_ref_lord; function $hyoo_crus_ref_land(ref) { return $.$hyoo_crus_ref(ref.description.split('_').slice(0, 3).join('_').replace(/_$/, '')); } $.$hyoo_crus_ref_land = $hyoo_crus_ref_land; function $hyoo_crus_ref_peer(ref) { return ref.description.split('_')[0] ?? ''; } $.$hyoo_crus_ref_peer = $hyoo_crus_ref_peer; function $hyoo_crus_ref_area(ref) { return ref.description.split('_')[2] ?? ''; } $.$hyoo_crus_ref_area = $hyoo_crus_ref_area; function $hyoo_crus_ref_head(ref) { return ref.description.split('_')[3] ?? ''; } $.$hyoo_crus_ref_head = $hyoo_crus_ref_head; function $hyoo_crus_ref_encode(ref) { return $mol_base64_ae_decode((ref.description || '_') .split('_') .map(numb => numb || 'AAAAAAAA') .join('')); } $.$hyoo_crus_ref_encode = $hyoo_crus_ref_encode; function $hyoo_crus_ref_decode(bin) { return $.$hyoo_crus_ref([...$mol_base64_ae_encode(bin).match(/(.{8})/g) ?? []] .map(numb => numb === 'AAAAAAAA' ? '' : numb) .join('_').replace(/_+$/, '')); } $.$hyoo_crus_ref_decode = $hyoo_crus_ref_decode; function $hyoo_crus_ref_relate(base, ref) { base = $hyoo_crus_ref_land(base); if ($hyoo_crus_ref_land(ref) !== base) return ref; const head = $hyoo_crus_ref_head(ref); return $.$hyoo_crus_ref(head ? '___' + head : ''); } $.$hyoo_crus_ref_relate = $hyoo_crus_ref_relate; function $hyoo_crus_ref_resolve(base, ref) { if (!ref.description) return $hyoo_crus_ref_land(base); if (!ref.description.startsWith('___')) return ref; const parts = base.description.split('_').slice(0, 3); while (parts.length < 3) parts.push(''); parts.push(ref.description.slice(3)); return $.$hyoo_crus_ref(parts.join('_')); } $.$hyoo_crus_ref_resolve = $hyoo_crus_ref_resolve; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_crypto_salt() { return $mol_crypto_native.getRandomValues(new Uint8Array(16)); } $.$mol_crypto_salt = $mol_crypto_salt; $.$mol_crypto_salt_once = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6]); })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_crypto_sacred extends $mol_buffer { static size = 16; static make() { return this.from($mol_crypto_salt()); } static from(serial) { if (typeof serial === 'string') { serial = new Uint8Array([ ...$mol_base64_url_decode(serial), ]); } if (!(serial instanceof Uint8Array)) { serial = new Uint8Array(serial.buffer, serial.byteOffset, serial.byteLength); } ; serial[0] = 0xFF; const sacred = super.from(serial); return sacred; } static async from_native(native) { const buf = await $mol_crypto_native.subtle.exportKey('raw', native).catch($mol_crypto_restack); const sacred = this.from(new Uint8Array(buf)); sacred._native = native; return sacred; } constructor(buffer, byteOffset, byteLength) { super(buffer, byteOffset, byteLength); if (this.getUint8(0) !== 0xFF) $mol_fail(new Error('Buffer should starts with 0xFF byte')); } toString() { return $mol_base64_url_encode(this.asArray()); } _native; async native() { return this._native ?? (this._native = await $mol_crypto_native.subtle.importKey('raw', this, { name: 'AES-CBC', length: 128, }, true, ['encrypt', 'decrypt']).catch($mol_crypto_restack)); } async encrypt(open, salt) { return new Uint8Array(await $mol_crypto_native.subtle.encrypt({ name: 'AES-CBC', length: 128, tagLength: 32, iv: salt, }, await this.native(), open).catch($mol_crypto_restack)); } async decrypt(closed, salt) { return new Uint8Array(await $mol_crypto_native.subtle.decrypt({ name: 'AES-CBC', length: 128, tagLength: 32, iv: salt, }, await this.native(), closed).catch($mol_crypto_restack)); } async close(sacred, salt) { if (sacred.getUint8(0) !== 0xFF) throw new Error('Closable buffer should starts with 0xFF'); const buf = new Uint8Array(sacred.buffer, sacred.byteOffset + 1, sacred.byteLength - 1); return this.encrypt(buf, salt); } async open(buf, salt) { const buf2 = new Uint8Array(16); buf2[0] = 0xFF; buf2.set(await this.decrypt(buf, salt), 1); return buf2; } } __decorate([ $mol_memo.method ], $mol_crypto_sacred.prototype, "toString", null); $.$mol_crypto_sacred = $mol_crypto_sacred; })($ || ($ = {})); ; "use strict"; var $; (function ($) { const algorithm = { name: 'AES-CBC', length: 128, tagLength: 32, }; class $mol_crypto_secret extends Object { native; static size = 16; constructor(native) { super(); this.native = native; } static async generate() { return new this(await $mol_crypto_native.subtle.generateKey(algorithm, true, ['encrypt', 'decrypt'])); } static async from(serial) { return new this(await $mol_crypto_native.subtle.importKey('raw', serial, algorithm, true, ['encrypt', 'decrypt'])); } static async pass(pass, salt) { return new this(await $mol_crypto_native.subtle.deriveKey({ name: "PBKDF2", salt, iterations: 10_000, hash: "SHA-256", }, await $mol_crypto_native.subtle.importKey("raw", $mol_charset_encode(pass), "PBKDF2", false, ["deriveKey"]), algorithm, true, ['encrypt', 'decrypt'])); } static async derive(private_serial, public_serial) { const ecdh = { name: "ECDH", namedCurve: "P-256" }; const jwk = { crv: 'P-256', ext: true, kty: 'EC' }; const private_key = await $mol_crypto_native.subtle.importKey('jwk', { ...jwk, key_ops: ['deriveKey'], x: private_serial.slice(0, 43), y: private_serial.slice(43, 86), d: private_serial.slice(86, 129), }, ecdh, true, ['deriveKey']); const public_key = await $mol_crypto_native.subtle.importKey('jwk', { ...jwk, key_ops: [], x: public_serial.slice(0, 43), y: public_serial.slice(43, 86), }, ecdh, true, []); const secret = await $mol_crypto_native.subtle.deriveKey({ name: "ECDH", public: public_key, }, private_key, algorithm, true, ["encrypt", "decrypt"]); return new this(secret); } async serial() { return new Uint8Array(await $mol_crypto_native.subtle.exportKey('raw', this.native)); } async encrypt(open, salt) { return new Uint8Array(await $mol_crypto_native.subtle.encrypt({ ...algorithm, iv: salt, }, this.native, open)); } async decrypt(closed, salt) { return new Uint8Array(await $mol_crypto_native.subtle.decrypt({ ...algorithm, iv: salt, }, this.native, closed)); } } $.$mol_crypto_secret = $mol_crypto_secret; })($ || ($ = {})); ; "use strict"; var $; (function ($) { let $hyoo_crus_part; (function ($hyoo_crus_part) { $hyoo_crus_part[$hyoo_crus_part["land"] = 3] = "land"; $hyoo_crus_part[$hyoo_crus_part["face"] = 11] = "face"; $hyoo_crus_part[$hyoo_crus_part["pass"] = 255] = "pass"; $hyoo_crus_part[$hyoo_crus_part["gift"] = 247] = "gift"; $hyoo_crus_part[$hyoo_crus_part["sand"] = 8] = "sand"; $hyoo_crus_part[$hyoo_crus_part["rock"] = 5] = "rock"; $hyoo_crus_part[$hyoo_crus_part["root"] = 1] = "root"; $hyoo_crus_part[$hyoo_crus_part["buck"] = 9] = "buck"; })($hyoo_crus_part = $.$hyoo_crus_part || ($.$hyoo_crus_part = {})); })($ || ($ = {})); ; "use strict"; ; "use strict"; ; "use strict"; var $; (function ($) { function $mol_data_setup(value, config) { return Object.assign(value, { config, Value: null }); } $.$mol_data_setup = $mol_data_setup; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_func_is_class(func) { return Object.getOwnPropertyDescriptor(func, 'prototype')?.writable === false; } $.$mol_func_is_class = $mol_func_is_class; })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { function $mol_data_pipe(...funcs) { return $mol_data_setup(function (input) { let value = input; for (const func of funcs) value = $mol_func_is_class(func) ? new func(value) : func.call(this, value); return value; }, { funcs }); } $.$mol_data_pipe = $mol_data_pipe; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function cause_serialize(cause) { return JSON.stringify(cause, null, ' ') .replace(/\(/, '<') .replace(/\)/, ' >'); } function frame_normalize(frame) { return (typeof frame === 'string' ? frame : cause_serialize(frame)) .trim() .replace(/at /gm, ' at ') .replace(/^(?! +at )(.*)/gm, ' at | $1 (#)'); } class $mol_error_mix extends AggregateError { cause; name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error'; constructor(message, cause = {}, ...errors) { super(errors, message, { cause }); this.cause = cause; const desc = Object.getOwnPropertyDescriptor(this, 'stack'); const stack_get = () => desc?.get?.() ?? super.stack ?? desc?.value ?? this.message; Object.defineProperty(this, 'stack', { get: () => stack_get() + '\n' + [ this.cause ?? 'no cause', ...this.errors.flatMap(e => [ e.stack, ...e instanceof $mol_error_mix || !e.cause ? [] : [e.cause] ]) ].map(frame_normalize).join('\n') }); Object.defineProperty(this, 'cause', { get: () => cause }); } static [Symbol.toPrimitive]() { return this.toString(); } static toString() { return $$.$mol_func_name(this); } static make(...params) { return new this(...params); } } $.$mol_error_mix = $mol_error_mix; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_data_error extends $mol_error_mix { } $.$mol_data_error = $mol_data_error; })($ || ($ = {})); ; "use strict"; var $; (function ($) { $.$mol_data_number = (val) => { if (typeof val === 'number') return val; return $mol_fail(new $mol_data_error(`${val} is not a number`)); }; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_data_integer(val) { const val2 = $mol_data_number(val); if (Math.floor(val2) === val2) return val2; return $mol_fail(new $mol_data_error(`${val} is not an integer`)); } $.$mol_data_integer = $mol_data_integer; })($ || ($ = {})); ; "use strict"; var $; (function ($) { $.$hyoo_crus_rank = $mol_data_tagged({ $hyoo_crus_rank: $mol_data_pipe($mol_data_integer, (rank) => { if (rank >= $.$hyoo_crus_rank_deny && rank <= $.$hyoo_crus_rank_rule) return rank; $mol_fail(new $mol_data_error(`${rank} is out of Ran range`)); }), }).$hyoo_crus_rank; function $hyoo_crus_rank_make(tier, fame) { return ($hyoo_crus_rank_tier[tier] | $hyoo_crus_rank_rate[fame]); } $.$hyoo_crus_rank_make = $hyoo_crus_rank_make; let $hyoo_crus_rank_tier; (function ($hyoo_crus_rank_tier) { $hyoo_crus_rank_tier[$hyoo_crus_rank_tier["deny"] = 0] = "deny"; $hyoo_crus_rank_tier[$hyoo_crus_rank_tier["read"] = 16] = "read"; $hyoo_crus_rank_tier[$hyoo_crus_rank_tier["join"] = 48] = "join"; $hyoo_crus_rank_tier[$hyoo_crus_rank_tier["post"] = 112] = "post"; $hyoo_crus_rank_tier[$hyoo_crus_rank_tier["rule"] = 240] = "rule"; })($hyoo_crus_rank_tier = $.$hyoo_crus_rank_tier || ($.$hyoo_crus_rank_tier = {})); let $hyoo_crus_rank_rate; (function ($hyoo_crus_rank_rate) { $hyoo_crus_rank_rate[$hyoo_crus_rank_rate["late"] = 0] = "late"; $hyoo_crus_rank_rate[$hyoo_crus_rank_rate["long"] = 3] = "long"; $hyoo_crus_rank_rate[$hyoo_crus_rank_rate["slow"] = 7] = "slow"; $hyoo_crus_rank_rate[$hyoo_crus_rank_rate["fast"] = 11] = "fast"; $hyoo_crus_rank_rate[$hyoo_crus_rank_rate["just"] = 15] = "just"; })($hyoo_crus_rank_rate = $.$hyoo_crus_rank_rate || ($.$hyoo_crus_rank_rate = {})); $.$hyoo_crus_rank_deny = $hyoo_crus_rank_make('deny', 'late'); $.$hyoo_crus_rank_read = $hyoo_crus_rank_make('read', 'late'); $.$hyoo_crus_rank_rule = $hyoo_crus_rank_make('rule', 'just'); function $hyoo_crus_rank_join(rate) { return $hyoo_crus_rank_make('join', rate); } $.$hyoo_crus_rank_join = $hyoo_crus_rank_join; function $hyoo_crus_rank_post(rate) { return $hyoo_crus_rank_make('post', rate); } $.$hyoo_crus_rank_post = $hyoo_crus_rank_post; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_time_base { static patterns = {}; static formatter(pattern) { if (this.patterns[pattern]) return this.patterns[pattern]; var tokens = Object.keys(this.patterns) .sort() .reverse() .map((token) => token.replace(/([-+*.\[\]()\^])/g, '\\$1')); var lexer = RegExp('(.*?)(' + tokens.join('|') + '|$)', 'g'); var funcs = []; pattern.replace(lexer, (str, text, token) => { if (text) funcs.push(() => text); if (token) funcs.push(this.patterns[token]); return str; }); return this.patterns[pattern] = (arg) => { return funcs.reduce((res, func) => res + func(arg), ''); }; } toString(pattern) { const Base = this.constructor; const formatter = Base.formatter(pattern); return formatter(this); } } $.$mol_time_base = $mol_time_base; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_time_duration extends $mol_time_base { constructor(config = 0) { super(); if (typeof config === 'number') { if (!Number.isFinite(config)) throw new RangeError(`Wrong ms count`); this.second = config / 1000; return; } if (typeof config === 'string') { if (config === 'Z') { this.hour = 0; this.minute = 0; return; } duration: { const parser = /^(-?)P(?:([+-]?\d+(?:\.\d+)?)Y)?(?:([+-]?\d+(?:\.\d+)?)M)?(?:([+-]?\d+(?:\.\d+)?)D)?(?:T(?:([+-]?\d+(?:\.\d+)?)h)?(?:([+-]?\d+(?:\.\d+)?)m)?(?:([+-]?\d+(?:\.\d+)?)s)?)?$/i; const found = parser.exec(config); if (!found) break duration; const sign = found[1] ? -1 : 1; if (found[2]) this.year = sign * Number(found[2]); if (found[3]) this.month = sign * Number(found[3]); if (found[4]) this.day = sign * Number(found[4]); if (found[5]) this.hour = sign * Number(found[5]); if (found[6]) this.minute = sign * Number(found[6]); if (found[7]) this.second = sign * Number(found[7]); return; } offset: { var parser = /^[+-](\d\d)(?::?(\d\d))?$/i; var found = parser.exec(config); if (!found) break offset; if (found[1]) this.hour = Number(found[1]); if (found[2]) this.minute = Number(found[2]); return; } throw new Error(`Can not parse time duration (${config})`); } this.year = config.year || 0; this.month = config.month || 0; this.day = config.day || 0; this.hour = config.hour || 0; this.minute = config.minute || 0; this.second = config.second || 0; } year = 0; month = 0; day = 0; hour = 0; minute = 0; second = 0; get normal() { let second = this.second ?? 0; let minute = this.minute ?? 0; let hour = this.hour ?? 0; let day = this.day ?? 0; minute += Math.floor(second / 60); second = second % 60; hour += Math.floor(minute / 60); minute = minute % 60; day += Math.floor(hour / 24); hour = hour % 24; return new $mol_time_duration({ year: this.year, month: this.month, day: day, hour: hour, minute: minute, second: second, }); } summ(config) { const duration = new $mol_time_duration(config); return new $mol_time_duration({ year: this.year + duration.year, month: this.month + duration.month, day: this.day + duration.day, hour: this.hour + duration.hour, minute: this.minute + duration.minute, second: this.second + duration.second, }); } mult(numb) { return new $mol_time_duration({ year: this.year && this.year * numb, month: this.month && this.month * numb, day: this.day && this.day * numb, hour: this.hour && this.hour * numb, minute: this.minute && this.minute * numb, second: this.second && this.second * numb, }); } count(config) { const duration = new $mol_time_duration(config); return this.valueOf() / duration.valueOf(); } valueOf() { var day = this.year * 365 + this.month * 30.4 + this.day; var second = ((day * 24 + this.hour) * 60 + this.minute) * 60 + this.second; return second * 1000; } toJSON() { return this.toString(); } toString(pattern = 'P#Y#M#DT#h#m#s') { return super.toString(pattern); } [Symbol.toPrimitive](mode) { return mode === 'number' ? this.valueOf() : this.toString(); } static patterns = { '#Y': (duration) => { if (!duration.year) return ''; return duration.year + 'Y'; }, '#M': (duration) => { if (!duration.month) return ''; return duration.month + 'M'; }, '#D': (duration) => { if (!duration.day) return ''; return duration.day + 'D'; }, '#h': (duration) => { if (!duration.hour) return ''; return duration.hour + 'H'; }, '#m': (duration) => { if (!duration.minute) return ''; return duration.minute + 'M'; }, '#s': (duration) => { if (!duration.second) return ''; return duration.second + 'S'; }, 'hh': (moment) => { if (moment.hour == null) return ''; return String(100 + moment.hour).slice(1); }, 'h': (moment) => { if (moment.hour == null) return ''; return String(moment.hour); }, ':mm': (moment) => { if (moment.minute == null) return ''; return ':' + $mol_time_moment.patterns['mm'](moment); }, 'mm': (moment) => { if (moment.minute == null) return ''; return String(100 + moment.minute).slice(1); }, 'm': (moment) => { if (moment.minute == null) return ''; return String(moment.minute); }, ':ss': (moment) => { if (moment.second == null) return ''; return ':' + $mol_time_moment.patterns['ss'](moment); }, 'ss': (moment) => { if (moment.second == null) return ''; return String(100 + moment.second | 0).slice(1); }, 's': (moment) => { if (moment.second == null) return ''; return String(moment.second | 0); }, '.sss': (moment) => { if (moment.second == null) return ''; return '.' + $mol_time_moment.patterns['sss'](moment); }, 'sss': (moment) => { if (moment.second == null) return ''; const millisecond = (moment.second - Math.trunc(moment.second)).toFixed(3); return millisecond.slice(2); }, }; } $.$mol_time_duration = $mol_time_duration; })($ || ($ = {})); ; "use strict"; var $; (function ($) { let $mol_time_moment_weekdays; (function ($mol_time_moment_weekdays) { $mol_time_moment_weekdays[$mol_time_moment_weekdays["monday"] = 0] = "monday"; $mol_time_moment_weekdays[$mol_time_moment_weekdays["tuesday"] = 1] = "tuesday"; $mol_time_moment_weekdays[$mol_time_moment_weekdays["wednesday"] = 2] = "wednesday"; $mol_time_moment_weekdays[$mol_time_moment_weekdays["thursday"] = 3] = "thursday"; $mol_time_moment_weekdays[$mol_time_moment_weekdays["friday"] = 4] = "friday"; $mol_time_moment_weekdays[$mol_time_moment_weekdays["saturday"] = 5] = "saturday"; $mol_time_moment_weekdays[$mol_time_moment_weekdays["sunday"] = 6] = "sunday"; })($mol_time_moment_weekdays = $.$mol_time_moment_weekdays || ($.$mol_time_moment_weekdays = {})); function numb(str, max) { const numb = Number(str); if (numb < max) return numb; $mol_fail(new Error(`Wrong time component ${str}`)); } class $mol_time_moment extends $mol_time_base { constructor(config = new Date) { super(); if (typeof config === 'number') { config = new Date(config); if (Number.isNaN(config.valueOf())) throw new RangeError(`Wrong ms count`); } if (typeof config === 'string') { const parsed = /^(?:(\d\d?\d?\d?)(?:-?(\d\d?)(?:-?(\d\d?))?)?)?(?:[T ](?:(\d\d?)(?::?(\d\d?)(?::?(\d\d?(?:\.\d+)?))?)?)?(Z|[\+\-]\d\d?(?::?(?:\d\d?)?)?)?)?$/.exec(config); if (!parsed) throw new Error(`Can not parse time moment (${config})`); if (parsed[1]) this.year = numb(parsed[1], 9999); if (parsed[2]) this.month = numb(parsed[2], 13) - 1; if (parsed[3]) this.day = numb(parsed[3], 32) - 1; if (parsed[4]) this.hour = numb(parsed[4], 60); if (parsed[5]) this.minute = numb(parsed[5], 60); if (parsed[6]) this.second = numb(parsed[6], 60); if (parsed[7]) this.offset = new $mol_time_duration(parsed[7]); return; } if (config instanceof Date) { this.year = config.getFullYear(); this.month = config.getMonth(); this.day = config.getDate() - 1; this.hour = config.getHours(); this.minute = config.getMinutes(); this.second = config.getSeconds() + config.getMilliseconds() / 1000; const offset = -config.getTimezoneOffset(); this.offset = new $mol_time_duration({ hour: (offset < 0) ? Math.ceil(offset / 60) : Math.floor(offset / 60), minute: offset % 60 }); return; } this.year = config.year; this.month = config.month; this.day = config.day; this.hour = config.hour; this.minute = config.minute; this.second = config.second; this.offset = config.offset == null ? config.offset : new $mol_time_duration(config.offset); } year; month; day; hour; minute; second; offset; get weekday() { return (this.native.getDay() + 6) % 7; } _native; get native() { if (this._native) return this._native; const second = Math.floor(this.second ?? 0); const current = new Date(); const native = new Date(this.year ?? current.getFullYear(), this.month ?? (this.year === undefined ? current.getMonth() : 0), (this.day ?? (this.year === undefined && this.month === undefined ? current.getDate() - 1 : 0)) + 1, this.hour ?? 0, this.minute ?? 0, second, Math.floor(((this.second ?? 0) - second) * 1000)); const offset = -native.getTimezoneOffset(); shift: if (this.offset) { const target = this.offset.count('PT1m'); if (target === offset) break shift; native.setMinutes(native.getMinutes() + offset - target); } return this._native = native; } _normal; get normal() { if (this._normal) return this._normal; const moment = new $mol_time_moment(this.native).toOffset(this.offset); return this._normal = new $mol_time_moment({ year: this.year === undefined ? undefined : moment.year, month: this.month === undefined ? undefined : moment.month, day: this.day === undefined ? undefined : moment.day, hour: this.hour === undefined ? undefined : moment.hour, minute: this.minute === undefined ? undefined : moment.minute, second: this.second === undefined ? undefined : moment.second, offset: this.offset === undefined ? undefined : moment.offset, }); } merge(config) { const moment = new $mol_time_moment(config); return new $mol_time_moment({ year: moment.year === undefined ? this.year : moment.year, month: moment.month === undefined ? this.month : moment.month, day: moment.day === undefined ? this.day : moment.day, hour: moment.hour === undefined ? this.hour : moment.hour, minute: moment.minute === undefined ? this.minute : moment.minute, second: moment.second === undefined ? this.second : moment.second, offset: moment.offset === undefined ? this.offset : moment.offset, }); } shift(config) { const duration = new $mol_time_duration(config); const moment = new $mol_time_moment().merge({ year: this.year ?? 0, month: this.month ?? 0, day: this.day ?? 0, hour: this.hour ?? 0, minute: this.minute ?? 0, second: this.second ?? 0, offset: this.offset ?? 0 }); const second = moment.second + (duration.second ?? 0); const native = new Date(moment.year + (duration.year ?? 0), moment.month + (duration.month ?? 0), moment.day + 1 + (duration.day ?? 0), moment.hour + (duration.hour ?? 0), moment.minute + (duration.minute ?? 0), Math.floor(second), (second - Math.floor(second)) * 1000); if (isNaN(native.valueOf())) throw new Error('Wrong time'); return new $mol_time_moment({ year: this.year === undefined ? undefined : native.getFullYear(), month: this.month === undefined ? undefined : native.getMonth(), day: this.day === undefined ? undefined : native.getDate() - 1, hour: this.hour === undefined ? undefined : native.getHours(), minute: this.minute === undefined ? undefined : native.getMinutes(), second: this.second === undefined ? undefined : native.getSeconds() + native.getMilliseconds() / 1000, offset: this.offset, }); } mask(config) { const mask = new $mol_time_moment(config); return new $mol_time_moment({ year: mask.year === undefined ? undefined : this.year, month: mask.month === undefined ? undefined : this.month, day: mask.day === undefined ? undefined : this.day, hour: mask.hour === undefined ? undefined : this.hour, minute: mask.minute === undefined ? undefined : this.minute, second: mask.second === undefined ? undefined : this.second, offset: mask.offset === undefined ? undefined : this.offset, }); } toOffset(config = new $mol_time_moment().offset) { const duration = new $mol_time_duration(config); const offset = this.offset || new $mol_time_moment().offset; let with_time = new $mol_time_moment('0001-01-01T00:00:00').merge(this); const moment = with_time.shift(duration.summ(offset.mult(-1))); return moment.merge({ offset: duration }); } valueOf() { return this.native.getTime(); } toJSON() { return this.toString(); } toString(pattern = 'YYYY-MM-DDThh:mm:ss.sssZ') { return super.toString(pattern); } [Symbol.toPrimitive](mode) { return mode === 'number' ? this.valueOf() : this.toString(); } [$mol_dev_format_head]() { return $mol_dev_format_span({}, $mol_dev_format_native(this), ' ', $mol_dev_format_accent(this.toString('YYYY-MM-DD hh:mm:ss.sss Z'))); } static patterns = { 'YYYY': (moment) => { if (moment.year == null) return ''; return String(moment.year); }, 'AD': (moment) => { if (moment.year == null) return ''; return String(Math.floor(moment.year / 100) + 1); }, 'YY': (moment) => { if (moment.year == null) return ''; return String(moment.year % 100); }, 'Month': (pattern => (moment) => { if (moment.month == null) return ''; return pattern.format(moment.native); })(new Intl.DateTimeFormat(undefined, { month: 'long' })), 'DD Month': (pattern => (moment) => { if (moment.month == null) { if (moment.day == null) { return ''; } else { return $mol_time_moment.patterns['DD'](moment); } } else { if (moment.day == null) { return $mol_time_moment.patterns['Month'](moment); } else { return pattern.format(moment.native); } } })(new Intl.DateTimeFormat(undefined, { day: '2-digit', month: 'long' })), 'D Month': (pattern => (moment) => { if (moment.month == null) { if (moment.day == null) { return ''; } else { return $mol_time_moment.patterns['D'](moment); } } else { if (moment.day == null) { return $mol_time_moment.patterns['Month'](moment); } else { return pattern.format(moment.native); } } })(new Intl.DateTimeFormat(undefined, { day: 'numeric', month: 'long' })), 'Mon': (pattern => (moment) => { if (moment.month == null) return ''; return pattern.format(moment.native); })(new Intl.DateTimeFormat(undefined, { month: 'short' })), 'DD Mon': (pattern => (moment) => { if (moment.month == null) { if (moment.day == null) { return ''; } else { return $mol_time_moment.patterns['DD'](moment); } } else { if (moment.day == null) { return $mol_time_moment.patterns['Mon'](moment); } else { return pattern.format(moment.native); } } })(new Intl.DateTimeFormat(undefined, { day: '2-digit', month: 'short' })), 'D Mon': (pattern => (moment) => { if (moment.month == null) { if (moment.day == null) { return ''; } else { return $mol_time_moment.patterns['D'](moment); } } else { if (moment.day == null) { return $mol_time_moment.patterns['Mon'](moment); } else { return pattern.format(moment.native); } } })(new Intl.DateTimeFormat(undefined, { day: 'numeric', month: 'short' })), '-MM': (moment) => { if (moment.month == null) return ''; return '-' + $mol_time_moment.patterns['MM'](moment); }, 'MM': (moment) => { if (moment.month == null) return ''; return String(100 + moment.month + 1).slice(1); }, 'M': (moment) => { if (moment.month == null) return ''; return String(moment.month + 1); }, 'WeekDay': (pattern => (moment) => { if (moment.day == null) return ''; if (moment.month == null) return ''; if (moment.year == null) return ''; return pattern.format(moment.native); })(new Intl.DateTimeFormat(undefined, { weekday: 'long' })), 'WD': (pattern => (moment) => { if (moment.day == null) return ''; if (moment.month == null) return ''; if (moment.year == null) return ''; return pattern.format(moment.native); })(new Intl.DateTimeFormat(undefined, { weekday: 'short' })), '-DD': (moment) => { if (moment.day == null) return ''; return '-' + $mol_time_moment.patterns['DD'](moment); }, 'DD': (moment) => { if (moment.day == null) return ''; return String(100 + moment.day + 1).slice(1); }, 'D': (moment) => { if (moment.day == null) return ''; return String(moment.day + 1); }, 'Thh': (moment) => { if (moment.hour == null) return ''; return 'T' + $mol_time_moment.patterns['hh'](moment); }, 'hh': (moment) => { if (moment.hour == null) return ''; return String(100 + moment.hour).slice(1); }, 'h': (moment) => { if (moment.hour == null) return ''; return String(moment.hour); }, ':mm': (moment) => { if (moment.minute == null) return ''; return ':' + $mol_time_moment.patterns['mm'](moment); }, 'mm': (moment) => { if (moment.minute == null) return ''; return String(100 + moment.minute).slice(1); }, 'm': (moment) => { if (moment.minute == null) return ''; return String(moment.minute); }, ':ss': (moment) => { if (moment.second == null) return ''; return ':' + $mol_time_moment.patterns['ss'](moment); }, 'ss': (moment) => { if (moment.second == null) return ''; return String(100 + moment.second | 0).slice(1); }, 's': (moment) => { if (moment.second == null) return ''; return String(moment.second | 0); }, '.sss': (moment) => { if (moment.second == null) return ''; if (moment.second === (moment.second | 0)) return ''; return '.' + $mol_time_moment.patterns['sss'](moment); }, 'sss': (moment) => { if (moment.second == null) return ''; const millisecond = (moment.second - Math.trunc(moment.second)).toFixed(3); return millisecond.slice(2); }, 'Z': (moment) => { const offset = moment.offset; if (!offset) return ''; let hour = offset.hour; let sign = '+'; if (hour < 0) { sign = '-'; hour = -hour; } return sign + String(100 + hour).slice(1) + ':' + String(100 + offset.minute).slice(1); } }; } $.$mol_time_moment = $mol_time_moment; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $hyoo_crus_time_moment(time) { const stamp = Math.floor(time / 65536) * 1000; return new $mol_time_moment(stamp); } $.$hyoo_crus_time_moment = $hyoo_crus_time_moment; function $hyoo_crus_time_tick(time) { return time % 65536; } $.$hyoo_crus_time_tick = $hyoo_crus_time_tick; function $hyoo_crus_time_dump(time) { return $hyoo_crus_time_moment(time).toString('YYYY-MM-DD hh:mm:ss') + ' @' + $hyoo_crus_time_tick(time); } $.$hyoo_crus_time_dump = $hyoo_crus_time_dump; function $hyoo_crus_time_now() { return now || Math.floor(Date.now() / 1000) * 65536; } $.$hyoo_crus_time_now = $hyoo_crus_time_now; let now = 0; function $hyoo_crus_time_freeze(task) { if (now) return task(); now = $hyoo_crus_time_now(); try { return task(); } finally { now = 0; } } $.$hyoo_crus_time_freeze = $hyoo_crus_time_freeze; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $hyoo_crus_face_map extends Map { last_time = 0; total = 0; constructor(entries) { super(); if (entries) this.sync(entries); } sync(right) { if (right instanceof $hyoo_crus_face_map) this.total = right.total; for (const [peer, time] of right) this.time_max(peer, time); } time_max(peer, time) { if (this.last_time < time) this.last_time = time; let prev = this.get(peer) ?? 0; if (prev < time) this.set(peer, time); } tick() { return this.last_time = Math.max(this.last_time + 1, $hyoo_crus_time_now()); } last_moment() { return $hyoo_crus_time_moment(this.last_time); } [$mol_dev_format_head]() { return $mol_dev_format_span({}, $mol_dev_format_native(this), $mol_dev_format_shade(' ', $hyoo_crus_time_dump(this.last_time)), $mol_dev_format_shade(' #', this.total)); } } __decorate([ $mol_action ], $hyoo_crus_face_map.prototype, "tick", null); $.$hyoo_crus_face_map = $hyoo_crus_face_map; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_wire_dict extends Map { pub = new $mol_wire_pub; has(key) { this.pub.promote(); return super.has(key); } get(key) { this.pub.promote(); return super.get(key); } entries() { this.pub.promote(); return super.entries(); } keys() { this.pub.promote(); return super.keys(); } values() { this.pub.promote(); return super.values(); } forEach(task, self) { this.pub.promote(); super.forEach(task, self); } [Symbol.iterator]() { this.pub.promote(); return super[Symbol.iterator](); } get size() { this.pub.promote(); return super.size; } set(key, value) { if (super.get(key) === value) return this; super.set(key, value); this.pub?.emit(); return this; } delete(key) { const res = super.delete(key); if (res) this.pub.emit(); return res; } clear() { if (!super.size) return; super.clear(); this.pub.emit(); } item(key, next) { if (next === undefined) return this.get(key) ?? null; if (next === null) this.delete(key); else this.set(key, next); return next; } } $.$mol_wire_dict = $mol_wire_dict; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_guard_defined(value) { return value !== null && value !== undefined; } $.$mol_guard_defined = $mol_guard_defined; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $hyoo_crus_node extends $mol_object { static tag = 'vals'; land() { return null; } head() { return ''; } land_ref() { return this.land()?.ref() ?? this.$.$hyoo_crus_auth.current().lord(); } ref() { return $hyoo_crus_ref_resolve(this.land_ref(), $hyoo_crus_ref('___' + this.head())); } toJSON() { return this.ref().description; } cast(Node) { return this.land().Node(Node).Item(this.head()); } nodes(Node) { const land = this.land(); const map = { term: () => land.Node(Node || $hyoo_crus_atom_vary), solo: () => land.Node(Node || $hyoo_crus_atom_vary), vals: () => land.Node(Node || $hyoo_crus_list_vary), keys: () => land.Node(Node || $hyoo_crus_dict), }; return this.units().map(unit => map[unit.tag()]().Item(unit.self())); } units() { return this.units_of(''); } units_of(peer) { return this.land().sand_ordered({ head: this.head(), peer }).filter(unit => unit.tip() !== 'nil'); } filled() { return this.units().length > 0; } can_change() { return this.land().lord_rank(this.land().auth().lord()) >= $hyoo_crus_rank_tier.join; } last_change() { const land = this.land(); let last = 0; const visit = (sand) => { if (sand.time() > last) last = sand.time(); if (sand.tag() === 'term') return; land.Node($hyoo_crus_node).Item(sand.self()).units().forEach(visit); }; this.units().forEach(visit); return last ? $hyoo_crus_time_moment(last) : null; } author_peers() { const land = this.land(); const peers = new Set(); const visit = (sand) => { peers.add(sand.peer()); if (sand.tag() === 'term') return; land.Node($hyoo_crus_node).Item(sand.self()).units_of(null).forEach(visit); }; this.units_of(null).forEach(visit); return [...peers]; } author_lords() { const land = this.land(); return this.author_peers() .map(peer => land.pass.get(peer)?.lord()) .filter($mol_guard_defined); } ; [$mol_dev_format_head]() { return $mol_dev_format_span({}, $mol_dev_format_native(this), ' ', this.head()); } } __decorate([ $mol_memo.method ], $hyoo_crus_node.prototype, "ref", null); __decorate([ $mol_mem_key ], $hyoo_crus_node.prototype, "cast", null); __decorate([ $mol_mem_key ], $hyoo_crus_node.prototype, "nodes", null); __decorate([ $mol_mem_key ], $hyoo_crus_node.prototype, "units_of", null); __decorate([ $mol_mem ], $hyoo_crus_node.prototype, "last_change", null); __decorate([ $mol_mem ], $hyoo_crus_node.prototype, "author_peers", null); __decorate([ $mol_mem ], $hyoo_crus_node.prototype, "author_lords", null); $.$hyoo_crus_node = $hyoo_crus_node; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $hyoo_crus_fund extends $mol_object { item_make; constructor(item_make) { super(); this.item_make = item_make; } Item(head) { return this.item_make(head); } } __decorate([ $mol_mem_key ], $hyoo_crus_fund.prototype, "Item", null); $.$hyoo_crus_fund = $hyoo_crus_fund; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_graph { nodes = new Set(); edges_out = new Map(); edges_in = new Map(); link(from, to, edge) { this.link_out(from, to, edge); this.link_in(to, from, edge); } unlink(from, to) { this.edges_in.get(to)?.delete(from); this.edges_out.get(from)?.delete(to); } link_out(from, to, edge) { let pair = this.edges_out.get(from); if (!pair) { pair = new Map(); this.edges_out.set(from, pair); this.nodes.add(from); } pair.set(to, edge); this.nodes.add(to); } link_in(to, from, edge) { let pair = this.edges_in.get(to); if (!pair) { pair = new Map(); this.edges_in.set(to, pair); this.nodes.add(to); } pair.set(from, edge); this.nodes.add(to); } edge(from, to) { return this.edge_out(from, to) ?? this.edge_in(to, from); } edge_out(from, to) { return this.edges_out.get(from)?.get(to) ?? null; } edge_in(to, from) { return this.edges_in.get(to)?.get(from) ?? null; } acyclic(get_weight) { const checked = []; for (const start of this.nodes) { const path = []; const visit = (from) => { if (checked.includes(from)) return Number.MAX_SAFE_INTEGER; const index = path.lastIndexOf(from); if (index > -1) { const cycle = path.slice(index); return cycle.reduce((weight, node, index) => Math.min(weight, get_weight(this.edge_out(node, cycle[(index + 1) % cycle.length]))), Number.MAX_SAFE_INTEGER); } path.push(from); dive: try { const deps = this.edges_out.get(from); if (!deps) break dive; for (const [to, edge] of deps) { if (to === from) { this.unlink(from, to); continue; } const weight_out = get_weight(edge); const min = visit(to); if (weight_out > min) return min; if (weight_out === min) { this.unlink(from, to); if (path.length > 1) { const enter = path[path.length - 2]; this.link(enter, to, edge); } } } } finally { path.pop(); } checked.push(from); return Number.MAX_SAFE_INTEGER; }; visit(start); } } get sorted() { const sorted = new Set(); const visit = (node) => { if (sorted.has(node)) return; const deps = this.edges_out.get(node); if (deps) { for (const [dep] of deps) visit(dep); } sorted.add(node); }; for (const node of this.nodes) { visit(node); } return sorted; } get roots() { const roots = []; for (const node of this.nodes) { if (this.edges_in.get(node)?.size) continue; roots.push(node); } return roots; } nodes_depth(select) { const stat = new Map(); const visit = (node, depth = 0) => { if (stat.has(node)) stat.set(node, select(depth, stat.get(node))); else stat.set(node, depth); for (const kid of this.edges_out.get(node)?.keys() ?? []) visit(kid, depth + 1); }; for (const root of this.roots) visit(root); return stat; } depth_nodes(select) { const groups = []; for (const [node, depth] of this.nodes_depth(select).entries()) { if (groups[depth]) groups[depth].push(node); else groups[depth] = [node]; } return groups; } } $.$mol_graph = $mol_graph; })($ || ($ = {})); ; "use strict"; var $; (function ($) { let sponge = new Uint32Array(80); function $mol_crypto_hash(input) { const data = input instanceof Uint8Array ? input : new Uint8Array(input.buffer, input.byteOffset, input.byteLength); const bits = data.byteLength << 3; const kbits = bits >> 5; const kword = 0x80 << (24 - bits & 0b11111); const bytes = 16 + (bits + 64 >>> 9 << 4); const klens = bytes - 1; const words = new DataView(data.buffer, data.byteOffset, data.byteLength >> 2 << 2); let tail = 0; for (let i = words.byteLength; i < data.length; ++i) { tail |= data[i] << ((3 - i & 0b11) << 3); } const hash = new Int32Array([1732584193, -271733879, -1732584194, 271733878, -1009589776]); for (let i = 0; i < bytes; i += 16) { let h0 = hash[0]; let h1 = hash[1]; let h2 = hash[2]; let h3 = hash[3]; let h4 = hash[4]; for (let j = 0; j < 16; ++j) { const k = i + j; if (k === klens) { sponge[j] = bits; } else { const pos = k << 2; let word = pos === words.byteLength ? tail : pos > words.byteLength ? 0 : words.getInt32(pos, false); if (k === kbits) word |= kword; sponge[j] = word; } const next = ((h1 & h2 | ~h1 & h3) + 1518500249 + h4 + (sponge[j] >>> 0) + ((h0 << 5) | (h0 >>> 27))) | 0; h4 = h3; h3 = h2; h2 = (h1 << 30) | (h1 >>> 2); h1 = h0; h0 = next; } for (let j = 16; j < 20; ++j) { const shuffle = sponge[j - 3] ^ sponge[j - 8] ^ sponge[j - 14] ^ sponge[j - 16]; sponge[j] = shuffle << 1 | shuffle >>> 31; const next = ((h1 & h2 | ~h1 & h3) + 1518500249 + h4 + (sponge[j] >>> 0) + ((h0 << 5) | (h0 >>> 27))) | 0; h4 = h3; h3 = h2; h2 = (h1 << 30) | (h1 >>> 2); h1 = h0; h0 = next; } for (let j = 20; j < 40; ++j) { const shuffle = sponge[j - 3] ^ sponge[j - 8] ^ sponge[j - 14] ^ sponge[j - 16]; sponge[j] = shuffle << 1 | shuffle >>> 31; const next = ((h1 ^ h2 ^ h3) + 1859775393 + h4 + (sponge[j] >>> 0) + ((h0 << 5) | (h0 >>> 27))) | 0; h4 = h3; h3 = h2; h2 = (h1 << 30) | (h1 >>> 2); h1 = h0; h0 = next; } for (let j = 40; j < 60; ++j) { const shuffle = sponge[j - 3] ^ sponge[j - 8] ^ sponge[j - 14] ^ sponge[j - 16]; sponge[j] = shuffle << 1 | shuffle >>> 31; const next = ((h1 & h2 | h1 & h3 | h2 & h3) - 1894007588 + h4 + (sponge[j] >>> 0) + ((h0 << 5) | (h0 >>> 27))) | 0; h4 = h3; h3 = h2; h2 = (h1 << 30) | (h1 >>> 2); h1 = h0; h0 = next; } for (let j = 60; j < 80; ++j) { const shuffle = sponge[j - 3] ^ sponge[j - 8] ^ sponge[j - 14] ^ sponge[j - 16]; sponge[j] = shuffle << 1 | shuffle >>> 31; const next = ((h1 ^ h2 ^ h3) - 899497514 + h4 + (sponge[j] >>> 0) + ((h0 << 5) | (h0 >>> 27))) | 0; h4 = h3; h3 = h2; h2 = (h1 << 30) | (h1 >>> 2); h1 = h0; h0 = next; } hash[0] += h0; hash[1] += h1; hash[2] += h2; hash[3] += h3; hash[4] += h4; } for (let i = 0; i < 20; ++i) { const word = hash[i]; hash[i] = word << 24 | word << 8 & 0xFF0000 | word >>> 8 & 0xFF00 | word >>> 24 & 0xFF; } return new Uint8Array(hash.buffer); } $.$mol_crypto_hash = $mol_crypto_hash; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $hyoo_crus_pack extends $mol_buffer { toBlob() { return new Blob([this], { type: 'application/vnd.hyoo_crus_pack' }); } parts(land = null) { const lands = {}; if (land) lands[land] = { faces: new $hyoo_crus_face_map, units: [] }; let total = 0; const rocks = []; const buf = this.asArray(); for (let offset = 0; offset < this.byteLength;) { const kind = this.uint8(offset); if (!kind) break; if (kind % 2) { switch (kind) { case $hyoo_crus_part.land: { const faces = new $hyoo_crus_face_map; faces.total = this.uint32(offset) >> 8; offset += 4; land = $hyoo_crus_ref_decode(new Uint8Array(buf.buffer, buf.byteOffset + offset, 18)); offset += 20; lands[land] = { faces, units: [] }; continue; } case $hyoo_crus_part.face: { if (!land) $mol_fail(new Error('Land is undefined')); const count = this.uint32(offset) >> 8; offset += 4; const faces = lands[land].faces; for (let i = 0; i < count; ++i) { const peer = $mol_base64_ae_encode(new Uint8Array(buf.buffer, buf.byteOffset + offset, 6)); const time = this.uint48(offset + 6); faces.time_max(peer, time); offset += 12; } offset = Math.ceil(offset / 8) * 8; continue; } case $hyoo_crus_part.pass: { if (!land) $mol_fail(new Error('Land is undefined')); const unit = new $hyoo_crus_pass(buf.slice(offset, offset += $hyoo_crus_unit.size).buffer); lands[land].units ||= []; lands[land].units.push(unit); continue; } case $hyoo_crus_part.gift: { if (!land) $mol_fail(new Error('Land is undefined')); const unit = new $hyoo_crus_gift(buf.slice(offset, offset += $hyoo_crus_unit.size).buffer); lands[land].units ||= []; lands[land].units.push(unit); continue; } case $hyoo_crus_part.rock: { const size = this.uint32(offset) >> 8; if (size === 0) { const hash = buf.slice(offset + 4, offset + 4 + 24); rocks.push([hash, null]); offset += 4 + 24; } else { const rock = buf.slice(offset + 4, offset + 4 + size); const hash = $mol_crypto_hash(rock); rocks.push([hash, rock]); offset += Math.ceil(size / 8 + .5) * 8; } continue; } case $hyoo_crus_part.root: case $hyoo_crus_part.buck: { offset += 128; continue; } default: $mol_fail(new Error(`Unknown CRUS Pack Part (${kind.toString(2)}) at (${offset.toString(16)})`)); } } else { if (!land) $mol_fail(new Error('Land is undefined')); const unit = $hyoo_crus_sand.from(buf.slice(offset, offset += $hyoo_crus_unit.size)); lands[land].units ||= []; lands[land].units.push(unit); continue; } } return { lands, rocks }; } static make({ lands, rocks }) { let size = 0; for (const land of Reflect.ownKeys(lands)) { size += 24; size += Math.ceil(lands[land].faces.size * 12 / 8 + .5) * 8; size += lands[land].units.length * $hyoo_crus_unit.size; } for (const [hash, rock] of rocks) { size += rock ? Math.ceil(rock.length / 8 + .5) * 8 : 24; } if (size === 0) return null; const buff = new Uint8Array(size); const pack = new $hyoo_crus_pack(buff.buffer); let offset = 0; for (const land of Reflect.ownKeys(lands)) { const faces = lands[land].faces; pack.uint32(offset, $hyoo_crus_part.land | (faces.total << 8)); buff.set($hyoo_crus_ref_encode(land), offset + 4); offset += 24; pack.uint32(offset, $hyoo_crus_part.face | (faces.size << 8)); offset += 4; for (const [peer, time] of faces) { buff.set($mol_base64_ae_decode(peer), offset); pack.uint48(offset + 6, time); offset += 12; } offset = Math.ceil(offset / 8) * 8; for (const unit of lands[land].units) { buff.set(unit.asArray(), offset); offset += unit.byteLength; } } for (const [hash, rock] of rocks) { const len = rock?.length ?? 0; pack.uint32(offset, $hyoo_crus_part.rock | (len << 8)); if (rock) buff.set(rock, offset + 4); else buff.set(hash, offset + 4); offset += rock ? Math.ceil(len / 8 + .5) * 8 : 24; } return pack; } } $.$hyoo_crus_pack = $hyoo_crus_pack; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_time_interval extends $mol_time_base { constructor(config) { super(); if (typeof config === 'string') { var chunks = config.split('/'); if (chunks[0]) { if (chunks[0][0].toUpperCase() === 'P') { this._duration = new $mol_time_duration(chunks[0]); } else { this._start = new $mol_time_moment(chunks[0]); } } else { this._start = new $mol_time_moment(); } if (chunks[1]) { if (chunks[1][0].toUpperCase() === 'P') { this._duration = new $mol_time_duration(chunks[1]); } else { this._end = new $mol_time_moment(chunks[1]); } } else { this._end = new $mol_time_moment(); } return; } if (config.start !== undefined) this._start = new $mol_time_moment(config.start); if (config.end !== undefined) this._end = new $mol_time_moment(config.end); if (config.duration !== undefined) this._duration = new $mol_time_duration(config.duration); } _start; get start() { if (this._start) return this._start; return this._start = this._end.shift(this._duration.mult(-1)); } _end; get end() { if (this._end) return this._end; return this._end = this._start.shift(this._duration); } _duration; get duration() { if (this._duration) return this._duration; return this._duration = new $mol_time_duration(this._end.valueOf() - this._start.valueOf()); } toJSON() { return this.toString(); } toString() { return (this._start || this._duration || '').toString() + '/' + (this._end || this._duration || '').toString(); } [Symbol.toPrimitive](mode) { return this.toString(); } } $.$mol_time_interval = $mol_time_interval; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_span extends $mol_object2 { uri; source; row; col; length; constructor(uri, source, row, col, length) { super(); this.uri = uri; this.source = source; this.row = row; this.col = col; this.length = length; this[Symbol.toStringTag] = this.uri + ('#' + this.row + ':' + this.col + '/' + this.length); } static unknown = $mol_span.begin('?'); static begin(uri, source = '') { return new $mol_span(uri, source, 1, 1, 0); } static end(uri, source) { return new $mol_span(uri, source, 1, source.length + 1, 0); } static entire(uri, source) { return new $mol_span(uri, source, 1, 1, source.length); } toString() { return this[Symbol.toStringTag]; } toJSON() { return { uri: this.uri, row: this.row, col: this.col, length: this.length }; } error(message, Class = Error) { return new Class(`${message} (${this})`); } span(row, col, length) { return new $mol_span(this.uri, this.source, row, col, length); } after(length = 0) { return new $mol_span(this.uri, this.source, this.row, this.col + this.length, length); } slice(begin, end = -1) { let len = this.length; if (begin < 0) begin += len; if (end < 0) end += len; if (begin < 0 || begin > len) this.$.$mol_fail(this.error(`Begin value '${begin}' out of range`, RangeError)); if (end < 0 || end > len) this.$.$mol_fail(this.error(`End value '${end}' out of range`, RangeError)); if (end < begin) this.$.$mol_fail(this.error(`End value '${end}' can't be less than begin value`, RangeError)); return this.span(this.row, this.col + begin, end - begin); } } $.$mol_span = $mol_span; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_error_syntax extends SyntaxError { reason; line; span; constructor(reason, line, span) { super(`${reason}\n${span}\n${line.substring(0, span.col - 1).replace(/\S/g, ' ')}${''.padEnd(span.length, '!')}\n${line}`); this.reason = reason; this.line = line; this.span = span; } } $.$mol_error_syntax = $mol_error_syntax; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_tree2_from_string(str, uri = '?') { const span = $mol_span.entire(uri, str); var root = $mol_tree2.list([], span); var stack = [root]; var pos = 0, row = 0, min_indent = 0; while (str.length > pos) { var indent = 0; var line_start = pos; row++; while (str.length > pos && str[pos] == '\t') { indent++; pos++; } if (!root.kids.length) { min_indent = indent; } indent -= min_indent; if (indent < 0 || indent >= stack.length) { const sp = span.span(row, 1, pos - line_start); while (str.length > pos && str[pos] != '\n') { pos++; } if (indent < 0) { if (str.length > pos) { this.$mol_fail(new this.$mol_error_syntax(`Too few tabs`, str.substring(line_start, pos), sp)); } } else { this.$mol_fail(new this.$mol_error_syntax(`Too many tabs`, str.substring(line_start, pos), sp)); } } stack.length = indent + 1; var parent = stack[indent]; while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') { var error_start = pos; while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) { pos++; } if (pos > error_start) { let line_end = str.indexOf('\n', pos); if (line_end === -1) line_end = str.length; const sp = span.span(row, error_start - line_start + 1, pos - error_start); this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp)); } var type_start = pos; while (str.length > pos && str[pos] != '\\' && str[pos] != ' ' && str[pos] != '\t' && str[pos] != '\n') { pos++; } if (pos > type_start) { let next = new $mol_tree2(str.slice(type_start, pos), '', [], span.span(row, type_start - line_start + 1, pos - type_start)); const parent_kids = parent.kids; parent_kids.push(next); parent = next; } if (str.length > pos && str[pos] == ' ') { pos++; } } if (str.length > pos && str[pos] == '\\') { var data_start = pos; while (str.length > pos && str[pos] != '\n') { pos++; } let next = new $mol_tree2('', str.slice(data_start + 1, pos), [], span.span(row, data_start - line_start + 2, pos - data_start - 1)); const parent_kids = parent.kids; parent_kids.push(next); parent = next; } if (str.length === pos && stack.length > 0) { const sp = span.span(row, pos - line_start + 1, 1); this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp)); } stack.push(parent); pos++; } return root; } $.$mol_tree2_from_string = $mol_tree2_from_string; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_tree2_to_string(tree) { let output = []; function dump(tree, prefix = '') { if (tree.type.length) { if (!prefix.length) { prefix = "\t"; } output.push(tree.type); if (tree.kids.length == 1) { output.push(' '); dump(tree.kids[0], prefix); return; } output.push("\n"); } else if (tree.value.length || prefix.length) { output.push("\\" + tree.value + "\n"); } for (const kid of tree.kids) { output.push(prefix); dump(kid, prefix + "\t"); } } dump(tree); return output.join(''); } $.$mol_tree2_to_string = $mol_tree2_to_string; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_tree2 extends Object { type; value; kids; span; constructor(type, value, kids, span) { super(); this.type = type; this.value = value; this.kids = kids; this.span = span; this[Symbol.toStringTag] = type || '\\' + value; } static list(kids, span = $mol_span.unknown) { return new $mol_tree2('', '', kids, span); } list(kids) { return $mol_tree2.list(kids, this.span); } static data(value, kids = [], span = $mol_span.unknown) { const chunks = value.split('\n'); if (chunks.length > 1) { let kid_span = span.span(span.row, span.col, 0); const data = chunks.map(chunk => { kid_span = kid_span.after(chunk.length); return new $mol_tree2('', chunk, [], kid_span); }); kids = [...data, ...kids]; value = ''; } return new $mol_tree2('', value, kids, span); } data(value, kids = []) { return $mol_tree2.data(value, kids, this.span); } static struct(type, kids = [], span = $mol_span.unknown) { if (/[ \n\t\\]/.test(type)) { $$.$mol_fail(span.error(`Wrong type ${JSON.stringify(type)}`)); } return new $mol_tree2(type, '', kids, span); } struct(type, kids = []) { return $mol_tree2.struct(type, kids, this.span); } clone(kids, span = this.span) { return new $mol_tree2(this.type, this.value, kids, span); } text() { var values = []; for (var kid of this.kids) { if (kid.type) continue; values.push(kid.value); } return this.value + values.join('\n'); } static fromString(str, uri = 'unknown') { return $$.$mol_tree2_from_string(str, uri); } toString() { return $$.$mol_tree2_to_string(this); } insert(value, ...path) { return this.update($mol_maybe(value), ...path)[0]; } update(value, ...path) { if (path.length === 0) return value; const type = path[0]; if (typeof type === 'string') { let replaced = false; const sub = this.kids.flatMap((item, index) => { if (item.type !== type) return item; replaced = true; return item.update(value, ...path.slice(1)); }).filter(Boolean); if (!replaced && value) { sub.push(...this.struct(type, []).update(value, ...path.slice(1))); } return [this.clone(sub)]; } else if (typeof type === 'number') { const ins = (this.kids[type] || this.list([])) .update(value, ...path.slice(1)); return [this.clone([ ...this.kids.slice(0, type), ...ins, ...this.kids.slice(type + 1), ])]; } else { const kids = ((this.kids.length === 0) ? [this.list([])] : this.kids) .flatMap(item => item.update(value, ...path.slice(1))); return [this.clone(kids)]; } } select(...path) { let next = [this]; for (const type of path) { if (!next.length) break; const prev = next; next = []; for (var item of prev) { switch (typeof (type)) { case 'string': for (var child of item.kids) { if (child.type == type) { next.push(child); } } break; case 'number': if (type < item.kids.length) next.push(item.kids[type]); break; default: next.push(...item.kids); } } } return this.list(next); } filter(path, value) { const sub = this.kids.filter(item => { var found = item.select(...path); if (value === undefined) { return Boolean(found.kids.length); } else { return found.kids.some(child => child.value == value); } }); return this.clone(sub); } hack_self(belt, context = {}) { let handle = belt[this.type] || belt['']; if (!handle || handle === Object.prototype[this.type]) { handle = (input, belt, context) => [ input.clone(input.hack(belt, context), context.span) ]; } try { return handle(this, belt, context); } catch (error) { error.message += `\n${this.clone([])}${this.span}`; $mol_fail_hidden(error); } } hack(belt, context = {}) { return [].concat(...this.kids.map(child => child.hack_self(belt, context))); } error(message, Class = Error) { return this.span.error(`${message}\n${this.clone([])}`, Class); } } $.$mol_tree2 = $mol_tree2; class $mol_tree2_empty extends $mol_tree2 { constructor() { super('', '', [], $mol_span.unknown); } } $.$mol_tree2_empty = $mol_tree2_empty; })($ || ($ = {})); ; "use strict"; var $; (function ($) { $.$hyoo_crus_vary_mapping = { nil: null, bin: Uint8Array, bool: Boolean, int: BigInt, real: Number, ints: BigInt64Array, reals: Float64Array, ref: Symbol, str: String, time: $mol_time_moment, dur: $mol_time_duration, range: $mol_time_interval, json: Object, jsan: Array, dom: $mol_dom_context.Element, tree: $mol_tree2, }; let $hyoo_crus_vary_tip; (function ($hyoo_crus_vary_tip) { $hyoo_crus_vary_tip[$hyoo_crus_vary_tip["nil"] = 1] = "nil"; $hyoo_crus_vary_tip[$hyoo_crus_vary_tip["bin"] = 2] = "bin"; $hyoo_crus_vary_tip[$hyoo_crus_vary_tip["bool"] = 3] = "bool"; $hyoo_crus_vary_tip[$hyoo_crus_vary_tip["int"] = 4] = "int"; $hyoo_crus_vary_tip[$hyoo_crus_vary_tip["real"] = 5] = "real"; $hyoo_crus_vary_tip[$hyoo_crus_vary_tip["ints"] = 6] = "ints"; $hyoo_crus_vary_tip[$hyoo_crus_vary_tip["reals"] = 7] = "reals"; $hyoo_crus_vary_tip[$hyoo_crus_vary_tip["ref"] = 8] = "ref"; $hyoo_crus_vary_tip[$hyoo_crus_vary_tip["str"] = 16] = "str"; $hyoo_crus_vary_tip[$hyoo_crus_vary_tip["time"] = 17] = "time"; $hyoo_crus_vary_tip[$hyoo_crus_vary_tip["dur"] = 18] = "dur"; $hyoo_crus_vary_tip[$hyoo_crus_vary_tip["range"] = 19] = "range"; $hyoo_crus_vary_tip[$hyoo_crus_vary_tip["json"] = 20] = "json"; $hyoo_crus_vary_tip[$hyoo_crus_vary_tip["jsan"] = 21] = "jsan"; $hyoo_crus_vary_tip[$hyoo_crus_vary_tip["dom"] = 22] = "dom"; $hyoo_crus_vary_tip[$hyoo_crus_vary_tip["tree"] = 23] = "tree"; })($hyoo_crus_vary_tip = $.$hyoo_crus_vary_tip || ($.$hyoo_crus_vary_tip = {})); function $hyoo_crus_vary_switch(vary, ways) { if (vary === null) return ways.nil(vary); switch (typeof vary) { case "boolean": return ways.bool(vary); case "bigint": return ways.int(vary); case "number": return ways.real(vary); case "string": return ways.str(vary); case 'symbol': return ways.ref(vary); } switch (Reflect.getPrototypeOf(vary)) { case Object.prototype: return ways.json(vary); case Array.prototype: return ways.jsan(vary); case Uint8Array.prototype: return ways.bin(vary); case BigInt64Array.prototype: return ways.ints(vary); case Float64Array.prototype: return ways.reals(vary); case $mol_time_moment.prototype: return ways.time(vary); case $mol_time_duration.prototype: return ways.dur(vary); case $mol_time_interval.prototype: return ways.range(vary); case $mol_tree2.prototype: return ways.tree(vary); } if (vary instanceof $mol_dom_context.Element) return ways.dom(vary); return $mol_fail(new TypeError(`Unsupported vary type`)); } $.$hyoo_crus_vary_switch = $hyoo_crus_vary_switch; function $hyoo_crus_vary_encode(vary) { return $hyoo_crus_vary_switch(vary, { nil: vary => ({ tip: 'nil', bin: new Uint8Array([]) }), bin: vary => ({ tip: 'bin', bin: vary }), bool: vary => ({ tip: 'bool', bin: new Uint8Array([Number(vary)]) }), int: vary => ({ tip: 'int', bin: new Uint8Array(new BigInt64Array([vary]).buffer) }), ints: vary => ({ tip: 'ints', bin: new Uint8Array(vary.buffer, vary.byteLength, vary.byteLength) }), real: vary => ({ tip: 'real', bin: new Uint8Array(new Float64Array([vary]).buffer) }), reals: vary => ({ tip: 'reals', bin: new Uint8Array(vary.buffer, vary.byteLength, vary.byteLength) }), ref: vary => ({ tip: 'ref', bin: $hyoo_crus_ref_encode(vary) }), str: vary => ({ tip: 'str', bin: $mol_charset_encode(vary) }), time: vary => ({ tip: 'time', bin: $mol_charset_encode(String(vary)) }), dur: vary => ({ tip: 'dur', bin: $mol_charset_encode(String(vary)) }), range: vary => ({ tip: 'range', bin: $mol_charset_encode(String(vary)) }), json: vary => ({ tip: 'json', bin: $mol_charset_encode(JSON.stringify(vary)) }), jsan: vary => ({ tip: 'jsan', bin: $mol_charset_encode(JSON.stringify(vary)) }), dom: vary => ({ tip: 'dom', bin: $mol_charset_encode($mol_dom_serialize(vary)) }), tree: vary => ({ tip: 'tree', bin: $mol_charset_encode(String(vary)) }), }); } $.$hyoo_crus_vary_encode = $hyoo_crus_vary_encode; function $hyoo_crus_vary_decode({ tip, bin }) { switch (tip) { case 'nil': return null; case 'bin': return bin; case 'bool': return Boolean(bin[0]); case 'int': return new BigInt64Array(bin.buffer, bin.byteOffset, bin.byteLength / 8)[0]; case 'ints': return new BigInt64Array(bin.buffer, bin.byteOffset, bin.byteLength / 8); case 'real': return new Float64Array(bin.buffer, bin.byteOffset, bin.byteLength / 8)[0]; case 'reals': return new Float64Array(bin.buffer, bin.byteOffset, bin.byteLength / 8); case 'ref': return $hyoo_crus_ref_decode(bin); case 'str': return $mol_charset_decode(bin); case 'time': return new $mol_time_moment($mol_charset_decode(bin)); case 'dur': return new $mol_time_duration($mol_charset_decode(bin)); case 'range': return new $mol_time_interval($mol_charset_decode(bin)); case 'json': return JSON.parse($mol_charset_decode(bin)); case 'jsan': return JSON.parse($mol_charset_decode(bin)); case 'dom': return $mol_dom_parse($mol_charset_decode(bin)).documentElement; case 'tree': return $$.$mol_tree2_from_string($mol_charset_decode(bin)); } } $.$hyoo_crus_vary_decode = $hyoo_crus_vary_decode; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_tree2_bin_to_bytes(tree) { return Uint8Array.from(tree.kids, kid => parseInt(kid.value, 16)); } $.$mol_tree2_bin_to_bytes = $mol_tree2_bin_to_bytes; function $mol_tree2_bin_from_bytes(bytes, span = $mol_span.unknown) { return $mol_tree2.list(Array.from(bytes, code => { return $mol_tree2.data(code.toString(16).padStart(2, '0'), [], span); }), span); } $.$mol_tree2_bin_from_bytes = $mol_tree2_bin_from_bytes; function $mol_tree2_bin_from_string(str, span = $mol_span.unknown) { return $mol_tree2_bin_from_bytes([...new TextEncoder().encode(str)], span); } $.$mol_tree2_bin_from_string = $mol_tree2_bin_from_string; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_tree2_from_json(json, span = $mol_span.unknown) { if (typeof json === 'boolean' || typeof json === 'number' || json === null) { return new $mol_tree2(String(json), '', [], span); } if (typeof json === 'string') { return $mol_tree2.data(json, [], span); } if (typeof json.toJSON === 'function') { return $mol_tree2_from_json(json.toJSON()); } if (Array.isArray(json)) { const sub = json.map(json => $mol_tree2_from_json(json, span)); return new $mol_tree2('/', '', sub, span); } if (ArrayBuffer.isView(json)) { const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength); return $mol_tree2.data(String.fromCharCode(...buf), [], span); } if (json instanceof Date) { return new $mol_tree2('', json.toISOString(), [], span); } if (json.toString !== Object.prototype.toString) { return $mol_tree2.data(json.toString(), [], span); } if (json instanceof Error) { const { name, message, stack } = json; json = { ...json, name, message, stack }; } const sub = []; for (var key in json) { const val = json[key]; if (val === undefined) continue; const subsub = $mol_tree2_from_json(val, span); if (/^[^\n\t\\ ]+$/.test(key)) { sub.push(new $mol_tree2(key, '', [subsub], span)); } else { sub.push($mol_tree2.data(key, [subsub], span)); } } return new $mol_tree2('*', '', sub, span); } $.$mol_tree2_from_json = $mol_tree2_from_json; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_tree2_xml_from_dom(dom) { switch (dom.nodeType) { case dom.DOCUMENT_NODE: { let kids = []; for (const kid of dom.childNodes) { kids.push($mol_tree2_xml_from_dom(kid)); } return $mol_tree2.list(kids); } case dom.PROCESSING_INSTRUCTION_NODE: { return $mol_tree2.struct('?', [ $mol_tree2.struct(dom.nodeName, dom.nodeValue.split(' ').map(chunk => { const [, name, value] = /^(.*?)(?:="(.*?)")?$/.exec(chunk); const kids = value ? [$mol_tree2.data(value)] : []; return $mol_tree2.struct(name, kids); })) ]); } case dom.DOCUMENT_TYPE_NODE: { const dom2 = dom; return $mol_tree2.struct('!', [ $mol_tree2.struct('DOCTYPE', [ $mol_tree2.struct(dom2.name) ]) ]); } case dom.ELEMENT_NODE: { let kids = []; for (const attr of dom.attributes) { kids.push($mol_tree2.struct('@', [ $mol_tree2.struct(attr.nodeName, [ $mol_tree2.data(attr.nodeValue) ]) ])); } for (const kid of dom.childNodes) { const k = $mol_tree2_xml_from_dom(kid); if (k.type || k.value) kids.push(k); } return $mol_tree2.struct(dom.nodeName, kids); } case dom.COMMENT_NODE: { return $mol_tree2.struct('--', [ $mol_tree2.data(dom.nodeValue) ]); } case dom.TEXT_NODE: { if (!dom.nodeValue.trim()) return $mol_tree2.list([]); return $mol_tree2.data(dom.nodeValue.replace(/\s+/g, ' ')); } } return $mol_fail(new Error(`Unsupported node ${dom.nodeName}`)); } $.$mol_tree2_xml_from_dom = $mol_tree2_xml_from_dom; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $hyoo_crus_vary_cast_bin(vary) { return vary === null || vary === '' ? null : $hyoo_crus_vary_encode(vary).bin; } $.$hyoo_crus_vary_cast_bin = $hyoo_crus_vary_cast_bin; function $hyoo_crus_vary_cast_bool(vary) { return $hyoo_crus_vary_switch(vary, { nil: vary => null, bin: vary => Boolean(vary.length), bool: vary => vary, int: vary => Boolean(vary), real: vary => Boolean(vary), ints: vary => Boolean(vary.length), reals: vary => Boolean(vary.length), ref: vary => Boolean(vary.description), str: vary => Boolean(vary), time: vary => Boolean(vary.valueOf()), dur: vary => Boolean(vary.valueOf()), range: vary => Boolean(vary.duration.valueOf()), json: vary => Boolean(Reflect.ownKeys(vary).length), jsan: vary => Boolean(vary.length), dom: vary => Boolean(vary.attributes.length + vary.childNodes.length), tree: vary => Boolean(vary.value || vary.kids.length), }); } $.$hyoo_crus_vary_cast_bool = $hyoo_crus_vary_cast_bool; function $hyoo_crus_vary_cast_int(vary) { return $hyoo_crus_vary_switch(vary, { nil: vary => null, bin: vary => BigInt(vary.length), bool: vary => BigInt(vary), int: vary => vary, real: vary => Number.isFinite(vary) ? BigInt(Math.trunc(vary)) : null, ints: vary => BigInt(vary.length), reals: vary => BigInt(vary.length), ref: vary => null, str: vary => { try { return vary ? BigInt(vary) : null; } catch { return null; } }, time: vary => BigInt(vary.valueOf()), dur: vary => BigInt(vary.valueOf()), range: vary => BigInt(vary.duration.valueOf()), json: vary => BigInt(Reflect.ownKeys(vary).length), jsan: vary => BigInt(vary.length), dom: vary => BigInt(vary.attributes.length + vary.childNodes.length), tree: vary => { try { return BigInt(vary.value); } catch { return BigInt(vary.kids.length); } }, }); } $.$hyoo_crus_vary_cast_int = $hyoo_crus_vary_cast_int; function $hyoo_crus_vary_cast_real(vary) { return $hyoo_crus_vary_switch(vary, { nil: vary => null, bin: vary => vary.length, bool: vary => Number(vary), int: vary => Number(vary), real: vary => vary, ints: vary => vary.length, reals: vary => vary.length, ref: vary => null, str: vary => vary ? Number(vary) : null, time: vary => vary.valueOf(), dur: vary => vary.valueOf(), range: vary => vary.duration.valueOf(), json: vary => Reflect.ownKeys(vary).length, jsan: vary => vary.length, dom: vary => Number(vary.attributes.length + vary.childNodes.length), tree: vary => Number(vary.value || vary.kids.length), }); } $.$hyoo_crus_vary_cast_real = $hyoo_crus_vary_cast_real; function $hyoo_crus_vary_cast_ints(vary) { return $hyoo_crus_vary_switch(vary, { nil: vary => null, bin: vary => new BigInt64Array([...vary].map(BigInt)), bool: vary => vary ? new BigInt64Array([1n]) : null, int: vary => new BigInt64Array([vary]), real: vary => Number.isFinite(vary) ? new BigInt64Array([BigInt(vary)]) : null, ints: vary => vary, reals: vary => new BigInt64Array([...vary].map(BigInt)), ref: vary => null, str: vary => { if (!vary) return null; return new BigInt64Array(vary.split(',').map(v => BigInt(v) || 0n)); }, time: vary => new BigInt64Array([BigInt(vary.valueOf())]), dur: vary => new BigInt64Array([BigInt(vary.valueOf())]), range: vary => null, json: vary => null, jsan: vary => null, dom: vary => null, tree: vary => null, }); } $.$hyoo_crus_vary_cast_ints = $hyoo_crus_vary_cast_ints; function $hyoo_crus_vary_cast_reals(vary) { return $hyoo_crus_vary_switch(vary, { nil: vary => null, bin: vary => new Float64Array([...vary]), bool: vary => vary ? new Float64Array([1]) : null, int: vary => new Float64Array([Number(vary)]), real: vary => (vary && Number.isFinite(vary)) ? new Float64Array([vary]) : null, ints: vary => new Float64Array([...vary].map(Number)), reals: vary => vary, ref: vary => null, str: vary => { if (!vary) return null; return new Float64Array(vary.split(',').map(v => Number(v) || 0)); }, time: vary => new Float64Array([vary.valueOf()]), dur: vary => new Float64Array([vary.valueOf()]), range: vary => null, json: vary => null, jsan: vary => null, dom: vary => null, tree: vary => null, }); } $.$hyoo_crus_vary_cast_reals = $hyoo_crus_vary_cast_reals; function $hyoo_crus_vary_cast_ref(vary) { return $hyoo_crus_vary_switch(vary, { nil: vary => null, bin: vary => (!vary.length || vary.length % 6) ? null : $hyoo_crus_ref_decode(vary), bool: vary => null, int: vary => null, real: vary => null, ints: vary => null, reals: vary => null, ref: vary => vary, str: vary => { try { return $hyoo_crus_ref(vary); } catch { return null; } }, time: vary => null, dur: vary => null, range: vary => null, json: vary => null, jsan: vary => null, dom: vary => null, tree: vary => { try { return $hyoo_crus_ref(vary.type); } catch { return null; } }, }); } $.$hyoo_crus_vary_cast_ref = $hyoo_crus_vary_cast_ref; function $hyoo_crus_vary_cast_str(vary) { return $hyoo_crus_vary_switch(vary, { nil: vary => null, bin: vary => [...vary].map(n => n.toString(16).padStart(2, '0')).join(''), bool: vary => String(vary), int: vary => String(vary), real: vary => String(vary), ints: vary => vary.join(','), reals: vary => vary.join(','), ref: vary => vary.description, str: vary => vary, time: vary => String(vary), dur: vary => String(vary), range: vary => String(vary), json: vary => JSON.stringify(vary), jsan: vary => JSON.stringify(vary), dom: vary => $mol_dom_serialize(vary), tree: vary => String(vary), }); } $.$hyoo_crus_vary_cast_str = $hyoo_crus_vary_cast_str; function $hyoo_crus_vary_cast_time(vary) { return $hyoo_crus_vary_switch(vary, { nil: vary => null, bin: vary => null, bool: vary => null, int: vary => new $mol_time_moment(Number(vary & 0xffffffffffffn)), real: vary => { try { return new $mol_time_moment(vary); } catch { return null; } }, ints: vary => null, reals: vary => null, ref: vary => null, str: vary => { try { return vary ? new $mol_time_moment(vary) : null; } catch { return null; } }, time: vary => vary, dur: vary => null, range: vary => null, json: vary => { try { return new $mol_time_moment(vary); } catch { return null; } }, jsan: vary => null, dom: vary => null, tree: vary => null, }); } $.$hyoo_crus_vary_cast_time = $hyoo_crus_vary_cast_time; function $hyoo_crus_vary_cast_dur(vary) { return $hyoo_crus_vary_switch(vary, { nil: vary => null, bin: vary => null, bool: vary => null, int: vary => new $mol_time_duration(Number(vary & 0xffffffffffffn)), real: vary => { try { return new $mol_time_duration(vary); } catch { return null; } }, ints: vary => null, reals: vary => null, ref: vary => null, str: vary => { try { return new $mol_time_duration(vary); } catch { return null; } }, time: vary => null, dur: vary => vary, range: vary => null, json: vary => new $mol_time_duration(vary), jsan: vary => null, dom: vary => null, tree: vary => null, }); } $.$hyoo_crus_vary_cast_dur = $hyoo_crus_vary_cast_dur; function $hyoo_crus_vary_cast_range(vary) { return $hyoo_crus_vary_switch(vary, { nil: vary => null, bin: vary => null, bool: vary => null, int: vary => null, real: vary => null, ints: vary => null, reals: vary => null, ref: vary => null, str: vary => { try { return vary ? new $mol_time_interval(vary) : null; } catch { return null; } }, time: vary => new $mol_time_interval({ start: vary, duration: 0 }), dur: vary => null, range: vary => vary, json: vary => { try { return new $mol_time_interval(vary); } catch { return null; } }, jsan: vary => null, dom: vary => null, tree: vary => null, }); } $.$hyoo_crus_vary_cast_range = $hyoo_crus_vary_cast_range; function $hyoo_crus_vary_cast_json(vary) { return $hyoo_crus_vary_switch(vary, { nil: vary => null, bin: vary => null, bool: vary => null, int: vary => null, real: vary => null, ints: vary => null, reals: vary => null, ref: vary => null, str: vary => { if (!vary) return null; try { const res = JSON.parse(vary); if (typeof res === 'object') return res; return null; } catch { return null; } }, time: vary => ({ ...vary }), dur: vary => ({ ...vary }), range: vary => ({ ...vary }), json: vary => vary, jsan: vary => Object(vary[0]), dom: vary => null, tree: vary => null, }); } $.$hyoo_crus_vary_cast_json = $hyoo_crus_vary_cast_json; function $hyoo_crus_vary_cast_jsan(vary) { return $hyoo_crus_vary_switch(vary, { nil: vary => null, bin: vary => [...vary], bool: vary => [vary], int: vary => [vary.toString()], real: vary => Number.isFinite(vary) ? [vary] : null, ints: vary => [...vary].map(v => Number(v)), reals: vary => [...vary], ref: vary => [vary.description], str: vary => { if (!vary) return null; try { return [].concat(JSON.parse(vary)); } catch { return [vary]; } }, time: vary => [vary.toJSON()], dur: vary => [vary.toJSON()], range: vary => [vary.toJSON()], json: vary => [vary], jsan: vary => vary, dom: vary => [$mol_dom_serialize(vary)], tree: vary => [vary.toString()], }); } $.$hyoo_crus_vary_cast_jsan = $hyoo_crus_vary_cast_jsan; function $hyoo_crus_vary_cast_dom(vary) { return $hyoo_crus_vary_switch(vary, { nil: vary => null, bin: vary => $mol_jsx("body", null, vary && $mol_base64_ae_encode(vary)), bool: vary => $mol_jsx("body", null, vary), int: vary => $mol_jsx("body", null, vary), real: vary => $mol_jsx("body", null, vary), ints: vary => $mol_jsx("body", null, vary.join(',')), reals: vary => $mol_jsx("body", null, vary.join(',')), ref: vary => $mol_jsx("body", null, vary.description), str: vary => { if (!vary) return null; try { return vary ? $mol_dom_parse(vary, 'application/xhtml+xml').documentElement : null; } catch { return $mol_jsx("body", null, vary); } }, time: vary => $mol_jsx("body", null, vary), dur: vary => $mol_jsx("body", null, vary), range: vary => $mol_jsx("body", null, vary), json: vary => $mol_jsx("body", null, JSON.stringify(vary)), jsan: vary => $mol_jsx("body", null, JSON.stringify(vary)), dom: vary => vary, tree: vary => $mol_jsx("body", null, vary), }); } $.$hyoo_crus_vary_cast_dom = $hyoo_crus_vary_cast_dom; function $hyoo_crus_vary_cast_tree(vary) { return $hyoo_crus_vary_switch(vary, { nil: vary => null, bin: vary => $mol_tree2_bin_from_bytes(vary), bool: vary => $mol_tree2.struct(vary.toString()), int: vary => $mol_tree2.struct(vary.toString()), real: vary => $mol_tree2.struct(vary.toString()), ints: vary => $mol_tree2.list([...vary].map(v => $mol_tree2.struct(v.toString()))), reals: vary => $mol_tree2.list([...vary].map(v => $mol_tree2.struct(v.toString()))), ref: vary => $mol_tree2.struct(vary.description), str: vary => { if (!vary) return null; try { return $$.$mol_tree2_from_string(vary); } catch { return $$.$mol_tree2.data(vary); } }, time: vary => $mol_tree2.struct(vary.toString()), dur: vary => $mol_tree2.struct(vary.toString()), range: vary => $mol_tree2.struct(vary.toString()), json: vary => $$.$mol_tree2_from_json(vary), jsan: vary => $$.$mol_tree2_from_json(vary), dom: vary => $$.$mol_tree2_xml_from_dom(vary), tree: vary => vary, }); } $.$hyoo_crus_vary_cast_tree = $hyoo_crus_vary_cast_tree; $.$hyoo_crus_vary_cast_funcs = { nil: () => null, bin: $hyoo_crus_vary_cast_bin, bool: $hyoo_crus_vary_cast_bool, int: $hyoo_crus_vary_cast_int, real: $hyoo_crus_vary_cast_real, ints: $hyoo_crus_vary_cast_ints, reals: $hyoo_crus_vary_cast_reals, ref: $hyoo_crus_vary_cast_ref, str: $hyoo_crus_vary_cast_str, time: $hyoo_crus_vary_cast_time, dur: $hyoo_crus_vary_cast_dur, range: $hyoo_crus_vary_cast_range, json: $hyoo_crus_vary_cast_json, jsan: $hyoo_crus_vary_cast_jsan, dom: $hyoo_crus_vary_cast_dom, tree: $hyoo_crus_vary_cast_tree, }; function $hyoo_crus_vary_cast(tip, vary) { return $.$hyoo_crus_vary_cast_funcs[tip](vary); } $.$hyoo_crus_vary_cast = $hyoo_crus_vary_cast; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_bus extends $mol_object { name; handle; channel; constructor(name, handle) { super(); this.name = name; this.handle = handle; const channel = new BroadcastChannel(name); channel.onmessage = (event) => this.handle(event.data); this.channel = channel; } destructor() { this.channel.close(); } send(data) { this.channel.postMessage(data); } } $.$mol_bus = $mol_bus; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $hyoo_crus_log() { return this.$mol_state_arg.value('hyoo_crus_log') !== null; } $.$hyoo_crus_log = $hyoo_crus_log; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_wire_race(...tasks) { const results = tasks.map(task => { try { return task(); } catch (error) { return error; } }); const promises = results.filter(res => $mol_promise_like(res)); if (promises.length) $mol_fail(Promise.race(promises)); const error = results.find(res => res instanceof Error); if (error) $mol_fail(error); return results; } $.$mol_wire_race = $mol_wire_race; })($ || ($ = {})); ; "use strict"; var $; (function ($) { let $hyoo_crus_land_root; (function ($hyoo_crus_land_root) { $hyoo_crus_land_root["data"] = ""; $hyoo_crus_land_root["tine"] = "AQAAAAAA"; })($hyoo_crus_land_root = $.$hyoo_crus_land_root || ($.$hyoo_crus_land_root = {})); class $hyoo_crus_land extends $mol_object { ref() { return this.auth().lord(); } auth() { return this.$.$hyoo_crus_auth.current(); } faces = new $hyoo_crus_face_map; pass = new $mol_wire_dict(); gift = new $mol_wire_dict(); sand = new $mol_wire_dict(); self_all = new $mol_wire_dict(); self_make(idea = Math.floor(Math.random() * 2 ** 48)) { const auth = this.auth(); const rank = this.lord_rank(auth.lord()); if (rank < $hyoo_crus_rank_tier.post) $mol_fail(new Error(`Rank too low (${rank})`)); for (let i = 0; i < 4096; ++i) { idea = (idea + 1) % 2 ** 48; if (!idea) continue; const idea_str = $mol_base64_ae_encode(new Uint8Array(new BigUint64Array([BigInt(idea)]).buffer, 0, 6)); if (this.self_all.has(idea_str)) continue; this.self_all.set(idea_str, null); return idea_str; } $mol_fail(new Error(`Too long self generation`)); } home() { return this.Data($hyoo_crus_home); } area_make(idea = Math.floor(Math.random() * 2 ** 48)) { this.loading(); const id = $mol_base64_ae_encode(new Uint8Array(new BigUint64Array([BigInt(idea)]).buffer, 0, 6)); const ref = $hyoo_crus_ref($hyoo_crus_ref_lord(this.ref()).description + '_' + id); const area = this.$.$hyoo_crus_glob.Land(ref); const units = this.unit_sort([...this.pass.values(), ...this.gift.values()]).map(unit => { const clone = $hyoo_crus_unit.from(unit).narrow(); clone._land = area; $hyoo_crus_unit_trusted.add(clone); return clone; }); const errors = area.apply_unit(units, 'skip_check').filter(Boolean); for (const error of errors) this.$.$mol_log3_warn({ place: `${this}.area_make()`, message: error, hint: 'Send it to developer', }); area.bus(); area.sync_mine(); area.sync_yard(); return area; } Data(Node) { return this.Node(Node).Item($hyoo_crus_land_root.data); } Tine() { return this.Node($hyoo_crus_list_ref).Item($hyoo_crus_land_root.tine); } Node(Node) { return new $hyoo_crus_fund((head) => { if (head === 'AAAAAAAA') return this.Node(Node).Item($hyoo_crus_land_root.data); return Node.make({ land: () => this.sync(), head: $mol_const(head), }); }); } total() { let total = this.pass.size + this.gift.size; for (const peers of this.sand.values()) { for (const units of peers.values()) { total += units.size; } } return total; } joined_list() { return [...this.pass.values()].map(unit => unit.lord()); } key() { const pass = this.pass.get($hyoo_crus_ref_peer(this.ref())); if (!pass) return null; return $hyoo_crus_auth.from(pass.auth()); } lord_rank(lord, next) { if (lord === $hyoo_crus_ref_lord(this.ref())) return $hyoo_crus_rank_rule; const prev = this.gift.get(lord)?.rank() ?? this.gift.get($hyoo_crus_ref(''))?.rank() ?? (this.encrypted() ? $hyoo_crus_rank_deny : $hyoo_crus_rank_read); if (next === undefined) return prev; if (next === prev) return prev; this.give(lord, next); return next; } peer_rank(peer) { const auth = this.pass.get(peer); if (auth) return this.lord_rank(auth.lord()); return this.encrypted() ? $hyoo_crus_rank_deny : $hyoo_crus_rank_read; } unit_sort(units) { const dict = new Map(); for (const unit of units) dict.set(unit.key(), unit); const lord = $hyoo_crus_ref_lord(this.ref()); const graph = new $mol_graph(); for (const unit of units) { unit.choose({ pass: pass => { if (pass.lord() === lord) return; graph.link(pass.key(), 'gift:'); }, gift: gift => { graph.link('pass:' + $hyoo_crus_ref_peer(gift.dest()), gift.key()); graph.link(gift.key(), 'pass:' + gift.peer()); }, sand: sand => { graph.link(sand.key(), 'pass:' + sand.peer()); }, }); } graph.acyclic(() => 1); return [...graph.sorted].map(key => dict.get(key)).filter(Boolean); } delta_unit(face = new $hyoo_crus_face_map) { this.loading(); const delta = []; const passed = new Set(); const auth = (peer) => { if (passed.has(peer)) return; if (face.get(peer)) return; const pass = this.pass.get(peer); if (!pass) $mol_fail(new Error(`No pass for Peer (${peer})`)); delta.push(pass); passed.add(peer); }; for (const [lord, unit] of this.gift) { const time = face.get(unit.peer()) ?? 0; if (time >= unit.time()) continue; auth(unit.peer()); delta.push(unit); } for (const kids of this.sand.values()) { for (const peers of kids.values()) { for (const unit of peers.values()) { const time = face.get(unit.peer()) ?? 0; if (time >= unit.time()) continue; auth(unit.peer()); delta.push(unit); } } } for (const [peer, unit] of this.pass) { if (passed.has(peer)) continue; if (face.has(unit.peer())) continue; delta.push(unit); passed.add(peer); } if (delta.length || this.faces.total <= this.faces.total) return delta; this.$.$mol_log3_warn({ place: this, message: 'Unit Absent', hint: 'Relax, Delta contains all Units to restore', face, }); return this.delta_unit(); } delta_pack(face = new $hyoo_crus_face_map) { const parts = this.delta_parts(face); if (!parts) return null; const pack = $hyoo_crus_pack.make(parts); return pack; } delta_parts(face = new $hyoo_crus_face_map) { const units = this.delta_unit(face); if (!units.length) return null; const rocks = []; for (let unit of units) { if (unit.kind() !== 'sand') continue; const sand = unit.narrow(); if (sand.size() <= 32) continue; const rock = this.$.$hyoo_crus_mine.rock(sand.hash()) ?? null; rocks.push([sand.hash(), rock]); } return { lands: { [this.ref()]: { faces: new $hyoo_crus_face_map, units, }, }, rocks, }; } faces_pack() { const pack = $hyoo_crus_pack.make({ lands: { [this.ref()]: { faces: this.faces, units: [] }, }, rocks: [], }); return pack; } apply_unit(delta, skip_check) { if (!delta.length) return []; if (!skip_check) this.loading(); const doubt = delta.filter(unit => !$hyoo_crus_unit_trusted.has(unit)); if (doubt.length) { const errors = $mol_wire_sync(this).units_verify(doubt); if (errors.some(v => v)) return errors; } const errors = this.apply_unit_trust(delta, skip_check); for (const unit of doubt) $hyoo_crus_unit_trusted.add(unit); return errors; } async units_verify(units) { const passes = units.filter(unit => unit.kind() === 'pass'); const auth = new Map(passes.map((unit) => [ unit.peer(), $mol_crypto_key_public.from(unit.auth()), ])); const mixin = $hyoo_crus_ref_encode(this.ref()); const mixin_lord = $hyoo_crus_ref_encode($hyoo_crus_ref_lord(this.ref())); return await Promise.all(units.map(async (unit) => { let key_public = this.key_public(unit.peer()); if (!key_public) key_public = auth.get(unit.peer()) ?? null; if (!key_public) return `No public key for peer (${unit.peer()})`; const sign = unit.sign(); let sens = unit.sens().slice(); for (let i = 0; i < mixin.length; ++i) sens[i + 2] ^= mixin[i]; if (await key_public.verify(sens, sign)) return ''; sens = unit.sens().slice(); for (let i = 0; i < mixin_lord.length; ++i) sens[i + 2] ^= mixin_lord[i]; if (await key_public.verify(sens, sign)) return ''; return `Wrong unit sign`; })); } apply_unit_trust(delta, skip_check) { return delta.map(unit => { let need_recheck = false; const res = unit.choose({ pass: next => { const lord = next.lord(); const peer = next.peer(); if (!skip_check && this.lord_rank(lord) < next.rank_min()) return 'Need reg rank to join'; const exists = this.pass.get(peer); if (exists) return ''; this.pass.set(peer, next); this.faces.time_max(peer, 0); this.faces.total++; }, gift: next => { const peer = next.peer(); const dest = next.dest(); if (!skip_check && this.peer_rank(peer) < next.rank_min()) return 'Need law rank to change rank'; const prev = this.gift.get(dest); if (prev && $hyoo_crus_gift.compare(prev, next) <= 0) return ''; this.gift.set(dest, next); this.faces.time_max(peer, next.time()); if (!prev) this.faces.total++; if ((prev?.rank() ?? $hyoo_crus_rank_deny) > next.rank()) need_recheck = true; }, sand: next => { const head = next.head(); const peer = next.peer(); const self = next.self(); if (!skip_check && this.peer_rank(peer) < next.rank_min()) return 'Need mod rank to post data'; let peers = this.sand.get(head); if (!peers) this.sand.set(head, peers = new $mol_wire_dict); let units = peers.get(peer); if (!units) peers.set(peer, units = new $mol_wire_dict); const prev = units.get(self); if (prev && $hyoo_crus_sand.compare(prev, next) <= 0) return ''; units.set(self, next); this.self_all.set(self, next); this.faces.time_max(peer, next.time()); if (!prev) this.faces.total++; }, }); if (need_recheck) this.recheck(); return res ?? ''; }); } apply_land(land) { return this.apply_unit(land.delta_unit()); } recheck() { for (const [peer, pass] of this.pass) { if (this.lord_rank(pass.lord()) >= pass.rank_min()) continue; this.pass.delete(peer); this.faces.total--; } for (const [lord, gift] of this.gift) { if (this.peer_rank(gift.peer()) >= gift.rank_min()) continue; this.gift.delete(lord); this.faces.total--; } for (const [head, peers] of this.sand) { for (const [peer, sands] of peers) { const rank = this.peer_rank(peer); for (const [self, sand] of sands) { if (rank >= sand.rank_min()) continue; sands.delete(self); this.faces.total--; } } } } fork(preset = { '': $hyoo_crus_rank_read }) { const land = this.$.$hyoo_crus_glob.land_grab(preset); land.Tine().items_vary([this.ref()]); return land; } sand_ordered({ head, peer }) { this.sync(); const queue = peer ? [...this.sand.get(head)?.get(peer)?.values() ?? []] : [...this.sand.get(head)?.values() ?? []].flatMap(units => [...units.values()]); const slices = new Map; for (const sand of queue) slices.set(sand, 0); merge: if (head !== $hyoo_crus_land_root.tine) { const tines = (this.Tine()?.items_vary().slice().reverse() ?? []) .map($hyoo_crus_vary_cast_ref) .filter($mol_guard_defined); if (!tines.length) break merge; const exists = new Set(queue.map(sand => sand.self())); const glob = this.$.$hyoo_crus_glob; let slice = 0; for (const ref of tines) { ++slice; const land = glob.Land(ref); for (const sand of land.sand_ordered({ head, peer })) { if (exists.has(sand.self())) continue; queue.push(sand); exists.add(sand.self()); slices.set(sand, slice); } } } if (queue.length < 2) return queue; const compare = (left, right) => { return (slices.get(left) - slices.get(right)) || $hyoo_crus_sand.compare(left, right); }; queue.sort(compare); let entry = { sand: null, next: '', prev: '', }; const key = peer === null ? (sand) => sand.key() : (sand) => sand.self(); const by_key = new Map([['', entry]]); const by_self = new Map([['', entry]]); while (queue.length) { const last = queue.pop(); by_key.get(entry.prev).next = key(last); const item = { sand: last, next: '', prev: entry.prev }; by_key.set(key(last), item); const exists = by_self.get(last.self()); if (!exists || compare(exists.sand, last) < 0) { by_self.set(last.self(), item); } entry.prev = key(last); for (let cursor = queue.length - 1; cursor >= 0; --cursor) { const kid = queue[cursor]; let lead = by_self.get(kid.lead()); if (!lead) continue; while (lead.next && (compare(by_key.get(lead.next).sand, kid) < 0)) lead = by_key.get(lead.next); const exists1 = by_key.get(key(kid)); if (exists1) { if ((lead.sand ? key(lead.sand) : '') === exists1.prev) { exists1.sand = kid; if (cursor === queue.length - 1) queue.pop(); continue; } by_key.get(exists1.prev).next = exists1.next; by_key.get(exists1.next).prev = exists1.prev; } const follower = by_key.get(lead.next); follower.prev = key(kid); const item = { sand: kid, next: lead.next, prev: lead.sand ? key(lead.sand) : '' }; by_key.set(key(kid), item); const exists2 = by_self.get(kid.self()); if (!exists2 || compare(exists2.sand, kid) < 0) { by_self.set(kid.self(), item); } lead.next = key(kid); if (cursor === queue.length - 1) queue.pop(); cursor = queue.length; } } const res = []; while (entry.next) { entry = by_key.get(entry.next); res.push(entry.sand); } return res; } join() { const auth = this.auth(); const prev = this.pass.get(auth.peer()); if (prev) return prev; const next = new $hyoo_crus_pass; $hyoo_crus_unit_trusted.add(next); next.auth(auth.public().asArray()); next._land = this; const error = this.apply_unit([next])[0]; if (error) $mol_fail(new Error(error)); this.broadcast(); return next; } give(dest, rank) { this.join(); const auth = this.auth(); const unit = new $hyoo_crus_gift; $hyoo_crus_unit_trusted.add(unit); unit.rank(rank); unit.time(this.faces.tick()); unit.peer(auth.peer()); unit.dest(dest ? dest instanceof $hyoo_crus_auth ? dest.lord() : dest : $hyoo_crus_ref('')); unit._land = this; if (rank >= $hyoo_crus_rank_read) { const secret_land = this.secret(); if (secret_land) { if (!dest) $mol_fail(new Error(`Encrypted land can't be shared to everyone`)); if (typeof dest === 'symbol') { $mol_fail(new Error(`No pub key for lord (${dest.description})`)); } const secret_mutual = this.secret_mutual(dest.toString()); if (secret_mutual) { const secret_bin = $mol_wire_sync(secret_land).serial(); const bill = $mol_wire_sync(secret_mutual).encrypt(secret_bin, unit.salt()); unit.bill().set(bill); } } } const error = this.apply_unit([unit])[0]; if (error) $mol_fail(new Error(error)); this.broadcast(); return unit; } post(lead, head, self, vary, tag = 'term') { if (typeof vary === 'symbol') vary = $hyoo_crus_ref_relate(this.ref(), vary); this.join(); const auth = this.auth(); const unit = new $hyoo_crus_sand; $hyoo_crus_unit_trusted.add(unit); unit.time(this.faces.tick()); unit.peer(auth.peer()); unit.lead(lead); unit.head(head); unit._vary = vary; unit._land = this; let { tip, bin } = $hyoo_crus_vary_encode(vary); unit._open = bin; if (vary !== null && this.encrypted()) { unit.hash($mol_crypto_hash(bin), tip, tag); } else { if (bin.byteLength > 32) unit.hash(this.$.$hyoo_crus_mine.hash(bin), tip, tag); else unit.data(bin, tip, tag); } unit.self(self || this.self_make(unit.idea())); const error = this.apply_unit([unit])[0]; if (error) $mol_fail(new Error(error)); this.broadcast(); return unit; } sand_move(sand, head, seat, peer = '') { if (sand.tip() === 'nil') $mol_fail(new RangeError(`Can't move wiped sand`)); const units = this.sand_ordered({ head, peer }).filter(unit => unit.tip() !== 'nil'); if (seat > units.length) $mol_fail(new RangeError(`Seat (${seat}) out of units length (${units.length})`)); const lead = seat ? units[seat - 1].self() : ''; const vary = this.sand_decode(sand); if (sand.head() === head) { const seat_prev = units.indexOf(sand); if (seat === seat_prev) return; if (seat === seat_prev + 1) return; const prev = seat_prev ? units[seat_prev - 1].self() : ''; const next = units[seat_prev + 1]; if (next) this.post(prev, head, next.self(), this.sand_decode(next), next.tag()); } else { this.sand_wipe(sand); } return this.post(lead, head, sand.self(), vary, sand.tag()); } sand_wipe(sand, peer = '') { const head = sand.head(); const units = this.sand_ordered({ head, peer }).filter(unit => unit.tip() !== 'nil'); const seat = units.indexOf(sand); if (seat < 0) return sand; return this.post(seat ? units[seat - 1].self() : '', head, sand.self(), null, 'term'); } broadcast() { this.$.$hyoo_crus_glob.yard().lands_news.add(this.ref()); } sync() { this.loading(); this.bus(); this.sync_mine(); this.sync_yard(); return this; } destructor() { this.$.$hyoo_crus_glob.yard().forget_land(this); } sync_mine() { return new $mol_wire_atom('', () => this.saving()).fresh(); } sync_yard() { return new $mol_wire_atom('', () => this.$.$hyoo_crus_glob.yard().sync_land(this.ref())).fresh(); } bus() { return new this.$.$mol_bus(`$hyoo_crus_land:${this.ref().description}`, $mol_wire_async(bins => { this.apply_unit(bins.map(bin => { const unit = new $hyoo_crus_unit(bin).narrow(); $hyoo_crus_unit_trusted.add(unit); this.$.$hyoo_crus_mine.units_persisted.add(unit); return unit; })); })); } loading() { let units = this.unit_sort(this.$.$hyoo_crus_mine.units(this.ref()) ?? []); if (this.$.$hyoo_crus_log()) $mol_wire_sync(this.$).$mol_log3_rise({ place: this, message: 'Load Unit', units: units.length, }); const errors = this.apply_unit(units, 'skip_check').filter(Boolean); if (errors.length) this.$.$mol_log3_fail({ place: this, message: errors.join('\n'), }); } saving() { const mine = this.$.$hyoo_crus_mine; if (!mine) return; this.loading(); const encoding = []; const signing = []; const persisting = []; for (const pass of this.pass.values()) { if (!pass.signed()) signing.push(pass); if (!mine.units_persisted.has(pass)) persisting.push(pass); } for (const gift of this.gift.values()) { if (!gift.signed()) signing.push(gift); if (!mine.units_persisted.has(gift)) persisting.push(gift); } for (const kids of this.sand.values()) { for (const units of kids.values()) { for (const sand of units.values()) { if (!sand.signed()) { encoding.push(sand); signing.push(sand); } if (!mine.units_persisted.has(sand)) persisting.push(sand); } } } $mol_wire_race(...encoding.map(unit => () => this.sand_encode(unit))); $mol_wire_race(...signing.map(unit => () => this.unit_sign(unit))); if (persisting.length) { this.bus().send(persisting.map(unit => unit.buffer)); mine.units(this.ref(), persisting); if (this.$.$hyoo_crus_log()) $mol_wire_sync(this.$).$mol_log3_done({ place: this, message: 'Saved Units', units: persisting.length, }); } } unit_sign(unit) { if (unit.signed()) return; const key = $mol_wire_sync(unit._land.auth()); const mixin = $hyoo_crus_ref_encode(unit._land.ref()); const sens = unit.sens().slice(); for (let i = 0; i < mixin.length; ++i) sens[i + 2] ^= mixin[i]; while (true) { const sign = key.sign(sens); unit.sign(sign.slice(0, 2)); const rank = unit instanceof $hyoo_crus_pass ? this.lord_rank(unit.lord()) : this.peer_rank(unit.peer()); if (rank >= unit.rank_min()) { unit.sign(sign); return; } else { unit.sign(new Uint8Array([0, 0])); } } } sand_encode(sand) { if (sand._open === null) return sand; if (sand.tip() === 'nil') return sand; let bin = sand._open; const secret = sand._land.secret(); if (secret) bin = $mol_wire_sync(secret).encrypt(bin, sand.salt()); if (bin.byteLength > 32) sand.hash(this.$.$hyoo_crus_mine.rock_save(bin), sand.tip(), sand.tag()); else sand.data(bin, sand.tip(), sand.tag()); return sand; } sand_decode(sand) { try { let vary = this.sand_decode_raw(sand); if (typeof vary === 'symbol') vary = $hyoo_crus_ref_resolve(this.ref(), vary); return vary; } catch (error) { if (error instanceof Promise) return $mol_fail_hidden(error); this.$.$mol_fail_log(error); return null; } } sand_decode_raw(sand) { if (this.sand.get(sand.head())?.get(sand.peer())?.get(sand.self()) !== sand) { for (const id of this.Tine().items_vary() ?? []) { const vary = this.$.$hyoo_crus_glob.Land($hyoo_crus_vary_cast_ref(id)).sand_decode_raw(sand); if (vary !== undefined) return vary; } return undefined; } const secret = this.secret(); if (sand._vary !== undefined) return sand._vary; if (sand._open !== null) return sand._vary = $hyoo_crus_vary_decode({ tip: sand.tip(), bin: sand._open }); let bin = sand.size() > 32 ? this.$.$hyoo_crus_mine.rock(sand.hash()) : sand.data(); if (secret && bin && sand.tip() !== 'nil') { try { bin = $mol_wire_sync(secret).decrypt(bin, sand.salt()); } catch (error) { if ($mol_fail_catch(error)) { if (error.message) $mol_fail_hidden(error); else $mol_fail_hidden(new Error(`Can't decrypt`, { cause: error })); } } } sand._open = bin; return sand._vary = (bin ? $hyoo_crus_vary_decode({ tip: sand.tip(), bin }) : null); } key_public(peer) { const key = this.pass.get(peer)?.auth(); return key ? $mol_crypto_key_public.from(key) : null; } secret_mutual(key_public) { return $mol_wire_sync($mol_crypto_secret).derive(this.auth().toString(), key_public); } encryptable() { return !this.sand.size; } encrypted(next) { const gift = this.gift.get(this.ref()); const prev = gift?.bill().some(b => b) ?? false; if (next === undefined) return prev; if (prev === next) return prev; if (!this.encryptable()) $mol_fail(new Error(`Non empty Land never encrypted`)); this.join(); const auth = this.auth(); const secret = $mol_wire_sync($mol_crypto_secret).generate(); const secret_land = $mol_wire_sync(secret).serial(); const secret_mutual = auth.secret_mutual(auth.public().toString()); const unit = new $hyoo_crus_gift; $hyoo_crus_unit_trusted.add(unit); unit.rank($hyoo_crus_rank_rule); unit.time(this.faces.tick()); unit.peer(auth.peer()); unit.dest(auth.lord()); unit._land = this; const secret_closed = $mol_wire_sync(secret_mutual).encrypt(secret_land, unit.salt()); unit.bill().set(secret_closed); const error = this.apply_unit([unit])[0]; if (error) $mol_fail(new Error(error)); return next; } secret() { if (!this.encrypted()) return null; const auth = this.auth(); const gift = this.gift.get(auth.lord()); if (!gift) return $mol_fail(new Error(`Access denied`)); const bill = gift.bill(); if (!bill.some(b => b)) return $mol_fail(new Error(`No key to decrypt`)); const secret_mutual = auth.secret_mutual(this.key_public(gift.peer()).toString()); if (!secret_mutual) return $mol_fail(new Error(`Can't decrypt secret`)); const secret_land = $mol_wire_sync(secret_mutual).decrypt(bill, gift.salt()); return $mol_wire_sync($mol_crypto_secret).from(secret_land); } dump() { this.saving(); const units = []; const rocks = []; for (const pass of this.pass.values()) units.push(pass); for (const gift of this.gift.values()) units.push(gift); for (const heads of this.sand.values()) { for (const sands of heads.values()) { for (const sand of sands.values()) { units.push(sand); if (sand.size() <= 32) continue; const rock = this.$.$hyoo_crus_mine.rock(sand.hash()); if (!rock) continue; rocks.push([sand.hash(), rock]); } } } return { land: this.ref(), units, rocks, }; } ; [$mol_dev_format_head]() { return $mol_dev_format_span({}, $mol_dev_format_native(this), ' ', $mol_dev_format_auto(this.faces.total)); } } __decorate([ $mol_action ], $hyoo_crus_land.prototype, "self_make", null); __decorate([ $mol_action ], $hyoo_crus_land.prototype, "area_make", null); __decorate([ $mol_mem_key ], $hyoo_crus_land.prototype, "Data", null); __decorate([ $mol_mem ], $hyoo_crus_land.prototype, "Tine", null); __decorate([ $mol_mem_key ], $hyoo_crus_land.prototype, "Node", null); __decorate([ $mol_mem ], $hyoo_crus_land.prototype, "total", null); __decorate([ $mol_mem ], $hyoo_crus_land.prototype, "joined_list", null); __decorate([ $mol_mem ], $hyoo_crus_land.prototype, "key", null); __decorate([ $mol_mem_key ], $hyoo_crus_land.prototype, "lord_rank", null); __decorate([ $mol_action ], $hyoo_crus_land.prototype, "faces_pack", null); __decorate([ $mol_action ], $hyoo_crus_land.prototype, "apply_unit", null); __decorate([ $mol_action ], $hyoo_crus_land.prototype, "apply_unit_trust", null); __decorate([ $mol_action ], $hyoo_crus_land.prototype, "fork", null); __decorate([ $mol_mem_key ], $hyoo_crus_land.prototype, "sand_ordered", null); __decorate([ $mol_action ], $hyoo_crus_land.prototype, "join", null); __decorate([ $mol_action ], $hyoo_crus_land.prototype, "give", null); __decorate([ $mol_action ], $hyoo_crus_land.prototype, "post", null); __decorate([ $mol_action ], $hyoo_crus_land.prototype, "sand_move", null); __decorate([ $mol_action ], $hyoo_crus_land.prototype, "sand_wipe", null); __decorate([ $mol_mem ], $hyoo_crus_land.prototype, "sync", null); __decorate([ $mol_mem ], $hyoo_crus_land.prototype, "sync_mine", null); __decorate([ $mol_mem ], $hyoo_crus_land.prototype, "sync_yard", null); __decorate([ $mol_mem ], $hyoo_crus_land.prototype, "bus", null); __decorate([ $mol_mem ], $hyoo_crus_land.prototype, "loading", null); __decorate([ $mol_mem ], $hyoo_crus_land.prototype, "saving", null); __decorate([ $mol_mem_key ], $hyoo_crus_land.prototype, "unit_sign", null); __decorate([ $mol_mem_key ], $hyoo_crus_land.prototype, "sand_encode", null); __decorate([ $mol_mem_key ], $hyoo_crus_land.prototype, "sand_decode", null); __decorate([ $mol_mem_key ], $hyoo_crus_land.prototype, "sand_decode_raw", null); __decorate([ $mol_mem_key ], $hyoo_crus_land.prototype, "key_public", null); __decorate([ $mol_mem_key ], $hyoo_crus_land.prototype, "secret_mutual", null); __decorate([ $mol_mem ], $hyoo_crus_land.prototype, "encryptable", null); __decorate([ $mol_mem ], $hyoo_crus_land.prototype, "encrypted", null); __decorate([ $mol_mem ], $hyoo_crus_land.prototype, "secret", null); $.$hyoo_crus_land = $hyoo_crus_land; })($ || ($ = {})); ; "use strict"; var $; (function ($) { let $mol_rest_code; (function ($mol_rest_code) { $mol_rest_code[$mol_rest_code["Continue"] = 100] = "Continue"; $mol_rest_code[$mol_rest_code["Switching_Protocols"] = 101] = "Switching_Protocols"; $mol_rest_code[$mol_rest_code["Processing"] = 102] = "Processing"; $mol_rest_code[$mol_rest_code["OK"] = 200] = "OK"; $mol_rest_code[$mol_rest_code["Created"] = 201] = "Created"; $mol_rest_code[$mol_rest_code["Accepted"] = 202] = "Accepted"; $mol_rest_code[$mol_rest_code["Non_Authoritative_Information"] = 203] = "Non_Authoritative_Information"; $mol_rest_code[$mol_rest_code["No_Content"] = 204] = "No_Content"; $mol_rest_code[$mol_rest_code["Reset_Content"] = 205] = "Reset_Content"; $mol_rest_code[$mol_rest_code["Partial_Content"] = 206] = "Partial_Content"; $mol_rest_code[$mol_rest_code["Multi_Status"] = 207] = "Multi_Status"; $mol_rest_code[$mol_rest_code["Already_Reported"] = 208] = "Already_Reported"; $mol_rest_code[$mol_rest_code["IM_Used"] = 226] = "IM_Used"; $mol_rest_code[$mol_rest_code["Multiple_Choices"] = 300] = "Multiple_Choices"; $mol_rest_code[$mol_rest_code["Moved_Permanently"] = 301] = "Moved_Permanently"; $mol_rest_code[$mol_rest_code["Found"] = 302] = "Found"; $mol_rest_code[$mol_rest_code["See_Other"] = 303] = "See_Other"; $mol_rest_code[$mol_rest_code["Not_Modified"] = 304] = "Not_Modified"; $mol_rest_code[$mol_rest_code["Use_Proxy"] = 305] = "Use_Proxy"; $mol_rest_code[$mol_rest_code["Temporary_Redirect"] = 307] = "Temporary_Redirect"; $mol_rest_code[$mol_rest_code["Bad_Request"] = 400] = "Bad_Request"; $mol_rest_code[$mol_rest_code["Unauthorized"] = 401] = "Unauthorized"; $mol_rest_code[$mol_rest_code["Payment_Required"] = 402] = "Payment_Required"; $mol_rest_code[$mol_rest_code["Forbidden"] = 403] = "Forbidden"; $mol_rest_code[$mol_rest_code["Not_Found"] = 404] = "Not_Found"; $mol_rest_code[$mol_rest_code["Method_Not_Allowed"] = 405] = "Method_Not_Allowed"; $mol_rest_code[$mol_rest_code["Not_Acceptable"] = 406] = "Not_Acceptable"; $mol_rest_code[$mol_rest_code["Proxy_Authentication_Required"] = 407] = "Proxy_Authentication_Required"; $mol_rest_code[$mol_rest_code["Request_Timeout"] = 408] = "Request_Timeout"; $mol_rest_code[$mol_rest_code["Conflict"] = 409] = "Conflict"; $mol_rest_code[$mol_rest_code["Gone"] = 410] = "Gone"; $mol_rest_code[$mol_rest_code["Length_Required"] = 411] = "Length_Required"; $mol_rest_code[$mol_rest_code["Precondition_Failed"] = 412] = "Precondition_Failed"; $mol_rest_code[$mol_rest_code["Request_Entity_Too_Large"] = 413] = "Request_Entity_Too_Large"; $mol_rest_code[$mol_rest_code["Request_URI_Too_Long"] = 414] = "Request_URI_Too_Long"; $mol_rest_code[$mol_rest_code["Unsupported_Media_Type"] = 415] = "Unsupported_Media_Type"; $mol_rest_code[$mol_rest_code["Requested_Range_Not_Satisfiable"] = 416] = "Requested_Range_Not_Satisfiable"; $mol_rest_code[$mol_rest_code["Expectation_Failed"] = 417] = "Expectation_Failed"; $mol_rest_code[$mol_rest_code["Teapot"] = 418] = "Teapot"; $mol_rest_code[$mol_rest_code["Unprocessable_Entity"] = 422] = "Unprocessable_Entity"; $mol_rest_code[$mol_rest_code["Locked"] = 423] = "Locked"; $mol_rest_code[$mol_rest_code["Failed_Dependency"] = 424] = "Failed_Dependency"; $mol_rest_code[$mol_rest_code["Upgrade_Required"] = 426] = "Upgrade_Required"; $mol_rest_code[$mol_rest_code["Precondition_Required"] = 428] = "Precondition_Required"; $mol_rest_code[$mol_rest_code["Too_Many_Requests"] = 429] = "Too_Many_Requests"; $mol_rest_code[$mol_rest_code["Request_Header_Fields_Too_Large"] = 431] = "Request_Header_Fields_Too_Large"; $mol_rest_code[$mol_rest_code["Unavailable_For_Legal_Reasons"] = 451] = "Unavailable_For_Legal_Reasons"; $mol_rest_code[$mol_rest_code["Internal_Server_Error"] = 500] = "Internal_Server_Error"; $mol_rest_code[$mol_rest_code["Not_Implemented"] = 501] = "Not_Implemented"; $mol_rest_code[$mol_rest_code["Bad_Gateway"] = 502] = "Bad_Gateway"; $mol_rest_code[$mol_rest_code["Service_Unavailable"] = 503] = "Service_Unavailable"; $mol_rest_code[$mol_rest_code["Gateway_Timeout"] = 504] = "Gateway_Timeout"; $mol_rest_code[$mol_rest_code["HTTP_Version_Not_Supported"] = 505] = "HTTP_Version_Not_Supported"; $mol_rest_code[$mol_rest_code["Insufficient_Storage"] = 507] = "Insufficient_Storage"; $mol_rest_code[$mol_rest_code["Loop_Detected"] = 508] = "Loop_Detected"; $mol_rest_code[$mol_rest_code["Not_Extended"] = 510] = "Not_Extended"; $mol_rest_code[$mol_rest_code["Network_Authentication_Required"] = 511] = "Network_Authentication_Required"; $mol_rest_code[$mol_rest_code["Network_Read_Timeout_Error"] = 598] = "Network_Read_Timeout_Error"; $mol_rest_code[$mol_rest_code["Network_Connect_Timeout_Error"] = 599] = "Network_Connect_Timeout_Error"; })($mol_rest_code = $.$mol_rest_code || ($.$mol_rest_code = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_rest_port extends $mol_object { send_code(code) { } send_type(mime) { } send_data(data) { if (data === null) return this.send_nil(); if (typeof data === 'string') return this.send_text(data); if (data instanceof Uint8Array) return this.send_bin(data); if (data instanceof $mol_dom_context.Element) return this.send_dom(data); return this.send_json(data); } send_nil() { this.send_code(204); } send_bin(data) { this.send_code(200); this.send_type('application/octet-stream'); } send_text(data) { this.send_code(200); this.send_type('text/plain;charset=utf-8'); this.send_bin($mol_charset_encode(data)); } send_json(data) { this.send_code(200); this.send_type('application/json'); this.send_text(JSON.stringify(data)); } send_dom(data) { this.send_code(200); this.send_type('text/html;charset=utf-8'); this.send_text($mol_dom_serialize(data)); } static make(config) { return super.make(config); } } __decorate([ $mol_action ], $mol_rest_port.prototype, "send_data", null); __decorate([ $mol_action ], $mol_rest_port.prototype, "send_nil", null); __decorate([ $mol_action ], $mol_rest_port.prototype, "send_bin", null); __decorate([ $mol_action ], $mol_rest_port.prototype, "send_text", null); __decorate([ $mol_action ], $mol_rest_port.prototype, "send_json", null); __decorate([ $mol_action ], $mol_rest_port.prototype, "send_dom", null); __decorate([ ($mol_action) ], $mol_rest_port, "make", null); $.$mol_rest_port = $mol_rest_port; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_wire_set extends Set { pub = new $mol_wire_pub; has(value) { this.pub.promote(); return super.has(value); } entries() { this.pub.promote(); return super.entries(); } keys() { this.pub.promote(); return super.keys(); } values() { this.pub.promote(); return super.values(); } forEach(task, self) { this.pub.promote(); super.forEach(task, self); } [Symbol.iterator]() { this.pub.promote(); return super[Symbol.iterator](); } get size() { this.pub.promote(); return super.size; } add(value) { if (super.has(value)) return this; super.add(value); this.pub.emit(); return this; } delete(value) { const res = super.delete(value); if (res) this.pub.emit(); return res; } clear() { if (!super.size) return; super.clear(); this.pub.emit(); } item(val, next) { if (next === undefined) return this.has(val); if (next) this.add(val); else this.delete(val); return next; } } $.$mol_wire_set = $mol_wire_set; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_rest_port_ws extends $mol_rest_port { } $.$mol_rest_port_ws = $mol_rest_port_ws; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_rest_port_ws_std extends $mol_rest_port_ws { socket; send_nil() { if (this.socket.readyState !== this.socket.OPEN) return; this.socket.send(''); } send_bin(data) { if (this.socket.readyState !== this.socket.OPEN) return; this.socket.send(data); } send_text(data) { if (this.socket.readyState !== this.socket.OPEN) return; const bin = $mol_charset_encode(data); this.socket.send(bin); } } __decorate([ $mol_action ], $mol_rest_port_ws_std.prototype, "send_nil", null); __decorate([ $mol_action ], $mol_rest_port_ws_std.prototype, "send_bin", null); __decorate([ $mol_action ], $mol_rest_port_ws_std.prototype, "send_text", null); $.$mol_rest_port_ws_std = $mol_rest_port_ws_std; })($ || ($ = {})); ; "use strict"; var $; (function ($) { const Passives = new WeakMap(); class $hyoo_crus_yard extends $mol_object { glob() { return null; } lands_news = new $mol_wire_set(); static masters = []; master_cursor(next = 0) { return next; } master_current() { return this.$.$hyoo_crus_yard.masters[this.master_cursor()]; } master_next() { this.master_cursor((this.master_cursor() + 1) % this.$.$hyoo_crus_yard.masters.length); } reconnects(reset) { return ($mol_wire_probe(() => this.reconnects()) ?? 0) + 1; } master() { this.reconnects(); const link = this.master_current(); if (!link) return null; const socket = new $mol_dom_context.WebSocket(link.replace(/^http/, 'ws')); socket.binaryType = 'arraybuffer'; const port = $mol_rest_port_ws_std.make({ socket }); socket.onmessage = async (event) => { if (event.data instanceof ArrayBuffer) { if (!event.data.byteLength) return; await $mol_wire_async(this).port_income(port, new Uint8Array(event.data)); } else { this.$.$mol_log3_fail({ place: this, message: 'Wrong data', data: event.data }); } }; let interval; socket.onclose = () => { clearInterval(interval); setTimeout(() => this.reconnects(null), 1000); }; Object.assign(socket, { destructor: () => { socket.onclose = () => { }; clearInterval(interval); socket.close(); } }); return new Promise((done, fail) => { socket.onopen = () => { this.$.$mol_log3_come({ place: this, message: 'Connected', port: $mol_key(port), server: link, }); interval = setInterval(() => socket.send(new Uint8Array), 30000); done(port); }; socket.onerror = () => { socket.onclose = event => { fail(new Error(`Master (${link}) is unavailable (${event.code})`)); clearInterval(interval); interval = setTimeout(() => { this.master_next(); this.reconnects(null); }, 1000); }; }; }); } slaves = new $mol_wire_set(); sync() { this.sync_news(); this.sync_port(); } sync_news() { const glob = this.$.$hyoo_crus_glob; const lands = [...this.lands_news].map(ref => glob.Land(ref)); try { for (const port of this.masters()) { for (const land of lands) { this.sync_port_land([port, land.ref()]); } } for (const land of lands) land.saving(); this.lands_news.clear(); } catch (error) { $mol_fail_log(error); } } sync_port() { for (const port of this.ports()) this.sync_port_lands(port); } sync_port_lands(port) { for (const land of this.port_lands_active(port)) { this.sync_port_land([port, land]); } } ports() { return [...this.masters(), ...this.slaves]; } masters() { try { return [this.master()].filter($mol_guard_defined); } catch (error) { $mol_fail_log(error); return []; } } port_lands_active(port) { return new $mol_wire_set(); } port_lands_passive(port) { let passives = Passives.get(port); if (!passives) Passives.set(port, passives = new Set); return passives; } port_income(port, msg) { const pack = $mol_wire_sync($hyoo_crus_pack).from(msg); const parts = $mol_wire_sync(pack).parts(); if (this.$.$hyoo_crus_log()) $mol_wire_sync(this.$).$mol_log3_rise({ place: this, message: 'Gain Pack', port: $mol_key(port), lands: parts.lands, rocks: parts.rocks.length, }); forget: { if (parts.rocks.length) break forget; const lands = Object.getOwnPropertySymbols(parts.lands); for (const land of lands) { if (parts.lands[land].units.length) break forget; if (parts.lands[land].faces.size) break forget; if (!this.port_lands_active(port).has(land)) break forget; this.port_lands_active(port).delete(land); return; } } this.face_port_sync(port, parts.lands); this.$.$hyoo_crus_glob.apply_parts(parts.lands, parts.rocks); } face_port_sync(port, income) { const actives = this.port_lands_active(port); const passives = this.port_lands_passive(port); for (const land of Reflect.ownKeys(income)) { if (!passives.has(land)) actives.add(land); const faces = income[land].faces; let port_faces = this.face_port_land([port, land]); if (!port_faces) this.face_port_land([port, land], port_faces = $mol_mem_cached(() => this.face_port_land([port, land])) || new $hyoo_crus_face_map); port_faces.sync(faces); const units = income[land].units; for (let unit of units) { const unit2 = unit.narrow(); if (unit2 instanceof $hyoo_crus_pass) continue; port_faces.time_max(unit2.peer(), unit2.time()); } } } sync_land(land) { for (const port of this.masters()) { this.port_lands_passive(port).add(land); this.sync_port_land([port, land]); } this.sync(); } forget_land(land) { const faces = new $hyoo_crus_face_map; faces.total = land.faces.total; const pack = $hyoo_crus_pack.make({ lands: { [land.ref()]: { faces, units: [] } }, rocks: [], }).asArray(); for (const port of this.ports()) { if (!this.port_lands_passive(port).has(land.ref())) continue; this.port_lands_passive(port).delete(land.ref()); if (this.$.$hyoo_crus_log()) this.$.$mol_log3_rise({ place: this, message: 'Forget Land', port: $mol_key(port), land: land.ref(), }); port.send_bin(pack); } } sync_port_land([port, land]) { try { this.init_port_land([port, land]); const faces = this.face_port_land([port, land]); if (!faces) return; const Land = this.$.$hyoo_crus_glob.Land(land); Land.saving(); const parts = Land.delta_parts(faces); if (!parts) return; if (this.$.$hyoo_crus_log()) this.$.$mol_log3_rise({ place: this, message: 'Send Unit', port: $mol_key(port), lands: parts.lands, rocks: parts.rocks.length, }); port.send_bin($hyoo_crus_pack.make(parts).asArray()); faces.sync(Land.faces); } catch (error) { $mol_fail_log(error); } } init_port_land([port, land]) { const Land = this.$.$hyoo_crus_glob.Land(land); Land.loading(); if (this.$.$hyoo_crus_log()) this.$.$mol_log3_rise({ place: this, message: 'Send Face', port: $mol_key(port), land: land, faces: Land.faces, }); port.send_bin(Land.faces_pack().asArray()); } face_port_land([port, land], next = null) { $mol_wire_solid(); return next; } } __decorate([ $mol_mem ], $hyoo_crus_yard.prototype, "glob", null); __decorate([ $mol_mem ], $hyoo_crus_yard.prototype, "master_cursor", null); __decorate([ $mol_mem ], $hyoo_crus_yard.prototype, "master_current", null); __decorate([ $mol_action ], $hyoo_crus_yard.prototype, "master_next", null); __decorate([ $mol_mem ], $hyoo_crus_yard.prototype, "reconnects", null); __decorate([ $mol_mem ], $hyoo_crus_yard.prototype, "master", null); __decorate([ $mol_mem ], $hyoo_crus_yard.prototype, "sync", null); __decorate([ $mol_mem ], $hyoo_crus_yard.prototype, "sync_news", null); __decorate([ $mol_mem ], $hyoo_crus_yard.prototype, "sync_port", null); __decorate([ $mol_mem_key ], $hyoo_crus_yard.prototype, "sync_port_lands", null); __decorate([ $mol_mem ], $hyoo_crus_yard.prototype, "ports", null); __decorate([ $mol_mem ], $hyoo_crus_yard.prototype, "masters", null); __decorate([ $mol_mem_key ], $hyoo_crus_yard.prototype, "port_lands_active", null); __decorate([ $mol_action ], $hyoo_crus_yard.prototype, "port_income", null); __decorate([ $mol_action ], $hyoo_crus_yard.prototype, "face_port_sync", null); __decorate([ $mol_mem_key ], $hyoo_crus_yard.prototype, "sync_land", null); __decorate([ $mol_action ], $hyoo_crus_yard.prototype, "forget_land", null); __decorate([ $mol_mem_key ], $hyoo_crus_yard.prototype, "sync_port_land", null); __decorate([ $mol_mem_key ], $hyoo_crus_yard.prototype, "init_port_land", null); __decorate([ $mol_mem_key ], $hyoo_crus_yard.prototype, "face_port_land", null); $.$hyoo_crus_yard = $hyoo_crus_yard; })($ || ($ = {})); ; "use strict"; var $; (function ($) { $.$hyoo_crus_yard.masters = [ 'https://crus.hd4.ru/', 'https://i-love-crus.ru/', 'https://crus.87-120-36-150.ip.hyoo.ru/', ]; })($ || ($ = {})); ; "use strict"; var $; (function ($) { let $hyoo_crus_unit_kind; (function ($hyoo_crus_unit_kind) { $hyoo_crus_unit_kind[$hyoo_crus_unit_kind["pass"] = $hyoo_crus_part.pass] = "pass"; $hyoo_crus_unit_kind[$hyoo_crus_unit_kind["gift"] = $hyoo_crus_part.gift] = "gift"; $hyoo_crus_unit_kind[$hyoo_crus_unit_kind["sand"] = $hyoo_crus_part.sand] = "sand"; })($hyoo_crus_unit_kind = $.$hyoo_crus_unit_kind || ($.$hyoo_crus_unit_kind = {})); $.$hyoo_crus_unit_trusted = new WeakSet(); class $hyoo_crus_unit extends $mol_buffer { static size = 128; constructor(buffer = new ArrayBuffer($hyoo_crus_unit.size), byteOffset = 0, byteLength = buffer.byteLength) { super(buffer, byteOffset, byteLength); } kind() { const val = this.uint8(0); if (!val) $mol_fail(new Error(`Empty unit`)); if ((val & 1) === 0) return 'sand'; const kind = $hyoo_crus_unit_kind[val]; if (kind) return kind; $mol_fail(new Error(`Unknown unit kind (${val})`)); } choose(ways) { const way = this.kind(); const Unit = { pass: $hyoo_crus_pass, gift: $hyoo_crus_gift, sand: $hyoo_crus_sand, }[way]; if (this instanceof Unit) return ways[way](this); const unit = new Unit(this.buffer, this.byteOffset, this.byteLength); return ways[way](unit); } narrow() { return this.choose({ sand: unit => unit, pass: unit => unit, gift: unit => unit, }); } key() { return this.narrow().key(); } id6(offset, next) { if (next === undefined) { const str = $mol_base64_ae_encode(new Uint8Array(this.buffer, this.byteOffset + offset, 6)); return str === 'AAAAAAAA' ? '' : str; } else { this.asArray().set($mol_base64_ae_decode(next || 'AAAAAAAA'), this.byteOffset + offset); return next; } } id12(offset, next) { if (next === undefined) { return $hyoo_crus_ref_decode(new Uint8Array(this.buffer, this.byteOffset + offset, 12)); } else { this.asArray().set($hyoo_crus_ref_encode(next), this.byteOffset + offset); return next; } } _peer; peer(next) { if (next === undefined && this._peer !== undefined) return this._peer; else return this._peer = this.id6(2, next); } salt() { return new Uint8Array(this.buffer, this.byteOffset + 2, 16); } sens(next) { const prev = new Uint8Array(this.buffer, this.byteOffset, 64); if (next) prev.set(next); return prev; } mix(mixin) { for (let i = 0; i < mixin.length; ++i) { this.uint8(2 + i, this.uint8(2 + i) ^ mixin[i]); } } sign(next) { const prev = new Uint8Array(this.buffer, this.byteOffset + 64, 64); if (next) prev.set(next); return prev; } signed() { return this.sign().some(b => b); } work() { if (!this.signed()) { return $hyoo_crus_rank_rate.just; } const sign = this.sign(); let int = sign[0] | (sign[1] << 8); let count = 0; while (int & 1) { int >>>= 1; ++count; } return count; } rank_min() { return $hyoo_crus_rank_rule; } _land = null; dump() { return {}; } } $.$hyoo_crus_unit = $hyoo_crus_unit; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $hyoo_crus_gift extends $hyoo_crus_unit { rank(next) { if (next !== undefined) this.uint8(0, $hyoo_crus_unit_kind.gift); const res = this.uint8(1, next); if (res < $hyoo_crus_rank_deny || res > $hyoo_crus_rank_rule) { $mol_fail(new RangeError(`Wrong rank ${res}`)); } return res; } time(next) { return this.uint48(8, next); } free() { return new Uint8Array(this.buffer, this.byteOffset + 26, 6); } _dest; dest(next) { if (next === undefined && this._dest !== undefined) return this._dest; else return this._dest = this.id12(14, next); } key() { return `gift:${this.dest().description}`; } bill() { return new Uint8Array(this.buffer, this.byteOffset + 32, 32); } static compare(left, right) { return (right.time() - left.time()) || (right.peer() > left.peer() ? 1 : right.peer() < left.peer() ? -1 : 0); } dump() { return { kind: this.kind(), peer: this.peer(), dest: this.dest().description, tier: $hyoo_crus_rank_tier[this.rank() & ~$hyoo_crus_rank_rate.just], work: this.work(), time: $hyoo_crus_time_dump(this.time()), }; } rank_min() { return $hyoo_crus_rank($hyoo_crus_rank_rule | ($hyoo_crus_rank_rate.just - this.work())); } [$mol_dev_format_head]() { return $mol_dev_format_span({}, $mol_dev_format_native(this), ' ', this.peer(), ' 🏅 ', $mol_dev_format_span({}, this.dest().description || '_'), this.bill().some(v => v) ? ' 🔐' : ' 👀', $hyoo_crus_rank_tier[this.rank() & ~$hyoo_crus_rank_rate.just], ':', this.rank() & $hyoo_crus_rank_rate.just, ' ', $mol_dev_format_shade($hyoo_crus_time_dump(this.time()))); } } $.$hyoo_crus_gift = $hyoo_crus_gift; })($ || ($ = {})); ; "use strict"; var $; (function ($) { let $hyoo_crus_sand_tag; (function ($hyoo_crus_sand_tag) { $hyoo_crus_sand_tag[$hyoo_crus_sand_tag["term"] = 0] = "term"; $hyoo_crus_sand_tag[$hyoo_crus_sand_tag["solo"] = 1] = "solo"; $hyoo_crus_sand_tag[$hyoo_crus_sand_tag["vals"] = 2] = "vals"; $hyoo_crus_sand_tag[$hyoo_crus_sand_tag["keys"] = 3] = "keys"; })($hyoo_crus_sand_tag = $.$hyoo_crus_sand_tag || ($.$hyoo_crus_sand_tag = {})); class $hyoo_crus_sand extends $hyoo_crus_unit { _vary = undefined; _open = null; hint(tip = 'nil', tag = 'term') { this.uint8(0, ($hyoo_crus_sand_tag[tag] << 1) | ($hyoo_crus_vary_tip[tip] << 3)); } tag() { return $hyoo_crus_sand_tag[(this.uint8(0) >> 1) & 0b11]; } tip() { const tip = $hyoo_crus_vary_tip[this.uint8(0) >> 3] || $hyoo_crus_vary_tip.nil; return tip; } utf() { return Boolean(this.uint8(0) & 0b10000000); } size(next) { return this.uint8(1, next); } time(next) { return this.uint48(8, next); } _head; head(next) { if (next === undefined && this._head !== undefined) return this._head; else return this._head = this.id6(14, next); } _self; self(next) { if (next === undefined && this._self !== undefined) return this._self; else return this._self = this.id6(20, next); } key() { return `sand:${this.head()}/${this.peer()}/${this.self()}`; } _lead; lead(next) { if (next === undefined && this._lead !== undefined) return this._lead; else return this._lead = this.id6(26, next); } hash(next, tip = 'nil', tag = 'term') { const bin = new Uint8Array(this.buffer, this.byteOffset + 32, 20); if (next !== undefined) { this.hint(tip, tag); this.size(255); bin.set(next); } if (this.size() > 32) return bin; $mol_fail(new Error('No stored hash')); } meta() { return new Uint8Array(this.buffer, this.byteOffset + 42, 12); } data(next, tip = 'nil', tag = 'term') { if (next === undefined) { const size = this.size(); if (size > 32) $mol_fail(new Error('Too long data')); return new Uint8Array(this.buffer, this.byteOffset + 32, size); } else { this.hint(tip, tag); if (next.byteLength > 32) $mol_fail(new Error('Too long data')); this.uint8(1, next.byteLength); const bin = new Uint8Array(this.buffer, this.byteOffset + 32, next.byteLength); bin.set(next); new Uint8Array(this.buffer, this.byteOffset + 32 + next.length, 32 - next.length).fill(0); return bin; } } idea() { const bin = new Uint8Array(this.buffer, this.byteOffset + 20, 44); const hash = $mol_crypto_hash(bin); const buf = new $mol_buffer(hash.buffer); return buf.uint48(0); } static compare(left, right) { return (Math.floor(right.time() / 65536) - Math.floor(left.time() / 65536)) || (right.peer() > left.peer() ? 1 : right.peer() < left.peer() ? -1 : 0) || (right.time() - left.time()); } dump() { return { kind: this.kind(), peer: this.peer(), lead: this.lead(), head: this.head(), self: this.self(), tip: this.tip(), tag: this.tag(), size: this.size(), time: $hyoo_crus_time_dump(this.time()), }; } rank_min() { return $hyoo_crus_rank($hyoo_crus_rank_tier.post | ($hyoo_crus_rank_rate.just - this.work())); } [$mol_dev_format_head]() { return $mol_dev_format_span({}, $mol_dev_format_native(this), ' ', this.peer(), ' ', this.lead() || 'AAAAAAAA', $mol_dev_format_shade('\\'), $mol_dev_format_accent(this.head() || 'AAAAAAAA'), $mol_dev_format_shade('/'), this.self() || 'AAAAAAAA', ' ', $mol_dev_format_shade($hyoo_crus_time_dump(this.time())), ' ', { term: '💼', solo: '1️⃣', vals: '🎹', keys: '🔑', }[this.tag()], this.tip(), ' ', $mol_dev_format_native(this._vary)); } } $.$hyoo_crus_sand = $hyoo_crus_sand; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_reconcile({ prev, from, to, next, equal, drop, insert, update, replace, }) { if (!update) update = (next, prev, lead) => prev; if (!replace) replace = (next, prev, lead) => insert(next, drop(prev, lead)); if (to > prev.length) to = prev.length; if (from > to) from = to; let p = from; let n = 0; let lead = p ? prev[p - 1] : null; while (p < to || n < next.length) { if (p < to && n < next.length && equal(next[n], prev[p])) { lead = update(next[n], prev[p], lead); ++p; ++n; } else if (next.length - n > to - p) { lead = insert(next[n], lead); ++n; } else if (next.length - n < to - p) { lead = drop(prev[p], lead); ++p; } else { lead = replace(next[n], prev[p], lead); ++p; ++n; } } } $.$mol_reconcile = $mol_reconcile; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $hyoo_crus_list_vary extends $hyoo_crus_node { static tag = $hyoo_crus_sand_tag[$hyoo_crus_sand_tag.vals]; items_vary(next, tag = 'term') { const units = this.units(); if (next === undefined) return units.map(unit => this.land().sand_decode(unit)); this.splice(next, 0, units.length, tag); return this.items_vary(); } splice(next, from = this.units().length, to = from, tag = 'term') { const land = this.land(); $mol_reconcile({ prev: this.units(), from, to, next, equal: (next, prev) => $mol_compare_deep(this.land().sand_decode(prev), next), drop: (prev, lead) => this.land().post(lead?.self() ?? '', prev.head(), prev.self(), null), insert: (next, lead) => this.land().post(lead?.self() ?? '', this.head(), land.self_make(), next, tag), replace: (next, prev, lead) => this.land().post(lead?.self() ?? '', prev.head(), prev.self(), next, prev.tag()), }); } find(vary) { for (const unit of this.units()) { if ($mol_compare_deep(this.land().sand_decode(unit), vary)) return unit; } return null; } has(vary, next, tag = 'term') { if (next === undefined) return Boolean(this.find(vary)); if (next) this.add(vary, tag); else this.cut(vary); return next; } add(vary, tag = 'term') { if (this.has(vary)) return; this.land().post('', this.head(), '', vary, tag); } cut(vary) { const units = [...this.units()]; for (let i = 0; i < units.length; ++i) { if (!$mol_compare_deep(this.land().sand_decode(units[i]), vary)) continue; this.land().post(units[i - 1]?.self() ?? 0, units[i].head(), units[i].self(), null); units.splice(i, 1); --i; } } move(from, to) { this.land().sand_move(this.units()[from], this.head(), to); } wipe(seat) { this.land().sand_wipe(this.units()[seat]); } node_make(Node, vary, tag = 'term') { this.splice([vary], undefined, undefined, tag); return this.land().Node(Node).Item(this.units().at(-1).self()); } ; [$mol_dev_format_head]() { return $mol_dev_format_span({}, $mol_dev_format_native(this), ' ', this.head(), ' ', $mol_dev_format_auto(this.items_vary())); } } __decorate([ $mol_mem ], $hyoo_crus_list_vary.prototype, "items_vary", null); __decorate([ $mol_action ], $hyoo_crus_list_vary.prototype, "splice", null); $.$hyoo_crus_list_vary = $hyoo_crus_list_vary; function $hyoo_crus_list(parse) { class $hyoo_crus_list extends $hyoo_crus_list_vary { static parse = parse; items(next) { return this.items_vary(next?.map(parse)).map(parse); } static toString() { return this === $hyoo_crus_list ? '$hyoo_crus_list<' + this.$.$mol_func_name(parse) + '>' : super.toString(); } } __decorate([ $mol_mem ], $hyoo_crus_list.prototype, "items", null); return $hyoo_crus_list; } $.$hyoo_crus_list = $hyoo_crus_list; class $hyoo_crus_list_bin extends $hyoo_crus_list($hyoo_crus_vary_cast_bin) { } $.$hyoo_crus_list_bin = $hyoo_crus_list_bin; class $hyoo_crus_list_bool extends $hyoo_crus_list($hyoo_crus_vary_cast_bool) { } $.$hyoo_crus_list_bool = $hyoo_crus_list_bool; class $hyoo_crus_list_int extends $hyoo_crus_list($hyoo_crus_vary_cast_int) { } $.$hyoo_crus_list_int = $hyoo_crus_list_int; class $hyoo_crus_list_real extends $hyoo_crus_list($hyoo_crus_vary_cast_real) { } $.$hyoo_crus_list_real = $hyoo_crus_list_real; class $hyoo_crus_list_ints extends $hyoo_crus_list($hyoo_crus_vary_cast_ints) { } $.$hyoo_crus_list_ints = $hyoo_crus_list_ints; class $hyoo_crus_list_reals extends $hyoo_crus_list($hyoo_crus_vary_cast_reals) { } $.$hyoo_crus_list_reals = $hyoo_crus_list_reals; class $hyoo_crus_list_ref extends $hyoo_crus_list($hyoo_crus_vary_cast_ref) { } $.$hyoo_crus_list_ref = $hyoo_crus_list_ref; class $hyoo_crus_list_str extends $hyoo_crus_list($hyoo_crus_vary_cast_str) { } $.$hyoo_crus_list_str = $hyoo_crus_list_str; class $hyoo_crus_list_time extends $hyoo_crus_list($hyoo_crus_vary_cast_time) { } $.$hyoo_crus_list_time = $hyoo_crus_list_time; class $hyoo_crus_list_dur extends $hyoo_crus_list($hyoo_crus_vary_cast_dur) { } $.$hyoo_crus_list_dur = $hyoo_crus_list_dur; class $hyoo_crus_list_range extends $hyoo_crus_list($hyoo_crus_vary_cast_range) { } $.$hyoo_crus_list_range = $hyoo_crus_list_range; class $hyoo_crus_list_json extends $hyoo_crus_list($hyoo_crus_vary_cast_json) { } $.$hyoo_crus_list_json = $hyoo_crus_list_json; class $hyoo_crus_list_jsan extends $hyoo_crus_list($hyoo_crus_vary_cast_jsan) { } $.$hyoo_crus_list_jsan = $hyoo_crus_list_jsan; class $hyoo_crus_list_dom extends $hyoo_crus_list($hyoo_crus_vary_cast_dom) { } $.$hyoo_crus_list_dom = $hyoo_crus_list_dom; class $hyoo_crus_list_tree extends $hyoo_crus_list($hyoo_crus_vary_cast_tree) { } $.$hyoo_crus_list_tree = $hyoo_crus_list_tree; class $hyoo_crus_list_ref_base extends $hyoo_crus_list_ref { } $.$hyoo_crus_list_ref_base = $hyoo_crus_list_ref_base; function $hyoo_crus_list_ref_to(Value) { class $hyoo_crus_list_ref_to extends $hyoo_crus_list_ref_base { static Value = $mol_memo.func(Value); static toString() { return this === $hyoo_crus_list_ref_to ? '$hyoo_crus_list_ref_to<' + Value() + '>' : super.toString(); } remote_list(next) { const glob = this.$.$hyoo_crus_glob; const Node = Value(); return this.items_vary(next?.map(item => item.ref())) .map($hyoo_crus_vary_cast_ref) .filter($mol_guard_defined) .map(ref => glob.Node(ref, Node)); } remote_add(item) { this.add(item.ref()); } make(config) { if (config === null || typeof config === 'number') { const self = this.land().self_make(config || undefined); const node = this.land().Node(Value()).Item(self); this.splice([node.ref()]); return node; } else if (config instanceof $hyoo_crus_land) { const land = config.area_make(); this.splice([land.ref()]); return land.Node(Value()).Item(''); } else if (config) { const land = this.$.$hyoo_crus_glob.land_grab(config); this.splice([land.ref()]); return land.Node(Value()).Item(''); } } remote_make(config) { return this.make(config); } local_make(idea) { const self = this.land().self_make(idea); const node = this.land().Node(Value()).Item(self); this.splice([node.ref()]); return node; } } __decorate([ $mol_mem ], $hyoo_crus_list_ref_to.prototype, "remote_list", null); __decorate([ $mol_action ], $hyoo_crus_list_ref_to.prototype, "remote_add", null); __decorate([ $mol_action ], $hyoo_crus_list_ref_to.prototype, "make", null); __decorate([ $mol_action ], $hyoo_crus_list_ref_to.prototype, "local_make", null); return $hyoo_crus_list_ref_to; } $.$hyoo_crus_list_ref_to = $hyoo_crus_list_ref_to; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $hyoo_crus_dict extends $hyoo_crus_list_vary { static tag = $hyoo_crus_sand_tag[$hyoo_crus_sand_tag.keys]; keys() { return this.items_vary(); } dive(key, Node, auto) { if (this.can_change() && auto !== undefined) this.has(key, true, Node.tag); const unit = this.find(key); return unit ? this.land().Node(Node).Item(unit.self()) : null; } static schema = {}; static with(schema) { const $hyoo_crus_dict_with = class $hyoo_crus_dict_with extends this { static toString() { if (this !== $hyoo_crus_dict_with) return super.toString(); const params = Object.entries(schema).map(([name, type]) => `${name}: ${type}`); return '$hyoo_crus_dict.with<{' + params.join(', ') + '}>'; } }; for (const Field in schema) { Object.defineProperty($hyoo_crus_dict_with.prototype, Field, { value: function (auto) { return this.dive(Field, schema[Field], auto); } }); } return Object.assign($hyoo_crus_dict_with, { schema: { ...this.schema, ...schema } }); } ; [$mol_dev_format_head]() { const keys = $mol_wire_probe(() => this.keys()); const nodes = $mol_wire_probe(() => this.nodes(null)) ?? []; return $mol_dev_format_span({}, $mol_dev_format_native(this), ' ', this.head(), ' ', $mol_dev_format_auto(keys?.map((key, index) => new Pair(key, nodes[index])))); } } __decorate([ $mol_mem ], $hyoo_crus_dict.prototype, "keys", null); $.$hyoo_crus_dict = $hyoo_crus_dict; class Pair { key; val; constructor(key, val) { this.key = key; this.val = val; } ; [$mol_dev_format_head]() { return $mol_dev_format_tr({}, $mol_dev_format_td({}, $mol_dev_format_auto(this.key)), $mol_dev_format_td({}, ': '), $mol_dev_format_td({}, $mol_dev_format_auto(this.val))); } } function $hyoo_crus_dict_to(Value) { return class $hyoo_crus_dict_to extends $hyoo_crus_dict { Value = Value; key(key, auto) { return this.dive(key, this.Value, auto); } static toString() { return this === $hyoo_crus_dict_to ? '$hyoo_crus_dict_to<' + Value + '>' : super.toString(); } }; } $.$hyoo_crus_dict_to = $hyoo_crus_dict_to; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_hash_string(str, seed = 0) { let h1 = 0xdeadbeef ^ seed; let h2 = 0x41c6ce57 ^ seed; for (let i = 0; i < str.length; i++) { const ch = str.charCodeAt(i); h1 = Math.imul(h1 ^ ch, 2654435761); h2 = Math.imul(h2 ^ ch, 1597334677); } h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909); h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909); return 4294967296 * (((1 << 16) - 1) & h2) + (h1 >>> 0); } $.$mol_hash_string = $mol_hash_string; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $hyoo_crus_atom_vary extends $hyoo_crus_node { static tag = $hyoo_crus_sand_tag[$hyoo_crus_sand_tag.solo]; pick_unit(peer) { return this.units_of(peer).at(0); } vary(next) { return this.vary_of('', next); } vary_of(peer, next) { let unit_prev = this.pick_unit(peer); let prev = unit_prev ? this.land().sand_decode(unit_prev) : null; if (next === undefined) return prev; if ($mol_compare_deep(prev, next)) return next; this.land().post('', unit_prev?.head() ?? this.head(), unit_prev?.self() ?? '', next); return this.vary_of(peer); } ; [$mol_dev_format_head]() { return $mol_dev_format_span({}, $mol_dev_format_native(this), ' ', this.head(), ' ', $mol_dev_format_auto(this.vary())); } } __decorate([ $mol_mem_key ], $hyoo_crus_atom_vary.prototype, "vary_of", null); $.$hyoo_crus_atom_vary = $hyoo_crus_atom_vary; class $hyoo_crus_atom_enum_base extends $hyoo_crus_atom_vary { static options = []; } $.$hyoo_crus_atom_enum_base = $hyoo_crus_atom_enum_base; function $hyoo_crus_atom_enum(options) { class $hyoo_crus_atom_enum extends $hyoo_crus_atom_enum_base { static options = options; static toString() { return this === $hyoo_crus_atom_enum ? '$hyoo_crus_atom_enum<' + options.map($hyoo_crus_vary_cast_str) + '>' : super.toString(); } val(next) { return this.val_of('', next); } val_of(peer, next) { validate: if (next !== undefined) { for (const option of options) { if ($mol_compare_deep(option, next)) break validate; } $mol_fail(new Error(`Wrong value (${$hyoo_crus_vary_cast_str(next)})`)); } const val = this.vary_of(peer, next); for (const option of options) { if ($mol_compare_deep(option, val)) return val; } return null; } } __decorate([ $mol_mem_key ], $hyoo_crus_atom_enum.prototype, "val_of", null); return $hyoo_crus_atom_enum; } $.$hyoo_crus_atom_enum = $hyoo_crus_atom_enum; function $hyoo_crus_atom(parse) { class $hyoo_crus_atom extends $hyoo_crus_atom_vary { static parse = parse; val(next) { return this.val_of('', next); } val_of(peer, next) { if (next !== undefined) parse(next); const res = this.vary_of(peer, next); try { return parse(res); } catch { return null; } } static toString() { return this === $hyoo_crus_atom ? '$hyoo_crus_atom<' + this.$.$mol_func_name(parse) + '>' : super.toString(); } } return $hyoo_crus_atom; } $.$hyoo_crus_atom = $hyoo_crus_atom; class $hyoo_crus_atom_bin extends $hyoo_crus_atom($hyoo_crus_vary_cast_bin) { } $.$hyoo_crus_atom_bin = $hyoo_crus_atom_bin; class $hyoo_crus_atom_bool extends $hyoo_crus_atom($hyoo_crus_vary_cast_bool) { } $.$hyoo_crus_atom_bool = $hyoo_crus_atom_bool; class $hyoo_crus_atom_int extends $hyoo_crus_atom($hyoo_crus_vary_cast_int) { } $.$hyoo_crus_atom_int = $hyoo_crus_atom_int; class $hyoo_crus_atom_real extends $hyoo_crus_atom($hyoo_crus_vary_cast_real) { } $.$hyoo_crus_atom_real = $hyoo_crus_atom_real; class $hyoo_crus_atom_ints extends $hyoo_crus_atom($hyoo_crus_vary_cast_ints) { } $.$hyoo_crus_atom_ints = $hyoo_crus_atom_ints; class $hyoo_crus_atom_reals extends $hyoo_crus_atom($hyoo_crus_vary_cast_reals) { } $.$hyoo_crus_atom_reals = $hyoo_crus_atom_reals; class $hyoo_crus_atom_ref extends $hyoo_crus_atom($hyoo_crus_vary_cast_ref) { } $.$hyoo_crus_atom_ref = $hyoo_crus_atom_ref; class $hyoo_crus_atom_str extends $hyoo_crus_atom($hyoo_crus_vary_cast_str) { } $.$hyoo_crus_atom_str = $hyoo_crus_atom_str; class $hyoo_crus_atom_time extends $hyoo_crus_atom($hyoo_crus_vary_cast_time) { } $.$hyoo_crus_atom_time = $hyoo_crus_atom_time; class $hyoo_crus_atom_dur extends $hyoo_crus_atom($hyoo_crus_vary_cast_dur) { } $.$hyoo_crus_atom_dur = $hyoo_crus_atom_dur; class $hyoo_crus_atom_range extends $hyoo_crus_atom($hyoo_crus_vary_cast_range) { } $.$hyoo_crus_atom_range = $hyoo_crus_atom_range; class $hyoo_crus_atom_json extends $hyoo_crus_atom($hyoo_crus_vary_cast_json) { } $.$hyoo_crus_atom_json = $hyoo_crus_atom_json; class $hyoo_crus_atom_jsan extends $hyoo_crus_atom($hyoo_crus_vary_cast_jsan) { } $.$hyoo_crus_atom_jsan = $hyoo_crus_atom_jsan; class $hyoo_crus_atom_dom extends $hyoo_crus_atom($hyoo_crus_vary_cast_dom) { } $.$hyoo_crus_atom_dom = $hyoo_crus_atom_dom; class $hyoo_crus_atom_tree extends $hyoo_crus_atom($hyoo_crus_vary_cast_tree) { } $.$hyoo_crus_atom_tree = $hyoo_crus_atom_tree; class $hyoo_crus_atom_ref_base extends $hyoo_crus_atom_ref { static Value = $hyoo_crus_dict; } $.$hyoo_crus_atom_ref_base = $hyoo_crus_atom_ref_base; function $hyoo_crus_atom_ref_to(Value) { class $hyoo_crus_atom_ref_to extends $hyoo_crus_atom_ref_base { Value = $mol_memo.func(Value); static toString() { return this === $hyoo_crus_atom_ref_to ? '$hyoo_crus_atom_ref_to<' + Value() + '>' : super.toString(); } remote(next) { return this.remote_of('', next); } remote_of(peer, next) { let ref = next?.ref() ?? next; ref = $hyoo_crus_vary_cast_ref(this.vary_of(peer, ref)); if (!ref) return null; return this.$.$hyoo_crus_glob.Node(ref, Value()); } ensure(config) { return this.ensure_of('', config); } ensure_of(peer, config) { if (!this.val_of(peer)) { if (config === null) this.ensure_here(peer); else if (config instanceof $hyoo_crus_land) this.ensure_area(peer, config); else if (config) this.ensure_lord(peer, config); else return null; } return this.remote_of(peer); } ensure_here(peer) { const idea = $mol_hash_string(this.ref().description); const head = this.land().self_make(idea); const node = this.land().Node(Value()).Item(head); this.remote_of(peer, node); } ensure_area(peer, land) { const idea = $mol_hash_string(this.ref().description); const area = land.area_make(idea); this.val_of(peer, area.ref()); } ensure_lord(peer, preset) { const land = this.$.$hyoo_crus_glob.land_grab(preset); this.val_of(peer, land.ref()); } remote_ensure(preset) { return this.ensure(preset); } local_ensure() { return this.ensure(null); } } __decorate([ $mol_mem_key ], $hyoo_crus_atom_ref_to.prototype, "remote_of", null); __decorate([ $mol_action ], $hyoo_crus_atom_ref_to.prototype, "ensure_here", null); __decorate([ $mol_action ], $hyoo_crus_atom_ref_to.prototype, "ensure_area", null); __decorate([ $mol_action ], $hyoo_crus_atom_ref_to.prototype, "ensure_lord", null); return $hyoo_crus_atom_ref_to; } $.$hyoo_crus_atom_ref_to = $hyoo_crus_atom_ref_to; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $hyoo_crus_entity extends $hyoo_crus_dict.with({ Title: $hyoo_crus_atom_str, }) { title(next) { return this.Title(next)?.val(next) ?? ''; } } __decorate([ $mol_mem ], $hyoo_crus_entity.prototype, "title", null); $.$hyoo_crus_entity = $hyoo_crus_entity; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $hyoo_crus_home extends $hyoo_crus_entity.with({ Selection: $hyoo_crus_atom_str, Hall: $hyoo_crus_atom_ref_to(() => $hyoo_crus_dict), }) { hall_by(Node, preset) { return this.Hall(null)?.ensure(preset)?.cast(Node) ?? null; } } $.$hyoo_crus_home = $hyoo_crus_home; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $hyoo_crus_mine extends $mol_object { static unit_updates = 0; static unit_appends = 0; static rock_writes = 0; static hash(blob) { return $mol_crypto_hash(blob); } static rock(hash, next) { $mol_wire_solid(); return next ?? null; } static rock_save(blob) { const hash = this.hash(blob); this.rock(hash, blob); this.rock(hash); return hash; } static units_persisted = new WeakSet(); static units(land, next) { if (next) return $mol_wire_sync(this).units_save(land, next), next; else return $mol_wire_sync(this).units_load(land); } static async units_load(land) { return []; } static async units_save(land, units) { } } __decorate([ $mol_mem_key ], $hyoo_crus_mine, "hash", null); __decorate([ $mol_mem_key ], $hyoo_crus_mine, "rock", null); __decorate([ $mol_action ], $hyoo_crus_mine, "rock_save", null); $.$hyoo_crus_mine = $hyoo_crus_mine; })($ || ($ = {})); ; "use strict"; var $; (function ($) { function $mol_db_response(request) { return new Promise((done, fail) => { request.onerror = () => fail(new Error(request.error.message)); request.onsuccess = () => done(request.result); }); } $.$mol_db_response = $mol_db_response; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_db_store { native; constructor(native) { this.native = native; } get name() { return this.native.name; } get path() { return this.native.keyPath; } get incremental() { return this.native.autoIncrement; } get indexes() { return new Proxy({}, { ownKeys: () => [...this.native.indexNames], has: (_, name) => this.native.indexNames.contains(name), get: (_, name) => new $mol_db_index(this.native.index(name)) }); } index_make(name, path = [], unique = false, multiEntry = false) { return this.native.createIndex(name, path, { multiEntry, unique }); } index_drop(name) { this.native.deleteIndex(name); return this; } get transaction() { return new $mol_db_transaction(this.native.transaction); } get db() { return this.transaction.db; } clear() { return $mol_db_response(this.native.clear()); } count(keys) { return $mol_db_response(this.native.count(keys)); } put(doc, key) { return $mol_db_response(this.native.put(doc, key)); } get(key) { return $mol_db_response(this.native.get(key)); } select(key, count) { return $mol_db_response(this.native.getAll(key, count)); } drop(keys) { return $mol_db_response(this.native.delete(keys)); } } $.$mol_db_store = $mol_db_store; })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { class $mol_db_index { native; constructor(native) { this.native = native; } get name() { return this.native.name; } get paths() { return this.native.keyPath; } get unique() { return this.native.unique; } get multiple() { return this.native.multiEntry; } get store() { return new $mol_db_store(this.native.objectStore); } get transaction() { return this.store.transaction; } get db() { return this.store.db; } count(keys) { return $mol_db_response(this.native.count(keys)); } get(key) { return $mol_db_response(this.native.get(key)); } select(key, count) { return $mol_db_response(this.native.getAll(key, count)); } } $.$mol_db_index = $mol_db_index; })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { async function $mol_db(name, ...migrations) { const request = this.$mol_dom_context.indexedDB.open(name, migrations.length ? migrations.length + 1 : undefined); request.onupgradeneeded = event => { migrations.splice(0, event.oldVersion - 1); const transaction = new $mol_db_transaction(request.transaction); for (const migrate of migrations) migrate(transaction); }; const db = await $mol_db_response(request); return new $mol_db_database(db); } $.$mol_db = $mol_db; })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { class $mol_db_database { native; constructor(native) { this.native = native; } get name() { return this.native.name; } get version() { return this.native.version; } get stores() { return [...this.native.objectStoreNames]; } read(...names) { return new $mol_db_transaction(this.native.transaction(names, 'readonly', { durability: 'relaxed' })).stores; } change(...names) { return new $mol_db_transaction(this.native.transaction(names, 'readwrite', { durability: 'relaxed' })); } kill() { this.native.close(); const request = $mol_dom_context.indexedDB.deleteDatabase(this.name); request.onblocked = console.warn; return $mol_db_response(request); } destructor() { this.native.close(); } } $.$mol_db_database = $mol_db_database; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $mol_db_transaction { native; constructor(native) { this.native = native; } get stores() { return new Proxy({}, { ownKeys: () => [...this.native.objectStoreNames], has: (_, name) => this.native.objectStoreNames.contains(name), get: (_, name, proxy) => (name in proxy) ? new $mol_db_store(this.native.objectStore(name)) : undefined, }); } store_make(name) { return this.native.db.createObjectStore(name, { autoIncrement: true }); } store_drop(name) { this.native.db.deleteObjectStore(name); return this; } abort() { if (this.native.error) return; this.native.abort(); } commit() { this.native.commit?.(); return new Promise((done, fail) => { this.native.onerror = () => fail(new Error(this.native.error.message)); this.native.oncomplete = () => done(); }); } get db() { return new $mol_db_database(this.native.db); } } $.$mol_db_transaction = $mol_db_transaction; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $hyoo_crus_mine_idb extends $hyoo_crus_mine { static rock(hash, next) { const prev = $mol_mem_cached(() => this.rock(hash)); if (prev) return prev; if (next) { this.rock_change().then(Rock => Rock.put(next.buffer, [hash])); return next; } else { const buf = $mol_wire_sync(this.rock_read()).get([hash]); return buf ? new Uint8Array(buf) : null; } } static rock_read() { const db = this.db_sync(); return $mol_wire_sync(db).read('Rock').Rock; } static async rock_change() { const db = await this.db(); return db.change('Rock').stores.Rock; } static async units_save(land, units) { $hyoo_crus_land; const land_ref = land.description; const db = await this.db(); const change = db.change('Land'); const { Land } = change.stores; for (const unit of units) { Land.put(unit.buffer, [land_ref, unit.key()]); this.units_persisted.add(unit); } await change.commit(); } static async units_load(land) { const db = await this.db(); const { Land } = db.read('Land'); const land_ref = land.description; const land_key = IDBKeyRange.bound([land_ref, ''], [land_ref, '\uFFFF']); const res = await Land.select(land_key); const units = res.map(bin => new $hyoo_crus_unit(bin).narrow()); for (const unit of units) { this.units_persisted.add(unit); $hyoo_crus_unit_trusted.add(unit); } return units; } static db_sync() { $mol_wire_solid(); return $mol_wire_sync(this).db(); } static async db() { return await this.$.$mol_db('$hyoo_crus', mig => mig.store_make('Rock'), mig => mig.store_make('Land'), mig => mig.stores.Land.clear(), mig => mig.stores.Land.clear(), mig => mig.stores.Land.clear()); } } __decorate([ $mol_mem_key ], $hyoo_crus_mine_idb, "rock", null); __decorate([ $mol_action ], $hyoo_crus_mine_idb, "rock_read", null); __decorate([ $mol_mem ], $hyoo_crus_mine_idb, "db_sync", null); __decorate([ $mol_memo.method ], $hyoo_crus_mine_idb, "db", null); $.$hyoo_crus_mine_idb = $hyoo_crus_mine_idb; })($ || ($ = {})); ; "use strict"; var $; (function ($) { $.$hyoo_crus_mine = $hyoo_crus_mine_idb; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $hyoo_crus_pass extends $hyoo_crus_unit { _lord; lord(next) { if (next === undefined && this._lord !== undefined) return this._lord; else return this._lord = this.id12(2, next); } key() { return `pass:${this.id6(2)}`; } auth(next) { const prev = new Uint8Array(this.buffer, this.byteOffset, 64); if (next) prev.set(next); return prev; } dump() { return { kind: this.kind(), lord: this.lord().description, }; } rank_min() { return $hyoo_crus_rank($hyoo_crus_rank_tier.join | ($hyoo_crus_rank_rate.just - this.work())); } [$mol_dev_format_head]() { return $mol_dev_format_span({}, $mol_dev_format_native(this), ' ', this.peer(), ' 🔑 ', $mol_dev_format_span({}, this.lord().description)); } } $.$hyoo_crus_pass = $hyoo_crus_pass; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $hyoo_crus_auth extends $mol_crypto_key_private { static current(next) { $mol_wire_solid(); if (next === undefined) { const key = String($mol_state_local.value('$hyoo_crus_auth') ?? ''); if (key) return $hyoo_crus_auth.from(key); } if (!next) next = this.grab(); $mol_state_local.value('$hyoo_crus_auth', next.toString()); return next; } static embryos = []; static grab() { if (this.embryos.length) return this.from(this.embryos.pop()); return $mol_wire_sync(this).generate(); } static async generate() { for (let i = 0; i < 4096; ++i) { const auth = await super.generate(); if (auth.uint8(0) !== $hyoo_crus_unit_kind.pass) continue; return this.from(auth); } $mol_fail(new Error(`Too long key generation`)); } lord() { return $hyoo_crus_ref_decode(new Uint8Array(this.buffer, 2, 12)); } peer() { return $mol_base64_ae_encode(new Uint8Array(this.buffer, 2, 6)); } secret_mutual(pub) { return $mol_wire_sync($mol_crypto_secret).derive(this.toString(), pub.toString()); } } __decorate([ $mol_memo.method ], $hyoo_crus_auth.prototype, "lord", null); __decorate([ $mol_memo.method ], $hyoo_crus_auth.prototype, "peer", null); __decorate([ $mol_mem_key ], $hyoo_crus_auth.prototype, "secret_mutual", null); __decorate([ $mol_mem ], $hyoo_crus_auth, "current", null); __decorate([ $mol_action ], $hyoo_crus_auth, "grab", null); $.$hyoo_crus_auth = $hyoo_crus_auth; })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $hyoo_crus_glob extends $mol_object { static lands_touched = new $mol_wire_set(); lands_touched = this.constructor.lands_touched; static yard() { return new this.$.$hyoo_crus_yard; } yard() { return this.$.$hyoo_crus_glob.yard(); } static home(Node) { return this.Land(this.$.$hyoo_crus_auth.current().lord()).Data(Node ?? $hyoo_crus_home); } home() { return this.$.$hyoo_crus_glob.home(); } static king_grab(preset = { '': $hyoo_crus_rank_read }) { const king = this.$.$hyoo_crus_auth.grab(); const colony = $mol_wire_sync($hyoo_crus_land).make({ $: this.$ }); colony.auth = $mol_const(king); if ((preset[''] ?? $hyoo_crus_rank_deny) === $hyoo_crus_rank_deny) { colony.encrypted(true); } const self = this.$.$hyoo_crus_auth.current(); colony.give(self, $hyoo_crus_rank_rule); for (const key in preset) colony.give(key ? $hyoo_crus_auth.from(key) : null, preset[key]); this.Land(colony.ref()).apply_unit(colony.delta_unit()); return king; } king_grab(preset = { '': $hyoo_crus_rank_read }) { return this.$.$hyoo_crus_glob.king_grab(preset); } static land_grab(preset = { '': $hyoo_crus_rank_read }) { return this.Land(this.king_grab(preset).lord()); } land_grab(preset = { '': $hyoo_crus_rank_read }) { return this.$.$hyoo_crus_glob.land_grab(preset); } static Land(ref) { this.lands_touched.add(ref); return $hyoo_crus_land.make({ ref: $mol_const(ref), }); } Land(ref) { return this.$.$hyoo_crus_glob.Land(ref); } static Node(ref, Node) { const land = this.Land($hyoo_crus_ref_land(ref)); return land.Node(Node).Item($hyoo_crus_ref_head(ref)); } Node(ref, Node) { return this.$.$hyoo_crus_glob.Node(ref, Node); } static apply_pack(pack) { const { lands, rocks } = pack.parts(); return this.apply_parts(lands, rocks); } apply_pack(pack) { return this.$.$hyoo_crus_glob.apply_pack(pack); } static apply_parts(lands, rocks) { for (const land of Reflect.ownKeys(lands)) { const errors = this.Land(land).apply_unit(lands[land].units).filter(Boolean); for (const error of errors) this.$.$mol_log3_warn({ place: `${this}.apply_pack()`, message: error, hint: 'Send it to developer', }); } for (const [hash, rock] of rocks) { if (!rock) continue; this.$.$hyoo_crus_mine.rock_save(rock); } } apply_parts(lands, rocks) { return this.$.$hyoo_crus_glob.apply_parts(lands, rocks); } } __decorate([ $mol_mem ], $hyoo_crus_glob, "yard", null); __decorate([ $mol_action ], $hyoo_crus_glob, "king_grab", null); __decorate([ $mol_action ], $hyoo_crus_glob, "land_grab", null); __decorate([ $mol_mem_key ], $hyoo_crus_glob, "Land", null); __decorate([ $mol_action ], $hyoo_crus_glob, "apply_pack", null); __decorate([ $mol_action ], $hyoo_crus_glob, "apply_parts", null); $.$hyoo_crus_glob = $hyoo_crus_glob; })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $hd_canary_app_profile extends $.$hd_canary_app_profile { auth_title() { return this.key_import() ? "Войти в профиль" : "Поделиться профилем"; } key_import(next) { return this.$.$mol_state_arg.value('auth', next) ?? null; } current_peer() { return this.$.$hyoo_crus_auth.current().peer(); } home() { const home = this.$.$hyoo_crus_glob.home($hd_canary_app_home); home.land().give(null, $hyoo_crus_rank_rule); return home; } home_land() { return this.home().land_ref().description; } profile_name(next) { return this.home().title(next); } } __decorate([ $mol_mem ], $hd_canary_app_profile.prototype, "auth_title", null); __decorate([ $mol_mem ], $hd_canary_app_profile.prototype, "current_peer", null); __decorate([ $mol_mem ], $hd_canary_app_profile.prototype, "home", null); __decorate([ $mol_mem ], $hd_canary_app_profile.prototype, "home_land", null); __decorate([ $mol_mem ], $hd_canary_app_profile.prototype, "profile_name", null); $$.$hd_canary_app_profile = $hd_canary_app_profile; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { var $$; (function ($$) { const { rem } = $mol_style_unit; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; ($.$mol_icon_bird) = class $mol_icon_bird extends ($.$mol_icon) { path(){ return "M23 11.5L19.95 10.37C19.69 9.22 19.04 8.56 19.04 8.56C17.4 6.92 14.75 6.92 13.11 8.56L11.63 10.04L5 3C4 7 5 11 7.45 14.22L2 19.5C2 19.5 10.89 21.5 16.07 17.45C18.83 15.29 19.45 14.03 19.84 12.7L23 11.5M17.71 11.72C17.32 12.11 16.68 12.11 16.29 11.72C15.9 11.33 15.9 10.7 16.29 10.31C16.68 9.92 17.32 9.92 17.71 10.31C18.1 10.7 18.1 11.33 17.71 11.72Z"; } }; ; "use strict"; ; ($.$hd_canary_app) = class $hd_canary_app extends ($.$mol_book2_catalog) { Theme(){ const obj = new this.$.$mol_theme_auto(); return obj; } Lighter(){ const obj = new this.$.$mol_lights_toggle(); return obj; } share_link(){ return "https://hyoo.ru"; } Share_hyoo(){ const obj = new this.$.$mol_button_share(); (obj.title) = () => (""); (obj.hint) = () => ("Поделиться мониторами"); (obj.uri) = () => ((this.share_link())); (obj.capture) = () => (null); return obj; } List(){ const obj = new this.$.$hd_canary_app_bar(); return obj; } Profile(){ const obj = new this.$.$hd_canary_app_profile(); return obj; } plugins(){ return [(this.Theme())]; } Menu_logo(){ const obj = new this.$.$mol_icon_bird(); return obj; } menu_tools(){ return [(this.Lighter()), (this.Share_hyoo())]; } menu_title(){ return (this.$.$mol_locale.text("$hd_canary_app_menu_title")); } spreads(){ return {"monitor": (this.List()), "profile": (this.Profile())}; } }; ($mol_mem(($.$hd_canary_app.prototype), "Theme")); ($mol_mem(($.$hd_canary_app.prototype), "Lighter")); ($mol_mem(($.$hd_canary_app.prototype), "Share_hyoo")); ($mol_mem(($.$hd_canary_app.prototype), "List")); ($mol_mem(($.$hd_canary_app.prototype), "Profile")); ($mol_mem(($.$hd_canary_app.prototype), "Menu_logo")); ; ($.$mol_chip) = class $mol_chip extends ($.$mol_view) { hint(){ return ""; } minimal_height(){ return 40; } attr(){ return {...(super.attr()), "title": (this.hint())}; } sub(){ return [(this.title())]; } }; ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { $mol_style_define($mol_chip, { padding: $mol_gap.text, border: { radius: $mol_gap.round, }, background: { color: $mol_theme.card, }, gap: $mol_gap.block, }); })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; ($.$mol_icon_plus) = class $mol_icon_plus extends ($.$mol_icon) { path(){ return "M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z"; } }; ; "use strict"; ; ($.$mol_gallery) = class $mol_gallery extends ($.$mol_view) { items(){ return []; } side_size(id){ return "1"; } side_items(id){ return []; } sub(){ return (this.items()); } Side(id){ const obj = new this.$.$mol_gallery(); (obj.style) = () => ({"flexGrow": (this.side_size(id))}); (obj.items) = () => ((this.side_items(id))); return obj; } }; ($mol_mem_key(($.$mol_gallery.prototype), "Side")); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_gallery extends $.$mol_gallery { sub() { const items = this.items(); if (items.length <= 3) return items; return [ this.Side(0), this.Side(1), ]; } side_items(id) { const items = this.items(); const middle = items.length % 2 ? Math.ceil(items.length / 3) : items.length / 2; return id ? items.slice(middle) : items.slice(0, middle); } side_size(id) { return String(this.side_items(id).length); } } __decorate([ $mol_mem ], $mol_gallery.prototype, "sub", null); __decorate([ $mol_mem_key ], $mol_gallery.prototype, "side_items", null); $$.$mol_gallery = $mol_gallery; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { $mol_style_attach("mol/gallery/gallery.view.css", "[mol_gallery] {\n\tflex-wrap: wrap;\n\tflex: 1 1 auto;\n\talign-items: stretch;\n align-content: stretch;\n}\n"); })($ || ($ = {})); ; ($.$hd_canary_app_monitor) = class $hd_canary_app_monitor extends ($.$mol_page) { go_to_home(){ return null; } panel_title(){ return (this.$.$mol_locale.text("$hd_canary_app_monitor_panel_title")); } Theme(){ const obj = new this.$.$mol_theme_auto(); return obj; } status_total(){ return ""; } Status_total(){ const obj = new this.$.$mol_chip(); (obj.title) = () => ((this.status_total())); return obj; } add_url(next){ if(next !== undefined) return next; return ""; } add_submit(next){ if(next !== undefined) return next; return null; } Add_url(){ const obj = new this.$.$mol_string(); (obj.hint) = () => ((this.$.$mol_locale.text("$hd_canary_app_monitor_Add_url_hint"))); (obj.value) = (next) => ((this.add_url(next))); (obj.submit) = (next) => ((this.add_submit(next))); return obj; } add_title(next){ if(next !== undefined) return next; return ""; } Add_title(){ const obj = new this.$.$mol_string(); (obj.hint) = () => ((this.$.$mol_locale.text("$hd_canary_app_monitor_Add_title_hint"))); (obj.value) = (next) => ((this.add_title(next))); (obj.submit) = (next) => ((this.add_submit(next))); return obj; } Add_submit_icon(){ const obj = new this.$.$mol_icon_plus(); return obj; } Add_submit(){ const obj = new this.$.$mol_button_minor(); (obj.hint) = () => ((this.$.$mol_locale.text("$hd_canary_app_monitor_Add_submit_hint"))); (obj.click) = (next) => ((this.add_submit(next))); (obj.sub) = () => ([(this.Add_submit_icon())]); return obj; } Add(){ const obj = new this.$.$mol_view(); (obj.sub) = () => ([ (this.Add_url()), (this.Add_title()), (this.Add_submit()) ]); return obj; } target_status(id){ return ""; } Target_status(id){ const obj = new this.$.$mol_view(); (obj.sub) = () => ([(this.target_status(id))]); return obj; } target_title(id){ return ""; } target_url(id){ return ""; } Target_url(id){ const obj = new this.$.$mol_link(); (obj.title) = () => ((this.target_title(id))); (obj.uri) = () => ((this.target_url(id))); return obj; } target_remove(id){ return null; } Target_remove_icon(id){ const obj = new this.$.$mol_icon_close(); return obj; } Target_remove(id){ const obj = new this.$.$mol_button_minor(); (obj.click) = () => ((this.target_remove(id))); (obj.sub) = () => ([(this.Target_remove_icon(id))]); return obj; } Target_main(id){ const obj = new this.$.$mol_view(); (obj.sub) = () => ([ (this.Target_status(id)), (this.Target_url(id)), (this.Target_remove(id)) ]); return obj; } target_message(id, next){ if(next !== undefined) return next; return ""; } Target_message(id){ const obj = new this.$.$mol_view(); (obj.sub) = () => ([(this.target_message(id))]); return obj; } waiting_hint(){ return (this.$.$mol_locale.text("$hd_canary_app_monitor_waiting_hint")); } target_moment(id, next){ if(next !== undefined) return next; return (this.waiting_hint()); } Target_moment(id){ const obj = new this.$.$mol_view(); (obj.sub) = () => ([(this.target_moment(id))]); return obj; } target_rows(id){ return [ (this.Target_main(id)), (this.Target_message(id)), (this.Target_moment(id)) ]; } Target(id){ const obj = new this.$.$mol_list(); (obj.rows) = () => ((this.target_rows(id))); return obj; } target_list(){ return [(this.Target("0"))]; } Target_list(){ const obj = new this.$.$mol_gallery(); (obj.items) = () => ((this.target_list())); return obj; } home(){ const obj = new this.$.$hd_canary_app_home(); return obj; } Home_button(){ const obj = new this.$.$mol_button_minor(); (obj.title) = () => ("Домой"); (obj.click) = () => ((this.go_to_home())); return obj; } title(){ return (this.panel_title()); } targets(next){ if(next !== undefined) return next; return {}; } target_result(id, next){ if(next !== undefined) return next; return 1; } plugins(){ return [(this.Theme())]; } head(){ return [ (this.Status_total()), (this.Title()), (this.Add()), (this.Tools()) ]; } body(){ return [(this.Target_list())]; } }; ($mol_mem(($.$hd_canary_app_monitor.prototype), "Theme")); ($mol_mem(($.$hd_canary_app_monitor.prototype), "Status_total")); ($mol_mem(($.$hd_canary_app_monitor.prototype), "add_url")); ($mol_mem(($.$hd_canary_app_monitor.prototype), "add_submit")); ($mol_mem(($.$hd_canary_app_monitor.prototype), "Add_url")); ($mol_mem(($.$hd_canary_app_monitor.prototype), "add_title")); ($mol_mem(($.$hd_canary_app_monitor.prototype), "Add_title")); ($mol_mem(($.$hd_canary_app_monitor.prototype), "Add_submit_icon")); ($mol_mem(($.$hd_canary_app_monitor.prototype), "Add_submit")); ($mol_mem(($.$hd_canary_app_monitor.prototype), "Add")); ($mol_mem_key(($.$hd_canary_app_monitor.prototype), "Target_status")); ($mol_mem_key(($.$hd_canary_app_monitor.prototype), "Target_url")); ($mol_mem_key(($.$hd_canary_app_monitor.prototype), "Target_remove_icon")); ($mol_mem_key(($.$hd_canary_app_monitor.prototype), "Target_remove")); ($mol_mem_key(($.$hd_canary_app_monitor.prototype), "Target_main")); ($mol_mem_key(($.$hd_canary_app_monitor.prototype), "target_message")); ($mol_mem_key(($.$hd_canary_app_monitor.prototype), "Target_message")); ($mol_mem_key(($.$hd_canary_app_monitor.prototype), "target_moment")); ($mol_mem_key(($.$hd_canary_app_monitor.prototype), "Target_moment")); ($mol_mem_key(($.$hd_canary_app_monitor.prototype), "Target")); ($mol_mem(($.$hd_canary_app_monitor.prototype), "Target_list")); ($mol_mem(($.$hd_canary_app_monitor.prototype), "home")); ($mol_mem(($.$hd_canary_app_monitor.prototype), "Home_button")); ($mol_mem(($.$hd_canary_app_monitor.prototype), "targets")); ($mol_mem_key(($.$hd_canary_app_monitor.prototype), "target_result")); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { $hyoo_crus_yard.masters = [ $mol_dom_context.document.location.origin + '/', ]; class $hd_canary_app_monitor extends $.$hd_canary_app_monitor { status_total() { return this.home().Sites(null).remote_list().every(key => key.last_ping_status()?.val() == true) ? "🟢" : "🔴"; } target_status(prop) { return prop.last_ping_status()?.val() ? "🟢" : "🔴"; } target_title(prop) { return prop.title().val(); } target_url(prop) { return prop.url().val(); } target_moment(prop) { return (prop.last_ping_time()?.val() ?? "planed ping").toString('YYYY-MM-DD hh:mm:ss'); } target_list() { return this.home().Sites(null).remote_list().map(key => this.Target(key)) ?? []; } is_valid_http_url(string) { let url; try { url = new URL(string); } catch (_) { return false; } return url.protocol === "http:" || url.protocol === "https:"; } add_submit() { const url = this.add_url().trim(); if (url == "") throw "Empty url!"; if (this.is_valid_http_url(url) == false) throw "Not valid url!"; let title = this.add_title().trim(); if (title == "") title = url.replace(/(^https?:\/\/)|(\/+$)/g, ''); this.add_site(url, title); this.add_url(''); this.add_title(''); } add_site(url, title) { const new_site = this.home().Sites(null).make(null); new_site.land().give(null, $hyoo_crus_rank_rule); new_site.url(null).val(url); new_site.title(null).val(title); } Target_remove(prop) { if (this.can_access()) { return super.Target_remove(prop); } return null; } target_remove(prop) { this.home().Sites(null).cut(prop.ref()); } my_key() { return this.$.$hyoo_crus_auth.current().lord().description; } users() { const ref = $hyoo_crus_ref(this.$.$mol_fetch.text('/join')); return this.$.$hyoo_crus_glob.Node(ref, $hd_canary_app_server).Users(null); } selected_panel(next) { return this.$.$mol_state_arg.value('panel', next) ?? null; } panel() { const panel = this.selected_panel(); this.can_access(panel == null); if (panel == null) return this.$.$hyoo_crus_glob.home($hd_canary_app_home); const ref = $hyoo_crus_ref(panel); if (this.$.$hyoo_crus_glob.home($hd_canary_app_home).SharedPresets(null).has(ref) == false) { this.$.$hyoo_crus_glob.home($hd_canary_app_home).SharedPresets(null).add(ref); } return this.$.$hyoo_crus_glob.Node(ref, $hd_canary_app_home); } Add() { if (this.can_access()) return super.Add(); return this.Home_button(); } go_to_home() { this.$.$mol_state_arg.value('panel', null); } panel_title() { if (this.can_access()) return super.panel_title(); return "Пользователь: " + this.shared_user_title(); } shared_user_title() { if (this.panel().title() != "") return this.panel().title(); return this.panel().land_ref().description; } can_access(next) { return next ?? false; } home() { let home = this.panel(); if (this.can_access()) { home.land().give(null, $hyoo_crus_rank_read); if (this.users().has(home.ref()) == false) { const ref = $hyoo_crus_ref(this.$.$mol_fetch.text('/ref')); home.land().give(ref, $hyoo_crus_rank_post("just")); this.users().add(home.ref()); } } return home; } bulk_add(sites_input) { const sites = sites_input.split(/\r?\n/).map(site => site.trim()).filter(site => site != ""); for (const site of sites) { this.add_site(site, site.replace(/(^https?:\/\/)|(\/+$)/g, '')); } } } __decorate([ $mol_action ], $hd_canary_app_monitor.prototype, "add_site", null); __decorate([ $mol_mem ], $hd_canary_app_monitor.prototype, "users", null); __decorate([ $mol_mem ], $hd_canary_app_monitor.prototype, "can_access", null); __decorate([ $mol_mem ], $hd_canary_app_monitor.prototype, "home", null); __decorate([ $mol_action ], $hd_canary_app_monitor.prototype, "bulk_add", null); $$.$hd_canary_app_monitor = $hd_canary_app_monitor; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { var $$; (function ($$) { $mol_style_define($.$hd_canary_app_monitor, { Add: { flex: { shrink: 1, }, }, Body_content: { gap: $mol_gap.block, }, Target: { margin: $mol_gap.block, padding: $mol_gap.block, flex: { basis: `15rem`, grow: 1, }, background: { color: $mol_theme.card, }, border: { radius: $mol_gap.round, }, box: { shadow: [{ x: 0, y: 0, blur: 0, spread: `1px`, color: $mol_theme.line, }], }, }, Target_main: { align: { items: 'flex-start', }, }, Status_total: { width: `2.5rem`, height: `2.5rem`, padding: `.5rem`, justify: { content: 'center', }, }, Target_status: { width: `2.5rem`, height: `2.5rem`, padding: `.5rem`, justify: { content: 'center', }, }, Target_url: { flex: { grow: 1, shrink: 1, }, }, Target_moment: { padding: $mol_gap.text, color: $mol_theme.shade, }, Target_message: { padding: $mol_gap.text, color: $mol_theme.focus, }, }); })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; ($.$mol_check_list) = class $mol_check_list extends ($.$mol_view) { option_checked(id, next){ if(next !== undefined) return next; return false; } option_title(id){ return ""; } option_label(id){ return [(this.option_title(id))]; } enabled(){ return true; } option_enabled(id){ return (this.enabled()); } option_hint(id){ return ""; } items(){ return []; } dictionary(){ return {}; } Option(id){ const obj = new this.$.$mol_check(); (obj.checked) = (next) => ((this.option_checked(id, next))); (obj.label) = () => ((this.option_label(id))); (obj.enabled) = () => ((this.option_enabled(id))); (obj.hint) = () => ((this.option_hint(id))); (obj.minimal_height) = () => (24); return obj; } options(){ return {}; } keys(){ return []; } sub(){ return (this.items()); } }; ($mol_mem_key(($.$mol_check_list.prototype), "option_checked")); ($mol_mem_key(($.$mol_check_list.prototype), "Option")); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_check_list extends $.$mol_check_list { options() { return {}; } dictionary(next) { return next ?? {}; } option_checked(id, next) { const prev = this.dictionary(); if (next === undefined) return prev[id] ?? null; const next_rec = { ...prev, [id]: next }; if (next === null) delete next_rec[id]; return this.dictionary(next_rec)[id] ?? null; } keys() { return Object.keys(this.options()); } items() { return this.keys().map(key => this.Option(key)); } option_title(key) { return this.options()[key] || key; } } __decorate([ $mol_mem ], $mol_check_list.prototype, "keys", null); __decorate([ $mol_mem ], $mol_check_list.prototype, "items", null); $$.$mol_check_list = $mol_check_list; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { $mol_style_attach("mol/check/list/list.view.css", "[mol_check_list] {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tflex: 1 1 auto;\n\tborder-radius: var(--mol_gap_round);\n\tgap: 1px;\n}\n\n[mol_check_list_option] {\n\tflex: 0 1 auto;\n}\n\n[mol_check_list_option]:where([mol_check_checked=\"true\"]) {\n\ttext-shadow: 0 0;\n\tcolor: var(--mol_theme_current);\n}\n\n[mol_check_list_option]:where([mol_check_checked=\"true\"][disabled]) {\n\tcolor: var(--mol_theme_text);\n}\n"); })($ || ($ = {})); ; ($.$mol_switch) = class $mol_switch extends ($.$mol_check_list) { value(next){ if(next !== undefined) return next; return ""; } }; ($mol_mem(($.$mol_switch.prototype), "value")); ; "use strict"; var $; (function ($) { class $mol_state_session extends $mol_object { static 'native()'; static native() { if (this['native()']) return this['native()']; check: try { const native = $mol_dom_context.sessionStorage; if (!native) break check; native.setItem('', ''); native.removeItem(''); return this['native()'] = native; } catch (error) { console.warn(error); } return this['native()'] = { getItem(key) { return this[':' + key]; }, setItem(key, value) { this[':' + key] = value; }, removeItem(key) { this[':' + key] = void 0; } }; } static value(key, next) { if (next === void 0) return JSON.parse(this.native().getItem(key) || 'null'); if (next === null) this.native().removeItem(key); else this.native().setItem(key, JSON.stringify(next)); return next; } prefix() { return ''; } value(key, next) { return $mol_state_session.value(this.prefix() + '.' + key, next); } } __decorate([ $mol_mem_key ], $mol_state_session, "value", null); $.$mol_state_session = $mol_state_session; })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_switch extends $.$mol_switch { value(next) { return $mol_state_session.value(`${this}.value()`, next) ?? ''; } option_checked(key, next) { if (next === undefined) return this.value() == key; this.value(next ? key : ''); return next; } } $$.$mol_switch = $mol_switch; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; ($.$mol_deck) = class $mol_deck extends ($.$mol_list) { current(next){ if(next !== undefined) return next; return "0"; } switch_options(){ return {}; } Switch(){ const obj = new this.$.$mol_switch(); (obj.value) = (next) => ((this.current(next))); (obj.options) = () => ((this.switch_options())); return obj; } Content(){ const obj = new this.$.$mol_view(); return obj; } items(){ return []; } rows(){ return [(this.Switch()), (this.Content())]; } }; ($mol_mem(($.$mol_deck.prototype), "current")); ($mol_mem(($.$mol_deck.prototype), "Switch")); ($mol_mem(($.$mol_deck.prototype), "Content")); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $mol_deck extends $.$mol_deck { current(next) { return $mol_state_session.value(`${this}.current()`, next) || '0'; } switch_options() { let options = {}; this.items().forEach((item, index) => { options[String(index)] = item.title(); }); return options; } Content() { return this.items()[Number(this.current())]; } } __decorate([ $mol_mem ], $mol_deck.prototype, "Content", null); $$.$mol_deck = $mol_deck; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; ($.$hd_canary_app_bar) = class $hd_canary_app_bar extends ($.$mol_page) { home(){ return (this.My_monitor().home()); } My_monitor(){ const obj = new this.$.$hd_canary_app_monitor(); return obj; } users(){ return {}; } Other_monitors(){ const obj = new this.$.$mol_book2_catalog(); (obj.param) = () => ("user"); (obj.menu_title) = () => ("Расшаренные мне"); (obj.spreads) = () => ((this.users())); return obj; } Info(){ const obj = new this.$.$mol_deck(); (obj.items) = () => ([(this.My_monitor()), (this.Other_monitors())]); return obj; } panel_title(id){ return "diff"; } selected_home(id){ const obj = new this.$.$hd_canary_app_home(); return obj; } Head(){ return null; } title(){ return (this.$.$mol_locale.text("$hd_canary_app_bar_title")); } body(){ return [(this.Info())]; } Panel(id){ const obj = new this.$.$hd_canary_app_monitor(); (obj.title) = () => ((this.panel_title(id))); (obj.home) = () => ((this.selected_home(id))); (obj.Add) = () => (null); (obj.Target_remove) = () => (null); return obj; } }; ($mol_mem(($.$hd_canary_app_bar.prototype), "My_monitor")); ($mol_mem(($.$hd_canary_app_bar.prototype), "Other_monitors")); ($mol_mem(($.$hd_canary_app_bar.prototype), "Info")); ($mol_mem_key(($.$hd_canary_app_bar.prototype), "selected_home")); ($mol_mem_key(($.$hd_canary_app_bar.prototype), "Panel")); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $hd_canary_app_bar extends $.$hd_canary_app_bar { users() { const presets = this.$.$hyoo_crus_glob.home($hd_canary_app_home).SharedPresets(null); return presets.items().map(key => this.Panel(key)); } selected_home(ref) { return this.$.$hyoo_crus_glob.Node(ref, $hd_canary_app_home); } panel_title(ref) { if (this.selected_home(ref).title() != "") return this.selected_home(ref).title(); return this.selected_home(ref).land_ref().description; } } $$.$hd_canary_app_bar = $hd_canary_app_bar; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; "use strict"; ; "use strict"; var $; (function ($) { var $$; (function ($$) { class $hd_canary_app extends $.$hd_canary_app { share_link() { return this.$.$mol_state_arg.link({ panel: this.$.$hyoo_crus_glob.home($hd_canary_app_home).land_ref().description, }); } } __decorate([ $mol_mem ], $hd_canary_app.prototype, "share_link", null); $$.$hd_canary_app = $hd_canary_app; })($$ = $.$$ || ($.$$ = {})); })($ || ($ = {})); ; "use strict"; var $; (function ($) { class $hd_canary_app_server extends $hyoo_crus_dict.with({ Users: $hyoo_crus_list_ref_to(() => $hyoo_crus_atom_ref), }) { } $.$hd_canary_app_server = $hd_canary_app_server; class $hd_canary_app_home extends $hyoo_crus_home.with({ Sites: $hyoo_crus_list_ref_to(() => $hd_canary_app_home_site), SharedPresets: $hyoo_crus_list_ref_to(() => $hyoo_crus_ref), }) { } $.$hd_canary_app_home = $hd_canary_app_home; class $hd_canary_app_home_site extends $hyoo_crus_dict.with({ url: $hyoo_crus_atom_str, title: $hyoo_crus_atom_str, last_ping_time: $hyoo_crus_atom_time, last_ping_status: $hyoo_crus_atom_bool, sended_alert: $hyoo_crus_atom_bool, }) { tick() { this.$.$mol_state_time.now(5000); this.$.$mol_log3_done({ place: this, message: this.land().ref().description, }); if (this.can_change()) { const url = this.url().val(); const title = this.title().val(); this.$.$mol_log3_done({ place: this, message: this.land().ref().description, ...{ action: "tick", url, title, last_ping_status: this.last_ping_status(null).val() } }); const request = $mol_fetch.response(url); this.last_ping_status(null).val(request.code() == 200); this.last_ping_time(null).val(new $mol_time_moment); } } } __decorate([ $mol_mem ], $hd_canary_app_home_site.prototype, "tick", null); $.$hd_canary_app_home_site = $hd_canary_app_home_site; })($ || ($ = {})); ; var $node = $node || {} void function( module ) { var exports = module.exports = this; function require( id ) { return $node[ id.replace( /^.\// , "../hd/canary/" ) ] }; ; module.exports = { apps: [ { name: "canary", script: "node.js", cwd: "./-/", args: "port=9090", autorestart: true, env: { "TELEGRAM_TOKEN": "" }, }, ], }; ; $node[ "../hd/canary/ecosystem.config" ] = $node[ "../hd/canary/ecosystem.config.js" ] = module.exports }.call( {} , {} ) //# sourceMappingURL=web.js.map