@ainyc/canonry 4.192.1 → 4.192.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/assets/{AuditHistoryPanel-DvqnrQc_.js → AuditHistoryPanel-Cobvw7cD.js} +1 -1
- package/assets/assets/{BacklinksPage-BCk2qBfC.js → BacklinksPage-BKxZl1Or.js} +1 -1
- package/assets/assets/{HistoryPage-IMlkx--Q.js → HistoryPage-CtXevdXo.js} +1 -1
- package/assets/assets/MeasurementPropertyPage-Dr7jyMQx.js +1 -0
- package/assets/assets/ProjectPage-DSgwSrNA.js +8 -0
- package/assets/assets/{RunRow-BherM7NU.js → RunRow-5gcg6hPl.js} +1 -1
- package/assets/assets/{RunsPage-B5G_OrmE.js → RunsPage-D-6s-70o.js} +1 -1
- package/assets/assets/{SettingsPage-CMeCn5uk.js → SettingsPage-DiIoLm4A.js} +1 -1
- package/assets/assets/{SiteHealthSection-DZX1yv4k.js → SiteHealthSection-CSS8dE7I.js} +3 -3
- package/assets/assets/{TrafficPage-BV-HOztp.js → TrafficPage-CTDy_HNO.js} +1 -1
- package/assets/assets/{TrafficSourceDetailPage-9IN0q7bd.js → TrafficSourceDetailPage-CldL3bHd.js} +1 -1
- package/assets/assets/{extract-error-message-c7zJp5uX.js → extract-error-message-B2HJayiT.js} +1 -1
- package/assets/assets/{index-D3KGn0S0.js → index-C-CHPojU.js} +2 -2
- package/assets/assets/index-CjEprBri.css +1 -0
- package/assets/assets/{react-sigma_core.esm.min-DxHkjhKC.js → react-sigma_core.esm.min-DVwmfuwH.js} +1 -1
- package/assets/assets/v2-overview-adapter-CqskEPzK.js +1 -0
- package/assets/index.html +2 -2
- package/package.json +8 -8
- package/assets/assets/MeasurementPropertyPage-1o1e5vmH.js +0 -1
- package/assets/assets/ProjectPage-BusVoYaC.js +0 -8
- package/assets/assets/index-BtTEcbcB.css +0 -1
- package/assets/assets/v2-overview-adapter-COMP5UGt.js +0 -1
|
@@ -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-CSS8dE7I.js","./vendor-tanstack-ZXXkndVj.js","./vendor-lucide-CW2qe0uH.js","./ChartPrimitives-Bxa_vFmq.js","./vendor-recharts-D-cUuLZo.js","./ProjectPage-DSgwSrNA.js","./RunRow-5gcg6hPl.js","./extract-error-message-B2HJayiT.js","./v2-overview-adapter-CqskEPzK.js","./vendor-markdown-B-Oq2NYq.js","./AuditHistoryPanel-Cobvw7cD.js","./vendor-radix-twS1M3FF.js","./vendor-yaml-GWJz5H2G.js","./RunsPage-D-6s-70o.js","./HistoryPage-CtXevdXo.js","./SettingsPage-DiIoLm4A.js","./BacklinksPage-BKxZl1Or.js","./TrafficPage-CTDy_HNO.js","./TrafficSourceDetailPage-CldL3bHd.js","./MeasurementPropertyPage-Dr7jyMQx.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{c as R4,d as D4,r as T,j as c,Q as O4,M as q4,q as pe,e as Tl,L as tt,a as B4,t as Mo,u as zt,f as P4,h as da,k as Ks,l as _x,m as M4,n as zx,O as uh,o as ts,p as I4,s as St,v as Ex,x as ns,y as V4,z as L4,A as U4}from"./vendor-tanstack-ZXXkndVj.js";import{S as G4,O as Kh,P as Tx,C as Hh,a as Rx,T as Qh,D as Dx,R as Ox}from"./vendor-radix-twS1M3FF.js";import{c as qx}from"./vendor-recharts-D-cUuLZo.js";import{A as $4,X as ir,S as K4,L as Fo,C as Fh,R as uu,a as Bx,M as H4,b as Q4,c as F4,d as Zh,T as Px,W as Z4,e as Yh,f as Mx,g as Y4,G as X4,P as J4,H as W4,h as eA,i as tA,j as nA,k as aA,l as iA,B as sA,F as oA,m as rA,n as lA,o as cA,p as nb,E as uA}from"./vendor-lucide-CW2qe0uH.js";import{M as dA}from"./vendor-markdown-B-Oq2NYq.js";import{p as mA}from"./vendor-yaml-GWJz5H2G.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))r(u);new MutationObserver(u=>{for(const f of u)if(f.type==="childList")for(const g of f.addedNodes)g.tagName==="LINK"&&g.rel==="modulepreload"&&r(g)}).observe(document,{childList:!0,subtree:!0});function s(u){const f={};return u.integrity&&(f.integrity=u.integrity),u.referrerPolicy&&(f.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?f.credentials="include":u.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function r(u){if(u.ep)return;u.ep=!0;const f=s(u);fetch(u.href,f)}})();var Op={exports:{}},ul={},qp={exports:{}},Bp={};var ab;function pA(){return ab||(ab=1,(function(e){function a(P,ae){var he=P.length;P.push(ae);e:for(;0<he;){var je=he-1>>>1,X=P[je];if(0<u(X,ae))P[je]=ae,P[he]=X,he=je;else break e}}function s(P){return P.length===0?null:P[0]}function r(P){if(P.length===0)return null;var ae=P[0],he=P.pop();if(he!==ae){P[0]=he;e:for(var je=0,X=P.length,Ie=X>>>1;je<Ie;){var Ne=2*(je+1)-1,Ae=P[Ne],ne=Ne+1,V=P[ne];if(0>u(Ae,he))ne<X&&0>u(V,Ae)?(P[je]=V,P[ne]=he,je=ne):(P[je]=Ae,P[Ne]=he,je=Ne);else if(ne<X&&0>u(V,he))P[je]=V,P[ne]=he,je=ne;else break e}}return ae}function u(P,ae){var he=P.sortIndex-ae.sortIndex;return he!==0?he:P.id-ae.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;e.unstable_now=function(){return f.now()}}else{var g=Date,b=g.now();e.unstable_now=function(){return g.now()-b}}var v=[],k=[],S=1,A=null,C=3,E=!1,Z=!1,_=!1,G=!1,K=typeof setTimeout=="function"?setTimeout:null,te=typeof clearTimeout=="function"?clearTimeout:null,Q=typeof setImmediate<"u"?setImmediate:null;function re(P){for(var ae=s(k);ae!==null;){if(ae.callback===null)r(k);else if(ae.startTime<=P)r(k),ae.sortIndex=ae.expirationTime,a(v,ae);else break;ae=s(k)}}function W(P){if(_=!1,re(P),!Z)if(s(v)!==null)Z=!0,oe||(oe=!0,Re());else{var ae=s(k);ae!==null&&be(W,ae.startTime-P)}}var oe=!1,H=-1,$=5,Te=-1;function Ke(){return G?!0:!(e.unstable_now()-Te<$)}function Fe(){if(G=!1,oe){var P=e.unstable_now();Te=P;var ae=!0;try{e:{Z=!1,_&&(_=!1,te(H),H=-1),E=!0;var he=C;try{t:{for(re(P),A=s(v);A!==null&&!(A.expirationTime>P&&Ke());){var je=A.callback;if(typeof je=="function"){A.callback=null,C=A.priorityLevel;var X=je(A.expirationTime<=P);if(P=e.unstable_now(),typeof X=="function"){A.callback=X,re(P),ae=!0;break t}A===s(v)&&r(v),re(P)}else r(v);A=s(v)}if(A!==null)ae=!0;else{var Ie=s(k);Ie!==null&&be(W,Ie.startTime-P),ae=!1}}break e}finally{A=null,C=he,E=!1}ae=void 0}}finally{ae?Re():oe=!1}}}var Re;if(typeof Q=="function")Re=function(){Q(Fe)};else if(typeof MessageChannel<"u"){var ve=new MessageChannel,Ue=ve.port2;ve.port1.onmessage=Fe,Re=function(){Ue.postMessage(null)}}else Re=function(){K(Fe,0)};function be(P,ae){H=K(function(){P(e.unstable_now())},ae)}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(P){P.callback=null},e.unstable_forceFrameRate=function(P){0>P||125<P?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<P?Math.floor(1e3/P):5},e.unstable_getCurrentPriorityLevel=function(){return C},e.unstable_next=function(P){switch(C){case 1:case 2:case 3:var ae=3;break;default:ae=C}var he=C;C=ae;try{return P()}finally{C=he}},e.unstable_requestPaint=function(){G=!0},e.unstable_runWithPriority=function(P,ae){switch(P){case 1:case 2:case 3:case 4:case 5:break;default:P=3}var he=C;C=P;try{return ae()}finally{C=he}},e.unstable_scheduleCallback=function(P,ae,he){var je=e.unstable_now();switch(typeof he=="object"&&he!==null?(he=he.delay,he=typeof he=="number"&&0<he?je+he:je):he=je,P){case 1:var X=-1;break;case 2:X=250;break;case 5:X=1073741823;break;case 4:X=1e4;break;default:X=5e3}return X=he+X,P={id:S++,callback:ae,priorityLevel:P,startTime:he,expirationTime:X,sortIndex:-1},he>je?(P.sortIndex=he,a(k,P),s(v)===null&&P===s(k)&&(_?(te(H),H=-1):_=!0,be(W,he-je))):(P.sortIndex=X,a(v,P),Z||E||(Z=!0,oe||(oe=!0,Re()))),P},e.unstable_shouldYield=Ke,e.unstable_wrapCallback=function(P){var ae=C;return function(){var he=C;C=ae;try{return P.apply(this,arguments)}finally{C=he}}}})(Bp)),Bp}var ib;function hA(){return ib||(ib=1,qp.exports=pA()),qp.exports}var sb;function fA(){if(sb)return ul;sb=1;var e=hA(),a=R4(),s=D4();function r(t){var n="https://react.dev/errors/"+t;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var i=2;i<arguments.length;i++)n+="&args[]="+encodeURIComponent(arguments[i])}return"Minified React error #"+t+"; visit "+n+" 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 f(t){var n=t,i=t;if(t.alternate)for(;n.return;)n=n.return;else{t=n;do n=t,(n.flags&4098)!==0&&(i=n.return),t=n.return;while(t)}return n.tag===3?i:null}function g(t){if(t.tag===13){var n=t.memoizedState;if(n===null&&(t=t.alternate,t!==null&&(n=t.memoizedState)),n!==null)return n.dehydrated}return null}function b(t){if(t.tag===31){var n=t.memoizedState;if(n===null&&(t=t.alternate,t!==null&&(n=t.memoizedState)),n!==null)return n.dehydrated}return null}function v(t){if(f(t)!==t)throw Error(r(188))}function k(t){var n=t.alternate;if(!n){if(n=f(t),n===null)throw Error(r(188));return n!==t?null:t}for(var i=t,l=n;;){var m=i.return;if(m===null)break;var h=m.alternate;if(h===null){if(l=m.return,l!==null){i=l;continue}break}if(m.child===h.child){for(h=m.child;h;){if(h===i)return v(m),t;if(h===l)return v(m),n;h=h.sibling}throw Error(r(188))}if(i.return!==l.return)i=m,l=h;else{for(var x=!1,w=m.child;w;){if(w===i){x=!0,i=m,l=h;break}if(w===l){x=!0,l=m,i=h;break}w=w.sibling}if(!x){for(w=h.child;w;){if(w===i){x=!0,i=h,l=m;break}if(w===l){x=!0,l=h,i=m;break}w=w.sibling}if(!x)throw Error(r(189))}}if(i.alternate!==l)throw Error(r(190))}if(i.tag!==3)throw Error(r(188));return i.stateNode.current===i?t:n}function S(t){var n=t.tag;if(n===5||n===26||n===27||n===6)return t;for(t=t.child;t!==null;){if(n=S(t),n!==null)return n;t=t.sibling}return null}var A=Object.assign,C=Symbol.for("react.element"),E=Symbol.for("react.transitional.element"),Z=Symbol.for("react.portal"),_=Symbol.for("react.fragment"),G=Symbol.for("react.strict_mode"),K=Symbol.for("react.profiler"),te=Symbol.for("react.consumer"),Q=Symbol.for("react.context"),re=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),oe=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),$=Symbol.for("react.lazy"),Te=Symbol.for("react.activity"),Ke=Symbol.for("react.memo_cache_sentinel"),Fe=Symbol.iterator;function Re(t){return t===null||typeof t!="object"?null:(t=Fe&&t[Fe]||t["@@iterator"],typeof t=="function"?t:null)}var ve=Symbol.for("react.client.reference");function Ue(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===ve?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case _:return"Fragment";case K:return"Profiler";case G:return"StrictMode";case W:return"Suspense";case oe:return"SuspenseList";case Te:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case Z:return"Portal";case Q:return t.displayName||"Context";case te:return(t._context.displayName||"Context")+".Consumer";case re:var n=t.render;return t=t.displayName,t||(t=n.displayName||n.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case H:return n=t.displayName||null,n!==null?n:Ue(t.type)||"Memo";case $:n=t._payload,t=t._init;try{return Ue(t(n))}catch{}}return null}var be=Array.isArray,P=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ae=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,he={pending:!1,data:null,method:null,action:null},je=[],X=-1;function Ie(t){return{current:t}}function Ne(t){0>X||(t.current=je[X],je[X]=null,X--)}function Ae(t,n){X++,je[X]=t.current,t.current=n}var ne=Ie(null),V=Ie(null),q=Ie(null),le=Ie(null);function De(t,n){switch(Ae(q,n),Ae(V,t),Ae(ne,null),n.nodeType){case 9:case 11:t=(t=n.documentElement)&&(t=t.namespaceURI)?Ay(t):0;break;default:if(t=n.tagName,n=n.namespaceURI)n=Ay(n),t=Cy(n,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}Ne(ne),Ae(ne,t)}function ye(){Ne(ne),Ne(V),Ne(q)}function Je(t){t.memoizedState!==null&&Ae(le,t);var n=ne.current,i=Cy(n,t.type);n!==i&&(Ae(V,t),Ae(ne,i))}function Ge(t){V.current===t&&(Ne(ne),Ne(V)),le.current===t&&(Ne(le),ol._currentValue=he)}var Be,de;function Me(t){if(Be===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);Be=n&&n[1]||"",de=-1<i.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<i.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
4
|
`+Be+t+de}var Gt=!1;function Sn(t,n){if(!t||Gt)return"";Gt=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(n){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(F){var L=F}Reflect.construct(t,[],ie)}else{try{ie.call()}catch(F){L=F}t.call(ie.prototype)}}else{try{throw Error()}catch(F){L=F}(ie=t())&&typeof ie.catch=="function"&&ie.catch(function(){})}}catch(F){if(F&&L&&typeof F.stack=="string")return[F.stack,L.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var m=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");m&&m.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var h=l.DetermineComponentFrameRoot(),x=h[0],w=h[1];if(x&&w){var z=x.split(`
|
|
@@ -83,4 +83,4 @@ spec:
|
|
|
83
83
|
`);ut(Pe),Xs(!0)}}catch(U){Yl(U instanceof Error?U.message:"Failed to generate queries"),K({flowVersion:st,onboardingSessionId:_,event:"onboarding.blocked",step:"queries",action:"generate_queries",reasonCode:Sl(U,"unknown")},"onboarding.blocked:queries:generate")}finally{Ws(!1)}}},qd=async()=>{if(!Be)return;const U=qa;if(U.length!==0){Ot(!0),wi(null);try{await kI(Be,U),ki(!0),await r(),K({flowVersion:st,onboardingSessionId:_,event:"onboarding.step_completed",step:"competitors",method:"manual",countBucket:La(U.length)},"onboarding.step_completed:competitors"),P(4)}catch(Pe){wi(Pe instanceof Error?Pe.message:"Failed to save competitors"),K({flowVersion:st,onboardingSessionId:_,event:"onboarding.blocked",step:"competitors",action:"save",reasonCode:"unknown"},"onboarding.blocked:competitors:save")}finally{Ot(!1)}}},so=async()=>{const U=wr.trim();if(U){hs(!0),gn(null);try{await ES("gemini",{apiKey:U}),rn({title:"Gemini configured",detail:"Provider is ready — continuing setup.",tone:"positive",dedupeKey:"setup:gemini:configured",dedupeMode:"drop"}),ao(""),await r(),Ha(b.providerStatuses.find(Pe=>Pe.name.toLowerCase()==="gemini")?.name??"gemini"),K({flowVersion:st,onboardingSessionId:_,event:"onboarding.step_completed",step:"system",method:"inline"},"onboarding.step_completed:system")}catch(Pe){gn(Pe instanceof Error?Pe.message:"Failed to save Gemini key"),K({flowVersion:st,onboardingSessionId:_,event:"onboarding.blocked",step:"system",action:"configure_provider",reasonCode:"provider_save_failed"},"onboarding.blocked:system:provider_save_failed")}finally{hs(!1)}}},Wn=async()=>{if(!Bs()){if(!Be||_n){Si(_n??"Complete setup before launching the first sweep.");const U=In??(Be?Jn===0?"no_queries":"run_rejected":"unknown");un||K({flowVersion:st,onboardingSessionId:_,event:"run.requested",origin:"dashboard_setup",result:"rejected",providerCountBucket:La(bi),queryCountBucket:La(Jn),reasonCode:U});return}kr(!0),Si(null);try{const U=await Nn.mutateAsync({projectName:Be,projectLabel:Ne||X||Be,sourceAction:"setup-launch"});ya(U.id),Rd(!0),w3(Be,U.id),Ra.current=U.id,un||K({flowVersion:st,onboardingSessionId:_,event:"run.requested",origin:"dashboard_setup",result:"queued",providerCountBucket:La(bi),queryCountBucket:La(Jn)}),await r()}catch(U){Si(U instanceof Error?U.message:"Failed to queue the visibility sweep. Retry when the instance is ready."),un||K({flowVersion:st,onboardingSessionId:_,event:"run.requested",origin:"dashboard_setup",result:"rejected",providerCountBucket:La(bi),queryCountBucket:La(Jn),reasonCode:Sl(U,"run_rejected")})}finally{kr(!1)}}},ea=()=>P(U=>C?2:Math.max(0,U-1)),gs=(U,Pe,yn)=>{K({flowVersion:st,onboardingSessionId:_,event:"onboarding.step_completed",step:U,method:"existing",...yn===void 0?{}:{countBucket:La(yn)}},`onboarding.step_completed:${U}`),P(Pe)},ji=()=>{if(K({flowVersion:st,onboardingSessionId:_,event:"onboarding.step_completed",step:"queries",method:"skipped",countBucket:"0"},"onboarding.step_completed:queries"),C){ln();return}P(3)},Ai=()=>{K({flowVersion:st,onboardingSessionId:_,event:"onboarding.step_completed",step:"competitors",method:"skipped",countBucket:"0"},"onboarding.step_completed:competitors"),P(4)},ac=C?"section":ua,oo=$t!==!0||Ka===!0?c.jsx(fe,{type:"button",variant:"ghost",size:"sm",className:"min-h-11",onClick:()=>{r(),Wt&&Js.refetch()},children:"Check again"}):null,ic=($t===!1||ds)&&!!An,ys=C&&(be===2||be===4)?v?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:$t===!1?"Connect a provider":"Answer engine provider"}),c.jsx(pn,{tone:$t===!0?"positive":"neutral",children:$t===!0?"Configured":$t===!1?"Not connected":"Checking"})]}),c.jsx("p",{className:"max-w-prose text-sm text-secondary",children:$t===!0?Pn.length>0?`${Pn.map(U=>U.displayName??U.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.":$t===!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."}),$t===!1||ds?An?c.jsx("div",{children:c.jsx(J$,{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:br,id:"setup-provider",className:"setup-input",value:An.name,onChange:U=>{U.target.value!==An.name&&(eo.current=document.activeElement===U.currentTarget,Jl(U.target.value))},children:ga.map(U=>c.jsx("option",{value:U.name,children:U.displayName??U.name},U.name))})]}),secondaryActions:oo,providerName:An.name,keyUrl:An.keyUrl,modelHint:An.modelHint,onSaved:()=>{vr(!1),r()}},An.name)}):c.jsx("p",{className:"max-w-prose text-sm text-secondary",children:Xn.length>0?`This project's provider selection is ${Xn.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:[$t===!0&&!ds&&An?c.jsx(fe,{type:"button",variant:"outline",size:"sm",onClick:()=>vr(!0),children:"Configure a provider"}):null,!An||Ka===!0?c.jsx(fe,{type:"button",variant:"outline",size:"sm",asChild:!0,children:c.jsx(tt,{to:"/settings",target:"_blank",rel:"noopener noreferrer",children:"Open provider settings"})}):null,ic?null:oo]})]}):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."}),gr?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:$t===!0?"An answer engine is available for this project.":$t===!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(fe,{type:"button",variant:"ghost",size:"sm",className:"min-h-11",disabled:Tt.isFetching,onClick:()=>{Tt.refetch()},children:gr?"Retry provider check":"Check again"})]}):null,va=(()=>{switch(be){case 0:return c.jsxs(ua,{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:A.healthChecks.map(U=>c.jsxs("div",{className:"health-check-row",children:[c.jsxs("div",{children:[c.jsx("p",{className:"run-row-title",children:U.label}),c.jsx("p",{className:"supporting-copy",children:U.detail}),U.id==="provider"&&U.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:wr,onChange:Pe=>ao(Pe.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:io}),c.jsx(fe,{type:"button",size:"sm",disabled:io||!wr.trim(),onClick:Qt(so),children:io?"Saving...":"Save"})]}),tc&&c.jsxs("div",{role:"alert",className:"space-y-1 text-xs text-negative",children:[c.jsx("p",{children:tc}),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(tt,{to:"/settings",className:"text-link hover:underline",children:"Settings"}),"."]})]})]}),c.jsx(pn,{tone:U.state==="ready"?"positive":"caution",title:U.id==="api"?nr(S.apiStatus):U.id==="worker"?nr(S.workerStatus):U.detail,children:U.state==="ready"?"Ready":"Attention"})]},U.id))}),c.jsxs("div",{className:"setup-nav",children:[A.launchState.blockedReason?c.jsx("p",{role:"status",className:"supporting-copy text-negative",children:A.launchState.blockedReason}):c.jsx("span",{}),c.jsx(fe,{type:"button",disabled:!A.launchState.enabled,title:A.launchState.blockedReason,onClick:()=>{K({flowVersion:st,onboardingSessionId:_,event:"onboarding.step_completed",step:"system",method:"automatic"},"onboarding.step_completed:system"),P(Ue)},children:"Continue"})]})]});case 1:return c.jsxs(ua,{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(pn,{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(fe,{type:"button",variant:"outline",onClick:ea,children:"Back"}),c.jsx(fe,{type:"button",onClick:()=>gs("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:X,onChange:U=>Ie(U.target.value)}),ba&&ba!==X?c.jsxs("p",{className:"supporting-copy",children:["Slug: ",ba]}):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:Ne,onChange:U=>Ae(U.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:ne,onChange:U=>V(U.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:q,onChange:U=>le(U.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:De,onChange:U=>ye(U.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:Je,onChange:U=>Ge(U.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(tt,{to:"/backlinks",className:"text-positive-400 hover:text-positive underline underline-offset-2",children:"Manage backlinks"})]})]})]}),Me?c.jsx("p",{className:"text-negative-400 text-sm",children:Me}):null,c.jsxs("div",{className:"setup-nav",children:[c.jsx(fe,{type:"button",variant:"outline",onClick:ea,children:"Back"}),c.jsx(fe,{type:"button",disabled:!ba||!ne||Sn,onClick:Qt(nc),children:Sn?"Creating...":"Create project"})]})]})]});case 2:return c.jsxs(ac,{className:C?"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:C?"Step 1 of 2":"Step 3 of 5"}),c.jsx("h2",{id:"setup-queries-heading",children:"Add queries"})]}),je?c.jsx(pn,{tone:"neutral",children:"Loading"}):oe.isError?c.jsx(pn,{tone:"negative",children:"Load failed"}):Jt?c.jsxs(pn,{tone:"positive",children:[Mn.length," saved"]}):c.jsxs(pn,{tone:"neutral",children:[Mn.length," quer",Mn.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(fe,{type:"button",variant:"outline",size:"sm",className:"min-h-11 shrink-0 self-start",onClick:Qt(Ed),children:Wl?"Research prompt copied":"Copy research prompt"})]}),c.jsxs("details",{open:Pt||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:ec})]}),Pt?c.jsx("p",{role:"alert",className:"text-sm text-negative",children:"Could not copy. Select and copy the prompt above."}):null]}),je?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…"}):oe.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(fe,{type:"button",variant:"outline",onClick:C?ln:ea,children:"Back"}),c.jsx(fe,{type:"button",onClick:()=>{oe.refetch()},children:"Retry loading queries"})]})]}):Jt?c.jsxs("div",{className:"compact-stack",children:[c.jsx("ul",{className:"detail-list",children:Mn.map(U=>c.jsx("li",{children:U},U))}),c.jsxs("div",{className:"setup-nav",children:[c.jsx(fe,{type:"button",variant:"outline",onClick:C?ln:ea,children:"Back"}),c.jsx(fe,{type:"button",variant:"outline",onClick:()=>cs(!1),children:"Edit queries"}),c.jsx(fe,{type:"button",onClick:()=>gs("queries",C?4:3,Mn.length),children:"Continue"})]})]}):c.jsxs("div",{className:"compact-stack",children:[Pn.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:jn,onChange:U=>Ha(U.target.value),children:Pn.map(U=>c.jsxs("option",{value:U.name,children:[U.displayName??U.name,U.model?` (${U.model})`:""]},U.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:vi,onChange:U=>zd(Number(U.target.value)),children:[3,5,10,15,20].map(U=>c.jsx("option",{value:U,children:U},U))})]}),c.jsx(fe,{type:"button",variant:"outline",disabled:yr||!jn,onClick:Qt(Od),children:yr?"Analyzing site...":"Generate"})]}),xi?c.jsx("p",{className:"text-negative-400 text-sm",children:xi}):null]}):null,C?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:Ve,onChange:U=>ut(U.target.value)})]}),Kl?c.jsx("p",{className:"text-negative-400 text-sm",children:Kl}):null,c.jsxs("div",{className:"setup-nav",children:[c.jsx(fe,{type:"button",variant:"outline",onClick:C?ln:ea,children:"Back"}),c.jsx(fe,{type:"button",variant:"ghost",onClick:ji,children:C?"Finish without AI Visibility":"Skip for now"}),c.jsx(fe,{type:"button",disabled:Mn.length===0||Hl,onClick:Qt(Sr),children:Hl?"Saving...":`Save ${Mn.length} quer${Mn.length!==1?"ies":"y"}`})]})]})]});case 3:return c.jsxs(ua,{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"})]}),to?c.jsx(pn,{tone:"positive",children:"Saved"}):null]}),c.jsx("p",{className:"supporting-copy",children:"Domains that compete for the same queries. One per line."}),to?c.jsxs("div",{className:"compact-stack",children:[c.jsx("ul",{className:"detail-list",children:qa.map(U=>c.jsx("li",{children:U},U))}),c.jsxs("div",{className:"setup-nav",children:[c.jsx(fe,{type:"button",variant:"outline",onClick:ea,children:"Back"}),c.jsx(fe,{type:"button",onClick:()=>gs("competitors",4,qa.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:xr,onChange:U=>ms(U.target.value)})]}),Qa?c.jsx("p",{className:"text-negative-400 text-sm",children:Qa}):null,c.jsxs("div",{className:"setup-nav",children:[c.jsx(fe,{type:"button",variant:"outline",onClick:ea,children:"Back"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(fe,{type:"button",variant:"outline",onClick:Ai,children:"Skip"}),c.jsx(fe,{type:"button",disabled:qa.length===0||Fa,onClick:Qt(qd),children:Fa?"Saving...":`Save ${qa.length} competitor${qa.length!==1?"s":""}`})]})]})]})]});case 4:{const U=Oa.data,Pe=U?.status??(Da===Ke?.id?Ke.status:void 0),yn=Pe==="completed"||Pe==="partial"||Pe==="failed"||Pe==="cancelled",Ba=U?.snapshots??[],ro=Ba.filter(ta=>ta.citationState==="cited").length,sc=Ba.filter(ta=>ta.answerMentioned===!0).length,bs=new Set(Ba.map(ta=>ta.query).filter(ta=>!!ta)).size,vs=Pe?Sx(Pe,Ba.length):!1,jr=Fe&&!Cn,dn=Za??(U?.error?JI(U.error):Pe==="cancelled"?"The sweep was cancelled before it produced a baseline.":(Pe==="completed"||Pe==="partial")&&Ba.length===0?"The sweep finished without producing any snapshots.":Ke?.statusDetail||"The sweep did not produce a baseline.");let Vn=null;return jr||vs?Vn=c.jsx(pn,{tone:"positive",children:"Complete"}):Za&&!Cn?Vn=c.jsx(pn,{tone:"negative",children:"Failed"}):yn?Vn=c.jsx(pn,{tone:"negative",children:Pe==="cancelled"?"Cancelled":"Failed"}):Cn&&(Vn=c.jsx(pn,{tone:"caution",children:"Running"})),c.jsxs(ua,{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:C?"Step 2 of 2":"Step 5 of 5"}),c.jsx("h2",{children:Bs()?"AI Visibility":"Launch first run"})]}),Vn]}),jr?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(fe,{type:"button",onClick:ln,children:g?"Finish and open project":"Open project dashboard →"})]})]}):!Cn&&Bs()?c.jsxs("div",{className:"compact-stack",children:[Be?c.jsx(a$,{projectName:Be}):c.jsx("p",{className:"text-sm text-secondary",children:Uh}),Za&&c.jsx("p",{role:"alert",className:"text-sm text-negative",children:Za}),c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(fe,{type:"button",onClick:ln,children:"Open project dashboard →"})]})]}):Cn?yn?vs?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:[" / ",bs]})]}),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:[ro,c.jsxs("span",{className:"text-faint text-lg",children:[" / ",bs]})]}),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:Ba.length}),c.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"completed engine checks"})]})]}),c.jsx("p",{className:"mt-1 text-sm text-secondary",children:g?"Your project is ready. Review the evidence in the project.":"Open the project to review the evidence."}),c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(fe,{type:"button",onClick:ln,children:g?"Finish and open project":"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:dn}),c.jsx("p",{className:"mt-1 text-xs text-secondary",children:Bs()?Uh:v?"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:[v&&!Bs()?c.jsx(fe,{type:"button",variant:"outline",asChild:!0,children:c.jsx(tt,{to:"/settings",children:"Configure providers"})}):c.jsx("span",{}),Bs()||!v?c.jsx(fe,{type:"button",onClick:ln,children:"Open project dashboard →"}):c.jsx(fe,{type:"button",disabled:ps||!!_n,onClick:Qt(Wn),children:ps?"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:Pe??"queued"})]})}),Oa.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:Oa.error instanceof Error?Oa.error.message:"Could not refresh the sweep status."}),c.jsx(fe,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:()=>{Oa.refetch()},children:"Retry status check"})]}),c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(fe,{type:"button",variant:"outline",onClick:ln,children:g?"Finish and open project":"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."]}),(_n||Za)&&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:Za??_n}),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(fe,{type:"button",variant:"outline",onClick:ea,children:"Back"}),c.jsx(fe,{type:"button",variant:"ghost",onClick:ln,children:"Finish without running"}),In==="no_provider"&&!C?c.jsx(fe,{type:"button",asChild:!0,children:c.jsx(tt,{to:"/settings",children:"Configure a provider"})}):c.jsx(fe,{type:"button",disabled:ps||!!_n,title:_n,onClick:Qt(Wn),children:ps?"Launching...":Za?"Retry visibility sweep":"Launch visibility sweep"})]})]})]})}default:return null}})();return c.jsxs("div",{className:C?"page-container visibility-setup":"page-container",children:[g?c.jsx(ar,{current:"visibility"}):null,c.jsxs("div",{className:"page-header",children:[c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{ref:u?f: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(fe,{type:"button",variant:"outline",className:"min-h-11",onClick:ln,children:"Skip AI Visibility"})}):null]}),g?null:c.jsx(aK,{current:C?be===4?1:0:be,labels:C?tK:eK}),c.jsxs("section",{className:"setup-wizard",children:[ys,va]})]})}const oK=T.lazy(async()=>({default:(await yi(()=>import("./SiteHealthSection-DZX1yv4k.js").then(a=>a.d),__vite__mapDeps([0,1,2,3,4]),import.meta.url)).SiteHealthSection})),rK=1800,lK="https://github.com/Canonry/canonry#or-use-any-shell-capable-coding-agent",cK="Help me set up Canonry for my public site.\n\nUse Canonry's official 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\nUse an existing Canonry installation or connected plugin/MCP if one is already available. Do not create a duplicate. The `cnry` and `canonry` commands are interchangeable.\n\n1. Ask for my public domain, country, and language. Do not create or scan anything yet.\n2. Check the local setup with `command -v cnry`, `cnry --version`, `cnry doctor --format json`, and `cnry project list --format json`. If Canonry is missing, propose `npm install -g @canonry/canonry` and wait for approval. If initialization is required, tell me to run `cnry bootstrap` in my private terminal and wait. Never ask me to paste passwords, API keys, OAuth credentials, or `cnry bootstrap` output.\n3. Show the normalized domain, proposed project name, exact `cnry project create ...` command, and wait for explicit approval before creating it.\n4. Propose a bounded Site Health scan, including `--max-pages` and whether dead-link checking is enabled. Show the exact `cnry technical-aeo run ... --wait --format json` command and wait for separate approval before scanning.\n5. After the crawl, summarize the findings and propose AI Visibility setup. Ask before adding queries, connecting providers, starting any provider-backed or quota-consuming run, editing files, or publishing.";function uK(e,a){return e==="legacy"?"legacy":e==="platform"?"platform":a.state==="success"?a.projectCount===0?"platform":"legacy":a.state==="error"?"retry":"loading"}const C3=[{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"}],N3=[{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 dK(e,a){try{const s=new Intl.DisplayNames(["en"],{type:"region"}),r=new Intl.DisplayNames(["en"],{type:"language"}),u=e.length===2?s.of(e.toUpperCase()):void 0,f=a?r.of(a.toLowerCase()):void 0;return`${u??(e||"Country")} · ${f??(a||"Language")}`}catch{return`${e||"Country"} · ${a||"Language"}`}}function mK(e,a){const s=e.trim().toUpperCase(),r=a.trim().toLowerCase();return{countryValid:C3.some(u=>u.value===s),languageValid:N3.some(u=>u.value===r)}}function pK(e){const a=e.replace(/^\[|\]$/g,"");return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(a)||a.includes(":")}function hK(e){const a=e.trim();if(!a)return null;const s=/^[a-z][a-z\d+.-]*:\/\//i.test(a)?a:`https://${a}`;let r;try{r=new URL(s)}catch{return null}if(r.protocol!=="http:"&&r.protocol!=="https:")return null;const u=r.hostname.toLowerCase().replace(/^www\./,"");if(!u||u==="localhost"||pK(u)||!u.includes("."))return null;const f=u.replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return f?{canonicalDomain:u,projectName:f,displayName:u}:null}async function fK(e,a=rK){let s;const r=new Promise(f=>{s=setTimeout(()=>f({state:"timed-out"}),a)}),u=await Promise.race([e.then(f=>({state:"queued",run:f})),r]);return s&&clearTimeout(s),u}function gK(e,a){e.catch(()=>{rn({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:${a}`})})}function _3(e){const a=T.useRef(v3()).current,s=T.useRef(new Set),r=T.useCallback((u,f)=>{if(f){if(s.current.has(f))return;s.current.add(f)}TS({...u,surface:e,eventId:x3()})},[e]);return{onboardingSessionId:a,emit:r}}function Cx(e,a){return e instanceof fn&&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:a}function yK(){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(Fo,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading projects…"]})]})}function bK({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(fe,{type:"button",className:"mt-4",variant:"secondary",onClick:e,children:"Retry project check"})]})]})}function vK({projectName:e,initialRunId:a}){return c.jsx(Nf,{title:"Site Health setup",children:c.jsx(xK,{projectName:e,initialRunId:a})})}function xK({projectName:e,initialRunId:a}){const s=Ks(),r=zt({...Fs({client:se}),enabled:!!e,retry:!1,refetchOnMount:"always"}),{onboardingSessionId:u,emit:f}=_3("site_health");T.useEffect(()=>{e&&f({flowVersion:st,onboardingSessionId:u,event:"onboarding.started",step:"run",resumed:!!a},"onboarding.started")},[f,a,u,e]),T.useEffect(()=>{!e||!a||S3(e)?.runId!==a&&w3(e,a)},[a,e]);const b=zt({...ff({client:se,path:{id:a??""}}),enabled:!!a,refetchInterval:({state:C})=>{const E=C.data?.status;return E==="completed"||E==="partial"||E==="failed"||E==="cancelled"?!1:2e3},refetchIntervalInBackground:!0}).data?.status;if(T.useEffect(()=>{if(!e||!a||!b)return;if(b==="completed"||b==="partial"){f({flowVersion:st,onboardingSessionId:u,event:"onboarding.step_completed",step:"run",method:"automatic"},"onboarding.step_completed:run"),Fu(a);return}if(b!=="failed"&&b!=="cancelled")return;const C=b==="cancelled"?"run_cancelled":"run_failed";f({flowVersion:st,onboardingSessionId:u,event:"onboarding.blocked",step:"run",action:"retry_run",reasonCode:C},`onboarding.blocked:run:${C}`),Fu(a)},[f,a,u,e,b]),!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(fe,{type:"button",variant:"secondary",onClick:()=>{s({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(ar,{current:"site"}),c.jsxs("div",{className:"mt-8 flex items-center gap-3 text-sm text-secondary",role:"status",children:[c.jsx(Fo,{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(fe,{type:"button",className:"mt-4",variant:"secondary",onClick:()=>{r.refetch()},children:"Retry project check"})]})]});const v=r.data.find(C=>C.name===e);if(!v)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(fe,{type:"button",variant:"secondary",onClick:()=>{s({to:"/projects"})},children:"View projects"})]});const k=()=>{s({to:"/setup",search:{onboarding:"site-health",setupProject:v.name},replace:!0})},S=()=>{s({to:"/setup",search:{experience:"legacy",onboarding:"site-health",setupProject:v.name},replace:!0})},A=()=>{f({flowVersion:st,onboardingSessionId:u,event:"onboarding.step_completed",step:"run",method:"skipped"},"onboarding.step_completed:run"),s({to:"/projects/$projectName/technical-aeo",params:{projectName:v.name},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(T.Suspense,{fallback:c.jsxs("div",{className:"space-y-5",children:[c.jsx(ar,{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(Fo,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading Site Health…"]})]}),children:c.jsx(oK,{projectName:v.name,projectId:v.id,initialRunId:a,onReleaseInitialRun:k,showOnboardingActions:!0,onContinueOnboarding:S,onSkipOnboarding:A})})]})}function kK(){const e=_x({from:"/setup"}),a=e.onboarding==="site-health"&&!e.setupProject,s=e.onboarding==="site-health"&&e.experience!=="legacy",r=XM(),u=e.experience==="legacy"?"legacy":e.experience==="platform"?"platform":r,[f,g]=T.useState(!1),b=zt({...Fs({client:se}),enabled:u==="auto",retry:!1,refetchOnMount:"always"}),v=u==="auto"&&b.isSuccess&&b.isFetchedAfterMount&&b.data.length===0;T.useEffect(()=>{v&&g(!0)},[v]);const k=u!=="auto"?{state:"idle"}:b.isSuccess&&b.isFetchedAfterMount?{state:"success",projectCount:b.data.length}:b.isError?{state:"error"}:{state:"loading"},S=u==="legacy"?"legacy":f||v?"platform":uK(u,k);return a||s?c.jsx(vK,{projectName:e.setupProject,initialRunId:e.siteHealthRunId}):S==="legacy"?c.jsx(iK,{visibilityProjectName:e.setupProject,siteHealthOnboarding:e.onboarding==="site-health"}):S==="loading"?c.jsx(yK,{}):S==="retry"?c.jsx(bK,{onRetry:()=>{b.refetch()}}):c.jsx(wK,{onActivationStarted:()=>g(!0),skipSiteScan:e.siteScan==="skip"})}function wK({onActivationStarted:e,skipSiteScan:a}){return c.jsx(Nf,{title:"Site Health setup",children:c.jsx(SK,{onActivationStarted:e,skipSiteScan:a})})}function SK({onActivationStarted:e,skipSiteScan:a}){const s=Ks(),r=da(),u=X$(),f=zt({...BV({client:se}),retry:!1}),g=ts(PV()),[b,v]=T.useState(""),[k,S]=T.useState(""),[A,C]=T.useState(""),[E,Z]=T.useState("US"),[_,G]=T.useState("en"),[K,te]=T.useState(!1),[Q,re]=T.useState("idle"),[W,oe]=T.useState(null),[H,$]=T.useState(null),[Te,Ke]=T.useState(!1),[Fe,Re]=T.useState(null),[ve,Ue]=T.useState(!1),be=f.data,P=typeof be?.enabled=="boolean"?be.enabled:null,ae=g.isPending?g.variables.body.enabled:P,[he,je]=T.useState(null),X=T.useRef(null),{onboardingSessionId:Ie,emit:Ne}=_3("platform");T.useEffect(()=>{Ne({flowVersion:st,onboardingSessionId:Ie,event:"onboarding.started",step:"project",resumed:!1},"onboarding.started")},[Ne,Ie]);const Ae=hK(b),ne=k||Ae?.projectName||"",V=A||Ae?.displayName||"",q=Q==="creating"||Q==="dispatching",le=H??Fe,De=dK(E,_),{countryValid:ye,languageValid:Je}=mK(E,_),Ge=ye&&Je;T.useEffect(()=>{le&&X.current?.focus()},[le]);const Be=(Ve,ut)=>s({to:"/setup",search:{...ut?{siteHealthRunId:ut}:{},onboarding:"site-health",setupProject:Ve.name},replace:!0}),de=async Ve=>{re("dispatching"),Re(null);try{const ut=u.mutateAsync({projectName:Ve.name,projectId:Ve.id,projectLabel:Ve.displayName||Ve.name,suppressErrorToast:!0,body:{checkDeadLinks:!0}}),Jt=await fK(ut);if(Jt.state==="queued"){Ne({flowVersion:st,onboardingSessionId:Ie,event:"run.requested",origin:"dashboard_setup",result:"queued",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0"}),await Be(Ve,Jt.run.runId);return}ut.then(()=>{Ne({flowVersion:st,onboardingSessionId:Ie,event:"run.requested",origin:"dashboard_setup",result:"queued",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0"})},cs=>{Ne({flowVersion:st,onboardingSessionId:Ie,event:"run.requested",origin:"dashboard_setup",result:"rejected",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0",reasonCode:Sl(cs,"run_rejected")})}),gK(ut,Ve.id),await Be(Ve)}catch(ut){re("recovery"),Re(Cx(ut,"The project was created, but the Site Health scan could not be started."));const Jt=Sl(ut,"run_rejected");Ne({flowVersion:st,onboardingSessionId:Ie,event:"run.requested",origin:"dashboard_setup",result:"rejected",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0",reasonCode:Jt}),Ne({flowVersion:st,onboardingSessionId:Ie,event:"onboarding.blocked",step:"run",action:"retry_run",reasonCode:Jt},`onboarding.blocked:run:${Jt}`)}},Me=async Ve=>{if(Ve.preventDefault(),!(!Ae||!a&&!K||!Ge||q)){re("creating"),$(null),Ke(!1),Re(null);try{const ut=await yI({name:ne,displayName:V,canonicalDomain:Ae.canonicalDomain,country:E,language:_});if(e(),oe(ut),Ne({flowVersion:st,onboardingSessionId:Ie,event:"onboarding.step_completed",step:"project",method:"manual"},"onboarding.step_completed:project"),await r.invalidateQueries({queryKey:es({client:se})}),a){await s({to:"/setup",search:{experience:"legacy",onboarding:"first-run",setupProject:ut.name},replace:!0});return}await de(ut)}catch(ut){re("idle");const Jt=ut instanceof fn&&ut.statusCode===409;Ke(Jt),$(Cx(ut,"Could not create the project. Try again.")),Ne({flowVersion:st,onboardingSessionId:Ie,event:"onboarding.blocked",step:"project",action:"save",reasonCode:Sl(ut,"project_create_failed")},"onboarding.blocked:project"),Jt&&(e(),r.invalidateQueries({queryKey:es({client:se})}))}}},Gt=()=>{W&&!q&&de(W)},Sn=()=>{q||s({to:"/projects"})},fa=async()=>{try{await navigator.clipboard.writeText(cK),Ue(!0)}catch{rn({tone:"negative",title:"Could not copy setup request",detail:"Open the agent quickstart to continue with the CLI instead."})}},ln=async Ve=>{je(null);try{const ut=await g.mutateAsync({client:se,body:{enabled:Ve}});r.setQueryData(IS({client:se}),ut),ut.enabled!==Ve&&je(`The server kept telemetry ${ut.enabled?"on":"off"}. Check its telemetry settings.`)}catch{je("Could not update telemetry. Try again.")}};return W&&Q==="recovery"?c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx(ar,{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:[W.displayName||W.name," is ready. The Site Health scan needs another try."]})]})}),c.jsxs("div",{ref:X,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:Fe}),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(fe,{type:"button",onClick:Gt,children:"Retry Site Health scan"}),c.jsx(fe,{type:"button",variant:"secondary",onClick:()=>{Be(W)},children:"Continue setup"})]})]})]}):c.jsxs("div",{className:"page-container max-w-xl py-8 md:py-12",children:[a?null:c.jsx(ar,{current:"site"}),c.jsxs("header",{className:`mb-8 ${a?"":"mt-8"}`,children:[c.jsx("h1",{id:"site-map-setup-title",className:"text-2xl font-semibold tracking-[-0.025em] text-heading",children:a?"Create a project":"Map your site"}),c.jsx("p",{className:"mt-2 max-w-lg text-sm leading-6 text-secondary",children:a?"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:Qt(Me),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&&!Ae),"aria-describedby":b&&!Ae?"launchpad-domain-hint launchpad-domain-error":"launchpad-domain-hint",placeholder:"https://example.com",value:b,onChange:Ve=>{v(Ve.target.value),$(null),Ke(!1)}}),c.jsx("p",{id:"launchpad-domain-hint",className:"text-sm text-secondary",children:a?c.jsxs(c.Fragment,{children:["A public domain is still required."," ",c.jsx(tt,{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(tt,{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&&!Ae?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:"Advanced settings"}),c.jsxs("span",{className:"flex items-center gap-2 text-secondary",children:[De,c.jsx(Fh,{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:[Ae?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:ne,onChange:Ve=>S(Ve.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:V,onChange:Ve=>C(Ve.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:E,onChange:Ve=>Z(Ve.target.value),children:C3.map(Ve=>c.jsx("option",{value:Ve.value,children:Ve.label},Ve.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:_,onChange:Ve=>G(Ve.target.value),children:N3.map(Ve=>c.jsx("option",{value:Ve.value,children:Ve.label},Ve.value))})]})]})]})]})]}),a?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:K,onChange:Ve=>te(Ve.target.checked),"aria-label":"Allow Canonry to scan this public site.","aria-describedby":"local-crawl-note"}),c.jsxs("span",{className:"grid gap-0.5",children:[c.jsx("span",{className:"text-sm leading-5 text-heading",children:"Allow Canonry to scan this public site."}),c.jsx("span",{id:"local-crawl-note",className:"text-sm leading-5 text-secondary",children:"The crawl runs on this Canonry instance, follows internal links, and stores its results locally."})]})]}),le?c.jsxs("div",{ref:X,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:le}),Te?c.jsx(fe,{type:"button",variant:"secondary",size:"sm",className:"mt-3",onClick:Sn,children:"View projects"}):null]}):null,c.jsxs("div",{className:"grid gap-2",children:[c.jsx(fe,{className:"h-11 w-full",type:"submit",disabled:!Ae||!a&&!K||!Ge||q,children:Q==="creating"||Q==="dispatching"?c.jsxs(c.Fragment,{children:[c.jsx(Fo,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"})," ",a?"Creating project…":"Mapping site…"]}):a?"Create project":"Map site"}),Q==="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 coding agent."}),c.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-1",children:[c.jsxs(fe,{type:"button",variant:"ghost",size:"sm",className:"-ml-3",onClick:Qt(fa),children:[ve?c.jsx(Zh,{className:"size-3.5","aria-hidden":"true"}):c.jsx(Mx,{className:"size-3.5","aria-hidden":"true"}),c.jsx("span",{"aria-live":"polite",children:ve?"Copied setup request":"Copy setup request"})]}),c.jsx(fe,{asChild:!0,variant:"ghost",size:"sm",children:c.jsxs("a",{href:lK,target:"_blank",rel:"noopener noreferrer",children:["Agent quickstart",c.jsx(uA,{className:"size-3.5","aria-hidden":"true"}),c.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]})})]})]}),P!==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:ae??!1,disabled:g.isPending,onChange:Ve=>{ln(Ve.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,he?c.jsx("p",{className:"mt-1 text-sm text-negative",role:"alert",children:he}):null]}):null]})}function jK(){return c.jsx("div",{className:"page-container",children:c.jsx("section",{className:"page-section",children:c.jsxs(ua,{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(fe,{asChild:!0,children:c.jsx(tt,{to:"/",children:"Return to overview"})})]})})})}const Yn=ns(()=>yi(()=>import("./ProjectPage-BusVoYaC.js"),__vite__mapDeps([5,1,2,6,0,3,4,7,8,9,10,11,12]),import.meta.url),"ProjectPage"),AK=ns(()=>yi(()=>import("./RunsPage-B5G_OrmE.js"),__vite__mapDeps([13,1,6,11,4,2,8,12]),import.meta.url),"RunsPage"),CK=ns(()=>yi(()=>import("./HistoryPage-IMlkx--Q.js"),__vite__mapDeps([14,1,9,11,4,2,8,12]),import.meta.url),"HistoryPage"),NK=ns(()=>yi(()=>import("./SettingsPage-CMeCn5uk.js"),__vite__mapDeps([15,1,11,4,2,8,12]),import.meta.url),"SettingsPage"),_K=ns(()=>yi(()=>import("./BacklinksPage-BCk2qBfC.js"),__vite__mapDeps([16,1,2,11,4,8,12]),import.meta.url),"BacklinksPage"),zK=ns(()=>yi(()=>import("./TrafficPage-BV-HOztp.js"),__vite__mapDeps([17,1,7,2,11,4,8,12]),import.meta.url),"TrafficPage"),EK=ns(()=>yi(()=>import("./TrafficSourceDetailPage-9IN0q7bd.js"),__vite__mapDeps([18,1,7,3,4,2,11,8,12]),import.meta.url),"TrafficSourceDetailPage"),TK=ns(()=>yi(()=>import("./MeasurementPropertyPage-1o1e5vmH.js"),__vite__mapDeps([19,1,3,4,10,2,11,8,12]),import.meta.url),"MeasurementPropertyPage");function RK(){return c.jsx(z$,{children:c.jsx(_$,{})})}const kn=I4()({component:RK,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:void 0,experience:e.experience==="legacy"||e.experience==="platform"?e.experience:void 0,siteScan:e.siteScan==="skip"?"skip":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(a=>[a,typeof e[a]=="string"?e[a]:void 0]))})}),DK=St({getParentRoute:()=>kn,path:"/",component:O$,beforeLoad:async({context:e})=>{let a=e.queryClient.getQueryData(es({client:se}));if(a===void 0)try{a=await e.queryClient.ensureQueryData(Fs({client:se}))}catch{return}if(a.length===0)throw Ex({to:"/setup"})}}),OK=St({getParentRoute:()=>kn,path:"/projects",component:M$}),qK=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,wn=St({getParentRoute:()=>kn,path:"/projects/$projectName",component:()=>c.jsx(uh,{}),beforeLoad:async({context:e,params:a,location:s})=>{const r=a.projectName;if(!qK.test(r))return;let u=e.queryClient.getQueryData(es({client:se}));if(!u)try{u=await e.queryClient.ensureQueryData(Fs({client:se}))}catch{return}const f=u.find(g=>g.id===r);if(f)throw Ex({to:s.pathname.replace(`/projects/${r}`,`/projects/${encodeURIComponent(f.name)}`),replace:!0})}}),BK=St({getParentRoute:()=>wn,path:"/",component:()=>c.jsx(Yn,{tab:"overview"})}),PK=St({getParentRoute:()=>wn,path:"/portfolio",component:()=>c.jsx(Yn,{tab:"portfolio"})}),MK=St({getParentRoute:()=>wn,path:"/search-console",component:()=>c.jsx(Yn,{tab:"search-console"})}),IK=St({getParentRoute:()=>wn,path:"/conversions",component:()=>c.jsx(Yn,{tab:"conversions"})}),VK=St({getParentRoute:()=>wn,path:"/local",component:()=>c.jsx(Yn,{tab:"local"})}),LK=St({getParentRoute:()=>wn,path:"/discovery",component:()=>c.jsx(Yn,{tab:"discovery"})}),UK=St({getParentRoute:()=>wn,path:"/queries",component:()=>c.jsx(Yn,{tab:"queries"})}),GK=St({getParentRoute:()=>wn,path:"/properties/$targetKey",component:()=>c.jsx(TK,{})}),$K=St({getParentRoute:()=>wn,path:"/report",component:()=>c.jsx(Yn,{tab:"report"})}),KK=St({getParentRoute:()=>wn,path:"/activity",component:()=>c.jsx(Yn,{tab:"activity"})}),HK=St({getParentRoute:()=>wn,path:"/backlinks",component:()=>c.jsx(Yn,{tab:"backlinks"})}),QK=St({getParentRoute:()=>wn,path:"/technical-aeo",component:()=>c.jsx(Yn,{tab:"technical-aeo"})}),FK=St({getParentRoute:()=>wn,path:"/history",component:()=>c.jsx(Yn,{tab:"history"})}),ZK=St({getParentRoute:()=>wn,path:"/settings",component:()=>c.jsx(Yn,{tab:"settings"})}),YK=St({getParentRoute:()=>kn,path:"/runs",component:AK}),XK=St({getParentRoute:()=>kn,path:"/history",component:CK}),JK=St({getParentRoute:()=>kn,path:"/settings",component:NK,beforeLoad:({context:e})=>{}}),WK=St({getParentRoute:()=>kn,path:"/setup",component:kK}),eH=St({getParentRoute:()=>kn,path:"/backlinks",component:_K}),tH=St({getParentRoute:()=>kn,path:"/traffic",component:zK}),nH=St({getParentRoute:()=>kn,path:"/traffic/$projectName/$sourceId",component:EK}),aH=St({getParentRoute:()=>kn,path:"*",component:jK}),iH=kn.addChildren([DK,OK,wn.addChildren([BK,PK,MK,IK,VK,LK,UK,GK,$K,KK,HK,QK,FK,ZK]),YK,XK,JK,WK,eH,tH,nH,aH]);function sH(){return typeof window<"u"&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath:"/"}const Nx=sH(),oH=Nx==="/"?"":Nx.replace(/\/$/,"");function rH(e,a){return V4({routeTree:iH,basepath:oH||"/",context:{queryClient:e},...a?.initialEntries})}const lH=6e4;function cH(){const e=T.useRef(hI()).current,[a,s]=T.useState(e?"ready":"checking"),[r,u]=T.useState(null),[f,g]=T.useState(null),[b,v]=T.useState(e),[k,S]=T.useState(!1),[A,C]=T.useState(""),[E,Z]=T.useState(""),[_,G]=T.useState(""),[K,te]=T.useState(!1),[Q,re]=T.useState("password"),[W,oe]=T.useState(null),[H,$]=T.useState(!1),[Te,Ke]=T.useState(!1),Fe=T.useRef(null),Re=T.useRef(null),ve=T.useRef(null),Ue=()=>{const q=r?`${r.name}:${r.role}`:e?"api-key:explicit":f?`api-key:${f.id}`:"no-accounts";if(!Fe.current||ve.current!==q){Re.current?.clear();const le=FI();Re.current=le,Fe.current=rH(le),ve.current=q}return{queryClient:Re.current,router:Fe.current}},be=q=>q.authRequired?(S(!0),u(q.user),g(null),v(!1),s(q.user?"ready":"account-login"),!0):!1;T.useEffect(()=>{let q=!1;const le=async(De,ye=!1)=>{try{const Je=await ih();if(q)return;g(Je),v(!1),s("ready")}catch(Je){if(q)return;if(ye&&Je instanceof fn&&Je.statusCode===401)return CI().then(()=>{q||(oe(null),g(null),v(!1),Ke(!0),s("login"))}).catch(Ge=>{q||(oe(Ge instanceof Error?Ge.message:"Could not clear the invalid session"),s(De))});oe(Je instanceof Error?Je.message:"Could not verify API key access"),s(De)}};return e?(le("api-key-error"),()=>{q=!0}):(Promise.allSettled([Iv(),Mv()]).then(([De,ye])=>{if(q||De.status==="fulfilled"&&be(De.value))return;if(ye.status==="rejected"){const Ge=ye.reason;oe(Ge instanceof Error?Ge.message:"Failed to reach the Canonry API"),s("login");return}const Je=ye.value;Je.authenticated?(v(!0),le("api-key-error",!0)):(g(null),v(!1),s(Je.setupRequired?"setup":"login"))}),()=>{q=!0})},[]),T.useEffect(()=>{if(a!=="ready"||e)return;const q=setInterval(()=>{if(k){Iv().then(le=>{le.authRequired&&!le.user&&(Ke(!0),u(null),g(null),s("account-login"))}).catch(()=>{});return}Mv().then(le=>{le.authenticated||(Ke(!0),g(null),s(le.setupRequired?"setup":"login"))}).catch(()=>{})},lH);return Pv(()=>{Ke(!0),u(null),g(null),v(!1),s(k?"account-login":"login")}),()=>{clearInterval(q),Pv(null)}},[a,k,e]);const P=async q=>{if(q.preventDefault(),!E.trim()||E.trim().length<8){oe("Password must be at least 8 characters");return}if(E!==_){oe("Passwords do not match");return}$(!0),oe(null);try{if(!(await SI(E.trim())).authenticated){oe("Setup failed");return}Z(""),G(""),te(!1),Ke(!1),g(null),v(!0),s("checking");try{const De=await ih();g(De),v(!1),s("ready")}catch(De){oe(De instanceof Error?De.message:"Could not verify API key access"),s("api-key-error")}}catch(le){oe(le instanceof fn||le instanceof Error?le.message:"Setup failed")}finally{$(!1)}},ae=q=>{Z(q),oe(null)},he=q=>{G(q),oe(null)},je=async q=>{if(q.preventDefault(),!!E.trim()){$(!0),oe(null);try{if(!(Q==="api-key"?await AI(E.trim()):await jI(E.trim())).authenticated){oe(Q==="api-key"?"Invalid API key":"Incorrect password");return}const De=await ih();g(De),v(!1),Z(""),te(!1),Ke(!1),s("ready")}catch(le){oe(le instanceof fn||le instanceof Error?le.message:"Authentication failed")}finally{$(!1)}}},X=q=>{re(q),Z(""),te(!1),oe(null)},Ie=async q=>{if(q.preventDefault(),!(!A.trim()||!E)){$(!0),oe(null);try{const le=await NI(A.trim(),E);if(!le.user){oe("Incorrect name or password.");return}Z(""),Ke(!1),u(le.user),g(null),v(!1),s("ready")}catch(le){oe(le instanceof fn?le.message:"Incorrect name or password.")}finally{$(!1)}}};if(a==="ready"){const{queryClient:q,router:le}=Ue();return c.jsx(MI,{account:r,apiKey:f,apiKeyPending:b,children:c.jsx(L4,{client:q,children:c.jsx(U4,{router:le})})})}const Ne=E.trim(),Ae=E.length>0&&Ne.length<8,ne=_.length>0&&E!==_,V=Ne.length>=8&&E===_;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(ua,{className:"surface-card w-full",children:a==="checking"?c.jsx(Ps,{className:"py-8",children:c.jsx("p",{className:"supporting-copy text-center",children:"Connecting to Canonry…"})}):a==="api-key-error"?c.jsxs(c.Fragment,{children:[c.jsxs($o,{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(Ps,{className:"space-y-4",children:[c.jsx("p",{className:"supporting-copy",children:W??"Canonry could not verify this session’s access, so the dashboard stayed locked."}),c.jsx(fe,{type:"button",className:"w-full",onClick:()=>{window.location.reload()},children:"Try again"})]})]}):a==="account-login"?c.jsxs(c.Fragment,{children:[c.jsxs($o,{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(Ps,{children:[Te?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:Qt(Ie),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:q=>{C(q.target.value),oe(null)},"aria-invalid":!!W,"aria-describedby":W?"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:E,onChange:q=>ae(q.target.value),"aria-invalid":!!W,"aria-describedby":W?"account-login-error":void 0})]}),W?c.jsx("p",{id:"account-login-error",role:"alert",className:"text-sm text-negative-400",children:W}):null,c.jsx(fe,{type:"submit",disabled:H||!A.trim()||!E,children:H?"Signing in…":"Sign in"})]})]})]}):a==="setup"?c.jsxs(c.Fragment,{children:[c.jsxs($o,{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(Hu,{children:"Stored on this Canonry install as a salted, one-way hash. Canonry cannot recover it."})]}),c.jsx(Ps,{children:c.jsxs("form",{className:"space-y-4",onSubmit:Qt(P),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:K?"text":"password",name:"new-password",autoComplete:"new-password",minLength:8,required:!0,value:E,onChange:q=>ae(q.target.value),"aria-invalid":Ae,"aria-describedby":"dashboard-password-new-help"}),c.jsx("span",{id:"dashboard-password-new-help","aria-live":"polite",className:Ae?"block text-sm text-negative-400":"block text-sm text-secondary",children:Ae?"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:K?"text":"password",name:"confirm-password",autoComplete:"new-password",minLength:8,required:!0,value:_,onChange:q=>he(q.target.value),"aria-invalid":ne,"aria-describedby":"dashboard-password-confirm-help"}),c.jsx("span",{id:"dashboard-password-confirm-help","aria-live":"polite",className:ne?"block text-sm text-negative-400":"block text-sm text-secondary",children:ne?"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:K,onChange:q=>te(q.target.checked)}),"Show passwords"]}),W?c.jsx("p",{id:"dashboard-password-setup-error",role:"alert",className:"text-sm text-negative-400",children:W}):null,c.jsx(fe,{type:"submit",disabled:H||!V,children:H?"Creating password…":"Create password and continue"})]})})]}):c.jsxs(c.Fragment,{children:[c.jsxs($o,{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(Hu,{children:Q==="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(Ps,{children:[Te?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:Qt(je),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:Q==="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:K?"text":"password",name:Q==="api-key"?"apiKey":"password",autoComplete:Q==="api-key"?"off":"current-password",spellCheck:!1,required:!0,value:E,onChange:q=>ae(q.target.value),"aria-invalid":!!W,"aria-describedby":W?"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:K,onChange:q=>te(q.target.checked)}),Q==="api-key"?"Show API key":"Show password"]}),W?c.jsx("p",{id:"dashboard-password-login-error",role:"alert",className:"text-sm text-negative-400",children:W}):null,c.jsx(fe,{type:"submit",disabled:H||!E.trim(),children:H?"Signing in…":"Open dashboard"}),c.jsx(fe,{type:"button",variant:"ghost",onClick:()=>X(Q==="api-key"?"password":"api-key"),children:Q==="api-key"?"Use dashboard password instead":"Forgot password? Use API key"})]})]})]})})]})})}const z3=document.getElementById("root");if(!z3)throw new Error("Expected #root element for web app bootstrap.");yA.createRoot(z3).render(c.jsx(T.StrictMode,{children:c.jsx(cH,{})}));export{CZ as $,AF as A,fe as B,Lu as C,_F as D,NQ as E,AZ as F,jF as G,_Z as H,gl as I,NZ as J,BQ as K,qQ as L,wY as M,HQ as N,rn as O,WU as P,TZ as Q,RZ as R,XI as S,pn as T,LQ as U,DZ as V,UQ as W,MQ as X,VQ as Y,zZ as Z,EZ as _,kY as a,pf as a$,PQ as a0,OZ as a1,LZ as a2,PZ as a3,IZ as a4,MZ as a5,VZ as a6,uF as a7,gf as a8,ze as a9,KI as aA,VF as aB,on as aC,cV as aD,RV as aE,HF as aF,XF as aG,QF as aH,KH as aI,QH as aJ,SO as aK,FH as aL,xV as aM,KF as aN,AO as aO,Th as aP,HH as aQ,iI as aR,FF as aS,$F as aT,wV as aU,ZF as aV,jY as aW,YF as aX,sY as aY,oY as aZ,GQ as a_,BZ as aa,GS as ab,gi as ac,qZ as ad,EY as ae,_T as af,zT as ag,bH as ah,yH as ai,pF as aj,vF as ak,xF as al,fn as am,kF as an,bQ as ao,JI as ap,aU as aq,Dh as ar,wF as as,Eu as at,eY as au,s_ as av,Uh as aw,Bs as ax,IQ as ay,gH as az,P9 as b,LH as b$,WZ as b0,CV as b1,nZ as b2,iZ as b3,mZ as b4,wZ as b5,kZ as b6,uZ as b7,vZ as b8,jZ as b9,WH as bA,eQ as bB,sQ as bC,iQ as bD,aQ as bE,tQ as bF,nQ as bG,JH as bH,XH as bI,YH as bJ,ZH as bK,Wq as bL,DH as bM,zH as bN,EH as bO,TH as bP,OH as bQ,RH as bR,PH as bS,JZ as bT,qH as bU,BH as bV,eF as bW,NH as bX,zY as bY,VH as bZ,MH as b_,oZ as ba,hZ as bb,fZ as bc,gZ as bd,sZ as be,pZ as bf,rZ as bg,yZ as bh,lZ as bi,bZ as bj,dZ as bk,xZ as bl,SZ as bm,H$ as bn,cZ as bo,ge as bp,fQ as bq,hQ as br,pQ as bs,mQ as bt,cQ as bu,lQ as bv,dQ as bw,uQ as bx,rQ as by,oQ as bz,z2 as c,GZ as c$,UH as c0,_H as c1,IH as c2,AQ as c3,jQ as c4,SQ as c5,tF as c6,qV as c7,aZ as c8,TF as c9,Y$ as cA,JF as cB,qF as cC,IF as cD,BF as cE,WF as cF,SY as cG,PF as cH,xn as cI,gI as cJ,aV as cK,a$ as cL,vQ as cM,vI as cN,xQ as cO,kQ as cP,wQ as cQ,es as cR,lV as cS,mV as cT,CQ as cU,UZ as cV,TI as cW,XQ as cX,$Z as cY,KZ as cZ,HZ as c_,$v as ca,zQ as cb,EQ as cc,zF as cd,EF as ce,TQ as cf,RQ as cg,OQ as ch,DQ as ci,$l as cj,Fs as ck,AS as cl,OF as cm,DF as cn,$G as co,eG as cp,r3 as cq,sG as cr,l3 as cs,c3 as ct,pV as cu,Ms as cv,Zu as cw,IV as cx,W$ as cy,_Y as cz,SF as d,WG as d$,CF as d0,QQ as d1,FQ as d2,ZQ as d3,JQ as d4,YQ as d5,tr as d6,hf as d7,AY as d8,Ad as d9,B$ as dA,$H as dB,tf as dC,RF as dD,tY as dE,iY as dF,lF as dG,GH as dH,oF as dI,rF as dJ,sF as dK,nY as dL,I8 as dM,LF as dN,MF as dO,GF as dP,UF as dQ,kH as dR,yi as dS,ha as dT,xH as dU,aI as dV,rY as dW,cY as dX,lY as dY,X$ as dZ,mY as d_,vf as da,eZ as db,tZ as dc,cI as dd,gQ as de,yQ as df,_Q as dg,$Q as dh,KQ as di,Nf as dj,Cd as dk,xf as dl,J$ as dm,WQ as dn,nr as dp,Hv as dq,dF as dr,hF as ds,gF as dt,yF as du,mF as dv,fF as dw,bF as dx,cF as dy,aY as dz,ZZ as e,wH as e0,bY as e1,vY as e2,xY as e3,uY as e4,dY as e5,vH as e6,hY as e7,yY as e8,pY as e9,gY as ea,ar as eb,SH as ec,fY as ed,m9 as ee,AH as ef,jH as eg,ua as f,QZ as g,ax as h,se as i,sI as j,mn as k,Qt as l,FZ as m,XZ as n,YZ as o,nF as p,iF as q,aF as r,CH as s,eV as t,kf as u,pa as v,CY as w,NY as x,Vh as y,NF as z};
|
|
86
|
+
competitor2.com`,value:xr,onChange:U=>ms(U.target.value)})]}),Qa?c.jsx("p",{className:"text-negative-400 text-sm",children:Qa}):null,c.jsxs("div",{className:"setup-nav",children:[c.jsx(fe,{type:"button",variant:"outline",onClick:ea,children:"Back"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(fe,{type:"button",variant:"outline",onClick:Ai,children:"Skip"}),c.jsx(fe,{type:"button",disabled:qa.length===0||Fa,onClick:Qt(qd),children:Fa?"Saving...":`Save ${qa.length} competitor${qa.length!==1?"s":""}`})]})]})]})]});case 4:{const U=Oa.data,Pe=U?.status??(Da===Ke?.id?Ke.status:void 0),yn=Pe==="completed"||Pe==="partial"||Pe==="failed"||Pe==="cancelled",Ba=U?.snapshots??[],ro=Ba.filter(ta=>ta.citationState==="cited").length,sc=Ba.filter(ta=>ta.answerMentioned===!0).length,bs=new Set(Ba.map(ta=>ta.query).filter(ta=>!!ta)).size,vs=Pe?Sx(Pe,Ba.length):!1,jr=Fe&&!Cn,dn=Za??(U?.error?JI(U.error):Pe==="cancelled"?"The sweep was cancelled before it produced a baseline.":(Pe==="completed"||Pe==="partial")&&Ba.length===0?"The sweep finished without producing any snapshots.":Ke?.statusDetail||"The sweep did not produce a baseline.");let Vn=null;return jr||vs?Vn=c.jsx(pn,{tone:"positive",children:"Complete"}):Za&&!Cn?Vn=c.jsx(pn,{tone:"negative",children:"Failed"}):yn?Vn=c.jsx(pn,{tone:"negative",children:Pe==="cancelled"?"Cancelled":"Failed"}):Cn&&(Vn=c.jsx(pn,{tone:"caution",children:"Running"})),c.jsxs(ua,{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:C?"Step 2 of 2":"Step 5 of 5"}),c.jsx("h2",{children:Bs()?"AI Visibility":"Launch first run"})]}),Vn]}),jr?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(fe,{type:"button",onClick:ln,children:g?"Finish and open project":"Open project dashboard →"})]})]}):!Cn&&Bs()?c.jsxs("div",{className:"compact-stack",children:[Be?c.jsx(a$,{projectName:Be}):c.jsx("p",{className:"text-sm text-secondary",children:Uh}),Za&&c.jsx("p",{role:"alert",className:"text-sm text-negative",children:Za}),c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(fe,{type:"button",onClick:ln,children:"Open project dashboard →"})]})]}):Cn?yn?vs?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:[" / ",bs]})]}),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:[ro,c.jsxs("span",{className:"text-faint text-lg",children:[" / ",bs]})]}),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:Ba.length}),c.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"completed engine checks"})]})]}),c.jsx("p",{className:"mt-1 text-sm text-secondary",children:g?"Your project is ready. Review the evidence in the project.":"Open the project to review the evidence."}),c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(fe,{type:"button",onClick:ln,children:g?"Finish and open project":"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:dn}),c.jsx("p",{className:"mt-1 text-xs text-secondary",children:Bs()?Uh:v?"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:[v&&!Bs()?c.jsx(fe,{type:"button",variant:"outline",asChild:!0,children:c.jsx(tt,{to:"/settings",children:"Configure providers"})}):c.jsx("span",{}),Bs()||!v?c.jsx(fe,{type:"button",onClick:ln,children:"Open project dashboard →"}):c.jsx(fe,{type:"button",disabled:ps||!!_n,onClick:Qt(Wn),children:ps?"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:Pe??"queued"})]})}),Oa.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:Oa.error instanceof Error?Oa.error.message:"Could not refresh the sweep status."}),c.jsx(fe,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:()=>{Oa.refetch()},children:"Retry status check"})]}),c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(fe,{type:"button",variant:"outline",onClick:ln,children:g?"Finish and open project":"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."]}),(_n||Za)&&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:Za??_n}),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(fe,{type:"button",variant:"outline",onClick:ea,children:"Back"}),c.jsx(fe,{type:"button",variant:"ghost",onClick:ln,children:"Finish without running"}),In==="no_provider"&&!C?c.jsx(fe,{type:"button",asChild:!0,children:c.jsx(tt,{to:"/settings",children:"Configure a provider"})}):c.jsx(fe,{type:"button",disabled:ps||!!_n,title:_n,onClick:Qt(Wn),children:ps?"Launching...":Za?"Retry visibility sweep":"Launch visibility sweep"})]})]})]})}default:return null}})();return c.jsxs("div",{className:C?"page-container visibility-setup":"page-container",children:[g?c.jsx(ar,{current:"visibility"}):null,c.jsxs("div",{className:"page-header",children:[c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{ref:u?f: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(fe,{type:"button",variant:"outline",className:"min-h-11",onClick:ln,children:"Skip AI Visibility"})}):null]}),g?null:c.jsx(aK,{current:C?be===4?1:0:be,labels:C?tK:eK}),c.jsxs("section",{className:"setup-wizard",children:[ys,va]})]})}const oK=T.lazy(async()=>({default:(await yi(()=>import("./SiteHealthSection-CSS8dE7I.js").then(a=>a.d),__vite__mapDeps([0,1,2,3,4]),import.meta.url)).SiteHealthSection})),rK=1800,lK="https://github.com/Canonry/canonry#or-use-any-shell-capable-coding-agent",cK="Help me set up Canonry for my public site.\n\nUse Canonry's official 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\nUse an existing Canonry installation or connected plugin/MCP if one is already available. Do not create a duplicate. The `cnry` and `canonry` commands are interchangeable.\n\n1. Ask for my public domain, country, and language. Do not create or scan anything yet.\n2. Check the local setup with `command -v cnry`, `cnry --version`, `cnry doctor --format json`, and `cnry project list --format json`. If Canonry is missing, propose `npm install -g @canonry/canonry` and wait for approval. If initialization is required, tell me to run `cnry bootstrap` in my private terminal and wait. Never ask me to paste passwords, API keys, OAuth credentials, or `cnry bootstrap` output.\n3. Show the normalized domain, proposed project name, exact `cnry project create ...` command, and wait for explicit approval before creating it.\n4. Propose a bounded Site Health scan, including `--max-pages` and whether dead-link checking is enabled. Show the exact `cnry technical-aeo run ... --wait --format json` command and wait for separate approval before scanning.\n5. After the crawl, summarize the findings and propose AI Visibility setup. Ask before adding queries, connecting providers, starting any provider-backed or quota-consuming run, editing files, or publishing.";function uK(e,a){return e==="legacy"?"legacy":e==="platform"?"platform":a.state==="success"?a.projectCount===0?"platform":"legacy":a.state==="error"?"retry":"loading"}const C3=[{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"}],N3=[{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 dK(e,a){try{const s=new Intl.DisplayNames(["en"],{type:"region"}),r=new Intl.DisplayNames(["en"],{type:"language"}),u=e.length===2?s.of(e.toUpperCase()):void 0,f=a?r.of(a.toLowerCase()):void 0;return`${u??(e||"Country")} · ${f??(a||"Language")}`}catch{return`${e||"Country"} · ${a||"Language"}`}}function mK(e,a){const s=e.trim().toUpperCase(),r=a.trim().toLowerCase();return{countryValid:C3.some(u=>u.value===s),languageValid:N3.some(u=>u.value===r)}}function pK(e){const a=e.replace(/^\[|\]$/g,"");return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(a)||a.includes(":")}function hK(e){const a=e.trim();if(!a)return null;const s=/^[a-z][a-z\d+.-]*:\/\//i.test(a)?a:`https://${a}`;let r;try{r=new URL(s)}catch{return null}if(r.protocol!=="http:"&&r.protocol!=="https:")return null;const u=r.hostname.toLowerCase().replace(/^www\./,"");if(!u||u==="localhost"||pK(u)||!u.includes("."))return null;const f=u.replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return f?{canonicalDomain:u,projectName:f,displayName:u}:null}async function fK(e,a=rK){let s;const r=new Promise(f=>{s=setTimeout(()=>f({state:"timed-out"}),a)}),u=await Promise.race([e.then(f=>({state:"queued",run:f})),r]);return s&&clearTimeout(s),u}function gK(e,a){e.catch(()=>{rn({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:${a}`})})}function _3(e){const a=T.useRef(v3()).current,s=T.useRef(new Set),r=T.useCallback((u,f)=>{if(f){if(s.current.has(f))return;s.current.add(f)}TS({...u,surface:e,eventId:x3()})},[e]);return{onboardingSessionId:a,emit:r}}function Cx(e,a){return e instanceof fn&&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:a}function yK(){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(Fo,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading projects…"]})]})}function bK({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(fe,{type:"button",className:"mt-4",variant:"secondary",onClick:e,children:"Retry project check"})]})]})}function vK({projectName:e,initialRunId:a}){return c.jsx(Nf,{title:"Site Health setup",children:c.jsx(xK,{projectName:e,initialRunId:a})})}function xK({projectName:e,initialRunId:a}){const s=Ks(),r=zt({...Fs({client:se}),enabled:!!e,retry:!1,refetchOnMount:"always"}),{onboardingSessionId:u,emit:f}=_3("site_health");T.useEffect(()=>{e&&f({flowVersion:st,onboardingSessionId:u,event:"onboarding.started",step:"run",resumed:!!a},"onboarding.started")},[f,a,u,e]),T.useEffect(()=>{!e||!a||S3(e)?.runId!==a&&w3(e,a)},[a,e]);const b=zt({...ff({client:se,path:{id:a??""}}),enabled:!!a,refetchInterval:({state:C})=>{const E=C.data?.status;return E==="completed"||E==="partial"||E==="failed"||E==="cancelled"?!1:2e3},refetchIntervalInBackground:!0}).data?.status;if(T.useEffect(()=>{if(!e||!a||!b)return;if(b==="completed"||b==="partial"){f({flowVersion:st,onboardingSessionId:u,event:"onboarding.step_completed",step:"run",method:"automatic"},"onboarding.step_completed:run"),Fu(a);return}if(b!=="failed"&&b!=="cancelled")return;const C=b==="cancelled"?"run_cancelled":"run_failed";f({flowVersion:st,onboardingSessionId:u,event:"onboarding.blocked",step:"run",action:"retry_run",reasonCode:C},`onboarding.blocked:run:${C}`),Fu(a)},[f,a,u,e,b]),!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(fe,{type:"button",variant:"secondary",onClick:()=>{s({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(ar,{current:"site"}),c.jsxs("div",{className:"mt-8 flex items-center gap-3 text-sm text-secondary",role:"status",children:[c.jsx(Fo,{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(fe,{type:"button",className:"mt-4",variant:"secondary",onClick:()=>{r.refetch()},children:"Retry project check"})]})]});const v=r.data.find(C=>C.name===e);if(!v)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(fe,{type:"button",variant:"secondary",onClick:()=>{s({to:"/projects"})},children:"View projects"})]});const k=()=>{s({to:"/setup",search:{onboarding:"site-health",setupProject:v.name},replace:!0})},S=()=>{s({to:"/setup",search:{experience:"legacy",onboarding:"site-health",setupProject:v.name},replace:!0})},A=()=>{f({flowVersion:st,onboardingSessionId:u,event:"onboarding.step_completed",step:"run",method:"skipped"},"onboarding.step_completed:run"),s({to:"/projects/$projectName/technical-aeo",params:{projectName:v.name},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(T.Suspense,{fallback:c.jsxs("div",{className:"space-y-5",children:[c.jsx(ar,{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(Fo,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading Site Health…"]})]}),children:c.jsx(oK,{projectName:v.name,projectId:v.id,initialRunId:a,onReleaseInitialRun:k,showOnboardingActions:!0,onContinueOnboarding:S,onSkipOnboarding:A})})]})}function kK(){const e=_x({from:"/setup"}),a=e.onboarding==="site-health"&&!e.setupProject,s=e.onboarding==="site-health"&&e.experience!=="legacy",r=XM(),u=e.experience==="legacy"?"legacy":e.experience==="platform"?"platform":r,[f,g]=T.useState(!1),b=zt({...Fs({client:se}),enabled:u==="auto",retry:!1,refetchOnMount:"always"}),v=u==="auto"&&b.isSuccess&&b.isFetchedAfterMount&&b.data.length===0;T.useEffect(()=>{v&&g(!0)},[v]);const k=u!=="auto"?{state:"idle"}:b.isSuccess&&b.isFetchedAfterMount?{state:"success",projectCount:b.data.length}:b.isError?{state:"error"}:{state:"loading"},S=u==="legacy"?"legacy":f||v?"platform":uK(u,k);return a||s?c.jsx(vK,{projectName:e.setupProject,initialRunId:e.siteHealthRunId}):S==="legacy"?c.jsx(iK,{visibilityProjectName:e.setupProject,siteHealthOnboarding:e.onboarding==="site-health"}):S==="loading"?c.jsx(yK,{}):S==="retry"?c.jsx(bK,{onRetry:()=>{b.refetch()}}):c.jsx(wK,{onActivationStarted:()=>g(!0),skipSiteScan:e.siteScan==="skip"})}function wK({onActivationStarted:e,skipSiteScan:a}){return c.jsx(Nf,{title:"Site Health setup",children:c.jsx(SK,{onActivationStarted:e,skipSiteScan:a})})}function SK({onActivationStarted:e,skipSiteScan:a}){const s=Ks(),r=da(),u=X$(),f=zt({...BV({client:se}),retry:!1}),g=ts(PV()),[b,v]=T.useState(""),[k,S]=T.useState(""),[A,C]=T.useState(""),[E,Z]=T.useState("US"),[_,G]=T.useState("en"),[K,te]=T.useState(!1),[Q,re]=T.useState("idle"),[W,oe]=T.useState(null),[H,$]=T.useState(null),[Te,Ke]=T.useState(!1),[Fe,Re]=T.useState(null),[ve,Ue]=T.useState(!1),be=f.data,P=typeof be?.enabled=="boolean"?be.enabled:null,ae=g.isPending?g.variables.body.enabled:P,[he,je]=T.useState(null),X=T.useRef(null),{onboardingSessionId:Ie,emit:Ne}=_3("platform");T.useEffect(()=>{Ne({flowVersion:st,onboardingSessionId:Ie,event:"onboarding.started",step:"project",resumed:!1},"onboarding.started")},[Ne,Ie]);const Ae=hK(b),ne=k||Ae?.projectName||"",V=A||Ae?.displayName||"",q=Q==="creating"||Q==="dispatching",le=H??Fe,De=dK(E,_),{countryValid:ye,languageValid:Je}=mK(E,_),Ge=ye&&Je;T.useEffect(()=>{le&&X.current?.focus()},[le]);const Be=(Ve,ut)=>s({to:"/setup",search:{...ut?{siteHealthRunId:ut}:{},onboarding:"site-health",setupProject:Ve.name},replace:!0}),de=async Ve=>{re("dispatching"),Re(null);try{const ut=u.mutateAsync({projectName:Ve.name,projectId:Ve.id,projectLabel:Ve.displayName||Ve.name,suppressErrorToast:!0,body:{checkDeadLinks:!0}}),Jt=await fK(ut);if(Jt.state==="queued"){Ne({flowVersion:st,onboardingSessionId:Ie,event:"run.requested",origin:"dashboard_setup",result:"queued",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0"}),await Be(Ve,Jt.run.runId);return}ut.then(()=>{Ne({flowVersion:st,onboardingSessionId:Ie,event:"run.requested",origin:"dashboard_setup",result:"queued",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0"})},cs=>{Ne({flowVersion:st,onboardingSessionId:Ie,event:"run.requested",origin:"dashboard_setup",result:"rejected",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0",reasonCode:Sl(cs,"run_rejected")})}),gK(ut,Ve.id),await Be(Ve)}catch(ut){re("recovery"),Re(Cx(ut,"The project was created, but the Site Health scan could not be started."));const Jt=Sl(ut,"run_rejected");Ne({flowVersion:st,onboardingSessionId:Ie,event:"run.requested",origin:"dashboard_setup",result:"rejected",kind:"site_health",providerCountBucket:"0",queryCountBucket:"0",reasonCode:Jt}),Ne({flowVersion:st,onboardingSessionId:Ie,event:"onboarding.blocked",step:"run",action:"retry_run",reasonCode:Jt},`onboarding.blocked:run:${Jt}`)}},Me=async Ve=>{if(Ve.preventDefault(),!(!Ae||!a&&!K||!Ge||q)){re("creating"),$(null),Ke(!1),Re(null);try{const ut=await yI({name:ne,displayName:V,canonicalDomain:Ae.canonicalDomain,country:E,language:_});if(e(),oe(ut),Ne({flowVersion:st,onboardingSessionId:Ie,event:"onboarding.step_completed",step:"project",method:"manual"},"onboarding.step_completed:project"),await r.invalidateQueries({queryKey:es({client:se})}),a){await s({to:"/setup",search:{experience:"legacy",onboarding:"first-run",setupProject:ut.name},replace:!0});return}await de(ut)}catch(ut){re("idle");const Jt=ut instanceof fn&&ut.statusCode===409;Ke(Jt),$(Cx(ut,"Could not create the project. Try again.")),Ne({flowVersion:st,onboardingSessionId:Ie,event:"onboarding.blocked",step:"project",action:"save",reasonCode:Sl(ut,"project_create_failed")},"onboarding.blocked:project"),Jt&&(e(),r.invalidateQueries({queryKey:es({client:se})}))}}},Gt=()=>{W&&!q&&de(W)},Sn=()=>{q||s({to:"/projects"})},fa=async()=>{try{await navigator.clipboard.writeText(cK),Ue(!0)}catch{rn({tone:"negative",title:"Could not copy setup request",detail:"Open the agent quickstart to continue with the CLI instead."})}},ln=async Ve=>{je(null);try{const ut=await g.mutateAsync({client:se,body:{enabled:Ve}});r.setQueryData(IS({client:se}),ut),ut.enabled!==Ve&&je(`The server kept telemetry ${ut.enabled?"on":"off"}. Check its telemetry settings.`)}catch{je("Could not update telemetry. Try again.")}};return W&&Q==="recovery"?c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx(ar,{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:[W.displayName||W.name," is ready. The Site Health scan needs another try."]})]})}),c.jsxs("div",{ref:X,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:Fe}),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(fe,{type:"button",onClick:Gt,children:"Retry Site Health scan"}),c.jsx(fe,{type:"button",variant:"secondary",onClick:()=>{Be(W)},children:"Continue setup"})]})]})]}):c.jsxs("div",{className:"page-container max-w-xl py-8 md:py-12",children:[a?null:c.jsx(ar,{current:"site"}),c.jsxs("header",{className:`mb-8 ${a?"":"mt-8"}`,children:[c.jsx("h1",{id:"site-map-setup-title",className:"text-2xl font-semibold tracking-[-0.025em] text-heading",children:a?"Create a project":"Map your site"}),c.jsx("p",{className:"mt-2 max-w-lg text-sm leading-6 text-secondary",children:a?"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:Qt(Me),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&&!Ae),"aria-describedby":b&&!Ae?"launchpad-domain-hint launchpad-domain-error":"launchpad-domain-hint",placeholder:"https://example.com",value:b,onChange:Ve=>{v(Ve.target.value),$(null),Ke(!1)}}),c.jsx("p",{id:"launchpad-domain-hint",className:"text-sm text-secondary",children:a?c.jsxs(c.Fragment,{children:["A public domain is still required."," ",c.jsx(tt,{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(tt,{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&&!Ae?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:"Advanced settings"}),c.jsxs("span",{className:"flex items-center gap-2 text-secondary",children:[De,c.jsx(Fh,{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:[Ae?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:ne,onChange:Ve=>S(Ve.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:V,onChange:Ve=>C(Ve.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:E,onChange:Ve=>Z(Ve.target.value),children:C3.map(Ve=>c.jsx("option",{value:Ve.value,children:Ve.label},Ve.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:_,onChange:Ve=>G(Ve.target.value),children:N3.map(Ve=>c.jsx("option",{value:Ve.value,children:Ve.label},Ve.value))})]})]})]})]})]}),a?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:K,onChange:Ve=>te(Ve.target.checked),"aria-label":"Allow Canonry to scan this public site.","aria-describedby":"local-crawl-note"}),c.jsxs("span",{className:"grid gap-0.5",children:[c.jsx("span",{className:"text-sm leading-5 text-heading",children:"Allow Canonry to scan this public site."}),c.jsx("span",{id:"local-crawl-note",className:"text-sm leading-5 text-secondary",children:"The crawl runs on this Canonry instance, follows internal links, and stores its results locally."})]})]}),le?c.jsxs("div",{ref:X,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:le}),Te?c.jsx(fe,{type:"button",variant:"secondary",size:"sm",className:"mt-3",onClick:Sn,children:"View projects"}):null]}):null,c.jsxs("div",{className:"grid gap-2",children:[c.jsx(fe,{className:"h-11 w-full",type:"submit",disabled:!Ae||!a&&!K||!Ge||q,children:Q==="creating"||Q==="dispatching"?c.jsxs(c.Fragment,{children:[c.jsx(Fo,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"})," ",a?"Creating project…":"Mapping site…"]}):a?"Create project":"Map site"}),Q==="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 coding agent."}),c.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-1",children:[c.jsxs(fe,{type:"button",variant:"ghost",size:"sm",className:"-ml-3",onClick:Qt(fa),children:[ve?c.jsx(Zh,{className:"size-3.5","aria-hidden":"true"}):c.jsx(Mx,{className:"size-3.5","aria-hidden":"true"}),c.jsx("span",{"aria-live":"polite",children:ve?"Copied setup request":"Copy setup request"})]}),c.jsx(fe,{asChild:!0,variant:"ghost",size:"sm",children:c.jsxs("a",{href:lK,target:"_blank",rel:"noopener noreferrer",children:["Agent quickstart",c.jsx(uA,{className:"size-3.5","aria-hidden":"true"}),c.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]})})]})]}),P!==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:ae??!1,disabled:g.isPending,onChange:Ve=>{ln(Ve.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,he?c.jsx("p",{className:"mt-1 text-sm text-negative",role:"alert",children:he}):null]}):null]})}function jK(){return c.jsx("div",{className:"page-container",children:c.jsx("section",{className:"page-section",children:c.jsxs(ua,{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(fe,{asChild:!0,children:c.jsx(tt,{to:"/",children:"Return to overview"})})]})})})}const Yn=ns(()=>yi(()=>import("./ProjectPage-DSgwSrNA.js"),__vite__mapDeps([5,1,2,6,0,3,4,7,8,9,10,11,12]),import.meta.url),"ProjectPage"),AK=ns(()=>yi(()=>import("./RunsPage-D-6s-70o.js"),__vite__mapDeps([13,1,6,11,4,2,9,12]),import.meta.url),"RunsPage"),CK=ns(()=>yi(()=>import("./HistoryPage-CtXevdXo.js"),__vite__mapDeps([14,1,10,11,4,2,9,12]),import.meta.url),"HistoryPage"),NK=ns(()=>yi(()=>import("./SettingsPage-DiIoLm4A.js"),__vite__mapDeps([15,1,11,4,2,9,12]),import.meta.url),"SettingsPage"),_K=ns(()=>yi(()=>import("./BacklinksPage-BKxZl1Or.js"),__vite__mapDeps([16,1,2,11,4,9,12]),import.meta.url),"BacklinksPage"),zK=ns(()=>yi(()=>import("./TrafficPage-CTDy_HNO.js"),__vite__mapDeps([17,1,7,2,11,4,9,12]),import.meta.url),"TrafficPage"),EK=ns(()=>yi(()=>import("./TrafficSourceDetailPage-CldL3bHd.js"),__vite__mapDeps([18,1,7,3,4,2,11,9,12]),import.meta.url),"TrafficSourceDetailPage"),TK=ns(()=>yi(()=>import("./MeasurementPropertyPage-Dr7jyMQx.js"),__vite__mapDeps([19,1,3,4,8,9,2,11,12]),import.meta.url),"MeasurementPropertyPage");function RK(){return c.jsx(z$,{children:c.jsx(_$,{})})}const kn=I4()({component:RK,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:void 0,experience:e.experience==="legacy"||e.experience==="platform"?e.experience:void 0,siteScan:e.siteScan==="skip"?"skip":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(a=>[a,typeof e[a]=="string"?e[a]:void 0]))})}),DK=St({getParentRoute:()=>kn,path:"/",component:O$,beforeLoad:async({context:e})=>{let a=e.queryClient.getQueryData(es({client:se}));if(a===void 0)try{a=await e.queryClient.ensureQueryData(Fs({client:se}))}catch{return}if(a.length===0)throw Ex({to:"/setup"})}}),OK=St({getParentRoute:()=>kn,path:"/projects",component:M$}),qK=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,wn=St({getParentRoute:()=>kn,path:"/projects/$projectName",component:()=>c.jsx(uh,{}),beforeLoad:async({context:e,params:a,location:s})=>{const r=a.projectName;if(!qK.test(r))return;let u=e.queryClient.getQueryData(es({client:se}));if(!u)try{u=await e.queryClient.ensureQueryData(Fs({client:se}))}catch{return}const f=u.find(g=>g.id===r);if(f)throw Ex({to:s.pathname.replace(`/projects/${r}`,`/projects/${encodeURIComponent(f.name)}`),replace:!0})}}),BK=St({getParentRoute:()=>wn,path:"/",component:()=>c.jsx(Yn,{tab:"overview"})}),PK=St({getParentRoute:()=>wn,path:"/portfolio",component:()=>c.jsx(Yn,{tab:"portfolio"})}),MK=St({getParentRoute:()=>wn,path:"/search-console",component:()=>c.jsx(Yn,{tab:"search-console"})}),IK=St({getParentRoute:()=>wn,path:"/conversions",component:()=>c.jsx(Yn,{tab:"conversions"})}),VK=St({getParentRoute:()=>wn,path:"/local",component:()=>c.jsx(Yn,{tab:"local"})}),LK=St({getParentRoute:()=>wn,path:"/discovery",component:()=>c.jsx(Yn,{tab:"discovery"})}),UK=St({getParentRoute:()=>wn,path:"/queries",component:()=>c.jsx(Yn,{tab:"queries"})}),GK=St({getParentRoute:()=>wn,path:"/properties/$targetKey",component:()=>c.jsx(TK,{})}),$K=St({getParentRoute:()=>wn,path:"/report",component:()=>c.jsx(Yn,{tab:"report"})}),KK=St({getParentRoute:()=>wn,path:"/activity",component:()=>c.jsx(Yn,{tab:"activity"})}),HK=St({getParentRoute:()=>wn,path:"/backlinks",component:()=>c.jsx(Yn,{tab:"backlinks"})}),QK=St({getParentRoute:()=>wn,path:"/technical-aeo",component:()=>c.jsx(Yn,{tab:"technical-aeo"})}),FK=St({getParentRoute:()=>wn,path:"/history",component:()=>c.jsx(Yn,{tab:"history"})}),ZK=St({getParentRoute:()=>wn,path:"/settings",component:()=>c.jsx(Yn,{tab:"settings"})}),YK=St({getParentRoute:()=>kn,path:"/runs",component:AK}),XK=St({getParentRoute:()=>kn,path:"/history",component:CK}),JK=St({getParentRoute:()=>kn,path:"/settings",component:NK,beforeLoad:({context:e})=>{}}),WK=St({getParentRoute:()=>kn,path:"/setup",component:kK}),eH=St({getParentRoute:()=>kn,path:"/backlinks",component:_K}),tH=St({getParentRoute:()=>kn,path:"/traffic",component:zK}),nH=St({getParentRoute:()=>kn,path:"/traffic/$projectName/$sourceId",component:EK}),aH=St({getParentRoute:()=>kn,path:"*",component:jK}),iH=kn.addChildren([DK,OK,wn.addChildren([BK,PK,MK,IK,VK,LK,UK,GK,$K,KK,HK,QK,FK,ZK]),YK,XK,JK,WK,eH,tH,nH,aH]);function sH(){return typeof window<"u"&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath:"/"}const Nx=sH(),oH=Nx==="/"?"":Nx.replace(/\/$/,"");function rH(e,a){return V4({routeTree:iH,basepath:oH||"/",context:{queryClient:e},...a?.initialEntries})}const lH=6e4;function cH(){const e=T.useRef(hI()).current,[a,s]=T.useState(e?"ready":"checking"),[r,u]=T.useState(null),[f,g]=T.useState(null),[b,v]=T.useState(e),[k,S]=T.useState(!1),[A,C]=T.useState(""),[E,Z]=T.useState(""),[_,G]=T.useState(""),[K,te]=T.useState(!1),[Q,re]=T.useState("password"),[W,oe]=T.useState(null),[H,$]=T.useState(!1),[Te,Ke]=T.useState(!1),Fe=T.useRef(null),Re=T.useRef(null),ve=T.useRef(null),Ue=()=>{const q=r?`${r.name}:${r.role}`:e?"api-key:explicit":f?`api-key:${f.id}`:"no-accounts";if(!Fe.current||ve.current!==q){Re.current?.clear();const le=FI();Re.current=le,Fe.current=rH(le),ve.current=q}return{queryClient:Re.current,router:Fe.current}},be=q=>q.authRequired?(S(!0),u(q.user),g(null),v(!1),s(q.user?"ready":"account-login"),!0):!1;T.useEffect(()=>{let q=!1;const le=async(De,ye=!1)=>{try{const Je=await ih();if(q)return;g(Je),v(!1),s("ready")}catch(Je){if(q)return;if(ye&&Je instanceof fn&&Je.statusCode===401)return CI().then(()=>{q||(oe(null),g(null),v(!1),Ke(!0),s("login"))}).catch(Ge=>{q||(oe(Ge instanceof Error?Ge.message:"Could not clear the invalid session"),s(De))});oe(Je instanceof Error?Je.message:"Could not verify API key access"),s(De)}};return e?(le("api-key-error"),()=>{q=!0}):(Promise.allSettled([Iv(),Mv()]).then(([De,ye])=>{if(q||De.status==="fulfilled"&&be(De.value))return;if(ye.status==="rejected"){const Ge=ye.reason;oe(Ge instanceof Error?Ge.message:"Failed to reach the Canonry API"),s("login");return}const Je=ye.value;Je.authenticated?(v(!0),le("api-key-error",!0)):(g(null),v(!1),s(Je.setupRequired?"setup":"login"))}),()=>{q=!0})},[]),T.useEffect(()=>{if(a!=="ready"||e)return;const q=setInterval(()=>{if(k){Iv().then(le=>{le.authRequired&&!le.user&&(Ke(!0),u(null),g(null),s("account-login"))}).catch(()=>{});return}Mv().then(le=>{le.authenticated||(Ke(!0),g(null),s(le.setupRequired?"setup":"login"))}).catch(()=>{})},lH);return Pv(()=>{Ke(!0),u(null),g(null),v(!1),s(k?"account-login":"login")}),()=>{clearInterval(q),Pv(null)}},[a,k,e]);const P=async q=>{if(q.preventDefault(),!E.trim()||E.trim().length<8){oe("Password must be at least 8 characters");return}if(E!==_){oe("Passwords do not match");return}$(!0),oe(null);try{if(!(await SI(E.trim())).authenticated){oe("Setup failed");return}Z(""),G(""),te(!1),Ke(!1),g(null),v(!0),s("checking");try{const De=await ih();g(De),v(!1),s("ready")}catch(De){oe(De instanceof Error?De.message:"Could not verify API key access"),s("api-key-error")}}catch(le){oe(le instanceof fn||le instanceof Error?le.message:"Setup failed")}finally{$(!1)}},ae=q=>{Z(q),oe(null)},he=q=>{G(q),oe(null)},je=async q=>{if(q.preventDefault(),!!E.trim()){$(!0),oe(null);try{if(!(Q==="api-key"?await AI(E.trim()):await jI(E.trim())).authenticated){oe(Q==="api-key"?"Invalid API key":"Incorrect password");return}const De=await ih();g(De),v(!1),Z(""),te(!1),Ke(!1),s("ready")}catch(le){oe(le instanceof fn||le instanceof Error?le.message:"Authentication failed")}finally{$(!1)}}},X=q=>{re(q),Z(""),te(!1),oe(null)},Ie=async q=>{if(q.preventDefault(),!(!A.trim()||!E)){$(!0),oe(null);try{const le=await NI(A.trim(),E);if(!le.user){oe("Incorrect name or password.");return}Z(""),Ke(!1),u(le.user),g(null),v(!1),s("ready")}catch(le){oe(le instanceof fn?le.message:"Incorrect name or password.")}finally{$(!1)}}};if(a==="ready"){const{queryClient:q,router:le}=Ue();return c.jsx(MI,{account:r,apiKey:f,apiKeyPending:b,children:c.jsx(L4,{client:q,children:c.jsx(U4,{router:le})})})}const Ne=E.trim(),Ae=E.length>0&&Ne.length<8,ne=_.length>0&&E!==_,V=Ne.length>=8&&E===_;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(ua,{className:"surface-card w-full",children:a==="checking"?c.jsx(Ps,{className:"py-8",children:c.jsx("p",{className:"supporting-copy text-center",children:"Connecting to Canonry…"})}):a==="api-key-error"?c.jsxs(c.Fragment,{children:[c.jsxs($o,{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(Ps,{className:"space-y-4",children:[c.jsx("p",{className:"supporting-copy",children:W??"Canonry could not verify this session’s access, so the dashboard stayed locked."}),c.jsx(fe,{type:"button",className:"w-full",onClick:()=>{window.location.reload()},children:"Try again"})]})]}):a==="account-login"?c.jsxs(c.Fragment,{children:[c.jsxs($o,{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(Ps,{children:[Te?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:Qt(Ie),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:q=>{C(q.target.value),oe(null)},"aria-invalid":!!W,"aria-describedby":W?"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:E,onChange:q=>ae(q.target.value),"aria-invalid":!!W,"aria-describedby":W?"account-login-error":void 0})]}),W?c.jsx("p",{id:"account-login-error",role:"alert",className:"text-sm text-negative-400",children:W}):null,c.jsx(fe,{type:"submit",disabled:H||!A.trim()||!E,children:H?"Signing in…":"Sign in"})]})]})]}):a==="setup"?c.jsxs(c.Fragment,{children:[c.jsxs($o,{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(Hu,{children:"Stored on this Canonry install as a salted, one-way hash. Canonry cannot recover it."})]}),c.jsx(Ps,{children:c.jsxs("form",{className:"space-y-4",onSubmit:Qt(P),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:K?"text":"password",name:"new-password",autoComplete:"new-password",minLength:8,required:!0,value:E,onChange:q=>ae(q.target.value),"aria-invalid":Ae,"aria-describedby":"dashboard-password-new-help"}),c.jsx("span",{id:"dashboard-password-new-help","aria-live":"polite",className:Ae?"block text-sm text-negative-400":"block text-sm text-secondary",children:Ae?"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:K?"text":"password",name:"confirm-password",autoComplete:"new-password",minLength:8,required:!0,value:_,onChange:q=>he(q.target.value),"aria-invalid":ne,"aria-describedby":"dashboard-password-confirm-help"}),c.jsx("span",{id:"dashboard-password-confirm-help","aria-live":"polite",className:ne?"block text-sm text-negative-400":"block text-sm text-secondary",children:ne?"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:K,onChange:q=>te(q.target.checked)}),"Show passwords"]}),W?c.jsx("p",{id:"dashboard-password-setup-error",role:"alert",className:"text-sm text-negative-400",children:W}):null,c.jsx(fe,{type:"submit",disabled:H||!V,children:H?"Creating password…":"Create password and continue"})]})})]}):c.jsxs(c.Fragment,{children:[c.jsxs($o,{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(Hu,{children:Q==="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(Ps,{children:[Te?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:Qt(je),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:Q==="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:K?"text":"password",name:Q==="api-key"?"apiKey":"password",autoComplete:Q==="api-key"?"off":"current-password",spellCheck:!1,required:!0,value:E,onChange:q=>ae(q.target.value),"aria-invalid":!!W,"aria-describedby":W?"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:K,onChange:q=>te(q.target.checked)}),Q==="api-key"?"Show API key":"Show password"]}),W?c.jsx("p",{id:"dashboard-password-login-error",role:"alert",className:"text-sm text-negative-400",children:W}):null,c.jsx(fe,{type:"submit",disabled:H||!E.trim(),children:H?"Signing in…":"Open dashboard"}),c.jsx(fe,{type:"button",variant:"ghost",onClick:()=>X(Q==="api-key"?"password":"api-key"),children:Q==="api-key"?"Use dashboard password instead":"Forgot password? Use API key"})]})]})]})})]})})}const z3=document.getElementById("root");if(!z3)throw new Error("Expected #root element for web app bootstrap.");yA.createRoot(z3).render(c.jsx(T.StrictMode,{children:c.jsx(cH,{})}));export{CZ as $,AF as A,fe as B,Lu as C,_F as D,NQ as E,AZ as F,jF as G,_Z as H,gl as I,NZ as J,BQ as K,qQ as L,wY as M,HQ as N,rn as O,WU as P,TZ as Q,RZ as R,XI as S,pn as T,LQ as U,DZ as V,UQ as W,MQ as X,VQ as Y,zZ as Z,EZ as _,kY as a,pf as a$,PQ as a0,OZ as a1,LZ as a2,PZ as a3,IZ as a4,MZ as a5,VZ as a6,uF as a7,gf as a8,ze as a9,KI as aA,VF as aB,on as aC,cV as aD,RV as aE,HF as aF,XF as aG,QF as aH,KH as aI,QH as aJ,SO as aK,FH as aL,xV as aM,KF as aN,AO as aO,Th as aP,HH as aQ,iI as aR,FF as aS,$F as aT,wV as aU,ZF as aV,jY as aW,YF as aX,sY as aY,oY as aZ,GQ as a_,BZ as aa,GS as ab,gi as ac,qZ as ad,EY as ae,_T as af,zT as ag,bH as ah,yH as ai,pF as aj,vF as ak,xF as al,fn as am,kF as an,bQ as ao,JI as ap,aU as aq,Dh as ar,wF as as,Eu as at,eY as au,s_ as av,Uh as aw,Bs as ax,IQ as ay,gH as az,P9 as b,LH as b$,WZ as b0,CV as b1,nZ as b2,iZ as b3,mZ as b4,wZ as b5,kZ as b6,uZ as b7,vZ as b8,jZ as b9,WH as bA,eQ as bB,sQ as bC,iQ as bD,aQ as bE,tQ as bF,nQ as bG,JH as bH,XH as bI,YH as bJ,ZH as bK,Wq as bL,DH as bM,zH as bN,EH as bO,TH as bP,OH as bQ,RH as bR,PH as bS,JZ as bT,qH as bU,BH as bV,eF as bW,NH as bX,zY as bY,VH as bZ,MH as b_,oZ as ba,hZ as bb,fZ as bc,gZ as bd,sZ as be,pZ as bf,rZ as bg,yZ as bh,lZ as bi,bZ as bj,dZ as bk,xZ as bl,SZ as bm,H$ as bn,cZ as bo,ge as bp,fQ as bq,hQ as br,pQ as bs,mQ as bt,cQ as bu,lQ as bv,dQ as bw,uQ as bx,rQ as by,oQ as bz,z2 as c,GZ as c$,UH as c0,_H as c1,IH as c2,AQ as c3,jQ as c4,SQ as c5,tF as c6,qV as c7,aZ as c8,TF as c9,Y$ as cA,JF as cB,qF as cC,IF as cD,BF as cE,WF as cF,SY as cG,PF as cH,xn as cI,gI as cJ,aV as cK,a$ as cL,vQ as cM,vI as cN,xQ as cO,kQ as cP,wQ as cQ,es as cR,lV as cS,mV as cT,CQ as cU,UZ as cV,TI as cW,XQ as cX,$Z as cY,KZ as cZ,HZ as c_,$v as ca,zQ as cb,EQ as cc,zF as cd,EF as ce,TQ as cf,RQ as cg,OQ as ch,DQ as ci,$l as cj,Fs as ck,AS as cl,OF as cm,DF as cn,$G as co,eG as cp,r3 as cq,sG as cr,l3 as cs,c3 as ct,pV as cu,Ms as cv,Zu as cw,IV as cx,W$ as cy,_Y as cz,SF as d,WG as d$,CF as d0,QQ as d1,FQ as d2,ZQ as d3,JQ as d4,YQ as d5,tr as d6,hf as d7,AY as d8,Ad as d9,B$ as dA,$H as dB,tf as dC,RF as dD,tY as dE,iY as dF,lF as dG,GH as dH,oF as dI,rF as dJ,sF as dK,nY as dL,I8 as dM,LF as dN,MF as dO,GF as dP,UF as dQ,kH as dR,yi as dS,ha as dT,xH as dU,aI as dV,rY as dW,cY as dX,lY as dY,X$ as dZ,mY as d_,vf as da,eZ as db,tZ as dc,cI as dd,gQ as de,yQ as df,_Q as dg,$Q as dh,KQ as di,Nf as dj,Cd as dk,xf as dl,J$ as dm,WQ as dn,nr as dp,Hv as dq,dF as dr,hF as ds,gF as dt,yF as du,mF as dv,fF as dw,bF as dx,cF as dy,aY as dz,ZZ as e,wH as e0,bY as e1,vY as e2,xY as e3,uY as e4,dY as e5,vH as e6,hY as e7,yY as e8,pY as e9,gY as ea,ar as eb,SH as ec,fY as ed,m9 as ee,AH as ef,jH as eg,ua as f,QZ as g,ax as h,se as i,sI as j,mn as k,Qt as l,FZ as m,XZ as n,YZ as o,nF as p,iF as q,aF as r,CH as s,eV as t,kf as u,pa as v,CY as w,NY as x,Vh as y,NF as z};
|