quotacap 0.0.26 → 0.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/webHtml.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // generated by scripts/build-embed.mjs — do not edit
2
- export const webHtml = "<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"color-scheme\" content=\"light dark\">\n<title>QuotaCap</title>\n<script>\ntry {\n var stored = localStorage.getItem(\"quotacap-theme\");\n var dark = stored === \"dark\" || (stored !== \"light\" && matchMedia(\"(prefers-color-scheme: dark)\").matches);\n document.documentElement.dataset.theme = dark ? \"dark\" : \"light\";\n} catch (e) { /* default light theme stands */ }\n</script>\n <script type=\"module\" crossorigin src=\"/assets/index-ClNhsr1-.js\"></script>\n <link rel=\"stylesheet\" crossorigin href=\"/assets/index-TJk_KDbS.css\">\n</head>\n<body><div id=\"app\"></div></body>\n</html>\n";
2
+ export const webHtml = "<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"color-scheme\" content=\"light dark\">\n<title>QuotaCap</title>\n<script>\ntry {\n var stored = localStorage.getItem(\"quotacap-theme\");\n var dark = stored === \"dark\" || (stored !== \"light\" && matchMedia(\"(prefers-color-scheme: dark)\").matches);\n document.documentElement.dataset.theme = dark ? \"dark\" : \"light\";\n} catch (e) { /* default light theme stands */ }\n</script>\n <script type=\"module\" crossorigin src=\"/assets/index-hmABfkqB.js\"></script>\n <link rel=\"stylesheet\" crossorigin href=\"/assets/index-TJk_KDbS.css\">\n</head>\n<body><div id=\"app\"></div></body>\n</html>\n";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quotacap",
3
- "version": "0.0.26",
3
+ "version": "0.0.28",
4
4
  "description": "Local quota tracker for AI coding plans with a dashboard, CLI, MCP server, and next-plan recommendations.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -9,4 +9,4 @@ Error generating stack: `+e.message+`
