@canonry/canonry 5.15.0 → 5.16.0
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/agent-workspace/skills/canonry/references/canonry-cli.md +2 -0
- package/assets/assets/{AuditHistoryPanel-BZJn-wvp.js → AuditHistoryPanel-CnoGPJ5Y.js} +1 -1
- package/assets/assets/{BacklinksPage-DsQAKO31.js → BacklinksPage-DYe2CYfD.js} +1 -1
- package/assets/assets/{HistoryPage-DWn459Gu.js → HistoryPage-CO-dzLAo.js} +1 -1
- package/assets/assets/{MeasurementPropertyPage-D6pUcBiT.js → MeasurementPropertyPage-smsZFdd6.js} +1 -1
- package/assets/assets/{ProjectPage-D-lDBpPV.js → ProjectPage-jL3jB2TR.js} +1 -1
- package/assets/assets/{RunRow-BJxx50Ar.js → RunRow-CzcaoK_3.js} +1 -1
- package/assets/assets/{RunsPage-DvoNDx6z.js → RunsPage-DQWPHDoq.js} +1 -1
- package/assets/assets/{SettingsPage-DXbhM5Lv.js → SettingsPage-DMtQLrWP.js} +1 -1
- package/assets/assets/{SiteHealthSection-4mMfc6Rb.js → SiteHealthSection-2ljW02xK.js} +3 -3
- package/assets/assets/{TrafficPage-EYSxLxkQ.js → TrafficPage-NFu0LEdk.js} +1 -1
- package/assets/assets/{TrafficSourceDetailPage-DY4sV_BX.js → TrafficSourceDetailPage-DbBIzmbL.js} +1 -1
- package/assets/assets/{extract-error-message-BMpWRqf9.js → extract-error-message-pMGpUsIh.js} +1 -1
- package/assets/assets/{index-KCAlcuMN.js → index-D9NReRHX.js} +3 -3
- package/assets/assets/{react-sigma_core.esm.min-CHepSGqZ.js → react-sigma_core.esm.min-CadBie52.js} +1 -1
- package/assets/assets/{v2-overview-adapter-CpM-FjB_.js → v2-overview-adapter-Oe8hHMAO.js} +1 -1
- package/assets/index.html +1 -1
- package/dist/{chunk-SJ7ZOFL5.js → chunk-XDFMFZRN.js} +42 -12
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +10 -10
|
@@ -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-2ljW02xK.js","./vendor-tanstack-ZXXkndVj.js","./vendor-lucide-N6vOpZmh.js","./ChartPrimitives-BQC2VH0O.js","./vendor-recharts-llkUFBGR.js","./ProjectPage-jL3jB2TR.js","./RunRow-CzcaoK_3.js","./extract-error-message-pMGpUsIh.js","./v2-overview-adapter-Oe8hHMAO.js","./vendor-markdown-B4giJcws.js","./AuditHistoryPanel-CnoGPJ5Y.js","./vendor-radix-twS1M3FF.js","./vendor-yaml-GWJz5H2G.js","./RunsPage-DQWPHDoq.js","./HistoryPage-CO-dzLAo.js","./SettingsPage-DMtQLrWP.js","./BacklinksPage-DYe2CYfD.js","./TrafficPage-NFu0LEdk.js","./TrafficSourceDetailPage-DbBIzmbL.js","./MeasurementPropertyPage-smsZFdd6.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{c as H4,d as Q4,r as C,j as c,Q as F4,M as Z4,q as ge,e as ic,L as Fe,a as Y4,t as ir,u as Nt,f as X4,h as ka,k as fs,l as gw,m as J4,n as yw,O as Lh,o as gs,p as W4,s as Et,v as bw,x as ys,y as eC,z as tC,A as nC}from"./vendor-tanstack-ZXXkndVj.js";import{S as aC,O as Cf,P as vw,C as Nf,a as xw,T as _f,D as ww,R as kw}from"./vendor-radix-twS1M3FF.js";import{c as Sw}from"./vendor-recharts-llkUFBGR.js";import{A as Zl,X as kr,S as Tf,a as iC,G as jw,C as bd,L as pr,R as _u,M as sC,b as oC,P as Vh,H as Aw,c as rC,d as lC,e as vd,f as Rf,T as Cw,W as cC,g as Ef,h as uC,i as dC,j as mC,k as pC,l as hC,m as fC,n as gC,B as yC,F as bC,o as vC,p as xC,q as wC,r as kC,s as Nw,t as _w,u as $h,v as Tw,w as SC,x as Rw,E as jC}from"./vendor-lucide-N6vOpZmh.js";import{M as AC,r as CC}from"./vendor-markdown-B4giJcws.js";import{p as NC}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 g of h.addedNodes)g.tagName==="LINK"&&g.rel==="modulepreload"&&r(g)}).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 oh={exports:{}},Dl={},rh={exports:{}},lh={};var Vb;function _C(){return Vb||(Vb=1,(function(e){function n(q,Y){var fe=q.length;q.push(Y);e:for(;0<fe;){var be=fe-1>>>1,ne=q[be];if(0<u(ne,Y))q[be]=Y,q[fe]=ne,fe=be;else break e}}function i(q){return q.length===0?null:q[0]}function r(q){if(q.length===0)return null;var Y=q[0],fe=q.pop();if(fe!==Y){q[0]=fe;e:for(var be=0,ne=q.length,De=ne>>>1;be<De;){var Oe=2*(be+1)-1,ve=q[Oe],oe=Oe+1,ue=q[oe];if(0>u(ve,fe))oe<ne&&0>u(ue,ve)?(q[be]=ue,q[oe]=fe,be=oe):(q[be]=ve,q[Oe]=fe,be=Oe);else if(oe<ne&&0>u(ue,fe))q[be]=ue,q[oe]=fe,be=oe;else break e}}return Y}function u(q,Y){var fe=q.sortIndex-Y.sortIndex;return fe!==0?fe:q.id-Y.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 g=Date,b=g.now();e.unstable_now=function(){return g.now()-b}}var v=[],w=[],S=1,A=null,R=3,_=!1,U=!1,T=!1,P=!1,F=typeof setTimeout=="function"?setTimeout:null,ae=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;function te(q){for(var Y=i(w);Y!==null;){if(Y.callback===null)r(w);else if(Y.startTime<=q)r(w),Y.sortIndex=Y.expirationTime,n(v,Y);else break;Y=i(w)}}function J(q){if(T=!1,te(q),!U)if(i(v)!==null)U=!0,se||(se=!0,Ne());else{var Y=i(w);Y!==null&&Le(J,Y.startTime-q)}}var se=!1,H=-1,G=5,ke=-1;function Ke(){return P?!0:!(e.unstable_now()-ke<G)}function He(){if(P=!1,se){var q=e.unstable_now();ke=q;var Y=!0;try{e:{U=!1,T&&(T=!1,ae(H),H=-1),_=!0;var fe=R;try{t:{for(te(q),A=i(v);A!==null&&!(A.expirationTime>q&&Ke());){var be=A.callback;if(typeof be=="function"){A.callback=null,R=A.priorityLevel;var ne=be(A.expirationTime<=q);if(q=e.unstable_now(),typeof ne=="function"){A.callback=ne,te(q),Y=!0;break t}A===i(v)&&r(v),te(q)}else r(v);A=i(v)}if(A!==null)Y=!0;else{var De=i(w);De!==null&&Le(J,De.startTime-q),Y=!1}}break e}finally{A=null,R=fe,_=!1}Y=void 0}}finally{Y?Ne():se=!1}}}var Ne;if(typeof L=="function")Ne=function(){L(He)};else if(typeof MessageChannel<"u"){var et=new MessageChannel,ze=et.port2;et.port1.onmessage=He,Ne=function(){ze.postMessage(null)}}else Ne=function(){F(He,0)};function Le(q,Y){H=F(function(){q(e.unstable_now())},Y)}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(q){q.callback=null},e.unstable_forceFrameRate=function(q){0>q||125<q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):G=0<q?Math.floor(1e3/q):5},e.unstable_getCurrentPriorityLevel=function(){return R},e.unstable_next=function(q){switch(R){case 1:case 2:case 3:var Y=3;break;default:Y=R}var fe=R;R=Y;try{return q()}finally{R=fe}},e.unstable_requestPaint=function(){P=!0},e.unstable_runWithPriority=function(q,Y){switch(q){case 1:case 2:case 3:case 4:case 5:break;default:q=3}var fe=R;R=q;try{return Y()}finally{R=fe}},e.unstable_scheduleCallback=function(q,Y,fe){var be=e.unstable_now();switch(typeof fe=="object"&&fe!==null?(fe=fe.delay,fe=typeof fe=="number"&&0<fe?be+fe:be):fe=be,q){case 1:var ne=-1;break;case 2:ne=250;break;case 5:ne=1073741823;break;case 4:ne=1e4;break;default:ne=5e3}return ne=fe+ne,q={id:S++,callback:Y,priorityLevel:q,startTime:fe,expirationTime:ne,sortIndex:-1},fe>be?(q.sortIndex=fe,n(w,q),i(v)===null&&q===i(w)&&(T?(ae(H),H=-1):T=!0,Le(J,fe-be))):(q.sortIndex=ne,n(v,q),U||_||(U=!0,se||(se=!0,Ne()))),q},e.unstable_shouldYield=Ke,e.unstable_wrapCallback=function(q){var Y=R;return function(){var fe=R;R=Y;try{return q.apply(this,arguments)}finally{R=fe}}}})(lh)),lh}var $b;function TC(){return $b||($b=1,rh.exports=_C()),rh.exports}var Ub;function RC(){if(Ub)return Dl;Ub=1;var e=TC(),n=H4(),i=Q4();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 g(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 w(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,l=a;;){var p=s.return;if(p===null)break;var f=p.alternate;if(f===null){if(l=p.return,l!==null){s=l;continue}break}if(p.child===f.child){for(f=p.child;f;){if(f===s)return v(p),t;if(f===l)return v(p),a;f=f.sibling}throw Error(r(188))}if(s.return!==l.return)s=p,l=f;else{for(var x=!1,k=p.child;k;){if(k===s){x=!0,s=p,l=f;break}if(k===l){x=!0,l=p,s=f;break}k=k.sibling}if(!x){for(k=f.child;k;){if(k===s){x=!0,s=f,l=p;break}if(k===l){x=!0,l=f,s=p;break}k=k.sibling}if(!x)throw Error(r(189))}}if(s.alternate!==l)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 A=Object.assign,R=Symbol.for("react.element"),_=Symbol.for("react.transitional.element"),U=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),F=Symbol.for("react.profiler"),ae=Symbol.for("react.consumer"),L=Symbol.for("react.context"),te=Symbol.for("react.forward_ref"),J=Symbol.for("react.suspense"),se=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),G=Symbol.for("react.lazy"),ke=Symbol.for("react.activity"),Ke=Symbol.for("react.memo_cache_sentinel"),He=Symbol.iterator;function Ne(t){return t===null||typeof t!="object"?null:(t=He&&t[He]||t["@@iterator"],typeof t=="function"?t:null)}var et=Symbol.for("react.client.reference");function ze(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===et?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case T:return"Fragment";case F:return"Profiler";case P:return"StrictMode";case J:return"Suspense";case se:return"SuspenseList";case ke:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case U:return"Portal";case L:return t.displayName||"Context";case ae:return(t._context.displayName||"Context")+".Consumer";case te:var a=t.render;return t=t.displayName,t||(t=a.displayName||a.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case H:return a=t.displayName||null,a!==null?a:ze(t.type)||"Memo";case G:a=t._payload,t=t._init;try{return ze(t(a))}catch{}}return null}var Le=Array.isArray,q=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,fe={pending:!1,data:null,method:null,action:null},be=[],ne=-1;function De(t){return{current:t}}function Oe(t){0>ne||(t.current=be[ne],be[ne]=null,ne--)}function ve(t,a){ne++,be[ne]=t.current,t.current=a}var oe=De(null),ue=De(null),K=De(null),ce=De(null);function Ue(t,a){switch(ve(K,a),ve(ue,t),ve(oe,null),a.nodeType){case 9:case 11:t=(t=a.documentElement)&&(t=t.namespaceURI)?ub(t):0;break;default:if(t=a.tagName,a=a.namespaceURI)a=ub(a),t=db(a,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}Oe(oe),ve(oe,t)}function xe(){Oe(oe),Oe(ue),Oe(K)}function Xe(t){t.memoizedState!==null&&ve(ce,t);var a=oe.current,s=db(a,t.type);a!==s&&(ve(ue,t),ve(oe,s))}function Ve(t){ue.current===t&&(Oe(oe),Oe(ue)),ce.current===t&&(Oe(ce),Tl._currentValue=fe)}var ut,Be;function re(t){if(ut===void 0)try{throw Error()}catch(s){var a=s.stack.trim().match(/\n( *(at )?)/);ut=a&&a[1]||"",Be=-1<s.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
4
|
`+ut+t+Be}var ct=!1;function Vt(t,a){if(!t||ct)return"";ct=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={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(Q){var $=Q}Reflect.construct(t,[],ie)}else{try{ie.call()}catch(Q){$=Q}t.call(ie.prototype)}}else{try{throw Error()}catch(Q){$=Q}(ie=t())&&typeof ie.catch=="function"&&ie.catch(function(){})}}catch(Q){if(Q&&$&&typeof Q.stack=="string")return[Q.stack,$.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var p=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");p&&p.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var f=l.DetermineComponentFrameRoot(),x=f[0],k=f[1];if(x&&k){var E=x.split(`
|
|
@@ -60,7 +60,7 @@ ${JSON.stringify(r.raw,null,2)}`):n.push(u)}return n.length>0?n.join(`
|
|
|
60
60
|
`);for(;te!==-1;){const J=P.slice(0,te);P=P.slice(te+2);for(const se of J.split(`
|
|
61
61
|
`)){if(!se.startsWith("data:"))continue;const H=se.slice(5).trim();if(!H)continue;let G;try{G=JSON.parse(H)}catch{continue}G.type==="stream_close"&&(_=!0),S(G)}te=P.indexOf(`
|
|
62
62
|
|
|
63
|
-
`)}}if(w?.aborted)throw new DOMException("Turn stopped","AbortError");if(!_)throw new Error("Connection ended before Aero finished. Review the partial answer before retrying.")}finally{w?.removeEventListener("abort",F);try{U.releaseLock()}catch{}}}function kf(e){return!e||e.role!=="assistant"?"":e.content.filter(n=>n.type==="text").map(n=>n.text).join("")}const TH=[{label:"Status",prompt:"Quick status overview for this project — latest runs, current health, anything unusual."},{label:"Top insights",prompt:"Walk me through the 3 most severe active insights and what to do about each."},{label:"Last failed run",prompt:"If the latest run failed, dig into it and tell me what went wrong plus how to fix it."},{label:"Schedule",prompt:"What is the current sweep schedule, and is it appropriate given recent volatility?"}],RH=[{command:"/status",label:"Status",prompt:"Quick status overview for this project — latest runs, current health, anything unusual."},{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 — provider mix, visibility changes, and anything that moved."},{command:"/last-failed",label:"Last failed run",prompt:"If the latest run failed, dig into it and tell me what went wrong plus how to fix it."},{command:"/run-sweep",label:"Run sweep now",prompt:"Run a new answer-visibility sweep for this project now and tell me when it lands."},{command:"/schedule",label:"Schedule",prompt:"What is the current sweep schedule, and is it appropriate given recent volatility?"},{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:"List this project's tracked competitors and call out which ones are showing up in answer citations."},{command:"/new",label:"New conversation (save current)",action:"new"}],Uu=e=>`canonry:aero:provider:${e}`,EH=e=>`canonry:aero:scope:${e}`;function tw(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function zH(e,n){if(!(typeof window>"u"))try{window.localStorage.setItem(e,n)}catch{}}function nw(e){if(!(typeof window>"u"))try{window.localStorage.removeItem(e)}catch{}}function DH({projectName:e,context:n}){const i=Js(),{canWrite:r}=na(),[u,h]=C.useState(!1),[g,b]=C.useState(!1),[v,w]=C.useState([]),[S,A]=C.useState(void 0),R=C.useRef(!1),[_,U]=C.useState(!1),[T,P]=C.useState(!1),[F,ae]=C.useState(null),[L,te]=C.useState(!1),[J,se]=C.useState(!1),[H,G]=C.useState(null),ke=C.useRef(!1),[Ke,He]=C.useState(""),[Ne,et]=C.useState(!1),[ze,Le]=C.useState([]),[q,Y]=C.useState(""),[fe,be]=C.useState(null),[ne,De]=C.useState(null),[Oe,ve]=C.useState(null),oe=C.useRef(!0),[ue,K]=C.useState(()=>tw(Uu(e))??null),ce=i?null:ue,[Ue]=C.useState(()=>tw(EH(e))==="all"?"all":"read-only"),xe=i?"read-only":Ue,Xe=C.useRef(null),Ve=C.useRef(null),ut=C.useRef(null),Be=C.useRef(null),{ref:re}=wH([v,q,ze]),ct=C.useRef(null),[Vt,qn]=C.useState(0),_t=C.useMemo(()=>{const le=Ke.trimStart();if(!le.startsWith("/"))return[];if(/\s/.test(le))return[];const _e=le.toLowerCase();return RH.filter(qe=>(!i||qe.command!=="/run-sweep")&&(qe.command.startsWith(_e)||qe.label.toLowerCase().includes(_e.slice(1))))},[Ke,i]);C.useEffect(()=>{qn(le=>_t.length===0?0:Math.min(le,_t.length-1))},[_t.length]);const Re=Nt({...sG({client:ee,path:{name:e}}),staleTime:6e4}),Je=C.useMemo(()=>{const le=Re.data?.providers??[];if(ce){const qe=le.find(cn=>cn.id===ce&&cn.configured);if(qe)return qe}const _e=Re.data?.defaultProvider;return _e?le.find(qe=>qe.id===_e)??null:null},[ce,Re.data]);C.useEffect(()=>{if(!Re.data||!ce)return;Re.data.providers.find(_e=>_e.id===ce&&_e.configured)||(K(null),nw(Uu(e)))},[Re.data,ce,e]);const Qt=C.useCallback(le=>{K(le),le?zH(Uu(e),le):nw(Uu(e))},[e]);C.useEffect(()=>{if(!u)return;const le=_e=>{_e.key==="Escape"&&(T?P(!1):g?b(!1):h(!1))};return window.addEventListener("keydown",le),()=>window.removeEventListener("keydown",le)},[u,g,T]),C.useEffect(()=>{if(!u||!Je)return;let le=!1;be(null);const _e=()=>{le||Ne||ke.current||Mh(e).then(bt=>{le||ke.current||(se(bt.isStreaming??!1),A(bt.conversationId??null),!le&&!bt.isStreaming&&(Ve.current===null||bt.updatedAt&&bt.updatedAt!==Ve.current.previous)&&(w(bt.messages),Xe.current=bt.updatedAt,Ve.current=null))}).catch(bt=>{le||be($l(bt))})};_e();const cn=window.setInterval(_e,15e3);return()=>{le=!0,window.clearInterval(cn)}},[u,e,Ne,Je,L]),C.useEffect(()=>(oe.current=!0,()=>{oe.current=!1,Be.current?.abort()}),[e]);async function bn(le,_e=n){const qe=le.trim();if(!qe||T||Ne||L||ke.current||J||!Je)return;if(i&&/^\/run-sweep(?:\s|$)/i.test(qe)){be(wf);return}be(null),De(null),ve({prompt:qe,context:_e}),He(""),et(!0),Y(""),ut.current=null,Le([]),Ve.current={previous:Xe.current};const cn={role:"user",content:qe,timestamp:Date.now(),aeroContext:_e};w(vn=>[...vn,cn]);const bt=new AbortController;Be.current=bt;try{await _H({project:e,prompt:qe,conversationId:S,provider:ce??void 0,scope:xe,context:_e,signal:bt.signal,onEvent:js});const vn=await Mh(e);oe.current&&!vn.isStreaming&&(A(vn.conversationId??null),w(vn.messages),Xe.current=vn.updatedAt,Ve.current=null)}catch(vn){if(!oe.current)return;const un=ut.current;un&&kf(un).trim()&&w(ia=>[...ia,un]),bt.signal.aborted?De("Stopped. Partial response preserved. An action already dispatched may still finish."):be($l(vn))}finally{oe.current&&(et(!1),Y(""),Le(vn=>vn.map(un=>un.endedAt===void 0?{...un,interrupted:!0}:un))),Be.current=null}}function js(le){if(oe.current)switch(le.type){case"message_update":le.message.role==="assistant"&&(ut.current=le.message),Y(kf(le.message));break;case"message_end":if(le.message.role!=="user"){const _e=le.message;w(qe=>[...qe,_e])}le.message.role==="assistant"&&(ut.current=null,Y(""),le.message.errorMessage&&be(le.message.errorMessage));break;case"aero_turn_status":le.status?.reason==="tool-limit"?De("Tool-call limit reached. Partial response preserved."):le.status?.reason==="time-limit"?De("Time limit reached. Partial response preserved."):le.status?.reason==="completed"&&ve(null);break;case"tool_execution_start":Le(_e=>[..._e,{id:le.toolCallId,name:le.toolName,label:le.label,args:le.args,startedAt:Date.now()}]);break;case"tool_execution_end":Le(_e=>_e.map(qe=>qe.id===le.toolCallId?{...qe,endedAt:Date.now(),isError:le.isError,result:le.result}:qe));break;case"error":be(le.message);break}}async function $t(le,_e=!1){if(!(Ne||J||ke.current)){ke.current=!0,te(!0),be(null);try{await le();const qe=await Mh(e);if(!oe.current)return;Ve.current=null,Xe.current=qe.updatedAt,A(qe.conversationId??null),w(qe.messages),Le([]),Y(""),De(null),ve(null),G(null),P(_e),ae(_e?await Tx(e):null),ct.current?.focus()}catch(qe){oe.current&&be($l(qe))}finally{ke.current=!1,oe.current&&te(!1)}}}async function Ma(){await $t(()=>UV(e,crypto.randomUUID()))}async function _i(le=!1){if(!(ke.current||R.current)){R.current=!0,U(!0),P(!0),be(null);try{const _e=await Tx(e,{offset:le?F?.nextOffset??0:0});oe.current&&ae(qe=>le&&qe?{..._e,conversations:[...qe.conversations,..._e.conversations]}:_e)}catch(_e){oe.current&&be($l(_e))}finally{R.current=!1,oe.current&&U(!1)}}}const As=v.length===0;if(Re.isPending)return null;if(Re.isError)return c.jsx("div",{className:"pointer-events-none fixed inset-x-0 bottom-0 z-40 flex justify-center p-3",children:c.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:[c.jsx(_u,{className:"h-4 w-4 text-muted","aria-hidden":"true"}),c.jsx("span",{className:"font-medium text-strong",children:"Aero could not check provider availability."}),c.jsx(me,{variant:"outline",size:"sm",className:"pointer-events-auto ml-auto",onClick:()=>{Re.refetch()},children:"Try again"})]})});const _n=Je&&!Je.configured?Je:null;if(!Je||_n)return c.jsx("div",{className:"pointer-events-none fixed inset-x-0 bottom-0 z-40 flex justify-center p-3",children:c.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:[c.jsx(_u,{className:"h-4 w-4 text-muted","aria-hidden":"true"}),c.jsxs("span",{className:"flex items-center gap-1.5 font-medium text-strong",children:[_n?`Aero is set to ${_n.label.replace(/\s+\(.+\)$/,"")}, which has no API key.`:"Aero needs an answer-engine provider.",c.jsx(Ws,{text:_n?`Set ${zj(_n.id)} on the server, or providers.${_n.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."})]}),_n?null:r?c.jsx(me,{asChild:!0,variant:"outline",size:"sm",className:"pointer-events-auto ml-auto",children:c.jsx(Fe,{to:"/settings",children:"Open Settings"})}):c.jsx("span",{className:"ml-auto text-secondary",children:"Ask an administrator to configure one."})]})});const go=u&&g?"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",yo=g?"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",bo=g?"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 c.jsx("div",{className:go,onClick:le=>{g&&le.target===le.currentTarget&&b(!1)},children:c.jsx("div",{className:yo,children:u?c.jsxs("div",{className:g?"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:[c.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-mono-800/70 px-4 py-2.5",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(_u,{className:"h-4 w-4 text-positive-400","aria-hidden":"true"}),c.jsx("span",{className:"text-sm font-medium text-heading",children:"Aero"}),c.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted",children:Ne||J?"working…":e})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[!i&&c.jsx(OH,{providers:Re.data?.providers??[],active:Je,override:ce,onPick:Qt,disabled:Ne}),c.jsx("button",{type:"button",onClick:()=>b(le=>!le),className:"rounded-md p-1.5 text-muted transition hover:bg-surface-inset hover:text-strong","aria-label":g?"Collapse":"Expand",title:g?"Collapse":"Expand",children:g?c.jsx(sC,{className:"h-3.5 w-3.5","aria-hidden":"true"}):c.jsx(oC,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),c.jsx("button",{type:"button",onClick:()=>{b(!1),h(!1)},className:"rounded-md p-1.5 text-muted transition hover:bg-surface-inset hover:text-strong","aria-label":"Close Aero",children:c.jsx(kr,{className:"h-4 w-4","aria-hidden":"true"})})]})]}),c.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-subtle px-4 py-2",children:[c.jsxs(me,{variant:"outline",size:"sm",disabled:Ne||J||L,onClick:an(Ma),title:"Save this conversation and start fresh. Shared project notes are kept.",children:[c.jsx(Vh,{className:"h-3.5 w-3.5","aria-hidden":"true"})," New conversation"]}),c.jsxs(me,{variant:"ghost",size:"sm","aria-expanded":T,"aria-controls":"aero-history",disabled:L,onClick:()=>{T?P(!1):_i()},children:[c.jsx(Aw,{className:"h-3.5 w-3.5","aria-hidden":"true"})," History"]})]}),T?c.jsxs("div",{id:"aero-history",className:bo,"aria-label":"Conversation history",children:[c.jsxs("h3",{className:"mb-2 text-sm font-medium text-heading",children:["Conversations in ",e]}),F?F.conversations.length===0?c.jsx("p",{className:"text-sm text-secondary",children:"No saved conversations yet. Your conversations will appear here."}):c.jsx("ul",{className:"divide-y divide-default",children:F.conversations.map(le=>c.jsxs("li",{className:"py-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.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:Ne||J||L,onClick:()=>{le.active?P(!1):$t(()=>GV(e,le.id))},children:[c.jsx("span",{className:"block truncate text-sm text-heading",children:le.title}),c.jsxs("span",{className:"text-xs text-secondary",children:[le.active?"Current · ":"",new Date(le.updatedAt).toLocaleString()]})]}),c.jsx(me,{variant:"ghost",size:"sm",disabled:Ne||J||L,"aria-label":`Delete conversation: ${le.title}`,onClick:()=>G(le.id),children:"Delete"})]}),H===le.id&&c.jsxs("div",{role:"group","aria-label":"Confirm conversation deletion",className:"mt-2 rounded-md border border-default p-3 text-sm text-secondary",children:[c.jsx("p",{children:"Delete this conversation permanently? Shared project notes will be kept."}),c.jsxs("div",{className:"mt-2 flex gap-2",children:[c.jsx(me,{variant:"destructive",size:"sm",disabled:L,onClick:()=>{$t(async()=>{await KV(e,le.id)},!0)},children:"Delete conversation"}),c.jsx(me,{variant:"ghost",size:"sm",disabled:L,onClick:()=>G(null),children:"Cancel"})]})]})]},le.id))}):c.jsx("p",{className:"text-sm text-secondary",children:_?"Loading history…":"History could not be loaded. Close and reopen History to retry."}),F?.nextOffset!=null&&c.jsx(me,{variant:"ghost",size:"sm",disabled:_,onClick:()=>{_i(!0)},children:_?"Loading…":"Load more"})]}):c.jsxs("div",{ref:re,className:bo,children:[As&&!Ne&&c.jsxs("div",{className:"flex flex-col gap-3 py-2",children:[c.jsxs("p",{className:"text-sm text-secondary",children:["Ask about ",c.jsx("span",{className:"text-strong",children:e})," or choose a starting point."]}),c.jsx("div",{className:"flex flex-wrap gap-1.5",children:TH.map(le=>c.jsx("button",{type:"button",onClick:()=>{bn(le.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:le.label},le.label))})]}),PH(v,e,ce,xe,ze,Ne),Ne&&q&&c.jsxs("div",{className:"mt-3",children:[c.jsx("div",{className:"mb-0.5 text-[10px] uppercase tracking-wider text-positive-400",children:"Aero"}),c.jsx(Dj,{content:q})]}),Ne&&!q&&ze.every(le=>le.endedAt!==void 0)&&c.jsx($H,{})]}),(fe||ne)&&c.jsxs("div",{role:fe?"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:[c.jsx("span",{className:"flex-1",children:fe??ne}),Oe&&!Ne&&c.jsx(me,{variant:"outline",size:"sm",onClick:()=>{xe==="all"?(He(Oe.prompt),ct.current?.focus()):bn(Oe.prompt,Oe.context)},children:xe==="all"?"Review prompt":"Retry"})]}),c.jsxs("div",{className:"relative",children:[!T&&_t.length>0&&c.jsx(qH,{matches:_t,selectedIndex:Vt,onHover:qn,onPick:le=>{He(""),ct.current?.focus(),le.action==="new"?Ma():bn(le.prompt)}}),c.jsxs("form",{className:"flex items-end gap-2 border-t border-mono-800/70 bg-bg/80 px-3 py-2.5",onSubmit:le=>{if(le.preventDefault(),_t.length>0){const _e=_t[Vt];He(""),_e.action==="new"?Ma():bn(_e.prompt);return}bn(Ke)},children:[c.jsx("textarea",{ref:ct,value:Ke,onChange:le=>He(le.target.value),onKeyDown:le=>{if(_t.length>0){if(le.key==="ArrowDown"){le.preventDefault(),qn(_e=>(_e+1)%_t.length);return}if(le.key==="ArrowUp"){le.preventDefault(),qn(_e=>(_e-1+_t.length)%_t.length);return}if(le.key==="Tab"){le.preventDefault();const _e=_t[Vt];He(`${_e.command} `);return}if(le.key==="Escape"){le.preventDefault(),He("");return}}if(le.key==="Enter"&&!le.shiftKey)if(le.preventDefault(),_t.length>0){const _e=_t[Vt];He(""),_e.action==="new"?Ma():bn(_e.prompt)}else bn(Ke)},disabled:T||L,placeholder:T?"Open a conversation to continue…":"Ask Aero, or / for commands…","aria-label":"Message Aero",rows:g?3:1,className:"flex-1 resize-none bg-transparent text-sm text-heading placeholder:text-mono-600 focus:outline-none disabled:opacity-60"}),Ne?c.jsxs(me,{type:"button",variant:"outline",size:"sm",onClick:()=>Be.current?.abort(),"aria-label":"Stop Aero",children:[c.jsx(rC,{className:"h-3.5 w-3.5","aria-hidden":"true"})," Stop"]}):c.jsx(me,{type:"submit",size:"sm",disabled:!Ke.trim()||T||L||J,"aria-label":"Send",children:c.jsx(lC,{className:"h-4 w-4","aria-hidden":"true"})})]})]})]}):c.jsx("button",{type:"button",onClick:()=>h(!0),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:c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx(_u,{className:"h-4 w-4 text-positive-400","aria-hidden":"true"}),"Ask Aero about ",e,"…"]})})})})}function OH({providers:e,active:n,override:i,onPick:r,disabled:u}){const[h,g]=C.useState(!1),b=C.useRef(null);if(C.useEffect(()=>{if(!h)return;const w=A=>{b.current?.contains(A.target)||g(!1)},S=A=>{A.key==="Escape"&&g(!1)};return window.addEventListener("mousedown",w),window.addEventListener("keydown",S),()=>{window.removeEventListener("mousedown",w),window.removeEventListener("keydown",S)}},[h]),e.length===0)return null;const v=n?.label.replace(/\s+\(.+\)$/,"")??"No provider";return c.jsxs("div",{ref:b,className:"relative",children:[c.jsxs("button",{type:"button",onClick:()=>g(w=>!w),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:[c.jsx("span",{className:"font-medium text-strong",children:v}),c.jsx(bd,{className:"h-3 w-3","aria-hidden":"true"})]}),h&&c.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:[c.jsx("div",{className:"border-b border-default px-3 py-2 text-sm font-medium text-secondary",children:"Answer engine"}),c.jsx("ul",{className:"max-h-72 overflow-y-auto py-1",children:e.map(w=>{const S=n?.id===w.id,A=i===w.id;return c.jsx("li",{children:c.jsxs("button",{type:"button",role:"option","aria-selected":S,disabled:!w.configured,onClick:()=>{w.configured&&(r(A?null:w.id),g(!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:w.configured?w.defaultModel:`Add ${zj(w.id)} in Settings or your environment`,children:[c.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:S?c.jsx(vd,{className:"h-3 w-3 text-positive-400","aria-hidden":"true"}):null}),c.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-heading",children:w.label.replace(/\s+\(.+\)$/,"")}),A&&c.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"}),!w.configured&&c.jsx("span",{className:"rounded-md border border-base px-2 py-0.5 text-[11px] text-secondary",children:"Needs setup"})]})},w.id)})}),i&&c.jsx("button",{type:"button",onClick:()=>{r(null),g(!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"})]})]})}function qH({matches:e,selectedIndex:n,onHover:i,onPick:r}){return c.jsxs("div",{className:"absolute inset-x-3 bottom-full mb-2 overflow-hidden rounded-lg border border-base bg-bg/98 shadow-2xl",children:[c.jsx("div",{className:"border-b border-default px-3 py-1.5 text-[10px] uppercase tracking-wider text-muted",children:"Commands"}),c.jsx("ul",{role:"listbox",className:"max-h-72 overflow-y-auto py-1",children:e.map((u,h)=>{const g=h===n;return c.jsx("li",{children:c.jsxs("button",{type:"button",role:"option","aria-selected":g,onMouseEnter:()=>i(h),onClick:()=>r(u),className:`flex w-full items-center gap-3 px-3 py-2 text-left text-sm transition ${g?"bg-bg-elevated text-heading":"text-neutral hover:bg-bg-elevated/60"}`,children:[c.jsx("span",{className:"font-medium",children:u.label}),c.jsx("span",{className:"ml-auto font-mono text-[11px] text-secondary",children:u.command})]})},u.command)})})]})}function zj(e){switch(e){case"claude":return"ANTHROPIC_API_KEY";case"openai":return"OPENAI_API_KEY";case"gemini":return"GOOGLE_API_KEY";case"zai":return"ZAI_API_KEY";case"deepinfra":return"DEEPINFRA_TOKEN"}}function IH(e,n){const i=e.timestamp??0;return`${e.role}:${i}:${n}`}function PH(e,n,i,r,u,h){const g=[];for(let b=0;b<e.length;b++){const v=e[b],w=IH(v,b);if(v.role==="user"){const S=typeof v.content=="string"?v.content:JSON.stringify(v.content);if(S.startsWith("[system]"))continue;g.push(c.jsx(MH,{text:S,projectName:n,providerOverride:i,scope:r,context:v.aeroContext},w));continue}if(v.role==="assistant"){const S=new Map;let A=b+1;for(;A<e.length&&e[A].role==="toolResult";){const U=e[A];S.set(U.toolCallId,U),A++}const R=LH(v,S).map(U=>{const T=u.find(F=>F.id===U.id),P={...U,...T};return{...P,interrupted:P.endedAt===void 0&&(!h||P.interrupted)}}),_=kf(v);g.push(c.jsxs(C.Fragment,{children:[_.trim()&&c.jsxs("div",{className:"mt-3",children:[c.jsx("div",{className:"mb-0.5 text-[10px] uppercase tracking-wider text-positive-400",children:"Aero"}),c.jsx(Dj,{content:_})]}),R.length>0&&c.jsx("div",{className:"mt-3 space-y-1.5",children:R.map(U=>c.jsx(VH,{trail:U},U.id))})]},w)),b=A-1;continue}}return g}function MH({text:e,projectName:n,providerOverride:i,scope:r,context:u}){const[h,g]=C.useState(!1),b=C.useMemo(()=>BH(n,e,i,r,u),[n,e,i,r,u]);async function v(){try{await navigator.clipboard.writeText(b),g(!0),window.setTimeout(()=>g(!1),1500)}catch{}}return c.jsxs("div",{className:"group relative mt-3 rounded-md bg-bg-elevated/60 px-3 py-2 text-strong",children:[c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted",children:"You"}),c.jsx("button",{type:"button",onClick:an(v),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:b,children:h?c.jsxs(c.Fragment,{children:[c.jsx(vd,{className:"h-2.5 w-2.5 text-positive-400","aria-hidden":"true"}),"Copied"]}):c.jsxs(c.Fragment,{children:[c.jsx(Rf,{className:"h-2.5 w-2.5","aria-hidden":"true"}),"Copy as CLI"]})})]}),c.jsx("div",{className:"whitespace-pre-wrap",children:e})]})}function BH(e,n,i,r,u){const h=["canonry","agent","ask",Eh(e),Eh(n)];return i&&h.push("--provider",i),r==="read-only"&&h.push("--scope","read-only"),u&&h.push("--context",Eh(JSON.stringify(u))),h.join(" ")}function LH(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}function VH({trail:e}){const[n,i]=C.useState(!1),r=e.endedAt===void 0&&!e.interrupted,u=!r&&e.isError===!0,h=e.durationMs??(e.endedAt!=null&&e.startedAt!=null?e.endedAt-e.startedAt:null),g=h==null||h<0?null:h<1e3?`${h}ms`:`${(h/1e3).toFixed(1)}s`,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 c.jsxs("div",{className:`rounded-md border ${b} ${v}`,children:[c.jsxs("button",{type:"button",onClick:()=>i(w=>!w),className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left","aria-expanded":n,children:[c.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:r?c.jsx(pr,{className:"h-3 w-3 animate-spin text-positive-400","aria-hidden":"true"}):u?c.jsx(Cw,{className:"h-3 w-3 text-negative-400","aria-hidden":"true"}):c.jsx(cC,{className:"h-3 w-3 text-muted","aria-hidden":"true"})}),c.jsx("span",{className:"text-sm font-medium text-heading",children:e.label??e.name.replace(/^(?:canonry|aero)_/,"").replace(/_/g," ")}),c.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-muted",children:[r?c.jsx("span",{className:"text-positive-400",children:"running…"}):c.jsxs(c.Fragment,{children:[c.jsx("span",{children:e.interrupted?"interrupted":u?"failed":"done"}),g&&c.jsx("span",{children:g})]}),c.jsx(Ef,{className:`h-3 w-3 transition-transform ${n?"rotate-90":""}`,"aria-hidden":"true"})]})]}),n&&c.jsxs("div",{className:"border-t border-default px-2.5 py-2 text-[11px] text-secondary",children:[c.jsx("div",{className:"mb-2 text-xs text-secondary",children:e.name}),c.jsx("div",{className:"mb-1 text-xs text-secondary",children:"Inputs"}),c.jsx("pre",{className:"mb-2 overflow-x-auto whitespace-pre-wrap break-all text-xs text-neutral",children:aw(e.args)}),!r&&e.result!==void 0&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"mb-1 text-[9px] uppercase tracking-wider text-faint",children:u?"Error":"Result"}),c.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-all text-xs text-neutral",children:aw(e.result)})]})]})]})}function aw(e){try{const n=typeof e=="string"?e:JSON.stringify(e,null,2);return n.length>2e3?`${n.slice(0,2e3)}
|
|
63
|
+
`)}}if(w?.aborted)throw new DOMException("Turn stopped","AbortError");if(!_)throw new Error("Connection ended before Aero finished. Review the partial answer before retrying.")}finally{w?.removeEventListener("abort",F);try{U.releaseLock()}catch{}}}function kf(e){return!e||e.role!=="assistant"?"":e.content.filter(n=>n.type==="text").map(n=>n.text).join("")}const TH=[{label:"Status",prompt:"Give me a quick status: the latest sweep, which engines answered, and anything that needs attention."},{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."},{label:"Biggest gaps",prompt:"Which tracked queries does no engine mention us on, and who gets named instead? Group them by topic or market."},{label:"Top insights",prompt:"Walk me through the 3 most severe active insights and what to do about each."}],RH=[{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"}],Uu=e=>`canonry:aero:provider:${e}`,EH=e=>`canonry:aero:scope:${e}`;function tw(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function zH(e,n){if(!(typeof window>"u"))try{window.localStorage.setItem(e,n)}catch{}}function nw(e){if(!(typeof window>"u"))try{window.localStorage.removeItem(e)}catch{}}function DH({projectName:e,context:n}){const i=Js(),{canWrite:r}=na(),[u,h]=C.useState(!1),[g,b]=C.useState(!1),[v,w]=C.useState([]),[S,A]=C.useState(void 0),R=C.useRef(!1),[_,U]=C.useState(!1),[T,P]=C.useState(!1),[F,ae]=C.useState(null),[L,te]=C.useState(!1),[J,se]=C.useState(!1),[H,G]=C.useState(null),ke=C.useRef(!1),[Ke,He]=C.useState(""),[Ne,et]=C.useState(!1),[ze,Le]=C.useState([]),[q,Y]=C.useState(""),[fe,be]=C.useState(null),[ne,De]=C.useState(null),[Oe,ve]=C.useState(null),oe=C.useRef(!0),[ue,K]=C.useState(()=>tw(Uu(e))??null),ce=i?null:ue,[Ue]=C.useState(()=>tw(EH(e))==="all"?"all":"read-only"),xe=i?"read-only":Ue,Xe=C.useRef(null),Ve=C.useRef(null),ut=C.useRef(null),Be=C.useRef(null),{ref:re}=wH([v,q,ze]),ct=C.useRef(null),[Vt,qn]=C.useState(0),_t=C.useMemo(()=>{const le=Ke.trimStart();if(!le.startsWith("/"))return[];if(/\s/.test(le))return[];const _e=le.toLowerCase();return RH.filter(qe=>(!i||qe.command!=="/run-sweep")&&(qe.command.startsWith(_e)||qe.label.toLowerCase().includes(_e.slice(1))))},[Ke,i]);C.useEffect(()=>{qn(le=>_t.length===0?0:Math.min(le,_t.length-1))},[_t.length]);const Re=Nt({...sG({client:ee,path:{name:e}}),staleTime:6e4}),Je=C.useMemo(()=>{const le=Re.data?.providers??[];if(ce){const qe=le.find(cn=>cn.id===ce&&cn.configured);if(qe)return qe}const _e=Re.data?.defaultProvider;return _e?le.find(qe=>qe.id===_e)??null:null},[ce,Re.data]);C.useEffect(()=>{if(!Re.data||!ce)return;Re.data.providers.find(_e=>_e.id===ce&&_e.configured)||(K(null),nw(Uu(e)))},[Re.data,ce,e]);const Qt=C.useCallback(le=>{K(le),le?zH(Uu(e),le):nw(Uu(e))},[e]);C.useEffect(()=>{if(!u)return;const le=_e=>{_e.key==="Escape"&&(T?P(!1):g?b(!1):h(!1))};return window.addEventListener("keydown",le),()=>window.removeEventListener("keydown",le)},[u,g,T]),C.useEffect(()=>{if(!u||!Je)return;let le=!1;be(null);const _e=()=>{le||Ne||ke.current||Mh(e).then(bt=>{le||ke.current||(se(bt.isStreaming??!1),A(bt.conversationId??null),!le&&!bt.isStreaming&&(Ve.current===null||bt.updatedAt&&bt.updatedAt!==Ve.current.previous)&&(w(bt.messages),Xe.current=bt.updatedAt,Ve.current=null))}).catch(bt=>{le||be($l(bt))})};_e();const cn=window.setInterval(_e,15e3);return()=>{le=!0,window.clearInterval(cn)}},[u,e,Ne,Je,L]),C.useEffect(()=>(oe.current=!0,()=>{oe.current=!1,Be.current?.abort()}),[e]);async function bn(le,_e=n){const qe=le.trim();if(!qe||T||Ne||L||ke.current||J||!Je)return;if(i&&/^\/run-sweep(?:\s|$)/i.test(qe)){be(wf);return}be(null),De(null),ve({prompt:qe,context:_e}),He(""),et(!0),Y(""),ut.current=null,Le([]),Ve.current={previous:Xe.current};const cn={role:"user",content:qe,timestamp:Date.now(),aeroContext:_e};w(vn=>[...vn,cn]);const bt=new AbortController;Be.current=bt;try{await _H({project:e,prompt:qe,conversationId:S,provider:ce??void 0,scope:xe,context:_e,signal:bt.signal,onEvent:js});const vn=await Mh(e);oe.current&&!vn.isStreaming&&(A(vn.conversationId??null),w(vn.messages),Xe.current=vn.updatedAt,Ve.current=null)}catch(vn){if(!oe.current)return;const un=ut.current;un&&kf(un).trim()&&w(ia=>[...ia,un]),bt.signal.aborted?De("Stopped. Partial response preserved. An action already dispatched may still finish."):be($l(vn))}finally{oe.current&&(et(!1),Y(""),Le(vn=>vn.map(un=>un.endedAt===void 0?{...un,interrupted:!0}:un))),Be.current=null}}function js(le){if(oe.current)switch(le.type){case"message_update":le.message.role==="assistant"&&(ut.current=le.message),Y(kf(le.message));break;case"message_end":if(le.message.role!=="user"){const _e=le.message;w(qe=>[...qe,_e])}le.message.role==="assistant"&&(ut.current=null,Y(""),le.message.errorMessage&&be(le.message.errorMessage));break;case"aero_turn_status":le.status?.reason==="tool-limit"?De("Tool-call limit reached. Partial response preserved."):le.status?.reason==="time-limit"?De("Time limit reached. Partial response preserved."):le.status?.reason==="completed"&&ve(null);break;case"tool_execution_start":Le(_e=>[..._e,{id:le.toolCallId,name:le.toolName,label:le.label,args:le.args,startedAt:Date.now()}]);break;case"tool_execution_end":Le(_e=>_e.map(qe=>qe.id===le.toolCallId?{...qe,endedAt:Date.now(),isError:le.isError,result:le.result}:qe));break;case"error":be(le.message);break}}async function $t(le,_e=!1){if(!(Ne||J||ke.current)){ke.current=!0,te(!0),be(null);try{await le();const qe=await Mh(e);if(!oe.current)return;Ve.current=null,Xe.current=qe.updatedAt,A(qe.conversationId??null),w(qe.messages),Le([]),Y(""),De(null),ve(null),G(null),P(_e),ae(_e?await Tx(e):null),ct.current?.focus()}catch(qe){oe.current&&be($l(qe))}finally{ke.current=!1,oe.current&&te(!1)}}}async function Ma(){await $t(()=>UV(e,crypto.randomUUID()))}async function _i(le=!1){if(!(ke.current||R.current)){R.current=!0,U(!0),P(!0),be(null);try{const _e=await Tx(e,{offset:le?F?.nextOffset??0:0});oe.current&&ae(qe=>le&&qe?{..._e,conversations:[...qe.conversations,..._e.conversations]}:_e)}catch(_e){oe.current&&be($l(_e))}finally{R.current=!1,oe.current&&U(!1)}}}const As=v.length===0;if(Re.isPending)return null;if(Re.isError)return c.jsx("div",{className:"pointer-events-none fixed inset-x-0 bottom-0 z-40 flex justify-center p-3",children:c.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:[c.jsx(_u,{className:"h-4 w-4 text-muted","aria-hidden":"true"}),c.jsx("span",{className:"font-medium text-strong",children:"Aero could not check provider availability."}),c.jsx(me,{variant:"outline",size:"sm",className:"pointer-events-auto ml-auto",onClick:()=>{Re.refetch()},children:"Try again"})]})});const _n=Je&&!Je.configured?Je:null;if(!Je||_n)return c.jsx("div",{className:"pointer-events-none fixed inset-x-0 bottom-0 z-40 flex justify-center p-3",children:c.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:[c.jsx(_u,{className:"h-4 w-4 text-muted","aria-hidden":"true"}),c.jsxs("span",{className:"flex items-center gap-1.5 font-medium text-strong",children:[_n?`Aero is set to ${_n.label.replace(/\s+\(.+\)$/,"")}, which has no API key.`:"Aero needs an answer-engine provider.",c.jsx(Ws,{text:_n?`Set ${zj(_n.id)} on the server, or providers.${_n.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."})]}),_n?null:r?c.jsx(me,{asChild:!0,variant:"outline",size:"sm",className:"pointer-events-auto ml-auto",children:c.jsx(Fe,{to:"/settings",children:"Open Settings"})}):c.jsx("span",{className:"ml-auto text-secondary",children:"Ask an administrator to configure one."})]})});const go=u&&g?"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",yo=g?"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",bo=g?"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 c.jsx("div",{className:go,onClick:le=>{g&&le.target===le.currentTarget&&b(!1)},children:c.jsx("div",{className:yo,children:u?c.jsxs("div",{className:g?"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:[c.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-mono-800/70 px-4 py-2.5",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(_u,{className:"h-4 w-4 text-positive-400","aria-hidden":"true"}),c.jsx("span",{className:"text-sm font-medium text-heading",children:"Aero"}),c.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted",children:Ne||J?"working…":e})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[!i&&c.jsx(OH,{providers:Re.data?.providers??[],active:Je,override:ce,onPick:Qt,disabled:Ne}),c.jsx("button",{type:"button",onClick:()=>b(le=>!le),className:"rounded-md p-1.5 text-muted transition hover:bg-surface-inset hover:text-strong","aria-label":g?"Collapse":"Expand",title:g?"Collapse":"Expand",children:g?c.jsx(sC,{className:"h-3.5 w-3.5","aria-hidden":"true"}):c.jsx(oC,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),c.jsx("button",{type:"button",onClick:()=>{b(!1),h(!1)},className:"rounded-md p-1.5 text-muted transition hover:bg-surface-inset hover:text-strong","aria-label":"Close Aero",children:c.jsx(kr,{className:"h-4 w-4","aria-hidden":"true"})})]})]}),c.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-subtle px-4 py-2",children:[c.jsxs(me,{variant:"outline",size:"sm",disabled:Ne||J||L,onClick:an(Ma),title:"Save this conversation and start fresh. Shared project notes are kept.",children:[c.jsx(Vh,{className:"h-3.5 w-3.5","aria-hidden":"true"})," New conversation"]}),c.jsxs(me,{variant:"ghost",size:"sm","aria-expanded":T,"aria-controls":"aero-history",disabled:L,onClick:()=>{T?P(!1):_i()},children:[c.jsx(Aw,{className:"h-3.5 w-3.5","aria-hidden":"true"})," History"]})]}),T?c.jsxs("div",{id:"aero-history",className:bo,"aria-label":"Conversation history",children:[c.jsxs("h3",{className:"mb-2 text-sm font-medium text-heading",children:["Conversations in ",e]}),F?F.conversations.length===0?c.jsx("p",{className:"text-sm text-secondary",children:"No saved conversations yet. Your conversations will appear here."}):c.jsx("ul",{className:"divide-y divide-default",children:F.conversations.map(le=>c.jsxs("li",{className:"py-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.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:Ne||J||L,onClick:()=>{le.active?P(!1):$t(()=>GV(e,le.id))},children:[c.jsx("span",{className:"block truncate text-sm text-heading",children:le.title}),c.jsxs("span",{className:"text-xs text-secondary",children:[le.active?"Current · ":"",new Date(le.updatedAt).toLocaleString()]})]}),c.jsx(me,{variant:"ghost",size:"sm",disabled:Ne||J||L,"aria-label":`Delete conversation: ${le.title}`,onClick:()=>G(le.id),children:"Delete"})]}),H===le.id&&c.jsxs("div",{role:"group","aria-label":"Confirm conversation deletion",className:"mt-2 rounded-md border border-default p-3 text-sm text-secondary",children:[c.jsx("p",{children:"Delete this conversation permanently? Shared project notes will be kept."}),c.jsxs("div",{className:"mt-2 flex gap-2",children:[c.jsx(me,{variant:"destructive",size:"sm",disabled:L,onClick:()=>{$t(async()=>{await KV(e,le.id)},!0)},children:"Delete conversation"}),c.jsx(me,{variant:"ghost",size:"sm",disabled:L,onClick:()=>G(null),children:"Cancel"})]})]})]},le.id))}):c.jsx("p",{className:"text-sm text-secondary",children:_?"Loading history…":"History could not be loaded. Close and reopen History to retry."}),F?.nextOffset!=null&&c.jsx(me,{variant:"ghost",size:"sm",disabled:_,onClick:()=>{_i(!0)},children:_?"Loading…":"Load more"})]}):c.jsxs("div",{ref:re,className:bo,children:[As&&!Ne&&c.jsxs("div",{className:"flex flex-col gap-3 py-2",children:[c.jsxs("p",{className:"text-sm text-secondary",children:["Ask about ",c.jsx("span",{className:"text-strong",children:e})," or choose a starting point."]}),c.jsx("div",{className:"flex flex-wrap gap-1.5",children:TH.map(le=>c.jsx("button",{type:"button",onClick:()=>{bn(le.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:le.label},le.label))})]}),PH(v,e,ce,xe,ze,Ne),Ne&&q&&c.jsxs("div",{className:"mt-3",children:[c.jsx("div",{className:"mb-0.5 text-[10px] uppercase tracking-wider text-positive-400",children:"Aero"}),c.jsx(Dj,{content:q})]}),Ne&&!q&&ze.every(le=>le.endedAt!==void 0)&&c.jsx($H,{})]}),(fe||ne)&&c.jsxs("div",{role:fe?"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:[c.jsx("span",{className:"flex-1",children:fe??ne}),Oe&&!Ne&&c.jsx(me,{variant:"outline",size:"sm",onClick:()=>{xe==="all"?(He(Oe.prompt),ct.current?.focus()):bn(Oe.prompt,Oe.context)},children:xe==="all"?"Review prompt":"Retry"})]}),c.jsxs("div",{className:"relative",children:[!T&&_t.length>0&&c.jsx(qH,{matches:_t,selectedIndex:Vt,onHover:qn,onPick:le=>{He(""),ct.current?.focus(),le.action==="new"?Ma():bn(le.prompt)}}),c.jsxs("form",{className:"flex items-end gap-2 border-t border-mono-800/70 bg-bg/80 px-3 py-2.5",onSubmit:le=>{if(le.preventDefault(),_t.length>0){const _e=_t[Vt];He(""),_e.action==="new"?Ma():bn(_e.prompt);return}bn(Ke)},children:[c.jsx("textarea",{ref:ct,value:Ke,onChange:le=>He(le.target.value),onKeyDown:le=>{if(_t.length>0){if(le.key==="ArrowDown"){le.preventDefault(),qn(_e=>(_e+1)%_t.length);return}if(le.key==="ArrowUp"){le.preventDefault(),qn(_e=>(_e-1+_t.length)%_t.length);return}if(le.key==="Tab"){le.preventDefault();const _e=_t[Vt];He(`${_e.command} `);return}if(le.key==="Escape"){le.preventDefault(),He("");return}}if(le.key==="Enter"&&!le.shiftKey)if(le.preventDefault(),_t.length>0){const _e=_t[Vt];He(""),_e.action==="new"?Ma():bn(_e.prompt)}else bn(Ke)},disabled:T||L,placeholder:T?"Open a conversation to continue…":"Ask Aero, or / for commands…","aria-label":"Message Aero",rows:g?3:1,className:"flex-1 resize-none bg-transparent text-sm text-heading placeholder:text-mono-600 focus:outline-none disabled:opacity-60"}),Ne?c.jsxs(me,{type:"button",variant:"outline",size:"sm",onClick:()=>Be.current?.abort(),"aria-label":"Stop Aero",children:[c.jsx(rC,{className:"h-3.5 w-3.5","aria-hidden":"true"})," Stop"]}):c.jsx(me,{type:"submit",size:"sm",disabled:!Ke.trim()||T||L||J,"aria-label":"Send",children:c.jsx(lC,{className:"h-4 w-4","aria-hidden":"true"})})]})]})]}):c.jsx("button",{type:"button",onClick:()=>h(!0),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:c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx(_u,{className:"h-4 w-4 text-positive-400","aria-hidden":"true"}),"Ask Aero about ",e,"…"]})})})})}function OH({providers:e,active:n,override:i,onPick:r,disabled:u}){const[h,g]=C.useState(!1),b=C.useRef(null);if(C.useEffect(()=>{if(!h)return;const w=A=>{b.current?.contains(A.target)||g(!1)},S=A=>{A.key==="Escape"&&g(!1)};return window.addEventListener("mousedown",w),window.addEventListener("keydown",S),()=>{window.removeEventListener("mousedown",w),window.removeEventListener("keydown",S)}},[h]),e.length===0)return null;const v=n?.label.replace(/\s+\(.+\)$/,"")??"No provider";return c.jsxs("div",{ref:b,className:"relative",children:[c.jsxs("button",{type:"button",onClick:()=>g(w=>!w),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:[c.jsx("span",{className:"font-medium text-strong",children:v}),c.jsx(bd,{className:"h-3 w-3","aria-hidden":"true"})]}),h&&c.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:[c.jsx("div",{className:"border-b border-default px-3 py-2 text-sm font-medium text-secondary",children:"Answer engine"}),c.jsx("ul",{className:"max-h-72 overflow-y-auto py-1",children:e.map(w=>{const S=n?.id===w.id,A=i===w.id;return c.jsx("li",{children:c.jsxs("button",{type:"button",role:"option","aria-selected":S,disabled:!w.configured,onClick:()=>{w.configured&&(r(A?null:w.id),g(!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:w.configured?w.defaultModel:`Add ${zj(w.id)} in Settings or your environment`,children:[c.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:S?c.jsx(vd,{className:"h-3 w-3 text-positive-400","aria-hidden":"true"}):null}),c.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-heading",children:w.label.replace(/\s+\(.+\)$/,"")}),A&&c.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"}),!w.configured&&c.jsx("span",{className:"rounded-md border border-base px-2 py-0.5 text-[11px] text-secondary",children:"Needs setup"})]})},w.id)})}),i&&c.jsx("button",{type:"button",onClick:()=>{r(null),g(!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"})]})]})}function qH({matches:e,selectedIndex:n,onHover:i,onPick:r}){return c.jsxs("div",{className:"absolute inset-x-3 bottom-full mb-2 overflow-hidden rounded-lg border border-base bg-bg/98 shadow-2xl",children:[c.jsx("div",{className:"border-b border-default px-3 py-1.5 text-[10px] uppercase tracking-wider text-muted",children:"Commands"}),c.jsx("ul",{role:"listbox",className:"max-h-72 overflow-y-auto py-1",children:e.map((u,h)=>{const g=h===n;return c.jsx("li",{children:c.jsxs("button",{type:"button",role:"option","aria-selected":g,onMouseEnter:()=>i(h),onClick:()=>r(u),className:`flex w-full items-center gap-3 px-3 py-2 text-left text-sm transition ${g?"bg-bg-elevated text-heading":"text-neutral hover:bg-bg-elevated/60"}`,children:[c.jsx("span",{className:"font-medium",children:u.label}),c.jsx("span",{className:"ml-auto font-mono text-[11px] text-secondary",children:u.command})]})},u.command)})})]})}function zj(e){switch(e){case"claude":return"ANTHROPIC_API_KEY";case"openai":return"OPENAI_API_KEY";case"gemini":return"GOOGLE_API_KEY";case"zai":return"ZAI_API_KEY";case"deepinfra":return"DEEPINFRA_TOKEN"}}function IH(e,n){const i=e.timestamp??0;return`${e.role}:${i}:${n}`}function PH(e,n,i,r,u,h){const g=[];for(let b=0;b<e.length;b++){const v=e[b],w=IH(v,b);if(v.role==="user"){const S=typeof v.content=="string"?v.content:JSON.stringify(v.content);if(S.startsWith("[system]"))continue;g.push(c.jsx(MH,{text:S,projectName:n,providerOverride:i,scope:r,context:v.aeroContext},w));continue}if(v.role==="assistant"){const S=new Map;let A=b+1;for(;A<e.length&&e[A].role==="toolResult";){const U=e[A];S.set(U.toolCallId,U),A++}const R=LH(v,S).map(U=>{const T=u.find(F=>F.id===U.id),P={...U,...T};return{...P,interrupted:P.endedAt===void 0&&(!h||P.interrupted)}}),_=kf(v);g.push(c.jsxs(C.Fragment,{children:[_.trim()&&c.jsxs("div",{className:"mt-3",children:[c.jsx("div",{className:"mb-0.5 text-[10px] uppercase tracking-wider text-positive-400",children:"Aero"}),c.jsx(Dj,{content:_})]}),R.length>0&&c.jsx("div",{className:"mt-3 space-y-1.5",children:R.map(U=>c.jsx(VH,{trail:U},U.id))})]},w)),b=A-1;continue}}return g}function MH({text:e,projectName:n,providerOverride:i,scope:r,context:u}){const[h,g]=C.useState(!1),b=C.useMemo(()=>BH(n,e,i,r,u),[n,e,i,r,u]);async function v(){try{await navigator.clipboard.writeText(b),g(!0),window.setTimeout(()=>g(!1),1500)}catch{}}return c.jsxs("div",{className:"group relative mt-3 rounded-md bg-bg-elevated/60 px-3 py-2 text-strong",children:[c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted",children:"You"}),c.jsx("button",{type:"button",onClick:an(v),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:b,children:h?c.jsxs(c.Fragment,{children:[c.jsx(vd,{className:"h-2.5 w-2.5 text-positive-400","aria-hidden":"true"}),"Copied"]}):c.jsxs(c.Fragment,{children:[c.jsx(Rf,{className:"h-2.5 w-2.5","aria-hidden":"true"}),"Copy as CLI"]})})]}),c.jsx("div",{className:"whitespace-pre-wrap",children:e})]})}function BH(e,n,i,r,u){const h=["canonry","agent","ask",Eh(e),Eh(n)];return i&&h.push("--provider",i),r==="read-only"&&h.push("--scope","read-only"),u&&h.push("--context",Eh(JSON.stringify(u))),h.join(" ")}function LH(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}function VH({trail:e}){const[n,i]=C.useState(!1),r=e.endedAt===void 0&&!e.interrupted,u=!r&&e.isError===!0,h=e.durationMs??(e.endedAt!=null&&e.startedAt!=null?e.endedAt-e.startedAt:null),g=h==null||h<0?null:h<1e3?`${h}ms`:`${(h/1e3).toFixed(1)}s`,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 c.jsxs("div",{className:`rounded-md border ${b} ${v}`,children:[c.jsxs("button",{type:"button",onClick:()=>i(w=>!w),className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left","aria-expanded":n,children:[c.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:r?c.jsx(pr,{className:"h-3 w-3 animate-spin text-positive-400","aria-hidden":"true"}):u?c.jsx(Cw,{className:"h-3 w-3 text-negative-400","aria-hidden":"true"}):c.jsx(cC,{className:"h-3 w-3 text-muted","aria-hidden":"true"})}),c.jsx("span",{className:"text-sm font-medium text-heading",children:e.label??e.name.replace(/^(?:canonry|aero)_/,"").replace(/_/g," ")}),c.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-muted",children:[r?c.jsx("span",{className:"text-positive-400",children:"running…"}):c.jsxs(c.Fragment,{children:[c.jsx("span",{children:e.interrupted?"interrupted":u?"failed":"done"}),g&&c.jsx("span",{children:g})]}),c.jsx(Ef,{className:`h-3 w-3 transition-transform ${n?"rotate-90":""}`,"aria-hidden":"true"})]})]}),n&&c.jsxs("div",{className:"border-t border-default px-2.5 py-2 text-[11px] text-secondary",children:[c.jsx("div",{className:"mb-2 text-xs text-secondary",children:e.name}),c.jsx("div",{className:"mb-1 text-xs text-secondary",children:"Inputs"}),c.jsx("pre",{className:"mb-2 overflow-x-auto whitespace-pre-wrap break-all text-xs text-neutral",children:aw(e.args)}),!r&&e.result!==void 0&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"mb-1 text-[9px] uppercase tracking-wider text-faint",children:u?"Error":"Result"}),c.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-all text-xs text-neutral",children:aw(e.result)})]})]})]})}function aw(e){try{const n=typeof e=="string"?e:JSON.stringify(e,null,2);return n.length>2e3?`${n.slice(0,2e3)}
|
|
64
64
|
… (${n.length-2e3} more chars)`:n}catch{return String(e)}}function Dj({content:e}){return c.jsx("div",{className:"text-heading",children:c.jsx(AC,{remarkPlugins:[CC],components:{h1:n=>c.jsx("h1",{...n,className:"mt-3 mb-2 text-base font-semibold text-primary"}),h2:n=>c.jsx("h2",{...n,className:"mt-3 mb-2 text-sm font-semibold text-primary"}),h3:n=>c.jsx("h3",{...n,className:"mt-3 mb-1.5 text-sm font-semibold text-heading"}),h4:n=>c.jsx("h4",{...n,className:"mt-2 mb-1 text-xs font-semibold uppercase tracking-wide text-neutral"}),p:n=>c.jsx("p",{...n,className:"mb-2 leading-relaxed"}),ul:n=>c.jsx("ul",{...n,className:"mb-2 ml-4 list-disc space-y-1"}),ol:n=>c.jsx("ol",{...n,className:"mb-2 ml-4 list-decimal space-y-1"}),li:n=>c.jsx("li",{...n,className:"marker:text-mono-600"}),strong:n=>c.jsx("strong",{...n,className:"font-semibold text-primary"}),em:n=>c.jsx("em",{...n,className:"text-strong"}),code:({children:n,...i})=>c.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=>c.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=>c.jsx("a",{...n,className:"text-positive-400 underline decoration-positive-700 hover:decoration-positive-400",target:"_blank",rel:"noopener noreferrer"}),table:n=>c.jsx("div",{className:"mb-2 overflow-x-auto",children:c.jsx("table",{...n,className:"w-full border-collapse text-xs"})}),thead:n=>c.jsx("thead",{...n,className:"border-b border-base"}),th:n=>c.jsx("th",{...n,className:"px-2 py-1 text-left font-semibold text-neutral"}),tr:n=>c.jsx("tr",{...n,className:"border-b border-mono-900"}),td:n=>c.jsx("td",{...n,className:"px-2 py-1 text-strong"}),blockquote:n=>c.jsx("blockquote",{...n,className:"mb-2 border-l-2 border-strong pl-3 italic text-secondary"}),hr:()=>c.jsx("hr",{className:"my-3 border-base"})},children:e})})}function $H(){return c.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[c.jsx("div",{className:"text-[10px] uppercase tracking-wider text-positive-400",children:"Aero"}),c.jsxs("div",{className:"flex items-center gap-1","aria-label":"Aero is thinking",children:[c.jsx("span",{className:"aero-dot h-1.5 w-1.5 rounded-full bg-positive-400/80"}),c.jsx("span",{className:"aero-dot aero-dot-2 h-1.5 w-1.5 rounded-full bg-positive-400/60"}),c.jsx("span",{className:"aero-dot aero-dot-3 h-1.5 w-1.5 rounded-full bg-positive-400/40"})]})]})}function UH(){const{isAdmin:e}=na(),n=yw(),i=/^\/projects\/([^/]+)/.exec(n.pathname),r=i?decodeURIComponent(i[1]):null,u=Nt({...po({client:ee}),enabled:r!==null,staleTime:6e4}),h=xH(n.pathname,n.search),g=u.data??[],b=g.find(w=>w.id===r)??g.find(w=>w.name===r),v=l$(b?.name??r??"",h);return!r||!e||!b?null:c.jsx(DH,{projectName:b.name,context:v},b.name)}const Sf={project:"getApiV1ProjectsByName",google:"getApiV1ProjectsByNameGoogle",gsc:"getApiV1ProjectsByNameGoogleGsc",bing:"getApiV1ProjectsByNameBing",ga:"getApiV1ProjectsByNameGa",gbp:"getApiV1ProjectsByNameGbp",ads:"getApiV1ProjectsByNameAds",googleAds:"getApiV1ProjectsByNameGoogleAds",gtm:"getApiV1ProjectsByNameGtm",conversionTracking:"getApiV1ProjectsByNameConversionTracking",traffic:"getApiV1ProjectsByNameTraffic",discovery:"getApiV1ProjectsByNameDiscover",researchRuns:"getApiV1ProjectsByNameResearchRuns",visibilityReport:"getApiV1ProjectsByNameVisibilityReport",queryTracking:"getApiV1ProjectsByNameQueryTracking",technicalAeo:"getApiV1ProjectsByNameTechnicalAeo",runs:"getApiV1ProjectsByNameRuns"};function Sn(e,n){const i=Sf[n];return e.invalidateQueries({predicate:r=>{const u=r.queryKey[0];return typeof u?._id=="string"&&u._id.startsWith(i)}})}function Lee(e,n){return e.invalidateQueries({predicate:i=>{const r=i.queryKey[0];return r?.path?.name!==n||typeof r._id!="string"?!1:r._id.startsWith("getApiV1ProjectsByNameMeasurement")||r._id===Sf.queryTracking||r._id===Sf.visibilityReport||r._id==="getApiV1ProjectsByNameQueries"||r._id==="getApiV1ProjectsByName"}})}function ac(e,n,i){switch(e.invalidateQueries({queryKey:J0({client:ee})}),e.invalidateQueries({queryKey:hs({client:ee})}),Sn(e,"runs"),n){case Ee["answer-visibility"]:xf(e,i,"none"),Sn(e,"visibilityReport"),Sn(e,"queryTracking");return;case Ee["backlink-extract"]:return;case Ee["site-audit"]:Sn(e,"technicalAeo");return;case Ee["gsc-sync"]:case Ee["inspect-sitemap"]:Sn(e,"gsc");return;case Ee["ga-sync"]:Sn(e,"ga");return;case Ee["traffic-sync"]:Sn(e,"ga"),Sn(e,"traffic");return;case Ee["bing-inspect"]:case Ee["bing-inspect-sitemap"]:Sn(e,"bing");return;case Ee["aeo-discover-seed"]:case Ee["aeo-discover-probe"]:xf(e,i);return;case Ee["gbp-sync"]:Sn(e,"gbp");return;case Ee["ads-sync"]:Sn(e,"ads");return;case Ee["google-ads-sync"]:Sn(e,"googleAds"),Sn(e,"conversionTracking");return;case Ee["gtm-sync"]:Sn(e,"gtm"),Sn(e,"conversionTracking");return;default:return n}}const iw=[{label:"GitHub",href:"https://github.com/Canonry/canonry",Icon:jw},{label:"Docs",href:"https://github.com/Canonry/canonry/tree/main/docs",Icon:yC},{label:"Changelog",href:"https://github.com/Canonry/canonry/releases",Icon:bC}],sw=e=>({label:e,state:"checking",detail:"Checking service health"}),GH={apiStatus:sw("API"),workerStatus:sw("Worker")};function KH(e){return e==="completed"?"positive":e==="partial"?"caution":"negative"}function HH(e){const n=Ql(e.kind);return e.status==="completed"?`${n} completed`:e.status==="partial"?`${n} completed with partial results`:e.status==="cancelled"?`${n} cancelled`:`${n} failed`}function QH(e,n){return e.error?`${n}: ${w0(e.error)}`:e.location?`${n} · ${e.location}`:n}function ow(e,n,i){if(n)return n;const r=i.find(u=>u.id===e);return r?.displayName||r?.name||e}function FH(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 ZH(e){return e.failed>0||e.cancelled>0?"negative":e.partial>0?"caution":"positive"}function YH(){const e=ka(),n=C.useSyncExternalStore(nj,Ci,Ci),i=Object.keys(n.runs).length>0||Object.keys(n.batches).length>0,r=Nt({...Yd({client:ee}),enabled:i,staleTime:xr,refetchInterval:3e3}),u=Nt({...po({client:ee}),enabled:i}),h=C.useRef({}),g=C.useCallback(()=>{r.refetch()},[r.refetch]);return C.useEffect(()=>{i&&g()},[i,g]),C.useEffect(()=>{if(!i||typeof window>"u")return;const b=()=>{document.visibilityState==="visible"&&g()};return window.addEventListener("focus",g),document.addEventListener("visibilitychange",b),()=>{window.removeEventListener("focus",g),document.removeEventListener("visibilitychange",b)}},[i,g]),C.useEffect(()=>{const b=r.data??[],v=u.data??[],w=Object.fromEntries(b.map(A=>[A.id,A])),S=Object.fromEntries(b.map(A=>[A.id,A.status]));for(const A of Object.values(n.runs)){const R=w[A.runId];if(!R||!gG(R.status)||(h.current[R.id]??A.lastAnnouncedStatus)===R.status)continue;const U=v.find(P=>P.id===R.projectId);if(U&&ac(e,R.kind,U.name),A.sourceAction==="run-all"){Dh(R.id);continue}const T=ow(R.projectId,A.projectLabel,v);ln({title:HH(R),detail:QH(R,T),tone:KH(R.status),dedupeKey:`run:${R.id}`,dedupeMode:"replace",cta:{label:"View run",intent:"open-run-drawer",runId:R.id}}),Dh(R.id)}if(r.data!==void 0){const A=new Set(b.map(_=>_.id)),R=bG(Object.values(n.runs),A,Date.now(),yG);for(const _ of R){const U=v.find(T=>T.id===_.projectId);U&&ac(e,_.kind,U.name),_.sourceAction!=="run-all"&&ln({title:`${Ql(_.kind)} status unavailable`,detail:ow(_.projectId,_.projectLabel,v),tone:"neutral",dedupeKey:`run-stale:${_.runId}`,dedupeMode:"replace"}),Dh(_.runId)}}for(const A of Object.values(n.batches)){const R=vG(A.runIds,w);R.finished&&(ln({title:"Run-all batch finished",detail:FH(R,A.skippedCount),tone:ZH(R),dedupeKey:`batch:${A.batchId}`,dedupeMode:"replace",cta:{label:"View runs",intent:"go-to-runs"}}),fG(A.batchId))}h.current=S},[u.data,r.data,n,e]),null}function XH(){const{account:e,isAdmin:n}=na(),i=yc(),r=C.useMemo(()=>M3(),[]),u=C.useMemo(rV,[]),g=C.useMemo(lV,[])&&n,b=C.useMemo(cV,[]),v=yw(),{dashboard:w,isLoading:S,refetch:A}=tm(void 0,{includeSettings:!r,includeOverviews:!1,pauseProjectPolling:v.pathname==="/setup"}),U=ig(!i,i?.health).data??i?.health??GH,{runId:T,evidenceId:P,closeDrawer:F}=sg(),[ae,L]=C.useState(!1),[te,J]=C.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem("canonry:sidebarHidden")==="true"}catch{return!1}}),[se,H]=C.useState(()=>{if(typeof window>"u")return null;try{return window.localStorage.getItem("canonry:dismissedUpdateVersion")}catch{return null}}),[G]=C.useState(()=>typeof window>"u"?null:new URLSearchParams(window.location.search).get("force-update")),ke=G?{current:U.apiStatus.version??"0.0.0",latest:G,url:"https://www.npmjs.com/package/@canonry/canonry",upgradeCommand:"npm install -g @canonry/canonry"}:U.apiStatus.updateAvailable,Ke=b&&ke&&ke.latest!==se,He=()=>{if(ke){try{window.localStorage.setItem("canonry:dismissedUpdateVersion",ke.latest)}catch{}H(ke.latest)}},Ne=()=>{const re=!te;try{re?window.localStorage.setItem("canonry:sidebarHidden","true"):window.localStorage.removeItem("canonry:sidebarHidden")}catch{}J(re)},et=oH(T),ze=et.data??null,Le=et.isLoading;C.useEffect(()=>{ze&&ze.status!=="running"&&ze.status!=="queued"&&A()},[ze?.status,A]),C.useEffect(()=>{L(!1)},[v.pathname]),C.useEffect(()=>{if(typeof window>"u"||!T&&!P)return;const re=ct=>{ct.key==="Escape"&&F()};return window.addEventListener("keydown",re),()=>{window.removeEventListener("keydown",re)}},[T,P,F]);const q=w??i?.dashboard??null,Y=v.pathname==="/setup",fe=Y&&q!==null&&q.portfolioOverview.projects.length===0,be=Y&&(v.search.onboarding==="site-health"||v.search.onboarding==="first-run"||v.search.onboarding==="complete"),[ne,De]=C.useState(fe);C.useEffect(()=>{Y?fe&&De(!0):De(!1)},[fe,Y]);const ve=Y&&(be||fe||ne||Y&&q===null),oe=ve?"app-shell-focus":te?"app-shell-sidebar-hidden":"",ue=T?(q?EK(q,T):void 0)??(ze?em(ze,q?.projects.find(re=>re.project.id===ze.projectId)?.project.displayName??q?.projects.find(re=>re.project.id===ze.projectId)?.project.name??"Unknown project"):void 0):void 0,K=C.useMemo(()=>AK(v.pathname,q),[v.pathname,q]),{commandCenter:ce,evidenceLoading:Ue,evidenceError:xe,isError:Xe,refetch:Ve}=aH(P?K:null,{evidence:!0}),ut=C.useMemo(()=>{if(P)return DK(ce,q,P)},[P,ce,q]),Be=(()=>{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 ct=q?.projects.find(Vt=>Vt.project.name===K);return ct?.project.displayName||ct?.project.name||K||"Projects"}return"Not found"})();if(r){const re=!r.views||r.views.includes(h$(v.pathname));return c.jsxs("div",{className:"app-shell app-shell-embed","data-theme":v$(r.theme),style:x$(r.theme),children:[c.jsx("a",{className:"skip-link",href:"#content",children:"Skip to content"}),c.jsx("main",{id:"content",className:"page-shell",children:re?c.jsx(Lh,{}):c.jsx("div",{className:"embed-view-unavailable",role:"status",children:"This view is not available in embed mode."})})]})}return c.jsxs(c.Fragment,{children:[c.jsx("a",{className:"skip-link",href:"#content",children:"Skip to content"}),c.jsx(pH,{}),c.jsxs("div",{className:`app-shell ${oe}${Hl()?" app-shell-demo":""}`,children:[!ve&&!te&&c.jsxs("aside",{id:"desktop-sidebar",className:"sidebar","aria-label":"Primary navigation",children:[c.jsx("div",{className:"sidebar-brand",children:c.jsx(Kx,{version:U.apiStatus.version,updateAvailable:Ke?ke:null,onDismissUpdate:He})}),c.jsxs("nav",{className:"sidebar-nav",children:[c.jsxs(Fe,{to:"/",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[c.jsx(uC,{className:"sidebar-icon"}),c.jsx("span",{children:"Portfolio"})]}),c.jsxs(Fe,{to:"/projects",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!1},children:[c.jsx(dC,{className:"sidebar-icon"}),c.jsx("span",{children:"Projects"})]}),c.jsxs(Fe,{to:"/runs",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[c.jsx(mC,{className:"sidebar-icon"}),c.jsx("span",{children:"Runs"})]}),c.jsxs(Fe,{to:"/history",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[c.jsx(Aw,{className:"sidebar-icon"}),c.jsx("span",{children:"History"})]}),c.jsxs(Fe,{to:"/traffic",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!1},children:[c.jsx(pC,{className:"sidebar-icon"}),c.jsx("span",{children:"Traffic sources"})]}),!Hl()&&c.jsxs(Fe,{to:"/backlinks",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[c.jsx(hC,{className:"sidebar-icon"}),c.jsx("span",{children:"Backlink data"})]}),n&&c.jsxs(Fe,{to:"/settings",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[c.jsx(fC,{className:"sidebar-icon"}),c.jsx("span",{children:"Settings"})]}),S?c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"sidebar-section-title",children:"Tracked projects"}),[1,2,3].map(re=>c.jsxs("div",{className:"sidebar-skeleton-item",children:[c.jsx("span",{className:"skeleton-circle size-2"}),c.jsx("span",{className:"skeleton-text flex-1",style:{width:`${50+re*15}%`}})]},re))]}):q&&q.projects.length>0?c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"sidebar-section-title",children:"Tracked projects"}),q.projects.map(re=>{const ct=re.visibilitySummary.tone;return c.jsxs(Fe,{to:"/projects/$projectName",params:{projectName:re.project.name},className:"sidebar-project",activeProps:{className:"sidebar-project sidebar-project-active"},children:[c.jsx("span",{className:`sidebar-dot sidebar-dot-${ct}`}),c.jsx("span",{children:re.project.displayName||re.project.name})]},re.project.id)})]}):S?null:c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"sidebar-section-title",children:"Resources"}),n&&c.jsxs(Fe,{to:"/setup",className:"sidebar-link",activeProps:{className:"sidebar-link sidebar-link-active"},activeOptions:{exact:!0},children:[c.jsx(gC,{className:"sidebar-icon"}),c.jsx("span",{children:"Setup"})]})]})]}),e&&c.jsxs("div",{className:"sidebar-account",children:[c.jsxs("div",{className:"sidebar-account-identity",children:[c.jsx("span",{className:"sidebar-account-name",children:e.name}),e.role==="viewer"?c.jsx("span",{className:"sidebar-account-role",children:jx()}):null]}),c.jsx(me,{type:"button",variant:"ghost",size:"sm",onClick:an(async()=>{await _x(),window.location.reload()}),children:"Sign out"})]}),u?c.jsx("div",{className:"sidebar-footer",children:iw.map(({label:re,href:ct,Icon:Vt})=>c.jsx("a",{className:"sidebar-footer-icon",href:ct,target:"_blank",rel:"noopener noreferrer",title:re,"aria-label":re,children:c.jsx(Vt,{className:"size-4"})},ct))}):null]}),c.jsxs("div",{className:"main-area",children:[c.jsxs("header",{className:"topbar",children:[c.jsxs("div",{className:"topbar-left",children:[!ve&&c.jsx(me,{className:"sidebar-privacy-toggle",variant:"ghost",size:"icon",type:"button","aria-label":te?"Show sidebar":"Hide sidebar","aria-controls":te?void 0:"desktop-sidebar","aria-expanded":!te,title:te?"Show sidebar":"Hide sidebar",onClick:Ne,children:te?c.jsx(vC,{className:"size-4"}):c.jsx(xC,{className:"size-4"})}),c.jsx("div",{className:"topbar-brand-mobile",children:c.jsx(Kx,{compact:!0})}),c.jsxs("nav",{className:"breadcrumb","aria-label":"Breadcrumb",children:[c.jsx(Fe,{to:"/",children:"Home"}),c.jsx(Ef,{className:"breadcrumb-sep size-3"}),c.jsx("span",{className:"breadcrumb-current",children:Be})]})]}),c.jsxs("div",{className:"topbar-actions",children:[c.jsx(hH,{}),c.jsxs("div",{className:"health-pill-row",children:[c.jsxs("span",{className:`health-pill health-pill-${U.apiStatus.state}`,title:wr(U.apiStatus),children:["API ",U.apiStatus.state==="ok"?"ok":U.apiStatus.state]}),c.jsx("span",{className:`health-pill health-pill-${U.workerStatus.state}`,title:wr(U.workerStatus),children:`Worker ${U.workerStatus.state==="ok"?"ok":U.workerStatus.state}`})]}),ve?null:c.jsxs(me,{className:"nav-toggle",variant:"secondary",size:"icon",type:"button","aria-expanded":ae,"aria-controls":"mobile-nav",onClick:()=>L(re=>!re),children:[c.jsx(wC,{className:"size-4"}),c.jsx("span",{className:"sr-only",children:"Open navigation"})]})]})]}),ve?null:c.jsxs("div",{id:"mobile-nav",className:`mobile-nav ${ae?"mobile-nav-open":""}`,children:[c.jsxs(me,{className:"mobile-nav-close",variant:"ghost",size:"icon",type:"button",onClick:()=>L(!1),children:[c.jsx(kr,{className:"size-5"}),c.jsx("span",{className:"sr-only",children:"Close navigation"})]}),c.jsx(Fe,{to:"/",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Portfolio"}),c.jsx(Fe,{to:"/projects",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!1},children:"Projects"}),c.jsx(Fe,{to:"/runs",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Runs"}),c.jsx(Fe,{to:"/history",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"History"}),c.jsx(Fe,{to:"/traffic",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!1},children:"Traffic sources"}),!Hl()&&c.jsx(Fe,{to:"/backlinks",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Backlink data"}),n&&c.jsx(Fe,{to:"/settings",className:"mobile-nav-link",activeProps:{className:"mobile-nav-link mobile-nav-link-active"},activeOptions:{exact:!0},children:"Settings"}),q&&q.projects.length>0?c.jsxs("div",{className:"mobile-nav-section",children:[c.jsx("p",{className:"mobile-nav-section-title",children:"Tracked projects"}),q.projects.map(re=>c.jsx(Fe,{to:"/projects/$projectName",params:{projectName:re.project.name},className:"mobile-nav-link",children:re.project.name},re.project.id))]}):null,e&&c.jsxs("div",{className:"mobile-nav-section",children:[c.jsx("p",{className:"mobile-nav-section-title",children:"Signed in"}),c.jsxs("div",{className:"sidebar-account",children:[c.jsxs("div",{className:"sidebar-account-identity",children:[c.jsx("span",{className:"sidebar-account-name",children:e.name}),e.role==="viewer"?c.jsx("span",{className:"sidebar-account-role",children:jx()}):null]}),c.jsx(me,{type:"button",variant:"ghost",size:"sm","data-testid":"mobile-sign-out",onClick:an(async()=>{await _x(),window.location.reload()}),children:"Sign out"})]})]})]}),c.jsx("main",{id:"content",className:`page-shell ${g&&K?"pb-20":""}`.trim(),children:S&&!i?c.jsxs("div",{className:"page-skeleton",children:[c.jsxs("div",{className:"page-skeleton-header",children:[c.jsx("div",{className:"skeleton-text h-6 w-40"}),c.jsx("div",{className:"skeleton-text-sm w-72"})]}),c.jsx("div",{className:"page-skeleton-grid",children:[1,2,3].map(re=>c.jsxs("div",{className:"page-skeleton-card",children:[c.jsx("div",{className:"skeleton-text w-24"}),c.jsx("div",{className:"skeleton-text w-full"}),c.jsx("div",{className:"skeleton-text-sm w-3/4"})]},re))}),c.jsx("div",{className:"page-skeleton-grid",style:{gridTemplateColumns:"1fr 1fr"},children:[1,2].map(re=>c.jsxs("div",{className:"page-skeleton-card",children:[c.jsx("div",{className:"skeleton-text w-20"}),c.jsx("div",{className:"space-y-2",children:[1,2,3].map(ct=>c.jsx("div",{className:"skeleton-text-sm w-full"},ct))})]},re))})]}):c.jsx(Lh,{})}),c.jsxs("footer",{className:"footer",children:[c.jsxs("span",{className:"footer-brand",children:[c.jsx("span",{children:c.jsx("a",{href:"https://canonry.ai",children:"Canonry"})}),U.apiStatus.version&&U.apiStatus.version!=="unknown"?c.jsxs("span",{className:"footer-version",children:["v",U.apiStatus.version]}):null]}),u?c.jsx("div",{className:"footer-links",children:iw.map(({label:re,href:ct,Icon:Vt})=>c.jsx("a",{href:ct,target:"_blank",rel:"noopener noreferrer",title:re,"aria-label":re,className:"footer-icon",children:c.jsx(Vt,{className:"size-3.5"})},ct))}):null]})]}),T&&!ue&&Le?c.jsx($u,{open:!0,title:"Loading run details",subtitle:"Fetching the durable run record",onClose:F,children:c.jsx("p",{className:"text-sm text-muted",role:"status",children:"Loading run details…"})}):null,T&&!ue&&et.isError?c.jsx($u,{open:!0,title:"Run unavailable",subtitle:"The run could not be loaded",onClose:F,children:c.jsx("p",{className:"text-sm text-negative",children:et.error instanceof Error?et.error.message:"Run details are unavailable."})}):null,ue?c.jsxs($u,{open:!0,title:ue.summary,subtitle:`${ue.projectName} · ${ue.kindLabel}`,onClose:F,children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-1 text-sm",children:[c.jsx(ag,{status:ue.status}),c.jsx("span",{className:"text-secondary",children:ue.startedAt}),c.jsx("span",{className:"text-muted",children:ue.duration}),c.jsx("span",{className:"text-faint",children:ue.triggerLabel})]}),ue.status==="failed"&&ue.statusDetail&&c.jsx("p",{className:"mt-2 text-sm text-negative",children:ue.statusDetail}),c.jsxs("div",{className:"mt-4",children:[c.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted mb-2",children:"Activity Log"}),Le?c.jsx("p",{className:"text-sm text-muted",children:"Loading run details..."}):ze?.snapshots&&ze.snapshots.length>0?c.jsxs("div",{className:"space-y-2",children:[ze.snapshots.map(re=>c.jsxs("div",{className:"rounded-lg border border-default bg-surface p-3",children:[c.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[c.jsx("p",{className:"text-sm font-medium text-strong truncate",children:re.query??"Unknown query"}),c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(mK,{provider:re.provider}),c.jsx(bj,{variant:re.citationState===cd.cited?"success":"neutral",children:re.citationState})]})]}),re.model&&c.jsx("p",{className:"text-[11px] text-muted font-mono",children:re.model}),re.citedDomains.length>0&&c.jsxs("p",{className:"text-xs text-muted mt-1",children:[c.jsx("span",{className:"text-secondary",children:"Sources:"})," ",re.citedDomains.join(", ")]}),re.citedCompetitorDomains.length>0&&c.jsxs("p",{className:"text-xs text-negative-400/80 mt-0.5",children:["Competitor cited: ",re.citedCompetitorDomains.join(", ")]}),re.mentionedCompetitorDomains.length>0&&c.jsxs("p",{className:"text-xs text-negative-400/80 mt-0.5",children:["Competitor mentioned: ",re.mentionedCompetitorDomains.join(", ")]}),re.groundingSources&&re.groundingSources.length>0&&c.jsxs("details",{className:"mt-2",children:[c.jsxs("summary",{className:"text-xs text-muted cursor-pointer hover:text-secondary",children:[re.groundingSources.length," grounding source",re.groundingSources.length!==1?"s":""]}),c.jsx("ul",{className:"mt-1 space-y-0.5",children:re.groundingSources.map((ct,Vt)=>{const qn=vf(ct.uri),_t=ct.title||ct.uri;return c.jsx("li",{className:"text-xs text-muted truncate",children:qn?c.jsx("a",{href:qn,target:"_blank",rel:"noopener noreferrer",className:"hover:text-neutral",children:_t}):c.jsx("span",{children:_t})},Vt)})})]}),re.answerText&&c.jsxs("details",{className:"mt-1",children:[c.jsx("summary",{className:"text-xs text-muted cursor-pointer hover:text-secondary",children:"Answer preview"}),c.jsx("p",{className:"mt-1 text-xs text-secondary leading-relaxed whitespace-pre-wrap",children:re.answerText})]})]},re.id)),ze.status==="running"&&c.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-muted",children:[c.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-caution-500 animate-pulse"}),"Running remaining queries..."]})]}):ze&&ze.status==="running"?c.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-muted",children:[c.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-caution-500 animate-pulse"}),"Waiting for first query result..."]}):ze&&ze.status==="queued"?c.jsxs("div",{className:"flex items-center gap-2 p-3 text-sm text-muted",children:[c.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-mono-500 animate-pulse"}),"Run queued, waiting for execution slot..."]}):ze&&ze.error?c.jsxs("div",{className:"rounded-lg border border-negative-800/40 bg-negative-950/20 p-3",children:[c.jsx("p",{className:"text-sm font-medium text-negative mb-2",children:"Run failed"}),c.jsx("pre",{className:"max-h-48 overflow-y-auto whitespace-pre-wrap break-words font-mono text-xs leading-5 text-negative",children:d$(ze.error)})]}):c.jsx("p",{className:"text-sm text-muted",children:"No snapshot data available."})]})]}):null,P&&!ut?c.jsx($u,{open:!0,title:Ue?"Loading answer":"Answer unavailable",subtitle:"Query evidence",onClose:F,children:Ue?c.jsx("p",{role:"status",className:"text-sm text-secondary",children:"Loading answer…"}):c.jsxs(c.Fragment,{children:[c.jsx("p",{role:"alert",className:"text-sm text-secondary",children:xe||Xe?"Could not load this answer.":"This answer is not in the available query evidence."}),c.jsx(me,{type:"button",variant:"outline",onClick:()=>{Ve()},children:"Retry"})]})}):null,ut?c.jsx(kK,{evidence:ut.evidence,project:ut.project,onClose:F}):null,c.jsx(YH,{}),c.jsx(cH,{}),g?c.jsx(UH,{}):null]})]})}class JH extends C.Component{state={error:null};static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,i){console.error("[ErrorBoundary]",n,i.componentStack)}handleReset=()=>{this.setState({error:null})};render(){return this.state.error?c.jsx("div",{className:"page-container",children:c.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 py-20 text-center",children:[c.jsx("div",{className:"rounded-full bg-negative-950/40 p-3",children:c.jsx(Cw,{className:"size-6 text-negative-400"})}),c.jsx("h2",{className:"text-lg font-semibold text-heading",children:"Something went wrong"}),c.jsx("p",{className:"text-sm text-secondary max-w-md",children:this.state.error.message||"An unexpected error occurred while rendering this page."}),c.jsxs("div",{className:"flex gap-3 mt-2",children:[c.jsxs(me,{variant:"secondary",size:"sm",onClick:this.handleReset,children:[c.jsx(kC,{className:"size-3.5 mr-1.5"}),"Try again"]}),c.jsx(me,{variant:"secondary",size:"sm",onClick:()=>{const n=window.__CANONRY_CONFIG__?.basePath?.replace(/\/$/,"")??"";window.location.href=n||"/"},children:"Go home"})]})]})}):this.props.children}}const ba=C.forwardRef(({className:e,...n},i)=>c.jsx("div",{ref:i,className:ja("rounded-xl border border-base bg-bg/75 shadow-[0_0_0_1px_var(--color-shadow-hairline)]",e),...n}));ba.displayName="Card";const ur=C.forwardRef(({className:e,...n},i)=>c.jsx("div",{ref:i,className:ja("flex flex-col gap-1.5 p-5",e),...n}));ur.displayName="CardHeader";const Oj=C.forwardRef(({className:e,...n},i)=>c.jsx("h3",{ref:i,className:ja("font-medium tracking-tight text-primary",e),...n}));Oj.displayName="CardTitle";const hd=C.forwardRef(({className:e,...n},i)=>c.jsx("p",{ref:i,className:ja("text-sm text-muted",e),...n}));hd.displayName="CardDescription";const eo=C.forwardRef(({className:e,...n},i)=>c.jsx("div",{ref:i,className:ja("p-5 pt-0",e),...n}));eo.displayName="CardContent";const WH=20,eQ=6;function tQ({points:e,tone:n}){const i=C.useId();if(e.length===0)return null;const r=42,u=132,h=5,g=u-h*2,b=r-h*2,v=b-eQ,w=P=>h+P/Math.max(e.length-1,1)*g,S=UL(e),A=Math.min(...e),R=Math.max(...e),_=Math.max(R-A,WH),U=(R+A)/2-_/2,T=e.map((P,F)=>({x:w(F),y:h+(1-(P-U)/_)*v}));return c.jsxs("svg",{className:`sparkline sparkline-${n}${S?" sparkline-provisional":""}`,viewBox:`0 0 ${u} ${r}`,"aria-hidden":"true",children:[c.jsx("defs",{children:c.jsx("clipPath",{id:i,children:c.jsx("rect",{x:h,y:h,width:g,height:b,rx:"8"})})}),c.jsx("line",{className:"sparkline-guide",x1:h,x2:u-h,y1:r-h,y2:r-h}),T.length===1?c.jsx("circle",{className:"sparkline-point",cx:T[0].x,cy:T[0].y,r:"3"}):c.jsx("polyline",{clipPath:`url(#${i})`,points:T.map(P=>`${P.x},${P.y}`).join(" "),vectorEffect:"non-scaling-stroke"})]})}function nQ({project:e}){return c.jsxs(Fe,{to:"/projects/$projectName",params:{projectName:e.project.name},className:"project-row cursor-pointer",children:[c.jsx("div",{className:"project-row-chart",children:c.jsx(tQ,{points:e.trend,tone:W3(e.lastRun.status)})}),c.jsxs("div",{className:"project-row-primary",children:[c.jsxs("div",{children:[c.jsx("p",{className:"project-name",children:e.project.name}),c.jsx("p",{className:"project-domain",children:e.project.canonicalDomain})]}),c.jsx("p",{className:"project-insight",children:e.insight})]}),c.jsx("div",{className:"project-row-stat",children:c.jsxs("div",{className:"metric-inline-block",children:[c.jsx("p",{className:"metric-inline-label",children:"Mentioned"}),c.jsx("p",{className:`metric-inline-value ${e.mentionTone==="caution"?"text-caution-400":""}`,children:e.hasMeasurement===!1?"Not measured":e.mentionScore}),c.jsx("p",{className:`metric-inline-caption${e.providerCoverage?" text-caution":""}`,title:e.providerCoverage,children:e.providerCoverage?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"sr-only",children:"Partial sweep: "}),e.providerCoverage]}):e.mentionDelta})]})}),c.jsx("div",{className:"project-row-stat",children:c.jsxs("div",{className:"metric-inline-block",children:[c.jsxs("p",{className:"metric-inline-label",children:[c.jsx("span",{"aria-hidden":"true",children:"Pressure"}),c.jsx("span",{className:"sr-only",children:"Competitor pressure"})]}),c.jsx("p",{className:"metric-inline-value",children:e.hasMeasurement===!1?"Not measured":e.competitorPressureLabel}),c.jsx("p",{className:"metric-inline-caption","aria-hidden":"true"})]})}),c.jsx("span",{className:"project-row-link",children:c.jsx(Ef,{className:"h-4 w-4 text-muted"})})]})}function aQ(){const{isAdmin:e}=na(),n=yc(),{dashboard:i,isLoading:r,isError:u,refetch:h}=tm(),g=i??n?.dashboard,v=ig(!n,n?.health),{openRun:w}=sg();if(u&&!g)return c.jsxs("div",{className:"page-container",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Portfolio unavailable"}),c.jsx("p",{className:"page-subtitle",children:"Canonry could not load the project list."})]})}),c.jsxs("div",{className:"max-w-xl rounded-lg border border-negative bg-negative-soft p-4",role:"alert",children:[c.jsx("p",{className:"text-sm font-medium text-heading",children:"Your projects have not been changed."}),c.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Check the connection or sign in again, then retry."}),c.jsx(me,{type:"button",variant:"secondary",className:"mt-4",onClick:()=>{h()},children:"Retry loading portfolio"})]})]});if(!g||r)return c.jsxs("div",{className:"page-skeleton",children:[c.jsxs("div",{className:"page-skeleton-header",children:[c.jsx("div",{className:"skeleton-text h-6 w-32"}),c.jsx("div",{className:"skeleton-text-sm w-64"})]}),c.jsx("div",{className:"space-y-3",children:[1,2,3].map(T=>c.jsxs("div",{className:"rounded-xl border border-default bg-surface p-4 flex items-center gap-4",children:[c.jsxs("div",{className:"flex-1 space-y-2",children:[c.jsx("div",{className:"skeleton-text w-36"}),c.jsx("div",{className:"skeleton-text-sm w-48"})]}),c.jsx("div",{className:"skeleton-text w-16"}),c.jsx("div",{className:"skeleton-text w-16"}),c.jsx("div",{className:"skeleton h-8 w-20 rounded"})]},T))})]});const S=g.portfolioOverview,A=S.projects.length>0&&S.projects.every(T=>T.hasMeasurement===!1),R=S.attentionItems.map(T=>A&&T.id==="attention_stable"?{...T,tone:"neutral",title:"Awaiting first measurement",detail:"Visibility results will appear after the first sweep."}:T),_=v.data??n?.health??{apiStatus:{label:"API",state:"checking",detail:"Checking service health"},workerStatus:{label:"Worker",state:"checking",detail:"Checking service health"}},U=rG(S.systemHealth.filter(T=>e||T.id==="api"||T.id==="worker"),_,g.settings);return c.jsxs("div",{className:"page-container",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Portfolio"}),c.jsx("p",{className:"page-subtitle",children:"Visibility across all projects."})]})}),S.projects.length>0?c.jsx("div",{className:"project-list project-list-scrollable",children:S.projects.map(T=>c.jsx(nQ,{project:T},T.project.id))}):c.jsxs(ba,{className:"surface-card empty-card",children:[c.jsx("h3",{children:S.emptyState?.title??"No projects yet"}),c.jsx("p",{className:"supporting-copy",children:S.emptyState?.detail}),c.jsx(me,{size:"sm",asChild:!0,children:c.jsx(Fe,{to:S.emptyState?.ctaHref==="/setup"||!S.emptyState?.ctaHref?"/setup":"/",children:S.emptyState?.ctaLabel??"Launch setup"})})]}),c.jsxs("div",{className:"overview-secondary-grid",children:[R.length>0&&c.jsxs("section",{className:"overview-secondary-section",children:[c.jsx("div",{className:"section-head section-head-inline",children:c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Needs attention"}),c.jsx("h2",{className:"section-title-sm",children:"What changed"})]})}),c.jsx("div",{className:"attention-list attention-list-scrollable",children:R.map(T=>T.href?c.jsxs(Fe,{to:T.href,className:`attention-item attention-item-${T.tone}`,children:[c.jsxs("div",{children:[c.jsx("p",{className:"attention-title",children:T.title}),c.jsx("p",{className:"attention-detail",children:T.detail})]}),T.actionLabel&&c.jsx("span",{className:"attention-action",children:T.actionLabel})]},T.id):c.jsxs("div",{className:`attention-item attention-item-static attention-item-${T.tone}`,children:[c.jsxs("div",{children:[c.jsx("p",{className:"attention-title",children:T.title}),c.jsx("p",{className:"attention-detail",children:T.detail})]}),T.actionLabel&&c.jsx("span",{className:"attention-action",children:T.actionLabel})]},T.id))})]}),c.jsxs("section",{className:"overview-secondary-section",children:[c.jsx("div",{className:"section-head section-head-inline",children:c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Recent runs"}),c.jsx("h2",{className:"section-title-sm",children:"Activity"})]})}),c.jsx("div",{className:"compact-stack compact-stack-scrollable",children:S.recentRuns.length>0?S.recentRuns.map(T=>c.jsxs("button",{className:"compact-run",type:"button",onClick:()=>w(T.id),children:[c.jsxs("div",{children:[c.jsx("p",{className:"compact-run-title",children:T.projectName}),c.jsx("p",{className:"compact-run-detail",children:T.summary})]}),c.jsx(ag,{status:T.status})]},T.id)):c.jsx("p",{className:"supporting-copy",children:"Run history appears here after the first launch."})})]})]}),c.jsxs("section",{className:"page-section",children:[c.jsx("div",{className:"section-head section-head-inline",children:c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"System health"}),c.jsx("h2",{className:"section-title-sm",children:"Infrastructure"})]})}),c.jsx("div",{className:"divide-y divide-default border-y border-default",children:U.map(T=>{const P=T.id==="api"?_.apiStatus:T.id==="worker"?_.workerStatus:void 0,F=P?P.state==="ok"?void 0:wr(P):T.tone==="positive"?void 0:T.meta;return c.jsxs("div",{className:"flex items-start justify-between gap-4 py-3",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm font-medium text-heading",children:T.label}),F&&c.jsx("p",{className:"mt-1 text-sm text-secondary",children:F})]}),c.jsx(jn,{tone:T.tone,title:P?wr(P):T.meta,children:T.detail})]},T.id)})})]})]})}const iQ='a, button, input, select, textarea, label, [role="button"], [role="link"], [role="checkbox"], [role="menuitem"]';function sQ(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(iQ))return!1;const i=typeof window<"u"?window.getSelection():null;return!(i&&!i.isCollapsed&&i.toString().trim()!=="")}function oQ({onApplied:e}){const{canWrite:n}=na(),[i,r]=C.useState(""),[u,h]=C.useState(!1),[g,b]=C.useState([]),[v,w]=C.useState([]);if(mV()||!n)return null;const S=async()=>{if(!i.trim())return;h(!0),b([]),w([]);const A=NC(i),R=[],_=[];for(let U=0;U<A.length;U++){const T=A[U];if(T.errors.length>0){R.push(`Document ${U+1}: ${T.errors[0]?.message}`);continue}const P=T.toJSON();if(!(!P||typeof P!="object"))try{const F=await IV(P);_.push(`Applied "${F.displayName||F.name}" (revision ${F.configRevision})`)}catch(F){R.push(`Document ${U+1}: ${$l(F)}`)}}b(_),w(R),h(!1),_.length>0&&(ln({title:"YAML applied",detail:`Applied ${_.length} document${_.length===1?"":"s"} successfully.`,tone:R.length>0?"caution":"positive",dedupeKey:"yaml:apply",dedupeMode:"replace"}),e())};return c.jsxs("section",{className:"mt-8",children:[c.jsx("div",{className:"page-section-divider"}),c.jsx("div",{className:"section-head mt-6",children:c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Config as code"}),c.jsx("h2",{className:"text-sm font-medium text-strong",children:"Apply YAML"})]})}),c.jsxs("p",{className:"text-muted text-sm mb-3",children:["Paste a ",c.jsx("code",{className:"text-secondary",children:"canonry.yaml"})," config (multi-document YAML with ",c.jsx("code",{className:"text-secondary",children:"---"})," separators supported)."]}),c.jsx("textarea",{className:"setup-input w-full font-mono text-xs",rows:10,placeholder:`apiVersion: canonry/v1
|
|
65
65
|
kind: Project
|
|
66
66
|
metadata:
|
|
@@ -83,4 +83,4 @@ spec:
|
|
|
83
83
|
`);js($e),bo(!0)}}catch(V){qr(V instanceof Error?V.message:"Failed to generate queries"),ae({flowVersion:lt,onboardingSessionId:P,event:"onboarding.blocked",step:"queries",action:"generate_queries",reasonCode:Fl(V,"unknown")},"onboarding.blocked:queries:generate")}finally{Dr(!1)}}},Kr=async()=>{if(!Be)return;const V=ai;if(V.length!==0){Ba(!0),Br(null);try{await _V(Be,V),qi(!0),await r(),ae({flowVersion:lt,onboardingSessionId:P,event:"onboarding.step_completed",step:"competitors",method:"manual",countBucket:Za(V.length)},"onboarding.step_completed:competitors"),Y(4)}catch($e){Br($e instanceof Error?$e.message:"Failed to save competitors"),ae({flowVersion:lt,onboardingSessionId:P,event:"onboarding.blocked",step:"competitors",action:"save",reasonCode:"unknown"},"onboarding.blocked:competitors:save")}finally{Ba(!1)}}},Hr=async()=>{const V=Pi.trim();if(V){So(!0),jo(null);try{await U3("gemini",{apiKey:V}),ln({title:"Gemini configured",detail:"Provider is ready — continuing setup.",tone:"positive",dedupeKey:"setup:gemini:configured",dedupeMode:"drop"}),wc(""),await r(),Ns(v.providerStatuses.find($e=>$e.name.toLowerCase()==="gemini")?.name??"gemini"),ae({flowVersion:lt,onboardingSessionId:P,event:"onboarding.step_completed",step:"system",method:"inline"},"onboarding.step_completed:system")}catch($e){jo($e instanceof Error?$e.message:"Failed to save Gemini key"),ae({flowVersion:lt,onboardingSessionId:P,event:"onboarding.blocked",step:"system",action:"configure_provider",reasonCode:"provider_save_failed"},"onboarding.blocked:system:provider_save_failed")}finally{So(!1)}}},ii=async()=>{if(!Js()){if(!Be||$a){wn($a??"Complete setup before launching the first sweep.");const V=la??(Be?ra===0?"no_queries":"run_rejected":"unknown");un||ae({flowVersion:lt,onboardingSessionId:P,event:"run.requested",origin:"dashboard_setup",result:"rejected",providerCountBucket:Za(ei),queryCountBucket:Za(ra),reasonCode:V});return}Rs(!0),wn(null);try{const V=await Ur.mutateAsync({projectName:Be,projectLabel:ve||De||Be,sourceAction:"setup-launch"});om(V.id),sm(!0),Ij(Be,V.id),$r.current=V.id,un||ae({flowVersion:lt,onboardingSessionId:P,event:"run.requested",origin:"dashboard_setup",result:"queued",providerCountBucket:Za(ei),queryCountBucket:Za(ra)}),await r()}catch(V){wn(V instanceof Error?V.message:"Failed to queue the visibility sweep. Retry when the instance is ready."),un||ae({flowVersion:lt,onboardingSessionId:P,event:"run.requested",origin:"dashboard_setup",result:"rejected",providerCountBucket:Za(ei),queryCountBucket:Za(ra),reasonCode:Fl(V,"run_rejected")})}finally{Rs(!1)}}},Tn=()=>Y(V=>_?2:Math.max(0,V-1)),No=(V,$e,si)=>{ae({flowVersion:lt,onboardingSessionId:P,event:"onboarding.step_completed",step:V,method:"existing",...si===void 0?{}:{countBucket:Za(si)}},`onboarding.step_completed:${V}`),Y($e)},Qr=()=>{if(ae({flowVersion:lt,onboardingSessionId:P,event:"onboarding.step_completed",step:"queries",method:"skipped",countBucket:"0"},"onboarding.step_completed:queries"),_){Qt();return}Y(3)},kc=()=>{ae({flowVersion:lt,onboardingSessionId:P,event:"onboarding.step_completed",step:"competitors",method:"skipped",countBucket:"0"},"onboarding.step_completed:competitors"),Y(4)},Es=_?"section":ba,ca=en!==!0||sa===!0?c.jsx(me,{type:"button",variant:"ghost",size:"sm",className:"min-h-11",onClick:()=>{r(),vn&&Wa.refetch()},children:"Check again"}):null,Fr=(en===!1||oa)&&!!Gn,zs=_&&(q===2||q===4)?w?c.jsxs("section",{"aria-labelledby":"setup-provider-heading",className:"space-y-3 border-b border-default pb-6 mb-6",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[c.jsx("h2",{id:"setup-provider-heading",className:"text-lg font-semibold text-heading",children:en===!1?"Connect a provider":"Answer engine provider"}),c.jsx(jn,{tone:en===!0?"positive":"neutral",children:en===!0?"Configured":en===!1?"Not connected":"Checking"})]}),c.jsx("p",{className:"max-w-prose text-sm text-secondary",children:en===!0?qe.length>0?`${qe.map(V=>V.displayName??V.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.":en===!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."}),en===!1||oa?Gn?c.jsx("div",{children:c.jsx(NQ,{compact:!0,leadingField:c.jsxs("div",{className:"min-w-0 space-y-1.5",children:[c.jsx("label",{className:"block text-sm font-medium text-secondary",htmlFor:"setup-provider",children:"Provider to connect"}),c.jsx("select",{ref:vc,id:"setup-provider",className:"setup-input",value:Gn.name,onChange:V=>{V.target.value!==Gn.name&&(xo.current=document.activeElement===V.currentTarget,Pr(V.target.value))},children:ko.map(V=>c.jsx("option",{value:V.name,children:V.displayName??V.name},V.name))})]}),secondaryActions:ca,providerName:Gn.name,keyUrl:Gn.keyUrl,modelHint:Gn.modelHint,onSaved:()=>{Ft(!1),r()}},Gn.name)}):c.jsx("p",{className:"max-w-prose text-sm text-secondary",children:_e.length>0?`This project's provider selection is ${_e.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,c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[en===!0&&!oa&&Gn?c.jsx(me,{type:"button",variant:"outline",size:"sm",onClick:()=>Ft(!0),children:"Configure a provider"}):null,!Gn||sa===!0?c.jsx(me,{type:"button",variant:"outline",size:"sm",asChild:!0,children:c.jsx(Fe,{to:"/settings",target:"_blank",rel:"noopener noreferrer",children:"Open provider settings"})}):null,Fr?null:ca]})]}):c.jsxs("section",{"aria-labelledby":"setup-provider-heading",className:"space-y-2 border-b border-default pb-6 mb-6",children:[c.jsx("h2",{id:"setup-provider-heading",className:"text-lg font-semibold text-heading",children:"Answer engine provider"}),c.jsx("p",{className:"max-w-prose text-sm text-secondary",children:"Provider settings are managed by an administrator."}),Ti?c.jsx("p",{role:"alert",className:"text-sm text-negative",children:"Provider readiness could not be checked. Try again."}):c.jsx("p",{className:"max-w-prose text-sm text-secondary",role:"status",children:en===!0?"An answer engine is available for this project.":en===!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."}),c.jsx(me,{type:"button",variant:"ghost",size:"sm",className:"min-h-11",disabled:ia.isFetching,onClick:()=>{ia.refetch()},children:Ti?"Retry provider check":"Check again"})]}):null,Ua=(()=>{switch(q){case 0:return c.jsxs(ba,{className:"surface-card step-card",children:[c.jsx("div",{className:"section-head",children:c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 1 of 5"}),c.jsx("h2",{children:"System check"})]})}),c.jsx("p",{className:"supporting-copy",children:"Checking that your Canonry instance is configured and reachable."}),c.jsx("div",{className:"compact-stack",children:R.healthChecks.map(V=>c.jsxs("div",{className:"health-check-row",children:[c.jsxs("div",{children:[c.jsx("p",{className:"run-row-title",children:V.label}),c.jsx("p",{className:"supporting-copy",children:V.detail}),V.id==="provider"&&V.state!=="ready"&&c.jsxs("div",{className:"mt-3 rounded-md border border-default bg-bg-elevated/40 p-3 space-y-2",children:[c.jsxs("p",{className:"text-xs text-secondary",children:["Paste a Gemini key to enable visibility checks (free at"," ",c.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"}),")."]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"password",value:Pi,onChange:$e=>wc($e.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:kn}),c.jsx(me,{type:"button",size:"sm",disabled:kn||!Pi.trim(),onClick:an(Hr),children:kn?"Saving...":"Save"})]}),Gr&&c.jsxs("div",{role:"alert",className:"space-y-1 text-xs text-negative",children:[c.jsx("p",{children:Gr}),c.jsx("p",{children:"Check that the key is complete, then retry Save."})]}),c.jsxs("p",{className:"text-sm text-secondary",children:["Connect more answer engines later in"," ",c.jsx(Fe,{to:"/settings",className:"text-link hover:underline",children:"Settings"}),"."]})]})]}),c.jsx(jn,{tone:V.state==="ready"?"positive":"caution",title:V.id==="api"?wr(A.apiStatus):V.id==="worker"?wr(A.workerStatus):V.detail,children:V.state==="ready"?"Ready":"Attention"})]},V.id))}),c.jsxs("div",{className:"setup-nav",children:[R.launchState.blockedReason?c.jsx("p",{role:"status",className:"supporting-copy text-negative",children:R.launchState.blockedReason}):c.jsx("span",{}),c.jsx(me,{type:"button",disabled:!R.launchState.enabled,title:R.launchState.blockedReason,onClick:()=>{ae({flowVersion:lt,onboardingSessionId:P,event:"onboarding.step_completed",step:"system",method:"automatic"},"onboarding.step_completed:system"),Y(Le)},children:"Continue"})]})]});case 1:return c.jsxs(ba,{className:"surface-card step-card",children:[c.jsxs("div",{className:"section-head",children:[c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 2 of 5"}),c.jsx("h2",{children:"Create project"})]}),Be?c.jsx(jn,{tone:"positive",children:"Created"}):null]}),Be?c.jsxs("div",{className:"compact-stack",children:[c.jsxs("p",{className:"text-neutral",children:["Project ",c.jsx("span",{className:"text-heading font-medium",children:Be})," created successfully."]}),c.jsxs("div",{className:"setup-nav",children:[c.jsx(me,{type:"button",variant:"outline",onClick:Tn,children:"Back"}),c.jsx(me,{type:"button",onClick:()=>No("project",2),children:"Continue"})]})]}):c.jsxs("div",{className:"compact-stack",children:[c.jsxs("div",{className:"setup-field",children:[c.jsx("label",{className:"setup-label",htmlFor:"project-name",children:"Project name"}),c.jsx("input",{id:"project-name",className:"setup-input",type:"text",placeholder:"my-website",value:De,onChange:V=>Oe(V.target.value)}),In&&In!==De?c.jsxs("p",{className:"supporting-copy",children:["Slug: ",In]}):null]}),c.jsxs("div",{className:"setup-field",children:[c.jsx("label",{className:"setup-label",htmlFor:"display-name",children:"Display name (optional)"}),c.jsx("input",{id:"display-name",className:"setup-input",type:"text",placeholder:"My Website",value:ve,onChange:V=>oe(V.target.value)})]}),c.jsxs("div",{className:"setup-field",children:[c.jsx("label",{className:"setup-label",htmlFor:"domain",children:"Canonical domain"}),c.jsx("input",{id:"domain",className:"setup-input",type:"text",placeholder:"example.com",value:ue,onChange:V=>K(V.target.value)})]}),c.jsxs("div",{className:"setup-field-row",children:[c.jsxs("div",{className:"setup-field",children:[c.jsx("label",{className:"setup-label",htmlFor:"country",children:"Country"}),c.jsx("input",{id:"country",className:"setup-input",type:"text",placeholder:"US",maxLength:2,value:ce,onChange:V=>Ue(V.target.value.toUpperCase())})]}),c.jsxs("div",{className:"setup-field",children:[c.jsx("label",{className:"setup-label",htmlFor:"language",children:"Language"}),c.jsx("input",{id:"language",className:"setup-input",type:"text",placeholder:"en",maxLength:5,value:xe,onChange:V=>Xe(V.target.value.toLowerCase())})]})]}),c.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-default bg-surface p-3 cursor-pointer hover:border-strong",children:[c.jsx("input",{type:"checkbox",className:"mt-0.5 h-4 w-4 rounded border-strong bg-bg",checked:Ve,onChange:V=>ut(V.target.checked)}),c.jsxs("span",{className:"flex-1",children:[c.jsx("span",{className:"block text-sm text-heading",children:"Auto-extract backlinks"}),c.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."," ",c.jsx(Fe,{to:"/backlinks",className:"text-positive-400 hover:text-positive underline underline-offset-2",children:"Manage backlinks"})]})]})]}),ct?c.jsx("p",{className:"text-negative-400 text-sm",children:ct}):null,c.jsxs("div",{className:"setup-nav",children:[c.jsx(me,{type:"button",variant:"outline",onClick:Tn,children:"Back"}),c.jsx(me,{type:"button",disabled:!In||!ue||qn,onClick:an(lm),children:qn?"Creating...":"Create project"})]})]})]});case 2:return c.jsxs(Es,{className:_?"visibility-setup-section step-card":"surface-card step-card","aria-labelledby":"setup-queries-heading",children:[c.jsxs("div",{className:"section-head",children:[c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:_?"Step 1 of 2":"Step 3 of 5"}),c.jsx("h2",{id:"setup-queries-heading",children:"Add queries"})]}),ne?c.jsx(jn,{tone:"neutral",children:"Loading"}):H.isError?c.jsx(jn,{tone:"negative",children:"Load failed"}):$t?c.jsxs(jn,{tone:"positive",children:[Kn.length," saved"]}):c.jsxs(jn,{tone:"neutral",children:[Kn.length," quer",Kn.length!==1?"ies":"y"]})]}),c.jsx("p",{className:"supporting-copy",children:"Add the queries your customers use, one per line. You can refine your list later."}),c.jsxs("div",{className:"space-y-2 border-b border-default pb-4",children:[c.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[c.jsxs("div",{className:"min-w-0 space-y-1",children:[c.jsx("h3",{className:"text-sm font-semibold text-heading",children:"Research queries with your agent"}),c.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."})]}),c.jsx(me,{type:"button",variant:"outline",size:"sm",className:"min-h-11 shrink-0 self-start",onClick:an(Mr),children:xn?"Research prompt copied":"Copy research prompt"})]}),c.jsxs("details",{open:wo||void 0,className:"text-sm text-secondary",children:[c.jsx("summary",{className:"min-h-11 cursor-pointer py-3 text-link",children:"View agent prompt"}),c.jsx("textarea",{"aria-label":"Agent query research prompt",readOnly:!0,className:"setup-textarea mt-2 w-full",rows:8,value:zi})]}),wo?c.jsx("p",{role:"alert",className:"text-sm text-negative",children:"Could not copy. Select and copy the prompt above."}):null]}),ne?c.jsx("div",{className:"rounded-md border border-default bg-bg-elevated/40 p-4 text-sm text-secondary",role:"status",children:"Loading saved queries…"}):H.isError?c.jsxs("div",{className:"compact-stack",children:[c.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."}),c.jsxs("div",{className:"setup-nav",children:[c.jsx(me,{type:"button",variant:"outline",onClick:_?Re:Tn,children:"Back"}),c.jsx(me,{type:"button",onClick:()=>{H.refetch()},children:"Retry loading queries"})]})]}):$t?c.jsxs("div",{className:"compact-stack",children:[c.jsx("ul",{className:"detail-list",children:Kn.map(V=>c.jsx("li",{children:V},V))}),c.jsxs("div",{className:"setup-nav",children:[c.jsx(me,{type:"button",variant:"outline",onClick:_?Re:Tn,children:"Back"}),c.jsx(me,{type:"button",variant:"outline",onClick:()=>Ma(!1),children:"Edit queries"}),c.jsx(me,{type:"button",onClick:()=>No("queries",_?4:3,Kn.length),children:"Continue"})]})]}):c.jsxs("div",{className:"compact-stack",children:[qe.length>0?c.jsxs("div",{className:"compact-stack",children:[c.jsxs("div",{className:"flex items-center gap-2 text-muted text-xs uppercase tracking-wide",children:[c.jsx("span",{className:"flex-1 border-t border-base"}),"auto-generate",c.jsx("span",{className:"flex-1 border-t border-base"})]}),c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsxs("div",{className:"setup-field flex-1",children:[c.jsx("label",{className:"setup-label",htmlFor:"gen-provider",children:"Provider"}),c.jsx("select",{id:"gen-provider",className:"setup-input",value:Ri,onChange:V=>Ns(V.target.value),children:qe.map(V=>c.jsxs("option",{value:V.name,children:[V.displayName??V.name,V.model?` (${V.model})`:""]},V.name))})]}),c.jsxs("div",{className:"setup-field",children:[c.jsx("label",{className:"setup-label",htmlFor:"gen-count",children:"Count"}),c.jsx("select",{id:"gen-count",className:"setup-input",value:vo,onChange:V=>_s(Number(V.target.value)),children:[3,5,10,15,20].map(V=>c.jsx("option",{value:V,children:V},V))})]}),c.jsx(me,{type:"button",variant:"outline",disabled:bc||!Ri,onClick:an(Ca),children:bc?"Analyzing site...":"Generate"})]}),Or?c.jsx("p",{className:"text-negative-400 text-sm",children:Or}):null]}):null,_?null:c.jsxs("div",{className:"flex items-center gap-2 text-muted text-xs uppercase tracking-wide",children:[c.jsx("span",{className:"flex-1 border-t border-base"}),"or type manually",c.jsx("span",{className:"flex-1 border-t border-base"})]}),c.jsxs("div",{className:"setup-field",children:[c.jsx("label",{className:"setup-label",htmlFor:"queries",children:"Queries (one per line)"}),c.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:bn,onChange:V=>js(V.target.value)})]}),_i?c.jsx("p",{className:"text-negative-400 text-sm",children:_i}):null,c.jsxs("div",{className:"setup-nav",children:[c.jsx(me,{type:"button",variant:"outline",onClick:_?Re:Tn,children:"Back"}),c.jsx(me,{type:"button",variant:"ghost",onClick:Qr,children:_?"Finish without AI Visibility":"Skip for now"}),c.jsx(me,{type:"button",disabled:Kn.length===0||_n,onClick:an(Co),children:_n?"Saving...":`Save ${Kn.length} quer${Kn.length!==1?"ies":"y"}`})]})]})]});case 3:return c.jsxs(ba,{className:"surface-card step-card",children:[c.jsxs("div",{className:"section-head",children:[c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 4 of 5"}),c.jsx("h2",{children:"Add competitors"})]}),Oi?c.jsx(jn,{tone:"positive",children:"Saved"}):null]}),c.jsx("p",{className:"supporting-copy",children:"Domains that compete for the same queries. One per line."}),Oi?c.jsxs("div",{className:"compact-stack",children:[c.jsx("ul",{className:"detail-list",children:ai.map(V=>c.jsx("li",{children:V},V))}),c.jsxs("div",{className:"setup-nav",children:[c.jsx(me,{type:"button",variant:"outline",onClick:Tn,children:"Back"}),c.jsx(me,{type:"button",onClick:()=>No("competitors",4,ai.length),children:"Continue"})]})]}):c.jsxs("div",{className:"compact-stack",children:[c.jsxs("div",{className:"setup-field",children:[c.jsx("label",{className:"setup-label",htmlFor:"competitors",children:"Competitor domains (one per line)"}),c.jsx("textarea",{id:"competitors",className:"setup-textarea",rows:4,placeholder:`competitor1.com
|
|
86
|
-
competitor2.com`,value:ti,onChange:V=>Di(V.target.value)})]}),Ut?c.jsx("p",{className:"text-negative-400 text-sm",children:Ut}):null,c.jsxs("div",{className:"setup-nav",children:[c.jsx(me,{type:"button",variant:"outline",onClick:Tn,children:"Back"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(me,{type:"button",variant:"outline",onClick:kc,children:"Skip"}),c.jsx(me,{type:"button",disabled:ai.length===0||Lr,onClick:an(Kr),children:Lr?"Saving...":`Save ${ai.length} competitor${ai.length!==1?"s":""}`})]})]})]})]});case 4:{const V=Va.data,$e=V?.status??(Ii===He?.id?He.status:void 0),si=$e==="completed"||$e==="partial"||$e==="failed"||$e==="cancelled",Na=V?.snapshots??[],_o=Na.filter(_a=>_a.citationState==="cited").length,Sc=Na.filter(_a=>_a.answerMentioned===!0).length,mn=new Set(Na.map(_a=>_a.query).filter(_a=>!!_a)).size,Ga=$e?cw($e,Na.length):!1,Ds=Ne&&!La,Os=dn??(V?.error?u$(V.error):$e==="cancelled"?"The sweep was cancelled before it produced a baseline.":($e==="completed"||$e==="partial")&&Na.length===0?"The sweep finished without producing any snapshots.":He?.statusDetail||"The sweep did not produce a baseline.");let qs=null;return Ds||Ga?qs=c.jsx(jn,{tone:"positive",children:"Complete"}):dn&&!La?qs=c.jsx(jn,{tone:"negative",children:"Failed"}):si?qs=c.jsx(jn,{tone:"negative",children:$e==="cancelled"?"Cancelled":"Failed"}):La&&(qs=c.jsx(jn,{tone:"caution",children:"Running"})),c.jsxs(ba,{className:"surface-card step-card",children:[c.jsxs("div",{className:"section-head",children:[c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:_?"Step 2 of 2":"Step 5 of 5"}),c.jsx("h2",{children:Js()?"AI Visibility":"Launch first run"})]}),qs]}),Ds?c.jsxs("div",{className:"compact-stack",children:[c.jsxs("p",{className:"text-secondary",children:["Setup is complete. ",c.jsx("span",{className:"text-strong font-medium",children:Be})," already has a successful answer-visibility baseline."]}),c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(me,{type:"button",onClick:()=>Je(),children:g?"Finish setup":"Open project dashboard →"})]})]}):!La&&Js()?c.jsxs("div",{className:"compact-stack",children:[Be?c.jsx(CH,{projectName:Be}):c.jsx("p",{className:"text-sm text-secondary",children:wf}),dn&&c.jsx("p",{role:"alert",className:"text-sm text-negative",children:dn}),c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(me,{type:"button",onClick:Re,children:"Open project dashboard →"})]})]}):La?si?Ga?c.jsxs("div",{className:"compact-stack",children:[c.jsxs("p",{className:"text-neutral",children:["Sweep complete. Your first answer-visibility snapshot for"," ",c.jsx("span",{className:"text-heading font-medium",children:Be}),":"]}),c.jsxs("div",{className:"grid grid-cols-3 gap-2 mt-1",children:[c.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[c.jsx("p",{className:"text-xs font-medium text-secondary",children:"Mentioned"}),c.jsxs("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:[Sc,c.jsxs("span",{className:"text-faint text-lg",children:[" / ",mn]})]}),c.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"queries naming your brand"})]}),c.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[c.jsx("p",{className:"text-xs font-medium text-secondary",children:"Cited"}),c.jsxs("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:[_o,c.jsxs("span",{className:"text-faint text-lg",children:[" / ",mn]})]}),c.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"queries citing your site"})]}),c.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[c.jsx("p",{className:"text-xs font-medium text-secondary",children:"Results"}),c.jsx("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:Na.length}),c.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"completed engine checks"})]})]}),!b&&Be?c.jsx(CQ,{projectName:Be}):null,c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(me,{type:"button",onClick:()=>Je(),children:g?"Finish setup":"Open project dashboard →"})]})]}):c.jsxs("div",{className:"compact-stack",children:[c.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[c.jsx("p",{children:Os}),c.jsx("p",{className:"mt-1 text-xs text-secondary",children:Js()?wf:w?"Fix provider or query configuration if needed, then retry without leaving setup.":"Ask an administrator to review the provider and query configuration."})]}),c.jsxs("div",{className:"setup-nav",children:[w&&!Js()?c.jsx(me,{type:"button",variant:"outline",asChild:!0,children:c.jsx(Fe,{to:"/settings",children:"Configure providers"})}):c.jsx("span",{}),Js()||!w?c.jsx(me,{type:"button",onClick:Re,children:"Open project dashboard →"}):c.jsx(me,{type:"button",disabled:ni||!!$a,onClick:an(ii),children:ni?"Retrying...":"Retry visibility sweep"})]})]}):c.jsxs("div",{className:"compact-stack",children:[c.jsx("p",{className:"text-neutral",children:"Sweep running. This usually takes 30 to 60 seconds."}),c.jsx("div",{className:"rounded-md border border-default bg-surface p-3 text-xs text-muted",children:c.jsxs("p",{children:["Status: ",c.jsx("span",{className:"text-neutral",children:$e??"queued"})]})}),Va.isError&&c.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[c.jsx("p",{children:Va.error instanceof Error?Va.error.message:"Could not refresh the sweep status."}),c.jsx(me,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:()=>{Va.refetch()},children:"Retry status check"})]}),c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(me,{type:"button",variant:"outline",onClick:g?()=>Je():Re,children:g?"Finish setup":"Watch on project page"})]})]}):c.jsxs("div",{className:"compact-stack",children:[c.jsxs("p",{className:"supporting-copy",children:["Your queries are saved. Run a first sweep to get a baseline for"," ",c.jsx("span",{className:"text-heading font-medium",children:Be}),", or finish and run it later from the project. A sweep calls the answer engines, so it costs provider usage."]}),($a||dn)&&c.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[c.jsx("p",{children:dn??$a}),c.jsx("p",{className:"mt-1 text-xs text-secondary",children:"Resolve the blocker above, then retry the sweep here."})]}),c.jsxs("div",{className:"setup-nav",children:[c.jsx(me,{type:"button",variant:"outline",onClick:Tn,children:"Back"}),c.jsx(me,{type:"button",variant:"ghost",onClick:Qt,children:"Finish without running"}),la==="no_provider"&&!_?c.jsx(me,{type:"button",asChild:!0,children:c.jsx(Fe,{to:"/settings",children:"Configure a provider"})}):c.jsx(me,{type:"button",disabled:ni||!!$a,title:$a,onClick:an(ii),children:ni?"Launching...":dn?"Retry visibility sweep":"Launch visibility sweep"})]})]})]})}default:return null}})();return c.jsxs("div",{className:_?"page-container visibility-setup":"page-container",children:[g?c.jsx(lo,{current:"visibility"}):null,c.jsxs("div",{className:"page-header",children:[c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{ref:u?h:void 0,tabIndex:u?-1:void 0,className:"page-title",children:u?"Set up AI Visibility":"Setup"}),c.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."})]}),g?c.jsx("div",{className:"page-header-right",children:c.jsx(me,{type:"button",variant:"outline",className:"min-h-11",onClick:Qt,children:"Skip AI Visibility"})}):null]}),g?null:c.jsx(zQ,{current:_?q===4?1:0:q,labels:_?RQ:TQ}),c.jsxs("section",{className:"setup-wizard",children:[zs,Ua]})]})}const Bh="canonry mcp install --client claude-code",qQ="https://github.com/Canonry/canonry/blob/main/docs/mcp.md";function IQ(){const e=C.useRef(lg()).current,n=C.useRef(new Set),i=C.useCallback((r,u)=>{n.current.has(r)||(n.current.add(r),Z0({...u,flowVersion:lt,onboardingSessionId:e,surface:"platform",eventId:cg()}))},[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 am=C.createContext(()=>{});function PQ({projectName:e,skippedVisibility:n=!1}){const i=Nt({...GU({client:ee,path:{name:e}}),retry:!1}),r=i.data?.hasData?i.data:null,u=IQ(),h=mw(e,Ee["site-audit"]),g=mw(e,Ee["answer-visibility"]),b={...h?{site:h,fixes:h}:{},...MQ(g,n)};return c.jsx(am.Provider,{value:u,children:c.jsxs("div",{className:"page-container max-w-6xl py-8 md:py-10",children:[c.jsx(lo,{current:"done",outcomes:b}),c.jsxs("header",{className:"relative mx-auto mt-12 max-w-2xl text-center md:mt-16",children:[c.jsx(BQ,{}),c.jsx("p",{className:"onb-reveal mt-6 text-sm font-medium text-positive",style:va(250),children:"Setup complete"}),c.jsx("h1",{className:"onb-reveal mt-2 text-5xl font-semibold tracking-tight text-heading md:text-6xl",style:va(350),children:"You’re set."}),c.jsxs("p",{className:"onb-reveal mx-auto mt-4 max-w-xl text-lg text-secondary",style:va(450),children:["Canonry is tracking ",c.jsx("span",{className:"font-medium text-heading",children:e}),". Here’s how to get the most out of it from here."]})]}),c.jsxs("div",{className:"mt-14 grid gap-4 md:grid-cols-6",children:[c.jsx(Gu,{className:"md:col-span-4 md:row-span-2",delayMs:600,labelledBy:"onb-agent-heading",children:c.jsx($Q,{projectName:e})}),c.jsx(Gu,{className:"md:col-span-2 md:row-span-2",delayMs:700,labelledBy:"onb-data-heading",children:c.jsx(KQ,{projectName:e})}),c.jsx(Gu,{className:"md:col-span-3",delayMs:800,labelledBy:"onb-schedule-heading",children:c.jsx(FQ,{projectName:e})}),c.jsx(Gu,{className:"md:col-span-3",delayMs:900,labelledBy:"onb-alerts-heading",children:c.jsx(ZQ,{projectName:e,score:r?.aggregateScore??null})})]}),c.jsxs("div",{className:"onb-reveal mt-12 flex flex-col items-center gap-3 sm:flex-row sm:justify-center",style:va(1e3),children:[c.jsx(me,{asChild:!0,className:"h-11 rounded-full px-6 text-base md:h-11",children:c.jsxs(Fe,{to:"/projects/$projectName",params:{projectName:e},replace:!0,onClick:()=>u("open_project"),children:["Open ",e,c.jsx(Zl,{className:"size-4","aria-hidden":"true"})]})}),c.jsx(me,{asChild:!0,variant:"ghost",className:"h-11 rounded-full px-5 md:h-11",children:c.jsx(Fe,{to:"/projects/$projectName/technical-aeo",params:{projectName:e},replace:!0,onClick:()=>u("review_page_health"),children:"Review page health"})})]})]})})}function mw(e,n){const i=Nt({...X3({client:ee,path:{name:e},query:{kind:n,limit:20}}),retry:!1,refetchInterval:r=>pw(r.state.status==="success"?{isSuccess:!0,data:r.state.data}:{isSuccess:!1})==="pending"?5e3:!1});return pw(i)}function MQ(e,n){return e===void 0?{}:n?{visibility:"skipped"}:{visibility:e}}function pw(e){if(!e.isSuccess||!e.data)return"unknown";const n=e.data.filter(i=>i.trigger!==ds.probe);if(!n.some(i=>i.status===Ht.completed||i.status===Ht.partial))return n.some(i=>i.status===Ht.queued||i.status===Ht.running)?"pending":n.length>0?"incomplete":"skipped"}function va(e){return{"--onb-delay":`${e}ms`}}function BQ(){return c.jsx("div",{className:"onb-check relative mx-auto size-20","aria-hidden":"true",children:c.jsxs("svg",{viewBox:"0 0 80 80",className:"relative size-20",children:[c.jsx("circle",{className:"onb-check-ring",cx:"40",cy:"40",r:"36",fill:"none",strokeWidth:"3",pathLength:"1"}),c.jsx("path",{className:"onb-check-mark",d:"M25 41 L35 51 L56 30",fill:"none",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round",pathLength:"1"})]})})}function Gu({className:e="",delayMs:n,labelledBy:i,children:r}){return c.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:va(n),children:r})}function im({id:e,eyebrow:n,title:i,children:r}){return c.jsxs("div",{children:[c.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted",children:n}),c.jsx("h2",{id:e,className:"mt-1.5 text-2xl font-semibold tracking-tight text-heading",children:i}),c.jsx("p",{className:"mt-2 text-sm text-secondary",children:r})]})}const Ku=[{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."}],LQ=9e3;function VQ(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function $Q({projectName:e}){const n=C.useContext(am),[i,r]=C.useState(0),[u,h]=C.useState(!1),[g,b]=C.useState(!1);C.useEffect(()=>{if(u||VQ())return;const S=window.setTimeout(()=>r(A=>(A+1)%Ku.length),LQ);return()=>window.clearTimeout(S)},[i,u]);const v=async()=>{try{await navigator.clipboard.writeText(Bh),n("copy_agent_command"),b(!0),window.setTimeout(()=>b(!1),1800)}catch{ln({tone:"negative",title:"Could not copy the command",detail:`Run ${Bh} in your terminal.`})}},w=Ku[i]??Ku[0];return c.jsxs(c.Fragment,{children:[c.jsxs(im,{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"," ",c.jsx("span",{className:"text-heading",children:e})," that reviews every sweep on its own."]}),c.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:[c.jsxs("div",{className:"flex items-center gap-1 border-b border-default px-3 py-2",role:"tablist","aria-label":"Example agent sessions",children:[Ku.map((S,A)=>c.jsx("button",{type:"button",role:"tab","aria-selected":A===i,onClick:()=>{r(A),h(!0)},className:`rounded-md px-2.5 py-1 text-xs font-medium transition-colors ${A===i?"bg-surface-inset text-heading":"text-muted hover:text-secondary"}`,children:S.label},S.id)),c.jsx("span",{className:"ml-auto text-xs text-faint",children:"Example"})]}),c.jsxs("div",{role:"tabpanel","aria-label":`${w.label} example`,className:"flex-1 p-4 font-mono text-[13px] leading-relaxed",children:[c.jsxs("p",{className:"onb-type text-heading",style:va(150),children:[c.jsx("span",{className:"text-muted",children:"> "}),w.prompt]}),w.calls.map((S,A)=>c.jsxs("p",{className:"onb-line mt-1 text-muted first:mt-3",style:va(1300+A*450),children:[c.jsx("span",{className:"text-positive",children:"●"})," ",S]},S)),c.jsx("p",{className:"onb-line mt-3 text-secondary",style:va(1500+w.calls.length*450),children:w.reply}),c.jsx("span",{className:"onb-caret mt-2 inline-block h-4 w-2 bg-current align-middle text-secondary",style:va(1900+w.calls.length*450),"aria-hidden":"true"})]},w.id)]}),c.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[c.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:Bh}),c.jsxs(me,{type:"button",variant:"secondary",size:"sm",className:"h-9 md:h-9",onClick:()=>{v()},children:[g?c.jsx(vd,{className:"size-4","aria-hidden":"true"}):c.jsx(Rf,{className:"size-4","aria-hidden":"true"}),g?"Copied":"Copy"]}),c.jsx("a",{href:qQ,target:"_blank",rel:"noreferrer",className:"text-sm font-medium text-link underline-offset-4 hover:underline",children:"Other clients"})]})]})}const UQ=[{icon:Tf,label:"Search Console",action:"connect_search_console",to:"/projects/$projectName/search-console"},{icon:Nw,label:"Google Analytics",action:"connect_analytics",to:"/projects/$projectName/activity"},{icon:Tw,label:"Business Profile",action:"connect_business_profile",to:"/projects/$projectName/local"}],GQ=["GPTBot","ClaudeBot","PerplexityBot"];function KQ({projectName:e}){const n=C.useContext(am);return c.jsxs(c.Fragment,{children:[c.jsx(im,{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."}),c.jsx(HQ,{}),c.jsxs(Fe,{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:[c.jsx(Rw,{className:"size-4 text-positive","aria-hidden":"true"}),c.jsxs("span",{className:"flex-1",children:["Connect your server",c.jsx("span",{className:"block text-xs font-normal text-secondary",children:"Cloudflare, Vercel, WordPress, or Cloud Run"})]}),c.jsx(Zl,{className:"size-4 text-link transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]}),c.jsx("p",{className:"mt-5 text-xs font-medium uppercase tracking-wide text-muted",children:"Also connect"}),c.jsx("ul",{className:"mt-1 divide-y divide-default",children:UQ.map(({icon:i,label:r,action:u,to:h})=>c.jsx("li",{children:c.jsxs(Fe,{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:[c.jsx(i,{className:"size-4 text-muted","aria-hidden":"true"}),c.jsx("span",{className:"flex-1",children:r}),c.jsx(Zl,{className:"size-3.5 text-link transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]})},r))})]})}function HQ(){const e=[22,70,118];return c.jsxs("div",{className:"relative my-6 h-36","aria-hidden":"true",children:[c.jsx("svg",{viewBox:"0 0 200 140",preserveAspectRatio:"none",className:"absolute inset-0 size-full",children:e.map((n,i)=>c.jsx("path",{className:"onb-flow",style:va(i*400),d:`M20 ${n} C 100 ${n}, 118 70, 170 70`,fill:"none",strokeWidth:"1.5"},n))}),GQ.map((n,i)=>c.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}%`,...va(i*600)},children:n},n)),c.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:c.jsx(Rw,{className:"size-5"})})]})}const QQ=["M","T","W","T","F","S","S"];function FQ({projectName:e}){return c.jsxs(c.Fragment,{children:[c.jsx(im,{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."}),c.jsx("ol",{className:"mt-6 grid grid-cols-7 gap-2","aria-hidden":"true",children:QQ.map((n,i)=>c.jsxs("li",{className:"flex flex-col items-center gap-2",children:[c.jsx("span",{className:"onb-day size-3 rounded-full bg-surface-inset",style:va(i*500)}),c.jsx("span",{className:"text-xs text-muted",children:n})]},i))}),c.jsx(Lj,{projectName:e,to:"/projects/$projectName/settings",icon:_w,label:"Set a schedule",action:"set_schedule"})]})}function ZQ({projectName:e,score:n}){return c.jsxs(c.Fragment,{children:[c.jsx(im,{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."}),c.jsxs("div",{className:"relative mt-6 flex h-14 items-center","aria-hidden":"true",children:[c.jsx("span",{className:"onb-bell flex size-10 items-center justify-center rounded-full border border-default bg-bg-elevated",children:c.jsx($h,{className:"size-4 text-secondary"})}),c.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:[c.jsx("span",{className:"size-2 rounded-full bg-positive-400"}),c.jsx("span",{className:"text-heading",children:e}),c.jsx("span",{className:"text-secondary",children:n===null?"sweep finished":`page health ${n}`})]})]}),c.jsx(Lj,{projectName:e,to:"/projects/$projectName/settings",icon:$h,label:"Add a notification",action:"add_notification"})]})}function Lj({projectName:e,to:n,icon:i,label:r,action:u}){const h=C.useContext(am);return c.jsxs(Fe,{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:[c.jsx(i,{className:"size-4","aria-hidden":"true"}),r,c.jsx(Zl,{className:"size-3.5 transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]})}const YQ=C.lazy(async()=>({default:(await Ni(()=>import("./SiteHealthSection-4mMfc6Rb.js").then(n=>n.d),__vite__mapDeps([0,1,2,3,4]),import.meta.url)).SiteHealthSection})),XQ=`Public pages only, crawled from this computer and stored locally. The first scan reads up to ${wS} pages, then stops.`,JQ=1800,WQ="https://github.com/Canonry/canonry#or-use-any-shell-capable-coding-agent",eF="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 tF(e,n){return e==="legacy"?"legacy":e==="platform"?"platform":n.state==="success"?n.projectCount===0?"platform":"legacy":n.state==="error"?"retry":"loading"}const nF="2000-01-01T00:00:00.000Z",aF=5e3;function iF(e,n){const i=new Set,r=new Map;for(const g of n)g.trigger!==ds.probe&&(r.has(g.projectId)||r.set(g.projectId,g.id),(g.status===Ht.completed||g.status===Ht.partial)&&i.add(g.projectId));const h=(e.every(g=>g.createdAt)?[...e].sort((g,b)=>(g.createdAt??"").localeCompare(b.createdAt??"")||g.name.localeCompare(b.name)):e).find(g=>!i.has(g.id));return h?{projectName:h.name,runId:r.get(h.id)}:null}const Vj=[{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"}],$j=[{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 sF(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 oF(e,n){const i=e.trim().toUpperCase(),r=n.trim().toLowerCase();return{countryValid:Vj.some(u=>u.value===i),languageValid:$j.some(u=>u.value===r)}}function rF(e){const n=e.replace(/^\[|\]$/g,"");return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(n)||n.includes(":")}function lF(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"||rF(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 cF(e,n=JQ){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 uF(e,n){e.catch(()=>{ln({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 Uj(e){const n=C.useRef(lg()).current,i=C.useRef(new Set),r=C.useCallback((u,h)=>{if(h){if(i.current.has(h))return;i.current.add(h)}Z0({...u,surface:e,eventId:cg()})},[e]);return{onboardingSessionId:n,emit:r}}function hw(e,n){return e instanceof Cn&&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 Af(){return c.jsxs("div",{className:"page-container max-w-3xl","aria-busy":"true","aria-live":"polite",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Preparing setup"}),c.jsx("p",{className:"page-subtitle",children:"Checking the projects already on this install."})]})}),c.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-default bg-surface p-4 text-sm text-secondary",role:"status",children:[c.jsx(pr,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading projects…"]})]})}function dF({onRetry:e}){return c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Can’t load projects"}),c.jsx("p",{className:"page-subtitle",children:"Canonry could not confirm whether this install already has a project."})]})}),c.jsxs("div",{className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",tabIndex:-1,children:[c.jsx("p",{className:"text-sm font-medium text-heading",children:"Setup is paused to protect existing projects."}),c.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Check the connection or sign in again, then retry."}),c.jsx(me,{type:"button",className:"mt-4",variant:"secondary",onClick:e,children:"Retry project check"})]})]})}function mF({projectName:e,initialRunId:n}){return c.jsx(mg,{title:"Site Health setup",children:c.jsx(pF,{projectName:e,initialRunId:n})})}function pF({projectName:e,initialRunId:n}){const i=fs(),r=Nt({...po({client:ee}),enabled:!!e,retry:!1,refetchOnMount:"always"}),{onboardingSessionId:u,emit:h}=Uj("site_health"),[g]=C.useState(()=>fQ(n));C.useEffect(()=>{g&&gQ()},[g]),C.useEffect(()=>{e&&h({flowVersion:lt,onboardingSessionId:u,event:"onboarding.started",step:"run",resumed:!!n&&!g},"onboarding.started")},[h,g,n,u,e]),C.useEffect(()=>{!e||!n||Pj(e)?.runId!==n&&Ij(e,n)},[n,e]);const v=Nt({...W0({client:ee,path:{id:n??""}}),enabled:!!n,refetchInterval:({state:_})=>{const U=_.data?.status;return U==="completed"||U==="partial"||U==="failed"||U==="cancelled"?!1:2e3},refetchIntervalInBackground:!0}).data?.status;if(C.useEffect(()=>{if(!e||!n||!v)return;if(v==="completed"||v==="partial"){h({flowVersion:lt,onboardingSessionId:u,event:"onboarding.step_completed",step:"run",method:"automatic"},"onboarding.step_completed:run"),gd(n);return}if(v!=="failed"&&v!=="cancelled")return;const _=v==="cancelled"?"run_cancelled":"run_failed";h({flowVersion:lt,onboardingSessionId:u,event:"onboarding.blocked",step:"run",action:"retry_run",reasonCode:_},`onboarding.blocked:run:${_}`),gd(n)},[h,n,u,e,v]),!e)return c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Project not found"}),c.jsx("p",{className:"page-subtitle",children:"This setup link does not identify a project."})]})}),c.jsx(me,{type:"button",variant:"secondary",onClick:()=>{i({to:"/projects"})},children:"View projects"})]});if(r.isPending)return c.jsxs("div",{className:"page-container max-w-3xl","aria-busy":"true","aria-live":"polite",children:[c.jsx(lo,{current:"site"}),c.jsxs("div",{className:"mt-8 flex items-center gap-3 text-sm text-secondary",role:"status",children:[c.jsx(pr,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading Site Health setup…"]})]});if(r.isError)return c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Can’t resume setup"}),c.jsx("p",{className:"page-subtitle",children:"Canonry could not load the project for this Site Health scan."})]})}),c.jsxs("div",{className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",children:[c.jsx("p",{className:"text-sm text-secondary",children:"Check the connection or sign in again, then retry."}),c.jsx(me,{type:"button",className:"mt-4",variant:"secondary",onClick:()=>{r.refetch()},children:"Retry project check"})]})]});const w=r.data.find(_=>_.name===e);if(!w)return c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Project not found"}),c.jsxs("p",{className:"page-subtitle",children:["Canonry could not find ",e,". It will not open a different project."]})]})}),c.jsx(me,{type:"button",variant:"secondary",onClick:()=>{i({to:"/projects"})},children:"View projects"})]});const S=()=>{i({to:"/setup",search:{onboarding:"site-health",setupProject:w.name},replace:!0})},A=()=>{i({to:"/setup",search:{experience:"legacy",onboarding:"site-health",setupProject:w.name},replace:!0})},R=()=>{h({flowVersion:lt,onboardingSessionId:u,event:"onboarding.step_completed",step:"run",method:"skipped"},"onboarding.step_completed:run"),i({to:"/setup",search:{onboarding:"complete",setupProject:w.name,skipped:"visibility"},replace:!0})};return c.jsxs("div",{className:"page-container max-w-7xl py-8 md:py-10",children:[c.jsx("h1",{className:"sr-only",children:"Set up Canonry"}),c.jsx(C.Suspense,{fallback:c.jsxs("div",{className:"space-y-5",children:[c.jsx(lo,{current:"site"}),c.jsxs("div",{className:"flex min-h-72 items-center justify-center gap-3 text-sm text-secondary",role:"status",children:[c.jsx(pr,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading Site Health…"]})]}),children:c.jsx(YQ,{projectName:w.name,projectId:w.id,initialRunId:n,onReleaseInitialRun:S,showOnboardingActions:!0,onContinueOnboarding:A,onSkipOnboarding:R})})]})}function hF(){const e=gw({from:"/setup"}),n=e.onboarding==="site-health"&&!e.setupProject,i=e.onboarding==="site-health"&&e.experience!=="legacy",r=iV(),u=e.experience==="legacy"?"legacy":e.experience==="platform"?"platform":r,[h,g]=C.useState(!1),[b,v]=C.useState(void 0),w=Nt({...po({client:ee}),enabled:u==="auto",retry:!1,refetchOnMount:"always"}),S=Nt({...Yd({client:ee,query:{kind:Ee["site-audit"],since:nF,limit:aF}}),enabled:u==="auto",retry:!1,refetchOnMount:"always"}),A=u==="auto"&&w.isSuccess&&w.isFetchedAfterMount&&w.data.length===0;C.useEffect(()=>{A&&g(!0)},[A]);const R=u!=="auto"?{state:"idle"}:w.isSuccess&&w.isFetchedAfterMount?{state:"success",projectCount:w.data.length}:w.isError?{state:"error"}:{state:"loading"},_=u==="legacy"?"legacy":h||A?"platform":tF(u,R);if(e.onboarding==="complete"&&e.setupProject)return c.jsx(PQ,{projectName:e.setupProject,skippedVisibility:e.skipped==="visibility"});if(n||i)return c.jsx(mF,{projectName:e.setupProject,initialRunId:e.siteHealthRunId});const U=u==="auto"&&_==="legacy"&&!e.setupProject&&w.isSuccess;if(U&&b===void 0)return S.isError?v(null):S.isSuccess&&S.isFetchedAfterMount&&v(iF(w.data,S.data)),c.jsx(Af,{});const T=U?b:null;return T?c.jsx(fF,{projectName:T.projectName,runId:T.runId}):_==="legacy"?c.jsx(DQ,{visibilityProjectName:e.setupProject,siteHealthOnboarding:e.onboarding==="site-health",onboardingFinish:e.onboarding==="site-health"||e.onboarding==="first-run"}):_==="loading"?c.jsx(Af,{}):_==="retry"?c.jsx(dF,{onRetry:()=>{w.refetch()}}):c.jsx(gF,{onActivationStarted:()=>g(!0),skipSiteScan:e.siteScan==="skip"})}function fF({projectName:e,runId:n}){const i=fs();return C.useEffect(()=>{i({to:"/setup",search:{onboarding:"site-health",setupProject:e,...n?{siteHealthRunId:n}:{}},replace:!0})},[i,e,n]),c.jsx(Af,{})}function gF({onActivationStarted:e,skipSiteScan:n}){return c.jsx(mg,{title:"Site Health setup",children:c.jsx(yF,{onActivationStarted:e,skipSiteScan:n})})}function yF({onActivationStarted:e,skipSiteScan:n}){const i=fs(),r=ka(),u=SQ(),h=Nt({...F$({client:ee}),retry:!1}),g=gs(Z$()),[b,v]=C.useState(""),[w,S]=C.useState(""),[A,R]=C.useState(""),[_,U]=C.useState("US"),[T,P]=C.useState("en"),[F,ae]=C.useState(!1),[L,te]=C.useState("idle"),[J,se]=C.useState(null),[H,G]=C.useState(null),[ke,Ke]=C.useState(!1),[He,Ne]=C.useState(null),[et,ze]=C.useState(!1),Le=h.isError?void 0:h.data,q=typeof Le?.enabled=="boolean"?Le.enabled:null,Y=g.isPending?g.variables.body.enabled:q,[fe,be]=C.useState(null),ne=C.useRef(null),{onboardingSessionId:De,emit:Oe}=Uj("platform");C.useEffect(()=>{Oe({flowVersion:lt,onboardingSessionId:De,event:"onboarding.started",step:"project",resumed:!1},"onboarding.started")},[Oe,De]);const ve=lF(b),oe=w||ve?.projectName||"",ue=A||ve?.displayName||"",K=L==="creating"||L==="dispatching",ce=H??He,Ue=sF(_,T),{countryValid:xe,languageValid:Xe}=oF(_,T),Ve=xe&&Xe;C.useEffect(()=>{ce&&ne.current?.focus()},[ce]);const ut=(Re,Je)=>i({to:"/setup",search:{...Je?{siteHealthRunId:Je}:{},onboarding:"site-health",setupProject:Re.name},replace:!0}),Be=async Re=>{te("dispatching"),Ne(null);try{const Je=u.mutateAsync({projectName:Re.name,projectId:Re.id,projectLabel:Re.displayName||Re.name,suppressErrorToast:!0,body:{checkDeadLinks:!0,maxPages:wS}}),Qt=await cF(Je);if(Qt.state==="queued"){Oe({flowVersion:lt,onboardingSessionId:De,event:"run.requested",origin:"dashboard_setup",result:"queued",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0"}),hQ(Qt.run.runId),await ut(Re,Qt.run.runId);return}Je.then(()=>{Oe({flowVersion:lt,onboardingSessionId:De,event:"run.requested",origin:"dashboard_setup",result:"queued",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0"})},bn=>{Oe({flowVersion:lt,onboardingSessionId:De,event:"run.requested",origin:"dashboard_setup",result:"rejected",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0",reasonCode:Fl(bn,"run_rejected")})}),uF(Je,Re.id),await ut(Re)}catch(Je){te("recovery"),Ne(hw(Je,"The project was created, but the Site Health scan could not be started."));const Qt=Fl(Je,"run_rejected");Oe({flowVersion:lt,onboardingSessionId:De,event:"run.requested",origin:"dashboard_setup",result:"rejected",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0",reasonCode:Qt}),Oe({flowVersion:lt,onboardingSessionId:De,event:"onboarding.blocked",step:"run",action:"retry_run",reasonCode:Qt},`onboarding.blocked:run:${Qt}`)}},re=async Re=>{if(Re.preventDefault(),!(!ve||!n&&!F||!Ve||K)){te("creating"),G(null),Ke(!1),Ne(null);try{const Je=await jV({name:oe,displayName:ue,canonicalDomain:ve.canonicalDomain,country:_,language:T});if(e(),se(Je),Oe({flowVersion:lt,onboardingSessionId:De,event:"onboarding.step_completed",step:"project",method:"manual"},"onboarding.step_completed:project"),await r.invalidateQueries({queryKey:hs({client:ee})}),n){await i({to:"/setup",search:{experience:"legacy",onboarding:"first-run",setupProject:Je.name},replace:!0});return}await Be(Je)}catch(Je){te("idle");const Qt=Je instanceof Cn&&Je.statusCode===409;Ke(Qt),G(hw(Je,"Could not create the project. Try again.")),Oe({flowVersion:lt,onboardingSessionId:De,event:"onboarding.blocked",step:"project",action:"save",reasonCode:Fl(Je,"project_create_failed")},"onboarding.blocked:project"),Qt&&(e(),r.invalidateQueries({queryKey:hs({client:ee})}))}}},ct=()=>{J&&!K&&Be(J)},Vt=()=>{K||i({to:"/projects"})},qn=async()=>{try{await navigator.clipboard.writeText(eF),ze(!0)}catch{ln({tone:"negative",title:"Could not copy setup request",detail:"Open the agent quickstart to continue with the CLI instead."})}},_t=async Re=>{be(null);try{const Je=await g.mutateAsync({client:ee,body:{enabled:Re}});r.setQueryData(J3({client:ee}),Je),Je.enabled!==Re&&be(`The server kept telemetry ${Je.enabled?"on":"off"}. Check its telemetry settings.`)}catch{be("Could not update telemetry. Try again.")}};return J&&L==="recovery"?c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx(lo,{current:"site"}),c.jsx("div",{className:"page-header mt-8",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Project created"}),c.jsxs("p",{className:"page-subtitle",children:[J.displayName||J.name," is ready. The Site Health scan needs another try."]})]})}),c.jsxs("div",{ref:ne,className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",tabIndex:-1,children:[c.jsx("p",{className:"text-sm font-medium text-heading",children:He}),c.jsx("p",{className:"mt-1 text-sm text-secondary",children:"You can retry the scan or continue setup and retry from Site Health."}),c.jsxs("div",{className:"mt-4 flex flex-wrap gap-3",children:[c.jsx(me,{type:"button",onClick:ct,children:"Retry Site Health scan"}),c.jsx(me,{type:"button",variant:"secondary",onClick:()=>{ut(J)},children:"Continue setup"})]})]})]}):c.jsxs("div",{className:"page-container max-w-xl py-8 md:py-12",children:[n?null:c.jsx(lo,{current:"site"}),c.jsxs("header",{className:`mb-8 ${n?"":"mt-8"}`,children:[c.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"}),c.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."})]}),c.jsxs("form",{"aria-labelledby":"site-map-setup-title",className:"space-y-6",onSubmit:an(re),noValidate:!0,children:[c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm font-medium text-heading",htmlFor:"launchpad-domain",children:"Website URL"}),c.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&&!ve),"aria-describedby":b&&!ve?"launchpad-domain-hint launchpad-domain-error":"launchpad-domain-hint",placeholder:"https://example.com",value:b,onChange:Re=>{v(Re.target.value),G(null),Ke(!1)}}),c.jsx("p",{id:"launchpad-domain-hint",className:"text-sm text-secondary",children:n?c.jsxs(c.Fragment,{children:["A public domain is still required."," ",c.jsx(Fe,{to:"/setup",search:{experience:"platform"},className:"font-medium text-link underline-offset-4 hover:underline",children:"Map with Site Health instead"})]}):c.jsxs(c.Fragment,{children:["Only public pages are scanned."," ",c.jsx(Fe,{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&&!ve?c.jsx("p",{id:"launchpad-domain-error",className:"text-sm text-negative",role:"alert",children:"Enter a public domain, such as example.com."}):null]}),c.jsxs("details",{className:"group border-y border-default",children:[c.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:[c.jsx("span",{className:"font-medium text-heading",children:"Project name and locale"}),c.jsxs("span",{className:"flex items-center gap-2 text-secondary",children:[Ue,c.jsx(bd,{className:"size-4 transition-transform group-open:rotate-180 motion-reduce:transition-none","aria-hidden":"true"})]})]}),c.jsxs("div",{className:"space-y-5 border-t border-default py-4",children:[ve?c.jsxs("div",{children:[c.jsx("p",{className:"mb-3 text-sm font-medium text-heading",children:"Project"}),c.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-project-name",children:"Project name"}),c.jsx("input",{id:"launchpad-project-name",className:"setup-input h-10",type:"text",value:oe,onChange:Re=>S(Re.target.value)})]}),c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-display-name",children:"Display name"}),c.jsx("input",{id:"launchpad-display-name",className:"setup-input h-10",type:"text",value:ue,onChange:Re=>R(Re.target.value)})]})]})]}):null,c.jsxs("div",{children:[c.jsx("p",{className:"mb-3 text-sm font-medium text-heading",children:"Locale"}),c.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-country",children:"Country"}),c.jsx("select",{id:"launchpad-country",className:"setup-input h-10",value:_,onChange:Re=>U(Re.target.value),children:Vj.map(Re=>c.jsx("option",{value:Re.value,children:Re.label},Re.value))})]}),c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-language",children:"Language"}),c.jsx("select",{id:"launchpad-language",className:"setup-input h-10",value:T,onChange:Re=>P(Re.target.value),children:$j.map(Re=>c.jsx("option",{value:Re.value,children:Re.label},Re.value))})]})]})]})]})]}),n?null:c.jsxs("label",{className:"flex min-h-11 cursor-pointer items-start gap-3 py-2",children:[c.jsx("input",{className:"mt-0.5 size-4 shrink-0 rounded border-strong bg-bg",type:"checkbox",checked:F,onChange:Re=>ae(Re.target.checked),"aria-label":"Allow Canonry to scan this public site."}),c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"text-sm leading-5 text-heading",children:"Allow Canonry to scan this public site."}),c.jsx(Ws,{text:XQ})]})]}),ce?c.jsxs("div",{ref:ne,className:"rounded-md border border-negative bg-negative-soft p-3",role:"alert",tabIndex:-1,children:[c.jsx("p",{className:"text-sm font-medium text-heading",children:ce}),ke?c.jsx(me,{type:"button",variant:"secondary",size:"sm",className:"mt-3",onClick:Vt,children:"View projects"}):null]}):null,c.jsxs("div",{className:"grid gap-2",children:[c.jsx(me,{className:"h-11 w-full",type:"submit",disabled:!ve||!n&&!F||!Ve||K,children:L==="creating"||L==="dispatching"?c.jsxs(c.Fragment,{children:[c.jsx(pr,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"})," ",n?"Creating project…":"Mapping site…"]}):n?"Create project":"Scan site"}),L==="dispatching"?c.jsx("span",{className:"text-center text-sm text-secondary",role:"status",children:"Opening Site Health when the scan is ready."}):null]})]}),c.jsxs("section",{className:"mt-8 border-t border-default pt-6","aria-labelledby":"agent-setup-title",children:[c.jsx("p",{id:"agent-setup-title",className:"text-sm font-medium text-heading",children:"Use your agent instead"}),c.jsx("p",{className:"mt-1 text-sm leading-5 text-secondary",children:"Copy a complete CLI setup request into any agent."}),c.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-1",children:[c.jsxs(me,{type:"button",variant:"ghost",size:"sm",className:"-ml-3",onClick:an(qn),children:[et?c.jsx(vd,{className:"size-3.5","aria-hidden":"true"}):c.jsx(Rf,{className:"size-3.5","aria-hidden":"true"}),c.jsx("span",{"aria-live":"polite",children:et?"Copied setup request":"Copy setup request"})]}),c.jsx(me,{asChild:!0,variant:"ghost",size:"sm",children:c.jsxs("a",{href:WQ,target:"_blank",rel:"noopener noreferrer",children:["Agent quickstart",c.jsx(jC,{className:"size-3.5","aria-hidden":"true"}),c.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]})})]})]}),q!==null?c.jsxs("section",{className:"mt-6 border-t border-default pt-5","aria-labelledby":"telemetry-title",children:[c.jsxs("label",{className:`flex min-h-11 items-start gap-3 py-2 ${g.isPending?"cursor-wait":"cursor-pointer"}`,children:[c.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:Y??!1,disabled:g.isPending,onChange:Re=>{_t(Re.target.checked)},"aria-describedby":"telemetry-detail"}),c.jsxs("span",{className:"grid gap-0.5",children:[c.jsx("span",{id:"telemetry-title",className:"text-sm leading-5 text-heading",children:"Share anonymous product telemetry"}),c.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."})]})]}),g.isPending?c.jsx("p",{className:"mt-1 text-sm text-secondary",role:"status",children:"Saving preference…"}):null,fe?c.jsx("p",{className:"mt-1 text-sm text-negative",role:"alert",children:fe}):null]}):null]})}function bF(){return c.jsx("div",{className:"page-container",children:c.jsx("section",{className:"page-section",children:c.jsxs(ba,{className:"surface-card empty-card",children:[c.jsx("h1",{children:"Route not found"}),c.jsx("p",{children:"The current path does not map to a dashboard view."}),c.jsx(me,{asChild:!0,children:c.jsx(Fe,{to:"/",children:"Return to overview"})})]})})})}const aa=ys(()=>Ni(()=>import("./ProjectPage-D-lDBpPV.js"),__vite__mapDeps([5,1,2,6,0,3,4,7,8,9,10,11,12]),import.meta.url),"ProjectPage"),vF=ys(()=>Ni(()=>import("./RunsPage-DvoNDx6z.js"),__vite__mapDeps([13,1,6,11,4,2,9,12]),import.meta.url),"RunsPage"),xF=ys(()=>Ni(()=>import("./HistoryPage-DWn459Gu.js"),__vite__mapDeps([14,1,10,11,4,2,9,12]),import.meta.url),"HistoryPage"),wF=ys(()=>Ni(()=>import("./SettingsPage-DXbhM5Lv.js"),__vite__mapDeps([15,1,11,4,2,9,12]),import.meta.url),"SettingsPage"),kF=ys(()=>Ni(()=>import("./BacklinksPage-DsQAKO31.js"),__vite__mapDeps([16,1,2,11,4,9,12]),import.meta.url),"BacklinksPage"),SF=ys(()=>Ni(()=>import("./TrafficPage-EYSxLxkQ.js"),__vite__mapDeps([17,1,7,2,11,4,9,12]),import.meta.url),"TrafficPage"),jF=ys(()=>Ni(()=>import("./TrafficSourceDetailPage-DY4sV_BX.js"),__vite__mapDeps([18,1,7,3,4,2,11,9,12]),import.meta.url),"TrafficSourceDetailPage"),AF=ys(()=>Ni(()=>import("./MeasurementPropertyPage-D6pUcBiT.js"),__vite__mapDeps([19,1,3,4,8,9,2,11,12]),import.meta.url),"MeasurementPropertyPage");function CF(){return c.jsx(JH,{children:c.jsx(r$,{children:c.jsx(XH,{})})})}const Dn=W4()({component:CF,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]))})}),NF=Et({getParentRoute:()=>Dn,path:"/",component:aQ,beforeLoad:async({context:e})=>{let n=e.queryClient.getQueryData(hs({client:ee}));if(n===void 0)try{n=await e.queryClient.ensureQueryData(po({client:ee}))}catch{return}if(n.length===0)throw bw({to:"/setup"})}}),_F=Et({getParentRoute:()=>Dn,path:"/projects",component:rQ}),TF=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,On=Et({getParentRoute:()=>Dn,path:"/projects/$projectName",component:()=>c.jsx(Lh,{}),beforeLoad:async({context:e,params:n,location:i})=>{const r=n.projectName;if(!TF.test(r))return;let u=e.queryClient.getQueryData(hs({client:ee}));if(!u)try{u=await e.queryClient.ensureQueryData(po({client:ee}))}catch{return}const h=u.find(g=>g.id===r);if(h)throw bw({to:i.pathname.replace(`/projects/${r}`,`/projects/${encodeURIComponent(h.name)}`),replace:!0})}}),RF=Et({getParentRoute:()=>On,path:"/",component:()=>c.jsx(aa,{tab:"overview"})}),EF=Et({getParentRoute:()=>On,path:"/portfolio",component:()=>c.jsx(aa,{tab:"portfolio"})}),zF=Et({getParentRoute:()=>On,path:"/search-console",component:()=>c.jsx(aa,{tab:"search-console"})}),DF=Et({getParentRoute:()=>On,path:"/conversions",component:()=>c.jsx(aa,{tab:"conversions"})}),OF=Et({getParentRoute:()=>On,path:"/local",component:()=>c.jsx(aa,{tab:"local"})}),qF=Et({getParentRoute:()=>On,path:"/discovery",component:()=>c.jsx(aa,{tab:"discovery"})}),IF=Et({getParentRoute:()=>On,path:"/queries",component:()=>c.jsx(aa,{tab:"queries"})}),PF=Et({getParentRoute:()=>On,path:"/properties/$targetKey",component:()=>c.jsx(AF,{})}),MF=Et({getParentRoute:()=>On,path:"/report",component:()=>c.jsx(aa,{tab:"report"})}),BF=Et({getParentRoute:()=>On,path:"/activity",component:()=>c.jsx(aa,{tab:"activity"})}),LF=Et({getParentRoute:()=>On,path:"/backlinks",component:()=>c.jsx(aa,{tab:"backlinks"})}),VF=Et({getParentRoute:()=>On,path:"/technical-aeo",component:()=>c.jsx(aa,{tab:"technical-aeo"})}),$F=Et({getParentRoute:()=>On,path:"/history",component:()=>c.jsx(aa,{tab:"history"})}),UF=Et({getParentRoute:()=>On,path:"/settings",component:()=>c.jsx(aa,{tab:"settings"})}),GF=Et({getParentRoute:()=>Dn,path:"/runs",component:vF}),KF=Et({getParentRoute:()=>Dn,path:"/history",component:xF}),HF=Et({getParentRoute:()=>Dn,path:"/settings",component:wF,beforeLoad:({context:e})=>{}}),QF=Et({getParentRoute:()=>Dn,path:"/setup",component:hF}),FF=Et({getParentRoute:()=>Dn,path:"/backlinks",component:kF}),ZF=Et({getParentRoute:()=>Dn,path:"/traffic",component:SF}),YF=Et({getParentRoute:()=>Dn,path:"/traffic/$projectName/$sourceId",component:jF}),XF=Et({getParentRoute:()=>Dn,path:"*",component:bF}),JF=Dn.addChildren([NF,_F,On.addChildren([RF,EF,zF,DF,OF,qF,IF,PF,MF,BF,LF,VF,$F,UF]),GF,KF,HF,QF,FF,ZF,YF,XF]);function WF(){return typeof window<"u"&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath:"/"}const fw=WF(),eZ=fw==="/"?"":fw.replace(/\/$/,"");function tZ(e,n){return eC({routeTree:JF,basepath:eZ||"/",context:{queryClient:e},...n?.initialEntries})}const nZ=6e4;function aZ(){const e=C.useRef(wV()).current,[n,i]=C.useState(e?"ready":"checking"),[r,u]=C.useState(null),[h,g]=C.useState(null),[b,v]=C.useState(e),[w,S]=C.useState(!1),[A,R]=C.useState(""),[_,U]=C.useState(""),[T,P]=C.useState(""),[F,ae]=C.useState(!1),[L,te]=C.useState("password"),[J,se]=C.useState(null),[H,G]=C.useState(!1),[ke,Ke]=C.useState(!1),He=C.useRef(null),Ne=C.useRef(null),et=C.useRef(null),ze=()=>{const K=r?`${r.name}:${r.role}`:e?"api-key:explicit":h?`api-key:${h.id}`:"no-accounts";if(!He.current||et.current!==K){Ne.current?.clear();const ce=i$();Ne.current=ce,He.current=tZ(ce),et.current=K}return{queryClient:Ne.current,router:He.current}},Le=K=>K.authRequired?(S(!0),u(K.user),g(null),v(!1),i(K.user?"ready":"account-login"),!0):!1;C.useEffect(()=>{let K=!1;const ce=async(Ue,xe=!1)=>{try{const Xe=await zh();if(K)return;g(Xe),v(!1),i("ready")}catch(Xe){if(K)return;if(xe&&Xe instanceof Cn&&Xe.statusCode===401)return DV().then(()=>{K||(se(null),g(null),v(!1),Ke(!0),i("login"))}).catch(Ve=>{K||(se(Ve instanceof Error?Ve.message:"Could not clear the invalid session"),i(Ue))});se(Xe instanceof Error?Xe.message:"Could not verify API key access"),i(Ue)}};return e?(ce("api-key-error"),()=>{K=!0}):(Promise.allSettled([Nx(),Cx()]).then(([Ue,xe])=>{if(K||Ue.status==="fulfilled"&&Le(Ue.value))return;if(xe.status==="rejected"){const Ve=xe.reason;se(Ve instanceof Error?Ve.message:"Failed to reach the Canonry API"),i("login");return}const Xe=xe.value;Xe.authenticated?(v(!0),ce("api-key-error",!0)):(g(null),v(!1),i(Xe.setupRequired?"setup":"login"))}),()=>{K=!0})},[]),C.useEffect(()=>{if(n!=="ready"||e)return;const K=setInterval(()=>{if(w){Nx().then(ce=>{ce.authRequired&&!ce.user&&(Ke(!0),u(null),g(null),i("account-login"))}).catch(()=>{});return}Cx().then(ce=>{ce.authenticated||(Ke(!0),g(null),i(ce.setupRequired?"setup":"login"))}).catch(()=>{})},nZ);return Ax(()=>{Ke(!0),u(null),g(null),v(!1),i(w?"account-login":"login")}),()=>{clearInterval(K),Ax(null)}},[n,w,e]);const q=async K=>{if(K.preventDefault(),!_.trim()||_.trim().length<8){se("Password must be at least 8 characters");return}if(_!==T){se("Passwords do not match");return}G(!0),se(null);try{if(!(await RV(_.trim())).authenticated){se("Setup failed");return}U(""),P(""),ae(!1),Ke(!1),g(null),v(!0),i("checking");try{const Ue=await zh();g(Ue),v(!1),i("ready")}catch(Ue){se(Ue instanceof Error?Ue.message:"Could not verify API key access"),i("api-key-error")}}catch(ce){se(ce instanceof Cn||ce instanceof Error?ce.message:"Setup failed")}finally{G(!1)}},Y=K=>{U(K),se(null)},fe=K=>{P(K),se(null)},be=async K=>{if(K.preventDefault(),!!_.trim()){G(!0),se(null);try{if(!(L==="api-key"?await zV(_.trim()):await EV(_.trim())).authenticated){se(L==="api-key"?"Invalid API key":"Incorrect password");return}const Ue=await zh();g(Ue),v(!1),U(""),ae(!1),Ke(!1),i("ready")}catch(ce){se(ce instanceof Cn||ce instanceof Error?ce.message:"Authentication failed")}finally{G(!1)}}},ne=K=>{te(K),U(""),ae(!1),se(null)},De=async K=>{if(K.preventDefault(),!(!A.trim()||!_)){G(!0),se(null);try{const ce=await OV(A.trim(),_);if(!ce.user){se("Incorrect name or password.");return}U(""),Ke(!1),u(ce.user),g(null),v(!1),i("ready")}catch(ce){se(ce instanceof Cn?ce.message:"Incorrect name or password.")}finally{G(!1)}}};if(n==="ready"){const{queryClient:K,router:ce}=ze();return c.jsx(FV,{account:r,apiKey:h,apiKeyPending:b,children:c.jsx(tC,{client:K,children:c.jsx(nC,{router:ce})})})}const Oe=_.trim(),ve=_.length>0&&Oe.length<8,oe=T.length>0&&_!==T,ue=Oe.length>=8&&_===T;return c.jsx("div",{className:"min-h-screen bg-bg px-4 py-8",children:c.jsxs("div",{className:"mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col items-center justify-center gap-5",children:[c.jsxs("div",{"data-testid":"auth-brand",className:"flex items-center gap-2.5",children:[c.jsx("img",{className:"size-7",src:"./favicon.svg",alt:"","aria-hidden":"true"}),c.jsx("span",{className:"text-lg font-semibold tracking-tight text-heading",children:"Canonry"})]}),c.jsx(ba,{className:"surface-card w-full",children:n==="checking"?c.jsx(eo,{className:"py-8",children:c.jsx("p",{className:"supporting-copy text-center",children:"Connecting to Canonry…"})}):n==="api-key-error"?c.jsxs(c.Fragment,{children:[c.jsxs(ur,{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),c.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Could not verify API key access"})]}),c.jsxs(eo,{className:"space-y-4",children:[c.jsx("p",{className:"supporting-copy",children:J??"Canonry could not verify this session’s access, so the dashboard stayed locked."}),c.jsx(me,{type:"button",className:"w-full",onClick:()=>{window.location.reload()},children:"Try again"})]})]}):n==="account-login"?c.jsxs(c.Fragment,{children:[c.jsxs(ur,{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),c.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Sign in to Canonry"})]}),c.jsxs(eo,{children:[ke?c.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,c.jsxs("form",{className:"space-y-4",onSubmit:an(De),children:[c.jsxs("label",{className:"block space-y-1.5",htmlFor:"account-name",children:[c.jsx("span",{className:"text-xs font-medium text-secondary",children:"Name"}),c.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:A,onChange:K=>{R(K.target.value),se(null)},"aria-invalid":!!J,"aria-describedby":J?"account-login-error":void 0})]}),c.jsxs("label",{className:"block space-y-1.5",htmlFor:"account-password",children:[c.jsx("span",{className:"text-xs font-medium text-secondary",children:"Password"}),c.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:_,onChange:K=>Y(K.target.value),"aria-invalid":!!J,"aria-describedby":J?"account-login-error":void 0})]}),J?c.jsx("p",{id:"account-login-error",role:"alert",className:"text-sm text-negative-400",children:J}):null,c.jsx(me,{type:"submit",disabled:H||!A.trim()||!_,children:H?"Signing in…":"Sign in"})]})]})]}):n==="setup"?c.jsxs(c.Fragment,{children:[c.jsxs(ur,{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"First-time setup"}),c.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Create a dashboard password"}),c.jsx(hd,{children:"This password protects the dashboard on this computer."})]}),c.jsx(eo,{children:c.jsxs("form",{className:"space-y-4",onSubmit:an(q),children:[c.jsxs("div",{className:"space-y-1.5",children:[c.jsx("label",{className:"block text-xs font-medium text-secondary",htmlFor:"dashboard-password-new",children:"Password"}),c.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:F?"text":"password",name:"new-password",autoComplete:"new-password",minLength:8,required:!0,value:_,onChange:K=>Y(K.target.value),"aria-invalid":ve,"aria-describedby":"dashboard-password-new-help"}),c.jsx("span",{id:"dashboard-password-new-help","aria-live":"polite",className:ve?"block text-sm text-negative-400":"block text-sm text-secondary",children:ve?"Enter at least 8 characters.":"Use at least 8 characters."})]}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsx("label",{className:"block text-xs font-medium text-secondary",htmlFor:"dashboard-password-confirm",children:"Confirm password"}),c.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:F?"text":"password",name:"confirm-password",autoComplete:"new-password",minLength:8,required:!0,value:T,onChange:K=>fe(K.target.value),"aria-invalid":oe,"aria-describedby":"dashboard-password-confirm-help"}),c.jsx("span",{id:"dashboard-password-confirm-help","aria-live":"polite",className:oe?"block text-sm text-negative-400":"block text-sm text-secondary",children:oe?"Passwords do not match.":"Enter the same password again."})]}),c.jsxs("label",{className:"flex min-h-10 cursor-pointer items-center gap-2 text-sm text-secondary",htmlFor:"dashboard-password-show",children:[c.jsx("input",{id:"dashboard-password-show",type:"checkbox",checked:F,onChange:K=>ae(K.target.checked)}),"Show passwords"]}),J?c.jsx("p",{id:"dashboard-password-setup-error",role:"alert",className:"text-sm text-negative-400",children:J}):null,c.jsx(me,{type:"submit",disabled:H||!ue,children:H?"Creating password…":"Create password and continue"})]})})]}):c.jsxs(c.Fragment,{children:[c.jsxs(ur,{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),c.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Sign in to Canonry"}),c.jsx(hd,{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."})]}),c.jsxs(eo,{children:[ke?c.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,c.jsxs("form",{className:"space-y-4",onSubmit:an(be),children:[c.jsxs("label",{className:"block space-y-1.5",htmlFor:"dashboard-password-current",children:[c.jsx("span",{className:"text-xs font-medium text-secondary",children:L==="api-key"?"Canonry API key":"Password"}),c.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:F?"text":"password",name:L==="api-key"?"apiKey":"password",autoComplete:L==="api-key"?"off":"current-password",spellCheck:!1,required:!0,value:_,onChange:K=>Y(K.target.value),"aria-invalid":!!J,"aria-describedby":J?"dashboard-password-login-error":void 0})]}),c.jsxs("label",{className:"flex min-h-10 cursor-pointer items-center gap-2 text-sm text-secondary",htmlFor:"dashboard-login-password-show",children:[c.jsx("input",{id:"dashboard-login-password-show",type:"checkbox",checked:F,onChange:K=>ae(K.target.checked)}),L==="api-key"?"Show API key":"Show password"]}),J?c.jsx("p",{id:"dashboard-password-login-error",role:"alert",className:"text-sm text-negative-400",children:J}):null,c.jsx(me,{type:"submit",disabled:H||!_.trim(),children:H?"Signing in…":"Open dashboard"}),c.jsx(me,{type:"button",variant:"ghost",onClick:()=>ne(L==="api-key"?"password":"api-key"),children:L==="api-key"?"Use dashboard password instead":"Forgot password? Use API key"})]})]})]})})]})})}const Gj=document.getElementById("root");if(!Gj)throw new Error("Expected #root element for web app bootstrap.");zC.createRoot(Gj).render(c.jsx(C.StrictMode,{children:c.jsx(aZ,{})}));export{JX as $,vf as A,me as B,cd as C,LJ as D,PZ as E,MJ as F,VJ as G,BX as H,Ws as I,IJ as J,MW as K,VW as L,Oee as M,LW as N,FX as O,mK as P,QX as Q,iJ as R,c$ as S,jn as T,ln as U,GW as V,KW as W,WX as X,HW as Y,eJ as Z,YX as _,Dee as a,dV as a$,$W as a0,UW as a1,BW as a2,ZX as a3,QW as a4,eee as a5,YW as a6,JW as a7,XW as a8,WW as a9,Js as aA,t$ as aB,WJ as aC,vH as aD,XX as aE,GZ as aF,IZ as aG,NX as aH,fD as aI,yn as aJ,qZ as aK,OZ as aL,$Z as aM,k$ as aN,G$ as aO,sW as aP,uW as aQ,oW as aR,SY as aS,AY as aT,DB as aU,CY as aV,D$ as aW,iW as aX,qB as aY,cf as aZ,jY as a_,kJ as aa,eg as ab,Ee as ac,ZW as ad,nj as ae,Ci as af,FW as ag,Hee as ah,jq as ai,Aq as aj,HZ as ak,KZ as al,AJ as am,EJ as an,zJ as ao,Cn as ap,DJ as aq,RX as ar,u$ as as,gG as at,mf as au,OJ as av,Yu as aw,pee as ax,$l as ay,wf as az,qI as b,cY as b$,rW as b0,aW as b1,q$ as b2,lW as b3,Lee as b4,cW as b5,bee as b6,vee as b7,tJ as b8,J0 as b9,RZ as bA,TZ as bB,_Z as bC,NZ as bD,jZ as bE,SZ as bF,CZ as bG,AZ as bH,kZ as bI,wZ as bJ,hZ as bK,fZ as bL,xZ as bM,vZ as bN,bZ as bO,gZ as bP,yZ as bQ,pZ as bR,mZ as bS,dZ as bT,uZ as bU,a5 as bV,uY as bW,oY as bX,rY as bY,lY as bZ,dY as b_,mee as ba,X3 as bb,fW as bc,yW as bd,AW as be,qW as bf,OW as bg,SW as bh,zW as bi,PW as bj,vW as bk,NW as bl,_W as bm,TW as bn,bW as bo,CW as bp,xW as bq,RW as br,wW as bs,EW as bt,jW as bu,DW as bv,IW as bw,bQ as bx,kW as by,ye as bz,Ik as c,jX as c$,hY as c0,Kee as c1,dee as c2,df as c3,mY as c4,_Y as c5,TY as c6,io as c7,NY as c8,pY as c9,oX as cA,bY as cB,aX as cC,nX as cD,KY as cE,HY as cF,fY as cG,xY as cH,QY as cI,uX as cJ,MZ as cK,bX as cL,vX as cM,hX as cN,gX as cO,BZ as cP,yX as cQ,fX as cR,aY as cS,eX as cT,BY as cU,LY as cV,VY as cW,$Y as cX,UY as cY,GY as cZ,FL as c_,mJ as ca,At as cb,eB as cc,WY as cd,CX as ce,FY as cf,ZY as cg,YY as ch,XY as ci,JY as cj,ZP as ck,iY as cl,Sx as cm,AX as cn,vY as co,yY as cp,zY as cq,UL as cr,kX as cs,SX as ct,wX as cu,xX as cv,lX as cw,q9 as cx,rX as cy,sX as cz,qJ as d,dW as d$,sY as d0,EZ as d1,YP as d2,OY as d3,cX as d4,DZ as d5,gY as d6,RY as d7,DY as d8,EY as d9,UJ as dA,UX as dB,GX as dC,HX as dD,KX as dE,yc as dF,po as dG,M3 as dH,QJ as dI,HJ as dJ,aH as dK,pK as dL,xj as dM,bK as dN,wj as dO,kj as dP,bH as dQ,C$ as dR,to as dS,yd as dT,X$ as dU,_Q as dV,Gee as dW,Mee as dX,gH as dY,Pee as dZ,kQ as d_,LZ as da,dX as db,mX as dc,pX as dd,q3 as de,qY as df,IY as dg,VZ as dh,PY as di,tX as dj,zZ as dk,iX as dl,MY as dm,PX as dn,IX as dp,qX as dq,pJ as dr,Q$ as ds,gW as dt,GJ as du,UZ as dv,Dx as dw,VX as dx,$X as dy,$J as dz,lee as e,Eh as e$,FJ as e0,Iee as e1,JJ as e2,ZJ as e3,mW as e4,qee as e5,YJ as e6,Ht as e7,Ree as e8,AH as e9,xr as eA,Yd as eB,Vee as eC,em as eD,ag as eE,pW as eF,hW as eG,gV as eH,_X as eI,TX as eJ,LX as eK,nJ as eL,aJ as eM,mg as eN,tm as eO,ig as eP,NQ as eQ,dJ as eR,wr as eS,qx as eT,SJ as eU,CJ as eV,_J as eW,TJ as eX,jJ as eY,NJ as eZ,RJ as e_,SV as ea,f$ as eb,CH as ec,Bee as ed,EX as ee,CV as ef,zX as eg,DX as eh,OX as ei,hs as ej,w$ as ek,A$ as el,MX as em,tee as en,MV as eo,cJ as ep,aee as eq,iee as er,see as es,nee as et,BJ as eu,sJ as ev,oJ as ew,rJ as ex,uJ as ey,lJ as ez,ba as f,wJ as f0,gee as f1,sQ as f2,kY as f3,M0 as f4,KJ as f5,hee as f6,yee as f7,xJ as f8,wY as f9,See as fA,QZ as fB,Cee as fC,Tee as fD,Aee as fE,_ee as fF,lo as fG,wS as fH,XZ as fI,eY as fJ,Nee as fK,uI as fL,WZ as fM,JZ as fN,bJ as fa,vJ as fb,yJ as fc,fee as fd,PJ as fe,Nz as ff,eW as fg,XJ as fh,nW as fi,tW as fj,ZZ as fk,Ni as fl,ja as fm,FZ as fn,uV as fo,GU as fp,wee as fq,xee as fr,SQ as fs,jee as ft,kH as fu,tY as fv,YZ as fw,Eee as fx,zee as fy,kee as fz,oee as g,Hx as h,zn as i,ee as j,mV as k,Hl as l,Sn as m,an as n,ree as o,uee as p,cee as q,hJ as r,nY as s,m$ as t,sg as u,gJ as v,fJ as w,na as x,$ee as y,Uee as z};
|
|
86
|
+
competitor2.com`,value:ti,onChange:V=>Di(V.target.value)})]}),Ut?c.jsx("p",{className:"text-negative-400 text-sm",children:Ut}):null,c.jsxs("div",{className:"setup-nav",children:[c.jsx(me,{type:"button",variant:"outline",onClick:Tn,children:"Back"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(me,{type:"button",variant:"outline",onClick:kc,children:"Skip"}),c.jsx(me,{type:"button",disabled:ai.length===0||Lr,onClick:an(Kr),children:Lr?"Saving...":`Save ${ai.length} competitor${ai.length!==1?"s":""}`})]})]})]})]});case 4:{const V=Va.data,$e=V?.status??(Ii===He?.id?He.status:void 0),si=$e==="completed"||$e==="partial"||$e==="failed"||$e==="cancelled",Na=V?.snapshots??[],_o=Na.filter(_a=>_a.citationState==="cited").length,Sc=Na.filter(_a=>_a.answerMentioned===!0).length,mn=new Set(Na.map(_a=>_a.query).filter(_a=>!!_a)).size,Ga=$e?cw($e,Na.length):!1,Ds=Ne&&!La,Os=dn??(V?.error?u$(V.error):$e==="cancelled"?"The sweep was cancelled before it produced a baseline.":($e==="completed"||$e==="partial")&&Na.length===0?"The sweep finished without producing any snapshots.":He?.statusDetail||"The sweep did not produce a baseline.");let qs=null;return Ds||Ga?qs=c.jsx(jn,{tone:"positive",children:"Complete"}):dn&&!La?qs=c.jsx(jn,{tone:"negative",children:"Failed"}):si?qs=c.jsx(jn,{tone:"negative",children:$e==="cancelled"?"Cancelled":"Failed"}):La&&(qs=c.jsx(jn,{tone:"caution",children:"Running"})),c.jsxs(ba,{className:"surface-card step-card",children:[c.jsxs("div",{className:"section-head",children:[c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:_?"Step 2 of 2":"Step 5 of 5"}),c.jsx("h2",{children:Js()?"AI Visibility":"Launch first run"})]}),qs]}),Ds?c.jsxs("div",{className:"compact-stack",children:[c.jsxs("p",{className:"text-secondary",children:["Setup is complete. ",c.jsx("span",{className:"text-strong font-medium",children:Be})," already has a successful answer-visibility baseline."]}),c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(me,{type:"button",onClick:()=>Je(),children:g?"Finish setup":"Open project dashboard →"})]})]}):!La&&Js()?c.jsxs("div",{className:"compact-stack",children:[Be?c.jsx(CH,{projectName:Be}):c.jsx("p",{className:"text-sm text-secondary",children:wf}),dn&&c.jsx("p",{role:"alert",className:"text-sm text-negative",children:dn}),c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(me,{type:"button",onClick:Re,children:"Open project dashboard →"})]})]}):La?si?Ga?c.jsxs("div",{className:"compact-stack",children:[c.jsxs("p",{className:"text-neutral",children:["Sweep complete. Your first answer-visibility snapshot for"," ",c.jsx("span",{className:"text-heading font-medium",children:Be}),":"]}),c.jsxs("div",{className:"grid grid-cols-3 gap-2 mt-1",children:[c.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[c.jsx("p",{className:"text-xs font-medium text-secondary",children:"Mentioned"}),c.jsxs("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:[Sc,c.jsxs("span",{className:"text-faint text-lg",children:[" / ",mn]})]}),c.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"queries naming your brand"})]}),c.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[c.jsx("p",{className:"text-xs font-medium text-secondary",children:"Cited"}),c.jsxs("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:[_o,c.jsxs("span",{className:"text-faint text-lg",children:[" / ",mn]})]}),c.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"queries citing your site"})]}),c.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[c.jsx("p",{className:"text-xs font-medium text-secondary",children:"Results"}),c.jsx("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:Na.length}),c.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"completed engine checks"})]})]}),!b&&Be?c.jsx(CQ,{projectName:Be}):null,c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(me,{type:"button",onClick:()=>Je(),children:g?"Finish setup":"Open project dashboard →"})]})]}):c.jsxs("div",{className:"compact-stack",children:[c.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[c.jsx("p",{children:Os}),c.jsx("p",{className:"mt-1 text-xs text-secondary",children:Js()?wf:w?"Fix provider or query configuration if needed, then retry without leaving setup.":"Ask an administrator to review the provider and query configuration."})]}),c.jsxs("div",{className:"setup-nav",children:[w&&!Js()?c.jsx(me,{type:"button",variant:"outline",asChild:!0,children:c.jsx(Fe,{to:"/settings",children:"Configure providers"})}):c.jsx("span",{}),Js()||!w?c.jsx(me,{type:"button",onClick:Re,children:"Open project dashboard →"}):c.jsx(me,{type:"button",disabled:ni||!!$a,onClick:an(ii),children:ni?"Retrying...":"Retry visibility sweep"})]})]}):c.jsxs("div",{className:"compact-stack",children:[c.jsx("p",{className:"text-neutral",children:"Sweep running. This usually takes 30 to 60 seconds."}),c.jsx("div",{className:"rounded-md border border-default bg-surface p-3 text-xs text-muted",children:c.jsxs("p",{children:["Status: ",c.jsx("span",{className:"text-neutral",children:$e??"queued"})]})}),Va.isError&&c.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[c.jsx("p",{children:Va.error instanceof Error?Va.error.message:"Could not refresh the sweep status."}),c.jsx(me,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:()=>{Va.refetch()},children:"Retry status check"})]}),c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(me,{type:"button",variant:"outline",onClick:g?()=>Je():Re,children:g?"Finish setup":"Watch on project page"})]})]}):c.jsxs("div",{className:"compact-stack",children:[c.jsxs("p",{className:"supporting-copy",children:["Your queries are saved. Run a first sweep to get a baseline for"," ",c.jsx("span",{className:"text-heading font-medium",children:Be}),", or finish and run it later from the project. A sweep calls the answer engines, so it costs provider usage."]}),($a||dn)&&c.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[c.jsx("p",{children:dn??$a}),c.jsx("p",{className:"mt-1 text-xs text-secondary",children:"Resolve the blocker above, then retry the sweep here."})]}),c.jsxs("div",{className:"setup-nav",children:[c.jsx(me,{type:"button",variant:"outline",onClick:Tn,children:"Back"}),c.jsx(me,{type:"button",variant:"ghost",onClick:Qt,children:"Finish without running"}),la==="no_provider"&&!_?c.jsx(me,{type:"button",asChild:!0,children:c.jsx(Fe,{to:"/settings",children:"Configure a provider"})}):c.jsx(me,{type:"button",disabled:ni||!!$a,title:$a,onClick:an(ii),children:ni?"Launching...":dn?"Retry visibility sweep":"Launch visibility sweep"})]})]})]})}default:return null}})();return c.jsxs("div",{className:_?"page-container visibility-setup":"page-container",children:[g?c.jsx(lo,{current:"visibility"}):null,c.jsxs("div",{className:"page-header",children:[c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{ref:u?h:void 0,tabIndex:u?-1:void 0,className:"page-title",children:u?"Set up AI Visibility":"Setup"}),c.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."})]}),g?c.jsx("div",{className:"page-header-right",children:c.jsx(me,{type:"button",variant:"outline",className:"min-h-11",onClick:Qt,children:"Skip AI Visibility"})}):null]}),g?null:c.jsx(zQ,{current:_?q===4?1:0:q,labels:_?RQ:TQ}),c.jsxs("section",{className:"setup-wizard",children:[zs,Ua]})]})}const Bh="canonry mcp install --client claude-code",qQ="https://github.com/Canonry/canonry/blob/main/docs/mcp.md";function IQ(){const e=C.useRef(lg()).current,n=C.useRef(new Set),i=C.useCallback((r,u)=>{n.current.has(r)||(n.current.add(r),Z0({...u,flowVersion:lt,onboardingSessionId:e,surface:"platform",eventId:cg()}))},[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 am=C.createContext(()=>{});function PQ({projectName:e,skippedVisibility:n=!1}){const i=Nt({...GU({client:ee,path:{name:e}}),retry:!1}),r=i.data?.hasData?i.data:null,u=IQ(),h=mw(e,Ee["site-audit"]),g=mw(e,Ee["answer-visibility"]),b={...h?{site:h,fixes:h}:{},...MQ(g,n)};return c.jsx(am.Provider,{value:u,children:c.jsxs("div",{className:"page-container max-w-6xl py-8 md:py-10",children:[c.jsx(lo,{current:"done",outcomes:b}),c.jsxs("header",{className:"relative mx-auto mt-12 max-w-2xl text-center md:mt-16",children:[c.jsx(BQ,{}),c.jsx("p",{className:"onb-reveal mt-6 text-sm font-medium text-positive",style:va(250),children:"Setup complete"}),c.jsx("h1",{className:"onb-reveal mt-2 text-5xl font-semibold tracking-tight text-heading md:text-6xl",style:va(350),children:"You’re set."}),c.jsxs("p",{className:"onb-reveal mx-auto mt-4 max-w-xl text-lg text-secondary",style:va(450),children:["Canonry is tracking ",c.jsx("span",{className:"font-medium text-heading",children:e}),". Here’s how to get the most out of it from here."]})]}),c.jsxs("div",{className:"mt-14 grid gap-4 md:grid-cols-6",children:[c.jsx(Gu,{className:"md:col-span-4 md:row-span-2",delayMs:600,labelledBy:"onb-agent-heading",children:c.jsx($Q,{projectName:e})}),c.jsx(Gu,{className:"md:col-span-2 md:row-span-2",delayMs:700,labelledBy:"onb-data-heading",children:c.jsx(KQ,{projectName:e})}),c.jsx(Gu,{className:"md:col-span-3",delayMs:800,labelledBy:"onb-schedule-heading",children:c.jsx(FQ,{projectName:e})}),c.jsx(Gu,{className:"md:col-span-3",delayMs:900,labelledBy:"onb-alerts-heading",children:c.jsx(ZQ,{projectName:e,score:r?.aggregateScore??null})})]}),c.jsxs("div",{className:"onb-reveal mt-12 flex flex-col items-center gap-3 sm:flex-row sm:justify-center",style:va(1e3),children:[c.jsx(me,{asChild:!0,className:"h-11 rounded-full px-6 text-base md:h-11",children:c.jsxs(Fe,{to:"/projects/$projectName",params:{projectName:e},replace:!0,onClick:()=>u("open_project"),children:["Open ",e,c.jsx(Zl,{className:"size-4","aria-hidden":"true"})]})}),c.jsx(me,{asChild:!0,variant:"ghost",className:"h-11 rounded-full px-5 md:h-11",children:c.jsx(Fe,{to:"/projects/$projectName/technical-aeo",params:{projectName:e},replace:!0,onClick:()=>u("review_page_health"),children:"Review page health"})})]})]})})}function mw(e,n){const i=Nt({...X3({client:ee,path:{name:e},query:{kind:n,limit:20}}),retry:!1,refetchInterval:r=>pw(r.state.status==="success"?{isSuccess:!0,data:r.state.data}:{isSuccess:!1})==="pending"?5e3:!1});return pw(i)}function MQ(e,n){return e===void 0?{}:n?{visibility:"skipped"}:{visibility:e}}function pw(e){if(!e.isSuccess||!e.data)return"unknown";const n=e.data.filter(i=>i.trigger!==ds.probe);if(!n.some(i=>i.status===Ht.completed||i.status===Ht.partial))return n.some(i=>i.status===Ht.queued||i.status===Ht.running)?"pending":n.length>0?"incomplete":"skipped"}function va(e){return{"--onb-delay":`${e}ms`}}function BQ(){return c.jsx("div",{className:"onb-check relative mx-auto size-20","aria-hidden":"true",children:c.jsxs("svg",{viewBox:"0 0 80 80",className:"relative size-20",children:[c.jsx("circle",{className:"onb-check-ring",cx:"40",cy:"40",r:"36",fill:"none",strokeWidth:"3",pathLength:"1"}),c.jsx("path",{className:"onb-check-mark",d:"M25 41 L35 51 L56 30",fill:"none",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round",pathLength:"1"})]})})}function Gu({className:e="",delayMs:n,labelledBy:i,children:r}){return c.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:va(n),children:r})}function im({id:e,eyebrow:n,title:i,children:r}){return c.jsxs("div",{children:[c.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted",children:n}),c.jsx("h2",{id:e,className:"mt-1.5 text-2xl font-semibold tracking-tight text-heading",children:i}),c.jsx("p",{className:"mt-2 text-sm text-secondary",children:r})]})}const Ku=[{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."}],LQ=9e3;function VQ(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function $Q({projectName:e}){const n=C.useContext(am),[i,r]=C.useState(0),[u,h]=C.useState(!1),[g,b]=C.useState(!1);C.useEffect(()=>{if(u||VQ())return;const S=window.setTimeout(()=>r(A=>(A+1)%Ku.length),LQ);return()=>window.clearTimeout(S)},[i,u]);const v=async()=>{try{await navigator.clipboard.writeText(Bh),n("copy_agent_command"),b(!0),window.setTimeout(()=>b(!1),1800)}catch{ln({tone:"negative",title:"Could not copy the command",detail:`Run ${Bh} in your terminal.`})}},w=Ku[i]??Ku[0];return c.jsxs(c.Fragment,{children:[c.jsxs(im,{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"," ",c.jsx("span",{className:"text-heading",children:e})," that reviews every sweep on its own."]}),c.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:[c.jsxs("div",{className:"flex items-center gap-1 border-b border-default px-3 py-2",role:"tablist","aria-label":"Example agent sessions",children:[Ku.map((S,A)=>c.jsx("button",{type:"button",role:"tab","aria-selected":A===i,onClick:()=>{r(A),h(!0)},className:`rounded-md px-2.5 py-1 text-xs font-medium transition-colors ${A===i?"bg-surface-inset text-heading":"text-muted hover:text-secondary"}`,children:S.label},S.id)),c.jsx("span",{className:"ml-auto text-xs text-faint",children:"Example"})]}),c.jsxs("div",{role:"tabpanel","aria-label":`${w.label} example`,className:"flex-1 p-4 font-mono text-[13px] leading-relaxed",children:[c.jsxs("p",{className:"onb-type text-heading",style:va(150),children:[c.jsx("span",{className:"text-muted",children:"> "}),w.prompt]}),w.calls.map((S,A)=>c.jsxs("p",{className:"onb-line mt-1 text-muted first:mt-3",style:va(1300+A*450),children:[c.jsx("span",{className:"text-positive",children:"●"})," ",S]},S)),c.jsx("p",{className:"onb-line mt-3 text-secondary",style:va(1500+w.calls.length*450),children:w.reply}),c.jsx("span",{className:"onb-caret mt-2 inline-block h-4 w-2 bg-current align-middle text-secondary",style:va(1900+w.calls.length*450),"aria-hidden":"true"})]},w.id)]}),c.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[c.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:Bh}),c.jsxs(me,{type:"button",variant:"secondary",size:"sm",className:"h-9 md:h-9",onClick:()=>{v()},children:[g?c.jsx(vd,{className:"size-4","aria-hidden":"true"}):c.jsx(Rf,{className:"size-4","aria-hidden":"true"}),g?"Copied":"Copy"]}),c.jsx("a",{href:qQ,target:"_blank",rel:"noreferrer",className:"text-sm font-medium text-link underline-offset-4 hover:underline",children:"Other clients"})]})]})}const UQ=[{icon:Tf,label:"Search Console",action:"connect_search_console",to:"/projects/$projectName/search-console"},{icon:Nw,label:"Google Analytics",action:"connect_analytics",to:"/projects/$projectName/activity"},{icon:Tw,label:"Business Profile",action:"connect_business_profile",to:"/projects/$projectName/local"}],GQ=["GPTBot","ClaudeBot","PerplexityBot"];function KQ({projectName:e}){const n=C.useContext(am);return c.jsxs(c.Fragment,{children:[c.jsx(im,{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."}),c.jsx(HQ,{}),c.jsxs(Fe,{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:[c.jsx(Rw,{className:"size-4 text-positive","aria-hidden":"true"}),c.jsxs("span",{className:"flex-1",children:["Connect your server",c.jsx("span",{className:"block text-xs font-normal text-secondary",children:"Cloudflare, Vercel, WordPress, or Cloud Run"})]}),c.jsx(Zl,{className:"size-4 text-link transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]}),c.jsx("p",{className:"mt-5 text-xs font-medium uppercase tracking-wide text-muted",children:"Also connect"}),c.jsx("ul",{className:"mt-1 divide-y divide-default",children:UQ.map(({icon:i,label:r,action:u,to:h})=>c.jsx("li",{children:c.jsxs(Fe,{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:[c.jsx(i,{className:"size-4 text-muted","aria-hidden":"true"}),c.jsx("span",{className:"flex-1",children:r}),c.jsx(Zl,{className:"size-3.5 text-link transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]})},r))})]})}function HQ(){const e=[22,70,118];return c.jsxs("div",{className:"relative my-6 h-36","aria-hidden":"true",children:[c.jsx("svg",{viewBox:"0 0 200 140",preserveAspectRatio:"none",className:"absolute inset-0 size-full",children:e.map((n,i)=>c.jsx("path",{className:"onb-flow",style:va(i*400),d:`M20 ${n} C 100 ${n}, 118 70, 170 70`,fill:"none",strokeWidth:"1.5"},n))}),GQ.map((n,i)=>c.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}%`,...va(i*600)},children:n},n)),c.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:c.jsx(Rw,{className:"size-5"})})]})}const QQ=["M","T","W","T","F","S","S"];function FQ({projectName:e}){return c.jsxs(c.Fragment,{children:[c.jsx(im,{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."}),c.jsx("ol",{className:"mt-6 grid grid-cols-7 gap-2","aria-hidden":"true",children:QQ.map((n,i)=>c.jsxs("li",{className:"flex flex-col items-center gap-2",children:[c.jsx("span",{className:"onb-day size-3 rounded-full bg-surface-inset",style:va(i*500)}),c.jsx("span",{className:"text-xs text-muted",children:n})]},i))}),c.jsx(Lj,{projectName:e,to:"/projects/$projectName/settings",icon:_w,label:"Set a schedule",action:"set_schedule"})]})}function ZQ({projectName:e,score:n}){return c.jsxs(c.Fragment,{children:[c.jsx(im,{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."}),c.jsxs("div",{className:"relative mt-6 flex h-14 items-center","aria-hidden":"true",children:[c.jsx("span",{className:"onb-bell flex size-10 items-center justify-center rounded-full border border-default bg-bg-elevated",children:c.jsx($h,{className:"size-4 text-secondary"})}),c.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:[c.jsx("span",{className:"size-2 rounded-full bg-positive-400"}),c.jsx("span",{className:"text-heading",children:e}),c.jsx("span",{className:"text-secondary",children:n===null?"sweep finished":`page health ${n}`})]})]}),c.jsx(Lj,{projectName:e,to:"/projects/$projectName/settings",icon:$h,label:"Add a notification",action:"add_notification"})]})}function Lj({projectName:e,to:n,icon:i,label:r,action:u}){const h=C.useContext(am);return c.jsxs(Fe,{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:[c.jsx(i,{className:"size-4","aria-hidden":"true"}),r,c.jsx(Zl,{className:"size-3.5 transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]})}const YQ=C.lazy(async()=>({default:(await Ni(()=>import("./SiteHealthSection-2ljW02xK.js").then(n=>n.d),__vite__mapDeps([0,1,2,3,4]),import.meta.url)).SiteHealthSection})),XQ=`Public pages only, crawled from this computer and stored locally. The first scan reads up to ${wS} pages, then stops.`,JQ=1800,WQ="https://github.com/Canonry/canonry#or-use-any-shell-capable-coding-agent",eF="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 tF(e,n){return e==="legacy"?"legacy":e==="platform"?"platform":n.state==="success"?n.projectCount===0?"platform":"legacy":n.state==="error"?"retry":"loading"}const nF="2000-01-01T00:00:00.000Z",aF=5e3;function iF(e,n){const i=new Set,r=new Map;for(const g of n)g.trigger!==ds.probe&&(r.has(g.projectId)||r.set(g.projectId,g.id),(g.status===Ht.completed||g.status===Ht.partial)&&i.add(g.projectId));const h=(e.every(g=>g.createdAt)?[...e].sort((g,b)=>(g.createdAt??"").localeCompare(b.createdAt??"")||g.name.localeCompare(b.name)):e).find(g=>!i.has(g.id));return h?{projectName:h.name,runId:r.get(h.id)}:null}const Vj=[{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"}],$j=[{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 sF(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 oF(e,n){const i=e.trim().toUpperCase(),r=n.trim().toLowerCase();return{countryValid:Vj.some(u=>u.value===i),languageValid:$j.some(u=>u.value===r)}}function rF(e){const n=e.replace(/^\[|\]$/g,"");return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(n)||n.includes(":")}function lF(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"||rF(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 cF(e,n=JQ){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 uF(e,n){e.catch(()=>{ln({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 Uj(e){const n=C.useRef(lg()).current,i=C.useRef(new Set),r=C.useCallback((u,h)=>{if(h){if(i.current.has(h))return;i.current.add(h)}Z0({...u,surface:e,eventId:cg()})},[e]);return{onboardingSessionId:n,emit:r}}function hw(e,n){return e instanceof Cn&&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 Af(){return c.jsxs("div",{className:"page-container max-w-3xl","aria-busy":"true","aria-live":"polite",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Preparing setup"}),c.jsx("p",{className:"page-subtitle",children:"Checking the projects already on this install."})]})}),c.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-default bg-surface p-4 text-sm text-secondary",role:"status",children:[c.jsx(pr,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading projects…"]})]})}function dF({onRetry:e}){return c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Can’t load projects"}),c.jsx("p",{className:"page-subtitle",children:"Canonry could not confirm whether this install already has a project."})]})}),c.jsxs("div",{className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",tabIndex:-1,children:[c.jsx("p",{className:"text-sm font-medium text-heading",children:"Setup is paused to protect existing projects."}),c.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Check the connection or sign in again, then retry."}),c.jsx(me,{type:"button",className:"mt-4",variant:"secondary",onClick:e,children:"Retry project check"})]})]})}function mF({projectName:e,initialRunId:n}){return c.jsx(mg,{title:"Site Health setup",children:c.jsx(pF,{projectName:e,initialRunId:n})})}function pF({projectName:e,initialRunId:n}){const i=fs(),r=Nt({...po({client:ee}),enabled:!!e,retry:!1,refetchOnMount:"always"}),{onboardingSessionId:u,emit:h}=Uj("site_health"),[g]=C.useState(()=>fQ(n));C.useEffect(()=>{g&&gQ()},[g]),C.useEffect(()=>{e&&h({flowVersion:lt,onboardingSessionId:u,event:"onboarding.started",step:"run",resumed:!!n&&!g},"onboarding.started")},[h,g,n,u,e]),C.useEffect(()=>{!e||!n||Pj(e)?.runId!==n&&Ij(e,n)},[n,e]);const v=Nt({...W0({client:ee,path:{id:n??""}}),enabled:!!n,refetchInterval:({state:_})=>{const U=_.data?.status;return U==="completed"||U==="partial"||U==="failed"||U==="cancelled"?!1:2e3},refetchIntervalInBackground:!0}).data?.status;if(C.useEffect(()=>{if(!e||!n||!v)return;if(v==="completed"||v==="partial"){h({flowVersion:lt,onboardingSessionId:u,event:"onboarding.step_completed",step:"run",method:"automatic"},"onboarding.step_completed:run"),gd(n);return}if(v!=="failed"&&v!=="cancelled")return;const _=v==="cancelled"?"run_cancelled":"run_failed";h({flowVersion:lt,onboardingSessionId:u,event:"onboarding.blocked",step:"run",action:"retry_run",reasonCode:_},`onboarding.blocked:run:${_}`),gd(n)},[h,n,u,e,v]),!e)return c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Project not found"}),c.jsx("p",{className:"page-subtitle",children:"This setup link does not identify a project."})]})}),c.jsx(me,{type:"button",variant:"secondary",onClick:()=>{i({to:"/projects"})},children:"View projects"})]});if(r.isPending)return c.jsxs("div",{className:"page-container max-w-3xl","aria-busy":"true","aria-live":"polite",children:[c.jsx(lo,{current:"site"}),c.jsxs("div",{className:"mt-8 flex items-center gap-3 text-sm text-secondary",role:"status",children:[c.jsx(pr,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading Site Health setup…"]})]});if(r.isError)return c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Can’t resume setup"}),c.jsx("p",{className:"page-subtitle",children:"Canonry could not load the project for this Site Health scan."})]})}),c.jsxs("div",{className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",children:[c.jsx("p",{className:"text-sm text-secondary",children:"Check the connection or sign in again, then retry."}),c.jsx(me,{type:"button",className:"mt-4",variant:"secondary",onClick:()=>{r.refetch()},children:"Retry project check"})]})]});const w=r.data.find(_=>_.name===e);if(!w)return c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Project not found"}),c.jsxs("p",{className:"page-subtitle",children:["Canonry could not find ",e,". It will not open a different project."]})]})}),c.jsx(me,{type:"button",variant:"secondary",onClick:()=>{i({to:"/projects"})},children:"View projects"})]});const S=()=>{i({to:"/setup",search:{onboarding:"site-health",setupProject:w.name},replace:!0})},A=()=>{i({to:"/setup",search:{experience:"legacy",onboarding:"site-health",setupProject:w.name},replace:!0})},R=()=>{h({flowVersion:lt,onboardingSessionId:u,event:"onboarding.step_completed",step:"run",method:"skipped"},"onboarding.step_completed:run"),i({to:"/setup",search:{onboarding:"complete",setupProject:w.name,skipped:"visibility"},replace:!0})};return c.jsxs("div",{className:"page-container max-w-7xl py-8 md:py-10",children:[c.jsx("h1",{className:"sr-only",children:"Set up Canonry"}),c.jsx(C.Suspense,{fallback:c.jsxs("div",{className:"space-y-5",children:[c.jsx(lo,{current:"site"}),c.jsxs("div",{className:"flex min-h-72 items-center justify-center gap-3 text-sm text-secondary",role:"status",children:[c.jsx(pr,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading Site Health…"]})]}),children:c.jsx(YQ,{projectName:w.name,projectId:w.id,initialRunId:n,onReleaseInitialRun:S,showOnboardingActions:!0,onContinueOnboarding:A,onSkipOnboarding:R})})]})}function hF(){const e=gw({from:"/setup"}),n=e.onboarding==="site-health"&&!e.setupProject,i=e.onboarding==="site-health"&&e.experience!=="legacy",r=iV(),u=e.experience==="legacy"?"legacy":e.experience==="platform"?"platform":r,[h,g]=C.useState(!1),[b,v]=C.useState(void 0),w=Nt({...po({client:ee}),enabled:u==="auto",retry:!1,refetchOnMount:"always"}),S=Nt({...Yd({client:ee,query:{kind:Ee["site-audit"],since:nF,limit:aF}}),enabled:u==="auto",retry:!1,refetchOnMount:"always"}),A=u==="auto"&&w.isSuccess&&w.isFetchedAfterMount&&w.data.length===0;C.useEffect(()=>{A&&g(!0)},[A]);const R=u!=="auto"?{state:"idle"}:w.isSuccess&&w.isFetchedAfterMount?{state:"success",projectCount:w.data.length}:w.isError?{state:"error"}:{state:"loading"},_=u==="legacy"?"legacy":h||A?"platform":tF(u,R);if(e.onboarding==="complete"&&e.setupProject)return c.jsx(PQ,{projectName:e.setupProject,skippedVisibility:e.skipped==="visibility"});if(n||i)return c.jsx(mF,{projectName:e.setupProject,initialRunId:e.siteHealthRunId});const U=u==="auto"&&_==="legacy"&&!e.setupProject&&w.isSuccess;if(U&&b===void 0)return S.isError?v(null):S.isSuccess&&S.isFetchedAfterMount&&v(iF(w.data,S.data)),c.jsx(Af,{});const T=U?b:null;return T?c.jsx(fF,{projectName:T.projectName,runId:T.runId}):_==="legacy"?c.jsx(DQ,{visibilityProjectName:e.setupProject,siteHealthOnboarding:e.onboarding==="site-health",onboardingFinish:e.onboarding==="site-health"||e.onboarding==="first-run"}):_==="loading"?c.jsx(Af,{}):_==="retry"?c.jsx(dF,{onRetry:()=>{w.refetch()}}):c.jsx(gF,{onActivationStarted:()=>g(!0),skipSiteScan:e.siteScan==="skip"})}function fF({projectName:e,runId:n}){const i=fs();return C.useEffect(()=>{i({to:"/setup",search:{onboarding:"site-health",setupProject:e,...n?{siteHealthRunId:n}:{}},replace:!0})},[i,e,n]),c.jsx(Af,{})}function gF({onActivationStarted:e,skipSiteScan:n}){return c.jsx(mg,{title:"Site Health setup",children:c.jsx(yF,{onActivationStarted:e,skipSiteScan:n})})}function yF({onActivationStarted:e,skipSiteScan:n}){const i=fs(),r=ka(),u=SQ(),h=Nt({...F$({client:ee}),retry:!1}),g=gs(Z$()),[b,v]=C.useState(""),[w,S]=C.useState(""),[A,R]=C.useState(""),[_,U]=C.useState("US"),[T,P]=C.useState("en"),[F,ae]=C.useState(!1),[L,te]=C.useState("idle"),[J,se]=C.useState(null),[H,G]=C.useState(null),[ke,Ke]=C.useState(!1),[He,Ne]=C.useState(null),[et,ze]=C.useState(!1),Le=h.isError?void 0:h.data,q=typeof Le?.enabled=="boolean"?Le.enabled:null,Y=g.isPending?g.variables.body.enabled:q,[fe,be]=C.useState(null),ne=C.useRef(null),{onboardingSessionId:De,emit:Oe}=Uj("platform");C.useEffect(()=>{Oe({flowVersion:lt,onboardingSessionId:De,event:"onboarding.started",step:"project",resumed:!1},"onboarding.started")},[Oe,De]);const ve=lF(b),oe=w||ve?.projectName||"",ue=A||ve?.displayName||"",K=L==="creating"||L==="dispatching",ce=H??He,Ue=sF(_,T),{countryValid:xe,languageValid:Xe}=oF(_,T),Ve=xe&&Xe;C.useEffect(()=>{ce&&ne.current?.focus()},[ce]);const ut=(Re,Je)=>i({to:"/setup",search:{...Je?{siteHealthRunId:Je}:{},onboarding:"site-health",setupProject:Re.name},replace:!0}),Be=async Re=>{te("dispatching"),Ne(null);try{const Je=u.mutateAsync({projectName:Re.name,projectId:Re.id,projectLabel:Re.displayName||Re.name,suppressErrorToast:!0,body:{checkDeadLinks:!0,maxPages:wS}}),Qt=await cF(Je);if(Qt.state==="queued"){Oe({flowVersion:lt,onboardingSessionId:De,event:"run.requested",origin:"dashboard_setup",result:"queued",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0"}),hQ(Qt.run.runId),await ut(Re,Qt.run.runId);return}Je.then(()=>{Oe({flowVersion:lt,onboardingSessionId:De,event:"run.requested",origin:"dashboard_setup",result:"queued",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0"})},bn=>{Oe({flowVersion:lt,onboardingSessionId:De,event:"run.requested",origin:"dashboard_setup",result:"rejected",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0",reasonCode:Fl(bn,"run_rejected")})}),uF(Je,Re.id),await ut(Re)}catch(Je){te("recovery"),Ne(hw(Je,"The project was created, but the Site Health scan could not be started."));const Qt=Fl(Je,"run_rejected");Oe({flowVersion:lt,onboardingSessionId:De,event:"run.requested",origin:"dashboard_setup",result:"rejected",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0",reasonCode:Qt}),Oe({flowVersion:lt,onboardingSessionId:De,event:"onboarding.blocked",step:"run",action:"retry_run",reasonCode:Qt},`onboarding.blocked:run:${Qt}`)}},re=async Re=>{if(Re.preventDefault(),!(!ve||!n&&!F||!Ve||K)){te("creating"),G(null),Ke(!1),Ne(null);try{const Je=await jV({name:oe,displayName:ue,canonicalDomain:ve.canonicalDomain,country:_,language:T});if(e(),se(Je),Oe({flowVersion:lt,onboardingSessionId:De,event:"onboarding.step_completed",step:"project",method:"manual"},"onboarding.step_completed:project"),await r.invalidateQueries({queryKey:hs({client:ee})}),n){await i({to:"/setup",search:{experience:"legacy",onboarding:"first-run",setupProject:Je.name},replace:!0});return}await Be(Je)}catch(Je){te("idle");const Qt=Je instanceof Cn&&Je.statusCode===409;Ke(Qt),G(hw(Je,"Could not create the project. Try again.")),Oe({flowVersion:lt,onboardingSessionId:De,event:"onboarding.blocked",step:"project",action:"save",reasonCode:Fl(Je,"project_create_failed")},"onboarding.blocked:project"),Qt&&(e(),r.invalidateQueries({queryKey:hs({client:ee})}))}}},ct=()=>{J&&!K&&Be(J)},Vt=()=>{K||i({to:"/projects"})},qn=async()=>{try{await navigator.clipboard.writeText(eF),ze(!0)}catch{ln({tone:"negative",title:"Could not copy setup request",detail:"Open the agent quickstart to continue with the CLI instead."})}},_t=async Re=>{be(null);try{const Je=await g.mutateAsync({client:ee,body:{enabled:Re}});r.setQueryData(J3({client:ee}),Je),Je.enabled!==Re&&be(`The server kept telemetry ${Je.enabled?"on":"off"}. Check its telemetry settings.`)}catch{be("Could not update telemetry. Try again.")}};return J&&L==="recovery"?c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx(lo,{current:"site"}),c.jsx("div",{className:"page-header mt-8",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Project created"}),c.jsxs("p",{className:"page-subtitle",children:[J.displayName||J.name," is ready. The Site Health scan needs another try."]})]})}),c.jsxs("div",{ref:ne,className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",tabIndex:-1,children:[c.jsx("p",{className:"text-sm font-medium text-heading",children:He}),c.jsx("p",{className:"mt-1 text-sm text-secondary",children:"You can retry the scan or continue setup and retry from Site Health."}),c.jsxs("div",{className:"mt-4 flex flex-wrap gap-3",children:[c.jsx(me,{type:"button",onClick:ct,children:"Retry Site Health scan"}),c.jsx(me,{type:"button",variant:"secondary",onClick:()=>{ut(J)},children:"Continue setup"})]})]})]}):c.jsxs("div",{className:"page-container max-w-xl py-8 md:py-12",children:[n?null:c.jsx(lo,{current:"site"}),c.jsxs("header",{className:`mb-8 ${n?"":"mt-8"}`,children:[c.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"}),c.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."})]}),c.jsxs("form",{"aria-labelledby":"site-map-setup-title",className:"space-y-6",onSubmit:an(re),noValidate:!0,children:[c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm font-medium text-heading",htmlFor:"launchpad-domain",children:"Website URL"}),c.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&&!ve),"aria-describedby":b&&!ve?"launchpad-domain-hint launchpad-domain-error":"launchpad-domain-hint",placeholder:"https://example.com",value:b,onChange:Re=>{v(Re.target.value),G(null),Ke(!1)}}),c.jsx("p",{id:"launchpad-domain-hint",className:"text-sm text-secondary",children:n?c.jsxs(c.Fragment,{children:["A public domain is still required."," ",c.jsx(Fe,{to:"/setup",search:{experience:"platform"},className:"font-medium text-link underline-offset-4 hover:underline",children:"Map with Site Health instead"})]}):c.jsxs(c.Fragment,{children:["Only public pages are scanned."," ",c.jsx(Fe,{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&&!ve?c.jsx("p",{id:"launchpad-domain-error",className:"text-sm text-negative",role:"alert",children:"Enter a public domain, such as example.com."}):null]}),c.jsxs("details",{className:"group border-y border-default",children:[c.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:[c.jsx("span",{className:"font-medium text-heading",children:"Project name and locale"}),c.jsxs("span",{className:"flex items-center gap-2 text-secondary",children:[Ue,c.jsx(bd,{className:"size-4 transition-transform group-open:rotate-180 motion-reduce:transition-none","aria-hidden":"true"})]})]}),c.jsxs("div",{className:"space-y-5 border-t border-default py-4",children:[ve?c.jsxs("div",{children:[c.jsx("p",{className:"mb-3 text-sm font-medium text-heading",children:"Project"}),c.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-project-name",children:"Project name"}),c.jsx("input",{id:"launchpad-project-name",className:"setup-input h-10",type:"text",value:oe,onChange:Re=>S(Re.target.value)})]}),c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-display-name",children:"Display name"}),c.jsx("input",{id:"launchpad-display-name",className:"setup-input h-10",type:"text",value:ue,onChange:Re=>R(Re.target.value)})]})]})]}):null,c.jsxs("div",{children:[c.jsx("p",{className:"mb-3 text-sm font-medium text-heading",children:"Locale"}),c.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-country",children:"Country"}),c.jsx("select",{id:"launchpad-country",className:"setup-input h-10",value:_,onChange:Re=>U(Re.target.value),children:Vj.map(Re=>c.jsx("option",{value:Re.value,children:Re.label},Re.value))})]}),c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-language",children:"Language"}),c.jsx("select",{id:"launchpad-language",className:"setup-input h-10",value:T,onChange:Re=>P(Re.target.value),children:$j.map(Re=>c.jsx("option",{value:Re.value,children:Re.label},Re.value))})]})]})]})]})]}),n?null:c.jsxs("label",{className:"flex min-h-11 cursor-pointer items-start gap-3 py-2",children:[c.jsx("input",{className:"mt-0.5 size-4 shrink-0 rounded border-strong bg-bg",type:"checkbox",checked:F,onChange:Re=>ae(Re.target.checked),"aria-label":"Allow Canonry to scan this public site."}),c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"text-sm leading-5 text-heading",children:"Allow Canonry to scan this public site."}),c.jsx(Ws,{text:XQ})]})]}),ce?c.jsxs("div",{ref:ne,className:"rounded-md border border-negative bg-negative-soft p-3",role:"alert",tabIndex:-1,children:[c.jsx("p",{className:"text-sm font-medium text-heading",children:ce}),ke?c.jsx(me,{type:"button",variant:"secondary",size:"sm",className:"mt-3",onClick:Vt,children:"View projects"}):null]}):null,c.jsxs("div",{className:"grid gap-2",children:[c.jsx(me,{className:"h-11 w-full",type:"submit",disabled:!ve||!n&&!F||!Ve||K,children:L==="creating"||L==="dispatching"?c.jsxs(c.Fragment,{children:[c.jsx(pr,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"})," ",n?"Creating project…":"Mapping site…"]}):n?"Create project":"Scan site"}),L==="dispatching"?c.jsx("span",{className:"text-center text-sm text-secondary",role:"status",children:"Opening Site Health when the scan is ready."}):null]})]}),c.jsxs("section",{className:"mt-8 border-t border-default pt-6","aria-labelledby":"agent-setup-title",children:[c.jsx("p",{id:"agent-setup-title",className:"text-sm font-medium text-heading",children:"Use your agent instead"}),c.jsx("p",{className:"mt-1 text-sm leading-5 text-secondary",children:"Copy a complete CLI setup request into any agent."}),c.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-1",children:[c.jsxs(me,{type:"button",variant:"ghost",size:"sm",className:"-ml-3",onClick:an(qn),children:[et?c.jsx(vd,{className:"size-3.5","aria-hidden":"true"}):c.jsx(Rf,{className:"size-3.5","aria-hidden":"true"}),c.jsx("span",{"aria-live":"polite",children:et?"Copied setup request":"Copy setup request"})]}),c.jsx(me,{asChild:!0,variant:"ghost",size:"sm",children:c.jsxs("a",{href:WQ,target:"_blank",rel:"noopener noreferrer",children:["Agent quickstart",c.jsx(jC,{className:"size-3.5","aria-hidden":"true"}),c.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]})})]})]}),q!==null?c.jsxs("section",{className:"mt-6 border-t border-default pt-5","aria-labelledby":"telemetry-title",children:[c.jsxs("label",{className:`flex min-h-11 items-start gap-3 py-2 ${g.isPending?"cursor-wait":"cursor-pointer"}`,children:[c.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:Y??!1,disabled:g.isPending,onChange:Re=>{_t(Re.target.checked)},"aria-describedby":"telemetry-detail"}),c.jsxs("span",{className:"grid gap-0.5",children:[c.jsx("span",{id:"telemetry-title",className:"text-sm leading-5 text-heading",children:"Share anonymous product telemetry"}),c.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."})]})]}),g.isPending?c.jsx("p",{className:"mt-1 text-sm text-secondary",role:"status",children:"Saving preference…"}):null,fe?c.jsx("p",{className:"mt-1 text-sm text-negative",role:"alert",children:fe}):null]}):null]})}function bF(){return c.jsx("div",{className:"page-container",children:c.jsx("section",{className:"page-section",children:c.jsxs(ba,{className:"surface-card empty-card",children:[c.jsx("h1",{children:"Route not found"}),c.jsx("p",{children:"The current path does not map to a dashboard view."}),c.jsx(me,{asChild:!0,children:c.jsx(Fe,{to:"/",children:"Return to overview"})})]})})})}const aa=ys(()=>Ni(()=>import("./ProjectPage-jL3jB2TR.js"),__vite__mapDeps([5,1,2,6,0,3,4,7,8,9,10,11,12]),import.meta.url),"ProjectPage"),vF=ys(()=>Ni(()=>import("./RunsPage-DQWPHDoq.js"),__vite__mapDeps([13,1,6,11,4,2,9,12]),import.meta.url),"RunsPage"),xF=ys(()=>Ni(()=>import("./HistoryPage-CO-dzLAo.js"),__vite__mapDeps([14,1,10,11,4,2,9,12]),import.meta.url),"HistoryPage"),wF=ys(()=>Ni(()=>import("./SettingsPage-DMtQLrWP.js"),__vite__mapDeps([15,1,11,4,2,9,12]),import.meta.url),"SettingsPage"),kF=ys(()=>Ni(()=>import("./BacklinksPage-DYe2CYfD.js"),__vite__mapDeps([16,1,2,11,4,9,12]),import.meta.url),"BacklinksPage"),SF=ys(()=>Ni(()=>import("./TrafficPage-NFu0LEdk.js"),__vite__mapDeps([17,1,7,2,11,4,9,12]),import.meta.url),"TrafficPage"),jF=ys(()=>Ni(()=>import("./TrafficSourceDetailPage-DbBIzmbL.js"),__vite__mapDeps([18,1,7,3,4,2,11,9,12]),import.meta.url),"TrafficSourceDetailPage"),AF=ys(()=>Ni(()=>import("./MeasurementPropertyPage-smsZFdd6.js"),__vite__mapDeps([19,1,3,4,8,9,2,11,12]),import.meta.url),"MeasurementPropertyPage");function CF(){return c.jsx(JH,{children:c.jsx(r$,{children:c.jsx(XH,{})})})}const Dn=W4()({component:CF,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]))})}),NF=Et({getParentRoute:()=>Dn,path:"/",component:aQ,beforeLoad:async({context:e})=>{let n=e.queryClient.getQueryData(hs({client:ee}));if(n===void 0)try{n=await e.queryClient.ensureQueryData(po({client:ee}))}catch{return}if(n.length===0)throw bw({to:"/setup"})}}),_F=Et({getParentRoute:()=>Dn,path:"/projects",component:rQ}),TF=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,On=Et({getParentRoute:()=>Dn,path:"/projects/$projectName",component:()=>c.jsx(Lh,{}),beforeLoad:async({context:e,params:n,location:i})=>{const r=n.projectName;if(!TF.test(r))return;let u=e.queryClient.getQueryData(hs({client:ee}));if(!u)try{u=await e.queryClient.ensureQueryData(po({client:ee}))}catch{return}const h=u.find(g=>g.id===r);if(h)throw bw({to:i.pathname.replace(`/projects/${r}`,`/projects/${encodeURIComponent(h.name)}`),replace:!0})}}),RF=Et({getParentRoute:()=>On,path:"/",component:()=>c.jsx(aa,{tab:"overview"})}),EF=Et({getParentRoute:()=>On,path:"/portfolio",component:()=>c.jsx(aa,{tab:"portfolio"})}),zF=Et({getParentRoute:()=>On,path:"/search-console",component:()=>c.jsx(aa,{tab:"search-console"})}),DF=Et({getParentRoute:()=>On,path:"/conversions",component:()=>c.jsx(aa,{tab:"conversions"})}),OF=Et({getParentRoute:()=>On,path:"/local",component:()=>c.jsx(aa,{tab:"local"})}),qF=Et({getParentRoute:()=>On,path:"/discovery",component:()=>c.jsx(aa,{tab:"discovery"})}),IF=Et({getParentRoute:()=>On,path:"/queries",component:()=>c.jsx(aa,{tab:"queries"})}),PF=Et({getParentRoute:()=>On,path:"/properties/$targetKey",component:()=>c.jsx(AF,{})}),MF=Et({getParentRoute:()=>On,path:"/report",component:()=>c.jsx(aa,{tab:"report"})}),BF=Et({getParentRoute:()=>On,path:"/activity",component:()=>c.jsx(aa,{tab:"activity"})}),LF=Et({getParentRoute:()=>On,path:"/backlinks",component:()=>c.jsx(aa,{tab:"backlinks"})}),VF=Et({getParentRoute:()=>On,path:"/technical-aeo",component:()=>c.jsx(aa,{tab:"technical-aeo"})}),$F=Et({getParentRoute:()=>On,path:"/history",component:()=>c.jsx(aa,{tab:"history"})}),UF=Et({getParentRoute:()=>On,path:"/settings",component:()=>c.jsx(aa,{tab:"settings"})}),GF=Et({getParentRoute:()=>Dn,path:"/runs",component:vF}),KF=Et({getParentRoute:()=>Dn,path:"/history",component:xF}),HF=Et({getParentRoute:()=>Dn,path:"/settings",component:wF,beforeLoad:({context:e})=>{}}),QF=Et({getParentRoute:()=>Dn,path:"/setup",component:hF}),FF=Et({getParentRoute:()=>Dn,path:"/backlinks",component:kF}),ZF=Et({getParentRoute:()=>Dn,path:"/traffic",component:SF}),YF=Et({getParentRoute:()=>Dn,path:"/traffic/$projectName/$sourceId",component:jF}),XF=Et({getParentRoute:()=>Dn,path:"*",component:bF}),JF=Dn.addChildren([NF,_F,On.addChildren([RF,EF,zF,DF,OF,qF,IF,PF,MF,BF,LF,VF,$F,UF]),GF,KF,HF,QF,FF,ZF,YF,XF]);function WF(){return typeof window<"u"&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath:"/"}const fw=WF(),eZ=fw==="/"?"":fw.replace(/\/$/,"");function tZ(e,n){return eC({routeTree:JF,basepath:eZ||"/",context:{queryClient:e},...n?.initialEntries})}const nZ=6e4;function aZ(){const e=C.useRef(wV()).current,[n,i]=C.useState(e?"ready":"checking"),[r,u]=C.useState(null),[h,g]=C.useState(null),[b,v]=C.useState(e),[w,S]=C.useState(!1),[A,R]=C.useState(""),[_,U]=C.useState(""),[T,P]=C.useState(""),[F,ae]=C.useState(!1),[L,te]=C.useState("password"),[J,se]=C.useState(null),[H,G]=C.useState(!1),[ke,Ke]=C.useState(!1),He=C.useRef(null),Ne=C.useRef(null),et=C.useRef(null),ze=()=>{const K=r?`${r.name}:${r.role}`:e?"api-key:explicit":h?`api-key:${h.id}`:"no-accounts";if(!He.current||et.current!==K){Ne.current?.clear();const ce=i$();Ne.current=ce,He.current=tZ(ce),et.current=K}return{queryClient:Ne.current,router:He.current}},Le=K=>K.authRequired?(S(!0),u(K.user),g(null),v(!1),i(K.user?"ready":"account-login"),!0):!1;C.useEffect(()=>{let K=!1;const ce=async(Ue,xe=!1)=>{try{const Xe=await zh();if(K)return;g(Xe),v(!1),i("ready")}catch(Xe){if(K)return;if(xe&&Xe instanceof Cn&&Xe.statusCode===401)return DV().then(()=>{K||(se(null),g(null),v(!1),Ke(!0),i("login"))}).catch(Ve=>{K||(se(Ve instanceof Error?Ve.message:"Could not clear the invalid session"),i(Ue))});se(Xe instanceof Error?Xe.message:"Could not verify API key access"),i(Ue)}};return e?(ce("api-key-error"),()=>{K=!0}):(Promise.allSettled([Nx(),Cx()]).then(([Ue,xe])=>{if(K||Ue.status==="fulfilled"&&Le(Ue.value))return;if(xe.status==="rejected"){const Ve=xe.reason;se(Ve instanceof Error?Ve.message:"Failed to reach the Canonry API"),i("login");return}const Xe=xe.value;Xe.authenticated?(v(!0),ce("api-key-error",!0)):(g(null),v(!1),i(Xe.setupRequired?"setup":"login"))}),()=>{K=!0})},[]),C.useEffect(()=>{if(n!=="ready"||e)return;const K=setInterval(()=>{if(w){Nx().then(ce=>{ce.authRequired&&!ce.user&&(Ke(!0),u(null),g(null),i("account-login"))}).catch(()=>{});return}Cx().then(ce=>{ce.authenticated||(Ke(!0),g(null),i(ce.setupRequired?"setup":"login"))}).catch(()=>{})},nZ);return Ax(()=>{Ke(!0),u(null),g(null),v(!1),i(w?"account-login":"login")}),()=>{clearInterval(K),Ax(null)}},[n,w,e]);const q=async K=>{if(K.preventDefault(),!_.trim()||_.trim().length<8){se("Password must be at least 8 characters");return}if(_!==T){se("Passwords do not match");return}G(!0),se(null);try{if(!(await RV(_.trim())).authenticated){se("Setup failed");return}U(""),P(""),ae(!1),Ke(!1),g(null),v(!0),i("checking");try{const Ue=await zh();g(Ue),v(!1),i("ready")}catch(Ue){se(Ue instanceof Error?Ue.message:"Could not verify API key access"),i("api-key-error")}}catch(ce){se(ce instanceof Cn||ce instanceof Error?ce.message:"Setup failed")}finally{G(!1)}},Y=K=>{U(K),se(null)},fe=K=>{P(K),se(null)},be=async K=>{if(K.preventDefault(),!!_.trim()){G(!0),se(null);try{if(!(L==="api-key"?await zV(_.trim()):await EV(_.trim())).authenticated){se(L==="api-key"?"Invalid API key":"Incorrect password");return}const Ue=await zh();g(Ue),v(!1),U(""),ae(!1),Ke(!1),i("ready")}catch(ce){se(ce instanceof Cn||ce instanceof Error?ce.message:"Authentication failed")}finally{G(!1)}}},ne=K=>{te(K),U(""),ae(!1),se(null)},De=async K=>{if(K.preventDefault(),!(!A.trim()||!_)){G(!0),se(null);try{const ce=await OV(A.trim(),_);if(!ce.user){se("Incorrect name or password.");return}U(""),Ke(!1),u(ce.user),g(null),v(!1),i("ready")}catch(ce){se(ce instanceof Cn?ce.message:"Incorrect name or password.")}finally{G(!1)}}};if(n==="ready"){const{queryClient:K,router:ce}=ze();return c.jsx(FV,{account:r,apiKey:h,apiKeyPending:b,children:c.jsx(tC,{client:K,children:c.jsx(nC,{router:ce})})})}const Oe=_.trim(),ve=_.length>0&&Oe.length<8,oe=T.length>0&&_!==T,ue=Oe.length>=8&&_===T;return c.jsx("div",{className:"min-h-screen bg-bg px-4 py-8",children:c.jsxs("div",{className:"mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col items-center justify-center gap-5",children:[c.jsxs("div",{"data-testid":"auth-brand",className:"flex items-center gap-2.5",children:[c.jsx("img",{className:"size-7",src:"./favicon.svg",alt:"","aria-hidden":"true"}),c.jsx("span",{className:"text-lg font-semibold tracking-tight text-heading",children:"Canonry"})]}),c.jsx(ba,{className:"surface-card w-full",children:n==="checking"?c.jsx(eo,{className:"py-8",children:c.jsx("p",{className:"supporting-copy text-center",children:"Connecting to Canonry…"})}):n==="api-key-error"?c.jsxs(c.Fragment,{children:[c.jsxs(ur,{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),c.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Could not verify API key access"})]}),c.jsxs(eo,{className:"space-y-4",children:[c.jsx("p",{className:"supporting-copy",children:J??"Canonry could not verify this session’s access, so the dashboard stayed locked."}),c.jsx(me,{type:"button",className:"w-full",onClick:()=>{window.location.reload()},children:"Try again"})]})]}):n==="account-login"?c.jsxs(c.Fragment,{children:[c.jsxs(ur,{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),c.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Sign in to Canonry"})]}),c.jsxs(eo,{children:[ke?c.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,c.jsxs("form",{className:"space-y-4",onSubmit:an(De),children:[c.jsxs("label",{className:"block space-y-1.5",htmlFor:"account-name",children:[c.jsx("span",{className:"text-xs font-medium text-secondary",children:"Name"}),c.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:A,onChange:K=>{R(K.target.value),se(null)},"aria-invalid":!!J,"aria-describedby":J?"account-login-error":void 0})]}),c.jsxs("label",{className:"block space-y-1.5",htmlFor:"account-password",children:[c.jsx("span",{className:"text-xs font-medium text-secondary",children:"Password"}),c.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:_,onChange:K=>Y(K.target.value),"aria-invalid":!!J,"aria-describedby":J?"account-login-error":void 0})]}),J?c.jsx("p",{id:"account-login-error",role:"alert",className:"text-sm text-negative-400",children:J}):null,c.jsx(me,{type:"submit",disabled:H||!A.trim()||!_,children:H?"Signing in…":"Sign in"})]})]})]}):n==="setup"?c.jsxs(c.Fragment,{children:[c.jsxs(ur,{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"First-time setup"}),c.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Create a dashboard password"}),c.jsx(hd,{children:"This password protects the dashboard on this computer."})]}),c.jsx(eo,{children:c.jsxs("form",{className:"space-y-4",onSubmit:an(q),children:[c.jsxs("div",{className:"space-y-1.5",children:[c.jsx("label",{className:"block text-xs font-medium text-secondary",htmlFor:"dashboard-password-new",children:"Password"}),c.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:F?"text":"password",name:"new-password",autoComplete:"new-password",minLength:8,required:!0,value:_,onChange:K=>Y(K.target.value),"aria-invalid":ve,"aria-describedby":"dashboard-password-new-help"}),c.jsx("span",{id:"dashboard-password-new-help","aria-live":"polite",className:ve?"block text-sm text-negative-400":"block text-sm text-secondary",children:ve?"Enter at least 8 characters.":"Use at least 8 characters."})]}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsx("label",{className:"block text-xs font-medium text-secondary",htmlFor:"dashboard-password-confirm",children:"Confirm password"}),c.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:F?"text":"password",name:"confirm-password",autoComplete:"new-password",minLength:8,required:!0,value:T,onChange:K=>fe(K.target.value),"aria-invalid":oe,"aria-describedby":"dashboard-password-confirm-help"}),c.jsx("span",{id:"dashboard-password-confirm-help","aria-live":"polite",className:oe?"block text-sm text-negative-400":"block text-sm text-secondary",children:oe?"Passwords do not match.":"Enter the same password again."})]}),c.jsxs("label",{className:"flex min-h-10 cursor-pointer items-center gap-2 text-sm text-secondary",htmlFor:"dashboard-password-show",children:[c.jsx("input",{id:"dashboard-password-show",type:"checkbox",checked:F,onChange:K=>ae(K.target.checked)}),"Show passwords"]}),J?c.jsx("p",{id:"dashboard-password-setup-error",role:"alert",className:"text-sm text-negative-400",children:J}):null,c.jsx(me,{type:"submit",disabled:H||!ue,children:H?"Creating password…":"Create password and continue"})]})})]}):c.jsxs(c.Fragment,{children:[c.jsxs(ur,{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),c.jsx("h1",{className:"font-medium tracking-tight text-primary",children:"Sign in to Canonry"}),c.jsx(hd,{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."})]}),c.jsxs(eo,{children:[ke?c.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,c.jsxs("form",{className:"space-y-4",onSubmit:an(be),children:[c.jsxs("label",{className:"block space-y-1.5",htmlFor:"dashboard-password-current",children:[c.jsx("span",{className:"text-xs font-medium text-secondary",children:L==="api-key"?"Canonry API key":"Password"}),c.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:F?"text":"password",name:L==="api-key"?"apiKey":"password",autoComplete:L==="api-key"?"off":"current-password",spellCheck:!1,required:!0,value:_,onChange:K=>Y(K.target.value),"aria-invalid":!!J,"aria-describedby":J?"dashboard-password-login-error":void 0})]}),c.jsxs("label",{className:"flex min-h-10 cursor-pointer items-center gap-2 text-sm text-secondary",htmlFor:"dashboard-login-password-show",children:[c.jsx("input",{id:"dashboard-login-password-show",type:"checkbox",checked:F,onChange:K=>ae(K.target.checked)}),L==="api-key"?"Show API key":"Show password"]}),J?c.jsx("p",{id:"dashboard-password-login-error",role:"alert",className:"text-sm text-negative-400",children:J}):null,c.jsx(me,{type:"submit",disabled:H||!_.trim(),children:H?"Signing in…":"Open dashboard"}),c.jsx(me,{type:"button",variant:"ghost",onClick:()=>ne(L==="api-key"?"password":"api-key"),children:L==="api-key"?"Use dashboard password instead":"Forgot password? Use API key"})]})]})]})})]})})}const Gj=document.getElementById("root");if(!Gj)throw new Error("Expected #root element for web app bootstrap.");zC.createRoot(Gj).render(c.jsx(C.StrictMode,{children:c.jsx(aZ,{})}));export{JX as $,vf as A,me as B,cd as C,LJ as D,PZ as E,MJ as F,VJ as G,BX as H,Ws as I,IJ as J,MW as K,VW as L,Oee as M,LW as N,FX as O,mK as P,QX as Q,iJ as R,c$ as S,jn as T,ln as U,GW as V,KW as W,WX as X,HW as Y,eJ as Z,YX as _,Dee as a,dV as a$,$W as a0,UW as a1,BW as a2,ZX as a3,QW as a4,eee as a5,YW as a6,JW as a7,XW as a8,WW as a9,Js as aA,t$ as aB,WJ as aC,vH as aD,XX as aE,GZ as aF,IZ as aG,NX as aH,fD as aI,yn as aJ,qZ as aK,OZ as aL,$Z as aM,k$ as aN,G$ as aO,sW as aP,uW as aQ,oW as aR,SY as aS,AY as aT,DB as aU,CY as aV,D$ as aW,iW as aX,qB as aY,cf as aZ,jY as a_,kJ as aa,eg as ab,Ee as ac,ZW as ad,nj as ae,Ci as af,FW as ag,Hee as ah,jq as ai,Aq as aj,HZ as ak,KZ as al,AJ as am,EJ as an,zJ as ao,Cn as ap,DJ as aq,RX as ar,u$ as as,gG as at,mf as au,OJ as av,Yu as aw,pee as ax,$l as ay,wf as az,qI as b,cY as b$,rW as b0,aW as b1,q$ as b2,lW as b3,Lee as b4,cW as b5,bee as b6,vee as b7,tJ as b8,J0 as b9,RZ as bA,TZ as bB,_Z as bC,NZ as bD,jZ as bE,SZ as bF,CZ as bG,AZ as bH,kZ as bI,wZ as bJ,hZ as bK,fZ as bL,xZ as bM,vZ as bN,bZ as bO,gZ as bP,yZ as bQ,pZ as bR,mZ as bS,dZ as bT,uZ as bU,a5 as bV,uY as bW,oY as bX,rY as bY,lY as bZ,dY as b_,mee as ba,X3 as bb,fW as bc,yW as bd,AW as be,qW as bf,OW as bg,SW as bh,zW as bi,PW as bj,vW as bk,NW as bl,_W as bm,TW as bn,bW as bo,CW as bp,xW as bq,RW as br,wW as bs,EW as bt,jW as bu,DW as bv,IW as bw,bQ as bx,kW as by,ye as bz,Ik as c,jX as c$,hY as c0,Kee as c1,dee as c2,df as c3,mY as c4,_Y as c5,TY as c6,io as c7,NY as c8,pY as c9,oX as cA,bY as cB,aX as cC,nX as cD,KY as cE,HY as cF,fY as cG,xY as cH,QY as cI,uX as cJ,MZ as cK,bX as cL,vX as cM,hX as cN,gX as cO,BZ as cP,yX as cQ,fX as cR,aY as cS,eX as cT,BY as cU,LY as cV,VY as cW,$Y as cX,UY as cY,GY as cZ,FL as c_,mJ as ca,At as cb,eB as cc,WY as cd,CX as ce,FY as cf,ZY as cg,YY as ch,XY as ci,JY as cj,ZP as ck,iY as cl,Sx as cm,AX as cn,vY as co,yY as cp,zY as cq,UL as cr,kX as cs,SX as ct,wX as cu,xX as cv,lX as cw,q9 as cx,rX as cy,sX as cz,qJ as d,dW as d$,sY as d0,EZ as d1,YP as d2,OY as d3,cX as d4,DZ as d5,gY as d6,RY as d7,DY as d8,EY as d9,UJ as dA,UX as dB,GX as dC,HX as dD,KX as dE,yc as dF,po as dG,M3 as dH,QJ as dI,HJ as dJ,aH as dK,pK as dL,xj as dM,bK as dN,wj as dO,kj as dP,bH as dQ,C$ as dR,to as dS,yd as dT,X$ as dU,_Q as dV,Gee as dW,Mee as dX,gH as dY,Pee as dZ,kQ as d_,LZ as da,dX as db,mX as dc,pX as dd,q3 as de,qY as df,IY as dg,VZ as dh,PY as di,tX as dj,zZ as dk,iX as dl,MY as dm,PX as dn,IX as dp,qX as dq,pJ as dr,Q$ as ds,gW as dt,GJ as du,UZ as dv,Dx as dw,VX as dx,$X as dy,$J as dz,lee as e,Eh as e$,FJ as e0,Iee as e1,JJ as e2,ZJ as e3,mW as e4,qee as e5,YJ as e6,Ht as e7,Ree as e8,AH as e9,xr as eA,Yd as eB,Vee as eC,em as eD,ag as eE,pW as eF,hW as eG,gV as eH,_X as eI,TX as eJ,LX as eK,nJ as eL,aJ as eM,mg as eN,tm as eO,ig as eP,NQ as eQ,dJ as eR,wr as eS,qx as eT,SJ as eU,CJ as eV,_J as eW,TJ as eX,jJ as eY,NJ as eZ,RJ as e_,SV as ea,f$ as eb,CH as ec,Bee as ed,EX as ee,CV as ef,zX as eg,DX as eh,OX as ei,hs as ej,w$ as ek,A$ as el,MX as em,tee as en,MV as eo,cJ as ep,aee as eq,iee as er,see as es,nee as et,BJ as eu,sJ as ev,oJ as ew,rJ as ex,uJ as ey,lJ as ez,ba as f,wJ as f0,gee as f1,sQ as f2,kY as f3,M0 as f4,KJ as f5,hee as f6,yee as f7,xJ as f8,wY as f9,See as fA,QZ as fB,Cee as fC,Tee as fD,Aee as fE,_ee as fF,lo as fG,wS as fH,XZ as fI,eY as fJ,Nee as fK,uI as fL,WZ as fM,JZ as fN,bJ as fa,vJ as fb,yJ as fc,fee as fd,PJ as fe,Nz as ff,eW as fg,XJ as fh,nW as fi,tW as fj,ZZ as fk,Ni as fl,ja as fm,FZ as fn,uV as fo,GU as fp,wee as fq,xee as fr,SQ as fs,jee as ft,kH as fu,tY as fv,YZ as fw,Eee as fx,zee as fy,kee as fz,oee as g,Hx as h,zn as i,ee as j,mV as k,Hl as l,Sn as m,an as n,ree as o,uee as p,cee as q,hJ as r,nY as s,m$ as t,sg as u,gJ as v,fJ as w,na as x,$ee as y,Uee as z};
|