@ainyc/canonry 4.50.0 → 4.51.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/assets/assets/BacklinksPage-DIZCcqsP.js +1 -0
  2. package/assets/assets/ChartPrimitives-9Kx3gzQL.js +1 -0
  3. package/assets/assets/ProjectPage-R2cxJb5Y.js +6 -0
  4. package/assets/assets/RunRow-DqezNIUy.js +1 -0
  5. package/assets/assets/RunsPage-CfvTJ9Ny.js +1 -0
  6. package/assets/assets/SettingsPage-HfMGIa5v.js +1 -0
  7. package/assets/assets/TrafficPage-DV_Dvpl3.js +1 -0
  8. package/assets/assets/TrafficSourceDetailPage-lefreKBO.js +1 -0
  9. package/assets/assets/arrow-left-DpxpMUNt.js +1 -0
  10. package/assets/assets/index-DKBPD33e.js +210 -0
  11. package/assets/assets/{index-DOP3oQmw.css → index-DeGyEwik.css} +1 -1
  12. package/assets/assets/server-traffic-Bm8iKtXK.js +1 -0
  13. package/assets/assets/trash-2-CnBiLbiZ.js +1 -0
  14. package/assets/assets/{vendor-markdown-DN2199pt.js → vendor-markdown-DK7fbRNb.js} +1 -1
  15. package/assets/assets/{vendor-radix-Bvy4KXTI.js → vendor-radix-B57xfQbP.js} +1 -1
  16. package/assets/assets/{vendor-recharts-DPeiXMwW.js → vendor-recharts-DWvKDyBF.js} +1 -1
  17. package/assets/assets/vendor-tanstack-Dq7p98wZ.js +1 -0
  18. package/assets/index.html +6 -6
  19. package/dist/{chunk-QIG3TKL4.js → chunk-2ARCCG5E.js} +72 -1
  20. package/dist/{chunk-M4USKXJ4.js → chunk-DLDLDWH4.js} +128 -40
  21. package/dist/{chunk-MYDJ25GO.js → chunk-GGXU5VKI.js} +111 -77
  22. package/dist/{chunk-YVP5CTSV.js → chunk-JOKPYAEL.js} +2178 -1624
  23. package/dist/cli.js +6 -6
  24. package/dist/index.js +4 -4
  25. package/dist/{intelligence-service-TY7IPRST.js → intelligence-service-XMZEWLCW.js} +2 -2
  26. package/dist/mcp.js +2 -2
  27. package/package.json +9 -9
  28. package/assets/assets/index-DVK0M62U.js +0 -214
  29. package/assets/assets/vendor-tanstack-DPXTJtWt.js +0 -1
@@ -1,214 +0,0 @@
1
- import{c as _S,d as ES,Q as DS,M as OS,r as j,q as vt,j as t,L as ft,a as RS,e as kr,u as tn,f as Fb,h as bo,k as LS,l as MS,m as Yb,O as Xb,n as wn,o as bs,p as Jb,s as $S,t as Sn,v as Wb,x as BS,y as qS,z as IS}from"./vendor-tanstack-DPXTJtWt.js";import{S as US,O as yf,P as ev,C as bf,a as tv,T as vf,D as nv,R as sv}from"./vendor-radix-Bvy4KXTI.js";import{c as av,R as uu,C as Uh,X as du,Y as mu,T as hu,L as PS,A as ao,B as GS,a as VS,b as ny,d as sy}from"./vendor-recharts-DPeiXMwW.js";import{M as HS}from"./vendor-markdown-DN2199pt.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const u of o)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&r(d)}).observe(document,{childList:!0,subtree:!0});function i(o){const u={};return o.integrity&&(u.integrity=o.integrity),o.referrerPolicy&&(u.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?u.credentials="include":o.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function r(o){if(o.ep)return;o.ep=!0;const u=i(o);fetch(o.href,u)}})();var hh={exports:{}},Yl={},fh={exports:{}},ph={};var ay;function KS(){return ay||(ay=1,(function(e){function s(V,ne){var me=V.length;V.push(ne);e:for(;0<me;){var Ne=me-1>>>1,se=V[Ne];if(0<o(se,ne))V[Ne]=ne,V[me]=se,me=Ne;else break e}}function i(V){return V.length===0?null:V[0]}function r(V){if(V.length===0)return null;var ne=V[0],me=V.pop();if(me!==ne){V[0]=me;e:for(var Ne=0,se=V.length,pe=se>>>1;Ne<pe;){var E=2*(Ne+1)-1,X=V[E],Y=E+1,ye=V[Y];if(0>o(X,me))Y<se&&0>o(ye,X)?(V[Ne]=ye,V[Y]=me,Ne=Y):(V[Ne]=X,V[E]=me,Ne=E);else if(Y<se&&0>o(ye,me))V[Ne]=ye,V[Y]=me,Ne=Y;else break e}}return ne}function o(V,ne){var me=V.sortIndex-ne.sortIndex;return me!==0?me:V.id-ne.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var d=Date,h=d.now();e.unstable_now=function(){return d.now()-h}}var p=[],x=[],b=1,v=null,N=3,z=!1,T=!1,w=!1,A=!1,D=typeof setTimeout=="function"?setTimeout:null,U=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;function C(V){for(var ne=i(x);ne!==null;){if(ne.callback===null)r(x);else if(ne.startTime<=V)r(x),ne.sortIndex=ne.expirationTime,s(p,ne);else break;ne=i(x)}}function L(V){if(w=!1,C(V),!T)if(i(p)!==null)T=!0,M||(M=!0,ie());else{var ne=i(x);ne!==null&&ve(L,ne.startTime-V)}}var M=!1,_=-1,B=5,J=-1;function ue(){return A?!0:!(e.unstable_now()-J<B)}function P(){if(A=!1,M){var V=e.unstable_now();J=V;var ne=!0;try{e:{T=!1,w&&(w=!1,U(_),_=-1),z=!0;var me=N;try{t:{for(C(V),v=i(p);v!==null&&!(v.expirationTime>V&&ue());){var Ne=v.callback;if(typeof Ne=="function"){v.callback=null,N=v.priorityLevel;var se=Ne(v.expirationTime<=V);if(V=e.unstable_now(),typeof se=="function"){v.callback=se,C(V),ne=!0;break t}v===i(p)&&r(p),C(V)}else r(p);v=i(p)}if(v!==null)ne=!0;else{var pe=i(x);pe!==null&&ve(L,pe.startTime-V),ne=!1}}break e}finally{v=null,N=me,z=!1}ne=void 0}}finally{ne?ie():M=!1}}}var ie;if(typeof I=="function")ie=function(){I(P)};else if(typeof MessageChannel<"u"){var te=new MessageChannel,ze=te.port2;te.port1.onmessage=P,ie=function(){ze.postMessage(null)}}else ie=function(){D(P,0)};function ve(V,ne){_=D(function(){V(e.unstable_now())},ne)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(V){V.callback=null},e.unstable_forceFrameRate=function(V){0>V||125<V?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):B=0<V?Math.floor(1e3/V):5},e.unstable_getCurrentPriorityLevel=function(){return N},e.unstable_next=function(V){switch(N){case 1:case 2:case 3:var ne=3;break;default:ne=N}var me=N;N=ne;try{return V()}finally{N=me}},e.unstable_requestPaint=function(){A=!0},e.unstable_runWithPriority=function(V,ne){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var me=N;N=V;try{return ne()}finally{N=me}},e.unstable_scheduleCallback=function(V,ne,me){var Ne=e.unstable_now();switch(typeof me=="object"&&me!==null?(me=me.delay,me=typeof me=="number"&&0<me?Ne+me:Ne):me=Ne,V){case 1:var se=-1;break;case 2:se=250;break;case 5:se=1073741823;break;case 4:se=1e4;break;default:se=5e3}return se=me+se,V={id:b++,callback:ne,priorityLevel:V,startTime:me,expirationTime:se,sortIndex:-1},me>Ne?(V.sortIndex=me,s(x,V),i(p)===null&&V===i(x)&&(w?(U(_),_=-1):w=!0,ve(L,me-Ne))):(V.sortIndex=se,s(p,V),T||z||(T=!0,M||(M=!0,ie()))),V},e.unstable_shouldYield=ue,e.unstable_wrapCallback=function(V){var ne=N;return function(){var me=N;N=ne;try{return V.apply(this,arguments)}finally{N=me}}}})(ph)),ph}var iy;function QS(){return iy||(iy=1,fh.exports=KS()),fh.exports}var ry;function ZS(){if(ry)return Yl;ry=1;var e=QS(),s=_S(),i=ES();function r(n){var a="https://react.dev/errors/"+n;if(1<arguments.length){a+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)a+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+n+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function u(n){var a=n,l=n;if(n.alternate)for(;a.return;)a=a.return;else{n=a;do a=n,(a.flags&4098)!==0&&(l=a.return),n=a.return;while(n)}return a.tag===3?l:null}function d(n){if(n.tag===13){var a=n.memoizedState;if(a===null&&(n=n.alternate,n!==null&&(a=n.memoizedState)),a!==null)return a.dehydrated}return null}function h(n){if(n.tag===31){var a=n.memoizedState;if(a===null&&(n=n.alternate,n!==null&&(a=n.memoizedState)),a!==null)return a.dehydrated}return null}function p(n){if(u(n)!==n)throw Error(r(188))}function x(n){var a=n.alternate;if(!a){if(a=u(n),a===null)throw Error(r(188));return a!==n?null:n}for(var l=n,c=a;;){var m=l.return;if(m===null)break;var f=m.alternate;if(f===null){if(c=m.return,c!==null){l=c;continue}break}if(m.child===f.child){for(f=m.child;f;){if(f===l)return p(m),n;if(f===c)return p(m),a;f=f.sibling}throw Error(r(188))}if(l.return!==c.return)l=m,c=f;else{for(var y=!1,S=m.child;S;){if(S===l){y=!0,l=m,c=f;break}if(S===c){y=!0,c=m,l=f;break}S=S.sibling}if(!y){for(S=f.child;S;){if(S===l){y=!0,l=f,c=m;break}if(S===c){y=!0,c=f,l=m;break}S=S.sibling}if(!y)throw Error(r(189))}}if(l.alternate!==c)throw Error(r(190))}if(l.tag!==3)throw Error(r(188));return l.stateNode.current===l?n:a}function b(n){var a=n.tag;if(a===5||a===26||a===27||a===6)return n;for(n=n.child;n!==null;){if(a=b(n),a!==null)return a;n=n.sibling}return null}var v=Object.assign,N=Symbol.for("react.element"),z=Symbol.for("react.transitional.element"),T=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),D=Symbol.for("react.profiler"),U=Symbol.for("react.consumer"),I=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),M=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),B=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),ue=Symbol.for("react.memo_cache_sentinel"),P=Symbol.iterator;function ie(n){return n===null||typeof n!="object"?null:(n=P&&n[P]||n["@@iterator"],typeof n=="function"?n:null)}var te=Symbol.for("react.client.reference");function ze(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===te?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case w:return"Fragment";case D:return"Profiler";case A:return"StrictMode";case L:return"Suspense";case M:return"SuspenseList";case J:return"Activity"}if(typeof n=="object")switch(n.$$typeof){case T:return"Portal";case I:return n.displayName||"Context";case U:return(n._context.displayName||"Context")+".Consumer";case C:var a=n.render;return n=n.displayName,n||(n=a.displayName||a.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case _:return a=n.displayName||null,a!==null?a:ze(n.type)||"Memo";case B:a=n._payload,n=n._init;try{return ze(n(a))}catch{}}return null}var ve=Array.isArray,V=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,me={pending:!1,data:null,method:null,action:null},Ne=[],se=-1;function pe(n){return{current:n}}function E(n){0>se||(n.current=Ne[se],Ne[se]=null,se--)}function X(n,a){se++,Ne[se]=n.current,n.current=a}var Y=pe(null),ye=pe(null),le=pe(null),Re=pe(null);function tt(n,a){switch(X(le,a),X(ye,n),X(Y,null),a.nodeType){case 9:case 11:n=(n=a.documentElement)&&(n=n.namespaceURI)?z0(n):0;break;default:if(n=a.tagName,a=a.namespaceURI)a=z0(a),n=k0(a,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}E(Y),X(Y,n)}function we(){E(Y),E(ye),E(le)}function Ue(n){n.memoizedState!==null&&X(Re,n);var a=Y.current,l=k0(a,n.type);a!==l&&(X(ye,n),X(Y,l))}function Ce(n){ye.current===n&&(E(Y),E(ye)),Re.current===n&&(E(Re),Kl._currentValue=me)}var mt,Nt;function pt(n){if(mt===void 0)try{throw Error()}catch(l){var a=l.stack.trim().match(/\n( *(at )?)/);mt=a&&a[1]||"",Nt=-1<l.stack.indexOf(`
2
- at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
3
- `+mt+n+Nt}var gt=!1;function St(n,a){if(!n||gt)return"";gt=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(a){var de=function(){throw Error()};if(Object.defineProperty(de.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(de,[])}catch(W){var Z=W}Reflect.construct(n,[],de)}else{try{de.call()}catch(W){Z=W}n.call(de.prototype)}}else{try{throw Error()}catch(W){Z=W}(de=n())&&typeof de.catch=="function"&&de.catch(function(){})}}catch(W){if(W&&Z&&typeof W.stack=="string")return[W.stack,Z.stack]}return[null,null]}};c.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var m=Object.getOwnPropertyDescriptor(c.DetermineComponentFrameRoot,"name");m&&m.configurable&&Object.defineProperty(c.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var f=c.DetermineComponentFrameRoot(),y=f[0],S=f[1];if(y&&S){var $=y.split(`
4
- `),Q=S.split(`
5
- `);for(m=c=0;c<$.length&&!$[c].includes("DetermineComponentFrameRoot");)c++;for(;m<Q.length&&!Q[m].includes("DetermineComponentFrameRoot");)m++;if(c===$.length||m===Q.length)for(c=$.length-1,m=Q.length-1;1<=c&&0<=m&&$[c]!==Q[m];)m--;for(;1<=c&&0<=m;c--,m--)if($[c]!==Q[m]){if(c!==1||m!==1)do if(c--,m--,0>m||$[c]!==Q[m]){var re=`
6
- `+$[c].replace(" at new "," at ");return n.displayName&&re.includes("<anonymous>")&&(re=re.replace("<anonymous>",n.displayName)),re}while(1<=c&&0<=m);break}}}finally{gt=!1,Error.prepareStackTrace=l}return(l=n?n.displayName||n.name:"")?pt(l):""}function Fn(n,a){switch(n.tag){case 26:case 27:case 5:return pt(n.type);case 16:return pt("Lazy");case 13:return n.child!==a&&a!==null?pt("Suspense Fallback"):pt("Suspense");case 19:return pt("SuspenseList");case 0:case 15:return St(n.type,!1);case 11:return St(n.type.render,!1);case 1:return St(n.type,!0);case 31:return pt("Activity");default:return""}}function be(n){try{var a="",l=null;do a+=Fn(n,l),l=n,n=n.return;while(n);return a}catch(c){return`
7
- Error generating stack: `+c.message+`
8
- `+c.stack}}var Ae=Object.prototype.hasOwnProperty,sn=e.unstable_scheduleCallback,Zt=e.unstable_cancelCallback,an=e.unstable_shouldYield,ws=e.unstable_requestPaint,$t=e.unstable_now,$n=e.unstable_getCurrentPriorityLevel,Yn=e.unstable_ImmediatePriority,dn=e.unstable_UserBlockingPriority,zn=e.unstable_NormalPriority,rs=e.unstable_LowPriority,kn=e.unstable_IdlePriority,Ss=e.log,zs=e.unstable_setDisableYieldValue,F=null,Pe=null;function He(n){if(typeof Ss=="function"&&zs(n),Pe&&typeof Pe.setStrictMode=="function")try{Pe.setStrictMode(F,n)}catch{}}var ut=Math.clz32?Math.clz32:ui,ht=Math.log,ls=Math.LN2;function ui(n){return n>>>=0,n===0?32:31-(ht(n)/ls|0)|0}var Ks=256,ks=262144,Ft=4194304;function he(n){var a=n&42;if(a!==0)return a;switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function qe(n,a,l){var c=n.pendingLanes;if(c===0)return 0;var m=0,f=n.suspendedLanes,y=n.pingedLanes;n=n.warmLanes;var S=c&134217727;return S!==0?(c=S&~f,c!==0?m=he(c):(y&=S,y!==0?m=he(y):l||(l=S&~n,l!==0&&(m=he(l))))):(S=c&~f,S!==0?m=he(S):y!==0?m=he(y):l||(l=c&~n,l!==0&&(m=he(l)))),m===0?0:a!==0&&a!==m&&(a&f)===0&&(f=m&-m,l=a&-a,f>=l||f===32&&(l&4194048)!==0)?a:m}function De(n,a){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&a)===0}function Ge(n,a){switch(n){case 1:case 2:case 4:case 8:case 64:return a+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Xe(){var n=Ft;return Ft<<=1,(Ft&62914560)===0&&(Ft=4194304),n}function fe(n){for(var a=[],l=0;31>l;l++)a.push(n);return a}function $e(n,a){n.pendingLanes|=a,a!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function We(n,a,l,c,m,f){var y=n.pendingLanes;n.pendingLanes=l,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=l,n.entangledLanes&=l,n.errorRecoveryDisabledLanes&=l,n.shellSuspendCounter=0;var S=n.entanglements,$=n.expirationTimes,Q=n.hiddenUpdates;for(l=y&~l;0<l;){var re=31-ut(l),de=1<<re;S[re]=0,$[re]=-1;var Z=Q[re];if(Z!==null)for(Q[re]=null,re=0;re<Z.length;re++){var W=Z[re];W!==null&&(W.lane&=-536870913)}l&=~de}c!==0&&Cs(n,c,0),f!==0&&m===0&&n.tag!==0&&(n.suspendedLanes|=f&~(y&~a))}function Cs(n,a,l){n.pendingLanes|=a,n.suspendedLanes&=~a;var c=31-ut(a);n.entangledLanes|=a,n.entanglements[c]=n.entanglements[c]|1073741824|l&261930}function As(n,a){var l=n.entangledLanes|=a;for(n=n.entanglements;l;){var c=31-ut(l),m=1<<c;m&a|n[c]&a&&(n[c]|=a),l&=~m}}function mn(n,a){var l=a&-a;return l=(l&42)!==0?1:Qs(l),(l&(n.suspendedLanes|a))!==0?0:l}function Qs(n){switch(n){case 2:n=1;break;case 8:n=4;break;case 32:n=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:n=128;break;case 268435456:n=134217728;break;default:n=0}return n}function Bn(n){return n&=-n,2<n?8<n?(n&134217727)!==0?32:268435456:8:2}function Zs(){var n=ne.p;return n!==0?n:(n=window.event,n===void 0?32:F0(n.type))}function Hi(n,a){var l=ne.p;try{return ne.p=n,a()}finally{ne.p=l}}var Xn=Math.random().toString(36).slice(2),Yt="__reactFiber$"+Xn,hn="__reactProps$"+Xn,ba="__reactContainer$"+Xn,va="__reactEvents$"+Xn,Ao="__reactListeners$"+Xn,rd="__reactHandles$"+Xn,rl="__reactResources$"+Xn,ja="__reactMarker$"+Xn;function ll(n){delete n[Yt],delete n[hn],delete n[va],delete n[Ao],delete n[rd]}function Na(n){var a=n[Yt];if(a)return a;for(var l=n.parentNode;l;){if(a=l[ba]||l[Yt]){if(l=a.alternate,a.child!==null||l!==null&&l.child!==null)for(n=O0(n);n!==null;){if(l=n[Yt])return l;n=O0(n)}return a}n=l,l=n.parentNode}return null}function wa(n){if(n=n[Yt]||n[ba]){var a=n.tag;if(a===5||a===6||a===13||a===31||a===26||a===27||a===3)return n}return null}function di(n){var a=n.tag;if(a===5||a===26||a===27||a===6)return n.stateNode;throw Error(r(33))}function Fs(n){var a=n[rl];return a||(a=n[rl]={hoistableStyles:new Map,hoistableScripts:new Map}),a}function O(n){n[ja]=!0}var ge=new Set,Fe={};function at(n,a){Dt(n,a),Dt(n+"Capture",a)}function Dt(n,a){for(Fe[n]=a,n=0;n<a.length;n++)ge.add(a[n])}var Cn=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),_n={},Ys={};function qn(n){return Ae.call(Ys,n)?!0:Ae.call(_n,n)?!1:Cn.test(n)?Ys[n]=!0:(_n[n]=!0,!1)}function Ki(n,a,l){if(qn(a))if(l===null)n.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":n.removeAttribute(a);return;case"boolean":var c=a.toLowerCase().slice(0,5);if(c!=="data-"&&c!=="aria-"){n.removeAttribute(a);return}}n.setAttribute(a,""+l)}}function Ts(n,a,l){if(l===null)n.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(a);return}n.setAttribute(a,""+l)}}function En(n,a,l,c){if(c===null)n.removeAttribute(l);else{switch(typeof c){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(l);return}n.setAttributeNS(a,l,""+c)}}function fn(n){switch(typeof n){case"bigint":case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function ol(n){var a=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function ld(n,a,l){var c=Object.getOwnPropertyDescriptor(n.constructor.prototype,a);if(!n.hasOwnProperty(a)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var m=c.get,f=c.set;return Object.defineProperty(n,a,{configurable:!0,get:function(){return m.call(this)},set:function(y){l=""+y,f.call(this,y)}}),Object.defineProperty(n,a,{enumerable:c.enumerable}),{getValue:function(){return l},setValue:function(y){l=""+y},stopTracking:function(){n._valueTracker=null,delete n[a]}}}}function Sa(n){if(!n._valueTracker){var a=ol(n)?"checked":"value";n._valueTracker=ld(n,a,""+n[a])}}function mi(n){if(!n)return!1;var a=n._valueTracker;if(!a)return!0;var l=a.getValue(),c="";return n&&(c=ol(n)?n.checked?"true":"false":n.value),n=c,n!==l?(a.setValue(n),!0):!1}function Qi(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var od=/[\n"\\]/g;function it(n){return n.replace(od,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function Jn(n,a,l,c,m,f,y,S){n.name="",y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"?n.type=y:n.removeAttribute("type"),a!=null?y==="number"?(a===0&&n.value===""||n.value!=a)&&(n.value=""+fn(a)):n.value!==""+fn(a)&&(n.value=""+fn(a)):y!=="submit"&&y!=="reset"||n.removeAttribute("value"),a!=null?os(n,y,fn(a)):l!=null?os(n,y,fn(l)):c!=null&&n.removeAttribute("value"),m==null&&f!=null&&(n.defaultChecked=!!f),m!=null&&(n.checked=m&&typeof m!="function"&&typeof m!="symbol"),S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?n.name=""+fn(S):n.removeAttribute("name")}function Dn(n,a,l,c,m,f,y,S){if(f!=null&&typeof f!="function"&&typeof f!="symbol"&&typeof f!="boolean"&&(n.type=f),a!=null||l!=null){if(!(f!=="submit"&&f!=="reset"||a!=null)){Sa(n);return}l=l!=null?""+fn(l):"",a=a!=null?""+fn(a):l,S||a===n.value||(n.value=a),n.defaultValue=a}c=c??m,c=typeof c!="function"&&typeof c!="symbol"&&!!c,n.checked=S?n.checked:!!c,n.defaultChecked=!!c,y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(n.name=y),Sa(n)}function os(n,a,l){a==="number"&&Qi(n.ownerDocument)===n||n.defaultValue===""+l||(n.defaultValue=""+l)}function _s(n,a,l,c){if(n=n.options,a){a={};for(var m=0;m<l.length;m++)a["$"+l[m]]=!0;for(l=0;l<n.length;l++)m=a.hasOwnProperty("$"+n[l].value),n[l].selected!==m&&(n[l].selected=m),m&&c&&(n[l].defaultSelected=!0)}else{for(l=""+fn(l),a=null,m=0;m<n.length;m++){if(n[m].value===l){n[m].selected=!0,c&&(n[m].defaultSelected=!0);return}a!==null||n[m].disabled||(a=n[m])}a!==null&&(a.selected=!0)}}function vp(n,a,l){if(a!=null&&(a=""+fn(a),a!==n.value&&(n.value=a),l==null)){n.defaultValue!==a&&(n.defaultValue=a);return}n.defaultValue=l!=null?""+fn(l):""}function jp(n,a,l,c){if(a==null){if(c!=null){if(l!=null)throw Error(r(92));if(ve(c)){if(1<c.length)throw Error(r(93));c=c[0]}l=c}l==null&&(l=""),a=l}l=fn(a),n.defaultValue=l,c=n.textContent,c===l&&c!==""&&c!==null&&(n.value=c),Sa(n)}function Zi(n,a){if(a){var l=n.firstChild;if(l&&l===n.lastChild&&l.nodeType===3){l.nodeValue=a;return}}n.textContent=a}var z1=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Np(n,a,l){var c=a.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?c?n.setProperty(a,""):a==="float"?n.cssFloat="":n[a]="":c?n.setProperty(a,l):typeof l!="number"||l===0||z1.has(a)?a==="float"?n.cssFloat=l:n[a]=(""+l).trim():n[a]=l+"px"}function wp(n,a,l){if(a!=null&&typeof a!="object")throw Error(r(62));if(n=n.style,l!=null){for(var c in l)!l.hasOwnProperty(c)||a!=null&&a.hasOwnProperty(c)||(c.indexOf("--")===0?n.setProperty(c,""):c==="float"?n.cssFloat="":n[c]="");for(var m in a)c=a[m],a.hasOwnProperty(m)&&l[m]!==c&&Np(n,m,c)}else for(var f in a)a.hasOwnProperty(f)&&Np(n,f,a[f])}function cd(n){if(n.indexOf("-")===-1)return!1;switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var k1=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),C1=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function To(n){return C1.test(""+n)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":n}function Xs(){}var ud=null;function dd(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Fi=null,Yi=null;function Sp(n){var a=wa(n);if(a&&(n=a.stateNode)){var l=n[hn]||null;e:switch(n=a.stateNode,a.type){case"input":if(Jn(n,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),a=l.name,l.type==="radio"&&a!=null){for(l=n;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+it(""+a)+'"][type="radio"]'),a=0;a<l.length;a++){var c=l[a];if(c!==n&&c.form===n.form){var m=c[hn]||null;if(!m)throw Error(r(90));Jn(c,m.value,m.defaultValue,m.defaultValue,m.checked,m.defaultChecked,m.type,m.name)}}for(a=0;a<l.length;a++)c=l[a],c.form===n.form&&mi(c)}break e;case"textarea":vp(n,l.value,l.defaultValue);break e;case"select":a=l.value,a!=null&&_s(n,!!l.multiple,a,!1)}}}var md=!1;function zp(n,a,l){if(md)return n(a,l);md=!0;try{var c=n(a);return c}finally{if(md=!1,(Fi!==null||Yi!==null)&&(gc(),Fi&&(a=Fi,n=Yi,Yi=Fi=null,Sp(a),n)))for(a=0;a<n.length;a++)Sp(n[a])}}function cl(n,a){var l=n.stateNode;if(l===null)return null;var c=l[hn]||null;if(c===null)return null;l=c[a];e:switch(a){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(n=n.type,c=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!c;break e;default:n=!1}if(n)return null;if(l&&typeof l!="function")throw Error(r(231,a,typeof l));return l}var Js=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),hd=!1;if(Js)try{var ul={};Object.defineProperty(ul,"passive",{get:function(){hd=!0}}),window.addEventListener("test",ul,ul),window.removeEventListener("test",ul,ul)}catch{hd=!1}var za=null,fd=null,_o=null;function kp(){if(_o)return _o;var n,a=fd,l=a.length,c,m="value"in za?za.value:za.textContent,f=m.length;for(n=0;n<l&&a[n]===m[n];n++);var y=l-n;for(c=1;c<=y&&a[l-c]===m[f-c];c++);return _o=m.slice(n,1<c?1-c:void 0)}function Eo(n){var a=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&a===13&&(n=13)):n=a,n===10&&(n=13),32<=n||n===13?n:0}function Do(){return!0}function Cp(){return!1}function In(n){function a(l,c,m,f,y){this._reactName=l,this._targetInst=m,this.type=c,this.nativeEvent=f,this.target=y,this.currentTarget=null;for(var S in n)n.hasOwnProperty(S)&&(l=n[S],this[S]=l?l(f):f[S]);return this.isDefaultPrevented=(f.defaultPrevented!=null?f.defaultPrevented:f.returnValue===!1)?Do:Cp,this.isPropagationStopped=Cp,this}return v(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=Do)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Do)},persist:function(){},isPersistent:Do}),a}var hi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Oo=In(hi),dl=v({},hi,{view:0,detail:0}),A1=In(dl),pd,gd,ml,Ro=v({},dl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:yd,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==ml&&(ml&&n.type==="mousemove"?(pd=n.screenX-ml.screenX,gd=n.screenY-ml.screenY):gd=pd=0,ml=n),pd)},movementY:function(n){return"movementY"in n?n.movementY:gd}}),Ap=In(Ro),T1=v({},Ro,{dataTransfer:0}),_1=In(T1),E1=v({},dl,{relatedTarget:0}),xd=In(E1),D1=v({},hi,{animationName:0,elapsedTime:0,pseudoElement:0}),O1=In(D1),R1=v({},hi,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),L1=In(R1),M1=v({},hi,{data:0}),Tp=In(M1),$1={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},B1={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},q1={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function I1(n){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(n):(n=q1[n])?!!a[n]:!1}function yd(){return I1}var U1=v({},dl,{key:function(n){if(n.key){var a=$1[n.key]||n.key;if(a!=="Unidentified")return a}return n.type==="keypress"?(n=Eo(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?B1[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:yd,charCode:function(n){return n.type==="keypress"?Eo(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Eo(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),P1=In(U1),G1=v({},Ro,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),_p=In(G1),V1=v({},dl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:yd}),H1=In(V1),K1=v({},hi,{propertyName:0,elapsedTime:0,pseudoElement:0}),Q1=In(K1),Z1=v({},Ro,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),F1=In(Z1),Y1=v({},hi,{newState:0,oldState:0}),X1=In(Y1),J1=[9,13,27,32],bd=Js&&"CompositionEvent"in window,hl=null;Js&&"documentMode"in document&&(hl=document.documentMode);var W1=Js&&"TextEvent"in window&&!hl,Ep=Js&&(!bd||hl&&8<hl&&11>=hl),Dp=" ",Op=!1;function Rp(n,a){switch(n){case"keyup":return J1.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Lp(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Xi=!1;function ew(n,a){switch(n){case"compositionend":return Lp(a);case"keypress":return a.which!==32?null:(Op=!0,Dp);case"textInput":return n=a.data,n===Dp&&Op?null:n;default:return null}}function tw(n,a){if(Xi)return n==="compositionend"||!bd&&Rp(n,a)?(n=kp(),_o=fd=za=null,Xi=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return Ep&&a.locale!=="ko"?null:a.data;default:return null}}var nw={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Mp(n){var a=n&&n.nodeName&&n.nodeName.toLowerCase();return a==="input"?!!nw[n.type]:a==="textarea"}function $p(n,a,l,c){Fi?Yi?Yi.push(c):Yi=[c]:Fi=c,a=wc(a,"onChange"),0<a.length&&(l=new Oo("onChange","change",null,l,c),n.push({event:l,listeners:a}))}var fl=null,pl=null;function sw(n){b0(n,0)}function Lo(n){var a=di(n);if(mi(a))return n}function Bp(n,a){if(n==="change")return a}var qp=!1;if(Js){var vd;if(Js){var jd="oninput"in document;if(!jd){var Ip=document.createElement("div");Ip.setAttribute("oninput","return;"),jd=typeof Ip.oninput=="function"}vd=jd}else vd=!1;qp=vd&&(!document.documentMode||9<document.documentMode)}function Up(){fl&&(fl.detachEvent("onpropertychange",Pp),pl=fl=null)}function Pp(n){if(n.propertyName==="value"&&Lo(pl)){var a=[];$p(a,pl,n,dd(n)),zp(sw,a)}}function aw(n,a,l){n==="focusin"?(Up(),fl=a,pl=l,fl.attachEvent("onpropertychange",Pp)):n==="focusout"&&Up()}function iw(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Lo(pl)}function rw(n,a){if(n==="click")return Lo(a)}function lw(n,a){if(n==="input"||n==="change")return Lo(a)}function ow(n,a){return n===a&&(n!==0||1/n===1/a)||n!==n&&a!==a}var Wn=typeof Object.is=="function"?Object.is:ow;function gl(n,a){if(Wn(n,a))return!0;if(typeof n!="object"||n===null||typeof a!="object"||a===null)return!1;var l=Object.keys(n),c=Object.keys(a);if(l.length!==c.length)return!1;for(c=0;c<l.length;c++){var m=l[c];if(!Ae.call(a,m)||!Wn(n[m],a[m]))return!1}return!0}function Gp(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function Vp(n,a){var l=Gp(n);n=0;for(var c;l;){if(l.nodeType===3){if(c=n+l.textContent.length,n<=a&&c>=a)return{node:l,offset:a-n};n=c}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Gp(l)}}function Hp(n,a){return n&&a?n===a?!0:n&&n.nodeType===3?!1:a&&a.nodeType===3?Hp(n,a.parentNode):"contains"in n?n.contains(a):n.compareDocumentPosition?!!(n.compareDocumentPosition(a)&16):!1:!1}function Kp(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var a=Qi(n.document);a instanceof n.HTMLIFrameElement;){try{var l=typeof a.contentWindow.location.href=="string"}catch{l=!1}if(l)n=a.contentWindow;else break;a=Qi(n.document)}return a}function Nd(n){var a=n&&n.nodeName&&n.nodeName.toLowerCase();return a&&(a==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||a==="textarea"||n.contentEditable==="true")}var cw=Js&&"documentMode"in document&&11>=document.documentMode,Ji=null,wd=null,xl=null,Sd=!1;function Qp(n,a,l){var c=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Sd||Ji==null||Ji!==Qi(c)||(c=Ji,"selectionStart"in c&&Nd(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),xl&&gl(xl,c)||(xl=c,c=wc(wd,"onSelect"),0<c.length&&(a=new Oo("onSelect","select",null,a,l),n.push({event:a,listeners:c}),a.target=Ji)))}function fi(n,a){var l={};return l[n.toLowerCase()]=a.toLowerCase(),l["Webkit"+n]="webkit"+a,l["Moz"+n]="moz"+a,l}var Wi={animationend:fi("Animation","AnimationEnd"),animationiteration:fi("Animation","AnimationIteration"),animationstart:fi("Animation","AnimationStart"),transitionrun:fi("Transition","TransitionRun"),transitionstart:fi("Transition","TransitionStart"),transitioncancel:fi("Transition","TransitionCancel"),transitionend:fi("Transition","TransitionEnd")},zd={},Zp={};Js&&(Zp=document.createElement("div").style,"AnimationEvent"in window||(delete Wi.animationend.animation,delete Wi.animationiteration.animation,delete Wi.animationstart.animation),"TransitionEvent"in window||delete Wi.transitionend.transition);function pi(n){if(zd[n])return zd[n];if(!Wi[n])return n;var a=Wi[n],l;for(l in a)if(a.hasOwnProperty(l)&&l in Zp)return zd[n]=a[l];return n}var Fp=pi("animationend"),Yp=pi("animationiteration"),Xp=pi("animationstart"),uw=pi("transitionrun"),dw=pi("transitionstart"),mw=pi("transitioncancel"),Jp=pi("transitionend"),Wp=new Map,kd="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");kd.push("scrollEnd");function Es(n,a){Wp.set(n,a),at(a,[n])}var Mo=typeof reportError=="function"?reportError:function(n){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var a=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof n=="object"&&n!==null&&typeof n.message=="string"?String(n.message):String(n),error:n});if(!window.dispatchEvent(a))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",n);return}console.error(n)},cs=[],er=0,Cd=0;function $o(){for(var n=er,a=Cd=er=0;a<n;){var l=cs[a];cs[a++]=null;var c=cs[a];cs[a++]=null;var m=cs[a];cs[a++]=null;var f=cs[a];if(cs[a++]=null,c!==null&&m!==null){var y=c.pending;y===null?m.next=m:(m.next=y.next,y.next=m),c.pending=m}f!==0&&eg(l,m,f)}}function Bo(n,a,l,c){cs[er++]=n,cs[er++]=a,cs[er++]=l,cs[er++]=c,Cd|=c,n.lanes|=c,n=n.alternate,n!==null&&(n.lanes|=c)}function Ad(n,a,l,c){return Bo(n,a,l,c),qo(n)}function gi(n,a){return Bo(n,null,null,a),qo(n)}function eg(n,a,l){n.lanes|=l;var c=n.alternate;c!==null&&(c.lanes|=l);for(var m=!1,f=n.return;f!==null;)f.childLanes|=l,c=f.alternate,c!==null&&(c.childLanes|=l),f.tag===22&&(n=f.stateNode,n===null||n._visibility&1||(m=!0)),n=f,f=f.return;return n.tag===3?(f=n.stateNode,m&&a!==null&&(m=31-ut(l),n=f.hiddenUpdates,c=n[m],c===null?n[m]=[a]:c.push(a),a.lane=l|536870912),f):null}function qo(n){if(50<ql)throw ql=0,$m=null,Error(r(185));for(var a=n.return;a!==null;)n=a,a=n.return;return n.tag===3?n.stateNode:null}var tr={};function hw(n,a,l,c){this.tag=n,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=a,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function es(n,a,l,c){return new hw(n,a,l,c)}function Td(n){return n=n.prototype,!(!n||!n.isReactComponent)}function Ws(n,a){var l=n.alternate;return l===null?(l=es(n.tag,a,n.key,n.mode),l.elementType=n.elementType,l.type=n.type,l.stateNode=n.stateNode,l.alternate=n,n.alternate=l):(l.pendingProps=a,l.type=n.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=n.flags&65011712,l.childLanes=n.childLanes,l.lanes=n.lanes,l.child=n.child,l.memoizedProps=n.memoizedProps,l.memoizedState=n.memoizedState,l.updateQueue=n.updateQueue,a=n.dependencies,l.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},l.sibling=n.sibling,l.index=n.index,l.ref=n.ref,l.refCleanup=n.refCleanup,l}function tg(n,a){n.flags&=65011714;var l=n.alternate;return l===null?(n.childLanes=0,n.lanes=a,n.child=null,n.subtreeFlags=0,n.memoizedProps=null,n.memoizedState=null,n.updateQueue=null,n.dependencies=null,n.stateNode=null):(n.childLanes=l.childLanes,n.lanes=l.lanes,n.child=l.child,n.subtreeFlags=0,n.deletions=null,n.memoizedProps=l.memoizedProps,n.memoizedState=l.memoizedState,n.updateQueue=l.updateQueue,n.type=l.type,a=l.dependencies,n.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),n}function Io(n,a,l,c,m,f){var y=0;if(c=n,typeof n=="function")Td(n)&&(y=1);else if(typeof n=="string")y=yS(n,l,Y.current)?26:n==="html"||n==="head"||n==="body"?27:5;else e:switch(n){case J:return n=es(31,l,a,m),n.elementType=J,n.lanes=f,n;case w:return xi(l.children,m,f,a);case A:y=8,m|=24;break;case D:return n=es(12,l,a,m|2),n.elementType=D,n.lanes=f,n;case L:return n=es(13,l,a,m),n.elementType=L,n.lanes=f,n;case M:return n=es(19,l,a,m),n.elementType=M,n.lanes=f,n;default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case I:y=10;break e;case U:y=9;break e;case C:y=11;break e;case _:y=14;break e;case B:y=16,c=null;break e}y=29,l=Error(r(130,n===null?"null":typeof n,"")),c=null}return a=es(y,l,a,m),a.elementType=n,a.type=c,a.lanes=f,a}function xi(n,a,l,c){return n=es(7,n,c,a),n.lanes=l,n}function _d(n,a,l){return n=es(6,n,null,a),n.lanes=l,n}function ng(n){var a=es(18,null,null,0);return a.stateNode=n,a}function Ed(n,a,l){return a=es(4,n.children!==null?n.children:[],n.key,a),a.lanes=l,a.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},a}var sg=new WeakMap;function us(n,a){if(typeof n=="object"&&n!==null){var l=sg.get(n);return l!==void 0?l:(a={value:n,source:a,stack:be(a)},sg.set(n,a),a)}return{value:n,source:a,stack:be(a)}}var nr=[],sr=0,Uo=null,yl=0,ds=[],ms=0,ka=null,qs=1,Is="";function ea(n,a){nr[sr++]=yl,nr[sr++]=Uo,Uo=n,yl=a}function ag(n,a,l){ds[ms++]=qs,ds[ms++]=Is,ds[ms++]=ka,ka=n;var c=qs;n=Is;var m=32-ut(c)-1;c&=~(1<<m),l+=1;var f=32-ut(a)+m;if(30<f){var y=m-m%5;f=(c&(1<<y)-1).toString(32),c>>=y,m-=y,qs=1<<32-ut(a)+m|l<<m|c,Is=f+n}else qs=1<<f|l<<m|c,Is=n}function Dd(n){n.return!==null&&(ea(n,1),ag(n,1,0))}function Od(n){for(;n===Uo;)Uo=nr[--sr],nr[sr]=null,yl=nr[--sr],nr[sr]=null;for(;n===ka;)ka=ds[--ms],ds[ms]=null,Is=ds[--ms],ds[ms]=null,qs=ds[--ms],ds[ms]=null}function ig(n,a){ds[ms++]=qs,ds[ms++]=Is,ds[ms++]=ka,qs=a.id,Is=a.overflow,ka=n}var pn=null,Ot=null,dt=!1,Ca=null,hs=!1,Rd=Error(r(519));function Aa(n){var a=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw bl(us(a,n)),Rd}function rg(n){var a=n.stateNode,l=n.type,c=n.memoizedProps;switch(a[Yt]=n,a[hn]=c,l){case"dialog":lt("cancel",a),lt("close",a);break;case"iframe":case"object":case"embed":lt("load",a);break;case"video":case"audio":for(l=0;l<Ul.length;l++)lt(Ul[l],a);break;case"source":lt("error",a);break;case"img":case"image":case"link":lt("error",a),lt("load",a);break;case"details":lt("toggle",a);break;case"input":lt("invalid",a),Dn(a,c.value,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name,!0);break;case"select":lt("invalid",a);break;case"textarea":lt("invalid",a),jp(a,c.value,c.defaultValue,c.children)}l=c.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||a.textContent===""+l||c.suppressHydrationWarning===!0||w0(a.textContent,l)?(c.popover!=null&&(lt("beforetoggle",a),lt("toggle",a)),c.onScroll!=null&&lt("scroll",a),c.onScrollEnd!=null&&lt("scrollend",a),c.onClick!=null&&(a.onclick=Xs),a=!0):a=!1,a||Aa(n,!0)}function lg(n){for(pn=n.return;pn;)switch(pn.tag){case 5:case 31:case 13:hs=!1;return;case 27:case 3:hs=!0;return;default:pn=pn.return}}function ar(n){if(n!==pn)return!1;if(!dt)return lg(n),dt=!0,!1;var a=n.tag,l;if((l=a!==3&&a!==27)&&((l=a===5)&&(l=n.type,l=!(l!=="form"&&l!=="button")||Jm(n.type,n.memoizedProps)),l=!l),l&&Ot&&Aa(n),lg(n),a===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(r(317));Ot=D0(n)}else if(a===31){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(r(317));Ot=D0(n)}else a===27?(a=Ot,Pa(n.type)?(n=sh,sh=null,Ot=n):Ot=a):Ot=pn?ps(n.stateNode.nextSibling):null;return!0}function yi(){Ot=pn=null,dt=!1}function Ld(){var n=Ca;return n!==null&&(Vn===null?Vn=n:Vn.push.apply(Vn,n),Ca=null),n}function bl(n){Ca===null?Ca=[n]:Ca.push(n)}var Md=pe(null),bi=null,ta=null;function Ta(n,a,l){X(Md,a._currentValue),a._currentValue=l}function na(n){n._currentValue=Md.current,E(Md)}function $d(n,a,l){for(;n!==null;){var c=n.alternate;if((n.childLanes&a)!==a?(n.childLanes|=a,c!==null&&(c.childLanes|=a)):c!==null&&(c.childLanes&a)!==a&&(c.childLanes|=a),n===l)break;n=n.return}}function Bd(n,a,l,c){var m=n.child;for(m!==null&&(m.return=n);m!==null;){var f=m.dependencies;if(f!==null){var y=m.child;f=f.firstContext;e:for(;f!==null;){var S=f;f=m;for(var $=0;$<a.length;$++)if(S.context===a[$]){f.lanes|=l,S=f.alternate,S!==null&&(S.lanes|=l),$d(f.return,l,n),c||(y=null);break e}f=S.next}}else if(m.tag===18){if(y=m.return,y===null)throw Error(r(341));y.lanes|=l,f=y.alternate,f!==null&&(f.lanes|=l),$d(y,l,n),y=null}else y=m.child;if(y!==null)y.return=m;else for(y=m;y!==null;){if(y===n){y=null;break}if(m=y.sibling,m!==null){m.return=y.return,y=m;break}y=y.return}m=y}}function ir(n,a,l,c){n=null;for(var m=a,f=!1;m!==null;){if(!f){if((m.flags&524288)!==0)f=!0;else if((m.flags&262144)!==0)break}if(m.tag===10){var y=m.alternate;if(y===null)throw Error(r(387));if(y=y.memoizedProps,y!==null){var S=m.type;Wn(m.pendingProps.value,y.value)||(n!==null?n.push(S):n=[S])}}else if(m===Re.current){if(y=m.alternate,y===null)throw Error(r(387));y.memoizedState.memoizedState!==m.memoizedState.memoizedState&&(n!==null?n.push(Kl):n=[Kl])}m=m.return}n!==null&&Bd(a,n,l,c),a.flags|=262144}function Po(n){for(n=n.firstContext;n!==null;){if(!Wn(n.context._currentValue,n.memoizedValue))return!0;n=n.next}return!1}function vi(n){bi=n,ta=null,n=n.dependencies,n!==null&&(n.firstContext=null)}function gn(n){return og(bi,n)}function Go(n,a){return bi===null&&vi(n),og(n,a)}function og(n,a){var l=a._currentValue;if(a={context:a,memoizedValue:l,next:null},ta===null){if(n===null)throw Error(r(308));ta=a,n.dependencies={lanes:0,firstContext:a},n.flags|=524288}else ta=ta.next=a;return l}var fw=typeof AbortController<"u"?AbortController:function(){var n=[],a=this.signal={aborted:!1,addEventListener:function(l,c){n.push(c)}};this.abort=function(){a.aborted=!0,n.forEach(function(l){return l()})}},pw=e.unstable_scheduleCallback,gw=e.unstable_NormalPriority,Xt={$$typeof:I,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function qd(){return{controller:new fw,data:new Map,refCount:0}}function vl(n){n.refCount--,n.refCount===0&&pw(gw,function(){n.controller.abort()})}var jl=null,Id=0,rr=0,lr=null;function xw(n,a){if(jl===null){var l=jl=[];Id=0,rr=Gm(),lr={status:"pending",value:void 0,then:function(c){l.push(c)}}}return Id++,a.then(cg,cg),a}function cg(){if(--Id===0&&jl!==null){lr!==null&&(lr.status="fulfilled");var n=jl;jl=null,rr=0,lr=null;for(var a=0;a<n.length;a++)(0,n[a])()}}function yw(n,a){var l=[],c={status:"pending",value:null,reason:null,then:function(m){l.push(m)}};return n.then(function(){c.status="fulfilled",c.value=a;for(var m=0;m<l.length;m++)(0,l[m])(a)},function(m){for(c.status="rejected",c.reason=m,m=0;m<l.length;m++)(0,l[m])(void 0)}),c}var ug=V.S;V.S=function(n,a){Qx=$t(),typeof a=="object"&&a!==null&&typeof a.then=="function"&&xw(n,a),ug!==null&&ug(n,a)};var ji=pe(null);function Ud(){var n=ji.current;return n!==null?n:_t.pooledCache}function Vo(n,a){a===null?X(ji,ji.current):X(ji,a.pool)}function dg(){var n=Ud();return n===null?null:{parent:Xt._currentValue,pool:n}}var or=Error(r(460)),Pd=Error(r(474)),Ho=Error(r(542)),Ko={then:function(){}};function mg(n){return n=n.status,n==="fulfilled"||n==="rejected"}function hg(n,a,l){switch(l=n[l],l===void 0?n.push(a):l!==a&&(a.then(Xs,Xs),a=l),a.status){case"fulfilled":return a.value;case"rejected":throw n=a.reason,pg(n),n;default:if(typeof a.status=="string")a.then(Xs,Xs);else{if(n=_t,n!==null&&100<n.shellSuspendCounter)throw Error(r(482));n=a,n.status="pending",n.then(function(c){if(a.status==="pending"){var m=a;m.status="fulfilled",m.value=c}},function(c){if(a.status==="pending"){var m=a;m.status="rejected",m.reason=c}})}switch(a.status){case"fulfilled":return a.value;case"rejected":throw n=a.reason,pg(n),n}throw wi=a,or}}function Ni(n){try{var a=n._init;return a(n._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(wi=l,or):l}}var wi=null;function fg(){if(wi===null)throw Error(r(459));var n=wi;return wi=null,n}function pg(n){if(n===or||n===Ho)throw Error(r(483))}var cr=null,Nl=0;function Qo(n){var a=Nl;return Nl+=1,cr===null&&(cr=[]),hg(cr,n,a)}function wl(n,a){a=a.props.ref,n.ref=a!==void 0?a:null}function Zo(n,a){throw a.$$typeof===N?Error(r(525)):(n=Object.prototype.toString.call(a),Error(r(31,n==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":n)))}function gg(n){function a(H,q){if(n){var K=H.deletions;K===null?(H.deletions=[q],H.flags|=16):K.push(q)}}function l(H,q){if(!n)return null;for(;q!==null;)a(H,q),q=q.sibling;return null}function c(H){for(var q=new Map;H!==null;)H.key!==null?q.set(H.key,H):q.set(H.index,H),H=H.sibling;return q}function m(H,q){return H=Ws(H,q),H.index=0,H.sibling=null,H}function f(H,q,K){return H.index=K,n?(K=H.alternate,K!==null?(K=K.index,K<q?(H.flags|=67108866,q):K):(H.flags|=67108866,q)):(H.flags|=1048576,q)}function y(H){return n&&H.alternate===null&&(H.flags|=67108866),H}function S(H,q,K,ce){return q===null||q.tag!==6?(q=_d(K,H.mode,ce),q.return=H,q):(q=m(q,K),q.return=H,q)}function $(H,q,K,ce){var Ie=K.type;return Ie===w?re(H,q,K.props.children,ce,K.key):q!==null&&(q.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===B&&Ni(Ie)===q.type)?(q=m(q,K.props),wl(q,K),q.return=H,q):(q=Io(K.type,K.key,K.props,null,H.mode,ce),wl(q,K),q.return=H,q)}function Q(H,q,K,ce){return q===null||q.tag!==4||q.stateNode.containerInfo!==K.containerInfo||q.stateNode.implementation!==K.implementation?(q=Ed(K,H.mode,ce),q.return=H,q):(q=m(q,K.children||[]),q.return=H,q)}function re(H,q,K,ce,Ie){return q===null||q.tag!==7?(q=xi(K,H.mode,ce,Ie),q.return=H,q):(q=m(q,K),q.return=H,q)}function de(H,q,K){if(typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint")return q=_d(""+q,H.mode,K),q.return=H,q;if(typeof q=="object"&&q!==null){switch(q.$$typeof){case z:return K=Io(q.type,q.key,q.props,null,H.mode,K),wl(K,q),K.return=H,K;case T:return q=Ed(q,H.mode,K),q.return=H,q;case B:return q=Ni(q),de(H,q,K)}if(ve(q)||ie(q))return q=xi(q,H.mode,K,null),q.return=H,q;if(typeof q.then=="function")return de(H,Qo(q),K);if(q.$$typeof===I)return de(H,Go(H,q),K);Zo(H,q)}return null}function Z(H,q,K,ce){var Ie=q!==null?q.key:null;if(typeof K=="string"&&K!==""||typeof K=="number"||typeof K=="bigint")return Ie!==null?null:S(H,q,""+K,ce);if(typeof K=="object"&&K!==null){switch(K.$$typeof){case z:return K.key===Ie?$(H,q,K,ce):null;case T:return K.key===Ie?Q(H,q,K,ce):null;case B:return K=Ni(K),Z(H,q,K,ce)}if(ve(K)||ie(K))return Ie!==null?null:re(H,q,K,ce,null);if(typeof K.then=="function")return Z(H,q,Qo(K),ce);if(K.$$typeof===I)return Z(H,q,Go(H,K),ce);Zo(H,K)}return null}function W(H,q,K,ce,Ie){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return H=H.get(K)||null,S(q,H,""+ce,Ie);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case z:return H=H.get(ce.key===null?K:ce.key)||null,$(q,H,ce,Ie);case T:return H=H.get(ce.key===null?K:ce.key)||null,Q(q,H,ce,Ie);case B:return ce=Ni(ce),W(H,q,K,ce,Ie)}if(ve(ce)||ie(ce))return H=H.get(K)||null,re(q,H,ce,Ie,null);if(typeof ce.then=="function")return W(H,q,K,Qo(ce),Ie);if(ce.$$typeof===I)return W(H,q,K,Go(q,ce),Ie);Zo(q,ce)}return null}function Te(H,q,K,ce){for(var Ie=null,yt=null,Oe=q,Je=q=0,ct=null;Oe!==null&&Je<K.length;Je++){Oe.index>Je?(ct=Oe,Oe=null):ct=Oe.sibling;var bt=Z(H,Oe,K[Je],ce);if(bt===null){Oe===null&&(Oe=ct);break}n&&Oe&&bt.alternate===null&&a(H,Oe),q=f(bt,q,Je),yt===null?Ie=bt:yt.sibling=bt,yt=bt,Oe=ct}if(Je===K.length)return l(H,Oe),dt&&ea(H,Je),Ie;if(Oe===null){for(;Je<K.length;Je++)Oe=de(H,K[Je],ce),Oe!==null&&(q=f(Oe,q,Je),yt===null?Ie=Oe:yt.sibling=Oe,yt=Oe);return dt&&ea(H,Je),Ie}for(Oe=c(Oe);Je<K.length;Je++)ct=W(Oe,H,Je,K[Je],ce),ct!==null&&(n&&ct.alternate!==null&&Oe.delete(ct.key===null?Je:ct.key),q=f(ct,q,Je),yt===null?Ie=ct:yt.sibling=ct,yt=ct);return n&&Oe.forEach(function(Qa){return a(H,Qa)}),dt&&ea(H,Je),Ie}function Ve(H,q,K,ce){if(K==null)throw Error(r(151));for(var Ie=null,yt=null,Oe=q,Je=q=0,ct=null,bt=K.next();Oe!==null&&!bt.done;Je++,bt=K.next()){Oe.index>Je?(ct=Oe,Oe=null):ct=Oe.sibling;var Qa=Z(H,Oe,bt.value,ce);if(Qa===null){Oe===null&&(Oe=ct);break}n&&Oe&&Qa.alternate===null&&a(H,Oe),q=f(Qa,q,Je),yt===null?Ie=Qa:yt.sibling=Qa,yt=Qa,Oe=ct}if(bt.done)return l(H,Oe),dt&&ea(H,Je),Ie;if(Oe===null){for(;!bt.done;Je++,bt=K.next())bt=de(H,bt.value,ce),bt!==null&&(q=f(bt,q,Je),yt===null?Ie=bt:yt.sibling=bt,yt=bt);return dt&&ea(H,Je),Ie}for(Oe=c(Oe);!bt.done;Je++,bt=K.next())bt=W(Oe,H,Je,bt.value,ce),bt!==null&&(n&&bt.alternate!==null&&Oe.delete(bt.key===null?Je:bt.key),q=f(bt,q,Je),yt===null?Ie=bt:yt.sibling=bt,yt=bt);return n&&Oe.forEach(function(TS){return a(H,TS)}),dt&&ea(H,Je),Ie}function Tt(H,q,K,ce){if(typeof K=="object"&&K!==null&&K.type===w&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case z:e:{for(var Ie=K.key;q!==null;){if(q.key===Ie){if(Ie=K.type,Ie===w){if(q.tag===7){l(H,q.sibling),ce=m(q,K.props.children),ce.return=H,H=ce;break e}}else if(q.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===B&&Ni(Ie)===q.type){l(H,q.sibling),ce=m(q,K.props),wl(ce,K),ce.return=H,H=ce;break e}l(H,q);break}else a(H,q);q=q.sibling}K.type===w?(ce=xi(K.props.children,H.mode,ce,K.key),ce.return=H,H=ce):(ce=Io(K.type,K.key,K.props,null,H.mode,ce),wl(ce,K),ce.return=H,H=ce)}return y(H);case T:e:{for(Ie=K.key;q!==null;){if(q.key===Ie)if(q.tag===4&&q.stateNode.containerInfo===K.containerInfo&&q.stateNode.implementation===K.implementation){l(H,q.sibling),ce=m(q,K.children||[]),ce.return=H,H=ce;break e}else{l(H,q);break}else a(H,q);q=q.sibling}ce=Ed(K,H.mode,ce),ce.return=H,H=ce}return y(H);case B:return K=Ni(K),Tt(H,q,K,ce)}if(ve(K))return Te(H,q,K,ce);if(ie(K)){if(Ie=ie(K),typeof Ie!="function")throw Error(r(150));return K=Ie.call(K),Ve(H,q,K,ce)}if(typeof K.then=="function")return Tt(H,q,Qo(K),ce);if(K.$$typeof===I)return Tt(H,q,Go(H,K),ce);Zo(H,K)}return typeof K=="string"&&K!==""||typeof K=="number"||typeof K=="bigint"?(K=""+K,q!==null&&q.tag===6?(l(H,q.sibling),ce=m(q,K),ce.return=H,H=ce):(l(H,q),ce=_d(K,H.mode,ce),ce.return=H,H=ce),y(H)):l(H,q)}return function(H,q,K,ce){try{Nl=0;var Ie=Tt(H,q,K,ce);return cr=null,Ie}catch(Oe){if(Oe===or||Oe===Ho)throw Oe;var yt=es(29,Oe,null,H.mode);return yt.lanes=ce,yt.return=H,yt}}}var Si=gg(!0),xg=gg(!1),_a=!1;function Gd(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Vd(n,a){n=n.updateQueue,a.updateQueue===n&&(a.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function Ea(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function Da(n,a,l){var c=n.updateQueue;if(c===null)return null;if(c=c.shared,(jt&2)!==0){var m=c.pending;return m===null?a.next=a:(a.next=m.next,m.next=a),c.pending=a,a=qo(n),eg(n,null,l),a}return Bo(n,c,a,l),qo(n)}function Sl(n,a,l){if(a=a.updateQueue,a!==null&&(a=a.shared,(l&4194048)!==0)){var c=a.lanes;c&=n.pendingLanes,l|=c,a.lanes=l,As(n,l)}}function Hd(n,a){var l=n.updateQueue,c=n.alternate;if(c!==null&&(c=c.updateQueue,l===c)){var m=null,f=null;if(l=l.firstBaseUpdate,l!==null){do{var y={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};f===null?m=f=y:f=f.next=y,l=l.next}while(l!==null);f===null?m=f=a:f=f.next=a}else m=f=a;l={baseState:c.baseState,firstBaseUpdate:m,lastBaseUpdate:f,shared:c.shared,callbacks:c.callbacks},n.updateQueue=l;return}n=l.lastBaseUpdate,n===null?l.firstBaseUpdate=a:n.next=a,l.lastBaseUpdate=a}var Kd=!1;function zl(){if(Kd){var n=lr;if(n!==null)throw n}}function kl(n,a,l,c){Kd=!1;var m=n.updateQueue;_a=!1;var f=m.firstBaseUpdate,y=m.lastBaseUpdate,S=m.shared.pending;if(S!==null){m.shared.pending=null;var $=S,Q=$.next;$.next=null,y===null?f=Q:y.next=Q,y=$;var re=n.alternate;re!==null&&(re=re.updateQueue,S=re.lastBaseUpdate,S!==y&&(S===null?re.firstBaseUpdate=Q:S.next=Q,re.lastBaseUpdate=$))}if(f!==null){var de=m.baseState;y=0,re=Q=$=null,S=f;do{var Z=S.lane&-536870913,W=Z!==S.lane;if(W?(ot&Z)===Z:(c&Z)===Z){Z!==0&&Z===rr&&(Kd=!0),re!==null&&(re=re.next={lane:0,tag:S.tag,payload:S.payload,callback:null,next:null});e:{var Te=n,Ve=S;Z=a;var Tt=l;switch(Ve.tag){case 1:if(Te=Ve.payload,typeof Te=="function"){de=Te.call(Tt,de,Z);break e}de=Te;break e;case 3:Te.flags=Te.flags&-65537|128;case 0:if(Te=Ve.payload,Z=typeof Te=="function"?Te.call(Tt,de,Z):Te,Z==null)break e;de=v({},de,Z);break e;case 2:_a=!0}}Z=S.callback,Z!==null&&(n.flags|=64,W&&(n.flags|=8192),W=m.callbacks,W===null?m.callbacks=[Z]:W.push(Z))}else W={lane:Z,tag:S.tag,payload:S.payload,callback:S.callback,next:null},re===null?(Q=re=W,$=de):re=re.next=W,y|=Z;if(S=S.next,S===null){if(S=m.shared.pending,S===null)break;W=S,S=W.next,W.next=null,m.lastBaseUpdate=W,m.shared.pending=null}}while(!0);re===null&&($=de),m.baseState=$,m.firstBaseUpdate=Q,m.lastBaseUpdate=re,f===null&&(m.shared.lanes=0),$a|=y,n.lanes=y,n.memoizedState=de}}function yg(n,a){if(typeof n!="function")throw Error(r(191,n));n.call(a)}function bg(n,a){var l=n.callbacks;if(l!==null)for(n.callbacks=null,n=0;n<l.length;n++)yg(l[n],a)}var ur=pe(null),Fo=pe(0);function vg(n,a){n=da,X(Fo,n),X(ur,a),da=n|a.baseLanes}function Qd(){X(Fo,da),X(ur,ur.current)}function Zd(){da=Fo.current,E(ur),E(Fo)}var ts=pe(null),fs=null;function Oa(n){var a=n.alternate;X(Gt,Gt.current&1),X(ts,n),fs===null&&(a===null||ur.current!==null||a.memoizedState!==null)&&(fs=n)}function Fd(n){X(Gt,Gt.current),X(ts,n),fs===null&&(fs=n)}function jg(n){n.tag===22?(X(Gt,Gt.current),X(ts,n),fs===null&&(fs=n)):Ra()}function Ra(){X(Gt,Gt.current),X(ts,ts.current)}function ns(n){E(ts),fs===n&&(fs=null),E(Gt)}var Gt=pe(0);function Yo(n){for(var a=n;a!==null;){if(a.tag===13){var l=a.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||th(l)||nh(l)))return a}else if(a.tag===19&&(a.memoizedProps.revealOrder==="forwards"||a.memoizedProps.revealOrder==="backwards"||a.memoizedProps.revealOrder==="unstable_legacy-backwards"||a.memoizedProps.revealOrder==="together")){if((a.flags&128)!==0)return a}else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===n)break;for(;a.sibling===null;){if(a.return===null||a.return===n)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var sa=0,Ye=null,Ct=null,Jt=null,Xo=!1,dr=!1,zi=!1,Jo=0,Cl=0,mr=null,bw=0;function Ut(){throw Error(r(321))}function Yd(n,a){if(a===null)return!1;for(var l=0;l<a.length&&l<n.length;l++)if(!Wn(n[l],a[l]))return!1;return!0}function Xd(n,a,l,c,m,f){return sa=f,Ye=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,V.H=n===null||n.memoizedState===null?ax:mm,zi=!1,f=l(c,m),zi=!1,dr&&(f=wg(a,l,c,m)),Ng(n),f}function Ng(n){V.H=_l;var a=Ct!==null&&Ct.next!==null;if(sa=0,Jt=Ct=Ye=null,Xo=!1,Cl=0,mr=null,a)throw Error(r(300));n===null||Wt||(n=n.dependencies,n!==null&&Po(n)&&(Wt=!0))}function wg(n,a,l,c){Ye=n;var m=0;do{if(dr&&(mr=null),Cl=0,dr=!1,25<=m)throw Error(r(301));if(m+=1,Jt=Ct=null,n.updateQueue!=null){var f=n.updateQueue;f.lastEffect=null,f.events=null,f.stores=null,f.memoCache!=null&&(f.memoCache.index=0)}V.H=ix,f=a(l,c)}while(dr);return f}function vw(){var n=V.H,a=n.useState()[0];return a=typeof a.then=="function"?Al(a):a,n=n.useState()[0],(Ct!==null?Ct.memoizedState:null)!==n&&(Ye.flags|=1024),a}function Jd(){var n=Jo!==0;return Jo=0,n}function Wd(n,a,l){a.updateQueue=n.updateQueue,a.flags&=-2053,n.lanes&=~l}function em(n){if(Xo){for(n=n.memoizedState;n!==null;){var a=n.queue;a!==null&&(a.pending=null),n=n.next}Xo=!1}sa=0,Jt=Ct=Ye=null,dr=!1,Cl=Jo=0,mr=null}function On(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Jt===null?Ye.memoizedState=Jt=n:Jt=Jt.next=n,Jt}function Vt(){if(Ct===null){var n=Ye.alternate;n=n!==null?n.memoizedState:null}else n=Ct.next;var a=Jt===null?Ye.memoizedState:Jt.next;if(a!==null)Jt=a,Ct=n;else{if(n===null)throw Ye.alternate===null?Error(r(467)):Error(r(310));Ct=n,n={memoizedState:Ct.memoizedState,baseState:Ct.baseState,baseQueue:Ct.baseQueue,queue:Ct.queue,next:null},Jt===null?Ye.memoizedState=Jt=n:Jt=Jt.next=n}return Jt}function Wo(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Al(n){var a=Cl;return Cl+=1,mr===null&&(mr=[]),n=hg(mr,n,a),a=Ye,(Jt===null?a.memoizedState:Jt.next)===null&&(a=a.alternate,V.H=a===null||a.memoizedState===null?ax:mm),n}function ec(n){if(n!==null&&typeof n=="object"){if(typeof n.then=="function")return Al(n);if(n.$$typeof===I)return gn(n)}throw Error(r(438,String(n)))}function tm(n){var a=null,l=Ye.updateQueue;if(l!==null&&(a=l.memoCache),a==null){var c=Ye.alternate;c!==null&&(c=c.updateQueue,c!==null&&(c=c.memoCache,c!=null&&(a={data:c.data.map(function(m){return m.slice()}),index:0})))}if(a==null&&(a={data:[],index:0}),l===null&&(l=Wo(),Ye.updateQueue=l),l.memoCache=a,l=a.data[a.index],l===void 0)for(l=a.data[a.index]=Array(n),c=0;c<n;c++)l[c]=ue;return a.index++,l}function aa(n,a){return typeof a=="function"?a(n):a}function tc(n){var a=Vt();return nm(a,Ct,n)}function nm(n,a,l){var c=n.queue;if(c===null)throw Error(r(311));c.lastRenderedReducer=l;var m=n.baseQueue,f=c.pending;if(f!==null){if(m!==null){var y=m.next;m.next=f.next,f.next=y}a.baseQueue=m=f,c.pending=null}if(f=n.baseState,m===null)n.memoizedState=f;else{a=m.next;var S=y=null,$=null,Q=a,re=!1;do{var de=Q.lane&-536870913;if(de!==Q.lane?(ot&de)===de:(sa&de)===de){var Z=Q.revertLane;if(Z===0)$!==null&&($=$.next={lane:0,revertLane:0,gesture:null,action:Q.action,hasEagerState:Q.hasEagerState,eagerState:Q.eagerState,next:null}),de===rr&&(re=!0);else if((sa&Z)===Z){Q=Q.next,Z===rr&&(re=!0);continue}else de={lane:0,revertLane:Q.revertLane,gesture:null,action:Q.action,hasEagerState:Q.hasEagerState,eagerState:Q.eagerState,next:null},$===null?(S=$=de,y=f):$=$.next=de,Ye.lanes|=Z,$a|=Z;de=Q.action,zi&&l(f,de),f=Q.hasEagerState?Q.eagerState:l(f,de)}else Z={lane:de,revertLane:Q.revertLane,gesture:Q.gesture,action:Q.action,hasEagerState:Q.hasEagerState,eagerState:Q.eagerState,next:null},$===null?(S=$=Z,y=f):$=$.next=Z,Ye.lanes|=de,$a|=de;Q=Q.next}while(Q!==null&&Q!==a);if($===null?y=f:$.next=S,!Wn(f,n.memoizedState)&&(Wt=!0,re&&(l=lr,l!==null)))throw l;n.memoizedState=f,n.baseState=y,n.baseQueue=$,c.lastRenderedState=f}return m===null&&(c.lanes=0),[n.memoizedState,c.dispatch]}function sm(n){var a=Vt(),l=a.queue;if(l===null)throw Error(r(311));l.lastRenderedReducer=n;var c=l.dispatch,m=l.pending,f=a.memoizedState;if(m!==null){l.pending=null;var y=m=m.next;do f=n(f,y.action),y=y.next;while(y!==m);Wn(f,a.memoizedState)||(Wt=!0),a.memoizedState=f,a.baseQueue===null&&(a.baseState=f),l.lastRenderedState=f}return[f,c]}function Sg(n,a,l){var c=Ye,m=Vt(),f=dt;if(f){if(l===void 0)throw Error(r(407));l=l()}else l=a();var y=!Wn((Ct||m).memoizedState,l);if(y&&(m.memoizedState=l,Wt=!0),m=m.queue,rm(Cg.bind(null,c,m,n),[n]),m.getSnapshot!==a||y||Jt!==null&&Jt.memoizedState.tag&1){if(c.flags|=2048,hr(9,{destroy:void 0},kg.bind(null,c,m,l,a),null),_t===null)throw Error(r(349));f||(sa&127)!==0||zg(c,a,l)}return l}function zg(n,a,l){n.flags|=16384,n={getSnapshot:a,value:l},a=Ye.updateQueue,a===null?(a=Wo(),Ye.updateQueue=a,a.stores=[n]):(l=a.stores,l===null?a.stores=[n]:l.push(n))}function kg(n,a,l,c){a.value=l,a.getSnapshot=c,Ag(a)&&Tg(n)}function Cg(n,a,l){return l(function(){Ag(a)&&Tg(n)})}function Ag(n){var a=n.getSnapshot;n=n.value;try{var l=a();return!Wn(n,l)}catch{return!0}}function Tg(n){var a=gi(n,2);a!==null&&Hn(a,n,2)}function am(n){var a=On();if(typeof n=="function"){var l=n;if(n=l(),zi){He(!0);try{l()}finally{He(!1)}}}return a.memoizedState=a.baseState=n,a.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:aa,lastRenderedState:n},a}function _g(n,a,l,c){return n.baseState=l,nm(n,Ct,typeof c=="function"?c:aa)}function jw(n,a,l,c,m){if(ac(n))throw Error(r(485));if(n=a.action,n!==null){var f={payload:m,action:n,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(y){f.listeners.push(y)}};V.T!==null?l(!0):f.isTransition=!1,c(f),l=a.pending,l===null?(f.next=a.pending=f,Eg(a,f)):(f.next=l.next,a.pending=l.next=f)}}function Eg(n,a){var l=a.action,c=a.payload,m=n.state;if(a.isTransition){var f=V.T,y={};V.T=y;try{var S=l(m,c),$=V.S;$!==null&&$(y,S),Dg(n,a,S)}catch(Q){im(n,a,Q)}finally{f!==null&&y.types!==null&&(f.types=y.types),V.T=f}}else try{f=l(m,c),Dg(n,a,f)}catch(Q){im(n,a,Q)}}function Dg(n,a,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(c){Og(n,a,c)},function(c){return im(n,a,c)}):Og(n,a,l)}function Og(n,a,l){a.status="fulfilled",a.value=l,Rg(a),n.state=l,a=n.pending,a!==null&&(l=a.next,l===a?n.pending=null:(l=l.next,a.next=l,Eg(n,l)))}function im(n,a,l){var c=n.pending;if(n.pending=null,c!==null){c=c.next;do a.status="rejected",a.reason=l,Rg(a),a=a.next;while(a!==c)}n.action=null}function Rg(n){n=n.listeners;for(var a=0;a<n.length;a++)(0,n[a])()}function Lg(n,a){return a}function Mg(n,a){if(dt){var l=_t.formState;if(l!==null){e:{var c=Ye;if(dt){if(Ot){t:{for(var m=Ot,f=hs;m.nodeType!==8;){if(!f){m=null;break t}if(m=ps(m.nextSibling),m===null){m=null;break t}}f=m.data,m=f==="F!"||f==="F"?m:null}if(m){Ot=ps(m.nextSibling),c=m.data==="F!";break e}}Aa(c)}c=!1}c&&(a=l[0])}}return l=On(),l.memoizedState=l.baseState=a,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lg,lastRenderedState:a},l.queue=c,l=tx.bind(null,Ye,c),c.dispatch=l,c=am(!1),f=dm.bind(null,Ye,!1,c.queue),c=On(),m={state:a,dispatch:null,action:n,pending:null},c.queue=m,l=jw.bind(null,Ye,m,f,l),m.dispatch=l,c.memoizedState=n,[a,l,!1]}function $g(n){var a=Vt();return Bg(a,Ct,n)}function Bg(n,a,l){if(a=nm(n,a,Lg)[0],n=tc(aa)[0],typeof a=="object"&&a!==null&&typeof a.then=="function")try{var c=Al(a)}catch(y){throw y===or?Ho:y}else c=a;a=Vt();var m=a.queue,f=m.dispatch;return l!==a.memoizedState&&(Ye.flags|=2048,hr(9,{destroy:void 0},Nw.bind(null,m,l),null)),[c,f,n]}function Nw(n,a){n.action=a}function qg(n){var a=Vt(),l=Ct;if(l!==null)return Bg(a,l,n);Vt(),a=a.memoizedState,l=Vt();var c=l.queue.dispatch;return l.memoizedState=n,[a,c,!1]}function hr(n,a,l,c){return n={tag:n,create:l,deps:c,inst:a,next:null},a=Ye.updateQueue,a===null&&(a=Wo(),Ye.updateQueue=a),l=a.lastEffect,l===null?a.lastEffect=n.next=n:(c=l.next,l.next=n,n.next=c,a.lastEffect=n),n}function Ig(){return Vt().memoizedState}function nc(n,a,l,c){var m=On();Ye.flags|=n,m.memoizedState=hr(1|a,{destroy:void 0},l,c===void 0?null:c)}function sc(n,a,l,c){var m=Vt();c=c===void 0?null:c;var f=m.memoizedState.inst;Ct!==null&&c!==null&&Yd(c,Ct.memoizedState.deps)?m.memoizedState=hr(a,f,l,c):(Ye.flags|=n,m.memoizedState=hr(1|a,f,l,c))}function Ug(n,a){nc(8390656,8,n,a)}function rm(n,a){sc(2048,8,n,a)}function ww(n){Ye.flags|=4;var a=Ye.updateQueue;if(a===null)a=Wo(),Ye.updateQueue=a,a.events=[n];else{var l=a.events;l===null?a.events=[n]:l.push(n)}}function Pg(n){var a=Vt().memoizedState;return ww({ref:a,nextImpl:n}),function(){if((jt&2)!==0)throw Error(r(440));return a.impl.apply(void 0,arguments)}}function Gg(n,a){return sc(4,2,n,a)}function Vg(n,a){return sc(4,4,n,a)}function Hg(n,a){if(typeof a=="function"){n=n();var l=a(n);return function(){typeof l=="function"?l():a(null)}}if(a!=null)return n=n(),a.current=n,function(){a.current=null}}function Kg(n,a,l){l=l!=null?l.concat([n]):null,sc(4,4,Hg.bind(null,a,n),l)}function lm(){}function Qg(n,a){var l=Vt();a=a===void 0?null:a;var c=l.memoizedState;return a!==null&&Yd(a,c[1])?c[0]:(l.memoizedState=[n,a],n)}function Zg(n,a){var l=Vt();a=a===void 0?null:a;var c=l.memoizedState;if(a!==null&&Yd(a,c[1]))return c[0];if(c=n(),zi){He(!0);try{n()}finally{He(!1)}}return l.memoizedState=[c,a],c}function om(n,a,l){return l===void 0||(sa&1073741824)!==0&&(ot&261930)===0?n.memoizedState=a:(n.memoizedState=l,n=Fx(),Ye.lanes|=n,$a|=n,l)}function Fg(n,a,l,c){return Wn(l,a)?l:ur.current!==null?(n=om(n,l,c),Wn(n,a)||(Wt=!0),n):(sa&42)===0||(sa&1073741824)!==0&&(ot&261930)===0?(Wt=!0,n.memoizedState=l):(n=Fx(),Ye.lanes|=n,$a|=n,a)}function Yg(n,a,l,c,m){var f=ne.p;ne.p=f!==0&&8>f?f:8;var y=V.T,S={};V.T=S,dm(n,!1,a,l);try{var $=m(),Q=V.S;if(Q!==null&&Q(S,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var re=yw($,c);Tl(n,a,re,is(n))}else Tl(n,a,c,is(n))}catch(de){Tl(n,a,{then:function(){},status:"rejected",reason:de},is())}finally{ne.p=f,y!==null&&S.types!==null&&(y.types=S.types),V.T=y}}function Sw(){}function cm(n,a,l,c){if(n.tag!==5)throw Error(r(476));var m=Xg(n).queue;Yg(n,m,a,me,l===null?Sw:function(){return Jg(n),l(c)})}function Xg(n){var a=n.memoizedState;if(a!==null)return a;a={memoizedState:me,baseState:me,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:aa,lastRenderedState:me},next:null};var l={};return a.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:aa,lastRenderedState:l},next:null},n.memoizedState=a,n=n.alternate,n!==null&&(n.memoizedState=a),a}function Jg(n){var a=Xg(n);a.next===null&&(a=n.alternate.memoizedState),Tl(n,a.next.queue,{},is())}function um(){return gn(Kl)}function Wg(){return Vt().memoizedState}function ex(){return Vt().memoizedState}function zw(n){for(var a=n.return;a!==null;){switch(a.tag){case 24:case 3:var l=is();n=Ea(l);var c=Da(a,n,l);c!==null&&(Hn(c,a,l),Sl(c,a,l)),a={cache:qd()},n.payload=a;return}a=a.return}}function kw(n,a,l){var c=is();l={lane:c,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},ac(n)?nx(a,l):(l=Ad(n,a,l,c),l!==null&&(Hn(l,n,c),sx(l,a,c)))}function tx(n,a,l){var c=is();Tl(n,a,l,c)}function Tl(n,a,l,c){var m={lane:c,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(ac(n))nx(a,m);else{var f=n.alternate;if(n.lanes===0&&(f===null||f.lanes===0)&&(f=a.lastRenderedReducer,f!==null))try{var y=a.lastRenderedState,S=f(y,l);if(m.hasEagerState=!0,m.eagerState=S,Wn(S,y))return Bo(n,a,m,0),_t===null&&$o(),!1}catch{}if(l=Ad(n,a,m,c),l!==null)return Hn(l,n,c),sx(l,a,c),!0}return!1}function dm(n,a,l,c){if(c={lane:2,revertLane:Gm(),gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},ac(n)){if(a)throw Error(r(479))}else a=Ad(n,l,c,2),a!==null&&Hn(a,n,2)}function ac(n){var a=n.alternate;return n===Ye||a!==null&&a===Ye}function nx(n,a){dr=Xo=!0;var l=n.pending;l===null?a.next=a:(a.next=l.next,l.next=a),n.pending=a}function sx(n,a,l){if((l&4194048)!==0){var c=a.lanes;c&=n.pendingLanes,l|=c,a.lanes=l,As(n,l)}}var _l={readContext:gn,use:ec,useCallback:Ut,useContext:Ut,useEffect:Ut,useImperativeHandle:Ut,useLayoutEffect:Ut,useInsertionEffect:Ut,useMemo:Ut,useReducer:Ut,useRef:Ut,useState:Ut,useDebugValue:Ut,useDeferredValue:Ut,useTransition:Ut,useSyncExternalStore:Ut,useId:Ut,useHostTransitionStatus:Ut,useFormState:Ut,useActionState:Ut,useOptimistic:Ut,useMemoCache:Ut,useCacheRefresh:Ut};_l.useEffectEvent=Ut;var ax={readContext:gn,use:ec,useCallback:function(n,a){return On().memoizedState=[n,a===void 0?null:a],n},useContext:gn,useEffect:Ug,useImperativeHandle:function(n,a,l){l=l!=null?l.concat([n]):null,nc(4194308,4,Hg.bind(null,a,n),l)},useLayoutEffect:function(n,a){return nc(4194308,4,n,a)},useInsertionEffect:function(n,a){nc(4,2,n,a)},useMemo:function(n,a){var l=On();a=a===void 0?null:a;var c=n();if(zi){He(!0);try{n()}finally{He(!1)}}return l.memoizedState=[c,a],c},useReducer:function(n,a,l){var c=On();if(l!==void 0){var m=l(a);if(zi){He(!0);try{l(a)}finally{He(!1)}}}else m=a;return c.memoizedState=c.baseState=m,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:m},c.queue=n,n=n.dispatch=kw.bind(null,Ye,n),[c.memoizedState,n]},useRef:function(n){var a=On();return n={current:n},a.memoizedState=n},useState:function(n){n=am(n);var a=n.queue,l=tx.bind(null,Ye,a);return a.dispatch=l,[n.memoizedState,l]},useDebugValue:lm,useDeferredValue:function(n,a){var l=On();return om(l,n,a)},useTransition:function(){var n=am(!1);return n=Yg.bind(null,Ye,n.queue,!0,!1),On().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,a,l){var c=Ye,m=On();if(dt){if(l===void 0)throw Error(r(407));l=l()}else{if(l=a(),_t===null)throw Error(r(349));(ot&127)!==0||zg(c,a,l)}m.memoizedState=l;var f={value:l,getSnapshot:a};return m.queue=f,Ug(Cg.bind(null,c,f,n),[n]),c.flags|=2048,hr(9,{destroy:void 0},kg.bind(null,c,f,l,a),null),l},useId:function(){var n=On(),a=_t.identifierPrefix;if(dt){var l=Is,c=qs;l=(c&~(1<<32-ut(c)-1)).toString(32)+l,a="_"+a+"R_"+l,l=Jo++,0<l&&(a+="H"+l.toString(32)),a+="_"}else l=bw++,a="_"+a+"r_"+l.toString(32)+"_";return n.memoizedState=a},useHostTransitionStatus:um,useFormState:Mg,useActionState:Mg,useOptimistic:function(n){var a=On();a.memoizedState=a.baseState=n;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return a.queue=l,a=dm.bind(null,Ye,!0,l),l.dispatch=a,[n,a]},useMemoCache:tm,useCacheRefresh:function(){return On().memoizedState=zw.bind(null,Ye)},useEffectEvent:function(n){var a=On(),l={impl:n};return a.memoizedState=l,function(){if((jt&2)!==0)throw Error(r(440));return l.impl.apply(void 0,arguments)}}},mm={readContext:gn,use:ec,useCallback:Qg,useContext:gn,useEffect:rm,useImperativeHandle:Kg,useInsertionEffect:Gg,useLayoutEffect:Vg,useMemo:Zg,useReducer:tc,useRef:Ig,useState:function(){return tc(aa)},useDebugValue:lm,useDeferredValue:function(n,a){var l=Vt();return Fg(l,Ct.memoizedState,n,a)},useTransition:function(){var n=tc(aa)[0],a=Vt().memoizedState;return[typeof n=="boolean"?n:Al(n),a]},useSyncExternalStore:Sg,useId:Wg,useHostTransitionStatus:um,useFormState:$g,useActionState:$g,useOptimistic:function(n,a){var l=Vt();return _g(l,Ct,n,a)},useMemoCache:tm,useCacheRefresh:ex};mm.useEffectEvent=Pg;var ix={readContext:gn,use:ec,useCallback:Qg,useContext:gn,useEffect:rm,useImperativeHandle:Kg,useInsertionEffect:Gg,useLayoutEffect:Vg,useMemo:Zg,useReducer:sm,useRef:Ig,useState:function(){return sm(aa)},useDebugValue:lm,useDeferredValue:function(n,a){var l=Vt();return Ct===null?om(l,n,a):Fg(l,Ct.memoizedState,n,a)},useTransition:function(){var n=sm(aa)[0],a=Vt().memoizedState;return[typeof n=="boolean"?n:Al(n),a]},useSyncExternalStore:Sg,useId:Wg,useHostTransitionStatus:um,useFormState:qg,useActionState:qg,useOptimistic:function(n,a){var l=Vt();return Ct!==null?_g(l,Ct,n,a):(l.baseState=n,[n,l.queue.dispatch])},useMemoCache:tm,useCacheRefresh:ex};ix.useEffectEvent=Pg;function hm(n,a,l,c){a=n.memoizedState,l=l(c,a),l=l==null?a:v({},a,l),n.memoizedState=l,n.lanes===0&&(n.updateQueue.baseState=l)}var fm={enqueueSetState:function(n,a,l){n=n._reactInternals;var c=is(),m=Ea(c);m.payload=a,l!=null&&(m.callback=l),a=Da(n,m,c),a!==null&&(Hn(a,n,c),Sl(a,n,c))},enqueueReplaceState:function(n,a,l){n=n._reactInternals;var c=is(),m=Ea(c);m.tag=1,m.payload=a,l!=null&&(m.callback=l),a=Da(n,m,c),a!==null&&(Hn(a,n,c),Sl(a,n,c))},enqueueForceUpdate:function(n,a){n=n._reactInternals;var l=is(),c=Ea(l);c.tag=2,a!=null&&(c.callback=a),a=Da(n,c,l),a!==null&&(Hn(a,n,l),Sl(a,n,l))}};function rx(n,a,l,c,m,f,y){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(c,f,y):a.prototype&&a.prototype.isPureReactComponent?!gl(l,c)||!gl(m,f):!0}function lx(n,a,l,c){n=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(l,c),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(l,c),a.state!==n&&fm.enqueueReplaceState(a,a.state,null)}function ki(n,a){var l=a;if("ref"in a){l={};for(var c in a)c!=="ref"&&(l[c]=a[c])}if(n=n.defaultProps){l===a&&(l=v({},l));for(var m in n)l[m]===void 0&&(l[m]=n[m])}return l}function ox(n){Mo(n)}function cx(n){console.error(n)}function ux(n){Mo(n)}function ic(n,a){try{var l=n.onUncaughtError;l(a.value,{componentStack:a.stack})}catch(c){setTimeout(function(){throw c})}}function dx(n,a,l){try{var c=n.onCaughtError;c(l.value,{componentStack:l.stack,errorBoundary:a.tag===1?a.stateNode:null})}catch(m){setTimeout(function(){throw m})}}function pm(n,a,l){return l=Ea(l),l.tag=3,l.payload={element:null},l.callback=function(){ic(n,a)},l}function mx(n){return n=Ea(n),n.tag=3,n}function hx(n,a,l,c){var m=l.type.getDerivedStateFromError;if(typeof m=="function"){var f=c.value;n.payload=function(){return m(f)},n.callback=function(){dx(a,l,c)}}var y=l.stateNode;y!==null&&typeof y.componentDidCatch=="function"&&(n.callback=function(){dx(a,l,c),typeof m!="function"&&(Ba===null?Ba=new Set([this]):Ba.add(this));var S=c.stack;this.componentDidCatch(c.value,{componentStack:S!==null?S:""})})}function Cw(n,a,l,c,m){if(l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){if(a=l.alternate,a!==null&&ir(a,l,m,!0),l=ts.current,l!==null){switch(l.tag){case 31:case 13:return fs===null?xc():l.alternate===null&&Pt===0&&(Pt=3),l.flags&=-257,l.flags|=65536,l.lanes=m,c===Ko?l.flags|=16384:(a=l.updateQueue,a===null?l.updateQueue=new Set([c]):a.add(c),Im(n,c,m)),!1;case 22:return l.flags|=65536,c===Ko?l.flags|=16384:(a=l.updateQueue,a===null?(a={transitions:null,markerInstances:null,retryQueue:new Set([c])},l.updateQueue=a):(l=a.retryQueue,l===null?a.retryQueue=new Set([c]):l.add(c)),Im(n,c,m)),!1}throw Error(r(435,l.tag))}return Im(n,c,m),xc(),!1}if(dt)return a=ts.current,a!==null?((a.flags&65536)===0&&(a.flags|=256),a.flags|=65536,a.lanes=m,c!==Rd&&(n=Error(r(422),{cause:c}),bl(us(n,l)))):(c!==Rd&&(a=Error(r(423),{cause:c}),bl(us(a,l))),n=n.current.alternate,n.flags|=65536,m&=-m,n.lanes|=m,c=us(c,l),m=pm(n.stateNode,c,m),Hd(n,m),Pt!==4&&(Pt=2)),!1;var f=Error(r(520),{cause:c});if(f=us(f,l),Bl===null?Bl=[f]:Bl.push(f),Pt!==4&&(Pt=2),a===null)return!0;c=us(c,l),l=a;do{switch(l.tag){case 3:return l.flags|=65536,n=m&-m,l.lanes|=n,n=pm(l.stateNode,c,n),Hd(l,n),!1;case 1:if(a=l.type,f=l.stateNode,(l.flags&128)===0&&(typeof a.getDerivedStateFromError=="function"||f!==null&&typeof f.componentDidCatch=="function"&&(Ba===null||!Ba.has(f))))return l.flags|=65536,m&=-m,l.lanes|=m,m=mx(m),hx(m,n,l,c),Hd(l,m),!1}l=l.return}while(l!==null);return!1}var gm=Error(r(461)),Wt=!1;function xn(n,a,l,c){a.child=n===null?xg(a,null,l,c):Si(a,n.child,l,c)}function fx(n,a,l,c,m){l=l.render;var f=a.ref;if("ref"in c){var y={};for(var S in c)S!=="ref"&&(y[S]=c[S])}else y=c;return vi(a),c=Xd(n,a,l,y,f,m),S=Jd(),n!==null&&!Wt?(Wd(n,a,m),ia(n,a,m)):(dt&&S&&Dd(a),a.flags|=1,xn(n,a,c,m),a.child)}function px(n,a,l,c,m){if(n===null){var f=l.type;return typeof f=="function"&&!Td(f)&&f.defaultProps===void 0&&l.compare===null?(a.tag=15,a.type=f,gx(n,a,f,c,m)):(n=Io(l.type,null,c,a,a.mode,m),n.ref=a.ref,n.return=a,a.child=n)}if(f=n.child,!Sm(n,m)){var y=f.memoizedProps;if(l=l.compare,l=l!==null?l:gl,l(y,c)&&n.ref===a.ref)return ia(n,a,m)}return a.flags|=1,n=Ws(f,c),n.ref=a.ref,n.return=a,a.child=n}function gx(n,a,l,c,m){if(n!==null){var f=n.memoizedProps;if(gl(f,c)&&n.ref===a.ref)if(Wt=!1,a.pendingProps=c=f,Sm(n,m))(n.flags&131072)!==0&&(Wt=!0);else return a.lanes=n.lanes,ia(n,a,m)}return xm(n,a,l,c,m)}function xx(n,a,l,c){var m=c.children,f=n!==null?n.memoizedState:null;if(n===null&&a.stateNode===null&&(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),c.mode==="hidden"){if((a.flags&128)!==0){if(f=f!==null?f.baseLanes|l:l,n!==null){for(c=a.child=n.child,m=0;c!==null;)m=m|c.lanes|c.childLanes,c=c.sibling;c=m&~f}else c=0,a.child=null;return yx(n,a,f,l,c)}if((l&536870912)!==0)a.memoizedState={baseLanes:0,cachePool:null},n!==null&&Vo(a,f!==null?f.cachePool:null),f!==null?vg(a,f):Qd(),jg(a);else return c=a.lanes=536870912,yx(n,a,f!==null?f.baseLanes|l:l,l,c)}else f!==null?(Vo(a,f.cachePool),vg(a,f),Ra(),a.memoizedState=null):(n!==null&&Vo(a,null),Qd(),Ra());return xn(n,a,m,l),a.child}function El(n,a){return n!==null&&n.tag===22||a.stateNode!==null||(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),a.sibling}function yx(n,a,l,c,m){var f=Ud();return f=f===null?null:{parent:Xt._currentValue,pool:f},a.memoizedState={baseLanes:l,cachePool:f},n!==null&&Vo(a,null),Qd(),jg(a),n!==null&&ir(n,a,c,!0),a.childLanes=m,null}function rc(n,a){return a=oc({mode:a.mode,children:a.children},n.mode),a.ref=n.ref,n.child=a,a.return=n,a}function bx(n,a,l){return Si(a,n.child,null,l),n=rc(a,a.pendingProps),n.flags|=2,ns(a),a.memoizedState=null,n}function Aw(n,a,l){var c=a.pendingProps,m=(a.flags&128)!==0;if(a.flags&=-129,n===null){if(dt){if(c.mode==="hidden")return n=rc(a,c),a.lanes=536870912,El(null,n);if(Fd(a),(n=Ot)?(n=E0(n,hs),n=n!==null&&n.data==="&"?n:null,n!==null&&(a.memoizedState={dehydrated:n,treeContext:ka!==null?{id:qs,overflow:Is}:null,retryLane:536870912,hydrationErrors:null},l=ng(n),l.return=a,a.child=l,pn=a,Ot=null)):n=null,n===null)throw Aa(a);return a.lanes=536870912,null}return rc(a,c)}var f=n.memoizedState;if(f!==null){var y=f.dehydrated;if(Fd(a),m)if(a.flags&256)a.flags&=-257,a=bx(n,a,l);else if(a.memoizedState!==null)a.child=n.child,a.flags|=128,a=null;else throw Error(r(558));else if(Wt||ir(n,a,l,!1),m=(l&n.childLanes)!==0,Wt||m){if(c=_t,c!==null&&(y=mn(c,l),y!==0&&y!==f.retryLane))throw f.retryLane=y,gi(n,y),Hn(c,n,y),gm;xc(),a=bx(n,a,l)}else n=f.treeContext,Ot=ps(y.nextSibling),pn=a,dt=!0,Ca=null,hs=!1,n!==null&&ig(a,n),a=rc(a,c),a.flags|=4096;return a}return n=Ws(n.child,{mode:c.mode,children:c.children}),n.ref=a.ref,a.child=n,n.return=a,n}function lc(n,a){var l=a.ref;if(l===null)n!==null&&n.ref!==null&&(a.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(r(284));(n===null||n.ref!==l)&&(a.flags|=4194816)}}function xm(n,a,l,c,m){return vi(a),l=Xd(n,a,l,c,void 0,m),c=Jd(),n!==null&&!Wt?(Wd(n,a,m),ia(n,a,m)):(dt&&c&&Dd(a),a.flags|=1,xn(n,a,l,m),a.child)}function vx(n,a,l,c,m,f){return vi(a),a.updateQueue=null,l=wg(a,c,l,m),Ng(n),c=Jd(),n!==null&&!Wt?(Wd(n,a,f),ia(n,a,f)):(dt&&c&&Dd(a),a.flags|=1,xn(n,a,l,f),a.child)}function jx(n,a,l,c,m){if(vi(a),a.stateNode===null){var f=tr,y=l.contextType;typeof y=="object"&&y!==null&&(f=gn(y)),f=new l(c,f),a.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,f.updater=fm,a.stateNode=f,f._reactInternals=a,f=a.stateNode,f.props=c,f.state=a.memoizedState,f.refs={},Gd(a),y=l.contextType,f.context=typeof y=="object"&&y!==null?gn(y):tr,f.state=a.memoizedState,y=l.getDerivedStateFromProps,typeof y=="function"&&(hm(a,l,y,c),f.state=a.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof f.getSnapshotBeforeUpdate=="function"||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(y=f.state,typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount(),y!==f.state&&fm.enqueueReplaceState(f,f.state,null),kl(a,c,f,m),zl(),f.state=a.memoizedState),typeof f.componentDidMount=="function"&&(a.flags|=4194308),c=!0}else if(n===null){f=a.stateNode;var S=a.memoizedProps,$=ki(l,S);f.props=$;var Q=f.context,re=l.contextType;y=tr,typeof re=="object"&&re!==null&&(y=gn(re));var de=l.getDerivedStateFromProps;re=typeof de=="function"||typeof f.getSnapshotBeforeUpdate=="function",S=a.pendingProps!==S,re||typeof f.UNSAFE_componentWillReceiveProps!="function"&&typeof f.componentWillReceiveProps!="function"||(S||Q!==y)&&lx(a,f,c,y),_a=!1;var Z=a.memoizedState;f.state=Z,kl(a,c,f,m),zl(),Q=a.memoizedState,S||Z!==Q||_a?(typeof de=="function"&&(hm(a,l,de,c),Q=a.memoizedState),($=_a||rx(a,l,$,c,Z,Q,y))?(re||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount()),typeof f.componentDidMount=="function"&&(a.flags|=4194308)):(typeof f.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=c,a.memoizedState=Q),f.props=c,f.state=Q,f.context=y,c=$):(typeof f.componentDidMount=="function"&&(a.flags|=4194308),c=!1)}else{f=a.stateNode,Vd(n,a),y=a.memoizedProps,re=ki(l,y),f.props=re,de=a.pendingProps,Z=f.context,Q=l.contextType,$=tr,typeof Q=="object"&&Q!==null&&($=gn(Q)),S=l.getDerivedStateFromProps,(Q=typeof S=="function"||typeof f.getSnapshotBeforeUpdate=="function")||typeof f.UNSAFE_componentWillReceiveProps!="function"&&typeof f.componentWillReceiveProps!="function"||(y!==de||Z!==$)&&lx(a,f,c,$),_a=!1,Z=a.memoizedState,f.state=Z,kl(a,c,f,m),zl();var W=a.memoizedState;y!==de||Z!==W||_a||n!==null&&n.dependencies!==null&&Po(n.dependencies)?(typeof S=="function"&&(hm(a,l,S,c),W=a.memoizedState),(re=_a||rx(a,l,re,c,Z,W,$)||n!==null&&n.dependencies!==null&&Po(n.dependencies))?(Q||typeof f.UNSAFE_componentWillUpdate!="function"&&typeof f.componentWillUpdate!="function"||(typeof f.componentWillUpdate=="function"&&f.componentWillUpdate(c,W,$),typeof f.UNSAFE_componentWillUpdate=="function"&&f.UNSAFE_componentWillUpdate(c,W,$)),typeof f.componentDidUpdate=="function"&&(a.flags|=4),typeof f.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof f.componentDidUpdate!="function"||y===n.memoizedProps&&Z===n.memoizedState||(a.flags|=4),typeof f.getSnapshotBeforeUpdate!="function"||y===n.memoizedProps&&Z===n.memoizedState||(a.flags|=1024),a.memoizedProps=c,a.memoizedState=W),f.props=c,f.state=W,f.context=$,c=re):(typeof f.componentDidUpdate!="function"||y===n.memoizedProps&&Z===n.memoizedState||(a.flags|=4),typeof f.getSnapshotBeforeUpdate!="function"||y===n.memoizedProps&&Z===n.memoizedState||(a.flags|=1024),c=!1)}return f=c,lc(n,a),c=(a.flags&128)!==0,f||c?(f=a.stateNode,l=c&&typeof l.getDerivedStateFromError!="function"?null:f.render(),a.flags|=1,n!==null&&c?(a.child=Si(a,n.child,null,m),a.child=Si(a,null,l,m)):xn(n,a,l,m),a.memoizedState=f.state,n=a.child):n=ia(n,a,m),n}function Nx(n,a,l,c){return yi(),a.flags|=256,xn(n,a,l,c),a.child}var ym={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function bm(n){return{baseLanes:n,cachePool:dg()}}function vm(n,a,l){return n=n!==null?n.childLanes&~l:0,a&&(n|=as),n}function wx(n,a,l){var c=a.pendingProps,m=!1,f=(a.flags&128)!==0,y;if((y=f)||(y=n!==null&&n.memoizedState===null?!1:(Gt.current&2)!==0),y&&(m=!0,a.flags&=-129),y=(a.flags&32)!==0,a.flags&=-33,n===null){if(dt){if(m?Oa(a):Ra(),(n=Ot)?(n=E0(n,hs),n=n!==null&&n.data!=="&"?n:null,n!==null&&(a.memoizedState={dehydrated:n,treeContext:ka!==null?{id:qs,overflow:Is}:null,retryLane:536870912,hydrationErrors:null},l=ng(n),l.return=a,a.child=l,pn=a,Ot=null)):n=null,n===null)throw Aa(a);return nh(n)?a.lanes=32:a.lanes=536870912,null}var S=c.children;return c=c.fallback,m?(Ra(),m=a.mode,S=oc({mode:"hidden",children:S},m),c=xi(c,m,l,null),S.return=a,c.return=a,S.sibling=c,a.child=S,c=a.child,c.memoizedState=bm(l),c.childLanes=vm(n,y,l),a.memoizedState=ym,El(null,c)):(Oa(a),jm(a,S))}var $=n.memoizedState;if($!==null&&(S=$.dehydrated,S!==null)){if(f)a.flags&256?(Oa(a),a.flags&=-257,a=Nm(n,a,l)):a.memoizedState!==null?(Ra(),a.child=n.child,a.flags|=128,a=null):(Ra(),S=c.fallback,m=a.mode,c=oc({mode:"visible",children:c.children},m),S=xi(S,m,l,null),S.flags|=2,c.return=a,S.return=a,c.sibling=S,a.child=c,Si(a,n.child,null,l),c=a.child,c.memoizedState=bm(l),c.childLanes=vm(n,y,l),a.memoizedState=ym,a=El(null,c));else if(Oa(a),nh(S)){if(y=S.nextSibling&&S.nextSibling.dataset,y)var Q=y.dgst;y=Q,c=Error(r(419)),c.stack="",c.digest=y,bl({value:c,source:null,stack:null}),a=Nm(n,a,l)}else if(Wt||ir(n,a,l,!1),y=(l&n.childLanes)!==0,Wt||y){if(y=_t,y!==null&&(c=mn(y,l),c!==0&&c!==$.retryLane))throw $.retryLane=c,gi(n,c),Hn(y,n,c),gm;th(S)||xc(),a=Nm(n,a,l)}else th(S)?(a.flags|=192,a.child=n.child,a=null):(n=$.treeContext,Ot=ps(S.nextSibling),pn=a,dt=!0,Ca=null,hs=!1,n!==null&&ig(a,n),a=jm(a,c.children),a.flags|=4096);return a}return m?(Ra(),S=c.fallback,m=a.mode,$=n.child,Q=$.sibling,c=Ws($,{mode:"hidden",children:c.children}),c.subtreeFlags=$.subtreeFlags&65011712,Q!==null?S=Ws(Q,S):(S=xi(S,m,l,null),S.flags|=2),S.return=a,c.return=a,c.sibling=S,a.child=c,El(null,c),c=a.child,S=n.child.memoizedState,S===null?S=bm(l):(m=S.cachePool,m!==null?($=Xt._currentValue,m=m.parent!==$?{parent:$,pool:$}:m):m=dg(),S={baseLanes:S.baseLanes|l,cachePool:m}),c.memoizedState=S,c.childLanes=vm(n,y,l),a.memoizedState=ym,El(n.child,c)):(Oa(a),l=n.child,n=l.sibling,l=Ws(l,{mode:"visible",children:c.children}),l.return=a,l.sibling=null,n!==null&&(y=a.deletions,y===null?(a.deletions=[n],a.flags|=16):y.push(n)),a.child=l,a.memoizedState=null,l)}function jm(n,a){return a=oc({mode:"visible",children:a},n.mode),a.return=n,n.child=a}function oc(n,a){return n=es(22,n,null,a),n.lanes=0,n}function Nm(n,a,l){return Si(a,n.child,null,l),n=jm(a,a.pendingProps.children),n.flags|=2,a.memoizedState=null,n}function Sx(n,a,l){n.lanes|=a;var c=n.alternate;c!==null&&(c.lanes|=a),$d(n.return,a,l)}function wm(n,a,l,c,m,f){var y=n.memoizedState;y===null?n.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:c,tail:l,tailMode:m,treeForkCount:f}:(y.isBackwards=a,y.rendering=null,y.renderingStartTime=0,y.last=c,y.tail=l,y.tailMode=m,y.treeForkCount=f)}function zx(n,a,l){var c=a.pendingProps,m=c.revealOrder,f=c.tail;c=c.children;var y=Gt.current,S=(y&2)!==0;if(S?(y=y&1|2,a.flags|=128):y&=1,X(Gt,y),xn(n,a,c,l),c=dt?yl:0,!S&&n!==null&&(n.flags&128)!==0)e:for(n=a.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&Sx(n,l,a);else if(n.tag===19)Sx(n,l,a);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===a)break e;for(;n.sibling===null;){if(n.return===null||n.return===a)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}switch(m){case"forwards":for(l=a.child,m=null;l!==null;)n=l.alternate,n!==null&&Yo(n)===null&&(m=l),l=l.sibling;l=m,l===null?(m=a.child,a.child=null):(m=l.sibling,l.sibling=null),wm(a,!1,m,l,f,c);break;case"backwards":case"unstable_legacy-backwards":for(l=null,m=a.child,a.child=null;m!==null;){if(n=m.alternate,n!==null&&Yo(n)===null){a.child=m;break}n=m.sibling,m.sibling=l,l=m,m=n}wm(a,!0,l,null,f,c);break;case"together":wm(a,!1,null,null,void 0,c);break;default:a.memoizedState=null}return a.child}function ia(n,a,l){if(n!==null&&(a.dependencies=n.dependencies),$a|=a.lanes,(l&a.childLanes)===0)if(n!==null){if(ir(n,a,l,!1),(l&a.childLanes)===0)return null}else return null;if(n!==null&&a.child!==n.child)throw Error(r(153));if(a.child!==null){for(n=a.child,l=Ws(n,n.pendingProps),a.child=l,l.return=a;n.sibling!==null;)n=n.sibling,l=l.sibling=Ws(n,n.pendingProps),l.return=a;l.sibling=null}return a.child}function Sm(n,a){return(n.lanes&a)!==0?!0:(n=n.dependencies,!!(n!==null&&Po(n)))}function Tw(n,a,l){switch(a.tag){case 3:tt(a,a.stateNode.containerInfo),Ta(a,Xt,n.memoizedState.cache),yi();break;case 27:case 5:Ue(a);break;case 4:tt(a,a.stateNode.containerInfo);break;case 10:Ta(a,a.type,a.memoizedProps.value);break;case 31:if(a.memoizedState!==null)return a.flags|=128,Fd(a),null;break;case 13:var c=a.memoizedState;if(c!==null)return c.dehydrated!==null?(Oa(a),a.flags|=128,null):(l&a.child.childLanes)!==0?wx(n,a,l):(Oa(a),n=ia(n,a,l),n!==null?n.sibling:null);Oa(a);break;case 19:var m=(n.flags&128)!==0;if(c=(l&a.childLanes)!==0,c||(ir(n,a,l,!1),c=(l&a.childLanes)!==0),m){if(c)return zx(n,a,l);a.flags|=128}if(m=a.memoizedState,m!==null&&(m.rendering=null,m.tail=null,m.lastEffect=null),X(Gt,Gt.current),c)break;return null;case 22:return a.lanes=0,xx(n,a,l,a.pendingProps);case 24:Ta(a,Xt,n.memoizedState.cache)}return ia(n,a,l)}function kx(n,a,l){if(n!==null)if(n.memoizedProps!==a.pendingProps)Wt=!0;else{if(!Sm(n,l)&&(a.flags&128)===0)return Wt=!1,Tw(n,a,l);Wt=(n.flags&131072)!==0}else Wt=!1,dt&&(a.flags&1048576)!==0&&ag(a,yl,a.index);switch(a.lanes=0,a.tag){case 16:e:{var c=a.pendingProps;if(n=Ni(a.elementType),a.type=n,typeof n=="function")Td(n)?(c=ki(n,c),a.tag=1,a=jx(null,a,n,c,l)):(a.tag=0,a=xm(null,a,n,c,l));else{if(n!=null){var m=n.$$typeof;if(m===C){a.tag=11,a=fx(null,a,n,c,l);break e}else if(m===_){a.tag=14,a=px(null,a,n,c,l);break e}}throw a=ze(n)||n,Error(r(306,a,""))}}return a;case 0:return xm(n,a,a.type,a.pendingProps,l);case 1:return c=a.type,m=ki(c,a.pendingProps),jx(n,a,c,m,l);case 3:e:{if(tt(a,a.stateNode.containerInfo),n===null)throw Error(r(387));c=a.pendingProps;var f=a.memoizedState;m=f.element,Vd(n,a),kl(a,c,null,l);var y=a.memoizedState;if(c=y.cache,Ta(a,Xt,c),c!==f.cache&&Bd(a,[Xt],l,!0),zl(),c=y.element,f.isDehydrated)if(f={element:c,isDehydrated:!1,cache:y.cache},a.updateQueue.baseState=f,a.memoizedState=f,a.flags&256){a=Nx(n,a,c,l);break e}else if(c!==m){m=us(Error(r(424)),a),bl(m),a=Nx(n,a,c,l);break e}else for(n=a.stateNode.containerInfo,n.nodeType===9?n=n.body:n=n.nodeName==="HTML"?n.ownerDocument.body:n,Ot=ps(n.firstChild),pn=a,dt=!0,Ca=null,hs=!0,l=xg(a,null,c,l),a.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(yi(),c===m){a=ia(n,a,l);break e}xn(n,a,c,l)}a=a.child}return a;case 26:return lc(n,a),n===null?(l=$0(a.type,null,a.pendingProps,null))?a.memoizedState=l:dt||(l=a.type,n=a.pendingProps,c=Sc(le.current).createElement(l),c[Yt]=a,c[hn]=n,yn(c,l,n),O(c),a.stateNode=c):a.memoizedState=$0(a.type,n.memoizedProps,a.pendingProps,n.memoizedState),null;case 27:return Ue(a),n===null&&dt&&(c=a.stateNode=R0(a.type,a.pendingProps,le.current),pn=a,hs=!0,m=Ot,Pa(a.type)?(sh=m,Ot=ps(c.firstChild)):Ot=m),xn(n,a,a.pendingProps.children,l),lc(n,a),n===null&&(a.flags|=4194304),a.child;case 5:return n===null&&dt&&((m=c=Ot)&&(c=iS(c,a.type,a.pendingProps,hs),c!==null?(a.stateNode=c,pn=a,Ot=ps(c.firstChild),hs=!1,m=!0):m=!1),m||Aa(a)),Ue(a),m=a.type,f=a.pendingProps,y=n!==null?n.memoizedProps:null,c=f.children,Jm(m,f)?c=null:y!==null&&Jm(m,y)&&(a.flags|=32),a.memoizedState!==null&&(m=Xd(n,a,vw,null,null,l),Kl._currentValue=m),lc(n,a),xn(n,a,c,l),a.child;case 6:return n===null&&dt&&((n=l=Ot)&&(l=rS(l,a.pendingProps,hs),l!==null?(a.stateNode=l,pn=a,Ot=null,n=!0):n=!1),n||Aa(a)),null;case 13:return wx(n,a,l);case 4:return tt(a,a.stateNode.containerInfo),c=a.pendingProps,n===null?a.child=Si(a,null,c,l):xn(n,a,c,l),a.child;case 11:return fx(n,a,a.type,a.pendingProps,l);case 7:return xn(n,a,a.pendingProps,l),a.child;case 8:return xn(n,a,a.pendingProps.children,l),a.child;case 12:return xn(n,a,a.pendingProps.children,l),a.child;case 10:return c=a.pendingProps,Ta(a,a.type,c.value),xn(n,a,c.children,l),a.child;case 9:return m=a.type._context,c=a.pendingProps.children,vi(a),m=gn(m),c=c(m),a.flags|=1,xn(n,a,c,l),a.child;case 14:return px(n,a,a.type,a.pendingProps,l);case 15:return gx(n,a,a.type,a.pendingProps,l);case 19:return zx(n,a,l);case 31:return Aw(n,a,l);case 22:return xx(n,a,l,a.pendingProps);case 24:return vi(a),c=gn(Xt),n===null?(m=Ud(),m===null&&(m=_t,f=qd(),m.pooledCache=f,f.refCount++,f!==null&&(m.pooledCacheLanes|=l),m=f),a.memoizedState={parent:c,cache:m},Gd(a),Ta(a,Xt,m)):((n.lanes&l)!==0&&(Vd(n,a),kl(a,null,null,l),zl()),m=n.memoizedState,f=a.memoizedState,m.parent!==c?(m={parent:c,cache:c},a.memoizedState=m,a.lanes===0&&(a.memoizedState=a.updateQueue.baseState=m),Ta(a,Xt,c)):(c=f.cache,Ta(a,Xt,c),c!==m.cache&&Bd(a,[Xt],l,!0))),xn(n,a,a.pendingProps.children,l),a.child;case 29:throw a.pendingProps}throw Error(r(156,a.tag))}function ra(n){n.flags|=4}function zm(n,a,l,c,m){if((a=(n.mode&32)!==0)&&(a=!1),a){if(n.flags|=16777216,(m&335544128)===m)if(n.stateNode.complete)n.flags|=8192;else if(Wx())n.flags|=8192;else throw wi=Ko,Pd}else n.flags&=-16777217}function Cx(n,a){if(a.type!=="stylesheet"||(a.state.loading&4)!==0)n.flags&=-16777217;else if(n.flags|=16777216,!P0(a))if(Wx())n.flags|=8192;else throw wi=Ko,Pd}function cc(n,a){a!==null&&(n.flags|=4),n.flags&16384&&(a=n.tag!==22?Xe():536870912,n.lanes|=a,xr|=a)}function Dl(n,a){if(!dt)switch(n.tailMode){case"hidden":a=n.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?n.tail=null:l.sibling=null;break;case"collapsed":l=n.tail;for(var c=null;l!==null;)l.alternate!==null&&(c=l),l=l.sibling;c===null?a||n.tail===null?n.tail=null:n.tail.sibling=null:c.sibling=null}}function Rt(n){var a=n.alternate!==null&&n.alternate.child===n.child,l=0,c=0;if(a)for(var m=n.child;m!==null;)l|=m.lanes|m.childLanes,c|=m.subtreeFlags&65011712,c|=m.flags&65011712,m.return=n,m=m.sibling;else for(m=n.child;m!==null;)l|=m.lanes|m.childLanes,c|=m.subtreeFlags,c|=m.flags,m.return=n,m=m.sibling;return n.subtreeFlags|=c,n.childLanes=l,a}function _w(n,a,l){var c=a.pendingProps;switch(Od(a),a.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Rt(a),null;case 1:return Rt(a),null;case 3:return l=a.stateNode,c=null,n!==null&&(c=n.memoizedState.cache),a.memoizedState.cache!==c&&(a.flags|=2048),na(Xt),we(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(n===null||n.child===null)&&(ar(a)?ra(a):n===null||n.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,Ld())),Rt(a),null;case 26:var m=a.type,f=a.memoizedState;return n===null?(ra(a),f!==null?(Rt(a),Cx(a,f)):(Rt(a),zm(a,m,null,c,l))):f?f!==n.memoizedState?(ra(a),Rt(a),Cx(a,f)):(Rt(a),a.flags&=-16777217):(n=n.memoizedProps,n!==c&&ra(a),Rt(a),zm(a,m,n,c,l)),null;case 27:if(Ce(a),l=le.current,m=a.type,n!==null&&a.stateNode!=null)n.memoizedProps!==c&&ra(a);else{if(!c){if(a.stateNode===null)throw Error(r(166));return Rt(a),null}n=Y.current,ar(a)?rg(a):(n=R0(m,c,l),a.stateNode=n,ra(a))}return Rt(a),null;case 5:if(Ce(a),m=a.type,n!==null&&a.stateNode!=null)n.memoizedProps!==c&&ra(a);else{if(!c){if(a.stateNode===null)throw Error(r(166));return Rt(a),null}if(f=Y.current,ar(a))rg(a);else{var y=Sc(le.current);switch(f){case 1:f=y.createElementNS("http://www.w3.org/2000/svg",m);break;case 2:f=y.createElementNS("http://www.w3.org/1998/Math/MathML",m);break;default:switch(m){case"svg":f=y.createElementNS("http://www.w3.org/2000/svg",m);break;case"math":f=y.createElementNS("http://www.w3.org/1998/Math/MathML",m);break;case"script":f=y.createElement("div"),f.innerHTML="<script><\/script>",f=f.removeChild(f.firstChild);break;case"select":f=typeof c.is=="string"?y.createElement("select",{is:c.is}):y.createElement("select"),c.multiple?f.multiple=!0:c.size&&(f.size=c.size);break;default:f=typeof c.is=="string"?y.createElement(m,{is:c.is}):y.createElement(m)}}f[Yt]=a,f[hn]=c;e:for(y=a.child;y!==null;){if(y.tag===5||y.tag===6)f.appendChild(y.stateNode);else if(y.tag!==4&&y.tag!==27&&y.child!==null){y.child.return=y,y=y.child;continue}if(y===a)break e;for(;y.sibling===null;){if(y.return===null||y.return===a)break e;y=y.return}y.sibling.return=y.return,y=y.sibling}a.stateNode=f;e:switch(yn(f,m,c),m){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}c&&ra(a)}}return Rt(a),zm(a,a.type,n===null?null:n.memoizedProps,a.pendingProps,l),null;case 6:if(n&&a.stateNode!=null)n.memoizedProps!==c&&ra(a);else{if(typeof c!="string"&&a.stateNode===null)throw Error(r(166));if(n=le.current,ar(a)){if(n=a.stateNode,l=a.memoizedProps,c=null,m=pn,m!==null)switch(m.tag){case 27:case 5:c=m.memoizedProps}n[Yt]=a,n=!!(n.nodeValue===l||c!==null&&c.suppressHydrationWarning===!0||w0(n.nodeValue,l)),n||Aa(a,!0)}else n=Sc(n).createTextNode(c),n[Yt]=a,a.stateNode=n}return Rt(a),null;case 31:if(l=a.memoizedState,n===null||n.memoizedState!==null){if(c=ar(a),l!==null){if(n===null){if(!c)throw Error(r(318));if(n=a.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(r(557));n[Yt]=a}else yi(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Rt(a),n=!1}else l=Ld(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=l),n=!0;if(!n)return a.flags&256?(ns(a),a):(ns(a),null);if((a.flags&128)!==0)throw Error(r(558))}return Rt(a),null;case 13:if(c=a.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(m=ar(a),c!==null&&c.dehydrated!==null){if(n===null){if(!m)throw Error(r(318));if(m=a.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[Yt]=a}else yi(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Rt(a),m=!1}else m=Ld(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=m),m=!0;if(!m)return a.flags&256?(ns(a),a):(ns(a),null)}return ns(a),(a.flags&128)!==0?(a.lanes=l,a):(l=c!==null,n=n!==null&&n.memoizedState!==null,l&&(c=a.child,m=null,c.alternate!==null&&c.alternate.memoizedState!==null&&c.alternate.memoizedState.cachePool!==null&&(m=c.alternate.memoizedState.cachePool.pool),f=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(f=c.memoizedState.cachePool.pool),f!==m&&(c.flags|=2048)),l!==n&&l&&(a.child.flags|=8192),cc(a,a.updateQueue),Rt(a),null);case 4:return we(),n===null&&Qm(a.stateNode.containerInfo),Rt(a),null;case 10:return na(a.type),Rt(a),null;case 19:if(E(Gt),c=a.memoizedState,c===null)return Rt(a),null;if(m=(a.flags&128)!==0,f=c.rendering,f===null)if(m)Dl(c,!1);else{if(Pt!==0||n!==null&&(n.flags&128)!==0)for(n=a.child;n!==null;){if(f=Yo(n),f!==null){for(a.flags|=128,Dl(c,!1),n=f.updateQueue,a.updateQueue=n,cc(a,n),a.subtreeFlags=0,n=l,l=a.child;l!==null;)tg(l,n),l=l.sibling;return X(Gt,Gt.current&1|2),dt&&ea(a,c.treeForkCount),a.child}n=n.sibling}c.tail!==null&&$t()>fc&&(a.flags|=128,m=!0,Dl(c,!1),a.lanes=4194304)}else{if(!m)if(n=Yo(f),n!==null){if(a.flags|=128,m=!0,n=n.updateQueue,a.updateQueue=n,cc(a,n),Dl(c,!0),c.tail===null&&c.tailMode==="hidden"&&!f.alternate&&!dt)return Rt(a),null}else 2*$t()-c.renderingStartTime>fc&&l!==536870912&&(a.flags|=128,m=!0,Dl(c,!1),a.lanes=4194304);c.isBackwards?(f.sibling=a.child,a.child=f):(n=c.last,n!==null?n.sibling=f:a.child=f,c.last=f)}return c.tail!==null?(n=c.tail,c.rendering=n,c.tail=n.sibling,c.renderingStartTime=$t(),n.sibling=null,l=Gt.current,X(Gt,m?l&1|2:l&1),dt&&ea(a,c.treeForkCount),n):(Rt(a),null);case 22:case 23:return ns(a),Zd(),c=a.memoizedState!==null,n!==null?n.memoizedState!==null!==c&&(a.flags|=8192):c&&(a.flags|=8192),c?(l&536870912)!==0&&(a.flags&128)===0&&(Rt(a),a.subtreeFlags&6&&(a.flags|=8192)):Rt(a),l=a.updateQueue,l!==null&&cc(a,l.retryQueue),l=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(l=n.memoizedState.cachePool.pool),c=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(c=a.memoizedState.cachePool.pool),c!==l&&(a.flags|=2048),n!==null&&E(ji),null;case 24:return l=null,n!==null&&(l=n.memoizedState.cache),a.memoizedState.cache!==l&&(a.flags|=2048),na(Xt),Rt(a),null;case 25:return null;case 30:return null}throw Error(r(156,a.tag))}function Ew(n,a){switch(Od(a),a.tag){case 1:return n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 3:return na(Xt),we(),n=a.flags,(n&65536)!==0&&(n&128)===0?(a.flags=n&-65537|128,a):null;case 26:case 27:case 5:return Ce(a),null;case 31:if(a.memoizedState!==null){if(ns(a),a.alternate===null)throw Error(r(340));yi()}return n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 13:if(ns(a),n=a.memoizedState,n!==null&&n.dehydrated!==null){if(a.alternate===null)throw Error(r(340));yi()}return n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 19:return E(Gt),null;case 4:return we(),null;case 10:return na(a.type),null;case 22:case 23:return ns(a),Zd(),n!==null&&E(ji),n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 24:return na(Xt),null;case 25:return null;default:return null}}function Ax(n,a){switch(Od(a),a.tag){case 3:na(Xt),we();break;case 26:case 27:case 5:Ce(a);break;case 4:we();break;case 31:a.memoizedState!==null&&ns(a);break;case 13:ns(a);break;case 19:E(Gt);break;case 10:na(a.type);break;case 22:case 23:ns(a),Zd(),n!==null&&E(ji);break;case 24:na(Xt)}}function Ol(n,a){try{var l=a.updateQueue,c=l!==null?l.lastEffect:null;if(c!==null){var m=c.next;l=m;do{if((l.tag&n)===n){c=void 0;var f=l.create,y=l.inst;c=f(),y.destroy=c}l=l.next}while(l!==m)}}catch(S){kt(a,a.return,S)}}function La(n,a,l){try{var c=a.updateQueue,m=c!==null?c.lastEffect:null;if(m!==null){var f=m.next;c=f;do{if((c.tag&n)===n){var y=c.inst,S=y.destroy;if(S!==void 0){y.destroy=void 0,m=a;var $=l,Q=S;try{Q()}catch(re){kt(m,$,re)}}}c=c.next}while(c!==f)}}catch(re){kt(a,a.return,re)}}function Tx(n){var a=n.updateQueue;if(a!==null){var l=n.stateNode;try{bg(a,l)}catch(c){kt(n,n.return,c)}}}function _x(n,a,l){l.props=ki(n.type,n.memoizedProps),l.state=n.memoizedState;try{l.componentWillUnmount()}catch(c){kt(n,a,c)}}function Rl(n,a){try{var l=n.ref;if(l!==null){switch(n.tag){case 26:case 27:case 5:var c=n.stateNode;break;case 30:c=n.stateNode;break;default:c=n.stateNode}typeof l=="function"?n.refCleanup=l(c):l.current=c}}catch(m){kt(n,a,m)}}function Us(n,a){var l=n.ref,c=n.refCleanup;if(l!==null)if(typeof c=="function")try{c()}catch(m){kt(n,a,m)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(m){kt(n,a,m)}else l.current=null}function Ex(n){var a=n.type,l=n.memoizedProps,c=n.stateNode;try{e:switch(a){case"button":case"input":case"select":case"textarea":l.autoFocus&&c.focus();break e;case"img":l.src?c.src=l.src:l.srcSet&&(c.srcset=l.srcSet)}}catch(m){kt(n,n.return,m)}}function km(n,a,l){try{var c=n.stateNode;Ww(c,n.type,l,a),c[hn]=a}catch(m){kt(n,n.return,m)}}function Dx(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&Pa(n.type)||n.tag===4}function Cm(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Dx(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&Pa(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function Am(n,a,l){var c=n.tag;if(c===5||c===6)n=n.stateNode,a?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(n,a):(a=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,a.appendChild(n),l=l._reactRootContainer,l!=null||a.onclick!==null||(a.onclick=Xs));else if(c!==4&&(c===27&&Pa(n.type)&&(l=n.stateNode,a=null),n=n.child,n!==null))for(Am(n,a,l),n=n.sibling;n!==null;)Am(n,a,l),n=n.sibling}function uc(n,a,l){var c=n.tag;if(c===5||c===6)n=n.stateNode,a?l.insertBefore(n,a):l.appendChild(n);else if(c!==4&&(c===27&&Pa(n.type)&&(l=n.stateNode),n=n.child,n!==null))for(uc(n,a,l),n=n.sibling;n!==null;)uc(n,a,l),n=n.sibling}function Ox(n){var a=n.stateNode,l=n.memoizedProps;try{for(var c=n.type,m=a.attributes;m.length;)a.removeAttributeNode(m[0]);yn(a,c,l),a[Yt]=n,a[hn]=l}catch(f){kt(n,n.return,f)}}var la=!1,en=!1,Tm=!1,Rx=typeof WeakSet=="function"?WeakSet:Set,cn=null;function Dw(n,a){if(n=n.containerInfo,Ym=Ec,n=Kp(n),Nd(n)){if("selectionStart"in n)var l={start:n.selectionStart,end:n.selectionEnd};else e:{l=(l=n.ownerDocument)&&l.defaultView||window;var c=l.getSelection&&l.getSelection();if(c&&c.rangeCount!==0){l=c.anchorNode;var m=c.anchorOffset,f=c.focusNode;c=c.focusOffset;try{l.nodeType,f.nodeType}catch{l=null;break e}var y=0,S=-1,$=-1,Q=0,re=0,de=n,Z=null;t:for(;;){for(var W;de!==l||m!==0&&de.nodeType!==3||(S=y+m),de!==f||c!==0&&de.nodeType!==3||($=y+c),de.nodeType===3&&(y+=de.nodeValue.length),(W=de.firstChild)!==null;)Z=de,de=W;for(;;){if(de===n)break t;if(Z===l&&++Q===m&&(S=y),Z===f&&++re===c&&($=y),(W=de.nextSibling)!==null)break;de=Z,Z=de.parentNode}de=W}l=S===-1||$===-1?null:{start:S,end:$}}else l=null}l=l||{start:0,end:0}}else l=null;for(Xm={focusedElem:n,selectionRange:l},Ec=!1,cn=a;cn!==null;)if(a=cn,n=a.child,(a.subtreeFlags&1028)!==0&&n!==null)n.return=a,cn=n;else for(;cn!==null;){switch(a=cn,f=a.alternate,n=a.flags,a.tag){case 0:if((n&4)!==0&&(n=a.updateQueue,n=n!==null?n.events:null,n!==null))for(l=0;l<n.length;l++)m=n[l],m.ref.impl=m.nextImpl;break;case 11:case 15:break;case 1:if((n&1024)!==0&&f!==null){n=void 0,l=a,m=f.memoizedProps,f=f.memoizedState,c=l.stateNode;try{var Te=ki(l.type,m);n=c.getSnapshotBeforeUpdate(Te,f),c.__reactInternalSnapshotBeforeUpdate=n}catch(Ve){kt(l,l.return,Ve)}}break;case 3:if((n&1024)!==0){if(n=a.stateNode.containerInfo,l=n.nodeType,l===9)eh(n);else if(l===1)switch(n.nodeName){case"HEAD":case"HTML":case"BODY":eh(n);break;default:n.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((n&1024)!==0)throw Error(r(163))}if(n=a.sibling,n!==null){n.return=a.return,cn=n;break}cn=a.return}}function Lx(n,a,l){var c=l.flags;switch(l.tag){case 0:case 11:case 15:ca(n,l),c&4&&Ol(5,l);break;case 1:if(ca(n,l),c&4)if(n=l.stateNode,a===null)try{n.componentDidMount()}catch(y){kt(l,l.return,y)}else{var m=ki(l.type,a.memoizedProps);a=a.memoizedState;try{n.componentDidUpdate(m,a,n.__reactInternalSnapshotBeforeUpdate)}catch(y){kt(l,l.return,y)}}c&64&&Tx(l),c&512&&Rl(l,l.return);break;case 3:if(ca(n,l),c&64&&(n=l.updateQueue,n!==null)){if(a=null,l.child!==null)switch(l.child.tag){case 27:case 5:a=l.child.stateNode;break;case 1:a=l.child.stateNode}try{bg(n,a)}catch(y){kt(l,l.return,y)}}break;case 27:a===null&&c&4&&Ox(l);case 26:case 5:ca(n,l),a===null&&c&4&&Ex(l),c&512&&Rl(l,l.return);break;case 12:ca(n,l);break;case 31:ca(n,l),c&4&&Bx(n,l);break;case 13:ca(n,l),c&4&&qx(n,l),c&64&&(n=l.memoizedState,n!==null&&(n=n.dehydrated,n!==null&&(l=Uw.bind(null,l),lS(n,l))));break;case 22:if(c=l.memoizedState!==null||la,!c){a=a!==null&&a.memoizedState!==null||en,m=la;var f=en;la=c,(en=a)&&!f?ua(n,l,(l.subtreeFlags&8772)!==0):ca(n,l),la=m,en=f}break;case 30:break;default:ca(n,l)}}function Mx(n){var a=n.alternate;a!==null&&(n.alternate=null,Mx(a)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(a=n.stateNode,a!==null&&ll(a)),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}var Lt=null,Un=!1;function oa(n,a,l){for(l=l.child;l!==null;)$x(n,a,l),l=l.sibling}function $x(n,a,l){if(Pe&&typeof Pe.onCommitFiberUnmount=="function")try{Pe.onCommitFiberUnmount(F,l)}catch{}switch(l.tag){case 26:en||Us(l,a),oa(n,a,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:en||Us(l,a);var c=Lt,m=Un;Pa(l.type)&&(Lt=l.stateNode,Un=!1),oa(n,a,l),Gl(l.stateNode),Lt=c,Un=m;break;case 5:en||Us(l,a);case 6:if(c=Lt,m=Un,Lt=null,oa(n,a,l),Lt=c,Un=m,Lt!==null)if(Un)try{(Lt.nodeType===9?Lt.body:Lt.nodeName==="HTML"?Lt.ownerDocument.body:Lt).removeChild(l.stateNode)}catch(f){kt(l,a,f)}else try{Lt.removeChild(l.stateNode)}catch(f){kt(l,a,f)}break;case 18:Lt!==null&&(Un?(n=Lt,T0(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,l.stateNode),zr(n)):T0(Lt,l.stateNode));break;case 4:c=Lt,m=Un,Lt=l.stateNode.containerInfo,Un=!0,oa(n,a,l),Lt=c,Un=m;break;case 0:case 11:case 14:case 15:La(2,l,a),en||La(4,l,a),oa(n,a,l);break;case 1:en||(Us(l,a),c=l.stateNode,typeof c.componentWillUnmount=="function"&&_x(l,a,c)),oa(n,a,l);break;case 21:oa(n,a,l);break;case 22:en=(c=en)||l.memoizedState!==null,oa(n,a,l),en=c;break;default:oa(n,a,l)}}function Bx(n,a){if(a.memoizedState===null&&(n=a.alternate,n!==null&&(n=n.memoizedState,n!==null))){n=n.dehydrated;try{zr(n)}catch(l){kt(a,a.return,l)}}}function qx(n,a){if(a.memoizedState===null&&(n=a.alternate,n!==null&&(n=n.memoizedState,n!==null&&(n=n.dehydrated,n!==null))))try{zr(n)}catch(l){kt(a,a.return,l)}}function Ow(n){switch(n.tag){case 31:case 13:case 19:var a=n.stateNode;return a===null&&(a=n.stateNode=new Rx),a;case 22:return n=n.stateNode,a=n._retryCache,a===null&&(a=n._retryCache=new Rx),a;default:throw Error(r(435,n.tag))}}function dc(n,a){var l=Ow(n);a.forEach(function(c){if(!l.has(c)){l.add(c);var m=Pw.bind(null,n,c);c.then(m,m)}})}function Pn(n,a){var l=a.deletions;if(l!==null)for(var c=0;c<l.length;c++){var m=l[c],f=n,y=a,S=y;e:for(;S!==null;){switch(S.tag){case 27:if(Pa(S.type)){Lt=S.stateNode,Un=!1;break e}break;case 5:Lt=S.stateNode,Un=!1;break e;case 3:case 4:Lt=S.stateNode.containerInfo,Un=!0;break e}S=S.return}if(Lt===null)throw Error(r(160));$x(f,y,m),Lt=null,Un=!1,f=m.alternate,f!==null&&(f.return=null),m.return=null}if(a.subtreeFlags&13886)for(a=a.child;a!==null;)Ix(a,n),a=a.sibling}var Ds=null;function Ix(n,a){var l=n.alternate,c=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:Pn(a,n),Gn(n),c&4&&(La(3,n,n.return),Ol(3,n),La(5,n,n.return));break;case 1:Pn(a,n),Gn(n),c&512&&(en||l===null||Us(l,l.return)),c&64&&la&&(n=n.updateQueue,n!==null&&(c=n.callbacks,c!==null&&(l=n.shared.hiddenCallbacks,n.shared.hiddenCallbacks=l===null?c:l.concat(c))));break;case 26:var m=Ds;if(Pn(a,n),Gn(n),c&512&&(en||l===null||Us(l,l.return)),c&4){var f=l!==null?l.memoizedState:null;if(c=n.memoizedState,l===null)if(c===null)if(n.stateNode===null){e:{c=n.type,l=n.memoizedProps,m=m.ownerDocument||m;t:switch(c){case"title":f=m.getElementsByTagName("title")[0],(!f||f[ja]||f[Yt]||f.namespaceURI==="http://www.w3.org/2000/svg"||f.hasAttribute("itemprop"))&&(f=m.createElement(c),m.head.insertBefore(f,m.querySelector("head > title"))),yn(f,c,l),f[Yt]=n,O(f),c=f;break e;case"link":var y=I0("link","href",m).get(c+(l.href||""));if(y){for(var S=0;S<y.length;S++)if(f=y[S],f.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&f.getAttribute("rel")===(l.rel==null?null:l.rel)&&f.getAttribute("title")===(l.title==null?null:l.title)&&f.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){y.splice(S,1);break t}}f=m.createElement(c),yn(f,c,l),m.head.appendChild(f);break;case"meta":if(y=I0("meta","content",m).get(c+(l.content||""))){for(S=0;S<y.length;S++)if(f=y[S],f.getAttribute("content")===(l.content==null?null:""+l.content)&&f.getAttribute("name")===(l.name==null?null:l.name)&&f.getAttribute("property")===(l.property==null?null:l.property)&&f.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&f.getAttribute("charset")===(l.charSet==null?null:l.charSet)){y.splice(S,1);break t}}f=m.createElement(c),yn(f,c,l),m.head.appendChild(f);break;default:throw Error(r(468,c))}f[Yt]=n,O(f),c=f}n.stateNode=c}else U0(m,n.type,n.stateNode);else n.stateNode=q0(m,c,n.memoizedProps);else f!==c?(f===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):f.count--,c===null?U0(m,n.type,n.stateNode):q0(m,c,n.memoizedProps)):c===null&&n.stateNode!==null&&km(n,n.memoizedProps,l.memoizedProps)}break;case 27:Pn(a,n),Gn(n),c&512&&(en||l===null||Us(l,l.return)),l!==null&&c&4&&km(n,n.memoizedProps,l.memoizedProps);break;case 5:if(Pn(a,n),Gn(n),c&512&&(en||l===null||Us(l,l.return)),n.flags&32){m=n.stateNode;try{Zi(m,"")}catch(Te){kt(n,n.return,Te)}}c&4&&n.stateNode!=null&&(m=n.memoizedProps,km(n,m,l!==null?l.memoizedProps:m)),c&1024&&(Tm=!0);break;case 6:if(Pn(a,n),Gn(n),c&4){if(n.stateNode===null)throw Error(r(162));c=n.memoizedProps,l=n.stateNode;try{l.nodeValue=c}catch(Te){kt(n,n.return,Te)}}break;case 3:if(Cc=null,m=Ds,Ds=zc(a.containerInfo),Pn(a,n),Ds=m,Gn(n),c&4&&l!==null&&l.memoizedState.isDehydrated)try{zr(a.containerInfo)}catch(Te){kt(n,n.return,Te)}Tm&&(Tm=!1,Ux(n));break;case 4:c=Ds,Ds=zc(n.stateNode.containerInfo),Pn(a,n),Gn(n),Ds=c;break;case 12:Pn(a,n),Gn(n);break;case 31:Pn(a,n),Gn(n),c&4&&(c=n.updateQueue,c!==null&&(n.updateQueue=null,dc(n,c)));break;case 13:Pn(a,n),Gn(n),n.child.flags&8192&&n.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(hc=$t()),c&4&&(c=n.updateQueue,c!==null&&(n.updateQueue=null,dc(n,c)));break;case 22:m=n.memoizedState!==null;var $=l!==null&&l.memoizedState!==null,Q=la,re=en;if(la=Q||m,en=re||$,Pn(a,n),en=re,la=Q,Gn(n),c&8192)e:for(a=n.stateNode,a._visibility=m?a._visibility&-2:a._visibility|1,m&&(l===null||$||la||en||Ci(n)),l=null,a=n;;){if(a.tag===5||a.tag===26){if(l===null){$=l=a;try{if(f=$.stateNode,m)y=f.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none";else{S=$.stateNode;var de=$.memoizedProps.style,Z=de!=null&&de.hasOwnProperty("display")?de.display:null;S.style.display=Z==null||typeof Z=="boolean"?"":(""+Z).trim()}}catch(Te){kt($,$.return,Te)}}}else if(a.tag===6){if(l===null){$=a;try{$.stateNode.nodeValue=m?"":$.memoizedProps}catch(Te){kt($,$.return,Te)}}}else if(a.tag===18){if(l===null){$=a;try{var W=$.stateNode;m?_0(W,!0):_0($.stateNode,!1)}catch(Te){kt($,$.return,Te)}}}else if((a.tag!==22&&a.tag!==23||a.memoizedState===null||a===n)&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===n)break e;for(;a.sibling===null;){if(a.return===null||a.return===n)break e;l===a&&(l=null),a=a.return}l===a&&(l=null),a.sibling.return=a.return,a=a.sibling}c&4&&(c=n.updateQueue,c!==null&&(l=c.retryQueue,l!==null&&(c.retryQueue=null,dc(n,l))));break;case 19:Pn(a,n),Gn(n),c&4&&(c=n.updateQueue,c!==null&&(n.updateQueue=null,dc(n,c)));break;case 30:break;case 21:break;default:Pn(a,n),Gn(n)}}function Gn(n){var a=n.flags;if(a&2){try{for(var l,c=n.return;c!==null;){if(Dx(c)){l=c;break}c=c.return}if(l==null)throw Error(r(160));switch(l.tag){case 27:var m=l.stateNode,f=Cm(n);uc(n,f,m);break;case 5:var y=l.stateNode;l.flags&32&&(Zi(y,""),l.flags&=-33);var S=Cm(n);uc(n,S,y);break;case 3:case 4:var $=l.stateNode.containerInfo,Q=Cm(n);Am(n,Q,$);break;default:throw Error(r(161))}}catch(re){kt(n,n.return,re)}n.flags&=-3}a&4096&&(n.flags&=-4097)}function Ux(n){if(n.subtreeFlags&1024)for(n=n.child;n!==null;){var a=n;Ux(a),a.tag===5&&a.flags&1024&&a.stateNode.reset(),n=n.sibling}}function ca(n,a){if(a.subtreeFlags&8772)for(a=a.child;a!==null;)Lx(n,a.alternate,a),a=a.sibling}function Ci(n){for(n=n.child;n!==null;){var a=n;switch(a.tag){case 0:case 11:case 14:case 15:La(4,a,a.return),Ci(a);break;case 1:Us(a,a.return);var l=a.stateNode;typeof l.componentWillUnmount=="function"&&_x(a,a.return,l),Ci(a);break;case 27:Gl(a.stateNode);case 26:case 5:Us(a,a.return),Ci(a);break;case 22:a.memoizedState===null&&Ci(a);break;case 30:Ci(a);break;default:Ci(a)}n=n.sibling}}function ua(n,a,l){for(l=l&&(a.subtreeFlags&8772)!==0,a=a.child;a!==null;){var c=a.alternate,m=n,f=a,y=f.flags;switch(f.tag){case 0:case 11:case 15:ua(m,f,l),Ol(4,f);break;case 1:if(ua(m,f,l),c=f,m=c.stateNode,typeof m.componentDidMount=="function")try{m.componentDidMount()}catch(Q){kt(c,c.return,Q)}if(c=f,m=c.updateQueue,m!==null){var S=c.stateNode;try{var $=m.shared.hiddenCallbacks;if($!==null)for(m.shared.hiddenCallbacks=null,m=0;m<$.length;m++)yg($[m],S)}catch(Q){kt(c,c.return,Q)}}l&&y&64&&Tx(f),Rl(f,f.return);break;case 27:Ox(f);case 26:case 5:ua(m,f,l),l&&c===null&&y&4&&Ex(f),Rl(f,f.return);break;case 12:ua(m,f,l);break;case 31:ua(m,f,l),l&&y&4&&Bx(m,f);break;case 13:ua(m,f,l),l&&y&4&&qx(m,f);break;case 22:f.memoizedState===null&&ua(m,f,l),Rl(f,f.return);break;case 30:break;default:ua(m,f,l)}a=a.sibling}}function _m(n,a){var l=null;n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(l=n.memoizedState.cachePool.pool),n=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(n=a.memoizedState.cachePool.pool),n!==l&&(n!=null&&n.refCount++,l!=null&&vl(l))}function Em(n,a){n=null,a.alternate!==null&&(n=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==n&&(a.refCount++,n!=null&&vl(n))}function Os(n,a,l,c){if(a.subtreeFlags&10256)for(a=a.child;a!==null;)Px(n,a,l,c),a=a.sibling}function Px(n,a,l,c){var m=a.flags;switch(a.tag){case 0:case 11:case 15:Os(n,a,l,c),m&2048&&Ol(9,a);break;case 1:Os(n,a,l,c);break;case 3:Os(n,a,l,c),m&2048&&(n=null,a.alternate!==null&&(n=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==n&&(a.refCount++,n!=null&&vl(n)));break;case 12:if(m&2048){Os(n,a,l,c),n=a.stateNode;try{var f=a.memoizedProps,y=f.id,S=f.onPostCommit;typeof S=="function"&&S(y,a.alternate===null?"mount":"update",n.passiveEffectDuration,-0)}catch($){kt(a,a.return,$)}}else Os(n,a,l,c);break;case 31:Os(n,a,l,c);break;case 13:Os(n,a,l,c);break;case 23:break;case 22:f=a.stateNode,y=a.alternate,a.memoizedState!==null?f._visibility&2?Os(n,a,l,c):Ll(n,a):f._visibility&2?Os(n,a,l,c):(f._visibility|=2,fr(n,a,l,c,(a.subtreeFlags&10256)!==0||!1)),m&2048&&_m(y,a);break;case 24:Os(n,a,l,c),m&2048&&Em(a.alternate,a);break;default:Os(n,a,l,c)}}function fr(n,a,l,c,m){for(m=m&&((a.subtreeFlags&10256)!==0||!1),a=a.child;a!==null;){var f=n,y=a,S=l,$=c,Q=y.flags;switch(y.tag){case 0:case 11:case 15:fr(f,y,S,$,m),Ol(8,y);break;case 23:break;case 22:var re=y.stateNode;y.memoizedState!==null?re._visibility&2?fr(f,y,S,$,m):Ll(f,y):(re._visibility|=2,fr(f,y,S,$,m)),m&&Q&2048&&_m(y.alternate,y);break;case 24:fr(f,y,S,$,m),m&&Q&2048&&Em(y.alternate,y);break;default:fr(f,y,S,$,m)}a=a.sibling}}function Ll(n,a){if(a.subtreeFlags&10256)for(a=a.child;a!==null;){var l=n,c=a,m=c.flags;switch(c.tag){case 22:Ll(l,c),m&2048&&_m(c.alternate,c);break;case 24:Ll(l,c),m&2048&&Em(c.alternate,c);break;default:Ll(l,c)}a=a.sibling}}var Ml=8192;function pr(n,a,l){if(n.subtreeFlags&Ml)for(n=n.child;n!==null;)Gx(n,a,l),n=n.sibling}function Gx(n,a,l){switch(n.tag){case 26:pr(n,a,l),n.flags&Ml&&n.memoizedState!==null&&bS(l,Ds,n.memoizedState,n.memoizedProps);break;case 5:pr(n,a,l);break;case 3:case 4:var c=Ds;Ds=zc(n.stateNode.containerInfo),pr(n,a,l),Ds=c;break;case 22:n.memoizedState===null&&(c=n.alternate,c!==null&&c.memoizedState!==null?(c=Ml,Ml=16777216,pr(n,a,l),Ml=c):pr(n,a,l));break;default:pr(n,a,l)}}function Vx(n){var a=n.alternate;if(a!==null&&(n=a.child,n!==null)){a.child=null;do a=n.sibling,n.sibling=null,n=a;while(n!==null)}}function $l(n){var a=n.deletions;if((n.flags&16)!==0){if(a!==null)for(var l=0;l<a.length;l++){var c=a[l];cn=c,Kx(c,n)}Vx(n)}if(n.subtreeFlags&10256)for(n=n.child;n!==null;)Hx(n),n=n.sibling}function Hx(n){switch(n.tag){case 0:case 11:case 15:$l(n),n.flags&2048&&La(9,n,n.return);break;case 3:$l(n);break;case 12:$l(n);break;case 22:var a=n.stateNode;n.memoizedState!==null&&a._visibility&2&&(n.return===null||n.return.tag!==13)?(a._visibility&=-3,mc(n)):$l(n);break;default:$l(n)}}function mc(n){var a=n.deletions;if((n.flags&16)!==0){if(a!==null)for(var l=0;l<a.length;l++){var c=a[l];cn=c,Kx(c,n)}Vx(n)}for(n=n.child;n!==null;){switch(a=n,a.tag){case 0:case 11:case 15:La(8,a,a.return),mc(a);break;case 22:l=a.stateNode,l._visibility&2&&(l._visibility&=-3,mc(a));break;default:mc(a)}n=n.sibling}}function Kx(n,a){for(;cn!==null;){var l=cn;switch(l.tag){case 0:case 11:case 15:La(8,l,a);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var c=l.memoizedState.cachePool.pool;c!=null&&c.refCount++}break;case 24:vl(l.memoizedState.cache)}if(c=l.child,c!==null)c.return=l,cn=c;else e:for(l=n;cn!==null;){c=cn;var m=c.sibling,f=c.return;if(Mx(c),c===l){cn=null;break e}if(m!==null){m.return=f,cn=m;break e}cn=f}}}var Rw={getCacheForType:function(n){var a=gn(Xt),l=a.data.get(n);return l===void 0&&(l=n(),a.data.set(n,l)),l},cacheSignal:function(){return gn(Xt).controller.signal}},Lw=typeof WeakMap=="function"?WeakMap:Map,jt=0,_t=null,rt=null,ot=0,zt=0,ss=null,Ma=!1,gr=!1,Dm=!1,da=0,Pt=0,$a=0,Ai=0,Om=0,as=0,xr=0,Bl=null,Vn=null,Rm=!1,hc=0,Qx=0,fc=1/0,pc=null,Ba=null,rn=0,qa=null,yr=null,ma=0,Lm=0,Mm=null,Zx=null,ql=0,$m=null;function is(){return(jt&2)!==0&&ot!==0?ot&-ot:V.T!==null?Gm():Zs()}function Fx(){if(as===0)if((ot&536870912)===0||dt){var n=ks;ks<<=1,(ks&3932160)===0&&(ks=262144),as=n}else as=536870912;return n=ts.current,n!==null&&(n.flags|=32),as}function Hn(n,a,l){(n===_t&&(zt===2||zt===9)||n.cancelPendingCommit!==null)&&(br(n,0),Ia(n,ot,as,!1)),$e(n,l),((jt&2)===0||n!==_t)&&(n===_t&&((jt&2)===0&&(Ai|=l),Pt===4&&Ia(n,ot,as,!1)),Ps(n))}function Yx(n,a,l){if((jt&6)!==0)throw Error(r(327));var c=!l&&(a&127)===0&&(a&n.expiredLanes)===0||De(n,a),m=c?Bw(n,a):qm(n,a,!0),f=c;do{if(m===0){gr&&!c&&Ia(n,a,0,!1);break}else{if(l=n.current.alternate,f&&!Mw(l)){m=qm(n,a,!1),f=!1;continue}if(m===2){if(f=a,n.errorRecoveryDisabledLanes&f)var y=0;else y=n.pendingLanes&-536870913,y=y!==0?y:y&536870912?536870912:0;if(y!==0){a=y;e:{var S=n;m=Bl;var $=S.current.memoizedState.isDehydrated;if($&&(br(S,y).flags|=256),y=qm(S,y,!1),y!==2){if(Dm&&!$){S.errorRecoveryDisabledLanes|=f,Ai|=f,m=4;break e}f=Vn,Vn=m,f!==null&&(Vn===null?Vn=f:Vn.push.apply(Vn,f))}m=y}if(f=!1,m!==2)continue}}if(m===1){br(n,0),Ia(n,a,0,!0);break}e:{switch(c=n,f=m,f){case 0:case 1:throw Error(r(345));case 4:if((a&4194048)!==a)break;case 6:Ia(c,a,as,!Ma);break e;case 2:Vn=null;break;case 3:case 5:break;default:throw Error(r(329))}if((a&62914560)===a&&(m=hc+300-$t(),10<m)){if(Ia(c,a,as,!Ma),qe(c,0,!0)!==0)break e;ma=a,c.timeoutHandle=C0(Xx.bind(null,c,l,Vn,pc,Rm,a,as,Ai,xr,Ma,f,"Throttled",-0,0),m);break e}Xx(c,l,Vn,pc,Rm,a,as,Ai,xr,Ma,f,null,-0,0)}}break}while(!0);Ps(n)}function Xx(n,a,l,c,m,f,y,S,$,Q,re,de,Z,W){if(n.timeoutHandle=-1,de=a.subtreeFlags,de&8192||(de&16785408)===16785408){de={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Xs},Gx(a,f,de);var Te=(f&62914560)===f?hc-$t():(f&4194048)===f?Qx-$t():0;if(Te=vS(de,Te),Te!==null){ma=f,n.cancelPendingCommit=Te(i0.bind(null,n,a,f,l,c,m,y,S,$,re,de,null,Z,W)),Ia(n,f,y,!Q);return}}i0(n,a,f,l,c,m,y,S,$)}function Mw(n){for(var a=n;;){var l=a.tag;if((l===0||l===11||l===15)&&a.flags&16384&&(l=a.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var c=0;c<l.length;c++){var m=l[c],f=m.getSnapshot;m=m.value;try{if(!Wn(f(),m))return!1}catch{return!1}}if(l=a.child,a.subtreeFlags&16384&&l!==null)l.return=a,a=l;else{if(a===n)break;for(;a.sibling===null;){if(a.return===null||a.return===n)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function Ia(n,a,l,c){a&=~Om,a&=~Ai,n.suspendedLanes|=a,n.pingedLanes&=~a,c&&(n.warmLanes|=a),c=n.expirationTimes;for(var m=a;0<m;){var f=31-ut(m),y=1<<f;c[f]=-1,m&=~y}l!==0&&Cs(n,l,a)}function gc(){return(jt&6)===0?(Il(0),!1):!0}function Bm(){if(rt!==null){if(zt===0)var n=rt.return;else n=rt,ta=bi=null,em(n),cr=null,Nl=0,n=rt;for(;n!==null;)Ax(n.alternate,n),n=n.return;rt=null}}function br(n,a){var l=n.timeoutHandle;l!==-1&&(n.timeoutHandle=-1,nS(l)),l=n.cancelPendingCommit,l!==null&&(n.cancelPendingCommit=null,l()),ma=0,Bm(),_t=n,rt=l=Ws(n.current,null),ot=a,zt=0,ss=null,Ma=!1,gr=De(n,a),Dm=!1,xr=as=Om=Ai=$a=Pt=0,Vn=Bl=null,Rm=!1,(a&8)!==0&&(a|=a&32);var c=n.entangledLanes;if(c!==0)for(n=n.entanglements,c&=a;0<c;){var m=31-ut(c),f=1<<m;a|=n[m],c&=~f}return da=a,$o(),l}function Jx(n,a){Ye=null,V.H=_l,a===or||a===Ho?(a=fg(),zt=3):a===Pd?(a=fg(),zt=4):zt=a===gm?8:a!==null&&typeof a=="object"&&typeof a.then=="function"?6:1,ss=a,rt===null&&(Pt=1,ic(n,us(a,n.current)))}function Wx(){var n=ts.current;return n===null?!0:(ot&4194048)===ot?fs===null:(ot&62914560)===ot||(ot&536870912)!==0?n===fs:!1}function e0(){var n=V.H;return V.H=_l,n===null?_l:n}function t0(){var n=V.A;return V.A=Rw,n}function xc(){Pt=4,Ma||(ot&4194048)!==ot&&ts.current!==null||(gr=!0),($a&134217727)===0&&(Ai&134217727)===0||_t===null||Ia(_t,ot,as,!1)}function qm(n,a,l){var c=jt;jt|=2;var m=e0(),f=t0();(_t!==n||ot!==a)&&(pc=null,br(n,a)),a=!1;var y=Pt;e:do try{if(zt!==0&&rt!==null){var S=rt,$=ss;switch(zt){case 8:Bm(),y=6;break e;case 3:case 2:case 9:case 6:ts.current===null&&(a=!0);var Q=zt;if(zt=0,ss=null,vr(n,S,$,Q),l&&gr){y=0;break e}break;default:Q=zt,zt=0,ss=null,vr(n,S,$,Q)}}$w(),y=Pt;break}catch(re){Jx(n,re)}while(!0);return a&&n.shellSuspendCounter++,ta=bi=null,jt=c,V.H=m,V.A=f,rt===null&&(_t=null,ot=0,$o()),y}function $w(){for(;rt!==null;)n0(rt)}function Bw(n,a){var l=jt;jt|=2;var c=e0(),m=t0();_t!==n||ot!==a?(pc=null,fc=$t()+500,br(n,a)):gr=De(n,a);e:do try{if(zt!==0&&rt!==null){a=rt;var f=ss;t:switch(zt){case 1:zt=0,ss=null,vr(n,a,f,1);break;case 2:case 9:if(mg(f)){zt=0,ss=null,s0(a);break}a=function(){zt!==2&&zt!==9||_t!==n||(zt=7),Ps(n)},f.then(a,a);break e;case 3:zt=7;break e;case 4:zt=5;break e;case 7:mg(f)?(zt=0,ss=null,s0(a)):(zt=0,ss=null,vr(n,a,f,7));break;case 5:var y=null;switch(rt.tag){case 26:y=rt.memoizedState;case 5:case 27:var S=rt;if(y?P0(y):S.stateNode.complete){zt=0,ss=null;var $=S.sibling;if($!==null)rt=$;else{var Q=S.return;Q!==null?(rt=Q,yc(Q)):rt=null}break t}}zt=0,ss=null,vr(n,a,f,5);break;case 6:zt=0,ss=null,vr(n,a,f,6);break;case 8:Bm(),Pt=6;break e;default:throw Error(r(462))}}qw();break}catch(re){Jx(n,re)}while(!0);return ta=bi=null,V.H=c,V.A=m,jt=l,rt!==null?0:(_t=null,ot=0,$o(),Pt)}function qw(){for(;rt!==null&&!an();)n0(rt)}function n0(n){var a=kx(n.alternate,n,da);n.memoizedProps=n.pendingProps,a===null?yc(n):rt=a}function s0(n){var a=n,l=a.alternate;switch(a.tag){case 15:case 0:a=vx(l,a,a.pendingProps,a.type,void 0,ot);break;case 11:a=vx(l,a,a.pendingProps,a.type.render,a.ref,ot);break;case 5:em(a);default:Ax(l,a),a=rt=tg(a,da),a=kx(l,a,da)}n.memoizedProps=n.pendingProps,a===null?yc(n):rt=a}function vr(n,a,l,c){ta=bi=null,em(a),cr=null,Nl=0;var m=a.return;try{if(Cw(n,m,a,l,ot)){Pt=1,ic(n,us(l,n.current)),rt=null;return}}catch(f){if(m!==null)throw rt=m,f;Pt=1,ic(n,us(l,n.current)),rt=null;return}a.flags&32768?(dt||c===1?n=!0:gr||(ot&536870912)!==0?n=!1:(Ma=n=!0,(c===2||c===9||c===3||c===6)&&(c=ts.current,c!==null&&c.tag===13&&(c.flags|=16384))),a0(a,n)):yc(a)}function yc(n){var a=n;do{if((a.flags&32768)!==0){a0(a,Ma);return}n=a.return;var l=_w(a.alternate,a,da);if(l!==null){rt=l;return}if(a=a.sibling,a!==null){rt=a;return}rt=a=n}while(a!==null);Pt===0&&(Pt=5)}function a0(n,a){do{var l=Ew(n.alternate,n);if(l!==null){l.flags&=32767,rt=l;return}if(l=n.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!a&&(n=n.sibling,n!==null)){rt=n;return}rt=n=l}while(n!==null);Pt=6,rt=null}function i0(n,a,l,c,m,f,y,S,$){n.cancelPendingCommit=null;do bc();while(rn!==0);if((jt&6)!==0)throw Error(r(327));if(a!==null){if(a===n.current)throw Error(r(177));if(f=a.lanes|a.childLanes,f|=Cd,We(n,l,f,y,S,$),n===_t&&(rt=_t=null,ot=0),yr=a,qa=n,ma=l,Lm=f,Mm=m,Zx=c,(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?(n.callbackNode=null,n.callbackPriority=0,Gw(zn,function(){return u0(),null})):(n.callbackNode=null,n.callbackPriority=0),c=(a.flags&13878)!==0,(a.subtreeFlags&13878)!==0||c){c=V.T,V.T=null,m=ne.p,ne.p=2,y=jt,jt|=4;try{Dw(n,a,l)}finally{jt=y,ne.p=m,V.T=c}}rn=1,r0(),l0(),o0()}}function r0(){if(rn===1){rn=0;var n=qa,a=yr,l=(a.flags&13878)!==0;if((a.subtreeFlags&13878)!==0||l){l=V.T,V.T=null;var c=ne.p;ne.p=2;var m=jt;jt|=4;try{Ix(a,n);var f=Xm,y=Kp(n.containerInfo),S=f.focusedElem,$=f.selectionRange;if(y!==S&&S&&S.ownerDocument&&Hp(S.ownerDocument.documentElement,S)){if($!==null&&Nd(S)){var Q=$.start,re=$.end;if(re===void 0&&(re=Q),"selectionStart"in S)S.selectionStart=Q,S.selectionEnd=Math.min(re,S.value.length);else{var de=S.ownerDocument||document,Z=de&&de.defaultView||window;if(Z.getSelection){var W=Z.getSelection(),Te=S.textContent.length,Ve=Math.min($.start,Te),Tt=$.end===void 0?Ve:Math.min($.end,Te);!W.extend&&Ve>Tt&&(y=Tt,Tt=Ve,Ve=y);var H=Vp(S,Ve),q=Vp(S,Tt);if(H&&q&&(W.rangeCount!==1||W.anchorNode!==H.node||W.anchorOffset!==H.offset||W.focusNode!==q.node||W.focusOffset!==q.offset)){var K=de.createRange();K.setStart(H.node,H.offset),W.removeAllRanges(),Ve>Tt?(W.addRange(K),W.extend(q.node,q.offset)):(K.setEnd(q.node,q.offset),W.addRange(K))}}}}for(de=[],W=S;W=W.parentNode;)W.nodeType===1&&de.push({element:W,left:W.scrollLeft,top:W.scrollTop});for(typeof S.focus=="function"&&S.focus(),S=0;S<de.length;S++){var ce=de[S];ce.element.scrollLeft=ce.left,ce.element.scrollTop=ce.top}}Ec=!!Ym,Xm=Ym=null}finally{jt=m,ne.p=c,V.T=l}}n.current=a,rn=2}}function l0(){if(rn===2){rn=0;var n=qa,a=yr,l=(a.flags&8772)!==0;if((a.subtreeFlags&8772)!==0||l){l=V.T,V.T=null;var c=ne.p;ne.p=2;var m=jt;jt|=4;try{Lx(n,a.alternate,a)}finally{jt=m,ne.p=c,V.T=l}}rn=3}}function o0(){if(rn===4||rn===3){rn=0,ws();var n=qa,a=yr,l=ma,c=Zx;(a.subtreeFlags&10256)!==0||(a.flags&10256)!==0?rn=5:(rn=0,yr=qa=null,c0(n,n.pendingLanes));var m=n.pendingLanes;if(m===0&&(Ba=null),Bn(l),a=a.stateNode,Pe&&typeof Pe.onCommitFiberRoot=="function")try{Pe.onCommitFiberRoot(F,a,void 0,(a.current.flags&128)===128)}catch{}if(c!==null){a=V.T,m=ne.p,ne.p=2,V.T=null;try{for(var f=n.onRecoverableError,y=0;y<c.length;y++){var S=c[y];f(S.value,{componentStack:S.stack})}}finally{V.T=a,ne.p=m}}(ma&3)!==0&&bc(),Ps(n),m=n.pendingLanes,(l&261930)!==0&&(m&42)!==0?n===$m?ql++:(ql=0,$m=n):ql=0,Il(0)}}function c0(n,a){(n.pooledCacheLanes&=a)===0&&(a=n.pooledCache,a!=null&&(n.pooledCache=null,vl(a)))}function bc(){return r0(),l0(),o0(),u0()}function u0(){if(rn!==5)return!1;var n=qa,a=Lm;Lm=0;var l=Bn(ma),c=V.T,m=ne.p;try{ne.p=32>l?32:l,V.T=null,l=Mm,Mm=null;var f=qa,y=ma;if(rn=0,yr=qa=null,ma=0,(jt&6)!==0)throw Error(r(331));var S=jt;if(jt|=4,Hx(f.current),Px(f,f.current,y,l),jt=S,Il(0,!1),Pe&&typeof Pe.onPostCommitFiberRoot=="function")try{Pe.onPostCommitFiberRoot(F,f)}catch{}return!0}finally{ne.p=m,V.T=c,c0(n,a)}}function d0(n,a,l){a=us(l,a),a=pm(n.stateNode,a,2),n=Da(n,a,2),n!==null&&($e(n,2),Ps(n))}function kt(n,a,l){if(n.tag===3)d0(n,n,l);else for(;a!==null;){if(a.tag===3){d0(a,n,l);break}else if(a.tag===1){var c=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Ba===null||!Ba.has(c))){n=us(l,n),l=mx(2),c=Da(a,l,2),c!==null&&(hx(l,c,a,n),$e(c,2),Ps(c));break}}a=a.return}}function Im(n,a,l){var c=n.pingCache;if(c===null){c=n.pingCache=new Lw;var m=new Set;c.set(a,m)}else m=c.get(a),m===void 0&&(m=new Set,c.set(a,m));m.has(l)||(Dm=!0,m.add(l),n=Iw.bind(null,n,a,l),a.then(n,n))}function Iw(n,a,l){var c=n.pingCache;c!==null&&c.delete(a),n.pingedLanes|=n.suspendedLanes&l,n.warmLanes&=~l,_t===n&&(ot&l)===l&&(Pt===4||Pt===3&&(ot&62914560)===ot&&300>$t()-hc?(jt&2)===0&&br(n,0):Om|=l,xr===ot&&(xr=0)),Ps(n)}function m0(n,a){a===0&&(a=Xe()),n=gi(n,a),n!==null&&($e(n,a),Ps(n))}function Uw(n){var a=n.memoizedState,l=0;a!==null&&(l=a.retryLane),m0(n,l)}function Pw(n,a){var l=0;switch(n.tag){case 31:case 13:var c=n.stateNode,m=n.memoizedState;m!==null&&(l=m.retryLane);break;case 19:c=n.stateNode;break;case 22:c=n.stateNode._retryCache;break;default:throw Error(r(314))}c!==null&&c.delete(a),m0(n,l)}function Gw(n,a){return sn(n,a)}var vc=null,jr=null,Um=!1,jc=!1,Pm=!1,Ua=0;function Ps(n){n!==jr&&n.next===null&&(jr===null?vc=jr=n:jr=jr.next=n),jc=!0,Um||(Um=!0,Hw())}function Il(n,a){if(!Pm&&jc){Pm=!0;do for(var l=!1,c=vc;c!==null;){if(n!==0){var m=c.pendingLanes;if(m===0)var f=0;else{var y=c.suspendedLanes,S=c.pingedLanes;f=(1<<31-ut(42|n)+1)-1,f&=m&~(y&~S),f=f&201326741?f&201326741|1:f?f|2:0}f!==0&&(l=!0,g0(c,f))}else f=ot,f=qe(c,c===_t?f:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(f&3)===0||De(c,f)||(l=!0,g0(c,f));c=c.next}while(l);Pm=!1}}function Vw(){h0()}function h0(){jc=Um=!1;var n=0;Ua!==0&&tS()&&(n=Ua);for(var a=$t(),l=null,c=vc;c!==null;){var m=c.next,f=f0(c,a);f===0?(c.next=null,l===null?vc=m:l.next=m,m===null&&(jr=l)):(l=c,(n!==0||(f&3)!==0)&&(jc=!0)),c=m}rn!==0&&rn!==5||Il(n),Ua!==0&&(Ua=0)}function f0(n,a){for(var l=n.suspendedLanes,c=n.pingedLanes,m=n.expirationTimes,f=n.pendingLanes&-62914561;0<f;){var y=31-ut(f),S=1<<y,$=m[y];$===-1?((S&l)===0||(S&c)!==0)&&(m[y]=Ge(S,a)):$<=a&&(n.expiredLanes|=S),f&=~S}if(a=_t,l=ot,l=qe(n,n===a?l:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),c=n.callbackNode,l===0||n===a&&(zt===2||zt===9)||n.cancelPendingCommit!==null)return c!==null&&c!==null&&Zt(c),n.callbackNode=null,n.callbackPriority=0;if((l&3)===0||De(n,l)){if(a=l&-l,a===n.callbackPriority)return a;switch(c!==null&&Zt(c),Bn(l)){case 2:case 8:l=dn;break;case 32:l=zn;break;case 268435456:l=kn;break;default:l=zn}return c=p0.bind(null,n),l=sn(l,c),n.callbackPriority=a,n.callbackNode=l,a}return c!==null&&c!==null&&Zt(c),n.callbackPriority=2,n.callbackNode=null,2}function p0(n,a){if(rn!==0&&rn!==5)return n.callbackNode=null,n.callbackPriority=0,null;var l=n.callbackNode;if(bc()&&n.callbackNode!==l)return null;var c=ot;return c=qe(n,n===_t?c:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),c===0?null:(Yx(n,c,a),f0(n,$t()),n.callbackNode!=null&&n.callbackNode===l?p0.bind(null,n):null)}function g0(n,a){if(bc())return null;Yx(n,a,!0)}function Hw(){sS(function(){(jt&6)!==0?sn(Yn,Vw):h0()})}function Gm(){if(Ua===0){var n=rr;n===0&&(n=Ks,Ks<<=1,(Ks&261888)===0&&(Ks=256)),Ua=n}return Ua}function x0(n){return n==null||typeof n=="symbol"||typeof n=="boolean"?null:typeof n=="function"?n:To(""+n)}function y0(n,a){var l=a.ownerDocument.createElement("input");return l.name=a.name,l.value=a.value,n.id&&l.setAttribute("form",n.id),a.parentNode.insertBefore(l,a),n=new FormData(n),l.parentNode.removeChild(l),n}function Kw(n,a,l,c,m){if(a==="submit"&&l&&l.stateNode===m){var f=x0((m[hn]||null).action),y=c.submitter;y&&(a=(a=y[hn]||null)?x0(a.formAction):y.getAttribute("formAction"),a!==null&&(f=a,y=null));var S=new Oo("action","action",null,c,m);n.push({event:S,listeners:[{instance:null,listener:function(){if(c.defaultPrevented){if(Ua!==0){var $=y?y0(m,y):new FormData(m);cm(l,{pending:!0,data:$,method:m.method,action:f},null,$)}}else typeof f=="function"&&(S.preventDefault(),$=y?y0(m,y):new FormData(m),cm(l,{pending:!0,data:$,method:m.method,action:f},f,$))},currentTarget:m}]})}}for(var Vm=0;Vm<kd.length;Vm++){var Hm=kd[Vm],Qw=Hm.toLowerCase(),Zw=Hm[0].toUpperCase()+Hm.slice(1);Es(Qw,"on"+Zw)}Es(Fp,"onAnimationEnd"),Es(Yp,"onAnimationIteration"),Es(Xp,"onAnimationStart"),Es("dblclick","onDoubleClick"),Es("focusin","onFocus"),Es("focusout","onBlur"),Es(uw,"onTransitionRun"),Es(dw,"onTransitionStart"),Es(mw,"onTransitionCancel"),Es(Jp,"onTransitionEnd"),Dt("onMouseEnter",["mouseout","mouseover"]),Dt("onMouseLeave",["mouseout","mouseover"]),Dt("onPointerEnter",["pointerout","pointerover"]),Dt("onPointerLeave",["pointerout","pointerover"]),at("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),at("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),at("onBeforeInput",["compositionend","keypress","textInput","paste"]),at("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),at("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),at("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ul="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Fw=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ul));function b0(n,a){a=(a&4)!==0;for(var l=0;l<n.length;l++){var c=n[l],m=c.event;c=c.listeners;e:{var f=void 0;if(a)for(var y=c.length-1;0<=y;y--){var S=c[y],$=S.instance,Q=S.currentTarget;if(S=S.listener,$!==f&&m.isPropagationStopped())break e;f=S,m.currentTarget=Q;try{f(m)}catch(re){Mo(re)}m.currentTarget=null,f=$}else for(y=0;y<c.length;y++){if(S=c[y],$=S.instance,Q=S.currentTarget,S=S.listener,$!==f&&m.isPropagationStopped())break e;f=S,m.currentTarget=Q;try{f(m)}catch(re){Mo(re)}m.currentTarget=null,f=$}}}}function lt(n,a){var l=a[va];l===void 0&&(l=a[va]=new Set);var c=n+"__bubble";l.has(c)||(v0(a,n,2,!1),l.add(c))}function Km(n,a,l){var c=0;a&&(c|=4),v0(l,n,c,a)}var Nc="_reactListening"+Math.random().toString(36).slice(2);function Qm(n){if(!n[Nc]){n[Nc]=!0,ge.forEach(function(l){l!=="selectionchange"&&(Fw.has(l)||Km(l,!1,n),Km(l,!0,n))});var a=n.nodeType===9?n:n.ownerDocument;a===null||a[Nc]||(a[Nc]=!0,Km("selectionchange",!1,a))}}function v0(n,a,l,c){switch(F0(a)){case 2:var m=wS;break;case 8:m=SS;break;default:m=oh}l=m.bind(null,a,l,n),m=void 0,!hd||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(m=!0),c?m!==void 0?n.addEventListener(a,l,{capture:!0,passive:m}):n.addEventListener(a,l,!0):m!==void 0?n.addEventListener(a,l,{passive:m}):n.addEventListener(a,l,!1)}function Zm(n,a,l,c,m){var f=c;if((a&1)===0&&(a&2)===0&&c!==null)e:for(;;){if(c===null)return;var y=c.tag;if(y===3||y===4){var S=c.stateNode.containerInfo;if(S===m)break;if(y===4)for(y=c.return;y!==null;){var $=y.tag;if(($===3||$===4)&&y.stateNode.containerInfo===m)return;y=y.return}for(;S!==null;){if(y=Na(S),y===null)return;if($=y.tag,$===5||$===6||$===26||$===27){c=f=y;continue e}S=S.parentNode}}c=c.return}zp(function(){var Q=f,re=dd(l),de=[];e:{var Z=Wp.get(n);if(Z!==void 0){var W=Oo,Te=n;switch(n){case"keypress":if(Eo(l)===0)break e;case"keydown":case"keyup":W=P1;break;case"focusin":Te="focus",W=xd;break;case"focusout":Te="blur",W=xd;break;case"beforeblur":case"afterblur":W=xd;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":W=Ap;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":W=_1;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":W=H1;break;case Fp:case Yp:case Xp:W=O1;break;case Jp:W=Q1;break;case"scroll":case"scrollend":W=A1;break;case"wheel":W=F1;break;case"copy":case"cut":case"paste":W=L1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":W=_p;break;case"toggle":case"beforetoggle":W=X1}var Ve=(a&4)!==0,Tt=!Ve&&(n==="scroll"||n==="scrollend"),H=Ve?Z!==null?Z+"Capture":null:Z;Ve=[];for(var q=Q,K;q!==null;){var ce=q;if(K=ce.stateNode,ce=ce.tag,ce!==5&&ce!==26&&ce!==27||K===null||H===null||(ce=cl(q,H),ce!=null&&Ve.push(Pl(q,ce,K))),Tt)break;q=q.return}0<Ve.length&&(Z=new W(Z,Te,null,l,re),de.push({event:Z,listeners:Ve}))}}if((a&7)===0){e:{if(Z=n==="mouseover"||n==="pointerover",W=n==="mouseout"||n==="pointerout",Z&&l!==ud&&(Te=l.relatedTarget||l.fromElement)&&(Na(Te)||Te[ba]))break e;if((W||Z)&&(Z=re.window===re?re:(Z=re.ownerDocument)?Z.defaultView||Z.parentWindow:window,W?(Te=l.relatedTarget||l.toElement,W=Q,Te=Te?Na(Te):null,Te!==null&&(Tt=u(Te),Ve=Te.tag,Te!==Tt||Ve!==5&&Ve!==27&&Ve!==6)&&(Te=null)):(W=null,Te=Q),W!==Te)){if(Ve=Ap,ce="onMouseLeave",H="onMouseEnter",q="mouse",(n==="pointerout"||n==="pointerover")&&(Ve=_p,ce="onPointerLeave",H="onPointerEnter",q="pointer"),Tt=W==null?Z:di(W),K=Te==null?Z:di(Te),Z=new Ve(ce,q+"leave",W,l,re),Z.target=Tt,Z.relatedTarget=K,ce=null,Na(re)===Q&&(Ve=new Ve(H,q+"enter",Te,l,re),Ve.target=K,Ve.relatedTarget=Tt,ce=Ve),Tt=ce,W&&Te)t:{for(Ve=Yw,H=W,q=Te,K=0,ce=H;ce;ce=Ve(ce))K++;ce=0;for(var Ie=q;Ie;Ie=Ve(Ie))ce++;for(;0<K-ce;)H=Ve(H),K--;for(;0<ce-K;)q=Ve(q),ce--;for(;K--;){if(H===q||q!==null&&H===q.alternate){Ve=H;break t}H=Ve(H),q=Ve(q)}Ve=null}else Ve=null;W!==null&&j0(de,Z,W,Ve,!1),Te!==null&&Tt!==null&&j0(de,Tt,Te,Ve,!0)}}e:{if(Z=Q?di(Q):window,W=Z.nodeName&&Z.nodeName.toLowerCase(),W==="select"||W==="input"&&Z.type==="file")var yt=Bp;else if(Mp(Z))if(qp)yt=lw;else{yt=iw;var Oe=aw}else W=Z.nodeName,!W||W.toLowerCase()!=="input"||Z.type!=="checkbox"&&Z.type!=="radio"?Q&&cd(Q.elementType)&&(yt=Bp):yt=rw;if(yt&&(yt=yt(n,Q))){$p(de,yt,l,re);break e}Oe&&Oe(n,Z,Q),n==="focusout"&&Q&&Z.type==="number"&&Q.memoizedProps.value!=null&&os(Z,"number",Z.value)}switch(Oe=Q?di(Q):window,n){case"focusin":(Mp(Oe)||Oe.contentEditable==="true")&&(Ji=Oe,wd=Q,xl=null);break;case"focusout":xl=wd=Ji=null;break;case"mousedown":Sd=!0;break;case"contextmenu":case"mouseup":case"dragend":Sd=!1,Qp(de,l,re);break;case"selectionchange":if(cw)break;case"keydown":case"keyup":Qp(de,l,re)}var Je;if(bd)e:{switch(n){case"compositionstart":var ct="onCompositionStart";break e;case"compositionend":ct="onCompositionEnd";break e;case"compositionupdate":ct="onCompositionUpdate";break e}ct=void 0}else Xi?Rp(n,l)&&(ct="onCompositionEnd"):n==="keydown"&&l.keyCode===229&&(ct="onCompositionStart");ct&&(Ep&&l.locale!=="ko"&&(Xi||ct!=="onCompositionStart"?ct==="onCompositionEnd"&&Xi&&(Je=kp()):(za=re,fd="value"in za?za.value:za.textContent,Xi=!0)),Oe=wc(Q,ct),0<Oe.length&&(ct=new Tp(ct,n,null,l,re),de.push({event:ct,listeners:Oe}),Je?ct.data=Je:(Je=Lp(l),Je!==null&&(ct.data=Je)))),(Je=W1?ew(n,l):tw(n,l))&&(ct=wc(Q,"onBeforeInput"),0<ct.length&&(Oe=new Tp("onBeforeInput","beforeinput",null,l,re),de.push({event:Oe,listeners:ct}),Oe.data=Je)),Kw(de,n,Q,l,re)}b0(de,a)})}function Pl(n,a,l){return{instance:n,listener:a,currentTarget:l}}function wc(n,a){for(var l=a+"Capture",c=[];n!==null;){var m=n,f=m.stateNode;if(m=m.tag,m!==5&&m!==26&&m!==27||f===null||(m=cl(n,l),m!=null&&c.unshift(Pl(n,m,f)),m=cl(n,a),m!=null&&c.push(Pl(n,m,f))),n.tag===3)return c;n=n.return}return[]}function Yw(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5&&n.tag!==27);return n||null}function j0(n,a,l,c,m){for(var f=a._reactName,y=[];l!==null&&l!==c;){var S=l,$=S.alternate,Q=S.stateNode;if(S=S.tag,$!==null&&$===c)break;S!==5&&S!==26&&S!==27||Q===null||($=Q,m?(Q=cl(l,f),Q!=null&&y.unshift(Pl(l,Q,$))):m||(Q=cl(l,f),Q!=null&&y.push(Pl(l,Q,$)))),l=l.return}y.length!==0&&n.push({event:a,listeners:y})}var Xw=/\r\n?/g,Jw=/\u0000|\uFFFD/g;function N0(n){return(typeof n=="string"?n:""+n).replace(Xw,`
9
- `).replace(Jw,"")}function w0(n,a){return a=N0(a),N0(n)===a}function At(n,a,l,c,m,f){switch(l){case"children":typeof c=="string"?a==="body"||a==="textarea"&&c===""||Zi(n,c):(typeof c=="number"||typeof c=="bigint")&&a!=="body"&&Zi(n,""+c);break;case"className":Ts(n,"class",c);break;case"tabIndex":Ts(n,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":Ts(n,l,c);break;case"style":wp(n,c,f);break;case"data":if(a!=="object"){Ts(n,"data",c);break}case"src":case"href":if(c===""&&(a!=="a"||l!=="href")){n.removeAttribute(l);break}if(c==null||typeof c=="function"||typeof c=="symbol"||typeof c=="boolean"){n.removeAttribute(l);break}c=To(""+c),n.setAttribute(l,c);break;case"action":case"formAction":if(typeof c=="function"){n.setAttribute(l,"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}else typeof f=="function"&&(l==="formAction"?(a!=="input"&&At(n,a,"name",m.name,m,null),At(n,a,"formEncType",m.formEncType,m,null),At(n,a,"formMethod",m.formMethod,m,null),At(n,a,"formTarget",m.formTarget,m,null)):(At(n,a,"encType",m.encType,m,null),At(n,a,"method",m.method,m,null),At(n,a,"target",m.target,m,null)));if(c==null||typeof c=="symbol"||typeof c=="boolean"){n.removeAttribute(l);break}c=To(""+c),n.setAttribute(l,c);break;case"onClick":c!=null&&(n.onclick=Xs);break;case"onScroll":c!=null&&lt("scroll",n);break;case"onScrollEnd":c!=null&&lt("scrollend",n);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(r(61));if(l=c.__html,l!=null){if(m.children!=null)throw Error(r(60));n.innerHTML=l}}break;case"multiple":n.multiple=c&&typeof c!="function"&&typeof c!="symbol";break;case"muted":n.muted=c&&typeof c!="function"&&typeof c!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(c==null||typeof c=="function"||typeof c=="boolean"||typeof c=="symbol"){n.removeAttribute("xlink:href");break}l=To(""+c),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":c!=null&&typeof c!="function"&&typeof c!="symbol"?n.setAttribute(l,""+c):n.removeAttribute(l);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":c&&typeof c!="function"&&typeof c!="symbol"?n.setAttribute(l,""):n.removeAttribute(l);break;case"capture":case"download":c===!0?n.setAttribute(l,""):c!==!1&&c!=null&&typeof c!="function"&&typeof c!="symbol"?n.setAttribute(l,c):n.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":c!=null&&typeof c!="function"&&typeof c!="symbol"&&!isNaN(c)&&1<=c?n.setAttribute(l,c):n.removeAttribute(l);break;case"rowSpan":case"start":c==null||typeof c=="function"||typeof c=="symbol"||isNaN(c)?n.removeAttribute(l):n.setAttribute(l,c);break;case"popover":lt("beforetoggle",n),lt("toggle",n),Ki(n,"popover",c);break;case"xlinkActuate":En(n,"http://www.w3.org/1999/xlink","xlink:actuate",c);break;case"xlinkArcrole":En(n,"http://www.w3.org/1999/xlink","xlink:arcrole",c);break;case"xlinkRole":En(n,"http://www.w3.org/1999/xlink","xlink:role",c);break;case"xlinkShow":En(n,"http://www.w3.org/1999/xlink","xlink:show",c);break;case"xlinkTitle":En(n,"http://www.w3.org/1999/xlink","xlink:title",c);break;case"xlinkType":En(n,"http://www.w3.org/1999/xlink","xlink:type",c);break;case"xmlBase":En(n,"http://www.w3.org/XML/1998/namespace","xml:base",c);break;case"xmlLang":En(n,"http://www.w3.org/XML/1998/namespace","xml:lang",c);break;case"xmlSpace":En(n,"http://www.w3.org/XML/1998/namespace","xml:space",c);break;case"is":Ki(n,"is",c);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=k1.get(l)||l,Ki(n,l,c))}}function Fm(n,a,l,c,m,f){switch(l){case"style":wp(n,c,f);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(r(61));if(l=c.__html,l!=null){if(m.children!=null)throw Error(r(60));n.innerHTML=l}}break;case"children":typeof c=="string"?Zi(n,c):(typeof c=="number"||typeof c=="bigint")&&Zi(n,""+c);break;case"onScroll":c!=null&&lt("scroll",n);break;case"onScrollEnd":c!=null&&lt("scrollend",n);break;case"onClick":c!=null&&(n.onclick=Xs);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Fe.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(m=l.endsWith("Capture"),a=l.slice(2,m?l.length-7:void 0),f=n[hn]||null,f=f!=null?f[l]:null,typeof f=="function"&&n.removeEventListener(a,f,m),typeof c=="function")){typeof f!="function"&&f!==null&&(l in n?n[l]=null:n.hasAttribute(l)&&n.removeAttribute(l)),n.addEventListener(a,c,m);break e}l in n?n[l]=c:c===!0?n.setAttribute(l,""):Ki(n,l,c)}}}function yn(n,a,l){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":lt("error",n),lt("load",n);var c=!1,m=!1,f;for(f in l)if(l.hasOwnProperty(f)){var y=l[f];if(y!=null)switch(f){case"src":c=!0;break;case"srcSet":m=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,a));default:At(n,a,f,y,l,null)}}m&&At(n,a,"srcSet",l.srcSet,l,null),c&&At(n,a,"src",l.src,l,null);return;case"input":lt("invalid",n);var S=f=y=m=null,$=null,Q=null;for(c in l)if(l.hasOwnProperty(c)){var re=l[c];if(re!=null)switch(c){case"name":m=re;break;case"type":y=re;break;case"checked":$=re;break;case"defaultChecked":Q=re;break;case"value":f=re;break;case"defaultValue":S=re;break;case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(r(137,a));break;default:At(n,a,c,re,l,null)}}Dn(n,f,S,$,Q,y,m,!1);return;case"select":lt("invalid",n),c=y=f=null;for(m in l)if(l.hasOwnProperty(m)&&(S=l[m],S!=null))switch(m){case"value":f=S;break;case"defaultValue":y=S;break;case"multiple":c=S;default:At(n,a,m,S,l,null)}a=f,l=y,n.multiple=!!c,a!=null?_s(n,!!c,a,!1):l!=null&&_s(n,!!c,l,!0);return;case"textarea":lt("invalid",n),f=m=c=null;for(y in l)if(l.hasOwnProperty(y)&&(S=l[y],S!=null))switch(y){case"value":c=S;break;case"defaultValue":m=S;break;case"children":f=S;break;case"dangerouslySetInnerHTML":if(S!=null)throw Error(r(91));break;default:At(n,a,y,S,l,null)}jp(n,c,m,f);return;case"option":for($ in l)l.hasOwnProperty($)&&(c=l[$],c!=null)&&($==="selected"?n.selected=c&&typeof c!="function"&&typeof c!="symbol":At(n,a,$,c,l,null));return;case"dialog":lt("beforetoggle",n),lt("toggle",n),lt("cancel",n),lt("close",n);break;case"iframe":case"object":lt("load",n);break;case"video":case"audio":for(c=0;c<Ul.length;c++)lt(Ul[c],n);break;case"image":lt("error",n),lt("load",n);break;case"details":lt("toggle",n);break;case"embed":case"source":case"link":lt("error",n),lt("load",n);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Q in l)if(l.hasOwnProperty(Q)&&(c=l[Q],c!=null))switch(Q){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,a));default:At(n,a,Q,c,l,null)}return;default:if(cd(a)){for(re in l)l.hasOwnProperty(re)&&(c=l[re],c!==void 0&&Fm(n,a,re,c,l,void 0));return}}for(S in l)l.hasOwnProperty(S)&&(c=l[S],c!=null&&At(n,a,S,c,l,null))}function Ww(n,a,l,c){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var m=null,f=null,y=null,S=null,$=null,Q=null,re=null;for(W in l){var de=l[W];if(l.hasOwnProperty(W)&&de!=null)switch(W){case"checked":break;case"value":break;case"defaultValue":$=de;default:c.hasOwnProperty(W)||At(n,a,W,null,c,de)}}for(var Z in c){var W=c[Z];if(de=l[Z],c.hasOwnProperty(Z)&&(W!=null||de!=null))switch(Z){case"type":f=W;break;case"name":m=W;break;case"checked":Q=W;break;case"defaultChecked":re=W;break;case"value":y=W;break;case"defaultValue":S=W;break;case"children":case"dangerouslySetInnerHTML":if(W!=null)throw Error(r(137,a));break;default:W!==de&&At(n,a,Z,W,c,de)}}Jn(n,y,S,$,Q,re,f,m);return;case"select":W=y=S=Z=null;for(f in l)if($=l[f],l.hasOwnProperty(f)&&$!=null)switch(f){case"value":break;case"multiple":W=$;default:c.hasOwnProperty(f)||At(n,a,f,null,c,$)}for(m in c)if(f=c[m],$=l[m],c.hasOwnProperty(m)&&(f!=null||$!=null))switch(m){case"value":Z=f;break;case"defaultValue":S=f;break;case"multiple":y=f;default:f!==$&&At(n,a,m,f,c,$)}a=S,l=y,c=W,Z!=null?_s(n,!!l,Z,!1):!!c!=!!l&&(a!=null?_s(n,!!l,a,!0):_s(n,!!l,l?[]:"",!1));return;case"textarea":W=Z=null;for(S in l)if(m=l[S],l.hasOwnProperty(S)&&m!=null&&!c.hasOwnProperty(S))switch(S){case"value":break;case"children":break;default:At(n,a,S,null,c,m)}for(y in c)if(m=c[y],f=l[y],c.hasOwnProperty(y)&&(m!=null||f!=null))switch(y){case"value":Z=m;break;case"defaultValue":W=m;break;case"children":break;case"dangerouslySetInnerHTML":if(m!=null)throw Error(r(91));break;default:m!==f&&At(n,a,y,m,c,f)}vp(n,Z,W);return;case"option":for(var Te in l)Z=l[Te],l.hasOwnProperty(Te)&&Z!=null&&!c.hasOwnProperty(Te)&&(Te==="selected"?n.selected=!1:At(n,a,Te,null,c,Z));for($ in c)Z=c[$],W=l[$],c.hasOwnProperty($)&&Z!==W&&(Z!=null||W!=null)&&($==="selected"?n.selected=Z&&typeof Z!="function"&&typeof Z!="symbol":At(n,a,$,Z,c,W));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 Ve in l)Z=l[Ve],l.hasOwnProperty(Ve)&&Z!=null&&!c.hasOwnProperty(Ve)&&At(n,a,Ve,null,c,Z);for(Q in c)if(Z=c[Q],W=l[Q],c.hasOwnProperty(Q)&&Z!==W&&(Z!=null||W!=null))switch(Q){case"children":case"dangerouslySetInnerHTML":if(Z!=null)throw Error(r(137,a));break;default:At(n,a,Q,Z,c,W)}return;default:if(cd(a)){for(var Tt in l)Z=l[Tt],l.hasOwnProperty(Tt)&&Z!==void 0&&!c.hasOwnProperty(Tt)&&Fm(n,a,Tt,void 0,c,Z);for(re in c)Z=c[re],W=l[re],!c.hasOwnProperty(re)||Z===W||Z===void 0&&W===void 0||Fm(n,a,re,Z,c,W);return}}for(var H in l)Z=l[H],l.hasOwnProperty(H)&&Z!=null&&!c.hasOwnProperty(H)&&At(n,a,H,null,c,Z);for(de in c)Z=c[de],W=l[de],!c.hasOwnProperty(de)||Z===W||Z==null&&W==null||At(n,a,de,Z,c,W)}function S0(n){switch(n){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function eS(){if(typeof performance.getEntriesByType=="function"){for(var n=0,a=0,l=performance.getEntriesByType("resource"),c=0;c<l.length;c++){var m=l[c],f=m.transferSize,y=m.initiatorType,S=m.duration;if(f&&S&&S0(y)){for(y=0,S=m.responseEnd,c+=1;c<l.length;c++){var $=l[c],Q=$.startTime;if(Q>S)break;var re=$.transferSize,de=$.initiatorType;re&&S0(de)&&($=$.responseEnd,y+=re*($<S?1:(S-Q)/($-Q)))}if(--c,a+=8*(f+y)/(m.duration/1e3),n++,10<n)break}}if(0<n)return a/n/1e6}return navigator.connection&&(n=navigator.connection.downlink,typeof n=="number")?n:5}var Ym=null,Xm=null;function Sc(n){return n.nodeType===9?n:n.ownerDocument}function z0(n){switch(n){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function k0(n,a){if(n===0)switch(a){case"svg":return 1;case"math":return 2;default:return 0}return n===1&&a==="foreignObject"?0:n}function Jm(n,a){return n==="textarea"||n==="noscript"||typeof a.children=="string"||typeof a.children=="number"||typeof a.children=="bigint"||typeof a.dangerouslySetInnerHTML=="object"&&a.dangerouslySetInnerHTML!==null&&a.dangerouslySetInnerHTML.__html!=null}var Wm=null;function tS(){var n=window.event;return n&&n.type==="popstate"?n===Wm?!1:(Wm=n,!0):(Wm=null,!1)}var C0=typeof setTimeout=="function"?setTimeout:void 0,nS=typeof clearTimeout=="function"?clearTimeout:void 0,A0=typeof Promise=="function"?Promise:void 0,sS=typeof queueMicrotask=="function"?queueMicrotask:typeof A0<"u"?function(n){return A0.resolve(null).then(n).catch(aS)}:C0;function aS(n){setTimeout(function(){throw n})}function Pa(n){return n==="head"}function T0(n,a){var l=a,c=0;do{var m=l.nextSibling;if(n.removeChild(l),m&&m.nodeType===8)if(l=m.data,l==="/$"||l==="/&"){if(c===0){n.removeChild(m),zr(a);return}c--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")c++;else if(l==="html")Gl(n.ownerDocument.documentElement);else if(l==="head"){l=n.ownerDocument.head,Gl(l);for(var f=l.firstChild;f;){var y=f.nextSibling,S=f.nodeName;f[ja]||S==="SCRIPT"||S==="STYLE"||S==="LINK"&&f.rel.toLowerCase()==="stylesheet"||l.removeChild(f),f=y}}else l==="body"&&Gl(n.ownerDocument.body);l=m}while(l);zr(a)}function _0(n,a){var l=n;n=0;do{var c=l.nextSibling;if(l.nodeType===1?a?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",l.getAttribute("style")===""&&l.removeAttribute("style")):l.nodeType===3&&(a?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),c&&c.nodeType===8)if(l=c.data,l==="/$"){if(n===0)break;n--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||n++;l=c}while(l)}function eh(n){var a=n.firstChild;for(a&&a.nodeType===10&&(a=a.nextSibling);a;){var l=a;switch(a=a.nextSibling,l.nodeName){case"HTML":case"HEAD":case"BODY":eh(l),ll(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}n.removeChild(l)}}function iS(n,a,l,c){for(;n.nodeType===1;){var m=l;if(n.nodeName.toLowerCase()!==a.toLowerCase()){if(!c&&(n.nodeName!=="INPUT"||n.type!=="hidden"))break}else if(c){if(!n[ja])switch(a){case"meta":if(!n.hasAttribute("itemprop"))break;return n;case"link":if(f=n.getAttribute("rel"),f==="stylesheet"&&n.hasAttribute("data-precedence"))break;if(f!==m.rel||n.getAttribute("href")!==(m.href==null||m.href===""?null:m.href)||n.getAttribute("crossorigin")!==(m.crossOrigin==null?null:m.crossOrigin)||n.getAttribute("title")!==(m.title==null?null:m.title))break;return n;case"style":if(n.hasAttribute("data-precedence"))break;return n;case"script":if(f=n.getAttribute("src"),(f!==(m.src==null?null:m.src)||n.getAttribute("type")!==(m.type==null?null:m.type)||n.getAttribute("crossorigin")!==(m.crossOrigin==null?null:m.crossOrigin))&&f&&n.hasAttribute("async")&&!n.hasAttribute("itemprop"))break;return n;default:return n}}else if(a==="input"&&n.type==="hidden"){var f=m.name==null?null:""+m.name;if(m.type==="hidden"&&n.getAttribute("name")===f)return n}else return n;if(n=ps(n.nextSibling),n===null)break}return null}function rS(n,a,l){if(a==="")return null;for(;n.nodeType!==3;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!l||(n=ps(n.nextSibling),n===null))return null;return n}function E0(n,a){for(;n.nodeType!==8;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!a||(n=ps(n.nextSibling),n===null))return null;return n}function th(n){return n.data==="$?"||n.data==="$~"}function nh(n){return n.data==="$!"||n.data==="$?"&&n.ownerDocument.readyState!=="loading"}function lS(n,a){var l=n.ownerDocument;if(n.data==="$~")n._reactRetry=a;else if(n.data!=="$?"||l.readyState!=="loading")a();else{var c=function(){a(),l.removeEventListener("DOMContentLoaded",c)};l.addEventListener("DOMContentLoaded",c),n._reactRetry=c}}function ps(n){for(;n!=null;n=n.nextSibling){var a=n.nodeType;if(a===1||a===3)break;if(a===8){if(a=n.data,a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"||a==="F!"||a==="F")break;if(a==="/$"||a==="/&")return null}}return n}var sh=null;function D0(n){n=n.nextSibling;for(var a=0;n;){if(n.nodeType===8){var l=n.data;if(l==="/$"||l==="/&"){if(a===0)return ps(n.nextSibling);a--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||a++}n=n.nextSibling}return null}function O0(n){n=n.previousSibling;for(var a=0;n;){if(n.nodeType===8){var l=n.data;if(l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"){if(a===0)return n;a--}else l!=="/$"&&l!=="/&"||a++}n=n.previousSibling}return null}function R0(n,a,l){switch(a=Sc(l),n){case"html":if(n=a.documentElement,!n)throw Error(r(452));return n;case"head":if(n=a.head,!n)throw Error(r(453));return n;case"body":if(n=a.body,!n)throw Error(r(454));return n;default:throw Error(r(451))}}function Gl(n){for(var a=n.attributes;a.length;)n.removeAttributeNode(a[0]);ll(n)}var gs=new Map,L0=new Set;function zc(n){return typeof n.getRootNode=="function"?n.getRootNode():n.nodeType===9?n:n.ownerDocument}var ha=ne.d;ne.d={f:oS,r:cS,D:uS,C:dS,L:mS,m:hS,X:pS,S:fS,M:gS};function oS(){var n=ha.f(),a=gc();return n||a}function cS(n){var a=wa(n);a!==null&&a.tag===5&&a.type==="form"?Jg(a):ha.r(n)}var Nr=typeof document>"u"?null:document;function M0(n,a,l){var c=Nr;if(c&&typeof a=="string"&&a){var m=it(a);m='link[rel="'+n+'"][href="'+m+'"]',typeof l=="string"&&(m+='[crossorigin="'+l+'"]'),L0.has(m)||(L0.add(m),n={rel:n,crossOrigin:l,href:a},c.querySelector(m)===null&&(a=c.createElement("link"),yn(a,"link",n),O(a),c.head.appendChild(a)))}}function uS(n){ha.D(n),M0("dns-prefetch",n,null)}function dS(n,a){ha.C(n,a),M0("preconnect",n,a)}function mS(n,a,l){ha.L(n,a,l);var c=Nr;if(c&&n&&a){var m='link[rel="preload"][as="'+it(a)+'"]';a==="image"&&l&&l.imageSrcSet?(m+='[imagesrcset="'+it(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(m+='[imagesizes="'+it(l.imageSizes)+'"]')):m+='[href="'+it(n)+'"]';var f=m;switch(a){case"style":f=wr(n);break;case"script":f=Sr(n)}gs.has(f)||(n=v({rel:"preload",href:a==="image"&&l&&l.imageSrcSet?void 0:n,as:a},l),gs.set(f,n),c.querySelector(m)!==null||a==="style"&&c.querySelector(Vl(f))||a==="script"&&c.querySelector(Hl(f))||(a=c.createElement("link"),yn(a,"link",n),O(a),c.head.appendChild(a)))}}function hS(n,a){ha.m(n,a);var l=Nr;if(l&&n){var c=a&&typeof a.as=="string"?a.as:"script",m='link[rel="modulepreload"][as="'+it(c)+'"][href="'+it(n)+'"]',f=m;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":f=Sr(n)}if(!gs.has(f)&&(n=v({rel:"modulepreload",href:n},a),gs.set(f,n),l.querySelector(m)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Hl(f)))return}c=l.createElement("link"),yn(c,"link",n),O(c),l.head.appendChild(c)}}}function fS(n,a,l){ha.S(n,a,l);var c=Nr;if(c&&n){var m=Fs(c).hoistableStyles,f=wr(n);a=a||"default";var y=m.get(f);if(!y){var S={loading:0,preload:null};if(y=c.querySelector(Vl(f)))S.loading=5;else{n=v({rel:"stylesheet",href:n,"data-precedence":a},l),(l=gs.get(f))&&ah(n,l);var $=y=c.createElement("link");O($),yn($,"link",n),$._p=new Promise(function(Q,re){$.onload=Q,$.onerror=re}),$.addEventListener("load",function(){S.loading|=1}),$.addEventListener("error",function(){S.loading|=2}),S.loading|=4,kc(y,a,c)}y={type:"stylesheet",instance:y,count:1,state:S},m.set(f,y)}}}function pS(n,a){ha.X(n,a);var l=Nr;if(l&&n){var c=Fs(l).hoistableScripts,m=Sr(n),f=c.get(m);f||(f=l.querySelector(Hl(m)),f||(n=v({src:n,async:!0},a),(a=gs.get(m))&&ih(n,a),f=l.createElement("script"),O(f),yn(f,"link",n),l.head.appendChild(f)),f={type:"script",instance:f,count:1,state:null},c.set(m,f))}}function gS(n,a){ha.M(n,a);var l=Nr;if(l&&n){var c=Fs(l).hoistableScripts,m=Sr(n),f=c.get(m);f||(f=l.querySelector(Hl(m)),f||(n=v({src:n,async:!0,type:"module"},a),(a=gs.get(m))&&ih(n,a),f=l.createElement("script"),O(f),yn(f,"link",n),l.head.appendChild(f)),f={type:"script",instance:f,count:1,state:null},c.set(m,f))}}function $0(n,a,l,c){var m=(m=le.current)?zc(m):null;if(!m)throw Error(r(446));switch(n){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(a=wr(l.href),l=Fs(m).hoistableStyles,c=l.get(a),c||(c={type:"style",instance:null,count:0,state:null},l.set(a,c)),c):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){n=wr(l.href);var f=Fs(m).hoistableStyles,y=f.get(n);if(y||(m=m.ownerDocument||m,y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},f.set(n,y),(f=m.querySelector(Vl(n)))&&!f._p&&(y.instance=f,y.state.loading=5),gs.has(n)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},gs.set(n,l),f||xS(m,n,l,y.state))),a&&c===null)throw Error(r(528,""));return y}if(a&&c!==null)throw Error(r(529,""));return null;case"script":return a=l.async,l=l.src,typeof l=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=Sr(l),l=Fs(m).hoistableScripts,c=l.get(a),c||(c={type:"script",instance:null,count:0,state:null},l.set(a,c)),c):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,n))}}function wr(n){return'href="'+it(n)+'"'}function Vl(n){return'link[rel="stylesheet"]['+n+"]"}function B0(n){return v({},n,{"data-precedence":n.precedence,precedence:null})}function xS(n,a,l,c){n.querySelector('link[rel="preload"][as="style"]['+a+"]")?c.loading=1:(a=n.createElement("link"),c.preload=a,a.addEventListener("load",function(){return c.loading|=1}),a.addEventListener("error",function(){return c.loading|=2}),yn(a,"link",l),O(a),n.head.appendChild(a))}function Sr(n){return'[src="'+it(n)+'"]'}function Hl(n){return"script[async]"+n}function q0(n,a,l){if(a.count++,a.instance===null)switch(a.type){case"style":var c=n.querySelector('style[data-href~="'+it(l.href)+'"]');if(c)return a.instance=c,O(c),c;var m=v({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return c=(n.ownerDocument||n).createElement("style"),O(c),yn(c,"style",m),kc(c,l.precedence,n),a.instance=c;case"stylesheet":m=wr(l.href);var f=n.querySelector(Vl(m));if(f)return a.state.loading|=4,a.instance=f,O(f),f;c=B0(l),(m=gs.get(m))&&ah(c,m),f=(n.ownerDocument||n).createElement("link"),O(f);var y=f;return y._p=new Promise(function(S,$){y.onload=S,y.onerror=$}),yn(f,"link",c),a.state.loading|=4,kc(f,l.precedence,n),a.instance=f;case"script":return f=Sr(l.src),(m=n.querySelector(Hl(f)))?(a.instance=m,O(m),m):(c=l,(m=gs.get(f))&&(c=v({},l),ih(c,m)),n=n.ownerDocument||n,m=n.createElement("script"),O(m),yn(m,"link",c),n.head.appendChild(m),a.instance=m);case"void":return null;default:throw Error(r(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(c=a.instance,a.state.loading|=4,kc(c,l.precedence,n));return a.instance}function kc(n,a,l){for(var c=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=c.length?c[c.length-1]:null,f=m,y=0;y<c.length;y++){var S=c[y];if(S.dataset.precedence===a)f=S;else if(f!==m)break}f?f.parentNode.insertBefore(n,f.nextSibling):(a=l.nodeType===9?l.head:l,a.insertBefore(n,a.firstChild))}function ah(n,a){n.crossOrigin==null&&(n.crossOrigin=a.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=a.referrerPolicy),n.title==null&&(n.title=a.title)}function ih(n,a){n.crossOrigin==null&&(n.crossOrigin=a.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=a.referrerPolicy),n.integrity==null&&(n.integrity=a.integrity)}var Cc=null;function I0(n,a,l){if(Cc===null){var c=new Map,m=Cc=new Map;m.set(l,c)}else m=Cc,c=m.get(l),c||(c=new Map,m.set(l,c));if(c.has(n))return c;for(c.set(n,null),l=l.getElementsByTagName(n),m=0;m<l.length;m++){var f=l[m];if(!(f[ja]||f[Yt]||n==="link"&&f.getAttribute("rel")==="stylesheet")&&f.namespaceURI!=="http://www.w3.org/2000/svg"){var y=f.getAttribute(a)||"";y=n+y;var S=c.get(y);S?S.push(f):c.set(y,[f])}}return c}function U0(n,a,l){n=n.ownerDocument||n,n.head.insertBefore(l,a==="title"?n.querySelector("head > title"):null)}function yS(n,a,l){if(l===1||a.itemProp!=null)return!1;switch(n){case"meta":case"title":return!0;case"style":if(typeof a.precedence!="string"||typeof a.href!="string"||a.href==="")break;return!0;case"link":if(typeof a.rel!="string"||typeof a.href!="string"||a.href===""||a.onLoad||a.onError)break;return a.rel==="stylesheet"?(n=a.disabled,typeof a.precedence=="string"&&n==null):!0;case"script":if(a.async&&typeof a.async!="function"&&typeof a.async!="symbol"&&!a.onLoad&&!a.onError&&a.src&&typeof a.src=="string")return!0}return!1}function P0(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function bS(n,a,l,c){if(l.type==="stylesheet"&&(typeof c.media!="string"||matchMedia(c.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var m=wr(c.href),f=a.querySelector(Vl(m));if(f){a=f._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(n.count++,n=Ac.bind(n),a.then(n,n)),l.state.loading|=4,l.instance=f,O(f);return}f=a.ownerDocument||a,c=B0(c),(m=gs.get(m))&&ah(c,m),f=f.createElement("link"),O(f);var y=f;y._p=new Promise(function(S,$){y.onload=S,y.onerror=$}),yn(f,"link",c),l.instance=f}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(l,a),(a=l.state.preload)&&(l.state.loading&3)===0&&(n.count++,l=Ac.bind(n),a.addEventListener("load",l),a.addEventListener("error",l))}}var rh=0;function vS(n,a){return n.stylesheets&&n.count===0&&_c(n,n.stylesheets),0<n.count||0<n.imgCount?function(l){var c=setTimeout(function(){if(n.stylesheets&&_c(n,n.stylesheets),n.unsuspend){var f=n.unsuspend;n.unsuspend=null,f()}},6e4+a);0<n.imgBytes&&rh===0&&(rh=62500*eS());var m=setTimeout(function(){if(n.waitingForImages=!1,n.count===0&&(n.stylesheets&&_c(n,n.stylesheets),n.unsuspend)){var f=n.unsuspend;n.unsuspend=null,f()}},(n.imgBytes>rh?50:800)+a);return n.unsuspend=l,function(){n.unsuspend=null,clearTimeout(c),clearTimeout(m)}}:null}function Ac(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)_c(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var Tc=null;function _c(n,a){n.stylesheets=null,n.unsuspend!==null&&(n.count++,Tc=new Map,a.forEach(jS,n),Tc=null,Ac.call(n))}function jS(n,a){if(!(a.state.loading&4)){var l=Tc.get(n);if(l)var c=l.get(null);else{l=new Map,Tc.set(n,l);for(var m=n.querySelectorAll("link[data-precedence],style[data-precedence]"),f=0;f<m.length;f++){var y=m[f];(y.nodeName==="LINK"||y.getAttribute("media")!=="not all")&&(l.set(y.dataset.precedence,y),c=y)}c&&l.set(null,c)}m=a.instance,y=m.getAttribute("data-precedence"),f=l.get(y)||c,f===c&&l.set(null,m),l.set(y,m),this.count++,c=Ac.bind(this),m.addEventListener("load",c),m.addEventListener("error",c),f?f.parentNode.insertBefore(m,f.nextSibling):(n=n.nodeType===9?n.head:n,n.insertBefore(m,n.firstChild)),a.state.loading|=4}}var Kl={$$typeof:I,Provider:null,Consumer:null,_currentValue:me,_currentValue2:me,_threadCount:0};function NS(n,a,l,c,m,f,y,S,$){this.tag=1,this.containerInfo=n,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=fe(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=fe(0),this.hiddenUpdates=fe(null),this.identifierPrefix=c,this.onUncaughtError=m,this.onCaughtError=f,this.onRecoverableError=y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=$,this.incompleteTransitions=new Map}function G0(n,a,l,c,m,f,y,S,$,Q,re,de){return n=new NS(n,a,l,y,$,Q,re,de,S),a=1,f===!0&&(a|=24),f=es(3,null,null,a),n.current=f,f.stateNode=n,a=qd(),a.refCount++,n.pooledCache=a,a.refCount++,f.memoizedState={element:c,isDehydrated:l,cache:a},Gd(f),n}function V0(n){return n?(n=tr,n):tr}function H0(n,a,l,c,m,f){m=V0(m),c.context===null?c.context=m:c.pendingContext=m,c=Ea(a),c.payload={element:l},f=f===void 0?null:f,f!==null&&(c.callback=f),l=Da(n,c,a),l!==null&&(Hn(l,n,a),Sl(l,n,a))}function K0(n,a){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var l=n.retryLane;n.retryLane=l!==0&&l<a?l:a}}function lh(n,a){K0(n,a),(n=n.alternate)&&K0(n,a)}function Q0(n){if(n.tag===13||n.tag===31){var a=gi(n,67108864);a!==null&&Hn(a,n,67108864),lh(n,67108864)}}function Z0(n){if(n.tag===13||n.tag===31){var a=is();a=Qs(a);var l=gi(n,a);l!==null&&Hn(l,n,a),lh(n,a)}}var Ec=!0;function wS(n,a,l,c){var m=V.T;V.T=null;var f=ne.p;try{ne.p=2,oh(n,a,l,c)}finally{ne.p=f,V.T=m}}function SS(n,a,l,c){var m=V.T;V.T=null;var f=ne.p;try{ne.p=8,oh(n,a,l,c)}finally{ne.p=f,V.T=m}}function oh(n,a,l,c){if(Ec){var m=ch(c);if(m===null)Zm(n,a,c,Dc,l),Y0(n,c);else if(kS(m,n,a,l,c))c.stopPropagation();else if(Y0(n,c),a&4&&-1<zS.indexOf(n)){for(;m!==null;){var f=wa(m);if(f!==null)switch(f.tag){case 3:if(f=f.stateNode,f.current.memoizedState.isDehydrated){var y=he(f.pendingLanes);if(y!==0){var S=f;for(S.pendingLanes|=2,S.entangledLanes|=2;y;){var $=1<<31-ut(y);S.entanglements[1]|=$,y&=~$}Ps(f),(jt&6)===0&&(fc=$t()+500,Il(0))}}break;case 31:case 13:S=gi(f,2),S!==null&&Hn(S,f,2),gc(),lh(f,2)}if(f=ch(c),f===null&&Zm(n,a,c,Dc,l),f===m)break;m=f}m!==null&&c.stopPropagation()}else Zm(n,a,c,null,l)}}function ch(n){return n=dd(n),uh(n)}var Dc=null;function uh(n){if(Dc=null,n=Na(n),n!==null){var a=u(n);if(a===null)n=null;else{var l=a.tag;if(l===13){if(n=d(a),n!==null)return n;n=null}else if(l===31){if(n=h(a),n!==null)return n;n=null}else if(l===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;n=null}else a!==n&&(n=null)}}return Dc=n,null}function F0(n){switch(n){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($n()){case Yn:return 2;case dn:return 8;case zn:case rs:return 32;case kn:return 268435456;default:return 32}default:return 32}}var dh=!1,Ga=null,Va=null,Ha=null,Ql=new Map,Zl=new Map,Ka=[],zS="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 Y0(n,a){switch(n){case"focusin":case"focusout":Ga=null;break;case"dragenter":case"dragleave":Va=null;break;case"mouseover":case"mouseout":Ha=null;break;case"pointerover":case"pointerout":Ql.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":Zl.delete(a.pointerId)}}function Fl(n,a,l,c,m,f){return n===null||n.nativeEvent!==f?(n={blockedOn:a,domEventName:l,eventSystemFlags:c,nativeEvent:f,targetContainers:[m]},a!==null&&(a=wa(a),a!==null&&Q0(a)),n):(n.eventSystemFlags|=c,a=n.targetContainers,m!==null&&a.indexOf(m)===-1&&a.push(m),n)}function kS(n,a,l,c,m){switch(a){case"focusin":return Ga=Fl(Ga,n,a,l,c,m),!0;case"dragenter":return Va=Fl(Va,n,a,l,c,m),!0;case"mouseover":return Ha=Fl(Ha,n,a,l,c,m),!0;case"pointerover":var f=m.pointerId;return Ql.set(f,Fl(Ql.get(f)||null,n,a,l,c,m)),!0;case"gotpointercapture":return f=m.pointerId,Zl.set(f,Fl(Zl.get(f)||null,n,a,l,c,m)),!0}return!1}function X0(n){var a=Na(n.target);if(a!==null){var l=u(a);if(l!==null){if(a=l.tag,a===13){if(a=d(l),a!==null){n.blockedOn=a,Hi(n.priority,function(){Z0(l)});return}}else if(a===31){if(a=h(l),a!==null){n.blockedOn=a,Hi(n.priority,function(){Z0(l)});return}}else if(a===3&&l.stateNode.current.memoizedState.isDehydrated){n.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}n.blockedOn=null}function Oc(n){if(n.blockedOn!==null)return!1;for(var a=n.targetContainers;0<a.length;){var l=ch(n.nativeEvent);if(l===null){l=n.nativeEvent;var c=new l.constructor(l.type,l);ud=c,l.target.dispatchEvent(c),ud=null}else return a=wa(l),a!==null&&Q0(a),n.blockedOn=l,!1;a.shift()}return!0}function J0(n,a,l){Oc(n)&&l.delete(a)}function CS(){dh=!1,Ga!==null&&Oc(Ga)&&(Ga=null),Va!==null&&Oc(Va)&&(Va=null),Ha!==null&&Oc(Ha)&&(Ha=null),Ql.forEach(J0),Zl.forEach(J0)}function Rc(n,a){n.blockedOn===a&&(n.blockedOn=null,dh||(dh=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,CS)))}var Lc=null;function W0(n){Lc!==n&&(Lc=n,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Lc===n&&(Lc=null);for(var a=0;a<n.length;a+=3){var l=n[a],c=n[a+1],m=n[a+2];if(typeof c!="function"){if(uh(c||l)===null)continue;break}var f=wa(l);f!==null&&(n.splice(a,3),a-=3,cm(f,{pending:!0,data:m,method:l.method,action:c},c,m))}}))}function zr(n){function a($){return Rc($,n)}Ga!==null&&Rc(Ga,n),Va!==null&&Rc(Va,n),Ha!==null&&Rc(Ha,n),Ql.forEach(a),Zl.forEach(a);for(var l=0;l<Ka.length;l++){var c=Ka[l];c.blockedOn===n&&(c.blockedOn=null)}for(;0<Ka.length&&(l=Ka[0],l.blockedOn===null);)X0(l),l.blockedOn===null&&Ka.shift();if(l=(n.ownerDocument||n).$$reactFormReplay,l!=null)for(c=0;c<l.length;c+=3){var m=l[c],f=l[c+1],y=m[hn]||null;if(typeof f=="function")y||W0(l);else if(y){var S=null;if(f&&f.hasAttribute("formAction")){if(m=f,y=f[hn]||null)S=y.formAction;else if(uh(m)!==null)continue}else S=y.action;typeof S=="function"?l[c+1]=S:(l.splice(c,3),c-=3),W0(l)}}}function ey(){function n(f){f.canIntercept&&f.info==="react-transition"&&f.intercept({handler:function(){return new Promise(function(y){return m=y})},focusReset:"manual",scroll:"manual"})}function a(){m!==null&&(m(),m=null),c||setTimeout(l,20)}function l(){if(!c&&!navigation.transition){var f=navigation.currentEntry;f&&f.url!=null&&navigation.navigate(f.url,{state:f.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var c=!1,m=null;return navigation.addEventListener("navigate",n),navigation.addEventListener("navigatesuccess",a),navigation.addEventListener("navigateerror",a),setTimeout(l,100),function(){c=!0,navigation.removeEventListener("navigate",n),navigation.removeEventListener("navigatesuccess",a),navigation.removeEventListener("navigateerror",a),m!==null&&(m(),m=null)}}}function mh(n){this._internalRoot=n}Mc.prototype.render=mh.prototype.render=function(n){var a=this._internalRoot;if(a===null)throw Error(r(409));var l=a.current,c=is();H0(l,c,n,a,null,null)},Mc.prototype.unmount=mh.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var a=n.containerInfo;H0(n.current,2,null,n,null,null),gc(),a[ba]=null}};function Mc(n){this._internalRoot=n}Mc.prototype.unstable_scheduleHydration=function(n){if(n){var a=Zs();n={blockedOn:null,target:n,priority:a};for(var l=0;l<Ka.length&&a!==0&&a<Ka[l].priority;l++);Ka.splice(l,0,n),l===0&&X0(n)}};var ty=s.version;if(ty!=="19.2.4")throw Error(r(527,ty,"19.2.4"));ne.findDOMNode=function(n){var a=n._reactInternals;if(a===void 0)throw typeof n.render=="function"?Error(r(188)):(n=Object.keys(n).join(","),Error(r(268,n)));return n=x(a),n=n!==null?b(n):null,n=n===null?null:n.stateNode,n};var AS={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:V,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var $c=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!$c.isDisabled&&$c.supportsFiber)try{F=$c.inject(AS),Pe=$c}catch{}}return Yl.createRoot=function(n,a){if(!o(n))throw Error(r(299));var l=!1,c="",m=ox,f=cx,y=ux;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(c=a.identifierPrefix),a.onUncaughtError!==void 0&&(m=a.onUncaughtError),a.onCaughtError!==void 0&&(f=a.onCaughtError),a.onRecoverableError!==void 0&&(y=a.onRecoverableError)),a=G0(n,1,!1,null,null,l,c,null,m,f,y,ey),n[ba]=a.current,Qm(n),new mh(a)},Yl.hydrateRoot=function(n,a,l){if(!o(n))throw Error(r(299));var c=!1,m="",f=ox,y=cx,S=ux,$=null;return l!=null&&(l.unstable_strictMode===!0&&(c=!0),l.identifierPrefix!==void 0&&(m=l.identifierPrefix),l.onUncaughtError!==void 0&&(f=l.onUncaughtError),l.onCaughtError!==void 0&&(y=l.onCaughtError),l.onRecoverableError!==void 0&&(S=l.onRecoverableError),l.formState!==void 0&&($=l.formState)),a=G0(n,1,!0,a,l??null,c,m,$,f,y,S,ey),a.context=V0(null),l=a.current,c=is(),c=Qs(c),m=Ea(c),m.callback=null,Da(l,m,c),l=c,a.current.lanes=l,$e(a,l),Ps(a),n[ba]=a.current,Qm(n),new Mc(a)},Yl.version="19.2.4",Yl}var ly;function FS(){if(ly)return hh.exports;ly=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(s){console.error(s)}}return e(),hh.exports=ZS(),hh.exports}var YS=FS();const XS={bodySerializer:e=>JSON.stringify(e,(s,i)=>typeof i=="bigint"?i.toString():i)},JS=({onRequest:e,onSseError:s,onSseEvent:i,responseTransformer:r,responseValidator:o,sseDefaultRetryDelay:u,sseMaxRetryAttempts:d,sseMaxRetryDelay:h,sseSleepFn:p,url:x,...b})=>{let v;const N=p??(w=>new Promise(A=>setTimeout(A,w)));return{stream:async function*(){let w=u??3e3,A=0;const D=b.signal??new AbortController().signal;for(;!D.aborted;){A++;const U=b.headers instanceof Headers?b.headers:new Headers(b.headers);v!==void 0&&U.set("Last-Event-ID",v);try{const I={redirect:"follow",...b,body:b.serializedBody,headers:U,signal:D};let C=new Request(x,I);e&&(C=await e(x,I));const M=await(b.fetch??globalThis.fetch)(C);if(!M.ok)throw new Error(`SSE failed: ${M.status} ${M.statusText}`);if(!M.body)throw new Error("No body in SSE response");const _=M.body.pipeThrough(new TextDecoderStream).getReader();let B="";const J=()=>{try{_.cancel()}catch{}};D.addEventListener("abort",J);try{for(;;){const{done:ue,value:P}=await _.read();if(ue)break;B+=P;const ie=B.split(`
10
-
11
- `);B=ie.pop()??"";for(const te of ie){const ze=te.split(`
12
- `),ve=[];let V;for(const Ne of ze)if(Ne.startsWith("data:"))ve.push(Ne.replace(/^data:\s*/,""));else if(Ne.startsWith("event:"))V=Ne.replace(/^event:\s*/,"");else if(Ne.startsWith("id:"))v=Ne.replace(/^id:\s*/,"");else if(Ne.startsWith("retry:")){const se=Number.parseInt(Ne.replace(/^retry:\s*/,""),10);Number.isNaN(se)||(w=se)}let ne,me=!1;if(ve.length){const Ne=ve.join(`
13
- `);try{ne=JSON.parse(Ne),me=!0}catch{ne=Ne}}me&&(o&&await o(ne),r&&(ne=await r(ne))),i?.({data:ne,event:V,id:v,retry:w}),ve.length&&(yield ne)}}}finally{D.removeEventListener("abort",J),_.releaseLock()}break}catch(I){if(s?.(I),d!==void 0&&A>=d)break;const C=Math.min(w*2**(A-1),h??3e4);await N(C)}}}()}},WS=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},ez=e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},tz=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},iv=({allowReserved:e,explode:s,name:i,style:r,value:o})=>{if(!s){const h=(e?o:o.map(p=>encodeURIComponent(p))).join(ez(r));switch(r){case"label":return`.${h}`;case"matrix":return`;${i}=${h}`;case"simple":return h;default:return`${i}=${h}`}}const u=WS(r),d=o.map(h=>r==="label"||r==="simple"?e?h:encodeURIComponent(h):_u({allowReserved:e,name:i,value:h})).join(u);return r==="label"||r==="matrix"?u+d:d},_u=({allowReserved:e,name:s,value:i})=>{if(i==null)return"";if(typeof i=="object")throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${s}=${e?i:encodeURIComponent(i)}`},rv=({allowReserved:e,explode:s,name:i,style:r,value:o,valueOnly:u})=>{if(o instanceof Date)return u?o.toISOString():`${i}=${o.toISOString()}`;if(r!=="deepObject"&&!s){let p=[];Object.entries(o).forEach(([b,v])=>{p=[...p,b,e?v:encodeURIComponent(v)]});const x=p.join(",");switch(r){case"form":return`${i}=${x}`;case"label":return`.${x}`;case"matrix":return`;${i}=${x}`;default:return x}}const d=tz(r),h=Object.entries(o).map(([p,x])=>_u({allowReserved:e,name:r==="deepObject"?`${i}[${p}]`:p,value:x})).join(d);return r==="label"||r==="matrix"?d+h:h},nz=/\{[^{}]+\}/g,sz=({path:e,url:s})=>{let i=s;const r=s.match(nz);if(r)for(const o of r){let u=!1,d=o.substring(1,o.length-1),h="simple";d.endsWith("*")&&(u=!0,d=d.substring(0,d.length-1)),d.startsWith(".")?(d=d.substring(1),h="label"):d.startsWith(";")&&(d=d.substring(1),h="matrix");const p=e[d];if(p==null)continue;if(Array.isArray(p)){i=i.replace(o,iv({explode:u,name:d,style:h,value:p}));continue}if(typeof p=="object"){i=i.replace(o,rv({explode:u,name:d,style:h,value:p,valueOnly:!0}));continue}if(h==="matrix"){i=i.replace(o,`;${_u({name:d,value:p})}`);continue}const x=encodeURIComponent(h==="label"?`.${p}`:p);i=i.replace(o,x)}return i},az=({baseUrl:e,path:s,query:i,querySerializer:r,url:o})=>{const u=o.startsWith("/")?o:`/${o}`;let d=(e??"")+u;s&&(d=sz({path:s,url:d}));let h=i?r(i):"";return h.startsWith("?")&&(h=h.substring(1)),h&&(d+=`?${h}`),d};function iz(e){const s=e.body!==void 0;if(s&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(s)return e.body}const rz=async(e,s)=>{const i=typeof s=="function"?await s(e):s;if(i)return e.scheme==="bearer"?`Bearer ${i}`:e.scheme==="basic"?`Basic ${btoa(i)}`:i},lv=({allowReserved:e,array:s,object:i}={})=>o=>{const u=[];if(o&&typeof o=="object")for(const d in o){const h=o[d];if(h!=null)if(Array.isArray(h)){const p=iv({allowReserved:e,explode:!0,name:d,style:"form",value:h,...s});p&&u.push(p)}else if(typeof h=="object"){const p=rv({allowReserved:e,explode:!0,name:d,style:"deepObject",value:h,...i});p&&u.push(p)}else{const p=_u({allowReserved:e,name:d,value:h});p&&u.push(p)}}return u.join("&")},lz=e=>{if(!e)return"stream";const s=e.split(";")[0]?.trim();if(s){if(s.startsWith("application/json")||s.endsWith("+json"))return"json";if(s==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(i=>s.startsWith(i)))return"blob";if(s.startsWith("text/"))return"text"}},oz=(e,s)=>s?!!(e.headers.has(s)||e.query?.[s]||e.headers.get("Cookie")?.includes(`${s}=`)):!1,cz=async({security:e,...s})=>{for(const i of e){if(oz(s,i.name))continue;const r=await rz(i,s.auth);if(!r)continue;const o=i.name??"Authorization";switch(i.in){case"query":s.query||(s.query={}),s.query[o]=r;break;case"cookie":s.headers.append("Cookie",`${o}=${r}`);break;default:s.headers.set(o,r);break}}},oy=e=>az({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:lv(e.querySerializer),url:e.url}),cy=(e,s)=>{const i={...e,...s};return i.baseUrl?.endsWith("/")&&(i.baseUrl=i.baseUrl.substring(0,i.baseUrl.length-1)),i.headers=ov(e.headers,s.headers),i},uz=e=>{const s=[];return e.forEach((i,r)=>{s.push([r,i])}),s},ov=(...e)=>{const s=new Headers;for(const i of e){if(!i)continue;const r=i instanceof Headers?uz(i):Object.entries(i);for(const[o,u]of r)if(u===null)s.delete(o);else if(Array.isArray(u))for(const d of u)s.append(o,d);else u!==void 0&&s.set(o,typeof u=="object"?JSON.stringify(u):u)}return s};class gh{fns=[];clear(){this.fns=[]}eject(s){const i=this.getInterceptorIndex(s);this.fns[i]&&(this.fns[i]=null)}exists(s){const i=this.getInterceptorIndex(s);return!!this.fns[i]}getInterceptorIndex(s){return typeof s=="number"?this.fns[s]?s:-1:this.fns.indexOf(s)}update(s,i){const r=this.getInterceptorIndex(s);return this.fns[r]?(this.fns[r]=i,s):!1}use(s){return this.fns.push(s),this.fns.length-1}}const dz=()=>({error:new gh,request:new gh,response:new gh}),mz=lv({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),hz={"Content-Type":"application/json"},cv=(e={})=>({...XS,headers:hz,parseAs:"auto",querySerializer:mz,...e}),uv=(e={})=>{let s=cy(cv(),e);const i=()=>({...s}),r=x=>(s=cy(s,x),i()),o=dz(),u=async x=>{const b={...s,...x,fetch:x.fetch??s.fetch??globalThis.fetch,headers:ov(s.headers,x.headers),serializedBody:void 0};b.security&&await cz({...b,security:b.security}),b.requestValidator&&await b.requestValidator(b),b.body!==void 0&&b.bodySerializer&&(b.serializedBody=b.bodySerializer(b.body)),(b.body===void 0||b.serializedBody==="")&&b.headers.delete("Content-Type");const v=oy(b);return{opts:b,url:v}},d=async x=>{const{opts:b,url:v}=await u(x),N={redirect:"follow",...b,body:iz(b)};let z=new Request(v,N);for(const L of o.request.fns)L&&(z=await L(z,b));const T=b.fetch;let w=await T(z);for(const L of o.response.fns)L&&(w=await L(w,z,b));const A={request:z,response:w};if(w.ok){const L=(b.parseAs==="auto"?lz(w.headers.get("Content-Type")):b.parseAs)??"json";if(w.status===204||w.headers.get("Content-Length")==="0"){let _;switch(L){case"arrayBuffer":case"blob":case"text":_=await w[L]();break;case"formData":_=new FormData;break;case"stream":_=w.body;break;default:_={};break}return b.responseStyle==="data"?_:{data:_,...A}}let M;switch(L){case"arrayBuffer":case"blob":case"formData":case"json":case"text":M=await w[L]();break;case"stream":return b.responseStyle==="data"?w.body:{data:w.body,...A}}return L==="json"&&(b.responseValidator&&await b.responseValidator(M),b.responseTransformer&&(M=await b.responseTransformer(M))),b.responseStyle==="data"?M:{data:M,...A}}const D=await w.text();let U;try{U=JSON.parse(D)}catch{}const I=U??D;let C=I;for(const L of o.error.fns)L&&(C=await L(I,w,z,b));if(C=C||{},b.throwOnError)throw C;return b.responseStyle==="data"?void 0:{error:C,...A}},h=x=>b=>d({...b,method:x}),p=x=>async b=>{const{opts:v,url:N}=await u(b);return JS({...v,body:v.body,headers:v.headers,method:x,onRequest:async(z,T)=>{let w=new Request(z,T);for(const A of o.request.fns)A&&(w=await A(w,v));return w},url:N})};return{buildUrl:oy,connect:h("CONNECT"),delete:h("DELETE"),get:h("GET"),getConfig:i,head:h("HEAD"),interceptors:o,options:h("OPTIONS"),patch:h("PATCH"),post:h("POST"),put:h("PUT"),request:d,setConfig:r,sse:{connect:p("CONNECT"),delete:p("DELETE"),get:p("GET"),head:p("HEAD"),options:p("OPTIONS"),patch:p("PATCH"),post:p("POST"),put:p("PUT"),trace:p("TRACE")},trace:h("TRACE")}},xe=uv(cv()),fz=e=>(e.client??xe).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}",...e}),pz=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}",...e}),gz=e=>(e.client??xe).put({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}",...e,headers:{"Content-Type":"application/json",...e.headers}}),xz=e=>(e?.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects",...e}),yz=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/locations",...e,headers:{"Content-Type":"application/json",...e.headers}}),bz=e=>(e.client??xe).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/locations/{label}",...e}),vz=e=>(e.client??xe).put({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/locations/default",...e,headers:{"Content-Type":"application/json",...e.headers}}),jz=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/export",...e}),Nz=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/queries",...e}),wz=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/queries",...e,headers:{"Content-Type":"application/json",...e.headers}}),Sz=e=>(e.client??xe).put({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/queries",...e,headers:{"Content-Type":"application/json",...e.headers}}),zz=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/queries/generate",...e,headers:{"Content-Type":"application/json",...e.headers}}),kz=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/competitors",...e}),Cz=e=>(e.client??xe).put({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/competitors",...e,headers:{"Content-Type":"application/json",...e.headers}}),Az=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/runs",...e}),Tz=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/runs",...e,headers:{"Content-Type":"application/json",...e.headers}}),_z=e=>(e?.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/runs",...e}),Ez=e=>(e?.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/runs",...e,headers:{"Content-Type":"application/json",...e?.headers}}),dv=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/runs/{id}",...e}),Dz=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/apply",...e,headers:{"Content-Type":"application/json",...e.headers}}),Oz=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/timeline",...e}),mv=e=>(e?.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/settings",...e}),Rz=e=>(e.client??xe).put({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/settings/providers/{name}",...e,headers:{"Content-Type":"application/json",...e.headers}}),Lz=e=>(e.client??xe).put({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/settings/google",...e,headers:{"Content-Type":"application/json",...e.headers}}),Mz=e=>(e.client??xe).put({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/settings/bing",...e,headers:{"Content-Type":"application/json",...e.headers}}),$z=e=>(e.client??xe).put({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/settings/cdp",...e,headers:{"Content-Type":"application/json",...e.headers}}),Bz=e=>(e.client??xe).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/schedule",...e}),qz=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/schedule",...e}),Iz=e=>(e.client??xe).put({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/schedule",...e,headers:{"Content-Type":"application/json",...e.headers}}),Uz=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/notifications",...e}),Pz=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/notifications",...e,headers:{"Content-Type":"application/json",...e.headers}}),Gz=e=>(e.client??xe).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/notifications/{id}",...e}),Vz=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/notifications/{id}/test",...e}),Hz=e=>(e?.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/cdp/status",...e}),Kz=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/google/connections",...e}),Qz=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/google/connect",...e,headers:{"Content-Type":"application/json",...e.headers}}),Zz=e=>(e.client??xe).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/google/connections/{type}",...e}),Fz=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/google/properties",...e}),Yz=e=>(e.client??xe).put({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/google/connections/{type}/property",...e,headers:{"Content-Type":"application/json",...e.headers}}),Xz=e=>(e.client??xe).put({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/google/connections/{type}/sitemap",...e,headers:{"Content-Type":"application/json",...e.headers}}),Jz=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/google/gsc/sync",...e,headers:{"Content-Type":"application/json",...e.headers}}),Wz=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/google/gsc/performance",...e}),ek=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/google/gsc/performance/daily",...e}),tk=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/google/gsc/inspect",...e,headers:{"Content-Type":"application/json",...e.headers}}),nk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/google/gsc/inspections",...e}),sk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/google/gsc/deindexed",...e}),hv=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/google/gsc/coverage",...e}),ak=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/google/gsc/coverage/history",...e}),ik=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/google/gsc/sitemaps",...e}),rk=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/google/gsc/discover-sitemaps",...e}),lk=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/google/gsc/inspect-sitemap",...e,headers:{"Content-Type":"application/json",...e.headers}}),ok=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/google/indexing/request",...e,headers:{"Content-Type":"application/json",...e.headers}}),ck=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/bing/connect",...e,headers:{"Content-Type":"application/json",...e.headers}}),uk=e=>(e.client??xe).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/bing/disconnect",...e}),dk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/bing/status",...e}),mk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/bing/sites",...e}),hk=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/bing/set-site",...e,headers:{"Content-Type":"application/json",...e.headers}}),fv=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/bing/coverage",...e}),fk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/bing/inspections",...e}),pk=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/bing/inspect-url",...e,headers:{"Content-Type":"application/json",...e.headers}}),gk=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/bing/inspect-sitemap",...e,headers:{"Content-Type":"application/json",...e.headers}}),xk=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/bing/request-indexing",...e,headers:{"Content-Type":"application/json",...e.headers}}),yk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/bing/performance",...e}),bk=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/ga/connect",...e,headers:{"Content-Type":"application/json",...e.headers}}),vk=e=>(e.client??xe).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/ga/disconnect",...e}),jk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/ga/status",...e}),Nk=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/ga/sync",...e,headers:{"Content-Type":"application/json",...e.headers}}),wk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/ga/traffic",...e}),Sk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/ga/ai-referral-history",...e}),zk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/ga/social-referral-history",...e}),kk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/ga/session-history",...e}),Ck=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/insights",...e}),Ak=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/report",...e}),Tk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/citations/visibility",...e}),_k=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/overview",...e}),Ek=e=>(e?.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/backlinks/status",...e}),Dk=e=>(e?.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/backlinks/install",...e}),Ok=e=>(e?.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/backlinks/syncs",...e}),Rk=e=>(e?.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/backlinks/syncs",...e,headers:{"Content-Type":"application/json",...e?.headers}}),Lk=e=>(e?.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/backlinks/syncs/latest",...e}),Mk=e=>(e?.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/backlinks/releases",...e}),$k=e=>(e?.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/backlinks/latest-release",...e}),Bk=e=>(e.client??xe).delete({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/backlinks/cache/{release}",...e}),qk=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/backlinks/extract",...e,headers:{"Content-Type":"application/json",...e.headers}}),Ik=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/backlinks/summary",...e}),Uk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/backlinks/domains",...e}),Pk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/backlinks/history",...e}),Gk=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/traffic/connect/cloud-run",...e,headers:{"Content-Type":"application/json",...e.headers}}),Vk=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/traffic/connect/wordpress",...e,headers:{"Content-Type":"application/json",...e.headers}}),Hk=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/traffic/connect/vercel",...e,headers:{"Content-Type":"application/json",...e.headers}}),Kk=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/traffic/sources/{id}/sync",...e,headers:{"Content-Type":"application/json",...e.headers}}),Qk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/traffic/sources",...e}),Zk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/traffic/status",...e}),Fk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/traffic/sources/{id}",...e}),Yk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/traffic/events",...e}),Xk=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/discover/run",...e,headers:{"Content-Type":"application/json",...e.headers}}),Jk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/discover/sessions",...e}),Wk=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/discover/sessions/{id}",...e}),e2=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/discover/sessions/{id}/promote",...e}),t2=e=>(e.client??xe).post({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/discover/sessions/{id}/promote",...e,headers:{"Content-Type":"application/json",...e.headers}}),n2=e=>(e.client??xe).get({security:[{scheme:"bearer",type:"http"}],url:"/api/v1/projects/{name}/agent/providers",...e});function s2(e){const s={baseUrl:e.baseUrl,fetch:e.fetch,headers:{...e.headers??{}}};return uv(s)}class un extends Error{code;statusCode;constructor(s,i,r){super(s),this.name="ApiError",this.code=r??"UNKNOWN",this.statusCode=i}}function a2(){return typeof window<"u"&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath.replace(/\/$/,"")+"/api/v1":"/api/v1"}const pv=a2();function i2(){const e=typeof window<"u"&&window.location?window.location.origin:"";return typeof window<"u"&&window.__CANONRY_CONFIG__?.basePath?e+window.__CANONRY_CONFIG__.basePath.replace(/\/$/,""):e}function r2(){return typeof window<"u"&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath.replace(/\/$/,""):""}function l2(e){return`${r2()}${e}`}function o2(e,s){if(s===404)return"Health endpoint returned 404. Check basePath or reverse-proxy configuration and make sure the dashboard reaches /health instead of an API-prefixed route."}function c2(){return""}function xh(){return!!c2()}let gv=null;function uy(e){gv=e}function jf(){gv?.()}const ae=s2({baseUrl:i2()});ae.interceptors.response.use((e,s)=>((e.status===401||e.status===403)&&!s.url.includes("/api/v1/session")&&jf(),e));async function ke(e){const s=await e();if(s.error!==void 0&&s.error!==null){const i=s.response.status;let r=`API ${i}: ${s.response.statusText}`,o;if(typeof s.error=="object"&&s.error!==null){const u=s.error.error;if(typeof u=="string")r=u;else if(u&&typeof u=="object"){const d=u;d.message&&(r=d.message),d.code&&(o=d.code)}else{const d=s.error;d.message&&(r=d.message),d.code&&(o=d.code)}}else typeof s.error=="string"&&(r=s.error);throw new un(r,i,o)}if(s.response.status!==204)return s.data}async function Nf(e,s){const i=s?.body!=null,r=await fetch(`${pv}${e}`,{...s,credentials:s?.credentials??"same-origin",headers:{...i?{"Content-Type":"application/json"}:{},...s?.headers}});if(!r.ok){const o=await r.text();let u=`API ${r.status}: ${r.statusText}`,d;if(o)try{const h=JSON.parse(o);typeof h.error=="string"?u=h.error:h.error?.message?(u=h.error.message,d=h.error.code):h.message&&(u=h.message)}catch{u=o}throw(r.status===401||r.status===403)&&!e.startsWith("/session")&&jf(),new un(u,r.status,d)}if(r.status!==204)return r.json()}function wf(e){return ke(()=>pz({client:ae,path:{name:e}}))}function u2(e){return ke(()=>Az({client:ae,path:{name:e}}))}function Kr(e){return ke(()=>dv({client:ae,path:{id:e}}))}function d2(e){return ke(()=>Nz({client:ae,path:{name:e}}))}function xv(e){return ke(()=>kz({client:ae,path:{name:e}}))}function yv(e,s){return ke(()=>Oz({client:ae,path:{name:e},query:{location:s}}))}function m2(e,s){return ke(()=>_k({client:ae,path:{name:e},query:{location:s?.location,since:s?.since}}))}function vo(e,s){return ke(()=>gz({client:ae,path:{name:e},body:s}))}function h2(e,s){return ke(()=>Sz({client:ae,path:{name:e},body:{queries:s}}))}function bv(e,s){return ke(()=>wz({client:ae,path:{name:e},body:{queries:s}}))}function vv(e,s){return ke(()=>Cz({client:ae,path:{name:e},body:{competitors:s}}))}async function dy(e,s){const i=await wf(e);return vo(e,{displayName:i.displayName??i.name,canonicalDomain:i.canonicalDomain,ownedDomains:s,aliases:i.aliases,country:i.country,language:i.language,tags:i.tags,labels:i.labels,providers:i.providers,locations:i.locations,defaultLocation:i.defaultLocation})}async function my(e,s){const i=await wf(e);return vo(e,{displayName:i.displayName??i.name,canonicalDomain:i.canonicalDomain,ownedDomains:i.ownedDomains,aliases:s,country:i.country,language:i.language,tags:i.tags,labels:i.labels,providers:i.providers,locations:i.locations,defaultLocation:i.defaultLocation})}async function f2(e,s){const i=await wf(e);return vo(e,{displayName:s.displayName??i.displayName??i.name,canonicalDomain:s.canonicalDomain??i.canonicalDomain,ownedDomains:s.ownedDomains??i.ownedDomains,aliases:s.aliases??i.aliases,country:s.country??i.country,language:s.language??i.language,tags:i.tags,labels:i.labels,providers:i.providers,locations:s.locations??i.locations,defaultLocation:s.defaultLocation!==void 0?s.defaultLocation:i.defaultLocation})}function p2(e,s){const i={};return s?.location&&(i.location=s.location),s?.allLocations&&(i.allLocations=!0),s?.noLocation&&(i.noLocation=!0),ke(()=>Tz({client:ae,path:{name:e},body:i}))}function g2(e,s){return ke(()=>yz({client:ae,path:{name:e},body:s}))}async function x2(e,s){await ke(()=>bz({client:ae,path:{name:e,label:s}}))}function y2(e,s){return ke(()=>vz({client:ae,path:{name:e},body:{label:s}}))}async function b2(e){await ke(()=>fz({client:ae,path:{name:e}}))}function v2(e){return ke(()=>jz({client:ae,path:{name:e}}))}function j2(){return ke(()=>mv({client:ae}))}function hy(){return Nf("/session")}function N2(e){return Nf("/session/setup",{method:"POST",body:JSON.stringify({password:e})})}function w2(e){return Nf("/session",{method:"POST",body:JSON.stringify({password:e})})}function jv(e,s){return ke(()=>Rz({client:ae,path:{name:e},body:s}))}function S2(e){return ke(()=>Lz({client:ae,body:e}))}async function z2(e){try{return await ke(()=>qz({client:ae,path:{name:e}}))}catch(s){if(s instanceof un&&s.statusCode===404)return null;throw s}}function fy(e,s){return ke(()=>Iz({client:ae,path:{name:e},body:s}))}async function k2(e){await ke(()=>Bz({client:ae,path:{name:e}}))}function C2(e){return ke(()=>Uz({client:ae,path:{name:e}}))}function A2(e,s){return ke(()=>Pz({client:ae,path:{name:e},body:s}))}async function T2(e,s){await ke(()=>Gz({client:ae,path:{name:e,id:s}}))}function _2(e,s){return ke(()=>Vz({client:ae,path:{name:e,id:s}}))}function E2(e,s,i){return ke(()=>zz({client:ae,path:{name:e},body:{provider:s,count:i}}))}function D2(e){return ke(()=>Dz({client:ae,body:e}))}function O2(e){return ke(()=>Ez({client:ae,body:e??{}}))}function R2(e,s){return ke(()=>Qz({client:ae,path:{name:e},body:{type:s}}))}function L2(e,s){return ke(()=>Zz({client:ae,path:{name:e,type:s}}))}function M2(e,s,i){return ke(()=>Yz({client:ae,path:{name:e,type:s},body:{propertyId:i}}))}function $2(e,s,i){return ke(()=>Xz({client:ae,path:{name:e,type:s},body:{sitemapUrl:i}}))}function Nv(e,s){return ke(()=>Jz({client:ae,path:{name:e},body:s??{}}))}function B2(e,s){return ke(()=>tk({client:ae,path:{name:e},body:{url:s}}))}function q2(e){return ke(()=>hv({client:ae,path:{name:e}}))}function I2(e,s){return ke(()=>lk({client:ae,path:{name:e},body:s??{}}))}function U2(e){return ke(()=>ik({client:ae,path:{name:e}}))}function P2(e){return ke(()=>rk({client:ae,path:{name:e}}))}function G2(e,s){return ke(()=>Xk({client:ae,path:{name:e},body:s??{}}))}function V2(e,s,i){return ke(()=>t2({client:ae,path:{name:e,id:s},body:i??{}}))}function py(){return ke(()=>Hz({client:ae}))}function H2(e,s){return ke(()=>$z({client:ae,body:{host:e,port:s}}))}function gy(e,s){return ke(()=>ok({client:ae,path:{name:e},body:s}))}function K2(e,s){return ke(()=>ck({client:ae,path:{name:e},body:{apiKey:s}}))}function Q2(e){return ke(()=>uk({client:ae,path:{name:e}}))}function Z2(e,s){return ke(()=>hk({client:ae,path:{name:e},body:{siteUrl:s}}))}function F2(e){return ke(()=>fv({client:ae,path:{name:e}}))}function wv(e,s){return ke(()=>pk({client:ae,path:{name:e},body:{url:s}}))}function Y2(e,s){return ke(()=>gk({client:ae,path:{name:e},body:{}}))}function xy(e,s){return ke(()=>xk({client:ae,path:{name:e},body:s}))}function X2(e){return ke(()=>Mz({client:ae,body:{apiKey:e}}))}function J2(e){return e?/filename\s*=\s*"?([^";]+)"?/i.exec(e)?.[1]??null:null}async function W2(e,s="agency"){const i=new URLSearchParams({audience:s}),r=await fetch(`${pv}/projects/${encodeURIComponent(e)}/report.html?${i.toString()}`,{credentials:"same-origin",headers:{}});if(!r.ok)throw new un(`Failed to download report: ${r.status}`,r.status);const o=await r.blob(),u=URL.createObjectURL(o),d=J2(r.headers.get("Content-Disposition"))??`canonry-report-${e}.html`,h=document.createElement("a");h.href=u,h.download=d,document.body.appendChild(h),h.click(),document.body.removeChild(h),URL.revokeObjectURL(u)}function Sv(e,s){return ke(()=>Nk({client:ae,path:{name:e},body:{}}))}function eC(e,s){return ke(()=>bk({client:ae,path:{name:e},body:s}))}function tC(e){return ke(()=>vk({client:ae,path:{name:e}}))}function nC(e,s){return ke(()=>Gk({client:ae,path:{name:e},body:s}))}function sC(e,s){return ke(()=>Vk({client:ae,path:{name:e},body:s}))}function aC(e,s){return ke(()=>Hk({client:ae,path:{name:e},body:s}))}function iC(e,s,i){return ke(()=>Kk({client:ae,path:{name:e,id:s},body:i??{}}))}function rC(e,s){return ke(()=>Ck({client:ae,path:{name:e},query:{runId:s}}))}function lC(e){if(!e||typeof e!="object")return;const s=e;if(!(typeof s.current!="string"||typeof s.latest!="string"||typeof s.url!="string"||typeof s.upgradeCommand!="string"))return{current:s.current,latest:s.latest,url:s.url,upgradeCommand:s.upgradeCommand}}async function oC(e,s){const i=l2(e);try{const r=await fetch(i,{credentials:"same-origin"});if(!r.ok)return{label:s,state:"error",detail:`${s} ${r.status}: ${r.statusText}`,statusCode:r.status,hint:o2(e,r.status)};const o=await r.json(),u=typeof o.version=="string"?o.version:"unknown",d=typeof o.databaseUrlConfigured=="boolean"?o.databaseUrlConfigured:void 0,h=typeof o.lastHeartbeatAt=="string"?o.lastHeartbeatAt:void 0,p=lC(o.updateAvailable),x=[u,d===!1?"database not configured":"database configured",h?`heartbeat ${h}`:void 0].filter(Boolean).join(" · ");return{label:s,state:"ok",detail:x,version:u,databaseConfigured:d,lastHeartbeatAt:h,...p?{updateAvailable:p}:{}}}catch(r){return{label:s,state:"error",detail:r instanceof Error?r.message:"unreachable",hint:e==="/health"?`Request failed while checking ${i}. If this instance is served behind a sub-path, verify the dashboard basePath and reverse-proxy rewrites.`:void 0}}}function cC(){return ke(()=>Ek({client:ae}))}function uC(){return ke(()=>Dk({client:ae}))}function zv(){return ke(()=>Lk({client:ae}))}function dC(){return ke(()=>Ok({client:ae}))}function mC(e){return ke(()=>Rk({client:ae,body:e?{release:e}:{}}))}function hC(){return ke(()=>Mk({client:ae}))}function fC(){return ke(()=>$k({client:ae}))}function pC(e){return ke(()=>Bk({client:ae,path:{release:e}}))}function gC(e,s={}){return ke(()=>Ik({client:ae,path:{name:e},query:{release:s.release,excludeCrawlers:s.excludeCrawlers?"1":void 0}}))}function xC(e,s={}){return ke(()=>Uk({client:ae,path:{name:e},query:{limit:s.limit!==void 0?String(s.limit):void 0,offset:s.offset!==void 0?String(s.offset):void 0,release:s.release,excludeCrawlers:s.excludeCrawlers?"1":void 0}}))}function yC(e){return ke(()=>Pk({client:ae,path:{name:e}}))}function bC(e,s){return ke(()=>qk({client:ae,path:{name:e},body:{release:void 0}}))}function Le(e){return(...s)=>{e(...s)}}const vC=6e3,jC=5,NC=180;let Tn=[],wC=0;const Ph=new Set,Gh=new Map,Vh=new Map;function fu(){const e=[...Tn];for(const s of Ph)s(e)}function Sf(e){const s=Gh.get(e);s&&(clearTimeout(s),Gh.delete(e));const i=Vh.get(e);i&&(clearTimeout(i),Vh.delete(e))}function kv(e){Sf(e);const s=Tn.length;Tn=Tn.filter(i=>i.id!==e),Tn.length!==s&&fu()}function yy(e){Sf(e.id),Gh.set(e.id,setTimeout(()=>{Hh(e.id)},e.durationMs))}function SC(e,s,i){return typeof e=="string"?{title:e,tone:s,durationMs:i}:e}function Qe(e,s="negative",i=vC){const r=SC(e,s,i),o={id:String(++wC),title:r.title,detail:r.detail,tone:r.tone??s,durationMs:r.durationMs??i,dedupeKey:r.dedupeKey,cta:r.cta,state:"open"};if(r.dedupeKey){const u=Tn.find(d=>d.dedupeKey===r.dedupeKey);if(u){if((r.dedupeMode??"drop")==="drop")return u.id;const d={...u,title:o.title,detail:o.detail,tone:o.tone,durationMs:o.durationMs,cta:o.cta,state:"open"};return Tn=Tn.map(h=>h.id===u.id?d:h),fu(),yy(d),u.id}}return Tn.length>=jC&&kv(Tn[0].id),Tn=[...Tn,o],fu(),yy(o),o.id}function Hh(e){const s=Tn.find(i=>i.id===e);!s||s.state==="closing"||(Sf(e),Tn=Tn.map(i=>i.id===e?{...i,state:"closing"}:i),fu(),Vh.set(e,setTimeout(()=>{kv(e)},NC)))}function zC(e){return Ph.add(e),()=>{Ph.delete(e)}}function by(){return Tn}const kC=5*6e4,Cv=30*6e4,pa=3e4,bn=6e4,Kh=3e4;function CC(){return new DS({defaultOptions:{queries:{staleTime:kC,retry:1,refetchOnWindowFocus:!1}},mutationCache:new OS({onError:(e,s,i,r)=>{r.meta?.skipGlobalErrorToast||Qe({title:e instanceof Error?e.message:"An unexpected error occurred",tone:"negative"})}})})}const AC=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),TC=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(s,i,r)=>r?r.toUpperCase():i.toLowerCase()),vy=e=>{const s=TC(e);return s.charAt(0).toUpperCase()+s.slice(1)},Av=(...e)=>e.filter((s,i,r)=>!!s&&s.trim()!==""&&r.indexOf(s)===i).join(" ").trim(),_C=e=>{for(const s in e)if(s.startsWith("aria-")||s==="role"||s==="title")return!0};var EC={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const DC=j.forwardRef(({color:e="currentColor",size:s=24,strokeWidth:i=2,absoluteStrokeWidth:r,className:o="",children:u,iconNode:d,...h},p)=>j.createElement("svg",{ref:p,...EC,width:s,height:s,stroke:e,strokeWidth:r?Number(i)*24/Number(s):i,className:Av("lucide",o),...!u&&!_C(h)&&{"aria-hidden":"true"},...h},[...d.map(([x,b])=>j.createElement(x,b)),...Array.isArray(u)?u:[u]]));const st=(e,s)=>{const i=j.forwardRef(({className:r,...o},u)=>j.createElement(DC,{ref:u,iconNode:s,className:Av(`lucide-${AC(vy(e))}`,`lucide-${e}`,r),...o}));return i.displayName=vy(e),i};const OC=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Qh=st("arrow-left",OC);const RC=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],LC=st("arrow-right",RC);const MC=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],$C=st("arrow-up",MC);const BC=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],qC=st("book-open",BC);const IC=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Tv=st("check",IC);const UC=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],PC=st("chevron-down",UC);const GC=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],jo=st("chevron-right",GC);const VC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],HC=st("circle-alert",VC);const KC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],zf=st("circle-check",KC);const QC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],_v=st("circle-question-mark",QC);const ZC=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],FC=st("cloud",ZC);const YC=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],XC=st("copy",YC);const JC=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Eu=st("download",JC);const WC=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],eA=st("external-link",WC);const tA=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],nA=st("file-text",tA);const sA=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],aA=st("github",sA);const iA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Ev=st("globe",iA);const rA=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],lA=st("layout-dashboard",rA);const oA=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Dv=st("link-2",oA);const cA=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ov=st("loader-circle",cA);const uA=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],dA=st("maximize-2",uA);const mA=[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]],hA=st("menu",mA);const fA=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],pA=st("minimize-2",fA);const gA=[["path",{d:"M5 12h14",key:"1ays0h"}]],xA=st("minus",gA);const yA=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],uo=st("play",yA);const bA=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],pu=st("plus",bA);const vA=[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]],jA=st("radar",vA);const NA=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],mo=st("refresh-cw",NA);const wA=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],SA=st("rocket",wA);const zA=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Rv=st("rotate-ccw",zA);const kA=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],CA=st("settings",kA);const AA=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],jy=st("sparkles",AA);const TA=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Lv=st("trash-2",TA);const _A=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],gu=st("triangle-alert",_A);const EA=[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]],DA=st("triangle",EA);const OA=[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]],RA=st("unplug",OA);const LA=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],MA=st("upload",LA);const $A=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],BA=st("wrench",$A);const qA=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],qi=st("x",qA);function oe(e,s,i){function r(h,p){if(h._zod||Object.defineProperty(h,"_zod",{value:{def:p,constr:d,traits:new Set},enumerable:!1}),h._zod.traits.has(e))return;h._zod.traits.add(e),s(h,p);const x=d.prototype,b=Object.keys(x);for(let v=0;v<b.length;v++){const N=b[v];N in h||(h[N]=x[N].bind(h))}}const o=i?.Parent??Object;class u extends o{}Object.defineProperty(u,"name",{value:e});function d(h){var p;const x=i?.Parent?new u:this;r(x,h),(p=x._zod).deferred??(p.deferred=[]);for(const b of x._zod.deferred)b();return x}return Object.defineProperty(d,"init",{value:r}),Object.defineProperty(d,Symbol.hasInstance,{value:h=>i?.Parent&&h instanceof i.Parent?!0:h?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}class Br extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Mv extends Error{constructor(s){super(`Encountered unidirectional transform during encode: ${s}`),this.name="ZodEncodeError"}}const $v={};function ni(e){return $v}function Bv(e){const s=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>s.indexOf(+r)===-1).map(([r,o])=>o)}function Zh(e,s){return typeof s=="bigint"?s.toString():s}function Du(e){return{get value(){{const s=e();return Object.defineProperty(this,"value",{value:s}),s}}}}function kf(e){return e==null}function Cf(e){const s=e.startsWith("^")?1:0,i=e.endsWith("$")?e.length-1:e.length;return e.slice(s,i)}function IA(e,s){const i=(e.toString().split(".")[1]||"").length,r=s.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const p=r.match(/\d?e-(\d?)/);p?.[1]&&(o=Number.parseInt(p[1]))}const u=i>o?i:o,d=Number.parseInt(e.toFixed(u).replace(".","")),h=Number.parseInt(s.toFixed(u).replace(".",""));return d%h/10**u}const Ny=Symbol("evaluating");function wt(e,s,i){let r;Object.defineProperty(e,s,{get(){if(r!==Ny)return r===void 0&&(r=Ny,r=i()),r},set(o){Object.defineProperty(e,s,{value:o})},configurable:!0})}function Ii(e,s,i){Object.defineProperty(e,s,{value:i,writable:!0,enumerable:!0,configurable:!0})}function ii(...e){const s={};for(const i of e){const r=Object.getOwnPropertyDescriptors(i);Object.assign(s,r)}return Object.defineProperties({},s)}function wy(e){return JSON.stringify(e)}function UA(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const qv="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ho(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const PA=Du(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Qr(e){if(ho(e)===!1)return!1;const s=e.constructor;if(s===void 0||typeof s!="function")return!0;const i=s.prototype;return!(ho(i)===!1||Object.prototype.hasOwnProperty.call(i,"isPrototypeOf")===!1)}function Iv(e){return Qr(e)?{...e}:Array.isArray(e)?[...e]:e}const GA=new Set(["string","number","symbol"]);function Zr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ri(e,s,i){const r=new e._zod.constr(s??e._zod.def);return(!s||i?.parent)&&(r._zod.parent=e),r}function Be(e){const s=e;if(!s)return{};if(typeof s=="string")return{error:()=>s};if(s?.message!==void 0){if(s?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");s.error=s.message}return delete s.message,typeof s.error=="string"?{...s,error:()=>s.error}:s}function VA(e){return Object.keys(e).filter(s=>e[s]._zod.optin==="optional"&&e[s]._zod.optout==="optional")}const HA={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function KA(e,s){const i=e._zod.def,r=i.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const u=ii(e._zod.def,{get shape(){const d={};for(const h in s){if(!(h in i.shape))throw new Error(`Unrecognized key: "${h}"`);s[h]&&(d[h]=i.shape[h])}return Ii(this,"shape",d),d},checks:[]});return ri(e,u)}function QA(e,s){const i=e._zod.def,r=i.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const u=ii(e._zod.def,{get shape(){const d={...e._zod.def.shape};for(const h in s){if(!(h in i.shape))throw new Error(`Unrecognized key: "${h}"`);s[h]&&delete d[h]}return Ii(this,"shape",d),d},checks:[]});return ri(e,u)}function ZA(e,s){if(!Qr(s))throw new Error("Invalid input to extend: expected a plain object");const i=e._zod.def.checks;if(i&&i.length>0){const u=e._zod.def.shape;for(const d in s)if(Object.getOwnPropertyDescriptor(u,d)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=ii(e._zod.def,{get shape(){const u={...e._zod.def.shape,...s};return Ii(this,"shape",u),u}});return ri(e,o)}function FA(e,s){if(!Qr(s))throw new Error("Invalid input to safeExtend: expected a plain object");const i=ii(e._zod.def,{get shape(){const r={...e._zod.def.shape,...s};return Ii(this,"shape",r),r}});return ri(e,i)}function YA(e,s){const i=ii(e._zod.def,{get shape(){const r={...e._zod.def.shape,...s._zod.def.shape};return Ii(this,"shape",r),r},get catchall(){return s._zod.def.catchall},checks:[]});return ri(e,i)}function XA(e,s,i){const o=s._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const d=ii(s._zod.def,{get shape(){const h=s._zod.def.shape,p={...h};if(i)for(const x in i){if(!(x in h))throw new Error(`Unrecognized key: "${x}"`);i[x]&&(p[x]=e?new e({type:"optional",innerType:h[x]}):h[x])}else for(const x in h)p[x]=e?new e({type:"optional",innerType:h[x]}):h[x];return Ii(this,"shape",p),p},checks:[]});return ri(s,d)}function JA(e,s,i){const r=ii(s._zod.def,{get shape(){const o=s._zod.def.shape,u={...o};if(i)for(const d in i){if(!(d in u))throw new Error(`Unrecognized key: "${d}"`);i[d]&&(u[d]=new e({type:"nonoptional",innerType:o[d]}))}else for(const d in o)u[d]=new e({type:"nonoptional",innerType:o[d]});return Ii(this,"shape",u),u}});return ri(s,r)}function Er(e,s=0){if(e.aborted===!0)return!0;for(let i=s;i<e.issues.length;i++)if(e.issues[i]?.continue!==!0)return!0;return!1}function Dr(e,s){return s.map(i=>{var r;return(r=i).path??(r.path=[]),i.path.unshift(e),i})}function Bc(e){return typeof e=="string"?e:e?.message}function si(e,s,i){const r={...e,path:e.path??[]};if(!e.message){const o=Bc(e.inst?._zod.def?.error?.(e))??Bc(s?.error?.(e))??Bc(i.customError?.(e))??Bc(i.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,s?.reportInput||delete r.input,r}function Af(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function fo(...e){const[s,i,r]=e;return typeof s=="string"?{message:s,code:"custom",input:i,inst:r}:{...s}}const Uv=(e,s)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:s,enumerable:!1}),e.message=JSON.stringify(s,Zh,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Pv=oe("$ZodError",Uv),Gv=oe("$ZodError",Uv,{Parent:Error});function WA(e,s=i=>i.message){const i={},r=[];for(const o of e.issues)o.path.length>0?(i[o.path[0]]=i[o.path[0]]||[],i[o.path[0]].push(s(o))):r.push(s(o));return{formErrors:r,fieldErrors:i}}function e5(e,s=i=>i.message){const i={_errors:[]},r=o=>{for(const u of o.issues)if(u.code==="invalid_union"&&u.errors.length)u.errors.map(d=>r({issues:d}));else if(u.code==="invalid_key")r({issues:u.issues});else if(u.code==="invalid_element")r({issues:u.issues});else if(u.path.length===0)i._errors.push(s(u));else{let d=i,h=0;for(;h<u.path.length;){const p=u.path[h];h===u.path.length-1?(d[p]=d[p]||{_errors:[]},d[p]._errors.push(s(u))):d[p]=d[p]||{_errors:[]},d=d[p],h++}}};return r(e),i}const Tf=e=>(s,i,r,o)=>{const u=r?Object.assign(r,{async:!1}):{async:!1},d=s._zod.run({value:i,issues:[]},u);if(d instanceof Promise)throw new Br;if(d.issues.length){const h=new(o?.Err??e)(d.issues.map(p=>si(p,u,ni())));throw qv(h,o?.callee),h}return d.value},_f=e=>async(s,i,r,o)=>{const u=r?Object.assign(r,{async:!0}):{async:!0};let d=s._zod.run({value:i,issues:[]},u);if(d instanceof Promise&&(d=await d),d.issues.length){const h=new(o?.Err??e)(d.issues.map(p=>si(p,u,ni())));throw qv(h,o?.callee),h}return d.value},Ou=e=>(s,i,r)=>{const o=r?{...r,async:!1}:{async:!1},u=s._zod.run({value:i,issues:[]},o);if(u instanceof Promise)throw new Br;return u.issues.length?{success:!1,error:new(e??Pv)(u.issues.map(d=>si(d,o,ni())))}:{success:!0,data:u.value}},t5=Ou(Gv),Ru=e=>async(s,i,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let u=s._zod.run({value:i,issues:[]},o);return u instanceof Promise&&(u=await u),u.issues.length?{success:!1,error:new e(u.issues.map(d=>si(d,o,ni())))}:{success:!0,data:u.value}},n5=Ru(Gv),s5=e=>(s,i,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Tf(e)(s,i,o)},a5=e=>(s,i,r)=>Tf(e)(s,i,r),i5=e=>async(s,i,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return _f(e)(s,i,o)},r5=e=>async(s,i,r)=>_f(e)(s,i,r),l5=e=>(s,i,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ou(e)(s,i,o)},o5=e=>(s,i,r)=>Ou(e)(s,i,r),c5=e=>async(s,i,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ru(e)(s,i,o)},u5=e=>async(s,i,r)=>Ru(e)(s,i,r),d5=/^[cC][^\s-]{8,}$/,m5=/^[0-9a-z]+$/,h5=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,f5=/^[0-9a-vA-V]{20}$/,p5=/^[A-Za-z0-9]{27}$/,g5=/^[a-zA-Z0-9_-]{21}$/,x5=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,y5=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Sy=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,b5=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,v5="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function j5(){return new RegExp(v5,"u")}const N5=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,w5=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,S5=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,z5=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,k5=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Vv=/^[A-Za-z0-9_-]*$/,C5=/^\+[1-9]\d{6,14}$/,Hv="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",A5=new RegExp(`^${Hv}$`);function Kv(e){const s="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${s}`:e.precision===0?`${s}:[0-5]\\d`:`${s}:[0-5]\\d\\.\\d{${e.precision}}`:`${s}(?::[0-5]\\d(?:\\.\\d+)?)?`}function T5(e){return new RegExp(`^${Kv(e)}$`)}function _5(e){const s=Kv({precision:e.precision}),i=["Z"];e.local&&i.push(""),e.offset&&i.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${s}(?:${i.join("|")})`;return new RegExp(`^${Hv}T(?:${r})$`)}const E5=e=>{const s=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${s}$`)},D5=/^-?\d+$/,Qv=/^-?\d+(?:\.\d+)?$/,O5=/^(?:true|false)$/i,R5=/^[^A-Z]*$/,L5=/^[^a-z]*$/,Zn=oe("$ZodCheck",(e,s)=>{var i;e._zod??(e._zod={}),e._zod.def=s,(i=e._zod).onattach??(i.onattach=[])}),Zv={number:"number",bigint:"bigint",object:"date"},Fv=oe("$ZodCheckLessThan",(e,s)=>{Zn.init(e,s);const i=Zv[typeof s.value];e._zod.onattach.push(r=>{const o=r._zod.bag,u=(s.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;s.value<u&&(s.inclusive?o.maximum=s.value:o.exclusiveMaximum=s.value)}),e._zod.check=r=>{(s.inclusive?r.value<=s.value:r.value<s.value)||r.issues.push({origin:i,code:"too_big",maximum:typeof s.value=="object"?s.value.getTime():s.value,input:r.value,inclusive:s.inclusive,inst:e,continue:!s.abort})}}),Yv=oe("$ZodCheckGreaterThan",(e,s)=>{Zn.init(e,s);const i=Zv[typeof s.value];e._zod.onattach.push(r=>{const o=r._zod.bag,u=(s.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;s.value>u&&(s.inclusive?o.minimum=s.value:o.exclusiveMinimum=s.value)}),e._zod.check=r=>{(s.inclusive?r.value>=s.value:r.value>s.value)||r.issues.push({origin:i,code:"too_small",minimum:typeof s.value=="object"?s.value.getTime():s.value,input:r.value,inclusive:s.inclusive,inst:e,continue:!s.abort})}}),M5=oe("$ZodCheckMultipleOf",(e,s)=>{Zn.init(e,s),e._zod.onattach.push(i=>{var r;(r=i._zod.bag).multipleOf??(r.multipleOf=s.value)}),e._zod.check=i=>{if(typeof i.value!=typeof s.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof i.value=="bigint"?i.value%s.value===BigInt(0):IA(i.value,s.value)===0)||i.issues.push({origin:typeof i.value,code:"not_multiple_of",divisor:s.value,input:i.value,inst:e,continue:!s.abort})}}),$5=oe("$ZodCheckNumberFormat",(e,s)=>{Zn.init(e,s),s.format=s.format||"float64";const i=s.format?.includes("int"),r=i?"int":"number",[o,u]=HA[s.format];e._zod.onattach.push(d=>{const h=d._zod.bag;h.format=s.format,h.minimum=o,h.maximum=u,i&&(h.pattern=D5)}),e._zod.check=d=>{const h=d.value;if(i){if(!Number.isInteger(h)){d.issues.push({expected:r,format:s.format,code:"invalid_type",continue:!1,input:h,inst:e});return}if(!Number.isSafeInteger(h)){h>0?d.issues.push({input:h,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!s.abort}):d.issues.push({input:h,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!s.abort});return}}h<o&&d.issues.push({origin:"number",input:h,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!s.abort}),h>u&&d.issues.push({origin:"number",input:h,code:"too_big",maximum:u,inclusive:!0,inst:e,continue:!s.abort})}}),B5=oe("$ZodCheckMaxLength",(e,s)=>{var i;Zn.init(e,s),(i=e._zod.def).when??(i.when=r=>{const o=r.value;return!kf(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;s.maximum<o&&(r._zod.bag.maximum=s.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=s.maximum)return;const d=Af(o);r.issues.push({origin:d,code:"too_big",maximum:s.maximum,inclusive:!0,input:o,inst:e,continue:!s.abort})}}),q5=oe("$ZodCheckMinLength",(e,s)=>{var i;Zn.init(e,s),(i=e._zod.def).when??(i.when=r=>{const o=r.value;return!kf(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;s.minimum>o&&(r._zod.bag.minimum=s.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=s.minimum)return;const d=Af(o);r.issues.push({origin:d,code:"too_small",minimum:s.minimum,inclusive:!0,input:o,inst:e,continue:!s.abort})}}),I5=oe("$ZodCheckLengthEquals",(e,s)=>{var i;Zn.init(e,s),(i=e._zod.def).when??(i.when=r=>{const o=r.value;return!kf(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=s.length,o.maximum=s.length,o.length=s.length}),e._zod.check=r=>{const o=r.value,u=o.length;if(u===s.length)return;const d=Af(o),h=u>s.length;r.issues.push({origin:d,...h?{code:"too_big",maximum:s.length}:{code:"too_small",minimum:s.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!s.abort})}}),Lu=oe("$ZodCheckStringFormat",(e,s)=>{var i,r;Zn.init(e,s),e._zod.onattach.push(o=>{const u=o._zod.bag;u.format=s.format,s.pattern&&(u.patterns??(u.patterns=new Set),u.patterns.add(s.pattern))}),s.pattern?(i=e._zod).check??(i.check=o=>{s.pattern.lastIndex=0,!s.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:s.format,input:o.value,...s.pattern?{pattern:s.pattern.toString()}:{},inst:e,continue:!s.abort})}):(r=e._zod).check??(r.check=()=>{})}),U5=oe("$ZodCheckRegex",(e,s)=>{Lu.init(e,s),e._zod.check=i=>{s.pattern.lastIndex=0,!s.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:"regex",input:i.value,pattern:s.pattern.toString(),inst:e,continue:!s.abort})}}),P5=oe("$ZodCheckLowerCase",(e,s)=>{s.pattern??(s.pattern=R5),Lu.init(e,s)}),G5=oe("$ZodCheckUpperCase",(e,s)=>{s.pattern??(s.pattern=L5),Lu.init(e,s)}),V5=oe("$ZodCheckIncludes",(e,s)=>{Zn.init(e,s);const i=Zr(s.includes),r=new RegExp(typeof s.position=="number"?`^.{${s.position}}${i}`:i);s.pattern=r,e._zod.onattach.push(o=>{const u=o._zod.bag;u.patterns??(u.patterns=new Set),u.patterns.add(r)}),e._zod.check=o=>{o.value.includes(s.includes,s.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:s.includes,input:o.value,inst:e,continue:!s.abort})}}),H5=oe("$ZodCheckStartsWith",(e,s)=>{Zn.init(e,s);const i=new RegExp(`^${Zr(s.prefix)}.*`);s.pattern??(s.pattern=i),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(i)}),e._zod.check=r=>{r.value.startsWith(s.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:s.prefix,input:r.value,inst:e,continue:!s.abort})}}),K5=oe("$ZodCheckEndsWith",(e,s)=>{Zn.init(e,s);const i=new RegExp(`.*${Zr(s.suffix)}$`);s.pattern??(s.pattern=i),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(i)}),e._zod.check=r=>{r.value.endsWith(s.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:s.suffix,input:r.value,inst:e,continue:!s.abort})}}),Q5=oe("$ZodCheckOverwrite",(e,s)=>{Zn.init(e,s),e._zod.check=i=>{i.value=s.tx(i.value)}});class Z5{constructor(s=[]){this.content=[],this.indent=0,this&&(this.args=s)}indented(s){this.indent+=1,s(this),this.indent-=1}write(s){if(typeof s=="function"){s(this,{execution:"sync"}),s(this,{execution:"async"});return}const r=s.split(`
14
- `).filter(d=>d),o=Math.min(...r.map(d=>d.length-d.trimStart().length)),u=r.map(d=>d.slice(o)).map(d=>" ".repeat(this.indent*2)+d);for(const d of u)this.content.push(d)}compile(){const s=Function,i=this?.args,o=[...(this?.content??[""]).map(u=>` ${u}`)];return new s(...i,o.join(`
15
- `))}}const F5={major:4,minor:3,patch:6},Bt=oe("$ZodType",(e,s)=>{var i;e??(e={}),e._zod.def=s,e._zod.bag=e._zod.bag||{},e._zod.version=F5;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const u of o._zod.onattach)u(e);if(r.length===0)(i=e._zod).deferred??(i.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(d,h,p)=>{let x=Er(d),b;for(const v of h){if(v._zod.def.when){if(!v._zod.def.when(d))continue}else if(x)continue;const N=d.issues.length,z=v._zod.check(d);if(z instanceof Promise&&p?.async===!1)throw new Br;if(b||z instanceof Promise)b=(b??Promise.resolve()).then(async()=>{await z,d.issues.length!==N&&(x||(x=Er(d,N)))});else{if(d.issues.length===N)continue;x||(x=Er(d,N))}}return b?b.then(()=>d):d},u=(d,h,p)=>{if(Er(d))return d.aborted=!0,d;const x=o(h,r,p);if(x instanceof Promise){if(p.async===!1)throw new Br;return x.then(b=>e._zod.parse(b,p))}return e._zod.parse(x,p)};e._zod.run=(d,h)=>{if(h.skipChecks)return e._zod.parse(d,h);if(h.direction==="backward"){const x=e._zod.parse({value:d.value,issues:[]},{...h,skipChecks:!0});return x instanceof Promise?x.then(b=>u(b,d,h)):u(x,d,h)}const p=e._zod.parse(d,h);if(p instanceof Promise){if(h.async===!1)throw new Br;return p.then(x=>o(x,r,h))}return o(p,r,h)}}wt(e,"~standard",()=>({validate:o=>{try{const u=t5(e,o);return u.success?{value:u.data}:{issues:u.error?.issues}}catch{return n5(e,o).then(d=>d.success?{value:d.data}:{issues:d.error?.issues})}},vendor:"zod",version:1}))}),Ef=oe("$ZodString",(e,s)=>{Bt.init(e,s),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??E5(e._zod.bag),e._zod.parse=(i,r)=>{if(s.coerce)try{i.value=String(i.value)}catch{}return typeof i.value=="string"||i.issues.push({expected:"string",code:"invalid_type",input:i.value,inst:e}),i}}),Mt=oe("$ZodStringFormat",(e,s)=>{Lu.init(e,s),Ef.init(e,s)}),Y5=oe("$ZodGUID",(e,s)=>{s.pattern??(s.pattern=y5),Mt.init(e,s)}),X5=oe("$ZodUUID",(e,s)=>{if(s.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[s.version];if(r===void 0)throw new Error(`Invalid UUID version: "${s.version}"`);s.pattern??(s.pattern=Sy(r))}else s.pattern??(s.pattern=Sy());Mt.init(e,s)}),J5=oe("$ZodEmail",(e,s)=>{s.pattern??(s.pattern=b5),Mt.init(e,s)}),W5=oe("$ZodURL",(e,s)=>{Mt.init(e,s),e._zod.check=i=>{try{const r=i.value.trim(),o=new URL(r);s.hostname&&(s.hostname.lastIndex=0,s.hostname.test(o.hostname)||i.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:s.hostname.source,input:i.value,inst:e,continue:!s.abort})),s.protocol&&(s.protocol.lastIndex=0,s.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||i.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:s.protocol.source,input:i.value,inst:e,continue:!s.abort})),s.normalize?i.value=o.href:i.value=r;return}catch{i.issues.push({code:"invalid_format",format:"url",input:i.value,inst:e,continue:!s.abort})}}}),e4=oe("$ZodEmoji",(e,s)=>{s.pattern??(s.pattern=j5()),Mt.init(e,s)}),t4=oe("$ZodNanoID",(e,s)=>{s.pattern??(s.pattern=g5),Mt.init(e,s)}),n4=oe("$ZodCUID",(e,s)=>{s.pattern??(s.pattern=d5),Mt.init(e,s)}),s4=oe("$ZodCUID2",(e,s)=>{s.pattern??(s.pattern=m5),Mt.init(e,s)}),a4=oe("$ZodULID",(e,s)=>{s.pattern??(s.pattern=h5),Mt.init(e,s)}),i4=oe("$ZodXID",(e,s)=>{s.pattern??(s.pattern=f5),Mt.init(e,s)}),r4=oe("$ZodKSUID",(e,s)=>{s.pattern??(s.pattern=p5),Mt.init(e,s)}),l4=oe("$ZodISODateTime",(e,s)=>{s.pattern??(s.pattern=_5(s)),Mt.init(e,s)}),o4=oe("$ZodISODate",(e,s)=>{s.pattern??(s.pattern=A5),Mt.init(e,s)}),c4=oe("$ZodISOTime",(e,s)=>{s.pattern??(s.pattern=T5(s)),Mt.init(e,s)}),u4=oe("$ZodISODuration",(e,s)=>{s.pattern??(s.pattern=x5),Mt.init(e,s)}),d4=oe("$ZodIPv4",(e,s)=>{s.pattern??(s.pattern=N5),Mt.init(e,s),e._zod.bag.format="ipv4"}),m4=oe("$ZodIPv6",(e,s)=>{s.pattern??(s.pattern=w5),Mt.init(e,s),e._zod.bag.format="ipv6",e._zod.check=i=>{try{new URL(`http://[${i.value}]`)}catch{i.issues.push({code:"invalid_format",format:"ipv6",input:i.value,inst:e,continue:!s.abort})}}}),h4=oe("$ZodCIDRv4",(e,s)=>{s.pattern??(s.pattern=S5),Mt.init(e,s)}),f4=oe("$ZodCIDRv6",(e,s)=>{s.pattern??(s.pattern=z5),Mt.init(e,s),e._zod.check=i=>{const r=i.value.split("/");try{if(r.length!==2)throw new Error;const[o,u]=r;if(!u)throw new Error;const d=Number(u);if(`${d}`!==u)throw new Error;if(d<0||d>128)throw new Error;new URL(`http://[${o}]`)}catch{i.issues.push({code:"invalid_format",format:"cidrv6",input:i.value,inst:e,continue:!s.abort})}}});function Xv(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const p4=oe("$ZodBase64",(e,s)=>{s.pattern??(s.pattern=k5),Mt.init(e,s),e._zod.bag.contentEncoding="base64",e._zod.check=i=>{Xv(i.value)||i.issues.push({code:"invalid_format",format:"base64",input:i.value,inst:e,continue:!s.abort})}});function g4(e){if(!Vv.test(e))return!1;const s=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),i=s.padEnd(Math.ceil(s.length/4)*4,"=");return Xv(i)}const x4=oe("$ZodBase64URL",(e,s)=>{s.pattern??(s.pattern=Vv),Mt.init(e,s),e._zod.bag.contentEncoding="base64url",e._zod.check=i=>{g4(i.value)||i.issues.push({code:"invalid_format",format:"base64url",input:i.value,inst:e,continue:!s.abort})}}),y4=oe("$ZodE164",(e,s)=>{s.pattern??(s.pattern=C5),Mt.init(e,s)});function b4(e,s=null){try{const i=e.split(".");if(i.length!==3)return!1;const[r]=i;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||s&&(!("alg"in o)||o.alg!==s))}catch{return!1}}const v4=oe("$ZodJWT",(e,s)=>{Mt.init(e,s),e._zod.check=i=>{b4(i.value,s.alg)||i.issues.push({code:"invalid_format",format:"jwt",input:i.value,inst:e,continue:!s.abort})}}),Jv=oe("$ZodNumber",(e,s)=>{Bt.init(e,s),e._zod.pattern=e._zod.bag.pattern??Qv,e._zod.parse=(i,r)=>{if(s.coerce)try{i.value=Number(i.value)}catch{}const o=i.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return i;const u=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return i.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...u?{received:u}:{}}),i}}),j4=oe("$ZodNumberFormat",(e,s)=>{$5.init(e,s),Jv.init(e,s)}),N4=oe("$ZodBoolean",(e,s)=>{Bt.init(e,s),e._zod.pattern=O5,e._zod.parse=(i,r)=>{if(s.coerce)try{i.value=!!i.value}catch{}const o=i.value;return typeof o=="boolean"||i.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),i}}),w4=oe("$ZodUnknown",(e,s)=>{Bt.init(e,s),e._zod.parse=i=>i}),S4=oe("$ZodNever",(e,s)=>{Bt.init(e,s),e._zod.parse=(i,r)=>(i.issues.push({expected:"never",code:"invalid_type",input:i.value,inst:e}),i)});function zy(e,s,i){e.issues.length&&s.issues.push(...Dr(i,e.issues)),s.value[i]=e.value}const z4=oe("$ZodArray",(e,s)=>{Bt.init(e,s),e._zod.parse=(i,r)=>{const o=i.value;if(!Array.isArray(o))return i.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),i;i.value=Array(o.length);const u=[];for(let d=0;d<o.length;d++){const h=o[d],p=s.element._zod.run({value:h,issues:[]},r);p instanceof Promise?u.push(p.then(x=>zy(x,i,d))):zy(p,i,d)}return u.length?Promise.all(u).then(()=>i):i}});function xu(e,s,i,r,o){if(e.issues.length){if(o&&!(i in r))return;s.issues.push(...Dr(i,e.issues))}e.value===void 0?i in r&&(s.value[i]=void 0):s.value[i]=e.value}function Wv(e){const s=Object.keys(e.shape);for(const r of s)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const i=VA(e.shape);return{...e,keys:s,keySet:new Set(s),numKeys:s.length,optionalKeys:new Set(i)}}function ej(e,s,i,r,o,u){const d=[],h=o.keySet,p=o.catchall._zod,x=p.def.type,b=p.optout==="optional";for(const v in s){if(h.has(v))continue;if(x==="never"){d.push(v);continue}const N=p.run({value:s[v],issues:[]},r);N instanceof Promise?e.push(N.then(z=>xu(z,i,v,s,b))):xu(N,i,v,s,b)}return d.length&&i.issues.push({code:"unrecognized_keys",keys:d,input:s,inst:u}),e.length?Promise.all(e).then(()=>i):i}const k4=oe("$ZodObject",(e,s)=>{if(Bt.init(e,s),!Object.getOwnPropertyDescriptor(s,"shape")?.get){const h=s.shape;Object.defineProperty(s,"shape",{get:()=>{const p={...h};return Object.defineProperty(s,"shape",{value:p}),p}})}const r=Du(()=>Wv(s));wt(e._zod,"propValues",()=>{const h=s.shape,p={};for(const x in h){const b=h[x]._zod;if(b.values){p[x]??(p[x]=new Set);for(const v of b.values)p[x].add(v)}}return p});const o=ho,u=s.catchall;let d;e._zod.parse=(h,p)=>{d??(d=r.value);const x=h.value;if(!o(x))return h.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),h;h.value={};const b=[],v=d.shape;for(const N of d.keys){const z=v[N],T=z._zod.optout==="optional",w=z._zod.run({value:x[N],issues:[]},p);w instanceof Promise?b.push(w.then(A=>xu(A,h,N,x,T))):xu(w,h,N,x,T)}return u?ej(b,x,h,p,r.value,e):b.length?Promise.all(b).then(()=>h):h}}),C4=oe("$ZodObjectJIT",(e,s)=>{k4.init(e,s);const i=e._zod.parse,r=Du(()=>Wv(s)),o=N=>{const z=new Z5(["shape","payload","ctx"]),T=r.value,w=I=>{const C=wy(I);return`shape[${C}]._zod.run({ value: input[${C}], issues: [] }, ctx)`};z.write("const input = payload.value;");const A=Object.create(null);let D=0;for(const I of T.keys)A[I]=`key_${D++}`;z.write("const newResult = {};");for(const I of T.keys){const C=A[I],L=wy(I),_=N[I]?._zod?.optout==="optional";z.write(`const ${C} = ${w(I)};`),_?z.write(`
16
- if (${C}.issues.length) {
17
- if (${L} in input) {
18
- payload.issues = payload.issues.concat(${C}.issues.map(iss => ({
19
- ...iss,
20
- path: iss.path ? [${L}, ...iss.path] : [${L}]
21
- })));
22
- }
23
- }
24
-
25
- if (${C}.value === undefined) {
26
- if (${L} in input) {
27
- newResult[${L}] = undefined;
28
- }
29
- } else {
30
- newResult[${L}] = ${C}.value;
31
- }
32
-
33
- `):z.write(`
34
- if (${C}.issues.length) {
35
- payload.issues = payload.issues.concat(${C}.issues.map(iss => ({
36
- ...iss,
37
- path: iss.path ? [${L}, ...iss.path] : [${L}]
38
- })));
39
- }
40
-
41
- if (${C}.value === undefined) {
42
- if (${L} in input) {
43
- newResult[${L}] = undefined;
44
- }
45
- } else {
46
- newResult[${L}] = ${C}.value;
47
- }
48
-
49
- `)}z.write("payload.value = newResult;"),z.write("return payload;");const U=z.compile();return(I,C)=>U(N,I,C)};let u;const d=ho,h=!$v.jitless,x=h&&PA.value,b=s.catchall;let v;e._zod.parse=(N,z)=>{v??(v=r.value);const T=N.value;return d(T)?h&&x&&z?.async===!1&&z.jitless!==!0?(u||(u=o(s.shape)),N=u(N,z),b?ej([],T,N,z,v,e):N):i(N,z):(N.issues.push({expected:"object",code:"invalid_type",input:T,inst:e}),N)}});function ky(e,s,i,r){for(const u of e)if(u.issues.length===0)return s.value=u.value,s;const o=e.filter(u=>!Er(u));return o.length===1?(s.value=o[0].value,o[0]):(s.issues.push({code:"invalid_union",input:s.value,inst:i,errors:e.map(u=>u.issues.map(d=>si(d,r,ni())))}),s)}const tj=oe("$ZodUnion",(e,s)=>{Bt.init(e,s),wt(e._zod,"optin",()=>s.options.some(o=>o._zod.optin==="optional")?"optional":void 0),wt(e._zod,"optout",()=>s.options.some(o=>o._zod.optout==="optional")?"optional":void 0),wt(e._zod,"values",()=>{if(s.options.every(o=>o._zod.values))return new Set(s.options.flatMap(o=>Array.from(o._zod.values)))}),wt(e._zod,"pattern",()=>{if(s.options.every(o=>o._zod.pattern)){const o=s.options.map(u=>u._zod.pattern);return new RegExp(`^(${o.map(u=>Cf(u.source)).join("|")})$`)}});const i=s.options.length===1,r=s.options[0]._zod.run;e._zod.parse=(o,u)=>{if(i)return r(o,u);let d=!1;const h=[];for(const p of s.options){const x=p._zod.run({value:o.value,issues:[]},u);if(x instanceof Promise)h.push(x),d=!0;else{if(x.issues.length===0)return x;h.push(x)}}return d?Promise.all(h).then(p=>ky(p,o,e,u)):ky(h,o,e,u)}}),A4=oe("$ZodDiscriminatedUnion",(e,s)=>{s.inclusive=!1,tj.init(e,s);const i=e._zod.parse;wt(e._zod,"propValues",()=>{const o={};for(const u of s.options){const d=u._zod.propValues;if(!d||Object.keys(d).length===0)throw new Error(`Invalid discriminated union option at index "${s.options.indexOf(u)}"`);for(const[h,p]of Object.entries(d)){o[h]||(o[h]=new Set);for(const x of p)o[h].add(x)}}return o});const r=Du(()=>{const o=s.options,u=new Map;for(const d of o){const h=d._zod.propValues?.[s.discriminator];if(!h||h.size===0)throw new Error(`Invalid discriminated union option at index "${s.options.indexOf(d)}"`);for(const p of h){if(u.has(p))throw new Error(`Duplicate discriminator value "${String(p)}"`);u.set(p,d)}}return u});e._zod.parse=(o,u)=>{const d=o.value;if(!ho(d))return o.issues.push({code:"invalid_type",expected:"object",input:d,inst:e}),o;const h=r.value.get(d?.[s.discriminator]);return h?h._zod.run(o,u):s.unionFallback?i(o,u):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:s.discriminator,input:d,path:[s.discriminator],inst:e}),o)}}),T4=oe("$ZodIntersection",(e,s)=>{Bt.init(e,s),e._zod.parse=(i,r)=>{const o=i.value,u=s.left._zod.run({value:o,issues:[]},r),d=s.right._zod.run({value:o,issues:[]},r);return u instanceof Promise||d instanceof Promise?Promise.all([u,d]).then(([p,x])=>Cy(i,p,x)):Cy(i,u,d)}});function Fh(e,s){if(e===s)return{valid:!0,data:e};if(e instanceof Date&&s instanceof Date&&+e==+s)return{valid:!0,data:e};if(Qr(e)&&Qr(s)){const i=Object.keys(s),r=Object.keys(e).filter(u=>i.indexOf(u)!==-1),o={...e,...s};for(const u of r){const d=Fh(e[u],s[u]);if(!d.valid)return{valid:!1,mergeErrorPath:[u,...d.mergeErrorPath]};o[u]=d.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(s)){if(e.length!==s.length)return{valid:!1,mergeErrorPath:[]};const i=[];for(let r=0;r<e.length;r++){const o=e[r],u=s[r],d=Fh(o,u);if(!d.valid)return{valid:!1,mergeErrorPath:[r,...d.mergeErrorPath]};i.push(d.data)}return{valid:!0,data:i}}return{valid:!1,mergeErrorPath:[]}}function Cy(e,s,i){const r=new Map;let o;for(const h of s.issues)if(h.code==="unrecognized_keys"){o??(o=h);for(const p of h.keys)r.has(p)||r.set(p,{}),r.get(p).l=!0}else e.issues.push(h);for(const h of i.issues)if(h.code==="unrecognized_keys")for(const p of h.keys)r.has(p)||r.set(p,{}),r.get(p).r=!0;else e.issues.push(h);const u=[...r].filter(([,h])=>h.l&&h.r).map(([h])=>h);if(u.length&&o&&e.issues.push({...o,keys:u}),Er(e))return e;const d=Fh(s.value,i.value);if(!d.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(d.mergeErrorPath)}`);return e.value=d.data,e}const _4=oe("$ZodRecord",(e,s)=>{Bt.init(e,s),e._zod.parse=(i,r)=>{const o=i.value;if(!Qr(o))return i.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),i;const u=[],d=s.keyType._zod.values;if(d){i.value={};const h=new Set;for(const x of d)if(typeof x=="string"||typeof x=="number"||typeof x=="symbol"){h.add(typeof x=="number"?x.toString():x);const b=s.valueType._zod.run({value:o[x],issues:[]},r);b instanceof Promise?u.push(b.then(v=>{v.issues.length&&i.issues.push(...Dr(x,v.issues)),i.value[x]=v.value})):(b.issues.length&&i.issues.push(...Dr(x,b.issues)),i.value[x]=b.value)}let p;for(const x in o)h.has(x)||(p=p??[],p.push(x));p&&p.length>0&&i.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:p})}else{i.value={};for(const h of Reflect.ownKeys(o)){if(h==="__proto__")continue;let p=s.keyType._zod.run({value:h,issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof h=="string"&&Qv.test(h)&&p.issues.length){const v=s.keyType._zod.run({value:Number(h),issues:[]},r);if(v instanceof Promise)throw new Error("Async schemas not supported in object keys currently");v.issues.length===0&&(p=v)}if(p.issues.length){s.mode==="loose"?i.value[h]=o[h]:i.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map(v=>si(v,r,ni())),input:h,path:[h],inst:e});continue}const b=s.valueType._zod.run({value:o[h],issues:[]},r);b instanceof Promise?u.push(b.then(v=>{v.issues.length&&i.issues.push(...Dr(h,v.issues)),i.value[p.value]=v.value})):(b.issues.length&&i.issues.push(...Dr(h,b.issues)),i.value[p.value]=b.value)}}return u.length?Promise.all(u).then(()=>i):i}}),E4=oe("$ZodEnum",(e,s)=>{Bt.init(e,s);const i=Bv(s.entries),r=new Set(i);e._zod.values=r,e._zod.pattern=new RegExp(`^(${i.filter(o=>GA.has(typeof o)).map(o=>typeof o=="string"?Zr(o):o.toString()).join("|")})$`),e._zod.parse=(o,u)=>{const d=o.value;return r.has(d)||o.issues.push({code:"invalid_value",values:i,input:d,inst:e}),o}}),D4=oe("$ZodLiteral",(e,s)=>{if(Bt.init(e,s),s.values.length===0)throw new Error("Cannot create literal schema with no valid values");const i=new Set(s.values);e._zod.values=i,e._zod.pattern=new RegExp(`^(${s.values.map(r=>typeof r=="string"?Zr(r):r?Zr(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const u=r.value;return i.has(u)||r.issues.push({code:"invalid_value",values:s.values,input:u,inst:e}),r}}),O4=oe("$ZodTransform",(e,s)=>{Bt.init(e,s),e._zod.parse=(i,r)=>{if(r.direction==="backward")throw new Mv(e.constructor.name);const o=s.transform(i.value,i);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(d=>(i.value=d,i));if(o instanceof Promise)throw new Br;return i.value=o,i}});function Ay(e,s){return e.issues.length&&s===void 0?{issues:[],value:void 0}:e}const nj=oe("$ZodOptional",(e,s)=>{Bt.init(e,s),e._zod.optin="optional",e._zod.optout="optional",wt(e._zod,"values",()=>s.innerType._zod.values?new Set([...s.innerType._zod.values,void 0]):void 0),wt(e._zod,"pattern",()=>{const i=s.innerType._zod.pattern;return i?new RegExp(`^(${Cf(i.source)})?$`):void 0}),e._zod.parse=(i,r)=>{if(s.innerType._zod.optin==="optional"){const o=s.innerType._zod.run(i,r);return o instanceof Promise?o.then(u=>Ay(u,i.value)):Ay(o,i.value)}return i.value===void 0?i:s.innerType._zod.run(i,r)}}),R4=oe("$ZodExactOptional",(e,s)=>{nj.init(e,s),wt(e._zod,"values",()=>s.innerType._zod.values),wt(e._zod,"pattern",()=>s.innerType._zod.pattern),e._zod.parse=(i,r)=>s.innerType._zod.run(i,r)}),L4=oe("$ZodNullable",(e,s)=>{Bt.init(e,s),wt(e._zod,"optin",()=>s.innerType._zod.optin),wt(e._zod,"optout",()=>s.innerType._zod.optout),wt(e._zod,"pattern",()=>{const i=s.innerType._zod.pattern;return i?new RegExp(`^(${Cf(i.source)}|null)$`):void 0}),wt(e._zod,"values",()=>s.innerType._zod.values?new Set([...s.innerType._zod.values,null]):void 0),e._zod.parse=(i,r)=>i.value===null?i:s.innerType._zod.run(i,r)}),M4=oe("$ZodDefault",(e,s)=>{Bt.init(e,s),e._zod.optin="optional",wt(e._zod,"values",()=>s.innerType._zod.values),e._zod.parse=(i,r)=>{if(r.direction==="backward")return s.innerType._zod.run(i,r);if(i.value===void 0)return i.value=s.defaultValue,i;const o=s.innerType._zod.run(i,r);return o instanceof Promise?o.then(u=>Ty(u,s)):Ty(o,s)}});function Ty(e,s){return e.value===void 0&&(e.value=s.defaultValue),e}const $4=oe("$ZodPrefault",(e,s)=>{Bt.init(e,s),e._zod.optin="optional",wt(e._zod,"values",()=>s.innerType._zod.values),e._zod.parse=(i,r)=>(r.direction==="backward"||i.value===void 0&&(i.value=s.defaultValue),s.innerType._zod.run(i,r))}),B4=oe("$ZodNonOptional",(e,s)=>{Bt.init(e,s),wt(e._zod,"values",()=>{const i=s.innerType._zod.values;return i?new Set([...i].filter(r=>r!==void 0)):void 0}),e._zod.parse=(i,r)=>{const o=s.innerType._zod.run(i,r);return o instanceof Promise?o.then(u=>_y(u,e)):_y(o,e)}});function _y(e,s){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:s}),e}const q4=oe("$ZodCatch",(e,s)=>{Bt.init(e,s),wt(e._zod,"optin",()=>s.innerType._zod.optin),wt(e._zod,"optout",()=>s.innerType._zod.optout),wt(e._zod,"values",()=>s.innerType._zod.values),e._zod.parse=(i,r)=>{if(r.direction==="backward")return s.innerType._zod.run(i,r);const o=s.innerType._zod.run(i,r);return o instanceof Promise?o.then(u=>(i.value=u.value,u.issues.length&&(i.value=s.catchValue({...i,error:{issues:u.issues.map(d=>si(d,r,ni()))},input:i.value}),i.issues=[]),i)):(i.value=o.value,o.issues.length&&(i.value=s.catchValue({...i,error:{issues:o.issues.map(u=>si(u,r,ni()))},input:i.value}),i.issues=[]),i)}}),I4=oe("$ZodPipe",(e,s)=>{Bt.init(e,s),wt(e._zod,"values",()=>s.in._zod.values),wt(e._zod,"optin",()=>s.in._zod.optin),wt(e._zod,"optout",()=>s.out._zod.optout),wt(e._zod,"propValues",()=>s.in._zod.propValues),e._zod.parse=(i,r)=>{if(r.direction==="backward"){const u=s.out._zod.run(i,r);return u instanceof Promise?u.then(d=>qc(d,s.in,r)):qc(u,s.in,r)}const o=s.in._zod.run(i,r);return o instanceof Promise?o.then(u=>qc(u,s.out,r)):qc(o,s.out,r)}});function qc(e,s,i){return e.issues.length?(e.aborted=!0,e):s._zod.run({value:e.value,issues:e.issues},i)}const U4=oe("$ZodReadonly",(e,s)=>{Bt.init(e,s),wt(e._zod,"propValues",()=>s.innerType._zod.propValues),wt(e._zod,"values",()=>s.innerType._zod.values),wt(e._zod,"optin",()=>s.innerType?._zod?.optin),wt(e._zod,"optout",()=>s.innerType?._zod?.optout),e._zod.parse=(i,r)=>{if(r.direction==="backward")return s.innerType._zod.run(i,r);const o=s.innerType._zod.run(i,r);return o instanceof Promise?o.then(Ey):Ey(o)}});function Ey(e){return e.value=Object.freeze(e.value),e}const P4=oe("$ZodCustom",(e,s)=>{Zn.init(e,s),Bt.init(e,s),e._zod.parse=(i,r)=>i,e._zod.check=i=>{const r=i.value,o=s.fn(r);if(o instanceof Promise)return o.then(u=>Dy(u,i,r,e));Dy(o,i,r,e)}});function Dy(e,s,i,r){if(!e){const o={code:"custom",input:i,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),s.issues.push(fo(o))}}var Oy;class G4{constructor(){this._map=new WeakMap,this._idmap=new Map}add(s,...i){const r=i[0];return this._map.set(s,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,s),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(s){const i=this._map.get(s);return i&&typeof i=="object"&&"id"in i&&this._idmap.delete(i.id),this._map.delete(s),this}get(s){const i=s._zod.parent;if(i){const r={...this.get(i)??{}};delete r.id;const o={...r,...this._map.get(s)};return Object.keys(o).length?o:void 0}return this._map.get(s)}has(s){return this._map.has(s)}}function V4(){return new G4}(Oy=globalThis).__zod_globalRegistry??(Oy.__zod_globalRegistry=V4());const io=globalThis.__zod_globalRegistry;function H4(e,s){return new e({type:"string",...Be(s)})}function K4(e,s){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Be(s)})}function Ry(e,s){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Be(s)})}function Q4(e,s){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Be(s)})}function Z4(e,s){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Be(s)})}function F4(e,s){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Be(s)})}function Y4(e,s){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Be(s)})}function X4(e,s){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Be(s)})}function J4(e,s){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Be(s)})}function W4(e,s){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Be(s)})}function e3(e,s){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Be(s)})}function t3(e,s){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Be(s)})}function n3(e,s){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Be(s)})}function s3(e,s){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Be(s)})}function a3(e,s){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Be(s)})}function i3(e,s){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Be(s)})}function r3(e,s){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Be(s)})}function l3(e,s){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Be(s)})}function o3(e,s){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Be(s)})}function c3(e,s){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Be(s)})}function u3(e,s){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Be(s)})}function d3(e,s){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Be(s)})}function m3(e,s){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Be(s)})}function h3(e,s){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Be(s)})}function f3(e,s){return new e({type:"string",format:"date",check:"string_format",...Be(s)})}function p3(e,s){return new e({type:"string",format:"time",check:"string_format",precision:null,...Be(s)})}function g3(e,s){return new e({type:"string",format:"duration",check:"string_format",...Be(s)})}function x3(e,s){return new e({type:"number",checks:[],...Be(s)})}function y3(e,s){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Be(s)})}function b3(e,s){return new e({type:"boolean",...Be(s)})}function v3(e){return new e({type:"unknown"})}function j3(e,s){return new e({type:"never",...Be(s)})}function Ly(e,s){return new Fv({check:"less_than",...Be(s),value:e,inclusive:!1})}function yh(e,s){return new Fv({check:"less_than",...Be(s),value:e,inclusive:!0})}function My(e,s){return new Yv({check:"greater_than",...Be(s),value:e,inclusive:!1})}function bh(e,s){return new Yv({check:"greater_than",...Be(s),value:e,inclusive:!0})}function $y(e,s){return new M5({check:"multiple_of",...Be(s),value:e})}function sj(e,s){return new B5({check:"max_length",...Be(s),maximum:e})}function yu(e,s){return new q5({check:"min_length",...Be(s),minimum:e})}function aj(e,s){return new I5({check:"length_equals",...Be(s),length:e})}function N3(e,s){return new U5({check:"string_format",format:"regex",...Be(s),pattern:e})}function w3(e){return new P5({check:"string_format",format:"lowercase",...Be(e)})}function S3(e){return new G5({check:"string_format",format:"uppercase",...Be(e)})}function z3(e,s){return new V5({check:"string_format",format:"includes",...Be(s),includes:e})}function k3(e,s){return new H5({check:"string_format",format:"starts_with",...Be(s),prefix:e})}function C3(e,s){return new K5({check:"string_format",format:"ends_with",...Be(s),suffix:e})}function Wr(e){return new Q5({check:"overwrite",tx:e})}function A3(e){return Wr(s=>s.normalize(e))}function T3(){return Wr(e=>e.trim())}function _3(){return Wr(e=>e.toLowerCase())}function E3(){return Wr(e=>e.toUpperCase())}function D3(){return Wr(e=>UA(e))}function O3(e,s,i){return new e({type:"array",element:s,...Be(i)})}function R3(e,s,i){return new e({type:"custom",check:"custom",fn:s,...Be(i)})}function L3(e){const s=M3(i=>(i.addIssue=r=>{if(typeof r=="string")i.issues.push(fo(r,i.value,s._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=i.value),o.inst??(o.inst=s),o.continue??(o.continue=!s._zod.def.abort),i.issues.push(fo(o))}},e(i.value,i)));return s}function M3(e,s){const i=new Zn({check:"custom",...Be(s)});return i._zod.check=e,i}function ij(e){let s=e?.target??"draft-2020-12";return s==="draft-4"&&(s="draft-04"),s==="draft-7"&&(s="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??io,target:s,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function nn(e,s,i={path:[],schemaPath:[]}){var r;const o=e._zod.def,u=s.seen.get(e);if(u)return u.count++,i.schemaPath.includes(e)&&(u.cycle=i.path),u.schema;const d={schema:{},count:1,cycle:void 0,path:i.path};s.seen.set(e,d);const h=e._zod.toJSONSchema?.();if(h)d.schema=h;else{const b={...i,schemaPath:[...i.schemaPath,e],path:i.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(s,d.schema,b);else{const N=d.schema,z=s.processors[o.type];if(!z)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);z(e,s,N,b)}const v=e._zod.parent;v&&(d.ref||(d.ref=v),nn(v,s,b),s.seen.get(v).isParent=!0)}const p=s.metadataRegistry.get(e);return p&&Object.assign(d.schema,p),s.io==="input"&&Rn(e)&&(delete d.schema.examples,delete d.schema.default),s.io==="input"&&d.schema._prefault&&((r=d.schema).default??(r.default=d.schema._prefault)),delete d.schema._prefault,s.seen.get(e).schema}function rj(e,s){const i=e.seen.get(s);if(!i)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const d of e.seen.entries()){const h=e.metadataRegistry.get(d[0])?.id;if(h){const p=r.get(h);if(p&&p!==d[0])throw new Error(`Duplicate schema id "${h}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(h,d[0])}}const o=d=>{const h=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const v=e.external.registry.get(d[0])?.id,N=e.external.uri??(T=>T);if(v)return{ref:N(v)};const z=d[1].defId??d[1].schema.id??`schema${e.counter++}`;return d[1].defId=z,{defId:z,ref:`${N("__shared")}#/${h}/${z}`}}if(d[1]===i)return{ref:"#"};const x=`#/${h}/`,b=d[1].schema.id??`__schema${e.counter++}`;return{defId:b,ref:x+b}},u=d=>{if(d[1].schema.$ref)return;const h=d[1],{ref:p,defId:x}=o(d);h.def={...h.schema},x&&(h.defId=x);const b=h.schema;for(const v in b)delete b[v];b.$ref=p};if(e.cycles==="throw")for(const d of e.seen.entries()){const h=d[1];if(h.cycle)throw new Error(`Cycle detected: #/${h.cycle?.join("/")}/<root>
50
-
51
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const d of e.seen.entries()){const h=d[1];if(s===d[0]){u(d);continue}if(e.external){const x=e.external.registry.get(d[0])?.id;if(s!==d[0]&&x){u(d);continue}}if(e.metadataRegistry.get(d[0])?.id){u(d);continue}if(h.cycle){u(d);continue}if(h.count>1&&e.reused==="ref"){u(d);continue}}}function lj(e,s){const i=e.seen.get(s);if(!i)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=d=>{const h=e.seen.get(d);if(h.ref===null)return;const p=h.def??h.schema,x={...p},b=h.ref;if(h.ref=null,b){r(b);const N=e.seen.get(b),z=N.schema;if(z.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(z)):Object.assign(p,z),Object.assign(p,x),d._zod.parent===b)for(const w in p)w==="$ref"||w==="allOf"||w in x||delete p[w];if(z.$ref&&N.def)for(const w in p)w==="$ref"||w==="allOf"||w in N.def&&JSON.stringify(p[w])===JSON.stringify(N.def[w])&&delete p[w]}const v=d._zod.parent;if(v&&v!==b){r(v);const N=e.seen.get(v);if(N?.schema.$ref&&(p.$ref=N.schema.$ref,N.def))for(const z in p)z==="$ref"||z==="allOf"||z in N.def&&JSON.stringify(p[z])===JSON.stringify(N.def[z])&&delete p[z]}e.override({zodSchema:d,jsonSchema:p,path:h.path??[]})};for(const d of[...e.seen.entries()].reverse())r(d[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const d=e.external.registry.get(s)?.id;if(!d)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(d)}Object.assign(o,i.def??i.schema);const u=e.external?.defs??{};for(const d of e.seen.entries()){const h=d[1];h.def&&h.defId&&(u[h.defId]=h.def)}e.external||Object.keys(u).length>0&&(e.target==="draft-2020-12"?o.$defs=u:o.definitions=u);try{const d=JSON.parse(JSON.stringify(o));return Object.defineProperty(d,"~standard",{value:{...s["~standard"],jsonSchema:{input:bu(s,"input",e.processors),output:bu(s,"output",e.processors)}},enumerable:!1,writable:!1}),d}catch{throw new Error("Error converting schema to JSON.")}}function Rn(e,s){const i=s??{seen:new Set};if(i.seen.has(e))return!1;i.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Rn(r.element,i);if(r.type==="set")return Rn(r.valueType,i);if(r.type==="lazy")return Rn(r.getter(),i);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Rn(r.innerType,i);if(r.type==="intersection")return Rn(r.left,i)||Rn(r.right,i);if(r.type==="record"||r.type==="map")return Rn(r.keyType,i)||Rn(r.valueType,i);if(r.type==="pipe")return Rn(r.in,i)||Rn(r.out,i);if(r.type==="object"){for(const o in r.shape)if(Rn(r.shape[o],i))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(Rn(o,i))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(Rn(o,i))return!0;return!!(r.rest&&Rn(r.rest,i))}return!1}const $3=(e,s={})=>i=>{const r=ij({...i,processors:s});return nn(e,r),rj(r,e),lj(r,e)},bu=(e,s,i={})=>r=>{const{libraryOptions:o,target:u}=r??{},d=ij({...o??{},target:u,io:s,processors:i});return nn(e,d),rj(d,e),lj(d,e)},B3={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},q3=(e,s,i,r)=>{const o=i;o.type="string";const{minimum:u,maximum:d,format:h,patterns:p,contentEncoding:x}=e._zod.bag;if(typeof u=="number"&&(o.minLength=u),typeof d=="number"&&(o.maxLength=d),h&&(o.format=B3[h]??h,o.format===""&&delete o.format,h==="time"&&delete o.format),x&&(o.contentEncoding=x),p&&p.size>0){const b=[...p];b.length===1?o.pattern=b[0].source:b.length>1&&(o.allOf=[...b.map(v=>({...s.target==="draft-07"||s.target==="draft-04"||s.target==="openapi-3.0"?{type:"string"}:{},pattern:v.source}))])}},I3=(e,s,i,r)=>{const o=i,{minimum:u,maximum:d,format:h,multipleOf:p,exclusiveMaximum:x,exclusiveMinimum:b}=e._zod.bag;typeof h=="string"&&h.includes("int")?o.type="integer":o.type="number",typeof b=="number"&&(s.target==="draft-04"||s.target==="openapi-3.0"?(o.minimum=b,o.exclusiveMinimum=!0):o.exclusiveMinimum=b),typeof u=="number"&&(o.minimum=u,typeof b=="number"&&s.target!=="draft-04"&&(b>=u?delete o.minimum:delete o.exclusiveMinimum)),typeof x=="number"&&(s.target==="draft-04"||s.target==="openapi-3.0"?(o.maximum=x,o.exclusiveMaximum=!0):o.exclusiveMaximum=x),typeof d=="number"&&(o.maximum=d,typeof x=="number"&&s.target!=="draft-04"&&(x<=d?delete o.maximum:delete o.exclusiveMaximum)),typeof p=="number"&&(o.multipleOf=p)},U3=(e,s,i,r)=>{i.type="boolean"},P3=(e,s,i,r)=>{i.not={}},G3=(e,s,i,r)=>{},V3=(e,s,i,r)=>{const o=e._zod.def,u=Bv(o.entries);u.every(d=>typeof d=="number")&&(i.type="number"),u.every(d=>typeof d=="string")&&(i.type="string"),i.enum=u},H3=(e,s,i,r)=>{const o=e._zod.def,u=[];for(const d of o.values)if(d===void 0){if(s.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof d=="bigint"){if(s.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");u.push(Number(d))}else u.push(d);if(u.length!==0)if(u.length===1){const d=u[0];i.type=d===null?"null":typeof d,s.target==="draft-04"||s.target==="openapi-3.0"?i.enum=[d]:i.const=d}else u.every(d=>typeof d=="number")&&(i.type="number"),u.every(d=>typeof d=="string")&&(i.type="string"),u.every(d=>typeof d=="boolean")&&(i.type="boolean"),u.every(d=>d===null)&&(i.type="null"),i.enum=u},K3=(e,s,i,r)=>{if(s.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Q3=(e,s,i,r)=>{if(s.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Z3=(e,s,i,r)=>{const o=i,u=e._zod.def,{minimum:d,maximum:h}=e._zod.bag;typeof d=="number"&&(o.minItems=d),typeof h=="number"&&(o.maxItems=h),o.type="array",o.items=nn(u.element,s,{...r,path:[...r.path,"items"]})},F3=(e,s,i,r)=>{const o=i,u=e._zod.def;o.type="object",o.properties={};const d=u.shape;for(const x in d)o.properties[x]=nn(d[x],s,{...r,path:[...r.path,"properties",x]});const h=new Set(Object.keys(d)),p=new Set([...h].filter(x=>{const b=u.shape[x]._zod;return s.io==="input"?b.optin===void 0:b.optout===void 0}));p.size>0&&(o.required=Array.from(p)),u.catchall?._zod.def.type==="never"?o.additionalProperties=!1:u.catchall?u.catchall&&(o.additionalProperties=nn(u.catchall,s,{...r,path:[...r.path,"additionalProperties"]})):s.io==="output"&&(o.additionalProperties=!1)},Y3=(e,s,i,r)=>{const o=e._zod.def,u=o.inclusive===!1,d=o.options.map((h,p)=>nn(h,s,{...r,path:[...r.path,u?"oneOf":"anyOf",p]}));u?i.oneOf=d:i.anyOf=d},X3=(e,s,i,r)=>{const o=e._zod.def,u=nn(o.left,s,{...r,path:[...r.path,"allOf",0]}),d=nn(o.right,s,{...r,path:[...r.path,"allOf",1]}),h=x=>"allOf"in x&&Object.keys(x).length===1,p=[...h(u)?u.allOf:[u],...h(d)?d.allOf:[d]];i.allOf=p},J3=(e,s,i,r)=>{const o=i,u=e._zod.def;o.type="object";const d=u.keyType,p=d._zod.bag?.patterns;if(u.mode==="loose"&&p&&p.size>0){const b=nn(u.valueType,s,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const v of p)o.patternProperties[v.source]=b}else(s.target==="draft-07"||s.target==="draft-2020-12")&&(o.propertyNames=nn(u.keyType,s,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=nn(u.valueType,s,{...r,path:[...r.path,"additionalProperties"]});const x=d._zod.values;if(x){const b=[...x].filter(v=>typeof v=="string"||typeof v=="number");b.length>0&&(o.required=b)}},W3=(e,s,i,r)=>{const o=e._zod.def,u=nn(o.innerType,s,r),d=s.seen.get(e);s.target==="openapi-3.0"?(d.ref=o.innerType,i.nullable=!0):i.anyOf=[u,{type:"null"}]},eT=(e,s,i,r)=>{const o=e._zod.def;nn(o.innerType,s,r);const u=s.seen.get(e);u.ref=o.innerType},tT=(e,s,i,r)=>{const o=e._zod.def;nn(o.innerType,s,r);const u=s.seen.get(e);u.ref=o.innerType,i.default=JSON.parse(JSON.stringify(o.defaultValue))},nT=(e,s,i,r)=>{const o=e._zod.def;nn(o.innerType,s,r);const u=s.seen.get(e);u.ref=o.innerType,s.io==="input"&&(i._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},sT=(e,s,i,r)=>{const o=e._zod.def;nn(o.innerType,s,r);const u=s.seen.get(e);u.ref=o.innerType;let d;try{d=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}i.default=d},aT=(e,s,i,r)=>{const o=e._zod.def,u=s.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;nn(u,s,r);const d=s.seen.get(e);d.ref=u},iT=(e,s,i,r)=>{const o=e._zod.def;nn(o.innerType,s,r);const u=s.seen.get(e);u.ref=o.innerType,i.readOnly=!0},oj=(e,s,i,r)=>{const o=e._zod.def;nn(o.innerType,s,r);const u=s.seen.get(e);u.ref=o.innerType},rT=oe("ZodISODateTime",(e,s)=>{l4.init(e,s),It.init(e,s)});function lT(e){return h3(rT,e)}const oT=oe("ZodISODate",(e,s)=>{o4.init(e,s),It.init(e,s)});function cT(e){return f3(oT,e)}const uT=oe("ZodISOTime",(e,s)=>{c4.init(e,s),It.init(e,s)});function dT(e){return p3(uT,e)}const mT=oe("ZodISODuration",(e,s)=>{u4.init(e,s),It.init(e,s)});function hT(e){return g3(mT,e)}const fT=(e,s)=>{Pv.init(e,s),e.name="ZodError",Object.defineProperties(e,{format:{value:i=>e5(e,i)},flatten:{value:i=>WA(e,i)},addIssue:{value:i=>{e.issues.push(i),e.message=JSON.stringify(e.issues,Zh,2)}},addIssues:{value:i=>{e.issues.push(...i),e.message=JSON.stringify(e.issues,Zh,2)}},isEmpty:{get(){return e.issues.length===0}}})},js=oe("ZodError",fT,{Parent:Error}),pT=Tf(js),gT=_f(js),xT=Ou(js),yT=Ru(js),bT=s5(js),vT=a5(js),jT=i5(js),NT=r5(js),wT=l5(js),ST=o5(js),zT=c5(js),kT=u5(js),qt=oe("ZodType",(e,s)=>(Bt.init(e,s),Object.assign(e["~standard"],{jsonSchema:{input:bu(e,"input"),output:bu(e,"output")}}),e.toJSONSchema=$3(e,{}),e.def=s,e.type=s.type,Object.defineProperty(e,"_def",{value:s}),e.check=(...i)=>e.clone(ii(s,{checks:[...s.checks??[],...i.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(i,r)=>ri(e,i,r),e.brand=()=>e,e.register=((i,r)=>(i.add(e,r),e)),e.parse=(i,r)=>pT(e,i,r,{callee:e.parse}),e.safeParse=(i,r)=>xT(e,i,r),e.parseAsync=async(i,r)=>gT(e,i,r,{callee:e.parseAsync}),e.safeParseAsync=async(i,r)=>yT(e,i,r),e.spa=e.safeParseAsync,e.encode=(i,r)=>bT(e,i,r),e.decode=(i,r)=>vT(e,i,r),e.encodeAsync=async(i,r)=>jT(e,i,r),e.decodeAsync=async(i,r)=>NT(e,i,r),e.safeEncode=(i,r)=>wT(e,i,r),e.safeDecode=(i,r)=>ST(e,i,r),e.safeEncodeAsync=async(i,r)=>zT(e,i,r),e.safeDecodeAsync=async(i,r)=>kT(e,i,r),e.refine=(i,r)=>e.check(b_(i,r)),e.superRefine=i=>e.check(v_(i)),e.overwrite=i=>e.check(Wr(i)),e.optional=()=>Iy(e),e.exactOptional=()=>r_(e),e.nullable=()=>Uy(e),e.nullish=()=>Iy(Uy(e)),e.nonoptional=i=>m_(e,i),e.array=()=>G(e),e.or=i=>mj([e,i]),e.and=i=>e_(e,i),e.transform=i=>Py(e,a_(i)),e.default=i=>c_(e,i),e.prefault=i=>d_(e,i),e.catch=i=>f_(e,i),e.pipe=i=>Py(e,i),e.readonly=()=>x_(e),e.describe=i=>{const r=e.clone();return io.add(r,{description:i}),r},Object.defineProperty(e,"description",{get(){return io.get(e)?.description},configurable:!0}),e.meta=(...i)=>{if(i.length===0)return io.get(e);const r=e.clone();return io.add(r,i[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=i=>i(e),e)),cj=oe("_ZodString",(e,s)=>{Ef.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(r,o,u)=>q3(e,r,o);const i=e._zod.bag;e.format=i.format??null,e.minLength=i.minimum??null,e.maxLength=i.maximum??null,e.regex=(...r)=>e.check(N3(...r)),e.includes=(...r)=>e.check(z3(...r)),e.startsWith=(...r)=>e.check(k3(...r)),e.endsWith=(...r)=>e.check(C3(...r)),e.min=(...r)=>e.check(yu(...r)),e.max=(...r)=>e.check(sj(...r)),e.length=(...r)=>e.check(aj(...r)),e.nonempty=(...r)=>e.check(yu(1,...r)),e.lowercase=r=>e.check(w3(r)),e.uppercase=r=>e.check(S3(r)),e.trim=()=>e.check(T3()),e.normalize=(...r)=>e.check(A3(...r)),e.toLowerCase=()=>e.check(_3()),e.toUpperCase=()=>e.check(E3()),e.slugify=()=>e.check(D3())}),CT=oe("ZodString",(e,s)=>{Ef.init(e,s),cj.init(e,s),e.email=i=>e.check(K4(AT,i)),e.url=i=>e.check(X4(TT,i)),e.jwt=i=>e.check(m3(VT,i)),e.emoji=i=>e.check(J4(_T,i)),e.guid=i=>e.check(Ry(By,i)),e.uuid=i=>e.check(Q4(Ic,i)),e.uuidv4=i=>e.check(Z4(Ic,i)),e.uuidv6=i=>e.check(F4(Ic,i)),e.uuidv7=i=>e.check(Y4(Ic,i)),e.nanoid=i=>e.check(W4(ET,i)),e.guid=i=>e.check(Ry(By,i)),e.cuid=i=>e.check(e3(DT,i)),e.cuid2=i=>e.check(t3(OT,i)),e.ulid=i=>e.check(n3(RT,i)),e.base64=i=>e.check(c3(UT,i)),e.base64url=i=>e.check(u3(PT,i)),e.xid=i=>e.check(s3(LT,i)),e.ksuid=i=>e.check(a3(MT,i)),e.ipv4=i=>e.check(i3($T,i)),e.ipv6=i=>e.check(r3(BT,i)),e.cidrv4=i=>e.check(l3(qT,i)),e.cidrv6=i=>e.check(o3(IT,i)),e.e164=i=>e.check(d3(GT,i)),e.datetime=i=>e.check(lT(i)),e.date=i=>e.check(cT(i)),e.time=i=>e.check(dT(i)),e.duration=i=>e.check(hT(i))});function g(e){return H4(CT,e)}const It=oe("ZodStringFormat",(e,s)=>{Mt.init(e,s),cj.init(e,s)}),AT=oe("ZodEmail",(e,s)=>{J5.init(e,s),It.init(e,s)}),By=oe("ZodGUID",(e,s)=>{Y5.init(e,s),It.init(e,s)}),Ic=oe("ZodUUID",(e,s)=>{X5.init(e,s),It.init(e,s)}),TT=oe("ZodURL",(e,s)=>{W5.init(e,s),It.init(e,s)}),_T=oe("ZodEmoji",(e,s)=>{e4.init(e,s),It.init(e,s)}),ET=oe("ZodNanoID",(e,s)=>{t4.init(e,s),It.init(e,s)}),DT=oe("ZodCUID",(e,s)=>{n4.init(e,s),It.init(e,s)}),OT=oe("ZodCUID2",(e,s)=>{s4.init(e,s),It.init(e,s)}),RT=oe("ZodULID",(e,s)=>{a4.init(e,s),It.init(e,s)}),LT=oe("ZodXID",(e,s)=>{i4.init(e,s),It.init(e,s)}),MT=oe("ZodKSUID",(e,s)=>{r4.init(e,s),It.init(e,s)}),$T=oe("ZodIPv4",(e,s)=>{d4.init(e,s),It.init(e,s)}),BT=oe("ZodIPv6",(e,s)=>{m4.init(e,s),It.init(e,s)}),qT=oe("ZodCIDRv4",(e,s)=>{h4.init(e,s),It.init(e,s)}),IT=oe("ZodCIDRv6",(e,s)=>{f4.init(e,s),It.init(e,s)}),UT=oe("ZodBase64",(e,s)=>{p4.init(e,s),It.init(e,s)}),PT=oe("ZodBase64URL",(e,s)=>{x4.init(e,s),It.init(e,s)}),GT=oe("ZodE164",(e,s)=>{y4.init(e,s),It.init(e,s)}),VT=oe("ZodJWT",(e,s)=>{v4.init(e,s),It.init(e,s)}),uj=oe("ZodNumber",(e,s)=>{Jv.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(r,o,u)=>I3(e,r,o),e.gt=(r,o)=>e.check(My(r,o)),e.gte=(r,o)=>e.check(bh(r,o)),e.min=(r,o)=>e.check(bh(r,o)),e.lt=(r,o)=>e.check(Ly(r,o)),e.lte=(r,o)=>e.check(yh(r,o)),e.max=(r,o)=>e.check(yh(r,o)),e.int=r=>e.check(qy(r)),e.safe=r=>e.check(qy(r)),e.positive=r=>e.check(My(0,r)),e.nonnegative=r=>e.check(bh(0,r)),e.negative=r=>e.check(Ly(0,r)),e.nonpositive=r=>e.check(yh(0,r)),e.multipleOf=(r,o)=>e.check($y(r,o)),e.step=(r,o)=>e.check($y(r,o)),e.finite=()=>e;const i=e._zod.bag;e.minValue=Math.max(i.minimum??Number.NEGATIVE_INFINITY,i.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(i.maximum??Number.POSITIVE_INFINITY,i.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(i.format??"").includes("int")||Number.isSafeInteger(i.multipleOf??.5),e.isFinite=!0,e.format=i.format??null});function k(e){return x3(uj,e)}const HT=oe("ZodNumberFormat",(e,s)=>{j4.init(e,s),uj.init(e,s)});function qy(e){return y3(HT,e)}const KT=oe("ZodBoolean",(e,s)=>{N4.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>U3(e,i,r)});function Me(e){return b3(KT,e)}const QT=oe("ZodUnknown",(e,s)=>{w4.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>G3()});function Ri(){return v3(QT)}const ZT=oe("ZodNever",(e,s)=>{S4.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>P3(e,i,r)});function FT(e){return j3(ZT,e)}const YT=oe("ZodArray",(e,s)=>{z4.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>Z3(e,i,r,o),e.element=s.element,e.min=(i,r)=>e.check(yu(i,r)),e.nonempty=i=>e.check(yu(1,i)),e.max=(i,r)=>e.check(sj(i,r)),e.length=(i,r)=>e.check(aj(i,r)),e.unwrap=()=>e.element});function G(e,s){return O3(YT,e,s)}const XT=oe("ZodObject",(e,s)=>{C4.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>F3(e,i,r,o),wt(e,"shape",()=>s.shape),e.keyof=()=>je(Object.keys(e._zod.def.shape)),e.catchall=i=>e.clone({...e._zod.def,catchall:i}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Ri()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ri()}),e.strict=()=>e.clone({...e._zod.def,catchall:FT()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=i=>ZA(e,i),e.safeExtend=i=>FA(e,i),e.merge=i=>YA(e,i),e.pick=i=>KA(e,i),e.omit=i=>QA(e,i),e.partial=(...i)=>XA(fj,e,i[0]),e.required=(...i)=>JA(pj,e,i[0])});function R(e,s){const i={type:"object",shape:e??{},...Be(s)};return new XT(i)}const dj=oe("ZodUnion",(e,s)=>{tj.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>Y3(e,i,r,o),e.options=s.options});function mj(e,s){return new dj({type:"union",options:e,...Be(s)})}const JT=oe("ZodDiscriminatedUnion",(e,s)=>{dj.init(e,s),A4.init(e,s)});function hj(e,s,i){return new JT({type:"union",options:s,discriminator:e,...Be(i)})}const WT=oe("ZodIntersection",(e,s)=>{T4.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>X3(e,i,r,o)});function e_(e,s){return new WT({type:"intersection",left:e,right:s})}const t_=oe("ZodRecord",(e,s)=>{_4.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>J3(e,i,r,o),e.keyType=s.keyType,e.valueType=s.valueType});function Hs(e,s,i){return new t_({type:"record",keyType:e,valueType:s,...Be(i)})}const Yh=oe("ZodEnum",(e,s)=>{E4.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(r,o,u)=>V3(e,r,o),e.enum=s.entries,e.options=Object.values(s.entries);const i=new Set(Object.keys(s.entries));e.extract=(r,o)=>{const u={};for(const d of r)if(i.has(d))u[d]=s.entries[d];else throw new Error(`Key ${d} not found in enum`);return new Yh({...s,checks:[],...Be(o),entries:u})},e.exclude=(r,o)=>{const u={...s.entries};for(const d of r)if(i.has(d))delete u[d];else throw new Error(`Key ${d} not found in enum`);return new Yh({...s,checks:[],...Be(o),entries:u})}});function je(e,s){const i=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Yh({type:"enum",entries:i,...Be(s)})}const n_=oe("ZodLiteral",(e,s)=>{D4.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>H3(e,i,r),e.values=new Set(s.values),Object.defineProperty(e,"value",{get(){if(s.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return s.values[0]}})});function Qn(e,s){return new n_({type:"literal",values:Array.isArray(e)?e:[e],...Be(s)})}const s_=oe("ZodTransform",(e,s)=>{O4.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>Q3(e,i),e._zod.parse=(i,r)=>{if(r.direction==="backward")throw new Mv(e.constructor.name);i.addIssue=u=>{if(typeof u=="string")i.issues.push(fo(u,i.value,s));else{const d=u;d.fatal&&(d.continue=!1),d.code??(d.code="custom"),d.input??(d.input=i.value),d.inst??(d.inst=e),i.issues.push(fo(d))}};const o=s.transform(i.value,i);return o instanceof Promise?o.then(u=>(i.value=u,i)):(i.value=o,i)}});function a_(e){return new s_({type:"transform",transform:e})}const fj=oe("ZodOptional",(e,s)=>{nj.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>oj(e,i,r,o),e.unwrap=()=>e._zod.def.innerType});function Iy(e){return new fj({type:"optional",innerType:e})}const i_=oe("ZodExactOptional",(e,s)=>{R4.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>oj(e,i,r,o),e.unwrap=()=>e._zod.def.innerType});function r_(e){return new i_({type:"optional",innerType:e})}const l_=oe("ZodNullable",(e,s)=>{L4.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>W3(e,i,r,o),e.unwrap=()=>e._zod.def.innerType});function Uy(e){return new l_({type:"nullable",innerType:e})}const o_=oe("ZodDefault",(e,s)=>{M4.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>tT(e,i,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function c_(e,s){return new o_({type:"default",innerType:e,get defaultValue(){return typeof s=="function"?s():Iv(s)}})}const u_=oe("ZodPrefault",(e,s)=>{$4.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>nT(e,i,r,o),e.unwrap=()=>e._zod.def.innerType});function d_(e,s){return new u_({type:"prefault",innerType:e,get defaultValue(){return typeof s=="function"?s():Iv(s)}})}const pj=oe("ZodNonOptional",(e,s)=>{B4.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>eT(e,i,r,o),e.unwrap=()=>e._zod.def.innerType});function m_(e,s){return new pj({type:"nonoptional",innerType:e,...Be(s)})}const h_=oe("ZodCatch",(e,s)=>{q4.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>sT(e,i,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function f_(e,s){return new h_({type:"catch",innerType:e,catchValue:typeof s=="function"?s:()=>s})}const p_=oe("ZodPipe",(e,s)=>{I4.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>aT(e,i,r,o),e.in=s.in,e.out=s.out});function Py(e,s){return new p_({type:"pipe",in:e,out:s})}const g_=oe("ZodReadonly",(e,s)=>{U4.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>iT(e,i,r,o),e.unwrap=()=>e._zod.def.innerType});function x_(e){return new g_({type:"readonly",innerType:e})}const y_=oe("ZodCustom",(e,s)=>{P4.init(e,s),qt.init(e,s),e._zod.processJSONSchema=(i,r,o)=>K3(e,i)});function b_(e,s={}){return R3(y_,e,s)}function v_(e){return L3(e)}const j_=R({maxConcurrency:k().int().positive(),maxRequestsPerMinute:k().int().positive(),maxRequestsPerDay:k().int().positive()}),ya=g().min(1);g().min(1);const Df=R({label:g().min(1),city:g().min(1),region:g().min(1),country:g().length(2),timezone:g().optional()}),Of=je(["citation.lost","citation.gained","run.completed","run.failed","insight.critical","insight.high"]);R({id:g(),projectId:g(),channel:Qn("webhook"),url:g().url(),urlDisplay:g(),urlHost:g(),events:G(Of),enabled:Me().default(!0),source:g().optional(),webhookSecret:g().optional(),createdAt:g(),updatedAt:g()});R({channel:Qn("webhook"),url:g().url(),events:G(Of).min(1),source:g().optional()});const gj=je(["cli","api","config-file"]);function N_(e){const s=new Set,i=new Set;for(const r of e){if(s.has(r.label)){i.add(r.label);continue}s.add(r.label)}return[...i]}function w_(e,s){return s?e.some(i=>i.label===s):!0}R({displayName:g().min(1),canonicalDomain:g().min(1),ownedDomains:G(g().min(1)).optional(),aliases:G(g()).optional(),country:g().length(2),language:g().min(2),tags:G(g()).optional(),labels:Hs(g(),g()).optional(),providers:G(ya).optional(),locations:G(Df).optional(),defaultLocation:g().nullable().optional(),autoExtractBacklinks:Me().optional(),configSource:gj.optional()});R({id:g(),name:g(),displayName:g().optional(),canonicalDomain:g(),ownedDomains:G(g()).default([]),aliases:G(g()).default([]),country:g().length(2),language:g().min(2),tags:G(g()).default([]),labels:Hs(g(),g()).default({}),providers:G(g()).default([]),locations:G(Df).default([]),defaultLocation:g().nullable().optional(),autoExtractBacklinks:Me().default(!1),configSource:gj.default("cli"),configRevision:k().int().positive().default(1),createdAt:g().optional(),updatedAt:g().optional()});R({id:g(),query:g(),createdAt:g()});R({id:g(),keyword:g(),createdAt:g()});R({queries:G(g().trim().min(1)).min(1)});R({keywords:G(g().trim().min(1)).min(1)});R({provider:ya,count:k().int().min(1).max(20).optional()});R({id:g(),domain:g(),createdAt:g()});R({competitors:G(g().trim().min(1)).min(1)});function vu(e){let s=e.trim().toLowerCase();try{s.includes("://")&&(s=new URL(s).hostname.toLowerCase())}catch{}return s.replace(/^www\./,"")}const S_=new Set(["ac.uk","co.id","co.il","co.in","co.jp","co.kr","co.nz","co.th","co.uk","co.za","com.au","com.br","com.cn","com.mx","com.ph","com.sg","com.tr","edu.au","edu.sg","gov.au","gov.uk","me.uk","ne.jp","net.au","net.br","net.cn","net.in","net.tr","or.jp","or.kr","org.au","org.br","org.in","org.nz","org.tr","org.uk","org.za"]);function z_(e){const s=vu(e);if(!s)return"";const i=s.split("/")[0]?.split(":")[0]??"";if(!i)return"";const r=i.split(".").filter(Boolean);if(r.length<2)return"";if(r.length===2)return r.join(".");const o=r.slice(-2).join(".");return S_.has(o)?r.length>=3?r.slice(-3).join("."):"":r.slice(-2).join(".")}function xj(e){const s=z_(e);return s?s.split(".")[0]??"":""}function k_(e){const s=[e.canonicalDomain,...e.ownedDomains??[]],i=new Set,r=[];for(const o of s){const u=o.trim();if(!u)continue;const d=vu(u);i.has(d)||(i.add(d),r.push(u))}return r}const C_=R({name:g().min(1).max(63).regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,{message:"Name must be a lowercase slug (letters, numbers, hyphens)"}),labels:Hs(g(),g()).optional().default({})}),A_=R({preset:g().optional(),cron:g().optional(),timezone:g().optional().default("UTC"),providers:G(ya).optional().default([])}).refine(e=>e.preset&&!e.cron||!e.preset&&e.cron,{message:'Exactly one of "preset" or "cron" must be provided'}).optional(),T_=R({channel:Qn("webhook"),url:g().url(),events:G(Of).min(1)}),__=R({gsc:R({propertyUrl:g()}).optional(),syncSchedule:R({preset:g().optional(),cron:g().optional()}).optional()}).optional(),Gy=G(g().min(1)),E_=R({displayName:g().min(1),canonicalDomain:g().min(1),ownedDomains:G(g().min(1)).optional().default([]),aliases:G(g().min(1)).optional().default([]),country:g().length(2),language:g().min(2),queries:Gy.optional(),keywords:Gy.optional(),competitors:G(g().min(1)).optional().default([]),providers:G(ya).optional().default([]),locations:G(Df).optional().default([]),defaultLocation:g().optional(),schedule:A_,notifications:G(T_).optional().default([]),google:__,autoExtractBacklinks:Me().optional().default(!1)}).superRefine((e,s)=>{e.queries!==void 0&&e.keywords!==void 0&&s.addIssue({code:"custom",message:"Use spec.queries; spec.keywords is accepted only as a legacy alias when spec.queries is omitted",path:["keywords"]});const i=N_(e.locations);i.length>0&&s.addIssue({code:"custom",message:`Duplicate location labels are not allowed: ${i.join(", ")}`,path:["locations"]}),w_(e.locations,e.defaultLocation)||s.addIssue({code:"custom",message:`defaultLocation "${e.defaultLocation}" must match a configured location label`,path:["defaultLocation"]})});R({apiVersion:Qn("canonry/v1"),kind:Qn("Project"),metadata:C_,spec:E_});const D_=je(["gsc","ga4"]);R({id:g(),domain:g(),connectionType:D_,propertyId:g().nullable().optional(),sitemapUrl:g().nullable().optional(),scopes:G(g()).default([]),createdAt:g(),updatedAt:g()});R({date:g(),query:g(),page:g(),country:g().nullable().optional(),device:g().nullable().optional(),clicks:k(),impressions:k(),ctr:k(),position:k()});const O_=R({date:g(),clicks:k(),impressions:k(),ctr:k()});R({totals:R({clicks:k(),impressions:k(),ctr:k(),days:k()}),daily:G(O_)});const Xh=R({id:g(),url:g(),indexingState:g().nullable().optional(),verdict:g().nullable().optional(),coverageState:g().nullable().optional(),pageFetchState:g().nullable().optional(),robotsTxtState:g().nullable().optional(),crawlTime:g().nullable().optional(),lastCrawlResult:g().nullable().optional(),isMobileFriendly:Me().nullable().optional(),richResults:G(g()).default([]),referringUrls:G(g()).default([]),inspectedAt:g()});je(["stable","reindexed","deindexed","still-missing","new"]);const R_=R({url:g(),previousState:g().nullable(),currentState:g().nullable(),transitionDate:g()}),L_=R({reason:g(),count:k(),urls:G(Xh).default([])});R({summary:R({total:k(),indexed:k(),notIndexed:k(),deindexed:k(),percentage:k()}),lastInspectedAt:g().nullable(),lastSyncedAt:g().nullable(),indexed:G(Xh).default([]),notIndexed:G(Xh).default([]),deindexed:G(R_).default([]),reasonGroups:G(L_).default([])});R({url:g(),type:je(["URL_UPDATED","URL_DELETED"]),notifiedAt:g()});const M_=R({url:g(),type:je(["URL_UPDATED","URL_DELETED"]),notifiedAt:g(),status:je(["success","error"]),error:g().optional()});R({summary:R({total:k().int().nonnegative(),succeeded:k().int().nonnegative(),failed:k().int().nonnegative()}),results:G(M_).default([])});R({date:g(),indexed:k(),notIndexed:k(),reasonBreakdown:Hs(g(),k()).default({})});const $_=R({siteUrl:g(),permissionLevel:g()});R({sites:G($_).default([])});const B_=R({type:g(),submitted:g(),indexed:g()}),q_=R({path:g(),lastSubmitted:g().optional(),isPending:Me().optional(),isSitemapsIndex:Me().optional(),type:g().optional(),lastDownloaded:g().optional(),warnings:g().optional(),errors:g().optional(),contents:G(B_).optional()});R({sitemaps:G(q_).default([])});R({id:g(),domain:g(),siteUrl:g().nullable().optional(),createdAt:g(),updatedAt:g()});const vh=R({id:g(),url:g(),httpCode:k().nullable().optional(),inIndex:Me().nullable().optional(),lastCrawledDate:g().nullable().optional(),inIndexDate:g().nullable().optional(),inspectedAt:g(),documentSize:k().nullable().optional(),anchorCount:k().nullable().optional(),discoveryDate:g().nullable().optional()});R({summary:R({total:k(),indexed:k(),notIndexed:k(),unknown:k().optional(),percentage:k()}),lastInspectedAt:g().nullable(),indexed:G(vh).default([]),notIndexed:G(vh).default([]),unknown:G(vh).default([]).optional()});R({query:g(),impressions:k(),clicks:k(),ctr:k(),averagePosition:k()});R({date:g(),indexed:k(),notIndexed:k(),unknown:k()});const I_=R({url:g(),status:je(["success","error"]),submittedAt:g(),error:g().optional()});R({summary:R({total:k().int().nonnegative(),succeeded:k().int().nonnegative(),failed:k().int().nonnegative()}),results:G(I_).default([])});const yj=R({url:g(),verified:Me()});R({sites:G(yj).default([])});R({connected:Me(),domain:g(),siteUrl:g().nullable(),createdAt:g().nullable(),updatedAt:g().nullable()});R({connected:Me(),domain:g(),siteUrl:g().nullable(),availableSites:G(yj).default([])});R({siteUrl:g()});const U_=R({name:g(),alive:Me(),lastUsed:g().nullable()});R({connected:Me(),endpoint:g(),version:g().optional(),browserVersion:g().optional(),targets:G(U_).default([])});const el=je(["live","staging"]);R({projectName:g(),url:g(),stagingUrl:g().optional(),username:g(),defaultEnv:el,createdAt:g(),updatedAt:g()});const Vy=R({url:g(),reachable:Me(),pageCount:k().nullable().optional(),version:g().nullable().optional(),error:g().nullable().optional(),plugins:G(g()).optional(),authenticatedUser:R({id:k(),slug:g()}).nullable().optional()});R({connected:Me(),projectName:g(),defaultEnv:el,live:Vy.nullable(),staging:Vy.nullable(),adminUrl:g().nullable().optional()});const P_=R({id:k(),slug:g(),title:g(),status:g(),modifiedAt:g().nullable().optional(),link:g().nullable().optional()}),bj=R({title:g().nullable(),description:g().nullable(),noindex:Me().nullable(),writable:Me().default(!1),writeTargets:G(g()).default([])}),G_=R({type:g(),json:Hs(g(),Ri())}),V_=P_.extend({env:el,content:g(),seo:bj,schemaBlocks:G(G_).default([])}),Hy=V_.extend({contentHash:g(),contentSnippet:g()}),vj=R({manualRequired:Qn(!0),targetUrl:g(),adminUrl:g().nullable().optional(),content:g(),nextSteps:G(g()).default([])}),H_=R({slug:g(),severity:je(["high","medium","low"]),code:je(["noindex","missing-seo-title","missing-meta-description","missing-schema","thin-content"]),message:g()});R({slug:g(),title:g(),status:g(),wordCount:k(),seo:bj,schemaPresent:Me(),issues:G(H_).default([])});const K_=R({slug:g(),status:je(["applied","skipped","manual"]),error:g().optional(),manualAssist:vj.optional()});R({env:el,strategy:je(["plugin","manual"]),results:G(K_)});const Q_=R({slug:g(),status:je(["deployed","stripped","skipped","failed"]),schemasInjected:G(g()).optional(),manualAssist:vj.optional(),error:g().optional()});R({env:el,results:G(Q_)});const Z_=R({slug:g(),title:g(),canonrySchemas:G(g()),thirdPartySchemas:G(g()),hasCanonrySchema:Me()});R({env:el,pages:G(Z_)});const F_=R({name:g(),status:je(["completed","skipped","failed"]),summary:g().optional(),error:g().optional()});R({projectName:g(),steps:G(F_)});R({slug:g(),live:Hy,staging:Hy,hasDifferences:Me(),differences:R({title:Me(),slug:Me(),content:Me(),seoTitle:Me(),seoDescription:Me(),noindex:Me(),schema:Me()})});const Y_=R({name:g(),displayName:g().optional(),keyUrl:g().optional(),modelHint:g().optional(),model:g().optional(),configured:Me(),quota:j_.optional(),vertexConfigured:Me().optional()}),Ky=R({configured:Me()});R({providers:G(Y_).default([]),google:Ky,bing:Ky});const Mu=je(["queued","running","completed","partial","failed","cancelled"]),jn=Mu.enum,jj=je(["answer-visibility","site-audit","gsc-sync","inspect-sitemap","ga-sync","bing-inspect","bing-inspect-sitemap","backlink-extract","traffic-sync","aeo-discover-seed","aeo-discover-probe"]),et=jj.enum,Nj=je(["manual","scheduled","config-apply","backfill","probe"]),qr=Nj.enum,Li=je(["cited","not-cited"]),po=Li.enum,ju=je(["visible","not-visible"]);ju.enum;const Nu=je(["mentioned","not-mentioned"]);Nu.enum;const wj=je(["new","cited","lost","emerging","not-cited"]);wj.enum;const X_=je(["new","mentioned","lost","emerging","not-mentioned"]);X_.enum;const J_=je([qr.manual,qr.probe]);R({kind:Qn(et["answer-visibility"]).optional(),trigger:J_.optional(),providers:G(ya).optional(),queries:G(g().min(1)).min(1).optional(),location:g().min(1).optional(),allLocations:Me().optional(),noLocation:Me().optional()}).refine(e=>+!!e.location+ +!!e.allLocations+ +!!e.noLocation<=1,{message:'Only one of "location", "allLocations", or "noLocation" may be provided'});const W_=R({message:g(),raw:Ri().optional()}),eE=R({message:g().optional(),providers:Hs(g(),W_).optional()}),tE=R({id:g(),projectId:g(),kind:jj,status:Mu,trigger:Nj.default("manual"),location:g().nullable().optional(),queries:G(g()).nullable().optional(),startedAt:g().nullable().optional(),finishedAt:g().nullable().optional(),error:eE.nullable().optional(),createdAt:g()});function Rf(e){if(e.providers){const s=Object.entries(e.providers);if(s.length===1){const[i,r]=s[0];return`${i}: ${r.message}`}if(s.length>1)return s.map(([i,r])=>`${i}: ${r.message}`).join(" • ")}return e.message??"Run failed."}const Sj=R({uri:g(),title:g()}),zj=R({id:g(),runId:g(),queryId:g(),query:g().optional(),provider:ya,citationState:Li,answerMentioned:Me().optional(),visibilityState:ju.optional(),mentionState:Nu.optional(),transition:wj.optional(),answerText:g().nullable().optional(),citedDomains:G(g()).default([]),competitorOverlap:G(g()).default([]),recommendedCompetitors:G(g()).default([]),matchedTerms:G(g()).default([]),groundingSources:G(Sj).default([]),searchQueries:G(g()).default([]),model:g().nullable().optional(),location:g().nullable().optional(),createdAt:g()});R({snapshots:G(zj),total:k().int().nonnegative()});const nE=R({queryId:g().nullable(),query:g().nullable(),run1State:Li.nullable(),run2State:Li.nullable(),run1AnswerMentioned:Me().nullable(),run2AnswerMentioned:Me().nullable(),run1VisibilityState:ju.nullable(),run2VisibilityState:ju.nullable(),run1MentionState:Nu.nullable().optional(),run2MentionState:Nu.nullable().optional(),changed:Me(),visibilityChanged:Me()});R({run1:g(),run2:g(),diff:G(nE)});const sE=tE.extend({snapshots:G(zj).optional()});R({totalRuns:k().int().nonnegative(),run:sE.nullable()});R({id:g(),projectId:g().nullable().optional(),actor:g(),action:g(),entityType:g(),entityId:g().nullable().optional(),diff:Ri().optional(),createdAt:g()});const aE=je(["yes","no","unknown","not-mentioned"]),Qy=G(g().min(1));R({companyName:g().min(1),domain:g().min(1),queries:Qy.optional(),phrases:Qy.optional(),competitors:G(g().min(1)).optional().default([])}).superRefine((e,s)=>{e.queries!==void 0&&e.phrases!==void 0&&s.addIssue({code:"custom",message:"Use queries; phrases is accepted only as a legacy alias when queries is omitted",path:["phrases"]})});const iE=R({name:g(),count:k().int().nonnegative()}),rE=R({id:g(),name:g(),weight:k(),score:k(),grade:g(),status:je(["pass","partial","fail"]),findings:G(R({type:g(),message:g()})).default([]),recommendations:G(g()).default([])}),lE=R({url:g(),finalUrl:g(),auditedAt:g(),overallScore:k(),overallGrade:g(),summary:g(),factors:G(rE).default([])}),oE=R({industry:g(),summary:g(),services:G(g()).default([]),categoryTerms:G(g()).default([])}),cE=R({provider:g(),displayName:g(),model:g().nullable().optional(),mentioned:Me(),cited:Me(),describedAccurately:aE,accuracyNotes:g().nullable().optional(),incorrectClaims:G(g()).default([]),recommendedCompetitors:G(g()).default([]),citedDomains:G(g()).default([]),groundingSources:G(Sj).default([]),searchQueries:G(g()).default([]),answerText:g(),error:g().nullable().optional()}),uE=R({query:g(),providerResults:G(cE).default([])}),dE=R({totalQueries:k().int().nonnegative(),totalProviders:k().int().nonnegative(),totalComparisons:k().int().nonnegative(),mentionCount:k().int().nonnegative(),citationCount:k().int().nonnegative(),topCompetitors:G(iE).default([]),visibilityGap:g(),whatThisMeans:G(g()).default([]),recommendedActions:G(g()).default([])});R({companyName:g(),domain:g(),homepageUrl:g(),generatedAt:g(),queries:G(g()).default([]),competitors:G(g()).default([]),profile:oE,audit:lE,queryResults:G(uE).default([]),summary:dE});const Lf=je(["answer-visibility","traffic-sync"]);Lf.enum;R({id:g(),projectId:g(),kind:Lf,cronExpr:g(),preset:g().nullable().optional(),timezone:g().default("UTC"),enabled:Me().default(!0),providers:G(ya).default([]),sourceId:g().nullable().optional(),lastRunAt:g().nullable().optional(),nextRunAt:g().nullable().optional(),createdAt:g(),updatedAt:g()});R({kind:Lf.optional(),preset:g().optional(),cron:g().optional(),timezone:g().optional().default("UTC"),enabled:Me().optional().default(!0),providers:G(ya).optional().default([]),sourceId:g().optional()}).refine(e=>e.preset&&!e.cron||!e.preset&&e.cron,{message:'Exactly one of "preset" or "cron" must be provided'});const mE=je(["mentioned","cited"]);mE.enum;R({id:g(),projectId:g(),propertyId:g(),clientEmail:g(),connected:Me(),createdAt:g(),updatedAt:g()});R({date:g(),landingPage:g(),sessions:k(),organicSessions:k(),users:k()});const Mf=je(["session","first_user","manual_utm"]),hE=R({source:g(),medium:g(),sessions:k(),users:k(),sourceDimension:Mf}),fE=R({source:g(),medium:g(),sourceDimension:Mf,landingPage:g(),sessions:k(),users:k()}),pE=R({source:g(),medium:g(),sessions:k(),users:k(),channelGroup:g()}),Xl=R({sessions:k(),sharePct:k(),sharePctDisplay:g()}),gE=R({organic:Xl,social:Xl,direct:Xl,ai:Xl,other:Xl});R({totalSessions:k(),totalOrganicSessions:k(),totalDirectSessions:k(),totalUsers:k(),topPages:G(R({landingPage:g(),sessions:k(),organicSessions:k(),directSessions:k(),users:k()})),aiReferrals:G(hE),aiReferralLandingPages:G(fE),aiSessionsDeduped:k(),aiUsersDeduped:k(),aiSessionsBySession:k(),aiUsersBySession:k(),socialReferrals:G(pE),socialSessions:k(),socialUsers:k(),channelBreakdown:gE,organicSharePct:k(),aiSharePct:k(),aiSharePctBySession:k(),directSharePct:k(),socialSharePct:k(),organicSharePctDisplay:g(),aiSharePctDisplay:g(),aiSharePctBySessionDisplay:g(),directSharePctDisplay:g(),socialSharePctDisplay:g(),otherSessions:k(),otherSharePct:k(),otherSharePctDisplay:g(),lastSyncedAt:g().nullable()});R({connected:Me(),propertyId:g().nullable(),clientEmail:g().nullable(),authMethod:je(["service-account","oauth"]).nullable(),lastSyncedAt:g().nullable(),createdAt:g().nullable().optional(),updatedAt:g().nullable().optional()});R({synced:Me(),rowCount:k().int().nonnegative(),aiReferralCount:k().int().nonnegative(),socialReferralCount:k().int().nonnegative(),days:k().int().nonnegative(),syncedAt:g(),syncedComponents:G(g()).optional()});R({date:g(),source:g(),medium:g(),landingPage:g(),sessions:k(),users:k(),sourceDimension:Mf});R({date:g(),source:g(),medium:g(),sessions:k(),users:k(),channelGroup:g()});R({date:g(),sessions:k(),organicSessions:k(),users:k()});function wu(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}const kj=je(["claude","openai","gemini","zai"]),xE=R({id:kj,label:g(),defaultModel:g(),configured:Me(),keySource:je(["config","env"]).nullable()});R({providers:G(xE).default([]),defaultProvider:kj.nullable()});const yE=je(["aero","user","compaction"]);yE.enum;const Cj=128;R({key:g().min(1).max(Cj),value:g().min(1)});R({key:g().min(1).max(Cj)});const $f=je(["queued","downloading","querying","ready","failed"]);$f.enum;R({id:g(),release:g(),status:$f,phaseDetail:g().nullable().optional(),vertexPath:g().nullable().optional(),edgesPath:g().nullable().optional(),vertexSha256:g().nullable().optional(),edgesSha256:g().nullable().optional(),vertexBytes:k().int().nullable().optional(),edgesBytes:k().int().nullable().optional(),projectsProcessed:k().int().nullable().optional(),domainsDiscovered:k().int().nullable().optional(),downloadStartedAt:g().nullable().optional(),downloadFinishedAt:g().nullable().optional(),queryStartedAt:g().nullable().optional(),queryFinishedAt:g().nullable().optional(),error:g().nullable().optional(),createdAt:g(),updatedAt:g()});const bE=R({linkingDomain:g(),numHosts:k().int()}),vE=R({projectId:g(),release:g(),targetDomain:g(),totalLinkingDomains:k().int(),totalHosts:k().int(),top10HostsShare:g(),queriedAt:g(),excludedLinkingDomains:k().int().optional(),excludedHosts:k().int().optional()});R({summary:vE.nullable(),total:k().int(),rows:G(bE)});R({release:g(),totalLinkingDomains:k().int(),totalHosts:k().int(),top10HostsShare:g(),queriedAt:g()});R({duckdbInstalled:Me(),duckdbVersion:g().nullable().optional(),duckdbSpec:g(),pluginDir:g()});R({installed:Me(),version:g(),path:g(),alreadyPresent:Me()});R({release:g(),vertexUrl:g(),edgesUrl:g(),vertexBytes:k().int().nullable(),edgesBytes:k().int().nullable(),lastModified:g().nullable()});R({release:g(),syncStatus:$f.nullable(),bytes:k().int(),lastUsedAt:g().nullable()});je(["snapshot","insight"]);const jE=R({kind:Qn("snapshot"),id:g(),runId:g(),query:g(),provider:g(),model:g().nullable(),citationState:Li,matchedField:je(["answerText","citedDomains","searchQueries","query"]),snippet:g(),createdAt:g()}),NE=R({kind:Qn("insight"),id:g(),runId:g().nullable(),type:je(["regression","gain","opportunity","first-citation","provider-pickup","persistent-gap","competitor-gained","competitor-lost"]),severity:je(["critical","high","medium","low"]),title:g(),query:g(),provider:g(),matchedField:je(["title","query","recommendation","cause"]),snippet:g(),dismissed:Me(),createdAt:g()}),wE=hj("kind",[jE,NE]);R({query:g(),totalHits:k().int().nonnegative(),truncated:Me(),hits:G(wE)});const Aj=je(["create","expand","refresh","add-schema"]);Aj.enum;function SE(e){switch(e){case"create":return"Create";case"expand":return"Expand";case"refresh":return"Refresh";case"add-schema":return"Add schema"}}const Tj=je(["gsc","competitor-evidence","both"]);Tj.enum;const _j=je(["high","medium","low"]);_j.enum;const zE=je(["blog-post","comparison","listicle","how-to","guide","glossary"]);zE.enum;const Ej=je(["proposed","briefed","payload-generated","draft-created","published","validated","dismissed"]);Ej.enum;const kE=R({url:g(),gscImpressions:k().nonnegative(),gscClicks:k().nonnegative(),gscAvgPosition:k().nonnegative().nullable(),organicSessions:k().nonnegative()}),CE=R({domain:g(),url:g(),title:g(),citationCount:k().int().nonnegative()}),AE=R({demand:k(),competitor:k(),absence:k(),gapSeverity:k()}),TE=R({actionId:g(),state:Ej,lastUpdated:g()}),Dj=R({targetRef:g(),query:g(),action:Aj,ourBestPage:kE.nullable(),winningCompetitor:CE.nullable(),score:k(),scoreBreakdown:AE,drivers:G(g()),demandSource:Tj,actionConfidence:_j,existingAction:TE.nullable()});R({targets:G(Dj),contextMetrics:R({totalAiReferralSessions:k().int().nonnegative(),latestRunId:g(),runTimestamp:g()})});const _E=R({uri:g(),title:g(),domain:g(),isOurDomain:Me(),isCompetitor:Me(),citationCount:k().int().nonnegative(),providers:G(ya)}),Oj=R({query:g(),groundingSources:G(_E)});R({sources:G(Oj),latestRunId:g()});const Rj=R({query:g(),competitorDomains:G(g()),competitorCount:k().int().nonnegative(),missRate:k().min(0).max(1),lastSeenInRunId:g()});R({gaps:G(Rj),latestRunId:g()});const Lj=je(["ok","warn","fail","skipped"]);Lj.enum;const Bf=je(["global","project"]);Bf.enum;const Mj=je(["auth","config","providers","integrations","database","schedules","agent"]);Mj.enum;const EE=R({id:g(),category:Mj,scope:Bf,title:g(),status:Lj,code:g().describe('Stable machine-readable code (e.g. "google.token.refresh-failed"). Use this for filtering and remediation logic.'),summary:g(),remediation:g().nullable().optional().describe('Operator-facing next step. Null when status is "ok" or no specific remediation applies.'),details:Hs(g(),Ri()).optional().describe("Structured context — principal email, redirect URI, missing scopes, etc. Stable per check id."),durationMs:k().int().nonnegative().describe("How long the check took to execute.")});R({scope:Bf,project:g().nullable().describe('Project name when scope is "project", null otherwise.'),generatedAt:g().describe("ISO-8601 timestamp when this doctor run started."),durationMs:k().int().nonnegative(),summary:R({total:k().int().nonnegative(),ok:k().int().nonnegative(),warn:k().int().nonnegative(),fail:k().int().nonnegative(),skipped:k().int().nonnegative()}),checks:G(EE)});const DE=R({provider:g(),citationState:Li,cited:Me(),mentioned:Me(),runId:g(),runCreatedAt:g()}),OE=R({queryId:g(),query:g(),providers:G(DE),citedCount:k().int().nonnegative(),mentionedCount:k().int().nonnegative(),totalProviders:k().int().nonnegative()}),RE=R({queryId:g(),query:g(),provider:g(),citingCompetitors:G(g()),runId:g(),runCreatedAt:g()}),LE=R({providersConfigured:k().int().nonnegative(),providersCiting:k().int().nonnegative(),providersMentioning:k().int().nonnegative(),totalQueries:k().int().nonnegative(),queriesCitedAndMentioned:k().int().nonnegative(),queriesCitedOnly:k().int().nonnegative(),queriesMentionedOnly:k().int().nonnegative(),queriesInvisible:k().int().nonnegative(),latestRunId:g().nullable(),latestRunAt:g().nullable()});R({summary:LE,byQuery:G(OE),competitorGaps:G(RE),status:je(["ready","no-data"]),reason:je(["no-runs-yet","no-queries"]).optional()});const ME=je(["prompt","request-param","browser-geo","ignored"]),$E=R({label:g(),city:g(),region:g(),country:g(),otherConfiguredLabels:G(g())}),BE=R({provider:g(),treatment:ME,description:g()}),qE=R({generatedAt:g(),project:R({id:g(),name:g(),displayName:g(),canonicalDomain:g(),country:g(),language:g()}),location:$E.nullable(),providerLocationHandling:G(BE),periodStart:g().nullable(),periodEnd:g().nullable()}),IE=R({citationRate:k(),citedQueryCount:k(),totalQueryCount:k(),mentionRate:k(),mentionedQueryCount:k(),trend:je(["up","down","flat","unknown"]),queryCount:k(),competitorCount:k(),providerCount:k(),gsc:R({clicks:k(),impressions:k(),ctr:k(),avgPosition:k(),periodStart:g(),periodEnd:g()}).nullable(),ga:R({sessions:k(),users:k(),periodStart:g(),periodEnd:g()}).nullable(),findings:G(R({title:g(),detail:g(),tone:je(["positive","caution","negative","neutral"])}))}),UE=R({citationState:je(["cited","not-cited","pending"]),answerMentioned:Me().nullable(),model:g().nullable()}),PE=R({queries:G(g()),providers:G(g()),matrix:G(G(UE.nullable())),providerRates:G(R({provider:g(),citedCount:k(),totalCount:k(),citationRate:k()}))}),GE=R({domain:g(),citationCount:k(),totalCount:k(),pressureLabel:je(["High","Moderate","Low","None"]),citedQueries:G(g()),sharePct:k(),theirCitedPages:G(R({url:g(),citedFor:G(g())}))}),VE=R({projectCitationCount:k(),competitors:G(GE)}),HE=R({domain:g(),mentionCount:k(),totalCount:k(),pressureLabel:je(["High","Moderate","Low","None"]),mentionedQueries:G(g()),sharePct:k()}),KE=R({projectMentionCount:k(),totalAnswerSnapshots:k(),competitors:G(HE)}),QE=R({category:g(),label:g(),count:k(),sharePct:k()}),ZE=R({categories:G(QE),topDomains:G(R({domain:g(),count:k(),isCompetitor:Me()}))}),FE=R({query:g(),clicks:k(),impressions:k(),ctr:k(),avgPosition:k(),category:je(["brand","lead-gen","industry","other"])}),YE=R({periodStart:g(),periodEnd:g(),totalClicks:k(),totalImpressions:k(),ctr:k(),avgPosition:k(),topQueries:G(FE),categoryBreakdown:G(R({category:je(["brand","lead-gen","industry","other"]),clicks:k(),impressions:k(),sharePct:k()})),trend:G(R({date:g(),clicks:k(),impressions:k()})),trackedButNoGsc:G(g()),gscButNotTracked:G(g())}),XE=R({totalSessions:k(),totalUsers:k(),totalOrganicSessions:k(),periodStart:g(),periodEnd:g(),topLandingPages:G(R({page:g(),sessions:k(),users:k(),organicSessions:k()})),channelBreakdown:G(R({channel:g(),sessions:k(),sharePct:k()}))}),JE=R({totalSessions:k(),organicSessions:k(),paidSessions:k(),channels:G(R({channelGroup:g(),sessions:k(),sharePct:k()})),topCampaigns:G(R({source:g(),medium:g(),sessions:k()}))}),WE=R({totalSessions:k(),totalUsers:k(),bySource:G(R({source:g(),sessions:k(),users:k(),sharePct:k()})),trend:G(R({date:g(),sessions:k()})),topLandingPages:G(R({page:g(),sessions:k(),users:k()}))}),eD=R({windowStart:g(),windowEnd:g(),hasData:Me(),verifiedCrawlerHits:R({current:k(),prior:k(),deltaPct:k().nullable()}),unverifiedCrawlerHits:R({current:k(),prior:k(),deltaPct:k().nullable()}),referralArrivals:R({current:k(),prior:k(),deltaPct:k().nullable()}),byOperator:G(R({operator:g(),verifiedHits:k(),unverifiedHits:k(),referralArrivals:k(),deltaPct:k().nullable()})),topCrawledPaths:G(R({path:g(),verifiedHits:k(),distinctOperators:k()})),referralProducts:G(R({product:g(),arrivals:k(),distinctLandingPaths:k()})),dailyTrend:G(R({date:g(),verifiedCrawlerHits:k(),referralArrivals:k()})),topReferralLandingPaths:G(R({path:g(),arrivals:k(),distinctProducts:k()}))}),tD=R({provider:je(["google","bing"]).nullable(),total:k(),indexed:k(),notIndexed:k(),deindexed:k(),unknown:k(),indexedPct:k()}),nD=R({runId:g(),date:g(),citationRate:k(),citedQueryCount:k(),totalQueryCount:k(),mentionRate:k(),mentionedQueryCount:k(),providerRates:G(R({provider:g(),citationRate:k()}))}),Jh=R({id:g(),type:je(["regression","gain","opportunity"]),severity:je(["critical","high","medium","low"]),title:g(),query:g(),provider:g(),recommendation:g().nullable(),createdAt:g(),instanceCount:k()}),sD=R({horizon:je(["immediate","short-term","medium-term"]),title:g(),rationale:g()}),Jl=R({current:k(),prior:k(),deltaAbs:k(),direction:je(["up","down","flat"]),window:k().optional()}),aD=R({provider:g(),current:k(),prior:k(),deltaAbs:k(),direction:je(["up","down","flat"])}),iD=R({enoughHistory:Me(),headline:g(),citationRate:Jl.nullable(),mentionRate:Jl.nullable(),citedQueryCount:Jl.nullable(),gscClicksDelta:Jl.nullable(),aiReferralsDelta:Jl.nullable(),providerMovements:G(aD),wins:G(Jh),regressions:G(Jh)});je(["agency","client"]);const rD=je(["agency","client","both"]),lD=je(["immediate","short-term","medium-term"]),oD=je(["high","medium","low"]);je(["positive","caution","negative","neutral"]);const cD=je(["content","competitors","provider","search-demand","indexing","location","monitoring"]),qf=R({audience:rD,priority:k(),horizon:lD,category:cD,title:g(),action:g(),why:G(g()),evidence:G(g()),successMetric:g(),confidence:oD}),uD=R({headline:g(),overview:g(),actionItems:G(qf),confidenceNotes:G(g())}),dD=R({title:g(),detail:g(),severity:je(["positive","caution","negative","neutral"]),evidence:G(g())}),mD=R({priorities:G(qf),diagnostics:G(dD)});function hD(e){return e.horizon==="immediate"?"negative":e.confidence==="high"?"caution":e.confidence==="low"?"neutral":"caution"}function fD(e){switch(e){case"critical":return"Critical";case"high":return"High";case"medium":return"Medium";case"low":return"Low"}}function pD(e){switch(e){case"immediate":return"Immediate";case"short-term":return"Short term";case"medium-term":return"Medium term"}}function gD(e){switch(e){case"content":return"Content";case"competitors":return"Competitors";case"provider":return"Provider";case"search-demand":return"Search demand";case"indexing":return"Indexing";case"location":return"Location";case"monitoring":return"Monitoring"}}function xD(e){switch(e){case"high":return"High";case"medium":return"Medium";case"low":return"Low"}}R({meta:qE,executiveSummary:IE,citationScorecard:PE,competitorLandscape:VE,mentionLandscape:KE,aiSourceOrigin:ZE,gsc:YE.nullable(),ga:XE.nullable(),socialReferrals:JE.nullable(),aiReferrals:WE.nullable(),serverActivity:eD.nullable(),indexingHealth:tD.nullable(),citationsTrend:G(nD),whatsChanged:iD,insights:G(Jh),recommendedNextSteps:G(sD),actionPlan:G(qf),clientSummary:uD,agencyDiagnostics:mD,contentOpportunities:G(Dj),contentGaps:G(Rj),groundingSources:G(Oj)});const yD=new Set(["a","an","and","for","from","in","near","of","on","or","the","to"]);function $j(e){return e.toLowerCase().match(/[a-z0-9]+/g)??[]}function Bj(e){return e.length>4&&e.endsWith("ies")?`${e.slice(0,-3)}y`:e.length>4&&e.endsWith("s")&&!e.endsWith("ss")?e.slice(0,-1):e}function qj(e){const s=e.meta.location;return s?new Set([s.label,s.city,s.region,s.country].flatMap($j).map(Bj).filter(Boolean)):new Set}function Ij(e,s){const i=$j(e).map(Bj).filter(Boolean).filter(r=>!yD.has(r)).filter(r=>!s.has(r));return[...new Set(i)].sort().join(" ")}function bD(e){return e.title.match(/"([^"]+)"/)?.[1]??e.successMetric.match(/"([^"]+)"/)?.[1]??e.title}function vD(e,s){const i=qj(e);if(s.length<=1||i.size===0)return[...s];const r=new Set,o=[];for(const u of s){if(u.category!=="content"){o.push(u);continue}const d=Ij(bD(u),i);!d||r.has(d)||(r.add(d),o.push(u))}return o}function jD(e){const s=qj(e),i=e.contentOpportunities;if(i.length<=1||s.size===0)return i;const r=new Set;return i.filter(o=>{const u=Ij(o.query,s);return!u||r.has(u)?!1:(r.add(u),!0)})}const ND=je(["claude","codex"]);ND.enum;const wD=je(["claude","codex","all"]);wD.enum;const If=je(["cloud-run","wordpress","cloudflare","vercel","generic-log"]);If.enum;const SD=je(["raw-request-events","aggregate-request-metrics","request-url","status-code","user-agent","remote-ip","referer","cursor-pull"]);SD.enum;const zD=je(["raw-request","aggregate-bucket"]),kD=zD.enum,CD=je(["observed","provider-aggregated","inferred"]),AD=CD.enum,TD=R({type:g().nullable(),labels:Hs(g(),g())}),_D=R({sourceType:If,evidenceKind:Qn(kD["raw-request"]),confidence:Qn(AD.observed),eventId:g().min(1),observedAt:g().min(1),method:g().nullable(),requestUrl:g().nullable(),host:g().nullable(),path:g().min(1),queryString:g().nullable(),status:k().int().nullable(),userAgent:g().nullable(),remoteIp:g().nullable(),referer:g().nullable(),latencyMs:k().nullable(),requestSizeBytes:k().int().nullable(),responseSizeBytes:k().int().nullable(),providerResource:TD,providerLabels:Hs(g(),g())});R({events:G(_D),rawEntryCount:k().int().nonnegative(),skippedEntryCount:k().int().nonnegative(),nextPageToken:g().optional(),filter:g()});const Uj=je(["connected","paused","error","archived"]),ro=Uj.enum,Pj=je(["oauth","service-account"]);Pj.enum;const ED=je(["verified","claimed_unverified","unknown_ai_like"]);ED.enum;R({gcpProjectId:g().min(1),serviceName:g().nullable().optional(),location:g().nullable().optional(),authMode:Pj});R({baseUrl:g().url(),username:g().min(1)});const Uf=je(["production","preview"]);Uf.enum;R({projectId:g().min(1),teamId:g().min(1),environment:Uf});const Gj=R({id:g(),projectId:g(),sourceType:If,displayName:g(),status:Uj,lastSyncedAt:g().nullable(),lastCursor:g().nullable(),lastError:g().nullable(),archivedAt:g().nullable(),config:Hs(g(),Ri()),createdAt:g(),updatedAt:g()});R({gcpProjectId:g().min(1),serviceName:g().min(1).optional(),location:g().min(1).optional(),displayName:g().min(1).optional(),keyJson:g().optional()});R({baseUrl:g().url(),username:g().min(1),applicationPassword:g().min(1),displayName:g().min(1).optional()});R({projectId:g().min(1),teamId:g().min(1),token:g().min(1),environment:Uf.optional(),displayName:g().min(1).optional()});R({sourceId:g(),runId:g(),syncedAt:g(),pulledEvents:k().int().nonnegative(),crawlerHits:k().int().nonnegative(),aiReferralHits:k().int().nonnegative(),unknownHits:k().int().nonnegative(),crawlerBucketRows:k().int().nonnegative(),aiReferralBucketRows:k().int().nonnegative(),sampleRows:k().int().nonnegative(),windowStart:g(),windowEnd:g()});R({days:k().int().positive().optional()});R({sourceId:g(),runId:g(),status:Mu,windowStart:g(),windowEnd:g(),daysRequested:k().int().positive(),daysApplied:k().int().positive()});const DD=R({crawlerHits:k().int().nonnegative(),aiReferralHits:k().int().nonnegative(),sampleCount:k().int().nonnegative()});R({sources:G(Gj)});const OD=Gj.extend({totals24h:DD,latestRun:R({runId:g(),status:Mu,startedAt:g().nullable(),finishedAt:g().nullable(),error:g().nullable()}).nullable()});R({sources:G(OD)});const RD=je(["crawler","ai-referral"]),Gs=RD.enum,LD=R({kind:Qn(Gs.crawler),sourceId:g(),tsHour:g(),botId:g(),operator:g(),verificationStatus:g(),pathNormalized:g(),status:k().int(),hits:k().int().nonnegative()}),MD=R({kind:Qn(Gs["ai-referral"]),sourceId:g(),tsHour:g(),product:g(),operator:g(),sourceDomain:g(),evidenceType:g(),landingPathNormalized:g(),status:k().int(),hits:k().int().nonnegative()}),$D=hj("kind",[LD,MD]);R({windowStart:g(),windowEnd:g(),totals:R({crawlerHits:k().int().nonnegative(),aiReferralHits:k().int().nonnegative()}),events:G($D)});const Pf=je(["cited","aspirational","wasted-surface"]),Zy=Pf.enum;Zy.cited,Zy.aspirational;const Gf=je(["direct-competitor","ota-aggregator","editorial-media","other","unknown"]),BD=Gf.enum;BD["direct-competitor"];const Vf=je(["queued","seeding","probing","completed","failed"]);Vf.enum;const Vj=R({domain:g().min(1),hits:k().int().positive(),competitorType:Gf.default("unknown")}),qD=R({id:g(),sessionId:g(),projectId:g(),query:g(),bucket:Pf.nullable().default(null),citationState:Li,citedDomains:G(g()).default([]),createdAt:g()}),ID=R({id:g(),projectId:g(),status:Vf,icpDescription:g().nullable().optional(),seedProvider:g().nullable().optional(),seedCountRaw:k().int().nullable().optional(),seedCount:k().int().nullable().optional(),dedupThreshold:k().nullable().optional(),probeCount:k().int().nullable().optional(),citedCount:k().int().nullable().default(null),aspirationalCount:k().int().nullable().default(null),wastedCount:k().int().nullable().default(null),competitorMap:G(Vj).default([]),error:g().nullable().optional(),startedAt:g().nullable().optional(),finishedAt:g().nullable().optional(),createdAt:g()});ID.extend({probes:G(qD).default([])});const UD=500;R({icpDescription:g().min(1).optional(),dedupThreshold:k().min(0).max(1).optional(),maxProbes:k().int().positive().max(UD).optional(),locations:G(g().min(1)).optional()});R({buckets:G(Pf).min(1).optional(),includeCompetitors:Me().optional(),competitorTypes:G(Gf).min(1).optional()});R({sessionId:g(),projectId:g(),status:Vf,queriesByBucket:R({cited:G(g()),aspirational:G(g()),"wasted-surface":G(g())}),suggestedCompetitors:G(Vj)});R({sessionId:g(),projectId:g(),promoted:R({queries:G(g()),competitors:G(g())}),skipped:R({queries:G(g()),competitors:G(g())})});mj([Qn("cli"),g().regex(/^discovery:.+$/)]);function jh(e){return Number.isFinite(e)?Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString("en-US"):"—"}function PD(e,s){return s<=0?null:Math.round((e-s)/s*100)}function Fy(e,s,i="vs prior 7 days"){return e.deltaPct===null?e.prior===0?"First baseline week":"":e.deltaPct>0?`Up ${e.deltaPct}% ${i} (${jh(e.prior)} ${s})`:e.deltaPct<0?`Down ${Math.abs(e.deltaPct)}% ${i} (${jh(e.prior)} ${s})`:`Flat ${i} (${jh(e.prior)} ${s})`}var Wa=(e=>(e.Clicks="clicks",e.Impressions="impressions",e.CTR="ctr",e.Position="position",e))(Wa||{});const GD={clicks:"Clicks",impressions:"Impressions",ctr:"CTR",position:"Position"},Uc={clicks:"Clicks",impressions:"Impr",ctr:"CTR",position:"Pos"},VD=Rf;function HD(e){const s=[];if(e.message&&s.push(e.message),e.providers)for(const[i,r]of Object.entries(e.providers)){const o=`[${i}] ${r.message}`;r.raw!==void 0?s.push(`${o}
52
-
53
- ${JSON.stringify(r.raw,null,2)}`):s.push(o)}return s.length>0?s.join(`
54
-
55
- `):"Run failed."}function $u(e){return e.split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" ")}function $s(e){if(!e)return"—";try{return new Date(e).toLocaleString()}catch{return e}}function Yy(e){return e===null?"Unknown":e?"Pass":"Fail"}function Wh(e){return e===0?"12:00 AM":e<12?`${e}:00 AM`:e===12?"12:00 PM":`${e-12}:00 PM`}function KD(e,s){return e==="twice-daily"?"twice-daily":e.startsWith("weekly@")?`${e}@${s}`:`daily@${s}`}function QD(e,s){if(!e)return{freq:"custom",hour:6,customCron:s};if(e==="twice-daily")return{freq:"twice-daily",hour:6,customCron:""};const i=e.match(/^daily(?:@(\d+))?$/);if(i)return{freq:"daily",hour:i[1]?parseInt(i[1]):6,customCron:""};const r=e.match(/^(weekly@(?:mon|tue|wed|thu|fri|sat|sun))(?:@(\d+))?$/);return r?{freq:r[1],hour:r[2]?parseInt(r[2]):6,customCron:""}:{freq:"custom",hour:6,customCron:s}}function Nh(e,s,i){const r=i==="UTC"?"UTC":i.split("/").pop()?.replace(/_/g," ")??i;if(!e)return`Custom: ${s} · ${r}`;if(e==="twice-daily")return`Twice a day (6am & 6pm) · ${r}`;const o=e.match(/^daily(?:@(\d+))?$/);if(o){const d=o[1]?parseInt(o[1]):6;return`Every day at ${Wh(d)} · ${r}`}const u=e.match(/^weekly@(mon|tue|wed|thu|fri|sat|sun)(?:@(\d+))?$/);if(u){const d={mon:"Monday",tue:"Tuesday",wed:"Wednesday",thu:"Thursday",fri:"Friday",sat:"Saturday",sun:"Sunday"},h=u[2]?parseInt(u[2]):6;return`Every ${d[u[1]]} at ${Wh(h)} · ${r}`}return`${e} · ${r}`}const xt=(e,s,i,r)=>{const o={_id:e,baseUrl:s?.baseUrl||(s?.client??xe).getConfig().baseUrl};return s?.body&&(o.body=s.body),s?.headers&&(o.headers=s.headers),s?.path&&(o.path=s.path),s?.query&&(o.query=s.query),[o]},li=e=>xt("getApiV1Projects",e),Bu=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await xz({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:li(e)}),No=e=>xt("getApiV1Runs",e),Hj=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await _z({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:No(e)}),ZD=e=>xt("getApiV1RunsById",e),Kj=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await dv({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:ZD(e)}),FD=e=>xt("getApiV1Settings",e),Qj=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await mv({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:FD(e)}),YD=e=>xt("getApiV1ProjectsByNameGoogleConnections",e),Zj=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await Kz({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:YD(e)}),XD=e=>xt("getApiV1ProjectsByNameGoogleProperties",e),JD=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await Fz({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:XD(e)}),WD=e=>xt("getApiV1ProjectsByNameGoogleGscPerformance",e),eO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await Wz({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:WD(e)}),tO=e=>xt("getApiV1ProjectsByNameGoogleGscPerformanceDaily",e),nO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await ek({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:tO(e)}),sO=e=>xt("getApiV1ProjectsByNameGoogleGscInspections",e),aO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await nk({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:sO(e)}),iO=e=>xt("getApiV1ProjectsByNameGoogleGscDeindexed",e),rO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await sk({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:iO(e)}),lO=e=>xt("getApiV1ProjectsByNameGoogleGscCoverage",e),Fj=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await hv({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:lO(e)}),oO=e=>xt("getApiV1ProjectsByNameGoogleGscCoverageHistory",e),cO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await ak({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:oO(e)}),uO=e=>xt("getApiV1ProjectsByNameGoogleGscSitemaps",e),dO=e=>xt("getApiV1ProjectsByNameBingStatus",e),Yj=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await dk({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:dO(e)}),mO=e=>xt("getApiV1ProjectsByNameBingSites",e),hO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await mk({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:mO(e)}),fO=e=>xt("getApiV1ProjectsByNameBingCoverage",e),Xj=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await fv({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:fO(e)}),pO=e=>xt("getApiV1ProjectsByNameBingInspections",e),Jj=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await fk({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:pO(e)}),gO=e=>xt("getApiV1ProjectsByNameBingPerformance",e),xO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await yk({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:gO(e)}),yO=e=>xt("getApiV1ProjectsByNameGaStatus",e),bO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await jk({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:yO(e)}),vO=e=>xt("getApiV1ProjectsByNameGaTraffic",e),jO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await wk({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:vO(e)}),NO=e=>xt("getApiV1ProjectsByNameGaAiReferralHistory",e),wO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await Sk({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:NO(e)}),SO=e=>xt("getApiV1ProjectsByNameGaSocialReferralHistory",e),zO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await zk({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:SO(e)}),kO=e=>xt("getApiV1ProjectsByNameGaSessionHistory",e),CO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await kk({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:kO(e)}),AO=e=>xt("getApiV1ProjectsByNameReport",e),TO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await Ak({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:AO(e)}),_O=e=>xt("getApiV1ProjectsByNameCitationsVisibility",e),EO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await Tk({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:_O(e)}),DO=e=>xt("getApiV1ProjectsByNameTrafficSources",e),OO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await Qk({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:DO(e)}),RO=e=>xt("getApiV1ProjectsByNameTrafficStatus",e),LO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await Zk({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:RO(e)}),MO=e=>xt("getApiV1ProjectsByNameTrafficSourcesById",e),Wj=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await Fk({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:MO(e)}),$O=e=>xt("getApiV1ProjectsByNameTrafficEvents",e),BO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await Yk({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:$O(e)}),qO=e=>xt("getApiV1ProjectsByNameDiscoverSessions",e),IO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await Jk({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:qO(e)}),UO=e=>xt("getApiV1ProjectsByNameDiscoverSessionsById",e),PO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await Wk({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:UO(e)}),GO=e=>xt("getApiV1ProjectsByNameDiscoverSessionsByIdPromote",e),VO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await e2({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:GO(e)}),HO=e=>xt("getApiV1ProjectsByNameAgentProviders",e),KO=e=>vt({queryFn:async({queryKey:s,signal:i})=>{const{data:r}=await n2({...e,...s[0],signal:i,throwOnError:!0});return r},queryKey:HO(e)});function Su(e){return e.state==="ok"?"positive":e.state==="checking"?"neutral":"negative"}function eN(e){switch(e){case"completed":return"positive";case"partial":return"caution";case"failed":return"negative";case"cancelled":return"caution";case"queued":case"running":return"neutral";default:return"neutral"}}function QO(e){switch(e){case"cited":return"positive";case"emerging":return"caution";case"not-cited":return"caution";case"lost":return"negative";case"pending":return"neutral";default:return"neutral"}}function ZO(e){return e==="High"?"negative":e==="Moderate"?"caution":"neutral"}function FO(e){return e.displayName??e.name.charAt(0).toUpperCase()+e.name.slice(1)}function ai(e){const s=[e.detail,e.hint].filter(Boolean);return s.length>0?s.join(`
56
- `):void 0}function YO(e,s,i){return e.map(r=>{if(r.id==="api")return{...r,tone:Su(s.apiStatus),detail:s.apiStatus.state==="ok"?"Healthy":"Needs attention",meta:s.apiStatus.detail};if(r.id==="worker")return{...r,tone:Su(s.workerStatus),detail:s.workerStatus.state==="ok"?"Healthy":"Needs attention",meta:s.workerStatus.detail};const o=i.providerStatuses.filter(p=>p.state==="ready").length,u=i.providerStatuses.length,d=o>0,h=i.providerStatuses.filter(p=>p.state==="ready").map(p=>FO(p)).join(" · ");return{...r,label:"Providers",tone:d?"positive":"caution",detail:`${o} of ${u} configured`,meta:h||"None configured"}})}function XO(e,s){if(e.apiStatus.state!=="ok")return"Launch is blocked until the API responds cleanly.";if(e.apiStatus.databaseConfigured===!1)return"Launch is blocked until the API has a database connection configured.";if(e.workerStatus.state!=="ok")return"Launch is blocked until the worker is healthy and heartbeats are current.";if(!s.providerStatuses.some(i=>i.state==="ready"))return"Launch is blocked until at least one provider is configured."}function JO(e,s,i){const r=XO(s,i),o=structuredClone(e);return o.healthChecks=o.healthChecks.map(u=>{if(u.id==="api")return{...u,detail:s.apiStatus.detail,state:s.apiStatus.state==="ok"?"ready":"attention"};if(u.id==="worker")return{...u,detail:s.workerStatus.detail,state:s.workerStatus.state==="ok"?"ready":"attention"};const d=i.providerStatuses.some(h=>h.state==="ready");return{...u,detail:d?"At least one provider configured.":"No providers configured.",state:d?"ready":"attention"}}),o.launchState.enabled=r===void 0,o.launchState.blockedReason=r,o.launchState.summary=r??"Queue a visibility sweep first, then follow with a site audit to explain movement.",o}const tN="canonry.run-tracker",ef=new Set;let Xy=!1,WO=0,qu={runs:{},batches:{}};function eR(){const e=Mi();for(const s of ef)s(e)}function tR(e){if(!e)return{runs:{},batches:{}};try{const s=JSON.parse(e);return{runs:s.runs??{},batches:s.batches??{}}}catch{return{runs:{},batches:{}}}}function nR(){typeof window>"u"||window.sessionStorage.setItem(tN,JSON.stringify(qu))}function nN(){Xy||(Xy=!0,!(typeof window>"u")&&(qu=tR(window.sessionStorage.getItem(tN))))}function Iu(e){qu=e,nR(),eR()}function Mi(){return nN(),qu}function sR(e){return nN(),ef.add(e),()=>{ef.delete(e)}}function sN(e){const s=Mi();Iu({...s,runs:{...s.runs,[e.id]:{runId:e.id,projectId:e.projectId,projectLabel:e.projectLabel,kind:e.kind,sourceAction:e.sourceAction,lastAnnouncedStatus:e.lastAnnouncedStatus??"queued"}}})}function Jy(e){const s=Mi();if(!s.runs[e])return;const{[e]:i,...r}=s.runs;Iu({...s,runs:r})}function aR(e){const s=Mi(),i=`batch_${Date.now()}_${++WO}`;return Iu({...s,batches:{...s.batches,[i]:{batchId:i,runIds:e.runIds,queuedCount:e.queuedCount,skippedCount:e.skippedCount}}}),i}function iR(e){const s=Mi();if(!s.batches[e])return;const{[e]:i,...r}=s.batches;Iu({...s,batches:r})}function Hf(e){return e==="completed"||e==="partial"||e==="failed"||e==="cancelled"}function rR(e,s){let i=0,r=0,o=0,u=0,d=0;for(const h of e){const p=s[h]?.status;p==="completed"?i+=1:p==="partial"?r+=1:p==="failed"?o+=1:p==="cancelled"?u+=1:d+=1}return{completed:i,partial:r,failed:o,cancelled:u,pending:d,finished:d===0}}const Wy=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,eb=av,aN=(e,s)=>i=>{var r;if(s?.variants==null)return eb(e,i?.class,i?.className);const{variants:o,defaultVariants:u}=s,d=Object.keys(o).map(x=>{const b=i?.[x],v=u?.[x];if(b===null)return null;const N=Wy(b)||Wy(v);return o[x][N]}),h=i&&Object.entries(i).reduce((x,b)=>{let[v,N]=b;return N===void 0||(x[v]=N),x},{}),p=s==null||(r=s.compoundVariants)===null||r===void 0?void 0:r.reduce((x,b)=>{let{class:v,className:N,...z}=b;return Object.entries(z).every(T=>{let[w,A]=T;return Array.isArray(A)?A.includes({...u,...h}[w]):{...u,...h}[w]===A})?[...x,v,N]:x},[]);return eb(e,d,p,i?.class,i?.className)},lR=(e,s)=>{const i=new Array(e.length+s.length);for(let r=0;r<e.length;r++)i[r]=e[r];for(let r=0;r<s.length;r++)i[e.length+r]=s[r];return i},oR=(e,s)=>({classGroupId:e,validator:s}),iN=(e=new Map,s=null,i)=>({nextPart:e,validators:s,classGroupId:i}),zu="-",tb=[],cR="arbitrary..",uR=e=>{const s=mR(e),{conflictingClassGroups:i,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:d=>{if(d.startsWith("[")&&d.endsWith("]"))return dR(d);const h=d.split(zu),p=h[0]===""&&h.length>1?1:0;return rN(h,p,s)},getConflictingClassGroupIds:(d,h)=>{if(h){const p=r[d],x=i[d];return p?x?lR(x,p):p:x||tb}return i[d]||tb}}},rN=(e,s,i)=>{if(e.length-s===0)return i.classGroupId;const o=e[s],u=i.nextPart.get(o);if(u){const x=rN(e,s+1,u);if(x)return x}const d=i.validators;if(d===null)return;const h=s===0?e.join(zu):e.slice(s).join(zu),p=d.length;for(let x=0;x<p;x++){const b=d[x];if(b.validator(h))return b.classGroupId}},dR=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const s=e.slice(1,-1),i=s.indexOf(":"),r=s.slice(0,i);return r?cR+r:void 0})(),mR=e=>{const{theme:s,classGroups:i}=e;return hR(i,s)},hR=(e,s)=>{const i=iN();for(const r in e){const o=e[r];Kf(o,i,r,s)}return i},Kf=(e,s,i,r)=>{const o=e.length;for(let u=0;u<o;u++){const d=e[u];fR(d,s,i,r)}},fR=(e,s,i,r)=>{if(typeof e=="string"){pR(e,s,i);return}if(typeof e=="function"){gR(e,s,i,r);return}xR(e,s,i,r)},pR=(e,s,i)=>{const r=e===""?s:lN(s,e);r.classGroupId=i},gR=(e,s,i,r)=>{if(yR(e)){Kf(e(r),s,i,r);return}s.validators===null&&(s.validators=[]),s.validators.push(oR(i,e))},xR=(e,s,i,r)=>{const o=Object.entries(e),u=o.length;for(let d=0;d<u;d++){const[h,p]=o[d];Kf(p,lN(s,h),i,r)}},lN=(e,s)=>{let i=e;const r=s.split(zu),o=r.length;for(let u=0;u<o;u++){const d=r[u];let h=i.nextPart.get(d);h||(h=iN(),i.nextPart.set(d,h)),i=h}return i},yR=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,bR=e=>{if(e<1)return{get:()=>{},set:()=>{}};let s=0,i=Object.create(null),r=Object.create(null);const o=(u,d)=>{i[u]=d,s++,s>e&&(s=0,r=i,i=Object.create(null))};return{get(u){let d=i[u];if(d!==void 0)return d;if((d=r[u])!==void 0)return o(u,d),d},set(u,d){u in i?i[u]=d:o(u,d)}}},tf="!",nb=":",vR=[],sb=(e,s,i,r,o)=>({modifiers:e,hasImportantModifier:s,baseClassName:i,maybePostfixModifierPosition:r,isExternal:o}),jR=e=>{const{prefix:s,experimentalParseClassName:i}=e;let r=o=>{const u=[];let d=0,h=0,p=0,x;const b=o.length;for(let w=0;w<b;w++){const A=o[w];if(d===0&&h===0){if(A===nb){u.push(o.slice(p,w)),p=w+1;continue}if(A==="/"){x=w;continue}}A==="["?d++:A==="]"?d--:A==="("?h++:A===")"&&h--}const v=u.length===0?o:o.slice(p);let N=v,z=!1;v.endsWith(tf)?(N=v.slice(0,-1),z=!0):v.startsWith(tf)&&(N=v.slice(1),z=!0);const T=x&&x>p?x-p:void 0;return sb(u,z,N,T)};if(s){const o=s+nb,u=r;r=d=>d.startsWith(o)?u(d.slice(o.length)):sb(vR,!1,d,void 0,!0)}if(i){const o=r;r=u=>i({className:u,parseClassName:o})}return r},NR=e=>{const s=new Map;return e.orderSensitiveModifiers.forEach((i,r)=>{s.set(i,1e6+r)}),i=>{const r=[];let o=[];for(let u=0;u<i.length;u++){const d=i[u],h=d[0]==="[",p=s.has(d);h||p?(o.length>0&&(o.sort(),r.push(...o),o=[]),r.push(d)):o.push(d)}return o.length>0&&(o.sort(),r.push(...o)),r}},wR=e=>({cache:bR(e.cacheSize),parseClassName:jR(e),sortModifiers:NR(e),...uR(e)}),SR=/\s+/,zR=(e,s)=>{const{parseClassName:i,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:u}=s,d=[],h=e.trim().split(SR);let p="";for(let x=h.length-1;x>=0;x-=1){const b=h[x],{isExternal:v,modifiers:N,hasImportantModifier:z,baseClassName:T,maybePostfixModifierPosition:w}=i(b);if(v){p=b+(p.length>0?" "+p:p);continue}let A=!!w,D=r(A?T.substring(0,w):T);if(!D){if(!A){p=b+(p.length>0?" "+p:p);continue}if(D=r(T),!D){p=b+(p.length>0?" "+p:p);continue}A=!1}const U=N.length===0?"":N.length===1?N[0]:u(N).join(":"),I=z?U+tf:U,C=I+D;if(d.indexOf(C)>-1)continue;d.push(C);const L=o(D,A);for(let M=0;M<L.length;++M){const _=L[M];d.push(I+_)}p=b+(p.length>0?" "+p:p)}return p},kR=(...e)=>{let s=0,i,r,o="";for(;s<e.length;)(i=e[s++])&&(r=oN(i))&&(o&&(o+=" "),o+=r);return o},oN=e=>{if(typeof e=="string")return e;let s,i="";for(let r=0;r<e.length;r++)e[r]&&(s=oN(e[r]))&&(i&&(i+=" "),i+=s);return i},CR=(e,...s)=>{let i,r,o,u;const d=p=>{const x=s.reduce((b,v)=>v(b),e());return i=wR(x),r=i.cache.get,o=i.cache.set,u=h,h(p)},h=p=>{const x=r(p);if(x)return x;const b=zR(p,i);return o(p,b),b};return u=d,(...p)=>u(kR(...p))},AR=[],ln=e=>{const s=i=>i[e]||AR;return s.isThemeGetter=!0,s},cN=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,uN=/^\((?:(\w[\w-]*):)?(.+)\)$/i,TR=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,_R=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ER=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,DR=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,OR=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,RR=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Za=e=>TR.test(e),nt=e=>!!e&&!Number.isNaN(Number(e)),Fa=e=>!!e&&Number.isInteger(Number(e)),wh=e=>e.endsWith("%")&&nt(e.slice(0,-1)),fa=e=>_R.test(e),dN=()=>!0,LR=e=>ER.test(e)&&!DR.test(e),Qf=()=>!1,MR=e=>OR.test(e),$R=e=>RR.test(e),BR=e=>!_e(e)&&!Ee(e),qR=e=>oi(e,fN,Qf),_e=e=>cN.test(e),Ti=e=>oi(e,pN,LR),ab=e=>oi(e,QR,nt),IR=e=>oi(e,xN,dN),UR=e=>oi(e,gN,Qf),ib=e=>oi(e,mN,Qf),PR=e=>oi(e,hN,$R),Pc=e=>oi(e,yN,MR),Ee=e=>uN.test(e),Wl=e=>Ui(e,pN),GR=e=>Ui(e,gN),rb=e=>Ui(e,mN),VR=e=>Ui(e,fN),HR=e=>Ui(e,hN),Gc=e=>Ui(e,yN,!0),KR=e=>Ui(e,xN,!0),oi=(e,s,i)=>{const r=cN.exec(e);return r?r[1]?s(r[1]):i(r[2]):!1},Ui=(e,s,i=!1)=>{const r=uN.exec(e);return r?r[1]?s(r[1]):i:!1},mN=e=>e==="position"||e==="percentage",hN=e=>e==="image"||e==="url",fN=e=>e==="length"||e==="size"||e==="bg-size",pN=e=>e==="length",QR=e=>e==="number",gN=e=>e==="family-name",xN=e=>e==="number"||e==="weight",yN=e=>e==="shadow",ZR=()=>{const e=ln("color"),s=ln("font"),i=ln("text"),r=ln("font-weight"),o=ln("tracking"),u=ln("leading"),d=ln("breakpoint"),h=ln("container"),p=ln("spacing"),x=ln("radius"),b=ln("shadow"),v=ln("inset-shadow"),N=ln("text-shadow"),z=ln("drop-shadow"),T=ln("blur"),w=ln("perspective"),A=ln("aspect"),D=ln("ease"),U=ln("animate"),I=()=>["auto","avoid","all","avoid-page","page","left","right","column"],C=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],L=()=>[...C(),Ee,_e],M=()=>["auto","hidden","clip","visible","scroll"],_=()=>["auto","contain","none"],B=()=>[Ee,_e,p],J=()=>[Za,"full","auto",...B()],ue=()=>[Fa,"none","subgrid",Ee,_e],P=()=>["auto",{span:["full",Fa,Ee,_e]},Fa,Ee,_e],ie=()=>[Fa,"auto",Ee,_e],te=()=>["auto","min","max","fr",Ee,_e],ze=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],ve=()=>["start","end","center","stretch","center-safe","end-safe"],V=()=>["auto",...B()],ne=()=>[Za,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...B()],me=()=>[Za,"screen","full","dvw","lvw","svw","min","max","fit",...B()],Ne=()=>[Za,"screen","full","lh","dvh","lvh","svh","min","max","fit",...B()],se=()=>[e,Ee,_e],pe=()=>[...C(),rb,ib,{position:[Ee,_e]}],E=()=>["no-repeat",{repeat:["","x","y","space","round"]}],X=()=>["auto","cover","contain",VR,qR,{size:[Ee,_e]}],Y=()=>[wh,Wl,Ti],ye=()=>["","none","full",x,Ee,_e],le=()=>["",nt,Wl,Ti],Re=()=>["solid","dashed","dotted","double"],tt=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],we=()=>[nt,wh,rb,ib],Ue=()=>["","none",T,Ee,_e],Ce=()=>["none",nt,Ee,_e],mt=()=>["none",nt,Ee,_e],Nt=()=>[nt,Ee,_e],pt=()=>[Za,"full",...B()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[fa],breakpoint:[fa],color:[dN],container:[fa],"drop-shadow":[fa],ease:["in","out","in-out"],font:[BR],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[fa],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[fa],shadow:[fa],spacing:["px",nt],text:[fa],"text-shadow":[fa],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Za,_e,Ee,A]}],container:["container"],columns:[{columns:[nt,_e,Ee,h]}],"break-after":[{"break-after":I()}],"break-before":[{"break-before":I()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:L()}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:_()}],"overscroll-x":[{"overscroll-x":_()}],"overscroll-y":[{"overscroll-y":_()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:J()}],"inset-x":[{"inset-x":J()}],"inset-y":[{"inset-y":J()}],start:[{"inset-s":J(),start:J()}],end:[{"inset-e":J(),end:J()}],"inset-bs":[{"inset-bs":J()}],"inset-be":[{"inset-be":J()}],top:[{top:J()}],right:[{right:J()}],bottom:[{bottom:J()}],left:[{left:J()}],visibility:["visible","invisible","collapse"],z:[{z:[Fa,"auto",Ee,_e]}],basis:[{basis:[Za,"full","auto",h,...B()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[nt,Za,"auto","initial","none",_e]}],grow:[{grow:["",nt,Ee,_e]}],shrink:[{shrink:["",nt,Ee,_e]}],order:[{order:[Fa,"first","last","none",Ee,_e]}],"grid-cols":[{"grid-cols":ue()}],"col-start-end":[{col:P()}],"col-start":[{"col-start":ie()}],"col-end":[{"col-end":ie()}],"grid-rows":[{"grid-rows":ue()}],"row-start-end":[{row:P()}],"row-start":[{"row-start":ie()}],"row-end":[{"row-end":ie()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":te()}],"auto-rows":[{"auto-rows":te()}],gap:[{gap:B()}],"gap-x":[{"gap-x":B()}],"gap-y":[{"gap-y":B()}],"justify-content":[{justify:[...ze(),"normal"]}],"justify-items":[{"justify-items":[...ve(),"normal"]}],"justify-self":[{"justify-self":["auto",...ve()]}],"align-content":[{content:["normal",...ze()]}],"align-items":[{items:[...ve(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...ve(),{baseline:["","last"]}]}],"place-content":[{"place-content":ze()}],"place-items":[{"place-items":[...ve(),"baseline"]}],"place-self":[{"place-self":["auto",...ve()]}],p:[{p:B()}],px:[{px:B()}],py:[{py:B()}],ps:[{ps:B()}],pe:[{pe:B()}],pbs:[{pbs:B()}],pbe:[{pbe:B()}],pt:[{pt:B()}],pr:[{pr:B()}],pb:[{pb:B()}],pl:[{pl:B()}],m:[{m:V()}],mx:[{mx:V()}],my:[{my:V()}],ms:[{ms:V()}],me:[{me:V()}],mbs:[{mbs:V()}],mbe:[{mbe:V()}],mt:[{mt:V()}],mr:[{mr:V()}],mb:[{mb:V()}],ml:[{ml:V()}],"space-x":[{"space-x":B()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":B()}],"space-y-reverse":["space-y-reverse"],size:[{size:ne()}],"inline-size":[{inline:["auto",...me()]}],"min-inline-size":[{"min-inline":["auto",...me()]}],"max-inline-size":[{"max-inline":["none",...me()]}],"block-size":[{block:["auto",...Ne()]}],"min-block-size":[{"min-block":["auto",...Ne()]}],"max-block-size":[{"max-block":["none",...Ne()]}],w:[{w:[h,"screen",...ne()]}],"min-w":[{"min-w":[h,"screen","none",...ne()]}],"max-w":[{"max-w":[h,"screen","none","prose",{screen:[d]},...ne()]}],h:[{h:["screen","lh",...ne()]}],"min-h":[{"min-h":["screen","lh","none",...ne()]}],"max-h":[{"max-h":["screen","lh",...ne()]}],"font-size":[{text:["base",i,Wl,Ti]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,KR,IR]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",wh,_e]}],"font-family":[{font:[GR,UR,s]}],"font-features":[{"font-features":[_e]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,Ee,_e]}],"line-clamp":[{"line-clamp":[nt,"none",Ee,ab]}],leading:[{leading:[u,...B()]}],"list-image":[{"list-image":["none",Ee,_e]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ee,_e]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:se()}],"text-color":[{text:se()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Re(),"wavy"]}],"text-decoration-thickness":[{decoration:[nt,"from-font","auto",Ee,Ti]}],"text-decoration-color":[{decoration:se()}],"underline-offset":[{"underline-offset":[nt,"auto",Ee,_e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:B()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ee,_e]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ee,_e]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:pe()}],"bg-repeat":[{bg:E()}],"bg-size":[{bg:X()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Fa,Ee,_e],radial:["",Ee,_e],conic:[Fa,Ee,_e]},HR,PR]}],"bg-color":[{bg:se()}],"gradient-from-pos":[{from:Y()}],"gradient-via-pos":[{via:Y()}],"gradient-to-pos":[{to:Y()}],"gradient-from":[{from:se()}],"gradient-via":[{via:se()}],"gradient-to":[{to:se()}],rounded:[{rounded:ye()}],"rounded-s":[{"rounded-s":ye()}],"rounded-e":[{"rounded-e":ye()}],"rounded-t":[{"rounded-t":ye()}],"rounded-r":[{"rounded-r":ye()}],"rounded-b":[{"rounded-b":ye()}],"rounded-l":[{"rounded-l":ye()}],"rounded-ss":[{"rounded-ss":ye()}],"rounded-se":[{"rounded-se":ye()}],"rounded-ee":[{"rounded-ee":ye()}],"rounded-es":[{"rounded-es":ye()}],"rounded-tl":[{"rounded-tl":ye()}],"rounded-tr":[{"rounded-tr":ye()}],"rounded-br":[{"rounded-br":ye()}],"rounded-bl":[{"rounded-bl":ye()}],"border-w":[{border:le()}],"border-w-x":[{"border-x":le()}],"border-w-y":[{"border-y":le()}],"border-w-s":[{"border-s":le()}],"border-w-e":[{"border-e":le()}],"border-w-bs":[{"border-bs":le()}],"border-w-be":[{"border-be":le()}],"border-w-t":[{"border-t":le()}],"border-w-r":[{"border-r":le()}],"border-w-b":[{"border-b":le()}],"border-w-l":[{"border-l":le()}],"divide-x":[{"divide-x":le()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":le()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Re(),"hidden","none"]}],"divide-style":[{divide:[...Re(),"hidden","none"]}],"border-color":[{border:se()}],"border-color-x":[{"border-x":se()}],"border-color-y":[{"border-y":se()}],"border-color-s":[{"border-s":se()}],"border-color-e":[{"border-e":se()}],"border-color-bs":[{"border-bs":se()}],"border-color-be":[{"border-be":se()}],"border-color-t":[{"border-t":se()}],"border-color-r":[{"border-r":se()}],"border-color-b":[{"border-b":se()}],"border-color-l":[{"border-l":se()}],"divide-color":[{divide:se()}],"outline-style":[{outline:[...Re(),"none","hidden"]}],"outline-offset":[{"outline-offset":[nt,Ee,_e]}],"outline-w":[{outline:["",nt,Wl,Ti]}],"outline-color":[{outline:se()}],shadow:[{shadow:["","none",b,Gc,Pc]}],"shadow-color":[{shadow:se()}],"inset-shadow":[{"inset-shadow":["none",v,Gc,Pc]}],"inset-shadow-color":[{"inset-shadow":se()}],"ring-w":[{ring:le()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:se()}],"ring-offset-w":[{"ring-offset":[nt,Ti]}],"ring-offset-color":[{"ring-offset":se()}],"inset-ring-w":[{"inset-ring":le()}],"inset-ring-color":[{"inset-ring":se()}],"text-shadow":[{"text-shadow":["none",N,Gc,Pc]}],"text-shadow-color":[{"text-shadow":se()}],opacity:[{opacity:[nt,Ee,_e]}],"mix-blend":[{"mix-blend":[...tt(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":tt()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[nt]}],"mask-image-linear-from-pos":[{"mask-linear-from":we()}],"mask-image-linear-to-pos":[{"mask-linear-to":we()}],"mask-image-linear-from-color":[{"mask-linear-from":se()}],"mask-image-linear-to-color":[{"mask-linear-to":se()}],"mask-image-t-from-pos":[{"mask-t-from":we()}],"mask-image-t-to-pos":[{"mask-t-to":we()}],"mask-image-t-from-color":[{"mask-t-from":se()}],"mask-image-t-to-color":[{"mask-t-to":se()}],"mask-image-r-from-pos":[{"mask-r-from":we()}],"mask-image-r-to-pos":[{"mask-r-to":we()}],"mask-image-r-from-color":[{"mask-r-from":se()}],"mask-image-r-to-color":[{"mask-r-to":se()}],"mask-image-b-from-pos":[{"mask-b-from":we()}],"mask-image-b-to-pos":[{"mask-b-to":we()}],"mask-image-b-from-color":[{"mask-b-from":se()}],"mask-image-b-to-color":[{"mask-b-to":se()}],"mask-image-l-from-pos":[{"mask-l-from":we()}],"mask-image-l-to-pos":[{"mask-l-to":we()}],"mask-image-l-from-color":[{"mask-l-from":se()}],"mask-image-l-to-color":[{"mask-l-to":se()}],"mask-image-x-from-pos":[{"mask-x-from":we()}],"mask-image-x-to-pos":[{"mask-x-to":we()}],"mask-image-x-from-color":[{"mask-x-from":se()}],"mask-image-x-to-color":[{"mask-x-to":se()}],"mask-image-y-from-pos":[{"mask-y-from":we()}],"mask-image-y-to-pos":[{"mask-y-to":we()}],"mask-image-y-from-color":[{"mask-y-from":se()}],"mask-image-y-to-color":[{"mask-y-to":se()}],"mask-image-radial":[{"mask-radial":[Ee,_e]}],"mask-image-radial-from-pos":[{"mask-radial-from":we()}],"mask-image-radial-to-pos":[{"mask-radial-to":we()}],"mask-image-radial-from-color":[{"mask-radial-from":se()}],"mask-image-radial-to-color":[{"mask-radial-to":se()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":C()}],"mask-image-conic-pos":[{"mask-conic":[nt]}],"mask-image-conic-from-pos":[{"mask-conic-from":we()}],"mask-image-conic-to-pos":[{"mask-conic-to":we()}],"mask-image-conic-from-color":[{"mask-conic-from":se()}],"mask-image-conic-to-color":[{"mask-conic-to":se()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:pe()}],"mask-repeat":[{mask:E()}],"mask-size":[{mask:X()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ee,_e]}],filter:[{filter:["","none",Ee,_e]}],blur:[{blur:Ue()}],brightness:[{brightness:[nt,Ee,_e]}],contrast:[{contrast:[nt,Ee,_e]}],"drop-shadow":[{"drop-shadow":["","none",z,Gc,Pc]}],"drop-shadow-color":[{"drop-shadow":se()}],grayscale:[{grayscale:["",nt,Ee,_e]}],"hue-rotate":[{"hue-rotate":[nt,Ee,_e]}],invert:[{invert:["",nt,Ee,_e]}],saturate:[{saturate:[nt,Ee,_e]}],sepia:[{sepia:["",nt,Ee,_e]}],"backdrop-filter":[{"backdrop-filter":["","none",Ee,_e]}],"backdrop-blur":[{"backdrop-blur":Ue()}],"backdrop-brightness":[{"backdrop-brightness":[nt,Ee,_e]}],"backdrop-contrast":[{"backdrop-contrast":[nt,Ee,_e]}],"backdrop-grayscale":[{"backdrop-grayscale":["",nt,Ee,_e]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[nt,Ee,_e]}],"backdrop-invert":[{"backdrop-invert":["",nt,Ee,_e]}],"backdrop-opacity":[{"backdrop-opacity":[nt,Ee,_e]}],"backdrop-saturate":[{"backdrop-saturate":[nt,Ee,_e]}],"backdrop-sepia":[{"backdrop-sepia":["",nt,Ee,_e]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":B()}],"border-spacing-x":[{"border-spacing-x":B()}],"border-spacing-y":[{"border-spacing-y":B()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ee,_e]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[nt,"initial",Ee,_e]}],ease:[{ease:["linear","initial",D,Ee,_e]}],delay:[{delay:[nt,Ee,_e]}],animate:[{animate:["none",U,Ee,_e]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,Ee,_e]}],"perspective-origin":[{"perspective-origin":L()}],rotate:[{rotate:Ce()}],"rotate-x":[{"rotate-x":Ce()}],"rotate-y":[{"rotate-y":Ce()}],"rotate-z":[{"rotate-z":Ce()}],scale:[{scale:mt()}],"scale-x":[{"scale-x":mt()}],"scale-y":[{"scale-y":mt()}],"scale-z":[{"scale-z":mt()}],"scale-3d":["scale-3d"],skew:[{skew:Nt()}],"skew-x":[{"skew-x":Nt()}],"skew-y":[{"skew-y":Nt()}],transform:[{transform:[Ee,_e,"","none","gpu","cpu"]}],"transform-origin":[{origin:L()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:pt()}],"translate-x":[{"translate-x":pt()}],"translate-y":[{"translate-y":pt()}],"translate-z":[{"translate-z":pt()}],"translate-none":["translate-none"],accent:[{accent:se()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:se()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ee,_e]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":B()}],"scroll-mx":[{"scroll-mx":B()}],"scroll-my":[{"scroll-my":B()}],"scroll-ms":[{"scroll-ms":B()}],"scroll-me":[{"scroll-me":B()}],"scroll-mbs":[{"scroll-mbs":B()}],"scroll-mbe":[{"scroll-mbe":B()}],"scroll-mt":[{"scroll-mt":B()}],"scroll-mr":[{"scroll-mr":B()}],"scroll-mb":[{"scroll-mb":B()}],"scroll-ml":[{"scroll-ml":B()}],"scroll-p":[{"scroll-p":B()}],"scroll-px":[{"scroll-px":B()}],"scroll-py":[{"scroll-py":B()}],"scroll-ps":[{"scroll-ps":B()}],"scroll-pe":[{"scroll-pe":B()}],"scroll-pbs":[{"scroll-pbs":B()}],"scroll-pbe":[{"scroll-pbe":B()}],"scroll-pt":[{"scroll-pt":B()}],"scroll-pr":[{"scroll-pr":B()}],"scroll-pb":[{"scroll-pb":B()}],"scroll-pl":[{"scroll-pl":B()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ee,_e]}],fill:[{fill:["none",...se()]}],"stroke-w":[{stroke:[nt,Wl,Ti,ab]}],stroke:[{stroke:["none",...se()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},FR=CR(ZR);function Ns(...e){return FR(av(e))}const YR=aN("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400 focus-visible:ring-offset-2 focus-visible:ring-offset-black disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-zinc-50 text-black hover:bg-zinc-200",secondary:"border border-zinc-800 bg-zinc-950 text-zinc-100 hover:bg-zinc-900",ghost:"text-zinc-400 hover:bg-zinc-900 hover:text-zinc-50",outline:"border border-zinc-800 bg-transparent text-zinc-100 hover:bg-zinc-900",destructive:"bg-rose-600 text-white hover:bg-rose-700"},size:{default:"h-9 px-4",sm:"h-8 px-3 text-xs",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}}),ee=j.forwardRef(({className:e,variant:s,size:i,asChild:r=!1,...o},u)=>{const d=r?US:"button";return t.jsx(d,{ref:u,className:Ns(YR({variant:s,size:i,className:e})),...o})});ee.displayName="Button";const XR=aN("inline-flex items-center rounded-md border px-2 py-0.5 text-[11px] font-medium tracking-wide",{variants:{variant:{neutral:"border-zinc-800 bg-zinc-950 text-zinc-300",success:"border-emerald-500/25 bg-emerald-500/10 text-emerald-300",warning:"border-amber-500/25 bg-amber-500/10 text-amber-300",destructive:"border-rose-500/25 bg-rose-500/10 text-rose-300"}},defaultVariants:{variant:"neutral"}});function bN({className:e,variant:s,...i}){return t.jsx("div",{className:Ns(XR({variant:s}),e),...i})}const JR=220;function lb({compact:e=!1,version:s,updateAvailable:i,onDismissUpdate:r}){const o=!e&&s&&s!=="unknown",[u,d]=j.useState(!1),h=!e&&i&&r,p=()=>{d(!0),window.setTimeout(()=>{r?.(),d(!1)},JR)};return e?t.jsxs(ft,{to:"/",className:"brand-lockup brand-lockup-compact","aria-label":"Canonry home",children:[t.jsx("img",{className:"brand-icon",src:"./favicon.svg",alt:"","aria-hidden":"true"}),t.jsx("span",{className:"brand-copy",children:t.jsx("span",{className:"brand-mark",children:"Canonry"})})]}):t.jsxs("div",{className:"brand-lockup brand-lockup-wrapper",children:[t.jsx(ft,{to:"/",className:"brand-icon-link","aria-label":"Canonry home",tabIndex:-1,children:t.jsx("img",{className:"brand-icon",src:"./favicon.svg",alt:"","aria-hidden":"true"})}),t.jsxs("div",{className:"brand-copy",children:[t.jsx(ft,{to:"/",className:"brand-mark",children:"Canonry"}),h?t.jsxs("span",{className:`brand-update-bubble ${u?"brand-update-bubble-closing":""}`,role:"status","aria-live":"polite",children:[t.jsxs("a",{className:"brand-update-bubble-link",href:i.url,target:"_blank",rel:"noopener noreferrer",title:`Open release: ${i.upgradeCommand}`,"aria-label":`New version v${i.latest} available — open release page`,children:[t.jsxs("span",{className:"brand-update-bubble-from",children:["v",i.current]}),t.jsx(LC,{className:"brand-update-bubble-arrow size-3","aria-hidden":"true"}),t.jsxs("span",{className:"brand-update-bubble-to",children:["v",i.latest]})]}),t.jsx("button",{type:"button",className:"brand-update-bubble-dismiss",onClick:p,"aria-label":`Dismiss update notification for v${i.latest}`,children:t.jsx(qi,{className:"size-3","aria-hidden":"true"})})]}):o?t.jsxs("span",{className:"brand-version",children:["v",s]}):null]})]})}function $i({provider:e}){const s={gemini:"border-blue-800/50 bg-blue-950/40 text-blue-300",openai:"border-green-800/50 bg-green-950/40 text-green-300",claude:"border-amber-800/50 bg-amber-950/40 text-amber-300",perplexity:"border-teal-800/50 bg-teal-950/40 text-teal-300",local:"border-purple-800/50 bg-purple-950/40 text-purple-300"};return t.jsx("span",{className:`inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide ${s[e]??"border-zinc-700 bg-zinc-800 text-zinc-300"}`,children:e})}function Ke({tone:e,children:s,...i}){const r=e==="positive"?"success":e==="caution"?"warning":e==="negative"?"destructive":"neutral";return t.jsx(bN,{variant:r,...i,children:s})}function Uu({status:e}){return t.jsx(Ke,{tone:eN(e),children:$u(e)})}const vN=sv,WR=ev,jN=j.forwardRef(({className:e,...s},i)=>t.jsx(yf,{ref:i,className:Ns("fixed inset-0 z-50 bg-black/70 backdrop-blur-sm",e),...s}));jN.displayName=yf.displayName;const e6=400,t6=1200,n6=720,Zf=j.forwardRef(({className:e,children:s,...i},r)=>{const[o,u]=j.useState(n6),d=j.useRef(!1),h=j.useRef(0),p=j.useRef(0),x=j.useCallback(N=>{d.current=!0,h.current=N.clientX,p.current=o,N.target.setPointerCapture(N.pointerId),N.preventDefault()},[o]),b=j.useCallback(N=>{if(!d.current)return;const z=h.current-N.clientX,T=Math.min(t6,Math.max(e6,p.current+z));u(T)},[]),v=j.useCallback(()=>{d.current=!1},[]);return t.jsxs(WR,{children:[t.jsx(jN,{}),t.jsxs(bf,{ref:r,className:Ns("fixed z-50 flex flex-col bg-zinc-950 px-5 py-4 shadow-2xl overflow-hidden","max-md:inset-x-0 max-md:bottom-0 max-md:top-auto max-md:max-h-[88vh] max-md:rounded-t-2xl max-md:border-t","md:inset-y-0 md:right-0 md:h-full md:border-l","border-zinc-800",e),style:{width:`min(${o}px, 100vw)`},...i,children:[t.jsx("div",{className:"absolute inset-y-0 left-0 w-1.5 cursor-col-resize hover:bg-zinc-700/50 active:bg-zinc-600/50 transition-colors max-md:hidden",onPointerDown:x,onPointerMove:b,onPointerUp:v}),s,t.jsxs(tv,{className:"absolute right-4 top-4 inline-flex size-8 items-center justify-center rounded-md text-zinc-500 transition hover:bg-zinc-900 hover:text-zinc-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400",children:[t.jsx(qi,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Zf.displayName=bf.displayName;const Ff=({className:e,...s})=>t.jsx("div",{className:Ns("flex flex-col gap-1.5 pr-10",e),...s}),Pu=j.forwardRef(({className:e,...s},i)=>t.jsx(vf,{ref:i,className:Ns("text-lg font-medium text-zinc-50",e),...s}));Pu.displayName=vf.displayName;const Gu=j.forwardRef(({className:e,...s},i)=>t.jsx(nv,{ref:i,className:Ns("text-sm text-zinc-500",e),...s}));Gu.displayName=nv.displayName;function s6({title:e,subtitle:s,children:i,open:r,onClose:o}){return t.jsx(vN,{open:r,onOpenChange:u=>u?void 0:o(),children:t.jsxs(Zf,{children:[t.jsxs(Ff,{className:"drawer-head",children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:s}),t.jsx(Pu,{id:"drawer-title",children:e}),t.jsx(Gu,{className:"sr-only",children:s})]}),t.jsx("div",{className:"drawer-body",children:i})]})})}function on({text:e}){const[s,i]=j.useState(null),r=j.useRef(null),o=j.useCallback(()=>{if(!r.current)return;const d=r.current.getBoundingClientRect();i({top:d.top,left:d.left+d.width/2})},[]),u=j.useCallback(()=>i(null),[]);return t.jsxs("span",{className:"info-tooltip-wrapper",onMouseEnter:o,onMouseLeave:u,onFocus:o,onBlur:u,children:[t.jsxs("svg",{ref:r,className:"info-tooltip-icon",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[t.jsx("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("path",{d:"M8 7v4M8 5.5v0",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),s!==null&&RS.createPortal(t.jsx("span",{role:"tooltip",style:{position:"fixed",top:s.top,left:s.left,transform:"translateX(-50%) translateY(calc(-100% - 8px))",zIndex:9999,pointerEvents:"none",width:"14rem",padding:"0.5rem 0.75rem",fontSize:"11px",fontWeight:400,textTransform:"none",letterSpacing:"normal",lineHeight:"1rem",color:"#d4d4d8",backgroundColor:"#18181b",border:"1px solid rgba(63, 63, 70, 0.6)",borderRadius:"0.5rem",boxShadow:"0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1)"},children:e}),document.body)]})}const a6=/[\s\-_]+/;function i6(e){const s=e.split(a6).filter(Boolean);return s.length===0?null:s.map(i=>i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\s\\-_]*")}function nf(e,s){const i=r6(s),r=e.split(/(\*\*[^*]+\*\*)/).filter(Boolean).map(x=>x.startsWith("**")&&x.endsWith("**")?{type:"bold",value:x.slice(2,-2)}:{type:"text",value:x}),o=i.flatMap(x=>x.terms).filter(x=>x.trim().length>1);if(o.length===0)return r.map((x,b)=>x.type==="bold"?kr.createElement("strong",{key:`b-${b}`,className:"text-zinc-200 font-semibold"},x.value):x.value).filter(Boolean);const d=[...o].sort((x,b)=>b.length-x.length).map(i6).filter(x=>!!x);if(d.length===0)return r.map((x,b)=>x.type==="bold"?kr.createElement("strong",{key:`b-${b}`,className:"text-zinc-200 font-semibold"},x.value):x.value).filter(Boolean);const h=new RegExp(`(${d.join("|")})`,"gi"),p=new Map;for(const x of i)for(const b of x.terms){const v=wu(b);v&&!p.has(v)&&p.set(v,x.className)}return r.flatMap((x,b)=>x.value.split(h).map((N,z)=>{if(!N)return null;if(z%2===1){const w=p.get(wu(N))??"answer-highlight";return x.type==="bold"?kr.createElement("mark",{key:`hl-${b}-${z}`,className:w},kr.createElement("strong",{className:"text-zinc-200 font-semibold"},N)):kr.createElement("mark",{key:`hl-${b}-${z}`,className:w},N)}return x.type==="bold"?kr.createElement("strong",{key:`b-${b}-${z}`,className:"text-zinc-200 font-semibold"},N):N})).filter(Boolean)}function r6(e){return e.length===0?[]:typeof e[0]=="string"?[{terms:e,className:"answer-highlight"}]:e}function Sh(e,s){switch(e){case"new":return"First observation";case"emerging":return"First mention";case"lost":return"Lost since last run";default:return s==="mentioned"||s==="visible"?"Mentioned in latest run":s==="pending"?"Awaiting first run":"Not mentioned in latest run"}}function l6({evidence:e,project:s,onClose:i}){const[r,o]=j.useState(!1),[u,d]=j.useState("mentions"),[h,p]=j.useState(-1),[x,b]=j.useState(null),[v,N]=j.useState(!1),[z,T]=j.useState({}),w=k_(s.project),A=new Set(w.map(vu)),D=e.runHistory,U=D.length>1,[I,C]=j.useState(null),L=j.useRef(!1);j.useEffect(()=>{if(L.current||e.answerSnippet&&(e.visibilityState!=null||e.answerMentioned!=null))return;const Y=D.at(-1);Y&&(L.current=!0,Kr(Y.runId).then(ye=>{const le=ye.snapshots?.find(Re=>Re.query===e.query&&Re.provider===e.provider);le&&C({citationState:le.citationState,answerMentioned:le.answerMentioned,visibilityState:le.visibilityState,visibilityTransition:Y.visibilityTransition,provider:le.provider,model:le.model??e.model,answerSnippet:le.answerText??e.answerSnippet,citedDomains:le.citedDomains??e.citedDomains,competitorDomains:le.competitorOverlap??e.competitorDomains,recommendedCompetitors:le.recommendedCompetitors??e.recommendedCompetitors??[],matchedTerms:le.matchedTerms??e.matchedTerms??[],groundingSources:le.groundingSources??e.groundingSources,evidenceUrls:[],changeLabel:e.visibilityChangeLabel??e.changeLabel,summary:e.summary})}).catch(()=>{}))},[e,D]);const M=h>=0&&x!==null,_=M?x:I||{citationState:e.citationState,answerMentioned:e.answerMentioned,visibilityState:e.visibilityState,visibilityTransition:D.at(-1)?.visibilityTransition,provider:e.provider,model:e.model,answerSnippet:e.answerSnippet,citedDomains:e.citedDomains,competitorDomains:e.competitorDomains,recommendedCompetitors:e.recommendedCompetitors??[],matchedTerms:e.matchedTerms??[],groundingSources:e.groundingSources,evidenceUrls:e.evidenceUrls,changeLabel:e.visibilityChangeLabel??e.changeLabel,summary:e.summary},B=_.visibilityState==="pending"||_.citationState==="pending",J=B?!1:_.visibilityState!=null?_.visibilityState==="visible":_.answerMentioned!=null?_.answerMentioned:_.citationState===po.cited||_.citationState==="emerging",ue=_.answerMentioned!=null||_.visibilityState!=null||_.recommendedCompetitors.length>0,P=_.citedDomains.length>0||_.groundingSources.length>0||_.evidenceUrls.length>0,ie=s.project.displayName||s.project.name,te=[...w.map(vu),ie,ie.split(" ").slice(0,2).join(" "),..._.matchedTerms].filter(Y=>Y.trim().length>2),ze=[..._.competitorDomains.flatMap(Y=>{const ye=xj(Y);return ye.length>=4?[ye]:[]}),..._.recommendedCompetitors].filter(Y=>Y.trim().length>2),ve=[{terms:te,className:"answer-highlight-brand"},...ze.length>0?[{terms:ze,className:"answer-highlight-competitor"}]:[]],V=B?"pending":_.visibilityTransition==="lost"?"lost":J?"mentioned":"not-mentioned",ne=j.useRef(0),me=j.useCallback(async Y=>{const ye=++ne.current;if(Y===-1||Y===D.length-1){p(-1),b(null),o(!1);return}p(Y),o(!1);const le=D[Y],Re=`${le.runId}::${e.query}::${e.provider}`;if(z[Re]){b(z[Re]);return}N(!0);try{const tt=await Kr(le.runId);if(ye!==ne.current)return;const we=tt.snapshots?.find(Ce=>Ce.query===e.query&&Ce.provider===e.provider)??tt.snapshots?.find(Ce=>Ce.query===e.query),Ue=we?{citationState:we.citationState,answerMentioned:we.answerMentioned,visibilityState:we.visibilityState,visibilityTransition:le.visibilityTransition,provider:we.provider,model:we.model??null,answerSnippet:we.answerText??"",citedDomains:we.citedDomains,competitorDomains:we.competitorOverlap,recommendedCompetitors:we.recommendedCompetitors??[],matchedTerms:we.matchedTerms??[],groundingSources:we.groundingSources,evidenceUrls:[],changeLabel:Sh(le.mentionTransition??le.visibilityTransition,le.mentionState??le.visibilityState),summary:""}:{citationState:le.citationState,answerMentioned:le.answerMentioned,visibilityState:le.visibilityState,visibilityTransition:le.visibilityTransition,provider:e.provider,model:le.model??null,answerSnippet:"",citedDomains:[],competitorDomains:[],recommendedCompetitors:[],matchedTerms:[],groundingSources:[],evidenceUrls:[],changeLabel:Sh(le.mentionTransition??le.visibilityTransition,le.mentionState??le.visibilityState),summary:"Snapshot data not available for this run."};T(Ce=>({...Ce,[Re]:Ue})),b(Ue)}catch{if(ye!==ne.current)return;b({citationState:le.citationState,answerMentioned:le.answerMentioned,visibilityState:le.visibilityState,visibilityTransition:le.visibilityTransition,provider:e.provider,model:le.model??null,answerSnippet:"",citedDomains:[],competitorDomains:[],recommendedCompetitors:[],matchedTerms:[],groundingSources:[],evidenceUrls:[],changeLabel:Sh(le.mentionTransition??le.visibilityTransition,le.mentionState??le.visibilityState),summary:"Failed to load historical run data."})}finally{ye===ne.current&&N(!1)}},[D,e.query,e.provider,z]),se=(M||e.historyScope!=="provider")&&_.model?`${_.provider} (${_.model}) · ${_.changeLabel.toLowerCase()}`:`${_.provider} · ${_.changeLabel.toLowerCase()}`,pe=!M&&e.historyScope==="provider"?[e.model?`Current model: ${e.model}`:null,e.modelsSeen&&e.modelsSeen.length>1?`History spans ${e.modelsSeen.length} models`:null].filter(Boolean).join(" · "):"",E=J?{label:"Mentioned in answer",title:"Your brand or domain is mentioned in this answer",meta:se}:_.visibilityTransition==="lost"?{label:"Mention lost",title:"Your brand no longer appears in this answer",meta:se}:B?{label:"Pending",title:"Awaiting first run",meta:"No provider data yet"}:{label:"Not mentioned in answer",title:"Your brand or domain was not mentioned in this answer",meta:se},X=()=>{if(!_.answerSnippet)return null;const Y=_.answerSnippet.split(`
57
- `),ye=[];let le=[],Re=0;const tt=()=>{if(le.length===0)return;const we=le.join(" ").trim();we&&ye.push(t.jsx("p",{className:ye.length>0?"mt-2.5":"",children:nf(we,ve)},Re++)),le=[]};for(const we of Y){const Ue=we.trim();if(/^[-\u2013\u2014]{3,}$/.test(Ue)){tt(),ye.push(t.jsx("hr",{className:"border-zinc-800/60 my-3"},Re++));continue}const Ce=Ue.match(/^(#{1,3})\s+(\S.*)$/);if(Ce){tt();const mt=Ce[1].length,Nt=Ce[2].replace(/^[\p{Emoji}\p{Emoji_Component}\s]+/u,"").trim()||Ce[2],pt=mt===1?"text-[13px] font-semibold text-zinc-100 mt-4 mb-1":mt===2?"text-xs font-semibold text-zinc-200 mt-3 mb-0.5":"text-xs font-medium text-zinc-300 mt-2";ye.push(t.jsx("p",{className:pt,children:nf(Nt,ve)},Re++));continue}if(Ue===""){tt();continue}le.push(Ue)}return tt(),ye};return t.jsx(sv,{open:!0,onOpenChange:Y=>{Y||i()},children:t.jsxs(ev,{children:[t.jsx(yf,{className:"fixed inset-0 z-50 bg-black/80 backdrop-blur-sm"}),t.jsxs(bf,{className:"evidence-modal","aria-describedby":void 0,children:[t.jsxs("div",{className:"evidence-modal-header",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"eyebrow eyebrow-soft",children:[s.project.name," ","·"," ",_.provider||"All providers"]}),t.jsx(vf,{className:"text-lg font-semibold text-zinc-50 truncate",children:e.query})]}),t.jsxs(tv,{className:"inline-flex size-8 items-center justify-center rounded-md text-zinc-500 transition hover:bg-zinc-800 hover:text-zinc-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400 shrink-0",children:[t.jsx(qi,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]}),U&&t.jsxs("div",{className:"evidence-modal-timeline",children:[t.jsx("p",{className:"drawer-section-label mb-1.5",children:"Run history"}),t.jsx("div",{className:"flex items-center gap-1 overflow-x-auto pb-1",children:D.map((Y,ye)=>{const le=h===-1&&ye===D.length-1||h===ye,Re=Y.visibilityState??(Y.answerMentioned?"visible":"not-visible"),tt=Y.visibilityTransition??Re,we=Re==="visible"?"bg-emerald-400":tt==="emerging"?"bg-amber-400":tt==="lost"?"bg-rose-400":"bg-zinc-600",Ce=new Date(Y.createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric"}),mt=!!(Y.model&&ye>0&&D[ye-1]?.model&&D[ye-1].model!==Y.model);return t.jsxs("button",{type:"button",className:`evidence-run-dot ${le?"evidence-run-dot--selected":""}`,onClick:()=>{me(ye===D.length-1?-1:ye)},"aria-label":[`Run ${Ce}: ${Re}`,Y.model?`model ${Y.model}`:null,mt?"model changed":null].filter(Boolean).join(" — "),"aria-pressed":le,children:[t.jsx("span",{className:`size-2 rounded-full ${we} ${mt?"ring-1 ring-amber-300/80 ring-offset-2 ring-offset-zinc-950":""}`,"aria-hidden":"true"}),t.jsx("span",{className:"text-[10px] text-zinc-500",children:Ce})]},ye)})}),h>=0&&h<D.length&&t.jsxs("p",{className:"text-[11px] text-zinc-500 mt-1",children:["Viewing run from ",new Date(D[h].createdAt).toLocaleString()," ","—"," ",t.jsx("span",{className:"capitalize",children:D[h].visibilityState??(D[h].answerMentioned?"visible":"not-visible")}),t.jsxs("button",{type:"button",className:"text-zinc-400 hover:text-zinc-200 ml-2",onClick:()=>{me(-1)},children:["←"," Back to latest"]})]}),!M&&(e.modelTransitions?.length??0)>0&&t.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:e.modelTransitions.map(Y=>t.jsx("span",{className:"inline-flex items-center rounded-full border border-amber-400/30 bg-amber-400/10 px-2 py-1 text-[10px] text-amber-100",children:`${Y.fromModel??"unknown"} -> ${Y.toModel??"unknown"} on ${new Date(Y.createdAt).toLocaleDateString()}`},`${Y.runId}:${Y.toModel??"unknown"}`))})]}),t.jsxs("div",{className:"evidence-modal-body",children:[v&&t.jsxs("div",{className:"md:col-span-2 flex items-center justify-center py-12 text-zinc-500 text-sm",children:["Loading historical run data","…"]}),!v&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"evidence-modal-main",children:[t.jsxs("div",{className:`evidence-position-hero evidence-position-hero--${V}`,children:[t.jsx("p",{className:`evidence-position-label evidence-position-label--${V}`,children:E.label}),t.jsx("p",{className:`evidence-position-title evidence-position-title--${V}`,children:E.title}),t.jsx("p",{className:"evidence-position-meta",children:E.meta}),pe&&t.jsx("p",{className:"mt-1 text-[11px] text-zinc-500",children:pe})]}),_.answerSnippet&&t.jsxs("div",{children:[t.jsx("p",{className:"drawer-section-label",children:"What the AI said"}),t.jsx("div",{className:`answer-snippet-block ${r?"evidence-answer-expanded":"evidence-answer-collapsed"}`,children:X()}),_.answerSnippet.length>280&&t.jsx("button",{type:"button",className:"mt-1.5 text-xs text-zinc-500 hover:text-zinc-300 transition-colors",onClick:()=>o(!r),children:r?"↑ Collapse":"↓ Show full answer"})]}),!_.answerSnippet&&!v&&t.jsx("div",{className:"rounded-lg border border-zinc-800/40 bg-zinc-900/20 px-4 py-8 text-center text-zinc-600 text-sm",children:"No answer text recorded for this run"}),!M&&e.relatedTechnicalSignals.length>0&&t.jsxs("div",{children:[t.jsx("p",{className:"drawer-section-label",children:J?"Why you're visible":"What to fix"}),t.jsx("div",{className:"action-items-list",children:e.relatedTechnicalSignals.map((Y,ye)=>t.jsxs("div",{className:"action-item",children:[t.jsx("svg",{className:`action-item-icon ${J?"text-emerald-400":"text-amber-400"}`,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:J?t.jsx("path",{d:"M3 8l3.5 3.5L13 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}):t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"8",cy:"8",r:"7",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("path",{d:"M8 5v3.5M8 10.5v0",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}),t.jsx("span",{className:"action-item-text",children:Y})]},ye))})]}),_.summary&&t.jsx("p",{className:"text-xs text-zinc-600 border-t border-zinc-800/40 pt-3 mt-1",children:_.summary})]}),t.jsxs("div",{className:"evidence-modal-sidebar",children:[(ue||P)&&t.jsxs("div",{className:"sidebar-tabs",children:[t.jsx("button",{className:`sidebar-tab ${u==="mentions"?"sidebar-tab--active":""}`,onClick:()=>d("mentions"),type:"button",title:"Canonry's answer-level visibility assessment and any company names extracted from the answer text.",children:"Mentions"}),t.jsx("button",{className:`sidebar-tab ${u==="sources"?"sidebar-tab--active":""}`,onClick:()=>d("sources"),type:"button",title:"Grounding links the model used to build the answer. These are supporting sources, not the primary visibility signal.",children:"Sources"})]}),u==="mentions"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsxs("div",{className:"drawer-section-label flex items-center",children:[t.jsx("span",{children:"Mention in answer"}),t.jsx(on,{text:"Canonry scans the AI answer for your owned domains and project name. This is independent from grounding or citation sources."})]}),t.jsxs("div",{className:`mention-status mention-status--${J?"mentioned":"not-mentioned"}`,children:[t.jsx("span",{className:"mention-status-icon",children:B?"…":J?"✓":"—"}),t.jsx("span",{className:"mention-status-label",children:B?"Pending":J?"Mentioned":"Not mentioned"})]}),_.matchedTerms.length>0&&t.jsxs("div",{className:"mt-2",children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500 mb-1.5",children:"Matched in answer"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:_.matchedTerms.map(Y=>t.jsx("span",{className:"mention-chip mention-chip--brand",children:Y},Y))})]}),!B&&!J&&_.matchedTerms.length===0&&t.jsxs("div",{className:"mt-2",children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500 mb-1.5",children:"Searched for"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:te.map(Y=>t.jsx("span",{className:"mention-chip mention-chip--muted",children:Y},Y))}),t.jsx("p",{className:"text-[11px] text-zinc-600 mt-1.5",children:"None of these appear in the answer text."})]})]}),(_.recommendedCompetitors.length>0||_.competitorDomains.length>0)&&t.jsxs("div",{children:[t.jsxs("div",{className:"drawer-section-label flex items-center",children:[t.jsx("span",{children:"Competitors in answer"}),t.jsx(on,{text:"Competitors detected in the answer text or cited source links. Includes both tracked competitors and names extracted by Canonry."})]}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:(()=>{const Y=_.competitorDomains.map(Re=>Re.replace(/^www\./,"")),ye=new Set(Y.map(Re=>wu(Re.replace(/\.[^.]+$/,""))));return[..._.recommendedCompetitors.filter(Re=>!ye.has(wu(Re))),...Y].map(Re=>t.jsx("span",{className:"mention-chip mention-chip--competitor",children:Re},Re))})()})]})]}),u==="sources"&&t.jsxs(t.Fragment,{children:[_.citedDomains.length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"drawer-section-label flex items-center",children:[t.jsx("span",{children:"Domains from source links"}),t.jsx(on,{text:"These domains were extracted from grounding or citation URLs. They are supporting-source metadata, not proof that the answer text mentioned them."})]}),t.jsx("div",{className:"citation-leaderboard",children:_.citedDomains.map((Y,ye)=>{const le=Y.toLowerCase().replace(/^www\./,""),Re=A.has(le),tt=!Re&&_.competitorDomains.some(Ue=>Ue.toLowerCase().replace(/^www\./,"")===le),we=Re?"you":tt?"competitor":"other";return t.jsxs("div",{className:`citation-leaderboard-item citation-leaderboard-item--${we}`,children:[t.jsxs("span",{className:"citation-leaderboard-rank",children:["#",ye+1]}),t.jsx("span",{className:"citation-leaderboard-domain",children:Y}),Re&&t.jsx("span",{className:"citation-leaderboard-tag",children:"You"}),tt&&t.jsx("span",{className:"citation-leaderboard-tag",children:"Competitor"})]},Y)})})]}),_.groundingSources.length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"drawer-section-label flex items-center",children:[t.jsxs("span",{children:["Grounding source links (",_.groundingSources.length,")"]}),t.jsx(on,{text:"Links the model used as grounding or supporting context while producing the answer. These are not the same thing as answer visibility."})]}),t.jsx("ul",{className:"grid gap-0.5",children:_.groundingSources.map((Y,ye)=>t.jsx("li",{className:"truncate text-sm",children:t.jsx("a",{href:Y.uri,target:"_blank",rel:"noopener noreferrer",className:"text-zinc-400 hover:text-zinc-200 transition-colors",children:Y.title||Y.uri})},ye))})]}),_.evidenceUrls.length>0&&t.jsxs("div",{children:[t.jsx("p",{className:"drawer-section-label",children:"Evidence URLs"}),t.jsx("ul",{className:"grid gap-1",children:_.evidenceUrls.map(Y=>t.jsx("li",{className:"truncate text-sm",children:t.jsx("a",{href:Y,target:"_blank",rel:"noopener noreferrer",className:"text-zinc-400 hover:text-zinc-200 transition-colors",children:Y})},Y))})]}),_.citedDomains.length===0&&_.groundingSources.length===0&&_.evidenceUrls.length===0&&t.jsxs("div",{className:"flex items-center justify-center h-24 text-zinc-600 text-sm",children:["No source data ",M?"for this run":"yet"]})]}),!ue&&!P&&t.jsxs("div",{className:"flex items-center justify-center h-24 text-zinc-600 text-sm",children:["No answer visibility data ",M?"for this run":"yet"]})]})]})]})]})]})})}function Ms(e){const s=new Date("2026-02-20");return e.map((i,r)=>({runId:`run_mock_${r+1}`,citationState:i,createdAt:new Date(s.getTime()+r*2*24*60*60*1e3).toISOString()}))}const zh=[{id:"project_citypoint",name:"Citypoint Dental NYC",canonicalDomain:"citypointdental.com",ownedDomains:[],aliases:[],country:"US",language:"en",tags:["local intent","priority"],labels:{},providers:[],locations:[],defaultLocation:null,autoExtractBacklinks:!1,configSource:"cli",configRevision:1},{id:"project_harbor",name:"Harbor Legal Group",canonicalDomain:"harborlegal.com",ownedDomains:[],aliases:[],country:"US",language:"en",tags:["lead gen"],labels:{},providers:[],locations:[],defaultLocation:null,autoExtractBacklinks:!1,configSource:"cli",configRevision:1},{id:"project_northstar",name:"Northstar Orthopedics",canonicalDomain:"northstarortho.com",ownedDomains:[],aliases:[],country:"US",language:"en",tags:["multi-location"],labels:{},providers:[],locations:[],defaultLocation:null,autoExtractBacklinks:!1,configSource:"cli",configRevision:1}];function Vu(e){return{id:e.id,projectId:e.projectId,projectName:e.projectName,kind:e.kind,kindLabel:e.kindLabel,status:e.status,trigger:e.trigger??"manual",createdAt:e.createdAt,startedAt:e.startedAt,duration:e.duration,statusDetail:e.statusDetail,summary:e.summary,triggerLabel:e.triggerLabel}}const o6=Vu({id:"run_citypoint_visibility_20260308",projectId:"project_citypoint",projectName:"Citypoint Dental NYC",kind:"answer-visibility",kindLabel:"Answer visibility sweep",status:"completed",createdAt:"2026-03-08T12:15:00.000Z",startedAt:"Mar 8, 12:15 PM",duration:"6m 12s",statusDetail:"18 tracked queries checked; 3 citation losses detected on emergency-intent prompts.",summary:"Citation losses on emergency-intent prompts",triggerLabel:"Scheduled"}),c6=Vu({id:"run_citypoint_queued_20260309",projectId:"project_citypoint",projectName:"Citypoint Dental NYC",kind:"answer-visibility",kindLabel:"Answer visibility sweep",status:"queued",createdAt:"2026-03-09T08:05:00.000Z",startedAt:"Mar 9, 8:05 AM",duration:"Waiting for slot",statusDetail:"Ready to enqueue after the next provider rate window clears.",summary:"Queued follow-up after local ranking movement",triggerLabel:"Manual"}),u6=Vu({id:"run_harbor_visibility_20260308",projectId:"project_harbor",projectName:"Harbor Legal Group",kind:"answer-visibility",kindLabel:"Answer visibility sweep",status:"completed",createdAt:"2026-03-08T11:05:00.000Z",startedAt:"Mar 8, 11:05 AM",duration:"5m 07s",statusDetail:"12 tracked queries checked; local-intent visibility held steady across branded prompts.",summary:"Branded prompts remain stable",triggerLabel:"Scheduled"}),d6=Vu({id:"run_northstar_visibility_20260308",projectId:"project_northstar",projectName:"Northstar Orthopedics",kind:"answer-visibility",kindLabel:"Answer visibility sweep",status:"running",createdAt:"2026-03-08T13:40:00.000Z",startedAt:"Mar 8, 1:40 PM",duration:"3m 10s",statusDetail:"Provider responses still in flight for 9 multi-location prompts.",summary:"Mid-run on treatment-location prompts",triggerLabel:"Manual"}),m6=[{id:"evidence_citypoint_emergency_gemini",query:"emergency dentist brooklyn",provider:"gemini",model:"gemini-3-flash",location:null,citationState:"lost",changeLabel:"Lost since Mar 5",answerSnippet:"For urgent dental care in Brooklyn, Downtown Smiles and Harbor Dental are now cited first for emergency availability and same-day booking.",citedDomains:["downtownsmiles.com","harbordental.com"],evidenceUrls:["https://downtownsmiles.com/emergency-dentist-brooklyn","https://harbordental.com/same-day-emergency-care"],competitorDomains:["downtownsmiles.com","harbordental.com"],groundingSources:[],relatedTechnicalSignals:["FAQ schema missing on the emergency service page","llms.txt not found during latest site audit","Location pages link weakly into the emergency care hub"],summary:"AI answers now cite two competitors while your emergency page is no longer grounded.",runHistory:Ms(["cited","cited","cited","cited","cited","cited","cited","not-cited","not-cited"])},{id:"evidence_citypoint_emergency_openai",query:"emergency dentist brooklyn",provider:"openai",model:"gpt-5.4",location:null,citationState:"cited",changeLabel:"Cited for 6 runs",answerSnippet:"Citypoint Dental is listed as a top emergency dentist in Brooklyn for same-day appointments and walk-in availability.",citedDomains:["citypointdental.com","downtownsmiles.com"],evidenceUrls:["https://citypointdental.com/emergency-dentist-brooklyn"],competitorDomains:["downtownsmiles.com"],groundingSources:[],relatedTechnicalSignals:["Emergency page indexed with structured data"],summary:"OpenAI cites your emergency page consistently alongside one competitor.",runHistory:Ms(["not-cited","cited","cited","cited","cited","cited","cited"])},{id:"evidence_citypoint_emergency_claude",query:"emergency dentist brooklyn",provider:"claude",model:"claude-sonnet-4-6",location:null,citationState:"not-cited",changeLabel:"No citation across 12 runs",answerSnippet:"Based on the search results, top-rated emergency dental practices in Brooklyn include Downtown Smiles and Harbor Dental.",citedDomains:["downtownsmiles.com","harbordental.com"],evidenceUrls:[],competitorDomains:["downtownsmiles.com","harbordental.com"],groundingSources:[],relatedTechnicalSignals:["FAQ schema missing","llms.txt not found"],summary:"Claude does not cite your domain for this emergency query.",runHistory:Ms(["not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited"])},{id:"evidence_citypoint_invisalign_openai",query:"best invisalign dentist downtown brooklyn",provider:"openai",model:"gpt-5.4",location:null,citationState:"emerging",changeLabel:"First citation in 7 days",answerSnippet:"Citypoint Dental appears as an emerging recommendation for Invisalign in Downtown Brooklyn, supported by recent before-and-after case pages.",citedDomains:["citypointdental.com","clearlineortho.com"],evidenceUrls:["https://citypointdental.com/invisalign-downtown-brooklyn","https://citypointdental.com/case-studies/invisalign-open-bite"],competitorDomains:["clearlineortho.com"],groundingSources:[],relatedTechnicalSignals:["Structured data now present on two case-study pages","Internal links from service pages to case studies improved crawl depth"],summary:"Fresh case-study content is starting to earn citations on Invisalign prompts.",runHistory:Ms(["not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","cited"])},{id:"evidence_citypoint_invisalign_gemini",query:"best invisalign dentist downtown brooklyn",provider:"gemini",model:"gemini-3-flash",location:null,citationState:"cited",changeLabel:"Cited for 8 runs",answerSnippet:"Citypoint Dental in Downtown Brooklyn is highlighted for its Invisalign expertise and patient outcomes.",citedDomains:["citypointdental.com"],evidenceUrls:["https://citypointdental.com/invisalign-downtown-brooklyn"],competitorDomains:[],groundingSources:[],relatedTechnicalSignals:["Case study pages well-indexed"],summary:"Gemini consistently cites your Invisalign page with no competitor overlap.",runHistory:Ms(["cited","cited","cited","cited","cited","cited","cited","cited"])},{id:"evidence_citypoint_invisalign_claude",query:"best invisalign dentist downtown brooklyn",provider:"claude",model:"claude-sonnet-4-6",location:null,citationState:"not-cited",changeLabel:"No citation across 12 runs",answerSnippet:"For Invisalign in Downtown Brooklyn, Clear Line Ortho and Brooklyn Smiles are frequently recommended for their experienced orthodontists.",citedDomains:["clearlineortho.com","brooklynsmiles.com"],evidenceUrls:[],competitorDomains:["clearlineortho.com"],groundingSources:[],relatedTechnicalSignals:["No before/after schema on case study pages"],summary:"Claude does not surface your Invisalign content despite strong page quality.",runHistory:Ms(["not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited"])},{id:"evidence_citypoint_children_claude",query:"pediatric dentist brooklyn heights",provider:"claude",model:"claude-sonnet-4-6",location:null,citationState:"not-cited",changeLabel:"No citation across 4 runs",answerSnippet:"Answers cite neighborhood-specific pediatric practices with stronger family-focused FAQ content and clearer insurance details.",citedDomains:["brightkidsdental.com","parkpediatricdental.com"],evidenceUrls:["https://brightkidsdental.com/pediatric-dentist-brooklyn-heights","https://parkpediatricdental.com/insurance"],competitorDomains:["brightkidsdental.com","parkpediatricdental.com"],groundingSources:[],relatedTechnicalSignals:["No dedicated pediatric service page exists for Brooklyn Heights","Insurance content is buried three clicks deep"],summary:"Coverage gap is content-driven, not purely technical.",runHistory:Ms(["not-cited","not-cited","not-cited","not-cited"])},{id:"evidence_citypoint_children_gemini",query:"pediatric dentist brooklyn heights",provider:"gemini",model:"gemini-3-flash",location:null,citationState:"not-cited",changeLabel:"No citation across 12 runs",answerSnippet:"For pediatric dentistry in Brooklyn Heights, Bright Kids Dental and Park Pediatric Dental are cited for family-friendly care.",citedDomains:["brightkidsdental.com","parkpediatricdental.com"],evidenceUrls:[],competitorDomains:["brightkidsdental.com","parkpediatricdental.com"],groundingSources:[],relatedTechnicalSignals:["No dedicated pediatric page for Brooklyn Heights"],summary:"Gemini does not surface your domain for pediatric queries in this area.",runHistory:Ms(["not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited","not-cited"])},{id:"evidence_citypoint_children_openai",query:"pediatric dentist brooklyn heights",provider:"openai",model:"gpt-5.4",location:null,citationState:"cited",changeLabel:"First citation this month",answerSnippet:"Citypoint Dental is mentioned as offering pediatric services in Brooklyn, though specialized pediatric-only practices are also highlighted.",citedDomains:["citypointdental.com","brightkidsdental.com"],evidenceUrls:["https://citypointdental.com/family-dentistry"],competitorDomains:["brightkidsdental.com"],groundingSources:[],relatedTechnicalSignals:["Family dentistry page recently updated"],summary:"OpenAI recently started citing your family dentistry page for this query.",runHistory:Ms(["not-cited","not-cited","not-cited","not-cited","not-cited","cited"])}];zh[0],zh[1],Ms(["cited","cited","cited","cited","cited"]),zh[2],2/7,3/7,Ms(["not-cited","not-cited","not-cited","cited"]);function h6(e,s){return e.projects.find(i=>i.project.id===s)}function f6(e,s){return e.runs.find(i=>i.id===s)}function p6(e,s){for(const i of e.projects){const r=i.visibilityEvidence.find(o=>o.id===s);if(r)return{project:i,evidence:r}}}const g6={regression:"negative",gain:"positive",opportunity:"caution","first-citation":"positive","provider-pickup":"positive","persistent-gap":"caution","competitor-gained":"negative","competitor-lost":"neutral"},x6={opportunity:"write","persistent-gap":"write","competitor-gained":"write","competitor-lost":"write",regression:"investigate",gain:"monitor","first-citation":"monitor","provider-pickup":"monitor"},y6={regression:"lost",gain:"emerging",opportunity:"not-cited","first-citation":"emerging","provider-pickup":"emerging","persistent-gap":"not-cited","competitor-gained":"cited","competitor-lost":"not-cited"},b6={regression:"Regression",gain:"Gain",opportunity:"Opportunity","first-citation":"First citation","provider-pickup":"Pickup","persistent-gap":"Gap","competitor-gained":"Competitor","competitor-lost":"Competitor"};function v6(e){return{id:e.id,tone:g6[e.type],title:e.title,detail:e.cause?.details??e.cause?.cause??"",actionLabel:e.recommendation?.action??b6[e.type],actionGroup:x6[e.type],affectedPhrases:[{query:e.query,evidenceId:"",provider:e.provider,citationState:y6[e.type]}]}}function j6(e){return e.filter(s=>!s.dismissed).map(v6)}function NN(e){return{id:e.id,name:e.name,displayName:e.displayName,canonicalDomain:e.canonicalDomain,ownedDomains:e.ownedDomains??[],aliases:e.aliases??[],country:e.country,language:e.language,tags:e.tags,labels:e.labels,providers:e.providers??[],locations:e.locations??[],defaultLocation:e.defaultLocation??null,autoExtractBacklinks:e.autoExtractBacklinks??!1,configSource:e.configSource,configRevision:e.configRevision,createdAt:e.createdAt,updatedAt:e.updatedAt}}function ob(e){try{return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}catch{return e}}function N6(e,s){if(!e)return"Waiting";if(!s)return"Running";const i=new Date(s).getTime()-new Date(e).getTime();if(i<1e3)return"<1s";const r=Math.floor(i/1e3);if(r<60)return`${r}s`;const o=Math.floor(r/60),u=r%60;return`${o}m ${u}s`}function wN(e){switch(e){case et["answer-visibility"]:return"Answer visibility sweep";case et["gsc-sync"]:return"GSC sync";case et["inspect-sitemap"]:return"Sitemap inspection";case et["ga-sync"]:return"GA sync";case et["traffic-sync"]:return"Traffic sync";case et["bing-inspect"]:return"Bing URL inspection";case et["bing-inspect-sitemap"]:return"Bing sitemap inspection";case et["site-audit"]:return"Site audit";case et["backlink-extract"]:return"Backlink extract";case et["aeo-discover-seed"]:return"Discovery (seed phase)";case et["aeo-discover-probe"]:return"Discovery (probe phase)"}}function w6(e){return e===qr.manual?"Manual":e===qr.scheduled?"Scheduled":e===qr["config-apply"]?"Config apply":e}function Yf(e,s){return{id:e.id,projectId:e.projectId,projectName:s,kind:e.kind,kindLabel:wN(e.kind),status:e.status,trigger:e.trigger??"manual",location:e.location??null,createdAt:e.createdAt,startedAt:e.startedAt?ob(e.startedAt):ob(e.createdAt),duration:N6(e.startedAt??null,e.finishedAt??null),statusDetail:e.error?SN(e.error):S6(e),summary:z6(e),triggerLabel:w6(e.trigger)}}function SN(e){const s=Rf(e);return s.length>200?s.slice(0,200)+"…":s}function S6(e){switch(e.status){case jn.queued:return"Waiting for execution slot.";case jn.running:return"Provider queries in progress.";case jn.completed:return"All queries checked.";case jn.partial:return"Run completed with some queries skipped.";case jn.failed:return e.error?SN(e.error):"Run failed.";case jn.cancelled:return"Run was cancelled.";default:return""}}function z6(e){const s=wN(e.kind);switch(e.status){case jn.queued:return`${s} queued`;case jn.running:return`${s} in progress`;case jn.completed:return`${s} completed`;case jn.partial:return`${s} partially completed`;case jn.failed:return`${s} failed`;case jn.cancelled:return`${s} cancelled`;default:return e.status}}function k6(e,s,i,r){const o=[];let u=0;const d=new Set;if(i.length>0){const h=i.flatMap(T=>T.snapshots??[]),p=new Map;for(const T of h)if(T.query){const w=`${T.query}::${T.provider}::${T.location??""}`;p.set(w,T)}const x=new Set(h.map(T=>T.location??null));x.size===0&&x.add(null);const b=new Set(h.map(T=>T.provider)),v=new Set(s.flatMap(T=>Object.keys(T.providerRuns??{}))),N=[...new Set([...b,...v])].sort(),z=N.length>0?N:["gemini"];for(const T of s){if(T.runs.length===0)continue;d.add(T.query);const w=T.runs.at(-1),A=w?.transition??"not-cited";for(const D of z){const U=[...x].filter(L=>p.has(`${T.query}::${D}::${L??""}`)),I=(T.providerRuns?.[D]?.length??0)>0,C=U.length>0?U:I?[null]:[];for(const L of C){const M=L??"",_=p.get(`${T.query}::${D}::${M}`),B=_?.model??null,J=B?`${D}:${B}`:null,ue=T.providerRuns?.[D],P=J?T.modelRuns?.[J]:void 0,ie=Ue=>Ue?.filter(Ce=>(Ce.location??null)===L),te=U.length>0?ie(ue):ue,ze=U.length>0?ie(P):P,ve=(te?.length?te:null)??(ze?.length?ze:null),V=te?.length?"provider":ze?.length?"model":"query",ne=ve?ve.at(-1).transition:A,me=ve?ve.at(-1).visibilityTransition??(ve.at(-1).visibilityState==="visible"?"visible":"not-visible"):w?.visibilityTransition??(w?.visibilityState==="visible"?"visible":"not-visible"),Ne=ve?.at(-1)?.citationState,se=ve?.at(-1)?.visibilityState,pe=_?ne==="lost"?"lost":ne==="emerging"?"emerging":_.citationState===po.cited?"cited":"not-cited":Ne===po.cited?"cited":"not-cited",E=_?.visibilityState??(se==="visible"?"visible":se==="pending"?"pending":"not-visible"),X=cb(ve||T.runs),Y=ub(ve||T.runs),ye=C6(T,D),le=(ve??T.runs).map(Ue=>({runId:Ue.runId,citationState:Ue.citationState,createdAt:Ue.createdAt,model:ye.get(Ue.runId)??null,answerMentioned:Ue.answerMentioned,visibilityState:Ue.visibilityState,visibilityTransition:Ue.visibilityTransition,mentionState:Ue.mentionState,mentionTransition:Ue.mentionTransition})),Re=A6(le),tt=V==="provider"&&Re.length<=1?"model":V,we=T6(le);o.push({id:`evidence_${e}_${u++}`,query:T.query,provider:_?.provider??D,model:_?.model??null,location:_?.location??L,citationState:pe,answerMentioned:_?.answerMentioned,visibilityState:E,visibilityChangeLabel:db(me,Y,{positive:"visible",negative:"not visible",first:"first visibility"}),changeLabel:db(ne,X),answerSnippet:_?.answerText??"",citedDomains:_?.citedDomains??[],evidenceUrls:[],competitorDomains:_?.competitorOverlap??[],recommendedCompetitors:_?.recommendedCompetitors??[],matchedTerms:_?.matchedTerms??[],relatedTechnicalSignals:[],groundingSources:_?.groundingSources??[],summary:_6(E,me,T.query),runHistory:le,historyScope:tt,modelsSeen:Re,modelTransitions:we})}}}}for(const h of r)d.has(h.query)||o.push({id:`evidence_${e}_${u++}`,query:h.query,provider:"",model:null,location:null,citationState:"pending",visibilityState:"pending",visibilityChangeLabel:"Awaiting first run",changeLabel:"Awaiting first run",answerSnippet:"",citedDomains:[],evidenceUrls:[],competitorDomains:[],recommendedCompetitors:[],matchedTerms:[],relatedTechnicalSignals:[],groundingSources:[],summary:`"${h.query}" has been added but no visibility run has been triggered yet.`,runHistory:[],historyScope:"query",modelsSeen:[],modelTransitions:[]});return o}function C6(e,s){const i=new Map,r=`${s}:`;for(const[o,u]of Object.entries(e.modelRuns??{})){if(!o.startsWith(r))continue;const d=o.slice(r.length),h=d==="unknown"?null:d;for(const p of u)i.set(p.runId,h)}return i}function A6(e){const s=new Set;for(const i of e)i.model&&s.add(i.model);return[...s]}function T6(e){const s=[];let i=null;for(const r of e){const o=r.model??null;o!==i&&i!==null&&s.push({runId:r.runId,createdAt:r.createdAt,fromModel:i,toModel:o}),i=o}return s}function cb(e){if(e.length===0)return 0;const s=e[e.length-1].citationState;let i=0;for(let r=e.length-1;r>=0&&e[r].citationState===s;r--)i++;return i}function ub(e){if(e.length===0)return 0;const s=e[e.length-1].visibilityState??"not-visible";let i=0;for(let r=e.length-1;r>=0&&(e[r].visibilityState??"not-visible")===s;r--)i++;return i}function db(e,s,i){const r={positive:i?.positive??"cited",negative:i?.negative??"not cited",first:i?.first??"first citation"};switch(e){case"new":return"First observation";case"cited":case"visible":return s<=1?`${eo(r.positive)} in latest run`:`${eo(r.positive)} for ${s} runs`;case"lost":return"Lost since last run";case"emerging":return eo(r.first);case"not-cited":case"not-visible":return s<=1?`${eo(r.negative)} in latest run`:`${eo(r.negative)} across ${s} runs`;default:return e}}function eo(e){return e.charAt(0).toUpperCase()+e.slice(1)}function _6(e,s,i){switch(s){case"lost":return`Mention was lost for "${i}". Your brand no longer appeared in the latest answer.`;case"emerging":return`Your brand started appearing in AI answers for "${i}".`}switch(e){case"visible":return`Your brand or domain is mentioned in AI answers for "${i}".`;case"pending":return`"${i}" has been added but no run has been triggered yet.`;default:return`Your brand or domain was not mentioned in AI answers for "${i}".`}}function E6(e){const s=NN(e.project),i=k6(s.name,e.timeline,e.latestRunDetails,e.queries),o=[...e.runs].sort((u,d)=>d.createdAt.localeCompare(u.createdAt)).map(u=>Yf(u,e.project.displayName||e.project.name));return e.overview?D6(s,e.overview,i,o):O6(s,i,o)}function D6(e,s,i,r){const o=j6(s.topInsights);for(const u of s.attentionItems)u.id.startsWith("insight_")||o.push({id:u.id,tone:u.tone,title:u.title,detail:u.detail,actionLabel:u.actionLabel,actionGroup:"investigate",affectedPhrases:[]});return{project:e,dateRangeLabel:s.dateRangeLabel,contextLabel:s.contextLabel,mentionSummary:s.scores.mention,visibilitySummary:s.scores.visibility,mentionShareSummary:s.scores.mentionShare,queryCounts:{cited:s.queryCounts.citedQueries,total:s.queryCounts.totalQueries},gapQueries:s.scores.gapQueries,mentionGaps:s.scores.mentionGaps,indexCoverage:s.scores.indexCoverage,providerScores:s.providerScores,competitorPressure:s.scores.competitorPressure,runStatus:s.scores.runStatus,movementSummary:s.movementSummary,insights:o,visibilityEvidence:i,competitors:s.competitors.map(u=>({id:u.id,domain:u.domain,citationCount:u.citationCount,totalQueries:u.totalQueries,pressureLabel:u.pressureLabel,citedQueries:u.citedQueries,movement:"",notes:""})),recentRuns:r.slice(0,5),suggestedQueries:s.suggestedQueries}}function O6(e,s,i){const r={label:"",value:"No data",delta:"Loading…",tone:"neutral",description:"",tooltip:"",trend:[]};return{project:e,dateRangeLabel:"All time",contextLabel:`${e.country} / ${e.language.toUpperCase()}`,mentionSummary:{...r,label:"Mention Coverage"},visibilitySummary:{...r,label:"Citation Coverage"},mentionShareSummary:{...r,label:"Mention Share",breakdown:{projectMentionSnapshots:0,competitorMentionSnapshots:0,perCompetitor:[],snapshotsWithAnswerText:0,snapshotsTotal:0}},queryCounts:{cited:0,total:0},gapQueries:{...r,label:"Citation Gaps"},mentionGaps:{...r,label:"Mention Gaps"},indexCoverage:{...r,label:"Index Coverage"},providerScores:[],competitorPressure:{...r,label:"Competitor Pressure"},runStatus:{...r,label:"Run Status"},movementSummary:{gained:0,lost:0,tone:"neutral",hasPreviousRun:!1},insights:[],visibilityEvidence:s,competitors:[],recentRuns:i.slice(0,5),suggestedQueries:{rows:[],totalCandidates:0,skippedAlreadyTracked:0}}}function R6(e){const s=NN(e.project),i=[...e.runs].sort((N,z)=>z.createdAt.localeCompare(N.createdAt)),r=i.find(N=>N.kind===et["answer-visibility"])??i[0],o=e.project.displayName||e.project.name,u=r?Yf(r,o):L6(e.project.id,o),d=e.overview;if(!d)return{project:s,visibilityScore:0,visibilityDelta:"No data",visibilityTone:"neutral",lastRun:u,insight:"No runs completed yet.",trend:[],competitorPressureLabel:"None"};const h=d.scores.visibility,p=h.progress??0,x=d.queryCounts.citedQueries,b=d.queryCounts.totalQueries,v=d.providers.length;return{project:s,visibilityScore:p,visibilityDelta:b>0?`${x} of ${b} queries`:"No data",visibilityTone:h.tone,providerCoverage:h.providerCoverage,lastRun:u,insight:b>0?`${x} of ${b} queries mentioned across ${v} provider${v===1?"":"s"}.`:"No runs completed yet.",trend:[],competitorPressureLabel:d.scores.competitorPressure.value}}function L6(e,s){return{id:"none",projectId:e,projectName:s,kind:et["answer-visibility"],kindLabel:"No runs yet",status:jn.queued,trigger:qr.manual,createdAt:"",startedAt:"",duration:"",statusDetail:"",summary:"No runs yet",triggerLabel:""}}function M6(e,s){const i=[],r=[],o=[];for(const d of e){r.push(E6(d)),o.push(R6(d));const h=[...d.runs].sort((p,x)=>x.createdAt.localeCompare(p.createdAt));for(const p of h)i.push(Yf(p,d.project.displayName||d.project.name))}i.sort((d,h)=>h.createdAt.localeCompare(d.createdAt));const u=e.length>0;return{portfolioOverview:{projects:o,attentionItems:u?$6(r):[{id:"attention_setup",tone:"neutral",title:"No projects yet",detail:"Create your first project using the setup wizard, CLI, or API.",actionLabel:"Open setup",href:"/setup"}],recentRuns:i.slice(0,5),systemHealth:[{id:"api",label:"API",tone:"positive",detail:"Connected",meta:"Real-time data"},{id:"provider",label:"Gemini",tone:"positive",detail:"Configured",meta:"Provider active"}],lastUpdatedAt:new Date().toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}),...u?{}:{emptyState:{title:"No projects yet",detail:"Canonry becomes useful after one project, a small query set, and one competitor list are in place.",ctaLabel:"Launch setup",ctaHref:"/setup"}}},projects:r,runs:i,setup:{healthChecks:[{id:"api",label:"API reachable",detail:"API is responding.",state:"ready",guidance:"Required for project creation and run history."},{id:"provider",label:"Provider configured",detail:"Gemini key is configured.",state:"ready",guidance:"Required for answer-visibility sweeps."}],projectDraft:{name:"",canonicalDomain:"",country:"US",language:"en"},queryImportState:{mode:"paste",queryCount:0,preview:[]},competitorDraft:{domains:[],notes:"Use the CLI to add competitors."},launchState:{enabled:u,ctaLabel:u?"Trigger run":"Create a project first",summary:u?"Ready to run.":"Create a project first to launch a run."}},settings:{providerStatuses:(s?.providers??[]).map(d=>({name:d.name,displayName:d.displayName,keyUrl:d.keyUrl,modelHint:d.modelHint,model:d.model,state:d.configured?"ready":"needs-config",detail:d.configured?"Provider is configured.":"API key is missing.",quota:d.quota})),google:{state:s?.google?.configured?"ready":"needs-config",detail:s?.google?.configured?"Google OAuth app credentials are configured. Project-level GSC connections can be created from the dashboard.":"Google OAuth client ID and client secret are not configured yet."},bing:{state:s?.bing?.configured?"ready":"needs-config",detail:s?.bing?.configured?"Bing Webmaster Tools API key is configured. Project-level Bing connections can be created from the dashboard.":"Bing Webmaster Tools API key is not configured yet."},selfHostNotes:["Configuration is stored in ~/.canonry/config.yaml.","The local config file is the source of truth for authentication credentials.","Google OAuth app credentials and per-domain Google tokens are stored in local config, not the database.","Database is SQLite at ~/.canonry/data.db.","API key was auto-generated during canonry init."],bootstrapNote:"Use the UI, CLI, or ~/.canonry/config.yaml to manage settings. Authentication credentials persist to local config."}}}function $6(e){const s=[];for(const i of e){const r=i.visibilityEvidence.filter(u=>u.citationState==="lost");r.length>0&&s.push({id:`attention_${i.project.id}_lost`,tone:"negative",title:`${i.project.displayName||i.project.name} lost citations`,detail:`${r.length} quer${r.length>1?"ies":"y"} lost citation.`,actionLabel:"Open project",href:`/projects/${i.project.id}`});const o=i.recentRuns.filter(u=>u.status===jn.running||u.status===jn.queued);o.length>0&&s.push({id:`attention_${i.project.id}_active`,tone:"neutral",title:`${i.project.displayName||i.project.name} has active runs`,detail:`${o.length} run${o.length>1?"s":""} in progress.`,actionLabel:"View runs",href:"/runs"})}return s.length===0&&s.push({id:"attention_stable",tone:"positive",title:"All projects stable",detail:"No citation losses or active runs to flag.",actionLabel:"View portfolio",href:"/"}),s}const zN=j.createContext(null);zN.Provider;function wo(){return j.useContext(zN)}function B6(e,s){return["projects",e,s]}function Pi(e){const i=wo()?.dashboard??null,r=tn({...Bu({client:ae}),enabled:!i}),o=tn({...Hj({client:ae}),enabled:!i,staleTime:Kh,refetchInterval:T=>T.state.data?.some(D=>D.status==="running"||D.status==="queued")?3e3:Kh}),u=tn({...Qj({client:ae}),enabled:!i}),d=r.data??[],h=o.data??[],p=Fb({queries:d.map(T=>{const w=h.filter(M=>M.projectId===T.id),A=w.filter(M=>(M.status==="completed"||M.status==="partial")&&M.kind==="answer-visibility"&&M.trigger!=="probe").sort((M,_)=>_.createdAt.localeCompare(M.createdAt)),D=A[0]?.createdAt??null,U=D?A.filter(M=>M.createdAt===D).map(M=>M.id):[],I=A.find(M=>M.createdAt!==D)?.createdAt??null,C=I?A.filter(M=>M.createdAt===I).map(M=>M.id):[],L=[...U].sort().join(",");return{queryKey:B6(T.id,L||void 0),queryFn:async()=>{const[M,_,B,J,ue,P,ie,te,ze]=await Promise.all([d2(T.name).catch(()=>[]),xv(T.name).catch(()=>[]),yv(T.name).catch(()=>[]),U.length?Promise.all(U.map(ve=>Kr(ve).catch(()=>null))).then(ve=>ve.filter(V=>V!=null)):Promise.resolve([]),C.length?Promise.all(C.map(ve=>Kr(ve).catch(()=>null))).then(ve=>ve.filter(V=>V!=null)):Promise.resolve([]),q2(T.name).catch(()=>null),F2(T.name).catch(()=>null),rC(T.name).catch(()=>null),m2(T.name).catch(()=>null)]);return{project:T,runs:w,queries:M,competitors:_,timeline:B,latestRunDetails:J,previousRunDetails:ue,gscCoverage:P,bingCoverage:ie,dbInsights:te,overview:ze}},enabled:!i&&r.isSuccess&&o.isSuccess,staleTime:Cv}})}),x=p.every(T=>T.isSuccess),b=j.useMemo(()=>{if(i)return i;if(!r.data||!o.data||d.length>0&&!x)return null;const T=p.map(w=>w.data?{...w.data,runs:h.filter(A=>A.projectId===w.data.project.id)}:null).filter(w=>w!=null);return M6(T,u.data??null)},[i,r.data,o.data,u.data,x,p,d.length,h]),v=!i&&(r.isError||o.isError),N=!i&&!b&&!v,z=j.useCallback(async()=>{await Promise.all([r.refetch(),o.refetch(),u.refetch()])},[r.refetch,o.refetch,u.refetch]);return{dashboard:b,isLoading:N,isError:v,refetch:z}}const q6=["health"];async function I6(){const e=await oC("/health","API"),s=e.state==="ok"?{label:"Worker",state:"ok",detail:"In-process job runner"}:{label:"Worker",state:e.state,detail:`Depends on API health check · ${e.detail}`,statusCode:e.statusCode,hint:e.hint?`Worker status is inferred from API health in this deployment mode. ${e.hint}`:"Worker status is inferred from API health in this deployment mode."};return{apiStatus:e,workerStatus:s}}function Hu(e,s){return tn({queryKey:q6,queryFn:I6,enabled:e,refetchInterval:15e3,initialData:s})}function U6(e){return tn({...Kj({client:ae,path:{id:e??""}}),enabled:!!e,refetchInterval:s=>{const i=s.state.data?.status;return i==="running"||i==="queued"?3e3:!1}})}function tl(){const e=bo(),s=LS({strict:!1}),i=MS({select:p=>p.location.pathname}),r=s.runId??null,o=s.evidenceId??null;return{runId:r,evidenceId:o,openRun:p=>{e({to:i,from:Kn.to,search:x=>({...x,runId:p,evidenceId:void 0})})},openEvidence:p=>{e({to:i,from:Kn.to,search:x=>({...x,evidenceId:p,runId:void 0})})},closeDrawer:()=>{e({to:i,from:Kn.to,search:p=>({...p,runId:void 0,evidenceId:void 0})})}}}const P6={negative:"toast-card-negative",caution:"toast-card-caution",positive:"toast-card-positive",neutral:"toast-card-neutral"};function G6(e){if(e.cta)return`${e.cta.label}: ${e.title}`}function V6(){const e=j.useSyncExternalStore(zC,by,by),s=bo(),{openRun:i}=tl(),r=j.useCallback(u=>{Hh(u)},[]),o=j.useCallback(u=>{u.cta&&(u.cta.intent==="open-run-drawer"?i(u.cta.runId):s({to:"/runs"}),Hh(u.id))},[s,i]);return e.length===0?null:t.jsx("div",{className:"toast-viewport","aria-label":"Notifications",children:e.map(u=>t.jsxs("section",{role:u.tone==="negative"?"alert":"status","aria-live":u.tone==="negative"?"assertive":"polite","data-state":u.state,className:`toast-card ${P6[u.tone]}`,children:[t.jsxs("div",{className:"toast-copy",children:[t.jsx("p",{className:"toast-title",children:u.title}),u.detail?t.jsx("p",{className:"toast-detail",children:u.detail}):null,u.cta?t.jsx("button",{type:"button",className:"toast-action",onClick:()=>o(u),"aria-label":G6(u),children:u.cta.label}):null]}),t.jsx("button",{type:"button",onClick:()=>r(u.id),className:"toast-dismiss","aria-label":"Dismiss",children:t.jsx(qi,{className:"size-3.5"})})]},u.id))})}async function Xf(e){try{return await e.json()}catch{return{}}}function H6(){return typeof window<"u"&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath.replace(/\/$/,"")+"/api/v1":"/api/v1"}const Jf=H6();function Wf(e){(e===401||e===403)&&jf()}async function mb(e){const s=await fetch(`${Jf}/projects/${encodeURIComponent(e)}/agent/transcript`,{credentials:"include"});if(!s.ok){Wf(s.status);const i=await Xf(s);throw new un(i.error?.message??`transcript fetch failed: ${s.status}`,s.status,i.error?.code)}return await s.json()}async function K6(e){const s=await fetch(`${Jf}/projects/${encodeURIComponent(e)}/agent/transcript`,{method:"DELETE",credentials:"include"});if(!s.ok){Wf(s.status);const i=await Xf(s);throw new un(i.error?.message??`reset failed: ${s.status}`,s.status,i.error?.code)}}async function Q6({project:e,prompt:s,provider:i,modelId:r,scope:o,signal:u,onEvent:d}){const h={prompt:s};i&&(h.provider=i),r&&(h.modelId=r),o&&(h.scope=o);const p=await fetch(`${Jf}/projects/${encodeURIComponent(e)}/agent/prompt`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(h),signal:u});if(!p.ok||!p.body){Wf(p.status);const z=await Xf(p);throw new un(z.error?.message??`prompt failed: ${p.status}`,p.status,z.error?.code)}const x=p.body.getReader(),b=new TextDecoder;let v="";const N=()=>{x.cancel().catch(()=>{})};u?.addEventListener("abort",N,{once:!0});try{for(;;){const{value:z,done:T}=await x.read();if(T)break;v+=b.decode(z,{stream:!0});let w=v.indexOf(`
58
-
59
- `);for(;w!==-1;){const A=v.slice(0,w);v=v.slice(w+2);for(const D of A.split(`
60
- `)){if(!D.startsWith("data:"))continue;const U=D.slice(5).trim();if(U)try{d(JSON.parse(U))}catch{}}w=v.indexOf(`
61
-
62
- `)}}}finally{u?.removeEventListener("abort",N);try{x.releaseLock()}catch{}}}function kN(e){return!e||e.role!=="assistant"?"":e.content.filter(s=>s.type==="text").map(s=>s.text).join("")}const Z6=[{label:"Status",prompt:"Quick status overview for this project — latest runs, current health, anything unusual."},{label:"Top insights",prompt:"Walk me through the 3 most severe active insights and what to do about each."},{label:"Last failed run",prompt:"If the latest run failed, dig into it and tell me what went wrong plus how to fix it."},{label:"Schedule",prompt:"What is the current sweep schedule, and is it appropriate given recent volatility?"}],F6=[{command:"/status",label:"Status",hint:"Latest runs, health, anything unusual",prompt:"Quick status overview for this project — latest runs, current health, anything unusual."},{command:"/insights",label:"Top insights",hint:"Walk through the most severe active insights",prompt:"Walk me through the 3 most severe active insights and what to do about each."},{command:"/last-run",label:"Last run",hint:"Summarize the latest sweep",prompt:"Summarize the latest run for this project — provider mix, visibility changes, and anything that moved."},{command:"/last-failed",label:"Last failed run",hint:"Diagnose the most recent failure",prompt:"If the latest run failed, dig into it and tell me what went wrong plus how to fix it."},{command:"/run-sweep",label:"Run sweep now",hint:"Trigger a new visibility sweep",prompt:"Run a new answer-visibility sweep for this project now and tell me when it lands."},{command:"/schedule",label:"Schedule",hint:"Review the sweep schedule",prompt:"What is the current sweep schedule, and is it appropriate given recent volatility?"},{command:"/queries",label:"Queries",hint:"List tracked queries",prompt:"List the tracked queries for this project and flag any that are obvious duplicates or underperformers."},{command:"/competitors",label:"Competitors",hint:"List tracked competitors",prompt:"List this project's tracked competitors and call out which ones are showing up in answer citations."},{command:"/clear",label:"Clear conversation",hint:"Wipe transcript and start fresh",action:"clear"}],Vc=e=>`canonry:aero:provider:${e}`,hb=e=>`canonry:aero:scope:${e}`;function Y6({projectName:e}){const[s,i]=j.useState(!1),[r,o]=j.useState(!1),[u,d]=j.useState([]),[h,p]=j.useState(""),[x,b]=j.useState(!1),[v,N]=j.useState([]),[z,T]=j.useState(""),[w,A]=j.useState(null),[D,U]=j.useState(()=>typeof window>"u"?null:window.localStorage.getItem(Vc(e))??null),[I,C]=j.useState(()=>typeof window>"u"?"read-only":window.localStorage.getItem(hb(e))==="all"?"all":"read-only"),L=j.useRef(null),M=j.useRef(null),_=j.useRef(null),[B,J]=j.useState(0),ue=j.useMemo(()=>{const E=h.trimStart();if(!E.startsWith("/"))return[];if(/\s/.test(E))return[];const X=E.toLowerCase();return F6.filter(Y=>Y.command.startsWith(X)||Y.label.toLowerCase().includes(X.slice(1)))},[h]);j.useEffect(()=>{J(E=>ue.length===0?0:Math.min(E,ue.length-1))},[ue.length]);const P=tn({...KO({client:ae,path:{name:e}}),enabled:s,staleTime:6e4}),ie=j.useMemo(()=>{const E=P.data?.providers??[];if(D){const Y=E.find(ye=>ye.id===D&&ye.configured);if(Y)return Y}const X=P.data?.defaultProvider;return X?E.find(Y=>Y.id===X)??null:null},[D,P.data]);j.useEffect(()=>{if(!P.data||!D)return;P.data.providers.find(X=>X.id===D&&X.configured)||(U(null),window.localStorage.removeItem(Vc(e)))},[P.data,D,e]);const te=j.useCallback(E=>{U(E),!(typeof window>"u")&&(E?window.localStorage.setItem(Vc(e),E):window.localStorage.removeItem(Vc(e)))},[e]),ze=j.useCallback(()=>{C(E=>{const X=E==="all"?"read-only":"all";return typeof window<"u"&&window.localStorage.setItem(hb(e),X),X})},[e]);j.useEffect(()=>{if(!s)return;const E=X=>{X.key==="Escape"&&(r?o(!1):i(!1))};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[s,r]),j.useEffect(()=>{if(!s)return;let E=!1;A(null);const X=()=>{E||x||mb(e).then(le=>{E||d(le.messages)}).catch(le=>{E||A(le instanceof Error?le.message:"Failed to load transcript")})};X();const ye=window.setInterval(X,15e3);return()=>{E=!0,window.clearInterval(ye)}},[s,e,x]),j.useEffect(()=>()=>{L.current?.abort()},[e]),j.useEffect(()=>{const E=M.current;E&&(E.scrollTop=E.scrollHeight)},[u,z,v]);async function ve(E){const X=E.trim();if(!X||x)return;A(null),p(""),b(!0),T(""),N([]);const Y={role:"user",content:X,timestamp:Date.now()};d(le=>[...le,Y]);const ye=new AbortController;L.current=ye;try{await Q6({project:e,prompt:X,provider:D??void 0,scope:I,signal:ye.signal,onEvent:V});const le=await mb(e);d(le.messages)}catch(le){le.name!=="AbortError"&&A(le instanceof Error?le.message:"Prompt failed")}finally{b(!1),T(""),L.current=null}}function V(E){switch(E.type){case"message_update":T(kN(E.message));break;case"message_end":E.message.role==="assistant"&&T("");break;case"tool_execution_start":N(X=>[...X,{id:E.toolCallId,name:E.toolName,args:E.args,startedAt:Date.now()}]);break;case"tool_execution_end":N(X=>X.map(Y=>Y.id===E.toolCallId?{...Y,endedAt:Date.now(),isError:E.isError,result:E.result}:Y));break;case"error":A(E.message);break}}async function ne(){L.current?.abort();try{await K6(e),d([]),A(null)}catch(E){A(E instanceof Error?E.message:"Reset failed")}}const me=u.length===0,Ne=s&&r?"pointer-events-auto fixed inset-0 z-40 flex items-stretch justify-center bg-zinc-950/70 p-4 sm:p-8 backdrop-blur-sm":"pointer-events-none fixed inset-x-0 bottom-0 z-40 flex justify-center p-3",se=r?"pointer-events-auto flex h-full w-full max-w-5xl flex-col overflow-hidden rounded-2xl border border-zinc-800/80 bg-zinc-950/95 shadow-2xl":"pointer-events-auto w-full max-w-3xl",pe=r?"flex-1 overflow-y-auto px-6 py-5 text-sm text-zinc-200":"max-h-[40vh] min-h-[120px] overflow-y-auto px-4 py-3 text-sm text-zinc-200";return t.jsx("div",{className:Ne,onClick:E=>{r&&E.target===E.currentTarget&&o(!1)},children:t.jsx("div",{className:se,children:s?t.jsxs("div",{className:r?"flex h-full flex-col":"flex flex-col overflow-hidden rounded-2xl border border-zinc-800/80 bg-zinc-950/95 shadow-xl backdrop-blur",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-zinc-800/70 px-4 py-2.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(jy,{className:"h-4 w-4 text-emerald-400","aria-hidden":"true"}),t.jsx("span",{className:"text-sm font-medium text-zinc-100",children:"Aero"}),t.jsx("span",{className:"text-[10px] uppercase tracking-wider text-zinc-500",children:x?"working…":e})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(X6,{providers:P.data?.providers??[],active:ie,override:D,onPick:te,disabled:x}),t.jsx("button",{type:"button",onClick:Le(ne),className:"rounded-md p-1.5 text-zinc-500 transition hover:bg-zinc-800/60 hover:text-zinc-200","aria-label":"Reset conversation",title:"Reset conversation",children:t.jsx(Rv,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),t.jsx("button",{type:"button",onClick:()=>o(E=>!E),className:"rounded-md p-1.5 text-zinc-500 transition hover:bg-zinc-800/60 hover:text-zinc-200","aria-label":r?"Collapse":"Expand",title:r?"Collapse":"Expand",children:r?t.jsx(pA,{className:"h-3.5 w-3.5","aria-hidden":"true"}):t.jsx(dA,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),t.jsx("button",{type:"button",onClick:()=>{o(!1),i(!1)},className:"rounded-md p-1.5 text-zinc-500 transition hover:bg-zinc-800/60 hover:text-zinc-200","aria-label":"Close Aero",children:t.jsx(qi,{className:"h-4 w-4","aria-hidden":"true"})})]})]}),t.jsxs("div",{ref:M,className:pe,children:[w&&t.jsx("div",{className:"mb-2 rounded-md border border-rose-700/40 bg-rose-950/40 px-3 py-2 text-xs text-rose-200",children:w}),me&&!x&&t.jsxs("div",{className:"flex flex-col gap-3 py-2",children:[t.jsxs("p",{className:"text-xs text-zinc-500",children:["Ask anything about ",t.jsx("span",{className:"text-zinc-300",children:e}),", or start with:"]}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:Z6.map(E=>t.jsx("button",{type:"button",onClick:()=>{ve(E.prompt)},className:"rounded-full border border-zinc-800 bg-zinc-900/70 px-3 py-1 text-xs text-zinc-300 transition hover:border-zinc-700 hover:bg-zinc-800/70 hover:text-zinc-100",children:E.label},E.label))})]}),nL(u,e,D,I),v.length>0&&t.jsx("div",{className:"mt-3 space-y-1.5",children:v.map(E=>t.jsx(CN,{trail:E},E.id))}),x&&z&&t.jsxs("div",{className:"mt-3",children:[t.jsx("div",{className:"mb-0.5 text-[10px] uppercase tracking-wider text-emerald-400",children:"Aero"}),t.jsx(AN,{content:z})]}),x&&!z&&v.every(E=>E.endedAt!==void 0)&&t.jsx(rL,{})]}),t.jsx(J6,{projectName:e,activeProvider:ie,scope:I,onToggleScope:ze,disabled:x}),t.jsxs("div",{className:"relative",children:[ue.length>0&&t.jsx(W6,{matches:ue,selectedIndex:B,onHover:J,onPick:E=>{p(""),_.current?.focus(),E.action==="clear"?ne():ve(E.prompt)}}),t.jsxs("form",{className:"flex items-end gap-2 border-t border-zinc-800/70 bg-zinc-950/80 px-3 py-2.5",onSubmit:E=>{if(E.preventDefault(),ue.length>0){const X=ue[B];p(""),X.action==="clear"?ne():ve(X.prompt);return}ve(h)},children:[t.jsx("textarea",{ref:_,value:h,onChange:E=>p(E.target.value),onKeyDown:E=>{if(ue.length>0){if(E.key==="ArrowDown"){E.preventDefault(),J(X=>(X+1)%ue.length);return}if(E.key==="ArrowUp"){E.preventDefault(),J(X=>(X-1+ue.length)%ue.length);return}if(E.key==="Tab"){E.preventDefault();const X=ue[B];p(`${X.command} `);return}if(E.key==="Escape"){E.preventDefault(),p("");return}}if(E.key==="Enter"&&!E.shiftKey)if(E.preventDefault(),ue.length>0){const X=ue[B];p(""),X.action==="clear"?ne():ve(X.prompt)}else ve(h)},placeholder:"Ask Aero, or / for commands…",disabled:x,rows:r?3:1,className:"flex-1 resize-none bg-transparent text-sm text-zinc-100 placeholder:text-zinc-600 focus:outline-none disabled:opacity-60"}),t.jsx("button",{type:"submit",disabled:x||!h.trim(),className:"inline-flex h-7 w-7 items-center justify-center rounded-md bg-emerald-500 text-zinc-950 transition hover:bg-emerald-400 disabled:opacity-40","aria-label":"Send",children:t.jsx($C,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]})]}):t.jsxs("button",{type:"button",onClick:()=>i(!0),className:"flex w-full items-center justify-between rounded-full border border-zinc-800/80 bg-zinc-950/95 px-4 py-2 text-left text-sm text-zinc-400 shadow-lg backdrop-blur transition hover:border-zinc-700 hover:bg-zinc-900/90 hover:text-zinc-200",children:[t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(jy,{className:"h-4 w-4 text-emerald-400","aria-hidden":"true"}),"Ask Aero about ",e,"…"]}),t.jsx("span",{className:"text-[10px] uppercase tracking-wider text-zinc-600",children:"Enter"})]})})})}function X6({providers:e,active:s,override:i,onPick:r,disabled:o}){const[u,d]=j.useState(!1),h=j.useRef(null);if(j.useEffect(()=>{if(!u)return;const b=N=>{h.current?.contains(N.target)||d(!1)},v=N=>{N.key==="Escape"&&d(!1)};return window.addEventListener("mousedown",b),window.addEventListener("keydown",v),()=>{window.removeEventListener("mousedown",b),window.removeEventListener("keydown",v)}},[u]),e.length===0)return null;const p=s?.label.replace(/\s+\(.+\)$/,"")??"No provider",x=s?.defaultModel;return t.jsxs("div",{ref:h,className:"relative",children:[t.jsxs("button",{type:"button",onClick:()=>d(b=>!b),disabled:o,className:"flex items-center gap-1 rounded-md px-1.5 py-1 text-[11px] text-zinc-400 transition hover:bg-zinc-800/60 hover:text-zinc-200 disabled:opacity-50","aria-label":"Switch agent model","aria-haspopup":"listbox","aria-expanded":u,title:s?`${s.label} · ${s.defaultModel}`:"Pick a provider",children:[t.jsx("span",{className:"font-medium text-zinc-200",children:p}),x&&t.jsx("span",{className:"hidden font-mono text-[10px] text-zinc-500 sm:inline",children:x}),t.jsx(PC,{className:"h-3 w-3","aria-hidden":"true"})]}),u&&t.jsxs("div",{role:"listbox",className:"absolute right-0 top-full z-50 mt-1 w-64 overflow-hidden rounded-lg border border-zinc-800 bg-zinc-950 shadow-xl",children:[t.jsx("div",{className:"border-b border-zinc-800/60 px-3 py-2 text-[10px] uppercase tracking-wider text-zinc-500",children:"Aero provider"}),t.jsx("ul",{className:"max-h-72 overflow-y-auto py-1",children:e.map(b=>{const v=s?.id===b.id,N=i===b.id;return t.jsx("li",{children:t.jsxs("button",{type:"button",role:"option","aria-selected":v,disabled:!b.configured,onClick:()=>{b.configured&&(r(N?null:b.id),d(!1))},className:"flex w-full items-start gap-2 px-3 py-2 text-left text-xs transition enabled:hover:bg-zinc-900 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx("span",{className:"mt-0.5 flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:v?t.jsx(Tv,{className:"h-3 w-3 text-emerald-400","aria-hidden":"true"}):null}),t.jsxs("span",{className:"flex-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"font-medium text-zinc-100",children:b.label}),N&&t.jsx("span",{className:"rounded-full border border-emerald-800/60 bg-emerald-950/60 px-1.5 text-[9px] uppercase tracking-wider text-emerald-300",children:"Pinned"}),!b.configured&&t.jsx("span",{className:"rounded-full border border-zinc-800 px-1.5 text-[9px] uppercase tracking-wider text-zinc-500",children:"Key missing"})]}),t.jsx("span",{className:"mt-0.5 block font-mono text-[10px] text-zinc-500",children:b.defaultModel}),b.keySource==="env"&&t.jsx("span",{className:"mt-0.5 block text-[10px] text-zinc-600",children:"via env var"}),!b.configured&&t.jsxs("span",{className:"mt-0.5 block text-[10px] text-zinc-600",children:["Add key in config.yaml or export"," ",t.jsx("code",{className:"font-mono text-zinc-400",children:eL(b.id)})]})]})]})},b.id)})}),i&&t.jsx("button",{type:"button",onClick:()=>{r(null),d(!1)},className:"w-full border-t border-zinc-800/60 px-3 py-2 text-left text-[11px] text-zinc-400 transition hover:bg-zinc-900 hover:text-zinc-100",children:"Reset to auto-detected default"})]})]})}function J6({projectName:e,activeProvider:s,scope:i,onToggleScope:r,disabled:o}){const u=s?.label.replace(/\s+\(.+\)$/,"")??null,d=i==="all";return t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-zinc-800/70 bg-zinc-950/80 px-3 pt-2",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-zinc-800 bg-zinc-900/70 px-2 py-0.5 text-[10px] text-zinc-400",children:[t.jsx("span",{className:"text-zinc-600",children:"project"}),t.jsx("span",{className:"font-medium text-zinc-200",children:e})]}),u&&t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-zinc-800 bg-zinc-900/70 px-2 py-0.5 text-[10px] text-zinc-400",children:[t.jsx("span",{className:"text-zinc-600",children:"model"}),t.jsx("span",{className:"font-medium text-zinc-200",children:u})]}),t.jsxs("button",{type:"button",onClick:r,disabled:o,className:`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] transition disabled:opacity-50 ${d?"border-amber-800/60 bg-amber-950/40 text-amber-300 hover:border-amber-700 hover:text-amber-200":"border-zinc-800 bg-zinc-900/70 text-zinc-400 hover:border-zinc-700 hover:text-zinc-200"}`,title:d?"Aero can invoke write tools (run sweep, dismiss insight, etc). Click to restrict.":"Aero is restricted to read-only tools. Click to allow writes.",children:[t.jsx("span",{className:d?"text-amber-500":"text-zinc-600",children:"scope"}),t.jsx("span",{className:"font-medium",children:d?"all tools":"read-only"})]})]})}function W6({matches:e,selectedIndex:s,onHover:i,onPick:r}){return t.jsxs("div",{className:"absolute inset-x-3 bottom-full mb-2 overflow-hidden rounded-lg border border-zinc-800 bg-zinc-950/98 shadow-2xl",children:[t.jsx("div",{className:"border-b border-zinc-800/60 px-3 py-1.5 text-[10px] uppercase tracking-wider text-zinc-500",children:"Commands"}),t.jsx("ul",{role:"listbox",className:"max-h-72 overflow-y-auto py-1",children:e.map((o,u)=>{const d=u===s;return t.jsx("li",{children:t.jsxs("button",{type:"button",role:"option","aria-selected":d,onMouseEnter:()=>i(u),onClick:()=>r(o),className:`flex w-full items-center gap-3 px-3 py-1.5 text-left text-xs transition ${d?"bg-zinc-900 text-zinc-100":"text-zinc-300 hover:bg-zinc-900/60"}`,children:[t.jsx("span",{className:"font-mono text-[11px] text-emerald-400",children:o.command}),t.jsx("span",{className:"font-medium",children:o.label}),t.jsx("span",{className:"ml-auto text-[10px] text-zinc-500",children:o.hint})]})},o.command)})}),t.jsxs("div",{className:"border-t border-zinc-800/60 px-3 py-1.5 text-[10px] text-zinc-600",children:[t.jsx("span",{className:"mr-3",children:"↑↓ to select"}),t.jsx("span",{className:"mr-3",children:"Enter to run"}),t.jsx("span",{children:"Tab to autocomplete"})]})]})}function eL(e){switch(e){case"claude":return"ANTHROPIC_API_KEY";case"openai":return"OPENAI_API_KEY";case"gemini":return"GOOGLE_API_KEY";case"zai":return"ZAI_API_KEY"}}function tL(e,s){const i=e.timestamp??0;return`${e.role}:${i}:${s}`}function nL(e,s,i,r){const o=[];for(let u=0;u<e.length;u++){const d=e[u],h=tL(d,u);if(d.role==="user"){const p=typeof d.content=="string"?d.content:JSON.stringify(d.content);if(p.startsWith("[system]"))continue;o.push(t.jsx(sL,{text:p,projectName:s,providerOverride:i,scope:r},h));continue}if(d.role==="assistant"){const p=new Map;let x=u+1;for(;x<e.length&&e[x].role==="toolResult";){const N=e[x];p.set(N.toolCallId,N),x++}const b=iL(d,p,d.timestamp??0),v=kN(d);o.push(t.jsxs(j.Fragment,{children:[b.length>0&&t.jsx("div",{className:"mt-3 space-y-1.5",children:b.map(N=>t.jsx(CN,{trail:N},N.id))}),v.trim()&&t.jsxs("div",{className:"mt-3",children:[t.jsx("div",{className:"mb-0.5 text-[10px] uppercase tracking-wider text-emerald-400",children:"Aero"}),t.jsx(AN,{content:v})]})]},h)),u=x-1;continue}}return o}function sL({text:e,projectName:s,providerOverride:i,scope:r}){const[o,u]=j.useState(!1),d=j.useMemo(()=>aL(s,e,i,r),[s,e,i,r]);async function h(){try{await navigator.clipboard.writeText(d),u(!0),window.setTimeout(()=>u(!1),1500)}catch{}}return t.jsxs("div",{className:"group relative mt-3 rounded-md bg-zinc-900/60 px-3 py-2 text-zinc-200",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("div",{className:"text-[10px] uppercase tracking-wider text-zinc-500",children:"You"}),t.jsx("button",{type:"button",onClick:Le(h),className:"inline-flex items-center gap-1 rounded border border-zinc-800/70 bg-zinc-950/60 px-1.5 py-0.5 text-[10px] text-zinc-400 opacity-0 transition hover:border-zinc-700 hover:text-zinc-100 group-hover:opacity-100 focus:opacity-100","aria-label":"Copy as CLI command",title:d,children:o?t.jsxs(t.Fragment,{children:[t.jsx(Tv,{className:"h-2.5 w-2.5 text-emerald-400","aria-hidden":"true"}),"Copied"]}):t.jsxs(t.Fragment,{children:[t.jsx(XC,{className:"h-2.5 w-2.5","aria-hidden":"true"}),"Copy as CLI"]})})]}),t.jsx("div",{className:"whitespace-pre-wrap",children:e})]})}function aL(e,s,i,r){const o=["canonry","agent","ask",fb(e),fb(s)];return i&&o.push("--provider",i),r==="read-only"&&o.push("--scope","read-only"),o.join(" ")}function fb(e){return`'${e.replace(/'/g,"'\\''")}'`}function iL(e,s,i){const r=[];for(const o of e.content){if(o.type!=="toolCall")continue;const u=o,d=s.get(u.id);r.push({id:u.id,name:u.name,args:u.arguments,startedAt:i,endedAt:d?.timestamp,isError:d?.isError,result:d?.content})}return r}function CN({trail:e}){const[s,i]=j.useState(!1),r=e.endedAt===void 0,o=!r&&e.isError===!0,u=e.endedAt!=null?e.endedAt-e.startedAt:null,d=u==null||u<0?null:u<1e3?`${u}ms`:`${(u/1e3).toFixed(1)}s`,h=o?"border-rose-800/50":r?"border-emerald-800/50":"border-zinc-800/70",p=o?"bg-rose-950/20":r?"bg-emerald-950/20":"bg-zinc-900/40";return t.jsxs("div",{className:`rounded-md border ${h} ${p} font-mono`,children:[t.jsxs("button",{type:"button",onClick:()=>i(x=>!x),className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left","aria-expanded":s,children:[t.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:r?t.jsx(Ov,{className:"h-3 w-3 animate-spin text-emerald-400","aria-hidden":"true"}):o?t.jsx(gu,{className:"h-3 w-3 text-rose-400","aria-hidden":"true"}):t.jsx(BA,{className:"h-3 w-3 text-zinc-500","aria-hidden":"true"})}),t.jsx("span",{className:"text-[11px] font-semibold text-zinc-100",children:e.name}),t.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-zinc-500",children:[r?t.jsx("span",{className:"text-emerald-400",children:"running…"}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:o?"failed":"ok"}),d&&t.jsx("span",{children:d})]}),t.jsx(jo,{className:`h-3 w-3 transition-transform ${s?"rotate-90":""}`,"aria-hidden":"true"})]})]}),s&&t.jsxs("div",{className:"border-t border-zinc-800/60 px-2.5 py-2 text-[11px] text-zinc-400",children:[t.jsx("div",{className:"mb-1 text-[9px] uppercase tracking-wider text-zinc-600",children:"Args"}),t.jsx("pre",{className:"mb-2 overflow-x-auto whitespace-pre-wrap break-all text-[10px] text-zinc-300",children:pb(e.args)}),!r&&e.result!==void 0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"mb-1 text-[9px] uppercase tracking-wider text-zinc-600",children:o?"Error":"Result"}),t.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-all text-[10px] text-zinc-300",children:pb(e.result)})]})]})]})}function pb(e){try{const s=typeof e=="string"?e:JSON.stringify(e,null,2);return s.length>2e3?`${s.slice(0,2e3)}
63
- … (${s.length-2e3} more chars)`:s}catch{return String(e)}}function AN({content:e}){return t.jsx("div",{className:"aero-markdown text-zinc-100",children:t.jsx(HS,{components:{h1:s=>t.jsx("h1",{...s,className:"mt-3 mb-2 text-base font-semibold text-zinc-50"}),h2:s=>t.jsx("h2",{...s,className:"mt-3 mb-2 text-sm font-semibold text-zinc-50"}),h3:s=>t.jsx("h3",{...s,className:"mt-3 mb-1.5 text-sm font-semibold text-zinc-100"}),h4:s=>t.jsx("h4",{...s,className:"mt-2 mb-1 text-xs font-semibold uppercase tracking-wide text-zinc-300"}),p:s=>t.jsx("p",{...s,className:"mb-2 leading-relaxed"}),ul:s=>t.jsx("ul",{...s,className:"mb-2 ml-4 list-disc space-y-1"}),ol:s=>t.jsx("ol",{...s,className:"mb-2 ml-4 list-decimal space-y-1"}),li:s=>t.jsx("li",{...s,className:"marker:text-zinc-600"}),strong:s=>t.jsx("strong",{...s,className:"font-semibold text-zinc-50"}),em:s=>t.jsx("em",{...s,className:"text-zinc-200"}),code:({children:s,...i})=>t.jsx("code",{...i,className:"rounded bg-zinc-800/70 px-1 py-0.5 font-mono text-[12px] text-emerald-200",children:s}),pre:s=>t.jsx("pre",{...s,className:"mb-2 overflow-x-auto rounded-md border border-zinc-800 bg-zinc-900/70 p-3 font-mono text-xs text-zinc-200"}),a:s=>t.jsx("a",{...s,className:"text-emerald-400 underline decoration-emerald-700 hover:decoration-emerald-400",target:"_blank",rel:"noopener noreferrer"}),table:s=>t.jsx("div",{className:"mb-2 overflow-x-auto",children:t.jsx("table",{...s,className:"w-full border-collapse text-xs"})}),thead:s=>t.jsx("thead",{...s,className:"border-b border-zinc-800"}),th:s=>t.jsx("th",{...s,className:"px-2 py-1 text-left font-semibold text-zinc-300"}),tr:s=>t.jsx("tr",{...s,className:"border-b border-zinc-900"}),td:s=>t.jsx("td",{...s,className:"px-2 py-1 text-zinc-200"}),blockquote:s=>t.jsx("blockquote",{...s,className:"mb-2 border-l-2 border-zinc-700 pl-3 italic text-zinc-400"}),hr:()=>t.jsx("hr",{className:"my-3 border-zinc-800"})},children:e})})}function rL(){return t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[t.jsx("div",{className:"text-[10px] uppercase tracking-wider text-emerald-400",children:"Aero"}),t.jsxs("div",{className:"flex items-center gap-1","aria-label":"Aero is thinking",children:[t.jsx("span",{className:"aero-dot h-1.5 w-1.5 rounded-full bg-emerald-400/80"}),t.jsx("span",{className:"aero-dot aero-dot-2 h-1.5 w-1.5 rounded-full bg-emerald-400/60"}),t.jsx("span",{className:"aero-dot aero-dot-3 h-1.5 w-1.5 rounded-full bg-emerald-400/40"})]})]})}function lL(){const e=Yb(),s=/^\/projects\/([^/]+)/.exec(e.pathname),i=s?decodeURIComponent(s[1]):null,r=tn({...Bu({client:ae}),enabled:i!==null,staleTime:6e4});if(!i)return null;const o=r.data??[],u=o.find(d=>d.id===i)??o.find(d=>d.name===i);return u?t.jsx(Y6,{projectName:u.name},u.name):null}function to(e,s){e.invalidateQueries({predicate:i=>{const r=i.queryKey[0];return typeof r?._id=="string"&&r._id.startsWith(s)}})}function Ku(e,s,i){switch(e.invalidateQueries({queryKey:No({client:ae})}),e.invalidateQueries({queryKey:li({client:ae})}),s){case et["answer-visibility"]:case et["site-audit"]:case et["backlink-extract"]:return;case et["gsc-sync"]:case et["inspect-sitemap"]:to(e,"getApiV1ProjectsByNameGoogleGsc");return;case et["ga-sync"]:to(e,"getApiV1ProjectsByNameGa");return;case et["traffic-sync"]:to(e,"getApiV1ProjectsByNameGa"),to(e,"getApiV1ProjectsByNameTraffic");return;case et["bing-inspect"]:case et["bing-inspect-sitemap"]:to(e,"getApiV1ProjectsByNameBing");return;case et["aeo-discover-seed"]:case et["aeo-discover-probe"]:return;default:return s}}const gb=[{label:"GitHub",href:"https://github.com/AINYC/canonry",Icon:aA},{label:"Docs",href:"https://github.com/AINYC/canonry/tree/main/docs",Icon:qC},{label:"Changelog",href:"https://github.com/AINYC/canonry/releases",Icon:nA}],xb=e=>({label:e,state:"checking",detail:"Checking service health"}),oL={apiStatus:xb("API"),workerStatus:xb("Worker")};function cL(e){switch(e){case et["answer-visibility"]:return"Visibility sweep";case et["gsc-sync"]:return"GSC sync";case et["inspect-sitemap"]:return"Sitemap inspection";case et["ga-sync"]:return"GA sync";case et["traffic-sync"]:return"Traffic sync";case et["bing-inspect"]:return"Bing URL inspection";case et["bing-inspect-sitemap"]:return"Bing sitemap inspection";case et["site-audit"]:return"Site audit";case et["backlink-extract"]:return"Backlink extract";case et["aeo-discover-seed"]:return"Discovery (seed phase)";case et["aeo-discover-probe"]:return"Discovery (probe phase)"}}function uL(e){return e==="completed"?"positive":e==="partial"?"caution":"negative"}function dL(e){const s=cL(e.kind);return e.status==="completed"?`${s} completed`:e.status==="partial"?`${s} completed with partial results`:e.status==="cancelled"?`${s} cancelled`:`${s} failed`}function mL(e,s){return e.error?`${s}: ${Rf(e.error)}`:e.location?`${s} · ${e.location}`:s}function hL(e,s,i){if(s)return s;const r=i.find(o=>o.id===e);return r?.displayName||r?.name||e}function fL(e,s){return[e.completed>0?`${e.completed} completed`:null,e.partial>0?`${e.partial} partial`:null,e.failed>0?`${e.failed} failed`:null,e.cancelled>0?`${e.cancelled} cancelled`:null,s>0?`${s} skipped at queue time`:null].filter(Boolean).join(", ")}function pL(e){return e.failed>0||e.cancelled>0?"negative":e.partial>0?"caution":"positive"}function gL(){const e=wn(),s=j.useSyncExternalStore(sR,Mi,Mi),i=Object.keys(s.runs).length>0||Object.keys(s.batches).length>0,r=tn({...Hj({client:ae}),enabled:i,staleTime:Kh,refetchInterval:3e3}),o=tn({...Bu({client:ae}),enabled:i}),u=j.useRef({}),d=j.useCallback(()=>{r.refetch()},[r.refetch]);return j.useEffect(()=>{i&&d()},[i,d]),j.useEffect(()=>{if(!i||typeof window>"u")return;const h=()=>{document.visibilityState==="visible"&&d()};return window.addEventListener("focus",d),document.addEventListener("visibilitychange",h),()=>{window.removeEventListener("focus",d),document.removeEventListener("visibilitychange",h)}},[i,d]),j.useEffect(()=>{const h=r.data??[],p=o.data??[],x=Object.fromEntries(h.map(v=>[v.id,v])),b=Object.fromEntries(h.map(v=>[v.id,v.status]));for(const v of Object.values(s.runs)){const N=x[v.runId];if(!N||!Hf(N.status)||(u.current[N.id]??v.lastAnnouncedStatus)===N.status)continue;const T=p.find(A=>A.id===N.projectId);if(T&&Ku(e,N.kind,T.name),v.sourceAction==="run-all"){Jy(N.id);continue}const w=hL(N.projectId,v.projectLabel,p);Qe({title:dL(N),detail:mL(N,w),tone:uL(N.status),dedupeKey:`run:${N.id}`,dedupeMode:"replace",cta:{label:"View run",intent:"open-run-drawer",runId:N.id}}),Jy(N.id)}for(const v of Object.values(s.batches)){const N=rR(v.runIds,x);N.finished&&(Qe({title:"Run-all batch finished",detail:fL(N,v.skippedCount),tone:pL(N),dedupeKey:`batch:${v.batchId}`,dedupeMode:"replace",cta:{label:"View runs",intent:"go-to-runs"}}),iR(v.batchId))}u.current=b},[o.data,r.data,s,e]),null}function xL(){const e=wo(),{dashboard:s,isLoading:i,refetch:r}=Pi(),d=Hu(!e,e?.health).data??e?.health??oL,h=Yb(),{runId:p,evidenceId:x,closeDrawer:b}=tl(),[v,N]=j.useState(!1),[z,T]=j.useState(()=>{if(typeof window>"u")return null;try{return window.localStorage.getItem("canonry:dismissedUpdateVersion")}catch{return null}}),[w]=j.useState(()=>typeof window>"u"?null:new URLSearchParams(window.location.search).get("force-update")),A=w?{current:d.apiStatus.version??"0.0.0",latest:w,url:"https://www.npmjs.com/package/@ainyc/canonry",upgradeCommand:"npm install -g @ainyc/canonry"}:d.apiStatus.updateAvailable,D=A&&A.latest!==z,U=()=>{if(A){try{window.localStorage.setItem("canonry:dismissedUpdateVersion",A.latest)}catch{}T(A.latest)}},I=U6(p),C=I.data??null,L=I.isLoading;j.useEffect(()=>{C&&C.status!=="running"&&C.status!=="queued"&&r()},[C?.status,r]),j.useEffect(()=>{N(!1)},[h.pathname]),j.useEffect(()=>{if(typeof window>"u"||!p&&!x)return;const P=ie=>{ie.key==="Escape"&&b()};return window.addEventListener("keydown",P),()=>{window.removeEventListener("keydown",P)}},[p,x,b]);const M=s??e?.dashboard??null,_=h.pathname==="/setup"&&M!==null&&M.portfolioOverview.projects.length===0,B=p&&M?f6(M,p):void 0,J=x&&M?p6(M,x):void 0,ue=(()=>{const P=h.pathname;if(P==="/")return"Portfolio";if(P==="/projects")return"Projects";if(P==="/runs")return"Runs";if(P==="/settings")return"Settings";if(P==="/setup")return"Setup";if(P==="/backlinks")return"Backlinks";if(P==="/traffic"||P.startsWith("/traffic/"))return"Server traffic";if(P.startsWith("/projects/")){const te=P.split("/").filter(Boolean)[1];if(te&&M){const ze=M.projects.find(ve=>ve.project.id===te);if(ze)return ze.project.name}return"Project"}return"Not found"})();return t.jsxs("div",{className:`app-shell ${_?"app-shell-focus":""}`,children:[t.jsx("a",{className:"skip-link",href:"#content",children:"Skip to content"}),!_&&t.jsxs("aside",{className:"sidebar","aria-label":"Primary navigation",children:[t.jsx("div",{className:"sidebar-brand",children:t.jsx(lb,{version:d.apiStatus.version,updateAvailable:D?A:null,onDismissUpdate:U})}),t.jsxs("nav",{className:"sidebar-nav",children:[t.jsxs(ft,{to:"/",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[t.jsx(lA,{className:"sidebar-icon"}),t.jsx("span",{children:"Overview"})]}),t.jsxs(ft,{to:"/projects",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!1},children:[t.jsx(Ev,{className:"sidebar-icon"}),t.jsx("span",{children:"Projects"})]}),t.jsxs(ft,{to:"/runs",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[t.jsx(uo,{className:"sidebar-icon"}),t.jsx("span",{children:"Runs"})]}),t.jsxs(ft,{to:"/traffic",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!1},children:[t.jsx(jA,{className:"sidebar-icon"}),t.jsx("span",{children:"Server traffic"})]}),t.jsxs(ft,{to:"/backlinks",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[t.jsx(Dv,{className:"sidebar-icon"}),t.jsx("span",{children:"Backlinks"})]}),t.jsxs(ft,{to:"/settings",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[t.jsx(CA,{className:"sidebar-icon"}),t.jsx("span",{children:"Settings"})]}),i?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"sidebar-section-title",children:"Projects"}),[1,2,3].map(P=>t.jsxs("div",{className:"sidebar-skeleton-item",children:[t.jsx("span",{className:"skeleton-circle size-2"}),t.jsx("span",{className:"skeleton-text flex-1",style:{width:`${50+P*15}%`}})]},P))]}):M&&M.projects.length>0?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"sidebar-section-title",children:"Projects"}),M.projects.map(P=>{const ie=P.visibilitySummary.tone;return t.jsxs(ft,{to:"/projects/$projectId",params:{projectId:P.project.id},className:"sidebar-project",activeProps:{className:"sidebar-project sidebar-project-active"},children:[t.jsx("span",{className:`sidebar-dot sidebar-dot-${ie}`}),t.jsx("span",{children:P.project.displayName||P.project.name})]},P.project.id)})]}):i?null:t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"sidebar-section-title",children:"Resources"}),t.jsxs(ft,{to:"/setup",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[t.jsx(SA,{className:"sidebar-icon"}),t.jsx("span",{children:"Setup"})]})]})]}),t.jsx("div",{className:"sidebar-footer",children:gb.map(({label:P,href:ie,Icon:te})=>t.jsx("a",{className:"sidebar-footer-icon",href:ie,target:"_blank",rel:"noopener noreferrer",title:P,"aria-label":P,children:t.jsx(te,{className:"size-4"})},ie))})]}),t.jsxs("div",{className:"main-area",children:[t.jsxs("header",{className:"topbar",children:[t.jsxs("div",{className:"topbar-left",children:[t.jsx("div",{className:"topbar-brand-mobile",children:t.jsx(lb,{compact:!0})}),t.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[t.jsx(ft,{to:"/",children:"Home"}),t.jsx(jo,{className:"breadcrumb-sep size-3"}),t.jsx("span",{className:"breadcrumb-current",children:ue})]})]}),t.jsxs("div",{className:"topbar-actions",children:[t.jsxs("div",{className:"health-pill-row",children:[t.jsxs("span",{className:`health-pill health-pill-${d.apiStatus.state}`,title:ai(d.apiStatus),children:["API ",d.apiStatus.state==="ok"?"ok":d.apiStatus.state]}),t.jsxs("span",{className:`health-pill health-pill-${d.workerStatus.state}`,title:ai(d.workerStatus),children:["Worker ",d.workerStatus.state==="ok"?"ok":d.workerStatus.state]})]}),t.jsxs(ee,{className:"nav-toggle",variant:"secondary",size:"icon",type:"button","aria-expanded":v,"aria-controls":"mobile-nav",onClick:()=>N(P=>!P),children:[t.jsx(hA,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:"Open navigation"})]})]})]}),t.jsxs("div",{id:"mobile-nav",className:`mobile-nav ${v?"mobile-nav-open":""}`,children:[t.jsxs(ee,{className:"mobile-nav-close",variant:"ghost",size:"icon",type:"button",onClick:()=>N(!1),children:[t.jsx(qi,{className:"size-5"}),t.jsx("span",{className:"sr-only",children:"Close navigation"})]}),t.jsx(ft,{to:"/",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Overview"}),t.jsx(ft,{to:"/projects",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!1},children:"Projects"}),t.jsx(ft,{to:"/runs",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Runs"}),t.jsx(ft,{to:"/traffic",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!1},children:"Server traffic"}),t.jsx(ft,{to:"/settings",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Settings"}),M&&M.projects.length>0?t.jsxs("div",{className:"mobile-nav-section",children:[t.jsx("p",{className:"mobile-nav-section-title",children:"Projects"}),M.projects.map(P=>t.jsx(ft,{to:"/projects/$projectId",params:{projectId:P.project.id},className:"mobile-nav-link",children:P.project.name},P.project.id))]}):null]}),t.jsx("main",{id:"content",className:"page-shell",children:i&&!e?t.jsxs("div",{className:"page-skeleton",children:[t.jsxs("div",{className:"page-skeleton-header",children:[t.jsx("div",{className:"skeleton-text h-6 w-40"}),t.jsx("div",{className:"skeleton-text-sm w-72"})]}),t.jsx("div",{className:"page-skeleton-grid",children:[1,2,3].map(P=>t.jsxs("div",{className:"page-skeleton-card",children:[t.jsx("div",{className:"skeleton-text w-24"}),t.jsx("div",{className:"skeleton-text w-full"}),t.jsx("div",{className:"skeleton-text-sm w-3/4"})]},P))}),t.jsx("div",{className:"page-skeleton-grid",style:{gridTemplateColumns:"1fr 1fr"},children:[1,2].map(P=>t.jsxs("div",{className:"page-skeleton-card",children:[t.jsx("div",{className:"skeleton-text w-20"}),t.jsx("div",{className:"space-y-2",children:[1,2,3].map(ie=>t.jsx("div",{className:"skeleton-text-sm w-full"},ie))})]},P))})]}):t.jsx(Xb,{})}),t.jsxs("footer",{className:"footer",children:[t.jsxs("span",{className:"footer-brand",children:[t.jsx("span",{children:t.jsx("a",{href:"https://canonry.ai",children:"Canonry"})}),d.apiStatus.version&&d.apiStatus.version!=="unknown"?t.jsxs("span",{className:"footer-version",children:["v",d.apiStatus.version]}):null]}),t.jsx("div",{className:"footer-links",children:gb.map(({label:P,href:ie,Icon:te})=>t.jsx("a",{href:ie,target:"_blank",rel:"noopener noreferrer",title:P,"aria-label":P,className:"footer-icon",children:t.jsx(te,{className:"size-3.5"})},ie))})]})]}),B?t.jsxs(s6,{open:!0,title:B.summary,subtitle:`${B.projectName} · ${B.kindLabel}`,onClose:b,children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-1 text-sm",children:[t.jsx(Uu,{status:B.status}),t.jsx("span",{className:"text-zinc-400",children:B.startedAt}),t.jsx("span",{className:"text-zinc-500",children:B.duration}),t.jsx("span",{className:"text-zinc-600",children:B.triggerLabel})]}),B.status==="failed"&&B.statusDetail&&t.jsx("p",{className:"text-sm text-rose-300/80 mt-2",children:B.statusDetail}),t.jsxs("div",{className:"mt-4",children:[t.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-zinc-500 mb-2",children:"Activity Log"}),L?t.jsx("p",{className:"text-sm text-zinc-500",children:"Loading run details..."}):C?.snapshots&&C.snapshots.length>0?t.jsxs("div",{className:"space-y-2",children:[C.snapshots.map(P=>t.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/30 p-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[t.jsx("p",{className:"text-sm font-medium text-zinc-200 truncate",children:P.query??"Unknown query"}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx($i,{provider:P.provider}),t.jsx(bN,{variant:P.citationState===po.cited?"success":"neutral",children:P.citationState})]})]}),P.model&&t.jsx("p",{className:"text-[11px] text-zinc-500 font-mono",children:P.model}),P.citedDomains.length>0&&t.jsxs("p",{className:"text-xs text-zinc-500 mt-1",children:[t.jsx("span",{className:"text-zinc-400",children:"Sources:"})," ",P.citedDomains.join(", ")]}),P.competitorOverlap.length>0&&t.jsxs("p",{className:"text-xs text-rose-400/80 mt-0.5",children:["Competitor cited: ",P.competitorOverlap.join(", ")]}),P.groundingSources&&P.groundingSources.length>0&&t.jsxs("details",{className:"mt-2",children:[t.jsxs("summary",{className:"text-xs text-zinc-500 cursor-pointer hover:text-zinc-400",children:[P.groundingSources.length," grounding source",P.groundingSources.length!==1?"s":""]}),t.jsx("ul",{className:"mt-1 space-y-0.5",children:P.groundingSources.map((ie,te)=>t.jsx("li",{className:"text-xs text-zinc-500 truncate",children:t.jsx("a",{href:ie.uri,target:"_blank",rel:"noopener noreferrer",className:"hover:text-zinc-300",children:ie.title||ie.uri})},te))})]}),P.answerText&&t.jsxs("details",{className:"mt-1",children:[t.jsx("summary",{className:"text-xs text-zinc-500 cursor-pointer hover:text-zinc-400",children:"Answer preview"}),t.jsx("p",{className:"mt-1 text-xs text-zinc-400 leading-relaxed whitespace-pre-wrap",children:P.answerText})]})]},P.id)),C.status==="running"&&t.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-zinc-500",children:[t.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-amber-500 animate-pulse"}),"Running remaining queries..."]})]}):C&&C.status==="running"?t.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-zinc-500",children:[t.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-amber-500 animate-pulse"}),"Waiting for first query result..."]}):C&&C.status==="queued"?t.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-zinc-500",children:[t.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-zinc-500 animate-pulse"}),"Run queued, waiting for execution slot..."]}):C&&C.error?t.jsxs("div",{className:"rounded-lg border border-rose-800/40 bg-rose-950/20 p-3",children:[t.jsx("p",{className:"text-sm font-medium text-rose-300 mb-2",children:"Run failed"}),t.jsx("pre",{className:"text-xs text-rose-300/80 whitespace-pre-wrap break-words max-h-48 overflow-y-auto font-mono leading-5",children:HD(C.error)})]}):t.jsx("p",{className:"text-sm text-zinc-500",children:"No snapshot data available."})]})]}):null,J?t.jsx(l6,{evidence:J.evidence,project:J.project,onClose:b}):null,t.jsx(gL,{}),t.jsx(V6,{}),t.jsx(lL,{})]})}class yL extends j.Component{state={error:null};static getDerivedStateFromError(s){return{error:s}}componentDidCatch(s,i){console.error("[ErrorBoundary]",s,i.componentStack)}handleReset=()=>{this.setState({error:null})};render(){return this.state.error?t.jsx("div",{className:"page-container",children:t.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 py-20 text-center",children:[t.jsx("div",{className:"rounded-full bg-rose-950/40 p-3",children:t.jsx(gu,{className:"size-6 text-rose-400"})}),t.jsx("h2",{className:"text-lg font-semibold text-zinc-100",children:"Something went wrong"}),t.jsx("p",{className:"text-sm text-zinc-400 max-w-md",children:this.state.error.message||"An unexpected error occurred while rendering this page."}),t.jsxs("div",{className:"flex gap-3 mt-2",children:[t.jsxs(ee,{variant:"secondary",size:"sm",onClick:this.handleReset,children:[t.jsx(Rv,{className:"size-3.5 mr-1.5"}),"Try again"]}),t.jsx(ee,{variant:"secondary",size:"sm",onClick:()=>{const s=window.__CANONRY_CONFIG__?.basePath?.replace(/\/$/,"")??"";window.location.href=s||"/"},children:"Go home"})]})]})}):this.props.children}}const Se=j.forwardRef(({className:e,...s},i)=>t.jsx("div",{ref:i,className:Ns("rounded-xl border border-zinc-800 bg-zinc-950/75 shadow-[0_0_0_1px_rgba(255,255,255,0.01)] backdrop-blur",e),...s}));Se.displayName="Card";const sf=j.forwardRef(({className:e,...s},i)=>t.jsx("div",{ref:i,className:Ns("flex flex-col gap-1.5 p-5",e),...s}));sf.displayName="CardHeader";const af=j.forwardRef(({className:e,...s},i)=>t.jsx("h3",{ref:i,className:Ns("font-medium tracking-tight text-zinc-50",e),...s}));af.displayName="CardTitle";const rf=j.forwardRef(({className:e,...s},i)=>t.jsx("p",{ref:i,className:Ns("text-sm text-zinc-500",e),...s}));rf.displayName="CardDescription";const iu=j.forwardRef(({className:e,...s},i)=>t.jsx("div",{ref:i,className:Ns("p-5 pt-0",e),...s}));iu.displayName="CardContent";function bL({points:e,tone:s}){const i=j.useId();if(e.length===0)return null;const r=42,o=132,u=5,d=Math.min(...e),p=Math.max(...e)-d||1,x=o-u*2,b=r-u*2,v=e.map((N,z)=>{const T=u+z/Math.max(e.length-1,1)*x,w=u+(1-(N-d)/p)*b;return`${T},${w}`}).join(" ");return t.jsxs("svg",{className:`sparkline sparkline-${s}`,viewBox:`0 0 ${o} ${r}`,"aria-hidden":"true",children:[t.jsx("defs",{children:t.jsx("clipPath",{id:i,children:t.jsx("rect",{x:u,y:u,width:x,height:b,rx:"8"})})}),t.jsx("line",{className:"sparkline-guide",x1:u,x2:o-u,y1:r-u,y2:r-u}),t.jsx("polyline",{clipPath:`url(#${i})`,points:v,vectorEffect:"non-scaling-stroke"})]})}function vL({project:e}){return t.jsxs(ft,{to:"/projects/$projectId",params:{projectId:e.project.id},className:"project-row cursor-pointer",children:[t.jsxs("div",{className:"project-row-primary",children:[t.jsxs("div",{children:[t.jsx("p",{className:"project-name",children:e.project.name}),t.jsx("p",{className:"project-domain",children:e.project.canonicalDomain})]}),t.jsx("p",{className:"project-insight",children:e.insight})]}),t.jsx("div",{className:"project-row-stat",children:t.jsxs("div",{className:"metric-inline-block",children:[t.jsx("p",{className:"metric-inline-label",children:"Answer Visibility"}),t.jsx("p",{className:`metric-inline-value ${e.visibilityTone==="caution"?"text-amber-400":""}`,children:e.visibilityScore}),t.jsx("p",{className:"metric-inline-delta",children:e.visibilityDelta}),e.providerCoverage&&t.jsx("p",{className:"text-[10px] font-medium text-amber-400/80",children:e.providerCoverage})]})}),t.jsx("div",{className:"project-row-stat",children:t.jsxs("div",{className:"metric-inline-block",children:[t.jsx("p",{className:"metric-inline-label",children:"Competitor Pressure"}),t.jsx("p",{className:"metric-inline-value",children:e.competitorPressureLabel}),t.jsxs("p",{className:"metric-inline-delta",children:[e.lastRun.kindLabel," · ",$u(e.lastRun.status)]})]})}),t.jsx("div",{className:"project-row-chart",children:t.jsx(bL,{points:e.trend,tone:eN(e.lastRun.status)})}),t.jsx("span",{className:"project-row-link",children:t.jsx(jo,{className:"h-4 w-4 text-zinc-500"})})]})}function jL(){const e=wo(),{dashboard:s,isLoading:i}=Pi(),r=s??e?.dashboard;if(!r||i)return t.jsxs("div",{className:"page-skeleton",children:[t.jsxs("div",{className:"page-skeleton-header",children:[t.jsx("div",{className:"skeleton-text h-6 w-32"}),t.jsx("div",{className:"skeleton-text-sm w-64"})]}),t.jsx("div",{className:"space-y-3",children:[1,2,3].map(b=>t.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 p-4 flex items-center gap-4",children:[t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx("div",{className:"skeleton-text w-36"}),t.jsx("div",{className:"skeleton-text-sm w-48"})]}),t.jsx("div",{className:"skeleton-text w-16"}),t.jsx("div",{className:"skeleton-text w-16"}),t.jsx("div",{className:"skeleton h-8 w-20 rounded"})]},b))})]});const o=r.portfolioOverview,h=Hu(!e,e?.health).data??e?.health??{apiStatus:{label:"API",state:"checking",detail:"Checking service health"},workerStatus:{label:"Worker",state:"checking",detail:"Checking service health"}},p=YO(o.systemHealth,h,r.settings),{openRun:x}=tl();return t.jsxs("div",{className:"page-container",children:[t.jsxs("div",{className:"page-header",children:[t.jsxs("div",{className:"page-header-left",children:[t.jsx("h1",{className:"page-title",children:"Portfolio"}),t.jsx("p",{className:"page-subtitle",children:"Visibility and execution state across all projects"})]}),t.jsx("div",{className:"page-header-right",children:t.jsx("p",{className:"text-[11px] text-zinc-600",children:o.lastUpdatedAt})})]}),o.projects.length>0?t.jsx("div",{className:"project-list project-list-scrollable",children:o.projects.map(b=>t.jsx(vL,{project:b},b.project.id))}):t.jsxs(Se,{className:"surface-card empty-card",children:[t.jsx("h3",{children:o.emptyState?.title??"No projects yet"}),t.jsx("p",{className:"supporting-copy",children:o.emptyState?.detail}),t.jsx(ee,{size:"sm",asChild:!0,children:t.jsx(ft,{to:o.emptyState?.ctaHref==="/setup"||!o.emptyState?.ctaHref?"/setup":"/",children:o.emptyState?.ctaLabel??"Launch setup"})})]}),t.jsxs("div",{className:"overview-secondary-grid",children:[o.attentionItems.length>0&&t.jsxs("section",{className:"overview-secondary-section",children:[t.jsx("div",{className:"section-head section-head-inline",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Needs attention"}),t.jsx("h2",{className:"section-title-sm",children:"What changed"})]})}),t.jsx("div",{className:"attention-list attention-list-scrollable",children:o.attentionItems.map(b=>t.jsxs(ft,{to:b.href,className:`attention-item attention-item-${b.tone}`,children:[t.jsxs("div",{children:[t.jsx("p",{className:"attention-title",children:b.title}),t.jsx("p",{className:"attention-detail",children:b.detail})]}),t.jsx("span",{className:"attention-action",children:b.actionLabel})]},b.id))})]}),t.jsxs("section",{className:"overview-secondary-section",children:[t.jsx("div",{className:"section-head section-head-inline",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Recent runs"}),t.jsx("h2",{className:"section-title-sm",children:"Activity"})]})}),t.jsx("div",{className:"compact-stack compact-stack-scrollable",children:o.recentRuns.length>0?o.recentRuns.map(b=>t.jsxs("button",{className:"compact-run",type:"button",onClick:()=>x(b.id),children:[t.jsxs("div",{children:[t.jsx("p",{className:"compact-run-title",children:b.projectName}),t.jsx("p",{className:"compact-run-detail",children:b.summary})]}),t.jsx(Uu,{status:b.status})]},b.id)):t.jsx("p",{className:"supporting-copy",children:"Run history appears here after the first launch."})})]})]}),t.jsxs("section",{className:"page-section",children:[t.jsx("div",{className:"section-head section-head-inline",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"System health"}),t.jsx("h2",{className:"section-title-sm",children:"Infrastructure"})]})}),t.jsx("div",{className:"health-grid",children:p.map(b=>t.jsxs(Se,{className:"surface-card compact-card",children:[t.jsxs("div",{className:"section-head",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:b.label}),t.jsx("h3",{children:b.detail})]}),t.jsx(Ke,{tone:b.tone,title:b.id==="api"?ai(h.apiStatus):b.id==="worker"?ai(h.workerStatus):void 0,children:b.label})]}),t.jsx("p",{className:"supporting-copy",children:b.meta})]},b.id))})]})]})}const ep=Symbol.for("yaml.alias"),lf=Symbol.for("yaml.document"),ti=Symbol.for("yaml.map"),TN=Symbol.for("yaml.pair"),Vs=Symbol.for("yaml.scalar"),nl=Symbol.for("yaml.seq"),vs=Symbol.for("yaml.node.type"),Gi=e=>!!e&&typeof e=="object"&&e[vs]===ep,Qu=e=>!!e&&typeof e=="object"&&e[vs]===lf,So=e=>!!e&&typeof e=="object"&&e[vs]===ti,Qt=e=>!!e&&typeof e=="object"&&e[vs]===TN,Et=e=>!!e&&typeof e=="object"&&e[vs]===Vs,zo=e=>!!e&&typeof e=="object"&&e[vs]===nl;function Ht(e){if(e&&typeof e=="object")switch(e[vs]){case ti:case nl:return!0}return!1}function Kt(e){if(e&&typeof e=="object")switch(e[vs]){case ep:case ti:case Vs:case nl:return!0}return!1}const _N=e=>(Et(e)||Ht(e))&&!!e.anchor,Ei=Symbol("break visit"),NL=Symbol("skip children"),oo=Symbol("remove node");function sl(e,s){const i=wL(s);Qu(e)?Or(null,e.contents,i,Object.freeze([e]))===oo&&(e.contents=null):Or(null,e,i,Object.freeze([]))}sl.BREAK=Ei;sl.SKIP=NL;sl.REMOVE=oo;function Or(e,s,i,r){const o=SL(e,s,i,r);if(Kt(o)||Qt(o))return zL(e,r,o),Or(e,o,i,r);if(typeof o!="symbol"){if(Ht(s)){r=Object.freeze(r.concat(s));for(let u=0;u<s.items.length;++u){const d=Or(u,s.items[u],i,r);if(typeof d=="number")u=d-1;else{if(d===Ei)return Ei;d===oo&&(s.items.splice(u,1),u-=1)}}}else if(Qt(s)){r=Object.freeze(r.concat(s));const u=Or("key",s.key,i,r);if(u===Ei)return Ei;u===oo&&(s.key=null);const d=Or("value",s.value,i,r);if(d===Ei)return Ei;d===oo&&(s.value=null)}}return o}function wL(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function SL(e,s,i,r){if(typeof i=="function")return i(e,s,r);if(So(s))return i.Map?.(e,s,r);if(zo(s))return i.Seq?.(e,s,r);if(Qt(s))return i.Pair?.(e,s,r);if(Et(s))return i.Scalar?.(e,s,r);if(Gi(s))return i.Alias?.(e,s,r)}function zL(e,s,i){const r=s[s.length-1];if(Ht(r))r.items[e]=i;else if(Qt(r))e==="key"?r.key=i:r.value=i;else if(Qu(r))r.contents=i;else{const o=Gi(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${o} parent`)}}const kL={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},CL=e=>e.replace(/[!,[\]{}]/g,s=>kL[s]);class Ln{constructor(s,i){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},Ln.defaultYaml,s),this.tags=Object.assign({},Ln.defaultTags,i)}clone(){const s=new Ln(this.yaml,this.tags);return s.docStart=this.docStart,s}atDocument(){const s=new Ln(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:Ln.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},Ln.defaultTags);break}return s}add(s,i){this.atNextDocument&&(this.yaml={explicit:Ln.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},Ln.defaultTags),this.atNextDocument=!1);const r=s.trim().split(/[ \t]+/),o=r.shift();switch(o){case"%TAG":{if(r.length!==2&&(i(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;const[u,d]=r;return this.tags[u]=d,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return i(0,"%YAML directive should contain exactly one part"),!1;const[u]=r;if(u==="1.1"||u==="1.2")return this.yaml.version=u,!0;{const d=/^\d+\.\d+$/.test(u);return i(6,`Unsupported YAML version ${u}`,d),!1}}default:return i(0,`Unknown directive ${o}`,!0),!1}}tagName(s,i){if(s==="!")return"!";if(s[0]!=="!")return i(`Not a valid tag: ${s}`),null;if(s[1]==="<"){const d=s.slice(2,-1);return d==="!"||d==="!!"?(i(`Verbatim tags aren't resolved, so ${s} is invalid.`),null):(s[s.length-1]!==">"&&i("Verbatim tags must end with a >"),d)}const[,r,o]=s.match(/^(.*!)([^!]*)$/s);o||i(`The ${s} tag has no suffix`);const u=this.tags[r];if(u)try{return u+decodeURIComponent(o)}catch(d){return i(String(d)),null}return r==="!"?s:(i(`Could not resolve tag: ${s}`),null)}tagString(s){for(const[i,r]of Object.entries(this.tags))if(s.startsWith(r))return i+CL(s.substring(r.length));return s[0]==="!"?s:`!<${s}>`}toString(s){const i=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags);let o;if(s&&r.length>0&&Kt(s.contents)){const u={};sl(s.contents,(d,h)=>{Kt(h)&&h.tag&&(u[h.tag]=!0)}),o=Object.keys(u)}else o=[];for(const[u,d]of r)u==="!!"&&d==="tag:yaml.org,2002:"||(!s||o.some(h=>h.startsWith(d)))&&i.push(`%TAG ${u} ${d}`);return i.join(`
64
- `)}}Ln.defaultYaml={explicit:!1,version:"1.2"};Ln.defaultTags={"!!":"tag:yaml.org,2002:"};function EN(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){const i=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(i)}return!0}function DN(e){const s=new Set;return sl(e,{Value(i,r){r.anchor&&s.add(r.anchor)}}),s}function ON(e,s){for(let i=1;;++i){const r=`${e}${i}`;if(!s.has(r))return r}}function AL(e,s){const i=[],r=new Map;let o=null;return{onAnchor:u=>{i.push(u),o??(o=DN(e));const d=ON(s,o);return o.add(d),d},setAnchors:()=>{for(const u of i){const d=r.get(u);if(typeof d=="object"&&d.anchor&&(Et(d.node)||Ht(d.node)))d.node.anchor=d.anchor;else{const h=new Error("Failed to resolve repeated object (this should not happen)");throw h.source=u,h}}},sourceObjects:r}}function Rr(e,s,i,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let o=0,u=r.length;o<u;++o){const d=r[o],h=Rr(e,r,String(o),d);h===void 0?delete r[o]:h!==d&&(r[o]=h)}else if(r instanceof Map)for(const o of Array.from(r.keys())){const u=r.get(o),d=Rr(e,r,o,u);d===void 0?r.delete(o):d!==u&&r.set(o,d)}else if(r instanceof Set)for(const o of Array.from(r)){const u=Rr(e,r,o,o);u===void 0?r.delete(o):u!==o&&(r.delete(o),r.add(u))}else for(const[o,u]of Object.entries(r)){const d=Rr(e,r,o,u);d===void 0?delete r[o]:d!==u&&(r[o]=d)}return e.call(s,i,r)}function ys(e,s,i){if(Array.isArray(e))return e.map((r,o)=>ys(r,String(o),i));if(e&&typeof e.toJSON=="function"){if(!i||!_N(e))return e.toJSON(s,i);const r={aliasCount:0,count:1,res:void 0};i.anchors.set(e,r),i.onCreate=u=>{r.res=u,delete i.onCreate};const o=e.toJSON(s,i);return i.onCreate&&i.onCreate(o),o}return typeof e=="bigint"&&!i?.keep?Number(e):e}class tp{constructor(s){Object.defineProperty(this,vs,{value:s})}clone(){const s=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(s.range=this.range.slice()),s}toJS(s,{mapAsMap:i,maxAliasCount:r,onAnchor:o,reviver:u}={}){if(!Qu(s))throw new TypeError("A document argument is required");const d={anchors:new Map,doc:s,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},h=ys(this,"",d);if(typeof o=="function")for(const{count:p,res:x}of d.anchors.values())o(x,p);return typeof u=="function"?Rr(u,{"":h},"",h):h}}class np extends tp{constructor(s){super(ep),this.source=s,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(s,i){let r;i?.aliasResolveCache?r=i.aliasResolveCache:(r=[],sl(s,{Node:(u,d)=>{(Gi(d)||_N(d))&&r.push(d)}}),i&&(i.aliasResolveCache=r));let o;for(const u of r){if(u===this)break;u.anchor===this.source&&(o=u)}return o}toJSON(s,i){if(!i)return{source:this.source};const{anchors:r,doc:o,maxAliasCount:u}=i,d=this.resolve(o,i);if(!d){const p=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(p)}let h=r.get(d);if(h||(ys(d,null,i),h=r.get(d)),h?.res===void 0){const p="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(p)}if(u>=0&&(h.count+=1,h.aliasCount===0&&(h.aliasCount=ru(o,d,r)),h.count*h.aliasCount>u)){const p="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(p)}return h.res}toString(s,i,r){const o=`*${this.source}`;if(s){if(EN(this.source),s.options.verifyAliasOrder&&!s.anchors.has(this.source)){const u=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(u)}if(s.implicitKey)return`${o} `}return o}}function ru(e,s,i){if(Gi(s)){const r=s.resolve(e),o=i&&r&&i.get(r);return o?o.count*o.aliasCount:0}else if(Ht(s)){let r=0;for(const o of s.items){const u=ru(e,o,i);u>r&&(r=u)}return r}else if(Qt(s)){const r=ru(e,s.key,i),o=ru(e,s.value,i);return Math.max(r,o)}return 1}const RN=e=>!e||typeof e!="function"&&typeof e!="object";class Ze extends tp{constructor(s){super(Vs),this.value=s}toJSON(s,i){return i?.keep?this.value:ys(this.value,s,i)}toString(){return String(this.value)}}Ze.BLOCK_FOLDED="BLOCK_FOLDED";Ze.BLOCK_LITERAL="BLOCK_LITERAL";Ze.PLAIN="PLAIN";Ze.QUOTE_DOUBLE="QUOTE_DOUBLE";Ze.QUOTE_SINGLE="QUOTE_SINGLE";const TL="tag:yaml.org,2002:";function _L(e,s,i){if(s){const r=i.filter(u=>u.tag===s),o=r.find(u=>!u.format)??r[0];if(!o)throw new Error(`Tag ${s} not found`);return o}return i.find(r=>r.identify?.(e)&&!r.format)}function go(e,s,i){if(Qu(e)&&(e=e.contents),Kt(e))return e;if(Qt(e)){const v=i.schema[ti].createNode?.(i.schema,null,i);return v.items.push(e),v}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());const{aliasDuplicateObjects:r,onAnchor:o,onTagObj:u,schema:d,sourceObjects:h}=i;let p;if(r&&e&&typeof e=="object"){if(p=h.get(e),p)return p.anchor??(p.anchor=o(e)),new np(p.anchor);p={anchor:null,node:null},h.set(e,p)}s?.startsWith("!!")&&(s=TL+s.slice(2));let x=_L(e,s,d.tags);if(!x){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){const v=new Ze(e);return p&&(p.node=v),v}x=e instanceof Map?d[ti]:Symbol.iterator in Object(e)?d[nl]:d[ti]}u&&(u(x),delete i.onTagObj);const b=x?.createNode?x.createNode(i.schema,e,i):typeof x?.nodeClass?.from=="function"?x.nodeClass.from(i.schema,e,i):new Ze(e);return s?b.tag=s:x.default||(b.tag=x.tag),p&&(p.node=b),b}function ku(e,s,i){let r=i;for(let o=s.length-1;o>=0;--o){const u=s[o];if(typeof u=="number"&&Number.isInteger(u)&&u>=0){const d=[];d[u]=r,r=d}else r=new Map([[u,r]])}return go(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}const lo=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done;class LN extends tp{constructor(s,i){super(s),Object.defineProperty(this,"schema",{value:i,configurable:!0,enumerable:!1,writable:!0})}clone(s){const i=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return s&&(i.schema=s),i.items=i.items.map(r=>Kt(r)||Qt(r)?r.clone(s):r),this.range&&(i.range=this.range.slice()),i}addIn(s,i){if(lo(s))this.add(i);else{const[r,...o]=s,u=this.get(r,!0);if(Ht(u))u.addIn(o,i);else if(u===void 0&&this.schema)this.set(r,ku(this.schema,o,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${o}`)}}deleteIn(s){const[i,...r]=s;if(r.length===0)return this.delete(i);const o=this.get(i,!0);if(Ht(o))return o.deleteIn(r);throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}getIn(s,i){const[r,...o]=s,u=this.get(r,!0);return o.length===0?!i&&Et(u)?u.value:u:Ht(u)?u.getIn(o,i):void 0}hasAllNullValues(s){return this.items.every(i=>{if(!Qt(i))return!1;const r=i.value;return r==null||s&&Et(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(s){const[i,...r]=s;if(r.length===0)return this.has(i);const o=this.get(i,!0);return Ht(o)?o.hasIn(r):!1}setIn(s,i){const[r,...o]=s;if(o.length===0)this.set(r,i);else{const u=this.get(r,!0);if(Ht(u))u.setIn(o,i);else if(u===void 0&&this.schema)this.set(r,ku(this.schema,o,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${o}`)}}}const EL=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function ga(e,s){return/^\n+$/.test(e)?e.substring(1):s?e.replace(/^(?! *$)/gm,s):e}const Di=(e,s,i)=>e.endsWith(`
65
- `)?ga(i,s):i.includes(`
66
- `)?`
67
- `+ga(i,s):(e.endsWith(" ")?"":" ")+i,MN="flow",of="block",lu="quoted";function Zu(e,s,i="flow",{indentAtStart:r,lineWidth:o=80,minContentWidth:u=20,onFold:d,onOverflow:h}={}){if(!o||o<0)return e;o<u&&(u=0);const p=Math.max(1+u,1+o-s.length);if(e.length<=p)return e;const x=[],b={};let v=o-s.length;typeof r=="number"&&(r>o-Math.max(2,u)?x.push(0):v=o-r);let N,z,T=!1,w=-1,A=-1,D=-1;i===of&&(w=yb(e,w,s.length),w!==-1&&(v=w+p));for(let I;I=e[w+=1];){if(i===lu&&I==="\\"){switch(A=w,e[w+1]){case"x":w+=3;break;case"u":w+=5;break;case"U":w+=9;break;default:w+=1}D=w}if(I===`
68
- `)i===of&&(w=yb(e,w,s.length)),v=w+s.length+p,N=void 0;else{if(I===" "&&z&&z!==" "&&z!==`
69
- `&&z!==" "){const C=e[w+1];C&&C!==" "&&C!==`
70
- `&&C!==" "&&(N=w)}if(w>=v)if(N)x.push(N),v=N+p,N=void 0;else if(i===lu){for(;z===" "||z===" ";)z=I,I=e[w+=1],T=!0;const C=w>D+1?w-2:A-1;if(b[C])return e;x.push(C),b[C]=!0,v=C+p,N=void 0}else T=!0}z=I}if(T&&h&&h(),x.length===0)return e;d&&d();let U=e.slice(0,x[0]);for(let I=0;I<x.length;++I){const C=x[I],L=x[I+1]||e.length;C===0?U=`
71
- ${s}${e.slice(0,L)}`:(i===lu&&b[C]&&(U+=`${e[C]}\\`),U+=`
72
- ${s}${e.slice(C+1,L)}`)}return U}function yb(e,s,i){let r=s,o=s+1,u=e[o];for(;u===" "||u===" ";)if(s<o+i)u=e[++s];else{do u=e[++s];while(u&&u!==`
73
- `);r=s,o=s+1,u=e[o]}return r}const Fu=(e,s)=>({indentAtStart:s?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Yu=e=>/^(%|---|\.\.\.)/m.test(e);function DL(e,s,i){if(!s||s<0)return!1;const r=s-i,o=e.length;if(o<=r)return!1;for(let u=0,d=0;u<o;++u)if(e[u]===`
74
- `){if(u-d>r)return!0;if(d=u+1,o-d<=r)return!1}return!0}function co(e,s){const i=JSON.stringify(e);if(s.options.doubleQuotedAsJSON)return i;const{implicitKey:r}=s,o=s.options.doubleQuotedMinMultiLineLength,u=s.indent||(Yu(e)?" ":"");let d="",h=0;for(let p=0,x=i[p];x;x=i[++p])if(x===" "&&i[p+1]==="\\"&&i[p+2]==="n"&&(d+=i.slice(h,p)+"\\ ",p+=1,h=p,x="\\"),x==="\\")switch(i[p+1]){case"u":{d+=i.slice(h,p);const b=i.substr(p+2,4);switch(b){case"0000":d+="\\0";break;case"0007":d+="\\a";break;case"000b":d+="\\v";break;case"001b":d+="\\e";break;case"0085":d+="\\N";break;case"00a0":d+="\\_";break;case"2028":d+="\\L";break;case"2029":d+="\\P";break;default:b.substr(0,2)==="00"?d+="\\x"+b.substr(2):d+=i.substr(p,6)}p+=5,h=p+1}break;case"n":if(r||i[p+2]==='"'||i.length<o)p+=1;else{for(d+=i.slice(h,p)+`
75
-
76
- `;i[p+2]==="\\"&&i[p+3]==="n"&&i[p+4]!=='"';)d+=`
77
- `,p+=2;d+=u,i[p+2]===" "&&(d+="\\"),p+=1,h=p+1}break;default:p+=1}return d=h?d+i.slice(h):i,r?d:Zu(d,u,lu,Fu(s,!1))}function cf(e,s){if(s.options.singleQuote===!1||s.implicitKey&&e.includes(`
78
- `)||/[ \t]\n|\n[ \t]/.test(e))return co(e,s);const i=s.indent||(Yu(e)?" ":""),r="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
79
- ${i}`)+"'";return s.implicitKey?r:Zu(r,i,MN,Fu(s,!1))}function Lr(e,s){const{singleQuote:i}=s.options;let r;if(i===!1)r=co;else{const o=e.includes('"'),u=e.includes("'");o&&!u?r=cf:u&&!o?r=co:r=i?cf:co}return r(e,s)}let uf;try{uf=new RegExp(`(^|(?<!
80
- ))
81
- +(?!
82
- |$)`,"g")}catch{uf=/\n+(?!\n|$)/g}function ou({comment:e,type:s,value:i},r,o,u){const{blockQuote:d,commentString:h,lineWidth:p}=r.options;if(!d||/\n[\t ]+$/.test(i))return Lr(i,r);const x=r.indent||(r.forceBlockIndent||Yu(i)?" ":""),b=d==="literal"?!0:d==="folded"||s===Ze.BLOCK_FOLDED?!1:s===Ze.BLOCK_LITERAL?!0:!DL(i,p,x.length);if(!i)return b?`|
83
- `:`>
84
- `;let v,N;for(N=i.length;N>0;--N){const L=i[N-1];if(L!==`
85
- `&&L!==" "&&L!==" ")break}let z=i.substring(N);const T=z.indexOf(`
86
- `);T===-1?v="-":i===z||T!==z.length-1?(v="+",u&&u()):v="",z&&(i=i.slice(0,-z.length),z[z.length-1]===`
87
- `&&(z=z.slice(0,-1)),z=z.replace(uf,`$&${x}`));let w=!1,A,D=-1;for(A=0;A<i.length;++A){const L=i[A];if(L===" ")w=!0;else if(L===`
88
- `)D=A;else break}let U=i.substring(0,D<A?D+1:A);U&&(i=i.substring(U.length),U=U.replace(/\n+/g,`$&${x}`));let C=(w?x?"2":"1":"")+v;if(e&&(C+=" "+h(e.replace(/ ?[\r\n]+/g," ")),o&&o()),!b){const L=i.replace(/\n+/g,`
89
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${x}`);let M=!1;const _=Fu(r,!0);d!=="folded"&&s!==Ze.BLOCK_FOLDED&&(_.onOverflow=()=>{M=!0});const B=Zu(`${U}${L}${z}`,x,of,_);if(!M)return`>${C}
90
- ${x}${B}`}return i=i.replace(/\n+/g,`$&${x}`),`|${C}
91
- ${x}${U}${i}${z}`}function OL(e,s,i,r){const{type:o,value:u}=e,{actualString:d,implicitKey:h,indent:p,indentStep:x,inFlow:b}=s;if(h&&u.includes(`
92
- `)||b&&/[[\]{},]/.test(u))return Lr(u,s);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(u))return h||b||!u.includes(`
93
- `)?Lr(u,s):ou(e,s,i,r);if(!h&&!b&&o!==Ze.PLAIN&&u.includes(`
94
- `))return ou(e,s,i,r);if(Yu(u)){if(p==="")return s.forceBlockIndent=!0,ou(e,s,i,r);if(h&&p===x)return Lr(u,s)}const v=u.replace(/\n+/g,`$&
95
- ${p}`);if(d){const N=w=>w.default&&w.tag!=="tag:yaml.org,2002:str"&&w.test?.test(v),{compat:z,tags:T}=s.doc.schema;if(T.some(N)||z?.some(N))return Lr(u,s)}return h?v:Zu(v,p,MN,Fu(s,!1))}function sp(e,s,i,r){const{implicitKey:o,inFlow:u}=s,d=typeof e.value=="string"?e:Object.assign({},e,{value:String(e.value)});let{type:h}=e;h!==Ze.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(d.value)&&(h=Ze.QUOTE_DOUBLE);const p=b=>{switch(b){case Ze.BLOCK_FOLDED:case Ze.BLOCK_LITERAL:return o||u?Lr(d.value,s):ou(d,s,i,r);case Ze.QUOTE_DOUBLE:return co(d.value,s);case Ze.QUOTE_SINGLE:return cf(d.value,s);case Ze.PLAIN:return OL(d,s,i,r);default:return null}};let x=p(h);if(x===null){const{defaultKeyType:b,defaultStringType:v}=s.options,N=o&&b||v;if(x=p(N),x===null)throw new Error(`Unsupported default string type ${N}`)}return x}function $N(e,s){const i=Object.assign({blockQuote:!0,commentString:EL,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,s);let r;switch(i.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:i.flowCollectionPadding?" ":"",indent:"",indentStep:typeof i.indent=="number"?" ".repeat(i.indent):" ",inFlow:r,options:i}}function RL(e,s){if(s.tag){const o=e.filter(u=>u.tag===s.tag);if(o.length>0)return o.find(u=>u.format===s.format)??o[0]}let i,r;if(Et(s)){r=s.value;let o=e.filter(u=>u.identify?.(r));if(o.length>1){const u=o.filter(d=>d.test);u.length>0&&(o=u)}i=o.find(u=>u.format===s.format)??o.find(u=>!u.format)}else r=s,i=e.find(o=>o.nodeClass&&r instanceof o.nodeClass);if(!i){const o=r?.constructor?.name??(r===null?"null":typeof r);throw new Error(`Tag not resolved for ${o} value`)}return i}function LL(e,s,{anchors:i,doc:r}){if(!r.directives)return"";const o=[],u=(Et(e)||Ht(e))&&e.anchor;u&&EN(u)&&(i.add(u),o.push(`&${u}`));const d=e.tag??(s.default?null:s.tag);return d&&o.push(r.directives.tagString(d)),o.join(" ")}function Fr(e,s,i,r){if(Qt(e))return e.toString(s,i,r);if(Gi(e)){if(s.doc.directives)return e.toString(s);if(s.resolvedAliases?.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");s.resolvedAliases?s.resolvedAliases.add(e):s.resolvedAliases=new Set([e]),e=e.resolve(s.doc)}let o;const u=Kt(e)?e:s.doc.createNode(e,{onTagObj:p=>o=p});o??(o=RL(s.doc.schema.tags,u));const d=LL(u,o,s);d.length>0&&(s.indentAtStart=(s.indentAtStart??0)+d.length+1);const h=typeof o.stringify=="function"?o.stringify(u,s,i,r):Et(u)?sp(u,s,i,r):u.toString(s,i,r);return d?Et(u)||h[0]==="{"||h[0]==="["?`${d} ${h}`:`${d}
96
- ${s.indent}${h}`:h}function ML({key:e,value:s},i,r,o){const{allNullValues:u,doc:d,indent:h,indentStep:p,options:{commentString:x,indentSeq:b,simpleKeys:v}}=i;let N=Kt(e)&&e.comment||null;if(v){if(N)throw new Error("With simple keys, key nodes cannot have comments");if(Ht(e)||!Kt(e)&&typeof e=="object"){const _="With simple keys, collection cannot be used as a key value";throw new Error(_)}}let z=!v&&(!e||N&&s==null&&!i.inFlow||Ht(e)||(Et(e)?e.type===Ze.BLOCK_FOLDED||e.type===Ze.BLOCK_LITERAL:typeof e=="object"));i=Object.assign({},i,{allNullValues:!1,implicitKey:!z&&(v||!u),indent:h+p});let T=!1,w=!1,A=Fr(e,i,()=>T=!0,()=>w=!0);if(!z&&!i.inFlow&&A.length>1024){if(v)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");z=!0}if(i.inFlow){if(u||s==null)return T&&r&&r(),A===""?"?":z?`? ${A}`:A}else if(u&&!v||s==null&&z)return A=`? ${A}`,N&&!T?A+=Di(A,i.indent,x(N)):w&&o&&o(),A;T&&(N=null),z?(N&&(A+=Di(A,i.indent,x(N))),A=`? ${A}
97
- ${h}:`):(A=`${A}:`,N&&(A+=Di(A,i.indent,x(N))));let D,U,I;Kt(s)?(D=!!s.spaceBefore,U=s.commentBefore,I=s.comment):(D=!1,U=null,I=null,s&&typeof s=="object"&&(s=d.createNode(s))),i.implicitKey=!1,!z&&!N&&Et(s)&&(i.indentAtStart=A.length+1),w=!1,!b&&p.length>=2&&!i.inFlow&&!z&&zo(s)&&!s.flow&&!s.tag&&!s.anchor&&(i.indent=i.indent.substring(2));let C=!1;const L=Fr(s,i,()=>C=!0,()=>w=!0);let M=" ";if(N||D||U){if(M=D?`
98
- `:"",U){const _=x(U);M+=`
99
- ${ga(_,i.indent)}`}L===""&&!i.inFlow?M===`
100
- `&&I&&(M=`
101
-
102
- `):M+=`
103
- ${i.indent}`}else if(!z&&Ht(s)){const _=L[0],B=L.indexOf(`
104
- `),J=B!==-1,ue=i.inFlow??s.flow??s.items.length===0;if(J||!ue){let P=!1;if(J&&(_==="&"||_==="!")){let ie=L.indexOf(" ");_==="&"&&ie!==-1&&ie<B&&L[ie+1]==="!"&&(ie=L.indexOf(" ",ie+1)),(ie===-1||B<ie)&&(P=!0)}P||(M=`
105
- ${i.indent}`)}}else(L===""||L[0]===`
106
- `)&&(M="");return A+=M+L,i.inFlow?C&&r&&r():I&&!C?A+=Di(A,i.indent,x(I)):w&&o&&o(),A}function $L(e,s){(e==="debug"||e==="warn")&&console.warn(s)}const Hc="<<",xa={identify:e=>e===Hc||typeof e=="symbol"&&e.description===Hc,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Ze(Symbol(Hc)),{addToJSMap:BN}),stringify:()=>Hc},BL=(e,s)=>(xa.identify(s)||Et(s)&&(!s.type||s.type===Ze.PLAIN)&&xa.identify(s.value))&&e?.doc.schema.tags.some(i=>i.tag===xa.tag&&i.default);function BN(e,s,i){if(i=e&&Gi(i)?i.resolve(e.doc):i,zo(i))for(const r of i.items)kh(e,s,r);else if(Array.isArray(i))for(const r of i)kh(e,s,r);else kh(e,s,i)}function kh(e,s,i){const r=e&&Gi(i)?i.resolve(e.doc):i;if(!So(r))throw new Error("Merge sources must be maps or map aliases");const o=r.toJSON(null,e,Map);for(const[u,d]of o)s instanceof Map?s.has(u)||s.set(u,d):s instanceof Set?s.add(u):Object.prototype.hasOwnProperty.call(s,u)||Object.defineProperty(s,u,{value:d,writable:!0,enumerable:!0,configurable:!0});return s}function qN(e,s,{key:i,value:r}){if(Kt(i)&&i.addToJSMap)i.addToJSMap(e,s,r);else if(BL(e,i))BN(e,s,r);else{const o=ys(i,"",e);if(s instanceof Map)s.set(o,ys(r,o,e));else if(s instanceof Set)s.add(o);else{const u=qL(i,o,e),d=ys(r,u,e);u in s?Object.defineProperty(s,u,{value:d,writable:!0,enumerable:!0,configurable:!0}):s[u]=d}}return s}function qL(e,s,i){if(s===null)return"";if(typeof s!="object")return String(s);if(Kt(e)&&i?.doc){const r=$N(i.doc,{});r.anchors=new Set;for(const u of i.anchors.keys())r.anchors.add(u.anchor);r.inFlow=!0,r.inStringifyKey=!0;const o=e.toString(r);if(!i.mapKeyWarned){let u=JSON.stringify(o);u.length>40&&(u=u.substring(0,36)+'..."'),$L(i.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${u}. Set mapAsMap: true to use object keys.`),i.mapKeyWarned=!0}return o}return JSON.stringify(s)}function ap(e,s,i){const r=go(e,void 0,i),o=go(s,void 0,i);return new Mn(r,o)}class Mn{constructor(s,i=null){Object.defineProperty(this,vs,{value:TN}),this.key=s,this.value=i}clone(s){let{key:i,value:r}=this;return Kt(i)&&(i=i.clone(s)),Kt(r)&&(r=r.clone(s)),new Mn(i,r)}toJSON(s,i){const r=i?.mapAsMap?new Map:{};return qN(i,r,this)}toString(s,i,r){return s?.doc?ML(this,s,i,r):JSON.stringify(this)}}function IN(e,s,i){return(s.inFlow??e.flow?UL:IL)(e,s,i)}function IL({comment:e,items:s},i,{blockItemPrefix:r,flowChars:o,itemIndent:u,onChompKeep:d,onComment:h}){const{indent:p,options:{commentString:x}}=i,b=Object.assign({},i,{indent:u,type:null});let v=!1;const N=[];for(let T=0;T<s.length;++T){const w=s[T];let A=null;if(Kt(w))!v&&w.spaceBefore&&N.push(""),Cu(i,N,w.commentBefore,v),w.comment&&(A=w.comment);else if(Qt(w)){const U=Kt(w.key)?w.key:null;U&&(!v&&U.spaceBefore&&N.push(""),Cu(i,N,U.commentBefore,v))}v=!1;let D=Fr(w,b,()=>A=null,()=>v=!0);A&&(D+=Di(D,u,x(A))),v&&A&&(v=!1),N.push(r+D)}let z;if(N.length===0)z=o.start+o.end;else{z=N[0];for(let T=1;T<N.length;++T){const w=N[T];z+=w?`
107
- ${p}${w}`:`
108
- `}}return e?(z+=`
109
- `+ga(x(e),p),h&&h()):v&&d&&d(),z}function UL({items:e},s,{flowChars:i,itemIndent:r}){const{indent:o,indentStep:u,flowCollectionPadding:d,options:{commentString:h}}=s;r+=u;const p=Object.assign({},s,{indent:r,inFlow:!0,type:null});let x=!1,b=0;const v=[];for(let T=0;T<e.length;++T){const w=e[T];let A=null;if(Kt(w))w.spaceBefore&&v.push(""),Cu(s,v,w.commentBefore,!1),w.comment&&(A=w.comment);else if(Qt(w)){const U=Kt(w.key)?w.key:null;U&&(U.spaceBefore&&v.push(""),Cu(s,v,U.commentBefore,!1),U.comment&&(x=!0));const I=Kt(w.value)?w.value:null;I?(I.comment&&(A=I.comment),I.commentBefore&&(x=!0)):w.value==null&&U?.comment&&(A=U.comment)}A&&(x=!0);let D=Fr(w,p,()=>A=null);T<e.length-1&&(D+=","),A&&(D+=Di(D,r,h(A))),!x&&(v.length>b||D.includes(`
110
- `))&&(x=!0),v.push(D),b=v.length}const{start:N,end:z}=i;if(v.length===0)return N+z;if(!x){const T=v.reduce((w,A)=>w+A.length+2,2);x=s.options.lineWidth>0&&T>s.options.lineWidth}if(x){let T=N;for(const w of v)T+=w?`
111
- ${u}${o}${w}`:`
112
- `;return`${T}
113
- ${o}${z}`}else return`${N}${d}${v.join(" ")}${d}${z}`}function Cu({indent:e,options:{commentString:s}},i,r,o){if(r&&o&&(r=r.replace(/^\n+/,"")),r){const u=ga(s(r),e);i.push(u.trimStart())}}function Oi(e,s){const i=Et(s)?s.value:s;for(const r of e)if(Qt(r)&&(r.key===s||r.key===i||Et(r.key)&&r.key.value===i))return r}class xs extends LN{static get tagName(){return"tag:yaml.org,2002:map"}constructor(s){super(ti,s),this.items=[]}static from(s,i,r){const{keepUndefined:o,replacer:u}=r,d=new this(s),h=(p,x)=>{if(typeof u=="function")x=u.call(i,p,x);else if(Array.isArray(u)&&!u.includes(p))return;(x!==void 0||o)&&d.items.push(ap(p,x,r))};if(i instanceof Map)for(const[p,x]of i)h(p,x);else if(i&&typeof i=="object")for(const p of Object.keys(i))h(p,i[p]);return typeof s.sortMapEntries=="function"&&d.items.sort(s.sortMapEntries),d}add(s,i){let r;Qt(s)?r=s:!s||typeof s!="object"||!("key"in s)?r=new Mn(s,s?.value):r=new Mn(s.key,s.value);const o=Oi(this.items,r.key),u=this.schema?.sortMapEntries;if(o){if(!i)throw new Error(`Key ${r.key} already set`);Et(o.value)&&RN(r.value)?o.value.value=r.value:o.value=r.value}else if(u){const d=this.items.findIndex(h=>u(r,h)<0);d===-1?this.items.push(r):this.items.splice(d,0,r)}else this.items.push(r)}delete(s){const i=Oi(this.items,s);return i?this.items.splice(this.items.indexOf(i),1).length>0:!1}get(s,i){const o=Oi(this.items,s)?.value;return(!i&&Et(o)?o.value:o)??void 0}has(s){return!!Oi(this.items,s)}set(s,i){this.add(new Mn(s,i),!0)}toJSON(s,i,r){const o=r?new r:i?.mapAsMap?new Map:{};i?.onCreate&&i.onCreate(o);for(const u of this.items)qN(i,o,u);return o}toString(s,i,r){if(!s)return JSON.stringify(this);for(const o of this.items)if(!Qt(o))throw new Error(`Map items must all be pairs; found ${JSON.stringify(o)} instead`);return!s.allNullValues&&this.hasAllNullValues(!1)&&(s=Object.assign({},s,{allNullValues:!0})),IN(this,s,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:s.indent||"",onChompKeep:r,onComment:i})}}const al={collection:"map",default:!0,nodeClass:xs,tag:"tag:yaml.org,2002:map",resolve(e,s){return So(e)||s("Expected a mapping for this tag"),e},createNode:(e,s,i)=>xs.from(e,s,i)};class Bi extends LN{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(s){super(nl,s),this.items=[]}add(s){this.items.push(s)}delete(s){const i=Kc(s);return typeof i!="number"?!1:this.items.splice(i,1).length>0}get(s,i){const r=Kc(s);if(typeof r!="number")return;const o=this.items[r];return!i&&Et(o)?o.value:o}has(s){const i=Kc(s);return typeof i=="number"&&i<this.items.length}set(s,i){const r=Kc(s);if(typeof r!="number")throw new Error(`Expected a valid index, not ${s}.`);const o=this.items[r];Et(o)&&RN(i)?o.value=i:this.items[r]=i}toJSON(s,i){const r=[];i?.onCreate&&i.onCreate(r);let o=0;for(const u of this.items)r.push(ys(u,String(o++),i));return r}toString(s,i,r){return s?IN(this,s,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(s.indent||"")+" ",onChompKeep:r,onComment:i}):JSON.stringify(this)}static from(s,i,r){const{replacer:o}=r,u=new this(s);if(i&&Symbol.iterator in Object(i)){let d=0;for(let h of i){if(typeof o=="function"){const p=i instanceof Set?h:String(d++);h=o.call(i,p,h)}u.items.push(go(h,void 0,r))}}return u}}function Kc(e){let s=Et(e)?e.value:e;return s&&typeof s=="string"&&(s=Number(s)),typeof s=="number"&&Number.isInteger(s)&&s>=0?s:null}const il={collection:"seq",default:!0,nodeClass:Bi,tag:"tag:yaml.org,2002:seq",resolve(e,s){return zo(e)||s("Expected a sequence for this tag"),e},createNode:(e,s,i)=>Bi.from(e,s,i)},Xu={identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify(e,s,i,r){return s=Object.assign({actualString:!0},s),sp(e,s,i,r)}},Ju={identify:e=>e==null,createNode:()=>new Ze(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Ze(null),stringify:({source:e},s)=>typeof e=="string"&&Ju.test.test(e)?e:s.options.nullStr},ip={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new Ze(e[0]==="t"||e[0]==="T"),stringify({source:e,value:s},i){if(e&&ip.test.test(e)){const r=e[0]==="t"||e[0]==="T";if(s===r)return e}return s?i.options.trueStr:i.options.falseStr}};function Bs({format:e,minFractionDigits:s,tag:i,value:r}){if(typeof r=="bigint")return String(r);const o=typeof r=="number"?r:Number(r);if(!isFinite(o))return isNaN(o)?".nan":o<0?"-.inf":".inf";let u=Object.is(r,-0)?"-0":JSON.stringify(r);if(!e&&s&&(!i||i==="tag:yaml.org,2002:float")&&/^\d/.test(u)){let d=u.indexOf(".");d<0&&(d=u.length,u+=".");let h=s-(u.length-d-1);for(;h-- >0;)u+="0"}return u}const UN={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Bs},PN={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){const s=Number(e.value);return isFinite(s)?s.toExponential():Bs(e)}},GN={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){const s=new Ze(parseFloat(e)),i=e.indexOf(".");return i!==-1&&e[e.length-1]==="0"&&(s.minFractionDigits=e.length-i-1),s},stringify:Bs},Wu=e=>typeof e=="bigint"||Number.isInteger(e),rp=(e,s,i,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(s),i);function VN(e,s,i){const{value:r}=e;return Wu(r)&&r>=0?i+r.toString(s):Bs(e)}const HN={identify:e=>Wu(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,s,i)=>rp(e,2,8,i),stringify:e=>VN(e,8,"0o")},KN={identify:Wu,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,s,i)=>rp(e,0,10,i),stringify:Bs},QN={identify:e=>Wu(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,s,i)=>rp(e,2,16,i),stringify:e=>VN(e,16,"0x")},PL=[al,il,Xu,Ju,ip,HN,KN,QN,UN,PN,GN];function bb(e){return typeof e=="bigint"||Number.isInteger(e)}const Qc=({value:e})=>JSON.stringify(e),GL=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:Qc},{identify:e=>e==null,createNode:()=>new Ze(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Qc},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:Qc},{identify:bb,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,s,{intAsBigInt:i})=>i?BigInt(e):parseInt(e,10),stringify:({value:e})=>bb(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Qc}],VL={default:!0,tag:"",test:/^/,resolve(e,s){return s(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},HL=[al,il].concat(GL,VL),lp={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,s){if(typeof atob=="function"){const i=atob(e.replace(/[\n\r]/g,"")),r=new Uint8Array(i.length);for(let o=0;o<i.length;++o)r[o]=i.charCodeAt(o);return r}else return s("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:s,value:i},r,o,u){if(!i)return"";const d=i;let h;if(typeof btoa=="function"){let p="";for(let x=0;x<d.length;++x)p+=String.fromCharCode(d[x]);h=btoa(p)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(s??(s=Ze.BLOCK_LITERAL),s!==Ze.QUOTE_DOUBLE){const p=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),x=Math.ceil(h.length/p),b=new Array(x);for(let v=0,N=0;v<x;++v,N+=p)b[v]=h.substr(N,p);h=b.join(s===Ze.BLOCK_LITERAL?`
114
- `:" ")}return sp({comment:e,type:s,value:h},r,o,u)}};function ZN(e,s){if(zo(e))for(let i=0;i<e.items.length;++i){let r=e.items[i];if(!Qt(r)){if(So(r)){r.items.length>1&&s("Each pair must have its own sequence indicator");const o=r.items[0]||new Mn(new Ze(null));if(r.commentBefore&&(o.key.commentBefore=o.key.commentBefore?`${r.commentBefore}
115
- ${o.key.commentBefore}`:r.commentBefore),r.comment){const u=o.value??o.key;u.comment=u.comment?`${r.comment}
116
- ${u.comment}`:r.comment}r=o}e.items[i]=Qt(r)?r:new Mn(r)}}else s("Expected a sequence for this tag");return e}function FN(e,s,i){const{replacer:r}=i,o=new Bi(e);o.tag="tag:yaml.org,2002:pairs";let u=0;if(s&&Symbol.iterator in Object(s))for(let d of s){typeof r=="function"&&(d=r.call(s,String(u++),d));let h,p;if(Array.isArray(d))if(d.length===2)h=d[0],p=d[1];else throw new TypeError(`Expected [key, value] tuple: ${d}`);else if(d&&d instanceof Object){const x=Object.keys(d);if(x.length===1)h=x[0],p=d[h];else throw new TypeError(`Expected tuple with one key, not ${x.length} keys`)}else h=d;o.items.push(ap(h,p,i))}return o}const op={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:ZN,createNode:FN};class Ir extends Bi{constructor(){super(),this.add=xs.prototype.add.bind(this),this.delete=xs.prototype.delete.bind(this),this.get=xs.prototype.get.bind(this),this.has=xs.prototype.has.bind(this),this.set=xs.prototype.set.bind(this),this.tag=Ir.tag}toJSON(s,i){if(!i)return super.toJSON(s);const r=new Map;i?.onCreate&&i.onCreate(r);for(const o of this.items){let u,d;if(Qt(o)?(u=ys(o.key,"",i),d=ys(o.value,u,i)):u=ys(o,"",i),r.has(u))throw new Error("Ordered maps must not include duplicate keys");r.set(u,d)}return r}static from(s,i,r){const o=FN(s,i,r),u=new this;return u.items=o.items,u}}Ir.tag="tag:yaml.org,2002:omap";const cp={collection:"seq",identify:e=>e instanceof Map,nodeClass:Ir,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,s){const i=ZN(e,s),r=[];for(const{key:o}of i.items)Et(o)&&(r.includes(o.value)?s(`Ordered maps must not include duplicate keys: ${o.value}`):r.push(o.value));return Object.assign(new Ir,i)},createNode:(e,s,i)=>Ir.from(e,s,i)};function YN({value:e,source:s},i){return s&&(e?XN:JN).test.test(s)?s:e?i.options.trueStr:i.options.falseStr}const XN={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Ze(!0),stringify:YN},JN={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Ze(!1),stringify:YN},KL={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Bs},QL={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){const s=Number(e.value);return isFinite(s)?s.toExponential():Bs(e)}},ZL={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){const s=new Ze(parseFloat(e.replace(/_/g,""))),i=e.indexOf(".");if(i!==-1){const r=e.substring(i+1).replace(/_/g,"");r[r.length-1]==="0"&&(s.minFractionDigits=r.length)}return s},stringify:Bs},ko=e=>typeof e=="bigint"||Number.isInteger(e);function ed(e,s,i,{intAsBigInt:r}){const o=e[0];if((o==="-"||o==="+")&&(s+=1),e=e.substring(s).replace(/_/g,""),r){switch(i){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}const d=BigInt(e);return o==="-"?BigInt(-1)*d:d}const u=parseInt(e,i);return o==="-"?-1*u:u}function up(e,s,i){const{value:r}=e;if(ko(r)){const o=r.toString(s);return r<0?"-"+i+o.substr(1):i+o}return Bs(e)}const FL={identify:ko,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,s,i)=>ed(e,2,2,i),stringify:e=>up(e,2,"0b")},YL={identify:ko,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,s,i)=>ed(e,1,8,i),stringify:e=>up(e,8,"0")},XL={identify:ko,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,s,i)=>ed(e,0,10,i),stringify:Bs},JL={identify:ko,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,s,i)=>ed(e,2,16,i),stringify:e=>up(e,16,"0x")};class Ur extends xs{constructor(s){super(s),this.tag=Ur.tag}add(s){let i;Qt(s)?i=s:s&&typeof s=="object"&&"key"in s&&"value"in s&&s.value===null?i=new Mn(s.key,null):i=new Mn(s,null),Oi(this.items,i.key)||this.items.push(i)}get(s,i){const r=Oi(this.items,s);return!i&&Qt(r)?Et(r.key)?r.key.value:r.key:r}set(s,i){if(typeof i!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof i}`);const r=Oi(this.items,s);r&&!i?this.items.splice(this.items.indexOf(r),1):!r&&i&&this.items.push(new Mn(s))}toJSON(s,i){return super.toJSON(s,i,Set)}toString(s,i,r){if(!s)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},s,{allNullValues:!0}),i,r);throw new Error("Set items must all have null values")}static from(s,i,r){const{replacer:o}=r,u=new this(s);if(i&&Symbol.iterator in Object(i))for(let d of i)typeof o=="function"&&(d=o.call(i,d,d)),u.items.push(ap(d,null,r));return u}}Ur.tag="tag:yaml.org,2002:set";const dp={collection:"map",identify:e=>e instanceof Set,nodeClass:Ur,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,s,i)=>Ur.from(e,s,i),resolve(e,s){if(So(e)){if(e.hasAllNullValues(!0))return Object.assign(new Ur,e);s("Set items must all have null values")}else s("Expected a mapping for this tag");return e}};function mp(e,s){const i=e[0],r=i==="-"||i==="+"?e.substring(1):e,o=d=>s?BigInt(d):Number(d),u=r.replace(/_/g,"").split(":").reduce((d,h)=>d*o(60)+o(h),o(0));return i==="-"?o(-1)*u:u}function WN(e){let{value:s}=e,i=d=>d;if(typeof s=="bigint")i=d=>BigInt(d);else if(isNaN(s)||!isFinite(s))return Bs(e);let r="";s<0&&(r="-",s*=i(-1));const o=i(60),u=[s%o];return s<60?u.unshift(0):(s=(s-u[0])/o,u.unshift(s%o),s>=60&&(s=(s-u[0])/o,u.unshift(s))),r+u.map(d=>String(d).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}const e1={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,s,{intAsBigInt:i})=>mp(e,i),stringify:WN},t1={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>mp(e,!1),stringify:WN},td={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){const s=e.match(td.test);if(!s)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");const[,i,r,o,u,d,h]=s.map(Number),p=s[7]?Number((s[7]+"00").substr(1,3)):0;let x=Date.UTC(i,r-1,o,u||0,d||0,h||0,p);const b=s[8];if(b&&b!=="Z"){let v=mp(b,!1);Math.abs(v)<30&&(v*=60),x-=6e4*v}return new Date(x)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""},vb=[al,il,Xu,Ju,XN,JN,FL,YL,XL,JL,KL,QL,ZL,lp,xa,cp,op,dp,e1,t1,td],jb=new Map([["core",PL],["failsafe",[al,il,Xu]],["json",HL],["yaml11",vb],["yaml-1.1",vb]]),Nb={binary:lp,bool:ip,float:GN,floatExp:PN,floatNaN:UN,floatTime:t1,int:KN,intHex:QN,intOct:HN,intTime:e1,map:al,merge:xa,null:Ju,omap:cp,pairs:op,seq:il,set:dp,timestamp:td},WL={"tag:yaml.org,2002:binary":lp,"tag:yaml.org,2002:merge":xa,"tag:yaml.org,2002:omap":cp,"tag:yaml.org,2002:pairs":op,"tag:yaml.org,2002:set":dp,"tag:yaml.org,2002:timestamp":td};function Ch(e,s,i){const r=jb.get(s);if(r&&!e)return i&&!r.includes(xa)?r.concat(xa):r.slice();let o=r;if(!o)if(Array.isArray(e))o=[];else{const u=Array.from(jb.keys()).filter(d=>d!=="yaml11").map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown schema "${s}"; use one of ${u} or define customTags array`)}if(Array.isArray(e))for(const u of e)o=o.concat(u);else typeof e=="function"&&(o=e(o.slice()));return i&&(o=o.concat(xa)),o.reduce((u,d)=>{const h=typeof d=="string"?Nb[d]:d;if(!h){const p=JSON.stringify(d),x=Object.keys(Nb).map(b=>JSON.stringify(b)).join(", ");throw new Error(`Unknown custom tag ${p}; use one of ${x}`)}return u.includes(h)||u.push(h),u},[])}const eM=(e,s)=>e.key<s.key?-1:e.key>s.key?1:0;class hp{constructor({compat:s,customTags:i,merge:r,resolveKnownTags:o,schema:u,sortMapEntries:d,toStringDefaults:h}){this.compat=Array.isArray(s)?Ch(s,"compat"):s?Ch(null,s):null,this.name=typeof u=="string"&&u||"core",this.knownTags=o?WL:{},this.tags=Ch(i,this.name,r),this.toStringOptions=h??null,Object.defineProperty(this,ti,{value:al}),Object.defineProperty(this,Vs,{value:Xu}),Object.defineProperty(this,nl,{value:il}),this.sortMapEntries=typeof d=="function"?d:d===!0?eM:null}clone(){const s=Object.create(hp.prototype,Object.getOwnPropertyDescriptors(this));return s.tags=this.tags.slice(),s}}function tM(e,s){const i=[];let r=s.directives===!0;if(s.directives!==!1&&e.directives){const p=e.directives.toString(e);p?(i.push(p),r=!0):e.directives.docStart&&(r=!0)}r&&i.push("---");const o=$N(e,s),{commentString:u}=o.options;if(e.commentBefore){i.length!==1&&i.unshift("");const p=u(e.commentBefore);i.unshift(ga(p,""))}let d=!1,h=null;if(e.contents){if(Kt(e.contents)){if(e.contents.spaceBefore&&r&&i.push(""),e.contents.commentBefore){const b=u(e.contents.commentBefore);i.push(ga(b,""))}o.forceBlockIndent=!!e.comment,h=e.contents.comment}const p=h?void 0:()=>d=!0;let x=Fr(e.contents,o,()=>h=null,p);h&&(x+=Di(x,"",u(h))),(x[0]==="|"||x[0]===">")&&i[i.length-1]==="---"?i[i.length-1]=`--- ${x}`:i.push(x)}else i.push(Fr(e.contents,o));if(e.directives?.docEnd)if(e.comment){const p=u(e.comment);p.includes(`
117
- `)?(i.push("..."),i.push(ga(p,""))):i.push(`... ${p}`)}else i.push("...");else{let p=e.comment;p&&d&&(p=p.replace(/^\n+/,"")),p&&((!d||h)&&i[i.length-1]!==""&&i.push(""),i.push(ga(u(p),"")))}return i.join(`
118
- `)+`
119
- `}class nd{constructor(s,i,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,vs,{value:lf});let o=null;typeof i=="function"||Array.isArray(i)?o=i:r===void 0&&i&&(r=i,i=void 0);const u=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=u;let{version:d}=u;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(d=this.directives.yaml.version)):this.directives=new Ln({version:d}),this.setSchema(d,r),this.contents=s===void 0?null:this.createNode(s,o,r)}clone(){const s=Object.create(nd.prototype,{[vs]:{value:lf}});return s.commentBefore=this.commentBefore,s.comment=this.comment,s.errors=this.errors.slice(),s.warnings=this.warnings.slice(),s.options=Object.assign({},this.options),this.directives&&(s.directives=this.directives.clone()),s.schema=this.schema.clone(),s.contents=Kt(this.contents)?this.contents.clone(s.schema):this.contents,this.range&&(s.range=this.range.slice()),s}add(s){Cr(this.contents)&&this.contents.add(s)}addIn(s,i){Cr(this.contents)&&this.contents.addIn(s,i)}createAlias(s,i){if(!s.anchor){const r=DN(this);s.anchor=!i||r.has(i)?ON(i||"a",r):i}return new np(s.anchor)}createNode(s,i,r){let o;if(typeof i=="function")s=i.call({"":s},"",s),o=i;else if(Array.isArray(i)){const A=U=>typeof U=="number"||U instanceof String||U instanceof Number,D=i.filter(A).map(String);D.length>0&&(i=i.concat(D)),o=i}else r===void 0&&i&&(r=i,i=void 0);const{aliasDuplicateObjects:u,anchorPrefix:d,flow:h,keepUndefined:p,onTagObj:x,tag:b}=r??{},{onAnchor:v,setAnchors:N,sourceObjects:z}=AL(this,d||"a"),T={aliasDuplicateObjects:u??!0,keepUndefined:p??!1,onAnchor:v,onTagObj:x,replacer:o,schema:this.schema,sourceObjects:z},w=go(s,b,T);return h&&Ht(w)&&(w.flow=!0),N(),w}createPair(s,i,r={}){const o=this.createNode(s,null,r),u=this.createNode(i,null,r);return new Mn(o,u)}delete(s){return Cr(this.contents)?this.contents.delete(s):!1}deleteIn(s){return lo(s)?this.contents==null?!1:(this.contents=null,!0):Cr(this.contents)?this.contents.deleteIn(s):!1}get(s,i){return Ht(this.contents)?this.contents.get(s,i):void 0}getIn(s,i){return lo(s)?!i&&Et(this.contents)?this.contents.value:this.contents:Ht(this.contents)?this.contents.getIn(s,i):void 0}has(s){return Ht(this.contents)?this.contents.has(s):!1}hasIn(s){return lo(s)?this.contents!==void 0:Ht(this.contents)?this.contents.hasIn(s):!1}set(s,i){this.contents==null?this.contents=ku(this.schema,[s],i):Cr(this.contents)&&this.contents.set(s,i)}setIn(s,i){lo(s)?this.contents=i:this.contents==null?this.contents=ku(this.schema,Array.from(s),i):Cr(this.contents)&&this.contents.setIn(s,i)}setSchema(s,i={}){typeof s=="number"&&(s=String(s));let r;switch(s){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Ln({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=s:this.directives=new Ln({version:s}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{const o=JSON.stringify(s);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${o}`)}}if(i.schema instanceof Object)this.schema=i.schema;else if(r)this.schema=new hp(Object.assign(r,i));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:s,jsonArg:i,mapAsMap:r,maxAliasCount:o,onAnchor:u,reviver:d}={}){const h={anchors:new Map,doc:this,keep:!s,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof o=="number"?o:100},p=ys(this.contents,i??"",h);if(typeof u=="function")for(const{count:x,res:b}of h.anchors.values())u(b,x);return typeof d=="function"?Rr(d,{"":p},"",p):p}toJSON(s,i){return this.toJS({json:!0,jsonArg:s,mapAsMap:!1,onAnchor:i})}toString(s={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in s&&(!Number.isInteger(s.indent)||Number(s.indent)<=0)){const i=JSON.stringify(s.indent);throw new Error(`"indent" option must be a positive integer, not ${i}`)}return tM(this,s)}}function Cr(e){if(Ht(e))return!0;throw new Error("Expected a YAML collection as document contents")}class n1 extends Error{constructor(s,i,r,o){super(),this.name=s,this.code=r,this.message=o,this.pos=i}}class Zc extends n1{constructor(s,i,r){super("YAMLParseError",s,i,r)}}class nM extends n1{constructor(s,i,r){super("YAMLWarning",s,i,r)}}const wb=(e,s)=>i=>{if(i.pos[0]===-1)return;i.linePos=i.pos.map(h=>s.linePos(h));const{line:r,col:o}=i.linePos[0];i.message+=` at line ${r}, column ${o}`;let u=o-1,d=e.substring(s.lineStarts[r-1],s.lineStarts[r]).replace(/[\n\r]+$/,"");if(u>=60&&d.length>80){const h=Math.min(u-39,d.length-79);d="…"+d.substring(h),u-=h-1}if(d.length>80&&(d=d.substring(0,79)+"…"),r>1&&/^ *$/.test(d.substring(0,u))){let h=e.substring(s.lineStarts[r-2],s.lineStarts[r-1]);h.length>80&&(h=h.substring(0,79)+`…
120
- `),d=h+d}if(/[^ ]/.test(d)){let h=1;const p=i.linePos[1];p?.line===r&&p.col>o&&(h=Math.max(1,Math.min(p.col-o,80-u)));const x=" ".repeat(u)+"^".repeat(h);i.message+=`:
121
-
122
- ${d}
123
- ${x}
124
- `}};function Yr(e,{flow:s,indicator:i,next:r,offset:o,onError:u,parentIndent:d,startOnNewline:h}){let p=!1,x=h,b=h,v="",N="",z=!1,T=!1,w=null,A=null,D=null,U=null,I=null,C=null,L=null;for(const B of e)switch(T&&(B.type!=="space"&&B.type!=="newline"&&B.type!=="comma"&&u(B.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),T=!1),w&&(x&&B.type!=="comment"&&B.type!=="newline"&&u(w,"TAB_AS_INDENT","Tabs are not allowed as indentation"),w=null),B.type){case"space":!s&&(i!=="doc-start"||r?.type!=="flow-collection")&&B.source.includes(" ")&&(w=B),b=!0;break;case"comment":{b||u(B,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const J=B.source.substring(1)||" ";v?v+=N+J:v=J,N="",x=!1;break}case"newline":x?v?v+=B.source:(!C||i!=="seq-item-ind")&&(p=!0):N+=B.source,x=!0,z=!0,(A||D)&&(U=B),b=!0;break;case"anchor":A&&u(B,"MULTIPLE_ANCHORS","A node can have at most one anchor"),B.source.endsWith(":")&&u(B.offset+B.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),A=B,L??(L=B.offset),x=!1,b=!1,T=!0;break;case"tag":{D&&u(B,"MULTIPLE_TAGS","A node can have at most one tag"),D=B,L??(L=B.offset),x=!1,b=!1,T=!0;break}case i:(A||D)&&u(B,"BAD_PROP_ORDER",`Anchors and tags must be after the ${B.source} indicator`),C&&u(B,"UNEXPECTED_TOKEN",`Unexpected ${B.source} in ${s??"collection"}`),C=B,x=i==="seq-item-ind"||i==="explicit-key-ind",b=!1;break;case"comma":if(s){I&&u(B,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`),I=B,x=!1,b=!1;break}default:u(B,"UNEXPECTED_TOKEN",`Unexpected ${B.type} token`),x=!1,b=!1}const M=e[e.length-1],_=M?M.offset+M.source.length:o;return T&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&u(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),w&&(x&&w.indent<=d||r?.type==="block-map"||r?.type==="block-seq")&&u(w,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:I,found:C,spaceBefore:p,comment:v,hasNewline:z,anchor:A,tag:D,newlineAfterProp:U,end:_,start:L??_}}function xo(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
125
- `))return!0;if(e.end){for(const s of e.end)if(s.type==="newline")return!0}return!1;case"flow-collection":for(const s of e.items){for(const i of s.start)if(i.type==="newline")return!0;if(s.sep){for(const i of s.sep)if(i.type==="newline")return!0}if(xo(s.key)||xo(s.value))return!0}return!1;default:return!0}}function df(e,s,i){if(s?.type==="flow-collection"){const r=s.end[0];r.indent===e&&(r.source==="]"||r.source==="}")&&xo(s)&&i(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function s1(e,s,i){const{uniqueKeys:r}=e.options;if(r===!1)return!1;const o=typeof r=="function"?r:(u,d)=>u===d||Et(u)&&Et(d)&&u.value===d.value;return s.some(u=>o(u.key,i))}const Sb="All mapping items must start at the same column";function sM({composeNode:e,composeEmptyNode:s},i,r,o,u){const d=u?.nodeClass??xs,h=new d(i.schema);i.atRoot&&(i.atRoot=!1);let p=r.offset,x=null;for(const b of r.items){const{start:v,key:N,sep:z,value:T}=b,w=Yr(v,{indicator:"explicit-key-ind",next:N??z?.[0],offset:p,onError:o,parentIndent:r.indent,startOnNewline:!0}),A=!w.found;if(A){if(N&&(N.type==="block-seq"?o(p,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in N&&N.indent!==r.indent&&o(p,"BAD_INDENT",Sb)),!w.anchor&&!w.tag&&!z){x=w.end,w.comment&&(h.comment?h.comment+=`
126
- `+w.comment:h.comment=w.comment);continue}(w.newlineAfterProp||xo(N))&&o(N??v[v.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else w.found?.indent!==r.indent&&o(p,"BAD_INDENT",Sb);i.atKey=!0;const D=w.end,U=N?e(i,N,w,o):s(i,D,v,null,w,o);i.schema.compat&&df(r.indent,N,o),i.atKey=!1,s1(i,h.items,U)&&o(D,"DUPLICATE_KEY","Map keys must be unique");const I=Yr(z??[],{indicator:"map-value-ind",next:T,offset:U.range[2],onError:o,parentIndent:r.indent,startOnNewline:!N||N.type==="block-scalar"});if(p=I.end,I.found){A&&(T?.type==="block-map"&&!I.hasNewline&&o(p,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),i.options.strict&&w.start<I.found.offset-1024&&o(U.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));const C=T?e(i,T,I,o):s(i,p,z,null,I,o);i.schema.compat&&df(r.indent,T,o),p=C.range[2];const L=new Mn(U,C);i.options.keepSourceTokens&&(L.srcToken=b),h.items.push(L)}else{A&&o(U.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),I.comment&&(U.comment?U.comment+=`
127
- `+I.comment:U.comment=I.comment);const C=new Mn(U);i.options.keepSourceTokens&&(C.srcToken=b),h.items.push(C)}}return x&&x<p&&o(x,"IMPOSSIBLE","Map comment with trailing content"),h.range=[r.offset,p,x??p],h}function aM({composeNode:e,composeEmptyNode:s},i,r,o,u){const d=u?.nodeClass??Bi,h=new d(i.schema);i.atRoot&&(i.atRoot=!1),i.atKey&&(i.atKey=!1);let p=r.offset,x=null;for(const{start:b,value:v}of r.items){const N=Yr(b,{indicator:"seq-item-ind",next:v,offset:p,onError:o,parentIndent:r.indent,startOnNewline:!0});if(!N.found)if(N.anchor||N.tag||v)v?.type==="block-seq"?o(N.end,"BAD_INDENT","All sequence items must start at the same column"):o(p,"MISSING_CHAR","Sequence item without - indicator");else{x=N.end,N.comment&&(h.comment=N.comment);continue}const z=v?e(i,v,N,o):s(i,N.end,b,null,N,o);i.schema.compat&&df(r.indent,v,o),p=z.range[2],h.items.push(z)}return h.range=[r.offset,p,x??p],h}function Co(e,s,i,r){let o="";if(e){let u=!1,d="";for(const h of e){const{source:p,type:x}=h;switch(x){case"space":u=!0;break;case"comment":{i&&!u&&r(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const b=p.substring(1)||" ";o?o+=d+b:o=b,d="";break}case"newline":o&&(d+=p),u=!0;break;default:r(h,"UNEXPECTED_TOKEN",`Unexpected ${x} at node end`)}s+=p.length}}return{comment:o,offset:s}}const Ah="Block collections are not allowed within flow collections",Th=e=>e&&(e.type==="block-map"||e.type==="block-seq");function iM({composeNode:e,composeEmptyNode:s},i,r,o,u){const d=r.start.source==="{",h=d?"flow map":"flow sequence",p=u?.nodeClass??(d?xs:Bi),x=new p(i.schema);x.flow=!0;const b=i.atRoot;b&&(i.atRoot=!1),i.atKey&&(i.atKey=!1);let v=r.offset+r.start.source.length;for(let A=0;A<r.items.length;++A){const D=r.items[A],{start:U,key:I,sep:C,value:L}=D,M=Yr(U,{flow:h,indicator:"explicit-key-ind",next:I??C?.[0],offset:v,onError:o,parentIndent:r.indent,startOnNewline:!1});if(!M.found){if(!M.anchor&&!M.tag&&!C&&!L){A===0&&M.comma?o(M.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${h}`):A<r.items.length-1&&o(M.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${h}`),M.comment&&(x.comment?x.comment+=`
128
- `+M.comment:x.comment=M.comment),v=M.end;continue}!d&&i.options.strict&&xo(I)&&o(I,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(A===0)M.comma&&o(M.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${h}`);else if(M.comma||o(M.start,"MISSING_CHAR",`Missing , between ${h} items`),M.comment){let _="";e:for(const B of U)switch(B.type){case"comma":case"space":break;case"comment":_=B.source.substring(1);break e;default:break e}if(_){let B=x.items[x.items.length-1];Qt(B)&&(B=B.value??B.key),B.comment?B.comment+=`
129
- `+_:B.comment=_,M.comment=M.comment.substring(_.length+1)}}if(!d&&!C&&!M.found){const _=L?e(i,L,M,o):s(i,M.end,C,null,M,o);x.items.push(_),v=_.range[2],Th(L)&&o(_.range,"BLOCK_IN_FLOW",Ah)}else{i.atKey=!0;const _=M.end,B=I?e(i,I,M,o):s(i,_,U,null,M,o);Th(I)&&o(B.range,"BLOCK_IN_FLOW",Ah),i.atKey=!1;const J=Yr(C??[],{flow:h,indicator:"map-value-ind",next:L,offset:B.range[2],onError:o,parentIndent:r.indent,startOnNewline:!1});if(J.found){if(!d&&!M.found&&i.options.strict){if(C)for(const ie of C){if(ie===J.found)break;if(ie.type==="newline"){o(ie,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}M.start<J.found.offset-1024&&o(J.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else L&&("source"in L&&L.source?.[0]===":"?o(L,"MISSING_CHAR",`Missing space after : in ${h}`):o(J.start,"MISSING_CHAR",`Missing , or : between ${h} items`));const ue=L?e(i,L,J,o):J.found?s(i,J.end,C,null,J,o):null;ue?Th(L)&&o(ue.range,"BLOCK_IN_FLOW",Ah):J.comment&&(B.comment?B.comment+=`
130
- `+J.comment:B.comment=J.comment);const P=new Mn(B,ue);if(i.options.keepSourceTokens&&(P.srcToken=D),d){const ie=x;s1(i,ie.items,B)&&o(_,"DUPLICATE_KEY","Map keys must be unique"),ie.items.push(P)}else{const ie=new xs(i.schema);ie.flow=!0,ie.items.push(P);const te=(ue??B).range;ie.range=[B.range[0],te[1],te[2]],x.items.push(ie)}v=ue?ue.range[2]:J.end}}const N=d?"}":"]",[z,...T]=r.end;let w=v;if(z?.source===N)w=z.offset+z.source.length;else{const A=h[0].toUpperCase()+h.substring(1),D=b?`${A} must end with a ${N}`:`${A} in block collection must be sufficiently indented and end with a ${N}`;o(v,b?"MISSING_CHAR":"BAD_INDENT",D),z&&z.source.length!==1&&T.unshift(z)}if(T.length>0){const A=Co(T,w,i.options.strict,o);A.comment&&(x.comment?x.comment+=`
131
- `+A.comment:x.comment=A.comment),x.range=[r.offset,w,A.offset]}else x.range=[r.offset,w,w];return x}function _h(e,s,i,r,o,u){const d=i.type==="block-map"?sM(e,s,i,r,u):i.type==="block-seq"?aM(e,s,i,r,u):iM(e,s,i,r,u),h=d.constructor;return o==="!"||o===h.tagName?(d.tag=h.tagName,d):(o&&(d.tag=o),d)}function rM(e,s,i,r,o){const u=r.tag,d=u?s.directives.tagName(u.source,N=>o(u,"TAG_RESOLVE_FAILED",N)):null;if(i.type==="block-seq"){const{anchor:N,newlineAfterProp:z}=r,T=N&&u?N.offset>u.offset?N:u:N??u;T&&(!z||z.offset<T.offset)&&o(T,"MISSING_CHAR","Missing newline after block sequence props")}const h=i.type==="block-map"?"map":i.type==="block-seq"?"seq":i.start.source==="{"?"map":"seq";if(!u||!d||d==="!"||d===xs.tagName&&h==="map"||d===Bi.tagName&&h==="seq")return _h(e,s,i,o,d);let p=s.schema.tags.find(N=>N.tag===d&&N.collection===h);if(!p){const N=s.schema.knownTags[d];if(N?.collection===h)s.schema.tags.push(Object.assign({},N,{default:!1})),p=N;else return N?o(u,"BAD_COLLECTION_TYPE",`${N.tag} used for ${h} collection, but expects ${N.collection??"scalar"}`,!0):o(u,"TAG_RESOLVE_FAILED",`Unresolved tag: ${d}`,!0),_h(e,s,i,o,d)}const x=_h(e,s,i,o,d,p),b=p.resolve?.(x,N=>o(u,"TAG_RESOLVE_FAILED",N),s.options)??x,v=Kt(b)?b:new Ze(b);return v.range=x.range,v.tag=d,p?.format&&(v.format=p.format),v}function lM(e,s,i){const r=s.offset,o=oM(s,e.options.strict,i);if(!o)return{value:"",type:null,comment:"",range:[r,r,r]};const u=o.mode===">"?Ze.BLOCK_FOLDED:Ze.BLOCK_LITERAL,d=s.source?cM(s.source):[];let h=d.length;for(let w=d.length-1;w>=0;--w){const A=d[w][1];if(A===""||A==="\r")h=w;else break}if(h===0){const w=o.chomp==="+"&&d.length>0?`
132
- `.repeat(Math.max(1,d.length-1)):"";let A=r+o.length;return s.source&&(A+=s.source.length),{value:w,type:u,comment:o.comment,range:[r,A,A]}}let p=s.indent+o.indent,x=s.offset+o.length,b=0;for(let w=0;w<h;++w){const[A,D]=d[w];if(D===""||D==="\r")o.indent===0&&A.length>p&&(p=A.length);else{A.length<p&&i(x+A.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),o.indent===0&&(p=A.length),b=w,p===0&&!e.atRoot&&i(x,"BAD_INDENT","Block scalar values in collections must be indented");break}x+=A.length+D.length+1}for(let w=d.length-1;w>=h;--w)d[w][0].length>p&&(h=w+1);let v="",N="",z=!1;for(let w=0;w<b;++w)v+=d[w][0].slice(p)+`
133
- `;for(let w=b;w<h;++w){let[A,D]=d[w];x+=A.length+D.length+1;const U=D[D.length-1]==="\r";if(U&&(D=D.slice(0,-1)),D&&A.length<p){const C=`Block scalar lines must not be less indented than their ${o.indent?"explicit indentation indicator":"first line"}`;i(x-D.length-(U?2:1),"BAD_INDENT",C),A=""}u===Ze.BLOCK_LITERAL?(v+=N+A.slice(p)+D,N=`
134
- `):A.length>p||D[0]===" "?(N===" "?N=`
135
- `:!z&&N===`
136
- `&&(N=`
137
-
138
- `),v+=N+A.slice(p)+D,N=`
139
- `,z=!0):D===""?N===`
140
- `?v+=`
141
- `:N=`
142
- `:(v+=N+D,N=" ",z=!1)}switch(o.chomp){case"-":break;case"+":for(let w=h;w<d.length;++w)v+=`
143
- `+d[w][0].slice(p);v[v.length-1]!==`
144
- `&&(v+=`
145
- `);break;default:v+=`
146
- `}const T=r+o.length+s.source.length;return{value:v,type:u,comment:o.comment,range:[r,T,T]}}function oM({offset:e,props:s},i,r){if(s[0].type!=="block-scalar-header")return r(s[0],"IMPOSSIBLE","Block scalar header not found"),null;const{source:o}=s[0],u=o[0];let d=0,h="",p=-1;for(let N=1;N<o.length;++N){const z=o[N];if(!h&&(z==="-"||z==="+"))h=z;else{const T=Number(z);!d&&T?d=T:p===-1&&(p=e+N)}}p!==-1&&r(p,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${o}`);let x=!1,b="",v=o.length;for(let N=1;N<s.length;++N){const z=s[N];switch(z.type){case"space":x=!0;case"newline":v+=z.source.length;break;case"comment":i&&!x&&r(z,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),v+=z.source.length,b=z.source.substring(1);break;case"error":r(z,"UNEXPECTED_TOKEN",z.message),v+=z.source.length;break;default:{const T=`Unexpected token in block scalar header: ${z.type}`;r(z,"UNEXPECTED_TOKEN",T);const w=z.source;w&&typeof w=="string"&&(v+=w.length)}}}return{mode:u,indent:d,chomp:h,comment:b,length:v}}function cM(e){const s=e.split(/\n( *)/),i=s[0],r=i.match(/^( *)/),u=[r?.[1]?[r[1],i.slice(r[1].length)]:["",i]];for(let d=1;d<s.length;d+=2)u.push([s[d],s[d+1]]);return u}function uM(e,s,i){const{offset:r,type:o,source:u,end:d}=e;let h,p;const x=(N,z,T)=>i(r+N,z,T);switch(o){case"scalar":h=Ze.PLAIN,p=dM(u,x);break;case"single-quoted-scalar":h=Ze.QUOTE_SINGLE,p=mM(u,x);break;case"double-quoted-scalar":h=Ze.QUOTE_DOUBLE,p=hM(u,x);break;default:return i(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${o}`),{value:"",type:null,comment:"",range:[r,r+u.length,r+u.length]}}const b=r+u.length,v=Co(d,b,s,i);return{value:p,type:h,comment:v.comment,range:[r,b,v.offset]}}function dM(e,s){let i="";switch(e[0]){case" ":i="a tab character";break;case",":i="flow indicator character ,";break;case"%":i="directive indicator character %";break;case"|":case">":{i=`block scalar indicator ${e[0]}`;break}case"@":case"`":{i=`reserved character ${e[0]}`;break}}return i&&s(0,"BAD_SCALAR_START",`Plain value cannot start with ${i}`),a1(e)}function mM(e,s){return(e[e.length-1]!=="'"||e.length===1)&&s(e.length,"MISSING_CHAR","Missing closing 'quote"),a1(e.slice(1,-1)).replace(/''/g,"'")}function a1(e){let s,i;try{s=new RegExp(`(.*?)(?<![ ])[ ]*\r?
147
- `,"sy"),i=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
148
- `,"sy")}catch{s=/(.*?)[ \t]*\r?\n/sy,i=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=s.exec(e);if(!r)return e;let o=r[1],u=" ",d=s.lastIndex;for(i.lastIndex=d;r=i.exec(e);)r[1]===""?u===`
149
- `?o+=u:u=`
150
- `:(o+=u+r[1],u=" "),d=i.lastIndex;const h=/[ \t]*(.*)/sy;return h.lastIndex=d,r=h.exec(e),o+u+(r?.[1]??"")}function hM(e,s){let i="";for(let r=1;r<e.length-1;++r){const o=e[r];if(!(o==="\r"&&e[r+1]===`
151
- `))if(o===`
152
- `){const{fold:u,offset:d}=fM(e,r);i+=u,r=d}else if(o==="\\"){let u=e[++r];const d=pM[u];if(d)i+=d;else if(u===`
153
- `)for(u=e[r+1];u===" "||u===" ";)u=e[++r+1];else if(u==="\r"&&e[r+1]===`
154
- `)for(u=e[++r+1];u===" "||u===" ";)u=e[++r+1];else if(u==="x"||u==="u"||u==="U"){const h={x:2,u:4,U:8}[u];i+=gM(e,r+1,h,s),r+=h}else{const h=e.substr(r-1,2);s(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${h}`),i+=h}}else if(o===" "||o===" "){const u=r;let d=e[r+1];for(;d===" "||d===" ";)d=e[++r+1];d!==`
155
- `&&!(d==="\r"&&e[r+2]===`
156
- `)&&(i+=r>u?e.slice(u,r+1):o)}else i+=o}return(e[e.length-1]!=='"'||e.length===1)&&s(e.length,"MISSING_CHAR",'Missing closing "quote'),i}function fM(e,s){let i="",r=e[s+1];for(;(r===" "||r===" "||r===`
157
- `||r==="\r")&&!(r==="\r"&&e[s+2]!==`
158
- `);)r===`
159
- `&&(i+=`
160
- `),s+=1,r=e[s+1];return i||(i=" "),{fold:i,offset:s}}const pM={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
161
- `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function gM(e,s,i,r){const o=e.substr(s,i),d=o.length===i&&/^[0-9a-fA-F]+$/.test(o)?parseInt(o,16):NaN;if(isNaN(d)){const h=e.substr(s-2,i+2);return r(s-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${h}`),h}return String.fromCodePoint(d)}function i1(e,s,i,r){const{value:o,type:u,comment:d,range:h}=s.type==="block-scalar"?lM(e,s,r):uM(s,e.options.strict,r),p=i?e.directives.tagName(i.source,v=>r(i,"TAG_RESOLVE_FAILED",v)):null;let x;e.options.stringKeys&&e.atKey?x=e.schema[Vs]:p?x=xM(e.schema,o,p,i,r):s.type==="scalar"?x=yM(e,o,s,r):x=e.schema[Vs];let b;try{const v=x.resolve(o,N=>r(i??s,"TAG_RESOLVE_FAILED",N),e.options);b=Et(v)?v:new Ze(v)}catch(v){const N=v instanceof Error?v.message:String(v);r(i??s,"TAG_RESOLVE_FAILED",N),b=new Ze(o)}return b.range=h,b.source=o,u&&(b.type=u),p&&(b.tag=p),x.format&&(b.format=x.format),d&&(b.comment=d),b}function xM(e,s,i,r,o){if(i==="!")return e[Vs];const u=[];for(const h of e.tags)if(!h.collection&&h.tag===i)if(h.default&&h.test)u.push(h);else return h;for(const h of u)if(h.test?.test(s))return h;const d=e.knownTags[i];return d&&!d.collection?(e.tags.push(Object.assign({},d,{default:!1,test:void 0})),d):(o(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,i!=="tag:yaml.org,2002:str"),e[Vs])}function yM({atKey:e,directives:s,schema:i},r,o,u){const d=i.tags.find(h=>(h.default===!0||e&&h.default==="key")&&h.test?.test(r))||i[Vs];if(i.compat){const h=i.compat.find(p=>p.default&&p.test?.test(r))??i[Vs];if(d.tag!==h.tag){const p=s.tagString(d.tag),x=s.tagString(h.tag),b=`Value may be parsed as either ${p} or ${x}`;u(o,"TAG_RESOLVE_FAILED",b,!0)}}return d}function bM(e,s,i){if(s){i??(i=s.length);for(let r=i-1;r>=0;--r){let o=s[r];switch(o.type){case"space":case"comment":case"newline":e-=o.source.length;continue}for(o=s[++r];o?.type==="space";)e+=o.source.length,o=s[++r];break}}return e}const vM={composeNode:r1,composeEmptyNode:fp};function r1(e,s,i,r){const o=e.atKey,{spaceBefore:u,comment:d,anchor:h,tag:p}=i;let x,b=!0;switch(s.type){case"alias":x=jM(e,s,r),(h||p)&&r(s,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":x=i1(e,s,p,r),h&&(x.anchor=h.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":x=rM(vM,e,s,i,r),h&&(x.anchor=h.source.substring(1));break;default:{const v=s.type==="error"?s.message:`Unsupported token (type: ${s.type})`;r(s,"UNEXPECTED_TOKEN",v),x=fp(e,s.offset,void 0,null,i,r),b=!1}}return h&&x.anchor===""&&r(h,"BAD_ALIAS","Anchor cannot be an empty string"),o&&e.options.stringKeys&&(!Et(x)||typeof x.value!="string"||x.tag&&x.tag!=="tag:yaml.org,2002:str")&&r(p??s,"NON_STRING_KEY","With stringKeys, all keys must be strings"),u&&(x.spaceBefore=!0),d&&(s.type==="scalar"&&s.source===""?x.comment=d:x.commentBefore=d),e.options.keepSourceTokens&&b&&(x.srcToken=s),x}function fp(e,s,i,r,{spaceBefore:o,comment:u,anchor:d,tag:h,end:p},x){const b={type:"scalar",offset:bM(s,i,r),indent:-1,source:""},v=i1(e,b,h,x);return d&&(v.anchor=d.source.substring(1),v.anchor===""&&x(d,"BAD_ALIAS","Anchor cannot be an empty string")),o&&(v.spaceBefore=!0),u&&(v.comment=u,v.range[2]=p),v}function jM({options:e},{offset:s,source:i,end:r},o){const u=new np(i.substring(1));u.source===""&&o(s,"BAD_ALIAS","Alias cannot be an empty string"),u.source.endsWith(":")&&o(s+i.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);const d=s+i.length,h=Co(r,d,e.strict,o);return u.range=[s,d,h.offset],h.comment&&(u.comment=h.comment),u}function NM(e,s,{offset:i,start:r,value:o,end:u},d){const h=Object.assign({_directives:s},e),p=new nd(void 0,h),x={atKey:!1,atRoot:!0,directives:p.directives,options:p.options,schema:p.schema},b=Yr(r,{indicator:"doc-start",next:o??u?.[0],offset:i,onError:d,parentIndent:0,startOnNewline:!0});b.found&&(p.directives.docStart=!0,o&&(o.type==="block-map"||o.type==="block-seq")&&!b.hasNewline&&d(b.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),p.contents=o?r1(x,o,b,d):fp(x,b.end,r,null,b,d);const v=p.contents.range[2],N=Co(u,v,!1,d);return N.comment&&(p.comment=N.comment),p.range=[i,v,N.offset],p}function no(e){if(typeof e=="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];const{offset:s,source:i}=e;return[s,s+(typeof i=="string"?i.length:1)]}function zb(e){let s="",i=!1,r=!1;for(let o=0;o<e.length;++o){const u=e[o];switch(u[0]){case"#":s+=(s===""?"":r?`
162
-
163
- `:`
164
- `)+(u.substring(1)||" "),i=!0,r=!1;break;case"%":e[o+1]?.[0]!=="#"&&(o+=1),i=!1;break;default:i||(r=!0),i=!1}}return{comment:s,afterEmptyLine:r}}class wM{constructor(s={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(i,r,o,u)=>{const d=no(i);u?this.warnings.push(new nM(d,r,o)):this.errors.push(new Zc(d,r,o))},this.directives=new Ln({version:s.version||"1.2"}),this.options=s}decorate(s,i){const{comment:r,afterEmptyLine:o}=zb(this.prelude);if(r){const u=s.contents;if(i)s.comment=s.comment?`${s.comment}
165
- ${r}`:r;else if(o||s.directives.docStart||!u)s.commentBefore=r;else if(Ht(u)&&!u.flow&&u.items.length>0){let d=u.items[0];Qt(d)&&(d=d.key);const h=d.commentBefore;d.commentBefore=h?`${r}
166
- ${h}`:r}else{const d=u.commentBefore;u.commentBefore=d?`${r}
167
- ${d}`:r}}i?(Array.prototype.push.apply(s.errors,this.errors),Array.prototype.push.apply(s.warnings,this.warnings)):(s.errors=this.errors,s.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:zb(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(s,i=!1,r=-1){for(const o of s)yield*this.next(o);yield*this.end(i,r)}*next(s){switch(s.type){case"directive":this.directives.add(s.source,(i,r,o)=>{const u=no(s);u[0]+=i,this.onError(u,"BAD_DIRECTIVE",r,o)}),this.prelude.push(s.source),this.atDirectives=!0;break;case"document":{const i=NM(this.options,this.directives,s,this.onError);this.atDirectives&&!i.directives.docStart&&this.onError(s,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(i,!1),this.doc&&(yield this.doc),this.doc=i,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(s.source);break;case"error":{const i=s.source?`${s.message}: ${JSON.stringify(s.source)}`:s.message,r=new Zc(no(s),"UNEXPECTED_TOKEN",i);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){const r="Unexpected doc-end without preceding document";this.errors.push(new Zc(no(s),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;const i=Co(s.end,s.offset+s.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),i.comment){const r=this.doc.comment;this.doc.comment=r?`${r}
168
- ${i.comment}`:i.comment}this.doc.range[2]=i.offset;break}default:this.errors.push(new Zc(no(s),"UNEXPECTED_TOKEN",`Unsupported token ${s.type}`))}}*end(s=!1,i=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(s){const r=Object.assign({_directives:this.directives},this.options),o=new nd(void 0,r);this.atDirectives&&this.onError(i,"MISSING_CHAR","Missing directives-end indicator line"),o.range=[0,i,i],this.decorate(o,!1),yield o}}}const l1="\uFEFF",o1="",c1="",mf="";function SM(e){switch(e){case l1:return"byte-order-mark";case o1:return"doc-mode";case c1:return"flow-error-end";case mf:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
169
- `:case`\r
170
- `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}function Rs(e){switch(e){case void 0:case" ":case`
171
- `:case"\r":case" ":return!0;default:return!1}}const kb=new Set("0123456789ABCDEFabcdef"),zM=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Fc=new Set(",[]{}"),kM=new Set(` ,[]{}
172
- \r `),Eh=e=>!e||kM.has(e);class CM{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(s,i=!1){if(s){if(typeof s!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+s:s,this.lineEndPos=null}this.atEnd=!i;let r=this.next??"stream";for(;r&&(i||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let s=this.pos,i=this.buffer[s];for(;i===" "||i===" ";)i=this.buffer[++s];return!i||i==="#"||i===`
173
- `?!0:i==="\r"?this.buffer[s+1]===`
174
- `:!1}charAt(s){return this.buffer[this.pos+s]}continueScalar(s){let i=this.buffer[s];if(this.indentNext>0){let r=0;for(;i===" ";)i=this.buffer[++r+s];if(i==="\r"){const o=this.buffer[r+s+1];if(o===`
175
- `||!o&&!this.atEnd)return s+r+1}return i===`
176
- `||r>=this.indentNext||!i&&!this.atEnd?s+r:-1}if(i==="-"||i==="."){const r=this.buffer.substr(s,3);if((r==="---"||r==="...")&&Rs(this.buffer[s+3]))return-1}return s}getLine(){let s=this.lineEndPos;return(typeof s!="number"||s!==-1&&s<this.pos)&&(s=this.buffer.indexOf(`
177
- `,this.pos),this.lineEndPos=s),s===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[s-1]==="\r"&&(s-=1),this.buffer.substring(this.pos,s))}hasChars(s){return this.pos+s<=this.buffer.length}setNext(s){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=s,null}peek(s){return this.buffer.substr(this.pos,s)}*parseNext(s){switch(s){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let s=this.getLine();if(s===null)return this.setNext("stream");if(s[0]===l1&&(yield*this.pushCount(1),s=s.substring(1)),s[0]==="%"){let i=s.length,r=s.indexOf("#");for(;r!==-1;){const u=s[r-1];if(u===" "||u===" "){i=r-1;break}else r=s.indexOf("#",r+1)}for(;;){const u=s[i-1];if(u===" "||u===" ")i-=1;else break}const o=(yield*this.pushCount(i))+(yield*this.pushSpaces(!0));return yield*this.pushCount(s.length-o),this.pushNewline(),"stream"}if(this.atLineEnd()){const i=yield*this.pushSpaces(!0);return yield*this.pushCount(s.length-i),yield*this.pushNewline(),"stream"}return yield o1,yield*this.parseLineStart()}*parseLineStart(){const s=this.charAt(0);if(!s&&!this.atEnd)return this.setNext("line-start");if(s==="-"||s==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");const i=this.peek(3);if((i==="---"||i==="...")&&Rs(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,i==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Rs(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){const[s,i]=this.peek(2);if(!i&&!this.atEnd)return this.setNext("block-start");if((s==="-"||s==="?"||s===":")&&Rs(i)){const r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);const s=this.getLine();if(s===null)return this.setNext("doc");let i=yield*this.pushIndicators();switch(s[i]){case"#":yield*this.pushCount(s.length-i);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Eh),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return i+=yield*this.parseBlockScalarHeader(),i+=yield*this.pushSpaces(!0),yield*this.pushCount(s.length-i),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let s,i,r=-1;do s=yield*this.pushNewline(),s>0?(i=yield*this.pushSpaces(!1),this.indentValue=r=i):i=0,i+=yield*this.pushSpaces(!0);while(s+i>0);const o=this.getLine();if(o===null)return this.setNext("flow");if((r!==-1&&r<this.indentNext&&o[0]!=="#"||r===0&&(o.startsWith("---")||o.startsWith("..."))&&Rs(o[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(o[0]==="]"||o[0]==="}")))return this.flowLevel=0,yield c1,yield*this.parseLineStart();let u=0;for(;o[u]===",";)u+=yield*this.pushCount(1),u+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(u+=yield*this.pushIndicators(),o[u]){case void 0:return"flow";case"#":return yield*this.pushCount(o.length-u),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Eh),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{const d=this.charAt(1);if(this.flowKey||Rs(d)||d===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){const s=this.charAt(0);let i=this.buffer.indexOf(s,this.pos+1);if(s==="'")for(;i!==-1&&this.buffer[i+1]==="'";)i=this.buffer.indexOf("'",i+2);else for(;i!==-1;){let u=0;for(;this.buffer[i-1-u]==="\\";)u+=1;if(u%2===0)break;i=this.buffer.indexOf('"',i+1)}const r=this.buffer.substring(0,i);let o=r.indexOf(`
178
- `,this.pos);if(o!==-1){for(;o!==-1;){const u=this.continueScalar(o+1);if(u===-1)break;o=r.indexOf(`
179
- `,u)}o!==-1&&(i=o-(r[o-1]==="\r"?2:1))}if(i===-1){if(!this.atEnd)return this.setNext("quoted-scalar");i=this.buffer.length}return yield*this.pushToIndex(i+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let s=this.pos;for(;;){const i=this.buffer[++s];if(i==="+")this.blockScalarKeep=!0;else if(i>"0"&&i<="9")this.blockScalarIndent=Number(i)-1;else if(i!=="-")break}return yield*this.pushUntil(i=>Rs(i)||i==="#")}*parseBlockScalar(){let s=this.pos-1,i=0,r;e:for(let u=this.pos;r=this.buffer[u];++u)switch(r){case" ":i+=1;break;case`
180
- `:s=u,i=0;break;case"\r":{const d=this.buffer[u+1];if(!d&&!this.atEnd)return this.setNext("block-scalar");if(d===`
181
- `)break}default:break e}if(!r&&!this.atEnd)return this.setNext("block-scalar");if(i>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=i:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{const u=this.continueScalar(s+1);if(u===-1)break;s=this.buffer.indexOf(`
182
- `,u)}while(s!==-1);if(s===-1){if(!this.atEnd)return this.setNext("block-scalar");s=this.buffer.length}}let o=s+1;for(r=this.buffer[o];r===" ";)r=this.buffer[++o];if(r===" "){for(;r===" "||r===" "||r==="\r"||r===`
183
- `;)r=this.buffer[++o];s=o-1}else if(!this.blockScalarKeep)do{let u=s-1,d=this.buffer[u];d==="\r"&&(d=this.buffer[--u]);const h=u;for(;d===" ";)d=this.buffer[--u];if(d===`
184
- `&&u>=this.pos&&u+1+i>h)s=u;else break}while(!0);return yield mf,yield*this.pushToIndex(s+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){const s=this.flowLevel>0;let i=this.pos-1,r=this.pos-1,o;for(;o=this.buffer[++r];)if(o===":"){const u=this.buffer[r+1];if(Rs(u)||s&&Fc.has(u))break;i=r}else if(Rs(o)){let u=this.buffer[r+1];if(o==="\r"&&(u===`
185
- `?(r+=1,o=`
186
- `,u=this.buffer[r+1]):i=r),u==="#"||s&&Fc.has(u))break;if(o===`
187
- `){const d=this.continueScalar(r+1);if(d===-1)break;r=Math.max(r,d-2)}}else{if(s&&Fc.has(o))break;i=r}return!o&&!this.atEnd?this.setNext("plain-scalar"):(yield mf,yield*this.pushToIndex(i+1,!0),s?"flow":"doc")}*pushCount(s){return s>0?(yield this.buffer.substr(this.pos,s),this.pos+=s,s):0}*pushToIndex(s,i){const r=this.buffer.slice(this.pos,s);return r?(yield r,this.pos+=r.length,r.length):(i&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(Eh))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{const s=this.flowLevel>0,i=this.charAt(1);if(Rs(i)||s&&Fc.has(i))return s?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)==="<"){let s=this.pos+2,i=this.buffer[s];for(;!Rs(i)&&i!==">";)i=this.buffer[++s];return yield*this.pushToIndex(i===">"?s+1:s,!1)}else{let s=this.pos+1,i=this.buffer[s];for(;i;)if(zM.has(i))i=this.buffer[++s];else if(i==="%"&&kb.has(this.buffer[s+1])&&kb.has(this.buffer[s+2]))i=this.buffer[s+=3];else break;return yield*this.pushToIndex(s,!1)}}*pushNewline(){const s=this.buffer[this.pos];return s===`
188
- `?yield*this.pushCount(1):s==="\r"&&this.charAt(1)===`
189
- `?yield*this.pushCount(2):0}*pushSpaces(s){let i=this.pos-1,r;do r=this.buffer[++i];while(r===" "||s&&r===" ");const o=i-this.pos;return o>0&&(yield this.buffer.substr(this.pos,o),this.pos=i),o}*pushUntil(s){let i=this.pos,r=this.buffer[i];for(;!s(r);)r=this.buffer[++i];return yield*this.pushToIndex(i,!1)}}class AM{constructor(){this.lineStarts=[],this.addNewLine=s=>this.lineStarts.push(s),this.linePos=s=>{let i=0,r=this.lineStarts.length;for(;i<r;){const u=i+r>>1;this.lineStarts[u]<s?i=u+1:r=u}if(this.lineStarts[i]===s)return{line:i+1,col:1};if(i===0)return{line:0,col:s};const o=this.lineStarts[i-1];return{line:i,col:s-o+1}}}}function Xa(e,s){for(let i=0;i<e.length;++i)if(e[i].type===s)return!0;return!1}function Cb(e){for(let s=0;s<e.length;++s)switch(e[s].type){case"space":case"comment":case"newline":break;default:return s}return-1}function u1(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Yc(e){switch(e.type){case"document":return e.start;case"block-map":{const s=e.items[e.items.length-1];return s.sep??s.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function Ar(e){if(e.length===0)return[];let s=e.length;e:for(;--s>=0;)switch(e[s].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;e[++s]?.type==="space";);return e.splice(s,e.length)}function Ab(e){if(e.start.type==="flow-seq-start")for(const s of e.items)s.sep&&!s.value&&!Xa(s.start,"explicit-key-ind")&&!Xa(s.sep,"map-value-ind")&&(s.key&&(s.value=s.key),delete s.key,u1(s.value)?s.value.end?Array.prototype.push.apply(s.value.end,s.sep):s.value.end=s.sep:Array.prototype.push.apply(s.start,s.sep),delete s.sep)}class TM{constructor(s){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new CM,this.onNewLine=s}*parse(s,i=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(const r of this.lexer.lex(s,i))yield*this.next(r);i||(yield*this.end())}*next(s){if(this.source=s,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=s.length;return}const i=SM(s);if(i)if(i==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=i,yield*this.step(),i){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+s.length);break;case"space":this.atNewLine&&s[0]===" "&&(this.indent+=s.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=s.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=s.length}else{const r=`Not a YAML token: ${s}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:s}),this.offset+=s.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){const s=this.peek(1);if(this.type==="doc-end"&&s?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!s)return yield*this.stream();switch(s.type){case"document":return yield*this.document(s);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(s);case"block-scalar":return yield*this.blockScalar(s);case"block-map":return yield*this.blockMap(s);case"block-seq":return yield*this.blockSequence(s);case"flow-collection":return yield*this.flowCollection(s);case"doc-end":return yield*this.documentEnd(s)}yield*this.pop()}peek(s){return this.stack[this.stack.length-s]}*pop(s){const i=s??this.stack.pop();if(!i)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield i;else{const r=this.peek(1);switch(i.type==="block-scalar"?i.indent="indent"in r?r.indent:0:i.type==="flow-collection"&&r.type==="document"&&(i.indent=0),i.type==="flow-collection"&&Ab(i),r.type){case"document":r.value=i;break;case"block-scalar":r.props.push(i);break;case"block-map":{const o=r.items[r.items.length-1];if(o.value){r.items.push({start:[],key:i,sep:[]}),this.onKeyLine=!0;return}else if(o.sep)o.value=i;else{Object.assign(o,{key:i,sep:[]}),this.onKeyLine=!o.explicitKey;return}break}case"block-seq":{const o=r.items[r.items.length-1];o.value?r.items.push({start:[],value:i}):o.value=i;break}case"flow-collection":{const o=r.items[r.items.length-1];!o||o.value?r.items.push({start:[],key:i,sep:[]}):o.sep?o.value=i:Object.assign(o,{key:i,sep:[]});return}default:yield*this.pop(),yield*this.pop(i)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(i.type==="block-map"||i.type==="block-seq")){const o=i.items[i.items.length-1];o&&!o.sep&&!o.value&&o.start.length>0&&Cb(o.start)===-1&&(i.indent===0||o.start.every(u=>u.type!=="comment"||u.indent<i.indent))&&(r.type==="document"?r.end=o.start:r.items.push({start:o.start}),i.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{const s={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&s.start.push(this.sourceToken),this.stack.push(s);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(s){if(s.value)return yield*this.lineEnd(s);switch(this.type){case"doc-start":{Cb(s.start)!==-1?(yield*this.pop(),yield*this.step()):s.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":s.start.push(this.sourceToken);return}const i=this.startBlockValue(s);i?this.stack.push(i):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(s){if(this.type==="map-value-ind"){const i=Yc(this.peek(2)),r=Ar(i);let o;s.end?(o=s.end,o.push(this.sourceToken),delete s.end):o=[this.sourceToken];const u={type:"block-map",offset:s.offset,indent:s.indent,items:[{start:r,key:s,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=u}else yield*this.lineEnd(s)}*blockScalar(s){switch(this.type){case"space":case"comment":case"newline":s.props.push(this.sourceToken);return;case"scalar":if(s.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let i=this.source.indexOf(`
190
- `)+1;for(;i!==0;)this.onNewLine(this.offset+i),i=this.source.indexOf(`
191
- `,i)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(s){const i=s.items[s.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,i.value){const r="end"in i.value?i.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):s.items.push({start:[this.sourceToken]})}else i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)s.items.push({start:[this.sourceToken]});else if(i.sep)i.sep.push(this.sourceToken);else{if(this.atIndentedComment(i.start,s.indent)){const o=s.items[s.items.length-2]?.value?.end;if(Array.isArray(o)){Array.prototype.push.apply(o,i.start),o.push(this.sourceToken),s.items.pop();return}}i.start.push(this.sourceToken)}return}if(this.indent>=s.indent){const r=!this.onKeyLine&&this.indent===s.indent,o=r&&(i.sep||i.explicitKey)&&this.type!=="seq-item-ind";let u=[];if(o&&i.sep&&!i.value){const d=[];for(let h=0;h<i.sep.length;++h){const p=i.sep[h];switch(p.type){case"newline":d.push(h);break;case"space":break;case"comment":p.indent>s.indent&&(d.length=0);break;default:d.length=0}}d.length>=2&&(u=i.sep.splice(d[1]))}switch(this.type){case"anchor":case"tag":o||i.value?(u.push(this.sourceToken),s.items.push({start:u}),this.onKeyLine=!0):i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"explicit-key-ind":!i.sep&&!i.explicitKey?(i.start.push(this.sourceToken),i.explicitKey=!0):o||i.value?(u.push(this.sourceToken),s.items.push({start:u,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(i.explicitKey)if(i.sep)if(i.value)s.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Xa(i.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:u,key:null,sep:[this.sourceToken]}]});else if(u1(i.key)&&!Xa(i.sep,"newline")){const d=Ar(i.start),h=i.key,p=i.sep;p.push(this.sourceToken),delete i.key,delete i.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:d,key:h,sep:p}]})}else u.length>0?i.sep=i.sep.concat(u,this.sourceToken):i.sep.push(this.sourceToken);else if(Xa(i.start,"newline"))Object.assign(i,{key:null,sep:[this.sourceToken]});else{const d=Ar(i.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:d,key:null,sep:[this.sourceToken]}]})}else i.sep?i.value||o?s.items.push({start:u,key:null,sep:[this.sourceToken]}):Xa(i.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):i.sep.push(this.sourceToken):Object.assign(i,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const d=this.flowScalar(this.type);o||i.value?(s.items.push({start:u,key:d,sep:[]}),this.onKeyLine=!0):i.sep?this.stack.push(d):(Object.assign(i,{key:d,sep:[]}),this.onKeyLine=!0);return}default:{const d=this.startBlockValue(s);if(d){if(d.type==="block-seq"){if(!i.explicitKey&&i.sep&&!Xa(i.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else r&&s.items.push({start:u});this.stack.push(d);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(s){const i=s.items[s.items.length-1];switch(this.type){case"newline":if(i.value){const r="end"in i.value?i.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):s.items.push({start:[this.sourceToken]})}else i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)s.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(i.start,s.indent)){const o=s.items[s.items.length-2]?.value?.end;if(Array.isArray(o)){Array.prototype.push.apply(o,i.start),o.push(this.sourceToken),s.items.pop();return}}i.start.push(this.sourceToken)}return;case"anchor":case"tag":if(i.value||this.indent<=s.indent)break;i.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==s.indent)break;i.value||Xa(i.start,"seq-item-ind")?s.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return}if(this.indent>s.indent){const r=this.startBlockValue(s);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(s){const i=s.items[s.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(s.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!i||i.sep?s.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return;case"map-value-ind":!i||i.value?s.items.push({start:[],key:null,sep:[this.sourceToken]}):i.sep?i.sep.push(this.sourceToken):Object.assign(i,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!i||i.value?s.items.push({start:[this.sourceToken]}):i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const o=this.flowScalar(this.type);!i||i.value?s.items.push({start:[],key:o,sep:[]}):i.sep?this.stack.push(o):Object.assign(i,{key:o,sep:[]});return}case"flow-map-end":case"flow-seq-end":s.end.push(this.sourceToken);return}const r=this.startBlockValue(s);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{const r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===s.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){const o=Yc(r),u=Ar(o);Ab(s);const d=s.end.splice(1,s.end.length);d.push(this.sourceToken);const h={type:"block-map",offset:s.offset,indent:s.indent,items:[{start:u,key:s,sep:d}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=h}else yield*this.lineEnd(s)}}flowScalar(s){if(this.onNewLine){let i=this.source.indexOf(`
192
- `)+1;for(;i!==0;)this.onNewLine(this.offset+i),i=this.source.indexOf(`
193
- `,i)+1}return{type:s,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(s){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const i=Yc(s),r=Ar(i);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const i=Yc(s),r=Ar(i);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(s,i){return this.type!=="comment"||this.indent<=i?!1:s.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(s){this.type!=="doc-mode"&&(s.end?s.end.push(this.sourceToken):s.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(s){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:s.end?s.end.push(this.sourceToken):s.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function _M(e){const s=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||s&&new AM||null,prettyErrors:s}}function EM(e,s={}){const{lineCounter:i,prettyErrors:r}=_M(s),o=new TM(i?.addNewLine),u=new wM(s),d=Array.from(u.compose(o.parse(e)));if(r&&i)for(const h of d)h.errors.forEach(wb(e,i)),h.warnings.forEach(wb(e,i));return d.length>0?d:Object.assign([],{empty:!0},u.streamInfo())}function DM({onApplied:e}){const[s,i]=j.useState(""),[r,o]=j.useState(!1),[u,d]=j.useState([]),[h,p]=j.useState([]),x=async()=>{if(!s.trim())return;o(!0),d([]),p([]);const b=EM(s),v=[],N=[];for(let z=0;z<b.length;z++){const T=b[z];if(T.errors.length>0){v.push(`Document ${z+1}: ${T.errors[0]?.message}`);continue}const w=T.toJSON();if(!(!w||typeof w!="object"))try{const A=await D2(w);N.push(`Applied "${A.displayName||A.name}" (revision ${A.configRevision})`)}catch(A){v.push(`Document ${z+1}: ${A instanceof Error?A.message:String(A)}`)}}d(N),p(v),o(!1),N.length>0&&(Qe({title:"YAML applied",detail:`Applied ${N.length} document${N.length===1?"":"s"} successfully.`,tone:v.length>0?"caution":"positive",dedupeKey:"yaml:apply",dedupeMode:"replace"}),e())};return t.jsxs("section",{className:"mt-8",children:[t.jsx("div",{className:"page-section-divider"}),t.jsx("div",{className:"section-head mt-6",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Config as code"}),t.jsx("h2",{className:"text-sm font-medium text-zinc-200",children:"Apply YAML"})]})}),t.jsxs("p",{className:"text-zinc-500 text-sm mb-3",children:["Paste a ",t.jsx("code",{className:"text-zinc-400",children:"canonry.yaml"})," config (multi-document YAML with ",t.jsx("code",{className:"text-zinc-400",children:"---"})," separators supported)."]}),t.jsx("textarea",{className:"setup-input w-full font-mono text-xs",rows:10,placeholder:`apiVersion: canonry/v1
194
- kind: Project
195
- metadata:
196
- name: my-project
197
- spec:
198
- canonicalDomain: example.com
199
- country: US
200
- language: en
201
- queries: []`,value:s,onChange:b=>i(b.target.value)}),u.length>0&&t.jsx("ul",{className:"mt-2 space-y-1",children:u.map((b,v)=>t.jsx("li",{className:"text-emerald-400 text-sm",children:b},v))}),h.length>0&&t.jsx("ul",{className:"mt-2 space-y-1",children:h.map((b,v)=>t.jsx("li",{className:"text-rose-400 text-sm",children:b},v))}),t.jsx("div",{className:"mt-3",children:t.jsx(ee,{type:"button",disabled:!s.trim()||r,onClick:Le(x),children:r?"Applying...":"Apply"})})]})}function OM(){const{dashboard:e,isLoading:s,refetch:i}=Pi();if(!e||s)return t.jsxs("div",{className:"page-skeleton",children:[t.jsxs("div",{className:"page-skeleton-header",children:[t.jsx("div",{className:"skeleton-text h-6 w-28"}),t.jsx("div",{className:"skeleton-text-sm w-40"})]}),t.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 overflow-hidden",children:[t.jsx("div",{className:"p-3 border-b border-zinc-800/60 flex gap-8",children:["Name","Domain","Mentions","Last run","Country"].map(_=>t.jsx("div",{className:"skeleton-text-sm w-16"},_))}),[1,2,3].map(_=>t.jsxs("div",{className:"p-3 border-b border-zinc-800/40 flex gap-8 items-center",children:[t.jsxs("div",{className:"flex-1 space-y-1",children:[t.jsx("div",{className:"skeleton-text w-28"}),t.jsx("div",{className:"skeleton-text-sm w-16"})]}),t.jsx("div",{className:"skeleton-text w-24"}),t.jsx("div",{className:"skeleton h-5 w-14 rounded-full"}),t.jsx("div",{className:"skeleton h-5 w-16 rounded-full"}),t.jsx("div",{className:"skeleton-text-sm w-8"})]},_))]})]});const r=e.projects,o=bo(),[u,d]=j.useState(!1),[h,p]=j.useState(""),[x,b]=j.useState(""),[v,N]=j.useState(""),[z,T]=j.useState("US"),[w,A]=j.useState("en"),[D,U]=j.useState(!1),[I,C]=j.useState(null),L=h.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),M=async()=>{if(!(!L||!v)){U(!0),C(null);try{const _=await vo(L,{displayName:x||h,canonicalDomain:v,country:z,language:w});Qe({title:"Project created",detail:`${_.displayName||_.name} is ready to configure.`,tone:"positive",dedupeKey:`project:create:${_.name}`,dedupeMode:"drop"}),i(),p(""),b(""),N(""),T("US"),A("en"),d(!1),o({to:"/projects/$projectId",params:{projectId:_.id}})}catch(_){C(_ instanceof Error?_.message:"Failed to create project")}finally{U(!1)}}};return t.jsxs("div",{className:"page-container",children:[t.jsxs("div",{className:"page-header",children:[t.jsxs("div",{className:"page-header-left",children:[t.jsx("h1",{className:"page-title",children:"Projects"}),t.jsxs("p",{className:"page-subtitle",children:[r.length," project",r.length!==1?"s":""," tracked"]})]}),t.jsx("div",{className:"page-header-right",children:t.jsxs(ee,{type:"button",onClick:()=>d(_=>!_),children:[t.jsx(pu,{className:"size-4 mr-1.5"}),"Add project"]})})]}),u?t.jsxs(Se,{className:"surface-card mb-6",children:[t.jsx("div",{className:"section-head",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"New project"}),t.jsx("h2",{className:"text-sm font-medium text-zinc-200",children:"Create a new monitoring project"})]})}),t.jsxs("div",{className:"compact-stack mt-4",children:[t.jsxs("div",{className:"setup-field-row",children:[t.jsxs("div",{className:"setup-field",children:[t.jsx("label",{className:"setup-label",htmlFor:"new-project-name",children:"Project name"}),t.jsx("input",{id:"new-project-name",className:"setup-input",type:"text",placeholder:"my-project",value:h,onChange:_=>p(_.target.value)}),L&&L!==h?t.jsxs("p",{className:"supporting-copy",children:["Slug: ",L]}):null]}),t.jsxs("div",{className:"setup-field",children:[t.jsx("label",{className:"setup-label",htmlFor:"new-display-name",children:"Display name"}),t.jsx("input",{id:"new-display-name",className:"setup-input",type:"text",placeholder:"My Project",value:x,onChange:_=>b(_.target.value)})]})]}),t.jsxs("div",{className:"setup-field",children:[t.jsx("label",{className:"setup-label",htmlFor:"new-domain",children:"Canonical domain"}),t.jsx("input",{id:"new-domain",className:"setup-input",type:"text",placeholder:"example.com",value:v,onChange:_=>N(_.target.value)})]}),t.jsxs("div",{className:"setup-field-row",children:[t.jsxs("div",{className:"setup-field",children:[t.jsx("label",{className:"setup-label",htmlFor:"new-country",children:"Country"}),t.jsx("input",{id:"new-country",className:"setup-input",type:"text",placeholder:"US",maxLength:2,value:z,onChange:_=>T(_.target.value.toUpperCase())})]}),t.jsxs("div",{className:"setup-field",children:[t.jsx("label",{className:"setup-label",htmlFor:"new-language",children:"Language"}),t.jsx("input",{id:"new-language",className:"setup-input",type:"text",placeholder:"en",maxLength:5,value:w,onChange:_=>A(_.target.value.toLowerCase())})]})]})]}),I?t.jsx("p",{className:"text-rose-400 text-sm mt-3",children:I}):null,t.jsxs("div",{className:"flex items-center gap-3 mt-4",children:[t.jsx(ee,{type:"button",disabled:!L||!v||D,onClick:Le(M),children:D?"Creating...":"Create project"}),t.jsx(ee,{type:"button",variant:"ghost",onClick:()=>d(!1),children:"Cancel"})]})]}):null,r.length>0?t.jsx("div",{className:"data-table-wrapper",children:t.jsxs("table",{className:"data-table",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"Name"}),t.jsx("th",{children:"Domain"}),t.jsx("th",{children:"Mentions"}),t.jsx("th",{children:"Last run"}),t.jsx("th",{className:"text-right",children:"Country"})]})}),t.jsx("tbody",{children:r.map(_=>{const B=_.recentRuns[0];return t.jsxs("tr",{className:"cursor-pointer",onClick:()=>{o({to:"/projects/$projectId",params:{projectId:_.project.id}})},children:[t.jsxs("td",{children:[t.jsx(ft,{to:"/projects/$projectId",params:{projectId:_.project.id},className:"text-zinc-100 font-medium hover:underline",onClick:J=>J.stopPropagation(),children:_.project.displayName||_.project.name}),t.jsx("p",{className:"text-[11px] text-zinc-500",children:_.project.name})]}),t.jsx("td",{className:"text-zinc-400",children:_.project.canonicalDomain}),t.jsx("td",{children:t.jsx(Ke,{tone:_.mentionSummary.tone,children:_.mentionSummary.value})}),t.jsx("td",{className:"text-zinc-500 text-sm",children:B?t.jsx(Uu,{status:B.status}):t.jsx("span",{className:"text-zinc-600",children:"No runs"})}),t.jsx("td",{className:"text-right text-zinc-500",children:_.project.country})]},_.project.id)})})]})}):u?null:t.jsxs(Se,{className:"surface-card empty-card",children:[t.jsx("h3",{children:"No projects yet"}),t.jsx("p",{className:"supporting-copy",children:"Create your first monitoring project to start tracking AI visibility."}),t.jsxs(ee,{type:"button",onClick:()=>d(!0),children:[t.jsx(pu,{className:"size-4 mr-1.5"}),"Add project"]})]}),t.jsx(DM,{onApplied:()=>{i()}})]})}function hf({state:e,label:s}){return t.jsx(Ke,{tone:QO(e),children:s??$u(e)})}function d1({run:e}){const{openRun:s}=tl();return t.jsxs("article",{className:"run-row",children:[t.jsxs("div",{className:"run-row-main",children:[t.jsxs("div",{className:"run-row-head",children:[t.jsxs("div",{children:[t.jsx("p",{className:"run-row-title",children:e.summary}),t.jsxs("p",{className:"run-row-subtitle",children:[e.projectName,e.location?` · ${e.location}`:""," · ",e.kindLabel]})]}),t.jsx(Uu,{status:e.status})]}),t.jsx("p",{className:"run-row-detail",children:e.statusDetail})]}),t.jsxs("dl",{className:"run-row-meta",children:[t.jsxs("div",{children:[t.jsx("dt",{children:"Started"}),t.jsx("dd",{children:e.startedAt})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Duration"}),t.jsx("dd",{children:e.duration})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Trigger"}),t.jsx("dd",{children:e.triggerLabel})]})]}),t.jsx(ee,{variant:"outline",size:"sm",type:"button",onClick:()=>s(e.id),children:"View run"})]})}function Tb({history:e,maxDots:s=12}){const i=e.slice(-s);if(i.length===0)return t.jsx("span",{className:"text-[11px] text-zinc-600",children:"No data"});const r={cited:"bg-emerald-400","not-cited":"bg-zinc-600",lost:"bg-rose-400",emerging:"bg-amber-400 ring-1 ring-amber-300/60"},o=new Date(i[0].createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric"}),u=new Date(i[i.length-1].createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric"});return t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-[9px] text-zinc-600 shrink-0",children:o}),t.jsx("div",{className:"flex items-center gap-[3px]",title:`${i.length} runs`,children:i.map((d,h)=>t.jsx("div",{className:`h-2.5 w-2.5 rounded-sm ${r[d.citationState]??"bg-zinc-700"} ${d.model&&h>0&&i[h-1]?.model&&i[h-1].model!==d.model?"ring-1 ring-amber-300/80 ring-offset-1 ring-offset-zinc-950":""}`,title:[d.citationState,new Date(d.createdAt).toLocaleDateString(),d.model?`model ${d.model}`:null,d.model&&h>0&&i[h-1]?.model&&i[h-1].model!==d.model?"model changed":null].filter(Boolean).join(" — ")},h))}),t.jsx("span",{className:"text-[9px] text-zinc-600 shrink-0",children:u})]})}function RM(e){const s=new Map;for(const r of e)for(const o of r.runHistory){const u=s.get(o.createdAt);u?u.states.push(o.citationState):s.set(o.createdAt,{states:[o.citationState],runId:o.runId})}return[...s.entries()].sort(([r],[o])=>r.localeCompare(o)).map(([r,{states:o,runId:u}])=>({runId:u,createdAt:r,citationState:o.includes("cited")?"cited":o.includes("emerging")?"emerging":"not-cited"}))}const LM=320;function _b(e,s){return s==="citations"?e.citationState:e.visibilityState==="pending"||e.answerMentioned==null&&e.visibilityState==null?"pending":e.visibilityState==="visible"||e.answerMentioned===!0?"cited":"not-cited"}function Eb(e,s){if(s==="mentions")switch(e){case"cited":return"Mentioned";case"not-cited":return"Not Mentioned";case"pending":return"Pending";case"emerging":return"Newly Mentioned";case"lost":return"No Longer Mentioned"}switch(e){case"cited":return"Cited";case"not-cited":return"Not Cited";case"lost":return"Lost";case"emerging":return"Emerging";case"pending":return"Pending"}}function Db(e,s){const i=s==="mentions"?"mentioned":"cited",r=s==="mentions"?"Mentioned":"Cited";if(e.length===0)return"Awaiting first run";if(e.length===1)return"First observation";const o=e[e.length-1].citationState,u=e[e.length-2].citationState;if(u!=="cited"&&o==="cited")return`Newly ${i}`;if(u==="cited"&&o!=="cited")return"Lost since last run";let d=0;for(let h=e.length-1;h>=0&&e[h].citationState===o;h--)d++;return o==="cited"?d<=1?`${r} in latest run`:`${r} for ${d} runs`:d<=1?`Not ${i} in latest run`:`Not ${i} across ${d} runs`}function MM(e,s){return s==="citations"?e:e.map(i=>({...i,citationState:_b(i,s),runHistory:i.runHistory.map(r=>({...r,citationState:_b(r,s)}))}))}function $M({evidence:e,compareLocations:s=!1,defaultDensity:i="detailed"}){const{openEvidence:r}=tl(),[o,u]=j.useState(new Set),[d,h]=j.useState("mentions"),[p,x]=j.useState(i),b=j.useMemo(()=>{const w=MM(e,d),A=new Map;for(const D of w){const U=D.query,I=s?D.location??null:null,C=s?JSON.stringify([U,I]):U,L=A.get(C)??{key:C,phrase:U,location:I,items:[]};L.items.push(D),A.set(C,L)}return[...A.values()]},[e,d,s]),v=w=>{u(A=>{const D=new Set(A);return D.has(w)?D.delete(w):D.add(w),D})},N=d==="mentions"?"mentioned":"cited",z=d==="mentions"?"Mention History":"Citation History",T=d==="mentions"?"mentioned":"cited";return t.jsxs("div",{children:[t.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"View by"}),t.jsxs("div",{className:"inline-flex gap-0.5 p-0.5 rounded-md bg-zinc-900/60 border border-zinc-800/40",role:"tablist","aria-label":"Citation tracking view",children:[t.jsx("button",{type:"button",role:"tab","aria-selected":d==="mentions",className:`px-2.5 py-1 text-xs font-medium rounded transition-colors ${d==="mentions"?"bg-zinc-800 text-zinc-100":"text-zinc-400 hover:text-zinc-200"}`,onClick:()=>h("mentions"),children:"Mentions"}),t.jsx("button",{type:"button",role:"tab","aria-selected":d==="citations",className:`px-2.5 py-1 text-xs font-medium rounded transition-colors ${d==="citations"?"bg-zinc-800 text-zinc-100":"text-zinc-400 hover:text-zinc-200"}`,onClick:()=>h("citations"),children:"Citations"})]}),t.jsx("span",{className:"text-[11px] text-zinc-500",children:d==="mentions"?"Brand or domain in answer text":"Brand or domain in source links"}),t.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[t.jsx("button",{type:"button",className:"text-[11px] text-zinc-400 hover:text-zinc-200",onClick:()=>{u(w=>w.size===b.length?new Set:new Set(b.map(A=>A.key)))},children:o.size===b.length&&b.length>0?"Collapse all":"Expand all"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Density"}),t.jsxs("div",{className:"inline-flex gap-0.5 p-0.5 rounded-md bg-zinc-900/60 border border-zinc-800/40",role:"tablist","aria-label":"Evidence row density",children:[t.jsx("button",{type:"button",role:"tab","aria-selected":p==="compact",className:`px-2.5 py-1 text-xs font-medium rounded transition-colors ${p==="compact"?"bg-zinc-800 text-zinc-100":"text-zinc-400 hover:text-zinc-200"}`,onClick:()=>x("compact"),children:"Compact"}),t.jsx("button",{type:"button",role:"tab","aria-selected":p==="detailed",className:`px-2.5 py-1 text-xs font-medium rounded transition-colors ${p==="detailed"?"bg-zinc-800 text-zinc-100":"text-zinc-400 hover:text-zinc-200"}`,onClick:()=>x("detailed"),children:"Detailed"})]})]})]})]}),t.jsx("div",{className:"evidence-table-wrap",children:t.jsxs("table",{className:"evidence-table",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{style:{width:"2rem"}}),t.jsx("th",{children:"Query"}),t.jsx("th",{children:"Status"}),t.jsx("th",{children:z}),t.jsx("th",{children:"Change"}),t.jsx("th",{})]})}),t.jsx("tbody",{children:b.map(({key:w,phrase:A,location:D,items:U})=>{const I=o.has(w),C=U.map(J=>J.citationState),L=C.includes("cited")?"cited":C.includes("emerging")?"emerging":C.includes("lost")?"lost":C.every(J=>J==="pending")?"pending":"not-cited",M=RM(U),_=U.filter(J=>J.citationState===po.cited||J.citationState==="emerging").length,B=Db(M,d);return t.jsxs(j.Fragment,{children:[t.jsxs("tr",{className:"evidence-phrase-row cursor-pointer hover:bg-zinc-800/40",onClick:()=>v(w),"aria-expanded":I,children:[t.jsx("td",{children:t.jsx(jo,{size:14,className:`transition-transform duration-150 text-zinc-500 ${I?"rotate-90":""}`})}),t.jsx("td",{className:"evidence-query-cell",children:t.jsxs("div",{children:[t.jsx("span",{className:"font-medium text-zinc-100",children:A}),s&&t.jsx("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-zinc-500",children:D??"No location"}),t.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:U.map(J=>t.jsx($i,{provider:J.provider},J.id))})]})}),t.jsx("td",{children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(hf,{state:L,label:Eb(L,d)}),t.jsxs("span",{className:"text-[11px] text-zinc-500",title:`${_} of ${U.length} engines ${T}`,children:[_,"/",U.length]})]})}),t.jsx("td",{children:t.jsx(Tb,{history:M})}),t.jsx("td",{className:"evidence-change-cell",children:B}),t.jsx("td",{})]}),I&&U.map(J=>t.jsxs(j.Fragment,{children:[t.jsxs("tr",{className:"bg-zinc-900/30",children:[t.jsx("td",{}),t.jsx("td",{className:"evidence-query-cell pl-5",children:t.jsx($i,{provider:J.provider})}),t.jsx("td",{children:t.jsx(hf,{state:J.citationState,label:Eb(J.citationState,d)})}),t.jsx("td",{children:t.jsx(Tb,{history:J.runHistory})}),t.jsx("td",{className:"evidence-change-cell",children:Db(J.runHistory,d)}),t.jsx("td",{children:t.jsx(ee,{variant:"ghost",size:"sm",type:"button",onClick:ue=>{ue.stopPropagation(),r(J.id)},children:"View"})})]}),p==="detailed"&&t.jsxs("tr",{className:"bg-zinc-900/20",children:[t.jsx("td",{}),t.jsx("td",{colSpan:5,className:"px-5 pb-4",children:t.jsx(IM,{item:J,onViewFull:()=>r(J.id)})})]})]},J.id))]},w)})})]})}),t.jsxs("p",{className:"sr-only","aria-live":"polite",children:["Showing ",N==="cited"?"citations (sources)":"mentions (answer text)","."]})]})}function BM(e){const s=(e.matchedTerms??[]).filter(o=>o.trim().length>2),i=[...e.competitorDomains.flatMap(o=>{const u=xj(o);return u.length>=4?[u]:[]}),...e.recommendedCompetitors??[]].filter(o=>o.trim().length>2),r=[];return s.length>0&&r.push({terms:s,className:"answer-highlight-brand"}),i.length>0&&r.push({terms:i,className:"answer-highlight-competitor"}),r}function qM(e,s){if(e.length<=s)return{body:e,truncated:!1};const i=e.lastIndexOf(" ",s);return{body:`${e.slice(0,i>s-40?i:s).trimEnd()}…`,truncated:!0}}function IM({item:e,onViewFull:s}){if(!(e.answerSnippet.trim().length>0))return t.jsx("p",{className:"text-[11px] text-zinc-500 italic",children:"No answer text captured for this run."});const{body:r,truncated:o}=qM(e.answerSnippet,LM),u=BM(e);return t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Answer text"}),t.jsx("p",{className:"text-sm leading-relaxed text-zinc-300",children:nf(r,u)}),(e.citedDomains.length>0||e.competitorDomains.length>0)&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.citedDomains.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Cited:"}),e.citedDomains.slice(0,6).map(d=>t.jsx("span",{className:"rounded-full border border-zinc-700/60 bg-zinc-900/60 px-2 py-0.5 text-[11px] text-zinc-300",children:d},`c-${d}`)),e.citedDomains.length>6&&t.jsxs("span",{className:"text-[10px] text-zinc-500",children:["+",e.citedDomains.length-6," more"]})]}),e.competitorDomains.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-rose-500/80",children:"Competitors:"}),e.competitorDomains.slice(0,4).map(d=>t.jsx("span",{className:"rounded-full border border-rose-900/40 bg-rose-950/30 px-2 py-0.5 text-[11px] text-rose-300",children:d},`co-${d}`)),e.competitorDomains.length>4&&t.jsxs("span",{className:"text-[10px] text-zinc-500",children:["+",e.competitorDomains.length-4," more"]})]})]}),o&&t.jsx("button",{type:"button",className:"text-[11px] font-medium text-emerald-400 hover:text-emerald-300",onClick:d=>{d.stopPropagation(),s()},children:"View full answer →"})]})}function UM({competitors:e,onSelectCompetitor:s,activeFilter:i}){if(e.length===0)return t.jsx("p",{className:"text-sm text-zinc-500",children:"No competitors configured. Add competitors to track overlap."});const r=s!=null;return t.jsx("div",{className:"competitor-table-wrap",children:t.jsxs("table",{className:"competitor-table",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"Domain"}),t.jsx("th",{children:"Pressure"}),t.jsx("th",{children:"Citations"}),t.jsx("th",{children:"Queries"})]})}),t.jsx("tbody",{children:e.map(o=>{const u=i!=null&&i.toLowerCase()===o.domain.toLowerCase(),d=[r?"cursor-pointer hover:bg-zinc-800/30 transition-colors":"",u?"bg-rose-950/20":""].filter(Boolean).join(" ");return t.jsxs("tr",{className:d,onClick:r?()=>s(o.domain):void 0,title:r?`Filter answers to queries where ${o.domain} surfaced`:void 0,children:[t.jsx("td",{className:"font-medium text-zinc-100",children:o.domain}),t.jsx("td",{children:t.jsx(Ke,{tone:ZO(o.pressureLabel),children:o.pressureLabel})}),t.jsx("td",{className:"text-zinc-300 tabular-nums",children:o.totalQueries>0?`${o.citationCount} / ${o.totalQueries}`:"—"}),t.jsx("td",{className:"text-zinc-500 text-xs",children:o.citedQueries.length>0?o.citedQueries.join(", "):"Not cited"})]},o.id)})})]})})}function Ob({eyebrow:e,title:s,status:i,tone:r,targetLabel:o,targetValue:u,coverageValue:d,note:h,updatedAt:p,active:x,onClick:b}){return t.jsxs("button",{type:"button",onClick:b,className:`surface-card w-full text-left transition-colors ${x?"border-zinc-200 bg-zinc-900/50":"hover:border-zinc-700 hover:bg-zinc-900/40"}`,children:[t.jsxs("div",{className:"section-head",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:e}),t.jsx("h3",{children:s})]}),t.jsx(Ke,{tone:r,children:i})]}),t.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[t.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/20 p-3",children:[t.jsx("p",{className:"text-xs uppercase tracking-wide text-zinc-500",children:o}),t.jsx("p",{className:"mt-1 truncate text-sm text-zinc-200",children:u})]}),t.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/20 p-3",children:[t.jsx("p",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Coverage"}),t.jsx("p",{className:"mt-1 text-sm text-zinc-200",children:d})]})]}),t.jsxs("div",{className:"mt-3 flex flex-col gap-1 text-xs text-zinc-500 sm:flex-row sm:items-center sm:justify-between",children:[t.jsx("span",{children:h}),t.jsx("span",{children:p?`Updated ${$s(p)}`:"No recent sync yet"})]})]})}function Xc({label:e,value:s,tone:i}){const r=i==="positive"?"text-emerald-400":i==="negative"?"text-rose-400":"text-zinc-200";return t.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/20 p-3",children:[t.jsx("p",{className:"text-xs uppercase tracking-wide text-zinc-500",children:e}),t.jsx("p",{className:`mt-2 text-2xl font-semibold ${r}`,children:s})]})}const Pr={contentStyle:{backgroundColor:"#18181b",border:"1px solid #3f3f46",borderRadius:8,fontSize:12},labelStyle:{color:"#e4e4e7"},itemStyle:{color:"#a1a1aa"}},ei={fill:"#71717a",fontSize:11},PM="#27272a",Xr="#27272a",Gr=["#34d399","#60a5fa","#f472b6","#facc15","#a78bfa","#fb923c","#22d3ee","#f87171"];function m1(e){const s=String(e);return s.includes("T")?new Date(s):new Date(s+"T00:00:00")}function ff(e){return m1(String(e)).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function pf(e){const s=m1(e);return`${s.getMonth()+1}/${s.getDate()}`}function pp(e){switch(e){case ro.connected:return"positive";case ro.paused:return"caution";case ro.error:return"negative";case ro.archived:return"neutral"}}function GM(e){const s={};return e.sourceId&&(s.sourceId=e.sourceId),e.sinceMinutes!==void 0&&(s.since=new Date(Date.now()-e.sinceMinutes*6e4).toISOString()),e.limit!==void 0&&(s.limit=String(e.limit)),s}function sd(e){e.invalidateQueries({predicate:s=>{const i=s.queryKey[0];return typeof i?._id=="string"&&i._id.startsWith("getApiV1ProjectsByNameTraffic")}})}function VM(e){return tn({...OO({client:ae,path:{name:e??""}}),enabled:!!e,staleTime:pa})}function HM(e){return tn({...LO({client:ae,path:{name:e??""}}),enabled:!!e,staleTime:pa})}function KM(e,s){return tn({...Wj({client:ae,path:{name:e??"",id:s??""}}),enabled:!!(e&&s),staleTime:pa})}function QM(e,s){return tn({...BO({client:ae,path:{name:e??""},query:GM(s)}),enabled:!!e,staleTime:pa})}function ZM(e){const s=wn();return bs({mutationFn:i=>{if(!e)throw new Error("Project is required to connect a Cloud Run source");return nC(e,i)},onSuccess:()=>{e&&sd(s)}})}function FM(e){const s=wn();return bs({mutationFn:i=>{if(!e)throw new Error("Project is required to connect a WordPress source");return sC(e,i)},onSuccess:()=>{e&&sd(s)}})}function YM(e){const s=wn();return bs({mutationFn:i=>{if(!e)throw new Error("Project is required to connect a Vercel source");return aC(e,i)},onSuccess:()=>{e&&sd(s)}})}function XM(e,s){const i=wn();return bs({mutationFn:r=>{if(!e||!s)throw new Error("Project and sourceId are required to sync");return iC(e,s,r??void 0)},onSuccess:()=>{e&&(sd(i),i.invalidateQueries({queryKey:No({client:ae})}))}})}const JM=6,Jr="__other__",Vr="_socialTotal";function WM(e,s=JM){const i=new Map;for(const b of e)i.set(b.source,(i.get(b.source)??0)+b.sessions);const r=[...i.entries()].sort((b,v)=>v[1]!==b[1]?v[1]-b[1]:b[0].localeCompare(v[0])),o=r.slice(0,s),u=new Set(o.map(([b])=>b)),d=Math.max(0,r.length-s),h=new Map;for(const b of e){let v=h.get(b.date);v||(v={date:b.date,[Vr]:0},h.set(b.date,v));const N=u.has(b.source)?b.source:Jr;v[N]=(v[N]??0)+b.sessions,v[Vr]=(v[Vr]??0)+b.sessions}const p=[...h.values()].sort((b,v)=>String(b.date).localeCompare(String(v.date))),x=o.map(([b])=>b);return d>0&&x.push(Jr),{data:p,sources:x,otherCount:d}}function Hr(e){return e.replace(/\+/g," ")}function h1(e,s=30){return e.length<=s?e:e.slice(0,Math.max(1,s-1))+"…"}const e$=["7d","30d","90d","all"],Ja=Gr,gf="#71717a",f1="#52525b",so=25;function Jc(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function p1(e){const s=Date.now()-new Date(e).getTime(),i=Math.floor(s/6e4);if(i<1)return"just now";if(i<60)return`${i}m ago`;const r=Math.floor(i/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function t$({projectName:e}){const{data:s,isLoading:i,isError:r}=HM(e);if(i)return t.jsx(Se,{className:"p-5",children:t.jsx("div",{className:"text-sm text-zinc-500",children:"Loading server activity…"})});if(r)return t.jsx(Se,{className:"p-5",children:t.jsx("div",{className:"text-sm text-rose-400",children:"Failed to load server activity."})});const o=s?.sources??[];return t.jsxs("section",{children:[t.jsx("div",{className:"flex items-baseline justify-between mb-3",children:t.jsxs("div",{children:[t.jsx("div",{className:"eyebrow",children:"Server activity (last 24h)"}),t.jsx("h2",{className:"text-lg font-semibold text-zinc-50",children:"Engine crawler hits & AI-referral sessions"}),t.jsxs("p",{className:"text-xs text-zinc-500 mt-1",children:["Server-side log evidence of bots crawling the site and AI-referral sessions — orthogonal to GA4 click-through traffic below. "," ",t.jsx(ft,{to:"/traffic",className:"text-blue-400 hover:underline",children:"Manage sources →"})]})]})}),o.length===0?t.jsx(Se,{className:"p-5",children:t.jsxs("div",{className:"text-sm text-zinc-400",children:["No server traffic source connected yet."," ",t.jsx(ft,{to:"/traffic",className:"text-blue-400 hover:underline",children:"Connect a traffic source"})," ","to surface bot crawls and AI referrals straight from server logs."]})}):t.jsx(Se,{className:"overflow-hidden",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-zinc-900/50 text-[10px] uppercase tracking-wide text-zinc-500",children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Source"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Status"}),t.jsx("th",{className:"text-right px-4 py-2 font-medium",children:"Crawler hits 24h"}),t.jsx("th",{className:"text-right px-4 py-2 font-medium",children:"AI sessions 24h"}),t.jsx("th",{className:"text-right px-4 py-2 font-medium",children:"Last sync"}),t.jsx("th",{className:"text-left px-4 py-2 font-medium","aria-label":"open"})]})}),t.jsx("tbody",{children:o.map(u=>t.jsxs("tr",{className:"border-t border-zinc-800/60",children:[t.jsx("td",{className:"px-4 py-3 text-zinc-100",children:u.displayName}),t.jsx("td",{className:"px-4 py-3",children:t.jsx(Ke,{tone:pp(u.status),children:u.status})}),t.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-zinc-100",children:u.totals24h.crawlerHits.toLocaleString("en-US")}),t.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-zinc-100",children:u.totals24h.aiReferralHits.toLocaleString("en-US")}),t.jsx("td",{className:"px-4 py-3 text-right text-zinc-400 text-xs",children:u.lastSyncedAt?p1(u.lastSyncedAt):"never"}),t.jsx("td",{className:"px-4 py-3 text-right",children:t.jsx(ft,{to:"/traffic/$projectName/$sourceId",params:{projectName:e,sourceId:u.id},className:"text-blue-400 hover:underline text-xs",children:"Detail →"})})]},u.id))})]})})]})}function n$({projectName:e}){return t.jsxs("div",{className:"space-y-10",children:[t.jsx(t$,{projectName:e}),t.jsx(s$,{projectName:e})]})}function s$({projectName:e}){const s=wn(),[i,r]=j.useState(null),[o,u]=j.useState(null),[d,h]=j.useState(!0),[p,x]=j.useState(!1),[b,v]=j.useState(!1),[N,z]=j.useState(null),[T,w]=j.useState(null),[A,D]=j.useState("sessions"),[U,I]=j.useState("desc"),[C,L]=j.useState("sessions"),[M,_]=j.useState("desc"),[B,J]=j.useState("sessions"),[ue,P]=j.useState("desc"),[ie,te]=j.useState("sessions"),[ze,ve]=j.useState("desc"),[V,ne]=j.useState([]),[me,Ne]=j.useState([]),[se,pe]=j.useState([]),[E,X]=j.useState(!1),[Y,ye]=j.useState("30d");async function le(he){h(!0),z(null);try{const qe=await s.fetchQuery({...bO({client:ae,path:{name:e}}),staleTime:pa});if(he.current)return;if(r(qe),!qe.connected){u(null),ne([]),Ne([]),pe([]),h(!1);return}const De=Y==="all"?void 0:Y,[Ge,Xe,fe,$e]=await Promise.all([s.fetchQuery({...jO({client:ae,path:{name:e},query:De?{window:De}:void 0}),staleTime:pa}).then(We=>We),s.fetchQuery({...wO({client:ae,path:{name:e},query:De?{window:De}:void 0}),staleTime:pa}).catch(()=>[]),s.fetchQuery({...CO({client:ae,path:{name:e},query:De?{window:De}:void 0}),staleTime:pa}).catch(()=>[]),s.fetchQuery({...zO({client:ae,path:{name:e},query:De?{window:De}:void 0}),staleTime:pa}).catch(()=>[])]);if(he.current)return;u(Ge),ne(Xe),Ne(fe),pe($e),h(!1)}catch(qe){if(he.current)return;z(qe instanceof Error?qe.message:"Failed to load GA4 data"),h(!1)}}j.useEffect(()=>{const he={current:!1};return le(he),()=>{he.current=!0}},[e,Y,s]);async function Re(){x(!0),z(null),w(null);try{const he=await Sv(e);w(`Synced ${he.rowCount.toLocaleString()} page rows, ${he.aiReferralCount.toLocaleString()} AI and ${he.socialReferralCount.toLocaleString()} social referral rows (${he.days} days)`),await s.invalidateQueries({predicate:qe=>{const De=qe.queryKey[0];return typeof De?._id=="string"&&De._id.startsWith("getApiV1ProjectsByNameGa")}}),await le({current:!1})}catch(he){z(he instanceof Error?he.message:"Sync failed")}finally{x(!1)}}async function tt(){v(!0),z(null),w(null);try{await tC(e),await s.invalidateQueries({predicate:he=>{const qe=he.queryKey[0];return typeof qe?._id=="string"&&qe._id.startsWith("getApiV1ProjectsByNameGa")}}),r({connected:!1,propertyId:null,clientEmail:null,lastSyncedAt:null,createdAt:null,updatedAt:null}),u(null),w("GA4 disconnected")}catch(he){z(he instanceof Error?he.message:"Disconnect failed")}finally{v(!1)}}function we(he){A===he?I(qe=>qe==="desc"?"asc":"desc"):(D(he),I("desc"))}function Ue(he){C===he?_(qe=>qe==="desc"?"asc":"desc"):(L(he),_("desc"))}function Ce(he){B===he?P(qe=>qe==="desc"?"asc":"desc"):(J(he),P("desc"))}function mt(he){ie===he?ve(qe=>qe==="desc"?"asc":"desc"):(te(he),ve("desc"))}const Nt=j.useMemo(()=>o?.topPages?[...o.topPages].sort((he,qe)=>{const De=he[A],Ge=qe[A];return typeof De=="string"&&typeof Ge=="string"?U==="asc"?De.localeCompare(Ge):Ge.localeCompare(De):U==="asc"?De-Ge:Ge-De}):[],[o?.topPages,A,U]),pt=j.useMemo(()=>o?.aiReferrals?[...o.aiReferrals].sort((he,qe)=>{const De=he[C],Ge=qe[C];return typeof De=="string"&&typeof Ge=="string"?M==="asc"?De.localeCompare(Ge):Ge.localeCompare(De):M==="asc"?De-Ge:Ge-De}):[],[o?.aiReferrals,C,M]),gt=j.useMemo(()=>o?.aiReferralLandingPages?[...o.aiReferralLandingPages].sort((he,qe)=>{const De=he[ie],Ge=qe[ie];return typeof De=="string"&&typeof Ge=="string"?ze==="asc"?De.localeCompare(Ge):Ge.localeCompare(De):ze==="asc"?De-Ge:Ge-De}):[],[o?.aiReferralLandingPages,ie,ze]),St=j.useMemo(()=>o?.socialReferrals?[...o.socialReferrals].sort((he,qe)=>{const De=he[B],Ge=qe[B];return typeof De=="string"&&typeof Ge=="string"?ue==="asc"?De.localeCompare(Ge):Ge.localeCompare(De):ue==="asc"?De-Ge:Ge-De}):[],[o?.socialReferrals,B,ue]),{socialChartData:Fn,socialChartSources:be,socialOtherCount:Ae}=j.useMemo(()=>{const he=WM(se);return{socialChartData:he.data,socialChartSources:he.sources,socialOtherCount:he.otherCount}},[se]),{chartData:sn,chartSources:Zt,dateRange:an}=j.useMemo(()=>{const he=[...new Set(V.map($e=>$e.source))],qe=new Map;for(const $e of me)qe.set($e.date,{_totalSessions:$e.sessions,_organicSessions:$e.organicSessions});const De=new Map;for(const $e of V){const We=`${$e.date}::${$e.source}`,Cs=De.get(We)??0;De.set(We,Math.max(Cs,$e.sessions))}for(const[$e,We]of De){const[Cs,As]=$e.split("::");let mn=qe.get(Cs);mn||(mn={_totalSessions:0,_organicSessions:0},qe.set(Cs,mn)),mn[As]=(mn[As]??0)+We}const Ge=[...qe.entries()].sort(([$e],[We])=>$e.localeCompare(We)).map(([$e,We])=>({date:$e,...We})),Xe=Ge.map($e=>$e.date),fe=Xe.length>0?{start:Xe[0],end:Xe[Xe.length-1]}:null;return{chartData:Ge,chartSources:he,dateRange:fe}},[V,me]);if(d&&!i)return t.jsx("p",{className:"text-sm text-zinc-500 py-8 text-center",children:"Loading traffic data…"});if(!i?.connected)return t.jsx(a$,{projectName:e,onConnected:()=>{(async()=>(await s.invalidateQueries({predicate:he=>{const qe=he.queryKey[0];return typeof qe?._id=="string"&&qe._id.startsWith("getApiV1ProjectsByNameGa")}}),await le({current:!1})))()}});const ws=o?.organicSharePctDisplay??"0%",$t=o?.channelBreakdown?.organic.sharePctDisplay??ws,$n=o?.channelBreakdown?.organic.sessions??o?.totalOrganicSessions??0,Yn=o?.aiSessionsDeduped??0,dn=o?.channelBreakdown?.ai.sessions??o?.aiSessionsBySession??0,zn=o?.channelBreakdown?.ai.sharePctDisplay??o?.aiSharePctBySessionDisplay??"0%",rs=o?new Set(o.aiReferrals.map(he=>he.source.toLowerCase())).size:0,kn=pt[0]??null,Ss=o?.totalDirectSessions??0,zs=o?.directSharePctDisplay??"0%",F=o?.channelBreakdown?.direct.sessions??Ss,Pe=o?.channelBreakdown?.direct.sharePctDisplay??zs,He=o?.channelBreakdown?.other.sessions??o?.otherSessions??0,ut=o?.channelBreakdown?.other.sharePctDisplay??o?.otherSharePctDisplay??"0%",ht=o?.socialSessions??0,ls=o?.socialSharePctDisplay??"0%",ui=o?.channelBreakdown?.social.sessions??ht,Ks=o?.channelBreakdown?.social.sharePctDisplay??ls,ks=o?new Set(o.socialReferrals.map(he=>he.source.toLowerCase())).size:0,Ft=St[0]??null;return t.jsxs(t.Fragment,{children:[N&&t.jsx("div",{className:"mb-4 px-4 py-2 rounded-lg bg-rose-900/20 border border-rose-800/60 text-sm text-rose-300",children:N}),T&&t.jsx("div",{className:"mb-4 px-4 py-2 rounded-lg bg-emerald-900/20 border border-emerald-800/60 text-sm text-emerald-300",children:T}),t.jsxs("div",{className:"flex items-center justify-between mb-6",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-emerald-500"}),t.jsxs("span",{className:"text-xs text-zinc-400",children:["Property ",t.jsx("span",{className:"text-zinc-300",children:i.propertyId}),i.clientEmail&&t.jsxs(t.Fragment,{children:[" · ",t.jsx("span",{className:"text-zinc-500",children:i.clientEmail})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(ee,{variant:"outline",size:"sm",disabled:p,onClick:Le(Re),children:[t.jsx(mo,{className:`w-3.5 h-3.5 mr-1.5 ${p?"animate-spin":""}`}),p?"Syncing…":"Sync"]}),t.jsxs(ee,{variant:"ghost",size:"sm",className:"text-rose-400 hover:text-rose-300",disabled:b,onClick:Le(tt),children:[t.jsx(RA,{className:"w-3.5 h-3.5 mr-1.5"}),"Disconnect"]})]})]}),t.jsxs("section",{children:[t.jsxs("div",{className:"mb-4 flex items-start justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-zinc-500 mb-1",children:"Traffic Overview"}),t.jsxs("h2",{className:"text-base font-semibold text-zinc-50 flex items-center gap-1.5",children:["Site Traffic",t.jsx(on,{text:`Aggregated traffic metrics from Google Analytics 4. Sessions and users are summed across the selected period.${o?.periodStart&&o?.periodEnd?` Data available: ${new Date(o.periodStart+"T00:00:00").toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})} – ${new Date(o.periodEnd+"T00:00:00").toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}.`:""} Organic sessions are Google organic search sessions specifically.`})]})]}),t.jsx("div",{className:"flex gap-1",children:e$.map(he=>t.jsx("button",{type:"button",className:`px-3 py-1 text-xs rounded-full border transition-colors ${Y===he?"bg-zinc-700 border-zinc-600 text-zinc-50":"border-zinc-800 text-zinc-400 hover:border-zinc-700 hover:text-zinc-300"}`,onClick:()=>ye(he),children:he==="all"?"All":he},he))})]}),o?t.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[t.jsx(Dh,{value:Jc(o.totalSessions),label:"Total Sessions",subtitle:o.totalSessions.toLocaleString(),tone:"neutral"}),t.jsx(Dh,{value:Jc(o.totalOrganicSessions),label:"Organic Sessions",subtitle:`${ws} of total`,tone:"positive"}),t.jsx(Dh,{value:Jc(o.totalUsers),label:"Total Users",subtitle:o.totalUsers.toLocaleString(),tone:"neutral"})]}):t.jsxs("div",{className:"surface-card rounded-lg p-6 text-center border border-zinc-800/60",children:[t.jsx("p",{className:"text-sm text-zinc-400 mb-3",children:"No traffic data yet."}),t.jsxs(ee,{variant:"outline",size:"sm",disabled:p,onClick:Le(Re),children:[t.jsx(mo,{className:`w-3.5 h-3.5 mr-1.5 ${p?"animate-spin":""}`}),"Sync from GA4"]})]})]}),o&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"page-section-divider"}),t.jsxs("section",{children:[t.jsxs("div",{className:"mb-4 flex items-end justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-zinc-500 mb-1",children:"Traffic Attribution"}),t.jsxs("h2",{className:"text-base font-semibold text-zinc-50 flex items-center gap-1.5",children:["Traffic by channel",t.jsx(on,{text:"Decomposes GA4 sessions into five disjoint channels — known AI referrers first, then organic search, social, direct, and other channels. Known AI referrers are removed from their native GA4 channel before the residual Other bucket is computed. Other channels are the remaining GA4 session default channel groups, such as Referral, Email, Paid Search, Display, Cross-network, Shopping, Video, Affiliates, SMS, and Paid Other."})]})]}),an&&t.jsxs("p",{className:"text-xs text-zinc-500",children:[new Date(an.start+"T00:00:00").toLocaleDateString(void 0,{month:"short",day:"numeric"})," – ",new Date(an.end+"T00:00:00").toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})]})]}),sn.length>0&&t.jsxs(Se,{className:"surface-card p-5 mb-4",children:[t.jsxs("div",{className:"mb-4 flex items-end justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Trend"}),t.jsx("h3",{className:"text-sm font-semibold text-zinc-100",children:Zt.length>0?"AI vs. total sessions":"All sessions (baseline)"}),Zt.length===0&&t.jsx("p",{className:"text-xs text-zinc-500 mt-0.5",children:"AI referral sessions will be overlaid here once detected"})]}),Zt.length===0&&t.jsx("p",{className:"text-xs text-zinc-500",children:"No AI referrals detected yet"})]}),t.jsx("div",{className:"h-64",children:t.jsx(uu,{width:"100%",height:"100%",children:t.jsxs(Uh,{data:sn,margin:{top:4,right:4,bottom:0,left:0},children:[t.jsx(du,{dataKey:"date",tick:ei,tickLine:!1,axisLine:{stroke:Xr},tickFormatter:pf}),t.jsx(mu,{tick:ei,tickLine:!1,axisLine:!1,allowDecimals:!1,width:36}),t.jsx(hu,{...Pr,labelFormatter:ff,formatter:(he,qe)=>{const De=typeof he=="number"?he.toLocaleString():String(he??0),Ge=String(qe??"");return Ge==="_totalSessions"?[De,"Total Sessions"]:Ge==="_organicSessions"?[De,"Organic Sessions"]:[De,Ge]}}),t.jsx(PS,{wrapperStyle:{fontSize:11,color:"#a1a1aa"},formatter:he=>he==="_totalSessions"?"Total Sessions":he==="_organicSessions"?"Organic Sessions":he}),t.jsx(ao,{type:"monotone",dataKey:"_totalSessions",stroke:"#52525b",fill:"#27272a",fillOpacity:.4,strokeWidth:1.5,dot:!1}),Zt.map((he,qe)=>t.jsx(ao,{type:"monotone",dataKey:he,stackId:"ai",stroke:Ja[qe%Ja.length],fill:Ja[qe%Ja.length],fillOpacity:.4,strokeWidth:1.5},he))]})})})]}),t.jsxs(Se,{className:"surface-card p-5 mb-4",children:[t.jsxs("div",{className:"mb-4",children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Summary"}),t.jsx("h3",{className:"text-sm font-semibold text-zinc-100",children:"Channel breakdown"})]}),t.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-5",children:[t.jsx(Ls,{label:"Organic",value:$t,hint:`${$n.toLocaleString()} sessions`,tone:"positive",tooltip:"Sessions from Google organic search (sessionDefaultChannelGrouping = 'Organic Search'), after known AI referrers are removed for a disjoint channel breakdown."}),t.jsx(Ls,{label:"Social",value:Ks,hint:`${ui.toLocaleString()} sessions`,tone:"neutral",tooltip:"Sessions from social platforms (sessionDefaultChannelGrouping = 'Organic Social' or 'Paid Social'), after known AI referrers are removed for a disjoint channel breakdown."}),t.jsx(Ls,{label:"Direct",value:Pe,hint:`${F.toLocaleString()} sessions`,tone:"neutral",tooltip:"Sessions with no source — bookmarks, typed URLs, untagged email, in-app browsers, and AI-driven traffic whose referrer header was stripped. Known AI referrers are removed if GA4 classified them as Direct."}),t.jsx(Ls,{label:"Known AI referrers (lower bound)",value:zn,hint:`${dn.toLocaleString()} sessions`,tone:"positive",tooltip:"Sessions whose current sessionSource matched a known AI engine (e.g. chatgpt.com, claude.ai, gemini.google.com). These sessions are removed from their native GA4 channel in this card grid so the five buckets stay disjoint. This is a strict lower bound: most AI traffic strips the referrer and falls into Direct, so the true AI share is typically higher than what's shown here. The detail table below also surfaces firstUserSource and UTM-tagged AI signals."}),t.jsx(Ls,{label:"Other channels",value:ut,hint:`${He.toLocaleString()} sessions`,tone:"neutral",tooltip:"Remaining GA4 session default channel groups after Known AI, Organic Search, Organic/Paid Social, and Direct are accounted for. This is a residual bucket, not a single source. It can include Referral, Email, Paid Search, Display, Cross-network, Shopping, Video, Affiliates, SMS, Mobile Push Notifications, Paid Other, and unclassified traffic."})]}),kn&&t.jsxs("div",{className:"mt-4 rounded-lg border border-emerald-800/40 bg-emerald-500/6 px-4 py-3 text-sm text-emerald-100",children:["Top AI referrer: ",t.jsx("span",{className:"font-medium",children:kn.source})," via ",kn.medium,", accounting for ",kn.sessions.toLocaleString()," sessions."]})]}),t.jsxs(Se,{className:"surface-card p-5 mb-4",children:[t.jsxs("div",{className:"mb-4 flex items-end justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Detail"}),t.jsx("h3",{className:"text-sm font-semibold text-zinc-100",children:"Known AI referrers — sources detected"})]}),t.jsx("p",{className:"text-xs text-zinc-500",children:o.aiReferrals.length>0?`${rs} unique sources, ${o.aiReferrals.length} rows`:"No source rows"})]}),o.aiReferrals.length>0?t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-[10px] uppercase tracking-wider text-zinc-500",children:[t.jsx(An,{label:"Source",sortKey:"source",current:C,dir:M,onSort:Ue,align:"left"}),t.jsx(An,{label:"Medium",sortKey:"medium",current:C,dir:M,onSort:Ue,align:"left"}),t.jsx("th",{className:"py-1 font-medium text-left",children:"Attribution"}),t.jsx(An,{label:"Sessions",sortKey:"sessions",current:C,dir:M,onSort:Ue,align:"right"}),t.jsx("th",{className:"py-1 font-medium text-right",children:"Share"}),t.jsx(An,{label:"Users",sortKey:"users",current:C,dir:M,onSort:Ue,align:"right"})]})}),t.jsx("tbody",{children:pt.map(he=>t.jsx(r$,{referral:he,totalSessions:Yn},`${he.source}:${he.medium}:${he.sourceDimension}`))})]})}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[t.jsx("p",{className:"text-sm text-zinc-400 mb-2",children:"No AI referrer sessions detected yet"}),t.jsx("p",{className:"text-xs text-zinc-500 max-w-sm",children:"AI engines that preserve a referrer (Perplexity, copy/paste from ChatGPT, etc.) will appear here. Most AI traffic strips the referrer — see the Direct cell above for the upper bound."})]})]}),t.jsxs(Se,{className:"surface-card p-5",children:[t.jsxs("div",{className:"mb-4 flex items-end justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Detail"}),t.jsx("h3",{className:"text-sm font-semibold text-zinc-100",children:"Known AI referrers — landing pages"})]}),t.jsx("p",{className:"text-xs text-zinc-500",children:gt.length>0?`${gt.length} rows`:"No landing-page rows"})]}),gt.length>0?t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-[10px] uppercase tracking-wider text-zinc-500",children:[t.jsx(An,{label:"Landing Page",sortKey:"landingPage",current:ie,dir:ze,onSort:mt,align:"left"}),t.jsx(An,{label:"Source",sortKey:"source",current:ie,dir:ze,onSort:mt,align:"left"}),t.jsx("th",{className:"py-1 font-medium text-left",children:"Attribution"}),t.jsx(An,{label:"Sessions",sortKey:"sessions",current:ie,dir:ze,onSort:mt,align:"right"}),t.jsx(An,{label:"Users",sortKey:"users",current:ie,dir:ze,onSort:mt,align:"right"})]})}),t.jsx("tbody",{children:gt.map(he=>t.jsx(l$,{row:he},`${he.landingPage}:${he.source}:${he.medium}:${he.sourceDimension}`))})]})}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[t.jsx("p",{className:"text-sm text-zinc-400 mb-2",children:"No AI landing pages detected yet"}),t.jsx("p",{className:"text-xs text-zinc-500 max-w-sm",children:"Known-AI landing pages appear after a GA4 sync records visits from AI referrers."})]})]})]})]}),o&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"page-section-divider"}),t.jsxs("section",{children:[t.jsxs("div",{className:"mb-4",children:[t.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-zinc-500 mb-1",children:"Social Attribution"}),t.jsxs("h2",{className:"text-base font-semibold text-zinc-50 flex items-center gap-1.5",children:["Social Media Traffic",t.jsx(on,{text:"Tracks sessions classified as social traffic by GA4's default channel grouping (Organic Social and Paid Social). Google maintains the source-to-channel mapping."})]})]}),Fn.length>0&&t.jsxs(Se,{className:"surface-card p-5 mb-4",children:[t.jsxs("div",{className:"mb-4 flex items-end justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Trend"}),t.jsx("h3",{className:"text-sm font-semibold text-zinc-100",children:"Social sessions over time"})]}),Ae>0&&t.jsxs("p",{className:"text-xs text-zinc-500",children:["Showing top ",be.length-1," sources · ",Ae," more grouped as Other"]})]}),t.jsx("div",{className:"h-64",children:t.jsx(uu,{width:"100%",height:"100%",children:t.jsxs(Uh,{data:Fn,margin:{top:4,right:4,bottom:0,left:0},children:[t.jsx(du,{dataKey:"date",tick:ei,tickLine:!1,axisLine:{stroke:Xr},tickFormatter:pf}),t.jsx(mu,{tick:ei,tickLine:!1,axisLine:!1,allowDecimals:!1,width:36}),t.jsx(hu,{...Pr,labelFormatter:ff,formatter:(he,qe)=>{const De=typeof he=="number"?he.toLocaleString():String(he??0),Ge=String(qe??"");if(Ge===Vr)return[De,"Total Social"];if(Ge===Jr){const Xe=`Other (${Ae} source${Ae===1?"":"s"})`;return[De,Xe]}return[De,Hr(Ge)]}}),t.jsx(ao,{type:"monotone",dataKey:Vr,stroke:f1,fill:"#27272a",fillOpacity:.4,strokeWidth:1.5,dot:!1}),be.map((he,qe)=>{const Ge=he===Jr?gf:Ja[qe%Ja.length];return t.jsx(ao,{type:"monotone",dataKey:he,stackId:"social",stroke:Ge,fill:Ge,fillOpacity:.4,strokeWidth:1.5},he)})]})})}),t.jsx(c$,{sources:be,otherCount:Ae})]}),t.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.5fr)]",children:[t.jsxs(Se,{className:"surface-card p-5",children:[t.jsxs("div",{className:"mb-4",children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Summary"}),t.jsx("h3",{className:"text-sm font-semibold text-zinc-100",children:"Social media visits"})]}),o.socialReferrals.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[t.jsx(Ls,{label:"Social Sessions",value:Jc(ht),hint:`${ht.toLocaleString()} sessions`,tone:"positive",tooltip:"Total sessions classified as Organic Social or Paid Social by GA4's default channel grouping."}),t.jsx(Ls,{label:"Share of Traffic",value:ls,hint:"of total sessions",tone:"neutral",tooltip:"Percentage of your total site sessions that originated from social media platforms."}),t.jsx(Ls,{label:"Platforms",value:String(ks),hint:`${o.socialReferrals.length} source rows`,tone:"neutral",tooltip:"Number of distinct social media platforms detected. Each unique source/medium combination counts as one source row."})]}),Ft&&t.jsxs("div",{className:"mt-4 rounded-lg border border-sky-800/40 bg-sky-500/6 px-4 py-3 text-sm text-sky-100",children:[t.jsx("p",{className:"text-xs uppercase tracking-wider text-sky-300/70 mb-1",children:"Top social source"}),t.jsx("p",{className:"font-medium truncate",title:`${Ft.source} via ${Ft.medium}`,children:h1(Hr(Ft.source),64)}),t.jsxs("p",{className:"text-xs text-sky-200/70 mt-0.5 truncate",title:Ft.medium,children:["via ",Hr(Ft.medium)," · ",Ft.sessions.toLocaleString()," sessions"]})]})]}):t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[t.jsx(Ls,{label:"Social Sessions",value:"0",hint:"0 sessions",tone:"neutral",tooltip:"Total sessions attributed to social media platforms."}),t.jsx(Ls,{label:"Share of Traffic",value:"0%",hint:"of total sessions",tone:"neutral",tooltip:"Percentage of your total site sessions from social media."}),t.jsx(Ls,{label:"Platforms",value:"0",hint:"known platforms",tone:"neutral",tooltip:"Number of distinct social media platforms detected."})]}),t.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/30 px-4 py-3 text-sm text-zinc-400",children:[t.jsx("p",{className:"mb-1.5 text-zinc-300",children:"Monitoring social media traffic via GA4 channel grouping"}),t.jsx("p",{className:"text-xs text-zinc-500",children:"Sessions classified as Organic Social or Paid Social by GA4 will appear here. Google maintains the source-to-channel mapping, which includes Facebook, Instagram, X/Twitter, LinkedIn, Reddit, Pinterest, Snapchat, and other platforms."})]})]})]}),t.jsxs(Se,{className:"surface-card p-5",children:[t.jsxs("div",{className:"mb-4 flex items-end justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Breakdown"}),t.jsx("h3",{className:"text-sm font-semibold text-zinc-100",children:"Source / medium"})]}),t.jsx("p",{className:"text-xs text-zinc-500",children:o.socialReferrals.length>0?St.length>so&&!E?`Top ${so} of ${St.length}`:`${St.length} rows`:"No source rows"})]}),o.socialReferrals.length>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm table-fixed",children:[t.jsxs("colgroup",{children:[t.jsx("col",{className:"w-[32%]"}),t.jsx("col",{className:"w-[22%]"}),t.jsx("col",{className:"w-[12%]"}),t.jsx("col",{className:"w-[11%]"}),t.jsx("col",{className:"w-[11%]"}),t.jsx("col",{className:"w-[12%]"})]}),t.jsx("thead",{children:t.jsxs("tr",{className:"text-[10px] uppercase tracking-wider text-zinc-500",children:[t.jsx(An,{label:"Source",sortKey:"source",current:B,dir:ue,onSort:Ce,align:"left"}),t.jsx(An,{label:"Medium",sortKey:"medium",current:B,dir:ue,onSort:Ce,align:"left"}),t.jsx("th",{className:"py-1 font-medium text-left",children:"Channel"}),t.jsx(An,{label:"Sessions",sortKey:"sessions",current:B,dir:ue,onSort:Ce,align:"right"}),t.jsx("th",{className:"py-1 font-medium text-right",children:"Share"}),t.jsx(An,{label:"Users",sortKey:"users",current:B,dir:ue,onSort:Ce,align:"right"})]})}),t.jsx("tbody",{children:(E?St:St.slice(0,so)).map(he=>t.jsx(o$,{referral:he,totalSessions:ht},`${he.source}:${he.medium}:${he.channelGroup}`))})]})}),St.length>so&&t.jsx("div",{className:"mt-3 flex justify-center",children:t.jsx("button",{type:"button",onClick:()=>X(he=>!he),className:"text-xs text-zinc-400 hover:text-zinc-200 px-3 py-1 rounded-full border border-zinc-800 hover:border-zinc-700 transition-colors",children:E?`Show top ${so}`:`Show all ${St.length} sources`})})]}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[t.jsx("p",{className:"text-sm text-zinc-400 mb-2",children:"No social media sessions detected yet"}),t.jsx("p",{className:"text-xs text-zinc-500 max-w-sm",children:"When visitors arrive from Facebook, X/Twitter, LinkedIn, or other social platforms, their sessions will be broken down here by source and medium."})]})]})]})]})]}),o&&o.topPages.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"page-section-divider"}),t.jsxs("section",{children:[t.jsxs("div",{className:"mb-4",children:[t.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-zinc-500 mb-1",children:"Page Performance"}),t.jsxs("h2",{className:"text-base font-semibold text-zinc-50 flex items-center gap-1.5",children:["Top Landing Pages",t.jsx(on,{text:"Landing pages ranked by session volume. Click column headers to sort. Organic % shows the share of sessions coming from Google organic search."})]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-[10px] uppercase tracking-wider text-zinc-500",children:[t.jsx(An,{label:"Landing Page",sortKey:"landingPage",current:A,dir:U,onSort:we,align:"left"}),t.jsx(An,{label:"Sessions",sortKey:"sessions",current:A,dir:U,onSort:we,align:"right"}),t.jsx(An,{label:"Organic",sortKey:"organicSessions",current:A,dir:U,onSort:we,align:"right"}),t.jsx("th",{className:"text-right py-1 font-medium",children:"Organic %"}),t.jsx(An,{label:"Users",sortKey:"users",current:A,dir:U,onSort:we,align:"right"})]})}),t.jsx("tbody",{children:Nt.map(he=>t.jsx(i$,{page:he},he.landingPage))})]})})]})]}),t.jsxs("div",{className:"mt-6 flex items-center justify-between text-xs text-zinc-500",children:[t.jsx("span",{children:o?.lastSyncedAt?`Last synced ${p1(o.lastSyncedAt)}`:"Never synced"}),t.jsx("span",{children:o?`${o.topPages.length} pages · ${o.aiReferrals.length} AI rows · ${o.socialReferrals.length} social rows`:""})]})]})}function a$({projectName:e,onConnected:s}){const[i,r]=j.useState(""),[o,u]=j.useState(null),[d,h]=j.useState(null),[p,x]=j.useState(!1),[b,v]=j.useState(null),N=j.useRef(null),z=j.useCallback(w=>{const A=w.target.files?.[0];if(!A)return;v(null),u(A.name);const D=new FileReader;D.onload=()=>{const U=D.result;try{const I=JSON.parse(U);if(!I.client_email||!I.private_key){v("JSON file is missing required fields: client_email and private_key. Make sure you downloaded a service account key (not an OAuth client)."),h(null);return}h(U)}catch{v("File is not valid JSON. Please upload a service account key file (.json) downloaded from Google Cloud Console."),h(null)}},D.onerror=()=>{v("Failed to read file."),h(null)},D.readAsText(A)},[]);async function T(){if(v(null),!i.trim()){v("Property ID is required.");return}if(!d){v("Please upload a service account key file.");return}x(!0);try{await eC(e,{propertyId:i.trim(),keyJson:d});try{await Sv(e)}catch{}s()}catch(w){v(w instanceof Error?w.message:"Failed to connect GA4")}finally{x(!1)}}return t.jsxs(Se,{className:"surface-card p-6",children:[t.jsx("h3",{className:"text-base font-semibold text-zinc-50 mb-1",children:"Connect Google Analytics 4"}),t.jsx("p",{className:"text-sm text-zinc-400 mb-5",children:"Connect a GA4 property to see traffic data for this project. You'll need a service account key file from Google Cloud Console."}),b&&t.jsx("div",{className:"mb-4 px-4 py-2 rounded-lg bg-rose-900/20 border border-rose-800/60 text-sm text-rose-300",children:b}),t.jsxs("div",{className:"mb-4",children:[t.jsx("label",{htmlFor:"ga4-property-id",className:"block text-xs font-medium text-zinc-400 mb-1.5",children:"GA4 Property ID"}),t.jsx("input",{id:"ga4-property-id",type:"text",placeholder:"e.g. 123456789",value:i,onChange:w=>r(w.target.value),className:"w-full rounded-lg bg-zinc-900/60 border border-zinc-800/60 px-3 py-2 text-sm text-zinc-200 placeholder:text-zinc-600 focus:outline-none focus:ring-1 focus:ring-zinc-600"}),t.jsx("p",{className:"mt-1 text-[11px] text-zinc-500",children:"Find this in GA4 → Admin → Property Settings. It's a numeric ID, not the Measurement ID (G-XXXXXX)."})]}),t.jsxs("div",{className:"mb-5",children:[t.jsx("label",{className:"block text-xs font-medium text-zinc-400 mb-1.5",children:"Service Account Key File"}),t.jsx("input",{ref:N,type:"file",accept:".json,application/json",onChange:z,className:"hidden"}),t.jsxs("button",{type:"button",onClick:()=>N.current?.click(),className:"flex items-center gap-2 w-full rounded-lg bg-zinc-900/60 border border-zinc-800/60 border-dashed px-4 py-3 text-sm text-zinc-400 hover:border-zinc-600 hover:text-zinc-300 transition-colors cursor-pointer",children:[t.jsx(MA,{className:"w-4 h-4 shrink-0"}),o?t.jsx("span",{className:"text-zinc-200 truncate",children:o}):t.jsx("span",{children:"Upload .json key file"})]}),t.jsxs("p",{className:"mt-1 text-[11px] text-zinc-500",children:["Download from Google Cloud Console → IAM & Admin → Service Accounts → Keys → Add Key → JSON. The service account must have ",t.jsx("span",{className:"text-zinc-400",children:"Viewer"})," access on the GA4 property."]})]}),t.jsx(ee,{variant:"default",size:"sm",disabled:p||!i.trim()||!d,onClick:Le(T),children:p?"Connecting & syncing…":"Connect GA4"})]})}function An({label:e,sortKey:s,current:i,dir:r,onSort:o,align:u}){const d=i===s;return t.jsxs("th",{className:`py-1 font-medium cursor-pointer select-none hover:text-zinc-300 transition-colors ${u==="right"?"text-right":"text-left"}`,onClick:()=>o(s),children:[e,d&&t.jsx("span",{className:"ml-0.5",children:r==="asc"?"↑":"↓"})]})}const g1={positive:"text-emerald-400",caution:"text-amber-400",negative:"text-rose-400",neutral:"text-zinc-50"};function Dh({value:e,label:s,subtitle:i,tone:r}){return t.jsxs("div",{className:"rounded-lg bg-zinc-900/30 border border-zinc-800/60 px-5 py-4",children:[t.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-zinc-500 mb-1",children:s}),t.jsx("p",{className:`text-2xl font-bold tabular-nums ${g1[r]}`,children:e}),t.jsx("p",{className:"text-xs text-zinc-500 mt-1",children:i})]})}function Ls({value:e,label:s,hint:i,tone:r,tooltip:o}){return t.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-950/40 px-4 py-3 flex flex-col",children:[t.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-zinc-500 mb-1 flex items-center gap-1",children:[s,o&&t.jsx(on,{text:o})]}),t.jsx("p",{className:`text-xl font-semibold tabular-nums ${g1[r]}`,children:e}),t.jsx("p",{className:"text-xs text-zinc-500 mt-1",children:i})]})}function i$({page:e}){const s=e.sessions>0?(e.organicSessions/e.sessions*100).toFixed(1):"0.0";return t.jsxs("tr",{className:"border-t border-zinc-800/40",children:[t.jsx("td",{className:"py-1.5 text-zinc-300 max-w-[400px] truncate",title:e.landingPage,children:e.landingPage}),t.jsx("td",{className:"py-1.5 text-right text-zinc-200 tabular-nums",children:e.sessions.toLocaleString()}),t.jsx("td",{className:"py-1.5 text-right text-emerald-400 tabular-nums",children:e.organicSessions.toLocaleString()}),t.jsxs("td",{className:"py-1.5 text-right text-zinc-400 tabular-nums",children:[s,"%"]}),t.jsx("td",{className:"py-1.5 text-right text-zinc-200 tabular-nums",children:e.users.toLocaleString()})]})}const x1={session:"Session",first_user:"First Visit",manual_utm:"UTM"},y1={session:"Detected via GA4 sessionSource (referrer or utm_source for this session)",first_user:"Detected via GA4 firstUserSource (referrer from the user's first-ever visit)",manual_utm:"Detected via GA4 sessionManualSource (explicit utm_source parameter for the session)"};function r$({referral:e,totalSessions:s}){const i=s>0?(e.sessions/s*100).toFixed(1):"0.0",r=x1[e.sourceDimension]??e.sourceDimension,o=y1[e.sourceDimension]??"";return t.jsxs("tr",{className:"border-t border-zinc-800/40",children:[t.jsx("td",{className:"py-1.5 text-zinc-200 max-w-[220px] truncate",title:e.source,children:e.source}),t.jsx("td",{className:"py-1.5 text-zinc-500 max-w-[180px] truncate",title:e.medium,children:e.medium}),t.jsx("td",{className:"py-1.5",children:t.jsx("span",{className:"inline-block text-[10px] px-1.5 py-0.5 rounded-full border border-zinc-700 text-zinc-400",title:o,children:r})}),t.jsx("td",{className:"py-1.5 text-right text-emerald-400 tabular-nums",children:e.sessions.toLocaleString()}),t.jsxs("td",{className:"py-1.5 text-right text-zinc-400 tabular-nums",children:[i,"%"]}),t.jsx("td",{className:"py-1.5 text-right text-zinc-200 tabular-nums",children:e.users.toLocaleString()})]})}function l$({row:e}){const s=x1[e.sourceDimension]??e.sourceDimension,i=y1[e.sourceDimension]??"";return t.jsxs("tr",{className:"border-t border-zinc-800/40",children:[t.jsx("td",{className:"py-1.5 text-zinc-300 max-w-[360px] truncate",title:e.landingPage,children:e.landingPage}),t.jsx("td",{className:"py-1.5 text-zinc-200 max-w-[220px] truncate",title:e.source,children:e.source}),t.jsx("td",{className:"py-1.5",children:t.jsx("span",{className:"inline-block text-[10px] px-1.5 py-0.5 rounded-full border border-zinc-700 text-zinc-400",title:i,children:s})}),t.jsx("td",{className:"py-1.5 text-right text-emerald-400 tabular-nums",children:e.sessions.toLocaleString()}),t.jsx("td",{className:"py-1.5 text-right text-zinc-200 tabular-nums",children:e.users.toLocaleString()})]})}function o$({referral:e,totalSessions:s}){const i=s>0?(e.sessions/s*100).toFixed(1):"0.0",r=e.channelGroup==="Paid Social"?"Paid":"Organic",o=Hr(e.source),u=Hr(e.medium);return t.jsxs("tr",{className:"border-t border-zinc-800/40",children:[t.jsx("td",{className:"py-1.5 pr-3 text-zinc-200 truncate",title:e.source,children:o}),t.jsx("td",{className:"py-1.5 pr-3 text-zinc-500 truncate",title:e.medium,children:u}),t.jsx("td",{className:"py-1.5 pr-3",children:t.jsx("span",{className:"inline-block text-[10px] px-1.5 py-0.5 rounded-full border border-zinc-700 text-zinc-400",title:`GA4 channel group: ${e.channelGroup}`,children:r})}),t.jsx("td",{className:"py-1.5 text-right text-sky-400 tabular-nums",children:e.sessions.toLocaleString()}),t.jsxs("td",{className:"py-1.5 text-right text-zinc-400 tabular-nums",children:[i,"%"]}),t.jsx("td",{className:"py-1.5 text-right text-zinc-200 tabular-nums",children:e.users.toLocaleString()})]})}function c$({sources:e,otherCount:s}){const i=[{key:Vr,color:f1,label:"Total",tooltip:"All social sessions across every source."}];for(let r=0;r<e.length;r++){const o=e[r];if(o===Jr)i.push({key:Jr,color:gf,label:`Other (${s})`,tooltip:`${s} smaller source${s===1?"":"s"} grouped together`});else{const u=Hr(o);i.push({key:o,color:Ja[r%Ja.length]??gf,label:h1(u,32),tooltip:u})}}return t.jsx("div",{className:"mt-3 flex flex-wrap gap-x-4 gap-y-1.5 text-[11px] text-zinc-400",children:i.map(r=>t.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 max-w-[260px]",title:r.tooltip,children:[t.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-sm shrink-0",style:{backgroundColor:r.color},"aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:r.label})]},r.key))})}function b1(e){e.invalidateQueries({queryKey:No({client:ae})}),e.invalidateQueries({queryKey:li({client:ae})})}function u$(e){return e==="gsc-sync"?"GSC sync queued":e==="inspect-sitemap"?"Sitemap inspection queued":"Visibility sweep queued"}function d$(e,s){const i=e??"Project";return s==="gsc-sync"?`${i} will refresh after the sync completes.`:s==="inspect-sitemap"?`${i} will notify you when sitemap inspection finishes.`:`${i} will notify you when the run finishes.`}function ad(e,s){sN({id:e.id,projectId:e.projectId,kind:e.kind,projectLabel:s.projectLabel,sourceAction:s.sourceAction,lastAnnouncedStatus:"queued"}),Qe({title:u$(e.kind),detail:d$(s.projectLabel,e.kind),tone:"neutral",dedupeKey:`run:${e.id}`,dedupeMode:"replace"})}function m$(e){const s=e.filter(o=>o.status!=="conflict"),i=e.filter(o=>o.status==="conflict");if(s.length===0){Qe({title:"No runs queued",detail:i.length>0?`${i.length} project${i.length===1?"":"s"} already had a run in progress.`:"No projects were available to queue.",tone:"caution",durationMs:8e3,dedupeKey:"run-all:conflict",dedupeMode:"replace"});return}for(const o of s)sN({id:o.id,projectId:o.projectId,kind:o.kind,projectLabel:o.projectName,sourceAction:"run-all",lastAnnouncedStatus:"queued"});const r=aR({runIds:s.map(o=>o.id),queuedCount:s.length,skippedCount:i.length});Qe({title:"Run-all batch queued",detail:i.length>0?`${s.length} project${s.length===1?"":"s"} queued, ${i.length} skipped because a run is already active.`:`${s.length} project${s.length===1?"":"s"} queued.`,tone:i.length>0?"caution":"neutral",dedupeKey:`batch:${r}`,dedupeMode:"replace"})}function id(e,s){if(e instanceof un&&e.code==="RUN_IN_PROGRESS"){Qe({title:"Run already in progress",detail:s?.projectLabel?`${s.projectLabel} already has an active run. Wait for it to finish, then retry.`:"This project already has an active run. Wait for it to finish, then retry.",tone:"caution",durationMs:8e3,dedupeKey:`run-in-progress:${s?.projectKey??"project"}:${s?.sourceAction??"run"}`,dedupeMode:"replace"});return}Qe({title:e instanceof Error?e.message:"Failed to queue run",tone:"negative"})}function v1(){const e=wn();return bs({meta:{skipGlobalErrorToast:!0},mutationFn:({projectName:s,opts:i})=>p2(s,i),onSuccess:(s,i)=>{b1(e),ad(s,{projectLabel:i.projectLabel??i.projectName,sourceAction:i.sourceAction})},onError:(s,i)=>{id(s,{projectKey:i.projectName,projectLabel:i.projectLabel??i.projectName,sourceAction:i.sourceAction})}})}function h$(){const e=wn();return bs({meta:{skipGlobalErrorToast:!0},mutationFn:s=>O2(s),onSuccess:s=>{b1(e),m$(s)},onError:s=>{Qe({title:s instanceof Error?s.message:"Failed to queue runs",tone:"negative"})}})}function f$(){const e=wn();return bs({meta:{skipGlobalErrorToast:!0},mutationFn:({projectName:s,opts:i})=>Nv(s,i),onSuccess:(s,i)=>{Ku(e,et["gsc-sync"],i.projectName),ad(s,{projectLabel:i.projectLabel??i.projectName,sourceAction:"gsc-sync"})},onError:(s,i)=>{id(s,{projectKey:i.projectName,projectLabel:i.projectLabel??i.projectName,sourceAction:"gsc-sync"})}})}function p$(){const e=wn();return bs({meta:{skipGlobalErrorToast:!0},mutationFn:({projectName:s})=>P2(s),onSuccess:(s,i)=>{Ku(e,s.run.kind,i.projectName),ad(s.run,{projectLabel:i.projectLabel??i.projectName,sourceAction:"discover-sitemaps"})},onError:(s,i)=>{id(s,{projectKey:i.projectName,projectLabel:i.projectLabel??i.projectName,sourceAction:"discover-sitemaps"})}})}function g$(){const e=wn();return bs({meta:{skipGlobalErrorToast:!0},mutationFn:({projectName:s,opts:i})=>I2(s,i),onSuccess:(s,i)=>{Ku(e,et["inspect-sitemap"],i.projectName),ad(s,{projectLabel:i.projectLabel??i.projectName,sourceAction:"inspect-sitemap"})},onError:(s,i)=>{id(s,{projectKey:i.projectName,projectLabel:i.projectLabel??i.projectName,sourceAction:"inspect-sitemap"})}})}function x$(){const e=wn();return bs({mutationFn:({projectName:s,queries:i})=>bv(s,i),onSuccess:()=>{e.invalidateQueries({queryKey:li({client:ae})})}})}const y$=["7d","30d","90d","all"],Wc=500;function b$({projectName:e,refreshNonce:s}){const i=wn(),[r,o]=j.useState(!1),[u,d]=j.useState([]),[h,p]=j.useState([]),[x,b]=j.useState([]),[v,N]=j.useState(null),[z,T]=j.useState([]),[w,A]=j.useState([]),[D,U]=j.useState(null),[I,C]=j.useState(""),[L,M]=j.useState(""),[_,B]=j.useState("30"),[J,ue]=j.useState(!1),[P,ie]=j.useState("30d"),[te,ze]=j.useState({startDate:"",endDate:"",query:"",page:"",limit:"20"}),[ve,V]=j.useState(0),[ne,me]=j.useState(!1),[Ne,se]=j.useState(0),[pe,E]=j.useState(!1),[X,Y]=j.useState(""),[ye,le]=j.useState(!0),[Re,tt]=j.useState(!1),[we,Ue]=j.useState(!1),[Ce,mt]=j.useState(!1),[Nt,pt]=j.useState(!1),[gt,St]=j.useState(!1),[Fn,be]=j.useState(!1),[Ae,sn]=j.useState(null),[Zt,an]=j.useState(!1),[ws,$t]=j.useState(!1),[$n,Yn]=j.useState(null),[dn,zn]=j.useState(""),[rs,kn]=j.useState(!1),[Ss,zs]=j.useState(!1),[F,Pe]=j.useState("indexed"),[He,ut]=j.useState(null),ht=!!(te.query.trim()||te.page.trim()||He),ls=He!==null,ui=j.useMemo(()=>{if(!He)return x;const{key:O,dir:ge}=He;return[...x].sort((Fe,at)=>{const Dt=O===Wa.CTR?Number.isFinite(Fe.ctr)?Fe.ctr:0:Fe[O],Cn=O===Wa.CTR?Number.isFinite(at.ctr)?at.ctr:0:at[O];return ge==="asc"?Dt-Cn:Cn-Dt})},[x,He]),[Ks,ks]=j.useState([]),[Ft,he]=j.useState(null),[qe,De]=j.useState(!1),[Ge,Xe]=j.useState(null),[fe,$e]=j.useState(null),We=u.find(O=>O.connectionType==="gsc"),Cs=x.length>0||z.length>0||w.length>0,As=f$(),mn=p$(),Qs=g$();async function Bn(O){if(!O){p([]),C("");return}Ue(!0);try{const{sites:ge}=await i.fetchQuery({...JD({client:ae,path:{name:e}}),staleTime:bn});p(ge),C(O.propertyId??ge[0]?.siteUrl??"")}catch(ge){p([]),Xe(ge instanceof Error?ge.message:"Failed to load Search Console properties")}finally{Ue(!1)}}async function Zs(O){pt(!0);const ge=O??ve;try{const Fe=parseInt(te.limit,10)||20,at=ht?Wc:Fe+1,Dt=ht?0:ge,Cn={limit:String(at)};te.startDate&&(Cn.startDate=te.startDate),te.endDate&&(Cn.endDate=te.endDate),te.query&&(Cn.query=te.query),te.page&&(Cn.page=te.page),Dt>0&&(Cn.offset=String(Dt)),P&&P!=="all"&&!te.startDate&&(Cn.window=P);const _n=await i.fetchQuery({...eO({client:ae,path:{name:e},query:Cn}),staleTime:bn});ht?(me(!1),b(_n),se(_n.length),E(!0)):(me(_n.length>Fe),b(_n.slice(0,Fe)),se(0),E(!1))}catch(Fe){b([]),me(!1),se(0),Xe(Fe instanceof Error?Fe.message:"Failed to load GSC performance data")}finally{pt(!1)}}async function Hi(){try{const O={};te.startDate&&(O.startDate=te.startDate),te.endDate&&(O.endDate=te.endDate),P&&P!=="all"&&!te.startDate&&(O.window=P);const ge=await i.fetchQuery({...nO({client:ae,path:{name:e},query:O}),staleTime:bn});N(ge)}catch{N(null)}}async function Xn(){St(!0);try{const O=X.trim()||void 0,ge={limit:"20"};O&&(ge.url=O);const[Fe,at]=await Promise.all([i.fetchQuery({...aO({client:ae,path:{name:e},query:ge}),staleTime:bn}),i.fetchQuery({...rO({client:ae,path:{name:e}}),staleTime:bn})]);T(Fe),A(at)}catch(O){T([]),A([]),Xe(O instanceof Error?O.message:"Failed to load GSC inspection history")}finally{St(!1)}}async function Yt(){an(!0);try{const[O,ge]=await Promise.all([i.fetchQuery({...Fj({client:ae,path:{name:e}}),staleTime:bn}),i.fetchQuery({...cO({client:ae,path:{name:e}}),staleTime:bn}).catch(()=>[])]);sn(O),ks(ge)}catch(O){sn(null),ks([]),Xe(O instanceof Error?O.message:"Failed to load coverage data")}finally{an(!1)}}async function hn(O){De(!0),Xe(null);try{const ge=await gy(e,{urls:O}),{succeeded:Fe,failed:at,total:Dt}=ge.summary;Qe({title:"Indexing requested",detail:at===0?`${Fe} URL${Fe!==1?"s":""} submitted for indexing.`:`${Fe}/${Dt} submitted successfully, ${at} failed.`,tone:at===0?"positive":"caution",dedupeKey:`gsc:indexing:${e}`,dedupeMode:"replace"})}catch(ge){Xe(ge instanceof Error?ge.message:"Failed to request indexing")}finally{De(!1)}}async function ba(){De(!0),Xe(null);try{const O=await gy(e,{urls:[],allUnindexed:!0}),{succeeded:ge,failed:Fe,total:at}=O.summary;Qe({title:"Indexing requested",detail:Fe===0?`${ge} unindexed URL${ge!==1?"s":""} submitted for indexing.`:`${ge}/${at} submitted successfully, ${Fe} failed.`,tone:Fe===0?"positive":"caution",dedupeKey:`gsc:indexing-all:${e}`,dedupeMode:"replace"})}catch(O){Xe(O instanceof Error?O.message:"Failed to request indexing")}finally{De(!1)}}async function va(){if(dn.trim()){kn(!0),Xe(null);try{await $2(e,"gsc",dn.trim()),await i.invalidateQueries({predicate:O=>{const ge=O.queryKey[0];return typeof ge?._id=="string"&&ge._id.startsWith("getApiV1ProjectsByNameGoogleGsc")}}),d(O=>O.map(ge=>ge.connectionType==="gsc"?{...ge,sitemapUrl:dn.trim()}:ge)),Qe({title:"Sitemap URL saved",detail:`${e} will use the updated sitemap URL.`,tone:"positive",dedupeKey:`gsc:sitemap:${e}`,dedupeMode:"drop"}),zn("")}catch(O){Xe(O instanceof Error?O.message:"Failed to save sitemap URL")}finally{kn(!1)}}}async function Ao(){Xe(null);try{const O=await mn.mutateAsync({projectName:e,projectLabel:e});Yn(O.sitemaps),d(ge=>ge.map(Fe=>Fe.connectionType==="gsc"?{...Fe,sitemapUrl:O.primarySitemapUrl}:Fe))}catch{}}async function rd(){$t(!0),Xe(null);try{const O=await U2(e);i.setQueryData(uO({client:ae,path:{name:e}}),O),Yn(O.sitemaps),O.sitemaps.length===0&&$e("No sitemaps found in this GSC property. Submit a sitemap in Google Search Console first.")}catch(O){Xe(O instanceof Error?O.message:"Failed to list sitemaps")}finally{$t(!1)}}async function rl(){le(!0),Xe(null);try{const[O,ge]=await Promise.all([j2().catch(()=>null),i.fetchQuery({...Zj({client:ae,path:{name:e}}),staleTime:bn}).catch(()=>[])]);o(!!O?.google?.configured),d(ge);const Fe=ge.find(at=>at.connectionType==="gsc");await Promise.all([Bn(Fe),Zs(),Hi(),Xn(),Yt()])}finally{le(!1)}}j.useEffect(()=>{rl()},[e,s]),j.useEffect(()=>{V(0),Zs(0),Hi()},[P]);const ja=j.useRef(!1);j.useEffect(()=>{if(!ja.current){ja.current=!0;return}V(0),Zs(0)},[ls]);async function ll(){if(!r){Xe("Google OAuth app credentials are not configured yet. Set them on the Settings page first.");return}tt(!0),Xe(null),$e(null);try{const{authUrl:O}=await R2(e,"gsc");if(!O.startsWith("https://accounts.google.com/")){Xe("Unexpected OAuth redirect URL. Please try again.");return}const ge=window.open(O,"_blank","width=600,height=700");if(!ge){window.location.assign(O);return}$e("Finish the Google consent flow in the popup, then close it to refresh this project.");const Fe=window.setInterval(()=>{ge.closed&&(window.clearInterval(Fe),$e(null),i.invalidateQueries({predicate:at=>{const Dt=at.queryKey[0];return typeof Dt?._id=="string"&&Dt._id.startsWith("getApiV1ProjectsByNameGoogleGsc")}}),rl())},1e3)}catch(O){Xe(O instanceof Error?O.message:"Failed to start OAuth flow")}finally{tt(!1)}}async function Na(){Xe(null),$e(null);try{await L2(e,"gsc"),await i.invalidateQueries({predicate:O=>{const ge=O.queryKey[0];return typeof ge?._id=="string"&&ge._id.startsWith("getApiV1ProjectsByNameGoogleGsc")}}),d(O=>O.filter(ge=>ge.connectionType!=="gsc")),p([]),C("")}catch(O){Xe(O instanceof Error?O.message:"Failed to disconnect")}}async function wa(){if(I){mt(!0),Xe(null);try{await M2(e,"gsc",I),await i.invalidateQueries({predicate:O=>{const ge=O.queryKey[0];return typeof ge?._id=="string"&&ge._id.startsWith("getApiV1ProjectsByNameGoogleGsc")}}),d(O=>O.map(ge=>ge.connectionType==="gsc"?{...ge,propertyId:I}:ge)),Qe({title:"GSC property updated",detail:`${e} is now linked to ${I}.`,tone:"positive",dedupeKey:`gsc:property:${e}`,dedupeMode:"drop"})}catch(O){Xe(O instanceof Error?O.message:"Failed to save GSC property")}finally{mt(!1)}}}async function di(){Xe(null),$e(null);try{await As.mutateAsync({projectName:e,projectLabel:e,opts:{days:parseInt(_,10)||void 0,full:J||void 0}}),await i.invalidateQueries({predicate:O=>{const ge=O.queryKey[0];return typeof ge?._id=="string"&&ge._id.startsWith("getApiV1ProjectsByNameGoogleGsc")}})}catch{}}async function Fs(){if(L.trim()){be(!0),Xe(null),$e(null);try{const O=await B2(e,L.trim());await i.invalidateQueries({predicate:ge=>{const Fe=ge.queryKey[0];return typeof Fe?._id=="string"&&Fe._id.startsWith("getApiV1ProjectsByNameGoogleGsc")}}),U(O),M(""),await Xn()}catch(O){Xe(O instanceof Error?O.message:"Failed to inspect URL")}finally{be(!1)}}}return t.jsxs("section",{className:"page-section-divider",children:[t.jsx("div",{className:"section-head section-head-inline",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Search Console"}),t.jsx("h2",{children:"Google Search Console"})]})}),Ge&&t.jsxs("div",{className:"mb-3 rounded-lg border border-rose-800/40 bg-rose-950/20 px-3 py-2 text-sm text-rose-300",children:[Ge,t.jsx("button",{type:"button",className:"ml-2 text-rose-400 hover:text-rose-200",onClick:()=>Xe(null),children:"×"})]}),fe&&t.jsxs("div",{className:"mb-3 rounded-lg border border-emerald-800/40 bg-emerald-950/20 px-3 py-2 text-sm text-emerald-300",children:[fe,t.jsx("button",{type:"button",className:"ml-2 text-emerald-400 hover:text-emerald-200",onClick:()=>$e(null),children:"×"})]}),ye?t.jsx("p",{className:"text-sm text-zinc-500",children:"Loading…"}):t.jsxs("div",{className:"space-y-3",children:[We?t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-1 text-xs text-zinc-500",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"}),t.jsx("span",{className:"text-zinc-300",children:"Authorized"})]}),t.jsx("span",{className:"text-zinc-700",children:"·"}),t.jsx("code",{className:"text-zinc-400",children:We.domain}),t.jsx("span",{className:"text-zinc-700",children:"·"}),t.jsxs("span",{children:["Last updated ",$s(We.updatedAt)]}),t.jsx("button",{type:"button",className:"ml-auto text-zinc-500 transition-colors hover:text-rose-400",onClick:Le(Na),children:"Disconnect"})]}):t.jsxs(Se,{className:"surface-card",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Connection"}),t.jsx("h3",{children:"Domain authorization"})]}),t.jsx(Ke,{tone:r?"caution":"negative",children:r?"Ready to connect":"App credentials missing"})]}),t.jsxs("div",{className:"mt-3 rounded-lg border border-zinc-800/60 bg-zinc-900/30 px-4 py-5",children:[t.jsx("p",{className:"text-sm text-zinc-300",children:r?"Generate a Google OAuth link for this project and have the client sign in with a Google account that already has access to the correct Search Console property.":"Set Google OAuth client credentials first. Once configured, you can generate a consent link for this project domain."}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[r?t.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:Re,onClick:Le(ll),children:Re?"Opening…":"Connect Google Search Console"}):t.jsx(ee,{type:"button",variant:"outline",size:"sm",asChild:!0,children:t.jsx(ft,{to:"/settings",children:"Open Settings"})}),!r&&t.jsx("p",{className:"text-xs text-zinc-500",children:"The same Google OAuth app credentials are shared across all projects."})]})]})]}),We&&!We.sitemapUrl&&t.jsx("div",{className:"rounded-lg border border-amber-800/40 bg-amber-950/20 px-4 py-3",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("span",{className:"mt-0.5 text-amber-400",children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-5 w-5","aria-hidden":"true",children:t.jsx("path",{fillRule:"evenodd",d:"M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 6a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 6zm0 9a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium text-amber-300",children:"Set your sitemap URL"}),t.jsx("p",{className:"mt-1 text-xs text-amber-400/70",children:"Canonry uses your sitemap to discover URLs for index coverage inspection. Auto-discover from GSC or enter it manually."}),t.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[t.jsxs("div",{className:"flex flex-col gap-2 lg:flex-row",children:[t.jsx(ee,{type:"button",size:"sm",disabled:mn.isPending||!We.propertyId,onClick:Le(Ao),children:mn.isPending?"Discovering…":"Auto-discover from GSC"}),t.jsx("span",{className:"self-center text-xs text-amber-400/60",children:"or enter manually:"})]}),t.jsxs("div",{className:"flex flex-col gap-2 lg:flex-row",children:[t.jsx("input",{className:"flex-1 rounded border border-amber-800/40 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-500 focus:border-amber-600 focus:outline-none",type:"url",placeholder:"https://example.com/sitemap.xml",value:dn,onChange:O=>zn(O.target.value),onKeyDown:O=>O.key==="Enter"&&void va()}),t.jsx(ee,{type:"button",size:"sm",variant:"outline",disabled:rs||!dn.trim(),onClick:Le(va),children:rs?"Saving…":"Save sitemap URL"})]})]})]})]})}),(We||Cs)&&t.jsxs(t.Fragment,{children:[t.jsxs(Se,{className:"surface-card",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Coverage"}),t.jsx("h3",{children:"Index coverage"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[Ae&&Ae.notIndexed.length>0&&t.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:qe,onClick:()=>{ba()},children:qe?"Requesting…":`Request indexing (${Ae.notIndexed.length})`}),t.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:Zt,onClick:()=>{Yt()},children:Zt?"Loading…":"Refresh coverage"})]})]}),Ae&&Ae.summary.total>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"mt-6 flex flex-col items-center",children:(()=>{const O=Ae.summary.indexed+Ae.summary.notIndexed,ge=O>0?Ae.summary.indexed/O:0,Fe=O>0?Ae.summary.notIndexed/O:0,at=54,Dt=2*Math.PI*at,Cn=Dt*(1-ge),_n=Dt*Fe,Ys=Dt*ge;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative h-48 w-48",children:[t.jsxs("svg",{viewBox:"0 0 128 128",className:"h-full w-full","aria-hidden":"true",children:[t.jsx("circle",{cx:"64",cy:"64",r:at,fill:"none",stroke:"rgba(255,255,255,0.04)",strokeWidth:"14"}),t.jsx("circle",{cx:"64",cy:"64",r:at,fill:"none",stroke:"#10b981",strokeWidth:"14",strokeDasharray:Dt,strokeDashoffset:Cn,strokeLinecap:"round",transform:"rotate(-90 64 64)",style:{transition:"stroke-dashoffset 0.6s ease"}}),Ae.summary.notIndexed>0&&t.jsx("circle",{cx:"64",cy:"64",r:at,fill:"none",stroke:"#52525b",strokeWidth:"14",strokeDasharray:`${_n} ${Dt-_n}`,strokeDashoffset:-Ys,transform:"rotate(-90 64 64)",style:{transition:"stroke-dasharray 0.6s ease, stroke-dashoffset 0.6s ease"}})]}),t.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[t.jsxs("span",{className:"text-3xl font-bold tabular-nums text-zinc-50",children:[(ge*100).toFixed(0),"%"]}),t.jsx("span",{className:"text-xs uppercase tracking-widest text-zinc-500 mt-0.5",children:"Indexed"})]})]}),t.jsxs("div",{className:"mt-4 flex items-center justify-center gap-8",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full bg-emerald-500"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-2xl font-semibold tabular-nums text-zinc-50",children:Ae.summary.indexed.toLocaleString()}),t.jsx("p",{className:"text-[11px] uppercase tracking-wide text-zinc-500",children:"Indexed"})]})]}),t.jsx("div",{className:"h-8 w-px bg-zinc-800"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full bg-zinc-500"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-2xl font-semibold tabular-nums text-zinc-50",children:Ae.summary.notIndexed.toLocaleString()}),t.jsxs("p",{className:"text-[11px] uppercase tracking-wide text-zinc-500",children:["Not indexed",(Ae.reasonGroups??[]).length>0&&t.jsxs("span",{className:"ml-1 text-zinc-600",children:["· ",(Ae.reasonGroups??[]).length," ",(Ae.reasonGroups??[]).length===1?"reason":"reasons"]})]})]})]}),Ae.summary.deindexed>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"h-8 w-px bg-zinc-800"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full bg-rose-500"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-2xl font-semibold tabular-nums text-zinc-50",children:Ae.summary.deindexed.toLocaleString()}),t.jsx("p",{className:"text-[11px] uppercase tracking-wide text-zinc-500",children:"Deindexed"})]})]})]})]})]})})()}),t.jsx("div",{className:"mt-3 flex gap-1",children:["indexed","notIndexed","deindexed"].map(O=>{const ge=O==="indexed"?Ae.indexed.length:O==="notIndexed"?Ae.notIndexed.length:Ae.deindexed.length,Fe=O==="indexed"?"Indexed":O==="notIndexed"?"Not Indexed":"Deindexed";return t.jsxs("button",{type:"button",className:`rounded-full px-3 py-1 text-xs font-medium transition-colors ${F===O?"bg-zinc-700 text-zinc-100":"text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200"}`,onClick:()=>{Pe(O),he(null)},children:[Fe," (",ge,")"]},O)})}),t.jsxs("div",{className:"mt-3 overflow-x-auto",children:[F==="indexed"&&Ae.indexed.length>0&&t.jsxs("table",{className:"data-table w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-left",children:"URL"}),t.jsx("th",{className:"text-left",children:"Verdict"}),t.jsx("th",{className:"text-left",children:"Last Crawl"}),t.jsx("th",{className:"text-left",children:"Mobile"})]})}),t.jsx("tbody",{children:Ae.indexed.map(O=>t.jsxs("tr",{children:[t.jsx("td",{className:"max-w-sm truncate text-zinc-200",children:O.url}),t.jsx("td",{className:"text-zinc-400",children:O.verdict??"Unknown"}),t.jsx("td",{className:"text-zinc-400",children:O.crawlTime?O.crawlTime.split("T")[0]:"—"}),t.jsx("td",{className:"text-zinc-400",children:O.isMobileFriendly===!0?"Yes":O.isMobileFriendly===!1?"No":"—"})]},O.id))})]}),F==="notIndexed"&&!Ft&&(Ae.reasonGroups??[]).length>0&&t.jsxs("table",{className:"data-table w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-left",children:"Reason"}),t.jsx("th",{className:"text-right",children:"Pages"})]})}),t.jsx("tbody",{children:(Ae.reasonGroups??[]).map(O=>t.jsxs("tr",{className:"cursor-pointer hover:bg-zinc-800/40",onClick:()=>he(O.reason),children:[t.jsx("td",{className:"text-zinc-200",children:O.reason}),t.jsx("td",{className:"text-right tabular-nums text-zinc-400",children:O.count})]},O.reason))})]}),F==="notIndexed"&&!Ft&&(Ae.reasonGroups??[]).length===0&&Ae.notIndexed.length>0&&t.jsxs("table",{className:"data-table w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-left",children:"URL"}),t.jsx("th",{className:"text-left",children:"Indexing State"}),t.jsx("th",{className:"text-left",children:"Coverage"})]})}),t.jsx("tbody",{children:Ae.notIndexed.map(O=>t.jsxs("tr",{children:[t.jsx("td",{className:"max-w-sm truncate text-zinc-200",children:O.url}),t.jsx("td",{className:"text-zinc-400",children:O.indexingState??"Unknown"}),t.jsx("td",{className:"text-zinc-400",children:O.coverageState??"Unknown"})]},O.id))})]}),F==="notIndexed"&&Ft&&(()=>{const O=(Ae.reasonGroups??[]).find(ge=>ge.reason===Ft);return O?t.jsxs("div",{children:[t.jsx("div",{className:"flex items-center gap-2 mb-3",children:t.jsxs("button",{type:"button",className:"text-xs text-zinc-400 hover:text-zinc-200 transition-colors",onClick:()=>he(null),children:["←"," Back to reasons"]})}),t.jsxs("div",{className:"mb-3 flex items-center justify-between rounded-lg border border-zinc-800/60 bg-zinc-900/20 p-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-zinc-200",children:O.reason}),t.jsxs("p",{className:"mt-1 text-xs text-zinc-500",children:[O.count," affected page",O.count!==1?"s":""]})]}),t.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:qe,onClick:()=>{hn(O.urls.map(ge=>ge.url))},children:qe?"Requesting…":`Request indexing (${O.count})`})]}),t.jsxs("table",{className:"data-table w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-left",children:"URL"}),t.jsx("th",{className:"text-left",children:"Last Crawl"}),t.jsx("th",{className:"w-8"})]})}),t.jsx("tbody",{children:O.urls.map(ge=>t.jsxs("tr",{children:[t.jsx("td",{className:"max-w-sm truncate text-zinc-200",children:ge.url}),t.jsx("td",{className:"text-zinc-400",children:ge.crawlTime?ge.crawlTime.split("T")[0]:"—"}),t.jsx("td",{children:t.jsx("button",{type:"button",className:"text-xs text-zinc-500 hover:text-zinc-200 transition-colors",disabled:qe,onClick:()=>{hn([ge.url])},title:"Request indexing",children:"Index"})})]},ge.id))})]})]}):null})(),F==="deindexed"&&Ae.deindexed.length>0&&t.jsxs("table",{className:"data-table w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-left",children:"URL"}),t.jsx("th",{className:"text-left",children:"Previous"}),t.jsx("th",{className:"text-left",children:"Current"}),t.jsx("th",{className:"text-left",children:"Detected"})]})}),t.jsx("tbody",{children:Ae.deindexed.map((O,ge)=>t.jsxs("tr",{children:[t.jsx("td",{className:"max-w-sm truncate text-zinc-200",children:O.url}),t.jsx("td",{className:"text-zinc-400",children:O.previousState}),t.jsx("td",{className:"text-zinc-400",children:O.currentState}),t.jsx("td",{className:"text-zinc-400",children:O.transitionDate.split("T")[0]})]},`${O.url}-${ge}`))})]}),(F==="indexed"&&Ae.indexed.length===0||F==="notIndexed"&&!Ft&&Ae.notIndexed.length===0||F==="deindexed"&&Ae.deindexed.length===0)&&t.jsx("p",{className:"text-sm text-zinc-500",children:"No URLs in this category."})]})]}):t.jsx("p",{className:"mt-3 text-sm text-zinc-500",children:Zt?"Loading coverage data…":"No coverage data yet. Inspect your sitemap to populate this view."})]}),t.jsxs(Se,{className:"surface-card",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Performance"}),t.jsx("h3",{children:"Search performance"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"flex gap-1",role:"tablist","aria-label":"Performance window",children:y$.map(O=>t.jsx("button",{type:"button",role:"tab","aria-selected":P===O,className:`px-2.5 py-1 text-xs rounded-full border transition-colors ${P===O?"bg-zinc-700 border-zinc-600 text-zinc-50":"border-zinc-800 text-zinc-400 hover:border-zinc-700 hover:text-zinc-300"}`,onClick:()=>ie(O),children:O==="all"?"All":O},O))}),t.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:Nt,onClick:()=>{V(0),Zs(0),Hi()},children:Nt?"Loading…":"Apply filters"})]})]}),v&&v.daily.length>0&&(()=>{const O=v.daily,ge=Math.max(...O.map(it=>it.impressions),1),{clicks:Fe,impressions:at,ctr:Dt}=v.totals,Cn=(Dt*100).toFixed(1),_n=700,Ys=220,qn={top:12,bottom:36,left:48,right:12},Ki=_n-qn.left-qn.right,Ts=Ys-qn.top-qn.bottom,En=Ki/O.length,fn=Math.max(Math.min(En*.35,24),4),ol=Math.max(fn*.15,1),ld=it=>{if(it<=0)return 1;const Jn=Math.pow(10,Math.floor(Math.log10(it))),Dn=it/Jn,os=Dn<=1.5?1.5:Dn<=3?3:Dn<=5?5:10;return Math.ceil(os*Jn)},Sa=4,mi=Math.ceil(ld(ge)/Sa)*Sa,Qi=Array.from({length:Sa+1},(it,Jn)=>mi/Sa*Jn),od=it=>it>=1e3?`${(it/1e3).toFixed(it>=1e4?0:1)}k`:String(it);return t.jsxs("div",{className:"mt-3",children:[t.jsxs("div",{className:"flex items-center gap-5 mb-2",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-sm bg-emerald-500"}),t.jsxs("span",{className:"text-xs text-zinc-400",children:["Clicks ",t.jsx("span",{className:"text-zinc-200 tabular-nums font-medium",children:Fe.toLocaleString()})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-sm bg-blue-500"}),t.jsxs("span",{className:"text-xs text-zinc-400",children:["Impressions ",t.jsx("span",{className:"text-zinc-200 tabular-nums font-medium",children:at.toLocaleString()})]})]}),t.jsxs("span",{className:"text-xs text-zinc-500",children:["CTR ",t.jsxs("span",{className:"text-amber-400 tabular-nums font-medium",children:[Cn,"%"]})]})]}),t.jsx("div",{className:"relative w-full",style:{aspectRatio:`${_n} / ${Ys}`},children:t.jsxs("svg",{viewBox:`0 0 ${_n} ${Ys}`,className:"h-full w-full",children:[Qi.map((it,Jn)=>{const Dn=qn.top+Ts-it/mi*Ts;return t.jsxs("g",{children:[t.jsx("line",{x1:qn.left,y1:Dn,x2:_n-qn.right,y2:Dn,stroke:"rgba(255,255,255,0.06)",strokeWidth:"1"}),t.jsx("text",{x:qn.left-6,y:Dn+3.5,textAnchor:"end",fill:"#a1a1aa",fontSize:"10",fontFamily:"inherit",children:od(it)})]},`t-${Jn}`)}),O.map((it,Jn)=>{const Dn=qn.left+En*Jn+En/2,os=it.impressions/mi*Ts,_s=it.clicks/mi*Ts;return t.jsxs("g",{children:[t.jsx("title",{children:`${it.date}
202
- Clicks: ${it.clicks}
203
- Impressions: ${it.impressions}
204
- CTR: ${(it.ctr*100).toFixed(1)}%`}),t.jsx("rect",{x:Dn-fn-ol/2,y:qn.top+Ts-os,width:fn,height:Math.max(os,1),rx:2,fill:"#3b82f6",opacity:.85}),t.jsx("rect",{x:Dn+ol/2,y:qn.top+Ts-_s,width:fn,height:Math.max(_s,1),rx:2,fill:"#10b981",opacity:.85})]},it.date)}),(()=>{const it=Math.min(O.length,7);return Array.from({length:it},(Jn,Dn)=>{const os=O.length===1?0:Math.round(Dn/(it-1)*(O.length-1)),_s=qn.left+En*os+En/2;return t.jsx("text",{x:_s,y:Ys-8,textAnchor:"middle",fill:"#71717a",fontSize:"10",fontFamily:"inherit",children:O[os].date.slice(5)},`xl-${os}`)})})()]})})]})})(),t.jsxs("div",{className:"mt-3 grid gap-2 lg:grid-cols-5",children:[t.jsx("input",{className:"rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",type:"date","aria-label":"Start date",title:"Start date (inclusive). Leave blank to use the window above.",value:te.startDate,onChange:O=>ze(ge=>({...ge,startDate:O.target.value}))}),t.jsx("input",{className:"rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",type:"date","aria-label":"End date",title:"End date (inclusive).",value:te.endDate,onChange:O=>ze(ge=>({...ge,endDate:O.target.value}))}),t.jsx("input",{className:"rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",type:"text",placeholder:"Contains query…","aria-label":"Filter query (substring match)",title:"Case-insensitive substring match on the query column.",value:te.query,onChange:O=>ze(ge=>({...ge,query:O.target.value}))}),t.jsx("input",{className:"rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",type:"text",placeholder:"Contains page URL…","aria-label":"Filter page (substring match)",title:"Case-insensitive substring match on the page URL.",value:te.page,onChange:O=>ze(ge=>({...ge,page:O.target.value}))}),t.jsx("input",{className:"rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",type:"number",min:"1",placeholder:"Rows per page (20)","aria-label":"Rows per page",title:"Rows per page. Ignored while a filter or column sort is active — then up to 500 matches are loaded.",value:te.limit,onChange:O=>ze(ge=>({...ge,limit:O.target.value}))})]}),t.jsxs("p",{className:"mt-2 text-xs text-zinc-500",children:["Query and page filters match case-insensitive substrings. Click Apply filters to run. When a filter or column sort is active, up to ",Wc.toLocaleString()," matching rows load so sorting covers the full set."]}),x.length>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"mt-3 overflow-x-auto",children:t.jsxs("table",{className:"data-table w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-left",children:"Date"}),t.jsx("th",{className:"text-left",children:"Query"}),t.jsx("th",{className:"text-left",children:"Page"}),Object.values(Wa).map(O=>t.jsx("th",{className:"text-right","aria-sort":He?.key===O?He.dir==="asc"?"ascending":"descending":"none",children:t.jsxs("button",{type:"button",className:"w-full cursor-pointer select-none text-right hover:text-zinc-200 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-zinc-400 rounded px-1 -mx-1",onClick:()=>ut(ge=>ge?.key===O?ge.dir==="desc"?{key:O,dir:"asc"}:null:{key:O,dir:"desc"}),children:[GD[O],He?.key===O?He.dir==="desc"?" ↓":" ↑":""]})},O))]})}),t.jsx("tbody",{children:ui.map((O,ge)=>t.jsxs("tr",{children:[t.jsx("td",{className:"text-zinc-400",children:O.date}),t.jsx("td",{className:"max-w-xs truncate text-zinc-200",children:O.query}),t.jsx("td",{className:"max-w-xs truncate text-zinc-400",children:O.page}),t.jsx("td",{className:"text-right tabular-nums text-zinc-300",children:O.clicks.toLocaleString()}),t.jsx("td",{className:"text-right tabular-nums text-zinc-400",children:O.impressions.toLocaleString()}),t.jsxs("td",{className:"text-right tabular-nums text-zinc-400",children:[(Number.isFinite(O.ctr)?O.ctr*100:0).toFixed(1),"%"]}),t.jsx("td",{className:"text-right tabular-nums text-zinc-400",children:O.position.toFixed(1)})]},`${O.date}:${O.query}:${O.page}:${ge}`))})]})}),pe?t.jsx("div",{className:"mt-3 text-xs text-zinc-500",children:t.jsxs("span",{className:"tabular-nums",children:["Showing ",Ne.toLocaleString()," matching row",Ne===1?"":"s",Ne>=Wc?` (capped at ${Wc.toLocaleString()} — narrow the filter to see more)`:""]})}):(ve>0||ne)&&(()=>{const O=parseInt(te.limit,10)||20,ge=ve+1,Fe=ve+x.length;return t.jsxs("div",{className:"mt-3 flex items-center justify-between text-xs text-zinc-500",children:[t.jsxs("span",{className:"tabular-nums",children:["Showing ",ge.toLocaleString()," – ",Fe.toLocaleString(),ne?"+":""]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:Nt||ve===0,onClick:()=>{const at=Math.max(0,ve-O);V(at),Zs(at)},children:"Previous"}),t.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:Nt||!ne,onClick:()=>{const at=ve+O;V(at),Zs(at)},children:"Next"})]})]})})()]}):t.jsx("p",{className:"mt-3 text-sm text-zinc-500",children:"No performance rows match the current filters yet."})]}),t.jsxs(Se,{className:"surface-card",children:[t.jsx("div",{className:"section-head",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Inspection"}),t.jsx("h3",{children:"Inspect a URL"})]})}),t.jsxs("div",{className:"mt-3 flex flex-col gap-2 lg:flex-row",children:[t.jsx("input",{className:"flex-1 rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",type:"url",placeholder:"https://example.com/page",value:L,onChange:O=>M(O.target.value),onKeyDown:O=>O.key==="Enter"&&void Fs()}),t.jsx(ee,{type:"button",size:"sm",disabled:Fn||!We?.propertyId||!L.trim(),onClick:Le(Fs),children:Fn?"Inspecting…":"Inspect URL"})]}),D&&t.jsxs("div",{className:"mt-3 grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[t.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/20 p-3",children:[t.jsx("p",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Indexing state"}),t.jsx("p",{className:"mt-1 text-sm text-zinc-200",children:D.indexingState??"Unknown"})]}),t.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/20 p-3",children:[t.jsx("p",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Verdict"}),t.jsx("p",{className:"mt-1 text-sm text-zinc-200",children:D.verdict??"Unknown"})]}),t.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/20 p-3",children:[t.jsx("p",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Mobile friendly"}),t.jsx("p",{className:"mt-1 text-sm text-zinc-200",children:Yy(D.isMobileFriendly??null)})]}),t.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/20 p-3",children:[t.jsx("p",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Last crawl"}),t.jsx("p",{className:"mt-1 text-sm text-zinc-200",children:$s(D.crawlTime)})]})]})]}),t.jsxs(Se,{className:"surface-card",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"History"}),t.jsx("h3",{children:"Inspection log"})]}),t.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:gt,onClick:()=>{Xn()},children:gt?"Loading…":"Refresh history"})]}),t.jsxs("div",{className:"mt-3 flex flex-col gap-2 lg:flex-row",children:[t.jsx("input",{className:"flex-1 rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",type:"text",placeholder:"Filter exact URL",value:X,onChange:O=>Y(O.target.value)}),t.jsx(ee,{type:"button",size:"sm",variant:"outline",disabled:gt,onClick:()=>{Xn()},children:"Apply filter"})]}),z.length>0?t.jsx("div",{className:"mt-3 overflow-x-auto",children:t.jsxs("table",{className:"data-table w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-left",children:"URL"}),t.jsx("th",{className:"text-left",children:"Indexing"}),t.jsx("th",{className:"text-left",children:"Verdict"}),t.jsx("th",{className:"text-left",children:"Coverage"}),t.jsx("th",{className:"text-left",children:"Mobile"}),t.jsx("th",{className:"text-left",children:"Inspected"})]})}),t.jsx("tbody",{children:z.map(O=>t.jsxs("tr",{children:[t.jsx("td",{className:"max-w-sm truncate text-zinc-200",children:O.url}),t.jsx("td",{className:"text-zinc-300",children:O.indexingState??"Unknown"}),t.jsx("td",{className:"text-zinc-400",children:O.verdict??"Unknown"}),t.jsx("td",{className:"text-zinc-400",children:O.coverageState??"Unknown"}),t.jsx("td",{className:"text-zinc-400",children:Yy(O.isMobileFriendly??null)}),t.jsx("td",{className:"text-zinc-400",children:$s(O.inspectedAt)})]},O.id))})]})}):t.jsx("p",{className:"mt-3 text-sm text-zinc-500",children:"No inspection history yet."})]}),t.jsxs(Se,{className:"surface-card",children:[t.jsx("div",{className:"section-head",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Deindexed"}),t.jsx("h3",{children:"Recent indexing losses"})]})}),w.length>0?t.jsx("div",{className:"mt-3 overflow-x-auto",children:t.jsxs("table",{className:"data-table w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-left",children:"URL"}),t.jsx("th",{className:"text-left",children:"Previous"}),t.jsx("th",{className:"text-left",children:"Current"}),t.jsx("th",{className:"text-left",children:"Changed at"})]})}),t.jsx("tbody",{children:w.map(O=>t.jsxs("tr",{children:[t.jsx("td",{className:"max-w-sm truncate text-zinc-200",children:O.url}),t.jsx("td",{className:"text-zinc-400",children:O.previousState??"Unknown"}),t.jsx("td",{className:"text-zinc-300",children:O.currentState??"Unknown"}),t.jsx("td",{className:"text-zinc-400",children:$s(O.transitionDate)})]},`${O.url}:${O.transitionDate}`))})]})}):t.jsx("p",{className:"mt-3 text-sm text-zinc-500",children:"No deindexed transitions recorded."})]})]}),We&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-t border-zinc-800/60 pt-3",children:t.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 text-left",onClick:()=>zs(O=>!O),children:[t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:`h-4 w-4 text-zinc-500 transition-transform ${Ss?"rotate-90":""}`,"aria-hidden":"true",children:t.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})}),t.jsx("span",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Setup & Configuration"})]})}),Ss&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[t.jsxs(Se,{className:"surface-card",children:[t.jsx("div",{className:"section-head",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Property"}),t.jsx("h3",{children:"Pick the Search Console property"})]})}),t.jsxs("div",{className:"mt-3 space-y-2",children:[t.jsx("label",{className:"text-xs text-zinc-500",htmlFor:`gsc-property-${e}`,children:"Property URL"}),t.jsx("select",{id:`gsc-property-${e}`,className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 focus:border-zinc-500 focus:outline-none",value:I,disabled:we||h.length===0,onChange:O=>C(O.target.value),children:h.length===0?t.jsx("option",{value:"",children:we?"Loading properties…":"No properties available"}):h.map(O=>t.jsxs("option",{value:O.siteUrl,children:[O.siteUrl," · ",O.permissionLevel]},O.siteUrl))}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(ee,{type:"button",size:"sm",variant:"outline",disabled:we,onClick:()=>{Bn(We)},children:we?"Refreshing…":"Refresh properties"}),t.jsx(ee,{type:"button",size:"sm",disabled:!I||Ce,onClick:Le(wa),children:Ce?"Saving…":"Save property"})]}),t.jsx("p",{className:"text-xs text-zinc-500",children:"The selected property is used for future syncs and URL inspections for this project."})]})]}),t.jsxs(Se,{className:"surface-card",children:[t.jsx("div",{className:"section-head",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Sync"}),t.jsx("h3",{children:"Import GSC performance data"})]})}),t.jsxs("div",{className:"mt-3 space-y-3",children:[t.jsxs("div",{className:"grid gap-3 sm:grid-cols-[160px_1fr]",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-xs text-zinc-500",htmlFor:`gsc-sync-days-${e}`,children:"Days"}),t.jsx("input",{id:`gsc-sync-days-${e}`,type:"number",min:"1",className:"mt-0.5 w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",value:_,onChange:O=>B(O.target.value)})]}),t.jsxs("label",{className:"flex items-center gap-2 rounded border border-zinc-800/60 bg-zinc-900/20 px-3 py-2 text-sm text-zinc-300",children:[t.jsx("input",{type:"checkbox",checked:J,onChange:O=>ue(O.target.checked)}),"Replace existing imported rows for the requested range"]})]}),t.jsx(ee,{type:"button",size:"sm",disabled:As.isPending||!We.propertyId,onClick:Le(di),children:As.isPending?"Queueing…":"Queue sync"}),!We.propertyId&&t.jsx("p",{className:"text-xs text-amber-400",children:"Select a Search Console property before queueing a sync."})]})]})]}),t.jsxs(Se,{className:"surface-card",children:[t.jsx("div",{className:"section-head",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Sitemap"}),t.jsx("h3",{children:"Sitemap configuration"})]})}),t.jsxs("div",{className:"mt-3 space-y-3",children:[We.sitemapUrl&&t.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/20 p-3",children:[t.jsx("p",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Current sitemap URL"}),t.jsx("p",{className:"mt-1 text-sm text-zinc-200 break-all",children:We.sitemapUrl})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(ee,{type:"button",size:"sm",variant:"outline",disabled:ws||!We.propertyId,onClick:()=>{rd()},children:ws?"Loading…":"Browse sitemaps from GSC"}),t.jsx(ee,{type:"button",size:"sm",variant:"outline",disabled:mn.isPending||!We.propertyId,onClick:Le(Ao),children:mn.isPending?"Discovering…":"Auto-discover and queue inspection"})]}),t.jsx("p",{className:"text-xs text-zinc-500",children:"Browse lists available sitemaps without queueing a run. Auto-discover saves the primary sitemap and queues an inspection."}),$n&&$n.length>0&&t.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/20 p-3 space-y-2",children:[t.jsxs("p",{className:"text-xs uppercase tracking-wide text-zinc-500",children:["Sitemaps (",$n.length,")"]}),$n.map(O=>{const ge=O.contents?.[0];return t.jsxs("div",{className:"flex items-start justify-between gap-2 text-xs",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-zinc-200 break-all",children:O.path}),O.lastSubmitted&&t.jsxs("p",{className:"text-zinc-500",children:["Submitted: ",O.lastSubmitted.split("T")[0]]})]}),t.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[ge&&t.jsxs("div",{className:"text-right",children:[t.jsxs("p",{className:"text-zinc-300",children:[ge.indexed," / ",ge.submitted]}),t.jsx("p",{className:"text-zinc-500",children:"indexed"})]}),t.jsx("button",{type:"button",className:"text-xs text-zinc-400 hover:text-zinc-200 transition-colors",onClick:()=>zn(O.path),children:"Use"})]})]},O.path)})]}),t.jsxs("div",{className:"flex flex-col gap-2 lg:flex-row",children:[t.jsx("input",{className:"flex-1 rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",type:"url",placeholder:We.sitemapUrl?"Update sitemap URL…":"https://example.com/sitemap.xml",value:dn,onChange:O=>zn(O.target.value),onKeyDown:O=>O.key==="Enter"&&dn.trim()&&void va()}),t.jsx(ee,{type:"button",size:"sm",disabled:rs||!dn.trim(),onClick:Le(va),children:rs?"Saving…":We.sitemapUrl?"Update":"Save"})]}),t.jsxs("div",{className:"flex flex-col gap-2 lg:flex-row",children:[t.jsx("input",{className:"flex-1 rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",type:"url",placeholder:"Sitemap URL for inspection (leave empty for saved default)",id:`gsc-sitemap-inspect-${e}`}),t.jsx(ee,{type:"button",size:"sm",variant:"outline",disabled:Qs.isPending||!We.propertyId,onClick:Le(async()=>{const ge=document.getElementById(`gsc-sitemap-inspect-${e}`)?.value?.trim()||We.sitemapUrl||void 0;Xe(null),$e(null);try{await Qs.mutateAsync({projectName:e,projectLabel:e,opts:{sitemapUrl:ge}})}catch{}}),children:Qs.isPending?"Queueing…":"Inspect sitemap"})]}),!We.propertyId&&t.jsx("p",{className:"text-xs text-amber-400",children:"Select a Search Console property first."})]})]})]})]})]})]})}function Oh({children:e,label:s="More info",placement:i="top",className:r}){const o=j.useId(),[u,d]=j.useState(!1);return t.jsxs("span",{className:`relative inline-flex ${r??""}`,children:[t.jsx("button",{type:"button","aria-label":s,"aria-describedby":u?o:void 0,className:"inline-flex h-4 w-4 items-center justify-center rounded-full text-zinc-500 hover:text-zinc-200 focus:text-zinc-200 focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-500",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onFocus:()=>d(!0),onBlur:()=>d(!1),children:t.jsx(_v,{className:"h-3.5 w-3.5","aria-hidden":!0})}),u&&t.jsx("span",{id:o,role:"tooltip",className:`absolute z-50 w-64 rounded border border-zinc-700 bg-zinc-900 px-3 py-2 text-xs font-normal leading-relaxed text-zinc-200 shadow-lg ${i==="top"?"bottom-full mb-2":"top-full mt-2"} left-1/2 -translate-x-1/2 whitespace-normal`,children:e})]})}const _i=50;function Tr(e){return typeof window>"u"?e:`${window.__CANONRY_CONFIG__?.basePath?.replace(/\/$/,"")??""}${e}`}function eu(e){return e.toLocaleString()}function v$(e){const s=Number(e);return Number.isFinite(s)?`${(s*100).toFixed(1)}%`:"—"}function j$(e){const s=Date.now()-new Date(e).getTime(),i=Math.floor(s/6e4);if(i<1)return"just now";if(i<60)return`${i}m ago`;const r=Math.floor(i/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function N$(e){const s=e.filter(i=>i.kind===et["backlink-extract"]&&!Hf(i.status));return s.length===0?null:s.reduce((i,r)=>i.createdAt>r.createdAt?i:r)}function w$(e,s){const i=new Date(e??s).getTime(),r=Math.max(0,Math.floor((Date.now()-i)/1e3));if(r<60)return`${r}s`;const o=Math.floor(r/60),u=r%60;return u===0?`${o}m`:`${o}m ${u}s`}function S$({projectName:e}){const[s,i]=j.useState(null),[r,o]=j.useState(null),[u,d]=j.useState([]),[h,p]=j.useState(null),[x,b]=j.useState(null),[v,N]=j.useState(null),[z,T]=j.useState(Date.now()),[w,A]=j.useState(0),[D,U]=j.useState(!0),[I,C]=j.useState(!1),[L,M]=j.useState(null),_=j.useRef(null),B=j.useCallback(async()=>{U(!0),M(null);try{const[me,Ne,se,pe,E]=await Promise.all([zv().catch(()=>null),gC(e,{excludeCrawlers:!0}).catch(()=>null),xC(e,{limit:_i,offset:w,excludeCrawlers:!0}).catch(Y=>{if(Y instanceof un&&Y.code==="NOT_FOUND")return null;throw Y}),yC(e).catch(()=>[]),u2(e).catch(()=>[])]);p(me),i(Ne),o(se),d(pe);const X=N$(E);b(X),_.current=X?.id??null}catch(me){M(me instanceof Error?me.message:"Failed to load backlinks")}finally{U(!1)}},[e,w]);j.useEffect(()=>{B()},[B]),j.useEffect(()=>{if(!x)return;const me=x.id;let Ne=!1;const se=async()=>{try{const E=await Kr(me);if(Ne)return;Hf(E.status)?(b(null),N(E),await B()):b(X=>X?.id===E.id?{...X,...E}:X)}catch{}},pe=window.setInterval(()=>{se()},3e3);return()=>{Ne=!0,window.clearInterval(pe)}},[x,B]),j.useEffect(()=>{if(!x)return;const me=window.setInterval(()=>T(Date.now()),1e3);return()=>window.clearInterval(me)},[x]),j.useEffect(()=>{if(!v||v.status==="failed")return;const me=window.setTimeout(()=>N(null),1e4);return()=>window.clearTimeout(me)},[v]);async function J(){C(!0),M(null);try{const me=await bC(e);b(me),_.current=me.id}catch(me){me instanceof un&&me.code==="MISSING_DEPENDENCY"?M("DuckDB is not installed. Visit the Backlinks admin page to install it."):M(me instanceof Error?me.message:"Failed to trigger extract")}finally{C(!1)}}const ue=j.useMemo(()=>u.slice().sort((me,Ne)=>me.queriedAt.localeCompare(Ne.queriedAt)).map(me=>({date:me.queriedAt,linkingDomains:me.totalLinkingDomains})),[u]),P=r?.rows??[],ie=r?.total??0,te=s?.excludedLinkingDomains??0,ze=ie>_i,ve=Math.floor(w/_i)+1,V=Math.max(1,Math.ceil(ie/_i));return j.useEffect(()=>{w>0&&w>=ie&&A(0)},[w,ie]),t.jsxs("section",{className:"page-section-divider",children:[t.jsx("div",{className:"section-head section-head-inline",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Backlinks"}),t.jsx("h2",{children:"Referring domains"}),t.jsxs("p",{className:"text-sm text-zinc-500 mt-1 max-w-2xl",children:["Domains linking to "," ",t.jsx("span",{className:"text-zinc-300",children:e}),", extracted from the Common Crawl hyperlink graph. Updates when a release sync completes — no live scraping, no paid API."]})]})}),L&&t.jsx(Se,{className:"surface-card p-4 mb-4 border-rose-800/60",children:t.jsx("p",{className:"text-sm text-rose-300",children:L})}),x&&t.jsx(Se,{className:"surface-card p-4 mb-4 border-sky-800/60",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(Ov,{className:"h-5 w-5 text-sky-400 animate-spin shrink-0 mt-0.5","aria-hidden":!0}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("p",{className:"text-sm font-medium text-zinc-100",children:"Extract running"}),t.jsx(Ke,{tone:"neutral",children:x.status}),t.jsxs("span",{className:"text-xs text-zinc-500 tabular-nums",children:[w$(x.startedAt??null,x.createdAt)," elapsed · refreshing every 3s"]}),t.jsxs("span",{className:"sr-only",children:["now=",z]})]}),t.jsxs("p",{className:"text-xs text-zinc-500 mt-1",children:["Re-querying the cached Common Crawl release for"," ",t.jsx("span",{className:"text-zinc-300",children:e}),". No re-download — the ~16 GB dump already lives at"," ",t.jsx("code",{className:"text-zinc-400",children:"~/.canonry/cache/commoncrawl/"}),". Typically takes ~5 minutes."]})]})]})}),v&&!x&&t.jsx(Se,{className:`surface-card p-4 mb-4 ${v.status==="failed"?"border-rose-800/60":"border-emerald-800/60"}`,children:t.jsxs("div",{className:"flex items-start gap-3",children:[v.status==="failed"?t.jsx("span",{className:"h-5 w-5 shrink-0 mt-0.5 text-rose-400 text-lg leading-none","aria-hidden":!0,children:"!"}):t.jsx(zf,{className:"h-5 w-5 text-emerald-400 shrink-0 mt-0.5","aria-hidden":!0}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:`text-sm font-medium ${v.status==="failed"?"text-rose-300":"text-emerald-300"}`,children:v.status==="failed"?"Extract failed":"Extract complete"}),v.error?t.jsx("p",{className:"text-xs text-zinc-500 mt-1",children:VD(v.error)}):v.status!=="failed"?t.jsx("p",{className:"text-xs text-zinc-500 mt-1",children:"Backlinks refreshed from the cached release."}):null]})]})}),ne()]});function ne(){if(D)return t.jsx(Se,{className:"surface-card p-6",children:t.jsx("p",{className:"text-sm text-zinc-500",children:"Loading backlinks…"})});const me=s!==null&&s.totalLinkingDomains>0,Ne=v?.status==="failed",se=s!==null&&s.totalLinkingDomains===0&&!Ne,pe=h?.status==="ready",E=h?.status==="failed",X=h&&(h.status==="downloading"||h.status==="querying"||h.status==="queued");return me?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"gauge-row",children:[t.jsxs("div",{className:"metric-card",children:[t.jsx("p",{className:"metric-card-eyebrow",children:"Referring domains"}),t.jsx("p",{className:"metric-card-big-value",children:t.jsx("span",{className:"text-zinc-50",children:eu(s.totalLinkingDomains)})}),t.jsxs("p",{className:"metric-card-sub",children:["unique domains linking to ",s.targetDomain]})]}),t.jsxs("div",{className:"metric-card",children:[t.jsx("p",{className:"metric-card-eyebrow",children:"Total linking hosts"}),t.jsx("p",{className:"metric-card-big-value",children:t.jsx("span",{className:"text-zinc-50",children:eu(s.totalHosts)})}),t.jsx("p",{className:"metric-card-sub",children:"aggregate host count across referring domains"})]}),t.jsxs("div",{className:"metric-card",children:[t.jsx("p",{className:"metric-card-eyebrow",children:"Top-10 concentration"}),t.jsx("p",{className:"metric-card-big-value",children:t.jsx("span",{className:"text-zinc-50",children:v$(s.top10HostsShare)})}),t.jsx("p",{className:"metric-card-sub",children:"share of hosts from the 10 largest linking domains"})]})]}),t.jsxs("p",{className:"text-xs text-zinc-600 mt-2",children:["Release ",t.jsx("code",{className:"text-zinc-400",children:s.release})," · queried ",j$(s.queriedAt),te>0&&t.jsxs(t.Fragment,{children:[" · ",t.jsxs("span",{className:"text-zinc-500",children:[te," crawler/proxy domain",te===1?"":"s"," hidden"]})]})]}),ue.length>=2&&t.jsxs(Se,{className:"surface-card p-4 mt-4",children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Referring domains over releases"}),t.jsx("div",{className:"h-40 mt-2",children:t.jsx(uu,{width:"100%",height:"100%",children:t.jsxs(Uh,{data:ue,margin:{top:8,right:12,bottom:0,left:12},children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:"bl-gradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:Gr[0],stopOpacity:.4}),t.jsx("stop",{offset:"100%",stopColor:Gr[0],stopOpacity:0})]})}),t.jsx(du,{dataKey:"date",tick:ei,stroke:Xr,tickFormatter:pf}),t.jsx(mu,{tick:ei,stroke:Xr,allowDecimals:!1}),t.jsx(hu,{contentStyle:Pr.contentStyle,labelStyle:Pr.labelStyle,itemStyle:Pr.itemStyle,labelFormatter:ff}),t.jsx(ao,{type:"monotone",dataKey:"linkingDomains",name:"Referring domains",stroke:Gr[0],fill:"url(#bl-gradient)",strokeWidth:2})]})})})]}),t.jsxs("div",{className:"mt-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Top referring domains"}),ze&&t.jsxs("p",{className:"text-xs text-zinc-600",children:["Page ",ve," of ",V," · ",eu(ie)," total"]})]}),t.jsx(Se,{className:"surface-card overflow-hidden",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-zinc-800 text-left text-xs uppercase tracking-wide text-zinc-600",children:[t.jsx("th",{className:"px-4 py-2 font-medium",children:"Domain"}),t.jsx("th",{className:"px-4 py-2 text-right font-medium",children:"Linking hosts"})]})}),t.jsxs("tbody",{children:[P.map(Y=>t.jsxs("tr",{className:"border-b border-zinc-900 last:border-0",children:[t.jsx("td",{className:"px-4 py-2 text-zinc-200",children:Y.linkingDomain}),t.jsx("td",{className:"px-4 py-2 text-right text-zinc-400 tabular-nums",children:eu(Y.numHosts)})]},Y.linkingDomain)),P.length===0&&t.jsx("tr",{children:t.jsx("td",{className:"px-4 py-4 text-sm text-zinc-500",colSpan:2,children:te>0&&ie===0?`Every referring domain in this release was a crawler/proxy host (${te} hidden).`:"No referring domains in this release."})})]})]})}),ze&&t.jsxs("div",{className:"flex items-center justify-end gap-2 mt-2",children:[t.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:w===0,onClick:()=>A(Y=>Math.max(0,Y-_i)),children:"Previous"}),t.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:w+_i>=ie,onClick:()=>A(Y=>Y+_i),children:"Next"})]})]}),t.jsxs("div",{className:"mt-4 flex items-center gap-3 flex-wrap",children:[t.jsxs(ee,{type:"button",variant:"outline",size:"sm",disabled:I||x!==null,onClick:Le(J),children:[t.jsx(Eu,{className:"h-4 w-4 mr-1.5","aria-hidden":!0}),x?"Extract running…":I?"Queuing…":"Re-run extract"]}),t.jsxs(Oh,{label:"What does Re-run extract do?",children:[t.jsxs("span",{className:"block",children:["Re-queries the ",t.jsx("span",{className:"text-zinc-200",children:"cached release files"})," at"," ",t.jsx("code",{className:"text-zinc-300",children:"~/.canonry/cache/commoncrawl/"})," for ",t.jsx("span",{className:"text-zinc-200",children:e}),". Replaces existing backlink rows for this project under the current release."]}),t.jsxs("span",{className:"mt-2 block text-zinc-400",children:[t.jsx("span",{className:"text-zinc-200",children:"No re-download"})," of the ~16 GB dump. Typically ",t.jsx("span",{className:"text-zinc-200",children:"~5 min"}),"."]})]}),t.jsx(ee,{asChild:!0,type:"button",variant:"outline",size:"sm",children:t.jsx("a",{href:Tr("/backlinks"),children:"Open admin"})})]})]}):t.jsx(Se,{className:"surface-card p-6",children:t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-zinc-900 text-zinc-400",children:t.jsx(Dv,{className:"h-5 w-5","aria-hidden":!0})}),t.jsxs("div",{className:"flex-1",children:[!h&&t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"text-base font-semibold text-zinc-100",children:"No release sync yet"}),t.jsx("p",{className:"text-sm text-zinc-500 mt-1",children:"Run a workspace release sync to populate backlinks for every project in this workspace."}),t.jsx("div",{className:"mt-4",children:t.jsx(ee,{asChild:!0,type:"button",size:"sm",children:t.jsx("a",{href:Tr("/backlinks"),children:"Set up backlinks"})})})]}),X&&t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"text-base font-semibold text-zinc-100",children:"Sync in progress"}),t.jsxs("p",{className:"text-sm text-zinc-500 mt-1",children:["A workspace release sync is running (",h.status,h.phaseDetail?` — ${h.phaseDetail}`:"","). Backlinks will appear here once it finishes."]}),t.jsx("div",{className:"mt-4",children:t.jsx(ee,{asChild:!0,type:"button",variant:"outline",size:"sm",children:t.jsx("a",{href:Tr("/backlinks"),children:"View sync status"})})})]}),E&&t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"text-base font-semibold text-zinc-100",children:"Last sync failed"}),t.jsx("p",{className:"text-sm text-zinc-500 mt-1",children:h.error??"The workspace release sync failed. Retry from the Backlinks admin page."}),t.jsx("div",{className:"mt-4",children:t.jsx(ee,{asChild:!0,type:"button",size:"sm",children:t.jsx("a",{href:Tr("/backlinks"),children:"Go to Backlinks admin"})})})]}),pe&&!X&&!se&&!Ne&&t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"text-base font-semibold text-zinc-100",children:"No backlinks yet for this project"}),t.jsxs("p",{className:"text-sm text-zinc-500 mt-1",children:["Release ",t.jsx("code",{className:"text-zinc-300",children:h.release})," is ready but no backlinks have been extracted for"," ",t.jsx("code",{className:"text-zinc-300",children:e}),". Run an extract to populate data using the cached release."]}),t.jsxs("div",{className:"mt-4 flex items-center gap-3 flex-wrap",children:[t.jsxs(ee,{type:"button",size:"sm",disabled:I||x!==null,onClick:Le(J),children:[t.jsx(uo,{className:"h-4 w-4 mr-1.5","aria-hidden":!0}),x?"Extract running…":I?"Queuing…":"Run extract"]}),t.jsxs(Oh,{label:"What does Run extract do?",children:[t.jsxs("span",{className:"block",children:["Runs a DuckDB query against the ",t.jsx("span",{className:"text-zinc-200",children:"cached release files"})," at"," ",t.jsx("code",{className:"text-zinc-300",children:"~/.canonry/cache/commoncrawl/"})," to find referring domains for ",t.jsx("span",{className:"text-zinc-200",children:e}),"."]}),t.jsxs("span",{className:"mt-2 block text-zinc-400",children:["No re-download. Typically takes ",t.jsx("span",{className:"text-zinc-200",children:"~5 min"}),"."]})]})]})]}),Ne&&t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"text-base font-semibold text-zinc-100",children:"Last extract failed"}),t.jsxs("p",{className:"text-sm text-zinc-500 mt-1",children:["See the error above for details. If the cache files for release"," ",t.jsx("code",{className:"text-zinc-300",children:h?.release})," are missing, re-sync the release from the Backlinks admin to restore the ~16 GB dump, then re-run the extract."]}),t.jsx("div",{className:"mt-4 flex items-center gap-3 flex-wrap",children:t.jsx(ee,{asChild:!0,type:"button",size:"sm",children:t.jsx("a",{href:Tr("/backlinks"),children:"Go to Backlinks admin"})})})]}),se&&t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"text-base font-semibold text-zinc-100",children:"No referring domains found"}),t.jsxs("p",{className:"text-sm text-zinc-500 mt-1",children:["The last extract against release ",t.jsx("code",{className:"text-zinc-300",children:s.release})," found"," ",t.jsx("span",{className:"text-zinc-300",children:"0 referring domains"})," for"," ",t.jsx("code",{className:"text-zinc-300",children:s.targetDomain}),". This can happen when:"]}),t.jsxs("ul",{className:"mt-2 space-y-1 text-xs text-zinc-500 list-disc list-inside",children:[t.jsx("li",{children:"the domain is newer than the release’s crawl window"}),t.jsx("li",{children:"the Common Crawl snapshot didn’t capture pages that link to it"}),t.jsx("li",{children:"the extract ran against a cache that was missing or incomplete"})]}),t.jsx("p",{className:"text-sm text-zinc-500 mt-3",children:"Try syncing a newer release — each Common Crawl dump is a different snapshot of the web graph."}),t.jsxs("div",{className:"mt-4 flex items-center gap-3 flex-wrap",children:[t.jsx(ee,{asChild:!0,type:"button",size:"sm",children:t.jsx("a",{href:Tr("/backlinks"),children:"Go to Backlinks admin"})}),t.jsxs(ee,{type:"button",variant:"outline",size:"sm",disabled:I||x!==null,onClick:Le(J),children:[t.jsx(uo,{className:"h-4 w-4 mr-1.5","aria-hidden":!0}),x?"Extract running…":I?"Queuing…":"Re-run extract"]}),t.jsxs(Oh,{label:"What does Re-run extract do?",children:[t.jsxs("span",{className:"block",children:["Re-queries the cached release for ",t.jsx("span",{className:"text-zinc-200",children:s.targetDomain}),". Only useful if the cache files were incomplete last time."]}),t.jsx("span",{className:"mt-2 block text-zinc-400",children:"No re-download. ~5 min. If the release genuinely has no links for your domain, this won’t help — sync a different release instead."})]})]})]})]})]})})}}function z$({projectName:e}){const s=tn({...EO({client:ae,path:{name:e}}),staleTime:Cv}),i=s.data??null,r=s.error;if(s.isLoading&&!i)return null;if(r)return t.jsxs("section",{className:"page-section-divider",children:[t.jsx("div",{className:"section-head section-head-inline",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Citation visibility"}),t.jsx("h2",{children:"Citation + answer-mention coverage"})]})}),t.jsx("p",{className:"text-sm text-rose-400",children:r instanceof Error?r.message:String(r)})]});if(!i)return null;if(i.status==="no-data")return t.jsxs("section",{className:"page-section-divider",children:[t.jsx("div",{className:"section-head section-head-inline",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Citation visibility"}),t.jsx("h2",{children:"Citation + answer-mention coverage"})]})}),t.jsx("p",{className:"text-sm text-zinc-500",children:i.reason==="no-queries"?"Add queries to start tracking AI citations.":"Run a sweep to see which engines cite this project."})]});const{providersCiting:o,providersMentioning:u,providersConfigured:d}=i.summary;return t.jsxs("section",{className:"page-section-divider",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Citation visibility"}),t.jsxs("h2",{className:"flex items-center gap-2",children:["Cited by ",o," of ",d," engines",t.jsx(on,{text:"An engine is ‘citing’ when our domain appears in its grounding source list (the structured citation/search-result attribution it returns alongside the answer). Counts each configured engine that cites the project on at least one tracked query in the latest snapshot per (query × provider)."})]}),t.jsxs("p",{className:"text-base text-zinc-300 flex items-center gap-2",children:["Mentioned in ",u," of ",d," engine answers",t.jsx(on,{text:"An engine is ‘mentioning’ when our brand or domain appears inside the prose of the answer text — independent of whether it’s in the citation list. Models often name-drop from training without citing a fresh page."})]})]}),i.summary.latestRunAt&&t.jsxs("p",{className:"supporting-copy",children:["Latest run ",new Date(i.summary.latestRunAt).toLocaleString()]})]}),t.jsx(k$,{data:i}),t.jsx(C$,{data:i}),i.competitorGaps.length>0&&t.jsx(E$,{data:i})]})}function k$({data:e}){const{totalQueries:s,queriesCitedAndMentioned:i,queriesCitedOnly:r,queriesMentionedOnly:o,queriesInvisible:u}=e.summary;return t.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4 mb-4",children:[t.jsx(tu,{label:"Cited + mentioned",value:`${i} / ${s}`,helper:"In sources AND named in answer",tone:i>0?"positive":"neutral"}),t.jsx(tu,{label:"Cited only",value:`${r} / ${s}`,helper:"In sources, not named in answer",tone:r>0?"positive-dim":"neutral"}),t.jsx(tu,{label:"Mentioned only",value:`${o} / ${s}`,helper:"Named in answer, no source link",tone:o>0?"caution":"neutral"}),t.jsx(tu,{label:"Invisible",value:`${u} / ${s}`,helper:"No engine cites or mentions",tone:u>0?"negative":"neutral"})]})}function tu({label:e,value:s,helper:i,tone:r}){const o=r==="positive"?"text-emerald-300":r==="positive-dim"?"text-emerald-400/70":r==="caution"?"text-amber-300":r==="negative"?"text-rose-300":"text-zinc-100";return t.jsxs("div",{className:"rounded-md border border-zinc-800/60 bg-zinc-900/30 px-4 py-3",children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:e}),t.jsx("p",{className:`mt-1 text-2xl font-semibold tabular-nums ${o}`,children:s}),t.jsx("p",{className:"text-[11px] text-zinc-500",children:i})]})}function C$({data:e}){const s=j.useMemo(()=>{const i=new Set;for(const r of e.byQuery)for(const o of r.providers)i.add(o.provider);return Array.from(i).sort()},[e.byQuery]);return e.byQuery.length===0?t.jsx("p",{className:"text-sm text-zinc-500",children:"No query coverage rows."}):t.jsxs("div",{children:[t.jsx(A$,{}),t.jsx("div",{className:"evidence-table-wrap",children:t.jsxs("table",{className:"evidence-table",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"Query"}),s.map(i=>t.jsx("th",{className:"text-center",children:t.jsx($i,{provider:i})},i)),t.jsx("th",{className:"text-right",children:"Cite"}),t.jsx("th",{className:"text-right",children:"Ment"})]})}),t.jsx("tbody",{children:e.byQuery.map(i=>t.jsxs("tr",{children:[t.jsx("td",{className:"font-medium text-zinc-100",children:i.query}),s.map(r=>{const o=i.providers.find(u=>u.provider===r);return t.jsx("td",{className:"text-center",children:o==null?t.jsx(xA,{className:"inline h-3.5 w-3.5 text-zinc-700","aria-label":"no data"}):t.jsx(T$,{provider:o})},r)}),t.jsx("td",{className:"text-right tabular-nums",children:t.jsxs("span",{className:i.totalProviders>0&&i.citedCount===i.totalProviders?"text-emerald-300":i.citedCount>0?"text-emerald-400/70":"text-zinc-500",children:[i.citedCount,"/",i.totalProviders]})}),t.jsx("td",{className:"text-right tabular-nums",children:t.jsxs("span",{className:i.totalProviders>0&&i.mentionedCount===i.totalProviders?"text-sky-300":i.mentionedCount>0?"text-sky-400/70":"text-zinc-500",children:[i.mentionedCount,"/",i.totalProviders]})})]},i.queryId))})]})})]})}function A$(){return t.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-3 text-[11px] text-zinc-500",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Mr,{active:!0,tone:"cited"}),t.jsx("span",{children:"cited (in sources)"})]}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Mr,{active:!0,tone:"mentioned"}),t.jsx("span",{children:"mentioned (in answer)"})]}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Mr,{active:!1,tone:"cited"}),t.jsx(Mr,{active:!1,tone:"mentioned"}),t.jsx("span",{children:"neither"})]})]})}function T$({provider:e}){const s=_$(e);return t.jsxs("span",{className:"inline-flex items-center justify-center gap-1",title:s,children:[t.jsx(Mr,{active:e.cited,tone:"cited"}),t.jsx(Mr,{active:e.mentioned,tone:"mentioned"})]})}function _$(e){return e.cited&&e.mentioned?"Cited in sources and mentioned in answer":e.cited?"Cited in sources, not mentioned in answer":e.mentioned?"Mentioned in answer, not in sources":"Not cited and not mentioned"}function Mr({active:e,tone:s}){if(!e)return t.jsx("span",{className:"inline-block h-2 w-2 rounded-full border border-zinc-700/80 bg-transparent","aria-hidden":"true"});const i=s==="cited"?"inline-block h-2 w-2 rounded-full bg-emerald-400 shadow-[0_0_0_1px_rgba(16,185,129,0.25)]":"inline-block h-2 w-2 rounded-full bg-sky-400 shadow-[0_0_0_1px_rgba(56,189,248,0.25)]";return t.jsx("span",{className:i,"aria-hidden":"true"})}function E$({data:e}){return t.jsxs("div",{className:"mt-4",children:[t.jsxs("h3",{className:"text-sm font-semibold text-zinc-200 mb-2 flex items-center gap-2",children:["Competitor gaps",t.jsx(on,{text:"Queries where the project is not cited but a configured competitor is. Each row maps to one (query, engine) pair — the same query may surface for multiple engines."}),t.jsxs("span",{className:"text-[10px] font-normal uppercase tracking-wide text-zinc-500",children:[e.competitorGaps.length," ",e.competitorGaps.length===1?"gap":"gaps"]})]}),t.jsx("div",{className:"evidence-table-wrap",children:t.jsxs("table",{className:"evidence-table",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"Query"}),t.jsx("th",{children:"Engine"}),t.jsx("th",{children:"Competitors cited"})]})}),t.jsx("tbody",{children:e.competitorGaps.map(s=>t.jsxs("tr",{children:[t.jsx("td",{className:"font-medium text-zinc-100",children:s.query}),t.jsx("td",{children:t.jsx($i,{provider:s.provider})}),t.jsx("td",{className:"text-zinc-300",children:s.citingCompetitors.join(", ")})]},`${s.queryId}::${s.provider}`))})]})})]})}const xf=new Set(["queued","seeding","probing"]);function D$({projectName:e}){const s=wn(),[i,r]=j.useState(null),[o,u]=j.useState(""),[d,h]=j.useState("100"),p=tn({...IO({client:ae,path:{name:e},query:{limit:"10"}}),refetchInterval:C=>C.state.data?.some(M=>xf.has(M.status))?3e3:!1}),x=p.data??[];j.useEffect(()=>{!i&&x[0]&&r(x[0].id)},[i,x]);const b=x.find(C=>C.id===i)??null,v=tn({...PO({client:ae,path:{name:e,id:i??""}}),enabled:!!i,refetchInterval:b&&xf.has(b.status)?3e3:!1}),N=v.data??null,z=tn({...VO({client:ae,path:{name:e,id:i??""}}),enabled:!!(i&&b?.status==="completed")}),T=bs({mutationFn:()=>{const C={},L=o.trim();L&&(C.icpDescription=L);const M=Number.parseInt(d,10);return Number.isFinite(M)&&M>0&&(C.maxProbes=M),G2(e,C)},onSuccess:async C=>{r(C.sessionId),u(""),await Lb(s,e,C.sessionId),Qe({title:"Discovery started",detail:`Run ${Rh(C.sessionId)} is testing questions your customers might ask.`,tone:"neutral",dedupeKey:`discovery:start:${C.sessionId}`,dedupeMode:"replace"})},onError:C=>{Qe({title:"Discovery failed to start",detail:C instanceof Error?C.message:"Could not start discovery.",tone:"negative"})}}),w=bs({mutationFn:C=>{if(!i)throw new Error("Select a completed discovery session first.");return V2(e,i,C)},onSuccess:async C=>{await Lb(s,e,C.sessionId),s.invalidateQueries({queryKey:li({client:ae})}),Qe({title:"Queries added",detail:M$(C),tone:"positive",dedupeKey:`discovery:promote:${C.sessionId}`,dedupeMode:"replace"})},onError:C=>{Qe({title:"Could not add queries",detail:C instanceof Error?C.message:"Could not add queries from this run.",tone:"negative"})}}),A=N??b,D=z.data??null,U=(D?.queriesByBucket.cited.length??0)+(D?.queriesByBucket.aspirational.length??0),I=j.useMemo(()=>(N?.probes??[]).slice(0,30),[N?.probes]);return t.jsxs("section",{className:"page-section-divider",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Discovery"}),t.jsx("h2",{children:"Find new queries to track"}),t.jsx("p",{className:"mt-1 max-w-3xl text-sm leading-6 text-zinc-500",children:"Describe your ideal customer and Canonry generates the questions they would ask an AI engine, checks which ones already cite your site, then lets you add the promising ones to your tracked queries."})]}),t.jsxs(ee,{type:"button",variant:"outline",size:"sm",disabled:p.isFetching,onClick:()=>{p.refetch()},children:[t.jsx(mo,{size:14}),"Refresh"]})]}),t.jsxs("div",{className:"grid gap-4 xl:grid-cols-[360px_minmax(0,1fr)]",children:[t.jsxs("div",{className:"space-y-4",children:[t.jsxs(Se,{className:"surface-card",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 1"}),t.jsx("h3",{children:"Describe your customer"})]}),t.jsx(Ke,{tone:"neutral",children:"Runs on Gemini"})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"text-xs text-zinc-500",children:"Who is your ideal customer?"}),t.jsx("textarea",{className:"mt-1 min-h-24 w-full rounded border border-zinc-700 bg-transparent px-3 py-2 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"e.g. Small e-commerce stores that want AI-powered customer support. Leave blank to use the customer profile saved on this project.",value:o,onChange:C=>u(C.target.value)})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"text-xs text-zinc-500",children:"How many questions to test"}),t.jsx("input",{className:"mt-1 w-full rounded border border-zinc-700 bg-transparent px-3 py-2 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",inputMode:"numeric",value:d,onChange:C=>h(C.target.value)}),t.jsx("span",{className:"mt-1 block text-[11px] text-zinc-600",children:"More questions means broader coverage but a longer run. 100 is a good default."})]}),t.jsxs(ee,{type:"button",size:"sm",disabled:T.isPending,onClick:()=>T.mutate(),children:[t.jsx(uo,{size:14}),T.isPending?"Starting…":"Find queries"]})]})]}),t.jsxs(Se,{className:"surface-card",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"History"}),t.jsx("h3",{children:"Recent runs"})]}),p.isFetching&&t.jsx(Ke,{tone:"neutral",children:"Loading"})]}),x.length===0?t.jsx("p",{className:"text-sm text-zinc-500",children:"No discovery runs yet. Describe your customer above to start your first one."}):t.jsx("div",{className:"space-y-2",children:x.map(C=>t.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-2 text-left transition-colors ${i===C.id?"border-zinc-600 bg-zinc-900/70":"border-zinc-800/60 bg-zinc-950/40 hover:border-zinc-700 hover:bg-zinc-900/40"}`,onClick:()=>r(C.id),children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm font-medium text-zinc-100",children:Rh(C.id)}),t.jsx(Ke,{tone:Rb(C.status),children:C.status})]}),t.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-[11px] text-zinc-500",children:[t.jsxs("span",{children:["Cited ",C.citedCount??0]}),t.jsxs("span",{children:["Opportunity ",C.aspirationalCount??0]}),t.jsxs("span",{children:["Low value ",C.wastedCount??0]})]})]},C.id))})]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs(Se,{className:"surface-card",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Run detail"}),t.jsx("h3",{children:A?Rh(A.id):"No run selected"})]}),A&&t.jsx(Ke,{tone:Rb(A.status),children:A.status})]}),A?t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid gap-3 sm:grid-cols-4",children:[t.jsx(Ya,{label:"Questions tested",value:A.probeCount??0}),t.jsx(Ya,{label:"Already cited",value:A.citedCount??0,tone:"positive"}),t.jsx(Ya,{label:"Opportunities",value:A.aspirationalCount??0,tone:"caution"}),t.jsx(Ya,{label:"Low value",value:A.wastedCount??0,tone:"negative"})]}),A.error&&t.jsx("div",{className:"rounded-md border border-rose-800/40 bg-rose-950/20 px-3 py-2 text-sm text-rose-300",children:A.error}),A.icpDescription&&t.jsxs("div",{className:"rounded-md border border-zinc-800/60 bg-zinc-900/30 px-3 py-2",children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Customer profile"}),t.jsx("p",{className:"mt-1 text-sm text-zinc-300",children:A.icpDescription})]}),A.competitorMap.length>0&&t.jsxs("div",{children:[t.jsx("p",{className:"mb-2 text-xs font-medium text-zinc-400",children:"Sites that keep getting cited"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:A.competitorMap.slice(0,8).map(C=>t.jsxs("span",{className:"rounded-md border border-zinc-800/60 bg-zinc-950 px-2 py-1 text-xs text-zinc-300",children:[C.domain," ",t.jsx("span",{className:"text-zinc-500",children:C.hits})]},C.domain))})]})]}):t.jsx("p",{className:"text-sm text-zinc-500",children:"Start a run above, or pick one from Recent runs to see its progress."})]}),A?.status==="completed"&&t.jsxs(Se,{className:"surface-card",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 2"}),t.jsx("h3",{children:"Add queries to your project"})]}),t.jsxs(ee,{type:"button",size:"sm",disabled:w.isPending||U===0,onClick:()=>w.mutate(void 0),children:[t.jsx(zf,{size:14}),w.isPending?"Adding…":"Add recommended queries"]})]}),z.isLoading?t.jsx("p",{className:"text-sm text-zinc-500",children:"Loading recommendations…"}):D?t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid gap-3 sm:grid-cols-4",children:[t.jsx(Ya,{label:"Queries to add",value:U,tone:"positive"}),t.jsx(Ya,{label:"Already cited",value:D.queriesByBucket.cited.length,tone:"positive"}),t.jsx(Ya,{label:"Opportunities",value:D.queriesByBucket.aspirational.length,tone:"caution"}),t.jsx(Ya,{label:"Low value (skipped)",value:D.queriesByBucket["wasted-surface"].length,tone:"negative"})]}),t.jsx("p",{className:"text-xs leading-5 text-zinc-500",children:"Adding queries starts tracking the “already cited” and “opportunity” questions, plus any competitor sites that kept showing up. “Low value” questions are listed below for reference only and are not added."}),D.suggestedCompetitors.length>0&&t.jsxs("div",{children:[t.jsx("p",{className:"mb-2 text-xs font-medium text-zinc-400",children:"Competitor sites that will be added"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:D.suggestedCompetitors.map(C=>t.jsxs("span",{className:"rounded-md border border-zinc-800/60 bg-zinc-950 px-2 py-1 text-xs text-zinc-300",children:[C.domain," ",t.jsx("span",{className:"text-zinc-500",children:C.hits})]},C.domain))})]})]}):t.jsx("p",{className:"text-sm text-zinc-500",children:"No recommendations available for this run."})]}),t.jsxs(Se,{className:"surface-card",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"All results"}),t.jsx("h3",{children:"Every question we tested"})]}),v.isFetching&&t.jsx(Ke,{tone:"neutral",children:"Loading"})]}),I.length===0?t.jsx("p",{className:"text-sm text-zinc-500",children:"Results show up here once the run starts testing questions."}):t.jsx("div",{className:"evidence-table-wrap",children:t.jsxs("table",{className:"evidence-table",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"Question"}),t.jsx("th",{children:"Result"}),t.jsx("th",{children:"Sites cited"})]})}),t.jsx("tbody",{children:I.map(C=>t.jsxs("tr",{children:[t.jsx("td",{className:"font-medium text-zinc-100",children:C.query}),t.jsx("td",{children:t.jsx(Ke,{tone:O$(C.bucket),children:L$(C.bucket)})}),t.jsx("td",{className:"text-zinc-400",children:C.citedDomains.length>0?C.citedDomains.slice(0,3).join(", "):"-"})]},C.id))})]})})]})]})]})]})}function Ya({label:e,value:s,tone:i="neutral"}){const r=i==="positive"?"text-emerald-300":i==="caution"?"text-amber-300":i==="negative"?"text-rose-300":"text-zinc-100";return t.jsxs("div",{className:"rounded-md border border-zinc-800/60 bg-zinc-900/30 px-4 py-3",children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:e}),t.jsx("p",{className:`mt-1 text-2xl font-semibold tabular-nums ${r}`,children:s})]})}function Rb(e){return e==="completed"?"positive":e==="failed"?"negative":xf.has(e)?"caution":"neutral"}function O$(e){return e==="cited"?"positive":e==="aspirational"?"caution":e==="wasted-surface"?"negative":"neutral"}const R$={cited:"Already cited",aspirational:"Opportunity","wasted-surface":"Low value"};function L$(e){return e?R$[e]:"Not classified"}function Rh(e){return e.length>8?e.slice(0,8):e}function M$(e){const s=e.promoted.queries.length,i=e.promoted.competitors.length,r=e.skipped.queries.length+e.skipped.competitors.length;return`${s} quer${s===1?"y":"ies"} and ${i} competitor${i===1?"":"s"} added${r>0?`; ${r} already tracked`:""}.`}async function Lb(e,s,i){await Promise.all([e.invalidateQueries({predicate:r=>{const o=r.queryKey[0];return typeof o?._id=="string"&&o._id.startsWith("getApiV1ProjectsByNameDiscover")}}),e.invalidateQueries({queryKey:No({client:ae})})])}const $$={critical:"negative",high:"negative",medium:"caution",low:"neutral"};function vn(e){return Number.isFinite(e)?Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString("en-US"):"—"}function B$(e){if(!e)return"—";const s=new Date(e);return Number.isNaN(s.getTime())?e:s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function q$(e){const s=[e.city,e.region,e.country].filter(Boolean).join(", ");return s?`${e.label} (${s})`:e.label}function I$({projectName:e}){const[s,i]=j.useState(!1),[r,o]=j.useState(null),u=tn(TO({client:ae,path:{name:e}}));async function d(){i(!0),o(null);try{await W2(e,"client")}catch(p){const x=p instanceof un||p instanceof Error?p.message:"Download failed";o(x)}finally{i(!1)}}if(u.isLoading)return t.jsx("p",{className:"text-sm text-zinc-500 py-8 text-center",children:"Loading report…"});if(u.error){const p=u.error instanceof Error?u.error.message:"Failed to load report";return t.jsx("div",{className:"py-8 text-center",children:t.jsx("p",{className:"text-sm text-rose-400",children:p})})}const h=u.data;return h?t.jsxs("div",{children:[t.jsxs("div",{className:"page-header",children:[t.jsxs("div",{className:"page-header-left",children:[t.jsx("p",{className:"eyebrow",children:"AI Visibility Report"}),t.jsx("h1",{className:"page-title",children:h.meta.project.displayName}),t.jsxs("p",{className:"page-subtitle",children:[h.meta.project.canonicalDomain," · ",h.meta.project.country," / ",h.meta.project.language.toUpperCase(),h.meta.location?` · Location: ${q$(h.meta.location)}`:" · No location set"," · ","Generated ",B$(h.meta.generatedAt)]}),r&&t.jsx("p",{className:"mt-2 text-xs text-rose-400",children:r})]}),t.jsx("div",{className:"page-header-right",children:t.jsxs(ee,{variant:"secondary",size:"sm",onClick:Le(d),disabled:s,children:[t.jsx(Eu,{className:"size-4"}),s?"Preparing…":"Download report HTML"]})})]}),t.jsx(Q$,{report:h}),t.jsx(eB,{report:h,audience:"client"}),t.jsx(G$,{report:h}),t.jsx(Y$,{report:h,audience:"client"}),t.jsx(X$,{report:h})]}):null}const Mb="AI Visibility — Server-Side",$b="AI engine attention",U$="What AI engines actually do in your server logs over the last 7 days — the other half of citations.",P$="Live telemetry from your server logs.";function G$({report:e}){const s=e.serverActivity;if(!s)return null;if(!s.hasData)return t.jsxs("section",{className:"page-section-divider",children:[t.jsx(yo,{eyebrow:$b,title:Mb,subtitle:P$}),t.jsx("p",{className:"text-sm text-zinc-500",children:"Your server-side traffic source is connected. Numbers will appear after the next sync."})]});const i={current:s.verifiedCrawlerHits.current+s.unverifiedCrawlerHits.current,prior:s.verifiedCrawlerHits.prior+s.unverifiedCrawlerHits.prior,deltaPct:PD(s.verifiedCrawlerHits.current+s.unverifiedCrawlerHits.current,s.verifiedCrawlerHits.prior+s.unverifiedCrawlerHits.prior)},r=Fy(i,"requests"),o=`${vn(s.verifiedCrawlerHits.current)} verified · ${vn(s.unverifiedCrawlerHits.current)} unverified${r?` · ${r}`:""}`,u=Fy(s.referralArrivals,"sessions"),d=s.byOperator.filter(h=>h.verifiedHits>0||h.unverifiedHits>0||h.referralArrivals>0).slice(0,5);return t.jsxs("section",{className:"page-section-divider",children:[t.jsx(yo,{eyebrow:$b,title:Mb,subtitle:U$}),t.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[t.jsx(Ub,{label:"AI bot requests observed",value:vn(i.current),subtitle:o}),t.jsx(Ub,{label:"AI referral sessions",value:vn(s.referralArrivals.current),subtitle:u})]}),d.length>0&&t.jsxs("div",{className:"mt-4",children:[t.jsx("p",{className:"eyebrow mb-2",children:"By AI tool"}),t.jsx("div",{className:"evidence-table-wrap",children:t.jsxs("table",{className:"evidence-table",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"AI tool"}),t.jsx("th",{children:"Bot requests (7d)"}),t.jsx("th",{children:"Referral sessions"})]})}),t.jsx("tbody",{children:d.map(h=>t.jsxs("tr",{children:[t.jsx("td",{className:"evidence-query-cell",children:h.operator}),t.jsx("td",{children:vn(h.verifiedHits+h.unverifiedHits)}),t.jsx("td",{children:vn(h.referralArrivals)})]},h.operator))})]})}),t.jsx("p",{className:"mt-2 text-[11px] text-zinc-500",children:"Verified requests are reverse-DNS confirmed. Unverified requests are user-agent claims shown separately in agency diagnostics."})]})]})}function V$(e,s){return e.audience==="both"||e.audience===s}const H$={gemini:"Gemini",openai:"ChatGPT",claude:"Claude",perplexity:"Perplexity",local:"Local model","cdp:chatgpt":"ChatGPT (browser)"};function Au(e){return H$[e]??e.charAt(0).toUpperCase()+e.slice(1)}function K$(e){if(!e)return null;const s=e.window??1,i=s>=2?`vs prior ${s} checks (avg ${e.prior}%)`:`since last check (was ${e.prior}%)`;return e.direction==="up"?{text:`Up ${e.deltaAbs.toFixed(1)} points ${i}`,tone:"positive",arrow:"↑"}:e.direction==="down"?{text:`Down ${Math.abs(e.deltaAbs).toFixed(1)} points ${i}`,tone:"negative",arrow:"↓"}:{text:`Holding steady ${s>=2?`vs prior ${s} checks (avg ${e.prior}%)`:`since last check (was ${e.prior}%)`}`,tone:"neutral",arrow:"→"}}function Q$({report:e}){const s=e.executiveSummary,i=e.citationScorecard,r=s.totalQueryCount,o=r>0?`${s.citationRate}%`:"—",u=r>0?`When customers asked AI ${r} ${r===1?"question":"questions"} about your industry, AI linked to your website in ${s.citedQueryCount} of ${r===1?"them":"those answers"}.`:"No AI check has been run yet. Run a check to see how AI tools answer customer questions about your business.",d=K$(e.whatsChanged.citationRate),h=i.providers.length>0?i.providers.map(Au).join(", "):`${vn(s.queryCount)} ${s.queryCount===1?"question":"questions"} tested`;return t.jsxs("section",{className:"page-section-divider",children:[t.jsxs("div",{className:"rounded-2xl border border-zinc-800/60 bg-zinc-900/40 p-6 sm:p-8",children:[t.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-zinc-500",children:"Overview"}),t.jsx("p",{className:"mt-3 text-6xl font-bold tracking-tight text-zinc-50 sm:text-7xl",children:o}),t.jsx("p",{className:"mt-3 max-w-2xl text-base text-zinc-300 sm:text-lg",children:u}),d&&t.jsxs("p",{className:`mt-3 text-sm font-medium ${d.tone==="positive"?"text-emerald-400":d.tone==="negative"?"text-rose-400":"text-zinc-400"}`,children:[t.jsx("span",{className:"mr-1",children:d.arrow}),d.text]})]}),t.jsxs("div",{className:"mt-5 grid gap-4 sm:grid-cols-3",children:[t.jsx(Lh,{label:"AI mentions your name",value:`${s.mentionRate}%`,subtitle:r>0?`Says your name in ${s.mentionedQueryCount} of ${r} ${r===1?"answer":"answers"}`:"No data yet"}),t.jsx(Lh,{label:"AI links to your website",value:`${s.citationRate}%`,subtitle:r>0?`Cites your site as a source in ${s.citedQueryCount} of ${r} ${r===1?"answer":"answers"}`:"No data yet"}),t.jsx(Lh,{label:"AI tools tested",value:vn(s.providerCount),subtitle:h})]}),t.jsxs("div",{className:"mt-4 rounded-xl border border-zinc-800/60 bg-zinc-950/40 px-4 py-3 text-xs text-zinc-400",children:[t.jsx("span",{className:"font-semibold text-zinc-200",children:"Mentions and links are different."})," ","A ",t.jsx("span",{className:"font-medium text-zinc-200",children:"mention"})," is when AI says your name out loud in its answer. A ",t.jsx("span",{className:"font-medium text-zinc-200",children:"link"})," is when AI lists your website as a source it used. AI can do either, both, or neither — that's why we track both."]}),i.queries.length>0&&t.jsxs("div",{className:"mt-5 rounded-xl border border-zinc-800/60 bg-zinc-900/30 p-5",children:[t.jsx("p",{className:"text-sm font-semibold text-zinc-100",children:"Customer questions we tested"}),t.jsxs("p",{className:"mt-1 text-xs text-zinc-500",children:["These are the ",i.queries.length," ",i.queries.length===1?"question we asked":"questions we asked"," every AI tool. The numbers above measure how often you came up."]}),t.jsx("ol",{className:"mt-4 grid gap-2 sm:grid-cols-2",children:i.queries.map((p,x)=>t.jsxs("li",{className:"flex items-start gap-3 rounded-lg border border-zinc-800/60 bg-zinc-950/40 px-3 py-2 text-sm text-zinc-200",children:[t.jsx("span",{className:"shrink-0 text-xs font-semibold tabular-nums text-zinc-500",children:String(x+1).padStart(2,"0")}),t.jsxs("span",{children:['"',p,'"']})]},x))})]}),i.providerRates.length>0&&t.jsxs("div",{className:"mt-5 rounded-xl border border-zinc-800/60 bg-zinc-900/30 p-5",children:[t.jsx("p",{className:"text-sm font-semibold text-zinc-100",children:"How often each AI tool links to your website"}),t.jsx("p",{className:"mt-1 text-xs text-zinc-500",children:"Higher is better. Each bar shows the share of customer questions where the AI cited your site."}),t.jsx("div",{className:"mt-4 space-y-3",children:i.providerRates.map(p=>t.jsxs("div",{className:"grid grid-cols-[120px_1fr_120px] items-center gap-3",children:[t.jsx("span",{className:"text-sm text-zinc-300",children:Au(p.provider)}),t.jsx("div",{className:"h-3 overflow-hidden rounded-full bg-zinc-800/80",children:t.jsx("div",{className:"h-full rounded-full bg-emerald-500/70",style:{width:`${Math.max(p.citationRate,1.5)}%`}})}),t.jsxs("span",{className:"text-right text-sm font-semibold text-zinc-100",children:[p.citationRate,"% ",t.jsxs("span",{className:"font-normal text-zinc-500",children:["(",p.citedCount,"/",p.totalCount,")"]})]})]},p.provider))})]}),e.clientSummary.confidenceNotes.length>0&&t.jsx("div",{className:"mt-4 grid gap-2",children:e.clientSummary.confidenceNotes.map((p,x)=>t.jsx("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/30 px-3 py-2 text-xs text-zinc-400",children:p},x))})]})}function Lh({label:e,value:s,subtitle:i}){return t.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 p-5",children:[t.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t.jsx("p",{className:"mt-3 text-4xl font-bold tracking-tight text-zinc-50 sm:text-5xl",children:s}),t.jsx("p",{className:"mt-2 text-xs text-zinc-500",children:i})]})}function Z$(e){switch(e){case"immediate":return"Do now";case"short-term":return"This month";case"medium-term":return"Next quarter"}}function F$(e){switch(e){case"high":return"Strong evidence";case"medium":return"Some evidence";case"low":return"Worth trying"}}function Y$({report:e,audience:s}){const i=s==="client"?e.clientSummary.actionItems:e.agencyDiagnostics.priorities.length>0?e.agencyDiagnostics.priorities:e.actionPlan.filter(u=>V$(u,s)),r=vD(e,i),o=s==="client";return t.jsxs("section",{className:"page-section-divider",children:[t.jsx(yo,{eyebrow:o?"Action plan":"Agency actions",title:o?"What to do next":"Agency Action Plan",subtitle:o?"Approve these in order. They are sorted by what will move the needle fastest.":"The highest-leverage work, sorted by urgency and evidence strength."}),r.length===0?t.jsx(yp,{message:"No recommendations yet — run an AI check to populate this."}):t.jsx("div",{className:"grid gap-3 lg:grid-cols-2",children:r.map((u,d)=>{const h=u.evidence.length>0?u.evidence:u.why,p=u.why.length>0||u.evidence.length>0;return t.jsxs("article",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 p-4",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-full bg-zinc-800/80 text-sm font-semibold text-zinc-100",title:"Priority — 1 will move the needle fastest",children:d+1}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"mb-2 flex flex-wrap gap-2",children:[t.jsx(Ke,{tone:hD(u),children:o?Z$(u.horizon):pD(u.horizon)}),!o&&t.jsx(Ke,{tone:"neutral",children:gD(u.category)}),t.jsx(Ke,{tone:"neutral",children:o?F$(u.confidence):`${xD(u.confidence)} confidence`})]}),t.jsx("p",{className:"text-sm font-medium text-zinc-100",children:u.title})]})]}),t.jsx("p",{className:"mt-3 text-sm text-zinc-400",children:u.action}),t.jsx(tB,{items:h,limit:3,className:"mt-3"}),p&&t.jsxs("details",{className:"mt-3 text-xs text-zinc-400",children:[t.jsx("summary",{className:"cursor-pointer text-zinc-500 hover:text-zinc-300",children:o?"See the data behind this":"Evidence details"}),u.why.length>0&&t.jsxs("div",{className:"mt-2",children:[t.jsx("p",{className:"eyebrow-soft mb-1",children:o?"Why this matters":"Why"}),t.jsx("ul",{className:"list-disc space-y-1 pl-4",children:u.why.map((x,b)=>t.jsx("li",{children:x},b))})]}),u.evidence.length>0&&t.jsxs("div",{className:"mt-2",children:[t.jsx("p",{className:"eyebrow-soft mb-1",children:o?"What we saw":"Evidence"}),t.jsx("ul",{className:"list-disc space-y-1 pl-4",children:u.evidence.map((x,b)=>t.jsx("li",{children:x},b))})]})]}),t.jsxs("p",{className:"mt-3 border-t border-zinc-800/60 pt-3 text-xs text-zinc-300",children:[t.jsx("span",{className:"font-medium",children:o?"What success looks like:":"Win condition:"})," ",u.successMetric]})]},`${u.priority}-${u.title}`)})})]})}function Bb({label:e,value:s,displayValue:i,max:r,barClass:o}){const u=r>0?Math.max(s/r*100,1.5):0;return t.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center gap-3 text-sm",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-zinc-300",title:e,children:e}),t.jsx("div",{className:"mt-1 h-2 overflow-hidden rounded-full bg-zinc-800/80",children:t.jsx("div",{className:`h-full rounded-full ${o}`,style:{width:`${u}%`}})})]}),t.jsx("span",{className:"whitespace-nowrap text-sm font-semibold text-zinc-100",children:i})]})}function X$({report:e}){const s=e.aiSourceOrigin.topDomains.slice(0,5),i=e.gsc,r=e.indexingHealth,o=jD(e).slice(0,5),u=s.length>0?Math.max(...s.map(p=>p.count)):0,d=i?Math.max(...i.topQueries.slice(0,5).map(p=>p.impressions),1):0,h=s.length>0||i!==null||r!==null||o.length>0;return t.jsxs("section",{className:"page-section-divider",children:[t.jsx(yo,{eyebrow:"What we based this on",title:"The signals behind this plan",subtitle:"The data behind the recommendations above. Switch to Agency for the full breakdowns."}),h?t.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[s.length>0&&t.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 p-5",children:[t.jsx("p",{className:"text-sm font-semibold text-zinc-100",children:"Where AI gets its answers"}),t.jsx("p",{className:"mt-1 text-xs text-zinc-500",children:"The websites AI tools cited most often when answering customer questions about your industry."}),t.jsx("div",{className:"mt-4 space-y-3",children:s.map(p=>t.jsx(Bb,{label:p.domain+(p.isCompetitor?" (competitor)":""),value:p.count,displayValue:`${vn(p.count)}×`,max:u,barClass:"bg-zinc-400/70"},p.domain))})]}),r&&t.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 p-5",children:[t.jsx("p",{className:"text-sm font-semibold text-zinc-100",children:"Pages Google can find on your site"}),t.jsx("p",{className:"mt-1 text-xs text-zinc-500",children:"Google indexing your site increases the chances of it appearing in AI search (especially Gemini)."}),t.jsxs("p",{className:`mt-4 text-5xl font-bold tracking-tight ${r.indexedPct>=90?"text-emerald-400":r.indexedPct>=70?"text-amber-400":"text-rose-400"}`,children:[r.indexedPct,"%"]}),t.jsxs("p",{className:"mt-1 text-xs text-zinc-500",children:[vn(r.indexed)," of ",vn(r.total)," pages indexed"]}),t.jsx("div",{className:"mt-3 h-3 overflow-hidden rounded-full bg-zinc-800/80",children:t.jsx("div",{className:`h-full rounded-full ${r.indexedPct>=90?"bg-emerald-500/70":r.indexedPct>=70?"bg-amber-500/70":"bg-rose-500/70"}`,style:{width:`${Math.max(r.indexedPct,1.5)}%`}})}),t.jsxs("p",{className:"mt-3 text-xs text-zinc-400",children:[t.jsx("span",{className:"font-medium text-zinc-200",children:vn(r.notIndexed)})," ",r.notIndexed===1?"page is":"pages are"," not indexed yet."]})]}),i&&t.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 p-5",children:[t.jsx("p",{className:"text-sm font-semibold text-zinc-100",children:"What people search Google for"}),t.jsxs("p",{className:"mt-1 text-xs text-zinc-500",children:["You appeared in ",t.jsx("span",{className:"font-semibold text-zinc-200",children:vn(i.totalImpressions)})," Google searches and got ",t.jsx("span",{className:"font-semibold text-zinc-200",children:vn(i.totalClicks)})," ",i.totalClicks===1?"click":"clicks"," this period."]}),i.topQueries.length>0&&t.jsx("div",{className:"mt-4 space-y-3",children:i.topQueries.slice(0,5).map(p=>t.jsx(Bb,{label:p.query,value:p.impressions,displayValue:`${vn(p.impressions)} ${p.impressions===1?"search":"searches"}`,max:d,barClass:"bg-sky-500/70"},p.query))})]}),o.length>0&&t.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 p-5",children:[t.jsx("p",{className:"text-sm font-semibold text-zinc-100",children:"Topics where you could improve"}),t.jsx("p",{className:"mt-1 text-xs text-zinc-500",children:"Customer questions where better content on your site would help AI cite you."}),t.jsx("ul",{className:"mt-4 space-y-2 text-sm text-zinc-300",children:o.map((p,x)=>t.jsxs("li",{className:"rounded-lg border border-zinc-800/60 bg-zinc-950/40 px-3 py-2",children:[t.jsx("p",{className:"font-medium text-zinc-100",children:p.query}),t.jsx("p",{className:"mt-0.5 text-xs text-zinc-400",children:SE(p.action)})]},x))})]})]}):t.jsx(yp,{message:"No supporting evidence yet — this fills in after the first AI check."})]})}const J$=14;function gp(e){return e==="up"?"positive":e==="down"?"negative":"neutral"}function xp(e){return e==="up"?"↑":e==="down"?"↓":"→"}function Mh({label:e,delta:s,unit:i}){if(!s)return t.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 px-4 py-3",children:[t.jsx("p",{className:"eyebrow-soft",children:e}),t.jsx("p",{className:"text-2xl font-semibold tracking-tight text-zinc-500",children:"—"}),t.jsx("p",{className:"mt-1 text-[11px] text-zinc-500",children:"No prior data"})]});const r=i==="%"?"%":"",o=s.deltaAbs>0?"+":"",u=gp(s.direction),d=u==="positive"?"text-emerald-400":u==="negative"?"text-rose-400":"text-zinc-100";return t.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 px-4 py-3",children:[t.jsx("p",{className:"eyebrow-soft",children:e}),t.jsxs("p",{className:`text-2xl font-semibold tracking-tight ${d}`,children:[s.current,r," ",t.jsx("span",{className:"text-sm font-medium",children:xp(s.direction)})]}),t.jsxs("p",{className:"mt-1 text-[11px] text-zinc-500",children:[o,i==="%"?s.deltaAbs.toFixed(1):s.deltaAbs,r," vs ",s.prior,r]})]})}function qb({label:e,delta:s,countLabel:i}){if(!s)return t.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 px-4 py-3",children:[t.jsx("p",{className:"eyebrow-soft",children:e}),t.jsx("p",{className:"text-2xl font-semibold tracking-tight text-zinc-500",children:"—"}),t.jsx("p",{className:"mt-1 text-[11px] text-zinc-500",children:"Not enough trend data"})]});const r=s.deltaAbs>0?"+":"",o=gp(s.direction),u=o==="positive"?"text-emerald-400":o==="negative"?"text-rose-400":"text-zinc-100";return t.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 px-4 py-3",children:[t.jsx("p",{className:"eyebrow-soft",children:e}),t.jsxs("p",{className:`text-2xl font-semibold tracking-tight ${u}`,children:[vn(s.current)," ",t.jsx("span",{className:"text-sm font-medium",children:xp(s.direction)})]}),t.jsxs("p",{className:"mt-1 text-[11px] text-zinc-500",children:[r,vn(s.deltaAbs)," ",i," vs prior ",J$," days"]})]})}function W$({movements:e,audience:s}){const i=e.filter(o=>o.direction!=="flat");if(i.length===0)return null;const r=s==="client";return t.jsxs("div",{className:"mt-4",children:[t.jsx("p",{className:"eyebrow mb-2",children:r?"How each AI tool changed":"AI engine movements"}),t.jsx("div",{className:"evidence-table-wrap",children:t.jsxs("table",{className:"evidence-table",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:r?"AI tool":"Engine"}),t.jsx("th",{children:r?"Was":"Prior"}),t.jsx("th",{children:r?"Now":"Current"}),t.jsx("th",{children:"Change"})]})}),t.jsx("tbody",{children:i.map(o=>{const u=o.deltaAbs>0?"+":"",d=gp(o.direction),h=d==="positive"?"text-emerald-400":d==="negative"?"text-rose-400":"text-zinc-300";return t.jsxs("tr",{children:[t.jsx("td",{children:r?Au(o.provider):o.provider}),t.jsxs("td",{children:[o.prior,"%"]}),t.jsxs("td",{children:[o.current,"%"]}),t.jsxs("td",{className:h,children:[u,o.deltaAbs.toFixed(1),"% ",xp(o.direction)]})]},o.provider)})})]})})]})}function Ib({insights:e,heading:s,emptyMessage:i,audience:r}){if(e.length===0)return t.jsxs("div",{className:"mt-4 rounded-xl border border-zinc-800/60 bg-zinc-900/30 p-4",children:[t.jsx("p",{className:"eyebrow mb-1",children:s}),t.jsx("p",{className:"text-xs text-zinc-500",children:i})]});const o=r==="client";return t.jsxs("div",{className:"mt-4",children:[t.jsx("p",{className:"eyebrow mb-2",children:s}),t.jsx("div",{className:"evidence-table-wrap",children:t.jsxs("table",{className:"evidence-table",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[!o&&t.jsx("th",{children:"Severity"}),t.jsx("th",{children:o?"What changed":"Title"}),t.jsx("th",{children:o?"Customer question":"Query"}),t.jsx("th",{children:o?"AI tool":"Provider"})]})}),t.jsx("tbody",{children:e.map(u=>t.jsxs("tr",{children:[!o&&t.jsxs("td",{children:[t.jsx(Ke,{tone:$$[u.severity],children:fD(u.severity)}),u.instanceCount>1&&t.jsxs("span",{className:"ml-2 text-[11px] text-zinc-500",children:["×",u.instanceCount]})]}),t.jsxs("td",{className:"evidence-query-cell",children:[u.title,o&&u.instanceCount>1&&t.jsxs("span",{className:"ml-2 text-[11px] text-zinc-500",children:["×",u.instanceCount]})]}),t.jsx("td",{className:"text-xs text-zinc-400",children:u.query}),t.jsx("td",{className:"text-xs text-zinc-400",children:o?Au(u.provider):u.provider})]},u.id))})]})})]})}function eB({report:e,audience:s}){const i=e.whatsChanged,r=s==="client",o=!i.enoughHistory&&!i.gscClicksDelta&&!i.aiReferralsDelta&&i.wins.length===0&&i.regressions.length===0,u=t.jsx(yo,{eyebrow:r?"Since last check":"Section 2",title:r?"What's different since last check":"What's Changed",subtitle:r?void 0:i.headline});return o?t.jsxs("section",{className:"page-section-divider",children:[u,t.jsx(yp,{message:r?"No comparison yet — trends will appear after a few more checks.":"Trends will appear after a few more checks."})]}):t.jsxs("section",{className:"page-section-divider",children:[u,t.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-5",children:[t.jsx(Mh,{label:r?"AI links to your website":"Citation rate",delta:i.citationRate,unit:"%"}),t.jsx(Mh,{label:r?"AI mentions your name":"Mention rate",delta:i.mentionRate,unit:"%"}),t.jsx(Mh,{label:r?"Questions AI answered with you":"Cited queries",delta:i.citedQueryCount,unit:"count"}),t.jsx(qb,{label:r?"Visitors from Google":"GSC clicks",delta:i.gscClicksDelta,countLabel:r?"visits":"clicks"}),t.jsx(qb,{label:r?"Visitors from AI tools":"AI referral sessions",delta:i.aiReferralsDelta,countLabel:r?"visits":"sessions"})]}),t.jsx(W$,{movements:i.providerMovements,audience:s}),t.jsx(Ib,{insights:i.wins,heading:r?"What got better":"Wins",emptyMessage:r?"No new wins this period.":"No new gains in the latest check.",audience:s}),t.jsx(Ib,{insights:i.regressions,heading:r?"What got worse":"Regressions",emptyMessage:r?"Nothing got worse this period.":"No new regressions in the latest check.",audience:s})]})}function Ub({label:e,value:s,tone:i,subtitle:r}){const o=i==="positive"?"text-emerald-400":i==="caution"?"text-amber-400":i==="negative"?"text-rose-400":"text-zinc-100";return t.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 px-4 py-3",children:[t.jsx("p",{className:"eyebrow-soft",children:e}),t.jsx("p",{className:`text-2xl font-semibold tracking-tight ${o}`,children:s}),r&&t.jsx("p",{className:"mt-1 text-[11px] text-zinc-500",children:r})]})}function yo({eyebrow:e,title:s,subtitle:i}){return t.jsxs("div",{className:"mb-3",children:[t.jsx("p",{className:"eyebrow-soft",children:e}),t.jsx("h2",{className:"page-title",children:s}),i&&t.jsx("p",{className:"page-subtitle mt-1",children:i})]})}function tB({items:e,limit:s=3,className:i}){if(e.length===0)return null;const r=e.slice(0,s),o=e.length-r.length;return t.jsxs("div",{className:`flex flex-wrap gap-1.5 ${i??""}`,children:[r.map((u,d)=>t.jsx("span",{className:"rounded-md border border-zinc-800/60 bg-zinc-900/40 px-2 py-0.5 text-[11px] text-zinc-300",children:u},d)),o>0&&t.jsxs("span",{className:"rounded-md border border-zinc-800/60 bg-zinc-900/40 px-2 py-0.5 text-[11px] text-zinc-400",children:["+",o," more"]})]})}function yp({message:e}){return t.jsx("p",{className:"text-sm text-zinc-500 py-4 text-center",children:e})}function nB({project:e,onUpdateProject:s,onRefresh:i}){const[r,o]=j.useState(!1),[u,d]=j.useState(!1),[h,p]=j.useState(null),[x,b]=j.useState(e.displayName),[v,N]=j.useState(e.canonicalDomain),[z,T]=j.useState(e.country),[w,A]=j.useState(e.language),[D,U]=j.useState(e.ownedDomains??[]),[I,C]=j.useState(""),[L,M]=j.useState(e.aliases??[]),[_,B]=j.useState(""),[J,ue]=j.useState(null),[P,ie]=j.useState(!1),[te,ze]=j.useState(!1),[ve,V]=j.useState(""),[ne,me]=j.useState(""),[Ne,se]=j.useState(""),[pe,E]=j.useState(""),[X,Y]=j.useState("");j.useEffect(()=>{r||(b(e.displayName),N(e.canonicalDomain),T(e.country),A(e.language),U(e.ownedDomains??[]),M(e.aliases??[]))},[e,r]);function ye(){o(!1),p(null),b(e.displayName),N(e.canonicalDomain),T(e.country),A(e.language),U(e.ownedDomains??[]),M(e.aliases??[]),C(""),B("")}function le(){const be=I.trim();be&&(D.includes(be)||U([...D,be]),C(""))}function Re(be){U(D.filter(Ae=>Ae!==be))}function tt(){const be=_.trim();if(!be)return;const Ae=be.toLowerCase();L.some(sn=>sn.toLowerCase()===Ae)||M([...L,be]),B("")}function we(be){M(L.filter(Ae=>Ae!==be))}async function Ue(){if(!(!x.trim()||!v.trim()||!z.trim()||!w.trim())){d(!0),p(null);try{await s(e.name,{displayName:x.trim(),canonicalDomain:v.trim(),ownedDomains:D,aliases:L,country:z.trim(),language:w.trim()}),o(!1),Qe({title:"Project settings saved",detail:`${x.trim()} was updated.`,tone:"positive",dedupeKey:`project:update:${e.name}`,dedupeMode:"replace"})}catch(be){p(be instanceof Error?be.message:"Failed to save")}finally{d(!1)}}}async function Ce(){const be=ve.trim(),Ae=ne.trim(),sn=Ne.trim(),Zt=pe.trim();if(!(!be||!Ae||!sn||!Zt)){ie(!0),ue(null);try{const an={label:be,city:Ae,region:sn,country:Zt};X.trim()&&(an.timezone=X.trim()),await g2(e.name,an),i(),V(""),me(""),se(""),E(""),Y(""),ze(!1),Qe({title:"Location added",detail:`${be} is now available for ${e.name}.`,tone:"positive",dedupeKey:`project:location:add:${e.name}:${be}`,dedupeMode:"drop"})}catch(an){ue(an instanceof Error?an.message:"Failed to add location")}finally{ie(!1)}}}async function mt(be){ie(!0),ue(null);try{await x2(e.name,be),i(),Qe({title:"Location removed",detail:`${be} was removed from ${e.name}.`,tone:"positive",dedupeKey:`project:location:remove:${e.name}:${be}`,dedupeMode:"drop"})}catch(Ae){ue(Ae instanceof Error?Ae.message:"Failed to remove location")}finally{ie(!1)}}async function Nt(be){ie(!0),ue(null);try{await y2(e.name,be),i(),Qe({title:"Default location updated",detail:`${be} is now the default for ${e.name}.`,tone:"positive",dedupeKey:`project:location:default:${e.name}`,dedupeMode:"replace"})}catch(Ae){ue(Ae instanceof Error?Ae.message:"Failed to set default location")}finally{ie(!1)}}const pt=x!==e.displayName||v!==e.canonicalDomain||z!==e.country||w!==e.language||JSON.stringify(D)!==JSON.stringify(e.ownedDomains??[])||JSON.stringify(L)!==JSON.stringify(e.aliases??[]),gt="w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",St="block text-xs font-medium text-zinc-400 mb-1",Fn=ve.trim()&&ne.trim()&&Ne.trim()&&pe.trim();return t.jsxs("section",{className:"page-section-divider",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Configuration"}),t.jsx("h2",{children:"Project settings"})]}),!r&&t.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>o(!0),children:"Edit settings"})]}),h&&t.jsxs("div",{className:"mb-3 rounded-lg border border-rose-800/40 bg-rose-950/20 px-3 py-2 text-sm text-rose-300",children:[h,t.jsx("button",{type:"button",className:"ml-2 text-rose-400 hover:text-rose-200",onClick:()=>p(null),children:"×"})]}),r?t.jsxs("div",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4 space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:St,children:"Display name"}),t.jsx("input",{className:gt,type:"text",value:x,onChange:be=>b(be.target.value),placeholder:"My Project"})]}),t.jsxs("div",{children:[t.jsx("label",{className:St,children:"Canonical domain"}),t.jsx("input",{className:gt,type:"text",value:v,onChange:be=>N(be.target.value),placeholder:"example.com"})]}),t.jsxs("div",{children:[t.jsx("label",{className:St,children:"Country"}),t.jsx("input",{className:gt,type:"text",value:z,onChange:be=>T(be.target.value),placeholder:"US",maxLength:2})]}),t.jsxs("div",{children:[t.jsx("label",{className:St,children:"Language"}),t.jsx("input",{className:gt,type:"text",value:w,onChange:be=>A(be.target.value),placeholder:"en"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:St,children:"Owned domains"}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:D.map(be=>t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-zinc-700/60 bg-zinc-800/40 px-2 py-0.5 text-xs text-zinc-300",children:[be,t.jsx("button",{type:"button",className:"ml-0.5 text-zinc-500 hover:text-zinc-200 transition-colors",onClick:()=>Re(be),"aria-label":`Remove ${be}`,children:"×"})]},be))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{className:`${gt} flex-1`,type:"text",placeholder:"docs.example.com",value:I,onChange:be=>C(be.target.value),onKeyDown:be=>be.key==="Enter"&&(be.preventDefault(),le())}),t.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:!I.trim(),onClick:le,children:"Add"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:St,children:"Aliases"}),t.jsx("p",{className:"text-[11px] text-zinc-500 mb-1.5",children:'Additional brand names checked against LLM answer text. Use for product names, prior names, or DBAs (e.g. add "Meta" as an alias to facebook.com).'}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:L.map(be=>t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-zinc-700/60 bg-zinc-800/40 px-2 py-0.5 text-xs text-zinc-300",children:[be,t.jsx("button",{type:"button",className:"ml-0.5 text-zinc-500 hover:text-zinc-200 transition-colors",onClick:()=>we(be),"aria-label":`Remove ${be}`,children:"×"})]},be))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{className:`${gt} flex-1`,type:"text",placeholder:"Facebook",value:_,onChange:be=>B(be.target.value),onKeyDown:be=>be.key==="Enter"&&(be.preventDefault(),tt())}),t.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:!_.trim(),onClick:tt,children:"Add"})]})]}),t.jsxs("div",{className:"flex items-center gap-2 pt-2 border-t border-zinc-800/60",children:[t.jsx(ee,{type:"button",disabled:u||!pt||!x.trim()||!v.trim(),onClick:Le(Ue),children:u?"Saving...":"Save changes"}),t.jsx(ee,{type:"button",variant:"outline",disabled:u,onClick:ye,children:"Cancel"})]})]}):t.jsx("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/30 overflow-hidden",children:t.jsx("table",{className:"w-full text-sm",children:t.jsxs("tbody",{children:[t.jsxs("tr",{className:"border-b border-zinc-800/40",children:[t.jsx("td",{className:"px-4 py-2.5 text-zinc-500 font-medium w-40",children:"Display name"}),t.jsx("td",{className:"px-4 py-2.5 text-zinc-200",children:e.displayName||"—"})]}),t.jsxs("tr",{className:"border-b border-zinc-800/40",children:[t.jsx("td",{className:"px-4 py-2.5 text-zinc-500 font-medium",children:"Canonical domain"}),t.jsx("td",{className:"px-4 py-2.5 text-zinc-200",children:e.canonicalDomain})]}),t.jsxs("tr",{className:"border-b border-zinc-800/40",children:[t.jsx("td",{className:"px-4 py-2.5 text-zinc-500 font-medium",children:"Owned domains"}),t.jsx("td",{className:"px-4 py-2.5",children:(e.ownedDomains??[]).length>0?t.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.ownedDomains.map(be=>t.jsx("span",{className:"rounded-full border border-zinc-700/60 bg-zinc-800/40 px-2 py-0.5 text-xs text-zinc-300",children:be},be))}):t.jsx("span",{className:"text-zinc-500",children:"—"})})]}),t.jsxs("tr",{className:"border-b border-zinc-800/40",children:[t.jsx("td",{className:"px-4 py-2.5 text-zinc-500 font-medium",children:"Aliases"}),t.jsx("td",{className:"px-4 py-2.5",children:(e.aliases??[]).length>0?t.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.aliases.map(be=>t.jsx("span",{className:"rounded-full border border-zinc-700/60 bg-zinc-800/40 px-2 py-0.5 text-xs text-zinc-300",children:be},be))}):t.jsx("span",{className:"text-zinc-500",children:"—"})})]}),t.jsxs("tr",{className:"border-b border-zinc-800/40",children:[t.jsx("td",{className:"px-4 py-2.5 text-zinc-500 font-medium",children:"Country"}),t.jsx("td",{className:"px-4 py-2.5 text-zinc-200",children:e.country})]}),t.jsxs("tr",{className:"border-b border-zinc-800/40",children:[t.jsx("td",{className:"px-4 py-2.5 text-zinc-500 font-medium",children:"Language"}),t.jsx("td",{className:"px-4 py-2.5 text-zinc-200",children:e.language})]}),t.jsxs("tr",{children:[t.jsx("td",{className:"px-4 py-2.5 text-zinc-500 font-medium align-top pt-3",children:"Locations"}),t.jsxs("td",{className:"px-4 py-2.5",children:[J&&t.jsxs("div",{className:"mb-2 rounded border border-rose-800/40 bg-rose-950/20 px-2 py-1 text-xs text-rose-300",children:[J,t.jsx("button",{type:"button",className:"ml-1 text-rose-400 hover:text-rose-200",onClick:()=>ue(null),children:"×"})]}),(e.locations??[]).length>0?t.jsxs("table",{className:"w-full text-xs mb-2",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-zinc-600",children:[t.jsx("th",{className:"text-left pb-1 font-medium pr-3",children:"Label"}),t.jsx("th",{className:"text-left pb-1 font-medium pr-3",children:"City"}),t.jsx("th",{className:"text-left pb-1 font-medium pr-3",children:"Region"}),t.jsx("th",{className:"text-left pb-1 font-medium pr-3",children:"Country"}),t.jsx("th",{className:"text-left pb-1 font-medium pr-3",children:"Timezone"}),t.jsx("th",{className:"pb-1"})]})}),t.jsx("tbody",{children:e.locations.map(be=>t.jsxs("tr",{className:"border-t border-zinc-800/30",children:[t.jsx("td",{className:"py-1.5 pr-3",children:t.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${be.label===e.defaultLocation?"border-emerald-700/60 bg-emerald-950/30 text-emerald-300":"border-zinc-700/60 bg-zinc-800/40 text-zinc-300"}`,children:[be.label,be.label===e.defaultLocation?" ★":""]})}),t.jsx("td",{className:"py-1.5 pr-3 text-zinc-300",children:be.city}),t.jsx("td",{className:"py-1.5 pr-3 text-zinc-300",children:be.region}),t.jsx("td",{className:"py-1.5 pr-3 text-zinc-300",children:be.country}),t.jsx("td",{className:"py-1.5 pr-3 text-zinc-500",children:be.timezone??"—"}),t.jsx("td",{className:"py-1.5",children:t.jsxs("div",{className:"flex items-center gap-1.5",children:[be.label!==e.defaultLocation&&t.jsx("button",{type:"button",disabled:P,onClick:()=>{Nt(be.label)},className:"text-[10px] text-zinc-500 hover:text-emerald-400 transition-colors disabled:opacity-40","aria-label":`Set ${be.label} as default location`,children:"Set default"}),t.jsx("button",{type:"button",disabled:P,onClick:()=>{mt(be.label)},className:"text-[10px] text-zinc-500 hover:text-rose-400 transition-colors disabled:opacity-40","aria-label":`Remove location ${be.label}`,children:"Remove"})]})})]},be.label))})]}):t.jsx("p",{className:"text-zinc-500 text-xs mb-2",children:"No locations configured"}),te?t.jsxs("div",{className:"mt-2 rounded border border-zinc-800 bg-zinc-900/50 p-3 space-y-2",children:[t.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-zinc-500",children:"Add location"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] text-zinc-500 mb-0.5",children:"Label *"}),t.jsx("input",{className:gt,type:"text",value:ve,onChange:be=>V(be.target.value),placeholder:"nyc"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] text-zinc-500 mb-0.5",children:"City *"}),t.jsx("input",{className:gt,type:"text",value:ne,onChange:be=>me(be.target.value),placeholder:"New York"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] text-zinc-500 mb-0.5",children:"Region *"}),t.jsx("input",{className:gt,type:"text",value:Ne,onChange:be=>se(be.target.value),placeholder:"NY"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-[10px] text-zinc-500 mb-0.5",children:"Country *"}),t.jsx("input",{className:gt,type:"text",value:pe,onChange:be=>E(be.target.value),placeholder:"US",maxLength:2})]}),t.jsxs("div",{className:"col-span-2",children:[t.jsx("label",{className:"block text-[10px] text-zinc-500 mb-0.5",children:"Timezone (optional)"}),t.jsx("input",{className:gt,type:"text",value:X,onChange:be=>Y(be.target.value),placeholder:"America/New_York"})]})]}),t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(ee,{type:"button",size:"sm",disabled:P||!Fn,onClick:Le(Ce),children:P?"Adding...":"Add location"}),t.jsx(ee,{type:"button",size:"sm",variant:"outline",disabled:P,onClick:()=>{ze(!1),ue(null)},children:"Cancel"})]})]}):t.jsx(ee,{type:"button",size:"sm",variant:"outline",onClick:()=>ze(!0),children:"+ Add location"})]})]})]})})})]})}const sB=[{value:"daily",label:"Every day"},{value:"weekly@mon",label:"Every Monday"},{value:"weekly@wed",label:"Every Wednesday"},{value:"weekly@fri",label:"Every Friday"},{value:"twice-daily",label:"Twice a day (6am & 6pm)"},{value:"custom",label:"Custom cron expression"}],Pb=["UTC","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Toronto","America/Vancouver","Europe/London","Europe/Paris","Europe/Berlin","Asia/Tokyo","Asia/Shanghai","Asia/Singapore","Australia/Sydney"];function aB({projectName:e}){const[s,i]=j.useState("loading"),[r,o]=j.useState(!1),[u,d]=j.useState("daily"),[h,p]=j.useState(6),[x,b]=j.useState(""),[v,N]=j.useState("UTC"),[z,T]=j.useState(!1),[w,A]=j.useState(""),[D,U]=j.useState(!1),[I,C]=j.useState(!1),[L,M]=j.useState(null);j.useEffect(()=>{z2(e).then(i).catch(()=>i(null))},[e]);const _=()=>{if(s&&s!=="loading"){const P=QD(s.preset??null,s.cronExpr);d(P.freq),p(P.hour),b(P.customCron);const ie=Pb.includes(s.timezone);N(ie?s.timezone:"Other"),T(!ie),A(ie?"":s.timezone)}else d("daily"),p(6),b(""),N("UTC"),T(!1),A("");M(null),o(!0)},B=async()=>{U(!0),M(null);try{const ie={timezone:z?w.trim()||"UTC":v};u==="custom"?ie.cron=x.trim():ie.preset=KD(u,h);const te=await fy(e,ie);i(te),o(!1),Qe({title:"Schedule saved",detail:Nh(te.preset??null,te.cronExpr,te.timezone),tone:"positive",dedupeKey:`schedule:${e}`,dedupeMode:"replace"})}catch(P){M(P instanceof Error?P.message:"Failed to save schedule")}finally{U(!1)}},J=async()=>{if(!(!s||s==="loading")){U(!0),M(null);try{const P={timezone:s.timezone,enabled:!s.enabled};s.preset?P.preset=s.preset:P.cron=s.cronExpr;const ie=await fy(e,P);i(ie),Qe({title:ie.enabled?"Schedule resumed":"Schedule paused",detail:Nh(ie.preset??null,ie.cronExpr,ie.timezone),tone:"positive",dedupeKey:`schedule:toggle:${e}`,dedupeMode:"replace"})}catch(P){M(P instanceof Error?P.message:"Failed to update schedule")}finally{U(!1)}}},ue=async()=>{C(!0),M(null);try{await k2(e),i(null),o(!1),Qe({title:"Schedule removed",detail:`${e} will no longer run automatically.`,tone:"positive",dedupeKey:`schedule:remove:${e}`,dedupeMode:"drop"})}catch(P){M(P instanceof Error?P.message:"Failed to remove schedule")}finally{C(!1)}};return t.jsxs("section",{className:"page-section-divider",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Automation"}),t.jsx("h2",{children:"Scheduled runs"})]}),s!=="loading"&&!r&&t.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:_,children:s?"Edit schedule":"+ Set schedule"})]}),s==="loading"&&t.jsx("p",{className:"supporting-copy",children:"Loading..."}),s!=="loading"&&!r&&s===null&&t.jsx(Se,{className:"surface-card compact-card",children:t.jsx("p",{className:"supporting-copy",children:"No schedule configured. Set one to automatically trigger visibility sweeps."})}),s!=="loading"&&!r&&s!==null&&t.jsxs(Se,{className:"surface-card compact-card",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"text-sm font-medium text-zinc-200",children:Nh(s.preset??null,s.cronExpr,s.timezone)}),t.jsxs("p",{className:"text-xs text-zinc-500",children:["Cron: ",t.jsx("span",{className:"font-mono",children:s.cronExpr})]}),s.nextRunAt&&t.jsxs("p",{className:"text-xs text-zinc-500",children:["Next run: ",new Date(s.nextRunAt).toLocaleString()]}),s.lastRunAt&&t.jsxs("p",{className:"text-xs text-zinc-500",children:["Last run: ",new Date(s.lastRunAt).toLocaleString()]})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t.jsx(Ke,{tone:s.enabled?"positive":"neutral",children:s.enabled?"Active":"Paused"}),t.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:D,onClick:Le(J),children:s.enabled?"Pause":"Resume"}),t.jsx(ee,{type:"button",variant:"ghost",size:"sm",disabled:I,onClick:Le(ue),children:I?"Removing...":"Remove"})]})]}),L&&t.jsx("p",{className:"text-rose-400 text-sm mt-2",children:L})]}),r&&t.jsxs("div",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4 space-y-3",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"text-xs font-medium text-zinc-400",children:"Frequency"}),t.jsx("select",{className:"w-full rounded border border-zinc-700 bg-zinc-900 px-2 py-1.5 text-sm text-zinc-200 focus:border-zinc-500 focus:outline-none",value:u,onChange:P=>d(P.target.value),children:sB.map(P=>t.jsx("option",{value:P.value,children:P.label},P.value))})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"text-xs font-medium text-zinc-400",children:"Time"}),t.jsx("select",{className:"w-full rounded border border-zinc-700 bg-zinc-900 px-2 py-1.5 text-sm text-zinc-200 focus:border-zinc-500 focus:outline-none disabled:opacity-40",value:h,disabled:u==="twice-daily"||u==="custom",onChange:P=>p(parseInt(P.target.value)),children:Array.from({length:24},(P,ie)=>t.jsx("option",{value:ie,children:Wh(ie)},ie))})]})]}),u==="custom"&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"text-xs font-medium text-zinc-400",children:"Cron expression"}),t.jsx("input",{className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 font-mono focus:border-zinc-500 focus:outline-none",type:"text",placeholder:"0 9 * * 1-5",value:x,onChange:P=>b(P.target.value)})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"text-xs font-medium text-zinc-400",children:"Timezone"}),t.jsxs("select",{className:"w-full rounded border border-zinc-700 bg-zinc-900 px-2 py-1.5 text-sm text-zinc-200 focus:border-zinc-500 focus:outline-none",value:z?"Other":v,onChange:P=>{P.target.value==="Other"?(T(!0),N("Other")):(T(!1),N(P.target.value))},children:[Pb.map(P=>t.jsx("option",{value:P,children:P},P)),t.jsxs("option",{value:"Other",children:["Other (enter manually)","…"]})]}),z&&t.jsx("input",{className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",type:"text",placeholder:"e.g. America/New_York",value:w,onChange:P=>A(P.target.value)})]}),L&&t.jsx("p",{className:"text-rose-400 text-sm",children:L}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>{o(!1),M(null)},children:"Cancel"}),t.jsx(ee,{type:"button",size:"sm",disabled:D||u==="custom"&&!x.trim(),onClick:Le(B),children:D?"Saving...":"Save schedule"})]})]})]})}const iB=[{value:"citation.lost",label:"Citation lost"},{value:"citation.gained",label:"Citation gained"},{value:"run.completed",label:"Run completed"},{value:"run.failed",label:"Run failed"}];function rB({projectName:e}){const[s,i]=j.useState("loading"),[r,o]=j.useState(!1),[u,d]=j.useState(""),[h,p]=j.useState(["citation.lost","citation.gained"]),[x,b]=j.useState(!1),[v,N]=j.useState(null),[z,T]=j.useState({}),[w,A]=j.useState(new Set);j.useEffect(()=>{C2(e).then(i).catch(()=>i([]))},[e]);const D=L=>{p(M=>M.includes(L)?M.filter(_=>_!==L):[...M,L])},U=async()=>{if(!(!u.trim()||h.length===0)){b(!0),N(null);try{const L=await A2(e,{channel:"webhook",url:u.trim(),events:h});i(M=>M==="loading"?[L]:[...M,L]),d(""),p(["citation.lost","citation.gained"]),o(!1),Qe({title:"Webhook added",detail:`Notifications will be sent to ${L.url}.`,tone:"positive",dedupeKey:`notification:add:${e}`,dedupeMode:"drop"})}catch(L){N(L instanceof Error?L.message:"Failed to add webhook")}finally{b(!1)}}},I=async L=>{if(!w.has(L)){A(M=>new Set(M).add(L));try{await T2(e,L),i(M=>M==="loading"?M:M.filter(_=>_.id!==L)),Qe({title:"Webhook removed",detail:`${e} no longer sends notifications to this endpoint.`,tone:"positive",dedupeKey:`notification:remove:${e}:${L}`,dedupeMode:"drop"})}catch(M){N(M instanceof Error?M.message:"Failed to remove webhook")}finally{A(M=>{const _=new Set(M);return _.delete(L),_})}}},C=async L=>{T(M=>({...M,[L]:{state:"testing"}}));try{const M=await _2(e,L);T(_=>({..._,[L]:{state:M.ok?"ok":"fail",status:M.status}})),M.ok&&Qe({title:"Test notification sent",detail:`Webhook returned status ${M.status}.`,tone:"positive",dedupeKey:`notification:test:${e}:${L}`,dedupeMode:"replace"})}catch{T(M=>({...M,[L]:{state:"fail"}}))}};return t.jsxs("section",{className:"page-section-divider",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Automation"}),t.jsx("h2",{children:"Notifications"})]}),s!=="loading"&&t.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>{o(!r),N(null)},children:r?"Cancel":"+ Add webhook"})]}),r&&t.jsxs("div",{className:"mb-3 rounded-lg border border-zinc-800 bg-zinc-900/40 p-4 space-y-3",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"text-xs font-medium text-zinc-400",children:"Webhook URL"}),t.jsx("input",{className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",type:"url",placeholder:"https://hooks.example.com/canonry",value:u,onChange:L=>d(L.target.value)})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("label",{className:"text-xs font-medium text-zinc-400",children:"Trigger on"}),t.jsx("div",{className:"flex flex-wrap gap-3",children:iB.map(L=>t.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[t.jsx("input",{type:"checkbox",className:"rounded border-zinc-600 bg-zinc-800",checked:h.includes(L.value),onChange:()=>D(L.value)}),t.jsx("span",{className:"text-sm text-zinc-300",children:L.label})]},L.value))})]}),v&&t.jsx("p",{className:"text-rose-400 text-sm",children:v}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>{o(!1),N(null)},children:"Cancel"}),t.jsx(ee,{type:"button",size:"sm",disabled:x||!u.trim()||h.length===0,onClick:Le(U),children:x?"Adding...":"Add webhook"})]})]}),s==="loading"&&t.jsx("p",{className:"supporting-copy",children:"Loading..."}),s!=="loading"&&s.length===0&&!r&&t.jsx(Se,{className:"surface-card compact-card",children:t.jsx("p",{className:"supporting-copy",children:"No webhooks configured. Add one to get alerted when citations change or runs complete."})}),s!=="loading"&&s.length>0&&t.jsxs("div",{className:"evidence-table-wrap",children:[t.jsxs("table",{className:"evidence-table",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"Endpoint"}),t.jsx("th",{children:"Events"}),t.jsx("th",{children:"Status"}),t.jsx("th",{})]})}),t.jsx("tbody",{children:s.map(L=>t.jsxs("tr",{children:[t.jsx("td",{className:"evidence-query-cell",children:t.jsx("span",{className:"font-mono text-xs text-zinc-300 break-all",title:L.urlHost,children:L.urlDisplay??L.url})}),t.jsx("td",{children:t.jsx("div",{className:"flex flex-wrap gap-1",children:L.events.map(M=>t.jsx("span",{className:"inline-flex items-center rounded-full border border-zinc-700 bg-zinc-800/60 px-2 py-0.5 text-[10px] font-medium text-zinc-400 uppercase tracking-wide",children:M.replace("."," ")},M))})}),t.jsx("td",{children:t.jsx(Ke,{tone:L.enabled?"positive":"neutral",children:L.enabled?"Active":"Paused"})}),t.jsx("td",{children:t.jsxs("div",{className:"flex items-center gap-1 justify-end",children:[z[L.id]&&(()=>{const M=z[L.id],_=M.state==="testing"?"Sending…":M.state==="ok"?`Delivered${M.status?` (${M.status})`:""}`:`Failed${M.status?` (${M.status})`:""}`;return t.jsx(Ke,{tone:M.state==="ok"?"positive":M.state==="fail"?"negative":"neutral",children:_})})(),t.jsx(ee,{variant:"ghost",size:"sm",type:"button",disabled:z[L.id]?.state==="testing",onClick:()=>{C(L.id)},children:"Test"}),t.jsx(ee,{variant:"ghost",size:"sm",type:"button",disabled:w.has(L.id),onClick:()=>{I(L.id)},children:w.has(L.id)?"Removing…":"Remove"})]})})]},L.id))})]}),v&&t.jsx("p",{className:"text-rose-400 text-sm mt-2",children:v})]})]})}function $r(e,s){return e.invalidateQueries({predicate:i=>{const r=i.queryKey[0];return typeof r?._id=="string"&&r._id.startsWith(s)}})}function lB({projectName:e,refreshNonce:s}){const i=wn(),[r,o]=j.useState(null),[u,d]=j.useState([]),[h,p]=j.useState(null),[x,b]=j.useState([]),[v,N]=j.useState([]),[z,T]=j.useState(null),[w,A]=j.useState(""),[D,U]=j.useState(""),[I,C]=j.useState(""),[L,M]=j.useState(!0),[_,B]=j.useState(!1),[J,ue]=j.useState(null),[P,ie]=j.useState("performance");j.useEffect(()=>{te()},[e,s]);async function te(){M(!0),ue(null);try{const E=await i.fetchQuery({...Yj({client:ae,path:{name:e}}),staleTime:bn});if(o(E),E.connected){const[X,Y,ye,le]=await Promise.all([i.fetchQuery({...Xj({client:ae,path:{name:e}}),staleTime:bn}).catch(()=>null),i.fetchQuery({...Jj({client:ae,path:{name:e}}),staleTime:bn}).catch(()=>[]),i.fetchQuery({...xO({client:ae,path:{name:e}}),staleTime:bn}).catch(()=>[]),E.siteUrl?Promise.resolve([]):i.fetchQuery({...hO({client:ae,path:{name:e}}),staleTime:bn}).then(Re=>Re.sites).catch(()=>[])]);p(X),b(Y),N(ye),d(le)}else p(null),b([]),N([]),d([])}catch(E){ue(E instanceof Error?E.message:"Failed to load Bing data")}finally{M(!1)}}async function ze(){if(D.trim()){ue(null);try{const E=await K2(e,D.trim());await $r(i,"getApiV1ProjectsByNameBing"),U(""),E.availableSites.length>0&&d(E.availableSites),await te()}catch(E){ue(E instanceof Error?E.message:"Failed to connect")}}}async function ve(){try{await Q2(e),await $r(i,"getApiV1ProjectsByNameBing"),o(null),d([]),p(null),b([]),N([]),T(null),C(""),ue(null)}catch(E){ue(E instanceof Error?E.message:"Failed to disconnect")}}async function V(){if(I)try{await Z2(e,I),await $r(i,"getApiV1ProjectsByNameBing"),await te()}catch(E){ue(E instanceof Error?E.message:"Failed to set site")}}async function ne(){if(w.trim())try{const E=await wv(e,w.trim());await $r(i,"getApiV1ProjectsByNameBing"),T(E),b(X=>[E,...X])}catch(E){ue(E instanceof Error?E.message:"Inspection failed")}}async function me(E){B(!0),ue(null);try{const X=await xy(e,{urls:[E]}),{succeeded:Y,failed:ye,total:le}=X.summary;Qe({title:"Bing submission requested",detail:ye===0?`${Y} URL submitted to Bing.`:`${Y}/${le} submitted successfully, ${ye} failed.`,tone:ye===0?"positive":"caution",dedupeKey:`bing:indexing:${e}:${E}`,dedupeMode:"replace"})}catch(X){const Y=X instanceof Error?X.message:"Submission failed";ue(Y),Qe({title:"Bing submission failed",detail:Y,tone:"negative",dedupeKey:`bing:indexing:${e}:${E}`,dedupeMode:"replace"})}finally{B(!1)}}async function Ne(){B(!0),ue(null),Qe({title:"Submitting URLs to Bing",detail:"Requesting indexing for all currently unindexed URLs.",tone:"neutral",dedupeKey:`bing:indexing-all:${e}`,dedupeMode:"replace"});try{const E=await xy(e,{allUnindexed:!0}),{succeeded:X,failed:Y,total:ye}=E.summary;Qe({title:"Bing submissions requested",detail:Y===0?`${X}/${ye} URL${ye!==1?"s":""} submitted to Bing.`:`${X}/${ye} submitted successfully, ${Y} failed.`,tone:Y===0?"positive":"caution",dedupeKey:`bing:indexing-all:${e}`,dedupeMode:"replace"})}catch(E){const X=E instanceof Error?E.message:"Batch submission failed";ue(X),Qe({title:"Bing submissions failed",detail:X,tone:"negative",dedupeKey:`bing:indexing-all:${e}`,dedupeMode:"replace"})}finally{B(!1)}}if(L)return t.jsx(Se,{className:"surface-card",children:t.jsx("div",{className:"text-sm text-zinc-400",children:"Loading Bing data..."})});if(!r?.connected)return t.jsxs(Se,{className:"surface-card",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Connection"}),t.jsx("h3",{children:"Domain authorization"})]}),t.jsx(Ke,{tone:"caution",children:"Not connected"})]}),t.jsx("p",{className:"text-sm text-zinc-300",children:"Connect Bing Webmaster Tools to inspect URLs, monitor index coverage, and submit pages for indexing."}),t.jsxs("div",{className:"mt-3",children:[t.jsx("label",{className:"text-xs text-zinc-500",htmlFor:"bing-api-key",children:"API Key"}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("input",{id:"bing-api-key",type:"password",className:"flex-1 rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"Bing Webmaster Tools API key",value:D,onChange:E=>U(E.target.value),onKeyDown:E=>{E.key==="Enter"&&ze()}}),t.jsx(ee,{size:"sm",disabled:!D.trim(),onClick:Le(ze),children:"Connect"})]}),t.jsxs("p",{className:"mt-1 text-[11px] text-zinc-500",children:["Get your API key from"," ",t.jsx("a",{href:"https://www.bing.com/webmasters/",target:"_blank",rel:"noopener noreferrer",className:"text-zinc-400 hover:text-zinc-300 underline underline-offset-2",children:"Bing Webmaster Tools"})]})]}),J&&t.jsx("p",{className:"mt-3 text-xs text-rose-400",children:J})]});if(!r.siteUrl)return t.jsxs(Se,{className:"surface-card",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Connection"}),t.jsx("h3",{children:"Domain authorization"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ke,{tone:"positive",children:"Connected"}),t.jsx(ee,{size:"sm",variant:"ghost",onClick:Le(ve),children:"Disconnect"})]})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/30 px-4 py-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),t.jsx("span",{className:"text-sm text-zinc-200",children:"Authorized for this project domain"}),t.jsx("span",{className:"text-xs text-zinc-500",children:r.domain})]}),t.jsx("p",{className:"mt-2 text-xs text-zinc-500",children:"The API key is connected, but no Bing site is selected yet. Pick the verified site that should receive inspections and indexing requests."})]}),t.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[t.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/20 p-3",children:[t.jsx("p",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Registered domain"}),t.jsx("p",{className:"mt-1 text-sm text-zinc-200",children:r.domain})]}),t.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/20 p-3",children:[t.jsx("p",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Last auth update"}),t.jsx("p",{className:"mt-1 text-sm text-zinc-200",children:r.updatedAt?$s(r.updatedAt):"—"})]})]}),t.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/20 p-3",children:[t.jsx("p",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Select site"}),u.length>0?t.jsxs("div",{className:"mt-3 flex flex-col gap-2 lg:flex-row",children:[t.jsxs("select",{className:"flex-1 rounded border border-zinc-700 bg-zinc-900 px-2 py-1.5 text-sm text-zinc-200 focus:border-zinc-500 focus:outline-none",value:I,onChange:E=>C(E.target.value),children:[t.jsx("option",{value:"",children:"Select a site..."}),u.map(E=>t.jsxs("option",{value:E.url,children:[E.url,E.verified?" (verified)":""]},E.url))]}),t.jsx(ee,{size:"sm",disabled:!I,onClick:Le(V),children:"Set Site"})]}):t.jsx("p",{className:"mt-3 text-xs text-zinc-500",children:"No verified Bing sites are available yet. Verify the domain in Bing Webmaster Tools, then use the page-level refresh to reload everything."})]})]}),J&&t.jsx("p",{className:"mt-3 text-xs text-rose-400",children:J})]});const se=[{key:"performance",label:"Performance",eyebrow:"Performance",title:"Search performance"},{key:"coverage",label:"Coverage",eyebrow:"Coverage",title:"Index monitoring"},{key:"inspections",label:"Inspections",eyebrow:"Inspection",title:"URL inspection history"}],pe=se.find(E=>E.key===P)??se[0];return t.jsxs("div",{className:"space-y-3",children:[t.jsxs(Se,{className:"surface-card",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Connection"}),t.jsx("h3",{children:"Domain authorization"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ke,{tone:"positive",children:"Connected"}),t.jsx(ee,{size:"sm",variant:"ghost",onClick:Le(ve),children:"Disconnect"})]})]}),J&&t.jsx("p",{className:"mb-3 text-xs text-rose-400",children:J}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/30 px-4 py-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),t.jsx("span",{className:"text-sm text-zinc-200",children:"Authorized for this project domain"}),t.jsx("span",{className:"text-xs text-zinc-500",children:r.domain})]}),t.jsxs("p",{className:"mt-2 text-xs text-zinc-500",children:["Canonry stores Bing connections per canonical domain. This project is currently mapped to ",t.jsx("code",{children:r.siteUrl}),"."]})]}),t.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[t.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/20 p-3",children:[t.jsx("p",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Selected site"}),t.jsx("p",{className:"mt-1 text-sm text-zinc-200",children:r.siteUrl})]}),t.jsxs("div",{className:"rounded-lg border border-zinc-800/60 bg-zinc-900/20 p-3",children:[t.jsx("p",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Last auth update"}),t.jsx("p",{className:"mt-1 text-sm text-zinc-200",children:r.updatedAt?$s(r.updatedAt):"—"})]})]})]})]}),t.jsxs(Se,{className:"surface-card",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:pe.eyebrow}),t.jsx("h3",{children:pe.title})]}),t.jsx("p",{className:"text-xs text-zinc-500",children:h?.lastInspectedAt?`Last inspected ${$s(h.lastInspectedAt)}`:"No inspection history yet"})]}),t.jsx("div",{className:"flex gap-1 border-b border-zinc-800",children:se.map(E=>t.jsx("button",{className:`px-3 py-1.5 text-xs font-medium border-b-2 transition-colors ${P===E.key?"border-zinc-200 text-zinc-200":"border-transparent text-zinc-500 hover:text-zinc-300"}`,onClick:()=>ie(E.key),children:E.label},E.key))}),P==="coverage"&&h&&t.jsxs("div",{className:"mt-4 space-y-4",children:[t.jsxs("div",{className:"grid gap-3 sm:grid-cols-4",children:[t.jsx(Xc,{label:"Indexed",value:h.summary.indexed,tone:"positive"}),t.jsx(Xc,{label:"Not in index",value:h.summary.notIndexed+(h.summary.unknown??0),tone:"negative"}),t.jsx(Xc,{label:"Status unknown",value:h.summary.unknown??0,tone:"neutral"}),t.jsx(Xc,{label:"Coverage",value:`${h.summary.percentage}%`,tone:"neutral"})]}),h.notIndexed.length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[t.jsxs("h4",{className:"text-xs font-medium text-zinc-400",children:["Not Indexed (",h.notIndexed.length,")"]}),t.jsx(ee,{size:"sm",variant:"ghost",disabled:_,onClick:Le(Ne),children:_?"Submitting…":"Submit all to Bing"})]}),t.jsx("div",{className:"overflow-x-auto rounded-lg border border-zinc-800/60",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-zinc-800",children:[t.jsx("th",{className:"text-left py-1.5 px-3 text-zinc-500 font-medium",children:"URL"}),t.jsx("th",{className:"text-left py-1.5 px-3 text-zinc-500 font-medium w-16",children:"HTTP"}),t.jsx("th",{className:"text-right py-1.5 px-3 text-zinc-500 font-medium w-20",children:"Action"})]})}),t.jsx("tbody",{children:h.notIndexed.map(E=>t.jsxs("tr",{className:"border-b border-zinc-800/50",children:[t.jsx("td",{className:"py-1.5 px-3 text-zinc-300 truncate max-w-[480px]",children:E.url}),t.jsx("td",{className:"py-1.5 px-3 text-zinc-400",children:E.httpCode??"—"}),t.jsx("td",{className:"py-1.5 px-3 text-right",children:t.jsx("button",{className:"text-[10px] text-zinc-400 hover:text-zinc-200 underline underline-offset-2",disabled:_,onClick:()=>{me(E.url)},children:"Submit"})})]},E.id))})]})})]}),(h.unknown??[]).length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[t.jsxs("h4",{className:"text-xs font-medium text-zinc-400",children:["Unknown — not yet confirmed (",(h.unknown??[]).length,")"]}),t.jsx(ee,{size:"sm",variant:"ghost",disabled:_,onClick:Le(Ne),children:_?"Submitting…":"Submit all to Bing"})]}),t.jsx("div",{className:"overflow-x-auto rounded-lg border border-zinc-800/60",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-zinc-800",children:[t.jsx("th",{className:"text-left py-1.5 px-3 text-zinc-500 font-medium",children:"URL"}),t.jsx("th",{className:"text-left py-1.5 px-3 text-zinc-500 font-medium w-32",children:"Last Crawled"}),t.jsx("th",{className:"text-right py-1.5 px-3 text-zinc-500 font-medium w-20",children:"Action"})]})}),t.jsx("tbody",{children:(h.unknown??[]).map(E=>t.jsxs("tr",{className:"border-b border-zinc-800/50",children:[t.jsx("td",{className:"py-1.5 px-3 text-zinc-300 truncate max-w-[480px]",children:E.url}),t.jsx("td",{className:"py-1.5 px-3 text-zinc-400",children:E.lastCrawledDate?$s(E.lastCrawledDate):"—"}),t.jsx("td",{className:"py-1.5 px-3 text-right",children:t.jsx("button",{className:"text-[10px] text-zinc-400 hover:text-zinc-200 underline underline-offset-2",disabled:_,onClick:()=>{me(E.url)},children:"Submit"})})]},E.id))})]})})]}),h.indexed.length>0&&t.jsxs("div",{children:[t.jsxs("h4",{className:"mb-2 text-xs font-medium text-zinc-400",children:["Indexed (",h.indexed.length,")"]}),t.jsx("div",{className:"overflow-x-auto rounded-lg border border-zinc-800/60",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-zinc-800",children:[t.jsx("th",{className:"text-left py-1.5 px-3 text-zinc-500 font-medium",children:"URL"}),t.jsx("th",{className:"text-left py-1.5 px-3 text-zinc-500 font-medium w-32",children:"Last Crawled"})]})}),t.jsx("tbody",{children:h.indexed.map(E=>t.jsxs("tr",{className:"border-b border-zinc-800/50",children:[t.jsx("td",{className:"py-1.5 px-3 text-zinc-300 truncate max-w-[480px]",children:E.url}),t.jsx("td",{className:"py-1.5 px-3 text-zinc-400",children:E.lastCrawledDate?$s(E.lastCrawledDate):"—"})]},E.id))})]})})]})]}),P==="coverage"&&!h&&t.jsx("p",{className:"mt-4 text-xs text-zinc-500",children:"No coverage data yet. Inspect URLs to build coverage data."}),P==="inspections"&&t.jsxs("div",{className:"mt-4 space-y-3",children:[t.jsxs("div",{className:"flex flex-col gap-2 lg:flex-row",children:[t.jsx("input",{type:"text",className:"flex-1 rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"URL to inspect",value:w,onChange:E=>A(E.target.value),onKeyDown:E=>{E.key==="Enter"&&ne()}}),t.jsx(ee,{size:"sm",disabled:!w.trim(),onClick:Le(ne),children:"Inspect"})]}),z&&t.jsxs("div",{className:"rounded border border-zinc-800 bg-zinc-900/40 p-3 text-xs space-y-1",children:[t.jsx("div",{className:"font-medium text-zinc-200",children:z.url}),t.jsxs("div",{className:"text-zinc-400",children:["In Index: ",t.jsx("span",{className:z.inIndex?"text-emerald-400":"text-rose-400",children:z.inIndex?"Yes":"No"})," · ","HTTP: ",z.httpCode??"—"," · ","Crawled: ",z.lastCrawledDate??"—"]})]}),x.length>0&&t.jsx("div",{className:"overflow-x-auto rounded-lg border border-zinc-800/60",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-zinc-800",children:[t.jsx("th",{className:"text-left py-1.5 px-3 text-zinc-500 font-medium",children:"URL"}),t.jsx("th",{className:"text-left py-1.5 px-3 text-zinc-500 font-medium w-16",children:"Index"}),t.jsx("th",{className:"text-left py-1.5 px-3 text-zinc-500 font-medium w-14",children:"HTTP"}),t.jsx("th",{className:"text-left py-1.5 px-3 text-zinc-500 font-medium w-32",children:"Inspected"})]})}),t.jsx("tbody",{children:x.map(E=>t.jsxs("tr",{className:"border-b border-zinc-800/50",children:[t.jsx("td",{className:"py-1.5 px-3 text-zinc-300 truncate max-w-[480px]",children:E.url}),t.jsx("td",{className:"py-1.5 px-3",children:t.jsx(Ke,{tone:E.inIndex?"positive":"negative",children:E.inIndex?"Yes":"No"})}),t.jsx("td",{className:"py-1.5 px-3 text-zinc-400",children:E.httpCode??"—"}),t.jsx("td",{className:"py-1.5 px-3 text-zinc-400",children:$s(E.inspectedAt)})]},E.id))})]})})]}),P==="performance"&&t.jsx("div",{className:"mt-4",children:v.length===0?t.jsx("p",{className:"text-xs text-zinc-500",children:"No Bing performance data available."}):t.jsx("div",{className:"overflow-x-auto rounded-lg border border-zinc-800/60",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-zinc-800",children:[t.jsx("th",{className:"text-left py-1.5 px-3 text-zinc-500 font-medium",children:"Query"}),t.jsx("th",{className:"text-right py-1.5 px-3 text-zinc-500 font-medium w-16",children:Uc[Wa.Clicks]}),t.jsx("th",{className:"text-right py-1.5 px-3 text-zinc-500 font-medium w-16",children:Uc[Wa.Impressions]}),t.jsx("th",{className:"text-right py-1.5 px-3 text-zinc-500 font-medium w-14",children:Uc[Wa.CTR]}),t.jsx("th",{className:"text-right py-1.5 px-3 text-zinc-500 font-medium w-14",children:Uc[Wa.Position]})]})}),t.jsx("tbody",{children:v.map((E,X)=>t.jsxs("tr",{className:"border-b border-zinc-800/50",children:[t.jsx("td",{className:"py-1.5 px-3 text-zinc-300 truncate max-w-[480px]",children:E.query}),t.jsx("td",{className:"py-1.5 px-3 text-right text-zinc-200",children:E.clicks}),t.jsx("td",{className:"py-1.5 px-3 text-right text-zinc-400",children:E.impressions}),t.jsxs("td",{className:"py-1.5 px-3 text-right text-zinc-400",children:[(Number.isFinite(E.ctr)?E.ctr*100:0).toFixed(1),"%"]}),t.jsx("td",{className:"py-1.5 px-3 text-right text-zinc-400",children:E.averagePosition.toFixed(1)})]},X))})]})})})]})]})}function oB({projectName:e}){const s=wn(),[i,r]=j.useState("google"),[o,u]=j.useState(!0),[d,h]=j.useState("idle"),[p,x]=j.useState(null),b=j.useRef(null),[v,N]=j.useState(!1),[z,T]=j.useState(null),[w,A]=j.useState(null),[D,U]=j.useState(!1),[I,C]=j.useState(null),[L,M]=j.useState(null),[_,B]=j.useState(0);async function J(E=!1){E||u(!0),x(null);try{const[X,Y,ye]=await Promise.all([s.fetchQuery(Qj({client:ae})).catch(()=>null),s.fetchQuery({...Zj({client:ae,path:{name:e}}),staleTime:bn}).catch(()=>[]),s.fetchQuery({...Yj({client:ae,path:{name:e}}),staleTime:bn}).catch(()=>null)]),le=Y.find(we=>we.connectionType==="gsc")??null;N(!!X?.google?.configured),U(!!X?.bing?.configured),T(le),C(ye);const[Re,tt]=await Promise.all([le?s.fetchQuery({...Fj({client:ae,path:{name:e}}),staleTime:bn}).catch(()=>null):Promise.resolve(null),ye?.connected?s.fetchQuery({...Xj({client:ae,path:{name:e}}),staleTime:bn}).catch(()=>null):Promise.resolve(null)]);A(Re),M(tt)}catch(X){x(X instanceof Error?X.message:"Failed to load search console overview")}finally{u(!1)}}async function ue(){if(d!=="idle")return;b.current?.abort();const E=new AbortController;b.current=E;const X=E.signal;h("syncing"),x(null);const Y=[];try{async function ye(){if(!z)return;const we=await Nv(e);if(!we?.id)return;const Ue=2e3,mt=Date.now()+12e4;for(;Date.now()<mt;){if(X.aborted||(await new Promise(pt=>setTimeout(pt,Ue)),X.aborted))return;const Nt=await Kr(we.id).catch(()=>null);if(!Nt)break;if(["completed","failed","cancelled"].includes(Nt.status)){Nt.status!=="completed"&&Y.push(`Google sync ${Nt.status}`);break}}}const le=10;async function Re(){if(!I?.connected)return;const we=await s.fetchQuery({...Jj({client:ae,path:{name:e}}),staleTime:0}).catch(()=>[]),Ue=[...new Set(we.map(Ce=>Ce.url))];if(Ue.length===0){await Y2(e).catch(()=>null);return}for(let Ce=0;Ce<Ue.length;Ce+=le){if(X.aborted)return;const mt=Ue.slice(Ce,Ce+le),pt=(await Promise.allSettled(mt.map(gt=>wv(e,gt)))).filter(gt=>gt.status==="rejected").length;pt>0&&Y.push(`${pt} Bing inspection(s) failed`)}}const tt=await Promise.allSettled([ye(),Re()]);for(const we of tt)we.status==="rejected"&&Y.push(we.reason instanceof Error?we.reason.message:"Sync failed");if(X.aborted)return;h("reloading"),await Promise.all([$r(s,"getApiV1ProjectsByNameGoogleGsc"),$r(s,"getApiV1ProjectsByNameBing")]),await J(!0),B(we=>we+1),Y.length>0&&x(`Partial refresh: ${Y.join("; ")}`)}catch(ye){X.aborted||x(ye instanceof Error?ye.message:"Refresh failed")}finally{X.aborted||h("idle")}}j.useEffect(()=>(J(),()=>{b.current?.abort()}),[e]);const P=z?"positive":v?"caution":"negative",ie=z?"Connected":v?"Ready to connect":"Needs setup",te=w?`${w.summary.percentage}% indexed`:z?"Awaiting coverage":"No coverage data",ze=w?`${w.summary.notIndexed} not indexed${w.summary.deindexed>0?` · ${w.summary.deindexed} deindexed`:""}`:z?"Run sitemap inspection to populate coverage":v?"Connect Search Console for this domain":"Add Google OAuth credentials in Settings",ve=w?.lastSyncedAt??w?.lastInspectedAt??z?.updatedAt??null,V=I?.connected?"positive":D?"caution":"negative",ne=I?.connected?"Connected":D?"Ready to connect":"Needs setup",me=L?`${L.summary.percentage}% indexed`:I?.connected?"Awaiting coverage":"No coverage data",Ne=L?L.summary.notIndexed+(L.summary.unknown??0):0,se=L?`${Ne} not in index`:I?.connected?"Inspect URLs to populate coverage":D?"Connect Bing Webmaster Tools for this domain":"Add a Bing API key in Settings",pe=L?.lastInspectedAt??I?.updatedAt??null;return t.jsxs("div",{className:"space-y-6",children:[t.jsxs(Se,{className:"surface-card",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Search console"}),t.jsx("h2",{children:"Search Engine Intelligence"}),t.jsx("p",{className:"mt-1 max-w-3xl text-sm leading-6 text-zinc-500",children:"Scan both engines at a glance, then open the Google or Bing workspace when you need to inspect coverage or take action."})]}),t.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:o||d!=="idle",onClick:()=>{ue()},children:o?"Loading…":d==="syncing"?"Refreshing Google & Bing…":d==="reloading"?"Reloading workspaces…":"Refresh all"})]}),p&&t.jsx("div",{className:"mb-3 rounded-lg border border-rose-800/40 bg-rose-950/20 px-3 py-2 text-sm text-rose-300",children:p}),t.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[t.jsx(Ob,{eyebrow:"Google",title:"Google Search Console",status:o?"Loading…":ie,tone:o?"neutral":P,targetLabel:"Selected property",targetValue:z?.propertyId??"No property selected",coverageValue:o?"Loading…":te,note:o?"Loading overview…":ze,updatedAt:ve,active:i==="google",onClick:()=>r("google")}),t.jsx(Ob,{eyebrow:"Bing",title:"Bing Webmaster Tools",status:o?"Loading…":ne,tone:o?"neutral":V,targetLabel:"Selected site",targetValue:I?.siteUrl??"No site selected",coverageValue:o?"Loading…":me,note:o?"Loading overview…":se,updatedAt:pe,active:i==="bing",onClick:()=>r("bing")})]})]}),t.jsx("div",{className:"flex flex-wrap gap-2",role:"tablist","aria-label":"Search engine workspaces",children:[["google","Google"],["bing","Bing"]].map(([E,X])=>t.jsx("button",{type:"button",role:"tab","aria-selected":i===E,className:`project-subnav-link ${i===E?"project-subnav-link-active":""}`,onClick:()=>r(E),children:X},E))}),i==="google"&&t.jsx(b$,{projectName:e,refreshNonce:_}),i==="bing"&&t.jsxs("section",{className:"page-section-divider",children:[t.jsx("div",{className:"section-head section-head-inline",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Search engine"}),t.jsx("h2",{children:"Bing Webmaster Tools"})]})}),t.jsx(lB,{projectName:e,refreshNonce:_})]})]})}function cB({summary:e,onJumpToEvidence:s}){if(!e.hasPreviousRun)return t.jsxs("section",{className:"movement-banner",children:[t.jsx("span",{className:"movement-banner-label",children:"Since last run"}),t.jsx("span",{className:"text-zinc-500",children:"First run — no comparison yet"})]});const i=e.gained,r=e.lost,o=i===0&&r===0?"· no changes":i>r?"· improving":r>i?"· declining":"";return t.jsxs("section",{className:"movement-banner",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"movement-banner-label",children:"Since last run"}),i>0?t.jsxs("button",{type:"button",className:"movement-banner-chip text-emerald-400 font-medium",onClick:s,title:"Jump to the queries that gained citations",children:["+",i," gained"]}):t.jsx("span",{className:"text-zinc-500",children:"+0 gained"}),t.jsx("span",{className:"text-zinc-700 mx-1",children:"·"}),r>0?t.jsxs("button",{type:"button",className:"movement-banner-chip text-rose-400 font-medium",onClick:s,title:"Jump to the queries that lost citations",children:["−",r," lost"]}):t.jsx("span",{className:"text-zinc-500",children:"−0 lost"}),t.jsx("span",{className:"text-zinc-600 ml-2",children:o})]}),e.gainedQueries?.length||e.lostQueries?.length?t.jsxs("div",{className:"movement-banner-detail",children:[e.gainedQueries&&e.gainedQueries.length>0&&t.jsxs("p",{children:[t.jsx("span",{className:"text-emerald-500/90",children:"Gained:"})," ",t.jsx("span",{className:"text-zinc-300",children:Gb(e.gainedQueries)})]}),e.lostQueries&&e.lostQueries.length>0&&t.jsxs("p",{children:[t.jsx("span",{className:"text-rose-500/90",children:"Lost:"})," ",t.jsx("span",{className:"text-zinc-300",children:Gb(e.lostQueries)})]})]}):null]})}function Gb(e,s=4){return e.length<=s?e.map(r=>`"${r}"`).join(", "):`${e.slice(0,s).map(r=>`"${r}"`).join(", ")}, and ${e.length-s} more`}function uB({summary:e,projectLabel:s}){const i=e.breakdown;if(i.perCompetitor.length===0)return null;const r=i.projectMentionSnapshots+i.competitorMentionSnapshots;if(r===0)return null;const o=[{label:`${s} (you)`,mentions:i.projectMentionSnapshots,isYou:!0},...i.perCompetitor.map(d=>({label:d.domain,mentions:d.mentionSnapshots,isYou:!1}))].sort((d,h)=>h.mentions-d.mentions),u=o[0]?.mentions??1;return t.jsxs("div",{className:"mention-share-breakdown",children:[t.jsx("p",{className:"mention-share-breakdown-title",children:"Mention share breakdown"}),t.jsx("ul",{className:"mention-share-breakdown-rows",children:o.map(d=>{const h=d.mentions/r*100;return t.jsxs("li",{className:"mention-share-breakdown-row",children:[t.jsx("span",{className:`mention-share-breakdown-label ${d.isYou?"text-zinc-100 font-medium":"text-zinc-400"}`,children:d.label}),t.jsx("div",{className:"mention-share-breakdown-bar",children:t.jsx("div",{className:`mention-share-breakdown-bar-fill ${d.isYou?"bg-emerald-500/70":"bg-zinc-500/60"}`,style:{width:`${Math.max(d.mentions/u*100,2)}%`}})}),t.jsx("span",{className:"mention-share-breakdown-count",children:d.mentions}),t.jsxs("span",{className:"mention-share-breakdown-share",children:[h.toFixed(1),"%"]})]},d.label)})})]})}function dB({trend:e,currentScore:s}){if(!e||e.length<2)return t.jsx("span",{className:"text-[11px] text-zinc-600",children:"—"});const i=96,r=24,o=100,u=e.length>1?i/(e.length-1):0,d=e.map((b,v)=>`${(v*u).toFixed(2)},${(r-b/o*r).toFixed(2)}`).join(" "),h=s>=70?"rgb(52 211 153)":s>=40?"rgb(251 191 36)":"rgb(251 113 133)",p=(e.length-1)*u,x=r-e[e.length-1]/o*r;return t.jsxs("svg",{width:i,height:r,viewBox:`0 0 ${i} ${r}`,className:"overflow-visible","aria-label":`Trend ${e.join(", ")}`,role:"img",children:[t.jsx("polyline",{points:d,fill:"none",stroke:h,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}),t.jsx("circle",{cx:p,cy:x,r:2.5,fill:h})]})}const mB={write:{title:"Write or update content",subtitle:"Queries with no answer, persistent gaps, or competitors winning the spot"},investigate:{title:"Investigate what changed",subtitle:"Citations or mentions you lost since the previous run"},monitor:{title:"Keep monitoring",subtitle:"Gains, new providers picking you up, holding ground"}};function hB({insights:e,suggestedQueries:s,projectName:i}){const{openEvidence:r}=tl(),[o,u]=j.useState(null),d=s.rows.length>0;if(e.length===0&&!d)return t.jsx("p",{className:"text-sm text-zinc-500",children:"No outstanding opportunities. Trigger a sweep to surface fresh signals."});const h=["write","investigate","monitor"],p=new Map;for(const x of e){const b=p.get(x.actionGroup)??[];b.push(x),p.set(x.actionGroup,b)}return t.jsxs("div",{className:"opportunities-grid",children:[h.map(x=>{const b=p.get(x);if(!b||b.length===0)return null;const v=mB[x];return t.jsxs("div",{className:`opportunity-card opportunity-card-${x}`,children:[t.jsxs("div",{className:"opportunity-card-head",children:[t.jsx("p",{className:"opportunity-card-title",children:v.title}),t.jsx("span",{className:"opportunity-card-count",children:b.length})]}),t.jsx("p",{className:"opportunity-card-subtitle",children:v.subtitle}),t.jsx("div",{className:"opportunity-card-list",children:b.map(N=>{const z=o===N.id,T=N.affectedPhrases.length>0;return t.jsxs("div",{children:[t.jsx("div",{className:`opportunity-item opportunity-item-${N.tone} ${T?"cursor-pointer":""}`,onClick:T?()=>u(z?null:N.id):void 0,children:t.jsxs("div",{className:"flex items-start gap-1.5 min-w-0",children:[T&&t.jsx(jo,{size:12,className:`mt-1 shrink-0 text-zinc-500 transition-transform duration-150 ${z?"rotate-90":""}`}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-medium text-zinc-100 leading-snug",children:N.title}),N.detail&&t.jsx("p",{className:"text-[11px] text-zinc-500 mt-0.5 leading-snug",children:N.detail})]})]})}),z&&t.jsx("div",{className:"opportunity-item-detail",children:N.affectedPhrases.map((w,A)=>t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[t.jsx(hf,{state:w.citationState}),t.jsx("span",{className:"text-xs text-zinc-300 truncate",children:w.query}),w.provider&&t.jsx($i,{provider:w.provider})]}),w.evidenceId&&t.jsx("button",{type:"button",className:"text-[11px] text-zinc-400 hover:text-zinc-200 whitespace-nowrap",onClick:D=>{D.stopPropagation(),r(w.evidenceId)},children:"View →"})]},w.evidenceId||`${N.id}-${A}`))})]},N.id)})})]},x)}),d&&t.jsx(fB,{suggestedQueries:s,projectName:i})]})}function fB({suggestedQueries:e,projectName:s}){const i=x$(),[r,o]=j.useState(new Set),u=b=>{o(v=>new Set(v).add(b)),i.mutate({projectName:s,queries:[b]},{onSuccess:()=>{Qe({tone:"positive",title:`Tracking "${b}"`})},onError:v=>{Qe({tone:"negative",title:`Couldn't add "${b}"`,detail:String(v)}),o(N=>{const z=new Set(N);return z.delete(b),z})}})},{rows:d,totalCandidates:h,skippedAlreadyTracked:p}=e,x=p>0?`GSC queries you're getting impressions for · ${p} already tracked`:"GSC queries you're getting impressions for but aren't tracking yet";return t.jsxs("div",{className:"opportunity-card opportunity-card-track",children:[t.jsxs("div",{className:"opportunity-card-head",children:[t.jsx("p",{className:"opportunity-card-title",children:"Track new queries"}),t.jsx("span",{className:"opportunity-card-count",children:h>d.length?`${d.length} of ${h}`:d.length})]}),t.jsx("p",{className:"opportunity-card-subtitle",children:x}),t.jsx("div",{className:"opportunity-card-list",children:d.map(b=>{const v=r.has(b.query);return t.jsxs("div",{className:"opportunity-item opportunity-item-neutral flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-zinc-100 leading-snug truncate",title:b.query,children:b.query}),t.jsx("p",{className:"text-[11px] text-zinc-500 mt-0.5 leading-snug",children:b.reason})]}),t.jsx("button",{type:"button",className:"suggested-query-add",disabled:v,onClick:()=>u(b.query),children:v?"Adding…":"+ Track"})]},b.query)})})]})}function Vi({tab:e}){const{projectId:s}=Jb({from:"/projects/$projectId"}),i=bo(),{dashboard:r,isLoading:o,refetch:u}=Pi(),d=wn();if(!r||o)return t.jsxs("div",{className:"page-skeleton",children:[t.jsxs("div",{className:"page-skeleton-header",children:[t.jsx("div",{className:"skeleton-text h-6 w-48"}),t.jsx("div",{className:"skeleton-text-sm w-32"})]}),t.jsx("div",{className:"grid grid-cols-3 gap-4",children:[1,2,3].map(F=>t.jsxs("div",{className:"page-skeleton-card flex flex-col items-center",children:[t.jsx("div",{className:"skeleton-circle size-20"}),t.jsx("div",{className:"skeleton-text w-16 mt-3"})]},F))}),t.jsxs("div",{className:"page-skeleton-card",children:[t.jsx("div",{className:"skeleton-text w-28"}),t.jsx("div",{className:"space-y-2 mt-2",children:[1,2,3,4].map(F=>t.jsx("div",{className:"skeleton-text-sm w-full"},F))})]})]});const h=h6(r,s),[p,x]=j.useState(!1),[b,v]=j.useState(!1),[N,z]=j.useState(!1),[T,w]=j.useState(""),[A,D]=j.useState(!1),[U,I]=j.useState(!1),[C,L]=j.useState(""),[M,_]=j.useState(!1),[B,J]=j.useState(!1),[ue,P]=j.useState(""),[ie,te]=j.useState(!1),[ze,ve]=j.useState(!1),[V,ne]=j.useState(""),[me,Ne]=j.useState(!1),[se,pe]=j.useState(void 0),[E,X]=j.useState(!1),[Y,ye]=j.useState(null),[le,Re]=j.useState(null),[tt,we]=j.useState(!1),Ue=h?.visibilityEvidence??[],Ce=h?.project.name??"",mt=h?.project.displayName||h?.project.name||Ce,Nt=v1(),pt=(h?.recentRuns??[]).some(F=>F.kind===et["answer-visibility"]&&(F.status===jn.running||F.status===jn.queued)),gt=j.useMemo(()=>(h?.project.locations??[]).map(F=>F.label),[h?.project.locations]),St=j.useMemo(()=>new Set(Ue.map(F=>F.location??"")),[Ue]),Fn=St.has(""),be=j.useMemo(()=>{const F=[...St].filter(Boolean);return F.length>1?F:gt},[St,gt]);j.useEffect(()=>{if(se===void 0||se===""||!Ce){Re(null),we(!1);return}we(!0),yv(Ce,se).then(F=>{Re(F),we(!1)}).catch(()=>{Re(null),we(!1)})},[se,Ce]);const Ae=j.useMemo(()=>{if(!le)return null;const F=new Map;for(const Pe of le){for(const[He,ut]of Object.entries(Pe.providerRuns??{}))F.set(`${Pe.query}::${He}`,ut.map(ht=>({runId:ht.runId,citationState:ht.citationState,createdAt:ht.createdAt,answerMentioned:ht.answerMentioned,visibilityState:ht.visibilityState,visibilityTransition:ht.visibilityTransition,mentionState:ht.mentionState,mentionTransition:ht.mentionTransition})));(!Pe.providerRuns||Object.keys(Pe.providerRuns).length===0)&&F.set(`${Pe.query}::`,Pe.runs.map(He=>({runId:He.runId,citationState:He.citationState,createdAt:He.createdAt,answerMentioned:He.answerMentioned,visibilityState:He.visibilityState,visibilityTransition:He.visibilityTransition,mentionState:He.mentionState,mentionTransition:He.mentionTransition})))}return F},[le]),sn=j.useMemo(()=>{let F=se!==void 0?Ue.filter(Pe=>se===""?!Pe.location:Pe.location===se):Ue;if(Y){const Pe=Y.toLowerCase();F=F.filter(He=>He.competitorDomains.some(ut=>ut.toLowerCase()===Pe))}return Ae?F.map(Pe=>{const He=Ae.get(`${Pe.query}::${Pe.provider}`)??Ae.get(`${Pe.query}::`);return He?{...Pe,runHistory:He}:Pe}):F},[Ue,se,Y,Ae]);if(!h)return t.jsx("div",{className:"page-container",children:t.jsxs(Se,{className:"surface-card empty-card",children:[t.jsx("h1",{children:"Project not found"}),t.jsxs("p",{children:['Could not find a project with ID "',s,'".']}),t.jsx(ee,{asChild:!0,children:t.jsx(ft,{to:"/",children:"Return to overview"})})]})});async function Zt(){try{await Nt.mutateAsync({projectName:Ce,projectLabel:mt,sourceAction:"project-run"}),u()}catch{}}async function an(){v(!0);try{await b2(Ce),Qe({title:"Project deleted",detail:`${mt} was removed.`,tone:"positive",dedupeKey:`project:delete:${Ce}`,dedupeMode:"drop"}),i({to:"/"}),u()}catch(F){console.error("Failed to delete project:",F)}finally{v(!1)}}async function ws(){try{const F=await v2(Ce),Pe=typeof F=="string"?F:JSON.stringify(F,null,2),He=new Blob([Pe],{type:"text/yaml"}),ut=URL.createObjectURL(He),ht=document.createElement("a");ht.href=ut,ht.download=`${Ce}.yaml`,ht.click()}catch(F){Qe({title:"Export failed",detail:F instanceof Error?F.message:"Could not export project YAML.",tone:"negative"})}}async function $t(){const F=T.split(`
205
- `).map(Pe=>Pe.trim()).filter(Boolean);if(F.length!==0){D(!0);try{await bv(Ce,F),u(),w(""),z(!1)}finally{D(!1)}}}async function $n(){const F=C.trim();if(F){_(!0);try{const He=(await xv(Ce)).map(ht=>ht.domain),ut=[...new Set([...He,F])];await vv(Ce,ut),u(),L(""),I(!1)}finally{_(!1)}}}async function Yn(){const F=ue.trim();if(F){te(!0);try{const Pe=h?.project.ownedDomains??[];await dy(Ce,[...Pe,F]),u(),P(""),J(!1)}finally{te(!1)}}}async function dn(F){te(!0);try{const Pe=h?.project.ownedDomains??[];await dy(Ce,Pe.filter(He=>He!==F)),u()}finally{te(!1)}}async function zn(){const F=V.trim();if(F){Ne(!0);try{const Pe=h?.project.aliases??[],He=F.toLowerCase();if(Pe.some(ut=>ut.toLowerCase()===He)){ne(""),ve(!1);return}await my(Ce,[...Pe,F]),u(),ne(""),ve(!1)}finally{Ne(!1)}}}async function rs(F){Ne(!0);try{const Pe=h?.project.aliases??[];await my(Ce,Pe.filter(He=>He!==F)),u()}finally{Ne(!1)}}async function kn(F,Pe){await f2(F,Pe),await d.invalidateQueries({queryKey:li({client:ae})})}const Ss=F=>!Number.isNaN(Number.parseInt(F,10)),zs=[{key:"overview",label:"Overview",href:`/projects/${h.project.id}`},{key:"search-console",label:"Search Engine Intelligence",href:`/projects/${h.project.id}/search-console`},{key:"activity",label:"Activity",href:`/projects/${h.project.id}/activity`},{key:"report",label:"Report",href:`/projects/${h.project.id}/report`},{key:"backlinks",label:"Backlinks",href:`/projects/${h.project.id}/backlinks`},{key:"discovery",label:"Discovery",href:`/projects/${h.project.id}/discovery`},{key:"settings",label:"Settings",href:`/projects/${h.project.id}/settings`}];return t.jsxs("div",{className:"page-container",children:[p?t.jsxs(Se,{className:"surface-card p-6 mb-6 border-rose-800/60",children:[t.jsx("h3",{className:"text-base font-semibold text-rose-400 mb-2",children:"Delete project?"}),t.jsxs("p",{className:"text-sm text-zinc-400 mb-4",children:["This will permanently delete ",t.jsx("strong",{className:"text-zinc-200",children:h.project.displayName||h.project.name})," and all its queries, competitors, runs, and snapshots. This cannot be undone."]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ee,{type:"button",variant:"destructive",disabled:b,onClick:Le(an),children:b?"Deleting...":"Yes, delete project"}),t.jsx(ee,{type:"button",variant:"outline",disabled:b,onClick:()=>x(!1),children:"Cancel"})]})]}):null,t.jsxs("div",{className:"page-header",children:[t.jsxs("div",{className:"page-header-left",children:[t.jsx("h1",{className:"page-title",children:h.project.displayName||h.project.name}),t.jsxs("p",{className:"page-subtitle",children:[h.project.canonicalDomain,(h.project.ownedDomains??[]).length===0&&!B&&t.jsx("button",{type:"button",className:"ml-2 text-[10px] uppercase tracking-wide text-zinc-600 hover:text-zinc-400 transition-colors",onClick:()=>J(!0),children:"+ add domain"})," "," · ",h.contextLabel]}),t.jsxs("div",{className:"tag-row",children:[t.jsx("span",{className:"tag",children:h.project.country}),t.jsx("span",{className:"tag",children:h.project.language.toUpperCase()}),h.project.tags.map(F=>t.jsx("span",{className:"tag",children:F},F))]}),((h.project.ownedDomains??[]).length>0||B)&&t.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-zinc-500 mr-1",children:"Also tracking"}),(h.project.ownedDomains??[]).map(F=>t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-zinc-700/60 bg-zinc-800/40 px-2 py-0.5 text-xs text-zinc-300",children:[F,t.jsx("button",{type:"button",className:"ml-0.5 text-zinc-500 hover:text-zinc-200 transition-colors",disabled:ie,onClick:()=>{dn(F)},"aria-label":`Remove ${F}`,children:"×"})]},F)),B?t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("input",{className:"rounded border border-zinc-700 bg-transparent px-1.5 py-0.5 text-xs text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none w-40",type:"text",placeholder:"docs.example.com",value:ue,onChange:F=>P(F.target.value),onKeyDown:F=>{F.key==="Enter"&&Yn()},autoFocus:!0}),t.jsx(ee,{type:"button",size:"sm",disabled:!ue.trim()||ie,onClick:Le(Yn),children:ie?"...":"Add"}),t.jsx("button",{type:"button",className:"text-xs text-zinc-500 hover:text-zinc-300",onClick:()=>{J(!1),P("")},children:"Cancel"})]}):t.jsx("button",{type:"button",className:"rounded-full border border-dashed border-zinc-700 px-2 py-0.5 text-[10px] uppercase tracking-wide text-zinc-500 hover:text-zinc-300 hover:border-zinc-500 transition-colors",onClick:()=>J(!0),children:"+ domain"})]}),t.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] uppercase tracking-wide text-zinc-500 mr-1",children:["Also known as",t.jsx(on,{text:"Extra brand names checked against LLM answer text alongside the project name. Use for product names, prior names, or DBAs (e.g. add Meta as an alias to facebook.com). Changing these recomputes mentions on historical runs."})]}),(h.project.aliases??[]).map(F=>t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-zinc-700/60 bg-zinc-800/40 px-2 py-0.5 text-xs text-zinc-300",children:[F,t.jsx("button",{type:"button",className:"ml-0.5 text-zinc-500 hover:text-zinc-200 transition-colors",disabled:me,onClick:()=>{rs(F)},"aria-label":`Remove ${F}`,children:"×"})]},F)),ze?t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("input",{className:"rounded border border-zinc-700 bg-transparent px-1.5 py-0.5 text-xs text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none w-40",type:"text",placeholder:"LlamaParse",value:V,onChange:F=>ne(F.target.value),onKeyDown:F=>{F.key==="Enter"&&zn()},autoFocus:!0}),t.jsx(ee,{type:"button",size:"sm",disabled:!V.trim()||me,onClick:Le(zn),children:me?"...":"Add"}),t.jsx("button",{type:"button",className:"text-xs text-zinc-500 hover:text-zinc-300",onClick:()=>{ve(!1),ne("")},children:"Cancel"})]}):t.jsx("button",{type:"button",className:"rounded-full border border-dashed border-zinc-700 px-2 py-0.5 text-[10px] uppercase tracking-wide text-zinc-500 hover:text-zinc-300 hover:border-zinc-500 transition-colors",onClick:()=>ve(!0),children:"+ alias"})]})]}),t.jsxs("div",{className:"page-header-right",children:[t.jsx("p",{className:"text-sm text-zinc-500",children:h.dateRangeLabel}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ee,{type:"button",variant:"outline",size:"icon",onClick:Le(ws),"aria-label":"Export project as YAML",children:t.jsx(Eu,{className:"h-4 w-4 text-zinc-400"})}),t.jsx(ee,{type:"button",variant:"outline",size:"icon",onClick:()=>x(!0),"aria-label":"Delete project",children:t.jsx(Lv,{className:"h-4 w-4 text-zinc-400"})}),t.jsx(ee,{type:"button",disabled:Nt.isPending||pt,onClick:Le(Zt),children:Nt.isPending?"Starting…":pt?"Sweep running…":"Run now"})]})]})]}),t.jsx("nav",{className:"project-subnav","aria-label":"Project sections",children:zs.map(F=>t.jsx(ft,{to:F.href,className:`project-subnav-link ${F.key===e?"project-subnav-link-active":""}`,"aria-current":F.key===e?"page":void 0,children:F.label},F.key))}),e==="overview"?t.jsxs(t.Fragment,{children:[t.jsxs("section",{className:"aeo-hero",children:[t.jsx("p",{className:"aeo-hero-title",children:"AEO performance"}),t.jsx("div",{className:"aeo-hero-rows",children:[{key:"mention",label:"Mentioned",tooltip:"Your domain or company name was in the answer returned by the LLM.",summary:h.mentionSummary},{key:"citation",label:"Cited",tooltip:"An LLM used a page on your domain as a source for its answer.",summary:h.visibilitySummary},{key:"mention-share",label:"Mention share",tooltip:"Of all brand mentions in answer text across your tracked queries (you + tracked competitors), the % that were you. Head-to-head AI prominence, not market share.",summary:h.mentionShareSummary}].map(F=>t.jsxs("div",{className:"aeo-hero-row",children:[t.jsxs("div",{className:"aeo-hero-row-label",children:[t.jsx("span",{children:F.label}),t.jsx(on,{text:F.tooltip})]}),t.jsxs("div",{className:"aeo-hero-row-value",children:[t.jsx("span",{className:"text-zinc-50",children:F.summary.value}),Ss(F.summary.value)?t.jsx("span",{className:"text-zinc-600",children:"%"}):null]}),t.jsx("div",{className:"aeo-hero-row-bar",children:t.jsx("div",{className:`metric-card-bar-fill progress-fill-${F.summary.tone}`,style:{width:F.summary.progress!==void 0?`${Math.min(Math.max(F.summary.progress,0),100)}%`:"0%"}})}),t.jsx("div",{className:"aeo-hero-row-detail",children:F.summary.delta})]},F.key))}),t.jsx(uB,{summary:h.mentionShareSummary,projectLabel:h.project.displayName||h.project.name}),h.providerScores.length>0&&t.jsxs("p",{className:"aeo-hero-context",children:["Across ",h.providerScores.length," ",h.providerScores.length===1?"provider":"providers","."]})]}),t.jsx(cB,{summary:h.movementSummary,onJumpToEvidence:()=>document.getElementById("evidence-section")?.scrollIntoView({behavior:"smooth",block:"start"})}),t.jsxs("section",{className:"metric-grid",children:[t.jsxs("div",{className:"metric-card",children:[t.jsxs("p",{className:"metric-card-eyebrow",children:["Mention Gaps",t.jsx(on,{text:"Queries where a competitor was mentioned in the answer but your brand wasn't."})]}),t.jsxs("p",{className:"metric-card-big-value",children:[t.jsx("span",{className:"text-zinc-50",children:h.mentionGaps.value}),t.jsxs("span",{className:"text-zinc-600",children:[" / ",h.queryCounts.total]})]}),t.jsx("div",{className:"metric-card-bar",children:t.jsx("div",{className:`metric-card-bar-fill progress-fill-${h.mentionGaps.tone}`,style:{width:h.mentionGaps.progress!==void 0?`${Math.min(Math.max(h.mentionGaps.progress,0),100)}%`:"0%"}})}),t.jsx("p",{className:"metric-card-detail",children:h.mentionGaps.delta})]}),t.jsxs("div",{className:"metric-card",children:[t.jsxs("p",{className:"metric-card-eyebrow",children:["Citation Gaps",t.jsx(on,{text:"Queries where a competitor was cited as a source but you weren't."})]}),t.jsxs("p",{className:"metric-card-big-value",children:[t.jsx("span",{className:"text-zinc-50",children:h.gapQueries.value}),t.jsxs("span",{className:"text-zinc-600",children:[" / ",h.queryCounts.total]})]}),t.jsx("div",{className:"metric-card-bar",children:t.jsx("div",{className:`metric-card-bar-fill progress-fill-${h.gapQueries.tone}`,style:{width:h.gapQueries.progress!==void 0?`${Math.min(Math.max(h.gapQueries.progress,0),100)}%`:"0%"}})}),t.jsx("p",{className:"metric-card-detail",children:h.gapQueries.delta})]}),t.jsxs("div",{className:"metric-card",children:[t.jsxs("p",{className:"metric-card-eyebrow",children:["Index Coverage",t.jsx(on,{text:"Percentage of your tracked URLs that Google or Bing has indexed."})]}),t.jsxs("p",{className:"metric-card-big-value",children:[t.jsx("span",{className:"text-zinc-50",children:h.indexCoverage.value}),t.jsx("span",{className:"text-zinc-600",children:"%"})]}),t.jsx("div",{className:"metric-card-bar",children:t.jsx("div",{className:`metric-card-bar-fill progress-fill-${h.indexCoverage.tone}`,style:{width:`${Number.parseInt(h.indexCoverage.value,10)||0}%`}})}),t.jsx("p",{className:"metric-card-detail",children:h.indexCoverage.delta})]})]}),t.jsxs("section",{id:"evidence-section",className:"page-section-divider scroll-mt-24",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Answer evidence"}),t.jsx("h2",{children:"What the LLMs said"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("p",{className:"supporting-copy",children:[new Set(h.visibilityEvidence.map(F=>F.query)).size," queries tracked"]}),t.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>z(!N),children:N?"Cancel":"+ Add queries"})]})]}),N&&t.jsxs("div",{className:"mb-3 rounded-lg border border-zinc-800 bg-zinc-900/40 p-3",children:[t.jsx("textarea",{className:"w-full resize-none rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",rows:3,placeholder:"Enter queries, one per line",value:T,onChange:F=>w(F.target.value)}),t.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[t.jsxs("p",{className:"text-xs text-zinc-500",children:[T.split(`
206
- `).filter(F=>F.trim()).length," queries"]}),t.jsx(ee,{type:"button",size:"sm",disabled:!T.trim()||A,onClick:Le($t),children:A?"Adding...":"Add queries"})]})]}),h.project.locations&&h.project.locations.length>0&&t.jsxs("div",{className:"filter-row mb-3",role:"toolbar","aria-label":"Location filters",children:[t.jsx("button",{className:`filter-chip ${se===void 0?"filter-chip-active":""}`,type:"button","aria-pressed":se===void 0,onClick:()=>{pe(void 0)},children:"All locations"}),h.project.locations.map(F=>t.jsx("button",{className:`filter-chip ${se===F.label?"filter-chip-active":""}`,type:"button","aria-pressed":se===F.label,onClick:()=>{pe(F.label),X(!1)},children:F.label},F.label)),Fn&&t.jsx("button",{className:`filter-chip ${se===""?"filter-chip-active":""}`,type:"button","aria-pressed":se==="",onClick:()=>{pe(""),X(!1)},children:"No location"}),be.length>1&&se===void 0&&t.jsx("button",{className:`filter-chip filter-chip-compare ${E?"filter-chip-active":""}`,type:"button","aria-pressed":E,onClick:()=>X(F=>!F),title:"Side-by-side location comparison",children:"Compare"})]}),Y&&t.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-md border border-rose-900/40 bg-rose-950/20 px-3 py-2",children:[t.jsx("span",{className:"text-[11px] uppercase tracking-wide text-rose-400",children:"Competitor filter"}),t.jsxs("span",{className:"text-sm text-zinc-200",children:["Showing queries where ",t.jsx("span",{className:"font-semibold",children:Y})," surfaced"]}),t.jsx("button",{type:"button",className:"ml-auto text-xs text-zinc-400 hover:text-zinc-200",onClick:()=>ye(null),children:"Clear filter ×"})]}),t.jsx($M,{evidence:sn,compareLocations:E})]}),t.jsxs("section",{className:"page-section-divider",children:[t.jsx("div",{className:"section-head section-head-inline",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Opportunities"}),t.jsx("h2",{children:"What to act on next"})]})}),t.jsx(hB,{insights:h.insights,suggestedQueries:h.suggestedQueries,projectName:Ce})]}),t.jsxs("section",{className:"page-section-divider",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Competitors"}),t.jsx("h2",{children:"Competitive landscape"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("p",{className:"supporting-copy",children:[h.competitors.length," tracked"]}),t.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>I(!U),children:U?"Cancel":"+ Add competitor"})]})]}),U&&t.jsxs("div",{className:"mb-3 flex gap-2 rounded-lg border border-zinc-800 bg-zinc-900/40 p-3",children:[t.jsx("input",{className:"flex-1 rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",type:"text",placeholder:"competitor.com",value:C,onChange:F=>L(F.target.value),onKeyDown:F=>{F.key==="Enter"&&$n()}}),t.jsx(ee,{type:"button",size:"sm",disabled:!C.trim()||M,onClick:Le($n),children:M?"Adding...":"Add"})]}),t.jsx(UM,{competitors:h.competitors,onSelectCompetitor:F=>{ye(F),document.getElementById("evidence-section")?.scrollIntoView({behavior:"smooth",block:"start"})},activeFilter:Y})]}),t.jsx(z$,{projectName:h.project.name}),h.providerScores.length>1&&t.jsxs("section",{className:"page-section-divider",children:[t.jsx("div",{className:"section-head section-head-inline",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Model breakdown"}),t.jsxs("h2",{children:["Visibility by model ",t.jsx(on,{text:"Per-model citation rate today plus a sparkline of the recent run history. Same query set, different LLMs — gaps between providers point at content / source issues, not the metric."})]})]})}),t.jsx("div",{className:"evidence-table-wrap",children:t.jsxs("table",{className:"evidence-table",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"Model"}),t.jsx("th",{children:"Score"}),t.jsx("th",{children:"Trend"}),t.jsx("th",{children:"Cited queries"})]})}),t.jsx("tbody",{children:h.providerScores.map(F=>t.jsxs("tr",{children:[t.jsx("td",{children:t.jsxs("div",{className:"flex flex-col items-start gap-0.5",children:[t.jsx($i,{provider:F.provider}),F.model&&t.jsx("span",{className:"text-[11px] font-mono text-zinc-500",children:F.model})]})}),t.jsx("td",{children:t.jsxs("span",{className:`font-semibold ${F.score>=70?"text-emerald-400":F.score>=40?"text-amber-400":"text-rose-400"}`,children:[F.score,"%"]})}),t.jsx("td",{children:t.jsx(dB,{trend:F.trend,currentScore:F.score})}),t.jsxs("td",{className:"text-zinc-500",children:[F.cited," of ",F.total]})]},`${F.provider}::${F.model??"unknown"}`))})]})})]}),t.jsxs("section",{className:"page-section-divider",children:[t.jsx("div",{className:"section-head section-head-inline",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Run timeline"}),t.jsx("h2",{children:"Recent execution history"})]})}),t.jsx("div",{className:"run-list",children:h.recentRuns.map(F=>t.jsx(d1,{run:F},F.id))})]})]}):e==="settings"?t.jsxs(t.Fragment,{children:[t.jsx(nB,{project:{...h.project,displayName:h.project.displayName??h.project.name,defaultLocation:h.project.defaultLocation??null},onUpdateProject:kn,onRefresh:()=>{u()}}),t.jsx(aB,{projectName:h.project.name}),t.jsx(rB,{projectName:h.project.name})]}):e==="report"?t.jsx(I$,{projectName:h.project.name}):e==="discovery"?t.jsx(D$,{projectName:Ce}):e==="activity"?t.jsx(n$,{projectName:h.project.name}):e==="backlinks"?t.jsx(S$,{projectName:h.project.name}):t.jsx(oB,{projectName:h.project.name})]})}function pB(){const{dashboard:e,isLoading:s}=Pi(),i=h$();if(!e||s)return t.jsxs("div",{className:"page-skeleton",children:[t.jsxs("div",{className:"page-skeleton-header",children:[t.jsx("div",{className:"skeleton-text h-6 w-20"}),t.jsx("div",{className:"skeleton-text-sm w-72"})]}),t.jsx("div",{className:"space-y-2",children:[1,2,3,4].map(p=>t.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 p-3 flex items-center gap-3",children:[t.jsxs("div",{className:"flex-1 space-y-1.5",children:[t.jsx("div",{className:"skeleton-text w-40"}),t.jsx("div",{className:"skeleton-text-sm w-56"})]}),t.jsx("div",{className:"skeleton h-5 w-16 rounded-full"})]},p))})]});const r=e.runs,[o,u]=j.useState("all"),d=o==="all"?r:r.filter(p=>p.status===o),h=async()=>{try{await i.mutateAsync(void 0)}catch{}};return t.jsxs("div",{className:"page-container",children:[t.jsxs("div",{className:"page-header",children:[t.jsxs("div",{className:"page-header-left",children:[t.jsx("h1",{className:"page-title",children:"Runs"}),t.jsx("p",{className:"page-subtitle",children:"Status, type, project, duration, and the shortest explanation that makes the outcome trustworthy."})]}),t.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:i.isPending,onClick:()=>{h()},children:i.isPending?"Queueing…":"Run all projects"})]}),t.jsxs("section",{children:[t.jsx("div",{className:"filter-row",role:"toolbar","aria-label":"Run filters",children:["all","queued","running","completed","partial","failed","cancelled"].map(p=>t.jsx("button",{className:`filter-chip ${o===p?"filter-chip-active":""}`,type:"button","aria-pressed":o===p,onClick:()=>u(p),children:p==="all"?"All runs":$u(p)},p))}),t.jsx("div",{className:"run-list",children:d.length>0?d.map(p=>t.jsx(d1,{run:p},p.id)):t.jsxs(Se,{className:"surface-card empty-card",children:[t.jsx("h2",{children:"No runs match this filter"}),t.jsx("p",{children:"Try another status filter or queue a new run from a project command center."})]})})]})]})}function gB({providerName:e,keyUrl:s,modelHint:i,onSaved:r}){const o=e.toLowerCase()==="local",[u,d]=j.useState(""),[h,p]=j.useState(""),[x,b]=j.useState(""),[v,N]=j.useState(""),[z,T]=j.useState(""),[w,A]=j.useState(""),[D,U]=j.useState(!1),[I,C]=j.useState(null),[L,M]=j.useState(!1),_=o?h.trim().length>0:u.trim().length>0;async function B(){if(_){U(!0),C(null),M(!1);try{const ue=ve=>{const V=parseInt(ve.trim(),10);return Number.isFinite(V)&&V>0?V:void 0},P={},ie=ue(v);ie!==void 0&&(P.maxConcurrency=ie);const te=ue(z);te!==void 0&&(P.maxRequestsPerMinute=te);const ze=ue(w);ze!==void 0&&(P.maxRequestsPerDay=ze),await jv(e.toLowerCase(),{...u.trim()?{apiKey:u.trim()}:{},...h.trim()?{baseUrl:h.trim()}:{},...x.trim()?{model:x.trim()}:{},...Object.keys(P).length>0?{quota:P}:{}}),d(""),p(""),b(""),N(""),T(""),A(""),M(!0),Qe({title:"Provider updated",detail:`${e} configuration saved.`,tone:"positive",dedupeKey:`settings:provider:${e}`,dedupeMode:"replace"}),r()}catch(ue){C(ue instanceof Error?ue.message:"Failed to update provider")}finally{U(!1)}}}const J=i??"Use default model";return t.jsxs("div",{className:"mt-3 rounded-lg border border-zinc-800 bg-zinc-900/40 p-3 space-y-2",children:[o&&t.jsxs("div",{children:[t.jsx("label",{className:"text-xs text-zinc-500",htmlFor:`base-url-${e}`,children:"Base URL"}),t.jsx("input",{id:`base-url-${e}`,type:"text",className:"mt-0.5 w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"http://localhost:11434/v1",value:h,onChange:ue=>p(ue.target.value)}),t.jsx("p",{className:"mt-0.5 text-[10px] text-zinc-600",children:"Any OpenAI-compatible endpoint — Ollama, LM Studio, llama.cpp, vLLM"})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("label",{className:"text-xs text-zinc-500",htmlFor:`api-key-${e}`,children:["API Key",o?" (optional)":""]}),s&&t.jsxs("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-zinc-500 hover:text-zinc-300 underline underline-offset-2",children:["Get API key ","↗"]})]}),t.jsx("input",{id:`api-key-${e}`,type:"password",className:"mt-0.5 w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:o?"Optional — most local servers don't need one":`Enter ${e} API key`,value:u,onChange:ue=>d(ue.target.value)})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-xs text-zinc-500",htmlFor:`model-${e}`,children:"Model (optional)"}),t.jsx("input",{id:`model-${e}`,type:"text",className:"mt-0.5 w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:J,value:x,onChange:ue=>b(ue.target.value)})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-xs text-zinc-500",children:"Quota (optional)"}),t.jsxs("div",{className:"mt-0.5 grid grid-cols-3 gap-1.5",children:[t.jsxs("div",{children:[t.jsx("input",{type:"number",min:"1",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"Concurrent",value:v,onChange:ue=>N(ue.target.value)}),t.jsx("p",{className:"mt-0.5 text-[10px] text-zinc-600",children:"Max concurrent"})]}),t.jsxs("div",{children:[t.jsx("input",{type:"number",min:"1",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"/min",value:z,onChange:ue=>T(ue.target.value)}),t.jsx("p",{className:"mt-0.5 text-[10px] text-zinc-600",children:"Per minute"})]}),t.jsxs("div",{children:[t.jsx("input",{type:"number",min:"1",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"/day",value:w,onChange:ue=>A(ue.target.value)}),t.jsx("p",{className:"mt-0.5 text-[10px] text-zinc-600",children:"Per day"})]})]})]}),I&&t.jsx("p",{className:"text-xs text-rose-400",children:I}),L&&t.jsx("p",{className:"text-xs text-emerald-400",children:"Provider updated."}),t.jsx(ee,{type:"button",size:"sm",disabled:!_||D,onClick:Le(B),children:D?"Saving...":"Save"})]})}function xB({onSaved:e}){const[s,i]=j.useState(""),[r,o]=j.useState(""),[u,d]=j.useState(!1),[h,p]=j.useState(null),[x,b]=j.useState(!1),v=s.trim().length>0&&r.trim().length>0;async function N(){if(v){d(!0),p(null),b(!1);try{await S2({clientId:s.trim(),clientSecret:r.trim()}),i(""),o(""),b(!0),Qe({title:"Google OAuth app updated",detail:"Dashboard Google credentials were saved.",tone:"positive",dedupeKey:"settings:google-oauth",dedupeMode:"replace"}),e()}catch(z){p(z instanceof Error?z.message:"Failed to update Google OAuth credentials")}finally{d(!1)}}}return t.jsxs("div",{className:"mt-3 rounded-lg border border-zinc-800 bg-zinc-900/40 p-3 space-y-2",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"text-xs text-zinc-500",htmlFor:"google-client-id",children:"Client ID"}),t.jsxs("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-zinc-500 hover:text-zinc-300 underline underline-offset-2",children:["Google Cloud ","↗"]})]}),t.jsx("input",{id:"google-client-id",type:"text",className:"mt-0.5 w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"Google OAuth client ID",value:s,onChange:z=>i(z.target.value)})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-xs text-zinc-500",htmlFor:"google-client-secret",children:"Client secret"}),t.jsx("input",{id:"google-client-secret",type:"password",className:"mt-0.5 w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"Google OAuth client secret",value:r,onChange:z=>o(z.target.value)})]}),t.jsxs("p",{className:"text-[11px] text-zinc-500",children:["These credentials are stored in ",t.jsx("code",{children:"~/.canonry/config.yaml"}),". Project-level Search Console connections are created separately per canonical domain."]}),h&&t.jsx("p",{className:"text-xs text-rose-400",children:h}),x&&t.jsx("p",{className:"text-xs text-emerald-400",children:"Google OAuth credentials updated."}),t.jsx(ee,{type:"button",size:"sm",disabled:!v||u,onClick:Le(N),children:u?"Saving...":"Save Google OAuth app"})]})}function yB(){const[e,s]=j.useState(null),[i,r]=j.useState(null),[o,u]=j.useState(!1),[d,h]=j.useState("localhost"),[p,x]=j.useState("9222"),[b,v]=j.useState(!1);return j.useEffect(()=>{py().then(s).catch(N=>{const z=N instanceof Error?N.message:String(N);z.includes("501")||r(z)})},[]),t.jsxs(Se,{className:"surface-card",children:[t.jsxs("div",{className:"section-head",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Browser provider"}),t.jsx("h2",{children:"ChatGPT (CDP)"})]}),t.jsx(Ke,{tone:e?.connected?"positive":"caution",children:e?.connected?"Connected":"Not connected"})]}),t.jsxs("dl",{className:"definition-list mt-3",children:[e?.endpoint&&t.jsxs("div",{children:[t.jsx("dt",{children:"Endpoint"}),t.jsx("dd",{className:"font-mono text-xs",children:e.endpoint})]}),e?.browserVersion&&t.jsxs("div",{children:[t.jsx("dt",{children:"Browser"}),t.jsx("dd",{className:"text-xs",children:e.browserVersion})]}),e?.targets&&e.targets.length>0&&t.jsxs("div",{children:[t.jsx("dt",{children:"Tabs"}),t.jsx("dd",{children:e.targets.map(N=>t.jsxs("span",{className:"mr-2",children:[N.name,": ",N.alive?"● alive":"○ idle"]},N.name))})]})]}),t.jsx("p",{className:"mt-2 text-sm text-zinc-500",children:e?.connected?"Connected to Chrome via CDP. Launch Chrome with --remote-debugging-port to use this provider.":i||"Not configured. Set an endpoint below or run: canonry cdp connect --host localhost --port 9222"}),t.jsx("div",{className:"mt-2",children:t.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>u(!o),children:o?"Cancel":e?.connected?"Update endpoint":"Configure"})}),o&&t.jsxs("form",{className:"mt-3 flex flex-col gap-2",onSubmit:Le(async N=>{N.preventDefault(),v(!0);try{await H2(d,parseInt(p,10)||9222);const z=await py().catch(()=>null);z&&s(z),u(!1),Qe({title:"CDP endpoint saved",detail:`${d}:${parseInt(p,10)||9222} is now configured.`,tone:"positive",dedupeKey:"settings:cdp",dedupeMode:"replace"})}catch(z){r(z instanceof Error?z.message:String(z))}finally{v(!1)}}),children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{className:"flex-1 rounded border border-zinc-700 bg-zinc-900 px-2 py-1 text-sm text-zinc-100 placeholder-zinc-500 focus:outline-none focus:ring-1 focus:ring-zinc-500",placeholder:"localhost",value:d,onChange:N=>h(N.target.value),"aria-label":"CDP host"}),t.jsx("input",{className:"w-24 rounded border border-zinc-700 bg-zinc-900 px-2 py-1 text-sm text-zinc-100 placeholder-zinc-500 focus:outline-none focus:ring-1 focus:ring-zinc-500",placeholder:"9222",value:p,onChange:N=>x(N.target.value),"aria-label":"CDP port"})]}),t.jsx("div",{children:t.jsx(ee,{type:"submit",size:"sm",disabled:b,children:b?"Saving…":"Save endpoint"})})]})]})}const bB={apiStatus:{state:"checking",detail:"Checking service health"},workerStatus:{state:"checking",detail:"Checking service health"}};function vB(){const e=wo(),{dashboard:s}=Pi(),i=s?.settings??e?.dashboard?.settings,u=Hu(!e,e?.health).data??e?.health??bB,[d,h]=j.useState(null),[p,x]=j.useState(!1),[b,v]=j.useState(!1),[N,z]=j.useState(""),[T,w]=j.useState(!1),[A,D]=j.useState(null),[U,I]=j.useState(!1);return i?t.jsxs("div",{className:"page-container",children:[t.jsx("div",{className:"page-header",children:t.jsxs("div",{className:"page-header-left",children:[t.jsx("h1",{className:"page-title",children:"Settings"}),t.jsx("p",{className:"page-subtitle",children:"Provider state, Google OAuth, Bing WMT setup, and service health."})]})}),t.jsxs("section",{className:"settings-grid",children:[i.providerStatuses.map(C=>t.jsxs(Se,{className:"surface-card",children:[t.jsxs("div",{className:"section-head",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Provider"}),t.jsx("h2",{children:C.displayName??C.name})]}),t.jsx(Ke,{tone:C.state==="ready"?"positive":"caution",children:C.state==="ready"?"Ready":"Needs config"})]}),t.jsxs("dl",{className:"definition-list mt-3",children:[t.jsxs("div",{children:[t.jsx("dt",{children:"Model"}),t.jsx("dd",{className:"font-mono text-xs",children:C.model})]}),C.quota&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("dt",{children:"Concurrency"}),t.jsx("dd",{children:C.quota.maxConcurrency})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Rate limit"}),t.jsxs("dd",{children:[C.quota.maxRequestsPerMinute,"/min · ",C.quota.maxRequestsPerDay,"/day"]})]})]})]}),t.jsx("p",{className:"mt-2 text-sm text-zinc-500",children:C.detail}),t.jsx("div",{className:"mt-2",children:t.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>h(d===C.name?null:C.name),children:d===C.name?"Cancel":C.state==="ready"?C.name.toLowerCase()==="local"?"Update config":"Update key":"Configure"})}),d===C.name&&t.jsx(gB,{providerName:C.name,keyUrl:C.keyUrl,modelHint:C.modelHint,onSaved:()=>{h(null)}})]},C.name)),t.jsxs(Se,{className:"surface-card",children:[t.jsxs("div",{className:"section-head",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Google"}),t.jsx("h2",{children:"Search Console OAuth"})]}),t.jsx(Ke,{tone:i.google.state==="ready"?"positive":"caution",children:i.google.state==="ready"?"Ready":"Needs config"})]}),t.jsxs("dl",{className:"definition-list mt-3",children:[t.jsxs("div",{children:[t.jsx("dt",{children:"Auth model"}),t.jsx("dd",{children:"One app credential set, then one OAuth connection per project domain"})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Storage"}),t.jsx("dd",{className:"font-mono text-xs",children:"~/.canonry/config.yaml"})]})]}),t.jsx("p",{className:"mt-2 text-sm text-zinc-500",children:i.google.detail}),t.jsx("div",{className:"mt-2",children:t.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>x(!p),children:p?"Cancel":i.google.state==="ready"?"Update OAuth app":"Configure Google OAuth"})}),p&&t.jsx(xB,{onSaved:()=>{x(!1)}})]}),t.jsxs(Se,{className:"surface-card",children:[t.jsxs("div",{className:"section-head",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Bing"}),t.jsx("h2",{children:"Webmaster Tools"})]}),t.jsx(Ke,{tone:i.bing.state==="ready"?"positive":"caution",children:i.bing.state==="ready"?"Ready":"Needs config"})]}),t.jsxs("dl",{className:"definition-list mt-3",children:[t.jsxs("div",{children:[t.jsx("dt",{children:"Auth model"}),t.jsx("dd",{children:"API key authentication — no OAuth needed"})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Storage"}),t.jsx("dd",{className:"font-mono text-xs",children:"~/.canonry/config.yaml"})]})]}),t.jsx("p",{className:"mt-2 text-sm text-zinc-500",children:i.bing.detail}),t.jsx("div",{className:"mt-2",children:t.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>v(!b),children:b?"Cancel":i.bing.state==="ready"?"Update API key":"Configure Bing"})}),b&&t.jsxs("div",{className:"mt-3 rounded-lg border border-zinc-800 bg-zinc-900/40 p-3 space-y-2",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"text-xs text-zinc-500",htmlFor:"bing-api-key",children:"API Key"}),t.jsx("a",{href:"https://www.bing.com/webmasters/",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-zinc-500 hover:text-zinc-300 underline underline-offset-2",children:"Bing Webmaster Tools"})]}),t.jsx("input",{id:"bing-api-key",type:"password",className:"mt-0.5 w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"Bing Webmaster Tools API key",value:N,onChange:C=>z(C.target.value)})]}),t.jsxs("p",{className:"text-[11px] text-zinc-500",children:["This key is stored in ",t.jsx("code",{children:"~/.canonry/config.yaml"}),". Project-level Bing connections are created separately per canonical domain."]}),A&&t.jsx("p",{className:"text-xs text-rose-400",children:A}),U&&t.jsx("p",{className:"text-xs text-emerald-400",children:"Bing API key updated."}),t.jsx(ee,{type:"button",size:"sm",disabled:!N.trim()||T,onClick:Le(async()=>{if(N.trim()){w(!0),D(null),I(!1);try{await X2(N.trim()),z(""),I(!0),v(!1),Qe({title:"Bing API key updated",detail:"Dashboard Bing credentials were saved.",tone:"positive",dedupeKey:"settings:bing",dedupeMode:"replace"})}catch(C){D(C instanceof Error?C.message:"Failed to update Bing API key")}finally{w(!1)}}}),children:T?"Saving...":"Save Bing API key"})]})]}),t.jsx(yB,{}),t.jsxs(Se,{className:"surface-card",children:[t.jsx("div",{className:"section-head",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Service health"}),t.jsx("h2",{children:"API and worker"})]})}),t.jsxs("div",{className:"compact-stack",children:[t.jsxs("div",{className:"health-row",children:[t.jsxs("div",{children:[t.jsx("p",{className:"run-row-title",children:"API"}),t.jsx("p",{className:"supporting-copy",children:u.apiStatus.detail})]}),t.jsx(Ke,{tone:Su(u.apiStatus),title:ai(u.apiStatus),children:u.apiStatus.state==="ok"?"Healthy":"Attention"})]}),t.jsxs("div",{className:"health-row",children:[t.jsxs("div",{children:[t.jsx("p",{className:"run-row-title",children:"Worker"}),t.jsx("p",{className:"supporting-copy",children:u.workerStatus.detail})]}),t.jsx(Ke,{tone:Su(u.workerStatus),title:ai(u.workerStatus),children:u.workerStatus.state==="ok"?"Healthy":"Attention"})]})]})]})]}),t.jsx("section",{className:"page-section",children:t.jsxs(Se,{className:"surface-card",children:[t.jsx("div",{className:"section-head",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Self-host notes"}),t.jsx("h2",{children:"Operational guidance"})]})}),t.jsx("ul",{className:"detail-list",children:i.selfHostNotes.map(C=>t.jsx("li",{children:C},C))}),t.jsx("p",{className:"supporting-copy",children:i.bootstrapNote})]})})]}):null}const jB=[{label:"System check",description:"Verify your instance is ready"},{label:"Create project",description:"Name, domain, and locale"},{label:"Queries",description:"Add queries to track"},{label:"Competitors",description:"Add competitor domains"},{label:"Launch",description:"Start your first visibility sweep"}];function NB({current:e,labels:s}){return t.jsx("div",{className:"setup-steps",role:"list","aria-label":"Setup progress",children:s.map((i,r)=>{const o=r<e,u=r===e;return t.jsxs("div",{className:`setup-step ${o?"setup-step-done":""} ${u?"setup-step-active":""}`,role:"listitem","aria-current":u?"step":void 0,children:[t.jsx("span",{className:"setup-step-number",children:o?"✓":r+1}),t.jsx("span",{className:"setup-step-label",children:i.label})]},i.label)})})}function wB(){const e=wo(),{dashboard:s,isLoading:i,refetch:r}=Pi(),o=s??e?.dashboard;if(!o||i)return t.jsxs("div",{className:"page-skeleton",children:[t.jsxs("div",{className:"page-skeleton-header",children:[t.jsx("div",{className:"skeleton-text h-6 w-24"}),t.jsx("div",{className:"skeleton-text-sm w-80"})]}),t.jsxs("div",{className:"page-skeleton-card",children:[t.jsx("div",{className:"skeleton-text w-32"}),t.jsx("div",{className:"space-y-3 mt-3",children:[1,2,3].map(fe=>t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"space-y-1 flex-1",children:[t.jsx("div",{className:"skeleton-text w-24"}),t.jsx("div",{className:"skeleton-text-sm w-48"})]}),t.jsx("div",{className:"skeleton h-6 w-16 rounded-full"})]},fe))})]})]});const u=o.settings,p=Hu(!e,e?.health).data??e?.health??{apiStatus:{label:"API",state:"checking",detail:"Checking service health"},workerStatus:{label:"Worker",state:"checking",detail:"Checking service health"}},x=JO(o.setup,p,u),b=bo(),[v,N]=j.useState(0),[z,T]=j.useState(""),[w,A]=j.useState(""),[D,U]=j.useState(""),[I,C]=j.useState("US"),[L,M]=j.useState("en"),[_,B]=j.useState(!1),[J,ue]=j.useState(null),[P,ie]=j.useState(null),[te,ze]=j.useState(null),[ve,V]=j.useState(!1),[ne,me]=j.useState(""),[Ne,se]=j.useState(!1),[pe,E]=j.useState(null),[X,Y]=j.useState(!1),ye=u.providerStatuses.filter(fe=>fe.state==="ready"),[le,Re]=j.useState(ye[0]?.name??""),[tt,we]=j.useState(5),[Ue,Ce]=j.useState(!1),[mt,Nt]=j.useState(null),[pt,gt]=j.useState(""),[St,Fn]=j.useState(!1),[be,Ae]=j.useState(null),[sn,Zt]=j.useState(!1),[an,ws]=j.useState(!1),[$t,$n]=j.useState(!1),[Yn,dn]=j.useState(null),zn=v1(),rs=tn({...Kj({client:ae,path:{id:Yn??""}}),enabled:!!Yn,refetchInterval:({state:fe})=>{const $e=fe.data?.status;return $e==="completed"||$e==="partial"||$e==="failed"||$e==="cancelled"?!1:2e3},refetchIntervalInBackground:!0}),[kn,Ss]=j.useState(""),[zs,F]=j.useState(!1),[Pe,He]=j.useState(null),ut=z.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),ht=ne.split(`
207
- `).map(fe=>fe.trim()).filter(Boolean),ls=pt.split(`
208
- `).map(fe=>fe.trim()).filter(Boolean),ui=x.healthChecks.some(fe=>fe.id==="api"&&fe.state==="ready"),Ks=async()=>{if(!(!ut||!D)){V(!0),ze(null);try{const fe=await vo(ut,{displayName:w||z,canonicalDomain:D,country:I,language:L,autoExtractBacklinks:_});ue(ut),ie(fe.id),Qe({title:"Project created",detail:`${fe.displayName||fe.name} is ready for setup.`,tone:"positive",dedupeKey:`project:create:${fe.name}`,dedupeMode:"drop"}),await r(),N(2)}catch(fe){ze(fe instanceof Error?fe.message:"Failed to create project")}finally{V(!1)}}},ks=async()=>{if(!J)return;const fe=ht;if(fe.length!==0){Y(!0),E(null);try{await h2(J,fe),se(!0),await r(),N(3)}catch($e){E($e instanceof Error?$e.message:"Failed to save queries")}finally{Y(!1)}}},Ft=async()=>{if(!(!J||!le)){Ce(!0),Nt(null);try{const fe=await E2(J,le,tt);if(fe.queries.length>0){const $e=ne?ne.trimEnd()+`
209
- `+fe.queries.join(`
210
- `):fe.queries.join(`
211
- `);me($e)}}catch(fe){Nt(fe instanceof Error?fe.message:"Failed to generate queries")}finally{Ce(!1)}}},he=async()=>{if(!J)return;const fe=ls;if(fe.length!==0){Zt(!0),Ae(null);try{await vv(J,fe),Fn(!0),await r(),N(4)}catch($e){Ae($e instanceof Error?$e.message:"Failed to save competitors")}finally{Zt(!1)}}},qe=async()=>{const fe=kn.trim();if(fe){F(!0),He(null);try{await jv("gemini",{apiKey:fe}),Qe({title:"Gemini configured",detail:"Provider is ready — continuing setup.",tone:"positive",dedupeKey:"setup:gemini:configured",dedupeMode:"drop"}),Ss(""),await r()}catch($e){He($e instanceof Error?$e.message:"Failed to save Gemini key")}finally{F(!1)}}},De=async()=>{if(J){$n(!0);try{const fe=await zn.mutateAsync({projectName:J,projectLabel:w||z||J,sourceAction:"setup-launch"});dn(fe.id),ws(!0),await r()}catch{}finally{$n(!1)}}},Ge=()=>N(fe=>Math.max(0,fe-1)),Xe=(()=>{switch(v){case 0:return t.jsxs(Se,{className:"surface-card step-card",children:[t.jsx("div",{className:"section-head",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 1 of 5"}),t.jsx("h2",{children:"System ready"})]})}),t.jsx("p",{className:"supporting-copy",children:"Checking that your Canonry instance is configured and reachable."}),t.jsx("div",{className:"compact-stack",children:x.healthChecks.map(fe=>t.jsxs("div",{className:"health-check-row",children:[t.jsxs("div",{children:[t.jsx("p",{className:"run-row-title",children:fe.label}),t.jsx("p",{className:"supporting-copy",children:fe.detail}),fe.id==="provider"&&fe.state!=="ready"&&t.jsxs("div",{className:"mt-3 rounded-md border border-zinc-800/60 bg-zinc-900/40 p-3 space-y-2",children:[t.jsxs("p",{className:"text-xs text-zinc-400",children:["Paste a Gemini key to enable visibility checks (free at"," ",t.jsx("a",{href:"https://aistudio.google.com/apikey",target:"_blank",rel:"noreferrer",className:"text-emerald-400 hover:text-emerald-300 underline underline-offset-2",children:"aistudio.google.com"}),")."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"password",value:kn,onChange:$e=>Ss($e.target.value),placeholder:"AI... (paste here)",className:"flex-1 rounded-md border border-zinc-800 bg-zinc-950 px-2.5 py-1.5 text-sm text-zinc-100 placeholder:text-zinc-600 focus:border-zinc-600 focus:outline-none font-mono",disabled:zs}),t.jsx(ee,{type:"button",size:"sm",disabled:zs||!kn.trim(),onClick:Le(qe),children:zs?"Saving...":"Save"})]}),Pe&&t.jsx("p",{className:"text-xs text-rose-400",children:Pe}),t.jsxs("p",{className:"text-[11px] text-zinc-600",children:["Other providers (OpenAI, Claude, Perplexity) configurable later via"," ",t.jsx(ft,{to:"/settings",className:"text-zinc-500 hover:text-zinc-300 underline underline-offset-2",children:"/settings"}),"."]})]})]}),t.jsx(Ke,{tone:fe.state==="ready"?"positive":"caution",title:fe.id==="api"?ai(p.apiStatus):fe.id==="worker"?ai(p.workerStatus):fe.detail,children:fe.state==="ready"?"Ready":"Attention"})]},fe.id))}),t.jsxs("div",{className:"setup-nav",children:[t.jsx("span",{}),t.jsx(ee,{type:"button",disabled:!ui,onClick:()=>N(1),children:"Continue"})]})]});case 1:return t.jsxs(Se,{className:"surface-card step-card",children:[t.jsxs("div",{className:"section-head",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 2 of 5"}),t.jsx("h2",{children:"Create project"})]}),J?t.jsx(Ke,{tone:"positive",children:"Created"}):null]}),J?t.jsxs("div",{className:"compact-stack",children:[t.jsxs("p",{className:"text-zinc-300",children:["Project ",t.jsx("span",{className:"text-zinc-100 font-medium",children:J})," created successfully."]}),t.jsxs("div",{className:"setup-nav",children:[t.jsx(ee,{type:"button",variant:"outline",onClick:Ge,children:"Back"}),t.jsx(ee,{type:"button",onClick:()=>N(2),children:"Continue"})]})]}):t.jsxs("div",{className:"compact-stack",children:[t.jsxs("div",{className:"setup-field",children:[t.jsx("label",{className:"setup-label",htmlFor:"project-name",children:"Project name"}),t.jsx("input",{id:"project-name",className:"setup-input",type:"text",placeholder:"my-website",value:z,onChange:fe=>T(fe.target.value)}),ut&&ut!==z?t.jsxs("p",{className:"supporting-copy",children:["Slug: ",ut]}):null]}),t.jsxs("div",{className:"setup-field",children:[t.jsx("label",{className:"setup-label",htmlFor:"display-name",children:"Display name (optional)"}),t.jsx("input",{id:"display-name",className:"setup-input",type:"text",placeholder:"My Website",value:w,onChange:fe=>A(fe.target.value)})]}),t.jsxs("div",{className:"setup-field",children:[t.jsx("label",{className:"setup-label",htmlFor:"domain",children:"Canonical domain"}),t.jsx("input",{id:"domain",className:"setup-input",type:"text",placeholder:"example.com",value:D,onChange:fe=>U(fe.target.value)})]}),t.jsxs("div",{className:"setup-field-row",children:[t.jsxs("div",{className:"setup-field",children:[t.jsx("label",{className:"setup-label",htmlFor:"country",children:"Country"}),t.jsx("input",{id:"country",className:"setup-input",type:"text",placeholder:"US",maxLength:2,value:I,onChange:fe=>C(fe.target.value.toUpperCase())})]}),t.jsxs("div",{className:"setup-field",children:[t.jsx("label",{className:"setup-label",htmlFor:"language",children:"Language"}),t.jsx("input",{id:"language",className:"setup-input",type:"text",placeholder:"en",maxLength:5,value:L,onChange:fe=>M(fe.target.value.toLowerCase())})]})]}),t.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-zinc-800/60 bg-zinc-900/30 p-3 cursor-pointer hover:border-zinc-700",children:[t.jsx("input",{type:"checkbox",className:"mt-0.5 h-4 w-4 rounded border-zinc-700 bg-zinc-950",checked:_,onChange:fe=>B(fe.target.checked)}),t.jsxs("span",{className:"flex-1",children:[t.jsx("span",{className:"block text-sm text-zinc-100",children:"Auto-extract backlinks"}),t.jsxs("span",{className:"block text-xs text-zinc-500 mt-0.5",children:["When a new Common Crawl release syncs, automatically extract backlinks for this project."," ",t.jsx(ft,{to:"/backlinks",className:"text-emerald-400 hover:text-emerald-300 underline underline-offset-2",children:"Manage backlinks"})]})]})]}),te?t.jsx("p",{className:"text-rose-400 text-sm",children:te}):null,t.jsxs("div",{className:"setup-nav",children:[t.jsx(ee,{type:"button",variant:"outline",onClick:Ge,children:"Back"}),t.jsx(ee,{type:"button",disabled:!ut||!D||ve,onClick:Le(Ks),children:ve?"Creating...":"Create project"})]})]})]});case 2:return t.jsxs(Se,{className:"surface-card step-card",children:[t.jsxs("div",{className:"section-head",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 3 of 5"}),t.jsx("h2",{children:"Add queries"})]}),Ne?t.jsxs(Ke,{tone:"positive",children:[ht.length," saved"]}):t.jsxs(Ke,{tone:"neutral",children:[ht.length," quer",ht.length!==1?"ies":"y"]})]}),t.jsx("p",{className:"supporting-copy",children:"Enter the search queries you want to track. One per line."}),Ne?t.jsxs("div",{className:"compact-stack",children:[t.jsx("ul",{className:"detail-list",children:ht.map(fe=>t.jsx("li",{children:fe},fe))}),t.jsxs("div",{className:"setup-nav",children:[t.jsx(ee,{type:"button",variant:"outline",onClick:Ge,children:"Back"}),t.jsx(ee,{type:"button",onClick:()=>N(3),children:"Continue"})]})]}):t.jsxs("div",{className:"compact-stack",children:[ye.length>0?t.jsxs("div",{className:"compact-stack",children:[t.jsxs("div",{className:"flex items-center gap-2 text-zinc-500 text-xs uppercase tracking-wide",children:[t.jsx("span",{className:"flex-1 border-t border-zinc-800"}),"auto-generate",t.jsx("span",{className:"flex-1 border-t border-zinc-800"})]}),t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsxs("div",{className:"setup-field flex-1",children:[t.jsx("label",{className:"setup-label",htmlFor:"gen-provider",children:"Provider"}),t.jsx("select",{id:"gen-provider",className:"setup-input",value:le,onChange:fe=>Re(fe.target.value),children:ye.map(fe=>t.jsxs("option",{value:fe.name,children:[fe.displayName??fe.name,fe.model?` (${fe.model})`:""]},fe.name))})]}),t.jsxs("div",{className:"setup-field",children:[t.jsx("label",{className:"setup-label",htmlFor:"gen-count",children:"Count"}),t.jsx("select",{id:"gen-count",className:"setup-input",value:tt,onChange:fe=>we(Number(fe.target.value)),children:[3,5,10,15,20].map(fe=>t.jsx("option",{value:fe,children:fe},fe))})]}),t.jsx(ee,{type:"button",variant:"outline",disabled:Ue||!le,onClick:Le(Ft),children:Ue?"Analyzing site...":"Generate"})]}),mt?t.jsx("p",{className:"text-rose-400 text-sm",children:mt}):null]}):null,t.jsxs("div",{className:"flex items-center gap-2 text-zinc-500 text-xs uppercase tracking-wide",children:[t.jsx("span",{className:"flex-1 border-t border-zinc-800"}),"or type manually",t.jsx("span",{className:"flex-1 border-t border-zinc-800"})]}),t.jsxs("div",{className:"setup-field",children:[t.jsx("label",{className:"setup-label",htmlFor:"queries",children:"Queries (one per line)"}),t.jsx("textarea",{id:"queries",className:"setup-textarea",rows:6,placeholder:`emergency dentist brooklyn
212
- best invisalign downtown brooklyn
213
- pediatric dentist brooklyn heights`,value:ne,onChange:fe=>me(fe.target.value)})]}),pe?t.jsx("p",{className:"text-rose-400 text-sm",children:pe}):null,t.jsxs("div",{className:"setup-nav",children:[t.jsx(ee,{type:"button",variant:"outline",onClick:Ge,children:"Back"}),t.jsx(ee,{type:"button",disabled:ht.length===0||X,onClick:Le(ks),children:X?"Saving...":`Save ${ht.length} quer${ht.length!==1?"ies":"y"}`})]})]})]});case 3:return t.jsxs(Se,{className:"surface-card step-card",children:[t.jsxs("div",{className:"section-head",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 4 of 5"}),t.jsx("h2",{children:"Add competitors"})]}),St?t.jsx(Ke,{tone:"positive",children:"Saved"}):null]}),t.jsx("p",{className:"supporting-copy",children:"Domains that compete for the same queries. One per line."}),St?t.jsxs("div",{className:"compact-stack",children:[t.jsx("ul",{className:"detail-list",children:ls.map(fe=>t.jsx("li",{children:fe},fe))}),t.jsxs("div",{className:"setup-nav",children:[t.jsx(ee,{type:"button",variant:"outline",onClick:Ge,children:"Back"}),t.jsx(ee,{type:"button",onClick:()=>N(4),children:"Continue"})]})]}):t.jsxs("div",{className:"compact-stack",children:[t.jsxs("div",{className:"setup-field",children:[t.jsx("label",{className:"setup-label",htmlFor:"competitors",children:"Competitor domains (one per line)"}),t.jsx("textarea",{id:"competitors",className:"setup-textarea",rows:4,placeholder:`competitor1.com
214
- competitor2.com`,value:pt,onChange:fe=>gt(fe.target.value)})]}),be?t.jsx("p",{className:"text-rose-400 text-sm",children:be}):null,t.jsxs("div",{className:"setup-nav",children:[t.jsx(ee,{type:"button",variant:"outline",onClick:Ge,children:"Back"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(ee,{type:"button",variant:"outline",onClick:()=>N(4),children:"Skip"}),t.jsx(ee,{type:"button",disabled:ls.length===0||sn,onClick:Le(he),children:sn?"Saving...":`Save ${ls.length} competitor${ls.length!==1?"s":""}`})]})]})]})]});case 4:{const fe=rs.data,$e=fe?.status==="completed"||fe?.status==="partial"||fe?.status==="failed"||fe?.status==="cancelled",We=fe?.snapshots??[],Cs=We.filter(Bn=>Bn.citationState==="cited").length,As=We.filter(Bn=>Bn.answerMentioned===!0).length,mn=new Set(We.map(Bn=>Bn.query).filter(Bn=>!!Bn)).size,Qs=an?$e&&(fe?.status==="completed"||fe?.status==="partial")?t.jsx(Ke,{tone:"positive",children:"Complete"}):$e?t.jsx(Ke,{tone:"negative",children:"Failed"}):t.jsx(Ke,{tone:"caution",children:"Running"}):null;return t.jsxs(Se,{className:"surface-card step-card",children:[t.jsxs("div",{className:"section-head",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 5 of 5"}),t.jsx("h2",{children:"Launch first run"})]}),Qs]}),an?$e?fe?.status==="failed"?t.jsxs("div",{className:"compact-stack",children:[t.jsx("p",{className:"text-rose-400",children:"Sweep failed. Inspect the run on the project page for the provider error and retry from there."}),t.jsxs("div",{className:"setup-nav",children:[t.jsx("span",{}),t.jsx(ee,{type:"button",onClick:()=>{b({to:P?`/projects/${P}`:"/"})},children:"Open project"})]})]}):t.jsxs("div",{className:"compact-stack",children:[t.jsxs("p",{className:"text-zinc-300",children:["Sweep complete. Your first answer-visibility snapshot for"," ",t.jsx("span",{className:"text-zinc-100 font-medium",children:J}),":"]}),t.jsxs("div",{className:"grid grid-cols-3 gap-2 mt-1",children:[t.jsxs("div",{className:"rounded-md border border-zinc-800/60 bg-zinc-900/30 p-3",children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Mentioned"}),t.jsxs("p",{className:"text-2xl font-bold tabular-nums text-zinc-50 mt-1",children:[As,t.jsxs("span",{className:"text-zinc-600 text-lg",children:[" / ",mn]})]}),t.jsx("p",{className:"text-[11px] text-zinc-500 mt-0.5",children:"queries with brand in answer"})]}),t.jsxs("div",{className:"rounded-md border border-zinc-800/60 bg-zinc-900/30 p-3",children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Cited"}),t.jsxs("p",{className:"text-2xl font-bold tabular-nums text-zinc-50 mt-1",children:[Cs,t.jsxs("span",{className:"text-zinc-600 text-lg",children:[" / ",mn]})]}),t.jsx("p",{className:"text-[11px] text-zinc-500 mt-0.5",children:"queries with domain in sources"})]}),t.jsxs("div",{className:"rounded-md border border-zinc-800/60 bg-zinc-900/30 p-3",children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Snapshots"}),t.jsx("p",{className:"text-2xl font-bold tabular-nums text-zinc-50 mt-1",children:We.length}),t.jsx("p",{className:"text-[11px] text-zinc-500 mt-0.5",children:"total (query × provider)"})]})]}),t.jsx("p",{className:"text-[11px] text-zinc-500 mt-1",children:"Full evidence, per-provider breakdown, and suggested next queries on the project dashboard."}),t.jsxs("div",{className:"setup-nav",children:[t.jsx("span",{}),t.jsx(ee,{type:"button",onClick:()=>{b({to:P?`/projects/${P}`:"/"})},children:"Open project dashboard →"})]})]}):t.jsxs("div",{className:"compact-stack",children:[t.jsx("p",{className:"text-zinc-300",children:"Sweep running — typically 30-60s. Polling every 2s…"}),t.jsx("div",{className:"rounded-md border border-zinc-800/60 bg-zinc-900/30 p-3 text-xs text-zinc-500",children:t.jsxs("p",{children:["Status: ",t.jsx("span",{className:"text-zinc-300",children:fe?.status??"queued"})]})}),t.jsxs("div",{className:"setup-nav",children:[t.jsx("span",{}),t.jsx(ee,{type:"button",variant:"outline",onClick:()=>{b({to:P?`/projects/${P}`:"/"})},children:"Watch on project page"})]})]}):t.jsxs("div",{className:"compact-stack",children:[t.jsxs("p",{className:"supporting-copy",children:["Everything is configured. Launch an answer-visibility sweep to start tracking citations for ",t.jsx("span",{className:"text-zinc-100 font-medium",children:J}),"."]}),t.jsxs("div",{className:"setup-nav",children:[t.jsx(ee,{type:"button",variant:"outline",onClick:Ge,children:"Back"}),t.jsx(ee,{type:"button",disabled:$t,onClick:Le(De),children:$t?"Launching...":"Launch visibility sweep"})]})]})]})}default:return null}})();return t.jsxs("div",{className:"page-container",children:[t.jsx("div",{className:"page-header",children:t.jsxs("div",{className:"page-header-left",children:[t.jsx("h1",{className:"page-title",children:"Setup"}),t.jsx("p",{className:"page-subtitle",children:"Create a project, add queries, add competitors, and launch the first run."})]})}),t.jsx(NB,{current:v,labels:jB}),t.jsx("section",{className:"setup-wizard",children:Xe})]})}function _r({children:e,label:s="More info",placement:i="top",className:r}){const o=j.useId(),[u,d]=j.useState(!1);return t.jsxs("span",{className:`relative inline-flex ${r??""}`,children:[t.jsx("button",{type:"button","aria-label":s,"aria-describedby":u?o:void 0,className:"inline-flex h-4 w-4 items-center justify-center rounded-full text-zinc-500 hover:text-zinc-200 focus:text-zinc-200 focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-500",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onFocus:()=>d(!0),onBlur:()=>d(!1),children:t.jsx(_v,{className:"h-3.5 w-3.5","aria-hidden":!0})}),u&&t.jsx("span",{id:o,role:"tooltip",className:`absolute z-50 w-64 rounded border border-zinc-700 bg-zinc-900 px-3 py-2 text-xs font-normal leading-relaxed text-zinc-200 shadow-lg ${i==="top"?"bottom-full mb-2":"top-full mt-2"} left-1/2 -translate-x-1/2 whitespace-normal`,children:e})]})}const SB="https://commoncrawl.org/web-graphs";function $h(e){return e==null?"—":e>=1e12?`${(e/1e12).toFixed(1)} TB`:e>=1e9?`${(e/1e9).toFixed(1)} GB`:e>=1e6?`${(e/1e6).toFixed(1)} MB`:e>=1e3?`${(e/1e3).toFixed(1)} KB`:`${e} B`}function nu(e){if(!e)return"—";const s=Date.now()-new Date(e).getTime(),i=Math.floor(s/6e4);if(i<1)return"just now";if(i<60)return`${i}m ago`;const r=Math.floor(i/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Bh(e){switch(e){case"ready":return"positive";case"failed":return"negative";case"downloading":case"querying":case"queued":return"caution"}}function zB(){const[e,s]=j.useState(null),[i,r]=j.useState(null),[o,u]=j.useState([]),[d,h]=j.useState([]),[p,x]=j.useState(null),[b,v]=j.useState(!0),[N,z]=j.useState(!1),[T,w]=j.useState(!1),[A,D]=j.useState(""),[U,I]=j.useState(!1),[C,L]=j.useState(null),[M,_]=j.useState(null),B=j.useCallback(async()=>{v(!0),L(null);try{const[te,ze,ve,V,ne]=await Promise.all([cC(),zv().catch(()=>null),dC().catch(()=>[]),hC().catch(()=>[]),fC().catch(()=>null)]);s(te),r(ze),u(ve),h(V),x(ne)}catch(te){L(te instanceof Error?te.message:"Failed to load backlinks status")}finally{v(!1)}},[]);j.useEffect(()=>{B()},[B]);async function J(){z(!0),L(null),_(null);try{const te=await uC();_(te.alreadyPresent?`DuckDB already installed (${te.version}).`:`Installed DuckDB ${te.version}.`),await B()}catch(te){L(te instanceof Error?te.message:"Failed to install DuckDB")}finally{z(!1)}}async function ue(){const te=A.trim()||void 0;w(!0),L(null),_(null);try{const ze=await mC(te);_(te?`Queued sync for ${ze.release}. Download + query runs in the background.`:`Queued sync for auto-discovered release ${ze.release}. Download + query runs in the background.`),D(""),I(!1),await B()}catch(ze){ze instanceof un&&ze.code==="MISSING_DEPENDENCY"?L("DuckDB is not installed. Install it first."):L(ze instanceof Error?ze.message:"Failed to trigger sync")}finally{w(!1)}}async function P(te){L(null),_(null);try{await pC(te),_(`Pruned cached release ${te}.`),await B()}catch(ze){L(ze instanceof Error?ze.message:"Failed to prune release")}}const ie=i?.status==="ready"&&d.every(te=>te.release!==i.release);return t.jsxs("div",{className:"page-container",children:[t.jsx("div",{className:"page-header",children:t.jsxs("div",{className:"page-header-left",children:[t.jsx("h1",{className:"page-title",children:"Backlinks"}),t.jsx("p",{className:"page-subtitle",children:"Find domains that link to your projects, computed from the open Common Crawl web graph. Runs entirely on your machine — nothing is sent to third parties."})]})}),t.jsx(Se,{className:"surface-card p-4 mb-6 border-amber-800/60",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(gu,{className:"h-5 w-5 text-amber-400 shrink-0 mt-0.5","aria-hidden":!0}),t.jsxs("div",{className:"text-sm text-zinc-300 leading-relaxed",children:[t.jsx("p",{className:"font-medium text-amber-200",children:"Heads up — a release sync is a large download."}),t.jsxs("ul",{className:"mt-1.5 space-y-1 text-zinc-400",children:[t.jsxs("li",{children:[t.jsx("span",{className:"text-zinc-200",children:"~16 GB"})," of gzipped vertex + edge files per release, stored at"," ",t.jsx("code",{className:"text-zinc-300",children:"~/.canonry/cache/commoncrawl/"}),"."]}),t.jsxs("li",{children:[t.jsx("span",{className:"text-zinc-200",children:"10–20 min on a fast connection"})," for the download, then ~5 min for the DuckDB query."]}),t.jsx("li",{children:"One sync covers every project in this workspace. Releases are immutable, so the download only happens once per release."})]})]})]})}),t.jsxs("section",{className:"page-section-divider",children:[t.jsx("div",{className:"section-head section-head-inline",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"About"}),t.jsx("h2",{children:"How it works"})]})}),t.jsxs(Se,{className:"surface-card p-5",children:[t.jsxs("p",{className:"text-sm text-zinc-400 leading-relaxed max-w-3xl mb-4",children:["Common Crawl publishes a quarterly snapshot of the public web’s hyperlink graph. Canonry downloads one"," ",t.jsx("span",{className:"text-zinc-200",children:"release"})," at a time and extracts backlinks for every project in this workspace in a single pass."]}),t.jsxs("ol",{className:"space-y-3 text-sm text-zinc-400 max-w-3xl",children:[t.jsxs("li",{className:"flex gap-3",children:[t.jsx("span",{className:"shrink-0 inline-flex h-6 w-6 items-center justify-center rounded-full border border-zinc-700 bg-zinc-900 text-xs font-semibold text-zinc-300 tabular-nums",children:"1"}),t.jsxs("span",{children:[t.jsx("span",{className:"text-zinc-200 font-medium",children:"Download (one-time, ~16 GB)"})," — vertex + edge files cached to"," ",t.jsx("code",{className:"text-zinc-300",children:"~/.canonry/cache/commoncrawl/"}),". Runs once per release; subsequent operations reuse the cache."]})]}),t.jsxs("li",{className:"flex gap-3",children:[t.jsx("span",{className:"shrink-0 inline-flex h-6 w-6 items-center justify-center rounded-full border border-zinc-700 bg-zinc-900 text-xs font-semibold text-zinc-300 tabular-nums",children:"2"}),t.jsxs("span",{children:[t.jsx("span",{className:"text-zinc-200 font-medium",children:"Query (~5 min)"})," — one DuckDB pass scans the cached files and extracts referring domains for every project’s canonical domain. DuckDB is only used to ",t.jsx("span",{className:"text-zinc-200",children:"read"})," these dumps; it doesn’t store any canonry state."]})]}),t.jsxs("li",{className:"flex gap-3",children:[t.jsx("span",{className:"shrink-0 inline-flex h-6 w-6 items-center justify-center rounded-full border border-zinc-700 bg-zinc-900 text-xs font-semibold text-zinc-300 tabular-nums",children:"3"}),t.jsxs("span",{children:[t.jsx("span",{className:"text-zinc-200 font-medium",children:"Persist"})," — results land in the same SQLite database the rest of canonry uses. After the first sync, per-project reads (and re-run extracts against the cached release) are instant."]})]})]})]})]}),C&&t.jsx(Se,{className:"surface-card p-4 mb-4 border-rose-800/60",children:t.jsx("p",{className:"text-sm text-rose-300",children:C})}),M&&t.jsx(Se,{className:"surface-card p-4 mb-4 border-emerald-800/60",children:t.jsx("p",{className:"text-sm text-emerald-300",children:M})}),t.jsxs("section",{className:"page-section-divider",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dependency"}),t.jsxs("h2",{className:"flex items-center gap-2",children:["DuckDB install status",t.jsxs(_r,{label:"Why DuckDB?",children:[t.jsx("span",{className:"block",children:"DuckDB is a query engine canonry uses to scan the ~16 GB Common Crawl dumps and pull out your referring domains."}),t.jsxs("span",{className:"mt-2 block text-zinc-400",children:["It does ",t.jsx("span",{className:"text-zinc-200",children:"not"})," store any canonry data — your backlink results live in SQLite alongside the rest of your projects. DuckDB is purely a tool for processing the raw CSV files."]}),t.jsxs("span",{className:"mt-2 block text-zinc-500",children:["Installed on demand (not bundled) into ",t.jsx("code",{className:"text-zinc-300",children:"~/.canonry/plugins/"})," so users who never run backlinks don’t pay the ~40 MB install cost."]})]})]})]}),e?.duckdbInstalled?t.jsx(Ke,{tone:"positive",children:"Installed"}):t.jsx(Ke,{tone:"caution",children:"Not installed"})]}),t.jsx(Se,{className:"surface-card p-5",children:b?t.jsx("p",{className:"text-sm text-zinc-500",children:"Checking…"}):e?.duckdbInstalled?t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(zf,{className:"h-5 w-5 text-emerald-400 shrink-0 mt-0.5","aria-hidden":!0}),t.jsxs("div",{children:[t.jsxs("p",{className:"text-sm text-zinc-200",children:["Version ",e.duckdbVersion??"unknown"," installed at"," ",t.jsx("code",{className:"text-zinc-300",children:e.pluginDir})]}),t.jsxs("p",{className:"text-xs text-zinc-500 mt-1",children:["Required spec: ",e.duckdbSpec]})]})]}):t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(HC,{className:"h-5 w-5 text-amber-400 shrink-0 mt-0.5","aria-hidden":!0}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm text-zinc-200",children:"DuckDB is not installed. It’s the query engine canonry uses to scan Common Crawl dumps — required before you can run a release sync or per-project extract."}),t.jsx("p",{className:"text-xs text-zinc-500 mt-1",children:"Installing doesn’t touch your project data. DuckDB only reads the downloaded CSV files; backlink results are written to the same SQLite database canonry already uses."}),e&&t.jsxs("p",{className:"text-xs text-zinc-500 mt-1",children:["Will be installed into ",t.jsx("code",{className:"text-zinc-300",children:e.pluginDir})," (~40 MB)."]}),t.jsx("div",{className:"mt-3",children:t.jsxs(ee,{type:"button",size:"sm",disabled:N,onClick:Le(J),children:[t.jsx(Eu,{className:"h-4 w-4 mr-1.5","aria-hidden":!0}),N?"Installing…":"Install DuckDB"]})})]})]})})]}),t.jsxs("section",{className:"page-section-divider",children:[t.jsxs("div",{className:"section-head section-head-inline",children:[t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Latest sync"}),t.jsxs("h2",{className:"flex items-center gap-2",children:["Release sync",t.jsx(_r,{label:"What is a release sync?",children:"A release sync downloads one Common Crawl dump (~16 GB) and extracts backlinks for every project in this workspace in one pass. This is the heavy job — subsequent per-project re-runs skip the download and just re-query the cached files."})]})]}),i&&t.jsx(Ke,{tone:Bh(i.status),children:i.status})]}),t.jsxs(Se,{className:"surface-card p-5",children:[t.jsxs("p",{className:"text-xs text-zinc-500 max-w-3xl mb-4",children:["A release is one Common Crawl dump (e.g. ",t.jsx("code",{className:"text-zinc-400",children:"cc-main-2026-jan-feb-mar"}),"). Syncing it downloads the graph and populates backlinks for every project in this workspace."]}),i?t.jsxs("div",{className:"space-y-2 text-sm",children:[t.jsxs("p",{className:"text-zinc-200",children:["Release ",t.jsx("code",{className:"text-zinc-300",children:i.release})]}),i.phaseDetail&&t.jsx("p",{className:"text-zinc-500",children:i.phaseDetail}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-xs text-zinc-500 pt-2",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-zinc-600 uppercase tracking-wide",children:"Projects"}),t.jsx("p",{className:"text-zinc-300 mt-0.5",children:i.projectsProcessed??"—"})]}),t.jsxs("div",{children:[t.jsxs("p",{className:"text-zinc-600 uppercase tracking-wide flex items-center gap-1",children:["Rows",t.jsx(_r,{label:"What are rows?",children:"Total number of (project, referring domain) pairs persisted in SQLite from this sync, across every project in the workspace."})]}),t.jsx("p",{className:"text-zinc-300 mt-0.5",children:i.domainsDiscovered??"—"})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-zinc-600 uppercase tracking-wide",children:"Started"}),t.jsx("p",{className:"text-zinc-300 mt-0.5",children:nu(i.downloadStartedAt??i.createdAt)})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-zinc-600 uppercase tracking-wide",children:"Finished"}),t.jsx("p",{className:"text-zinc-300 mt-0.5",children:nu(i.queryFinishedAt)})]})]}),i.error&&t.jsx("p",{className:"text-sm text-rose-400 pt-2",children:i.error})]}):t.jsx("p",{className:"text-sm text-zinc-500",children:"No release sync has run in this workspace yet."}),ie&&t.jsx("div",{className:"mt-4 rounded border border-amber-800/60 bg-amber-950/20 p-3",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(gu,{className:"h-4 w-4 text-amber-400 shrink-0 mt-0.5","aria-hidden":!0}),t.jsxs("div",{className:"text-xs text-zinc-300 leading-relaxed",children:[t.jsx("p",{className:"font-medium text-amber-200",children:"Cached files for this release are missing."}),t.jsxs("p",{className:"mt-1 text-zinc-400",children:["The sync record in the database says this release finished successfully, but the ~16 GB dump at"," ",t.jsxs("code",{className:"text-zinc-300",children:["~/.canonry/cache/commoncrawl/",i?.release,"/"]})," isn’t on disk. Your backlink data is still intact (it lives in SQLite), but per-project re-run extracts will fail until you either re-sync this release or start a new one."]})]})]})}),t.jsxs("div",{className:"mt-4 rounded border border-zinc-800 bg-zinc-900/40 p-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Auto-detected release"}),p?t.jsxs("p",{className:"text-sm text-zinc-200 mt-0.5",children:[t.jsx("code",{className:"text-zinc-100",children:p.release}),t.jsxs("span",{className:"ml-2 text-xs text-zinc-500",children:["— vertex ",$h(p.vertexBytes),", edges ",$h(p.edgesBytes)]})]}):t.jsx("p",{className:"text-sm text-zinc-500 mt-0.5",children:b?"Probing Common Crawl…":"Could not auto-detect — pass an explicit release below."}),t.jsxs("a",{href:SB,target:"_blank",rel:"noopener noreferrer",className:"mt-1 inline-flex items-center gap-1 text-xs text-zinc-400 hover:text-zinc-200 focus:text-zinc-200 focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-500 rounded",children:["Browse all Common Crawl web-graph releases",t.jsx(eA,{className:"h-3 w-3","aria-hidden":!0})]})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t.jsxs(ee,{type:"button",size:"sm",disabled:T||!e?.duckdbInstalled||!p&&!A.trim(),onClick:Le(ue),children:[t.jsx(uo,{className:"h-4 w-4 mr-1.5","aria-hidden":!0}),T?"Queuing…":"Run sync"]}),t.jsxs(_r,{label:"What does Run sync do?",children:[t.jsxs("span",{className:"block",children:["Downloads the auto-detected (or chosen) Common Crawl release (~16 GB) to"," ",t.jsx("code",{className:"text-zinc-300",children:"~/.canonry/cache/commoncrawl/"}),", then runs a single DuckDB query that extracts referring domains for every project in this workspace."]}),t.jsxs("span",{className:"mt-2 block text-zinc-400",children:["First time for a release: ",t.jsx("span",{className:"text-zinc-200",children:"~10–20 min download + ~5 min query"}),". Re-running the same release later: ",t.jsx("span",{className:"text-zinc-200",children:"skips download, just re-queries"})," (~5 min)."]})]})]})]}),U?t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("input",{type:"text",className:"flex-1 min-w-[240px] rounded border border-zinc-700 bg-transparent px-2.5 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"cc-main-2026-jan-feb-mar",value:A,onChange:te=>D(te.target.value),disabled:T,autoFocus:!0}),t.jsx("button",{type:"button",className:"text-xs text-zinc-500 hover:text-zinc-300 focus:text-zinc-300 focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-500 rounded",onClick:()=>{D(""),I(!1)},disabled:T,children:"Cancel"})]}):t.jsx("button",{type:"button",className:"text-xs text-zinc-500 hover:text-zinc-300 focus:text-zinc-300 focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-500 rounded",onClick:()=>I(!0),disabled:T,children:"Use a different release →"})]}),!e?.duckdbInstalled&&t.jsx("p",{className:"text-xs text-zinc-600 mt-2",children:"Install DuckDB first to enable sync."})]})]}),t.jsxs("section",{className:"page-section-divider",children:[t.jsx("div",{className:"section-head section-head-inline",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Cached releases"}),t.jsxs("h2",{className:"flex items-center gap-2",children:["Local disk cache",t.jsxs(_r,{label:"What is this?",children:[t.jsxs("span",{className:"block",children:["Raw Common Crawl dumps stored at"," ",t.jsx("code",{className:"text-zinc-300",children:"~/.canonry/cache/commoncrawl/<release>/"}),". Each release takes ~16 GB."]}),t.jsxs("span",{className:"mt-2 block text-zinc-400",children:["These files are needed to re-run per-project extracts against a release without re-downloading. Pruning here ",t.jsx("span",{className:"text-zinc-200",children:"does not delete your backlink data"})," — that lives in SQLite."]})]})]})]})}),t.jsx("p",{className:"text-xs text-zinc-500 mb-3 max-w-3xl",children:"Each cached release is a ~16 GB pair of gzipped files. They’re needed to re-query the graph (e.g. for a newly-added project) without re-downloading. Safe to prune — backlink results persist in SQLite."}),t.jsx(Se,{className:"surface-card overflow-hidden",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-zinc-800 text-left text-xs uppercase tracking-wide text-zinc-600",children:[t.jsx("th",{className:"px-4 py-2 font-medium",children:"Release"}),t.jsx("th",{className:"px-4 py-2 font-medium",children:"Sync status"}),t.jsx("th",{className:"px-4 py-2 text-right font-medium",children:"Size"}),t.jsx("th",{className:"px-4 py-2 font-medium",children:"Last used"}),t.jsx("th",{className:"px-4 py-2 font-medium sr-only",children:"Actions"})]})}),t.jsxs("tbody",{children:[d.map(te=>t.jsxs("tr",{className:"border-b border-zinc-900 last:border-0",children:[t.jsx("td",{className:"px-4 py-2 text-zinc-200",children:t.jsx("code",{children:te.release})}),t.jsx("td",{className:"px-4 py-2",children:te.syncStatus?t.jsx(Ke,{tone:Bh(te.syncStatus),children:te.syncStatus}):t.jsx("span",{className:"text-zinc-600",children:"—"})}),t.jsx("td",{className:"px-4 py-2 text-right text-zinc-400 tabular-nums",children:$h(te.bytes)}),t.jsx("td",{className:"px-4 py-2 text-zinc-400",children:nu(te.lastUsedAt)}),t.jsx("td",{className:"px-4 py-2 text-right",children:t.jsxs("div",{className:"inline-flex items-center gap-1",children:[t.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>{P(te.release)},children:[t.jsx(Lv,{className:"h-4 w-4 mr-1.5","aria-hidden":!0}),"Prune"]}),t.jsx(_r,{label:"What does Prune do?",placement:"top",children:"Deletes the ~16 GB cache for this release from disk. Backlink results already in SQLite remain untouched. To re-run extracts against this release, you’d have to sync it again (another ~16 GB download)."})]})})]},te.release)),d.length===0&&t.jsx("tr",{children:t.jsx("td",{className:"px-4 py-4 text-sm text-zinc-500",colSpan:5,children:"No cached releases on this machine. If you ran a sync from a different machine (or deleted the cache), the backlink data is still in the database — but you’ll need to re-sync a release to run new extracts."})})]})]})})]}),o.length>1&&t.jsxs("section",{className:"page-section-divider",children:[t.jsx("div",{className:"section-head section-head-inline",children:t.jsxs("div",{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"History"}),t.jsx("h2",{children:"Past release syncs"})]})}),t.jsx(Se,{className:"surface-card overflow-hidden",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-zinc-800 text-left text-xs uppercase tracking-wide text-zinc-600",children:[t.jsx("th",{className:"px-4 py-2 font-medium",children:"Release"}),t.jsx("th",{className:"px-4 py-2 font-medium",children:"Status"}),t.jsx("th",{className:"px-4 py-2 text-right font-medium",children:"Projects"}),t.jsx("th",{className:"px-4 py-2 text-right font-medium",children:"Rows"}),t.jsx("th",{className:"px-4 py-2 font-medium",children:"Finished"})]})}),t.jsx("tbody",{children:o.map(te=>t.jsxs("tr",{className:"border-b border-zinc-900 last:border-0",children:[t.jsx("td",{className:"px-4 py-2 text-zinc-200",children:t.jsx("code",{children:te.release})}),t.jsx("td",{className:"px-4 py-2",children:t.jsx(Ke,{tone:Bh(te.status),children:te.status})}),t.jsx("td",{className:"px-4 py-2 text-right text-zinc-400 tabular-nums",children:te.projectsProcessed??"—"}),t.jsx("td",{className:"px-4 py-2 text-right text-zinc-400 tabular-nums",children:te.domainsDiscovered??"—"}),t.jsx("td",{className:"px-4 py-2 text-zinc-400",children:nu(te.queryFinishedAt??te.updatedAt)})]},te.id))})]})})]})]})}function kB({open:e,onOpenChange:s,projectName:i}){const[r,o]=j.useState("pick");j.useEffect(()=>{e&&o("pick")},[e]);const u=()=>{s(!1),o("pick")};return t.jsx(vN,{open:e,onOpenChange:d=>{d?s(!0):u()},children:t.jsx(Zf,{children:r==="pick"?t.jsx(AB,{onPick:o}):r==="wordpress"?t.jsx(TB,{projectName:i,onBack:()=>o("pick"),onClose:u}):r==="vercel"?t.jsx(EB,{projectName:i,onBack:()=>o("pick"),onClose:u}):t.jsx(_B,{projectName:i,onBack:()=>o("pick"),onClose:u})})})}const CB=[{type:"wordpress",name:"WordPress site",tagline:"Easiest if you run WordPress",description:"Install the Canonry Traffic Logger plugin and connect with an Application Password. No cloud account needed.",icon:Ev},{type:"cloud-run",name:"Google Cloud Run",tagline:"For apps hosted on Cloud Run",description:"Connect a Google Cloud service account so Canonry can read your Cloud Run request logs.",icon:FC},{type:"vercel",name:"Vercel project",tagline:"For sites hosted on Vercel",description:"Connect a Vercel API token so Canonry can pull request logs straight from Vercel — no in-app instrumentation needed.",icon:DA}];function AB({onPick:e}){return t.jsxs(t.Fragment,{children:[t.jsxs(Ff,{children:[t.jsx(Pu,{children:"Connect a traffic source"}),t.jsx(Gu,{children:"Canonry reads your server logs to see when AI crawlers and AI-referred visitors hit your site. Pick where your site is hosted to get started."})]}),t.jsx("div",{className:"mt-6 flex flex-col gap-3",children:CB.map(({type:s,name:i,tagline:r,description:o,icon:u})=>t.jsxs("button",{type:"button",onClick:()=>e(s),className:"group flex items-start gap-4 rounded-lg border border-zinc-800 bg-zinc-900/30 p-4 text-left transition-colors hover:border-zinc-600 hover:bg-zinc-900/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400",children:[t.jsx("span",{className:"mt-0.5 inline-flex size-9 shrink-0 items-center justify-center rounded-md border border-zinc-800 bg-zinc-950 text-zinc-300 group-hover:text-zinc-100",children:t.jsx(u,{className:"size-4"})}),t.jsxs("span",{className:"flex flex-col gap-0.5",children:[t.jsxs("span",{className:"flex flex-wrap items-baseline gap-x-2",children:[t.jsx("span",{className:"text-sm font-medium text-zinc-100",children:i}),t.jsx("span",{className:"text-[11px] text-zinc-500",children:r})]}),t.jsx("span",{className:"text-xs leading-5 text-zinc-500",children:o})]})]},s))})]})}function bp({title:e,description:s,onBack:i}){return t.jsxs(Ff,{children:[t.jsxs("button",{type:"button",onClick:i,className:"mb-1 inline-flex w-fit items-center gap-1 rounded text-xs text-zinc-500 transition-colors hover:text-zinc-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400",children:[t.jsx(Qh,{className:"size-3"}),"Choose a different source"]}),t.jsx(Pu,{children:e}),t.jsx(Gu,{children:s})]})}function TB({projectName:e,onBack:s,onClose:i}){const[r,o]=j.useState(""),[u,d]=j.useState(""),[h,p]=j.useState(""),[x,b]=j.useState(""),[v,N]=j.useState(null),[z,T]=j.useState(null),w=FM(e||null),A=async D=>{if(D.preventDefault(),N(null),T(null),!r.trim()){N("WordPress site URL is required.");return}if(!u.trim()){N("Username is required.");return}if(!h.trim()){N("Application Password is required.");return}try{const U=await w.mutateAsync({baseUrl:r.trim(),username:u.trim(),applicationPassword:h.trim(),displayName:x.trim()||void 0});p(""),T(`Connected ${U.displayName}.`)}catch(U){const I=U instanceof un||U instanceof Error?U.message:String(U);N(I)}};return t.jsxs(t.Fragment,{children:[t.jsx(bp,{title:"Connect a WordPress site",description:t.jsxs(t.Fragment,{children:["Pulls request events from the Canonry Traffic Logger plugin. The Application Password is stored in ",t.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),onBack:s}),t.jsxs("form",{onSubmit:Le(A),className:"mt-6 flex flex-col gap-5 overflow-y-auto pr-1",children:[t.jsx(Nn,{label:"Project",description:"Canonry project this source attaches to.",children:t.jsx("input",{type:"text",value:e,disabled:!0,className:"w-full rounded border border-zinc-700 bg-zinc-900/50 px-2 py-1.5 text-sm text-zinc-300"})}),t.jsx(Nn,{label:"WordPress site URL",description:"Base URL of the site running the Canonry Traffic Logger plugin.",required:!0,children:t.jsx("input",{type:"url",value:r,onChange:D=>o(D.target.value),required:!0,autoComplete:"url",placeholder:"https://example.com",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none"})}),t.jsx(Nn,{label:"Username",description:"WordPress user that owns the Application Password.",required:!0,children:t.jsx("input",{type:"text",value:u,onChange:D=>d(D.target.value),required:!0,autoComplete:"username",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none"})}),t.jsx(Nn,{label:"Application Password",description:"Create one in wp-admin under Users -> Profile -> Application Passwords.",required:!0,children:t.jsx("input",{type:"password",value:h,onChange:D=>p(D.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none"})}),t.jsx(Nn,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the WordPress host.",children:t.jsx("input",{type:"text",value:x,onChange:D=>b(D.target.value),autoComplete:"off",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none"})}),v?t.jsx("p",{className:"rounded-md border border-rose-800/50 bg-rose-950/30 px-3 py-2 text-xs text-rose-200",children:v}):null,z?t.jsx("p",{className:"rounded-md border border-emerald-800/50 bg-emerald-950/30 px-3 py-2 text-xs text-emerald-200",children:z}):null,t.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2 border-t border-zinc-800/60 pt-4",children:[t.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:i,children:"Close"}),t.jsx(ee,{type:"submit",disabled:w.isPending,size:"sm",children:w.isPending?"Connecting...":"Connect"})]})]})]})}function _B({projectName:e,onBack:s,onClose:i}){const[r,o]=j.useState(""),[u,d]=j.useState(""),[h,p]=j.useState(""),[x,b]=j.useState(""),[v,N]=j.useState(""),[z,T]=j.useState(null),[w,A]=j.useState(null),D=ZM(e||null),U=async C=>{if(C.preventDefault(),T(null),A(null),!r.trim()){T("GCP project ID is required.");return}if(!v.trim()){T("Service-account JSON content is required.");return}try{const L=await D.mutateAsync({gcpProjectId:r.trim(),serviceName:u.trim()||void 0,location:h.trim()||void 0,displayName:x.trim()||void 0,keyJson:v.trim()});N(""),A(`Connected ${L.displayName}.`)}catch(L){const M=L instanceof un||L instanceof Error?L.message:String(L);T(M)}},I=async C=>{if(!C)return;const L=await C.text();N(L)};return t.jsxs(t.Fragment,{children:[t.jsx(bp,{title:"Connect a Cloud Run service",description:t.jsxs(t.Fragment,{children:["v1 supports service-account JSON only. The private key is stored in"," ",t.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),onBack:s}),t.jsxs("form",{onSubmit:Le(U),className:"mt-6 flex flex-col gap-5 overflow-y-auto pr-1",children:[t.jsx(Nn,{label:"Project",description:"Canonry project this source attaches to.",children:t.jsx("input",{type:"text",value:e,disabled:!0,className:"w-full rounded border border-zinc-700 bg-zinc-900/50 px-2 py-1.5 text-sm text-zinc-300"})}),t.jsx(Nn,{label:"GCP project ID",description:"The Google Cloud project hosting the Cloud Run service (e.g. my-prod-foo).",required:!0,children:t.jsx("input",{type:"text",value:r,onChange:C=>o(C.target.value),required:!0,autoComplete:"off",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none"})}),t.jsx(Nn,{label:"Service name (optional)",description:"Restrict log pulls to a specific Cloud Run service. Omit to pull all services in the project.",children:t.jsx("input",{type:"text",value:u,onChange:C=>d(C.target.value),autoComplete:"off",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none"})}),t.jsx(Nn,{label:"Location (optional)",description:"Region of the Cloud Run service (e.g. us-central1). Helpful when multiple regions emit logs.",children:t.jsx("input",{type:"text",value:h,onChange:C=>p(C.target.value),autoComplete:"off",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none"})}),t.jsx(Nn,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the project + service combo.",children:t.jsx("input",{type:"text",value:x,onChange:C=>b(C.target.value),autoComplete:"off",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none"})}),t.jsxs(Nn,{label:"Service-account JSON",description:"Paste the contents of the SA key (JSON). The SA needs roles/logging.viewer (or any role granting logging.logEntries.list).",required:!0,children:[t.jsx("textarea",{value:v,onChange:C=>N(C.target.value),rows:6,spellCheck:!1,autoComplete:"off",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 font-mono text-[11px] text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:'{"type":"service_account","project_id":"…","private_key":"…"}',required:!0}),t.jsxs("label",{className:"mt-2 inline-flex cursor-pointer items-center gap-2 text-xs text-zinc-400 hover:text-zinc-200",children:[t.jsx("input",{type:"file",accept:"application/json,.json",className:"hidden",onChange:C=>{I(C.target.files?.[0]??null)}}),t.jsx("span",{className:"rounded-md border border-zinc-800 px-2 py-1",children:"Or upload a key file"})]})]}),z?t.jsx("p",{className:"rounded-md border border-rose-800/50 bg-rose-950/30 px-3 py-2 text-xs text-rose-200",children:z}):null,w?t.jsx("p",{className:"rounded-md border border-emerald-800/50 bg-emerald-950/30 px-3 py-2 text-xs text-emerald-200",children:w}):null,t.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2 border-t border-zinc-800/60 pt-4",children:[t.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:i,children:"Close"}),t.jsx(ee,{type:"submit",disabled:D.isPending,size:"sm",children:D.isPending?"Connecting…":"Connect"})]})]})]})}function EB({projectName:e,onBack:s,onClose:i}){const[r,o]=j.useState(""),[u,d]=j.useState(""),[h,p]=j.useState(""),[x,b]=j.useState("production"),[v,N]=j.useState(""),[z,T]=j.useState(null),[w,A]=j.useState(null),D=YM(e||null),U=async I=>{if(I.preventDefault(),T(null),A(null),!r.trim()){T("Vercel project ID is required.");return}if(!u.trim()){T("Vercel team ID is required.");return}if(!h.trim()){T("Vercel API token is required.");return}try{const C=await D.mutateAsync({projectId:r.trim(),teamId:u.trim(),token:h.trim(),environment:x,displayName:v.trim()||void 0});p(""),A(`Connected ${C.displayName}.`)}catch(C){const L=C instanceof un||C instanceof Error?C.message:String(C);T(L)}};return t.jsxs(t.Fragment,{children:[t.jsx(bp,{title:"Connect a Vercel project",description:t.jsxs(t.Fragment,{children:["Pulls request logs straight from Vercel — no in-app instrumentation needed. The API token is stored in ",t.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),onBack:s}),t.jsxs("form",{onSubmit:Le(U),className:"mt-6 flex flex-col gap-5 overflow-y-auto pr-1",children:[t.jsx(Nn,{label:"Project",description:"Canonry project this source attaches to.",children:t.jsx("input",{type:"text",value:e,disabled:!0,className:"w-full rounded border border-zinc-700 bg-zinc-900/50 px-2 py-1.5 text-sm text-zinc-300"})}),t.jsx(Nn,{label:"Vercel project ID",description:"The prj_… id from the Vercel dashboard or .vercel/project.json.",required:!0,children:t.jsx("input",{type:"text",value:r,onChange:I=>o(I.target.value),required:!0,autoComplete:"off",placeholder:"prj_…",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none"})}),t.jsx(Nn,{label:"Vercel team ID",description:"The team_… (or owner) id the project belongs to.",required:!0,children:t.jsx("input",{type:"text",value:u,onChange:I=>d(I.target.value),required:!0,autoComplete:"off",placeholder:"team_…",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none"})}),t.jsx(Nn,{label:"API token",description:"Create one in Vercel under Account Settings → Tokens. Tokens can expire — use a long-lived token.",required:!0,children:t.jsx("input",{type:"password",value:h,onChange:I=>p(I.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none"})}),t.jsx(Nn,{label:"Environment",description:"Which deployment environment's request logs to pull.",children:t.jsxs("select",{value:x,onChange:I=>b(I.target.value),className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 focus:border-zinc-500 focus:outline-none",children:[t.jsx("option",{value:"production",children:"production"}),t.jsx("option",{value:"preview",children:"preview"})]})}),t.jsx(Nn,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the Vercel project ID.",children:t.jsx("input",{type:"text",value:v,onChange:I=>N(I.target.value),autoComplete:"off",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none"})}),z?t.jsx("p",{className:"rounded-md border border-rose-800/50 bg-rose-950/30 px-3 py-2 text-xs text-rose-200",children:z}):null,w?t.jsx("p",{className:"rounded-md border border-emerald-800/50 bg-emerald-950/30 px-3 py-2 text-xs text-emerald-200",children:w}):null,t.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2 border-t border-zinc-800/60 pt-4",children:[t.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:i,children:"Close"}),t.jsx(ee,{type:"submit",disabled:D.isPending,size:"sm",children:D.isPending?"Connecting…":"Connect"})]})]})]})}function Nn({label:e,description:s,required:i,children:r}){return t.jsxs("label",{className:"flex flex-col gap-1",children:[t.jsxs("span",{className:"text-xs font-medium text-zinc-200",children:[e,i?t.jsx("span",{className:"ml-1 text-rose-400",children:"*"}):null]}),r,t.jsx("span",{className:"text-[11px] text-zinc-500",children:s})]})}function DB(e){if(!e)return"never";const s=Date.now()-new Date(e).getTime(),i=Math.floor(s/6e4);if(i<1)return"just now";if(i<60)return`${i}m ago`;const r=Math.floor(i/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function qh(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function OB(){const[e,s]=j.useState(""),[i,r]=j.useState(!1),u=tn(Bu({client:ae})).data??[],d=j.useMemo(()=>e||(u[0]?.name??""),[e,u]),h=VM(d||null),p=h.data?.sources??[];return t.jsxs("div",{className:"page-container",children:[t.jsxs("div",{className:"page-header",children:[t.jsxs("div",{className:"page-header-left",children:[t.jsx("h1",{className:"page-title",children:"Server traffic"}),t.jsx("p",{className:"page-subtitle",children:"Crawler hits and AI-referral sessions pulled directly from your server logs. Independent of GA — useful when you need server-side evidence that GPTBot or ChatGPT-User actually hit a page."})]}),t.jsx("div",{className:"flex flex-wrap items-center justify-end gap-2",children:t.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>r(!0),disabled:!d,children:[t.jsx(pu,{className:"size-3.5"}),"Connect a source"]})})]}),t.jsxs("section",{children:[t.jsx("div",{className:"filter-row",role:"toolbar","aria-label":"Project picker",children:u.map(x=>t.jsx("button",{type:"button",className:`filter-chip ${d===x.name?"filter-chip-active":""}`,"aria-pressed":d===x.name,onClick:()=>s(x.name),children:x.displayName??x.name},x.id))}),d?h.isLoading?t.jsx(Se,{className:"p-6 text-center text-sm text-zinc-500",children:"Loading sources…"}):p.length===0?t.jsxs(Se,{className:"p-8 text-center",children:[t.jsxs("p",{className:"text-sm text-zinc-300",children:["No traffic sources connected for ",d,"."]}),t.jsx("p",{className:"mt-1 text-xs text-zinc-500",children:"Connect a traffic source to start ingesting crawler hits and AI-referral sessions from your server logs."}),t.jsx("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-2",children:t.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>r(!0),children:[t.jsx(pu,{className:"size-3.5"}),"Connect a source"]})})]}):t.jsx(RB,{projectName:d,sources:p}):t.jsx(Se,{className:"p-6 text-center text-sm text-zinc-500",children:"No projects yet."})]}),t.jsx(kB,{open:i,onOpenChange:r,projectName:d})]})}function RB({projectName:e,sources:s}){const i=Fb({queries:s.map(o=>({...Wj({client:ae,path:{name:e,id:o.id}}),staleTime:3e4}))}),r=s.map((o,u)=>({source:o,detail:i[u]?.data,isLoading:i[u]?.isLoading??!1}));return t.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 overflow-hidden",children:[t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-zinc-900/50 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-2 text-left",children:"Source"}),t.jsx("th",{className:"px-4 py-2 text-left",children:"Status"}),t.jsx("th",{className:"px-4 py-2 text-left",children:"Last sync"}),t.jsx("th",{className:"px-4 py-2 text-right",children:"24h crawler"}),t.jsx("th",{className:"px-4 py-2 text-right",children:"24h AI sessions"}),t.jsx("th",{className:"px-4 py-2 text-right",children:"24h samples"}),t.jsx("th",{className:"px-4 py-2 text-right"})]})}),t.jsx("tbody",{className:"divide-y divide-zinc-800/60",children:r.map(({source:o,detail:u,isLoading:d})=>t.jsxs("tr",{className:"hover:bg-zinc-900/40 transition-colors",children:[t.jsxs("td",{className:"px-4 py-3",children:[t.jsx("div",{className:"font-medium text-zinc-100",children:o.displayName}),t.jsxs("div",{className:"text-[11px] text-zinc-500 font-mono",children:[o.sourceType," · ",o.id.slice(0,8)]})]}),t.jsxs("td",{className:"px-4 py-3",children:[t.jsx(Ke,{tone:pp(o.status),children:o.status}),o.lastError?t.jsx("p",{className:"mt-1 max-w-[18rem] truncate text-[11px] text-rose-400/80",title:o.lastError,children:o.lastError}):null]}),t.jsx("td",{className:"px-4 py-3 text-zinc-300",children:DB(o.lastSyncedAt)}),t.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-zinc-100",children:d?"—":qh(u?.totals24h.crawlerHits??0)}),t.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-zinc-100",children:d?"—":qh(u?.totals24h.aiReferralHits??0)}),t.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-zinc-300",children:d?"—":qh(u?.totals24h.sampleCount??0)}),t.jsx("td",{className:"px-4 py-3 text-right",children:t.jsxs(ft,{to:"/traffic/$projectName/$sourceId",params:{projectName:e,sourceId:o.id},className:"inline-flex items-center gap-1 text-xs text-zinc-300 hover:text-zinc-100",children:[t.jsx(mo,{className:"size-3"}),"View"]})})]},o.id))})]}),t.jsxs("p",{className:"border-t border-zinc-800/60 px-4 py-2 text-[11px] text-zinc-600",children:["Showing ",s.filter(o=>o.status!==ro.archived).length," active source",s.length===1?"":"s"," for ",e,". Same shape as ",t.jsxs("code",{className:"text-zinc-400",children:["canonry traffic status ",e," --format json"]}),"."]})]})}function Ih({value:e,label:s,delta:i,tone:r,description:o,tooltip:u,isNumeric:d=!0,progress:h,providerCoverage:p}){const v=2*Math.PI*48,N=Number.parseInt(e,10),z=typeof h=="number"&&Number.isFinite(h)?Math.min(Math.max(h,0),100)/100:d&&!Number.isNaN(N)?Math.min(N/100,1):.5,T=v*(1-z);return t.jsxs("div",{className:"score-gauge",children:[t.jsxs("div",{className:"gauge-ring-wrapper",children:[t.jsxs("svg",{className:"gauge-ring",viewBox:"0 0 120 120","aria-hidden":"true",children:[t.jsx("circle",{className:"gauge-bg",cx:"60",cy:"60",r:48,strokeWidth:6}),t.jsx("circle",{className:`gauge-fill gauge-fill-${r}`,cx:"60",cy:"60",r:48,strokeWidth:6,strokeDasharray:v,strokeDashoffset:T,transform:"rotate(-90 60 60)"})]}),t.jsx("div",{className:"gauge-center",children:t.jsx("span",{className:d?"gauge-value":"gauge-value-text",children:e.split(" / ")[0]})})]}),t.jsxs("p",{className:"gauge-label",children:[s,u&&t.jsx(on,{text:u})]}),t.jsx("p",{className:"gauge-delta",children:i}),p&&t.jsx("p",{className:"gauge-provider-coverage",children:p}),t.jsx("p",{className:"gauge-description",children:o})]})}function j1(e){return e.kind===Gs.crawler?e.botId:e.product}function LB(e){return e.kind===Gs.crawler?e.pathNormalized:e.landingPathNormalized}function N1(e,s){if(s==="hour")return e;const i=new Date(e),r=i.getFullYear(),o=String(i.getMonth()+1).padStart(2,"0"),u=String(i.getDate()).padStart(2,"0");return`${r}-${o}-${u}`}function MB(e,s,i){const r=s.pathQuery.trim().toLowerCase();return e.filter(o=>!(s.selectedBucket&&N1(o.tsHour,i)!==s.selectedBucket||s.identity&&j1(o)!==s.identity||s.operator&&o.operator!==s.operator||r&&!LB(o).toLowerCase().includes(r)))}function $B(e,s){if(!e||typeof e!="object")return null;const i=e.activeTooltipIndex;let r;if(typeof i=="number")r=i;else if(typeof i=="string"&&i!=="")r=Number(i);else return null;return!Number.isInteger(r)||r<0||r>=s.length?null:s[r]?.bucket??null}const Tu=[{value:60,label:"1h",granularity:"hour",fetchLimit:500},{value:360,label:"6h",granularity:"hour",fetchLimit:500},{value:1440,label:"24h",granularity:"hour",fetchLimit:500},{value:10080,label:"7d",granularity:"hour",fetchLimit:1e3},{value:720*60,label:"30d",granularity:"day",fetchLimit:2e3},{value:2160*60,label:"90d",granularity:"day",fetchLimit:5e3}],Vb=Tu.find(e=>e.label==="7d")??Tu[2],Hb=Gr[0],Kb=Gr[1];function w1(e){const s=new Date(e);return`${s.getMonth()+1}/${s.getDate()} ${String(s.getHours()).padStart(2,"0")}:00`}function BB(e){const s=new Date(`${e}T00:00:00`);return`${s.getMonth()+1}/${s.getDate()}`}function su(e){if(!e)return"never";const s=Date.now()-new Date(e).getTime(),i=Math.floor(s/6e4);if(i<1)return"just now";if(i<60)return`${i}m ago`;const r=Math.floor(i/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function qB(){const e=Jb({strict:!1}),s=e.projectName??"",i=e.sourceId??"",[r,o]=j.useState(Vb.value),[u,d]=j.useState(()=>new Set(["crawler","ai-referral"])),[h,p]=j.useState(null),[x,b]=j.useState(""),[v,N]=j.useState(""),[z,T]=j.useState(""),[w,A]=j.useState(null),[D,U]=j.useState(null),I=j.useMemo(()=>Tu.find(pe=>pe.value===r)??Vb,[r]),C=KM(s||null,i||null),L=QM(s||null,{sourceId:i||void 0,sinceMinutes:r,limit:I.fetchLimit}),M=XM(s||null,i||null),_=C.data,B=L.data?.events??[],J=L.data?.totals,ue=j.useMemo(()=>B.filter(pe=>pe.kind===Gs.crawler?u.has("crawler"):u.has("ai-referral")),[B,u]),P=j.useMemo(()=>{const pe=new Set;for(const E of B)pe.add(j1(E));return x&&pe.add(x),[...pe].sort((E,X)=>E.localeCompare(X))},[B,x]),ie=j.useMemo(()=>{const pe=new Set;for(const E of B)pe.add(E.operator);return v&&pe.add(v),[...pe].sort((E,X)=>E.localeCompare(X))},[B,v]),te=j.useMemo(()=>MB(ue,{selectedBucket:h,identity:x,operator:v,pathQuery:z},I.granularity),[ue,h,x,v,z,I.granularity]),ze=j.useMemo(()=>h?cu(h,I.granularity):null,[h,I.granularity]),ve=j.useMemo(()=>IB(B,I.granularity,L.data?.windowStart,L.data?.windowEnd),[B,I.granularity,L.data?.windowStart,L.data?.windowEnd]),V=pe=>{d(E=>{const X=new Set(E);return X.has(pe)?X.size>1&&X.delete(pe):X.add(pe),X})},ne=pe=>{const E=$B(pe,ve);E&&p(X=>X===E?null:E)},me=()=>{p(null),b(""),N(""),T("")},Ne=!!(h||x||v||z.trim()),se=async()=>{A(null),U(null);try{const pe=await M.mutateAsync({sinceMinutes:60});U(`Pulled ${pe.pulledEvents} entries · ${pe.crawlerHits} crawler · ${pe.aiReferralHits} AI referral · ${pe.unknownHits} unknown`)}catch(pe){const E=pe instanceof un||pe instanceof Error?pe.message:String(pe);A(E)}};return!s||!i?t.jsx("div",{className:"page-container",children:t.jsx("p",{className:"text-sm text-zinc-500",children:"Missing project name or source id in URL."})}):C.isLoading?t.jsx("div",{className:"page-container",children:t.jsx("p",{className:"text-sm text-zinc-500",children:"Loading source…"})}):C.isError||!_?t.jsxs("div",{className:"page-container",children:[t.jsx("p",{className:"text-sm text-rose-300",children:"Could not load this source."}),t.jsxs(ft,{to:"/traffic",className:"mt-2 inline-flex items-center gap-1 text-xs text-zinc-400 hover:text-zinc-200",children:[t.jsx(Qh,{className:"size-3"})," Back to sources"]})]}):t.jsxs("div",{className:"page-container space-y-8",children:[t.jsxs("div",{className:"page-header",children:[t.jsxs("div",{className:"page-header-left",children:[t.jsxs(ft,{to:"/traffic",className:"inline-flex items-center gap-1 text-xs text-zinc-500 hover:text-zinc-200",children:[t.jsx(Qh,{className:"size-3"})," All sources"]}),t.jsx("h1",{className:"page-title mt-2",children:_.displayName}),t.jsxs("p",{className:"page-subtitle",children:[_.sourceType," · project ",t.jsx("span",{className:"text-zinc-300",children:s})," ·",t.jsx("span",{className:"ml-1 font-mono text-zinc-400",children:_.id})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ke,{tone:pp(_.status),children:_.status}),t.jsxs(ee,{type:"button",variant:"outline",size:"sm",disabled:M.isPending,onClick:()=>{se()},children:[t.jsx(mo,{className:`size-3.5 ${M.isPending?"animate-spin":""}`}),M.isPending?"Syncing…":"Sync now"]})]})]}),w?t.jsx("div",{className:"rounded-md border border-rose-800/50 bg-rose-950/30 px-3 py-2 text-xs text-rose-200",children:w}):null,D?t.jsx("div",{className:"rounded-md border border-emerald-800/50 bg-emerald-950/30 px-3 py-2 text-xs text-emerald-200",children:D}):null,t.jsxs("section",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[t.jsx(Ih,{label:"24h crawler hits",value:String(_.totals24h.crawlerHits),delta:_.lastSyncedAt?`last sync ${su(_.lastSyncedAt)}`:"never synced",tone:_.totals24h.crawlerHits>0?"positive":"neutral",description:"GPTBot, ChatGPT-User, PerplexityBot, etc. — verified crawler requests in the last 24h.",isNumeric:!0,progress:Math.min(100,Math.round(_.totals24h.crawlerHits/1e3*100))}),t.jsx(Ih,{label:"24h AI referral sessions",value:String(_.totals24h.aiReferralHits),delta:_.lastSyncedAt?`last sync ${su(_.lastSyncedAt)}`:"never synced",tone:_.totals24h.aiReferralHits>0?"positive":"neutral",description:"Sessionized visits arriving from chat.openai.com, perplexity.ai, etc. (Referer header evidence).",isNumeric:!0,progress:Math.min(100,Math.round(_.totals24h.aiReferralHits/1e3*100))}),t.jsx(Ih,{label:"24h sample rows",value:String(_.totals24h.sampleCount),delta:"bounded per sync",tone:"neutral",description:"Per-request samples retained for evidence (capped to keep storage bounded).",isNumeric:!0,progress:Math.min(100,Math.round(_.totals24h.sampleCount/100*100))})]}),t.jsxs("section",{children:[t.jsx("p",{className:"mb-4 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:"Latest sync run"}),_.latestRun?t.jsxs(Se,{className:"p-4 text-sm",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-1.5",children:[t.jsxs("span",{className:"text-zinc-100",children:["Status: ",t.jsx("span",{className:"font-medium",children:_.latestRun.status})]}),t.jsxs("span",{className:"text-zinc-500",children:["Started: ",su(_.latestRun.startedAt)]}),_.latestRun.finishedAt?t.jsxs("span",{className:"text-zinc-500",children:["Finished: ",su(_.latestRun.finishedAt)]}):null,t.jsx("span",{className:"font-mono text-[11px] text-zinc-600",children:_.latestRun.runId})]}),_.latestRun.error?t.jsx("p",{className:"mt-2 rounded border border-rose-900/40 bg-rose-950/30 px-3 py-2 text-xs text-rose-300",children:_.latestRun.error}):null]}):t.jsx(Se,{className:"px-4 py-3 text-sm text-zinc-500",children:'No traffic-sync runs recorded yet. Hit "Sync now" above to create one.'})]}),t.jsxs("section",{children:[t.jsxs("div",{className:"mb-4 flex flex-wrap items-end justify-between gap-x-4 gap-y-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:"Events"}),t.jsx("h2",{className:"mt-1 text-base font-semibold text-zinc-50",children:I.granularity==="day"?"Daily rollups":"Hourly rollups"}),J?t.jsxs("p",{className:"mt-1.5 text-xs text-zinc-500",children:[J.crawlerHits.toLocaleString("en-US")," crawler ·"," ",J.aiReferralHits.toLocaleString("en-US")," AI referral sessions · last ",I.label]}):null]}),t.jsx("div",{className:"filter-row mb-0",role:"toolbar","aria-label":"Window",children:Tu.map(pe=>t.jsx("button",{type:"button",className:`filter-chip ${r===pe.value?"filter-chip-active":""}`,"aria-pressed":r===pe.value,onClick:()=>{o(pe.value),p(null)},children:pe.label},pe.value))})]}),t.jsxs(Se,{className:"p-4",children:[t.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",role:"toolbar","aria-label":"Series",children:[t.jsx(Qb,{label:"Crawler",color:Hb,count:J?.crawlerHits??0,active:u.has("crawler"),onToggle:()=>V("crawler")}),t.jsx(Qb,{label:"AI referral sessions",color:Kb,count:J?.aiReferralHits??0,active:u.has("ai-referral"),onToggle:()=>V("ai-referral")})]}),ve.length===0?t.jsx("p",{className:"py-12 text-center text-xs text-zinc-500",children:"No events in this window."}):t.jsx("div",{className:"h-72",children:t.jsx(uu,{children:t.jsxs(GS,{data:ve,margin:{top:4,right:4,bottom:0,left:0},onClick:ne,style:{cursor:"pointer"},children:[t.jsx(VS,{stroke:PM,strokeDasharray:"3 3"}),t.jsx(du,{dataKey:"label",tick:ei,stroke:Xr,interval:"preserveStartEnd",minTickGap:I.granularity==="day"?24:32}),t.jsx(mu,{tick:ei,stroke:Xr,allowDecimals:!1}),t.jsx(hu,{...Pr}),u.has("crawler")?t.jsx(ny,{dataKey:"crawler",name:"Crawler",fill:Hb,stackId:"a",children:ve.map(pe=>t.jsx(sy,{fillOpacity:h&&h!==pe.bucket?.25:1},pe.bucket))}):null,u.has("ai-referral")?t.jsx(ny,{dataKey:"aiReferral",name:"AI referral",fill:Kb,stackId:"a",children:ve.map(pe=>t.jsx(sy,{fillOpacity:h&&h!==pe.bucket?.25:1},pe.bucket))}):null]})})})]})]}),t.jsxs("section",{children:[t.jsxs("div",{className:"mb-4 flex flex-wrap items-end justify-between gap-x-4 gap-y-2",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:"Event rows"}),t.jsxs("p",{className:"mt-1 text-xs text-zinc-500",children:["Showing ",t.jsx("span",{className:"tabular-nums text-zinc-300",children:te.length.toLocaleString("en-US")})," of"," ",t.jsx("span",{className:"tabular-nums text-zinc-500",children:ue.length.toLocaleString("en-US")})," events"]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("select",{"aria-label":"Filter by identity",value:x,onChange:pe=>b(pe.target.value),className:"rounded-md border border-zinc-800 bg-zinc-950 px-2.5 py-1.5 text-xs text-zinc-200 focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-600",children:[t.jsx("option",{value:"",children:"All identities"}),P.map(pe=>t.jsx("option",{value:pe,children:pe},pe))]}),t.jsxs("select",{"aria-label":"Filter by operator",value:v,onChange:pe=>N(pe.target.value),className:"rounded-md border border-zinc-800 bg-zinc-950 px-2.5 py-1.5 text-xs text-zinc-200 focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-600",children:[t.jsx("option",{value:"",children:"All operators"}),ie.map(pe=>t.jsx("option",{value:pe,children:pe},pe))]}),t.jsx("input",{type:"search","aria-label":"Filter by path",placeholder:"path contains…",value:z,onChange:pe=>T(pe.target.value),className:"w-44 rounded-md border border-zinc-800 bg-zinc-950 px-2.5 py-1.5 text-xs text-zinc-200 placeholder:text-zinc-600 focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-600"})]})]}),Ne?t.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[ze?t.jsx(au,{label:`Bucket: ${ze}`,onClear:()=>p(null)}):null,x?t.jsx(au,{label:`Identity: ${x}`,onClear:()=>b("")}):null,v?t.jsx(au,{label:`Operator: ${v}`,onClear:()=>N("")}):null,z.trim()?t.jsx(au,{label:`Path: ${z.trim()}`,onClear:()=>T("")}):null,t.jsx("button",{type:"button",onClick:me,className:"text-xs text-zinc-500 underline-offset-4 hover:text-zinc-200 hover:underline",children:"Clear all"})]}):null,t.jsx(UB,{events:te})]})]})}function cu(e,s){return s==="day"?BB(e):w1(e)}function IB(e,s,i,r){const o=new Map;for(const u of e){const d=N1(u.tsHour,s);let h=o.get(d);h||(h={bucket:d,label:cu(d,s),crawler:0,aiReferral:0},o.set(d,h)),u.kind===Gs.crawler?h.crawler+=u.hits:h.aiReferral+=u.hits}if(i&&r){const u=new Date(i),d=new Date(r);if(s==="day"){const h=new Date(Date.UTC(u.getUTCFullYear(),u.getUTCMonth(),u.getUTCDate())),p=new Date(Date.UTC(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()));for(;h<=p;){const x=h.getUTCFullYear(),b=String(h.getUTCMonth()+1).padStart(2,"0"),v=String(h.getUTCDate()).padStart(2,"0"),N=`${x}-${b}-${v}`;o.has(N)||o.set(N,{bucket:N,label:cu(N,s),crawler:0,aiReferral:0}),h.setUTCDate(h.getUTCDate()+1)}}else{const h=new Date(u);for(h.setUTCMinutes(0,0,0);h<=d;){const p=h.toISOString();o.has(p)||o.set(p,{bucket:p,label:cu(p,s),crawler:0,aiReferral:0}),h.setUTCHours(h.getUTCHours()+1)}}}return[...o.values()].sort((u,d)=>u.bucket<d.bucket?-1:u.bucket>d.bucket?1:0)}function au({label:e,onClear:s}){return t.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-zinc-700 bg-zinc-800/60 px-2.5 py-1 text-[11px] text-zinc-200",children:[e,t.jsx("button",{type:"button",onClick:s,"aria-label":`Clear ${e}`,className:"rounded-full p-0.5 text-zinc-400 hover:bg-zinc-700/60 hover:text-zinc-100",children:t.jsx(qi,{className:"size-3"})})]})}function Qb({label:e,color:s,count:i,active:r,onToggle:o}){return t.jsxs("button",{type:"button",onClick:o,"aria-pressed":r,className:`inline-flex items-center gap-2 rounded-full border px-3 py-1 text-xs font-medium transition ${r?"border-zinc-700 bg-zinc-800/60 text-zinc-100":"border-zinc-800 bg-transparent text-zinc-500 hover:text-zinc-300"}`,children:[t.jsx("span",{"aria-hidden":"true",className:`size-2 rounded-full transition-opacity ${r?"opacity-100":"opacity-30"}`,style:{backgroundColor:s}}),t.jsx("span",{children:e}),t.jsx("span",{className:`tabular-nums ${r?"text-zinc-400":"text-zinc-600"}`,children:i.toLocaleString("en-US")})]})}function UB({events:e}){return e.length===0?t.jsx(Se,{className:"p-6 text-center text-sm text-zinc-500",children:"No event rows match the current filters."}):t.jsx("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 overflow-hidden",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-zinc-900/50 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-2 text-left",children:"Hour"}),t.jsx("th",{className:"px-4 py-2 text-left",children:"Kind"}),t.jsx("th",{className:"px-4 py-2 text-left",children:"Identity"}),t.jsx("th",{className:"px-4 py-2 text-left",children:"Evidence / status"}),t.jsx("th",{className:"px-4 py-2 text-left",children:"Path"}),t.jsx("th",{className:"px-4 py-2 text-right",children:"Hits"})]})}),t.jsx("tbody",{className:"divide-y divide-zinc-800/60",children:e.map((s,i)=>t.jsxs("tr",{className:"hover:bg-zinc-900/40 transition-colors",children:[t.jsx("td",{className:"px-4 py-2 font-mono text-xs text-zinc-300",children:w1(s.tsHour)}),t.jsx("td",{className:"px-4 py-2 text-zinc-300",children:s.kind===Gs.crawler?"Crawler":"AI referral"}),t.jsxs("td",{className:"px-4 py-2 text-zinc-100",children:[s.kind===Gs.crawler?s.botId:s.product,t.jsx("span",{className:"ml-2 text-[11px] text-zinc-500",children:s.operator})]}),t.jsx("td",{className:"px-4 py-2 text-zinc-300",children:s.kind===Gs.crawler?`${s.verificationStatus} · HTTP ${s.status}`:`${s.evidenceType} · ${s.sourceDomain}`}),t.jsx("td",{className:"px-4 py-2 truncate font-mono text-xs text-zinc-300",children:s.kind===Gs.crawler?s.pathNormalized:s.landingPathNormalized}),t.jsx("td",{className:"px-4 py-2 text-right tabular-nums text-zinc-100",children:s.hits})]},`${s.kind}:${s.tsHour}:${i}`))})]})})}function PB(){return t.jsx("div",{className:"page-container",children:t.jsx("section",{className:"page-section",children:t.jsxs(Se,{className:"surface-card empty-card",children:[t.jsx("h1",{children:"Route not found"}),t.jsx("p",{children:"The current path does not map to a dashboard view."}),t.jsx(ee,{asChild:!0,children:t.jsx(ft,{to:"/",children:"Return to overview"})})]})})})}function GB(){return t.jsx(yL,{children:t.jsx(xL,{})})}const Kn=$S()({component:GB,validateSearch:e=>({runId:typeof e.runId=="string"?e.runId:void 0,evidenceId:typeof e.evidenceId=="string"?e.evidenceId:void 0})}),VB=Sn({getParentRoute:()=>Kn,path:"/",component:jL,beforeLoad:({context:e})=>{const s=e.queryClient.getQueryData(li({client:ae}));if(s&&s.length===0)throw Wb({to:"/setup"})}}),HB=Sn({getParentRoute:()=>Kn,path:"/projects",component:OM}),ci=Sn({getParentRoute:()=>Kn,path:"/projects/$projectId",component:()=>t.jsx(Xb,{})}),KB=Sn({getParentRoute:()=>ci,path:"/",component:()=>t.jsx(Vi,{tab:"overview"})}),QB=Sn({getParentRoute:()=>ci,path:"/search-console",component:()=>t.jsx(Vi,{tab:"search-console"})}),ZB=Sn({getParentRoute:()=>ci,path:"/discovery",component:()=>t.jsx(Vi,{tab:"discovery"})}),FB=Sn({getParentRoute:()=>ci,path:"/report",component:()=>t.jsx(Vi,{tab:"report"})}),YB=Sn({getParentRoute:()=>ci,path:"/activity",component:()=>t.jsx(Vi,{tab:"activity"})}),XB=Sn({getParentRoute:()=>ci,path:"/backlinks",component:()=>t.jsx(Vi,{tab:"backlinks"})}),JB=Sn({getParentRoute:()=>ci,path:"/settings",component:()=>t.jsx(Vi,{tab:"settings"})}),WB=Sn({getParentRoute:()=>Kn,path:"/runs",component:pB}),e8=Sn({getParentRoute:()=>Kn,path:"/settings",component:vB,beforeLoad:({context:e})=>{}}),t8=Sn({getParentRoute:()=>Kn,path:"/setup",component:wB,beforeLoad:({context:e})=>{const s=e.queryClient.getQueryData(li({client:ae}));if(s&&s.length>0)throw Wb({to:"/"})}}),n8=Sn({getParentRoute:()=>Kn,path:"/backlinks",component:zB}),s8=Sn({getParentRoute:()=>Kn,path:"/traffic",component:OB}),a8=Sn({getParentRoute:()=>Kn,path:"/traffic/$projectName/$sourceId",component:qB}),i8=Sn({getParentRoute:()=>Kn,path:"*",component:PB}),r8=Kn.addChildren([VB,HB,ci.addChildren([KB,QB,ZB,FB,YB,XB,JB]),WB,e8,t8,n8,s8,a8,i8]);function l8(){return typeof window<"u"&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath:"/"}const Zb=l8(),o8=Zb==="/"?"":Zb.replace(/\/$/,"");function c8(e,s){return BS({routeTree:r8,basepath:o8||"/",context:{queryClient:e},...s?.initialEntries})}const u8=6e4;function d8(){const[e,s]=j.useState(xh()?"ready":"checking"),[i,r]=j.useState(""),[o,u]=j.useState(""),[d,h]=j.useState(null),[p,x]=j.useState(!1),[b,v]=j.useState(!1),N=j.useRef(null),z=j.useRef(null),T=()=>{if(!N.current){const D=CC();z.current=D,N.current=c8(D)}return{queryClient:z.current,router:N.current}};j.useEffect(()=>{if(xh())return;let D=!1;return hy().then(U=>{D||(U.authenticated?s("ready"):s(U.setupRequired?"setup":"login"))}).catch(U=>{D||(h(U instanceof Error?U.message:"Failed to reach the Canonry API"),s("login"))}),()=>{D=!0}},[]),j.useEffect(()=>{if(e!=="ready"||xh())return;const D=setInterval(()=>{hy().then(U=>{U.authenticated||(v(!0),s(U.setupRequired?"setup":"login"))}).catch(()=>{})},u8);return uy(()=>{v(!0),s("login")}),()=>{clearInterval(D),uy(null)}},[e]);const w=async D=>{if(D.preventDefault(),!i.trim()||i.trim().length<8){h("Password must be at least 8 characters");return}if(i!==o){h("Passwords do not match");return}x(!0),h(null);try{if(!(await N2(i.trim())).authenticated){h("Setup failed");return}r(""),u(""),v(!1),s("ready")}catch(U){h(U instanceof un||U instanceof Error?U.message:"Setup failed")}finally{x(!1)}},A=async D=>{if(D.preventDefault(),!!i.trim()){x(!0),h(null);try{if(!(await w2(i.trim())).authenticated){h("Incorrect password");return}r(""),v(!1),s("ready")}catch(U){h(U instanceof un||U instanceof Error?U.message:"Authentication failed")}finally{x(!1)}}};if(e==="ready"){const{queryClient:D,router:U}=T();return t.jsx(qS,{client:D,children:t.jsx(IS,{router:U})})}return t.jsx("div",{className:"min-h-screen bg-zinc-950 px-4 py-8",children:t.jsx("div",{className:"mx-auto flex min-h-[calc(100vh-4rem)] max-w-md items-center justify-center",children:t.jsx(Se,{className:"surface-card w-full",children:e==="checking"?t.jsx(iu,{className:"py-8",children:t.jsx("p",{className:"supporting-copy text-center",children:"Connecting to Canonry…"})}):e==="setup"?t.jsxs(t.Fragment,{children:[t.jsxs(sf,{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"First-time setup"}),t.jsx(af,{children:"Create a dashboard password"}),t.jsx(rf,{children:"Choose a password to protect the Canonry dashboard. You will use this to sign in on future visits."})]}),t.jsx(iu,{children:t.jsxs("form",{className:"space-y-4",onSubmit:Le(w),children:[t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"text-xs font-medium text-zinc-400",children:"Password"}),t.jsx("input",{autoFocus:!0,className:"w-full rounded-md border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none transition focus:border-zinc-600",type:"password",value:i,onChange:D=>r(D.target.value),placeholder:"At least 8 characters"})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"text-xs font-medium text-zinc-400",children:"Confirm password"}),t.jsx("input",{className:"w-full rounded-md border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none transition focus:border-zinc-600",type:"password",value:o,onChange:D=>u(D.target.value),placeholder:"Re-enter password"})]}),d?t.jsx("p",{className:"text-sm text-rose-400",children:d}):null,t.jsx(ee,{type:"submit",disabled:p||!i.trim()||!o.trim(),children:p?"Setting up…":"Create password & open dashboard"})]})})]}):t.jsxs(t.Fragment,{children:[t.jsxs(sf,{children:[t.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),t.jsx(af,{children:"Sign in to Canonry"}),t.jsx(rf,{children:"Enter your dashboard password to continue."})]}),t.jsxs(iu,{children:[b?t.jsx("p",{className:"mb-4 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-300",children:"Your session expired — please sign in again."}):null,t.jsxs("form",{className:"space-y-4",onSubmit:Le(A),children:[t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"text-xs font-medium text-zinc-400",children:"Password"}),t.jsx("input",{autoFocus:!0,className:"w-full rounded-md border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none transition focus:border-zinc-600",type:"password",value:i,onChange:D=>r(D.target.value),placeholder:"Dashboard password"})]}),d?t.jsx("p",{className:"text-sm text-rose-400",children:d}):null,t.jsx(ee,{type:"submit",disabled:p||!i.trim(),children:p?"Signing in…":"Open dashboard"})]})]})]})})})})}const S1=document.getElementById("root");if(!S1)throw new Error("Expected #root element for web app bootstrap.");YS.createRoot(S1).render(t.jsx(j.StrictMode,{children:t.jsx(d8,{})}));