"use strict"; // Source-preserving XML: parses into elements that remember where every attribute value and text // sits in the original string, so edits replace just those characters (comments, spacing, line // breaks, CP949 bytes — the text travels as latin1 — all stay as they were). After an edit the // document is re-parsed (UI files are small). const XmlDoc = (() => { const isName = (c) => /[A-Za-z0-9_:.\-]/.test(c); /** → { src, root, elements } ; element = { tag, attrs: [{ name, value, vs, ve, ns }], start, openEnd, selfClose, end, children, parent, textStart, textEnd } */ function parse(src) { const els = []; const stack = []; const warnings = []; let root = null; let i = 0; const n = src.length; const err = (msg) => { const line = src.slice(0, i).split("\n").length; throw new Error(`XML line ${line}: ${msg}`); }; while (i < n) { const lt = src.indexOf("<", i); if (lt < 0) break; const top = stack[stack.length - 1]; if (top && top.textStart === undefined && lt > i) { // text between tags (only kept for leaf elements such as