mesurer-solid 0.2.0-beta.0 → 0.2.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -14630,21 +14630,17 @@ function t_(e) {
14630
14630
  if (!Ru(e.fingerprint)) return null;
14631
14631
  let t = [];
14632
14632
  try {
14633
- t = D(e.selector).filter((t) => zu(t, e.fingerprint));
14633
+ t = D(e.selector);
14634
14634
  } catch {
14635
14635
  return null;
14636
14636
  }
14637
- if (t.length !== 1) return null;
14638
- if (!e.fingerprint.id && !e.fingerprint.testId) {
14639
- let n = [];
14640
- try {
14641
- n = D(e.fingerprint.tag).filter((t) => zu(t, e.fingerprint));
14642
- } catch {
14643
- return null;
14644
- }
14645
- if (n.length !== 1 || n[0] !== t[0]) return null;
14646
- }
14647
- return t[0] ?? null;
14637
+ let n = t.filter((t) => zu(t, e.fingerprint));
14638
+ if (t.length === 1 && n.length === 1) return n[0] ?? null;
14639
+ if (t.length !== 1 || e.fingerprint.id || e.fingerprint.testId) return null;
14640
+ let r = t[0];
14641
+ if (!r || r.localName !== e.fingerprint.tag) return null;
14642
+ let i = Tu(r), a = e.lastRect, o = Math.max(4, Math.max(a.width, a.height) * .05), s = Math.max(2, Math.max(a.width, a.height) * .03);
14643
+ return Math.abs(i.left - a.left) <= o && Math.abs(i.top - a.top) <= o && Math.abs(i.width - a.width) <= s && Math.abs(i.height - a.height) <= s ? r : null;
14648
14644
  }, j = (e, t) => {
14649
14645
  let n = T(e, t.id), r = y.get(n);
14650
14646
  if (r?.isConnected && E(r)) return r;
@@ -17836,7 +17832,7 @@ function Ty(e) {
17836
17832
  }
17837
17833
  //#endregion
17838
17834
  //#region src/version.ts
17839
- var Ey = "0.2.0-beta.0", Dy = Xf, Oy = Zf, ky = () => ({
17835
+ var Ey = "0.2.0-beta.2", Dy = Xf, Oy = Zf, ky = () => ({
17840
17836
  ...Ip(),
17841
17837
  version: Ey
17842
17838
  }), Ay = (e, t) => e.left <= t.left + t.width && e.left + e.width >= t.left && e.top <= t.top + t.height && e.top + e.height >= t.top, jy = (e) => {
@@ -18340,8 +18336,8 @@ var Xy = (e, t, n, r, i) => {
18340
18336
  evidence: t,
18341
18337
  id: n,
18342
18338
  label: r
18343
- });
18344
- function Qy(e) {
18339
+ }), Qy = (e, t) => Math.abs(e.left - t.left) < .01 && Math.abs(e.top - t.top) < .01 && Math.abs(e.width - t.width) < .01 && Math.abs(e.height - t.height) < .01;
18340
+ function $y(e) {
18345
18341
  let t = e.runtime.annotation(e.annotationId);
18346
18342
  if (!t) throw Error(`Mesurer annotation not found: ${e.annotationId}`);
18347
18343
  let n = Gy({
@@ -18375,12 +18371,13 @@ function Qy(e) {
18375
18371
  Xy(a, "guide", `${e.orientation} guide ${e.id}`, e.position, t.position);
18376
18372
  }
18377
18373
  for (let e of t.baseline.measurements) {
18378
- let t = n.visualContext.measurements.find((t) => t.id === e.id) ?? i.find((t) => t.id === e.id);
18379
- if (!t) {
18380
- Zy(a, "measurement", e.id, e.id);
18374
+ let r = n.visualContext.measurements.find((t) => t.id === e.id) ?? i.find((t) => t.id === e.id);
18375
+ if (!r) {
18376
+ let r = t.baseline.targets.find((t) => Qy(t.rect, e.rect));
18377
+ r && n.targets.some((e) => e.ref === r.id) || Zy(a, "measurement", e.id, e.id);
18381
18378
  continue;
18382
18379
  }
18383
- Xy(a, "measurement", `${e.id} width`, e.rect.width, t.rect.width), Xy(a, "measurement", `${e.id} height`, e.rect.height, t.rect.height);
18380
+ Xy(a, "measurement", `${e.id} width`, e.rect.width, r.rect.width), Xy(a, "measurement", `${e.id} height`, e.rect.height, r.rect.height);
18384
18381
  }
18385
18382
  for (let e of t.baseline.distances) {
18386
18383
  let t = n.visualContext.distances.find((t) => t.id === e.id) ?? r.heldDistances.find((t) => t.id === e.id);
@@ -18400,7 +18397,7 @@ function Qy(e) {
18400
18397
  changes: a
18401
18398
  };
18402
18399
  }
18403
- async function $y(e, t, n) {
18400
+ async function eb(e, t, n) {
18404
18401
  try {
18405
18402
  if (t.navigator.clipboard?.writeText) {
18406
18403
  await t.navigator.clipboard.writeText(n);
@@ -18414,22 +18411,22 @@ async function $y(e, t, n) {
18414
18411
  }
18415
18412
  //#endregion
18416
18413
  //#region src/layout-guides.ts
18417
- var eb = $_, tb = ev, nb = () => ({
18414
+ var tb = $_, nb = ev, rb = () => ({
18418
18415
  ...Ev(),
18419
18416
  version: Ey
18420
- }), rb = "mesurer.context", ib = "context:v1", ab = "mesurer.context.settings", ob = "context.ui", sb = "data-mesurer-direct-text-edit-active", cb = {
18417
+ }), ib = "mesurer.context", ab = "context:v1", ob = "mesurer.context.settings", sb = "context.ui", cb = "data-mesurer-direct-text-edit-active", lb = {
18421
18418
  viewBox: "0 0 256 256",
18422
18419
  paths: ["M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z"]
18423
- }, lb = {
18420
+ }, ub = {
18424
18421
  viewBox: "0 0 256 256",
18425
18422
  paths: ["M152,40a8,8,0,0,1-8,8H112a8,8,0,0,1,0-16h32A8,8,0,0,1,152,40Zm-8,168H112a8,8,0,0,0,0,16h32a8,8,0,0,0,0-16ZM208,32H184a8,8,0,0,0,0,16h24V72a8,8,0,0,0,16,0V48A16,16,0,0,0,208,32Zm8,72a8,8,0,0,0-8,8v32a8,8,0,0,0,16,0V112A8,8,0,0,0,216,104Zm0,72a8,8,0,0,0-8,8v24H184a8,8,0,0,0,0,16h24a16,16,0,0,0,16-16V184A8,8,0,0,0,216,176ZM40,152a8,8,0,0,0,8-8V112a8,8,0,0,0-16,0v32A8,8,0,0,0,40,152Zm32,56H48V184a8,8,0,0,0-16,0v24a16,16,0,0,0,16,16H72a8,8,0,0,0,0-16ZM72,32H48A16,16,0,0,0,32,48V72a8,8,0,0,0,16,0V48H72a8,8,0,0,0,0-16Z"]
18426
- }, ub = {
18423
+ }, db = {
18427
18424
  viewBox: "0 0 256 256",
18428
18425
  paths: ["M229.66,58.34l-32-32a8,8,0,0,0-11.32,0l-96,96A8,8,0,0,0,88,128v32a8,8,0,0,0,8,8h32a8,8,0,0,0,5.66-2.34l96-96A8,8,0,0,0,229.66,58.34ZM124.69,152H104V131.31l64-64L188.69,88ZM200,76.69,179.31,56,192,43.31,212.69,64ZM224,128v80a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32h80a8,8,0,0,1,0,16H48V208H208V128a8,8,0,0,1,16,0Z"]
18429
- }, db = async (e, t, n = 1) => {
18426
+ }, fb = async (e, t, n = 1) => {
18430
18427
  await e.fonts?.ready;
18431
18428
  for (let e = 0; e < Math.max(1, n); e += 1) await new Promise((e) => t.requestAnimationFrame(() => e()));
18432
- }, fb = (e, t, n, r) => {
18429
+ }, pb = (e, t, n, r) => {
18433
18430
  let i = async (i) => Gy({
18434
18431
  runtime: e,
18435
18432
  ownerDocument: t,
@@ -18440,17 +18437,17 @@ var eb = $_, tb = ev, nb = () => ({
18440
18437
  return {
18441
18438
  context: i,
18442
18439
  contextText: a,
18443
- copyContext: async (e) => $y(t, n, await a(e)),
18440
+ copyContext: async (e) => eb(t, n, await a(e)),
18444
18441
  select: async (r) => {
18445
18442
  let a = Array.isArray(r) ? [...r] : [String(r)];
18446
- return e.select(a), await db(t, n), i({ scope: "selection" });
18443
+ return e.select(a), await fb(t, n), i({ scope: "selection" });
18447
18444
  },
18448
18445
  annotations: async () => e.annotations(),
18449
18446
  removeAnnotation: async (r) => {
18450
- e.removeAnnotation(r), await db(t, n);
18447
+ e.removeAnnotation(r), await fb(t, n);
18451
18448
  },
18452
18449
  review: async (i) => {
18453
- if (await db(t, n), i) return Qy({
18450
+ if (await fb(t, n), i) return $y({
18454
18451
  runtime: e,
18455
18452
  ownerDocument: t,
18456
18453
  ownerWindow: n,
@@ -18458,7 +18455,7 @@ var eb = $_, tb = ev, nb = () => ({
18458
18455
  layoutGuides: r()
18459
18456
  });
18460
18457
  let a = r();
18461
- return e.annotations().map((r) => Qy({
18458
+ return e.annotations().map((r) => $y({
18462
18459
  runtime: e,
18463
18460
  ownerDocument: t,
18464
18461
  ownerWindow: n,
@@ -18468,36 +18465,36 @@ var eb = $_, tb = ev, nb = () => ({
18468
18465
  },
18469
18466
  capturePlan: async (e) => Yy(await i(e)),
18470
18467
  prepareCapture: async () => {
18471
- e.prepareCapture(), await db(t, n);
18468
+ e.prepareCapture(), await fb(t, n);
18472
18469
  },
18473
18470
  finishCapture: async () => {
18474
- e.finishCapture(), await db(t, n);
18471
+ e.finishCapture(), await fb(t, n);
18475
18472
  }
18476
18473
  };
18477
- }, pb = (e) => {
18474
+ }, mb = (e) => {
18478
18475
  let t = e.currentSelection();
18479
18476
  return t.elements.length > 0 || t.region !== null;
18480
18477
  };
18481
- function mb(e = {}) {
18478
+ function hb(e = {}) {
18482
18479
  return {
18483
- id: rb,
18480
+ id: ib,
18484
18481
  version: Ey,
18485
18482
  requires: ["runtime:solid"],
18486
- provides: [ib],
18483
+ provides: [ab],
18487
18484
  setup(t) {
18488
18485
  let n = t.service.get("runtime:solid");
18489
18486
  if (!n) throw Error("Mesurer context plugin requires the renderer runtime service.");
18490
- let r = n.createWorkspaceRuntime(rb), i = fb(r, n.ownerDocument, n.ownerWindow, () => t.service.get(tb)?.list() ?? []);
18491
- t.service.provide(ib, i), t.state.register({
18492
- id: ab,
18487
+ let r = n.createWorkspaceRuntime(ib), i = pb(r, n.ownerDocument, n.ownerWindow, () => t.service.get(nb)?.list() ?? []);
18488
+ t.service.provide(ab, i), t.state.register({
18489
+ id: ob,
18493
18490
  initial: { ui: e.ui ?? !0 },
18494
18491
  persist: !0
18495
18492
  }), t.state.register({
18496
- id: ob,
18497
- initial: { hasSelection: pb(r) }
18493
+ id: sb,
18494
+ initial: { hasSelection: mb(r) }
18498
18495
  });
18499
- let a = () => t.state.get("mesurer.context.settings")?.ui ?? !0, o = () => t.state.get(ob)?.hasSelection === !0, s = (e) => {
18500
- t.state.update(ab, (t) => ({
18496
+ let a = () => t.state.get("mesurer.context.settings")?.ui ?? !0, o = () => t.state.get(sb)?.hasSelection === !0, s = (e) => {
18497
+ t.state.update(ob, (t) => ({
18501
18498
  ...t,
18502
18499
  ui: e
18503
18500
  }));
@@ -18511,12 +18508,12 @@ function mb(e = {}) {
18511
18508
  region: e.region ? { ...e.region } : null
18512
18509
  }, r.selectGestureActive() ? c?.abandonNoteComposer() : n && c?.closeNoteComposer();
18513
18510
  let i = e.elements.length > 0 || e.region !== null;
18514
- i !== (t.state.get(ob)?.hasSelection ?? !1) && t.state.update(ob, () => ({ hasSelection: i }));
18511
+ i !== (t.state.get(sb)?.hasSelection ?? !1) && t.state.update(sb, () => ({ hasSelection: i }));
18515
18512
  });
18516
18513
  t.command.register("context.copy", () => i.copyContext()), t.command.register("context.copy-selection", () => i.copyContext({ scope: "selection" }));
18517
18514
  let g = () => {
18518
18515
  let e = u?.element;
18519
- e && (n.rendererRoot?.hasAttribute(sb) ? e.setAttribute(sb, "true") : e.removeAttribute(sb));
18516
+ e && (n.rendererRoot?.hasAttribute(cb) ? e.setAttribute(cb, "true") : e.removeAttribute(cb));
18520
18517
  }, _ = () => {
18521
18518
  d?.disconnect(), d = null, c = null, l?.(), l = null, u?.dispose(), u = null;
18522
18519
  }, v = () => {
@@ -18525,7 +18522,7 @@ function mb(e = {}) {
18525
18522
  let e = new n.ownerWindow.MutationObserver(g);
18526
18523
  d = e, e.observe(n.rendererRoot, {
18527
18524
  attributes: !0,
18528
- attributeFilter: [sb]
18525
+ attributeFilter: [cb]
18529
18526
  }), g();
18530
18527
  }
18531
18528
  let e = {
@@ -18548,7 +18545,7 @@ function mb(e = {}) {
18548
18545
  shortcut: "C",
18549
18546
  command: "context.copy",
18550
18547
  order: 70,
18551
- icon: cb,
18548
+ icon: lb,
18552
18549
  hidden: () => !a()
18553
18550
  }), t.tool.register({
18554
18551
  id: "context.copy-selection",
@@ -18556,7 +18553,7 @@ function mb(e = {}) {
18556
18553
  shortcut: "Shift+C",
18557
18554
  command: "context.copy-selection",
18558
18555
  order: 71,
18559
- icon: lb,
18556
+ icon: ub,
18560
18557
  hidden: () => !a(),
18561
18558
  disabled: () => !o()
18562
18559
  }), t.tool.register({
@@ -18565,7 +18562,7 @@ function mb(e = {}) {
18565
18562
  shortcut: "N",
18566
18563
  command: "context.add-note",
18567
18564
  order: 72,
18568
- icon: ub,
18565
+ icon: db,
18569
18566
  hidden: () => !a(),
18570
18567
  disabled: () => !o()
18571
18568
  }), t.settings.register({
@@ -18588,7 +18585,7 @@ function mb(e = {}) {
18588
18585
  }
18589
18586
  //#endregion
18590
18587
  //#region src/host-layer.ts
18591
- var hb = {
18588
+ var gb = {
18592
18589
  display: "block",
18593
18590
  position: "fixed",
18594
18591
  inset: "0",
@@ -18630,48 +18627,48 @@ var hb = {
18630
18627
  "letter-spacing": "normal",
18631
18628
  direction: "ltr"
18632
18629
  };
18633
- function gb(e) {
18634
- for (let [t, n] of Object.entries(hb)) e.style.setProperty(t, n, "important");
18635
- }
18636
18630
  function _b(e) {
18631
+ for (let [t, n] of Object.entries(gb)) e.style.setProperty(t, n, "important");
18632
+ }
18633
+ function vb(e) {
18637
18634
  return "popover" in e && "showPopover" in e && typeof e.showPopover == "function" && "hidePopover" in e && typeof e.hidePopover == "function";
18638
18635
  }
18639
- var vb = (e) => "newState" in e, yb = (e) => e.localName === "dialog";
18640
- function bb(e) {
18641
- if (!yb(e) || !e.open) return !1;
18636
+ var yb = (e) => "newState" in e, bb = (e) => e.localName === "dialog";
18637
+ function xb(e) {
18638
+ if (!bb(e) || !e.open) return !1;
18642
18639
  try {
18643
18640
  return e.matches(":modal");
18644
18641
  } catch {
18645
18642
  return !1;
18646
18643
  }
18647
18644
  }
18648
- function xb(e, t, n = !0) {
18649
- gb(e);
18645
+ function Sb(e, t, n = !0) {
18646
+ _b(e);
18650
18647
  let r = e.ownerDocument, i = r.defaultView ?? window, a = t, o = !1, s = "fixed", c = !1, l = 0, u = [];
18651
- if (n && _b(e) && (e.popover = "manual"), t.append(e), n && _b(e)) try {
18648
+ if (n && vb(e) && (e.popover = "manual"), t.append(e), n && vb(e)) try {
18652
18649
  e.showPopover(), c = e.matches(":popover-open"), c && (s = "top-layer");
18653
18650
  } catch {
18654
18651
  e.removeAttribute("popover");
18655
18652
  }
18656
18653
  let d = () => {
18657
- if (!(!c || !_b(e))) try {
18654
+ if (!(!c || !vb(e))) try {
18658
18655
  e.matches(":popover-open") || e.showPopover();
18659
18656
  } catch {}
18660
18657
  }, f = (t) => {
18661
18658
  if (e.parentNode === t) return;
18662
- let n = c && _b(e) && e.matches(":popover-open");
18663
- if (n && _b(e)) try {
18659
+ let n = c && vb(e) && e.matches(":popover-open");
18660
+ if (n && vb(e)) try {
18664
18661
  e.hidePopover();
18665
18662
  } catch {}
18666
- t.append(e), gb(e), n && d();
18663
+ t.append(e), _b(e), n && d();
18667
18664
  }, p = () => {
18668
- u = u.filter((e) => e.isConnected && bb(e)), f(u.at(-1) ?? a);
18665
+ u = u.filter((e) => e.isConnected && xb(e)), f(u.at(-1) ?? a);
18669
18666
  }, m = (e) => {
18670
18667
  u = u.filter((t) => t !== e), u.push(e), p();
18671
18668
  }, h = (e) => {
18672
18669
  u = u.filter((t) => t !== e), p();
18673
18670
  }, g = () => {
18674
- if (!(o || !c || !_b(e))) try {
18671
+ if (!(o || !c || !vb(e))) try {
18675
18672
  e.matches(":popover-open") && e.hidePopover(), e.showPopover();
18676
18673
  } catch {}
18677
18674
  }, _ = () => {
@@ -18680,27 +18677,27 @@ function xb(e, t, n = !0) {
18680
18677
  }));
18681
18678
  }, v = (t) => {
18682
18679
  if (!c || t.target === e) return;
18683
- let n = vb(t) ? t.newState : void 0, r = t.target;
18680
+ let n = yb(t) ? t.newState : void 0, r = t.target;
18684
18681
  if (r instanceof i.Element) {
18685
- if (yb(r)) {
18686
- n === "open" && bb(r) ? (m(r), _()) : n === "closed" ? h(r) : n === "open" && _();
18682
+ if (bb(r)) {
18683
+ n === "open" && xb(r) ? (m(r), _()) : n === "closed" ? h(r) : n === "open" && _();
18687
18684
  return;
18688
18685
  }
18689
18686
  n === "open" && r.hasAttribute("popover") && _();
18690
18687
  }
18691
18688
  }, y = (e) => {
18692
18689
  let t = e.target;
18693
- t instanceof i.Element && yb(t) && h(t);
18690
+ t instanceof i.Element && bb(t) && h(t);
18694
18691
  }, b = () => {
18695
18692
  r.fullscreenElement && _();
18696
18693
  }, x = (e) => {
18697
- bb(e) && m(e);
18698
- for (let t of e.querySelectorAll("dialog")) bb(t) && m(t);
18694
+ xb(e) && m(e);
18695
+ for (let t of e.querySelectorAll("dialog")) xb(t) && m(t);
18699
18696
  }, S = new i.MutationObserver((e) => {
18700
18697
  if (c) for (let t of e) {
18701
18698
  if (t.type === "attributes") {
18702
18699
  let e = t.target;
18703
- e instanceof i.Element && yb(e) && (bb(e) ? m(e) : h(e));
18700
+ e instanceof i.Element && bb(e) && (xb(e) ? m(e) : h(e));
18704
18701
  }
18705
18702
  for (let e of t.addedNodes) e instanceof i.Element && x(e);
18706
18703
  u.some((e) => !e.isConnected) && p();
@@ -18716,7 +18713,7 @@ function xb(e, t, n = !0) {
18716
18713
  bringToFront: g,
18717
18714
  dispose() {
18718
18715
  if (!o) {
18719
- if (o = !0, l && i.cancelAnimationFrame(l), r.removeEventListener("toggle", v, !0), r.removeEventListener("close", y, !0), r.removeEventListener("fullscreenchange", b, !0), S.disconnect(), c && _b(e) && e.matches(":popover-open")) try {
18716
+ if (o = !0, l && i.cancelAnimationFrame(l), r.removeEventListener("toggle", v, !0), r.removeEventListener("close", y, !0), r.removeEventListener("fullscreenchange", b, !0), S.disconnect(), c && vb(e) && e.matches(":popover-open")) try {
18720
18717
  e.hidePopover();
18721
18718
  } catch {}
18722
18719
  u = [];
@@ -18726,28 +18723,28 @@ function xb(e, t, n = !0) {
18726
18723
  }
18727
18724
  //#endregion
18728
18725
  //#region src/codex-plugin.ts
18729
- var Sb = "mesurer.codex", Cb = "codex:v1", wb = "http://127.0.0.1:47365", Tb = 2e3, Eb = 750, Db = 1800, Ob = 2e3, kb = 12e4, Ab = 10, jb = 5, Mb = [
18726
+ var Cb = "mesurer.codex", wb = "codex:v1", Tb = "http://127.0.0.1:47365", Eb = 2e3, Db = 750, Ob = 1800, kb = 2e3, Ab = 12e4, jb = 10, Mb = 5, Nb = [
18730
18727
  "Implement the current human feedback from Mesurer in this project.",
18731
18728
  "Treat the rendered page as the source of truth, preserve unrelated Mesurer review state,",
18732
18729
  "and verify the affected UI in the live page with Mesurer before claiming completion."
18733
- ].join(" "), Nb = {
18730
+ ].join(" "), Pb = {
18734
18731
  viewBox: "0 0 256 256",
18735
18732
  paths: ["M224,48,32,120l88,32,32,88Z M120,152l104-104"]
18736
- }, Pb = {
18733
+ }, Fb = {
18737
18734
  viewBox: "0 0 256 256",
18738
18735
  paths: ["M72,32H184a8,8,0,0,1,0,16h-8v20.69a40,40,0,0,1-11.72,28.28L137.25,124l27.03,27.03A40,40,0,0,1,176,179.31V208h8a8,8,0,0,1,0,16H72a8,8,0,0,1,0-16h8V179.31a40,40,0,0,1,11.72-28.28L118.75,124,91.72,96.97A40,40,0,0,1,80,68.69V48H72a8,8,0,0,1,0-16Zm24,16V68.69a24,24,0,0,0,7.03,16.97L128,110.63l24.97-24.97A24,24,0,0,0,160,68.69V48Zm32,90.63-24.97,24.97A24,24,0,0,0,96,180.57V208h64V180.57a24,24,0,0,0-7.03-16.97Z"]
18739
- }, Fb = {
18736
+ }, Ib = {
18740
18737
  viewBox: "0 0 256 256",
18741
18738
  paths: ["M229.66,77.66l-128,128a8,8,0,0,1-11.32,0l-56-56a8,8,0,0,1,11.32-11.32L96,188.69,218.34,66.34a8,8,0,0,1,11.32,11.32Z"]
18742
- }, Ib = (e) => {
18739
+ }, Lb = (e) => {
18743
18740
  try {
18744
18741
  let t = globalThis.location;
18745
18742
  return t?.origin ? `mesurer-codex-ui:v1:${e}:${t.origin}${t.pathname}` : null;
18746
18743
  } catch {
18747
18744
  return null;
18748
18745
  }
18749
- }, Lb = (e) => {
18750
- let t = Ib(e);
18746
+ }, Rb = (e) => {
18747
+ let t = Lb(e);
18751
18748
  if (!t) return null;
18752
18749
  try {
18753
18750
  let e = globalThis.sessionStorage?.getItem(t);
@@ -18772,18 +18769,18 @@ var Sb = "mesurer.codex", Cb = "codex:v1", wb = "http://127.0.0.1:47365", Tb = 2
18772
18769
  } catch {
18773
18770
  return null;
18774
18771
  }
18775
- }, Rb = (e, t) => {
18776
- let n = Ib(e);
18772
+ }, zb = (e, t) => {
18773
+ let n = Lb(e);
18777
18774
  if (n) try {
18778
18775
  globalThis.sessionStorage?.setItem(n, JSON.stringify(t));
18779
18776
  } catch {}
18780
- }, zb = (e, t) => {
18777
+ }, Bb = (e, t) => {
18781
18778
  let n = e.endsWith("/") ? e : `${e}/`;
18782
18779
  return new URL(t, n).toString();
18783
- }, Bb = async (e, t, n) => {
18780
+ }, Vb = async (e, t, n) => {
18784
18781
  let r = new AbortController(), i = setTimeout(() => r.abort(), 15e3);
18785
18782
  try {
18786
- let i = await fetch(zb(e, t), {
18783
+ let i = await fetch(Bb(e, t), {
18787
18784
  ...n,
18788
18785
  signal: r.signal
18789
18786
  }), a = await i.text(), o = {};
@@ -18799,10 +18796,10 @@ var Sb = "mesurer.codex", Cb = "codex:v1", wb = "http://127.0.0.1:47365", Tb = 2
18799
18796
  } finally {
18800
18797
  clearTimeout(i);
18801
18798
  }
18802
- }, Vb = (e) => ({
18799
+ }, Hb = (e) => ({
18803
18800
  thread: e.thread?.trim() || null,
18804
18801
  threads: Array.isArray(e.threads) ? e.threads.filter((e) => e.trim().length > 0) : []
18805
- }), Hb = (e) => {
18802
+ }), Ub = (e) => {
18806
18803
  let t = e.deliveryId?.trim(), n = e.thread?.trim(), r = e.status;
18807
18804
  if (!t || !n || !r) throw Error("Mesurer Codex bridge returned an invalid delivery state.");
18808
18805
  let i = {
@@ -18814,7 +18811,7 @@ var Sb = "mesurer.codex", Cb = "codex:v1", wb = "http://127.0.0.1:47365", Tb = 2
18814
18811
  updatedAt: Number.isFinite(e.updatedAt) ? Number(e.updatedAt) : 0
18815
18812
  };
18816
18813
  return e.queuedSubmissionId !== void 0 && (i.queuedSubmissionId = e.queuedSubmissionId?.trim() || null), e.dispatch !== void 0 && (i.dispatch = e.dispatch), e.dispatchError !== void 0 && (i.dispatchError = e.dispatchError?.trim() || null), i;
18817
- }, Ub = (e) => ({
18814
+ }, Wb = (e) => ({
18818
18815
  thread: e.thread?.trim() || null,
18819
18816
  threads: Array.isArray(e.threadDetails) ? e.threadDetails.flatMap((e) => {
18820
18817
  let t = e.id?.trim() ?? "";
@@ -18826,7 +18823,7 @@ var Sb = "mesurer.codex", Cb = "codex:v1", wb = "http://127.0.0.1:47365", Tb = 2
18826
18823
  }] : [];
18827
18824
  }) : [],
18828
18825
  hasMore: e.hasMore === !0
18829
- }), Wb = async (e, t, n) => {
18826
+ }), Gb = async (e, t, n) => {
18830
18827
  let r = t?.instruction?.trim() || n, i = await e.annotations(), a = t?.annotationIds, o = a ? a.flatMap((e) => {
18831
18828
  let t = i.find((t) => t.id === e);
18832
18829
  return t ? [t] : [];
@@ -18849,18 +18846,18 @@ var Sb = "mesurer.codex", Cb = "codex:v1", wb = "http://127.0.0.1:47365", Tb = 2
18849
18846
  ])
18850
18847
  ].join("\n").trimEnd()
18851
18848
  };
18852
- }, Gb = (e) => e.length > 16 ? `${e.slice(0, 8)}…${e.slice(-4)}` : e, Kb = (e, t = 42) => e.length > t ? `${e.slice(0, t - 1)}…` : e, qb = (e, t) => e instanceof Error && e.message === `Mesurer Codex bridge is unavailable at ${t}. Start the local bridge before queueing feedback.`;
18853
- function Jb(e = {}) {
18854
- let t = e.endpoint ?? wb, n = e.instruction?.trim() || Mb, r = e.ui ?? !0, i = e.clearCompletedAnnotations ?? !0;
18849
+ }, Kb = (e) => e.length > 16 ? `${e.slice(0, 8)}…${e.slice(-4)}` : e, qb = (e, t = 42) => e.length > t ? `${e.slice(0, t - 1)}…` : e, Jb = (e, t) => e instanceof Error && e.message === `Mesurer Codex bridge is unavailable at ${t}. Start the local bridge before queueing feedback.`;
18850
+ function Yb(e = {}) {
18851
+ let t = e.endpoint ?? Tb, n = e.instruction?.trim() || Nb, r = e.ui ?? !0, i = e.clearCompletedAnnotations ?? !0;
18855
18852
  return {
18856
- id: Sb,
18853
+ id: Cb,
18857
18854
  version: Ey,
18858
- requires: [ib],
18859
- provides: [Cb],
18855
+ requires: [ab],
18856
+ provides: [wb],
18860
18857
  setup(e) {
18861
- let a = e.service.get(ib);
18858
+ let a = e.service.get(ab);
18862
18859
  if (!a) throw Error("Mesurer Codex plugin requires context() from mesurer-solid/plugins.");
18863
- let o = r ? Lb(t) : null, s = "unknown", c = !1, l = o?.originThread ?? null, u = o?.selectedThread ?? o?.originThread ?? null, d = !1, f = null, p = [], m = [], h = !1, g = jb, _, v = "", y = null, b = o?.delivery ? {
18860
+ let o = r ? Rb(t) : null, s = "unknown", c = !1, l = o?.originThread ?? null, u = o?.selectedThread ?? o?.originThread ?? null, d = !1, f = null, p = [], m = [], h = !1, g = Mb, _, v = "", y = null, b = o?.delivery ? {
18864
18861
  id: o.delivery.id,
18865
18862
  thread: o.delivery.thread,
18866
18863
  status: o.delivery.status,
@@ -18868,22 +18865,22 @@ function Jb(e = {}) {
18868
18865
  queuedSubmissionId: o.delivery.queuedSubmissionId ?? null,
18869
18866
  dispatch: o.delivery.dispatch ?? null,
18870
18867
  dispatchError: o.delivery.dispatchError ?? null
18871
- } : null, x = 0, S = 0, C = null, w = !1, T = async () => Vb(await Bb(t, "health")), E = async (e) => Hb(await Bb(t, `deliveries/${encodeURIComponent(e)}`)), D = async (e) => {
18868
+ } : null, x = 0, S = 0, C = null, w = !1, T = async () => Hb(await Vb(t, "health")), E = async (e) => Ub(await Vb(t, `deliveries/${encodeURIComponent(e)}`)), D = async (e) => {
18872
18869
  if (!e.id || !e.thread) throw Error("Cannot restore a Codex delivery without its id and thread.");
18873
18870
  let n = {
18874
18871
  deliveryId: e.id,
18875
18872
  thread: e.thread
18876
18873
  };
18877
- return e.queuedSubmissionId && (n.queuedSubmissionId = e.queuedSubmissionId), Hb(await Bb(t, "deliveries/restore", {
18874
+ return e.queuedSubmissionId && (n.queuedSubmissionId = e.queuedSubmissionId), Ub(await Vb(t, "deliveries/restore", {
18878
18875
  method: "POST",
18879
18876
  headers: { "Content-Type": "application/json" },
18880
18877
  body: JSON.stringify(n)
18881
18878
  }));
18882
18879
  }, O = async (e = {}) => {
18883
18880
  let n = new URLSearchParams();
18884
- n.set("limit", String(e.limit ?? Ab));
18881
+ n.set("limit", String(e.limit ?? jb));
18885
18882
  let r = e.thread?.trim();
18886
- return r && n.set("thread", r), Ub(await Bb(t, `threads?${n.toString()}`));
18883
+ return r && n.set("thread", r), Wb(await Vb(t, `threads?${n.toString()}`));
18887
18884
  }, k = () => u ?? l ?? (d ? null : f), A = () => {
18888
18885
  if (!r) return;
18889
18886
  let e = b?.id && (b.status === "queued" || b.status === "working" || b.status === "interrupted") ? {
@@ -18895,7 +18892,7 @@ function Jb(e = {}) {
18895
18892
  dispatch: b.dispatch,
18896
18893
  dispatchError: b.dispatchError
18897
18894
  } : null;
18898
- Rb(t, {
18895
+ zb(t, {
18899
18896
  version: 1,
18900
18897
  originThread: l,
18901
18898
  selectedThread: u,
@@ -18913,12 +18910,12 @@ function Jb(e = {}) {
18913
18910
  "queueing",
18914
18911
  "queued",
18915
18912
  "working"
18916
- ].includes(b.status) ? Pb : b.status === "completed" ? Fb : Nb : Nb, L = () => {
18913
+ ].includes(b.status) ? Fb : b.status === "completed" ? Ib : Pb : Pb, L = () => {
18917
18914
  let e = [], t = /* @__PURE__ */ new Set(), n = (n) => {
18918
18915
  t.has(n.id) || (t.add(n.id), e.push(n));
18919
18916
  }, r = (e) => ({
18920
18917
  id: e,
18921
- title: `Codex ${Gb(e)}`,
18918
+ title: `Codex ${Kb(e)}`,
18922
18919
  updatedAt: null,
18923
18920
  connected: !0
18924
18921
  });
@@ -18938,7 +18935,7 @@ function Jb(e = {}) {
18938
18935
  let t = e.id === l ? "Current · " : e.connected ? "Connected · " : "", r = b?.thread === e.id ? ` · ${N() ? "Blocked" : P(b.status)}` : "";
18939
18936
  return {
18940
18937
  id: `codex.thread.${e.id}`,
18941
- label: `${t}${Kb(e.title)}${r}`,
18938
+ label: `${t}${qb(e.title)}${r}`,
18942
18939
  checked: () => n === e.id,
18943
18940
  disabled: () => M(),
18944
18941
  run() {
@@ -18946,11 +18943,11 @@ function Jb(e = {}) {
18946
18943
  }
18947
18944
  };
18948
18945
  });
18949
- return g < Ab && (e.length > g || h) && r.push({
18946
+ return g < jb && (e.length > g || h) && r.push({
18950
18947
  id: "codex.thread.show-more",
18951
18948
  label: "Show 5 more…",
18952
18949
  run() {
18953
- g = Ab, B();
18950
+ g = jb, B();
18954
18951
  }
18955
18952
  }), r;
18956
18953
  }, B = () => {
@@ -18986,14 +18983,14 @@ function Jb(e = {}) {
18986
18983
  let e = l && p.includes(l) ? l : f;
18987
18984
  try {
18988
18985
  let t = await O({
18989
- limit: Ab,
18986
+ limit: jb,
18990
18987
  thread: e ?? void 0
18991
18988
  });
18992
18989
  m = t.threads, h = t.hasMore;
18993
18990
  } catch {
18994
18991
  m = p.map((e) => ({
18995
18992
  id: e,
18996
- title: `Codex ${Gb(e)}`,
18993
+ title: `Codex ${Kb(e)}`,
18997
18994
  updatedAt: null,
18998
18995
  connected: !0
18999
18996
  })), h = !1;
@@ -19016,7 +19013,7 @@ function Jb(e = {}) {
19016
19013
  }, te = () => {
19017
19014
  S && globalThis.clearTimeout(S), S = globalThis.setTimeout(() => {
19018
19015
  S = 0, b?.status === "completed" && (b = null, A(), B());
19019
- }, Db);
19016
+ }, Ob);
19020
19017
  }, H = async (e) => {
19021
19018
  if (!(!b || b.id !== e.id)) {
19022
19019
  if (b = {
@@ -19034,14 +19031,14 @@ function Jb(e = {}) {
19034
19031
  if (e.status === "interrupted") {
19035
19032
  A(), B();
19036
19033
  let t = e.updatedAt > 0 ? e.updatedAt : Date.now();
19037
- Date.now() - t < kb && (x = globalThis.setTimeout(() => {
19034
+ Date.now() - t < Ab && (x = globalThis.setTimeout(() => {
19038
19035
  x = 0, ne(e.id);
19039
- }, Ob));
19036
+ }, kb));
19040
19037
  return;
19041
19038
  }
19042
19039
  B(), x = globalThis.setTimeout(() => {
19043
19040
  x = 0, ne(e.id);
19044
- }, Eb);
19041
+ }, Db);
19045
19042
  }
19046
19043
  }, ne = async (e) => {
19047
19044
  if (!(w || b?.id !== e)) try {
@@ -19065,7 +19062,7 @@ function Jb(e = {}) {
19065
19062
  b = {
19066
19063
  ...b,
19067
19064
  status: "failed"
19068
- }, A(), qb(r, t) && (s = "unavailable"), B();
19065
+ }, A(), Jb(r, t) && (s = "unavailable"), B();
19069
19066
  }
19070
19067
  }, U = {
19071
19068
  health: T,
@@ -19074,7 +19071,7 @@ function Jb(e = {}) {
19074
19071
  async useThread(e) {
19075
19072
  let n = e.trim();
19076
19073
  if (!n) throw Error("Codex thread must be a non-empty string.");
19077
- let r = Vb(await Bb(t, "target", {
19074
+ let r = Hb(await Vb(t, "target", {
19078
19075
  method: "POST",
19079
19076
  headers: { "Content-Type": "application/json" },
19080
19077
  body: JSON.stringify({ thread: n })
@@ -19082,12 +19079,12 @@ function Jb(e = {}) {
19082
19079
  return j(n, !l), f = r.thread, p = r.threads, s = "available", c = !0, B(), r;
19083
19080
  },
19084
19081
  async queue(e) {
19085
- let i = await Wb(a, e, n), o = e?.thread?.trim(), c = o || (r ? k() : null);
19082
+ let i = await Gb(a, e, n), o = e?.thread?.trim(), c = o || (r ? k() : null);
19086
19083
  if (r && !o && (d || !c)) throw Error("Choose a Codex thread before queueing feedback.");
19087
19084
  let l = { message: i.message };
19088
19085
  c && (l.thread = c);
19089
19086
  try {
19090
- let e = await Bb(t, "send", {
19087
+ let e = await Vb(t, "send", {
19091
19088
  method: "POST",
19092
19089
  headers: { "Content-Type": "application/json" },
19093
19090
  body: JSON.stringify(l)
@@ -19103,14 +19100,14 @@ function Jb(e = {}) {
19103
19100
  };
19104
19101
  return e.queuedSubmissionId !== void 0 && (r.queuedSubmissionId = e.queuedSubmissionId?.trim() || null), e.dispatch !== void 0 && (r.dispatch = e.dispatch), e.dispatchError !== void 0 && (r.dispatchError = e.dispatchError?.trim() || null), r;
19105
19102
  } catch (e) {
19106
- throw r && qb(e, t) && (s = "unavailable", B()), e;
19103
+ throw r && Jb(e, t) && (s = "unavailable", B()), e;
19107
19104
  }
19108
19105
  },
19109
19106
  send(e) {
19110
19107
  return U.queue(e);
19111
19108
  }
19112
19109
  };
19113
- e.service.provide(Cb, U);
19110
+ e.service.provide(wb, U);
19114
19111
  let re = async () => {
19115
19112
  if (!(C || M())) return V(), b = {
19116
19113
  id: null,
@@ -19141,9 +19138,9 @@ function Jb(e = {}) {
19141
19138
  updatedAt: 0
19142
19139
  }) : x = globalThis.setTimeout(() => {
19143
19140
  x = 0, ne(e.deliveryId);
19144
- }, Eb) : S = globalThis.setTimeout(() => {
19141
+ }, Db) : S = globalThis.setTimeout(() => {
19145
19142
  S = 0, b?.id === null && b?.status === "queued" && (b = null, A(), B());
19146
- }, Db);
19143
+ }, Ob);
19147
19144
  } catch (e) {
19148
19145
  b = null, A(), B();
19149
19146
  let t = e instanceof Error ? e.message : String(e);
@@ -19159,7 +19156,7 @@ function Jb(e = {}) {
19159
19156
  }, 0));
19160
19157
  let t = globalThis.setInterval(() => {
19161
19158
  c && R().catch(() => void 0);
19162
- }, Tb);
19159
+ }, Eb);
19163
19160
  e.lifecycle.onDispose(() => {
19164
19161
  w = !0, V(), globalThis.clearInterval(t), _?.dispose(), _ = void 0;
19165
19162
  });
@@ -19169,12 +19166,12 @@ function Jb(e = {}) {
19169
19166
  }
19170
19167
  //#endregion
19171
19168
  //#region src/plugin-catalog.ts
19172
- var Yb = [
19169
+ var Xb = [
19173
19170
  {
19174
- id: rb,
19171
+ id: ib,
19175
19172
  label: "Context",
19176
19173
  order: 30,
19177
- create: mb,
19174
+ create: hb,
19178
19175
  settingsIds: ["context"],
19179
19176
  hiddenSettingsControlIds: ["ui"]
19180
19177
  },
@@ -19186,10 +19183,10 @@ var Yb = [
19186
19183
  settingsIds: ["arrange"]
19187
19184
  },
19188
19185
  {
19189
- id: eb,
19186
+ id: tb,
19190
19187
  label: "Layout Guides",
19191
19188
  order: 38,
19192
- create: nb
19189
+ create: rb
19193
19190
  },
19194
19191
  {
19195
19192
  id: Rv,
@@ -19203,13 +19200,13 @@ var Yb = [
19203
19200
  hiddenSettingsControlIds: ["tool"]
19204
19201
  },
19205
19202
  {
19206
- id: Sb,
19203
+ id: Cb,
19207
19204
  label: "Codex",
19208
19205
  order: 45,
19209
- create: Jb
19206
+ create: Yb
19210
19207
  }
19211
- ], Xb = (e) => {
19212
- let t = e !== void 0, n = new Map((e ?? []).map((e) => [e.id, e])), r = new Set(Yb.map((e) => e.id)), i = Yb.map((e) => {
19208
+ ], Zb = (e) => {
19209
+ let t = e !== void 0, n = new Map((e ?? []).map((e) => [e.id, e])), r = new Set(Xb.map((e) => e.id)), i = Xb.map((e) => {
19213
19210
  let r = n.get(e.id);
19214
19211
  return {
19215
19212
  ...e,
@@ -19226,16 +19223,16 @@ var Yb = [
19226
19223
  create: () => n
19227
19224
  });
19228
19225
  return i;
19229
- }, Zb = (e) => e;
19230
- function Qb() {
19226
+ }, Qb = (e) => e;
19227
+ function $b() {
19231
19228
  return zy();
19232
19229
  }
19233
- async function $b(e = {}) {
19230
+ async function ex(e = {}) {
19234
19231
  return By(e);
19235
19232
  }
19236
19233
  //#endregion
19237
19234
  //#region src/index.tsx
19238
- var ex = {
19235
+ var tx = {
19239
19236
  select: "select",
19240
19237
  xray: "xray",
19241
19238
  colorPicker: "color-picker",
@@ -19245,14 +19242,14 @@ var ex = {
19245
19242
  distance: "distance",
19246
19243
  settings: "settings"
19247
19244
  };
19248
- function tx(e = {}) {
19245
+ function nx(e = {}) {
19249
19246
  if (!("document" in globalThis)) throw Error("mountMesurer() requires a browser or Electron renderer document.");
19250
19247
  let { target: t = document.body, isolate: n = !0, shadowMode: r = "open", topLayer: i = !0, agent: a = !1, signal: o, onPluginHost: s, onPluginsReady: c, plugins: l, excludeBuiltins: u, excludePlugins: d, ...f } = e;
19251
19248
  if (o?.aborted) throw o.reason ?? new DOMException("Mesurer mount aborted.", "AbortError");
19252
19249
  if (!t) throw Error("mountMesurer() requires document.body to exist or an explicit target.");
19253
19250
  let p = t.ownerDocument ?? document, m = p.defaultView ?? window, h = p.createElement("div");
19254
19251
  h.dataset.mesurerIsland = "true";
19255
- let g = xb(h, t, i), _ = h, v = h, y = h;
19252
+ let g = Sb(h, t, i), _ = h, v = h, y = h;
19256
19253
  if (n) {
19257
19254
  let e = h.attachShadow({ mode: r });
19258
19255
  v = p.createElement("div"), v.dataset.mesurerIslandMount = "true", e.append(v), _ = e, y = e;
@@ -19275,7 +19272,7 @@ function tx(e = {}) {
19275
19272
  return t;
19276
19273
  }, N = async () => {
19277
19274
  await j.ready();
19278
- let e = b?.service.get(ib);
19275
+ let e = b?.service.get(ab);
19279
19276
  if (!e) throw Error("Mesurer Context is disabled. Enable it in Settings or include context() in plugins.");
19280
19277
  return e;
19281
19278
  }, P = async () => {
@@ -19291,7 +19288,7 @@ function tx(e = {}) {
19291
19288
  (await P()).show(e, t);
19292
19289
  }, re = async (e, t) => (await P()).capturePlan(e, t), ie = async (e, t) => (await P()).review(e, t), ae = () => j.textEdits(), oe = (e) => j.textEdit(e), se = Object.assign(j, {
19293
19290
  capabilities: () => {
19294
- let e = !!b?.service.get(ib);
19291
+ let e = !!b?.service.get(ab);
19295
19292
  return {
19296
19293
  protocol: "mesurer.agent/v1",
19297
19294
  contextSchema: "mesurer.context/v1",
@@ -19322,8 +19319,8 @@ function tx(e = {}) {
19322
19319
  }), ce = {
19323
19320
  ...f,
19324
19321
  version: Ey,
19325
- plugins: Xb(l),
19326
- excludePlugins: u ? u.map((e) => ex[e]) : [...d ?? []]
19322
+ plugins: Zb(l),
19323
+ excludePlugins: u ? u.map((e) => tx[e]) : [...d ?? []]
19327
19324
  }, le = _i(() => Rr(u_, gi(ce, {
19328
19325
  portalTarget: y,
19329
19326
  pageTarget: t,
@@ -19392,6 +19389,6 @@ function tx(e = {}) {
19392
19389
  }
19393
19390
  return _e;
19394
19391
  }
19395
- var nx = tx;
19392
+ var rx = nx;
19396
19393
  //#endregion
19397
- export { Cy as MESURER_TEXT_EDIT_SERVICE_ID, Ey as MESURER_VERSION, Gy as captureMesurerContext, $y as copyTextToClipboard, Ty as createMesurerAgentHarness, Yy as createMesurerCapturePlan, Qb as createMesurerPluginHost, $b as createMesurerRuntime, Zb as defineMesurerPlugin, Jy as formatMesurerContext, nx as mountMeasurer, tx as mountMesurer, Qy as reviewMesurerAnnotation };
19394
+ export { Cy as MESURER_TEXT_EDIT_SERVICE_ID, Ey as MESURER_VERSION, Gy as captureMesurerContext, eb as copyTextToClipboard, Ty as createMesurerAgentHarness, Yy as createMesurerCapturePlan, $b as createMesurerPluginHost, ex as createMesurerRuntime, Qb as defineMesurerPlugin, Jy as formatMesurerContext, rx as mountMeasurer, nx as mountMesurer, $y as reviewMesurerAnnotation };