@qikbar/qikbar 0.2.1 → 0.2.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.
Files changed (43) hide show
  1. package/dist/ai.js +5 -6
  2. package/dist/chunks/{bar-P3SCR4SJ.js → bar-4WGKZKVL.js} +263 -215
  3. package/dist/chunks/bar-4WGKZKVL.js.map +7 -0
  4. package/dist/chunks/{chunk-PQEHV3D4.js → chunk-FRR2RT26.js} +3 -8
  5. package/dist/chunks/{chunk-PQEHV3D4.js.map → chunk-FRR2RT26.js.map} +1 -1
  6. package/dist/chunks/{chunk-WO6XXQ3H.js → chunk-JBXMI45H.js} +40 -37
  7. package/dist/chunks/chunk-JBXMI45H.js.map +7 -0
  8. package/dist/chunks/{chunk-24EBWTCF.js → chunk-MDIFIKGL.js} +7 -13
  9. package/dist/chunks/{chunk-24EBWTCF.js.map → chunk-MDIFIKGL.js.map} +2 -2
  10. package/dist/chunks/{chunk-JHQAIXM7.js → chunk-OUEAI6J2.js} +139 -82
  11. package/dist/chunks/chunk-OUEAI6J2.js.map +7 -0
  12. package/dist/chunks/{launcher-B5MGOPEQ.js → launcher-S3P2HQOR.js} +1 -3
  13. package/dist/chunks/{launcher-B5MGOPEQ.js.map → launcher-S3P2HQOR.js.map} +1 -1
  14. package/dist/core/frecency.d.ts +1 -1
  15. package/dist/element.js +5 -12
  16. package/dist/element.js.map +1 -1
  17. package/dist/extensions.js +3 -6
  18. package/dist/extensions.js.map +1 -1
  19. package/dist/index.d.ts +5 -3
  20. package/dist/index.js +3 -5
  21. package/dist/locales.js +0 -1
  22. package/dist/locales.js.map +1 -1
  23. package/dist/qikbar.global.js +23 -23
  24. package/dist/qikbar.global.js.map +3 -3
  25. package/dist/react.js +3 -5
  26. package/dist/react.js.map +1 -1
  27. package/dist/server.js +0 -1
  28. package/dist/server.js.map +1 -1
  29. package/dist/solid.js +3 -5
  30. package/dist/solid.js.map +1 -1
  31. package/dist/svelte.js +3 -5
  32. package/dist/svelte.js.map +1 -1
  33. package/dist/theme.js +0 -1
  34. package/dist/ui/bar.d.ts +20 -0
  35. package/dist/utils.js +2 -3
  36. package/dist/vue.js +3 -5
  37. package/dist/vue.js.map +1 -1
  38. package/package.json +1 -1
  39. package/dist/chunks/bar-P3SCR4SJ.js.map +0 -7
  40. package/dist/chunks/chunk-JHQAIXM7.js.map +0 -7
  41. package/dist/chunks/chunk-MPTP2EWW.js +0 -8
  42. package/dist/chunks/chunk-MPTP2EWW.js.map +0 -7
  43. package/dist/chunks/chunk-WO6XXQ3H.js.map +0 -7
@@ -18,7 +18,7 @@ import {
18
18
  matchItem,
19
19
  rank,
20
20
  renderMarkdown
21
- } from "./chunk-JHQAIXM7.js";
21
+ } from "./chunk-OUEAI6J2.js";
22
22
  import {
23
23
  defaultStorage,
24
24
  scopedStorage
@@ -29,14 +29,11 @@ import {
29
29
  formatHotkey,
30
30
  isEditable,
31
31
  matchesHotkey
32
- } from "./chunk-PQEHV3D4.js";
32
+ } from "./chunk-FRR2RT26.js";
33
33
  import {
34
34
  en,
35
35
  format
36
36
  } from "./chunk-TIM4VBM4.js";
37
- import {
38
- __publicField
39
- } from "./chunk-MPTP2EWW.js";
40
37
 
41
38
  // src/ui/dom.ts
