@canonry/canonry 7.20.0 → 7.20.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.
- package/assets/assets/{AuditHistoryPanel-C0vj3liH.js → AuditHistoryPanel-DVtz1ZuT.js} +1 -1
- package/assets/assets/{BacklinksPage-TnDsI9Wu.js → BacklinksPage-Tvt0-ppX.js} +1 -1
- package/assets/assets/{HistoryPage-DEEC3g6M.js → HistoryPage-DqXwPH3k.js} +1 -1
- package/assets/assets/{MeasurementPropertyPage-MT4tFOwx.js → MeasurementPropertyPage-CsbfFEjB.js} +1 -1
- package/assets/assets/{ProjectPage-NI-bjpfN.js → ProjectPage-Cyvt96AV.js} +2 -2
- package/assets/assets/{RunsPage-GIKqPu0J.js → RunsPage-Io7ZFw4-.js} +1 -1
- package/assets/assets/{SettingsPage-DLFwSj4J.js → SettingsPage-BPYxgchP.js} +1 -1
- package/assets/assets/{SiteHealthSection-CYG9IMh5.js → SiteHealthSection-CwffU3tv.js} +3 -3
- package/assets/assets/{TrafficPage-oOxDmxQq.js → TrafficPage-DIm60m1J.js} +1 -1
- package/assets/assets/{TrafficSourceDetailPage-BGrwpVvM.js → TrafficSourceDetailPage-DWT1Ip5P.js} +1 -1
- package/assets/assets/{extract-error-message-DRDQFsgG.js → extract-error-message-BVYchXhT.js} +1 -1
- package/assets/assets/{index-B_2gPTCa.js → index-DrQLR1jE.js} +3 -3
- package/assets/assets/{react-sigma_core.esm.min-DzDqz7hq.js → react-sigma_core.esm.min-f31sqfAC.js} +1 -1
- package/assets/assets/{v2-overview-adapter-BHzFliuj.js → v2-overview-adapter-By0930UY.js} +1 -1
- package/assets/index.html +1 -1
- package/dist/{chunk-KF7LRHGJ.js → chunk-CIPWGVX6.js} +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +11 -11
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SiteHealthSection-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SiteHealthSection-CwffU3tv.js","./vendor-tanstack-ZXXkndVj.js","./vendor-lucide-Y6jANGfG.js","./ChartPrimitives-CYlrwLJs.js","./vendor-recharts-D-cUuLZo.js","./ProjectPage-Cyvt96AV.js","./v2-overview-adapter-By0930UY.js","./vendor-markdown-B4giJcws.js","./extract-error-message-BVYchXhT.js","./Hint-DICI5Jq9.js","./AuditHistoryPanel-DVtz1ZuT.js","./vendor-radix-twS1M3FF.js","./vendor-yaml-GWJz5H2G.js","./RunsPage-Io7ZFw4-.js","./HistoryPage-DqXwPH3k.js","./SettingsPage-BPYxgchP.js","./BacklinksPage-Tvt0-ppX.js","./TrafficPage-DIm60m1J.js","./TrafficSourceDetailPage-DWT1Ip5P.js","./MeasurementPropertyPage-CsbfFEjB.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{c as F5,d as Z5,r as C,j as l,Q as Y5,M as X5,q as be,e as Bc,L as at,a as J5,t as Nr,u as yt,f as W5,h as Ds,k as zs,l as fk,m as e6,n as gk,O as Xf,o as oi,p as t6,s as Bt,v as Kg,x as Is,y as n6,z as a6,A as i6}from"./vendor-tanstack-ZXXkndVj.js";import{S as s6,O as Gg,P as yk,C as Hg,a as bk,T as Qg,D as vk,R as xk}from"./vendor-radix-twS1M3FF.js";import{c as wk}from"./vendor-recharts-D-cUuLZo.js";import{A as Tc,X as Gr,S as Fg,a as Sk,G as kk,C as Lc,L as Ts,R as hd,M as o6,b as r6,P as Jf,H as jk,c as Ak,d as l6,e as Uc,f as Zg,T as ym,g as Vc,W as Nk,h as c6,i as u6,j as d6,k as m6,l as p6,m as h6,n as f6,B as g6,F as y6,o as b6,p as v6,q as x6,r as w6,s as Ck,t as _k,u as Wf,v as Tk,w as S6,x as Ek,E as k6}from"./vendor-lucide-Y6jANGfG.js";import{M as j6,r as A6}from"./vendor-markdown-B4giJcws.js";import{p as N6}from"./vendor-yaml-GWJz5H2G.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))r(u);new MutationObserver(u=>{for(const h of u)if(h.type==="childList")for(const f of h.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&r(f)}).observe(document,{childList:!0,subtree:!0});function i(u){const h={};return u.integrity&&(h.integrity=u.integrity),u.referrerPolicy&&(h.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?h.credentials="include":u.crossOrigin==="anonymous"?h.credentials="omit":h.credentials="same-origin",h}function r(u){if(u.ep)return;u.ep=!0;const h=i(u);fetch(u.href,h)}})();var lf={exports:{}},cc={},cf={exports:{}},uf={};var bx;function C6(){return bx||(bx=1,(function(e){function n(B,W){var ve=B.length;B.push(W);e:for(;0<ve;){var Ae=ve-1>>>1,se=B[Ae];if(0<u(se,W))B[Ae]=W,B[ve]=se,ve=Ae;else break e}}function i(B){return B.length===0?null:B[0]}function r(B){if(B.length===0)return null;var W=B[0],ve=B.pop();if(ve!==W){B[0]=ve;e:for(var Ae=0,se=B.length,Se=se>>>1;Ae<Se;){var Me=2*(Ae+1)-1,xe=B[Me],pe=Me+1,ce=B[pe];if(0>u(xe,ve))pe<se&&0>u(ce,xe)?(B[Ae]=ce,B[pe]=ve,Ae=pe):(B[Ae]=xe,B[Me]=ve,Ae=Me);else if(pe<se&&0>u(ce,ve))B[Ae]=ce,B[pe]=ve,Ae=pe;else break e}}return W}function u(B,W){var ve=B.sortIndex-W.sortIndex;return ve!==0?ve:B.id-W.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var h=performance;e.unstable_now=function(){return h.now()}}else{var f=Date,b=f.now();e.unstable_now=function(){return f.now()-b}}var v=[],x=[],S=1,k=null,N=3,T=!1,z=!1,q=!1,E=!1,P=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;function $(B){for(var W=i(x);W!==null;){if(W.callback===null)r(x);else if(W.startTime<=B)r(x),W.sortIndex=W.expirationTime,n(v,W);else break;W=i(x)}}function F(B){if(q=!1,$(B),!z)if(i(v)!==null)z=!0,ae||(ae=!0,Ke());else{var W=i(x);W!==null&&Le(F,W.startTime-B)}}var ae=!1,V=-1,Z=5,X=-1;function Ce(){return E?!0:!(e.unstable_now()-X<Z)}function tt(){if(E=!1,ae){var B=e.unstable_now();X=B;var W=!0;try{e:{z=!1,q&&(q=!1,M(V),V=-1),T=!0;var ve=N;try{t:{for($(B),k=i(v);k!==null&&!(k.expirationTime>B&&Ce());){var Ae=k.callback;if(typeof Ae=="function"){k.callback=null,N=k.priorityLevel;var se=Ae(k.expirationTime<=B);if(B=e.unstable_now(),typeof se=="function"){k.callback=se,$(B),W=!0;break t}k===i(v)&&r(v),$(B)}else r(v);k=i(v)}if(k!==null)W=!0;else{var Se=i(x);Se!==null&&Le(F,Se.startTime-B),W=!1}}break e}finally{k=null,N=ve,T=!1}W=void 0}}finally{W?Ke():ae=!1}}}var Ke;if(typeof L=="function")Ke=function(){L(tt)};else if(typeof MessageChannel<"u"){var Ue=new MessageChannel,ke=Ue.port2;Ue.port1.onmessage=tt,Ke=function(){ke.postMessage(null)}}else Ke=function(){P(tt,0)};function Le(B,W){V=P(function(){B(e.unstable_now())},W)}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(B){B.callback=null},e.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Z=0<B?Math.floor(1e3/B):5},e.unstable_getCurrentPriorityLevel=function(){return N},e.unstable_next=function(B){switch(N){case 1:case 2:case 3:var W=3;break;default:W=N}var ve=N;N=W;try{return B()}finally{N=ve}},e.unstable_requestPaint=function(){E=!0},e.unstable_runWithPriority=function(B,W){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var ve=N;N=B;try{return W()}finally{N=ve}},e.unstable_scheduleCallback=function(B,W,ve){var Ae=e.unstable_now();switch(typeof ve=="object"&&ve!==null?(ve=ve.delay,ve=typeof ve=="number"&&0<ve?Ae+ve:Ae):ve=Ae,B){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=ve+se,B={id:S++,callback:W,priorityLevel:B,startTime:ve,expirationTime:se,sortIndex:-1},ve>Ae?(B.sortIndex=ve,n(x,B),i(v)===null&&B===i(x)&&(q?(M(V),V=-1):q=!0,Le(F,ve-Ae))):(B.sortIndex=se,n(v,B),z||T||(z=!0,ae||(ae=!0,Ke()))),B},e.unstable_shouldYield=Ce,e.unstable_wrapCallback=function(B){var W=N;return function(){var ve=N;N=W;try{return B.apply(this,arguments)}finally{N=ve}}}})(uf)),uf}var vx;function _6(){return vx||(vx=1,cf.exports=C6()),cf.exports}var xx;function T6(){if(xx)return cc;xx=1;var e=_6(),n=F5(),i=Z5();function r(t){var a="https://react.dev/errors/"+t;if(1<arguments.length){a+="?args[]="+encodeURIComponent(arguments[1]);for(var s=2;s<arguments.length;s++)a+="&args[]="+encodeURIComponent(arguments[s])}return"Minified React error #"+t+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function u(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function h(t){var a=t,s=t;if(t.alternate)for(;a.return;)a=a.return;else{t=a;do a=t,(a.flags&4098)!==0&&(s=a.return),t=a.return;while(t)}return a.tag===3?s:null}function f(t){if(t.tag===13){var a=t.memoizedState;if(a===null&&(t=t.alternate,t!==null&&(a=t.memoizedState)),a!==null)return a.dehydrated}return null}function b(t){if(t.tag===31){var a=t.memoizedState;if(a===null&&(t=t.alternate,t!==null&&(a=t.memoizedState)),a!==null)return a.dehydrated}return null}function v(t){if(h(t)!==t)throw Error(r(188))}function x(t){var a=t.alternate;if(!a){if(a=h(t),a===null)throw Error(r(188));return a!==t?null:t}for(var s=t,c=a;;){var p=s.return;if(p===null)break;var g=p.alternate;if(g===null){if(c=p.return,c!==null){s=c;continue}break}if(p.child===g.child){for(g=p.child;g;){if(g===s)return v(p),t;if(g===c)return v(p),a;g=g.sibling}throw Error(r(188))}if(s.return!==c.return)s=p,c=g;else{for(var w=!1,A=p.child;A;){if(A===s){w=!0,s=p,c=g;break}if(A===c){w=!0,c=p,s=g;break}A=A.sibling}if(!w){for(A=g.child;A;){if(A===s){w=!0,s=g,c=p;break}if(A===c){w=!0,c=g,s=p;break}A=A.sibling}if(!w)throw Error(r(189))}}if(s.alternate!==c)throw Error(r(190))}if(s.tag!==3)throw Error(r(188));return s.stateNode.current===s?t:a}function S(t){var a=t.tag;if(a===5||a===26||a===27||a===6)return t;for(t=t.child;t!==null;){if(a=S(t),a!==null)return a;t=t.sibling}return null}var k=Object.assign,N=Symbol.for("react.element"),T=Symbol.for("react.transitional.element"),z=Symbol.for("react.portal"),q=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),L=Symbol.for("react.context"),$=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),ae=Symbol.for("react.suspense_list"),V=Symbol.for("react.memo"),Z=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),Ce=Symbol.for("react.memo_cache_sentinel"),tt=Symbol.iterator;function Ke(t){return t===null||typeof t!="object"?null:(t=tt&&t[tt]||t["@@iterator"],typeof t=="function"?t:null)}var Ue=Symbol.for("react.client.reference");function ke(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===Ue?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case q:return"Fragment";case P:return"Profiler";case E:return"StrictMode";case F:return"Suspense";case ae:return"SuspenseList";case X:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case z:return"Portal";case L:return t.displayName||"Context";case M:return(t._context.displayName||"Context")+".Consumer";case $:var a=t.render;return t=t.displayName,t||(t=a.displayName||a.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case V:return a=t.displayName||null,a!==null?a:ke(t.type)||"Memo";case Z:a=t._payload,t=t._init;try{return ke(t(a))}catch{}}return null}var Le=Array.isArray,B=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ve={pending:!1,data:null,method:null,action:null},Ae=[],se=-1;function Se(t){return{current:t}}function Me(t){0>se||(t.current=Ae[se],Ae[se]=null,se--)}function xe(t,a){se++,Ae[se]=t.current,t.current=a}var pe=Se(null),ce=Se(null),ue=Se(null),_e=Se(null);function Fe(t,a){switch(xe(ue,a),xe(ce,t),xe(pe,null),a.nodeType){case 9:case 11:t=(t=a.documentElement)&&(t=t.namespaceURI)?Uv(t):0;break;default:if(t=a.tagName,a=a.namespaceURI)a=Uv(a),t=Vv(a,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}Me(pe),xe(pe,t)}function Ee(){Me(pe),Me(ce),Me(ue)}function Ct(t){t.memoizedState!==null&&xe(_e,t);var a=pe.current,s=Vv(a,t.type);a!==s&&(xe(ce,t),xe(pe,s))}function me(t){ce.current===t&&(Me(pe),Me(ce)),_e.current===t&&(Me(_e),sc._currentValue=ve)}var Be,Ne;function re(t){if(Be===void 0)try{throw Error()}catch(s){var a=s.stack.trim().match(/\n( *(at )?)/);Be=a&&a[1]||"",Ne=-1<s.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
4
|
`+Be+t+Ne}var Ze=!1;function bt(t,a){if(!t||Ze)return"";Ze=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(a){var ie=function(){throw Error()};if(Object.defineProperty(ie.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ie,[])}catch(Y){var Q=Y}Reflect.construct(t,[],ie)}else{try{ie.call()}catch(Y){Q=Y}t.call(ie.prototype)}}else{try{throw Error()}catch(Y){Q=Y}(ie=t())&&typeof ie.catch=="function"&&ie.catch(function(){})}}catch(Y){if(Y&&Q&&typeof Y.stack=="string")return[Y.stack,Q.stack]}return[null,null]}};c.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var p=Object.getOwnPropertyDescriptor(c.DetermineComponentFrameRoot,"name");p&&p.configurable&&Object.defineProperty(c.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=c.DetermineComponentFrameRoot(),w=g[0],A=g[1];if(w&&A){var D=w.split(`
|
|
@@ -61,7 +61,7 @@ ${JSON.stringify(r.raw,null,2)}`):n.push(u)}return n.length>0?n.join(`
|
|
|
61
61
|
`)){if(!ae.startsWith("data:"))continue;const V=ae.slice(5).trim();if(!V)continue;let Z;try{Z=JSON.parse(V)}catch{continue}Z.type==="stream_close"&&(T=!0),S(Z)}$=E.indexOf(`
|
|
62
62
|
|
|
63
63
|
`)}}if(x?.aborted)throw new DOMException("Turn stopped","AbortError");if(!T)throw new Error("Connection ended before Aero finished. Review the partial answer before retrying.")}finally{x?.removeEventListener("abort",P);try{z.releaseLock()}catch{}}}function Ld(e){return!e||e.role!=="assistant"?"":e.content.filter(n=>n.type==="text").map(n=>n.text).join("")}const Mg=[{id:"status",label:"Status",prompt:"Give me a quick status: the latest sweep, which engines answered, and anything that needs attention."},{id:"changes",label:"What changed",prompt:"Compare the latest complete sweep with the one before it. Lead with mentions, then citations. Keep branded and non-brand queries separate if the project splits them, and say which changes are bigger than normal run-to-run noise."},{id:"gaps",label:"Biggest gaps",prompt:"Which tracked queries does no engine mention us on, and who gets named instead? Group them by topic or market."},{id:"insights",label:"Top insights",prompt:"Walk me through the 3 most severe active insights and what to do about each."}],$X="https://canonry.ai",KX="This demo plays sample answers only. Pick a starting point, or type / to choose one.",GX="Stopped. The sample answer so far is kept.";function GS(e){return{queryKey:["aero-preview",e],queryFn:()=>LX(e),staleTime:1/0,gcTime:1/0}}const HS=[{command:"/status",label:"Status",prompt:"Give me a quick status: the latest sweep, which engines answered, and anything that needs attention."},{command:"/changes",label:"What changed",prompt:"Compare the latest complete sweep with the one before it. Lead with mentions, then citations. Keep branded and non-brand queries separate if the project splits them, and say which changes are bigger than normal run-to-run noise."},{command:"/gaps",label:"Biggest gaps",prompt:"Which tracked queries does no engine mention us on, and who gets named instead? Group them by topic or market."},{command:"/insights",label:"Top insights",prompt:"Walk me through the 3 most severe active insights and what to do about each."},{command:"/last-run",label:"Last run",prompt:"Summarize the latest run for this project: which engines answered, what moved in mentions and citations, and anything that failed."},{command:"/run-sweep",label:"Run sweep now",prompt:"Run a new answer-visibility sweep for this project now and tell me when it lands."},{command:"/queries",label:"Queries",prompt:"List the tracked queries for this project and flag any that are obvious duplicates or underperformers."},{command:"/competitors",label:"Competitors",prompt:"Which competitors do engines name most often on queries where we are not named, and on which engines?"},{command:"/new",label:"New conversation (save current)",action:"new"}],Ed=e=>`canonry:aero:provider:${e}`,HX=e=>`canonry:aero:scope:${e}`;function QS(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function QX(e,n){if(!(typeof window>"u"))try{window.localStorage.setItem(e,n)}catch{}}function FS(e){if(!(typeof window>"u"))try{window.localStorage.removeItem(e)}catch{}}function FX({projectName:e,context:n,preview:i=j1()}){const r=bo(),{canWrite:u,account:h}=fa(),f=Ds(),b=h?.role==="viewer",[v,x]=C.useState(!1),[S,k]=C.useState(!1),[N,T]=C.useState([]),[z,q]=C.useState(void 0),E=C.useRef(!1),[P,M]=C.useState(!1),[L,$]=C.useState(!1),[F,ae]=C.useState(null),[V,Z]=C.useState(!1),[X,Ce]=C.useState(!1),[tt,Ke]=C.useState(null),Ue=C.useRef(!1),[ke,Le]=C.useState(""),[B,W]=C.useState(!1),[ve,Ae]=C.useState([]),[se,Se]=C.useState(""),[Me,xe]=C.useState(null),[pe,ce]=C.useState(null),[ue,_e]=C.useState(null),Fe=C.useRef(!0),[Ee,Ct]=C.useState(()=>QS(Ed(e))??null),me=r||b||i?null:Ee,[Be]=C.useState(()=>QS(HX(e))==="all"?"all":"read-only"),Ne=r||b||i?"read-only":Be,re=C.useRef(null),Ze=C.useRef(null),bt=C.useRef(null),qn=C.useRef(null),{ref:Ht}=kX([N,se,ve]),Ve=C.useRef(null);C.useLayoutEffect(()=>{const oe=Ve.current;if(!oe)return;oe.style.height="auto";const ze=S?XX:YX;oe.scrollHeight>0&&(oe.style.height=`${Math.min(oe.scrollHeight,ze)}px`)},[ke,S,v]);const[ct,Qt]=C.useState(0),Ft=C.useMemo(()=>{const oe=ke.trimStart();if(!oe.startsWith("/"))return[];if(/\s/.test(oe))return[];const ze=oe.toLowerCase();return HS.filter(Je=>(!(r||b)||Je.command!=="/run-sweep")&&(!b||Je.action!=="new")&&(!i||Mg.some(Ot=>Ot.prompt===Je.prompt))&&(Je.command.startsWith(ze)||Je.label.toLowerCase().includes(ze.slice(1))))},[ke,r,b,i]);C.useEffect(()=>{Qt(oe=>Ft.length===0?0:Math.min(oe,Ft.length-1))},[Ft.length]);const En=yt({...lZ({client:J,path:{name:e}}),enabled:!b&&!i,staleTime:6e4}),Vt=C.useMemo(()=>{const oe=En.data?.providers??[];if(me){const Je=oe.find(Ot=>Ot.id===me&&Ot.configured);if(Je)return Je}const ze=En.data?.defaultProvider;return ze?oe.find(Je=>Je.id===ze)??null:null},[me,En.data]),di=b||i||Vt!==null;yt({...GS(e),enabled:i&&v}),C.useEffect(()=>{if(!En.data||!me)return;En.data.providers.find(ze=>ze.id===me&&ze.configured)||(Ct(null),FS(Ed(e)))},[En.data,me,e]);const Vs=C.useCallback(oe=>{Ct(oe),oe?QX(Ed(e),oe):FS(Ed(e))},[e]);C.useEffect(()=>{if(!v)return;const oe=ze=>{ze.key==="Escape"&&(L?$(!1):S?k(!1):x(!1))};return window.addEventListener("keydown",oe),()=>window.removeEventListener("keydown",oe)},[v,S,L]);const mi=C.useRef(null);C.useEffect(()=>{v||(mi.current=null)},[v]),C.useEffect(()=>{if(!v||!di||i)return;let oe=!1;mi.current!==e&&(mi.current=e,xe(null));const ze=()=>{oe||B||Ue.current||Qf(e).then(et=>{oe||Ue.current||(Ce(et.isStreaming??!1),q(et.conversationId??null),!oe&&!et.isStreaming&&(Ze.current===null||et.updatedAt&&et.updatedAt!==Ze.current.previous)&&(T(et.messages),re.current=et.updatedAt,Ze.current=null))}).catch(et=>{oe||xe(qi(et))})};ze();const Ot=window.setInterval(ze,15e3);return()=>{oe=!0,window.clearInterval(Ot)}},[v,e,B,di,V,i]),C.useEffect(()=>(Fe.current=!0,()=>{Fe.current=!1,qn.current?.abort()}),[e]);async function Rn(oe,ze=n){const Je=oe.trim();if(!Je||L||B||V||Ue.current||X||!di)return;if(i){await Uo(Je);return}if(r&&/^\/run-sweep(?:\s|$)/i.test(Je)){xe(Pg);return}xe(null),ce(null),_e({prompt:Je,context:ze}),Le(""),W(!0),Se(""),bt.current=null,Ae([]),Ze.current={previous:re.current};const Ot={role:"user",content:Je,timestamp:Date.now(),aeroContext:ze};T(kt=>[...kt,Ot]);const et=new AbortController;qn.current=et;try{await VX({project:e,prompt:Je,conversationId:z,provider:me??void 0,scope:Ne,context:ze,signal:et.signal,onEvent:$s});const kt=await Qf(e);Fe.current&&!kt.isStreaming&&(q(kt.conversationId??null),T(kt.messages),re.current=kt.updatedAt,Ze.current=null)}catch(kt){if(!Fe.current)return;b&&(Ze.current=null);const sn=bt.current;sn&&Ld(sn).trim()&&T(hi=>[...hi,sn]),et.signal.aborted?ce("Stopped. Partial response preserved. An action already dispatched may still finish."):xe(qi(kt))}finally{Fe.current&&(W(!1),Se(""),Ae(kt=>kt.map(sn=>sn.endedAt===void 0?{...sn,interrupted:!0}:sn))),qn.current=null}}async function Uo(oe){const ze=HS.find(et=>et.command===oe.toLowerCase())?.prompt??oe,Je=Mg.find(et=>et.prompt===ze)?.id;if(!Je){xe(null),_e(null),ce(KX);return}xe(null),ce(null),_e({prompt:ze}),Le(""),W(!0),Se(""),bt.current=null,Ae([]),T(et=>[...et,{role:"user",content:ze,timestamp:Date.now()}]);const Ot=new AbortController;qn.current=Ot;try{const et=await f.ensureQueryData(GS(e));if(Ot.signal.aborted)throw new DOMException("Preview stopped","AbortError");const kt=et.starters.find(sn=>sn.id===Je);if(!kt)throw new Error("This demo has no sample answer for that starting point.");await MX({starter:kt,signal:Ot.signal,onEvent:$s,reducedMotion:IX()})}catch(et){if(!Fe.current)return;const kt=bt.current;kt&&Ld(kt).trim()&&T(sn=>[...sn,kt]),Ot.signal.aborted?ce(GX):xe(qi(et))}finally{Fe.current&&(W(!1),Se(""),Ae(et=>et.map(kt=>kt.endedAt===void 0?{...kt,interrupted:!0}:kt))),qn.current=null}}function $s(oe){if(Fe.current)switch(oe.type){case"message_update":oe.message.role==="assistant"&&(bt.current=oe.message),Se(Ld(oe.message));break;case"message_end":if(oe.message.role!=="user"){const ze=oe.message;T(Je=>[...Je,ze])}oe.message.role==="assistant"&&(bt.current=null,Se(""),oe.message.errorMessage&&xe(oe.message.errorMessage));break;case"aero_turn_status":oe.status?.reason==="tool-limit"?ce("Tool-call limit reached. Partial response preserved."):oe.status?.reason==="time-limit"?ce("Time limit reached. Partial response preserved."):oe.status?.reason==="completed"?_e(null):oe.status?.reason==="error"&&xe(ze=>ze??"Aero could not finish this answer. Retry to ask again.");break;case"tool_execution_start":Ae(ze=>[...ze,{id:oe.toolCallId,name:oe.toolName,label:oe.label,args:oe.args,startedAt:Date.now()}]);break;case"tool_execution_end":Ae(ze=>ze.map(Je=>Je.id===oe.toolCallId?{...Je,endedAt:Date.now(),isError:oe.isError,result:oe.result}:Je));break;case"error":xe(oe.message);break}}async function Ks(oe,ze=!1){if(!(B||X||Ue.current)){Ue.current=!0,Z(!0),xe(null);try{await oe();const Je=await Qf(e);if(!Fe.current)return;Ze.current=null,re.current=Je.updatedAt,q(Je.conversationId??null),T(Je.messages),Ae([]),Se(""),ce(null),_e(null),Ke(null),$(ze),ae(ze?await gS(e):null),Ve.current?.focus()}catch(Je){Fe.current&&xe(qi(Je))}finally{Ue.current=!1,Fe.current&&Z(!1)}}}async function pi(){if(i){if(B)return;T([]),Ae([]),Se(""),xe(null),ce(null),_e(null),Ve.current?.focus();return}await Ks(()=>b?UX(e):RH(e,crypto.randomUUID()))}async function vn(oe=!1){if(!(Ue.current||E.current)){E.current=!0,M(!0),$(!0),xe(null);try{const ze=await gS(e,{offset:oe?F?.nextOffset??0:0});Fe.current&&ae(Je=>oe&&Je?{...ze,conversations:[...Je.conversations,...ze.conversations]}:ze)}catch(ze){Fe.current&&xe(qi(ze))}finally{E.current=!1,Fe.current&&M(!1)}}}const Et=N.length===0,$n=!(b||i);if($n&&En.isPending)return null;if($n&&En.isError)return l.jsx("div",{className:"pointer-events-none fixed inset-x-0 bottom-0 z-40 flex justify-center p-3",children:l.jsxs("div",{role:"status",className:"flex w-full max-w-3xl flex-wrap items-center gap-x-2 gap-y-1 rounded-lg border border-base bg-bg/95 px-4 py-2 text-sm shadow-lg",children:[l.jsx(hd,{className:"h-4 w-4 text-muted","aria-hidden":"true"}),l.jsx("span",{className:"font-medium text-strong",children:"Aero could not check provider availability."}),l.jsx(le,{variant:"outline",size:"sm",className:"pointer-events-auto ml-auto",onClick:()=>{En.refetch()},children:"Try again"})]})});const Zt=Vt&&!Vt.configured?Vt:null;if($n&&(!Vt||Zt))return l.jsx("div",{className:"pointer-events-none fixed inset-x-0 bottom-0 z-40 flex justify-center p-3",children:l.jsxs("div",{role:"status",className:"flex w-full max-w-3xl flex-wrap items-center gap-x-2 gap-y-1 rounded-lg border border-base bg-bg/95 px-4 py-2 text-sm shadow-lg",children:[l.jsx(hd,{className:"h-4 w-4 text-muted","aria-hidden":"true"}),l.jsxs("span",{className:"flex items-center gap-1.5 font-medium text-strong",children:[Zt?`Aero is set to ${Zt.label.replace(/\s+\(.+\)$/,"")}, which has no API key.`:"Aero needs an answer-engine provider.",l.jsx(ua,{text:Zt?`Set ${_C(Zt.id)} on the server, or providers.${Zt.id}.apiKey in its config.yaml.`:"Aero is the built-in AEO analyst. It reads your Canonry data with you once a provider is connected."})]}),Zt?null:u?l.jsx(le,{asChild:!0,variant:"outline",size:"sm",className:"pointer-events-auto ml-auto",children:l.jsx(at,{to:"/settings",children:"Open Settings"})}):l.jsx("span",{className:"ml-auto text-secondary",children:"Ask an administrator to configure one."})]})});const Gs=v&&S?"pointer-events-auto fixed inset-0 z-40 flex items-stretch justify-center bg-bg/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",Oa=S?"pointer-events-auto flex h-full w-full max-w-5xl flex-col overflow-hidden rounded-2xl border border-mono-800/80 bg-bg/95 shadow-2xl":"pointer-events-auto w-full max-w-3xl",ea=S?"flex-1 overflow-y-auto px-6 py-5 text-sm text-strong":"max-h-[40vh] min-h-[120px] overflow-y-auto px-4 py-3 text-sm text-strong";return l.jsx("div",{className:Gs,onClick:oe=>{S&&oe.target===oe.currentTarget&&k(!1)},children:l.jsx("div",{className:Oa,children:v?l.jsxs("div",{"data-aero-panel":!0,className:S?"flex h-full flex-col":"flex flex-col overflow-hidden rounded-2xl border border-mono-800/80 bg-bg/95 shadow-xl backdrop-blur",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-mono-800/70 px-4 py-2.5",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(hd,{className:"h-4 w-4 text-positive-400","aria-hidden":"true"}),l.jsx("span",{className:"text-sm font-medium text-heading",children:"Aero"}),l.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted",children:B||X?"working…":e})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[!r&&!b&&!i&&l.jsx(ZX,{providers:En.data?.providers??[],active:Vt,override:me,onPick:Vs,disabled:B}),l.jsx("button",{type:"button",onClick:()=>k(oe=>!oe),className:"rounded-md p-1.5 text-muted transition hover:bg-surface-inset hover:text-strong","aria-label":S?"Collapse":"Expand",title:S?"Collapse":"Expand",children:S?l.jsx(o6,{className:"h-3.5 w-3.5","aria-hidden":"true"}):l.jsx(r6,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),l.jsx("button",{type:"button",onClick:()=>{k(!1),x(!1)},className:"rounded-md p-1.5 text-muted transition hover:bg-surface-inset hover:text-strong","aria-label":"Close Aero",children:l.jsx(Gr,{className:"h-4 w-4","aria-hidden":"true"})})]})]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-subtle px-4 py-2",children:[l.jsxs(le,{variant:"outline",size:"sm",disabled:B||X||V,onClick:fn(pi),title:b||i?"Clear this conversation and start fresh.":"Save this conversation and start fresh. Shared project notes are kept.",children:[l.jsx(Jf,{className:"h-3.5 w-3.5","aria-hidden":"true"})," New conversation"]}),!b&&!i&&l.jsxs(le,{variant:"ghost",size:"sm","aria-expanded":L,"aria-controls":"aero-history",disabled:V,onClick:()=>{L?$(!1):vn()},children:[l.jsx(jk,{className:"h-3.5 w-3.5","aria-hidden":"true"})," History"]})]}),L?l.jsxs("div",{id:"aero-history",className:ea,"aria-label":"Conversation history",children:[l.jsxs("h3",{className:"mb-2 text-sm font-medium text-heading",children:["Conversations in ",e]}),F?F.conversations.length===0?l.jsx("p",{className:"text-sm text-secondary",children:"No saved conversations yet. Your conversations will appear here."}):l.jsx("ul",{className:"divide-y divide-default",children:F.conversations.map(oe=>l.jsxs("li",{className:"py-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("button",{className:"min-w-0 flex-1 rounded-md px-2 py-1 text-left hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-positive-500",disabled:B||X||V,onClick:()=>{oe.active?$(!1):Ks(()=>DH(e,oe.id))},children:[l.jsx("span",{className:"block truncate text-sm text-heading",children:oe.title}),l.jsxs("span",{className:"text-xs text-secondary",children:[oe.active?"Current · ":"",new Date(oe.updatedAt).toLocaleString()]})]}),l.jsx(le,{variant:"ghost",size:"sm",disabled:B||X||V,"aria-label":`Delete conversation: ${oe.title}`,onClick:()=>Ke(oe.id),children:"Delete"})]}),tt===oe.id&&l.jsxs("div",{role:"group","aria-label":"Confirm conversation deletion",className:"mt-2 rounded-md border border-default p-3 text-sm text-secondary",children:[l.jsx("p",{children:"Delete this conversation permanently? Shared project notes will be kept."}),l.jsxs("div",{className:"mt-2 flex gap-2",children:[l.jsx(le,{variant:"destructive",size:"sm",disabled:V,onClick:()=>{Ks(async()=>{await zH(e,oe.id)},!0)},children:"Delete conversation"}),l.jsx(le,{variant:"ghost",size:"sm",disabled:V,onClick:()=>Ke(null),children:"Cancel"})]})]})]},oe.id))}):l.jsx("p",{className:"text-sm text-secondary",children:P?"Loading history…":"History could not be loaded. Close and reopen History to retry."}),F?.nextOffset!=null&&l.jsx(le,{variant:"ghost",size:"sm",disabled:P,onClick:()=>{vn(!0)},children:P?"Loading…":"Load more"})]}):l.jsxs("div",{ref:Ht,className:ea,children:[Et&&!B&&l.jsxs("div",{className:"flex flex-col gap-3 py-2",children:[l.jsx("p",{className:"text-sm text-secondary",children:i?l.jsxs(l.Fragment,{children:["See how Aero answers about ",l.jsx("span",{className:"text-strong",children:e}),". Choose a starting point."]}):l.jsxs(l.Fragment,{children:["Ask about ",l.jsx("span",{className:"text-strong",children:e})," or choose a starting point."]})}),l.jsx(ZS,{onPick:oe=>{Rn(oe)}})]}),tJ(N,e,me,Ne,ve,B,!!se.trim(),!b&&!i),B&&se&&l.jsxs("div",{className:"mt-3",children:[l.jsx("div",{className:"mb-0.5 text-[10px] uppercase tracking-wider text-positive-400",children:"Aero"}),l.jsx(RC,{content:se})]}),B&&!se&&ve.every(oe=>oe.endedAt!==void 0)&&l.jsx(dJ,{}),i&&!Et&&!B&&l.jsxs("div",{className:"mt-4 flex flex-col gap-2 border-t border-subtle pt-3",children:[l.jsx("p",{className:"text-xs text-secondary",children:"Try another starting point."}),l.jsx(ZS,{onPick:oe=>{Rn(oe)}})]})]}),(Me||pe)&&l.jsxs("div",{role:Me?"alert":"status",className:"mx-3 my-2 flex flex-wrap items-center gap-2 rounded-md border border-base bg-surface px-3 py-2 text-sm text-secondary",children:[l.jsx("span",{className:"flex-1",children:Me??pe}),ue&&!B&&l.jsx(le,{variant:"outline",size:"sm",onClick:()=>{Ne==="all"?(Le(ue.prompt),Ve.current?.focus()):Rn(ue.prompt,ue.context)},children:Ne==="all"?"Review prompt":"Retry"})]}),i&&l.jsxs("p",{className:"border-t border-subtle px-4 py-2 text-xs text-secondary",children:["Sample answers on demo data."," ",l.jsxs("a",{href:$X,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-0.5 text-positive-400 underline decoration-positive-700 hover:decoration-positive-400",children:["Aero answers from your own Canonry data.",l.jsx(Sk,{className:"h-3 w-3","aria-hidden":"true"}),l.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]})]}),l.jsxs("div",{className:"relative",children:[!L&&Ft.length>0&&l.jsx(WX,{title:i?"Starting points":"Commands",matches:Ft,selectedIndex:ct,onHover:Qt,onPick:oe=>{Le(""),Ve.current?.focus(),oe.action==="new"?pi():Rn(oe.prompt)}}),l.jsxs("form",{className:"flex items-end gap-2 border-t border-mono-800/70 bg-bg/80 px-3 py-2.5",onSubmit:oe=>{if(oe.preventDefault(),Ft.length>0){const ze=Ft[ct];Le(""),ze.action==="new"?pi():Rn(ze.prompt);return}Rn(ke)},children:[l.jsx("textarea",{ref:Ve,value:ke,onChange:oe=>Le(oe.target.value),onKeyDown:oe=>{if(Ft.length>0){if(oe.key==="ArrowDown"){oe.preventDefault(),Qt(ze=>(ze+1)%Ft.length);return}if(oe.key==="ArrowUp"){oe.preventDefault(),Qt(ze=>(ze-1+Ft.length)%Ft.length);return}if(oe.key==="Tab"){oe.preventDefault();const ze=Ft[ct];Le(`${ze.command} `);return}if(oe.key==="Escape"){oe.preventDefault(),Le("");return}}if(oe.key==="Enter"&&!oe.shiftKey)if(oe.preventDefault(),Ft.length>0){const ze=Ft[ct];Le(""),ze.action==="new"?pi():Rn(ze.prompt)}else Rn(ke)},disabled:L||V,placeholder:L?"Open a conversation to continue…":i?"Type / for a starting point":"Ask Aero, or / for commands…","aria-label":"Message Aero",rows:S?3:1,className:"flex-1 resize-none overflow-y-auto bg-transparent text-sm text-heading placeholder:text-mono-600 focus:outline-none disabled:opacity-60"}),B?l.jsxs(le,{type:"button",variant:"outline",size:"sm",onClick:()=>qn.current?.abort(),"aria-label":"Stop Aero",children:[l.jsx(Ak,{className:"h-3.5 w-3.5","aria-hidden":"true"})," Stop"]}):l.jsx(le,{type:"submit",size:"sm",disabled:!ke.trim()||L||V||X,"aria-label":"Send",children:l.jsx(l6,{className:"h-4 w-4","aria-hidden":"true"})})]})]})]}):l.jsx("button",{type:"button",onClick:()=>{x(!0),il("aero.open")},className:"flex w-full items-center justify-between rounded-lg border border-mono-800/80 bg-bg/95 px-4 py-2 text-left text-sm text-secondary shadow-lg transition hover:border-strong hover:bg-bg-elevated/90 hover:text-strong",children:l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(hd,{className:"h-4 w-4 text-positive-400","aria-hidden":"true"}),"Ask Aero about ",e,"…"]})})})})}function ZX({providers:e,active:n,override:i,onPick:r,disabled:u}){const[h,f]=C.useState(!1),b=C.useRef(null);if(C.useEffect(()=>{if(!h)return;const x=k=>{b.current?.contains(k.target)||f(!1)},S=k=>{k.key==="Escape"&&f(!1)};return window.addEventListener("mousedown",x),window.addEventListener("keydown",S),()=>{window.removeEventListener("mousedown",x),window.removeEventListener("keydown",S)}},[h]),e.length===0)return null;const v=n?.label.replace(/\s+\(.+\)$/,"")??"No provider";return l.jsxs("div",{ref:b,className:"relative",children:[l.jsxs("button",{type:"button",onClick:()=>f(x=>!x),disabled:u,className:"flex items-center gap-1 rounded-md px-2 py-1 text-sm text-secondary transition hover:bg-surface-inset hover:text-strong disabled:opacity-50","aria-label":"Switch agent model","aria-haspopup":"listbox","aria-expanded":h,title:n?`${n.label} · ${n.defaultModel}`:"Pick a provider",children:[l.jsx("span",{className:"font-medium text-strong",children:v}),l.jsx(Lc,{className:"h-3 w-3","aria-hidden":"true"})]}),h&&l.jsxs("div",{role:"listbox",className:"absolute right-0 top-full z-50 mt-1 w-64 overflow-hidden rounded-lg border border-base bg-bg shadow-xl",children:[l.jsx("div",{className:"border-b border-default px-3 py-2 text-sm font-medium text-secondary",children:"Answer engine"}),l.jsx("ul",{className:"max-h-72 overflow-y-auto py-1",children:e.map(x=>{const S=n?.id===x.id,k=i===x.id;return l.jsx("li",{children:l.jsxs("button",{type:"button",role:"option","aria-selected":S,disabled:!x.configured,onClick:()=>{x.configured&&(r(k?null:x.id),f(!1))},className:"flex w-full items-center gap-2 px-3 py-2.5 text-left text-sm transition enabled:hover:bg-bg-elevated disabled:cursor-not-allowed disabled:opacity-60",title:x.configured?x.defaultModel:`Add ${_C(x.id)} in Settings or your environment`,children:[l.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:S?l.jsx(Uc,{className:"h-3 w-3 text-positive-400","aria-hidden":"true"}):null}),l.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-heading",children:x.label.replace(/\s+\(.+\)$/,"")}),k&&l.jsx("span",{className:"rounded-md border border-positive-800/60 bg-positive-950/60 px-2 py-0.5 text-[11px] text-positive",children:"Selected"}),!x.configured&&l.jsx("span",{className:"rounded-md border border-base px-2 py-0.5 text-[11px] text-secondary",children:"Needs setup"})]})},x.id)})}),i&&l.jsx("button",{type:"button",onClick:()=>{r(null),f(!1)},className:"w-full border-t border-default px-3 py-2 text-left text-[11px] text-secondary transition hover:bg-bg-elevated hover:text-heading",children:"Reset to default"})]})]})}const YX=144,XX=288,Ff=288,JX=8;function WX({title:e,matches:n,selectedIndex:i,onHover:r,onPick:u}){const h=C.useRef(null),f=C.useRef(null),b=C.useRef(null),[v,x]=C.useState(Ff);return C.useLayoutEffect(()=>{const S=h.current,k=S?.closest("[data-aero-panel]"),N=S?.parentElement;if(!S||!k||!N)return;const T=N.getBoundingClientRect().top-k.getBoundingClientRect().top-JX*2-(f.current?.getBoundingClientRect().height??0);x(T>0?Math.min(Ff,Math.floor(T)):Ff)},[n.length]),C.useEffect(()=>{b.current?.querySelector('[aria-selected="true"]')?.scrollIntoView?.({block:"nearest"})},[i]),l.jsxs("div",{ref:h,className:"absolute inset-x-3 bottom-full mb-2 overflow-hidden rounded-lg border border-base bg-bg/98 shadow-2xl",children:[l.jsx("div",{ref:f,className:"border-b border-default px-3 py-1.5 text-[10px] uppercase tracking-wider text-muted",children:e}),l.jsx("ul",{ref:b,role:"listbox",className:"overflow-y-auto py-1",style:{maxHeight:v},children:n.map((S,k)=>{const N=k===i;return l.jsx("li",{children:l.jsxs("button",{type:"button",role:"option","aria-selected":N,onMouseEnter:()=>r(k),onClick:()=>u(S),className:`flex w-full items-center gap-3 px-3 py-2 text-left text-sm transition ${N?"bg-bg-elevated text-heading":"text-neutral hover:bg-bg-elevated/60"}`,children:[l.jsx("span",{className:"font-medium",children:S.label}),l.jsx("span",{className:"ml-auto font-mono text-[11px] text-secondary",children:S.command})]})},S.command)})})]})}function ZS({onPick:e}){return l.jsx("div",{className:"flex flex-wrap gap-1.5",children:Mg.map(n=>l.jsx("button",{type:"button",onClick:()=>e(n.prompt),className:"rounded-md border border-base bg-bg-elevated/70 px-3 py-1.5 text-sm text-neutral transition hover:border-strong hover:bg-mono-800/70 hover:text-heading",children:n.label},n.label))})}function _C(e){switch(e){case"claude":return"ANTHROPIC_API_KEY";case"openai":return"OPENAI_API_KEY";case"gemini":return"GEMINI_API_KEY";case"zai":return"ZAI_API_KEY"}}function eJ(e,n){const i=e.timestamp??0;return`${e.role}:${i}:${n}`}function tJ(e,n,i,r,u,h,f,b=!0){const v=[];let x=[],S=0;for(let N=e.length-1;N>=0;N--)if(e[N].role==="user"){S=N+1;break}const k=(N=!1)=>{x.length!==0&&(v.push(l.jsx(cJ,{trails:x,betweenSteps:N&&h&&!f},`tools:${x[0].id}`)),x=[])};for(let N=0;N<e.length;N++){const T=e[N],z=eJ(T,N);if(T.role==="user"){k();const q=typeof T.content=="string"?T.content:JSON.stringify(T.content);if(q.startsWith("[system]"))continue;v.push(l.jsx(nJ,{text:q,projectName:n,providerOverride:i,scope:r,context:T.aeroContext,cliCopy:b},z));continue}if(T.role==="assistant"){const q=new Map;let E=N+1;for(;E<e.length&&e[E].role==="toolResult";){const $=e[E];q.set($.toolCallId,$),E++}const P=h&&N>=S,M=iJ(T,q).map($=>{const F=u.find(V=>V.id===$.id),ae={...$,...F,label:$.label??F?.label};return{...ae,interrupted:ae.endedAt===void 0&&(!P||ae.interrupted)}}),L=Ld(T);L.trim()&&(k(),v.push(l.jsxs("div",{className:"mt-3",children:[l.jsx("div",{className:"mb-0.5 text-[10px] uppercase tracking-wider text-positive-400",children:"Aero"}),l.jsx(RC,{content:L})]},z))),x.push(...M),N=E-1;continue}}return k(!0),v}function nJ({text:e,projectName:n,providerOverride:i,scope:r,context:u,cliCopy:h=!0}){const[f,b]=C.useState(!1),v=C.useMemo(()=>aJ(n,e,i,r,u),[n,e,i,r,u]);async function x(){try{await navigator.clipboard.writeText(v),b(!0),window.setTimeout(()=>b(!1),1500)}catch{}}return l.jsxs("div",{className:"group relative mt-3 rounded-md bg-bg-elevated/60 px-3 py-2 text-strong",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted",children:"You"}),h&&l.jsx("button",{type:"button",onClick:fn(x),className:"inline-flex items-center gap-1 rounded border border-mono-800/70 bg-bg/60 px-1.5 py-0.5 text-[10px] text-secondary opacity-0 transition hover:border-strong hover:text-heading group-hover:opacity-100 focus:opacity-100","aria-label":"Copy as CLI command",title:v,children:f?l.jsxs(l.Fragment,{children:[l.jsx(Uc,{className:"h-2.5 w-2.5 text-positive-400","aria-hidden":"true"}),"Copied"]}):l.jsxs(l.Fragment,{children:[l.jsx(Zg,{className:"h-2.5 w-2.5","aria-hidden":"true"}),"Copy as CLI"]})})]}),l.jsx("div",{className:"whitespace-pre-wrap",children:e})]})}function aJ(e,n,i,r,u){const h=["canonry","agent","ask",Mf(e),Mf(n)];return i&&h.push("--provider",i),r==="read-only"&&h.push("--scope","read-only"),u&&h.push("--context",Mf(JSON.stringify(u))),h.join(" ")}function iJ(e,n){const i=[];for(const r of e.content){if(r.type!=="toolCall")continue;const u=r,h=n.get(u.id);i.push({id:u.id,name:u.name,args:u.arguments,label:h?.aeroToolLabel,durationMs:h?.aeroDurationMs,endedAt:h?.timestamp,isError:h?.isError,result:h?.content})}return i}const YS=new Set(["aero_list_toolkits","aero_load_toolkit"]),sJ=new Map([["Read","Reading"],["List","Listing"],["Get","Getting"],["Load","Loading"],["Find","Finding"],["Check","Checking"],["Compare","Comparing"],["Inspect","Inspecting"],["Preview","Previewing"],["Search","Searching"],["Show","Showing"],["Run","Running"]]);function Pr(e){return e.endedAt===void 0&&!e.interrupted}function Bg(e){return e.label??e.name.replace(/^(?:canonry|aero)_/,"").replace(/_/g," ")}function TC(e){const n=e.durationMs??(e.endedAt!=null&&e.startedAt!=null?e.endedAt-e.startedAt:null);return n==null||n<0?null:n}function EC(e){let n=null;for(const i of e){const r=TC(i);r!=null&&(n=(n??0)+r)}return n}function q1(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function oJ(e){const n=Math.floor(Math.max(0,e)/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`}function Zf(e,n,i){return`${e} ${e===1?n:i}`}function XS(e=""){return sJ.get(e.charAt(0).toUpperCase()+e.slice(1))}function rJ(e){const[n,...i]=e.trim().split(/\s+/),r=XS(n);if(!r)return"Working…";if(i[0]==="or"||i[0]==="and"){const u=XS(i[1]);return u?`${[r,i[0],u.toLowerCase(),...i.slice(2)].join(" ")}…`:"Working…"}return`${[r,...i].join(" ")}…`}function lJ(e){const[n,i]=C.useState(()=>Date.now());return C.useEffect(()=>{if(!e)return;const r=()=>i(Date.now()),u=window.setTimeout(r,0),h=window.setInterval(r,1e3);return()=>{window.clearTimeout(u),window.clearInterval(h)}},[e]),n}function cJ({trails:e,betweenSteps:n}){const[i,r]=C.useState(!1),u=C.useId(),h=e.filter($=>!YS.has($.name)),f=e.filter($=>YS.has($.name)),b=h.filter(Pr),v=b.length>0?b[b.length-1]:void 0,x=f.some(Pr),S=v!==void 0||x||n,k=h.length>0?h:f,N=k.filter($=>!Pr($)&&$.isError===!0).length,T=e.some($=>$.interrupted),z=e.flatMap($=>$.startedAt===void 0?[]:[$.startedAt]),q=z.length>0?Math.min(...z):void 0,E=lJ(S),P=EC(k),M=S?v?rJ(Bg(v)):x?"Loading tools…":"Working…":h.length>0?Zf(h.length,"step","steps"):Zf(f.length,"setup step","setup steps"),L=new Map;for(const $ of h){const F=Bg($),ae=L.get(F);ae?ae.push($):L.set(F,[$])}return l.jsxs("div",{className:"mt-3 rounded-md border border-mono-800/70 bg-surface-hover",children:[l.jsxs("button",{type:"button",onClick:()=>r($=>!$),className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left","aria-expanded":i,"aria-controls":u,children:[l.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:S?l.jsx(Ts,{className:"h-3 w-3 animate-spin text-positive-400 motion-reduce:animate-none","aria-hidden":"true"}):N>0?l.jsx(ym,{className:"h-3 w-3 text-negative-400","aria-hidden":"true"}):T?l.jsx(Ak,{className:"h-3 w-3 text-muted","aria-hidden":"true"}):l.jsx(Uc,{className:"h-3 w-3 text-muted","aria-hidden":"true"})}),l.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-heading",children:M}),N>0&&l.jsxs("span",{className:"shrink-0 rounded-md border border-negative-800/50 bg-negative-950/20 px-1.5 py-0.5 text-[10px] text-negative-400",children:[N," failed"]}),T&&l.jsx("span",{className:"shrink-0 rounded-md border border-mono-800/70 px-1.5 py-0.5 text-[10px] text-muted",children:"interrupted"}),l.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2 text-[10px] text-muted",children:[S?l.jsxs(l.Fragment,{children:[v&&l.jsxs("span",{children:["step ",h.indexOf(v)+1]}),q!==void 0&&l.jsx("span",{className:"tabular-nums","aria-hidden":"true",children:oJ(E-q)})]}):P!=null&&l.jsx("span",{className:"tabular-nums",children:q1(P)}),l.jsx(Vc,{className:`h-3 w-3 transition-transform ${i?"rotate-90":""}`,"aria-hidden":"true"})]})]}),i&&l.jsxs("div",{id:u,className:"space-y-1.5 border-t border-default px-2.5 py-2",children:[[...L].map(([$,F])=>l.jsx(JS,{trails:F,title:$},`label:${$}`)),f.length>0&&l.jsx(JS,{trails:f,title:`+ ${Zf(f.length,"setup step","setup steps")}`,muted:!0},"setup")]})]})}function JS({trails:e,title:n,muted:i=!1}){const[r,u]=C.useState(!1),h=C.useId(),f=!i&&e.length===1,b=e.some(Pr),v=e.filter(N=>!Pr(N)&&N.isError===!0).length,x=e.some(N=>N.interrupted),S=EC(e),k=f?()=>u(!0):void 0;return l.jsxs("div",{className:f?void 0:i?"rounded-md":"rounded-md border border-mono-800/70 bg-surface-hover",onFocus:k,onClick:k,children:[!f&&l.jsxs("button",{type:"button",onClick:()=>u(N=>!N),className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left","aria-expanded":r,"aria-controls":h,children:[!i&&l.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:b?l.jsx(Ts,{className:"h-3 w-3 animate-spin text-positive-400 motion-reduce:animate-none","aria-hidden":"true"}):v>0?l.jsx(ym,{className:"h-3 w-3 text-negative-400","aria-hidden":"true"}):l.jsx(Nk,{className:"h-3 w-3 text-muted","aria-hidden":"true"})}),l.jsx("span",{className:i?"text-xs text-muted":"text-sm font-medium text-heading",children:n}),!i&&l.jsxs("span",{className:"text-[10px] text-muted",children:["×",e.length]}),l.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-muted",children:[b?l.jsx("span",{className:"text-positive-400",children:"running…"}):l.jsxs(l.Fragment,{children:[v>0?l.jsxs("span",{className:"text-negative-400",children:[v," failed"]}):l.jsx("span",{children:x?"interrupted":"done"}),S!=null&&l.jsx("span",{className:"tabular-nums",children:q1(S)})]}),l.jsx(Vc,{className:`h-3 w-3 transition-transform ${r?"rotate-90":""}`,"aria-hidden":"true"})]})]}),(f||r)&&l.jsx("div",{id:h,className:f?void 0:"space-y-1.5 px-2.5 pb-2",children:e.map(N=>l.jsx(uJ,{trail:N},N.id))})]})}function uJ({trail:e}){const[n,i]=C.useState(!1),r=Pr(e),u=!r&&e.isError===!0,h=TC(e),f=h==null?null:q1(h),b=u?"border-negative-800/50":r?"border-positive-800/50":"border-mono-800/70",v=u?"bg-negative-950/20":r?"bg-positive-950/20":"bg-surface-hover";return l.jsxs("div",{className:`rounded-md border ${b} ${v}`,children:[l.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":n,children:[l.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:r?l.jsx(Ts,{className:"h-3 w-3 animate-spin text-positive-400","aria-hidden":"true"}):u?l.jsx(ym,{className:"h-3 w-3 text-negative-400","aria-hidden":"true"}):l.jsx(Nk,{className:"h-3 w-3 text-muted","aria-hidden":"true"})}),l.jsx("span",{className:"text-sm font-medium text-heading",children:Bg(e)}),l.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-muted",children:[r?l.jsx("span",{className:"text-positive-400",children:"running…"}):l.jsxs(l.Fragment,{children:[l.jsx("span",{children:e.interrupted?"interrupted":u?"failed":"done"}),f&&l.jsx("span",{children:f})]}),l.jsx(Vc,{className:`h-3 w-3 transition-transform ${n?"rotate-90":""}`,"aria-hidden":"true"})]})]}),n&&l.jsxs("div",{className:"border-t border-default px-2.5 py-2 text-[11px] text-secondary",children:[l.jsx("div",{className:"mb-2 text-xs text-secondary",children:e.name}),l.jsx("div",{className:"mb-1 text-xs text-secondary",children:"Inputs"}),l.jsx("pre",{className:"mb-2 overflow-x-auto whitespace-pre-wrap break-all text-xs text-neutral",children:WS(e.args)}),!r&&e.result!==void 0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"mb-1 text-[9px] uppercase tracking-wider text-faint",children:u?"Error":"Result"}),l.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-all text-xs text-neutral",children:WS(e.result)})]})]})]})}function WS(e){try{const n=typeof e=="string"?e:JSON.stringify(e,null,2);return n.length>2e3?`${n.slice(0,2e3)}
|
|
64
|
-
… (${n.length-2e3} more chars)`:n}catch{return String(e)}}function RC({content:e}){return l.jsx("div",{className:"text-heading",children:l.jsx(j6,{remarkPlugins:[A6],components:{h1:n=>l.jsx("h1",{...n,className:"mt-3 mb-2 text-base font-semibold text-primary"}),h2:n=>l.jsx("h2",{...n,className:"mt-3 mb-2 text-sm font-semibold text-primary"}),h3:n=>l.jsx("h3",{...n,className:"mt-3 mb-1.5 text-sm font-semibold text-heading"}),h4:n=>l.jsx("h4",{...n,className:"mt-2 mb-1 text-xs font-semibold uppercase tracking-wide text-neutral"}),p:n=>l.jsx("p",{...n,className:"mb-2 leading-relaxed"}),ul:n=>l.jsx("ul",{...n,className:"mb-2 ml-4 list-disc space-y-1"}),ol:n=>l.jsx("ol",{...n,className:"mb-2 ml-4 list-decimal space-y-1"}),li:n=>l.jsx("li",{...n,className:"marker:text-mono-600"}),strong:n=>l.jsx("strong",{...n,className:"font-semibold text-primary"}),em:n=>l.jsx("em",{...n,className:"text-strong"}),code:({children:n,...i})=>l.jsx("code",{...i,className:"rounded bg-mono-800/70 px-1 py-0.5 font-mono text-[12px] text-positive-200",children:n}),pre:n=>l.jsx("pre",{...n,className:"mb-2 overflow-x-auto rounded-md border border-base bg-bg-elevated/70 p-3 font-mono text-xs text-strong"}),a:n=>l.jsx("a",{...n,className:"text-positive-400 underline decoration-positive-700 hover:decoration-positive-400",target:"_blank",rel:"noopener noreferrer"}),table:n=>l.jsx("div",{className:"mb-2 overflow-x-auto",children:l.jsx("table",{...n,className:"w-full border-collapse text-xs"})}),thead:n=>l.jsx("thead",{...n,className:"border-b border-base"}),th:n=>l.jsx("th",{...n,className:"px-2 py-1 text-left font-semibold text-neutral"}),tr:n=>l.jsx("tr",{...n,className:"border-b border-mono-900"}),td:n=>l.jsx("td",{...n,className:"px-2 py-1 text-strong"}),blockquote:n=>l.jsx("blockquote",{...n,className:"mb-2 border-l-2 border-strong pl-3 italic text-secondary"}),hr:()=>l.jsx("hr",{className:"my-3 border-base"})},children:e})})}function dJ(){return l.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-wider text-positive-400",children:"Aero"}),l.jsxs("div",{className:"flex items-center gap-1","aria-label":"Aero is thinking",children:[l.jsx("span",{className:"aero-dot h-1.5 w-1.5 rounded-full bg-positive-400/80"}),l.jsx("span",{className:"aero-dot aero-dot-2 h-1.5 w-1.5 rounded-full bg-positive-400/60"}),l.jsx("span",{className:"aero-dot aero-dot-3 h-1.5 w-1.5 rounded-full bg-positive-400/40"})]})]})}function DC({isAdmin:e,account:n}){return e||n?.role==="viewer"&&XG()}function mJ(){const{isAdmin:e,account:n}=fa(),i=gk(),r=/^\/projects\/([^/]+)/.exec(i.pathname),u=r?decodeURIComponent(r[1]):null,h=yt({...Bo({client:J}),enabled:u!==null,staleTime:6e4}),f=SX(i.pathname,i.search),b=h.data??[],v=b.find(N=>N.id===u)??b.find(N=>N.name===u),x=sQ(v?.name??u??"",f),S=j1(),k=S||DC({isAdmin:e,account:n});return!u||!k||!v?null:l.jsx(FX,{projectName:v.name,context:x,preview:S},v.name)}function ek(e,n,i){switch(e.invalidateQueries({queryKey:JN({client:J})}),e.invalidateQueries({queryKey:$r({client:J})}),On(e,"runs"),n){case Oe["answer-visibility"]:Og(e,i,"none"),On(e,"visibilityReport"),On(e,"queryTracking");return;case Oe["backlink-extract"]:return;case Oe["site-audit"]:On(e,"technicalAeo");return;case Oe["gsc-sync"]:case Oe["inspect-sitemap"]:On(e,"gsc");return;case Oe["ga-sync"]:On(e,"ga");return;case Oe["traffic-sync"]:On(e,"ga"),On(e,"traffic");return;case Oe["bing-inspect"]:case Oe["bing-inspect-sitemap"]:On(e,"bing");return;case Oe["aeo-discover-seed"]:case Oe["aeo-discover-probe"]:Og(e,i);return;case Oe["gbp-sync"]:On(e,"gbp");return;case Oe["ads-sync"]:On(e,"ads");return;case Oe["google-ads-sync"]:On(e,"googleAds"),On(e,"conversionTracking");return;case Oe["gtm-sync"]:On(e,"gtm"),On(e,"conversionTracking");return;default:return n}}const tk=[{label:"GitHub",href:"https://github.com/Canonry/canonry",Icon:kk},{label:"Docs",href:"https://github.com/Canonry/canonry/tree/main/docs",Icon:g6},{label:"Changelog",href:"https://github.com/Canonry/canonry/releases",Icon:y6}],nk=e=>({label:e,state:"checking",detail:"Checking service health"}),pJ={apiStatus:nk("API"),workerStatus:nk("Worker")};function hJ(e){return e==="completed"?"positive":e==="partial"?"caution":"negative"}function fJ(e){const n=Nc(e.kind);return e.status==="completed"?`${n} completed`:e.status==="partial"?`${n} completed with partial results`:e.status==="cancelled"?`${n} cancelled`:`${n} failed`}function gJ(e,n){return e.error?`${n}: ${T0(e.error)}`:e.location?`${n} · ${e.location}`:n}function ak(e,n,i){if(n)return n;const r=i.find(u=>u.id===e);return r?.displayName||r?.name||e}function yJ(e,n){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,n>0?`${n} skipped at queue time`:null].filter(Boolean).join(", ")}function bJ(e){return e.failed>0||e.cancelled>0?"negative":e.partial>0?"caution":"positive"}function vJ(){const e=Ds(),n=C.useSyncExternalStore(aC,Gi,Gi),i=Object.keys(n.runs).length>0||Object.keys(n.batches).length>0,r=yt({...qc({client:J}),enabled:i,staleTime:_s,refetchInterval:3e3}),u=yt({...Bo({client:J}),enabled:i}),h=C.useRef({}),f=C.useCallback(()=>{r.refetch()},[r.refetch]);return C.useEffect(()=>{i&&f()},[i,f]),C.useEffect(()=>{if(!i||typeof window>"u")return;const b=()=>{document.visibilityState==="visible"&&f()};return window.addEventListener("focus",f),document.addEventListener("visibilitychange",b),()=>{window.removeEventListener("focus",f),document.removeEventListener("visibilitychange",b)}},[i,f]),C.useEffect(()=>{const b=r.data??[],v=u.data??[],x=Object.fromEntries(b.map(k=>[k.id,k])),S=Object.fromEntries(b.map(k=>[k.id,k.status]));for(const k of Object.values(n.runs)){const N=x[k.runId];if(!N||!vZ(N.status)||(h.current[N.id]??k.lastAnnouncedStatus)===N.status)continue;const z=v.find(E=>E.id===N.projectId);if(z&&ek(e,N.kind,z.name),k.sourceAction==="run-all"){Vf(N.id);continue}const q=ak(N.projectId,k.projectLabel,v);bn({title:fJ(N),detail:gJ(N,q),tone:hJ(N.status),dedupeKey:`run:${N.id}`,dedupeMode:"replace",cta:{label:"View run",intent:"open-run-drawer",runId:N.id}}),Vf(N.id)}if(r.data!==void 0){const k=new Set(b.map(T=>T.id)),N=wZ(Object.values(n.runs),k,Date.now(),xZ);for(const T of N){const z=v.find(q=>q.id===T.projectId);z&&ek(e,T.kind,z.name),T.sourceAction!=="run-all"&&bn({title:`${Nc(T.kind)} status unavailable`,detail:ak(T.projectId,T.projectLabel,v),tone:"neutral",dedupeKey:`run-stale:${T.runId}`,dedupeMode:"replace"}),Vf(T.runId)}}for(const k of Object.values(n.batches)){const N=SZ(k.runIds,x);N.finished&&(bn({title:"Run-all batch finished",detail:yJ(N,k.skippedCount),tone:bJ(N),dedupeKey:`batch:${k.batchId}`,dedupeMode:"replace",cta:{label:"View runs",intent:"go-to-runs"}}),bZ(k.batchId))}h.current=S},[u.data,r.data,n,e]),null}function xJ(){const{account:e,isAdmin:n}=fa(),i=su(),r=C.useMemo(()=>MN(),[]),u=C.useMemo(ZG,[]),h=C.useMemo(YG,[]),f=j1()||h&&DC({isAdmin:n,account:e}),b=C.useMemo(JG,[]),v=gk(),{dashboard:x,isLoading:S,refetch:k}=Ym(void 0,{includeSettings:!r,includeOverviews:!1,pauseProjectPolling:v.pathname==="/setup"}),z=I1(!i,i?.health).data??i?.health??pJ,{runId:q,evidenceId:E,closeDrawer:P}=O1(),[M,L]=C.useState(!1),[$,F]=C.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem("canonry:sidebarHidden")==="true"}catch{return!1}}),[ae,V]=C.useState(()=>{if(typeof window>"u")return null;try{return window.localStorage.getItem("canonry:dismissedUpdateVersion")}catch{return null}}),[Z]=C.useState(()=>typeof window>"u"?null:new URLSearchParams(window.location.search).get("force-update")),X=Z?{current:z.apiStatus.version??"0.0.0",latest:Z,url:"https://www.npmjs.com/package/@canonry/canonry",upgradeCommand:"npm install -g @canonry/canonry"}:z.apiStatus.updateAvailable,Ce=b&&X&&X.latest!==ae,tt=()=>{if(X){try{window.localStorage.setItem("canonry:dismissedUpdateVersion",X.latest)}catch{}V(X.latest)}},Ke=()=>{const re=!$;try{re?window.localStorage.setItem("canonry:sidebarHidden","true"):window.localStorage.removeItem("canonry:sidebarHidden")}catch{}F(re)},Ue=lX(q),ke=Ue.data??null,Le=Ue.isLoading;C.useEffect(()=>{ke&&ke.status!=="running"&&ke.status!=="queued"&&k()},[ke?.status,k]),C.useEffect(()=>{L(!1)},[v.pathname]),C.useEffect(()=>{if(typeof window>"u"||!q&&!E)return;const re=Ze=>{Ze.key==="Escape"&&P()};return window.addEventListener("keydown",re),()=>{window.removeEventListener("keydown",re)}},[q,E,P]);const B=x??i?.dashboard??null,W=v.pathname==="/setup",ve=W&&B!==null&&B.portfolioOverview.projects.length===0,Ae=W&&(v.search.onboarding==="site-health"||v.search.onboarding==="first-run"||v.search.onboarding==="complete"),[se,Se]=C.useState(ve);C.useEffect(()=>{W?ve&&Se(!0):Se(!1)},[ve,W]);const xe=W&&(Ae||ve||se||W&&B===null),pe=xe?"app-shell-focus":$?"app-shell-sidebar-hidden":"",ce=q?(B?DY(B,q):void 0)??(ke?iu(ke,B?.projects.find(re=>re.project.id===ke.projectId)?.project.displayName??B?.projects.find(re=>re.project.id===ke.projectId)?.project.name??"Unknown project"):void 0):void 0,ue=C.useMemo(()=>_Y(v.pathname,B),[v.pathname,B]),{commandCenter:_e,evidenceLoading:Fe,evidenceError:Ee,isError:Ct,refetch:me}=sX(E?ue:null,{evidence:!0}),Be=C.useMemo(()=>{if(E)return IY(_e,B,E)},[E,_e,B]),Ne=(()=>{const re=v.pathname;if(re==="/")return"Portfolio";if(re==="/projects")return"Projects";if(re==="/runs")return"Runs";if(re==="/history")return"History";if(re==="/settings")return"Settings";if(re==="/setup")return"Setup";if(re==="/backlinks")return"Backlink data";if(re==="/traffic"||re.startsWith("/traffic/"))return"Traffic sources";if(re.startsWith("/projects/")){const Ze=B?.projects.find(bt=>bt.project.name===ue);return Ze?.project.displayName||Ze?.project.name||ue||"Projects"}return"Not found"})();if(r){const re=gN(r.projectTabs),Ze=!r.views||r.views.includes(fQ(v.pathname));return l.jsxs("div",{className:"app-shell app-shell-embed","data-theme":xQ(r.theme),style:wQ(r.theme),children:[l.jsx("a",{className:"skip-link",href:"#content",children:"Skip to content"}),l.jsx("main",{id:"content",className:"page-shell",children:re?l.jsx("div",{className:"embed-view-unavailable",role:"status",children:"This embed uses the retired Report tab. Update its allowed tabs to show AI Visibility."}):Ze?l.jsx(Xf,{}):l.jsx("div",{className:"embed-view-unavailable",role:"status",children:"This view is not available in embed mode."})})]})}return l.jsxs(l.Fragment,{children:[l.jsx("a",{className:"skip-link",href:"#content",children:"Skip to content"}),l.jsx(fX,{}),l.jsxs("div",{className:`app-shell ${pe}${jo()?" app-shell-demo":""}`,children:[!xe&&!$&&l.jsxs("aside",{id:"desktop-sidebar",className:"sidebar","aria-label":"Primary navigation",children:[l.jsx("div",{className:"sidebar-brand",children:l.jsx(zS,{version:z.apiStatus.version,updateAvailable:Ce?X:null,onDismissUpdate:tt})}),l.jsxs("nav",{className:"sidebar-nav",children:[l.jsxs(at,{to:"/",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(c6,{className:"sidebar-icon"}),l.jsx("span",{children:"Portfolio"})]}),l.jsxs(at,{to:"/projects",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!1},children:[l.jsx(u6,{className:"sidebar-icon"}),l.jsx("span",{children:"Projects"})]}),l.jsxs(at,{to:"/runs",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(d6,{className:"sidebar-icon"}),l.jsx("span",{children:"Runs"})]}),l.jsxs(at,{to:"/history",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(jk,{className:"sidebar-icon"}),l.jsx("span",{children:"History"})]}),l.jsxs(at,{to:"/traffic",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!1},children:[l.jsx(m6,{className:"sidebar-icon"}),l.jsx("span",{children:"Traffic sources"})]}),!jo()&&l.jsxs(at,{to:"/backlinks",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(p6,{className:"sidebar-icon"}),l.jsx("span",{children:"Backlink data"})]}),n&&l.jsxs(at,{to:"/settings",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(h6,{className:"sidebar-icon"}),l.jsx("span",{children:"Settings"})]}),S?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"sidebar-section-title",children:"Tracked projects"}),[1,2,3].map(re=>l.jsxs("div",{className:"sidebar-skeleton-item",children:[l.jsx("span",{className:"skeleton-circle size-2"}),l.jsx("span",{className:"skeleton-text flex-1",style:{width:`${50+re*15}%`}})]},re))]}):B&&B.projects.length>0?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"sidebar-section-title",children:"Tracked projects"}),B.projects.map(re=>{const Ze=re.visibilitySummary.tone;return l.jsxs(at,{to:"/projects/$projectName",params:{projectName:re.project.name},className:"sidebar-project",activeProps:{className:"sidebar-project sidebar-project-active"},children:[l.jsx("span",{className:`sidebar-dot sidebar-dot-${Ze}`}),l.jsx("span",{children:re.project.displayName||re.project.name})]},re.project.id)})]}):S?null:l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"sidebar-section-title",children:"Resources"}),n&&l.jsxs(at,{to:"/setup",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(f6,{className:"sidebar-icon"}),l.jsx("span",{children:"Setup"})]})]})]}),e&&l.jsxs("div",{className:"sidebar-account",children:[l.jsxs("div",{className:"sidebar-account-identity",children:[l.jsx("span",{className:"sidebar-account-name",children:e.name}),e.role==="viewer"?l.jsx("span",{className:"sidebar-account-role",children:dS()}):null]}),l.jsx(le,{type:"button",variant:"ghost",size:"sm",onClick:fn(async()=>{await fS(),window.location.reload()}),children:"Sign out"})]}),u?l.jsx("div",{className:"sidebar-footer",children:tk.map(({label:re,href:Ze,Icon:bt})=>l.jsx("a",{className:"sidebar-footer-icon",href:Ze,target:"_blank",rel:"noopener noreferrer",title:re,"aria-label":re,children:l.jsx(bt,{className:"size-4"})},Ze))}):null]}),l.jsxs("div",{className:"main-area",children:[l.jsxs("header",{className:"topbar",children:[l.jsxs("div",{className:"topbar-left",children:[!xe&&l.jsx(le,{className:"sidebar-privacy-toggle",variant:"ghost",size:"icon",type:"button","aria-label":$?"Show sidebar":"Hide sidebar","aria-controls":$?void 0:"desktop-sidebar","aria-expanded":!$,title:$?"Show sidebar":"Hide sidebar",onClick:Ke,children:$?l.jsx(b6,{className:"size-4"}):l.jsx(v6,{className:"size-4"})}),l.jsx("div",{className:"topbar-brand-mobile",children:l.jsx(zS,{compact:!0})}),l.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[l.jsx(at,{to:"/",children:"Home"}),l.jsx(Vc,{className:"breadcrumb-sep size-3"}),l.jsx("span",{className:"breadcrumb-current",children:Ne})]})]}),l.jsxs("div",{className:"topbar-actions",children:[l.jsx(gX,{}),l.jsxs("div",{className:"health-pill-row",children:[l.jsxs("span",{className:`health-pill health-pill-${z.apiStatus.state}`,title:Kr(z.apiStatus),children:["API ",z.apiStatus.state==="ok"?"ok":z.apiStatus.state]}),l.jsx("span",{className:`health-pill health-pill-${z.workerStatus.state}`,title:Kr(z.workerStatus),children:`Worker ${z.workerStatus.state==="ok"?"ok":z.workerStatus.state}`})]}),xe?null:l.jsxs(le,{className:"nav-toggle",variant:"secondary",size:"icon",type:"button","aria-expanded":M,"aria-controls":"mobile-nav",onClick:()=>L(re=>!re),children:[l.jsx(x6,{className:"size-4"}),l.jsx("span",{className:"sr-only",children:"Open navigation"})]})]})]}),xe?null:l.jsxs("div",{id:"mobile-nav",className:`mobile-nav ${M?"mobile-nav-open":""}`,children:[l.jsxs(le,{className:"mobile-nav-close",variant:"ghost",size:"icon",type:"button",onClick:()=>L(!1),children:[l.jsx(Gr,{className:"size-5"}),l.jsx("span",{className:"sr-only",children:"Close navigation"})]}),l.jsx(at,{to:"/",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Portfolio"}),l.jsx(at,{to:"/projects",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!1},children:"Projects"}),l.jsx(at,{to:"/runs",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Runs"}),l.jsx(at,{to:"/history",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"History"}),l.jsx(at,{to:"/traffic",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!1},children:"Traffic sources"}),!jo()&&l.jsx(at,{to:"/backlinks",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Backlink data"}),n&&l.jsx(at,{to:"/settings",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Settings"}),B&&B.projects.length>0?l.jsxs("div",{className:"mobile-nav-section",children:[l.jsx("p",{className:"mobile-nav-section-title",children:"Tracked projects"}),B.projects.map(re=>l.jsx(at,{to:"/projects/$projectName",params:{projectName:re.project.name},className:"mobile-nav-link",children:re.project.name},re.project.id))]}):null,e&&l.jsxs("div",{className:"mobile-nav-section",children:[l.jsx("p",{className:"mobile-nav-section-title",children:"Signed in"}),l.jsxs("div",{className:"sidebar-account",children:[l.jsxs("div",{className:"sidebar-account-identity",children:[l.jsx("span",{className:"sidebar-account-name",children:e.name}),e.role==="viewer"?l.jsx("span",{className:"sidebar-account-role",children:dS()}):null]}),l.jsx(le,{type:"button",variant:"ghost",size:"sm","data-testid":"mobile-sign-out",onClick:fn(async()=>{await fS(),window.location.reload()}),children:"Sign out"})]})]})]}),l.jsx("main",{id:"content",className:`page-shell ${f&&ue?"pb-20":""}`.trim(),children:S&&!i?l.jsxs("div",{className:"page-skeleton",children:[l.jsxs("div",{className:"page-skeleton-header",children:[l.jsx("div",{className:"skeleton-text h-6 w-40"}),l.jsx("div",{className:"skeleton-text-sm w-72"})]}),l.jsx("div",{className:"page-skeleton-grid",children:[1,2,3].map(re=>l.jsxs("div",{className:"page-skeleton-card",children:[l.jsx("div",{className:"skeleton-text w-24"}),l.jsx("div",{className:"skeleton-text w-full"}),l.jsx("div",{className:"skeleton-text-sm w-3/4"})]},re))}),l.jsx("div",{className:"page-skeleton-grid",style:{gridTemplateColumns:"1fr 1fr"},children:[1,2].map(re=>l.jsxs("div",{className:"page-skeleton-card",children:[l.jsx("div",{className:"skeleton-text w-20"}),l.jsx("div",{className:"space-y-2",children:[1,2,3].map(Ze=>l.jsx("div",{className:"skeleton-text-sm w-full"},Ze))})]},re))})]}):l.jsx(Xf,{})}),l.jsxs("footer",{className:"footer",children:[l.jsxs("span",{className:"footer-brand",children:[l.jsx("span",{children:l.jsx("a",{href:"https://canonry.ai",children:"Canonry"})}),z.apiStatus.version&&z.apiStatus.version!=="unknown"?l.jsxs("span",{className:"footer-version",children:["v",z.apiStatus.version]}):null]}),u?l.jsx("div",{className:"footer-links",children:tk.map(({label:re,href:Ze,Icon:bt})=>l.jsx("a",{href:Ze,target:"_blank",rel:"noopener noreferrer",title:re,"aria-label":re,className:"footer-icon",children:l.jsx(bt,{className:"size-3.5"})},Ze))}):null]})]}),q&&!ce&&Le?l.jsx(Td,{open:!0,title:"Loading run details",subtitle:"Fetching the durable run record",onClose:P,children:l.jsx("p",{className:"text-sm text-muted",role:"status",children:"Loading run details…"})}):null,q&&!ce&&Ue.isError?l.jsx(Td,{open:!0,title:"Run unavailable",subtitle:"The run could not be loaded",onClose:P,children:l.jsx("p",{className:"text-sm text-negative",children:Ue.error instanceof Error?Ue.error.message:"Run details are unavailable."})}):null,ce?l.jsxs(Td,{open:!0,title:ce.summary,subtitle:`${ce.projectName} · ${ce.kindLabel}`,onClose:P,children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-1 text-sm",children:[l.jsx(z1,{status:ce.status}),l.jsx("span",{className:"text-secondary",children:ce.startedAt}),l.jsx("span",{className:"text-muted",children:ce.duration}),l.jsx("span",{className:"text-faint",children:ce.triggerLabel})]}),ce.status==="failed"&&ce.statusDetail&&l.jsx("p",{className:"mt-2 text-sm text-negative",children:ce.statusDetail}),l.jsxs("div",{className:"mt-4",children:[l.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted mb-2",children:"Activity Log"}),Le?l.jsx("p",{className:"text-sm text-muted",children:"Loading run details..."}):ke?.snapshots&&ke.snapshots.length>0?l.jsxs("div",{className:"space-y-2",children:[ke.snapshots.map(re=>l.jsxs("div",{className:"rounded-lg border border-default bg-surface p-3",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[l.jsx("p",{className:"text-sm font-medium text-strong truncate",children:re.query??"Unknown query"}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(fY,{provider:re.provider}),l.jsx(vC,{variant:re.citationState===Sc.cited?"success":"neutral",children:re.citationState})]})]}),re.model&&l.jsx("p",{className:"text-[11px] text-muted font-mono",children:re.model}),re.citedDomains.length>0&&l.jsxs("p",{className:"text-xs text-muted mt-1",children:[l.jsx("span",{className:"text-secondary",children:"Sources:"})," ",re.citedDomains.join(", ")]}),re.citedCompetitorDomains.length>0&&l.jsxs("p",{className:"text-xs text-negative-400/80 mt-0.5",children:["Competitor cited: ",re.citedCompetitorDomains.join(", ")]}),re.mentionedCompetitorDomains.length>0&&l.jsxs("p",{className:"text-xs text-negative-400/80 mt-0.5",children:["Competitor mentioned: ",re.mentionedCompetitorDomains.join(", ")]}),re.groundingSources&&re.groundingSources.length>0&&l.jsxs("details",{className:"mt-2",children:[l.jsxs("summary",{className:"text-xs text-muted cursor-pointer hover:text-secondary",children:[re.groundingSources.length," grounding source",re.groundingSources.length!==1?"s":""]}),l.jsx("ul",{className:"mt-2 space-y-3",children:re.groundingSources.map((Ze,bt)=>l.jsx("li",{className:"min-w-0",children:l.jsx(Ig,{url:Ze.uri,title:Ze.title})},bt))})]}),re.answerText&&l.jsxs("details",{className:"mt-1",children:[l.jsx("summary",{className:"text-xs text-muted cursor-pointer hover:text-secondary",children:"Answer preview"}),l.jsx("p",{className:"mt-1 text-xs text-secondary leading-relaxed whitespace-pre-wrap",children:re.answerText})]})]},re.id)),ke.status==="running"&&l.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-muted",children:[l.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-caution-500 animate-pulse"}),"Running remaining queries..."]})]}):ke&&ke.status===Nt.running?l.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-muted",children:[l.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-caution-500 animate-pulse"}),ke.kind===Oe["answer-visibility"]?"Waiting for first query result...":"Run is in progress..."]}):ke&&ke.status===Nt.queued?l.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-muted",children:[l.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-mono-500 animate-pulse"}),"Run queued, waiting for execution slot..."]}):ke&&ke.error?l.jsxs("div",{className:"rounded-lg border border-negative-800/40 bg-negative-950/20 p-3",children:[l.jsx("p",{className:"text-sm font-medium text-negative mb-2",children:"Run failed"}),l.jsx("pre",{className:"max-h-48 overflow-y-auto whitespace-pre-wrap break-words font-mono text-xs leading-5 text-negative",children:lQ(ke.error)})]}):ce.kind!==Oe["answer-visibility"]?l.jsx("p",{className:"text-sm text-secondary",children:ce.status===Nt.completed?"Run completed.":ce.status===Nt.partial?"Run completed with partial results.":ce.status===Nt.cancelled?"Run cancelled.":ce.status===Nt.failed?"Run failed.":"No run details available."}):l.jsx("p",{className:"text-sm text-muted",children:"No snapshot data available."})]})]}):null,E&&!Be?l.jsx(Td,{open:!0,title:Fe?"Loading answer":"Answer unavailable",subtitle:"Query evidence",onClose:P,children:Fe?l.jsx("p",{role:"status",className:"text-sm text-secondary",children:"Loading answer…"}):l.jsxs(l.Fragment,{children:[l.jsx("p",{role:"alert",className:"text-sm text-secondary",children:Ee||Ct?"Could not load this answer.":"This answer is not in the available query evidence."}),l.jsx(le,{type:"button",variant:"outline",onClick:()=>{me()},children:"Retry"})]})}):null,Be?l.jsx(AY,{evidence:Be.evidence,project:Be.project,onClose:P}):null,l.jsx(vJ,{}),l.jsx(dX,{}),f?l.jsx(mJ,{}):null]})]})}class wJ extends C.Component{state={error:null};static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,i){console.error("[ErrorBoundary]",n,i.componentStack),lm({kind:"render",error:n,component:this.props.name??"root"})}handleReset=()=>{this.setState({error:null})};render(){return this.state.error?l.jsx("div",{className:"page-container",children:l.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 py-20 text-center",children:[l.jsx("div",{className:"rounded-full bg-negative-950/40 p-3",children:l.jsx(ym,{className:"size-6 text-negative-400"})}),l.jsx("h2",{className:"text-lg font-semibold text-heading",children:"Something went wrong"}),l.jsx("p",{className:"text-sm text-secondary max-w-md",children:this.state.error.message||"An unexpected error occurred while rendering this page."}),l.jsxs("div",{className:"flex gap-3 mt-2",children:[l.jsxs(le,{variant:"secondary",size:"sm",onClick:this.handleReset,children:[l.jsx(w6,{className:"size-3.5 mr-1.5"}),"Try again"]}),l.jsx(le,{variant:"secondary",size:"sm",onClick:()=>{const n=window.__CANONRY_CONFIG__?.basePath?.replace(/\/$/,"")??"";window.location.href=n||"/"},children:"Go home"})]})]})}):this.props.children}}const _a=C.forwardRef(({className:e,...n},i)=>l.jsx("div",{ref:i,className:za("rounded-xl border border-base bg-bg/75 shadow-[0_0_0_1px_var(--color-shadow-hairline)]",e),...n}));_a.displayName="Card";const zr=C.forwardRef(({className:e,...n},i)=>l.jsx("div",{ref:i,className:za("flex flex-col gap-1.5 p-5",e),...n}));zr.displayName="CardHeader";const zC=C.forwardRef(({className:e,...n},i)=>l.jsx("h3",{ref:i,className:za("font-medium tracking-tight text-primary",e),...n}));zC.displayName="CardTitle";const fm=C.forwardRef(({className:e,...n},i)=>l.jsx("p",{ref:i,className:za("text-sm text-muted",e),...n}));fm.displayName="CardDescription";const vo=C.forwardRef(({className:e,...n},i)=>l.jsx("div",{ref:i,className:za("p-5 pt-0",e),...n}));vo.displayName="CardContent";function Lg({disabled:e,title:n,...i}){const{canWrite:r}=fa();return r?l.jsx(le,{disabled:e,title:n,...i}):l.jsx(le,{...i,disabled:!0,title:QN})}function M1({title:e,children:n}){const{isAdmin:i}=fa();return i?l.jsx(l.Fragment,{children:n}):l.jsxs(_a,{className:"surface-card mx-auto mt-8 max-w-lg",children:[l.jsxs(zr,{children:[l.jsxs(zC,{children:[e," is for administrators"]}),l.jsx(fm,{children:"Your account has view-only access. You can read everything this install has measured; changing how it is set up needs an administrator account."})]}),l.jsx(vo,{children:l.jsx("p",{className:"supporting-copy",children:"If you need to make a change here, ask an administrator on this install."})})]})}function zse(e,n,i){return{mode:n,scope:e.measurementScope,scopeKey:e.measurementScopeKey,marketKey:e.marketKey,queryClass:e.queryClass==="non-brand"?"non-brand":"branded",provider:e.provider,model:e.model,location:e.location,runId:e.measurementRunId,revision:e.revision,evaluationDefinitionId:i}}function Ise(e,n,i){const r=[...new Set(n.filter(u=>!i||u.provider===i).map(u=>u.sourceRunId).filter(u=>!!u))].sort();return{...e,mode:"simple",scope:"project",scopeKey:void 0,marketKey:void 0,provider:i||void 0,model:void 0,revision:void 0,runId:r.length===1?r[0]:void 0,runIds:r.length>1?r:void 0}}function Cc(e,n,i,r){return["sentiment",e,n,i??null,r??null]}const IC=5e3,SJ=new Set(["pending","running","waiting-to-retry"]);function ik(e){return SJ.has(e.state)}function kJ(e){const n=e?.coverage.counts;return!!(n&&n.pending+n.running+n["waiting-to-retry"]>0)}function jJ(e,n){return kJ(e)||n?IC:!1}function AJ(e,n,i=!0){const r=yt({queryKey:Cc(e,"settings"),queryFn:()=>Md(e),retry:!1,staleTime:0,refetchOnWindowFocus:"always"}),u=yt({queryKey:Cc(e,"jobs"),queryFn:()=>BH(e),enabled:!!r.data?.actions.configure,retry:!1,refetchOnWindowFocus:"always",refetchInterval:x=>x.state.data?.jobs.some(ik)?IC:!1}),h=!!u.data?.jobs.some(ik),f=x=>{const S={...n,queryClass:x};return{queryKey:Cc(e,"summary",S),queryFn:()=>IH(e,S),enabled:i&&!!(r.data?.enabled&&r.data.installEnabled),retry:!1,staleTime:0,refetchOnWindowFocus:"always",refetchInterval:k=>jJ(k.state.data,h)}},b=yt(f("branded")),v=yt(f("non-brand"));return{settings:r,branded:b,nonBrand:v,jobs:u}}const Bi={branded:"Branded","non-brand":"Non-brand"},B1=10;function L1(e){return e>=B1}const We={states:{disabled:"Sentiment is off.","not-measured":"No ratings yet.",processing:"Analyzing sentiment…",canceled:"Analysis canceled.",partial:"Partial results.",failed:"Analysis failed.",complete:"Analysis complete.",unsupported:"Sentiment unavailable."},noJudgments:"No ratings available.",tooFew:"too few",minRated:`Shown from ${B1} ratings`,partial:"Partial results",columns:{favorable:"Favorable",rated:"With opinion"},title:"Sentiment",subtitle:"How AI answers describe you in queries that name you",rated:"Share of answers that give an opinion (favorable, mixed or unfavorable) about who they name",noAnswers:"No answers yet",ratedUnavailable:"Unavailable",details:{ratedAnswers:"Answers with an opinion",unadmitted:"Checks not yet analyzed",checksCaption:"Not counted in the favorable share:",interval:"Likely range (95%)"},nonBrand:{label:"Non-brand queries",none:"No unfavorable or mixed answers in non-brand queries.",noneSoFar:"No unfavorable or mixed answers in non-brand queries so far.",notRated:"Non-brand answers are not rated yet.",view:"View answers",evidence:"Non-brand queries, unfavorable and mixed",rowNone:"No unfavorable or mixed answers",rowLabel:"Unfavorable or mixed",help:"A non-brand answer almost always names you to recommend you, so its favorable share is near 100% and says little. Sentiment is measured on branded queries; unfavorable or mixed answers to non-brand queries are listed here when they happen."},properties:{title:"Most criticized properties",evidence:"unfavorable and mixed",viewAll:"View all unfavorable and mixed answers",allEvidence:"Branded queries, unfavorable and mixed"},overall:"Favorable share of ratings in answers to branded queries. Each saved answer-subject assessment counts once. Answers with no opinion, or where it is unclear who they name, are left out.",favorable:"The favorable share of favorable, mixed and unfavorable ratings in answers to branded queries. Each rating covers one subject named in an answer; answers with no opinion are left out."},_c="—",NJ={factual:"Named, no opinion","subject-not-mentioned":"Not named in the answer","wrong-subject":"Named someone else","ambiguous-subject":"Unclear which one was meant","ambiguous-judgment":"Opinion unclear","subject-not-applicable":"Not applicable","unsupported-language":"Not in English","missing-source-text":"No answer text","input-too-large":"Answer too long to rate","invalid-conclusion-evidence":"Rating set aside",pending:"Waiting to be rated",running:"Being rated","waiting-to-retry":"Retrying"};function Hi(e){return NJ[e]??e.replaceAll("-"," ").replace(/^./,n=>n.toUpperCase())}const Eo=["favorable","mixed","unfavorable"];function OC(e){return e==="favorable"?"positive":e==="unfavorable"?"negative":e==="mixed"?"caution":"neutral"}const Mc=["mixed","unfavorable"];function PC(e){return e.interval?`${nm(e.interval.low,Ga.fraction)} to ${nm(e.interval.high,Ga.fraction)}`:null}const ep={favorable:"progress-fill-info",mixed:"progress-fill-caution",unfavorable:"progress-fill-negative"};function Ud(e){return`${e} ${e===1?"rating":"ratings"}`}function tp(e){return e.score.favorableRate!==null&&e.coverage.judged>0}function Ug(e){return e.state==="complete"&&!e.provisional&&e.coverage.unadmittedAssessments===0}function qC(e){return e.state==="complete"?We.partial:We.states[e.state]}function U1(e){return e?tp(e)&&L1(e.coverage.judged):!1}function CJ({value:e,label:n}){const{counts:i,judged:r}=e.coverage;if(!tp(e))return l.jsx("div",{className:"sentiment-bar sentiment-bar-track","data-sentiment-bar":"empty","aria-hidden":"true"});const u=Eo.map(h=>`${i[h]} ${h}`).join(", ");return U1(e)?l.jsx("div",{role:"img","aria-label":`${n}: ${u}, ${e.score.favorableDisplay} favorable of ${Ud(r)}`,className:"sentiment-bar","data-sentiment-bar":"rated",children:Eo.filter(h=>i[h]>0).map(h=>l.jsx("span",{"data-outcome":h,className:`sentiment-bar-segment ${ep[h]}`,style:{flexGrow:i[h]},title:`${Hi(h)}: ${i[h]} of ${Ud(r)}`},h))}):l.jsx("div",{role:"img","aria-label":`${n}: ${u}, ${Ud(r)}, favorable share ${We.minRated.toLowerCase()}`,className:"sentiment-bar sentiment-bar-track","data-sentiment-bar":"too-few"})}function _J({value:e,label:n}){const{counts:i,judged:r}=e.coverage;return l.jsx("div",{role:"img","aria-label":`${n}: ${Eo.map(u=>`${i[u]} ${u}`).join(", ")}, ${Ud(r)}`,className:"sentiment-property-bar",children:Eo.filter(u=>i[u]>0).map(u=>l.jsx("span",{"data-outcome":u,className:`sentiment-bar-segment ${ep[u]}`,style:{flexGrow:i[u]}},u))})}function TJ(e){const n=new Map(e.breakdowns.filter(i=>i.dimension==="property").map(i=>[i.key,i]));return(e.criticizedProperties?.keys??[]).flatMap(i=>n.get(i)??[])}function EJ({value:e,label:n}){return l.jsx("div",{role:"group","aria-label":`${n} favorable share`,className:"sentiment-class-favorable",children:U1(e)?l.jsx("span",{className:"sentiment-class-share",children:e.score.favorableDisplay}):l.jsxs(l.Fragment,{children:[l.jsx("span",{"aria-hidden":"true",className:"sentiment-class-empty",title:We.minRated,children:_c}),l.jsx("span",{className:"sr-only",children:We.minRated})]})})}function RJ({ratedAnswers:e=0,eligibleAnswers:n=0}){return`${e} of ${n} ${n===1?"answer":"answers"} rated`}function DJ(e){const{eligibleAnswers:n}=e;return n===void 0?{display:_c,detail:We.ratedUnavailable,empty:!0}:n<=0?{display:_c,detail:We.noAnswers,empty:!0}:e.ratedAnswerRate===null||e.ratedAnswerRate===void 0?{display:_c,detail:We.states.disabled,empty:!0}:{display:nm(e.ratedAnswerRate,Ga.fraction),detail:RJ(e),empty:!1}}function zJ({coverage:e,label:n}){const{display:i,detail:r,empty:u}=DJ(e);return l.jsxs("div",{role:"group","aria-label":`${n} share rated`,className:"sentiment-class-ratings",children:[l.jsx("span",{"aria-hidden":"true",className:u?"sentiment-class-empty":void 0,title:r,children:i}),l.jsx("span",{className:"sr-only",children:u?r:`${i}, ${r}`})]})}function IJ({value:e}){return tp(e)?e.provisional?l.jsx("p",{className:"sentiment-class-note text-caution",children:We.partial}):null:l.jsx("p",{className:"sentiment-class-note",children:e.state==="complete"?We.noJudgments:We.states[e.state]})}function OJ(e){return!!(e.coverage.selected||e.coverage.eligibleAssessments||e.reason)}function PJ({value:e,queryClass:n,open:i,setOpenClass:r}){const u=C.useContext(ui),h=C.useId(),f=C.useId(),b=C.useId(),v=C.useRef(null),x=C.useRef(null),S=C.useCallback(()=>r(E=>E===n?null:E),[r,n]);C.useEffect(()=>{if(!i)return;const E=$=>$ instanceof Node&&!!(v.current?.contains($)||x.current?.contains($)),P=$=>{E($.target)||S()},M=$=>{E($.target)||S()},L=$=>{$.key==="Escape"&&(S(),v.current?.focus())};return document.addEventListener("pointerdown",P),document.addEventListener("focusin",M),document.addEventListener("keydown",L),()=>{document.removeEventListener("pointerdown",P),document.removeEventListener("focusin",M),document.removeEventListener("keydown",L)}},[i,S]);const{coverage:k,score:N}=e,T=PC(N),z=k.judged>0&&!L1(k.judged),q=n==="branded"?TJ(e):[];return OJ(e)?l.jsxs(l.Fragment,{children:[l.jsx("button",{ref:v,type:"button",className:"sentiment-class-details-toggle","aria-label":`${Bi[n]} details`,"aria-expanded":i,"aria-controls":h,onClick:()=>r(E=>E===n?null:n),children:l.jsx(Lc,{className:"sentiment-class-details-chevron","aria-hidden":"true"})}),l.jsxs("div",{ref:x,id:h,role:"group","aria-labelledby":f,className:"sentiment-class-details",hidden:!i,children:[l.jsx("p",{id:f,className:"sentiment-class-details-title",children:Bi[n]}),l.jsxs("dl",{className:"sentiment-details-list",children:[(k.eligibleAnswers??0)>0&&l.jsxs("div",{children:[l.jsx("dt",{children:We.details.ratedAnswers}),l.jsxs("dd",{children:[k.ratedAnswers??0," of ",k.eligibleAnswers]})]}),z&&Eo.filter(E=>k.counts[E]>0).map(E=>l.jsxs("div",{children:[l.jsx("dt",{children:Hi(E)}),l.jsx("dd",{children:k.counts[E]})]},E)),z&&l.jsxs("div",{children:[l.jsx("dt",{children:"Favorable share"}),l.jsx("dd",{children:We.minRated})]}),T&&l.jsxs("div",{children:[l.jsxs("dt",{children:[We.details.interval," ",l.jsx(ua,{text:N.limitation,placement:"bottom"})]}),l.jsx("dd",{children:T})]})]}),u&&q.length>0&&l.jsxs("div",{className:"sentiment-details-properties",role:"group","aria-labelledby":b,children:[l.jsxs("p",{id:b,className:"sentiment-details-subtitle",children:[We.properties.title,e.criticizedProperties&&e.criticizedProperties.total>q.length?l.jsxs("span",{className:"sentiment-details-subtitle-count",children:[" · ",q.length," of ",e.criticizedProperties.total]}):null]}),l.jsx("ul",{children:q.map(E=>l.jsxs("li",{className:"sentiment-property",children:[l.jsx("button",{type:"button",className:"sentiment-property-name","aria-label":`View ${We.properties.evidence} answers for ${E.label}`,onClick:()=>{if(!v.current)return;const P=Vg(u,e);u.openEvidence({...P,queryClass:n,scope:"property",scopeKey:E.key,marketKey:P.scope==="market"?P.scopeKey:P.marketKey,outcome:Mc},`${E.label}, ${We.properties.evidence}`,v.current)},children:E.label}),l.jsxs("span",{className:"sentiment-property-count",children:[E.coverage.counts.favorable," of ",E.coverage.judged," favorable"]}),l.jsx(_J,{value:E,label:E.label})]},E.key))}),l.jsx("button",{type:"button",className:"sentiment-property-name sentiment-details-view-all",onClick:()=>{v.current&&u.openEvidence({...Vg(u,e),queryClass:n,outcome:Mc},We.properties.allEvidence,v.current)},children:We.properties.viewAll})]}),(k.unadmittedAssessments>0||Object.entries(k.counts).some(([E,P])=>P>0&&!Eo.includes(E)))&&l.jsx("p",{className:"sentiment-details-caption",children:We.details.checksCaption}),l.jsxs("dl",{className:"sentiment-details-list",children:[k.unadmittedAssessments>0&&l.jsxs("div",{children:[l.jsx("dt",{children:We.details.unadmitted}),l.jsx("dd",{children:k.unadmittedAssessments})]}),Object.entries(k.counts).filter(([E,P])=>P>0&&!["favorable","mixed","unfavorable"].includes(E)).map(([E,P])=>l.jsxs("div",{children:[l.jsx("dt",{children:Hi(E)}),l.jsx("dd",{children:P})]},E))]}),e.reason&&l.jsx("p",{className:"sentiment-class-details-reason",children:e.reason})]})]}):null}function V1(e){return!!(e?.configured&&e.branded.coverage.judged>0&&e.branded.score.favorableRate!==null)&&!Gm()}function qJ({value:e}){if(!V1(e))return null;const n=e.branded,i=n.coverage.judged,r=PC(n.score),u=`${We.overall} ${i} of ${n.coverage.selected} judged${r?`, 95% interval ${r}`:""}. ${n.provisional?"Provisional. ":""}${We.states[n.state]}${n.reason?` ${n.reason}`:""}`;return l.jsx("div",{className:"project-row-stat","data-sentiment-score":!0,children:l.jsxs("div",{className:"metric-inline-block",children:[l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("p",{className:"metric-inline-label",children:"Sentiment"}),l.jsx("span",{className:"relative z-10",children:l.jsx(ua,{text:u,placement:"bottom"})})]}),L1(i)?l.jsxs("p",{className:"metric-inline-value",children:[n.score.favorableDisplay,l.jsx("span",{className:"sr-only",children:" favorable judgments, branded queries"})]}):l.jsxs("p",{className:"metric-inline-value text-secondary",children:[We.tooFew,l.jsxs("span",{className:"sr-only",children:[" ratings for a favorable share, ",i," of ",B1," needed, branded queries"]})]}),l.jsx("p",{className:"metric-inline-caption","aria-hidden":"true"})]})})}const ui=C.createContext(null);function Vg(e,n){const{selection:i}=n;return{...e.selection,...i,runId:i.runId??void 0,runIds:i.runId?void 0:i.runIds,revision:i.revision??void 0,evaluationDefinitionId:i.evaluationDefinitionId??void 0}}function Ose(){return C.useContext(ui)?.configured??!1}function Pse({projectName:e,selection:n,runOptions:i=[],waitForResolvedRun:r=!1,evidenceReady:u=!0,hasSourceEvidence:h=!0,children:f}){return l.jsx(MJ,{projectName:e,selection:n,runOptions:i,waitForResolvedRun:r,evidenceReady:u,hasSourceEvidence:h,children:f})}function MJ({projectName:e,selection:n,runOptions:i,waitForResolvedRun:r,evidenceReady:u,hasSourceEvidence:h,children:f}){const b=JSON.stringify([e,n]),[v,x]=C.useState(null),S=C.useCallback(Ue=>x(ke=>ke?.key===b&&ke?.runId===Ue?.runId&&ke?.revision===Ue?.revision?ke:Ue?{...Ue,key:b}:null),[b]),k=u&&(!r||v?.key===b),N=r&&k&&v?{...n,runId:v.runId,revision:v.revision}:n,T=JSON.stringify([e,N]),{settings:z,branded:q,nonBrand:E,jobs:P}=AJ(e,N,k&&h),[M,L]=C.useState(!1),[$,F]=C.useState(null),ae=C.useRef(null);C.useEffect(()=>{L(!1),F(null)},[T]);const V=k&&!!(z.data?.enabled&&z.data.installEnabled),X=(n.queryClass==="non-brand"?E.data:q.data)?.selection,Ce={...N,...X?{...X,runId:X.runId??void 0,runIds:X.runId?void 0:X.runIds,revision:X.revision??void 0,evaluationDefinitionId:X.evaluationDefinitionId??void 0}:{}},tt=Ce.runId&&!i.some(Ue=>Ue.id===Ce.runId)?[{id:Ce.runId,label:"Displayed sweep"},...i]:i,Ke=Ue=>{Ue.preventDefault(),ae.current?.focus()};return l.jsxs(ui.Provider,{value:{projectName:e,selection:N,resolveSource:S,settings:z,summaries:{branded:q,"non-brand":E},configured:V,hasSourceEvidence:h,openManage:Ue=>{ae.current=Ue,L(!0)},openEvidence:(Ue,ke,Le)=>{ae.current=Le,F({selection:Ue,label:ke})}},children:[f,l.jsx(Dg,{open:M&&!!z.data?.actions.configure,onOpenChange:L,children:l.jsxs(mm,{onCloseAutoFocus:Ke,className:"overflow-y-auto",children:[l.jsxs(zg,{children:[l.jsx(pm,{children:"Manage sentiment"}),l.jsx(hm,{children:"Classify saved answers and review the cost before submitting a backfill."})]}),z.data?.actions.configure&&l.jsx(XJ,{projectName:e,settings:z.data,selection:Ce,runOptions:tt},JSON.stringify([z.data.evaluationDefinitionId,z.data.enabled,z.data.enablementEpoch])),P.data&&l.jsx(HJ,{projectName:e,jobs:P.data.jobs})]})}),l.jsx(Dg,{open:$!==null,onOpenChange:Ue=>{Ue||F(null)},children:l.jsxs(mm,{onCloseAutoFocus:Ke,className:"overflow-y-auto",children:[l.jsxs(zg,{children:[l.jsxs(pm,{children:["Sentiment evidence",$?`: ${$.label}`:""]}),l.jsx(hm,{children:"Stored judgments and exact quotations for the selected query and scope."})]}),$&&l.jsx($J,{projectName:e,selection:$.selection},JSON.stringify($.selection))]})})]})}function qse(e,n){const i=C.useContext(ui)?.resolveSource;C.useEffect(()=>{i?.(e?{runId:e,revision:void 0}:null)},[i,e,n])}function sk(){const e=C.useContext(ui);return e?.settings.data?.actions.configure?l.jsx(Lg,{type:"button",variant:"outline",size:"sm",onClick:n=>e.openManage(n.currentTarget),children:e.settings.data.enabled?"Manage sentiment":"Enable sentiment"}):null}function MC(e,n){return!e?.configured||n==="unknown"||n==="unclassified"?null:["branded"]}function BJ({queryClass:e="all"}){const n=C.useContext(ui),i=MC(n,e);return!n?.hasSourceEvidence||!i?.some(r=>U1(n.summaries[r].data))?null:l.jsx("ul",{className:"sentiment-legend","aria-hidden":"true",children:Eo.map(r=>l.jsxs("li",{children:[l.jsx("span",{className:`sentiment-legend-swatch ${ep[r]}`}),Hi(r)]},r))})}function LJ({queryClass:e}){const n=C.useContext(ui);if(!n?.hasSourceEvidence)return null;const i=n.summaries["non-brand"],r=i.data,u=e==="non-brand";if(!r)return u?i.isError?l.jsxs("p",{role:"alert",className:"sentiment-nonbrand-note",children:["Couldn’t load non-brand sentiment. ",l.jsx(le,{variant:"ghost",onClick:()=>{i.refetch()},children:"Retry"})]}):l.jsx("p",{role:"status",className:"sentiment-nonbrand-note",children:"Loading non-brand sentiment…"}):null;const h=r.coverage.counts;return h.unfavorable===0&&h.mixed===0?u?Ug(r)?l.jsx("p",{className:"sentiment-nonbrand-note",children:We.nonBrand.none}):tp(r)?l.jsx("p",{className:"sentiment-nonbrand-note",children:We.nonBrand.noneSoFar}):l.jsx("p",{className:"sentiment-nonbrand-note",children:r.state==="not-measured"?We.nonBrand.notRated:`${We.nonBrand.label}: ${qC(r)}`}):null:l.jsx("div",{className:"sentiment-nonbrand",role:"group","aria-label":We.nonBrand.label,children:l.jsxs("div",{className:"sentiment-nonbrand-line",children:[l.jsxs("span",{className:"sentiment-nonbrand-label",children:[We.nonBrand.label,l.jsx(ua,{text:We.nonBrand.help})]}),l.jsxs("span",{className:"sentiment-nonbrand-counts",children:[Mc.slice().reverse().filter(f=>h[f]>0).map(f=>l.jsxs("span",{children:[l.jsx("span",{"aria-hidden":"true",className:`sentiment-legend-swatch ${ep[f]}`}),h[f]," ",f]},f)),!Ug(r)&&l.jsx("span",{className:"text-caution",children:We.partial})]}),l.jsx(le,{type:"button",variant:"outline",size:"sm",onClick:f=>n.openEvidence({...Vg(n,r),queryClass:"non-brand",outcome:Mc},We.nonBrand.evidence,f.currentTarget),children:We.nonBrand.view})]})})}function Mse({queryClass:e="all",legend:n=!0,manage:i=!1}){const r=C.useContext(ui),u=MC(r,e),[h,f]=C.useState(null);if(!r)return null;if(!u){const v=r.settings.data;return!i||!v?.actions.configure?null:l.jsxs("div",{className:"sentiment-headlines-title",children:[l.jsxs("div",{children:[l.jsx("h3",{className:"sentiment-headlines-heading",children:We.title}),!(v.enabled&&v.installEnabled)&&l.jsx("p",{className:"sentiment-headlines-subtitle",children:We.states.disabled})]}),l.jsx(sk,{})]})}const b=r.hasSourceEvidence&&u.some(v=>r.summaries[v].data);return l.jsxs("div",{className:"sentiment-headlines",role:"group","aria-label":"Favorable answer scores",children:[l.jsxs("div",{className:"sentiment-headlines-title",children:[l.jsxs("div",{children:[l.jsx("h3",{className:"sentiment-headlines-heading",children:We.title}),l.jsx("p",{className:"sentiment-headlines-subtitle",children:We.subtitle})]}),i&&l.jsx(sk,{})]}),n&&l.jsx(BJ,{queryClass:e}),b&&l.jsxs("div",{className:"sentiment-headlines-columns","aria-hidden":"true",children:[l.jsx("span",{className:"sentiment-headlines-favorable",children:We.columns.favorable}),l.jsx("span",{className:"sentiment-headlines-ratings",title:We.rated,children:We.columns.rated})]}),u.map(v=>{const x=r.summaries[v];return l.jsxs("div",{className:"sentiment-class","data-query-class":v,children:[l.jsxs("div",{className:"sentiment-class-label",children:[l.jsx("span",{children:Bi[v]}),l.jsx(ua,{text:We.favorable})]}),r.hasSourceEvidence?x.data?l.jsxs(l.Fragment,{children:[l.jsx(CJ,{value:x.data,label:Bi[v]}),l.jsx(EJ,{value:x.data,label:Bi[v]}),l.jsx(zJ,{coverage:x.data.coverage,label:Bi[v]}),l.jsx(IJ,{value:x.data}),l.jsx(PJ,{value:x.data,queryClass:v,open:h===v,setOpenClass:f})]}):x.isError?l.jsxs("p",{role:"alert",className:"sentiment-class-status",children:["Couldn’t load sentiment. ",l.jsx(le,{variant:"ghost",onClick:()=>{x.refetch()},children:"Retry"})]}):l.jsx("p",{role:"status",className:"sentiment-class-status",children:"Loading sentiment…"}):l.jsx("p",{className:"sentiment-class-status",children:"No saved answers."})]},v)}),e!=="branded"&&l.jsx(LJ,{queryClass:e})]})}function Bse({queryId:e,sourceSnapshotIds:n=[],queryClass:i,location:r,showLabel:u=!1}){const h=C.useContext(ui);if(!h?.configured)return null;const f=i?h.summaries[i]:void 0,b=h.hasSourceEvidence?f?.data:void 0,v=b?.queries.filter(N=>N.queryClass===i&&(e?N.queryId===e:n.length>0)&&n.every(T=>N.sourceSnapshotIds.includes(T)))??[],x=v.length===1?v[0]:void 0,S=r===void 0?x:x?.locations.find(N=>N.location===r);if(!x||!S)return l.jsx("span",{className:"text-sm text-secondary",children:h.hasSourceEvidence&&f?.isPending&&(e||n.length)?"Loading…":"Unavailable"});const k={...h.selection,...b.selection,runId:b.selection.runId??void 0,runIds:b.selection.runId?void 0:b.selection.runIds,revision:b.selection.revision??void 0,evaluationDefinitionId:b.selection.evaluationDefinitionId??void 0,queryClass:x.queryClass,queryId:x.queryId,executionNodeKey:x.executionNodeKey??void 0,...r===void 0?{}:{location:r??"none"}};if(x.queryClass==="non-brand"){if(S.state==="unsupported")return l.jsx("span",{className:"text-sm text-secondary",children:"Unavailable"});const{unfavorable:N,mixed:T}=S.coverage.counts;if(N===0&&T===0){const z=u&&l.jsx("span",{className:"block text-sm font-normal text-secondary",children:We.nonBrand.rowLabel});return Ug(S)?l.jsxs("span",{className:"text-sm text-muted",children:[z,l.jsx("span",{"aria-hidden":"true",title:We.nonBrand.rowNone,children:_c}),l.jsx("span",{className:"sr-only",children:We.nonBrand.rowNone})]}):l.jsxs("span",{className:"text-sm text-secondary",children:[z,l.jsx("span",{children:qC(S)})]})}return l.jsxs(le,{type:"button",variant:"ghost",className:"h-auto min-h-11 flex-col items-start gap-0 px-1","aria-label":`View unfavorable and mixed answers for ${x.queryText}`,onKeyDown:z=>z.stopPropagation(),onClick:z=>{z.stopPropagation(),h.openEvidence({...k,outcome:Mc},`${x.queryText}, unfavorable and mixed`,z.currentTarget)},children:[u&&l.jsx("span",{className:"text-sm font-normal text-secondary",children:We.nonBrand.rowLabel}),N>0&&l.jsxs("span",{className:"text-sm text-negative",children:[N," unfavorable"]}),T>0&&l.jsxs("span",{className:"text-sm text-caution",children:[T," mixed"]}),S.provisional&&l.jsx("span",{className:"text-xs font-normal text-caution",children:"Provisional"})]})}return l.jsxs(le,{type:"button",variant:"ghost",className:"h-auto min-h-11 flex-col items-start gap-0 px-1","aria-label":`View ${Bi[x.queryClass]} sentiment evidence for ${x.queryText}`,onKeyDown:N=>N.stopPropagation(),onClick:N=>{N.stopPropagation(),h.openEvidence(k,x.queryText,N.currentTarget)},children:[u&&l.jsx("span",{className:"text-sm font-normal text-secondary",children:"Favorable"}),l.jsx("span",{className:"font-mono text-primary",children:S.score.favorableDisplay}),l.jsxs("span",{className:"text-sm font-normal text-secondary",children:[S.coverage.judged," judged"]}),S.provisional&&l.jsx("span",{className:"text-xs font-normal text-caution",children:"Provisional"})]})}function UJ(e){return e.outcome==="subject-not-mentioned"?"Not mentioned":e.outcome==="running"?"Classifying":e.outcome==="waiting-to-retry"?"Retrying":e.outcome?Hi(e.outcome):e.state==="not-measured"?"Not classified":e.state==="processing"?"Classifying":e.state==="failed"?"Failed":e.state==="canceled"?"Canceled":"Unavailable"}function Lse({queryId:e,sourceSnapshotIds:n,queryClass:i,provider:r,model:u,location:h,showSubjects:f=!1,showLabel:b=!1}){const v=C.useContext(ui);if(!v?.configured)return null;const x=i?v.summaries[i]:void 0,S=v.hasSourceEvidence?x?.data:void 0,k=S?.queries.filter(z=>z.queryClass===i&&(!e||z.queryId===e)&&n.length>0&&n.every(q=>z.sourceSnapshotIds.includes(q)))??[],N=k.length===1?k[0]:void 0,T=N?.assessments?.filter(z=>n.includes(z.sourceSnapshotId)&&z.provider===r&&z.location===h&&(u===void 0||z.servedModel===u))??[];return l.jsxs("div",{role:"group",className:"text-sm text-secondary","aria-label":`${r||"Saved answer"} sentiment`,children:[b&&l.jsx("span",{className:"block text-sm text-secondary",children:"Sentiment"}),T.length?T.map(z=>{const q=UJ(z),E=OC(z.outcome),P=l.jsxs(l.Fragment,{children:[f&&l.jsxs("span",{children:[z.subjectLabel," · "]}),l.jsx(wn,{tone:E,className:"max-w-full shrink-0 rounded-none border-0 bg-transparent p-0 text-sm font-normal tracking-normal [overflow-wrap:normal]",children:q})]}),M={...v.selection,...S.selection,runId:S.selection.runId??void 0,runIds:S.selection.runId?void 0:S.selection.runIds,revision:S.selection.revision??void 0,evaluationDefinitionId:S.selection.evaluationDefinitionId??void 0,queryClass:N.queryClass,queryId:N.queryId,executionNodeKey:N.executionNodeKey??void 0,assessmentId:z.assessmentId??void 0};return l.jsxs("div",{className:"flex items-center gap-1",children:[z.assessmentId?l.jsx(le,{type:"button",variant:"ghost",className:"h-auto min-h-11 flex-wrap justify-start whitespace-normal px-1 text-left text-sm","aria-label":`View ${z.provider} sentiment evidence for ${z.subjectLabel}: ${q}`,onKeyDown:L=>L.stopPropagation(),onClick:L=>{L.stopPropagation(),v.openEvidence(M,`${N.queryText} · ${z.provider} · ${z.subjectLabel}`,L.currentTarget)},children:P}):l.jsx("span",{children:P}),z.reason&&l.jsx(ua,{text:z.reason})]},JSON.stringify([z.sourceSnapshotId,z.subjectId,z.assessmentId]))}):l.jsx("span",{children:v.hasSourceEvidence&&x?.isPending&&n.length?"Loading…":"Unavailable"})]})}function VJ({item:e}){return l.jsxs("article",{className:"space-y-4 border-b border-default py-5 text-sm text-secondary",children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l.jsx("strong",{className:"text-primary",children:e.subject.displayName}),l.jsx(wn,{tone:OC(e.outcome),children:Hi(e.outcome)}),l.jsx("span",{children:Bi[e.context.queryClass]}),l.jsx("span",{children:e.context.provider}),l.jsx("span",{children:e.context.servedModel??"Source model unavailable"}),l.jsx("span",{children:e.context.location??"No location"})]}),e.reason&&l.jsx("p",{children:e.reason}),l.jsxs("section",{children:[l.jsx("h3",{className:"mb-2 text-heading",children:"Conclusion evidence"}),e.conclusion.length?e.conclusion.map(n=>l.jsx("blockquote",{className:"mb-2 border-l border-strong pl-3 text-primary",children:n.text},`${n.id}:${n.start}`)):l.jsx("p",{children:"No valid conclusion evidence is available."})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"mb-2 text-heading",children:"Complaint evidence"}),e.complaint?.length?e.complaint.map(n=>l.jsx("blockquote",{className:"mb-2 border-l border-strong pl-3 text-primary",children:n.text},`${n.id}:${n.start}`)):l.jsx("p",{children:"No complaint was identified."})]}),l.jsxs("details",{children:[l.jsx("summary",{className:"cursor-pointer",children:"Original source answer"}),l.jsx("p",{className:"mt-2 whitespace-pre-wrap break-words text-primary",children:e.sourceText})]}),l.jsxs("details",{children:[l.jsx("summary",{className:"cursor-pointer",children:"Assessment provenance"}),l.jsxs("dl",{className:"mt-3 space-y-2 break-all",children:[l.jsx("dt",{children:"Query"}),l.jsx("dd",{children:e.context.queryText}),l.jsx("dt",{children:"Subject"}),l.jsxs("dd",{children:[e.subject.displayName," (",e.subject.id,")"]}),l.jsx("dt",{children:"Run"}),l.jsx("dd",{children:e.runId}),l.jsx("dt",{children:"Revision"}),l.jsx("dd",{children:e.context.revision??"Unavailable"}),l.jsx("dt",{children:"Evaluator"}),l.jsx("dd",{children:e.returnedModel??"Unavailable"}),l.jsx("dt",{children:"Evaluation definition"}),l.jsx("dd",{children:e.evaluationDefinitionId}),l.jsx("dt",{children:"Source snapshot"}),l.jsx("dd",{children:e.sourceSnapshotId}),l.jsx("dt",{children:"Source hash"}),l.jsx("dd",{children:e.sourceTextHash}),e.context.usageEdges.map((n,i)=>l.jsxs("div",{children:[l.jsx("dt",{children:"Assignment"}),l.jsxs("dd",{children:["Target ",n.targetId,"; Property ",n.propertyId??"None","; market ",n.marketId??"None","; ",n.queryClass]})]},i))]})]})]})}function $J({projectName:e,selection:n}){const[i,r]=C.useState(),u=yt({queryKey:Cc(e,"evidence",n,i),queryFn:()=>PH(e,n,i),retry:!1});return u.isPending?l.jsx("p",{role:"status",className:"mt-4 text-sm text-secondary",children:"Loading sentiment evidence…"}):u.isError?l.jsxs("p",{role:"alert",className:"mt-4 text-sm text-secondary",children:["Could not load sentiment evidence. ",l.jsx(le,{variant:"outline",onClick:()=>{u.refetch()},children:"Retry evidence"})]}):l.jsxs(l.Fragment,{children:[u.data.items.length?u.data.items.map(h=>l.jsx(VJ,{item:h},h.assessmentId)):l.jsx("p",{className:"mt-4 text-sm text-secondary",children:"No stored sentiment evidence for this query and scope."}),l.jsxs("div",{className:"mt-3 flex gap-2",children:[i&&l.jsx(le,{variant:"outline",onClick:()=>r(void 0),children:"First evidence page"}),u.data.nextCursor&&l.jsx(le,{variant:"outline",onClick:()=>r(u.data.nextCursor??void 0),children:"Next evidence page"})]})]})}function KJ({projectName:e,jobId:n}){const[i,r]=C.useState(),u=yt({queryKey:Cc(e,`job:${n}`,void 0,i),queryFn:()=>LH(e,n,i),retry:!1});return u.isPending?l.jsx("p",{role:"status",children:"Loading attempts…"}):u.isError?l.jsxs("p",{role:"alert",children:["Could not load attempts. ",l.jsx(le,{variant:"outline",onClick:()=>{u.refetch()},children:"Retry attempts"})]}):l.jsxs(l.Fragment,{children:[u.data.attempts.map(h=>l.jsxs("p",{children:[h.errorCode??"Request complete","; ",h.usage.kind==="unknown"?"Usage unknown":`${h.usage.inputTokens??"Unknown"} input tokens (${h.usage.kind})`]},h.id)),l.jsxs("div",{className:"mt-2 flex gap-2",children:[i&&l.jsx(le,{variant:"outline",onClick:()=>r(void 0),children:"Newest attempts"}),u.data.nextAttemptCursor&&l.jsx(le,{variant:"outline",onClick:()=>r(u.data.nextAttemptCursor??void 0),children:"Older attempts"})]})]})}function GJ({projectName:e,job:n}){const[i,r]=C.useState(!1);return l.jsxs("details",{onToggle:u=>r(u.currentTarget.open),children:[l.jsx("summary",{children:"Job details"}),n.cancellationReason&&l.jsx("p",{children:n.cancellationReason}),Object.entries(n.counts).filter(([,u])=>u>0).map(([u,h])=>l.jsxs("p",{children:[Hi(u),": ",h]},u)),l.jsxs("p",{children:["Attempts: ",n.attemptCount]}),i&&n.attemptCount>0&&l.jsx(KJ,{projectName:e,jobId:n.id})]})}function HJ({projectName:e,jobs:n}){return l.jsxs("details",{className:"mt-6 text-sm text-secondary",children:[l.jsx("summary",{className:"cursor-pointer",children:"Recent sentiment jobs"}),n.length===0?l.jsx("p",{className:"mt-2",children:"No sentiment jobs have been submitted."}):l.jsx("div",{className:"data-table-wrapper mt-3",children:l.jsxs("table",{className:"data-table","aria-label":"Sentiment jobs",children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{children:"Submitted"}),l.jsx("th",{children:"State"}),l.jsx("th",{children:"Selected"}),l.jsx("th",{children:"Details"})]})}),l.jsx("tbody",{children:n.map(i=>l.jsxs("tr",{children:[l.jsx("td",{children:pQ(i.createdAt)}),l.jsx("td",{children:Hi(i.state)}),l.jsx("td",{children:i.selected}),l.jsx("td",{children:l.jsx(GJ,{projectName:e,job:i})})]},i.id))})]})})]})}const QJ={probe:"Probe sweeps","unsupported-run-kind":"Not an answer sweep","failed-run":"Failed sweep","incomplete-run":"Incomplete sweep","legacy-missing-provenance":"Saved without its frozen query and subject record","legacy-missing-language":"Saved before the answer language was recorded","excluded-branded":"Branded answers (backfill that class separately)","excluded-non-brand":"Non-brand answers (backfill that class separately)"};function FJ(e){return QJ[e]??Hi(e)}function BC(e){return[e.provider&&`engine ${e.provider}`,e.model&&`model ${e.model}`,e.location&&(e.location==="none"?"no location":`location ${e.location}`),e.scope!=="project"&&e.scopeKey&&`${e.scope} ${e.scopeKey}`,e.marketKey&&`market ${e.marketKey}`,e.queryId&&`query ${e.queryId}`,e.revision!==void 0&&`revision ${e.revision}`].filter(n=>!!n)}function ZJ(e){const n=BC(e);return[`${Bi[e.queryClass]} queries`,...n.length?n:["whole sweep"]].join(" · ")}function YJ(e,n,i,r){return r?{...e,queryClass:i,queryId:void 0,runIds:void 0,runId:n}:{mode:"auto",scope:"project",queryClass:i,runId:n}}function XJ({projectName:e,settings:n,selection:i,runOptions:r}){const u=Ds(),[h,f]=C.useState(n.enabled),[b,v]=C.useState(i.runId??""),[x,S]=C.useState(i.queryClass),[k,N]=C.useState(!1),[T,z]=C.useState(null),q=C.useRef(null),E=BC({...i,queryId:void 0}),P=()=>u.invalidateQueries({queryKey:["sentiment",e]}),M=()=>{z(null),q.current=null},L=oi({mutationFn:async()=>{if(!(await Md(e)).actions.configure)throw new Error("Administrator permission is required to configure sentiment.");return OH(e,{enabled:h})},onSuccess:async()=>{M(),await P(),await u.invalidateQueries({queryKey:["project-overview-slim"]})},onError:P}),$=oi({mutationFn:async()=>{if(!(await Md(e)).actions.backfill)throw new Error("Administrator permission is required to backfill sentiment.");return qH(e,YJ(i,b,x,k&&E.length>0))},onSuccess:V=>{z(V),q.current=crypto.randomUUID()},onError:P}),F=oi({mutationFn:async()=>{if(!T?.previewToken||!q.current)throw new Error("Create and review a backfill preview first.");if(!(await Md(e)).actions.backfill)throw new Error("Administrator permission is required to backfill sentiment.");return MH(e,T.previewToken,q.current)},onSuccess:async()=>{M(),await P()},onError:P}),ae=L.isPending||$.isPending||F.isPending;return l.jsxs("div",{className:"mt-5 space-y-5 text-sm text-secondary",children:[l.jsx("p",{children:n.disclosure}),!n.ready&&l.jsx("p",{children:n.readinessReasons.join("; ")||"An operator must configure sentiment on this installation."}),l.jsxs("form",{className:"space-y-3",onSubmit:V=>{V.preventDefault(),L.mutate()},children:[l.jsxs("label",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",checked:h,disabled:ae,onChange:V=>{f(V.target.checked),M()}}),"Enable project sentiment"]}),l.jsx("p",{children:"Enabling applies to future completed sweeps. Past sweeps require an explicit backfill."}),l.jsx(Lg,{type:"submit",disabled:ae,children:L.isPending?"Saving…":"Save sentiment settings"}),L.isError&&l.jsx("p",{role:"alert",children:qi(L.error)}),L.isSuccess&&l.jsx("p",{role:"status",children:"Sentiment settings saved."})]}),n.actions.backfill&&l.jsxs("section",{className:"space-y-3",children:[l.jsx("h3",{children:"Backfill a saved sweep"}),l.jsxs("label",{className:"block",children:["Saved sweep",l.jsxs("select",{className:"mt-1 block w-full rounded-md border border-default bg-bg p-2 text-primary",value:b,disabled:ae,onChange:V=>{v(V.target.value),M()},children:[l.jsx("option",{value:"",children:"Select a saved sweep"}),r.map(V=>l.jsx("option",{value:V.id,children:V.label},V.id))]})]}),l.jsxs("label",{className:"block",children:["Query class",l.jsxs("select",{className:"mt-1 block w-full rounded-md border border-default bg-bg p-2 text-primary",value:x,disabled:ae,onChange:V=>{S(V.target.value),M()},children:[l.jsx("option",{value:"non-brand",children:"Non-brand"}),l.jsx("option",{value:"branded",children:"Branded"})]})]}),l.jsx("p",{children:"The backfill covers every engine, location and query of the chosen sweep for this query class."}),E.length>0&&l.jsxs("label",{className:"flex items-start gap-2",children:[l.jsx("input",{type:"checkbox",className:"mt-1",checked:k,disabled:ae,onChange:V=>{N(V.target.checked),M()}}),l.jsxs("span",{children:["Limit to the current view",l.jsx("span",{className:"block",children:E.join(" · ")})]})]}),l.jsx(le,{variant:"outline",disabled:ae||!b||!n.enabled||!n.ready,onClick:()=>{M(),$.mutate()},children:$.isPending?"Preparing preview…":"Preview sentiment backfill"}),$.isError&&l.jsx("p",{role:"alert",children:qi($.error)}),T&&l.jsxs("div",{className:"space-y-3",children:[l.jsxs("dl",{className:"grid grid-cols-[1fr_auto] gap-2",children:[l.jsx("dt",{children:"Selection"}),l.jsx("dd",{className:"text-right",children:ZJ(T.selection)}),l.jsx("dt",{children:"Eligible assessments"}),l.jsx("dd",{children:T.eligibleAssessments}),l.jsx("dt",{children:"Already classified"}),l.jsx("dd",{children:T.alreadyClassified}),l.jsx("dt",{children:"Estimated input tokens"}),l.jsx("dd",{children:T.estimatedInputTokens}),l.jsx("dt",{children:"Estimated cost (USD)"}),l.jsx("dd",{children:T.estimatedCostUsd??"Unavailable"})]}),l.jsx(ua,{text:T.estimateMethod}),T.eligibleAssessments===0&&l.jsx("p",{children:"No saved answers in this selection can be classified."}),T.skipped.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:"Not included:"}),l.jsx("ul",{"aria-label":"Skipped assessments",className:"list-disc pl-5",children:T.skipped.map(V=>l.jsxs("li",{children:[FJ(V.reason),": ",V.count]},`${V.runId}:${V.reason}`))})]}),l.jsx(Lg,{disabled:ae||!T.previewToken||T.eligibleAssessments===0,onClick:()=>F.mutate(),children:F.isPending?"Submitting…":"Confirm sentiment backfill"})]}),F.isError&&l.jsxs("p",{role:"alert",children:[qi(F.error)," Retry uses the same request key."]}),F.isSuccess&&l.jsx("p",{role:"status",children:"Backfill submitted. Progress is available in Recent jobs."})]})]})}const JJ=20,WJ=6;function eW({points:e,tone:n}){const i=C.useId();if(e.length===0)return null;const r=42,u=132,h=5,f=u-h*2,b=r-h*2,v=b-WJ,x=E=>h+E/Math.max(e.length-1,1)*f,S=nG(e),k=Math.min(...e),N=Math.max(...e),T=Math.max(N-k,JJ),z=(N+k)/2-T/2,q=e.map((E,P)=>({x:x(P),y:h+(1-(E-z)/T)*v}));return l.jsxs("svg",{className:`sparkline sparkline-${n}${S?" sparkline-provisional":""}`,viewBox:`0 0 ${u} ${r}`,"aria-hidden":"true",children:[l.jsx("defs",{children:l.jsx("clipPath",{id:i,children:l.jsx("rect",{x:h,y:h,width:f,height:b,rx:"8"})})}),l.jsx("line",{className:"sparkline-guide",x1:h,x2:u-h,y1:r-h,y2:r-h}),q.length===1?l.jsx("circle",{className:"sparkline-point",cx:q[0].x,cy:q[0].y,r:"3"}):l.jsx("polyline",{clipPath:`url(#${i})`,points:q.map(E=>`${E.x},${E.y}`).join(" "),vectorEffect:"non-scaling-stroke"})]})}function tW({project:e,sentimentColumn:n}){return l.jsxs("div",{className:`project-row relative${n?" project-row-with-sentiment":""}`,children:[l.jsx("div",{className:"project-row-chart",children:l.jsx(eW,{points:e.trend,tone:eC(e.lastRun.status)})}),l.jsxs("div",{className:"project-row-primary",children:[l.jsxs(at,{to:"/projects/$projectName",params:{projectName:e.project.name},className:"after:absolute after:inset-0 after:rounded-xl focus-visible:outline-none focus-visible:after:ring-2 focus-visible:after:ring-mono-400",children:[l.jsx("p",{className:"project-name",children:e.project.name}),l.jsx("p",{className:"project-domain",children:e.project.canonicalDomain})]}),l.jsx("p",{className:"project-insight",children:e.insight})]}),l.jsx("div",{className:"project-row-stat",children:l.jsxs("div",{className:"metric-inline-block",children:[l.jsx("p",{className:"metric-inline-label",children:"Mentioned"}),l.jsx("p",{className:`metric-inline-value ${e.mentionTone==="caution"?"text-caution-400":""}`,children:e.hasMeasurement===!1?"Not measured":nm(e.mentionScore,Ga.percent)}),l.jsx("p",{className:`metric-inline-caption${e.providerCoverage?" text-caution":""}`,title:e.providerCoverage,children:e.providerCoverage?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"sr-only",children:"Partial sweep: "}),e.providerCoverage]}):e.mentionDelta})]})}),l.jsx("div",{className:"project-row-stat",children:l.jsxs("div",{className:"metric-inline-block",children:[l.jsxs("p",{className:"metric-inline-label",children:[l.jsx("span",{"aria-hidden":"true",children:"Pressure"}),l.jsx("span",{className:"sr-only",children:"Competitor pressure"})]}),l.jsx("p",{className:"metric-inline-value",children:e.hasMeasurement===!1?"Not measured":e.competitorPressureLabel}),l.jsx("p",{className:"metric-inline-caption","aria-hidden":"true"})]})}),V1(e.sentiment)?l.jsx(qJ,{value:e.sentiment}):n&&l.jsx("div",{className:"project-row-stat","aria-hidden":"true","data-sentiment-placeholder":!0}),l.jsx("span",{className:"project-row-link",children:l.jsx(Vc,{className:"h-4 w-4 text-muted"})})]})}function nW(){const{isAdmin:e}=fa(),n=su(),{dashboard:i,isLoading:r,isError:u,activityLoading:h,activityError:f,refetch:b}=Ym(),v=i??n?.dashboard,S=I1(!n,n?.health),{openRun:k}=O1();if(u&&!v)return l.jsxs("div",{className:"page-container",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Portfolio unavailable"}),l.jsx("p",{className:"page-subtitle",children:"Canonry could not load the project list."})]})}),l.jsxs("div",{className:"max-w-xl rounded-lg border border-negative bg-negative-soft p-4",role:"alert",children:[l.jsx("p",{className:"text-sm font-medium text-heading",children:"Your projects have not been changed."}),l.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Check the connection or sign in again, then retry."}),l.jsx(le,{type:"button",variant:"secondary",className:"mt-4",onClick:()=>{b()},children:"Retry loading portfolio"})]})]});if(!v||r)return l.jsxs("div",{className:"page-skeleton",children:[l.jsxs("div",{className:"page-skeleton-header",children:[l.jsx("div",{className:"skeleton-text h-6 w-32"}),l.jsx("div",{className:"skeleton-text-sm w-64"})]}),l.jsx("div",{className:"space-y-3",children:[1,2,3].map(M=>l.jsxs("div",{className:"rounded-xl border border-default bg-surface p-4 flex items-center gap-4",children:[l.jsxs("div",{className:"flex-1 space-y-2",children:[l.jsx("div",{className:"skeleton-text w-36"}),l.jsx("div",{className:"skeleton-text-sm w-48"})]}),l.jsx("div",{className:"skeleton-text w-16"}),l.jsx("div",{className:"skeleton-text w-16"}),l.jsx("div",{className:"skeleton h-8 w-20 rounded"})]},M))})]});const N=v.portfolioOverview,T=N.projects.length>0&&N.projects.every(M=>M.hasMeasurement===!1),z=N.projects.some(M=>V1(M.sentiment)),q=N.attentionItems.map(M=>T&&M.id==="attention_stable"?{...M,tone:"neutral",title:"Awaiting first measurement",detail:"Visibility results will appear after the first sweep."}:M),E=S.data??n?.health??{apiStatus:{label:"API",state:"checking",detail:"Checking service health"},workerStatus:{label:"Worker",state:"checking",detail:"Checking service health"}},P=uZ(N.systemHealth.filter(M=>e||M.id==="api"||M.id==="worker"),E,v.settings);return l.jsxs("div",{className:"page-container",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Portfolio"}),l.jsx("p",{className:"page-subtitle",children:"Visibility across all projects."})]})}),N.projects.length>0?l.jsx("div",{className:"project-list project-list-scrollable",children:N.projects.map(M=>l.jsx(tW,{project:M,sentimentColumn:z},M.project.id))}):l.jsxs(_a,{className:"surface-card empty-card",children:[l.jsx("h3",{children:N.emptyState?.title??"No projects yet"}),l.jsx("p",{className:"supporting-copy",children:N.emptyState?.detail}),l.jsx(le,{size:"sm",asChild:!0,children:l.jsx(at,{to:N.emptyState?.ctaHref==="/setup"||!N.emptyState?.ctaHref?"/setup":"/",children:N.emptyState?.ctaLabel??"Launch setup"})})]}),l.jsxs("div",{className:"overview-secondary-grid",children:[q.length>0&&l.jsxs("section",{className:"overview-secondary-section",children:[l.jsx("div",{className:"section-head section-head-inline",children:l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Needs attention"}),l.jsx("h2",{className:"section-title-sm",children:"What changed"})]})}),l.jsx("div",{className:"attention-list attention-list-scrollable",children:q.map(M=>M.href?l.jsxs(at,{to:M.href,className:`attention-item attention-item-${M.tone}`,children:[l.jsxs("div",{children:[l.jsx("p",{className:"attention-title",children:M.title}),l.jsx("p",{className:"attention-detail",children:M.detail})]}),M.actionLabel&&l.jsx("span",{className:"attention-action",children:M.actionLabel})]},M.id):l.jsxs("div",{className:`attention-item attention-item-static attention-item-${M.tone}`,children:[l.jsxs("div",{children:[l.jsx("p",{className:"attention-title",children:M.title}),l.jsx("p",{className:"attention-detail",children:M.detail})]}),M.actionLabel&&l.jsx("span",{className:"attention-action",children:M.actionLabel})]},M.id))})]}),l.jsxs("section",{className:"overview-secondary-section",children:[l.jsx("div",{className:"section-head section-head-inline",children:l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Recent runs"}),l.jsx("h2",{className:"section-title-sm",children:"Activity"})]})}),l.jsx("div",{className:"compact-stack compact-stack-scrollable",children:f?l.jsxs("div",{role:"alert",children:[l.jsx("p",{className:"text-sm text-secondary",children:"Recent jobs could not be loaded."}),l.jsx(le,{type:"button",variant:"secondary",className:"mt-3",onClick:()=>{b()},children:"Retry loading activity"})]}):h?l.jsx("p",{className:"supporting-copy",role:"status",children:"Loading recent jobs…"}):N.recentRuns.length>0?N.recentRuns.map(M=>l.jsxs("button",{className:"compact-run",type:"button",onClick:()=>k(M.id),children:[l.jsxs("div",{children:[l.jsx("p",{className:"compact-run-title",children:M.projectName}),l.jsx("p",{className:"compact-run-detail",children:M.summary})]}),l.jsx(z1,{status:M.status})]},M.id)):l.jsx("p",{className:"supporting-copy",children:"Run history appears here after the first launch."})})]})]}),l.jsxs("section",{className:"page-section",children:[l.jsx("div",{className:"section-head section-head-inline",children:l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"System health"}),l.jsx("h2",{className:"section-title-sm",children:"Infrastructure"})]})}),l.jsx("div",{className:"divide-y divide-default border-y border-default",children:P.map(M=>{const L=M.id==="api"?E.apiStatus:M.id==="worker"?E.workerStatus:void 0,$=L?L.state==="ok"?void 0:Kr(L):M.tone==="positive"?void 0:M.meta;return l.jsxs("div",{className:"flex items-start justify-between gap-4 py-3",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium text-heading",children:M.label}),$&&l.jsx("p",{className:"mt-1 text-sm text-secondary",children:$})]}),l.jsx(wn,{tone:M.tone,title:L?Kr(L):M.meta,children:M.detail})]},M.id)})})]})]})}const aW='a, button, input, select, textarea, label, [role="button"], [role="link"], [role="checkbox"], [role="menuitem"]';function iW(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!1;const n=e.target;if(n&&typeof n.closest=="function"&&n.closest(aW))return!1;const i=typeof window<"u"?window.getSelection():null;return!(i&&!i.isCollapsed&&i.toString().trim()!=="")}function sW({onApplied:e}){const{canWrite:n}=fa(),[i,r]=C.useState(""),[u,h]=C.useState(!1),[f,b]=C.useState([]),[v,x]=C.useState([]);if(Gm()||!n)return null;const S=async()=>{if(!i.trim())return;h(!0),b([]),x([]);const k=N6(i),N=[],T=[];for(let z=0;z<k.length;z++){const q=k[z];if(q.errors.length>0){N.push(`Document ${z+1}: ${q.errors[0]?.message}`);continue}const E=q.toJSON();if(!(!E||typeof E!="object"))try{const P=await kH(E);T.push(`Applied "${P.displayName||P.name}" (revision ${P.configRevision})`)}catch(P){N.push(`Document ${z+1}: ${qi(P)}`)}}b(T),x(N),h(!1),T.length>0&&(bn({title:"YAML applied",detail:`Applied ${T.length} document${T.length===1?"":"s"} successfully.`,tone:N.length>0?"caution":"positive",dedupeKey:"yaml:apply",dedupeMode:"replace"}),e())};return l.jsxs("section",{className:"mt-8",children:[l.jsx("div",{className:"page-section-divider"}),l.jsx("div",{className:"section-head mt-6",children:l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Config as code"}),l.jsx("h2",{className:"text-sm font-medium text-strong",children:"Apply YAML"})]})}),l.jsxs("p",{className:"text-muted text-sm mb-3",children:["Paste a ",l.jsx("code",{className:"text-secondary",children:"canonry.yaml"})," config (multi-document YAML with ",l.jsx("code",{className:"text-secondary",children:"---"})," separators supported)."]}),l.jsx("textarea",{className:"setup-input w-full font-mono text-xs",rows:10,placeholder:`apiVersion: canonry/v1
|
|
64
|
+
… (${n.length-2e3} more chars)`:n}catch{return String(e)}}function RC({content:e}){return l.jsx("div",{className:"text-heading",children:l.jsx(j6,{remarkPlugins:[A6],components:{h1:n=>l.jsx("h1",{...n,className:"mt-3 mb-2 text-base font-semibold text-primary"}),h2:n=>l.jsx("h2",{...n,className:"mt-3 mb-2 text-sm font-semibold text-primary"}),h3:n=>l.jsx("h3",{...n,className:"mt-3 mb-1.5 text-sm font-semibold text-heading"}),h4:n=>l.jsx("h4",{...n,className:"mt-2 mb-1 text-xs font-semibold uppercase tracking-wide text-neutral"}),p:n=>l.jsx("p",{...n,className:"mb-2 leading-relaxed"}),ul:n=>l.jsx("ul",{...n,className:"mb-2 ml-4 list-disc space-y-1"}),ol:n=>l.jsx("ol",{...n,className:"mb-2 ml-4 list-decimal space-y-1"}),li:n=>l.jsx("li",{...n,className:"marker:text-mono-600"}),strong:n=>l.jsx("strong",{...n,className:"font-semibold text-primary"}),em:n=>l.jsx("em",{...n,className:"text-strong"}),code:({children:n,...i})=>l.jsx("code",{...i,className:"rounded bg-mono-800/70 px-1 py-0.5 font-mono text-[12px] text-positive-200",children:n}),pre:n=>l.jsx("pre",{...n,className:"mb-2 overflow-x-auto rounded-md border border-base bg-bg-elevated/70 p-3 font-mono text-xs text-strong"}),a:n=>l.jsx("a",{...n,className:"text-positive-400 underline decoration-positive-700 hover:decoration-positive-400",target:"_blank",rel:"noopener noreferrer"}),table:n=>l.jsx("div",{className:"mb-2 overflow-x-auto",children:l.jsx("table",{...n,className:"w-full border-collapse text-xs"})}),thead:n=>l.jsx("thead",{...n,className:"border-b border-base"}),th:n=>l.jsx("th",{...n,className:"px-2 py-1 text-left font-semibold text-neutral"}),tr:n=>l.jsx("tr",{...n,className:"border-b border-mono-900"}),td:n=>l.jsx("td",{...n,className:"px-2 py-1 text-strong"}),blockquote:n=>l.jsx("blockquote",{...n,className:"mb-2 border-l-2 border-strong pl-3 italic text-secondary"}),hr:()=>l.jsx("hr",{className:"my-3 border-base"})},children:e})})}function dJ(){return l.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-wider text-positive-400",children:"Aero"}),l.jsxs("div",{className:"flex items-center gap-1","aria-label":"Aero is thinking",children:[l.jsx("span",{className:"aero-dot h-1.5 w-1.5 rounded-full bg-positive-400/80"}),l.jsx("span",{className:"aero-dot aero-dot-2 h-1.5 w-1.5 rounded-full bg-positive-400/60"}),l.jsx("span",{className:"aero-dot aero-dot-3 h-1.5 w-1.5 rounded-full bg-positive-400/40"})]})]})}function DC({isAdmin:e,account:n}){return e||n?.role==="viewer"&&XG()}function mJ(){const{isAdmin:e,account:n}=fa(),i=gk(),r=/^\/projects\/([^/]+)/.exec(i.pathname),u=r?decodeURIComponent(r[1]):null,h=yt({...Bo({client:J}),enabled:u!==null,staleTime:6e4}),f=SX(i.pathname,i.search),b=h.data??[],v=b.find(N=>N.id===u)??b.find(N=>N.name===u),x=sQ(v?.name??u??"",f),S=j1(),k=S||DC({isAdmin:e,account:n});return!u||!k||!v?null:l.jsx(FX,{projectName:v.name,context:x,preview:S},v.name)}function ek(e,n,i){switch(e.invalidateQueries({queryKey:JN({client:J})}),e.invalidateQueries({queryKey:$r({client:J})}),On(e,"runs"),n){case Oe["answer-visibility"]:Og(e,i,"none"),On(e,"visibilityReport"),On(e,"queryTracking");return;case Oe["backlink-extract"]:return;case Oe["site-audit"]:On(e,"technicalAeo");return;case Oe["gsc-sync"]:case Oe["inspect-sitemap"]:On(e,"gsc");return;case Oe["ga-sync"]:On(e,"ga");return;case Oe["traffic-sync"]:On(e,"ga"),On(e,"traffic");return;case Oe["bing-inspect"]:case Oe["bing-inspect-sitemap"]:On(e,"bing");return;case Oe["aeo-discover-seed"]:case Oe["aeo-discover-probe"]:Og(e,i);return;case Oe["gbp-sync"]:On(e,"gbp");return;case Oe["ads-sync"]:On(e,"ads");return;case Oe["google-ads-sync"]:On(e,"googleAds"),On(e,"conversionTracking");return;case Oe["gtm-sync"]:On(e,"gtm"),On(e,"conversionTracking");return;default:return n}}const tk=[{label:"GitHub",href:"https://github.com/Canonry/canonry",Icon:kk},{label:"Docs",href:"https://github.com/Canonry/canonry/tree/main/docs",Icon:g6},{label:"Changelog",href:"https://github.com/Canonry/canonry/releases",Icon:y6}],nk=e=>({label:e,state:"checking",detail:"Checking service health"}),pJ={apiStatus:nk("API"),workerStatus:nk("Worker")};function hJ(e){return e==="completed"?"positive":e==="partial"?"caution":"negative"}function fJ(e){const n=Nc(e.kind);return e.status==="completed"?`${n} completed`:e.status==="partial"?`${n} completed with partial results`:e.status==="cancelled"?`${n} cancelled`:`${n} failed`}function gJ(e,n){return e.error?`${n}: ${T0(e.error)}`:e.location?`${n} · ${e.location}`:n}function ak(e,n,i){if(n)return n;const r=i.find(u=>u.id===e);return r?.displayName||r?.name||e}function yJ(e,n){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,n>0?`${n} skipped at queue time`:null].filter(Boolean).join(", ")}function bJ(e){return e.failed>0||e.cancelled>0?"negative":e.partial>0?"caution":"positive"}function vJ(){const e=Ds(),n=C.useSyncExternalStore(aC,Gi,Gi),i=Object.keys(n.runs).length>0||Object.keys(n.batches).length>0,r=yt({...qc({client:J}),enabled:i,staleTime:_s,refetchInterval:3e3}),u=yt({...Bo({client:J}),enabled:i}),h=C.useRef({}),f=C.useCallback(()=>{r.refetch()},[r.refetch]);return C.useEffect(()=>{i&&f()},[i,f]),C.useEffect(()=>{if(!i||typeof window>"u")return;const b=()=>{document.visibilityState==="visible"&&f()};return window.addEventListener("focus",f),document.addEventListener("visibilitychange",b),()=>{window.removeEventListener("focus",f),document.removeEventListener("visibilitychange",b)}},[i,f]),C.useEffect(()=>{const b=r.data??[],v=u.data??[],x=Object.fromEntries(b.map(k=>[k.id,k])),S=Object.fromEntries(b.map(k=>[k.id,k.status]));for(const k of Object.values(n.runs)){const N=x[k.runId];if(!N||!vZ(N.status)||(h.current[N.id]??k.lastAnnouncedStatus)===N.status)continue;const z=v.find(E=>E.id===N.projectId);if(z&&ek(e,N.kind,z.name),k.sourceAction==="run-all"){Vf(N.id);continue}const q=ak(N.projectId,k.projectLabel,v);bn({title:fJ(N),detail:gJ(N,q),tone:hJ(N.status),dedupeKey:`run:${N.id}`,dedupeMode:"replace",cta:{label:"View run",intent:"open-run-drawer",runId:N.id}}),Vf(N.id)}if(r.data!==void 0){const k=new Set(b.map(T=>T.id)),N=wZ(Object.values(n.runs),k,Date.now(),xZ);for(const T of N){const z=v.find(q=>q.id===T.projectId);z&&ek(e,T.kind,z.name),T.sourceAction!=="run-all"&&bn({title:`${Nc(T.kind)} status unavailable`,detail:ak(T.projectId,T.projectLabel,v),tone:"neutral",dedupeKey:`run-stale:${T.runId}`,dedupeMode:"replace"}),Vf(T.runId)}}for(const k of Object.values(n.batches)){const N=SZ(k.runIds,x);N.finished&&(bn({title:"Run-all batch finished",detail:yJ(N,k.skippedCount),tone:bJ(N),dedupeKey:`batch:${k.batchId}`,dedupeMode:"replace",cta:{label:"View runs",intent:"go-to-runs"}}),bZ(k.batchId))}h.current=S},[u.data,r.data,n,e]),null}function xJ(){const{account:e,isAdmin:n}=fa(),i=su(),r=C.useMemo(()=>MN(),[]),u=C.useMemo(ZG,[]),h=C.useMemo(YG,[]),f=j1()||h&&DC({isAdmin:n,account:e}),b=C.useMemo(JG,[]),v=gk(),{dashboard:x,isLoading:S,refetch:k}=Ym(void 0,{includeSettings:!r,includeOverviews:!1,pauseProjectPolling:v.pathname==="/setup"}),z=I1(!i,i?.health).data??i?.health??pJ,{runId:q,evidenceId:E,closeDrawer:P}=O1(),[M,L]=C.useState(!1),[$,F]=C.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem("canonry:sidebarHidden")==="true"}catch{return!1}}),[ae,V]=C.useState(()=>{if(typeof window>"u")return null;try{return window.localStorage.getItem("canonry:dismissedUpdateVersion")}catch{return null}}),[Z]=C.useState(()=>typeof window>"u"?null:new URLSearchParams(window.location.search).get("force-update")),X=Z?{current:z.apiStatus.version??"0.0.0",latest:Z,url:"https://www.npmjs.com/package/@canonry/canonry",upgradeCommand:"npm install -g @canonry/canonry"}:z.apiStatus.updateAvailable,Ce=b&&X&&X.latest!==ae,tt=()=>{if(X){try{window.localStorage.setItem("canonry:dismissedUpdateVersion",X.latest)}catch{}V(X.latest)}},Ke=()=>{const re=!$;try{re?window.localStorage.setItem("canonry:sidebarHidden","true"):window.localStorage.removeItem("canonry:sidebarHidden")}catch{}F(re)},Ue=lX(q),ke=Ue.data??null,Le=Ue.isLoading;C.useEffect(()=>{ke&&ke.status!=="running"&&ke.status!=="queued"&&k()},[ke?.status,k]),C.useEffect(()=>{L(!1)},[v.pathname]),C.useEffect(()=>{if(typeof window>"u"||!q&&!E)return;const re=Ze=>{Ze.key==="Escape"&&P()};return window.addEventListener("keydown",re),()=>{window.removeEventListener("keydown",re)}},[q,E,P]);const B=x??i?.dashboard??null,W=v.pathname==="/setup",ve=W&&B!==null&&B.portfolioOverview.projects.length===0,Ae=W&&(v.search.onboarding==="site-health"||v.search.onboarding==="first-run"||v.search.onboarding==="complete"),[se,Se]=C.useState(ve);C.useEffect(()=>{W?ve&&Se(!0):Se(!1)},[ve,W]);const xe=W&&(Ae||ve||se||W&&B===null),pe=xe?"app-shell-focus":$?"app-shell-sidebar-hidden":"",ce=q?(B?DY(B,q):void 0)??(ke?iu(ke,B?.projects.find(re=>re.project.id===ke.projectId)?.project.displayName??B?.projects.find(re=>re.project.id===ke.projectId)?.project.name??"Unknown project"):void 0):void 0,ue=C.useMemo(()=>_Y(v.pathname,B),[v.pathname,B]),{commandCenter:_e,evidenceLoading:Fe,evidenceError:Ee,isError:Ct,refetch:me}=sX(E?ue:null,{evidence:!0}),Be=C.useMemo(()=>{if(E)return IY(_e,B,E)},[E,_e,B]),Ne=(()=>{const re=v.pathname;if(re==="/")return"All projects";if(re==="/projects")return"Projects";if(re==="/runs")return"Runs";if(re==="/history")return"History";if(re==="/settings")return"Settings";if(re==="/setup")return"Setup";if(re==="/backlinks")return"Backlink data";if(re==="/traffic"||re.startsWith("/traffic/"))return"Traffic sources";if(re.startsWith("/projects/")){const Ze=B?.projects.find(bt=>bt.project.name===ue);return Ze?.project.displayName||Ze?.project.name||ue||"Projects"}return"Not found"})();if(r){const re=gN(r.projectTabs),Ze=!r.views||r.views.includes(fQ(v.pathname));return l.jsxs("div",{className:"app-shell app-shell-embed","data-theme":xQ(r.theme),style:wQ(r.theme),children:[l.jsx("a",{className:"skip-link",href:"#content",children:"Skip to content"}),l.jsx("main",{id:"content",className:"page-shell",children:re?l.jsx("div",{className:"embed-view-unavailable",role:"status",children:"This embed uses the retired Report tab. Update its allowed tabs to show AI Visibility."}):Ze?l.jsx(Xf,{}):l.jsx("div",{className:"embed-view-unavailable",role:"status",children:"This view is not available in embed mode."})})]})}return l.jsxs(l.Fragment,{children:[l.jsx("a",{className:"skip-link",href:"#content",children:"Skip to content"}),l.jsx(fX,{}),l.jsxs("div",{className:`app-shell ${pe}${jo()?" app-shell-demo":""}`,children:[!xe&&!$&&l.jsxs("aside",{id:"desktop-sidebar",className:"sidebar","aria-label":"Primary navigation",children:[l.jsx("div",{className:"sidebar-brand",children:l.jsx(zS,{version:z.apiStatus.version,updateAvailable:Ce?X:null,onDismissUpdate:tt})}),l.jsxs("nav",{className:"sidebar-nav",children:[l.jsxs(at,{to:"/",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(c6,{className:"sidebar-icon"}),l.jsx("span",{children:"All projects"})]}),l.jsxs(at,{to:"/projects",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!1},children:[l.jsx(u6,{className:"sidebar-icon"}),l.jsx("span",{children:"Projects"})]}),l.jsxs(at,{to:"/runs",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(d6,{className:"sidebar-icon"}),l.jsx("span",{children:"Runs"})]}),l.jsxs(at,{to:"/history",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(jk,{className:"sidebar-icon"}),l.jsx("span",{children:"History"})]}),l.jsxs(at,{to:"/traffic",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!1},children:[l.jsx(m6,{className:"sidebar-icon"}),l.jsx("span",{children:"Traffic sources"})]}),!jo()&&l.jsxs(at,{to:"/backlinks",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(p6,{className:"sidebar-icon"}),l.jsx("span",{children:"Backlink data"})]}),n&&l.jsxs(at,{to:"/settings",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(h6,{className:"sidebar-icon"}),l.jsx("span",{children:"Settings"})]}),S?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"sidebar-section-title",children:"Tracked projects"}),[1,2,3].map(re=>l.jsxs("div",{className:"sidebar-skeleton-item",children:[l.jsx("span",{className:"skeleton-circle size-2"}),l.jsx("span",{className:"skeleton-text flex-1",style:{width:`${50+re*15}%`}})]},re))]}):B&&B.projects.length>0?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"sidebar-section-title",children:"Tracked projects"}),B.projects.map(re=>{const Ze=re.visibilitySummary.tone;return l.jsxs(at,{to:"/projects/$projectName",params:{projectName:re.project.name},className:"sidebar-project",activeProps:{className:"sidebar-project sidebar-project-active"},children:[l.jsx("span",{className:`sidebar-dot sidebar-dot-${Ze}`}),l.jsx("span",{children:re.project.displayName||re.project.name})]},re.project.id)})]}):S?null:l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"sidebar-section-title",children:"Resources"}),n&&l.jsxs(at,{to:"/setup",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[l.jsx(f6,{className:"sidebar-icon"}),l.jsx("span",{children:"Setup"})]})]})]}),e&&l.jsxs("div",{className:"sidebar-account",children:[l.jsxs("div",{className:"sidebar-account-identity",children:[l.jsx("span",{className:"sidebar-account-name",children:e.name}),e.role==="viewer"?l.jsx("span",{className:"sidebar-account-role",children:dS()}):null]}),l.jsx(le,{type:"button",variant:"ghost",size:"sm",onClick:fn(async()=>{await fS(),window.location.reload()}),children:"Sign out"})]}),u?l.jsx("div",{className:"sidebar-footer",children:tk.map(({label:re,href:Ze,Icon:bt})=>l.jsx("a",{className:"sidebar-footer-icon",href:Ze,target:"_blank",rel:"noopener noreferrer",title:re,"aria-label":re,children:l.jsx(bt,{className:"size-4"})},Ze))}):null]}),l.jsxs("div",{className:"main-area",children:[l.jsxs("header",{className:"topbar",children:[l.jsxs("div",{className:"topbar-left",children:[!xe&&l.jsx(le,{className:"sidebar-privacy-toggle",variant:"ghost",size:"icon",type:"button","aria-label":$?"Show sidebar":"Hide sidebar","aria-controls":$?void 0:"desktop-sidebar","aria-expanded":!$,title:$?"Show sidebar":"Hide sidebar",onClick:Ke,children:$?l.jsx(b6,{className:"size-4"}):l.jsx(v6,{className:"size-4"})}),l.jsx("div",{className:"topbar-brand-mobile",children:l.jsx(zS,{compact:!0})}),l.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[l.jsx(at,{to:"/",children:"Home"}),l.jsx(Vc,{className:"breadcrumb-sep size-3"}),l.jsx("span",{className:"breadcrumb-current",children:Ne})]})]}),l.jsxs("div",{className:"topbar-actions",children:[l.jsx(gX,{}),l.jsxs("div",{className:"health-pill-row",children:[l.jsxs("span",{className:`health-pill health-pill-${z.apiStatus.state}`,title:Kr(z.apiStatus),children:["API ",z.apiStatus.state==="ok"?"ok":z.apiStatus.state]}),l.jsx("span",{className:`health-pill health-pill-${z.workerStatus.state}`,title:Kr(z.workerStatus),children:`Worker ${z.workerStatus.state==="ok"?"ok":z.workerStatus.state}`})]}),xe?null:l.jsxs(le,{className:"nav-toggle",variant:"secondary",size:"icon",type:"button","aria-expanded":M,"aria-controls":"mobile-nav",onClick:()=>L(re=>!re),children:[l.jsx(x6,{className:"size-4"}),l.jsx("span",{className:"sr-only",children:"Open navigation"})]})]})]}),xe?null:l.jsxs("div",{id:"mobile-nav",className:`mobile-nav ${M?"mobile-nav-open":""}`,children:[l.jsxs(le,{className:"mobile-nav-close",variant:"ghost",size:"icon",type:"button",onClick:()=>L(!1),children:[l.jsx(Gr,{className:"size-5"}),l.jsx("span",{className:"sr-only",children:"Close navigation"})]}),l.jsx(at,{to:"/",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"All projects"}),l.jsx(at,{to:"/projects",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!1},children:"Projects"}),l.jsx(at,{to:"/runs",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Runs"}),l.jsx(at,{to:"/history",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"History"}),l.jsx(at,{to:"/traffic",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!1},children:"Traffic sources"}),!jo()&&l.jsx(at,{to:"/backlinks",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Backlink data"}),n&&l.jsx(at,{to:"/settings",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Settings"}),B&&B.projects.length>0?l.jsxs("div",{className:"mobile-nav-section",children:[l.jsx("p",{className:"mobile-nav-section-title",children:"Tracked projects"}),B.projects.map(re=>l.jsx(at,{to:"/projects/$projectName",params:{projectName:re.project.name},className:"mobile-nav-link",children:re.project.name},re.project.id))]}):null,e&&l.jsxs("div",{className:"mobile-nav-section",children:[l.jsx("p",{className:"mobile-nav-section-title",children:"Signed in"}),l.jsxs("div",{className:"sidebar-account",children:[l.jsxs("div",{className:"sidebar-account-identity",children:[l.jsx("span",{className:"sidebar-account-name",children:e.name}),e.role==="viewer"?l.jsx("span",{className:"sidebar-account-role",children:dS()}):null]}),l.jsx(le,{type:"button",variant:"ghost",size:"sm","data-testid":"mobile-sign-out",onClick:fn(async()=>{await fS(),window.location.reload()}),children:"Sign out"})]})]})]}),l.jsx("main",{id:"content",className:`page-shell ${f&&ue?"pb-20":""}`.trim(),children:S&&!i?l.jsxs("div",{className:"page-skeleton",children:[l.jsxs("div",{className:"page-skeleton-header",children:[l.jsx("div",{className:"skeleton-text h-6 w-40"}),l.jsx("div",{className:"skeleton-text-sm w-72"})]}),l.jsx("div",{className:"page-skeleton-grid",children:[1,2,3].map(re=>l.jsxs("div",{className:"page-skeleton-card",children:[l.jsx("div",{className:"skeleton-text w-24"}),l.jsx("div",{className:"skeleton-text w-full"}),l.jsx("div",{className:"skeleton-text-sm w-3/4"})]},re))}),l.jsx("div",{className:"page-skeleton-grid",style:{gridTemplateColumns:"1fr 1fr"},children:[1,2].map(re=>l.jsxs("div",{className:"page-skeleton-card",children:[l.jsx("div",{className:"skeleton-text w-20"}),l.jsx("div",{className:"space-y-2",children:[1,2,3].map(Ze=>l.jsx("div",{className:"skeleton-text-sm w-full"},Ze))})]},re))})]}):l.jsx(Xf,{})}),l.jsxs("footer",{className:"footer",children:[l.jsxs("span",{className:"footer-brand",children:[l.jsx("span",{children:l.jsx("a",{href:"https://canonry.ai",children:"Canonry"})}),z.apiStatus.version&&z.apiStatus.version!=="unknown"?l.jsxs("span",{className:"footer-version",children:["v",z.apiStatus.version]}):null]}),u?l.jsx("div",{className:"footer-links",children:tk.map(({label:re,href:Ze,Icon:bt})=>l.jsx("a",{href:Ze,target:"_blank",rel:"noopener noreferrer",title:re,"aria-label":re,className:"footer-icon",children:l.jsx(bt,{className:"size-3.5"})},Ze))}):null]})]}),q&&!ce&&Le?l.jsx(Td,{open:!0,title:"Loading run details",subtitle:"Fetching the durable run record",onClose:P,children:l.jsx("p",{className:"text-sm text-muted",role:"status",children:"Loading run details…"})}):null,q&&!ce&&Ue.isError?l.jsx(Td,{open:!0,title:"Run unavailable",subtitle:"The run could not be loaded",onClose:P,children:l.jsx("p",{className:"text-sm text-negative",children:Ue.error instanceof Error?Ue.error.message:"Run details are unavailable."})}):null,ce?l.jsxs(Td,{open:!0,title:ce.summary,subtitle:`${ce.projectName} · ${ce.kindLabel}`,onClose:P,children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-1 text-sm",children:[l.jsx(z1,{status:ce.status}),l.jsx("span",{className:"text-secondary",children:ce.startedAt}),l.jsx("span",{className:"text-muted",children:ce.duration}),l.jsx("span",{className:"text-faint",children:ce.triggerLabel})]}),ce.status==="failed"&&ce.statusDetail&&l.jsx("p",{className:"mt-2 text-sm text-negative",children:ce.statusDetail}),l.jsxs("div",{className:"mt-4",children:[l.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted mb-2",children:"Activity Log"}),Le?l.jsx("p",{className:"text-sm text-muted",children:"Loading run details..."}):ke?.snapshots&&ke.snapshots.length>0?l.jsxs("div",{className:"space-y-2",children:[ke.snapshots.map(re=>l.jsxs("div",{className:"rounded-lg border border-default bg-surface p-3",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[l.jsx("p",{className:"text-sm font-medium text-strong truncate",children:re.query??"Unknown query"}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(fY,{provider:re.provider}),l.jsx(vC,{variant:re.citationState===Sc.cited?"success":"neutral",children:re.citationState})]})]}),re.model&&l.jsx("p",{className:"text-[11px] text-muted font-mono",children:re.model}),re.citedDomains.length>0&&l.jsxs("p",{className:"text-xs text-muted mt-1",children:[l.jsx("span",{className:"text-secondary",children:"Sources:"})," ",re.citedDomains.join(", ")]}),re.citedCompetitorDomains.length>0&&l.jsxs("p",{className:"text-xs text-negative-400/80 mt-0.5",children:["Competitor cited: ",re.citedCompetitorDomains.join(", ")]}),re.mentionedCompetitorDomains.length>0&&l.jsxs("p",{className:"text-xs text-negative-400/80 mt-0.5",children:["Competitor mentioned: ",re.mentionedCompetitorDomains.join(", ")]}),re.groundingSources&&re.groundingSources.length>0&&l.jsxs("details",{className:"mt-2",children:[l.jsxs("summary",{className:"text-xs text-muted cursor-pointer hover:text-secondary",children:[re.groundingSources.length," grounding source",re.groundingSources.length!==1?"s":""]}),l.jsx("ul",{className:"mt-2 space-y-3",children:re.groundingSources.map((Ze,bt)=>l.jsx("li",{className:"min-w-0",children:l.jsx(Ig,{url:Ze.uri,title:Ze.title})},bt))})]}),re.answerText&&l.jsxs("details",{className:"mt-1",children:[l.jsx("summary",{className:"text-xs text-muted cursor-pointer hover:text-secondary",children:"Answer preview"}),l.jsx("p",{className:"mt-1 text-xs text-secondary leading-relaxed whitespace-pre-wrap",children:re.answerText})]})]},re.id)),ke.status==="running"&&l.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-muted",children:[l.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-caution-500 animate-pulse"}),"Running remaining queries..."]})]}):ke&&ke.status===Nt.running?l.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-muted",children:[l.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-caution-500 animate-pulse"}),ke.kind===Oe["answer-visibility"]?"Waiting for first query result...":"Run is in progress..."]}):ke&&ke.status===Nt.queued?l.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-muted",children:[l.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-mono-500 animate-pulse"}),"Run queued, waiting for execution slot..."]}):ke&&ke.error?l.jsxs("div",{className:"rounded-lg border border-negative-800/40 bg-negative-950/20 p-3",children:[l.jsx("p",{className:"text-sm font-medium text-negative mb-2",children:"Run failed"}),l.jsx("pre",{className:"max-h-48 overflow-y-auto whitespace-pre-wrap break-words font-mono text-xs leading-5 text-negative",children:lQ(ke.error)})]}):ce.kind!==Oe["answer-visibility"]?l.jsx("p",{className:"text-sm text-secondary",children:ce.status===Nt.completed?"Run completed.":ce.status===Nt.partial?"Run completed with partial results.":ce.status===Nt.cancelled?"Run cancelled.":ce.status===Nt.failed?"Run failed.":"No run details available."}):l.jsx("p",{className:"text-sm text-muted",children:"No snapshot data available."})]})]}):null,E&&!Be?l.jsx(Td,{open:!0,title:Fe?"Loading answer":"Answer unavailable",subtitle:"Query evidence",onClose:P,children:Fe?l.jsx("p",{role:"status",className:"text-sm text-secondary",children:"Loading answer…"}):l.jsxs(l.Fragment,{children:[l.jsx("p",{role:"alert",className:"text-sm text-secondary",children:Ee||Ct?"Could not load this answer.":"This answer is not in the available query evidence."}),l.jsx(le,{type:"button",variant:"outline",onClick:()=>{me()},children:"Retry"})]})}):null,Be?l.jsx(AY,{evidence:Be.evidence,project:Be.project,onClose:P}):null,l.jsx(vJ,{}),l.jsx(dX,{}),f?l.jsx(mJ,{}):null]})]})}class wJ extends C.Component{state={error:null};static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,i){console.error("[ErrorBoundary]",n,i.componentStack),lm({kind:"render",error:n,component:this.props.name??"root"})}handleReset=()=>{this.setState({error:null})};render(){return this.state.error?l.jsx("div",{className:"page-container",children:l.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 py-20 text-center",children:[l.jsx("div",{className:"rounded-full bg-negative-950/40 p-3",children:l.jsx(ym,{className:"size-6 text-negative-400"})}),l.jsx("h2",{className:"text-lg font-semibold text-heading",children:"Something went wrong"}),l.jsx("p",{className:"text-sm text-secondary max-w-md",children:this.state.error.message||"An unexpected error occurred while rendering this page."}),l.jsxs("div",{className:"flex gap-3 mt-2",children:[l.jsxs(le,{variant:"secondary",size:"sm",onClick:this.handleReset,children:[l.jsx(w6,{className:"size-3.5 mr-1.5"}),"Try again"]}),l.jsx(le,{variant:"secondary",size:"sm",onClick:()=>{const n=window.__CANONRY_CONFIG__?.basePath?.replace(/\/$/,"")??"";window.location.href=n||"/"},children:"Go home"})]})]})}):this.props.children}}const _a=C.forwardRef(({className:e,...n},i)=>l.jsx("div",{ref:i,className:za("rounded-xl border border-base bg-bg/75 shadow-[0_0_0_1px_var(--color-shadow-hairline)]",e),...n}));_a.displayName="Card";const zr=C.forwardRef(({className:e,...n},i)=>l.jsx("div",{ref:i,className:za("flex flex-col gap-1.5 p-5",e),...n}));zr.displayName="CardHeader";const zC=C.forwardRef(({className:e,...n},i)=>l.jsx("h3",{ref:i,className:za("font-medium tracking-tight text-primary",e),...n}));zC.displayName="CardTitle";const fm=C.forwardRef(({className:e,...n},i)=>l.jsx("p",{ref:i,className:za("text-sm text-muted",e),...n}));fm.displayName="CardDescription";const vo=C.forwardRef(({className:e,...n},i)=>l.jsx("div",{ref:i,className:za("p-5 pt-0",e),...n}));vo.displayName="CardContent";function Lg({disabled:e,title:n,...i}){const{canWrite:r}=fa();return r?l.jsx(le,{disabled:e,title:n,...i}):l.jsx(le,{...i,disabled:!0,title:QN})}function M1({title:e,children:n}){const{isAdmin:i}=fa();return i?l.jsx(l.Fragment,{children:n}):l.jsxs(_a,{className:"surface-card mx-auto mt-8 max-w-lg",children:[l.jsxs(zr,{children:[l.jsxs(zC,{children:[e," is for administrators"]}),l.jsx(fm,{children:"Your account has view-only access. You can read everything this install has measured; changing how it is set up needs an administrator account."})]}),l.jsx(vo,{children:l.jsx("p",{className:"supporting-copy",children:"If you need to make a change here, ask an administrator on this install."})})]})}function zse(e,n,i){return{mode:n,scope:e.measurementScope,scopeKey:e.measurementScopeKey,marketKey:e.marketKey,queryClass:e.queryClass==="non-brand"?"non-brand":"branded",provider:e.provider,model:e.model,location:e.location,runId:e.measurementRunId,revision:e.revision,evaluationDefinitionId:i}}function Ise(e,n,i){const r=[...new Set(n.filter(u=>!i||u.provider===i).map(u=>u.sourceRunId).filter(u=>!!u))].sort();return{...e,mode:"simple",scope:"project",scopeKey:void 0,marketKey:void 0,provider:i||void 0,model:void 0,revision:void 0,runId:r.length===1?r[0]:void 0,runIds:r.length>1?r:void 0}}function Cc(e,n,i,r){return["sentiment",e,n,i??null,r??null]}const IC=5e3,SJ=new Set(["pending","running","waiting-to-retry"]);function ik(e){return SJ.has(e.state)}function kJ(e){const n=e?.coverage.counts;return!!(n&&n.pending+n.running+n["waiting-to-retry"]>0)}function jJ(e,n){return kJ(e)||n?IC:!1}function AJ(e,n,i=!0){const r=yt({queryKey:Cc(e,"settings"),queryFn:()=>Md(e),retry:!1,staleTime:0,refetchOnWindowFocus:"always"}),u=yt({queryKey:Cc(e,"jobs"),queryFn:()=>BH(e),enabled:!!r.data?.actions.configure,retry:!1,refetchOnWindowFocus:"always",refetchInterval:x=>x.state.data?.jobs.some(ik)?IC:!1}),h=!!u.data?.jobs.some(ik),f=x=>{const S={...n,queryClass:x};return{queryKey:Cc(e,"summary",S),queryFn:()=>IH(e,S),enabled:i&&!!(r.data?.enabled&&r.data.installEnabled),retry:!1,staleTime:0,refetchOnWindowFocus:"always",refetchInterval:k=>jJ(k.state.data,h)}},b=yt(f("branded")),v=yt(f("non-brand"));return{settings:r,branded:b,nonBrand:v,jobs:u}}const Bi={branded:"Branded","non-brand":"Non-brand"},B1=10;function L1(e){return e>=B1}const We={states:{disabled:"Sentiment is off.","not-measured":"No ratings yet.",processing:"Analyzing sentiment…",canceled:"Analysis canceled.",partial:"Partial results.",failed:"Analysis failed.",complete:"Analysis complete.",unsupported:"Sentiment unavailable."},noJudgments:"No ratings available.",tooFew:"too few",minRated:`Shown from ${B1} ratings`,partial:"Partial results",columns:{favorable:"Favorable",rated:"With opinion"},title:"Sentiment",subtitle:"How AI answers describe you in queries that name you",rated:"Share of answers that give an opinion (favorable, mixed or unfavorable) about who they name",noAnswers:"No answers yet",ratedUnavailable:"Unavailable",details:{ratedAnswers:"Answers with an opinion",unadmitted:"Checks not yet analyzed",checksCaption:"Not counted in the favorable share:",interval:"Likely range (95%)"},nonBrand:{label:"Non-brand queries",none:"No unfavorable or mixed answers in non-brand queries.",noneSoFar:"No unfavorable or mixed answers in non-brand queries so far.",notRated:"Non-brand answers are not rated yet.",view:"View answers",evidence:"Non-brand queries, unfavorable and mixed",rowNone:"No unfavorable or mixed answers",rowLabel:"Unfavorable or mixed",help:"A non-brand answer almost always names you to recommend you, so its favorable share is near 100% and says little. Sentiment is measured on branded queries; unfavorable or mixed answers to non-brand queries are listed here when they happen."},properties:{title:"Most criticized properties",evidence:"unfavorable and mixed",viewAll:"View all unfavorable and mixed answers",allEvidence:"Branded queries, unfavorable and mixed"},overall:"Favorable share of ratings in answers to branded queries. Each saved answer-subject assessment counts once. Answers with no opinion, or where it is unclear who they name, are left out.",favorable:"The favorable share of favorable, mixed and unfavorable ratings in answers to branded queries. Each rating covers one subject named in an answer; answers with no opinion are left out."},_c="—",NJ={factual:"Named, no opinion","subject-not-mentioned":"Not named in the answer","wrong-subject":"Named someone else","ambiguous-subject":"Unclear which one was meant","ambiguous-judgment":"Opinion unclear","subject-not-applicable":"Not applicable","unsupported-language":"Not in English","missing-source-text":"No answer text","input-too-large":"Answer too long to rate","invalid-conclusion-evidence":"Rating set aside",pending:"Waiting to be rated",running:"Being rated","waiting-to-retry":"Retrying"};function Hi(e){return NJ[e]??e.replaceAll("-"," ").replace(/^./,n=>n.toUpperCase())}const Eo=["favorable","mixed","unfavorable"];function OC(e){return e==="favorable"?"positive":e==="unfavorable"?"negative":e==="mixed"?"caution":"neutral"}const Mc=["mixed","unfavorable"];function PC(e){return e.interval?`${nm(e.interval.low,Ga.fraction)} to ${nm(e.interval.high,Ga.fraction)}`:null}const ep={favorable:"progress-fill-info",mixed:"progress-fill-caution",unfavorable:"progress-fill-negative"};function Ud(e){return`${e} ${e===1?"rating":"ratings"}`}function tp(e){return e.score.favorableRate!==null&&e.coverage.judged>0}function Ug(e){return e.state==="complete"&&!e.provisional&&e.coverage.unadmittedAssessments===0}function qC(e){return e.state==="complete"?We.partial:We.states[e.state]}function U1(e){return e?tp(e)&&L1(e.coverage.judged):!1}function CJ({value:e,label:n}){const{counts:i,judged:r}=e.coverage;if(!tp(e))return l.jsx("div",{className:"sentiment-bar sentiment-bar-track","data-sentiment-bar":"empty","aria-hidden":"true"});const u=Eo.map(h=>`${i[h]} ${h}`).join(", ");return U1(e)?l.jsx("div",{role:"img","aria-label":`${n}: ${u}, ${e.score.favorableDisplay} favorable of ${Ud(r)}`,className:"sentiment-bar","data-sentiment-bar":"rated",children:Eo.filter(h=>i[h]>0).map(h=>l.jsx("span",{"data-outcome":h,className:`sentiment-bar-segment ${ep[h]}`,style:{flexGrow:i[h]},title:`${Hi(h)}: ${i[h]} of ${Ud(r)}`},h))}):l.jsx("div",{role:"img","aria-label":`${n}: ${u}, ${Ud(r)}, favorable share ${We.minRated.toLowerCase()}`,className:"sentiment-bar sentiment-bar-track","data-sentiment-bar":"too-few"})}function _J({value:e,label:n}){const{counts:i,judged:r}=e.coverage;return l.jsx("div",{role:"img","aria-label":`${n}: ${Eo.map(u=>`${i[u]} ${u}`).join(", ")}, ${Ud(r)}`,className:"sentiment-property-bar",children:Eo.filter(u=>i[u]>0).map(u=>l.jsx("span",{"data-outcome":u,className:`sentiment-bar-segment ${ep[u]}`,style:{flexGrow:i[u]}},u))})}function TJ(e){const n=new Map(e.breakdowns.filter(i=>i.dimension==="property").map(i=>[i.key,i]));return(e.criticizedProperties?.keys??[]).flatMap(i=>n.get(i)??[])}function EJ({value:e,label:n}){return l.jsx("div",{role:"group","aria-label":`${n} favorable share`,className:"sentiment-class-favorable",children:U1(e)?l.jsx("span",{className:"sentiment-class-share",children:e.score.favorableDisplay}):l.jsxs(l.Fragment,{children:[l.jsx("span",{"aria-hidden":"true",className:"sentiment-class-empty",title:We.minRated,children:_c}),l.jsx("span",{className:"sr-only",children:We.minRated})]})})}function RJ({ratedAnswers:e=0,eligibleAnswers:n=0}){return`${e} of ${n} ${n===1?"answer":"answers"} rated`}function DJ(e){const{eligibleAnswers:n}=e;return n===void 0?{display:_c,detail:We.ratedUnavailable,empty:!0}:n<=0?{display:_c,detail:We.noAnswers,empty:!0}:e.ratedAnswerRate===null||e.ratedAnswerRate===void 0?{display:_c,detail:We.states.disabled,empty:!0}:{display:nm(e.ratedAnswerRate,Ga.fraction),detail:RJ(e),empty:!1}}function zJ({coverage:e,label:n}){const{display:i,detail:r,empty:u}=DJ(e);return l.jsxs("div",{role:"group","aria-label":`${n} share rated`,className:"sentiment-class-ratings",children:[l.jsx("span",{"aria-hidden":"true",className:u?"sentiment-class-empty":void 0,title:r,children:i}),l.jsx("span",{className:"sr-only",children:u?r:`${i}, ${r}`})]})}function IJ({value:e}){return tp(e)?e.provisional?l.jsx("p",{className:"sentiment-class-note text-caution",children:We.partial}):null:l.jsx("p",{className:"sentiment-class-note",children:e.state==="complete"?We.noJudgments:We.states[e.state]})}function OJ(e){return!!(e.coverage.selected||e.coverage.eligibleAssessments||e.reason)}function PJ({value:e,queryClass:n,open:i,setOpenClass:r}){const u=C.useContext(ui),h=C.useId(),f=C.useId(),b=C.useId(),v=C.useRef(null),x=C.useRef(null),S=C.useCallback(()=>r(E=>E===n?null:E),[r,n]);C.useEffect(()=>{if(!i)return;const E=$=>$ instanceof Node&&!!(v.current?.contains($)||x.current?.contains($)),P=$=>{E($.target)||S()},M=$=>{E($.target)||S()},L=$=>{$.key==="Escape"&&(S(),v.current?.focus())};return document.addEventListener("pointerdown",P),document.addEventListener("focusin",M),document.addEventListener("keydown",L),()=>{document.removeEventListener("pointerdown",P),document.removeEventListener("focusin",M),document.removeEventListener("keydown",L)}},[i,S]);const{coverage:k,score:N}=e,T=PC(N),z=k.judged>0&&!L1(k.judged),q=n==="branded"?TJ(e):[];return OJ(e)?l.jsxs(l.Fragment,{children:[l.jsx("button",{ref:v,type:"button",className:"sentiment-class-details-toggle","aria-label":`${Bi[n]} details`,"aria-expanded":i,"aria-controls":h,onClick:()=>r(E=>E===n?null:n),children:l.jsx(Lc,{className:"sentiment-class-details-chevron","aria-hidden":"true"})}),l.jsxs("div",{ref:x,id:h,role:"group","aria-labelledby":f,className:"sentiment-class-details",hidden:!i,children:[l.jsx("p",{id:f,className:"sentiment-class-details-title",children:Bi[n]}),l.jsxs("dl",{className:"sentiment-details-list",children:[(k.eligibleAnswers??0)>0&&l.jsxs("div",{children:[l.jsx("dt",{children:We.details.ratedAnswers}),l.jsxs("dd",{children:[k.ratedAnswers??0," of ",k.eligibleAnswers]})]}),z&&Eo.filter(E=>k.counts[E]>0).map(E=>l.jsxs("div",{children:[l.jsx("dt",{children:Hi(E)}),l.jsx("dd",{children:k.counts[E]})]},E)),z&&l.jsxs("div",{children:[l.jsx("dt",{children:"Favorable share"}),l.jsx("dd",{children:We.minRated})]}),T&&l.jsxs("div",{children:[l.jsxs("dt",{children:[We.details.interval," ",l.jsx(ua,{text:N.limitation,placement:"bottom"})]}),l.jsx("dd",{children:T})]})]}),u&&q.length>0&&l.jsxs("div",{className:"sentiment-details-properties",role:"group","aria-labelledby":b,children:[l.jsxs("p",{id:b,className:"sentiment-details-subtitle",children:[We.properties.title,e.criticizedProperties&&e.criticizedProperties.total>q.length?l.jsxs("span",{className:"sentiment-details-subtitle-count",children:[" · ",q.length," of ",e.criticizedProperties.total]}):null]}),l.jsx("ul",{children:q.map(E=>l.jsxs("li",{className:"sentiment-property",children:[l.jsx("button",{type:"button",className:"sentiment-property-name","aria-label":`View ${We.properties.evidence} answers for ${E.label}`,onClick:()=>{if(!v.current)return;const P=Vg(u,e);u.openEvidence({...P,queryClass:n,scope:"property",scopeKey:E.key,marketKey:P.scope==="market"?P.scopeKey:P.marketKey,outcome:Mc},`${E.label}, ${We.properties.evidence}`,v.current)},children:E.label}),l.jsxs("span",{className:"sentiment-property-count",children:[E.coverage.counts.favorable," of ",E.coverage.judged," favorable"]}),l.jsx(_J,{value:E,label:E.label})]},E.key))}),l.jsx("button",{type:"button",className:"sentiment-property-name sentiment-details-view-all",onClick:()=>{v.current&&u.openEvidence({...Vg(u,e),queryClass:n,outcome:Mc},We.properties.allEvidence,v.current)},children:We.properties.viewAll})]}),(k.unadmittedAssessments>0||Object.entries(k.counts).some(([E,P])=>P>0&&!Eo.includes(E)))&&l.jsx("p",{className:"sentiment-details-caption",children:We.details.checksCaption}),l.jsxs("dl",{className:"sentiment-details-list",children:[k.unadmittedAssessments>0&&l.jsxs("div",{children:[l.jsx("dt",{children:We.details.unadmitted}),l.jsx("dd",{children:k.unadmittedAssessments})]}),Object.entries(k.counts).filter(([E,P])=>P>0&&!["favorable","mixed","unfavorable"].includes(E)).map(([E,P])=>l.jsxs("div",{children:[l.jsx("dt",{children:Hi(E)}),l.jsx("dd",{children:P})]},E))]}),e.reason&&l.jsx("p",{className:"sentiment-class-details-reason",children:e.reason})]})]}):null}function V1(e){return!!(e?.configured&&e.branded.coverage.judged>0&&e.branded.score.favorableRate!==null)&&!Gm()}function qJ({value:e}){if(!V1(e))return null;const n=e.branded,i=n.coverage.judged,r=PC(n.score),u=`${We.overall} ${i} of ${n.coverage.selected} judged${r?`, 95% interval ${r}`:""}. ${n.provisional?"Provisional. ":""}${We.states[n.state]}${n.reason?` ${n.reason}`:""}`;return l.jsx("div",{className:"project-row-stat","data-sentiment-score":!0,children:l.jsxs("div",{className:"metric-inline-block",children:[l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("p",{className:"metric-inline-label",children:"Sentiment"}),l.jsx("span",{className:"relative z-10",children:l.jsx(ua,{text:u,placement:"bottom"})})]}),L1(i)?l.jsxs("p",{className:"metric-inline-value",children:[n.score.favorableDisplay,l.jsx("span",{className:"sr-only",children:" favorable judgments, branded queries"})]}):l.jsxs("p",{className:"metric-inline-value text-secondary",children:[We.tooFew,l.jsxs("span",{className:"sr-only",children:[" ratings for a favorable share, ",i," of ",B1," needed, branded queries"]})]}),l.jsx("p",{className:"metric-inline-caption","aria-hidden":"true"})]})})}const ui=C.createContext(null);function Vg(e,n){const{selection:i}=n;return{...e.selection,...i,runId:i.runId??void 0,runIds:i.runId?void 0:i.runIds,revision:i.revision??void 0,evaluationDefinitionId:i.evaluationDefinitionId??void 0}}function Ose(){return C.useContext(ui)?.configured??!1}function Pse({projectName:e,selection:n,runOptions:i=[],waitForResolvedRun:r=!1,evidenceReady:u=!0,hasSourceEvidence:h=!0,children:f}){return l.jsx(MJ,{projectName:e,selection:n,runOptions:i,waitForResolvedRun:r,evidenceReady:u,hasSourceEvidence:h,children:f})}function MJ({projectName:e,selection:n,runOptions:i,waitForResolvedRun:r,evidenceReady:u,hasSourceEvidence:h,children:f}){const b=JSON.stringify([e,n]),[v,x]=C.useState(null),S=C.useCallback(Ue=>x(ke=>ke?.key===b&&ke?.runId===Ue?.runId&&ke?.revision===Ue?.revision?ke:Ue?{...Ue,key:b}:null),[b]),k=u&&(!r||v?.key===b),N=r&&k&&v?{...n,runId:v.runId,revision:v.revision}:n,T=JSON.stringify([e,N]),{settings:z,branded:q,nonBrand:E,jobs:P}=AJ(e,N,k&&h),[M,L]=C.useState(!1),[$,F]=C.useState(null),ae=C.useRef(null);C.useEffect(()=>{L(!1),F(null)},[T]);const V=k&&!!(z.data?.enabled&&z.data.installEnabled),X=(n.queryClass==="non-brand"?E.data:q.data)?.selection,Ce={...N,...X?{...X,runId:X.runId??void 0,runIds:X.runId?void 0:X.runIds,revision:X.revision??void 0,evaluationDefinitionId:X.evaluationDefinitionId??void 0}:{}},tt=Ce.runId&&!i.some(Ue=>Ue.id===Ce.runId)?[{id:Ce.runId,label:"Displayed sweep"},...i]:i,Ke=Ue=>{Ue.preventDefault(),ae.current?.focus()};return l.jsxs(ui.Provider,{value:{projectName:e,selection:N,resolveSource:S,settings:z,summaries:{branded:q,"non-brand":E},configured:V,hasSourceEvidence:h,openManage:Ue=>{ae.current=Ue,L(!0)},openEvidence:(Ue,ke,Le)=>{ae.current=Le,F({selection:Ue,label:ke})}},children:[f,l.jsx(Dg,{open:M&&!!z.data?.actions.configure,onOpenChange:L,children:l.jsxs(mm,{onCloseAutoFocus:Ke,className:"overflow-y-auto",children:[l.jsxs(zg,{children:[l.jsx(pm,{children:"Manage sentiment"}),l.jsx(hm,{children:"Classify saved answers and review the cost before submitting a backfill."})]}),z.data?.actions.configure&&l.jsx(XJ,{projectName:e,settings:z.data,selection:Ce,runOptions:tt},JSON.stringify([z.data.evaluationDefinitionId,z.data.enabled,z.data.enablementEpoch])),P.data&&l.jsx(HJ,{projectName:e,jobs:P.data.jobs})]})}),l.jsx(Dg,{open:$!==null,onOpenChange:Ue=>{Ue||F(null)},children:l.jsxs(mm,{onCloseAutoFocus:Ke,className:"overflow-y-auto",children:[l.jsxs(zg,{children:[l.jsxs(pm,{children:["Sentiment evidence",$?`: ${$.label}`:""]}),l.jsx(hm,{children:"Stored judgments and exact quotations for the selected query and scope."})]}),$&&l.jsx($J,{projectName:e,selection:$.selection},JSON.stringify($.selection))]})})]})}function qse(e,n){const i=C.useContext(ui)?.resolveSource;C.useEffect(()=>{i?.(e?{runId:e,revision:void 0}:null)},[i,e,n])}function sk(){const e=C.useContext(ui);return e?.settings.data?.actions.configure?l.jsx(Lg,{type:"button",variant:"outline",size:"sm",onClick:n=>e.openManage(n.currentTarget),children:e.settings.data.enabled?"Manage sentiment":"Enable sentiment"}):null}function MC(e,n){return!e?.configured||n==="unknown"||n==="unclassified"?null:["branded"]}function BJ({queryClass:e="all"}){const n=C.useContext(ui),i=MC(n,e);return!n?.hasSourceEvidence||!i?.some(r=>U1(n.summaries[r].data))?null:l.jsx("ul",{className:"sentiment-legend","aria-hidden":"true",children:Eo.map(r=>l.jsxs("li",{children:[l.jsx("span",{className:`sentiment-legend-swatch ${ep[r]}`}),Hi(r)]},r))})}function LJ({queryClass:e}){const n=C.useContext(ui);if(!n?.hasSourceEvidence)return null;const i=n.summaries["non-brand"],r=i.data,u=e==="non-brand";if(!r)return u?i.isError?l.jsxs("p",{role:"alert",className:"sentiment-nonbrand-note",children:["Couldn’t load non-brand sentiment. ",l.jsx(le,{variant:"ghost",onClick:()=>{i.refetch()},children:"Retry"})]}):l.jsx("p",{role:"status",className:"sentiment-nonbrand-note",children:"Loading non-brand sentiment…"}):null;const h=r.coverage.counts;return h.unfavorable===0&&h.mixed===0?u?Ug(r)?l.jsx("p",{className:"sentiment-nonbrand-note",children:We.nonBrand.none}):tp(r)?l.jsx("p",{className:"sentiment-nonbrand-note",children:We.nonBrand.noneSoFar}):l.jsx("p",{className:"sentiment-nonbrand-note",children:r.state==="not-measured"?We.nonBrand.notRated:`${We.nonBrand.label}: ${qC(r)}`}):null:l.jsx("div",{className:"sentiment-nonbrand",role:"group","aria-label":We.nonBrand.label,children:l.jsxs("div",{className:"sentiment-nonbrand-line",children:[l.jsxs("span",{className:"sentiment-nonbrand-label",children:[We.nonBrand.label,l.jsx(ua,{text:We.nonBrand.help})]}),l.jsxs("span",{className:"sentiment-nonbrand-counts",children:[Mc.slice().reverse().filter(f=>h[f]>0).map(f=>l.jsxs("span",{children:[l.jsx("span",{"aria-hidden":"true",className:`sentiment-legend-swatch ${ep[f]}`}),h[f]," ",f]},f)),!Ug(r)&&l.jsx("span",{className:"text-caution",children:We.partial})]}),l.jsx(le,{type:"button",variant:"outline",size:"sm",onClick:f=>n.openEvidence({...Vg(n,r),queryClass:"non-brand",outcome:Mc},We.nonBrand.evidence,f.currentTarget),children:We.nonBrand.view})]})})}function Mse({queryClass:e="all",legend:n=!0,manage:i=!1}){const r=C.useContext(ui),u=MC(r,e),[h,f]=C.useState(null);if(!r)return null;if(!u){const v=r.settings.data;return!i||!v?.actions.configure?null:l.jsxs("div",{className:"sentiment-headlines-title",children:[l.jsxs("div",{children:[l.jsx("h3",{className:"sentiment-headlines-heading",children:We.title}),!(v.enabled&&v.installEnabled)&&l.jsx("p",{className:"sentiment-headlines-subtitle",children:We.states.disabled})]}),l.jsx(sk,{})]})}const b=r.hasSourceEvidence&&u.some(v=>r.summaries[v].data);return l.jsxs("div",{className:"sentiment-headlines",role:"group","aria-label":"Favorable answer scores",children:[l.jsxs("div",{className:"sentiment-headlines-title",children:[l.jsxs("div",{children:[l.jsx("h3",{className:"sentiment-headlines-heading",children:We.title}),l.jsx("p",{className:"sentiment-headlines-subtitle",children:We.subtitle})]}),i&&l.jsx(sk,{})]}),n&&l.jsx(BJ,{queryClass:e}),b&&l.jsxs("div",{className:"sentiment-headlines-columns","aria-hidden":"true",children:[l.jsx("span",{className:"sentiment-headlines-favorable",children:We.columns.favorable}),l.jsx("span",{className:"sentiment-headlines-ratings",title:We.rated,children:We.columns.rated})]}),u.map(v=>{const x=r.summaries[v];return l.jsxs("div",{className:"sentiment-class","data-query-class":v,children:[l.jsxs("div",{className:"sentiment-class-label",children:[l.jsx("span",{children:Bi[v]}),l.jsx(ua,{text:We.favorable})]}),r.hasSourceEvidence?x.data?l.jsxs(l.Fragment,{children:[l.jsx(CJ,{value:x.data,label:Bi[v]}),l.jsx(EJ,{value:x.data,label:Bi[v]}),l.jsx(zJ,{coverage:x.data.coverage,label:Bi[v]}),l.jsx(IJ,{value:x.data}),l.jsx(PJ,{value:x.data,queryClass:v,open:h===v,setOpenClass:f})]}):x.isError?l.jsxs("p",{role:"alert",className:"sentiment-class-status",children:["Couldn’t load sentiment. ",l.jsx(le,{variant:"ghost",onClick:()=>{x.refetch()},children:"Retry"})]}):l.jsx("p",{role:"status",className:"sentiment-class-status",children:"Loading sentiment…"}):l.jsx("p",{className:"sentiment-class-status",children:"No saved answers."})]},v)}),e!=="branded"&&l.jsx(LJ,{queryClass:e})]})}function Bse({queryId:e,sourceSnapshotIds:n=[],queryClass:i,location:r,showLabel:u=!1}){const h=C.useContext(ui);if(!h?.configured)return null;const f=i?h.summaries[i]:void 0,b=h.hasSourceEvidence?f?.data:void 0,v=b?.queries.filter(N=>N.queryClass===i&&(e?N.queryId===e:n.length>0)&&n.every(T=>N.sourceSnapshotIds.includes(T)))??[],x=v.length===1?v[0]:void 0,S=r===void 0?x:x?.locations.find(N=>N.location===r);if(!x||!S)return l.jsx("span",{className:"text-sm text-secondary",children:h.hasSourceEvidence&&f?.isPending&&(e||n.length)?"Loading…":"Unavailable"});const k={...h.selection,...b.selection,runId:b.selection.runId??void 0,runIds:b.selection.runId?void 0:b.selection.runIds,revision:b.selection.revision??void 0,evaluationDefinitionId:b.selection.evaluationDefinitionId??void 0,queryClass:x.queryClass,queryId:x.queryId,executionNodeKey:x.executionNodeKey??void 0,...r===void 0?{}:{location:r??"none"}};if(x.queryClass==="non-brand"){if(S.state==="unsupported")return l.jsx("span",{className:"text-sm text-secondary",children:"Unavailable"});const{unfavorable:N,mixed:T}=S.coverage.counts;if(N===0&&T===0){const z=u&&l.jsx("span",{className:"block text-sm font-normal text-secondary",children:We.nonBrand.rowLabel});return Ug(S)?l.jsxs("span",{className:"text-sm text-muted",children:[z,l.jsx("span",{"aria-hidden":"true",title:We.nonBrand.rowNone,children:_c}),l.jsx("span",{className:"sr-only",children:We.nonBrand.rowNone})]}):l.jsxs("span",{className:"text-sm text-secondary",children:[z,l.jsx("span",{children:qC(S)})]})}return l.jsxs(le,{type:"button",variant:"ghost",className:"h-auto min-h-11 flex-col items-start gap-0 px-1","aria-label":`View unfavorable and mixed answers for ${x.queryText}`,onKeyDown:z=>z.stopPropagation(),onClick:z=>{z.stopPropagation(),h.openEvidence({...k,outcome:Mc},`${x.queryText}, unfavorable and mixed`,z.currentTarget)},children:[u&&l.jsx("span",{className:"text-sm font-normal text-secondary",children:We.nonBrand.rowLabel}),N>0&&l.jsxs("span",{className:"text-sm text-negative",children:[N," unfavorable"]}),T>0&&l.jsxs("span",{className:"text-sm text-caution",children:[T," mixed"]}),S.provisional&&l.jsx("span",{className:"text-xs font-normal text-caution",children:"Provisional"})]})}return l.jsxs(le,{type:"button",variant:"ghost",className:"h-auto min-h-11 flex-col items-start gap-0 px-1","aria-label":`View ${Bi[x.queryClass]} sentiment evidence for ${x.queryText}`,onKeyDown:N=>N.stopPropagation(),onClick:N=>{N.stopPropagation(),h.openEvidence(k,x.queryText,N.currentTarget)},children:[u&&l.jsx("span",{className:"text-sm font-normal text-secondary",children:"Favorable"}),l.jsx("span",{className:"font-mono text-primary",children:S.score.favorableDisplay}),l.jsxs("span",{className:"text-sm font-normal text-secondary",children:[S.coverage.judged," judged"]}),S.provisional&&l.jsx("span",{className:"text-xs font-normal text-caution",children:"Provisional"})]})}function UJ(e){return e.outcome==="subject-not-mentioned"?"Not mentioned":e.outcome==="running"?"Classifying":e.outcome==="waiting-to-retry"?"Retrying":e.outcome?Hi(e.outcome):e.state==="not-measured"?"Not classified":e.state==="processing"?"Classifying":e.state==="failed"?"Failed":e.state==="canceled"?"Canceled":"Unavailable"}function Lse({queryId:e,sourceSnapshotIds:n,queryClass:i,provider:r,model:u,location:h,showSubjects:f=!1,showLabel:b=!1}){const v=C.useContext(ui);if(!v?.configured)return null;const x=i?v.summaries[i]:void 0,S=v.hasSourceEvidence?x?.data:void 0,k=S?.queries.filter(z=>z.queryClass===i&&(!e||z.queryId===e)&&n.length>0&&n.every(q=>z.sourceSnapshotIds.includes(q)))??[],N=k.length===1?k[0]:void 0,T=N?.assessments?.filter(z=>n.includes(z.sourceSnapshotId)&&z.provider===r&&z.location===h&&(u===void 0||z.servedModel===u))??[];return l.jsxs("div",{role:"group",className:"text-sm text-secondary","aria-label":`${r||"Saved answer"} sentiment`,children:[b&&l.jsx("span",{className:"block text-sm text-secondary",children:"Sentiment"}),T.length?T.map(z=>{const q=UJ(z),E=OC(z.outcome),P=l.jsxs(l.Fragment,{children:[f&&l.jsxs("span",{children:[z.subjectLabel," · "]}),l.jsx(wn,{tone:E,className:"max-w-full shrink-0 rounded-none border-0 bg-transparent p-0 text-sm font-normal tracking-normal [overflow-wrap:normal]",children:q})]}),M={...v.selection,...S.selection,runId:S.selection.runId??void 0,runIds:S.selection.runId?void 0:S.selection.runIds,revision:S.selection.revision??void 0,evaluationDefinitionId:S.selection.evaluationDefinitionId??void 0,queryClass:N.queryClass,queryId:N.queryId,executionNodeKey:N.executionNodeKey??void 0,assessmentId:z.assessmentId??void 0};return l.jsxs("div",{className:"flex items-center gap-1",children:[z.assessmentId?l.jsx(le,{type:"button",variant:"ghost",className:"h-auto min-h-11 flex-wrap justify-start whitespace-normal px-1 text-left text-sm","aria-label":`View ${z.provider} sentiment evidence for ${z.subjectLabel}: ${q}`,onKeyDown:L=>L.stopPropagation(),onClick:L=>{L.stopPropagation(),v.openEvidence(M,`${N.queryText} · ${z.provider} · ${z.subjectLabel}`,L.currentTarget)},children:P}):l.jsx("span",{children:P}),z.reason&&l.jsx(ua,{text:z.reason})]},JSON.stringify([z.sourceSnapshotId,z.subjectId,z.assessmentId]))}):l.jsx("span",{children:v.hasSourceEvidence&&x?.isPending&&n.length?"Loading…":"Unavailable"})]})}function VJ({item:e}){return l.jsxs("article",{className:"space-y-4 border-b border-default py-5 text-sm text-secondary",children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l.jsx("strong",{className:"text-primary",children:e.subject.displayName}),l.jsx(wn,{tone:OC(e.outcome),children:Hi(e.outcome)}),l.jsx("span",{children:Bi[e.context.queryClass]}),l.jsx("span",{children:e.context.provider}),l.jsx("span",{children:e.context.servedModel??"Source model unavailable"}),l.jsx("span",{children:e.context.location??"No location"})]}),e.reason&&l.jsx("p",{children:e.reason}),l.jsxs("section",{children:[l.jsx("h3",{className:"mb-2 text-heading",children:"Conclusion evidence"}),e.conclusion.length?e.conclusion.map(n=>l.jsx("blockquote",{className:"mb-2 border-l border-strong pl-3 text-primary",children:n.text},`${n.id}:${n.start}`)):l.jsx("p",{children:"No valid conclusion evidence is available."})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"mb-2 text-heading",children:"Complaint evidence"}),e.complaint?.length?e.complaint.map(n=>l.jsx("blockquote",{className:"mb-2 border-l border-strong pl-3 text-primary",children:n.text},`${n.id}:${n.start}`)):l.jsx("p",{children:"No complaint was identified."})]}),l.jsxs("details",{children:[l.jsx("summary",{className:"cursor-pointer",children:"Original source answer"}),l.jsx("p",{className:"mt-2 whitespace-pre-wrap break-words text-primary",children:e.sourceText})]}),l.jsxs("details",{children:[l.jsx("summary",{className:"cursor-pointer",children:"Assessment provenance"}),l.jsxs("dl",{className:"mt-3 space-y-2 break-all",children:[l.jsx("dt",{children:"Query"}),l.jsx("dd",{children:e.context.queryText}),l.jsx("dt",{children:"Subject"}),l.jsxs("dd",{children:[e.subject.displayName," (",e.subject.id,")"]}),l.jsx("dt",{children:"Run"}),l.jsx("dd",{children:e.runId}),l.jsx("dt",{children:"Revision"}),l.jsx("dd",{children:e.context.revision??"Unavailable"}),l.jsx("dt",{children:"Evaluator"}),l.jsx("dd",{children:e.returnedModel??"Unavailable"}),l.jsx("dt",{children:"Evaluation definition"}),l.jsx("dd",{children:e.evaluationDefinitionId}),l.jsx("dt",{children:"Source snapshot"}),l.jsx("dd",{children:e.sourceSnapshotId}),l.jsx("dt",{children:"Source hash"}),l.jsx("dd",{children:e.sourceTextHash}),e.context.usageEdges.map((n,i)=>l.jsxs("div",{children:[l.jsx("dt",{children:"Assignment"}),l.jsxs("dd",{children:["Target ",n.targetId,"; Property ",n.propertyId??"None","; market ",n.marketId??"None","; ",n.queryClass]})]},i))]})]})]})}function $J({projectName:e,selection:n}){const[i,r]=C.useState(),u=yt({queryKey:Cc(e,"evidence",n,i),queryFn:()=>PH(e,n,i),retry:!1});return u.isPending?l.jsx("p",{role:"status",className:"mt-4 text-sm text-secondary",children:"Loading sentiment evidence…"}):u.isError?l.jsxs("p",{role:"alert",className:"mt-4 text-sm text-secondary",children:["Could not load sentiment evidence. ",l.jsx(le,{variant:"outline",onClick:()=>{u.refetch()},children:"Retry evidence"})]}):l.jsxs(l.Fragment,{children:[u.data.items.length?u.data.items.map(h=>l.jsx(VJ,{item:h},h.assessmentId)):l.jsx("p",{className:"mt-4 text-sm text-secondary",children:"No stored sentiment evidence for this query and scope."}),l.jsxs("div",{className:"mt-3 flex gap-2",children:[i&&l.jsx(le,{variant:"outline",onClick:()=>r(void 0),children:"First evidence page"}),u.data.nextCursor&&l.jsx(le,{variant:"outline",onClick:()=>r(u.data.nextCursor??void 0),children:"Next evidence page"})]})]})}function KJ({projectName:e,jobId:n}){const[i,r]=C.useState(),u=yt({queryKey:Cc(e,`job:${n}`,void 0,i),queryFn:()=>LH(e,n,i),retry:!1});return u.isPending?l.jsx("p",{role:"status",children:"Loading attempts…"}):u.isError?l.jsxs("p",{role:"alert",children:["Could not load attempts. ",l.jsx(le,{variant:"outline",onClick:()=>{u.refetch()},children:"Retry attempts"})]}):l.jsxs(l.Fragment,{children:[u.data.attempts.map(h=>l.jsxs("p",{children:[h.errorCode??"Request complete","; ",h.usage.kind==="unknown"?"Usage unknown":`${h.usage.inputTokens??"Unknown"} input tokens (${h.usage.kind})`]},h.id)),l.jsxs("div",{className:"mt-2 flex gap-2",children:[i&&l.jsx(le,{variant:"outline",onClick:()=>r(void 0),children:"Newest attempts"}),u.data.nextAttemptCursor&&l.jsx(le,{variant:"outline",onClick:()=>r(u.data.nextAttemptCursor??void 0),children:"Older attempts"})]})]})}function GJ({projectName:e,job:n}){const[i,r]=C.useState(!1);return l.jsxs("details",{onToggle:u=>r(u.currentTarget.open),children:[l.jsx("summary",{children:"Job details"}),n.cancellationReason&&l.jsx("p",{children:n.cancellationReason}),Object.entries(n.counts).filter(([,u])=>u>0).map(([u,h])=>l.jsxs("p",{children:[Hi(u),": ",h]},u)),l.jsxs("p",{children:["Attempts: ",n.attemptCount]}),i&&n.attemptCount>0&&l.jsx(KJ,{projectName:e,jobId:n.id})]})}function HJ({projectName:e,jobs:n}){return l.jsxs("details",{className:"mt-6 text-sm text-secondary",children:[l.jsx("summary",{className:"cursor-pointer",children:"Recent sentiment jobs"}),n.length===0?l.jsx("p",{className:"mt-2",children:"No sentiment jobs have been submitted."}):l.jsx("div",{className:"data-table-wrapper mt-3",children:l.jsxs("table",{className:"data-table","aria-label":"Sentiment jobs",children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{children:"Submitted"}),l.jsx("th",{children:"State"}),l.jsx("th",{children:"Selected"}),l.jsx("th",{children:"Details"})]})}),l.jsx("tbody",{children:n.map(i=>l.jsxs("tr",{children:[l.jsx("td",{children:pQ(i.createdAt)}),l.jsx("td",{children:Hi(i.state)}),l.jsx("td",{children:i.selected}),l.jsx("td",{children:l.jsx(GJ,{projectName:e,job:i})})]},i.id))})]})})]})}const QJ={probe:"Probe sweeps","unsupported-run-kind":"Not an answer sweep","failed-run":"Failed sweep","incomplete-run":"Incomplete sweep","legacy-missing-provenance":"Saved without its frozen query and subject record","legacy-missing-language":"Saved before the answer language was recorded","excluded-branded":"Branded answers (backfill that class separately)","excluded-non-brand":"Non-brand answers (backfill that class separately)"};function FJ(e){return QJ[e]??Hi(e)}function BC(e){return[e.provider&&`engine ${e.provider}`,e.model&&`model ${e.model}`,e.location&&(e.location==="none"?"no location":`location ${e.location}`),e.scope!=="project"&&e.scopeKey&&`${e.scope} ${e.scopeKey}`,e.marketKey&&`market ${e.marketKey}`,e.queryId&&`query ${e.queryId}`,e.revision!==void 0&&`revision ${e.revision}`].filter(n=>!!n)}function ZJ(e){const n=BC(e);return[`${Bi[e.queryClass]} queries`,...n.length?n:["whole sweep"]].join(" · ")}function YJ(e,n,i,r){return r?{...e,queryClass:i,queryId:void 0,runIds:void 0,runId:n}:{mode:"auto",scope:"project",queryClass:i,runId:n}}function XJ({projectName:e,settings:n,selection:i,runOptions:r}){const u=Ds(),[h,f]=C.useState(n.enabled),[b,v]=C.useState(i.runId??""),[x,S]=C.useState(i.queryClass),[k,N]=C.useState(!1),[T,z]=C.useState(null),q=C.useRef(null),E=BC({...i,queryId:void 0}),P=()=>u.invalidateQueries({queryKey:["sentiment",e]}),M=()=>{z(null),q.current=null},L=oi({mutationFn:async()=>{if(!(await Md(e)).actions.configure)throw new Error("Administrator permission is required to configure sentiment.");return OH(e,{enabled:h})},onSuccess:async()=>{M(),await P(),await u.invalidateQueries({queryKey:["project-overview-slim"]})},onError:P}),$=oi({mutationFn:async()=>{if(!(await Md(e)).actions.backfill)throw new Error("Administrator permission is required to backfill sentiment.");return qH(e,YJ(i,b,x,k&&E.length>0))},onSuccess:V=>{z(V),q.current=crypto.randomUUID()},onError:P}),F=oi({mutationFn:async()=>{if(!T?.previewToken||!q.current)throw new Error("Create and review a backfill preview first.");if(!(await Md(e)).actions.backfill)throw new Error("Administrator permission is required to backfill sentiment.");return MH(e,T.previewToken,q.current)},onSuccess:async()=>{M(),await P()},onError:P}),ae=L.isPending||$.isPending||F.isPending;return l.jsxs("div",{className:"mt-5 space-y-5 text-sm text-secondary",children:[l.jsx("p",{children:n.disclosure}),!n.ready&&l.jsx("p",{children:n.readinessReasons.join("; ")||"An operator must configure sentiment on this installation."}),l.jsxs("form",{className:"space-y-3",onSubmit:V=>{V.preventDefault(),L.mutate()},children:[l.jsxs("label",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",checked:h,disabled:ae,onChange:V=>{f(V.target.checked),M()}}),"Enable project sentiment"]}),l.jsx("p",{children:"Enabling applies to future completed sweeps. Past sweeps require an explicit backfill."}),l.jsx(Lg,{type:"submit",disabled:ae,children:L.isPending?"Saving…":"Save sentiment settings"}),L.isError&&l.jsx("p",{role:"alert",children:qi(L.error)}),L.isSuccess&&l.jsx("p",{role:"status",children:"Sentiment settings saved."})]}),n.actions.backfill&&l.jsxs("section",{className:"space-y-3",children:[l.jsx("h3",{children:"Backfill a saved sweep"}),l.jsxs("label",{className:"block",children:["Saved sweep",l.jsxs("select",{className:"mt-1 block w-full rounded-md border border-default bg-bg p-2 text-primary",value:b,disabled:ae,onChange:V=>{v(V.target.value),M()},children:[l.jsx("option",{value:"",children:"Select a saved sweep"}),r.map(V=>l.jsx("option",{value:V.id,children:V.label},V.id))]})]}),l.jsxs("label",{className:"block",children:["Query class",l.jsxs("select",{className:"mt-1 block w-full rounded-md border border-default bg-bg p-2 text-primary",value:x,disabled:ae,onChange:V=>{S(V.target.value),M()},children:[l.jsx("option",{value:"non-brand",children:"Non-brand"}),l.jsx("option",{value:"branded",children:"Branded"})]})]}),l.jsx("p",{children:"The backfill covers every engine, location and query of the chosen sweep for this query class."}),E.length>0&&l.jsxs("label",{className:"flex items-start gap-2",children:[l.jsx("input",{type:"checkbox",className:"mt-1",checked:k,disabled:ae,onChange:V=>{N(V.target.checked),M()}}),l.jsxs("span",{children:["Limit to the current view",l.jsx("span",{className:"block",children:E.join(" · ")})]})]}),l.jsx(le,{variant:"outline",disabled:ae||!b||!n.enabled||!n.ready,onClick:()=>{M(),$.mutate()},children:$.isPending?"Preparing preview…":"Preview sentiment backfill"}),$.isError&&l.jsx("p",{role:"alert",children:qi($.error)}),T&&l.jsxs("div",{className:"space-y-3",children:[l.jsxs("dl",{className:"grid grid-cols-[1fr_auto] gap-2",children:[l.jsx("dt",{children:"Selection"}),l.jsx("dd",{className:"text-right",children:ZJ(T.selection)}),l.jsx("dt",{children:"Eligible assessments"}),l.jsx("dd",{children:T.eligibleAssessments}),l.jsx("dt",{children:"Already classified"}),l.jsx("dd",{children:T.alreadyClassified}),l.jsx("dt",{children:"Estimated input tokens"}),l.jsx("dd",{children:T.estimatedInputTokens}),l.jsx("dt",{children:"Estimated cost (USD)"}),l.jsx("dd",{children:T.estimatedCostUsd??"Unavailable"})]}),l.jsx(ua,{text:T.estimateMethod}),T.eligibleAssessments===0&&l.jsx("p",{children:"No saved answers in this selection can be classified."}),T.skipped.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:"Not included:"}),l.jsx("ul",{"aria-label":"Skipped assessments",className:"list-disc pl-5",children:T.skipped.map(V=>l.jsxs("li",{children:[FJ(V.reason),": ",V.count]},`${V.runId}:${V.reason}`))})]}),l.jsx(Lg,{disabled:ae||!T.previewToken||T.eligibleAssessments===0,onClick:()=>F.mutate(),children:F.isPending?"Submitting…":"Confirm sentiment backfill"})]}),F.isError&&l.jsxs("p",{role:"alert",children:[qi(F.error)," Retry uses the same request key."]}),F.isSuccess&&l.jsx("p",{role:"status",children:"Backfill submitted. Progress is available in Recent jobs."})]})]})}const JJ=20,WJ=6;function eW({points:e,tone:n}){const i=C.useId();if(e.length===0)return null;const r=42,u=132,h=5,f=u-h*2,b=r-h*2,v=b-WJ,x=E=>h+E/Math.max(e.length-1,1)*f,S=nG(e),k=Math.min(...e),N=Math.max(...e),T=Math.max(N-k,JJ),z=(N+k)/2-T/2,q=e.map((E,P)=>({x:x(P),y:h+(1-(E-z)/T)*v}));return l.jsxs("svg",{className:`sparkline sparkline-${n}${S?" sparkline-provisional":""}`,viewBox:`0 0 ${u} ${r}`,"aria-hidden":"true",children:[l.jsx("defs",{children:l.jsx("clipPath",{id:i,children:l.jsx("rect",{x:h,y:h,width:f,height:b,rx:"8"})})}),l.jsx("line",{className:"sparkline-guide",x1:h,x2:u-h,y1:r-h,y2:r-h}),q.length===1?l.jsx("circle",{className:"sparkline-point",cx:q[0].x,cy:q[0].y,r:"3"}):l.jsx("polyline",{clipPath:`url(#${i})`,points:q.map(E=>`${E.x},${E.y}`).join(" "),vectorEffect:"non-scaling-stroke"})]})}function tW({project:e,sentimentColumn:n}){return l.jsxs("div",{className:`project-row relative${n?" project-row-with-sentiment":""}`,children:[l.jsx("div",{className:"project-row-chart",children:l.jsx(eW,{points:e.trend,tone:eC(e.lastRun.status)})}),l.jsxs("div",{className:"project-row-primary",children:[l.jsxs(at,{to:"/projects/$projectName",params:{projectName:e.project.name},className:"after:absolute after:inset-0 after:rounded-xl focus-visible:outline-none focus-visible:after:ring-2 focus-visible:after:ring-mono-400",children:[l.jsx("p",{className:"project-name",children:e.project.name}),l.jsx("p",{className:"project-domain",children:e.project.canonicalDomain})]}),l.jsx("p",{className:"project-insight",children:e.insight})]}),l.jsx("div",{className:"project-row-stat",children:l.jsxs("div",{className:"metric-inline-block",children:[l.jsx("p",{className:"metric-inline-label",children:"Mentioned"}),l.jsx("p",{className:`metric-inline-value ${e.mentionTone==="caution"?"text-caution-400":""}`,children:e.hasMeasurement===!1?"Not measured":nm(e.mentionScore,Ga.percent)}),l.jsx("p",{className:`metric-inline-caption${e.providerCoverage?" text-caution":""}`,title:e.providerCoverage,children:e.providerCoverage?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"sr-only",children:"Partial sweep: "}),e.providerCoverage]}):e.mentionDelta})]})}),l.jsx("div",{className:"project-row-stat",children:l.jsxs("div",{className:"metric-inline-block",children:[l.jsxs("p",{className:"metric-inline-label",children:[l.jsx("span",{"aria-hidden":"true",children:"Pressure"}),l.jsx("span",{className:"sr-only",children:"Competitor pressure"})]}),l.jsx("p",{className:"metric-inline-value",children:e.hasMeasurement===!1?"Not measured":e.competitorPressureLabel}),l.jsx("p",{className:"metric-inline-caption","aria-hidden":"true"})]})}),V1(e.sentiment)?l.jsx(qJ,{value:e.sentiment}):n&&l.jsx("div",{className:"project-row-stat","aria-hidden":"true","data-sentiment-placeholder":!0}),l.jsx("span",{className:"project-row-link",children:l.jsx(Vc,{className:"h-4 w-4 text-muted"})})]})}function nW(){const{isAdmin:e}=fa(),n=su(),{dashboard:i,isLoading:r,isError:u,activityLoading:h,activityError:f,refetch:b}=Ym(),v=i??n?.dashboard,S=I1(!n,n?.health),{openRun:k}=O1();if(u&&!v)return l.jsxs("div",{className:"page-container",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"All projects unavailable"}),l.jsx("p",{className:"page-subtitle",children:"Canonry could not load the project list."})]})}),l.jsxs("div",{className:"max-w-xl rounded-lg border border-negative bg-negative-soft p-4",role:"alert",children:[l.jsx("p",{className:"text-sm font-medium text-heading",children:"Your projects have not been changed."}),l.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Check the connection or sign in again, then retry."}),l.jsx(le,{type:"button",variant:"secondary",className:"mt-4",onClick:()=>{b()},children:"Retry loading projects"})]})]});if(!v||r)return l.jsxs("div",{className:"page-skeleton",children:[l.jsxs("div",{className:"page-skeleton-header",children:[l.jsx("div",{className:"skeleton-text h-6 w-32"}),l.jsx("div",{className:"skeleton-text-sm w-64"})]}),l.jsx("div",{className:"space-y-3",children:[1,2,3].map(M=>l.jsxs("div",{className:"rounded-xl border border-default bg-surface p-4 flex items-center gap-4",children:[l.jsxs("div",{className:"flex-1 space-y-2",children:[l.jsx("div",{className:"skeleton-text w-36"}),l.jsx("div",{className:"skeleton-text-sm w-48"})]}),l.jsx("div",{className:"skeleton-text w-16"}),l.jsx("div",{className:"skeleton-text w-16"}),l.jsx("div",{className:"skeleton h-8 w-20 rounded"})]},M))})]});const N=v.portfolioOverview,T=N.projects.length>0&&N.projects.every(M=>M.hasMeasurement===!1),z=N.projects.some(M=>V1(M.sentiment)),q=N.attentionItems.map(M=>T&&M.id==="attention_stable"?{...M,tone:"neutral",title:"Awaiting first measurement",detail:"Visibility results will appear after the first sweep."}:M),E=S.data??n?.health??{apiStatus:{label:"API",state:"checking",detail:"Checking service health"},workerStatus:{label:"Worker",state:"checking",detail:"Checking service health"}},P=uZ(N.systemHealth.filter(M=>e||M.id==="api"||M.id==="worker"),E,v.settings);return l.jsxs("div",{className:"page-container",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"All projects"}),l.jsx("p",{className:"page-subtitle",children:"Visibility across all projects."})]})}),N.projects.length>0?l.jsx("div",{className:"project-list project-list-scrollable",children:N.projects.map(M=>l.jsx(tW,{project:M,sentimentColumn:z},M.project.id))}):l.jsxs(_a,{className:"surface-card empty-card",children:[l.jsx("h3",{children:N.emptyState?.title??"No projects yet"}),l.jsx("p",{className:"supporting-copy",children:N.emptyState?.detail}),l.jsx(le,{size:"sm",asChild:!0,children:l.jsx(at,{to:N.emptyState?.ctaHref==="/setup"||!N.emptyState?.ctaHref?"/setup":"/",children:N.emptyState?.ctaLabel??"Launch setup"})})]}),l.jsxs("div",{className:"overview-secondary-grid",children:[q.length>0&&l.jsxs("section",{className:"overview-secondary-section",children:[l.jsx("div",{className:"section-head section-head-inline",children:l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Needs attention"}),l.jsx("h2",{className:"section-title-sm",children:"What changed"})]})}),l.jsx("div",{className:"attention-list attention-list-scrollable",children:q.map(M=>M.href?l.jsxs(at,{to:M.href,className:`attention-item attention-item-${M.tone}`,children:[l.jsxs("div",{children:[l.jsx("p",{className:"attention-title",children:M.title}),l.jsx("p",{className:"attention-detail",children:M.detail})]}),M.actionLabel&&l.jsx("span",{className:"attention-action",children:M.actionLabel})]},M.id):l.jsxs("div",{className:`attention-item attention-item-static attention-item-${M.tone}`,children:[l.jsxs("div",{children:[l.jsx("p",{className:"attention-title",children:M.title}),l.jsx("p",{className:"attention-detail",children:M.detail})]}),M.actionLabel&&l.jsx("span",{className:"attention-action",children:M.actionLabel})]},M.id))})]}),l.jsxs("section",{className:"overview-secondary-section",children:[l.jsx("div",{className:"section-head section-head-inline",children:l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Recent runs"}),l.jsx("h2",{className:"section-title-sm",children:"Activity"})]})}),l.jsx("div",{className:"compact-stack compact-stack-scrollable",children:f?l.jsxs("div",{role:"alert",children:[l.jsx("p",{className:"text-sm text-secondary",children:"Recent jobs could not be loaded."}),l.jsx(le,{type:"button",variant:"secondary",className:"mt-3",onClick:()=>{b()},children:"Retry loading activity"})]}):h?l.jsx("p",{className:"supporting-copy",role:"status",children:"Loading recent jobs…"}):N.recentRuns.length>0?N.recentRuns.map(M=>l.jsxs("button",{className:"compact-run",type:"button",onClick:()=>k(M.id),children:[l.jsxs("div",{children:[l.jsx("p",{className:"compact-run-title",children:M.projectName}),l.jsx("p",{className:"compact-run-detail",children:M.summary})]}),l.jsx(z1,{status:M.status})]},M.id)):l.jsx("p",{className:"supporting-copy",children:"Run history appears here after the first launch."})})]})]}),l.jsxs("section",{className:"page-section",children:[l.jsx("div",{className:"section-head section-head-inline",children:l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"System health"}),l.jsx("h2",{className:"section-title-sm",children:"Infrastructure"})]})}),l.jsx("div",{className:"divide-y divide-default border-y border-default",children:P.map(M=>{const L=M.id==="api"?E.apiStatus:M.id==="worker"?E.workerStatus:void 0,$=L?L.state==="ok"?void 0:Kr(L):M.tone==="positive"?void 0:M.meta;return l.jsxs("div",{className:"flex items-start justify-between gap-4 py-3",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium text-heading",children:M.label}),$&&l.jsx("p",{className:"mt-1 text-sm text-secondary",children:$})]}),l.jsx(wn,{tone:M.tone,title:L?Kr(L):M.meta,children:M.detail})]},M.id)})})]})]})}const aW='a, button, input, select, textarea, label, [role="button"], [role="link"], [role="checkbox"], [role="menuitem"]';function iW(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!1;const n=e.target;if(n&&typeof n.closest=="function"&&n.closest(aW))return!1;const i=typeof window<"u"?window.getSelection():null;return!(i&&!i.isCollapsed&&i.toString().trim()!=="")}function sW({onApplied:e}){const{canWrite:n}=fa(),[i,r]=C.useState(""),[u,h]=C.useState(!1),[f,b]=C.useState([]),[v,x]=C.useState([]);if(Gm()||!n)return null;const S=async()=>{if(!i.trim())return;h(!0),b([]),x([]);const k=N6(i),N=[],T=[];for(let z=0;z<k.length;z++){const q=k[z];if(q.errors.length>0){N.push(`Document ${z+1}: ${q.errors[0]?.message}`);continue}const E=q.toJSON();if(!(!E||typeof E!="object"))try{const P=await kH(E);T.push(`Applied "${P.displayName||P.name}" (revision ${P.configRevision})`)}catch(P){N.push(`Document ${z+1}: ${qi(P)}`)}}b(T),x(N),h(!1),T.length>0&&(bn({title:"YAML applied",detail:`Applied ${T.length} document${T.length===1?"":"s"} successfully.`,tone:N.length>0?"caution":"positive",dedupeKey:"yaml:apply",dedupeMode:"replace"}),e())};return l.jsxs("section",{className:"mt-8",children:[l.jsx("div",{className:"page-section-divider"}),l.jsx("div",{className:"section-head mt-6",children:l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Config as code"}),l.jsx("h2",{className:"text-sm font-medium text-strong",children:"Apply YAML"})]})}),l.jsxs("p",{className:"text-muted text-sm mb-3",children:["Paste a ",l.jsx("code",{className:"text-secondary",children:"canonry.yaml"})," config (multi-document YAML with ",l.jsx("code",{className:"text-secondary",children:"---"})," separators supported)."]}),l.jsx("textarea",{className:"setup-input w-full font-mono text-xs",rows:10,placeholder:`apiVersion: canonry/v1
|
|
65
65
|
kind: Project
|
|
66
66
|
metadata:
|
|
67
67
|
name: my-project
|
|
@@ -83,4 +83,4 @@ spec:
|
|
|
83
83
|
`);En(Ye),Ks(!0)}}catch(H){ll(H instanceof Error?H.message:"Failed to generate queries"),M({flowVersion:ft,onboardingSessionId:E,event:"onboarding.blocked",step:"queries",action:"generate_queries",reasonCode:Ac(H,"unknown")},"onboarding.blocked:queries:generate")}finally{ol(!1)}}},bl=async()=>{if(!Ne)return;const H=yi;if(H.length!==0){Fa(!0),ml(null);try{await fH(Ne,H),Ji(!0),await r(),M({flowVersion:ft,onboardingSessionId:E,event:"onboarding.step_completed",step:"competitors",method:"manual",countBucket:si(H.length)},"onboarding.step_completed:competitors"),W(4)}catch(Ye){ml(Ye instanceof Error?Ye.message:"Failed to save competitors"),M({flowVersion:ft,onboardingSessionId:E,event:"onboarding.blocked",step:"competitors",action:"save",reasonCode:"unknown"},"onboarding.blocked:competitors:save")}finally{Fa(!1)}}},vl=async()=>{const H=es.trim();if(H){Ho(!0),Qo(null);try{await KN("gemini",{apiKey:H}),bn({title:"Gemini configured",detail:"Provider is ready — continuing setup.",tone:"positive",dedupeKey:"setup:gemini:configured",dedupeMode:"drop"}),cu(""),await r(),hi(v.providerStatuses.find(Ye=>Ye.name.toLowerCase()==="gemini")?.name??"gemini"),M({flowVersion:ft,onboardingSessionId:E,event:"onboarding.step_completed",step:"system",method:"inline"},"onboarding.step_completed:system")}catch(Ye){Qo(Ye instanceof Error?Ye.message:"Failed to save Gemini key"),M({flowVersion:ft,onboardingSessionId:E,event:"onboarding.blocked",step:"system",action:"configure_provider",reasonCode:"provider_save_failed"},"onboarding.blocked:system:provider_save_failed")}finally{Ho(!1)}}},bi=async()=>{if(!bo()){if(!Ne||Xa){zn(Xa??"Complete setup before launching the first sweep.");const H=ba??(Ne?ya===0?"no_queries":"run_rejected":"unknown");Oa||M({flowVersion:ft,onboardingSessionId:E,event:"run.requested",origin:"dashboard_setup",result:"rejected",providerCountBucket:si(kt),queryCountBucket:si(ya),reasonCode:H});return}Fs(!0),zn(null);try{const H=await gl.mutateAsync({projectName:Ne,projectLabel:xe||Se||Ne,sourceAction:"setup-launch"});op(H.id),sp(!0),RN(Ne,H.id),fl.current=H.id,Oa||M({flowVersion:ft,onboardingSessionId:E,event:"run.requested",origin:"dashboard_setup",result:"queued",providerCountBucket:si(kt),queryCountBucket:si(ya)}),await r()}catch(H){zn(H instanceof Error?H.message:"Failed to queue the visibility sweep. Retry when the instance is ready."),Oa||M({flowVersion:ft,onboardingSessionId:E,event:"run.requested",origin:"dashboard_setup",result:"rejected",providerCountBucket:si(kt),queryCountBucket:si(ya),reasonCode:Ac(H,"run_rejected")})}finally{Fs(!1)}}},Mn=()=>W(H=>T?2:Math.max(0,H-1)),Yo=(H,Ye,vi)=>{M({flowVersion:ft,onboardingSessionId:E,event:"onboarding.step_completed",step:H,method:"existing",...vi===void 0?{}:{countBucket:si(vi)}},`onboarding.step_completed:${H}`),W(Ye)},xl=()=>{if(M({flowVersion:ft,onboardingSessionId:E,event:"onboarding.step_completed",step:"queries",method:"skipped",countBucket:"0"},"onboarding.step_completed:queries"),T){Qt();return}W(3)},wl=()=>{M({flowVersion:ft,onboardingSessionId:E,event:"onboarding.step_completed",step:"competitors",method:"skipped",countBucket:"0"},"onboarding.step_completed:competitors"),W(4)},Zs=T?"section":_a,va=et!==!0||Ot===!0?l.jsx(le,{type:"button",variant:"ghost",size:"sm",className:"min-h-11",onClick:()=>{r(),Gs&&Je.refetch()},children:"Check again"}):null,Sl=(et===!1||ga)&&!!ta,Ys=T&&(B===2||B===4)?x?l.jsxs("section",{"aria-labelledby":"setup-provider-heading",className:"space-y-3 border-b border-default pb-6 mb-6",children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l.jsx("h2",{id:"setup-provider-heading",className:"text-lg font-semibold text-heading",children:et===!1?"Connect a provider":"Answer engine provider"}),l.jsx(wn,{tone:et===!0?"positive":"neutral",children:et===!0?"Configured":et===!1?"Not connected":"Checking"})]}),l.jsx("p",{className:"max-w-prose text-sm text-secondary",children:et===!0?Et.length>0?`${Et.map(H=>H.displayName??H.name).join(", ")} available for this project. Research and sweeps use your provider account.`:"ChatGPT in Chrome is configured for sweeps. Query Research needs an API provider.":et===!1?"An answer engine is required for visibility sweeps. You can save queries now and connect later.":"Checking available providers. You can choose queries while this finishes."}),et===!1||ga?ta?l.jsx("div",{children:l.jsx(bW,{compact:!0,leadingField:l.jsxs("div",{className:"min-w-0 space-y-1.5",children:[l.jsx("label",{className:"block text-sm font-medium text-secondary",htmlFor:"setup-provider",children:"Provider to connect"}),l.jsx("select",{ref:ru,id:"setup-provider",className:"setup-input",value:ta.name,onChange:H=>{H.target.value!==ta.name&&($o.current=document.activeElement===H.currentTarget,ul(H.target.value))},children:Go.map(H=>l.jsx("option",{value:H.name,children:H.displayName??H.name},H.name))})]}),secondaryActions:va,providerName:ta.name,keyUrl:ta.keyUrl,modelHint:ta.modelHint,onSaved:()=>{on(!1),r()}},ta.name)}):l.jsx("p",{className:"max-w-prose text-sm text-secondary",children:vn.length>0?`This project's provider selection is ${vn.join(", ")}. Configure an allowed provider in Settings, or change the selection in project Settings.`:"Provider configuration is unavailable here. Open Settings to connect an answer engine, then check again."}):null,l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[et===!0&&!ga&&ta?l.jsx(le,{type:"button",variant:"outline",size:"sm",onClick:()=>on(!0),children:"Configure a provider"}):null,!ta||Ot===!0?l.jsx(le,{type:"button",variant:"outline",size:"sm",asChild:!0,children:l.jsx(at,{to:"/settings",target:"_blank",rel:"noopener noreferrer",children:"Open provider settings"})}):null,Sl?null:va]})]}):l.jsxs("section",{"aria-labelledby":"setup-provider-heading",className:"space-y-2 border-b border-default pb-6 mb-6",children:[l.jsx("h2",{id:"setup-provider-heading",className:"text-lg font-semibold text-heading",children:"Answer engine provider"}),l.jsx("p",{className:"max-w-prose text-sm text-secondary",children:"Provider settings are managed by an administrator."}),ze?l.jsx("p",{role:"alert",className:"text-sm text-negative",children:"Provider readiness could not be checked. Try again."}):l.jsx("p",{className:"max-w-prose text-sm text-secondary",role:"status",children:et===!0?"An answer engine is available for this project.":et===!1?"Ask an administrator to connect an answer engine for this project. You can save queries now.":"Checking provider readiness. You can save queries now."}),l.jsx(le,{type:"button",variant:"ghost",size:"sm",className:"min-h-11",disabled:ea.isFetching,onClick:()=>{ea.refetch()},children:ze?"Retry provider check":"Check again"})]}):null,Ja=(()=>{switch(B){case 0:return l.jsxs(_a,{className:"surface-card step-card",children:[l.jsx("div",{className:"section-head",children:l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 1 of 5"}),l.jsx("h2",{children:"System check"})]})}),l.jsx("p",{className:"supporting-copy",children:"Checking that your Canonry instance is configured and reachable."}),l.jsx("div",{className:"compact-stack",children:N.healthChecks.map(H=>l.jsxs("div",{className:"health-check-row",children:[l.jsxs("div",{children:[l.jsx("p",{className:"run-row-title",children:H.label}),l.jsx("p",{className:"supporting-copy",children:H.detail}),H.id==="provider"&&H.state!=="ready"&&l.jsxs("div",{className:"mt-3 rounded-md border border-default bg-bg-elevated/40 p-3 space-y-2",children:[l.jsxs("p",{className:"text-xs text-secondary",children:["Paste a Gemini key to enable visibility checks (free at"," ",l.jsx("a",{href:"https://aistudio.google.com/apikey",target:"_blank",rel:"noreferrer",className:"text-positive-400 hover:text-positive underline underline-offset-2",children:"aistudio.google.com"}),")."]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"password",value:es,onChange:Ye=>cu(Ye.target.value),placeholder:"AI... (paste here)",className:"flex-1 rounded-md border border-base bg-bg px-2.5 py-1.5 text-sm text-heading placeholder:text-faint focus:border-mono-600 focus:outline-none font-mono",disabled:In}),l.jsx(le,{type:"button",size:"sm",disabled:In||!es.trim(),onClick:fn(vl),children:In?"Saving...":"Save"})]}),yl&&l.jsxs("div",{role:"alert",className:"space-y-1 text-xs text-negative",children:[l.jsx("p",{children:yl}),l.jsx("p",{children:"Check that the key is complete, then retry Save."})]}),l.jsxs("p",{className:"text-sm text-secondary",children:["Connect more answer engines later in"," ",l.jsx(at,{to:"/settings",className:"text-link hover:underline",children:"Settings"}),"."]})]})]}),l.jsx(wn,{tone:H.state==="ready"?"positive":"caution",title:H.id==="api"?Kr(k.apiStatus):H.id==="worker"?Kr(k.workerStatus):H.detail,children:H.state==="ready"?"Ready":"Attention"})]},H.id))}),l.jsxs("div",{className:"setup-nav",children:[N.launchState.blockedReason?l.jsx("p",{role:"status",className:"supporting-copy text-negative",children:N.launchState.blockedReason}):l.jsx("span",{}),l.jsx(le,{type:"button",disabled:!N.launchState.enabled,title:N.launchState.blockedReason,onClick:()=>{M({flowVersion:ft,onboardingSessionId:E,event:"onboarding.step_completed",step:"system",method:"automatic"},"onboarding.step_completed:system"),W(Le)},children:"Continue"})]})]});case 1:return l.jsxs(_a,{className:"surface-card step-card",children:[l.jsxs("div",{className:"section-head",children:[l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 2 of 5"}),l.jsx("h2",{children:"Create project"})]}),Ne?l.jsx(wn,{tone:"positive",children:"Created"}):null]}),Ne?l.jsxs("div",{className:"compact-stack",children:[l.jsxs("p",{className:"text-neutral",children:["Project ",l.jsx("span",{className:"text-heading font-medium",children:Ne})," created successfully."]}),l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:Mn,children:"Back"}),l.jsx(le,{type:"button",onClick:()=>Yo("project",2),children:"Continue"})]})]}):l.jsxs("div",{className:"compact-stack",children:[l.jsxs("div",{className:"setup-field",children:[l.jsx("label",{className:"setup-label",htmlFor:"project-name",children:"Project name"}),l.jsx("input",{id:"project-name",className:"setup-input",type:"text",placeholder:"my-website",value:Se,onChange:H=>Me(H.target.value)}),Kn&&Kn!==Se?l.jsxs("p",{className:"supporting-copy",children:["Slug: ",Kn]}):null]}),l.jsxs("div",{className:"setup-field",children:[l.jsx("label",{className:"setup-label",htmlFor:"display-name",children:"Display name (optional)"}),l.jsx("input",{id:"display-name",className:"setup-input",type:"text",placeholder:"My Website",value:xe,onChange:H=>pe(H.target.value)})]}),l.jsxs("div",{className:"setup-field",children:[l.jsx("label",{className:"setup-label",htmlFor:"domain",children:"Canonical domain"}),l.jsx("input",{id:"domain",className:"setup-input",type:"text",placeholder:"example.com",value:ce,onChange:H=>ue(H.target.value)})]}),l.jsxs("div",{className:"setup-field-row",children:[l.jsxs("div",{className:"setup-field",children:[l.jsx("label",{className:"setup-label",htmlFor:"country",children:"Country"}),l.jsx("input",{id:"country",className:"setup-input",type:"text",placeholder:"US",maxLength:2,value:_e,onChange:H=>Fe(H.target.value.toUpperCase())})]}),l.jsxs("div",{className:"setup-field",children:[l.jsx("label",{className:"setup-label",htmlFor:"language",children:"Language"}),l.jsx("input",{id:"language",className:"setup-input",type:"text",placeholder:"en",maxLength:5,value:Ee,onChange:H=>Ct(H.target.value.toLowerCase())})]})]}),l.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-default bg-surface p-3 cursor-pointer hover:border-strong",children:[l.jsx("input",{type:"checkbox",className:"mt-0.5 h-4 w-4 rounded border-strong bg-bg",checked:me,onChange:H=>Be(H.target.checked)}),l.jsxs("span",{className:"flex-1",children:[l.jsx("span",{className:"block text-sm text-heading",children:"Auto-extract backlinks"}),l.jsxs("span",{className:"block text-xs text-muted mt-0.5",children:["When a new Common Crawl release syncs, automatically extract backlinks for this project."," ",l.jsx(at,{to:"/backlinks",className:"text-positive-400 hover:text-positive underline underline-offset-2",children:"Manage backlinks"})]})]})]}),Ze?l.jsx("p",{className:"text-negative-400 text-sm",children:Ze}):null,l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:Mn,children:"Back"}),l.jsx(le,{type:"button",disabled:!Kn||!ce||qn,onClick:fn(lp),children:qn?"Creating...":"Create project"})]})]})]});case 2:return l.jsxs(Zs,{className:T?"visibility-setup-section step-card":"surface-card step-card","aria-labelledby":"setup-queries-heading",children:[l.jsxs("div",{className:"section-head",children:[l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:T?"Step 1 of 2":"Step 3 of 5"}),l.jsx("h2",{id:"setup-queries-heading",children:"Add queries"})]}),se?l.jsx(wn,{tone:"neutral",children:"Loading"}):V.isError?l.jsx(wn,{tone:"negative",children:"Load failed"}):Vt?l.jsxs(wn,{tone:"positive",children:[na.length," saved"]}):l.jsxs(wn,{tone:"neutral",children:[na.length," quer",na.length!==1?"ies":"y"]})]}),l.jsx("p",{className:"supporting-copy",children:"Add the queries your customers use, one per line. You can refine your list later."}),l.jsxs("div",{className:"space-y-2 border-b border-default pb-4",children:[l.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[l.jsxs("div",{className:"min-w-0 space-y-1",children:[l.jsx("h3",{className:"text-sm font-semibold text-heading",children:"Research queries with your agent"}),l.jsx("p",{className:"max-w-prose text-sm text-secondary",children:"Ask your agent to compare answers and available sources with Canonry Research, then recommend queries. Research does not change your tracked queries."})]}),l.jsx(le,{type:"button",variant:"outline",size:"sm",className:"min-h-11 shrink-0 self-start",onClick:fn(dl),children:Dn?"Research prompt copied":"Copy research prompt"})]}),l.jsxs("details",{open:Ko||void 0,className:"text-sm text-secondary",children:[l.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-link",children:"View agent prompt"}),l.jsx("textarea",{"aria-label":"Agent query research prompt",readOnly:!0,className:"setup-textarea mt-2 w-full",rows:8,value:Zi})]}),Ko?l.jsx("p",{role:"alert",className:"text-sm text-negative",children:"Could not copy. Select and copy the prompt above."}):null]}),se?l.jsx("div",{className:"rounded-md border border-default bg-bg-elevated/40 p-4 text-sm text-secondary",role:"status",children:"Loading saved queries…"}):V.isError?l.jsxs("div",{className:"compact-stack",children:[l.jsx("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:"Saved queries could not be loaded. Retry before changing the query basket."}),l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:T?Ve:Mn,children:"Back"}),l.jsx(le,{type:"button",onClick:()=>{V.refetch()},children:"Retry loading queries"})]})]}):Vt?l.jsxs("div",{className:"compact-stack",children:[l.jsx("ul",{className:"detail-list",children:na.map(H=>l.jsx("li",{children:H},H))}),l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:T?Ve:Mn,children:"Back"}),l.jsx(le,{type:"button",variant:"outline",onClick:()=>di(!1),children:"Edit queries"}),l.jsx(le,{type:"button",onClick:()=>Yo("queries",T?4:3,na.length),children:"Continue"})]})]}):l.jsxs("div",{className:"compact-stack",children:[Et.length>0?l.jsxs("div",{className:"compact-stack",children:[l.jsxs("div",{className:"flex items-center gap-2 text-muted text-xs uppercase tracking-wide",children:[l.jsx("span",{className:"flex-1 border-t border-base"}),"auto-generate",l.jsx("span",{className:"flex-1 border-t border-base"})]}),l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsxs("div",{className:"setup-field flex-1",children:[l.jsx("label",{className:"setup-label",htmlFor:"gen-provider",children:"Provider"}),l.jsx("select",{id:"gen-provider",className:"setup-input",value:sn,onChange:H=>hi(H.target.value),children:Et.map(H=>l.jsxs("option",{value:H.name,children:[H.displayName??H.name,H.model?` (${H.model})`:""]},H.name))})]}),l.jsxs("div",{className:"setup-field",children:[l.jsx("label",{className:"setup-label",htmlFor:"gen-count",children:"Count"}),l.jsx("select",{id:"gen-count",className:"setup-input",value:Vo,onChange:H=>Hs(Number(H.target.value)),children:[3,5,10,15,20].map(H=>l.jsx("option",{value:H,children:H},H))})]}),l.jsx(le,{type:"button",variant:"outline",disabled:ou||!sn,onClick:fn(qa),children:ou?"Analyzing site...":"Generate"})]}),rl?l.jsx("p",{className:"text-negative-400 text-sm",children:rl}):null]}):null,T?null:l.jsxs("div",{className:"flex items-center gap-2 text-muted text-xs uppercase tracking-wide",children:[l.jsx("span",{className:"flex-1 border-t border-base"}),"or type manually",l.jsx("span",{className:"flex-1 border-t border-base"})]}),l.jsxs("div",{className:"setup-field",children:[l.jsx("label",{className:"setup-label",htmlFor:"queries",children:"Queries (one per line)"}),l.jsx("textarea",{id:"queries",className:"setup-textarea",rows:6,placeholder:`emergency dentist brooklyn
|
|
84
84
|
best invisalign downtown brooklyn
|
|
85
85
|
pediatric dentist brooklyn heights`,value:Ft,onChange:H=>En(H.target.value)})]}),Vs?l.jsx("p",{className:"text-negative-400 text-sm",children:Vs}):null,l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:T?Ve:Mn,children:"Back"}),l.jsx(le,{type:"button",variant:"ghost",onClick:xl,children:T?"Finish without AI Visibility":"Skip for now"}),l.jsx(le,{type:"button",disabled:na.length===0||Rn,onClick:fn(Zo),children:Rn?"Saving...":`Save ${na.length} quer${na.length!==1?"ies":"y"}`})]})]})]});case 3:return l.jsxs(_a,{className:"surface-card step-card",children:[l.jsxs("div",{className:"section-head",children:[l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 4 of 5"}),l.jsx("h2",{children:"Add competitors"})]}),Xi?l.jsx(wn,{tone:"positive",children:"Saved"}):null]}),l.jsx("p",{className:"supporting-copy",children:"Optional. Domains that compete for the same queries, one per line. You can add them later from the project."}),Xi?l.jsxs("div",{className:"compact-stack",children:[l.jsx("ul",{className:"detail-list",children:yi.map(H=>l.jsx("li",{children:H},H))}),l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:Mn,children:"Back"}),l.jsx(le,{type:"button",onClick:()=>Yo("competitors",4,yi.length),children:"Continue"})]})]}):l.jsxs("div",{className:"compact-stack",children:[l.jsxs("div",{className:"setup-field",children:[l.jsx("label",{className:"setup-label",htmlFor:"competitors",children:"Competitor domains (one per line)"}),l.jsx("textarea",{id:"competitors",className:"setup-textarea",rows:4,placeholder:`competitor1.com
|
|
86
|
-
competitor2.com`,value:fi,onChange:H=>Yi(H.target.value)})]}),en?l.jsx("p",{className:"text-negative-400 text-sm",children:en}):null,l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:Mn,children:"Back"}),l.jsx("div",{className:"flex gap-2",children:yi.length===0?l.jsx(le,{type:"button",onClick:wl,children:"Continue without competitors"}):l.jsxs(l.Fragment,{children:[l.jsx(le,{type:"button",variant:"outline",onClick:wl,children:"Skip"}),l.jsx(le,{type:"button",disabled:pl,onClick:fn(bl),children:pl?"Saving...":`Save ${yi.length} competitor${yi.length!==1?"s":""}`})]})})]})]})]});case 4:{const H=Ya.data,Ye=H?.status??(Wi===tt?.id?tt.status:void 0),vi=Ye==="completed"||Ye==="partial"||Ye==="failed"||Ye==="cancelled",ts=H?.snapshots??[],Ma=H?.queryCounts,kl=Ye?rk(Ye,ts.length):!1,An=Ke&&!Za,xi=jn??(H?.error?rQ(H.error):Ye==="cancelled"?"The sweep was cancelled before it produced a baseline.":(Ye==="completed"||Ye==="partial")&&ts.length===0?"The sweep finished without producing any snapshots.":tt?.statusDetail||"The sweep did not produce a baseline.");let Wa=null;return An||kl?Wa=l.jsx(wn,{tone:"positive",children:"Complete"}):jn&&!Za?Wa=l.jsx(wn,{tone:"negative",children:"Failed"}):vi?Wa=l.jsx(wn,{tone:"negative",children:Ye==="cancelled"?"Cancelled":"Failed"}):Za&&(Wa=l.jsx(wn,{tone:"caution",children:"Running"})),l.jsxs(_a,{className:"surface-card step-card",children:[l.jsxs("div",{className:"section-head",children:[l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:T?"Step 2 of 2":"Step 5 of 5"}),l.jsx("h2",{children:bo()?"AI Visibility":"Launch first run"})]}),Wa]}),An?l.jsxs("div",{className:"compact-stack",children:[l.jsxs("p",{className:"text-secondary",children:["Setup is complete. ",l.jsx("span",{className:"text-strong font-medium",children:Ne})," already has a successful answer-visibility baseline."]}),l.jsxs("div",{className:"setup-nav",children:[l.jsx("span",{}),l.jsx(le,{type:"button",onClick:()=>ct(),children:f?"Finish setup":"Open project dashboard →"})]})]}):!Za&&bo()?l.jsxs("div",{className:"compact-stack",children:[Ne?l.jsx(_X,{projectName:Ne}):l.jsx("p",{className:"text-sm text-secondary",children:Pg}),jn&&l.jsx("p",{role:"alert",className:"text-sm text-negative",children:jn}),l.jsxs("div",{className:"setup-nav",children:[l.jsx("span",{}),l.jsx(le,{type:"button",onClick:Ve,children:"Open project dashboard →"})]})]}):Za?vi?kl?l.jsxs("div",{className:"compact-stack",children:[l.jsxs("p",{className:"text-neutral",children:["Sweep complete. Your first answer-visibility snapshot for"," ",l.jsx("span",{className:"text-heading font-medium",children:Ne}),":"]}),l.jsxs("div",{className:"grid grid-cols-3 gap-2 mt-1",children:[l.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[l.jsx("p",{className:"text-xs font-medium text-secondary",children:"Mentioned"}),l.jsx("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:Ma?l.jsxs(l.Fragment,{children:[Ma.mentionedQueries,l.jsxs("span",{className:"text-faint text-lg",children:[" / ",Ma.totalQueries]})]}):"Unavailable"}),l.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"queries naming your brand"})]}),l.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[l.jsx("p",{className:"text-xs font-medium text-secondary",children:"Cited"}),l.jsx("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:Ma?l.jsxs(l.Fragment,{children:[Ma.citedQueries,l.jsxs("span",{className:"text-faint text-lg",children:[" / ",Ma.totalQueries]})]}):"Unavailable"}),l.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"queries citing your site"})]}),l.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[l.jsx("p",{className:"text-xs font-medium text-secondary",children:"Results"}),l.jsx("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:ts.length}),l.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"completed engine checks"})]})]}),!b&&Ne?l.jsx(yW,{projectName:Ne}):null,l.jsxs("div",{className:"setup-nav",children:[l.jsx("span",{}),l.jsx(le,{type:"button",onClick:()=>ct(),children:f?"Finish setup":"Open project dashboard →"})]})]}):l.jsxs("div",{className:"compact-stack",children:[l.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[l.jsx("p",{children:xi}),l.jsx("p",{className:"mt-1 text-xs text-secondary",children:bo()?Pg:x?"Fix provider or query configuration if needed, then retry without leaving setup.":"Ask an administrator to review the provider and query configuration."})]}),l.jsxs("div",{className:"setup-nav",children:[x&&!bo()?l.jsx(le,{type:"button",variant:"outline",asChild:!0,children:l.jsx(at,{to:"/settings",children:"Configure providers"})}):l.jsx("span",{}),bo()||!x?l.jsx(le,{type:"button",onClick:Ve,children:"Open project dashboard →"}):l.jsx(le,{type:"button",disabled:gi||!!Xa,onClick:fn(bi),children:gi?"Retrying...":"Retry visibility sweep"})]})]}):l.jsxs("div",{className:"compact-stack",children:[l.jsx("p",{className:"text-neutral",children:"Sweep running. This usually takes 30 to 60 seconds."}),l.jsx("div",{className:"rounded-md border border-default bg-surface p-3 text-xs text-muted",children:l.jsxs("p",{children:["Status: ",l.jsx("span",{className:"text-neutral",children:Ye??"queued"})]})}),Ya.isError&&l.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[l.jsx("p",{children:Ya.error instanceof Error?Ya.error.message:"Could not refresh the sweep status."}),l.jsx(le,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:()=>{Ya.refetch()},children:"Retry status check"})]}),l.jsxs("div",{className:"setup-nav",children:[l.jsx("span",{}),l.jsx(le,{type:"button",variant:"outline",onClick:f?()=>ct():Ve,children:f?"Finish setup":"Watch on project page"})]})]}):l.jsxs("div",{className:"compact-stack",children:[l.jsxs("p",{className:"supporting-copy",children:["Your queries are saved. Run a first sweep to get a baseline for"," ",l.jsx("span",{className:"text-heading font-medium",children:Ne}),", or finish and run it later from the project. A sweep calls the answer engines, so it costs provider usage."]}),(Xa||jn)&&l.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[l.jsx("p",{children:jn??Xa}),l.jsx("p",{className:"mt-1 text-xs text-secondary",children:"Resolve the blocker above, then retry the sweep here."})]}),l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:Mn,children:"Back"}),l.jsx(le,{type:"button",variant:"ghost",onClick:Qt,children:"Finish without running"}),ba==="no_provider"&&!T?l.jsx(le,{type:"button",asChild:!0,children:l.jsx(at,{to:"/settings",children:"Configure a provider"})}):l.jsx(le,{type:"button",disabled:gi||!!Xa,title:Xa,onClick:fn(bi),children:gi?"Launching...":jn?"Retry visibility sweep":"Launch visibility sweep"})]})]})]})}default:return null}})();return l.jsxs("div",{className:T?"page-container visibility-setup":"page-container",children:[f?l.jsx(Ro,{current:"visibility"}):null,l.jsxs("div",{className:"page-header",children:[l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{ref:u?h:void 0,tabIndex:u?-1:void 0,className:"page-title",children:u?"Set up AI Visibility":"Setup"}),l.jsx("p",{className:"page-subtitle",children:u?"Connect an answer engine, then choose queries for your first sweep.":"Create a project and run its first visibility check."})]}),f?l.jsx("div",{className:"page-header-right",children:l.jsx(le,{type:"button",variant:"outline",className:"min-h-11",onClick:Qt,children:"Skip AI Visibility"})}):null]}),f?null:l.jsx(kW,{current:T?B===4?1:0:B,labels:T?wW:xW}),l.jsxs("section",{className:"setup-wizard",children:[Ys,Ja]})]})}const Yf="canonry mcp install --client claude-code",NW="https://github.com/Canonry/canonry/blob/main/docs/mcp.md";function CW(){const e=C.useRef(w1()).current,n=C.useRef(new Set),i=C.useCallback((r,u)=>{n.current.has(r)||(n.current.add(r),N1({...u,flowVersion:ft,onboardingSessionId:e,surface:"platform",eventId:S1()}))},[e]);return C.useEffect(()=>{i("started",{event:"onboarding.started",step:"finish",resumed:!1})},[i]),C.useCallback(r=>{i(`action:${r}`,{event:"onboarding.step_completed",step:"finish",method:"manual",nextAction:r})},[i])}const ap=C.createContext(()=>{});function _W({projectName:e,skippedVisibility:n=!1}){const i=yt({...QF({client:J,path:{name:e}}),retry:!1}),r=i.data?.hasData?i.data:null,u=CW(),h=uk(e,Oe["site-audit"]),f=uk(e,Oe["answer-visibility"]),b={...h?{site:h,fixes:h}:{},...TW(f,n)};return l.jsx(ap.Provider,{value:u,children:l.jsxs("div",{className:"page-container max-w-6xl py-8 md:py-10",children:[l.jsx(Ro,{current:"done",outcomes:b}),l.jsxs("header",{className:"relative mx-auto mt-12 max-w-2xl text-center md:mt-16",children:[l.jsx(EW,{}),l.jsx("p",{className:"onb-reveal mt-6 text-sm font-medium text-positive",style:Ta(250),children:"Setup complete"}),l.jsx("h1",{className:"onb-reveal mt-2 text-5xl font-semibold tracking-tight text-heading md:text-6xl",style:Ta(350),children:"You’re set."}),l.jsxs("p",{className:"onb-reveal mx-auto mt-4 max-w-xl text-lg text-secondary",style:Ta(450),children:["Canonry is tracking ",l.jsx("span",{className:"font-medium text-heading",children:e}),". Here’s how to get the most out of it from here."]})]}),l.jsxs("div",{className:"mt-14 grid gap-4 md:grid-cols-6",children:[l.jsx(Rd,{className:"md:col-span-4 md:row-span-2",delayMs:600,labelledBy:"onb-agent-heading",children:l.jsx(zW,{projectName:e})}),l.jsx(Rd,{className:"md:col-span-2 md:row-span-2",delayMs:700,labelledBy:"onb-data-heading",children:l.jsx(PW,{projectName:e})}),l.jsx(Rd,{className:"md:col-span-3",delayMs:800,labelledBy:"onb-schedule-heading",children:l.jsx(BW,{projectName:e})}),l.jsx(Rd,{className:"md:col-span-3",delayMs:900,labelledBy:"onb-alerts-heading",children:l.jsx(LW,{projectName:e,score:r?.aggregateScore??null})})]}),l.jsxs("div",{className:"onb-reveal mt-12 flex flex-col items-center gap-3 sm:flex-row sm:justify-center",style:Ta(1e3),children:[l.jsx(le,{asChild:!0,className:"h-11 rounded-full px-6 text-base md:h-11",children:l.jsxs(at,{to:"/projects/$projectName",params:{projectName:e},replace:!0,onClick:()=>u("open_project"),children:["Open ",e,l.jsx(Tc,{className:"size-4","aria-hidden":"true"})]})}),l.jsx(le,{asChild:!0,variant:"ghost",className:"h-11 rounded-full px-5 md:h-11",children:l.jsx(at,{to:"/projects/$projectName/technical-aeo",params:{projectName:e},replace:!0,onClick:()=>u("review_page_health"),children:"Review page health"})})]})]})})}function uk(e,n){const i=yt({...XN({client:J,path:{name:e},query:{kind:n,limit:20}}),retry:!1,refetchInterval:r=>dk(r.state.status==="success"?{isSuccess:!0,data:r.state.data}:{isSuccess:!1})==="pending"?5e3:!1});return dk(i)}function TW(e,n){return e===void 0?{}:n?{visibility:"skipped"}:{visibility:e}}function dk(e){if(!e.isSuccess||!e.data)return"unknown";const n=e.data.filter(i=>i.trigger!==$a.probe);if(!n.some(i=>i.status===Nt.completed||i.status===Nt.partial))return n.some(i=>i.status===Nt.queued||i.status===Nt.running)?"pending":n.length>0?"incomplete":"skipped"}function Ta(e){return{"--onb-delay":`${e}ms`}}function EW(){return l.jsx("div",{className:"onb-check relative mx-auto size-20","aria-hidden":"true",children:l.jsxs("svg",{viewBox:"0 0 80 80",className:"relative size-20",children:[l.jsx("circle",{className:"onb-check-ring",cx:"40",cy:"40",r:"36",fill:"none",strokeWidth:"3",pathLength:"1"}),l.jsx("path",{className:"onb-check-mark",d:"M25 41 L35 51 L56 30",fill:"none",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round",pathLength:"1"})]})})}function Rd({className:e="",delayMs:n,labelledBy:i,children:r}){return l.jsx("section",{"aria-labelledby":i,className:`onb-reveal onb-tile flex flex-col overflow-hidden rounded-2xl border border-default bg-surface p-6 md:p-7 ${e}`,style:Ta(n),children:r})}function ip({id:e,eyebrow:n,title:i,children:r}){return l.jsxs("div",{children:[l.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted",children:n}),l.jsx("h2",{id:e,className:"mt-1.5 text-2xl font-semibold tracking-tight text-heading",children:i}),l.jsx("p",{className:"mt-2 text-sm text-secondary",children:r})]})}const Dd=[{id:"diagnose",label:"Diagnose",prompt:"Why did we lose citations this week?",calls:["canonry_insights_list","canonry_competitor_landscape"],reply:"Two engines started citing a competitor’s comparison page instead of yours. Want me to draft one that answers the same query?"},{id:"fix",label:"Fix",prompt:"Fix the weakest pages on the site.",calls:["canonry_technical_aeo_pages","canonry_site_health_page_audit"],reply:"The lowest-scoring pages are missing structured data and answer-first intros. I’ve written the changes for you to review."},{id:"automate",label:"Automate",prompt:"Re-check everything every Monday and tell me in Slack.",calls:["canonry_schedule_set","canonry_agent_webhook_attach"],reply:"Done. A sweep runs every Monday, and I’ll post what changed to Slack."}],RW=9e3;function DW(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function zW({projectName:e}){const n=C.useContext(ap),[i,r]=C.useState(0),[u,h]=C.useState(!1),[f,b]=C.useState(!1);C.useEffect(()=>{if(u||DW())return;const S=window.setTimeout(()=>r(k=>(k+1)%Dd.length),RW);return()=>window.clearTimeout(S)},[i,u]);const v=async()=>{try{await navigator.clipboard.writeText(Yf),n("copy_agent_command"),b(!0),window.setTimeout(()=>b(!1),1800)}catch{bn({tone:"negative",title:"Could not copy the command",detail:`Run ${Yf} in your terminal.`})}},x=Dd[i]??Dd[0];return l.jsxs(l.Fragment,{children:[l.jsxs(ip,{id:"onb-agent-heading",eyebrow:"Your agent",title:"Let your agent run it.",children:["Your agent can do everything in Canonry: diagnose a drop, fix pages, run sweeps and scans, and write the client report. Use Claude Code, Codex, Cursor, or Aero, the analyst built into"," ",l.jsx("span",{className:"text-heading",children:e})," that reviews every sweep on its own."]}),l.jsxs("div",{className:"mt-6 flex flex-1 flex-col rounded-xl border border-default bg-bg",onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),onFocus:()=>h(!0),children:[l.jsxs("div",{className:"flex items-center gap-1 border-b border-default px-3 py-2",role:"tablist","aria-label":"Example agent sessions",children:[Dd.map((S,k)=>l.jsx("button",{type:"button",role:"tab","aria-selected":k===i,onClick:()=>{r(k),h(!0)},className:`rounded-md px-2.5 py-1 text-xs font-medium transition-colors ${k===i?"bg-surface-inset text-heading":"text-muted hover:text-secondary"}`,children:S.label},S.id)),l.jsx("span",{className:"ml-auto text-xs text-faint",children:"Example"})]}),l.jsxs("div",{role:"tabpanel","aria-label":`${x.label} example`,className:"flex-1 p-4 font-mono text-[13px] leading-relaxed",children:[l.jsxs("p",{className:"onb-type text-heading",style:Ta(150),children:[l.jsx("span",{className:"text-muted",children:"> "}),x.prompt]}),x.calls.map((S,k)=>l.jsxs("p",{className:"onb-line mt-1 text-muted first:mt-3",style:Ta(1300+k*450),children:[l.jsx("span",{className:"text-positive",children:"●"})," ",S]},S)),l.jsx("p",{className:"onb-line mt-3 text-secondary",style:Ta(1500+x.calls.length*450),children:x.reply}),l.jsx("span",{className:"onb-caret mt-2 inline-block h-4 w-2 bg-current align-middle text-secondary",style:Ta(1900+x.calls.length*450),"aria-hidden":"true"})]},x.id)]}),l.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[l.jsx("code",{className:"min-w-0 flex-1 truncate rounded-lg border border-default bg-surface-inset px-3 py-2 font-mono text-[13px] text-heading",children:Yf}),l.jsxs(le,{type:"button",variant:"secondary",size:"sm",className:"h-9 md:h-9",onClick:()=>{v()},children:[f?l.jsx(Uc,{className:"size-4","aria-hidden":"true"}):l.jsx(Zg,{className:"size-4","aria-hidden":"true"}),f?"Copied":"Copy"]}),l.jsx("a",{href:NW,target:"_blank",rel:"noreferrer",className:"text-sm font-medium text-link underline-offset-4 hover:underline",children:"Other clients"})]})]})}const IW=[{icon:Fg,label:"Search Console",action:"connect_search_console",to:"/projects/$projectName/search-console"},{icon:Ck,label:"Google Analytics",action:"connect_analytics",to:"/projects/$projectName/activity"},{icon:Tk,label:"Business Profile",action:"connect_business_profile",to:"/projects/$projectName/local"}],OW=["GPTBot","ClaudeBot","PerplexityBot"];function PW({projectName:e}){const n=C.useContext(ap);return l.jsxs(l.Fragment,{children:[l.jsx(ip,{id:"onb-data-heading",eyebrow:"Server-side traffic",title:"See the AI bots.",children:"AI crawlers and answer-engine fetches never run JavaScript, so Google Analytics never sees them. Canonry reads them straight from your server."}),l.jsx(qW,{}),l.jsxs(at,{to:"/traffic",onClick:()=>n("connect_server_traffic"),"aria-label":"Connect server-side traffic",className:"group flex items-center gap-3 rounded-xl border border-strong bg-surface-inset px-4 py-3 text-sm font-medium text-heading transition-colors hover:bg-surface-inset-hover",children:[l.jsx(Ek,{className:"size-4 text-positive","aria-hidden":"true"}),l.jsxs("span",{className:"flex-1",children:["Connect your server",l.jsx("span",{className:"block text-xs font-normal text-secondary",children:"Cloudflare, Vercel, WordPress, or Cloud Run"})]}),l.jsx(Tc,{className:"size-4 text-link transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]}),l.jsx("p",{className:"mt-5 text-xs font-medium uppercase tracking-wide text-muted",children:"Also connect"}),l.jsx("ul",{className:"mt-1 divide-y divide-default",children:IW.map(({icon:i,label:r,action:u,to:h})=>l.jsx("li",{children:l.jsxs(at,{to:h,params:{projectName:e},"aria-label":`Connect ${r}`,onClick:()=>n(u),className:"group flex items-center gap-3 py-2.5 text-sm text-heading",children:[l.jsx(i,{className:"size-4 text-muted","aria-hidden":"true"}),l.jsx("span",{className:"flex-1",children:r}),l.jsx(Tc,{className:"size-3.5 text-link transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]})},r))})]})}function qW(){const e=[22,70,118];return l.jsxs("div",{className:"relative my-6 h-36","aria-hidden":"true",children:[l.jsx("svg",{viewBox:"0 0 200 140",preserveAspectRatio:"none",className:"absolute inset-0 size-full",children:e.map((n,i)=>l.jsx("path",{className:"onb-flow",style:Ta(i*400),d:`M20 ${n} C 100 ${n}, 118 70, 170 70`,fill:"none",strokeWidth:"1.5"},n))}),OW.map((n,i)=>l.jsx("span",{className:"onb-bot absolute left-0 -translate-y-1/2 rounded-md border border-default bg-bg-elevated px-2 py-1 font-mono text-[11px] text-secondary",style:{top:`${(e[i]??70)/140*100}%`,...Ta(i*600)},children:n},n)),l.jsx("span",{className:"onb-hub absolute right-0 top-1/2 flex size-11 -translate-y-1/2 items-center justify-center rounded-2xl bg-accent text-on-inverse",children:l.jsx(Ek,{className:"size-5"})})]})}const MW=["M","T","W","T","F","S","S"];function BW({projectName:e}){return l.jsxs(l.Fragment,{children:[l.jsx(ip,{id:"onb-schedule-heading",eyebrow:"Scheduled sweeps",title:"Runs on its own.",children:"Re-measure every week without lifting a finger, so a drop shows up before a customer notices."}),l.jsx("ol",{className:"mt-6 grid grid-cols-7 gap-2","aria-hidden":"true",children:MW.map((n,i)=>l.jsxs("li",{className:"flex flex-col items-center gap-2",children:[l.jsx("span",{className:"onb-day size-3 rounded-full bg-surface-inset",style:Ta(i*500)}),l.jsx("span",{className:"text-xs text-muted",children:n})]},i))}),l.jsx(UC,{projectName:e,to:"/projects/$projectName/settings",icon:_k,label:"Set a schedule",action:"set_schedule"})]})}function LW({projectName:e,score:n}){return l.jsxs(l.Fragment,{children:[l.jsx(ip,{id:"onb-alerts-heading",eyebrow:"Notifications",title:"Hear about changes.",children:"Get a webhook in Slack or anywhere else when a sweep finishes or a score moves."}),l.jsxs("div",{className:"relative mt-6 flex h-14 items-center","aria-hidden":"true",children:[l.jsx("span",{className:"onb-bell flex size-10 items-center justify-center rounded-full border border-default bg-bg-elevated",children:l.jsx(Wf,{className:"size-4 text-secondary"})}),l.jsxs("span",{className:"onb-toast ml-3 flex items-center gap-2 rounded-xl border border-default bg-bg-elevated px-3 py-2 text-sm shadow-[0_8px_24px_var(--color-shadow-panel)]",children:[l.jsx("span",{className:"size-2 rounded-full bg-positive-400"}),l.jsx("span",{className:"text-heading",children:e}),l.jsx("span",{className:"text-secondary",children:n===null?"sweep finished":`page health ${n}`})]})]}),l.jsx(UC,{projectName:e,to:"/projects/$projectName/settings",icon:Wf,label:"Add a notification",action:"add_notification"})]})}function UC({projectName:e,to:n,icon:i,label:r,action:u}){const h=C.useContext(ap);return l.jsxs(at,{to:n,params:{projectName:e},onClick:()=>h(u),className:"group mt-6 inline-flex items-center gap-2 self-start text-sm font-medium text-link",children:[l.jsx(i,{className:"size-4","aria-hidden":"true"}),r,l.jsx(Tc,{className:"size-3.5 transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]})}const UW=C.lazy(async()=>({default:(await Qi(()=>import("./SiteHealthSection-CYG9IMh5.js").then(n=>n.d),__vite__mapDeps([0,1,2,3,4]),import.meta.url)).SiteHealthSection})),VW=`Public pages only, crawled from this computer and stored locally. The first scan reads up to ${T2} pages, then stops.`,$W=1800,KW="https://github.com/Canonry/canonry#or-use-any-shell-capable-coding-agent",GW="Help me set up Canonry for my public site.\n\nUse the official Canonry docs:\n- Agent quickstart: https://github.com/Canonry/canonry#or-use-any-shell-capable-coding-agent\n- CLI reference: https://github.com/Canonry/canonry/blob/main/skills/canonry/references/canonry-cli.md\n- Plugin setup: https://github.com/Canonry/canonry/blob/main/docs/plugins.md\n- MCP setup: https://github.com/Canonry/canonry/blob/main/docs/mcp.md\n\nPick one path and stay on it. Use connected Canonry tools (plugin or MCP) only if you have them and I have not pointed you at a specific install. A connected tool runs in its own process and never sees `CANONRY_CONFIG_DIR`, `CANONRY_PORT`, or anything else you export in a shell, so it always acts on my default install. If I named a config directory, a port, or a sandbox, that is the shell path: use `cnry` and tell me which path you chose. Never mix the two in one run, and never create a duplicate project. The `cnry` and `canonry` commands are interchangeable.\n\n1. Ask for my public domain, country, and language. Do not create or scan anything yet. Country and language are only applied when a project is created, so if you reuse an existing project, report its country and language instead of changing them.\n2. Shell path only: confirm `cnry` is on PATH, then run `cnry --version`. If Canonry is missing, propose `npm install -g @canonry/canonry` and wait for approval. Then run `cnry doctor --format json`, which is the command that says whether config, database, and server are in place. `cnry --version` does not read config and succeeds on a completely unconfigured install, so it cannot answer this. If config is missing, run `cnry bootstrap` yourself: it is not interactive, takes about a second, and is safe to rerun. Do not hand it to me and wait. The interactive command is `cnry init`, which is optional provider and OAuth setup that Page Health does not need. Bootstrap prints an API key, so do not repeat its output back to me, and never ask me to paste passwords, API keys, OAuth credentials, or command output.\n3. Confirm the API is reachable. `cnry doctor --format json` reports it, and any project read exits non-zero with `CONNECTION_ERROR` when it is not. If it is unreachable, propose `cnry start` and wait for approval. Use `cnry start`, which is the background daemon, and not `cnry serve`, which runs in the foreground and will block you until I stop it, even though some error messages suggest it. Stop anything you started with `cnry stop`.\n4. List projects with the connected project tool or `cnry project list --format json`, and reuse one whose domain matches. Confirm the proposed name is not already assigned to a different domain. To find out whether a project has already been scanned, run `cnry technical-aeo score <project> --format json` with no `--run-id`, which reports the latest run. Read the `hasData` field, not the score: this command exits 0 and reports `aggregateScore: 0` for a project that has never been scanned, so reading the score alone would have you tell me my site scored zero. If `hasData` is true and `runStatus` is `completed` or `partial`, read that scan instead of starting a new one. If no project matches, show the exact create operation and wait for approval.\n5. Propose a bounded Site Health scan: `--max-pages 100` for a first look, plus whether dead-link checking is on (it is off unless you pass `--check-dead-links`). Show the connected operation or the exact `cnry technical-aeo run <project> --max-pages 100 --wait --format json` command with the project name filled in, and wait for separate approval before scanning. `--wait` polls for up to 15 minutes and returns only the run id and status. If the status it returns is still `queued` or `running`, the scan has not finished: do not rerun it or report results, poll `cnry technical-aeo progress <project> --run-id <run-id> --format json` until it is terminal. If `--wait` outruns your own tool timeout first, recover the run id with `cnry technical-aeo score <project> --format json` and poll the same way.\n6. When the run is `completed` or `partial`, read `cnry technical-aeo crawl <project> --run-id <run-id> --format json` first. It is the only one of these commands that carries `termination` and `complete`; the score and pages commands do not. Then read `cnry technical-aeo score <project> --run-id <run-id> --format json` and `cnry technical-aeo pages <project> --run-id <run-id> --sort score-asc --limit 10 --format jsonl`. Tell me the termination reason in plain words and whether the scan covered the whole site or stopped at a page, link, depth, or time limit. A `partial` run scored the pages it reached and not my site, so never present it as a full-site result. If it stopped early, the fix depends on the reason, so say which: a page or depth limit needs a larger budget, a time limit needs a smaller scan (a lower `--max-pages` or `--max-depth`). If the run failed or was cancelled, inspect the run error and stop.\n7. Summarize only completed evidence, then propose AI Visibility setup. Ask before you add queries, connect providers, start a provider-backed or quota-consuming run, edit files, or publish.";function HW(e,n){return e==="legacy"?"legacy":e==="platform"?"platform":n.state==="success"?n.projectCount===0?"platform":"legacy":n.state==="error"?"retry":"loading"}const QW="2000-01-01T00:00:00.000Z",FW=5e3;function ZW(e,n){const i=new Set,r=new Map;for(const f of n)f.trigger!==$a.probe&&(r.has(f.projectId)||r.set(f.projectId,f.id),(f.status===Nt.completed||f.status===Nt.partial)&&i.add(f.projectId));const h=(e.every(f=>f.createdAt)?[...e].sort((f,b)=>(f.createdAt??"").localeCompare(b.createdAt??"")||f.name.localeCompare(b.name)):e).find(f=>!i.has(f.id));return h?{projectName:h.name,runId:r.get(h.id)}:null}const VC=[{value:"US",label:"United States"},{value:"CA",label:"Canada"},{value:"GB",label:"United Kingdom"},{value:"AU",label:"Australia"},{value:"NZ",label:"New Zealand"},{value:"IE",label:"Ireland"},{value:"DE",label:"Germany"},{value:"FR",label:"France"},{value:"ES",label:"Spain"},{value:"IT",label:"Italy"},{value:"NL",label:"Netherlands"},{value:"BR",label:"Brazil"},{value:"MX",label:"Mexico"},{value:"IN",label:"India"},{value:"SG",label:"Singapore"},{value:"JP",label:"Japan"}],$C=[{value:"en",label:"English"},{value:"es",label:"Spanish"},{value:"fr",label:"French"},{value:"de",label:"German"},{value:"it",label:"Italian"},{value:"pt",label:"Portuguese"},{value:"nl",label:"Dutch"},{value:"ja",label:"Japanese"}];function YW(e,n){try{const i=new Intl.DisplayNames(["en"],{type:"region"}),r=new Intl.DisplayNames(["en"],{type:"language"}),u=e.length===2?i.of(e.toUpperCase()):void 0,h=n?r.of(n.toLowerCase()):void 0;return`${u??(e||"Country")} · ${h??(n||"Language")}`}catch{return`${e||"Country"} · ${n||"Language"}`}}function XW(e,n){const i=e.trim().toUpperCase(),r=n.trim().toLowerCase();return{countryValid:VC.some(u=>u.value===i),languageValid:$C.some(u=>u.value===r)}}function JW(e){const n=e.replace(/^\[|\]$/g,"");return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(n)||n.includes(":")}function WW(e){const n=e.trim();if(!n)return null;const i=/^[a-z][a-z\d+.-]*:\/\//i.test(n)?n:`https://${n}`;let r;try{r=new URL(i)}catch{return null}if(r.protocol!=="http:"&&r.protocol!=="https:")return null;const u=r.hostname.toLowerCase().replace(/^www\./,"");if(!u||u==="localhost"||JW(u)||!u.includes("."))return null;const h=u.replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return h?{canonicalDomain:u,projectName:h,displayName:u}:null}async function eee(e,n=$W){let i;const r=new Promise(h=>{i=setTimeout(()=>h({state:"timed-out"}),n)}),u=await Promise.race([e.then(h=>({state:"queued",run:h})),r]);return i&&clearTimeout(i),u}function tee(e,n){e.catch(()=>{bn({title:"Site Health scan did not start",detail:"The project is safe. Choose Run scan in Site Health to retry.",tone:"negative",dedupeKey:`site-health-dispatch:${n}`})})}function KC(e){const n=C.useRef(w1()).current,i=C.useRef(new Set),r=C.useCallback((u,h)=>{if(h){if(i.current.has(h))return;i.current.add(h)}N1({...u,surface:e,eventId:S1()})},[e]);return{onboardingSessionId:n,emit:r}}function mk(e,n){return e instanceof gn&&e.statusCode===409?"A project with this name already exists. Change the project name, or open the existing project.":e instanceof Error&&e.message?e.message:n}function $g(){return l.jsxs("div",{className:"page-container max-w-3xl","aria-busy":"true","aria-live":"polite",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Preparing setup"}),l.jsx("p",{className:"page-subtitle",children:"Checking the projects already on this install."})]})}),l.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-default bg-surface p-4 text-sm text-secondary",role:"status",children:[l.jsx(Ts,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading projects…"]})]})}function nee({onRetry:e}){return l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Can’t load projects"}),l.jsx("p",{className:"page-subtitle",children:"Canonry could not confirm whether this install already has a project."})]})}),l.jsxs("div",{className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",tabIndex:-1,children:[l.jsx("p",{className:"text-sm font-medium text-heading",children:"Setup is paused to protect existing projects."}),l.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Check the connection or sign in again, then retry."}),l.jsx(le,{type:"button",className:"mt-4",variant:"secondary",onClick:e,children:"Retry project check"})]})]})}function aee({projectName:e,initialRunId:n}){return l.jsx(M1,{title:"Site Health setup",children:l.jsx(iee,{projectName:e,initialRunId:n})})}function iee({projectName:e,initialRunId:n}){const i=zs(),r=yt({...Bo({client:J}),enabled:!!e,retry:!1,refetchOnMount:"always"}),{onboardingSessionId:u,emit:h}=KC("site_health"),[f]=C.useState(()=>bG(n));C.useEffect(()=>{f&&vG()},[f]),C.useEffect(()=>{e&&h({flowVersion:ft,onboardingSessionId:u,event:"onboarding.started",step:"run",resumed:!!n&&!f},"onboarding.started")},[h,f,n,u,e]),C.useEffect(()=>{!e||!n||DN(e)?.runId!==n&&RN(e,n)},[n,e]);const v=yt({...T1({client:J,path:{id:n??""}}),enabled:!!n,refetchInterval:({state:T})=>{const z=T.data?.status;return z==="completed"||z==="partial"||z==="failed"||z==="cancelled"?!1:2e3},refetchIntervalInBackground:!0}).data?.status;if(C.useEffect(()=>{if(!e||!n||!v)return;if(v==="completed"||v==="partial"){h({flowVersion:ft,onboardingSessionId:u,event:"onboarding.step_completed",step:"run",method:"automatic"},"onboarding.step_completed:run"),om(n);return}if(v!=="failed"&&v!=="cancelled")return;const T=v==="cancelled"?"run_cancelled":"run_failed";h({flowVersion:ft,onboardingSessionId:u,event:"onboarding.blocked",step:"run",action:"retry_run",reasonCode:T},`onboarding.blocked:run:${T}`),om(n)},[h,n,u,e,v]),!e)return l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Project not found"}),l.jsx("p",{className:"page-subtitle",children:"This setup link does not identify a project."})]})}),l.jsx(le,{type:"button",variant:"secondary",onClick:()=>{i({to:"/projects"})},children:"View projects"})]});if(r.isPending)return l.jsxs("div",{className:"page-container max-w-3xl","aria-busy":"true","aria-live":"polite",children:[l.jsx(Ro,{current:"site"}),l.jsxs("div",{className:"mt-8 flex items-center gap-3 text-sm text-secondary",role:"status",children:[l.jsx(Ts,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading Site Health setup…"]})]});if(r.isError)return l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Can’t resume setup"}),l.jsx("p",{className:"page-subtitle",children:"Canonry could not load the project for this Site Health scan."})]})}),l.jsxs("div",{className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",children:[l.jsx("p",{className:"text-sm text-secondary",children:"Check the connection or sign in again, then retry."}),l.jsx(le,{type:"button",className:"mt-4",variant:"secondary",onClick:()=>{r.refetch()},children:"Retry project check"})]})]});const x=r.data.find(T=>T.name===e);if(!x)return l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Project not found"}),l.jsxs("p",{className:"page-subtitle",children:["Canonry could not find ",e,". It will not open a different project."]})]})}),l.jsx(le,{type:"button",variant:"secondary",onClick:()=>{i({to:"/projects"})},children:"View projects"})]});const S=()=>{i({to:"/setup",search:{onboarding:"site-health",setupProject:x.name},replace:!0})},k=()=>{i({to:"/setup",search:{experience:"legacy",onboarding:"site-health",setupProject:x.name},replace:!0})},N=()=>{h({flowVersion:ft,onboardingSessionId:u,event:"onboarding.step_completed",step:"run",method:"skipped"},"onboarding.step_completed:run"),i({to:"/setup",search:{onboarding:"complete",setupProject:x.name,skipped:"visibility"},replace:!0})};return l.jsxs("div",{className:"page-container max-w-7xl py-8 md:py-10",children:[l.jsx("h1",{className:"sr-only",children:"Set up Canonry"}),l.jsx(C.Suspense,{fallback:l.jsxs("div",{className:"space-y-5",children:[l.jsx(Ro,{current:"site"}),l.jsxs("div",{className:"flex min-h-72 items-center justify-center gap-3 text-sm text-secondary",role:"status",children:[l.jsx(Ts,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading Site Health…"]})]}),children:l.jsx(UW,{projectName:x.name,projectId:x.id,initialRunId:n,onReleaseInitialRun:S,showOnboardingActions:!0,onContinueOnboarding:k,onSkipOnboarding:N})})]})}function see(){const e=fk({from:"/setup"}),n=e.onboarding==="site-health"&&!e.setupProject,i=e.onboarding==="site-health"&&e.experience!=="legacy",r=HG(),u=e.experience==="legacy"?"legacy":e.experience==="platform"?"platform":r,[h,f]=C.useState(!1),[b,v]=C.useState(void 0),x=yt({...Bo({client:J}),enabled:u==="auto",retry:!1,refetchOnMount:"always"}),S=yt({...qc({client:J,query:{kind:Oe["site-audit"],since:QW,limit:FW}}),enabled:u==="auto",retry:!1,refetchOnMount:"always"}),k=u==="auto"&&x.isSuccess&&x.isFetchedAfterMount&&x.data.length===0;C.useEffect(()=>{k&&f(!0)},[k]);const N=u!=="auto"?{state:"idle"}:x.isSuccess&&x.isFetchedAfterMount?{state:"success",projectCount:x.data.length}:x.isError?{state:"error"}:{state:"loading"},T=u==="legacy"?"legacy":h||k?"platform":HW(u,N);if(e.onboarding==="complete"&&e.setupProject)return l.jsx(_W,{projectName:e.setupProject,skippedVisibility:e.skipped==="visibility"});if(n||i)return l.jsx(aee,{projectName:e.setupProject,initialRunId:e.siteHealthRunId});const z=u==="auto"&&T==="legacy"&&!e.setupProject&&x.isSuccess;if(z&&b===void 0)return S.isError?v(null):S.isSuccess&&S.isFetchedAfterMount&&v(ZW(x.data,S.data)),l.jsx($g,{});const q=z?b:null;return q?l.jsx(oee,{projectName:q.projectName,runId:q.runId}):T==="legacy"?l.jsx(jW,{visibilityProjectName:e.setupProject,siteHealthOnboarding:e.onboarding==="site-health",onboardingFinish:e.onboarding==="site-health"||e.onboarding==="first-run"}):T==="loading"?l.jsx($g,{}):T==="retry"?l.jsx(nee,{onRetry:()=>{x.refetch()}}):l.jsx(ree,{onActivationStarted:()=>f(!0),skipSiteScan:e.siteScan==="skip"})}function oee({projectName:e,runId:n}){const i=zs();return C.useEffect(()=>{i({to:"/setup",search:{onboarding:"site-health",setupProject:e,...n?{siteHealthRunId:n}:{}},replace:!0})},[i,e,n]),l.jsx($g,{})}function ree({onActivationStarted:e,skipSiteScan:n}){return l.jsx(M1,{title:"Site Health setup",children:l.jsx(lee,{onActivationStarted:e,skipSiteScan:n})})}function lee({onActivationStarted:e,skipSiteScan:n}){const i=zs(),r=Ds(),u=pW(),h=yt({...XQ({client:J}),retry:!1}),f=oi(JQ()),[b,v]=C.useState(""),[x,S]=C.useState(""),[k,N]=C.useState(""),[T,z]=C.useState("US"),[q,E]=C.useState("en"),[P,M]=C.useState(!1),[L,$]=C.useState("idle"),[F,ae]=C.useState(null),[V,Z]=C.useState(null),[X,Ce]=C.useState(!1),[tt,Ke]=C.useState(null),[Ue,ke]=C.useState(!1),Le=h.isError?void 0:h.data,B=typeof Le?.enabled=="boolean"?Le.enabled:null,W=f.isPending?f.variables.body.enabled:B,[ve,Ae]=C.useState(null),se=C.useRef(null),{onboardingSessionId:Se,emit:Me}=KC("platform");C.useEffect(()=>{Me({flowVersion:ft,onboardingSessionId:Se,event:"onboarding.started",step:"project",resumed:!1},"onboarding.started")},[Me,Se]);const xe=WW(b),pe=x||xe?.projectName||"",ce=k||xe?.displayName||"",ue=L==="creating"||L==="dispatching",_e=V??tt,Fe=YW(T,q),{countryValid:Ee,languageValid:Ct}=XW(T,q),me=Ee&&Ct;C.useEffect(()=>{_e&&se.current?.focus()},[_e]);const Be=(Ve,ct)=>i({to:"/setup",search:{...ct?{siteHealthRunId:ct}:{},onboarding:"site-health",setupProject:Ve.name},replace:!0}),Ne=async Ve=>{$("dispatching"),Ke(null);try{const ct=u.mutateAsync({projectName:Ve.name,projectId:Ve.id,projectLabel:Ve.displayName||Ve.name,suppressErrorToast:!0,body:{checkDeadLinks:!0,maxPages:T2}}),Qt=await eee(ct);if(Qt.state==="queued"){Me({flowVersion:ft,onboardingSessionId:Se,event:"run.requested",origin:"dashboard_setup",result:"queued",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0"}),yG(Qt.run.runId),await Be(Ve,Qt.run.runId);return}ct.then(()=>{Me({flowVersion:ft,onboardingSessionId:Se,event:"run.requested",origin:"dashboard_setup",result:"queued",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0"})},Ft=>{Me({flowVersion:ft,onboardingSessionId:Se,event:"run.requested",origin:"dashboard_setup",result:"rejected",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0",reasonCode:Ac(Ft,"run_rejected")})}),tee(ct,Ve.id),await Be(Ve)}catch(ct){$("recovery"),Ke(mk(ct,"The project was created, but the Site Health scan could not be started."));const Qt=Ac(ct,"run_rejected");Me({flowVersion:ft,onboardingSessionId:Se,event:"run.requested",origin:"dashboard_setup",result:"rejected",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0",reasonCode:Qt}),Me({flowVersion:ft,onboardingSessionId:Se,event:"onboarding.blocked",step:"run",action:"retry_run",reasonCode:Qt},`onboarding.blocked:run:${Qt}`)}},re=async Ve=>{if(Ve.preventDefault(),!(!xe||!n&&!P||!me||ue)){$("creating"),Z(null),Ce(!1),Ke(null);try{const ct=await mH({name:pe,displayName:ce,canonicalDomain:xe.canonicalDomain,country:T,language:q});if(e(),ae(ct),Me({flowVersion:ft,onboardingSessionId:Se,event:"onboarding.step_completed",step:"project",method:"manual"},"onboarding.step_completed:project"),await r.invalidateQueries({queryKey:$r({client:J})}),n){await i({to:"/setup",search:{experience:"legacy",onboarding:"first-run",setupProject:ct.name},replace:!0});return}await Ne(ct)}catch(ct){$("idle");const Qt=ct instanceof gn&&ct.statusCode===409;Ce(Qt),Z(mk(ct,"Could not create the project. Try again.")),Me({flowVersion:ft,onboardingSessionId:Se,event:"onboarding.blocked",step:"project",action:"save",reasonCode:Ac(ct,"project_create_failed")},"onboarding.blocked:project"),Qt&&(e(),r.invalidateQueries({queryKey:$r({client:J})}))}}},Ze=()=>{F&&!ue&&Ne(F)},bt=()=>{ue||i({to:"/projects"})},qn=async()=>{try{await navigator.clipboard.writeText(GW),ke(!0)}catch{bn({tone:"negative",title:"Could not copy setup request",detail:"Open the agent quickstart to continue with the CLI instead."})}},Ht=async Ve=>{Ae(null);try{const ct=await f.mutateAsync({client:J,body:{enabled:Ve}});r.setQueryData(WN({client:J}),ct),ct.enabled!==Ve&&Ae(`The server kept telemetry ${ct.enabled?"on":"off"}. Check its telemetry settings.`)}catch{Ae("Could not update telemetry. Try again.")}};return F&&L==="recovery"?l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx(Ro,{current:"site"}),l.jsx("div",{className:"page-header mt-8",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Project created"}),l.jsxs("p",{className:"page-subtitle",children:[F.displayName||F.name," is ready. The Site Health scan needs another try."]})]})}),l.jsxs("div",{ref:se,className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",tabIndex:-1,children:[l.jsx("p",{className:"text-sm font-medium text-heading",children:tt}),l.jsx("p",{className:"mt-1 text-sm text-secondary",children:"You can retry the scan or continue setup and retry from Site Health."}),l.jsxs("div",{className:"mt-4 flex flex-wrap gap-3",children:[l.jsx(le,{type:"button",onClick:Ze,children:"Retry Site Health scan"}),l.jsx(le,{type:"button",variant:"secondary",onClick:()=>{Be(F)},children:"Continue setup"})]})]})]}):l.jsxs("div",{className:"page-container max-w-xl py-8 md:py-12",children:[n?null:l.jsx(Ro,{current:"site"}),l.jsxs("header",{className:`mb-8 ${n?"":"mt-8"}`,children:[l.jsx("h1",{id:"site-map-setup-title",className:"text-2xl font-semibold tracking-[-0.025em] text-heading",children:n?"Create a project":"Scan your site"}),l.jsx("p",{className:"mt-2 max-w-lg text-sm leading-6 text-secondary",children:n?"Add a public domain, then choose the queries you want to track. No site scan will run.":"Enter your public website to see its pages, structure, internal links, and technical SEO scores."})]}),l.jsxs("form",{"aria-labelledby":"site-map-setup-title",className:"space-y-6",onSubmit:fn(re),noValidate:!0,children:[l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm font-medium text-heading",htmlFor:"launchpad-domain",children:"Website URL"}),l.jsx("input",{id:"launchpad-domain",className:"h-11 w-full rounded-md border border-strong bg-bg-elevated/50 px-3 text-base text-heading outline-none transition placeholder:text-muted focus:border-mono-500 focus:ring-1 focus:ring-mono-500",type:"text",inputMode:"url",autoComplete:"url",autoCapitalize:"none",spellCheck:!1,required:!0,"aria-invalid":!!(b&&!xe),"aria-describedby":b&&!xe?"launchpad-domain-hint launchpad-domain-error":"launchpad-domain-hint",placeholder:"https://example.com",value:b,onChange:Ve=>{v(Ve.target.value),Z(null),Ce(!1)}}),l.jsx("p",{id:"launchpad-domain-hint",className:"text-sm text-secondary",children:n?l.jsxs(l.Fragment,{children:["A public domain is still required."," ",l.jsx(at,{to:"/setup",search:{experience:"platform"},className:"font-medium text-link underline-offset-4 hover:underline",children:"Map with Site Health instead"})]}):l.jsxs(l.Fragment,{children:["Only public pages are scanned."," ",l.jsx(at,{to:"/setup",search:{experience:"platform",onboarding:"first-run",siteScan:"skip"},className:"font-medium text-link underline-offset-4 hover:underline",children:"Set up without a site scan"})]})}),b&&!xe?l.jsx("p",{id:"launchpad-domain-error",className:"text-sm text-negative",role:"alert",children:"Enter a public domain, such as example.com."}):null]}),l.jsxs("details",{className:"group border-y border-default",children:[l.jsxs("summary",{className:"flex min-h-11 cursor-pointer list-none items-center justify-between gap-4 py-3 text-sm [&::-webkit-details-marker]:hidden",children:[l.jsx("span",{className:"font-medium text-heading",children:"Project name and locale"}),l.jsxs("span",{className:"flex items-center gap-2 text-secondary",children:[Fe,l.jsx(Lc,{className:"size-4 transition-transform group-open:rotate-180 motion-reduce:transition-none","aria-hidden":"true"})]})]}),l.jsxs("div",{className:"space-y-5 border-t border-default py-4",children:[xe?l.jsxs("div",{children:[l.jsx("p",{className:"mb-3 text-sm font-medium text-heading",children:"Project"}),l.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-project-name",children:"Project name"}),l.jsx("input",{id:"launchpad-project-name",className:"setup-input h-10",type:"text",value:pe,onChange:Ve=>S(Ve.target.value)})]}),l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-display-name",children:"Display name"}),l.jsx("input",{id:"launchpad-display-name",className:"setup-input h-10",type:"text",value:ce,onChange:Ve=>N(Ve.target.value)})]})]})]}):null,l.jsxs("div",{children:[l.jsx("p",{className:"mb-3 text-sm font-medium text-heading",children:"Locale"}),l.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-country",children:"Country"}),l.jsx("select",{id:"launchpad-country",className:"setup-input h-10",value:T,onChange:Ve=>z(Ve.target.value),children:VC.map(Ve=>l.jsx("option",{value:Ve.value,children:Ve.label},Ve.value))})]}),l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-language",children:"Language"}),l.jsx("select",{id:"launchpad-language",className:"setup-input h-10",value:q,onChange:Ve=>E(Ve.target.value),children:$C.map(Ve=>l.jsx("option",{value:Ve.value,children:Ve.label},Ve.value))})]})]})]})]})]}),n?null:l.jsxs("label",{className:"flex min-h-11 cursor-pointer items-start gap-3 py-2",children:[l.jsx("input",{className:"mt-0.5 size-4 shrink-0 rounded border-strong bg-bg",type:"checkbox",checked:P,onChange:Ve=>M(Ve.target.checked),"aria-label":"Allow Canonry to scan this public site."}),l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"text-sm leading-5 text-heading",children:"Allow Canonry to scan this public site."}),l.jsx(ua,{text:VW})]})]}),_e?l.jsxs("div",{ref:se,className:"rounded-md border border-negative bg-negative-soft p-3",role:"alert",tabIndex:-1,children:[l.jsx("p",{className:"text-sm font-medium text-heading",children:_e}),X?l.jsx(le,{type:"button",variant:"secondary",size:"sm",className:"mt-3",onClick:bt,children:"View projects"}):null]}):null,l.jsxs("div",{className:"grid gap-2",children:[l.jsx(le,{className:"h-11 w-full",type:"submit",disabled:!xe||!n&&!P||!me||ue,children:L==="creating"||L==="dispatching"?l.jsxs(l.Fragment,{children:[l.jsx(Ts,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"})," ",n?"Creating project…":"Mapping site…"]}):n?"Create project":"Scan site"}),L==="dispatching"?l.jsx("span",{className:"text-center text-sm text-secondary",role:"status",children:"Opening Site Health when the scan is ready."}):null]})]}),l.jsxs("section",{className:"mt-8 border-t border-default pt-6","aria-labelledby":"agent-setup-title",children:[l.jsx("p",{id:"agent-setup-title",className:"text-sm font-medium text-heading",children:"Use your agent instead"}),l.jsx("p",{className:"mt-1 text-sm leading-5 text-secondary",children:"Copy a complete CLI setup request into any agent."}),l.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-1",children:[l.jsxs(le,{type:"button",variant:"ghost",size:"sm",className:"-ml-3",onClick:fn(qn),children:[Ue?l.jsx(Uc,{className:"size-3.5","aria-hidden":"true"}):l.jsx(Zg,{className:"size-3.5","aria-hidden":"true"}),l.jsx("span",{"aria-live":"polite",children:Ue?"Copied setup request":"Copy setup request"})]}),l.jsx(le,{asChild:!0,variant:"ghost",size:"sm",children:l.jsxs("a",{href:KW,target:"_blank",rel:"noopener noreferrer",children:["Agent quickstart",l.jsx(k6,{className:"size-3.5","aria-hidden":"true"}),l.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]})})]})]}),B!==null?l.jsxs("section",{className:"mt-6 border-t border-default pt-5","aria-labelledby":"telemetry-title",children:[l.jsxs("label",{className:`flex min-h-11 items-start gap-3 py-2 ${f.isPending?"cursor-wait":"cursor-pointer"}`,children:[l.jsx("input",{className:"mt-0.5 size-4 shrink-0 rounded border-strong bg-bg accent-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-mono-500 disabled:cursor-wait",type:"checkbox",checked:W??!1,disabled:f.isPending,onChange:Ve=>{Ht(Ve.target.checked)},"aria-describedby":"telemetry-detail"}),l.jsxs("span",{className:"grid gap-0.5",children:[l.jsx("span",{id:"telemetry-title",className:"text-sm leading-5 text-heading",children:"Share anonymous product telemetry"}),l.jsx("span",{id:"telemetry-detail",className:"max-w-[70ch] text-sm leading-5 text-secondary",children:"Helps prioritize improvements. Canonry does not send raw domains, URLs, queries, answer content, or credentials."})]})]}),f.isPending?l.jsx("p",{className:"mt-1 text-sm text-secondary",role:"status",children:"Saving preference…"}):null,ve?l.jsx("p",{className:"mt-1 text-sm text-negative",role:"alert",children:ve}):null]}):null]})}function cee(){return l.jsx("div",{className:"page-container",children:l.jsx("section",{className:"page-section",children:l.jsxs(_a,{className:"surface-card empty-card",children:[l.jsx("h1",{children:"Route not found"}),l.jsx("p",{children:"The current path does not map to a dashboard view."}),l.jsx(le,{asChild:!0,children:l.jsx(at,{to:"/",children:"Return to overview"})})]})})})}const Ia=Is(()=>Qi(()=>import("./ProjectPage-NI-bjpfN.js"),__vite__mapDeps([5,1,0,2,3,4,6,7,8,9,10,11,12]),import.meta.url),"ProjectPage"),uee=Is(()=>Qi(()=>import("./RunsPage-GIKqPu0J.js"),__vite__mapDeps([13,1,11,4,2,7,12]),import.meta.url),"RunsPage"),dee=Is(()=>Qi(()=>import("./HistoryPage-DEEC3g6M.js"),__vite__mapDeps([14,1,10,11,4,2,7,12]),import.meta.url),"HistoryPage"),mee=Is(()=>Qi(()=>import("./SettingsPage-DLFwSj4J.js"),__vite__mapDeps([15,1,11,4,2,7,12]),import.meta.url),"SettingsPage"),pee=Is(()=>Qi(()=>import("./BacklinksPage-TnDsI9Wu.js"),__vite__mapDeps([16,1,9,2,11,4,7,12]),import.meta.url),"BacklinksPage"),hee=Is(()=>Qi(()=>import("./TrafficPage-oOxDmxQq.js"),__vite__mapDeps([17,1,8,2,11,4,7,12]),import.meta.url),"TrafficPage"),fee=Is(()=>Qi(()=>import("./TrafficSourceDetailPage-BGrwpVvM.js"),__vite__mapDeps([18,1,8,3,4,2,11,7,12]),import.meta.url),"TrafficSourceDetailPage"),gee=Is(()=>Qi(()=>import("./MeasurementPropertyPage-MT4tFOwx.js"),__vite__mapDeps([19,1,3,4,6,7,2,11,12]),import.meta.url),"MeasurementPropertyPage");function yee(){return l.jsx(wJ,{children:l.jsx(iQ,{children:l.jsx(xJ,{})})})}const Un=t6()({component:yee,validateSearch:e=>({manageQueries:e.manageQueries===!0||e.manageQueries==="true"?!0:void 0,runId:typeof e.runId=="string"?e.runId:void 0,siteHealthRunId:typeof e.siteHealthRunId=="string"?e.siteHealthRunId:void 0,evidenceId:typeof e.evidenceId=="string"?e.evidenceId:void 0,runStatus:typeof e.runStatus=="string"?e.runStatus:void 0,runKind:typeof e.runKind=="string"?e.runKind:void 0,runProject:typeof e.runProject=="string"?e.runProject:void 0,runWindow:typeof e.runWindow=="string"?e.runWindow:void 0,runQuery:typeof e.runQuery=="string"?e.runQuery:void 0,onboarding:e.onboarding==="site-health"||e.onboarding==="first-run"||e.onboarding==="complete"?e.onboarding:void 0,experience:e.experience==="legacy"||e.experience==="platform"?e.experience:void 0,siteScan:e.siteScan==="skip"?"skip":void 0,skipped:e.skipped==="visibility"?"visibility":void 0,setupProject:typeof e.setupProject=="string"?e.setupProject:void 0,scope:typeof e.scope=="string"?e.scope:void 0,class:typeof e.class=="string"?e.class:void 0,...Object.fromEntries(["queryWorkspace","researchMode","trackingQueryId","measurementScope","measurementScopeKey","measurementMarketKey","queryClass","measurementProvider","measurementModel","measurementLocation","measurementFrom","measurementTo","measurementRevision","measurementRunId","measurementQueryKey","measurementAnswer"].map(n=>[n,typeof e[n]=="string"?e[n]:void 0]))})}),bee=Bt({getParentRoute:()=>Un,path:"/",component:nW,beforeLoad:async({context:e})=>{let n=e.queryClient.getQueryData($r({client:J}));if(n===void 0)try{n=await e.queryClient.ensureQueryData(Bo({client:J}))}catch{return}if(n.length===0)throw Kg({to:"/setup"})}}),vee=Bt({getParentRoute:()=>Un,path:"/projects",component:oW}),xee=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Vn=Bt({getParentRoute:()=>Un,path:"/projects/$projectName",component:()=>l.jsx(Xf,{}),beforeLoad:async({context:e,params:n,location:i})=>{const r=n.projectName;if(!xee.test(r))return;let u=e.queryClient.getQueryData($r({client:J}));if(!u)try{u=await e.queryClient.ensureQueryData(Bo({client:J}))}catch{return}const h=u.find(f=>f.id===r);if(h)throw Kg({to:i.pathname.replace(`/projects/${r}`,`/projects/${encodeURIComponent(h.name)}`),replace:!0})}}),wee=Bt({getParentRoute:()=>Vn,path:"/",component:()=>l.jsx(Ia,{tab:"overview"})}),See=Bt({getParentRoute:()=>Vn,path:"/portfolio",component:()=>l.jsx(Ia,{tab:"portfolio"})}),kee=Bt({getParentRoute:()=>Vn,path:"/search-console",component:()=>l.jsx(Ia,{tab:"search-console"})}),jee=Bt({getParentRoute:()=>Vn,path:"/conversions",component:()=>l.jsx(Ia,{tab:"conversions"})}),Aee=Bt({getParentRoute:()=>Vn,path:"/local",component:()=>l.jsx(Ia,{tab:"local"})}),Nee=Bt({getParentRoute:()=>Vn,path:"/discovery",component:()=>l.jsx(Ia,{tab:"discovery"})}),Cee=Bt({getParentRoute:()=>Vn,path:"/queries",component:()=>l.jsx(Ia,{tab:"queries"})}),_ee=Bt({getParentRoute:()=>Vn,path:"/properties/$targetKey",component:()=>l.jsx(gee,{})}),Tee=Bt({getParentRoute:()=>Vn,path:"/report",beforeLoad:({params:e})=>{throw Kg({to:"/projects/$projectName",params:e,replace:!0})}}),Eee=Bt({getParentRoute:()=>Vn,path:"/activity",component:()=>l.jsx(Ia,{tab:"activity"})}),Ree=Bt({getParentRoute:()=>Vn,path:"/backlinks",component:()=>l.jsx(Ia,{tab:"backlinks"})}),Dee=Bt({getParentRoute:()=>Vn,path:"/technical-aeo",component:()=>l.jsx(Ia,{tab:"technical-aeo"})}),zee=Bt({getParentRoute:()=>Vn,path:"/history",component:()=>l.jsx(Ia,{tab:"history"})}),Iee=Bt({getParentRoute:()=>Vn,path:"/settings",component:()=>l.jsx(Ia,{tab:"settings"})}),Oee=Bt({getParentRoute:()=>Un,path:"/runs",component:uee}),Pee=Bt({getParentRoute:()=>Un,path:"/history",component:dee}),qee=Bt({getParentRoute:()=>Un,path:"/settings",component:mee,beforeLoad:({context:e})=>{}}),Mee=Bt({getParentRoute:()=>Un,path:"/setup",component:see}),Bee=Bt({getParentRoute:()=>Un,path:"/backlinks",component:pee}),Lee=Bt({getParentRoute:()=>Un,path:"/traffic",component:hee}),Uee=Bt({getParentRoute:()=>Un,path:"/traffic/$projectName/$sourceId",component:fee}),Vee=Bt({getParentRoute:()=>Un,path:"*",component:cee}),$ee=Un.addChildren([bee,vee,Vn.addChildren([wee,See,kee,jee,Aee,Nee,Cee,_ee,Tee,Eee,Ree,Dee,zee,Iee]),Oee,Pee,qee,Mee,Bee,Lee,Uee,Vee]);function Kee(){return typeof window<"u"&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath:"/"}const pk=Kee(),Gee=pk==="/"?"":pk.replace(/\/$/,"");function Hee(e,n){return n6({routeTree:$ee,basepath:Gee||"/",context:{queryClient:e},...n?.initialEntries})}let hk=!1;async function Qee(e){return(await lT({client:J,body:e,keepalive:!0})).data}function Fee(){hk||typeof window>"u"||(hk=!0,!(Gm()||jo())&&(NG({send:Qee}),J.interceptors.request.use((e,n)=>{const i=n.fetch??globalThis.fetch,r=typeof n.url=="string"?n.url:void 0;return n.fetch=async(u,h)=>{try{return await i(u,h)}catch(f){throw f instanceof DOMException&&f.name==="AbortError"||cm({method:e.method,route:r,network:!0}),f}},e}),J.interceptors.response.use((e,n,i)=>(cm({method:n.method,route:typeof i.url=="string"?i.url:void 0,path:Yee(n.url),status:e.status}),e)),window.addEventListener("error",e=>{lm({kind:"unhandled",error:e.error})}),window.addEventListener("unhandledrejection",e=>{lm({kind:"unhandled",error:e.reason})}),tte()))}function Zee(e){let n=null;const i=()=>{const r=e.state.matches.at(-1);if(!r)return;CG(r.fullPath);const u=e.state.location;if(!u)return;const h=u.search&&typeof u.search=="object"?u.search:{};n&&n.pathname===u.pathname&&DG(n.search,h),n={pathname:u.pathname,search:h}};return i(),e.subscribe("onResolved",i)}function Yee(e){try{return new URL(e,window.location.origin).pathname}catch{return}}const Xee={LCP:[2500,4e3],INP:[200,500],CLS:[.1,.25],FCP:[1800,3e3],TTFB:[800,1800]};function Jee(e,n){const[i,r]=Xee[e];return n<=i?"good":n<=r?"needs-improvement":"poor"}function Wee(){let e=0,n=0,i=-1/0,r=-1/0;return{add(u){u.hadRecentInput||(u.startTime-r<1e3&&u.startTime-i<5e3?n+=u.value:(n=u.value,i=u.startTime),r=u.startTime,e=Math.max(e,n))},value:()=>e}}function ete(){let e=0;return{add(n){n.interactionId&&(e=Math.max(e,n.duration))},value:()=>e}}function tte(){if(typeof PerformanceObserver>"u")return;const e=new Set,n=(b,v)=>{e.has(b)||!Number.isFinite(v)||(e.add(b),IG(b,Jee(b,v)))},i=(b,v,x={})=>{try{new PerformanceObserver(S=>v(S.getEntries())).observe({type:b,buffered:!0,...x})}catch{}};try{const b=performance.getEntriesByType("navigation")[0];b&&b.responseStart>0&&n("TTFB",b.responseStart)}catch{}i("paint",b=>{const v=b.find(x=>x.name==="first-contentful-paint");v&&n("FCP",v.startTime)});let r=0;i("largest-contentful-paint",b=>{const v=b.at(-1);v&&(r=v.startTime)});const u=Wee();i("layout-shift",b=>{for(const v of b)u.add({startTime:v.startTime,value:v.value??0,hadRecentInput:v.hadRecentInput===!0})});const h=ete();i("event",b=>{for(const v of b)h.add(v)},{durationThreshold:40});const f=()=>{r>0&&n("LCP",r),n("CLS",u.value()),h.value()>0&&n("INP",h.value())};document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&f()}),window.addEventListener("pagehide",f)}const nte=6e4,ate="Anyone with this password can sign in to this dashboard.",_r={label:"Root API key",help:"To create the password from here, enter the root API key (apiKey in config.yaml). It is used once and not saved.",missing:"Enter the root API key.",rejected:"That is not the root API key for this install.",show:"Show passwords and key"};function ite(){const e=C.useRef(cH()).current,[n,i]=C.useState(e?"ready":"checking"),[r,u]=C.useState(null),[h,f]=C.useState(null),[b,v]=C.useState(e),[x,S]=C.useState(!1),[k,N]=C.useState(""),[T,z]=C.useState(""),[q,E]=C.useState(""),[P,M]=C.useState(!1),[L,$]=C.useState("password"),[F,ae]=C.useState(!1),[V,Z]=C.useState(""),[X,Ce]=C.useState(null),[tt,Ke]=C.useState(!1),[Ue,ke]=C.useState(!1),Le=C.useRef(null),B=C.useRef(null),W=C.useRef(null),ve=()=>{const me=r?`${r.name}:${r.role}`:e?"api-key:explicit":h?`api-key:${h.id}`:"no-accounts";if(!Le.current||W.current!==me){B.current?.clear();const Be=tQ();B.current=Be,Le.current=Hee(Be),Zee(Le.current),W.current=me}return{queryClient:B.current,router:Le.current}},Ae=me=>me.authRequired?(S(!0),u(me.user),f(null),v(!1),i(me.user?"ready":"account-login"),!0):!1;C.useEffect(()=>{let me=!1;const Be=async(Ne,re=!1)=>{try{const Ze=await Uf();if(me)return;f(Ze),v(!1),i("ready")}catch(Ze){if(me)return;if(re&&Ze instanceof gn&&Ze.statusCode===401)return xH().then(()=>{me||(Ce(null),f(null),v(!1),ke(!0),i("login"))}).catch(bt=>{me||(Ce(bt instanceof Error?bt.message:"Could not clear the invalid session"),i(Ne))});Ce(Ze instanceof Error?Ze.message:"Could not verify API key access"),i(Ne)}};return e?(Be("api-key-error"),()=>{me=!0}):(Promise.allSettled([hS(),pS()]).then(([Ne,re])=>{if(me||Ne.status==="fulfilled"&&Ae(Ne.value))return;if(re.status==="rejected"){const bt=re.reason;Ce(bt instanceof Error?bt.message:"Failed to reach the Canonry API"),i("login");return}const Ze=re.value;Ze.authenticated?(v(!0),Be("api-key-error",!0)):(f(null),v(!1),i(Ze.setupRequired?"setup":"login"))}),()=>{me=!0})},[]),C.useEffect(()=>{if(n!=="ready"||e)return;const me=setInterval(()=>{if(x){hS().then(Be=>{Be.authRequired&&!Be.user&&(ke(!0),u(null),f(null),i("account-login"))}).catch(()=>{});return}pS().then(Be=>{Be.authenticated||(ke(!0),f(null),i(Be.setupRequired?"setup":"login"))}).catch(()=>{})},nte);return mS(()=>{ke(!0),u(null),f(null),v(!1),i(x?"account-login":"login")}),()=>{clearInterval(me),mS(null)}},[n,x,e]);const se=async me=>{if(me.preventDefault(),!T.trim()||T.trim().length<8){Ce("Password must be at least 8 characters");return}if(T!==q){Ce("Passwords do not match");return}const Be=V.trim();if(F&&!Be){Ce(_r.missing);return}Ke(!0),Ce(null);try{if(!(await yH(T.trim(),F?Be:void 0)).authenticated){Ce("Setup failed");return}z(""),E(""),Z(""),ae(!1),M(!1),ke(!1),f(null),v(!0),i("checking");try{const re=await Uf();f(re),v(!1),i("ready")}catch(re){Ce(re instanceof Error?re.message:"Could not verify API key access"),i("api-key-error")}}catch(Ne){if(Ne instanceof gn&&Ne.statusCode===401&&Ne.code==="AUTH_REQUIRED"){Ce(F?_r.rejected:null),ae(!0);return}Ce(Ne instanceof gn||Ne instanceof Error?Ne.message:"Setup failed")}finally{Ke(!1)}},Se=me=>{z(me),Ce(null)},Me=me=>{Z(me),Ce(null)},xe=me=>{E(me),Ce(null)},pe=async me=>{if(me.preventDefault(),!!T.trim()){Ke(!0),Ce(null);try{if(!(L==="api-key"?await vH(T.trim()):await bH(T.trim())).authenticated){Ce(L==="api-key"?"Invalid API key":"Incorrect password");return}const Ne=await Uf();f(Ne),v(!1),z(""),M(!1),ke(!1),i("ready")}catch(Be){Ce(Be instanceof gn||Be instanceof Error?Be.message:"Authentication failed")}finally{Ke(!1)}}},ce=me=>{$(me),z(""),M(!1),Ce(null)},ue=async me=>{if(me.preventDefault(),!(!k.trim()||!T)){Ke(!0),Ce(null);try{const Be=await wH(k.trim(),T);if(!Be.user){Ce("Incorrect name or password.");return}z(""),ke(!1),u(Be.user),f(null),v(!1),i("ready")}catch(Be){Ce(Be instanceof gn?Be.message:"Incorrect name or password.")}finally{Ke(!1)}}};if(n==="ready"){const{queryClient:me,router:Be}=ve();return l.jsx($H,{account:r,apiKey:h,apiKeyPending:b,children:l.jsx(a6,{client:me,children:l.jsx(i6,{router:Be})})})}const _e=T.trim(),Fe=T.length>0&&_e.length<8,Ee=q.length>0&&T!==q,Ct=_e.length>=8&&T===q&&(!F||V.trim().length>0);return l.jsx("div",{className:"min-h-screen bg-bg px-4 py-8",children:l.jsxs("div",{className:"mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col items-center justify-center gap-5",children:[l.jsxs("div",{"data-testid":"auth-brand",className:"flex items-center gap-2.5",children:[l.jsx("img",{className:"size-7",src:"./favicon.svg",alt:"","aria-hidden":"true"}),l.jsx("span",{className:"text-lg font-semibold tracking-tight text-heading",children:"Canonry"})]}),l.jsx(_a,{className:"surface-card w-full",children:n==="checking"?l.jsx(vo,{className:"py-8",children:l.jsx("p",{className:"supporting-copy text-center",children:"Connecting to Canonry…"})}):n==="api-key-error"?l.jsxs(l.Fragment,{children:[l.jsxs(zr,{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),l.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Could not verify API key access"})]}),l.jsxs(vo,{className:"space-y-4",children:[l.jsx("p",{className:"supporting-copy",children:X??"Canonry could not verify this session’s access, so the dashboard stayed locked."}),l.jsx(le,{type:"button",className:"w-full",onClick:()=>{window.location.reload()},children:"Try again"})]})]}):n==="account-login"?l.jsxs(l.Fragment,{children:[l.jsxs(zr,{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),l.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Sign in to Canonry"})]}),l.jsxs(vo,{children:[Ue?l.jsx("p",{className:"mb-4 rounded-md border border-caution bg-caution-soft px-3 py-2 text-sm text-caution",children:"You were signed out — please sign in again."}):null,l.jsxs("form",{className:"space-y-4",onSubmit:fn(ue),children:[l.jsxs("label",{className:"block space-y-1.5",htmlFor:"account-name",children:[l.jsx("span",{className:"text-xs font-medium text-secondary",children:"Name"}),l.jsx("input",{autoFocus:!0,id:"account-name",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"text",name:"username",autoComplete:"username",value:k,onChange:me=>{N(me.target.value),Ce(null)},"aria-invalid":!!X,"aria-describedby":X?"account-login-error":void 0})]}),l.jsxs("label",{className:"block space-y-1.5",htmlFor:"account-password",children:[l.jsx("span",{className:"text-xs font-medium text-secondary",children:"Password"}),l.jsx("input",{id:"account-password",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"password",name:"password",autoComplete:"current-password",value:T,onChange:me=>Se(me.target.value),"aria-invalid":!!X,"aria-describedby":X?"account-login-error":void 0})]}),X?l.jsx("p",{id:"account-login-error",role:"alert",className:"text-sm text-negative-400",children:X}):null,l.jsx(le,{type:"submit",disabled:tt||!k.trim()||!T,children:tt?"Signing in…":"Sign in"})]})]})]}):n==="setup"?l.jsxs(l.Fragment,{children:[l.jsxs(zr,{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"First-time setup"}),l.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Create a dashboard password"}),l.jsx(fm,{children:ate})]}),l.jsx(vo,{children:l.jsxs("form",{className:"space-y-4",onSubmit:fn(se),children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("label",{className:"block text-xs font-medium text-secondary",htmlFor:"dashboard-password-new",children:"Password"}),l.jsx("input",{autoFocus:!0,id:"dashboard-password-new",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:P?"text":"password",name:"new-password",autoComplete:"new-password",minLength:8,required:!0,value:T,onChange:me=>Se(me.target.value),"aria-invalid":Fe,"aria-describedby":"dashboard-password-new-help"}),l.jsx("span",{id:"dashboard-password-new-help","aria-live":"polite",className:Fe?"block text-sm text-negative-400":"block text-sm text-secondary",children:Fe?"Enter at least 8 characters.":"Use at least 8 characters."})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("label",{className:"block text-xs font-medium text-secondary",htmlFor:"dashboard-password-confirm",children:"Confirm password"}),l.jsx("input",{id:"dashboard-password-confirm",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:P?"text":"password",name:"confirm-password",autoComplete:"new-password",minLength:8,required:!0,value:q,onChange:me=>xe(me.target.value),"aria-invalid":Ee,"aria-describedby":"dashboard-password-confirm-help"}),l.jsx("span",{id:"dashboard-password-confirm-help","aria-live":"polite",className:Ee?"block text-sm text-negative-400":"block text-sm text-secondary",children:Ee?"Passwords do not match.":"Enter the same password again."})]}),F?l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("label",{className:"block text-xs font-medium text-secondary",htmlFor:"dashboard-setup-root-key",children:_r.label}),l.jsx("input",{autoFocus:!0,id:"dashboard-setup-root-key",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:P?"text":"password",name:"apiKey",autoComplete:"off",spellCheck:!1,required:!0,value:V,onChange:me=>Me(me.target.value),"aria-invalid":X===_r.rejected,"aria-describedby":"dashboard-setup-root-key-help"}),l.jsx("span",{id:"dashboard-setup-root-key-help","aria-live":"polite",className:"block text-sm text-secondary",children:_r.help})]}):null,l.jsxs("label",{className:"flex min-h-10 cursor-pointer items-center gap-2 text-sm text-secondary",htmlFor:"dashboard-password-show",children:[l.jsx("input",{id:"dashboard-password-show",type:"checkbox",checked:P,onChange:me=>M(me.target.checked)}),F?_r.show:"Show passwords"]}),X?l.jsx("p",{id:"dashboard-password-setup-error",role:"alert",className:"text-sm text-negative-400",children:X}):null,l.jsx(le,{type:"submit",disabled:tt||!Ct,children:tt?"Creating password…":"Create password and continue"})]})})]}):l.jsxs(l.Fragment,{children:[l.jsxs(zr,{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),l.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Sign in to Canonry"}),l.jsx(fm,{children:L==="api-key"?"Enter an API key from this Canonry install. This opens the dashboard with that key’s access and does not change the password.":"Enter your dashboard password to continue."})]}),l.jsxs(vo,{children:[Ue?l.jsx("p",{className:"mb-4 rounded-md border border-caution bg-caution-soft px-3 py-2 text-sm text-caution",children:"Your session expired — please sign in again."}):null,l.jsxs("form",{className:"space-y-4",onSubmit:fn(pe),children:[l.jsxs("label",{className:"block space-y-1.5",htmlFor:"dashboard-password-current",children:[l.jsx("span",{className:"text-xs font-medium text-secondary",children:L==="api-key"?"Canonry API key":"Password"}),l.jsx("input",{autoFocus:!0,id:"dashboard-password-current",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:P?"text":"password",name:L==="api-key"?"apiKey":"password",autoComplete:L==="api-key"?"off":"current-password",spellCheck:!1,required:!0,value:T,onChange:me=>Se(me.target.value),"aria-invalid":!!X,"aria-describedby":X?"dashboard-password-login-error":void 0})]}),l.jsxs("label",{className:"flex min-h-10 cursor-pointer items-center gap-2 text-sm text-secondary",htmlFor:"dashboard-login-password-show",children:[l.jsx("input",{id:"dashboard-login-password-show",type:"checkbox",checked:P,onChange:me=>M(me.target.checked)}),L==="api-key"?"Show API key":"Show password"]}),X?l.jsx("p",{id:"dashboard-password-login-error",role:"alert",className:"text-sm text-negative-400",children:X}):null,l.jsx(le,{type:"submit",disabled:tt||!T.trim(),children:tt?"Signing in…":"Open dashboard"}),l.jsx(le,{type:"button",variant:"ghost",onClick:()=>ce(L==="api-key"?"password":"api-key"),children:L==="api-key"?"Use dashboard password instead":"Forgot password? Use API key"})]})]})]})})]})})}const GC=document.getElementById("root");if(!GC)throw new Error("Expected #root element for web app bootstrap.");Fee();R6.createRoot(GC).render(l.jsx(C.StrictMode,{children:l.jsx(ite,{})}));export{xY as $,jo as A,le as B,Sc as C,On as D,fn as E,ese as F,ase as G,nse as H,ua as I,tae as J,aae as K,nne as L,Nse as M,Wie as N,ane as O,Yte as P,tne as Q,Ga as R,sk as S,wn as T,sne as U,nae as V,ine as W,fa as X,oQ as Y,Vse as Z,$se as _,Ase as a,Jte as a$,pQ as a0,Xte as a1,Nae as a2,Rae as a3,Cne as a4,jae as a5,Eie as a6,zie as a7,Die as a8,Pne as a9,Lie as aA,Lg as aB,S9 as aC,k9 as aD,zte as aE,Dte as aF,mae as aG,bae as aH,vae as aI,gn as aJ,xae as aK,bne as aL,rQ as aM,vZ as aN,jg as aO,wae as aP,Bd as aQ,sse as aR,Pg as aS,bo as aT,uQ as aU,Nt as aV,JH as aW,Kae as aX,wX as aY,Bne as aZ,ene as a_,One as aa,Hne as ab,bn as ac,Pie as ad,qie as ae,Une as af,Mie as ag,Vne as ah,Mne as ai,Lne as aj,Iie as ak,Oie as al,Rie as am,qne as an,Bie as ao,Hie as ap,Vie as aq,Kie as ar,$ie as as,Gie as at,cae as au,E1 as av,Oe as aw,Uie as ax,aC as ay,Gi as az,Eae as b,eae as b$,qi as b0,qse as b1,Fte as b2,fne as b3,yq as b4,mne as b5,Qte as b6,Tae as b7,Hte as b8,kQ as b9,rie as bA,cie as bB,yie as bC,Cie as bD,Nie as bE,fie as bF,jie as bG,Tie as bH,die as bI,vie as bJ,xie as bK,wie as bL,uie as bM,bie as bN,mie as bO,Sie as bP,pie as bQ,kie as bR,gie as bS,Aie as bT,_ie as bU,lW as bV,hie as bW,pne as bX,Ane as bY,jne as bZ,kne as b_,QQ as ba,Yae as bb,tie as bc,Xae as bd,lne as be,une as bf,C$ as bg,dne as bh,OQ as bi,Zae as bj,T$ as bk,Sg as bl,cne as bm,eH as bn,Jae as bo,Fae as bp,qQ as bq,Wae as br,Sae as bs,eie as bt,use as bu,dse as bv,$ne as bw,JN as bx,ise as by,XN as bz,Rte as c,Ise as c$,WG as c0,_2 as c1,Dm as c2,T2 as c3,_s as c4,iie as c5,Ite as c6,YQ as c7,lie as c8,Iae as c9,vW as cA,Kse as cB,Rse as cC,bX as cD,Ese as cE,mW as cF,nie as cG,Mae as cH,Tse as cI,$ae as cJ,Bae as cK,Y9 as cL,VP as cM,aie as cN,_se as cO,Uae as cP,Sse as cQ,CX as cR,dH as cS,gQ as cT,_X as cU,xne as cV,wne as cW,vne as cX,hH as cY,Dse as cZ,zse as c_,Wte as ca,wS as cb,Tne as cc,Ene as cd,Dae as ce,zae as cf,Rne as cg,Dne as ch,Ine as ci,zne as cj,su as ck,Bo as cl,MN as cm,qae as cn,Pae as co,sX as cp,Dg as cq,mm as cr,zg as cs,pm as ct,hm as cu,xX as cv,CQ as cw,xo as cx,gm as cy,eF as cz,mQ as d,r9 as d$,Pse as d0,Sne as d1,SQ as d2,Nne as d3,fY as d4,Qie as d5,AH as d6,Xne as d7,Zie as d8,Yie as d9,Kr as dA,kS as dB,uae as dC,pae as dD,fae as dE,gae as dF,dae as dG,hae as dH,yae as dI,Mf as dJ,lae as dK,lse as dL,iW as dM,rne as dN,h1 as dO,Oae as dP,ose as dQ,cse as dR,rae as dS,one as dT,sae as dU,oae as dV,iae as dW,rse as dX,Gte as dY,o9 as dZ,Ra as d_,Xie as da,Fie as db,Cae as dc,Qne as dd,Fne as de,Zne as df,Jne as dg,Yne as dh,z1 as di,qc as dj,Use as dk,iu as dl,sie as dm,oie as dn,iH as dp,gne as dq,yne as dr,_ne as ds,Kne as dt,Gne as du,M1 as dv,Ym as dw,I1 as dx,bW as dy,Wne as dz,dQ as e,Vte as e$,EP as e0,Lae as e1,Aae as e2,bO as e3,Gae as e4,Vae as e5,Qae as e6,Hae as e7,IS as e8,ye as e9,Qi as eA,za as eB,qte as eC,lm as eD,hne as eE,QF as eF,pse as eG,mse as eH,pW as eI,gse as eJ,jX as eK,Ote as eL,kse as eM,jse as eN,hse as eO,fse as eP,Pte as eQ,bse as eR,wse as eS,yse as eT,xse as eU,Ro as eV,Kte as eW,Lte as eX,vse as eY,Bte as eZ,oP as e_,Ete as ea,Tte as eb,_te as ec,Cte as ed,jte as ee,kte as ef,Nte as eg,Ate as eh,Ste as ei,wte as ej,hte as ek,fte as el,xte as em,vte as en,bte as eo,gte as ep,yte as eq,pte as er,mte as es,dte as et,a_ as eu,n_ as ev,$te as ew,kw as ex,Mte as ey,Oj as ez,nm as f,Ute as f0,Mse as g,Ose as h,Bse as i,Lse as j,Ig as k,$c as l,Cse as m,LV as n,wY as o,EG as p,kae as q,Jie as r,_ae as s,cQ as t,O1 as u,tse as v,_a as w,Zte as x,J as y,Gm as z};
|
|
86
|
+
competitor2.com`,value:fi,onChange:H=>Yi(H.target.value)})]}),en?l.jsx("p",{className:"text-negative-400 text-sm",children:en}):null,l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:Mn,children:"Back"}),l.jsx("div",{className:"flex gap-2",children:yi.length===0?l.jsx(le,{type:"button",onClick:wl,children:"Continue without competitors"}):l.jsxs(l.Fragment,{children:[l.jsx(le,{type:"button",variant:"outline",onClick:wl,children:"Skip"}),l.jsx(le,{type:"button",disabled:pl,onClick:fn(bl),children:pl?"Saving...":`Save ${yi.length} competitor${yi.length!==1?"s":""}`})]})})]})]})]});case 4:{const H=Ya.data,Ye=H?.status??(Wi===tt?.id?tt.status:void 0),vi=Ye==="completed"||Ye==="partial"||Ye==="failed"||Ye==="cancelled",ts=H?.snapshots??[],Ma=H?.queryCounts,kl=Ye?rk(Ye,ts.length):!1,An=Ke&&!Za,xi=jn??(H?.error?rQ(H.error):Ye==="cancelled"?"The sweep was cancelled before it produced a baseline.":(Ye==="completed"||Ye==="partial")&&ts.length===0?"The sweep finished without producing any snapshots.":tt?.statusDetail||"The sweep did not produce a baseline.");let Wa=null;return An||kl?Wa=l.jsx(wn,{tone:"positive",children:"Complete"}):jn&&!Za?Wa=l.jsx(wn,{tone:"negative",children:"Failed"}):vi?Wa=l.jsx(wn,{tone:"negative",children:Ye==="cancelled"?"Cancelled":"Failed"}):Za&&(Wa=l.jsx(wn,{tone:"caution",children:"Running"})),l.jsxs(_a,{className:"surface-card step-card",children:[l.jsxs("div",{className:"section-head",children:[l.jsxs("div",{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:T?"Step 2 of 2":"Step 5 of 5"}),l.jsx("h2",{children:bo()?"AI Visibility":"Launch first run"})]}),Wa]}),An?l.jsxs("div",{className:"compact-stack",children:[l.jsxs("p",{className:"text-secondary",children:["Setup is complete. ",l.jsx("span",{className:"text-strong font-medium",children:Ne})," already has a successful answer-visibility baseline."]}),l.jsxs("div",{className:"setup-nav",children:[l.jsx("span",{}),l.jsx(le,{type:"button",onClick:()=>ct(),children:f?"Finish setup":"Open project dashboard →"})]})]}):!Za&&bo()?l.jsxs("div",{className:"compact-stack",children:[Ne?l.jsx(_X,{projectName:Ne}):l.jsx("p",{className:"text-sm text-secondary",children:Pg}),jn&&l.jsx("p",{role:"alert",className:"text-sm text-negative",children:jn}),l.jsxs("div",{className:"setup-nav",children:[l.jsx("span",{}),l.jsx(le,{type:"button",onClick:Ve,children:"Open project dashboard →"})]})]}):Za?vi?kl?l.jsxs("div",{className:"compact-stack",children:[l.jsxs("p",{className:"text-neutral",children:["Sweep complete. Your first answer-visibility snapshot for"," ",l.jsx("span",{className:"text-heading font-medium",children:Ne}),":"]}),l.jsxs("div",{className:"grid grid-cols-3 gap-2 mt-1",children:[l.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[l.jsx("p",{className:"text-xs font-medium text-secondary",children:"Mentioned"}),l.jsx("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:Ma?l.jsxs(l.Fragment,{children:[Ma.mentionedQueries,l.jsxs("span",{className:"text-faint text-lg",children:[" / ",Ma.totalQueries]})]}):"Unavailable"}),l.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"queries naming your brand"})]}),l.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[l.jsx("p",{className:"text-xs font-medium text-secondary",children:"Cited"}),l.jsx("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:Ma?l.jsxs(l.Fragment,{children:[Ma.citedQueries,l.jsxs("span",{className:"text-faint text-lg",children:[" / ",Ma.totalQueries]})]}):"Unavailable"}),l.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"queries citing your site"})]}),l.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[l.jsx("p",{className:"text-xs font-medium text-secondary",children:"Results"}),l.jsx("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:ts.length}),l.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"completed engine checks"})]})]}),!b&&Ne?l.jsx(yW,{projectName:Ne}):null,l.jsxs("div",{className:"setup-nav",children:[l.jsx("span",{}),l.jsx(le,{type:"button",onClick:()=>ct(),children:f?"Finish setup":"Open project dashboard →"})]})]}):l.jsxs("div",{className:"compact-stack",children:[l.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[l.jsx("p",{children:xi}),l.jsx("p",{className:"mt-1 text-xs text-secondary",children:bo()?Pg:x?"Fix provider or query configuration if needed, then retry without leaving setup.":"Ask an administrator to review the provider and query configuration."})]}),l.jsxs("div",{className:"setup-nav",children:[x&&!bo()?l.jsx(le,{type:"button",variant:"outline",asChild:!0,children:l.jsx(at,{to:"/settings",children:"Configure providers"})}):l.jsx("span",{}),bo()||!x?l.jsx(le,{type:"button",onClick:Ve,children:"Open project dashboard →"}):l.jsx(le,{type:"button",disabled:gi||!!Xa,onClick:fn(bi),children:gi?"Retrying...":"Retry visibility sweep"})]})]}):l.jsxs("div",{className:"compact-stack",children:[l.jsx("p",{className:"text-neutral",children:"Sweep running. This usually takes 30 to 60 seconds."}),l.jsx("div",{className:"rounded-md border border-default bg-surface p-3 text-xs text-muted",children:l.jsxs("p",{children:["Status: ",l.jsx("span",{className:"text-neutral",children:Ye??"queued"})]})}),Ya.isError&&l.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[l.jsx("p",{children:Ya.error instanceof Error?Ya.error.message:"Could not refresh the sweep status."}),l.jsx(le,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:()=>{Ya.refetch()},children:"Retry status check"})]}),l.jsxs("div",{className:"setup-nav",children:[l.jsx("span",{}),l.jsx(le,{type:"button",variant:"outline",onClick:f?()=>ct():Ve,children:f?"Finish setup":"Watch on project page"})]})]}):l.jsxs("div",{className:"compact-stack",children:[l.jsxs("p",{className:"supporting-copy",children:["Your queries are saved. Run a first sweep to get a baseline for"," ",l.jsx("span",{className:"text-heading font-medium",children:Ne}),", or finish and run it later from the project. A sweep calls the answer engines, so it costs provider usage."]}),(Xa||jn)&&l.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[l.jsx("p",{children:jn??Xa}),l.jsx("p",{className:"mt-1 text-xs text-secondary",children:"Resolve the blocker above, then retry the sweep here."})]}),l.jsxs("div",{className:"setup-nav",children:[l.jsx(le,{type:"button",variant:"outline",onClick:Mn,children:"Back"}),l.jsx(le,{type:"button",variant:"ghost",onClick:Qt,children:"Finish without running"}),ba==="no_provider"&&!T?l.jsx(le,{type:"button",asChild:!0,children:l.jsx(at,{to:"/settings",children:"Configure a provider"})}):l.jsx(le,{type:"button",disabled:gi||!!Xa,title:Xa,onClick:fn(bi),children:gi?"Launching...":jn?"Retry visibility sweep":"Launch visibility sweep"})]})]})]})}default:return null}})();return l.jsxs("div",{className:T?"page-container visibility-setup":"page-container",children:[f?l.jsx(Ro,{current:"visibility"}):null,l.jsxs("div",{className:"page-header",children:[l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{ref:u?h:void 0,tabIndex:u?-1:void 0,className:"page-title",children:u?"Set up AI Visibility":"Setup"}),l.jsx("p",{className:"page-subtitle",children:u?"Connect an answer engine, then choose queries for your first sweep.":"Create a project and run its first visibility check."})]}),f?l.jsx("div",{className:"page-header-right",children:l.jsx(le,{type:"button",variant:"outline",className:"min-h-11",onClick:Qt,children:"Skip AI Visibility"})}):null]}),f?null:l.jsx(kW,{current:T?B===4?1:0:B,labels:T?wW:xW}),l.jsxs("section",{className:"setup-wizard",children:[Ys,Ja]})]})}const Yf="canonry mcp install --client claude-code",NW="https://github.com/Canonry/canonry/blob/main/docs/mcp.md";function CW(){const e=C.useRef(w1()).current,n=C.useRef(new Set),i=C.useCallback((r,u)=>{n.current.has(r)||(n.current.add(r),N1({...u,flowVersion:ft,onboardingSessionId:e,surface:"platform",eventId:S1()}))},[e]);return C.useEffect(()=>{i("started",{event:"onboarding.started",step:"finish",resumed:!1})},[i]),C.useCallback(r=>{i(`action:${r}`,{event:"onboarding.step_completed",step:"finish",method:"manual",nextAction:r})},[i])}const ap=C.createContext(()=>{});function _W({projectName:e,skippedVisibility:n=!1}){const i=yt({...QF({client:J,path:{name:e}}),retry:!1}),r=i.data?.hasData?i.data:null,u=CW(),h=uk(e,Oe["site-audit"]),f=uk(e,Oe["answer-visibility"]),b={...h?{site:h,fixes:h}:{},...TW(f,n)};return l.jsx(ap.Provider,{value:u,children:l.jsxs("div",{className:"page-container max-w-6xl py-8 md:py-10",children:[l.jsx(Ro,{current:"done",outcomes:b}),l.jsxs("header",{className:"relative mx-auto mt-12 max-w-2xl text-center md:mt-16",children:[l.jsx(EW,{}),l.jsx("p",{className:"onb-reveal mt-6 text-sm font-medium text-positive",style:Ta(250),children:"Setup complete"}),l.jsx("h1",{className:"onb-reveal mt-2 text-5xl font-semibold tracking-tight text-heading md:text-6xl",style:Ta(350),children:"You’re set."}),l.jsxs("p",{className:"onb-reveal mx-auto mt-4 max-w-xl text-lg text-secondary",style:Ta(450),children:["Canonry is tracking ",l.jsx("span",{className:"font-medium text-heading",children:e}),". Here’s how to get the most out of it from here."]})]}),l.jsxs("div",{className:"mt-14 grid gap-4 md:grid-cols-6",children:[l.jsx(Rd,{className:"md:col-span-4 md:row-span-2",delayMs:600,labelledBy:"onb-agent-heading",children:l.jsx(zW,{projectName:e})}),l.jsx(Rd,{className:"md:col-span-2 md:row-span-2",delayMs:700,labelledBy:"onb-data-heading",children:l.jsx(PW,{projectName:e})}),l.jsx(Rd,{className:"md:col-span-3",delayMs:800,labelledBy:"onb-schedule-heading",children:l.jsx(BW,{projectName:e})}),l.jsx(Rd,{className:"md:col-span-3",delayMs:900,labelledBy:"onb-alerts-heading",children:l.jsx(LW,{projectName:e,score:r?.aggregateScore??null})})]}),l.jsxs("div",{className:"onb-reveal mt-12 flex flex-col items-center gap-3 sm:flex-row sm:justify-center",style:Ta(1e3),children:[l.jsx(le,{asChild:!0,className:"h-11 rounded-full px-6 text-base md:h-11",children:l.jsxs(at,{to:"/projects/$projectName",params:{projectName:e},replace:!0,onClick:()=>u("open_project"),children:["Open ",e,l.jsx(Tc,{className:"size-4","aria-hidden":"true"})]})}),l.jsx(le,{asChild:!0,variant:"ghost",className:"h-11 rounded-full px-5 md:h-11",children:l.jsx(at,{to:"/projects/$projectName/technical-aeo",params:{projectName:e},replace:!0,onClick:()=>u("review_page_health"),children:"Review page health"})})]})]})})}function uk(e,n){const i=yt({...XN({client:J,path:{name:e},query:{kind:n,limit:20}}),retry:!1,refetchInterval:r=>dk(r.state.status==="success"?{isSuccess:!0,data:r.state.data}:{isSuccess:!1})==="pending"?5e3:!1});return dk(i)}function TW(e,n){return e===void 0?{}:n?{visibility:"skipped"}:{visibility:e}}function dk(e){if(!e.isSuccess||!e.data)return"unknown";const n=e.data.filter(i=>i.trigger!==$a.probe);if(!n.some(i=>i.status===Nt.completed||i.status===Nt.partial))return n.some(i=>i.status===Nt.queued||i.status===Nt.running)?"pending":n.length>0?"incomplete":"skipped"}function Ta(e){return{"--onb-delay":`${e}ms`}}function EW(){return l.jsx("div",{className:"onb-check relative mx-auto size-20","aria-hidden":"true",children:l.jsxs("svg",{viewBox:"0 0 80 80",className:"relative size-20",children:[l.jsx("circle",{className:"onb-check-ring",cx:"40",cy:"40",r:"36",fill:"none",strokeWidth:"3",pathLength:"1"}),l.jsx("path",{className:"onb-check-mark",d:"M25 41 L35 51 L56 30",fill:"none",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round",pathLength:"1"})]})})}function Rd({className:e="",delayMs:n,labelledBy:i,children:r}){return l.jsx("section",{"aria-labelledby":i,className:`onb-reveal onb-tile flex flex-col overflow-hidden rounded-2xl border border-default bg-surface p-6 md:p-7 ${e}`,style:Ta(n),children:r})}function ip({id:e,eyebrow:n,title:i,children:r}){return l.jsxs("div",{children:[l.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted",children:n}),l.jsx("h2",{id:e,className:"mt-1.5 text-2xl font-semibold tracking-tight text-heading",children:i}),l.jsx("p",{className:"mt-2 text-sm text-secondary",children:r})]})}const Dd=[{id:"diagnose",label:"Diagnose",prompt:"Why did we lose citations this week?",calls:["canonry_insights_list","canonry_competitor_landscape"],reply:"Two engines started citing a competitor’s comparison page instead of yours. Want me to draft one that answers the same query?"},{id:"fix",label:"Fix",prompt:"Fix the weakest pages on the site.",calls:["canonry_technical_aeo_pages","canonry_site_health_page_audit"],reply:"The lowest-scoring pages are missing structured data and answer-first intros. I’ve written the changes for you to review."},{id:"automate",label:"Automate",prompt:"Re-check everything every Monday and tell me in Slack.",calls:["canonry_schedule_set","canonry_agent_webhook_attach"],reply:"Done. A sweep runs every Monday, and I’ll post what changed to Slack."}],RW=9e3;function DW(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function zW({projectName:e}){const n=C.useContext(ap),[i,r]=C.useState(0),[u,h]=C.useState(!1),[f,b]=C.useState(!1);C.useEffect(()=>{if(u||DW())return;const S=window.setTimeout(()=>r(k=>(k+1)%Dd.length),RW);return()=>window.clearTimeout(S)},[i,u]);const v=async()=>{try{await navigator.clipboard.writeText(Yf),n("copy_agent_command"),b(!0),window.setTimeout(()=>b(!1),1800)}catch{bn({tone:"negative",title:"Could not copy the command",detail:`Run ${Yf} in your terminal.`})}},x=Dd[i]??Dd[0];return l.jsxs(l.Fragment,{children:[l.jsxs(ip,{id:"onb-agent-heading",eyebrow:"Your agent",title:"Let your agent run it.",children:["Your agent can do everything in Canonry: diagnose a drop, fix pages, run sweeps and scans, and write the client report. Use Claude Code, Codex, Cursor, or Aero, the analyst built into"," ",l.jsx("span",{className:"text-heading",children:e})," that reviews every sweep on its own."]}),l.jsxs("div",{className:"mt-6 flex flex-1 flex-col rounded-xl border border-default bg-bg",onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),onFocus:()=>h(!0),children:[l.jsxs("div",{className:"flex items-center gap-1 border-b border-default px-3 py-2",role:"tablist","aria-label":"Example agent sessions",children:[Dd.map((S,k)=>l.jsx("button",{type:"button",role:"tab","aria-selected":k===i,onClick:()=>{r(k),h(!0)},className:`rounded-md px-2.5 py-1 text-xs font-medium transition-colors ${k===i?"bg-surface-inset text-heading":"text-muted hover:text-secondary"}`,children:S.label},S.id)),l.jsx("span",{className:"ml-auto text-xs text-faint",children:"Example"})]}),l.jsxs("div",{role:"tabpanel","aria-label":`${x.label} example`,className:"flex-1 p-4 font-mono text-[13px] leading-relaxed",children:[l.jsxs("p",{className:"onb-type text-heading",style:Ta(150),children:[l.jsx("span",{className:"text-muted",children:"> "}),x.prompt]}),x.calls.map((S,k)=>l.jsxs("p",{className:"onb-line mt-1 text-muted first:mt-3",style:Ta(1300+k*450),children:[l.jsx("span",{className:"text-positive",children:"●"})," ",S]},S)),l.jsx("p",{className:"onb-line mt-3 text-secondary",style:Ta(1500+x.calls.length*450),children:x.reply}),l.jsx("span",{className:"onb-caret mt-2 inline-block h-4 w-2 bg-current align-middle text-secondary",style:Ta(1900+x.calls.length*450),"aria-hidden":"true"})]},x.id)]}),l.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[l.jsx("code",{className:"min-w-0 flex-1 truncate rounded-lg border border-default bg-surface-inset px-3 py-2 font-mono text-[13px] text-heading",children:Yf}),l.jsxs(le,{type:"button",variant:"secondary",size:"sm",className:"h-9 md:h-9",onClick:()=>{v()},children:[f?l.jsx(Uc,{className:"size-4","aria-hidden":"true"}):l.jsx(Zg,{className:"size-4","aria-hidden":"true"}),f?"Copied":"Copy"]}),l.jsx("a",{href:NW,target:"_blank",rel:"noreferrer",className:"text-sm font-medium text-link underline-offset-4 hover:underline",children:"Other clients"})]})]})}const IW=[{icon:Fg,label:"Search Console",action:"connect_search_console",to:"/projects/$projectName/search-console"},{icon:Ck,label:"Google Analytics",action:"connect_analytics",to:"/projects/$projectName/activity"},{icon:Tk,label:"Business Profile",action:"connect_business_profile",to:"/projects/$projectName/local"}],OW=["GPTBot","ClaudeBot","PerplexityBot"];function PW({projectName:e}){const n=C.useContext(ap);return l.jsxs(l.Fragment,{children:[l.jsx(ip,{id:"onb-data-heading",eyebrow:"Server-side traffic",title:"See the AI bots.",children:"AI crawlers and answer-engine fetches never run JavaScript, so Google Analytics never sees them. Canonry reads them straight from your server."}),l.jsx(qW,{}),l.jsxs(at,{to:"/traffic",onClick:()=>n("connect_server_traffic"),"aria-label":"Connect server-side traffic",className:"group flex items-center gap-3 rounded-xl border border-strong bg-surface-inset px-4 py-3 text-sm font-medium text-heading transition-colors hover:bg-surface-inset-hover",children:[l.jsx(Ek,{className:"size-4 text-positive","aria-hidden":"true"}),l.jsxs("span",{className:"flex-1",children:["Connect your server",l.jsx("span",{className:"block text-xs font-normal text-secondary",children:"Cloudflare, Vercel, WordPress, or Cloud Run"})]}),l.jsx(Tc,{className:"size-4 text-link transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]}),l.jsx("p",{className:"mt-5 text-xs font-medium uppercase tracking-wide text-muted",children:"Also connect"}),l.jsx("ul",{className:"mt-1 divide-y divide-default",children:IW.map(({icon:i,label:r,action:u,to:h})=>l.jsx("li",{children:l.jsxs(at,{to:h,params:{projectName:e},"aria-label":`Connect ${r}`,onClick:()=>n(u),className:"group flex items-center gap-3 py-2.5 text-sm text-heading",children:[l.jsx(i,{className:"size-4 text-muted","aria-hidden":"true"}),l.jsx("span",{className:"flex-1",children:r}),l.jsx(Tc,{className:"size-3.5 text-link transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]})},r))})]})}function qW(){const e=[22,70,118];return l.jsxs("div",{className:"relative my-6 h-36","aria-hidden":"true",children:[l.jsx("svg",{viewBox:"0 0 200 140",preserveAspectRatio:"none",className:"absolute inset-0 size-full",children:e.map((n,i)=>l.jsx("path",{className:"onb-flow",style:Ta(i*400),d:`M20 ${n} C 100 ${n}, 118 70, 170 70`,fill:"none",strokeWidth:"1.5"},n))}),OW.map((n,i)=>l.jsx("span",{className:"onb-bot absolute left-0 -translate-y-1/2 rounded-md border border-default bg-bg-elevated px-2 py-1 font-mono text-[11px] text-secondary",style:{top:`${(e[i]??70)/140*100}%`,...Ta(i*600)},children:n},n)),l.jsx("span",{className:"onb-hub absolute right-0 top-1/2 flex size-11 -translate-y-1/2 items-center justify-center rounded-2xl bg-accent text-on-inverse",children:l.jsx(Ek,{className:"size-5"})})]})}const MW=["M","T","W","T","F","S","S"];function BW({projectName:e}){return l.jsxs(l.Fragment,{children:[l.jsx(ip,{id:"onb-schedule-heading",eyebrow:"Scheduled sweeps",title:"Runs on its own.",children:"Re-measure every week without lifting a finger, so a drop shows up before a customer notices."}),l.jsx("ol",{className:"mt-6 grid grid-cols-7 gap-2","aria-hidden":"true",children:MW.map((n,i)=>l.jsxs("li",{className:"flex flex-col items-center gap-2",children:[l.jsx("span",{className:"onb-day size-3 rounded-full bg-surface-inset",style:Ta(i*500)}),l.jsx("span",{className:"text-xs text-muted",children:n})]},i))}),l.jsx(UC,{projectName:e,to:"/projects/$projectName/settings",icon:_k,label:"Set a schedule",action:"set_schedule"})]})}function LW({projectName:e,score:n}){return l.jsxs(l.Fragment,{children:[l.jsx(ip,{id:"onb-alerts-heading",eyebrow:"Notifications",title:"Hear about changes.",children:"Get a webhook in Slack or anywhere else when a sweep finishes or a score moves."}),l.jsxs("div",{className:"relative mt-6 flex h-14 items-center","aria-hidden":"true",children:[l.jsx("span",{className:"onb-bell flex size-10 items-center justify-center rounded-full border border-default bg-bg-elevated",children:l.jsx(Wf,{className:"size-4 text-secondary"})}),l.jsxs("span",{className:"onb-toast ml-3 flex items-center gap-2 rounded-xl border border-default bg-bg-elevated px-3 py-2 text-sm shadow-[0_8px_24px_var(--color-shadow-panel)]",children:[l.jsx("span",{className:"size-2 rounded-full bg-positive-400"}),l.jsx("span",{className:"text-heading",children:e}),l.jsx("span",{className:"text-secondary",children:n===null?"sweep finished":`page health ${n}`})]})]}),l.jsx(UC,{projectName:e,to:"/projects/$projectName/settings",icon:Wf,label:"Add a notification",action:"add_notification"})]})}function UC({projectName:e,to:n,icon:i,label:r,action:u}){const h=C.useContext(ap);return l.jsxs(at,{to:n,params:{projectName:e},onClick:()=>h(u),className:"group mt-6 inline-flex items-center gap-2 self-start text-sm font-medium text-link",children:[l.jsx(i,{className:"size-4","aria-hidden":"true"}),r,l.jsx(Tc,{className:"size-3.5 transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]})}const UW=C.lazy(async()=>({default:(await Qi(()=>import("./SiteHealthSection-CwffU3tv.js").then(n=>n.d),__vite__mapDeps([0,1,2,3,4]),import.meta.url)).SiteHealthSection})),VW=`Public pages only, crawled from this computer and stored locally. The first scan reads up to ${T2} pages, then stops.`,$W=1800,KW="https://github.com/Canonry/canonry#or-use-any-shell-capable-coding-agent",GW="Help me set up Canonry for my public site.\n\nUse the official Canonry docs:\n- Agent quickstart: https://github.com/Canonry/canonry#or-use-any-shell-capable-coding-agent\n- CLI reference: https://github.com/Canonry/canonry/blob/main/skills/canonry/references/canonry-cli.md\n- Plugin setup: https://github.com/Canonry/canonry/blob/main/docs/plugins.md\n- MCP setup: https://github.com/Canonry/canonry/blob/main/docs/mcp.md\n\nPick one path and stay on it. Use connected Canonry tools (plugin or MCP) only if you have them and I have not pointed you at a specific install. A connected tool runs in its own process and never sees `CANONRY_CONFIG_DIR`, `CANONRY_PORT`, or anything else you export in a shell, so it always acts on my default install. If I named a config directory, a port, or a sandbox, that is the shell path: use `cnry` and tell me which path you chose. Never mix the two in one run, and never create a duplicate project. The `cnry` and `canonry` commands are interchangeable.\n\n1. Ask for my public domain, country, and language. Do not create or scan anything yet. Country and language are only applied when a project is created, so if you reuse an existing project, report its country and language instead of changing them.\n2. Shell path only: confirm `cnry` is on PATH, then run `cnry --version`. If Canonry is missing, propose `npm install -g @canonry/canonry` and wait for approval. Then run `cnry doctor --format json`, which is the command that says whether config, database, and server are in place. `cnry --version` does not read config and succeeds on a completely unconfigured install, so it cannot answer this. If config is missing, run `cnry bootstrap` yourself: it is not interactive, takes about a second, and is safe to rerun. Do not hand it to me and wait. The interactive command is `cnry init`, which is optional provider and OAuth setup that Page Health does not need. Bootstrap prints an API key, so do not repeat its output back to me, and never ask me to paste passwords, API keys, OAuth credentials, or command output.\n3. Confirm the API is reachable. `cnry doctor --format json` reports it, and any project read exits non-zero with `CONNECTION_ERROR` when it is not. If it is unreachable, propose `cnry start` and wait for approval. Use `cnry start`, which is the background daemon, and not `cnry serve`, which runs in the foreground and will block you until I stop it, even though some error messages suggest it. Stop anything you started with `cnry stop`.\n4. List projects with the connected project tool or `cnry project list --format json`, and reuse one whose domain matches. Confirm the proposed name is not already assigned to a different domain. To find out whether a project has already been scanned, run `cnry technical-aeo score <project> --format json` with no `--run-id`, which reports the latest run. Read the `hasData` field, not the score: this command exits 0 and reports `aggregateScore: 0` for a project that has never been scanned, so reading the score alone would have you tell me my site scored zero. If `hasData` is true and `runStatus` is `completed` or `partial`, read that scan instead of starting a new one. If no project matches, show the exact create operation and wait for approval.\n5. Propose a bounded Site Health scan: `--max-pages 100` for a first look, plus whether dead-link checking is on (it is off unless you pass `--check-dead-links`). Show the connected operation or the exact `cnry technical-aeo run <project> --max-pages 100 --wait --format json` command with the project name filled in, and wait for separate approval before scanning. `--wait` polls for up to 15 minutes and returns only the run id and status. If the status it returns is still `queued` or `running`, the scan has not finished: do not rerun it or report results, poll `cnry technical-aeo progress <project> --run-id <run-id> --format json` until it is terminal. If `--wait` outruns your own tool timeout first, recover the run id with `cnry technical-aeo score <project> --format json` and poll the same way.\n6. When the run is `completed` or `partial`, read `cnry technical-aeo crawl <project> --run-id <run-id> --format json` first. It is the only one of these commands that carries `termination` and `complete`; the score and pages commands do not. Then read `cnry technical-aeo score <project> --run-id <run-id> --format json` and `cnry technical-aeo pages <project> --run-id <run-id> --sort score-asc --limit 10 --format jsonl`. Tell me the termination reason in plain words and whether the scan covered the whole site or stopped at a page, link, depth, or time limit. A `partial` run scored the pages it reached and not my site, so never present it as a full-site result. If it stopped early, the fix depends on the reason, so say which: a page or depth limit needs a larger budget, a time limit needs a smaller scan (a lower `--max-pages` or `--max-depth`). If the run failed or was cancelled, inspect the run error and stop.\n7. Summarize only completed evidence, then propose AI Visibility setup. Ask before you add queries, connect providers, start a provider-backed or quota-consuming run, edit files, or publish.";function HW(e,n){return e==="legacy"?"legacy":e==="platform"?"platform":n.state==="success"?n.projectCount===0?"platform":"legacy":n.state==="error"?"retry":"loading"}const QW="2000-01-01T00:00:00.000Z",FW=5e3;function ZW(e,n){const i=new Set,r=new Map;for(const f of n)f.trigger!==$a.probe&&(r.has(f.projectId)||r.set(f.projectId,f.id),(f.status===Nt.completed||f.status===Nt.partial)&&i.add(f.projectId));const h=(e.every(f=>f.createdAt)?[...e].sort((f,b)=>(f.createdAt??"").localeCompare(b.createdAt??"")||f.name.localeCompare(b.name)):e).find(f=>!i.has(f.id));return h?{projectName:h.name,runId:r.get(h.id)}:null}const VC=[{value:"US",label:"United States"},{value:"CA",label:"Canada"},{value:"GB",label:"United Kingdom"},{value:"AU",label:"Australia"},{value:"NZ",label:"New Zealand"},{value:"IE",label:"Ireland"},{value:"DE",label:"Germany"},{value:"FR",label:"France"},{value:"ES",label:"Spain"},{value:"IT",label:"Italy"},{value:"NL",label:"Netherlands"},{value:"BR",label:"Brazil"},{value:"MX",label:"Mexico"},{value:"IN",label:"India"},{value:"SG",label:"Singapore"},{value:"JP",label:"Japan"}],$C=[{value:"en",label:"English"},{value:"es",label:"Spanish"},{value:"fr",label:"French"},{value:"de",label:"German"},{value:"it",label:"Italian"},{value:"pt",label:"Portuguese"},{value:"nl",label:"Dutch"},{value:"ja",label:"Japanese"}];function YW(e,n){try{const i=new Intl.DisplayNames(["en"],{type:"region"}),r=new Intl.DisplayNames(["en"],{type:"language"}),u=e.length===2?i.of(e.toUpperCase()):void 0,h=n?r.of(n.toLowerCase()):void 0;return`${u??(e||"Country")} · ${h??(n||"Language")}`}catch{return`${e||"Country"} · ${n||"Language"}`}}function XW(e,n){const i=e.trim().toUpperCase(),r=n.trim().toLowerCase();return{countryValid:VC.some(u=>u.value===i),languageValid:$C.some(u=>u.value===r)}}function JW(e){const n=e.replace(/^\[|\]$/g,"");return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(n)||n.includes(":")}function WW(e){const n=e.trim();if(!n)return null;const i=/^[a-z][a-z\d+.-]*:\/\//i.test(n)?n:`https://${n}`;let r;try{r=new URL(i)}catch{return null}if(r.protocol!=="http:"&&r.protocol!=="https:")return null;const u=r.hostname.toLowerCase().replace(/^www\./,"");if(!u||u==="localhost"||JW(u)||!u.includes("."))return null;const h=u.replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return h?{canonicalDomain:u,projectName:h,displayName:u}:null}async function eee(e,n=$W){let i;const r=new Promise(h=>{i=setTimeout(()=>h({state:"timed-out"}),n)}),u=await Promise.race([e.then(h=>({state:"queued",run:h})),r]);return i&&clearTimeout(i),u}function tee(e,n){e.catch(()=>{bn({title:"Site Health scan did not start",detail:"The project is safe. Choose Run scan in Site Health to retry.",tone:"negative",dedupeKey:`site-health-dispatch:${n}`})})}function KC(e){const n=C.useRef(w1()).current,i=C.useRef(new Set),r=C.useCallback((u,h)=>{if(h){if(i.current.has(h))return;i.current.add(h)}N1({...u,surface:e,eventId:S1()})},[e]);return{onboardingSessionId:n,emit:r}}function mk(e,n){return e instanceof gn&&e.statusCode===409?"A project with this name already exists. Change the project name, or open the existing project.":e instanceof Error&&e.message?e.message:n}function $g(){return l.jsxs("div",{className:"page-container max-w-3xl","aria-busy":"true","aria-live":"polite",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Preparing setup"}),l.jsx("p",{className:"page-subtitle",children:"Checking the projects already on this install."})]})}),l.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-default bg-surface p-4 text-sm text-secondary",role:"status",children:[l.jsx(Ts,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading projects…"]})]})}function nee({onRetry:e}){return l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Can’t load projects"}),l.jsx("p",{className:"page-subtitle",children:"Canonry could not confirm whether this install already has a project."})]})}),l.jsxs("div",{className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",tabIndex:-1,children:[l.jsx("p",{className:"text-sm font-medium text-heading",children:"Setup is paused to protect existing projects."}),l.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Check the connection or sign in again, then retry."}),l.jsx(le,{type:"button",className:"mt-4",variant:"secondary",onClick:e,children:"Retry project check"})]})]})}function aee({projectName:e,initialRunId:n}){return l.jsx(M1,{title:"Site Health setup",children:l.jsx(iee,{projectName:e,initialRunId:n})})}function iee({projectName:e,initialRunId:n}){const i=zs(),r=yt({...Bo({client:J}),enabled:!!e,retry:!1,refetchOnMount:"always"}),{onboardingSessionId:u,emit:h}=KC("site_health"),[f]=C.useState(()=>bG(n));C.useEffect(()=>{f&&vG()},[f]),C.useEffect(()=>{e&&h({flowVersion:ft,onboardingSessionId:u,event:"onboarding.started",step:"run",resumed:!!n&&!f},"onboarding.started")},[h,f,n,u,e]),C.useEffect(()=>{!e||!n||DN(e)?.runId!==n&&RN(e,n)},[n,e]);const v=yt({...T1({client:J,path:{id:n??""}}),enabled:!!n,refetchInterval:({state:T})=>{const z=T.data?.status;return z==="completed"||z==="partial"||z==="failed"||z==="cancelled"?!1:2e3},refetchIntervalInBackground:!0}).data?.status;if(C.useEffect(()=>{if(!e||!n||!v)return;if(v==="completed"||v==="partial"){h({flowVersion:ft,onboardingSessionId:u,event:"onboarding.step_completed",step:"run",method:"automatic"},"onboarding.step_completed:run"),om(n);return}if(v!=="failed"&&v!=="cancelled")return;const T=v==="cancelled"?"run_cancelled":"run_failed";h({flowVersion:ft,onboardingSessionId:u,event:"onboarding.blocked",step:"run",action:"retry_run",reasonCode:T},`onboarding.blocked:run:${T}`),om(n)},[h,n,u,e,v]),!e)return l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Project not found"}),l.jsx("p",{className:"page-subtitle",children:"This setup link does not identify a project."})]})}),l.jsx(le,{type:"button",variant:"secondary",onClick:()=>{i({to:"/projects"})},children:"View projects"})]});if(r.isPending)return l.jsxs("div",{className:"page-container max-w-3xl","aria-busy":"true","aria-live":"polite",children:[l.jsx(Ro,{current:"site"}),l.jsxs("div",{className:"mt-8 flex items-center gap-3 text-sm text-secondary",role:"status",children:[l.jsx(Ts,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading Site Health setup…"]})]});if(r.isError)return l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Can’t resume setup"}),l.jsx("p",{className:"page-subtitle",children:"Canonry could not load the project for this Site Health scan."})]})}),l.jsxs("div",{className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",children:[l.jsx("p",{className:"text-sm text-secondary",children:"Check the connection or sign in again, then retry."}),l.jsx(le,{type:"button",className:"mt-4",variant:"secondary",onClick:()=>{r.refetch()},children:"Retry project check"})]})]});const x=r.data.find(T=>T.name===e);if(!x)return l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx("div",{className:"page-header",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Project not found"}),l.jsxs("p",{className:"page-subtitle",children:["Canonry could not find ",e,". It will not open a different project."]})]})}),l.jsx(le,{type:"button",variant:"secondary",onClick:()=>{i({to:"/projects"})},children:"View projects"})]});const S=()=>{i({to:"/setup",search:{onboarding:"site-health",setupProject:x.name},replace:!0})},k=()=>{i({to:"/setup",search:{experience:"legacy",onboarding:"site-health",setupProject:x.name},replace:!0})},N=()=>{h({flowVersion:ft,onboardingSessionId:u,event:"onboarding.step_completed",step:"run",method:"skipped"},"onboarding.step_completed:run"),i({to:"/setup",search:{onboarding:"complete",setupProject:x.name,skipped:"visibility"},replace:!0})};return l.jsxs("div",{className:"page-container max-w-7xl py-8 md:py-10",children:[l.jsx("h1",{className:"sr-only",children:"Set up Canonry"}),l.jsx(C.Suspense,{fallback:l.jsxs("div",{className:"space-y-5",children:[l.jsx(Ro,{current:"site"}),l.jsxs("div",{className:"flex min-h-72 items-center justify-center gap-3 text-sm text-secondary",role:"status",children:[l.jsx(Ts,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading Site Health…"]})]}),children:l.jsx(UW,{projectName:x.name,projectId:x.id,initialRunId:n,onReleaseInitialRun:S,showOnboardingActions:!0,onContinueOnboarding:k,onSkipOnboarding:N})})]})}function see(){const e=fk({from:"/setup"}),n=e.onboarding==="site-health"&&!e.setupProject,i=e.onboarding==="site-health"&&e.experience!=="legacy",r=HG(),u=e.experience==="legacy"?"legacy":e.experience==="platform"?"platform":r,[h,f]=C.useState(!1),[b,v]=C.useState(void 0),x=yt({...Bo({client:J}),enabled:u==="auto",retry:!1,refetchOnMount:"always"}),S=yt({...qc({client:J,query:{kind:Oe["site-audit"],since:QW,limit:FW}}),enabled:u==="auto",retry:!1,refetchOnMount:"always"}),k=u==="auto"&&x.isSuccess&&x.isFetchedAfterMount&&x.data.length===0;C.useEffect(()=>{k&&f(!0)},[k]);const N=u!=="auto"?{state:"idle"}:x.isSuccess&&x.isFetchedAfterMount?{state:"success",projectCount:x.data.length}:x.isError?{state:"error"}:{state:"loading"},T=u==="legacy"?"legacy":h||k?"platform":HW(u,N);if(e.onboarding==="complete"&&e.setupProject)return l.jsx(_W,{projectName:e.setupProject,skippedVisibility:e.skipped==="visibility"});if(n||i)return l.jsx(aee,{projectName:e.setupProject,initialRunId:e.siteHealthRunId});const z=u==="auto"&&T==="legacy"&&!e.setupProject&&x.isSuccess;if(z&&b===void 0)return S.isError?v(null):S.isSuccess&&S.isFetchedAfterMount&&v(ZW(x.data,S.data)),l.jsx($g,{});const q=z?b:null;return q?l.jsx(oee,{projectName:q.projectName,runId:q.runId}):T==="legacy"?l.jsx(jW,{visibilityProjectName:e.setupProject,siteHealthOnboarding:e.onboarding==="site-health",onboardingFinish:e.onboarding==="site-health"||e.onboarding==="first-run"}):T==="loading"?l.jsx($g,{}):T==="retry"?l.jsx(nee,{onRetry:()=>{x.refetch()}}):l.jsx(ree,{onActivationStarted:()=>f(!0),skipSiteScan:e.siteScan==="skip"})}function oee({projectName:e,runId:n}){const i=zs();return C.useEffect(()=>{i({to:"/setup",search:{onboarding:"site-health",setupProject:e,...n?{siteHealthRunId:n}:{}},replace:!0})},[i,e,n]),l.jsx($g,{})}function ree({onActivationStarted:e,skipSiteScan:n}){return l.jsx(M1,{title:"Site Health setup",children:l.jsx(lee,{onActivationStarted:e,skipSiteScan:n})})}function lee({onActivationStarted:e,skipSiteScan:n}){const i=zs(),r=Ds(),u=pW(),h=yt({...XQ({client:J}),retry:!1}),f=oi(JQ()),[b,v]=C.useState(""),[x,S]=C.useState(""),[k,N]=C.useState(""),[T,z]=C.useState("US"),[q,E]=C.useState("en"),[P,M]=C.useState(!1),[L,$]=C.useState("idle"),[F,ae]=C.useState(null),[V,Z]=C.useState(null),[X,Ce]=C.useState(!1),[tt,Ke]=C.useState(null),[Ue,ke]=C.useState(!1),Le=h.isError?void 0:h.data,B=typeof Le?.enabled=="boolean"?Le.enabled:null,W=f.isPending?f.variables.body.enabled:B,[ve,Ae]=C.useState(null),se=C.useRef(null),{onboardingSessionId:Se,emit:Me}=KC("platform");C.useEffect(()=>{Me({flowVersion:ft,onboardingSessionId:Se,event:"onboarding.started",step:"project",resumed:!1},"onboarding.started")},[Me,Se]);const xe=WW(b),pe=x||xe?.projectName||"",ce=k||xe?.displayName||"",ue=L==="creating"||L==="dispatching",_e=V??tt,Fe=YW(T,q),{countryValid:Ee,languageValid:Ct}=XW(T,q),me=Ee&&Ct;C.useEffect(()=>{_e&&se.current?.focus()},[_e]);const Be=(Ve,ct)=>i({to:"/setup",search:{...ct?{siteHealthRunId:ct}:{},onboarding:"site-health",setupProject:Ve.name},replace:!0}),Ne=async Ve=>{$("dispatching"),Ke(null);try{const ct=u.mutateAsync({projectName:Ve.name,projectId:Ve.id,projectLabel:Ve.displayName||Ve.name,suppressErrorToast:!0,body:{checkDeadLinks:!0,maxPages:T2}}),Qt=await eee(ct);if(Qt.state==="queued"){Me({flowVersion:ft,onboardingSessionId:Se,event:"run.requested",origin:"dashboard_setup",result:"queued",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0"}),yG(Qt.run.runId),await Be(Ve,Qt.run.runId);return}ct.then(()=>{Me({flowVersion:ft,onboardingSessionId:Se,event:"run.requested",origin:"dashboard_setup",result:"queued",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0"})},Ft=>{Me({flowVersion:ft,onboardingSessionId:Se,event:"run.requested",origin:"dashboard_setup",result:"rejected",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0",reasonCode:Ac(Ft,"run_rejected")})}),tee(ct,Ve.id),await Be(Ve)}catch(ct){$("recovery"),Ke(mk(ct,"The project was created, but the Site Health scan could not be started."));const Qt=Ac(ct,"run_rejected");Me({flowVersion:ft,onboardingSessionId:Se,event:"run.requested",origin:"dashboard_setup",result:"rejected",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0",reasonCode:Qt}),Me({flowVersion:ft,onboardingSessionId:Se,event:"onboarding.blocked",step:"run",action:"retry_run",reasonCode:Qt},`onboarding.blocked:run:${Qt}`)}},re=async Ve=>{if(Ve.preventDefault(),!(!xe||!n&&!P||!me||ue)){$("creating"),Z(null),Ce(!1),Ke(null);try{const ct=await mH({name:pe,displayName:ce,canonicalDomain:xe.canonicalDomain,country:T,language:q});if(e(),ae(ct),Me({flowVersion:ft,onboardingSessionId:Se,event:"onboarding.step_completed",step:"project",method:"manual"},"onboarding.step_completed:project"),await r.invalidateQueries({queryKey:$r({client:J})}),n){await i({to:"/setup",search:{experience:"legacy",onboarding:"first-run",setupProject:ct.name},replace:!0});return}await Ne(ct)}catch(ct){$("idle");const Qt=ct instanceof gn&&ct.statusCode===409;Ce(Qt),Z(mk(ct,"Could not create the project. Try again.")),Me({flowVersion:ft,onboardingSessionId:Se,event:"onboarding.blocked",step:"project",action:"save",reasonCode:Ac(ct,"project_create_failed")},"onboarding.blocked:project"),Qt&&(e(),r.invalidateQueries({queryKey:$r({client:J})}))}}},Ze=()=>{F&&!ue&&Ne(F)},bt=()=>{ue||i({to:"/projects"})},qn=async()=>{try{await navigator.clipboard.writeText(GW),ke(!0)}catch{bn({tone:"negative",title:"Could not copy setup request",detail:"Open the agent quickstart to continue with the CLI instead."})}},Ht=async Ve=>{Ae(null);try{const ct=await f.mutateAsync({client:J,body:{enabled:Ve}});r.setQueryData(WN({client:J}),ct),ct.enabled!==Ve&&Ae(`The server kept telemetry ${ct.enabled?"on":"off"}. Check its telemetry settings.`)}catch{Ae("Could not update telemetry. Try again.")}};return F&&L==="recovery"?l.jsxs("div",{className:"page-container max-w-3xl",children:[l.jsx(Ro,{current:"site"}),l.jsx("div",{className:"page-header mt-8",children:l.jsxs("div",{className:"page-header-left",children:[l.jsx("h1",{className:"page-title",children:"Project created"}),l.jsxs("p",{className:"page-subtitle",children:[F.displayName||F.name," is ready. The Site Health scan needs another try."]})]})}),l.jsxs("div",{ref:se,className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",tabIndex:-1,children:[l.jsx("p",{className:"text-sm font-medium text-heading",children:tt}),l.jsx("p",{className:"mt-1 text-sm text-secondary",children:"You can retry the scan or continue setup and retry from Site Health."}),l.jsxs("div",{className:"mt-4 flex flex-wrap gap-3",children:[l.jsx(le,{type:"button",onClick:Ze,children:"Retry Site Health scan"}),l.jsx(le,{type:"button",variant:"secondary",onClick:()=>{Be(F)},children:"Continue setup"})]})]})]}):l.jsxs("div",{className:"page-container max-w-xl py-8 md:py-12",children:[n?null:l.jsx(Ro,{current:"site"}),l.jsxs("header",{className:`mb-8 ${n?"":"mt-8"}`,children:[l.jsx("h1",{id:"site-map-setup-title",className:"text-2xl font-semibold tracking-[-0.025em] text-heading",children:n?"Create a project":"Scan your site"}),l.jsx("p",{className:"mt-2 max-w-lg text-sm leading-6 text-secondary",children:n?"Add a public domain, then choose the queries you want to track. No site scan will run.":"Enter your public website to see its pages, structure, internal links, and technical SEO scores."})]}),l.jsxs("form",{"aria-labelledby":"site-map-setup-title",className:"space-y-6",onSubmit:fn(re),noValidate:!0,children:[l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm font-medium text-heading",htmlFor:"launchpad-domain",children:"Website URL"}),l.jsx("input",{id:"launchpad-domain",className:"h-11 w-full rounded-md border border-strong bg-bg-elevated/50 px-3 text-base text-heading outline-none transition placeholder:text-muted focus:border-mono-500 focus:ring-1 focus:ring-mono-500",type:"text",inputMode:"url",autoComplete:"url",autoCapitalize:"none",spellCheck:!1,required:!0,"aria-invalid":!!(b&&!xe),"aria-describedby":b&&!xe?"launchpad-domain-hint launchpad-domain-error":"launchpad-domain-hint",placeholder:"https://example.com",value:b,onChange:Ve=>{v(Ve.target.value),Z(null),Ce(!1)}}),l.jsx("p",{id:"launchpad-domain-hint",className:"text-sm text-secondary",children:n?l.jsxs(l.Fragment,{children:["A public domain is still required."," ",l.jsx(at,{to:"/setup",search:{experience:"platform"},className:"font-medium text-link underline-offset-4 hover:underline",children:"Map with Site Health instead"})]}):l.jsxs(l.Fragment,{children:["Only public pages are scanned."," ",l.jsx(at,{to:"/setup",search:{experience:"platform",onboarding:"first-run",siteScan:"skip"},className:"font-medium text-link underline-offset-4 hover:underline",children:"Set up without a site scan"})]})}),b&&!xe?l.jsx("p",{id:"launchpad-domain-error",className:"text-sm text-negative",role:"alert",children:"Enter a public domain, such as example.com."}):null]}),l.jsxs("details",{className:"group border-y border-default",children:[l.jsxs("summary",{className:"flex min-h-11 cursor-pointer list-none items-center justify-between gap-4 py-3 text-sm [&::-webkit-details-marker]:hidden",children:[l.jsx("span",{className:"font-medium text-heading",children:"Project name and locale"}),l.jsxs("span",{className:"flex items-center gap-2 text-secondary",children:[Fe,l.jsx(Lc,{className:"size-4 transition-transform group-open:rotate-180 motion-reduce:transition-none","aria-hidden":"true"})]})]}),l.jsxs("div",{className:"space-y-5 border-t border-default py-4",children:[xe?l.jsxs("div",{children:[l.jsx("p",{className:"mb-3 text-sm font-medium text-heading",children:"Project"}),l.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-project-name",children:"Project name"}),l.jsx("input",{id:"launchpad-project-name",className:"setup-input h-10",type:"text",value:pe,onChange:Ve=>S(Ve.target.value)})]}),l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-display-name",children:"Display name"}),l.jsx("input",{id:"launchpad-display-name",className:"setup-input h-10",type:"text",value:ce,onChange:Ve=>N(Ve.target.value)})]})]})]}):null,l.jsxs("div",{children:[l.jsx("p",{className:"mb-3 text-sm font-medium text-heading",children:"Locale"}),l.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-country",children:"Country"}),l.jsx("select",{id:"launchpad-country",className:"setup-input h-10",value:T,onChange:Ve=>z(Ve.target.value),children:VC.map(Ve=>l.jsx("option",{value:Ve.value,children:Ve.label},Ve.value))})]}),l.jsxs("div",{className:"grid gap-2",children:[l.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-language",children:"Language"}),l.jsx("select",{id:"launchpad-language",className:"setup-input h-10",value:q,onChange:Ve=>E(Ve.target.value),children:$C.map(Ve=>l.jsx("option",{value:Ve.value,children:Ve.label},Ve.value))})]})]})]})]})]}),n?null:l.jsxs("label",{className:"flex min-h-11 cursor-pointer items-start gap-3 py-2",children:[l.jsx("input",{className:"mt-0.5 size-4 shrink-0 rounded border-strong bg-bg",type:"checkbox",checked:P,onChange:Ve=>M(Ve.target.checked),"aria-label":"Allow Canonry to scan this public site."}),l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"text-sm leading-5 text-heading",children:"Allow Canonry to scan this public site."}),l.jsx(ua,{text:VW})]})]}),_e?l.jsxs("div",{ref:se,className:"rounded-md border border-negative bg-negative-soft p-3",role:"alert",tabIndex:-1,children:[l.jsx("p",{className:"text-sm font-medium text-heading",children:_e}),X?l.jsx(le,{type:"button",variant:"secondary",size:"sm",className:"mt-3",onClick:bt,children:"View projects"}):null]}):null,l.jsxs("div",{className:"grid gap-2",children:[l.jsx(le,{className:"h-11 w-full",type:"submit",disabled:!xe||!n&&!P||!me||ue,children:L==="creating"||L==="dispatching"?l.jsxs(l.Fragment,{children:[l.jsx(Ts,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"})," ",n?"Creating project…":"Mapping site…"]}):n?"Create project":"Scan site"}),L==="dispatching"?l.jsx("span",{className:"text-center text-sm text-secondary",role:"status",children:"Opening Site Health when the scan is ready."}):null]})]}),l.jsxs("section",{className:"mt-8 border-t border-default pt-6","aria-labelledby":"agent-setup-title",children:[l.jsx("p",{id:"agent-setup-title",className:"text-sm font-medium text-heading",children:"Use your agent instead"}),l.jsx("p",{className:"mt-1 text-sm leading-5 text-secondary",children:"Copy a complete CLI setup request into any agent."}),l.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-1",children:[l.jsxs(le,{type:"button",variant:"ghost",size:"sm",className:"-ml-3",onClick:fn(qn),children:[Ue?l.jsx(Uc,{className:"size-3.5","aria-hidden":"true"}):l.jsx(Zg,{className:"size-3.5","aria-hidden":"true"}),l.jsx("span",{"aria-live":"polite",children:Ue?"Copied setup request":"Copy setup request"})]}),l.jsx(le,{asChild:!0,variant:"ghost",size:"sm",children:l.jsxs("a",{href:KW,target:"_blank",rel:"noopener noreferrer",children:["Agent quickstart",l.jsx(k6,{className:"size-3.5","aria-hidden":"true"}),l.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]})})]})]}),B!==null?l.jsxs("section",{className:"mt-6 border-t border-default pt-5","aria-labelledby":"telemetry-title",children:[l.jsxs("label",{className:`flex min-h-11 items-start gap-3 py-2 ${f.isPending?"cursor-wait":"cursor-pointer"}`,children:[l.jsx("input",{className:"mt-0.5 size-4 shrink-0 rounded border-strong bg-bg accent-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-mono-500 disabled:cursor-wait",type:"checkbox",checked:W??!1,disabled:f.isPending,onChange:Ve=>{Ht(Ve.target.checked)},"aria-describedby":"telemetry-detail"}),l.jsxs("span",{className:"grid gap-0.5",children:[l.jsx("span",{id:"telemetry-title",className:"text-sm leading-5 text-heading",children:"Share anonymous product telemetry"}),l.jsx("span",{id:"telemetry-detail",className:"max-w-[70ch] text-sm leading-5 text-secondary",children:"Helps prioritize improvements. Canonry does not send raw domains, URLs, queries, answer content, or credentials."})]})]}),f.isPending?l.jsx("p",{className:"mt-1 text-sm text-secondary",role:"status",children:"Saving preference…"}):null,ve?l.jsx("p",{className:"mt-1 text-sm text-negative",role:"alert",children:ve}):null]}):null]})}function cee(){return l.jsx("div",{className:"page-container",children:l.jsx("section",{className:"page-section",children:l.jsxs(_a,{className:"surface-card empty-card",children:[l.jsx("h1",{children:"Route not found"}),l.jsx("p",{children:"The current path does not map to a dashboard view."}),l.jsx(le,{asChild:!0,children:l.jsx(at,{to:"/",children:"Return to overview"})})]})})})}const Ia=Is(()=>Qi(()=>import("./ProjectPage-Cyvt96AV.js"),__vite__mapDeps([5,1,0,2,3,4,6,7,8,9,10,11,12]),import.meta.url),"ProjectPage"),uee=Is(()=>Qi(()=>import("./RunsPage-Io7ZFw4-.js"),__vite__mapDeps([13,1,11,4,2,7,12]),import.meta.url),"RunsPage"),dee=Is(()=>Qi(()=>import("./HistoryPage-DqXwPH3k.js"),__vite__mapDeps([14,1,10,11,4,2,7,12]),import.meta.url),"HistoryPage"),mee=Is(()=>Qi(()=>import("./SettingsPage-BPYxgchP.js"),__vite__mapDeps([15,1,11,4,2,7,12]),import.meta.url),"SettingsPage"),pee=Is(()=>Qi(()=>import("./BacklinksPage-Tvt0-ppX.js"),__vite__mapDeps([16,1,9,2,11,4,7,12]),import.meta.url),"BacklinksPage"),hee=Is(()=>Qi(()=>import("./TrafficPage-DIm60m1J.js"),__vite__mapDeps([17,1,8,2,11,4,7,12]),import.meta.url),"TrafficPage"),fee=Is(()=>Qi(()=>import("./TrafficSourceDetailPage-DWT1Ip5P.js"),__vite__mapDeps([18,1,8,3,4,2,11,7,12]),import.meta.url),"TrafficSourceDetailPage"),gee=Is(()=>Qi(()=>import("./MeasurementPropertyPage-CsbfFEjB.js"),__vite__mapDeps([19,1,3,4,6,7,2,11,12]),import.meta.url),"MeasurementPropertyPage");function yee(){return l.jsx(wJ,{children:l.jsx(iQ,{children:l.jsx(xJ,{})})})}const Un=t6()({component:yee,validateSearch:e=>({manageQueries:e.manageQueries===!0||e.manageQueries==="true"?!0:void 0,runId:typeof e.runId=="string"?e.runId:void 0,siteHealthRunId:typeof e.siteHealthRunId=="string"?e.siteHealthRunId:void 0,evidenceId:typeof e.evidenceId=="string"?e.evidenceId:void 0,runStatus:typeof e.runStatus=="string"?e.runStatus:void 0,runKind:typeof e.runKind=="string"?e.runKind:void 0,runProject:typeof e.runProject=="string"?e.runProject:void 0,runWindow:typeof e.runWindow=="string"?e.runWindow:void 0,runQuery:typeof e.runQuery=="string"?e.runQuery:void 0,onboarding:e.onboarding==="site-health"||e.onboarding==="first-run"||e.onboarding==="complete"?e.onboarding:void 0,experience:e.experience==="legacy"||e.experience==="platform"?e.experience:void 0,siteScan:e.siteScan==="skip"?"skip":void 0,skipped:e.skipped==="visibility"?"visibility":void 0,setupProject:typeof e.setupProject=="string"?e.setupProject:void 0,scope:typeof e.scope=="string"?e.scope:void 0,class:typeof e.class=="string"?e.class:void 0,...Object.fromEntries(["queryWorkspace","researchMode","trackingQueryId","measurementScope","measurementScopeKey","measurementMarketKey","queryClass","measurementProvider","measurementModel","measurementLocation","measurementFrom","measurementTo","measurementRevision","measurementRunId","measurementQueryKey","measurementAnswer"].map(n=>[n,typeof e[n]=="string"?e[n]:void 0]))})}),bee=Bt({getParentRoute:()=>Un,path:"/",component:nW,beforeLoad:async({context:e})=>{let n=e.queryClient.getQueryData($r({client:J}));if(n===void 0)try{n=await e.queryClient.ensureQueryData(Bo({client:J}))}catch{return}if(n.length===0)throw Kg({to:"/setup"})}}),vee=Bt({getParentRoute:()=>Un,path:"/projects",component:oW}),xee=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Vn=Bt({getParentRoute:()=>Un,path:"/projects/$projectName",component:()=>l.jsx(Xf,{}),beforeLoad:async({context:e,params:n,location:i})=>{const r=n.projectName;if(!xee.test(r))return;let u=e.queryClient.getQueryData($r({client:J}));if(!u)try{u=await e.queryClient.ensureQueryData(Bo({client:J}))}catch{return}const h=u.find(f=>f.id===r);if(h)throw Kg({to:i.pathname.replace(`/projects/${r}`,`/projects/${encodeURIComponent(h.name)}`),replace:!0})}}),wee=Bt({getParentRoute:()=>Vn,path:"/",component:()=>l.jsx(Ia,{tab:"overview"})}),See=Bt({getParentRoute:()=>Vn,path:"/portfolio",component:()=>l.jsx(Ia,{tab:"portfolio"})}),kee=Bt({getParentRoute:()=>Vn,path:"/search-console",component:()=>l.jsx(Ia,{tab:"search-console"})}),jee=Bt({getParentRoute:()=>Vn,path:"/conversions",component:()=>l.jsx(Ia,{tab:"conversions"})}),Aee=Bt({getParentRoute:()=>Vn,path:"/local",component:()=>l.jsx(Ia,{tab:"local"})}),Nee=Bt({getParentRoute:()=>Vn,path:"/discovery",component:()=>l.jsx(Ia,{tab:"discovery"})}),Cee=Bt({getParentRoute:()=>Vn,path:"/queries",component:()=>l.jsx(Ia,{tab:"queries"})}),_ee=Bt({getParentRoute:()=>Vn,path:"/properties/$targetKey",component:()=>l.jsx(gee,{})}),Tee=Bt({getParentRoute:()=>Vn,path:"/report",beforeLoad:({params:e})=>{throw Kg({to:"/projects/$projectName",params:e,replace:!0})}}),Eee=Bt({getParentRoute:()=>Vn,path:"/activity",component:()=>l.jsx(Ia,{tab:"activity"})}),Ree=Bt({getParentRoute:()=>Vn,path:"/backlinks",component:()=>l.jsx(Ia,{tab:"backlinks"})}),Dee=Bt({getParentRoute:()=>Vn,path:"/technical-aeo",component:()=>l.jsx(Ia,{tab:"technical-aeo"})}),zee=Bt({getParentRoute:()=>Vn,path:"/history",component:()=>l.jsx(Ia,{tab:"history"})}),Iee=Bt({getParentRoute:()=>Vn,path:"/settings",component:()=>l.jsx(Ia,{tab:"settings"})}),Oee=Bt({getParentRoute:()=>Un,path:"/runs",component:uee}),Pee=Bt({getParentRoute:()=>Un,path:"/history",component:dee}),qee=Bt({getParentRoute:()=>Un,path:"/settings",component:mee,beforeLoad:({context:e})=>{}}),Mee=Bt({getParentRoute:()=>Un,path:"/setup",component:see}),Bee=Bt({getParentRoute:()=>Un,path:"/backlinks",component:pee}),Lee=Bt({getParentRoute:()=>Un,path:"/traffic",component:hee}),Uee=Bt({getParentRoute:()=>Un,path:"/traffic/$projectName/$sourceId",component:fee}),Vee=Bt({getParentRoute:()=>Un,path:"*",component:cee}),$ee=Un.addChildren([bee,vee,Vn.addChildren([wee,See,kee,jee,Aee,Nee,Cee,_ee,Tee,Eee,Ree,Dee,zee,Iee]),Oee,Pee,qee,Mee,Bee,Lee,Uee,Vee]);function Kee(){return typeof window<"u"&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath:"/"}const pk=Kee(),Gee=pk==="/"?"":pk.replace(/\/$/,"");function Hee(e,n){return n6({routeTree:$ee,basepath:Gee||"/",context:{queryClient:e},...n?.initialEntries})}let hk=!1;async function Qee(e){return(await lT({client:J,body:e,keepalive:!0})).data}function Fee(){hk||typeof window>"u"||(hk=!0,!(Gm()||jo())&&(NG({send:Qee}),J.interceptors.request.use((e,n)=>{const i=n.fetch??globalThis.fetch,r=typeof n.url=="string"?n.url:void 0;return n.fetch=async(u,h)=>{try{return await i(u,h)}catch(f){throw f instanceof DOMException&&f.name==="AbortError"||cm({method:e.method,route:r,network:!0}),f}},e}),J.interceptors.response.use((e,n,i)=>(cm({method:n.method,route:typeof i.url=="string"?i.url:void 0,path:Yee(n.url),status:e.status}),e)),window.addEventListener("error",e=>{lm({kind:"unhandled",error:e.error})}),window.addEventListener("unhandledrejection",e=>{lm({kind:"unhandled",error:e.reason})}),tte()))}function Zee(e){let n=null;const i=()=>{const r=e.state.matches.at(-1);if(!r)return;CG(r.fullPath);const u=e.state.location;if(!u)return;const h=u.search&&typeof u.search=="object"?u.search:{};n&&n.pathname===u.pathname&&DG(n.search,h),n={pathname:u.pathname,search:h}};return i(),e.subscribe("onResolved",i)}function Yee(e){try{return new URL(e,window.location.origin).pathname}catch{return}}const Xee={LCP:[2500,4e3],INP:[200,500],CLS:[.1,.25],FCP:[1800,3e3],TTFB:[800,1800]};function Jee(e,n){const[i,r]=Xee[e];return n<=i?"good":n<=r?"needs-improvement":"poor"}function Wee(){let e=0,n=0,i=-1/0,r=-1/0;return{add(u){u.hadRecentInput||(u.startTime-r<1e3&&u.startTime-i<5e3?n+=u.value:(n=u.value,i=u.startTime),r=u.startTime,e=Math.max(e,n))},value:()=>e}}function ete(){let e=0;return{add(n){n.interactionId&&(e=Math.max(e,n.duration))},value:()=>e}}function tte(){if(typeof PerformanceObserver>"u")return;const e=new Set,n=(b,v)=>{e.has(b)||!Number.isFinite(v)||(e.add(b),IG(b,Jee(b,v)))},i=(b,v,x={})=>{try{new PerformanceObserver(S=>v(S.getEntries())).observe({type:b,buffered:!0,...x})}catch{}};try{const b=performance.getEntriesByType("navigation")[0];b&&b.responseStart>0&&n("TTFB",b.responseStart)}catch{}i("paint",b=>{const v=b.find(x=>x.name==="first-contentful-paint");v&&n("FCP",v.startTime)});let r=0;i("largest-contentful-paint",b=>{const v=b.at(-1);v&&(r=v.startTime)});const u=Wee();i("layout-shift",b=>{for(const v of b)u.add({startTime:v.startTime,value:v.value??0,hadRecentInput:v.hadRecentInput===!0})});const h=ete();i("event",b=>{for(const v of b)h.add(v)},{durationThreshold:40});const f=()=>{r>0&&n("LCP",r),n("CLS",u.value()),h.value()>0&&n("INP",h.value())};document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&f()}),window.addEventListener("pagehide",f)}const nte=6e4,ate="Anyone with this password can sign in to this dashboard.",_r={label:"Root API key",help:"To create the password from here, enter the root API key (apiKey in config.yaml). It is used once and not saved.",missing:"Enter the root API key.",rejected:"That is not the root API key for this install.",show:"Show passwords and key"};function ite(){const e=C.useRef(cH()).current,[n,i]=C.useState(e?"ready":"checking"),[r,u]=C.useState(null),[h,f]=C.useState(null),[b,v]=C.useState(e),[x,S]=C.useState(!1),[k,N]=C.useState(""),[T,z]=C.useState(""),[q,E]=C.useState(""),[P,M]=C.useState(!1),[L,$]=C.useState("password"),[F,ae]=C.useState(!1),[V,Z]=C.useState(""),[X,Ce]=C.useState(null),[tt,Ke]=C.useState(!1),[Ue,ke]=C.useState(!1),Le=C.useRef(null),B=C.useRef(null),W=C.useRef(null),ve=()=>{const me=r?`${r.name}:${r.role}`:e?"api-key:explicit":h?`api-key:${h.id}`:"no-accounts";if(!Le.current||W.current!==me){B.current?.clear();const Be=tQ();B.current=Be,Le.current=Hee(Be),Zee(Le.current),W.current=me}return{queryClient:B.current,router:Le.current}},Ae=me=>me.authRequired?(S(!0),u(me.user),f(null),v(!1),i(me.user?"ready":"account-login"),!0):!1;C.useEffect(()=>{let me=!1;const Be=async(Ne,re=!1)=>{try{const Ze=await Uf();if(me)return;f(Ze),v(!1),i("ready")}catch(Ze){if(me)return;if(re&&Ze instanceof gn&&Ze.statusCode===401)return xH().then(()=>{me||(Ce(null),f(null),v(!1),ke(!0),i("login"))}).catch(bt=>{me||(Ce(bt instanceof Error?bt.message:"Could not clear the invalid session"),i(Ne))});Ce(Ze instanceof Error?Ze.message:"Could not verify API key access"),i(Ne)}};return e?(Be("api-key-error"),()=>{me=!0}):(Promise.allSettled([hS(),pS()]).then(([Ne,re])=>{if(me||Ne.status==="fulfilled"&&Ae(Ne.value))return;if(re.status==="rejected"){const bt=re.reason;Ce(bt instanceof Error?bt.message:"Failed to reach the Canonry API"),i("login");return}const Ze=re.value;Ze.authenticated?(v(!0),Be("api-key-error",!0)):(f(null),v(!1),i(Ze.setupRequired?"setup":"login"))}),()=>{me=!0})},[]),C.useEffect(()=>{if(n!=="ready"||e)return;const me=setInterval(()=>{if(x){hS().then(Be=>{Be.authRequired&&!Be.user&&(ke(!0),u(null),f(null),i("account-login"))}).catch(()=>{});return}pS().then(Be=>{Be.authenticated||(ke(!0),f(null),i(Be.setupRequired?"setup":"login"))}).catch(()=>{})},nte);return mS(()=>{ke(!0),u(null),f(null),v(!1),i(x?"account-login":"login")}),()=>{clearInterval(me),mS(null)}},[n,x,e]);const se=async me=>{if(me.preventDefault(),!T.trim()||T.trim().length<8){Ce("Password must be at least 8 characters");return}if(T!==q){Ce("Passwords do not match");return}const Be=V.trim();if(F&&!Be){Ce(_r.missing);return}Ke(!0),Ce(null);try{if(!(await yH(T.trim(),F?Be:void 0)).authenticated){Ce("Setup failed");return}z(""),E(""),Z(""),ae(!1),M(!1),ke(!1),f(null),v(!0),i("checking");try{const re=await Uf();f(re),v(!1),i("ready")}catch(re){Ce(re instanceof Error?re.message:"Could not verify API key access"),i("api-key-error")}}catch(Ne){if(Ne instanceof gn&&Ne.statusCode===401&&Ne.code==="AUTH_REQUIRED"){Ce(F?_r.rejected:null),ae(!0);return}Ce(Ne instanceof gn||Ne instanceof Error?Ne.message:"Setup failed")}finally{Ke(!1)}},Se=me=>{z(me),Ce(null)},Me=me=>{Z(me),Ce(null)},xe=me=>{E(me),Ce(null)},pe=async me=>{if(me.preventDefault(),!!T.trim()){Ke(!0),Ce(null);try{if(!(L==="api-key"?await vH(T.trim()):await bH(T.trim())).authenticated){Ce(L==="api-key"?"Invalid API key":"Incorrect password");return}const Ne=await Uf();f(Ne),v(!1),z(""),M(!1),ke(!1),i("ready")}catch(Be){Ce(Be instanceof gn||Be instanceof Error?Be.message:"Authentication failed")}finally{Ke(!1)}}},ce=me=>{$(me),z(""),M(!1),Ce(null)},ue=async me=>{if(me.preventDefault(),!(!k.trim()||!T)){Ke(!0),Ce(null);try{const Be=await wH(k.trim(),T);if(!Be.user){Ce("Incorrect name or password.");return}z(""),ke(!1),u(Be.user),f(null),v(!1),i("ready")}catch(Be){Ce(Be instanceof gn?Be.message:"Incorrect name or password.")}finally{Ke(!1)}}};if(n==="ready"){const{queryClient:me,router:Be}=ve();return l.jsx($H,{account:r,apiKey:h,apiKeyPending:b,children:l.jsx(a6,{client:me,children:l.jsx(i6,{router:Be})})})}const _e=T.trim(),Fe=T.length>0&&_e.length<8,Ee=q.length>0&&T!==q,Ct=_e.length>=8&&T===q&&(!F||V.trim().length>0);return l.jsx("div",{className:"min-h-screen bg-bg px-4 py-8",children:l.jsxs("div",{className:"mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col items-center justify-center gap-5",children:[l.jsxs("div",{"data-testid":"auth-brand",className:"flex items-center gap-2.5",children:[l.jsx("img",{className:"size-7",src:"./favicon.svg",alt:"","aria-hidden":"true"}),l.jsx("span",{className:"text-lg font-semibold tracking-tight text-heading",children:"Canonry"})]}),l.jsx(_a,{className:"surface-card w-full",children:n==="checking"?l.jsx(vo,{className:"py-8",children:l.jsx("p",{className:"supporting-copy text-center",children:"Connecting to Canonry…"})}):n==="api-key-error"?l.jsxs(l.Fragment,{children:[l.jsxs(zr,{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),l.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Could not verify API key access"})]}),l.jsxs(vo,{className:"space-y-4",children:[l.jsx("p",{className:"supporting-copy",children:X??"Canonry could not verify this session’s access, so the dashboard stayed locked."}),l.jsx(le,{type:"button",className:"w-full",onClick:()=>{window.location.reload()},children:"Try again"})]})]}):n==="account-login"?l.jsxs(l.Fragment,{children:[l.jsxs(zr,{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),l.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Sign in to Canonry"})]}),l.jsxs(vo,{children:[Ue?l.jsx("p",{className:"mb-4 rounded-md border border-caution bg-caution-soft px-3 py-2 text-sm text-caution",children:"You were signed out — please sign in again."}):null,l.jsxs("form",{className:"space-y-4",onSubmit:fn(ue),children:[l.jsxs("label",{className:"block space-y-1.5",htmlFor:"account-name",children:[l.jsx("span",{className:"text-xs font-medium text-secondary",children:"Name"}),l.jsx("input",{autoFocus:!0,id:"account-name",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"text",name:"username",autoComplete:"username",value:k,onChange:me=>{N(me.target.value),Ce(null)},"aria-invalid":!!X,"aria-describedby":X?"account-login-error":void 0})]}),l.jsxs("label",{className:"block space-y-1.5",htmlFor:"account-password",children:[l.jsx("span",{className:"text-xs font-medium text-secondary",children:"Password"}),l.jsx("input",{id:"account-password",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"password",name:"password",autoComplete:"current-password",value:T,onChange:me=>Se(me.target.value),"aria-invalid":!!X,"aria-describedby":X?"account-login-error":void 0})]}),X?l.jsx("p",{id:"account-login-error",role:"alert",className:"text-sm text-negative-400",children:X}):null,l.jsx(le,{type:"submit",disabled:tt||!k.trim()||!T,children:tt?"Signing in…":"Sign in"})]})]})]}):n==="setup"?l.jsxs(l.Fragment,{children:[l.jsxs(zr,{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"First-time setup"}),l.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Create a dashboard password"}),l.jsx(fm,{children:ate})]}),l.jsx(vo,{children:l.jsxs("form",{className:"space-y-4",onSubmit:fn(se),children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("label",{className:"block text-xs font-medium text-secondary",htmlFor:"dashboard-password-new",children:"Password"}),l.jsx("input",{autoFocus:!0,id:"dashboard-password-new",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:P?"text":"password",name:"new-password",autoComplete:"new-password",minLength:8,required:!0,value:T,onChange:me=>Se(me.target.value),"aria-invalid":Fe,"aria-describedby":"dashboard-password-new-help"}),l.jsx("span",{id:"dashboard-password-new-help","aria-live":"polite",className:Fe?"block text-sm text-negative-400":"block text-sm text-secondary",children:Fe?"Enter at least 8 characters.":"Use at least 8 characters."})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("label",{className:"block text-xs font-medium text-secondary",htmlFor:"dashboard-password-confirm",children:"Confirm password"}),l.jsx("input",{id:"dashboard-password-confirm",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:P?"text":"password",name:"confirm-password",autoComplete:"new-password",minLength:8,required:!0,value:q,onChange:me=>xe(me.target.value),"aria-invalid":Ee,"aria-describedby":"dashboard-password-confirm-help"}),l.jsx("span",{id:"dashboard-password-confirm-help","aria-live":"polite",className:Ee?"block text-sm text-negative-400":"block text-sm text-secondary",children:Ee?"Passwords do not match.":"Enter the same password again."})]}),F?l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("label",{className:"block text-xs font-medium text-secondary",htmlFor:"dashboard-setup-root-key",children:_r.label}),l.jsx("input",{autoFocus:!0,id:"dashboard-setup-root-key",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:P?"text":"password",name:"apiKey",autoComplete:"off",spellCheck:!1,required:!0,value:V,onChange:me=>Me(me.target.value),"aria-invalid":X===_r.rejected,"aria-describedby":"dashboard-setup-root-key-help"}),l.jsx("span",{id:"dashboard-setup-root-key-help","aria-live":"polite",className:"block text-sm text-secondary",children:_r.help})]}):null,l.jsxs("label",{className:"flex min-h-10 cursor-pointer items-center gap-2 text-sm text-secondary",htmlFor:"dashboard-password-show",children:[l.jsx("input",{id:"dashboard-password-show",type:"checkbox",checked:P,onChange:me=>M(me.target.checked)}),F?_r.show:"Show passwords"]}),X?l.jsx("p",{id:"dashboard-password-setup-error",role:"alert",className:"text-sm text-negative-400",children:X}):null,l.jsx(le,{type:"submit",disabled:tt||!Ct,children:tt?"Creating password…":"Create password and continue"})]})})]}):l.jsxs(l.Fragment,{children:[l.jsxs(zr,{children:[l.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),l.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Sign in to Canonry"}),l.jsx(fm,{children:L==="api-key"?"Enter an API key from this Canonry install. This opens the dashboard with that key’s access and does not change the password.":"Enter your dashboard password to continue."})]}),l.jsxs(vo,{children:[Ue?l.jsx("p",{className:"mb-4 rounded-md border border-caution bg-caution-soft px-3 py-2 text-sm text-caution",children:"Your session expired — please sign in again."}):null,l.jsxs("form",{className:"space-y-4",onSubmit:fn(pe),children:[l.jsxs("label",{className:"block space-y-1.5",htmlFor:"dashboard-password-current",children:[l.jsx("span",{className:"text-xs font-medium text-secondary",children:L==="api-key"?"Canonry API key":"Password"}),l.jsx("input",{autoFocus:!0,id:"dashboard-password-current",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:P?"text":"password",name:L==="api-key"?"apiKey":"password",autoComplete:L==="api-key"?"off":"current-password",spellCheck:!1,required:!0,value:T,onChange:me=>Se(me.target.value),"aria-invalid":!!X,"aria-describedby":X?"dashboard-password-login-error":void 0})]}),l.jsxs("label",{className:"flex min-h-10 cursor-pointer items-center gap-2 text-sm text-secondary",htmlFor:"dashboard-login-password-show",children:[l.jsx("input",{id:"dashboard-login-password-show",type:"checkbox",checked:P,onChange:me=>M(me.target.checked)}),L==="api-key"?"Show API key":"Show password"]}),X?l.jsx("p",{id:"dashboard-password-login-error",role:"alert",className:"text-sm text-negative-400",children:X}):null,l.jsx(le,{type:"submit",disabled:tt||!T.trim(),children:tt?"Signing in…":"Open dashboard"}),l.jsx(le,{type:"button",variant:"ghost",onClick:()=>ce(L==="api-key"?"password":"api-key"),children:L==="api-key"?"Use dashboard password instead":"Forgot password? Use API key"})]})]})]})})]})})}const GC=document.getElementById("root");if(!GC)throw new Error("Expected #root element for web app bootstrap.");Fee();R6.createRoot(GC).render(l.jsx(C.StrictMode,{children:l.jsx(ite,{})}));export{xY as $,jo as A,le as B,Sc as C,On as D,fn as E,ese as F,ase as G,nse as H,ua as I,tae as J,aae as K,nne as L,Nse as M,Wie as N,ane as O,Yte as P,tne as Q,Ga as R,sk as S,wn as T,sne as U,nae as V,ine as W,fa as X,oQ as Y,Vse as Z,$se as _,Ase as a,Jte as a$,pQ as a0,Xte as a1,Nae as a2,Rae as a3,Cne as a4,jae as a5,Eie as a6,zie as a7,Die as a8,Pne as a9,Lie as aA,Lg as aB,S9 as aC,k9 as aD,zte as aE,Dte as aF,mae as aG,bae as aH,vae as aI,gn as aJ,xae as aK,bne as aL,rQ as aM,vZ as aN,jg as aO,wae as aP,Bd as aQ,sse as aR,Pg as aS,bo as aT,uQ as aU,Nt as aV,JH as aW,Kae as aX,wX as aY,Bne as aZ,ene as a_,One as aa,Hne as ab,bn as ac,Pie as ad,qie as ae,Une as af,Mie as ag,Vne as ah,Mne as ai,Lne as aj,Iie as ak,Oie as al,Rie as am,qne as an,Bie as ao,Hie as ap,Vie as aq,Kie as ar,$ie as as,Gie as at,cae as au,E1 as av,Oe as aw,Uie as ax,aC as ay,Gi as az,Eae as b,eae as b$,qi as b0,qse as b1,Fte as b2,fne as b3,yq as b4,mne as b5,Qte as b6,Tae as b7,Hte as b8,kQ as b9,rie as bA,cie as bB,yie as bC,Cie as bD,Nie as bE,fie as bF,jie as bG,Tie as bH,die as bI,vie as bJ,xie as bK,wie as bL,uie as bM,bie as bN,mie as bO,Sie as bP,pie as bQ,kie as bR,gie as bS,Aie as bT,_ie as bU,lW as bV,hie as bW,pne as bX,Ane as bY,jne as bZ,kne as b_,QQ as ba,Yae as bb,tie as bc,Xae as bd,lne as be,une as bf,C$ as bg,dne as bh,OQ as bi,Zae as bj,T$ as bk,Sg as bl,cne as bm,eH as bn,Jae as bo,Fae as bp,qQ as bq,Wae as br,Sae as bs,eie as bt,use as bu,dse as bv,$ne as bw,JN as bx,ise as by,XN as bz,Rte as c,Ise as c$,WG as c0,_2 as c1,Dm as c2,T2 as c3,_s as c4,iie as c5,Ite as c6,YQ as c7,lie as c8,Iae as c9,vW as cA,Kse as cB,Rse as cC,bX as cD,Ese as cE,mW as cF,nie as cG,Mae as cH,Tse as cI,$ae as cJ,Bae as cK,Y9 as cL,VP as cM,aie as cN,_se as cO,Uae as cP,Sse as cQ,CX as cR,dH as cS,gQ as cT,_X as cU,xne as cV,wne as cW,vne as cX,hH as cY,Dse as cZ,zse as c_,Wte as ca,wS as cb,Tne as cc,Ene as cd,Dae as ce,zae as cf,Rne as cg,Dne as ch,Ine as ci,zne as cj,su as ck,Bo as cl,MN as cm,qae as cn,Pae as co,sX as cp,Dg as cq,mm as cr,zg as cs,pm as ct,hm as cu,xX as cv,CQ as cw,xo as cx,gm as cy,eF as cz,mQ as d,r9 as d$,Pse as d0,Sne as d1,SQ as d2,Nne as d3,fY as d4,Qie as d5,AH as d6,Xne as d7,Zie as d8,Yie as d9,Kr as dA,kS as dB,uae as dC,pae as dD,fae as dE,gae as dF,dae as dG,hae as dH,yae as dI,Mf as dJ,lae as dK,lse as dL,iW as dM,rne as dN,h1 as dO,Oae as dP,ose as dQ,cse as dR,rae as dS,one as dT,sae as dU,oae as dV,iae as dW,rse as dX,Gte as dY,o9 as dZ,Ra as d_,Xie as da,Fie as db,Cae as dc,Qne as dd,Fne as de,Zne as df,Jne as dg,Yne as dh,z1 as di,qc as dj,Use as dk,iu as dl,sie as dm,oie as dn,iH as dp,gne as dq,yne as dr,_ne as ds,Kne as dt,Gne as du,M1 as dv,Ym as dw,I1 as dx,bW as dy,Wne as dz,dQ as e,Vte as e$,EP as e0,Lae as e1,Aae as e2,bO as e3,Gae as e4,Vae as e5,Qae as e6,Hae as e7,IS as e8,ye as e9,Qi as eA,za as eB,qte as eC,lm as eD,hne as eE,QF as eF,pse as eG,mse as eH,pW as eI,gse as eJ,jX as eK,Ote as eL,kse as eM,jse as eN,hse as eO,fse as eP,Pte as eQ,bse as eR,wse as eS,yse as eT,xse as eU,Ro as eV,Kte as eW,Lte as eX,vse as eY,Bte as eZ,oP as e_,Ete as ea,Tte as eb,_te as ec,Cte as ed,jte as ee,kte as ef,Nte as eg,Ate as eh,Ste as ei,wte as ej,hte as ek,fte as el,xte as em,vte as en,bte as eo,gte as ep,yte as eq,pte as er,mte as es,dte as et,a_ as eu,n_ as ev,$te as ew,kw as ex,Mte as ey,Oj as ez,nm as f,Ute as f0,Mse as g,Ose as h,Bse as i,Lse as j,Ig as k,$c as l,Cse as m,LV as n,wY as o,EG as p,kae as q,Jie as r,_ae as s,cQ as t,O1 as u,tse as v,_a as w,Zte as x,J as y,Gm as z};
|