9
9
  `).replace(Ad,``)}function Md(e,t){return t=jd(t),jd(e)===t}function $(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||$t(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&$t(e,``+r);break;case`className`:Lt(e,`class`,r);break;case`tabIndex`:Lt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Lt(e,n,r);break;case`style`:nn(e,r,o);break;case`data`:if(t!==`object`){Lt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=sn(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&$(e,t,`name`,a.name,a,null),$(e,t,`formEncType`,a.formEncType,a,null),$(e,t,`formMethod`,a.formMethod,a,null),$(e,t,`formTarget`,a.formTarget,a,null)):($(e,t,`encType`,a.encType,a,null),$(e,t,`method`,a.method,a,null),$(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=sn(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=cn);break;case`onScroll`:r!=null&&Q(`scroll`,e);break;case`onScrollEnd`:r!=null&&Q(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=sn(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Q(`beforetoggle`,e),Q(`toggle`,e),It(e,`popover`,r);break;case`xlinkActuate`:Rt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Rt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Rt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Rt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Rt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Rt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Rt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Rt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Rt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:It(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=an.get(n)||n,It(e,n,r))}}function Nd(e,t,n,r,a,o){switch(n){case`style`:nn(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?$t(e,r):(typeof r==`number`||typeof r==`bigint`)&&$t(e,``+r);break;case`onScroll`:r!=null&&Q(`scroll`,e);break;case`onScrollEnd`:r!=null&&Q(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=cn);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!kt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[gt]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):It(e,n,r)}}}function Pd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Q(`error`,e),Q(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:$(e,t,o,s,n,null)}}a&&$(e,t,`srcSet`,n.srcSet,n,null),r&&$(e,t,`src`,n.src,n,null);return;case`input`:Q(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:$(e,t,r,d,n,null)}}Jt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Q(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:$(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&Xt(e,!!r,n,!0):Xt(e,!!r,t,!1);return;case`textarea`:for(s in Q(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:$(e,t,s,c,n,null)}Qt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:$(e,t,l,r,n,null)}return;case`dialog`:Q(`beforetoggle`,e),Q(`toggle`,e),Q(`cancel`,e),Q(`close`,e);break;case`iframe`:case`object`:Q(`load`,e);break;case`video`:case`audio`:for(r=0;r<_d.length;r++)Q(_d[r],e);break;case`image`:Q(`error`,e),Q(`load`,e);break;case`details`:Q(`toggle`,e);break;case`embed`:case`source`:case`link`:Q(`error`,e),Q(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:$(e,t,u,r,n,null)}return;default:if(rn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Nd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&$(e,t,c,r,n,null))}function Fd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||$(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&$(e,t,p,m,r,f)}}qt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||$(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&$(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?Xt(e,!!n,n?[]:``,!1):Xt(e,!!n,t,!0)):Xt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:$(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&$(e,t,s,a,r,o)}Zt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:$(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:$(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&$(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:$(e,t,u,p,r,m)}return;default:if(rn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Nd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Nd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&$(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||$(e,t,f,p,r,m)}function Id(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Ld(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Id(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Rd=null,zd=null;function Bd(e){return e.nodeType===9?e:e.ownerDocument}function Vd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Hd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Ud(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Wd=null;function Gd(){var e=window.event;return e&&e.type===`popstate`?e!==Wd&&(Wd=e,!0):(Wd=null,!1)}var Kd=typeof setTimeout==`function`?setTimeout:void 0,qd=typeof clearTimeout==`function`?clearTimeout:void 0,Jd=typeof Promise==`function`?Promise:void 0,Yd=typeof queueMicrotask==`function`?queueMicrotask:Jd===void 0?Kd:function(e){return Jd.resolve(null).then(e).catch(Xd)};function Xd(e){setTimeout(function(){throw e})}function Zd(e){return e===`head`}function Qd(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Np(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)pf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,pf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[St]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&pf(e.ownerDocument.body)}n=i}while(n);Np(t)}function $d(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function ef(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:ef(n),Ct(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function tf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[St])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=cf(e.nextSibling),e===null)break}return null}function nf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=cf(e.nextSibling),e===null))return null;return e}function rf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=cf(e.nextSibling),e===null))return null;return e}function af(e){return e.data===`$?`||e.data===`$~`}function of(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function sf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function cf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var lf=null;function uf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return cf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function df(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function ff(e,t,n){switch(t=Bd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function pf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Ct(e)}var mf=new Map,hf=new Set;function gf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var _f=D.d;D.d={f:vf,r:yf,D:Sf,C:Cf,L:wf,m:Tf,X:Df,S:Ef,M:Of};function vf(){var e=_f.f(),t=bu();return e||t}function yf(e){var t=Tt(e);t!==null&&t.tag===5&&t.type===`form`?As(t):_f.r(e)}var bf=typeof document>`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Kt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),A(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Kt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Kt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Kt(n.imageSizes)+`"]`)):i+=`[href="`+Kt(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=h({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),A(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Kt(r)+`"][href="`+Kt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=h({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),A(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=Dt(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=h({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);A(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=Dt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),A(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=Dt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),A(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var a=(a=ge.current)?gf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=Dt(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var o=Dt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(jf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),o||Nf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=Dt(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Af(e){return`href="`+Kt(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return h({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),A(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Kt(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Kt(n.href)+`"]`);if(r)return t.instance=r,A(r),r;var a=h({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),A(r),Pd(r,`style`,a),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Af(n.href);var o=e.querySelector(jf(a));if(o)return t.state.loading|=4,t.instance=o,A(o),o;r=Mf(n),(a=mf.get(a))&&Rf(r,a),o=(e.ownerDocument||e).createElement(`link`),A(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(o,`link`,r),t.state.loading|=4,Lf(o,n.precedence,e),t.instance=o;case`script`:return o=Pf(n.src),(a=e.querySelector(Ff(o)))?(t.instance=a,A(a),a):(r=n,(a=mf.get(o))&&(r=h({},n),zf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),A(a),Pd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Rf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function zf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Bf=null;function Vf(e,t,n){if(Bf===null){var r=new Map,i=Bf=new Map;i.set(n,r)}else i=Bf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[St]||a[ht]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Hf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,A(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),A(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Kf===0&&(Kf=62500*Ld());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Jf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var Qf={$$typeof:C,Provider:null,Consumer:null,_currentValue:ue,_currentValue2:ue,_threadCount:0};function $f(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=it(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=it(0),this.hiddenUpdates=it(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function ep(e,t,n,r,i,a,o,s,c,l,u,d){return e=new $f(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=gi(3,null,null,t),e.current=a,a.stateNode=e,t=ma(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},qa(a),e}function tp(e){return e?(e=mi,e):mi}function np(e,t,n,r,i,a){i=tp(i),r.context===null?r.context=i:r.pendingContext=i,r=Ya(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Xa(e,r,t),n!==null&&(hu(n,e,t),Za(n,e,t))}function rp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ip(e,t){rp(e,t),(e=e.alternate)&&rp(e,t)}function ap(e){if(e.tag===13||e.tag===31){var t=di(e,67108864);t!==null&&hu(t,e,67108864),ip(e,67108864)}}function op(e){if(e.tag===13||e.tag===31){var t=pu();t=ut(t);var n=di(e,t);n!==null&&hu(n,e,t),ip(e,t)}}var sp=!0;function cp(e,t,n,r){var i=E.T;E.T=null;var a=D.p;try{D.p=2,up(e,t,n,r)}finally{D.p=a,E.T=i}}function lp(e,t,n,r){var i=E.T;E.T=null;var a=D.p;try{D.p=8,up(e,t,n,r)}finally{D.p=a,E.T=i}}function up(e,t,n,r){if(sp){var i=dp(r);if(i===null)wd(e,t,r,fp,n),Cp(e,r);else if(Tp(i,e,t,n,r))r.stopPropagation();else if(Cp(e,r),t&4&&-1<Sp.indexOf(e)){for(;i!==null;){var a=Tt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=$e(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Ke(o);s.entanglements[1]|=c,o&=~c}rd(a),!(W&6)&&(nu=Pe()+500,id(0,!1))}}break;case 31:case 13:s=di(a,2),s!==null&&hu(s,a,2),bu(),ip(a,2)}if(a=dp(r),a===null&&wd(e,t,r,fp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else wd(e,t,r,null,n)}}function dp(e){return e=un(e),pp(e)}var fp=null;function pp(e){if(fp=null,e=wt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return fp=e,null}function mp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Fe()){case Ie:return 2;case Le:return 8;case Re:case ze:return 32;case Be:return 268435456;default:return 32}default:return 32}}var hp=!1,gp=null,_p=null,vp=null,yp=new Map,bp=new Map,xp=[],Sp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Cp(e,t){switch(e){case`focusin`:case`focusout`:gp=null;break;case`dragenter`:case`dragleave`:_p=null;break;case`mouseover`:case`mouseout`:vp=null;break;case`pointerover`:case`pointerout`:yp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:bp.delete(t.pointerId)}}function wp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=Tt(t),t!==null&&ap(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Tp(e,t,n,r,i){switch(t){case`focusin`:return gp=wp(gp,e,t,n,r,i),!0;case`dragenter`:return _p=wp(_p,e,t,n,r,i),!0;case`mouseover`:return vp=wp(vp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return yp.set(a,wp(yp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,bp.set(a,wp(bp.get(a)||null,e,t,n,r,i)),!0}return!1}function Ep(e){var t=wt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,pt(e.priority,function(){op(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,pt(e.priority,function(){op(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Dp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=dp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);ln=r,n.target.dispatchEvent(r),ln=null}else return t=Tt(n),t!==null&&ap(t),e.blockedOn=n,!1;t.shift()}return!0}function Op(e,t,n){Dp(e)&&n.delete(t)}function kp(){hp=!1,gp!==null&&Dp(gp)&&(gp=null),_p!==null&&Dp(_p)&&(_p=null),vp!==null&&Dp(vp)&&(vp=null),yp.forEach(Op),bp.forEach(Op)}function Ap(e,n){e.blockedOn===n&&(e.blockedOn=null,hp||(hp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,kp)))}var jp=null;function Mp(e){jp!==e&&(jp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){jp===e&&(jp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(pp(r||n)===null)continue;break}var a=Tt(n);a!==null&&(e.splice(t,3),t-=3,Os(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Np(e){function t(t){return Ap(t,e)}gp!==null&&Ap(gp,e),_p!==null&&Ap(_p,e),vp!==null&&Ap(vp,e),yp.forEach(t),bp.forEach(t);for(var n=0;n<xp.length;n++){var r=xp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<xp.length&&(n=xp[0],n.blockedOn===null);)Ep(n),n.blockedOn===null&&xp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[gt]||null;if(typeof a==`function`)o||Mp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[gt]||null)s=o.formAction;else if(pp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Mp(n)}}}function Pp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Fp(e){this._internalRoot=e}Ip.prototype.render=Fp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;np(n,pu(),e,t,null,null)},Ip.prototype.unmount=Fp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;np(e.current,2,null,e,null,null),bu(),t[_t]=null}};function Ip(e){this._internalRoot=e}Ip.prototype.unstable_scheduleHydration=function(e){if(e){var t=ft();e={blockedOn:null,target:e,priority:t};for(var n=0;n<xp.length&&t!==0&&t<xp[n].priority;n++);xp.splice(n,0,e),n===0&&Ep(e)}};var Lp=n.version;if(Lp!==`19.2.8`)throw Error(i(527,Lp,`19.2.8`));D.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=d(t),e=e===null?null:p(e),e=e===null?null:e.stateNode,e};var Rp={bundleType:0,version:`19.2.8`,rendererPackageName:`react-dom`,currentDispatcherRef:E,reconcilerVersion:`19.2.8`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var zp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zp.isDisabled&&zp.supportsFiber)try{Ue=zp.inject(Rp),We=zp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Zs,s=Qs,c=$s;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=ep(e,1,!1,null,null,n,r,null,o,s,c,Pp),e[_t]=t.current,Sd(e),new Fp(t)}})),g=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=h()})),_=c(u(),1),v=g();function y(){return typeof window<`u`&&window.location?.origin?`${window.location.origin}/api/state`:`/api/state`}var b=class extends Error{endpoint;constructor(e,t){super(`service unavailable: ${e}`),this.name=`StateNetworkError`,this.endpoint=e,t!==void 0&&(this.cause=t)}},x=class extends Error{status;constructor(e,t){super(t),this.name=`StateHttpError`,this.status=e}};async function S(e){try{let t=await e.json();if(typeof t==`object`&&t)for(let e of[`error`,`message`,`reason`]){let n=t[e];if(typeof n==`string`&&n.length>0)return n}}catch{}return e.statusText||`HTTP ${e.status}`}async function C(){let e;try{e=await fetch(`/api/state`)}catch(e){throw new b(`/api/state`,e)}if(!e.ok)throw new x(e.status,await S(e));return await e.json()}async function w(){let e;try{e=await fetch(`/api/token`)}catch(e){throw new b(`/api/token`,e)}if(!e.ok)throw new x(e.status,await S(e));return(await e.json()).token}function ee(e){if(typeof e==`object`&&e)for(let t of[`message`,`error`,`reason`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}async function te(){let e=await w(),t;try{t=await fetch(`/api/refresh`,{method:`POST`,headers:{"X-QuotaCap-Token":e}})}catch(e){throw new b(`/api/refresh`,e)}let n=null;try{n=await t.json()}catch{n=null}if(!t.ok)throw new x(t.status,ee(n)??t.statusText??`HTTP ${t.status}`);return{ok:t.ok,status:t.status,message:ee(n),raw:n}}async function ne(e,t){let n=await w(),r;try{r=await fetch(`/api/providers/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,"X-QuotaCap-Token":n},body:JSON.stringify({displayName:t})})}catch(t){throw new b(`/api/providers/${e}`,t)}if(!r.ok)throw new x(r.status,await S(r))}function T(e){let t=Array.isArray(e.providers)?e.providers.map(e=>({...e,displayName:typeof e.displayName==`string`&&e.displayName?e.displayName:e.id,builtinName:e.builtinName??null,vendor:e.vendor??null,harness:e.harness??null,description:e.description??null,evidence:Array.isArray(e.evidence)?[...e.evidence]:[]})):[],n=Array.isArray(e.recommendation?.advisories)?[...e.recommendation.advisories]:[];return{asOf:e.asOf,runtime:{...e.runtime},providers:t,recommendation:{...e.recommendation,advisories:n}}}function re(e){return e.providers.every(e=>e.quota===null||e.quota===void 0)}function ie(e){return!e.harness&&!e.vendor?null:e.harness&&e.vendor&&e.harness===e.displayName?e.vendor:[e.harness,e.vendor].filter(Boolean).join(` · `)}function ae(e,t=Date.now()){let n=t-Date.parse(e);if(!Number.isFinite(n)||n<1e3)return`read just now`;let r=Math.floor(n/1e3);if(r<60)return`read ${r}s ago`;let i=Math.floor(r/60);if(i<60)return`read ${i}m ago`;let a=Math.floor(i/60);return a<48?`read ${a}h ago`:`read ${Math.floor(a/24)}d ago`}var oe=9e5;function se(e,t,n=Date.now(),r=oe){if(t===`in-progress`)return`Refreshing now`;if(!e)return`Next automatic refresh pending`;let i=Date.parse(e);if(!Number.isFinite(i))return`Next automatic refresh pending`;let a=r-(n-i);if(a<=0)return`Next automatic refresh due`;let o=Math.max(1,Math.round(a/6e4));if(o<60)return`Next automatic refresh in ${o}m`;let s=Math.floor(o/60),c=o%60;return c===0?`Next automatic refresh in ${s}h`:`Next automatic refresh in ${s}h ${c}m`}function ce(e){if(e===null||!Number.isFinite(e)||e<0)return null;if(e<6e4)return`${Math.floor(e/1e3)}s`;let t=Math.floor(e/6e4);if(t<60)return`${t}m`;let n=Math.floor(t/60),r=t%60;return r===0?`${n}h`:`${n}h ${r}m`}var le=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),E=o(((e,t)=>{t.exports=le()}))();function D(e){if(e.exclusionReason!==null)return`Not reporting`;let t=e.advisory;if(!t)return`Not reporting`;if(t.status===`at risk`)return`Cap risk`;switch(t.urgency){case`burn now`:case`use soon`:case`save`:return`Behind pace`;case`slow down`:return`Ahead of pace`;case`on track`:return`On track`}}function ue(e){switch(e){case`stale`:return`stale`;case`reset-passed`:return`reset passed`;case`invalid`:return`invalid`;case`provider-failed`:return`provider failed`;case`not-reporting`:case null:return null}}var de={measured:`Measured`,"window-average":`Window avg`};function fe(e){return e.filter(e=>e!==`estimated-reset`).map(e=>de[e]??e)}function pe(e){return e.evidence.includes(`estimated-reset`)}function O(e,t){let n=Date.parse(e);if(!Number.isFinite(n))return null;let r=new Date(n);return`${r.toLocaleDateString(t,{weekday:`short`})} ${r.toLocaleTimeString(t,{hour:`2-digit`,minute:`2-digit`,hour12:!1})}`}function k(e,t){let n=Date.parse(e);if(!Number.isFinite(n)||!Number.isFinite(t))return null;let r=n-t;if(r<=0)return null;let i=Math.floor(r/6e4),a=Math.floor(i/1440),o=Math.floor(i%1440/60),s=i%60;return a>=1?`${a}d ${o}h`:o>=1?`${o}h ${s}m`:`${Math.max(1,s)}m`}function me(e,t){if(e.exclusionReason===`reset-passed`)return`awaiting fresh window`;if(!e.quota)return`no readings`;let n=k(e.quota.resetsAt,t);if(n===null){let n=Date.parse(e.quota.resetsAt);return Number.isFinite(n)&&n<=t?`awaiting fresh window`:`reset unknown`}return`in ${n}${pe(e)?` (est.)`:``}`}function he(e,t){let n=e.quota?Math.min(100,Math.max(0,e.quota.usedPct)):0,r=null;if(e.quota){let n=Date.parse(e.quota.periodStart),i=Date.parse(e.quota.resetsAt);Number.isFinite(n)&&Number.isFinite(i)&&i>n&&(r=Math.min(1,Math.max(0,(t-n)/(i-n)))*100)}return{usedPct:n,elapsedPct:r}}function ge(e){switch(e){case`On track`:return`var(--fill-ontrack)`;case`Behind pace`:return`var(--fill-behind)`;case`Ahead of pace`:return`var(--fill-ahead)`;case`Cap risk`:return`var(--fill-cap)`;case`Not reporting`:return`var(--fill-out)`}}function _e(e){switch(e){case`On track`:return`var(--edge-ontrack)`;case`Behind pace`:return`var(--edge-behind)`;case`Ahead of pace`:return`var(--edge-ahead)`;case`Cap risk`:return`var(--edge-cap)`;case`Not reporting`:return`var(--edge-out)`}}function ve(e){switch(e){case`Behind pace`:return`behind`;case`Cap risk`:return`cap`;case`On track`:return`ontrack`;default:return`none`}}function ye({provider:e}){let t=D(e),n=ue(e.exclusionReason);return(0,E.jsxs)(`span`,{"data-testid":`pace-badge`,className:`pace ${t===`Behind pace`?`pace-behind`:t===`On track`?`pace-ontrack`:t===`Ahead of pace`?`pace-ahead`:t===`Cap risk`?`pace-cap`:`pace-out`}`,children:[t,n?` · ${n}`:``]})}function be({provider:e,asOf:t,showHeadline:n=!0}){let r=D(e),{usedPct:i,elapsedPct:a}=he(e,Date.parse(t)),o=e.advisory?.wastePct,s=o!=null&&Number.isFinite(o)&&o>=3,c=e.quota?`${e.id}: ${e.quota.usedPct}% used, ${r}`:`${e.id}: no readings, ${r}`,l=s&&r===`Behind pace`?`${Math.round(o)}% expires unused`:xe(e),u=ve(r);return(0,E.jsxs)(`div`,{"data-testid":`pace-bar`,role:`img`,"aria-label":c,className:`trackwrap`,children:[n&&e.quota&&(0,E.jsxs)(`div`,{className:`tline`,children:[(0,E.jsxs)(`span`,{className:`used`,children:[e.quota.usedPct,`% used`]}),l&&u!==`none`?(0,E.jsxs)(`span`,{className:`out out-${u}`,children:[`→ `,l]}):l?(0,E.jsxs)(`span`,{className:`out out-none`,children:[`→ `,l]}):null]}),(0,E.jsxs)(`div`,{className:`track`,children:[(0,E.jsx)(`div`,{"aria-hidden":`true`,className:`fill`,style:{width:`${i}%`,background:ge(r),"--fill-edge":_e(r)}}),s&&(0,E.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`pace-hatch`,className:`band band-waste`,style:{left:`${100-o}%`,width:`${o}%`}}),a!==null&&(0,E.jsx)(`div`,{"aria-hidden":`true`,title:`elapsed`,className:`mark`,style:{left:`${a}%`}})]}),(0,E.jsxs)(`div`,{className:`tfoot`,children:[(0,E.jsx)(`span`,{children:`start`}),(0,E.jsx)(`span`,{children:a===null?``:`Time elapsed: ${Math.round(a)}%`}),(0,E.jsx)(`span`,{children:`reset`})]})]})}function xe(e){if(e.exclusionReason===`not-reporting`||!e.quota)return`Not reporting yet.`;switch(e.exclusionReason){case`stale`:{let t=ce(e.ageMs);return t?`Stale. Last read ${t} ago.`:`Stale. Last read unknown.`}case`reset-passed`:return`Reset passed. Awaiting fresh window.`;case`invalid`:return`Reading invalid. Excluded from ranking.`;case`provider-failed`:return`Provider failed. Excluded from ranking.`}let t=e.advisory;return t?t.paceSource===`unknown`?`Measuring pace · ${Math.round(t.remaining)}% remaining`:t.status===`at risk`?t.daysToExhaust!==null&&Number.isFinite(t.daysToExhaust)?`Cap risk · exhausts in ${t.daysToExhaust.toFixed(1)}d at current pace`:`Cap risk at current pace`:t.wastePct===null?`On track.`:`${Math.round(t.wastePct)}% waste in ${t.daysLeft.toFixed(1)}d`:null}var Se={kimi:`M12 7v5l3 2M12 12m-8.5 0a8.5 8.5 0 1 0 17 0a8.5 8.5 0 1 0-17 0`,claude:`M6 3h8l4 4v14H6zM9 12h6M9 16h6`,grok:`M12 3.5l2.6 5.5 5.9.8-4.3 4.2 1 5.9-5.2-2.8-5.2 2.8 1-5.9L3.5 9.8l5.9-.8z`,codex:`M8 5l10 7-10 7z`,agy:`M12 4l7 7-7 9-7-9z`,muse:`M12 3l1.8 6.2L20 11l-6.2 1.8L12 19l-1.8-6.2L4 11l6.2-1.8z`};function Ce(e){return e.split(`:`)[0]}function we({id:e,title:t,size:n=17}){let r=Ce(e),i=Se[r];return i?(0,E.jsx)(`svg`,{width:n,height:n,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.9`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:r===`kimi`?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`path`,{d:`M12 7v5l3 2`}),(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})]}):r===`claude`?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`path`,{d:`M6 3h8l4 4v14H6z`}),(0,E.jsx)(`path`,{d:`M9 12h6M9 16h6`})]}):(0,E.jsx)(`path`,{d:i})}):(0,E.jsx)(`span`,{"aria-hidden":`true`,children:t.charAt(0)})}function Te(e){let t=Ce(e);return{background:`color-mix(in oklch, var(--p-${t}, var(--surface-raised)) 18%, transparent)`,color:`var(--p-${t}, var(--ink))`}}function Ee(e,t){if(t!==null)return null;switch(e.urgency){case`burn now`:case`use soon`:case`save`:return`use-more`;case`slow down`:return`ease-off`;case`on track`:return null}}function De(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[],i=[];for(let t of e){let e=n.get(t.provider);if(!e)continue;let a=Ee(t,e.exclusionReason);a===`use-more`?r.push(t):a===`ease-off`&&i.push(t)}return{useMore:r,easeOff:i}}function Oe({testId:e,label:t,tintClass:n,laneClass:r,icon:i,members:a,providers:o,asOfMs:s,onSelectProvider:c}){if(a.length===0)return null;let l=new Map(o.map(e=>[e.id,e]));return(0,E.jsxs)(`div`,{"data-testid":e,"aria-label":t,className:`lane ${n}`,children:[(0,E.jsxs)(`span`,{className:`lane-l ${r}`,children:[i,t]}),(0,E.jsx)(`div`,{className:`items`,children:a.map(e=>{let t=l.get(e.provider)?.quota,n=t?k(t.resetsAt,s):null,r=l.get(e.provider)?.displayName??e.provider;return(0,E.jsxs)(`div`,{className:`rsub`,children:[(0,E.jsx)(`span`,{className:`sq`,style:Te(e.provider),"aria-hidden":`true`,children:(0,E.jsx)(we,{id:e.provider,title:r,size:13})}),(0,E.jsx)(`div`,{className:`rnm-group`,children:(0,E.jsx)(`button`,{type:`button`,className:`rnm`,onClick:()=>c?.(e.provider),"aria-label":`View ${r} details`,children:r})}),(0,E.jsx)(`span`,{className:`rnum`,children:t?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`b`,{children:[t.usedPct,`%`]}),` used`,n?(0,E.jsxs)(E.Fragment,{children:[` · `,(0,E.jsx)(`b`,{children:n}),` left`]}):null]}):null})]},e.provider)})})]})}function ke({recommendation:e,providers:t,asOf:n,onSelectProvider:r,onViewAdvice:i}){let{useMore:a,easeOff:o}=De(e.advisories,t),s=Date.parse(n),c=e.use!==`none`&&e.wastePct===null,l=e.use===`none`&&a.length===0&&o.length===0,u=t.filter(e=>e.enabled&&e.id!==`manual`).length,d=o.some(e=>e.status===`at risk`)?`tint-cap`:`tint-ahead`,f=t.find(t=>t.id===e.use),p=f?.quota?k(f.quota.resetsAt,s):null,m=()=>{i?.()},h=(0,E.jsxs)(`div`,{className:`section-head`,children:[(0,E.jsx)(`h2`,{children:`Quota Advice & Pacing`}),(0,E.jsxs)(`span`,{className:`note`,children:[u,` tracked · `,ae(n)]})]});return l?(0,E.jsxs)(`section`,{"aria-label":`Quota advice and pacing`,children:[h,(0,E.jsxs)(`section`,{"data-testid":`recommendation`,"aria-label":`Recommendation`,className:`recwrap is-clear`,role:`status`,children:[(0,E.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z`}),(0,E.jsx)(`path`,{d:`M8 12.5l2.8 2.8L16 10`})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`b`,{children:`No subscription needs priority`}),(0,E.jsx)(`span`,{"data-testid":`rec-prose`,children:e.reason})]})]})]}):(0,E.jsxs)(`section`,{"aria-label":`Quota advice and pacing`,children:[h,(0,E.jsxs)(`section`,{"data-testid":`recommendation`,"aria-label":`Recommendation`,className:`recwrap`,role:`status`,children:[(0,E.jsxs)(`div`,{className:`rec-top`,children:[(0,E.jsxs)(`div`,{className:`rec-lead`,children:[(0,E.jsxs)(`span`,{className:`rec-badge`,children:[(0,E.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`m12 3-1.9 5.8a2 2 0 0 1-1.3 1.3L3 12l5.8 1.9a2 2 0 0 1 1.3 1.3L12 21l1.9-5.8a2 2 0 0 1 1.3-1.3L21 12l-5.8-1.9a2 2 0 0 1-1.3-1.3z`})}),`Recommendation`]}),e.use===`none`?(0,E.jsx)(`p`,{className:`rec-advice-prose`,"data-testid":`rec-prose`,children:e.reason}):(0,E.jsxs)(`p`,{className:`rec-advice-prose`,"data-testid":`rec-prose`,children:[`Switch to `,(0,E.jsx)(`strong`,{children:f?.displayName??e.use}),` next`,e.wastePct===null?(0,E.jsxs)(E.Fragment,{children:[` — `,e.reason]}):(0,E.jsxs)(E.Fragment,{children:[` — `,(0,E.jsxs)(`strong`,{children:[Math.round(e.wastePct),`%`]}),` unused quota forecast`,p?(0,E.jsxs)(E.Fragment,{children:[` to expire in `,(0,E.jsx)(`strong`,{children:p})]}):null,`.`]})]}),c&&(0,E.jsx)(`span`,{className:`rec-badge`,"data-testid":`rec-measuring`,style:{background:`var(--ahead-soft)`,color:`var(--ahead)`,borderColor:`var(--ahead)`},children:`measuring pace`})]}),e.use!==`none`&&(0,E.jsxs)(`button`,{type:`button`,className:`btn`,"data-testid":`view-advice`,title:`Open recommended provider`,onClick:m,children:[`View advice`,(0,E.jsx)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M5 12h14M12 5l7 7-7 7`})})]})]}),(a.length>0||o.length>0)&&(0,E.jsxs)(`div`,{className:`recB`,children:[(0,E.jsx)(Oe,{testId:`lane-use-more`,label:`Use more`,tintClass:`tint-behind`,laneClass:`l-behind`,icon:(0,E.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,E.jsx)(`path`,{d:`M12 20V5M6 11l6-6 6 6`})}),members:a,providers:t,asOfMs:s,onSelectProvider:r}),(0,E.jsx)(Oe,{testId:`lane-ease-off`,label:`Ease off`,tintClass:d,laneClass:d===`tint-cap`?`l-cap`:`l-ahead`,icon:(0,E.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,E.jsx)(`path`,{d:`M12 4v15M6 13l6 6 6-6`})}),members:o,providers:t,asOfMs:s,onSelectProvider:r})]})]})]})}function Ae(e){if(!e.quota)return null;let t=O(e.quota.resetsAt);return t?`Resets ${t}${pe(e)?` (est.)`:``}`:null}function je({provider:e,recommended:t,asOf:n,onSelect:r}){let i=e.quota,a=e.advisory,o=Date.parse(n),s=ce(e.ageMs),c=i?k(i.resetsAt,o):null,l=e.displayName;return(0,E.jsxs)(`article`,{"data-testid":`provider-card-${e.id}`,role:`button`,tabIndex:0,"aria-label":`${l} details`,onClick:()=>r(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),r(e.id))},className:`pcard ${t?`is-recommended is-top-pick`:``}`,children:[(0,E.jsxs)(`div`,{className:`pcard-head`,children:[(0,E.jsx)(`span`,{className:`picon`,style:Te(e.id),"aria-hidden":`true`,children:(0,E.jsx)(we,{id:e.id,title:l})}),(0,E.jsxs)(`div`,{className:`who`,children:[(0,E.jsxs)(`b`,{children:[l,t&&(0,E.jsx)(`span`,{className:`rec-icon`,title:`Recommended for next session`,role:`img`,"aria-label":`recommended`,children:(0,E.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.3`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`m12 3-1.9 5.8a2 2 0 0 1-1.3 1.3L3 12l5.8 1.9a2 2 0 0 1 1.3 1.3L12 21l1.9-5.8a2 2 0 0 1 1.3-1.3L21 12l-5.8-1.9a2 2 0 0 1-1.3-1.3z`})})})]}),i&&i.plan&&(0,E.jsx)(`span`,{className:`pl`,children:i.plan}),s&&(0,E.jsxs)(`span`,{className:`src`,children:[`Updated `,s,` ago`]})]}),(0,E.jsx)(ye,{provider:e})]}),(0,E.jsxs)(`div`,{className:`pcard-body`,children:[(0,E.jsx)(be,{provider:e,asOf:n}),(0,E.jsxs)(`div`,{className:`pstats`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`span`,{className:`l`,children:`Pace`}),(0,E.jsx)(`span`,{className:`v`,children:a&&a.burnRate!==null?`${a.burnRate.toFixed(1)}%/d`:`—`})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`span`,{className:`l`,children:`Needed`}),(0,E.jsx)(`span`,{className:`v`,children:a?`${a.idealRate.toFixed(1)}%/d`:`—`})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`span`,{className:`l`,children:`Resets in`}),(0,E.jsx)(`span`,{className:`v`,children:c?`${c}${pe(e)?` (est.)`:``}`:me(e,o)})]})]})]}),(0,E.jsxs)(`div`,{className:`pcard-foot`,children:[(0,E.jsx)(`span`,{children:Ae(e)??me(e,o)}),(0,E.jsx)(`span`,{className:`rowbtn`,"aria-hidden":`true`,children:`Inspect`})]})]})}function Me({provider:e,recommended:t,asOf:n,onSelect:r}){let i=e.quota,a=e.advisory,o=Date.parse(n),s=fe(e.evidence),c=e.displayName;return(0,E.jsxs)(`div`,{"data-testid":`provider-row-${e.id}`,className:`lrow ${t?`is-recommended is-top-pick`:``}`,onClick:()=>r(e.id),children:[(0,E.jsxs)(`div`,{className:`prov`,"data-label":`Provider`,children:[(0,E.jsx)(`span`,{className:`dot`,style:{background:`var(--p-${e.id.split(`:`)[0]}, var(--surface-raised))`},"aria-hidden":`true`}),(0,E.jsxs)(`span`,{children:[(0,E.jsxs)(`span`,{className:`nm`,children:[c,t&&(0,E.jsx)(`span`,{className:`rec-icon`,title:`Recommended for next session`,role:`img`,"aria-label":`recommended`,children:(0,E.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.3`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`m12 3-1.9 5.8a2 2 0 0 1-1.3 1.3L3 12l5.8 1.9a2 2 0 0 1 1.3 1.3L12 21l1.9-5.8a2 2 0 0 1 1.3-1.3L21 12l-5.8-1.9a2 2 0 0 1-1.3-1.3z`})})})]}),i?.plan&&(0,E.jsx)(`span`,{className:`pl`,children:i.plan}),i?.sessionPct!==void 0&&i.sessionPct!==null&&(0,E.jsxs)(`span`,{className:`src`,children:[`Session use `,i.sessionPct,`%`]})]})]}),(0,E.jsx)(`div`,{"data-label":`Used vs elapsed`,children:i?(0,E.jsx)(be,{provider:e,asOf:n}):`—`}),(0,E.jsx)(`div`,{"data-label":`Resets in`,children:(0,E.jsx)(`span`,{className:`cell-b`,children:me(e,o)})}),(0,E.jsxs)(`div`,{"data-label":`Pace`,children:[(0,E.jsx)(ye,{provider:e}),a&&a.burnRate!==null&&(0,E.jsxs)(`div`,{className:`cell-s`,style:{marginTop:2},children:[`Pace `,a.burnRate.toFixed(1),`%/d · needed `,a.idealRate.toFixed(1),`%/d`]}),s.length>0&&(0,E.jsx)(`div`,{className:`cell-s`,style:{marginTop:2},children:s.join(` · `)})]}),(0,E.jsx)(`button`,{type:`button`,className:`rowbtn`,onClick:t=>{t.stopPropagation(),r(e.id)},children:`Inspect`}),(0,E.jsx)(`span`,{className:`sr-only`,children:xe(e)})]})}function Ne(e,t,n){let r=[...e];if(t===`recommended`){let{useMore:t,easeOff:i}=De(n.advisories,e),a=new Map,o=0;n.use!==`none`&&a.set(n.use,o++);for(let e of[...t,...i])a.has(e.provider)||a.set(e.provider,o++);let s=r.filter(e=>e.exclusionReason===null&&a.has(e.id)).sort((e,t)=>a.get(e.id)-a.get(t.id)),c=r.filter(e=>e.exclusionReason===null&&!a.has(e.id)),l=r.filter(e=>e.exclusionReason!==null);return[...s,...c,...l]}let i=e=>e.quota?Date.parse(e.quota.resetsAt):NaN,a=e=>e.quota?e.quota.usedPct:NaN,o=(e,t)=>r.sort((n,r)=>{let i=t(n),a=t(r),o=!Number.isFinite(i),s=!Number.isFinite(a);return o&&s?0:o?1:s?-1:e(i,a)});switch(t){case`reset-asc`:return o((e,t)=>e-t,i);case`reset-desc`:return o((e,t)=>t-e,i);case`used-desc`:return o((e,t)=>t-e,a);case`used-asc`:return o((e,t)=>e-t,a)}}function Pe(e,t){return e}var Fe=[{value:`recommended`,label:`Recommended`},{value:`reset-asc`,label:`Earliest Reset`},{value:`reset-desc`,label:`Latest Reset`},{value:`used-desc`,label:`Highest Usage`},{value:`used-asc`,label:`Lowest Usage`}];function Ie({value:e,onChange:t}){let[n,r]=(0,_.useState)(!1),i=(0,_.useRef)(null),a=Fe.find(t=>t.value===e)??Fe[0];return(0,_.useEffect)(()=>{if(!n)return;let e=e=>{i.current?.contains(e.target)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]),(0,E.jsxs)(`div`,{className:`sort-dropdown`,ref:i,children:[(0,E.jsxs)(`button`,{type:`button`,className:`sort-btn`,"data-testid":`sort-select`,"aria-label":`Sort by`,"aria-haspopup":`listbox`,"aria-expanded":n,onClick:()=>r(e=>!e),children:[(0,E.jsx)(`span`,{className:`sort-icon`,"aria-hidden":`true`,children:(0,E.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,E.jsx)(`line`,{x1:`4`,y1:`6`,x2:`20`,y2:`6`}),(0,E.jsx)(`line`,{x1:`4`,y1:`12`,x2:`14`,y2:`12`}),(0,E.jsx)(`line`,{x1:`4`,y1:`18`,x2:`8`,y2:`18`})]})}),(0,E.jsxs)(`span`,{className:`sort-display`,children:[(0,E.jsx)(`span`,{className:`sort-prefix`,children:`Sort by:`}),(0,E.jsx)(`span`,{className:`sort-val`,children:a.label})]}),(0,E.jsx)(`svg`,{className:`sort-chevron`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`m6 9 6 6 6-6`})})]}),n&&(0,E.jsx)(`div`,{className:`sort-menu`,role:`listbox`,"aria-label":`Sort subscriptions`,children:Fe.map(n=>(0,E.jsxs)(`button`,{type:`button`,role:`option`,className:`sort-option${n.value===e?` is-active`:``}`,"aria-selected":n.value===e,onClick:()=>{t(n.value),r(!1)},children:[(0,E.jsx)(`span`,{children:n.label}),(0,E.jsx)(`svg`,{className:`check-svg`,width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`polyline`,{points:`20 6 9 17 4 12`})})]},n.value))})]})}function Le({providers:e,recommendation:t,asOf:n,lastCompletedPollAt:r,polling:i,onSelectProvider:a}){let[o,s]=(0,_.useState)(`cards`),[c,l]=(0,_.useState)(`recommended`),u=Pe(o,!1),d=Ne(e,c,t),f=d.filter(e=>e.enabled&&(e.id!==`manual`||e.quota!==null)),p=d.filter(e=>!e.enabled&&e.id!==`manual`),m=Date.parse(n),h=f.filter(e=>e.exclusionReason===null),g=f.filter(e=>e.exclusionReason!==null);return(0,E.jsxs)(`section`,{"aria-label":`Subscriptions`,children:[(0,E.jsxs)(`div`,{className:`section-head`,children:[(0,E.jsx)(`h2`,{children:`All subscriptions`}),(0,E.jsxs)(`div`,{className:`section-head-controls`,children:[(0,E.jsx)(Ie,{value:c,onChange:l}),(0,E.jsxs)(`div`,{role:`group`,"aria-label":`Display density`,className:`seg`,children:[(0,E.jsxs)(`button`,{type:`button`,"aria-pressed":u===`cards`,onClick:()=>s(`cards`),children:[(0,E.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:[(0,E.jsx)(`rect`,{x:`3`,y:`3`,width:`8`,height:`8`,rx:`2`}),(0,E.jsx)(`rect`,{x:`13`,y:`3`,width:`8`,height:`8`,rx:`2`}),(0,E.jsx)(`rect`,{x:`3`,y:`13`,width:`8`,height:`8`,rx:`2`}),(0,E.jsx)(`rect`,{x:`13`,y:`13`,width:`8`,height:`8`,rx:`2`})]}),`Cards`]}),(0,E.jsxs)(`button`,{type:`button`,"aria-pressed":u===`table`,onClick:()=>s(`table`),children:[(0,E.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:[(0,E.jsx)(`rect`,{x:`3`,y:`5`,width:`18`,height:`2.6`,rx:`1.3`}),(0,E.jsx)(`rect`,{x:`3`,y:`11`,width:`18`,height:`2.6`,rx:`1.3`}),(0,E.jsx)(`rect`,{x:`3`,y:`17`,width:`18`,height:`2.6`,rx:`1.3`})]}),`Table`]})]})]})]}),u===`cards`?(0,E.jsx)(`div`,{"data-testid":`cards-grid`,className:`cards cards-grid`,children:f.map(e=>(0,E.jsx)(je,{provider:e,recommended:e.id===t.use,asOf:n,onSelect:a},e.id))}):(0,E.jsx)(`div`,{className:`table-scroll`,children:(0,E.jsxs)(`div`,{"data-testid":`ledger-table`,className:`ledger`,role:`table`,children:[(0,E.jsxs)(`div`,{className:`lrow lhead`,role:`row`,children:[(0,E.jsx)(`span`,{role:`columnheader`,children:`Provider`}),(0,E.jsx)(`span`,{role:`columnheader`,children:`Used vs elapsed`}),(0,E.jsx)(`span`,{role:`columnheader`,children:`Resets in`}),(0,E.jsx)(`span`,{role:`columnheader`,children:`Pace`}),(0,E.jsx)(`span`,{role:`columnheader`})]}),f.map(e=>(0,E.jsx)(Me,{provider:e,recommended:e.id===t.use,asOf:n,onSelect:a},e.id))]})}),(0,E.jsxs)(`footer`,{className:`health`,children:[(0,E.jsxs)(`ul`,{children:[(0,E.jsxs)(`li`,{className:`legend-rec`,children:[(0,E.jsx)(`svg`,{className:`legend-star`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.3`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`m12 3-1.9 5.8a2 2 0 0 1-1.3 1.3L3 12l5.8 1.9a2 2 0 0 1 1.3 1.3L12 21l1.9-5.8a2 2 0 0 1 1.3-1.3L21 12l-5.8-1.9a2 2 0 0 1-1.3-1.3z`})}),(0,E.jsx)(`span`,{children:`Recommended to use next`})]}),(0,E.jsxs)(`li`,{children:[(0,E.jsx)(`span`,{className:`dot`,style:{background:`var(--good)`}}),(0,E.jsxs)(`span`,{children:[h.length,` used in ranking`]})]}),g.length>0&&(0,E.jsxs)(`li`,{children:[(0,E.jsx)(`span`,{className:`dot`,style:{background:`var(--fill-out)`}}),(0,E.jsxs)(`span`,{children:[g.length,` not reporting`,g.length<=2?` · ${g.map(e=>e.displayName).join(`, `)}`:``]})]})]}),(0,E.jsx)(`span`,{children:se(r,i)})]}),p.length>0&&(0,E.jsxs)(`section`,{"aria-label":`Disabled providers`,children:[(0,E.jsxs)(`h3`,{children:[`Disabled (`,p.length,`)`]}),(0,E.jsx)(`ul`,{children:p.map(e=>(0,E.jsxs)(`li`,{style:{fontSize:`var(--t-2)`},children:[e.displayName,` · disabled · `,me(e,m)]},e.id))})]})]})}var Re=6048e5,ze=3,Be=2;function Ve(e,t){let n=t.getTime(),r=[],i=[],a=[],o=[],s=[];for(let t of e){let e=t.resetsAt===null?NaN:Date.parse(t.resetsAt);if(!Number.isFinite(e)){o.push(t);continue}if(!(e<=n)){if(e-n>Re){a.push(t);continue}s.push({row:t,resetMs:e,positionPct:(e-n)/Re*100})}}s.sort((e,t)=>e.resetMs-t.resetMs);let c=[];for(let e of s){let t=c[c.length-1];t&&e.positionPct-t[0].positionPct<ze?t.push(e):c.push([e])}let l=[];for(let e of c)if(e.length<=Be)for(let t of e)l.push({kind:`pin`,pin:{...t.row,positionPct:t.positionPct,band:`above`,tier:0}});else{let t=e.reduce((e,t)=>e+t.positionPct,0)/e.length;l.push({kind:`cluster`,cluster:{ids:e.map(e=>e.row.id),positionPct:t,band:`above`,tier:0}})}l.sort((e,t)=>(e.kind===`pin`?e.pin.positionPct:e.cluster.positionPct)-(t.kind===`pin`?t.pin.positionPct:t.cluster.positionPct));let u={above:{position:-1/0,tier:0},below:{position:-1/0,tier:0}};l.forEach((e,t)=>{let n=e.kind===`pin`?e.pin:e.cluster,r=t%2==0?`above`:`below`,i=u[r],a=n.positionPct-i.position<6?i.tier+1:0;n.band=r,n.tier=a,u[r]={position:n.positionPct,tier:a}});for(let e of l)e.kind===`pin`?r.push(e.pin):i.push(e.cluster);return{placed:r,clusters:i,overflow:a,invalid:o}}function He({cluster:e,providers:t,asOfMs:n,onSelect:r,onClose:i}){let a=(0,_.useRef)(null);return(0,_.useEffect)(()=>{a.current?.focus();let e=e=>{e.key===`Escape`&&i()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i]),(0,E.jsxs)(`div`,{ref:a,tabIndex:-1,"data-testid":`cluster-popover`,role:`dialog`,"aria-label":`${e.ids.length} resets at the same time`,className:`cluster-popover`,style:{left:`${e.positionPct}%`,transform:`translateX(-${e.positionPct}%)`,top:e.band===`above`?`15%`:`55%`},children:[(0,E.jsxs)(`h4`,{children:[e.ids.length,` concurrent resets`]}),(0,E.jsx)(`ul`,{children:e.ids.map(e=>{let a=t.get(e),o=a?.displayName??e;return(0,E.jsx)(`li`,{children:(0,E.jsxs)(`button`,{type:`button`,onClick:()=>{r(e),i()},children:[(0,E.jsx)(`b`,{children:o}),(0,E.jsxs)(`span`,{children:[a?.quota?`${a.quota.usedPct}% · `:``,a?me(a,n):``]})]})},e)})}),(0,E.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-quiet`,style:{marginTop:`var(--s2)`,width:`100%`},onClick:i,children:`Close`})]})}function Ue(){try{return new Intl.DateTimeFormat(void 0,{timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value??``}catch{return``}}function We(e){if(!e)return{cls:`pace-out`,color:`var(--ink-soft)`};switch(D(e)){case`Behind pace`:return{cls:`pace-behind`,color:`var(--warn)`};case`On track`:return{cls:`pace-ontrack`,color:`var(--good)`};case`Ahead of pace`:return{cls:`pace-ahead`,color:`var(--ahead)`};case`Cap risk`:return{cls:`pace-cap`,color:`var(--danger)`};default:return{cls:`pace-out`,color:`var(--ink-soft)`}}}function Ge(e){return O(e)??``}function Ke(e){return Array.from({length:7},(t,n)=>{let r=new Date(e+n*24*60*60*1e3);return`${r.toLocaleDateString(void 0,{weekday:`short`})} ${r.toLocaleDateString(void 0,{day:`numeric`})}`})}function qe({providers:e,asOf:t,onSelectProvider:n}){let[r,i]=(0,_.useState)(null),a=Date.parse(t),o=new Map(e.map(e=>[e.id,e])),s=Ve(e.filter(e=>e.enabled&&e.quota).map(e=>({id:e.id,resetsAt:e.quota.resetsAt,estimated:!!e.quota.resetsAtEstimated})),new Date(a)),c=Ke(a);return(0,E.jsxs)(`section`,{"aria-label":`Upcoming resets`,children:[(0,E.jsxs)(`div`,{className:`section-head`,children:[(0,E.jsx)(`h2`,{id:`resets-h`,children:`Upcoming resets`}),(0,E.jsxs)(`span`,{className:`note`,children:[`Next 7 days · hover pin for usage · click for details · `,Ue(),s.overflow.length>0&&(0,E.jsxs)(`span`,{"data-testid":`rail-overflow`,title:s.overflow.map(e=>o.get(e.id)?.displayName??e.id).join(`, `),style:{marginLeft:8,fontWeight:600,color:`var(--ahead)`},children:[`+`,s.overflow.length,` beyond rail`]})]})]}),(0,E.jsx)(`div`,{"data-testid":`rail`,className:`rail-scroller`,tabIndex:0,role:`region`,"aria-label":`Upcoming resets over the next 7 days`,children:(0,E.jsxs)(`div`,{className:`rail`,children:[(0,E.jsx)(`div`,{className:`rail-grid`,"aria-hidden":`true`,children:Array.from({length:7},(e,t)=>(0,E.jsx)(`span`,{},t))}),(0,E.jsx)(`div`,{className:`rail-axis`,"aria-hidden":`true`}),(0,E.jsx)(`div`,{className:`rail-now`,"aria-hidden":`true`}),(0,E.jsx)(`span`,{className:`rail-nowlabel`,"aria-hidden":`true`,children:`Now`}),s.placed.map(e=>{let t=o.get(e.id),r=t?.quota?Ge(t.quota.resetsAt):t?me(t,a):``,i=t?D(t):``,s=t?.quota?k(t.quota.resetsAt,a):null,c=t?.displayName??e.id,{cls:l,color:u}=We(t),d=e.positionPct<12?`pin-start`:e.positionPct>88?`pin-end`:``,f=e.tier>0?`tier${e.tier+1}`:`tier1`,p={"--pin-border":`color-mix(in oklch, ${u} 45%, var(--line))`};return(0,E.jsxs)(`button`,{"data-testid":`pin`,type:`button`,className:`pin ${e.band} ${f} ${d}`,style:{left:`${e.positionPct}%`,"--dot-color":u},"aria-label":`${c}: ${i}, resets ${r}`,onClick:()=>n(e.id),children:[e.band===`above`?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`span`,{className:`pin-when`,children:e.estimated?`${r} (est.)`:r}),(0,E.jsx)(`span`,{className:`pin-label ${l}`,style:p,children:c}),(0,E.jsx)(`span`,{className:`pin-stem`}),(0,E.jsx)(`span`,{className:`pin-dot`})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`span`,{className:`pin-dot`}),(0,E.jsx)(`span`,{className:`pin-stem`}),(0,E.jsx)(`span`,{className:`pin-label ${l}`,style:p,children:c}),(0,E.jsx)(`span`,{className:`pin-when`,children:e.estimated?`${r} (est.)`:r})]}),(0,E.jsxs)(`span`,{className:`pin-tooltip`,role:`tooltip`,children:[(0,E.jsx)(`b`,{children:c}),(0,E.jsx)(`span`,{className:`pt-sep`,children:`·`}),t?.quota?`${t.quota.usedPct}% used`:`no readings`,(0,E.jsx)(`span`,{className:`pt-sep`,children:`·`}),s?`${s} left`:r,e.estimated?` (est.)`:``]})]},e.id)}),s.clusters.map((e,t)=>{let n=e.positionPct<12?`pin-start`:e.positionPct>88?`pin-end`:``,a=e.tier>0?`tier${e.tier+1}`:`tier1`;return(0,E.jsx)(`button`,{"data-testid":`cluster-pin`,type:`button`,className:`pin ${e.band} ${a} ${n}`,style:{left:`${e.positionPct}%`,"--dot-color":`var(--accent)`},"aria-label":`${e.ids.length} resets at the same time: ${e.ids.map(e=>o.get(e)?.displayName??e).join(`, `)}`,"aria-expanded":r===t,onClick:()=>i(r===t?null:t),children:e.band===`above`?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`span`,{className:`pin-label`,style:{borderColor:`var(--accent)`,color:`var(--accent)`},children:[e.ids.length,` resets`]}),(0,E.jsx)(`span`,{className:`pin-stem`}),(0,E.jsx)(`span`,{className:`pin-dot`})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`span`,{className:`pin-dot`}),(0,E.jsx)(`span`,{className:`pin-stem`}),(0,E.jsxs)(`span`,{className:`pin-label`,style:{borderColor:`var(--accent)`,color:`var(--accent)`},children:[e.ids.length,` resets`]})]})},e.ids.join(`+`))}),r!==null&&s.clusters[r]&&(0,E.jsx)(He,{cluster:s.clusters[r],providers:o,asOfMs:a,onSelect:n,onClose:()=>i(null)}),(0,E.jsx)(`div`,{className:`rail-days`,"aria-hidden":`true`,children:c.map(e=>(0,E.jsx)(`span`,{children:e},e))})]})})]})}function Je(e){switch(e){case`not-reporting`:return`Not reporting yet.`;case`stale`:return`Stale — excluded from ranking.`;case`reset-passed`:return`Reset passed — awaiting a fresh window.`;case`invalid`:return`Reading invalid — excluded from ranking.`;case`provider-failed`:return`Provider failed — excluded from ranking.`;case null:return null}}function Ye(e){switch(e){case`auth`:return`Authentication failed`;case`timeout`:return`Timed out`;case`parse`:return`Unreadable output`;case`network`:return`Network error`;case`skipped`:return`Skipped`;case`unknown`:return`Unknown error`;case null:return null}}function Xe(e){let t=e.advisory,n={id:e.id,name:e.displayName,badge:D(e),burnRate:t?.burnRate??null,idealRate:t?t.idealRate:null,paceSource:t?t.paceSource:null,paceLabel:t&&t.burnMeasured?`Measured`:t&&t.paceSource===`window-average`?`Window avg`:null,daysLeft:t?t.daysLeft:null,daysToExhaust:t?.daysToExhaust??null,remaining:t?t.remaining:null,wastePct:t?.wastePct??null,periodStart:e.quota?e.quota.periodStart:null,resetsAt:e.quota?e.quota.resetsAt:null,estimatedReset:e.evidence.includes(`estimated-reset`),lastSuccessAt:e.lastSuccessAt,ageMs:e.ageMs,failureCategory:e.lastAttempt?.failureCategory??null,failureWords:Ye(e.lastAttempt?.failureCategory??null),evidence:[...e.evidence],exclusionReason:e.exclusionReason,exclusionWords:Je(e.exclusionReason)};return e.quota?.sessionPct!==void 0&&e.quota.sessionPct!==null&&(n.sessionPct=e.quota.sessionPct),n}function Ze(e){switch(e){case`cli`:return`Live CLI`;case`api`:return`Live API`;case`tui`:return`Live TUI`;case`scrape`:return`Live scrape`;case`manual`:return`Manual ingest`;default:return e||`unknown`}}function Qe(e,t){let n=e.advisory;if(!n||n.paceSource===`unknown`)return`No current reading`;let r=e.quota?Date.parse(e.quota.periodStart):NaN;if(Number.isFinite(r)&&Number.isFinite(t)&&t>r){let e=(t-r)/864e5;if(e>=.1)return`averaged over ${e.toFixed(1)} days of this window`}return e.evidence.includes(`measured`)||n.burnMeasured?`Measured`:n.paceSource===`window-average`||e.evidence.includes(`window-average`)?`Window avg`:`No current reading`}function $e(e){let t=e.quota?.source;return t===`cli`||t===`tui`?`handled by ${e.displayName}`:`not stored by QuotaCap`}function et(e){switch(D(e)){case`Behind pace`:return`behind`;case`On track`:return`ontrack`;case`Ahead of pace`:return`ahead`;case`Cap risk`:return`cap`;case`Not reporting`:return`out`}}function tt(e){if(!e.quota)return null;let t=O(e.quota.resetsAt);return t?`${t}${pe(e)?` (est.)`:``}`:null}function nt(e,t){let n=tt(e);if(!n||!e.quota)return null;let r=k(e.quota.resetsAt,t);return r?`Resets ${n} · in ${r}`:`Resets ${n}`}function rt(e,t){let n=e.displayName,r=e.quota,i=e.advisory,a=tt(e),o=r?`${n} reports ${r.usedPct}% of quota used.${a?` Resets ${a}.`:``}`:`No reading yet.`,s;s=!i||i.paceSource===`unknown`||i.burnRate===null?it(e)??`No current pace.`:i.status===`at risk`?`${i.burnRate.toFixed(1)}%/day so far this window, against a ${i.idealRate.toFixed(1)}%/day target.`:`${i.burnRate.toFixed(1)}%/day so far this window. Finishing it needs ${i.idealRate.toFixed(1)}%/day.`;let c;return c=e.exclusionReason?`Excluded before ranking.`:t&&t.use===e.id&&t.reason?t.reason:i?.status===`at risk`?`Forecast to hit the cap before reset; flagged to ease off.`:i?.urgency===`slow down`?`Burning faster than the window; ease off.`:i?.urgency===`on track`?`Pace matches the window.`:`Unused quota in this reset window.`,{known:o,pace:s,decision:c}}function it(e){let t=Ye(e.lastAttempt?.failureCategory??null);return t?`No current pace. ${t}.`:null}function at(e,t){let n=e.quota,{elapsedPct:r}=he(e,t);return{provider:e.id,plan:n?.plan?n.plan.split(` · `)[0]:null,usedPct:n?.usedPct??null,elapsedPct:r===null?null:Math.round(r),resetsAt:n?.resetsAt??null,source:n?.source??null,pacingStatus:et(e),reporting:e.reporting}}async function ot(e,t,n){let r=t.trim(),i=r.length===0?null:r;try{return await n(e,i),{success:!0,error:null}}catch(e){return{success:!1,error:e.message||`Failed to update display name`}}}function st({provider:e,asOf:t,recommendation:n,onClose:r,onRenamed:i,renameAction:a}){let o=(0,_.useRef)(null),s=(0,_.useRef)(null),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(e?.displayName??``),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null);(0,_.useEffect)(()=>{e&&(d(e.displayName),l(!1),h(null))},[e?.id,e?.displayName]),(0,_.useEffect)(()=>{if(!e)return;s.current=document.activeElement,o.current?.focus();let t=e=>{if(e.key===`Escape`){r();return}if(e.key!==`Tab`||!o.current)return;let t=[...o.current.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)].filter(e=>!e.hasAttribute(`disabled`));if(t.length===0)return;let n=t[0],i=t[t.length-1],a=document.activeElement===n||document.activeElement===o.current;e.shiftKey&&a?(e.preventDefault(),i.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),n.focus())};return document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`keydown`,t),s.current?.focus?.()}},[e,r]);let g=async t=>{if(t.preventDefault(),!e)return;p(!0),h(null);let n=await ot(e.id,u,a??ne);n.success?(l(!1),i?.()):h(n.error),p(!1)},[v,y]=(0,_.useState)(!1);if(!e)return null;let b=Xe(e),x=`provider-drawer-title`,S=Date.parse(t),C=ce(b.ageMs),w=nt(e,S),ee=rt(e,n),te=at(e,S),T=JSON.stringify(te,null,2),re=[e.quota?.plan,Ze(e.quota?.source)].filter(e=>e&&e!==`unknown`).join(` · `);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{"data-testid":`drawer-scrim`,className:`scrim is-open`,"aria-hidden":`true`,onClick:r}),(0,E.jsxs)(`aside`,{ref:o,tabIndex:-1,"data-testid":`provider-drawer`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":x,className:`drawer is-open`,onClick:e=>e.stopPropagation(),children:[(0,E.jsxs)(`div`,{className:`drawer-head`,children:[(0,E.jsx)(`span`,{className:`picon`,style:Te(e.id),children:(0,E.jsx)(we,{id:e.id,title:b.name})}),(0,E.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,E.jsxs)(`h2`,{id:x,onClick:c?void 0:()=>l(!0),title:c?void 0:`Click to rename`,style:c?{position:`absolute`,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,border:0}:{cursor:`pointer`,display:`inline-flex`,alignItems:`center`,gap:`var(--s1)`},children:[(0,E.jsx)(`span`,{children:b.name}),!c&&(0,E.jsx)(`button`,{type:`button`,className:`btn-icon`,"aria-label":`Rename ${b.name}`,onClick:e=>{e.stopPropagation(),l(!0)},style:{background:`none`,border:`none`,padding:`2px`,cursor:`pointer`,color:`var(--ink-soft)`,display:`inline-flex`,verticalAlign:`middle`},children:(0,E.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z`})})})]}),c&&(0,E.jsxs)(`form`,{onSubmit:g,style:{display:`flex`,flexDirection:`column`,gap:`var(--s1)`,marginBottom:`var(--s2)`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`var(--s2)`},children:[(0,E.jsx)(`input`,{type:`text`,value:u,onChange:e=>d(e.target.value),onKeyDown:t=>{t.key===`Escape`&&(t.stopPropagation(),l(!1),d(e.displayName),h(null))},autoFocus:!0,maxLength:32,placeholder:e.builtinName??e.id,"aria-label":`Provider display name`,style:{font:`inherit`,fontSize:`var(--t-4)`,fontWeight:600,padding:`4px 8px`,borderRadius:`var(--r-sm)`,border:`1px solid var(--line)`,background:`var(--surface)`,color:`var(--ink)`,width:`100%`,maxWidth:`240px`}}),(0,E.jsx)(`button`,{type:`submit`,disabled:f,className:`btn btn-sm`,style:{flex:`none`},children:f?`Saving...`:`Save`}),(0,E.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>{l(!1),d(e.displayName),h(null)},className:`btn btn-quiet btn-sm`,style:{flex:`none`},children:`Cancel`})]}),m&&(0,E.jsx)(`span`,{style:{fontSize:`var(--t-2)`,color:`var(--danger)`},children:m})]}),e.builtinName&&e.displayName!==e.builtinName&&(0,E.jsx)(`div`,{className:`sub`,style:{marginTop:`2px`},"data-testid":`provider-builtin-name`,children:`Built-in: ${e.builtinName}`}),(0,E.jsx)(`span`,{className:`sub`,children:ie(e)??re})]}),(0,E.jsx)(`button`,{className:`drawer-close`,type:`button`,"aria-label":`Close provider details`,onClick:r,children:(0,E.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M6 6l12 12M18 6L6 18`})})})]}),e.description&&(0,E.jsx)(`p`,{style:{margin:`0 var(--s4) var(--s3)`,fontSize:`var(--t-2)`,color:`var(--ink-soft)`},children:e.description}),(0,E.jsxs)(`section`,{className:`dsec`,"aria-label":`Current window`,children:[(0,E.jsx)(`h3`,{children:`Current window`}),(0,E.jsx)(`div`,{className:`pcard-topline`,children:(0,E.jsx)(ye,{provider:e})}),e.quota?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(be,{provider:e,asOf:t}),w&&(0,E.jsx)(`div`,{className:`pcard-underline`,children:w})]}):(0,E.jsx)(`p`,{className:`cell-s`,children:`No readings yet.`})]}),b.sessionPct!==void 0&&b.sessionPct>0&&(0,E.jsxs)(`section`,{className:`dsec`,"aria-label":`Session`,children:[(0,E.jsx)(`h3`,{children:`Session`}),(0,E.jsx)(`div`,{className:`pcard-topline`,children:(0,E.jsxs)(`span`,{className:`used`,children:[b.sessionPct,`% used`]})}),(0,E.jsx)(`div`,{className:`track`,role:`img`,"aria-label":`${b.sessionPct} percent of session window used`,children:(0,E.jsx)(`div`,{className:`fill`,style:{width:`${Math.min(100,Math.max(0,b.sessionPct))}%`,background:`var(--fill-ontrack)`,"--fill-edge":`var(--edge-ontrack)`}})})]}),(0,E.jsxs)(`section`,{className:`dsec`,"aria-label":`Adapter and provenance`,children:[(0,E.jsx)(`h3`,{children:`Adapter and provenance`}),(0,E.jsxs)(`dl`,{className:`dkv`,children:[(0,E.jsx)(`dt`,{children:`Read by`}),(0,E.jsx)(`dd`,{children:Ze(e.quota?.source)}),(0,E.jsx)(`dt`,{children:`Credential`}),(0,E.jsx)(`dd`,{children:$e(e)}),(0,E.jsx)(`dt`,{children:`Window`}),(0,E.jsx)(`dd`,{children:[e.quota?.plan&&e.quota.plan!==`unknown`?e.quota.plan:null,tt(e)?`resets ${tt(e)}`:null].filter(Boolean).join(` · `)||`—`}),(0,E.jsx)(`dt`,{children:`Pace basis`}),(0,E.jsx)(`dd`,{children:Qe(e,S)}),(0,E.jsx)(`dt`,{children:`Last read`}),(0,E.jsxs)(`dd`,{children:[C?`${C} ago`:`unknown`,b.failureWords?` · ${b.failureWords}`:``]})]}),(0,E.jsxs)(`div`,{className:`draw-code-head`,children:[(0,E.jsx)(`span`,{className:`cell-s`,children:`Raw JSON snapshot:`}),(0,E.jsx)(`button`,{className:`btn btn-quiet btn-sm`,type:`button`,onClick:()=>{navigator.clipboard?.writeText(T).then(()=>{y(!0),setTimeout(()=>y(!1),1500)}).catch(()=>{})},children:v?`Copied!`:`Copy JSON`})]}),(0,E.jsx)(`pre`,{className:`draw-code`,children:T})]}),(0,E.jsxs)(`section`,{className:`dsec`,"aria-label":`Ranking rationale`,children:[(0,E.jsx)(`h3`,{children:`Ranking rationale`}),(0,E.jsxs)(`div`,{className:`why-block`,children:[(0,E.jsx)(`b`,{children:`Known`}),(0,E.jsx)(`span`,{children:ee.known})]}),(0,E.jsxs)(`div`,{className:`why-block`,children:[(0,E.jsx)(`b`,{children:`Pace`}),(0,E.jsx)(`span`,{children:ee.pace})]}),(0,E.jsxs)(`div`,{className:`why-block`,children:[(0,E.jsx)(`b`,{children:`Decision`}),(0,E.jsx)(`span`,{children:ee.decision})]})]})]})]})}function ct({open:e,recommendation:t,providers:n,asOf:r,onClose:i}){let a=(0,_.useRef)(null),o=(0,_.useRef)(null);if((0,_.useEffect)(()=>{if(!e)return;o.current=document.activeElement,a.current?.focus();let t=e=>{if(e.key===`Escape`){i();return}if(e.key!==`Tab`||!a.current)return;let t=[...a.current.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)].filter(e=>!e.hasAttribute(`disabled`));if(t.length===0)return;let n=t[0],r=t[t.length-1],o=document.activeElement===n||document.activeElement===a.current;e.shiftKey&&o?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())};return document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`keydown`,t),o.current?.focus?.()}},[e,i]),!e)return null;let s=Date.parse(r),{useMore:c,easeOff:l}=De(t.advisories,n),u=t.use===`none`?c[0]?.provider:t.use,d=u?n.find(e=>e.id===u):void 0,f=d?d.displayName:null,p=d?.advisory?.remaining!==null&&d?.advisory?.remaining!==void 0?Math.round(d.advisory.remaining):null,m=t.wastePct===null?d?.advisory?.wastePct!==null&&d?.advisory?.wastePct!==void 0?Math.round(d.advisory.wastePct):null:Math.round(t.wastePct),h=d?.quota?k(d.quota.resetsAt,s):null,g=c.filter(e=>e.provider!==u),v=`advice-drawer-title`;return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{"data-testid":`advice-scrim`,className:`scrim is-open`,"aria-hidden":`true`,onClick:i}),(0,E.jsxs)(`aside`,{ref:a,tabIndex:-1,"data-testid":`advice-drawer`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":v,className:`drawer is-open`,onClick:e=>e.stopPropagation(),children:[(0,E.jsxs)(`div`,{className:`drawer-head`,children:[(0,E.jsx)(`span`,{className:`picon rec-picon`,"aria-hidden":`true`,children:(0,E.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,E.jsx)(`path`,{d:`m12 3-1.9 5.8a2 2 0 0 1-1.3 1.3L3 12l5.8 1.9a2 2 0 0 1 1.3 1.3L12 21l1.9-5.8a2 2 0 0 1 1.3-1.3L21 12l-5.8-1.9a2 2 0 0 1-1.3-1.3z`})})}),(0,E.jsxs)(`div`,{style:{flex:1},children:[(0,E.jsx)(`h2`,{id:v,children:`Quota Advice & Pacing`}),(0,E.jsx)(`span`,{className:`sub`,children:`Actionable recommendations based on quota pacing & reset schedules`})]}),(0,E.jsx)(`button`,{className:`drawer-close`,type:`button`,"aria-label":`Close advice`,onClick:i,children:(0,E.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M6 6l12 12M18 6L6 18`})})})]}),(0,E.jsxs)(`div`,{className:`dsec`,children:[(0,E.jsx)(`h3`,{children:`Recommended for next session`}),d&&f?(0,E.jsxs)(`div`,{className:`advice-card`,style:{marginTop:8},children:[(0,E.jsxs)(`div`,{className:`advice-card-main`,children:[(0,E.jsxs)(`div`,{className:`advice-card-lead`,children:[(0,E.jsx)(`span`,{className:`sq`,style:Te(d.id),children:(0,E.jsx)(we,{id:d.id,title:f,size:16})}),(0,E.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,E.jsx)(`span`,{className:`name`,children:f}),(0,E.jsxs)(`span`,{className:`recommended-badge`,children:[(0,E.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`m12 3-1.9 5.8a2 2 0 0 1-1.3 1.3L3 12l5.8 1.9a2 2 0 0 1 1.3 1.3L12 21l1.9-5.8a2 2 0 0 1 1.3-1.3L21 12l-5.8-1.9a2 2 0 0 1-1.3-1.3z`})}),`Recommended`]})]})]}),m!==null&&h&&(0,E.jsxs)(`div`,{className:`advice-card-stats`,children:[(0,E.jsxs)(`b`,{children:[m,`%`]}),` unused quota expires in `,(0,E.jsx)(`b`,{children:h})]})]}),(0,E.jsx)(`p`,{className:`advice-card-body`,children:p!==null&&h&&m!==null?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`b`,{children:f}),` has `,p,`% quota remaining with its reset window closing in `,h,`. Current pacing projects `,m,`% unused quota at reset. Using this subscription now avoids unused quota expiration.`]}):t.reason})]}):(0,E.jsx)(`p`,{className:`advice-card-body`,children:t.reason})]}),(0,E.jsxs)(`div`,{className:`dsec`,children:[(0,E.jsx)(`h3`,{children:`Fleet Pacing Breakdown`}),(0,E.jsxs)(`dl`,{className:`dkv`,children:[(0,E.jsx)(`dt`,{children:`Use more`}),(0,E.jsx)(`dd`,{children:g.length?g.map((e,t)=>{let r=n.find(t=>t.id===e.provider),i=e.wastePct===null?null:`${Math.round(e.wastePct)}% unused`,a=r?.quota?k(r.quota.resetsAt,s):null,o=[i,a?`resets in ${a}`:null].filter(Boolean).join(` · `);return(0,E.jsxs)(`span`,{children:[t>0?`, `:``,(0,E.jsx)(`b`,{children:r?.displayName??e.provider}),o?` (${o})`:``]},e.provider)}):`None`}),(0,E.jsx)(`dt`,{children:`Ease off`}),(0,E.jsx)(`dd`,{children:l.length?l.map((e,t)=>{let r=n.find(t=>t.id===e.provider),i=r?D(r):e.urgency;return(0,E.jsxs)(`span`,{children:[t>0?`, `:``,(0,E.jsx)(`b`,{children:r?.displayName??e.provider}),` (`,i,`)`]},e.provider)}):`None`})]})]}),(0,E.jsxs)(`div`,{className:`dsec`,children:[(0,E.jsx)(`h3`,{children:`CLI Command`}),(0,E.jsx)(`p`,{style:{fontSize:`var(--t-2)`,color:`var(--ink-soft)`,marginBottom:8},children:`Equivalent terminal command:`}),(0,E.jsx)(`pre`,{className:`advice-cli`,children:(0,E.jsx)(`code`,{children:`$ quotacap advise`})})]})]})]})}function lt(e){return e.filter(e=>e.harness!==null)}var ut=new Map([[`claude`,`Claude Code`],[`codex`,`Codex`],[`kimi`,`Kimi Code`],[`grok`,`Grok`],[`agy`,`Antigravity`],[`agy:3p`,`Antigravity 3P`]]);function dt(e){return ut.get(e)??e}function ft(e){let t=pt(e),n=ce(e.ageMs);return n?`${t} · ${n} ago`:t}function pt(e){switch(e.exclusionReason){case`stale`:return`Stale`;case`provider-failed`:return`Failed`;case`invalid`:return`Invalid`;case`reset-passed`:return`Reset passed`;case`not-reporting`:return`Not reporting`;case null:return e.lastAttempt&&!e.lastAttempt.success?`Failed`:`Ready`}}function mt({providers:e,onRefresh:t,refreshing:n}){let r=lt(e);return(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:`var(--s3)`},children:[(0,E.jsx)(`h3`,{style:{fontSize:`var(--t-3)`,fontWeight:700,margin:0},children:`Active Tool Connections`}),(0,E.jsx)(`button`,{type:`button`,className:`btn btn-quiet`,onClick:t,disabled:n,style:{fontSize:`var(--t-1)`,padding:`4px 8px`},children:n?`Polling…`:`Re-poll adapters`})]}),(0,E.jsx)(`div`,{style:{border:`1px solid var(--line)`,borderRadius:`var(--r-md)`,overflow:`hidden`,background:`var(--surface)`,marginBottom:`var(--s5)`},children:r.map((e,t)=>{let n=pt(e)===`Ready`;return(0,E.jsxs)(`div`,{style:{padding:`10px 14px`,borderBottom:t<r.length-1?`1px solid var(--line)`:`none`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`b`,{style:{fontSize:`var(--t-3)`},children:dt(e.id)}),(0,E.jsx)(`span`,{style:{display:`block`,fontSize:`var(--t-1)`,color:`var(--ink-soft)`},children:Ze(e.quota?.source)})]}),(0,E.jsx)(`span`,{className:n?`st-ready`:`st-todo`,style:{fontSize:`var(--t-1)`,padding:`2px 8px`,borderRadius:999,background:n?`var(--good-soft)`:`var(--warn-soft)`,border:`1px solid ${n?`var(--good)`:`var(--warn)`}`,color:n?`var(--good)`:`var(--warn)`,fontWeight:600},children:ft(e)})]},e.id)})})]})}function ht(){return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h3`,{style:{fontSize:`var(--t-3)`,fontWeight:700,margin:`0 0 var(--s2)`},children:`Shell Prompt Integration`}),(0,E.jsx)(`p`,{style:{fontSize:`var(--t-2)`,color:`var(--ink-soft)`,margin:`0 0 var(--s3)`},children:`Display active quota headroom in your shell prompt or multiplexer statusline:`}),(0,E.jsxs)(`div`,{style:{marginBottom:`var(--s4)`},children:[(0,E.jsxs)(`b`,{style:{fontSize:`var(--t-2)`,display:`block`,marginBottom:4},children:[`Starship Prompt (`,(0,E.jsx)(`code`,{children:`starship.toml`}),`):`]}),(0,E.jsx)(`pre`,{style:{background:`var(--canvas)`,padding:`8px 12px`,border:`1px solid var(--line)`,borderRadius:`var(--r-sm)`,fontFamily:`var(--font-mono)`,fontSize:`var(--t-1)`,margin:0,overflowX:`auto`},children:`[custom.quotacap]
10
10
  command = "quotacap status --compact"
11
11
  when = "command -v quotacap"
12
- format = "[$output]($style) "`})]}),(0,E.jsxs)(`div`,{style:{marginBottom:`var(--s4)`},children:[(0,E.jsxs)(`b`,{style:{fontSize:`var(--t-2)`,display:`block`,marginBottom:4},children:[`tmux (`,(0,E.jsx)(`code`,{children:`~/.tmux.conf`}),`):`]}),(0,E.jsx)(`pre`,{style:{background:`var(--canvas)`,padding:`8px 12px`,border:`1px solid var(--line)`,borderRadius:`var(--r-sm)`,fontFamily:`var(--font-mono)`,fontSize:`var(--t-1)`,margin:0,overflowX:`auto`},children:`set -g status-right '#(quotacap status --compact)'`})]}),(0,E.jsxs)(`div`,{style:{marginBottom:`var(--s4)`},children:[(0,E.jsxs)(`b`,{style:{fontSize:`var(--t-2)`,display:`block`,marginBottom:4},children:[`Bash / Zsh (`,(0,E.jsx)(`code`,{children:`~/.zshrc`}),`):`]}),(0,E.jsx)(`pre`,{style:{background:`var(--canvas)`,padding:`8px 12px`,border:`1px solid var(--line)`,borderRadius:`var(--r-sm)`,fontFamily:`var(--font-mono)`,fontSize:`var(--t-1)`,margin:0,overflowX:`auto`},children:`export PS1='$(quotacap status --compact) '$PS1`})]}),(0,E.jsxs)(`div`,{style:{borderTop:`1px solid var(--line)`,paddingTop:`var(--s3)`},children:[(0,E.jsx)(`b`,{style:{fontSize:`var(--t-2)`,display:`block`,marginBottom:4},children:`CLI Status Commands:`}),(0,E.jsx)(`p`,{style:{fontSize:`var(--t-2)`,color:`var(--ink-soft)`,margin:`0 0 6px`},children:`Run status in terminal with custom sorting and ASCII fallbacks:`}),(0,E.jsx)(`code`,{style:{display:`block`,fontSize:`var(--t-1)`,background:`var(--canvas)`,padding:`6px 10px`,borderRadius:`var(--r-sm)`,border:`1px solid var(--line)`,marginBottom:4},children:`quotacap status --sort reset-asc`}),(0,E.jsx)(`code`,{style:{display:`block`,fontSize:`var(--t-1)`,background:`var(--canvas)`,padding:`6px 10px`,borderRadius:`var(--r-sm)`,border:`1px solid var(--line)`},children:`quotacap status --ascii`})]})]})}function gt(){try{return window.location.port||null}catch{return null}}function _t(){let e=gt();return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h3`,{style:{fontSize:`var(--t-3)`,fontWeight:700,margin:`0 0 var(--s2)`},children:`Local Daemon Process`}),(0,E.jsx)(`p`,{style:{fontSize:`var(--t-2)`,color:`var(--ink-soft)`,margin:`0 0 var(--s4)`},children:`Background process managing provider adapters and SQLite store.`}),(0,E.jsxs)(`div`,{style:{display:`grid`,gap:`var(--s2)`,fontSize:`var(--t-2)`,marginBottom:`var(--s4)`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,padding:`8px 0`,borderBottom:`1px solid var(--line)`},children:[(0,E.jsx)(`span`,{style:{color:`var(--ink-soft)`},children:`HTTP Service`}),(0,E.jsxs)(`code`,{children:[`127.0.0.1:`,e??`8787`]})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,padding:`8px 0`,borderBottom:`1px solid var(--line)`},children:[(0,E.jsx)(`span`,{style:{color:`var(--ink-soft)`},children:`Polling Cadence`}),(0,E.jsx)(`span`,{children:`Every 15 minutes (default)`})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,padding:`8px 0`,borderBottom:`1px solid var(--line)`},children:[(0,E.jsx)(`span`,{style:{color:`var(--ink-soft)`},children:`Storage Engine`}),(0,E.jsx)(`span`,{children:`SQLite`})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,padding:`8px 0`,borderBottom:`1px solid var(--line)`},children:[(0,E.jsx)(`span`,{style:{color:`var(--ink-soft)`},children:`Database File`}),(0,E.jsx)(`code`,{children:`~/.quotacap/quotacap.db`})]})]}),(0,E.jsxs)(`div`,{style:{display:`grid`,gap:`var(--s3)`,background:`var(--surface-raised)`,padding:`var(--s4)`,borderRadius:`var(--r-md)`,border:`1px solid var(--line)`},children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{style:{fontSize:`var(--t-2)`,fontWeight:600,display:`block`,marginBottom:4},children:`HTTP port`}),(0,E.jsx)(`input`,{type:`number`,value:e??`8787`,placeholder:`8787`,disabled:!0,"aria-label":`Daemon HTTP port (read-only)`,style:{width:`100%`,boxSizing:`border-box`,font:`inherit`,fontSize:`var(--t-2)`,padding:`6px 10px`,borderRadius:`var(--r-sm)`,border:`1px solid var(--line)`,background:`var(--surface)`,color:`var(--ink-soft)`}}),e&&(0,E.jsxs)(`p`,{style:{fontSize:`var(--t-1)`,color:`var(--ink-soft)`,margin:`4px 0 0`},children:[`This dashboard is served from port `,e,`.`]})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{style:{fontSize:`var(--t-2)`,fontWeight:600,display:`block`,marginBottom:4},children:`Poll cadence (minutes)`}),(0,E.jsx)(`input`,{type:`number`,value:`15`,placeholder:`15`,disabled:!0,"aria-label":`Background poll cadence in minutes (read-only)`,style:{width:`100%`,boxSizing:`border-box`,font:`inherit`,fontSize:`var(--t-2)`,padding:`6px 10px`,borderRadius:`var(--r-sm)`,border:`1px solid var(--line)`,background:`var(--surface)`,color:`var(--ink-soft)`}})]})]}),(0,E.jsxs)(`p`,{style:{fontSize:`var(--t-1)`,color:`var(--ink-soft)`,marginTop:`var(--s3)`},children:[`Change the port and polling cadence in `,(0,E.jsx)(`code`,{children:`~/.quotacap/config.json`}),` (`,(0,E.jsx)(`code`,{children:`port`}),`,`,` `,(0,E.jsx)(`code`,{children:`pollMinutes`}),`; defaults 8787 and 15), then restart the daemon. These controls stay read-only until the server offers a settings API.`]})]})}var vt=[{id:`providers`,label:`Providers`},{id:`cli`,label:`CLI & Shell`},{id:`daemon`,label:`Daemon`}];function yt({open:e,providers:t,onRefresh:n,refreshing:r,onClose:i}){let[a,o]=(0,_.useState)(`providers`),s=(0,_.useRef)(null),c=(0,_.useRef)(null);if((0,_.useEffect)(()=>{if(!e)return;c.current=document.activeElement,s.current?.focus();let t=e=>{if(e.key===`Escape`){i();return}if(e.key!==`Tab`||!s.current)return;let t=[...s.current.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)].filter(e=>!e.hasAttribute(`disabled`));if(t.length===0)return;let n=t[0],r=t[t.length-1],a=document.activeElement===n||document.activeElement===s.current;e.shiftKey&&a?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())};return document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`keydown`,t),c.current?.focus?.()}},[e,i]),!e)return null;let l=`settings-drawer-title`;return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{"data-testid":`settings-scrim`,className:`scrim is-open`,"aria-hidden":`true`,onClick:i}),(0,E.jsxs)(`aside`,{ref:s,tabIndex:-1,"data-testid":`settings-drawer`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":l,className:`drawer is-open`,style:{width:`min(580px, 100vw)`},onClick:e=>e.stopPropagation(),children:[(0,E.jsxs)(`div`,{className:`drawer-head`,children:[(0,E.jsxs)(`div`,{style:{flex:1},children:[(0,E.jsx)(`h2`,{id:l,style:{margin:`0 0 2px`},children:`Settings & Configuration`}),(0,E.jsx)(`span`,{className:`sub`,children:`Connected provider adapters and CLI prompt integration.`})]}),(0,E.jsx)(`button`,{className:`drawer-close`,type:`button`,"aria-label":`Close settings`,onClick:i,children:(0,E.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M6 6l12 12M18 6L6 18`})})})]}),(0,E.jsx)(`div`,{className:`seg`,role:`tablist`,"aria-label":`Settings sections`,style:{margin:`var(--s4) var(--s5) 0`,display:`flex`,height:32},children:vt.map(e=>(0,E.jsx)(`button`,{type:`button`,role:`tab`,className:`settings-tab${a===e.id?` is-active`:``}`,"aria-selected":a===e.id,onClick:()=>o(e.id),style:{flex:1,justifyContent:`center`},children:e.label},e.id))}),(0,E.jsxs)(`div`,{role:`tabpanel`,style:{padding:`var(--s4) var(--s5) var(--s6)`,overflowY:`auto`},children:[a===`providers`&&(0,E.jsx)(mt,{providers:t,onRefresh:n,refreshing:r}),a===`cli`&&(0,E.jsx)(ht,{}),a===`daemon`&&(0,E.jsx)(_t,{})]})]})]})}function bt(e,t){return t?`/setup`:`/`}function xt(){try{return window.location.pathname||`/`}catch{return`/`}}function St(e){window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))}function Ct(){let[e,t]=(0,_.useState)(()=>xt());return(0,_.useEffect)(()=>{let e=()=>t(xt());return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]),e}function wt(e){let t=e.displayName,n=e.id===`agy:3p`?`Antigravity`:t;if(e.exclusionReason===null&&e.quota){let t=ce(e.ageMs);return{status:`Ready`,detail:t?`Last read ${t} ago.`:`Reporting.`}}if(e.lastAttempt?.success&&e.lastAttempt.succeededAt)return{status:`Ready`,detail:`Connected — no readings yet.`};let r=`QuotaCap never handles those credentials.`;return e.harness===null?{status:`Sign in first`,detail:`QuotaCap has no live adapter for ${t}. Use manual ingest via the CLI to add readings.`}:e.lastAttempt?.failureCategory===`auth`?{status:`Sign in first`,detail:`Sign in to the ${n} CLI, then re-poll. ${r}`}:e.lastAttempt?{status:`Sign in first`,detail:`${Ye(e.lastAttempt.failureCategory)??`Last attempt failed`} — check the ${n} CLI, then re-poll. ${r}`}:{status:`Sign in first`,detail:`Install the ${n} CLI and sign in, then run the first poll. ${r}`}}function Tt({providers:e}){return(0,E.jsx)(`div`,{className:`provlist`,children:e.map(e=>{let t=wt(e),n=t.status===`Ready`;return(0,E.jsxs)(`div`,{className:`provrow`,children:[(0,E.jsx)(`b`,{children:e.displayName}),(0,E.jsx)(`span`,{className:`path`,children:t.detail}),(0,E.jsxs)(`span`,{className:n?`st-ready`:`st-todo`,children:[n?(0,E.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M20 6L9 17l-5-5`})}):(0,E.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,E.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,E.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),t.status]})]},e.id)})})}function Et(){return(0,E.jsxs)(`div`,{className:`preview`,"aria-label":`Sample payoff preview`,children:[(0,E.jsxs)(`div`,{className:`preview-head`,style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:`var(--s3)`},children:[(0,E.jsx)(`span`,{style:{fontWeight:600},children:`What your first result will show`}),(0,E.jsx)(`span`,{className:`chip-sample`,style:{fontSize:`var(--t-1)`,padding:`2px 8px`,borderRadius:999,background:`var(--surface-raised)`,border:`1px solid var(--line-strong)`,fontWeight:600,color:`var(--ink-soft)`},children:`Sample data`})]}),(0,E.jsxs)(`div`,{className:`trackwrap`,children:[(0,E.jsxs)(`div`,{className:`tline`,style:{display:`flex`,justifyContent:`space-between`,fontSize:`var(--t-2)`,marginBottom:4},children:[(0,E.jsx)(`span`,{className:`used`,style:{fontWeight:600},children:`Kimi Code · 22% used`}),(0,E.jsx)(`span`,{className:`gap`,style:{color:`var(--ink-soft)`},children:`61 points behind pace`})]}),(0,E.jsxs)(`div`,{className:`track`,role:`img`,"aria-label":`Sample: 22 percent of quota used, 83 percent of the window elapsed`,children:[(0,E.jsx)(`div`,{className:`fill`,style:{width:`22%`,background:`var(--fill-behind)`,borderRight:`1px solid var(--edge-behind)`}}),(0,E.jsx)(`div`,{className:`mark`,style:{left:`83%`}})]}),(0,E.jsxs)(`div`,{className:`tfoot`,style:{display:`flex`,justifyContent:`space-between`,fontSize:`var(--t-1)`,color:`var(--ink-faint)`,marginTop:4},children:[(0,E.jsx)(`span`,{children:`start`}),(0,E.jsx)(`span`,{children:`time elapsed: 83%`}),(0,E.jsx)(`span`,{children:`reset`})]})]}),(0,E.jsx)(`p`,{style:{fontSize:`var(--t-2)`,color:`var(--ink-soft)`,margin:`var(--s3) 0 0`},children:`Switch to Kimi next — 67% waste in 1.2d`})]})}function Dt({snapshot:e,onFirstPoll:t,polling:n,pollError:r}){let[i,a]=(0,_.useState)(1);return(0,E.jsxs)(`div`,{"data-testid":`setup-root`,style:{maxWidth:960,margin:`0 auto`,padding:`var(--s5) var(--s4) 56px`},children:[(0,E.jsx)(`p`,{className:`eyebrow`,style:{marginBottom:`var(--s1)`},children:`First run & accounts`}),(0,E.jsx)(`h1`,{style:{fontSize:`var(--t-6)`,letterSpacing:`-0.024em`,margin:`0 0 var(--s5)`,fontWeight:700},children:`Connect the subscriptions you already use`}),(0,E.jsxs)(`div`,{className:`setup`,children:[(0,E.jsxs)(`ol`,{className:`steps`,children:[(0,E.jsxs)(`li`,{className:i===1?`is-now`:``,"aria-current":i===1?`step`:void 0,children:[(0,E.jsx)(`span`,{className:`num`,children:`1`}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`span`,{className:`t`,children:`Detect`}),(0,E.jsx)(`span`,{className:`d`,children:`Find installed coding tools`})]})]}),(0,E.jsxs)(`li`,{className:i===2?`is-now`:``,"aria-current":i===2?`step`:void 0,children:[(0,E.jsx)(`span`,{className:`num`,children:`2`}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`span`,{className:`t`,children:`Review`}),(0,E.jsx)(`span`,{className:`d`,children:`Check what each adapter reads`})]})]}),(0,E.jsxs)(`li`,{className:i===3?`is-now`:``,"aria-current":i===3?`step`:void 0,children:[(0,E.jsx)(`span`,{className:`num`,children:`3`}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`span`,{className:`t`,children:`Start`}),(0,E.jsx)(`span`,{className:`d`,children:`Read current usage once`})]})]})]}),(0,E.jsxs)(`div`,{className:`panel`,children:[i===1&&(0,E.jsxs)(`section`,{"data-testid":`setup-step-1`,"aria-label":`Step 1: Detect`,children:[(0,E.jsxs)(`div`,{className:`panel-head`,children:[(0,E.jsx)(`p`,{className:`eyebrow`,children:`Step 1 of 3`}),(0,E.jsx)(`h2`,{children:`What the daemon can see`}),(0,E.jsx)(`p`,{children:`QuotaCap asked the running daemon what it knows. The dashboard cannot scan this machine from the browser, so anything missing here needs the provider CLI installed and signed in first.`}),(0,E.jsxs)(`div`,{className:`privacy`,children:[(0,E.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`var(--good)`,strokeWidth:`2.2`,style:{flex:`none`},"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M12 3l7 3v5c0 5-3 8-7 10-4-2-7-5-7-10V6z`}),(0,E.jsx)(`path`,{d:`M9 12l2 2 4-4`})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`b`,{children:`Usage history stays on this machine`}),(0,E.jsx)(`span`,{children:`QuotaCap reads quota percentages and reset times only. It never accesses code, prompts, or sensitive files.`})]})]})]}),(0,E.jsx)(Tt,{providers:e.providers}),(0,E.jsxs)(`div`,{className:`panel-foot`,children:[(0,E.jsx)(`span`,{style:{fontSize:`var(--t-2)`,color:`var(--ink-soft)`},children:`You can add, disable, or repair providers at any time.`}),(0,E.jsx)(`button`,{className:`btn btn-primary`,type:`button`,onClick:()=>a(2),children:`Continue to review`})]})]}),i===2&&(0,E.jsxs)(`section`,{"data-testid":`setup-step-2`,"aria-label":`Step 2: Review`,children:[(0,E.jsxs)(`div`,{className:`panel-head`,children:[(0,E.jsx)(`p`,{className:`eyebrow`,children:`Step 2 of 3`}),(0,E.jsx)(`h2`,{children:`Review accounts`}),(0,E.jsx)(`p`,{children:`QuotaCap reads usage through your own provider CLIs. It never asks for, stores, or transmits your provider credentials — sign-in happens in the provider CLI itself, not here.`}),(0,E.jsxs)(`div`,{className:`privacy`,children:[(0,E.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`var(--good)`,strokeWidth:`2.2`,style:{flex:`none`},"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M12 3l7 3v5c0 5-3 8-7 10-4-2-7-5-7-10V6z`}),(0,E.jsx)(`path`,{d:`M9 12l2 2 4-4`})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`b`,{children:`Zero credential storage`}),(0,E.jsx)(`span`,{children:`Authentication stays in official CLI keychains. QuotaCap never handles or persists tokens.`})]})]})]}),(0,E.jsx)(Tt,{providers:e.providers}),(0,E.jsxs)(`div`,{className:`panel-foot`,children:[(0,E.jsx)(`button`,{className:`btn btn-quiet`,type:`button`,onClick:()=>a(1),children:`Back`}),(0,E.jsx)(`button`,{className:`btn btn-primary`,type:`button`,onClick:()=>a(3),children:`Continue to first poll`})]})]}),i===3&&(0,E.jsxs)(`section`,{"data-testid":`setup-step-3`,"aria-label":`Step 3: Start`,children:[(0,E.jsxs)(`div`,{className:`panel-head`,children:[(0,E.jsx)(`p`,{className:`eyebrow`,children:`Step 3 of 3`}),(0,E.jsx)(`h2`,{children:`Take the first readings`}),(0,E.jsx)(`p`,{children:`Run the first poll. The daemon will ask each provider CLI for current usage and the dashboard will open when readings land.`})]}),(0,E.jsx)(Et,{}),(0,E.jsxs)(`div`,{className:`panel-foot`,children:[(0,E.jsx)(`button`,{className:`btn btn-quiet`,type:`button`,onClick:()=>a(2),children:`Back`}),(0,E.jsx)(`button`,{"data-testid":`setup-poll-button`,className:`btn btn-primary`,type:`button`,onClick:t,disabled:n,children:n?`Polling…`:`Run first poll`})]}),r&&(0,E.jsxs)(`div`,{"data-testid":`setup-poll-error`,className:`alert`,role:`alert`,style:{margin:`var(--s4) var(--s5)`},children:[(0,E.jsx)(`span`,{children:r}),(0,E.jsx)(`button`,{className:`btn btn-quiet btn-sm`,type:`button`,onClick:t,children:`Retry`})]})]})]})]})]})}var A=`quotacap-theme`;function Ot(e,t){return e===`light`||e===`dark`?e:t?`dark`:`light`}function kt(){try{return typeof localStorage>`u`?null:localStorage.getItem(A)}catch{return null}}function At(){try{return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}catch{return!1}}function jt(e){try{document.documentElement.dataset.theme=e}catch{}try{localStorage.setItem(A,e)}catch{}return e}function Mt(){return Ot(kt(),At())}function Nt(){let[e,t]=(0,_.useState)(()=>Mt()),n=(0,_.useCallback)(()=>{t(e=>jt(e===`dark`?`light`:`dark`))},[]);return(0,E.jsx)(`button`,{"data-testid":`theme-toggle`,className:`iconbtn`,type:`button`,onClick:n,"aria-label":e===`dark`?`Switch to light theme`:`Switch to dark theme`,"aria-pressed":e===`dark`,title:e===`dark`?`Switch to light theme`:`Switch to dark theme`,children:e===`dark`?(0,E.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,E.jsx)(`path`,{d:`M12 2v2M12 20v2M2 12h2M20 12h2M5 5l1.5 1.5M17.5 17.5L19 19M19 5l-1.5 1.5M6.5 17.5L5 19`})]}):(0,E.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`})})})}function Pt(e){return e.available?e.polling===`in-progress`||e.polling===`cooldown`?`polling`:!e.ready||e.version===``?`not-ready`:`live`:`unreachable`}function Ft(){try{return window.location.host||`127.0.0.1:8787`}catch{return`127.0.0.1:8787`}}function It(e,t){switch(e){case`live`:return`daemon live`;case`polling`:return t?.polling===`cooldown`?`Cooling down`:`Polling`;case`unreachable`:return`Daemon unreachable`;case`not-ready`:return t?.version===``?`Version unknown`:`Daemon not ready`}}function Lt({runtime:e,refreshing:t,onRefresh:n,onSettings:r,unreachable:i=!1}){let a=i?`unreachable`:e?Pt(e):null,o=e?.update,s=!!o&&!o.upToDate&&!!o.latest;return(0,E.jsx)(`header`,{className:`topbar`,children:(0,E.jsxs)(`div`,{className:`topbar-inner`,children:[(0,E.jsxs)(`span`,{className:`brand`,children:[(0,E.jsxs)(`svg`,{width:`21`,height:`21`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M4 16.5a8 8 0 0 1 16 0`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.1`,strokeLinecap:`round`}),(0,E.jsx)(`path`,{d:`M12 16.5l4.8-4.6`,stroke:`currentColor`,strokeWidth:`2.1`,strokeLinecap:`round`})]}),`QuotaCap`]}),(0,E.jsxs)(`div`,{className:`topbar-end`,children:[a?(0,E.jsxs)(`span`,{"data-testid":`pill`,"data-state":a,role:`status`,className:`daemon`,title:e?`available: ${e.available}; ready: ${e.ready}; polling: ${e.polling}; version: ${e.version}`:`no snapshot yet`,children:[(0,E.jsx)(`span`,{className:`daemon-dot is-${a}`,"aria-hidden":`true`}),(0,E.jsx)(`span`,{className:`daemon-t`,children:It(a,e)}),a===`live`&&(0,E.jsxs)(`code`,{className:`daemon-addr`,children:[` · `,Ft()]})]}):(0,E.jsxs)(`span`,{"data-testid":`pill`,"data-state":`connecting`,role:`status`,className:`daemon`,children:[(0,E.jsx)(`span`,{className:`daemon-dot is-polling`,"aria-hidden":`true`}),(0,E.jsx)(`span`,{className:`daemon-t`,children:`Connecting…`})]}),s&&o&&o.latest?(0,E.jsxs)(`span`,{"data-testid":`update-badge`,role:`status`,className:`update-badge`,title:`Run 'quotacap update' to upgrade`,children:[(0,E.jsx)(`span`,{className:`daemon-dot is-polling`,"aria-hidden":`true`}),(0,E.jsx)(`span`,{className:`daemon-t`,children:`Update ${o.current} to ${o.latest}`})]}):null,(0,E.jsxs)(`div`,{className:`topbar-actions`,children:[(0,E.jsx)(Nt,{}),(0,E.jsxs)(`button`,{"data-testid":`refresh-button`,className:`btn btn-quiet`,type:`button`,onClick:n,disabled:t,title:`Force refresh now`,children:[(0,E.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M20 12a8 8 0 1 1-2.5-5.8`}),(0,E.jsx)(`path`,{d:`M20 4v4h-4`})]}),(0,E.jsx)(`span`,{className:`btn-label`,children:t?`Refreshing…`:`Refresh`})]}),(0,E.jsxs)(`button`,{"data-testid":`settings-button`,className:`btn btn-quiet`,type:`button`,onClick:r,title:`Open Settings`,children:[(0,E.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,E.jsx)(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z`})]}),(0,E.jsx)(`span`,{className:`btn-label`,children:`Settings`})]})]})]})]})})}function Rt(e){let t=e.displayName;if(e.lastAttempt?.failureCategory===`auth`)return{text:`Sign in to the ${t} CLI, then re-poll. QuotaCap never handles those credentials.`};switch(e.exclusionReason){case`stale`:return{text:`Poll again to refresh this reading.`};case`reset-passed`:return{text:`Poll again to capture the new window.`};case`invalid`:return{text:`Check the ${t} CLI output, then re-poll.`};case`provider-failed`:return{text:`${Ye(e.lastAttempt?.failureCategory??null)??`Provider failed`} — check the ${t} CLI, then re-poll.`};case`not-reporting`:return{text:`No readings yet — run a poll.`};case null:return{text:`Poll again to refresh this reading.`}}}function zt(e){switch(e.exclusionReason){case`stale`:return`stopped reporting`;case`reset-passed`:return`reset passed`;case`invalid`:return`sent an invalid reading`;case`provider-failed`:return`failed`;case`not-reporting`:return`isn't reporting yet`;case null:return`needs attention`}}function Bt({providers:e,onRepoll:t,repolling:n}){let r=e.filter(e=>e.enabled&&e.exclusionReason!==null);return r.length===0?null:(0,E.jsx)(`div`,{children:r.map(e=>{let r=ce(e.ageMs),i=Rt(e);return(0,E.jsxs)(`div`,{"data-testid":`fault-banner`,role:`alert`,className:`alert`,children:[(0,E.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.3`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M12 8v5`}),(0,E.jsx)(`path`,{d:`M12 16.5v.01`}),(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})]}),(0,E.jsxs)(`span`,{children:[(0,E.jsxs)(`strong`,{children:[e.displayName,` `,zt(e),`.`]}),` `,r?`Last read ${r} ago; `:``,`excluded from ranking. `,i.text]}),(0,E.jsx)(`button`,{type:`button`,className:`linkbtn`,onClick:t,disabled:n,style:{flex:`none`,marginLeft:`auto`},children:n?`Polling…`:`Check ${e.displayName}`})]},e.id)})})}var Vt=[{label:`On track`,cls:`pace-ontrack`,meaning:`Usage aligns with time (±20%)`},{label:`Behind pace`,cls:`pace-behind`,meaning:`Burning slow; risk of unused quota waste`},{label:`Ahead of pace`,cls:`pace-ahead`,meaning:`Burning faster than time; monitor usage`},{label:`Cap risk`,cls:`pace-cap`,meaning:`Will hit cap before reset window closes`},{label:`Not reporting`,cls:`pace-out`,meaning:`No usable reading; excluded from ranking`}];function Ht(){let[e,t]=(0,_.useState)(!1),n=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(!e)return;let r=e=>{n.current&&!n.current.contains(e.target)&&t(!1)},i=e=>{e.key===`Escape`&&t(!1)};return document.addEventListener(`mousedown`,r),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,r),document.removeEventListener(`keydown`,i)}},[e]),(0,E.jsxs)(`div`,{className:`legend-wrap`,ref:n,children:[(0,E.jsx)(`button`,{type:`button`,className:`legend-btn`,"aria-expanded":e,"aria-controls":`pacing-legend`,onClick:()=>t(e=>!e),children:`Pacing Legend ▾`}),e&&(0,E.jsxs)(`div`,{id:`pacing-legend`,className:`legend-popover`,role:`dialog`,"aria-label":`Pacing legend`,children:[(0,E.jsxs)(`div`,{className:`legend-head`,children:[(0,E.jsx)(`b`,{children:`Pacing Scale Legend`}),(0,E.jsx)(`button`,{type:`button`,className:`legend-close`,"aria-label":`Close pacing legend`,onClick:()=>t(!1),children:`×`})]}),(0,E.jsx)(`p`,{className:`legend-intro`,children:`Pacing measures quota burn against elapsed window time:`}),(0,E.jsx)(`div`,{className:`legend-rows`,children:Vt.map(e=>(0,E.jsxs)(`div`,{className:`legend-row`,children:[(0,E.jsx)(`span`,{className:`pace ${e.cls}`,children:e.label}),(0,E.jsx)(`span`,{children:e.meaning})]},e.label))}),(0,E.jsxs)(`div`,{className:`legend-foot`,children:[(0,E.jsx)(`code`,{children:`█`}),` allowance used · `,(0,E.jsx)(`code`,{children:`│`}),` time elapsed · `,(0,E.jsx)(`code`,{children:`░`}),` projected waste`]})]})]})}function Ut(){try{return window.location.hostname||`127.0.0.1`}catch{return`127.0.0.1`}}function Wt(){return(0,E.jsxs)(`footer`,{className:`sitefoot`,children:[(0,E.jsxs)(`div`,{className:`sitefoot-start`,children:[(0,E.jsxs)(`span`,{children:[`QuotaCap · local quota tracker · bound to `,(0,E.jsx)(`code`,{children:Ut()})]}),(0,E.jsx)(Ht,{})]}),(0,E.jsx)(`span`,{children:`MIT licence · no telemetry · history stays on this machine`})]})}function Gt({endpoint:e,lastGood:t,onRetry:n}){return(0,E.jsxs)(`div`,{"data-testid":`state-unavailable`,role:`alert`,children:[(0,E.jsx)(`h2`,{children:`Service unavailable`}),(0,E.jsxs)(`p`,{children:[`The QuotaCap daemon did not answer at `,(0,E.jsx)(`code`,{children:e}),`. Start it with`,` `,(0,E.jsx)(`code`,{children:`quotacap daemon`}),`, then retry.`]}),(0,E.jsx)(`button`,{type:`button`,onClick:n,children:`Retry`}),t&&(0,E.jsxs)(`p`,{children:[`Showing last readings (`,ae(t.asOf),`).`]})]})}function Kt({status:e,message:t,lastGood:n,onRetry:r}){return(0,E.jsxs)(`div`,{"data-testid":`state-http-error`,role:`alert`,children:[(0,E.jsxs)(`h2`,{children:[`Request failed (HTTP `,e,`)`]}),(0,E.jsx)(`p`,{children:t}),(0,E.jsx)(`button`,{type:`button`,onClick:r,children:`Retry`}),n&&(0,E.jsxs)(`p`,{children:[`Showing last readings (`,ae(n.asOf),`).`]})]})}function qt({snapshot:e,onSelectProvider:t,onViewAdvice:n}){return(0,E.jsxs)(`div`,{"data-testid":`dashboard-root`,className:`dashboard`,children:[(0,E.jsx)(ke,{recommendation:e.recommendation,providers:e.providers,asOf:e.asOf,onSelectProvider:t,onViewAdvice:n}),!re(e)&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(qe,{providers:e.providers,asOf:e.asOf,onSelectProvider:t}),(0,E.jsx)(Le,{providers:e.providers,recommendation:e.recommendation,asOf:e.asOf,lastCompletedPollAt:e.runtime.lastCompletedPollAt,polling:e.runtime.polling,onSelectProvider:t})]})]})}function Jt(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(!1),g=Ct(),v=e?bt(g,re(e)):null;(0,_.useEffect)(()=>{v&&v!==g&&St(v)},[v,g]);let S=(0,_.useCallback)(async()=>{try{t(T(await C())),r(null)}catch(e){e instanceof b?r({kind:`service-unavailable`,message:e.message}):e instanceof x?r({kind:`http-error`,status:e.status,message:e.message}):r({kind:`http-error`,status:0,message:String(e)})}finally{a(!1)}},[]);(0,_.useEffect)(()=>{S()},[S]);let w=(0,_.useCallback)(async()=>{s(!0),l(null);try{let e=await te();e.message&&l(e.message),await S()}catch(e){e instanceof b?r({kind:`service-unavailable`,message:e.message}):e instanceof x?r({kind:`http-error`,status:e.status,message:e.message}):r({kind:`http-error`,status:0,message:String(e)})}finally{s(!1)}},[S]),ee=v===`/setup`,ne=n?n.kind===`http-error`?`Request failed (HTTP ${n.status}): ${n.message}`:`Service unavailable: ${n.message}`:null,ie=(0,E.jsx)(Lt,{runtime:e?.runtime??null,unreachable:n?.kind===`service-unavailable`,refreshing:o,onRefresh:()=>void w(),onSettings:()=>h(!0)});return e&&ee?(0,E.jsxs)(E.Fragment,{children:[ie,(0,E.jsx)(`main`,{children:(0,E.jsx)(Dt,{snapshot:e,onFirstPoll:()=>void w(),polling:o,pollError:ne})}),(0,E.jsx)(yt,{open:m,providers:e.providers,onRefresh:()=>void w(),refreshing:o,onClose:()=>h(!1)}),(0,E.jsx)(Wt,{})]}):(0,E.jsxs)(E.Fragment,{children:[ie,(0,E.jsxs)(`main`,{children:[c&&(0,E.jsx)(`div`,{"data-testid":`refresh-notice`,role:`status`,children:c}),i&&!e&&(0,E.jsx)(`div`,{"data-testid":`state-loading`,"aria-busy":`true`,"aria-label":`Loading quota state`,children:[0,1,2].map(e=>(0,E.jsx)(`div`,{"aria-hidden":`true`,className:`skel`,style:{height:64,background:`var(--surface-raised)`,border:e===0?`1px solid var(--rec)`:`1px solid var(--line)`,borderRadius:8,marginBottom:8}},e))}),n?.kind===`service-unavailable`&&!e&&(0,E.jsx)(Gt,{endpoint:y(),lastGood:e,onRetry:()=>void S()}),n?.kind===`http-error`&&!e&&(0,E.jsx)(Kt,{status:n.status,message:n.message,lastGood:e,onRetry:()=>void S()}),n&&e&&(0,E.jsxs)(`div`,{"data-testid":`state-stale-error`,role:`alert`,children:[n.kind===`http-error`?`Request failed (HTTP ${n.status}): `:`Service unavailable: `,n.message,` Showing last readings (`,ae(e.asOf),`).`,` `,(0,E.jsx)(`button`,{type:`button`,onClick:()=>void S(),children:`Retry`})]}),e&&(0,E.jsx)(Bt,{providers:e.providers,onRepoll:()=>void w(),repolling:o}),e&&(0,E.jsx)(qt,{snapshot:e,onSelectProvider:e=>{p(!1),d(e)},onViewAdvice:()=>{d(null),p(!0)}})]}),(0,E.jsx)(st,{provider:e?.providers.find(e=>e.id===u)??null,asOf:e?.asOf??``,recommendation:e?.recommendation??null,onClose:()=>d(null),onRenamed:()=>void S()}),e&&(0,E.jsx)(ct,{open:f,recommendation:e.recommendation,providers:e.providers,asOf:e.asOf,onClose:()=>p(!1)}),(0,E.jsx)(yt,{open:m,providers:e?.providers??[],onRefresh:()=>void w(),refreshing:o,onClose:()=>h(!1)}),(0,E.jsx)(Wt,{})]})}var Yt=typeof document>`u`?null:document.getElementById(`app`);Yt&&(0,v.createRoot)(Yt).render((0,E.jsx)(Jt,{}));
12
+ format = "[$output]($style) "`})]}),(0,E.jsxs)(`div`,{style:{marginBottom:`var(--s4)`},children:[(0,E.jsxs)(`b`,{style:{fontSize:`var(--t-2)`,display:`block`,marginBottom:4},children:[`tmux (`,(0,E.jsx)(`code`,{children:`~/.tmux.conf`}),`):`]}),(0,E.jsx)(`pre`,{style:{background:`var(--canvas)`,padding:`8px 12px`,border:`1px solid var(--line)`,borderRadius:`var(--r-sm)`,fontFamily:`var(--font-mono)`,fontSize:`var(--t-1)`,margin:0,overflowX:`auto`},children:`set -g status-right '#(quotacap status --compact)'`})]}),(0,E.jsxs)(`div`,{style:{marginBottom:`var(--s4)`},children:[(0,E.jsxs)(`b`,{style:{fontSize:`var(--t-2)`,display:`block`,marginBottom:4},children:[`Bash / Zsh (`,(0,E.jsx)(`code`,{children:`~/.zshrc`}),`):`]}),(0,E.jsx)(`pre`,{style:{background:`var(--canvas)`,padding:`8px 12px`,border:`1px solid var(--line)`,borderRadius:`var(--r-sm)`,fontFamily:`var(--font-mono)`,fontSize:`var(--t-1)`,margin:0,overflowX:`auto`},children:`export PS1='$(quotacap status --compact) '$PS1`})]}),(0,E.jsxs)(`div`,{style:{borderTop:`1px solid var(--line)`,paddingTop:`var(--s3)`},children:[(0,E.jsx)(`b`,{style:{fontSize:`var(--t-2)`,display:`block`,marginBottom:4},children:`CLI Status Commands:`}),(0,E.jsx)(`p`,{style:{fontSize:`var(--t-2)`,color:`var(--ink-soft)`,margin:`0 0 6px`},children:`Run status in terminal with custom sorting and ASCII fallbacks:`}),(0,E.jsx)(`code`,{style:{display:`block`,fontSize:`var(--t-1)`,background:`var(--canvas)`,padding:`6px 10px`,borderRadius:`var(--r-sm)`,border:`1px solid var(--line)`,marginBottom:4},children:`quotacap status --sort reset-asc`}),(0,E.jsx)(`code`,{style:{display:`block`,fontSize:`var(--t-1)`,background:`var(--canvas)`,padding:`6px 10px`,borderRadius:`var(--r-sm)`,border:`1px solid var(--line)`},children:`quotacap status --ascii`})]})]})}function gt(){try{return window.location.port||null}catch{return null}}function _t(){let e=gt();return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h3`,{style:{fontSize:`var(--t-3)`,fontWeight:700,margin:`0 0 var(--s2)`},children:`Local Daemon Process`}),(0,E.jsx)(`p`,{style:{fontSize:`var(--t-2)`,color:`var(--ink-soft)`,margin:`0 0 var(--s4)`},children:`Background process managing provider adapters and SQLite store.`}),(0,E.jsxs)(`div`,{style:{display:`grid`,gap:`var(--s2)`,fontSize:`var(--t-2)`,marginBottom:`var(--s4)`},children:[(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,padding:`8px 0`,borderBottom:`1px solid var(--line)`},children:[(0,E.jsx)(`span`,{style:{color:`var(--ink-soft)`},children:`HTTP Service`}),(0,E.jsxs)(`code`,{children:[`127.0.0.1:`,e??`8787`]})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,padding:`8px 0`,borderBottom:`1px solid var(--line)`},children:[(0,E.jsx)(`span`,{style:{color:`var(--ink-soft)`},children:`Polling Cadence`}),(0,E.jsx)(`span`,{children:`Every 15 minutes (default)`})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,padding:`8px 0`,borderBottom:`1px solid var(--line)`},children:[(0,E.jsx)(`span`,{style:{color:`var(--ink-soft)`},children:`Storage Engine`}),(0,E.jsx)(`span`,{children:`SQLite`})]}),(0,E.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,padding:`8px 0`,borderBottom:`1px solid var(--line)`},children:[(0,E.jsx)(`span`,{style:{color:`var(--ink-soft)`},children:`Database File`}),(0,E.jsx)(`code`,{children:`~/.quotacap/quotacap.db`})]})]}),(0,E.jsxs)(`div`,{style:{display:`grid`,gap:`var(--s3)`,background:`var(--surface-raised)`,padding:`var(--s4)`,borderRadius:`var(--r-md)`,border:`1px solid var(--line)`},children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{style:{fontSize:`var(--t-2)`,fontWeight:600,display:`block`,marginBottom:4},children:`HTTP port`}),(0,E.jsx)(`input`,{type:`number`,value:e??`8787`,placeholder:`8787`,disabled:!0,"aria-label":`Daemon HTTP port (read-only)`,style:{width:`100%`,boxSizing:`border-box`,font:`inherit`,fontSize:`var(--t-2)`,padding:`6px 10px`,borderRadius:`var(--r-sm)`,border:`1px solid var(--line)`,background:`var(--surface)`,color:`var(--ink-soft)`}}),e&&(0,E.jsxs)(`p`,{style:{fontSize:`var(--t-1)`,color:`var(--ink-soft)`,margin:`4px 0 0`},children:[`This dashboard is served from port `,e,`.`]})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{style:{fontSize:`var(--t-2)`,fontWeight:600,display:`block`,marginBottom:4},children:`Poll cadence (minutes)`}),(0,E.jsx)(`input`,{type:`number`,value:`15`,placeholder:`15`,disabled:!0,"aria-label":`Background poll cadence in minutes (read-only)`,style:{width:`100%`,boxSizing:`border-box`,font:`inherit`,fontSize:`var(--t-2)`,padding:`6px 10px`,borderRadius:`var(--r-sm)`,border:`1px solid var(--line)`,background:`var(--surface)`,color:`var(--ink-soft)`}})]})]}),(0,E.jsxs)(`p`,{style:{fontSize:`var(--t-1)`,color:`var(--ink-soft)`,marginTop:`var(--s3)`},children:[`Change the port and polling cadence in `,(0,E.jsx)(`code`,{children:`~/.quotacap/config.json`}),` (`,(0,E.jsx)(`code`,{children:`port`}),`,`,` `,(0,E.jsx)(`code`,{children:`pollMinutes`}),`; defaults 8787 and 15), then restart the daemon. These controls stay read-only until the server offers a settings API.`]})]})}var vt=[{id:`providers`,label:`Providers`},{id:`cli`,label:`CLI & Shell`},{id:`daemon`,label:`Daemon`}];function yt({open:e,providers:t,onRefresh:n,refreshing:r,onClose:i}){let[a,o]=(0,_.useState)(`providers`),s=(0,_.useRef)(null),c=(0,_.useRef)(null);if((0,_.useEffect)(()=>{if(!e)return;c.current=document.activeElement,s.current?.focus();let t=e=>{if(e.key===`Escape`){i();return}if(e.key!==`Tab`||!s.current)return;let t=[...s.current.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)].filter(e=>!e.hasAttribute(`disabled`));if(t.length===0)return;let n=t[0],r=t[t.length-1],a=document.activeElement===n||document.activeElement===s.current;e.shiftKey&&a?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())};return document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`keydown`,t),c.current?.focus?.()}},[e,i]),!e)return null;let l=`settings-drawer-title`;return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{"data-testid":`settings-scrim`,className:`scrim is-open`,"aria-hidden":`true`,onClick:i}),(0,E.jsxs)(`aside`,{ref:s,tabIndex:-1,"data-testid":`settings-drawer`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":l,className:`drawer is-open`,style:{width:`min(580px, 100vw)`},onClick:e=>e.stopPropagation(),children:[(0,E.jsxs)(`div`,{className:`drawer-head`,children:[(0,E.jsxs)(`div`,{style:{flex:1},children:[(0,E.jsx)(`h2`,{id:l,style:{margin:`0 0 2px`},children:`Settings & Configuration`}),(0,E.jsx)(`span`,{className:`sub`,children:`Connected provider adapters and CLI prompt integration.`})]}),(0,E.jsx)(`button`,{className:`drawer-close`,type:`button`,"aria-label":`Close settings`,onClick:i,children:(0,E.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M6 6l12 12M18 6L6 18`})})})]}),(0,E.jsx)(`div`,{className:`seg`,role:`tablist`,"aria-label":`Settings sections`,style:{margin:`var(--s4) var(--s5) 0`,display:`flex`,height:32},children:vt.map(e=>(0,E.jsx)(`button`,{type:`button`,role:`tab`,className:`settings-tab${a===e.id?` is-active`:``}`,"aria-selected":a===e.id,onClick:()=>o(e.id),style:{flex:1,justifyContent:`center`},children:e.label},e.id))}),(0,E.jsxs)(`div`,{role:`tabpanel`,style:{padding:`var(--s4) var(--s5) var(--s6)`,overflowY:`auto`},children:[a===`providers`&&(0,E.jsx)(mt,{providers:t,onRefresh:n,refreshing:r}),a===`cli`&&(0,E.jsx)(ht,{}),a===`daemon`&&(0,E.jsx)(_t,{})]})]})]})}function bt(e,t){return t?`/setup`:`/`}function xt(){try{return window.location.pathname||`/`}catch{return`/`}}function St(e){window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))}function Ct(){let[e,t]=(0,_.useState)(()=>xt());return(0,_.useEffect)(()=>{let e=()=>t(xt());return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]),e}function wt(e){let t=e.displayName,n=e.id===`agy:3p`?`Antigravity`:t;if(e.exclusionReason===null&&e.quota){let t=ce(e.ageMs);return{status:`Ready`,detail:t?`Last read ${t} ago.`:`Reporting.`}}if(e.lastAttempt?.success&&e.lastAttempt.succeededAt)return{status:`Ready`,detail:`Connected — no readings yet.`};let r=`QuotaCap never handles those credentials.`;return e.harness===null?{status:`Sign in first`,detail:`QuotaCap has no live adapter for ${t}. Use manual ingest via the CLI to add readings.`}:e.lastAttempt?.failureCategory===`auth`?{status:`Sign in first`,detail:`Sign in to the ${n} CLI, then re-poll. ${r}`}:e.lastAttempt?{status:`Sign in first`,detail:`${Ye(e.lastAttempt.failureCategory)??`Last attempt failed`} — check the ${n} CLI, then re-poll. ${r}`}:{status:`Sign in first`,detail:`Install the ${n} CLI and sign in, then run the first poll. ${r}`}}function Tt({providers:e}){return(0,E.jsx)(`div`,{className:`provlist`,children:e.map(e=>{let t=wt(e),n=t.status===`Ready`;return(0,E.jsxs)(`div`,{className:`provrow`,children:[(0,E.jsx)(`b`,{children:e.displayName}),(0,E.jsx)(`span`,{className:`path`,children:t.detail}),(0,E.jsxs)(`span`,{className:n?`st-ready`:`st-todo`,children:[n?(0,E.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M20 6L9 17l-5-5`})}):(0,E.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,E.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,E.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),t.status]})]},e.id)})})}function Et(){return(0,E.jsxs)(`div`,{className:`preview`,"aria-label":`Sample payoff preview`,children:[(0,E.jsxs)(`div`,{className:`preview-head`,style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:`var(--s3)`},children:[(0,E.jsx)(`span`,{style:{fontWeight:600},children:`What your first result will show`}),(0,E.jsx)(`span`,{className:`chip-sample`,style:{fontSize:`var(--t-1)`,padding:`2px 8px`,borderRadius:999,background:`var(--surface-raised)`,border:`1px solid var(--line-strong)`,fontWeight:600,color:`var(--ink-soft)`},children:`Sample data`})]}),(0,E.jsxs)(`div`,{className:`trackwrap`,children:[(0,E.jsxs)(`div`,{className:`tline`,style:{display:`flex`,justifyContent:`space-between`,fontSize:`var(--t-2)`,marginBottom:4},children:[(0,E.jsx)(`span`,{className:`used`,style:{fontWeight:600},children:`Kimi Code · 22% used`}),(0,E.jsx)(`span`,{className:`gap`,style:{color:`var(--ink-soft)`},children:`61 points behind pace`})]}),(0,E.jsxs)(`div`,{className:`track`,role:`img`,"aria-label":`Sample: 22 percent of quota used, 83 percent of the window elapsed`,children:[(0,E.jsx)(`div`,{className:`fill`,style:{width:`22%`,background:`var(--fill-behind)`,borderRight:`1px solid var(--edge-behind)`}}),(0,E.jsx)(`div`,{className:`mark`,style:{left:`83%`}})]}),(0,E.jsxs)(`div`,{className:`tfoot`,style:{display:`flex`,justifyContent:`space-between`,fontSize:`var(--t-1)`,color:`var(--ink-faint)`,marginTop:4},children:[(0,E.jsx)(`span`,{children:`start`}),(0,E.jsx)(`span`,{children:`time elapsed: 83%`}),(0,E.jsx)(`span`,{children:`reset`})]})]}),(0,E.jsx)(`p`,{style:{fontSize:`var(--t-2)`,color:`var(--ink-soft)`,margin:`var(--s3) 0 0`},children:`Switch to Kimi next — 67% waste in 1.2d`})]})}function Dt({snapshot:e,onFirstPoll:t,polling:n,pollError:r}){let[i,a]=(0,_.useState)(1);return(0,E.jsxs)(`div`,{"data-testid":`setup-root`,style:{maxWidth:960,margin:`0 auto`,padding:`var(--s5) var(--s4) 56px`},children:[(0,E.jsx)(`p`,{className:`eyebrow`,style:{marginBottom:`var(--s1)`},children:`First run & accounts`}),(0,E.jsx)(`h1`,{style:{fontSize:`var(--t-6)`,letterSpacing:`-0.024em`,margin:`0 0 var(--s5)`,fontWeight:700},children:`Connect the subscriptions you already use`}),(0,E.jsxs)(`div`,{className:`setup`,children:[(0,E.jsxs)(`ol`,{className:`steps`,children:[(0,E.jsxs)(`li`,{className:i===1?`is-now`:``,"aria-current":i===1?`step`:void 0,children:[(0,E.jsx)(`span`,{className:`num`,children:`1`}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`span`,{className:`t`,children:`Detect`}),(0,E.jsx)(`span`,{className:`d`,children:`Find installed coding tools`})]})]}),(0,E.jsxs)(`li`,{className:i===2?`is-now`:``,"aria-current":i===2?`step`:void 0,children:[(0,E.jsx)(`span`,{className:`num`,children:`2`}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`span`,{className:`t`,children:`Review`}),(0,E.jsx)(`span`,{className:`d`,children:`Check what each adapter reads`})]})]}),(0,E.jsxs)(`li`,{className:i===3?`is-now`:``,"aria-current":i===3?`step`:void 0,children:[(0,E.jsx)(`span`,{className:`num`,children:`3`}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`span`,{className:`t`,children:`Start`}),(0,E.jsx)(`span`,{className:`d`,children:`Read current usage once`})]})]})]}),(0,E.jsxs)(`div`,{className:`panel`,children:[i===1&&(0,E.jsxs)(`section`,{"data-testid":`setup-step-1`,"aria-label":`Step 1: Detect`,children:[(0,E.jsxs)(`div`,{className:`panel-head`,children:[(0,E.jsx)(`p`,{className:`eyebrow`,children:`Step 1 of 3`}),(0,E.jsx)(`h2`,{children:`What the daemon can see`}),(0,E.jsx)(`p`,{children:`QuotaCap asked the running daemon what it knows. The dashboard cannot scan this machine from the browser, so anything missing here needs the provider CLI installed and signed in first.`}),(0,E.jsxs)(`div`,{className:`privacy`,children:[(0,E.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`var(--good)`,strokeWidth:`2.2`,style:{flex:`none`},"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M12 3l7 3v5c0 5-3 8-7 10-4-2-7-5-7-10V6z`}),(0,E.jsx)(`path`,{d:`M9 12l2 2 4-4`})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`b`,{children:`Usage history stays on this machine`}),(0,E.jsx)(`span`,{children:`QuotaCap reads quota percentages and reset times only. It never accesses code, prompts, or sensitive files.`})]})]})]}),(0,E.jsx)(Tt,{providers:e.providers}),(0,E.jsxs)(`div`,{className:`panel-foot`,children:[(0,E.jsx)(`span`,{style:{fontSize:`var(--t-2)`,color:`var(--ink-soft)`},children:`You can add, disable, or repair providers at any time.`}),(0,E.jsx)(`button`,{className:`btn btn-primary`,type:`button`,onClick:()=>a(2),children:`Continue to review`})]})]}),i===2&&(0,E.jsxs)(`section`,{"data-testid":`setup-step-2`,"aria-label":`Step 2: Review`,children:[(0,E.jsxs)(`div`,{className:`panel-head`,children:[(0,E.jsx)(`p`,{className:`eyebrow`,children:`Step 2 of 3`}),(0,E.jsx)(`h2`,{children:`Review accounts`}),(0,E.jsx)(`p`,{children:`QuotaCap reads usage through your own provider CLIs. It never asks for, stores, or transmits your provider credentials — sign-in happens in the provider CLI itself, not here.`}),(0,E.jsxs)(`div`,{className:`privacy`,children:[(0,E.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`var(--good)`,strokeWidth:`2.2`,style:{flex:`none`},"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M12 3l7 3v5c0 5-3 8-7 10-4-2-7-5-7-10V6z`}),(0,E.jsx)(`path`,{d:`M9 12l2 2 4-4`})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`b`,{children:`Zero credential storage`}),(0,E.jsx)(`span`,{children:`Authentication stays in official CLI keychains. QuotaCap never handles or persists tokens.`})]})]})]}),(0,E.jsx)(Tt,{providers:e.providers}),(0,E.jsxs)(`div`,{className:`panel-foot`,children:[(0,E.jsx)(`button`,{className:`btn btn-quiet`,type:`button`,onClick:()=>a(1),children:`Back`}),(0,E.jsx)(`button`,{className:`btn btn-primary`,type:`button`,onClick:()=>a(3),children:`Continue to first poll`})]})]}),i===3&&(0,E.jsxs)(`section`,{"data-testid":`setup-step-3`,"aria-label":`Step 3: Start`,children:[(0,E.jsxs)(`div`,{className:`panel-head`,children:[(0,E.jsx)(`p`,{className:`eyebrow`,children:`Step 3 of 3`}),(0,E.jsx)(`h2`,{children:`Take the first readings`}),(0,E.jsx)(`p`,{children:`Run the first poll. The daemon will ask each provider CLI for current usage and the dashboard will open when readings land.`})]}),(0,E.jsx)(Et,{}),(0,E.jsxs)(`div`,{className:`panel-foot`,children:[(0,E.jsx)(`button`,{className:`btn btn-quiet`,type:`button`,onClick:()=>a(2),children:`Back`}),(0,E.jsx)(`button`,{"data-testid":`setup-poll-button`,className:`btn btn-primary`,type:`button`,onClick:t,disabled:n,children:n?`Polling…`:`Run first poll`})]}),r&&(0,E.jsxs)(`div`,{"data-testid":`setup-poll-error`,className:`alert`,role:`alert`,style:{margin:`var(--s4) var(--s5)`},children:[(0,E.jsx)(`span`,{children:r}),(0,E.jsx)(`button`,{className:`btn btn-quiet btn-sm`,type:`button`,onClick:t,children:`Retry`})]})]})]})]})]})}var A=`quotacap-theme`;function Ot(e,t){return e===`light`||e===`dark`?e:t?`dark`:`light`}function kt(){try{return typeof localStorage>`u`?null:localStorage.getItem(A)}catch{return null}}function At(){try{return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}catch{return!1}}function jt(e){try{document.documentElement.dataset.theme=e}catch{}try{localStorage.setItem(A,e)}catch{}return e}function Mt(){return Ot(kt(),At())}function Nt(){let[e,t]=(0,_.useState)(()=>Mt()),n=(0,_.useCallback)(()=>{t(e=>jt(e===`dark`?`light`:`dark`))},[]);return(0,E.jsx)(`button`,{"data-testid":`theme-toggle`,className:`iconbtn`,type:`button`,onClick:n,"aria-label":e===`dark`?`Switch to light theme`:`Switch to dark theme`,"aria-pressed":e===`dark`,title:e===`dark`?`Switch to light theme`:`Switch to dark theme`,children:e===`dark`?(0,E.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,E.jsx)(`path`,{d:`M12 2v2M12 20v2M2 12h2M20 12h2M5 5l1.5 1.5M17.5 17.5L19 19M19 5l-1.5 1.5M6.5 17.5L5 19`})]}):(0,E.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,E.jsx)(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`})})})}function Pt(e){return e.available?e.polling===`in-progress`||e.polling===`cooldown`?`polling`:!e.ready||e.version===``?`not-ready`:`live`:`unreachable`}function Ft(){try{return window.location.host||`127.0.0.1:8787`}catch{return`127.0.0.1:8787`}}function It(e,t){switch(e){case`live`:return`daemon live`;case`polling`:return t?.polling===`cooldown`?`Cooling down`:`Polling`;case`unreachable`:return`Daemon unreachable`;case`not-ready`:return t?.version===``?`Version unknown`:`Daemon not ready`}}function Lt({runtime:e,refreshing:t,onRefresh:n,onSettings:r,unreachable:i=!1}){let a=i?`unreachable`:e?Pt(e):null,o=e?.update,s=!!o&&!o.upToDate&&!!o.latest;return(0,E.jsx)(`header`,{className:`topbar`,children:(0,E.jsxs)(`div`,{className:`topbar-inner`,children:[(0,E.jsxs)(`span`,{className:`brand`,children:[(0,E.jsxs)(`svg`,{width:`21`,height:`21`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M4 16.5a8 8 0 0 1 16 0`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.1`,strokeLinecap:`round`}),(0,E.jsx)(`path`,{d:`M12 16.5l4.8-4.6`,stroke:`currentColor`,strokeWidth:`2.1`,strokeLinecap:`round`})]}),`QuotaCap`]}),(0,E.jsxs)(`div`,{className:`topbar-end`,children:[a?(0,E.jsxs)(`span`,{"data-testid":`pill`,"data-state":a,role:`status`,className:`daemon`,title:e?`available: ${e.available}; ready: ${e.ready}; polling: ${e.polling}; version: ${e.version}`:`no snapshot yet`,children:[(0,E.jsx)(`span`,{className:`daemon-dot is-${a}`,"aria-hidden":`true`}),(0,E.jsx)(`span`,{className:`daemon-t`,children:It(a,e)}),a===`live`&&(0,E.jsxs)(`code`,{className:`daemon-addr`,children:[` · `,Ft()]})]}):(0,E.jsxs)(`span`,{"data-testid":`pill`,"data-state":`connecting`,role:`status`,className:`daemon`,children:[(0,E.jsx)(`span`,{className:`daemon-dot is-polling`,"aria-hidden":`true`}),(0,E.jsx)(`span`,{className:`daemon-t`,children:`Connecting…`})]}),s&&o&&o.latest?(0,E.jsxs)(`span`,{"data-testid":`update-badge`,role:`status`,className:`update-badge`,title:`Run 'quotacap update' to upgrade`,children:[(0,E.jsx)(`span`,{className:`daemon-dot is-polling`,"aria-hidden":`true`}),(0,E.jsx)(`span`,{className:`daemon-t`,children:`Update ${o.current} to ${o.latest}`})]}):null,(0,E.jsxs)(`div`,{className:`topbar-actions`,children:[(0,E.jsx)(Nt,{}),(0,E.jsxs)(`button`,{"data-testid":`refresh-button`,className:`btn btn-quiet`,type:`button`,onClick:n,disabled:t,title:`Force refresh now`,children:[(0,E.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M20 12a8 8 0 1 1-2.5-5.8`}),(0,E.jsx)(`path`,{d:`M20 4v4h-4`})]}),(0,E.jsx)(`span`,{className:`btn-label`,children:t?`Refreshing…`:`Refresh`})]}),(0,E.jsxs)(`button`,{"data-testid":`settings-button`,className:`btn btn-quiet`,type:`button`,onClick:r,title:`Open Settings`,children:[(0,E.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,E.jsx)(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z`})]}),(0,E.jsx)(`span`,{className:`btn-label`,children:`Settings`})]})]})]})]})})}function Rt(e){let t=e.displayName;if(e.lastAttempt?.failureCategory===`auth`)return{text:`Sign in to the ${t} CLI, then re-poll. QuotaCap never handles those credentials.`};switch(e.exclusionReason){case`stale`:return{text:`Poll again to refresh this reading.`};case`reset-passed`:return{text:`Poll again to capture the new window.`};case`invalid`:return{text:`Check the ${t} CLI output, then re-poll.`};case`provider-failed`:return{text:`${Ye(e.lastAttempt?.failureCategory??null)??`Provider failed`} — check the ${t} CLI, then re-poll.`};case`not-reporting`:return{text:`No readings yet — run a poll.`};case null:return{text:`Poll again to refresh this reading.`}}}function zt(e){switch(e.exclusionReason){case`stale`:return`stopped reporting`;case`reset-passed`:return`reset passed`;case`invalid`:return`sent an invalid reading`;case`provider-failed`:return`failed`;case`not-reporting`:return`isn't reporting yet`;case null:return`needs attention`}}function Bt({providers:e,onRepoll:t,repolling:n}){let r=e.filter(e=>e.enabled&&e.exclusionReason!==null);return r.length===0?null:(0,E.jsx)(`div`,{children:r.map(e=>{let r=ce(e.ageMs),i=Rt(e);return(0,E.jsxs)(`div`,{"data-testid":`fault-banner`,role:`alert`,className:`alert`,children:[(0,E.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.3`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,E.jsx)(`path`,{d:`M12 8v5`}),(0,E.jsx)(`path`,{d:`M12 16.5v.01`}),(0,E.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})]}),(0,E.jsxs)(`span`,{children:[(0,E.jsxs)(`strong`,{children:[e.displayName,` `,zt(e),`.`]}),` `,r?`Last read ${r} ago; `:``,`excluded from ranking. `,i.text]}),(0,E.jsx)(`button`,{type:`button`,className:`linkbtn`,onClick:t,disabled:n,style:{flex:`none`,marginLeft:`auto`},children:n?`Polling…`:`Check ${e.displayName}`})]},e.id)})})}var Vt=[{label:`On track`,cls:`pace-ontrack`,meaning:`Usage aligns with time (±20%)`},{label:`Behind pace`,cls:`pace-behind`,meaning:`Burning slow; risk of unused quota waste`},{label:`Ahead of pace`,cls:`pace-ahead`,meaning:`Burning faster than time; monitor usage`},{label:`Cap risk`,cls:`pace-cap`,meaning:`Will hit cap before reset window closes`},{label:`Not reporting`,cls:`pace-out`,meaning:`No usable reading; excluded from ranking`}];function Ht(){let[e,t]=(0,_.useState)(!1),n=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(!e)return;let r=e=>{n.current&&!n.current.contains(e.target)&&t(!1)},i=e=>{e.key===`Escape`&&t(!1)};return document.addEventListener(`mousedown`,r),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,r),document.removeEventListener(`keydown`,i)}},[e]),(0,E.jsxs)(`div`,{className:`legend-wrap`,ref:n,children:[(0,E.jsx)(`button`,{type:`button`,className:`legend-btn`,"aria-expanded":e,"aria-controls":`pacing-legend`,onClick:()=>t(e=>!e),children:`Pacing Legend ▾`}),e&&(0,E.jsxs)(`div`,{id:`pacing-legend`,className:`legend-popover`,role:`dialog`,"aria-label":`Pacing legend`,children:[(0,E.jsxs)(`div`,{className:`legend-head`,children:[(0,E.jsx)(`b`,{children:`Pacing Scale Legend`}),(0,E.jsx)(`button`,{type:`button`,className:`legend-close`,"aria-label":`Close pacing legend`,onClick:()=>t(!1),children:`×`})]}),(0,E.jsx)(`p`,{className:`legend-intro`,children:`Pacing measures quota burn against elapsed window time:`}),(0,E.jsx)(`div`,{className:`legend-rows`,children:Vt.map(e=>(0,E.jsxs)(`div`,{className:`legend-row`,children:[(0,E.jsx)(`span`,{className:`pace ${e.cls}`,children:e.label}),(0,E.jsx)(`span`,{children:e.meaning})]},e.label))}),(0,E.jsxs)(`div`,{className:`legend-foot`,children:[(0,E.jsx)(`code`,{children:`█`}),` allowance used · `,(0,E.jsx)(`code`,{children:`│`}),` time elapsed · `,(0,E.jsx)(`code`,{children:`░`}),` projected waste`]})]})]})}function Ut(){try{return window.location.hostname||`127.0.0.1`}catch{return`127.0.0.1`}}function Wt({version:e}){let t=e?`QuotaCap v${e}`:`QuotaCap`;return(0,E.jsxs)(`footer`,{className:`sitefoot`,children:[(0,E.jsxs)(`div`,{className:`sitefoot-start`,children:[(0,E.jsxs)(`span`,{children:[t,` · local quota tracker · bound to `,(0,E.jsx)(`code`,{children:Ut()})]}),(0,E.jsx)(Ht,{})]}),(0,E.jsx)(`span`,{children:`MIT licence · no telemetry · history stays on this machine`})]})}function Gt({endpoint:e,lastGood:t,onRetry:n}){return(0,E.jsxs)(`div`,{"data-testid":`state-unavailable`,role:`alert`,children:[(0,E.jsx)(`h2`,{children:`Service unavailable`}),(0,E.jsxs)(`p`,{children:[`The QuotaCap daemon did not answer at `,(0,E.jsx)(`code`,{children:e}),`. Start it with`,` `,(0,E.jsx)(`code`,{children:`quotacap daemon`}),`, then retry.`]}),(0,E.jsx)(`button`,{type:`button`,onClick:n,children:`Retry`}),t&&(0,E.jsxs)(`p`,{children:[`Showing last readings (`,ae(t.asOf),`).`]})]})}function Kt({status:e,message:t,lastGood:n,onRetry:r}){return(0,E.jsxs)(`div`,{"data-testid":`state-http-error`,role:`alert`,children:[(0,E.jsxs)(`h2`,{children:[`Request failed (HTTP `,e,`)`]}),(0,E.jsx)(`p`,{children:t}),(0,E.jsx)(`button`,{type:`button`,onClick:r,children:`Retry`}),n&&(0,E.jsxs)(`p`,{children:[`Showing last readings (`,ae(n.asOf),`).`]})]})}function qt({snapshot:e,onSelectProvider:t,onViewAdvice:n}){return(0,E.jsxs)(`div`,{"data-testid":`dashboard-root`,className:`dashboard`,children:[(0,E.jsx)(ke,{recommendation:e.recommendation,providers:e.providers,asOf:e.asOf,onSelectProvider:t,onViewAdvice:n}),!re(e)&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(qe,{providers:e.providers,asOf:e.asOf,onSelectProvider:t}),(0,E.jsx)(Le,{providers:e.providers,recommendation:e.recommendation,asOf:e.asOf,lastCompletedPollAt:e.runtime.lastCompletedPollAt,polling:e.runtime.polling,onSelectProvider:t})]})]})}function Jt(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(!1),g=Ct(),v=e?bt(g,re(e)):null;(0,_.useEffect)(()=>{v&&v!==g&&St(v)},[v,g]);let S=(0,_.useCallback)(async()=>{try{t(T(await C())),r(null)}catch(e){e instanceof b?r({kind:`service-unavailable`,message:e.message}):e instanceof x?r({kind:`http-error`,status:e.status,message:e.message}):r({kind:`http-error`,status:0,message:String(e)})}finally{a(!1)}},[]);(0,_.useEffect)(()=>{S()},[S]);let w=(0,_.useCallback)(async()=>{s(!0),l(null);try{let e=await te();e.message&&l(e.message),await S()}catch(e){e instanceof b?r({kind:`service-unavailable`,message:e.message}):e instanceof x?r({kind:`http-error`,status:e.status,message:e.message}):r({kind:`http-error`,status:0,message:String(e)})}finally{s(!1)}},[S]),ee=v===`/setup`,ne=n?n.kind===`http-error`?`Request failed (HTTP ${n.status}): ${n.message}`:`Service unavailable: ${n.message}`:null,ie=(0,E.jsx)(Lt,{runtime:e?.runtime??null,unreachable:n?.kind===`service-unavailable`,refreshing:o,onRefresh:()=>void w(),onSettings:()=>h(!0)});return e&&ee?(0,E.jsxs)(E.Fragment,{children:[ie,(0,E.jsx)(`main`,{children:(0,E.jsx)(Dt,{snapshot:e,onFirstPoll:()=>void w(),polling:o,pollError:ne})}),(0,E.jsx)(yt,{open:m,providers:e.providers,onRefresh:()=>void w(),refreshing:o,onClose:()=>h(!1)}),(0,E.jsx)(Wt,{version:e.runtime.version})]}):(0,E.jsxs)(E.Fragment,{children:[ie,(0,E.jsxs)(`main`,{children:[c&&(0,E.jsx)(`div`,{"data-testid":`refresh-notice`,role:`status`,children:c}),i&&!e&&(0,E.jsx)(`div`,{"data-testid":`state-loading`,"aria-busy":`true`,"aria-label":`Loading quota state`,children:[0,1,2].map(e=>(0,E.jsx)(`div`,{"aria-hidden":`true`,className:`skel`,style:{height:64,background:`var(--surface-raised)`,border:e===0?`1px solid var(--rec)`:`1px solid var(--line)`,borderRadius:8,marginBottom:8}},e))}),n?.kind===`service-unavailable`&&!e&&(0,E.jsx)(Gt,{endpoint:y(),lastGood:e,onRetry:()=>void S()}),n?.kind===`http-error`&&!e&&(0,E.jsx)(Kt,{status:n.status,message:n.message,lastGood:e,onRetry:()=>void S()}),n&&e&&(0,E.jsxs)(`div`,{"data-testid":`state-stale-error`,role:`alert`,children:[n.kind===`http-error`?`Request failed (HTTP ${n.status}): `:`Service unavailable: `,n.message,` Showing last readings (`,ae(e.asOf),`).`,` `,(0,E.jsx)(`button`,{type:`button`,onClick:()=>void S(),children:`Retry`})]}),e&&(0,E.jsx)(Bt,{providers:e.providers,onRepoll:()=>void w(),repolling:o}),e&&(0,E.jsx)(qt,{snapshot:e,onSelectProvider:e=>{p(!1),d(e)},onViewAdvice:()=>{d(null),p(!0)}})]}),(0,E.jsx)(st,{provider:e?.providers.find(e=>e.id===u)??null,asOf:e?.asOf??``,recommendation:e?.recommendation??null,onClose:()=>d(null),onRenamed:()=>void S()}),e&&(0,E.jsx)(ct,{open:f,recommendation:e.recommendation,providers:e.providers,asOf:e.asOf,onClose:()=>p(!1)}),(0,E.jsx)(yt,{open:m,providers:e?.providers??[],onRefresh:()=>void w(),refreshing:o,onClose:()=>h(!1)}),(0,E.jsx)(Wt,{version:e?.runtime.version})]})}var Yt=typeof document>`u`?null:document.getElementById(`app`);Yt&&(0,v.createRoot)(Yt).render((0,E.jsx)(Jt,{}));
@@ -12,7 +12,7 @@ try {
12
12
  document.documentElement.dataset.theme = dark ? "dark" : "light";
13
13
  } catch (e) { /* default light theme stands */ }
14
14
  </script>
15
- <script type="module" crossorigin src="/assets/index-ClNhsr1-.js"></script>
15
+ <script type="module" crossorigin src="/assets/index-hmABfkqB.js"></script>
16
16
  <link rel="stylesheet" crossorigin href="/assets/index-TJk_KDbS.css">
17
17
  </head>
18
18
  <body><div id="app"></div></body>