{
  "version": 3,
  "sources": ["../src/modules/dom.js"],
  "sourcesContent": ["// zelvior-runtime/dom -- batched DOM read/write scheduling.\n// Zero dependency on core zelvior.js. ESM source of truth; bundled by build.mjs.\n//\n// Real justification (not speculative): interleaved DOM reads and writes\n// from independent call sites force the browser to run layout synchronously\n// between each read, once per interleaving (\"layout thrashing\"). Separating\n// all reads for a frame from all writes for that frame -- the pattern this\n// module implements -- is a well-established fix (see: fastdom, and the\n// \"batch your DOM reads and writes\" guidance in browser rendering-\n// performance documentation). This is the one DOM-performance utility in\n// this runtime with a clear mechanism, not an unverified guess.\n\nvar hasRaf = typeof window !== 'undefined' && typeof window.requestAnimationFrame === 'function';\n\nvar reads = [];\nvar writes = [];\nvar scheduled = false;\nvar nextId = 1;\n\nfunction flush() {\n  scheduled = false;\n  // Snapshot and clear before running -- a read/write scheduled from\n  // inside a callback should land in the *next* frame, not re-enter this\n  // flush and potentially loop.\n  var r = reads; reads = [];\n  var w = writes; writes = [];\n  for (var i = 0; i < r.length; i++) { if (r[i]) safeRun(r[i][1]); }\n  for (var j = 0; j < w.length; j++) { if (w[j]) safeRun(w[j][1]); }\n}\n\nfunction safeRun(fn) {\n  try {\n    fn();\n  } catch (e) {\n    // Reporting the error must never itself be able to abort the flush loop\n    // -- if console.error throws (unusual, but not impossible in some\n    // embedded/sandboxed environments), swallow that too rather than let it\n    // skip every remaining queued callback.\n    try { if (typeof console !== 'undefined' && console.error) console.error(e); } catch (e2) {}\n  }\n}\n\nfunction ensureScheduled() {\n  if (scheduled) return;\n  scheduled = true;\n  if (hasRaf) requestAnimationFrame(flush); else setTimeout(flush, 16);\n}\n\n/**\n * Queue `fn` to run in this frame's read phase (before any write-phase\n * callbacks queued this frame). Use for DOM reads (getBoundingClientRect,\n * offsetWidth, etc.) that would otherwise force a synchronous layout if\n * interleaved with writes elsewhere in the same frame.\n * Returns a numeric id usable with clear().\n */\nexport function read(fn) {\n  var id = nextId++;\n  reads.push([id, fn]);\n  ensureScheduled();\n  return id;\n}\n\n/**\n * Queue `fn` to run in this frame's write phase (after every queued read\n * this frame has run). Use for DOM writes (style/attribute/class changes).\n * Returns a numeric id usable with clear().\n */\nexport function write(fn) {\n  var id = nextId++;\n  writes.push([id, fn]);\n  ensureScheduled();\n  return id;\n}\n\n/** Cancel a previously queued read or write by the id returned from read()/write(). */\nexport function clear(id) {\n  for (var i = 0; i < reads.length; i++) { if (reads[i] && reads[i][0] === id) { reads[i] = null; return; } }\n  for (var j = 0; j < writes.length; j++) { if (writes[j] && writes[j][0] === id) { writes[j] = null; return; } }\n}\n"],
  "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,WAAAE,EAAA,SAAAC,EAAA,UAAAC,IAAA,eAAAC,EAAAL,GAYA,IAAIM,EAAS,OAAO,QAAW,aAAe,OAAO,OAAO,uBAA0B,WAElFC,EAAQ,CAAC,EACTC,EAAS,CAAC,EACVC,EAAY,GACZC,EAAS,EAEb,SAASC,GAAQ,CACfF,EAAY,GAIZ,IAAI,EAAIF,EAAOA,EAAQ,CAAC,EACxB,IAAIK,EAAIJ,EAAQA,EAAS,CAAC,EAC1B,QAASK,EAAI,EAAGA,EAAI,EAAE,OAAQA,IAAW,EAAEA,CAAC,GAAGC,EAAQ,EAAED,CAAC,EAAE,CAAC,CAAC,EAC9D,QAASE,EAAI,EAAGA,EAAIH,EAAE,OAAQG,IAAWH,EAAEG,CAAC,GAAGD,EAAQF,EAAEG,CAAC,EAAE,CAAC,CAAC,CAChE,CAEA,SAASD,EAAQE,EAAI,CACnB,GAAI,CACFA,EAAG,CACL,OAAS,EAAG,CAKV,GAAI,CAAM,OAAO,SAAY,aAAe,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAG,OAASC,EAAI,CAAC,CAC7F,CACF,CAEA,SAASC,GAAkB,CACrBT,IACJA,EAAY,GACRH,EAAQ,sBAAsBK,CAAK,EAAQ,WAAWA,EAAO,EAAE,EACrE,CASO,SAASR,EAAKa,EAAI,CACvB,IAAIG,EAAKT,IACT,OAAAH,EAAM,KAAK,CAACY,EAAIH,CAAE,CAAC,EACnBE,EAAgB,EACTC,CACT,CAOO,SAASf,EAAMY,EAAI,CACxB,IAAIG,EAAKT,IACT,OAAAF,EAAO,KAAK,CAACW,EAAIH,CAAE,CAAC,EACpBE,EAAgB,EACTC,CACT,CAGO,SAASjB,EAAMiB,EAAI,CACxB,QAASN,EAAI,EAAGA,EAAIN,EAAM,OAAQM,IAAO,GAAIN,EAAMM,CAAC,GAAKN,EAAMM,CAAC,EAAE,CAAC,IAAMM,EAAI,CAAEZ,EAAMM,CAAC,EAAI,KAAM,MAAQ,CACxG,QAASE,EAAI,EAAGA,EAAIP,EAAO,OAAQO,IAAO,GAAIP,EAAOO,CAAC,GAAKP,EAAOO,CAAC,EAAE,CAAC,IAAMI,EAAI,CAAEX,EAAOO,CAAC,EAAI,KAAM,MAAQ,CAC9G",
  "names": ["dom_exports", "__export", "clear", "read", "write", "__toCommonJS", "hasRaf", "reads", "writes", "scheduled", "nextId", "flush", "w", "i", "safeRun", "j", "fn", "e2", "ensureScheduled", "id"]
}
