@polka-codes/runner 0.9.89 → 0.9.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +3020 -782
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -37641,769 +37641,2288 @@ var require_mimeScore = __commonJS((exports, module) => {
37641
37641
  };
37642
37642
  });
37643
37643
 
37644
- // ../../node_modules/better-sqlite3/lib/util.js
37645
- var require_util3 = __commonJS((exports) => {
37646
- exports.getBooleanOption = (options, key) => {
37647
- let value = false;
37648
- if (key in options && typeof (value = options[key]) !== "boolean") {
37649
- throw new TypeError(`Expected the "${key}" option to be a boolean`);
37650
- }
37651
- return value;
37652
- };
37653
- exports.cppdb = Symbol();
37654
- exports.inspect = Symbol.for("nodejs.util.inspect.custom");
37655
- });
37656
-
37657
- // ../../node_modules/better-sqlite3/lib/sqlite-error.js
37658
- var require_sqlite_error = __commonJS((exports, module) => {
37659
- var descriptor = { value: "SqliteError", writable: true, enumerable: false, configurable: true };
37660
- function SqliteError(message, code) {
37661
- if (new.target !== SqliteError) {
37662
- return new SqliteError(message, code);
37663
- }
37664
- if (typeof code !== "string") {
37665
- throw new TypeError("Expected second argument to be a string");
37666
- }
37667
- Error.call(this, message);
37668
- descriptor.value = "" + message;
37669
- Object.defineProperty(this, "message", descriptor);
37670
- Error.captureStackTrace(this, SqliteError);
37671
- this.code = code;
37672
- }
37673
- Object.setPrototypeOf(SqliteError, Error);
37674
- Object.setPrototypeOf(SqliteError.prototype, Error.prototype);
37675
- Object.defineProperty(SqliteError.prototype, "name", descriptor);
37676
- module.exports = SqliteError;
37677
- });
37678
-
37679
- // ../../node_modules/file-uri-to-path/index.js
37680
- var require_file_uri_to_path = __commonJS((exports, module) => {
37681
- var sep = __require("path").sep || "/";
37682
- module.exports = fileUriToPath;
37683
- function fileUriToPath(uri) {
37684
- if (typeof uri != "string" || uri.length <= 7 || uri.substring(0, 7) != "file://") {
37685
- throw new TypeError("must pass in a file:// URI to convert to a file path");
37686
- }
37687
- var rest = decodeURI(uri.substring(7));
37688
- var firstSlash = rest.indexOf("/");
37689
- var host = rest.substring(0, firstSlash);
37690
- var path = rest.substring(firstSlash + 1);
37691
- if (host == "localhost")
37692
- host = "";
37693
- if (host) {
37694
- host = sep + sep + host;
37695
- }
37696
- path = path.replace(/^(.+)\|/, "$1:");
37697
- if (sep == "\\") {
37698
- path = path.replace(/\//g, "\\");
37699
- }
37700
- if (/^.+\:/.test(path)) {} else {
37701
- path = sep + path;
37702
- }
37703
- return host + path;
37704
- }
37705
- });
37706
-
37707
- // ../../node_modules/bindings/bindings.js
37708
- var require_bindings = __commonJS((exports, module) => {
37709
- var __filename = "/Users/xiliangchen/projects/polka-codes/node_modules/bindings/bindings.js";
37710
- var fs4 = __require("fs");
37711
- var path = __require("path");
37712
- var fileURLToPath = require_file_uri_to_path();
37713
- var join3 = path.join;
37714
- var dirname2 = path.dirname;
37715
- var exists = fs4.accessSync && function(path2) {
37716
- try {
37717
- fs4.accessSync(path2);
37718
- } catch (e2) {
37719
- return false;
37720
- }
37721
- return true;
37722
- } || fs4.existsSync || path.existsSync;
37723
- var defaults = {
37724
- arrow: process.env.NODE_BINDINGS_ARROW || " → ",
37725
- compiled: process.env.NODE_BINDINGS_COMPILED_DIR || "compiled",
37726
- platform: process.platform,
37727
- arch: process.arch,
37728
- nodePreGyp: "node-v" + process.versions.modules + "-" + process.platform + "-" + process.arch,
37729
- version: process.versions.node,
37730
- bindings: "bindings.node",
37731
- try: [
37732
- ["module_root", "build", "bindings"],
37733
- ["module_root", "build", "Debug", "bindings"],
37734
- ["module_root", "build", "Release", "bindings"],
37735
- ["module_root", "out", "Debug", "bindings"],
37736
- ["module_root", "Debug", "bindings"],
37737
- ["module_root", "out", "Release", "bindings"],
37738
- ["module_root", "Release", "bindings"],
37739
- ["module_root", "build", "default", "bindings"],
37740
- ["module_root", "compiled", "version", "platform", "arch", "bindings"],
37741
- ["module_root", "addon-build", "release", "install-root", "bindings"],
37742
- ["module_root", "addon-build", "debug", "install-root", "bindings"],
37743
- ["module_root", "addon-build", "default", "install-root", "bindings"],
37744
- ["module_root", "lib", "binding", "nodePreGyp", "bindings"]
37745
- ]
37746
- };
37747
- function bindings(opts) {
37748
- if (typeof opts == "string") {
37749
- opts = { bindings: opts };
37750
- } else if (!opts) {
37751
- opts = {};
37752
- }
37753
- Object.keys(defaults).map(function(i3) {
37754
- if (!(i3 in opts))
37755
- opts[i3] = defaults[i3];
37756
- });
37757
- if (!opts.module_root) {
37758
- opts.module_root = exports.getRoot(exports.getFileName());
37759
- }
37760
- if (path.extname(opts.bindings) != ".node") {
37761
- opts.bindings += ".node";
37762
- }
37763
- var requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
37764
- var tries = [], i2 = 0, l = opts.try.length, n, b, err;
37765
- for (;i2 < l; i2++) {
37766
- n = join3.apply(null, opts.try[i2].map(function(p) {
37767
- return opts[p] || p;
37768
- }));
37769
- tries.push(n);
37770
- try {
37771
- b = opts.path ? requireFunc.resolve(n) : requireFunc(n);
37772
- if (!opts.path) {
37773
- b.path = n;
37644
+ // ../../node_modules/sql.js/dist/sql-wasm.js
37645
+ var require_sql_wasm = __commonJS((exports, module) => {
37646
+ var __dirname = "/Users/xiliangchen/projects/polka-codes/node_modules/sql.js/dist";
37647
+ var initSqlJsPromise = undefined;
37648
+ var initSqlJs = function(moduleConfig) {
37649
+ if (initSqlJsPromise) {
37650
+ return initSqlJsPromise;
37651
+ }
37652
+ initSqlJsPromise = new Promise(function(resolveModule, reject) {
37653
+ var Module = typeof moduleConfig !== "undefined" ? moduleConfig : {};
37654
+ var originalOnAbortFunction = Module["onAbort"];
37655
+ Module["onAbort"] = function(errorThatCausedAbort) {
37656
+ reject(new Error(errorThatCausedAbort));
37657
+ if (originalOnAbortFunction) {
37658
+ originalOnAbortFunction(errorThatCausedAbort);
37774
37659
  }
37775
- return b;
37776
- } catch (e2) {
37777
- if (e2.code !== "MODULE_NOT_FOUND" && e2.code !== "QUALIFIED_PATH_RESOLUTION_FAILED" && !/not find/i.test(e2.message)) {
37778
- throw e2;
37660
+ };
37661
+ Module["postRun"] = Module["postRun"] || [];
37662
+ Module["postRun"].push(function() {
37663
+ resolveModule(Module);
37664
+ });
37665
+ module = undefined;
37666
+ var f3;
37667
+ f3 ||= typeof Module != "undefined" ? Module : {};
37668
+ var aa = typeof window == "object", ba = typeof WorkerGlobalScope != "undefined", ca = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string" && process.type != "renderer";
37669
+ f3.onRuntimeInitialized = function() {
37670
+ function a(g, l) {
37671
+ switch (typeof l) {
37672
+ case "boolean":
37673
+ dc(g, l ? 1 : 0);
37674
+ break;
37675
+ case "number":
37676
+ ec(g, l);
37677
+ break;
37678
+ case "string":
37679
+ fc(g, l, -1, -1);
37680
+ break;
37681
+ case "object":
37682
+ if (l === null)
37683
+ lb(g);
37684
+ else if (l.length != null) {
37685
+ var n = da(l, ea);
37686
+ gc(g, n, l.length, -1);
37687
+ fa(n);
37688
+ } else
37689
+ va(g, "Wrong API use : tried to return a value of an unknown type (" + l + ").", -1);
37690
+ break;
37691
+ default:
37692
+ lb(g);
37693
+ }
37779
37694
  }
37780
- }
37781
- }
37782
- err = new Error(`Could not locate the bindings file. Tried:
37783
- ` + tries.map(function(a) {
37784
- return opts.arrow + a;
37785
- }).join(`
37786
- `));
37787
- err.tries = tries;
37788
- throw err;
37789
- }
37790
- module.exports = exports = bindings;
37791
- exports.getFileName = function getFileName(calling_file) {
37792
- var { prepareStackTrace: origPST, stackTraceLimit: origSTL } = Error, dummy = {}, fileName;
37793
- Error.stackTraceLimit = 10;
37794
- Error.prepareStackTrace = function(e2, st) {
37795
- for (var i2 = 0, l = st.length;i2 < l; i2++) {
37796
- fileName = st[i2].getFileName();
37797
- if (fileName !== __filename) {
37798
- if (calling_file) {
37799
- if (fileName !== calling_file) {
37695
+ function b(g, l) {
37696
+ for (var n = [], r2 = 0;r2 < g; r2 += 1) {
37697
+ var t2 = m2(l + 4 * r2, "i32"), y = hc(t2);
37698
+ if (y === 1 || y === 2)
37699
+ t2 = ic(t2);
37700
+ else if (y === 3)
37701
+ t2 = jc(t2);
37702
+ else if (y === 4) {
37703
+ y = t2;
37704
+ t2 = kc(y);
37705
+ y = lc(y);
37706
+ for (var L = new Uint8Array(t2), J = 0;J < t2; J += 1)
37707
+ L[J] = p[y + J];
37708
+ t2 = L;
37709
+ } else
37710
+ t2 = null;
37711
+ n.push(t2);
37712
+ }
37713
+ return n;
37714
+ }
37715
+ function c(g, l) {
37716
+ this.Qa = g;
37717
+ this.db = l;
37718
+ this.Oa = 1;
37719
+ this.lb = [];
37720
+ }
37721
+ function d(g, l) {
37722
+ this.db = l;
37723
+ l = ha(g) + 1;
37724
+ this.eb = ia(l);
37725
+ if (this.eb === null)
37726
+ throw Error("Unable to allocate memory for the SQL string");
37727
+ u(g, x2, this.eb, l);
37728
+ this.kb = this.eb;
37729
+ this.Za = this.pb = null;
37730
+ }
37731
+ function e2(g) {
37732
+ this.filename = "dbfile_" + (4294967295 * Math.random() >>> 0);
37733
+ if (g != null) {
37734
+ var l = this.filename, n = "/", r2 = l;
37735
+ n && (n = typeof n == "string" ? n : ja(n), r2 = l ? ka(n + "/" + l) : n);
37736
+ l = la(true, true);
37737
+ r2 = ma(r2, l);
37738
+ if (g) {
37739
+ if (typeof g == "string") {
37740
+ n = Array(g.length);
37741
+ for (var t2 = 0, y = g.length;t2 < y; ++t2)
37742
+ n[t2] = g.charCodeAt(t2);
37743
+ g = n;
37744
+ }
37745
+ na(r2, l | 146);
37746
+ n = oa(r2, 577);
37747
+ pa(n, g, 0, g.length, 0);
37748
+ qa(n);
37749
+ na(r2, l);
37750
+ }
37751
+ }
37752
+ this.handleError(q(this.filename, h2));
37753
+ this.db = m2(h2, "i32");
37754
+ ob(this.db);
37755
+ this.fb = {};
37756
+ this.Sa = {};
37757
+ }
37758
+ var h2 = z2(4), k = f3.cwrap, q = k("sqlite3_open", "number", ["string", "number"]), w = k("sqlite3_close_v2", "number", ["number"]), v = k("sqlite3_exec", "number", ["number", "string", "number", "number", "number"]), C = k("sqlite3_changes", "number", ["number"]), G = k("sqlite3_prepare_v2", "number", ["number", "string", "number", "number", "number"]), pb = k("sqlite3_sql", "string", ["number"]), nc = k("sqlite3_normalized_sql", "string", ["number"]), qb = k("sqlite3_prepare_v2", "number", ["number", "number", "number", "number", "number"]), oc = k("sqlite3_bind_text", "number", ["number", "number", "number", "number", "number"]), rb = k("sqlite3_bind_blob", "number", ["number", "number", "number", "number", "number"]), pc = k("sqlite3_bind_double", "number", ["number", "number", "number"]), qc = k("sqlite3_bind_int", "number", ["number", "number", "number"]), rc = k("sqlite3_bind_parameter_index", "number", ["number", "string"]), sc = k("sqlite3_step", "number", ["number"]), tc = k("sqlite3_errmsg", "string", ["number"]), uc = k("sqlite3_column_count", "number", ["number"]), vc = k("sqlite3_data_count", "number", ["number"]), wc = k("sqlite3_column_double", "number", ["number", "number"]), sb = k("sqlite3_column_text", "string", ["number", "number"]), xc = k("sqlite3_column_blob", "number", ["number", "number"]), yc = k("sqlite3_column_bytes", "number", [
37759
+ "number",
37760
+ "number"
37761
+ ]), zc = k("sqlite3_column_type", "number", ["number", "number"]), Ac = k("sqlite3_column_name", "string", ["number", "number"]), Bc = k("sqlite3_reset", "number", ["number"]), Cc = k("sqlite3_clear_bindings", "number", ["number"]), Dc = k("sqlite3_finalize", "number", ["number"]), tb = k("sqlite3_create_function_v2", "number", "number string number number number number number number number".split(" ")), hc = k("sqlite3_value_type", "number", ["number"]), kc = k("sqlite3_value_bytes", "number", ["number"]), jc = k("sqlite3_value_text", "string", ["number"]), lc = k("sqlite3_value_blob", "number", ["number"]), ic = k("sqlite3_value_double", "number", ["number"]), ec = k("sqlite3_result_double", "", ["number", "number"]), lb = k("sqlite3_result_null", "", ["number"]), fc = k("sqlite3_result_text", "", ["number", "string", "number", "number"]), gc = k("sqlite3_result_blob", "", ["number", "number", "number", "number"]), dc = k("sqlite3_result_int", "", ["number", "number"]), va = k("sqlite3_result_error", "", ["number", "string", "number"]), ub = k("sqlite3_aggregate_context", "number", ["number", "number"]), ob = k("RegisterExtensionFunctions", "number", ["number"]), vb = k("sqlite3_update_hook", "number", ["number", "number", "number"]);
37762
+ c.prototype.bind = function(g) {
37763
+ if (!this.Qa)
37764
+ throw "Statement closed";
37765
+ this.reset();
37766
+ return Array.isArray(g) ? this.Cb(g) : g != null && typeof g === "object" ? this.Db(g) : true;
37767
+ };
37768
+ c.prototype.step = function() {
37769
+ if (!this.Qa)
37770
+ throw "Statement closed";
37771
+ this.Oa = 1;
37772
+ var g = sc(this.Qa);
37773
+ switch (g) {
37774
+ case 100:
37775
+ return true;
37776
+ case 101:
37777
+ return false;
37778
+ default:
37779
+ throw this.db.handleError(g);
37780
+ }
37781
+ };
37782
+ c.prototype.wb = function(g) {
37783
+ g == null && (g = this.Oa, this.Oa += 1);
37784
+ return wc(this.Qa, g);
37785
+ };
37786
+ c.prototype.Gb = function(g) {
37787
+ g == null && (g = this.Oa, this.Oa += 1);
37788
+ g = sb(this.Qa, g);
37789
+ if (typeof BigInt !== "function")
37790
+ throw Error("BigInt is not supported");
37791
+ return BigInt(g);
37792
+ };
37793
+ c.prototype.Hb = function(g) {
37794
+ g == null && (g = this.Oa, this.Oa += 1);
37795
+ return sb(this.Qa, g);
37796
+ };
37797
+ c.prototype.getBlob = function(g) {
37798
+ g == null && (g = this.Oa, this.Oa += 1);
37799
+ var l = yc(this.Qa, g);
37800
+ g = xc(this.Qa, g);
37801
+ for (var n = new Uint8Array(l), r2 = 0;r2 < l; r2 += 1)
37802
+ n[r2] = p[g + r2];
37803
+ return n;
37804
+ };
37805
+ c.prototype.get = function(g, l) {
37806
+ l = l || {};
37807
+ g != null && this.bind(g) && this.step();
37808
+ g = [];
37809
+ for (var n = vc(this.Qa), r2 = 0;r2 < n; r2 += 1)
37810
+ switch (zc(this.Qa, r2)) {
37811
+ case 1:
37812
+ var t2 = l.useBigInt ? this.Gb(r2) : this.wb(r2);
37813
+ g.push(t2);
37814
+ break;
37815
+ case 2:
37816
+ g.push(this.wb(r2));
37817
+ break;
37818
+ case 3:
37819
+ g.push(this.Hb(r2));
37820
+ break;
37821
+ case 4:
37822
+ g.push(this.getBlob(r2));
37823
+ break;
37824
+ default:
37825
+ g.push(null);
37826
+ }
37827
+ return g;
37828
+ };
37829
+ c.prototype.getColumnNames = function() {
37830
+ for (var g = [], l = uc(this.Qa), n = 0;n < l; n += 1)
37831
+ g.push(Ac(this.Qa, n));
37832
+ return g;
37833
+ };
37834
+ c.prototype.getAsObject = function(g, l) {
37835
+ g = this.get(g, l);
37836
+ l = this.getColumnNames();
37837
+ for (var n = {}, r2 = 0;r2 < l.length; r2 += 1)
37838
+ n[l[r2]] = g[r2];
37839
+ return n;
37840
+ };
37841
+ c.prototype.getSQL = function() {
37842
+ return pb(this.Qa);
37843
+ };
37844
+ c.prototype.getNormalizedSQL = function() {
37845
+ return nc(this.Qa);
37846
+ };
37847
+ c.prototype.run = function(g) {
37848
+ g != null && this.bind(g);
37849
+ this.step();
37850
+ return this.reset();
37851
+ };
37852
+ c.prototype.sb = function(g, l) {
37853
+ l == null && (l = this.Oa, this.Oa += 1);
37854
+ g = ra(g);
37855
+ var n = da(g, ea);
37856
+ this.lb.push(n);
37857
+ this.db.handleError(oc(this.Qa, l, n, g.length - 1, 0));
37858
+ };
37859
+ c.prototype.Bb = function(g, l) {
37860
+ l == null && (l = this.Oa, this.Oa += 1);
37861
+ var n = da(g, ea);
37862
+ this.lb.push(n);
37863
+ this.db.handleError(rb(this.Qa, l, n, g.length, 0));
37864
+ };
37865
+ c.prototype.rb = function(g, l) {
37866
+ l == null && (l = this.Oa, this.Oa += 1);
37867
+ this.db.handleError((g === (g | 0) ? qc : pc)(this.Qa, l, g));
37868
+ };
37869
+ c.prototype.Eb = function(g) {
37870
+ g == null && (g = this.Oa, this.Oa += 1);
37871
+ rb(this.Qa, g, 0, 0, 0);
37872
+ };
37873
+ c.prototype.tb = function(g, l) {
37874
+ l == null && (l = this.Oa, this.Oa += 1);
37875
+ switch (typeof g) {
37876
+ case "string":
37877
+ this.sb(g, l);
37878
+ return;
37879
+ case "number":
37880
+ this.rb(g, l);
37881
+ return;
37882
+ case "bigint":
37883
+ this.sb(g.toString(), l);
37884
+ return;
37885
+ case "boolean":
37886
+ this.rb(g + 0, l);
37800
37887
  return;
37888
+ case "object":
37889
+ if (g === null) {
37890
+ this.Eb(l);
37891
+ return;
37892
+ }
37893
+ if (g.length != null) {
37894
+ this.Bb(g, l);
37895
+ return;
37896
+ }
37897
+ }
37898
+ throw "Wrong API use : tried to bind a value of an unknown type (" + g + ").";
37899
+ };
37900
+ c.prototype.Db = function(g) {
37901
+ var l = this;
37902
+ Object.keys(g).forEach(function(n) {
37903
+ var r2 = rc(l.Qa, n);
37904
+ r2 !== 0 && l.tb(g[n], r2);
37905
+ });
37906
+ return true;
37907
+ };
37908
+ c.prototype.Cb = function(g) {
37909
+ for (var l = 0;l < g.length; l += 1)
37910
+ this.tb(g[l], l + 1);
37911
+ return true;
37912
+ };
37913
+ c.prototype.reset = function() {
37914
+ this.freemem();
37915
+ return Cc(this.Qa) === 0 && Bc(this.Qa) === 0;
37916
+ };
37917
+ c.prototype.freemem = function() {
37918
+ for (var g;(g = this.lb.pop()) !== undefined; )
37919
+ fa(g);
37920
+ };
37921
+ c.prototype.free = function() {
37922
+ this.freemem();
37923
+ var g = Dc(this.Qa) === 0;
37924
+ delete this.db.fb[this.Qa];
37925
+ this.Qa = 0;
37926
+ return g;
37927
+ };
37928
+ d.prototype.next = function() {
37929
+ if (this.eb === null)
37930
+ return { done: true };
37931
+ this.Za !== null && (this.Za.free(), this.Za = null);
37932
+ if (!this.db.db)
37933
+ throw this.mb(), Error("Database closed");
37934
+ var g = sa(), l = z2(4);
37935
+ ta(h2);
37936
+ ta(l);
37937
+ try {
37938
+ this.db.handleError(qb(this.db.db, this.kb, -1, h2, l));
37939
+ this.kb = m2(l, "i32");
37940
+ var n = m2(h2, "i32");
37941
+ if (n === 0)
37942
+ return this.mb(), { done: true };
37943
+ this.Za = new c(n, this.db);
37944
+ this.db.fb[n] = this.Za;
37945
+ return { value: this.Za, done: false };
37946
+ } catch (r2) {
37947
+ throw this.pb = ua(this.kb), this.mb(), r2;
37948
+ } finally {
37949
+ wa(g);
37950
+ }
37951
+ };
37952
+ d.prototype.mb = function() {
37953
+ fa(this.eb);
37954
+ this.eb = null;
37955
+ };
37956
+ d.prototype.getRemainingSQL = function() {
37957
+ return this.pb !== null ? this.pb : ua(this.kb);
37958
+ };
37959
+ typeof Symbol === "function" && typeof Symbol.iterator === "symbol" && (d.prototype[Symbol.iterator] = function() {
37960
+ return this;
37961
+ });
37962
+ e2.prototype.run = function(g, l) {
37963
+ if (!this.db)
37964
+ throw "Database closed";
37965
+ if (l) {
37966
+ g = this.prepare(g, l);
37967
+ try {
37968
+ g.step();
37969
+ } finally {
37970
+ g.free();
37801
37971
  }
37802
- } else {
37803
- return;
37972
+ } else
37973
+ this.handleError(v(this.db, g, 0, 0, h2));
37974
+ return this;
37975
+ };
37976
+ e2.prototype.exec = function(g, l, n) {
37977
+ if (!this.db)
37978
+ throw "Database closed";
37979
+ var r2 = sa(), t2 = null;
37980
+ try {
37981
+ var y = xa(g), L = z2(4);
37982
+ for (g = [];m2(y, "i8") !== 0; ) {
37983
+ ta(h2);
37984
+ ta(L);
37985
+ this.handleError(qb(this.db, y, -1, h2, L));
37986
+ var J = m2(h2, "i32");
37987
+ y = m2(L, "i32");
37988
+ if (J !== 0) {
37989
+ var I = null;
37990
+ t2 = new c(J, this);
37991
+ for (l != null && t2.bind(l);t2.step(); )
37992
+ I === null && (I = { columns: t2.getColumnNames(), values: [] }, g.push(I)), I.values.push(t2.get(null, n));
37993
+ t2.free();
37994
+ }
37995
+ }
37996
+ return g;
37997
+ } catch (M) {
37998
+ throw t2 && t2.free(), M;
37999
+ } finally {
38000
+ wa(r2);
37804
38001
  }
37805
- }
37806
- }
37807
- };
37808
- Error.captureStackTrace(dummy);
37809
- dummy.stack;
37810
- Error.prepareStackTrace = origPST;
37811
- Error.stackTraceLimit = origSTL;
37812
- var fileSchema = "file://";
37813
- if (fileName.indexOf(fileSchema) === 0) {
37814
- fileName = fileURLToPath(fileName);
37815
- }
37816
- return fileName;
37817
- };
37818
- exports.getRoot = function getRoot(file2) {
37819
- var dir = dirname2(file2), prev;
37820
- while (true) {
37821
- if (dir === ".") {
37822
- dir = process.cwd();
38002
+ };
38003
+ e2.prototype.each = function(g, l, n, r2, t2) {
38004
+ typeof l === "function" && (r2 = n, n = l, l = undefined);
38005
+ g = this.prepare(g, l);
38006
+ try {
38007
+ for (;g.step(); )
38008
+ n(g.getAsObject(null, t2));
38009
+ } finally {
38010
+ g.free();
38011
+ }
38012
+ if (typeof r2 === "function")
38013
+ return r2();
38014
+ };
38015
+ e2.prototype.prepare = function(g, l) {
38016
+ ta(h2);
38017
+ this.handleError(G(this.db, g, -1, h2, 0));
38018
+ g = m2(h2, "i32");
38019
+ if (g === 0)
38020
+ throw "Nothing to prepare";
38021
+ var n = new c(g, this);
38022
+ l != null && n.bind(l);
38023
+ return this.fb[g] = n;
38024
+ };
38025
+ e2.prototype.iterateStatements = function(g) {
38026
+ return new d(g, this);
38027
+ };
38028
+ e2.prototype["export"] = function() {
38029
+ Object.values(this.fb).forEach(function(l) {
38030
+ l.free();
38031
+ });
38032
+ Object.values(this.Sa).forEach(A2);
38033
+ this.Sa = {};
38034
+ this.handleError(w(this.db));
38035
+ var g = ya(this.filename);
38036
+ this.handleError(q(this.filename, h2));
38037
+ this.db = m2(h2, "i32");
38038
+ ob(this.db);
38039
+ return g;
38040
+ };
38041
+ e2.prototype.close = function() {
38042
+ this.db !== null && (Object.values(this.fb).forEach(function(g) {
38043
+ g.free();
38044
+ }), Object.values(this.Sa).forEach(A2), this.Sa = {}, this.Ya && (A2(this.Ya), this.Ya = undefined), this.handleError(w(this.db)), za("/" + this.filename), this.db = null);
38045
+ };
38046
+ e2.prototype.handleError = function(g) {
38047
+ if (g === 0)
38048
+ return null;
38049
+ g = tc(this.db);
38050
+ throw Error(g);
38051
+ };
38052
+ e2.prototype.getRowsModified = function() {
38053
+ return C(this.db);
38054
+ };
38055
+ e2.prototype.create_function = function(g, l) {
38056
+ Object.prototype.hasOwnProperty.call(this.Sa, g) && (A2(this.Sa[g]), delete this.Sa[g]);
38057
+ var n = Aa(function(r2, t2, y) {
38058
+ t2 = b(t2, y);
38059
+ try {
38060
+ var L = l.apply(null, t2);
38061
+ } catch (J) {
38062
+ va(r2, J, -1);
38063
+ return;
38064
+ }
38065
+ a(r2, L);
38066
+ }, "viii");
38067
+ this.Sa[g] = n;
38068
+ this.handleError(tb(this.db, g, l.length, 1, 0, n, 0, 0, 0));
38069
+ return this;
38070
+ };
38071
+ e2.prototype.create_aggregate = function(g, l) {
38072
+ var n = l.init || function() {
38073
+ return null;
38074
+ }, r2 = l.finalize || function(I) {
38075
+ return I;
38076
+ }, t2 = l.step;
38077
+ if (!t2)
38078
+ throw "An aggregate function must have a step function in " + g;
38079
+ var y = {};
38080
+ Object.hasOwnProperty.call(this.Sa, g) && (A2(this.Sa[g]), delete this.Sa[g]);
38081
+ l = g + "__finalize";
38082
+ Object.hasOwnProperty.call(this.Sa, l) && (A2(this.Sa[l]), delete this.Sa[l]);
38083
+ var L = Aa(function(I, M, Ra) {
38084
+ var X = ub(I, 1);
38085
+ Object.hasOwnProperty.call(y, X) || (y[X] = n());
38086
+ M = b(M, Ra);
38087
+ M = [y[X]].concat(M);
38088
+ try {
38089
+ y[X] = t2.apply(null, M);
38090
+ } catch (Fc) {
38091
+ delete y[X], va(I, Fc, -1);
38092
+ }
38093
+ }, "viii"), J = Aa(function(I) {
38094
+ var M = ub(I, 1);
38095
+ try {
38096
+ var Ra = r2(y[M]);
38097
+ } catch (X) {
38098
+ delete y[M];
38099
+ va(I, X, -1);
38100
+ return;
38101
+ }
38102
+ a(I, Ra);
38103
+ delete y[M];
38104
+ }, "vi");
38105
+ this.Sa[g] = L;
38106
+ this.Sa[l] = J;
38107
+ this.handleError(tb(this.db, g, t2.length - 1, 1, 0, 0, L, J, 0));
38108
+ return this;
38109
+ };
38110
+ e2.prototype.updateHook = function(g) {
38111
+ this.Ya && (vb(this.db, 0, 0), A2(this.Ya), this.Ya = undefined);
38112
+ g && (this.Ya = Aa(function(l, n, r2, t2, y) {
38113
+ switch (n) {
38114
+ case 18:
38115
+ l = "insert";
38116
+ break;
38117
+ case 23:
38118
+ l = "update";
38119
+ break;
38120
+ case 9:
38121
+ l = "delete";
38122
+ break;
38123
+ default:
38124
+ throw "unknown operationCode in updateHook callback: " + n;
38125
+ }
38126
+ r2 = r2 ? B(x2, r2) : "";
38127
+ t2 = t2 ? B(x2, t2) : "";
38128
+ if (y > Number.MAX_SAFE_INTEGER)
38129
+ throw "rowId too big to fit inside a Number";
38130
+ g(l, r2, t2, Number(y));
38131
+ }, "viiiij"), vb(this.db, this.Ya, 0));
38132
+ };
38133
+ f3.Database = e2;
38134
+ };
38135
+ var Ba = { ...f3 }, Ca = "./this.program", Da = (a, b) => {
38136
+ throw b;
38137
+ }, D = "", Ea, Fa;
38138
+ if (ca) {
38139
+ var fs4 = __require("fs");
38140
+ __require("path");
38141
+ D = __dirname + "/";
38142
+ Fa = (a) => {
38143
+ a = Ga(a) ? new URL(a) : a;
38144
+ return fs4.readFileSync(a);
38145
+ };
38146
+ Ea = async (a) => {
38147
+ a = Ga(a) ? new URL(a) : a;
38148
+ return fs4.readFileSync(a, undefined);
38149
+ };
38150
+ !f3.thisProgram && 1 < process.argv.length && (Ca = process.argv[1].replace(/\\/g, "/"));
38151
+ process.argv.slice(2);
38152
+ typeof module != "undefined" && (module.exports = f3);
38153
+ Da = (a, b) => {
38154
+ process.exitCode = a;
38155
+ throw b;
38156
+ };
38157
+ } else if (aa || ba)
38158
+ ba ? D = self.location.href : typeof document != "undefined" && document.currentScript && (D = document.currentScript.src), D = D.startsWith("blob:") ? "" : D.slice(0, D.replace(/[?#].*/, "").lastIndexOf("/") + 1), ba && (Fa = (a) => {
38159
+ var b = new XMLHttpRequest;
38160
+ b.open("GET", a, false);
38161
+ b.responseType = "arraybuffer";
38162
+ b.send(null);
38163
+ return new Uint8Array(b.response);
38164
+ }), Ea = async (a) => {
38165
+ if (Ga(a))
38166
+ return new Promise((c, d) => {
38167
+ var e2 = new XMLHttpRequest;
38168
+ e2.open("GET", a, true);
38169
+ e2.responseType = "arraybuffer";
38170
+ e2.onload = () => {
38171
+ e2.status == 200 || e2.status == 0 && e2.response ? c(e2.response) : d(e2.status);
38172
+ };
38173
+ e2.onerror = d;
38174
+ e2.send(null);
38175
+ });
38176
+ var b = await fetch(a, { credentials: "same-origin" });
38177
+ if (b.ok)
38178
+ return b.arrayBuffer();
38179
+ throw Error(b.status + " : " + b.url);
38180
+ };
38181
+ var Ha = f3.print || console.log.bind(console), Ia = f3.printErr || console.error.bind(console);
38182
+ Object.assign(f3, Ba);
38183
+ Ba = null;
38184
+ f3.thisProgram && (Ca = f3.thisProgram);
38185
+ var Ja = f3.wasmBinary, Ka, La = false, Ma, p, x2, Na, E, F2, Oa, H, Pa, Ga = (a) => a.startsWith("file://");
38186
+ function Qa() {
38187
+ var a = Ka.buffer;
38188
+ f3.HEAP8 = p = new Int8Array(a);
38189
+ f3.HEAP16 = Na = new Int16Array(a);
38190
+ f3.HEAPU8 = x2 = new Uint8Array(a);
38191
+ f3.HEAPU16 = new Uint16Array(a);
38192
+ f3.HEAP32 = E = new Int32Array(a);
38193
+ f3.HEAPU32 = F2 = new Uint32Array(a);
38194
+ f3.HEAPF32 = Oa = new Float32Array(a);
38195
+ f3.HEAPF64 = Pa = new Float64Array(a);
38196
+ f3.HEAP64 = H = new BigInt64Array(a);
38197
+ f3.HEAPU64 = new BigUint64Array(a);
38198
+ }
38199
+ var K = 0, Sa = null;
38200
+ function Ta(a) {
38201
+ f3.onAbort?.(a);
38202
+ a = "Aborted(" + a + ")";
38203
+ Ia(a);
38204
+ La = true;
38205
+ throw new WebAssembly.RuntimeError(a + ". Build with -sASSERTIONS for more info.");
38206
+ }
38207
+ var Ua;
38208
+ async function Va(a) {
38209
+ if (!Ja)
38210
+ try {
38211
+ var b = await Ea(a);
38212
+ return new Uint8Array(b);
38213
+ } catch {}
38214
+ if (a == Ua && Ja)
38215
+ a = new Uint8Array(Ja);
38216
+ else if (Fa)
38217
+ a = Fa(a);
38218
+ else
38219
+ throw "both async and sync fetching of the wasm failed";
38220
+ return a;
37823
38221
  }
37824
- if (exists(join3(dir, "package.json")) || exists(join3(dir, "node_modules"))) {
37825
- return dir;
38222
+ async function Wa(a, b) {
38223
+ try {
38224
+ var c = await Va(a);
38225
+ return await WebAssembly.instantiate(c, b);
38226
+ } catch (d) {
38227
+ Ia(`failed to asynchronously prepare wasm: ${d}`), Ta(d);
38228
+ }
37826
38229
  }
37827
- if (prev === dir) {
37828
- throw new Error('Could not find module root given file: "' + file2 + '". Do you have a `package.json` file? ');
38230
+ async function Xa(a) {
38231
+ var b = Ua;
38232
+ if (!Ja && typeof WebAssembly.instantiateStreaming == "function" && !Ga(b) && !ca)
38233
+ try {
38234
+ var c = fetch(b, { credentials: "same-origin" });
38235
+ return await WebAssembly.instantiateStreaming(c, a);
38236
+ } catch (d) {
38237
+ Ia(`wasm streaming compile failed: ${d}`), Ia("falling back to ArrayBuffer instantiation");
38238
+ }
38239
+ return Wa(b, a);
37829
38240
  }
37830
- prev = dir;
37831
- dir = join3(dir, "..");
37832
- }
37833
- };
37834
- });
37835
-
37836
- // ../../node_modules/better-sqlite3/lib/methods/wrappers.js
37837
- var require_wrappers = __commonJS((exports) => {
37838
- var { cppdb } = require_util3();
37839
- exports.prepare = function prepare(sql) {
37840
- return this[cppdb].prepare(sql, this, false);
37841
- };
37842
- exports.exec = function exec(sql) {
37843
- this[cppdb].exec(sql);
37844
- return this;
37845
- };
37846
- exports.close = function close() {
37847
- this[cppdb].close();
37848
- return this;
37849
- };
37850
- exports.loadExtension = function loadExtension(...args) {
37851
- this[cppdb].loadExtension(...args);
37852
- return this;
37853
- };
37854
- exports.defaultSafeIntegers = function defaultSafeIntegers(...args) {
37855
- this[cppdb].defaultSafeIntegers(...args);
37856
- return this;
37857
- };
37858
- exports.unsafeMode = function unsafeMode(...args) {
37859
- this[cppdb].unsafeMode(...args);
37860
- return this;
37861
- };
37862
- exports.getters = {
37863
- name: {
37864
- get: function name() {
37865
- return this[cppdb].name;
37866
- },
37867
- enumerable: true
37868
- },
37869
- open: {
37870
- get: function open() {
37871
- return this[cppdb].open;
37872
- },
37873
- enumerable: true
37874
- },
37875
- inTransaction: {
37876
- get: function inTransaction() {
37877
- return this[cppdb].inTransaction;
37878
- },
37879
- enumerable: true
37880
- },
37881
- readonly: {
37882
- get: function readonly() {
37883
- return this[cppdb].readonly;
37884
- },
37885
- enumerable: true
37886
- },
37887
- memory: {
37888
- get: function memory() {
37889
- return this[cppdb].memory;
37890
- },
37891
- enumerable: true
37892
- }
37893
- };
37894
- });
37895
38241
 
37896
- // ../../node_modules/better-sqlite3/lib/methods/transaction.js
37897
- var require_transaction = __commonJS((exports, module) => {
37898
- var { cppdb } = require_util3();
37899
- var controllers = new WeakMap;
37900
- module.exports = function transaction(fn) {
37901
- if (typeof fn !== "function")
37902
- throw new TypeError("Expected first argument to be a function");
37903
- const db2 = this[cppdb];
37904
- const controller = getController(db2, this);
37905
- const { apply: apply2 } = Function.prototype;
37906
- const properties = {
37907
- default: { value: wrapTransaction(apply2, fn, db2, controller.default) },
37908
- deferred: { value: wrapTransaction(apply2, fn, db2, controller.deferred) },
37909
- immediate: { value: wrapTransaction(apply2, fn, db2, controller.immediate) },
37910
- exclusive: { value: wrapTransaction(apply2, fn, db2, controller.exclusive) },
37911
- database: { value: this, enumerable: true }
37912
- };
37913
- Object.defineProperties(properties.default.value, properties);
37914
- Object.defineProperties(properties.deferred.value, properties);
37915
- Object.defineProperties(properties.immediate.value, properties);
37916
- Object.defineProperties(properties.exclusive.value, properties);
37917
- return properties.default.value;
37918
- };
37919
- var getController = (db2, self2) => {
37920
- let controller = controllers.get(db2);
37921
- if (!controller) {
37922
- const shared = {
37923
- commit: db2.prepare("COMMIT", self2, false),
37924
- rollback: db2.prepare("ROLLBACK", self2, false),
37925
- savepoint: db2.prepare("SAVEPOINT `\t_bs3.\t`", self2, false),
37926
- release: db2.prepare("RELEASE `\t_bs3.\t`", self2, false),
37927
- rollbackTo: db2.prepare("ROLLBACK TO `\t_bs3.\t`", self2, false)
37928
- };
37929
- controllers.set(db2, controller = {
37930
- default: Object.assign({ begin: db2.prepare("BEGIN", self2, false) }, shared),
37931
- deferred: Object.assign({ begin: db2.prepare("BEGIN DEFERRED", self2, false) }, shared),
37932
- immediate: Object.assign({ begin: db2.prepare("BEGIN IMMEDIATE", self2, false) }, shared),
37933
- exclusive: Object.assign({ begin: db2.prepare("BEGIN EXCLUSIVE", self2, false) }, shared)
37934
- });
37935
- }
37936
- return controller;
37937
- };
37938
- var wrapTransaction = (apply2, fn, db2, { begin, commit, rollback, savepoint, release, rollbackTo }) => function sqliteTransaction() {
37939
- let before, after, undo;
37940
- if (db2.inTransaction) {
37941
- before = savepoint;
37942
- after = release;
37943
- undo = rollbackTo;
37944
- } else {
37945
- before = begin;
37946
- after = commit;
37947
- undo = rollback;
37948
- }
37949
- before.run();
37950
- try {
37951
- const result = apply2.call(fn, this, arguments);
37952
- if (result && typeof result.then === "function") {
37953
- throw new TypeError("Transaction function cannot return a promise");
38242
+ class Ya {
38243
+ name = "ExitStatus";
38244
+ constructor(a) {
38245
+ this.message = `Program terminated with exit(${a})`;
38246
+ this.status = a;
38247
+ }
37954
38248
  }
37955
- after.run();
37956
- return result;
37957
- } catch (ex) {
37958
- if (db2.inTransaction) {
37959
- undo.run();
37960
- if (undo !== rollback)
37961
- after.run();
38249
+ var Za = (a) => {
38250
+ for (;0 < a.length; )
38251
+ a.shift()(f3);
38252
+ }, $a = [], ab = [], bb = () => {
38253
+ var a = f3.preRun.shift();
38254
+ ab.unshift(a);
38255
+ };
38256
+ function m2(a, b = "i8") {
38257
+ b.endsWith("*") && (b = "*");
38258
+ switch (b) {
38259
+ case "i1":
38260
+ return p[a];
38261
+ case "i8":
38262
+ return p[a];
38263
+ case "i16":
38264
+ return Na[a >> 1];
38265
+ case "i32":
38266
+ return E[a >> 2];
38267
+ case "i64":
38268
+ return H[a >> 3];
38269
+ case "float":
38270
+ return Oa[a >> 2];
38271
+ case "double":
38272
+ return Pa[a >> 3];
38273
+ case "*":
38274
+ return F2[a >> 2];
38275
+ default:
38276
+ Ta(`invalid type for getValue: ${b}`);
38277
+ }
37962
38278
  }
37963
- throw ex;
37964
- }
37965
- };
37966
- });
37967
-
37968
- // ../../node_modules/better-sqlite3/lib/methods/pragma.js
37969
- var require_pragma = __commonJS((exports, module) => {
37970
- var { getBooleanOption, cppdb } = require_util3();
37971
- module.exports = function pragma(source, options) {
37972
- if (options == null)
37973
- options = {};
37974
- if (typeof source !== "string")
37975
- throw new TypeError("Expected first argument to be a string");
37976
- if (typeof options !== "object")
37977
- throw new TypeError("Expected second argument to be an options object");
37978
- const simple = getBooleanOption(options, "simple");
37979
- const stmt = this[cppdb].prepare(`PRAGMA ${source}`, this, true);
37980
- return simple ? stmt.pluck().get() : stmt.all();
37981
- };
37982
- });
37983
-
37984
- // ../../node_modules/better-sqlite3/lib/methods/backup.js
37985
- var require_backup = __commonJS((exports, module) => {
37986
- var fs4 = __require("fs");
37987
- var path = __require("path");
37988
- var { promisify: promisify2 } = __require("util");
37989
- var { cppdb } = require_util3();
37990
- var fsAccess = promisify2(fs4.access);
37991
- module.exports = async function backup(filename, options) {
37992
- if (options == null)
37993
- options = {};
37994
- if (typeof filename !== "string")
37995
- throw new TypeError("Expected first argument to be a string");
37996
- if (typeof options !== "object")
37997
- throw new TypeError("Expected second argument to be an options object");
37998
- filename = filename.trim();
37999
- const attachedName = "attached" in options ? options.attached : "main";
38000
- const handler13 = "progress" in options ? options.progress : null;
38001
- if (!filename)
38002
- throw new TypeError("Backup filename cannot be an empty string");
38003
- if (filename === ":memory:")
38004
- throw new TypeError('Invalid backup filename ":memory:"');
38005
- if (typeof attachedName !== "string")
38006
- throw new TypeError('Expected the "attached" option to be a string');
38007
- if (!attachedName)
38008
- throw new TypeError('The "attached" option cannot be an empty string');
38009
- if (handler13 != null && typeof handler13 !== "function")
38010
- throw new TypeError('Expected the "progress" option to be a function');
38011
- await fsAccess(path.dirname(filename)).catch(() => {
38012
- throw new TypeError("Cannot save backup because the directory does not exist");
38013
- });
38014
- const isNewFile = await fsAccess(filename).then(() => false, () => true);
38015
- return runBackup(this[cppdb].backup(this, attachedName, filename, isNewFile), handler13 || null);
38016
- };
38017
- var runBackup = (backup, handler13) => {
38018
- let rate = 0;
38019
- let useDefault = true;
38020
- return new Promise((resolve4, reject) => {
38021
- setImmediate(function step() {
38022
- try {
38023
- const progress = backup.transfer(rate);
38024
- if (!progress.remainingPages) {
38025
- backup.close();
38026
- resolve4(progress);
38027
- return;
38279
+ var cb = f3.noExitRuntime || true;
38280
+ function ta(a) {
38281
+ var b = "i32";
38282
+ b.endsWith("*") && (b = "*");
38283
+ switch (b) {
38284
+ case "i1":
38285
+ p[a] = 0;
38286
+ break;
38287
+ case "i8":
38288
+ p[a] = 0;
38289
+ break;
38290
+ case "i16":
38291
+ Na[a >> 1] = 0;
38292
+ break;
38293
+ case "i32":
38294
+ E[a >> 2] = 0;
38295
+ break;
38296
+ case "i64":
38297
+ H[a >> 3] = BigInt(0);
38298
+ break;
38299
+ case "float":
38300
+ Oa[a >> 2] = 0;
38301
+ break;
38302
+ case "double":
38303
+ Pa[a >> 3] = 0;
38304
+ break;
38305
+ case "*":
38306
+ F2[a >> 2] = 0;
38307
+ break;
38308
+ default:
38309
+ Ta(`invalid type for setValue: ${b}`);
38310
+ }
38311
+ }
38312
+ var db2 = typeof TextDecoder != "undefined" ? new TextDecoder : undefined, B = (a, b = 0, c = NaN) => {
38313
+ var d = b + c;
38314
+ for (c = b;a[c] && !(c >= d); )
38315
+ ++c;
38316
+ if (16 < c - b && a.buffer && db2)
38317
+ return db2.decode(a.subarray(b, c));
38318
+ for (d = "";b < c; ) {
38319
+ var e2 = a[b++];
38320
+ if (e2 & 128) {
38321
+ var h2 = a[b++] & 63;
38322
+ if ((e2 & 224) == 192)
38323
+ d += String.fromCharCode((e2 & 31) << 6 | h2);
38324
+ else {
38325
+ var k = a[b++] & 63;
38326
+ e2 = (e2 & 240) == 224 ? (e2 & 15) << 12 | h2 << 6 | k : (e2 & 7) << 18 | h2 << 12 | k << 6 | a[b++] & 63;
38327
+ 65536 > e2 ? d += String.fromCharCode(e2) : (e2 -= 65536, d += String.fromCharCode(55296 | e2 >> 10, 56320 | e2 & 1023));
38328
+ }
38329
+ } else
38330
+ d += String.fromCharCode(e2);
38331
+ }
38332
+ return d;
38333
+ }, ua = (a, b) => a ? B(x2, a, b) : "", eb = (a, b) => {
38334
+ for (var c = 0, d = a.length - 1;0 <= d; d--) {
38335
+ var e2 = a[d];
38336
+ e2 === "." ? a.splice(d, 1) : e2 === ".." ? (a.splice(d, 1), c++) : c && (a.splice(d, 1), c--);
38337
+ }
38338
+ if (b)
38339
+ for (;c; c--)
38340
+ a.unshift("..");
38341
+ return a;
38342
+ }, ka = (a) => {
38343
+ var b = a.charAt(0) === "/", c = a.slice(-1) === "/";
38344
+ (a = eb(a.split("/").filter((d) => !!d), !b).join("/")) || b || (a = ".");
38345
+ a && c && (a += "/");
38346
+ return (b ? "/" : "") + a;
38347
+ }, fb = (a) => {
38348
+ var b = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);
38349
+ a = b[0];
38350
+ b = b[1];
38351
+ if (!a && !b)
38352
+ return ".";
38353
+ b &&= b.slice(0, -1);
38354
+ return a + b;
38355
+ }, gb = (a) => a && a.match(/([^\/]+|\/)\/*$/)[1], hb = () => {
38356
+ if (ca) {
38357
+ var a = __require("crypto");
38358
+ return (b) => a.randomFillSync(b);
38359
+ }
38360
+ return (b) => crypto.getRandomValues(b);
38361
+ }, ib = (a) => {
38362
+ (ib = hb())(a);
38363
+ }, jb = (...a) => {
38364
+ for (var b = "", c = false, d = a.length - 1;-1 <= d && !c; d--) {
38365
+ c = 0 <= d ? a[d] : "/";
38366
+ if (typeof c != "string")
38367
+ throw new TypeError("Arguments to path.resolve must be strings");
38368
+ if (!c)
38369
+ return "";
38370
+ b = c + "/" + b;
38371
+ c = c.charAt(0) === "/";
38372
+ }
38373
+ b = eb(b.split("/").filter((e2) => !!e2), !c).join("/");
38374
+ return (c ? "/" : "") + b || ".";
38375
+ }, kb = [], ha = (a) => {
38376
+ for (var b = 0, c = 0;c < a.length; ++c) {
38377
+ var d = a.charCodeAt(c);
38378
+ 127 >= d ? b++ : 2047 >= d ? b += 2 : 55296 <= d && 57343 >= d ? (b += 4, ++c) : b += 3;
38379
+ }
38380
+ return b;
38381
+ }, u = (a, b, c, d) => {
38382
+ if (!(0 < d))
38383
+ return 0;
38384
+ var e2 = c;
38385
+ d = c + d - 1;
38386
+ for (var h2 = 0;h2 < a.length; ++h2) {
38387
+ var k = a.charCodeAt(h2);
38388
+ if (55296 <= k && 57343 >= k) {
38389
+ var q = a.charCodeAt(++h2);
38390
+ k = 65536 + ((k & 1023) << 10) | q & 1023;
38028
38391
  }
38029
- if (useDefault) {
38030
- useDefault = false;
38031
- rate = 100;
38392
+ if (127 >= k) {
38393
+ if (c >= d)
38394
+ break;
38395
+ b[c++] = k;
38396
+ } else {
38397
+ if (2047 >= k) {
38398
+ if (c + 1 >= d)
38399
+ break;
38400
+ b[c++] = 192 | k >> 6;
38401
+ } else {
38402
+ if (65535 >= k) {
38403
+ if (c + 2 >= d)
38404
+ break;
38405
+ b[c++] = 224 | k >> 12;
38406
+ } else {
38407
+ if (c + 3 >= d)
38408
+ break;
38409
+ b[c++] = 240 | k >> 18;
38410
+ b[c++] = 128 | k >> 12 & 63;
38411
+ }
38412
+ b[c++] = 128 | k >> 6 & 63;
38413
+ }
38414
+ b[c++] = 128 | k & 63;
38032
38415
  }
38033
- if (handler13) {
38034
- const ret = handler13(progress);
38035
- if (ret !== undefined) {
38036
- if (typeof ret === "number" && ret === ret)
38037
- rate = Math.max(0, Math.min(2147483647, Math.round(ret)));
38038
- else
38039
- throw new TypeError("Expected progress callback to return a number or undefined");
38416
+ }
38417
+ b[c] = 0;
38418
+ return c - e2;
38419
+ }, ra = (a, b) => {
38420
+ var c = Array(ha(a) + 1);
38421
+ a = u(a, c, 0, c.length);
38422
+ b && (c.length = a);
38423
+ return c;
38424
+ }, mb = [];
38425
+ function nb(a, b) {
38426
+ mb[a] = { input: [], output: [], cb: b };
38427
+ wb(a, xb);
38428
+ }
38429
+ var xb = { open(a) {
38430
+ var b = mb[a.node.rdev];
38431
+ if (!b)
38432
+ throw new N(43);
38433
+ a.tty = b;
38434
+ a.seekable = false;
38435
+ }, close(a) {
38436
+ a.tty.cb.fsync(a.tty);
38437
+ }, fsync(a) {
38438
+ a.tty.cb.fsync(a.tty);
38439
+ }, read(a, b, c, d) {
38440
+ if (!a.tty || !a.tty.cb.xb)
38441
+ throw new N(60);
38442
+ for (var e2 = 0, h2 = 0;h2 < d; h2++) {
38443
+ try {
38444
+ var k = a.tty.cb.xb(a.tty);
38445
+ } catch (q) {
38446
+ throw new N(29);
38447
+ }
38448
+ if (k === undefined && e2 === 0)
38449
+ throw new N(6);
38450
+ if (k === null || k === undefined)
38451
+ break;
38452
+ e2++;
38453
+ b[c + h2] = k;
38454
+ }
38455
+ e2 && (a.node.atime = Date.now());
38456
+ return e2;
38457
+ }, write(a, b, c, d) {
38458
+ if (!a.tty || !a.tty.cb.qb)
38459
+ throw new N(60);
38460
+ try {
38461
+ for (var e2 = 0;e2 < d; e2++)
38462
+ a.tty.cb.qb(a.tty, b[c + e2]);
38463
+ } catch (h2) {
38464
+ throw new N(29);
38465
+ }
38466
+ d && (a.node.mtime = a.node.ctime = Date.now());
38467
+ return e2;
38468
+ } }, yb = { xb() {
38469
+ a: {
38470
+ if (!kb.length) {
38471
+ var a = null;
38472
+ if (ca) {
38473
+ var b = Buffer.alloc(256), c = 0, d = process.stdin.fd;
38474
+ try {
38475
+ c = fs4.readSync(d, b, 0, 256);
38476
+ } catch (e2) {
38477
+ if (e2.toString().includes("EOF"))
38478
+ c = 0;
38479
+ else
38480
+ throw e2;
38481
+ }
38482
+ 0 < c && (a = b.slice(0, c).toString("utf-8"));
38483
+ } else
38484
+ typeof window != "undefined" && typeof window.prompt == "function" && (a = window.prompt("Input: "), a !== null && (a += `
38485
+ `));
38486
+ if (!a) {
38487
+ a = null;
38488
+ break a;
38040
38489
  }
38490
+ kb = ra(a, true);
38041
38491
  }
38042
- setImmediate(step);
38043
- } catch (err) {
38044
- backup.close();
38045
- reject(err);
38492
+ a = kb.shift();
38493
+ }
38494
+ return a;
38495
+ }, qb(a, b) {
38496
+ b === null || b === 10 ? (Ha(B(a.output)), a.output = []) : b != 0 && a.output.push(b);
38497
+ }, fsync(a) {
38498
+ 0 < a.output?.length && (Ha(B(a.output)), a.output = []);
38499
+ }, Tb() {
38500
+ return { Ob: 25856, Qb: 5, Nb: 191, Pb: 35387, Mb: [3, 28, 127, 21, 4, 0, 1, 0, 17, 19, 26, 0, 18, 15, 23, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] };
38501
+ }, Ub() {
38502
+ return 0;
38503
+ }, Vb() {
38504
+ return [24, 80];
38505
+ } }, zb = { qb(a, b) {
38506
+ b === null || b === 10 ? (Ia(B(a.output)), a.output = []) : b != 0 && a.output.push(b);
38507
+ }, fsync(a) {
38508
+ 0 < a.output?.length && (Ia(B(a.output)), a.output = []);
38509
+ } }, O = { Wa: null, Xa() {
38510
+ return O.createNode(null, "/", 16895, 0);
38511
+ }, createNode(a, b, c, d) {
38512
+ if ((c & 61440) === 24576 || (c & 61440) === 4096)
38513
+ throw new N(63);
38514
+ O.Wa || (O.Wa = { dir: { node: { Ta: O.La.Ta, Ua: O.La.Ua, lookup: O.La.lookup, hb: O.La.hb, rename: O.La.rename, unlink: O.La.unlink, rmdir: O.La.rmdir, readdir: O.La.readdir, symlink: O.La.symlink }, stream: { Va: O.Ma.Va } }, file: { node: { Ta: O.La.Ta, Ua: O.La.Ua }, stream: { Va: O.Ma.Va, read: O.Ma.read, write: O.Ma.write, ib: O.Ma.ib, jb: O.Ma.jb } }, link: { node: { Ta: O.La.Ta, Ua: O.La.Ua, readlink: O.La.readlink }, stream: {} }, ub: { node: { Ta: O.La.Ta, Ua: O.La.Ua }, stream: Ab } });
38515
+ c = Bb(a, b, c, d);
38516
+ P(c.mode) ? (c.La = O.Wa.dir.node, c.Ma = O.Wa.dir.stream, c.Na = {}) : (c.mode & 61440) === 32768 ? (c.La = O.Wa.file.node, c.Ma = O.Wa.file.stream, c.Ra = 0, c.Na = null) : (c.mode & 61440) === 40960 ? (c.La = O.Wa.link.node, c.Ma = O.Wa.link.stream) : (c.mode & 61440) === 8192 && (c.La = O.Wa.ub.node, c.Ma = O.Wa.ub.stream);
38517
+ c.atime = c.mtime = c.ctime = Date.now();
38518
+ a && (a.Na[b] = c, a.atime = a.mtime = a.ctime = c.atime);
38519
+ return c;
38520
+ }, Sb(a) {
38521
+ return a.Na ? a.Na.subarray ? a.Na.subarray(0, a.Ra) : new Uint8Array(a.Na) : new Uint8Array(0);
38522
+ }, La: { Ta(a) {
38523
+ var b = {};
38524
+ b.dev = (a.mode & 61440) === 8192 ? a.id : 1;
38525
+ b.ino = a.id;
38526
+ b.mode = a.mode;
38527
+ b.nlink = 1;
38528
+ b.uid = 0;
38529
+ b.gid = 0;
38530
+ b.rdev = a.rdev;
38531
+ P(a.mode) ? b.size = 4096 : (a.mode & 61440) === 32768 ? b.size = a.Ra : (a.mode & 61440) === 40960 ? b.size = a.link.length : b.size = 0;
38532
+ b.atime = new Date(a.atime);
38533
+ b.mtime = new Date(a.mtime);
38534
+ b.ctime = new Date(a.ctime);
38535
+ b.blksize = 4096;
38536
+ b.blocks = Math.ceil(b.size / b.blksize);
38537
+ return b;
38538
+ }, Ua(a, b) {
38539
+ for (var c of ["mode", "atime", "mtime", "ctime"])
38540
+ b[c] != null && (a[c] = b[c]);
38541
+ b.size !== undefined && (b = b.size, a.Ra != b && (b == 0 ? (a.Na = null, a.Ra = 0) : (c = a.Na, a.Na = new Uint8Array(b), c && a.Na.set(c.subarray(0, Math.min(b, a.Ra))), a.Ra = b)));
38542
+ }, lookup() {
38543
+ throw O.vb;
38544
+ }, hb(a, b, c, d) {
38545
+ return O.createNode(a, b, c, d);
38546
+ }, rename(a, b, c) {
38547
+ try {
38548
+ var d = Q(b, c);
38549
+ } catch (h2) {}
38550
+ if (d) {
38551
+ if (P(a.mode))
38552
+ for (var e2 in d.Na)
38553
+ throw new N(55);
38554
+ Cb(d);
38555
+ }
38556
+ delete a.parent.Na[a.name];
38557
+ b.Na[c] = a;
38558
+ a.name = c;
38559
+ b.ctime = b.mtime = a.parent.ctime = a.parent.mtime = Date.now();
38560
+ }, unlink(a, b) {
38561
+ delete a.Na[b];
38562
+ a.ctime = a.mtime = Date.now();
38563
+ }, rmdir(a, b) {
38564
+ var c = Q(a, b), d;
38565
+ for (d in c.Na)
38566
+ throw new N(55);
38567
+ delete a.Na[b];
38568
+ a.ctime = a.mtime = Date.now();
38569
+ }, readdir(a) {
38570
+ return [".", "..", ...Object.keys(a.Na)];
38571
+ }, symlink(a, b, c) {
38572
+ a = O.createNode(a, b, 41471, 0);
38573
+ a.link = c;
38574
+ return a;
38575
+ }, readlink(a) {
38576
+ if ((a.mode & 61440) !== 40960)
38577
+ throw new N(28);
38578
+ return a.link;
38579
+ } }, Ma: { read(a, b, c, d, e2) {
38580
+ var h2 = a.node.Na;
38581
+ if (e2 >= a.node.Ra)
38582
+ return 0;
38583
+ a = Math.min(a.node.Ra - e2, d);
38584
+ if (8 < a && h2.subarray)
38585
+ b.set(h2.subarray(e2, e2 + a), c);
38586
+ else
38587
+ for (d = 0;d < a; d++)
38588
+ b[c + d] = h2[e2 + d];
38589
+ return a;
38590
+ }, write(a, b, c, d, e2, h2) {
38591
+ b.buffer === p.buffer && (h2 = false);
38592
+ if (!d)
38593
+ return 0;
38594
+ a = a.node;
38595
+ a.mtime = a.ctime = Date.now();
38596
+ if (b.subarray && (!a.Na || a.Na.subarray)) {
38597
+ if (h2)
38598
+ return a.Na = b.subarray(c, c + d), a.Ra = d;
38599
+ if (a.Ra === 0 && e2 === 0)
38600
+ return a.Na = b.slice(c, c + d), a.Ra = d;
38601
+ if (e2 + d <= a.Ra)
38602
+ return a.Na.set(b.subarray(c, c + d), e2), d;
38603
+ }
38604
+ h2 = e2 + d;
38605
+ var k = a.Na ? a.Na.length : 0;
38606
+ k >= h2 || (h2 = Math.max(h2, k * (1048576 > k ? 2 : 1.125) >>> 0), k != 0 && (h2 = Math.max(h2, 256)), k = a.Na, a.Na = new Uint8Array(h2), 0 < a.Ra && a.Na.set(k.subarray(0, a.Ra), 0));
38607
+ if (a.Na.subarray && b.subarray)
38608
+ a.Na.set(b.subarray(c, c + d), e2);
38609
+ else
38610
+ for (h2 = 0;h2 < d; h2++)
38611
+ a.Na[e2 + h2] = b[c + h2];
38612
+ a.Ra = Math.max(a.Ra, e2 + d);
38613
+ return d;
38614
+ }, Va(a, b, c) {
38615
+ c === 1 ? b += a.position : c === 2 && (a.node.mode & 61440) === 32768 && (b += a.node.Ra);
38616
+ if (0 > b)
38617
+ throw new N(28);
38618
+ return b;
38619
+ }, ib(a, b, c, d, e2) {
38620
+ if ((a.node.mode & 61440) !== 32768)
38621
+ throw new N(43);
38622
+ a = a.node.Na;
38623
+ if (e2 & 2 || !a || a.buffer !== p.buffer) {
38624
+ e2 = true;
38625
+ d = 65536 * Math.ceil(b / 65536);
38626
+ var h2 = Db(65536, d);
38627
+ h2 && x2.fill(0, h2, h2 + d);
38628
+ d = h2;
38629
+ if (!d)
38630
+ throw new N(48);
38631
+ if (a) {
38632
+ if (0 < c || c + b < a.length)
38633
+ a.subarray ? a = a.subarray(c, c + b) : a = Array.prototype.slice.call(a, c, c + b);
38634
+ p.set(a, d);
38635
+ }
38636
+ } else
38637
+ e2 = false, d = a.byteOffset;
38638
+ return { Kb: d, Ab: e2 };
38639
+ }, jb(a, b, c, d) {
38640
+ O.Ma.write(a, b, 0, d, c, false);
38641
+ return 0;
38642
+ } } }, la = (a, b) => {
38643
+ var c = 0;
38644
+ a && (c |= 365);
38645
+ b && (c |= 146);
38646
+ return c;
38647
+ }, Eb = null, Fb = {}, Gb = [], Hb = 1, R = null, Ib = false, Jb = true, Kb = {}, N = class {
38648
+ name = "ErrnoError";
38649
+ constructor(a) {
38650
+ this.Pa = a;
38651
+ }
38652
+ }, Lb = class {
38653
+ gb = {};
38654
+ node = null;
38655
+ get flags() {
38656
+ return this.gb.flags;
38657
+ }
38658
+ set flags(a) {
38659
+ this.gb.flags = a;
38660
+ }
38661
+ get position() {
38662
+ return this.gb.position;
38663
+ }
38664
+ set position(a) {
38665
+ this.gb.position = a;
38666
+ }
38667
+ }, Mb = class {
38668
+ La = {};
38669
+ Ma = {};
38670
+ ab = null;
38671
+ constructor(a, b, c, d) {
38672
+ a ||= this;
38673
+ this.parent = a;
38674
+ this.Xa = a.Xa;
38675
+ this.id = Hb++;
38676
+ this.name = b;
38677
+ this.mode = c;
38678
+ this.rdev = d;
38679
+ this.atime = this.mtime = this.ctime = Date.now();
38680
+ }
38681
+ get read() {
38682
+ return (this.mode & 365) === 365;
38683
+ }
38684
+ set read(a) {
38685
+ a ? this.mode |= 365 : this.mode &= -366;
38686
+ }
38687
+ get write() {
38688
+ return (this.mode & 146) === 146;
38689
+ }
38690
+ set write(a) {
38691
+ a ? this.mode |= 146 : this.mode &= -147;
38046
38692
  }
38047
- });
38048
- });
38049
- };
38050
- });
38051
-
38052
- // ../../node_modules/better-sqlite3/lib/methods/serialize.js
38053
- var require_serialize = __commonJS((exports, module) => {
38054
- var { cppdb } = require_util3();
38055
- module.exports = function serialize(options) {
38056
- if (options == null)
38057
- options = {};
38058
- if (typeof options !== "object")
38059
- throw new TypeError("Expected first argument to be an options object");
38060
- const attachedName = "attached" in options ? options.attached : "main";
38061
- if (typeof attachedName !== "string")
38062
- throw new TypeError('Expected the "attached" option to be a string');
38063
- if (!attachedName)
38064
- throw new TypeError('The "attached" option cannot be an empty string');
38065
- return this[cppdb].serialize(attachedName);
38066
- };
38067
- });
38068
-
38069
- // ../../node_modules/better-sqlite3/lib/methods/function.js
38070
- var require_function = __commonJS((exports, module) => {
38071
- var { getBooleanOption, cppdb } = require_util3();
38072
- module.exports = function defineFunction(name17, options, fn) {
38073
- if (options == null)
38074
- options = {};
38075
- if (typeof options === "function") {
38076
- fn = options;
38077
- options = {};
38078
- }
38079
- if (typeof name17 !== "string")
38080
- throw new TypeError("Expected first argument to be a string");
38081
- if (typeof fn !== "function")
38082
- throw new TypeError("Expected last argument to be a function");
38083
- if (typeof options !== "object")
38084
- throw new TypeError("Expected second argument to be an options object");
38085
- if (!name17)
38086
- throw new TypeError("User-defined function name cannot be an empty string");
38087
- const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
38088
- const deterministic = getBooleanOption(options, "deterministic");
38089
- const directOnly = getBooleanOption(options, "directOnly");
38090
- const varargs = getBooleanOption(options, "varargs");
38091
- let argCount = -1;
38092
- if (!varargs) {
38093
- argCount = fn.length;
38094
- if (!Number.isInteger(argCount) || argCount < 0)
38095
- throw new TypeError("Expected function.length to be a positive integer");
38096
- if (argCount > 100)
38097
- throw new RangeError("User-defined functions cannot have more than 100 arguments");
38098
- }
38099
- this[cppdb].function(fn, name17, argCount, safeIntegers, deterministic, directOnly);
38100
- return this;
38101
- };
38102
- });
38103
-
38104
- // ../../node_modules/better-sqlite3/lib/methods/aggregate.js
38105
- var require_aggregate = __commonJS((exports, module) => {
38106
- var { getBooleanOption, cppdb } = require_util3();
38107
- module.exports = function defineAggregate(name17, options) {
38108
- if (typeof name17 !== "string")
38109
- throw new TypeError("Expected first argument to be a string");
38110
- if (typeof options !== "object" || options === null)
38111
- throw new TypeError("Expected second argument to be an options object");
38112
- if (!name17)
38113
- throw new TypeError("User-defined function name cannot be an empty string");
38114
- const start = "start" in options ? options.start : null;
38115
- const step = getFunctionOption(options, "step", true);
38116
- const inverse = getFunctionOption(options, "inverse", false);
38117
- const result = getFunctionOption(options, "result", false);
38118
- const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
38119
- const deterministic = getBooleanOption(options, "deterministic");
38120
- const directOnly = getBooleanOption(options, "directOnly");
38121
- const varargs = getBooleanOption(options, "varargs");
38122
- let argCount = -1;
38123
- if (!varargs) {
38124
- argCount = Math.max(getLength(step), inverse ? getLength(inverse) : 0);
38125
- if (argCount > 0)
38126
- argCount -= 1;
38127
- if (argCount > 100)
38128
- throw new RangeError("User-defined functions cannot have more than 100 arguments");
38129
- }
38130
- this[cppdb].aggregate(start, step, inverse, result, name17, argCount, safeIntegers, deterministic, directOnly);
38131
- return this;
38132
- };
38133
- var getFunctionOption = (options, key, required2) => {
38134
- const value = key in options ? options[key] : null;
38135
- if (typeof value === "function")
38136
- return value;
38137
- if (value != null)
38138
- throw new TypeError(`Expected the "${key}" option to be a function`);
38139
- if (required2)
38140
- throw new TypeError(`Missing required option "${key}"`);
38141
- return null;
38142
- };
38143
- var getLength = ({ length }) => {
38144
- if (Number.isInteger(length) && length >= 0)
38145
- return length;
38146
- throw new TypeError("Expected function.length to be a positive integer");
38147
- };
38148
- });
38149
-
38150
- // ../../node_modules/better-sqlite3/lib/methods/table.js
38151
- var require_table = __commonJS((exports, module) => {
38152
- var { cppdb } = require_util3();
38153
- module.exports = function defineTable(name17, factory) {
38154
- if (typeof name17 !== "string")
38155
- throw new TypeError("Expected first argument to be a string");
38156
- if (!name17)
38157
- throw new TypeError("Virtual table module name cannot be an empty string");
38158
- let eponymous = false;
38159
- if (typeof factory === "object" && factory !== null) {
38160
- eponymous = true;
38161
- factory = defer(parseTableDefinition(factory, "used", name17));
38162
- } else {
38163
- if (typeof factory !== "function")
38164
- throw new TypeError("Expected second argument to be a function or a table definition object");
38165
- factory = wrapFactory(factory);
38166
- }
38167
- this[cppdb].table(factory, name17, eponymous);
38168
- return this;
38169
- };
38170
- function wrapFactory(factory) {
38171
- return function virtualTableFactory(moduleName, databaseName, tableName, ...args) {
38172
- const thisObject = {
38173
- module: moduleName,
38174
- database: databaseName,
38175
- table: tableName
38176
38693
  };
38177
- const def = apply2.call(factory, thisObject, args);
38178
- if (typeof def !== "object" || def === null) {
38179
- throw new TypeError(`Virtual table module "${moduleName}" did not return a table definition object`);
38694
+ function S2(a, b = {}) {
38695
+ if (!a)
38696
+ throw new N(44);
38697
+ b.nb ?? (b.nb = true);
38698
+ a.charAt(0) === "/" || (a = "//" + a);
38699
+ var c = 0;
38700
+ a:
38701
+ for (;40 > c; c++) {
38702
+ a = a.split("/").filter((q) => !!q);
38703
+ for (var d = Eb, e2 = "/", h2 = 0;h2 < a.length; h2++) {
38704
+ var k = h2 === a.length - 1;
38705
+ if (k && b.parent)
38706
+ break;
38707
+ if (a[h2] !== ".")
38708
+ if (a[h2] === "..")
38709
+ e2 = fb(e2), d = d.parent;
38710
+ else {
38711
+ e2 = ka(e2 + "/" + a[h2]);
38712
+ try {
38713
+ d = Q(d, a[h2]);
38714
+ } catch (q) {
38715
+ if (q?.Pa === 44 && k && b.Jb)
38716
+ return { path: e2 };
38717
+ throw q;
38718
+ }
38719
+ !d.ab || k && !b.nb || (d = d.ab.root);
38720
+ if ((d.mode & 61440) === 40960 && (!k || b.$a)) {
38721
+ if (!d.La.readlink)
38722
+ throw new N(52);
38723
+ d = d.La.readlink(d);
38724
+ d.charAt(0) === "/" || (d = fb(e2) + "/" + d);
38725
+ a = d + "/" + a.slice(h2 + 1).join("/");
38726
+ continue a;
38727
+ }
38728
+ }
38729
+ }
38730
+ return { path: e2, node: d };
38731
+ }
38732
+ throw new N(32);
38180
38733
  }
38181
- return parseTableDefinition(def, "returned", moduleName);
38182
- };
38183
- }
38184
- function parseTableDefinition(def, verb, moduleName) {
38185
- if (!hasOwnProperty10.call(def, "rows")) {
38186
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "rows" property`);
38187
- }
38188
- if (!hasOwnProperty10.call(def, "columns")) {
38189
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "columns" property`);
38190
- }
38191
- const rows = def.rows;
38192
- if (typeof rows !== "function" || Object.getPrototypeOf(rows) !== GeneratorFunctionPrototype) {
38193
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "rows" property (should be a generator function)`);
38194
- }
38195
- let columns = def.columns;
38196
- if (!Array.isArray(columns) || !(columns = [...columns]).every((x2) => typeof x2 === "string")) {
38197
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "columns" property (should be an array of strings)`);
38198
- }
38199
- if (columns.length !== new Set(columns).size) {
38200
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate column names`);
38201
- }
38202
- if (!columns.length) {
38203
- throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with zero columns`);
38204
- }
38205
- let parameters;
38206
- if (hasOwnProperty10.call(def, "parameters")) {
38207
- parameters = def.parameters;
38208
- if (!Array.isArray(parameters) || !(parameters = [...parameters]).every((x2) => typeof x2 === "string")) {
38209
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "parameters" property (should be an array of strings)`);
38734
+ function ja(a) {
38735
+ for (var b;; ) {
38736
+ if (a === a.parent)
38737
+ return a = a.Xa.zb, b ? a[a.length - 1] !== "/" ? `${a}/${b}` : a + b : a;
38738
+ b = b ? `${a.name}/${b}` : a.name;
38739
+ a = a.parent;
38740
+ }
38210
38741
  }
38211
- } else {
38212
- parameters = inferParameters(rows);
38213
- }
38214
- if (parameters.length !== new Set(parameters).size) {
38215
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate parameter names`);
38216
- }
38217
- if (parameters.length > 32) {
38218
- throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with more than the maximum number of 32 parameters`);
38219
- }
38220
- for (const parameter of parameters) {
38221
- if (columns.includes(parameter)) {
38222
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with column "${parameter}" which was ambiguously defined as both a column and parameter`);
38742
+ function Nb(a, b) {
38743
+ for (var c = 0, d = 0;d < b.length; d++)
38744
+ c = (c << 5) - c + b.charCodeAt(d) | 0;
38745
+ return (a + c >>> 0) % R.length;
38223
38746
  }
38224
- }
38225
- let safeIntegers = 2;
38226
- if (hasOwnProperty10.call(def, "safeIntegers")) {
38227
- const bool = def.safeIntegers;
38228
- if (typeof bool !== "boolean") {
38229
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "safeIntegers" property (should be a boolean)`);
38747
+ function Cb(a) {
38748
+ var b = Nb(a.parent.id, a.name);
38749
+ if (R[b] === a)
38750
+ R[b] = a.bb;
38751
+ else
38752
+ for (b = R[b];b; ) {
38753
+ if (b.bb === a) {
38754
+ b.bb = a.bb;
38755
+ break;
38756
+ }
38757
+ b = b.bb;
38758
+ }
38230
38759
  }
38231
- safeIntegers = +bool;
38232
- }
38233
- let directOnly = false;
38234
- if (hasOwnProperty10.call(def, "directOnly")) {
38235
- directOnly = def.directOnly;
38236
- if (typeof directOnly !== "boolean") {
38237
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "directOnly" property (should be a boolean)`);
38760
+ function Q(a, b) {
38761
+ var c = P(a.mode) ? (c = Ob(a, "x")) ? c : a.La.lookup ? 0 : 2 : 54;
38762
+ if (c)
38763
+ throw new N(c);
38764
+ for (c = R[Nb(a.id, b)];c; c = c.bb) {
38765
+ var d = c.name;
38766
+ if (c.parent.id === a.id && d === b)
38767
+ return c;
38768
+ }
38769
+ return a.La.lookup(a, b);
38770
+ }
38771
+ function Bb(a, b, c, d) {
38772
+ a = new Mb(a, b, c, d);
38773
+ b = Nb(a.parent.id, a.name);
38774
+ a.bb = R[b];
38775
+ return R[b] = a;
38776
+ }
38777
+ function P(a) {
38778
+ return (a & 61440) === 16384;
38779
+ }
38780
+ function Pb(a) {
38781
+ var b = ["r", "w", "rw"][a & 3];
38782
+ a & 512 && (b += "w");
38783
+ return b;
38238
38784
  }
38239
- }
38240
- const columnDefinitions = [
38241
- ...parameters.map(identifier).map((str) => `${str} HIDDEN`),
38242
- ...columns.map(identifier)
38243
- ];
38244
- return [
38245
- `CREATE TABLE x(${columnDefinitions.join(", ")});`,
38246
- wrapGenerator(rows, new Map(columns.map((x2, i2) => [x2, parameters.length + i2])), moduleName),
38247
- parameters,
38248
- safeIntegers,
38249
- directOnly
38250
- ];
38251
- }
38252
- function wrapGenerator(generator, columnMap, moduleName) {
38253
- return function* virtualTable(...args) {
38254
- const output = args.map((x2) => Buffer.isBuffer(x2) ? Buffer.from(x2) : x2);
38255
- for (let i2 = 0;i2 < columnMap.size; ++i2) {
38256
- output.push(null);
38257
- }
38258
- for (const row of generator(...args)) {
38259
- if (Array.isArray(row)) {
38260
- extractRowArray(row, output, columnMap.size, moduleName);
38261
- yield output;
38262
- } else if (typeof row === "object" && row !== null) {
38263
- extractRowObject(row, output, columnMap, moduleName);
38264
- yield output;
38265
- } else {
38266
- throw new TypeError(`Virtual table module "${moduleName}" yielded something that isn't a valid row object`);
38785
+ function Ob(a, b) {
38786
+ if (Jb)
38787
+ return 0;
38788
+ if (!b.includes("r") || a.mode & 292) {
38789
+ if (b.includes("w") && !(a.mode & 146) || b.includes("x") && !(a.mode & 73))
38790
+ return 2;
38791
+ } else
38792
+ return 2;
38793
+ return 0;
38794
+ }
38795
+ function Qb(a, b) {
38796
+ if (!P(a.mode))
38797
+ return 54;
38798
+ try {
38799
+ return Q(a, b), 20;
38800
+ } catch (c) {}
38801
+ return Ob(a, "wx");
38802
+ }
38803
+ function Rb(a, b, c) {
38804
+ try {
38805
+ var d = Q(a, b);
38806
+ } catch (e2) {
38807
+ return e2.Pa;
38267
38808
  }
38809
+ if (a = Ob(a, "wx"))
38810
+ return a;
38811
+ if (c) {
38812
+ if (!P(d.mode))
38813
+ return 54;
38814
+ if (d === d.parent || ja(d) === "/")
38815
+ return 10;
38816
+ } else if (P(d.mode))
38817
+ return 31;
38818
+ return 0;
38268
38819
  }
38269
- };
38270
- }
38271
- function extractRowArray(row, output, columnCount, moduleName) {
38272
- if (row.length !== columnCount) {
38273
- throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an incorrect number of columns`);
38274
- }
38275
- const offset = output.length - columnCount;
38276
- for (let i2 = 0;i2 < columnCount; ++i2) {
38277
- output[i2 + offset] = row[i2];
38278
- }
38279
- }
38280
- function extractRowObject(row, output, columnMap, moduleName) {
38281
- let count = 0;
38282
- for (const key of Object.keys(row)) {
38283
- const index = columnMap.get(key);
38284
- if (index === undefined) {
38285
- throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an undeclared column "${key}"`);
38820
+ function Sb(a) {
38821
+ if (!a)
38822
+ throw new N(63);
38823
+ return a;
38824
+ }
38825
+ function T(a) {
38826
+ a = Gb[a];
38827
+ if (!a)
38828
+ throw new N(8);
38829
+ return a;
38830
+ }
38831
+ function Tb(a, b = -1) {
38832
+ a = Object.assign(new Lb, a);
38833
+ if (b == -1)
38834
+ a: {
38835
+ for (b = 0;4096 >= b; b++)
38836
+ if (!Gb[b])
38837
+ break a;
38838
+ throw new N(33);
38839
+ }
38840
+ a.fd = b;
38841
+ return Gb[b] = a;
38842
+ }
38843
+ function Ub(a, b = -1) {
38844
+ a = Tb(a, b);
38845
+ a.Ma?.Rb?.(a);
38846
+ return a;
38847
+ }
38848
+ function Vb(a, b, c) {
38849
+ var d = a?.Ma.Ua;
38850
+ a = d ? a : b;
38851
+ d ??= b.La.Ua;
38852
+ Sb(d);
38853
+ d(a, c);
38854
+ }
38855
+ var Ab = { open(a) {
38856
+ a.Ma = Fb[a.node.rdev].Ma;
38857
+ a.Ma.open?.(a);
38858
+ }, Va() {
38859
+ throw new N(70);
38860
+ } };
38861
+ function wb(a, b) {
38862
+ Fb[a] = { Ma: b };
38863
+ }
38864
+ function Wb(a, b) {
38865
+ var c = b === "/";
38866
+ if (c && Eb)
38867
+ throw new N(10);
38868
+ if (!c && b) {
38869
+ var d = S2(b, { nb: false });
38870
+ b = d.path;
38871
+ d = d.node;
38872
+ if (d.ab)
38873
+ throw new N(10);
38874
+ if (!P(d.mode))
38875
+ throw new N(54);
38876
+ }
38877
+ b = { type: a, Wb: {}, zb: b, Ib: [] };
38878
+ a = a.Xa(b);
38879
+ a.Xa = b;
38880
+ b.root = a;
38881
+ c ? Eb = a : d && (d.ab = b, d.Xa && d.Xa.Ib.push(b));
38882
+ }
38883
+ function Xb(a, b, c) {
38884
+ var d = S2(a, { parent: true }).node;
38885
+ a = gb(a);
38886
+ if (!a)
38887
+ throw new N(28);
38888
+ if (a === "." || a === "..")
38889
+ throw new N(20);
38890
+ var e2 = Qb(d, a);
38891
+ if (e2)
38892
+ throw new N(e2);
38893
+ if (!d.La.hb)
38894
+ throw new N(63);
38895
+ return d.La.hb(d, a, b, c);
38896
+ }
38897
+ function ma(a, b = 438) {
38898
+ return Xb(a, b & 4095 | 32768, 0);
38899
+ }
38900
+ function U(a, b = 511) {
38901
+ return Xb(a, b & 1023 | 16384, 0);
38902
+ }
38903
+ function Yb(a, b, c) {
38904
+ typeof c == "undefined" && (c = b, b = 438);
38905
+ Xb(a, b | 8192, c);
38906
+ }
38907
+ function Zb(a, b) {
38908
+ if (!jb(a))
38909
+ throw new N(44);
38910
+ var c = S2(b, { parent: true }).node;
38911
+ if (!c)
38912
+ throw new N(44);
38913
+ b = gb(b);
38914
+ var d = Qb(c, b);
38915
+ if (d)
38916
+ throw new N(d);
38917
+ if (!c.La.symlink)
38918
+ throw new N(63);
38919
+ c.La.symlink(c, b, a);
38920
+ }
38921
+ function $b(a) {
38922
+ var b = S2(a, { parent: true }).node;
38923
+ a = gb(a);
38924
+ var c = Q(b, a), d = Rb(b, a, true);
38925
+ if (d)
38926
+ throw new N(d);
38927
+ if (!b.La.rmdir)
38928
+ throw new N(63);
38929
+ if (c.ab)
38930
+ throw new N(10);
38931
+ b.La.rmdir(b, a);
38932
+ Cb(c);
38933
+ }
38934
+ function za(a) {
38935
+ var b = S2(a, { parent: true }).node;
38936
+ if (!b)
38937
+ throw new N(44);
38938
+ a = gb(a);
38939
+ var c = Q(b, a), d = Rb(b, a, false);
38940
+ if (d)
38941
+ throw new N(d);
38942
+ if (!b.La.unlink)
38943
+ throw new N(63);
38944
+ if (c.ab)
38945
+ throw new N(10);
38946
+ b.La.unlink(b, a);
38947
+ Cb(c);
38948
+ }
38949
+ function ac(a, b) {
38950
+ a = S2(a, { $a: !b }).node;
38951
+ return Sb(a.La.Ta)(a);
38952
+ }
38953
+ function bc(a, b, c, d) {
38954
+ Vb(a, b, { mode: c & 4095 | b.mode & -4096, ctime: Date.now(), Fb: d });
38955
+ }
38956
+ function na(a, b) {
38957
+ a = typeof a == "string" ? S2(a, { $a: true }).node : a;
38958
+ bc(null, a, b);
38959
+ }
38960
+ function cc(a, b, c) {
38961
+ if (P(b.mode))
38962
+ throw new N(31);
38963
+ if ((b.mode & 61440) !== 32768)
38964
+ throw new N(28);
38965
+ var d = Ob(b, "w");
38966
+ if (d)
38967
+ throw new N(d);
38968
+ Vb(a, b, { size: c, timestamp: Date.now() });
38969
+ }
38970
+ function oa(a, b, c = 438) {
38971
+ if (a === "")
38972
+ throw new N(44);
38973
+ if (typeof b == "string") {
38974
+ var d = { r: 0, "r+": 2, w: 577, "w+": 578, a: 1089, "a+": 1090 }[b];
38975
+ if (typeof d == "undefined")
38976
+ throw Error(`Unknown file open mode: ${b}`);
38977
+ b = d;
38978
+ }
38979
+ c = b & 64 ? c & 4095 | 32768 : 0;
38980
+ if (typeof a == "object")
38981
+ d = a;
38982
+ else {
38983
+ var e2 = a.endsWith("/");
38984
+ a = S2(a, { $a: !(b & 131072), Jb: true });
38985
+ d = a.node;
38986
+ a = a.path;
38987
+ }
38988
+ var h2 = false;
38989
+ if (b & 64)
38990
+ if (d) {
38991
+ if (b & 128)
38992
+ throw new N(20);
38993
+ } else {
38994
+ if (e2)
38995
+ throw new N(31);
38996
+ d = Xb(a, c | 511, 0);
38997
+ h2 = true;
38998
+ }
38999
+ if (!d)
39000
+ throw new N(44);
39001
+ (d.mode & 61440) === 8192 && (b &= -513);
39002
+ if (b & 65536 && !P(d.mode))
39003
+ throw new N(54);
39004
+ if (!h2 && (e2 = d ? (d.mode & 61440) === 40960 ? 32 : P(d.mode) && (Pb(b) !== "r" || b & 576) ? 31 : Ob(d, Pb(b)) : 44))
39005
+ throw new N(e2);
39006
+ b & 512 && !h2 && (e2 = d, e2 = typeof e2 == "string" ? S2(e2, { $a: true }).node : e2, cc(null, e2, 0));
39007
+ b &= -131713;
39008
+ e2 = Tb({ node: d, path: ja(d), flags: b, seekable: true, position: 0, Ma: d.Ma, Lb: [], error: false });
39009
+ e2.Ma.open && e2.Ma.open(e2);
39010
+ h2 && na(d, c & 511);
39011
+ !f3.logReadFiles || b & 1 || a in Kb || (Kb[a] = 1);
39012
+ return e2;
39013
+ }
39014
+ function qa(a) {
39015
+ if (a.fd === null)
39016
+ throw new N(8);
39017
+ a.ob && (a.ob = null);
39018
+ try {
39019
+ a.Ma.close && a.Ma.close(a);
39020
+ } catch (b) {
39021
+ throw b;
39022
+ } finally {
39023
+ Gb[a.fd] = null;
39024
+ }
39025
+ a.fd = null;
39026
+ }
39027
+ function mc(a, b, c) {
39028
+ if (a.fd === null)
39029
+ throw new N(8);
39030
+ if (!a.seekable || !a.Ma.Va)
39031
+ throw new N(70);
39032
+ if (c != 0 && c != 1 && c != 2)
39033
+ throw new N(28);
39034
+ a.position = a.Ma.Va(a, b, c);
39035
+ a.Lb = [];
39036
+ }
39037
+ function Ec(a, b, c, d, e2) {
39038
+ if (0 > d || 0 > e2)
39039
+ throw new N(28);
39040
+ if (a.fd === null)
39041
+ throw new N(8);
39042
+ if ((a.flags & 2097155) === 1)
39043
+ throw new N(8);
39044
+ if (P(a.node.mode))
39045
+ throw new N(31);
39046
+ if (!a.Ma.read)
39047
+ throw new N(28);
39048
+ var h2 = typeof e2 != "undefined";
39049
+ if (!h2)
39050
+ e2 = a.position;
39051
+ else if (!a.seekable)
39052
+ throw new N(70);
39053
+ b = a.Ma.read(a, b, c, d, e2);
39054
+ h2 || (a.position += b);
39055
+ return b;
38286
39056
  }
38287
- output[index] = row[key];
38288
- count += 1;
38289
- }
38290
- if (count !== columnMap.size) {
38291
- throw new TypeError(`Virtual table module "${moduleName}" yielded a row with missing columns`);
38292
- }
38293
- }
38294
- function inferParameters({ length }) {
38295
- if (!Number.isInteger(length) || length < 0) {
38296
- throw new TypeError("Expected function.length to be a positive integer");
38297
- }
38298
- const params = [];
38299
- for (let i2 = 0;i2 < length; ++i2) {
38300
- params.push(`$${i2 + 1}`);
38301
- }
38302
- return params;
38303
- }
38304
- var { hasOwnProperty: hasOwnProperty10 } = Object.prototype;
38305
- var { apply: apply2 } = Function.prototype;
38306
- var GeneratorFunctionPrototype = Object.getPrototypeOf(function* () {});
38307
- var identifier = (str) => `"${str.replace(/"/g, '""')}"`;
38308
- var defer = (x2) => () => x2;
38309
- });
38310
-
38311
- // ../../node_modules/better-sqlite3/lib/methods/inspect.js
38312
- var require_inspect = __commonJS((exports, module) => {
38313
- var DatabaseInspection = function Database() {};
38314
- module.exports = function inspect(depth, opts) {
38315
- return Object.assign(new DatabaseInspection, this);
38316
- };
38317
- });
38318
-
38319
- // ../../node_modules/better-sqlite3/lib/database.js
38320
- var require_database = __commonJS((exports, module) => {
38321
- var fs4 = __require("fs");
38322
- var path = __require("path");
38323
- var util2 = require_util3();
38324
- var SqliteError = require_sqlite_error();
38325
- var DEFAULT_ADDON;
38326
- function Database(filenameGiven, options) {
38327
- if (new.target == null) {
38328
- return new Database(filenameGiven, options);
38329
- }
38330
- let buffer;
38331
- if (Buffer.isBuffer(filenameGiven)) {
38332
- buffer = filenameGiven;
38333
- filenameGiven = ":memory:";
38334
- }
38335
- if (filenameGiven == null)
38336
- filenameGiven = "";
38337
- if (options == null)
38338
- options = {};
38339
- if (typeof filenameGiven !== "string")
38340
- throw new TypeError("Expected first argument to be a string");
38341
- if (typeof options !== "object")
38342
- throw new TypeError("Expected second argument to be an options object");
38343
- if ("readOnly" in options)
38344
- throw new TypeError('Misspelled option "readOnly" should be "readonly"');
38345
- if ("memory" in options)
38346
- throw new TypeError('Option "memory" was removed in v7.0.0 (use ":memory:" filename instead)');
38347
- const filename = filenameGiven.trim();
38348
- const anonymous = filename === "" || filename === ":memory:";
38349
- const readonly2 = util2.getBooleanOption(options, "readonly");
38350
- const fileMustExist = util2.getBooleanOption(options, "fileMustExist");
38351
- const timeout = "timeout" in options ? options.timeout : 5000;
38352
- const verbose = "verbose" in options ? options.verbose : null;
38353
- const nativeBinding = "nativeBinding" in options ? options.nativeBinding : null;
38354
- if (readonly2 && anonymous && !buffer)
38355
- throw new TypeError("In-memory/temporary databases cannot be readonly");
38356
- if (!Number.isInteger(timeout) || timeout < 0)
38357
- throw new TypeError('Expected the "timeout" option to be a positive integer');
38358
- if (timeout > 2147483647)
38359
- throw new RangeError('Option "timeout" cannot be greater than 2147483647');
38360
- if (verbose != null && typeof verbose !== "function")
38361
- throw new TypeError('Expected the "verbose" option to be a function');
38362
- if (nativeBinding != null && typeof nativeBinding !== "string" && typeof nativeBinding !== "object")
38363
- throw new TypeError('Expected the "nativeBinding" option to be a string or addon object');
38364
- let addon;
38365
- if (nativeBinding == null) {
38366
- addon = DEFAULT_ADDON || (DEFAULT_ADDON = require_bindings()("better_sqlite3.node"));
38367
- } else if (typeof nativeBinding === "string") {
38368
- const requireFunc = typeof __non_webpack_require__ === "function" ? __non_webpack_require__ : __require;
38369
- addon = requireFunc(path.resolve(nativeBinding).replace(/(\.node)?$/, ".node"));
38370
- } else {
38371
- addon = nativeBinding;
38372
- }
38373
- if (!addon.isInitialized) {
38374
- addon.setErrorConstructor(SqliteError);
38375
- addon.isInitialized = true;
38376
- }
38377
- if (!anonymous && !filename.startsWith("file:") && !fs4.existsSync(path.dirname(filename))) {
38378
- throw new TypeError("Cannot open database because the directory does not exist");
38379
- }
38380
- Object.defineProperties(this, {
38381
- [util2.cppdb]: { value: new addon.Database(filename, filenameGiven, anonymous, readonly2, fileMustExist, timeout, verbose || null, buffer || null) },
38382
- ...wrappers.getters
39057
+ function pa(a, b, c, d, e2) {
39058
+ if (0 > d || 0 > e2)
39059
+ throw new N(28);
39060
+ if (a.fd === null)
39061
+ throw new N(8);
39062
+ if ((a.flags & 2097155) === 0)
39063
+ throw new N(8);
39064
+ if (P(a.node.mode))
39065
+ throw new N(31);
39066
+ if (!a.Ma.write)
39067
+ throw new N(28);
39068
+ a.seekable && a.flags & 1024 && mc(a, 0, 2);
39069
+ var h2 = typeof e2 != "undefined";
39070
+ if (!h2)
39071
+ e2 = a.position;
39072
+ else if (!a.seekable)
39073
+ throw new N(70);
39074
+ b = a.Ma.write(a, b, c, d, e2, undefined);
39075
+ h2 || (a.position += b);
39076
+ return b;
39077
+ }
39078
+ function ya(a) {
39079
+ var b = "binary";
39080
+ if (b !== "utf8" && b !== "binary")
39081
+ throw Error(`Invalid encoding type "${b}"`);
39082
+ var c;
39083
+ var d = oa(a, d || 0);
39084
+ a = ac(a).size;
39085
+ var e2 = new Uint8Array(a);
39086
+ Ec(d, e2, 0, a, 0);
39087
+ b === "utf8" ? c = B(e2) : b === "binary" && (c = e2);
39088
+ qa(d);
39089
+ return c;
39090
+ }
39091
+ function V(a, b, c) {
39092
+ a = ka("/dev/" + a);
39093
+ var d = la(!!b, !!c);
39094
+ V.yb ?? (V.yb = 64);
39095
+ var e2 = V.yb++ << 8 | 0;
39096
+ wb(e2, { open(h2) {
39097
+ h2.seekable = false;
39098
+ }, close() {
39099
+ c?.buffer?.length && c(10);
39100
+ }, read(h2, k, q, w) {
39101
+ for (var v = 0, C = 0;C < w; C++) {
39102
+ try {
39103
+ var G = b();
39104
+ } catch (pb) {
39105
+ throw new N(29);
39106
+ }
39107
+ if (G === undefined && v === 0)
39108
+ throw new N(6);
39109
+ if (G === null || G === undefined)
39110
+ break;
39111
+ v++;
39112
+ k[q + C] = G;
39113
+ }
39114
+ v && (h2.node.atime = Date.now());
39115
+ return v;
39116
+ }, write(h2, k, q, w) {
39117
+ for (var v = 0;v < w; v++)
39118
+ try {
39119
+ c(k[q + v]);
39120
+ } catch (C) {
39121
+ throw new N(29);
39122
+ }
39123
+ w && (h2.node.mtime = h2.node.ctime = Date.now());
39124
+ return v;
39125
+ } });
39126
+ Yb(a, d, e2);
39127
+ }
39128
+ var W = {};
39129
+ function Gc(a, b, c) {
39130
+ if (b.charAt(0) === "/")
39131
+ return b;
39132
+ a = a === -100 ? "/" : T(a).path;
39133
+ if (b.length == 0) {
39134
+ if (!c)
39135
+ throw new N(44);
39136
+ return a;
39137
+ }
39138
+ return a + "/" + b;
39139
+ }
39140
+ function Hc(a, b) {
39141
+ E[a >> 2] = b.dev;
39142
+ E[a + 4 >> 2] = b.mode;
39143
+ F2[a + 8 >> 2] = b.nlink;
39144
+ E[a + 12 >> 2] = b.uid;
39145
+ E[a + 16 >> 2] = b.gid;
39146
+ E[a + 20 >> 2] = b.rdev;
39147
+ H[a + 24 >> 3] = BigInt(b.size);
39148
+ E[a + 32 >> 2] = 4096;
39149
+ E[a + 36 >> 2] = b.blocks;
39150
+ var c = b.atime.getTime(), d = b.mtime.getTime(), e2 = b.ctime.getTime();
39151
+ H[a + 40 >> 3] = BigInt(Math.floor(c / 1000));
39152
+ F2[a + 48 >> 2] = c % 1000 * 1e6;
39153
+ H[a + 56 >> 3] = BigInt(Math.floor(d / 1000));
39154
+ F2[a + 64 >> 2] = d % 1000 * 1e6;
39155
+ H[a + 72 >> 3] = BigInt(Math.floor(e2 / 1000));
39156
+ F2[a + 80 >> 2] = e2 % 1000 * 1e6;
39157
+ H[a + 88 >> 3] = BigInt(b.ino);
39158
+ return 0;
39159
+ }
39160
+ var Ic = undefined, Jc = () => {
39161
+ var a = E[+Ic >> 2];
39162
+ Ic += 4;
39163
+ return a;
39164
+ }, Kc = 0, Lc = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335], Mc = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334], Nc = {}, Oc = (a) => {
39165
+ Ma = a;
39166
+ cb || 0 < Kc || (f3.onExit?.(a), La = true);
39167
+ Da(a, new Ya(a));
39168
+ }, Pc = (a) => {
39169
+ if (!La)
39170
+ try {
39171
+ if (a(), !(cb || 0 < Kc))
39172
+ try {
39173
+ Ma = a = Ma, Oc(a);
39174
+ } catch (b) {
39175
+ b instanceof Ya || b == "unwind" || Da(1, b);
39176
+ }
39177
+ } catch (b) {
39178
+ b instanceof Ya || b == "unwind" || Da(1, b);
39179
+ }
39180
+ }, Qc = {}, Sc = () => {
39181
+ if (!Rc) {
39182
+ var a = { USER: "web_user", LOGNAME: "web_user", PATH: "/", PWD: "/", HOME: "/home/web_user", LANG: (typeof navigator == "object" && navigator.languages && navigator.languages[0] || "C").replace("-", "_") + ".UTF-8", _: Ca || "./this.program" }, b;
39183
+ for (b in Qc)
39184
+ Qc[b] === undefined ? delete a[b] : a[b] = Qc[b];
39185
+ var c = [];
39186
+ for (b in a)
39187
+ c.push(`${b}=${a[b]}`);
39188
+ Rc = c;
39189
+ }
39190
+ return Rc;
39191
+ }, Rc, xa = (a) => {
39192
+ var b = ha(a) + 1, c = z2(b);
39193
+ u(a, x2, c, b);
39194
+ return c;
39195
+ }, Tc = (a, b, c, d) => {
39196
+ var e2 = { string: (v) => {
39197
+ var C = 0;
39198
+ v !== null && v !== undefined && v !== 0 && (C = xa(v));
39199
+ return C;
39200
+ }, array: (v) => {
39201
+ var C = z2(v.length);
39202
+ p.set(v, C);
39203
+ return C;
39204
+ } };
39205
+ a = f3["_" + a];
39206
+ var h2 = [], k = 0;
39207
+ if (d)
39208
+ for (var q = 0;q < d.length; q++) {
39209
+ var w = e2[c[q]];
39210
+ w ? (k === 0 && (k = sa()), h2[q] = w(d[q])) : h2[q] = d[q];
39211
+ }
39212
+ c = a(...h2);
39213
+ return c = function(v) {
39214
+ k !== 0 && wa(k);
39215
+ return b === "string" ? v ? B(x2, v) : "" : b === "boolean" ? !!v : v;
39216
+ }(c);
39217
+ }, ea = 0, da = (a, b) => {
39218
+ b = b == 1 ? z2(a.length) : ia(a.length);
39219
+ a.subarray || a.slice || (a = new Uint8Array(a));
39220
+ x2.set(a, b);
39221
+ return b;
39222
+ }, Uc, Vc = [], Y, A2 = (a) => {
39223
+ Uc.delete(Y.get(a));
39224
+ Y.set(a, null);
39225
+ Vc.push(a);
39226
+ }, Aa = (a, b) => {
39227
+ if (!Uc) {
39228
+ Uc = new WeakMap;
39229
+ var c = Y.length;
39230
+ if (Uc)
39231
+ for (var d = 0;d < 0 + c; d++) {
39232
+ var e2 = Y.get(d);
39233
+ e2 && Uc.set(e2, d);
39234
+ }
39235
+ }
39236
+ if (c = Uc.get(a) || 0)
39237
+ return c;
39238
+ if (Vc.length)
39239
+ c = Vc.pop();
39240
+ else {
39241
+ try {
39242
+ Y.grow(1);
39243
+ } catch (w) {
39244
+ if (!(w instanceof RangeError))
39245
+ throw w;
39246
+ throw "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";
39247
+ }
39248
+ c = Y.length - 1;
39249
+ }
39250
+ try {
39251
+ Y.set(c, a);
39252
+ } catch (w) {
39253
+ if (!(w instanceof TypeError))
39254
+ throw w;
39255
+ if (typeof WebAssembly.Function == "function") {
39256
+ var h2 = WebAssembly.Function;
39257
+ d = { i: "i32", j: "i64", f: "f32", d: "f64", e: "externref", p: "i32" };
39258
+ e2 = { parameters: [], results: b[0] == "v" ? [] : [d[b[0]]] };
39259
+ for (var k = 1;k < b.length; ++k)
39260
+ e2.parameters.push(d[b[k]]);
39261
+ b = new h2(e2, a);
39262
+ } else {
39263
+ d = [1];
39264
+ e2 = b.slice(0, 1);
39265
+ b = b.slice(1);
39266
+ k = { i: 127, p: 127, j: 126, f: 125, d: 124, e: 111 };
39267
+ d.push(96);
39268
+ var q = b.length;
39269
+ 128 > q ? d.push(q) : d.push(q % 128 | 128, q >> 7);
39270
+ for (h2 of b)
39271
+ d.push(k[h2]);
39272
+ e2 == "v" ? d.push(0) : d.push(1, k[e2]);
39273
+ b = [0, 97, 115, 109, 1, 0, 0, 0, 1];
39274
+ h2 = d.length;
39275
+ 128 > h2 ? b.push(h2) : b.push(h2 % 128 | 128, h2 >> 7);
39276
+ b.push(...d);
39277
+ b.push(2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0);
39278
+ b = new WebAssembly.Module(new Uint8Array(b));
39279
+ b = new WebAssembly.Instance(b, { e: { f: a } }).exports.f;
39280
+ }
39281
+ Y.set(c, b);
39282
+ }
39283
+ Uc.set(a, c);
39284
+ return c;
39285
+ };
39286
+ R = Array(4096);
39287
+ Wb(O, "/");
39288
+ U("/tmp");
39289
+ U("/home");
39290
+ U("/home/web_user");
39291
+ (function() {
39292
+ U("/dev");
39293
+ wb(259, { read: () => 0, write: (d, e2, h2, k) => k, Va: () => 0 });
39294
+ Yb("/dev/null", 259);
39295
+ nb(1280, yb);
39296
+ nb(1536, zb);
39297
+ Yb("/dev/tty", 1280);
39298
+ Yb("/dev/tty1", 1536);
39299
+ var a = new Uint8Array(1024), b = 0, c = () => {
39300
+ b === 0 && (ib(a), b = a.byteLength);
39301
+ return a[--b];
39302
+ };
39303
+ V("random", c);
39304
+ V("urandom", c);
39305
+ U("/dev/shm");
39306
+ U("/dev/shm/tmp");
39307
+ })();
39308
+ (function() {
39309
+ U("/proc");
39310
+ var a = U("/proc/self");
39311
+ U("/proc/self/fd");
39312
+ Wb({ Xa() {
39313
+ var b = Bb(a, "fd", 16895, 73);
39314
+ b.Ma = { Va: O.Ma.Va };
39315
+ b.La = { lookup(c, d) {
39316
+ c = +d;
39317
+ var e2 = T(c);
39318
+ c = { parent: null, Xa: { zb: "fake" }, La: { readlink: () => e2.path }, id: c + 1 };
39319
+ return c.parent = c;
39320
+ }, readdir() {
39321
+ return Array.from(Gb.entries()).filter(([, c]) => c).map(([c]) => c.toString());
39322
+ } };
39323
+ return b;
39324
+ } }, "/proc/self/fd");
39325
+ })();
39326
+ O.vb = new N(44);
39327
+ O.vb.stack = "<generic error, no stack>";
39328
+ var Xc = { a: (a, b, c, d) => Ta(`Assertion failed: ${a ? B(x2, a) : ""}, at: ` + [b ? b ? B(x2, b) : "" : "unknown filename", c, d ? d ? B(x2, d) : "" : "unknown function"]), i: function(a, b) {
39329
+ try {
39330
+ return a = a ? B(x2, a) : "", na(a, b), 0;
39331
+ } catch (c) {
39332
+ if (typeof W == "undefined" || c.name !== "ErrnoError")
39333
+ throw c;
39334
+ return -c.Pa;
39335
+ }
39336
+ }, L: function(a, b, c) {
39337
+ try {
39338
+ b = b ? B(x2, b) : "";
39339
+ b = Gc(a, b);
39340
+ if (c & -8)
39341
+ return -28;
39342
+ var d = S2(b, { $a: true }).node;
39343
+ if (!d)
39344
+ return -44;
39345
+ a = "";
39346
+ c & 4 && (a += "r");
39347
+ c & 2 && (a += "w");
39348
+ c & 1 && (a += "x");
39349
+ return a && Ob(d, a) ? -2 : 0;
39350
+ } catch (e2) {
39351
+ if (typeof W == "undefined" || e2.name !== "ErrnoError")
39352
+ throw e2;
39353
+ return -e2.Pa;
39354
+ }
39355
+ }, j: function(a, b) {
39356
+ try {
39357
+ var c = T(a);
39358
+ bc(c, c.node, b, false);
39359
+ return 0;
39360
+ } catch (d) {
39361
+ if (typeof W == "undefined" || d.name !== "ErrnoError")
39362
+ throw d;
39363
+ return -d.Pa;
39364
+ }
39365
+ }, h: function(a) {
39366
+ try {
39367
+ var b = T(a);
39368
+ Vb(b, b.node, { timestamp: Date.now(), Fb: false });
39369
+ return 0;
39370
+ } catch (c) {
39371
+ if (typeof W == "undefined" || c.name !== "ErrnoError")
39372
+ throw c;
39373
+ return -c.Pa;
39374
+ }
39375
+ }, b: function(a, b, c) {
39376
+ Ic = c;
39377
+ try {
39378
+ var d = T(a);
39379
+ switch (b) {
39380
+ case 0:
39381
+ var e2 = Jc();
39382
+ if (0 > e2)
39383
+ break;
39384
+ for (;Gb[e2]; )
39385
+ e2++;
39386
+ return Ub(d, e2).fd;
39387
+ case 1:
39388
+ case 2:
39389
+ return 0;
39390
+ case 3:
39391
+ return d.flags;
39392
+ case 4:
39393
+ return e2 = Jc(), d.flags |= e2, 0;
39394
+ case 12:
39395
+ return e2 = Jc(), Na[e2 + 0 >> 1] = 2, 0;
39396
+ case 13:
39397
+ case 14:
39398
+ return 0;
39399
+ }
39400
+ return -28;
39401
+ } catch (h2) {
39402
+ if (typeof W == "undefined" || h2.name !== "ErrnoError")
39403
+ throw h2;
39404
+ return -h2.Pa;
39405
+ }
39406
+ }, g: function(a, b) {
39407
+ try {
39408
+ var c = T(a), d = c.node, e2 = c.Ma.Ta;
39409
+ a = e2 ? c : d;
39410
+ e2 ??= d.La.Ta;
39411
+ Sb(e2);
39412
+ var h2 = e2(a);
39413
+ return Hc(b, h2);
39414
+ } catch (k) {
39415
+ if (typeof W == "undefined" || k.name !== "ErrnoError")
39416
+ throw k;
39417
+ return -k.Pa;
39418
+ }
39419
+ }, H: function(a, b) {
39420
+ b = -9007199254740992 > b || 9007199254740992 < b ? NaN : Number(b);
39421
+ try {
39422
+ if (isNaN(b))
39423
+ return 61;
39424
+ var c = T(a);
39425
+ if (0 > b || (c.flags & 2097155) === 0)
39426
+ throw new N(28);
39427
+ cc(c, c.node, b);
39428
+ return 0;
39429
+ } catch (d) {
39430
+ if (typeof W == "undefined" || d.name !== "ErrnoError")
39431
+ throw d;
39432
+ return -d.Pa;
39433
+ }
39434
+ }, G: function(a, b) {
39435
+ try {
39436
+ if (b === 0)
39437
+ return -28;
39438
+ var c = ha("/") + 1;
39439
+ if (b < c)
39440
+ return -68;
39441
+ u("/", x2, a, b);
39442
+ return c;
39443
+ } catch (d) {
39444
+ if (typeof W == "undefined" || d.name !== "ErrnoError")
39445
+ throw d;
39446
+ return -d.Pa;
39447
+ }
39448
+ }, K: function(a, b) {
39449
+ try {
39450
+ return a = a ? B(x2, a) : "", Hc(b, ac(a, true));
39451
+ } catch (c) {
39452
+ if (typeof W == "undefined" || c.name !== "ErrnoError")
39453
+ throw c;
39454
+ return -c.Pa;
39455
+ }
39456
+ }, C: function(a, b, c) {
39457
+ try {
39458
+ return b = b ? B(x2, b) : "", b = Gc(a, b), U(b, c), 0;
39459
+ } catch (d) {
39460
+ if (typeof W == "undefined" || d.name !== "ErrnoError")
39461
+ throw d;
39462
+ return -d.Pa;
39463
+ }
39464
+ }, J: function(a, b, c, d) {
39465
+ try {
39466
+ b = b ? B(x2, b) : "";
39467
+ var e2 = d & 256;
39468
+ b = Gc(a, b, d & 4096);
39469
+ return Hc(c, e2 ? ac(b, true) : ac(b));
39470
+ } catch (h2) {
39471
+ if (typeof W == "undefined" || h2.name !== "ErrnoError")
39472
+ throw h2;
39473
+ return -h2.Pa;
39474
+ }
39475
+ }, x: function(a, b, c, d) {
39476
+ Ic = d;
39477
+ try {
39478
+ b = b ? B(x2, b) : "";
39479
+ b = Gc(a, b);
39480
+ var e2 = d ? Jc() : 0;
39481
+ return oa(b, c, e2).fd;
39482
+ } catch (h2) {
39483
+ if (typeof W == "undefined" || h2.name !== "ErrnoError")
39484
+ throw h2;
39485
+ return -h2.Pa;
39486
+ }
39487
+ }, v: function(a, b, c, d) {
39488
+ try {
39489
+ b = b ? B(x2, b) : "";
39490
+ b = Gc(a, b);
39491
+ if (0 >= d)
39492
+ return -28;
39493
+ var e2 = S2(b).node;
39494
+ if (!e2)
39495
+ throw new N(44);
39496
+ if (!e2.La.readlink)
39497
+ throw new N(28);
39498
+ var h2 = e2.La.readlink(e2);
39499
+ var k = Math.min(d, ha(h2)), q = p[c + k];
39500
+ u(h2, x2, c, d + 1);
39501
+ p[c + k] = q;
39502
+ return k;
39503
+ } catch (w) {
39504
+ if (typeof W == "undefined" || w.name !== "ErrnoError")
39505
+ throw w;
39506
+ return -w.Pa;
39507
+ }
39508
+ }, u: function(a) {
39509
+ try {
39510
+ return a = a ? B(x2, a) : "", $b(a), 0;
39511
+ } catch (b) {
39512
+ if (typeof W == "undefined" || b.name !== "ErrnoError")
39513
+ throw b;
39514
+ return -b.Pa;
39515
+ }
39516
+ }, f: function(a, b) {
39517
+ try {
39518
+ return a = a ? B(x2, a) : "", Hc(b, ac(a));
39519
+ } catch (c) {
39520
+ if (typeof W == "undefined" || c.name !== "ErrnoError")
39521
+ throw c;
39522
+ return -c.Pa;
39523
+ }
39524
+ }, r: function(a, b, c) {
39525
+ try {
39526
+ return b = b ? B(x2, b) : "", b = Gc(a, b), c === 0 ? za(b) : c === 512 ? $b(b) : Ta("Invalid flags passed to unlinkat"), 0;
39527
+ } catch (d) {
39528
+ if (typeof W == "undefined" || d.name !== "ErrnoError")
39529
+ throw d;
39530
+ return -d.Pa;
39531
+ }
39532
+ }, q: function(a, b, c) {
39533
+ try {
39534
+ b = b ? B(x2, b) : "";
39535
+ b = Gc(a, b, true);
39536
+ var d = Date.now(), e2, h2;
39537
+ if (c) {
39538
+ var k = F2[c >> 2] + 4294967296 * E[c + 4 >> 2], q = E[c + 8 >> 2];
39539
+ q == 1073741823 ? e2 = d : q == 1073741822 ? e2 = null : e2 = 1000 * k + q / 1e6;
39540
+ c += 16;
39541
+ k = F2[c >> 2] + 4294967296 * E[c + 4 >> 2];
39542
+ q = E[c + 8 >> 2];
39543
+ q == 1073741823 ? h2 = d : q == 1073741822 ? h2 = null : h2 = 1000 * k + q / 1e6;
39544
+ } else
39545
+ h2 = e2 = d;
39546
+ if ((h2 ?? e2) !== null) {
39547
+ a = e2;
39548
+ var w = S2(b, { $a: true }).node;
39549
+ Sb(w.La.Ua)(w, { atime: a, mtime: h2 });
39550
+ }
39551
+ return 0;
39552
+ } catch (v) {
39553
+ if (typeof W == "undefined" || v.name !== "ErrnoError")
39554
+ throw v;
39555
+ return -v.Pa;
39556
+ }
39557
+ }, m: () => Ta(""), l: () => {
39558
+ cb = false;
39559
+ Kc = 0;
39560
+ }, A: function(a, b) {
39561
+ a = -9007199254740992 > a || 9007199254740992 < a ? NaN : Number(a);
39562
+ a = new Date(1000 * a);
39563
+ E[b >> 2] = a.getSeconds();
39564
+ E[b + 4 >> 2] = a.getMinutes();
39565
+ E[b + 8 >> 2] = a.getHours();
39566
+ E[b + 12 >> 2] = a.getDate();
39567
+ E[b + 16 >> 2] = a.getMonth();
39568
+ E[b + 20 >> 2] = a.getFullYear() - 1900;
39569
+ E[b + 24 >> 2] = a.getDay();
39570
+ var c = a.getFullYear();
39571
+ E[b + 28 >> 2] = (c % 4 !== 0 || c % 100 === 0 && c % 400 !== 0 ? Mc : Lc)[a.getMonth()] + a.getDate() - 1 | 0;
39572
+ E[b + 36 >> 2] = -(60 * a.getTimezoneOffset());
39573
+ c = new Date(a.getFullYear(), 6, 1).getTimezoneOffset();
39574
+ var d = new Date(a.getFullYear(), 0, 1).getTimezoneOffset();
39575
+ E[b + 32 >> 2] = (c != d && a.getTimezoneOffset() == Math.min(d, c)) | 0;
39576
+ }, y: function(a, b, c, d, e2, h2, k) {
39577
+ e2 = -9007199254740992 > e2 || 9007199254740992 < e2 ? NaN : Number(e2);
39578
+ try {
39579
+ if (isNaN(e2))
39580
+ return 61;
39581
+ var q = T(d);
39582
+ if ((b & 2) !== 0 && (c & 2) === 0 && (q.flags & 2097155) !== 2)
39583
+ throw new N(2);
39584
+ if ((q.flags & 2097155) === 1)
39585
+ throw new N(2);
39586
+ if (!q.Ma.ib)
39587
+ throw new N(43);
39588
+ if (!a)
39589
+ throw new N(28);
39590
+ var w = q.Ma.ib(q, a, e2, b, c);
39591
+ var v = w.Kb;
39592
+ E[h2 >> 2] = w.Ab;
39593
+ F2[k >> 2] = v;
39594
+ return 0;
39595
+ } catch (C) {
39596
+ if (typeof W == "undefined" || C.name !== "ErrnoError")
39597
+ throw C;
39598
+ return -C.Pa;
39599
+ }
39600
+ }, z: function(a, b, c, d, e2, h2) {
39601
+ h2 = -9007199254740992 > h2 || 9007199254740992 < h2 ? NaN : Number(h2);
39602
+ try {
39603
+ var k = T(e2);
39604
+ if (c & 2) {
39605
+ c = h2;
39606
+ if ((k.node.mode & 61440) !== 32768)
39607
+ throw new N(43);
39608
+ if (!(d & 2)) {
39609
+ var q = x2.slice(a, a + b);
39610
+ k.Ma.jb && k.Ma.jb(k, q, c, b, d);
39611
+ }
39612
+ }
39613
+ } catch (w) {
39614
+ if (typeof W == "undefined" || w.name !== "ErrnoError")
39615
+ throw w;
39616
+ return -w.Pa;
39617
+ }
39618
+ }, n: (a, b) => {
39619
+ Nc[a] && (clearTimeout(Nc[a].id), delete Nc[a]);
39620
+ if (!b)
39621
+ return 0;
39622
+ var c = setTimeout(() => {
39623
+ delete Nc[a];
39624
+ Pc(() => Wc(a, performance.now()));
39625
+ }, b);
39626
+ Nc[a] = {
39627
+ id: c,
39628
+ Xb: b
39629
+ };
39630
+ return 0;
39631
+ }, B: (a, b, c, d) => {
39632
+ var e2 = new Date().getFullYear(), h2 = new Date(e2, 0, 1).getTimezoneOffset();
39633
+ e2 = new Date(e2, 6, 1).getTimezoneOffset();
39634
+ F2[a >> 2] = 60 * Math.max(h2, e2);
39635
+ E[b >> 2] = Number(h2 != e2);
39636
+ b = (k) => {
39637
+ var q = Math.abs(k);
39638
+ return `UTC${0 <= k ? "-" : "+"}${String(Math.floor(q / 60)).padStart(2, "0")}${String(q % 60).padStart(2, "0")}`;
39639
+ };
39640
+ a = b(h2);
39641
+ b = b(e2);
39642
+ e2 < h2 ? (u(a, x2, c, 17), u(b, x2, d, 17)) : (u(a, x2, d, 17), u(b, x2, c, 17));
39643
+ }, d: () => Date.now(), s: () => 2147483648, c: () => performance.now(), o: (a) => {
39644
+ var b = x2.length;
39645
+ a >>>= 0;
39646
+ if (2147483648 < a)
39647
+ return false;
39648
+ for (var c = 1;4 >= c; c *= 2) {
39649
+ var d = b * (1 + 0.2 / c);
39650
+ d = Math.min(d, a + 100663296);
39651
+ a: {
39652
+ d = (Math.min(2147483648, 65536 * Math.ceil(Math.max(a, d) / 65536)) - Ka.buffer.byteLength + 65535) / 65536 | 0;
39653
+ try {
39654
+ Ka.grow(d);
39655
+ Qa();
39656
+ var e2 = 1;
39657
+ break a;
39658
+ } catch (h2) {}
39659
+ e2 = undefined;
39660
+ }
39661
+ if (e2)
39662
+ return true;
39663
+ }
39664
+ return false;
39665
+ }, E: (a, b) => {
39666
+ var c = 0;
39667
+ Sc().forEach((d, e2) => {
39668
+ var h2 = b + c;
39669
+ e2 = F2[a + 4 * e2 >> 2] = h2;
39670
+ for (h2 = 0;h2 < d.length; ++h2)
39671
+ p[e2++] = d.charCodeAt(h2);
39672
+ p[e2] = 0;
39673
+ c += d.length + 1;
39674
+ });
39675
+ return 0;
39676
+ }, F: (a, b) => {
39677
+ var c = Sc();
39678
+ F2[a >> 2] = c.length;
39679
+ var d = 0;
39680
+ c.forEach((e2) => d += e2.length + 1);
39681
+ F2[b >> 2] = d;
39682
+ return 0;
39683
+ }, e: function(a) {
39684
+ try {
39685
+ var b = T(a);
39686
+ qa(b);
39687
+ return 0;
39688
+ } catch (c) {
39689
+ if (typeof W == "undefined" || c.name !== "ErrnoError")
39690
+ throw c;
39691
+ return c.Pa;
39692
+ }
39693
+ }, p: function(a, b) {
39694
+ try {
39695
+ var c = T(a);
39696
+ p[b] = c.tty ? 2 : P(c.mode) ? 3 : (c.mode & 61440) === 40960 ? 7 : 4;
39697
+ Na[b + 2 >> 1] = 0;
39698
+ H[b + 8 >> 3] = BigInt(0);
39699
+ H[b + 16 >> 3] = BigInt(0);
39700
+ return 0;
39701
+ } catch (d) {
39702
+ if (typeof W == "undefined" || d.name !== "ErrnoError")
39703
+ throw d;
39704
+ return d.Pa;
39705
+ }
39706
+ }, w: function(a, b, c, d) {
39707
+ try {
39708
+ a: {
39709
+ var e2 = T(a);
39710
+ a = b;
39711
+ for (var h2, k = b = 0;k < c; k++) {
39712
+ var q = F2[a >> 2], w = F2[a + 4 >> 2];
39713
+ a += 8;
39714
+ var v = Ec(e2, p, q, w, h2);
39715
+ if (0 > v) {
39716
+ var C = -1;
39717
+ break a;
39718
+ }
39719
+ b += v;
39720
+ if (v < w)
39721
+ break;
39722
+ typeof h2 != "undefined" && (h2 += v);
39723
+ }
39724
+ C = b;
39725
+ }
39726
+ F2[d >> 2] = C;
39727
+ return 0;
39728
+ } catch (G) {
39729
+ if (typeof W == "undefined" || G.name !== "ErrnoError")
39730
+ throw G;
39731
+ return G.Pa;
39732
+ }
39733
+ }, D: function(a, b, c, d) {
39734
+ b = -9007199254740992 > b || 9007199254740992 < b ? NaN : Number(b);
39735
+ try {
39736
+ if (isNaN(b))
39737
+ return 61;
39738
+ var e2 = T(a);
39739
+ mc(e2, b, c);
39740
+ H[d >> 3] = BigInt(e2.position);
39741
+ e2.ob && b === 0 && c === 0 && (e2.ob = null);
39742
+ return 0;
39743
+ } catch (h2) {
39744
+ if (typeof W == "undefined" || h2.name !== "ErrnoError")
39745
+ throw h2;
39746
+ return h2.Pa;
39747
+ }
39748
+ }, I: function(a) {
39749
+ try {
39750
+ var b = T(a);
39751
+ return b.Ma?.fsync ? b.Ma.fsync(b) : 0;
39752
+ } catch (c) {
39753
+ if (typeof W == "undefined" || c.name !== "ErrnoError")
39754
+ throw c;
39755
+ return c.Pa;
39756
+ }
39757
+ }, t: function(a, b, c, d) {
39758
+ try {
39759
+ a: {
39760
+ var e2 = T(a);
39761
+ a = b;
39762
+ for (var h2, k = b = 0;k < c; k++) {
39763
+ var q = F2[a >> 2], w = F2[a + 4 >> 2];
39764
+ a += 8;
39765
+ var v = pa(e2, p, q, w, h2);
39766
+ if (0 > v) {
39767
+ var C = -1;
39768
+ break a;
39769
+ }
39770
+ b += v;
39771
+ if (v < w)
39772
+ break;
39773
+ typeof h2 != "undefined" && (h2 += v);
39774
+ }
39775
+ C = b;
39776
+ }
39777
+ F2[d >> 2] = C;
39778
+ return 0;
39779
+ } catch (G) {
39780
+ if (typeof W == "undefined" || G.name !== "ErrnoError")
39781
+ throw G;
39782
+ return G.Pa;
39783
+ }
39784
+ }, k: Oc }, Z2;
39785
+ (async function() {
39786
+ function a(c) {
39787
+ Z2 = c.exports;
39788
+ Ka = Z2.M;
39789
+ Qa();
39790
+ Y = Z2.O;
39791
+ K--;
39792
+ f3.monitorRunDependencies?.(K);
39793
+ K == 0 && Sa && (c = Sa, Sa = null, c());
39794
+ return Z2;
39795
+ }
39796
+ K++;
39797
+ f3.monitorRunDependencies?.(K);
39798
+ var b = { a: Xc };
39799
+ if (f3.instantiateWasm)
39800
+ return new Promise((c) => {
39801
+ f3.instantiateWasm(b, (d, e2) => {
39802
+ a(d, e2);
39803
+ c(d.exports);
39804
+ });
39805
+ });
39806
+ Ua ??= f3.locateFile ? f3.locateFile("sql-wasm.wasm", D) : D + "sql-wasm.wasm";
39807
+ return a((await Xa(b)).instance);
39808
+ })();
39809
+ f3._sqlite3_free = (a) => (f3._sqlite3_free = Z2.P)(a);
39810
+ f3._sqlite3_value_text = (a) => (f3._sqlite3_value_text = Z2.Q)(a);
39811
+ f3._sqlite3_prepare_v2 = (a, b, c, d, e2) => (f3._sqlite3_prepare_v2 = Z2.R)(a, b, c, d, e2);
39812
+ f3._sqlite3_step = (a) => (f3._sqlite3_step = Z2.S)(a);
39813
+ f3._sqlite3_reset = (a) => (f3._sqlite3_reset = Z2.T)(a);
39814
+ f3._sqlite3_exec = (a, b, c, d, e2) => (f3._sqlite3_exec = Z2.U)(a, b, c, d, e2);
39815
+ f3._sqlite3_finalize = (a) => (f3._sqlite3_finalize = Z2.V)(a);
39816
+ f3._sqlite3_column_name = (a, b) => (f3._sqlite3_column_name = Z2.W)(a, b);
39817
+ f3._sqlite3_column_text = (a, b) => (f3._sqlite3_column_text = Z2.X)(a, b);
39818
+ f3._sqlite3_column_type = (a, b) => (f3._sqlite3_column_type = Z2.Y)(a, b);
39819
+ f3._sqlite3_errmsg = (a) => (f3._sqlite3_errmsg = Z2.Z)(a);
39820
+ f3._sqlite3_clear_bindings = (a) => (f3._sqlite3_clear_bindings = Z2._)(a);
39821
+ f3._sqlite3_value_blob = (a) => (f3._sqlite3_value_blob = Z2.$)(a);
39822
+ f3._sqlite3_value_bytes = (a) => (f3._sqlite3_value_bytes = Z2.aa)(a);
39823
+ f3._sqlite3_value_double = (a) => (f3._sqlite3_value_double = Z2.ba)(a);
39824
+ f3._sqlite3_value_int = (a) => (f3._sqlite3_value_int = Z2.ca)(a);
39825
+ f3._sqlite3_value_type = (a) => (f3._sqlite3_value_type = Z2.da)(a);
39826
+ f3._sqlite3_result_blob = (a, b, c, d) => (f3._sqlite3_result_blob = Z2.ea)(a, b, c, d);
39827
+ f3._sqlite3_result_double = (a, b) => (f3._sqlite3_result_double = Z2.fa)(a, b);
39828
+ f3._sqlite3_result_error = (a, b, c) => (f3._sqlite3_result_error = Z2.ga)(a, b, c);
39829
+ f3._sqlite3_result_int = (a, b) => (f3._sqlite3_result_int = Z2.ha)(a, b);
39830
+ f3._sqlite3_result_int64 = (a, b) => (f3._sqlite3_result_int64 = Z2.ia)(a, b);
39831
+ f3._sqlite3_result_null = (a) => (f3._sqlite3_result_null = Z2.ja)(a);
39832
+ f3._sqlite3_result_text = (a, b, c, d) => (f3._sqlite3_result_text = Z2.ka)(a, b, c, d);
39833
+ f3._sqlite3_aggregate_context = (a, b) => (f3._sqlite3_aggregate_context = Z2.la)(a, b);
39834
+ f3._sqlite3_column_count = (a) => (f3._sqlite3_column_count = Z2.ma)(a);
39835
+ f3._sqlite3_data_count = (a) => (f3._sqlite3_data_count = Z2.na)(a);
39836
+ f3._sqlite3_column_blob = (a, b) => (f3._sqlite3_column_blob = Z2.oa)(a, b);
39837
+ f3._sqlite3_column_bytes = (a, b) => (f3._sqlite3_column_bytes = Z2.pa)(a, b);
39838
+ f3._sqlite3_column_double = (a, b) => (f3._sqlite3_column_double = Z2.qa)(a, b);
39839
+ f3._sqlite3_bind_blob = (a, b, c, d, e2) => (f3._sqlite3_bind_blob = Z2.ra)(a, b, c, d, e2);
39840
+ f3._sqlite3_bind_double = (a, b, c) => (f3._sqlite3_bind_double = Z2.sa)(a, b, c);
39841
+ f3._sqlite3_bind_int = (a, b, c) => (f3._sqlite3_bind_int = Z2.ta)(a, b, c);
39842
+ f3._sqlite3_bind_text = (a, b, c, d, e2) => (f3._sqlite3_bind_text = Z2.ua)(a, b, c, d, e2);
39843
+ f3._sqlite3_bind_parameter_index = (a, b) => (f3._sqlite3_bind_parameter_index = Z2.va)(a, b);
39844
+ f3._sqlite3_sql = (a) => (f3._sqlite3_sql = Z2.wa)(a);
39845
+ f3._sqlite3_normalized_sql = (a) => (f3._sqlite3_normalized_sql = Z2.xa)(a);
39846
+ f3._sqlite3_changes = (a) => (f3._sqlite3_changes = Z2.ya)(a);
39847
+ f3._sqlite3_close_v2 = (a) => (f3._sqlite3_close_v2 = Z2.za)(a);
39848
+ f3._sqlite3_create_function_v2 = (a, b, c, d, e2, h2, k, q, w) => (f3._sqlite3_create_function_v2 = Z2.Aa)(a, b, c, d, e2, h2, k, q, w);
39849
+ f3._sqlite3_update_hook = (a, b, c) => (f3._sqlite3_update_hook = Z2.Ba)(a, b, c);
39850
+ f3._sqlite3_open = (a, b) => (f3._sqlite3_open = Z2.Ca)(a, b);
39851
+ var ia = f3._malloc = (a) => (ia = f3._malloc = Z2.Da)(a), fa = f3._free = (a) => (fa = f3._free = Z2.Ea)(a);
39852
+ f3._RegisterExtensionFunctions = (a) => (f3._RegisterExtensionFunctions = Z2.Fa)(a);
39853
+ var Db = (a, b) => (Db = Z2.Ga)(a, b), Wc = (a, b) => (Wc = Z2.Ha)(a, b), wa = (a) => (wa = Z2.Ia)(a), z2 = (a) => (z2 = Z2.Ja)(a), sa = () => (sa = Z2.Ka)();
39854
+ f3.stackSave = () => sa();
39855
+ f3.stackRestore = (a) => wa(a);
39856
+ f3.stackAlloc = (a) => z2(a);
39857
+ f3.cwrap = (a, b, c, d) => {
39858
+ var e2 = !c || c.every((h2) => h2 === "number" || h2 === "boolean");
39859
+ return b !== "string" && e2 && !d ? f3["_" + a] : (...h2) => Tc(a, b, c, h2);
39860
+ };
39861
+ f3.addFunction = Aa;
39862
+ f3.removeFunction = A2;
39863
+ f3.UTF8ToString = ua;
39864
+ f3.ALLOC_NORMAL = ea;
39865
+ f3.allocate = da;
39866
+ f3.allocateUTF8OnStack = xa;
39867
+ function Yc() {
39868
+ function a() {
39869
+ f3.calledRun = true;
39870
+ if (!La) {
39871
+ if (!f3.noFSInit && !Ib) {
39872
+ var b, c;
39873
+ Ib = true;
39874
+ d ??= f3.stdin;
39875
+ b ??= f3.stdout;
39876
+ c ??= f3.stderr;
39877
+ d ? V("stdin", d) : Zb("/dev/tty", "/dev/stdin");
39878
+ b ? V("stdout", null, b) : Zb("/dev/tty", "/dev/stdout");
39879
+ c ? V("stderr", null, c) : Zb("/dev/tty1", "/dev/stderr");
39880
+ oa("/dev/stdin", 0);
39881
+ oa("/dev/stdout", 1);
39882
+ oa("/dev/stderr", 1);
39883
+ }
39884
+ Z2.N();
39885
+ Jb = false;
39886
+ f3.onRuntimeInitialized?.();
39887
+ if (f3.postRun)
39888
+ for (typeof f3.postRun == "function" && (f3.postRun = [f3.postRun]);f3.postRun.length; ) {
39889
+ var d = f3.postRun.shift();
39890
+ $a.unshift(d);
39891
+ }
39892
+ Za($a);
39893
+ }
39894
+ }
39895
+ if (0 < K)
39896
+ Sa = Yc;
39897
+ else {
39898
+ if (f3.preRun)
39899
+ for (typeof f3.preRun == "function" && (f3.preRun = [f3.preRun]);f3.preRun.length; )
39900
+ bb();
39901
+ Za(ab);
39902
+ 0 < K ? Sa = Yc : f3.setStatus ? (f3.setStatus("Running..."), setTimeout(() => {
39903
+ setTimeout(() => f3.setStatus(""), 1);
39904
+ a();
39905
+ }, 1)) : a();
39906
+ }
39907
+ }
39908
+ if (f3.preInit)
39909
+ for (typeof f3.preInit == "function" && (f3.preInit = [f3.preInit]);0 < f3.preInit.length; )
39910
+ f3.preInit.pop()();
39911
+ Yc();
39912
+ return Module;
38383
39913
  });
39914
+ return initSqlJsPromise;
39915
+ };
39916
+ if (typeof exports === "object" && typeof module === "object") {
39917
+ module.exports = initSqlJs;
39918
+ module.exports.default = initSqlJs;
39919
+ } else if (typeof define === "function" && define["amd"]) {
39920
+ define([], function() {
39921
+ return initSqlJs;
39922
+ });
39923
+ } else if (typeof exports === "object") {
39924
+ exports["Module"] = initSqlJs;
38384
39925
  }
38385
- var wrappers = require_wrappers();
38386
- Database.prototype.prepare = wrappers.prepare;
38387
- Database.prototype.transaction = require_transaction();
38388
- Database.prototype.pragma = require_pragma();
38389
- Database.prototype.backup = require_backup();
38390
- Database.prototype.serialize = require_serialize();
38391
- Database.prototype.function = require_function();
38392
- Database.prototype.aggregate = require_aggregate();
38393
- Database.prototype.table = require_table();
38394
- Database.prototype.loadExtension = wrappers.loadExtension;
38395
- Database.prototype.exec = wrappers.exec;
38396
- Database.prototype.close = wrappers.close;
38397
- Database.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;
38398
- Database.prototype.unsafeMode = wrappers.unsafeMode;
38399
- Database.prototype[util2.inspect] = require_inspect();
38400
- module.exports = Database;
38401
- });
38402
-
38403
- // ../../node_modules/better-sqlite3/lib/index.js
38404
- var require_lib2 = __commonJS((exports, module) => {
38405
- module.exports = require_database();
38406
- module.exports.SqliteError = require_sqlite_error();
38407
39926
  });
38408
39927
 
38409
39928
  // ../../node_modules/ws/lib/constants.js
@@ -41264,7 +42783,7 @@ var {
41264
42783
  Help
41265
42784
  } = import__.default;
41266
42785
  // package.json
41267
- var version = "0.9.89";
42786
+ var version = "0.9.90";
41268
42787
 
41269
42788
  // src/runner.ts
41270
42789
  import { execSync } from "node:child_process";
@@ -54888,13 +56407,57 @@ function date4(params) {
54888
56407
 
54889
56408
  // ../../node_modules/zod/v4/classic/external.js
54890
56409
  config(en_default());
56410
+ // ../core/src/config/base.ts
56411
+ var baseModelConfigSchema = exports_external.object({
56412
+ provider: exports_external.string().optional(),
56413
+ model: exports_external.string().optional(),
56414
+ parameters: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
56415
+ });
56416
+ var baseApprovalConfigSchema = exports_external.object({
56417
+ level: exports_external.enum(["none", "destructive", "commits", "all"]).optional(),
56418
+ autoApprove: exports_external.boolean().optional(),
56419
+ maxCost: exports_external.number().positive().optional()
56420
+ });
56421
+ var providerConfigSchema = exports_external.object({
56422
+ apiKey: exports_external.string().optional(),
56423
+ defaultModel: exports_external.string().optional(),
56424
+ defaultParameters: exports_external.record(exports_external.string(), exports_external.unknown()).optional(),
56425
+ location: exports_external.string().optional(),
56426
+ project: exports_external.string().optional(),
56427
+ keyFile: exports_external.string().optional(),
56428
+ baseUrl: exports_external.string().optional(),
56429
+ name: exports_external.string().optional()
56430
+ });
56431
+ var modelConfigSchema = baseModelConfigSchema.extend({
56432
+ budget: exports_external.number().positive().optional(),
56433
+ rules: exports_external.union([exports_external.string(), exports_external.array(exports_external.string()).optional()]).optional()
56434
+ });
56435
+ var toolConfigSchema = exports_external.union([
56436
+ exports_external.boolean(),
56437
+ baseModelConfigSchema
56438
+ ]);
56439
+
54891
56440
  // ../core/src/config/memory.ts
54892
56441
  var memoryConfigSchema = exports_external.object({
54893
56442
  enabled: exports_external.boolean().optional().default(true),
54894
56443
  type: exports_external.enum(["sqlite", "memory"]).optional().default("sqlite"),
54895
56444
  path: exports_external.string().optional().default("~/.config/polka-codes/memory.sqlite")
54896
56445
  }).strict().optional();
54897
-
56446
+ var DEFAULT_MEMORY_CONFIG = {
56447
+ enabled: true,
56448
+ type: "sqlite",
56449
+ path: "~/.config/polka-codes/memory.sqlite"
56450
+ };
56451
+ function resolveHomePath(path) {
56452
+ if (path.startsWith("~")) {
56453
+ const home = process.env.HOME || process.env.USERPROFILE || ".";
56454
+ if (home === ".") {
56455
+ throw new Error("Cannot resolve home directory: HOME and USERPROFILE environment variables are not set");
56456
+ }
56457
+ return `${home}${path.slice(1)}`;
56458
+ }
56459
+ return path;
56460
+ }
54898
56461
  // ../core/src/config.ts
54899
56462
  var ruleSchema = exports_external.union([
54900
56463
  exports_external.string(),
@@ -54908,20 +56471,10 @@ var ruleSchema = exports_external.union([
54908
56471
  branch: exports_external.string().optional()
54909
56472
  }).strict()
54910
56473
  ]);
54911
- var providerConfigSchema = exports_external.object({
54912
- apiKey: exports_external.string().optional(),
54913
- defaultModel: exports_external.string().optional(),
54914
- defaultParameters: exports_external.record(exports_external.string(), exports_external.any()).optional(),
54915
- location: exports_external.string().optional(),
54916
- project: exports_external.string().optional(),
54917
- keyFile: exports_external.string().optional(),
54918
- baseUrl: exports_external.string().optional(),
54919
- name: exports_external.string().optional()
54920
- });
54921
56474
  var providerModelSchema = exports_external.object({
54922
56475
  provider: exports_external.string().optional(),
54923
56476
  model: exports_external.string().optional(),
54924
- parameters: exports_external.record(exports_external.string(), exports_external.any()).optional(),
56477
+ parameters: exports_external.record(exports_external.string(), exports_external.unknown()).optional(),
54925
56478
  budget: exports_external.number().positive().optional(),
54926
56479
  rules: exports_external.array(ruleSchema).optional().or(exports_external.string()).optional()
54927
56480
  });
@@ -54934,7 +56487,7 @@ var scriptSchema = exports_external.union([
54934
56487
  exports_external.object({
54935
56488
  workflow: exports_external.string(),
54936
56489
  description: exports_external.string().optional(),
54937
- input: exports_external.record(exports_external.string(), exports_external.any()).optional()
56490
+ input: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
54938
56491
  }).strict(),
54939
56492
  exports_external.object({
54940
56493
  script: exports_external.string(),
@@ -55013,7 +56566,7 @@ var configSchema = exports_external.object({
55013
56566
  providers: exports_external.record(exports_external.string(), providerConfigSchema).optional(),
55014
56567
  defaultProvider: exports_external.string().optional(),
55015
56568
  defaultModel: exports_external.string().optional(),
55016
- defaultParameters: exports_external.record(exports_external.string(), exports_external.any()).optional(),
56569
+ defaultParameters: exports_external.record(exports_external.string(), exports_external.unknown()).optional(),
55017
56570
  maxMessageCount: exports_external.number().int().positive().optional(),
55018
56571
  budget: exports_external.number().positive().optional(),
55019
56572
  retryCount: exports_external.number().int().min(0).optional(),
@@ -66099,7 +67652,7 @@ var uiMessagesSchema = lazyValidator(() => zodSchema(exports_external.array(expo
66099
67652
  var WorkflowInputDefinitionSchema = exports_external.object({
66100
67653
  id: exports_external.string(),
66101
67654
  description: exports_external.string().nullish(),
66102
- default: exports_external.any().nullish()
67655
+ default: exports_external.unknown().nullish()
66103
67656
  });
66104
67657
  var WorkflowStepDefinitionSchema = exports_external.object({
66105
67658
  id: exports_external.string(),
@@ -66107,7 +67660,7 @@ var WorkflowStepDefinitionSchema = exports_external.object({
66107
67660
  task: exports_external.string(),
66108
67661
  output: exports_external.string().nullish(),
66109
67662
  expected_outcome: exports_external.string().nullish(),
66110
- outputSchema: exports_external.any().nullish(),
67663
+ outputSchema: exports_external.unknown().nullish(),
66111
67664
  timeout: exports_external.number().positive().nullish()
66112
67665
  });
66113
67666
  var WhileLoopStepSchema = exports_external.object({
@@ -67226,7 +68779,7 @@ function mergeConfigs(configs) {
67226
68779
  merged.rules = mergeArray(accRules, configRules);
67227
68780
  merged.excludeFiles = mergeArray(acc.excludeFiles, config3.excludeFiles);
67228
68781
  return merged;
67229
- });
68782
+ }, {});
67230
68783
  return mergedConfig;
67231
68784
  }
67232
68785
  async function resolveRules(rules) {
@@ -69426,12 +70979,12 @@ function isPlainObject3(value) {
69426
70979
  }
69427
70980
  return Object.getPrototypeOf(value) === proto;
69428
70981
  }
69429
- function deepMerge(...objects) {
70982
+ function deepMerge2(...objects) {
69430
70983
  const output = {};
69431
70984
  for (const obj of objects) {
69432
70985
  for (const [key, value] of Object.entries(obj)) {
69433
70986
  const prevValue = output[key];
69434
- output[key] = isPlainObject3(prevValue) && isPlainObject3(value) ? deepMerge(prevValue, value) : value;
70987
+ output[key] = isPlainObject3(prevValue) && isPlainObject3(value) ? deepMerge2(prevValue, value) : value;
69435
70988
  }
69436
70989
  }
69437
70990
  return output;
@@ -69441,7 +70994,7 @@ function makeTheme(...themes) {
69441
70994
  defaultTheme,
69442
70995
  ...themes.filter((theme) => theme != null)
69443
70996
  ];
69444
- return deepMerge(...themesToMerge);
70997
+ return deepMerge2(...themesToMerge);
69445
70998
  }
69446
70999
 
69447
71000
  // ../../node_modules/@inquirer/core/dist/lib/use-prefix.js
@@ -70923,12 +72476,59 @@ class InMemoryStore {
70923
72476
  this.#data = data;
70924
72477
  }
70925
72478
  }
72479
+ function isIMemoryStore(store) {
72480
+ return "readMemory" in store && "updateMemory" in store;
72481
+ }
70926
72482
  var getProvider = (options = {}) => {
70927
72483
  const ig = import_ignore2.default().add(options.excludeFiles ?? []);
70928
72484
  const memoryStore = options.memoryStore ?? new InMemoryStore;
70929
72485
  const todoItemStore = options.todoItemStore ?? new InMemoryStore;
70930
72486
  const defaultMemoryTopic = ":default:";
70931
72487
  const searchModel = options.getModel?.("search");
72488
+ const readMemoryKV = async (topic) => {
72489
+ if (!isIMemoryStore(memoryStore)) {
72490
+ const data = await memoryStore.read() ?? {};
72491
+ return data[topic];
72492
+ }
72493
+ return memoryStore.readMemory(topic);
72494
+ };
72495
+ const updateMemoryKV = async (operation, topic, content) => {
72496
+ if (!isIMemoryStore(memoryStore)) {
72497
+ const data = await memoryStore.read() ?? {};
72498
+ switch (operation) {
72499
+ case "append":
72500
+ if (content === undefined) {
72501
+ throw new Error("Content is required for append operation.");
72502
+ }
72503
+ data[topic] = `${data[topic] || ""}
72504
+ ${content}`;
72505
+ break;
72506
+ case "replace":
72507
+ if (content === undefined) {
72508
+ throw new Error("Content is required for replace operation.");
72509
+ }
72510
+ data[topic] = content;
72511
+ break;
72512
+ case "remove":
72513
+ delete data[topic];
72514
+ break;
72515
+ }
72516
+ await memoryStore.write(data);
72517
+ return;
72518
+ }
72519
+ await memoryStore.updateMemory(operation, topic, content);
72520
+ };
72521
+ const listMemoryTopicsKV = async () => {
72522
+ if (!isIMemoryStore(memoryStore)) {
72523
+ const data = await memoryStore.read() ?? {};
72524
+ return Object.keys(data);
72525
+ }
72526
+ const entries = await memoryStore.queryMemory({});
72527
+ if (Array.isArray(entries)) {
72528
+ return entries.map((e2) => e2.name);
72529
+ }
72530
+ return [];
72531
+ };
70932
72532
  const provider2 = {
70933
72533
  listTodoItems: async (id, status) => {
70934
72534
  const todoItems = await todoItemStore.read() ?? [];
@@ -71027,35 +72627,14 @@ var getProvider = (options = {}) => {
71027
72627
  }
71028
72628
  },
71029
72629
  listMemoryTopics: async () => {
71030
- const memory2 = await memoryStore.read() ?? {};
71031
- return Object.keys(memory2);
72630
+ return listMemoryTopicsKV();
71032
72631
  },
71033
72632
  readMemory: async (topic = defaultMemoryTopic) => {
71034
- const memory2 = await memoryStore.read() ?? {};
71035
- return memory2[topic];
72633
+ return readMemoryKV(topic);
71036
72634
  },
71037
72635
  updateMemory: async (operation, topic, content) => {
71038
72636
  const memoryTopic = topic ?? defaultMemoryTopic;
71039
- const memory2 = await memoryStore.read() ?? {};
71040
- switch (operation) {
71041
- case "append":
71042
- if (content === undefined) {
71043
- throw new Error("Content is required for append operation.");
71044
- }
71045
- memory2[memoryTopic] = `${memory2[memoryTopic] || ""}
71046
- ${content}`;
71047
- break;
71048
- case "replace":
71049
- if (content === undefined) {
71050
- throw new Error("Content is required for replace operation.");
71051
- }
71052
- memory2[memoryTopic] = content;
71053
- break;
71054
- case "remove":
71055
- delete memory2[memoryTopic];
71056
- break;
71057
- }
71058
- await memoryStore.write(memory2);
72637
+ await updateMemoryKV(operation, memoryTopic, content);
71059
72638
  },
71060
72639
  readFile: async (path, includeIgnored) => {
71061
72640
  if (!includeIgnored && ig.ignores(path)) {
@@ -71223,7 +72802,666 @@ ${content}`;
71223
72802
  return provider2;
71224
72803
  };
71225
72804
  // ../cli-shared/src/sqlite-memory-store.ts
71226
- var import_better_sqlite3 = __toESM(require_lib2(), 1);
72805
+ import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
72806
+ import { randomUUID } from "node:crypto";
72807
+ import { existsSync as existsSync2 } from "node:fs";
72808
+ import { mkdir as mkdir2, readFile as readFile3, rename as rename2, writeFile as writeFile2 } from "node:fs/promises";
72809
+ import { dirname as dirname2, resolve as resolve4 } from "node:path";
72810
+ var import_sql = __toESM(require_sql_wasm(), 1);
72811
+
72812
+ class FileLock {
72813
+ lockfilePath;
72814
+ static LOCK_TIMEOUT = 30000;
72815
+ constructor(dbPath) {
72816
+ this.lockfilePath = `${dbPath}.lock`;
72817
+ }
72818
+ async acquire(retries = 10, delay2 = 100) {
72819
+ for (let i2 = 0;i2 < retries; i2++) {
72820
+ try {
72821
+ const lockData = JSON.stringify({
72822
+ pid: process.pid,
72823
+ acquiredAt: Date.now()
72824
+ });
72825
+ await writeFile2(this.lockfilePath, lockData, {
72826
+ flag: "wx",
72827
+ mode: 384
72828
+ });
72829
+ return;
72830
+ } catch (error48) {
72831
+ const errorCode = error48?.code;
72832
+ if (errorCode === "EEXIST") {
72833
+ try {
72834
+ const lockContent = await readFile3(this.lockfilePath, "utf-8");
72835
+ const lockData = JSON.parse(lockContent);
72836
+ if (!lockData || typeof lockData.acquiredAt !== "number" || lockData.acquiredAt <= 0) {
72837
+ console.warn(`[FileLock] Lock file has invalid acquiredAt, treating as stale`);
72838
+ await rename2(this.lockfilePath, `${this.lockfilePath}.invalid.${Date.now()}`);
72839
+ continue;
72840
+ }
72841
+ const lockAge = Date.now() - lockData.acquiredAt;
72842
+ if (lockAge > FileLock.LOCK_TIMEOUT) {
72843
+ console.warn(`[FileLock] Breaking stale lock (age: ${lockAge}ms)`);
72844
+ await rename2(this.lockfilePath, `${this.lockfilePath}.stale.${Date.now()}`);
72845
+ continue;
72846
+ }
72847
+ } catch (readError) {
72848
+ if (readError instanceof SyntaxError) {
72849
+ console.warn(`[FileLock] Lock file contains invalid JSON, treating as stale`);
72850
+ await rename2(this.lockfilePath, `${this.lockfilePath}.corrupt.${Date.now()}`);
72851
+ continue;
72852
+ }
72853
+ }
72854
+ if (i2 < retries - 1) {
72855
+ await new Promise((resolve5) => setTimeout(resolve5, delay2));
72856
+ } else {
72857
+ throw new Error(`Cannot acquire lock after ${retries} retries (file: ${this.lockfilePath})`);
72858
+ }
72859
+ } else {
72860
+ throw error48;
72861
+ }
72862
+ }
72863
+ }
72864
+ }
72865
+ async release() {
72866
+ try {
72867
+ await rename2(this.lockfilePath, `${this.lockfilePath}.released.${Date.now()}`);
72868
+ } catch (error48) {
72869
+ const errorCode = error48.code;
72870
+ if (errorCode !== "ENOENT") {
72871
+ console.warn(`[FileLock] Error releasing lock: ${error48 instanceof Error ? error48.message : String(error48)}`);
72872
+ }
72873
+ }
72874
+ }
72875
+ }
72876
+
72877
+ class ReentrantMutex {
72878
+ queue = [];
72879
+ locked = false;
72880
+ lockCount = 0;
72881
+ owner = null;
72882
+ async acquire(owner) {
72883
+ if (this.locked && this.owner === owner) {
72884
+ this.lockCount++;
72885
+ return () => this.release(owner);
72886
+ }
72887
+ while (this.locked) {
72888
+ await new Promise((resolve5) => this.queue.push(resolve5));
72889
+ }
72890
+ this.locked = true;
72891
+ this.owner = owner;
72892
+ this.lockCount = 1;
72893
+ return () => this.release(owner);
72894
+ }
72895
+ release(owner) {
72896
+ if (this.owner !== owner) {
72897
+ return;
72898
+ }
72899
+ this.lockCount--;
72900
+ if (this.lockCount === 0) {
72901
+ this.locked = false;
72902
+ this.owner = null;
72903
+ const next = this.queue.shift();
72904
+ if (next) {
72905
+ next();
72906
+ }
72907
+ }
72908
+ }
72909
+ }
72910
+ var SqlJs = null;
72911
+ var SqlJsInitPromise = null;
72912
+ async function getSqlJs() {
72913
+ if (SqlJs) {
72914
+ return SqlJs;
72915
+ }
72916
+ if (SqlJsInitPromise) {
72917
+ return SqlJsInitPromise;
72918
+ }
72919
+ SqlJsInitPromise = import_sql.default({});
72920
+ SqlJs = await SqlJsInitPromise;
72921
+ return SqlJs;
72922
+ }
72923
+ var transactionOwnerStorage = new AsyncLocalStorage2;
72924
+
72925
+ class SQLiteMemoryStore {
72926
+ db = null;
72927
+ dbPromise = null;
72928
+ config;
72929
+ currentScope;
72930
+ inTransaction = false;
72931
+ transactionMutex = new ReentrantMutex;
72932
+ fileLock;
72933
+ getDbPath() {
72934
+ return this.config.path || DEFAULT_MEMORY_CONFIG.path;
72935
+ }
72936
+ getFileLock() {
72937
+ if (!this.fileLock) {
72938
+ const dbPath = this.resolvePath(this.getDbPath());
72939
+ this.fileLock = new FileLock(dbPath);
72940
+ }
72941
+ return this.fileLock;
72942
+ }
72943
+ static SORT_COLUMNS = {
72944
+ created: "created_at",
72945
+ updated: "updated_at",
72946
+ accessed: "last_accessed",
72947
+ name: "name"
72948
+ };
72949
+ static ALLOWED_SORT_ORDERS = ["asc", "desc"];
72950
+ static ALLOWED_PRIORITIES = ["low", "medium", "high", "critical"];
72951
+ constructor(config3, scope) {
72952
+ this.config = config3;
72953
+ this.currentScope = scope;
72954
+ }
72955
+ async initializeDatabase() {
72956
+ if (this.dbPromise) {
72957
+ return this.dbPromise;
72958
+ }
72959
+ this.dbPromise = (async () => {
72960
+ if (this.db) {
72961
+ return this.db;
72962
+ }
72963
+ const dbPath = this.resolvePath(this.getDbPath());
72964
+ try {
72965
+ const dir = dirname2(dbPath);
72966
+ if (!existsSync2(dir)) {
72967
+ await mkdir2(dir, { recursive: true, mode: 448 });
72968
+ }
72969
+ let dbData;
72970
+ if (existsSync2(dbPath)) {
72971
+ const lock = this.getFileLock();
72972
+ await lock.acquire();
72973
+ try {
72974
+ try {
72975
+ dbData = await readFile3(dbPath);
72976
+ if (dbData.length >= 16) {
72977
+ const header = String.fromCharCode(...dbData.subarray(0, 15));
72978
+ if (header !== "SQLite format 3") {
72979
+ console.warn("[SQLiteMemoryStore] Invalid SQLite database header, will recreate");
72980
+ dbData = undefined;
72981
+ }
72982
+ }
72983
+ } catch (error48) {
72984
+ const errorCode = error48?.code;
72985
+ if (errorCode === "ENOENT") {
72986
+ dbData = undefined;
72987
+ } else {
72988
+ throw new Error(`Failed to read database file at ${dbPath}: ${error48 instanceof Error ? error48.message : String(error48)}`);
72989
+ }
72990
+ }
72991
+ } finally {
72992
+ await lock.release();
72993
+ }
72994
+ }
72995
+ const SqlJs2 = await getSqlJs();
72996
+ const db2 = new SqlJs2.Database(dbData);
72997
+ this.configurePragmas(db2);
72998
+ this.checkIntegrity(db2);
72999
+ this.initializeSchema(db2);
73000
+ this.db = db2;
73001
+ return db2;
73002
+ } catch (error48) {
73003
+ console.error("[SQLiteMemoryStore] Initialization failed:", error48);
73004
+ if (existsSync2(dbPath)) {
73005
+ const backupPath = `${dbPath}.corrupted.${Date.now()}`;
73006
+ console.warn(`[SQLiteMemoryStore] Backing up corrupted database to: ${backupPath}`);
73007
+ try {
73008
+ await rename2(dbPath, backupPath);
73009
+ } catch (backupError) {
73010
+ console.error("[SQLiteMemoryStore] Failed to backup corrupted database:", backupError);
73011
+ this.dbPromise = null;
73012
+ throw backupError;
73013
+ }
73014
+ this.dbPromise = null;
73015
+ return this.initializeDatabase();
73016
+ }
73017
+ this.dbPromise = null;
73018
+ throw error48;
73019
+ }
73020
+ })();
73021
+ return this.dbPromise;
73022
+ }
73023
+ async saveDatabase() {
73024
+ if (!this.db) {
73025
+ return;
73026
+ }
73027
+ const lock = this.getFileLock();
73028
+ await lock.acquire();
73029
+ try {
73030
+ const dbPath = this.resolvePath(this.getDbPath());
73031
+ const tempPath = `${dbPath}.tmp`;
73032
+ const data = this.db.export();
73033
+ await writeFile2(tempPath, data, { mode: 384 });
73034
+ await rename2(tempPath, dbPath);
73035
+ } finally {
73036
+ await lock.release();
73037
+ }
73038
+ }
73039
+ configurePragmas(db2) {
73040
+ db2.run("PRAGMA synchronous = NORMAL");
73041
+ db2.run("PRAGMA busy_timeout = 5000");
73042
+ db2.run("PRAGMA foreign_keys = ON");
73043
+ db2.run("PRAGMA temp_store = MEMORY");
73044
+ }
73045
+ checkIntegrity(db2) {
73046
+ try {
73047
+ const results = db2.exec("SELECT 1");
73048
+ if (results.length === 0) {
73049
+ throw new Error("Database query returned no results");
73050
+ }
73051
+ } catch (error48) {
73052
+ console.error("[SQLiteMemoryStore] Integrity check failed:", error48);
73053
+ throw new Error("Database is corrupted");
73054
+ }
73055
+ }
73056
+ initializeSchema(db2) {
73057
+ db2.run(`
73058
+ CREATE TABLE IF NOT EXISTS memory_entries (
73059
+ id TEXT PRIMARY KEY,
73060
+ name TEXT NOT NULL CHECK(length(name) > 0),
73061
+ scope TEXT NOT NULL CHECK(scope IN ('global') OR scope LIKE 'project:%'),
73062
+ content TEXT NOT NULL CHECK(length(content) > 0),
73063
+ entry_type TEXT NOT NULL CHECK(length(entry_type) > 0),
73064
+ status TEXT CHECK(status IS NULL OR length(status) > 0),
73065
+ priority TEXT CHECK(priority IS NULL OR priority IN ('low', 'medium', 'high', 'critical')),
73066
+ tags TEXT CHECK(tags IS NULL OR length(tags) > 0),
73067
+ metadata TEXT CHECK(metadata IS NULL OR json_valid(metadata)),
73068
+ created_at INTEGER NOT NULL CHECK(created_at > 0),
73069
+ updated_at INTEGER NOT NULL CHECK(updated_at > 0),
73070
+ last_accessed INTEGER NOT NULL CHECK(last_accessed > 0),
73071
+ UNIQUE(name, scope)
73072
+ )
73073
+ `);
73074
+ db2.run("CREATE INDEX IF NOT EXISTS idx_memory_entries_scope_type ON memory_entries(scope, entry_type)");
73075
+ db2.run("CREATE INDEX IF NOT EXISTS idx_memory_entries_updated ON memory_entries(updated_at)");
73076
+ }
73077
+ async getDatabase() {
73078
+ if (!this.db) {
73079
+ this.db = await this.initializeDatabase();
73080
+ }
73081
+ return this.db;
73082
+ }
73083
+ resolvePath(path) {
73084
+ const resolved = resolveHomePath(path);
73085
+ return resolve4(resolved);
73086
+ }
73087
+ generateUUID() {
73088
+ return randomUUID();
73089
+ }
73090
+ now() {
73091
+ return Date.now();
73092
+ }
73093
+ async transaction(callback) {
73094
+ let owner = transactionOwnerStorage.getStore();
73095
+ if (!owner) {
73096
+ owner = Symbol("transaction");
73097
+ }
73098
+ const release = await this.transactionMutex.acquire(owner);
73099
+ return transactionOwnerStorage.run(owner, async () => {
73100
+ try {
73101
+ const db2 = await this.getDatabase();
73102
+ const shouldBegin = !this.inTransaction;
73103
+ try {
73104
+ if (shouldBegin) {
73105
+ db2.run("BEGIN TRANSACTION");
73106
+ this.inTransaction = true;
73107
+ }
73108
+ const result = await callback();
73109
+ if (shouldBegin) {
73110
+ db2.run("COMMIT");
73111
+ this.inTransaction = false;
73112
+ try {
73113
+ await this.saveDatabase();
73114
+ } catch (saveError) {
73115
+ console.error("[SQLiteMemoryStore] Failed to save database after commit, closing:", saveError);
73116
+ await this.close(true);
73117
+ throw saveError;
73118
+ }
73119
+ }
73120
+ return result;
73121
+ } catch (error48) {
73122
+ if (this.inTransaction) {
73123
+ try {
73124
+ db2.run("ROLLBACK");
73125
+ } catch (rollbackError) {
73126
+ console.error("[SQLiteMemoryStore] ROLLBACK failed:", rollbackError);
73127
+ }
73128
+ this.inTransaction = false;
73129
+ }
73130
+ throw error48;
73131
+ }
73132
+ } finally {
73133
+ release();
73134
+ }
73135
+ });
73136
+ }
73137
+ async readMemory(topic) {
73138
+ const db2 = await this.getDatabase();
73139
+ const scope = this.currentScope;
73140
+ const stmt = db2.prepare("SELECT content FROM memory_entries WHERE name = ? AND scope = ?");
73141
+ stmt.bind([topic, scope]);
73142
+ if (stmt.step()) {
73143
+ const row = stmt.getAsObject();
73144
+ const content = row.content;
73145
+ stmt.free();
73146
+ return content;
73147
+ }
73148
+ stmt.free();
73149
+ return;
73150
+ }
73151
+ async updateMemoryInternal(db2, operation, topic, content, metadata) {
73152
+ const scope = this.currentScope;
73153
+ const now = this.now();
73154
+ const createdAt = metadata?.created_at ?? now;
73155
+ const updatedAt = metadata?.updated_at ?? now;
73156
+ const lastAccessed = metadata?.last_accessed ?? now;
73157
+ if (operation === "remove") {
73158
+ const stmt2 = db2.prepare("DELETE FROM memory_entries WHERE name = ? AND scope = ?");
73159
+ stmt2.run([topic, scope]);
73160
+ stmt2.free();
73161
+ return;
73162
+ }
73163
+ const stmt = db2.prepare("SELECT content, entry_type, status, priority, tags FROM memory_entries WHERE name = ? AND scope = ?");
73164
+ stmt.bind([topic, scope]);
73165
+ let existing;
73166
+ if (stmt.step()) {
73167
+ const row = stmt.getAsObject();
73168
+ existing = {
73169
+ content: row.content,
73170
+ entry_type: row.entry_type,
73171
+ status: row.status,
73172
+ priority: row.priority,
73173
+ tags: row.tags
73174
+ };
73175
+ stmt.free();
73176
+ } else {
73177
+ existing = undefined;
73178
+ stmt.free();
73179
+ }
73180
+ let finalContent;
73181
+ let entry_type;
73182
+ let status;
73183
+ let priority;
73184
+ let tags;
73185
+ if (existing) {
73186
+ if (operation === "append") {
73187
+ if (!content) {
73188
+ throw new Error("Content is required for append operation.");
73189
+ }
73190
+ finalContent = `${existing.content}
73191
+ ${content}`;
73192
+ } else {
73193
+ if (!content) {
73194
+ throw new Error("Content is required for replace operation.");
73195
+ }
73196
+ finalContent = content;
73197
+ }
73198
+ entry_type = metadata?.entry_type || existing.entry_type;
73199
+ status = (metadata?.status || existing.status) ?? undefined;
73200
+ priority = (metadata?.priority || existing.priority) ?? undefined;
73201
+ tags = (metadata?.tags || existing.tags) ?? undefined;
73202
+ } else {
73203
+ if (!content) {
73204
+ throw new Error("Content is required for new memory entries.");
73205
+ }
73206
+ finalContent = content;
73207
+ entry_type = metadata?.entry_type || "note";
73208
+ status = metadata?.status;
73209
+ priority = metadata?.priority;
73210
+ tags = metadata?.tags;
73211
+ }
73212
+ const upsertStmt = db2.prepare(`
73213
+ INSERT INTO memory_entries (id, name, scope, content, entry_type, status, priority, tags, created_at, updated_at, last_accessed)
73214
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
73215
+ ON CONFLICT(name, scope) DO UPDATE SET
73216
+ content = excluded.content,
73217
+ entry_type = excluded.entry_type,
73218
+ status = excluded.status,
73219
+ priority = excluded.priority,
73220
+ tags = excluded.tags,
73221
+ updated_at = excluded.updated_at,
73222
+ last_accessed = excluded.last_accessed
73223
+ `);
73224
+ upsertStmt.run([
73225
+ this.generateUUID(),
73226
+ topic,
73227
+ scope,
73228
+ finalContent,
73229
+ entry_type,
73230
+ status ?? null,
73231
+ priority ?? null,
73232
+ tags ?? null,
73233
+ createdAt,
73234
+ updatedAt,
73235
+ lastAccessed
73236
+ ]);
73237
+ upsertStmt.free();
73238
+ }
73239
+ async updateMemory(operation, topic, content, metadata) {
73240
+ return this.transaction(async () => {
73241
+ const db2 = await this.getDatabase();
73242
+ await this.updateMemoryInternal(db2, operation, topic, content, metadata);
73243
+ });
73244
+ }
73245
+ async queryMemory(query = {}, options = {}) {
73246
+ if (options.operation === "delete") {
73247
+ return this.transaction(async () => {
73248
+ const db3 = await this.getDatabase();
73249
+ const { sql: sql2, params: params2 } = this.buildQuery(query);
73250
+ const deleteSql = `DELETE FROM memory_entries WHERE id IN (SELECT id FROM (${sql2}))`;
73251
+ const stmt2 = db3.prepare(deleteSql);
73252
+ stmt2.bind(params2);
73253
+ stmt2.step();
73254
+ stmt2.free();
73255
+ return db3.getRowsModified();
73256
+ });
73257
+ }
73258
+ const db2 = await this.getDatabase();
73259
+ const { sql, params } = this.buildQuery(query);
73260
+ if (options.operation === "count") {
73261
+ const countSql = `SELECT COUNT(*) as count FROM (${sql})`;
73262
+ const stmt2 = db2.prepare(countSql);
73263
+ stmt2.bind(params);
73264
+ let count = 0;
73265
+ if (stmt2.step()) {
73266
+ const row = stmt2.getAsObject();
73267
+ count = row.count;
73268
+ }
73269
+ stmt2.free();
73270
+ return count;
73271
+ }
73272
+ const stmt = db2.prepare(sql);
73273
+ stmt.bind(params);
73274
+ const entries = [];
73275
+ while (stmt.step()) {
73276
+ entries.push(stmt.getAsObject());
73277
+ }
73278
+ stmt.free();
73279
+ return entries;
73280
+ }
73281
+ buildQuery(query) {
73282
+ const conditions = [];
73283
+ const params = [];
73284
+ let sql = "SELECT * FROM memory_entries WHERE 1=1";
73285
+ const scope = query.scope === "auto" ? this.currentScope : query.scope;
73286
+ if (scope === "global") {
73287
+ conditions.push(`scope = ?`);
73288
+ params.push("global");
73289
+ } else if (scope === "project" || !scope && this.currentScope !== "global") {
73290
+ conditions.push(`scope = ?`);
73291
+ params.push(this.currentScope);
73292
+ }
73293
+ if (query.name) {
73294
+ if (!query.name.trim()) {
73295
+ throw new Error("Name cannot be empty");
73296
+ }
73297
+ conditions.push(`name = ?`);
73298
+ params.push(query.name.trim());
73299
+ }
73300
+ if (query.type) {
73301
+ if (!query.type.trim()) {
73302
+ throw new Error("Type cannot be empty");
73303
+ }
73304
+ conditions.push(`entry_type = ?`);
73305
+ params.push(query.type.trim());
73306
+ }
73307
+ if (query.status) {
73308
+ conditions.push(`status = ?`);
73309
+ params.push(query.status);
73310
+ }
73311
+ if (query.priority) {
73312
+ if (!SQLiteMemoryStore.ALLOWED_PRIORITIES.includes(query.priority)) {
73313
+ throw new Error(`Invalid priority: ${query.priority}`);
73314
+ }
73315
+ conditions.push(`priority = ?`);
73316
+ params.push(query.priority);
73317
+ }
73318
+ if (query.tags) {
73319
+ const tags = Array.isArray(query.tags) ? query.tags : [query.tags];
73320
+ for (const tag of tags) {
73321
+ const trimmed = tag.trim();
73322
+ if (!trimmed) {
73323
+ throw new Error("Tags cannot be empty");
73324
+ }
73325
+ const escaped = trimmed.replace(/[\\_%]/g, "\\$&");
73326
+ conditions.push(`(tags = ? OR tags LIKE ? ESCAPE '\\' OR tags LIKE ? ESCAPE '\\' OR tags LIKE ? ESCAPE '\\')`);
73327
+ params.push(trimmed, `${escaped},%`, `%,${escaped}`, `%,${escaped},%`);
73328
+ }
73329
+ }
73330
+ if (query.search) {
73331
+ const searchTerm = query.search.trim();
73332
+ conditions.push(`(content LIKE ? ESCAPE '\\' OR name LIKE ? ESCAPE '\\')`);
73333
+ const searchPattern = `%${searchTerm.replace(/[\\_%]/g, "\\$&")}%`;
73334
+ params.push(searchPattern, searchPattern);
73335
+ }
73336
+ if (query.createdAfter) {
73337
+ conditions.push(`created_at >= ?`);
73338
+ params.push(query.createdAfter);
73339
+ }
73340
+ if (query.createdBefore) {
73341
+ conditions.push(`created_at <= ?`);
73342
+ params.push(query.createdBefore);
73343
+ }
73344
+ if (query.updatedAfter) {
73345
+ conditions.push(`updated_at >= ?`);
73346
+ params.push(query.updatedAfter);
73347
+ }
73348
+ if (query.updatedBefore) {
73349
+ conditions.push(`updated_at <= ?`);
73350
+ params.push(query.updatedBefore);
73351
+ }
73352
+ if (conditions.length > 0) {
73353
+ sql += ` AND ${conditions.join(" AND ")}`;
73354
+ }
73355
+ if (query.sortBy) {
73356
+ const column = SQLiteMemoryStore.SORT_COLUMNS[query.sortBy];
73357
+ if (!column) {
73358
+ throw new Error(`Invalid sortBy: ${query.sortBy}`);
73359
+ }
73360
+ const order = query.sortOrder || "desc";
73361
+ if (!SQLiteMemoryStore.ALLOWED_SORT_ORDERS.includes(order)) {
73362
+ throw new Error(`Invalid sortOrder: ${order}`);
73363
+ }
73364
+ sql += ` ORDER BY ${column} ${order.toUpperCase()}`;
73365
+ }
73366
+ if (query.limit) {
73367
+ const limit = Number(query.limit);
73368
+ if (Number.isNaN(limit) || limit < 1 || limit > 1e4) {
73369
+ throw new Error("Limit must be between 1 and 10000");
73370
+ }
73371
+ sql += ` LIMIT ?`;
73372
+ params.push(limit);
73373
+ }
73374
+ if (query.offset) {
73375
+ const offset = Number(query.offset);
73376
+ if (Number.isNaN(offset) || offset < 0) {
73377
+ throw new Error("Offset must be >= 0");
73378
+ }
73379
+ sql += ` OFFSET ?`;
73380
+ params.push(offset);
73381
+ }
73382
+ return { sql, params };
73383
+ }
73384
+ async batchUpdateMemory(operations) {
73385
+ return this.transaction(async () => {
73386
+ const db2 = await this.getDatabase();
73387
+ for (const op of operations) {
73388
+ await this.updateMemoryInternal(db2, op.operation, op.name, op.content, op.metadata);
73389
+ }
73390
+ });
73391
+ }
73392
+ async close(skipSave = false) {
73393
+ const db2 = this.db;
73394
+ if (db2) {
73395
+ try {
73396
+ if (!skipSave) {
73397
+ await this.saveDatabase();
73398
+ }
73399
+ } finally {
73400
+ if (this.db === db2) {
73401
+ db2.close();
73402
+ this.db = null;
73403
+ }
73404
+ }
73405
+ }
73406
+ this.dbPromise = null;
73407
+ }
73408
+ async getStats() {
73409
+ const db2 = await this.getDatabase();
73410
+ const results = db2.exec("SELECT COUNT(*) as count FROM memory_entries");
73411
+ const totalEntries = results[0]?.values[0]?.[0] || 0;
73412
+ const typeResults = db2.exec("SELECT entry_type, COUNT(*) as count FROM memory_entries GROUP BY entry_type");
73413
+ const entriesByType = {};
73414
+ if (typeResults.length > 0) {
73415
+ for (const row of typeResults[0].values) {
73416
+ entriesByType[row[0]] = row[1];
73417
+ }
73418
+ }
73419
+ const dbPath = this.resolvePath(this.getDbPath());
73420
+ let databaseSize = 0;
73421
+ try {
73422
+ const stats = await import("node:fs/promises").then((fs4) => fs4.stat(dbPath));
73423
+ databaseSize = stats.size;
73424
+ } catch {}
73425
+ return {
73426
+ totalEntries,
73427
+ entriesByType,
73428
+ databaseSize
73429
+ };
73430
+ }
73431
+ }
73432
+ // ../cli-shared/src/utils/parameterSimplifier.ts
73433
+ function createSimplifier(keepFields) {
73434
+ return (params) => {
73435
+ const result = {};
73436
+ for (const field of keepFields) {
73437
+ if (params[field] !== undefined) {
73438
+ result[field] = params[field];
73439
+ }
73440
+ }
73441
+ return result;
73442
+ };
73443
+ }
73444
+ function createCustomSimplifier(transform2) {
73445
+ return transform2;
73446
+ }
73447
+ var SIMPLIFIERS = {
73448
+ replaceInFile: createSimplifier(["path"]),
73449
+ writeToFile: createSimplifier(["path"]),
73450
+ readFile: createSimplifier(["path", "includeIgnored"]),
73451
+ executeCommand: createSimplifier(["command", "requiresApproval"]),
73452
+ updateMemory: createSimplifier(["operation", "topic"]),
73453
+ searchFiles: createCustomSimplifier((params) => ({ ...params })),
73454
+ listFiles: createCustomSimplifier((params) => {
73455
+ const DEFAULT_MAX_COUNT = 2000;
73456
+ const maxCount = params.maxCount;
73457
+ return {
73458
+ path: params.path,
73459
+ recursive: params.recursive,
73460
+ ...maxCount !== DEFAULT_MAX_COUNT && { maxCount }
73461
+ };
73462
+ })
73463
+ };
73464
+
71227
73465
  // ../cli-shared/src/utils/eventHandler.ts
71228
73466
  var taskToolCallStats = new Map;
71229
73467
  var globalToolCallStats = new Map;