@qikbar/qikbar 0.1.0 → 0.2.1

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 (67) hide show
  1. package/README.md +30 -1
  2. package/bin/qikbar.mjs +203 -0
  3. package/dist/ai/embeddings.d.ts +51 -0
  4. package/dist/ai/index.d.ts +4 -0
  5. package/dist/ai/mcp.d.ts +84 -0
  6. package/dist/ai.js +27 -9
  7. package/dist/chunks/{bar-D5CSPT3U.js → bar-P3SCR4SJ.js} +684 -160
  8. package/dist/chunks/bar-P3SCR4SJ.js.map +7 -0
  9. package/dist/chunks/chunk-24EBWTCF.js +271 -0
  10. package/dist/chunks/chunk-24EBWTCF.js.map +7 -0
  11. package/dist/chunks/{chunk-I77YSUJN.js → chunk-INTEVQYK.js} +7 -3
  12. package/dist/chunks/{chunk-I77YSUJN.js.map → chunk-INTEVQYK.js.map} +2 -2
  13. package/dist/chunks/{chunk-VXTYD56F.js → chunk-JHQAIXM7.js} +9 -4
  14. package/dist/chunks/{chunk-VXTYD56F.js.map → chunk-JHQAIXM7.js.map} +2 -2
  15. package/dist/chunks/{chunk-2ADXL7KQ.js → chunk-MRHKJ2FZ.js} +63 -2
  16. package/dist/chunks/{chunk-2ADXL7KQ.js.map → chunk-MRHKJ2FZ.js.map} +3 -3
  17. package/dist/chunks/{chunk-IJ3WUM3T.js → chunk-R2AY6LRL.js} +35 -4
  18. package/dist/chunks/chunk-R2AY6LRL.js.map +7 -0
  19. package/dist/chunks/chunk-TIM4VBM4.js +98 -0
  20. package/dist/chunks/chunk-TIM4VBM4.js.map +7 -0
  21. package/dist/chunks/{chunk-HBBSETRF.js → chunk-WO6XXQ3H.js} +47 -6
  22. package/dist/chunks/chunk-WO6XXQ3H.js.map +7 -0
  23. package/dist/chunks/launcher-B5MGOPEQ.js +37 -0
  24. package/dist/chunks/launcher-B5MGOPEQ.js.map +7 -0
  25. package/dist/core/labels.d.ts +98 -0
  26. package/dist/core/launcher.d.ts +8 -0
  27. package/dist/core/lazy.d.ts +12 -0
  28. package/dist/core/types.d.ts +138 -2
  29. package/dist/element/index.d.ts +56 -0
  30. package/dist/element.js +145 -0
  31. package/dist/element.js.map +7 -0
  32. package/dist/extensions.js +1 -1
  33. package/dist/index.d.ts +4 -1
  34. package/dist/index.js +19 -7
  35. package/dist/locales/index.d.ts +24 -0
  36. package/dist/locales.js +812 -0
  37. package/dist/locales.js.map +7 -0
  38. package/dist/qikbar.global.js +68 -25
  39. package/dist/qikbar.global.js.map +4 -4
  40. package/dist/react.js +7 -6
  41. package/dist/react.js.map +2 -2
  42. package/dist/server/index.d.ts +19 -0
  43. package/dist/server.js +38 -2
  44. package/dist/server.js.map +2 -2
  45. package/dist/solid/index.d.ts +42 -0
  46. package/dist/solid.js +92 -0
  47. package/dist/solid.js.map +7 -0
  48. package/dist/styles.css +34 -3
  49. package/dist/svelte/index.d.ts +58 -0
  50. package/dist/svelte.js +54 -0
  51. package/dist/svelte.js.map +7 -0
  52. package/dist/theme.js +1 -1
  53. package/dist/ui/bar.d.ts +89 -3
  54. package/dist/ui/icons.d.ts +5 -0
  55. package/dist/ui/markdown.d.ts +3 -1
  56. package/dist/ui/views.d.ts +8 -0
  57. package/dist/ui/webmcp.d.ts +33 -0
  58. package/dist/utils.js +1 -1
  59. package/dist/vue/index.d.ts +74 -0
  60. package/dist/vue.js +121 -0
  61. package/dist/vue.js.map +7 -0
  62. package/package.json +45 -4
  63. package/dist/chunks/bar-D5CSPT3U.js.map +0 -7
  64. package/dist/chunks/chunk-6TC6G2C5.js +0 -107
  65. package/dist/chunks/chunk-6TC6G2C5.js.map +0 -7
  66. package/dist/chunks/chunk-HBBSETRF.js.map +0 -7
  67. package/dist/chunks/chunk-IJ3WUM3T.js.map +0 -7
@@ -1,9 +1,25 @@
1
- "use strict";var Qikbar=(()=>{var ne=Object.defineProperty;var _t=Object.getOwnPropertyDescriptor;var Ft=Object.getOwnPropertyNames;var Vt=Object.prototype.hasOwnProperty;var Nt=(s,e,t)=>e in s?ne(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var q=(s,e,t)=>()=>{if(t)throw t[0];try{return s&&(e=s(s=0)),e}catch(i){throw t=[i],i}};var we=(s,e)=>{for(var t in e)ne(s,t,{get:e[t],enumerable:!0})},Kt=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ft(e))!Vt.call(s,r)&&r!==t&&ne(s,r,{get:()=>e[r],enumerable:!(i=_t(e,r))||i.enumerable});return s};var zt=s=>Kt(ne({},"__esModule",{value:!0}),s);var m=(s,e,t)=>Nt(s,typeof e!="symbol"?e+"":e,t);function O(s){let e=We.get(s);return e||(e=s.trim().split(/\s+/).map(t=>{let i=t.toLowerCase().split("+");t.endsWith("++")&&i.splice(i.length-2,2,"+");let r={key:"",meta:!1,ctrl:!1,alt:!1,shift:!1};for(let n of i)n==="mod"?C?r.meta=!0:r.ctrl=!0:n==="cmd"||n==="meta"||n==="command"?r.meta=!0:n==="ctrl"||n==="control"?r.ctrl=!0:n==="alt"||n==="option"||n==="opt"?r.alt=!0:n==="shift"?r.shift=!0:r.key=jt[n]??n;return r}),We.set(s,e),e)}function Dt(s){let e=s.code;return e?.startsWith("Key")?e.slice(3).toLowerCase():e?.startsWith("Digit")?e.slice(5):(s.key??"").toLowerCase()}function Ge(s,e){if(s.metaKey!==e.meta||s.ctrlKey!==e.ctrl||s.altKey!==e.alt)return!1;let t=Dt(s);return e.shift!==s.shiftKey&&!(e.key.length===1&&!/[a-z0-9]/.test(e.key))?!1:t===e.key||(s.key??"").toLowerCase()===e.key}function E(s,e){let t=O(e);return t.length===1&&Ge(s,t[0])}function $(s){return O(s).map(e=>{let t=C?Bt:Ut,i=[];return C?(e.ctrl&&i.push(t.ctrl),e.alt&&i.push(t.alt),e.shift&&i.push(t.shift),e.meta&&i.push(t.meta)):(e.ctrl&&i.push(t.ctrl),e.meta&&i.push(t.meta),e.alt&&i.push(t.alt),e.shift&&i.push(t.shift)),i.push(t[e.key]??(e.key.length===1?e.key.toUpperCase():Qt(e.key))),i})}function Qt(s){return s.charAt(0).toUpperCase()+s.slice(1)}function j(s){let e=s;if(!e||!e.tagName)return!1;let t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}function U(s){let e=O(s);return e.length===1&&(e[0].meta||e[0].ctrl||e[0].alt)}var C,jt,We,Bt,Ut,z,H=q(()=>{"use strict";C=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/i.test(navigator.userAgentData?.platform??navigator.platform??navigator.userAgent),jt={esc:"escape",return:"enter",space:" ",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright",del:"delete",plus:"+"},We=new Map;Bt={meta:"\u2318",ctrl:"\u2303",alt:"\u2325",shift:"\u21E7",enter:"\u21B5",escape:"esc",backspace:"\u232B",delete:"\u2326",arrowup:"\u2191",arrowdown:"\u2193",arrowleft:"\u2190",arrowright:"\u2192",tab:"\u21E5"," ":"Space"},Ut={meta:"Win",ctrl:"Ctrl",alt:"Alt",shift:"Shift",enter:"\u21B5",escape:"Esc",backspace:"\u232B",delete:"Del",arrowup:"\u2191",arrowdown:"\u2193",arrowleft:"\u2190",arrowright:"\u2192",tab:"Tab"," ":"Space"};z=class{constructor(e=900){m(this,"timeout",e);m(this,"buffer",[]);m(this,"timer")}feed(e,t){if(["Shift","Meta","Control","Alt"].includes(e.key))return[];this.buffer.push(e),this.buffer.length>4&&this.buffer.shift(),clearTimeout(this.timer),this.timer=setTimeout(()=>this.buffer=[],this.timeout);let i=[];for(let r of t){let n=O(r);if(n.length>this.buffer.length)continue;let o=this.buffer.slice(-n.length);n.every((a,c)=>Ge(o[c],a))&&i.push(r)}return i.length&&(this.buffer=[]),i}reset(){this.buffer=[],clearTimeout(this.timer)}}});function Je(s){return{...s,type:"list"}}function Ye(s){return{...s,type:"grid"}}function Xe(s){return{...s,type:"detail"}}function Ze(s){return{...s,type:"form"}}function et(s={}){return{...s,type:"chat"}}function ke(s){return s}function tt(s){return s}function it(s){return s}function rt(s){return s}var M,oe=q(()=>{"use strict";M={copy(s,e={}){return{title:"Copy to Clipboard",icon:"copy",shortcut:"mod+c",...e,async run(t){let i=await t.copy(typeof s=="function"?s():s);t.toast({title:i?"Copied to clipboard":"Copy failed",style:i?"success":"failure"})}}},open(s,e={}){return{title:"Open in Browser",icon:"external",...e,run:t=>t.openUrl(s)}},navigate(s,e={}){return{title:"Open",icon:"arrow-right",...e,run:t=>t.navigate(s)}},navigateNewTab(s,e={}){return{title:"Open in New Tab",icon:"external",shortcut:"mod+enter",...e,run:t=>t.navigate(s,{newTab:!0})}},push(s,e,t={}){return{title:s,icon:"chevron-right",...t,run:i=>typeof e=="function"?e(i):e}},ask(s,e={}){return{title:"Ask AI",icon:"sparkles",shortcut:"mod+j",...e,run:()=>({type:"chat",prompt:s})}}}});function ae(){let s=new Map;return{getItem:e=>s.get(e)??null,setItem:(e,t)=>{s.set(e,t)},removeItem:e=>{s.delete(e)}}}function P(){try{let s=globalThis.localStorage,e="__qikbar__";return s.setItem(e,"1"),s.removeItem(e),s}catch{return ae()}}function Q(s,e){return{get(t){try{let i=s.getItem(`${e}:${t}`);return i==null?void 0:JSON.parse(i)}catch{return}},set(t,i){try{i===void 0?s.removeItem(`${e}:${t}`):s.setItem(`${e}:${t}`,JSON.stringify(i))}catch{}},remove(t){try{s.removeItem(`${e}:${t}`)}catch{}}}}var W=q(()=>{"use strict"});function dt(s,e){async function*t(i,r={}){for await(let n of s.stream({messages:[{role:"user",content:i}],system:r.system??e,signal:r.signal}))if(n.type==="text")yield n.text;else if(n.type==="error")throw new Error(n.error)}return{provider:s,stream:t,async ask(i,r){let n="";for await(let o of t(i,r))n+=o;return n}}}function Xt(s){if(s===void 0)return"Done.";if(typeof s=="string")return s;try{return JSON.stringify(s)}catch{return String(s)}}async function*ht(s){let{provider:e,system:t,signal:i}=s,r=e.tools===!1?[]:s.tools??[],n=[...s.messages],o=s.maxSteps??6;for(let a=0;a<o;a++){let c=[],l,h="";for await(let d of e.stream({messages:[...n],system:t,tools:r.length&&a<o-1?r.map(p=>p.definition):void 0,signal:i}))d.type==="text"?(h+=d.text,yield d):d.type==="tool_call"?c.push(d.call):d.type==="error"?yield d:d.type==="done"&&(l=d.message);if(l??(l={role:"assistant",content:h,toolCalls:c.length?c:void 0}),n.push(l),yield{type:"message",message:l},!c.length||i.aborted)return;for(let d of c){let p=r.find(y=>y.definition.name===d.name),g=p?.label?.(d.args)??d.name;yield{type:"tool_start",call:d,label:g};let f,b=!1;if(d.error)f=d.error,b=!0;else if(!p)f=`Unknown tool "${d.name}".`,b=!0;else try{f=Xt(await p.run(d.args,i))}catch(y){f=y instanceof Error?y.message:String(y),b=!0}f.length>ct&&(f=`${f.slice(0,ct)}\u2026 (truncated)`);let v={role:"tool",toolCallId:d.id,toolName:d.name,content:f,...b?{isError:b}:{}};if(n.push(v),yield{type:"message",message:v},yield{type:"tool_end",call:d,ok:!b,result:f},i.aborted)return}}}var ct,pt=q(()=>{"use strict";ct=12e3});var D,Ce=q(()=>{"use strict";D=class{constructor(e){m(this,"storage",e);m(this,"entries");this.entries=e.get("frecency")??{}}record(e){let t=this.entries[e]??{c:0,t:0};t.c++,t.t=Date.now(),this.entries[e]=t;let i=Object.keys(this.entries);if(i.length>200){i.sort((r,n)=>this.entries[r].t-this.entries[n].t);for(let r of i.slice(0,i.length-200))delete this.entries[r]}this.storage.set("frecency",this.entries)}score(e){let t=this.entries[e];if(!t)return 0;let i=Math.pow(.5,(Date.now()-t.t)/2592e5),r=Math.log2(1+t.c)*i;return r/(1+r)}top(e){return Object.keys(this.entries).map(t=>[t,this.score(t)]).filter(([,t])=>t>.02).sort((t,i)=>i[1]-t[1]).slice(0,e).map(([t])=>t)}clear(){this.entries={},this.storage.remove("frecency")}}});function T(s){let e=s.toLowerCase();if(!/[^\u0000-\u007f]/.test(e))return e;let t=e.normalize("NFD").replace(/[̀-ͯ]/g,"");return t.length===e.length?t:e}function X(s,e){if(e===0)return 14;let t=s[e-1];if(Zt.has(t))return 10;let i=s[e];return t!==t.toUpperCase()&&i!==i.toLowerCase()?8:/[0-9]/.test(i)&&!/[0-9]/.test(t)?10/2:0}function Le(s,e,t){let i=0,r=-2,n=0;for(let o=0;o<t.length;o++){let a=t[o],c=16+X(e,a);if(a===r+1)n++,c+=6+Math.min(n,3);else if(n=0,o>0){let l=a-r-1;c-=3+1*Math.min(l-1,12)}e[a]===s[o]&&(c+=1),i+=c,r=a}return i}function F(s,e,t=T(e)){let i=s.length,r=t.length;if(i===0)return{score:0,positions:[]};if(i>r)return null;if(t===s)return{score:1,positions:Array.from({length:i},(f,b)=>b)};let n=0,o=-1;for(let f=0;f<r;f++)if(t[f]===s[n]&&(n++,n===i)){o=f;break}if(o<0)return null;n=i-1;let a=o;for(let f=o;f>=0;f--)if(t[f]===s[n]&&(n--,n<0)){a=f;break}let c=ut(s,e,t,a),l=c?Le(s,e,c):-1/0,h=0;for(let f=0;f<r-i+1&&h<4;f++){if(f===a||t[f]!==s[0]||X(e,f)===0)continue;h++;let b=ut(s,e,t,f);if(!b)continue;let v=Le(s,e,b);v>l&&(l=v,c=b)}if(!c)return null;let d=t.indexOf(s);for(let f=0;d>=0&&f<4;f++){let b=Array.from({length:i},(y,x)=>d+x),v=Le(s,e,b);v>l&&(l=v,c=b),d=t.indexOf(s,d+1)}let p=Math.min((r-i)*.15,6),g=(l-p)/(i*37);for(let f=0;f<c.length;f++){let b=c[f];(f===0||b!==c[f-1]+1)&&X(e,b)===0&&(g*=.72)}return g=Math.max(.01,Math.min(.99,g)),{score:g,positions:c}}function ut(s,e,t,i){let r=s.length,n=[],o=0;for(let a=i;a<t.length&&o<r;a++)if(t[a]===s[o]){if(o>0&&X(e,a)===0&&a!==n[n.length-1]+1){let c=ei(t,e,s,o,a+1);c>=0&&(a=c)}n.push(a),o++}return o===r?n:null}function ei(s,e,t,i,r){let n=t[i],o=t.length-i;for(let a=r;a<=s.length-o;a++)if(s[a]===n&&X(e,a)>0){let c=i+1;for(let l=a+1;l<s.length&&c<t.length;l++)s[l]===t[c]&&c++;return c===t.length?a:-1}return-1}function Re(s){let e=0;for(let t=0;t<s.length;t++){let i=s.charCodeAt(t);i>=97&&i<=122?e|=1<<i-97:i>=48&&i<=57&&(e|=1<<26)}return e}function ti(s){let e=ft.get(s);return(!e||e.title!==s.title)&&(e={mask:0,title:s.title,titleNorm:T(s.title),subtitle:s.subtitle?T(s.subtitle):"",keywords:s.keywords?s.keywords.map(T):[],section:s.section?T(s.section):"",description:s.description?T(s.description):""},e.mask=Re(`${e.titleNorm} ${e.subtitle} ${e.keywords.join(" ")} ${e.section} ${e.description}`),ft.set(s,e)),e}function Z(s,e){let t=T(e.trim());return t?mt(s,t,t.split(/\s+/).filter(Boolean),Re(t)):{score:0,positions:[]}}function mt(s,e,t,i){let r=ti(s);if((i&r.mask)!==i)return null;let n=F(e,r.title,r.titleNorm),o=0,a=new Set,c=!0;if(t.length>1||!n){for(let d of t){let p=0,g=F(d,r.title,r.titleNorm);if(g){p=g.score;for(let f of g.positions)a.add(f)}for(let f of r.keywords){let b=F(d,f,f);b&&b.score*.88>p&&(p=b.score*.88)}if(r.subtitle){let f=F(d,r.subtitle,r.subtitle);f&&f.score*.7>p&&(p=f.score*.7)}if(r.section){let f=F(d,r.section,r.section);f&&f.score*.5>p&&(p=f.score*.5)}if(p===0&&r.description&&d.length>2&&r.description.includes(d)&&(p=.3),p===0){c=!1;break}o+=p}o/=t.length}let l=0,h=[];if(n&&n.score>=o)l=n.score,h=n.positions;else if(c&&o>0)l=o*.95,h=[...a].sort((d,p)=>d-p);else if(n)l=n.score,h=n.positions;else return null;return r.titleNorm.startsWith(e)&&(l=Math.min(.995,l+.15)),{score:l,positions:h}}function L(s,e,t={}){let{boost:i,limit:r,threshold:n=.05}=t,o=[],a=T(e.trim()),c=a.split(/\s+/).filter(Boolean),l=Re(a);for(let g of s){let f=a?mt(g,a,c,l):{score:0,positions:[]};if(!f||a&&f.score<n)continue;let b=f.score+(g.priority??0)*.1;i&&(b+=i(g)),o.push({item:g,score:b,positions:f.positions})}let h=o.map((g,f)=>[g,f]);h.sort((g,f)=>f[0].score-g[0].score||g[1]-f[1]);let d=h.map(g=>g[0]),p=d[0]?.score??0;return a.length>=3&&p>=.6&&(d=d.filter(g=>g.score>=p*.55)),r?d.slice(0,r):d}var Zt,ft,Oe=q(()=>{"use strict";Zt=new Set([" ","-","_",".","/",":","\\","(","[","{",",","@","#",'"',"'",">","|","+","&"]);ft=new WeakMap});function ce(s,e=16){let t=$e[s];if(t)return`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${e}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${t}</svg>`}var $e,He=q(()=>{"use strict";$e={search:'<circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>',command:'<path d="M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3"/>',"arrow-right":'<path d="M5 12h14"/><path d="m12 5 7 7-7 7"/>',"arrow-left":'<path d="M19 12H5"/><path d="m12 19-7-7 7-7"/>',"arrow-up-right":'<path d="M7 17 17 7"/><path d="M7 7h10v10"/>',"chevron-right":'<path d="m9 18 6-6-6-6"/>',"chevron-left":'<path d="m15 18-6-6 6-6"/>',"chevron-down":'<path d="m6 9 6 6 6-6"/>',"corner-down-left":'<path d="M20 4v7a4 4 0 0 1-4 4H4"/><path d="m9 10-5 5 5 5"/>',external:'<path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>',link:'<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>',copy:'<rect x="8" y="8" width="14" height="14" rx="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/>',check:'<path d="M20 6 9 17l-5-5"/>',x:'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',plus:'<path d="M5 12h14"/><path d="M12 5v14"/>',minus:'<path d="M5 12h14"/>',home:'<path d="m3 10 9-7 9 7v10a2 2 0 0 1-2 2h-4v-7H9v7H5a2 2 0 0 1-2-2z"/>',settings:'<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>',user:'<circle cx="12" cy="8" r="4"/><path d="M20 21a8 8 0 0 0-16 0"/>',users:'<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>',file:'<path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5z"/><path d="M14 2v6h6"/>',"file-text":'<path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5z"/><path d="M14 2v6h6"/><path d="M16 13H8"/><path d="M16 17H8"/><path d="M10 9H8"/>',folder:'<path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/>',book:'<path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/>',bookmark:'<path d="m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z"/>',star:'<path d="m12 2 3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01z"/>',heart:'<path d="M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"/>',clock:'<circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/>',history:'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/><path d="M12 7v5l4 2"/>',calendar:'<rect x="3" y="4" width="18" height="18" rx="2"/><path d="M16 2v4"/><path d="M8 2v4"/><path d="M3 10h18"/>',calculator:'<rect x="4" y="2" width="16" height="20" rx="2"/><path d="M8 6h8"/><path d="M16 14v4"/><path d="M16 10h.01"/><path d="M12 10h.01"/><path d="M8 10h.01"/><path d="M12 14h.01"/><path d="M8 14h.01"/><path d="M12 18h.01"/><path d="M8 18h.01"/>',sun:'<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>',moon:'<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>',monitor:'<rect x="2" y="3" width="20" height="14" rx="2"/><path d="M8 21h8"/><path d="M12 17v4"/>',palette:'<circle cx="13.5" cy="6.5" r=".5" fill="currentColor"/><circle cx="17.5" cy="10.5" r=".5" fill="currentColor"/><circle cx="8.5" cy="7.5" r=".5" fill="currentColor"/><circle cx="6.5" cy="12.5" r=".5" fill="currentColor"/><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.93 0 1.65-.75 1.65-1.69 0-.44-.18-.84-.44-1.13-.29-.29-.44-.65-.44-1.13a1.64 1.64 0 0 1 1.67-1.67h2c3.05 0 5.56-2.5 5.56-5.55C21.97 6.01 17.46 2 12 2z"/>',sparkles:'<path d="M9.94 15.5A2 2 0 0 0 8.5 14.06l-6.14-1.58a.5.5 0 0 1 0-.96L8.5 9.94A2 2 0 0 0 9.94 8.5l1.58-6.14a.5.5 0 0 1 .96 0L14.06 8.5A2 2 0 0 0 15.5 9.94l6.14 1.58a.5.5 0 0 1 0 .96L15.5 14.06a2 2 0 0 0-1.44 1.44l-1.58 6.14a.5.5 0 0 1-.96 0z"/><path d="M20 3v4"/><path d="M22 5h-4"/>',bot:'<path d="M12 8V4H8"/><rect x="4" y="8" width="16" height="12" rx="2"/><path d="M2 14h2"/><path d="M20 14h2"/><path d="M15 13v2"/><path d="M9 13v2"/>',message:'<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>',send:'<path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/>',mail:'<rect x="2" y="4" width="20" height="16" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/>',bell:'<path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/>',"credit-card":'<rect x="2" y="5" width="20" height="14" rx="2"/><path d="M2 10h20"/>',key:'<circle cx="7.5" cy="15.5" r="5.5"/><path d="m21 2-9.6 9.6"/><path d="m15.5 7.5 3 3L22 7l-3-3"/>',lock:'<rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>',"log-out":'<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><path d="m16 17 5-5-5-5"/><path d="M21 12H9"/>',trash:'<path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/>',pencil:'<path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/>',eye:'<path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/>',download:'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/><path d="M12 15V3"/>',upload:'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m17 8-5-5-5 5"/><path d="M12 3v12"/>',refresh:'<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/>',filter:'<path d="M22 3H2l8 9.46V19l4 2v-8.54z"/>',globe:'<circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/>',code:'<path d="m16 18 6-6-6-6"/><path d="m8 6-6 6 6 6"/>',terminal:'<path d="m4 17 6-6-6-6"/><path d="M12 19h8"/>',hash:'<path d="M4 9h16"/><path d="M4 15h16"/><path d="M10 3 8 21"/><path d="M16 3l-2 18"/>',zap:'<path d="M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"/>',layers:'<path d="m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z"/><path d="m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"/><path d="m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"/>',grid:'<rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/>',list:'<path d="M8 6h13"/><path d="M8 12h13"/><path d="M8 18h13"/><path d="M3 6h.01"/><path d="M3 12h.01"/><path d="M3 18h.01"/>',image:'<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.09-3.09a2 2 0 0 0-2.82 0L6 21"/>',"git-branch":'<path d="M6 3v12"/><circle cx="18" cy="6" r="3"/><circle cx="6" cy="18" r="3"/><path d="M18 9a9 9 0 0 1-9 9"/>',package:'<path d="m7.5 4.27 9 5.15"/><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.3 7 8.7 5 8.7-5"/><path d="M12 22V12"/>',puzzle:'<path d="M19.44 7.85c-.05.38.09.76.36 1.02l1.57 1.57c.47.47.7 1.08.7 1.7s-.23 1.23-.7 1.7l-1.61 1.61a.98.98 0 0 1-.84.28c-.47-.07-.8-.48-.97-.92a2.5 2.5 0 1 0-3.21 3.21c.44.17.85.5.92.97a.98.98 0 0 1-.28.84l-1.61 1.61c-.47.47-1.08.7-1.7.7s-1.23-.23-1.7-.7l-1.57-1.57a1.2 1.2 0 0 0-1.02-.36c-.47.07-.8.48-.97.92a2.5 2.5 0 1 1-3.21-3.21c.44-.17.85-.5.92-.97a1.2 1.2 0 0 0-.36-1.02L2.7 13.7A2.4 2.4 0 0 1 2 12c0-.62.24-1.23.7-1.7l1.57-1.57c.26-.27.64-.4 1.02-.36.47.07.8.48.97.92a2.5 2.5 0 1 0 3.21-3.21c-.44-.17-.85-.5-.92-.97a1.2 1.2 0 0 1 .36-1.02L10.3 2.7c.47-.47 1.08-.7 1.7-.7s1.23.23 1.7.7l1.57 1.57c.26.27.64.4 1.02.36.47-.07.8-.48.97-.92a2.5 2.5 0 1 1 3.21 3.21c-.44.17-.85.5-.92.97Z"/>',info:'<circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/>',alert:'<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/>',"check-circle":'<circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/>',"x-circle":'<circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/>',loader:'<path d="M21 12a9 9 0 1 1-6.22-8.56"/>',circle:'<circle cx="12" cy="12" r="9"/>',dot:'<circle cx="12" cy="12" r="4" fill="currentColor"/>',"more-horizontal":'<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>',"layout-dashboard":'<rect x="3" y="3" width="7" height="9" rx="1"/><rect x="14" y="3" width="7" height="5" rx="1"/><rect x="14" y="12" width="7" height="9" rx="1"/><rect x="3" y="16" width="7" height="5" rx="1"/>',"bar-chart":'<path d="M3 3v18h18"/><path d="M18 17V9"/><path d="M13 17V5"/><path d="M8 17v-3"/>',inbox:'<path d="M22 12h-6l-2 3h-4l-2-3H2"/><path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"/>',tag:'<path d="M12.59 2.59A2 2 0 0 0 11.17 2H4a2 2 0 0 0-2 2v7.17a2 2 0 0 0 .59 1.42l8.7 8.7a2.43 2.43 0 0 0 3.42 0l6.58-6.58a2.43 2.43 0 0 0 0-3.42z"/><circle cx="7.5" cy="7.5" r=".5" fill="currentColor"/>',languages:'<path d="m5 8 6 6"/><path d="m4 14 6-6 2-3"/><path d="M2 5h12"/><path d="M7 2h1"/><path d="m22 22-5-10-5 10"/><path d="M14 18h6"/>',wand:'<path d="m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72"/><path d="m14 7 3 3"/><path d="M5 6v4"/><path d="M19 14v4"/><path d="M10 2v2"/><path d="M7 8H3"/><path d="M21 16h-4"/><path d="M11 3H9"/>',keyboard:'<rect x="2" y="4" width="20" height="16" rx="2"/><path d="M6 8h.01"/><path d="M10 8h.01"/><path d="M14 8h.01"/><path d="M18 8h.01"/><path d="M8 12h.01"/><path d="M12 12h.01"/><path d="M16 12h.01"/><path d="M7 16h10"/>',github:'<path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/>'}});function u(s,e,...t){let i=document.createElement(s);if(e)for(let r in e){let n=e[r];n==null||n===!1||(r==="class"?i.className=n:r==="style"&&typeof n=="object"?Object.assign(i.style,n):r.startsWith("on")&&typeof n=="function"?i.addEventListener(r.slice(2).toLowerCase(),n):r==="html"?i.innerHTML=n:r in i&&typeof n!="string"?i[r]=n:i.setAttribute(r,n===!0?"":String(n)))}return bt(i,t),i}function bt(s,e){for(let t of e)Array.isArray(t)?bt(s,t):t!=null&&t!==!1&&s.append(t instanceof Node?t:String(t))}function k(s,e=16){if(s==null||s==="")return null;let t=u("span",{class:"qb-icon","aria-hidden":"true"});if(typeof s=="function")t.append(s());else if(typeof Node<"u"&&s instanceof Node)t.append(s.cloneNode(!0));else if(typeof s=="object"&&"url"in s)t.append(u("img",{src:s.url,alt:s.alt??"",loading:"lazy",decoding:"async",draggable:"false"}));else if(typeof s=="object"&&"color"in s){t.classList.add("qb-icon-tinted"),t.style.setProperty("--qb-tint",yt(s.color));let i=k(s.icon??"dot",e);i&&t.append(...i.childNodes)}else if(typeof s=="string"){let i=ce(s,e);i?t.innerHTML=i:s.trimStart().startsWith("<svg")?t.innerHTML=s:ii.test(s)?t.append(u("img",{src:s,alt:"",loading:"lazy",decoding:"async",draggable:"false"})):(t.classList.add("qb-icon-text"),t.textContent=s)}return t}function R(s,e="qb-kbd"){let t=u("span",{class:"qb-kbds","aria-label":s});return $(s).forEach((i,r)=>{r>0&&t.append(u("span",{class:"qb-kbd-then"},"then"));for(let n of i)t.append(u("kbd",{class:e},n))}),t}function Pe(s,e){if(!e||e.length===0)return s;let t=document.createDocumentFragment(),i=0,r=0;for(;r<e.length;){let n=e[r],o=n;for(;r+1<e.length&&e[r+1]===o+1;)r++,o++;n>i&&t.append(s.slice(i,n)),t.append(u("mark",{class:"qb-match"},s.slice(n,o+1))),i=o+1,r++}return i<s.length&&t.append(s.slice(i)),t}function yt(s){return s?gt[s]??s:gt.default}function _e(s){let e=typeof s=="string"?s:s.value,t=typeof s=="string"?void 0:s.color,i=u("span",{class:"qb-tag"},e);return t&&i.style.setProperty("--qb-tint",yt(t)),i}function ri(s){let e=new Date(s),t=(e.getTime()-Date.now())/1e3,i=Math.abs(t);return V?i<60?V.format(Math.round(t),"second"):i<3600?V.format(Math.round(t/60),"minute"):i<86400?V.format(Math.round(t/3600),"hour"):i<86400*30?V.format(Math.round(t/86400),"day"):i<86400*365?V.format(Math.round(t/(86400*30)),"month"):V.format(Math.round(t/(86400*365)),"year"):e.toLocaleDateString()}function vt(s){let e=u("span",{class:"qb-accessory",title:s.tooltip}),t=k(s.icon,14);return t&&e.append(t),s.tag&&e.append(_e(s.tag)),s.text&&e.append(u("span",null,s.text)),s.date!=null&&e.append(u("time",{datetime:new Date(s.date).toISOString()},ri(s.date))),s.kbd&&e.append(R(s.kbd)),e}function xt(s="qb"){return`${s}-${(++ni).toString(36)}`}var ii,gt,V,ni,Fe=q(()=>{"use strict";H();He();ii=/^(https?:|\/|\.\.?\/|data:image\/|blob:)/;gt={default:"var(--qb-fg-muted)",gray:"var(--qb-fg-subtle)",blue:"#3b82f6",green:"#22c55e",yellow:"#eab308",orange:"#f97316",red:"#ef4444",purple:"#a855f7",pink:"#ec4899"};V=typeof Intl<"u"&&"RelativeTimeFormat"in Intl?new Intl.RelativeTimeFormat(void 0,{numeric:"auto",style:"short"}):null;ni=0});async function N(s){try{return await navigator.clipboard.writeText(s),!0}catch{try{let e=document.createElement("textarea");e.value=s,e.setAttribute("readonly",""),e.style.cssText="position:fixed;top:-1000px;opacity:0",document.body.append(e),e.select();let t=document.execCommand("copy");return e.remove(),t}catch{return!1}}}function ee(s,e){if(e){window.open(s,"_blank","noopener");return}let t=[...document.querySelectorAll("a[href]")].find(r=>r.getAttribute("href")===s&&!r.closest(".qb-root")&&(!r.target||r.target==="_self")&&!r.hasAttribute("download"));if(t){t.click();return}let i=document.createElement("a");i.href=s,i.style.display="none",document.body.append(i),i.click(),i.remove()}var de=q(()=>{"use strict"});function K(s){return`--qb-${s.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}`}function ue(s,e){let t=typeof s=="string"?{preset:s}:s??{},i=t.preset?Ve[t.preset]:void 0,r=i?.only??(t.preset==="light"?"light":t.preset==="dark"?"dark":e);return{vars:{...r==="dark"?i?.dark:i?.light,...t.vars,...r==="dark"?t.dark:t.light},appearance:r}}function wt(s,e=".qb-root"){let t=Object.entries(s).filter(([,i])=>i!=null&&i!=="").map(([i,r])=>` ${K(i)}: ${r};`).join(`
1
+ "use strict";var Qikbar=(()=>{var ce=Object.defineProperty;var ci=Object.getOwnPropertyDescriptor;var di=Object.getOwnPropertyNames;var hi=Object.prototype.hasOwnProperty;var pi=(s,e,t)=>e in s?ce(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var E=(s,e,t)=>()=>{if(t)throw t[0];try{return s&&(e=s(s=0)),e}catch(i){throw t=[i],i}};var de=(s,e)=>{for(var t in e)ce(s,t,{get:e[t],enumerable:!0})},ui=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of di(e))!hi.call(s,n)&&n!==t&&ce(s,n,{get:()=>e[n],enumerable:!(i=ci(e,n))||i.enumerable});return s};var fi=s=>ui(ce({},"__esModule",{value:!0}),s);var u=(s,e,t)=>pi(s,typeof e!="symbol"?e+"":e,t);function P(s){let e=rt.get(s);return e||(e=s.trim().split(/\s+/).map(t=>{let i=t.toLowerCase().split("+");t.endsWith("++")&&i.splice(i.length-2,2,"+");let n={key:"",meta:!1,ctrl:!1,alt:!1,shift:!1};for(let r of i)r==="mod"?R?n.meta=!0:n.ctrl=!0:r==="cmd"||r==="meta"||r==="command"?n.meta=!0:r==="ctrl"||r==="control"?n.ctrl=!0:r==="alt"||r==="option"||r==="opt"?n.alt=!0:r==="shift"?n.shift=!0:n.key=mi[r]??r;return n}),rt.set(s,e),e)}function gi(s){let e=s.code;return e?.startsWith("Key")?e.slice(3).toLowerCase():e?.startsWith("Digit")?e.slice(5):(s.key??"").toLowerCase()}function st(s,e){if(s.metaKey!==e.meta||s.ctrlKey!==e.ctrl||s.altKey!==e.alt)return!1;let t=gi(s);return e.shift!==s.shiftKey&&!(e.key.length===1&&!/[a-z0-9]/.test(e.key))?!1:t===e.key||(s.key??"").toLowerCase()===e.key}function M(s,e){let t=P(e);return t.length===1&&st(s,t[0])}function $(s){return P(s).map(e=>{let t=R?bi:yi,i=[];return R?(e.ctrl&&i.push(t.ctrl),e.alt&&i.push(t.alt),e.shift&&i.push(t.shift),e.meta&&i.push(t.meta)):(e.ctrl&&i.push(t.ctrl),e.meta&&i.push(t.meta),e.alt&&i.push(t.alt),e.shift&&i.push(t.shift)),i.push(t[e.key]??(e.key.length===1?e.key.toUpperCase():vi(e.key))),i})}function vi(s){return s.charAt(0).toUpperCase()+s.slice(1)}function H(s){let e=s;if(!e||!e.tagName)return!1;let t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}function Q(s){let e=P(s);return e.length===1&&(e[0].meta||e[0].ctrl||e[0].alt)}var R,mi,rt,bi,yi,D,F=E(()=>{"use strict";R=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/i.test(navigator.userAgentData?.platform??navigator.platform??navigator.userAgent),mi={esc:"escape",return:"enter",space:" ",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright",del:"delete",plus:"+"},rt=new Map;bi={meta:"\u2318",ctrl:"\u2303",alt:"\u2325",shift:"\u21E7",enter:"\u21B5",escape:"esc",backspace:"\u232B",delete:"\u2326",arrowup:"\u2191",arrowdown:"\u2193",arrowleft:"\u2190",arrowright:"\u2192",tab:"\u21E5"," ":"Space"},yi={meta:"Win",ctrl:"Ctrl",alt:"Alt",shift:"Shift",enter:"\u21B5",escape:"Esc",backspace:"\u232B",delete:"Del",arrowup:"\u2191",arrowdown:"\u2193",arrowleft:"\u2190",arrowright:"\u2192",tab:"Tab"," ":"Space"};D=class{constructor(e=900){u(this,"timeout",e);u(this,"buffer",[]);u(this,"timer")}feed(e,t){if(["Shift","Meta","Control","Alt"].includes(e.key))return[];this.buffer.push(e),this.buffer.length>4&&this.buffer.shift(),clearTimeout(this.timer),this.timer=setTimeout(()=>this.buffer=[],this.timeout);let i=[];for(let n of t){let r=P(n);if(r.length>this.buffer.length)continue;let o=this.buffer.slice(-r.length);r.every((a,c)=>st(o[c],a))&&i.push(n)}return i.length&&(this.buffer=[]),i}reset(){this.buffer=[],clearTimeout(this.timer)}}});var Ie={};de(Ie,{mountLauncher:()=>qi,resolveLauncher:()=>ki});function ki(s){if(s)return s===!0?{}:s==="touch"?{touchOnly:!0}:s}function qi(s,e,t,i){if(typeof document>"u")return()=>{};if(!document.getElementById(ot)){let o=document.createElement("style");o.id=ot,i&&(o.nonce=i),o.textContent=xi,document.head.append(o)}let n=document.createElement("button");n.type="button",n.className="qb-launcher",n.setAttribute("aria-label",s.label??e),n.title=s.label??e,n.dataset.position=s.position??"bottom-right",s.touchOnly&&(n.dataset.touchOnly=""),s.offset!=null&&n.style.setProperty("--qb-launcher-offset",`${s.offset}px`);let r=s.icon??wi;return r.trimStart().startsWith("<svg")?n.innerHTML=r:n.textContent=r,n.addEventListener("click",o=>{o.preventDefault(),t()}),document.body.append(n),()=>n.remove()}var ot,xi,wi,Ce=E(()=>{"use strict";ot="qikbar-launcher-styles",xi=`.qb-launcher{position:fixed;z-index:2147482999;bottom:calc(var(--qb-launcher-offset,20px) + env(safe-area-inset-bottom,0px));right:calc(var(--qb-launcher-offset,20px) + env(safe-area-inset-right,0px));width:52px;height:52px;display:grid;place-items:center;border:0;border-radius:999px;background:var(--qb-launcher-bg,#18181b);color:var(--qb-launcher-fg,#fafafa);box-shadow:0 10px 30px -8px rgba(0,0,0,.45),0 0 0 1px rgba(255,255,255,.08) inset;cursor:pointer;-webkit-tap-highlight-color:transparent;transition:transform .15s cubic-bezier(.2,.9,.3,1.3),box-shadow .15s;font:inherit}
2
+ .qb-launcher:hover{transform:scale(1.06)}
3
+ .qb-launcher:active{transform:scale(.94)}
4
+ .qb-launcher:focus-visible{outline:2px solid var(--qb-launcher-ring,#8b7dff);outline-offset:3px}
5
+ .qb-launcher[data-position=bottom-left]{right:auto;left:calc(var(--qb-launcher-offset,20px) + env(safe-area-inset-left,0px))}
6
+ .qb-launcher svg{width:22px;height:22px}
7
+ .qb-launcher[data-touch-only]{display:none}
8
+ @media (hover:none) and (pointer:coarse){.qb-launcher[data-touch-only]{display:grid}}
9
+ @media print{.qb-launcher{display:none}}
10
+ @media (prefers-color-scheme:light){:root:not(.dark):not([data-theme=dark]):not([data-mode=dark]) .qb-launcher{--qb-launcher-bg:#fff;--qb-launcher-fg:#18181b;box-shadow:0 10px 30px -10px rgba(0,0,0,.25),0 0 0 1px rgba(0,0,0,.08) inset}}
11
+ :root.light .qb-launcher,:root[data-theme=light] .qb-launcher,:root[data-mode=light] .qb-launcher{--qb-launcher-bg:#fff;--qb-launcher-fg:#18181b;box-shadow:0 10px 30px -10px rgba(0,0,0,.25),0 0 0 1px rgba(0,0,0,.08) inset}`,wi='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>'});function lt(s){return{...s,type:"list"}}function ct(s){return{...s,type:"grid"}}function dt(s){return{...s,type:"detail"}}function ht(s){return{...s,type:"form"}}function pt(s={}){return{...s,type:"chat"}}function Le(s){return s}function ut(s){return s}function ft(s){return s}function mt(s){return s}var A,pe=E(()=>{"use strict";A={copy(s,e={}){return{title:"Copy to Clipboard",labelKey:"copyToClipboard",icon:"copy",shortcut:"mod+c",...e,async run(t){let i=await t.copy(typeof s=="function"?s():s),n=t.labels;t.toast({title:i?n?.copied??"Copied to clipboard":n?.copyFailed??"Copy failed",style:i?"success":"failure"})}}},open(s,e={}){return{title:"Open in Browser",labelKey:"openInBrowser",icon:"external",...e,run:t=>t.openUrl(s)}},navigate(s,e={}){return{title:"Open",labelKey:"open",icon:"arrow-right",...e,run:t=>t.navigate(s)}},navigateNewTab(s,e={}){return{title:"Open in New Tab",labelKey:"openInNewTab",icon:"external",shortcut:"mod+enter",...e,run:t=>t.navigate(s,{newTab:!0})}},push(s,e,t={}){return{title:s,icon:"chevron-right",...t,run:i=>typeof e=="function"?e(i):e}},ask(s,e={}){return{title:"Ask AI",icon:"sparkles",shortcut:"mod+j",...e,run:()=>({type:"chat",prompt:s})}}}});function ue(){let s=new Map;return{getItem:e=>s.get(e)??null,setItem:(e,t)=>{s.set(e,t)},removeItem:e=>{s.delete(e)}}}function _(){try{let s=globalThis.localStorage,e="__qikbar__";return s.setItem(e,"1"),s.removeItem(e),s}catch{return ue()}}function G(s,e){return{get(t){try{let i=s.getItem(`${e}:${t}`);return i==null?void 0:JSON.parse(i)}catch{return}},set(t,i){try{i===void 0?s.removeItem(`${e}:${t}`):s.setItem(`${e}:${t}`,JSON.stringify(i))}catch{}},remove(t){try{s.removeItem(`${e}:${t}`)}catch{}}}}var J=E(()=>{"use strict"});function kt(s,e){async function*t(i,n={}){for await(let r of s.stream({messages:[{role:"user",content:i}],system:n.system??e,signal:n.signal}))if(r.type==="text")yield r.text;else if(r.type==="error")throw new Error(r.error)}return{provider:s,stream:t,async ask(i,n){let r="";for await(let o of t(i,n))r+=o;return r}}}function Si(s){if(s===void 0)return"Done.";if(typeof s=="string")return s;try{return JSON.stringify(s)}catch{return String(s)}}async function*qt(s){let{provider:e,system:t,signal:i}=s,n=e.tools===!1?[]:s.tools??[],r=[...s.messages],o=s.maxSteps??6;for(let a=0;a<o;a++){let c=[],l,d="";for await(let h of e.stream({messages:[...r],system:t,tools:n.length&&a<o-1?n.map(b=>b.definition):void 0,signal:i}))h.type==="text"?(d+=h.text,yield h):h.type==="tool_call"?c.push(h.call):h.type==="error"?yield h:h.type==="done"&&(l=h.message);if(l??(l={role:"assistant",content:d,toolCalls:c.length?c:void 0}),r.push(l),yield{type:"message",message:l},!c.length||i.aborted)return;for(let h of c){let b=n.find(y=>y.definition.name===h.name),v=b?.label?.(h.args)??h.name;yield{type:"tool_start",call:h,label:v};let m,p=!1;if(h.error)m=h.error,p=!0;else if(!b)m=`Unknown tool "${h.name}".`,p=!0;else try{m=Si(await b.run(h.args,i))}catch(y){m=y instanceof Error?y.message:String(y),p=!0}m.length>wt&&(m=`${m.slice(0,wt)}\u2026 (truncated)`);let g={role:"tool",toolCallId:h.id,toolName:h.name,content:m,...p?{isError:p}:{}};if(r.push(g),yield{type:"message",message:g},yield{type:"tool_end",call:h,ok:!p,result:m},i.aborted)return}}}var wt,Tt=E(()=>{"use strict";wt=12e3});var U,ze=E(()=>{"use strict";U=class{constructor(e){u(this,"storage",e);u(this,"entries");this.entries=e.get("frecency")??{}}record(e){let t=this.entries[e]??{c:0,t:0};t.c++,t.t=Date.now(),this.entries[e]=t;let i=Object.keys(this.entries);if(i.length>200){i.sort((n,r)=>this.entries[n].t-this.entries[r].t);for(let n of i.slice(0,i.length-200))delete this.entries[n]}this.storage.set("frecency",this.entries)}score(e){let t=this.entries[e];if(!t)return 0;let i=Math.pow(.5,(Date.now()-t.t)/2592e5),n=Math.log2(1+t.c)*i;return n/(1+n)}top(e){return Object.keys(this.entries).map(t=>[t,this.score(t)]).filter(([,t])=>t>.02).sort((t,i)=>i[1]-t[1]).slice(0,e).map(([t])=>t)}clear(){this.entries={},this.storage.remove("frecency")}}});function Rt(s,e={}){return s.replace(/\{(\w+)\}/g,(t,i)=>i in e?String(e[i]):t)}var me,Ot=E(()=>{"use strict";me={placeholder:"Search for commands, pages and more\u2026",searchPlaceholder:"Search\u2026",search:"Search",commandBar:"Command bar",results:"Results",back:"Back",noResults:"No results",nothingMatches:"Nothing matches \u201C{query}\u201D",loadFailed:"Couldn\u2019t load results",startTyping:"Start typing to search",useQueryWith:"Use \u201C{query}\u201D with\u2026",recent:"Recent",pinned:"Pinned",related:"Related",commands:"Commands",navigation:"Navigation",pages:"Pages",actions:"Actions",customize:"Customize",history:"History",extension:"Extension",kindCommand:"Command",kindPage:"Page",kindLink:"Link",run:"Run",runCommand:"Run Command",runItem:"Run {title}",open:"Open",openInNewTab:"Open in New Tab",openInBrowser:"Open in Browser",copyToClipboard:"Copy to Clipboard",copyLink:"Copy Link",copyUrl:"Copy URL",copyContent:"Copy Content",configure:"Configure {name}",clearHistory:"Clear Recent History",searchActions:"Search for actions\u2026",noMatchingActions:"No matching actions",pin:"Pin to Top",unpin:"Unpin",setAlias:"Set Alias\u2026",editAlias:"Edit Alias\u2026",removeAlias:"Remove Alias",alias:"Alias",aliasPlaceholder:"e.g. bv2",aliasDescription:"Type the alias to jump straight to \u201C{title}\u201D.",aliasSaved:"Alias \u201C{alias}\u201D saved",aliasRemoved:"Alias removed",aliasTaken:"\u201C{alias}\u201D is already used by {title}",select:"Select",deselect:"Deselect",selectAll:"Select All",clearSelection:"Clear Selection",selected:"{count} selected",copied:"Copied to clipboard",copyFailed:"Copy failed",somethingWentWrong:"Something went wrong",undo:"Undo",cancel:"Cancel",confirm:"Confirm",allow:"Allow",allowTool:"Allow {ai} to {tool}?",submit:"Submit",save:"Save",saveAndContinue:"Save and Continue",preferencesSaved:"Preferences saved",fieldRequired:"{field} is required",optional:"(optional)",copy:"Copy",copiedShort:"Copied",failed:"Failed",askAi:"Ask {ai}",askAiSubtitle:"Chat, or tell it what to do",askAnything:"Ask {ai} anything",askAnythingPlaceholder:"Ask {ai} anything\u2026",chatHint:"Ask a question or tell it what to do, like \u201Ctake me to billing\u201D.",chatSuggestions:"What can I do here?|Summarize this page",followUp:"Ask a follow-up\u2026",send:"Send",stop:"Stop",copyAnswer:"Copy Answer",copiedAnswer:"Copied answer",nothingToCopy:"Nothing to copy",newChat:"New Chat",aiNotConfigured:"AI is not configured",openCommandBar:"Open command bar"}});function S(s){let e=s.toLowerCase();if(!/[^\u0000-\u007f]/.test(e))return e;let t=e.normalize("NFD").replace(/[̀-ͯ]/g,"");return t.length===e.length?t:e}function ee(s,e){if(e===0)return 14;let t=s[e-1];if(Li.has(t))return 10;let i=s[e];return t!==t.toUpperCase()&&i!==i.toLowerCase()?8:/[0-9]/.test(i)&&!/[0-9]/.test(t)?10/2:0}function Ve(s,e,t){let i=0,n=-2,r=0;for(let o=0;o<t.length;o++){let a=t[o],c=16+ee(e,a);if(a===n+1)r++,c+=6+Math.min(r,3);else if(r=0,o>0){let l=a-n-1;c-=3+1*Math.min(l-1,12)}e[a]===s[o]&&(c+=1),i+=c,n=a}return i}function z(s,e,t=S(e)){let i=s.length,n=t.length;if(i===0)return{score:0,positions:[]};if(i>n)return null;if(t===s)return{score:1,positions:Array.from({length:i},(m,p)=>p)};let r=0,o=-1;for(let m=0;m<n;m++)if(t[m]===s[r]&&(r++,r===i)){o=m;break}if(o<0)return null;r=i-1;let a=o;for(let m=o;m>=0;m--)if(t[m]===s[r]&&(r--,r<0)){a=m;break}let c=Pt(s,e,t,a),l=c?Ve(s,e,c):-1/0,d=0;for(let m=0;m<n-i+1&&d<4;m++){if(m===a||t[m]!==s[0]||ee(e,m)===0)continue;d++;let p=Pt(s,e,t,m);if(!p)continue;let g=Ve(s,e,p);g>l&&(l=g,c=p)}if(!c)return null;let h=t.indexOf(s);for(let m=0;h>=0&&m<4;m++){let p=Array.from({length:i},(y,x)=>h+x),g=Ve(s,e,p);g>l&&(l=g,c=p),h=t.indexOf(s,h+1)}let b=Math.min((n-i)*.15,6),v=(l-b)/(i*37);for(let m=0;m<c.length;m++){let p=c[m];(m===0||p!==c[m-1]+1)&&ee(e,p)===0&&(v*=.72)}return v=Math.max(.01,Math.min(.99,v)),{score:v,positions:c}}function Pt(s,e,t,i){let n=s.length,r=[],o=0;for(let a=i;a<t.length&&o<n;a++)if(t[a]===s[o]){if(o>0&&ee(e,a)===0&&a!==r[r.length-1]+1){let c=Ri(t,e,s,o,a+1);c>=0&&(a=c)}r.push(a),o++}return o===n?r:null}function Ri(s,e,t,i,n){let r=t[i],o=t.length-i;for(let a=n;a<=s.length-o;a++)if(s[a]===r&&ee(e,a)>0){let c=i+1;for(let l=a+1;l<s.length&&c<t.length;l++)s[l]===t[c]&&c++;return c===t.length?a:-1}return-1}function Ke(s){let e=0;for(let t=0;t<s.length;t++){let i=s.charCodeAt(t);i>=97&&i<=122?e|=1<<i-97:i>=48&&i<=57&&(e|=1<<26)}return e}function Oi(s){let e=$t.get(s);return(!e||e.title!==s.title)&&(e={mask:0,title:s.title,titleNorm:S(s.title),subtitle:s.subtitle?S(s.subtitle):"",keywords:s.keywords?s.keywords.map(S):[],section:s.section?S(s.section):"",description:s.description?S(s.description):""},e.mask=Ke(`${e.titleNorm} ${e.subtitle} ${e.keywords.join(" ")} ${e.section} ${e.description}`),$t.set(s,e)),e}function te(s,e){let t=S(e.trim());return t?Ht(s,t,t.split(/\s+/).filter(Boolean),Ke(t)):{score:0,positions:[]}}function Ht(s,e,t,i){let n=Oi(s);if((i&n.mask)!==i)return null;let r=z(e,n.title,n.titleNorm),o=0,a=new Set,c=!0;if(t.length>1||!r){for(let h of t){let b=0,v=z(h,n.title,n.titleNorm);if(v){b=v.score;for(let m of v.positions)a.add(m)}for(let m of n.keywords){let p=z(h,m,m);p&&p.score*.88>b&&(b=p.score*.88)}if(n.subtitle){let m=z(h,n.subtitle,n.subtitle);m&&m.score*.7>b&&(b=m.score*.7)}if(n.section){let m=z(h,n.section,n.section);m&&m.score*.5>b&&(b=m.score*.5)}if(b===0&&n.description&&h.length>2&&n.description.includes(h)&&(b=.3),b===0){c=!1;break}o+=b}o/=t.length}let l=0,d=[];if(r&&r.score>=o)l=r.score,d=r.positions;else if(c&&o>0)l=o*.95,d=[...a].sort((h,b)=>h-b);else if(r)l=r.score,d=r.positions;else return null;return n.titleNorm.startsWith(e)&&(l=Math.min(.995,l+.15)),{score:l,positions:d}}function O(s,e,t={}){let{boost:i,limit:n,threshold:r=.05}=t,o=[],a=S(e.trim()),c=a.split(/\s+/).filter(Boolean),l=Ke(a);for(let v of s){let m=a?Ht(v,a,c,l):{score:0,positions:[]};if(!m||a&&m.score<r)continue;let p=m.score+(v.priority??0)*.1;i&&(p+=i(v)),o.push({item:v,score:p,positions:m.positions})}let d=o.map((v,m)=>[v,m]);d.sort((v,m)=>m[0].score-v[0].score||v[1]-m[1]);let h=d.map(v=>v[0]),b=h[0]?.score??0;return a.length>=3&&b>=.6&&(h=h.filter(v=>v.score>=b*.55)),n?h.slice(0,n):h}var Li,$t,je=E(()=>{"use strict";Li=new Set([" ","-","_",".","/",":","\\","(","[","{",",","@","#",'"',"'",">","|","+","&"]);$t=new WeakMap});function ge(s,e=16){let t=De[s];if(t)return`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${e}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${t}</svg>`}var De,Be=E(()=>{"use strict";De={search:'<circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>',command:'<path d="M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3"/>',"arrow-right":'<path d="M5 12h14"/><path d="m12 5 7 7-7 7"/>',"arrow-left":'<path d="M19 12H5"/><path d="m12 19-7-7 7-7"/>',"arrow-up-right":'<path d="M7 17 17 7"/><path d="M7 7h10v10"/>',"chevron-right":'<path d="m9 18 6-6-6-6"/>',"chevron-left":'<path d="m15 18-6-6 6-6"/>',"chevron-down":'<path d="m6 9 6 6 6-6"/>',"corner-down-left":'<path d="M20 4v7a4 4 0 0 1-4 4H4"/><path d="m9 10-5 5 5 5"/>',external:'<path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>',link:'<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>',copy:'<rect x="8" y="8" width="14" height="14" rx="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/>',check:'<path d="M20 6 9 17l-5-5"/>',x:'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',plus:'<path d="M5 12h14"/><path d="M12 5v14"/>',minus:'<path d="M5 12h14"/>',home:'<path d="m3 10 9-7 9 7v10a2 2 0 0 1-2 2h-4v-7H9v7H5a2 2 0 0 1-2-2z"/>',settings:'<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>',user:'<circle cx="12" cy="8" r="4"/><path d="M20 21a8 8 0 0 0-16 0"/>',users:'<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>',file:'<path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5z"/><path d="M14 2v6h6"/>',"file-text":'<path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5z"/><path d="M14 2v6h6"/><path d="M16 13H8"/><path d="M16 17H8"/><path d="M10 9H8"/>',folder:'<path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/>',book:'<path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/>',bookmark:'<path d="m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z"/>',star:'<path d="m12 2 3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01z"/>',heart:'<path d="M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"/>',clock:'<circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/>',history:'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/><path d="M12 7v5l4 2"/>',calendar:'<rect x="3" y="4" width="18" height="18" rx="2"/><path d="M16 2v4"/><path d="M8 2v4"/><path d="M3 10h18"/>',calculator:'<rect x="4" y="2" width="16" height="20" rx="2"/><path d="M8 6h8"/><path d="M16 14v4"/><path d="M16 10h.01"/><path d="M12 10h.01"/><path d="M8 10h.01"/><path d="M12 14h.01"/><path d="M8 14h.01"/><path d="M12 18h.01"/><path d="M8 18h.01"/>',sun:'<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>',moon:'<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>',monitor:'<rect x="2" y="3" width="20" height="14" rx="2"/><path d="M8 21h8"/><path d="M12 17v4"/>',palette:'<circle cx="13.5" cy="6.5" r=".5" fill="currentColor"/><circle cx="17.5" cy="10.5" r=".5" fill="currentColor"/><circle cx="8.5" cy="7.5" r=".5" fill="currentColor"/><circle cx="6.5" cy="12.5" r=".5" fill="currentColor"/><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.93 0 1.65-.75 1.65-1.69 0-.44-.18-.84-.44-1.13-.29-.29-.44-.65-.44-1.13a1.64 1.64 0 0 1 1.67-1.67h2c3.05 0 5.56-2.5 5.56-5.55C21.97 6.01 17.46 2 12 2z"/>',sparkles:'<path d="M9.94 15.5A2 2 0 0 0 8.5 14.06l-6.14-1.58a.5.5 0 0 1 0-.96L8.5 9.94A2 2 0 0 0 9.94 8.5l1.58-6.14a.5.5 0 0 1 .96 0L14.06 8.5A2 2 0 0 0 15.5 9.94l6.14 1.58a.5.5 0 0 1 0 .96L15.5 14.06a2 2 0 0 0-1.44 1.44l-1.58 6.14a.5.5 0 0 1-.96 0z"/><path d="M20 3v4"/><path d="M22 5h-4"/>',bot:'<path d="M12 8V4H8"/><rect x="4" y="8" width="16" height="12" rx="2"/><path d="M2 14h2"/><path d="M20 14h2"/><path d="M15 13v2"/><path d="M9 13v2"/>',message:'<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>',send:'<path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/>',mail:'<rect x="2" y="4" width="20" height="16" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/>',bell:'<path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/>',"credit-card":'<rect x="2" y="5" width="20" height="14" rx="2"/><path d="M2 10h20"/>',key:'<circle cx="7.5" cy="15.5" r="5.5"/><path d="m21 2-9.6 9.6"/><path d="m15.5 7.5 3 3L22 7l-3-3"/>',lock:'<rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>',"log-out":'<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><path d="m16 17 5-5-5-5"/><path d="M21 12H9"/>',trash:'<path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/>',pencil:'<path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/>',eye:'<path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/>',download:'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/><path d="M12 15V3"/>',upload:'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m17 8-5-5-5 5"/><path d="M12 3v12"/>',refresh:'<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/>',filter:'<path d="M22 3H2l8 9.46V19l4 2v-8.54z"/>',globe:'<circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/>',code:'<path d="m16 18 6-6-6-6"/><path d="m8 6-6 6 6 6"/>',terminal:'<path d="m4 17 6-6-6-6"/><path d="M12 19h8"/>',hash:'<path d="M4 9h16"/><path d="M4 15h16"/><path d="M10 3 8 21"/><path d="M16 3l-2 18"/>',zap:'<path d="M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"/>',layers:'<path d="m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z"/><path d="m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"/><path d="m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"/>',grid:'<rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/>',list:'<path d="M8 6h13"/><path d="M8 12h13"/><path d="M8 18h13"/><path d="M3 6h.01"/><path d="M3 12h.01"/><path d="M3 18h.01"/>',image:'<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.09-3.09a2 2 0 0 0-2.82 0L6 21"/>',"git-branch":'<path d="M6 3v12"/><circle cx="18" cy="6" r="3"/><circle cx="6" cy="18" r="3"/><path d="M18 9a9 9 0 0 1-9 9"/>',package:'<path d="m7.5 4.27 9 5.15"/><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.3 7 8.7 5 8.7-5"/><path d="M12 22V12"/>',puzzle:'<path d="M19.44 7.85c-.05.38.09.76.36 1.02l1.57 1.57c.47.47.7 1.08.7 1.7s-.23 1.23-.7 1.7l-1.61 1.61a.98.98 0 0 1-.84.28c-.47-.07-.8-.48-.97-.92a2.5 2.5 0 1 0-3.21 3.21c.44.17.85.5.92.97a.98.98 0 0 1-.28.84l-1.61 1.61c-.47.47-1.08.7-1.7.7s-1.23-.23-1.7-.7l-1.57-1.57a1.2 1.2 0 0 0-1.02-.36c-.47.07-.8.48-.97.92a2.5 2.5 0 1 1-3.21-3.21c.44-.17.85-.5.92-.97a1.2 1.2 0 0 0-.36-1.02L2.7 13.7A2.4 2.4 0 0 1 2 12c0-.62.24-1.23.7-1.7l1.57-1.57c.26-.27.64-.4 1.02-.36.47.07.8.48.97.92a2.5 2.5 0 1 0 3.21-3.21c-.44-.17-.85-.5-.92-.97a1.2 1.2 0 0 1 .36-1.02L10.3 2.7c.47-.47 1.08-.7 1.7-.7s1.23.23 1.7.7l1.57 1.57c.26.27.64.4 1.02.36.47-.07.8-.48.97-.92a2.5 2.5 0 1 1 3.21 3.21c-.44.17-.85.5-.92.97Z"/>',info:'<circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/>',alert:'<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/>',"check-circle":'<circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/>',"x-circle":'<circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/>',loader:'<path d="M21 12a9 9 0 1 1-6.22-8.56"/>',circle:'<circle cx="12" cy="12" r="9"/>',dot:'<circle cx="12" cy="12" r="4" fill="currentColor"/>',"more-horizontal":'<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>',"layout-dashboard":'<rect x="3" y="3" width="7" height="9" rx="1"/><rect x="14" y="3" width="7" height="5" rx="1"/><rect x="14" y="12" width="7" height="9" rx="1"/><rect x="3" y="16" width="7" height="5" rx="1"/>',"bar-chart":'<path d="M3 3v18h18"/><path d="M18 17V9"/><path d="M13 17V5"/><path d="M8 17v-3"/>',inbox:'<path d="M22 12h-6l-2 3h-4l-2-3H2"/><path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"/>',tag:'<path d="M12.59 2.59A2 2 0 0 0 11.17 2H4a2 2 0 0 0-2 2v7.17a2 2 0 0 0 .59 1.42l8.7 8.7a2.43 2.43 0 0 0 3.42 0l6.58-6.58a2.43 2.43 0 0 0 0-3.42z"/><circle cx="7.5" cy="7.5" r=".5" fill="currentColor"/>',languages:'<path d="m5 8 6 6"/><path d="m4 14 6-6 2-3"/><path d="M2 5h12"/><path d="M7 2h1"/><path d="m22 22-5-10-5 10"/><path d="M14 18h6"/>',wand:'<path d="m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72"/><path d="m14 7 3 3"/><path d="M5 6v4"/><path d="M19 14v4"/><path d="M10 2v2"/><path d="M7 8H3"/><path d="M21 16h-4"/><path d="M11 3H9"/>',keyboard:'<rect x="2" y="4" width="20" height="16" rx="2"/><path d="M6 8h.01"/><path d="M10 8h.01"/><path d="M14 8h.01"/><path d="M18 8h.01"/><path d="M8 12h.01"/><path d="M12 12h.01"/><path d="M16 12h.01"/><path d="M7 16h10"/>',pin:'<path d="M12 17v5"/><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/>',undo:'<path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 0 11H11"/>',"check-square":'<rect width="18" height="18" x="3" y="3" rx="2"/><path d="m9 12 2 2 4-4"/>',square:'<rect width="18" height="18" x="3" y="3" rx="2"/>',"at-sign":'<circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"/>',github:'<path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/>'}});function f(s,e,...t){let i=document.createElement(s);if(e)for(let n in e){let r=e[n];r==null||r===!1||(n==="class"?i.className=r:n==="style"&&typeof r=="object"?Object.assign(i.style,r):n.startsWith("on")&&typeof r=="function"?i.addEventListener(n.slice(2).toLowerCase(),r):n==="html"?i.innerHTML=r:n in i&&typeof r!="string"?i[n]=r:i.setAttribute(n,r===!0?"":String(r)))}return _t(i,t),i}function _t(s,e){for(let t of e)Array.isArray(t)?_t(s,t):t!=null&&t!==!1&&s.append(t instanceof Node?t:String(t))}function T(s,e=16){if(s==null||s==="")return null;let t=f("span",{class:"qb-icon","aria-hidden":"true"});if(typeof s=="function")t.append(s());else if(typeof Node<"u"&&s instanceof Node)t.append(s.cloneNode(!0));else if(typeof s=="object"&&"url"in s)t.append(f("img",{src:s.url,alt:s.alt??"",loading:"lazy",decoding:"async",draggable:"false"}));else if(typeof s=="object"&&"color"in s){t.classList.add("qb-icon-tinted"),t.style.setProperty("--qb-tint",Nt(s.color));let i=T(s.icon??"dot",e);i&&t.append(...i.childNodes)}else if(typeof s=="string"){let i=ge(s,e);i?t.innerHTML=i:s.trimStart().startsWith("<svg")?t.innerHTML=s:Pi.test(s)?t.append(f("img",{src:s,alt:"",loading:"lazy",decoding:"async",draggable:"false"})):(t.classList.add("qb-icon-text"),t.textContent=s)}return t}function L(s,e="qb-kbd"){let t=f("span",{class:"qb-kbds","aria-label":s});return $(s).forEach((i,n)=>{n>0&&t.append(f("span",{class:"qb-kbd-then"},"then"));for(let r of i)t.append(f("kbd",{class:e},r))}),t}function Ue(s,e){if(!e||e.length===0)return s;let t=document.createDocumentFragment(),i=0,n=0;for(;n<e.length;){let r=e[n],o=r;for(;n+1<e.length&&e[n+1]===o+1;)n++,o++;r>i&&t.append(s.slice(i,r)),t.append(f("mark",{class:"qb-match"},s.slice(r,o+1))),i=o+1,n++}return i<s.length&&t.append(s.slice(i)),t}function Nt(s){return s?Ft[s]??s:Ft.default}function We(s){let e=typeof s=="string"?s:s.value,t=typeof s=="string"?void 0:s.color,i=f("span",{class:"qb-tag"},e);return t&&i.style.setProperty("--qb-tint",Nt(t)),i}function $i(s){let e=new Date(s),t=(e.getTime()-Date.now())/1e3,i=Math.abs(t);return V?i<60?V.format(Math.round(t),"second"):i<3600?V.format(Math.round(t/60),"minute"):i<86400?V.format(Math.round(t/3600),"hour"):i<86400*30?V.format(Math.round(t/86400),"day"):i<86400*365?V.format(Math.round(t/(86400*30)),"month"):V.format(Math.round(t/(86400*365)),"year"):e.toLocaleDateString()}function zt(s){let e=f("span",{class:"qb-accessory",title:s.tooltip}),t=T(s.icon,14);return t&&e.append(t),s.tag&&e.append(We(s.tag)),s.text&&e.append(f("span",null,s.text)),s.date!=null&&e.append(f("time",{datetime:new Date(s.date).toISOString()},$i(s.date))),s.kbd&&e.append(L(s.kbd)),e}function Vt(s="qb"){return`${s}-${(++Hi).toString(36)}`}var Pi,Ft,V,Hi,Qe=E(()=>{"use strict";F();Be();Pi=/^(https?:|\/|\.\.?\/|data:image\/|blob:)/;Ft={default:"var(--qb-fg-muted)",gray:"var(--qb-fg-subtle)",blue:"#3b82f6",green:"#22c55e",yellow:"#eab308",orange:"#f97316",red:"#ef4444",purple:"#a855f7",pink:"#ec4899"};V=typeof Intl<"u"&&"RelativeTimeFormat"in Intl?new Intl.RelativeTimeFormat(void 0,{numeric:"auto",style:"short"}):null;Hi=0});async function K(s){try{return await navigator.clipboard.writeText(s),!0}catch{try{let e=document.createElement("textarea");e.value=s,e.setAttribute("readonly",""),e.style.cssText="position:fixed;top:-1000px;opacity:0",document.body.append(e),e.select();let t=document.execCommand("copy");return e.remove(),t}catch{return!1}}}function ie(s,e){if(e){window.open(s,"_blank","noopener");return}let t=[...document.querySelectorAll("a[href]")].find(n=>n.getAttribute("href")===s&&!n.closest(".qb-root")&&(!n.target||n.target==="_self")&&!n.hasAttribute("download"));if(t){t.click();return}let i=document.createElement("a");i.href=s,i.style.display="none",document.body.append(i),i.click(),i.remove()}var be=E(()=>{"use strict"});function I(s){return s.replace(/[&<>"']/g,e=>Fi[e])}function Kt(s){let e=s.trim();return/^(https?:|mailto:|tel:|#|\/|\.\.?\/)/i.test(e)||/^data:image\/(png|jpe?g|gif|webp|avif);/i.test(e)||!/^[a-z][a-z0-9+.-]*:/i.test(e)?e:null}function W(s){let e=[],t=s.replace(/(`+)([\s\S]*?[^`])\1(?!`)/g,(i,n,r)=>(e.push(`<code>${I(r.trim())}</code>`),`\0${e.length-1}\0`));return t=I(t),t=t.replace(/!\[([^\]]*)\]\(([^)\s]+)(?:\s+&quot;([^&]*)&quot;)?\)/g,(i,n,r)=>{let o=Kt(jt(r));return o?`<img src="${I(o)}" alt="${n}" loading="lazy">`:i}),t=t.replace(/\[([^\]]+)\]\(([^)\s]+)(?:\s+&quot;([^&]*)&quot;)?\)/g,(i,n,r)=>{let o=Kt(jt(r));if(!o)return n;let a=/^https?:/i.test(o);return`<a href="${I(o)}"${a?' target="_blank" rel="noopener noreferrer"':""}>${n}</a>`}),t=t.replace(/(^|[\s(])(https?:\/\/[^\s<)]+[^\s<).,;:!?'"])/g,(i,n,r)=>`${n}<a href="${r}" target="_blank" rel="noopener noreferrer">${r}</a>`),t=t.replace(/\*\*([^*]+)\*\*|__([^_]+)__/g,(i,n,r)=>`<strong>${n??r}</strong>`),t=t.replace(/(^|[^*\w])\*([^*\s][^*]*?)\*(?!\w)/g,"$1<em>$2</em>"),t=t.replace(/(^|[^_\w])_([^_\s][^_]*?)_(?!\w)/g,"$1<em>$2</em>"),t=t.replace(/~~([^~]+)~~/g,"<del>$1</del>"),t=t.replace(/ {2,}\n|\\\n/g,"<br>"),t.replace(/\u0000(\d+)\u0000/g,(i,n)=>e[Number(n)])}function jt(s){return s.replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&lt;/g,"<").replace(/&gt;/g,">")}function ne(s,e={}){let t=I(e.copyLabel??"Copy"),i=s.replace(/\r\n?/g,`
12
+ `).split(`
13
+ `),n=[],r=[],o=[],a=0,c=()=>{r.length&&(n.push(`<p>${W(r.join(`
14
+ `))}</p>`),r=[])},l=(d=-1)=>{for(;o.length&&o[o.length-1].indent>d;)n.push(`</li></${o.pop().type}>`)};for(;a<i.length;){let d=i[a],h=d.match(/^\s*(```+|~~~+)\s*([\w+#.-]*)/);if(h){c(),l();let m=h[1],p=h[2]??"",g=[];for(a++;a<i.length&&!i[a].trim().startsWith(m);)g.push(i[a++]);a++,n.push(`<div class="qb-code"><div class="qb-code-head"><span>${I(p)}</span><button type="button" class="qb-code-copy" data-qb-copy>${t}</button></div><pre><code${p?` class="language-${I(p)}"`:""}>${I(g.join(`
15
+ `))}</code></pre></div>`);continue}if(!d.trim()){c();let m=i[a+1]??"";!/^\s*([-*+]|\d+[.)])\s+/.test(m)&&!/^\s{2,}\S/.test(m)&&l(),a++;continue}let b=d.match(/^(#{1,6})\s+(.*?)\s*#*\s*$/);if(b){c(),l();let m=b[1].length;n.push(`<h${m}>${W(b[2])}</h${m}>`),a++;continue}if(/^\s*([-*_])(\s*\1){2,}\s*$/.test(d)){c(),l(),n.push("<hr>"),a++;continue}if(/^\s*>/.test(d)){c(),l();let m=[];for(;a<i.length&&/^\s*>/.test(i[a]);)m.push(i[a++].replace(/^\s*>\s?/,""));n.push(`<blockquote>${ne(m.join(`
16
+ `))}</blockquote>`);continue}if(d.includes("|")&&/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(i[a+1]??"")){c(),l();let m=w=>w.trim().replace(/^\||\|$/g,"").split("|").map(k=>k.trim()),p=m(d),g=m(i[a+1]).map(w=>w.startsWith(":")&&w.endsWith(":")?"center":w.endsWith(":")?"right":"");a+=2;let y=[];for(;a<i.length&&i[a].includes("|")&&i[a].trim();)y.push(m(i[a++]));let x=(w,k,le)=>`<${w}${g[le]?` style="text-align:${g[le]}"`:""}>${W(k)}</${w}>`;n.push(`<div class="qb-table"><table><thead><tr>${p.map((w,k)=>x("th",w,k)).join("")}</tr></thead><tbody>${y.map(w=>`<tr>${w.map((k,le)=>x("td",k,le)).join("")}</tr>`).join("")}</tbody></table></div>`);continue}let v=d.match(/^(\s*)([-*+]|\d+[.)])\s+(.*)$/);if(v){c();let m=v[1].length,p=/\d/.test(v[2])?"ol":"ul",g=o[o.length-1];if(!g||m>g.indent){let k=p==="ol"&&parseInt(v[2],10)!==1?` start="${parseInt(v[2],10)}"`:"";n.push(`<${p}${k}><li>`),o.push({type:p,indent:m})}else{l(m);let k=o[o.length-1];k&&k.type!==p?(n.push(`</li></${o.pop().type}><${p}><li>`),o.push({type:p,indent:m})):k?n.push("</li><li>"):(n.push(`<${p}><li>`),o.push({type:p,indent:m}))}let y=v[3],x=y.match(/^\[([ xX])\]\s+(.*)$/);x?y=`<input type="checkbox" disabled${x[1]!==" "?" checked":""}> ${W(x[2])}`:y=W(y),a++;let w=[];for(;a<i.length&&/^\s{2,}\S/.test(i[a])&&!/^\s*([-*+]|\d+[.)])\s+/.test(i[a]);)w.push(i[a++].trim());n.push(y+(w.length?` ${W(w.join(`
17
+ `))}`:""));continue}l(),r.push(d),a++}return c(),l(),n.join("")}var Fi,Ge=E(()=>{"use strict";Fi={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}});function j(s){return`--qb-${s.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}`}function xe(s,e){let t=typeof s=="string"?{preset:s}:s??{},i=t.preset?Je[t.preset]:void 0,n=i?.only??(t.preset==="light"?"light":t.preset==="dark"?"dark":e);return{vars:{...n==="dark"?i?.dark:i?.light,...t.vars,...n==="dark"?t.dark:t.light},appearance:n}}function Dt(s,e=".qb-root"){let t=Object.entries(s).filter(([,i])=>i!=null&&i!=="").map(([i,n])=>` ${j(i)}: ${n};`).join(`
2
18
  `);return`${e} {
3
19
  ${t}
4
- }`}var he,pe,Ve,fe=q(()=>{"use strict";he={font:'ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',fontMono:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',fontSize:"14px",bg:"rgba(255, 255, 255, 0.92)",bgElevated:"#ffffff",fg:"#18181b",fgMuted:"#52525b",fgSubtle:"#a1a1aa",border:"rgba(0, 0, 0, 0.08)",selection:"rgba(0, 0, 0, 0.055)",selectionFg:"#09090b",hover:"rgba(0, 0, 0, 0.03)",accent:"#6d5dfc",accentFg:"#ffffff",highlight:"#6d5dfc",overlay:"rgba(24, 24, 27, 0.18)",backdropBlur:"20px",shadow:"0 0 0 1px rgba(0,0,0,.04), 0 24px 64px -12px rgba(0,0,0,.25), 0 8px 24px -8px rgba(0,0,0,.12)",radius:"14px",radiusItem:"8px",width:"680px",listHeight:"380px",rowHeight:"42px",sectionHeight:"30px",inputHeight:"56px",inputFontSize:"16px",top:"14vh",kbdBg:"rgba(0, 0, 0, 0.06)",kbdFg:"#52525b",danger:"#e5484d",success:"#30a46c",warning:"#f5a524"},pe={bg:"rgba(28, 28, 31, 0.9)",bgElevated:"#232327",fg:"#f4f4f5",fgMuted:"#a1a1aa",fgSubtle:"#71717a",border:"rgba(255, 255, 255, 0.09)",selection:"rgba(255, 255, 255, 0.075)",selectionFg:"#ffffff",hover:"rgba(255, 255, 255, 0.04)",accent:"#8b7dff",accentFg:"#ffffff",highlight:"#a99fff",overlay:"rgba(0, 0, 0, 0.45)",shadow:"0 0 0 1px rgba(255,255,255,.04), 0 24px 64px -12px rgba(0,0,0,.6), 0 8px 24px -8px rgba(0,0,0,.4)",kbdBg:"rgba(255, 255, 255, 0.08)",kbdFg:"#a1a1aa",danger:"#ff6369",success:"#3dd68c",warning:"#ffc53d"},Ve={light:{name:"light",label:"Light",only:"light"},dark:{name:"dark",label:"Dark",only:"dark"},raycast:{name:"raycast",label:"Raycast",light:{accent:"#ff6363",highlight:"#ff6363",bg:"rgba(250,250,250,.86)",radius:"12px",width:"750px",rowHeight:"40px"},dark:{accent:"#ff6363",highlight:"#ff6363",bg:"rgba(30, 30, 30, .82)",bgElevated:"#2a2a2a",selection:"rgba(255,255,255,.1)",border:"rgba(255,255,255,.1)",radius:"12px",width:"750px",rowHeight:"40px"}},linear:{name:"linear",label:"Linear",light:{accent:"#5e6ad2",highlight:"#5e6ad2",bg:"#ffffff",selection:"#f2f2f5",radius:"10px",fontSize:"13px",inputFontSize:"15px",rowHeight:"40px"},dark:{accent:"#5e6ad2",highlight:"#8d95f2",bg:"rgba(25, 26, 35, .96)",bgElevated:"#22232e",fg:"#eeeffc",fgMuted:"#9ea0b4",fgSubtle:"#6b6f85",selection:"rgba(255,255,255,.06)",border:"rgba(255,255,255,.07)",radius:"10px",fontSize:"13px",inputFontSize:"15px",rowHeight:"40px"}},vercel:{name:"vercel",label:"Vercel",light:{accent:"#000000",accentFg:"#fff",highlight:"#000",bg:"#ffffff",selection:"#f2f2f2",radius:"12px",fontSize:"14px",border:"#eaeaea"},dark:{accent:"#ffffff",accentFg:"#000",highlight:"#fff",bg:"#0a0a0a",bgElevated:"#111",fg:"#ededed",fgMuted:"#a1a1a1",fgSubtle:"#6e6e6e",selection:"#1f1f1f",border:"#262626",radius:"12px"}},github:{name:"github",label:"GitHub",light:{accent:"#0969da",highlight:"#0969da",bg:"#ffffff",selection:"#f6f8fa",fg:"#1f2328",fgMuted:"#59636e",border:"#d1d9e0",radius:"12px",radiusItem:"6px"},dark:{accent:"#4493f8",highlight:"#4493f8",bg:"#151b23",bgElevated:"#212830",fg:"#f0f6fc",fgMuted:"#9198a1",fgSubtle:"#656c76",selection:"#262c36",border:"#3d444d",radius:"12px",radiusItem:"6px"}},nord:{name:"nord",label:"Nord",light:{accent:"#5e81ac",highlight:"#5e81ac",bg:"#eceff4",bgElevated:"#e5e9f0",fg:"#2e3440",fgMuted:"#4c566a",selection:"#d8dee9",border:"#d8dee9"},dark:{accent:"#88c0d0",accentFg:"#2e3440",highlight:"#88c0d0",bg:"#2e3440",bgElevated:"#3b4252",fg:"#eceff4",fgMuted:"#d8dee9",fgSubtle:"#7b88a1",selection:"#3b4252",border:"#434c5e",kbdBg:"#434c5e",kbdFg:"#d8dee9"}},dracula:{name:"dracula",label:"Dracula",only:"dark",dark:{accent:"#bd93f9",accentFg:"#282a36",highlight:"#ff79c6",bg:"#282a36",bgElevated:"#343746",fg:"#f8f8f2",fgMuted:"#c1c4d6",fgSubtle:"#6272a4",selection:"#44475a",border:"#44475a",kbdBg:"#44475a",kbdFg:"#f8f8f2",success:"#50fa7b",danger:"#ff5555",warning:"#f1fa8c"}},catppuccin:{name:"catppuccin",label:"Catppuccin",light:{accent:"#8839ef",highlight:"#8839ef",bg:"#eff1f5",bgElevated:"#e6e9ef",fg:"#4c4f69",fgMuted:"#6c6f85",fgSubtle:"#9ca0b0",selection:"#ccd0da",border:"#ccd0da"},dark:{accent:"#cba6f7",accentFg:"#1e1e2e",highlight:"#f5c2e7",bg:"#1e1e2e",bgElevated:"#313244",fg:"#cdd6f4",fgMuted:"#a6adc8",fgSubtle:"#6c7086",selection:"#313244",border:"#45475a",kbdBg:"#313244",kbdFg:"#bac2de"}},"tokyo-night":{name:"tokyo-night",label:"Tokyo Night",only:"dark",dark:{accent:"#7aa2f7",accentFg:"#1a1b26",highlight:"#bb9af7",bg:"#1a1b26",bgElevated:"#24283b",fg:"#c0caf5",fgMuted:"#a9b1d6",fgSubtle:"#565f89",selection:"#292e42",border:"#2f344d",kbdBg:"#292e42",kbdFg:"#a9b1d6"}},"rose-pine":{name:"rose-pine",label:"Ros\xE9 Pine",light:{accent:"#907aa9",highlight:"#d7827e",bg:"#faf4ed",bgElevated:"#fffaf3",fg:"#575279",fgMuted:"#797593",fgSubtle:"#9893a5",selection:"#f2e9e1",border:"#dfdad9"},dark:{accent:"#c4a7e7",accentFg:"#191724",highlight:"#ebbcba",bg:"#191724",bgElevated:"#1f1d2e",fg:"#e0def4",fgMuted:"#908caa",fgSubtle:"#6e6a86",selection:"#26233a",border:"#26233a",kbdBg:"#26233a",kbdFg:"#908caa"}},solarized:{name:"solarized",label:"Solarized",light:{accent:"#268bd2",highlight:"#cb4b16",bg:"#fdf6e3",bgElevated:"#eee8d5",fg:"#586e75",fgMuted:"#657b83",fgSubtle:"#93a1a1",selection:"#eee8d5",border:"#e4ddc8"},dark:{accent:"#268bd2",highlight:"#b58900",bg:"#002b36",bgElevated:"#073642",fg:"#93a1a1",fgMuted:"#839496",fgSubtle:"#586e75",selection:"#073642",border:"#0a4352",kbdBg:"#073642",kbdFg:"#93a1a1"}},midnight:{name:"midnight",label:"Midnight",only:"dark",dark:{accent:"#22d3ee",accentFg:"#020617",highlight:"#67e8f9",bg:"rgba(2, 6, 23, .88)",bgElevated:"#0f172a",fg:"#e2e8f0",fgMuted:"#94a3b8",fgSubtle:"#475569",selection:"rgba(34, 211, 238, .1)",selectionFg:"#a5f3fc",border:"rgba(148, 163, 184, .14)",radius:"18px",radiusItem:"10px"}},paper:{name:"paper",label:"Paper",only:"light",light:{font:'ui-serif, Georgia, Cambria, "Times New Roman", serif',accent:"#1a1a1a",highlight:"#b4441f",bg:"#fbfaf7",bgElevated:"#ffffff",fg:"#1a1a1a",fgMuted:"#5c5a55",fgSubtle:"#9b978f",selection:"#f0ede6",border:"#e7e3da",radius:"4px",radiusItem:"2px",shadow:"0 1px 0 rgba(0,0,0,.04), 0 18px 40px -16px rgba(60,40,10,.25)"}}}});var kt,me,Ne=q(()=>{"use strict";fe();kt=s=>Object.entries(s).map(([e,t])=>`${K(e)}:${t};`).join(""),me=`
5
- .qb-root{${kt(he)}--qb-z:2147483000;--qb-ease:cubic-bezier(.16,1,.3,1);font-family:var(--qb-font);font-size:var(--qb-font-size);line-height:1.45;color:var(--qb-fg);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-align:start;color-scheme:light}
6
- .qb-root[data-qb-appearance=dark]{${kt(pe)}color-scheme:dark}
20
+ }`}var ye,ve,Je,we=E(()=>{"use strict";ye={font:'ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',fontMono:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',fontSize:"14px",bg:"rgba(255, 255, 255, 0.92)",bgElevated:"#ffffff",fg:"#18181b",fgMuted:"#52525b",fgSubtle:"#a1a1aa",border:"rgba(0, 0, 0, 0.08)",selection:"rgba(0, 0, 0, 0.055)",selectionFg:"#09090b",hover:"rgba(0, 0, 0, 0.03)",accent:"#6d5dfc",accentFg:"#ffffff",highlight:"#6d5dfc",overlay:"rgba(24, 24, 27, 0.18)",backdropBlur:"20px",shadow:"0 0 0 1px rgba(0,0,0,.04), 0 24px 64px -12px rgba(0,0,0,.25), 0 8px 24px -8px rgba(0,0,0,.12)",radius:"14px",radiusItem:"8px",width:"680px",listHeight:"380px",rowHeight:"42px",sectionHeight:"30px",inputHeight:"56px",inputFontSize:"16px",top:"14vh",kbdBg:"rgba(0, 0, 0, 0.06)",kbdFg:"#52525b",danger:"#e5484d",success:"#30a46c",warning:"#f5a524"},ve={bg:"rgba(28, 28, 31, 0.9)",bgElevated:"#232327",fg:"#f4f4f5",fgMuted:"#a1a1aa",fgSubtle:"#71717a",border:"rgba(255, 255, 255, 0.09)",selection:"rgba(255, 255, 255, 0.075)",selectionFg:"#ffffff",hover:"rgba(255, 255, 255, 0.04)",accent:"#8b7dff",accentFg:"#ffffff",highlight:"#a99fff",overlay:"rgba(0, 0, 0, 0.45)",shadow:"0 0 0 1px rgba(255,255,255,.04), 0 24px 64px -12px rgba(0,0,0,.6), 0 8px 24px -8px rgba(0,0,0,.4)",kbdBg:"rgba(255, 255, 255, 0.08)",kbdFg:"#a1a1aa",danger:"#ff6369",success:"#3dd68c",warning:"#ffc53d"},Je={light:{name:"light",label:"Light",only:"light"},dark:{name:"dark",label:"Dark",only:"dark"},raycast:{name:"raycast",label:"Raycast",light:{accent:"#ff6363",highlight:"#ff6363",bg:"rgba(250,250,250,.86)",radius:"12px",width:"750px",rowHeight:"40px"},dark:{accent:"#ff6363",highlight:"#ff6363",bg:"rgba(30, 30, 30, .82)",bgElevated:"#2a2a2a",selection:"rgba(255,255,255,.1)",border:"rgba(255,255,255,.1)",radius:"12px",width:"750px",rowHeight:"40px"}},linear:{name:"linear",label:"Linear",light:{accent:"#5e6ad2",highlight:"#5e6ad2",bg:"#ffffff",selection:"#f2f2f5",radius:"10px",fontSize:"13px",inputFontSize:"15px",rowHeight:"40px"},dark:{accent:"#5e6ad2",highlight:"#8d95f2",bg:"rgba(25, 26, 35, .96)",bgElevated:"#22232e",fg:"#eeeffc",fgMuted:"#9ea0b4",fgSubtle:"#6b6f85",selection:"rgba(255,255,255,.06)",border:"rgba(255,255,255,.07)",radius:"10px",fontSize:"13px",inputFontSize:"15px",rowHeight:"40px"}},vercel:{name:"vercel",label:"Vercel",light:{accent:"#000000",accentFg:"#fff",highlight:"#000",bg:"#ffffff",selection:"#f2f2f2",radius:"12px",fontSize:"14px",border:"#eaeaea"},dark:{accent:"#ffffff",accentFg:"#000",highlight:"#fff",bg:"#0a0a0a",bgElevated:"#111",fg:"#ededed",fgMuted:"#a1a1a1",fgSubtle:"#6e6e6e",selection:"#1f1f1f",border:"#262626",radius:"12px"}},github:{name:"github",label:"GitHub",light:{accent:"#0969da",highlight:"#0969da",bg:"#ffffff",selection:"#f6f8fa",fg:"#1f2328",fgMuted:"#59636e",border:"#d1d9e0",radius:"12px",radiusItem:"6px"},dark:{accent:"#4493f8",highlight:"#4493f8",bg:"#151b23",bgElevated:"#212830",fg:"#f0f6fc",fgMuted:"#9198a1",fgSubtle:"#656c76",selection:"#262c36",border:"#3d444d",radius:"12px",radiusItem:"6px"}},nord:{name:"nord",label:"Nord",light:{accent:"#5e81ac",highlight:"#5e81ac",bg:"#eceff4",bgElevated:"#e5e9f0",fg:"#2e3440",fgMuted:"#4c566a",selection:"#d8dee9",border:"#d8dee9"},dark:{accent:"#88c0d0",accentFg:"#2e3440",highlight:"#88c0d0",bg:"#2e3440",bgElevated:"#3b4252",fg:"#eceff4",fgMuted:"#d8dee9",fgSubtle:"#7b88a1",selection:"#3b4252",border:"#434c5e",kbdBg:"#434c5e",kbdFg:"#d8dee9"}},dracula:{name:"dracula",label:"Dracula",only:"dark",dark:{accent:"#bd93f9",accentFg:"#282a36",highlight:"#ff79c6",bg:"#282a36",bgElevated:"#343746",fg:"#f8f8f2",fgMuted:"#c1c4d6",fgSubtle:"#6272a4",selection:"#44475a",border:"#44475a",kbdBg:"#44475a",kbdFg:"#f8f8f2",success:"#50fa7b",danger:"#ff5555",warning:"#f1fa8c"}},catppuccin:{name:"catppuccin",label:"Catppuccin",light:{accent:"#8839ef",highlight:"#8839ef",bg:"#eff1f5",bgElevated:"#e6e9ef",fg:"#4c4f69",fgMuted:"#6c6f85",fgSubtle:"#9ca0b0",selection:"#ccd0da",border:"#ccd0da"},dark:{accent:"#cba6f7",accentFg:"#1e1e2e",highlight:"#f5c2e7",bg:"#1e1e2e",bgElevated:"#313244",fg:"#cdd6f4",fgMuted:"#a6adc8",fgSubtle:"#6c7086",selection:"#313244",border:"#45475a",kbdBg:"#313244",kbdFg:"#bac2de"}},"tokyo-night":{name:"tokyo-night",label:"Tokyo Night",only:"dark",dark:{accent:"#7aa2f7",accentFg:"#1a1b26",highlight:"#bb9af7",bg:"#1a1b26",bgElevated:"#24283b",fg:"#c0caf5",fgMuted:"#a9b1d6",fgSubtle:"#565f89",selection:"#292e42",border:"#2f344d",kbdBg:"#292e42",kbdFg:"#a9b1d6"}},"rose-pine":{name:"rose-pine",label:"Ros\xE9 Pine",light:{accent:"#907aa9",highlight:"#d7827e",bg:"#faf4ed",bgElevated:"#fffaf3",fg:"#575279",fgMuted:"#797593",fgSubtle:"#9893a5",selection:"#f2e9e1",border:"#dfdad9"},dark:{accent:"#c4a7e7",accentFg:"#191724",highlight:"#ebbcba",bg:"#191724",bgElevated:"#1f1d2e",fg:"#e0def4",fgMuted:"#908caa",fgSubtle:"#6e6a86",selection:"#26233a",border:"#26233a",kbdBg:"#26233a",kbdFg:"#908caa"}},solarized:{name:"solarized",label:"Solarized",light:{accent:"#268bd2",highlight:"#cb4b16",bg:"#fdf6e3",bgElevated:"#eee8d5",fg:"#586e75",fgMuted:"#657b83",fgSubtle:"#93a1a1",selection:"#eee8d5",border:"#e4ddc8"},dark:{accent:"#268bd2",highlight:"#b58900",bg:"#002b36",bgElevated:"#073642",fg:"#93a1a1",fgMuted:"#839496",fgSubtle:"#586e75",selection:"#073642",border:"#0a4352",kbdBg:"#073642",kbdFg:"#93a1a1"}},midnight:{name:"midnight",label:"Midnight",only:"dark",dark:{accent:"#22d3ee",accentFg:"#020617",highlight:"#67e8f9",bg:"rgba(2, 6, 23, .88)",bgElevated:"#0f172a",fg:"#e2e8f0",fgMuted:"#94a3b8",fgSubtle:"#475569",selection:"rgba(34, 211, 238, .1)",selectionFg:"#a5f3fc",border:"rgba(148, 163, 184, .14)",radius:"18px",radiusItem:"10px"}},paper:{name:"paper",label:"Paper",only:"light",light:{font:'ui-serif, Georgia, Cambria, "Times New Roman", serif',accent:"#1a1a1a",highlight:"#b4441f",bg:"#fbfaf7",bgElevated:"#ffffff",fg:"#1a1a1a",fgMuted:"#5c5a55",fgSubtle:"#9b978f",selection:"#f0ede6",border:"#e7e3da",radius:"4px",radiusItem:"2px",shadow:"0 1px 0 rgba(0,0,0,.04), 0 18px 40px -16px rgba(60,40,10,.25)"}}}});var Bt,ke,Ye=E(()=>{"use strict";we();Bt=s=>Object.entries(s).map(([e,t])=>`${j(e)}:${t};`).join(""),ke=`
21
+ .qb-root{${Bt(ye)}--qb-z:2147483000;--qb-ease:cubic-bezier(.16,1,.3,1);font-family:var(--qb-font);font-size:var(--qb-font-size);line-height:1.45;color:var(--qb-fg);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-align:start;color-scheme:light}
22
+ .qb-root[data-qb-appearance=dark]{${Bt(ve)}color-scheme:dark}
7
23
  :where(.qb-root) *,:where(.qb-root) *::before,:where(.qb-root) *::after{box-sizing:border-box}
8
24
  :where(.qb-root) :where(button,input,textarea,select){font:inherit;color:inherit;margin:0;letter-spacing:inherit}
9
25
  :where(.qb-root) button{background:none;border:0;padding:0;cursor:pointer;text-transform:none}
@@ -21,6 +37,7 @@ ${t}
21
37
  .qb-header{position:relative;display:flex;align-items:center;gap:10px;height:var(--qb-input-height);padding:0 16px;border-bottom:1px solid var(--qb-border);flex-shrink:0}
22
38
  .qb-header-icon{color:var(--qb-fg-subtle);display:flex}
23
39
  .qb-input{flex:1;min-width:0;height:100%;border:0;outline:0;background:transparent;font-size:var(--qb-input-font-size);padding:0;caret-color:var(--qb-accent)}
40
+ .qb-input:focus,.qb-input:focus-visible{outline:0;box-shadow:none}
24
41
  .qb-input::placeholder{color:var(--qb-fg-subtle);opacity:1}
25
42
  .qb-input::-webkit-search-cancel-button{display:none}
26
43
  .qb-back{display:flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:7px;background:var(--qb-kbd-bg);color:var(--qb-fg-muted);flex-shrink:0;transition:background .1s}
@@ -198,6 +215,33 @@ textarea.qb-field-input{height:auto;min-height:96px;padding:8px 10px;resize:vert
198
215
 
199
216
  .qb-hud{position:fixed;left:50%;bottom:32px;translate:-50% 0;z-index:calc(var(--qb-z) + 2);display:flex;align-items:center;gap:8px;max-width:calc(100vw - 32px);padding:9px 16px 9px 12px;border:1px solid var(--qb-border);border-radius:999px;background:var(--qb-bg-elevated);color:var(--qb-fg);box-shadow:0 12px 32px -8px rgba(0,0,0,.3);font-size:13px;animation:qb-hud .22s var(--qb-ease);pointer-events:none}
200
217
  .qb-hud .qb-toast-msg{color:var(--qb-fg-muted)}
218
+ .qb-hud[data-action]{pointer-events:auto;padding-right:6px}
219
+ .qb-toast-action{display:inline-flex;align-items:center;gap:6px;height:24px;margin-left:4px;padding:0 6px 0 9px;border-radius:7px;background:var(--qb-kbd-bg);color:var(--qb-fg);font-size:12.5px;font-weight:500;white-space:nowrap;flex-shrink:0}
220
+ .qb-toast-action:hover{background:var(--qb-hover)}
221
+ .qb-toast-action .qb-kbd{height:18px;min-width:18px;font-size:10.5px}
222
+ .qb-hud .qb-toast-action{border-radius:999px;height:28px;padding:0 8px 0 12px}
223
+
224
+ .qb-alias{display:inline-flex;align-items:center;height:20px;padding:0 7px;border-radius:6px;border:1px solid var(--qb-border);color:var(--qb-fg-muted);font:500 11.5px/1 var(--qb-font-mono,ui-monospace,monospace);flex-shrink:0}
225
+ .qb-pin{display:inline-flex;color:var(--qb-fg-subtle);flex-shrink:0}
226
+ .qb-item[aria-selected=true] .qb-pin{color:inherit;opacity:.7}
227
+ .qb-check{display:inline-grid;place-items:center;width:16px;height:16px;flex-shrink:0;border-radius:5px;border:1.5px solid var(--qb-fg-subtle);color:transparent;transition:background .1s,border-color .1s}
228
+ .qb-check .qb-icon svg{stroke-width:3}
229
+ [data-marked] .qb-check{background:var(--qb-accent);border-color:var(--qb-accent);color:var(--qb-accent-fg)}
230
+ .qb-item[data-marked]{background:color-mix(in srgb,var(--qb-accent) 10%,transparent)}
231
+ .qb-item[data-marked][aria-selected=true]{background:color-mix(in srgb,var(--qb-accent) 18%,var(--qb-selection))}
232
+ .qb-cell .qb-check{position:absolute;top:8px;left:8px;z-index:1;background:var(--qb-bg)}
233
+ .qb-cell[data-marked] .qb-check{background:var(--qb-accent)}
234
+ .qb-cell[data-marked]{outline:2px solid var(--qb-accent);outline-offset:-2px}
235
+
236
+ /* Touch: no keyboard hints, bigger targets, 16px inputs (prevents iOS zoom) */
237
+ .qb-root[data-qb-touch] .qb-item .qb-kbds,.qb-root[data-qb-touch] .qb-footer .qb-kbds,.qb-root[data-qb-touch] .qb-hint .qb-kbds,.qb-root[data-qb-touch] .qb-action .qb-kbds,.qb-root[data-qb-touch] .qb-toast-action .qb-kbd,.qb-root[data-qb-touch] .qb-btn .qb-kbds{display:none}
238
+ .qb-root[data-qb-touch] .qb-item{height:max(var(--qb-row-height),48px)}
239
+ .qb-root[data-qb-touch] .qb-action{min-height:44px}
240
+ .qb-root[data-qb-touch] .qb-footer-btn{height:34px;padding:0 10px}
241
+ .qb-root[data-qb-touch] .qb-input,.qb-root[data-qb-touch] .qb-actions-input,.qb-root[data-qb-touch] .qb-field-input,.qb-root[data-qb-touch] .qb-arg{font-size:max(16px,var(--qb-input-font-size))}
242
+ .qb-root[data-qb-touch] .qb-actions-input,.qb-root[data-qb-touch] .qb-field-input,.qb-root[data-qb-touch] .qb-arg{font-size:16px}
243
+ .qb-root[data-qb-touch] .qb-scroll{-webkit-overflow-scrolling:touch;overscroll-behavior:contain}
244
+ .qb-root[data-qb-touch] .qb-item,.qb-root[data-qb-touch] .qb-cell{-webkit-touch-callout:none}
201
245
 
202
246
  @keyframes qb-fade{from{opacity:0}}
203
247
  @keyframes qb-fade-out{to{opacity:0}}
@@ -211,10 +255,13 @@ textarea.qb-field-input{height:auto;min-height:96px;padding:8px 10px;resize:vert
211
255
  .qb-root[data-qb-inline] .qb-dialog{animation:none}
212
256
 
213
257
  @media (max-width:640px){
214
- .qb-dialog{top:8px;width:calc(100vw - 16px)}
215
- .qb-body{height:min(var(--qb-list-height),58vh)}
216
- .qb-footer-left,.qb-hint{display:none}
258
+ .qb-dialog{top:max(8px,env(safe-area-inset-top,0px));width:calc(100vw - 16px)}
259
+ .qb-body{height:min(var(--qb-list-height),calc(var(--qb-vvh,100dvh) - 140px - env(safe-area-inset-top,0px)))}
260
+ .qb-root[data-qb-inline] .qb-body{height:var(--qb-list-height)}
261
+ .qb-footer-left>:not(.qb-toast),.qb-hint{display:none}
217
262
  .qb-footer{justify-content:flex-end}
263
+ .qb-footer-left:has(.qb-toast){flex:1}
264
+ .qb-hud{bottom:calc(24px + env(safe-area-inset-bottom,0px))}
218
265
  .qb-form{grid-template-columns:1fr}
219
266
  .qb-form-label{text-align:left;padding:0}
220
267
  .qb-meta,.qb-split .qb-detail{display:none}
@@ -224,36 +271,32 @@ textarea.qb-field-input{height:auto;min-height:96px;padding:8px 10px;resize:vert
224
271
  .qb-root *,.qb-root *::before,.qb-root *::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition:none!important}
225
272
  .qb-progress::after{animation:qb-slide 1.6s linear infinite!important}
226
273
  }
227
- `});function I(s){return s.replace(/[&<>"']/g,e=>si[e])}function qt(s){let e=s.trim();return/^(https?:|mailto:|tel:|#|\/|\.\.?\/)/i.test(e)||/^data:image\/(png|jpe?g|gif|webp|avif);/i.test(e)||!/^[a-z][a-z0-9+.-]*:/i.test(e)?e:null}function B(s){let e=[],t=s.replace(/(`+)([\s\S]*?[^`])\1(?!`)/g,(i,r,n)=>(e.push(`<code>${I(n.trim())}</code>`),`\0${e.length-1}\0`));return t=I(t),t=t.replace(/!\[([^\]]*)\]\(([^)\s]+)(?:\s+&quot;([^&]*)&quot;)?\)/g,(i,r,n)=>{let o=qt(Mt(n));return o?`<img src="${I(o)}" alt="${r}" loading="lazy">`:i}),t=t.replace(/\[([^\]]+)\]\(([^)\s]+)(?:\s+&quot;([^&]*)&quot;)?\)/g,(i,r,n)=>{let o=qt(Mt(n));if(!o)return r;let a=/^https?:/i.test(o);return`<a href="${I(o)}"${a?' target="_blank" rel="noopener noreferrer"':""}>${r}</a>`}),t=t.replace(/(^|[\s(])(https?:\/\/[^\s<)]+[^\s<).,;:!?'"])/g,(i,r,n)=>`${r}<a href="${n}" target="_blank" rel="noopener noreferrer">${n}</a>`),t=t.replace(/\*\*([^*]+)\*\*|__([^_]+)__/g,(i,r,n)=>`<strong>${r??n}</strong>`),t=t.replace(/(^|[^*\w])\*([^*\s][^*]*?)\*(?!\w)/g,"$1<em>$2</em>"),t=t.replace(/(^|[^_\w])_([^_\s][^_]*?)_(?!\w)/g,"$1<em>$2</em>"),t=t.replace(/~~([^~]+)~~/g,"<del>$1</del>"),t=t.replace(/ {2,}\n|\\\n/g,"<br>"),t.replace(/\u0000(\d+)\u0000/g,(i,r)=>e[Number(r)])}function Mt(s){return s.replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&lt;/g,"<").replace(/&gt;/g,">")}function S(s){let e=s.replace(/\r\n?/g,`
228
- `).split(`
229
- `),t=[],i=[],r=[],n=0,o=()=>{i.length&&(t.push(`<p>${B(i.join(`
230
- `))}</p>`),i=[])},a=(c=-1)=>{for(;r.length&&r[r.length-1].indent>c;)t.push(`</li></${r.pop().type}>`)};for(;n<e.length;){let c=e[n],l=c.match(/^\s*(```+|~~~+)\s*([\w+#.-]*)/);if(l){o(),a();let p=l[1],g=l[2]??"",f=[];for(n++;n<e.length&&!e[n].trim().startsWith(p);)f.push(e[n++]);n++,t.push(`<div class="qb-code"><div class="qb-code-head"><span>${I(g)}</span><button type="button" class="qb-code-copy" data-qb-copy>Copy</button></div><pre><code${g?` class="language-${I(g)}"`:""}>${I(f.join(`
231
- `))}</code></pre></div>`);continue}if(!c.trim()){o();let p=e[n+1]??"";!/^\s*([-*+]|\d+[.)])\s+/.test(p)&&!/^\s{2,}\S/.test(p)&&a(),n++;continue}let h=c.match(/^(#{1,6})\s+(.*?)\s*#*\s*$/);if(h){o(),a();let p=h[1].length;t.push(`<h${p}>${B(h[2])}</h${p}>`),n++;continue}if(/^\s*([-*_])(\s*\1){2,}\s*$/.test(c)){o(),a(),t.push("<hr>"),n++;continue}if(/^\s*>/.test(c)){o(),a();let p=[];for(;n<e.length&&/^\s*>/.test(e[n]);)p.push(e[n++].replace(/^\s*>\s?/,""));t.push(`<blockquote>${S(p.join(`
232
- `))}</blockquote>`);continue}if(c.includes("|")&&/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(e[n+1]??"")){o(),a();let p=y=>y.trim().replace(/^\||\|$/g,"").split("|").map(x=>x.trim()),g=p(c),f=p(e[n+1]).map(y=>y.startsWith(":")&&y.endsWith(":")?"center":y.endsWith(":")?"right":"");n+=2;let b=[];for(;n<e.length&&e[n].includes("|")&&e[n].trim();)b.push(p(e[n++]));let v=(y,x,A)=>`<${y}${f[A]?` style="text-align:${f[A]}"`:""}>${B(x)}</${y}>`;t.push(`<div class="qb-table"><table><thead><tr>${g.map((y,x)=>v("th",y,x)).join("")}</tr></thead><tbody>${b.map(y=>`<tr>${y.map((x,A)=>v("td",x,A)).join("")}</tr>`).join("")}</tbody></table></div>`);continue}let d=c.match(/^(\s*)([-*+]|\d+[.)])\s+(.*)$/);if(d){o();let p=d[1].length,g=/\d/.test(d[2])?"ol":"ul",f=r[r.length-1];if(!f||p>f.indent){let x=g==="ol"&&parseInt(d[2],10)!==1?` start="${parseInt(d[2],10)}"`:"";t.push(`<${g}${x}><li>`),r.push({type:g,indent:p})}else{a(p);let x=r[r.length-1];x&&x.type!==g?(t.push(`</li></${r.pop().type}><${g}><li>`),r.push({type:g,indent:p})):x?t.push("</li><li>"):(t.push(`<${g}><li>`),r.push({type:g,indent:p}))}let b=d[3],v=b.match(/^\[([ xX])\]\s+(.*)$/);v?b=`<input type="checkbox" disabled${v[1]!==" "?" checked":""}> ${B(v[2])}`:b=B(b),n++;let y=[];for(;n<e.length&&/^\s{2,}\S/.test(e[n])&&!/^\s*([-*+]|\d+[.)])\s+/.test(e[n]);)y.push(e[n++].trim());t.push(b+(y.length?` ${B(y.join(`
233
- `))}`:""));continue}a(),i.push(c),n++}return o(),a(),t.join("")}var si,Ke=q(()=>{"use strict";si={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}});function Tt(s,e){let t=parseFloat(s);return Number.isFinite(t)&&t>0?t:e}function je(s,e){if(s.length!==e.length)return!1;for(let t=0;t<s.length;t++)if(s[t]!==e[t])return!1;return!0}function At(s,e){let t=0,i=s.length-1;for(;t<i;){let r=t+i+1>>1;s[r]<=e?t=r:i=r-1}return t}var oi,Et,It,ze,te,ge,be,ye,ve,St=q(()=>{"use strict";de();Fe();Ke();oi=150,Et=10,It=(s,e)=>`${s.instanceId}-opt-${e.replace(/[^\w-]/g,"_")}`;ze=new WeakMap,te=class{constructor(e,t){m(this,"bar",e);m(this,"frame",t);m(this,"el");m(this,"hasInput",!0);m(this,"scroller");m(this,"inner");m(this,"emptyEl");m(this,"detailEl");m(this,"cache",new Map);m(this,"renderedKeys",[]);m(this,"selectedEl");m(this,"virtual",!1);m(this,"offsets",[]);m(this,"rowHeight",42);m(this,"sectionHeight",30);m(this,"rafId",0);m(this,"detailFor");m(this,"onScroll",()=>{!this.virtual||this.rafId||(this.rafId=requestAnimationFrame(()=>{this.rafId=0,this.renderWindow()}))});m(this,"onPointerMove",e=>{let t=e.target.closest?.("[data-index]");if(!t)return;let i=Number(t.dataset.index);i!==this.frame.selected&&this.select(i,!1)});m(this,"onClick",e=>{let t=e.target.closest?.("[data-index]");t&&(this.select(Number(t.dataset.index),!1),this.bar.runPrimary(this.frame,e.metaKey||e.ctrlKey?1:0))});this.inner=u("div",{class:"qb-list-inner"}),this.scroller=u("div",{class:`${e.cls("qb-scroll qb-list","list")}`,role:"listbox",id:`${e.instanceId}-list`,"aria-label":"Results",tabindex:"-1"},this.inner),this.emptyEl=u("div",{class:"qb-empty",hidden:!0}),t.view.type==="list"&&t.view.detail?(this.detailEl=u("div",{class:e.cls("qb-detail qb-md","detail")}),this.el=u("div",{class:"qb-split",style:"display:flex;flex:1;min-width:0;position:relative"},this.scroller,this.detailEl,this.emptyEl)):this.el=u("div",{style:"display:flex;flex:1;min-width:0;position:relative"},this.scroller,this.emptyEl),this.scroller.addEventListener("pointermove",this.onPointerMove),this.scroller.addEventListener("click",this.onClick),this.scroller.addEventListener("pointerdown",r=>r.preventDefault()),this.scroller.addEventListener("scroll",this.onScroll,{passive:!0})}measure(){let e=getComputedStyle(this.bar.dom.root);this.rowHeight=Tt(e.getPropertyValue("--qb-row-height"),42),this.sectionHeight=Tt(e.getPropertyValue("--qb-section-height"),30)}update(){let e=this.frame.rows,t=this.virtual;if(this.virtual=e.length>oi,this.virtual){t||this.measure();let i=0;this.offsets=e.map(r=>{let n=i;return i+=r.kind==="section"?this.sectionHeight:this.rowHeight,n}),this.inner.style.height=`${i}px`,this.renderWindow()}else{if(t){this.inner.style.height="";for(let{el:n}of this.cache.values())n.style.cssText=""}let i=e.map(n=>n.key),r=e.map(n=>this.rowEl(n));(!je(i,this.renderedKeys)||r.some((n,o)=>this.inner.children[o]!==n))&&(this.inner.replaceChildren(...r),this.renderedKeys=i),this.prune(new Set(i))}this.updateSelection(),this.updateEmpty(),this.updateDetail()}prune(e){if(!(this.cache.size<400))for(let t of this.cache.keys())e.has(t)||this.cache.delete(t)}renderWindow(){let e=this.frame.rows,t=this.scroller.scrollTop,i=this.scroller.clientHeight||400,r=At(this.offsets,t)-Et;r=Math.max(0,r);let n=At(this.offsets,t+i)+Et;n=Math.min(e.length,n+1);let o=[],a=[];for(let c=r;c<n;c++){let l=e[c],h=this.rowEl(l);h.style.position="absolute",h.style.top=`${this.offsets[c]}px`,h.style.left="0",h.style.right="0",o.push(h),a.push(l.key)}je(a,this.renderedKeys)||(this.inner.replaceChildren(...o),this.renderedKeys=a),this.updateSelection()}rowSig(e){return e.kind==="section"?e.title:`${e.index}|${e.positions?.join(",")??""}`}rowEl(e){let t=this.rowSig(e),i=this.cache.get(e.key);if(i&&i.sig===t&&(e.kind==="section"||i.el.__item===e.item))return i.el;let r=e.kind==="section"?this.sectionEl(e.title):this.itemEl(e);return e.kind==="item"&&(r.__item=e.item),this.cache.set(e.key,{el:r,sig:t}),r}sectionEl(e){return u("div",{class:this.bar.cls("qb-section","section"),role:"presentation"},e)}itemEl(e){let{item:t}=e,i=this.frame.view.type==="root",r=[];return t.accessories?.length?r.push(u("span",{class:"qb-item-accessories"},...t.accessories.map(vt))):t.shortcut&&r.push(u("span",{class:"qb-item-accessories"},R(t.shortcut))),i&&!t.accessories?.length&&!t.shortcut&&r.push(u("span",{class:"qb-item-kind"},this.kindOf(t))),u("div",{class:this.bar.cls("qb-item","item"),role:"option",id:It(this.bar,e.key),"aria-selected":"false","data-index":String(e.index)},u("span",{class:"qb-item-icon"},k(t.icon??(i?"command":void 0),16)),u("span",{class:"qb-item-text"},u("span",{class:"qb-item-title"},Pe(t.title,e.positions)),t.subtitle?u("span",{class:"qb-item-subtitle"},t.subtitle):null),...r)}kindOf(e){return this.bar.itemExt.get(e)?"Command":e.href?"Page":e.url?"Link":"Command"}updateSelection(){let e=this.frame.itemRows[this.frame.selected],t=e?this.cache.get(e.key)?.el:void 0;this.selectedEl&&this.selectedEl!==t&&this.selectedEl.setAttribute("aria-selected","false"),t&&t.setAttribute("aria-selected","true"),this.selectedEl=t}updateEmpty(){let e=this.frame,t=e.itemRows.length===0;if(this.scroller.hidden=t&&!this.detailEl,!t||e.loading>0&&!e.error){this.emptyEl.hidden=!0;return}let i=e.view,r="search",n="No results",o=e.query?`Nothing matches \u201C${e.query}\u201D`:null;e.error?(r="alert",n="Couldn\u2019t load results",o=e.error):i.emptyView?(r=i.emptyView.icon??r,n=i.emptyView.title,o=i.emptyView.description??null):e.view.type==="root"&&!e.query&&(n="Start typing to search",o=null),this.emptyEl.replaceChildren(k(r,28)??"",u("div",{class:"qb-empty-title"},n),o?u("div",{class:"qb-empty-desc"},o):""),this.emptyEl.hidden=!1}updateDetail(){let e=this.detailEl;if(!e)return;let t=this.bar.selectedItem(this.frame);if(t===this.detailFor)return;if(this.detailFor=t,!t?.detail){e.innerHTML=t?.description?S(t.description):"";return}let i=ze.get(t);if(i===void 0){let r=t.detail;i=typeof r=="function"?Promise.resolve(r()):r,ze.set(t,i)}typeof i=="string"?e.innerHTML=S(i):(e.innerHTML="",i.then(r=>{ze.set(t,r),this.detailFor===t&&(e.innerHTML=S(r))},r=>{this.detailFor===t&&(e.textContent=String(r?.message??r))}))}select(e,t=!0){let i=this.frame.itemRows.length;i&&(this.frame.selected=(e%i+i)%i,this.frame.selectedKey=this.frame.itemRows[this.frame.selected].key,this.frame.userMoved=!0,t&&this.ensureVisible(),this.updateSelection(),this.bar.invalidate())}move(e){let t=this.frame.itemRows.length;if(!t)return;let i=this.frame.selected+e;this.select(Math.abs(e)===1?i:Math.max(0,Math.min(t-1,i)))}ensureVisible(){let e=this.frame,t=e.itemRows[e.selected];if(!t)return;let i=e.rows.indexOf(t),r=e.rows[i-1],n,o;if(this.virtual)n=this.offsets[i],o=n+this.rowHeight,r?.kind==="section"&&(n=this.offsets[i-1]);else{let l=this.cache.get(t.key)?.el;if(!l)return;if(n=l.offsetTop,o=n+l.offsetHeight,r?.kind==="section"){let h=this.cache.get(r.key)?.el;h&&(n=h.offsetTop)}}let a=8,c=this.scroller;e.selected===0?c.scrollTop=0:n<c.scrollTop+a?c.scrollTop=n-a:o>c.scrollTop+c.clientHeight-a&&(c.scrollTop=o-c.clientHeight+a),this.virtual&&this.renderWindow()}onKey(e){let t=e.key,i=e.metaKey||e.ctrlKey;if(t==="ArrowDown"&&i)return this.select(this.frame.itemRows.length-1),!0;if(t==="ArrowUp"&&i)return this.select(0),!0;if(t==="ArrowDown"||e.ctrlKey&&!e.metaKey&&!e.altKey&&(t==="n"||t==="j"))return this.move(1),!0;if(t==="ArrowUp"||e.ctrlKey&&!e.metaKey&&!e.altKey&&t==="p")return this.move(-1),!0;if(t==="PageDown")return this.move(8),!0;if(t==="PageUp")return this.move(-8),!0;if(t==="Enter"&&!i&&!e.altKey)return this.bar.runPrimary(this.frame),!0;if(t==="Tab"&&!e.shiftKey&&!i&&!e.altKey){let r=this.bar.selectedItem(this.frame);if(r?.arguments?.length){let n=this.bar.actionsFor(r,this.frame)[0];return n&&this.bar.runAction(this.frame,r,n),!0}return this.frame.view.type==="root"&&this.bar.ai&&this.bar.ask(this.frame.query),!0}return!1}scrollTop(){return this.scroller.scrollTop}restoreScroll(e){this.scroller.scrollTop=e,this.virtual&&this.renderWindow()}resetScroll(){this.scroller.scrollTop=0}destroy(){cancelAnimationFrame(this.rafId)}};ge=class extends te{constructor(e,t){super(e,t);let i=t.view;this.scroller.className=e.cls("qb-scroll qb-grid","grid"),this.scroller.style.setProperty("--qb-columns",String(i.columns??5)),i.aspectRatio&&this.scroller.style.setProperty("--qb-aspect",i.aspectRatio),i.fit&&this.scroller.style.setProperty("--qb-fit",i.fit),this.inner.style.display="contents"}update(){let e=this.frame.rows.slice(0,600),t=e.map(r=>r.key),i=e.map(r=>this.rowEl(r));je(t,this.renderedKeys)||(this.inner.replaceChildren(...i),this.renderedKeys=t),this.updateSelection(),this.updateEmpty()}itemEl(e){let{item:t}=e,i=u("div",{class:"qb-cell-media"});if(t.image)i.append(u("img",{src:t.image,alt:"",loading:"lazy",decoding:"async",draggable:"false"}));else{let r=k(t.icon,28);r&&i.append(r)}return u("div",{class:this.bar.cls("qb-cell","item"),role:"option",id:It(this.bar,e.key),"aria-selected":"false","data-index":String(e.index),title:t.title},i,u("div",{class:"qb-cell-title"},Pe(t.title,e.positions)),t.subtitle?u("div",{class:"qb-cell-subtitle"},t.subtitle):null)}ensureVisible(){let e=this.frame.itemRows[this.frame.selected];(e&&this.cache.get(e.key)?.el)?.scrollIntoView({block:"nearest"})}onKey(e){let t=this.frame.view.columns??5;return e.key==="ArrowRight"&&!e.metaKey&&!e.ctrlKey?(this.move(1),!0):e.key==="ArrowLeft"&&!e.metaKey&&!e.ctrlKey?(this.move(-1),!0):e.key==="ArrowDown"&&!e.metaKey&&!e.ctrlKey?(this.step(t),!0):e.key==="ArrowUp"&&!e.metaKey&&!e.ctrlKey?(this.step(-t),!0):super.onKey(e)}step(e){let t=this.frame.itemRows.length,i=this.frame.selected+e;i>=0&&i<t&&this.select(i)}},be=class{constructor(e,t){m(this,"bar",e);m(this,"frame",t);m(this,"el");m(this,"hasInput",!1);m(this,"body");m(this,"rendered","");m(this,"raf",0);let i=t.view;this.body=u("div",{class:e.cls("qb-detail qb-md","detail"),tabindex:"-1"});let r=[this.body];i.metadata?.length&&r.push(u("div",{class:"qb-meta"},...i.metadata.map(n=>u("div",null,u("div",{class:"qb-meta-label"},n.label),u("div",{class:"qb-meta-value"},k(n.icon,14),n.tag?_e(n.tag):null,n.href?u("a",{href:n.href,target:/^https?:/.test(n.href)?"_blank":null,rel:"noopener"},n.value??n.href):n.value??null))))),this.el=u("div",{style:"display:flex;flex:1;min-width:0"},...r)}update(){this.raf||(this.raf=requestAnimationFrame(()=>{this.raf=0,this.render()}))}render(){let e=this.frame.detail;if(!e)return;let t=`${e.text.length}|${e.done}|${e.error??""}`;if(t===this.rendered)return;this.rendered=t;let i=this.body.scrollTop+this.body.clientHeight>=this.body.scrollHeight-24,r=S(e.text);e.done||(r+='<span class="qb-caret"></span>'),e.error&&(r+=`<p class="qb-msg-error">${e.error.replace(/</g,"&lt;")}</p>`),this.body.innerHTML=r,i&&!e.done&&(this.body.scrollTop=this.body.scrollHeight)}onKey(e){return e.key==="ArrowDown"?(this.body.scrollTop+=40,!0):e.key==="ArrowUp"?(this.body.scrollTop-=40,!0):e.key==="Enter"&&!e.metaKey&&!e.ctrlKey?(this.bar.runPrimary(this.frame),!0):!1}viewActions(){let e=this.frame.detail;return[{title:"Copy Content",icon:"copy",shortcut:"mod+shift+c",keepOpen:!0,run:async t=>{let i=await t.copy(e?.text??"");return t.toast({title:i?"Copied to clipboard":"Copy failed",style:i?"success":"failure"}),!1}}]}focusTarget(){return this.body}scrollTop(){return this.body.scrollTop}restoreScroll(e){this.body.scrollTop=e}destroy(){cancelAnimationFrame(this.raf)}},ye=class{constructor(e,t){m(this,"bar",e);m(this,"frame",t);m(this,"el");m(this,"hasInput",!1);m(this,"inputs",new Map);m(this,"errors",new Map);let i=t.view,r=[];for(let n of i.fields){let o=`${e.instanceId}-f-${n.name}`,a=u("label",{class:"qb-form-label",for:o,"data-required":n.required?"":null},n.type==="checkbox"?"":n.label??n.name),c=this.control(n,o),l=u("div",{class:"qb-field-error",hidden:!0,id:`${o}-err`});this.errors.set(n.name,l),r.push(a,u("div",{class:"qb-field"},c,n.description?u("div",{class:"qb-field-desc"},n.description):null,l))}this.el=u("form",{class:e.cls("qb-form","form"),novalidate:!0},...r),this.el.addEventListener("submit",n=>{n.preventDefault(),this.submit()})}control(e,t){let i=this.frame.form.values,r=o=>{i[e.name]=o,this.frame.form.errors[e.name]&&(delete this.frame.form.errors[e.name],this.showErrors())},n;if(e.type==="checkbox"){let o=u("input",{type:"checkbox",id:t,checked:!!i[e.name]});return o.addEventListener("change",()=>r(o.checked)),this.inputs.set(e.name,o),u("label",{class:"qb-field-check"},o,u("span",null,e.label??e.name))}if(e.type==="select"){let o=u("select",{class:"qb-field-input",id:t},...(e.options??[]).map(a=>u("option",{value:a.value},a.title)));o.value=String(i[e.name]??""),o.addEventListener("change",()=>r(o.value)),n=o}else if(e.type==="textarea"){let o=u("textarea",{class:"qb-field-input",id:t,placeholder:e.placeholder??"",rows:4});o.value=String(i[e.name]??""),o.addEventListener("input",()=>r(o.value)),n=o}else{let o=u("input",{class:"qb-field-input",id:t,type:e.type??"text",placeholder:e.placeholder??"",autocomplete:e.type==="password"?"off":"on",spellcheck:"false"});o.value=String(i[e.name]??""),o.addEventListener("input",()=>r(e.type==="number"?o.value===""?"":Number(o.value):o.value)),n=o}return n.setAttribute("aria-describedby",`${t}-err`),this.inputs.set(e.name,n),n}showErrors(){let e=this.frame.form.errors;for(let[t,i]of this.errors){let r=e[t];i.hidden=!r,i.textContent=r??"",this.inputs.get(t)?.setAttribute("aria-invalid",r?"true":"false")}}submit(){let e=this.frame.view,t=this.frame.form;t.errors={};for(let r of e.fields){let n=t.values[r.name];if(r.required&&(n===""||n==null||n===!1))t.errors[r.name]=`${r.label??r.name} is required`;else{let o=r.validate?.(n,t.values);o&&(t.errors[r.name]=o)}}this.showErrors();let i=Object.keys(t.errors)[0];if(i){this.inputs.get(i)?.focus();return}this.bar.runAction(this.frame,void 0,{title:e.submitLabel??"Submit",run:r=>e.onSubmit({...t.values},r)})}update(){}onKey(e){if(e.key==="Enter"&&(e.metaKey||e.ctrlKey))return this.submit(),!0;let t=e.target;return e.key==="Enter"&&t.tagName==="INPUT"&&t.type!=="checkbox"?(this.submit(),!0):!1}footerPrimary(){return{title:this.frame.view.submitLabel??"Submit",hotkey:"mod+enter",run:()=>this.submit()}}focusTarget(){return this.el.contains(document.activeElement)?document.activeElement:this.el.querySelector("input,textarea,select")??this.el}scrollTop(){return this.el.scrollTop}restoreScroll(e){this.el.scrollTop=e}destroy(){}},ve=class{constructor(e,t){m(this,"bar",e);m(this,"frame",t);m(this,"el");m(this,"hasInput",!0);m(this,"turnEls",[]);m(this,"emptyEl");m(this,"raf",0);this.el=u("div",{class:e.cls("qb-chat","chat"),role:"log","aria-live":"polite",tabindex:"-1"})}update(){this.raf||(this.raf=requestAnimationFrame(()=>{this.raf=0,this.render()}))}render(){let e=this.frame.chat?.turns??[];if(!e.length){this.emptyEl||(this.emptyEl=this.empty(),this.el.replaceChildren(this.emptyEl));return}this.emptyEl&&(this.emptyEl.remove(),this.emptyEl=void 0);let t=this.el.scrollTop+this.el.clientHeight>=this.el.scrollHeight-40;e.forEach((i,r)=>{let n=`${i.text.length}|${i.streaming}|${i.error??""}|${i.tools.map(c=>c.state).join()}`,o=this.turnEls[r];if(o&&o.sig===n)return;let a;if(i.role==="user")a=u("div",{class:"qb-msg-user"},i.text);else{let c=u("div",{class:"qb-msg-head"},k("sparkles",13),this.bar.aiName),l=i.tools.length?u("div",{class:"qb-tools"},...i.tools.map(p=>{let g=k(p.state==="running"?"loader":p.state==="done"?"check":"x",12);return p.state==="running"&&g.classList.add("qb-spin"),u("span",{class:"qb-tool","data-state":p.state},g,p.label)})):null,h=u("div",{class:"qb-md"}),d=S(i.text);i.streaming&&(d+=i.text||!i.tools.length?'<span class="qb-caret"></span>':""),h.innerHTML=d,a=u("div",{class:"qb-msg-ai"},c,l,h,i.error?u("div",{class:"qb-msg-error"},i.error):null)}o?o.el.replaceWith(a):this.el.append(a),this.turnEls[r]={el:a,sig:n}}),t&&(this.el.scrollTop=this.el.scrollHeight)}empty(){let e=this.bar.aiOptions?.suggestions??[],t=e.length?e:["What can I do here?","Summarize this page"];return u("div",{class:"qb-chat-empty"},k("sparkles",26),u("div",{class:"qb-empty-title"},`Ask ${this.bar.aiName} anything`),u("div",{class:"qb-empty-desc"},"Ask a question or tell it what to do, like \u201Ctake me to billing\u201D."),u("div",{class:"qb-suggestions"},...t.map(i=>{let r=u("button",{class:"qb-suggestion",type:"button"},i);return r.addEventListener("click",()=>this.bar.sendChat(this.frame,i)),r})))}lastAnswer(){let e=this.frame.chat?.turns??[];for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant"&&e[t].text)return e[t].text;return""}onKey(e){if(e.key==="Enter"&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey){let t=this.frame.query.trim();return t&&this.bar.sendChat(this.frame,t),!0}return e.key==="ArrowUp"&&!this.frame.query?(this.el.scrollTop-=60,!0):e.key==="ArrowDown"&&!this.frame.query?(this.el.scrollTop+=60,!0):!1}placeholder(){return this.frame.chat?.turns.length??0?"Ask a follow-up\u2026":`Ask ${this.bar.aiName} anything\u2026`}footerPrimary(){return this.frame.chat?.controller?{title:"Stop",hotkey:"escape",run:()=>{this.bar.stopChat(this.frame)}}:{title:"Send",hotkey:"enter",run:()=>this.bar.sendChat(this.frame,this.frame.query)}}viewActions(){let e=this.frame.view;return[{title:"Copy Answer",icon:"copy",shortcut:"mod+shift+c",keepOpen:!0,run:async t=>{let i=await N(this.lastAnswer());return t.toast({title:i?"Copied answer":"Nothing to copy",style:i?"success":"failure"}),!1}},{title:"New Chat",icon:"plus",shortcut:"mod+shift+o",run:t=>(t.render({...e,type:"chat",prompt:void 0}),!1)}]}scrollTop(){return this.el.scrollTop}restoreScroll(e){this.el.scrollTop=e}destroy(){cancelAnimationFrame(this.raf)}}});var Ct={};we(Ct,{Bar:()=>Be,isView:()=>De});function pi(s,e){if(s===e)return!0;if(!s||!e)return!1;let t=Object.keys(s);return t.length!==Object.keys(e).length?!1:t.every(i=>s[i]===e[i])}async function ui(s,e){let t;try{return await Promise.race([Promise.resolve(s),new Promise((i,r)=>t=setTimeout(()=>r(new Error("timeout")),e))])}finally{clearTimeout(t)}}var ai,De,li,ci,di,hi,Be,Lt=q(()=>{"use strict";pt();oe();Ce();H();Oe();W();Fe();de();Ne();fe();St();ai=new Set(["list","grid","detail","form","chat"]),De=s=>!!s&&typeof s=="object"&&ai.has(s.type),li="nav a[href], header a[href], aside a[href], [data-qikbar-index] a[href]",ci="mod+.",di=s=>s.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64),hi=0,Be=class{constructor(e={}){m(this,"config");m(this,"instanceId",xt("qikbar"));m(this,"storageAdapter");m(this,"storage");m(this,"frecency");m(this,"registrations",new Map);m(this,"regCounter",0);m(this,"sources",new Set);m(this,"sourceExt",new WeakMap);m(this,"itemExt",new WeakMap);m(this,"extensions",new Map);m(this,"configExtensions",[]);m(this,"configSources",[]);m(this,"ids",new WeakMap);m(this,"listeners",new Map);m(this,"stack",[]);m(this,"_open",!1);m(this,"rootCache",null);m(this,"routeItems",[]);m(this,"autoItems",[]);m(this,"shortcutItems",[]);m(this,"aiOptions");m(this,"ai");m(this,"dom");m(this,"renderer");m(this,"panel");m(this,"toastState");m(this,"toastTimer");m(this,"toastId",0);m(this,"hud");m(this,"confirmState");m(this,"argMode");m(this,"seq",new z);m(this,"prevFocus",null);m(this,"teardown",[]);m(this,"appliedVars",[]);m(this,"scheduled",!1);m(this,"scrollLock");m(this,"closeTimer");m(this,"destroyed",!1);m(this,"styleEl");m(this,"onGlobalKeyDown",e=>{if(this.destroyed||e.defaultPrevented||e.isComposing)return;let t=this.config.hotkey===!1?[]:[].concat(this.config.hotkey??"mod+k"),i=j(e.target);if(t.some(l=>E(e,l)&&(!i||U(l)))){e.preventDefault(),e.stopPropagation(),this.isInline?(this.open(),this.focusInput()):this.toggle();return}if(this._open&&!this.isInline||this.isInline&&this.dom?.root.contains(e.target)||this.config.shortcuts===!1||(this.rootItems(),!this.shortcutItems.length))return;let r=this.shortcutItems.map(l=>l.shortcut).filter(l=>!i||U(l)),n=this.seq.feed(e,r);if(!n.length)return;let o=this.shortcutItems.find(l=>l.shortcut===n[0]);if(!o)return;e.preventDefault();let a=this.createFrame({type:"root"}),c=this.actionsFor(o,a)[0];c&&this.runAction(a,o,c)});m(this,"onGlobalClick",e=>{let t=e.target?.closest?.("[data-qikbar-open]");if(!t||this.destroyed)return;let i=t.getAttribute("data-qikbar-open");(i?i!==this.instanceId&&i!==this.config.namespace:this.isInline)||(e.preventDefault(),this.open({query:t.getAttribute("data-qikbar-query")??void 0}))});m(this,"onDialogKeyDown",e=>{if(e.stopPropagation(),e.isComposing||e.keyCode===229)return;let t=this.top;if(!t)return;if(this.confirmState){if(e.key==="Escape")e.preventDefault(),this.confirmState.resolve(!1);else if(e.key==="Tab"){let r=[...this.dom?.layer.querySelectorAll("button")??[]],n=r.indexOf(document.activeElement);e.preventDefault(),r[(n+(e.shiftKey?-1:1)+r.length)%r.length]?.focus()}e.stopPropagation();return}if(this.panel){this.onPanelKey(e)&&(e.preventDefault(),e.stopPropagation());return}if(this.argMode){if(e.key==="Escape"){e.preventDefault(),e.stopPropagation(),this.argMode=void 0,this.flush(),this.focusInput();return}if(e.key==="Enter"){e.preventDefault(),this.submitArgs();return}return}if(e.key==="Escape"){e.preventDefault(),e.stopPropagation(),this.escape();return}if(E(e,this.actionsHotkey)){e.preventDefault(),this.openPanel();return}if(this.renderer?.onKey(e)){e.preventDefault();return}let i=this.actionsFor(this.selectedItem(t),t);if(e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.shiftKey&&!e.altKey&&t.view.type!=="form"){let r=i[1];if(r&&!r.shortcut){e.preventDefault(),this.runAction(t,this.selectedItem(t),r);return}}for(let r of i)if(r.shortcut&&E(e,r.shortcut)){e.preventDefault(),this.runAction(t,this.selectedItem(t),r);return}e.key==="Backspace"&&this.stack.length>1&&e.target===this.dom?.input&&!this.dom.input.value&&!e.repeat&&(e.preventDefault(),this.pop())});if(this.config={...e},this.storageAdapter=e.storage??P(),this.storage=Q(this.storageAdapter,e.namespace??"qikbar"),this.frecency=new D(this.storage),this.applyConfig(e,!0),!(typeof document>"u")&&(this.listen(document,"keydown",this.onGlobalKeyDown,!0),this.listen(document,"click",this.onGlobalClick,!0),this.inlineTarget())){let t=()=>this.open({focus:!1});document.readyState==="loading"?this.listen(document,"DOMContentLoaded",t):t()}}get isOpen(){return this._open}get query(){return this.top?.query??""}get top(){return this.stack[this.stack.length-1]}get isInline(){return!!this.config.inline}get aiName(){return this.aiOptions?.name??"AI"}get actionsHotkey(){return this.config.actionsHotkey??ci}open(e={}){if(this.destroyed||typeof document>"u")return;if(this.mount(),clearTimeout(this.closeTimer),!this._open){this._open=!0,this.prevFocus=document.activeElement,this.rootCache=null,this.autoIndex(),this.resetToRoot(),this.applyTheme();let i=this.dom;i.root.dataset.qbState="open",i.overlay.hidden=this.isInline,i.dialog.hidden=!1,this.isInline||this.lockScroll(),this.emit("open",void 0),this.config.onOpen?.()}e.view&&this.push(e.view),e.query!=null&&this.setQuery(e.query),this.flush(),e.focus!==!1&&this.focusInput(),this.emitChange()}close(){if(!this._open||!this.dom)return;if(this.closePanel(),this.confirmState?.resolve(!1),this.confirmState=void 0,this.argMode=void 0,this.isInline){this.resetToRoot(),this.flush(),document.activeElement?.blur?.(),this.emitChange();return}this._open=!1;let e=this.dom;e.root.dataset.qbState="closing";let t=()=>{if(!this._open){e.root.dataset.qbState="closed",e.dialog.hidden=!0,e.overlay.hidden=!0,this.renderer?.destroy(),this.renderer=void 0,e.body.replaceChildren();for(let n of this.stack)this.destroyFrame(n);this.stack=[]}};typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches?t():this.closeTimer=setTimeout(t,120),this.unlockScroll();let r=this.prevFocus;r&&typeof r.focus=="function"&&document.contains(r)&&r.focus({preventScroll:!0}),this.toastState&&this.renderToast(),this.emit("close",void 0),this.config.onClose?.(),this.emitChange()}toggle(){this._open&&!this.isInline?this.close():this.open()}register(e){let t=++this.regCounter;return this.registrations.set(t,Array.isArray(e)?e:[e]),this.invalidateRoot(),()=>{this.registrations.delete(t),this.invalidateRoot()}}addSource(e){return this.sources.add(e),()=>{this.sources.delete(e);for(let t of this.stack)t.sourceResults?.delete(e.id);this.invalidate()}}use(e,t={}){this.extensions.get(e.name)?.cleanup?.();let i=Q(this.storageAdapter,`${this.config.namespace??"qikbar"}:ext:${e.name}`),r={ext:e,provided:t,storage:i,prefs:()=>{let h=i.get("preferences")??{},d={};for(let p of e.preferences??[])p.default!==void 0&&(d[p.name]=p.default);return{...d,...h,...t}},missing:()=>{let h=r.prefs();return(e.preferences??[]).filter(d=>d.required&&(h[d.name]===void 0||h[d.name]===""))}},n=(e.commands??[]).map(h=>{let{name:d,...p}=h,g={section:e.title,icon:e.icon,...p,id:`${e.name}.${d}`};return this.itemExt.set(g,r),g}),o=(e.sources??[]).map(h=>(this.sourceExt.set(h,r),this.addSource(h))),a;try{a=e.setup?.({bar:this,preferences:r.prefs(),storage:i})}catch(h){console.error(`[qikbar] extension "${e.name}" setup failed`,h)}let c=!1,l={rt:r,items:n,cleanup:()=>{c||(c=!0,o.forEach(h=>h()),typeof a=="function"&&a(),this.extensions.get(e.name)===l&&this.extensions.delete(e.name),this.invalidateRoot())}};return this.extensions.set(e.name,l),this.invalidateRoot(),l.cleanup}configure(e){let t=this.config;this.config={...this.config,...e},this.applyConfig(e,!1,t),this.dom&&(("theme"in e||"appearance"in e)&&this.applyTheme(),"classNames"in e&&this.applyClassNames(),"dir"in e&&(this.dom.root.dir=this.config.dir??"")),this.invalidateRoot()}push(e,t){if(!this._open&&(this.open(),!this._open))return;let i=this.top;i&&this.renderer&&(i.scrollTop=this.renderer.scrollTop());let r=this.createFrame(e,t??i?.ext);this.stack.push(r),this.closePanel(),this.argMode=void 0,this.startFrame(r),this.flush(),this.focusInput(),this.emitChange()}pop(){if(this.stack.length<=1)return;let e=this.stack.pop();this.destroyFrame(e),this.closePanel(),this.argMode=void 0,this.flush(),this.focusInput(),this.emitChange()}setQuery(e){let t=this.top;t&&(this.dom&&(this.dom.input.value=e),this.onQueryChange(t,e))}ask(e){if(!this.ai){this.toast({style:"failure",title:"AI is not configured",message:"Pass `ai` to createQikbar()."});return}this.push({type:"chat",prompt:e?.trim()||void 0})}commands(){return this.rootItems()}on(e,t){let i=this.listeners.get(e);return i||this.listeners.set(e,i=new Set),i.add(t),()=>i.delete(t)}preload(){return Promise.resolve()}destroy(){this.destroyed=!0,this._open&&!this.isInline&&this.unlockScroll(),this._open=!1;for(let e of this.stack)this.destroyFrame(e);this.stack=[];for(let e of this.extensions.values())e.cleanup?.();for(let e of this.teardown)e();this.teardown=[],this.dom?.root.remove(),this.hud?.remove(),this.dom=void 0,this.listeners.clear()}applyConfig(e,t,i){if(("routes"in e||t)&&(this.routeItems=(this.config.routes??[]).map(r=>({id:`route:${r.path}`,title:r.title,subtitle:r.subtitle,icon:r.icon??"arrow-right",keywords:[...r.keywords??[],r.path],section:r.section??"Navigation",href:r.path,shortcut:r.shortcut}))),("sources"in e||t)&&(t||i?.sources!==this.config.sources)){for(let r of this.configSources)r();this.configSources=(this.config.sources??[]).map(r=>this.addSource(r))}if("ai"in e||t){let r=this.config.ai;this.aiOptions=r?"stream"in r?{provider:r}:r:void 0,this.ai=this.aiOptions?dt(this.aiOptions.provider,this.aiOptions.system):void 0}if("extensions"in e||t){let r=(this.config.extensions??[]).map(a=>Array.isArray(a)?{ext:a[0],prefs:a[1]}:{ext:a,prefs:void 0}),n=!t&&i?.extensions===this.config.extensions,o=r.length===this.configExtensions.length&&r.every((a,c)=>a.ext===this.configExtensions[c].ext&&pi(a.prefs,this.configExtensions[c].prefs));if(!n&&!o){for(let a of this.configExtensions)a.uninstall();this.configExtensions=r.map(a=>({...a,uninstall:this.use(a.ext,a.prefs)}))}}}inlineTarget(){let e=this.config.inline;return!e||typeof document>"u"?null:typeof e=="string"?document.querySelector(e):e}emit(e,t){this.listeners.get(e)?.forEach(i=>{try{i(t)}catch(r){console.error(r)}})}emitChange(){let e={open:this._open,query:this.query,depth:this.stack.length,loading:!!this.top?.loading};this.emit("change",e)}listen(e,t,i,r=!1){e.addEventListener(t,i,r),this.teardown.push(()=>e.removeEventListener(t,i,r))}idOf(e){return e.id??this.ids.get(e)??e.title}invalidateRoot(){if(this.rootCache=null,this._open){for(let e of this.stack)e.view.type==="root"&&this.computeRows(e);this.invalidate()}}rootItems(){if(this.rootCache)return this.rootCache;let e=[],t=new Set,i=(r,n)=>{try{if(r.when&&!r.when())return}catch{return}let o=r.id??`${n}:${r.section??""}:${r.title}`;for(;t.has(o);)o+="'";t.add(o),this.ids.set(r,o),e.push(r)};for(let r of this.config.commands??[])i(r,"cmd");for(let r of this.routeItems)i(r,"route");for(let r of this.registrations.values())for(let n of r)i(n,"reg");for(let r of this.extensions.values())for(let n of r.items)i(n,"ext");for(let r of this.autoItems)i(r,"auto");return this.ai&&this.aiOptions?.fallback!==!1&&i({id:"qikbar.ask-ai",title:`Ask ${this.aiName}`,subtitle:"Chat, or tell it what to do",icon:"sparkles",section:"AI",keywords:["chat","assistant","ai","help"],searchOnly:!0,view:{type:"chat"}},"qb"),this.rootCache=e,this.shortcutItems=e.filter(r=>r.shortcut),e}autoIndex(){let e=this.config.autoIndex;if(!e||typeof document>"u"){this.autoItems.length&&(this.autoItems=[],this.rootCache=null);return}let t=e===!0?{}:e,i=[],r=new Set;if(t.links!==!1)for(let n of document.querySelectorAll(t.links??li)){if(n.closest(".qb-root")||n.closest("[data-qikbar-ignore]"))continue;let o=n.getAttribute("href")??"";if(!o||o.startsWith("#")&&!o.startsWith("#/")||/^(javascript|mailto|tel):/i.test(o))continue;let a=(n.getAttribute("aria-label")||n.textContent||n.title||"").replace(/\s+/g," ").trim().slice(0,80);if(!a)continue;let c=n.host!==location.host,l=c?n.href:o.startsWith("#")?o:n.pathname+n.search+n.hash;if(r.has(l))continue;r.add(l);let h=n.closest("[data-qikbar-section],nav[aria-label],aside[aria-label]");i.push({id:`auto:${l}`,title:a,subtitle:c?n.host:o.startsWith("#")?o:n.pathname,section:h?.dataset.qikbarSection??h?.getAttribute("aria-label")??t.section??"Pages",icon:c?"globe":"file",keywords:[l],...c?{url:l}:{href:l}})}if(t.elements!==!1)for(let n of document.querySelectorAll("[data-qikbar]")){if(n.closest(".qb-root"))continue;let o=(n.dataset.qikbar||n.getAttribute("aria-label")||n.textContent||"").replace(/\s+/g," ").trim().slice(0,80);o&&i.push({id:`el:${n.id||o}`,title:o,subtitle:n.dataset.qikbarSubtitle,keywords:n.dataset.qikbarKeywords?.split(",").map(a=>a.trim()),section:n.dataset.qikbarSection??"Actions",icon:n.dataset.qikbarIcon??"zap",shortcut:n.dataset.qikbarShortcut,run:()=>{n.click()}})}this.autoItems=i,this.rootCache=null}createFrame(e,t,i){return{id:++hi,view:e,query:("query"in e&&typeof e.query=="string"?e.query:"")||"",selected:0,rows:[],itemRows:[],loading:0,controller:new AbortController,ext:t,args:i}}resetToRoot(){for(let t of this.stack)this.destroyFrame(t);let e=this.createFrame({type:"root"});e.sourceResults=new Map,this.stack=[e],this.renderer?.destroy(),this.renderer=void 0,this.dom&&(this.dom.input.value=""),this.computeRows(e)}destroyFrame(e){e.controller.abort(),e.queryController?.abort(),e.chat?.controller?.abort();try{e.view.onClose?.()}catch(t){console.error(t)}}startFrame(e){let t=e.view;if(t.type==="list"||t.type==="grid")typeof t.items=="function"&&this.loadItems(e,!0),this.computeRows(e);else if(t.type==="detail")this.loadDetail(e,t);else if(t.type==="form"){let i={};for(let r of t.fields)i[r.name]=r.defaultValue??(r.type==="checkbox"?!1:r.type==="select"?r.options?.[0]?.value??"":"");e.form={values:i,errors:{}}}else t.type==="chat"&&(e.chat={messages:[],turns:[]},t.prompt&&queueMicrotask(()=>this.sendChat(e,t.prompt)))}replaceFrame(e,t){let i=this.stack.indexOf(e);if(i<0)return;let r=this.createFrame(t,e.ext,e.args);t.type===e.view.type&&!("query"in t&&t.query!=null)&&(r.query=e.query),e===this.top&&this.renderer&&(r.scrollTop=this.renderer.scrollTop()),r.selectedKey=e.itemRows[e.selected]?.key,r.userMoved=!!r.selectedKey,this.destroyFrame(e),this.stack[i]=r,this.startFrame(r),this.invalidate()}computeRows(e){let t=e.view,i;t.type==="root"?i=this.rootGroups(e):t.type==="list"||t.type==="grid"?i=this.listGroups(e,t):i=[];let r=[],n=[],o=new Set;for(let a of i)if(a.entries.length){a.title&&r.push({kind:"section",key:`s:${a.title}`,title:a.title});for(let c of a.entries){let l=t.type==="root"?this.idOf(c.item):c.item.id??`${a.title}:${c.item.title}`;for(;o.has(l);)l+="'";o.add(l);let h={kind:"item",key:l,item:c.item,positions:c.positions,index:n.length};r.push(h),n.push(h)}}if(e.rows=r,e.itemRows=n,e.userMoved||(e.selectedKey=void 0,e.selected=0),e.selectedKey){let a=n.findIndex(c=>c.key===e.selectedKey);e.selected=a>=0?a:Math.min(e.selected,Math.max(0,n.length-1))}else e.selected=Math.min(e.selected,Math.max(0,n.length-1));e.selectedKey=n[e.selected]?.key}rootGroups(e){let t=e.query.trim(),i=this.rootItems(),r=[],n=new Map,o=h=>{let d=n.get(h);return d||(d={title:h,entries:[]},n.set(h,d),r.push(d)),d};if(!t){let h=new Set,d=this.config.recents===!1?0:typeof this.config.recents=="number"?this.config.recents:4;if(d){let p=new Map(i.map(g=>[this.idOf(g),g]));for(let g of this.frecency.top(d*2)){let f=p.get(g);if(!(!f||f.searchOnly)&&(o("Recent").entries.push({item:f}),h.add(f),h.size>=d))break}}for(let p of i)p.searchOnly||h.has(p)||o(p.section??"Commands").entries.push({item:p});return r}let a=h=>{for(let d of this.sources){if((d.position??"bottom")!==h)continue;let p=e.sourceResults?.get(d.id);if(!p?.length)continue;let g=o(d.title??"Results"),f=d.filter?L(p,t):p.map(b=>({item:b,positions:Z(b,t)?.positions}));for(let b of f.slice(0,d.limit??8))g.entries.push({item:b.item,positions:b.positions})}};a("top");let c=L(i,t,{boost:h=>this.frecency.score(this.idOf(h))*.3,limit:300});for(let h of c)o(h.item.section??"Commands").entries.push({item:h.item,positions:h.positions});a("bottom");let l=(this.config.fallbacks??[]).map((h,d)=>({...h,id:`fallback:${d}`,title:h.title.replaceAll("{query}",t),subtitle:h.subtitle?.replaceAll("{query}",t)}));if(this.ai&&this.aiOptions?.fallback!==!1&&l.unshift({id:"qikbar.ask-ai-fallback",title:`Ask ${this.aiName}`,subtitle:`\u201C${t.length>60?`${t.slice(0,60)}\u2026`:t}\u201D`,icon:"sparkles",accessories:[{kbd:"tab"}],noHistory:!0,run:()=>({type:"chat",prompt:t})}),l.length){let h=o(`Use \u201C${t.length>24?`${t.slice(0,24)}\u2026`:t}\u201D with\u2026`);for(let d of l)h.entries.push({item:d})}return r}listGroups(e,t){let i=typeof t.items=="function"?e.items??[]:t.items,r=e.query.trim(),o=(t.filter??typeof t.items!="function")&&r?L(i,r).map(l=>({item:l.item,positions:l.positions})):i.map(l=>({item:l})),a=[],c=new Map;for(let l of o){let h=l.item.section??"",d=c.get(h);d||(d={title:h,entries:[]},c.set(h,d),a.push(d)),d.entries.push(l)}return a}onQueryChange(e,t){if(e.query===t)return;e.query=t;let i=e.view;(i.type==="root"||i.type==="list"||i.type==="grid")&&(e.selected=0,e.selectedKey=void 0,e.userMoved=!1,i.type==="root"?this.searchSources(e):typeof i.items=="function"&&this.loadItems(e,!1),this.computeRows(e),this.renderer?.resetScroll?.()),this.invalidate(),this.emitChange()}searchSources(e){e.queryController?.abort();let t=new AbortController;e.queryController=t;let i=e.query.trim(),r=e.sourceResults??(e.sourceResults=new Map);for(let n of this.sources){let o=r.get(n.id);if(i.length<(n.minQueryLength??1)){r.delete(n.id);continue}o&&r.set(n.id,o.filter(h=>Z(h,i)));let a=async()=>{if(!t.signal.aborted){e.loading++,this.invalidate();try{let h=this.sourceExt.get(n),d=await n.search({query:i,signal:t.signal,ctx:this.makeContext(e,{ext:h,signal:t.signal})});if(t.signal.aborted)return;if(h)for(let p of d)this.itemExt.set(p,h);r.set(n.id,d)}catch(h){t.signal.aborted||console.error(`[qikbar] source "${n.id}" failed`,h)}finally{e.loading--,!t.signal.aborted&&this.stack.includes(e)&&this.computeRows(e),this.invalidate()}}},c=n.debounce??150,l=setTimeout(a,c);t.signal.addEventListener("abort",()=>clearTimeout(l))}}loadItems(e,t){let i=e.view;if(typeof i.items!="function")return;let r=i.items;e.queryController?.abort();let n=new AbortController;e.queryController=n,e.controller.signal.addEventListener("abort",()=>n.abort());let o=async()=>{if(!n.signal.aborted){e.loading++,e.error=void 0,this.invalidate();try{let a=r({query:e.query,signal:n.signal,ctx:this.makeContext(e,{signal:n.signal})});if(a&&typeof a[Symbol.asyncIterator]=="function")for await(let c of a){if(n.signal.aborted)return;this.setItems(e,c)}else{let c=await a;n.signal.aborted||this.setItems(e,c)}}catch(a){n.signal.aborted||(e.error=a instanceof Error?a.message:String(a),e.items=[],this.computeRows(e))}finally{e.loading--,this.invalidate()}}};if(t)o();else{let a=setTimeout(o,i.debounce??120);n.signal.addEventListener("abort",()=>clearTimeout(a))}}setItems(e,t){if(e.items=t,e.ext)for(let i of t)this.itemExt.set(i,e.ext);this.computeRows(e),this.invalidate()}async loadDetail(e,t){e.detail={text:"",done:!1},e.loading++;try{let i=t.markdown;if(typeof i=="function"&&(i=await i()),typeof i=="string")e.detail.text=i;else for await(let r of i){if(e.controller.signal.aborted)return;e.detail.text+=r,this.invalidate()}}catch(i){e.controller.signal.aborted||(e.detail.error=i instanceof Error?i.message:String(i))}finally{e.detail.done=!0,e.loading--,this.invalidate()}}makeContext(e,t={}){let i=t.ext??e.ext;return{bar:this,get query(){return e.query},signal:t.signal??e.controller.signal,preferences:i?i.prefs():{},arguments:t.args??e.args??{},storage:i?.storage??this.storage,ai:this.ai,push:n=>this.push(n,i),pop:()=>this.pop(),render:n=>{this.stack.includes(e)?this.replaceFrame(e,n):this.push(n,i)},close:()=>this.close(),navigate:(n,o)=>this.navigate(n,o?.newTab??!1),openUrl:n=>{this.close(),window.open(n,"_blank","noopener,noreferrer")},copy:n=>N(n),toast:n=>this.toast(n),confirm:n=>this.confirm(n),setQuery:n=>{e===this.top?this.setQuery(n):e.query=n}}}navigate(e,t=!1){this.isInline||this.close();let i=this.config.navigate;if(i)return i(e,{newTab:t});ee(e,t)}actionsFor(e,t){let i=this.renderer?.frame===t?this.renderer.viewActions?.()??[]:[],r=[...t.view.actions??[],...i];if(!e)return r;t.actionCache??(t.actionCache=new WeakMap);let n=t.actionCache.get(e);if(n)return n;let o=[];if(e.run&&o.push({title:t.view.type==="root"?"Run Command":"Run",icon:"corner-down-left",run:e.run}),e.view){let c=e.view;o.push({title:"Open",icon:"chevron-right",run:l=>typeof c=="function"?c(l):c})}if(e.href){let c=e.href;o.push(M.navigate(c,{title:"Open"})),o.push(M.navigateNewTab(c)),o.push(M.copy(()=>new URL(c,location.href).href,{title:"Copy Link",icon:"link",shortcut:"mod+shift+c"}))}e.url&&(o.push(M.open(e.url)),o.push(M.copy(e.url,{title:"Copy URL",icon:"link",shortcut:"mod+shift+c"}))),e.actions&&o.push(...e.actions),o.push(...r);let a=this.itemExt.get(e);return t.view.type==="root"&&a?.ext.preferences?.length&&o.push({title:`Configure ${a.ext.title}`,icon:"settings",section:"Extension",run:()=>this.preferencesForm(a)}),t.view.type==="root"&&this.frecency.score(this.idOf(e))>0&&o.push({title:"Clear Recent History",icon:"history",section:"History",keepOpen:!0,run:()=>(this.frecency.clear(),this.computeRows(t),this.invalidate(),!1)}),t.actionCache.set(e,o),o}selectedItem(e=this.top){if(e)return e.itemRows[e.selected]?.item}async runAction(e,t,i,r){if(t?.arguments?.length&&!r){this.enterArgMode(e,t,i);return}let n=(t&&this.itemExt.get(t))??e.ext;if(t&&n&&n.missing().length){this.push(this.preferencesForm(n,()=>this.runAction(e,t,i,r)),n);return}t&&e.view.type==="root"&&!t.noHistory&&this.frecency.record(this.idOf(t)),t&&(this.config.onRun?.(t,i),this.emit("run",{item:t,action:i}));let o=!1,a=this.makeContext(e,{ext:n,args:r}),c=Object.create(a,{push:{value:l=>(o=!0,a.push(l))},render:{value:l=>(o=!0,a.render(l))},pop:{value:()=>(o=!0,a.pop())},close:{value:()=>(o=!0,a.close())},navigate:{value:(l,h)=>(o=!0,a.navigate(l,h))},openUrl:{value:l=>(o=!0,a.openUrl(l))}});e.loading++,this.invalidate();try{let l=await i.run(c);De(l)?this.push(l,n):l===!1||i.keepOpen||o||this.close()}catch(l){console.error(l),this.toast({style:"failure",title:"Something went wrong",message:l instanceof Error?l.message:String(l)})}finally{e.loading--,this.invalidate()}}runPrimary(e=this.top,t=0){if(!e)return;let i=this.selectedItem(e),r=this.actionsFor(i,e)[t];r&&this.runAction(e,i,r)}preferencesForm(e,t){let i=e.prefs();return{type:"form",title:`Configure ${e.ext.title}`,submitLabel:t?"Save and Continue":"Save",fields:(e.ext.preferences??[]).map(r=>({name:r.name,label:r.title,description:r.description,type:r.type==="text"?"text":r.type,required:r.required,placeholder:r.placeholder,options:r.options,defaultValue:i[r.name]??r.default})),onSubmit:r=>{let n=e.storage.get("preferences")??{};return e.storage.set("preferences",{...n,...r}),this.toast({style:"success",title:"Preferences saved"}),this.pop(),t?.(),!1}}}enterArgMode(e,t,i){this.argMode={item:t,action:i,frame:e,values:{}},this.closePanel(),this.flush(),this.dom?.args.querySelector("input,select")?.focus()}submitArgs(){let e=this.argMode;if(!e||!this.dom)return;let t=(e.item.arguments??[]).find(i=>i.required&&!e.values[i.name]?.trim());if(t){this.dom.args.querySelector(`[name="${CSS.escape(t.name)}"]`)?.focus();return}this.argMode=void 0,this.runAction(e.frame,e.item,e.action,e.values),this.flush()}sendChat(e,t){let i=e.chat;if(!i||!this.aiOptions||!t.trim()||i.controller&&!i.controller.signal.aborted)return;let r=new AbortController;e.controller.signal.addEventListener("abort",()=>r.abort()),i.controller=r,i.messages.push({role:"user",content:t}),i.turns.push({role:"user",text:t,tools:[]});let n={role:"assistant",text:"",tools:[],streaming:!0};i.turns.push(n),e===this.top&&this.dom&&(this.dom.input.value="",e.query=""),e.loading++,this.invalidate();let o=e.view,a=o.tools!==!1&&this.aiOptions.tools!==!1;(async()=>{try{for await(let l of ht({provider:this.aiOptions.provider,messages:i.messages,system:o.system??this.systemPrompt(a),tools:a?this.agentTools(e):[],maxSteps:this.aiOptions.maxSteps??6,signal:r.signal})){if(l.type==="text")n.text+=l.text;else if(l.type==="message")i.messages.push(l.message);else if(l.type==="tool_start")n.text&&!/\n\s*$/.test(n.text)&&(n.text+=`
274
+ `});function _i(){let s=typeof document<"u"?document.modelContext:void 0,e=typeof navigator<"u"?navigator.modelContext:void 0,t=s??e;return t&&typeof t.registerTool=="function"?t:void 0}function Wt(s,e={}){let t=_i();if(!t)return()=>{};let i=Ut(e.prefix??"qikbar"),n=new AbortController,r=[],o=new Map,a=l=>o.get(l)??s.rootItems().find(d=>s.idOf(d)===l),c=l=>{try{t.registerTool(l,{signal:n.signal}),r.push(l.name)}catch(d){console.warn(`[qikbar] could not register WebMCP tool "${l.name}"`,d)}};if(c({name:`${i}_list_commands`,description:`List the commands and pages available in this app's command bar (${typeof document<"u"?document.title:"this app"}). Returns ids you can pass to ${i}_run.`,inputSchema:{type:"object",properties:{}},annotations:{readOnlyHint:!0},execute:async()=>JSON.stringify(s.rootItems().filter(l=>!s.idOf(l).startsWith("qikbar.")).map(l=>({id:s.idOf(l),title:l.title,subtitle:l.subtitle,section:l.section,description:l.description,href:l.href??l.url})))}),c({name:`${i}_search`,description:`Search this app's commands, pages and records (including live data sources). Returns matching items with ids you can pass to ${i}_run.`,inputSchema:{type:"object",properties:{query:{type:"string",description:"What to look for"}},required:["query"]},annotations:{readOnlyHint:!0,untrustedContentHint:!0},execute:async(l,d)=>{let h=await s.searchForAgent(String(l.query??""),void 0,d?.signal??new AbortController().signal,o);return h.length?JSON.stringify(h):"No results."}}),e.run!==!1&&c({name:`${i}_run`,description:"Open a page or run a command in this app by id (from list_commands or search). Destructive commands ask the user first.",inputSchema:{type:"object",properties:{id:{type:"string"},arguments:{type:"object",description:"Values for the command arguments, if it has any.",additionalProperties:{type:"string"}}},required:["id"]},execute:async l=>{let d=a(String(l.id??""));if(!d)return`No item with id "${String(l.id)}". Call ${i}_search or ${i}_list_commands first.`;try{return await s.runForAgent(d,l.arguments,void 0,"agent")}catch(h){return`Error: ${h instanceof Error?h.message:String(h)}`}}}),e.tools!==!1)for(let{tool:l,rt:d,prefix:h}of s.toolList())c({name:Ut(`${i}_${h?`${h}_`:""}${l.name}`),description:l.description,inputSchema:l.parameters??{type:"object",properties:{}},annotations:l.confirm?{consequentialHint:!0}:void 0,execute:async b=>{if(l.confirm){let m=typeof l.confirm=="function"?l.confirm(b):s.t("allowTool",{tool:l.name});if(!await s.confirm({title:m,confirmLabel:s.t("allow")}))return"The user declined."}let v=await l.run(b,s.toolContext(d));return typeof v=="string"?v:JSON.stringify(v??"Done.")}});return()=>{if(n.abort(),typeof t.unregisterTool=="function")for(let l of r)try{t.unregisterTool(l)}catch{}}}var Ut,Qt=E(()=>{"use strict";Ut=s=>s.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64)});function Jt(s,e){let t=parseFloat(s);return Number.isFinite(t)&&t>0?t:e}function Ze(s,e){if(s.length!==e.length)return!1;for(let t=0;t<s.length;t++)if(s[t]!==e[t])return!1;return!0}function Yt(s,e){let t=0,i=s.length-1;for(;t<i;){let n=t+i+1>>1;s[n]<=e?t=n:i=n-1}return t}var Ni,zi,Gt,Xt,Xe,re,qe,Te,Ee,Me,Zt=E(()=>{"use strict";be();Qe();Ni=480,zi=150,Gt=10,Xt=(s,e)=>`${s.instanceId}-opt-${e.replace(/[^\w-]/g,"_")}`;Xe=new WeakMap,re=class{constructor(e,t){u(this,"bar",e);u(this,"frame",t);u(this,"el");u(this,"hasInput",!0);u(this,"scroller");u(this,"inner");u(this,"emptyEl");u(this,"detailEl");u(this,"cache",new Map);u(this,"renderedKeys",[]);u(this,"selectedEl");u(this,"virtual",!1);u(this,"offsets",[]);u(this,"rowHeight",42);u(this,"sectionHeight",30);u(this,"rafId",0);u(this,"detailFor");u(this,"press");u(this,"onScroll",()=>{!this.virtual||this.rafId||(this.rafId=requestAnimationFrame(()=>{this.rafId=0,this.renderWindow()}))});u(this,"onPointerMove",e=>{let t=this.press;if(t&&!t.fired&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>8&&this.cancelPress(),e.pointerType!=="mouse")return;let i=e.target.closest?.("[data-index]");if(!i)return;let n=Number(i.dataset.index);n!==this.frame.selected&&this.select(n,!1)});u(this,"onClick",e=>{let t=e.target.closest?.("[data-index]");if(!t)return;if(this.press?.fired){this.press=void 0,e.stopPropagation();return}let i=Number(t.dataset.index);this.select(i,!1);let n=this.frame.itemRows[i]?.item;if(n&&this.bar.isMulti(this.frame)){if(e.shiftKey)return this.bar.markRange(this.frame,n);if(e.metaKey||e.ctrlKey)return this.bar.toggleMark(this.frame,n);if(this.frame.marked?.size)return this.bar.toggleMark(this.frame,n)}this.bar.runPrimary(this.frame,e.metaKey||e.ctrlKey?1:0,"click")});u(this,"onPointerDown",e=>{if(e.preventDefault(),this.cancelPress(),e.pointerType==="mouse")return;let t=e.target.closest?.("[data-index]");if(!t)return;let i=Number(t.dataset.index),n={x:e.clientX,y:e.clientY,fired:!1,timer:setTimeout(()=>{n.fired=!0,this.select(i,!1),this.bar.openPanel(),navigator.vibrate?.(8)},Ni)};this.press=n});u(this,"cancelPress",e=>{let t=this.press;t&&(clearTimeout(t.timer),(!t.fired||e?.type==="pointercancel")&&(this.press=void 0))});u(this,"onContextMenu",e=>{let t=e.target.closest?.("[data-index]");t&&(e.preventDefault(),!(this.press?.fired||this.bar.panel)&&(this.select(Number(t.dataset.index),!1),this.bar.openPanel()))});this.inner=f("div",{class:"qb-list-inner"}),this.scroller=f("div",{class:`${e.cls("qb-scroll qb-list","list")}`,role:"listbox",id:`${e.instanceId}-list`,"aria-label":e.t("results"),tabindex:"-1"},this.inner),this.emptyEl=f("div",{class:"qb-empty",hidden:!0}),t.view.type==="list"&&t.view.detail?(this.detailEl=f("div",{class:e.cls("qb-detail qb-md","detail")}),this.el=f("div",{class:"qb-split",style:"display:flex;flex:1;min-width:0;position:relative"},this.scroller,this.detailEl,this.emptyEl)):this.el=f("div",{style:"display:flex;flex:1;min-width:0;position:relative"},this.scroller,this.emptyEl),this.scroller.addEventListener("pointermove",this.onPointerMove),this.scroller.addEventListener("click",this.onClick),this.scroller.addEventListener("pointerdown",this.onPointerDown),this.scroller.addEventListener("pointerup",this.cancelPress),this.scroller.addEventListener("pointercancel",this.cancelPress),this.scroller.addEventListener("contextmenu",this.onContextMenu),this.scroller.addEventListener("scroll",this.onScroll,{passive:!0})}measure(){let e=getComputedStyle(this.bar.dom.root);this.rowHeight=Jt(e.getPropertyValue("--qb-row-height"),42),this.sectionHeight=Jt(e.getPropertyValue("--qb-section-height"),30),this.bar.isTouch&&(this.rowHeight=Math.max(this.rowHeight,48))}refresh(){this.cache.clear(),this.inner.replaceChildren(),this.renderedKeys=[],this.selectedEl=void 0,this.update()}update(){let e=this.frame.rows,t=this.virtual;if(this.virtual=e.length>zi,this.virtual){t||this.measure();let i=0;this.offsets=e.map(n=>{let r=i;return i+=n.kind==="section"?this.sectionHeight:this.rowHeight,r}),this.inner.style.height=`${i}px`,this.renderWindow()}else{if(t){this.inner.style.height="";for(let{el:r}of this.cache.values())r.style.cssText=""}let i=e.map(r=>r.key),n=e.map(r=>this.rowEl(r));(!Ze(i,this.renderedKeys)||n.some((r,o)=>this.inner.children[o]!==r))&&(this.inner.replaceChildren(...n),this.renderedKeys=i),this.prune(new Set(i))}this.updateSelection(),this.updateEmpty(),this.updateDetail()}prune(e){if(!(this.cache.size<400))for(let t of this.cache.keys())e.has(t)||this.cache.delete(t)}renderWindow(){let e=this.frame.rows,t=this.scroller.scrollTop,i=this.scroller.clientHeight||400,n=Yt(this.offsets,t)-Gt;n=Math.max(0,n);let r=Yt(this.offsets,t+i)+Gt;r=Math.min(e.length,r+1);let o=[],a=[];for(let c=n;c<r;c++){let l=e[c],d=this.rowEl(l);d.style.position="absolute",d.style.top=`${this.offsets[c]}px`,d.style.left="0",d.style.right="0",o.push(d),a.push(l.key)}Ze(a,this.renderedKeys)||(this.inner.replaceChildren(...o),this.renderedKeys=a),this.updateSelection()}rowSig(e){if(e.kind==="section")return e.title;let t=`${e.index}|${e.positions?.join(",")??""}`;if(this.frame.view.type==="root"&&this.bar.personalize){let i=this.bar.idOf(e.item);t+=`|${this.bar.aliasOf(i)??""}|${this.bar.pins().includes(i)?"p":""}`}return t}rowEl(e){let t=this.rowSig(e),i=this.cache.get(e.key);if(i&&i.sig===t&&(e.kind==="section"||i.el.__item===e.item))return i.el;let n=e.kind==="section"?this.sectionEl(e.title):this.itemEl(e);return e.kind==="item"&&(n.__item=e.item),this.cache.set(e.key,{el:n,sig:t}),n}sectionEl(e){return f("div",{class:this.bar.cls("qb-section","section"),role:"presentation"},e)}itemEl(e){let{item:t}=e,i=this.frame.view.type==="root",n=[];if(i&&this.bar.personalize){let r=this.bar.idOf(t),o=this.bar.aliasOf(r);o&&n.push(f("span",{class:"qb-alias",title:this.bar.t("alias")},o)),this.bar.pins().includes(r)&&n.push(f("span",{class:"qb-pin",title:this.bar.t("pinned")},T("pin",13)))}return t.accessories?.length?n.push(f("span",{class:"qb-item-accessories"},...t.accessories.map(zt))):t.shortcut&&n.push(f("span",{class:"qb-item-accessories"},L(t.shortcut))),i&&!t.accessories?.length&&!t.shortcut&&n.push(f("span",{class:"qb-item-kind"},this.kindOf(t))),f("div",{class:this.bar.cls("qb-item","item"),role:"option",id:Xt(this.bar,e.key),"aria-selected":"false","data-index":String(e.index)},this.bar.isMulti(this.frame)?f("span",{class:"qb-check","aria-hidden":"true"},T("check",12)):null,f("span",{class:"qb-item-icon"},T(t.icon??(i?"command":void 0),16)),f("span",{class:"qb-item-text"},f("span",{class:"qb-item-title"},Ue(t.title,e.positions)),t.subtitle?f("span",{class:"qb-item-subtitle"},t.subtitle):null),...n)}kindOf(e){return this.bar.itemExt.get(e)?this.bar.t("kindCommand"):e.href?this.bar.t("kindPage"):e.url?this.bar.t("kindLink"):this.bar.t("kindCommand")}updateSelection(){let e=this.frame.itemRows[this.frame.selected],t=e?this.cache.get(e.key)?.el:void 0;if(this.selectedEl&&this.selectedEl!==t&&this.selectedEl.setAttribute("aria-selected","false"),t&&t.setAttribute("aria-selected","true"),this.selectedEl=t,this.bar.isMulti(this.frame))for(let i of this.frame.itemRows){let n=this.cache.get(i.key)?.el;if(!n)continue;let r=this.bar.isMarked(this.frame,i.key);r?n.dataset.marked="":delete n.dataset.marked,n.setAttribute("aria-checked",r?"true":"false")}}updateEmpty(){let e=this.frame,t=e.itemRows.length===0;if(this.scroller.hidden=t&&!this.detailEl,!t||e.loading>0&&!e.error){this.emptyEl.hidden=!0;return}let i=e.view,n="search",r=this.bar.t("noResults"),o=e.query?this.bar.t("nothingMatches",{query:e.query}):null;e.error?(n="alert",r=this.bar.t("loadFailed"),o=e.error):i.emptyView?(n=i.emptyView.icon??n,r=i.emptyView.title,o=i.emptyView.description??null):e.view.type==="root"&&!e.query&&(r=this.bar.t("startTyping"),o=null),this.emptyEl.replaceChildren(T(n,28)??"",f("div",{class:"qb-empty-title"},r),o?f("div",{class:"qb-empty-desc"},o):""),this.emptyEl.hidden=!1}updateDetail(){let e=this.detailEl;if(!e)return;let t=this.bar.selectedItem(this.frame);if(t===this.detailFor)return;if(this.detailFor=t,!t?.detail){e.innerHTML=t?.description?this.bar.md(t.description):"";return}let i=Xe.get(t);if(i===void 0){let n=t.detail;i=typeof n=="function"?Promise.resolve(n()):n,Xe.set(t,i)}typeof i=="string"?e.innerHTML=this.bar.md(i):(e.innerHTML="",i.then(n=>{Xe.set(t,n),this.detailFor===t&&(e.innerHTML=this.bar.md(n))},n=>{this.detailFor===t&&(e.textContent=String(n?.message??n))}))}select(e,t=!0){let i=this.frame.itemRows.length;i&&(this.frame.selected=(e%i+i)%i,this.frame.selectedKey=this.frame.itemRows[this.frame.selected].key,this.frame.userMoved=!0,t&&this.ensureVisible(),this.updateSelection(),this.bar.invalidate())}move(e){let t=this.frame.itemRows.length;if(!t)return;let i=this.frame.selected+e;this.select(Math.abs(e)===1?i:Math.max(0,Math.min(t-1,i)))}ensureVisible(){let e=this.frame,t=e.itemRows[e.selected];if(!t)return;let i=e.rows.indexOf(t),n=e.rows[i-1],r,o;if(this.virtual)r=this.offsets[i],o=r+this.rowHeight,n?.kind==="section"&&(r=this.offsets[i-1]);else{let l=this.cache.get(t.key)?.el;if(!l)return;if(r=l.offsetTop,o=r+l.offsetHeight,n?.kind==="section"){let d=this.cache.get(n.key)?.el;d&&(r=d.offsetTop)}}let a=8,c=this.scroller;e.selected===0?c.scrollTop=0:r<c.scrollTop+a?c.scrollTop=r-a:o>c.scrollTop+c.clientHeight-a&&(c.scrollTop=o-c.clientHeight+a),this.virtual&&this.renderWindow()}onKey(e){let t=e.key,i=e.metaKey||e.ctrlKey;if((t==="ArrowDown"||t==="ArrowUp")&&e.shiftKey&&!i&&this.bar.isMulti(this.frame)){let r=this.frame.itemRows[this.frame.selected]?.item;r&&this.bar.toggleMark(this.frame,r,!0),this.move(t==="ArrowDown"?1:-1);let o=this.frame.itemRows[this.frame.selected]?.item;return o&&this.bar.toggleMark(this.frame,o,!0),!0}if(t==="ArrowDown"&&i)return this.select(this.frame.itemRows.length-1),!0;if(t==="ArrowUp"&&i)return this.select(0),!0;let n=e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey;if(t==="ArrowDown"||n&&(t==="n"||t==="j"))return this.move(1),!0;if(t==="ArrowUp"||n&&t==="p")return this.move(-1),!0;if(t==="PageDown")return this.move(8),!0;if(t==="PageUp")return this.move(-8),!0;if(t==="Enter"&&!i&&!e.altKey)return this.bar.runPrimary(this.frame),!0;if(t==="Tab"&&!e.shiftKey&&!i&&!e.altKey){let r=this.bar.selectedItem(this.frame);if(r?.arguments?.length){let o=this.bar.actionsFor(r,this.frame)[0];return o&&this.bar.runAction(this.frame,r,o),!0}return this.frame.view.type==="root"&&this.bar.ai&&this.bar.ask(this.frame.query),!0}return!1}scrollTop(){return this.scroller.scrollTop}restoreScroll(e){this.scroller.scrollTop=e,this.virtual&&this.renderWindow()}resetScroll(){this.scroller.scrollTop=0}destroy(){cancelAnimationFrame(this.rafId),this.press&&clearTimeout(this.press.timer)}};qe=class extends re{constructor(e,t){super(e,t);let i=t.view;this.scroller.className=e.cls("qb-scroll qb-grid","grid"),this.scroller.style.setProperty("--qb-columns",String(i.columns??5)),i.aspectRatio&&this.scroller.style.setProperty("--qb-aspect",i.aspectRatio),i.fit&&this.scroller.style.setProperty("--qb-fit",i.fit),this.inner.style.display="contents"}update(){let e=this.frame.rows.slice(0,600),t=e.map(n=>n.key),i=e.map(n=>this.rowEl(n));Ze(t,this.renderedKeys)||(this.inner.replaceChildren(...i),this.renderedKeys=t),this.updateSelection(),this.updateEmpty()}itemEl(e){let{item:t}=e,i=f("div",{class:"qb-cell-media"});if(t.image)i.append(f("img",{src:t.image,alt:"",loading:"lazy",decoding:"async",draggable:"false"}));else{let n=T(t.icon,28);n&&i.append(n)}return f("div",{class:this.bar.cls("qb-cell","item"),role:"option",id:Xt(this.bar,e.key),"aria-selected":"false","data-index":String(e.index),title:t.title},this.bar.isMulti(this.frame)?f("span",{class:"qb-check","aria-hidden":"true"},T("check",12)):null,i,f("div",{class:"qb-cell-title"},Ue(t.title,e.positions)),t.subtitle?f("div",{class:"qb-cell-subtitle"},t.subtitle):null)}ensureVisible(){let e=this.frame.itemRows[this.frame.selected];(e&&this.cache.get(e.key)?.el)?.scrollIntoView({block:"nearest"})}onKey(e){let t=this.frame.view.columns??5;return e.key==="ArrowRight"&&!e.metaKey&&!e.ctrlKey?(this.move(1),!0):e.key==="ArrowLeft"&&!e.metaKey&&!e.ctrlKey?(this.move(-1),!0):e.key==="ArrowDown"&&!e.metaKey&&!e.ctrlKey?(this.step(t),!0):e.key==="ArrowUp"&&!e.metaKey&&!e.ctrlKey?(this.step(-t),!0):super.onKey(e)}step(e){let t=this.frame.itemRows.length,i=this.frame.selected+e;i>=0&&i<t&&this.select(i)}},Te=class{constructor(e,t){u(this,"bar",e);u(this,"frame",t);u(this,"el");u(this,"hasInput",!1);u(this,"body");u(this,"rendered","");u(this,"raf",0);let i=t.view;this.body=f("div",{class:e.cls("qb-detail qb-md","detail"),tabindex:"-1"});let n=[this.body];i.metadata?.length&&n.push(f("div",{class:"qb-meta"},...i.metadata.map(r=>f("div",null,f("div",{class:"qb-meta-label"},r.label),f("div",{class:"qb-meta-value"},T(r.icon,14),r.tag?We(r.tag):null,r.href?f("a",{href:r.href,target:/^https?:/.test(r.href)?"_blank":null,rel:"noopener"},r.value??r.href):r.value??null))))),this.el=f("div",{style:"display:flex;flex:1;min-width:0"},...n)}update(){this.raf||(this.raf=requestAnimationFrame(()=>{this.raf=0,this.render()}))}render(){let e=this.frame.detail;if(!e)return;let t=`${e.text.length}|${e.done}|${e.error??""}`;if(t===this.rendered)return;this.rendered=t;let i=this.body.scrollTop+this.body.clientHeight>=this.body.scrollHeight-24,n=this.bar.md(e.text);e.done||(n+='<span class="qb-caret"></span>'),e.error&&(n+=`<p class="qb-msg-error">${e.error.replace(/</g,"&lt;")}</p>`),this.body.innerHTML=n,i&&!e.done&&(this.body.scrollTop=this.body.scrollHeight)}onKey(e){return e.key==="ArrowDown"?(this.body.scrollTop+=40,!0):e.key==="ArrowUp"?(this.body.scrollTop-=40,!0):e.key==="Enter"&&!e.metaKey&&!e.ctrlKey?(this.bar.runPrimary(this.frame),!0):!1}viewActions(){let e=this.frame.detail;return[{title:this.bar.t("copyContent"),icon:"copy",shortcut:"mod+shift+c",keepOpen:!0,run:async t=>{let i=await t.copy(e?.text??"");return t.toast({title:i?this.bar.t("copied"):this.bar.t("copyFailed"),style:i?"success":"failure"}),!1}}]}focusTarget(){return this.body}scrollTop(){return this.body.scrollTop}restoreScroll(e){this.body.scrollTop=e}destroy(){cancelAnimationFrame(this.raf)}},Ee=class{constructor(e,t){u(this,"bar",e);u(this,"frame",t);u(this,"el");u(this,"hasInput",!1);u(this,"inputs",new Map);u(this,"errors",new Map);let i=t.view,n=[];for(let r of i.fields){let o=`${e.instanceId}-f-${r.name}`,a=f("label",{class:"qb-form-label",for:o,"data-required":r.required?"":null},r.type==="checkbox"?"":r.label??r.name),c=this.control(r,o),l=f("div",{class:"qb-field-error",hidden:!0,id:`${o}-err`});this.errors.set(r.name,l),n.push(a,f("div",{class:"qb-field"},c,r.description?f("div",{class:"qb-field-desc"},r.description):null,l))}this.el=f("form",{class:e.cls("qb-form","form"),novalidate:!0},...n),this.el.addEventListener("submit",r=>{r.preventDefault(),this.submit()})}control(e,t){let i=this.frame.form.values,n=o=>{i[e.name]=o,this.frame.form.errors[e.name]&&(delete this.frame.form.errors[e.name],this.showErrors())},r;if(e.type==="checkbox"){let o=f("input",{type:"checkbox",id:t,checked:!!i[e.name]});return o.addEventListener("change",()=>n(o.checked)),this.inputs.set(e.name,o),f("label",{class:"qb-field-check"},o,f("span",null,e.label??e.name))}if(e.type==="select"){let o=f("select",{class:"qb-field-input",id:t},...(e.options??[]).map(a=>f("option",{value:a.value},a.title)));o.value=String(i[e.name]??""),o.addEventListener("change",()=>n(o.value)),r=o}else if(e.type==="textarea"){let o=f("textarea",{class:"qb-field-input",id:t,placeholder:e.placeholder??"",rows:4});o.value=String(i[e.name]??""),o.addEventListener("input",()=>n(o.value)),r=o}else{let o=f("input",{class:"qb-field-input",id:t,type:e.type??"text",placeholder:e.placeholder??"",autocomplete:e.type==="password"?"off":"on",spellcheck:"false"});o.value=String(i[e.name]??""),o.addEventListener("input",()=>n(e.type==="number"?o.value===""?"":Number(o.value):o.value)),r=o}return r.setAttribute("aria-describedby",`${t}-err`),this.inputs.set(e.name,r),r}showErrors(){let e=this.frame.form.errors;for(let[t,i]of this.errors){let n=e[t];i.hidden=!n,i.textContent=n??"",this.inputs.get(t)?.setAttribute("aria-invalid",n?"true":"false")}}submit(){let e=this.frame.view,t=this.frame.form;t.errors={};for(let n of e.fields){let r=t.values[n.name];if(n.required&&(r===""||r==null||r===!1))t.errors[n.name]=this.bar.t("fieldRequired",{field:n.label??n.name});else{let o=n.validate?.(r,t.values);o&&(t.errors[n.name]=o)}}this.showErrors();let i=Object.keys(t.errors)[0];if(i){this.inputs.get(i)?.focus();return}this.bar.runAction(this.frame,void 0,{title:e.submitLabel??this.bar.t("submit"),run:n=>e.onSubmit({...t.values},n)})}update(){}onKey(e){if(e.key==="Enter"&&(e.metaKey||e.ctrlKey))return this.submit(),!0;let t=e.target;return e.key==="Enter"&&t.tagName==="INPUT"&&t.type!=="checkbox"?(this.submit(),!0):!1}footerPrimary(){return{title:this.frame.view.submitLabel??this.bar.t("submit"),hotkey:"mod+enter",run:()=>this.submit()}}focusTarget(){return this.el.contains(document.activeElement)?document.activeElement:this.el.querySelector("input,textarea,select")??this.el}scrollTop(){return this.el.scrollTop}restoreScroll(e){this.el.scrollTop=e}destroy(){}},Me=class{constructor(e,t){u(this,"bar",e);u(this,"frame",t);u(this,"el");u(this,"hasInput",!0);u(this,"turnEls",[]);u(this,"emptyEl");u(this,"raf",0);this.el=f("div",{class:e.cls("qb-chat","chat"),role:"log","aria-live":"polite",tabindex:"-1"})}update(){this.raf||(this.raf=requestAnimationFrame(()=>{this.raf=0,this.render()}))}render(){let e=this.frame.chat?.turns??[];if(!e.length){this.emptyEl||(this.emptyEl=this.empty(),this.el.replaceChildren(this.emptyEl));return}this.emptyEl&&(this.emptyEl.remove(),this.emptyEl=void 0);let t=this.el.scrollTop+this.el.clientHeight>=this.el.scrollHeight-40;e.forEach((i,n)=>{let r=`${i.text.length}|${i.streaming}|${i.error??""}|${i.tools.map(c=>c.state).join()}`,o=this.turnEls[n];if(o&&o.sig===r)return;let a;if(i.role==="user")a=f("div",{class:"qb-msg-user"},i.text);else{let c=f("div",{class:"qb-msg-head"},T("sparkles",13),this.bar.aiName),l=i.tools.length?f("div",{class:"qb-tools"},...i.tools.map(b=>{let v=T(b.state==="running"?"loader":b.state==="done"?"check":"x",12);return b.state==="running"&&v.classList.add("qb-spin"),f("span",{class:"qb-tool","data-state":b.state},v,b.label)})):null,d=f("div",{class:"qb-md"}),h=this.bar.md(i.text);i.streaming&&(h+=i.text||!i.tools.length?'<span class="qb-caret"></span>':""),d.innerHTML=h,a=f("div",{class:"qb-msg-ai"},c,l,d,i.error?f("div",{class:"qb-msg-error"},i.error):null)}o?o.el.replaceWith(a):this.el.append(a),this.turnEls[n]={el:a,sig:r}}),t&&(this.el.scrollTop=this.el.scrollHeight)}empty(){let e=this.bar.aiOptions?.suggestions??[],t=e.length?e:this.bar.t("chatSuggestions").split("|");return f("div",{class:"qb-chat-empty"},T("sparkles",26),f("div",{class:"qb-empty-title"},this.bar.t("askAnything")),f("div",{class:"qb-empty-desc"},this.bar.t("chatHint")),f("div",{class:"qb-suggestions"},...t.map(i=>{let n=f("button",{class:"qb-suggestion",type:"button"},i);return n.addEventListener("click",()=>this.bar.sendChat(this.frame,i)),n})))}lastAnswer(){let e=this.frame.chat?.turns??[];for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant"&&e[t].text)return e[t].text;return""}onKey(e){if(e.key==="Enter"&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey){let t=this.frame.query.trim();return t&&this.bar.sendChat(this.frame,t),!0}return e.key==="ArrowUp"&&!this.frame.query?(this.el.scrollTop-=60,!0):e.key==="ArrowDown"&&!this.frame.query?(this.el.scrollTop+=60,!0):!1}placeholder(){return this.frame.chat?.turns.length??0?this.bar.t("followUp"):this.bar.t("askAnythingPlaceholder")}footerPrimary(){return this.frame.chat?.controller?{title:this.bar.t("stop"),hotkey:"escape",run:()=>{this.bar.stopChat(this.frame)}}:{title:this.bar.t("send"),hotkey:"enter",run:()=>this.bar.sendChat(this.frame,this.frame.query)}}viewActions(){let e=this.frame.view;return[{title:this.bar.t("copyAnswer"),icon:"copy",shortcut:"mod+shift+c",keepOpen:!0,run:async t=>{let i=await K(this.lastAnswer());return t.toast({title:i?this.bar.t("copiedAnswer"):this.bar.t("nothingToCopy"),style:i?"success":"failure"}),!1}},{title:this.bar.t("newChat"),icon:"plus",shortcut:"mod+shift+o",run:t=>(t.render({...e,type:"chat",prompt:void 0}),!1)}]}scrollTop(){return this.el.scrollTop}restoreScroll(e){this.el.scrollTop=e}destroy(){cancelAnimationFrame(this.raf)}}});var ni={};de(ni,{Bar:()=>tt,embedText:()=>Ae,isView:()=>et,normalizeAlias:()=>se});function Ae(s){return[s.title,s.subtitle,s.section,s.keywords?.join(", "),s.description].filter(Boolean).join(" \xB7 ")}function ti(s){let e=0;for(let n of s)e+=n*n;let t=Math.sqrt(e)||1,i=new Float32Array(s.length);for(let n=0;n<s.length;n++)i[n]=s[n]/t;return i}function Ui(s,e){let t=0,i=Math.min(s.length,e.length);for(let n=0;n<i;n++)t+=s[n]*e[n];return t}function Wi(s,e){if(s===e)return!0;if(!s||!e)return!1;let t=Object.keys(s);return t.length!==Object.keys(e).length?!1:t.every(i=>s[i]===e[i])}async function ii(s,e){let t;try{return await Promise.race([Promise.resolve(s),new Promise((i,n)=>t=setTimeout(()=>n(new Error("timeout")),e))])}finally{clearTimeout(t)}}var Vi,et,Ki,ji,Di,Bi,tt,ei,se,ri=E(()=>{"use strict";Tt();pe();ze();Ot();F();je();J();Qe();be();Ge();Ye();we();Qt();Zt();Vi=new Set(["list","grid","detail","form","chat"]),et=s=>!!s&&typeof s=="object"&&Vi.has(s.type),Ki="nav a[href], header a[href], aside a[href], [data-qikbar-index] a[href]",ji="mod+.",Di=s=>s.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64),Bi=0,tt=class{constructor(e={}){u(this,"config");u(this,"instanceId",Vt("qikbar"));u(this,"storageAdapter");u(this,"storage");u(this,"frecency");u(this,"registrations",new Map);u(this,"regCounter",0);u(this,"sources",new Set);u(this,"sourceExt",new WeakMap);u(this,"itemExt",new WeakMap);u(this,"extensions",new Map);u(this,"configExtensions",[]);u(this,"configSources",[]);u(this,"ids",new WeakMap);u(this,"listeners",new Map);u(this,"stack",[]);u(this,"_open",!1);u(this,"rootCache",null);u(this,"routeItems",[]);u(this,"autoItems",[]);u(this,"shortcutItems",[]);u(this,"aiOptions");u(this,"ai");u(this,"dom");u(this,"renderer");u(this,"panel");u(this,"toastState");u(this,"toastTimer");u(this,"toastId",0);u(this,"hud");u(this,"confirmState");u(this,"argMode");u(this,"seq",new D);u(this,"prevFocus",null);u(this,"teardown",[]);u(this,"appliedVars",[]);u(this,"scheduled",!1);u(this,"scrollLock");u(this,"closeTimer");u(this,"destroyed",!1);u(this,"styleEl");u(this,"searchEventTimer");u(this,"webmcpCleanup");u(this,"labelCache");u(this,"vectors",new Map);u(this,"semanticWarned",!1);u(this,"onGlobalKeyDown",e=>{if(this.destroyed||e.defaultPrevented||e.isComposing)return;let t=this.config.hotkey===!1?[]:[].concat(this.config.hotkey??"mod+k"),i=H(e.target);if(t.some(d=>M(e,d)&&(!i||Q(d)))){e.preventDefault(),e.stopPropagation(),this.isInline?(this.open(),this.focusInput()):this.toggle();return}if(this._open&&!this.isInline||this.isInline&&this.dom?.root.contains(e.target))return;let n=this.toastState?.act;if(n?.shortcut&&!i&&M(e,n.shortcut)){e.preventDefault(),this.runToastAction();return}if(this.config.shortcuts===!1||(this.rootItems(),!this.shortcutItems.length))return;let r=this.shortcutItems.map(d=>d.shortcut).filter(d=>!i||Q(d)),o=this.seq.feed(e,r);if(!o.length)return;let a=this.shortcutItems.find(d=>d.shortcut===o[0]);if(!a)return;e.preventDefault();let c=this.createFrame({type:"root"}),l=this.actionsFor(a,c)[0];l&&this.runAction(c,a,l,void 0,"shortcut")});u(this,"onGlobalClick",e=>{let t=e.target?.closest?.("[data-qikbar-open]");if(!t||this.destroyed)return;let i=t.getAttribute("data-qikbar-open");(i?i!==this.instanceId&&i!==this.config.namespace:this.isInline)||(e.preventDefault(),this.open({query:t.getAttribute("data-qikbar-query")??void 0}))});u(this,"onDialogKeyDown",e=>{if(e.stopPropagation(),e.isComposing||e.keyCode===229)return;let t=this.top;if(!t)return;if(this.confirmState){if(e.key==="Escape")e.preventDefault(),this.confirmState.resolve(!1);else if(e.key==="Tab"){let r=[...this.dom?.layer.querySelectorAll("button")??[]],o=r.indexOf(document.activeElement);e.preventDefault(),r[(o+(e.shiftKey?-1:1)+r.length)%r.length]?.focus()}e.stopPropagation();return}let i=this.toastState?.act;if(i?.shortcut&&M(e,i.shortcut)&&!(H(e.target)&&e.target.value)){e.preventDefault(),this.runToastAction();return}if(this.panel){this.onPanelKey(e)&&(e.preventDefault(),e.stopPropagation());return}if(this.argMode){if(e.key==="Escape"){e.preventDefault(),e.stopPropagation(),this.argMode=void 0,this.flush(),this.focusInput();return}if(e.key==="Enter"){e.preventDefault(),this.submitArgs();return}return}if(e.key==="Escape"){e.preventDefault(),e.stopPropagation(),this.escape();return}if(M(e,this.actionsHotkey)){e.preventDefault(),this.openPanel();return}if(this.renderer?.onKey(e)){e.preventDefault();return}let n=this.actionsFor(this.selectedItem(t),t);if(e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.shiftKey&&!e.altKey&&t.view.type!=="form"){let r=n[1];if(r&&!r.shortcut){e.preventDefault(),this.runAction(t,this.selectedItem(t),r);return}}for(let r of n)if(r.shortcut&&M(e,r.shortcut)){e.preventDefault(),this.runAction(t,this.selectedItem(t),r);return}e.key==="Backspace"&&this.stack.length>1&&e.target===this.dom?.input&&!this.dom.input.value&&!e.repeat&&(e.preventDefault(),this.pop())});if(this.config={...e},this.storageAdapter=e.storage??_(),this.storage=G(this.storageAdapter,e.namespace??"qikbar"),this.frecency=new U(this.storage),this.applyConfig(e,!0),!(typeof document>"u")&&(this.listen(document,"keydown",this.onGlobalKeyDown,!0),this.listen(document,"click",this.onGlobalClick,!0),this.applyWebMCP(),this.inlineTarget())){let t=()=>this.open({focus:!1});document.readyState==="loading"?this.listen(document,"DOMContentLoaded",t):t()}}get isOpen(){return this._open}get query(){return this.top?.query??""}get top(){return this.stack[this.stack.length-1]}get isInline(){return!!this.config.inline}get isTouch(){let e=this.config.touch??"auto";return e!=="auto"?e:typeof matchMedia<"u"&&matchMedia("(hover: none) and (pointer: coarse)").matches}applyTouch(){let e=this.dom?.root;e&&(this.isTouch?e.dataset.qbTouch="":delete e.dataset.qbTouch)}watchViewport(){let e=typeof window<"u"?window.visualViewport:void 0;if(!e||this.isInline)return;let t=()=>{this._open&&this.dom&&this.dom.root.style.setProperty("--qb-vvh",`${Math.round(e.height)}px`)};e.addEventListener("resize",t),e.addEventListener("scroll",t),this.teardown.push(()=>{e.removeEventListener("resize",t),e.removeEventListener("scroll",t)}),t()}get aiName(){return this.aiOptions?.name??"AI"}get actionsHotkey(){return this.config.actionsHotkey??ji}get labels(){let e=this.config.labels;return(!this.labelCache||this.labelCache.src!==e)&&(this.labelCache={src:e,labels:e?{...me,...e}:me}),this.labelCache.labels}t(e,t={}){return Rt(this.labels[e],{ai:this.aiName,...t})}actionTitle(e){return e.labelKey&&e.title===me[e.labelKey]?this.t(e.labelKey):e.title}open(e={}){if(this.destroyed||typeof document>"u")return;if(this.mount(),clearTimeout(this.closeTimer),!this._open){this._open=!0,this.prevFocus=document.activeElement,this.rootCache=null,this.autoIndex(),this.resetToRoot(),this.applyTheme();let i=this.dom;i.root.dataset.qbState="open";let n=typeof window<"u"?window.visualViewport:void 0;n&&!this.isInline&&i.root.style.setProperty("--qb-vvh",`${Math.round(n.height)}px`),i.overlay.hidden=this.isInline,i.dialog.hidden=!1,this.isInline||this.lockScroll(),this.emit("open",void 0),this.config.onOpen?.(),this.track({type:"open"})}e.view&&this.push(e.view),e.query!=null&&this.setQuery(e.query),this.flush(),e.focus!==!1&&this.focusInput(),this.emitChange()}close(){if(!this._open||!this.dom)return;if(this.closePanel(),this.confirmState?.resolve(!1),this.confirmState=void 0,this.argMode=void 0,this.isInline){this.resetToRoot(),this.flush(),document.activeElement?.blur?.(),this.emitChange();return}this._open=!1;let e=this.dom;e.root.dataset.qbState="closing";let t=()=>{if(!this._open){e.root.dataset.qbState="closed",e.dialog.hidden=!0,e.overlay.hidden=!0,this.renderer?.destroy(),this.renderer=void 0,e.body.replaceChildren();for(let r of this.stack)this.destroyFrame(r);this.stack=[]}};typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches?t():this.closeTimer=setTimeout(t,120),this.unlockScroll();let n=this.prevFocus;n&&typeof n.focus=="function"&&document.contains(n)&&n.focus({preventScroll:!0}),this.toastState&&this.renderToast(),this.emit("close",void 0),this.config.onClose?.(),this.track({type:"close"}),this.emitChange()}toggle(){this._open&&!this.isInline?this.close():this.open()}register(e){let t=++this.regCounter;return this.registrations.set(t,Array.isArray(e)?e:[e]),this.invalidateRoot(),()=>{this.registrations.delete(t),this.invalidateRoot()}}addSource(e){return this.sources.add(e),()=>{this.sources.delete(e);for(let t of this.stack)t.sourceResults?.delete(e.id);this.invalidate()}}use(e,t={}){this.extensions.get(e.name)?.cleanup?.();let i=G(this.storageAdapter,`${this.config.namespace??"qikbar"}:ext:${e.name}`),n={ext:e,provided:t,storage:i,prefs:()=>{let d=i.get("preferences")??{},h={};for(let b of e.preferences??[])b.default!==void 0&&(h[b.name]=b.default);return{...h,...d,...t}},missing:()=>{let d=n.prefs();return(e.preferences??[]).filter(h=>h.required&&(d[h.name]===void 0||d[h.name]===""))}},r=(e.commands??[]).map(d=>{let{name:h,...b}=d,v={section:e.title,icon:e.icon,...b,id:`${e.name}.${h}`};return this.itemExt.set(v,n),v}),o=(e.sources??[]).map(d=>(this.sourceExt.set(d,n),this.addSource(d))),a;try{a=e.setup?.({bar:this,preferences:n.prefs(),storage:i})}catch(d){console.error(`[qikbar] extension "${e.name}" setup failed`,d)}let c=!1,l={rt:n,items:r,cleanup:()=>{c||(c=!0,o.forEach(d=>d()),typeof a=="function"&&a(),this.extensions.get(e.name)===l&&this.extensions.delete(e.name),this.invalidateRoot())}};return this.extensions.set(e.name,l),this.invalidateRoot(),l.cleanup}configure(e){let t=this.config;this.config={...this.config,...e},this.applyConfig(e,!1,t),("webmcp"in e||"tools"in e)&&this.applyWebMCP(),this.dom&&(("theme"in e||"appearance"in e)&&this.applyTheme(),"classNames"in e&&this.applyClassNames(),"dir"in e&&(this.dom.root.dir=this.config.dir??""),"touch"in e&&this.applyTouch(),"labels"in e&&this.renderer?.refresh?.()),this.invalidateRoot()}push(e,t){if(!this._open&&(this.open(),!this._open))return;let i=this.top;i&&this.renderer&&(i.scrollTop=this.renderer.scrollTop());let n=this.createFrame(e,t??i?.ext);this.stack.push(n),this.closePanel(),this.argMode=void 0,this.startFrame(n),this.flush(),this.focusInput(),this.emitChange()}pop(){if(this.stack.length<=1)return;let e=this.stack.pop();this.destroyFrame(e),this.closePanel(),this.argMode=void 0,this.flush(),this.focusInput(),this.emitChange()}setQuery(e){let t=this.top;t&&(this.dom&&(this.dom.input.value=e),this.onQueryChange(t,e))}ask(e){if(!this.ai){this.toast({style:"failure",title:this.t("aiNotConfigured"),message:"Pass `ai` to createQikbar()."});return}this.push({type:"chat",prompt:e?.trim()||void 0})}commands(){return this.rootItems()}get personalize(){return this.config.personalize!==!1}pins(){return this.storage.get("pins")??[]}pin(e,t=!this.pins().includes(e)){let i=this.pins().filter(r=>r!==e);t&&i.unshift(e),this.storage.set("pins",i);let n=this.rootItems().find(r=>this.idOf(r)===e);n&&this.track({type:t?"pin":"unpin",item:this.eventItem(n)}),this.invalidateRoot()}aliases(){return this.storage.get("aliases")??{}}aliasOf(e){for(let[t,i]of Object.entries(this.aliases()))if(i===e)return t}setAlias(e,t){let i={...this.aliases()};for(let[o,a]of Object.entries(i))a===e&&delete i[o];let n=t==null?"":se(t);n&&(i[n]=e),this.storage.set("aliases",i);let r=this.rootItems().find(o=>this.idOf(o)===e);r&&this.track({type:"alias",item:this.eventItem(r),alias:n||null}),this.invalidateRoot()}personalizable(e,t){return!this.personalize||t.view.type!=="root"||ei(e)?!1:!this.idOf(e).startsWith("qikbar.")&&this.rootItems().includes(e)}aliasForm(e){let t=this.idOf(e),i=this.aliasOf(t);return{type:"form",title:e.title,submitLabel:this.t("save"),fields:[{name:"alias",label:this.t("alias"),placeholder:this.t("aliasPlaceholder"),description:this.t("aliasDescription",{title:e.title}),required:!0,defaultValue:i??"",validate:n=>{let r=se(String(n??"")),o=this.aliases()[r];if(o&&o!==t){let a=this.rootItems().find(c=>this.idOf(c)===o);return this.t("aliasTaken",{alias:r,title:a?.title??o})}}}],onSubmit:n=>{let r=se(String(n.alias??""));return this.setAlias(t,r),this.toast({style:"success",title:this.t("aliasSaved",{alias:r})}),this.pop(),!1}}}on(e,t){let i=this.listeners.get(e);return i||this.listeners.set(e,i=new Set),i.add(t),()=>i.delete(t)}preload(){return Promise.resolve()}destroy(){this.destroyed=!0,this._open&&!this.isInline&&this.unlockScroll(),this._open=!1;for(let e of this.stack)this.destroyFrame(e);this.stack=[];for(let e of this.extensions.values())e.cleanup?.();for(let e of this.teardown)e();this.teardown=[],this.webmcpCleanup?.(),this.webmcpCleanup=void 0,clearTimeout(this.searchEventTimer),clearTimeout(this.toastTimer),this.dom?.root.remove(),this.hud?.remove(),this.dom=void 0,this.listeners.clear()}applyConfig(e,t,i){if(("routes"in e||"labels"in e||t)&&(this.routeItems=(this.config.routes??[]).map(n=>({id:`route:${n.path}`,title:n.title,subtitle:n.subtitle,icon:n.icon??"arrow-right",keywords:[...n.keywords??[],n.path],section:n.section??this.t("navigation"),href:n.path,shortcut:n.shortcut}))),("sources"in e||t)&&(t||i?.sources!==this.config.sources)){for(let n of this.configSources)n();this.configSources=(this.config.sources??[]).map(n=>this.addSource(n))}if("ai"in e||t){let n=this.config.ai;this.aiOptions=n?"stream"in n?{provider:n}:n:void 0,this.ai=this.aiOptions?kt(this.aiOptions.provider,this.aiOptions.system):void 0}if("extensions"in e||t){let n=(this.config.extensions??[]).map(a=>Array.isArray(a)?{ext:a[0],prefs:a[1]}:{ext:a,prefs:void 0}),r=!t&&i?.extensions===this.config.extensions,o=n.length===this.configExtensions.length&&n.every((a,c)=>a.ext===this.configExtensions[c].ext&&Wi(a.prefs,this.configExtensions[c].prefs));if(!r&&!o){for(let a of this.configExtensions)a.uninstall();this.configExtensions=n.map(a=>({...a,uninstall:this.use(a.ext,a.prefs)}))}}}applyWebMCP(){this.webmcpCleanup?.(),this.webmcpCleanup=void 0;let e=this.config.webmcp;!e||this.destroyed||(this.webmcpCleanup=Wt(this,e===!0?{}:e))}inlineTarget(){let e=this.config.inline;return!e||typeof document>"u"?null:typeof e=="string"?document.querySelector(e):e}emit(e,t){this.listeners.get(e)?.forEach(i=>{try{i(t)}catch(n){console.error(n)}})}emitChange(){let e={open:this._open,query:this.query,depth:this.stack.length,loading:!!this.top?.loading};this.emit("change",e)}track(e){try{this.config.onEvent?.(e)}catch(t){console.error(t)}this.emit("event",e)}eventItem(e){return{id:this.idOf(e),title:e.title,section:e.section}}scheduleSearchEvent(e){clearTimeout(this.searchEventTimer);let t=e.query.trim();if(!t||!this.config.onEvent&&!this.listeners.get("event")?.size)return;let i=0,n=()=>{if(e!==this.top||e.query.trim()!==t)return;if(e.loading>0&&i++<10){this.searchEventTimer=setTimeout(n,300);return}let r=e.itemRows.filter(a=>!ei(a.item)).length,o=e.view.type;this.track({type:"search",query:t,results:r,view:o}),r||this.track({type:"no_results",query:t,view:o})};this.searchEventTimer=setTimeout(n,800)}listen(e,t,i,n=!1){e.addEventListener(t,i,n),this.teardown.push(()=>e.removeEventListener(t,i,n))}idOf(e){return e.id??this.ids.get(e)??e.title}invalidateRoot(){if(this.rootCache=null,this._open){for(let e of this.stack)e.actionCache=void 0,e.view.type==="root"&&this.computeRows(e);this.renderer?.refresh?.(),this.invalidate()}}rootItems(){if(this.rootCache)return this.rootCache;let e=[],t=new Set,i=(n,r)=>{try{if(n.when&&!n.when())return}catch{return}let o=n.id??`${r}:${n.section??""}:${n.title}`;for(;t.has(o);)o+="'";t.add(o),this.ids.set(n,o),e.push(n)};for(let n of this.config.commands??[])i(n,"cmd");for(let n of this.routeItems)i(n,"route");for(let n of this.registrations.values())for(let r of n)i(r,"reg");for(let n of this.extensions.values())for(let r of n.items)i(r,"ext");for(let n of this.autoItems)i(n,"auto");return this.ai&&this.aiOptions?.fallback!==!1&&i({id:"qikbar.ask-ai",title:this.t("askAi"),subtitle:this.t("askAiSubtitle"),icon:"sparkles",section:"AI",keywords:["chat","assistant","ai","help"],searchOnly:!0,view:{type:"chat"}},"qb"),this.rootCache=e,this.shortcutItems=e.filter(n=>n.shortcut),e}autoIndex(){let e=this.config.autoIndex;if(!e||typeof document>"u"){this.autoItems.length&&(this.autoItems=[],this.rootCache=null);return}let t=e===!0?{}:e,i=[],n=new Set;if(t.links!==!1)for(let r of document.querySelectorAll(t.links??Ki)){if(r.closest(".qb-root")||r.closest("[data-qikbar-ignore]"))continue;let o=r.getAttribute("href")??"";if(!o||o.startsWith("#")&&!o.startsWith("#/")||/^(javascript|mailto|tel):/i.test(o))continue;let a=(r.getAttribute("aria-label")||r.textContent||r.title||"").replace(/\s+/g," ").trim().slice(0,80);if(!a)continue;let c=r.host!==location.host,l=c?r.href:o.startsWith("#")?o:r.pathname+r.search+r.hash;if(n.has(l))continue;n.add(l);let d=r.closest("[data-qikbar-section],nav[aria-label],aside[aria-label]");i.push({id:`auto:${l}`,title:a,subtitle:c?r.host:o.startsWith("#")?o:r.pathname,section:d?.dataset.qikbarSection??d?.getAttribute("aria-label")??t.section??this.t("pages"),icon:c?"globe":"file",keywords:[l],...c?{url:l}:{href:l}})}if(t.elements!==!1)for(let r of document.querySelectorAll("[data-qikbar]")){if(r.closest(".qb-root"))continue;let o=(r.dataset.qikbar||r.getAttribute("aria-label")||r.textContent||"").replace(/\s+/g," ").trim().slice(0,80);o&&i.push({id:`el:${r.id||o}`,title:o,subtitle:r.dataset.qikbarSubtitle,keywords:r.dataset.qikbarKeywords?.split(",").map(a=>a.trim()),section:r.dataset.qikbarSection??this.t("actions"),icon:r.dataset.qikbarIcon??"zap",shortcut:r.dataset.qikbarShortcut,run:()=>{r.click()}})}this.autoItems=i,this.rootCache=null}createFrame(e,t,i){return{id:++Bi,view:e,query:("query"in e&&typeof e.query=="string"?e.query:"")||"",selected:0,rows:[],itemRows:[],loading:0,controller:new AbortController,ext:t,args:i}}resetToRoot(){for(let t of this.stack)this.destroyFrame(t);let e=this.createFrame({type:"root"});e.sourceResults=new Map,this.stack=[e],this.renderer?.destroy(),this.renderer=void 0,this.dom&&(this.dom.input.value=""),this.computeRows(e)}destroyFrame(e){e.controller.abort(),e.queryController?.abort(),e.chat?.controller?.abort();try{e.view.onClose?.()}catch(t){console.error(t)}}startFrame(e){let t=e.view;if(t.type==="list"||t.type==="grid")typeof t.items=="function"&&this.loadItems(e,!0),this.computeRows(e);else if(t.type==="detail")this.loadDetail(e,t);else if(t.type==="form"){let i={};for(let n of t.fields)i[n.name]=n.defaultValue??(n.type==="checkbox"?!1:n.type==="select"?n.options?.[0]?.value??"":"");e.form={values:i,errors:{}}}else t.type==="chat"&&(e.chat={messages:[],turns:[]},t.prompt&&queueMicrotask(()=>this.sendChat(e,t.prompt)))}replaceFrame(e,t){let i=this.stack.indexOf(e);if(i<0)return;let n=this.createFrame(t,e.ext,e.args);t.type===e.view.type&&!("query"in t&&t.query!=null)&&(n.query=e.query),e===this.top&&this.renderer&&(n.scrollTop=this.renderer.scrollTop()),n.selectedKey=e.itemRows[e.selected]?.key,n.userMoved=!!n.selectedKey,this.destroyFrame(e),this.stack[i]=n,this.startFrame(n),this.invalidate()}computeRows(e){let t=e.view,i;t.type==="root"?i=this.rootGroups(e):t.type==="list"||t.type==="grid"?i=this.listGroups(e,t):i=[];let n=[],r=[],o=new Set;for(let a of i)if(a.entries.length){a.title&&n.push({kind:"section",key:`s:${a.title}`,title:a.title});for(let c of a.entries){let l=t.type==="root"?this.idOf(c.item):c.item.id??`${a.title}:${c.item.title}`;for(;o.has(l);)l+="'";o.add(l);let d={kind:"item",key:l,item:c.item,positions:c.positions,index:r.length};n.push(d),r.push(d)}}if(e.rows=n,e.itemRows=r,e.userMoved||(e.selectedKey=void 0,e.selected=0),e.selectedKey){let a=r.findIndex(c=>c.key===e.selectedKey);e.selected=a>=0?a:Math.min(e.selected,Math.max(0,r.length-1))}else e.selected=Math.min(e.selected,Math.max(0,r.length-1));e.selectedKey=r[e.selected]?.key}rootGroups(e){let t=e.query.trim(),i=this.rootItems(),n=[],r=new Map,o=p=>{let g=r.get(p);return g||(g={title:p,entries:[]},r.set(p,g),n.push(g)),g},a=()=>new Map(i.map(p=>[this.idOf(p),p]));if(!t){let p=new Set;if(this.personalize){let y=a();for(let x of this.pins()){let w=y.get(x);!w||p.has(w)||(o(this.t("pinned")).entries.push({item:w}),p.add(w))}}let g=this.config.recents===!1?0:typeof this.config.recents=="number"?this.config.recents:4;if(g){let y=a(),x=0;for(let w of this.frecency.top(g*2+p.size)){let k=y.get(w);if(!(!k||k.searchOnly||p.has(k))&&(o(this.t("recent")).entries.push({item:k}),p.add(k),++x>=g))break}}for(let y of i)y.searchOnly||p.has(y)||o(y.section??this.t("commands")).entries.push({item:y});return n}let c=p=>{for(let g of this.sources){if((g.position??"bottom")!==p)continue;let y=e.sourceResults?.get(g.id);if(!y?.length)continue;let x=o(g.title??this.t("results")),w=g.filter?O(y,t):y.map(k=>({item:k,positions:te(k,t)?.positions}));for(let k of w.slice(0,g.limit??8))x.entries.push({item:k.item,positions:k.positions})}},l=this.personalize?this.aliases()[se(t)]:void 0,d=l?a().get(l):void 0;d&&o(d.section??this.t("commands")).entries.push({item:d}),c("top");let h=this.personalize?new Set(this.pins()):void 0,b=O(i,t,{boost:p=>{let g=this.idOf(p);return this.frecency.score(g)*.3+(h?.has(g)?.15:0)},limit:300});for(let p of b)p.item!==d&&o(p.item.section??this.t("commands")).entries.push({item:p.item,positions:p.positions});let v=this.relatedResults(e,b.map(p=>p.item));if(v.length){let p=o(this.t("related"));for(let g of v)g!==d&&p.entries.push({item:g})}c("bottom");let m=(this.config.fallbacks??[]).map((p,g)=>({...p,id:`fallback:${g}`,title:p.title.replaceAll("{query}",t),subtitle:p.subtitle?.replaceAll("{query}",t)}));if(this.ai&&this.aiOptions?.fallback!==!1&&m.unshift({id:"qikbar.ask-ai-fallback",title:this.t("askAi"),subtitle:`\u201C${t.length>60?`${t.slice(0,60)}\u2026`:t}\u201D`,icon:"sparkles",accessories:[{kbd:"tab"}],noHistory:!0,run:()=>({type:"chat",prompt:t})}),m.length){let p=o(this.t("useQueryWith",{query:t.length>24?`${t.slice(0,24)}\u2026`:t}));for(let g of m)p.entries.push({item:g})}return n}listGroups(e,t){let i=typeof t.items=="function"?e.items??[]:t.items,n=e.query.trim(),o=(t.filter??typeof t.items!="function")&&n?O(i,n).map(l=>({item:l.item,positions:l.positions})):i.map(l=>({item:l})),a=[],c=new Map;for(let l of o){let d=l.item.section??"",h=c.get(d);h||(h={title:d,entries:[]},c.set(d,h),a.push(h)),h.entries.push(l)}return a}onQueryChange(e,t){if(e.query===t)return;e.query=t;let i=e.view;(i.type==="root"||i.type==="list"||i.type==="grid")&&(e.selected=0,e.selectedKey=void 0,e.userMoved=!1,i.type==="root"?(this.searchSources(e),this.searchSemantic(e)):typeof i.items=="function"&&this.loadItems(e,!1),this.computeRows(e),this.renderer?.resetScroll?.(),this.scheduleSearchEvent(e)),this.invalidate(),this.emitChange()}searchSources(e){e.queryController?.abort();let t=new AbortController;e.queryController=t;let i=e.query.trim(),n=e.sourceResults??(e.sourceResults=new Map);for(let r of this.sources){let o=n.get(r.id);if(i.length<(r.minQueryLength??1)){n.delete(r.id);continue}o&&n.set(r.id,o.filter(d=>te(d,i)));let a=async()=>{if(!t.signal.aborted){e.loading++,this.invalidate();try{let d=this.sourceExt.get(r),h=await r.search({query:i,signal:t.signal,ctx:this.makeContext(e,{ext:d,signal:t.signal})});if(t.signal.aborted)return;if(d)for(let b of h)this.itemExt.set(b,d);n.set(r.id,h)}catch(d){t.signal.aborted||console.error(`[qikbar] source "${r.id}" failed`,d)}finally{e.loading--,!t.signal.aborted&&this.stack.includes(e)&&this.computeRows(e),this.invalidate()}}},c=r.debounce??150,l=setTimeout(a,c);t.signal.addEventListener("abort",()=>clearTimeout(l))}}searchSemantic(e){let t=this.config.semantic;if(e.related=void 0,!t)return;let i=e.query.trim();if(i.length<(t.minQueryLength??3))return;let r=(e.queryController??new AbortController).signal,a=setTimeout(async()=>{if(!r.aborted){e.loading++,this.invalidate();try{let c=this.rootItems().filter(p=>!this.idOf(p).startsWith("qikbar."));if(t.sources)for(let p of e.sourceResults?.values()??[])c.push(...p);let l=p=>this.rootItems().includes(p)?this.idOf(p):`src:${p.id??p.title}`,d=c.filter(p=>this.vectors.get(l(p))?.text!==Ae(p));for(let p=0;p<d.length;p+=128){let g=d.slice(p,p+128),y=await t.embed(g.map(Ae),{signal:r});if(r.aborted)return;g.forEach((x,w)=>{let k=y[w];k&&this.vectors.set(l(x),{text:Ae(x),vec:ti(k)})})}let[h]=await t.embed([i],{signal:r});if(r.aborted||!h)return;let b=ti(h),v=t.threshold??.35,m=[];for(let p of c){let g=this.vectors.get(l(p));if(!g)continue;let y=Ui(b,g.vec);y>=v&&m.push({item:p,score:y})}m.sort((p,g)=>g.score-p.score),e.related=m.slice(0,(t.limit??5)*3),this.stack.includes(e)&&this.computeRows(e)}catch(c){!r.aborted&&!this.semanticWarned&&(this.semanticWarned=!0,console.warn("[qikbar] semantic search failed",c))}finally{e.loading--,this.invalidate()}}},t.debounce??250);r.addEventListener("abort",()=>clearTimeout(a))}relatedResults(e,t){if(!e.related?.length)return[];let i=new Set(t);return e.related.filter(n=>!i.has(n.item)&&!n.item.searchOnly).slice(0,this.config.semantic?.limit??5).map(n=>n.item)}loadItems(e,t){let i=e.view;if(typeof i.items!="function")return;let n=i.items;e.queryController?.abort();let r=new AbortController;e.queryController=r,e.controller.signal.addEventListener("abort",()=>r.abort());let o=async()=>{if(!r.signal.aborted){e.loading++,e.error=void 0,this.invalidate();try{let a=n({query:e.query,signal:r.signal,ctx:this.makeContext(e,{signal:r.signal})});if(a&&typeof a[Symbol.asyncIterator]=="function")for await(let c of a){if(r.signal.aborted)return;this.setItems(e,c)}else{let c=await a;r.signal.aborted||this.setItems(e,c)}}catch(a){r.signal.aborted||(e.error=a instanceof Error?a.message:String(a),e.items=[],this.computeRows(e))}finally{e.loading--,this.invalidate()}}};if(t)o();else{let a=setTimeout(o,i.debounce??120);r.signal.addEventListener("abort",()=>clearTimeout(a))}}setItems(e,t){if(e.items=t,e.ext)for(let i of t)this.itemExt.set(i,e.ext);this.computeRows(e),this.invalidate()}async loadDetail(e,t){e.detail={text:"",done:!1},e.loading++;try{let i=t.markdown;if(typeof i=="function"&&(i=await i()),typeof i=="string")e.detail.text=i;else for await(let n of i){if(e.controller.signal.aborted)return;e.detail.text+=n,this.invalidate()}}catch(i){e.controller.signal.aborted||(e.detail.error=i instanceof Error?i.message:String(i))}finally{e.detail.done=!0,e.loading--,this.invalidate()}}makeContext(e,t={}){let i=t.ext??e.ext;return{bar:this,get query(){return e.query},signal:t.signal??e.controller.signal,preferences:i?i.prefs():{},arguments:t.args??e.args??{},storage:i?.storage??this.storage,ai:this.ai,push:r=>this.push(r,i),pop:()=>this.pop(),render:r=>{this.stack.includes(e)?this.replaceFrame(e,r):this.push(r,i)},close:()=>this.close(),navigate:(r,o)=>this.navigate(r,o?.newTab??!1),openUrl:r=>{this.close(),window.open(r,"_blank","noopener,noreferrer")},copy:r=>K(r),toast:r=>this.toast(r),confirm:r=>this.confirm(r),setQuery:r=>{e===this.top?this.setQuery(r):e.query=r},get selection(){return e.marked?[...e.marked.values()]:[]},labels:this.labels}}navigate(e,t=!1){this.isInline||this.close();let i=this.config.navigate;if(i)return i(e,{newTab:t});ie(e,t)}actionsFor(e,t){if(t.marked?.size)return this.bulkActions(t);let i=this.renderer?.frame===t?this.renderer.viewActions?.()??[]:[],n=[...t.view.actions??[],...i];if(!e)return n;t.actionCache??(t.actionCache=new WeakMap);let r=t.actionCache.get(e);if(r)return r;let o=[];if(e.run&&o.push({title:t.view.type==="root"?this.t("runCommand"):this.t("run"),icon:"corner-down-left",run:e.run}),e.view){let c=e.view;o.push({title:this.t("open"),icon:"chevron-right",run:l=>typeof c=="function"?c(l):c})}if(e.href){let c=e.href;o.push(A.navigate(c)),o.push(A.navigateNewTab(c)),o.push(A.copy(()=>new URL(c,location.href).href,{title:this.t("copyLink"),icon:"link",shortcut:"mod+shift+c"}))}e.url&&(o.push(A.open(e.url)),o.push(A.copy(e.url,{title:this.t("copyUrl"),icon:"link",shortcut:"mod+shift+c"}))),e.actions&&o.push(...e.actions),o.push(...n);let a=this.itemExt.get(e);if(t.view.type==="root"&&a?.ext.preferences?.length&&o.push({title:this.t("configure",{name:a.ext.title}),icon:"settings",section:this.t("extension"),run:()=>this.preferencesForm(a)}),this.isMulti(t)&&o.push({title:this.t("select"),icon:"check-square",shortcut:"mod+shift+x",keepOpen:!0,run:()=>(this.toggleMark(t,e),!1)}),this.personalizable(e,t)){let c=this.idOf(e),l=this.pins().includes(c),d=this.aliasOf(c);o.push({title:l?this.t("unpin"):this.t("pin"),icon:"pin",section:this.t("customize"),shortcut:"mod+shift+p",keepOpen:!0,run:()=>(this.pin(c,!l),!1)}),o.push({title:d?this.t("editAlias"):this.t("setAlias"),icon:"at-sign",section:this.t("customize"),run:()=>this.aliasForm(e)}),d&&o.push({title:this.t("removeAlias"),icon:"x",section:this.t("customize"),keepOpen:!0,run:()=>(this.setAlias(c,null),this.toast({title:this.t("aliasRemoved")}),!1)})}return t.view.type==="root"&&this.frecency.score(this.idOf(e))>0&&o.push({title:this.t("clearHistory"),icon:"history",section:this.t("history"),keepOpen:!0,run:()=>(this.frecency.clear(),this.computeRows(t),this.invalidate(),!1)}),t.actionCache.set(e,o),o}selectedItem(e=this.top){if(e)return e.itemRows[e.selected]?.item}async runAction(e,t,i,n,r="keyboard"){let o=i.runMany&&e.marked?.size?[...e.marked.values()]:void 0;if(o&&(t=void 0),t?.arguments?.length&&!n){this.enterArgMode(e,t,i);return}let a=(t&&this.itemExt.get(t))??e.ext;if(t&&a&&a.missing().length){this.push(this.preferencesForm(a,()=>this.runAction(e,t,i,n)),a);return}t&&e.view.type==="root"&&!t.noHistory&&this.frecency.record(this.idOf(t)),t?(this.config.onRun?.(t,i),this.emit("run",{item:t,action:i}),this.track({type:"run",item:this.eventItem(t),action:this.actionTitle(i),via:r})):o&&this.track({type:"run",item:this.eventItem(o[0]),action:this.actionTitle(i),via:r,count:o.length});let c=!1,l=this.makeContext(e,{ext:a,args:n}),d=Object.create(l,{push:{value:h=>(c=!0,l.push(h))},render:{value:h=>(c=!0,l.render(h))},pop:{value:()=>(c=!0,l.pop())},close:{value:()=>(c=!0,l.close())},navigate:{value:(h,b)=>(c=!0,l.navigate(h,b))},openUrl:{value:h=>(c=!0,l.openUrl(h))}});e.loading++,this.invalidate();try{let h=o?await i.runMany(o,d):await i.run(d);o&&this.stack.includes(e)&&this.clearMarks(e),et(h)?this.push(h,a):h===!1||i.keepOpen||c||this.close()}catch(h){console.error(h);let b=h instanceof Error?h.message:String(h);this.track({type:"error",message:b}),this.toast({style:"failure",title:this.t("somethingWentWrong"),message:b})}finally{e.loading--,this.invalidate()}}runPrimary(e=this.top,t=0,i="keyboard"){if(!e)return;let n=this.selectedItem(e),r=this.actionsFor(n,e)[t];r&&this.runAction(e,n,r,void 0,i)}isMulti(e){let t=e.view;return(t.type==="list"||t.type==="grid")&&!!t.multiSelect}rowKeyOf(e,t){return e.itemRows.find(i=>i.item===t)?.key}isMarked(e,t){return!!e.marked?.has(t)}toggleMark(e,t,i){if(!this.isMulti(e))return;let n=this.rowKeyOf(e,t);if(!n)return;e.marked??(e.marked=new Map),i??!e.marked.has(n)?e.marked.set(n,t):e.marked.delete(n),e.anchor=n,this.marksChanged(e)}markRange(e,t){if(!this.isMulti(e))return;let i=e.itemRows,n=i.findIndex(c=>c.item===t),r=e.anchor?i.findIndex(c=>c.key===e.anchor):-1;if(n<0)return;e.marked??(e.marked=new Map);let[o,a]=r<0?[n,n]:r<n?[r,n]:[n,r];for(let c=o;c<=a;c++)e.marked.set(i[c].key,i[c].item);e.anchor=i[n].key,this.marksChanged(e)}markAll(e){e.marked??(e.marked=new Map);for(let t of e.itemRows)e.marked.set(t.key,t.item);this.marksChanged(e)}clearMarks(e){e.marked?.size&&(e.marked.clear(),e.anchor=void 0,this.marksChanged(e))}marksChanged(e){e.actionCache=void 0,this.panel&&e===this.top&&this.closePanel(),this.renderer?.refresh?.(),this.invalidate();let t=e.marked?.size??0;t&&this.announce(this.t("selected",{count:t}))}bulkActions(e){let i=[...e.marked.values()][0],n=e.marked;e.marked=void 0;let r;try{r=this.actionsFor(i,e)}finally{e.marked=n}let o=r.filter(c=>c.runMany),a=[];return e.marked.size<e.itemRows.length&&a.push({title:this.t("selectAll"),icon:"check-square",shortcut:"mod+shift+a",keepOpen:!0,run:()=>(this.markAll(e),!1)}),a.push({title:this.t("clearSelection"),icon:"x",keepOpen:!0,run:()=>(this.clearMarks(e),!1)}),[...o,...a]}preferencesForm(e,t){let i=e.prefs();return{type:"form",title:this.t("configure",{name:e.ext.title}),submitLabel:t?this.t("saveAndContinue"):this.t("save"),fields:(e.ext.preferences??[]).map(n=>({name:n.name,label:n.title,description:n.description,type:n.type==="text"?"text":n.type,required:n.required,placeholder:n.placeholder,options:n.options,defaultValue:i[n.name]??n.default})),onSubmit:n=>{let r=e.storage.get("preferences")??{};return e.storage.set("preferences",{...r,...n}),this.toast({style:"success",title:this.t("preferencesSaved")}),this.pop(),t?.(),!1}}}enterArgMode(e,t,i){this.argMode={item:t,action:i,frame:e,values:{}},this.closePanel(),this.flush(),this.dom?.args.querySelector("input,select")?.focus()}submitArgs(){let e=this.argMode;if(!e||!this.dom)return;let t=(e.item.arguments??[]).find(i=>i.required&&!e.values[i.name]?.trim());if(t){this.dom.args.querySelector(`[name="${CSS.escape(t.name)}"]`)?.focus();return}this.argMode=void 0,this.runAction(e.frame,e.item,e.action,e.values),this.flush()}sendChat(e,t){let i=e.chat;if(!i||!this.aiOptions||!t.trim()||i.controller&&!i.controller.signal.aborted)return;let n=new AbortController;e.controller.signal.addEventListener("abort",()=>n.abort()),i.controller=n,i.messages.push({role:"user",content:t}),i.turns.push({role:"user",text:t,tools:[]});let r={role:"assistant",text:"",tools:[],streaming:!0};i.turns.push(r),e===this.top&&this.dom&&(this.dom.input.value="",e.query=""),e.loading++,this.invalidate();let o=e.view,a=o.tools!==!1&&this.aiOptions.tools!==!1;this.track({type:"ask_ai",prompt:t}),(async()=>{try{let l=a?await this.agentTools(e,n.signal):[];if(n.signal.aborted)return;for await(let d of qt({provider:this.aiOptions.provider,messages:i.messages,system:o.system??this.systemPrompt(a),tools:l,maxSteps:this.aiOptions.maxSteps??6,signal:n.signal})){if(d.type==="text")r.text+=d.text;else if(d.type==="message")i.messages.push(d.message);else if(d.type==="tool_start")r.text&&!/\n\s*$/.test(r.text)&&(r.text+=`
234
275
 
235
- `),n.tools.push({label:l.label,state:"running"});else if(l.type==="tool_end"){let h=n.tools.find(d=>d.state==="running");h&&(h.state=l.ok?"done":"error")}else l.type==="error"&&(n.error=l.error);this.invalidate()}}catch(l){r.signal.aborted||(n.error=l instanceof Error?l.message:String(l))}finally{n.streaming=!1;for(let l of n.tools)l.state==="running"&&(l.state="error");e.loading--,i.controller=void 0,this.invalidate()}})()}stopChat(e){let t=e.chat?.controller;return t&&!t.signal.aborted?(t.abort(),!0):!1}systemPrompt(e){let t=[`You are ${this.aiName}, the assistant built into this web app's command bar.`,"Answer concisely in Markdown. Prefer short paragraphs and lists."];if(typeof document<"u"&&t.push(`The user is on the page "${document.title}" (${location.pathname}).`),e){let i=this.rootItems().filter(r=>!r.id?.startsWith("qikbar."));t.push("","You can act inside the app:","- Call `run` with an item id to open a page or run a command when the user asks you to go somewhere or do something.","- Call `search` to find commands, pages and records that are not listed below.","Only call tools when the user wants something done or found in the app; otherwise just answer. After acting, confirm briefly what you did.","","Available items (id | title | section):",...i.slice(0,80).map(r=>`${this.idOf(r)} | ${r.title}${r.subtitle?` \u2014 ${r.subtitle}`:""} | ${r.section??"Commands"}`)),i.length>80&&t.push(`\u2026and ${i.length-80} more (use search).`)}return this.aiOptions?.system&&t.push("",this.aiOptions.system),t.join(`
236
- `)}agentTools(e){let t=new Map,i=o=>t.get(o)??this.rootItems().find(a=>this.idOf(a)===o),r=[{definition:{name:"search",description:"Search the app's commands, pages and records (including results from connected data sources). Returns matching items with ids you can pass to `run`.",parameters:{type:"object",properties:{query:{type:"string",description:"What to look for"}},required:["query"]}},label:o=>`Searching \u201C${String(o.query??"")}\u201D`,run:async(o,a)=>{let c=String(o.query??""),l=L(this.rootItems(),c,{limit:10}).map(p=>p.item),h=await Promise.all([...this.sources].map(async p=>{if(c.length<(p.minQueryLength??1))return[];try{let g=this.sourceExt.get(p),f=await ui(p.search({query:c,signal:a,ctx:this.makeContext(e,{ext:g,signal:a})}),6e3);if(g)for(let b of f)this.itemExt.set(b,g);return f.slice(0,p.limit??8).map(b=>({item:b,section:p.title??p.id}))}catch{return[]}})),d=[...l.map(p=>({item:p,section:p.section??"Commands"})),...h.flat()];return d.length?d.map(({item:p,section:g},f)=>{let b=p.id&&!t.has(p.id)?p.id:`${g}#${f}`;return t.set(b,p),{id:b,title:p.title,subtitle:p.subtitle,section:g,description:p.description,href:p.href??p.url}}):"No results."}},{definition:{name:"run",description:"Open or run an item (page, command or record) by id. Use ids from the system prompt or from `search`.",parameters:{type:"object",properties:{id:{type:"string"},arguments:{type:"object",description:"Values for the command arguments, if it has any.",additionalProperties:{type:"string"}}},required:["id"]}},label:o=>{let a=i(String(o.id??""));return a?`Opening ${a.title}`:`Running ${String(o.id??"")}`},run:async o=>{let a=i(String(o.id??""));if(!a)throw new Error(`No item with id "${String(o.id)}". Use search first.`);let c=this.itemExt.get(a);if(c?.missing().length)throw new Error(`${c.ext.title} needs to be configured first. Ask the user to open it from the command bar.`);let l=this.actionsFor(a,this.stack[0]??e)[0];if(!l)throw new Error("This item has no action.");if(l.style==="destructive"&&!await this.confirm({title:`${l.title}?`,message:a.title,destructive:!0,confirmLabel:l.title}))return"The user cancelled.";if(a.href){let g=this.config.navigate;return g?g(a.href,{newTab:!1}):ee(a.href,!1),this.frecency.record(this.idOf(a)),`Navigated to ${a.href}.`}if(a.url)return window.open(a.url,"_blank","noopener,noreferrer"),`Opened ${a.url} in a new tab.`;let h=Object.fromEntries(Object.entries(o.arguments??{}).map(([g,f])=>[g,String(f)])),d=Object.create(this.makeContext(e,{ext:c,args:h}),{close:{value:()=>{}}}),p=await l.run(d);return this.frecency.record(this.idOf(a)),De(p)?(this.push(p,c),`Opened the "${a.title}" view for the user.`):`Ran "${a.title}".`}}];this.aiOptions?.pageContext!==!1&&typeof document<"u"&&r.push({definition:{name:"read_page",description:'Read the visible text of the page the user is currently on. Use it when the user asks about "this page" or its content.',parameters:{type:"object",properties:{}}},label:()=>"Reading this page",run:async()=>{let a=(document.querySelector("main, [role=main], article")??document.body).innerText.replace(/\n{3,}/g,`
276
+ `),r.tools.push({label:d.label,state:"running"});else if(d.type==="tool_end"){let h=r.tools.find(b=>b.state==="running");h&&(h.state=d.ok?"done":"error")}else d.type==="error"&&(r.error=d.error);this.invalidate()}}catch(l){n.signal.aborted||(r.error=l instanceof Error?l.message:String(l))}finally{r.streaming=!1;for(let l of r.tools)l.state==="running"&&(l.state="error");e.loading--,i.controller=void 0,this.invalidate()}})()}stopChat(e){let t=e.chat?.controller;return t&&!t.signal.aborted?(t.abort(),!0):!1}systemPrompt(e){let t=[`You are ${this.aiName}, the assistant built into this web app's command bar.`,"Answer concisely in Markdown. Prefer short paragraphs and lists."];if(typeof document<"u"&&t.push(`The user is on the page "${document.title}" (${location.pathname}).`),e){let i=this.rootItems().filter(n=>!n.id?.startsWith("qikbar."));t.push("","You can act inside the app:","- Call `run` with an item id to open a page or run a command when the user asks you to go somewhere or do something.","- Call `search` to find commands, pages and records that are not listed below.","Only call tools when the user wants something done or found in the app; otherwise just answer. After acting, confirm briefly what you did.","","Available items (id | title | section):",...i.slice(0,80).map(n=>`${this.idOf(n)} | ${n.title}${n.subtitle?` \u2014 ${n.subtitle}`:""} | ${n.section??"Commands"}`)),i.length>80&&t.push(`\u2026and ${i.length-80} more (use search).`)}return this.aiOptions?.system&&t.push("",this.aiOptions.system),t.join(`
277
+ `)}async runForAgent(e,t,i,n){let r=i??this.createFrame({type:"root"}),o=this.itemExt.get(e);if(o?.missing().length)throw new Error(`${o.ext.title} needs to be configured first. Ask the user to open it from the command bar.`);let a=this.actionsFor(e,this.stack[0]??r)[0];if(!a)throw new Error("This item has no action.");if(a.style==="destructive"&&!await this.confirm({title:`${this.actionTitle(a)}?`,message:e.title,destructive:!0,confirmLabel:this.actionTitle(a)}))return"The user cancelled.";if(this.track({type:"run",item:this.eventItem(e),action:this.actionTitle(a),via:n}),e.href){let h=this.config.navigate;return h?h(e.href,{newTab:!1}):ie(e.href,!1),this.frecency.record(this.idOf(e)),`Navigated to ${e.href}.`}if(e.url)return window.open(e.url,"_blank","noopener,noreferrer"),`Opened ${e.url} in a new tab.`;let c=Object.fromEntries(Object.entries(t??{}).map(([h,b])=>[h,String(b)])),l=Object.create(this.makeContext(r,{ext:o,args:c}),{close:{value:()=>{}}}),d=await a.run(l);return this.frecency.record(this.idOf(e)),et(d)?(this.push(d,o),`Opened the "${e.title}" view for the user.`):`Ran "${e.title}".`}async searchForAgent(e,t,i,n){let r=t??this.createFrame({type:"root"}),o=O(this.rootItems(),e,{limit:10}).map(l=>l.item),a=await Promise.all([...this.sources].map(async l=>{if(e.length<(l.minQueryLength??1))return[];try{let d=this.sourceExt.get(l),h=await ii(l.search({query:e,signal:i,ctx:this.makeContext(r,{ext:d,signal:i})}),6e3);if(d)for(let b of h)this.itemExt.set(b,d);return h.slice(0,l.limit??8).map(b=>({item:b,section:l.title??l.id}))}catch{return[]}}));return[...o.map(l=>({item:l,section:l.section??"Commands"})),...a.flat()].map(({item:l,section:d},h)=>{let b=this.rootItems().includes(l)?this.idOf(l):l.id&&!n.has(l.id)?l.id:`${d}#${h}`;return n.set(b,l),{id:b,title:l.title,subtitle:l.subtitle,section:d,description:l.description,href:l.href??l.url}})}async agentTools(e,t){let i=new Map,n=a=>i.get(a)??this.rootItems().find(c=>this.idOf(c)===a),r=[{definition:{name:"search",description:"Search the app's commands, pages and records (including results from connected data sources). Returns matching items with ids you can pass to `run`.",parameters:{type:"object",properties:{query:{type:"string",description:"What to look for"}},required:["query"]}},label:a=>`Searching \u201C${String(a.query??"")}\u201D`,run:async(a,c)=>{let l=await this.searchForAgent(String(a.query??""),e,c,i);return l.length?l:"No results."}},{definition:{name:"run",description:"Open or run an item (page, command or record) by id. Use ids from the system prompt or from `search`.",parameters:{type:"object",properties:{id:{type:"string"},arguments:{type:"object",description:"Values for the command arguments, if it has any.",additionalProperties:{type:"string"}}},required:["id"]}},label:a=>{let c=n(String(a.id??""));return c?`Opening ${c.title}`:`Running ${String(a.id??"")}`},run:async a=>{let c=n(String(a.id??""));if(!c)throw new Error(`No item with id "${String(a.id)}". Use search first.`);return this.runForAgent(c,a.arguments,e,"ai")}}];this.aiOptions?.pageContext!==!1&&typeof document<"u"&&r.push({definition:{name:"read_page",description:'Read the visible text of the page the user is currently on. Use it when the user asks about "this page" or its content.',parameters:{type:"object",properties:{}}},label:()=>"Reading this page",run:async()=>{let c=(document.querySelector("main, [role=main], article")??document.body).innerText.replace(/\n{3,}/g,`
237
278
 
238
279
  `).trim();return`# ${document.title}
239
280
  URL: ${location.href}
240
281
 
241
- ${a.slice(0,2e4)}`}});let n=(o,a,c)=>{for(let l of o)r.push({definition:{name:di(c?`${c}__${l.name}`:l.name),description:l.description,parameters:l.parameters??{type:"object",properties:{}}},label:()=>l.description.split(/[.\n]/)[0].slice(0,60),run:async h=>{if(l.confirm){let d=typeof l.confirm=="function"?l.confirm(h):`Allow ${this.aiName} to ${l.name}?`;if(!await this.confirm({title:d,confirmLabel:"Allow"}))return"The user declined."}return l.run(h,this.makeContext(e,{ext:a}))}})};n(this.config.tools??[],void 0,"");for(let o of this.extensions.values())n(o.rt.ext.tools??[],o.rt,o.rt.ext.name);return r}toast(e){let t=typeof e=="string"?{title:e}:e,i=++this.toastId,r=()=>{clearTimeout(this.toastTimer);let o=this.toastState;if(!o)return;let a=o.duration??(o.style==="loading"?0:2600);a>0&&(this.toastTimer=setTimeout(()=>n(),a))},n=()=>{this.toastState?.id===i&&(this.toastState=void 0,this.renderToast())};return this.toastState={...t,id:i},r(),this.renderToast(),{update:o=>{this.toastState?.id===i&&(this.toastState={...this.toastState,...o},r(),this.renderToast())},hide:n}}confirm(e){let t=typeof e=="string"?{title:e}:e;return!this._open||!this.dom?Promise.resolve(typeof window<"u"?window.confirm(t.message?`${t.title}
282
+ ${c.slice(0,2e4)}`}});let o=(a,c,l)=>{for(let d of a)r.push({definition:{name:Di(l?`${l}__${d.name}`:d.name),description:d.description,parameters:d.parameters??{type:"object",properties:{}}},label:()=>d.description.split(/[.\n]/)[0].slice(0,60),run:async h=>{if(d.confirm){let b=typeof d.confirm=="function"?d.confirm(h):this.t("allowTool",{tool:d.name});if(!await this.confirm({title:b,confirmLabel:this.t("allow")}))return"The user declined."}return d.run(h,this.makeContext(e,{ext:c}))}})};o(this.config.tools??[],void 0,"");for(let a of this.extensions.values())o(a.rt.ext.tools??[],a.rt,a.rt.ext.name);for(let a of this.aiOptions?.mcp??[])try{o(await ii(a.tools(t),1e4),void 0,a.name)}catch(c){t?.aborted||console.warn(`[qikbar] tools from "${a.name}" are unavailable`,c)}return r}toolList(){let e=(this.config.tools??[]).map(t=>({tool:t,prefix:""}));for(let t of this.extensions.values())for(let i of t.rt.ext.tools??[])e.push({tool:i,rt:t.rt,prefix:t.rt.ext.name});return e}toolContext(e){return this.makeContext(this.top??this.createFrame({type:"root"}),{ext:e})}toast(e){let t=typeof e=="string"?{title:e}:e,i=++this.toastId,n=a=>a.action??(a.undo?{title:this.t("undo"),shortcut:"mod+z",run:a.undo}:void 0),r=()=>{clearTimeout(this.toastTimer);let a=this.toastState;if(!a)return;let c=a.duration??(a.style==="loading"?0:a.act?6e3:2600);c>0&&(this.toastTimer=setTimeout(()=>o(),c))},o=()=>{this.toastState?.id===i&&(this.toastState=void 0,this.renderToast())};return this.toastState={...t,id:i,act:n(t)},r(),this.renderToast(),{update:a=>{if(this.toastState?.id!==i)return;let c={...this.toastState,...a};this.toastState={...c,act:n(c)},r(),this.renderToast()},hide:o}}async runToastAction(){let e=this.toastState,t=e?.act;if(!(!e||!t)){clearTimeout(this.toastTimer),this.toastState=void 0,this.renderToast();try{await t.run(),e.undo&&!e.action&&this.track({type:"undo",title:e.title})}catch(i){console.error(i),this.toast({style:"failure",title:this.t("somethingWentWrong"),message:i instanceof Error?i.message:String(i)})}}}confirm(e){let t=typeof e=="string"?{title:e}:e;return!this._open||!this.dom?Promise.resolve(typeof window<"u"?window.confirm(t.message?`${t.title}
242
283
 
243
- ${t.message}`:t.title):!1):(this.confirmState?.resolve(!1),new Promise(i=>{this.confirmState={...t,resolve:r=>{this.confirmState=void 0,this.renderLayer(),this.focusInput(),i(r)}},this.renderLayer()}))}escape(){let e=this.top;if(e&&!(e.chat&&this.stopChat(e))){if(this.stack.length>1)return this.pop();if(e.query)return this.setQuery("");this.close()}}openPanel(){let e=this.top;if(!e||!this.dom)return;if(this.panel)return this.closePanel();let t=this.selectedItem(e),i=this.actionsFor(t,e);i.length&&(this.panel={item:t,actions:i,filter:"",selected:0},this.renderPanel())}closePanel(){this.panel&&(this.panel.el?.remove(),this.panel=void 0,this.focusInput())}panelActions(){let e=this.panel;return e.filter?L(e.actions,e.filter).map(t=>t.item):e.actions}onPanelKey(e){let t=this.panel,i=this.panelActions();if(e.key==="Escape"||E(e,this.actionsHotkey))return this.closePanel(),!0;if(e.key==="ArrowDown"||e.ctrlKey&&e.key==="n")return t.selected=(t.selected+1)%Math.max(1,i.length),this.renderPanel(),!0;if(e.key==="ArrowUp"||e.ctrlKey&&e.key==="p")return t.selected=(t.selected-1+i.length)%Math.max(1,i.length),this.renderPanel(),!0;if(e.key==="Enter"){let r=i[t.selected];return r&&this.runFromPanel(r),!0}for(let r of t.actions)if(r.shortcut&&E(e,r.shortcut))return this.runFromPanel(r),!0;return!1}runFromPanel(e){let t=this.panel?.item,i=this.top;this.closePanel(),this.runAction(i,t,e)}renderPanel(){let e=this.panel,t=this.dom;if(!e||!t)return;e.el||(e.list=u("div",{class:"qb-actions-list",role:"listbox",id:`${this.instanceId}-actions`}),e.input=u("input",{class:"qb-actions-input",placeholder:"Search for actions\u2026","aria-label":"Search actions",autocomplete:"off",spellcheck:"false",onInput:()=>{e.filter=e.input.value,e.selected=0,this.renderPanel()}}),e.el=u("div",{class:this.cls("qb-actions","actions"),role:"dialog","aria-label":"Actions"},u("div",{class:"qb-actions-title"},e.item?.title??"Actions"),e.list,e.input),e.el.addEventListener("pointerdown",o=>{o.target!==e.input&&o.preventDefault()}),t.dialog.append(e.el),e.input.focus());let i=this.panelActions();e.selected=Math.min(e.selected,Math.max(0,i.length-1));let r=[],n;i.forEach((o,a)=>{!e.filter&&o.section&&o.section!==n&&r.push(u("div",{class:"qb-section"},o.section)),n=o.section;let c=o.shortcut??(a===0&&!e.filter?"enter":a===1&&!e.filter?"mod+enter":void 0),l=u("div",{class:"qb-action",role:"option",id:`${this.instanceId}-action-${a}`,"aria-selected":a===e.selected?"true":"false","data-style":o.style??"default",onClick:()=>this.runFromPanel(o),onPointermove:()=>{e.selected!==a&&(e.selected=a,this.renderPanel())}},k(o.icon??"dot",15),u("span",{class:"qb-action-title"},o.title),c?R(c):null);r.push(l)}),i.length||r.push(u("div",{class:"qb-empty-desc",style:"padding:10px 8px"},"No matching actions")),e.list.replaceChildren(...r),e.input.setAttribute("aria-activedescendant",`${this.instanceId}-action-${e.selected}`),e.list.querySelector("[aria-selected=true]")?.scrollIntoView({block:"nearest"})}cls(e,t){let i=this.config.classNames?.[t];return i?`${e} ${i}`:e}injectStyles(){if(this.config.unstyled||typeof document>"u"||document.getElementById("qikbar-styles"))return;let t=document.createElement("style");t.id="qikbar-styles",this.config.nonce&&(t.nonce=this.config.nonce),t.textContent=me,document.head.append(t),this.styleEl=t}mount(){if(this.dom||typeof document>"u")return;this.injectStyles();let e=this.instanceId,t=u("input",{class:this.cls("qb-input","input"),type:"text",role:"combobox",autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellcheck:"false",enterkeyhint:"go","aria-autocomplete":"list","aria-expanded":"true","aria-controls":`${e}-list`,"aria-label":"Search"});t.addEventListener("input",()=>{let y=this.top;y&&this.onQueryChange(y,t.value)});let i=u("button",{class:"qb-back",type:"button","aria-label":"Back",title:"Back",html:""});i.append(k("arrow-left",15)),i.addEventListener("click",()=>this.pop());let r=u("button",{class:"qb-hint",type:"button"});r.addEventListener("click",()=>this.ask(this.top?.query));let n=u("div",{class:"qb-progress","aria-hidden":"true"}),o=u("div",{class:this.cls("qb-header","header")},i,u("div",{class:"qb-crumb"}),u("span",{class:"qb-header-icon"},k("search",18)),t,u("div",{class:"qb-args",style:"display:contents"}),u("div",{class:"qb-title"}),r,n),a=u("div",{class:"qb-body"}),c=u("div",{class:"qb-footer-left","aria-live":"polite"}),l=u("div",{class:"qb-footer-right"}),h=u("div",{class:this.cls("qb-footer","footer")},c,l),d=u("div",{style:"display:contents"}),p=u("div",{class:this.cls("qb-dialog","dialog"),role:"dialog","aria-modal":this.isInline?"false":"true","aria-label":"Command bar",tabindex:"-1",hidden:!0},o,a,h,d),g=u("div",{class:this.cls("qb-overlay","overlay"),hidden:!0});g.addEventListener("pointerdown",y=>{y.preventDefault(),this.close()});let f=u("div",{class:"qb-sr-only","aria-live":"polite"}),b=u("div",{class:this.cls("qb-root","root"),"data-qb-state":"closed",id:e},g,p,f);this.config.dir&&(b.dir=this.config.dir),p.addEventListener("keydown",this.onDialogKeyDown),p.addEventListener("click",y=>{let x=y.target.closest?.("[data-qb-copy]");if(x){let A=x.closest(".qb-code")?.querySelector("code")?.textContent??"";N(A).then(Pt=>{x.textContent=Pt?"Copied":"Failed",setTimeout(()=>x.textContent="Copy",1200)})}this.panel&&!y.target.closest?.(".qb-actions")&&!y.target.closest?.(".qb-footer-btn")&&this.closePanel()});let v=this.inlineTarget();v?(b.dataset.qbInline="",v.append(b)):(this.config.container??document.body).append(b),this.dom={root:b,overlay:g,dialog:p,header:o,back:i,crumb:o.querySelector(".qb-crumb"),searchIcon:o.querySelector(".qb-header-icon"),input:t,args:o.querySelector(".qb-args"),title:o.querySelector(".qb-title"),hint:r,progress:n,body:a,footer:h,footerLeft:c,footerRight:l,layer:d,live:f},this.applyTheme(),this.watchAppearance(),this.listen(document,"focusin",(y=>{this._open&&!this.isInline&&this.dom&&!this.dom.root.contains(y.target)&&this.focusInput()}))}applyClassNames(){let e=this.dom;e&&(e.root.className=this.cls("qb-root","root"),e.overlay.className=this.cls("qb-overlay","overlay"),e.dialog.className=this.cls("qb-dialog","dialog"),e.header.className=this.cls("qb-header","header"),e.input.className=this.cls("qb-input","input"),e.footer.className=this.cls("qb-footer","footer"),this.renderer&&(this.renderer.destroy(),this.renderer=void 0,this.flush()))}resolveAppearance(){let e=this.config.appearance??"auto";if(typeof e=="function")return e();if(e!=="auto")return e;let t=document.documentElement,i=document.body,r=a=>!!a&&(a.classList.contains("dark")||a.dataset.theme==="dark"||a.dataset.mode==="dark"||a.dataset.colorScheme==="dark"||a.dataset.bsTheme==="dark"),n=a=>!!a&&(a.classList.contains("light")||a.dataset.theme==="light"||a.dataset.mode==="light"||a.dataset.colorScheme==="light"||a.dataset.bsTheme==="light");if(r(t)||r(i))return"dark";if(n(t)||n(i))return"light";let o=t.style.colorScheme||getComputedStyle(t).colorScheme;return o==="dark"?"dark":o==="light"?"light":typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}applyTheme(){let e=this.dom?.root;if(!e)return;let{vars:t,appearance:i}=ue(this.config.theme,this.resolveAppearance());e.dataset.qbAppearance=i;let r=typeof this.config.theme=="string"?this.config.theme:this.config.theme?.preset;r?e.dataset.qbTheme=r:delete e.dataset.qbTheme;for(let n of this.appliedVars)e.style.removeProperty(n);this.appliedVars=[];for(let[n,o]of Object.entries(t)){if(o==null||o==="")continue;let a=K(n);e.style.setProperty(a,o),this.appliedVars.push(a)}}watchAppearance(){if(typeof MutationObserver>"u")return;let e=()=>{this.dom&&(this.config.appearance??"auto")==="auto"&&this.applyTheme()},t=new MutationObserver(e);if(t.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","data-mode","data-color-scheme","data-bs-theme","style"]}),document.body&&t.observe(document.body,{attributes:!0,attributeFilter:["class","data-theme","data-mode"]}),this.teardown.push(()=>t.disconnect()),typeof matchMedia<"u"){let i=matchMedia("(prefers-color-scheme: dark)");i.addEventListener?.("change",e),this.teardown.push(()=>i.removeEventListener?.("change",e))}}lockScroll(){let e=document.documentElement,t=window.innerWidth-e.clientWidth;this.scrollLock={overflow:e.style.overflow,paddingRight:e.style.paddingRight},e.style.overflow="hidden",t>0&&(e.style.paddingRight=`${t}px`)}unlockScroll(){if(!this.scrollLock)return;let e=document.documentElement;e.style.overflow=this.scrollLock.overflow,e.style.paddingRight=this.scrollLock.paddingRight,this.scrollLock=void 0}focusInput(){if(!this.dom||!this._open)return;let e=this.renderer?.focusTarget?.()??(this.dom.input.hidden?this.dom.dialog:this.dom.input);document.activeElement!==e&&e.focus({preventScroll:!0})}invalidate(){this.scheduled||!this.dom||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.flush()}))}flush(){let e=this.dom,t=this.top;!e||!t||!this._open&&!this.isInline||(!this.renderer||this.renderer.frame!==t?(this.renderer?.destroy(),this.renderer=this.createRenderer(t),e.body.replaceChildren(this.renderer.el),this.renderer.update(),t.scrollTop&&this.renderer.restoreScroll(t.scrollTop),t.selected>0&&this.renderer.ensureVisible?.()):this.renderer.update(),this.renderHeader(t),this.renderFooter(t),this.renderLayer(),this.panel&&this.renderPanel())}createRenderer(e){switch(e.view.type){case"grid":return new ge(this,e);case"detail":return new be(this,e);case"form":return new ye(this,e);case"chat":return new ve(this,e);default:return new te(this,e)}}renderHeader(e){let t=this.dom,i=e.view,r=this.stack.length,n=this.renderer?.hasInput??!0;t.back.hidden=r<=1;let o=r>1?i.title??(i.type==="chat"?this.aiName:void 0):void 0;if(t.crumb.hidden=!o||!n,o&&n&&t.crumb.replaceChildren(...[k(e.ext?.ext.icon,13),u("span",null,o)].filter(Boolean)),t.searchIcon.hidden=r>1||!!this.argMode,this.argMode){let l=this.argMode;if(t.input.hidden=!0,t.title.hidden=!0,t.args.dataset.for!==this.idOf(l.item)){t.args.dataset.for=this.idOf(l.item);let h=(l.item.arguments??[]).map(d=>{if(d.type==="dropdown"){let g=u("select",{class:"qb-arg",name:d.name,"aria-label":d.placeholder??d.name},...(d.options??[]).map(f=>u("option",{value:f.value},f.title)));return l.values[d.name]=g.value,g.addEventListener("change",()=>l.values[d.name]=g.value),g}let p=u("input",{class:"qb-arg",name:d.name,type:d.type==="password"?"password":"text",placeholder:`${d.placeholder??d.name}${d.required?"":" (optional)"}`,"aria-label":d.placeholder??d.name,autocomplete:"off",spellcheck:"false"});return p.addEventListener("input",()=>l.values[d.name]=p.value),p});t.args.replaceChildren(u("span",{class:"qb-arg-cmd"},k(l.item.icon,16),l.item.title),...h)}t.args.hidden=!1}else{t.args.hidden=!0,delete t.args.dataset.for,t.args.replaceChildren(),t.input.hidden=!n,t.title.hidden=n,n||(t.title.textContent=i.title??"");let l=this.renderer?.placeholder?.()??i.placeholder??(i.type==="root"?this.config.placeholder??"Search for commands, pages and more\u2026":"Search\u2026");t.input.placeholder!==l&&(t.input.placeholder=l),t.input.value!==e.query&&(t.input.value=e.query)}let a=e.itemRows[e.selected];a&&(i.type==="root"||i.type==="list"||i.type==="grid")?t.input.setAttribute("aria-activedescendant",`${this.instanceId}-opt-${a.key.replace(/[^\w-]/g,"_")}`):t.input.removeAttribute("aria-activedescendant");let c=!!this.ai&&i.type==="root"&&!this.argMode&&this.aiOptions?.fallback!==!1;t.hint.hidden=!c,c&&!t.hint.childElementCount&&t.hint.append(u("span",null,`Ask ${this.aiName}`),R("tab")),e.loading>0?t.progress.dataset.active="":delete t.progress.dataset.active}renderFooter(e){let t=this.dom;!this.toastState||!this._open?this.renderFooterLeft(e):this.renderToast();let i=[],r=this.renderer?.footerPrimary?.(),n=this.actionsFor(this.selectedItem(e),e),o=r??(n[0]?{title:n[0].title,hotkey:"enter",run:()=>this.runPrimary(e)}:void 0);this.argMode?i.push(this.footerButton(`Run ${this.argMode.item.title}`,"enter",()=>this.submitArgs(),!0)):o&&i.push(this.footerButton(o.title,o.hotkey,o.run,!0)),n.length>(r?0:1)&&!this.argMode&&i.push(u("span",{class:"qb-footer-sep"}),this.footerButton("Actions",this.actionsHotkey,()=>this.openPanel())),t.footerRight.replaceChildren(...i)}renderFooterLeft(e){let t=this.dom,i=e.view,r=[];if(this.stack.length>1&&i.title){let n=k(e.ext?.ext.icon??"layers",14);n&&r.push(n),r.push(u("span",null,i.title))}else if(this.config.footer)r.push(u("span",null,this.config.footer));else if(this.config.branding){let n=u("a",{class:"qb-brand",href:"https://qikbar.com",target:"_blank",rel:"noopener"},k("command",13),"qikbar");r.push(n)}t.footerLeft.replaceChildren(...r)}footerButton(e,t,i,r=!1){let n=u("button",{class:`qb-footer-btn${r?" qb-primary":""}`,type:"button"},u("span",null,e),R(t));return n.addEventListener("pointerdown",o=>o.preventDefault()),n.addEventListener("click",i),n}renderToast(){let e=this.toastState,t=r=>r==="success"?"check-circle":r==="failure"?"x-circle":r==="loading"?"loader":"info",i=r=>{let n=k(t(e.style),14);return e.style==="loading"&&n.classList.add("qb-spin"),u("div",{class:this.cls(r,"toast"),"data-style":e.style??"info",role:"status"},n,u("span",{class:"qb-toast-title"},e.title),e.message?u("span",{class:"qb-toast-msg"},e.message):null)};if(this._open&&this.dom){this.hud?.remove(),this.hud=void 0,e?this.dom.footerLeft.replaceChildren(i("qb-toast")):this.top&&this.renderFooterLeft(this.top);return}typeof document>"u"||(this.mount(),this.hud?.remove(),this.hud=void 0,!(!e||!this.dom)&&(this.applyTheme(),this.hud=i("qb-hud"),this.dom.root.append(this.hud)))}renderLayer(){let e=this.dom;if(!e)return;let t=this.confirmState;if(!t){e.layer.replaceChildren();return}if(e.layer.firstChild)return;let i=u("button",{class:"qb-btn",type:"button"},t.cancelLabel??"Cancel"),r=u("button",{class:`qb-btn ${t.destructive?"qb-btn-danger":"qb-btn-primary"}`,type:"button"},t.confirmLabel??"Confirm",R("enter"));i.addEventListener("click",()=>t.resolve(!1)),r.addEventListener("click",()=>t.resolve(!0)),r.addEventListener("keydown",n=>{n.key==="Enter"&&(n.preventDefault(),t.resolve(!0))}),e.layer.append(u("div",{class:"qb-confirm-layer"},u("div",{class:"qb-confirm",role:"alertdialog","aria-modal":"true","aria-label":t.title},u("div",{class:"qb-confirm-title"},t.title),t.message?u("div",{class:"qb-confirm-msg"},t.message):null,u("div",{class:"qb-confirm-buttons"},i,r)))),r.focus()}announce(e){this.dom&&(this.dom.live.textContent=e)}}});var Ti={};we(Ti,{Frecency:()=>D,SequenceMatcher:()=>z,action:()=>M,anthropic:()=>J,baseDark:()=>pe,baseLight:()=>he,browserAI:()=>Te,byok:()=>Se,chat:()=>et,copyText:()=>N,createQikbar:()=>fi,css:()=>me,cssVarName:()=>K,defaultNavigate:()=>ee,defaultStorage:()=>P,defineCommands:()=>tt,defineExtension:()=>ke,defineSource:()=>it,defineTool:()=>rt,detail:()=>Xe,escapeHtml:()=>I,extensions:()=>Qe,form:()=>Ze,formatHotkey:()=>$,fuzzyMatch:()=>F,gemini:()=>Y,grid:()=>Ye,iconSvg:()=>ce,icons:()=>$e,isEditable:()=>j,isMac:()=>C,list:()=>Je,matchItem:()=>Z,matchesHotkey:()=>E,memoryStorage:()=>ae,normalize:()=>T,ollama:()=>Ee,openai:()=>_,openaiCompatible:()=>Me,parseHotkey:()=>O,presets:()=>Ve,proxy:()=>Ae,rank:()=>L,renderMarkdown:()=>S,resolveThemeVars:()=>ue,scopedStorage:()=>Q,themeToCss:()=>wt,version:()=>mi});H();var se=class{constructor(e,t){m(this,"loader",t);m(this,"bar");m(this,"loading");m(this,"queue",[]);m(this,"config");m(this,"teardown",[]);m(this,"destroyed",!1);if(this.config={...e},typeof document>"u")return;if(e.inline){this.load();return}let i=o=>{let a=this.config.hotkey===!1?[]:[].concat(this.config.hotkey??"mod+k"),c=j(o.target);!this.bar&&a.some(l=>E(o,l)&&(!c||U(l)))&&(o.preventDefault(),this.open())},r=o=>{let a=o.target?.closest?.("[data-qikbar-open]");if(!a||this.bar)return;let c=a.getAttribute("data-qikbar-open");c&&c!==this.config.namespace||(o.preventDefault(),this.open({query:a.getAttribute("data-qikbar-query")??void 0}))};document.addEventListener("keydown",i,!0),document.addEventListener("click",r,!0),this.teardown.push(()=>{document.removeEventListener("keydown",i,!0),document.removeEventListener("click",r,!0)});let n=globalThis.requestIdleCallback;n?n(()=>{this.load()},{timeout:2500}):setTimeout(()=>{this.load()},1200)}preload(){return this.load().then(()=>{})}load(){return this.loading??(this.loading=this.loader().then(({Bar:e})=>{if(this.destroyed)throw new Error("destroyed");for(let r of this.teardown)r();this.teardown=[];let t=new e(this.config);this.bar=t;let i=this.queue;this.queue=[];for(let r of i)r(t);return t})),this.loading.catch(e=>{this.destroyed||console.error("[qikbar] failed to load UI",e)}),this.loading}run(e){this.bar?e(this.bar):(this.queue.push(e),this.load())}disposable(e){if(this.bar)return e(this.bar);let t,i=!1;return this.queue.push(r=>{i||(t=e(r))}),()=>{i=!0,t?.()}}get isOpen(){return this.bar?.isOpen??!1}get query(){return this.bar?.query??""}get ai(){return this.bar?.ai}open(e){this.run(t=>t.open(e))}close(){this.bar?.close()}toggle(){this.bar?this.bar.toggle():this.open()}register(e){return this.disposable(t=>t.register(e))}addSource(e){return this.disposable(t=>t.addSource(e))}use(e,t){return this.disposable(i=>i.use(e,t))}configure(e){this.bar?this.bar.configure(e):this.config={...this.config,...e}}push(e){this.run(t=>t.push(e))}pop(){this.bar?.pop()}setQuery(e){this.run(t=>t.setQuery(e))}ask(e){this.run(t=>t.ask(e))}toast(e){if(this.bar)return this.bar.toast(e);let t,i=[];return this.run(r=>{t=r.toast(e);for(let n of i)n(t)}),{update:r=>t?t.update(r):i.push(n=>n.update(r)),hide:()=>t?t.hide():i.push(r=>r.hide())}}commands(){return this.bar?.commands()??[]}on(e,t){return this.disposable(i=>i.on(e,t))}destroy(){this.destroyed=!0;for(let e of this.teardown)e();this.teardown=[],this.queue=[],this.bar?.destroy()}};oe();H();W();async function*nt(s){if(!s.body)return;let e=s.body.getReader(),t=new TextDecoder,i="";try{for(;;){let{value:r,done:n}=await e.read();if(n)break;i+=t.decode(r,{stream:!0});let o;for(;(o=i.indexOf(`
244
- `))>=0;){let a=i.slice(0,o).replace(/\r$/,"");i=i.slice(o+1),yield a}}i+=t.decode(),i&&(yield i)}finally{e.releaseLock()}}async function*le(s){let e,t=[];for await(let i of nt(s))i===""?(t.length&&(yield{event:e,data:t.join(`
284
+ ${t.message}`:t.title):!1):(this.confirmState?.resolve(!1),new Promise(i=>{this.confirmState={...t,resolve:n=>{this.confirmState=void 0,this.renderLayer(),this.focusInput(),i(n)}},this.renderLayer()}))}escape(){let e=this.top;if(e&&!(e.chat&&this.stopChat(e))){if(e.marked?.size)return this.clearMarks(e);if(this.stack.length>1)return this.pop();if(e.query)return this.setQuery("");this.close()}}openPanel(){let e=this.top;if(!e||!this.dom)return;if(this.panel)return this.closePanel();let t=e.marked?.size?void 0:this.selectedItem(e),i=this.actionsFor(t,e);i.length&&(this.panel={item:t,actions:i,filter:"",selected:0},this.renderPanel())}closePanel(){this.panel&&(this.panel.el?.remove(),this.panel=void 0,this.focusInput())}panelActions(){let e=this.panel;return e.filter?O(e.actions,e.filter).map(t=>t.item):e.actions}onPanelKey(e){let t=this.panel,i=this.panelActions();if(e.key==="Escape"||M(e,this.actionsHotkey))return this.closePanel(),!0;let n=e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey;if(e.key==="ArrowDown"||n&&e.key==="n")return t.selected=(t.selected+1)%Math.max(1,i.length),this.renderPanel(),!0;if(e.key==="ArrowUp"||n&&e.key==="p")return t.selected=(t.selected-1+i.length)%Math.max(1,i.length),this.renderPanel(),!0;if(e.key==="Enter"){let r=i[t.selected];return r&&this.runFromPanel(r),!0}for(let r of t.actions)if(r.shortcut&&M(e,r.shortcut))return this.runFromPanel(r),!0;return!1}runFromPanel(e){let t=this.panel?.item,i=this.top;this.closePanel(),this.runAction(i,t,e,void 0,"panel")}renderPanel(){let e=this.panel,t=this.dom;if(!e||!t)return;e.el||(e.list=f("div",{class:"qb-actions-list",role:"listbox",id:`${this.instanceId}-actions`}),e.input=f("input",{class:"qb-actions-input",placeholder:this.t("searchActions"),"aria-label":this.t("searchActions"),autocomplete:"off",spellcheck:"false",onInput:()=>{e.filter=e.input.value,e.selected=0,this.renderPanel()}}),e.el=f("div",{class:this.cls("qb-actions","actions"),role:"dialog","aria-label":this.t("actions")},f("div",{class:"qb-actions-title"},e.item?.title??(this.top?.marked?.size?this.t("selected",{count:this.top.marked.size}):this.t("actions"))),e.list,e.input),e.el.addEventListener("pointerdown",o=>{o.target!==e.input&&o.preventDefault()}),t.dialog.append(e.el),this.isTouch||e.input.focus());let i=this.panelActions();e.selected=Math.min(e.selected,Math.max(0,i.length-1));let n=[],r;i.forEach((o,a)=>{!e.filter&&o.section&&o.section!==r&&n.push(f("div",{class:"qb-section"},o.section)),r=o.section;let c=o.shortcut??(a===0&&!e.filter?"enter":a===1&&!e.filter?"mod+enter":void 0),l=f("div",{class:"qb-action",role:"option",id:`${this.instanceId}-action-${a}`,"aria-selected":a===e.selected?"true":"false","data-style":o.style??"default",onClick:()=>this.runFromPanel(o),onPointermove:()=>{e.selected!==a&&(e.selected=a,this.renderPanel())}},T(o.icon??"dot",15),f("span",{class:"qb-action-title"},this.actionTitle(o)),c?L(c):null);n.push(l)}),i.length||n.push(f("div",{class:"qb-empty-desc",style:"padding:10px 8px"},this.t("noMatchingActions"))),e.list.replaceChildren(...n),e.input.setAttribute("aria-activedescendant",`${this.instanceId}-action-${e.selected}`),e.list.querySelector("[aria-selected=true]")?.scrollIntoView({block:"nearest"})}cls(e,t){let i=this.config.classNames?.[t];return i?`${e} ${i}`:e}injectStyles(){if(this.config.unstyled||typeof document>"u"||document.getElementById("qikbar-styles"))return;let t=document.createElement("style");t.id="qikbar-styles",this.config.nonce&&(t.nonce=this.config.nonce),t.textContent=ke,document.head.append(t),this.styleEl=t}mount(){if(this.dom||typeof document>"u")return;this.injectStyles();let e=this.instanceId,t=f("input",{class:this.cls("qb-input","input"),type:"text",role:"combobox",autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellcheck:"false",enterkeyhint:"go","aria-autocomplete":"list","aria-expanded":"true","aria-controls":`${e}-list`,"aria-label":this.t("search")});t.addEventListener("input",()=>{let y=this.top;y&&this.onQueryChange(y,t.value)});let i=f("button",{class:"qb-back",type:"button","aria-label":this.t("back"),title:this.t("back"),html:""});i.append(T("arrow-left",15)),i.addEventListener("click",()=>this.pop());let n=f("button",{class:"qb-hint",type:"button"});n.addEventListener("click",()=>this.ask(this.top?.query));let r=f("div",{class:"qb-progress","aria-hidden":"true"}),o=f("div",{class:this.cls("qb-header","header")},i,f("div",{class:"qb-crumb"}),f("span",{class:"qb-header-icon"},T("search",18)),t,f("div",{class:"qb-args",style:"display:contents"}),f("div",{class:"qb-title"}),n,r),a=f("div",{class:"qb-body"}),c=f("div",{class:"qb-footer-left","aria-live":"polite"}),l=f("div",{class:"qb-footer-right"}),d=f("div",{class:this.cls("qb-footer","footer")},c,l),h=f("div",{style:"display:contents"}),b=f("div",{class:this.cls("qb-dialog","dialog"),role:"dialog","aria-modal":this.isInline?"false":"true","aria-label":this.t("commandBar"),tabindex:"-1",hidden:!0},o,a,d,h),v=f("div",{class:this.cls("qb-overlay","overlay"),hidden:!0});v.addEventListener("pointerdown",y=>{y.preventDefault(),this.close()});let m=f("div",{class:"qb-sr-only","aria-live":"polite"}),p=f("div",{class:this.cls("qb-root","root"),"data-qb-state":"closed",id:e},v,b,m);this.config.dir&&(p.dir=this.config.dir),b.addEventListener("keydown",this.onDialogKeyDown),b.addEventListener("click",y=>{let x=y.target.closest?.("[data-qb-copy]");if(x){let w=x.closest(".qb-code")?.querySelector("code")?.textContent??"";K(w).then(k=>{x.textContent=k?this.t("copiedShort"):this.t("failed"),setTimeout(()=>x.textContent=this.t("copy"),1200)})}this.panel&&!y.target.closest?.(".qb-actions")&&!y.target.closest?.(".qb-footer-btn")&&this.closePanel()});let g=this.inlineTarget();g?(p.dataset.qbInline="",g.append(p)):(this.config.container??document.body).append(p),this.dom={root:p,overlay:v,dialog:b,header:o,back:i,crumb:o.querySelector(".qb-crumb"),searchIcon:o.querySelector(".qb-header-icon"),input:t,args:o.querySelector(".qb-args"),title:o.querySelector(".qb-title"),hint:n,progress:r,body:a,footer:d,footerLeft:c,footerRight:l,layer:h,live:m},this.applyTheme(),this.applyTouch(),this.watchAppearance(),this.watchViewport(),this.listen(document,"focusin",(y=>{this._open&&!this.isInline&&this.dom&&!this.dom.root.contains(y.target)&&this.focusInput()}))}applyClassNames(){let e=this.dom;e&&(e.root.className=this.cls("qb-root","root"),e.overlay.className=this.cls("qb-overlay","overlay"),e.dialog.className=this.cls("qb-dialog","dialog"),e.header.className=this.cls("qb-header","header"),e.input.className=this.cls("qb-input","input"),e.footer.className=this.cls("qb-footer","footer"),this.renderer&&(this.renderer.destroy(),this.renderer=void 0,this.flush()))}resolveAppearance(){let e=this.config.appearance??"auto";if(typeof e=="function")return e();if(e!=="auto")return e;let t=document.documentElement,i=document.body,n=a=>!!a&&(a.classList.contains("dark")||a.dataset.theme==="dark"||a.dataset.mode==="dark"||a.dataset.colorScheme==="dark"||a.dataset.bsTheme==="dark"),r=a=>!!a&&(a.classList.contains("light")||a.dataset.theme==="light"||a.dataset.mode==="light"||a.dataset.colorScheme==="light"||a.dataset.bsTheme==="light");if(n(t)||n(i))return"dark";if(r(t)||r(i))return"light";let o=t.style.colorScheme||getComputedStyle(t).colorScheme;return o==="dark"?"dark":o==="light"?"light":typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}applyTheme(){let e=this.dom?.root;if(!e)return;let{vars:t,appearance:i}=xe(this.config.theme,this.resolveAppearance());e.dataset.qbAppearance=i;let n=typeof this.config.theme=="string"?this.config.theme:this.config.theme?.preset;n?e.dataset.qbTheme=n:delete e.dataset.qbTheme;for(let r of this.appliedVars)e.style.removeProperty(r);this.appliedVars=[];for(let[r,o]of Object.entries(t)){if(o==null||o==="")continue;let a=j(r);e.style.setProperty(a,o),this.appliedVars.push(a)}}watchAppearance(){if(typeof MutationObserver>"u")return;let e=()=>{this.dom&&(this.config.appearance??"auto")==="auto"&&this.applyTheme()},t=new MutationObserver(e);if(t.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","data-mode","data-color-scheme","data-bs-theme","style"]}),document.body&&t.observe(document.body,{attributes:!0,attributeFilter:["class","data-theme","data-mode"]}),this.teardown.push(()=>t.disconnect()),typeof matchMedia<"u"){let i=matchMedia("(prefers-color-scheme: dark)");i.addEventListener?.("change",e),this.teardown.push(()=>i.removeEventListener?.("change",e))}}lockScroll(){let e=document.documentElement,t=window.innerWidth-e.clientWidth;this.scrollLock={overflow:e.style.overflow,paddingRight:e.style.paddingRight},e.style.overflow="hidden",t>0&&(e.style.paddingRight=`${t}px`)}unlockScroll(){if(!this.scrollLock)return;let e=document.documentElement;e.style.overflow=this.scrollLock.overflow,e.style.paddingRight=this.scrollLock.paddingRight,this.scrollLock=void 0}focusInput(){if(!this.dom||!this._open)return;let e=this.renderer?.focusTarget?.()??(this.dom.input.hidden?this.dom.dialog:this.dom.input);document.activeElement!==e&&e.focus({preventScroll:!0})}invalidate(){this.scheduled||!this.dom||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.flush()}))}flush(){let e=this.dom,t=this.top;!e||!t||!this._open&&!this.isInline||(!this.renderer||this.renderer.frame!==t?(this.renderer?.destroy(),this.renderer=this.createRenderer(t),e.body.replaceChildren(this.renderer.el),this.renderer.update(),t.scrollTop&&this.renderer.restoreScroll(t.scrollTop),t.selected>0&&this.renderer.ensureVisible?.()):this.renderer.update(),this.renderHeader(t),this.renderFooter(t),this.renderLayer(),this.panel&&this.renderPanel())}createRenderer(e){switch(e.view.type){case"grid":return new qe(this,e);case"detail":return new Te(this,e);case"form":return new Ee(this,e);case"chat":return new Me(this,e);default:return new re(this,e)}}renderHeader(e){let t=this.dom,i=e.view,n=this.stack.length,r=this.renderer?.hasInput??!0;t.back.hidden=n<=1;let o=n>1?i.title??(i.type==="chat"?this.aiName:void 0):void 0;if(t.crumb.hidden=!o||!r,o&&r&&t.crumb.replaceChildren(...[T(e.ext?.ext.icon,13),f("span",null,o)].filter(Boolean)),t.searchIcon.hidden=n>1||!!this.argMode,this.argMode){let l=this.argMode;if(t.input.hidden=!0,t.title.hidden=!0,t.args.dataset.for!==this.idOf(l.item)){t.args.dataset.for=this.idOf(l.item);let d=(l.item.arguments??[]).map(h=>{if(h.type==="dropdown"){let v=f("select",{class:"qb-arg",name:h.name,"aria-label":h.placeholder??h.name},...(h.options??[]).map(m=>f("option",{value:m.value},m.title)));return l.values[h.name]=v.value,v.addEventListener("change",()=>l.values[h.name]=v.value),v}let b=f("input",{class:"qb-arg",name:h.name,type:h.type==="password"?"password":"text",placeholder:`${h.placeholder??h.name}${h.required?"":` ${this.t("optional")}`}`,"aria-label":h.placeholder??h.name,autocomplete:"off",spellcheck:"false"});return b.addEventListener("input",()=>l.values[h.name]=b.value),b});t.args.replaceChildren(f("span",{class:"qb-arg-cmd"},T(l.item.icon,16),l.item.title),...d)}t.args.hidden=!1}else{t.args.hidden=!0,delete t.args.dataset.for,t.args.replaceChildren(),t.input.hidden=!r,t.title.hidden=r,r||(t.title.textContent=i.title??"");let l=this.renderer?.placeholder?.()??i.placeholder??(i.type==="root"?this.config.placeholder??this.t("placeholder"):this.t("searchPlaceholder"));t.input.placeholder!==l&&(t.input.placeholder=l),t.input.value!==e.query&&(t.input.value=e.query)}let a=e.itemRows[e.selected];a&&(i.type==="root"||i.type==="list"||i.type==="grid")?t.input.setAttribute("aria-activedescendant",`${this.instanceId}-opt-${a.key.replace(/[^\w-]/g,"_")}`):t.input.removeAttribute("aria-activedescendant");let c=!!this.ai&&i.type==="root"&&!this.argMode&&this.aiOptions?.fallback!==!1;t.hint.hidden=!c,c&&!t.hint.childElementCount&&t.hint.append(f("span",null,this.t("askAi")),L("tab")),e.loading>0?t.progress.dataset.active="":delete t.progress.dataset.active}renderFooter(e){let t=this.dom;!this.toastState||!this._open?this.renderFooterLeft(e):this.renderToast();let i=[],n=this.renderer?.footerPrimary?.(),r=this.actionsFor(this.selectedItem(e),e),o=n??(r[0]?{title:this.actionTitle(r[0]),hotkey:"enter",run:()=>this.runPrimary(e)}:void 0);this.argMode?i.push(this.footerButton(this.t("runItem",{title:this.argMode.item.title}),"enter",()=>this.submitArgs(),!0)):o&&i.push(this.footerButton(o.title,o.hotkey,o.run,!0)),r.length>(n?0:1)&&!this.argMode&&i.push(f("span",{class:"qb-footer-sep"}),this.footerButton(this.t("actions"),this.actionsHotkey,()=>this.openPanel())),t.footerRight.replaceChildren(...i)}renderFooterLeft(e){let t=this.dom,i=e.view,n=[];if(e.marked?.size)n.push(T("check-square",14),f("span",null,this.t("selected",{count:e.marked.size})));else if(this.stack.length>1&&i.title){let r=T(e.ext?.ext.icon??"layers",14);r&&n.push(r),n.push(f("span",null,i.title))}else if(this.config.footer)n.push(f("span",null,this.config.footer));else if(this.config.branding){let r=f("a",{class:"qb-brand",href:"https://qikbar.com",target:"_blank",rel:"noopener"},T("command",13),"qikbar");n.push(r)}t.footerLeft.replaceChildren(...n)}footerButton(e,t,i,n=!1){let r=f("button",{class:`qb-footer-btn${n?" qb-primary":""}`,type:"button"},f("span",null,e),L(t));return r.addEventListener("pointerdown",o=>o.preventDefault()),r.addEventListener("click",i),r}renderToast(){let e=this.toastState,t=n=>n==="success"?"check-circle":n==="failure"?"x-circle":n==="loading"?"loader":"info",i=n=>{let r=T(t(e.style),14);e.style==="loading"&&r.classList.add("qb-spin");let o=null;return e.act&&(o=f("button",{class:"qb-toast-action",type:"button"},f("span",null,e.act.title),e.act.shortcut?L(e.act.shortcut):null),o.addEventListener("pointerdown",a=>a.preventDefault()),o.addEventListener("click",a=>{a.stopPropagation(),this.runToastAction()})),f("div",{class:this.cls(n,"toast"),"data-style":e.style??"info","data-action":e.act?"":null,role:"status"},r,f("span",{class:"qb-toast-title"},e.title),e.message?f("span",{class:"qb-toast-msg"},e.message):null,o)};if(this._open&&this.dom){this.hud?.remove(),this.hud=void 0,e?this.dom.footerLeft.replaceChildren(i("qb-toast")):this.top&&this.renderFooterLeft(this.top);return}typeof document>"u"||(this.mount(),this.hud?.remove(),this.hud=void 0,!(!e||!this.dom)&&(this.applyTheme(),this.hud=i("qb-hud"),this.dom.root.append(this.hud)))}renderLayer(){let e=this.dom;if(!e)return;let t=this.confirmState;if(!t){e.layer.replaceChildren();return}if(e.layer.firstChild)return;let i=f("button",{class:"qb-btn",type:"button"},t.cancelLabel??this.t("cancel")),n=f("button",{class:`qb-btn ${t.destructive?"qb-btn-danger":"qb-btn-primary"}`,type:"button"},t.confirmLabel??this.t("confirm"),L("enter"));i.addEventListener("click",()=>t.resolve(!1)),n.addEventListener("click",()=>t.resolve(!0)),n.addEventListener("keydown",r=>{r.key==="Enter"&&(r.preventDefault(),t.resolve(!0))}),e.layer.append(f("div",{class:"qb-confirm-layer"},f("div",{class:"qb-confirm",role:"alertdialog","aria-modal":"true","aria-label":t.title},f("div",{class:"qb-confirm-title"},t.title),t.message?f("div",{class:"qb-confirm-msg"},t.message):null,f("div",{class:"qb-confirm-buttons"},i,n)))),n.focus()}md(e){return ne(e,{copyLabel:this.t("copy")})}announce(e){this.dom&&(this.dom.live.textContent=e)}},ei=s=>!!s.id&&(s.id.startsWith("fallback:")||s.id==="qikbar.ask-ai-fallback"),se=s=>s.trim().toLowerCase().replace(/\s+/g," ")});var an={};de(an,{Frecency:()=>U,SequenceMatcher:()=>D,action:()=>A,anthropic:()=>X,baseDark:()=>ve,baseLight:()=>ye,browserAI:()=>$e,byok:()=>_e,cachedEmbeddings:()=>Lt,chat:()=>pt,copyText:()=>K,createQikbar:()=>Qi,css:()=>ke,cssVarName:()=>j,defaultNavigate:()=>ie,defaultStorage:()=>_,defineCommands:()=>ut,defineExtension:()=>Le,defineSource:()=>ft,defineTool:()=>mt,detail:()=>dt,escapeHtml:()=>I,extensions:()=>nt,form:()=>ht,formatHotkey:()=>$,fuzzyMatch:()=>z,gemini:()=>Z,geminiEmbeddings:()=>It,grid:()=>ct,iconSvg:()=>ge,icons:()=>De,isEditable:()=>H,isMac:()=>R,list:()=>lt,matchItem:()=>te,matchesHotkey:()=>M,mcp:()=>Mt,memoryStorage:()=>ue,normalize:()=>S,ollama:()=>Pe,ollamaEmbeddings:()=>St,openai:()=>N,openaiCompatible:()=>Oe,openaiEmbeddings:()=>At,parseHotkey:()=>P,presets:()=>Je,proxy:()=>He,proxyEmbeddings:()=>Ct,rank:()=>O,renderMarkdown:()=>ne,resolveThemeVars:()=>xe,scopedStorage:()=>G,themeToCss:()=>Dt,version:()=>Gi});F();var at=()=>!!(document.modelContext??navigator.modelContext),he=class{constructor(e,t){u(this,"loader",t);u(this,"bar");u(this,"loading");u(this,"queue",[]);u(this,"config");u(this,"teardown",[]);u(this,"destroyed",!1);u(this,"removeLauncher");u(this,"launcherToken",0);if(this.config={...e},typeof document>"u")return;if(e.inline){this.load();return}this.updateLauncher(),e.webmcp&&at()&&this.load();let i=o=>{let a=this.config.hotkey===!1?[]:[].concat(this.config.hotkey??"mod+k"),c=H(o.target);!this.bar&&a.some(l=>M(o,l)&&(!c||Q(l)))&&(o.preventDefault(),this.open())},n=o=>{let a=o.target?.closest?.("[data-qikbar-open]");if(!a||this.bar)return;let c=a.getAttribute("data-qikbar-open");c&&c!==this.config.namespace||(o.preventDefault(),this.open({query:a.getAttribute("data-qikbar-query")??void 0}))};document.addEventListener("keydown",i,!0),document.addEventListener("click",n,!0),this.teardown.push(()=>{document.removeEventListener("keydown",i,!0),document.removeEventListener("click",n,!0)});let r=globalThis.requestIdleCallback;r?r(()=>{this.load()},{timeout:2500}):setTimeout(()=>{this.load()},1200)}updateLauncher(){this.removeLauncher?.(),this.removeLauncher=void 0;let e=++this.launcherToken;!this.config.launcher||this.config.inline||this.destroyed||Promise.resolve().then(()=>(Ce(),Ie)).then(({mountLauncher:t,resolveLauncher:i})=>{let n=i(this.config.launcher);if(!n||e!==this.launcherToken||this.destroyed)return;let r=this.config.labels?.openCommandBar??"Open command bar",o=()=>{this.destroyed||e!==this.launcherToken||(this.removeLauncher=t(n,r,()=>this.open(),this.config.nonce))};document.body?o():document.addEventListener("DOMContentLoaded",o,{once:!0})})}launcherReady(){return Promise.resolve().then(()=>(Ce(),Ie)).then(()=>new Promise(e=>setTimeout(e)))}stored(e){try{let i=(this.config.storage??globalThis.localStorage).getItem(`${this.config.namespace??"qikbar"}:${e}`);return i==null?void 0:JSON.parse(i)}catch{return}}preload(){return this.load().then(()=>{})}load(){return this.loading??(this.loading=this.loader().then(({Bar:e})=>{if(this.destroyed)throw new Error("destroyed");for(let n of this.teardown)n();this.teardown=[];let t=new e(this.config);this.bar=t;let i=this.queue;this.queue=[];for(let n of i)n(t);return t})),this.loading.catch(e=>{this.destroyed||console.error("[qikbar] failed to load UI",e)}),this.loading}run(e){this.bar?e(this.bar):(this.queue.push(e),this.load())}disposable(e){if(this.bar)return e(this.bar);let t,i=!1;return this.queue.push(n=>{i||(t=e(n))}),()=>{i=!0,t?.()}}get isOpen(){return this.bar?.isOpen??!1}get query(){return this.bar?.query??""}get ai(){return this.bar?.ai}open(e){this.run(t=>t.open(e))}close(){this.bar?.close()}toggle(){this.bar?this.bar.toggle():this.open()}register(e){return this.disposable(t=>t.register(e))}addSource(e){return this.disposable(t=>t.addSource(e))}use(e,t){return this.disposable(i=>i.use(e,t))}configure(e){this.config={...this.config,...e},this.bar&&this.bar.configure(e),("launcher"in e||"labels"in e)&&this.updateLauncher(),e.webmcp&&!this.bar&&at()&&this.load()}push(e){this.run(t=>t.push(e))}pop(){this.bar?.pop()}setQuery(e){this.run(t=>t.setQuery(e))}ask(e){this.run(t=>t.ask(e))}toast(e){if(this.bar)return this.bar.toast(e);let t,i=[];return this.run(n=>{t=n.toast(e);for(let r of i)r(t)}),{update:n=>t?t.update(n):i.push(r=>r.update(n)),hide:()=>t?t.hide():i.push(n=>n.hide())}}commands(){return this.bar?.commands()??[]}pins(){return this.bar?.pins()??this.stored("pins")??[]}pin(e,t){this.run(i=>i.pin(e,t))}aliases(){return this.bar?.aliases()??this.stored("aliases")??{}}setAlias(e,t){this.run(i=>i.setAlias(e,t))}on(e,t){return this.disposable(i=>i.on(e,t))}destroy(){this.destroyed=!0,this.launcherToken++,this.removeLauncher?.(),this.removeLauncher=void 0;for(let e of this.teardown)e();this.teardown=[],this.queue=[],this.bar?.destroy()}};pe();F();J();async function*gt(s){if(!s.body)return;let e=s.body.getReader(),t=new TextDecoder,i="";try{for(;;){let{value:n,done:r}=await e.read();if(r)break;i+=t.decode(n,{stream:!0});let o;for(;(o=i.indexOf(`
285
+ `))>=0;){let a=i.slice(0,o).replace(/\r$/,"");i=i.slice(o+1),yield a}}i+=t.decode(),i&&(yield i)}finally{e.releaseLock()}}async function*B(s){let e,t=[];for await(let i of gt(s))i===""?(t.length&&(yield{event:e,data:t.join(`
245
286
  `)}),e=void 0,t=[]):i.startsWith("data:")?t.push(i.slice(i[5]===" "?6:5)):i.startsWith("event:")&&(e=i.slice(6).trim());t.length&&(yield{event:e,data:t.join(`
246
- `)})}async function*st(s){for await(let e of nt(s))e.trim()&&(yield JSON.parse(e))}async function G(s,e){let t="";try{let i=await s.text();try{let r=JSON.parse(i);t=r?.error?.message??r?.message??r?.error??i}catch{t=i}}catch{}return new Error(`${e} ${s.status}: ${String(t||s.statusText).slice(0,300)}`)}var Wt=0,ot=()=>`call_${Date.now().toString(36)}${(Wt++).toString(36)}`;function at(s){if(!s.trim())return{args:{}};try{let e=JSON.parse(s);return e&&typeof e=="object"&&!Array.isArray(e)?{args:e}:{args:{},error:"Tool arguments must be a JSON object."}}catch{return{args:{},error:`Invalid JSON arguments: ${s.slice(0,200)}`}}}var Gt=/claude-(opus|sonnet|haiku|fable|mythos)-5|claude-opus-4-[5-8]/,Jt=/^claude-(opus-5|opus-5-5|sonnet-5-5|fable-5-1)$/;function J(s={}){let e=s.model??"claude-opus-5-5",t=(s.baseURL??"https://api.anthropic.com").replace(/\/$/,""),i=s.fetch??((...n)=>fetch(...n));function r(n){let o=[];for(let a of n)if(a.role==="user")o.push({role:"user",content:a.content});else if(a.role==="assistant")if(a.raw?.provider==="anthropic")o.push({role:"assistant",content:a.raw.data});else{let c=[];a.content&&c.push({type:"text",text:a.content});for(let l of a.toolCalls??[])c.push({type:"tool_use",id:l.id,name:l.name,input:l.args});o.push({role:"assistant",content:c.length?c:a.content||"\u2026"})}else{let c={type:"tool_result",tool_use_id:a.toolCallId,content:a.content,...a.isError?{is_error:!0}:{}},l=o[o.length-1];l?.role==="user"&&Array.isArray(l.content)&&l.content[0]?.type==="tool_result"?l.content.push(c):o.push({role:"user",content:[c]})}return o}return{id:"anthropic",model:e,async*stream(n){let o={"content-type":"application/json","anthropic-version":"2023-06-01",...s.headers};s.apiKey&&(o["x-api-key"]=s.apiKey,o["anthropic-dangerous-direct-browser-access"]="true");let a={model:e,max_tokens:n.maxTokens??s.maxTokens??16e3,stream:!0,messages:r(n.messages)};n.system&&(a.system=n.system),n.tools?.length&&(a.tools=n.tools.map(b=>({name:b.name,description:b.description,input_schema:b.parameters,eager_input_streaming:!0})));let c=s.effort===void 0?Gt.test(e)?"low":!1:s.effort;c&&(a.output_config={effort:c}),s.fallbacks!==!1&&Jt.test(e)&&!s.baseURL&&(a.fallbacks="default",o["anthropic-beta"]=[o["anthropic-beta"],"server-side-fallback-2026-07-01"].filter(Boolean).join(","));let l=await i(`${t}/v1/messages`,{method:"POST",headers:o,body:JSON.stringify(a),signal:n.signal});if(!l.ok)throw await G(l,"Anthropic");let h={},d,p="";for await(let b of le(l)){if(!b.data||b.data==="[DONE]")continue;let v=JSON.parse(b.data);switch(v.type){case"content_block_start":{let y={...v.content_block};y.type==="tool_use"&&(y._json=""),h[v.index]=y,y.type==="text"&&y.text&&(p+=y.text,yield{type:"text",text:y.text});break}case"content_block_delta":{let y=h[v.index],x=v.delta;if(!y)break;x.type==="text_delta"?(y.text=(y.text??"")+x.text,p+=x.text,yield{type:"text",text:x.text}):x.type==="input_json_delta"?y._json+=x.partial_json:x.type==="thinking_delta"?y.thinking=(y.thinking??"")+x.thinking:x.type==="signature_delta"&&(y.signature=x.signature);break}case"content_block_stop":{let y=h[v.index];if(y?.type==="tool_use"){let{args:x,error:A}=at(y._json);y.input=x,A&&(y._error=A),delete y._json}break}case"message_delta":v.delta?.stop_reason&&(d=v.delta.stop_reason);break;case"error":throw new Error(`Anthropic: ${v.error?.message??"stream error"}`)}}let g=Object.keys(h).map(Number).sort((b,v)=>b-v).map(b=>h[b]),f=[];if(d!=="max_tokens"&&d!=="refusal")for(let b of g){if(b.type!=="tool_use")continue;let v={id:b.id,name:b.name,args:b.input??{}};b._error&&(v.error=b._error),f.push(v),yield{type:"tool_call",call:v}}for(let b of g)delete b._error;d==="refusal"&&(yield{type:"error",error:"The model declined to answer this request."}),yield{type:"done",stopReason:d,message:{role:"assistant",content:p,toolCalls:f.length?f:void 0,raw:{provider:"anthropic",data:g}}}}}}function _(s={}){let e=s.model??"gpt-6-luna",t=(s.baseURL??"https://api.openai.com/v1").replace(/\/$/,""),i=s.fetch??((...n)=>fetch(...n));function r(n,o){let a=[];o&&a.push({role:"system",content:o});for(let c of n)c.role==="user"?a.push({role:"user",content:c.content}):c.role==="assistant"?a.push({role:"assistant",content:c.content||null,...c.toolCalls?.length?{tool_calls:c.toolCalls.map(l=>({id:l.id,type:"function",function:{name:l.name,arguments:JSON.stringify(l.args)}}))}:{}}):a.push({role:"tool",tool_call_id:c.toolCallId,content:c.content});return a}return{id:s.id??"openai",model:e,tools:s.tools??!0,async*stream(n){let o={model:e,stream:!0,messages:r(n.messages,n.system)},a=n.maxTokens??s.maxTokens;a&&(o.max_completion_tokens=a),n.tools?.length&&s.tools!==!1&&(o.tools=n.tools.map(g=>({type:"function",function:{name:g.name,description:g.description,parameters:g.parameters}})));let c=await i(`${t}/chat/completions`,{method:"POST",headers:{"content-type":"application/json",...s.apiKey?{authorization:`Bearer ${s.apiKey}`}:{},...s.headers},body:JSON.stringify(o),signal:n.signal});if(!c.ok)throw await G(c,s.id??"OpenAI");let l="",h,d=[];for await(let g of le(c)){if(!g.data||g.data==="[DONE]")continue;let f=JSON.parse(g.data);if(f.error)throw new Error(`${s.id??"OpenAI"}: ${f.error.message??f.error}`);let b=f.choices?.[0];if(!b)continue;let v=b.delta??{};typeof v.content=="string"&&v.content&&(l+=v.content,yield{type:"text",text:v.content});for(let y of v.tool_calls??[]){let x=y.index??0;d[x]??(d[x]={id:y.id??ot(),name:"",json:""}),y.id&&(d[x].id=y.id),y.function?.name&&(d[x].name+=y.function.name),y.function?.arguments&&(d[x].json+=y.function.arguments)}b.finish_reason&&(h=b.finish_reason)}let p=[];if(h!=="length"&&h!=="content_filter")for(let g of d.filter(Boolean)){let{args:f,error:b}=at(g.json),v={id:g.id,name:g.name,args:f,...b?{error:b}:{}};p.push(v),yield{type:"tool_call",call:v}}h==="content_filter"&&(yield{type:"error",error:"The response was blocked by the provider\u2019s content filter."}),yield{type:"done",stopReason:h,message:{role:"assistant",content:l,toolCalls:p.length?p:void 0}}}}}function Me(s){return _({id:"openai-compatible",...s})}function Ee(s={model:"llama3.2"}){return _({id:"ollama",baseURL:s.baseURL??"http://localhost:11434/v1",model:s.model,tools:s.tools})}function qe(s){let{additionalProperties:e,$schema:t,default:i,...r}=s,n={...r};return r.properties&&(n.properties=Object.fromEntries(Object.entries(r.properties).map(([o,a])=>[o,qe(a)]))),r.items&&(n.items=qe(r.items)),n}function Y(s={}){let e=s.model??"gemini-flash-latest",t=(s.baseURL??"https://generativelanguage.googleapis.com/v1beta").replace(/\/$/,""),i=s.fetch??((...n)=>fetch(...n));function r(n){let o=[];for(let a of n)if(a.role==="user")o.push({role:"user",parts:[{text:a.content}]});else if(a.role==="assistant")if(a.raw?.provider==="gemini")o.push({role:"model",parts:a.raw.data});else{let c=[];a.content&&c.push({text:a.content});for(let l of a.toolCalls??[])c.push({functionCall:{name:l.name,args:l.args}});o.push({role:"model",parts:c.length?c:[{text:""}]})}else{let c={functionResponse:{name:a.toolName??"tool",response:a.isError?{error:a.content}:{result:a.content}}},l=o[o.length-1];l?.role==="user"&&l.parts[0]?.functionResponse?l.parts.push(c):o.push({role:"user",parts:[c]})}return o}return{id:"gemini",model:e,async*stream(n){let o={contents:r(n.messages)};n.system&&(o.systemInstruction={parts:[{text:n.system}]}),n.tools?.length&&(o.tools=[{functionDeclarations:n.tools.map(g=>({name:g.name,description:g.description,...g.parameters?.properties&&Object.keys(g.parameters.properties).length?{parameters:qe(g.parameters)}:{}}))}]);let a=n.maxTokens??s.maxTokens;a&&(o.generationConfig={maxOutputTokens:a});let c=await i(`${t}/models/${encodeURIComponent(e)}:streamGenerateContent?alt=sse`,{method:"POST",headers:{"content-type":"application/json",...s.apiKey?{"x-goog-api-key":s.apiKey}:{},...s.headers},body:JSON.stringify(o),signal:n.signal});if(!c.ok)throw await G(c,"Gemini");let l="",h,d=[],p=[];for await(let g of le(c)){if(!g.data)continue;let f=JSON.parse(g.data);if(f.error)throw new Error(`Gemini: ${f.error.message}`);if(f.promptFeedback?.blockReason){yield{type:"error",error:`Blocked by Gemini (${f.promptFeedback.blockReason}).`};continue}let b=f.candidates?.[0];if(b){for(let v of b.content?.parts??[])if(v.functionCall){d.push(v);let y={id:v.functionCall.id??ot(),name:v.functionCall.name,args:v.functionCall.args??{}};p.push(y)}else if(typeof v.text=="string"){let y=d[d.length-1];!v.thought&&y&&typeof y.text=="string"&&!y.thought&&!y.thoughtSignature&&!v.thoughtSignature?y.text+=v.text:d.push({...v}),!v.thought&&v.text&&(l+=v.text,yield{type:"text",text:v.text})}else d.push(v);b.finishReason&&(h=b.finishReason)}}if(h!=="MAX_TOKENS")for(let g of p)yield{type:"tool_call",call:g};h==="SAFETY"&&(yield{type:"error",error:"The response was blocked by Gemini safety filters."}),yield{type:"done",stopReason:h,message:{role:"assistant",content:l,toolCalls:p.length&&h!=="MAX_TOKENS"?p:void 0,raw:{provider:"gemini",data:d}}}}}}var Te=Object.assign(function(){return{id:"browser",model:"on-device",tools:!1,async*stream(e){let t=globalThis.LanguageModel;if(!t)throw new Error("Built-in AI is not available in this browser.");let i=e.messages.filter(c=>c.role!=="tool"),r=i.pop(),n=[...e.system?[{role:"system",content:e.system}]:[],...i.map(c=>({role:c.role,content:c.content}))],o=await t.create({initialPrompts:n,signal:e.signal}),a="";try{let c=o.promptStreaming(r?.content??"",{signal:e.signal});for await(let l of c){let h=l.startsWith(a)&&a?l.slice(a.length):l;a+=h,h&&(yield{type:"text",text:h})}}finally{o.destroy?.()}yield{type:"done",message:{role:"assistant",content:a}}}}},{async isAvailable(){let s=globalThis.LanguageModel;if(!s?.availability)return!1;try{return await s.availability()!=="unavailable"}catch{return!1}}});function Ae(s){let e=typeof s=="string"?{url:s}:s,t=e.fetch??((...i)=>fetch(...i));return{id:"proxy",async*stream(i){let r=typeof e.headers=="function"?await e.headers():e.headers,n=await t(e.url,{method:"POST",headers:{"content-type":"application/json",accept:"application/x-ndjson",...r},credentials:e.credentials??"same-origin",body:JSON.stringify({messages:i.messages,system:i.system,tools:i.tools,maxTokens:i.maxTokens}),signal:i.signal});if(!n.ok)throw await G(n,"AI proxy");yield*st(n)}}}W();var lt={anthropic:"Anthropic (Claude)",openai:"OpenAI",gemini:"Google Gemini","openai-compatible":"OpenAI-compatible (OpenRouter, Groq, Ollama\u2026)"};function Ie(s,e){try{let t=s.getItem(e);return t?JSON.parse(t):void 0}catch{return}}var Se=Object.assign(function(e={}){let t=e.storage??P(),i=e.key??"qikbar:byok";return{id:"byok",get model(){return Ie(t,i)?.model},async*stream(r){let n=Ie(t,i);if(!n?.apiKey&&n?.vendor!=="openai-compatible"){yield{type:"error",error:"Add your AI API key first: search for \u201CAI Settings\u201D in the command bar."},yield{type:"done",message:{role:"assistant",content:""}};return}yield*(n.vendor==="anthropic"?J({apiKey:n.apiKey,model:n.model||void 0}):n.vendor==="gemini"?Y({apiKey:n.apiKey,model:n.model||void 0}):_({apiKey:n.apiKey||void 0,model:n.model||void 0,baseURL:n.baseURL||void 0})).stream(r)}}},{settings:Yt});function Yt(s={}){let e=s.storage??P(),t=s.key??"qikbar:byok",i=s.vendors??Object.keys(lt);return{name:"qikbar-ai-settings",title:"AI",icon:"key",commands:[{name:"settings",title:"AI Settings",subtitle:"Use your own API key",keywords:["api key","openai","anthropic","claude","gemini","model","byok"],icon:"key",view:()=>{let r=Ie(e,t);return{type:"form",title:"AI Settings",submitLabel:"Save",fields:[{name:"vendor",label:"Provider",type:"select",options:i.map(n=>({title:lt[n],value:n})),defaultValue:r?.vendor??i[0]},{name:"apiKey",label:"API key",type:"password",placeholder:"Stored only in this browser",defaultValue:r?.apiKey??"",description:"Your key never leaves your browser except to call the provider directly."},{name:"model",label:"Model",placeholder:"Leave empty for the default",defaultValue:r?.model??""},{name:"baseURL",label:"Base URL",placeholder:"Only for OpenAI-compatible APIs",defaultValue:r?.baseURL??""}],onSubmit(n,o){e.setItem(t,JSON.stringify(n)),o.toast({title:"AI settings saved",style:"success"})}}}},{name:"clear",title:"Remove AI API Key",icon:"trash",keywords:["byok","api key"],searchOnly:!0,async run(r){if(!await r.confirm({title:"Remove your API key?",destructive:!0,confirmLabel:"Remove"}))return!1;e.removeItem(t),r.toast({title:"API key removed",style:"success"})}}]}}function fi(s={}){return new se(s,()=>Promise.resolve().then(()=>(Lt(),Ct)))}var mi="0.1.0";fe();Ne();Oe();H();Ce();W();Ke();He();de();var Qe={};we(Qe,{aiActions:()=>qi,calculator:()=>xi,convert:()=>xe,evaluate:()=>ie,formatNumber:()=>re,page:()=>ki,shortcutLabel:()=>Ei,shortcuts:()=>Mi,themeSwitcher:()=>wi});oe();H();var Rt={pi:Math.PI,\u03C0:Math.PI,e:Math.E,tau:Math.PI*2,phi:(1+Math.sqrt(5))/2},gi={sqrt:Math.sqrt,cbrt:Math.cbrt,abs:Math.abs,round:(s,e=0)=>Math.round(s*10**e)/10**e,floor:Math.floor,ceil:Math.ceil,sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,log:Math.log10,log2:Math.log2,ln:Math.log,exp:Math.exp,min:Math.min,max:Math.max};function bi(s){let e=[],t=0,i=s.replace(/×/g,"*").replace(/÷/g,"/").replace(/−/g,"-");for(;t<i.length;){let r=i[t];if(/\s/.test(r)){t++;continue}let n=i.slice(t).match(/^(\d[\d_]*(\.\d+)?|\.\d+)(e[+-]?\d+)?/i);if(n){e.push({t:"num",v:parseFloat(n[0].replace(/_/g,""))}),t+=n[0].length;continue}if(i.startsWith("**",t)){e.push({t:"op",v:"^"}),t+=2;continue}if("+-*/^".includes(r)){e.push({t:"op",v:r}),t++;continue}if(r==="%"){e.push({t:"%"}),t++;continue}if(r==="("||r===")"||r===","){e.push({t:r}),t++;continue}let o=i.slice(t).match(/^[a-zπ][a-z0-9_]*/i);if(o){e.push({t:"id",v:o[0].toLowerCase()}),t+=o[0].length;continue}throw new Error(`Unexpected "${r}"`)}return e}var Ue=class{constructor(e){m(this,"tokens",e);m(this,"i",0)}peek(){return this.tokens[this.i]}next(){return this.tokens[this.i++]}parse(){let e=this.expr();if(this.i<this.tokens.length)throw new Error("Unexpected input");return e}expr(){let e=this.term();for(;;){let t=this.peek();if(t?.t==="op"&&(t.v==="+"||t.v==="-")){this.next();let i=this.i,r=this.term();this.isBarePercent(i)&&(r=e*r),e=t.v==="+"?e+r:e-r}else return e}}isBarePercent(e){return this.tokens[e]?.t==="num"&&this.tokens[e+1]?.t==="%"&&this.i===e+2}term(){let e=this.power();for(;;){let t=this.peek();if(t?.t==="op"&&(t.v==="*"||t.v==="/")){this.next();let i=this.power();e=t.v==="*"?e*i:e/i}else if(t&&(t.t==="num"||t.t==="("||t.t==="id"&&t.v!=="of"))e*=this.power();else if(t?.t==="id"&&t.v==="of")this.next(),e*=this.power();else return e}}power(){let e=this.unary(),t=this.peek();return t?.t==="op"&&t.v==="^"?(this.next(),e**this.power()):e}unary(){let e=this.peek();if(e?.t==="op"&&(e.v==="-"||e.v==="+")){this.next();let t=this.unary();return e.v==="-"?-t:t}return this.postfix()}postfix(){let e=this.primary();for(;this.peek()?.t==="%";)this.next(),e/=100;return e}primary(){let e=this.next();if(!e)throw new Error("Unexpected end");if(e.t==="num")return e.v;if(e.t==="("){let t=this.expr();if(this.next()?.t!==")")throw new Error("Missing )");return t}if(e.t==="id"){if(e.v in Rt)return Rt[e.v];let t=gi[e.v];if(t){if(this.peek()?.t!=="(")return t(this.power());this.next();let i=[this.expr()];for(;this.peek()?.t===",";)this.next(),i.push(this.expr());if(this.next()?.t!==")")throw new Error("Missing )");return t(...i)}throw new Error(`Unknown "${e.v}"`)}throw new Error("Unexpected token")}};function ie(s){let e=new Ue(bi(s)).parse();if(!Number.isFinite(e))throw new Error("Not a finite number");return e}var w=(s,e,t,...i)=>i.map(r=>[r,{dim:s,factor:e,label:t}]),Ot=new Map([...w("length",1,"m","m","meter","meters","metre","metres"),...w("length",1e3,"km","km","kilometer","kilometers","kilometre","kilometres"),...w("length",.01,"cm","cm","centimeter","centimeters"),...w("length",.001,"mm","mm","millimeter","millimeters"),...w("length",1609.344,"mi","mi","mile","miles"),...w("length",.3048,"ft","ft","foot","feet"),...w("length",.0254,"in","inch","inches"),...w("length",.9144,"yd","yd","yard","yards"),...w("mass",1,"kg","kg","kilogram","kilograms","kilo","kilos"),...w("mass",.001,"g","g","gram","grams"),...w("mass",.45359237,"lb","lb","lbs","pound","pounds"),...w("mass",.028349523125,"oz","oz","ounce","ounces"),...w("mass",6.35029318,"st","st","stone","stones"),...w("data",1,"B","b","byte","bytes"),...w("data",1024,"KB","kb","kib","kilobyte","kilobytes"),...w("data",1024**2,"MB","mb","mib","megabyte","megabytes"),...w("data",1024**3,"GB","gb","gib","gigabyte","gigabytes"),...w("data",1024**4,"TB","tb","tib","terabyte","terabytes"),...w("time",1,"s","s","sec","second","seconds"),...w("time",60,"min","min","mins","minute","minutes"),...w("time",3600,"h","h","hr","hrs","hour","hours"),...w("time",86400,"d","d","day","days"),...w("time",604800,"wk","wk","week","weeks"),...w("volume",1,"L","l","liter","liters","litre","litres"),...w("volume",.001,"mL","ml","milliliter","milliliters"),...w("volume",3.785411784,"gal","gal","gallon","gallons"),...w("volume",.2365882365,"cup","cup","cups"),...w("temp",1,"\xB0C","c","\xB0c","celsius"),...w("temp",1,"\xB0F","f","\xB0f","fahrenheit"),...w("temp",1,"K","k","kelvin")]);function yi(s,e){return e==="\xB0C"?s+273.15:e==="\xB0F"?(s-32)*5/9+273.15:s}function vi(s,e){return e==="\xB0C"?s-273.15:e==="\xB0F"?(s-273.15)*9/5+32:s}function xe(s){let e=s.trim().match(/^(.+?)\s*([a-z°]+)\s+(?:in|to|as|=)\s+([a-z°]+)$/i);if(!e)return;let t=Ot.get(e[2].toLowerCase()),i=Ot.get(e[3].toLowerCase());if(!t||!i||t.dim!==i.dim)return;let r=ie(e[1]);return t.dim==="temp"?{value:vi(yi(r,t.label),i.label),unit:i.label}:{value:r*t.factor/i.factor,unit:i.label}}function re(s){return Math.abs(s)>=1e15||Math.abs(s)<1e-6&&s!==0?s.toExponential(6).replace(/\.?0+e/,"e"):(Math.round(s*1e10)/1e10).toLocaleString(void 0,{maximumFractionDigits:10})}function $t(s){let e=s.trim();return!e||!/\d|pi|π/.test(e)||/^\d+(\.\d+)?$/.test(e)?!1:/[+\-*/^%×÷()]|\b(in|to)\b|\b(sqrt|sin|cos|tan|log|ln|abs|round|of)\b/i.test(e)}function xi(){return{name:"calculator",title:"Calculator",icon:"calculator",description:"Evaluate math and convert units as you type.",sources:[{id:"calculator",title:"Calculator",position:"top",debounce:0,search({query:s}){let e=s.trim().replace(/^=/,"");if(!$t(e))return[];let t;try{let r=xe(e);t=r?`${re(r.value)} ${r.unit}`:re(ie(e))}catch{return[]}let i=t.replace(/,/g,"");return[{id:"calculator:result",title:t,subtitle:`= ${e}`,icon:"calculator",noHistory:!0,accessories:[{text:"Copy",kbd:"enter"}],actions:[M.copy(i,{title:"Copy Result",shortcut:void 0}),M.copy(`${e} = ${t}`,{title:"Copy Equation",shortcut:"mod+shift+c"})]}]}}]}}function wi(s={}){let e=s.storageKey??"theme",t=s.set??(n=>{let o=n==="dark"||n==="system"&&matchMedia("(prefers-color-scheme: dark)").matches,a=document.documentElement;a.classList.toggle("dark",o),a.classList.toggle("light",!o),a.style.colorScheme=o?"dark":"light";try{n==="system"?localStorage.removeItem(e):localStorage.setItem(e,n)}catch{}}),i=()=>document.documentElement.classList.contains("dark")||document.documentElement.dataset.theme==="dark",r=(n,o)=>a=>{t(n),a.toast({title:o,style:"success",duration:1500})};return{name:"theme",title:"Appearance",icon:"palette",commands:[{name:"toggle",title:"Toggle Dark Mode",icon:"moon",keywords:["theme","light","dark","appearance","night"],shortcut:s.shortcut===!1?void 0:s.shortcut??"mod+shift+l",run:n=>r(i()?"light":"dark",i()?"Light mode":"Dark mode")(n)},{name:"light",title:"Use Light Theme",icon:"sun",keywords:["theme","appearance"],searchOnly:!0,run:r("light","Light mode")},{name:"dark",title:"Use Dark Theme",icon:"moon",keywords:["theme","appearance"],searchOnly:!0,run:r("dark","Dark mode")},{name:"system",title:"Use System Theme",icon:"monitor",keywords:["theme","appearance","auto"],searchOnly:!0,run:r("system","System theme")}]}}function ki(s={}){let e=s.headings??"h1[id], h2[id], h3[id]",t=(i,r,n,o,a={})=>({name:i,title:r,icon:n,searchOnly:!0,run:async c=>{await o(c)},...a});return{name:"page",title:"Page",icon:"file",commands:[t("back","Go Back","arrow-left",()=>history.back(),{keywords:["history","previous"]}),t("forward","Go Forward","arrow-right",()=>history.forward(),{keywords:["history","next"]}),t("reload","Reload Page","refresh",()=>location.reload(),{keywords:["refresh"]}),t("copy-url","Copy Page URL","link",async i=>{let r=await i.copy(location.href);i.toast({title:r?"Copied page URL":"Copy failed",style:r?"success":"failure"})},{keywords:["link","share","address"]}),t("top","Scroll to Top","arrow-up-right",()=>window.scrollTo({top:0,behavior:"smooth"})),t("bottom","Scroll to Bottom","chevron-down",()=>window.scrollTo({top:document.documentElement.scrollHeight,behavior:"smooth"})),t("print","Print Page","file-text",()=>setTimeout(()=>window.print(),150)),t("share","Share Page\u2026","send",()=>navigator.share?.({title:document.title,url:location.href}),{when:()=>typeof navigator<"u"&&"share"in navigator})],sources:e?[{id:"page-headings",title:"On This Page",debounce:0,filter:!0,limit:6,search(){let i=new Set;return[...document.querySelectorAll(e)].filter(r=>!r.closest(".qb-root")&&r.id&&!i.has(r.id)&&i.add(r.id)).map(r=>({id:`heading:${r.id}`,title:(r.textContent??"").replace(/\s+/g," ").trim(),subtitle:`#${r.id}`,icon:"hash",noHistory:!0,run:n=>{n.close(),history.replaceState(null,"",`#${r.id}`),r.scrollIntoView({behavior:"smooth",block:"start"})}}))}}]:[]}}function Ht(s=16e3){return(document.querySelector("main, [role=main], article")??document.body).innerText.replace(/\n{3,}/g,`
287
+ `)})}async function*bt(s){for await(let e of gt(s))e.trim()&&(yield JSON.parse(e))}async function Y(s,e){let t="";try{let i=await s.text();try{let n=JSON.parse(i);t=n?.error?.message??n?.message??n?.error??i}catch{t=i}}catch{}return new Error(`${e} ${s.status}: ${String(t||s.statusText).slice(0,300)}`)}var Ti=0,yt=()=>`call_${Date.now().toString(36)}${(Ti++).toString(36)}`;function vt(s){if(!s.trim())return{args:{}};try{let e=JSON.parse(s);return e&&typeof e=="object"&&!Array.isArray(e)?{args:e}:{args:{},error:"Tool arguments must be a JSON object."}}catch{return{args:{},error:`Invalid JSON arguments: ${s.slice(0,200)}`}}}var Ei=/claude-(opus|sonnet|haiku|fable|mythos)-5|claude-opus-4-[5-8]/,Mi=/^claude-(opus-5|opus-5-5|sonnet-5-5|fable-5-1)$/;function X(s={}){let e=s.model??"claude-opus-5-5",t=(s.baseURL??"https://api.anthropic.com").replace(/\/$/,""),i=s.fetch??((...r)=>fetch(...r));function n(r){let o=[];for(let a of r)if(a.role==="user")o.push({role:"user",content:a.content});else if(a.role==="assistant")if(a.raw?.provider==="anthropic")o.push({role:"assistant",content:a.raw.data});else{let c=[];a.content&&c.push({type:"text",text:a.content});for(let l of a.toolCalls??[])c.push({type:"tool_use",id:l.id,name:l.name,input:l.args});o.push({role:"assistant",content:c.length?c:a.content||"\u2026"})}else{let c={type:"tool_result",tool_use_id:a.toolCallId,content:a.content,...a.isError?{is_error:!0}:{}},l=o[o.length-1];l?.role==="user"&&Array.isArray(l.content)&&l.content[0]?.type==="tool_result"?l.content.push(c):o.push({role:"user",content:[c]})}return o}return{id:"anthropic",model:e,async*stream(r){let o={"content-type":"application/json","anthropic-version":"2023-06-01",...s.headers};s.apiKey&&(o["x-api-key"]=s.apiKey,o["anthropic-dangerous-direct-browser-access"]="true");let a={model:e,max_tokens:r.maxTokens??s.maxTokens??16e3,stream:!0,messages:n(r.messages)};r.system&&(a.system=r.system),r.tools?.length&&(a.tools=r.tools.map(p=>({name:p.name,description:p.description,input_schema:p.parameters,eager_input_streaming:!0})));let c=s.effort===void 0?Ei.test(e)?"low":!1:s.effort;c&&(a.output_config={effort:c}),s.fallbacks!==!1&&Mi.test(e)&&!s.baseURL&&(a.fallbacks="default",o["anthropic-beta"]=[o["anthropic-beta"],"server-side-fallback-2026-07-01"].filter(Boolean).join(","));let l=await i(`${t}/v1/messages`,{method:"POST",headers:o,body:JSON.stringify(a),signal:r.signal});if(!l.ok)throw await Y(l,"Anthropic");let d={},h,b="";for await(let p of B(l)){if(!p.data||p.data==="[DONE]")continue;let g=JSON.parse(p.data);switch(g.type){case"content_block_start":{let y={...g.content_block};y.type==="tool_use"&&(y._json=""),d[g.index]=y,y.type==="text"&&y.text&&(b+=y.text,yield{type:"text",text:y.text});break}case"content_block_delta":{let y=d[g.index],x=g.delta;if(!y)break;x.type==="text_delta"?(y.text=(y.text??"")+x.text,b+=x.text,yield{type:"text",text:x.text}):x.type==="input_json_delta"?y._json+=x.partial_json:x.type==="thinking_delta"?y.thinking=(y.thinking??"")+x.thinking:x.type==="signature_delta"&&(y.signature=x.signature);break}case"content_block_stop":{let y=d[g.index];if(y?.type==="tool_use"){let{args:x,error:w}=vt(y._json);y.input=x,w&&(y._error=w),delete y._json}break}case"message_delta":g.delta?.stop_reason&&(h=g.delta.stop_reason);break;case"error":throw new Error(`Anthropic: ${g.error?.message??"stream error"}`)}}let v=Object.keys(d).map(Number).sort((p,g)=>p-g).map(p=>d[p]),m=[];if(h!=="max_tokens"&&h!=="refusal")for(let p of v){if(p.type!=="tool_use")continue;let g={id:p.id,name:p.name,args:p.input??{}};p._error&&(g.error=p._error),m.push(g),yield{type:"tool_call",call:g}}for(let p of v)delete p._error;h==="refusal"&&(yield{type:"error",error:"The model declined to answer this request."}),yield{type:"done",stopReason:h,message:{role:"assistant",content:b,toolCalls:m.length?m:void 0,raw:{provider:"anthropic",data:v}}}}}}function N(s={}){let e=s.model??"gpt-6-luna",t=(s.baseURL??"https://api.openai.com/v1").replace(/\/$/,""),i=s.fetch??((...r)=>fetch(...r));function n(r,o){let a=[];o&&a.push({role:"system",content:o});for(let c of r)c.role==="user"?a.push({role:"user",content:c.content}):c.role==="assistant"?a.push({role:"assistant",content:c.content||null,...c.toolCalls?.length?{tool_calls:c.toolCalls.map(l=>({id:l.id,type:"function",function:{name:l.name,arguments:JSON.stringify(l.args)}}))}:{}}):a.push({role:"tool",tool_call_id:c.toolCallId,content:c.content});return a}return{id:s.id??"openai",model:e,tools:s.tools??!0,async*stream(r){let o={model:e,stream:!0,messages:n(r.messages,r.system)},a=r.maxTokens??s.maxTokens;a&&(o.max_completion_tokens=a),r.tools?.length&&s.tools!==!1&&(o.tools=r.tools.map(v=>({type:"function",function:{name:v.name,description:v.description,parameters:v.parameters}})));let c=await i(`${t}/chat/completions`,{method:"POST",headers:{"content-type":"application/json",...s.apiKey?{authorization:`Bearer ${s.apiKey}`}:{},...s.headers},body:JSON.stringify(o),signal:r.signal});if(!c.ok)throw await Y(c,s.id??"OpenAI");let l="",d,h=[];for await(let v of B(c)){if(!v.data||v.data==="[DONE]")continue;let m=JSON.parse(v.data);if(m.error)throw new Error(`${s.id??"OpenAI"}: ${m.error.message??m.error}`);let p=m.choices?.[0];if(!p)continue;let g=p.delta??{};typeof g.content=="string"&&g.content&&(l+=g.content,yield{type:"text",text:g.content});for(let y of g.tool_calls??[]){let x=y.index??0;h[x]??(h[x]={id:y.id??yt(),name:"",json:""}),y.id&&(h[x].id=y.id),y.function?.name&&(h[x].name+=y.function.name),y.function?.arguments&&(h[x].json+=y.function.arguments)}p.finish_reason&&(d=p.finish_reason)}let b=[];if(d!=="length"&&d!=="content_filter")for(let v of h.filter(Boolean)){let{args:m,error:p}=vt(v.json),g={id:v.id,name:v.name,args:m,...p?{error:p}:{}};b.push(g),yield{type:"tool_call",call:g}}d==="content_filter"&&(yield{type:"error",error:"The response was blocked by the provider\u2019s content filter."}),yield{type:"done",stopReason:d,message:{role:"assistant",content:l,toolCalls:b.length?b:void 0}}}}}function Oe(s){return N({id:"openai-compatible",...s})}function Pe(s={model:"llama3.2"}){return N({id:"ollama",baseURL:s.baseURL??"http://localhost:11434/v1",model:s.model,tools:s.tools})}function Re(s){let{additionalProperties:e,$schema:t,default:i,...n}=s,r={...n};return n.properties&&(r.properties=Object.fromEntries(Object.entries(n.properties).map(([o,a])=>[o,Re(a)]))),n.items&&(r.items=Re(n.items)),r}function Z(s={}){let e=s.model??"gemini-flash-latest",t=(s.baseURL??"https://generativelanguage.googleapis.com/v1beta").replace(/\/$/,""),i=s.fetch??((...r)=>fetch(...r));function n(r){let o=[];for(let a of r)if(a.role==="user")o.push({role:"user",parts:[{text:a.content}]});else if(a.role==="assistant")if(a.raw?.provider==="gemini")o.push({role:"model",parts:a.raw.data});else{let c=[];a.content&&c.push({text:a.content});for(let l of a.toolCalls??[])c.push({functionCall:{name:l.name,args:l.args}});o.push({role:"model",parts:c.length?c:[{text:""}]})}else{let c={functionResponse:{name:a.toolName??"tool",response:a.isError?{error:a.content}:{result:a.content}}},l=o[o.length-1];l?.role==="user"&&l.parts[0]?.functionResponse?l.parts.push(c):o.push({role:"user",parts:[c]})}return o}return{id:"gemini",model:e,async*stream(r){let o={contents:n(r.messages)};r.system&&(o.systemInstruction={parts:[{text:r.system}]}),r.tools?.length&&(o.tools=[{functionDeclarations:r.tools.map(v=>({name:v.name,description:v.description,...v.parameters?.properties&&Object.keys(v.parameters.properties).length?{parameters:Re(v.parameters)}:{}}))}]);let a=r.maxTokens??s.maxTokens;a&&(o.generationConfig={maxOutputTokens:a});let c=await i(`${t}/models/${encodeURIComponent(e)}:streamGenerateContent?alt=sse`,{method:"POST",headers:{"content-type":"application/json",...s.apiKey?{"x-goog-api-key":s.apiKey}:{},...s.headers},body:JSON.stringify(o),signal:r.signal});if(!c.ok)throw await Y(c,"Gemini");let l="",d,h=[],b=[];for await(let v of B(c)){if(!v.data)continue;let m=JSON.parse(v.data);if(m.error)throw new Error(`Gemini: ${m.error.message}`);if(m.promptFeedback?.blockReason){yield{type:"error",error:`Blocked by Gemini (${m.promptFeedback.blockReason}).`};continue}let p=m.candidates?.[0];if(p){for(let g of p.content?.parts??[])if(g.functionCall){h.push(g);let y={id:g.functionCall.id??yt(),name:g.functionCall.name,args:g.functionCall.args??{}};b.push(y)}else if(typeof g.text=="string"){let y=h[h.length-1];!g.thought&&y&&typeof y.text=="string"&&!y.thought&&!y.thoughtSignature&&!g.thoughtSignature?y.text+=g.text:h.push({...g}),!g.thought&&g.text&&(l+=g.text,yield{type:"text",text:g.text})}else h.push(g);p.finishReason&&(d=p.finishReason)}}if(d!=="MAX_TOKENS")for(let v of b)yield{type:"tool_call",call:v};d==="SAFETY"&&(yield{type:"error",error:"The response was blocked by Gemini safety filters."}),yield{type:"done",stopReason:d,message:{role:"assistant",content:l,toolCalls:b.length&&d!=="MAX_TOKENS"?b:void 0,raw:{provider:"gemini",data:h}}}}}}var $e=Object.assign(function(){return{id:"browser",model:"on-device",tools:!1,async*stream(e){let t=globalThis.LanguageModel;if(!t)throw new Error("Built-in AI is not available in this browser.");let i=e.messages.filter(c=>c.role!=="tool"),n=i.pop(),r=[...e.system?[{role:"system",content:e.system}]:[],...i.map(c=>({role:c.role,content:c.content}))],o=await t.create({initialPrompts:r,signal:e.signal}),a="";try{let c=o.promptStreaming(n?.content??"",{signal:e.signal});for await(let l of c){let d=l.startsWith(a)&&a?l.slice(a.length):l;a+=d,d&&(yield{type:"text",text:d})}}finally{o.destroy?.()}yield{type:"done",message:{role:"assistant",content:a}}}}},{async isAvailable(){let s=globalThis.LanguageModel;if(!s?.availability)return!1;try{return await s.availability()!=="unavailable"}catch{return!1}}});function He(s){let e=typeof s=="string"?{url:s}:s,t=e.fetch??((...i)=>fetch(...i));return{id:"proxy",async*stream(i){let n=typeof e.headers=="function"?await e.headers():e.headers,r=await t(e.url,{method:"POST",headers:{"content-type":"application/json",accept:"application/x-ndjson",...n},credentials:e.credentials??"same-origin",body:JSON.stringify({messages:i.messages,system:i.system,tools:i.tools,maxTokens:i.maxTokens}),signal:i.signal});if(!r.ok)throw await Y(r,"AI proxy");yield*bt(r)}}}J();var xt={anthropic:"Anthropic (Claude)",openai:"OpenAI",gemini:"Google Gemini","openai-compatible":"OpenAI-compatible (OpenRouter, Groq, Ollama\u2026)"};function Fe(s,e){try{let t=s.getItem(e);return t?JSON.parse(t):void 0}catch{return}}var _e=Object.assign(function(e={}){let t=e.storage??_(),i=e.key??"qikbar:byok";return{id:"byok",get model(){return Fe(t,i)?.model},async*stream(n){let r=Fe(t,i);if(!r?.apiKey&&r?.vendor!=="openai-compatible"){yield{type:"error",error:"Add your AI API key first: search for \u201CAI Settings\u201D in the command bar."},yield{type:"done",message:{role:"assistant",content:""}};return}yield*(r.vendor==="anthropic"?X({apiKey:r.apiKey,model:r.model||void 0}):r.vendor==="gemini"?Z({apiKey:r.apiKey,model:r.model||void 0}):N({apiKey:r.apiKey||void 0,model:r.model||void 0,baseURL:r.baseURL||void 0})).stream(n)}}},{settings:Ai});function Ai(s={}){let e=s.storage??_(),t=s.key??"qikbar:byok",i=s.vendors??Object.keys(xt);return{name:"qikbar-ai-settings",title:"AI",icon:"key",commands:[{name:"settings",title:"AI Settings",subtitle:"Use your own API key",keywords:["api key","openai","anthropic","claude","gemini","model","byok"],icon:"key",view:()=>{let n=Fe(e,t);return{type:"form",title:"AI Settings",submitLabel:"Save",fields:[{name:"vendor",label:"Provider",type:"select",options:i.map(r=>({title:xt[r],value:r})),defaultValue:n?.vendor??i[0]},{name:"apiKey",label:"API key",type:"password",placeholder:"Stored only in this browser",defaultValue:n?.apiKey??"",description:"Your key never leaves your browser except to call the provider directly."},{name:"model",label:"Model",placeholder:"Leave empty for the default",defaultValue:n?.model??""},{name:"baseURL",label:"Base URL",placeholder:"Only for OpenAI-compatible APIs",defaultValue:n?.baseURL??""}],onSubmit(r,o){e.setItem(t,JSON.stringify(r)),o.toast({title:"AI settings saved",style:"success"})}}}},{name:"clear",title:"Remove AI API Key",icon:"trash",keywords:["byok","api key"],searchOnly:!0,async run(n){if(!await n.confirm({title:"Remove your API key?",destructive:!0,confirmLabel:"Remove"}))return!1;e.removeItem(t),n.toast({title:"API key removed",style:"success"})}}]}}var Et="2025-06-18",C=class extends Error{constructor(t,i){super(t);u(this,"code",i);this.name="MCPError"}},Ne=class{constructor(e){u(this,"options",e);u(this,"session");u(this,"protocol",Et);u(this,"ready");u(this,"negotiated",!1);u(this,"nextId",1);u(this,"serverInfo")}async headers(){let e=this.options.headers,t=typeof e=="function"?await e():e??{};return{"content-type":"application/json",accept:"application/json, text/event-stream",...this.session?{"mcp-session-id":this.session}:{},...this.negotiated?{"mcp-protocol-version":this.protocol}:{},...t}}async post(e,t,i){let r=await(this.options.fetch??globalThis.fetch)(this.options.url,{method:"POST",headers:await this.headers(),body:JSON.stringify(e),signal:t,credentials:this.options.credentials??"same-origin"}),o=r.headers.get("mcp-session-id");if(o&&(this.session=o),r.status===404&&this.session&&i!=null)throw this.session=void 0,this.ready=void 0,this.negotiated=!1,new C("MCP session expired",404);if(!r.ok&&r.status!==202){let d=await r.text().catch(()=>"");throw new C(`MCP server responded ${r.status}${d?`: ${d.slice(0,200)}`:""}`,r.status)}if(i==null||r.status===202)return;if((r.headers.get("content-type")??"").includes("text/event-stream")){for await(let d of B(r)){if(!d.data)continue;let h;try{h=JSON.parse(d.data)}catch{continue}for(let b of Array.isArray(h)?h:[h])if(b.id===i)return b}throw new C("MCP stream ended without a response")}let c=await r.json(),l=Array.isArray(c)?c:[c];return l.find(d=>d.id===i)??l[0]}async request(e,t,i,n=!0){e!=="initialize"&&await this.connect(i);let r=this.nextId++,o;try{o=await this.post({jsonrpc:"2.0",id:r,method:e,...t?{params:t}:{}},i,r)}catch(a){if(n&&a instanceof C&&a.code===404&&e!=="initialize")return this.request(e,t,i,!1);throw a}if(!o)throw new C(`No response to ${e}`);if(o.error)throw new C(o.error.message,o.error.code);return o.result}connect(e){return this.ready??(this.ready=(async()=>{let t=await this.request("initialize",{protocolVersion:Et,capabilities:{},clientInfo:{name:"qikbar",version:"0.2.1"}},e);t?.protocolVersion&&(this.protocol=t.protocolVersion),this.negotiated=!0,this.serverInfo=t?.serverInfo,await this.post({jsonrpc:"2.0",method:"notifications/initialized"},e)})()),this.ready.catch(()=>{this.ready=void 0}),this.ready}async listTools(e){let t=[],i;for(let n=0;n<20;n++){let r=await this.request("tools/list",i?{cursor:i}:void 0,e);if(t.push(...r?.tools??[]),i=r?.nextCursor,!i)break}return t}async callTool(e,t,i){let n=await this.request("tools/call",{name:e,arguments:t},i),r=Ii(n?.content,n?.structuredContent);if(n?.isError)throw new C(r||`Tool ${e} failed`);return r}async close(){if(!this.session)return;let e=this.options.fetch??globalThis.fetch;try{await e(this.options.url,{method:"DELETE",headers:await this.headers(),credentials:this.options.credentials??"same-origin"})}catch{}this.session=void 0,this.ready=void 0,this.negotiated=!1}};function Ii(s,e){let t=[];for(let i of s??[])i.type==="text"&&i.text!=null?t.push(i.text):i.type==="resource"&&i.resource?.text?t.push(i.resource.text):i.type==="resource_link"?t.push(`[${i.name??i.uri}](${i.uri})`):(i.type==="image"||i.type==="audio")&&t.push(`[${i.type}${i.mimeType?` ${i.mimeType}`:""}]`);return!t.length&&e!==void 0?JSON.stringify(e):t.join(`
288
+
289
+ `)}function Ci(s){try{return(new URL(s,typeof location<"u"?location.href:"http://localhost").host.replace(/^(www|api|mcp)\./,"").split(".")[0]||"mcp").replace(/[^a-zA-Z0-9_-]/g,"_")}catch{return"mcp"}}function Mt(s){let e=new Ne(s),t=(s.name??Ci(s.url)).replace(/[^a-zA-Z0-9_-]/g,"_"),i,n=s.ttl??5*6e4,r=a=>{let c=s.confirm;return typeof c=="function"?c(a):typeof c=="boolean"?c:a.annotations?.readOnlyHint!==!0},o=async a=>(await e.listTools(a)).filter(l=>(!s.include||s.include.includes(l.name))&&!s.exclude?.includes(l.name)).map(l=>({name:l.name,description:l.description||l.annotations?.title||l.title||l.name,parameters:l.inputSchema??{type:"object",properties:{}},confirm:r(l)?()=>`Allow ${l.annotations?.title??l.title??l.name} (${t})?`:!1,run:(d,h)=>e.callTool(l.name,d??{},h.signal)}));return{name:t,client:e,refresh(){i=void 0},tools(a){if(!i||Date.now()-i.at>n){let c={at:Date.now(),tools:o(a)};i=c,c.tools.catch(()=>{i===c&&(i=void 0)})}return i.tools}}}async function fe(s,e,t,i,n=globalThis.fetch){let r=await n(s,{method:"POST",headers:{"content-type":"application/json",...t},body:JSON.stringify(e),signal:i});if(!r.ok){let o=await r.text().catch(()=>"");throw new Error(`Embeddings request failed (${r.status})${o?`: ${o.slice(0,200)}`:""}`)}return r.json()}function At(s={}){let e=(s.baseURL??"https://api.openai.com/v1").replace(/\/$/,""),t=s.dimensions===void 0?256:s.dimensions;return async(i,{signal:n})=>(await fe(`${e}/embeddings`,{model:s.model??"text-embedding-3-small",input:i,...t?{dimensions:t}:{}},{...s.apiKey?{authorization:`Bearer ${s.apiKey}`}:{},...s.headers},n,s.fetch)).data.sort((o,a)=>o.index-a.index).map(o=>o.embedding)}function St(s={}){let e=(s.host??"http://localhost:11434").replace(/\/$/,"");return async(t,{signal:i})=>(await fe(`${e}/api/embed`,{model:s.model??"nomic-embed-text",input:t},{},i,s.fetch)).embeddings}function It(s){let e=s.model??"gemini-embedding-001";return async(t,{signal:i})=>(await fe(`https://generativelanguage.googleapis.com/v1beta/models/${e}:batchEmbedContents`,{requests:t.map(r=>({model:`models/${e}`,content:{parts:[{text:r}]},outputDimensionality:s.dimensions??256}))},{"x-goog-api-key":s.apiKey},i,s.fetch)).embeddings.map(r=>r.values)}function Ct(s){return async(e,{signal:t})=>(await fe(s.url,{texts:e},s.headers??{},t,s.fetch)).embeddings}function Lt(s,e=2e3){let t=new Map;return async(i,n)=>{let r=[...new Set(i.filter(o=>!t.has(o)))];if(r.length){let o=await s(r,n);for(r.forEach((a,c)=>{o[c]&&t.set(a,o[c])});t.size>e;)t.delete(t.keys().next().value)}return i.map(o=>t.get(o)??[])}}function Qi(s={}){return new he(s,()=>Promise.resolve().then(()=>(ri(),ni)))}var Gi="0.2.1";we();Ye();je();F();ze();J();Ge();Be();be();var nt={};de(nt,{aiActions:()=>rn,calculator:()=>en,convert:()=>Se,evaluate:()=>oe,formatNumber:()=>ae,page:()=>nn,shortcutLabel:()=>on,shortcuts:()=>sn,themeSwitcher:()=>tn});pe();F();var si={pi:Math.PI,\u03C0:Math.PI,e:Math.E,tau:Math.PI*2,phi:(1+Math.sqrt(5))/2},Ji={sqrt:Math.sqrt,cbrt:Math.cbrt,abs:Math.abs,round:(s,e=0)=>Math.round(s*10**e)/10**e,floor:Math.floor,ceil:Math.ceil,sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,log:Math.log10,log2:Math.log2,ln:Math.log,exp:Math.exp,min:Math.min,max:Math.max};function Yi(s){let e=[],t=0,i=s.replace(/×/g,"*").replace(/÷/g,"/").replace(/−/g,"-");for(;t<i.length;){let n=i[t];if(/\s/.test(n)){t++;continue}let r=i.slice(t).match(/^(\d[\d_]*(\.\d+)?|\.\d+)(e[+-]?\d+)?/i);if(r){e.push({t:"num",v:parseFloat(r[0].replace(/_/g,""))}),t+=r[0].length;continue}if(i.startsWith("**",t)){e.push({t:"op",v:"^"}),t+=2;continue}if("+-*/^".includes(n)){e.push({t:"op",v:n}),t++;continue}if(n==="%"){e.push({t:"%"}),t++;continue}if(n==="("||n===")"||n===","){e.push({t:n}),t++;continue}let o=i.slice(t).match(/^[a-zπ][a-z0-9_]*/i);if(o){e.push({t:"id",v:o[0].toLowerCase()}),t+=o[0].length;continue}throw new Error(`Unexpected "${n}"`)}return e}var it=class{constructor(e){u(this,"tokens",e);u(this,"i",0)}peek(){return this.tokens[this.i]}next(){return this.tokens[this.i++]}parse(){let e=this.expr();if(this.i<this.tokens.length)throw new Error("Unexpected input");return e}expr(){let e=this.term();for(;;){let t=this.peek();if(t?.t==="op"&&(t.v==="+"||t.v==="-")){this.next();let i=this.i,n=this.term();this.isBarePercent(i)&&(n=e*n),e=t.v==="+"?e+n:e-n}else return e}}isBarePercent(e){return this.tokens[e]?.t==="num"&&this.tokens[e+1]?.t==="%"&&this.i===e+2}term(){let e=this.power();for(;;){let t=this.peek();if(t?.t==="op"&&(t.v==="*"||t.v==="/")){this.next();let i=this.power();e=t.v==="*"?e*i:e/i}else if(t&&(t.t==="num"||t.t==="("||t.t==="id"&&t.v!=="of"))e*=this.power();else if(t?.t==="id"&&t.v==="of")this.next(),e*=this.power();else return e}}power(){let e=this.unary(),t=this.peek();return t?.t==="op"&&t.v==="^"?(this.next(),e**this.power()):e}unary(){let e=this.peek();if(e?.t==="op"&&(e.v==="-"||e.v==="+")){this.next();let t=this.unary();return e.v==="-"?-t:t}return this.postfix()}postfix(){let e=this.primary();for(;this.peek()?.t==="%";)this.next(),e/=100;return e}primary(){let e=this.next();if(!e)throw new Error("Unexpected end");if(e.t==="num")return e.v;if(e.t==="("){let t=this.expr();if(this.next()?.t!==")")throw new Error("Missing )");return t}if(e.t==="id"){if(e.v in si)return si[e.v];let t=Ji[e.v];if(t){if(this.peek()?.t!=="(")return t(this.power());this.next();let i=[this.expr()];for(;this.peek()?.t===",";)this.next(),i.push(this.expr());if(this.next()?.t!==")")throw new Error("Missing )");return t(...i)}throw new Error(`Unknown "${e.v}"`)}throw new Error("Unexpected token")}};function oe(s){let e=new it(Yi(s)).parse();if(!Number.isFinite(e))throw new Error("Not a finite number");return e}var q=(s,e,t,...i)=>i.map(n=>[n,{dim:s,factor:e,label:t}]),oi=new Map([...q("length",1,"m","m","meter","meters","metre","metres"),...q("length",1e3,"km","km","kilometer","kilometers","kilometre","kilometres"),...q("length",.01,"cm","cm","centimeter","centimeters"),...q("length",.001,"mm","mm","millimeter","millimeters"),...q("length",1609.344,"mi","mi","mile","miles"),...q("length",.3048,"ft","ft","foot","feet"),...q("length",.0254,"in","inch","inches"),...q("length",.9144,"yd","yd","yard","yards"),...q("mass",1,"kg","kg","kilogram","kilograms","kilo","kilos"),...q("mass",.001,"g","g","gram","grams"),...q("mass",.45359237,"lb","lb","lbs","pound","pounds"),...q("mass",.028349523125,"oz","oz","ounce","ounces"),...q("mass",6.35029318,"st","st","stone","stones"),...q("data",1,"B","b","byte","bytes"),...q("data",1024,"KB","kb","kib","kilobyte","kilobytes"),...q("data",1024**2,"MB","mb","mib","megabyte","megabytes"),...q("data",1024**3,"GB","gb","gib","gigabyte","gigabytes"),...q("data",1024**4,"TB","tb","tib","terabyte","terabytes"),...q("time",1,"s","s","sec","second","seconds"),...q("time",60,"min","min","mins","minute","minutes"),...q("time",3600,"h","h","hr","hrs","hour","hours"),...q("time",86400,"d","d","day","days"),...q("time",604800,"wk","wk","week","weeks"),...q("volume",1,"L","l","liter","liters","litre","litres"),...q("volume",.001,"mL","ml","milliliter","milliliters"),...q("volume",3.785411784,"gal","gal","gallon","gallons"),...q("volume",.2365882365,"cup","cup","cups"),...q("temp",1,"\xB0C","c","\xB0c","celsius"),...q("temp",1,"\xB0F","f","\xB0f","fahrenheit"),...q("temp",1,"K","k","kelvin")]);function Xi(s,e){return e==="\xB0C"?s+273.15:e==="\xB0F"?(s-32)*5/9+273.15:s}function Zi(s,e){return e==="\xB0C"?s-273.15:e==="\xB0F"?(s-273.15)*9/5+32:s}function Se(s){let e=s.trim().match(/^(.+?)\s*([a-z°]+)\s+(?:in|to|as|=)\s+([a-z°]+)$/i);if(!e)return;let t=oi.get(e[2].toLowerCase()),i=oi.get(e[3].toLowerCase());if(!t||!i||t.dim!==i.dim)return;let n=oe(e[1]);return t.dim==="temp"?{value:Zi(Xi(n,t.label),i.label),unit:i.label}:{value:n*t.factor/i.factor,unit:i.label}}function ae(s){return Math.abs(s)>=1e15||Math.abs(s)<1e-6&&s!==0?s.toExponential(6).replace(/\.?0+e/,"e"):(Math.round(s*1e10)/1e10).toLocaleString(void 0,{maximumFractionDigits:10})}function ai(s){let e=s.trim();return!e||!/\d|pi|π/.test(e)||/^\d+(\.\d+)?$/.test(e)?!1:/[+\-*/^%×÷()]|\b(in|to)\b|\b(sqrt|sin|cos|tan|log|ln|abs|round|of)\b/i.test(e)}function en(){return{name:"calculator",title:"Calculator",icon:"calculator",description:"Evaluate math and convert units as you type.",sources:[{id:"calculator",title:"Calculator",position:"top",debounce:0,search({query:s}){let e=s.trim().replace(/^=/,"");if(!ai(e))return[];let t;try{let n=Se(e);t=n?`${ae(n.value)} ${n.unit}`:ae(oe(e))}catch{return[]}let i=t.replace(/,/g,"");return[{id:"calculator:result",title:t,subtitle:`= ${e}`,icon:"calculator",noHistory:!0,accessories:[{text:"Copy",kbd:"enter"}],actions:[A.copy(i,{title:"Copy Result",shortcut:void 0}),A.copy(`${e} = ${t}`,{title:"Copy Equation",shortcut:"mod+shift+c"})]}]}}]}}function tn(s={}){let e=s.storageKey??"theme",t=s.set??(r=>{let o=r==="dark"||r==="system"&&matchMedia("(prefers-color-scheme: dark)").matches,a=document.documentElement;a.classList.toggle("dark",o),a.classList.toggle("light",!o),a.style.colorScheme=o?"dark":"light";try{r==="system"?localStorage.removeItem(e):localStorage.setItem(e,r)}catch{}}),i=()=>document.documentElement.classList.contains("dark")||document.documentElement.dataset.theme==="dark",n=(r,o)=>a=>{t(r),a.toast({title:o,style:"success",duration:1500})};return{name:"theme",title:"Appearance",icon:"palette",commands:[{name:"toggle",title:"Toggle Dark Mode",icon:"moon",keywords:["theme","light","dark","appearance","night"],shortcut:s.shortcut===!1?void 0:s.shortcut??"mod+shift+l",run:r=>n(i()?"light":"dark",i()?"Light mode":"Dark mode")(r)},{name:"light",title:"Use Light Theme",icon:"sun",keywords:["theme","appearance"],searchOnly:!0,run:n("light","Light mode")},{name:"dark",title:"Use Dark Theme",icon:"moon",keywords:["theme","appearance"],searchOnly:!0,run:n("dark","Dark mode")},{name:"system",title:"Use System Theme",icon:"monitor",keywords:["theme","appearance","auto"],searchOnly:!0,run:n("system","System theme")}]}}function nn(s={}){let e=s.headings??"h1[id], h2[id], h3[id]",t=(i,n,r,o,a={})=>({name:i,title:n,icon:r,searchOnly:!0,run:async c=>{await o(c)},...a});return{name:"page",title:"Page",icon:"file",commands:[t("back","Go Back","arrow-left",()=>history.back(),{keywords:["history","previous"]}),t("forward","Go Forward","arrow-right",()=>history.forward(),{keywords:["history","next"]}),t("reload","Reload Page","refresh",()=>location.reload(),{keywords:["refresh"]}),t("copy-url","Copy Page URL","link",async i=>{let n=await i.copy(location.href);i.toast({title:n?"Copied page URL":"Copy failed",style:n?"success":"failure"})},{keywords:["link","share","address"]}),t("top","Scroll to Top","arrow-up-right",()=>window.scrollTo({top:0,behavior:"smooth"})),t("bottom","Scroll to Bottom","chevron-down",()=>window.scrollTo({top:document.documentElement.scrollHeight,behavior:"smooth"})),t("print","Print Page","file-text",()=>setTimeout(()=>window.print(),150)),t("share","Share Page\u2026","send",()=>navigator.share?.({title:document.title,url:location.href}),{when:()=>typeof navigator<"u"&&"share"in navigator})],sources:e?[{id:"page-headings",title:"On This Page",debounce:0,filter:!0,limit:6,search(){let i=new Set;return[...document.querySelectorAll(e)].filter(n=>!n.closest(".qb-root")&&n.id&&!i.has(n.id)&&i.add(n.id)).map(n=>({id:`heading:${n.id}`,title:(n.textContent??"").replace(/\s+/g," ").trim(),subtitle:`#${n.id}`,icon:"hash",noHistory:!0,run:r=>{r.close(),history.replaceState(null,"",`#${n.id}`),n.scrollIntoView({behavior:"smooth",block:"start"})}}))}}]:[]}}function li(s=16e3){return(document.querySelector("main, [role=main], article")??document.body).innerText.replace(/\n{3,}/g,`
247
290
 
248
- `).trim().slice(0,s)}function qi(){let s,e="",t=r=>r.ai?!1:(r.toast({title:"AI is not configured",style:"failure"}),!0),i=(r,n,o)=>{if(t(r))return!1;let a=r.ai.stream(o,{signal:r.signal});return{type:"detail",title:n,markdown:a,actions:[M.ask(`${o}
291
+ `).trim().slice(0,s)}function rn(){let s,e="",t=n=>n.ai?!1:(n.toast({title:"AI is not configured",style:"failure"}),!0),i=(n,r,o)=>{if(t(n))return!1;let a=n.ai.stream(o,{signal:n.signal});return{type:"detail",title:r,markdown:a,actions:[A.ask(`${o}
249
292
 
250
- Let's discuss.`,{title:"Continue in Chat"})]}};return{name:"ai-actions",title:"AI",icon:"sparkles",setup({bar:r}){return s=r,r.on("open",()=>{e=typeof window<"u"?(window.getSelection()?.toString()??"").trim():""})},commands:[{name:"summarize-page",title:"Summarize This Page",icon:"sparkles",keywords:["tldr","summary","ai"],when:()=>!!s?.ai,run:r=>i(r,"Summary",`Summarize this web page in a few bullet points, then one sentence on what the reader should do next.
293
+ Let's discuss.`,{title:"Continue in Chat"})]}};return{name:"ai-actions",title:"AI",icon:"sparkles",setup({bar:n}){return s=n,n.on("open",()=>{e=typeof window<"u"?(window.getSelection()?.toString()??"").trim():""})},commands:[{name:"summarize-page",title:"Summarize This Page",icon:"sparkles",keywords:["tldr","summary","ai"],when:()=>!!s?.ai,run:n=>i(n,"Summary",`Summarize this web page in a few bullet points, then one sentence on what the reader should do next.
251
294
 
252
295
  Title: ${document.title}
253
296
 
254
- ${Ht()}`)},{name:"explain-selection",title:"Explain Selected Text",icon:"wand",keywords:["ai","selection","what does this mean"],when:()=>!!s?.ai&&!!e,run:r=>i(r,"Explanation",`Explain this clearly and briefly:
297
+ ${li()}`)},{name:"explain-selection",title:"Explain Selected Text",icon:"wand",keywords:["ai","selection","what does this mean"],when:()=>!!s?.ai&&!!e,run:n=>i(n,"Explanation",`Explain this clearly and briefly:
255
298
 
256
- ${e}`)},{name:"translate",title:"Translate",subtitle:"Selection or page",icon:"languages",keywords:["ai","language"],when:()=>!!s?.ai,arguments:[{name:"language",placeholder:"Language",required:!0}],run:r=>i(r,`Translation (${r.arguments.language})`,`Translate the following into ${r.arguments.language}. Reply with only the translation, keeping Markdown formatting.
299
+ ${e}`)},{name:"translate",title:"Translate",subtitle:"Selection or page",icon:"languages",keywords:["ai","language"],when:()=>!!s?.ai,arguments:[{name:"language",placeholder:"Language",required:!0}],run:n=>i(n,`Translation (${n.arguments.language})`,`Translate the following into ${n.arguments.language}. Reply with only the translation, keeping Markdown formatting.
257
300
 
258
- ${e||Ht(6e3)}`)}]}}function Mi(){return{name:"shortcuts",title:"Help",icon:"keyboard",commands:[{name:"list",title:"Keyboard Shortcuts",icon:"keyboard",keywords:["hotkeys","keys","help","cheatsheet"],view:s=>{let e=s.bar.commands().filter(i=>i.shortcut).map(i=>({...i,section:i.section??"Commands",accessories:[{kbd:i.shortcut}]})),t=[["Open command bar","mod+k"],["Move selection","arrowdown"],["Run selected","enter"],["Secondary action","mod+enter"],["Show actions","mod+."],["Ask AI","tab"],["Go back","escape"]].map(([i,r])=>({title:i,section:"Command bar",accessories:[{kbd:r}],icon:"command"}));return{type:"list",title:"Keyboard Shortcuts",placeholder:"Search shortcuts\u2026",items:[...e,...t],actions:[]}}}]}}function Ei(s){return $(s).map(e=>e.join(C?"":"+")).join(" ")}return zt(Ti);})();
301
+ ${e||li(6e3)}`)}]}}function sn(){return{name:"shortcuts",title:"Help",icon:"keyboard",commands:[{name:"list",title:"Keyboard Shortcuts",icon:"keyboard",keywords:["hotkeys","keys","help","cheatsheet"],view:s=>{let e=s.bar.commands().filter(i=>i.shortcut).map(i=>({...i,section:i.section??"Commands",accessories:[{kbd:i.shortcut}]})),t=[["Open command bar","mod+k"],["Move selection","arrowdown"],["Run selected","enter"],["Secondary action","mod+enter"],["Show actions","mod+."],["Ask AI","tab"],["Go back","escape"]].map(([i,n])=>({title:i,section:"Command bar",accessories:[{kbd:n}],icon:"command"}));return{type:"list",title:"Keyboard Shortcuts",placeholder:"Search shortcuts\u2026",items:[...e,...t],actions:[]}}}]}}function on(s){return $(s).map(e=>e.join(R?"":"+")).join(" ")}return fi(an);})();
259
302
  //# sourceMappingURL=qikbar.global.js.map