WebOrbiton

Code

AtheraStudio Code

A local web page editor for HTML, CSS, JavaScript and PHP.

Version history

Version 1.3.2 2026-10-10

Browse files
Files changed24
Lines added+3856
Lines removed-83
assets/app/app.css Modified

Not shown (binary file or too large to diff).

assets/app/app.js Modified

Not shown (binary file or too large to diff).

assets/app/backup.js Added +189 -0
+ (function () {
+   "use strict";
+ 
+   var A = window.Athera;
+   var util = A.util;
+   var fs = A.fs;
+ 
+   var DIR = ".backups";
+   var MAX_SIZE = 0xffffffff;
+   var MAX_ENTRIES = 0xffff;
+ 
+   var crcTable = (function () {
+     var table = new Uint32Array(256);
+     for (var n = 0; n < 256; n++) {
+       var c = n;
+       for (var k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
+       table[n] = c >>> 0;
+     }
+     return table;
+   })();
+ 
+   function crc32(bytes) {
+     var c = 0xffffffff;
+     for (var i = 0; i < bytes.length; i++) c = crcTable[(c ^ bytes[i]) & 255] ^ (c >>> 8);
+     return (c ^ 0xffffffff) >>> 0;
+   }
+ 
+   function two(n) {
+     return n < 10 ? "0" + n : String(n);
+   }
+ 
+   function stamp(d) {
+     return d.getFullYear() + "-" + two(d.getMonth() + 1) + "-" + two(d.getDate()) + "-" +
+       two(d.getHours()) + "-" + two(d.getMinutes()) + "-" + two(d.getSeconds());
+   }
+ 
+   function dosStamp(ms) {
+     var d = new Date(ms);
+     var year = Math.min(2107, Math.max(1980, d.getFullYear()));
+     return {
+       time: (d.getHours() << 11) | (d.getMinutes() << 5) | (d.getSeconds() >> 1),
+       date: ((year - 1980) << 9) | ((d.getMonth() + 1) << 5) | d.getDate()
+     };
+   }
+ 
+   function tooLarge() {
+     return new Error(A.t("backup.too_large"));
+   }
+ 
+   async function deflate(bytes) {
+     if (typeof CompressionStream !== "function") return null;
+     try {
+       var stream = new Blob([bytes]).stream().pipeThrough(new CompressionStream("deflate-raw"));
+       return new Uint8Array(await new Response(stream).arrayBuffer());
+     } catch (e) {
+       return null;
+     }
+   }
+ 
+   async function walk(provider, dir, out) {
+     var count = 0;
+     for (var e of await provider.list(dir)) {
+       var path = util.join(dir, e.name);
+       if (e.kind === "dir") {
+         if (fs.HIDDEN_DIRS.indexOf(e.name) >= 0) continue;
+         count++;
+         await walk(provider, path, out);
+       } else if (fs.HIDDEN_FILES.indexOf(e.name) < 0) {
+         count++;
+         out.push({ path: path, dir: false });
+       }
+     }
+     if (!count && dir) out.push({ path: dir, dir: true });
+   }
+ 
+   function localHeader(name, method, time, crc, packed, size) {
+     var bytes = new Uint8Array(30);
+     var v = new DataView(bytes.buffer);
+     v.setUint32(0, 0x04034b50, true);
+     v.setUint16(4, 20, true);
+     v.setUint16(6, 0x0800, true);
+     v.setUint16(8, method, true);
+     v.setUint16(10, time.time, true);
+     v.setUint16(12, time.date, true);
+     v.setUint32(14, crc, true);
+     v.setUint32(18, packed, true);
+     v.setUint32(22, size, true);
+     v.setUint16(26, name.length, true);
+     return bytes;
+   }
+ 
+   function centralHeader(name, method, time, crc, packed, size, isDir, offset) {
+     var bytes = new Uint8Array(46);
+     var v = new DataView(bytes.buffer);
+     v.setUint32(0, 0x02014b50, true);
+     v.setUint16(4, 20, true);
+     v.setUint16(6, 20, true);
+     v.setUint16(8, 0x0800, true);
+     v.setUint16(10, method, true);
+     v.setUint16(12, time.time, true);
+     v.setUint16(14, time.date, true);
+     v.setUint32(16, crc, true);
+     v.setUint32(20, packed, true);
+     v.setUint32(24, size, true);
+     v.setUint16(28, name.length, true);
+     v.setUint32(38, isDir ? 0x10 : 0, true);
+     v.setUint32(42, offset, true);
+     return bytes;
+   }
+ 
+   function endRecord(count, size, offset) {
+     var bytes = new Uint8Array(22);
+     var v = new DataView(bytes.buffer);
+     v.setUint32(0, 0x06054b50, true);
+     v.setUint16(8, count, true);
+     v.setUint16(10, count, true);
+     v.setUint32(12, size, true);
+     v.setUint32(16, offset, true);
+     return bytes;
+   }
+ 
+   async function build(provider) {
+     var items = [];
+     await walk(provider, "", items);
+     if (items.length > MAX_ENTRIES) throw tooLarge();
+ 
+     var encoder = new TextEncoder();
+     var parts = [], central = [], centralSize = 0, offset = 0;
+ 
+     for (var item of items) {
+       var name = encoder.encode(item.dir ? item.path + "/" : item.path);
+       var raw = new Uint8Array(0), modified = Date.now();
+       if (!item.dir) {
+         var file = await provider.readFile(item.path);
+         raw = new Uint8Array(await file.arrayBuffer());
+         modified = file.lastModified || modified;
+       }
+       if (raw.length > MAX_SIZE) throw tooLarge();
+ 
+       var data = raw, method = 0;
+       if (raw.length) {
+         var packed = await deflate(raw);
+         if (packed && packed.length < raw.length) { data = packed; method = 8; }
+       }
+ 
+       var crc = raw.length ? crc32(raw) : 0;
+       var time = dosStamp(modified);
+       var local = localHeader(name, method, time, crc, data.length, raw.length);
+       var entry = centralHeader(name, method, time, crc, data.length, raw.length, item.dir, offset);
+ 
+       parts.push(local, name, data);
+       central.push(entry, name);
+       centralSize += entry.length + name.length;
+       offset += local.length + name.length + data.length;
+       if (offset > MAX_SIZE) throw tooLarge();
+     }
+ 
+     parts.push.apply(parts, central);
+     parts.push(endRecord(items.length, centralSize, offset));
+     return new Blob(parts, { type: "application/zip" });
+   }
+ 
+   var busy = false;
+ 
+   async function run() {
+     var provider = fs.provider;
+     if (!provider) return A.ui.toast(A.t("app.open_folder_first"), "info");
+     if (busy) return;
+     busy = true;
+     try {
+       A.ui.toast(A.t("backup.started"), "info");
+       var name = stamp(new Date()) + ".zip";
+       var blob = await build(provider);
+       if (provider.kind === "disk") {
+         var path = util.join(DIR, name);
+         await provider.write(path, blob);
+         A.ui.toast(A.t("backup.done", { path: path }), "success");
+       } else {
+         fs.download(name, blob, "application/zip");
+         A.ui.toast(A.t("backup.downloaded", { name: name }), "success");
+       }
+     } finally {
+       busy = false;
+     }
+   }
+ 
+   A.backup = { run: run, build: build, stamp: stamp, DIR: DIR };
+ })();
+ 
assets/app/core.js Modified +5 -0
⋮ 143 unchanged lines ⋮
      warning: '<path d="M12 3l10 18H2z"/><path d="M12 10v5M12 18h.01"/>',
      settings: '<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z"/>',
      type: '<path d="M4 7V5h16v2M9 19h6M12 5v14"/>',
+     search: '<circle cx="11" cy="11" r="7"/><path d="M20 20l-3.5-3.5"/>',
+     replace: '<path d="M4 8h13l-3-3M20 16H7l3 3"/>',
+     undo: '<path d="M9 14L4 9l5-5"/><path d="M4 9h10a6 6 0 0 1 0 12h-3"/>',
+     rss: '<path d="M5 11a8 8 0 0 1 8 8M5 4a15 15 0 0 1 15 15"/><circle cx="6" cy="18" r="1.3"/>',
+     sitemap: '<rect x="9" y="3" width="6" height="5" rx="1"/><rect x="2" y="16" width="6" height="5" rx="1"/><rect x="9" y="16" width="6" height="5" rx="1"/><rect x="16" y="16" width="6" height="5" rx="1"/><path d="M12 8v4M5 16v-4h14v4"/>',
      wand: '<path d="M15 4V2M15 16v-2M8 9h2M20 9h2M17.8 11.8l1.4 1.4M17.8 6.2l1.4-1.4M12.2 6.2l-1.4-1.4"/><path d="M15 9l-12 12"/>'
    };
    A.icon = function (name, cls) {
⋮ 167 unchanged lines ⋮
assets/app/desktop.js Added +59 -0
+ (function () {
+   "use strict";
+ 
+   var desktop = window.atheraDesktop;
+   var A = window.Athera;
+   if (!desktop || !desktop.isDesktop || !A) return;
+ 
+   function baseName(p) {
+     return String(p).split(/[\\/]/).pop();
+   }
+ 
+   function makeHandle(filePath) {
+     var name = baseName(filePath);
+     return {
+       kind: "file",
+       name: name,
+       _path: filePath,
+       getFile: async function () {
+         var r = await desktop.readFile(filePath);
+         return new File([r.data], name, { lastModified: r.mtime || Date.now() });
+       },
+       createWritable: async function () {
+         var chunks = [];
+         return {
+           write: async function (d) { chunks.push(d); },
+           close: async function () {
+             var buf = new Uint8Array(await new Blob(chunks).arrayBuffer());
+             await desktop.writeFile(filePath, buf);
+           },
+           abort: async function () { chunks = []; }
+         };
+       },
+       isSameEntry: async function (other) { return !!other && other._path === filePath; },
+       queryPermission: async function () { return "granted"; },
+       requestPermission: async function () { return "granted"; }
+     };
+   }
+ 
+   async function openFromSystem(filePath) {
+     try {
+       for (var t of A.tabs.list) {
+         if (t.handle && t.handle._path === filePath) return A.tabs.activate(t);
+       }
+       var handle = makeHandle(filePath);
+       var file = await handle.getFile();
+       var tab = await A.tabs.openFile({ name: handle.name, handle: null, file: file });
+       if (tab && tab.kind) A.tabs.retarget(tab, tab.name, undefined, handle);
+     } catch (e) {
+       console.error(e);
+       A.ui.toast(String((e && e.message) || e), "danger");
+     }
+   }
+ 
+   var chain = Promise.resolve();
+   desktop.onOpenFile(function (filePath) {
+     chain = chain.then(function () { return openFromSystem(filePath); });
+   });
+ })();
+ 
assets/app/editor.js Modified +11 -1
⋮ 13 unchanged lines ⋮
      ts: { label: "TypeScript", make: function () { return CM.javascript({ typescript: true }); } },
      tsx: { label: "TypeScript JSX", make: function () { return CM.javascript({ typescript: true, jsx: true }); } },
      json: { label: "JSON", make: function () { return [CM.json(), CM.linter(CM.jsonParseLinter())]; } },
+     jsonc: { label: "JSON with Comments", make: function () { return CM.javascript(); } },
      md: { label: "Markdown", make: function () { return CM.markdown(); } },
      svg: { label: "SVG", make: function () { return CM.html(); } },
      text: { label: null, make: function () { return []; } }
⋮ 3 unchanged lines ⋮
      php: "php", phtml: "php",
      css: "css", scss: "css", less: "css",
      js: "js", mjs: "js", cjs: "js", jsx: "jsx", ts: "ts", mts: "ts", tsx: "tsx",
-     json: "json", webmanifest: "json",
+     json: "json", jsonc: "jsonc", webmanifest: "json",
      md: "md", markdown: "md"
    };
  
⋮ 229 unchanged lines ⋮
        var l = doc.line(Math.max(1, Math.min(doc.lines, line)));
        var pos = Math.min(l.from + Math.max(0, (col || 1) - 1), l.to);
        view.dispatch({ selection: { anchor: pos }, effects: CM.EditorView.scrollIntoView(pos, { y: "center" }) });
+       view.focus();
+     },
+ 
+     select: function (line, col, length) {
+       var view = editor.view, doc = view.state.doc;
+       var l = doc.line(Math.max(1, Math.min(doc.lines, line)));
+       var from = Math.min(l.from + Math.max(0, (col || 1) - 1), l.to);
+       var to = Math.min(from + (length || 0), doc.length);
+       view.dispatch({ selection: { anchor: from, head: to }, effects: CM.EditorView.scrollIntoView(from, { y: "center" }) });
        view.focus();
      },
  
⋮ 43 unchanged lines ⋮
assets/app/explorer.js Modified +118 -21
⋮ 18 unchanged lines ⋮
    var hover = { path: null, timer: 0 };
    var multi = new Set();
    var anchorPath = null;
+   var nodes = new Map();
+   var enter = new Map();
+   var enterUntil = 0;
  
    var ex = (A.explorer = {
      el: null,
⋮ 13 unchanged lines ⋮
        el.appendChild(message);
        el.addEventListener("scroll", queuePaint, { passive: true });
        window.addEventListener("resize", queuePaint);
+       win.addEventListener("animationend", onAnimEnd);
        el.addEventListener("click", onClick);
        el.addEventListener("contextmenu", onContext);
        el.addEventListener("keydown", onKey);
⋮ 12 unchanged lines ⋮
          ex.cache.clear();
          ex.expanded.clear();
          loading.clear();
+         clearNodes();
          setSel(null);
          focusPath = null;
          el.scrollTop = 0;
⋮ 3 unchanged lines ⋮
          if (tab && tab.path != null && fs.provider) ex.reveal(tab.path);
          else paint();
        });
-       A.on("lang", function () { if (fs.provider) ex.render(); });
+       A.on("lang", function () { clearNodes(); if (fs.provider) ex.render(); });
      },
  
      load: async function (dir) {
⋮ 278 unchanged lines ⋮
  
    async function draw() {
      if (!fs.provider) {
-       rows = [];
+       setRows([]);
        showMessage("");
        paint();
        return;
⋮ 3 unchanged lines ⋮
        var missing = visibleExpanded();
        if (!missing.length) break;
        missing.forEach(function (d) { loading.add(d); });
-       rows = flatten();
+       setRows(flatten());
        paint();
        var results = await Promise.all(missing.map(function (d) {
          return ex.load(d).then(function () { return null; }, function (e) { return { dir: d, error: e }; });
⋮ 7 unchanged lines ⋮
          else ex.expanded.delete(r.dir);
        });
        if (rootError) {
-         rows = [];
+         setRows([]);
          showMessage(A.t("explorer.read_error", { error: rootError.message }), true);
          paint();
          return;
        }
      }
-     rows = flatten();
+     setRows(flatten());
      showMessage(rows.length ? "" : A.t("explorer.empty"));
      paint();
    }
⋮ 18 unchanged lines ⋮
      });
    }
  
-   function rowHtml(r, active) {
+   function onAnimEnd(e) {
+     var t = e.target;
+     if (e.animationName === "ath-row-in") {
+       t.classList.remove("is-entering");
+       t.style.removeProperty("--i");
+     } else if (e.animationName === "ath-ficon-pop") {
+       t.classList.remove("is-toggled");
+     }
+   }
+ 
+   function setRows(next) {
+     var prev = new Set(rows.map(function (r) { return r.path; }));
+     var fresh = new Map(), n = 0;
+     next.forEach(function (r) {
+       if (!prev.has(r.path)) fresh.set(r.path, Math.min(n++, 14));
+     });
+     enter = fresh;
+     enterUntil = performance.now() + 600;
+     rows = next;
+   }
+ 
+   function clearNodes() {
+     nodes.forEach(function (n) { n.remove(); });
+     nodes.clear();
+     enter = new Map();
+   }
+ 
+   function buildRow(r) {
+     var node = document.createElement("div");
+     node.className = "ath-tree-row";
+     node.setAttribute("role", "treeitem");
+     node.setAttribute("tabindex", "-1");
+     node.setAttribute("draggable", "true");
+     node.setAttribute("data-path", r.path);
+     node.setAttribute("data-kind", r.kind);
+     node.style.setProperty("--depth", r.depth);
      if (r.kind === "loading") {
-       return '<div class="ath-tree-row is-loading" style="--depth:' + r.depth + '"><span class="ath-tree-chevron"></span>' +
-         '<span class="ath-spinner ath-spinner-sm"></span><span class="ath-tree-name">' + util.esc(A.t("palette.loading").replace(/…$/, "")) + "…</span></div>";
+       node.classList.add("is-loading");
+       node.innerHTML = '<span class="ath-tree-chevron"></span><span class="ath-spinner ath-spinner-sm"></span>' +
+         '<span class="ath-tree-name">' + util.esc(A.t("palette.loading").replace(/…$/, "")) + "…</span>";
+       return node;
      }
-     var cls = "ath-tree-row" + (r.kind === "dir" ? " is-dir" : "") + (r.open ? " is-open" : "") +
-       (r.path === active ? " is-active" : "") + (multi.has(r.path) ? " is-selected" : "") + (multi.size > 1 && multi.has(r.path) ? " is-multi" : "") +
-       (drag && dragItems(drag).some(function (it) { return it.path === r.path; }) ? " is-dragging" : "") + (dropPath === r.path ? " is-drop-target" : "");
-     var icon = r.kind === "dir"
-       ? '<span class="ath-tree-chevron">' + A.icon("chevron") + '</span><span class="ath-ficon ath-ficon-dir">' + A.icon(r.open ? "folderOpen" : "folder") + "</span>"
-       : '<span class="ath-tree-chevron"></span>' + A.fileBadge(r.name);
-     return '<div class="' + cls + '" role="treeitem" tabindex="-1" draggable="true"' +
-       (r.kind === "dir" ? ' aria-expanded="' + r.open + '"' : "") +
-       ' data-path="' + util.esc(r.path) + '" data-kind="' + r.kind + '" title="' + util.esc(r.path) + '" style="--depth:' + r.depth + '">' +
-       icon + '<span class="ath-tree-name">' + util.esc(r.name) + "</span></div>";
+     node.title = r.path;
+     if (r.kind === "dir") {
+       node.classList.add("is-dir");
+       node.innerHTML = '<span class="ath-tree-chevron">' + A.icon("chevron") + '</span><span class="ath-ficon ath-ficon-dir">' +
+         A.icon(r.open ? "folderOpen" : "folder") + "</span>" +
+         '<span class="ath-tree-name">' + util.esc(r.name) + "</span>";
+       node.setAttribute("aria-expanded", String(!!r.open));
+       node._open = !!r.open;
+     } else {
+       node.innerHTML = '<span class="ath-tree-chevron"></span>' + A.fileBadge(r.name) +
+         '<span class="ath-tree-name">' + util.esc(r.name) + "</span>";
+     }
+     return node;
    }
  
+   function syncRow(node, r, active) {
+     if (r.kind === "loading") return;
+     var c = node.classList;
+     var dragging = !!drag && dragItems(drag).some(function (it) { return it.path === r.path; });
+     var sel = multi.has(r.path);
+     c.toggle("is-open", !!r.open);
+     c.toggle("is-active", r.path === active);
+     c.toggle("is-selected", sel);
+     c.toggle("is-multi", multi.size > 1 && sel);
+     c.toggle("is-dragging", dragging);
+     c.toggle("is-drop-target", dropPath === r.path);
+     if (r.kind === "dir" && node._open !== !!r.open) {
+       node._open = !!r.open;
+       node.setAttribute("aria-expanded", String(!!r.open));
+       var icon = node.querySelector(".ath-ficon-dir");
+       if (icon) {
+         icon.innerHTML = A.icon(r.open ? "folderOpen" : "folder");
+         icon.classList.remove("is-toggled");
+         void icon.offsetWidth;
+         icon.classList.add("is-toggled");
+       }
+     }
+   }
+ 
    function paint() {
      if (!win) return;
      var el = ex.el;
⋮ 3 unchanged lines ⋮
      var end = Math.min(rows.length, Math.ceil((el.scrollTop + height) / ROW_H) + OVERSCAN);
      var hadFocus = el.contains(document.activeElement) && document.activeElement !== el;
      var active = A.tabs.active && A.tabs.active.path;
-     var html = "";
-     for (var i = start; i < end; i++) html += rowHtml(rows[i], active);
+     var animate = performance.now() < enterUntil;
+     var seen = new Set(), prevNode = null;
+     for (var i = start; i < end; i++) {
+       var r = rows[i];
+       var node = nodes.get(r.path);
+       if (node && node.getAttribute("data-kind") !== r.kind) {
+         node.remove();
+         nodes.delete(r.path);
+         node = null;
+       }
+       if (!node) {
+         node = buildRow(r);
+         nodes.set(r.path, node);
+         if (animate && enter.has(r.path)) {
+           node.style.setProperty("--i", enter.get(r.path));
+           node.classList.add("is-entering");
+           enter.delete(r.path);
+         }
+       }
+       syncRow(node, r, active);
+       seen.add(r.path);
+       var ref = prevNode ? prevNode.nextSibling : win.firstChild;
+       if (node !== ref) win.insertBefore(node, ref);
+       prevNode = node;
+     }
+     nodes.forEach(function (n, path) {
+       if (!seen.has(path)) {
+         n.remove();
+         nodes.delete(path);
+       }
+     });
      win.style.transform = "translateY(" + start * ROW_H + "px)";
-     win.innerHTML = html;
      if (hadFocus && focusPath) {
        var row = ex.rowOf(focusPath);
        if (row) row.focus({ preventScroll: true });
⋮ 308 unchanged lines ⋮
assets/app/fs.js Modified +1 -1
⋮ 17 unchanged lines ⋮
    function notFound(path) { return new Error(A.t("fs.not_found", { path: path })); }
  
    var collator = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" });
-   var HIDDEN_DIRS = [".git", "node_modules"];
+   var HIDDEN_DIRS = [".git", "node_modules", ".backups"];
    var HIDDEN_FILES = [".DS_Store", "Thumbs.db"];
  
    function sortEntries(list) {
⋮ 399 unchanged lines ⋮
assets/app/intellisense.js Modified +21 -11
⋮ 231 unchanged lines ⋮
          if (info.name === "html") htmlEl = info;
          if (info.name === "head") headEl = info;
          if (info.name === "img" && !("alt" in info.attrs)) {
-           out.push({ from: tagFrom, to: tagTo, severity: "warning", source: "html", message: t("lint.img_alt"),
-             actions: [insertAction(t("lint.fix_alt"), info.nameTo, ' alt=""')] });
+           out.push({
+             from: tagFrom, to: tagTo, severity: "warning", source: "html", message: t("lint.img_alt"),
+             actions: [insertAction(t("lint.fix_alt"), info.nameTo, ' alt=""')]
+           });
          }
          if (info.name === "a" && info.attrs.target === "_blank" && !/noopener|noreferrer/.test(info.attrs.rel || "")) {
-           out.push({ from: tagFrom, to: tagTo, severity: "info", source: "html", message: t("lint.blank_rel"),
-             actions: [insertAction(t("lint.fix_rel"), info.nameTo, ' rel="noopener"')] });
+           out.push({
+             from: tagFrom, to: tagTo, severity: "info", source: "html", message: t("lint.blank_rel"),
+             actions: [insertAction(t("lint.fix_rel"), info.nameTo, ' rel="noopener"')]
+           });
          }
          if (DEPRECATED.indexOf(info.name) >= 0) {
            out.push({ from: tagFrom, to: tagTo, severity: "warning", source: "html", message: t("lint.deprecated", { tag: info.name }) });
⋮ 11 unchanged lines ⋮
      });
      if (htmlEl) {
        if (!hasDoctype && strictClose) {
-         out.push({ from: htmlEl.open.from, to: htmlEl.open.to, severity: "info", source: "html", message: t("lint.doctype"),
-           actions: [insertAction(t("lint.fix_add"), htmlEl.open.from, "<!DOCTYPE html>\n")] });
+         out.push({
+           from: htmlEl.open.from, to: htmlEl.open.to, severity: "info", source: "html", message: t("lint.doctype"),
+           actions: [insertAction(t("lint.fix_add"), htmlEl.open.from, "<!DOCTYPE html>\n")]
+         });
        }
        if (!("lang" in htmlEl.attrs)) {
          var code = (A.i18n.current() || {}).code || "en";
-         out.push({ from: htmlEl.open.from, to: htmlEl.open.to, severity: "warning", source: "html", message: t("lint.lang"),
-           actions: [insertAction(t("lint.fix_add"), htmlEl.nameTo, ' lang="' + code + '"')] });
+         out.push({
+           from: htmlEl.open.from, to: htmlEl.open.to, severity: "warning", source: "html", message: t("lint.lang"),
+           actions: [insertAction(t("lint.fix_add"), htmlEl.nameTo, ' lang="' + code + '"')]
+         });
        }
      }
      if (headEl) {
⋮ 6 unchanged lines ⋮
        ];
        checks.forEach(function (c) {
          if (c[0].test(head)) return;
-         out.push({ from: headEl.open.from, to: headEl.open.to, severity: "warning", source: "html", message: t(c[1]),
-           actions: [insertAction(t("lint.fix_add"), at, pad + c[2])] });
+         out.push({
+           from: headEl.open.from, to: headEl.open.to, severity: "warning", source: "html", message: t(c[1]),
+           actions: [insertAction(t("lint.fix_add"), at, pad + c[2])]
+         });
        });
      }
      return out;
⋮ 161 unchanged lines ⋮
    var PARSERS = {
      html: "html", htm: "html", xhtml: "html", vue: "vue", css: "css", scss: "scss", less: "less",
      js: "babel", mjs: "babel", cjs: "babel", jsx: "babel", ts: "babel-ts", mts: "babel-ts", tsx: "babel-ts",
-     json: "json", webmanifest: "json", md: "markdown", markdown: "markdown", php: "php", phtml: "php"
+     json: "json", jsonc: "json", webmanifest: "json", md: "markdown", markdown: "markdown", php: "php", phtml: "php"
    };
  
    A.intellisense = {
⋮ 58 unchanged lines ⋮
assets/app/lang-builtin.js Modified +20 -6
  (window.Athera = window.Athera || {}).langBuiltin = {"polski.xml":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<language code=\"pl\" name=\"Polski\" author=\"WebOrbiton\" version=\"1.0.0\">\n  <string key=\"app.description\">AtheraStudio Code: lokalny edytor stron internetowych (HTML, CSS, JS, PHP) by WebOrbiton.</string>\n  <string key=\"app.folder_opened\">Otwarto folder „{name}”.</string>\n  <string key=\"app.no_permission\">Brak zgody na dostęp do folderu.</string>\n  <string key=\"app.reopen_failed\">Nie można ponownie otworzyć folderu (mógł zostać przeniesiony lub usunięty).</string>\n  <string key=\"app.new_file_label\">Nazwa pliku (rozszerzenie wybiera język: .html, .css, .js, .php…)</string>\n  <string key=\"app.open_folder_first\">Najpierw otwórz folder.</string>\n  <string key=\"app.saved_as\">Zapisano jako „{name}”.</string>\n  <string key=\"app.downloaded\">Pobrano plik „{name}”.</string>\n  <string key=\"app.wrap_on\">Zawijanie wierszy: wł�
  czone</string>\n  <string key=\"app.wrap_off\">Zawijanie wierszy: wył�
- czone</string>\n\n  <string key=\"common.close\">Zamknij</string>\n  <string key=\"common.cancel\">Anuluj</string>\n  <string key=\"common.ok\">OK</string>\n  <string key=\"common.create\">Utwórz</string>\n  <string key=\"common.rename\">Zmień</string>\n  <string key=\"common.delete\">Usuń</string>\n  <string key=\"common.save\">Zapisz</string>\n\n  <string key=\"menu.main\">Menu główne</string>\n  <string key=\"menu.file\">Plik</string>\n  <string key=\"menu.view\">Widok</string>\n  <string key=\"menu.help\">Pomoc</string>\n  <string key=\"menu.open_folder\">Otwórz folder…</string>\n  <string key=\"menu.open_file\">Otwórz plik…</string>\n  <string key=\"menu.new_file\">Nowy plik</string>\n  <string key=\"menu.new_folder\">Nowy folder</string>\n  <string key=\"menu.save\">Zapisz</string>\n  <string key=\"menu.save_all\">Zapisz wszystko</string>\n  <string key=\"menu.save_as\">Zapisz jako…</string>\n  <string key=\"menu.close_tab\">Zamknij kartę</string>\n  <string key=\"menu.close_folder\">Zamknij folder</string>\n  <string key=\"menu.sidebar\">Pasek boczny</string>\n  <string key=\"menu.preview\">Podgl�
+ czone</string>\n\n  <string key=\"common.close\">Zamknij</string>\n  <string key=\"common.cancel\">Anuluj</string>\n  <string key=\"common.ok\">OK</string>\n  <string key=\"common.create\">Utwórz</string>\n  <string key=\"common.rename\">Zmień</string>\n  <string key=\"common.delete\">Usuń</string>\n  <string key=\"common.save\">Zapisz</string>\n\n  <string key=\"menu.main\">Menu główne</string>\n  <string key=\"menu.file\">Plik</string>\n  <string key=\"menu.view\">Widok</string>\n  <string key=\"menu.help\">Pomoc</string>\n  <string key=\"menu.open_folder\">Otwórz folder…</string>\n  <string key=\"menu.open_file\">Otwórz plik…</string>\n  <string key=\"menu.new_file\">Nowy plik</string>\n  <string key=\"menu.new_folder\">Nowy folder</string>\n  <string key=\"menu.save\">Zapisz</string>\n  <string key=\"menu.save_all\">Zapisz wszystko</string>\n  <string key=\"menu.save_as\">Zapisz jako…</string>\n  <string key=\"menu.close_tab\">Zamknij kartę</string>\n  <string key=\"menu.backup\">Utwórz kopię zapasow�
+ </string>\n  <string key=\"menu.close_folder\">Zamknij folder</string>\n  <string key=\"menu.sidebar\">Pasek boczny</string>\n  <string key=\"menu.preview\">Podgl�
  d na żywo</string>\n  <string key=\"menu.wrap\">Zawijanie wierszy</string>\n  <string key=\"menu.search\">Szukaj i zamień</string>\n  <string key=\"menu.zoom_in\">Powiększ tekst</string>\n  <string key=\"menu.zoom_out\">Pomniejsz tekst</string>\n  <string key=\"menu.zoom_reset\">Domyślny rozmiar</string>\n  <string key=\"menu.shortcuts\">Skróty klawiszowe</string>\n  <string key=\"menu.about\">O programie</string>\n\n  <string key=\"top.preview\">Podgl�
  d na żywo (Alt+P)</string>\n  <string key=\"top.accent\">Kolor akcentu</string>\n  <string key=\"top.theme\">Jasny / ciemny motyw</string>\n\n  <string key=\"accent.blue\">Niebieski (domyślny)</string>\n  <string key=\"accent.indigo\">Indygo</string>\n  <string key=\"accent.violet\">Fiolet</string>\n  <string key=\"accent.purple\">Purpura</string>\n  <string key=\"accent.fuchsia\">Fuksja</string>\n  <string key=\"accent.pink\">Róż</string>\n  <string key=\"accent.rose\">Różany</string>\n  <string key=\"accent.red\">Czerwony</string>\n  <string key=\"accent.orange\">Pomarańczowy</string>\n  <string key=\"accent.amber\">Bursztyn</string>\n  <string key=\"accent.lime\">Limonka</string>\n  <string key=\"accent.green\">Zielony</string>\n  <string key=\"accent.emerald\">Szmaragd</string>\n  <string key=\"accent.teal\">Morski</string>\n  <string key=\"accent.cyan\">Cyjan</string>\n  <string key=\"accent.slate\">Grafit</string>\n\n  <string key=\"lang.title\">Język</string>\n  <string key=\"lang.import\">Wczytaj tłumaczenie (XML)…</string>\n  <string key=\"lang.template\">Pobierz szablon tłumaczenia</string>\n  <string key=\"lang.template_file\">moj-jezyk.xml</string>\n  <string key=\"lang.imported\">Dodano język: {name}</string>\n  <string key=\"lang.imported_tag\">wczytany</string>\n  <string key=\"lang.invalid\">Niepoprawny plik tłumaczenia: {error}</string>\n  <string key=\"lang.remove\">Usuń język „{name}”</string>\n  <string key=\"lang.remove_title\">Usuń język</string>\n  <string key=\"lang.remove_confirm\">Usun�
  ć wczytane tłumaczenie „{name}”?</string>\n\n  <string key=\"sidebar.explorer\">Eksplorator</string>\n  <string key=\"sidebar.files\">Pliki</string>\n  <string key=\"sidebar.no_folder\">Nie otwarto folderu.</string>\n  <string key=\"sidebar.drop_hint\">Możesz też przeci�
⋮ 1 unchanged line ⋮
  ć folder lub pliki do okna edytora.</string>\n\n  <string key=\"layout.resize_sidebar\">Zmień szerokość paska bocznego</string>\n  <string key=\"layout.resize_preview\">Zmień szerokość podgl�
  du</string>\n\n  <string key=\"action.open_folder\">Otwórz folder</string>\n  <string key=\"action.open_file\">Otwórz plik</string>\n  <string key=\"action.new_file\">Nowy plik</string>\n\n  <string key=\"welcome.lead\">Lokalny edytor stron internetowych: HTML, CSS, JavaScript i PHP. Twoje pliki zostaj�
   na Twoim komputerze, nic nie jest wysyłane.</string>\n  <string key=\"welcome.limited_title\">Tryb ograniczony</string>\n  <string key=\"welcome.limited_text\">Ta przegl�
- darka nie pozwala zapisywać plików bezpośrednio na dysku, więc zapis pobierze plik. Pełny tryb działa w Chrome, Edge i Operze.</string>\n  <string key=\"welcome.reopen\">Otwórz ponownie „{name}”</string>\n\n  <string key=\"shortcut.open_folder\">Otwórz folder</string>\n  <string key=\"shortcut.save\">Zapisz</string>\n  <string key=\"shortcut.save_all\">Zapisz wszystko</string>\n  <string key=\"shortcut.new_file\">Nowy plik</string>\n  <string key=\"shortcut.close_tab\">Zamknij kartę</string>\n  <string key=\"shortcut.switch_tab\">Następna / poprzednia karta</string>\n  <string key=\"shortcut.sidebar\">Pasek boczny</string>\n  <string key=\"shortcut.preview\">Podgl�
+ darka nie pozwala zapisywać plików bezpośrednio na dysku, więc zapis pobierze plik. Pełny tryb działa w Chrome, Edge i Operze.</string>\n  <string key=\"welcome.reopen\">Otwórz ponownie „{name}”</string>\n\n  <string key=\"shortcut.open_folder\">Otwórz folder</string>\n  <string key=\"shortcut.save\">Zapisz</string>\n  <string key=\"shortcut.save_all\">Zapisz wszystko</string>\n  <string key=\"shortcut.new_file\">Nowy plik</string>\n  <string key=\"shortcut.close_tab\">Zamknij kartę</string>\n  <string key=\"shortcut.switch_tab\">Następna / poprzednia karta</string>\n  <string key=\"shortcut.move_tab\">Przenieś kartę w lewo / prawo (lub przeci�
+ gnij)</string>\n  <string key=\"shortcut.sidebar\">Pasek boczny</string>\n  <string key=\"shortcut.preview\">Podgl�
  d na żywo</string>\n  <string key=\"shortcut.wrap\">Zawijanie wierszy</string>\n  <string key=\"shortcut.complete\">Podpowiedzi</string>\n  <string key=\"shortcut.search\">Szukaj i zamień</string>\n  <string key=\"shortcut.comment\">Zakomentuj linię</string>\n  <string key=\"shortcut.move_line\">Przenieś linię</string>\n  <string key=\"shortcut.copy_line\">Powiel linię</string>\n  <string key=\"shortcut.select_next\">Zaznacz następne wyst�
  pienie</string>\n  <string key=\"shortcut.multi_cursor\">Dodatkowy kursor</string>\n  <string key=\"shortcut.fold\">Zwiń / rozwiń blok</string>\n  <string key=\"shortcut.zoom\">Rozmiar tekstu</string>\n  <string key=\"shortcut.explorer\">Zmień nazwę / usuń (w eksploratorze)</string>\n  <string key=\"shortcut.drag_move\">Przenieś plik lub folder (w eksploratorze)</string>\n  <string key=\"key.drag\">Przeci�
- gnij</string>\n  <string key=\"key.space\">Spacja</string>\n  <string key=\"key.click\">klik</string>\n\n  <string key=\"tabs.aria\">Otwarte pliki</string>\n  <string key=\"tabs.binary\">„{name}” to plik binarny, nie da się go edytować jako tekst.</string>\n  <string key=\"tabs.open_failed\">Nie udało się otworzyć „{name}”: {error}</string>\n  <string key=\"tabs.memory_saved\">Tryb ograniczony: „{name}” pobrano jako plik.</string>\n  <string key=\"tabs.save_failed\">Nie zapisano „{name}”: {error}</string>\n  <plural key=\"tabs.saved_count\">\n    <one>Zapisano {n} plik</one>\n    <few>Zapisano {n} pliki</few>\n    <many>Zapisano {n} plików</many>\n    <other>Zapisano {n} pliku</other>\n  </plural>\n  <string key=\"tabs.unsaved_title\">Niezapisane zmiany</string>\n  <string key=\"tabs.unsaved_text\">Plik „{name}” ma niezapisane zmiany. Zapisać je przed zamknięciem?</string>\n  <string key=\"tabs.dont_save\">Nie zapisuj</string>\n  <string key=\"tabs.not_on_disk\">(niezapisany na dysku)</string>\n  <string key=\"tabs.close_named\">Zamknij {name}</string>\n  <string key=\"tabs.close\">Zamknij</string>\n  <string key=\"tabs.close_others\">Zamknij pozostałe</string>\n  <string key=\"tabs.close_all\">Zamknij wszystkie</string>\n\n  <string key=\"explorer.read_error\">Nie można odczytać folderu: {error}</string>\n  <string key=\"explorer.empty\">Folder jest pusty. Utwórz pierwszy plik przyciskiem „+” powyżej.</string>\n  <string key=\"explorer.new_file\">Nowy plik</string>\n  <string key=\"explorer.new_file_label\">Nazwa pliku (można podać podfolder, np. css/style.css)</string>\n  <string key=\"explorer.new_file_label_in\">Nazwa pliku w „{dir}/” (można podać podfolder, np. css/style.css)</string>\n  <string key=\"explorer.new_folder\">Nowy folder</string>\n  <string key=\"explorer.new_folder_label\">Nazwa folderu</string>\n  <string key=\"explorer.new_folder_label_in\">Nazwa folderu w „{dir}/”</string>\n  <string key=\"explorer.rename_title\">Zmień nazwę</string>\n  <string key=\"explorer.rename_label\">Nowa nazwa</string>\n  <string key=\"explorer.invalid_name\">Nazwa zawiera niedozwolone znaki.</string>\n  <string key=\"explorer.rename_failed\">Nie zmieniono nazwy: {error}</string>\n  <string key=\"explorer.delete_file_confirm\">Na pewno usun�
+ gnij</string>\n  <string key=\"key.space\">Spacja</string>\n  <string key=\"key.click\">klik</string>\n\n  <string key=\"tabs.aria\">Otwarte pliki</string>\n  <string key=\"tabs.binary\">„{name}” to plik binarny, nie da się go edytować jako tekst.</string>\n  <string key=\"tabs.open_failed\">Nie udało się otworzyć „{name}”: {error}</string>\n  <string key=\"tabs.memory_saved\">Tryb ograniczony: „{name}” pobrano jako plik.</string>\n  <string key=\"tabs.save_failed\">Nie zapisano „{name}”: {error}</string>\n  <plural key=\"tabs.saved_count\">\n    <one>Zapisano {n} plik</one>\n    <few>Zapisano {n} pliki</few>\n    <many>Zapisano {n} plików</many>\n    <other>Zapisano {n} pliku</other>\n  </plural>\n  <string key=\"tabs.unsaved_title\">Niezapisane zmiany</string>\n  <string key=\"tabs.unsaved_text\">Plik „{name}” ma niezapisane zmiany. Zapisać je przed zamknięciem?</string>\n  <string key=\"tabs.dont_save\">Nie zapisuj</string>\n  <string key=\"tabs.not_on_disk\">(niezapisany na dysku)</string>\n  <string key=\"tabs.close_named\">Zamknij {name}</string>\n  <string key=\"tabs.close\">Zamknij</string>\n  <string key=\"tabs.close_others\">Zamknij pozostałe</string>\n  <string key=\"tabs.close_all\">Zamknij wszystkie</string>\n  <string key=\"tabs.move_left\">Przenieś w lewo</string>\n  <string key=\"tabs.move_right\">Przenieś w prawo</string>\n\n  <string key=\"explorer.read_error\">Nie można odczytać folderu: {error}</string>\n  <string key=\"explorer.empty\">Folder jest pusty. Utwórz pierwszy plik przyciskiem „+” powyżej.</string>\n  <string key=\"explorer.new_file\">Nowy plik</string>\n  <string key=\"explorer.new_file_label\">Nazwa pliku (można podać podfolder, np. css/style.css)</string>\n  <string key=\"explorer.new_file_label_in\">Nazwa pliku w „{dir}/” (można podać podfolder, np. css/style.css)</string>\n  <string key=\"explorer.new_folder\">Nowy folder</string>\n  <string key=\"explorer.new_folder_label\">Nazwa folderu</string>\n  <string key=\"explorer.new_folder_label_in\">Nazwa folderu w „{dir}/”</string>\n  <string key=\"explorer.rename_title\">Zmień nazwę</string>\n  <string key=\"explorer.rename_label\">Nowa nazwa</string>\n  <string key=\"explorer.invalid_name\">Nazwa zawiera niedozwolone znaki.</string>\n  <string key=\"explorer.rename_failed\">Nie zmieniono nazwy: {error}</string>\n  <string key=\"explorer.delete_file_confirm\">Na pewno usun�
  ć plik „{path}”? Tej operacji nie da się cofn�
  ć.</string>\n  <string key=\"explorer.delete_folder_confirm\">Na pewno usun�
  ć folder „{path}” razem z zawartości�
⋮ 33 unchanged lines ⋮
  cy {tag} nie pasuje do otwartego elementu</string>\n  <string key=\"lint.unclosed\">Znacznik &lt;{tag}&gt; nie jest zamknięty</string>\n  <string key=\"lint.img_alt\">Obraz nie ma atrybutu alt (ważne dla dostępności i SEO)</string>\n  <string key=\"lint.fix_alt\">Dodaj alt</string>\n  <string key=\"lint.blank_rel\">Link otwierany w nowej karcie powinien mieć rel=\"noopener\"</string>\n  <string key=\"lint.fix_rel\">Dodaj rel</string>\n  <string key=\"lint.deprecated\">Znacznik &lt;{tag}&gt; jest przestarzały, użyj CSS</string>\n  <string key=\"lint.duplicate_id\">Identyfikator „{id}” występuje więcej niż raz</string>\n  <string key=\"lint.doctype\">Brak deklaracji &lt;!DOCTYPE html&gt;</string>\n  <string key=\"lint.lang\">Element &lt;html&gt; nie ma atrybutu lang</string>\n  <string key=\"lint.charset\">Brak &lt;meta charset&gt; (polskie znaki mog�
   się źle wyświetlać)</string>\n  <string key=\"lint.viewport\">Brak meta viewport (strona nie dopasuje się do telefonu)</string>\n  <string key=\"lint.title\">Brak znacznika &lt;title&gt;</string>\n  <string key=\"lint.fix_add\">Dodaj</string>\n  <string key=\"settings.emmet\">Emmet</string>\n  <string key=\"settings.emmet_hint\">Skróty typu ! albo ul&gt;li*3 rozwijane klawiszem Tab, automatyczna zmiana nazwy pary tagów.</string>\n  <string key=\"settings.smart_suggest\">Inteligentne podpowiedzi bloków</string>\n  <string key=\"settings.smart_suggest_hint\">Po Enterze w pustym &lt;head&gt;, &lt;body&gt;, liście lub formularzu sama otwiera się lista gotowych układów.</string>\n  <string key=\"settings.lint_hints\">Wykrywanie problemów</string>\n  <string key=\"settings.lint_hints_hint\">Błędy składni i wskazówki HTML (alt, lang, viewport, niezamknięte tagi) z przyciskiem „Dodaj”.</string>\n  <string key=\"settings.format_on_save\">Formatuj przy zapisie</string>\n  <string key=\"settings.format_on_save_hint\">Przed zapisem kod jest porz�
  dkowany przez Prettier (HTML, CSS, JS, PHP, JSON).</string>\n  <string key=\"editor.paste_blocked\">Przegl�
- darka zablokowała dostęp do schowka. Użyj Ctrl+V.</string>\n  <string key=\"shortcut.emmet\">Rozwiń skrót Emmet / przyjmij podpowiedź</string>\n\n  <string key=\"php.loading\">Uruchamianie PHP 8.3… (tylko za pierwszym razem)</string>\n  <string key=\"php.load_failed\">Nie udało się wczytać silnika PHP.</string>\n  <string key=\"php.syncing\">Przygotowanie plików projektu dla PHP: {done} z {total}…</string>\n  <string key=\"php.sync_timeout\">Kopiowanie plików projektu do PHP trwało dłużej niż {s} s. Spróbuj odświeżyć podgl�
+ darka zablokowała dostęp do schowka. Użyj Ctrl+V.</string>\n  <string key=\"shortcut.emmet\">Rozwiń skrót Emmet / przyjmij podpowiedź</string>\n\n  <string key=\"settings.mysql_emulation\">Emulacja MySQL (BETA)</string>\n  <string key=\"settings.mysql_emulation_hint\">Skrypty używaj�
+ ce mysqli lub PDO(\"mysql:…\") działaj�
+  w podgl�
+ dzie na bazie SQLite w pamięci zamiast na serwerze MySQL. Zrzut .sql z projektu jest importowany automatycznie. Nie wszystkie funkcje MySQL s�
+  obsługiwane.</string>\n  <string key=\"php.loading\">Uruchamianie PHP 8.3… (tylko za pierwszym razem)</string>\n  <string key=\"php.load_failed\">Nie udało się wczytać silnika PHP.</string>\n  <string key=\"php.syncing\">Przygotowanie plików projektu dla PHP: {done} z {total}…</string>\n  <string key=\"php.sync_timeout\">Kopiowanie plików projektu do PHP trwało dłużej niż {s} s. Spróbuj odświeżyć podgl�
  d.</string>\n  <string key=\"php.timeout\">Skrypt PHP działał dłużej niż {s} s i został przerwany.</string>\n  <string key=\"php.stopped\">Silnik PHP został zatrzymany.</string>\n  <string key=\"php.failed_title\">Nie udało się wykonać PHP</string>\n  <string key=\"php.redirect_external\">Przekierowanie na zewnętrzny adres: {url}</string>\n  <string key=\"php.redirect_loop\">Zbyt wiele przekierowań</string>\n  <string key=\"php.redirect_missing\">Przekierowanie do nieistniej�
  cego pliku: {url}</string>\n  <string key=\"php.restarted\">PHP uruchomiony ponownie (sesje i ciasteczka wyczyszczone).</string>\n  <string key=\"cmd.php_restart\">PHP: uruchom ponownie (wyczyść sesje)</string>\n  <string key=\"settings.php_runtime\">Uruchamiaj PHP w podgl�
  dzie</string>\n  <string key=\"settings.php_runtime_hint\">Prawdziwy PHP 8.3 w przegl�
  darce: include, sesje, formularze, SQLite. Silnik (ok. 9 MB) wczytuje się przy pierwszym podgl�
- dzie pliku .php. MySQL nie jest dostępny.</string>\n\n  <string key=\"drop.hint\">Upuść folder lub pliki, aby je otworzyć</string>\n\n  <string key=\"cm.Find\">Znajdź</string>\n  <string key=\"cm.Replace\">Zamień</string>\n  <string key=\"cm.next\">następny</string>\n  <string key=\"cm.previous\">poprzedni</string>\n  <string key=\"cm.all\">wszystkie</string>\n  <string key=\"cm.match case\">wielkość liter</string>\n  <string key=\"cm.regexp\">wyrażenie regularne</string>\n  <string key=\"cm.by word\">całe słowa</string>\n  <string key=\"cm.replace\">zamień</string>\n  <string key=\"cm.replace all\">zamień wszystkie</string>\n  <string key=\"cm.close\">zamknij</string>\n  <string key=\"cm.current match\">bież�
+ dzie pliku .php.</string>\n\n  <string key=\"cmd.search_in_files\">Szukaj w plikach</string>\n  <string key=\"search.title\">Szukaj</string>\n  <string key=\"search.placeholder\">Szukaj w plikach</string>\n  <string key=\"search.replace_placeholder\">Zamień na</string>\n  <string key=\"search.files_placeholder\">Pliki: *.css, src/, !vendor/</string>\n  <string key=\"search.case\">Uwzględnij wielkość liter</string>\n  <string key=\"search.word\">Całe słowa</string>\n  <string key=\"search.regex\">Wyrażenie regularne</string>\n  <string key=\"search.toggle_replace\">Pokaż lub ukryj zamianę</string>\n  <string key=\"search.clear\">Wyczyść</string>\n  <string key=\"search.stop\">Zatrzymaj</string>\n  <string key=\"search.running\">Szukanie… {done} z {total} plików</string>\n  <string key=\"search.progress\">przeszukano {done} z {total} plików</string>\n  <string key=\"search.show_more\">Pokaż więcej wyników (przeszukano {done} z {total} plików)</string>\n  <string key=\"search.no_results\">Brak wyników</string>\n  <string key=\"search.bad_regex\">Nieprawidłowy wzorzec: {error}</string>\n  <string key=\"search.truncated\">Pokazano pierwsze {n} dopasowań w tym pliku</string>\n  <string key=\"search.replace_all\">Zamień wszystko</string>\n  <string key=\"search.undo_replace\">Cofnij ostatni�
+  zamianę</string>\n  <string key=\"search.undo_empty\">Brak zamiany do cofnięcia.</string>\n  <string key=\"search.undone\">Cofnięto zmiany {files}.</string>\n  <string key=\"search.undo_skipped\">Pominięto {files} (zmienione po zamianie).</string>\n  <string key=\"search.replace_in_file\">Zamień w tym pliku</string>\n  <string key=\"search.replace_one\">Zamień</string>\n  <string key=\"search.replacing\">Zamiana… {done} z {total} plików</string>\n  <string key=\"search.stale\">Tekst zmienił się od czasu wyszukiwania. Odświeżono wyniki.</string>\n  <string key=\"search.replace_failed\">Nie udało się zmienić „{name}”: {error}</string>\n  <string key=\"search.confirm_title\">Zamiana w plikach</string>\n  <string key=\"search.confirm_partial\">Wyszukiwanie nie jest zakończone, więc zamienione zostan�
+  tylko dotychczas załadowane wyniki.</string>\n  <string key=\"search.confirm_more\">W niektórych plikach jest więcej dopasowań niż pokazano; zamienione zostan�
+  wszystkie dopasowania w tych plikach.</string>\n  <string key=\"search.confirm_open\">Otwarte pliki zostan�
+  zmienione, ale niezapisane (cofniesz przez Ctrl+Z). Pozostałe pliki zostan�
+  od razu zapisane na dysku. Cał�
+  zamianę cofniesz przyciskiem obok „Zamień wszystko”, dopóki nie zamkniesz lub nie zmienisz folderu.</string>\n  <plural key=\"search.n_matches\">\n    <one>{n} dopasowanie</one>\n    <few>{n} dopasowania</few>\n    <many>{n} dopasowań</many>\n    <other>{n} dopasowania</other>\n  </plural>\n  <plural key=\"search.n_files\">\n    <one>{n} plik</one>\n    <few>{n} pliki</few>\n    <many>{n} plików</many>\n    <other>{n} pliku</other>\n  </plural>\n  <plural key=\"search.in_n_files\">\n    <one>w {n} pliku</one>\n    <few>w {n} plikach</few>\n    <many>w {n} plikach</many>\n    <other>w {n} pliku</other>\n  </plural>\n  <plural key=\"search.confirm_text\">\n    <one>Zamienić {n} dopasowanie {files}?</one>\n    <few>Zamienić {n} dopasowania {files}?</few>\n    <many>Zamienić {n} dopasowań {files}?</many>\n    <other>Zamienić {n} dopasowania {files}?</other>\n  </plural>\n  <plural key=\"search.replaced\">\n    <one>Zamieniono {n} dopasowanie</one>\n    <few>Zamieniono {n} dopasowania</few>\n    <many>Zamieniono {n} dopasowań</many>\n    <other>Zamieniono {n} dopasowania</other>\n  </plural>\n\n  <string key=\"backup.started\">Tworzenie kopii zapasowej…</string>\n  <string key=\"backup.done\">Zapisano kopię zapasow�
+ : {path}</string>\n  <string key=\"backup.downloaded\">Pobrano kopię zapasow�
+  „{name}”.</string>\n  <string key=\"backup.too_large\">Projekt jest za duży na jedno archiwum ZIP (limit: 4 GB na plik i 65535 pozycji).</string>\n\n  <string key=\"drop.hint\">Upuść folder lub pliki, aby je otworzyć</string>\n\n  <string key=\"cm.Find\">Znajdź</string>\n  <string key=\"cm.Replace\">Zamień</string>\n  <string key=\"cm.next\">następny</string>\n  <string key=\"cm.previous\">poprzedni</string>\n  <string key=\"cm.all\">wszystkie</string>\n  <string key=\"cm.match case\">wielkość liter</string>\n  <string key=\"cm.regexp\">wyrażenie regularne</string>\n  <string key=\"cm.by word\">całe słowa</string>\n  <string key=\"cm.replace\">zamień</string>\n  <string key=\"cm.replace all\">zamień wszystkie</string>\n  <string key=\"cm.close\">zamknij</string>\n  <string key=\"cm.current match\">bież�
  ce dopasowanie</string>\n  <string key=\"cm.replaced $ matches\">zamieniono dopasowania: $</string>\n  <string key=\"cm.replaced match on line $\">zamieniono dopasowanie w wierszu $</string>\n  <string key=\"cm.on line\">w wierszu</string>\n  <string key=\"cm.Go to line\">Przejdź do wiersza</string>\n  <string key=\"cm.go\">przejdź</string>\n  <string key=\"cm.Folded lines\">Zwinięte wiersze</string>\n  <string key=\"cm.Unfolded lines\">Rozwinięte wiersze</string>\n  <string key=\"cm.Fold line\">Zwiń</string>\n  <string key=\"cm.Unfold line\">Rozwiń</string>\n  <string key=\"cm.folded code\">zwinięty kod</string>\n  <string key=\"cm.unfold\">rozwiń</string>\n  <string key=\"cm.to\">do</string>\n  <string key=\"cm.Completions\">Podpowiedzi</string>\n  <string key=\"cm.Diagnostics\">Diagnostyka</string>\n  <string key=\"cm.No diagnostics\">Brak problemów</string>\n  <string key=\"cm.Selection deleted\">Usunięto zaznaczenie</string>\n  <string key=\"cm.Control character\">Znak steruj�
- cy</string>\n</language>\n","english.xml":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<language code=\"en\" name=\"English\" author=\"WebOrbiton\" version=\"1.0.0\">\n  <string key=\"app.description\">AtheraStudio Code: a local web page editor (HTML, CSS, JS, PHP) by WebOrbiton.</string>\n  <string key=\"app.folder_opened\">Opened folder \"{name}\".</string>\n  <string key=\"app.no_permission\">Permission to access the folder was denied.</string>\n  <string key=\"app.reopen_failed\">The folder can't be reopened (it may have been moved or deleted).</string>\n  <string key=\"app.new_file_label\">File name (the extension picks the language: .html, .css, .js, .php…)</string>\n  <string key=\"app.open_folder_first\">Open a folder first.</string>\n  <string key=\"app.saved_as\">Saved as \"{name}\".</string>\n  <string key=\"app.downloaded\">Downloaded \"{name}\".</string>\n  <string key=\"app.wrap_on\">Word wrap: on</string>\n  <string key=\"app.wrap_off\">Word wrap: off</string>\n\n  <string key=\"common.close\">Close</string>\n  <string key=\"common.cancel\">Cancel</string>\n  <string key=\"common.ok\">OK</string>\n  <string key=\"common.create\">Create</string>\n  <string key=\"common.rename\">Rename</string>\n  <string key=\"common.delete\">Delete</string>\n  <string key=\"common.save\">Save</string>\n\n  <string key=\"menu.main\">Main menu</string>\n  <string key=\"menu.file\">File</string>\n  <string key=\"menu.view\">View</string>\n  <string key=\"menu.help\">Help</string>\n  <string key=\"menu.open_folder\">Open folder…</string>\n  <string key=\"menu.open_file\">Open file…</string>\n  <string key=\"menu.new_file\">New file</string>\n  <string key=\"menu.new_folder\">New folder</string>\n  <string key=\"menu.save\">Save</string>\n  <string key=\"menu.save_all\">Save all</string>\n  <string key=\"menu.save_as\">Save as…</string>\n  <string key=\"menu.close_tab\">Close tab</string>\n  <string key=\"menu.close_folder\">Close folder</string>\n  <string key=\"menu.sidebar\">Sidebar</string>\n  <string key=\"menu.preview\">Live preview</string>\n  <string key=\"menu.wrap\">Word wrap</string>\n  <string key=\"menu.search\">Find and replace</string>\n  <string key=\"menu.zoom_in\">Larger text</string>\n  <string key=\"menu.zoom_out\">Smaller text</string>\n  <string key=\"menu.zoom_reset\">Default size</string>\n  <string key=\"menu.shortcuts\">Keyboard shortcuts</string>\n  <string key=\"menu.about\">About</string>\n\n  <string key=\"top.preview\">Live preview (Alt+P)</string>\n  <string key=\"top.accent\">Accent color</string>\n  <string key=\"top.theme\">Light / dark theme</string>\n\n  <string key=\"accent.blue\">Blue (default)</string>\n  <string key=\"accent.indigo\">Indigo</string>\n  <string key=\"accent.violet\">Violet</string>\n  <string key=\"accent.purple\">Purple</string>\n  <string key=\"accent.fuchsia\">Fuchsia</string>\n  <string key=\"accent.pink\">Pink</string>\n  <string key=\"accent.rose\">Rose</string>\n  <string key=\"accent.red\">Red</string>\n  <string key=\"accent.orange\">Orange</string>\n  <string key=\"accent.amber\">Amber</string>\n  <string key=\"accent.lime\">Lime</string>\n  <string key=\"accent.green\">Green</string>\n  <string key=\"accent.emerald\">Emerald</string>\n  <string key=\"accent.teal\">Teal</string>\n  <string key=\"accent.cyan\">Cyan</string>\n  <string key=\"accent.slate\">Slate</string>\n\n  <string key=\"lang.title\">Language</string>\n  <string key=\"lang.import\">Load translation (XML)…</string>\n  <string key=\"lang.template\">Download translation template</string>\n  <string key=\"lang.template_file\">my-language.xml</string>\n  <string key=\"lang.imported\">Language added: {name}</string>\n  <string key=\"lang.imported_tag\">loaded</string>\n  <string key=\"lang.invalid\">Invalid translation file: {error}</string>\n  <string key=\"lang.remove\">Remove language \"{name}\"</string>\n  <string key=\"lang.remove_title\">Remove language</string>\n  <string key=\"lang.remove_confirm\">Remove the loaded translation \"{name}\"?</string>\n\n  <string key=\"sidebar.explorer\">Explorer</string>\n  <string key=\"sidebar.files\">Files</string>\n  <string key=\"sidebar.no_folder\">No folder is open.</string>\n  <string key=\"sidebar.drop_hint\">You can also drag a folder or files into the editor window.</string>\n\n  <string key=\"layout.resize_sidebar\">Resize sidebar</string>\n  <string key=\"layout.resize_preview\">Resize preview</string>\n\n  <string key=\"action.open_folder\">Open folder</string>\n  <string key=\"action.open_file\">Open file</string>\n  <string key=\"action.new_file\">New file</string>\n\n  <string key=\"welcome.lead\">A local web page editor for HTML, CSS, JavaScript and PHP. Your files stay on your computer; nothing is uploaded.</string>\n  <string key=\"welcome.limited_title\">Limited mode</string>\n  <string key=\"welcome.limited_text\">This browser can't save files directly to disk, so saving downloads the file. Full mode works in Chrome, Edge and Opera.</string>\n  <string key=\"welcome.reopen\">Reopen \"{name}\"</string>\n\n  <string key=\"shortcut.open_folder\">Open folder</string>\n  <string key=\"shortcut.save\">Save</string>\n  <string key=\"shortcut.save_all\">Save all</string>\n  <string key=\"shortcut.new_file\">New file</string>\n  <string key=\"shortcut.close_tab\">Close tab</string>\n  <string key=\"shortcut.switch_tab\">Next / previous tab</string>\n  <string key=\"shortcut.sidebar\">Sidebar</string>\n  <string key=\"shortcut.preview\">Live preview</string>\n  <string key=\"shortcut.wrap\">Word wrap</string>\n  <string key=\"shortcut.complete\">Suggestions</string>\n  <string key=\"shortcut.search\">Find and replace</string>\n  <string key=\"shortcut.comment\">Toggle comment</string>\n  <string key=\"shortcut.move_line\">Move line</string>\n  <string key=\"shortcut.copy_line\">Duplicate line</string>\n  <string key=\"shortcut.select_next\">Select next occurrence</string>\n  <string key=\"shortcut.multi_cursor\">Add cursor</string>\n  <string key=\"shortcut.fold\">Fold / unfold block</string>\n  <string key=\"shortcut.zoom\">Text size</string>\n  <string key=\"shortcut.explorer\">Rename / delete (in the explorer)</string>\n  <string key=\"shortcut.drag_move\">Move a file or folder (in the explorer)</string>\n  <string key=\"key.drag\">Drag</string>\n  <string key=\"key.space\">Space</string>\n  <string key=\"key.click\">Click</string>\n\n  <string key=\"tabs.aria\">Open files</string>\n  <string key=\"tabs.binary\">\"{name}\" is a binary file and can't be edited as text.</string>\n  <string key=\"tabs.open_failed\">Couldn't open \"{name}\": {error}</string>\n  <string key=\"tabs.memory_saved\">Limited mode: \"{name}\" was downloaded.</string>\n  <string key=\"tabs.save_failed\">Couldn't save \"{name}\": {error}</string>\n  <plural key=\"tabs.saved_count\">\n    <one>Saved {n} file</one>\n    <other>Saved {n} files</other>\n  </plural>\n  <string key=\"tabs.unsaved_title\">Unsaved changes</string>\n  <string key=\"tabs.unsaved_text\">\"{name}\" has unsaved changes. Save them before closing?</string>\n  <string key=\"tabs.dont_save\">Don't save</string>\n  <string key=\"tabs.not_on_disk\">(not saved to disk)</string>\n  <string key=\"tabs.close_named\">Close {name}</string>\n  <string key=\"tabs.close\">Close</string>\n  <string key=\"tabs.close_others\">Close others</string>\n  <string key=\"tabs.close_all\">Close all</string>\n\n  <string key=\"explorer.read_error\">Can't read the folder: {error}</string>\n  <string key=\"explorer.empty\">The folder is empty. Create the first file with the \"+\" button above.</string>\n  <string key=\"explorer.new_file\">New file</string>\n  <string key=\"explorer.new_file_label\">File name (may include a subfolder, e.g. css/style.css)</string>\n  <string key=\"explorer.new_file_label_in\">File name in \"{dir}/\" (may include a subfolder, e.g. css/style.css)</string>\n  <string key=\"explorer.new_folder\">New folder</string>\n  <string key=\"explorer.new_folder_label\">Folder name</string>\n  <string key=\"explorer.new_folder_label_in\">Folder name in \"{dir}/\"</string>\n  <string key=\"explorer.rename_title\">Rename</string>\n  <string key=\"explorer.rename_label\">New name</string>\n  <string key=\"explorer.invalid_name\">The name contains characters that aren't allowed.</string>\n  <string key=\"explorer.rename_failed\">Couldn't rename: {error}</string>\n  <string key=\"explorer.delete_file_confirm\">Delete the file \"{path}\"? This can't be undone.</string>\n  <string key=\"explorer.delete_folder_confirm\">Delete the folder \"{path}\" and everything in it? This can't be undone.</string>\n  <string key=\"explorer.delete_failed\">Couldn't delete: {error}</string>\n  <plural key=\"explorer.delete_many_confirm\">\n    <one>Delete {n} item? This can't be undone.</one>\n    <other>Delete {n} items? This can't be undone.</other>\n  </plural>\n  <plural key=\"explorer.moved_many\">\n    <one>Moved {n} item to \"{dir}\".</one>\n    <other>Moved {n} items to \"{dir}\".</other>\n  </plural>\n  <string key=\"explorer.moved\">Moved \"{name}\" to \"{dir}\".</string>\n  <string key=\"explorer.move_failed\">Couldn't move: {error}</string>\n  <string key=\"explorer.copy_path\">Copy path</string>\n  <string key=\"explorer.copied\">Copied: {path}</string>\n  <string key=\"explorer.refresh\">Refresh</string>\n  <string key=\"explorer.collapse\">Collapse all</string>\n\n  <string key=\"fs.exists\">\"{path}\" already exists.</string>\n  <string key=\"fs.not_found\">File \"{path}\" was not found.</string>\n  <string key=\"fs.no_permission\">Permission to write the file was denied.</string>\n\n  <string key=\"preview.title\">Preview</string>\n  <string key=\"preview.empty\">Open an HTML or PHP file to see a live preview.</string>\n  <string key=\"preview.refresh\">Refresh preview</string>\n  <string key=\"preview.new_window\">Open in a new window</string>\n  <string key=\"preview.close\">Close preview</string>\n  <string key=\"preview.frame_title\">Page preview</string>\n  <string key=\"preview.error\">JavaScript error</string>\n  <string key=\"preview.error_line\">{message} (line {line})</string>\n  <string key=\"preview.missing\">Missing file: {path}</string>\n  <string key=\"preview.page_not_found\">Page \"{path}\" was not found.</string>\n  <string key=\"preview.problems_title\">Preview problems</string>\n  <plural key=\"preview.problems\">\n    <one>{n} problem</one>\n    <other>{n} problems</other>\n  </plural>\n\n  <string key=\"status.no_folder\">No folder</string>\n  <string key=\"status.disk\">Local folder: {name}</string>\n  <string key=\"status.memory\">Limited mode: {name}</string>\n  <string key=\"status.image\">Image</string>\n  <string key=\"status.plain_text\">Plain text</string>\n  <string key=\"status.spaces\">Spaces: {n}</string>\n  <string key=\"status.position\">Ln {line}, Col {col}</string>\n  <string key=\"status.selected\">({n} selected)</string>\n  <string key=\"status.cursors\">cursors: {n}</string>\n\n\n  <string key=\"about.text\">A local web page editor by WebOrbiton.</string>\n  <string key=\"about.license\">License: {license}</string>\n  <string key=\"about.ui\">Interface: {name}</string>\n  <string key=\"about.engine\">Editor engine: {name}</string>\n  <string key=\"about.translation\">Translation: {name}</string>\n\n  <string key=\"menu.settings\">Settings…</string>\n  <string key=\"top.settings\">Settings (Ctrl+,)</string>\n  <string key=\"shortcut.settings\">Settings</string>\n  <string key=\"status.tabs\">Tab size: {n}</string>\n  <string key=\"settings.title\">Settings</string>\n  <string key=\"settings.section_appearance\">Appearance</string>\n  <string key=\"settings.section_editor\">Editor</string>\n  <string key=\"settings.section_files\">Files and preview</string>\n  <string key=\"settings.section_fonts\">Fonts</string>\n  <string key=\"settings.language\">Language</string>\n  <string key=\"settings.theme\">Theme</string>\n  <string key=\"settings.theme_system\">System</string>\n  <string key=\"settings.theme_light\">Light</string>\n  <string key=\"settings.theme_dark\">Dark</string>\n  <string key=\"settings.accent\">Accent color</string>\n  <string key=\"settings.ui_font\">Interface font</string>\n  <string key=\"settings.code_font\">Code font</string>\n  <string key=\"settings.font_system\">System default</string>\n  <string key=\"settings.font_size\">Font size</string>\n  <string key=\"settings.line_height\">Line height</string>\n  <string key=\"settings.tab_size\">Tab size</string>\n  <string key=\"settings.indent\">Indentation</string>\n  <string key=\"settings.indent_spaces\">Spaces</string>\n  <string key=\"settings.indent_tabs\">Tabs</string>\n  <string key=\"settings.wrap\">Word wrap</string>\n  <string key=\"settings.line_numbers\">Line numbers</string>\n  <string key=\"settings.active_line\">Highlight current line</string>\n  <string key=\"settings.fold\">Code folding</string>\n  <string key=\"settings.close_brackets\">Auto-close brackets and quotes</string>\n  <string key=\"settings.autocomplete\">Suggestions while typing</string>\n  <string key=\"settings.match_highlight\">Highlight selection matches</string>\n  <string key=\"settings.auto_save\">Auto save</string>\n  <string key=\"settings.auto_save_hint\">Saves a file one second after the last change and when you switch windows. Works for files on disk.</string>\n  <string key=\"settings.live_preview\">Refresh preview while typing</string>\n  <string key=\"settings.live_preview_hint\">When off, the preview refreshes on save.</string>\n  <string key=\"settings.fonts_hint\">Fonts uploaded here are kept in this browser. To add a font permanently, put the file in assets/fonts and list it in assets/fonts/fonts.css (see README).</string>\n  <string key=\"settings.fonts_none\">No uploaded fonts.</string>\n  <string key=\"settings.font_upload\">Add font (TTF, OTF, WOFF)…</string>\n  <string key=\"settings.font_name_title\">Font name</string>\n  <string key=\"settings.font_name_label\">The font will appear in the list under this name</string>\n  <string key=\"settings.font_added\">Font added: {name}</string>\n  <string key=\"settings.font_invalid\">Couldn't load the font: {error}</string>\n  <string key=\"settings.font_remove\">Remove font {name}</string>\n  <string key=\"settings.reset\">Restore defaults</string>\n  <string key=\"settings.reset_done\">Default settings restored.</string>\n\n  <string key=\"menu.edit\">Edit</string>\n  <string key=\"cmd.undo\">Undo</string>\n  <string key=\"cmd.redo\">Redo</string>\n  <string key=\"cmd.cut\">Cut</string>\n  <string key=\"cmd.copy\">Copy</string>\n  <string key=\"cmd.paste\">Paste</string>\n  <string key=\"cmd.cut_line\">Cut line</string>\n  <string key=\"cmd.copy_line\">Copy line</string>\n  <string key=\"cmd.select_occurrences\">Select all occurrences</string>\n  <string key=\"cmd.toggle_comment\">Toggle comment</string>\n  <string key=\"cmd.duplicate_line\">Duplicate line</string>\n  <string key=\"cmd.delete_line\">Delete line</string>\n  <string key=\"cmd.indent_more\">Indent</string>\n  <string key=\"cmd.indent_less\">Outdent</string>\n  <string key=\"cmd.fold_all\">Fold all</string>\n  <string key=\"cmd.unfold_all\">Unfold all</string>\n  <string key=\"cmd.suggest\">Trigger suggestions</string>\n  <string key=\"cmd.format\">Format document</string>\n  <string key=\"cmd.quick_open\">Quick open file</string>\n  <string key=\"cmd.command_palette\">Command palette</string>\n  <string key=\"cmd.goto_line\">Go to line</string>\n  <string key=\"cmd.problems\">Problems</string>\n  <string key=\"cmd.next_problem\">Next problem</string>\n  <string key=\"cmd.toggle_theme\">Toggle light / dark theme</string>\n  <string key=\"cmd.emmet_wrap\">Emmet: wrap with abbreviation</string>\n  <string key=\"cmd.emmet_balance_out\">Emmet: balance outward</string>\n  <string key=\"cmd.emmet_balance_in\">Emmet: balance inward</string>\n  <string key=\"cmd.emmet_remove_tag\">Emmet: remove tag</string>\n  <string key=\"cmd.emmet_tag_pair\">Emmet: go to matching pair</string>\n  <string key=\"cmd.emmet_split_join\">Emmet: split / join tag</string>\n  <string key=\"cmd.emmet_math\">Emmet: evaluate math expression</string>\n  <string key=\"cmd.emmet_next_edit\">Emmet: next edit point</string>\n  <string key=\"cmd.emmet_prev_edit\">Emmet: previous edit point</string>\n  <string key=\"cmd.emmet_increment\">Emmet: increment number by 1</string>\n  <string key=\"cmd.emmet_decrement\">Emmet: decrement number by 1</string>\n  <string key=\"palette.title\">Palette</string>\n  <string key=\"palette.placeholder\">Search files · &gt; commands · : line number</string>\n  <string key=\"palette.no_editor\">Open a file in the editor first.</string>\n  <string key=\"palette.line_hint\">Type a line number (1–{max}), e.g. :12 or :12:5</string>\n  <string key=\"palette.go_line\">Go to line {line}</string>\n  <string key=\"palette.open_tab\">open tab</string>\n  <string key=\"palette.no_folder\">Open a folder to search project files. Type &gt; for commands.</string>\n  <string key=\"palette.loading\">Loading file list…</string>\n  <string key=\"palette.no_results\">No results</string>\n  <string key=\"format.load_failed\">Couldn't load the formatter.</string>\n  <string key=\"format.unsupported\">Formatting isn't available for this file type.</string>\n  <string key=\"format.error_line\">Can't format, error on line {line}: {error}</string>\n  <string key=\"format.error\">Can't format: {error}</string>\n  <string key=\"format.unchanged\">The code is already formatted.</string>\n  <string key=\"lint.syntax\">Syntax error</string>\n  <string key=\"lint.mismatched\">Closing tag {tag} doesn't match the open element</string>\n  <string key=\"lint.unclosed\">Tag &lt;{tag}&gt; is not closed</string>\n  <string key=\"lint.img_alt\">Image has no alt attribute (important for accessibility and SEO)</string>\n  <string key=\"lint.fix_alt\">Add alt</string>\n  <string key=\"lint.blank_rel\">A link opened in a new tab should have rel=\"noopener\"</string>\n  <string key=\"lint.fix_rel\">Add rel</string>\n  <string key=\"lint.deprecated\">The &lt;{tag}&gt; tag is obsolete, use CSS instead</string>\n  <string key=\"lint.duplicate_id\">The id \"{id}\" is used more than once</string>\n  <string key=\"lint.doctype\">Missing &lt;!DOCTYPE html&gt; declaration</string>\n  <string key=\"lint.lang\">The &lt;html&gt; element has no lang attribute</string>\n  <string key=\"lint.charset\">Missing &lt;meta charset&gt; (special characters may display incorrectly)</string>\n  <string key=\"lint.viewport\">Missing meta viewport (the page won't fit on phones)</string>\n  <string key=\"lint.title\">Missing &lt;title&gt; tag</string>\n  <string key=\"lint.fix_add\">Add</string>\n  <string key=\"settings.emmet\">Emmet</string>\n  <string key=\"settings.emmet_hint\">Abbreviations like ! or ul&gt;li*3 expanded with Tab, automatic renaming of tag pairs.</string>\n  <string key=\"settings.smart_suggest\">Smart block suggestions</string>\n  <string key=\"settings.smart_suggest_hint\">After Enter in an empty &lt;head&gt;, &lt;body&gt;, list or form, a list of ready-made layouts opens automatically.</string>\n  <string key=\"settings.lint_hints\">Problem detection</string>\n  <string key=\"settings.lint_hints_hint\">Syntax errors and HTML hints (alt, lang, viewport, unclosed tags) with an \"Add\" button.</string>\n  <string key=\"settings.format_on_save\">Format on save</string>\n  <string key=\"settings.format_on_save_hint\">Code is cleaned up with Prettier before saving (HTML, CSS, JS, PHP, JSON).</string>\n  <string key=\"editor.paste_blocked\">The browser blocked clipboard access. Use Ctrl+V.</string>\n  <string key=\"shortcut.emmet\">Expand Emmet abbreviation / accept suggestion</string>\n\n  <string key=\"php.loading\">Starting PHP 8.3… (first time only)</string>\n  <string key=\"php.load_failed\">Couldn't load the PHP engine.</string>\n  <string key=\"php.syncing\">Preparing project files for PHP: {done} of {total}…</string>\n  <string key=\"php.sync_timeout\">Copying project files to PHP took longer than {s} s. Try refreshing the preview.</string>\n  <string key=\"php.timeout\">The PHP script ran longer than {s} s and was stopped.</string>\n  <string key=\"php.stopped\">The PHP engine was stopped.</string>\n  <string key=\"php.failed_title\">PHP could not be executed</string>\n  <string key=\"php.redirect_external\">Redirect to an external address: {url}</string>\n  <string key=\"php.redirect_loop\">Too many redirects</string>\n  <string key=\"php.redirect_missing\">Redirect to a file that doesn't exist: {url}</string>\n  <string key=\"php.restarted\">PHP restarted (sessions and cookies cleared).</string>\n  <string key=\"cmd.php_restart\">PHP: restart (clear sessions)</string>\n  <string key=\"settings.php_runtime\">Run PHP in the preview</string>\n  <string key=\"settings.php_runtime_hint\">Real PHP 8.3 in the browser: include, sessions, forms, SQLite. The engine (about 9 MB) loads on the first .php preview. MySQL is not available.</string>\n\n  <string key=\"drop.hint\">Drop a folder or files to open them</string>\n</language>\n"};
+ cy</string>\n</language>","english.xml":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<language code=\"en\" name=\"English\" author=\"WebOrbiton\" version=\"1.0.0\">\n  <string key=\"app.description\">AtheraStudio Code: a local web page editor (HTML, CSS, JS, PHP) by WebOrbiton.</string>\n  <string key=\"app.folder_opened\">Opened folder \"{name}\".</string>\n  <string key=\"app.no_permission\">Permission to access the folder was denied.</string>\n  <string key=\"app.reopen_failed\">The folder can't be reopened (it may have been moved or deleted).</string>\n  <string key=\"app.new_file_label\">File name (the extension picks the language: .html, .css, .js, .php…)</string>\n  <string key=\"app.open_folder_first\">Open a folder first.</string>\n  <string key=\"app.saved_as\">Saved as \"{name}\".</string>\n  <string key=\"app.downloaded\">Downloaded \"{name}\".</string>\n  <string key=\"app.wrap_on\">Word wrap: on</string>\n  <string key=\"app.wrap_off\">Word wrap: off</string>\n\n  <string key=\"common.close\">Close</string>\n  <string key=\"common.cancel\">Cancel</string>\n  <string key=\"common.ok\">OK</string>\n  <string key=\"common.create\">Create</string>\n  <string key=\"common.rename\">Rename</string>\n  <string key=\"common.delete\">Delete</string>\n  <string key=\"common.save\">Save</string>\n\n  <string key=\"menu.main\">Main menu</string>\n  <string key=\"menu.file\">File</string>\n  <string key=\"menu.view\">View</string>\n  <string key=\"menu.help\">Help</string>\n  <string key=\"menu.open_folder\">Open folder…</string>\n  <string key=\"menu.open_file\">Open file…</string>\n  <string key=\"menu.new_file\">New file</string>\n  <string key=\"menu.new_folder\">New folder</string>\n  <string key=\"menu.save\">Save</string>\n  <string key=\"menu.save_all\">Save all</string>\n  <string key=\"menu.save_as\">Save as…</string>\n  <string key=\"menu.close_tab\">Close tab</string>\n  <string key=\"menu.backup\">Create backup</string>\n  <string key=\"menu.close_folder\">Close folder</string>\n  <string key=\"menu.sidebar\">Sidebar</string>\n  <string key=\"menu.preview\">Live preview</string>\n  <string key=\"menu.wrap\">Word wrap</string>\n  <string key=\"menu.search\">Find and replace</string>\n  <string key=\"menu.zoom_in\">Larger text</string>\n  <string key=\"menu.zoom_out\">Smaller text</string>\n  <string key=\"menu.zoom_reset\">Default size</string>\n  <string key=\"menu.shortcuts\">Keyboard shortcuts</string>\n  <string key=\"menu.about\">About</string>\n\n  <string key=\"top.preview\">Live preview (Alt+P)</string>\n  <string key=\"top.accent\">Accent color</string>\n  <string key=\"top.theme\">Light / dark theme</string>\n\n  <string key=\"accent.blue\">Blue (default)</string>\n  <string key=\"accent.indigo\">Indigo</string>\n  <string key=\"accent.violet\">Violet</string>\n  <string key=\"accent.purple\">Purple</string>\n  <string key=\"accent.fuchsia\">Fuchsia</string>\n  <string key=\"accent.pink\">Pink</string>\n  <string key=\"accent.rose\">Rose</string>\n  <string key=\"accent.red\">Red</string>\n  <string key=\"accent.orange\">Orange</string>\n  <string key=\"accent.amber\">Amber</string>\n  <string key=\"accent.lime\">Lime</string>\n  <string key=\"accent.green\">Green</string>\n  <string key=\"accent.emerald\">Emerald</string>\n  <string key=\"accent.teal\">Teal</string>\n  <string key=\"accent.cyan\">Cyan</string>\n  <string key=\"accent.slate\">Slate</string>\n\n  <string key=\"lang.title\">Language</string>\n  <string key=\"lang.import\">Load translation (XML)…</string>\n  <string key=\"lang.template\">Download translation template</string>\n  <string key=\"lang.template_file\">my-language.xml</string>\n  <string key=\"lang.imported\">Language added: {name}</string>\n  <string key=\"lang.imported_tag\">loaded</string>\n  <string key=\"lang.invalid\">Invalid translation file: {error}</string>\n  <string key=\"lang.remove\">Remove language \"{name}\"</string>\n  <string key=\"lang.remove_title\">Remove language</string>\n  <string key=\"lang.remove_confirm\">Remove the loaded translation \"{name}\"?</string>\n\n  <string key=\"sidebar.explorer\">Explorer</string>\n  <string key=\"sidebar.files\">Files</string>\n  <string key=\"sidebar.no_folder\">No folder is open.</string>\n  <string key=\"sidebar.drop_hint\">You can also drag a folder or files into the editor window.</string>\n\n  <string key=\"layout.resize_sidebar\">Resize sidebar</string>\n  <string key=\"layout.resize_preview\">Resize preview</string>\n\n  <string key=\"action.open_folder\">Open folder</string>\n  <string key=\"action.open_file\">Open file</string>\n  <string key=\"action.new_file\">New file</string>\n\n  <string key=\"welcome.lead\">A local web page editor for HTML, CSS, JavaScript and PHP. Your files stay on your computer; nothing is uploaded.</string>\n  <string key=\"welcome.limited_title\">Limited mode</string>\n  <string key=\"welcome.limited_text\">This browser can't save files directly to disk, so saving downloads the file. Full mode works in Chrome, Edge and Opera.</string>\n  <string key=\"welcome.reopen\">Reopen \"{name}\"</string>\n\n  <string key=\"shortcut.open_folder\">Open folder</string>\n  <string key=\"shortcut.save\">Save</string>\n  <string key=\"shortcut.save_all\">Save all</string>\n  <string key=\"shortcut.new_file\">New file</string>\n  <string key=\"shortcut.close_tab\">Close tab</string>\n  <string key=\"shortcut.switch_tab\">Next / previous tab</string>\n  <string key=\"shortcut.move_tab\">Move tab left / right (or drag it)</string>\n  <string key=\"shortcut.sidebar\">Sidebar</string>\n  <string key=\"shortcut.preview\">Live preview</string>\n  <string key=\"shortcut.wrap\">Word wrap</string>\n  <string key=\"shortcut.complete\">Suggestions</string>\n  <string key=\"shortcut.search\">Find and replace</string>\n  <string key=\"shortcut.comment\">Toggle comment</string>\n  <string key=\"shortcut.move_line\">Move line</string>\n  <string key=\"shortcut.copy_line\">Duplicate line</string>\n  <string key=\"shortcut.select_next\">Select next occurrence</string>\n  <string key=\"shortcut.multi_cursor\">Add cursor</string>\n  <string key=\"shortcut.fold\">Fold / unfold block</string>\n  <string key=\"shortcut.zoom\">Text size</string>\n  <string key=\"shortcut.explorer\">Rename / delete (in the explorer)</string>\n  <string key=\"shortcut.drag_move\">Move a file or folder (in the explorer)</string>\n  <string key=\"key.drag\">Drag</string>\n  <string key=\"key.space\">Space</string>\n  <string key=\"key.click\">Click</string>\n\n  <string key=\"tabs.aria\">Open files</string>\n  <string key=\"tabs.binary\">\"{name}\" is a binary file and can't be edited as text.</string>\n  <string key=\"tabs.open_failed\">Couldn't open \"{name}\": {error}</string>\n  <string key=\"tabs.memory_saved\">Limited mode: \"{name}\" was downloaded.</string>\n  <string key=\"tabs.save_failed\">Couldn't save \"{name}\": {error}</string>\n  <plural key=\"tabs.saved_count\">\n    <one>Saved {n} file</one>\n    <other>Saved {n} files</other>\n  </plural>\n  <string key=\"tabs.unsaved_title\">Unsaved changes</string>\n  <string key=\"tabs.unsaved_text\">\"{name}\" has unsaved changes. Save them before closing?</string>\n  <string key=\"tabs.dont_save\">Don't save</string>\n  <string key=\"tabs.not_on_disk\">(not saved to disk)</string>\n  <string key=\"tabs.close_named\">Close {name}</string>\n  <string key=\"tabs.close\">Close</string>\n  <string key=\"tabs.close_others\">Close others</string>\n  <string key=\"tabs.close_all\">Close all</string>\n  <string key=\"tabs.move_left\">Move left</string>\n  <string key=\"tabs.move_right\">Move right</string>\n\n  <string key=\"explorer.read_error\">Can't read the folder: {error}</string>\n  <string key=\"explorer.empty\">The folder is empty. Create the first file with the \"+\" button above.</string>\n  <string key=\"explorer.new_file\">New file</string>\n  <string key=\"explorer.new_file_label\">File name (may include a subfolder, e.g. css/style.css)</string>\n  <string key=\"explorer.new_file_label_in\">File name in \"{dir}/\" (may include a subfolder, e.g. css/style.css)</string>\n  <string key=\"explorer.new_folder\">New folder</string>\n  <string key=\"explorer.new_folder_label\">Folder name</string>\n  <string key=\"explorer.new_folder_label_in\">Folder name in \"{dir}/\"</string>\n  <string key=\"explorer.rename_title\">Rename</string>\n  <string key=\"explorer.rename_label\">New name</string>\n  <string key=\"explorer.invalid_name\">The name contains characters that aren't allowed.</string>\n  <string key=\"explorer.rename_failed\">Couldn't rename: {error}</string>\n  <string key=\"explorer.delete_file_confirm\">Delete the file \"{path}\"? This can't be undone.</string>\n  <string key=\"explorer.delete_folder_confirm\">Delete the folder \"{path}\" and everything in it? This can't be undone.</string>\n  <string key=\"explorer.delete_failed\">Couldn't delete: {error}</string>\n  <plural key=\"explorer.delete_many_confirm\">\n    <one>Delete {n} item? This can't be undone.</one>\n    <other>Delete {n} items? This can't be undone.</other>\n  </plural>\n  <plural key=\"explorer.moved_many\">\n    <one>Moved {n} item to \"{dir}\".</one>\n    <other>Moved {n} items to \"{dir}\".</other>\n  </plural>\n  <string key=\"explorer.moved\">Moved \"{name}\" to \"{dir}\".</string>\n  <string key=\"explorer.move_failed\">Couldn't move: {error}</string>\n  <string key=\"explorer.copy_path\">Copy path</string>\n  <string key=\"explorer.copied\">Copied: {path}</string>\n  <string key=\"explorer.refresh\">Refresh</string>\n  <string key=\"explorer.collapse\">Collapse all</string>\n\n  <string key=\"fs.exists\">\"{path}\" already exists.</string>\n  <string key=\"fs.not_found\">File \"{path}\" was not found.</string>\n  <string key=\"fs.no_permission\">Permission to write the file was denied.</string>\n\n  <string key=\"preview.title\">Preview</string>\n  <string key=\"preview.empty\">Open an HTML or PHP file to see a live preview.</string>\n  <string key=\"preview.refresh\">Refresh preview</string>\n  <string key=\"preview.new_window\">Open in a new window</string>\n  <string key=\"preview.close\">Close preview</string>\n  <string key=\"preview.frame_title\">Page preview</string>\n  <string key=\"preview.error\">JavaScript error</string>\n  <string key=\"preview.error_line\">{message} (line {line})</string>\n  <string key=\"preview.missing\">Missing file: {path}</string>\n  <string key=\"preview.page_not_found\">Page \"{path}\" was not found.</string>\n  <string key=\"preview.problems_title\">Preview problems</string>\n  <plural key=\"preview.problems\">\n    <one>{n} problem</one>\n    <other>{n} problems</other>\n  </plural>\n\n  <string key=\"status.no_folder\">No folder</string>\n  <string key=\"status.disk\">Local folder: {name}</string>\n  <string key=\"status.memory\">Limited mode: {name}</string>\n  <string key=\"status.image\">Image</string>\n  <string key=\"status.plain_text\">Plain text</string>\n  <string key=\"status.spaces\">Spaces: {n}</string>\n  <string key=\"status.position\">Ln {line}, Col {col}</string>\n  <string key=\"status.selected\">({n} selected)</string>\n  <string key=\"status.cursors\">cursors: {n}</string>\n\n\n  <string key=\"about.text\">A local web page editor by WebOrbiton.</string>\n  <string key=\"about.license\">License: {license}</string>\n  <string key=\"about.ui\">Interface: {name}</string>\n  <string key=\"about.engine\">Editor engine: {name}</string>\n  <string key=\"about.translation\">Translation: {name}</string>\n\n  <string key=\"menu.settings\">Settings…</string>\n  <string key=\"top.settings\">Settings (Ctrl+,)</string>\n  <string key=\"shortcut.settings\">Settings</string>\n  <string key=\"status.tabs\">Tab size: {n}</string>\n  <string key=\"settings.title\">Settings</string>\n  <string key=\"settings.section_appearance\">Appearance</string>\n  <string key=\"settings.section_editor\">Editor</string>\n  <string key=\"settings.section_files\">Files and preview</string>\n  <string key=\"settings.section_fonts\">Fonts</string>\n  <string key=\"settings.language\">Language</string>\n  <string key=\"settings.theme\">Theme</string>\n  <string key=\"settings.theme_system\">System</string>\n  <string key=\"settings.theme_light\">Light</string>\n  <string key=\"settings.theme_dark\">Dark</string>\n  <string key=\"settings.accent\">Accent color</string>\n  <string key=\"settings.ui_font\">Interface font</string>\n  <string key=\"settings.code_font\">Code font</string>\n  <string key=\"settings.font_system\">System default</string>\n  <string key=\"settings.font_size\">Font size</string>\n  <string key=\"settings.line_height\">Line height</string>\n  <string key=\"settings.tab_size\">Tab size</string>\n  <string key=\"settings.indent\">Indentation</string>\n  <string key=\"settings.indent_spaces\">Spaces</string>\n  <string key=\"settings.indent_tabs\">Tabs</string>\n  <string key=\"settings.wrap\">Word wrap</string>\n  <string key=\"settings.line_numbers\">Line numbers</string>\n  <string key=\"settings.active_line\">Highlight current line</string>\n  <string key=\"settings.fold\">Code folding</string>\n  <string key=\"settings.close_brackets\">Auto-close brackets and quotes</string>\n  <string key=\"settings.autocomplete\">Suggestions while typing</string>\n  <string key=\"settings.match_highlight\">Highlight selection matches</string>\n  <string key=\"settings.auto_save\">Auto save</string>\n  <string key=\"settings.auto_save_hint\">Saves a file one second after the last change and when you switch windows. Works for files on disk.</string>\n  <string key=\"settings.live_preview\">Refresh preview while typing</string>\n  <string key=\"settings.live_preview_hint\">When off, the preview refreshes on save.</string>\n  <string key=\"settings.fonts_hint\">Fonts uploaded here are kept in this browser. To add a font permanently, put the file in assets/fonts and list it in assets/fonts/fonts.css (see README).</string>\n  <string key=\"settings.fonts_none\">No uploaded fonts.</string>\n  <string key=\"settings.font_upload\">Add font (TTF, OTF, WOFF)…</string>\n  <string key=\"settings.font_name_title\">Font name</string>\n  <string key=\"settings.font_name_label\">The font will appear in the list under this name</string>\n  <string key=\"settings.font_added\">Font added: {name}</string>\n  <string key=\"settings.font_invalid\">Couldn't load the font: {error}</string>\n  <string key=\"settings.font_remove\">Remove font {name}</string>\n  <string key=\"settings.reset\">Restore defaults</string>\n  <string key=\"settings.reset_done\">Default settings restored.</string>\n\n  <string key=\"menu.edit\">Edit</string>\n  <string key=\"cmd.undo\">Undo</string>\n  <string key=\"cmd.redo\">Redo</string>\n  <string key=\"cmd.cut\">Cut</string>\n  <string key=\"cmd.copy\">Copy</string>\n  <string key=\"cmd.paste\">Paste</string>\n  <string key=\"cmd.cut_line\">Cut line</string>\n  <string key=\"cmd.copy_line\">Copy line</string>\n  <string key=\"cmd.select_occurrences\">Select all occurrences</string>\n  <string key=\"cmd.toggle_comment\">Toggle comment</string>\n  <string key=\"cmd.duplicate_line\">Duplicate line</string>\n  <string key=\"cmd.delete_line\">Delete line</string>\n  <string key=\"cmd.indent_more\">Indent</string>\n  <string key=\"cmd.indent_less\">Outdent</string>\n  <string key=\"cmd.fold_all\">Fold all</string>\n  <string key=\"cmd.unfold_all\">Unfold all</string>\n  <string key=\"cmd.suggest\">Trigger suggestions</string>\n  <string key=\"cmd.format\">Format document</string>\n  <string key=\"cmd.quick_open\">Quick open file</string>\n  <string key=\"cmd.command_palette\">Command palette</string>\n  <string key=\"cmd.goto_line\">Go to line</string>\n  <string key=\"cmd.problems\">Problems</string>\n  <string key=\"cmd.next_problem\">Next problem</string>\n  <string key=\"cmd.toggle_theme\">Toggle light / dark theme</string>\n  <string key=\"cmd.emmet_wrap\">Emmet: wrap with abbreviation</string>\n  <string key=\"cmd.emmet_balance_out\">Emmet: balance outward</string>\n  <string key=\"cmd.emmet_balance_in\">Emmet: balance inward</string>\n  <string key=\"cmd.emmet_remove_tag\">Emmet: remove tag</string>\n  <string key=\"cmd.emmet_tag_pair\">Emmet: go to matching pair</string>\n  <string key=\"cmd.emmet_split_join\">Emmet: split / join tag</string>\n  <string key=\"cmd.emmet_math\">Emmet: evaluate math expression</string>\n  <string key=\"cmd.emmet_next_edit\">Emmet: next edit point</string>\n  <string key=\"cmd.emmet_prev_edit\">Emmet: previous edit point</string>\n  <string key=\"cmd.emmet_increment\">Emmet: increment number by 1</string>\n  <string key=\"cmd.emmet_decrement\">Emmet: decrement number by 1</string>\n  <string key=\"palette.title\">Palette</string>\n  <string key=\"palette.placeholder\">Search files · &gt; commands · : line number</string>\n  <string key=\"palette.no_editor\">Open a file in the editor first.</string>\n  <string key=\"palette.line_hint\">Type a line number (1–{max}), e.g. :12 or :12:5</string>\n  <string key=\"palette.go_line\">Go to line {line}</string>\n  <string key=\"palette.open_tab\">open tab</string>\n  <string key=\"palette.no_folder\">Open a folder to search project files. Type &gt; for commands.</string>\n  <string key=\"palette.loading\">Loading file list…</string>\n  <string key=\"palette.no_results\">No results</string>\n  <string key=\"format.load_failed\">Couldn't load the formatter.</string>\n  <string key=\"format.unsupported\">Formatting isn't available for this file type.</string>\n  <string key=\"format.error_line\">Can't format, error on line {line}: {error}</string>\n  <string key=\"format.error\">Can't format: {error}</string>\n  <string key=\"format.unchanged\">The code is already formatted.</string>\n  <string key=\"lint.syntax\">Syntax error</string>\n  <string key=\"lint.mismatched\">Closing tag {tag} doesn't match the open element</string>\n  <string key=\"lint.unclosed\">Tag &lt;{tag}&gt; is not closed</string>\n  <string key=\"lint.img_alt\">Image has no alt attribute (important for accessibility and SEO)</string>\n  <string key=\"lint.fix_alt\">Add alt</string>\n  <string key=\"lint.blank_rel\">A link opened in a new tab should have rel=\"noopener\"</string>\n  <string key=\"lint.fix_rel\">Add rel</string>\n  <string key=\"lint.deprecated\">The &lt;{tag}&gt; tag is obsolete, use CSS instead</string>\n  <string key=\"lint.duplicate_id\">The id \"{id}\" is used more than once</string>\n  <string key=\"lint.doctype\">Missing &lt;!DOCTYPE html&gt; declaration</string>\n  <string key=\"lint.lang\">The &lt;html&gt; element has no lang attribute</string>\n  <string key=\"lint.charset\">Missing &lt;meta charset&gt; (special characters may display incorrectly)</string>\n  <string key=\"lint.viewport\">Missing meta viewport (the page won't fit on phones)</string>\n  <string key=\"lint.title\">Missing &lt;title&gt; tag</string>\n  <string key=\"lint.fix_add\">Add</string>\n  <string key=\"settings.emmet\">Emmet</string>\n  <string key=\"settings.emmet_hint\">Abbreviations like ! or ul&gt;li*3 expanded with Tab, automatic renaming of tag pairs.</string>\n  <string key=\"settings.smart_suggest\">Smart block suggestions</string>\n  <string key=\"settings.smart_suggest_hint\">After Enter in an empty &lt;head&gt;, &lt;body&gt;, list or form, a list of ready-made layouts opens automatically.</string>\n  <string key=\"settings.lint_hints\">Problem detection</string>\n  <string key=\"settings.lint_hints_hint\">Syntax errors and HTML hints (alt, lang, viewport, unclosed tags) with an \"Add\" button.</string>\n  <string key=\"settings.format_on_save\">Format on save</string>\n  <string key=\"settings.format_on_save_hint\">Code is cleaned up with Prettier before saving (HTML, CSS, JS, PHP, JSON).</string>\n  <string key=\"editor.paste_blocked\">The browser blocked clipboard access. Use Ctrl+V.</string>\n  <string key=\"shortcut.emmet\">Expand Emmet abbreviation / accept suggestion</string>\n\n  <string key=\"settings.mysql_emulation\">MySQL emulation (BETA)</string>\n  <string key=\"settings.mysql_emulation_hint\">Scripts using mysqli or PDO(\"mysql:…\") run in the preview on an in-memory SQLite database instead of a MySQL server. A .sql dump from the project is imported automatically. Not every MySQL feature is supported.</string>\n  <string key=\"php.loading\">Starting PHP 8.3… (first time only)</string>\n  <string key=\"php.load_failed\">Couldn't load the PHP engine.</string>\n  <string key=\"php.syncing\">Preparing project files for PHP: {done} of {total}…</string>\n  <string key=\"php.sync_timeout\">Copying project files to PHP took longer than {s} s. Try refreshing the preview.</string>\n  <string key=\"php.timeout\">The PHP script ran longer than {s} s and was stopped.</string>\n  <string key=\"php.stopped\">The PHP engine was stopped.</string>\n  <string key=\"php.failed_title\">PHP could not be executed</string>\n  <string key=\"php.redirect_external\">Redirect to an external address: {url}</string>\n  <string key=\"php.redirect_loop\">Too many redirects</string>\n  <string key=\"php.redirect_missing\">Redirect to a file that doesn't exist: {url}</string>\n  <string key=\"php.restarted\">PHP restarted (sessions and cookies cleared).</string>\n  <string key=\"cmd.php_restart\">PHP: restart (clear sessions)</string>\n  <string key=\"settings.php_runtime\">Run PHP in the preview</string>\n  <string key=\"settings.php_runtime_hint\">Real PHP 8.3 in the browser: include, sessions, forms, SQLite. The engine (about 9 MB) loads on the first .php preview.</string>\n\n  <string key=\"cmd.search_in_files\">Search in files</string>\n  <string key=\"search.title\">Search</string>\n  <string key=\"search.placeholder\">Search in files</string>\n  <string key=\"search.replace_placeholder\">Replace with</string>\n  <string key=\"search.files_placeholder\">Files: *.css, src/, !vendor/</string>\n  <string key=\"search.case\">Match case</string>\n  <string key=\"search.word\">Whole word</string>\n  <string key=\"search.regex\">Regular expression</string>\n  <string key=\"search.toggle_replace\">Show or hide replace</string>\n  <string key=\"search.clear\">Clear</string>\n  <string key=\"search.stop\">Stop</string>\n  <string key=\"search.running\">Searching… {done} of {total} files</string>\n  <string key=\"search.progress\">searched {done} of {total} files</string>\n  <string key=\"search.show_more\">Show more results (searched {done} of {total} files)</string>\n  <string key=\"search.no_results\">No results</string>\n  <string key=\"search.bad_regex\">Invalid pattern: {error}</string>\n  <string key=\"search.truncated\">Showing the first {n} matches in this file</string>\n  <string key=\"search.replace_all\">Replace all</string>\n  <string key=\"search.undo_replace\">Undo last replace</string>\n  <string key=\"search.undo_empty\">There is no replace to undo.</string>\n  <string key=\"search.undone\">Reverted changes {files}.</string>\n  <string key=\"search.undo_skipped\">Skipped {files} (changed since the replace).</string>\n  <string key=\"search.replace_in_file\">Replace in this file</string>\n  <string key=\"search.replace_one\">Replace</string>\n  <string key=\"search.replacing\">Replacing… {done} of {total} files</string>\n  <string key=\"search.stale\">The text has changed since the search. Results refreshed.</string>\n  <string key=\"search.replace_failed\">Couldn't change \"{name}\": {error}</string>\n  <string key=\"search.confirm_title\">Replace in files</string>\n  <string key=\"search.confirm_partial\">The search isn't finished, so only the results loaded so far will be replaced.</string>\n  <string key=\"search.confirm_more\">Some files have more matches than shown; all matches in those files will be replaced.</string>\n  <string key=\"search.confirm_open\">Open files are changed but not saved (undo with Ctrl+Z). Other files are written to disk immediately. You can revert the whole replace with the undo button next to \"Replace all\" until you close or switch the folder.</string>\n  <plural key=\"search.n_matches\">\n    <one>{n} match</one>\n    <other>{n} matches</other>\n  </plural>\n  <plural key=\"search.n_files\">\n    <one>{n} file</one>\n    <other>{n} files</other>\n  </plural>\n  <plural key=\"search.in_n_files\">\n    <one>in {n} file</one>\n    <other>in {n} files</other>\n  </plural>\n  <plural key=\"search.confirm_text\">\n    <one>Replace {n} match {files}?</one>\n    <other>Replace {n} matches {files}?</other>\n  </plural>\n  <plural key=\"search.replaced\">\n    <one>Replaced {n} match</one>\n    <other>Replaced {n} matches</other>\n  </plural>\n\n  <string key=\"backup.started\">Creating backup…</string>\n  <string key=\"backup.done\">Backup saved: {path}</string>\n  <string key=\"backup.downloaded\">Backup downloaded: \"{name}\".</string>\n  <string key=\"backup.too_large\">The project is too large for a single ZIP archive (limit: 4 GB per file and 65535 entries).</string>\n\n  <string key=\"drop.hint\">Drop a folder or files to open them</string>\n</language>"};
  
assets/app/mysql-shim.js Added +2 -0
+ (window.Athera = window.Athera || {}).mysqlShim = "<?php\n\nfinal class AthMy\n{\n    const ID = '(?:`[^`]+`|[A-Za-z_\\x80-\\xff][\\w$\\x80-\\xff]*)';\n    const NOOP = 'SELECT 1 WHERE 0';\n    const OPT = \"\\0\";\n\n    public static $dir = '/tmp/athera-mysql';\n    public static $root = '/www';\n    public static $db = 'default';\n    public static $report = 3;\n    public static $dump = null;\n    public static $problems = [];\n    private static $likeCache = [];\n\n    public static function unescape(string $e): string\n    {\n        switch ($e) {\n            case 'n': return \"\\n\";\n            case 'r': return \"\\r\";\n            case 't': return \"\\t\";\n            case '0': return \"\\0\";\n            case 'Z': return \"\\x1a\";\n            case 'b': return \"\\x08\";\n            case '%': return '\\\\%';\n            case '_': return '\\\\_';\n        }\n        return $e;\n    }\n\n    public static function mask(string $sql, array &$lits): string\n    {\n        $re = '~\\'((?:[^\\'\\\\\\\\]|\\\\\\\\.|\\'\\')*)\\'|\"((?:[^\"\\\\\\\\]|\\\\\\\\.|\"\")*)\"|(`[^`]*`)|(--(?:[ \\t\\r\\n]|$)[^\\n]*)|(#[^\\n]*)|(/\\*.*?\\*/)~s';\n        return preg_replace_callback($re, function ($m) use (&$lits) {\n            if ($m[1] !== null) {\n                $q = \"'\";\n                $v = $m[1];\n            } elseif ($m[2] !== null) {\n                $q = '\"';\n                $v = $m[2];\n            } elseif ($m[3] !== null) {\n                return $m[3];\n            } else {\n                return ' ';\n            }\n            $v = preg_replace_callback('~\\\\\\\\(.)|\\'\\'|\"\"~s', function ($x) use ($q) {\n                if ($x[0][0] === '\\\\') return AthMy::unescape($x[1]);\n                return $x[0] === $q . $q ? $q : $x[0];\n            }, $v);\n            $lits[] = $v;\n            return \"\\x01\" . (count($lits) - 1) . \"\\x02\";\n        }, $sql, -1, $count, PREG_UNMATCHED_AS_NULL);\n    }\n\n    public static function unmask(string $s, array $lits): string\n    {\n        if (strpos($s, \"\\x01\") === false) return $s;\n        return preg_replace_callback('~\\x01(\\d+)\\x02~', function ($m) use ($lits) {\n            return \"'\" . str_replace(\"'\", \"''\", $lits[(int)$m[1]]) . \"'\";\n        }, $s);\n    }\n\n    public static function splitSql(string $masked): array\n    {\n        $out = [];\n        foreach (preg_split('~`[^`]*`(*SKIP)(*FAIL)|;~', $masked) as $part) {\n            $part = trim($part);\n            if ($part !== '') $out[] = $part;\n        }\n        return $out;\n    }\n\n    public static function splitTop(string $s, string $sep = ','): array\n    {\n        $out = [];\n        $cur = '';\n        $depth = 0;\n        $n = strlen($s);\n        for ($i = 0; $i < $n; $i++) {\n            $c = $s[$i];\n            if ($c === '`') {\n                $j = strpos($s, '`', $i + 1);\n                if ($j === false) $j = $n - 1;\n                $cur .= substr($s, $i, $j - $i + 1);\n                $i = $j;\n                continue;\n            }\n            if ($c === '(') $depth++;\n            elseif ($c === ')') $depth--;\n            if ($c === $sep && $depth === 0) {\n                $out[] = $cur;\n                $cur = '';\n                continue;\n            }\n            $cur .= $c;\n        }\n        $out[] = $cur;\n        return $out;\n    }\n\n    public static function unq(string $id): string\n    {\n        return trim($id, '`');\n    }\n\n    public static function quote(string $name): string\n    {\n        return '\"' . str_replace('\"', '\"\"', $name) . '\"';\n    }\n\n    public static function isQuery(string $sql): bool\n    {\n        $lits = [];\n        $m = ltrim(self::mask(substr($sql, 0, 400), $lits), \" \\t\\r\\n(\");\n        return (bool)preg_match('/^(SELECT|SHOW|DESCRIBE|DESC|EXPLAIN|WITH|VALUES|TABLE|PRAGMA)\\b/i', $m);\n    }\n\n    public static function kind(string $sql): string\n    {\n        $lits = [];\n        $m = ltrim(self::mask(substr($sql, 0, 400), $lits), \" \\t\\r\\n(\");\n        return preg_match('/^([A-Za-z]+)/', $m, $w) ? strtoupper($w[1]) : '';\n    }\n\n    public static function translate(string $sql): array\n    {\n        $lits = [];\n        $masked = self::mask($sql, $lits);\n        $out = [];\n        foreach (self::splitSql($masked) as $stmt) {\n            foreach (self::convert($stmt) as $one) {\n                $out[] = self::unmask($one, $lits);\n            }\n        }\n        return $out;\n    }\n\n    public static function convert(string $s): array\n    {\n        $s = trim($s);\n        if ($s === '') return [];\n        preg_match('/^\\(*\\s*([A-Za-z_]+)/', $s, $w);\n        $word = isset($w[1]) ? strtoupper($w[1]) : '';\n        switch ($word) {\n            case 'SET':\n                return self::convertSet($s);\n            case 'USE':\n            case 'LOCK':\n            case 'UNLOCK':\n            case 'FLUSH':\n            case 'OPTIMIZE':\n            case 'ANALYZE':\n            case 'REPAIR':\n            case 'CHECK':\n            case 'GRANT':\n            case 'REVOKE':\n            case 'KILL':\n            case 'DELIMITER':\n            case 'COMMENT':\n                return [self::NOOP];\n            case 'START':\n                return ['BEGIN'];\n            case 'CREATE':\n                if (preg_match('/^CREATE\\s+(?:DATABASE|SCHEMA|USER|ROLE)\\b/i', $s)) return [self::NOOP];\n                if (preg_match('/^CREATE\\s+(?:TEMPORARY\\s+)?TABLE\\b/i', $s)) return self::createTable($s);\n                if (preg_match('/^CREATE\\s+(?:UNIQUE\\s+|FULLTEXT\\s+|SPATIAL\\s+)?INDEX\\b/i', $s)) return self::createIndex($s);\n                if (preg_match('/^CREATE\\s+(?:OR\\s+REPLACE\\s+)?(?:ALGORITHM\\s*=\\s*\\w+\\s+)?(?:DEFINER\\s*=\\s*\\S+\\s+)?(?:SQL\\s+SECURITY\\s+\\w+\\s+)?VIEW\\b/i', $s)) {\n                    $s = preg_replace('/^CREATE\\s+(?:OR\\s+REPLACE\\s+)?(?:ALGORITHM\\s*=\\s*\\w+\\s+)?(?:DEFINER\\s*=\\s*\\S+\\s+)?(?:SQL\\s+SECURITY\\s+\\w+\\s+)?VIEW/i', 'CREATE VIEW', $s);\n                    return [self::dml($s)];\n                }\n                return [$s];\n            case 'DROP':\n                if (preg_match('/^DROP\\s+(?:DATABASE|SCHEMA|USER|ROLE)\\b/i', $s)) return [self::NOOP];\n                if (preg_match('/^DROP\\s+(?:TEMPORARY\\s+)?TABLE\\b/i', $s)) return self::dropTable($s);\n                if (preg_match('/^DROP\\s+INDEX\\b/i', $s)) return self::dropIndex($s);\n                return [self::dml($s)];\n            case 'ALTER':\n                return self::alterTable($s);\n            case 'TRUNCATE':\n                return self::truncate($s);\n            case 'RENAME':\n                return self::renameTable($s);\n            case 'SHOW':\n            case 'DESCRIBE':\n            case 'DESC':\n                return self::show($s);\n            case 'EXPLAIN':\n                if (preg_match('/^EXPLAIN\\s+(?:SELECT|INSERT|UPDATE|DELETE|REPLACE|WITH|FORMAT|ANALYZE)\\b/i', $s)) {\n                    return ['EXPLAIN QUERY PLAN ' . self::dml(preg_replace('/^EXPLAIN\\s+(?:(?:FORMAT|EXTENDED|PARTITIONS)\\s*(?:=\\s*\\w+)?\\s+)?/i', '', $s))];\n                }\n                return self::show($s);\n        }\n        return [self::dml($s)];\n    }\n\n    public static function convertSet(string $s): array\n    {\n        if (preg_match('/^SET\\s+(?:@@(?:SESSION\\.|GLOBAL\\.)?|SESSION\\s+|GLOBAL\\s+)?FOREIGN_KEY_CHECKS\\s*=\\s*(\\w+)/i', $s, $m)) {\n            return ['PRAGMA foreign_keys = ' . (in_array(strtoupper($m[1]), ['0', 'OFF', 'FALSE'], true) ? 'OFF' : 'ON')];\n        }\n        return [self::NOOP];\n    }\n\n    public static function cleanCols(string $cols): string\n    {\n        return trim(preg_replace('/\\(\\s*\\d+\\s*\\)/', '', $cols));\n    }\n\n    public static function indexName(string $table, ?string $name, string $cols): string\n    {\n        if ($name === null || $name === '') {\n            $first = trim(explode(',', $cols)[0]);\n            $first = preg_replace('/\\s+(ASC|DESC)$/i', '', $first);\n            $name = preg_replace('/[^\\w]+/', '_', self::unq($first));\n        }\n        return self::quote(self::unq($table) . '_' . self::unq($name));\n    }\n\n    public static function tableName(string $q, ?string $t): string\n    {\n        return ($t !== null && $t !== '') ? $t : $q;\n    }\n\n    public static function parseColumn(string $name, string $rest): array\n    {\n        $auto = (bool)preg_match('/\\bAUTO_INCREMENT\\b/i', $rest);\n        $rest = preg_replace('/\\bAUTO_INCREMENT\\b/i', '', $rest);\n        $type = 'NUM';\n        $text = false;\n        $after = $rest;\n        if (preg_match('/^\\s*([A-Za-z]+)(?:\\s+VARYING)?(\\s*\\(([^)]*)\\))?/', $rest, $t)) {\n            $base = strtoupper($t[1]);\n            $args = isset($t[3]) ? $t[3] : '';\n            $after = substr($rest, strlen($t[0]));\n            if ($base === 'ENUM' || $base === 'SET' || $base === 'JSON') {\n                $type = 'TEXT';\n                $text = true;\n            } elseif (in_array($base, ['CHAR', 'VARCHAR', 'NCHAR', 'NVARCHAR', 'CHARACTER', 'TINYTEXT', 'TEXT', 'MEDIUMTEXT', 'LONGTEXT'], true)) {\n                $type = $base . ($args !== '' ? '(' . $args . ')' : '');\n                $text = true;\n            } else {\n                $type = $base . ($args !== '' ? '(' . $args . ')' : '');\n            }\n        }\n        $after = preg_replace('/\\b(?:UNSIGNED|ZEROFILL|SIGNED)\\b/i', '', $after);\n        $after = preg_replace('/\\b(?:CHARACTER\\s+SET|CHAR\\s+SET|CHARSET)\\s+\\w+/i', '', $after);\n        $binary = false;\n        if (preg_match('/\\bCOLLATE\\s+(\\w+)/i', $after, $c)) {\n            $binary = stripos($c[1], 'bin') !== false;\n            $after = preg_replace('/\\bCOLLATE\\s+\\w+/i', '', $after);\n        }\n        $after = preg_replace('/\\bCOMMENT\\s+\\x01\\d+\\x02/i', '', $after);\n        $after = preg_replace('/\\bON\\s+UPDATE\\s+(?:CURRENT_TIMESTAMP|NOW|LOCALTIME(?:STAMP)?)\\s*(?:\\(\\s*\\d*\\s*\\))?/i', '', $after);\n        $after = preg_replace('/\\bDEFAULT\\s+(?:CURRENT_TIMESTAMP|NOW|LOCALTIME(?:STAMP)?)\\s*(?:\\(\\s*\\d*\\s*\\))?/i', 'DEFAULT (now())', $after);\n        $after = preg_replace('/\\bUNIQUE\\s+KEY\\b/i', 'UNIQUE', $after);\n        $after = preg_replace('/\\b(?:VISIBLE|INVISIBLE)\\b/i', '', $after);\n        $attrs = trim(preg_replace('/\\s+/', ' ', $after));\n        if ($text && !$binary) $attrs = trim($attrs . ' COLLATE NOCASE');\n        return ['name' => $name, 'type' => $type, 'attrs' => $attrs, 'auto' => $auto];\n    }\n\n    public static function parseCreate(string $s): ?array\n    {\n        $I = self::ID;\n        if (!preg_match('/^CREATE\\s+(TEMPORARY\\s+)?TABLE\\s+(IF\\s+NOT\\s+EXISTS\\s+)?(' . $I . ')(?:\\s*\\.\\s*(' . $I . '))?\\s*\\(/is', $s, $m, PREG_OFFSET_CAPTURE)) return null;\n        $name = (isset($m[4]) && $m[4][0] !== '') ? $m[4][0] : $m[3][0];\n        $open = $m[0][1] + strlen($m[0][0]) - 1;\n        $n = strlen($s);\n        $depth = 0;\n        $close = null;\n        for ($i = $open; $i < $n; $i++) {\n            $c = $s[$i];\n            if ($c === '`') {\n                $j = strpos($s, '`', $i + 1);\n                if ($j === false) return null;\n                $i = $j;\n                continue;\n            }\n            if ($c === '(') $depth++;\n            elseif ($c === ')') {\n                $depth--;\n                if ($depth === 0) {\n                    $close = $i;\n                    break;\n                }\n            }\n        }\n        if ($close === null) return null;\n        $st = [\n            'temp' => trim($m[1][0]) !== '',\n            'ine' => trim($m[2][0]) !== '',\n            'name' => $name,\n            'cols' => [],\n            'pk' => [],\n            'uniq' => [],\n            'idx' => [],\n            'fks' => [],\n            'checks' => [],\n            'seq' => null\n        ];\n        if (preg_match('/\\bAUTO_INCREMENT\\s*=\\s*(\\d+)/i', substr($s, $close + 1), $q)) $st['seq'] = (int)$q[1];\n        foreach (self::splitTop(substr($s, $open + 1, $close - $open - 1)) as $part) {\n            $part = trim($part);\n            if ($part === '') continue;\n            if (preg_match('/^(?:CONSTRAINT\\s+(?:' . $I . '\\s+)?)?PRIMARY\\s+KEY\\s*(?:USING\\s+\\w+\\s*)?\\((.*)\\)/is', $part, $x)) {\n                $st['pk'] = array_map('trim', explode(',', self::cleanCols($x[1])));\n            } elseif (preg_match('/^(?:CONSTRAINT\\s+(?:' . $I . '\\s+)?)?UNIQUE(?:\\s+(?:KEY|INDEX))?\\s*(?:' . $I . ')?\\s*(?:USING\\s+\\w+\\s*)?\\((.*)\\)/is', $part, $x)) {\n                $st['uniq'][] = self::cleanCols($x[1]);\n            } elseif (preg_match('/^(?:FULLTEXT\\s+|SPATIAL\\s+)?(?:KEY|INDEX)\\s*(' . $I . ')?\\s*(?:USING\\s+\\w+\\s*)?\\((.*)\\)/is', $part, $x)) {\n                $st['idx'][] = ['name' => $x[1] !== '' ? $x[1] : null, 'cols' => self::cleanCols($x[2]), 'unique' => false];\n            } elseif (preg_match('/^(?:CONSTRAINT\\s+(?:' . $I . '\\s+)?)?FOREIGN\\s+KEY/i', $part)) {\n                $st['fks'][] = preg_replace('/FOREIGN\\s+KEY\\s+(?!\\()' . $I . '\\s*/i', 'FOREIGN KEY ', $part);\n            } elseif (preg_match('/^(?:CONSTRAINT\\s+(?:' . $I . '\\s+)?)?CHECK\\b/i', $part)) {\n                $st['checks'][] = $part;\n            } elseif (preg_match('/^(' . $I . ')\\s+(.*)$/s', $part, $x)) {\n                $st['cols'][] = self::parseColumn($x[1], $x[2]);\n            }\n        }\n        return $st;\n    }\n\n    public static function buildCreate(array $st): array\n    {\n        $lines = [];\n        $auto = false;\n        foreach ($st['cols'] as $c) {\n            if ($c['auto']) {\n                $auto = true;\n                $lines[] = $c['name'] . ' INTEGER PRIMARY KEY AUTOINCREMENT';\n            } else {\n                $lines[] = trim($c['name'] . ' ' . $c['type'] . ' ' . $c['attrs']);\n            }\n        }\n        if ($st['pk'] && !$auto) $lines[] = 'PRIMARY KEY (' . implode(', ', $st['pk']) . ')';\n        foreach ($st['uniq'] as $u) $lines[] = 'UNIQUE (' . $u . ')';\n        foreach ($st['fks'] as $f) $lines[] = $f;\n        foreach ($st['checks'] as $f) $lines[] = $f;\n        $out = ['CREATE ' . ($st['temp'] ? 'TEMPORARY ' : '') . 'TABLE ' . ($st['ine'] ? 'IF NOT EXISTS ' : '') . $st['name'] . \" (\\n  \" . implode(\",\\n  \", $lines) . \"\\n)\"];\n        foreach ($st['idx'] as $i) {\n            $out[] = 'CREATE ' . ($i['unique'] ? 'UNIQUE ' : '') . 'INDEX IF NOT EXISTS ' . self::indexName($st['name'], $i['name'], $i['cols']) . ' ON ' . $st['name'] . ' (' . $i['cols'] . ')';\n        }\n        return $out;\n    }\n\n    public static function createTable(string $s): array\n    {\n        $st = self::parseCreate($s);\n        if ($st === null) {\n            $s = preg_replace('/^CREATE\\s+(TEMPORARY\\s+)?TABLE\\s+(IF\\s+NOT\\s+EXISTS\\s+)?(' . self::ID . ')\\s*\\.\\s*(' . self::ID . ')/i', 'CREATE $1TABLE $2$4', $s);\n            if (preg_match('/^(CREATE\\s+(?:TEMPORARY\\s+)?TABLE\\s+(?:IF\\s+NOT\\s+EXISTS\\s+)?' . self::ID . ')\\s+LIKE\\s+(' . self::ID . ')(?:\\s*\\.\\s*(' . self::ID . '))?/i', $s, $m)) {\n                $src = (isset($m[3]) && $m[3] !== '') ? $m[3] : $m[2];\n                return [$m[1] . ' AS SELECT * FROM ' . $src . ' WHERE 0'];\n            }\n            return [self::dml($s)];\n        }\n        return self::buildCreate($st);\n    }\n\n    public static function createIndex(string $s): array\n    {\n        $I = self::ID;\n        if (!preg_match('/^CREATE\\s+(UNIQUE\\s+)?(?:FULLTEXT\\s+|SPATIAL\\s+)?INDEX\\s+(IF\\s+NOT\\s+EXISTS\\s+)?(' . $I . ')\\s*(?:USING\\s+\\w+\\s*)?ON\\s+(' . $I . ')(?:\\s*\\.\\s*(' . $I . '))?\\s*\\((.*?)\\)\\s*(?:USING\\s+\\w+)?\\s*$/is', $s, $m)) return [self::NOOP];\n        $table = (isset($m[5]) && $m[5] !== '') ? $m[5] : $m[4];\n        $cols = self::cleanCols($m[6]);\n        return ['CREATE ' . (trim($m[1]) !== '' ? 'UNIQUE ' : '') . 'INDEX IF NOT EXISTS ' . self::indexName($table, $m[3], $cols) . ' ON ' . $table . ' (' . $cols . ')'];\n    }\n\n    public static function dropTable(string $s): array\n    {\n        $I = self::ID;\n        if (!preg_match('/^DROP\\s+(?:TEMPORARY\\s+)?TABLE\\s+(IF\\s+EXISTS\\s+)?(.*?)(?:\\s+(?:RESTRICT|CASCADE))?\\s*$/is', $s, $m)) return [$s];\n        $out = [];\n        foreach (explode(',', $m[2]) as $t) {\n            $t = trim($t);\n            if (!preg_match('/^(?:' . $I . '\\s*\\.\\s*)?(' . $I . ')$/', $t, $x)) continue;\n            $out[] = 'DROP TABLE ' . (trim($m[1]) !== '' ? 'IF EXISTS ' : '') . $x[1];\n        }\n        return $out ?: [self::NOOP];\n    }\n\n    public static function dropIndex(string $s): array\n    {\n        $I = self::ID;\n        if (!preg_match('/^DROP\\s+INDEX\\s+(' . $I . ')\\s+ON\\s+(?:' . $I . '\\s*\\.\\s*)?(' . $I . ')/i', $s, $m)) return [$s];\n        return ['DROP INDEX IF EXISTS ' . self::indexName($m[2], $m[1], '')];\n    }\n\n    public static function truncate(string $s): array\n    {\n        $I = self::ID;\n        if (!preg_match('/^TRUNCATE\\s+(?:TABLE\\s+)?(?:' . $I . '\\s*\\.\\s*)?(' . $I . ')/i', $s, $m)) return [self::NOOP];\n        return ['DELETE FROM ' . $m[1], self::OPT . \"DELETE FROM sqlite_sequence WHERE name = '\" . str_replace(\"'\", \"''\", self::unq($m[1])) . \"'\"];\n    }\n\n    public static function renameTable(string $s): array\n    {\n        $I = self::ID;\n        if (!preg_match('/^RENAME\\s+TABLE\\s+(.*)$/is', $s, $m)) return [self::NOOP];\n        $out = [];\n        foreach (explode(',', $m[1]) as $pair) {\n            if (preg_match('/^\\s*(?:' . $I . '\\s*\\.\\s*)?(' . $I . ')\\s+TO\\s+(?:' . $I . '\\s*\\.\\s*)?(' . $I . ')\\s*$/i', $pair, $x)) {\n                $out[] = 'ALTER TABLE ' . $x[1] . ' RENAME TO ' . $x[2];\n            }\n        }\n        return $out ?: [self::NOOP];\n    }\n\n    public static function alterTable(string $s): array\n    {\n        $I = self::ID;\n        if (!preg_match('/^ALTER\\s+(?:IGNORE\\s+)?TABLE\\s+(?:' . $I . '\\s*\\.\\s*)?(' . $I . ')\\s+(.*)$/is', $s, $m)) return [self::NOOP];\n        $out = [];\n        foreach (self::splitTop($m[2]) as $clause) {\n            foreach (self::alterClause($m[1], trim($clause)) as $q) $out[] = $q;\n        }\n        return $out ?: [self::NOOP];\n    }\n\n    public static function alterClause(string $t, string $c): array\n    {\n        $I = self::ID;\n        if (preg_match('/^ADD\\s+(?:CONSTRAINT\\s+(?:' . $I . '\\s+)?)?PRIMARY\\s+KEY/i', $c)) return [];\n        if (preg_match('/^ADD\\s+(?:CONSTRAINT\\s+(?:' . $I . '\\s+)?)?FOREIGN\\s+KEY/i', $c)) return [];\n        if (preg_match('/^ADD\\s+(?:CONSTRAINT\\s+(?:' . $I . '\\s+)?)?(UNIQUE\\s+)?(?:FULLTEXT\\s+|SPATIAL\\s+)?(?:(?:KEY|INDEX)\\s*|(?=UNIQUE))(?:UNIQUE\\s*)?(?:(?:KEY|INDEX)\\s*)?(' . $I . ')?\\s*(?:USING\\s+\\w+\\s*)?\\((.*)\\)\\s*(?:USING\\s+\\w+)?$/is', $c, $m)) {\n            $cols = self::cleanCols($m[3]);\n            $name = $m[2] !== '' ? $m[2] : null;\n            return ['CREATE ' . (trim($m[1]) !== '' ? 'UNIQUE ' : '') . 'INDEX IF NOT EXISTS ' . self::indexName($t, $name, $cols) . ' ON ' . $t . ' (' . $cols . ')'];\n        }\n        if (preg_match('/^ADD\\s+UNIQUE\\s*(?:(?:KEY|INDEX)\\s*)?(' . $I . ')?\\s*\\((.*)\\)/is', $c, $m)) {\n            $cols = self::cleanCols($m[2]);\n            return ['CREATE UNIQUE INDEX IF NOT EXISTS ' . self::indexName($t, $m[1] !== '' ? $m[1] : null, $cols) . ' ON ' . $t . ' (' . $cols . ')'];\n        }\n        if (preg_match('/^ADD\\s+(?:COLUMN\\s+)?(' . $I . ')\\s+(.+)$/is', $c, $m) && !preg_match('/^(?:INDEX|KEY|UNIQUE|PRIMARY|FOREIGN|CONSTRAINT|FULLTEXT|SPATIAL|CHECK)$/i', $m[1])) {\n            $rest = preg_replace('/\\s+(?:AFTER\\s+' . $I . '|FIRST)\\s*$/i', '', $m[2]);\n            $col = self::parseColumn($m[1], $rest);\n            $attrs = preg_replace('/\\bDEFAULT\\s+\\(now\\(\\)\\)/i', '', $col['attrs']);\n            $attrs = preg_replace('/\\b(?:PRIMARY\\s+KEY|UNIQUE)\\b/i', '', $attrs);\n            if (preg_match('/\\bNOT\\s+NULL\\b/i', $attrs) && !preg_match('/\\bDEFAULT\\b/i', $attrs)) {\n                $attrs .= preg_match('/^(?:CHAR|VARCHAR|NCHAR|NVARCHAR|CHARACTER|TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT)/i', $col['type']) || $col['type'] === 'TEXT' ? \" DEFAULT ''\" : ' DEFAULT 0';\n            }\n            return ['ALTER TABLE ' . $t . ' ADD COLUMN ' . trim($col['name'] . ' ' . $col['type'] . ' ' . trim($attrs))];\n        }\n        if (preg_match('/^DROP\\s+(?:COLUMN\\s+)?(' . $I . ')\\s*$/i', $c, $m) && !preg_match('/^(?:PRIMARY|INDEX|KEY|FOREIGN|CONSTRAINT|CHECK)$/i', $m[1])) {\n            return ['ALTER TABLE ' . $t . ' DROP COLUMN ' . $m[1]];\n        }\n        if (preg_match('/^DROP\\s+(?:INDEX|KEY)\\s+(' . $I . ')/i', $c, $m)) return ['DROP INDEX IF EXISTS ' . self::indexName($t, $m[1], '')];\n        if (preg_match('/^CHANGE\\s+(?:COLUMN\\s+)?(' . $I . ')\\s+(' . $I . ')\\s/i', $c, $m)) {\n            if (self::unq($m[1]) !== self::unq($m[2])) return ['ALTER TABLE ' . $t . ' RENAME COLUMN ' . $m[1] . ' TO ' . $m[2]];\n            return [];\n        }\n        if (preg_match('/^RENAME\\s+COLUMN\\s+(' . $I . ')\\s+TO\\s+(' . $I . ')/i', $c, $m)) return ['ALTER TABLE ' . $t . ' RENAME COLUMN ' . $m[1] . ' TO ' . $m[2]];\n        if (preg_match('/^RENAME\\s+(?:TO\\s+|AS\\s+)?(' . $I . ')\\s*$/i', $c, $m) && !preg_match('/^(?:INDEX|KEY|COLUMN)$/i', $m[1])) return ['ALTER TABLE ' . $t . ' RENAME TO ' . $m[1]];\n        return [];\n    }\n\n    public static function mergeAlter(array &$st, string $clauses): bool\n    {\n        $I = self::ID;\n        foreach (self::splitTop($clauses) as $c) {\n            $c = trim($c);\n            if ($c === '') continue;\n            if (preg_match('/^ADD\\s+(?:CONSTRAINT\\s+(?:' . $I . '\\s+)?)?PRIMARY\\s+KEY\\s*(?:USING\\s+\\w+\\s*)?\\((.*)\\)/is', $c, $m)) {\n                $st['pk'] = array_map('trim', explode(',', self::cleanCols($m[1])));\n            } elseif (preg_match('/^ADD\\s+(?:CONSTRAINT\\s+(?:' . $I . '\\s+)?)?UNIQUE\\s*(?:(?:KEY|INDEX)\\s*)?(?:' . $I . ')?\\s*(?:USING\\s+\\w+\\s*)?\\((.*)\\)/is', $c, $m)) {\n                $st['uniq'][] = self::cleanCols($m[1]);\n            } elseif (preg_match('/^ADD\\s+(?:FULLTEXT\\s+|SPATIAL\\s+)?(?:KEY|INDEX)\\s*(' . $I . ')?\\s*(?:USING\\s+\\w+\\s*)?\\((.*)\\)/is', $c, $m)) {\n                $st['idx'][] = ['name' => $m[1] !== '' ? $m[1] : null, 'cols' => self::cleanCols($m[2]), 'unique' => false];\n            } elseif (preg_match('/^ADD\\s+(?:CONSTRAINT\\s+(?:' . $I . '\\s+)?)?FOREIGN\\s+KEY/i', $c)) {\n                $st['fks'][] = preg_replace('/^ADD\\s+/i', '', preg_replace('/FOREIGN\\s+KEY\\s+(?!\\()' . $I . '\\s*/i', 'FOREIGN KEY ', $c));\n            } elseif (preg_match('/^MODIFY\\s+(?:COLUMN\\s+)?(' . $I . ')\\s+(.*)$/is', $c, $m)) {\n                $col = self::parseColumn($m[1], $m[2]);\n                foreach ($st['cols'] as $k => $existing) {\n                    if (self::unq($existing['name']) === self::unq($m[1])) $st['cols'][$k] = $col;\n                }\n            } elseif (preg_match('/^CHANGE\\s+(?:COLUMN\\s+)?(' . $I . ')\\s+(' . $I . ')\\s+(.*)$/is', $c, $m)) {\n                $col = self::parseColumn($m[2], $m[3]);\n                foreach ($st['cols'] as $k => $existing) {\n                    if (self::unq($existing['name']) === self::unq($m[1])) $st['cols'][$k] = $col;\n                }\n            } elseif (preg_match('/^(?:ENGINE|DEFAULT|CHARSET|CHARACTER|COLLATE|COMMENT|ROW_FORMAT|CONVERT)\\b/i', $c)) {\n                continue;\n            } elseif (preg_match('/^AUTO_INCREMENT\\s*=?\\s*(\\d+)/i', $c, $m)) {\n                $st['seq'] = (int)$m[1];\n            } else {\n                return false;\n            }\n        }\n        return true;\n    }\n\n    public static function show(string $s): array\n    {\n        $I = self::ID;\n        $db = str_replace(\"'\", \"''\", self::$db);\n        $skip = \"type IN ('table','view') AND substr(name,1,7) <> 'sqlite_'\";\n        $empty = 'SELECT NULL AS \"Variable_name\", NULL AS \"Value\" WHERE 0';\n        if (preg_match('/^SHOW\\s+(FULL\\s+)?TABLES\\b(?:\\s+(?:FROM|IN)\\s+' . $I . ')?(?:\\s+LIKE\\s+(\\x01\\d+\\x02))?/i', $s, $m)) {\n            $like = (isset($m[2]) && $m[2] !== '') ? ' AND name LIKE ' . $m[2] : '';\n            $extra = (isset($m[1]) && trim($m[1]) !== '') ? \", CASE type WHEN 'view' THEN 'VIEW' ELSE 'BASE TABLE' END AS \\\"Table_type\\\"\" : '';\n            return ['SELECT name AS \"Tables_in_' . str_replace('\"', '', self::$db) . '\"' . $extra . ' FROM sqlite_master WHERE ' . $skip . $like . ' ORDER BY name'];\n        }\n        if (preg_match('/^SHOW\\s+TABLE\\s+STATUS\\b/i', $s)) {\n            return ['SELECT name AS \"Name\", \\'InnoDB\\' AS \"Engine\", 0 AS \"Rows\" FROM sqlite_master WHERE ' . $skip . ' ORDER BY name'];\n        }\n        if (preg_match('/^SHOW\\s+(?:DATABASES|SCHEMAS)\\b/i', $s)) {\n            return [\"SELECT '\" . $db . \"' AS \\\"Database\\\"\"];\n        }\n        if (preg_match('/^SHOW\\s+CREATE\\s+TABLE\\s+(?:' . $I . '\\s*\\.\\s*)?(' . $I . ')/i', $s, $m)) {\n            $t = str_replace(\"'\", \"''\", self::unq($m[1]));\n            return [\"SELECT name AS \\\"Table\\\", sql AS \\\"Create Table\\\" FROM sqlite_master WHERE type = 'table' AND name = '\" . $t . \"'\"];\n        }\n        if (preg_match('/^SHOW\\s+(?:INDEX|INDEXES|KEYS)\\s+(?:FROM|IN)\\s+(?:' . $I . '\\s*\\.\\s*)?(' . $I . ')/i', $s, $m)) {\n            $t = str_replace(\"'\", \"''\", self::unq($m[1]));\n            return [\"SELECT '\" . $t . \"' AS \\\"Table\\\", CASE il.\\\"unique\\\" WHEN 1 THEN 0 ELSE 1 END AS \\\"Non_unique\\\", il.name AS \\\"Key_name\\\", ii.seqno + 1 AS \\\"Seq_in_index\\\", ii.name AS \\\"Column_name\\\" FROM pragma_index_list('\" . $t . \"') il, pragma_index_info(il.name) ii\"];\n        }\n        if (preg_match('/^(?:SHOW\\s+(?:FULL\\s+)?(?:COLUMNS|FIELDS)\\s+(?:FROM|IN)|DESCRIBE|DESC|EXPLAIN)\\s+(?:' . $I . '\\s*\\.\\s*)?(' . $I . ')(?:\\s+(?:FROM|IN)\\s+' . $I . ')?(?:\\s+LIKE\\s+(\\x01\\d+\\x02))?/i', $s, $m)) {\n            $t = str_replace(\"'\", \"''\", self::unq($m[1]));\n            $like = (isset($m[2]) && $m[2] !== '') ? ' WHERE p.name LIKE ' . $m[2] : '';\n            return [\"SELECT p.name AS \\\"Field\\\", lower(p.type) AS \\\"Type\\\", CASE WHEN p.\\\"notnull\\\" = 1 OR p.pk > 0 THEN 'NO' ELSE 'YES' END AS \\\"Null\\\", CASE WHEN p.pk > 0 THEN 'PRI' ELSE '' END AS \\\"Key\\\", CASE WHEN substr(p.dflt_value, 1, 1) = '''' THEN substr(p.dflt_value, 2, length(p.dflt_value) - 2) ELSE p.dflt_value END AS \\\"Default\\\", CASE WHEN p.pk > 0 AND (SELECT instr(sql, 'AUTOINCREMENT') FROM sqlite_master WHERE name = '\" . $t . \"') > 0 THEN 'auto_increment' ELSE '' END AS \\\"Extra\\\" FROM pragma_table_info('\" . $t . \"') p\" . $like];\n        }\n        return [$empty];\n    }\n\n    public static function dml(string $s): string\n    {\n        $I = self::ID;\n        $db = str_replace(\"'\", \"''\", self::$db);\n        if (stripos($s, 'information_schema') !== false) {\n            $s = preg_replace_callback('/\\binformation_schema\\s*\\.\\s*`?(\\w+)`?/i', function ($m) use ($db) {\n                switch (strtolower($m[1])) {\n                    case 'tables':\n                        return \"(SELECT '$db' AS table_catalog, '$db' AS table_schema, name AS table_name, CASE type WHEN 'view' THEN 'VIEW' ELSE 'BASE TABLE' END AS table_type, 'InnoDB' AS engine, 0 AS table_rows FROM sqlite_master WHERE type IN ('table','view') AND substr(name,1,7) <> 'sqlite_')\";\n                    case 'columns':\n                        return \"(SELECT '$db' AS table_catalog, '$db' AS table_schema, m.name AS table_name, p.name AS column_name, p.cid + 1 AS ordinal_position, p.dflt_value AS column_default, CASE p.\\\"notnull\\\" WHEN 1 THEN 'NO' ELSE 'YES' END AS is_nullable, lower(p.type) AS data_type, lower(p.type) AS column_type, CASE WHEN p.pk > 0 THEN 'PRI' ELSE '' END AS column_key FROM sqlite_master m, pragma_table_info(m.name) p WHERE m.type IN ('table','view') AND substr(m.name,1,7) <> 'sqlite_')\";\n                    case 'schemata':\n                        return \"(SELECT '$db' AS schema_name, 'utf8mb4' AS default_character_set_name)\";\n                }\n                return '(SELECT NULL AS table_schema, NULL AS table_name WHERE 0)';\n            }, $s);\n        }\n        $s = preg_replace('/\\b(FROM|JOIN|INTO|UPDATE|TABLE)\\s+(' . $I . ')\\s*\\.\\s*(' . $I . ')/i', '$1 $3', $s);\n\n        if (preg_match('/^(INSERT\\s+(?:IGNORE\\s+)?INTO\\s+' . $I . ')\\s+SET\\s+(.+?)(\\s+ON\\s+DUPLICATE\\s+KEY\\s+UPDATE\\b.*)?$/is', $s, $m)) {\n            $cols = [];\n            $vals = [];\n            foreach (self::splitTop($m[2]) as $a) {\n                if (!preg_match('/^\\s*(' . $I . ')\\s*=\\s*(.+)$/s', $a, $x)) {\n                    $cols = [];\n                    break;\n                }\n                $cols[] = $x[1];\n                $vals[] = trim($x[2]);\n            }\n            if ($cols) $s = $m[1] . ' (' . implode(', ', $cols) . ') VALUES (' . implode(', ', $vals) . ')' . (isset($m[3]) ? $m[3] : '');\n        }\n\n        if (preg_match('/^DELETE\\s+FROM\\s+(' . $I . ')(\\s+.*?)?\\s+LIMIT\\s+(\\d+|\\?|:\\w+)\\s*$/is', $s, $m) && !preg_match('/\\bJOIN\\b/i', $s)) {\n            $s = 'DELETE FROM ' . $m[1] . ' WHERE rowid IN (SELECT rowid FROM ' . $m[1] . (isset($m[2]) ? $m[2] : '') . ' LIMIT ' . $m[3] . ')';\n        } elseif (preg_match('/^UPDATE\\s+(?:IGNORE\\s+)?(' . $I . ')\\s+SET\\s+(.*?)((?:\\s+WHERE\\s+.*?)?(?:\\s+ORDER\\s+BY\\s+.*?)?)\\s+LIMIT\\s+(\\d+|\\?|:\\w+)\\s*$/is', $s, $m) && !preg_match('/\\bJOIN\\b/i', $s)) {\n            $s = 'UPDATE ' . $m[1] . ' SET ' . $m[2] . ' WHERE rowid IN (SELECT rowid FROM ' . $m[1] . $m[3] . ' LIMIT ' . $m[4] . ')';\n        }\n\n        $s = preg_replace('/^INSERT\\s+(?:LOW_PRIORITY\\s+|DELAYED\\s+|HIGH_PRIORITY\\s+)*IGNORE\\b/i', 'INSERT OR IGNORE', $s);\n        $s = preg_replace('/^UPDATE\\s+(?:LOW_PRIORITY\\s+)?IGNORE\\b/i', 'UPDATE OR IGNORE', $s);\n        $s = preg_replace('/\\b(?:SQL_CALC_FOUND_ROWS|SQL_NO_CACHE|SQL_CACHE|SQL_SMALL_RESULT|SQL_BIG_RESULT|SQL_BUFFER_RESULT|HIGH_PRIORITY|LOW_PRIORITY|DELAYED)\\b/i', '', $s);\n        $s = preg_replace('/\\bSTRAIGHT_JOIN\\b/i', 'JOIN', $s);\n        $s = preg_replace('/\\s+(?:FOR\\s+(?:UPDATE|SHARE)|LOCK\\s+IN\\s+SHARE\\s+MODE)(?:\\s+(?:NOWAIT|SKIP\\s+LOCKED))?\\s*$/i', '', $s);\n        $s = preg_replace('/\\b(?:USE|FORCE|IGNORE)\\s+(?:INDEX|KEY)\\s*(?:FOR\\s+\\w+(?:\\s+BY)?\\s*)?\\([^)]*\\)/i', '', $s);\n        $s = preg_replace('/\\bFROM\\s+DUAL\\b/i', '', $s);\n        if (preg_match('/^INSERT\\b/i', $s)) $s = preg_replace('/(?<![\\w`])DEFAULT(?=\\s*[,)])/i', 'NULL', $s);\n\n        if (stripos($s, 'ON DUPLICATE') !== false) {\n            $s = preg_replace_callback('/^(.*?)\\bON\\s+DUPLICATE\\s+KEY\\s+UPDATE\\b(.*)$/is', function ($m) use ($I) {\n                $tail = preg_replace('/\\bVALUES\\s*\\(\\s*(' . $I . ')\\s*\\)/i', 'excluded.$1', $m[2]);\n                return $m[1] . 'ON CONFLICT DO UPDATE SET' . $tail;\n            }, $s);\n        }\n\n        $unit = 'MICROSECOND|SECOND|MINUTE|HOUR|DAY|WEEK|MONTH|QUARTER|YEAR';\n        if (stripos($s, 'INTERVAL') !== false) {\n            $s = preg_replace_callback('/\\b(DATE_ADD|ADDDATE|DATE_SUB|SUBDATE)\\s*\\(\\s*(.+?)\\s*,\\s*INTERVAL\\s+(.+?)\\s+(' . $unit . ')\\s*\\)/is', function ($m) {\n                return 'ath_date_add(' . $m[2] . ', ' . $m[3] . \", '\" . strtoupper($m[4]) . \"', \" . (stripos($m[1], 'ADD') !== false ? '1' : '-1') . ')';\n            }, $s);\n            $left = '(\\bNOW\\s*\\(\\s*\\)|\\bCURRENT_TIMESTAMP\\b(?:\\s*\\(\\s*\\d*\\s*\\))?|\\bCURDATE\\s*\\(\\s*\\)|\\bCURRENT_DATE\\b(?:\\s*\\(\\s*\\))?|' . $I . '(?:\\s*\\.\\s*' . $I . ')?|\\x01\\d+\\x02)';\n            $num = '(-?\\d+(?:\\.\\d+)?|\\x01\\d+\\x02|\\?|:\\w+|' . $I . '(?:\\.' . $I . ')?)';\n            $s = preg_replace_callback('/' . $left . '\\s*([+-])\\s*INTERVAL\\s+' . $num . '\\s+(' . $unit . ')\\b/i', function ($m) {\n                return 'ath_date_add(' . $m[1] . ', ' . $m[3] . \", '\" . strtoupper($m[4]) . \"', \" . ($m[2] === '+' ? '1' : '-1') . ')';\n            }, $s);\n        }\n        if (stripos($s, 'TIMESTAMPDIFF') !== false) $s = preg_replace('/\\bTIMESTAMPDIFF\\s*\\(\\s*(\\w+)\\s*,/i', \"timestampdiff('$1',\", $s);\n        if (stripos($s, 'SEPARATOR') !== false) {\n            $s = preg_replace_callback('/\\bGROUP_CONCAT\\s*\\(\\s*(DISTINCT\\s+)?(.+?)(\\s+ORDER\\s+BY\\s+.+?)?\\s+SEPARATOR\\s+(\\x01\\d+\\x02)\\s*\\)/is', function ($m) {\n                if (trim($m[1]) !== '') return 'group_concat(DISTINCT ' . $m[2] . ')';\n                return 'group_concat(' . $m[2] . ', ' . $m[4] . $m[3] . ')';\n            }, $s);\n        }\n        if (stripos($s, 'CAST') !== false || stripos($s, ' AS ') !== false) {\n            $s = preg_replace('/\\bCAST\\s*\\(\\s*([^()]+?)\\s+AS\\s+DATETIME\\s*\\)/i', 'datetime($1)', $s);\n            $s = preg_replace('/\\bCAST\\s*\\(\\s*([^()]+?)\\s+AS\\s+DATE\\s*\\)/i', 'date($1)', $s);\n            $s = preg_replace('/\\bAS\\s+(?:UNSIGNED|SIGNED)(?:\\s+INTEGER)?\\b/i', 'AS INTEGER', $s);\n            $s = preg_replace('/\\bAS\\s+(?:CHAR|NCHAR|BINARY)(?:\\s*\\(\\s*\\d+\\s*\\))?(?=\\s*\\))/i', 'AS TEXT', $s);\n        }\n        $s = preg_replace('/\\bLAST_INSERT_ID\\s*\\(\\s*\\)/i', 'last_insert_rowid()', $s);\n        $s = preg_replace('/\\bROW_COUNT\\s*\\(\\s*\\)/i', 'changes()', $s);\n        $s = preg_replace('/\\bGREATEST\\s*\\(/i', 'max(', $s);\n        $s = preg_replace('/\\bLEAST\\s*\\(/i', 'min(', $s);\n        $s = preg_replace('/\\b(?:CURRENT_TIMESTAMP|LOCALTIMESTAMP|LOCALTIME)\\b(?:\\s*\\(\\s*\\d*\\s*\\))?/i', 'now()', $s);\n        $s = preg_replace('/\\bCURRENT_DATE\\b(?:\\s*\\(\\s*\\))?/i', 'curdate()', $s);\n        $s = preg_replace('/\\bCURRENT_TIME\\b(?:\\s*\\(\\s*\\d*\\s*\\))?/i', 'curtime()', $s);\n        $s = str_replace('<=>', ' IS ', $s);\n        $s = preg_replace('/\\bDIV\\b/i', '/', $s);\n        $s = preg_replace('/\\bMOD\\b(?!\\s*\\()/i', '%', $s);\n        $s = preg_replace('/\\bRLIKE\\b/i', 'REGEXP', $s);\n        if (stripos($s, 'BINARY') !== false) {\n            $s = preg_replace('/\\bBINARY\\s+(' . $I . '(?:\\s*\\.\\s*' . $I . ')?|\\x01\\d+\\x02|\\?)/i', '$1 COLLATE BINARY', $s);\n        }\n        return trim($s);\n    }\n\n    public static function runList(AthPDO $pdo, array $list): int\n    {\n        $n = 0;\n        foreach ($list as $q) {\n            if ($q !== '' && $q[0] === self::OPT) {\n                try {\n                    $pdo->rawExec(substr($q, 1));\n                } catch (Throwable $e) {\n                }\n                continue;\n            }\n            $r = $pdo->rawExec($q);\n            $n = $r === false ? 0 : $r;\n        }\n        return $n;\n    }\n\n    public static function escape(string $s): string\n    {\n        return strtr($s, [\"\\0\" => '\\\\0', \"\\n\" => '\\\\n', \"\\r\" => '\\\\r', '\\\\' => '\\\\\\\\', \"'\" => \"\\\\'\", '\"' => '\\\\\"', \"\\x1a\" => '\\\\Z']);\n    }\n\n    public static function mysqlError(string $msg): array\n    {\n        $db = self::$db;\n        if (preg_match('/no such table:\\s*(?:\\w+\\.)?(\\S+)/i', $msg, $m)) {\n            return [1146, '42S02', \"Table '$db.\" . $m[1] . \"' doesn't exist\", 'Base table or view not found'];\n        }\n        if (preg_match('/no such column:\\s*(\\S+)/i', $msg, $m) || preg_match('/table \\S+ has no column named (\\S+)/i', $msg, $m)) {\n            return [1054, '42S22', \"Unknown column '\" . $m[1] . \"' in 'field list'\", 'Column not found'];\n        }\n        if (preg_match('/UNIQUE constraint failed:\\s*(\\S+)/i', $msg, $m)) {\n            return [1062, '23000', \"Duplicate entry for key '\" . $m[1] . \"'\", 'Integrity constraint violation'];\n        }\n        if (preg_match('/NOT NULL constraint failed:\\s*(?:\\w+\\.)?(\\S+)/i', $msg, $m)) {\n            return [1048, '23000', \"Column '\" . $m[1] . \"' cannot be null\", 'Integrity constraint violation'];\n        }\n        if (stripos($msg, 'FOREIGN KEY constraint failed') !== false) {\n            return [1452, '23000', 'Cannot add or update a child row: a foreign key constraint fails', 'Integrity constraint violation'];\n        }\n        if (preg_match('/table (\\S+) already exists/i', $msg, $m)) {\n            return [1050, '42S01', \"Table '\" . trim($m[1], '\"`') . \"' already exists\", 'Base table or view already exists'];\n        }\n        if (preg_match('/no such function:\\s*(\\S+)/i', $msg, $m)) {\n            return [1305, '42000', \"FUNCTION $db.\" . $m[1] . ' does not exist', 'Syntax error or access violation'];\n        }\n        if (preg_match('/near \"([^\"]*)\"/', $msg, $m) || stripos($msg, 'syntax error') !== false || stripos($msg, 'incomplete input') !== false) {\n            $near = isset($m[1]) ? $m[1] : '';\n            return [1064, '42000', \"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$near' at line 1\", 'Syntax error or access violation'];\n        }\n        return [1105, 'HY000', 'Unknown error: ' . $msg, 'General error'];\n    }\n\n    public static function mapPdo(PDOException $e): PDOException\n    {\n        if (isset($e->errorInfo[1]) && (int)$e->errorInfo[1] >= 1000) return $e;\n        if (!preg_match('/^SQLSTATE\\[[^\\]]*\\]:[^:]*:\\s*\\d+\\s+(.*)$/s', $e->getMessage(), $m)) return $e;\n        list($no, $state, $text, $label) = self::mysqlError($m[1]);\n        $e->errorInfo = [$state, $no, $text];\n        (new ReflectionProperty('Exception', 'message'))->setValue($e, \"SQLSTATE[$state]: $label: $no $text\");\n        (new ReflectionProperty('Exception', 'code'))->setValue($e, $state);\n        return $e;\n    }\n\n    public static function dt($v): ?DateTimeImmutable\n    {\n        if ($v === null || $v === '') return null;\n        $v = (string)$v;\n        if (strpos($v, '0000-00-00') === 0) return null;\n        try {\n            return new DateTimeImmutable($v);\n        } catch (Throwable $e) {\n            return null;\n        }\n    }\n\n    public static function fmt($v, $f): ?string\n    {\n        $d = self::dt($v);\n        if ($d === null || $f === null) return null;\n        $f = (string)$f;\n        $map = ['Y' => 'Y', 'y' => 'y', 'm' => 'm', 'c' => 'n', 'd' => 'd', 'e' => 'j', 'H' => 'H', 'k' => 'G', 'h' => 'h', 'I' => 'h', 'l' => 'g', 'i' => 'i', 's' => 's', 'S' => 's', 'p' => 'A', 'M' => 'F', 'b' => 'M', 'W' => 'l', 'a' => 'D', 'w' => 'w', 'T' => 'H:i:s', 'r' => 'h:i:s A', 'u' => 'W'];\n        $out = '';\n        $n = strlen($f);\n        for ($i = 0; $i < $n; $i++) {\n            $c = $f[$i];\n            if ($c !== '%' || $i + 1 >= $n) {\n                $out .= $c;\n                continue;\n            }\n            $x = $f[++$i];\n            if ($x === 'j') $out .= str_pad((string)((int)$d->format('z') + 1), 3, '0', STR_PAD_LEFT);\n            elseif ($x === 'f') $out .= '000000';\n            elseif ($x === '%') $out .= '%';\n            elseif (isset($map[$x])) $out .= $d->format($map[$x]);\n            else $out .= $x;\n        }\n        return $out;\n    }\n\n    public static function dateAdd($v, $n, $unit, $sign = 1)\n    {\n        $d = self::dt($v);\n        if ($d === null || $n === null) return null;\n        $n = (int)round((float)$n) * (int)$sign;\n        $unit = strtoupper((string)$unit);\n        $time = (bool)preg_match('/\\d:\\d/', (string)$v) || in_array($unit, ['SECOND', 'MINUTE', 'HOUR', 'MICROSECOND'], true);\n        if ($unit === 'MONTH' || $unit === 'QUARTER' || $unit === 'YEAR') {\n            $months = $unit === 'YEAR' ? $n * 12 : ($unit === 'QUARTER' ? $n * 3 : $n);\n            $total = (int)$d->format('Y') * 12 + ((int)$d->format('n') - 1) + $months;\n            $y = intdiv($total, 12);\n            $m = $total % 12 + 1;\n            $last = (int)(new DateTimeImmutable(sprintf('%04d-%02d-01', $y, $m)))->format('t');\n            $d = $d->setDate($y, $m, min((int)$d->format('j'), $last));\n        } elseif ($unit === 'WEEK') {\n            $d = $d->modify(($n * 7) . ' days');\n        } elseif ($unit === 'DAY') {\n            $d = $d->modify($n . ' days');\n        } elseif ($unit === 'HOUR') {\n            $d = $d->modify($n . ' hours');\n        } elseif ($unit === 'MINUTE') {\n            $d = $d->modify($n . ' minutes');\n        } elseif ($unit === 'SECOND') {\n            $d = $d->modify($n . ' seconds');\n        }\n        return $d->format($time ? 'Y-m-d H:i:s' : 'Y-m-d');\n    }\n\n    public static function tsDiff($unit, $a, $b)\n    {\n        $x = self::dt($a);\n        $y = self::dt($b);\n        if ($x === null || $y === null) return null;\n        $unit = strtoupper((string)$unit);\n        $secs = $y->getTimestamp() - $x->getTimestamp();\n        $div = ['SECOND' => 1, 'MINUTE' => 60, 'HOUR' => 3600, 'DAY' => 86400, 'WEEK' => 604800];\n        if (isset($div[$unit])) return (int)($secs / $div[$unit]);\n        $i = $x->diff($y);\n        $months = ($i->y * 12 + $i->m) * ($i->invert ? -1 : 1);\n        if ($unit === 'YEAR') return intdiv($months, 12);\n        if ($unit === 'QUARTER') return intdiv($months, 3);\n        return $months;\n    }\n\n    public static function strToDate($str, $fmt)\n    {\n        if ($str === null || $fmt === null) return null;\n        $re = '';\n        $order = [];\n        $f = (string)$fmt;\n        $map = ['Y' => '(\\d{4})', 'y' => '(\\d{2})', 'm' => '(\\d{1,2})', 'c' => '(\\d{1,2})', 'd' => '(\\d{1,2})', 'e' => '(\\d{1,2})', 'H' => '(\\d{1,2})', 'k' => '(\\d{1,2})', 'h' => '(\\d{1,2})', 'I' => '(\\d{1,2})', 'i' => '(\\d{1,2})', 's' => '(\\d{1,2})', 'S' => '(\\d{1,2})', 'p' => '([AaPp][Mm])'];\n        for ($i = 0, $n = strlen($f); $i < $n; $i++) {\n            if ($f[$i] === '%' && $i + 1 < $n) {\n                $x = $f[++$i];\n                if (isset($map[$x])) {\n                    $re .= $map[$x];\n                    $order[] = $x;\n                } else {\n                    $re .= preg_quote($x, '~');\n                }\n            } else {\n                $re .= preg_quote($f[$i], '~');\n            }\n        }\n        if (!preg_match('~^\\s*' . $re . '~', (string)$str, $m)) return null;\n        $p = ['Y' => 1970, 'm' => 1, 'd' => 1, 'H' => 0, 'i' => 0, 's' => 0];\n        $pm = null;\n        foreach ($order as $k => $x) {\n            $v = $m[$k + 1];\n            if ($x === 'Y') $p['Y'] = (int)$v;\n            elseif ($x === 'y') $p['Y'] = (int)$v + ((int)$v < 70 ? 2000 : 1900);\n            elseif ($x === 'm' || $x === 'c') $p['m'] = (int)$v;\n            elseif ($x === 'd' || $x === 'e') $p['d'] = (int)$v;\n            elseif ($x === 'H' || $x === 'k' || $x === 'h' || $x === 'I') $p['H'] = (int)$v;\n            elseif ($x === 'i') $p['i'] = (int)$v;\n            elseif ($x === 's' || $x === 'S') $p['s'] = (int)$v;\n            elseif ($x === 'p') $pm = strtoupper($v);\n        }\n        if ($pm === 'PM' && $p['H'] < 12) $p['H'] += 12;\n        if ($pm === 'AM' && $p['H'] === 12) $p['H'] = 0;\n        $hasTime = (bool)array_intersect($order, ['H', 'k', 'h', 'I', 'i', 's', 'S']);\n        $date = sprintf('%04d-%02d-%02d', $p['Y'], $p['m'], $p['d']);\n        return $hasTime ? $date . sprintf(' %02d:%02d:%02d', $p['H'], $p['i'], $p['s']) : $date;\n    }\n\n    public static function register(PDO $pdo): void\n    {\n        $f = function ($name, $fn, $n = -1) use ($pdo) {\n            $pdo->sqliteCreateFunction($name, $fn, $n);\n        };\n        $str = function ($v) {\n            return $v === null ? null : (string)$v;\n        };\n\n        $pdo->sqliteCreateCollation('NOCASE', function ($a, $b) {\n            return strcmp(mb_strtolower((string)$a), mb_strtolower((string)$b));\n        });\n\n        $f('like', function ($p, $s, $e = null) {\n            if ($p === null || $s === null) return null;\n            $e = ($e === null || $e === '') ? '\\\\' : (string)$e;\n            $key = $p . \"\\0\" . $e;\n            if (!isset(self::$likeCache[$key])) {\n                if (count(self::$likeCache) > 500) self::$likeCache = [];\n                $chars = preg_split('//u', (string)$p, -1, PREG_SPLIT_NO_EMPTY);\n                if ($chars === false) $chars = str_split((string)$p);\n                $re = '';\n                for ($i = 0, $n = count($chars); $i < $n; $i++) {\n                    $c = $chars[$i];\n                    if ($c === $e && $i + 1 < $n) $re .= preg_quote($chars[++$i], '~');\n                    elseif ($c === '%') $re .= '.*';\n                    elseif ($c === '_') $re .= '.';\n                    else $re .= preg_quote($c, '~');\n                }\n                self::$likeCache[$key] = '~^' . $re . '$~isu';\n            }\n            $r = @preg_match(self::$likeCache[$key], (string)$s);\n            if ($r === false) $r = @preg_match(substr(self::$likeCache[$key], 0, -1), (string)$s);\n            return $r ? 1 : 0;\n        });\n        $f('regexp', function ($p, $s) {\n            if ($p === null || $s === null) return null;\n            return @preg_match('~' . str_replace('~', '\\\\~', (string)$p) . '~iu', (string)$s) ? 1 : 0;\n        }, 2);\n\n        foreach (['upper', 'ucase'] as $n) $f($n, function ($s) use ($str) { return $s === null ? null : mb_strtoupper((string)$s); }, 1);\n        foreach (['lower', 'lcase'] as $n) $f($n, function ($s) use ($str) { return $s === null ? null : mb_strtolower((string)$s); }, 1);\n        foreach (['char_length', 'character_length'] as $n) $f($n, function ($s) { return $s === null ? null : mb_strlen((string)$s); }, 1);\n\n        $f('concat', function (...$a) {\n            $o = '';\n            foreach ($a as $v) {\n                if ($v === null) return null;\n                $o .= $v;\n            }\n            return $o;\n        });\n        $f('concat_ws', function ($sep, ...$a) {\n            if ($sep === null) return null;\n            $p = [];\n            foreach ($a as $v) if ($v !== null) $p[] = $v;\n            return implode((string)$sep, $p);\n        });\n        $f('left', function ($s, $n) { return $s === null ? null : mb_substr((string)$s, 0, max(0, (int)$n)); }, 2);\n        $f('right', function ($s, $n) { return $s === null ? null : ((int)$n <= 0 ? '' : mb_substr((string)$s, -(int)$n)); }, 2);\n        $f('lpad', function ($s, $n, $p) {\n            if ($s === null || $n === null || $p === null) return null;\n            $s = (string)$s;\n            $len = mb_strlen($s);\n            $n = (int)$n;\n            if ($n <= $len) return mb_substr($s, 0, $n);\n            if ($p === '') return null;\n            $pad = '';\n            while (mb_strlen($pad) < $n - $len) $pad .= $p;\n            return mb_substr($pad, 0, $n - $len) . $s;\n        }, 3);\n        $f('rpad', function ($s, $n, $p) {\n            if ($s === null || $n === null || $p === null) return null;\n            $s = (string)$s;\n            $len = mb_strlen($s);\n            $n = (int)$n;\n            if ($n <= $len) return mb_substr($s, 0, $n);\n            if ($p === '') return null;\n            $pad = '';\n            while (mb_strlen($pad) < $n - $len) $pad .= $p;\n            return $s . mb_substr($pad, 0, $n - $len);\n        }, 3);\n        $f('locate', function ($sub, $s, $pos = 1) {\n            if ($sub === null || $s === null) return null;\n            $r = mb_stripos((string)$s, (string)$sub, max(0, (int)$pos - 1));\n            return $r === false ? 0 : $r + 1;\n        });\n        $f('find_in_set', function ($a, $list) {\n            if ($a === null || $list === null) return null;\n            $i = array_search(mb_strtolower((string)$a), array_map('mb_strtolower', explode(',', (string)$list)), true);\n            return $i === false ? 0 : $i + 1;\n        }, 2);\n        $f('substring_index', function ($s, $d, $c) {\n            if ($s === null || $d === null || $c === null) return null;\n            $parts = explode((string)$d, (string)$s);\n            $c = (int)$c;\n            if ($c >= 0) return implode((string)$d, array_slice($parts, 0, $c));\n            return implode((string)$d, array_slice($parts, $c));\n        }, 3);\n        $f('reverse', function ($s) { return $s === null ? null : implode('', array_reverse(preg_split('//u', (string)$s, -1, PREG_SPLIT_NO_EMPTY))); }, 1);\n        $f('repeat', function ($s, $n) { return $s === null ? null : str_repeat((string)$s, max(0, (int)$n)); }, 2);\n        $f('space', function ($n) { return str_repeat(' ', max(0, (int)$n)); }, 1);\n        $f('strcmp', function ($a, $b) { return $a === null || $b === null ? null : (strcmp((string)$a, (string)$b) <=> 0); }, 2);\n        $f('format', function ($n, $d = 0) { return $n === null ? null : number_format((float)$n, max(0, (int)$d), '.', ','); });\n        $f('field', function ($v, ...$list) {\n            foreach ($list as $i => $x) if ((string)$x === (string)$v) return $i + 1;\n            return 0;\n        });\n        $f('isnull', function ($v) { return $v === null ? 1 : 0; }, 1);\n        $f('any_value', function ($v) { return $v; }, 1);\n        $f('truncate', function ($x, $d) {\n            if ($x === null) return null;\n            $m = pow(10, (int)$d);\n            return ($x < 0 ? ceil($x * $m) : floor($x * $m)) / $m;\n        }, 2);\n\n        $f('md5', function ($s) { return $s === null ? null : md5((string)$s); }, 1);\n        $f('sha1', function ($s) { return $s === null ? null : sha1((string)$s); }, 1);\n        $f('sha2', function ($s, $b = 256) {\n            $algo = [0 => 'sha256', 224 => 'sha224', 256 => 'sha256', 384 => 'sha384', 512 => 'sha512'][(int)$b] ?? null;\n            return ($s === null || $algo === null) ? null : hash($algo, (string)$s);\n        });\n        $f('uuid', function () {\n            $b = random_bytes(16);\n            $b[6] = chr(ord($b[6]) & 0x0f | 0x40);\n            $b[8] = chr(ord($b[8]) & 0x3f | 0x80);\n            return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($b), 4));\n        }, 0);\n        $f('rand', function ($seed = null) { return mt_rand() / mt_getrandmax(); });\n        $f('database', function () { return self::$db; }, 0);\n        $f('schema', function () { return self::$db; }, 0);\n        $f('version', function () { return '8.0.36-athera'; }, 0);\n        $f('user', function () { return 'root@localhost'; }, 0);\n        $f('current_user', function () { return 'root@localhost'; }, 0);\n        $f('connection_id', function () { return 1; }, 0);\n\n        $f('now', function () { return date('Y-m-d H:i:s'); }, 0);\n        $f('sysdate', function () { return date('Y-m-d H:i:s'); }, 0);\n        $f('utc_timestamp', function () { return gmdate('Y-m-d H:i:s'); }, 0);\n        $f('curdate', function () { return date('Y-m-d'); }, 0);\n        $f('utc_date', function () { return gmdate('Y-m-d'); }, 0);\n        $f('curtime', function () { return date('H:i:s'); }, 0);\n        $f('unix_timestamp', function ($v = null) {\n            if ($v === null) return time();\n            $d = self::dt($v);\n            return $d === null ? null : $d->getTimestamp();\n        });\n        $f('from_unixtime', function ($ts, $fmt = null) {\n            if ($ts === null) return null;\n            $d = date('Y-m-d H:i:s', (int)$ts);\n            return $fmt === null ? $d : self::fmt($d, $fmt);\n        });\n        $f('date_format', function ($d, $fmt) { return self::fmt($d, $fmt); }, 2);\n        $f('str_to_date', function ($s, $fmt) { return self::strToDate($s, $fmt); }, 2);\n        $f('ath_date_add', function ($d, $n, $u, $s = 1) { return self::dateAdd($d, $n, $u, $s); });\n        $f('timestampdiff', function ($u, $a, $b) { return self::tsDiff($u, $a, $b); }, 3);\n        $f('datediff', function ($a, $b) {\n            $x = self::dt($a);\n            $y = self::dt($b);\n            if ($x === null || $y === null) return null;\n            return (int)round(($x->setTime(0, 0)->getTimestamp() - $y->setTime(0, 0)->getTimestamp()) / 86400);\n        }, 2);\n        $parts = [\n            'year' => 'Y', 'month' => 'n', 'day' => 'j', 'dayofmonth' => 'j', 'hour' => 'G', 'minute' => 'i', 'second' => 's',\n            'dayofyear' => 'z', 'weekday' => 'N', 'dayofweek' => 'w', 'quarter' => 'n', 'week' => 'W'\n        ];\n        foreach ($parts as $name => $code) {\n            $f($name, function ($v) use ($name, $code) {\n                $d = self::dt($v);\n                if ($d === null) return null;\n                $x = (int)$d->format($code);\n                if ($name === 'dayofyear') return $x + 1;\n                if ($name === 'weekday') return $x - 1;\n                if ($name === 'dayofweek') return $x + 1;\n                if ($name === 'quarter') return (int)ceil($x / 3);\n                return $x;\n            }, 1);\n        }\n        $f('monthname', function ($v) { $d = self::dt($v); return $d === null ? null : $d->format('F'); }, 1);\n        $f('dayname', function ($v) { $d = self::dt($v); return $d === null ? null : $d->format('l'); }, 1);\n        $f('last_day', function ($v) { $d = self::dt($v); return $d === null ? null : $d->format('Y-m-t'); }, 1);\n    }\n\n    public static function findDump(string $db): ?string\n    {\n        $found = [];\n        foreach (['', 'sql', 'db', 'database', 'databases', 'data', 'dump', 'dumps', 'backup', 'backups', 'schema', 'install'] as $d) {\n            $p = self::$root . ($d === '' ? '' : '/' . $d);\n            if (!is_dir($p)) continue;\n            foreach (glob($p . '/*.sql') ?: [] as $file) $found[] = $file;\n        }\n        foreach ($found as $file) {\n            if (strcasecmp(basename($file, '.sql'), $db) === 0) return $file;\n        }\n        return count($found) === 1 ? $found[0] : null;\n    }\n\n    public static function dbFile(string $db, &$fresh): string\n    {\n        if (!is_dir(self::$dir)) @mkdir(self::$dir, 0777, true);\n        $name = preg_replace('/[^\\w.\\-]+/', '_', $db);\n        if ($name === null || $name === '') $name = 'default';\n        $file = self::$dir . '/' . $name . '.sqlite';\n        $sigFile = self::$dir . '/' . $name . '.sig';\n        $dump = self::findDump($db);\n        self::$dump = $dump;\n        $sig = $dump !== null ? $dump . ':' . filemtime($dump) . ':' . filesize($dump) : '';\n        $fresh = !is_file($file);\n        if (!$fresh) {\n            $old = is_file($sigFile) ? (string)file_get_contents($sigFile) : '';\n            if ($old !== $sig) {\n                @unlink($file);\n                $fresh = true;\n            }\n        }\n        if ($fresh) file_put_contents($sigFile, $sig);\n        return $file;\n    }\n\n    public static function splitDump(string $masked): array\n    {\n        $out = [];\n        $delim = ';';\n        $pos = 0;\n        $add = function ($seg) use (&$out, &$delim) {\n            $parts = $delim === ';' ? preg_split('~`[^`]*`(*SKIP)(*FAIL)|;~', $seg) : explode($delim, $seg);\n            foreach ($parts as $p) {\n                $p = trim($p);\n                if ($p !== '') $out[] = $p;\n            }\n        };\n        while (preg_match('~^[ \\t]*DELIMITER[ \\t]+(\\S+)[ \\t]*$~mi', $masked, $m, PREG_OFFSET_CAPTURE, $pos)) {\n            $add(substr($masked, $pos, $m[0][1] - $pos));\n            $delim = $m[1][0];\n            $pos = $m[0][1] + strlen($m[0][0]);\n        }\n        $add(substr($masked, $pos));\n        return $out;\n    }\n\n    public static function importDump(AthPDO $pdo, string $sql, string $label): void\n    {\n        $I = self::ID;\n        $lits = [];\n        $masked = self::mask($sql, $lits);\n        $tables = [];\n        $plan = [];\n        foreach (self::splitDump($masked) as $s) {\n            if (preg_match('/^CREATE\\s+(?:TEMPORARY\\s+)?TABLE\\b/i', $s)) {\n                $st = self::parseCreate($s);\n                if ($st !== null) {\n                    $key = strtolower(self::unq($st['name']));\n                    $tables[$key] = $st;\n                    $plan[] = ['t', $key];\n                    continue;\n                }\n            }\n            if (preg_match('/^ALTER\\s+(?:IGNORE\\s+)?TABLE\\s+(?:' . $I . '\\s*\\.\\s*)?(' . $I . ')\\s+(.*)$/is', $s, $m)) {\n                $key = strtolower(self::unq($m[1]));\n                if (isset($tables[$key]) && self::mergeAlter($tables[$key], $m[2])) continue;\n            }\n            $plan[] = ['s', $s];\n        }\n        $pdo->rawExec('PRAGMA foreign_keys = OFF');\n        $pdo->rawExec('BEGIN');\n        $done = 0;\n        $failed = 0;\n        $skipped = 0;\n        $errors = [];\n        foreach ($plan as $p) {\n            if ($p[0] === 't') {\n                $list = self::buildCreate($tables[$p[1]]);\n            } else {\n                if (preg_match('/^(?:START\\s+TRANSACTION|BEGIN|COMMIT|ROLLBACK|SAVEPOINT|RELEASE)\\b/i', $p[1])) continue;\n                if (preg_match('/^CREATE\\s+(?:DEFINER\\s*=\\s*\\S+\\s+)?(?:TRIGGER|PROCEDURE|FUNCTION|EVENT)\\b/i', $p[1])) {\n                    $skipped++;\n                    continue;\n                }\n                $list = self::convert($p[1]);\n            }\n            foreach ($list as $q) {\n                try {\n                    self::runList($pdo, [self::unmask($q, $lits)]);\n                    $done++;\n                } catch (Throwable $e) {\n                    $failed++;\n                    if (count($errors) < 3) {\n                        $msg = $e instanceof PDOException ? self::mapPdo($e)->getMessage() : $e->getMessage();\n                        $errors[] = $msg;\n                    }\n                }\n            }\n        }\n        $pdo->rawExec('COMMIT');\n        foreach ($tables as $st) {\n            if (!$st['seq']) continue;\n            $t = str_replace(\"'\", \"''\", self::unq($st['name']));\n            $n = (int)$st['seq'] - 1;\n            try {\n                $pdo->rawExec(\"UPDATE sqlite_sequence SET seq = $n WHERE name = '$t' AND seq < $n\");\n                $pdo->rawExec(\"INSERT INTO sqlite_sequence (name, seq) SELECT '$t', $n WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = '$t')\");\n            } catch (Throwable $e) {\n            }\n        }\n        $pdo->rawExec('PRAGMA foreign_keys = ON');\n        if ($failed || $skipped) {\n            $msg = '[Athera MySQL BETA] ' . $label . ': ' . $done . ' OK, ' . $failed . ' failed' . ($skipped ? ', ' . $skipped . ' skipped (triggers/procedures)' : '');\n            if ($errors) $msg .= '. ' . implode(' | ', $errors);\n            trigger_error($msg, E_USER_NOTICE);\n        }\n    }\n}\n\nclass AthStmt extends PDOStatement\n{\n    private $athPdo = null;\n    private $athSql = '';\n    private $athPost = [];\n    private $athBinds = [];\n    private $athParams = null;\n\n    public function athInit(AthPDO $pdo, string $sql, array $post = []): void\n    {\n        $this->athPdo = $pdo;\n        $this->athSql = $sql;\n        $this->athPost = $post;\n    }\n\n    public function athChanges(): int\n    {\n        return parent::rowCount();\n    }\n\n    public function execute(?array $params = null): bool\n    {\n        $this->athParams = $params;\n        try {\n            $ok = parent::execute($params);\n        } catch (PDOException $e) {\n            throw AthMy::mapPdo($e);\n        }\n        if ($ok && $this->athPost && $this->athPdo !== null) AthMy::runList($this->athPdo, $this->athPost);\n        return $ok;\n    }\n\n    public function bindValue(string|int $param, mixed $value, int $type = PDO::PARAM_STR): bool\n    {\n        $this->athBinds[$param] = [$value, $type];\n        return parent::bindValue($param, $value, $type);\n    }\n\n    public function bindParam(string|int $param, mixed &$var, int $type = PDO::PARAM_STR, int $maxLength = 0, mixed $driverOptions = null): bool\n    {\n        $this->athBinds[$param] = [&$var, $type];\n        return parent::bindParam($param, $var, $type, $maxLength, $driverOptions);\n    }\n\n    public function rowCount(): int\n    {\n        if ($this->athPdo !== null && $this->columnCount() > 0 && AthMy::isQuery($this->athSql)) return $this->athCount();\n        return parent::rowCount();\n    }\n\n    private function athCount(): int\n    {\n        try {\n            $st = $this->athPdo->rawPrepare('SELECT COUNT(*) FROM (' . $this->athSql . ')');\n            if ($this->athParams !== null) {\n                $st->execute($this->athParams);\n            } else {\n                foreach ($this->athBinds as $k => $b) $st->bindValue($k, $b[0], $b[1]);\n                $st->execute();\n            }\n            return (int)$st->fetchColumn();\n        } catch (Throwable $e) {\n            return 0;\n        }\n    }\n}\n\nclass AthPDO extends PDO\n{\n    const MYSQL_ATTR_USE_BUFFERED_QUERY = 1000;\n    const MYSQL_ATTR_LOCAL_INFILE = 1001;\n    const MYSQL_ATTR_INIT_COMMAND = 1002;\n    const MYSQL_ATTR_COMPRESS = 1003;\n    const MYSQL_ATTR_DIRECT_QUERY = 1004;\n    const MYSQL_ATTR_FOUND_ROWS = 1005;\n    const MYSQL_ATTR_IGNORE_SPACE = 1006;\n    const MYSQL_ATTR_SSL_KEY = 1007;\n    const MYSQL_ATTR_SSL_CERT = 1008;\n    const MYSQL_ATTR_SSL_CA = 1009;\n    const MYSQL_ATTR_SSL_CAPATH = 1010;\n    const MYSQL_ATTR_SSL_CIPHER = 1011;\n    const MYSQL_ATTR_SERVER_PUBLIC_KEY = 1012;\n    const MYSQL_ATTR_MULTI_STATEMENTS = 1013;\n    const MYSQL_ATTR_SSL_VERIFY_SERVER_CERT = 1014;\n\n    private $athMy = false;\n\n    public function __construct($dsn, $username = null, $password = null, $options = null)\n    {\n        if (!is_string($dsn) || stripos(ltrim($dsn), 'mysql:') !== 0) {\n            parent::__construct($dsn, $username, $password, $options);\n            return;\n        }\n        $attrs = [];\n        preg_match_all('/(\\w+)\\s*=\\s*([^;]*)/', substr(ltrim($dsn), 6), $pairs, PREG_SET_ORDER);\n        foreach ($pairs as $x) $attrs[strtolower($x[1])] = trim($x[2]);\n        $db = isset($attrs['dbname']) ? $attrs['dbname'] : '';\n        if ($db === '') $db = 'default';\n        $fresh = false;\n        $file = AthMy::dbFile($db, $fresh);\n        $keep = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];\n        $init = null;\n        foreach ((array)$options as $k => $v) {\n            if ($k === 1002) $init = $v;\n            elseif (in_array($k, [PDO::ATTR_ERRMODE, PDO::ATTR_DEFAULT_FETCH_MODE, PDO::ATTR_CASE, PDO::ATTR_ORACLE_NULLS], true)) $keep[$k] = $v;\n        }\n        parent::__construct('sqlite:' . $file, null, null, $keep);\n        $this->athMy = true;\n        AthMy::$db = $db;\n        $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, ['AthStmt']);\n        AthMy::register($this);\n        parent::exec('PRAGMA foreign_keys = ON');\n        if ($fresh && AthMy::$dump !== null) {\n            AthMy::importDump($this, (string)file_get_contents(AthMy::$dump), basename(AthMy::$dump));\n        }\n        if (is_string($init) && $init !== '') $this->exec($init);\n    }\n\n    public static function getAvailableDrivers(): array\n    {\n        return array_values(array_unique(array_merge(parent::getAvailableDrivers(), ['mysql'])));\n    }\n\n    public function rawExec(string $sql): int|false\n    {\n        return parent::exec($sql);\n    }\n\n    public function rawQuery(string $sql): PDOStatement|false\n    {\n        return parent::query($sql);\n    }\n\n    public function rawPrepare(string $sql): PDOStatement|false\n    {\n        return parent::prepare($sql);\n    }\n\n    public function exec(string $statement): int|false\n    {\n        if (!$this->athMy) return parent::exec($statement);\n        try {\n            return AthMy::runList($this, AthMy::translate($statement));\n        } catch (PDOException $e) {\n            throw AthMy::mapPdo($e);\n        }\n    }\n\n    public function query(string $query, ?int $fetchMode = null, mixed ...$fetchModeArgs): PDOStatement|false\n    {\n        if (!$this->athMy) return $fetchMode === null ? parent::query($query) : parent::query($query, $fetchMode, ...$fetchModeArgs);\n        try {\n            $list = AthMy::translate($query);\n            if (!$list) $list = [AthMy::NOOP];\n            $main = array_shift($list);\n            $st = $fetchMode === null ? parent::query($main) : parent::query($main, $fetchMode, ...$fetchModeArgs);\n            if ($st instanceof AthStmt) $st->athInit($this, $main);\n            if ($list) AthMy::runList($this, $list);\n            return $st;\n        } catch (PDOException $e) {\n            throw AthMy::mapPdo($e);\n        }\n    }\n\n    public function prepare(string $query, array $options = []): PDOStatement|false\n    {\n        if (!$this->athMy) return parent::prepare($query, $options);\n        try {\n            $list = AthMy::translate($query);\n            if (!$list) $list = [AthMy::NOOP];\n            $main = array_shift($list);\n            $st = parent::prepare($main, $options);\n            if ($st instanceof AthStmt) $st->athInit($this, $main, $list);\n            return $st;\n        } catch (PDOException $e) {\n            throw AthMy::mapPdo($e);\n        }\n    }\n\n    public function quote(string $string, int $type = PDO::PARAM_STR): string|false\n    {\n        if (!$this->athMy) return parent::quote($string, $type);\n        return \"'\" . AthMy::escape($string) . \"'\";\n    }\n\n    public function getAttribute(int $attribute): mixed\n    {\n        if ($this->athMy) {\n            if ($attribute === PDO::ATTR_DRIVER_NAME) return 'mysql';\n            if ($attribute === PDO::ATTR_SERVER_VERSION) return '8.0.36-athera';\n            if ($attribute === PDO::ATTR_CLIENT_VERSION) return 'mysqlnd 8.3';\n        }\n        return parent::getAttribute($attribute);\n    }\n}\n\nforeach ([\n    'MYSQLI_ASSOC' => 1, 'MYSQLI_NUM' => 2, 'MYSQLI_BOTH' => 3, 'MYSQLI_STORE_RESULT' => 0, 'MYSQLI_USE_RESULT' => 1, 'MYSQLI_ASYNC' => 8,\n    'MYSQLI_REPORT_OFF' => 0, 'MYSQLI_REPORT_ERROR' => 1, 'MYSQLI_REPORT_STRICT' => 2, 'MYSQLI_REPORT_INDEX' => 4, 'MYSQLI_REPORT_ALL' => 255,\n    'MYSQLI_OPT_CONNECT_TIMEOUT' => 0, 'MYSQLI_OPT_LOCAL_INFILE' => 8, 'MYSQLI_INIT_COMMAND' => 3, 'MYSQLI_OPT_INT_AND_FLOAT_NATIVE' => 201,\n    'MYSQLI_SET_CHARSET_NAME' => 7, 'MYSQLI_CLIENT_SSL' => 2048, 'MYSQLI_CLIENT_COMPRESS' => 32, 'MYSQLI_CLIENT_INTERACTIVE' => 1024, 'MYSQLI_CLIENT_FOUND_ROWS' => 2,\n    'MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT' => 1, 'MYSQLI_TRANS_START_READ_WRITE' => 2, 'MYSQLI_TRANS_START_READ_ONLY' => 4,\n    'MYSQLI_TYPE_DECIMAL' => 0, 'MYSQLI_TYPE_TINY' => 1, 'MYSQLI_TYPE_SHORT' => 2, 'MYSQLI_TYPE_LONG' => 3, 'MYSQLI_TYPE_FLOAT' => 4, 'MYSQLI_TYPE_DOUBLE' => 5,\n    'MYSQLI_TYPE_NULL' => 6, 'MYSQLI_TYPE_TIMESTAMP' => 7, 'MYSQLI_TYPE_LONGLONG' => 8, 'MYSQLI_TYPE_INT24' => 9, 'MYSQLI_TYPE_DATE' => 10, 'MYSQLI_TYPE_TIME' => 11,\n    'MYSQLI_TYPE_DATETIME' => 12, 'MYSQLI_TYPE_YEAR' => 13, 'MYSQLI_TYPE_NEWDECIMAL' => 246, 'MYSQLI_TYPE_BLOB' => 252, 'MYSQLI_TYPE_VAR_STRING' => 253, 'MYSQLI_TYPE_STRING' => 254\n] as $ath_name => $ath_value) {\n    if (!defined($ath_name)) define($ath_name, $ath_value);\n}\n\nfunction ath_extension_loaded($name)\n{\n    return in_array(strtolower((string)$name), ['mysqli', 'pdo_mysql', 'mysqlnd'], true) ? true : extension_loaded($name);\n}\n\nclass mysqli_sql_exception extends RuntimeException\n{\n    protected string $sqlstate = '00000';\n\n    public function getSqlState(): string\n    {\n        return $this->sqlstate;\n    }\n\n    public function athState(string $state): void\n    {\n        $this->sqlstate = $state;\n    }\n}\n\nfinal class AthMyi\n{\n    public static function fail($obj, PDOException $e, string $where)\n    {\n        $e = AthMy::mapPdo($e);\n        $info = (isset($e->errorInfo[1]) && $e->errorInfo[1] !== null) ? $e->errorInfo : ['HY000', 1105, $e->getMessage()];\n        $obj->errno = (int)$info[1];\n        $obj->error = (string)$info[2];\n        $obj->sqlstate = (string)$info[0];\n        $obj->error_list = [['errno' => $obj->errno, 'sqlstate' => $obj->sqlstate, 'error' => $obj->error]];\n        if (AthMy::$report & 2) {\n            $x = new mysqli_sql_exception($obj->error, $obj->errno);\n            $x->athState($obj->sqlstate);\n            throw $x;\n        }\n        if (AthMy::$report & 1) trigger_error($where . '(): ' . $obj->error, E_USER_WARNING);\n        return false;\n    }\n\n    public static function clear($obj): void\n    {\n        $obj->errno = 0;\n        $obj->error = '';\n        $obj->sqlstate = '00000';\n        $obj->error_list = [];\n    }\n\n    public static function open($db): AthPDO\n    {\n        return new AthPDO('mysql:dbname=' . (($db === null || $db === '') ? 'default' : $db));\n    }\n\n    public static function strings(array $row): array\n    {\n        foreach ($row as $k => $v) {\n            if ($v !== null && !is_string($v)) $row[$k] = (string)$v;\n        }\n        return $row;\n    }\n}\n\nclass mysqli_result implements IteratorAggregate\n{\n    public $current_field = 0;\n    public $field_count = 0;\n    public $lengths = null;\n    public $num_rows = 0;\n    public $type = 0;\n    private $names = [];\n    private $rows = [];\n    private $pos = 0;\n\n    public function __construct($source = null, bool $strings = true)\n    {\n        if ($source instanceof PDOStatement) {\n            $names = [];\n            for ($i = 0, $n = $source->columnCount(); $i < $n; $i++) {\n                $meta = $source->getColumnMeta($i);\n                $names[] = is_array($meta) && isset($meta['name']) ? $meta['name'] : (string)$i;\n            }\n            $this->athLoad($names, $source->fetchAll(PDO::FETCH_NUM), $strings);\n        }\n    }\n\n    public function athLoad(array $names, array $rows, bool $strings): void\n    {\n        $this->names = $names;\n        $this->rows = $strings ? array_map([AthMyi::class, 'strings'], $rows) : $rows;\n        $this->field_count = count($names);\n        $this->num_rows = count($rows);\n        $this->pos = 0;\n    }\n\n    private function assoc(array $row): array\n    {\n        $out = [];\n        foreach ($this->names as $i => $name) $out[$name] = $row[$i] ?? null;\n        return $out;\n    }\n\n    private function both(array $row): array\n    {\n        $out = [];\n        foreach ($this->names as $i => $name) {\n            $out[$i] = $row[$i] ?? null;\n            $out[$name] = $row[$i] ?? null;\n        }\n        return $out;\n    }\n\n    private function next(): ?array\n    {\n        if ($this->pos >= count($this->rows)) return null;\n        $row = $this->rows[$this->pos++];\n        $this->lengths = array_map(function ($v) { return $v === null ? 0 : strlen((string)$v); }, $row);\n        return $row;\n    }\n\n    public function fetch_assoc(): array|null|false\n    {\n        $row = $this->next();\n        return $row === null ? null : $this->assoc($row);\n    }\n\n    public function fetch_row(): array|null|false\n    {\n        return $this->next();\n    }\n\n    public function fetch_array(int $mode = MYSQLI_BOTH): array|null|false\n    {\n        $row = $this->next();\n        if ($row === null) return null;\n        if ($mode === MYSQLI_ASSOC) return $this->assoc($row);\n        if ($mode === MYSQLI_NUM) return $row;\n        return $this->both($row);\n    }\n\n    public function fetch_object(string $class = 'stdClass', array $constructor_args = []): object|null|false\n    {\n        $row = $this->next();\n        if ($row === null) return null;\n        $obj = $class === 'stdClass' ? new stdClass() : new $class(...$constructor_args);\n        foreach ($this->assoc($row) as $k => $v) $obj->$k = $v;\n        return $obj;\n    }\n\n    public function fetch_all(int $mode = MYSQLI_NUM): array\n    {\n        $out = [];\n        while (($row = $this->next()) !== null) {\n            $out[] = $mode === MYSQLI_ASSOC ? $this->assoc($row) : ($mode === MYSQLI_BOTH ? $this->both($row) : $row);\n        }\n        return $out;\n    }\n\n    public function fetch_column(int $column = 0): string|int|float|null|false\n    {\n        $row = $this->next();\n        if ($row === null) return false;\n        return $row[$column] ?? null;\n    }\n\n    private function field(int $i): object\n    {\n        $o = new stdClass();\n        $o->name = $this->names[$i];\n        $o->orgname = $this->names[$i];\n        $o->table = '';\n        $o->orgtable = '';\n        $o->def = '';\n        $o->db = AthMy::$db;\n        $o->catalog = 'def';\n        $o->max_length = 0;\n        $o->length = 0;\n        $o->charsetnr = 255;\n        $o->flags = 0;\n        $o->type = MYSQLI_TYPE_VAR_STRING;\n        $o->decimals = 0;\n        return $o;\n    }\n\n    public function fetch_field(): object|false\n    {\n        if ($this->current_field >= count($this->names)) return false;\n        return $this->field($this->current_field++);\n    }\n\n    public function fetch_fields(): array\n    {\n        $out = [];\n        foreach ($this->names as $i => $n) $out[] = $this->field($i);\n        return $out;\n    }\n\n    public function fetch_field_direct(int $index): object|false\n    {\n        return isset($this->names[$index]) ? $this->field($index) : false;\n    }\n\n    public function field_seek(int $index): bool\n    {\n        $this->current_field = $index;\n        return true;\n    }\n\n    public function data_seek(int $offset): bool\n    {\n        if ($offset < 0 || $offset > count($this->rows)) return false;\n        $this->pos = $offset;\n        return true;\n    }\n\n    public function free(): void\n    {\n        $this->rows = [];\n        $this->pos = 0;\n    }\n\n    public function close(): void\n    {\n        $this->free();\n    }\n\n    public function free_result(): void\n    {\n        $this->free();\n    }\n\n    public function getIterator(): Iterator\n    {\n        $this->pos = 0;\n        return (function () {\n            while (($row = $this->next()) !== null) yield $this->assoc($row);\n        })();\n    }\n}\n\nclass mysqli_stmt\n{\n    public $affected_rows = 0;\n    public $insert_id = 0;\n    public $num_rows = 0;\n    public $param_count = 0;\n    public $field_count = 0;\n    public $errno = 0;\n    public $error = '';\n    public $error_list = [];\n    public $sqlstate = '00000';\n    public $id = 1;\n    private $conn = null;\n    private $st = null;\n    private $sql = '';\n    private $types = '';\n    private $refs = [];\n    private $out = [];\n    private $names = [];\n    private $rows = null;\n    private $pos = 0;\n    private $isInsert = false;\n\n    public function __construct($mysqli = null, $query = null)\n    {\n        $this->conn = $mysqli;\n        if ($query !== null) $this->prepare($query);\n    }\n\n    public function prepare(string $query): bool\n    {\n        AthMyi::clear($this);\n        try {\n            $list = AthMy::translate($query);\n            if (!$list) $list = [AthMy::NOOP];\n            $main = array_shift($list);\n            $this->st = $this->conn->athPdo()->rawPrepare($main);\n            if ($this->st instanceof AthStmt) $this->st->athInit($this->conn->athPdo(), $main, $list);\n            $this->sql = $main;\n            $lits = [];\n            $this->param_count = substr_count(AthMy::mask($main, $lits), '?');\n            $this->isInsert = (bool)preg_match('/^\\s*(?:INSERT|REPLACE)\\b/i', $main);\n            return true;\n        } catch (PDOException $e) {\n            return AthMyi::fail($this, $e, 'mysqli::prepare') !== false;\n        }\n    }\n\n    public function bind_param(string $types, mixed &...$vars): bool\n    {\n        $this->types = $types;\n        $this->refs = [];\n        foreach ($vars as $i => &$v) $this->refs[$i] = &$v;\n        unset($v);\n        return true;\n    }\n\n    public function bind_result(mixed &...$vars): bool\n    {\n        $this->out = [];\n        foreach ($vars as $i => &$v) $this->out[$i] = &$v;\n        unset($v);\n        return true;\n    }\n\n    public function execute(?array $params = null): bool\n    {\n        AthMyi::clear($this);\n        try {\n            $i = 1;\n            if ($params !== null) {\n                foreach (array_values($params) as $v) {\n                    $this->st->bindValue($i++, $v, $v === null ? PDO::PARAM_NULL : (is_int($v) ? PDO::PARAM_INT : PDO::PARAM_STR));\n                }\n            } else {\n                foreach ($this->refs as $k => $v) {\n                    $t = isset($this->types[$k]) ? $this->types[$k] : 's';\n                    if ($v === null) $this->st->bindValue($i, null, PDO::PARAM_NULL);\n                    elseif ($t === 'i') $this->st->bindValue($i, (int)$v, PDO::PARAM_INT);\n                    elseif ($t === 'b') $this->st->bindValue($i, (string)$v, PDO::PARAM_LOB);\n                    else $this->st->bindValue($i, $t === 'd' ? (float)$v : (string)$v, PDO::PARAM_STR);\n                    $i++;\n                }\n            }\n            $this->st->execute();\n            $this->rows = null;\n            $this->pos = 0;\n            $this->num_rows = 0;\n            $this->field_count = $this->st->columnCount();\n            if ($this->field_count > 0) {\n                $this->names = [];\n                for ($c = 0; $c < $this->field_count; $c++) {\n                    $meta = $this->st->getColumnMeta($c);\n                    $this->names[] = is_array($meta) && isset($meta['name']) ? $meta['name'] : (string)$c;\n                }\n                $this->rows = $this->st->fetchAll(PDO::FETCH_NUM);\n                $this->affected_rows = count($this->rows);\n            } else {\n                $this->affected_rows = $this->st instanceof AthStmt ? $this->st->athChanges() : $this->st->rowCount();\n                $this->insert_id = $this->isInsert && $this->affected_rows > 0 ? (int)$this->conn->athPdo()->lastInsertId() : 0;\n                $this->conn->athSetResult($this->affected_rows, $this->insert_id);\n            }\n            return true;\n        } catch (PDOException $e) {\n            return AthMyi::fail($this, $e, 'mysqli_stmt::execute') !== false;\n        }\n    }\n\n    public function fetch(): ?bool\n    {\n        if ($this->rows === null || $this->pos >= count($this->rows)) return null;\n        $row = $this->rows[$this->pos++];\n        foreach ($this->out as $i => &$ref) $ref = $row[$i] ?? null;\n        unset($ref);\n        return true;\n    }\n\n    public function get_result(): mysqli_result|false\n    {\n        if ($this->rows === null) return false;\n        $r = new mysqli_result();\n        $r->athLoad($this->names, $this->rows, false);\n        $this->num_rows = count($this->rows);\n        return $r;\n    }\n\n    public function result_metadata(): mysqli_result|false\n    {\n        if ($this->st === null || $this->st->columnCount() === 0) return false;\n        $names = [];\n        for ($c = 0, $n = $this->st->columnCount(); $c < $n; $c++) {\n            $meta = $this->st->getColumnMeta($c);\n            $names[] = is_array($meta) && isset($meta['name']) ? $meta['name'] : (string)$c;\n        }\n        $r = new mysqli_result();\n        $r->athLoad($names, [], false);\n        return $r;\n    }\n\n    public function store_result(): bool\n    {\n        $this->num_rows = $this->rows === null ? 0 : count($this->rows);\n        return true;\n    }\n\n    public function data_seek(int $offset): void\n    {\n        $this->pos = max(0, $offset);\n    }\n\n    public function free_result(): void\n    {\n        $this->rows = null;\n        $this->pos = 0;\n    }\n\n    public function reset(): bool\n    {\n        $this->free_result();\n        return true;\n    }\n\n    public function close(): bool\n    {\n        $this->free_result();\n        return true;\n    }\n\n    public function attr_get(int $attribute): int|false\n    {\n        return 0;\n    }\n\n    public function attr_set(int $attribute, int $value): bool\n    {\n        return true;\n    }\n\n    public function more_results(): bool\n    {\n        return false;\n    }\n\n    public function next_result(): bool\n    {\n        return false;\n    }\n\n    public function send_long_data(int $param_num, string $data): bool\n    {\n        return true;\n    }\n}\n\nclass mysqli\n{\n    public $affected_rows = 0;\n    public $client_info = 'mysqlnd 8.3';\n    public $client_version = 80333;\n    public $connect_errno = 0;\n    public $connect_error = null;\n    public $errno = 0;\n    public $error = '';\n    public $error_list = [];\n    public $field_count = 0;\n    public $host_info = 'localhost via Athera';\n    public $info = null;\n    public $insert_id = 0;\n    public $protocol_version = 10;\n    public $server_info = '8.0.36-athera';\n    public $server_version = 80036;\n    public $sqlstate = '00000';\n    public $thread_id = 1;\n    public $warning_count = 0;\n    private $ath = null;\n    private $last = null;\n    private $queue = [];\n\n    public function __construct($hostname = null, $username = null, $password = null, $database = null, $port = null, $socket = null)\n    {\n        if ($hostname !== null || $database !== null) $this->real_connect($hostname, $username, $password, $database, $port, $socket);\n    }\n\n    public function real_connect($hostname = null, $username = null, $password = null, $database = null, $port = null, $socket = null, $flags = 0): bool\n    {\n        $this->ath = AthMyi::open($database);\n        return true;\n    }\n\n    public function athPdo(): AthPDO\n    {\n        if ($this->ath === null) throw new Error('mysqli object is already closed');\n        return $this->ath;\n    }\n\n    public function athSetResult(int $affected, $insertId): void\n    {\n        $this->affected_rows = $affected;\n        $this->insert_id = $insertId;\n    }\n\n    public function query(string $query, int $result_mode = MYSQLI_STORE_RESULT): mysqli_result|bool\n    {\n        AthMyi::clear($this);\n        $pdo = $this->athPdo();\n        try {\n            $list = AthMy::translate($query);\n            if (!$list) return true;\n            if (AthMy::isQuery($query)) {\n                $main = array_shift($list);\n                $st = $pdo->rawQuery($main);\n                if ($list) AthMy::runList($pdo, $list);\n                $res = new mysqli_result($st, true);\n                $this->affected_rows = $res->num_rows;\n                $this->field_count = $res->field_count;\n                return $res;\n            }\n            $this->affected_rows = AthMy::runList($pdo, $list);\n            $this->field_count = 0;\n            $this->insert_id = preg_match('/^(?:INSERT|REPLACE)$/', AthMy::kind($query)) && $this->affected_rows > 0 ? (int)$pdo->lastInsertId() : 0;\n            return true;\n        } catch (PDOException $e) {\n            return AthMyi::fail($this, $e, 'mysqli::query');\n        }\n    }\n\n    public function real_query(string $query): bool\n    {\n        $this->last = $this->query($query);\n        return $this->last !== false;\n    }\n\n    public function store_result(int $mode = 0): mysqli_result|false\n    {\n        return $this->last instanceof mysqli_result ? $this->last : false;\n    }\n\n    public function use_result(): mysqli_result|false\n    {\n        return $this->store_result();\n    }\n\n    public function multi_query(string $query): bool\n    {\n        $this->queue = AthMy::translate($query);\n        $this->last = null;\n        return $this->queue ? $this->step() : true;\n    }\n\n    private function step(): bool\n    {\n        AthMyi::clear($this);\n        $q = array_shift($this->queue);\n        $pdo = $this->athPdo();\n        try {\n            if (AthMy::isQuery($q)) {\n                $this->last = new mysqli_result($pdo->rawQuery($q), true);\n            } else {\n                $this->affected_rows = AthMy::runList($pdo, [$q]);\n                $this->last = null;\n            }\n            return true;\n        } catch (PDOException $e) {\n            $this->queue = [];\n            return AthMyi::fail($this, $e, 'mysqli::multi_query') !== false;\n        }\n    }\n\n    public function more_results(): bool\n    {\n        return count($this->queue) > 0;\n    }\n\n    public function next_result(): bool\n    {\n        return $this->queue ? $this->step() : false;\n    }\n\n    public function prepare(string $query): mysqli_stmt|false\n    {\n        AthMyi::clear($this);\n        $stmt = new mysqli_stmt($this);\n        if (!$stmt->prepare($query)) return false;\n        return $stmt;\n    }\n\n    public function execute_query(string $query, ?array $params = null): mysqli_result|bool\n    {\n        $stmt = $this->prepare($query);\n        if ($stmt === false) return false;\n        if (!$stmt->execute($params)) return false;\n        $res = $stmt->get_result();\n        return $res === false ? true : $res;\n    }\n\n    public function real_escape_string(string $string): string\n    {\n        return AthMy::escape($string);\n    }\n\n    public function escape_string(string $string): string\n    {\n        return AthMy::escape($string);\n    }\n\n    public function select_db(string $database): bool\n    {\n        $this->ath = AthMyi::open($database);\n        return true;\n    }\n\n    public function set_charset(string $charset): bool\n    {\n        return true;\n    }\n\n    public function character_set_name(): string\n    {\n        return 'utf8mb4';\n    }\n\n    public function get_charset(): object\n    {\n        $o = new stdClass();\n        $o->charset = 'utf8mb4';\n        $o->collation = 'utf8mb4_general_ci';\n        $o->dir = '';\n        $o->min_length = 1;\n        $o->max_length = 4;\n        $o->number = 45;\n        $o->state = 1;\n        $o->comment = '';\n        return $o;\n    }\n\n    public function begin_transaction(int $flags = 0, ?string $name = null): bool\n    {\n        $pdo = $this->athPdo();\n        if (!$pdo->inTransaction()) $pdo->beginTransaction();\n        return true;\n    }\n\n    public function commit(int $flags = 0, ?string $name = null): bool\n    {\n        $pdo = $this->athPdo();\n        if ($pdo->inTransaction()) $pdo->commit();\n        return true;\n    }\n\n    public function rollback(int $flags = 0, ?string $name = null): bool\n    {\n        $pdo = $this->athPdo();\n        if ($pdo->inTransaction()) $pdo->rollBack();\n        return true;\n    }\n\n    public function autocommit(bool $enable): bool\n    {\n        $pdo = $this->athPdo();\n        if ($enable && $pdo->inTransaction()) $pdo->commit();\n        if (!$enable && !$pdo->inTransaction()) $pdo->beginTransaction();\n        return true;\n    }\n\n    public function ping(): bool\n    {\n        return $this->ath !== null;\n    }\n\n    public function close(): bool\n    {\n        $this->ath = null;\n        return true;\n    }\n\n    public function options(int $option, $value): bool\n    {\n        return true;\n    }\n\n    public function ssl_set($key = null, $certificate = null, $ca = null, $capath = null, $cipher = null): bool\n    {\n        return true;\n    }\n\n    public function get_server_info(): string\n    {\n        return $this->server_info;\n    }\n\n    public function get_connection_stats(): array|false\n    {\n        return [];\n    }\n\n    public function stat(): string|false\n    {\n        return 'Uptime: 1  Threads: 1';\n    }\n\n    public function get_warnings(): mixed\n    {\n        return false;\n    }\n\n    public function kill(int $process_id): bool\n    {\n        return true;\n    }\n}\n\nfunction mysqli_report(int $flags): bool { AthMy::$report = $flags; return true; }\nfunction mysqli_init(): mysqli { return new mysqli(); }\nfunction mysqli_connect($hostname = null, $username = null, $password = null, $database = null, $port = null, $socket = null) { return new mysqli($hostname ?? 'localhost', $username, $password, $database, $port, $socket); }\nfunction mysqli_real_connect(mysqli $mysql, $hostname = null, $username = null, $password = null, $database = null, $port = null, $socket = null, $flags = 0): bool { return $mysql->real_connect($hostname, $username, $password, $database, $port, $socket, $flags); }\nfunction mysqli_connect_error(): ?string { return null; }\nfunction mysqli_connect_errno(): int { return 0; }\nfunction mysqli_query(mysqli $mysql, string $query, int $result_mode = MYSQLI_STORE_RESULT) { return $mysql->query($query, $result_mode); }\nfunction mysqli_real_query(mysqli $mysql, string $query): bool { return $mysql->real_query($query); }\nfunction mysqli_multi_query(mysqli $mysql, string $query): bool { return $mysql->multi_query($query); }\nfunction mysqli_next_result(mysqli $mysql): bool { return $mysql->next_result(); }\nfunction mysqli_more_results(mysqli $mysql): bool { return $mysql->more_results(); }\nfunction mysqli_store_result(mysqli $mysql, int $mode = 0) { return $mysql->store_result($mode); }\nfunction mysqli_use_result(mysqli $mysql) { return $mysql->use_result(); }\nfunction mysqli_error(mysqli $mysql): string { return $mysql->error; }\nfunction mysqli_errno(mysqli $mysql): int { return $mysql->errno; }\nfunction mysqli_sqlstate(mysqli $mysql): string { return $mysql->sqlstate; }\nfunction mysqli_error_list(mysqli $mysql): array { return $mysql->error_list; }\nfunction mysqli_insert_id(mysqli $mysql): int|string { return $mysql->insert_id; }\nfunction mysqli_affected_rows(mysqli $mysql): int|string { return $mysql->affected_rows; }\nfunction mysqli_field_count(mysqli $mysql): int { return $mysql->field_count; }\nfunction mysqli_close(mysqli $mysql): bool { return $mysql->close(); }\nfunction mysqli_ping(mysqli $mysql): bool { return $mysql->ping(); }\nfunction mysqli_select_db(mysqli $mysql, string $database): bool { return $mysql->select_db($database); }\nfunction mysqli_set_charset(mysqli $mysql, string $charset): bool { return $mysql->set_charset($charset); }\nfunction mysqli_character_set_name(mysqli $mysql): string { return $mysql->character_set_name(); }\nfunction mysqli_real_escape_string(mysqli $mysql, string $string): string { return $mysql->real_escape_string($string); }\nfunction mysqli_escape_string(mysqli $mysql, string $string): string { return $mysql->real_escape_string($string); }\nfunction mysqli_begin_transaction(mysqli $mysql, int $flags = 0, ?string $name = null): bool { return $mysql->begin_transaction($flags, $name); }\nfunction mysqli_commit(mysqli $mysql, int $flags = 0, ?string $name = null): bool { return $mysql->commit($flags, $name); }\nfunction mysqli_rollback(mysqli $mysql, int $flags = 0, ?string $name = null): bool { return $mysql->rollback($flags, $name); }\nfunction mysqli_autocommit(mysqli $mysql, bool $enable): bool { return $mysql->autocommit($enable); }\nfunction mysqli_get_server_info(mysqli $mysql): string { return $mysql->get_server_info(); }\nfunction mysqli_get_client_info(?mysqli $mysql = null): string { return 'mysqlnd 8.3'; }\nfunction mysqli_options(mysqli $mysql, int $option, $value): bool { return true; }\nfunction mysqli_ssl_set(mysqli $mysql, $key = null, $certificate = null, $ca = null, $capath = null, $cipher = null): bool { return true; }\nfunction mysqli_stat(mysqli $mysql) { return $mysql->stat(); }\nfunction mysqli_thread_id(mysqli $mysql): int { return 1; }\nfunction mysqli_warning_count(mysqli $mysql): int { return 0; }\nfunction mysqli_info(mysqli $mysql): ?string { return null; }\nfunction mysqli_prepare(mysqli $mysql, string $query) { return $mysql->prepare($query); }\nfunction mysqli_execute_query(mysqli $mysql, string $query, ?array $params = null) { return $mysql->execute_query($query, $params); }\nfunction mysqli_fetch_assoc(mysqli_result $result) { return $result->fetch_assoc(); }\nfunction mysqli_fetch_row(mysqli_result $result) { return $result->fetch_row(); }\nfunction mysqli_fetch_array(mysqli_result $result, int $mode = MYSQLI_BOTH) { return $result->fetch_array($mode); }\nfunction mysqli_fetch_object(mysqli_result $result, string $class = 'stdClass', array $constructor_args = []) { return $result->fetch_object($class, $constructor_args); }\nfunction mysqli_fetch_all(mysqli_result $result, int $mode = MYSQLI_NUM): array { return $result->fetch_all($mode); }\nfunction mysqli_fetch_column(mysqli_result $result, int $column = 0) { return $result->fetch_column($column); }\nfunction mysqli_fetch_field(mysqli_result $result) { return $result->fetch_field(); }\nfunction mysqli_fetch_fields(mysqli_result $result): array { return $result->fetch_fields(); }\nfunction mysqli_fetch_field_direct(mysqli_result $result, int $index) { return $result->fetch_field_direct($index); }\nfunction mysqli_field_seek(mysqli_result $result, int $index): bool { return $result->field_seek($index); }\nfunction mysqli_data_seek(mysqli_result $result, int $offset): bool { return $result->data_seek($offset); }\nfunction mysqli_num_rows(mysqli_result $result): int|string { return $result->num_rows; }\nfunction mysqli_num_fields(mysqli_result $result): int { return $result->field_count; }\nfunction mysqli_free_result(mysqli_result $result): void { $result->free(); }\nfunction mysqli_stmt_bind_param(mysqli_stmt $statement, string $types, mixed &...$vars): bool { return $statement->bind_param($types, ...$vars); }\nfunction mysqli_stmt_bind_result(mysqli_stmt $statement, mixed &...$vars): bool { return $statement->bind_result(...$vars); }\nfunction mysqli_stmt_execute(mysqli_stmt $statement, ?array $params = null): bool { return $statement->execute($params); }\nfunction mysqli_stmt_fetch(mysqli_stmt $statement): ?bool { return $statement->fetch(); }\nfunction mysqli_stmt_get_result(mysqli_stmt $statement) { return $statement->get_result(); }\nfunction mysqli_stmt_store_result(mysqli_stmt $statement): bool { return $statement->store_result(); }\nfunction mysqli_stmt_num_rows(mysqli_stmt $statement): int|string { return $statement->num_rows; }\nfunction mysqli_stmt_affected_rows(mysqli_stmt $statement): int|string { return $statement->affected_rows; }\nfunction mysqli_stmt_insert_id(mysqli_stmt $statement): int|string { return $statement->insert_id; }\nfunction mysqli_stmt_close(mysqli_stmt $statement): bool { return $statement->close(); }\nfunction mysqli_stmt_reset(mysqli_stmt $statement): bool { return $statement->reset(); }\nfunction mysqli_stmt_free_result(mysqli_stmt $statement): void { $statement->free_result(); }\nfunction mysqli_stmt_error(mysqli_stmt $statement): string { return $statement->error; }\nfunction mysqli_stmt_errno(mysqli_stmt $statement): int { return $statement->errno; }\nfunction mysqli_stmt_param_count(mysqli_stmt $statement): int { return $statement->param_count; }\nfunction mysqli_stmt_field_count(mysqli_stmt $statement): int { return $statement->field_count; }\nfunction mysqli_stmt_data_seek(mysqli_stmt $statement, int $offset): void { $statement->data_seek($offset); }\nfunction mysqli_stmt_result_metadata(mysqli_stmt $statement) { return $statement->result_metadata(); }\n";
+ 
assets/app/php.js Modified +40 -1
⋮ 12 unchanged lines ⋮
    var BATCH_BYTES = 16 * 1024 * 1024;
    var PHP_EXT = ["php", "phtml", "inc", "html", "htm", "json", "xml", "csv", "txt", "ini", "env", "sql", "md", "yml", "yaml",
      "twig", "tpl", "svg", "log", "lock", "htaccess", "sqlite", "sqlite3", "db"];
-   var DB = ["sqlite", "sqlite3", "db"];
+   var DB = ["sqlite", "sqlite3", "db", "sql"];
+   var SHIM_PATH = "../internal/shared/preload/athera-mysql.php";
+   var REWRITE_EXT = ["php", "phtml", "inc"];
+   var REWRITE_TEST = /PDO|mysqli|extension_loaded/i;
  
    var worker = null, workerUrl = null, wasm = null, ready = null, seq = 0;
    var pending = {};
⋮ 3 unchanged lines ⋮
    var dirty = new Set();
    var syncing = null;
    var cookies = {};
+   var shimState = null;
+   var shimNeeded = false;
  
    function loadScript(src) {
      return new Promise(function (resolve, reject) {
⋮ 29 unchanged lines ⋮
      worker = null;
      ready = null;
      synced.clear();
+     shimState = null;
+     shimNeeded = false;
      scanned = false;
      needsScan = true;
      Object.keys(pending).forEach(function (id) {
⋮ 88 unchanged lines ⋮
      }
  
      function queue(path, data, stamp) {
+       data = rewrite(path, data);
        writes.push({ path: path, data: data });
        bytes += typeof data === "string" ? data.length : data.byteLength;
        synced.set(path, stamp);
⋮ 57 unchanged lines ⋮
          synced.delete(p);
        }
      });
+     if (mysqlOn() && shimNeeded && shimState !== true) {
+       writes.push({ path: SHIM_PATH, data: A.mysqlShim });
+       shimState = true;
+     } else if (!mysqlOn() && shimState === true) {
+       deletes.push(SHIM_PATH);
+       shimState = false;
+     }
      await flush();
    }
  
+   function mysqlOn() {
+     return !!A.mysqlShim && A.settings.get("mysqlEmulation") !== false;
+   }
+ 
+   function rewrite(path, data) {
+     if (!mysqlOn() || REWRITE_EXT.indexOf(util.ext(path)) < 0) return data;
+     var text = typeof data === "string" ? data : new TextDecoder().decode(data);
+     if (!REWRITE_TEST.test(text)) return data;
+     shimNeeded = true;
+     var out = text
+       .replace(/\bnew\s+\\?PDO\s*\(/gi, "new \\AthPDO(")
+       .replace(/\\?\bPDO::(MYSQL_ATTR_\w+|getAvailableDrivers)/gi, "\\AthPDO::$1")
+       .replace(/\bextends\s+\\?PDO\b(?!\w|::)/gi, "extends \\AthPDO")
+       .replace(/\bextension_loaded\s*\(/g, "ath_extension_loaded(");
+     return out === text ? data : out;
+   }
+ 
    function hash(text) {
      var h = 0;
      for (var i = 0; i < text.length; i++) h = (h * 31 + text.charCodeAt(i)) | 0;
⋮ 22 unchanged lines ⋮
  
    A.on("workspace", function () {
      cookies = {};
+     shimNeeded = false;
      synced.clear();
      scanned = false;
      needsScan = true;
⋮ 1 unchanged line ⋮
      if (worker) reset();
    });
    A.on("files-changed", function () { needsScan = true; });
+   A.on("settings", function (keys) {
+     if (keys.indexOf("mysqlEmulation") < 0) return;
+     synced.clear();
+     scanned = false;
+     needsScan = true;
+   });
    A.on("saved", function (tab) { if (tab && tab.path != null) dirty.add(tab.path); });
  
    A.php = {
⋮ 49 unchanged lines ⋮
assets/app/preview.js Modified +1 -1
⋮ 55 unchanged lines ⋮
          if (pv.target && pv.routes[pv.target.id]) pv.routes[pv.target.id] = { query: pv.routes[pv.target.id].query || "" };
          pv.build();
        });
-       A.on("settings", function (keys) { if (pv.open && keys.indexOf("phpRuntime") >= 0) pv.build(); });
+       A.on("settings", function (keys) { if (pv.open && (keys.indexOf("phpRuntime") >= 0 || keys.indexOf("mysqlEmulation") >= 0)) pv.build(); });
        pane.querySelector("[data-preview-window]").addEventListener("click", pv.openWindow);
        pv.statusEl.addEventListener("click", showErrors);
  
⋮ 329 unchanged lines ⋮
assets/app/search.js Added +855 -0
+ (function () {
+   "use strict";
+ 
+   var A = window.Athera;
+   var util = A.util;
+   var fs = A.fs;
+   var tabs = A.tabs;
+   var t = A.t;
+   var $ = function (id) { return document.getElementById(id); };
+ 
+   var STAGE_MATCHES = 200;
+   var FILE_MATCH_CAP = 500;
+   var MAX_FILE_BYTES = 1500000;
+   var MAX_LINE = 20000;
+   var PARALLEL = 4;
+   var SLICE_MS = 10;
+   var AUTO_MIN = 2;
+   var SKIP_NAME = /\.min\.(js|css)$|\.map$|\.lock$|-lock\.json$/i;
+ 
+   var els = {};
+   var prefs = { caseSensitive: false, word: false, regex: false, files: "", open: false, replace: false, height: 0 };
+   var job = null;
+   var seq = 0;
+   var replacing = false;
+   var undoStack = [];
+   var MAX_UNDO = 5;
+ 
+   function escapeRe(s) {
+     return s.replace(/[.*+?^${}()|[\]\\\/]/g, "\\$&");
+   }
+ 
+   function compile(opts) {
+     var base = opts.regex ? opts.query : escapeRe(opts.query);
+     var flags = "g" + (opts.caseSensitive ? "" : "i");
+     var attempts = opts.word
+       ? [["(?<![\\p{L}\\p{N}_])(?:" + base + ")(?![\\p{L}\\p{N}_])", flags + "u"], ["\\b(?:" + base + ")\\b", flags]]
+       : [[base, flags + "u"], [base, flags]];
+     var first = null;
+     for (var i = 0; i < attempts.length; i++) {
+       try { return new RegExp(attempts[i][0], attempts[i][1]); } catch (e) { first = first || e; }
+     }
+     throw first;
+   }
+ 
+   function expand(repl, m, regexMode) {
+     if (!regexMode) return repl;
+     return repl.replace(/\$(\$|&|\d{1,2}|<[^>]*>)/g, function (all, k) {
+       if (k === "$") return "$";
+       if (k === "&") return m[0];
+       if (k.charAt(0) === "<") return (m.groups && m.groups[k.slice(1, -1)]) || "";
+       var n = parseInt(k, 10);
+       if (n > 0 && n < m.length) return m[n] || "";
+       if (k.length === 2) {
+         var d = parseInt(k.charAt(0), 10);
+         if (d > 0 && d < m.length) return (m[d] || "") + k.charAt(1);
+       }
+       return all;
+     });
+   }
+ 
+   function glob(token) {
+     var re = escapeRe(token).replace(/\\\*\\\*/g, "\u0001").replace(/\\\*/g, "[^/]*").replace(/\u0001/g, ".*").replace(/\\\?/g, "[^/]");
+     return re;
+   }
+ 
+   function predicate(token) {
+     var dir = /\/$/.test(token);
+     var body = token.replace(/^\.?\//, "").replace(/\/$/, "");
+     if (!body) return null;
+     var hasGlob = /[*?]/.test(body);
+     var hasSlash = body.indexOf("/") >= 0;
+     var src = hasGlob ? glob(body) : escapeRe(body);
+     var re;
+     if (dir) re = new RegExp("(^|/)" + src + "/", "i");
+     else if (hasSlash) re = new RegExp("(^|/)" + src + "(/|$)", "i");
+     else if (hasGlob || body.indexOf(".") >= 0) re = new RegExp("(^|/)" + src + "$", "i");
+     else re = new RegExp("(^|/)" + src + "(/|$)", "i");
+     return function (path) { return re.test(path); };
+   }
+ 
+   function filterOf(spec) {
+     var include = [], exclude = [];
+     String(spec || "").split(",").forEach(function (raw) {
+       var tok = raw.trim();
+       if (!tok) return;
+       var neg = tok.charAt(0) === "!";
+       var p = predicate(neg ? tok.slice(1).trim() : tok);
+       if (p) (neg ? exclude : include).push(p);
+     });
+     return function (path) {
+       if (exclude.some(function (p) { return p(path); })) return false;
+       return !include.length || include.some(function (p) { return p(path); });
+     };
+   }
+ 
+   function eligible(path) {
+     var name = util.basename(path);
+     if (SKIP_NAME.test(name)) return false;
+     if (fs.isBinary(name)) return false;
+     return !(fs.isImage(name) && util.ext(name) !== "svg");
+   }
+ 
+   async function readSearchable(path) {
+     var tab = tabs.byPath(path);
+     if (tab) return tab.kind === "text" ? tabs.textOf(tab) : null;
+     try {
+       var file = await fs.provider.readFile(path);
+       if (file.size > MAX_FILE_BYTES) return null;
+       var text = await file.text();
+       return text.indexOf("\u0000") >= 0 ? null : text;
+     } catch (e) {
+       return null;
+     }
+   }
+ 
+   function scanText(re, text) {
+     var lines = text.split("\n");
+     var matches = [], truncated = false;
+     var rx = new RegExp(re.source, re.flags);
+     for (var i = 0; i < lines.length && !truncated; i++) {
+       var line = lines[i];
+       var body = line.charCodeAt(line.length - 1) === 13 ? line.slice(0, -1) : line;
+       if (!body.length || body.length > MAX_LINE) continue;
+       rx.lastIndex = 0;
+       var m;
+       while ((m = rx.exec(body)) !== null) {
+         if (m[0].length === 0) { rx.lastIndex++; continue; }
+         if (matches.length >= FILE_MATCH_CAP) { truncated = true; break; }
+         var from = Math.max(0, m.index - 36);
+         var end = m.index + m[0].length;
+         var to = Math.min(body.length, end + 90);
+         var pre = body.slice(from, m.index);
+         if (from === 0) pre = pre.replace(/^\s+/, "");
+         matches.push({
+           l: i,
+           c: m.index,
+           n: m[0].length,
+           pre: (from > 0 ? "…" : "") + pre,
+           hit: m[0].length > 160 ? m[0].slice(0, 160) + "…" : m[0],
+           post: body.slice(end, to) + (to < body.length ? "…" : ""),
+           g: m.length > 1 ? { all: Array.prototype.slice.call(m), named: m.groups || null } : null
+         });
+       }
+     }
+     return { matches: matches, truncated: truncated };
+   }
+ 
+   function transform(text, re, repl, regexMode, pick) {
+     var lines = text.split("\n");
+     var changes = [], offset = 0;
+     var rx = new RegExp(re.source, re.flags);
+     for (var i = 0; i < lines.length; i++) {
+       var line = lines[i];
+       var body = line.charCodeAt(line.length - 1) === 13 ? line.slice(0, -1) : line;
+       if (body.length && body.length <= MAX_LINE) {
+         rx.lastIndex = 0;
+         var m;
+         while ((m = rx.exec(body)) !== null) {
+           if (m[0].length === 0) { rx.lastIndex++; continue; }
+           if (!pick || pick(i, m.index)) {
+             changes.push({ from: offset + m.index, to: offset + m.index + m[0].length, insert: expand(repl, m, regexMode) });
+           }
+         }
+       }
+       offset += line.length + 1;
+     }
+     return changes;
+   }
+ 
+   function applyChanges(text, changes) {
+     var out = [], last = 0;
+     changes.forEach(function (c) {
+       out.push(text.slice(last, c.from), c.insert);
+       last = c.to;
+     });
+     out.push(text.slice(last));
+     return out.join("");
+   }
+ 
+   function previewOf(m, regexMode) {
+     var fake = m.g ? m.g.all.slice() : [m.hit];
+     if (m.g && m.g.named) fake.groups = m.g.named;
+     return expand(els.replace.value, fake, regexMode);
+   }
+ 
+   function yieldUI() {
+     return new Promise(function (resolve) { setTimeout(resolve, 0); });
+   }
+ 
+   function readOptions() {
+     return {
+       query: els.query.value,
+       caseSensitive: prefs.caseSensitive,
+       word: prefs.word,
+       regex: prefs.regex,
+       files: els.files.value
+     };
+   }
+ 
+   function savePrefs() {
+     A.store.set("search", prefs);
+   }
+ 
+   function cancelJob() {
+     seq++;
+     if (job && job.state === "running") job.state = "stopped";
+   }
+ 
+   function clearResults() {
+     cancelJob();
+     job = null;
+     els.results.innerHTML = "";
+     els.status.textContent = "";
+     els.stop.hidden = true;
+     els.replaceAll.disabled = true;
+     els.count.textContent = "";
+   }
+ 
+   function showError(e) {
+     cancelJob();
+     job = null;
+     els.results.innerHTML = "";
+     els.stop.hidden = true;
+     els.replaceAll.disabled = true;
+     els.count.textContent = "";
+     els.status.textContent = t("search.bad_regex", { error: String(e.message || e).replace(/^Invalid regular expression:\s*/i, "") });
+   }
+ 
+   function summaryText(j) {
+     return A.tn("search.n_matches", j.matches) + " · " + A.tn("search.n_files", j.order.length);
+   }
+ 
+   function renderStatus() {
+     var j = job;
+     if (!j) return;
+     var text;
+     if (j.state === "running") {
+       text = t("search.running", { done: j.pos, total: j.files ? j.files.length : 0 });
+       if (j.matches) text += " · " + summaryText(j);
+     } else if (!j.matches) {
+       text = t("search.no_results");
+     } else {
+       text = summaryText(j);
+       if (j.state === "paused") text += " · " + t("search.progress", { done: j.pos, total: j.files.length });
+     }
+     els.status.textContent = text;
+     els.stop.hidden = j.state !== "running";
+     els.replaceAll.disabled = !j.matches || replacing;
+     els.count.textContent = j.matches ? String(j.matches) : "";
+     updateMore();
+   }
+ 
+   function updateMore() {
+     var j = job;
+     var existing = els.results.querySelector(".ath-search-more");
+     if (!j || j.state !== "paused") {
+       if (existing) existing.remove();
+       return;
+     }
+     if (!existing) {
+       existing = util.el("div", { class: "ath-search-more" }, [
+         util.el("button", { type: "button", class: "orb-btn orb-btn-soft orb-btn-sm orb-btn-block", "data-act": "more" })
+       ]);
+     }
+     existing.firstChild.textContent = t("search.show_more", { done: j.pos, total: j.files.length });
+     els.results.appendChild(existing);
+   }
+ 
+   function buildGroup(entry) {
+     var name = util.basename(entry.path);
+     var dir = util.dirname(entry.path);
+     var head = util.el("div", {
+       class: "ath-sr-file",
+       role: "button",
+       tabindex: "0",
+       "data-act": "toggle",
+       "data-path": entry.path,
+       "aria-expanded": entry.collapsed ? "false" : "true",
+       title: entry.path
+     }, [
+       util.el("span", { class: "ath-sr-chev", html: A.icon("chevron") }),
+       util.el("span", { class: "ath-sr-badge", html: A.fileBadge(name) }),
+       util.el("span", { class: "ath-sr-name" }, name),
+       util.el("span", { class: "ath-sr-dir" }, dir),
+       util.el("span", { class: "ath-sr-num", title: entry.truncated ? t("search.truncated", { n: entry.matches.length }) : null }, String(entry.matches.length) + (entry.truncated ? "+" : "")),
+       util.el("button", {
+         type: "button",
+         class: "ath-icon-btn ath-sr-replace",
+         "data-act": "replace-file",
+         "data-path": entry.path,
+         title: t("search.replace_in_file"),
+         "aria-label": t("search.replace_in_file"),
+         html: A.icon("replace")
+       })
+     ]);
+     var list = util.el("div", { class: "ath-sr-list" });
+     entry.matches.forEach(function (m, i) {
+       var ins = util.el("ins", { class: "ath-sr-ins" }, previewOf(m, job.opts.regex));
+       m.ins = ins;
+       list.appendChild(util.el("div", {
+         class: "ath-sr-match",
+         role: "button",
+         tabindex: "0",
+         "data-act": "open",
+         "data-path": entry.path,
+         "data-i": String(i)
+       }, [
+         util.el("span", { class: "ath-sr-line" }, String(m.l + 1)),
+         util.el("span", { class: "ath-sr-text" }, [
+           m.pre,
+           util.el("mark", { class: "ath-sr-hit" }, m.hit),
+           ins,
+           m.post
+         ]),
+         util.el("button", {
+           type: "button",
+           class: "ath-icon-btn ath-sr-replace",
+           "data-act": "replace-one",
+           "data-path": entry.path,
+           "data-i": String(i),
+           title: t("search.replace_one"),
+           "aria-label": t("search.replace_one"),
+           html: A.icon("replace")
+         })
+       ]));
+     });
+     var group = util.el("div", { class: "ath-sr-group" + (entry.collapsed ? " is-collapsed" : "") }, [head, list]);
+     entry.el = group;
+     return group;
+   }
+ 
+   var renderQueued = false;
+   function scheduleRender() {
+     if (renderQueued) return;
+     renderQueued = true;
+     requestAnimationFrame(function () {
+       renderQueued = false;
+       flushRender();
+     });
+   }
+ 
+   function flushRender() {
+     var j = job;
+     if (!j) return;
+     var frag = document.createDocumentFragment();
+     while (j.rendered < j.order.length) {
+       frag.appendChild(buildGroup(j.results.get(j.order[j.rendered])));
+       j.rendered++;
+     }
+     var more = els.results.querySelector(".ath-search-more");
+     els.results.insertBefore(frag, more);
+     renderStatus();
+   }
+ 
+   function addResult(j, path, found) {
+     var entry = { path: path, matches: found.matches, truncated: found.truncated, collapsed: false, el: null };
+     j.results.set(path, entry);
+     j.order.push(path);
+     j.matches += found.matches.length;
+     j.stageMatches += found.matches.length;
+   }
+ 
+   async function prepare(j) {
+     var all = await fs.allFiles();
+     if (j.id !== seq) return false;
+     var pass = filterOf(j.opts.files);
+     var list = all.filter(function (p) { return eligible(p) && pass(p); });
+     var open = new Set(tabs.list.filter(function (x) { return x.path != null; }).map(function (x) { return x.path; }));
+     if (open.size) {
+       var first = [], rest = [];
+       list.forEach(function (p) { (open.has(p) ? first : rest).push(p); });
+       list = first.concat(rest);
+     }
+     j.files = list;
+     return true;
+   }
+ 
+   async function loop(j) {
+     j.state = "running";
+     j.stageMatches = 0;
+     renderStatus();
+     var sliceStart = performance.now();
+     while (j.pos < j.files.length) {
+       if (j.id !== seq) return;
+       if (j.stopRequested) {
+         j.stopRequested = false;
+         j.state = "paused";
+         flushRender();
+         return;
+       }
+       if (j.stageMatches >= STAGE_MATCHES) {
+         j.state = "paused";
+         flushRender();
+         return;
+       }
+       var batch = j.files.slice(j.pos, j.pos + PARALLEL);
+       j.pos += batch.length;
+       var texts = await Promise.all(batch.map(readSearchable));
+       if (j.id !== seq) return;
+       for (var i = 0; i < batch.length; i++) {
+         if (texts[i] == null) continue;
+         var found = scanText(j.re, texts[i]);
+         if (found.matches.length) addResult(j, batch[i], found);
+         if (performance.now() - sliceStart > SLICE_MS) {
+           scheduleRender();
+           await yieldUI();
+           if (j.id !== seq) return;
+           sliceStart = performance.now();
+         }
+       }
+       scheduleRender();
+     }
+     j.state = "done";
+     flushRender();
+   }
+ 
+   async function start() {
+     cancelJob();
+     var opts = readOptions();
+     if (!opts.query) return clearResults();
+     if (!fs.provider) return;
+     var re;
+     try { re = compile(opts); } catch (e) { return showError(e); }
+     var id = seq;
+     job = { id: id, re: re, opts: opts, files: [], pos: 0, matches: 0, stageMatches: 0, state: "running", results: new Map(), order: [], rendered: 0 };
+     els.results.innerHTML = "";
+     els.results.classList.toggle("is-replace", prefs.replace);
+     renderStatus();
+     var j = job;
+     if (!(await prepare(j))) return;
+     await loop(j);
+   }
+ 
+   var startSoon = util.debounce(function () { start().catch(fail); }, 300);
+ 
+   function fail(e) {
+     console.error(e);
+     A.ui.toast(e && e.message ? e.message : String(e), "danger");
+   }
+ 
+   function moreResults() {
+     if (!job || job.state !== "paused") return;
+     loop(job).catch(fail);
+   }
+ 
+   async function openMatch(path, m) {
+     var tab = await tabs.openPath(path);
+     if (!tab || tab.kind !== "text") return;
+     A.editor.select(m.l + 1, m.c + 1, m.n);
+   }
+ 
+   function applyToTab(tab, changes) {
+     if (tab === tabs.active) {
+       A.editor.view.dispatch({ changes: changes, userEvent: "input.replace" });
+       return;
+     }
+     tab.state = tab.state.update({ changes: changes }).state;
+     tab.dirty = !tab.state.doc.eq(tab.savedDoc);
+     tabs.render();
+   }
+ 
+   function renderUndo() {
+     if (els.undo) els.undo.disabled = !undoStack.length || replacing;
+   }
+ 
+   function pushUndo(record) {
+     if (!record.length) return;
+     undoStack.push(record);
+     if (undoStack.length > MAX_UNDO) undoStack.shift();
+     renderUndo();
+   }
+ 
+   async function replaceInFile(path, pick, record) {
+     var j = job;
+     var repl = els.replace.value;
+     var tab = tabs.byPath(path);
+     if (tab && tab.kind === "text") {
+       var before = tabs.textOf(tab);
+       var changes = transform(before, j.re, repl, j.opts.regex, pick);
+       if (changes.length) {
+         applyToTab(tab, changes);
+         if (record) record.push({ path: path, before: before, after: applyChanges(before, changes) });
+       }
+       return changes.length;
+     }
+     var raw = await fs.provider.readText(path);
+     var list = transform(raw, j.re, repl, j.opts.regex, pick);
+     if (!list.length) return 0;
+     var updated = applyChanges(raw, list);
+     await fs.provider.write(path, updated);
+     if (record) record.push({ path: path, before: raw, after: updated });
+     A.emit("saved", { path: path, name: util.basename(path) });
+     return list.length;
+   }
+ 
+   async function undoReplace() {
+     if (replacing) return;
+     var record = undoStack.pop();
+     renderUndo();
+     if (!record) return A.ui.toast(t("search.undo_empty"), "info");
+     replacing = true;
+     renderUndo();
+     var restored = 0, skipped = 0;
+     try {
+       for (var i = 0; i < record.length; i++) {
+         var f = record[i];
+         try {
+           var tab = tabs.byPath(f.path);
+           var current;
+           if (tab && tab.kind === "text") {
+             current = tabs.textOf(tab);
+             if (current === f.before) continue;
+             if (current !== f.after) { skipped++; continue; }
+             applyToTab(tab, [{ from: 0, to: current.length, insert: f.before }]);
+           } else {
+             current = await fs.provider.readText(f.path);
+             if (current === f.before) continue;
+             if (current !== f.after) { skipped++; continue; }
+             await fs.provider.write(f.path, f.before);
+             A.emit("saved", { path: f.path, name: util.basename(f.path) });
+           }
+           restored++;
+         } catch (e) {
+           skipped++;
+           A.ui.toast(t("search.replace_failed", { name: util.basename(f.path), error: e.message }), "danger");
+         }
+         if (i % 20 === 19) await yieldUI();
+       }
+     } finally {
+       replacing = false;
+       renderUndo();
+     }
+     if (restored) A.ui.toast(t("search.undone", { files: A.tn("search.in_n_files", restored) }), skipped ? "warning" : "success");
+     if (skipped) A.ui.toast(t("search.undo_skipped", { files: A.tn("search.n_files", skipped) }), "warning");
+     if (els.query.value) start().catch(fail);
+   }
+ 
+   async function refreshEntry(path) {
+     var j = job;
+     if (!j) return;
+     var entry = j.results.get(path);
+     if (!entry) return;
+     var text = await readSearchable(path);
+     if (j !== job) return;
+     var found = text == null ? { matches: [], truncated: false } : scanText(j.re, text);
+     j.matches += found.matches.length - entry.matches.length;
+     var old = entry.el;
+     if (!found.matches.length) {
+       old.remove();
+       j.results.delete(path);
+       var at = j.order.indexOf(path);
+       if (at >= 0) { j.order.splice(at, 1); if (at < j.rendered) j.rendered--; }
+     } else {
+       entry.matches = found.matches;
+       entry.truncated = found.truncated;
+       old.replaceWith(buildGroup(entry));
+     }
+     renderStatus();
+   }
+ 
+   async function replaceOne(path, index) {
+     var entry = job && job.results.get(path);
+     var m = entry && entry.matches[index];
+     if (!m || replacing) return;
+     replacing = true;
+     renderUndo();
+     var record = [];
+     try {
+       var n = await replaceInFile(path, function (line, col) { return line === m.l && col === m.c; }, record);
+       if (!n) A.ui.toast(t("search.stale"), "warning");
+       await refreshEntry(path);
+     } catch (e) {
+       A.ui.toast(t("search.replace_failed", { name: util.basename(path), error: e.message }), "danger");
+     } finally {
+       replacing = false;
+       pushUndo(record);
+       renderStatus();
+     }
+   }
+ 
+   async function replaceFile(path) {
+     if (!job || !job.results.has(path) || replacing) return;
+     replacing = true;
+     renderUndo();
+     var record = [];
+     try {
+       var n = await replaceInFile(path, null, record);
+       if (n) A.ui.toast(A.tn("search.replaced", n), "success");
+       else A.ui.toast(t("search.stale"), "warning");
+       await refreshEntry(path);
+     } catch (e) {
+       A.ui.toast(t("search.replace_failed", { name: util.basename(path), error: e.message }), "danger");
+     } finally {
+       replacing = false;
+       pushUndo(record);
+       renderStatus();
+     }
+   }
+ 
+   async function replaceAll() {
+     var j = job;
+     if (!j || !j.matches || replacing) return;
+     var paths = j.order.slice();
+     var lines = [A.tn("search.confirm_text", j.matches, { files: A.tn("search.in_n_files", paths.length) })];
+     if (j.state !== "done") lines.push(t("search.confirm_partial"));
+     if (paths.some(function (p) { return j.results.get(p).truncated; })) lines.push(t("search.confirm_more"));
+     lines.push(t("search.confirm_open"));
+     var body = util.el("div", { class: "ath-dialog-text" }, lines.map(function (l) { return util.el("p", {}, l); }));
+     var ok = await A.ui.dialog({
+       title: t("search.confirm_title"),
+       body: body,
+       size: "sm",
+       actions: [
+         { label: t("common.cancel"), value: null, kind: "ghost" },
+         { label: t("search.replace_all"), value: "go", kind: "primary" }
+       ]
+     });
+     if (ok !== "go" || j !== job) return;
+     replacing = true;
+     renderUndo();
+     els.replaceAll.disabled = true;
+     var record = [];
+     var total = 0, failed = 0;
+     els.query.disabled = true;
+     els.files.disabled = true;
+     try {
+       for (var i = 0; i < paths.length; i++) {
+         els.status.textContent = t("search.replacing", { done: i, total: paths.length });
+         try {
+           total += await replaceInFile(paths[i], null, record);
+         } catch (e) {
+           failed++;
+           A.ui.toast(t("search.replace_failed", { name: util.basename(paths[i]), error: e.message }), "danger");
+         }
+         await yieldUI();
+       }
+     } finally {
+       replacing = false;
+       pushUndo(record);
+       els.query.disabled = false;
+       els.files.disabled = false;
+     }
+     if (total) A.ui.toast(A.tn("search.replaced", total), failed ? "warning" : "success");
+     start().catch(fail);
+   }
+ 
+   function setToggle(btn, on) {
+     btn.setAttribute("aria-pressed", on ? "true" : "false");
+   }
+ 
+   function setOpen(open, focus) {
+     prefs.open = open;
+     els.panel.classList.toggle("is-open", open);
+     els.toggle.setAttribute("aria-expanded", open ? "true" : "false");
+     if (prefs.height) els.panel.style.setProperty("--ath-search-h", prefs.height + "px");
+     savePrefs();
+     if (open && focus) {
+       els.query.focus();
+       els.query.select();
+     }
+   }
+ 
+   function setReplace(on) {
+     prefs.replace = on;
+     els.replaceRow.hidden = !on;
+     els.results.classList.toggle("is-replace", on);
+     setToggle(els.replaceToggle, on);
+     savePrefs();
+   }
+ 
+   function setPlaceholders() {
+     els.query.placeholder = t("search.placeholder");
+     els.replace.placeholder = t("search.replace_placeholder");
+     els.files.placeholder = t("search.files_placeholder");
+   }
+ 
+   function updateInsertions() {
+     if (!job) return;
+     job.results.forEach(function (entry) {
+       entry.matches.forEach(function (m) {
+         if (m.ins) m.ins.textContent = previewOf(m, job.opts.regex);
+       });
+     });
+   }
+ 
+   function onResultsClick(e) {
+     var target = e.target.closest("[data-act]");
+     if (!target || !job) return;
+     var act = target.getAttribute("data-act");
+     var path = target.getAttribute("data-path");
+     var index = parseInt(target.getAttribute("data-i"), 10);
+     if (act === "more") return moreResults();
+     var entry = path ? job.results.get(path) : null;
+     if (act === "toggle" && entry) {
+       entry.collapsed = !entry.collapsed;
+       entry.el.classList.toggle("is-collapsed", entry.collapsed);
+       target.setAttribute("aria-expanded", entry.collapsed ? "false" : "true");
+     } else if (act === "open" && entry) {
+       openMatch(path, entry.matches[index]).catch(fail);
+     } else if (act === "replace-one") {
+       e.stopPropagation();
+       replaceOne(path, index).catch(fail);
+     } else if (act === "replace-file") {
+       e.stopPropagation();
+       replaceFile(path).catch(fail);
+     }
+   }
+ 
+   function onResultsKey(e) {
+     if (e.key !== "Enter" && e.key !== " ") return;
+     var target = e.target.closest("[data-act]");
+     if (!target || target.tagName === "BUTTON") return;
+     e.preventDefault();
+     target.click();
+   }
+ 
+   function initGrip() {
+     els.grip.addEventListener("pointerdown", function (e) {
+       if (e.button !== 0 || !prefs.open) return;
+       e.preventDefault();
+       els.grip.setPointerCapture(e.pointerId);
+       document.body.classList.add("ath-resizing");
+       var startY = e.clientY;
+       var startH = els.panel.offsetHeight;
+       var limit = els.panel.parentNode.clientHeight * 0.8;
+       function move(ev) {
+         prefs.height = Math.round(Math.max(150, Math.min(limit, startH - (ev.clientY - startY))));
+         els.panel.style.setProperty("--ath-search-h", prefs.height + "px");
+       }
+       function up() {
+         els.grip.removeEventListener("pointermove", move);
+         els.grip.removeEventListener("pointerup", up);
+         els.grip.removeEventListener("pointercancel", up);
+         document.body.classList.remove("ath-resizing");
+         savePrefs();
+       }
+       els.grip.addEventListener("pointermove", move);
+       els.grip.addEventListener("pointerup", up);
+       els.grip.addEventListener("pointercancel", up);
+     });
+     els.grip.addEventListener("dblclick", function () {
+       prefs.height = 0;
+       els.panel.style.removeProperty("--ath-search-h");
+       savePrefs();
+     });
+   }
+ 
+   var search = (A.search = {
+     init: function () {
+       els.panel = $("search");
+       els.grip = $("search-grip");
+       els.toggle = $("search-toggle");
+       els.count = $("search-count");
+       els.query = $("search-query");
+       els.replace = $("search-replace");
+       els.files = $("search-files");
+       els.replaceRow = $("search-replace-row");
+       els.replaceToggle = $("search-replace-toggle");
+       els.replaceAll = $("search-replace-all");
+       els.undo = $("search-replace-undo");
+       els.caseBtn = $("search-case");
+       els.wordBtn = $("search-word");
+       els.regexBtn = $("search-regex");
+       els.clear = $("search-clear");
+       els.stop = $("search-stop");
+       els.status = $("search-status");
+       els.results = $("search-results");
+ 
+       Object.assign(prefs, A.store.get("search", {}));
+       els.files.value = prefs.files || "";
+       setToggle(els.caseBtn, prefs.caseSensitive);
+       setToggle(els.wordBtn, prefs.word);
+       setToggle(els.regexBtn, prefs.regex);
+       setReplace(prefs.replace);
+       setOpen(prefs.open, false);
+       setPlaceholders();
+       initGrip();
+ 
+       els.toggle.addEventListener("click", function () { setOpen(!prefs.open, !prefs.open); });
+       els.replaceToggle.addEventListener("click", function () { setReplace(!prefs.replace); if (prefs.replace) els.replace.focus(); });
+       els.clear.addEventListener("click", function () {
+         els.query.value = "";
+         clearResults();
+         els.query.focus();
+       });
+       els.stop.addEventListener("click", function () {
+         if (job && job.state === "running") job.stopRequested = true;
+       });
+       [[els.caseBtn, "caseSensitive"], [els.wordBtn, "word"], [els.regexBtn, "regex"]].forEach(function (pair) {
+         pair[0].addEventListener("click", function () {
+           prefs[pair[1]] = !prefs[pair[1]];
+           setToggle(pair[0], prefs[pair[1]]);
+           savePrefs();
+           if (els.query.value) start().catch(fail);
+         });
+       });
+       els.query.addEventListener("input", function () {
+         if (els.query.value.length >= AUTO_MIN) startSoon();
+         else if (!els.query.value) clearResults();
+       });
+       els.query.addEventListener("keydown", function (e) {
+         if (e.key === "Enter") { e.preventDefault(); start().catch(fail); }
+         else if (e.key === "Escape") {
+           if (job && job.state === "running") els.stop.click();
+           else A.editor.focus();
+         }
+       });
+       els.files.addEventListener("input", function () {
+         prefs.files = els.files.value;
+         savePrefs();
+         if (els.query.value.length >= AUTO_MIN) startSoon();
+       });
+       els.files.addEventListener("keydown", function (e) {
+         if (e.key === "Enter") { e.preventDefault(); start().catch(fail); }
+       });
+       els.replace.addEventListener("input", util.debounce(updateInsertions, 150));
+       els.replaceAll.addEventListener("click", function () { replaceAll().catch(fail); });
+       els.undo.addEventListener("click", function () { undoReplace().catch(fail); });
+       renderUndo();
+       els.results.addEventListener("click", onResultsClick);
+       els.results.addEventListener("keydown", onResultsKey);
+ 
+       A.on("workspace", function (p) {
+         els.panel.hidden = !p;
+         undoStack = [];
+         renderUndo();
+         clearResults();
+       });
+       A.on("lang", function () {
+         setPlaceholders();
+         renderStatus();
+       });
+     },
+ 
+     undoReplace: function () {
+       return undoReplace();
+     },
+ 
+     open: function () {
+       if (!fs.provider) return A.ui.toast(t("app.open_folder_first"), "info");
+       if (document.body.classList.contains("ath-no-sidebar")) A.commands.toggleSidebar();
+       var tab = tabs.active;
+       if (tab && tab.kind === "text") {
+         var st = A.editor.view.state, r = st.selection.main;
+         if (!r.empty && r.to - r.from <= 200) {
+           var picked = st.sliceDoc(r.from, r.to);
+           if (picked.indexOf("\n") < 0) els.query.value = picked;
+         }
+       }
+       setOpen(true, true);
+       if (els.query.value) start().catch(fail);
+     }
+   });
+ })();
+ 
assets/app/settings.js Modified +4 -2
⋮ 24 unchanged lines ⋮
      autoSave: false,
      formatOnSave: false,
      livePreview: true,
-     phpRuntime: true
+     phpRuntime: true,
+     mysqlEmulation: true
    };
  
    var ACCENTS = ["default", "indigo", "violet", "purple", "fuchsia", "pink", "rose", "red",
⋮ 253 unchanged lines ⋮
          row(t("settings.auto_save"), toggle("autoSave"), t("settings.auto_save_hint")),
          row(t("settings.format_on_save"), toggle("formatOnSave"), t("settings.format_on_save_hint")),
          row(t("settings.live_preview"), toggle("livePreview"), t("settings.live_preview_hint")),
-         row(t("settings.php_runtime"), toggle("phpRuntime"), t("settings.php_runtime_hint"))
+         row(t("settings.php_runtime"), toggle("phpRuntime"), t("settings.php_runtime_hint")),
+         row(t("settings.mysql_emulation"), toggle("mysqlEmulation"), t("settings.mysql_emulation_hint"))
        ]),
        section(t("settings.section_fonts"), [
          util.el("p", { class: "ath-set-hint" }, t("settings.fonts_hint")),
⋮ 8 unchanged lines ⋮
assets/app/tabs.js Modified +233 -34
⋮ 7 unchanged lines ⋮
    var BADGES = {
      html: ["html", "<>"], htm: ["html", "<>"], php: ["php", "php"], css: ["css", "#"], scss: ["css", "S"],
      js: ["js", "JS"], mjs: ["js", "JS"], jsx: ["js", "JSX"], ts: ["ts", "TS"], tsx: ["ts", "TSX"],
-     json: ["json", "{}"], md: ["md", "M↓"], svg: ["img", "svg"], txt: ["txt", "≡"]
+     json: ["json", "{}"], jsonc: ["json", "{}"], xml: ["xml", "</>"], md: ["md", "M↓"], svg: ["img", "svg"], txt: ["txt", "≡"]
    };
+   var NAMED = {
+     "sitemap.xml": ["sitemap", "sitemap"], "sitemap_index.xml": ["sitemap", "sitemap"],
+     "rss.xml": ["rss", "rss"], "feed.xml": ["rss", "rss"], "atom.xml": ["rss", "rss"]
+   };
    A.fileBadge = function (name) {
+     var named = NAMED[util.basename(name).toLowerCase()];
+     if (named) return '<span class="ath-ficon" data-type="' + named[0] + '">' + A.icon(named[1]) + "</span>";
      var ext = util.ext(name);
      var b = BADGES[ext] || (fs.isImage(name) ? ["img", "▣"] : null);
      if (!b) return '<span class="ath-ficon ath-ficon-file">' + A.icon("file") + "</span>";
⋮ 17 unchanged lines ⋮
      list.forEach(function (tab) { if (canAutoSave(tab)) tabs.save(tab, true); });
    }, 1000);
  
+   var dragTab = null;
+   var dropAt = -1;
+   var marker = null;
+ 
+   function reduced() {
+     return window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
+   }
+ 
+   function onEnterEnd(e) {
+     if (e.animationName !== "ath-tab-in") return;
+     var n = e.currentTarget;
+     n.classList.remove("is-entering");
+     n.removeEventListener("animationend", onEnterEnd);
+     if (n.classList.contains("is-active")) n.scrollIntoView({ block: "nearest", inline: "nearest" });
+   }
+ 
+   function leave(node, animate) {
+     node.removeAttribute("draggable");
+     if (!animate) { node.remove(); return; }
+     node.style.setProperty("--w", node.offsetWidth + "px");
+     node.classList.remove("is-entering");
+     node.classList.add("is-leaving");
+     var done = false;
+     function finish() {
+       if (done) return;
+       done = true;
+       node.remove();
+     }
+     node.addEventListener("animationend", function (e) {
+       if (e.animationName === "ath-tab-out") finish();
+     });
+     setTimeout(finish, 600);
+   }
+ 
+   function buildTab(tab) {
+     var node = util.el("div", { class: "ath-tab", role: "tab", draggable: "true" });
+     node._tab = tab;
+     node.innerHTML = A.fileBadge(tab.name) + '<span class="ath-tab-name"></span>';
+     var close = util.el("button", { type: "button", class: "ath-tab-close", html: '<span class="ath-tab-dot"></span>' + A.icon("x") });
+     close.addEventListener("click", function (e) { e.stopPropagation(); tabs.close(tab); });
+     node.appendChild(close);
+     node.addEventListener("mousedown", function (e) {
+       if (e.button === 1) { e.preventDefault(); tabs.close(tab); }
+     });
+     node.addEventListener("click", function () { if (tab !== tabs.active) tabs.activate(tab); });
+     node.addEventListener("contextmenu", function (e) {
+       e.preventDefault();
+       var i = tabs.list.indexOf(tab);
+       var items = [
+         { label: A.t("common.save"), icon: "save", kbd: "Ctrl+S", action: function () { tabs.save(tab); } },
+         "-",
+         { label: A.t("tabs.close"), icon: "x", kbd: "Alt+W", action: function () { tabs.close(tab); } },
+         { label: A.t("tabs.close_others"), action: function () { tabs.closeAll(tab); } },
+         { label: A.t("tabs.close_all"), action: function () { tabs.closeAll(); } }
+       ];
+       var moves = [];
+       if (i > 0) moves.push({ label: A.t("tabs.move_left"), kbd: "Alt+Shift+PgUp", action: function () { tabs.shift(-1, tab); } });
+       if (i >= 0 && i < tabs.list.length - 1) moves.push({ label: A.t("tabs.move_right"), kbd: "Alt+Shift+PgDn", action: function () { tabs.shift(1, tab); } });
+       if (moves.length) items.push.apply(items, ["-"].concat(moves));
+       A.ui.contextMenu(e.clientX, e.clientY, items);
+     });
+     node._name = null;
+     return node;
+   }
+ 
+   function syncTab(node, tab) {
+     var c = node.classList;
+     c.toggle("is-active", tab === tabs.active);
+     c.toggle("is-dirty", !!tab.dirty);
+     node.setAttribute("aria-selected", tab === tabs.active ? "true" : "false");
+     node.title = tab.path != null ? tab.path : tab.name + (tab.handle ? "" : " " + A.t("tabs.not_on_disk"));
+     if (node._name !== tab.name) {
+       node._name = tab.name;
+       node.firstChild.outerHTML = A.fileBadge(tab.name);
+       node.querySelector(".ath-tab-name").textContent = tab.name;
+     }
+     node.querySelector(".ath-tab-close").setAttribute("aria-label", A.t("tabs.close_named", { name: tab.name }));
+   }
+ 
+   function liveNodes() {
+     return tabs.list.map(function (t) { return t._node; }).filter(Boolean);
+   }
+ 
+   function indexAt(x) {
+     var nodes = liveNodes();
+     for (var i = 0; i < nodes.length; i++) {
+       var r = nodes[i].getBoundingClientRect();
+       if (x < r.left + r.width / 2) return i;
+     }
+     return nodes.length;
+   }
+ 
+   function showMarker(index) {
+     var nodes = liveNodes();
+     if (!nodes.length) return hideMarker();
+     var from = tabs.list.indexOf(dragTab);
+     if (index === from || index === from + 1) return hideMarker();
+     var host = tabs.el.getBoundingClientRect();
+     var x = index < nodes.length ? nodes[index].getBoundingClientRect().left : nodes[nodes.length - 1].getBoundingClientRect().right;
+     if (x < host.left - 1 || x > host.right + 1) return hideMarker();
+     if (!marker) {
+       marker = document.createElement("div");
+       marker.className = "ath-tab-marker";
+       document.body.appendChild(marker);
+     }
+     marker.style.top = host.top + "px";
+     marker.style.height = host.height + "px";
+     marker.style.transform = "translateX(" + Math.round(x) + "px)";
+     marker.classList.add("is-visible");
+   }
+ 
+   function hideMarker() {
+     if (marker) marker.classList.remove("is-visible");
+   }
+ 
+   function endTabDrag() {
+     if (!dragTab) return;
+     if (dragTab._node) dragTab._node.classList.remove("is-dragging");
+     dragTab = null;
+     dropAt = -1;
+     hideMarker();
+     if (tabs.el) tabs.el.classList.remove("is-reordering");
+   }
+ 
+   function initDrag(el) {
+     el.addEventListener("dragstart", function (e) {
+       var node = e.target.closest && e.target.closest(".ath-tab");
+       if (!node || !node._tab || node.classList.contains("is-leaving")) return;
+       dragTab = node._tab;
+       e.dataTransfer.effectAllowed = "move";
+       e.dataTransfer.setData("text/plain", dragTab.name);
+       requestAnimationFrame(function () {
+         if (dragTab && dragTab._node) dragTab._node.classList.add("is-dragging");
+         el.classList.add("is-reordering");
+       });
+     });
+     el.addEventListener("dragover", function (e) {
+       if (!dragTab) return;
+       e.preventDefault();
+       e.dataTransfer.dropEffect = "move";
+       var r = el.getBoundingClientRect();
+       if (e.clientX < r.left + 48) el.scrollLeft -= 16;
+       else if (e.clientX > r.right - 48) el.scrollLeft += 16;
+       dropAt = indexAt(e.clientX);
+       showMarker(dropAt);
+     });
+     el.addEventListener("dragleave", function (e) {
+       if (dragTab && !el.contains(e.relatedTarget)) hideMarker();
+     });
+     el.addEventListener("drop", function (e) {
+       if (!dragTab) return;
+       e.preventDefault();
+       e.stopPropagation();
+       var tab = dragTab, to = indexAt(e.clientX);
+       endTabDrag();
+       tabs.reorder(tab, to);
+     });
+     el.addEventListener("dragend", endTabDrag);
+     window.addEventListener("dragend", endTabDrag, true);
+     window.addEventListener("drop", function () { setTimeout(endTabDrag, 0); }, true);
+   }
+ 
    var seq = 0;
    var tabs = (A.tabs = {
      list: [],
⋮ 2 unchanged lines ⋮
  
      init: function (el) {
        tabs.el = el;
+       initDrag(el);
        el.addEventListener("wheel", function (e) {
          if (Math.abs(e.deltaY) > Math.abs(e.deltaX)) { el.scrollLeft += e.deltaY; e.preventDefault(); }
        }, { passive: false });
⋮ 184 unchanged lines ⋮
        if (i < 0) return true;
        tabs.list.splice(i, 1);
        if (tab.imageUrl) URL.revokeObjectURL(tab.imageUrl);
+       if (dragTab === tab) endTabDrag();
        if (tabs.active === tab) {
          tabs.active = null;
          tabs.activate(tabs.list[Math.min(i, tabs.list.length - 1)] || null);
⋮ 38 unchanged lines ⋮
        if (tab === tabs.active) A.emit("active-change", tab);
      },
  
+     reorder: function (tab, to) {
+       var from = tabs.list.indexOf(tab);
+       if (from < 0) return false;
+       if (to > from) to--;
+       to = Math.max(0, Math.min(tabs.list.length - 1, to));
+       if (to === from) return false;
+       var before = new Map();
+       tabs.list.forEach(function (t) {
+         if (t._node) before.set(t, t._node.getBoundingClientRect().left);
+       });
+       tabs.list.splice(from, 1);
+       tabs.list.splice(to, 0, tab);
+       tabs.render();
+       if (!reduced()) {
+         tabs.list.forEach(function (t) {
+           var n = t._node, b = before.get(t);
+           if (!n || b == null) return;
+           var d = b - n.getBoundingClientRect().left;
+           if (d) {
+             n.animate(
+               [{ transform: "translateX(" + d + "px)" }, { transform: "none" }],
+               { duration: 240, easing: "cubic-bezier(0.22, 1, 0.36, 1)" }
+             );
+           }
+         });
+       }
+       if (tab._node) tab._node.scrollIntoView({ block: "nearest", inline: "nearest" });
+       return true;
+     },
+ 
+     shift: function (dir, tab) {
+       tab = tab || tabs.active;
+       if (!tab) return;
+       var i = tabs.list.indexOf(tab);
+       if (i < 0) return;
+       var j = i + dir;
+       if (j < 0 || j >= tabs.list.length) return;
+       tabs.reorder(tab, dir > 0 ? j + 1 : j);
+     },
+ 
      render: function () {
        var el = tabs.el;
        if (!el) return;
-       el.innerHTML = "";
+       var animate = el._ready && !reduced();
+       var seen = new Set();
+       var prev = null;
        tabs.list.forEach(function (tab) {
-         var node = util.el("div", {
-           class: "ath-tab" + (tab === tabs.active ? " is-active" : "") + (tab.dirty ? " is-dirty" : ""),
-           role: "tab",
-           "aria-selected": tab === tabs.active ? "true" : "false",
-           title: tab.path != null ? tab.path : tab.name + (tab.handle ? "" : " " + A.t("tabs.not_on_disk")),
-           html: A.fileBadge(tab.name) + '<span class="ath-tab-name">' + util.esc(tab.name) + "</span>"
-         });
-         var close = util.el("button", {
-           type: "button",
-           class: "ath-tab-close",
-           "aria-label": A.t("tabs.close_named", { name: tab.name }),
-           html: '<span class="ath-tab-dot"></span>' + A.icon("x")
-         });
-         close.addEventListener("click", function (e) { e.stopPropagation(); tabs.close(tab); });
-         node.appendChild(close);
-         node.addEventListener("mousedown", function (e) {
-           if (e.button === 1) { e.preventDefault(); tabs.close(tab); }
-         });
-         node.addEventListener("click", function () { if (tab !== tabs.active) tabs.activate(tab); });
-         node.addEventListener("contextmenu", function (e) {
-           e.preventDefault();
-           A.ui.contextMenu(e.clientX, e.clientY, [
-             { label: A.t("common.save"), icon: "save", kbd: "Ctrl+S", action: function () { tabs.save(tab); } },
-             "-",
-             { label: A.t("tabs.close"), icon: "x", kbd: "Alt+W", action: function () { tabs.close(tab); } },
-             { label: A.t("tabs.close_others"), action: function () { tabs.closeAll(tab); } },
-             { label: A.t("tabs.close_all"), action: function () { tabs.closeAll(); } }
-           ]);
-         });
-         el.appendChild(node);
+         var node = tab._node;
+         if (!node) {
+           node = tab._node = buildTab(tab);
+           if (animate) {
+             node.classList.add("is-entering");
+             node.addEventListener("animationend", onEnterEnd);
+           }
+         }
+         syncTab(node, tab);
+         seen.add(node);
+         var ref = prev ? prev.nextSibling : el.firstChild;
+         if (node !== ref) el.insertBefore(node, ref);
+         prev = node;
        });
-       var act = el.querySelector(".is-active");
+       Array.from(el.children).forEach(function (n) {
+         if (seen.has(n) || n.classList.contains("is-leaving")) return;
+         leave(n, animate);
+       });
+       el._ready = true;
+       var act = tabs.active && tabs.active._node;
        if (act) act.scrollIntoView({ block: "nearest", inline: "nearest" });
        document.title = (tabs.active ? (tabs.active.dirty ? "● " : "") + tabs.active.name + " · " : "") + "AtheraStudio Code";
      }
    });
  })();
- 
index.html Modified +41 -1
⋮ 55 unchanged lines ⋮
            <button type="button" class="orb-dropdown-item" data-cmd="save" data-icon="save"><span data-i18n="menu.save"></span><span class="orb-kbd">Ctrl+S</span></button>
            <button type="button" class="orb-dropdown-item ath-no-icon" data-cmd="saveAll"><span data-i18n="menu.save_all"></span><span class="orb-kbd">Ctrl+Shift+S</span></button>
            <button type="button" class="orb-dropdown-item ath-no-icon" data-cmd="saveAs"><span data-i18n="menu.save_as"></span></button>
+           <button type="button" class="orb-dropdown-item" data-cmd="backup" data-icon="download"><span data-i18n="menu.backup"></span></button>
            <div class="orb-dropdown-divider"></div>
            <button type="button" class="orb-dropdown-item" data-cmd="closeTab" data-icon="x"><span data-i18n="menu.close_tab"></span><span class="orb-kbd">Alt+W</span></button>
            <button type="button" class="orb-dropdown-item ath-no-icon" data-cmd="closeFolder"><span data-i18n="menu.close_folder"></span></button>
⋮ 12 unchanged lines ⋮
            <button type="button" class="orb-dropdown-item ath-no-icon" data-cmd="paste"><span data-i18n="cmd.paste"></span><span class="orb-kbd">Ctrl+V</span></button>
            <div class="orb-dropdown-divider"></div>
            <button type="button" class="orb-dropdown-item ath-no-icon" data-cmd="search"><span data-i18n="menu.search"></span><span class="orb-kbd">Ctrl+F</span></button>
+           <button type="button" class="orb-dropdown-item ath-no-icon" data-cmd="searchInFiles"><span data-i18n="cmd.search_in_files"></span><span class="orb-kbd">Ctrl+Shift+F</span></button>
            <button type="button" class="orb-dropdown-item ath-no-icon" data-cmd="selectOccurrences"><span data-i18n="cmd.select_occurrences"></span><span class="orb-kbd">Ctrl+Shift+L</span></button>
            <button type="button" class="orb-dropdown-item ath-no-icon" data-cmd="toggleComment"><span data-i18n="cmd.toggle_comment"></span><span class="orb-kbd">Ctrl+/</span></button>
            <button type="button" class="orb-dropdown-item ath-no-icon" data-cmd="duplicateLine"><span data-i18n="cmd.duplicate_line"></span><span class="orb-kbd">Shift+Alt+↓</span></button>
⋮ 85 unchanged lines ⋮
          <button type="button" class="orb-btn orb-btn-secondary orb-btn-sm orb-btn-block" data-cmd="openFile" data-icon="file"><span data-i18n="action.open_file"></span></button>
          <p class="ath-hint" data-i18n="sidebar.drop_hint"></p>
        </div>
+       <section class="ath-search" id="search" data-i18n-aria="search.title" hidden>
+         <div class="ath-search-grip" id="search-grip" role="separator" aria-orientation="horizontal"></div>
+         <div class="ath-search-head">
+           <button type="button" class="ath-search-toggle" id="search-toggle" aria-expanded="false">
+             <span class="ath-search-chev" data-icon="chevron"></span>
+             <span class="ath-pane-title" data-i18n="search.title"></span>
+             <span class="ath-search-count" id="search-count"></span>
+           </button>
+           <div class="ath-pane-actions">
+             <button type="button" class="ath-icon-btn" id="search-replace-toggle" aria-pressed="false" data-icon="replace" data-i18n-title="search.toggle_replace" data-i18n-aria="search.toggle_replace"></button>
+             <button type="button" class="ath-icon-btn" id="search-clear" data-icon="x" data-i18n-title="search.clear" data-i18n-aria="search.clear"></button>
+           </div>
+         </div>
+         <div class="ath-search-body">
+           <div class="ath-search-form">
+             <div class="ath-search-row">
+               <input type="text" class="orb-input ath-search-input" id="search-query" spellcheck="false" autocomplete="off">
+               <button type="button" class="ath-search-opt" id="search-case" aria-pressed="false" data-i18n-title="search.case" data-i18n-aria="search.case">Aa</button>
+               <button type="button" class="ath-search-opt" id="search-word" aria-pressed="false" data-i18n-title="search.word" data-i18n-aria="search.word">ab</button>
+               <button type="button" class="ath-search-opt" id="search-regex" aria-pressed="false" data-i18n-title="search.regex" data-i18n-aria="search.regex">.*</button>
+             </div>
+             <div class="ath-search-row" id="search-replace-row" hidden>
+               <input type="text" class="orb-input ath-search-input" id="search-replace" spellcheck="false" autocomplete="off">
+               <button type="button" class="orb-btn orb-btn-secondary orb-btn-sm" id="search-replace-all" disabled data-i18n="search.replace_all"></button>
+               <button type="button" class="ath-icon-btn" id="search-replace-undo" disabled data-icon="undo" data-i18n-title="search.undo_replace" data-i18n-aria="search.undo_replace"></button>
+             </div>
+             <input type="text" class="orb-input ath-search-input" id="search-files" spellcheck="false" autocomplete="off">
+           </div>
+           <div class="ath-search-status">
+             <span id="search-status" aria-live="polite"></span>
+             <button type="button" class="ath-search-stop" id="search-stop" hidden data-i18n="search.stop"></button>
+           </div>
+           <div class="ath-search-results" id="search-results"></div>
+         </div>
+       </section>
      </aside>
  
      <div class="ath-splitter" data-split="sidebar" role="separator" aria-orientation="vertical" data-i18n-aria="layout.resize_sidebar"></div>
⋮ 85 unchanged lines ⋮
  <script src="assets/app/fonts.js"></script>
  <script src="assets/app/settings.js"></script>
  <script src="assets/app/fs.js"></script>
+ <script src="assets/app/backup.js"></script>
  <script src="assets/app/templates.js"></script>
  <script src="assets/app/snippets.js"></script>
  <script src="assets/app/intellisense.js"></script>
  <script src="assets/app/editor.js"></script>
  <script src="assets/app/tabs.js"></script>
  <script src="assets/app/explorer.js"></script>
+ <script src="assets/app/search.js"></script>
+ <script src="assets/app/mysql-shim.js"></script>
  <script src="assets/app/php.js"></script>
  <script src="assets/app/preview.js"></script>
  <script src="assets/app/palette.js"></script>
  <script src="assets/app/app.js"></script>
+ <script src="assets/app/desktop.js"></script>
  </body>
  </html>
- 
languages/english.xml Modified +64 -1
⋮ 30 unchanged lines ⋮
    <string key="menu.save_all">Save all</string>
    <string key="menu.save_as">Save as…</string>
    <string key="menu.close_tab">Close tab</string>
+   <string key="menu.backup">Create backup</string>
    <string key="menu.close_folder">Close folder</string>
    <string key="menu.sidebar">Sidebar</string>
    <string key="menu.preview">Live preview</string>
⋮ 60 unchanged lines ⋮
    <string key="shortcut.new_file">New file</string>
    <string key="shortcut.close_tab">Close tab</string>
    <string key="shortcut.switch_tab">Next / previous tab</string>
+   <string key="shortcut.move_tab">Move tab left / right (or drag it)</string>
    <string key="shortcut.sidebar">Sidebar</string>
    <string key="shortcut.preview">Live preview</string>
    <string key="shortcut.wrap">Word wrap</string>
⋮ 29 unchanged lines ⋮
    <string key="tabs.close">Close</string>
    <string key="tabs.close_others">Close others</string>
    <string key="tabs.close_all">Close all</string>
+   <string key="tabs.move_left">Move left</string>
+   <string key="tabs.move_right">Move right</string>
  
    <string key="explorer.read_error">Can't read the folder: {error}</string>
    <string key="explorer.empty">The folder is empty. Create the first file with the "+" button above.</string>
⋮ 183 unchanged lines ⋮
    <string key="editor.paste_blocked">The browser blocked clipboard access. Use Ctrl+V.</string>
    <string key="shortcut.emmet">Expand Emmet abbreviation / accept suggestion</string>
  
+   <string key="settings.mysql_emulation">MySQL emulation (BETA)</string>
+   <string key="settings.mysql_emulation_hint">Scripts using mysqli or PDO("mysql:…") run in the preview on an in-memory SQLite database instead of a MySQL server. A .sql dump from the project is imported automatically. Not every MySQL feature is supported.</string>
    <string key="php.loading">Starting PHP 8.3… (first time only)</string>
    <string key="php.load_failed">Couldn't load the PHP engine.</string>
    <string key="php.syncing">Preparing project files for PHP: {done} of {total}…</string>
⋮ 7 unchanged lines ⋮
    <string key="php.restarted">PHP restarted (sessions and cookies cleared).</string>
    <string key="cmd.php_restart">PHP: restart (clear sessions)</string>
    <string key="settings.php_runtime">Run PHP in the preview</string>
-   <string key="settings.php_runtime_hint">Real PHP 8.3 in the browser: include, sessions, forms, SQLite. The engine (about 9 MB) loads on the first .php preview. MySQL is not available.</string>
+   <string key="settings.php_runtime_hint">Real PHP 8.3 in the browser: include, sessions, forms, SQLite. The engine (about 9 MB) loads on the first .php preview.</string>
+ 
+   <string key="cmd.search_in_files">Search in files</string>
+   <string key="search.title">Search</string>
+   <string key="search.placeholder">Search in files</string>
+   <string key="search.replace_placeholder">Replace with</string>
+   <string key="search.files_placeholder">Files: *.css, src/, !vendor/</string>
+   <string key="search.case">Match case</string>
+   <string key="search.word">Whole word</string>
+   <string key="search.regex">Regular expression</string>
+   <string key="search.toggle_replace">Show or hide replace</string>
+   <string key="search.clear">Clear</string>
+   <string key="search.stop">Stop</string>
+   <string key="search.running">Searching… {done} of {total} files</string>
+   <string key="search.progress">searched {done} of {total} files</string>
+   <string key="search.show_more">Show more results (searched {done} of {total} files)</string>
+   <string key="search.no_results">No results</string>
+   <string key="search.bad_regex">Invalid pattern: {error}</string>
+   <string key="search.truncated">Showing the first {n} matches in this file</string>
+   <string key="search.replace_all">Replace all</string>
+   <string key="search.undo_replace">Undo last replace</string>
+   <string key="search.undo_empty">There is no replace to undo.</string>
+   <string key="search.undone">Reverted changes {files}.</string>
+   <string key="search.undo_skipped">Skipped {files} (changed since the replace).</string>
+   <string key="search.replace_in_file">Replace in this file</string>
+   <string key="search.replace_one">Replace</string>
+   <string key="search.replacing">Replacing… {done} of {total} files</string>
+   <string key="search.stale">The text has changed since the search. Results refreshed.</string>
+   <string key="search.replace_failed">Couldn't change "{name}": {error}</string>
+   <string key="search.confirm_title">Replace in files</string>
+   <string key="search.confirm_partial">The search isn't finished, so only the results loaded so far will be replaced.</string>
+   <string key="search.confirm_more">Some files have more matches than shown; all matches in those files will be replaced.</string>
+   <string key="search.confirm_open">Open files are changed but not saved (undo with Ctrl+Z). Other files are written to disk immediately. You can revert the whole replace with the undo button next to "Replace all" until you close or switch the folder.</string>
+   <plural key="search.n_matches">
+     <one>{n} match</one>
+     <other>{n} matches</other>
+   </plural>
+   <plural key="search.n_files">
+     <one>{n} file</one>
+     <other>{n} files</other>
+   </plural>
+   <plural key="search.in_n_files">
+     <one>in {n} file</one>
+     <other>in {n} files</other>
+   </plural>
+   <plural key="search.confirm_text">
+     <one>Replace {n} match {files}?</one>
+     <other>Replace {n} matches {files}?</other>
+   </plural>
+   <plural key="search.replaced">
+     <one>Replaced {n} match</one>
+     <other>Replaced {n} matches</other>
+   </plural>
+ 
+   <string key="backup.started">Creating backup…</string>
+   <string key="backup.done">Backup saved: {path}</string>
+   <string key="backup.downloaded">Backup downloaded: "{name}".</string>
+   <string key="backup.too_large">The project is too large for a single ZIP archive (limit: 4 GB per file and 65535 entries).</string>
  
    <string key="drop.hint">Drop a folder or files to open them</string>
  </language>
languages/polski.xml Modified +88 -1
⋮ 32 unchanged lines ⋮
    <string key="menu.save_all">Zapisz wszystko</string>
    <string key="menu.save_as">Zapisz jako…</string>
    <string key="menu.close_tab">Zamknij kartę</string>
+   <string key="menu.backup">Utwórz kopię zapasow�
+ </string>
    <string key="menu.close_folder">Zamknij folder</string>
    <string key="menu.sidebar">Pasek boczny</string>
    <string key="menu.preview">Podgl�
⋮ 68 unchanged lines ⋮
    <string key="shortcut.new_file">Nowy plik</string>
    <string key="shortcut.close_tab">Zamknij kartę</string>
    <string key="shortcut.switch_tab">Następna / poprzednia karta</string>
+   <string key="shortcut.move_tab">Przenieś kartę w lewo / prawo (lub przeci�
+ gnij)</string>
    <string key="shortcut.sidebar">Pasek boczny</string>
    <string key="shortcut.preview">Podgl�
  d na żywo</string>
⋮ 34 unchanged lines ⋮
    <string key="tabs.close">Zamknij</string>
    <string key="tabs.close_others">Zamknij pozostałe</string>
    <string key="tabs.close_all">Zamknij wszystkie</string>
+   <string key="tabs.move_left">Przenieś w lewo</string>
+   <string key="tabs.move_right">Przenieś w prawo</string>
  
    <string key="explorer.read_error">Nie można odczytać folderu: {error}</string>
    <string key="explorer.empty">Folder jest pusty. Utwórz pierwszy plik przyciskiem „+” powyżej.</string>
⋮ 229 unchanged lines ⋮
  darka zablokowała dostęp do schowka. Użyj Ctrl+V.</string>
    <string key="shortcut.emmet">Rozwiń skrót Emmet / przyjmij podpowiedź</string>
  
+   <string key="settings.mysql_emulation">Emulacja MySQL (BETA)</string>
+   <string key="settings.mysql_emulation_hint">Skrypty używaj�
+ ce mysqli lub PDO("mysql:…") działaj�
+  w podgl�
+ dzie na bazie SQLite w pamięci zamiast na serwerze MySQL. Zrzut .sql z projektu jest importowany automatycznie. Nie wszystkie funkcje MySQL s�
+  obsługiwane.</string>
    <string key="php.loading">Uruchamianie PHP 8.3… (tylko za pierwszym razem)</string>
    <string key="php.load_failed">Nie udało się wczytać silnika PHP.</string>
    <string key="php.syncing">Przygotowanie plików projektu dla PHP: {done} z {total}…</string>
⋮ 12 unchanged lines ⋮
  dzie</string>
    <string key="settings.php_runtime_hint">Prawdziwy PHP 8.3 w przegl�
  darce: include, sesje, formularze, SQLite. Silnik (ok. 9 MB) wczytuje się przy pierwszym podgl�
- dzie pliku .php. MySQL nie jest dostępny.</string>
+ dzie pliku .php.</string>
+ 
+   <string key="cmd.search_in_files">Szukaj w plikach</string>
+   <string key="search.title">Szukaj</string>
+   <string key="search.placeholder">Szukaj w plikach</string>
+   <string key="search.replace_placeholder">Zamień na</string>
+   <string key="search.files_placeholder">Pliki: *.css, src/, !vendor/</string>
+   <string key="search.case">Uwzględnij wielkość liter</string>
+   <string key="search.word">Całe słowa</string>
+   <string key="search.regex">Wyrażenie regularne</string>
+   <string key="search.toggle_replace">Pokaż lub ukryj zamianę</string>
+   <string key="search.clear">Wyczyść</string>
+   <string key="search.stop">Zatrzymaj</string>
+   <string key="search.running">Szukanie… {done} z {total} plików</string>
+   <string key="search.progress">przeszukano {done} z {total} plików</string>
+   <string key="search.show_more">Pokaż więcej wyników (przeszukano {done} z {total} plików)</string>
+   <string key="search.no_results">Brak wyników</string>
+   <string key="search.bad_regex">Nieprawidłowy wzorzec: {error}</string>
+   <string key="search.truncated">Pokazano pierwsze {n} dopasowań w tym pliku</string>
+   <string key="search.replace_all">Zamień wszystko</string>
+   <string key="search.undo_replace">Cofnij ostatni�
+  zamianę</string>
+   <string key="search.undo_empty">Brak zamiany do cofnięcia.</string>
+   <string key="search.undone">Cofnięto zmiany {files}.</string>
+   <string key="search.undo_skipped">Pominięto {files} (zmienione po zamianie).</string>
+   <string key="search.replace_in_file">Zamień w tym pliku</string>
+   <string key="search.replace_one">Zamień</string>
+   <string key="search.replacing">Zamiana… {done} z {total} plików</string>
+   <string key="search.stale">Tekst zmienił się od czasu wyszukiwania. Odświeżono wyniki.</string>
+   <string key="search.replace_failed">Nie udało się zmienić „{name}”: {error}</string>
+   <string key="search.confirm_title">Zamiana w plikach</string>
+   <string key="search.confirm_partial">Wyszukiwanie nie jest zakończone, więc zamienione zostan�
+  tylko dotychczas załadowane wyniki.</string>
+   <string key="search.confirm_more">W niektórych plikach jest więcej dopasowań niż pokazano; zamienione zostan�
+  wszystkie dopasowania w tych plikach.</string>
+   <string key="search.confirm_open">Otwarte pliki zostan�
+  zmienione, ale niezapisane (cofniesz przez Ctrl+Z). Pozostałe pliki zostan�
+  od razu zapisane na dysku. Cał�
+  zamianę cofniesz przyciskiem obok „Zamień wszystko”, dopóki nie zamkniesz lub nie zmienisz folderu.</string>
+   <plural key="search.n_matches">
+     <one>{n} dopasowanie</one>
+     <few>{n} dopasowania</few>
+     <many>{n} dopasowań</many>
+     <other>{n} dopasowania</other>
+   </plural>
+   <plural key="search.n_files">
+     <one>{n} plik</one>
+     <few>{n} pliki</few>
+     <many>{n} plików</many>
+     <other>{n} pliku</other>
+   </plural>
+   <plural key="search.in_n_files">
+     <one>w {n} pliku</one>
+     <few>w {n} plikach</few>
+     <many>w {n} plikach</many>
+     <other>w {n} pliku</other>
+   </plural>
+   <plural key="search.confirm_text">
+     <one>Zamienić {n} dopasowanie {files}?</one>
+     <few>Zamienić {n} dopasowania {files}?</few>
+     <many>Zamienić {n} dopasowań {files}?</many>
+     <other>Zamienić {n} dopasowania {files}?</other>
+   </plural>
+   <plural key="search.replaced">
+     <one>Zamieniono {n} dopasowanie</one>
+     <few>Zamieniono {n} dopasowania</few>
+     <many>Zamieniono {n} dopasowań</many>
+     <other>Zamieniono {n} dopasowania</other>
+   </plural>
+ 
+   <string key="backup.started">Tworzenie kopii zapasowej…</string>
+   <string key="backup.done">Zapisano kopię zapasow�
+ : {path}</string>
+   <string key="backup.downloaded">Pobrano kopię zapasow�
+  „{name}”.</string>
+   <string key="backup.too_large">Projekt jest za duży na jedno archiwum ZIP (limit: 4 GB na plik i 65535 pozycji).</string>
  
    <string key="drop.hint">Upuść folder lub pliki, aby je otworzyć</string>
  
⋮ 32 unchanged lines ⋮
sw.js Modified +3 -0
⋮ 20 unchanged lines ⋮
    "assets/fonts/geist-mono.ttf",
    "assets/fonts/sora.ttf",
    "assets/app/fs.js",
+   "assets/app/backup.js",
    "assets/app/templates.js",
    "assets/app/snippets.js",
    "assets/app/intellisense.js",
⋮ 2 unchanged lines ⋮
    "assets/app/editor.js",
    "assets/app/tabs.js",
    "assets/app/explorer.js",
+   "assets/app/search.js",
+   "assets/app/mysql-shim.js",
    "assets/app/php.js",
    "assets/app/preview.js",
    "assets/app/app.js",
⋮ 33 unchanged lines ⋮
tools/build.js Modified +9 -0
⋮ 37 unchanged lines ⋮
    }
  }
  
+ function buildShim() {
+   const src = path.join(__dirname, "mysql-shim", "shim.php");
+   const out = path.join(ROOT, "assets", "app", "mysql-shim.js");
+   const code = fs.readFileSync(src, "utf8");
+   fs.writeFileSync(out, "(window.Athera = window.Athera || {}).mysqlShim = " + JSON.stringify(code) + ";\n");
+   console.log("mysql-shim.js: " + Math.round(code.length / 1024) + " KB");
+ }
+ 
  function copy(src, dst) {
    const stat = fs.statSync(src);
    if (stat.isDirectory()) {
⋮ 17 unchanged lines ⋮
    console.log("release: " + path.relative(ROOT, dist));
  }
  
+ buildShim();
  buildLanguages();
  if (process.argv.includes("--release")) release();
  
tools/mysql-shim/shim.php Added +2090 -0
+ <?php
+ 
+ final class AthMy
+ {
+     const ID = '(?:`[^`]+`|[A-Za-z_\x80-\xff][\w$\x80-\xff]*)';
+     const NOOP = 'SELECT 1 WHERE 0';
+     const OPT = "\0";
+ 
+     public static $dir = '/tmp/athera-mysql';
+     public static $root = '/www';
+     public static $db = 'default';
+     public static $report = 3;
+     public static $dump = null;
+     public static $problems = [];
+     private static $likeCache = [];
+ 
+     public static function unescape(string $e): string
+     {
+         switch ($e) {
+             case 'n': return "\n";
+             case 'r': return "\r";
+             case 't': return "\t";
+             case '0': return "\0";
+             case 'Z': return "\x1a";
+             case 'b': return "\x08";
+             case '%': return '\\%';
+             case '_': return '\\_';
+         }
+         return $e;
+     }
+ 
+     public static function mask(string $sql, array &$lits): string
+     {
+         $re = '~\'((?:[^\'\\\\]|\\\\.|\'\')*)\'|"((?:[^"\\\\]|\\\\.|"")*)"|(`[^`]*`)|(--(?:[ \t\r\n]|$)[^\n]*)|(#[^\n]*)|(/\*.*?\*/)~s';
+         return preg_replace_callback($re, function ($m) use (&$lits) {
+             if ($m[1] !== null) {
+                 $q = "'";
+                 $v = $m[1];
+             } elseif ($m[2] !== null) {
+                 $q = '"';
+                 $v = $m[2];
+             } elseif ($m[3] !== null) {
+                 return $m[3];
+             } else {
+                 return ' ';
+             }
+             $v = preg_replace_callback('~\\\\(.)|\'\'|""~s', function ($x) use ($q) {
+                 if ($x[0][0] === '\\') return AthMy::unescape($x[1]);
+                 return $x[0] === $q . $q ? $q : $x[0];
+             }, $v);
+             $lits[] = $v;
+             return "\x01" . (count($lits) - 1) . "\x02";
+         }, $sql, -1, $count, PREG_UNMATCHED_AS_NULL);
+     }
+ 
+     public static function unmask(string $s, array $lits): string
+     {
+         if (strpos($s, "\x01") === false) return $s;
+         return preg_replace_callback('~\x01(\d+)\x02~', function ($m) use ($lits) {
+             return "'" . str_replace("'", "''", $lits[(int)$m[1]]) . "'";
+         }, $s);
+     }
+ 
+     public static function splitSql(string $masked): array
+     {
+         $out = [];
+         foreach (preg_split('~`[^`]*`(*SKIP)(*FAIL)|;~', $masked) as $part) {
+             $part = trim($part);
+             if ($part !== '') $out[] = $part;
+         }
+         return $out;
+     }
+ 
+     public static function splitTop(string $s, string $sep = ','): array
+     {
+         $out = [];
+         $cur = '';
+         $depth = 0;
+         $n = strlen($s);
+         for ($i = 0; $i < $n; $i++) {
+             $c = $s[$i];
+             if ($c === '`') {
+                 $j = strpos($s, '`', $i + 1);
+                 if ($j === false) $j = $n - 1;
+                 $cur .= substr($s, $i, $j - $i + 1);
+                 $i = $j;
+                 continue;
+             }
+             if ($c === '(') $depth++;
+             elseif ($c === ')') $depth--;
+             if ($c === $sep && $depth === 0) {
+                 $out[] = $cur;
+                 $cur = '';
+                 continue;
+             }
+             $cur .= $c;
+         }
+         $out[] = $cur;
+         return $out;
+     }
+ 
+     public static function unq(string $id): string
+     {
+         return trim($id, '`');
+     }
+ 
+     public static function quote(string $name): string
+     {
+         return '"' . str_replace('"', '""', $name) . '"';
+     }
+ 
+     public static function isQuery(string $sql): bool
+     {
+         $lits = [];
+         $m = ltrim(self::mask(substr($sql, 0, 400), $lits), " \t\r\n(");
+         return (bool)preg_match('/^(SELECT|SHOW|DESCRIBE|DESC|EXPLAIN|WITH|VALUES|TABLE|PRAGMA)\b/i', $m);
+     }
+ 
+     public static function kind(string $sql): string
+     {
+         $lits = [];
+         $m = ltrim(self::mask(substr($sql, 0, 400), $lits), " \t\r\n(");
+         return preg_match('/^([A-Za-z]+)/', $m, $w) ? strtoupper($w[1]) : '';
+     }
+ 
+     public static function translate(string $sql): array
+     {
+         $lits = [];
+         $masked = self::mask($sql, $lits);
+         $out = [];
+         foreach (self::splitSql($masked) as $stmt) {
+             foreach (self::convert($stmt) as $one) {
+                 $out[] = self::unmask($one, $lits);
+             }
+         }
+         return $out;
+     }
+ 
+     public static function convert(string $s): array
+     {
+         $s = trim($s);
+         if ($s === '') return [];
+         preg_match('/^\(*\s*([A-Za-z_]+)/', $s, $w);
+         $word = isset($w[1]) ? strtoupper($w[1]) : '';
+         switch ($word) {
+             case 'SET':
+                 return self::convertSet($s);
+             case 'USE':
+             case 'LOCK':
+             case 'UNLOCK':
+             case 'FLUSH':
+             case 'OPTIMIZE':
+             case 'ANALYZE':
+             case 'REPAIR':
+             case 'CHECK':
+             case 'GRANT':
+             case 'REVOKE':
+             case 'KILL':
+             case 'DELIMITER':
+             case 'COMMENT':
+                 return [self::NOOP];
+             case 'START':
+                 return ['BEGIN'];
+             case 'CREATE':
+                 if (preg_match('/^CREATE\s+(?:DATABASE|SCHEMA|USER|ROLE)\b/i', $s)) return [self::NOOP];
+                 if (preg_match('/^CREATE\s+(?:TEMPORARY\s+)?TABLE\b/i', $s)) return self::createTable($s);
+                 if (preg_match('/^CREATE\s+(?:UNIQUE\s+|FULLTEXT\s+|SPATIAL\s+)?INDEX\b/i', $s)) return self::createIndex($s);
+                 if (preg_match('/^CREATE\s+(?:OR\s+REPLACE\s+)?(?:ALGORITHM\s*=\s*\w+\s+)?(?:DEFINER\s*=\s*\S+\s+)?(?:SQL\s+SECURITY\s+\w+\s+)?VIEW\b/i', $s)) {
+                     $s = preg_replace('/^CREATE\s+(?:OR\s+REPLACE\s+)?(?:ALGORITHM\s*=\s*\w+\s+)?(?:DEFINER\s*=\s*\S+\s+)?(?:SQL\s+SECURITY\s+\w+\s+)?VIEW/i', 'CREATE VIEW', $s);
+                     return [self::dml($s)];
+                 }
+                 return [$s];
+             case 'DROP':
+                 if (preg_match('/^DROP\s+(?:DATABASE|SCHEMA|USER|ROLE)\b/i', $s)) return [self::NOOP];
+                 if (preg_match('/^DROP\s+(?:TEMPORARY\s+)?TABLE\b/i', $s)) return self::dropTable($s);
+                 if (preg_match('/^DROP\s+INDEX\b/i', $s)) return self::dropIndex($s);
+                 return [self::dml($s)];
+             case 'ALTER':
+                 return self::alterTable($s);
+             case 'TRUNCATE':
+                 return self::truncate($s);
+             case 'RENAME':
+                 return self::renameTable($s);
+             case 'SHOW':
+             case 'DESCRIBE':
+             case 'DESC':
+                 return self::show($s);
+             case 'EXPLAIN':
+                 if (preg_match('/^EXPLAIN\s+(?:SELECT|INSERT|UPDATE|DELETE|REPLACE|WITH|FORMAT|ANALYZE)\b/i', $s)) {
+                     return ['EXPLAIN QUERY PLAN ' . self::dml(preg_replace('/^EXPLAIN\s+(?:(?:FORMAT|EXTENDED|PARTITIONS)\s*(?:=\s*\w+)?\s+)?/i', '', $s))];
+                 }
+                 return self::show($s);
+         }
+         return [self::dml($s)];
+     }
+ 
+     public static function convertSet(string $s): array
+     {
+         if (preg_match('/^SET\s+(?:@@(?:SESSION\.|GLOBAL\.)?|SESSION\s+|GLOBAL\s+)?FOREIGN_KEY_CHECKS\s*=\s*(\w+)/i', $s, $m)) {
+             return ['PRAGMA foreign_keys = ' . (in_array(strtoupper($m[1]), ['0', 'OFF', 'FALSE'], true) ? 'OFF' : 'ON')];
+         }
+         return [self::NOOP];
+     }
+ 
+     public static function cleanCols(string $cols): string
+     {
+         return trim(preg_replace('/\(\s*\d+\s*\)/', '', $cols));
+     }
+ 
+     public static function indexName(string $table, ?string $name, string $cols): string
+     {
+         if ($name === null || $name === '') {
+             $first = trim(explode(',', $cols)[0]);
+             $first = preg_replace('/\s+(ASC|DESC)$/i', '', $first);
+             $name = preg_replace('/[^\w]+/', '_', self::unq($first));
+         }
+         return self::quote(self::unq($table) . '_' . self::unq($name));
+     }
+ 
+     public static function tableName(string $q, ?string $t): string
+     {
+         return ($t !== null && $t !== '') ? $t : $q;
+     }
+ 
+     public static function parseColumn(string $name, string $rest): array
+     {
+         $auto = (bool)preg_match('/\bAUTO_INCREMENT\b/i', $rest);
+         $rest = preg_replace('/\bAUTO_INCREMENT\b/i', '', $rest);
+         $type = 'NUM';
+         $text = false;
+         $after = $rest;
+         if (preg_match('/^\s*([A-Za-z]+)(?:\s+VARYING)?(\s*\(([^)]*)\))?/', $rest, $t)) {
+             $base = strtoupper($t[1]);
+             $args = isset($t[3]) ? $t[3] : '';
+             $after = substr($rest, strlen($t[0]));
+             if ($base === 'ENUM' || $base === 'SET' || $base === 'JSON') {
+                 $type = 'TEXT';
+                 $text = true;
+             } elseif (in_array($base, ['CHAR', 'VARCHAR', 'NCHAR', 'NVARCHAR', 'CHARACTER', 'TINYTEXT', 'TEXT', 'MEDIUMTEXT', 'LONGTEXT'], true)) {
+                 $type = $base . ($args !== '' ? '(' . $args . ')' : '');
+                 $text = true;
+             } else {
+                 $type = $base . ($args !== '' ? '(' . $args . ')' : '');
+             }
+         }
+         $after = preg_replace('/\b(?:UNSIGNED|ZEROFILL|SIGNED)\b/i', '', $after);
+         $after = preg_replace('/\b(?:CHARACTER\s+SET|CHAR\s+SET|CHARSET)\s+\w+/i', '', $after);
+         $binary = false;
+         if (preg_match('/\bCOLLATE\s+(\w+)/i', $after, $c)) {
+             $binary = stripos($c[1], 'bin') !== false;
+             $after = preg_replace('/\bCOLLATE\s+\w+/i', '', $after);
+         }
+         $after = preg_replace('/\bCOMMENT\s+\x01\d+\x02/i', '', $after);
+         $after = preg_replace('/\bON\s+UPDATE\s+(?:CURRENT_TIMESTAMP|NOW|LOCALTIME(?:STAMP)?)\s*(?:\(\s*\d*\s*\))?/i', '', $after);
+         $after = preg_replace('/\bDEFAULT\s+(?:CURRENT_TIMESTAMP|NOW|LOCALTIME(?:STAMP)?)\s*(?:\(\s*\d*\s*\))?/i', 'DEFAULT (now())', $after);
+         $after = preg_replace('/\bUNIQUE\s+KEY\b/i', 'UNIQUE', $after);
+         $after = preg_replace('/\b(?:VISIBLE|INVISIBLE)\b/i', '', $after);
+         $attrs = trim(preg_replace('/\s+/', ' ', $after));
+         if ($text && !$binary) $attrs = trim($attrs . ' COLLATE NOCASE');
+         return ['name' => $name, 'type' => $type, 'attrs' => $attrs, 'auto' => $auto];
+     }
+ 
+     public static function parseCreate(string $s): ?array
+     {
+         $I = self::ID;
+         if (!preg_match('/^CREATE\s+(TEMPORARY\s+)?TABLE\s+(IF\s+NOT\s+EXISTS\s+)?(' . $I . ')(?:\s*\.\s*(' . $I . '))?\s*\(/is', $s, $m, PREG_OFFSET_CAPTURE)) return null;
+         $name = (isset($m[4]) && $m[4][0] !== '') ? $m[4][0] : $m[3][0];
+         $open = $m[0][1] + strlen($m[0][0]) - 1;
+         $n = strlen($s);
+         $depth = 0;
+         $close = null;
+         for ($i = $open; $i < $n; $i++) {
+             $c = $s[$i];
+             if ($c === '`') {
+                 $j = strpos($s, '`', $i + 1);
+                 if ($j === false) return null;
+                 $i = $j;
+                 continue;
+             }
+             if ($c === '(') $depth++;
+             elseif ($c === ')') {
+                 $depth--;
+                 if ($depth === 0) {
+                     $close = $i;
+                     break;
+                 }
+             }
+         }
+         if ($close === null) return null;
+         $st = [
+             'temp' => trim($m[1][0]) !== '',
+             'ine' => trim($m[2][0]) !== '',
+             'name' => $name,
+             'cols' => [],
+             'pk' => [],
+             'uniq' => [],
+             'idx' => [],
+             'fks' => [],
+             'checks' => [],
+             'seq' => null
+         ];
+         if (preg_match('/\bAUTO_INCREMENT\s*=\s*(\d+)/i', substr($s, $close + 1), $q)) $st['seq'] = (int)$q[1];
+         foreach (self::splitTop(substr($s, $open + 1, $close - $open - 1)) as $part) {
+             $part = trim($part);
+             if ($part === '') continue;
+             if (preg_match('/^(?:CONSTRAINT\s+(?:' . $I . '\s+)?)?PRIMARY\s+KEY\s*(?:USING\s+\w+\s*)?\((.*)\)/is', $part, $x)) {
+                 $st['pk'] = array_map('trim', explode(',', self::cleanCols($x[1])));
+             } elseif (preg_match('/^(?:CONSTRAINT\s+(?:' . $I . '\s+)?)?UNIQUE(?:\s+(?:KEY|INDEX))?\s*(?:' . $I . ')?\s*(?:USING\s+\w+\s*)?\((.*)\)/is', $part, $x)) {
+                 $st['uniq'][] = self::cleanCols($x[1]);
+             } elseif (preg_match('/^(?:FULLTEXT\s+|SPATIAL\s+)?(?:KEY|INDEX)\s*(' . $I . ')?\s*(?:USING\s+\w+\s*)?\((.*)\)/is', $part, $x)) {
+                 $st['idx'][] = ['name' => $x[1] !== '' ? $x[1] : null, 'cols' => self::cleanCols($x[2]), 'unique' => false];
+             } elseif (preg_match('/^(?:CONSTRAINT\s+(?:' . $I . '\s+)?)?FOREIGN\s+KEY/i', $part)) {
+                 $st['fks'][] = preg_replace('/FOREIGN\s+KEY\s+(?!\()' . $I . '\s*/i', 'FOREIGN KEY ', $part);
+             } elseif (preg_match('/^(?:CONSTRAINT\s+(?:' . $I . '\s+)?)?CHECK\b/i', $part)) {
+                 $st['checks'][] = $part;
+             } elseif (preg_match('/^(' . $I . ')\s+(.*)$/s', $part, $x)) {
+                 $st['cols'][] = self::parseColumn($x[1], $x[2]);
+             }
+         }
+         return $st;
+     }
+ 
+     public static function buildCreate(array $st): array
+     {
+         $lines = [];
+         $auto = false;
+         foreach ($st['cols'] as $c) {
+             if ($c['auto']) {
+                 $auto = true;
+                 $lines[] = $c['name'] . ' INTEGER PRIMARY KEY AUTOINCREMENT';
+             } else {
+                 $lines[] = trim($c['name'] . ' ' . $c['type'] . ' ' . $c['attrs']);
+             }
+         }
+         if ($st['pk'] && !$auto) $lines[] = 'PRIMARY KEY (' . implode(', ', $st['pk']) . ')';
+         foreach ($st['uniq'] as $u) $lines[] = 'UNIQUE (' . $u . ')';
+         foreach ($st['fks'] as $f) $lines[] = $f;
+         foreach ($st['checks'] as $f) $lines[] = $f;
+         $out = ['CREATE ' . ($st['temp'] ? 'TEMPORARY ' : '') . 'TABLE ' . ($st['ine'] ? 'IF NOT EXISTS ' : '') . $st['name'] . " (\n  " . implode(",\n  ", $lines) . "\n)"];
+         foreach ($st['idx'] as $i) {
+             $out[] = 'CREATE ' . ($i['unique'] ? 'UNIQUE ' : '') . 'INDEX IF NOT EXISTS ' . self::indexName($st['name'], $i['name'], $i['cols']) . ' ON ' . $st['name'] . ' (' . $i['cols'] . ')';
+         }
+         return $out;
+     }
+ 
+     public static function createTable(string $s): array
+     {
+         $st = self::parseCreate($s);
+         if ($st === null) {
+             $s = preg_replace('/^CREATE\s+(TEMPORARY\s+)?TABLE\s+(IF\s+NOT\s+EXISTS\s+)?(' . self::ID . ')\s*\.\s*(' . self::ID . ')/i', 'CREATE $1TABLE $2$4', $s);
+             if (preg_match('/^(CREATE\s+(?:TEMPORARY\s+)?TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?' . self::ID . ')\s+LIKE\s+(' . self::ID . ')(?:\s*\.\s*(' . self::ID . '))?/i', $s, $m)) {
+                 $src = (isset($m[3]) && $m[3] !== '') ? $m[3] : $m[2];
+                 return [$m[1] . ' AS SELECT * FROM ' . $src . ' WHERE 0'];
+             }
+             return [self::dml($s)];
+         }
+         return self::buildCreate($st);
+     }
+ 
+     public static function createIndex(string $s): array
+     {
+         $I = self::ID;
+         if (!preg_match('/^CREATE\s+(UNIQUE\s+)?(?:FULLTEXT\s+|SPATIAL\s+)?INDEX\s+(IF\s+NOT\s+EXISTS\s+)?(' . $I . ')\s*(?:USING\s+\w+\s*)?ON\s+(' . $I . ')(?:\s*\.\s*(' . $I . '))?\s*\((.*?)\)\s*(?:USING\s+\w+)?\s*$/is', $s, $m)) return [self::NOOP];
+         $table = (isset($m[5]) && $m[5] !== '') ? $m[5] : $m[4];
+         $cols = self::cleanCols($m[6]);
+         return ['CREATE ' . (trim($m[1]) !== '' ? 'UNIQUE ' : '') . 'INDEX IF NOT EXISTS ' . self::indexName($table, $m[3], $cols) . ' ON ' . $table . ' (' . $cols . ')'];
+     }
+ 
+     public static function dropTable(string $s): array
+     {
+         $I = self::ID;
+         if (!preg_match('/^DROP\s+(?:TEMPORARY\s+)?TABLE\s+(IF\s+EXISTS\s+)?(.*?)(?:\s+(?:RESTRICT|CASCADE))?\s*$/is', $s, $m)) return [$s];
+         $out = [];
+         foreach (explode(',', $m[2]) as $t) {
+             $t = trim($t);
+             if (!preg_match('/^(?:' . $I . '\s*\.\s*)?(' . $I . ')$/', $t, $x)) continue;
+             $out[] = 'DROP TABLE ' . (trim($m[1]) !== '' ? 'IF EXISTS ' : '') . $x[1];
+         }
+         return $out ?: [self::NOOP];
+     }
+ 
+     public static function dropIndex(string $s): array
+     {
+         $I = self::ID;
+         if (!preg_match('/^DROP\s+INDEX\s+(' . $I . ')\s+ON\s+(?:' . $I . '\s*\.\s*)?(' . $I . ')/i', $s, $m)) return [$s];
+         return ['DROP INDEX IF EXISTS ' . self::indexName($m[2], $m[1], '')];
+     }
+ 
+     public static function truncate(string $s): array
+     {
+         $I = self::ID;
+         if (!preg_match('/^TRUNCATE\s+(?:TABLE\s+)?(?:' . $I . '\s*\.\s*)?(' . $I . ')/i', $s, $m)) return [self::NOOP];
+         return ['DELETE FROM ' . $m[1], self::OPT . "DELETE FROM sqlite_sequence WHERE name = '" . str_replace("'", "''", self::unq($m[1])) . "'"];
+     }
+ 
+     public static function renameTable(string $s): array
+     {
+         $I = self::ID;
+         if (!preg_match('/^RENAME\s+TABLE\s+(.*)$/is', $s, $m)) return [self::NOOP];
+         $out = [];
+         foreach (explode(',', $m[1]) as $pair) {
+             if (preg_match('/^\s*(?:' . $I . '\s*\.\s*)?(' . $I . ')\s+TO\s+(?:' . $I . '\s*\.\s*)?(' . $I . ')\s*$/i', $pair, $x)) {
+                 $out[] = 'ALTER TABLE ' . $x[1] . ' RENAME TO ' . $x[2];
+             }
+         }
+         return $out ?: [self::NOOP];
+     }
+ 
+     public static function alterTable(string $s): array
+     {
+         $I = self::ID;
+         if (!preg_match('/^ALTER\s+(?:IGNORE\s+)?TABLE\s+(?:' . $I . '\s*\.\s*)?(' . $I . ')\s+(.*)$/is', $s, $m)) return [self::NOOP];
+         $out = [];
+         foreach (self::splitTop($m[2]) as $clause) {
+             foreach (self::alterClause($m[1], trim($clause)) as $q) $out[] = $q;
+         }
+         return $out ?: [self::NOOP];
+     }
+ 
+     public static function alterClause(string $t, string $c): array
+     {
+         $I = self::ID;
+         if (preg_match('/^ADD\s+(?:CONSTRAINT\s+(?:' . $I . '\s+)?)?PRIMARY\s+KEY/i', $c)) return [];
+         if (preg_match('/^ADD\s+(?:CONSTRAINT\s+(?:' . $I . '\s+)?)?FOREIGN\s+KEY/i', $c)) return [];
+         if (preg_match('/^ADD\s+(?:CONSTRAINT\s+(?:' . $I . '\s+)?)?(UNIQUE\s+)?(?:FULLTEXT\s+|SPATIAL\s+)?(?:(?:KEY|INDEX)\s*|(?=UNIQUE))(?:UNIQUE\s*)?(?:(?:KEY|INDEX)\s*)?(' . $I . ')?\s*(?:USING\s+\w+\s*)?\((.*)\)\s*(?:USING\s+\w+)?$/is', $c, $m)) {
+             $cols = self::cleanCols($m[3]);
+             $name = $m[2] !== '' ? $m[2] : null;
+             return ['CREATE ' . (trim($m[1]) !== '' ? 'UNIQUE ' : '') . 'INDEX IF NOT EXISTS ' . self::indexName($t, $name, $cols) . ' ON ' . $t . ' (' . $cols . ')'];
+         }
+         if (preg_match('/^ADD\s+UNIQUE\s*(?:(?:KEY|INDEX)\s*)?(' . $I . ')?\s*\((.*)\)/is', $c, $m)) {
+             $cols = self::cleanCols($m[2]);
+             return ['CREATE UNIQUE INDEX IF NOT EXISTS ' . self::indexName($t, $m[1] !== '' ? $m[1] : null, $cols) . ' ON ' . $t . ' (' . $cols . ')'];
+         }
+         if (preg_match('/^ADD\s+(?:COLUMN\s+)?(' . $I . ')\s+(.+)$/is', $c, $m) && !preg_match('/^(?:INDEX|KEY|UNIQUE|PRIMARY|FOREIGN|CONSTRAINT|FULLTEXT|SPATIAL|CHECK)$/i', $m[1])) {
+             $rest = preg_replace('/\s+(?:AFTER\s+' . $I . '|FIRST)\s*$/i', '', $m[2]);
+             $col = self::parseColumn($m[1], $rest);
+             $attrs = preg_replace('/\bDEFAULT\s+\(now\(\)\)/i', '', $col['attrs']);
+             $attrs = preg_replace('/\b(?:PRIMARY\s+KEY|UNIQUE)\b/i', '', $attrs);
+             if (preg_match('/\bNOT\s+NULL\b/i', $attrs) && !preg_match('/\bDEFAULT\b/i', $attrs)) {
+                 $attrs .= preg_match('/^(?:CHAR|VARCHAR|NCHAR|NVARCHAR|CHARACTER|TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT)/i', $col['type']) || $col['type'] === 'TEXT' ? " DEFAULT ''" : ' DEFAULT 0';
+             }
+             return ['ALTER TABLE ' . $t . ' ADD COLUMN ' . trim($col['name'] . ' ' . $col['type'] . ' ' . trim($attrs))];
+         }
+         if (preg_match('/^DROP\s+(?:COLUMN\s+)?(' . $I . ')\s*$/i', $c, $m) && !preg_match('/^(?:PRIMARY|INDEX|KEY|FOREIGN|CONSTRAINT|CHECK)$/i', $m[1])) {
+             return ['ALTER TABLE ' . $t . ' DROP COLUMN ' . $m[1]];
+         }
+         if (preg_match('/^DROP\s+(?:INDEX|KEY)\s+(' . $I . ')/i', $c, $m)) return ['DROP INDEX IF EXISTS ' . self::indexName($t, $m[1], '')];
+         if (preg_match('/^CHANGE\s+(?:COLUMN\s+)?(' . $I . ')\s+(' . $I . ')\s/i', $c, $m)) {
+             if (self::unq($m[1]) !== self::unq($m[2])) return ['ALTER TABLE ' . $t . ' RENAME COLUMN ' . $m[1] . ' TO ' . $m[2]];
+             return [];
+         }
+         if (preg_match('/^RENAME\s+COLUMN\s+(' . $I . ')\s+TO\s+(' . $I . ')/i', $c, $m)) return ['ALTER TABLE ' . $t . ' RENAME COLUMN ' . $m[1] . ' TO ' . $m[2]];
+         if (preg_match('/^RENAME\s+(?:TO\s+|AS\s+)?(' . $I . ')\s*$/i', $c, $m) && !preg_match('/^(?:INDEX|KEY|COLUMN)$/i', $m[1])) return ['ALTER TABLE ' . $t . ' RENAME TO ' . $m[1]];
+         return [];
+     }
+ 
+     public static function mergeAlter(array &$st, string $clauses): bool
+     {
+         $I = self::ID;
+         foreach (self::splitTop($clauses) as $c) {
+             $c = trim($c);
+             if ($c === '') continue;
+             if (preg_match('/^ADD\s+(?:CONSTRAINT\s+(?:' . $I . '\s+)?)?PRIMARY\s+KEY\s*(?:USING\s+\w+\s*)?\((.*)\)/is', $c, $m)) {
+                 $st['pk'] = array_map('trim', explode(',', self::cleanCols($m[1])));
+             } elseif (preg_match('/^ADD\s+(?:CONSTRAINT\s+(?:' . $I . '\s+)?)?UNIQUE\s*(?:(?:KEY|INDEX)\s*)?(?:' . $I . ')?\s*(?:USING\s+\w+\s*)?\((.*)\)/is', $c, $m)) {
+                 $st['uniq'][] = self::cleanCols($m[1]);
+             } elseif (preg_match('/^ADD\s+(?:FULLTEXT\s+|SPATIAL\s+)?(?:KEY|INDEX)\s*(' . $I . ')?\s*(?:USING\s+\w+\s*)?\((.*)\)/is', $c, $m)) {
+                 $st['idx'][] = ['name' => $m[1] !== '' ? $m[1] : null, 'cols' => self::cleanCols($m[2]), 'unique' => false];
+             } elseif (preg_match('/^ADD\s+(?:CONSTRAINT\s+(?:' . $I . '\s+)?)?FOREIGN\s+KEY/i', $c)) {
+                 $st['fks'][] = preg_replace('/^ADD\s+/i', '', preg_replace('/FOREIGN\s+KEY\s+(?!\()' . $I . '\s*/i', 'FOREIGN KEY ', $c));
+             } elseif (preg_match('/^MODIFY\s+(?:COLUMN\s+)?(' . $I . ')\s+(.*)$/is', $c, $m)) {
+                 $col = self::parseColumn($m[1], $m[2]);
+                 foreach ($st['cols'] as $k => $existing) {
+                     if (self::unq($existing['name']) === self::unq($m[1])) $st['cols'][$k] = $col;
+                 }
+             } elseif (preg_match('/^CHANGE\s+(?:COLUMN\s+)?(' . $I . ')\s+(' . $I . ')\s+(.*)$/is', $c, $m)) {
+                 $col = self::parseColumn($m[2], $m[3]);
+                 foreach ($st['cols'] as $k => $existing) {
+                     if (self::unq($existing['name']) === self::unq($m[1])) $st['cols'][$k] = $col;
+                 }
+             } elseif (preg_match('/^(?:ENGINE|DEFAULT|CHARSET|CHARACTER|COLLATE|COMMENT|ROW_FORMAT|CONVERT)\b/i', $c)) {
+                 continue;
+             } elseif (preg_match('/^AUTO_INCREMENT\s*=?\s*(\d+)/i', $c, $m)) {
+                 $st['seq'] = (int)$m[1];
+             } else {
+                 return false;
+             }
+         }
+         return true;
+     }
+ 
+     public static function show(string $s): array
+     {
+         $I = self::ID;
+         $db = str_replace("'", "''", self::$db);
+         $skip = "type IN ('table','view') AND substr(name,1,7) <> 'sqlite_'";
+         $empty = 'SELECT NULL AS "Variable_name", NULL AS "Value" WHERE 0';
+         if (preg_match('/^SHOW\s+(FULL\s+)?TABLES\b(?:\s+(?:FROM|IN)\s+' . $I . ')?(?:\s+LIKE\s+(\x01\d+\x02))?/i', $s, $m)) {
+             $like = (isset($m[2]) && $m[2] !== '') ? ' AND name LIKE ' . $m[2] : '';
+             $extra = (isset($m[1]) && trim($m[1]) !== '') ? ", CASE type WHEN 'view' THEN 'VIEW' ELSE 'BASE TABLE' END AS \"Table_type\"" : '';
+             return ['SELECT name AS "Tables_in_' . str_replace('"', '', self::$db) . '"' . $extra . ' FROM sqlite_master WHERE ' . $skip . $like . ' ORDER BY name'];
+         }
+         if (preg_match('/^SHOW\s+TABLE\s+STATUS\b/i', $s)) {
+             return ['SELECT name AS "Name", \'InnoDB\' AS "Engine", 0 AS "Rows" FROM sqlite_master WHERE ' . $skip . ' ORDER BY name'];
+         }
+         if (preg_match('/^SHOW\s+(?:DATABASES|SCHEMAS)\b/i', $s)) {
+             return ["SELECT '" . $db . "' AS \"Database\""];
+         }
+         if (preg_match('/^SHOW\s+CREATE\s+TABLE\s+(?:' . $I . '\s*\.\s*)?(' . $I . ')/i', $s, $m)) {
+             $t = str_replace("'", "''", self::unq($m[1]));
+             return ["SELECT name AS \"Table\", sql AS \"Create Table\" FROM sqlite_master WHERE type = 'table' AND name = '" . $t . "'"];
+         }
+         if (preg_match('/^SHOW\s+(?:INDEX|INDEXES|KEYS)\s+(?:FROM|IN)\s+(?:' . $I . '\s*\.\s*)?(' . $I . ')/i', $s, $m)) {
+             $t = str_replace("'", "''", self::unq($m[1]));
+             return ["SELECT '" . $t . "' AS \"Table\", CASE il.\"unique\" WHEN 1 THEN 0 ELSE 1 END AS \"Non_unique\", il.name AS \"Key_name\", ii.seqno + 1 AS \"Seq_in_index\", ii.name AS \"Column_name\" FROM pragma_index_list('" . $t . "') il, pragma_index_info(il.name) ii"];
+         }
+         if (preg_match('/^(?:SHOW\s+(?:FULL\s+)?(?:COLUMNS|FIELDS)\s+(?:FROM|IN)|DESCRIBE|DESC|EXPLAIN)\s+(?:' . $I . '\s*\.\s*)?(' . $I . ')(?:\s+(?:FROM|IN)\s+' . $I . ')?(?:\s+LIKE\s+(\x01\d+\x02))?/i', $s, $m)) {
+             $t = str_replace("'", "''", self::unq($m[1]));
+             $like = (isset($m[2]) && $m[2] !== '') ? ' WHERE p.name LIKE ' . $m[2] : '';
+             return ["SELECT p.name AS \"Field\", lower(p.type) AS \"Type\", CASE WHEN p.\"notnull\" = 1 OR p.pk > 0 THEN 'NO' ELSE 'YES' END AS \"Null\", CASE WHEN p.pk > 0 THEN 'PRI' ELSE '' END AS \"Key\", CASE WHEN substr(p.dflt_value, 1, 1) = '''' THEN substr(p.dflt_value, 2, length(p.dflt_value) - 2) ELSE p.dflt_value END AS \"Default\", CASE WHEN p.pk > 0 AND (SELECT instr(sql, 'AUTOINCREMENT') FROM sqlite_master WHERE name = '" . $t . "') > 0 THEN 'auto_increment' ELSE '' END AS \"Extra\" FROM pragma_table_info('" . $t . "') p" . $like];
+         }
+         return [$empty];
+     }
+ 
+     public static function dml(string $s): string
+     {
+         $I = self::ID;
+         $db = str_replace("'", "''", self::$db);
+         if (stripos($s, 'information_schema') !== false) {
+             $s = preg_replace_callback('/\binformation_schema\s*\.\s*`?(\w+)`?/i', function ($m) use ($db) {
+                 switch (strtolower($m[1])) {
+                     case 'tables':
+                         return "(SELECT '$db' AS table_catalog, '$db' AS table_schema, name AS table_name, CASE type WHEN 'view' THEN 'VIEW' ELSE 'BASE TABLE' END AS table_type, 'InnoDB' AS engine, 0 AS table_rows FROM sqlite_master WHERE type IN ('table','view') AND substr(name,1,7) <> 'sqlite_')";
+                     case 'columns':
+                         return "(SELECT '$db' AS table_catalog, '$db' AS table_schema, m.name AS table_name, p.name AS column_name, p.cid + 1 AS ordinal_position, p.dflt_value AS column_default, CASE p.\"notnull\" WHEN 1 THEN 'NO' ELSE 'YES' END AS is_nullable, lower(p.type) AS data_type, lower(p.type) AS column_type, CASE WHEN p.pk > 0 THEN 'PRI' ELSE '' END AS column_key FROM sqlite_master m, pragma_table_info(m.name) p WHERE m.type IN ('table','view') AND substr(m.name,1,7) <> 'sqlite_')";
+                     case 'schemata':
+                         return "(SELECT '$db' AS schema_name, 'utf8mb4' AS default_character_set_name)";
+                 }
+                 return '(SELECT NULL AS table_schema, NULL AS table_name WHERE 0)';
+             }, $s);
+         }
+         $s = preg_replace('/\b(FROM|JOIN|INTO|UPDATE|TABLE)\s+(' . $I . ')\s*\.\s*(' . $I . ')/i', '$1 $3', $s);
+ 
+         if (preg_match('/^(INSERT\s+(?:IGNORE\s+)?INTO\s+' . $I . ')\s+SET\s+(.+?)(\s+ON\s+DUPLICATE\s+KEY\s+UPDATE\b.*)?$/is', $s, $m)) {
+             $cols = [];
+             $vals = [];
+             foreach (self::splitTop($m[2]) as $a) {
+                 if (!preg_match('/^\s*(' . $I . ')\s*=\s*(.+)$/s', $a, $x)) {
+                     $cols = [];
+                     break;
+                 }
+                 $cols[] = $x[1];
+                 $vals[] = trim($x[2]);
+             }
+             if ($cols) $s = $m[1] . ' (' . implode(', ', $cols) . ') VALUES (' . implode(', ', $vals) . ')' . (isset($m[3]) ? $m[3] : '');
+         }
+ 
+         if (preg_match('/^DELETE\s+FROM\s+(' . $I . ')(\s+.*?)?\s+LIMIT\s+(\d+|\?|:\w+)\s*$/is', $s, $m) && !preg_match('/\bJOIN\b/i', $s)) {
+             $s = 'DELETE FROM ' . $m[1] . ' WHERE rowid IN (SELECT rowid FROM ' . $m[1] . (isset($m[2]) ? $m[2] : '') . ' LIMIT ' . $m[3] . ')';
+         } elseif (preg_match('/^UPDATE\s+(?:IGNORE\s+)?(' . $I . ')\s+SET\s+(.*?)((?:\s+WHERE\s+.*?)?(?:\s+ORDER\s+BY\s+.*?)?)\s+LIMIT\s+(\d+|\?|:\w+)\s*$/is', $s, $m) && !preg_match('/\bJOIN\b/i', $s)) {
+             $s = 'UPDATE ' . $m[1] . ' SET ' . $m[2] . ' WHERE rowid IN (SELECT rowid FROM ' . $m[1] . $m[3] . ' LIMIT ' . $m[4] . ')';
+         }
+ 
+         $s = preg_replace('/^INSERT\s+(?:LOW_PRIORITY\s+|DELAYED\s+|HIGH_PRIORITY\s+)*IGNORE\b/i', 'INSERT OR IGNORE', $s);
+         $s = preg_replace('/^UPDATE\s+(?:LOW_PRIORITY\s+)?IGNORE\b/i', 'UPDATE OR IGNORE', $s);
+         $s = preg_replace('/\b(?:SQL_CALC_FOUND_ROWS|SQL_NO_CACHE|SQL_CACHE|SQL_SMALL_RESULT|SQL_BIG_RESULT|SQL_BUFFER_RESULT|HIGH_PRIORITY|LOW_PRIORITY|DELAYED)\b/i', '', $s);
+         $s = preg_replace('/\bSTRAIGHT_JOIN\b/i', 'JOIN', $s);
+         $s = preg_replace('/\s+(?:FOR\s+(?:UPDATE|SHARE)|LOCK\s+IN\s+SHARE\s+MODE)(?:\s+(?:NOWAIT|SKIP\s+LOCKED))?\s*$/i', '', $s);
+         $s = preg_replace('/\b(?:USE|FORCE|IGNORE)\s+(?:INDEX|KEY)\s*(?:FOR\s+\w+(?:\s+BY)?\s*)?\([^)]*\)/i', '', $s);
+         $s = preg_replace('/\bFROM\s+DUAL\b/i', '', $s);
+         if (preg_match('/^INSERT\b/i', $s)) $s = preg_replace('/(?<![\w`])DEFAULT(?=\s*[,)])/i', 'NULL', $s);
+ 
+         if (stripos($s, 'ON DUPLICATE') !== false) {
+             $s = preg_replace_callback('/^(.*?)\bON\s+DUPLICATE\s+KEY\s+UPDATE\b(.*)$/is', function ($m) use ($I) {
+                 $tail = preg_replace('/\bVALUES\s*\(\s*(' . $I . ')\s*\)/i', 'excluded.$1', $m[2]);
+                 return $m[1] . 'ON CONFLICT DO UPDATE SET' . $tail;
+             }, $s);
+         }
+ 
+         $unit = 'MICROSECOND|SECOND|MINUTE|HOUR|DAY|WEEK|MONTH|QUARTER|YEAR';
+         if (stripos($s, 'INTERVAL') !== false) {
+             $s = preg_replace_callback('/\b(DATE_ADD|ADDDATE|DATE_SUB|SUBDATE)\s*\(\s*(.+?)\s*,\s*INTERVAL\s+(.+?)\s+(' . $unit . ')\s*\)/is', function ($m) {
+                 return 'ath_date_add(' . $m[2] . ', ' . $m[3] . ", '" . strtoupper($m[4]) . "', " . (stripos($m[1], 'ADD') !== false ? '1' : '-1') . ')';
+             }, $s);
+             $left = '(\bNOW\s*\(\s*\)|\bCURRENT_TIMESTAMP\b(?:\s*\(\s*\d*\s*\))?|\bCURDATE\s*\(\s*\)|\bCURRENT_DATE\b(?:\s*\(\s*\))?|' . $I . '(?:\s*\.\s*' . $I . ')?|\x01\d+\x02)';
+             $num = '(-?\d+(?:\.\d+)?|\x01\d+\x02|\?|:\w+|' . $I . '(?:\.' . $I . ')?)';
+             $s = preg_replace_callback('/' . $left . '\s*([+-])\s*INTERVAL\s+' . $num . '\s+(' . $unit . ')\b/i', function ($m) {
+                 return 'ath_date_add(' . $m[1] . ', ' . $m[3] . ", '" . strtoupper($m[4]) . "', " . ($m[2] === '+' ? '1' : '-1') . ')';
+             }, $s);
+         }
+         if (stripos($s, 'TIMESTAMPDIFF') !== false) $s = preg_replace('/\bTIMESTAMPDIFF\s*\(\s*(\w+)\s*,/i', "timestampdiff('$1',", $s);
+         if (stripos($s, 'SEPARATOR') !== false) {
+             $s = preg_replace_callback('/\bGROUP_CONCAT\s*\(\s*(DISTINCT\s+)?(.+?)(\s+ORDER\s+BY\s+.+?)?\s+SEPARATOR\s+(\x01\d+\x02)\s*\)/is', function ($m) {
+                 if (trim($m[1]) !== '') return 'group_concat(DISTINCT ' . $m[2] . ')';
+                 return 'group_concat(' . $m[2] . ', ' . $m[4] . $m[3] . ')';
+             }, $s);
+         }
+         if (stripos($s, 'CAST') !== false || stripos($s, ' AS ') !== false) {
+             $s = preg_replace('/\bCAST\s*\(\s*([^()]+?)\s+AS\s+DATETIME\s*\)/i', 'datetime($1)', $s);
+             $s = preg_replace('/\bCAST\s*\(\s*([^()]+?)\s+AS\s+DATE\s*\)/i', 'date($1)', $s);
+             $s = preg_replace('/\bAS\s+(?:UNSIGNED|SIGNED)(?:\s+INTEGER)?\b/i', 'AS INTEGER', $s);
+             $s = preg_replace('/\bAS\s+(?:CHAR|NCHAR|BINARY)(?:\s*\(\s*\d+\s*\))?(?=\s*\))/i', 'AS TEXT', $s);
+         }
+         $s = preg_replace('/\bLAST_INSERT_ID\s*\(\s*\)/i', 'last_insert_rowid()', $s);
+         $s = preg_replace('/\bROW_COUNT\s*\(\s*\)/i', 'changes()', $s);
+         $s = preg_replace('/\bGREATEST\s*\(/i', 'max(', $s);
+         $s = preg_replace('/\bLEAST\s*\(/i', 'min(', $s);
+         $s = preg_replace('/\b(?:CURRENT_TIMESTAMP|LOCALTIMESTAMP|LOCALTIME)\b(?:\s*\(\s*\d*\s*\))?/i', 'now()', $s);
+         $s = preg_replace('/\bCURRENT_DATE\b(?:\s*\(\s*\))?/i', 'curdate()', $s);
+         $s = preg_replace('/\bCURRENT_TIME\b(?:\s*\(\s*\d*\s*\))?/i', 'curtime()', $s);
+         $s = str_replace('<=>', ' IS ', $s);
+         $s = preg_replace('/\bDIV\b/i', '/', $s);
+         $s = preg_replace('/\bMOD\b(?!\s*\()/i', '%', $s);
+         $s = preg_replace('/\bRLIKE\b/i', 'REGEXP', $s);
+         if (stripos($s, 'BINARY') !== false) {
+             $s = preg_replace('/\bBINARY\s+(' . $I . '(?:\s*\.\s*' . $I . ')?|\x01\d+\x02|\?)/i', '$1 COLLATE BINARY', $s);
+         }
+         return trim($s);
+     }
+ 
+     public static function runList(AthPDO $pdo, array $list): int
+     {
+         $n = 0;
+         foreach ($list as $q) {
+             if ($q !== '' && $q[0] === self::OPT) {
+                 try {
+                     $pdo->rawExec(substr($q, 1));
+                 } catch (Throwable $e) {
+                 }
+                 continue;
+             }
+             $r = $pdo->rawExec($q);
+             $n = $r === false ? 0 : $r;
+         }
+         return $n;
+     }
+ 
+     public static function escape(string $s): string
+     {
+         return strtr($s, ["\0" => '\\0', "\n" => '\\n', "\r" => '\\r', '\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\x1a" => '\\Z']);
+     }
+ 
+     public static function mysqlError(string $msg): array
+     {
+         $db = self::$db;
+         if (preg_match('/no such table:\s*(?:\w+\.)?(\S+)/i', $msg, $m)) {
+             return [1146, '42S02', "Table '$db." . $m[1] . "' doesn't exist", 'Base table or view not found'];
+         }
+         if (preg_match('/no such column:\s*(\S+)/i', $msg, $m) || preg_match('/table \S+ has no column named (\S+)/i', $msg, $m)) {
+             return [1054, '42S22', "Unknown column '" . $m[1] . "' in 'field list'", 'Column not found'];
+         }
+         if (preg_match('/UNIQUE constraint failed:\s*(\S+)/i', $msg, $m)) {
+             return [1062, '23000', "Duplicate entry for key '" . $m[1] . "'", 'Integrity constraint violation'];
+         }
+         if (preg_match('/NOT NULL constraint failed:\s*(?:\w+\.)?(\S+)/i', $msg, $m)) {
+             return [1048, '23000', "Column '" . $m[1] . "' cannot be null", 'Integrity constraint violation'];
+         }
+         if (stripos($msg, 'FOREIGN KEY constraint failed') !== false) {
+             return [1452, '23000', 'Cannot add or update a child row: a foreign key constraint fails', 'Integrity constraint violation'];
+         }
+         if (preg_match('/table (\S+) already exists/i', $msg, $m)) {
+             return [1050, '42S01', "Table '" . trim($m[1], '"`') . "' already exists", 'Base table or view already exists'];
+         }
+         if (preg_match('/no such function:\s*(\S+)/i', $msg, $m)) {
+             return [1305, '42000', "FUNCTION $db." . $m[1] . ' does not exist', 'Syntax error or access violation'];
+         }
+         if (preg_match('/near "([^"]*)"/', $msg, $m) || stripos($msg, 'syntax error') !== false || stripos($msg, 'incomplete input') !== false) {
+             $near = isset($m[1]) ? $m[1] : '';
+             return [1064, '42000', "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$near' at line 1", 'Syntax error or access violation'];
+         }
+         return [1105, 'HY000', 'Unknown error: ' . $msg, 'General error'];
+     }
+ 
+     public static function mapPdo(PDOException $e): PDOException
+     {
+         if (isset($e->errorInfo[1]) && (int)$e->errorInfo[1] >= 1000) return $e;
+         if (!preg_match('/^SQLSTATE\[[^\]]*\]:[^:]*:\s*\d+\s+(.*)$/s', $e->getMessage(), $m)) return $e;
+         list($no, $state, $text, $label) = self::mysqlError($m[1]);
+         $e->errorInfo = [$state, $no, $text];
+         (new ReflectionProperty('Exception', 'message'))->setValue($e, "SQLSTATE[$state]: $label: $no $text");
+         (new ReflectionProperty('Exception', 'code'))->setValue($e, $state);
+         return $e;
+     }
+ 
+     public static function dt($v): ?DateTimeImmutable
+     {
+         if ($v === null || $v === '') return null;
+         $v = (string)$v;
+         if (strpos($v, '0000-00-00') === 0) return null;
+         try {
+             return new DateTimeImmutable($v);
+         } catch (Throwable $e) {
+             return null;
+         }
+     }
+ 
+     public static function fmt($v, $f): ?string
+     {
+         $d = self::dt($v);
+         if ($d === null || $f === null) return null;
+         $f = (string)$f;
+         $map = ['Y' => 'Y', 'y' => 'y', 'm' => 'm', 'c' => 'n', 'd' => 'd', 'e' => 'j', 'H' => 'H', 'k' => 'G', 'h' => 'h', 'I' => 'h', 'l' => 'g', 'i' => 'i', 's' => 's', 'S' => 's', 'p' => 'A', 'M' => 'F', 'b' => 'M', 'W' => 'l', 'a' => 'D', 'w' => 'w', 'T' => 'H:i:s', 'r' => 'h:i:s A', 'u' => 'W'];
+         $out = '';
+         $n = strlen($f);
+         for ($i = 0; $i < $n; $i++) {
+             $c = $f[$i];
+             if ($c !== '%' || $i + 1 >= $n) {
+                 $out .= $c;
+                 continue;
+             }
+             $x = $f[++$i];
+             if ($x === 'j') $out .= str_pad((string)((int)$d->format('z') + 1), 3, '0', STR_PAD_LEFT);
+             elseif ($x === 'f') $out .= '000000';
+             elseif ($x === '%') $out .= '%';
+             elseif (isset($map[$x])) $out .= $d->format($map[$x]);
+             else $out .= $x;
+         }
+         return $out;
+     }
+ 
+     public static function dateAdd($v, $n, $unit, $sign = 1)
+     {
+         $d = self::dt($v);
+         if ($d === null || $n === null) return null;
+         $n = (int)round((float)$n) * (int)$sign;
+         $unit = strtoupper((string)$unit);
+         $time = (bool)preg_match('/\d:\d/', (string)$v) || in_array($unit, ['SECOND', 'MINUTE', 'HOUR', 'MICROSECOND'], true);
+         if ($unit === 'MONTH' || $unit === 'QUARTER' || $unit === 'YEAR') {
+             $months = $unit === 'YEAR' ? $n * 12 : ($unit === 'QUARTER' ? $n * 3 : $n);
+             $total = (int)$d->format('Y') * 12 + ((int)$d->format('n') - 1) + $months;
+             $y = intdiv($total, 12);
+             $m = $total % 12 + 1;
+             $last = (int)(new DateTimeImmutable(sprintf('%04d-%02d-01', $y, $m)))->format('t');
+             $d = $d->setDate($y, $m, min((int)$d->format('j'), $last));
+         } elseif ($unit === 'WEEK') {
+             $d = $d->modify(($n * 7) . ' days');
+         } elseif ($unit === 'DAY') {
+             $d = $d->modify($n . ' days');
+         } elseif ($unit === 'HOUR') {
+             $d = $d->modify($n . ' hours');
+         } elseif ($unit === 'MINUTE') {
+             $d = $d->modify($n . ' minutes');
+         } elseif ($unit === 'SECOND') {
+             $d = $d->modify($n . ' seconds');
+         }
+         return $d->format($time ? 'Y-m-d H:i:s' : 'Y-m-d');
+     }
+ 
+     public static function tsDiff($unit, $a, $b)
+     {
+         $x = self::dt($a);
+         $y = self::dt($b);
+         if ($x === null || $y === null) return null;
+         $unit = strtoupper((string)$unit);
+         $secs = $y->getTimestamp() - $x->getTimestamp();
+         $div = ['SECOND' => 1, 'MINUTE' => 60, 'HOUR' => 3600, 'DAY' => 86400, 'WEEK' => 604800];
+         if (isset($div[$unit])) return (int)($secs / $div[$unit]);
+         $i = $x->diff($y);
+         $months = ($i->y * 12 + $i->m) * ($i->invert ? -1 : 1);
+         if ($unit === 'YEAR') return intdiv($months, 12);
+         if ($unit === 'QUARTER') return intdiv($months, 3);
+         return $months;
+     }
+ 
+     public static function strToDate($str, $fmt)
+     {
+         if ($str === null || $fmt === null) return null;
+         $re = '';
+         $order = [];
+         $f = (string)$fmt;
+         $map = ['Y' => '(\d{4})', 'y' => '(\d{2})', 'm' => '(\d{1,2})', 'c' => '(\d{1,2})', 'd' => '(\d{1,2})', 'e' => '(\d{1,2})', 'H' => '(\d{1,2})', 'k' => '(\d{1,2})', 'h' => '(\d{1,2})', 'I' => '(\d{1,2})', 'i' => '(\d{1,2})', 's' => '(\d{1,2})', 'S' => '(\d{1,2})', 'p' => '([AaPp][Mm])'];
+         for ($i = 0, $n = strlen($f); $i < $n; $i++) {
+             if ($f[$i] === '%' && $i + 1 < $n) {
+                 $x = $f[++$i];
+                 if (isset($map[$x])) {
+                     $re .= $map[$x];
+                     $order[] = $x;
+                 } else {
+                     $re .= preg_quote($x, '~');
+                 }
+             } else {
+                 $re .= preg_quote($f[$i], '~');
+             }
+         }
+         if (!preg_match('~^\s*' . $re . '~', (string)$str, $m)) return null;
+         $p = ['Y' => 1970, 'm' => 1, 'd' => 1, 'H' => 0, 'i' => 0, 's' => 0];
+         $pm = null;
+         foreach ($order as $k => $x) {
+             $v = $m[$k + 1];
+             if ($x === 'Y') $p['Y'] = (int)$v;
+             elseif ($x === 'y') $p['Y'] = (int)$v + ((int)$v < 70 ? 2000 : 1900);
+             elseif ($x === 'm' || $x === 'c') $p['m'] = (int)$v;
+             elseif ($x === 'd' || $x === 'e') $p['d'] = (int)$v;
+             elseif ($x === 'H' || $x === 'k' || $x === 'h' || $x === 'I') $p['H'] = (int)$v;
+             elseif ($x === 'i') $p['i'] = (int)$v;
+             elseif ($x === 's' || $x === 'S') $p['s'] = (int)$v;
+             elseif ($x === 'p') $pm = strtoupper($v);
+         }
+         if ($pm === 'PM' && $p['H'] < 12) $p['H'] += 12;
+         if ($pm === 'AM' && $p['H'] === 12) $p['H'] = 0;
+         $hasTime = (bool)array_intersect($order, ['H', 'k', 'h', 'I', 'i', 's', 'S']);
+         $date = sprintf('%04d-%02d-%02d', $p['Y'], $p['m'], $p['d']);
+         return $hasTime ? $date . sprintf(' %02d:%02d:%02d', $p['H'], $p['i'], $p['s']) : $date;
+     }
+ 
+     public static function register(PDO $pdo): void
+     {
+         $f = function ($name, $fn, $n = -1) use ($pdo) {
+             $pdo->sqliteCreateFunction($name, $fn, $n);
+         };
+         $str = function ($v) {
+             return $v === null ? null : (string)$v;
+         };
+ 
+         $pdo->sqliteCreateCollation('NOCASE', function ($a, $b) {
+             return strcmp(mb_strtolower((string)$a), mb_strtolower((string)$b));
+         });
+ 
+         $f('like', function ($p, $s, $e = null) {
+             if ($p === null || $s === null) return null;
+             $e = ($e === null || $e === '') ? '\\' : (string)$e;
+             $key = $p . "\0" . $e;
+             if (!isset(self::$likeCache[$key])) {
+                 if (count(self::$likeCache) > 500) self::$likeCache = [];
+                 $chars = preg_split('//u', (string)$p, -1, PREG_SPLIT_NO_EMPTY);
+                 if ($chars === false) $chars = str_split((string)$p);
+                 $re = '';
+                 for ($i = 0, $n = count($chars); $i < $n; $i++) {
+                     $c = $chars[$i];
+                     if ($c === $e && $i + 1 < $n) $re .= preg_quote($chars[++$i], '~');
+                     elseif ($c === '%') $re .= '.*';
+                     elseif ($c === '_') $re .= '.';
+                     else $re .= preg_quote($c, '~');
+                 }
+                 self::$likeCache[$key] = '~^' . $re . '$~isu';
+             }
+             $r = @preg_match(self::$likeCache[$key], (string)$s);
+             if ($r === false) $r = @preg_match(substr(self::$likeCache[$key], 0, -1), (string)$s);
+             return $r ? 1 : 0;
+         });
+         $f('regexp', function ($p, $s) {
+             if ($p === null || $s === null) return null;
+             return @preg_match('~' . str_replace('~', '\\~', (string)$p) . '~iu', (string)$s) ? 1 : 0;
+         }, 2);
+ 
+         foreach (['upper', 'ucase'] as $n) $f($n, function ($s) use ($str) { return $s === null ? null : mb_strtoupper((string)$s); }, 1);
+         foreach (['lower', 'lcase'] as $n) $f($n, function ($s) use ($str) { return $s === null ? null : mb_strtolower((string)$s); }, 1);
+         foreach (['char_length', 'character_length'] as $n) $f($n, function ($s) { return $s === null ? null : mb_strlen((string)$s); }, 1);
+ 
+         $f('concat', function (...$a) {
+             $o = '';
+             foreach ($a as $v) {
+                 if ($v === null) return null;
+                 $o .= $v;
+             }
+             return $o;
+         });
+         $f('concat_ws', function ($sep, ...$a) {
+             if ($sep === null) return null;
+             $p = [];
+             foreach ($a as $v) if ($v !== null) $p[] = $v;
+             return implode((string)$sep, $p);
+         });
+         $f('left', function ($s, $n) { return $s === null ? null : mb_substr((string)$s, 0, max(0, (int)$n)); }, 2);
+         $f('right', function ($s, $n) { return $s === null ? null : ((int)$n <= 0 ? '' : mb_substr((string)$s, -(int)$n)); }, 2);
+         $f('lpad', function ($s, $n, $p) {
+             if ($s === null || $n === null || $p === null) return null;
+             $s = (string)$s;
+             $len = mb_strlen($s);
+             $n = (int)$n;
+             if ($n <= $len) return mb_substr($s, 0, $n);
+             if ($p === '') return null;
+             $pad = '';
+             while (mb_strlen($pad) < $n - $len) $pad .= $p;
+             return mb_substr($pad, 0, $n - $len) . $s;
+         }, 3);
+         $f('rpad', function ($s, $n, $p) {
+             if ($s === null || $n === null || $p === null) return null;
+             $s = (string)$s;
+             $len = mb_strlen($s);
+             $n = (int)$n;
+             if ($n <= $len) return mb_substr($s, 0, $n);
+             if ($p === '') return null;
+             $pad = '';
+             while (mb_strlen($pad) < $n - $len) $pad .= $p;
+             return $s . mb_substr($pad, 0, $n - $len);
+         }, 3);
+         $f('locate', function ($sub, $s, $pos = 1) {
+             if ($sub === null || $s === null) return null;
+             $r = mb_stripos((string)$s, (string)$sub, max(0, (int)$pos - 1));
+             return $r === false ? 0 : $r + 1;
+         });
+         $f('find_in_set', function ($a, $list) {
+             if ($a === null || $list === null) return null;
+             $i = array_search(mb_strtolower((string)$a), array_map('mb_strtolower', explode(',', (string)$list)), true);
+             return $i === false ? 0 : $i + 1;
+         }, 2);
+         $f('substring_index', function ($s, $d, $c) {
+             if ($s === null || $d === null || $c === null) return null;
+             $parts = explode((string)$d, (string)$s);
+             $c = (int)$c;
+             if ($c >= 0) return implode((string)$d, array_slice($parts, 0, $c));
+             return implode((string)$d, array_slice($parts, $c));
+         }, 3);
+         $f('reverse', function ($s) { return $s === null ? null : implode('', array_reverse(preg_split('//u', (string)$s, -1, PREG_SPLIT_NO_EMPTY))); }, 1);
+         $f('repeat', function ($s, $n) { return $s === null ? null : str_repeat((string)$s, max(0, (int)$n)); }, 2);
+         $f('space', function ($n) { return str_repeat(' ', max(0, (int)$n)); }, 1);
+         $f('strcmp', function ($a, $b) { return $a === null || $b === null ? null : (strcmp((string)$a, (string)$b) <=> 0); }, 2);
+         $f('format', function ($n, $d = 0) { return $n === null ? null : number_format((float)$n, max(0, (int)$d), '.', ','); });
+         $f('field', function ($v, ...$list) {
+             foreach ($list as $i => $x) if ((string)$x === (string)$v) return $i + 1;
+             return 0;
+         });
+         $f('isnull', function ($v) { return $v === null ? 1 : 0; }, 1);
+         $f('any_value', function ($v) { return $v; }, 1);
+         $f('truncate', function ($x, $d) {
+             if ($x === null) return null;
+             $m = pow(10, (int)$d);
+             return ($x < 0 ? ceil($x * $m) : floor($x * $m)) / $m;
+         }, 2);
+ 
+         $f('md5', function ($s) { return $s === null ? null : md5((string)$s); }, 1);
+         $f('sha1', function ($s) { return $s === null ? null : sha1((string)$s); }, 1);
+         $f('sha2', function ($s, $b = 256) {
+             $algo = [0 => 'sha256', 224 => 'sha224', 256 => 'sha256', 384 => 'sha384', 512 => 'sha512'][(int)$b] ?? null;
+             return ($s === null || $algo === null) ? null : hash($algo, (string)$s);
+         });
+         $f('uuid', function () {
+             $b = random_bytes(16);
+             $b[6] = chr(ord($b[6]) & 0x0f | 0x40);
+             $b[8] = chr(ord($b[8]) & 0x3f | 0x80);
+             return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($b), 4));
+         }, 0);
+         $f('rand', function ($seed = null) { return mt_rand() / mt_getrandmax(); });
+         $f('database', function () { return self::$db; }, 0);
+         $f('schema', function () { return self::$db; }, 0);
+         $f('version', function () { return '8.0.36-athera'; }, 0);
+         $f('user', function () { return 'root@localhost'; }, 0);
+         $f('current_user', function () { return 'root@localhost'; }, 0);
+         $f('connection_id', function () { return 1; }, 0);
+ 
+         $f('now', function () { return date('Y-m-d H:i:s'); }, 0);
+         $f('sysdate', function () { return date('Y-m-d H:i:s'); }, 0);
+         $f('utc_timestamp', function () { return gmdate('Y-m-d H:i:s'); }, 0);
+         $f('curdate', function () { return date('Y-m-d'); }, 0);
+         $f('utc_date', function () { return gmdate('Y-m-d'); }, 0);
+         $f('curtime', function () { return date('H:i:s'); }, 0);
+         $f('unix_timestamp', function ($v = null) {
+             if ($v === null) return time();
+             $d = self::dt($v);
+             return $d === null ? null : $d->getTimestamp();
+         });
+         $f('from_unixtime', function ($ts, $fmt = null) {
+             if ($ts === null) return null;
+             $d = date('Y-m-d H:i:s', (int)$ts);
+             return $fmt === null ? $d : self::fmt($d, $fmt);
+         });
+         $f('date_format', function ($d, $fmt) { return self::fmt($d, $fmt); }, 2);
+         $f('str_to_date', function ($s, $fmt) { return self::strToDate($s, $fmt); }, 2);
+         $f('ath_date_add', function ($d, $n, $u, $s = 1) { return self::dateAdd($d, $n, $u, $s); });
+         $f('timestampdiff', function ($u, $a, $b) { return self::tsDiff($u, $a, $b); }, 3);
+         $f('datediff', function ($a, $b) {
+             $x = self::dt($a);
+             $y = self::dt($b);
+             if ($x === null || $y === null) return null;
+             return (int)round(($x->setTime(0, 0)->getTimestamp() - $y->setTime(0, 0)->getTimestamp()) / 86400);
+         }, 2);
+         $parts = [
+             'year' => 'Y', 'month' => 'n', 'day' => 'j', 'dayofmonth' => 'j', 'hour' => 'G', 'minute' => 'i', 'second' => 's',
+             'dayofyear' => 'z', 'weekday' => 'N', 'dayofweek' => 'w', 'quarter' => 'n', 'week' => 'W'
+         ];
+         foreach ($parts as $name => $code) {
+             $f($name, function ($v) use ($name, $code) {
+                 $d = self::dt($v);
+                 if ($d === null) return null;
+                 $x = (int)$d->format($code);
+                 if ($name === 'dayofyear') return $x + 1;
+                 if ($name === 'weekday') return $x - 1;
+                 if ($name === 'dayofweek') return $x + 1;
+                 if ($name === 'quarter') return (int)ceil($x / 3);
+                 return $x;
+             }, 1);
+         }
+         $f('monthname', function ($v) { $d = self::dt($v); return $d === null ? null : $d->format('F'); }, 1);
+         $f('dayname', function ($v) { $d = self::dt($v); return $d === null ? null : $d->format('l'); }, 1);
+         $f('last_day', function ($v) { $d = self::dt($v); return $d === null ? null : $d->format('Y-m-t'); }, 1);
+     }
+ 
+     public static function findDump(string $db): ?string
+     {
+         $found = [];
+         foreach (['', 'sql', 'db', 'database', 'databases', 'data', 'dump', 'dumps', 'backup', 'backups', 'schema', 'install'] as $d) {
+             $p = self::$root . ($d === '' ? '' : '/' . $d);
+             if (!is_dir($p)) continue;
+             foreach (glob($p . '/*.sql') ?: [] as $file) $found[] = $file;
+         }
+         foreach ($found as $file) {
+             if (strcasecmp(basename($file, '.sql'), $db) === 0) return $file;
+         }
+         return count($found) === 1 ? $found[0] : null;
+     }
+ 
+     public static function dbFile(string $db, &$fresh): string
+     {
+         if (!is_dir(self::$dir)) @mkdir(self::$dir, 0777, true);
+         $name = preg_replace('/[^\w.\-]+/', '_', $db);
+         if ($name === null || $name === '') $name = 'default';
+         $file = self::$dir . '/' . $name . '.sqlite';
+         $sigFile = self::$dir . '/' . $name . '.sig';
+         $dump = self::findDump($db);
+         self::$dump = $dump;
+         $sig = $dump !== null ? $dump . ':' . filemtime($dump) . ':' . filesize($dump) : '';
+         $fresh = !is_file($file);
+         if (!$fresh) {
+             $old = is_file($sigFile) ? (string)file_get_contents($sigFile) : '';
+             if ($old !== $sig) {
+                 @unlink($file);
+                 $fresh = true;
+             }
+         }
+         if ($fresh) file_put_contents($sigFile, $sig);
+         return $file;
+     }
+ 
+     public static function splitDump(string $masked): array
+     {
+         $out = [];
+         $delim = ';';
+         $pos = 0;
+         $add = function ($seg) use (&$out, &$delim) {
+             $parts = $delim === ';' ? preg_split('~`[^`]*`(*SKIP)(*FAIL)|;~', $seg) : explode($delim, $seg);
+             foreach ($parts as $p) {
+                 $p = trim($p);
+                 if ($p !== '') $out[] = $p;
+             }
+         };
+         while (preg_match('~^[ \t]*DELIMITER[ \t]+(\S+)[ \t]*$~mi', $masked, $m, PREG_OFFSET_CAPTURE, $pos)) {
+             $add(substr($masked, $pos, $m[0][1] - $pos));
+             $delim = $m[1][0];
+             $pos = $m[0][1] + strlen($m[0][0]);
+         }
+         $add(substr($masked, $pos));
+         return $out;
+     }
+ 
+     public static function importDump(AthPDO $pdo, string $sql, string $label): void
+     {
+         $I = self::ID;
+         $lits = [];
+         $masked = self::mask($sql, $lits);
+         $tables = [];
+         $plan = [];
+         foreach (self::splitDump($masked) as $s) {
+             if (preg_match('/^CREATE\s+(?:TEMPORARY\s+)?TABLE\b/i', $s)) {
+                 $st = self::parseCreate($s);
+                 if ($st !== null) {
+                     $key = strtolower(self::unq($st['name']));
+                     $tables[$key] = $st;
+                     $plan[] = ['t', $key];
+                     continue;
+                 }
+             }
+             if (preg_match('/^ALTER\s+(?:IGNORE\s+)?TABLE\s+(?:' . $I . '\s*\.\s*)?(' . $I . ')\s+(.*)$/is', $s, $m)) {
+                 $key = strtolower(self::unq($m[1]));
+                 if (isset($tables[$key]) && self::mergeAlter($tables[$key], $m[2])) continue;
+             }
+             $plan[] = ['s', $s];
+         }
+         $pdo->rawExec('PRAGMA foreign_keys = OFF');
+         $pdo->rawExec('BEGIN');
+         $done = 0;
+         $failed = 0;
+         $skipped = 0;
+         $errors = [];
+         foreach ($plan as $p) {
+             if ($p[0] === 't') {
+                 $list = self::buildCreate($tables[$p[1]]);
+             } else {
+                 if (preg_match('/^(?:START\s+TRANSACTION|BEGIN|COMMIT|ROLLBACK|SAVEPOINT|RELEASE)\b/i', $p[1])) continue;
+                 if (preg_match('/^CREATE\s+(?:DEFINER\s*=\s*\S+\s+)?(?:TRIGGER|PROCEDURE|FUNCTION|EVENT)\b/i', $p[1])) {
+                     $skipped++;
+                     continue;
+                 }
+                 $list = self::convert($p[1]);
+             }
+             foreach ($list as $q) {
+                 try {
+                     self::runList($pdo, [self::unmask($q, $lits)]);
+                     $done++;
+                 } catch (Throwable $e) {
+                     $failed++;
+                     if (count($errors) < 3) {
+                         $msg = $e instanceof PDOException ? self::mapPdo($e)->getMessage() : $e->getMessage();
+                         $errors[] = $msg;
+                     }
+                 }
+             }
+         }
+         $pdo->rawExec('COMMIT');
+         foreach ($tables as $st) {
+             if (!$st['seq']) continue;
+             $t = str_replace("'", "''", self::unq($st['name']));
+             $n = (int)$st['seq'] - 1;
+             try {
+                 $pdo->rawExec("UPDATE sqlite_sequence SET seq = $n WHERE name = '$t' AND seq < $n");
+                 $pdo->rawExec("INSERT INTO sqlite_sequence (name, seq) SELECT '$t', $n WHERE NOT EXISTS (SELECT 1 FROM sqlite_sequence WHERE name = '$t')");
+             } catch (Throwable $e) {
+             }
+         }
+         $pdo->rawExec('PRAGMA foreign_keys = ON');
+         if ($failed || $skipped) {
+             $msg = '[Athera MySQL BETA] ' . $label . ': ' . $done . ' OK, ' . $failed . ' failed' . ($skipped ? ', ' . $skipped . ' skipped (triggers/procedures)' : '');
+             if ($errors) $msg .= '. ' . implode(' | ', $errors);
+             trigger_error($msg, E_USER_NOTICE);
+         }
+     }
+ }
+ 
+ class AthStmt extends PDOStatement
+ {
+     private $athPdo = null;
+     private $athSql = '';
+     private $athPost = [];
+     private $athBinds = [];
+     private $athParams = null;
+ 
+     public function athInit(AthPDO $pdo, string $sql, array $post = []): void
+     {
+         $this->athPdo = $pdo;
+         $this->athSql = $sql;
+         $this->athPost = $post;
+     }
+ 
+     public function athChanges(): int
+     {
+         return parent::rowCount();
+     }
+ 
+     public function execute(?array $params = null): bool
+     {
+         $this->athParams = $params;
+         try {
+             $ok = parent::execute($params);
+         } catch (PDOException $e) {
+             throw AthMy::mapPdo($e);
+         }
+         if ($ok && $this->athPost && $this->athPdo !== null) AthMy::runList($this->athPdo, $this->athPost);
+         return $ok;
+     }
+ 
+     public function bindValue(string|int $param, mixed $value, int $type = PDO::PARAM_STR): bool
+     {
+         $this->athBinds[$param] = [$value, $type];
+         return parent::bindValue($param, $value, $type);
+     }
+ 
+     public function bindParam(string|int $param, mixed &$var, int $type = PDO::PARAM_STR, int $maxLength = 0, mixed $driverOptions = null): bool
+     {
+         $this->athBinds[$param] = [&$var, $type];
+         return parent::bindParam($param, $var, $type, $maxLength, $driverOptions);
+     }
+ 
+     public function rowCount(): int
+     {
+         if ($this->athPdo !== null && $this->columnCount() > 0 && AthMy::isQuery($this->athSql)) return $this->athCount();
+         return parent::rowCount();
+     }
+ 
+     private function athCount(): int
+     {
+         try {
+             $st = $this->athPdo->rawPrepare('SELECT COUNT(*) FROM (' . $this->athSql . ')');
+             if ($this->athParams !== null) {
+                 $st->execute($this->athParams);
+             } else {
+                 foreach ($this->athBinds as $k => $b) $st->bindValue($k, $b[0], $b[1]);
+                 $st->execute();
+             }
+             return (int)$st->fetchColumn();
+         } catch (Throwable $e) {
+             return 0;
+         }
+     }
+ }
+ 
+ class AthPDO extends PDO
+ {
+     const MYSQL_ATTR_USE_BUFFERED_QUERY = 1000;
+     const MYSQL_ATTR_LOCAL_INFILE = 1001;
+     const MYSQL_ATTR_INIT_COMMAND = 1002;
+     const MYSQL_ATTR_COMPRESS = 1003;
+     const MYSQL_ATTR_DIRECT_QUERY = 1004;
+     const MYSQL_ATTR_FOUND_ROWS = 1005;
+     const MYSQL_ATTR_IGNORE_SPACE = 1006;
+     const MYSQL_ATTR_SSL_KEY = 1007;
+     const MYSQL_ATTR_SSL_CERT = 1008;
+     const MYSQL_ATTR_SSL_CA = 1009;
+     const MYSQL_ATTR_SSL_CAPATH = 1010;
+     const MYSQL_ATTR_SSL_CIPHER = 1011;
+     const MYSQL_ATTR_SERVER_PUBLIC_KEY = 1012;
+     const MYSQL_ATTR_MULTI_STATEMENTS = 1013;
+     const MYSQL_ATTR_SSL_VERIFY_SERVER_CERT = 1014;
+ 
+     private $athMy = false;
+ 
+     public function __construct($dsn, $username = null, $password = null, $options = null)
+     {
+         if (!is_string($dsn) || stripos(ltrim($dsn), 'mysql:') !== 0) {
+             parent::__construct($dsn, $username, $password, $options);
+             return;
+         }
+         $attrs = [];
+         preg_match_all('/(\w+)\s*=\s*([^;]*)/', substr(ltrim($dsn), 6), $pairs, PREG_SET_ORDER);
+         foreach ($pairs as $x) $attrs[strtolower($x[1])] = trim($x[2]);
+         $db = isset($attrs['dbname']) ? $attrs['dbname'] : '';
+         if ($db === '') $db = 'default';
+         $fresh = false;
+         $file = AthMy::dbFile($db, $fresh);
+         $keep = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
+         $init = null;
+         foreach ((array)$options as $k => $v) {
+             if ($k === 1002) $init = $v;
+             elseif (in_array($k, [PDO::ATTR_ERRMODE, PDO::ATTR_DEFAULT_FETCH_MODE, PDO::ATTR_CASE, PDO::ATTR_ORACLE_NULLS], true)) $keep[$k] = $v;
+         }
+         parent::__construct('sqlite:' . $file, null, null, $keep);
+         $this->athMy = true;
+         AthMy::$db = $db;
+         $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, ['AthStmt']);
+         AthMy::register($this);
+         parent::exec('PRAGMA foreign_keys = ON');
+         if ($fresh && AthMy::$dump !== null) {
+             AthMy::importDump($this, (string)file_get_contents(AthMy::$dump), basename(AthMy::$dump));
+         }
+         if (is_string($init) && $init !== '') $this->exec($init);
+     }
+ 
+     public static function getAvailableDrivers(): array
+     {
+         return array_values(array_unique(array_merge(parent::getAvailableDrivers(), ['mysql'])));
+     }
+ 
+     public function rawExec(string $sql): int|false
+     {
+         return parent::exec($sql);
+     }
+ 
+     public function rawQuery(string $sql): PDOStatement|false
+     {
+         return parent::query($sql);
+     }
+ 
+     public function rawPrepare(string $sql): PDOStatement|false
+     {
+         return parent::prepare($sql);
+     }
+ 
+     public function exec(string $statement): int|false
+     {
+         if (!$this->athMy) return parent::exec($statement);
+         try {
+             return AthMy::runList($this, AthMy::translate($statement));
+         } catch (PDOException $e) {
+             throw AthMy::mapPdo($e);
+         }
+     }
+ 
+     public function query(string $query, ?int $fetchMode = null, mixed ...$fetchModeArgs): PDOStatement|false
+     {
+         if (!$this->athMy) return $fetchMode === null ? parent::query($query) : parent::query($query, $fetchMode, ...$fetchModeArgs);
+         try {
+             $list = AthMy::translate($query);
+             if (!$list) $list = [AthMy::NOOP];
+             $main = array_shift($list);
+             $st = $fetchMode === null ? parent::query($main) : parent::query($main, $fetchMode, ...$fetchModeArgs);
+             if ($st instanceof AthStmt) $st->athInit($this, $main);
+             if ($list) AthMy::runList($this, $list);
+             return $st;
+         } catch (PDOException $e) {
+             throw AthMy::mapPdo($e);
+         }
+     }
+ 
+     public function prepare(string $query, array $options = []): PDOStatement|false
+     {
+         if (!$this->athMy) return parent::prepare($query, $options);
+         try {
+             $list = AthMy::translate($query);
+             if (!$list) $list = [AthMy::NOOP];
+             $main = array_shift($list);
+             $st = parent::prepare($main, $options);
+             if ($st instanceof AthStmt) $st->athInit($this, $main, $list);
+             return $st;
+         } catch (PDOException $e) {
+             throw AthMy::mapPdo($e);
+         }
+     }
+ 
+     public function quote(string $string, int $type = PDO::PARAM_STR): string|false
+     {
+         if (!$this->athMy) return parent::quote($string, $type);
+         return "'" . AthMy::escape($string) . "'";
+     }
+ 
+     public function getAttribute(int $attribute): mixed
+     {
+         if ($this->athMy) {
+             if ($attribute === PDO::ATTR_DRIVER_NAME) return 'mysql';
+             if ($attribute === PDO::ATTR_SERVER_VERSION) return '8.0.36-athera';
+             if ($attribute === PDO::ATTR_CLIENT_VERSION) return 'mysqlnd 8.3';
+         }
+         return parent::getAttribute($attribute);
+     }
+ }
+ 
+ foreach ([
+     'MYSQLI_ASSOC' => 1, 'MYSQLI_NUM' => 2, 'MYSQLI_BOTH' => 3, 'MYSQLI_STORE_RESULT' => 0, 'MYSQLI_USE_RESULT' => 1, 'MYSQLI_ASYNC' => 8,
+     'MYSQLI_REPORT_OFF' => 0, 'MYSQLI_REPORT_ERROR' => 1, 'MYSQLI_REPORT_STRICT' => 2, 'MYSQLI_REPORT_INDEX' => 4, 'MYSQLI_REPORT_ALL' => 255,
+     'MYSQLI_OPT_CONNECT_TIMEOUT' => 0, 'MYSQLI_OPT_LOCAL_INFILE' => 8, 'MYSQLI_INIT_COMMAND' => 3, 'MYSQLI_OPT_INT_AND_FLOAT_NATIVE' => 201,
+     'MYSQLI_SET_CHARSET_NAME' => 7, 'MYSQLI_CLIENT_SSL' => 2048, 'MYSQLI_CLIENT_COMPRESS' => 32, 'MYSQLI_CLIENT_INTERACTIVE' => 1024, 'MYSQLI_CLIENT_FOUND_ROWS' => 2,
+     'MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT' => 1, 'MYSQLI_TRANS_START_READ_WRITE' => 2, 'MYSQLI_TRANS_START_READ_ONLY' => 4,
+     'MYSQLI_TYPE_DECIMAL' => 0, 'MYSQLI_TYPE_TINY' => 1, 'MYSQLI_TYPE_SHORT' => 2, 'MYSQLI_TYPE_LONG' => 3, 'MYSQLI_TYPE_FLOAT' => 4, 'MYSQLI_TYPE_DOUBLE' => 5,
+     'MYSQLI_TYPE_NULL' => 6, 'MYSQLI_TYPE_TIMESTAMP' => 7, 'MYSQLI_TYPE_LONGLONG' => 8, 'MYSQLI_TYPE_INT24' => 9, 'MYSQLI_TYPE_DATE' => 10, 'MYSQLI_TYPE_TIME' => 11,
+     'MYSQLI_TYPE_DATETIME' => 12, 'MYSQLI_TYPE_YEAR' => 13, 'MYSQLI_TYPE_NEWDECIMAL' => 246, 'MYSQLI_TYPE_BLOB' => 252, 'MYSQLI_TYPE_VAR_STRING' => 253, 'MYSQLI_TYPE_STRING' => 254
+ ] as $ath_name => $ath_value) {
+     if (!defined($ath_name)) define($ath_name, $ath_value);
+ }
+ 
+ function ath_extension_loaded($name)
+ {
+     return in_array(strtolower((string)$name), ['mysqli', 'pdo_mysql', 'mysqlnd'], true) ? true : extension_loaded($name);
+ }
+ 
+ class mysqli_sql_exception extends RuntimeException
+ {
+     protected string $sqlstate = '00000';
+ 
+     public function getSqlState(): string
+     {
+         return $this->sqlstate;
+     }
+ 
+     public function athState(string $state): void
+     {
+         $this->sqlstate = $state;
+     }
+ }
+ 
+ final class AthMyi
+ {
+     public static function fail($obj, PDOException $e, string $where)
+     {
+         $e = AthMy::mapPdo($e);
+         $info = (isset($e->errorInfo[1]) && $e->errorInfo[1] !== null) ? $e->errorInfo : ['HY000', 1105, $e->getMessage()];
+         $obj->errno = (int)$info[1];
+         $obj->error = (string)$info[2];
+         $obj->sqlstate = (string)$info[0];
+         $obj->error_list = [['errno' => $obj->errno, 'sqlstate' => $obj->sqlstate, 'error' => $obj->error]];
+         if (AthMy::$report & 2) {
+             $x = new mysqli_sql_exception($obj->error, $obj->errno);
+             $x->athState($obj->sqlstate);
+             throw $x;
+         }
+         if (AthMy::$report & 1) trigger_error($where . '(): ' . $obj->error, E_USER_WARNING);
+         return false;
+     }
+ 
+     public static function clear($obj): void
+     {
+         $obj->errno = 0;
+         $obj->error = '';
+         $obj->sqlstate = '00000';
+         $obj->error_list = [];
+     }
+ 
+     public static function open($db): AthPDO
+     {
+         return new AthPDO('mysql:dbname=' . (($db === null || $db === '') ? 'default' : $db));
+     }
+ 
+     public static function strings(array $row): array
+     {
+         foreach ($row as $k => $v) {
+             if ($v !== null && !is_string($v)) $row[$k] = (string)$v;
+         }
+         return $row;
+     }
+ }
+ 
+ class mysqli_result implements IteratorAggregate
+ {
+     public $current_field = 0;
+     public $field_count = 0;
+     public $lengths = null;
+     public $num_rows = 0;
+     public $type = 0;
+     private $names = [];
+     private $rows = [];
+     private $pos = 0;
+ 
+     public function __construct($source = null, bool $strings = true)
+     {
+         if ($source instanceof PDOStatement) {
+             $names = [];
+             for ($i = 0, $n = $source->columnCount(); $i < $n; $i++) {
+                 $meta = $source->getColumnMeta($i);
+                 $names[] = is_array($meta) && isset($meta['name']) ? $meta['name'] : (string)$i;
+             }
+             $this->athLoad($names, $source->fetchAll(PDO::FETCH_NUM), $strings);
+         }
+     }
+ 
+     public function athLoad(array $names, array $rows, bool $strings): void
+     {
+         $this->names = $names;
+         $this->rows = $strings ? array_map([AthMyi::class, 'strings'], $rows) : $rows;
+         $this->field_count = count($names);
+         $this->num_rows = count($rows);
+         $this->pos = 0;
+     }
+ 
+     private function assoc(array $row): array
+     {
+         $out = [];
+         foreach ($this->names as $i => $name) $out[$name] = $row[$i] ?? null;
+         return $out;
+     }
+ 
+     private function both(array $row): array
+     {
+         $out = [];
+         foreach ($this->names as $i => $name) {
+             $out[$i] = $row[$i] ?? null;
+             $out[$name] = $row[$i] ?? null;
+         }
+         return $out;
+     }
+ 
+     private function next(): ?array
+     {
+         if ($this->pos >= count($this->rows)) return null;
+         $row = $this->rows[$this->pos++];
+         $this->lengths = array_map(function ($v) { return $v === null ? 0 : strlen((string)$v); }, $row);
+         return $row;
+     }
+ 
+     public function fetch_assoc(): array|null|false
+     {
+         $row = $this->next();
+         return $row === null ? null : $this->assoc($row);
+     }
+ 
+     public function fetch_row(): array|null|false
+     {
+         return $this->next();
+     }
+ 
+     public function fetch_array(int $mode = MYSQLI_BOTH): array|null|false
+     {
+         $row = $this->next();
+         if ($row === null) return null;
+         if ($mode === MYSQLI_ASSOC) return $this->assoc($row);
+         if ($mode === MYSQLI_NUM) return $row;
+         return $this->both($row);
+     }
+ 
+     public function fetch_object(string $class = 'stdClass', array $constructor_args = []): object|null|false
+     {
+         $row = $this->next();
+         if ($row === null) return null;
+         $obj = $class === 'stdClass' ? new stdClass() : new $class(...$constructor_args);
+         foreach ($this->assoc($row) as $k => $v) $obj->$k = $v;
+         return $obj;
+     }
+ 
+     public function fetch_all(int $mode = MYSQLI_NUM): array
+     {
+         $out = [];
+         while (($row = $this->next()) !== null) {
+             $out[] = $mode === MYSQLI_ASSOC ? $this->assoc($row) : ($mode === MYSQLI_BOTH ? $this->both($row) : $row);
+         }
+         return $out;
+     }
+ 
+     public function fetch_column(int $column = 0): string|int|float|null|false
+     {
+         $row = $this->next();
+         if ($row === null) return false;
+         return $row[$column] ?? null;
+     }
+ 
+     private function field(int $i): object
+     {
+         $o = new stdClass();
+         $o->name = $this->names[$i];
+         $o->orgname = $this->names[$i];
+         $o->table = '';
+         $o->orgtable = '';
+         $o->def = '';
+         $o->db = AthMy::$db;
+         $o->catalog = 'def';
+         $o->max_length = 0;
+         $o->length = 0;
+         $o->charsetnr = 255;
+         $o->flags = 0;
+         $o->type = MYSQLI_TYPE_VAR_STRING;
+         $o->decimals = 0;
+         return $o;
+     }
+ 
+     public function fetch_field(): object|false
+     {
+         if ($this->current_field >= count($this->names)) return false;
+         return $this->field($this->current_field++);
+     }
+ 
+     public function fetch_fields(): array
+     {
+         $out = [];
+         foreach ($this->names as $i => $n) $out[] = $this->field($i);
+         return $out;
+     }
+ 
+     public function fetch_field_direct(int $index): object|false
+     {
+         return isset($this->names[$index]) ? $this->field($index) : false;
+     }
+ 
+     public function field_seek(int $index): bool
+     {
+         $this->current_field = $index;
+         return true;
+     }
+ 
+     public function data_seek(int $offset): bool
+     {
+         if ($offset < 0 || $offset > count($this->rows)) return false;
+         $this->pos = $offset;
+         return true;
+     }
+ 
+     public function free(): void
+     {
+         $this->rows = [];
+         $this->pos = 0;
+     }
+ 
+     public function close(): void
+     {
+         $this->free();
+     }
+ 
+     public function free_result(): void
+     {
+         $this->free();
+     }
+ 
+     public function getIterator(): Iterator
+     {
+         $this->pos = 0;
+         return (function () {
+             while (($row = $this->next()) !== null) yield $this->assoc($row);
+         })();
+     }
+ }
+ 
+ class mysqli_stmt
+ {
+     public $affected_rows = 0;
+     public $insert_id = 0;
+     public $num_rows = 0;
+     public $param_count = 0;
+     public $field_count = 0;
+     public $errno = 0;
+     public $error = '';
+     public $error_list = [];
+     public $sqlstate = '00000';
+     public $id = 1;
+     private $conn = null;
+     private $st = null;
+     private $sql = '';
+     private $types = '';
+     private $refs = [];
+     private $out = [];
+     private $names = [];
+     private $rows = null;
+     private $pos = 0;
+     private $isInsert = false;
+ 
+     public function __construct($mysqli = null, $query = null)
+     {
+         $this->conn = $mysqli;
+         if ($query !== null) $this->prepare($query);
+     }
+ 
+     public function prepare(string $query): bool
+     {
+         AthMyi::clear($this);
+         try {
+             $list = AthMy::translate($query);
+             if (!$list) $list = [AthMy::NOOP];
+             $main = array_shift($list);
+             $this->st = $this->conn->athPdo()->rawPrepare($main);
+             if ($this->st instanceof AthStmt) $this->st->athInit($this->conn->athPdo(), $main, $list);
+             $this->sql = $main;
+             $lits = [];
+             $this->param_count = substr_count(AthMy::mask($main, $lits), '?');
+             $this->isInsert = (bool)preg_match('/^\s*(?:INSERT|REPLACE)\b/i', $main);
+             return true;
+         } catch (PDOException $e) {
+             return AthMyi::fail($this, $e, 'mysqli::prepare') !== false;
+         }
+     }
+ 
+     public function bind_param(string $types, mixed &...$vars): bool
+     {
+         $this->types = $types;
+         $this->refs = [];
+         foreach ($vars as $i => &$v) $this->refs[$i] = &$v;
+         unset($v);
+         return true;
+     }
+ 
+     public function bind_result(mixed &...$vars): bool
+     {
+         $this->out = [];
+         foreach ($vars as $i => &$v) $this->out[$i] = &$v;
+         unset($v);
+         return true;
+     }
+ 
+     public function execute(?array $params = null): bool
+     {
+         AthMyi::clear($this);
+         try {
+             $i = 1;
+             if ($params !== null) {
+                 foreach (array_values($params) as $v) {
+                     $this->st->bindValue($i++, $v, $v === null ? PDO::PARAM_NULL : (is_int($v) ? PDO::PARAM_INT : PDO::PARAM_STR));
+                 }
+             } else {
+                 foreach ($this->refs as $k => $v) {
+                     $t = isset($this->types[$k]) ? $this->types[$k] : 's';
+                     if ($v === null) $this->st->bindValue($i, null, PDO::PARAM_NULL);
+                     elseif ($t === 'i') $this->st->bindValue($i, (int)$v, PDO::PARAM_INT);
+                     elseif ($t === 'b') $this->st->bindValue($i, (string)$v, PDO::PARAM_LOB);
+                     else $this->st->bindValue($i, $t === 'd' ? (float)$v : (string)$v, PDO::PARAM_STR);
+                     $i++;
+                 }
+             }
+             $this->st->execute();
+             $this->rows = null;
+             $this->pos = 0;
+             $this->num_rows = 0;
+             $this->field_count = $this->st->columnCount();
+             if ($this->field_count > 0) {
+                 $this->names = [];
+                 for ($c = 0; $c < $this->field_count; $c++) {
+                     $meta = $this->st->getColumnMeta($c);
+                     $this->names[] = is_array($meta) && isset($meta['name']) ? $meta['name'] : (string)$c;
+                 }
+                 $this->rows = $this->st->fetchAll(PDO::FETCH_NUM);
+                 $this->affected_rows = count($this->rows);
+             } else {
+                 $this->affected_rows = $this->st instanceof AthStmt ? $this->st->athChanges() : $this->st->rowCount();
+                 $this->insert_id = $this->isInsert && $this->affected_rows > 0 ? (int)$this->conn->athPdo()->lastInsertId() : 0;
+                 $this->conn->athSetResult($this->affected_rows, $this->insert_id);
+             }
+             return true;
+         } catch (PDOException $e) {
+             return AthMyi::fail($this, $e, 'mysqli_stmt::execute') !== false;
+         }
+     }
+ 
+     public function fetch(): ?bool
+     {
+         if ($this->rows === null || $this->pos >= count($this->rows)) return null;
+         $row = $this->rows[$this->pos++];
+         foreach ($this->out as $i => &$ref) $ref = $row[$i] ?? null;
+         unset($ref);
+         return true;
+     }
+ 
+     public function get_result(): mysqli_result|false
+     {
+         if ($this->rows === null) return false;
+         $r = new mysqli_result();
+         $r->athLoad($this->names, $this->rows, false);
+         $this->num_rows = count($this->rows);
+         return $r;
+     }
+ 
+     public function result_metadata(): mysqli_result|false
+     {
+         if ($this->st === null || $this->st->columnCount() === 0) return false;
+         $names = [];
+         for ($c = 0, $n = $this->st->columnCount(); $c < $n; $c++) {
+             $meta = $this->st->getColumnMeta($c);
+             $names[] = is_array($meta) && isset($meta['name']) ? $meta['name'] : (string)$c;
+         }
+         $r = new mysqli_result();
+         $r->athLoad($names, [], false);
+         return $r;
+     }
+ 
+     public function store_result(): bool
+     {
+         $this->num_rows = $this->rows === null ? 0 : count($this->rows);
+         return true;
+     }
+ 
+     public function data_seek(int $offset): void
+     {
+         $this->pos = max(0, $offset);
+     }
+ 
+     public function free_result(): void
+     {
+         $this->rows = null;
+         $this->pos = 0;
+     }
+ 
+     public function reset(): bool
+     {
+         $this->free_result();
+         return true;
+     }
+ 
+     public function close(): bool
+     {
+         $this->free_result();
+         return true;
+     }
+ 
+     public function attr_get(int $attribute): int|false
+     {
+         return 0;
+     }
+ 
+     public function attr_set(int $attribute, int $value): bool
+     {
+         return true;
+     }
+ 
+     public function more_results(): bool
+     {
+         return false;
+     }
+ 
+     public function next_result(): bool
+     {
+         return false;
+     }
+ 
+     public function send_long_data(int $param_num, string $data): bool
+     {
+         return true;
+     }
+ }
+ 
+ class mysqli
+ {
+     public $affected_rows = 0;
+     public $client_info = 'mysqlnd 8.3';
+     public $client_version = 80333;
+     public $connect_errno = 0;
+     public $connect_error = null;
+     public $errno = 0;
+     public $error = '';
+     public $error_list = [];
+     public $field_count = 0;
+     public $host_info = 'localhost via Athera';
+     public $info = null;
+     public $insert_id = 0;
+     public $protocol_version = 10;
+     public $server_info = '8.0.36-athera';
+     public $server_version = 80036;
+     public $sqlstate = '00000';
+     public $thread_id = 1;
+     public $warning_count = 0;
+     private $ath = null;
+     private $last = null;
+     private $queue = [];
+ 
+     public function __construct($hostname = null, $username = null, $password = null, $database = null, $port = null, $socket = null)
+     {
+         if ($hostname !== null || $database !== null) $this->real_connect($hostname, $username, $password, $database, $port, $socket);
+     }
+ 
+     public function real_connect($hostname = null, $username = null, $password = null, $database = null, $port = null, $socket = null, $flags = 0): bool
+     {
+         $this->ath = AthMyi::open($database);
+         return true;
+     }
+ 
+     public function athPdo(): AthPDO
+     {
+         if ($this->ath === null) throw new Error('mysqli object is already closed');
+         return $this->ath;
+     }
+ 
+     public function athSetResult(int $affected, $insertId): void
+     {
+         $this->affected_rows = $affected;
+         $this->insert_id = $insertId;
+     }
+ 
+     public function query(string $query, int $result_mode = MYSQLI_STORE_RESULT): mysqli_result|bool
+     {
+         AthMyi::clear($this);
+         $pdo = $this->athPdo();
+         try {
+             $list = AthMy::translate($query);
+             if (!$list) return true;
+             if (AthMy::isQuery($query)) {
+                 $main = array_shift($list);
+                 $st = $pdo->rawQuery($main);
+                 if ($list) AthMy::runList($pdo, $list);
+                 $res = new mysqli_result($st, true);
+                 $this->affected_rows = $res->num_rows;
+                 $this->field_count = $res->field_count;
+                 return $res;
+             }
+             $this->affected_rows = AthMy::runList($pdo, $list);
+             $this->field_count = 0;
+             $this->insert_id = preg_match('/^(?:INSERT|REPLACE)$/', AthMy::kind($query)) && $this->affected_rows > 0 ? (int)$pdo->lastInsertId() : 0;
+             return true;
+         } catch (PDOException $e) {
+             return AthMyi::fail($this, $e, 'mysqli::query');
+         }
+     }
+ 
+     public function real_query(string $query): bool
+     {
+         $this->last = $this->query($query);
+         return $this->last !== false;
+     }
+ 
+     public function store_result(int $mode = 0): mysqli_result|false
+     {
+         return $this->last instanceof mysqli_result ? $this->last : false;
+     }
+ 
+     public function use_result(): mysqli_result|false
+     {
+         return $this->store_result();
+     }
+ 
+     public function multi_query(string $query): bool
+     {
+         $this->queue = AthMy::translate($query);
+         $this->last = null;
+         return $this->queue ? $this->step() : true;
+     }
+ 
+     private function step(): bool
+     {
+         AthMyi::clear($this);
+         $q = array_shift($this->queue);
+         $pdo = $this->athPdo();
+         try {
+             if (AthMy::isQuery($q)) {
+                 $this->last = new mysqli_result($pdo->rawQuery($q), true);
+             } else {
+                 $this->affected_rows = AthMy::runList($pdo, [$q]);
+                 $this->last = null;
+             }
+             return true;
+         } catch (PDOException $e) {
+             $this->queue = [];
+             return AthMyi::fail($this, $e, 'mysqli::multi_query') !== false;
+         }
+     }
+ 
+     public function more_results(): bool
+     {
+         return count($this->queue) > 0;
+     }
+ 
+     public function next_result(): bool
+     {
+         return $this->queue ? $this->step() : false;
+     }
+ 
+     public function prepare(string $query): mysqli_stmt|false
+     {
+         AthMyi::clear($this);
+         $stmt = new mysqli_stmt($this);
+         if (!$stmt->prepare($query)) return false;
+         return $stmt;
+     }
+ 
+     public function execute_query(string $query, ?array $params = null): mysqli_result|bool
+     {
+         $stmt = $this->prepare($query);
+         if ($stmt === false) return false;
+         if (!$stmt->execute($params)) return false;
+         $res = $stmt->get_result();
+         return $res === false ? true : $res;
+     }
+ 
+     public function real_escape_string(string $string): string
+     {
+         return AthMy::escape($string);
+     }
+ 
+     public function escape_string(string $string): string
+     {
+         return AthMy::escape($string);
+     }
+ 
+     public function select_db(string $database): bool
+     {
+         $this->ath = AthMyi::open($database);
+         return true;
+     }
+ 
+     public function set_charset(string $charset): bool
+     {
+         return true;
+     }
+ 
+     public function character_set_name(): string
+     {
+         return 'utf8mb4';
+     }
+ 
+     public function get_charset(): object
+     {
+         $o = new stdClass();
+         $o->charset = 'utf8mb4';
+         $o->collation = 'utf8mb4_general_ci';
+         $o->dir = '';
+         $o->min_length = 1;
+         $o->max_length = 4;
+         $o->number = 45;
+         $o->state = 1;
+         $o->comment = '';
+         return $o;
+     }
+ 
+     public function begin_transaction(int $flags = 0, ?string $name = null): bool
+     {
+         $pdo = $this->athPdo();
+         if (!$pdo->inTransaction()) $pdo->beginTransaction();
+         return true;
+     }
+ 
+     public function commit(int $flags = 0, ?string $name = null): bool
+     {
+         $pdo = $this->athPdo();
+         if ($pdo->inTransaction()) $pdo->commit();
+         return true;
+     }
+ 
+     public function rollback(int $flags = 0, ?string $name = null): bool
+     {
+         $pdo = $this->athPdo();
+         if ($pdo->inTransaction()) $pdo->rollBack();
+         return true;
+     }
+ 
+     public function autocommit(bool $enable): bool
+     {
+         $pdo = $this->athPdo();
+         if ($enable && $pdo->inTransaction()) $pdo->commit();
+         if (!$enable && !$pdo->inTransaction()) $pdo->beginTransaction();
+         return true;
+     }
+ 
+     public function ping(): bool
+     {
+         return $this->ath !== null;
+     }
+ 
+     public function close(): bool
+     {
+         $this->ath = null;
+         return true;
+     }
+ 
+     public function options(int $option, $value): bool
+     {
+         return true;
+     }
+ 
+     public function ssl_set($key = null, $certificate = null, $ca = null, $capath = null, $cipher = null): bool
+     {
+         return true;
+     }
+ 
+     public function get_server_info(): string
+     {
+         return $this->server_info;
+     }
+ 
+     public function get_connection_stats(): array|false
+     {
+         return [];
+     }
+ 
+     public function stat(): string|false
+     {
+         return 'Uptime: 1  Threads: 1';
+     }
+ 
+     public function get_warnings(): mixed
+     {
+         return false;
+     }
+ 
+     public function kill(int $process_id): bool
+     {
+         return true;
+     }
+ }
+ 
+ function mysqli_report(int $flags): bool { AthMy::$report = $flags; return true; }
+ function mysqli_init(): mysqli { return new mysqli(); }
+ function mysqli_connect($hostname = null, $username = null, $password = null, $database = null, $port = null, $socket = null) { return new mysqli($hostname ?? 'localhost', $username, $password, $database, $port, $socket); }
+ function mysqli_real_connect(mysqli $mysql, $hostname = null, $username = null, $password = null, $database = null, $port = null, $socket = null, $flags = 0): bool { return $mysql->real_connect($hostname, $username, $password, $database, $port, $socket, $flags); }
+ function mysqli_connect_error(): ?string { return null; }
+ function mysqli_connect_errno(): int { return 0; }
+ function mysqli_query(mysqli $mysql, string $query, int $result_mode = MYSQLI_STORE_RESULT) { return $mysql->query($query, $result_mode); }
+ function mysqli_real_query(mysqli $mysql, string $query): bool { return $mysql->real_query($query); }
+ function mysqli_multi_query(mysqli $mysql, string $query): bool { return $mysql->multi_query($query); }
+ function mysqli_next_result(mysqli $mysql): bool { return $mysql->next_result(); }
+ function mysqli_more_results(mysqli $mysql): bool { return $mysql->more_results(); }
+ function mysqli_store_result(mysqli $mysql, int $mode = 0) { return $mysql->store_result($mode); }
+ function mysqli_use_result(mysqli $mysql) { return $mysql->use_result(); }
+ function mysqli_error(mysqli $mysql): string { return $mysql->error; }
+ function mysqli_errno(mysqli $mysql): int { return $mysql->errno; }
+ function mysqli_sqlstate(mysqli $mysql): string { return $mysql->sqlstate; }
+ function mysqli_error_list(mysqli $mysql): array { return $mysql->error_list; }
+ function mysqli_insert_id(mysqli $mysql): int|string { return $mysql->insert_id; }
+ function mysqli_affected_rows(mysqli $mysql): int|string { return $mysql->affected_rows; }
+ function mysqli_field_count(mysqli $mysql): int { return $mysql->field_count; }
+ function mysqli_close(mysqli $mysql): bool { return $mysql->close(); }
+ function mysqli_ping(mysqli $mysql): bool { return $mysql->ping(); }
+ function mysqli_select_db(mysqli $mysql, string $database): bool { return $mysql->select_db($database); }
+ function mysqli_set_charset(mysqli $mysql, string $charset): bool { return $mysql->set_charset($charset); }
+ function mysqli_character_set_name(mysqli $mysql): string { return $mysql->character_set_name(); }
+ function mysqli_real_escape_string(mysqli $mysql, string $string): string { return $mysql->real_escape_string($string); }
+ function mysqli_escape_string(mysqli $mysql, string $string): string { return $mysql->real_escape_string($string); }
+ function mysqli_begin_transaction(mysqli $mysql, int $flags = 0, ?string $name = null): bool { return $mysql->begin_transaction($flags, $name); }
+ function mysqli_commit(mysqli $mysql, int $flags = 0, ?string $name = null): bool { return $mysql->commit($flags, $name); }
+ function mysqli_rollback(mysqli $mysql, int $flags = 0, ?string $name = null): bool { return $mysql->rollback($flags, $name); }
+ function mysqli_autocommit(mysqli $mysql, bool $enable): bool { return $mysql->autocommit($enable); }
+ function mysqli_get_server_info(mysqli $mysql): string { return $mysql->get_server_info(); }
+ function mysqli_get_client_info(?mysqli $mysql = null): string { return 'mysqlnd 8.3'; }
+ function mysqli_options(mysqli $mysql, int $option, $value): bool { return true; }
+ function mysqli_ssl_set(mysqli $mysql, $key = null, $certificate = null, $ca = null, $capath = null, $cipher = null): bool { return true; }
+ function mysqli_stat(mysqli $mysql) { return $mysql->stat(); }
+ function mysqli_thread_id(mysqli $mysql): int { return 1; }
+ function mysqli_warning_count(mysqli $mysql): int { return 0; }
+ function mysqli_info(mysqli $mysql): ?string { return null; }
+ function mysqli_prepare(mysqli $mysql, string $query) { return $mysql->prepare($query); }
+ function mysqli_execute_query(mysqli $mysql, string $query, ?array $params = null) { return $mysql->execute_query($query, $params); }
+ function mysqli_fetch_assoc(mysqli_result $result) { return $result->fetch_assoc(); }
+ function mysqli_fetch_row(mysqli_result $result) { return $result->fetch_row(); }
+ function mysqli_fetch_array(mysqli_result $result, int $mode = MYSQLI_BOTH) { return $result->fetch_array($mode); }
+ function mysqli_fetch_object(mysqli_result $result, string $class = 'stdClass', array $constructor_args = []) { return $result->fetch_object($class, $constructor_args); }
+ function mysqli_fetch_all(mysqli_result $result, int $mode = MYSQLI_NUM): array { return $result->fetch_all($mode); }
+ function mysqli_fetch_column(mysqli_result $result, int $column = 0) { return $result->fetch_column($column); }
+ function mysqli_fetch_field(mysqli_result $result) { return $result->fetch_field(); }
+ function mysqli_fetch_fields(mysqli_result $result): array { return $result->fetch_fields(); }
+ function mysqli_fetch_field_direct(mysqli_result $result, int $index) { return $result->fetch_field_direct($index); }
+ function mysqli_field_seek(mysqli_result $result, int $index): bool { return $result->field_seek($index); }
+ function mysqli_data_seek(mysqli_result $result, int $offset): bool { return $result->data_seek($offset); }
+ function mysqli_num_rows(mysqli_result $result): int|string { return $result->num_rows; }
+ function mysqli_num_fields(mysqli_result $result): int { return $result->field_count; }
+ function mysqli_free_result(mysqli_result $result): void { $result->free(); }
+ function mysqli_stmt_bind_param(mysqli_stmt $statement, string $types, mixed &...$vars): bool { return $statement->bind_param($types, ...$vars); }
+ function mysqli_stmt_bind_result(mysqli_stmt $statement, mixed &...$vars): bool { return $statement->bind_result(...$vars); }
+ function mysqli_stmt_execute(mysqli_stmt $statement, ?array $params = null): bool { return $statement->execute($params); }
+ function mysqli_stmt_fetch(mysqli_stmt $statement): ?bool { return $statement->fetch(); }
+ function mysqli_stmt_get_result(mysqli_stmt $statement) { return $statement->get_result(); }
+ function mysqli_stmt_store_result(mysqli_stmt $statement): bool { return $statement->store_result(); }
+ function mysqli_stmt_num_rows(mysqli_stmt $statement): int|string { return $statement->num_rows; }
+ function mysqli_stmt_affected_rows(mysqli_stmt $statement): int|string { return $statement->affected_rows; }
+ function mysqli_stmt_insert_id(mysqli_stmt $statement): int|string { return $statement->insert_id; }
+ function mysqli_stmt_close(mysqli_stmt $statement): bool { return $statement->close(); }
+ function mysqli_stmt_reset(mysqli_stmt $statement): bool { return $statement->reset(); }
+ function mysqli_stmt_free_result(mysqli_stmt $statement): void { $statement->free_result(); }
+ function mysqli_stmt_error(mysqli_stmt $statement): string { return $statement->error; }
+ function mysqli_stmt_errno(mysqli_stmt $statement): int { return $statement->errno; }
+ function mysqli_stmt_param_count(mysqli_stmt $statement): int { return $statement->param_count; }
+ function mysqli_stmt_field_count(mysqli_stmt $statement): int { return $statement->field_count; }
+ function mysqli_stmt_data_seek(mysqli_stmt $statement, int $offset): void { $statement->data_seek($offset); }
+ function mysqli_stmt_result_metadata(mysqli_stmt $statement) { return $statement->result_metadata(); }
+ 
version.js Modified +1 -1
- (window.Athera = window.Athera || {}).version = "1.3.1";
+ (window.Athera = window.Athera || {}).version = "1.3.2";
  
version.txt Modified +1 -1
- 1.3.1
+ 1.3.2