42
39
  function h(tag, props, ...children) {
@@ -52,7 +49,20 @@ function append(el, children) {
52
49
  for (let child of children)
53
50
  Array.isArray(child) ? append(el, child) : child != null && child !== !1 && el.append(child instanceof Node ? child : String(child));
54
51
  }
55
- var URL_RE = /^(https?:|\/|\.\.?\/|data:image\/|blob:)/;
52
+ var URL_RE = /^(https?:|\/|\.\.?\/|data:image\/|blob:)/, svgTemplates = /* @__PURE__ */ new Map();
53
+ function cloneIconSvg(name, size) {
54
+ let key = `${name}:${size}`, tpl = svgTemplates.get(key);
55
+ if (!tpl || tpl.ownerDocument !== document) {
56
+ let svg = iconSvg(name, size);
57
+ if (!svg) return null;
58
+ let host = document.createElement("span");
59
+ host.innerHTML = svg;
60
+ let node = host.firstChild;
61
+ if (!node) return null;
62
+ tpl = node, svgTemplates.set(key, tpl);
63
+ }
64
+ return tpl.cloneNode(!0);
65
+ }
56
66
  function renderIcon(icon, size = 16) {
57
67
  if (icon == null || icon === "") return null;
58
68
  let wrap = h("span", { class: "qb-icon", "aria-hidden": "true" });
@@ -67,8 +77,8 @@ function renderIcon(icon, size = 16) {
67
77
  let inner = renderIcon(icon.icon ?? "dot", size);
68
78
  inner && wrap.append(...inner.childNodes);
69
79
  } else if (typeof icon == "string") {
70
- let svg = iconSvg(icon, size);
71
- svg ? wrap.innerHTML = svg : icon.trimStart().startsWith("<svg") ? wrap.innerHTML = icon : URL_RE.test(icon) ? wrap.append(h("img", { src: icon, alt: "", loading: "lazy", decoding: "async", draggable: "false" })) : (wrap.classList.add("qb-icon-text"), wrap.textContent = icon);
80
+ let node = cloneIconSvg(icon, size);
81
+ node ? wrap.append(node) : icon.trimStart().startsWith("<svg") ? wrap.innerHTML = icon : URL_RE.test(icon) ? wrap.append(h("img", { src: icon, alt: "", loading: "lazy", decoding: "async", draggable: "false" })) : (wrap.classList.add("qb-icon-text"), wrap.textContent = icon);
72
82
  }
73
83
  return wrap;
74
84
  }
@@ -210,38 +220,30 @@ function px(value, fallback) {
210
220
  }
211
221
  var detailCache = /* @__PURE__ */ new WeakMap(), ListRenderer = class {
212
222
  constructor(bar, frame) {
213
- __publicField(this, "bar", bar);
214
- __publicField(this, "frame", frame);
215
- __publicField(this, "el");
216
- __publicField(this, "hasInput", !0);
217
- __publicField(this, "scroller");
218
- __publicField(this, "inner");
219
- __publicField(this, "emptyEl");
220
- __publicField(this, "detailEl");
221
- __publicField(this, "cache", /* @__PURE__ */ new Map());
222
- __publicField(this, "renderedKeys", []);
223
- __publicField(this, "selectedEl");
224
- __publicField(this, "virtual", !1);
225
- __publicField(this, "offsets", []);
226
- __publicField(this, "rowHeight", 42);
227
- __publicField(this, "sectionHeight", 30);
228
- __publicField(this, "rafId", 0);
229
- __publicField(this, "detailFor");
230
- __publicField(this, "press");
231
- __publicField(this, "onScroll", () => {
223
+ this.bar = bar;
224
+ this.frame = frame;
225
+ this.hasInput = !0;
226
+ this.cache = /* @__PURE__ */ new Map();
227
+ this.renderedKeys = [];
228
+ this.virtual = !1;
229
+ this.offsets = [];
230
+ this.rowHeight = 42;
231
+ this.sectionHeight = 30;
232
+ this.rafId = 0;
233
+ this.onScroll = () => {
232
234
  !this.virtual || this.rafId || (this.rafId = requestAnimationFrame(() => {
233
235
  this.rafId = 0, this.renderWindow();
234
236
  }));
235
- });
236
- __publicField(this, "onPointerMove", (e) => {
237
+ };
238
+ this.onPointerMove = (e) => {
237
239
  let p = this.press;
238
240
  if (p && !p.fired && Math.hypot(e.clientX - p.x, e.clientY - p.y) > 8 && this.cancelPress(), e.pointerType !== "mouse") return;
239
241
  let el = e.target.closest?.("[data-index]");
240
242
  if (!el) return;
241
243
  let index = Number(el.dataset.index);
242
244
  index !== this.frame.selected && this.select(index, !1);
243
- });
244
- __publicField(this, "onClick", (e) => {
245
+ };
246
+ this.onClick = (e) => {
245
247
  let el = e.target.closest?.("[data-index]");
246
248
  if (!el) return;
247
249
  if (this.press?.fired) {
@@ -257,9 +259,9 @@ var detailCache = /* @__PURE__ */ new WeakMap(), ListRenderer = class {
257
259
  if (this.frame.marked?.size) return this.bar.toggleMark(this.frame, item);
258
260
  }
259
261
  this.bar.runPrimary(this.frame, e.metaKey || e.ctrlKey ? 1 : 0, "click");
260
- });
262
+ };
261
263
  /** Keep focus in the search box; on touch, a long press opens the actions. */
262
- __publicField(this, "onPointerDown", (e) => {
264
+ this.onPointerDown = (e) => {
263
265
  if (e.preventDefault(), this.cancelPress(), e.pointerType === "mouse") return;
264
266
  let el = e.target.closest?.("[data-index]");
265
267
  if (!el) return;
@@ -272,15 +274,15 @@ var detailCache = /* @__PURE__ */ new WeakMap(), ListRenderer = class {
272
274
  }, LONG_PRESS_MS)
273
275
  };
274
276
  this.press = press;
275
- });
276
- __publicField(this, "cancelPress", (e) => {
277
+ };
278
+ this.cancelPress = (e) => {
277
279
  let p = this.press;
278
280
  p && (clearTimeout(p.timer), (!p.fired || e?.type === "pointercancel") && (this.press = void 0));
279
- });
280
- __publicField(this, "onContextMenu", (e) => {
281
+ };
282
+ this.onContextMenu = (e) => {
281
283
  let el = e.target.closest?.("[data-index]");
282
284
  el && (e.preventDefault(), !(this.press?.fired || this.bar.panel) && (this.select(Number(el.dataset.index), !1), this.bar.openPanel()));
283
- });
285
+ };
284
286
  this.inner = h("div", { class: "qb-list-inner" }), this.scroller = h(
285
287
  "div",
286
288
  { class: `${bar.cls("qb-scroll qb-list", "list")}`, role: "listbox", id: `${bar.instanceId}-list`, "aria-label": bar.t("results"), tabindex: "-1" },
@@ -327,14 +329,19 @@ var detailCache = /* @__PURE__ */ new WeakMap(), ListRenderer = class {
327
329
  let row = rows[i], el = this.rowEl(row);
328
330
  el.style.position = "absolute", el.style.top = `${this.offsets[i]}px`, el.style.left = "0", el.style.right = "0", els.push(el), keys.push(row.key);
329
331
  }
330
- sameKeys(keys, this.renderedKeys) || (this.inner.replaceChildren(...els), this.renderedKeys = keys), this.updateSelection();
332
+ if ((!sameKeys(keys, this.renderedKeys) || els.some((el, i) => this.inner.children[i] !== el)) && (this.inner.replaceChildren(...els), this.renderedKeys = keys), this.cache.size > 200) {
333
+ let keep = new Set(keys), sel = this.frame.itemRows[this.frame.selected]?.key;
334
+ sel && keep.add(sel);
335
+ for (let key of this.cache.keys()) keep.has(key) || this.cache.delete(key);
336
+ }
337
+ this.updateSelection();
331
338
  }
332
339
  rowSig(row) {
333
340
  if (row.kind === "section") return row.title;
334
341
  let sig = `${row.index}|${row.positions?.join(",") ?? ""}`;
335
342
  if (this.frame.view.type === "root" && this.bar.personalize) {
336
343
  let id = this.bar.idOf(row.item);
337
- sig += `|${this.bar.aliasOf(id) ?? ""}|${this.bar.pins().includes(id) ? "p" : ""}`;
344
+ sig += `|${this.bar.aliasOf(id) ?? ""}|${this.bar.isPinned(id) ? "p" : ""}`;
338
345
  }
339
346
  return sig;
340
347
  }
@@ -351,7 +358,7 @@ var detailCache = /* @__PURE__ */ new WeakMap(), ListRenderer = class {
351
358
  let { item } = row, isRoot = this.frame.view.type === "root", right = [];
352
359
  if (isRoot && this.bar.personalize) {
353
360
  let id = this.bar.idOf(item), alias = this.bar.aliasOf(id);
354
- alias && right.push(h("span", { class: "qb-alias", title: this.bar.t("alias") }, alias)), this.bar.pins().includes(id) && right.push(h("span", { class: "qb-pin", title: this.bar.t("pinned") }, renderIcon("pin", 13)));
361
+ alias && right.push(h("span", { class: "qb-alias", title: this.bar.t("alias") }, alias)), this.bar.isPinned(id) && right.push(h("span", { class: "qb-pin", title: this.bar.t("pinned") }, renderIcon("pin", 13)));
355
362
  }
356
363
  return item.accessories?.length ? right.push(h("span", { class: "qb-item-accessories" }, ...item.accessories.map(renderAccessory))) : item.shortcut && right.push(h("span", { class: "qb-item-accessories" }, renderKbd(item.shortcut))), isRoot && !item.accessories?.length && !item.shortcut && right.push(h("span", { class: "qb-item-kind" }, this.kindOf(item))), h(
357
364
  "div",
@@ -379,10 +386,10 @@ var detailCache = /* @__PURE__ */ new WeakMap(), ListRenderer = class {
379
386
  updateSelection() {
380
387
  let row = this.frame.itemRows[this.frame.selected], el = row ? this.cache.get(row.key)?.el : void 0;
381
388
  if (this.selectedEl && this.selectedEl !== el && this.selectedEl.setAttribute("aria-selected", "false"), el && el.setAttribute("aria-selected", "true"), this.selectedEl = el, this.bar.isMulti(this.frame))
382
- for (let r of this.frame.itemRows) {
383
- let rowEl = this.cache.get(r.key)?.el;
384
- if (!rowEl) continue;
385
- let marked = this.bar.isMarked(this.frame, r.key);
389
+ for (let key of this.renderedKeys) {
390
+ let rowEl = this.cache.get(key)?.el;
391
+ if (!rowEl || !rowEl.__item) continue;
392
+ let marked = this.bar.isMarked(this.frame, key);
386
393
  marked ? rowEl.dataset.marked = "" : delete rowEl.dataset.marked, rowEl.setAttribute("aria-checked", marked ? "true" : "false");
387
394
  }
388
395
  }
@@ -435,7 +442,7 @@ var detailCache = /* @__PURE__ */ new WeakMap(), ListRenderer = class {
435
442
  ensureVisible() {
436
443
  let f = this.frame, row = f.itemRows[f.selected];
437
444
  if (!row) return;
438
- let rowIndex = f.rows.indexOf(row), prev = f.rows[rowIndex - 1], top, bottom;
445
+ let rowIndex = row.rowIndex, prev = f.rows[rowIndex - 1], top, bottom;
439
446
  if (this.virtual)
440
447
  top = this.offsets[rowIndex], bottom = top + this.rowHeight, prev?.kind === "section" && (top = this.offsets[rowIndex - 1]);
441
448
  else {
@@ -542,13 +549,11 @@ var GridRenderer = class extends ListRenderer {
542
549
  }
543
550
  }, DetailRenderer = class {
544
551
  constructor(bar, frame) {
545
- __publicField(this, "bar", bar);
546
- __publicField(this, "frame", frame);
547
- __publicField(this, "el");
548
- __publicField(this, "hasInput", !1);
549
- __publicField(this, "body");
550
- __publicField(this, "rendered", "");
551
- __publicField(this, "raf", 0);
552
+ this.bar = bar;
553
+ this.frame = frame;
554
+ this.hasInput = !1;
555
+ this.rendered = "";
556
+ this.raf = 0;
552
557
  let v = frame.view;
553
558
  this.body = h("div", { class: bar.cls("qb-detail qb-md", "detail"), tabindex: "-1" });
554
559
  let children = [this.body];
@@ -619,12 +624,11 @@ var GridRenderer = class extends ListRenderer {
619
624
  }
620
625
  }, FormRenderer = class {
621
626
  constructor(bar, frame) {
622
- __publicField(this, "bar", bar);
623
- __publicField(this, "frame", frame);
624
- __publicField(this, "el");
625
- __publicField(this, "hasInput", !1);
626
- __publicField(this, "inputs", /* @__PURE__ */ new Map());
627
- __publicField(this, "errors", /* @__PURE__ */ new Map());
627
+ this.bar = bar;
628
+ this.frame = frame;
629
+ this.hasInput = !1;
630
+ this.inputs = /* @__PURE__ */ new Map();
631
+ this.errors = /* @__PURE__ */ new Map();
628
632
  let v = frame.view, children = [];
629
633
  for (let field of v.fields) {
630
634
  let id = `${bar.instanceId}-f-${field.name}`, label = h("label", { class: "qb-form-label", for: id, "data-required": field.required ? "" : null }, field.type === "checkbox" ? "" : field.label ?? field.name), control = this.control(field, id), error = h("div", { class: "qb-field-error", hidden: !0, id: `${id}-err` });
@@ -714,13 +718,11 @@ var GridRenderer = class extends ListRenderer {
714
718
  }
715
719
  }, ChatRenderer = class {
716
720
  constructor(bar, frame) {
717
- __publicField(this, "bar", bar);
718
- __publicField(this, "frame", frame);
719
- __publicField(this, "el");
720
- __publicField(this, "hasInput", !0);
721
- __publicField(this, "turnEls", []);
722
- __publicField(this, "emptyEl");
723
- __publicField(this, "raf", 0);
721
+ this.bar = bar;
722
+ this.frame = frame;
723
+ this.hasInput = !0;
724
+ this.turnEls = [];
725
+ this.raf = 0;
724
726
  this.el = h("div", { class: bar.cls("qb-chat", "chat"), role: "log", "aria-live": "polite", tabindex: "-1" });
725
727
  }
726
728
  update() {
@@ -737,22 +739,39 @@ var GridRenderer = class extends ListRenderer {
737
739
  this.emptyEl && (this.emptyEl.remove(), this.emptyEl = void 0);
738
740
  let stick = this.el.scrollTop + this.el.clientHeight >= this.el.scrollHeight - 40;
739
741
  turns.forEach((turn, i) => {
740
- let sig = `${turn.text.length}|${turn.streaming}|${turn.error ?? ""}|${turn.tools.map((t) => t.state).join()}`, existing = this.turnEls[i];
742
+ let toolsSig = turn.tools.map((t) => `${t.state}:${t.label}`).join("|"), mdSig = `${turn.text.length}|${turn.streaming}|${turn.tools.length > 0}`, errSig = turn.error ?? "", sig = `${mdSig}|${errSig}|${toolsSig}`, existing = this.turnEls[i];
741
743
  if (existing && existing.sig === sig) return;
742
- let el;
743
- if (turn.role === "user") el = h("div", { class: "qb-msg-user" }, turn.text);
744
- else {
745
- let head = h("div", { class: "qb-msg-head" }, renderIcon("sparkles", 13), this.bar.aiName), tools = turn.tools.length ? h(
746
- "div",
747
- { class: "qb-tools" },
744
+ if (turn.role === "user") {
745
+ let el = h("div", { class: "qb-msg-user" }, turn.text);
746
+ existing ? existing.el.replaceWith(el) : this.el.append(el), this.turnEls[i] = { el, sig };
747
+ return;
748
+ }
749
+ let entry = existing;
750
+ if (!entry || !entry.md) {
751
+ let head = h("div", { class: "qb-msg-head" }, renderIcon("sparkles", 13), this.bar.aiName), toolsEl = h("div", { class: "qb-tools", hidden: !0 }), md = h("div", { class: "qb-md" }), errEl = h("div", { class: "qb-msg-error", hidden: !0 }), el = h("div", { class: "qb-msg-ai" }, head, toolsEl, md, errEl);
752
+ existing ? existing.el.replaceWith(el) : this.el.append(el), entry = { el, sig, md, toolsEl, errEl }, this.turnEls[i] = entry;
753
+ } else
754
+ entry.sig = sig;
755
+ if (entry.toolsSig !== toolsSig) {
756
+ entry.toolsSig = toolsSig;
757
+ let toolsEl = entry.toolsEl;
758
+ turn.tools.length ? (toolsEl.hidden = !1, toolsEl.replaceChildren(
748
759
  ...turn.tools.map((t) => {
749
760
  let icon = renderIcon(t.state === "running" ? "loader" : t.state === "done" ? "check" : "x", 12);
750
761
  return t.state === "running" && icon.classList.add("qb-spin"), h("span", { class: "qb-tool", "data-state": t.state }, icon, t.label);
751
762
  })
752
- ) : null, md = h("div", { class: "qb-md" }), html = this.bar.md(turn.text);
753
- turn.streaming && (html += turn.text || !turn.tools.length ? '<span class="qb-caret"></span>' : ""), md.innerHTML = html, el = h("div", { class: "qb-msg-ai" }, head, tools, md, turn.error ? h("div", { class: "qb-msg-error" }, turn.error) : null);
763
+ )) : (toolsEl.hidden = !0, toolsEl.childElementCount && toolsEl.replaceChildren());
764
+ }
765
+ if (entry.mdSig !== mdSig) {
766
+ entry.mdSig = mdSig;
767
+ let html = this.bar.md(turn.text);
768
+ turn.streaming && (html += turn.text || !turn.tools.length ? '<span class="qb-caret"></span>' : ""), entry.md.innerHTML = html;
769
+ }
770
+ if (entry.errSig !== errSig) {
771
+ entry.errSig = errSig;
772
+ let errEl = entry.errEl;
773
+ errEl.hidden = !errSig, errEl.textContent = errSig;
754
774
  }
755
- existing ? existing.el.replaceWith(el) : this.el.append(el), this.turnEls[i] = { el, sig };
756
775
  }), stick && (this.el.scrollTop = this.el.scrollHeight);
757
776
  }
758
777
  empty() {
@@ -828,55 +847,45 @@ var GridRenderer = class extends ListRenderer {
828
847
  // src/ui/bar.ts
829
848
  var VIEW_TYPES = /* @__PURE__ */ new Set(["list", "grid", "detail", "form", "chat"]), isView = (x) => !!x && typeof x == "object" && VIEW_TYPES.has(x.type), DEFAULT_LINKS = "nav a[href], header a[href], aside a[href], [data-qikbar-index] a[href]", DEFAULT_ACTIONS_HOTKEY = "mod+.", toolName = (s) => s.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64), frameCounter = 0, Bar = class {
830
849
  constructor(config = {}) {
831
- __publicField(this, "config");
832
- __publicField(this, "instanceId", uid("qikbar"));
833
- __publicField(this, "storageAdapter");
834
- __publicField(this, "storage");
835
- __publicField(this, "frecency");
836
- __publicField(this, "registrations", /* @__PURE__ */ new Map());
837
- __publicField(this, "regCounter", 0);
838
- __publicField(this, "sources", /* @__PURE__ */ new Set());
839
- __publicField(this, "sourceExt", /* @__PURE__ */ new WeakMap());
840
- __publicField(this, "itemExt", /* @__PURE__ */ new WeakMap());
841
- __publicField(this, "extensions", /* @__PURE__ */ new Map());
842
- __publicField(this, "configExtensions", []);
843
- __publicField(this, "configSources", []);
844
- __publicField(this, "ids", /* @__PURE__ */ new WeakMap());
845
- __publicField(this, "listeners", /* @__PURE__ */ new Map());
846
- __publicField(this, "stack", []);
847
- __publicField(this, "_open", !1);
848
- __publicField(this, "rootCache", null);
849
- __publicField(this, "routeItems", []);
850
- __publicField(this, "autoItems", []);
851
- __publicField(this, "shortcutItems", []);
852
- __publicField(this, "aiOptions");
853
- __publicField(this, "ai");
854
- __publicField(this, "dom");
855
- __publicField(this, "renderer");
856
- __publicField(this, "panel");
857
- __publicField(this, "toastState");
858
- __publicField(this, "toastTimer");
859
- __publicField(this, "toastId", 0);
860
- __publicField(this, "hud");
861
- __publicField(this, "confirmState");
862
- __publicField(this, "argMode");
863
- __publicField(this, "seq", new SequenceMatcher());
864
- __publicField(this, "prevFocus", null);
865
- __publicField(this, "teardown", []);
866
- __publicField(this, "appliedVars", []);
867
- __publicField(this, "scheduled", !1);
868
- __publicField(this, "scrollLock");
869
- __publicField(this, "closeTimer");
870
- __publicField(this, "destroyed", !1);
871
- __publicField(this, "styleEl");
872
- __publicField(this, "searchEventTimer");
873
- __publicField(this, "webmcpCleanup");
874
- __publicField(this, "labelCache");
850
+ this.instanceId = uid("qikbar");
851
+ this.registrations = /* @__PURE__ */ new Map();
852
+ this.regCounter = 0;
853
+ this.sources = /* @__PURE__ */ new Set();
854
+ this.sourceExt = /* @__PURE__ */ new WeakMap();
855
+ this.itemExt = /* @__PURE__ */ new WeakMap();
856
+ this.extensions = /* @__PURE__ */ new Map();
857
+ this.configExtensions = [];
858
+ this.configSources = [];
859
+ this.ids = /* @__PURE__ */ new WeakMap();
860
+ this.listeners = /* @__PURE__ */ new Map();
861
+ this.stack = [];
862
+ this._open = !1;
863
+ this.rootCache = null;
864
+ this.rootItemSet = null;
865
+ this.rootById = null;
866
+ this.pinList = [];
867
+ this.pinSet = /* @__PURE__ */ new Set();
868
+ this.aliasMap = {};
869
+ this.aliasById = /* @__PURE__ */ new Map();
870
+ this.routeItems = [];
871
+ this.autoItems = [];
872
+ this.shortcutItems = [];
873
+ this.crumbSig = null;
874
+ this.footerLeftSig = null;
875
+ this.footerRightSig = null;
876
+ this.themeSig = null;
877
+ this.toastId = 0;
878
+ this.seq = new SequenceMatcher();
879
+ this.prevFocus = null;
880
+ this.teardown = [];
881
+ this.appliedVars = [];
882
+ this.scheduled = !1;
883
+ this.destroyed = !1;
875
884
  // ─── Semantic search ─────────────────────────────────────────────────────
876
- __publicField(this, "vectors", /* @__PURE__ */ new Map());
877
- __publicField(this, "semanticWarned", !1);
885
+ this.vectors = /* @__PURE__ */ new Map();
886
+ this.semanticWarned = !1;
878
887
  // ─── Keyboard ────────────────────────────────────────────────────────────
879
- __publicField(this, "onGlobalKeyDown", (e) => {
888
+ this.onGlobalKeyDown = (e) => {
880
889
  if (this.destroyed || e.defaultPrevented || e.isComposing) return;
881
890
  let hotkeys = this.config.hotkey === !1 ? [] : [].concat(this.config.hotkey ?? "mod+k"), inField = isEditable(e.target);
882
891
  if (hotkeys.some((hk) => matchesHotkey(e, hk) && (!inField || allowedInInput(hk)))) {
@@ -897,14 +906,14 @@ var VIEW_TYPES = /* @__PURE__ */ new Set(["list", "grid", "detail", "form", "cha
897
906
  e.preventDefault();
898
907
  let frame = this.createFrame({ type: "root" }), act = this.actionsFor(item, frame)[0];
899
908
  act && this.runAction(frame, item, act, void 0, "shortcut");
900
- });
901
- __publicField(this, "onGlobalClick", (e) => {
909
+ };
910
+ this.onGlobalClick = (e) => {
902
911
  let trigger = e.target?.closest?.("[data-qikbar-open]");
903
912
  if (!trigger || this.destroyed) return;
904
913
  let target = trigger.getAttribute("data-qikbar-open");
905
914
  (target ? target !== this.instanceId && target !== this.config.namespace : this.isInline) || (e.preventDefault(), this.open({ query: trigger.getAttribute("data-qikbar-query") ?? void 0 }));
906
- });
907
- __publicField(this, "onDialogKeyDown", (e) => {
915
+ };
916
+ this.onDialogKeyDown = (e) => {
908
917
  if (e.stopPropagation(), e.isComposing || e.keyCode === 229) return;
909
918
  let frame = this.top;
910
919
  if (!frame) return;
@@ -964,8 +973,8 @@ var VIEW_TYPES = /* @__PURE__ */ new Set(["list", "grid", "detail", "form", "cha
964
973
  return;
965
974
  }
966
975
  e.key === "Backspace" && this.stack.length > 1 && e.target === this.dom?.input && !this.dom.input.value && !e.repeat && (e.preventDefault(), this.pop());
967
- });
968
- if (this.config = { ...config }, this.storageAdapter = config.storage ?? defaultStorage(), this.storage = scopedStorage(this.storageAdapter, config.namespace ?? "qikbar"), this.frecency = new Frecency(this.storage), this.applyConfig(config, !0), !(typeof document > "u") && (this.listen(document, "keydown", this.onGlobalKeyDown, !0), this.listen(document, "click", this.onGlobalClick, !0), this.applyWebMCP(), this.inlineTarget())) {
976
+ };
977
+ if (this.config = { ...config }, this.storageAdapter = config.storage ?? defaultStorage(), this.storage = scopedStorage(this.storageAdapter, config.namespace ?? "qikbar"), this.frecency = new Frecency(this.storage), this.syncPersonalization(), this.applyConfig(config, !0), !(typeof document > "u") && (this.listen(document, "keydown", this.onGlobalKeyDown, !0), this.listen(document, "click", this.onGlobalClick, !0), this.applyWebMCP(), this.inlineTarget())) {
969
978
  let start = () => this.open({ focus: !1 });
970
979
  document.readyState === "loading" ? this.listen(document, "DOMContentLoaded", start) : start();
971
980
  }
@@ -1025,7 +1034,7 @@ var VIEW_TYPES = /* @__PURE__ */ new Set(["list", "grid", "detail", "form", "cha
1025
1034
  open(options = {}) {
1026
1035
  if (this.destroyed || typeof document > "u") return;
1027
1036
  if (this.mount(), clearTimeout(this.closeTimer), !this._open) {
1028
- this._open = !0, this.prevFocus = document.activeElement, this.rootCache = null, this.autoIndex(), this.resetToRoot(), this.applyTheme();
1037
+ this._open = !0, this.prevFocus = document.activeElement, this.syncPersonalization(), this.clearRootCache(), this.autoIndex(), this.resetToRoot(), this.applyTheme();
1029
1038
  let dom = this.dom;
1030
1039
  dom.root.dataset.qbState = "open";
1031
1040
  let vv = typeof window < "u" ? window.visualViewport : void 0;
@@ -1063,7 +1072,7 @@ var VIEW_TYPES = /* @__PURE__ */ new Set(["list", "grid", "detail", "form", "cha
1063
1072
  };
1064
1073
  }
1065
1074
  addSource(source) {
1066
- return this.sources.add(source), () => {
1075
+ return this.sources.add(source), this._open && this.top?.view.type === "root" && this.top.query.trim() && this.searchSources(this.top), () => {
1067
1076
  this.sources.delete(source);
1068
1077
  for (let f of this.stack) f.sourceResults?.delete(source.id);
1069
1078
  this.invalidate();
@@ -1134,35 +1143,46 @@ var VIEW_TYPES = /* @__PURE__ */ new Set(["list", "grid", "detail", "form", "cha
1134
1143
  return this.rootItems();
1135
1144
  }
1136
1145
  // ─── Pins & aliases ──────────────────────────────────────────────────────
1146
+ syncPersonalization() {
1147
+ this.pinList = this.storage.get("pins") ?? [], this.pinSet = new Set(this.pinList), this.aliasMap = this.storage.get("aliases") ?? {}, this.aliasById = /* @__PURE__ */ new Map();
1148
+ for (let [alias, target] of Object.entries(this.aliasMap)) this.aliasById.set(target, alias);
1149
+ }
1137
1150
  get personalize() {
1138
1151
  return this.config.personalize !== !1;
1139
1152
  }
1153
+ isPinned(id) {
1154
+ return this.pinSet.has(id);
1155
+ }
1140
1156
  pins() {
1141
- return this.storage.get("pins") ?? [];
1157
+ return [...this.pinList];
1142
1158
  }
1143
- pin(id, pinned = !this.pins().includes(id)) {
1144
- let list = this.pins().filter((x) => x !== id);
1145
- pinned && list.unshift(id), this.storage.set("pins", list);
1146
- let item = this.rootItems().find((i) => this.idOf(i) === id);
1159
+ pin(id, pinned = !this.pinSet.has(id)) {
1160
+ let list = this.pinList.filter((x) => x !== id);
1161
+ pinned && list.unshift(id), this.pinList = list, this.pinSet = new Set(list), this.storage.set("pins", list);
1162
+ let item = this.rootItemById(id);
1147
1163
  item && this.track({ type: pinned ? "pin" : "unpin", item: this.eventItem(item) }), this.invalidateRoot();
1148
1164
  }
1149
1165
  aliases() {
1150
- return this.storage.get("aliases") ?? {};
1166
+ return { ...this.aliasMap };
1151
1167
  }
1152
1168
  aliasOf(id) {
1153
- for (let [alias, target] of Object.entries(this.aliases())) if (target === id) return alias;
1169
+ return this.aliasById.get(id);
1154
1170
  }
1155
1171
  setAlias(id, alias) {
1156
- let map = { ...this.aliases() };
1157
- for (let [k, v] of Object.entries(map)) v === id && delete map[k];
1172
+ let map = { ...this.aliasMap }, prev = this.aliasById.get(id);
1173
+ prev !== void 0 && (delete map[prev], this.aliasById.delete(id));
1158
1174
  let clean = alias == null ? "" : normalizeAlias(alias);
1159
- clean && (map[clean] = id), this.storage.set("aliases", map);
1160
- let item = this.rootItems().find((i) => this.idOf(i) === id);
1175
+ if (clean) {
1176
+ let displaced = map[clean];
1177
+ displaced !== void 0 && this.aliasById.delete(displaced), map[clean] = id, this.aliasById.set(id, clean);
1178
+ }
1179
+ this.aliasMap = map, this.storage.set("aliases", map);
1180
+ let item = this.rootItemById(id);
1161
1181
  item && this.track({ type: "alias", item: this.eventItem(item), alias: clean || null }), this.invalidateRoot();
1162
1182
  }
1163
1183
  /** Whether pin/alias actions apply to this item. */
1164
1184
  personalizable(item, frame) {
1165
- return !this.personalize || frame.view.type !== "root" || isFallback(item) ? !1 : !this.idOf(item).startsWith("qikbar.") && this.rootItems().includes(item);
1185
+ return !this.personalize || frame.view.type !== "root" || isFallback(item) ? !1 : !this.idOf(item).startsWith("qikbar.") && this.hasRootItem(item);
1166
1186
  }
1167
1187
  aliasForm(item) {
1168
1188
  let id = this.idOf(item), current = this.aliasOf(id);
@@ -1179,9 +1199,9 @@ var VIEW_TYPES = /* @__PURE__ */ new Set(["list", "grid", "detail", "form", "cha
1179
1199
  required: !0,
1180
1200
  defaultValue: current ?? "",
1181
1201
  validate: (value) => {
1182
- let alias = normalizeAlias(String(value ?? "")), owner = this.aliases()[alias];
1202
+ let alias = normalizeAlias(String(value ?? "")), owner = this.aliasMap[alias];
1183
1203
  if (owner && owner !== id) {
1184
- let other = this.rootItems().find((i) => this.idOf(i) === owner);
1204
+ let other = this.rootItemById(owner);
1185
1205
  return this.t("aliasTaken", { alias, title: other?.title ?? owner });
1186
1206
  }
1187
1207
  }
@@ -1293,8 +1313,17 @@ var VIEW_TYPES = /* @__PURE__ */ new Set(["list", "grid", "detail", "form", "cha
1293
1313
  idOf(item) {
1294
1314
  return item.id ?? this.ids.get(item) ?? item.title;
1295
1315
  }
1316
+ clearRootCache() {
1317
+ this.rootCache = null, this.rootItemSet = null, this.rootById = null;
1318
+ }
1319
+ hasRootItem(item) {
1320
+ return this.rootItems(), this.rootItemSet.has(item);
1321
+ }
1322
+ rootItemById(id) {
1323
+ return this.rootItems(), this.rootById.get(id);
1324
+ }
1296
1325
  invalidateRoot() {
1297
- if (this.rootCache = null, this._open) {
1326
+ if (this.clearRootCache(), this._open) {
1298
1327
  for (let f of this.stack)
1299
1328
  f.actionCache = void 0, f.view.type === "root" && this.computeRows(f);
1300
1329
  this.renderer?.refresh?.(), this.invalidate();
@@ -1302,15 +1331,15 @@ var VIEW_TYPES = /* @__PURE__ */ new Set(["list", "grid", "detail", "form", "cha
1302
1331
  }
1303
1332
  rootItems() {
1304
1333
  if (this.rootCache) return this.rootCache;
1305
- let out = [], seen = /* @__PURE__ */ new Set(), add = (item, prefix) => {
1334
+ let out = [], itemSet = /* @__PURE__ */ new Set(), byId = /* @__PURE__ */ new Map(), add = (item, prefix) => {
1306
1335
  try {
1307
1336
  if (item.when && !item.when()) return;
1308
1337
  } catch {
1309
1338
  return;
1310
1339
  }
1311
1340
  let id = item.id ?? `${prefix}:${item.section ?? ""}:${item.title}`;
1312
- for (; seen.has(id); ) id += "'";
1313
- seen.add(id), this.ids.set(item, id), out.push(item);
1341
+ for (; byId.has(id); ) id += "'";
1342
+ byId.set(id, item), itemSet.add(item), this.ids.set(item, id), out.push(item);
1314
1343
  };
1315
1344
  for (let c of this.config.commands ?? []) add(c, "cmd");
1316
1345
  for (let c of this.routeItems) add(c, "route");
@@ -1329,12 +1358,12 @@ var VIEW_TYPES = /* @__PURE__ */ new Set(["list", "grid", "detail", "form", "cha
1329
1358
  view: { type: "chat" }
1330
1359
  },
1331
1360
  "qb"
1332
- ), this.rootCache = out, this.shortcutItems = out.filter((i) => i.shortcut), out;
1361
+ ), this.rootCache = out, this.rootItemSet = itemSet, this.rootById = byId, this.shortcutItems = out.filter((i) => i.shortcut), out;
1333
1362
  }
1334
1363
  autoIndex() {
1335
1364
  let opt = this.config.autoIndex;
1336
1365
  if (!opt || typeof document > "u") {
1337
- this.autoItems.length && (this.autoItems = [], this.rootCache = null);
1366
+ this.autoItems.length && (this.autoItems = [], this.clearRootCache());
1338
1367
  return;
1339
1368
  }
1340
1369
  let o = opt === !0 ? {} : opt, items = [], seen = /* @__PURE__ */ new Set();
@@ -1376,7 +1405,7 @@ var VIEW_TYPES = /* @__PURE__ */ new Set(["list", "grid", "detail", "form", "cha
1376
1405
  }
1377
1406
  });
1378
1407
  }
1379
- this.autoItems = items, this.rootCache = null;
1408
+ this.autoItems = items, this.clearRootCache();
1380
1409
  }
1381
1410
  // ─── Frames ──────────────────────────────────────────────────────────────
1382
1411
  createFrame(view, ext, args) {
@@ -1437,7 +1466,7 @@ var VIEW_TYPES = /* @__PURE__ */ new Set(["list", "grid", "detail", "form", "cha
1437
1466
  let key = v.type === "root" ? this.idOf(e.item) : e.item.id ?? `${g.title}:${e.item.title}`;
1438
1467
  for (; keys.has(key); ) key += "'";
1439
1468
  keys.add(key);
1440
- let row = { kind: "item", key, item: e.item, positions: e.positions, index: itemRows.length };
1469
+ let row = { kind: "item", key, item: e.item, positions: e.positions, index: itemRows.length, rowIndex: rows.length };
1441
1470
  rows.push(row), itemRows.push(row);
1442
1471
  }
1443
1472
  }
@@ -1451,21 +1480,19 @@ var VIEW_TYPES = /* @__PURE__ */ new Set(["list", "grid", "detail", "form", "cha
1451
1480
  let q = frame.query.trim(), items = this.rootItems(), groups = [], bySection = /* @__PURE__ */ new Map(), group = (title) => {
1452
1481
  let g = bySection.get(title);
1453
1482
  return g || (g = { title, entries: [] }, bySection.set(title, g), groups.push(g)), g;
1454
- }, byId = () => new Map(items.map((i) => [this.idOf(i), i]));
1483
+ };
1455
1484
  if (!q) {
1456
1485
  let shown = /* @__PURE__ */ new Set();
1457
- if (this.personalize) {
1458
- let map = byId();
1459
- for (let id of this.pins()) {
1460
- let item = map.get(id);
1486
+ if (this.personalize)
1487
+ for (let id of this.pinList) {
1488
+ let item = this.rootItemById(id);
1461
1489
  !item || shown.has(item) || (group(this.t("pinned")).entries.push({ item }), shown.add(item));
1462
1490
  }
1463
- }
1464
1491
  let recentsLimit = this.config.recents === !1 ? 0 : typeof this.config.recents == "number" ? this.config.recents : 4;
1465
1492
  if (recentsLimit) {
1466
- let map = byId(), added = 0;
1493
+ let added = 0;
1467
1494
  for (let id of this.frecency.top(recentsLimit * 2 + shown.size)) {
1468
- let item = map.get(id);
1495
+ let item = this.rootItemById(id);
1469
1496
  if (!(!item || item.searchOnly || shown.has(item)) && (group(this.t("recent")).entries.push({ item }), shown.add(item), ++added >= recentsLimit))
1470
1497
  break;
1471
1498
  }
@@ -1482,12 +1509,12 @@ var VIEW_TYPES = /* @__PURE__ */ new Set(["list", "grid", "detail", "form", "cha
1482
1509
  let g = group(source.title ?? this.t("results")), list = source.filter ? rank(results, q) : results.map((item) => ({ item, positions: matchItem(item, q)?.positions }));
1483
1510
  for (let r of list.slice(0, source.limit ?? 8)) g.entries.push({ item: r.item, positions: r.positions });
1484
1511
  }
1485
- }, aliased = this.personalize ? this.aliases()[normalizeAlias(q)] : void 0, aliasItem = aliased ? byId().get(aliased) : void 0;
1512
+ }, aliased = this.personalize ? this.aliasMap[normalizeAlias(q)] : void 0, aliasItem = aliased ? this.rootItemById(aliased) : void 0;
1486
1513
  aliasItem && group(aliasItem.section ?? this.t("commands")).entries.push({ item: aliasItem }), addSources("top");
1487
- let pins = this.personalize ? new Set(this.pins()) : void 0, ranked = rank(items, q, {
1514
+ let pins = this.personalize ? this.pinSet : void 0, now = Date.now(), ranked = rank(items, q, {
1488
1515
  boost: (i) => {
1489
1516
  let id = this.idOf(i);
1490
- return this.frecency.score(id) * 0.3 + (pins?.has(id) ? 0.15 : 0);
1517
+ return this.frecency.score(id, now) * 0.3 + (pins?.has(id) ? 0.15 : 0);
1491
1518
  },
1492
1519
  limit: 300
1493
1520
  });
@@ -1570,7 +1597,7 @@ var VIEW_TYPES = /* @__PURE__ */ new Set(["list", "grid", "detail", "form", "cha
1570
1597
  try {
1571
1598
  let candidates = this.rootItems().filter((i) => !this.idOf(i).startsWith("qikbar."));
1572
1599
  if (opt.sources) for (let list of frame.sourceResults?.values() ?? []) candidates.push(...list);
1573
- let keyOf = (i) => this.rootItems().includes(i) ? this.idOf(i) : `src:${i.id ?? i.title}`, missing = candidates.filter((i) => this.vectors.get(keyOf(i))?.text !== embedText(i));
1600
+ let keyOf = (i) => this.hasRootItem(i) ? this.idOf(i) : `src:${i.id ?? i.title}`, missing = candidates.filter((i) => this.vectors.get(keyOf(i))?.text !== embedText(i));
1574
1601
  for (let i = 0; i < missing.length; i += 128) {
1575
1602
  let batch = missing.slice(i, i + 128), vecs = await opt.embed(batch.map(embedText), { signal });
1576
1603
  if (signal.aborted) return;
@@ -1730,7 +1757,7 @@ var VIEW_TYPES = /* @__PURE__ */ new Set(["list", "grid", "detail", "form", "cha
1730
1757
  keepOpen: !0,
1731
1758
  run: () => (this.toggleMark(frame, item), !1)
1732
1759
  }), this.personalizable(item, frame)) {
1733
- let id = this.idOf(item), pinned = this.pins().includes(id), alias = this.aliasOf(id);
1760
+ let id = this.idOf(item), pinned = this.isPinned(id), alias = this.aliasOf(id);
1734
1761
  acts.push({
1735
1762
  title: pinned ? this.t("unpin") : this.t("pin"),
1736
1763
  icon: "pin",
@@ -1993,12 +2020,12 @@ var VIEW_TYPES = /* @__PURE__ */ new Set(["list", "grid", "detail", "form", "cha
1993
2020
  })
1994
2021
  );
1995
2022
  return [...local.map((item) => ({ item, section: item.section ?? "Commands" })), ...remote.flat()].map(({ item, section }, n) => {
1996
- let id = this.rootItems().includes(item) ? this.idOf(item) : item.id && !found.has(item.id) ? item.id : `${section}#${n}`;
2023
+ let id = this.hasRootItem(item) ? this.idOf(item) : item.id && !found.has(item.id) ? item.id : `${section}#${n}`;
1997
2024
  return found.set(id, item), { id, title: item.title, subtitle: item.subtitle, section, description: item.description, href: item.href ?? item.url };
1998
2025
  });
1999
2026
  }
2000
2027
  async agentTools(chatFrame, signal) {
2001
- let found = /* @__PURE__ */ new Map(), lookup = (id) => found.get(id) ?? this.rootItems().find((i) => this.idOf(i) === id), tools = [
2028
+ let found = /* @__PURE__ */ new Map(), lookup = (id) => found.get(id) ?? this.rootItemById(id), tools = [
2002
2029
  {
2003
2030
  definition: {
2004
2031
  name: "search",
@@ -2203,29 +2230,33 @@ ${opts.message}` : opts.title) : !1) : (this.confirmState?.resolve(!1), new Prom
2203
2230
  e.target !== p.input && e.preventDefault();
2204
2231
  }), dom.dialog.append(p.el), this.isTouch || p.input.focus());
2205
2232
  let list = this.panelActions();
2206
- p.selected = Math.min(p.selected, Math.max(0, list.length - 1));
2207
- let children = [], section;
2208
- list.forEach((act, i) => {
2209
- !p.filter && act.section && act.section !== section && children.push(h("div", { class: "qb-section" }, act.section)), section = act.section;
2210
- let shortcut = act.shortcut ?? (i === 0 && !p.filter ? "enter" : i === 1 && !p.filter ? "mod+enter" : void 0), el = h(
2211
- "div",
2212
- {
2213
- class: "qb-action",
2214
- role: "option",
2215
- id: `${this.instanceId}-action-${i}`,
2216
- "aria-selected": i === p.selected ? "true" : "false",
2217
- "data-style": act.style ?? "default",
2218
- onClick: () => this.runFromPanel(act),
2219
- onPointermove: () => {
2220
- p.selected !== i && (p.selected = i, this.renderPanel());
2221
- }
2222
- },
2223
- renderIcon(act.icon ?? "dot", 15),
2224
- h("span", { class: "qb-action-title" }, this.actionTitle(act)),
2225
- shortcut ? renderKbd(shortcut) : null
2226
- );
2227
- children.push(el);
2228
- }), list.length || children.push(h("div", { class: "qb-empty-desc", style: "padding:10px 8px" }, this.t("noMatchingActions"))), p.list.replaceChildren(...children), p.input.setAttribute("aria-activedescendant", `${this.instanceId}-action-${p.selected}`), p.list.querySelector("[aria-selected=true]")?.scrollIntoView({ block: "nearest" });
2233
+ if (p.selected = Math.min(p.selected, Math.max(0, list.length - 1)), !p.actionEls || p.filterRendered !== p.filter) {
2234
+ p.filterRendered = p.filter;
2235
+ let children = [], actionEls = [], section;
2236
+ list.forEach((act, i) => {
2237
+ !p.filter && act.section && act.section !== section && children.push(h("div", { class: "qb-section" }, act.section)), section = act.section;
2238
+ let shortcut = act.shortcut ?? (i === 0 && !p.filter ? "enter" : i === 1 && !p.filter ? "mod+enter" : void 0), el = h(
2239
+ "div",
2240
+ {
2241
+ class: "qb-action",
2242
+ role: "option",
2243
+ id: `${this.instanceId}-action-${i}`,
2244
+ "aria-selected": "false",
2245
+ "data-style": act.style ?? "default",
2246
+ onClick: () => this.runFromPanel(act),
2247
+ onPointermove: () => {
2248
+ p.selected !== i && (p.selected = i, this.renderPanel());
2249
+ }
2250
+ },
2251
+ renderIcon(act.icon ?? "dot", 15),
2252
+ h("span", { class: "qb-action-title" }, this.actionTitle(act)),
2253
+ shortcut ? renderKbd(shortcut) : null
2254
+ );
2255
+ children.push(el), actionEls.push(el);
2256
+ }), list.length || children.push(h("div", { class: "qb-empty-desc", style: "padding:10px 8px" }, this.t("noMatchingActions"))), p.list.replaceChildren(...children), p.actionEls = actionEls, p.selectedEl = void 0;
2257
+ }
2258
+ let nextEl = p.actionEls[p.selected];
2259
+ p.selectedEl && p.selectedEl !== nextEl && p.selectedEl.setAttribute("aria-selected", "false"), nextEl && (nextEl.setAttribute("aria-selected", "true"), nextEl.scrollIntoView({ block: "nearest" })), p.selectedEl = nextEl, p.input.setAttribute("aria-activedescendant", `${this.instanceId}-action-${p.selected}`);
2229
2260
  }
2230
2261
  // ─── DOM ─────────────────────────────────────────────────────────────────
2231
2262
  cls(base, slot) {
@@ -2336,16 +2367,21 @@ ${opts.message}` : opts.title) : !1) : (this.confirmState?.resolve(!1), new Prom
2336
2367
  applyTheme() {
2337
2368
  let root = this.dom?.root;
2338
2369
  if (!root) return;
2339
- let { vars, appearance } = resolveThemeVars(this.config.theme, this.resolveAppearance());
2340
- root.dataset.qbAppearance = appearance;
2341
- let preset = typeof this.config.theme == "string" ? this.config.theme : this.config.theme?.preset;
2342
- preset ? root.dataset.qbTheme = preset : delete root.dataset.qbTheme;
2343
- for (let name of this.appliedVars) root.style.removeProperty(name);
2344
- this.appliedVars = [];
2345
- for (let [k, v] of Object.entries(vars)) {
2346
- if (v == null || v === "") continue;
2347
- let name = cssVarName(k);
2348
- root.style.setProperty(name, v), this.appliedVars.push(name);
2370
+ let { vars, appearance } = resolveThemeVars(this.config.theme, this.resolveAppearance()), preset = typeof this.config.theme == "string" ? this.config.theme : this.config.theme?.preset, entries = Object.entries(vars), sig = `${appearance}|${preset ?? ""}`;
2371
+ for (let i = 0; i < entries.length; i++) {
2372
+ let [k, v] = entries[i];
2373
+ v != null && v !== "" && (sig += `|${k}=${v}`);
2374
+ }
2375
+ if (sig !== this.themeSig) {
2376
+ this.themeSig = sig, root.dataset.qbAppearance = appearance, preset ? root.dataset.qbTheme = preset : delete root.dataset.qbTheme;
2377
+ for (let name of this.appliedVars) root.style.removeProperty(name);
2378
+ this.appliedVars = [];
2379
+ for (let i = 0; i < entries.length; i++) {
2380
+ let [k, v] = entries[i];
2381
+ if (v == null || v === "") continue;
2382
+ let name = cssVarName(k);
2383
+ root.style.setProperty(name, v), this.appliedVars.push(name);
2384
+ }
2349
2385
  }
2350
2386
  }
2351
2387
  watchAppearance() {
@@ -2400,7 +2436,11 @@ ${opts.message}` : opts.title) : !1) : (this.confirmState?.resolve(!1), new Prom
2400
2436
  let dom = this.dom, v = frame.view, depth = this.stack.length, hasInput = this.renderer?.hasInput ?? !0;
2401
2437
  dom.back.hidden = depth <= 1;
2402
2438
  let crumbTitle = depth > 1 ? v.title ?? (v.type === "chat" ? this.aiName : void 0) : void 0;
2403
- if (dom.crumb.hidden = !crumbTitle || !hasInput, crumbTitle && hasInput && dom.crumb.replaceChildren(...[renderIcon(frame.ext?.ext.icon, 13), h("span", null, crumbTitle)].filter(Boolean)), dom.searchIcon.hidden = depth > 1 || !!this.argMode, this.argMode) {
2439
+ if (dom.crumb.hidden = !crumbTitle || !hasInput, crumbTitle && hasInput) {
2440
+ let extIcon = frame.ext?.ext.icon, sig = `${crumbTitle}|${typeof extIcon == "string" ? extIcon : frame.ext?.ext.name ?? ""}`;
2441
+ sig !== this.crumbSig && (this.crumbSig = sig, dom.crumb.replaceChildren(...[renderIcon(extIcon, 13), h("span", null, crumbTitle)].filter(Boolean)));
2442
+ } else this.crumbSig !== null && (this.crumbSig = null);
2443
+ if (dom.searchIcon.hidden = depth > 1 || !!this.argMode, this.argMode) {
2404
2444
  let m = this.argMode;
2405
2445
  if (dom.input.hidden = !0, dom.title.hidden = !0, dom.args.dataset.for !== this.idOf(m.item)) {
2406
2446
  dom.args.dataset.for = this.idOf(m.item);
@@ -2428,7 +2468,7 @@ ${opts.message}` : opts.title) : !1) : (this.confirmState?.resolve(!1), new Prom
2428
2468
  }
2429
2469
  dom.args.hidden = !1;
2430
2470
  } else {
2431
- dom.args.hidden = !0, delete dom.args.dataset.for, dom.args.replaceChildren(), dom.input.hidden = !hasInput, dom.title.hidden = hasInput, hasInput || (dom.title.textContent = v.title ?? "");
2471
+ dom.args.hidden = !0, dom.args.dataset.for !== void 0 && delete dom.args.dataset.for, dom.args.childElementCount && dom.args.replaceChildren(), dom.input.hidden = !hasInput, dom.title.hidden = hasInput, hasInput || (dom.title.textContent = v.title ?? "");
2432
2472
  let placeholder = this.renderer?.placeholder?.() ?? v.placeholder ?? (v.type === "root" ? this.config.placeholder ?? this.t("placeholder") : this.t("searchPlaceholder"));
2433
2473
  dom.input.placeholder !== placeholder && (dom.input.placeholder = placeholder), dom.input.value !== frame.query && (dom.input.value = frame.query);
2434
2474
  }
@@ -2439,17 +2479,25 @@ ${opts.message}` : opts.title) : !1) : (this.confirmState?.resolve(!1), new Prom
2439
2479
  }
2440
2480
  renderFooter(frame) {
2441
2481
  let dom = this.dom;
2442
- !this.toastState || !this._open ? this.renderFooterLeft(frame) : this.renderToast();
2443
- let right = [], custom = this.renderer?.footerPrimary?.(), actions = this.actionsFor(this.selectedItem(frame), frame), primary = custom ?? (actions[0] ? { title: this.actionTitle(actions[0]), hotkey: "enter", run: () => this.runPrimary(frame) } : void 0);
2444
- this.argMode ? right.push(this.footerButton(this.t("runItem", { title: this.argMode.item.title }), "enter", () => this.submitArgs(), !0)) : primary && right.push(this.footerButton(primary.title, primary.hotkey, primary.run, !0)), actions.length > (custom ? 0 : 1) && !this.argMode && right.push(h("span", { class: "qb-footer-sep" }), this.footerButton(this.t("actions"), this.actionsHotkey, () => this.openPanel())), dom.footerRight.replaceChildren(...right);
2482
+ !this.toastState || !this._open ? this.renderFooterLeft(frame) : dom.footerLeft.firstElementChild?.classList.contains("qb-toast") || this.renderToast();
2483
+ let custom = this.renderer?.footerPrimary?.(), actions = this.actionsFor(this.selectedItem(frame), frame), primary = custom ?? (actions[0] ? { title: this.actionTitle(actions[0]), hotkey: "enter", run: () => this.runPrimary(frame) } : void 0), showActions = actions.length > (custom ? 0 : 1) && !this.argMode, primaryTitle = this.argMode ? this.t("runItem", { title: this.argMode.item.title }) : primary?.title ?? "", primaryHotkey = this.argMode ? "enter" : primary?.hotkey ?? "";
2484
+ this.footerPrimaryRun = this.argMode ? () => this.submitArgs() : primary?.run;
2485
+ let sig = `${primaryTitle}|${primaryHotkey}|${showActions ? `${this.t("actions")}|${this.actionsHotkey}` : ""}`;
2486
+ if (sig === this.footerRightSig) return;
2487
+ this.footerRightSig = sig;
2488
+ let right = [];
2489
+ (this.argMode || primary) && right.push(this.footerButton(primaryTitle, primaryHotkey, () => this.footerPrimaryRun?.(), !0)), showActions && right.push(h("span", { class: "qb-footer-sep" }), this.footerButton(this.t("actions"), this.actionsHotkey, () => this.openPanel())), dom.footerRight.replaceChildren(...right);
2445
2490
  }
2446
2491
  renderFooterLeft(frame) {
2447
- let dom = this.dom, v = frame.view, left = [];
2448
- if (frame.marked?.size)
2449
- left.push(renderIcon("check-square", 14), h("span", null, this.t("selected", { count: frame.marked.size })));
2450
- else if (this.stack.length > 1 && v.title) {
2451
- let icon = renderIcon(frame.ext?.ext.icon ?? "layers", 14);
2452
- icon && left.push(icon), left.push(h("span", null, v.title));
2492
+ let dom = this.dom, v = frame.view, marked = frame.marked?.size ?? 0, title = this.stack.length > 1 ? v.title ?? "" : "", extIcon = frame.ext?.ext.icon, sig = marked ? `m:${marked}:${this.t("selected", { count: marked })}` : title ? `t:${title}:${typeof extIcon == "string" ? extIcon : frame.ext?.ext.name ?? ""}` : this.config.footer ? `f:${this.config.footer}` : this.config.branding ? "b" : "";
2493
+ if (sig === this.footerLeftSig) return;
2494
+ this.footerLeftSig = sig;
2495
+ let left = [];
2496
+ if (marked)
2497
+ left.push(renderIcon("check-square", 14), h("span", null, this.t("selected", { count: marked })));
2498
+ else if (title) {
2499
+ let icon = renderIcon(extIcon ?? "layers", 14);
2500
+ icon && left.push(icon), left.push(h("span", null, title));
2453
2501
  } else if (this.config.footer) left.push(h("span", null, this.config.footer));
2454
2502
  else if (this.config.branding) {
2455
2503
  let a = h("a", { class: "qb-brand", href: "https://qikbar.com", target: "_blank", rel: "noopener" }, renderIcon("command", 13), "qikbar");
@@ -2478,7 +2526,7 @@ ${opts.message}` : opts.title) : !1) : (this.confirmState?.resolve(!1), new Prom
2478
2526
  );
2479
2527
  };
2480
2528
  if (this._open && this.dom) {
2481
- this.hud?.remove(), this.hud = void 0, t ? this.dom.footerLeft.replaceChildren(build("qb-toast")) : this.top && this.renderFooterLeft(this.top);
2529
+ this.hud?.remove(), this.hud = void 0, this.footerLeftSig = null, t ? this.dom.footerLeft.replaceChildren(build("qb-toast")) : this.top && this.renderFooterLeft(this.top);
2482
2530
  return;
2483
2531
  }
2484
2532
  typeof document > "u" || (this.mount(), this.hud?.remove(), this.hud = void 0, !(!t || !this.dom) && (this.applyTheme(), this.hud = build("qb-hud"), this.dom.root.append(this.hud)));
@@ -2488,7 +2536,7 @@ ${opts.message}` : opts.title) : !1) : (this.confirmState?.resolve(!1), new Prom
2488
2536
  if (!dom) return;
2489
2537
  let c = this.confirmState;
2490
2538
  if (!c) {
2491
- dom.layer.replaceChildren();
2539
+ dom.layer.childElementCount && dom.layer.replaceChildren();
2492
2540
  return;
2493
2541
  }
2494
2542
  if (dom.layer.firstChild) return;
@@ -2552,4 +2600,4 @@ export {
2552
2600
  isView,
2553
2601
  normalizeAlias
2554
2602
  };
2555
- //# sourceMappingURL=bar-P3SCR4SJ.js.map
2603
+ //# sourceMappingURL=bar-4WGKZKVL.js.map