@canonry/canonry 7.108.1 → 7.108.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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProjectPage-2oJ95fiK.js","./rolldown-runtime-XKyaHtl9.js","./vendor-lucide-iE5MEh2-.js","./vendor-radix-DKCt5Z_h.js","./vendor-markdown-BBGbNklj.js","./vendor-tanstack-16u6cATb.js","./vendor-recharts-ColROAYR.js","./ToneBadge-BkNG9buI.js","./AccessControls-B6bkOAge.js","./ChartPrimitives-C1meaNiX.js","./account-context-C66suepK.js","./card-iPmHn3JZ.js","./async-handler-Bj3TnIRw.js","./query-client-D_jULVYr.js","./react-query-ih29UP0I.js","./InfoTooltip-D29JcNMW.js","./use-tooltip-position-BOzm-6Wy.js","./Hint-3TTi0MgX.js","./AuditHistoryPanel-Cmm537Mw.js","./service-DYJdF5mP.js","./server-traffic-BScF0-_t.js","./agent-trust-copy-BKQRIoVJ.js","./ServerTrafficSection-umoq1lg0.js","./RunsPage-Cc3kJZ39.js","./HistoryPage-DMmZ0fSd.js","./SettingsPage-NebxmvVG.js","./AgentSetupPage-CR6hyf9a.js","./BacklinksPage-Dg6IJr83.js","./TrafficPage-Dia9_FuQ.js","./TrafficSourceDetailPage-DJ5EQEL9.js","./MeasurementPropertyPage-CpYhSd3d.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProjectPage-DnDw0Cvk.js","./rolldown-runtime-XKyaHtl9.js","./vendor-lucide-iE5MEh2-.js","./vendor-radix-DKCt5Z_h.js","./vendor-markdown-BBGbNklj.js","./vendor-tanstack-16u6cATb.js","./vendor-recharts-ColROAYR.js","./ToneBadge-BkNG9buI.js","./AccessControls-B6bkOAge.js","./ChartPrimitives-C1meaNiX.js","./account-context-C66suepK.js","./card-iPmHn3JZ.js","./async-handler-Bj3TnIRw.js","./query-client-D_jULVYr.js","./react-query-ih29UP0I.js","./InfoTooltip-D29JcNMW.js","./use-tooltip-position-BOzm-6Wy.js","./Hint-3TTi0MgX.js","./AuditHistoryPanel-Cmm537Mw.js","./service-DYJdF5mP.js","./server-traffic-BScF0-_t.js","./agent-trust-copy-BKQRIoVJ.js","./ServerTrafficSection-B-QGjFGD.js","./RunsPage-DG43ZJib.js","./HistoryPage-DMmZ0fSd.js","./SettingsPage-CJlAiPn3.js","./AgentSetupPage-H8VoauIK.js","./BacklinksPage-Dg6IJr83.js","./TrafficPage-Dlp26Fvy.js","./TrafficSourceDetailPage-D-x32dzk.js","./MeasurementPropertyPage-x4S_SV30.js"])))=>i.map(i=>d[i]);
2
2
  import{r as e,t}from"./rolldown-runtime-XKyaHtl9.js";import{C as n,D as r,E as i,F as a,G as o,I as s,J as c,K as l,L as u,M as d,N as f,O as p,P as m,Q as h,R as g,S as _,V as v,W as y,Z as b,_ as x,a as S,at as C,ct as w,d as T,et as E,ft as D,h as O,it as k,j as A,k as j,l as M,lt as N,m as ee,n as P,nt as F,ot as I,r as L,rt as R,s as z,st as te,tt as ne,u as re,v as ie,w as ae,x as oe,y as se,z as ce}from"./vendor-lucide-iE5MEh2-.js";import{a as B,c as V,i as le,n as ue,o as de,r as fe,s as H,t as pe,u as me}from"./vendor-radix-DKCt5Z_h.js";import{n as he,r as ge,t as _e}from"./vendor-markdown-BBGbNklj.js";import{D as ve,E as ye,O as be,S as xe,a as Se,b as Ce,c as we,d as Te,f as Ee,g as De,h as Oe,i as ke,l as Ae,m as je,n as Me,o as Ne,r as Pe,s as U,u as W,v as Fe,x as G}from"./vendor-tanstack-16u6cATb.js";import{$a as Ie,$c as Le,$n as Re,$s as ze,A as Be,An as Ve,As as He,At as Ue,Bc as We,Bt as Ge,Dc as Ke,Ds as qe,Dt as Je,Ec as Ye,Es as Xe,Et as Ze,Fn as Qe,Fo as $e,Fs as et,Ft as tt,G as nt,Gn as rt,I as it,In as at,Is as ot,It as st,Jc as ct,Jn as lt,Js as ut,Kc as dt,Kn as ft,Ks as pt,Ln as mt,Ls as ht,M as gt,Mc as _t,Mn as vt,Mo as yt,Ms as bt,Mt as xt,Nc as St,Nn as Ct,No as wt,Nt as Tt,O as Et,On as Dt,Os as Ot,Ot as kt,P as At,Pn as jt,Po as Mt,Q as Nt,Qn as Pt,R as Ft,Rc as It,Rn as Lt,Rs as Rt,Rt as zt,S as Bt,Sn as Vt,Tc as Ht,Tn as Ut,Ts as K,Uc as Wt,Un as Gt,Vc as Kt,Vn as qt,Vt as Jt,Wc as Yt,Wn as Xt,Xn as Zt,Y as Qt,Yc as $t,Yn as en,Yt as tn,Z as nn,Zc as rn,Zn as an,_c as on,a as sn,al as cn,an as ln,at as un,b as dn,bc as fn,bn as pn,bt as q,cc as mn,cn as hn,co as gn,ct as _n,d as vn,dc as yn,do as bn,dt as xn,el as Sn,en as Cn,et as wn,f as Tn,fc as En,fn as Dn,fo as On,ft as kn,gc as J,go as An,hc as jn,ho as Mn,i as Nn,il as Pn,in as Fn,is as In,it as Ln,j as Rn,jn as zn,js as Bn,k as Vn,kn as Hn,ks as Un,kt as Wn,lc as Gn,ln as Kn,lo as qn,lt as Jn,mc as Yn,mn as Xn,mo as Zn,mt as Qn,n as $n,nl as er,nn as tr,ns as nr,nt as rr,o as ir,ol as ar,ot as or,pc as sr,pn as cr,po as lr,pt as ur,qn as dr,r as Y,rl as fr,rn as pr,rs as mr,rt as hr,sl as gr,sn as _r,ss as vr,st as yr,t as br,tl as xr,tt as Sr,un as Cr,uo as wr,vc as Tr,vt as Er,ws as Dr,x as Or,yc as kr,yn as Ar,yt as jr,zc as Mr,zn as Nr}from"./ToneBadge-BkNG9buI.js";import{E as Pr,H as Fr,_ as Ir,n as Lr,t as Rr}from"./AccessControls-B6bkOAge.js";import{D as zr,F as Br,I as Vr,L as Hr,O as Ur,k as Wr,v as Gr,w as Kr}from"./ChartPrimitives-C1meaNiX.js";import{n as qr,r as Jr,t as Yr}from"./account-context-C66suepK.js";import{t as Xr}from"./async-handler-Bj3TnIRw.js";import{a as Zr,c as Qr,d as $r,f as ei,i as ti,l as ni,m as ri,o as ii,p as ai,r as oi}from"./query-client-D_jULVYr.js";import{Cn as si,Dn as ci,En as li,Ft as ui,Gt as di,It as fi,Kt as pi,Lt as mi,On as hi,Pt as gi,Sn as _i,Tn as vi,Un as yi,Ut as bi,Wt as xi,Yn as Si,a as Ci,bn as wi,c as Ti,cn as Ei,i as Di,ln as Oi,o as ki,s as Ai,u as ji,wn as Mi,xn as Ni}from"./react-query-ih29UP0I.js";import{t as Pi}from"./InfoTooltip-D29JcNMW.js";import{i as Fi,n as Ii,r as Li,t as Ri}from"./card-iPmHn3JZ.js";import{t as zi}from"./vendor-yaml-Y43rmNgW.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Bi=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}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(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Vi=t(((e,t)=>{t.exports=Bi()})),Hi=t((e=>{var t=Vi(),n=D(),r=me();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function x(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function S(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function C(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var w=Object.assign,T=Symbol.for(`react.element`),E=Symbol.for(`react.transitional.element`),O=Symbol.for(`react.portal`),k=Symbol.for(`react.fragment`),A=Symbol.for(`react.strict_mode`),j=Symbol.for(`react.profiler`),M=Symbol.for(`react.consumer`),N=Symbol.for(`react.context`),ee=Symbol.for(`react.forward_ref`),P=Symbol.for(`react.suspense`),F=Symbol.for(`react.suspense_list`),I=Symbol.for(`react.memo`),L=Symbol.for(`react.lazy`),R=Symbol.for(`react.activity`),z=Symbol.for(`react.legacy_hidden`),te=Symbol.for(`react.memo_cache_sentinel`),ne=Symbol.for(`react.view_transition`),re=Symbol.for(`react.recoverable`),ie=Symbol.iterator;function ae(e){return typeof e!=`object`||!e?null:(e=ie&&e[ie]||e[`@@iterator`],typeof e==`function`?e:null)}var oe=Symbol.for(`react.client.reference`);function se(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===oe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case k:return`Fragment`;case j:return`Profiler`;case A:return`StrictMode`;case P:return`Suspense`;case F:return`SuspenseList`;case R:return`Activity`;case ne:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case O:return`Portal`;case N:return e.displayName||`Context`;case M:return(e._context.displayName||`Context`)+`.Consumer`;case ee:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case I:return t=e.displayName||null,t===null?se(e.type)||`Memo`:t;case L:t=e._payload,e=e._init;try{return se(e(t))}catch{}}return null}var ce=Array.isArray,B=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,le={pending:!1,data:null,method:null,action:null},ue=[],de=-1;function fe(e){return{current:e}}function H(e){0>de||(e.current=ue[de],ue[de]=null,de--)}function pe(e,t){de++,ue[de]=e.current,e.current=t}var he=fe(null),ge=fe(null),_e=fe(null),ve=fe(null);function ye(e,t){switch(pe(_e,t),pe(ge,e),pe(he,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}H(he),pe(he,e)}function be(){H(he),H(ge),H(_e)}function xe(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,pe(ve,e)),t=he.current;var n=dp(t,e.type);t!==n&&(pe(ge,e),pe(he,n))}function Se(e){ge.current===e&&(H(he),H(ge)),ve.current===e&&(H(ve),sh._currentValue=le)}var Ce,we;function Te(e){if(Ce===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ce=t&&t[1]||``,we=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+Ce+e+we}var Ee=!1;function De(e,t){if(!e||Ee)return``;Ee=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
@@ -40,4 +40,4 @@ spec:
40
40
  `)),mt(!0)),te(!0))},[P.queriesText,x,M,u,z,E,mt,dt]),(0,X.useEffect)(()=>{z&&(h({flowVersion:1,onboardingSessionId:p,event:`onboarding.started`,step:an(M),resumed:!!g},`onboarding.started`),!g&&M>0&&h({flowVersion:1,onboardingSessionId:p,event:`onboarding.step_completed`,step:`system`,method:`automatic`},`onboarding.step_completed:system`))},[h,M,p,z,g]),(0,X.useEffect)(()=>{u||dr(c)&&st&&h({flowVersion:1,onboardingSessionId:p,event:`onboarding.blocked`,step:`system`,action:st===`no_provider`?`configure_provider`:`continue`,reasonCode:st},`onboarding.blocked:system:${st}`)},[h,c,u,p,st]);let ht=Xe.data?.status,gt=Xe.data?.snapshots?.length??0,_t=F===4&&U&&!!(ht&&rm(ht,gt)),vt=T&&!U;(0,X.useEffect)(()=>{if(!U||!ht)return;let e=Pe.current;if(!e||e!==He)return;if(rm(ht,gt)){h({flowVersion:1,onboardingSessionId:p,event:`onboarding.step_completed`,step:`run`,method:`automatic`,countBucket:lr(gt)},`onboarding.step_completed:run:${e}`),lt(e);return}let t=ht===`cancelled`?`run_cancelled`:ht===`failed`||(ht===`completed`||ht===`partial`)&&gt===0?`run_failed`:void 0;t&&(h({flowVersion:1,onboardingSessionId:p,event:`onboarding.blocked`,step:`run`,action:`retry_run`,reasonCode:t},`onboarding.blocked:run:${e}:${t}`),lt(e))},[h,He,p,ht,gt,U]);let yt=async()=>{if(it&&se){_e(!0),he(null);try{let e=await Be(it,{displayName:ae||re,canonicalDomain:se,country:B,language:le,autoExtractBacklinks:de});pe(it),A.setEngineProject(e),$r({title:`Project created`,detail:`${e.displayName||e.name} is ready for setup.`,tone:`positive`,dedupeKey:`project:create:${e.name}`,dedupeMode:`drop`}),await r(),h({flowVersion:1,onboardingSessionId:p,event:`onboarding.step_completed`,step:`project`,method:`manual`},`onboarding.step_completed:project`),I(2)}catch(e){he(e instanceof Error?e.message:`Failed to create project`),h({flowVersion:1,onboardingSessionId:p,event:`onboarding.blocked`,step:`project`,action:`save`,reasonCode:`project_create_failed`},`onboarding.blocked:project:project_create_failed`)}finally{_e(!1)}}},bt=async()=>{if(!H)return;let e=at;if(e.length!==0){Ae(!0),Oe(null);try{await Cn(H,e),Ee(!0),await r(),h({flowVersion:1,onboardingSessionId:p,event:`onboarding.step_completed`,step:`competitors`,method:`manual`,countBucket:lr(e.length)},`onboarding.step_completed:competitors`),I(4)}catch(e){Oe(e instanceof Error?e.message:`Failed to save competitors`),h({flowVersion:1,onboardingSessionId:p,event:`onboarding.blocked`,step:`competitors`,action:`save`,reasonCode:`unknown`},`onboarding.blocked:competitors:save`)}finally{Ae(!1)}}},xt=async()=>{let e=Ze.trim();if(e){et(!0),nt(null);try{await Hn(`gemini`,{apiKey:e}),$r({title:`Gemini configured`,detail:`Connection saved. Your first check will verify it.`,tone:`positive`,dedupeKey:`setup:gemini:configured`,dedupeMode:`drop`}),Qe(``),await r(),xe.setSelectedProvider(o.providerStatuses.find(e=>e.name.toLowerCase()===`gemini`)?.name??`gemini`),h({flowVersion:1,onboardingSessionId:p,event:`onboarding.step_completed`,step:`system`,method:`inline`},`onboarding.step_completed:system`)}catch(e){nt(e instanceof Error?e.message:`Failed to save Gemini key`),h({flowVersion:1,onboardingSessionId:p,event:`onboarding.blocked`,step:`system`,action:`configure_provider`,reasonCode:`provider_save_failed`},`onboarding.blocked:system:provider_save_failed`)}finally{et(!1)}}},St=async()=>{if(Wn()||Ke.isError||Ke.isFetching||Ke.data?.canStart!==!0)return;if(!H||ut){Ve(ut??`Complete setup before launching the first check.`);let e=st??(H?ot===0?`no_queries`:`run_rejected`:`unknown`);A.usesProjectProviderReadiness||h({flowVersion:1,onboardingSessionId:p,event:`run.requested`,origin:`dashboard_setup`,result:`rejected`,providerCountBucket:lr(A.runnableProviderCount),queryCountBucket:lr(ot),reasonCode:e});return}Le(!0),Ve(null);let e=Ke.data.requestCount;try{let t=await We.mutateAsync({projectName:H,projectLabel:ae||re||H,sourceAction:`setup-launch`});Ye({runId:t.id,requestCount:e}),Ue(t.id),Fe(!0),en(H,t.id,J[`answer-visibility`]),Pe.current=t.id,A.usesProjectProviderReadiness||h({flowVersion:1,onboardingSessionId:p,event:`run.requested`,origin:`dashboard_setup`,result:`queued`,providerCountBucket:lr(A.runnableProviderCount),queryCountBucket:lr(ot)}),await r()}catch(e){Ve(e instanceof Error?e.message:`Failed to queue the AI Visibility check. Retry when the instance is ready.`),A.usesProjectProviderReadiness||h({flowVersion:1,onboardingSessionId:p,event:`run.requested`,origin:`dashboard_setup`,result:`rejected`,providerCountBucket:lr(A.runnableProviderCount),queryCountBucket:lr(ot),reasonCode:Zt(e,`run_rejected`)})}finally{Le(!1)}},Ct=()=>I(e=>u?2:Math.max(0,e-1)),wt=(e,t,n)=>{h({flowVersion:1,onboardingSessionId:p,event:`onboarding.step_completed`,step:e,method:`existing`,...n===void 0?{}:{countBucket:lr(n)}},`onboarding.step_completed:${e}`),I(t)},Tt=()=>{h({flowVersion:1,onboardingSessionId:p,event:`onboarding.step_completed`,step:`queries`,method:`skipped`,countBucket:`0`},`onboarding.step_completed:queries`),u?ye():I(3)},Et=()=>{h({flowVersion:1,onboardingSessionId:p,event:`onboarding.step_completed`,step:`competitors`,method:`skipped`,countBucket:`0`},`onboarding.step_completed:competitors`),I(4)},Dt=u?`section`:Ri,Ot=u?ve:Ct,kt=u&&F===2||F===4&&(A.showProviderConfig||A.providerReadiness!==!0)?(0,Z.jsx)(Tp,{engines:A,headingLevel:`h2`,separated:!0}):null,At=(()=>{switch(F){case 0:return(0,Z.jsxs)(Ri,{className:`surface-card step-card`,children:[(0,Z.jsx)(`div`,{className:`section-head`,children:(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h2`,{children:`System check`})})}),(0,Z.jsx)(`p`,{className:`supporting-copy`,children:`Checking that your Canonry instance is configured and reachable.`}),(0,Z.jsx)(`div`,{className:`compact-stack`,children:l.healthChecks.map(e=>(0,Z.jsxs)(`div`,{className:`health-check-row`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`run-row-title`,children:e.label}),(0,Z.jsx)(`p`,{className:`supporting-copy`,children:e.id===`provider`&&A.openRouterConnected?`OpenRouter connected. Choose models before your first check.`:e.detail}),e.id===`provider`&&e.state!==`ready`&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,Z.jsxs)(`p`,{className:`text-copy-13 text-secondary`,children:[`Connect Gemini with a key from`,` `,(0,Z.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`}),`.`]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`password`,"aria-label":`Gemini API key`,autoComplete:`new-password`,value:Ze,onChange:e=>Qe(e.target.value),placeholder:`AI… (paste here)`,className:`flex-1 rounded-md border border-base bg-bg px-2.5 py-1.5 text-label-14-mono text-heading placeholder:text-faint focus:border-mono-600 focus:outline-none`,disabled:$e}),(0,Z.jsx)(Y,{type:`button`,size:`sm`,disabled:$e||!Ze.trim(),onClick:Xr(xt),children:$e?`Saving…`:`Save`})]}),tt&&(0,Z.jsxs)(`div`,{role:`alert`,className:`space-y-1 text-label-12 text-negative`,children:[(0,Z.jsx)(`p`,{children:tt}),(0,Z.jsx)(`p`,{children:`Check that the key is complete, then retry Save.`})]}),(0,Z.jsxs)(`p`,{className:`text-copy-14 text-secondary`,children:[`Connect more answer engines later in`,` `,(0,Z.jsx)(W,{to:`/settings`,className:`text-link hover:underline`,children:`Settings`}),`.`]}),o.providerStatuses.some(e=>e.name===`openrouter`)&&(0,Z.jsxs)(`details`,{children:[(0,Z.jsx)(`summary`,{className:`min-h-11 cursor-pointer py-3 text-label-14 text-link`,children:`Connect OpenRouter`}),(0,Z.jsx)(pp,{providerName:`openrouter`,compact:!0,keyUrl:o.providerStatuses.find(e=>e.name===`openrouter`)?.keyUrl,onSaved:()=>{r()}})]})]})]}),(0,Z.jsx)(br,{tone:e.state===`ready`?e.id===`provider`?A.connectionStatus.tone:`positive`:`caution`,title:e.id===`api`?lu(c.apiStatus):e.id===`worker`?lu(c.workerStatus):e.detail,children:e.state===`ready`?e.id===`provider`?A.connectionStatus.label:`Ready`:`Attention`})]},e.id))}),(0,Z.jsxs)(`div`,{className:`setup-nav`,children:[l.launchState.blockedReason?(0,Z.jsx)(`p`,{role:`status`,className:`supporting-copy text-negative`,children:l.launchState.blockedReason}):(0,Z.jsx)(`span`,{}),(0,Z.jsx)(Y,{type:`button`,disabled:!j,title:l.launchState.blockedReason,onClick:()=>{h({flowVersion:1,onboardingSessionId:p,event:`onboarding.step_completed`,step:`system`,method:`automatic`},`onboarding.step_completed:system`),I(N)},children:`Continue`})]})]});case 1:return(0,Z.jsxs)(Ri,{className:`surface-card step-card`,children:[(0,Z.jsxs)(`div`,{className:`section-head`,children:[(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h2`,{children:`Create project`})}),H?(0,Z.jsx)(br,{tone:`positive`,children:`Created`}):null]}),H?(0,Z.jsxs)(`div`,{className:`compact-stack`,children:[(0,Z.jsxs)(`p`,{className:`text-neutral`,children:[`Project `,(0,Z.jsx)(`span`,{className:`text-heading text-label-14-strong`,children:H}),` created successfully.`]}),(0,Z.jsxs)(`div`,{className:`setup-nav`,children:[(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:Ct,children:`Back`}),(0,Z.jsx)(Y,{type:`button`,onClick:()=>wt(`project`,2),children:`Continue`})]})]}):(0,Z.jsxs)(`div`,{className:`compact-stack`,children:[(0,Z.jsxs)(`div`,{className:`setup-field`,children:[(0,Z.jsx)(`label`,{className:`setup-label`,htmlFor:`project-name`,children:`Project name`}),(0,Z.jsx)(`input`,{id:`project-name`,className:`setup-input`,type:`text`,placeholder:`my-website`,value:re,onChange:e=>ie(e.target.value)}),it&&it!==re?(0,Z.jsxs)(`p`,{className:`supporting-copy`,children:[`Slug: `,it]}):null]}),(0,Z.jsxs)(`div`,{className:`setup-field`,children:[(0,Z.jsx)(`label`,{className:`setup-label`,htmlFor:`display-name`,children:`Display name (optional)`}),(0,Z.jsx)(`input`,{id:`display-name`,className:`setup-input`,type:`text`,placeholder:`My Website`,value:ae,onChange:e=>oe(e.target.value)})]}),(0,Z.jsxs)(`div`,{className:`setup-field`,children:[(0,Z.jsx)(`label`,{className:`setup-label`,htmlFor:`domain`,children:`Canonical domain`}),(0,Z.jsx)(`input`,{id:`domain`,className:`setup-input`,type:`text`,placeholder:`example.com`,value:se,onChange:e=>ce(e.target.value)})]}),(0,Z.jsxs)(`div`,{className:`setup-field-row`,children:[(0,Z.jsxs)(`div`,{className:`setup-field`,children:[(0,Z.jsx)(`label`,{className:`setup-label`,htmlFor:`country`,children:`Country`}),(0,Z.jsx)(`input`,{id:`country`,className:`setup-input`,type:`text`,placeholder:`US`,maxLength:2,value:B,onChange:e=>V(e.target.value.toUpperCase())})]}),(0,Z.jsxs)(`div`,{className:`setup-field`,children:[(0,Z.jsx)(`label`,{className:`setup-label`,htmlFor:`language`,children:`Language`}),(0,Z.jsx)(`input`,{id:`language`,className:`setup-input`,type:`text`,placeholder:`en`,maxLength:5,value:le,onChange:e=>ue(e.target.value.toLowerCase())})]})]}),(0,Z.jsxs)(`details`,{children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer py-2 text-label-14 text-link`,children:`Backlink tracking`}),(0,Z.jsxs)(`label`,{className:`flex items-start gap-3 py-3 cursor-pointer`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 h-4 w-4 rounded border-strong bg-bg`,checked:de,onChange:e=>fe(e.target.checked)}),(0,Z.jsxs)(`span`,{className:`flex-1`,children:[(0,Z.jsx)(`span`,{className:`block text-label-14 text-heading`,children:`Auto-extract backlinks`}),(0,Z.jsxs)(`span`,{className:`block text-label-12 text-muted mt-0.5`,children:[`When a new Common Crawl release syncs, automatically extract backlinks for this project.`,` `,(0,Z.jsx)(W,{to:`/backlinks`,className:`text-positive-400 hover:text-positive underline underline-offset-2`,children:`Manage backlinks`})]})]})]})]}),me?(0,Z.jsx)(`p`,{className:`text-negative-400 text-copy-14`,children:me}):null,(0,Z.jsxs)(`div`,{className:`setup-nav`,children:[(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:Ct,children:`Back`}),(0,Z.jsx)(Y,{type:`button`,disabled:!it||!se||ge,onClick:Xr(yt),children:ge?`Creating…`:`Create project`})]})]})]});case 2:return(0,Z.jsx)(Dt,{className:u?`visibility-setup-section step-card`:`surface-card step-card`,"aria-labelledby":`setup-queries-heading`,children:(0,Z.jsx)(jp,{queries:xe,headingLevel:`h2`,loading:ne,loadFailed:b.isError,onRetryLoad:()=>{b.refetch()},onBack:Ot,skipAction:(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,onClick:Tt,children:u?`Finish without AI Visibility`:`Skip for now`}),saveVariant:A.providerFormVisible?`secondary`:`default`})});case 3:return(0,Z.jsxs)(Ri,{className:`surface-card step-card`,children:[(0,Z.jsxs)(`div`,{className:`section-head`,children:[(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`h2`,{children:`Add competitors`})}),we?(0,Z.jsx)(br,{tone:`positive`,children:`Saved`}):null]}),(0,Z.jsx)(`p`,{className:`supporting-copy`,children:`Optional. Domains that compete for the same queries, one per line. You can add them later from the project.`}),we?(0,Z.jsxs)(`div`,{className:`compact-stack`,children:[(0,Z.jsx)(`ul`,{className:`detail-list`,children:at.map(e=>(0,Z.jsx)(`li`,{children:e},e))}),(0,Z.jsxs)(`div`,{className:`setup-nav`,children:[(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:Ct,children:`Back`}),(0,Z.jsx)(Y,{type:`button`,onClick:()=>wt(`competitors`,4,at.length),children:`Continue`})]})]}):(0,Z.jsxs)(`div`,{className:`compact-stack`,children:[(0,Z.jsxs)(`div`,{className:`setup-field`,children:[(0,Z.jsx)(`label`,{className:`setup-label`,htmlFor:`competitors`,children:`Competitor domains (one per line)`}),(0,Z.jsx)(`textarea`,{id:`competitors`,className:`setup-textarea text-copy-14`,rows:4,placeholder:`competitor1.com
41
41
  competitor2.com`,value:Se,onChange:e=>Ce(e.target.value)})]}),De?(0,Z.jsx)(`p`,{className:`text-negative-400 text-copy-14`,children:De}):null,(0,Z.jsxs)(`div`,{className:`setup-nav`,children:[(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:Ct,children:`Back`}),(0,Z.jsx)(`div`,{className:`flex gap-2`,children:at.length===0?(0,Z.jsx)(Y,{type:`button`,onClick:Et,children:`Continue without competitors`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:Et,children:`Skip`}),(0,Z.jsx)(Y,{type:`button`,disabled:ke,onClick:Xr(bt),children:ke?`Saving…`:`Save ${at.length} competitor${at.length===1?``:`s`}`})]})})]})]})]});case 4:{let e=Xe.data,t=U&&!e&&!!He,n=e?.status??(He===w?.id?w.status:void 0),r=n===`completed`||n===`partial`||n===`failed`||n===`cancelled`,i=e?.snapshots??[],a=e?.plannedAnswers??(e&&Je?.runId===e.id?Je.requestCount:null),o=vf(i,e=>x.find(t=>t.id===e)?.queryClass),c=ae||H||`your brand`,l=n?rm(n,i.length):!1,d=ze??(e?.error?Br(e.error):n===`cancelled`?`The check was cancelled before it produced a baseline.`:(n===`completed`||n===`partial`)&&i.length===0?`The check finished without saving any engine results.`:w?.statusDetail||`The check did not produce a baseline.`),f=null;return vt||l?f=(0,Z.jsx)(br,{tone:`positive`,children:`Complete`}):ze&&!U?f=(0,Z.jsx)(br,{tone:`negative`,children:`Failed`}):t?f=(0,Z.jsx)(br,{tone:`neutral`,children:Xe.isError?`Unavailable`:`Loading`}):r?f=(0,Z.jsx)(br,{tone:`negative`,children:n===`cancelled`?`Cancelled`:`Failed`}):U&&(f=(0,Z.jsx)(br,{tone:`caution`,children:n===on.queued?`Queued`:`Running`})),(0,Z.jsxs)(Ri,{className:`surface-card step-card`,children:[(0,Z.jsxs)(`div`,{className:`section-head`,children:[(0,Z.jsx)(`div`,{children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`h2`,{children:l?`Saved answers`:Wn()?`AI Visibility`:U?`Your first AI Visibility check`:`Run your first AI Visibility check`}),l||Wn()?null:(0,Z.jsx)(Pi,{text:Dp(c,qe)})]})}),f]}),vt?(0,Z.jsxs)(`div`,{className:`compact-stack`,children:[(0,Z.jsxs)(`p`,{className:`text-secondary`,children:[(0,Z.jsx)(`span`,{className:`text-strong text-label-14-strong`,children:H}),` has saved AI Visibility results.`]}),(0,Z.jsxs)(`div`,{className:`setup-nav`,children:[(0,Z.jsx)(`span`,{}),(0,Z.jsx)(Y,{type:`button`,onClick:()=>ye(),children:`Open project dashboard →`})]})]}):!U&&Wn()?(0,Z.jsx)(Ap,{projectName:H,error:ze,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{}),(0,Z.jsx)(Y,{type:`button`,onClick:()=>ye(),children:`Open project dashboard →`})]})}):U?t?(0,Z.jsxs)(`div`,{className:`compact-stack`,children:[(0,Z.jsx)(`p`,{role:Xe.isError?`alert`:`status`,className:`text-copy-14 text-secondary`,children:Xe.isError?`Could not load the saved check. Try again to see its result.`:`Loading saved check…`}),(0,Z.jsxs)(`div`,{className:`setup-nav`,children:[(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,onClick:()=>ye(),children:`Open project dashboard →`}),Xe.isError?(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:()=>{Xe.refetch()},children:`Retry status check`}):null]})]}):r?l?(0,Z.jsxs)(`div`,{className:`compact-stack`,children:[(0,Z.jsxs)(`p`,{className:`text-copy-14 text-secondary`,children:[(0,Z.jsx)(`span`,{className:`text-label-14-strong text-heading`,children:ae||H}),` · `,i.length,` `,i.length===1?`answer`:`answers`]}),(0,Z.jsx)(Sf,{byClass:e?.queryCountsByClass,pooled:e?.queryCounts}),o?(0,Z.jsx)(`section`,{className:`mt-3 border-t border-default pt-4`,"aria-label":`Your first saved answer`,children:(0,Z.jsx)(Cf,{answer:o})}):null,H?(0,Z.jsxs)(`details`,{children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer py-2 text-label-14 text-link`,children:`More setup options`}),(0,Z.jsx)(hf,{projectName:H})]}):null,(0,Z.jsxs)(`div`,{className:`setup-nav`,children:[(0,Z.jsx)(`span`,{}),(0,Z.jsx)(Y,{type:`button`,onClick:()=>ye(),children:`Open project dashboard →`})]})]}):(0,Z.jsxs)(`div`,{className:`compact-stack`,children:[(0,Z.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-negative bg-negative-soft p-3 text-label-14 text-negative`,children:[(0,Z.jsx)(`p`,{children:d}),(0,Z.jsx)(`p`,{className:`mt-1 text-copy-13 text-secondary`,children:Wn()?Tc:s?`Review the connection, then retry.`:`Ask an administrator to review the provider and query configuration.`})]}),Ke.isError&&!Wn()?(0,Z.jsx)(pf,{preview:Ke.data,pending:Ke.isFetching,failed:!0,onRetry:()=>{Ke.refetch()}}):null,(0,Z.jsxs)(`div`,{className:`setup-nav`,children:[s&&!Wn()?(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:A.repairConnection,children:`Repair connection`}):(0,Z.jsx)(`span`,{}),Wn()||!s?(0,Z.jsx)(Y,{type:`button`,onClick:()=>ye(),children:`Open project dashboard →`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,onClick:()=>ye(),children:`Open project dashboard →`}),(0,Z.jsx)(Y,{type:`button`,disabled:Ie||!!ut||Ke.isError||Ke.isFetching||Ke.data?.canStart!==!0,onClick:Xr(St),children:Ie?`Retrying…`:`Retry check`})]})]})]}):(0,Z.jsxs)(`div`,{className:`space-y-5`,children:[(0,Z.jsx)(gf,{label:`AI Visibility check progress`,noun:`check`,phase:e?.startedAt?`Asking engines`:`Waiting to start`,count:e?a!==null&&i.length<=a?`${i.length} of ${a} ${a===1?`answer`:`answers`} saved`:`${i.length} ${i.length===1?`answer`:`answers`} saved`:null,done:e?i.length:null,total:a,startedAt:e?.startedAt,queuedAt:e?.createdAt}),Object.entries(e?.providerFailures??{}).map(([e,t])=>(0,Z.jsxs)(`div`,{role:`status`,className:`rounded-md border border-caution px-3 py-2`,children:[(0,Z.jsxs)(`p`,{className:`text-copy-14 text-primary`,children:[Pr(e),`: `,t.failedQueries,` `,t.failedQueries===1?`query`:`queries`,` failed`,t.stopped?`, so this check stopped asking it`:``,`.`]}),(0,Z.jsxs)(`details`,{className:`mt-1`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer text-label-13 text-secondary`,children:`Engine message`}),(0,Z.jsx)(`p`,{className:`mt-1 break-words text-copy-13 text-secondary`,children:t.message})]})]},e)),Xe.isError&&(0,Z.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-negative bg-negative-soft p-3 text-label-14 text-negative`,children:[(0,Z.jsx)(`p`,{children:Xe.error instanceof Error?Xe.error.message:`Could not refresh the check status.`}),(0,Z.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,className:`mt-2`,onClick:()=>{Xe.refetch()},children:`Retry status check`})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,onClick:()=>ye(),children:`Open project dashboard →`})})]}):(0,Z.jsx)(kp,{preview:Ke,details:[{label:`Website`,value:se},{label:`Market`,value:pt(B,le)}],queries:x,usesAccount:qe,alert:ze??ut??null,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:Ct,children:`Back`}),(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,onClick:ye,children:`Finish without running`}),st===`no_provider`&&!u?(0,Z.jsx)(Y,{type:`button`,onClick:()=>A.setShowProviderConfig(!0),children:`Connect an AI engine`}):(0,Z.jsx)(Y,{type:`button`,disabled:Ie||!!ut||Ke.isError||Ke.isFetching||Ke.data?.canStart!==!0,title:ut,onClick:Xr(St),children:Ie?`Starting…`:ze?`Retry check`:`Run check`})]})})]})}default:return null}})(),jt=u?nm:tm,Mt=F===4&&(_t||vt)?jt.length:u?+(F===4):F,Pt=F===4&&!U?(0,Z.jsx)(Ep,{engines:A}):null;return(0,Z.jsxs)(`div`,{className:u?`page-container visibility-setup`:`page-container`,children:[(0,Z.jsxs)(`div`,{className:`page-header`,children:[(0,Z.jsxs)(`div`,{className:`page-header-left`,children:[(0,Z.jsx)(`h1`,{ref:i?a:void 0,tabIndex:i?-1:void 0,className:`page-title outline-none`,children:_t?`Your first AI Visibility result`:i?`Set up AI Visibility`:`Setup`}),!_t&&!(F===4&&U)?(0,Z.jsx)(`p`,{className:`page-subtitle`,children:i?F===4?`Review the queries and engines for your first check.`:A.providerReadiness===!0?`Choose the queries you want to track.`:`Connect an AI engine and add the queries you want to track.`:`Create a project and run its first AI Visibility check.`}):null]}),!_t&&F!==4?(0,Z.jsx)(`div`,{className:`page-header-right`,children:(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,disabled:!!y&&!b.isSuccess||ge||xe.saving||ke||Ie,onClick:je,children:`Reset unsaved fields`})}):null]}),(0,Z.jsx)(sm,{current:Mt,labels:jt}),(0,Z.jsxs)(`section`,{className:`setup-wizard`,children:[kt,Pt,(0,Z.jsx)(`div`,{ref:L,children:At})]}),A.providerGuard.dialog]})}var dm=[{id:`engine`,label:`AI engine`},{id:`queries`,label:`Queries`},{id:`first-check`,label:`First check`}];function fm({current:e,done:t,hasBaseline:n}){return(0,Z.jsx)(`ol`,{"aria-label":`AI Visibility steps`,className:`mb-4 flex flex-wrap items-center gap-x-2 gap-y-1 text-label-14 text-secondary`,children:dm.map((r,i)=>{let a=r.id===e,o=!a&&t[r.id];return(0,Z.jsxs)(`li`,{"aria-current":a?`step`:void 0,className:a?`inline-flex items-center gap-1.5 text-heading`:`inline-flex items-center gap-1.5`,children:[i>0?(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`·`}):null,o?(0,Z.jsx)(ne,{className:`size-3.5 text-positive`,"aria-hidden":`true`}):(0,Z.jsx)(`span`,{className:`tabular-nums`,"aria-hidden":`true`,children:i+1}),r.id===`first-check`&&n?`Check`:r.label,o?(0,Z.jsx)(`span`,{className:`sr-only`,children:`, done`}):null]},r.id)})})}function pm(e){let t=Vs(),{isAdmin:n}=Jr(),r=G({...wi({client:q}),enabled:!t}),i=G({...vi({client:q}),enabled:!t&&n}),a=Zs(!t,t?.health),o=(0,X.useMemo)(()=>zs(i.data??null),[i.data]),{refetch:s}=r,{refetch:c}=i;return{project:t?t.dashboard.projects.find(t=>t.project.name===e)?.project??null:r.data?.find(t=>t.name===e)??null,settings:t?.dashboard.settings??o,health:a.data??t?.health??su,loading:!t&&(r.isPending||n&&i.isPending),failed:!t&&r.isError,refresh:async()=>{await Promise.all([s(),...n?[c()]:[]])}}}function mm({projectName:e,initialStep:t,hasBaseline:n=!1,onClose:r,onLaunched:i}){let a=pm(e);return a.loading?(0,Z.jsx)(`p`,{role:`status`,className:`text-copy-14 text-secondary`,children:`Loading AI engines and queries…`}):a.project?(0,Z.jsx)(hm,{project:a.project,settings:a.settings,health:a.health,refresh:a.refresh,initialStep:t,hasBaseline:n,onClose:r,onLaunched:i},e):(0,Z.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-caution px-3 py-2`,children:[(0,Z.jsx)(`p`,{className:`text-copy-14 text-primary`,children:a.failed?`Canonry could not load the project list.`:(0,Z.jsxs)(Z.Fragment,{children:[`Canonry could not find `,e,` in the project list.`]})}),(0,Z.jsx)(Y,{type:`button`,variant:`secondary`,size:`sm`,className:`mt-2`,onClick:()=>{a.refresh()},children:`Retry`})]})}function hm({project:e,settings:t,health:n,refresh:r,initialStep:i,hasBaseline:a,onClose:o,onLaunched:s}){let c=e.name,l=Te(),u=be(),d=qd(`wizard`),f=G({queryKey:Yp(c),queryFn:()=>Nt(c)}),p=f.data,m=p?.length??0,h=(p??[]).map(e=>e.query).join(`
42
42
  `),g=`wizard:${c}`,[_]=(0,X.useState)(()=>Wd(g)),[v,y]=(0,X.useState)(i),[b,x]=(0,X.useState)(!f.isPending),S=Mp({settings:t,project:e,projectScoped:!0,refresh:r}),C=em({projectName:c,initialText:_.queriesText??h,initialSaved:_.queriesText===void 0&&m>0,generateProviders:S.runnableApiProviders,research:{projectName:c,domain:e.canonicalDomain},telemetry:d,refreshAfterSave:e=>Xp(u,e),onContinue:()=>y(`first-check`)}),{setText:w,setSaved:T}=C;(0,X.useEffect)(()=>{b||f.isPending||(p&&p.length>0&&_.queriesText===void 0&&(w(p.map(e=>e.query).join(`
43
- `)),T(!0)),x(!0))},[_.queriesText,b,p,f.isPending,T,w]),(0,X.useEffect)(()=>{b&&Gd(g,{...!C.saved&&C.text!==h?{queriesText:C.text}:{},..._.competitorsText===void 0?{}:{competitorsText:_.competitorsText}})},[_.competitorsText,g,C.saved,C.text,b,h]);let{emit:E,onboardingSessionId:D}=d;(0,X.useEffect)(()=>{b&&E({flowVersion:1,onboardingSessionId:D,event:`onboarding.started`,step:i===`first-check`?`run`:`queries`,resumed:!0},`onboarding.started`)},[E,i,D,b]);let O=(0,X.useRef)(null),k=(0,X.useRef)(v);(0,X.useEffect)(()=>{if(k.current===v)return;k.current=v;let e=O.current?.querySelector(`h2, h3`);e&&(e.tabIndex=-1,e.focus())},[v]);let A=(0,X.useRef)(null),j=(0,X.useRef)(!0);(0,X.useEffect)(()=>{if(!j.current)return;let e=document.activeElement;if(e&&e!==document.body){j.current=!1;return}let t=A.current?.querySelector(`h3`);t&&(j.current=!1,t.tabIndex=-1,t.focus())});let M=Wn(),N=uf(c,v===`first-check`&&!M),ee=Op(N.data),{systemBlockReason:P,blockedReason:F}=Np(n,t,S),I=F??(f.isSuccess&&m===0?`Add at least one query before launching the first check.`:void 0),L=Hp(),[R,z]=(0,X.useState)(!1),[te,ne]=(0,X.useState)(null),re=e.displayName||c,ie=async()=>{if(!M&&!(N.isError||N.isFetching||N.data?.canStart!==!0)){if(I)ne(I),S.usesProjectProviderReadiness||E({flowVersion:1,onboardingSessionId:D,event:`run.requested`,origin:`dashboard_setup`,result:`rejected`,providerCountBucket:lr(S.runnableProviderCount),queryCountBucket:lr(m),reasonCode:P??(m===0?`no_queries`:`run_rejected`)});else{z(!0),ne(null);try{let e=await L.mutateAsync({projectName:c,projectLabel:re,sourceAction:`setup-launch`,suppressQueuedToast:!0});en(c,e.id,J[`answer-visibility`]),s(e.id),S.usesProjectProviderReadiness||E({flowVersion:1,onboardingSessionId:D,event:`run.requested`,origin:`dashboard_setup`,result:`queued`,providerCountBucket:lr(S.runnableProviderCount),queryCountBucket:lr(m)})}catch(e){ne(e instanceof Error?e.message:`Failed to queue the AI Visibility check. Retry when the instance is ready.`),S.usesProjectProviderReadiness||E({flowVersion:1,onboardingSessionId:D,event:`run.requested`,origin:`dashboard_setup`,result:`rejected`,providerCountBucket:lr(S.runnableProviderCount),queryCountBucket:lr(m),reasonCode:Zt(e,`run_rejected`)})}finally{z(!1)}}}},ae=S.isAdmin&&(S.providerFormVisible||S.inlineModelPicker),oe=S.providerReadiness===!1&&!te;return(0,Z.jsxs)(`div`,{ref:A,children:[(0,Z.jsx)(fm,{current:v,done:{engine:S.providerReadiness===!0,queries:m>0,"first-check":!1},hasBaseline:a}),(0,Z.jsx)(`div`,{ref:O,children:v===`engine`?(0,Z.jsxs)(`div`,{className:`space-y-5`,children:[(0,Z.jsx)(Tp,{engines:S,headingLevel:`h3`}),(0,Z.jsxs)(`div`,{className:`setup-nav`,children:[(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:()=>S.providerGuard.request(o),children:`Back`}),(0,Z.jsx)(Y,{type:`button`,variant:ae?`secondary`:`default`,onClick:()=>S.providerGuard.request(()=>{S.closeProviderForm(),y(`queries`)}),children:`Continue`})]})]}):v===`queries`?(0,Z.jsx)(`div`,{className:`space-y-3`,"aria-labelledby":`setup-queries-heading`,children:(0,Z.jsx)(jp,{queries:C,headingLevel:`h3`,loading:f.isPending||!b,loadFailed:f.isError,onRetryLoad:()=>{f.refetch()},onBack:()=>y(`engine`),note:(0,Z.jsxs)(`p`,{className:`text-copy-13 text-secondary`,children:[`Queries naming `,re,` are branded. Results keep branded and non-brand queries apart.`]}),saveVariant:`default`})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ep,{engines:S}),(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`div`,{className:`section-head`,children:(0,Z.jsx)(`div`,{children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-heading-16 text-heading`,children:M?`AI Visibility`:a?`Run an AI Visibility check`:`Run your first AI Visibility check`}),M?null:(0,Z.jsx)(Pi,{text:Dp(re,ee)})]})})}),M?(0,Z.jsx)(Ap,{projectName:c,error:te,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{}),(0,Z.jsx)(Y,{type:`button`,onClick:()=>{l({to:`/projects/$projectName`,params:{projectName:c},replace:!0})},children:`Open project dashboard →`})]})}):(0,Z.jsx)(kp,{preview:N,details:[{label:`Website`,value:e.canonicalDomain},{label:`Market`,value:pt(e.country,e.language)}],queries:p??[],usesAccount:ee,alert:oe?null:te??I??null,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:()=>y(`queries`),children:`Back`}),oe?(0,Z.jsx)(Y,{type:`button`,onClick:()=>y(`engine`),children:`Connect an AI engine`}):(0,Z.jsx)(Y,{type:`button`,disabled:R||!!I||N.isError||N.isFetching||N.data?.canStart!==!0,title:I,onClick:Xr(ie),children:R?`Starting…`:te?`Retry check`:a?`Run check`:`Run first check`})]})})]})]})}),S.providerGuard.dialog]})}var gm=`Public pages only, read by this Canonry server and stored with this project. The first scan reads up to 100 pages, then stops.`,_m=En.enum;function vm(e){return e===K.queued||e===K.running}function ym(e){return e===K.not_started||e===K.cancelled||e===K.failed}function bm(e,t,n){return`${e} ${e===1?t:n}`}function xm({projectName:e,firstRun:t,track:n}){let r=Te(),i=be(),{canWrite:a,isAdmin:o}=Jr(),s=G({...Ei({client:q,path:{name:e}}),retry:!1,refetchInterval:({state:e})=>{let t=e.data;return t&&(vm(t.tracks.agentReadiness.state)||vm(t.tracks.aiVisibility.state))?3e3:!t?.complete&&15e3}}),c=G({...ui({client:q,path:{name:e}}),retry:!1}),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)(null),p=(0,X.useRef)(null),m=(0,X.useRef)(!1),h=s.data?.tracks.aiVisibility;(0,X.useEffect)(()=>{h&&(vm(h.state)?(m.current=!0,u(null)):n===`ai-visibility`&&!m.current&&(m.current=!0,u(Am(h.blockedBy))))},[n,h]);let g=()=>i.invalidateQueries({queryKey:Oi({client:q,path:{name:e}})}),_=Sm(e,s.data);Cm(s.data);let v=s.isSuccess;(0,X.useEffect)(()=>{v&&p.current?.focus({preventScroll:!0})},[v]);let y=e=>{r({to:`/setup`,search:t=>({...t,track:e}),replace:!0})},b=e=>{u(e),y(`ai-visibility`)},x=()=>{u(null),y(void 0)};if(s.isPending)return(0,Z.jsx)(Tm,{});if(s.isError){let n=ro(s.error).code===`NOT_FOUND`;return(0,Z.jsxs)(`div`,{className:`page-container max-w-3xl`,children:[(0,Z.jsx)(`h1`,{className:`text-heading-24 text-heading`,children:t?`Set up Canonry`:`Project setup`}),(0,Z.jsxs)(`div`,{role:`alert`,className:`mt-6 rounded-md border border-negative bg-negative-soft p-4`,children:[(0,Z.jsx)(`p`,{className:`text-copy-14-strong text-heading`,children:n?`No project named ${e}.`:`Setup status could not be loaded.`}),(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:n?(0,Z.jsx)(Y,{asChild:!0,variant:`secondary`,size:`sm`,children:(0,Z.jsx)(W,{to:`/projects`,children:`View projects`})}):(0,Z.jsx)(Y,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>{s.refetch()},children:`Retry`})})]})]})}let S=s.data,C=c.data,w=S.project.displayName||S.project.name,T=Yt(S.project.canonicalDomain),E=C?pt(C.country,C.language):null,D=S.tracks.agentReadiness,O=S.tracks.aiVisibility,k=d!==null&&O.runId===d.listedRunId&&O.runId!==d.runId,A=a&&l!==null&&!vm(O.state),j=A||!a?null:ym(D.state)?`agent-readiness`:ym(O.state)&&!k?`ai-visibility`:null;return(0,Z.jsxs)(`div`,{className:`page-container max-w-3xl`,children:[(0,Z.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-x-4 gap-y-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h1`,{ref:p,tabIndex:-1,className:`text-heading-24 text-heading outline-none`,children:t?`Set up Canonry`:`Project setup`}),(0,Z.jsxs)(`p`,{className:`mt-1 text-copy-14 text-secondary`,children:[S.complete?`Setup complete · `:null,w,` · `,T]})]}),(0,Z.jsx)(Y,{asChild:!0,variant:S.complete?`default`:`ghost`,className:`shrink-0`,children:(0,Z.jsxs)(W,{to:`/projects/$projectName`,params:{projectName:e},children:[`Open project`,S.complete?null:(0,Z.jsx)(N,{className:`size-4`,"aria-hidden":`true`})]})})]}),(0,Z.jsxs)(Qd,{label:`Setup progress`,children:[(0,Z.jsx)($d,{id:`setup-website`,title:`Website`,mark:`done`,summary:E?`${T} · ${E}`:T,trailing:a?(0,Z.jsxs)(W,{className:`shrink-0 text-label-14 text-secondary underline underline-offset-4 hover:text-primary`,to:`/projects/$projectName/settings`,params:{projectName:e},children:[`Edit`,(0,Z.jsx)(`span`,{className:`sr-only`,children:` website`})]}):null}),(0,Z.jsx)(km,{projectName:e,projectId:C?.id??null,brand:w,track:D,primary:j===`agent-readiness`,canWrite:a,onStarted:async e=>{_(e,J[`site-audit`]),await g()},onCancelled:g}),(0,Z.jsx)(Mm,{projectName:e,brand:w,domain:T,track:O,panelStep:A?l:null,onOpenPanel:b,onClosePanel:x,starting:k,onLaunched:e=>{_(e,J[`answer-visibility`]),f({runId:e,listedRunId:O.runId}),x(),g()},onCancelled:g,primary:j===`ai-visibility`,canWrite:a,isAdmin:o})]}),(0,Z.jsx)(`p`,{role:`status`,className:`sr-only`,children:Em(D)}),(0,Z.jsx)(`p`,{role:`status`,className:`sr-only`,children:Dm(O,k?K.queued:O.state)}),S.complete?(0,Z.jsx)(hf,{projectName:e}):null]})}function Sm(e,t){let{emit:n,onboardingSessionId:r}=qd(`site_health`),{emit:i,onboardingSessionId:a}=qd(`wizard`),o=(0,X.useRef)(new Map);return(0,X.useEffect)(()=>{let t=Re(e);t?.kind&&o.current.set(t.runId,t.kind)},[e]),(0,X.useEffect)(()=>{if(!t)return;let e=[{...t.tracks.agentReadiness,kind:J[`site-audit`],answers:null},{...t.tracks.aiVisibility,kind:J[`answer-visibility`],answers:t.tracks.aiVisibility.result?.answers??null}];for(let{runId:t,state:s,kind:c,answers:l}of e){if(!t||o.current.get(t)!==c)continue;let e=c===J[`site-audit`]?{emit:n,onboardingSessionId:r}:{emit:i,onboardingSessionId:a},u=(s===K.completed||s===K.partial)&&l!==0,d=s===K.cancelled?`run_cancelled`:s===K.failed||(s===K.completed||s===K.partial)&&l===0?`run_failed`:null;if(u)e.emit({flowVersion:1,onboardingSessionId:e.onboardingSessionId,event:`onboarding.step_completed`,step:`run`,method:`automatic`,...l===null?{}:{countBucket:lr(l)}},`onboarding.step_completed:run:${t}`);else if(d)e.emit({flowVersion:1,onboardingSessionId:e.onboardingSessionId,event:`onboarding.blocked`,step:`run`,action:`retry_run`,reasonCode:d},`onboarding.blocked:run:${t}:${d}`);else continue;o.current.delete(t),lt(t)}},[a,i,n,r,t]),(t,i)=>{o.current.set(t,i),i===J[`site-audit`]&&(en(e,t,i),n({flowVersion:1,onboardingSessionId:r,event:`onboarding.started`,step:`run`,resumed:!1},`onboarding.started:${t}`))}}function Cm(e){let t=be(),n=e?.tracks.agentReadiness.state,r=e?.tracks.aiVisibility.state,i=(0,X.useRef)({});(0,X.useEffect)(()=>{let e=i.current;i.current={scan:n,check:r};let a=(e,t)=>e!==void 0&&t!==void 0&&vm(e)&&!vm(t);(a(e.scan,n)||a(e.check,r))&&t.invalidateQueries({queryKey:Mi({client:q})})},[n,r,t])}function wm({runIds:e,noun:t,note:n,onCancelled:r}){let[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(null),c=Fe({...yi({client:q}),meta:{skipGlobalErrorToast:!0}}),l=(0,X.useRef)(null),u=(0,X.useRef)(null),d=(0,X.useRef)(!1);(0,X.useEffect)(()=>{d.current&&(d.current=!1,(i?u:l).current?.focus())},[i]);let f=e=>{d.current=!0,s(null),a(e)},p=async()=>{if(c.isPending)return;s(null);let n=(await Promise.allSettled(e.map(e=>c.mutateAsync({path:{id:e}})))).find(e=>e.status===`rejected`&&ro(e.reason).code!==`RUN_NOT_CANCELLABLE`);n&&s(`The ${t} could not be stopped. ${dt(n.reason)}`),await r()};return i?(0,Z.jsxs)(`div`,{role:`group`,"aria-label":`Stop the ${t}`,className:`flex flex-wrap items-center justify-end gap-x-3 gap-y-2`,children:[(0,Z.jsxs)(`p`,{className:`text-copy-14 text-secondary`,children:[`Stop the `,t,`? `,n]}),(0,Z.jsxs)(`div`,{className:`flex gap-2 max-sm:w-full max-sm:[&>*]:flex-1`,children:[(0,Z.jsx)(Y,{ref:u,type:`button`,variant:`ghost`,"aria-disabled":c.isPending||void 0,onClick:()=>{c.isPending||f(!1)},children:`Keep running`}),(0,Z.jsx)(Y,{type:`button`,variant:`secondary`,"aria-disabled":c.isPending||void 0,onClick:()=>{p()},children:c.isPending?`Stopping…`:`Stop ${t}`})]}),o?(0,Z.jsx)(`p`,{role:`alert`,className:`w-full text-right text-copy-14 text-negative`,children:o}):null]}):(0,Z.jsxs)(Y,{ref:l,type:`button`,variant:`ghost`,"data-focus-skip":!0,onClick:()=>f(!0),children:[`Cancel `,t]})}function Tm(){return(0,Z.jsxs)(`div`,{className:`page-container max-w-3xl`,"aria-busy":`true`,children:[(0,Z.jsx)(`div`,{className:`skeleton-text h-6 w-40`}),(0,Z.jsx)(`div`,{className:`skeleton-text-sm mt-2 w-56`}),(0,Z.jsx)(`div`,{className:`material-base mt-6 space-y-6 p-5`,children:[1,2,3].map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`div`,{className:`skeleton-text w-32`}),(0,Z.jsx)(`div`,{className:`skeleton-text-sm w-64`})]}),(0,Z.jsx)(`div`,{className:`skeleton h-5 w-20 rounded-md`})]},e))})]})}function Em(e){switch(e.state){case K.not_started:return``;case K.queued:return`Agent Readiness audit scan queued.`;case K.running:return`Agent Readiness audit scan running.`;case K.completed:case K.partial:{let t=e.state===K.partial?`Agent Readiness audit scan stopped partway.`:`Agent Readiness audit scan complete.`,n=e.result?.score??null;return n===null?t:`${t} Score ${Math.round(n)} of 100.`}case K.failed:return`Agent Readiness audit scan failed.`;case K.cancelled:return`Agent Readiness audit scan cancelled.`;default:return e.state}}function Dm(e,t){switch(t){case K.not_started:return``;case K.queued:return`AI Visibility check queued.`;case K.running:return`AI Visibility check running.`;case K.completed:case K.partial:{let n=t===K.partial?`AI Visibility check stopped partway.`:`AI Visibility check complete.`,r=e.result;return r?`${n} ${bm(r.answers,`answer`,`answers`)} from ${bm(r.engines,`engine`,`engines`)}.`:n}case K.failed:return`AI Visibility check failed.`;case K.cancelled:return`AI Visibility check cancelled.`;default:return t}}function Om(e){let t=e.progress;if(!t)return{phase:e.state===K.queued?`Waiting to start`:`Starting the scan`,count:null,done:null,total:null};switch(t.phase){case _m.queued:return{phase:`Waiting to start`,count:null,done:null,total:null};case _m.discovering:return{phase:`Finding pages`,count:t.pagesFound===null?null:`${t.pagesFound} found`,done:null,total:null};case _m.checking:{let e=t.pagesFound,n=t.pageLimit;return e!==null&&(n===null||e<n)?{phase:`Checking pages`,count:`${t.pagesChecked} of ${e}`,done:t.pagesChecked,total:e}:{phase:`Checking pages`,count:n===null?`${t.pagesChecked} checked`:`${t.pagesChecked} of up to ${n}`,done:t.pagesChecked,total:n}}case _m[`arranging-map`]:return{phase:`Building the score`,count:bm(t.pagesChecked,`page checked`,`pages checked`),done:null,total:null};case _m.completed:case _m.partial:case _m.failed:case _m.cancelled:return{phase:`Finishing`,count:null,done:null,total:null};default:return t.phase}}function km({projectName:e,projectId:t,brand:n,track:r,primary:i,canWrite:a,onStarted:o,onCancelled:s}){let c=Wp(),{onboardingSessionId:l,emit:u}=qd(`platform`),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(!1),h=r.state,g=async()=>{if(t&&!p){f(null),m(!0);try{let r=await c.mutateAsync({projectName:e,projectId:t,projectLabel:n,suppressErrorToast:!0,suppressQueuedToast:!0,body:{checkDeadLinks:!0,maxPages:100,sites:[]}});u({flowVersion:1,onboardingSessionId:l,event:`run.requested`,origin:`dashboard_setup`,result:`queued`,kind:`site_health`,providerCountBucket:`0`,queryCountBucket:`0`}),await o(r.runId)}catch(e){f(`The audit scan could not start. ${dt(e)}`),u({flowVersion:1,onboardingSessionId:l,event:`run.requested`,origin:`dashboard_setup`,result:`rejected`,kind:`site_health`,providerCountBucket:`0`,queryCountBucket:`0`,reasonCode:Zt(e,`run_rejected`)})}finally{m(!1)}}},_=e=>a?(0,Z.jsx)(Y,{type:`button`,variant:i?`default`:`secondary`,disabled:!t,"aria-disabled":p||void 0,className:p?`opacity-50`:void 0,onClick:()=>{g()},children:p?`Starting…`:e}):null,v=null,y=null,b=null;switch(h){case K.not_started:case K.cancelled:v=(0,Z.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-1.5`,children:[h===K.cancelled?`The last scan was cancelled. `:null,`Reads up to `,100,` public pages. No AI engine needed.`,(0,Z.jsx)(Pi,{text:gm})]}),b=_(h===K.cancelled?`Run audit scan again`:`Run audit scan`);break;case K.queued:case K.running:{let e=Om(r),t=r.progress;y=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(gf,{label:`Agent Readiness audit scan progress`,noun:`scan`,phase:e.phase,count:e.count,done:e.done,total:e.total,startedAt:r.startedAt}),t?(0,Z.jsxs)(`details`,{className:`mt-2`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer py-1 text-label-14 text-secondary`,children:`Scan details`}),(0,Z.jsx)(`dl`,{className:`mt-2 grid grid-cols-2 gap-x-6 gap-y-3 sm:grid-cols-4`,children:[[`Pages found`,t.pagesFound],[`Pages checked`,t.pagesChecked],[`Links found`,t.linksFound],[`Pages failed`,t.pagesFailed]].map(([e,t])=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-label-13 text-secondary`,children:e}),(0,Z.jsx)(`dd`,{className:`text-label-14-strong tabular-nums text-heading`,children:t===null?`Unavailable`:t.toLocaleString()})]},e))})]}):null]}),b=a&&r.runId?(0,Z.jsx)(wm,{runIds:[r.runId],noun:`scan`,note:`It saves no score.`,onCancelled:s},r.runId):null;break}case K.completed:case K.partial:{let t=r.result;v=h===K.partial?`The scan stopped before it reached every page.`:null,y=t?(0,Z.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`text-heading-20 tabular-nums text-heading`,children:t.score===null?`–`:Math.round(t.score)}),(0,Z.jsxs)(`span`,{className:`text-label-14 text-secondary`,children:[t.score===null?`Score unavailable`:h===K.partial?`of 100 so far`:`of 100`,` · `,bm(t.pagesScored,`page scored`,`pages scored`)]})]}):(0,Z.jsx)(`p`,{className:`text-copy-14 text-secondary`,children:`The scan finished.`}),b=(0,Z.jsx)(Y,{asChild:!0,variant:`ghost`,children:(0,Z.jsxs)(W,{to:`/projects/$projectName/agent-readiness`,params:{projectName:e},children:[`Open Agent Readiness`,(0,Z.jsx)(N,{className:`size-4`,"aria-hidden":`true`})]})});break}case K.failed:v=`The scan did not finish.${r.error?` ${r.error}`:``}`,b=_(`Run audit scan again`);break;default:return h}return(0,Z.jsxs)($d,{id:`setup-agent-readiness`,title:`Agent Readiness`,mark:Xd(h),summary:v,trailing:(0,Z.jsx)(Yd,{state:h}),action:b,children:[y,d?(0,Z.jsx)(`p`,{role:`alert`,className:`${y?`mt-3 `:``}text-copy-14 text-negative`,children:d}):null]})}function Am(e){switch(e){case null:return`first-check`;case Dr.no_engine:case Dr.engines_failing:return`engine`;case Dr.no_queries:return`queries`;case Dr.plan_unpublished:return null;default:return e}}function jm(e,t,n){let r=`Whether AI answers mention ${t} and cite ${n}.`,i=e.baselineRunId===null;switch(e.blockedBy){case Dr.no_engine:return{line:`${r} Needs an AI engine.`,action:`Connect an AI engine`,step:`engine`};case Dr.no_queries:return{line:`${r} Add queries to check.`,action:`Add queries`,step:`queries`};case Dr.plan_unpublished:return{line:`Publish the measurement plan before the ${i?`first`:`next`} check.`,action:`Open measurement plan`,step:`plan`};case Dr.engines_failing:return{line:`${r} The AI engine connection needs attention.`,action:`Repair connection`,step:`engine`};case null:{let t=e.engines.length;return{line:`Asks ${bm(t,`engine`,`engines`)} your ${bm(e.queries.total,`query`,`queries`)}.`,action:i?`Review first check`:`Review check`,step:`first-check`}}default:return e.blockedBy}}function Mm({projectName:e,brand:t,domain:n,track:r,panelStep:i,onOpenPanel:a,onClosePanel:o,onLaunched:s,onCancelled:c,starting:l,primary:u,canWrite:d,isAdmin:f}){let p=l?K.queued:r.state,m=u?`default`:`secondary`;if(i!==null)return(0,Z.jsx)($d,{id:`setup-ai-visibility`,title:`AI Visibility`,mark:Xd(p),trailing:(0,Z.jsx)(Yd,{state:p}),childrenManageFocus:!0,children:(0,Z.jsx)(mm,{projectName:e,initialStep:i,hasBaseline:r.baselineRunId!==null,onClose:o,onLaunched:s})});let h=null,g=null,_=null;switch(p){case K.not_started:case K.cancelled:{let i=jm(r,t,n);if(h=p===K.cancelled?`The last check was cancelled. ${i.line}`:i.line,d){let t=i.step;_=t===`plan`?(0,Z.jsx)(Y,{asChild:!0,variant:m,children:(0,Z.jsx)(W,{to:`/projects/$projectName/portfolio`,params:{projectName:e},children:i.action})}):(0,Z.jsx)(Y,{type:`button`,variant:m,onClick:()=>a(t),children:i.action})}break}case K.queued:case K.running:{let e=r.progress,t=e?e.answersPlanned!==null&&e.answersSaved<=e.answersPlanned?`${e.answersSaved} of ${bm(e.answersPlanned,`answer`,`answers`)} saved`:`${bm(e.answersSaved,`answer`,`answers`)} saved`:null;g=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(gf,{label:`AI Visibility check progress`,noun:`check`,phase:p===K.queued?`Waiting to start`:`Asking engines`,count:t,done:e?.answersSaved??null,total:e?.answersPlanned??null,startedAt:r.startedAt}),Object.entries(r.providerFailures??{}).map(([e,t])=>(0,Z.jsxs)(`div`,{role:`status`,className:`mt-3 rounded-md border border-caution px-3 py-2`,children:[(0,Z.jsxs)(`p`,{className:`text-copy-14 text-primary`,children:[Pr(e),`: `,bm(t.failedQueries,`query`,`queries`),` failed`,t.stopped?`, so this check stopped asking it`:``,`.`]}),(0,Z.jsxs)(`details`,{className:`mt-1`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer text-label-13 text-secondary`,children:`Engine message`}),(0,Z.jsx)(`p`,{className:`mt-1 break-words text-copy-13 text-secondary`,children:t.message})]})]},e)),(0,Z.jsxs)(`details`,{className:`mt-2`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer py-1 text-label-14 text-secondary`,children:`Check details`}),(0,Z.jsxs)(`dl`,{className:`mt-2 grid gap-x-6 gap-y-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-label-13 text-secondary`,children:`Engines`}),(0,Z.jsx)(`dd`,{className:`text-label-14 text-heading`,children:r.engines.length>0?r.engines.map(e=>Pr(e)).join(`, `):`Unavailable`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-label-13 text-secondary`,children:`Queries`}),(0,Z.jsxs)(`dd`,{className:`text-label-14 tabular-nums text-heading`,children:[bm(r.queries.nonBrand,`non-brand`,`non-brand`),` · `,bm(r.queries.branded,`branded`,`branded`)]})]})]})]})]}),_=d&&!l&&r.runId?(0,Z.jsx)(wm,{runIds:r.runIds,noun:`check`,note:r.baselineRunId===null?`It saves no baseline.`:`Earlier results stay as they are.`,onCancelled:c},r.runId):null;break}case K.completed:case K.partial:{let t=r.result,n=r.runId!==null&&r.runId===r.baselineRunId;h=t?`${p===K.partial?`Partial results`:n?`Baseline`:`Latest check`} · ${bm(t.answers,`answer`,`answers`)} from ${bm(t.engines,`engine`,`engines`)}${r.finishedAt?` · ${Ur(r.finishedAt)}`:``}`:`The check finished.`,g=t?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Sf,{byClass:t.queryCountsByClass,pooled:t.queryCounts,caption:n?void 0:`Latest AI Visibility check by query class`}),n?(0,Z.jsx)(`p`,{className:`mt-3 text-copy-13 text-secondary`,children:`Later checks are compared with this baseline.`}):null,r.runId?(0,Z.jsx)(Nm,{runId:r.runId,projectName:e}):null]}):null,_=(0,Z.jsx)(Y,{asChild:!0,variant:`ghost`,children:(0,Z.jsxs)(W,{to:`/projects/$projectName`,params:{projectName:e},children:[`Open AI Visibility`,(0,Z.jsx)(N,{className:`size-4`,"aria-hidden":`true`})]})});break}case K.failed:{h=r.baselineRunId===null?`The check did not finish. No baseline was saved.`:`The check did not finish. Earlier results are unchanged.`;let e=f?null:(0,Z.jsx)(`p`,{className:`text-copy-14 text-secondary`,children:`Ask an administrator to check the AI engine connection.`}),t=r.failedEngines??[];g=t.length>0?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[t.map(e=>{let t=Pr(e.provider),n=Ke(e.code,Pr(xr(e.provider)));return(0,Z.jsx)(`div`,{className:`rounded-md border border-caution px-3 py-2`,children:n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`text-copy-14 text-primary`,children:n}),(0,Z.jsxs)(`details`,{className:`mt-1`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer text-label-13 text-secondary`,children:`Engine message`}),(0,Z.jsxs)(`p`,{className:`mt-1 break-words text-copy-13 text-secondary`,children:[t,`: `,e.message]})]})]}):(0,Z.jsxs)(`p`,{className:`break-words text-copy-14 text-primary`,children:[t,`: `,e.message]})},e.provider)}),e]}):r.error?(0,Z.jsxs)(`div`,{className:`rounded-md border border-caution px-3 py-2`,children:[(0,Z.jsx)(`p`,{className:`break-words text-copy-14 text-primary`,children:r.error}),e?(0,Z.jsx)(`div`,{className:`mt-1`,children:e}):null]}):null,d&&(_=(0,Z.jsxs)(Z.Fragment,{children:[f?(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,onClick:()=>a(`engine`),children:`Change AI engines`}):null,(0,Z.jsx)(Y,{type:`button`,variant:m,onClick:()=>a(`first-check`),children:`Run check again`})]}));break}default:return p}return(0,Z.jsx)($d,{id:`setup-ai-visibility`,title:`AI Visibility`,mark:Xd(p),summary:h,trailing:(0,Z.jsx)(Yd,{state:p}),action:_,children:g})}function Nm({runId:e,projectName:t}){let[n,r]=(0,X.useState)(!1),i=G({..._i({client:q,path:{id:e}}),enabled:n}),a=G({...fi({client:q,path:{name:t}}),enabled:n}),o=i.data?vf(i.data.snapshots??[],e=>a.data?.find(t=>t.id===e)?.queryClass):void 0;return(0,Z.jsxs)(`details`,{className:`mt-3`,onToggle:e=>r(e.currentTarget.open),children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer py-1 text-label-14 text-link`,children:`Example answer`}),(0,Z.jsx)(`div`,{className:`mt-3 border-t border-default pt-4`,children:i.isPending?(0,Z.jsx)(`p`,{role:`status`,className:`text-copy-14 text-secondary`,children:`Loading the answer…`}):i.isError?(0,Z.jsx)(`p`,{role:`alert`,className:`text-copy-14 text-negative`,children:`The answer could not be loaded.`}):o?(0,Z.jsx)(Cf,{answer:o}):(0,Z.jsx)(`p`,{className:`text-copy-14 text-secondary`,children:`This check saved no answer text.`})})]})}var Pm=`pointer-coarse:min-h-11 max-md:min-h-11`,Fm=`setup-input h-10 w-full max-md:text-label-16 ${Pm}`,Im=[{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`}],Lm=[{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 Rm(e,t){let n=e.trim().toUpperCase(),r=t.trim().toLowerCase();return{countryValid:Im.some(e=>e.value===n),languageValid:Lm.some(e=>e.value===r)}}function zm(e){let t=e.replace(/^\[|\]$/g,``);return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(t)||t.includes(`:`)}function Bm(e){let t=e.trim();if(!t)return null;let n=/^[a-z][a-z\d+.-]*:\/\//i.test(t)?t:`https://${t}`,r;try{r=new URL(n)}catch{return null}if(r.protocol!==`http:`&&r.protocol!==`https:`)return null;let i=r.hostname.toLowerCase().replace(/^www\./,``);if(!i||i===`localhost`||zm(i)||!i.includes(`.`))return null;let a=ht(i);return a?{canonicalDomain:i,projectName:a,displayName:Rt(i)}:null}function Vm(e,t){return e instanceof ir&&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:t}function Hm(){return(0,Z.jsxs)(`div`,{className:`page-container max-w-3xl`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,Z.jsx)(`div`,{className:`page-header`,children:(0,Z.jsxs)(`div`,{className:`page-header-left`,children:[(0,Z.jsx)(`h1`,{className:`page-title`,children:`Preparing setup`}),(0,Z.jsx)(`p`,{className:`page-subtitle`,children:`Checking the projects already on this install.`})]})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 material-base p-4 text-label-14 text-secondary`,role:`status`,children:[(0,Z.jsx)(s,{className:`size-4 motion-safe:animate-spin`,"aria-hidden":`true`}),`Loading projects…`]})]})}function Um({onRetry:e}){return(0,Z.jsxs)(`div`,{className:`page-container max-w-3xl`,children:[(0,Z.jsx)(`div`,{className:`page-header`,children:(0,Z.jsxs)(`div`,{className:`page-header-left`,children:[(0,Z.jsx)(`h1`,{className:`page-title`,children:`Can’t load projects`}),(0,Z.jsx)(`p`,{className:`page-subtitle`,children:`Canonry could not confirm whether this install already has a project.`})]})}),(0,Z.jsxs)(`div`,{className:`rounded-md border border-negative bg-negative-soft p-4`,role:`alert`,tabIndex:-1,children:[(0,Z.jsx)(`p`,{className:`text-copy-14-strong text-heading`,children:`Setup is paused to protect existing projects.`}),(0,Z.jsx)(`p`,{className:`mt-1 text-copy-14 text-secondary`,children:`Check the connection or sign in again, then retry.`}),(0,Z.jsx)(Y,{type:`button`,className:`mt-4`,variant:`secondary`,onClick:e,children:`Retry project check`})]})]})}function Wm(){let e=Ee({from:`/setup`});if(e.experience===`legacy`||e.experience!==`platform`&&ur()===`legacy`)return(0,Z.jsx)(cm,{visibilityProjectName:e.setupProject??e.project});let t=e.project??e.setupProject;if(t){let n=e.track??(e.onboarding===`site-health`?`agent-readiness`:void 0);return(0,Z.jsx)(xm,{projectName:t,firstRun:e.onboarding!==void 0,track:n},t)}let n=e.experience===`platform`;return(0,Z.jsx)(Gm,{addProject:n},n?`add-project`:`entry`)}function Gm({addProject:e}){let t=Te(),n=G({...wi({client:q}),retry:!1,refetchOnMount:`always`}),r=n.isSuccess&&n.isFetchedAfterMount,i=!e&&r&&n.data.length===1?n.data[0]:void 0,a=G({...Ei({client:q,path:{name:i?.name??``}}),enabled:i!==void 0,retry:!1}),[o,s]=(0,X.useState)(null);return(0,X.useEffect)(()=>{if(o||!r)return;let t=n.data;if(e||t.length===0)s({firstRun:t.length===0});else if(i){if(a.isPending)return;s(a.data?.complete===!0?{addProject:!0}:{redirectTo:i.name})}else s({addProject:!0})},[e,o,r,i,a.data,a.isPending,n.data]),(0,X.useEffect)(()=>{o&&(`redirectTo`in o?t({to:`/setup`,search:{project:o.redirectTo,onboarding:`first-run`},replace:!0}):`addProject`in o&&t({to:`/setup`,search:{experience:`platform`},replace:!0}))},[o,t]),!o&&n.isError?(0,Z.jsx)(Um,{onRetry:()=>{n.refetch()}}):!o||`redirectTo`in o||`addProject`in o?(0,Z.jsx)(Hm,{}):(0,Z.jsx)(Km,{firstRun:o.firstRun})}function Km({firstRun:e}){return(0,Z.jsx)(Rr,{title:e?`Set up Canonry`:`Add a project`,children:(0,Z.jsx)(qm,{firstRun:e})})}function qm({firstRun:e}){let t=Te(),n=be(),r=e&&jr(),i=G({...li({client:q}),enabled:r,retry:!1}),a=Fe(Si()),[o]=(0,X.useState)(()=>Wd(`platform`)),[c,l]=(0,X.useState)(o.domain??``),[u,d]=(0,X.useState)(o.projectName??``),[f,p]=(0,X.useState)(o.displayName??``),[m,h]=(0,X.useState)(o.country??`US`),[g,_]=(0,X.useState)(o.language??`en`),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(null),[w,T]=(0,X.useState)(null),D=G({...wi({client:q}),enabled:w!==null,retry:!1}),O=w===null?null:D.data?.find(e=>ht(e.name)===w)?.name??w,A=!r||i.isError?void 0:i.data,j=typeof A?.enabled==`boolean`?A.enabled:null,M=a.isPending?a.variables.body.enabled:j,[N,ee]=(0,X.useState)(null),P=(0,X.useRef)(null),F=(0,X.useRef)(null),I=(0,X.useRef)(null),{onboardingSessionId:L,emit:R}=qd(`platform`);(0,X.useEffect)(()=>{R({flowVersion:1,onboardingSessionId:L,event:`onboarding.started`,step:`project`,resumed:!1},`onboarding.started`)},[R,L]),(0,X.useEffect)(()=>{Gd(`platform`,{domain:c,projectName:u,displayName:f,country:m,language:g})},[c,u,f,m,g]);let z=()=>{Kd(`platform`),l(``),d(``),p(``),h(`US`),_(`en`),C(null),T(null)},te=Bm(c),ne=u.trim()||te?.projectName||``,re=f.trim()||te?.displayName||``,ie=pt(m,g),{countryValid:ae,languageValid:oe}=Rm(m,g),se=ae&&oe,ce=!!(c||u||f||m!==`US`||g!==`en`),B=!!(c&&!te&&b);(0,X.useEffect)(()=>{S&&(w!==null&&I.current?(F.current&&(F.current.open=!0),I.current.focus()):P.current?.focus())},[w,S]);let V=async r=>{if(r.preventDefault(),x(!0),te&&se&&!v){y(!0),C(null),T(null);try{let r=await Vn({name:ne,displayName:re,canonicalDomain:te.canonicalDomain,country:m,language:g});Kd(`platform`),R({flowVersion:1,onboardingSessionId:L,event:`onboarding.step_completed`,step:`project`,method:`manual`},`onboarding.step_completed:project`),await n.invalidateQueries({queryKey:Ni({client:q})}),await t({to:`/setup`,search:{project:r.name,...e?{onboarding:`first-run`}:{}},replace:!0})}catch(e){y(!1);let t=e instanceof ir&&e.statusCode===409;T(t?ht(ne):null),C(Vm(e,`Could not create the project. Try again.`)),R({flowVersion:1,onboardingSessionId:L,event:`onboarding.blocked`,step:`project`,action:`save`,reasonCode:Zt(e,`project_create_failed`)},`onboarding.blocked:project`),t&&n.invalidateQueries({queryKey:Ni({client:q})})}}},le=async e=>{ee(null);try{let t=await a.mutateAsync({client:q,body:{enabled:e}});n.setQueryData(ci({client:q}),t),t.enabled!==e&&ee(`The server kept telemetry ${t.enabled?`on`:`off`}. Check its telemetry settings.`)}catch{ee(`Could not update telemetry. Try again.`)}};return(0,Z.jsxs)(`div`,{className:`page-container max-w-3xl`,children:[(0,Z.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-x-4 gap-y-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h1`,{className:`text-heading-24 text-heading`,children:e?`Set up Canonry`:`Add a project`}),e?(0,Z.jsx)(`p`,{className:`mt-1 max-w-prose text-copy-14 text-secondary`,children:`Add your first website to get its Agent Readiness score and first AI Visibility result.`}):null]}),e?(0,Z.jsx)(Y,{asChild:!0,variant:`ghost`,className:`shrink-0`,children:(0,Z.jsxs)(W,{to:`/agent-setup`,children:[(0,Z.jsx)(k,{className:`size-4`,"aria-hidden":`true`}),`Set up with an agent`]})}):null]}),(0,Z.jsxs)(Qd,{label:`Setup progress`,children:[(0,Z.jsx)($d,{id:`setup-website`,title:`Website`,mark:`idle`,trailing:(0,Z.jsx)(br,{tone:`neutral`,className:`shrink-0`,children:`Required`}),children:(0,Z.jsxs)(`form`,{"aria-label":`Website`,className:`space-y-5`,onSubmit:Xr(V),noValidate:!0,children:[(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`label`,{className:`text-label-14-strong text-heading`,htmlFor:`launchpad-domain`,children:`Website URL`}),(0,Z.jsx)(`input`,{id:`launchpad-domain`,className:Fm,type:`text`,inputMode:`url`,autoComplete:`url`,autoCapitalize:`none`,spellCheck:!1,required:!0,"aria-invalid":B,"aria-describedby":B?`launchpad-domain-error`:void 0,placeholder:`https://example.com`,value:c,onBlur:()=>x(!0),onChange:e=>{l(e.target.value),C(null),T(null)}}),B?(0,Z.jsx)(`p`,{id:`launchpad-domain-error`,className:`text-copy-14 text-negative`,role:`alert`,children:`Enter a public domain, such as example.com.`}):null]}),(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`label`,{className:`text-label-14-strong text-heading`,htmlFor:`launchpad-display-name`,children:`Brand name`}),(0,Z.jsx)(`input`,{id:`launchpad-display-name`,className:Fm,type:`text`,autoComplete:`organization`,"aria-describedby":`launchpad-display-name-hint`,placeholder:te?.displayName??`Your brand`,value:f,onChange:e=>p(e.target.value)}),(0,Z.jsx)(`p`,{id:`launchpad-display-name-hint`,className:`text-copy-13 text-secondary`,children:`Answers that name this brand count as mentions.`})]}),(0,Z.jsxs)(`details`,{ref:F,className:`group border-t border-default`,children:[(0,Z.jsxs)(`summary`,{className:`flex min-h-9 cursor-pointer list-none items-center justify-between gap-4 py-2 text-label-14 [&::-webkit-details-marker]:hidden ${Pm}`,children:[(0,Z.jsx)(`span`,{className:`text-label-14-strong text-heading`,children:`Project details`}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-2 text-secondary`,children:[ie,(0,Z.jsx)(E,{className:`size-4 transition-transform group-open:rotate-180 motion-reduce:transition-none`,"aria-hidden":`true`})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-5 pb-4 pt-2`,children:[te?(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:max-w-[50%]`,children:[(0,Z.jsx)(`label`,{className:`text-label-14 text-secondary`,htmlFor:`launchpad-project-name`,children:`Project name`}),(0,Z.jsx)(`input`,{ref:I,id:`launchpad-project-name`,className:Fm,type:`text`,placeholder:te.projectName,"aria-invalid":w!==null,"aria-describedby":w===null?void 0:`launchpad-create-error`,value:u,onChange:e=>{d(e.target.value),w!==null&&(T(null),C(null))}})]}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`label`,{className:`text-label-14 text-secondary`,htmlFor:`launchpad-country`,children:`Country`}),(0,Z.jsx)(`select`,{id:`launchpad-country`,className:Fm,value:m,onChange:e=>h(e.target.value),children:Im.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`label`,{className:`text-label-14 text-secondary`,htmlFor:`launchpad-language`,children:`Language`}),(0,Z.jsx)(`select`,{id:`launchpad-language`,className:Fm,value:g,onChange:e=>_(e.target.value),children:Lm.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]})]})]}),S?(0,Z.jsxs)(`div`,{ref:P,className:`rounded-md border border-negative bg-negative-soft p-3`,role:`alert`,tabIndex:-1,children:[(0,Z.jsx)(`p`,{id:`launchpad-create-error`,className:`text-copy-14-strong text-heading`,children:S}),O===null?null:(0,Z.jsx)(Y,{asChild:!0,variant:`secondary`,size:`sm`,className:`mt-3`,children:(0,Z.jsxs)(W,{to:`/projects/$projectName`,params:{projectName:O},children:[`Open `,O]})})]}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 max-sm:[&>*]:w-full`,children:[ce?(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,disabled:v,onClick:z,children:`Reset unsaved fields`}):null,e?null:(0,Z.jsx)(Y,{asChild:!0,variant:`ghost`,className:Pm,children:(0,Z.jsx)(W,{to:`/projects`,onClick:()=>Kd(`platform`),children:`Cancel`})}),(0,Z.jsx)(Y,{className:Pm,type:`submit`,disabled:!te||!se||v,children:v?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(s,{className:`size-4 motion-safe:animate-spin`,"aria-hidden":`true`}),` Creating project…`]}):`Continue`})]})]})}),(0,Z.jsx)($d,{id:`setup-agent-readiness`,title:`Agent Readiness`,mark:`idle`,summary:`How well AI agents can read your site`,trailing:(0,Z.jsx)(Yd,{state:K.not_started})}),(0,Z.jsx)($d,{id:`setup-ai-visibility`,title:`AI Visibility`,mark:`idle`,summary:`Whether AI answers mention your brand and cite your site`,trailing:(0,Z.jsx)(Yd,{state:K.not_started})})]}),j===null?null:(0,Z.jsxs)(`section`,{className:`mt-6 border-t border-default pt-5`,"aria-labelledby":`telemetry-title`,children:[(0,Z.jsxs)(`label`,{className:`flex min-h-11 items-start gap-3 py-2 ${a.isPending?`cursor-wait`:`cursor-pointer`}`,children:[(0,Z.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:M??!1,disabled:a.isPending,onChange:e=>{le(e.target.checked)},"aria-describedby":`telemetry-detail`}),(0,Z.jsxs)(`span`,{className:`grid gap-0.5`,children:[(0,Z.jsx)(`span`,{id:`telemetry-title`,className:`text-label-14 text-heading`,children:`Share anonymous product telemetry`}),(0,Z.jsx)(`span`,{id:`telemetry-detail`,className:`max-w-[70ch] text-label-14 text-secondary`,children:`Helps prioritize improvements. Canonry does not send raw domains, URLs, queries, answer content, or credentials.`})]})]}),a.isPending?(0,Z.jsx)(`p`,{className:`mt-1 text-copy-14 text-secondary`,role:`status`,children:`Saving preference…`}):null,N?(0,Z.jsx)(`p`,{className:`mt-1 text-copy-14 text-negative`,role:`alert`,children:N}):null]})]})}function Jm(){return(0,Z.jsx)(`div`,{className:`page-container`,children:(0,Z.jsx)(`section`,{className:`page-section`,children:(0,Z.jsxs)(Ri,{className:`surface-card empty-card`,children:[(0,Z.jsx)(`h1`,{children:`Page not found`}),(0,Z.jsx)(`p`,{children:`This page may have moved. Choose a project to continue.`}),(0,Z.jsx)(Y,{asChild:!0,children:(0,Z.jsx)(W,{to:`/projects`,children:`View projects`})})]})})})}var Ym=`modulepreload`,Xm=function(e,t){return new URL(e,t).href},Zm={},Qm=function(e){return e.pathname.endsWith(`.css`)},$m=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},eh=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=Xm(t,n);let r=s(t),i=Qm(r);return $m(Zm,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:Ym,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},th=U(()=>eh(()=>import(`./ProjectPage-2oJ95fiK.js`).then(e=>e.t),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]),import.meta.url),`ProjectPage`),nh=U(()=>eh(()=>import(`./RunsPage-Cc3kJZ39.js`),__vite__mapDeps([23,1,2,3,4,5,6,7,8,9,10,11,13,14,15,16]),import.meta.url),`RunsPage`),rh=U(()=>eh(()=>import(`./HistoryPage-DMmZ0fSd.js`),__vite__mapDeps([24,4,1,2,18,5,6,3,7,14,11]),import.meta.url),`HistoryPage`),ih=U(()=>eh(()=>import(`./SettingsPage-NebxmvVG.js`),__vite__mapDeps([25,1,2,4,5,6,3,7,8,9,10,11,12,13]),import.meta.url),`SettingsPage`),ah=U(()=>eh(()=>import(`./AgentSetupPage-CR6hyf9a.js`),__vite__mapDeps([26,1,2,4,7,3,6,10,12]),import.meta.url),`AgentSetupPage`),oh=U(()=>eh(()=>import(`./BacklinksPage-Dg6IJr83.js`),__vite__mapDeps([27,1,2,4,7,3,6,12,11,17,16]),import.meta.url),`BacklinksPage`),sh=U(()=>eh(()=>import(`./TrafficPage-Dia9_FuQ.js`),__vite__mapDeps([28,1,2,4,5,6,3,7,14,11,22,12,13,15,16,20]),import.meta.url),`TrafficPage`),ch=U(()=>eh(()=>import(`./TrafficSourceDetailPage-DJ5EQEL9.js`),__vite__mapDeps([29,1,2,4,5,6,3,7,9,15,16,11,20,13,14,21]),import.meta.url),`TrafficSourceDetailPage`),lh=U(()=>eh(()=>import(`./MeasurementPropertyPage-CpYhSd3d.js`),__vite__mapDeps([30,1,2,4,5,6,3,7,8,9,10,11,14,15,16,19]),import.meta.url),`MeasurementPropertyPage`);function uh(){return(0,Z.jsx)(Du,{children:(0,Z.jsx)(ta,{children:(0,Z.jsx)(Su,{})})})}var dh=we()({component:uh,notFoundComponent:Jm,validateSearch:e=>({manageQueries:e.manageQueries===!0||e.manageQueries===`true`||void 0,runId:typeof e.runId==`string`?e.runId:void 0,siteHealthRunId:typeof e.siteHealthRunId==`string`?e.siteHealthRunId:void 0,seoProfileId:typeof e.seoProfileId==`string`?e.seoProfileId:void 0,seoRunId:typeof e.seoRunId==`string`?e.seoRunId:void 0,seoView:typeof e.seoView==`string`?e.seoView:void 0,seoTrendDays:nr.safeParse(typeof e.seoTrendDays==`string`?Number(e.seoTrendDays):e.seoTrendDays).data,seoTrendMetric:In.safeParse(e.seoTrendMetric).data,seoTrendKeyword:mr.safeParse(e.seoTrendKeyword).data,seoRegion:typeof e.seoRegion==`string`&&e.seoRegion?e.seoRegion:void 0,seoMarket:typeof e.seoMarket==`string`&&e.seoMarket?e.seoMarket:void 0,seoShow:typeof e.seoShow==`string`&&e.seoShow?e.seoShow:void 0,seoSort:typeof e.seoSort==`string`&&e.seoSort?e.seoSort:void 0,seoQ:typeof e.seoQ==`string`&&e.seoQ?e.seoQ:void 0,evidenceId:typeof e.evidenceId==`string`?e.evidenceId:void 0,runStatus:typeof e.runStatus==`string`?e.runStatus:void 0,runKind:typeof e.runKind==`string`?e.runKind:void 0,runProject:typeof e.runProject==`string`?e.runProject:void 0,runWindow:typeof e.runWindow==`string`?e.runWindow:void 0,runQuery:typeof e.runQuery==`string`?e.runQuery:void 0,onboarding:e.onboarding===`site-health`||e.onboarding===`first-run`||e.onboarding===`complete`?e.onboarding:void 0,experience:e.experience===`legacy`||e.experience===`platform`?e.experience:void 0,siteScan:e.siteScan===`skip`||e.siteScan===`scan`?e.siteScan:void 0,skipped:e.skipped===`visibility`?`visibility`:void 0,setupProject:typeof e.setupProject==`string`?e.setupProject:void 0,project:typeof e.project==`string`&&e.project?e.project:void 0,track:e.track===`agent-readiness`||e.track===`ai-visibility`?e.track: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`,`journeyView`,`journeyDays`,`journeyVisitor`,`journeyEngine`,`journeyReturned`,`journeyOffset`,`agentHours`].map(t=>[t,typeof e[t]==`string`&&e[t]?e[t]:void 0]))})}),fh=Ae({getParentRoute:()=>dh,path:`/`,component:Ld,beforeLoad:async({context:e})=>{let t=e.queryClient.getQueryData(Ni({client:q}));if(t===void 0)try{t=await e.queryClient.ensureQueryData(wi({client:q}))}catch{return}if(t.length===0)throw De({to:`/setup`})}}),ph=Ae({getParentRoute:()=>dh,path:`/projects`,component:Vd}),mh=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,hh=Ae({getParentRoute:()=>dh,path:`/projects/$projectName`,component:()=>(0,Z.jsx)(Ne,{}),beforeLoad:async({context:e,params:t,location:n})=>{let r=t.projectName;if(!mh.test(r))return;let i=e.queryClient.getQueryData(Ni({client:q}));if(!i)try{i=await e.queryClient.ensureQueryData(wi({client:q}))}catch{return}let a=i.find(e=>e.id===r);if(a)throw De({to:n.pathname.replace(`/projects/${r}`,`/projects/${encodeURIComponent(a.name)}`),replace:!0})}}),gh=Ae({getParentRoute:()=>hh,path:`/`,component:()=>(0,Z.jsx)(th,{tab:`overview`})}),_h=Ae({getParentRoute:()=>hh,path:`/portfolio`,component:()=>(0,Z.jsx)(th,{tab:`portfolio`})}),vh=Ae({getParentRoute:()=>hh,path:`/search-console`,component:()=>(0,Z.jsx)(th,{tab:`search-console`})}),yh=Ae({getParentRoute:()=>hh,path:`/seo-data`,component:()=>(0,Z.jsx)(th,{tab:`seo-data`})}),bh=Ae({getParentRoute:()=>hh,path:`/journeys`,component:()=>(0,Z.jsx)(th,{tab:`journeys`})}),xh=Ae({getParentRoute:()=>hh,path:`/conversions`,component:()=>(0,Z.jsx)(th,{tab:`conversions`})}),Sh=Ae({getParentRoute:()=>hh,path:`/local`,component:()=>(0,Z.jsx)(th,{tab:`local`})}),Ch=Ae({getParentRoute:()=>hh,path:`/discovery`,component:()=>(0,Z.jsx)(th,{tab:`discovery`})}),wh=Ae({getParentRoute:()=>hh,path:`/queries`,component:()=>(0,Z.jsx)(th,{tab:`queries`})}),Th=Ae({getParentRoute:()=>hh,path:`/client-queries`,component:()=>(0,Z.jsx)(th,{tab:`client-queries`})}),Eh=Ae({getParentRoute:()=>hh,path:`/properties/$targetKey`,component:()=>(0,Z.jsx)(lh,{})}),Dh=Ae({getParentRoute:()=>hh,path:`/report`,beforeLoad:({params:e})=>{throw De({to:`/projects/$projectName`,params:e,replace:!0})}}),Oh=Ae({getParentRoute:()=>hh,path:`/activity`,component:()=>(0,Z.jsx)(th,{tab:`activity`})}),kh=Ae({getParentRoute:()=>hh,path:`/traffic`,component:()=>(0,Z.jsx)(th,{tab:`traffic`})}),Ah=Ae({getParentRoute:()=>hh,path:`/backlinks`,component:()=>(0,Z.jsx)(th,{tab:`backlinks`})}),jh=Ae({getParentRoute:()=>hh,path:`/agent-readiness`,component:()=>(0,Z.jsx)(th,{tab:`agent-readiness`})}),Mh=Ae({getParentRoute:()=>hh,path:`/technical-aeo`,beforeLoad:({params:e,location:t})=>{throw De({to:`/projects/$projectName/agent-readiness`,params:e,search:t.search,hash:t.hash,replace:!0})}}),Nh=Ae({getParentRoute:()=>hh,path:`/history`,component:()=>(0,Z.jsx)(th,{tab:`history`})}),Ph=Ae({getParentRoute:()=>hh,path:`/settings`,component:()=>(0,Z.jsx)(th,{tab:`settings`})}),Fh=Ae({getParentRoute:()=>dh,path:`/runs`,component:nh}),Ih=Ae({getParentRoute:()=>dh,path:`/history`,component:rh}),Lh=Ae({getParentRoute:()=>dh,path:`/settings`,component:ih,beforeLoad:({context:e})=>{}}),Rh=Ae({getParentRoute:()=>dh,path:`/setup`,component:Wm}),zh=Ae({getParentRoute:()=>dh,path:`/agent-setup`,component:ah}),Bh=Ae({getParentRoute:()=>dh,path:`/backlinks`,component:oh}),Vh=Ae({getParentRoute:()=>dh,path:`/traffic`,component:sh}),Hh=Ae({getParentRoute:()=>dh,path:`/traffic/$projectName/$sourceId`,component:ch}),Uh=dh.addChildren([fh,ph,hh.addChildren([gh,_h,vh,yh,bh,xh,Sh,Ch,wh,Th,Eh,Dh,Oh,kh,Ah,jh,Mh,Nh,Ph]),Fh,Ih,Lh,Rh,zh,Bh,Vh,Hh]);function Wh(){return typeof window<`u`&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath:`/`}var Gh=Wh(),Kh=Gh===`/`?``:Gh.replace(/\/$/,``);function qh(e,t){return Se({routeTree:Uh,basepath:Kh||`/`,context:{queryClient:e},...t?.initialEntries&&{history:Oe({initialEntries:t.initialEntries})}})}var Jh=6e4,Yh=6e4,Xh=1e4,Zh=3e4;function Qh(){let e=!1,t=null,n,r=null,i=performance.now(),a=Date.now(),o=i,s=i,c=document.visibilityState===`visible`&&document.hasFocus(),l=0,u=()=>{let e=performance.now(),t=Date.now(),n=e-i;if(r&&c&&n>=0&&n<=Zh&&t-a<=Zh){let e=bn-r.foregroundMs,t=Math.min(n,e);r.foregroundMs+=t,r.activeMs+=Math.min(t,Math.max(0,o+Jh-i))}i=e,a=t},d=(e=!1)=>{!r||!t||r.foregroundMs<1||(e||Math.floor(r.foregroundMs)!==l)&&(l=Math.floor(r.foregroundMs),s=i,qt({event:`ui.page_time`,page:t,visitId:r.id,foregroundMs:l,activeMs:Math.floor(r.activeMs),completed:e}))},f=()=>{r={id:Xt(),foregroundMs:0,activeMs:0},l=0,s=i,o=i},p=()=>{u();let e=document.visibilityState===`visible`&&document.hasFocus();c&&!e&&d(),!c&&e&&(o=i),c=e},m=()=>{u(),c&&(o=i)},h=()=>{u(),d(!0),r=null,c=!1},g=()=>{p(),t&&!r&&f()},_=window.setInterval(()=>{u(),i-s>=Yh&&d()},Xh),v=[`pointerdown`,`pointermove`,`keydown`,`scroll`,`touchstart`];for(let e of v)document.addEventListener(e,m,{passive:!0,capture:!0});return document.addEventListener(`visibilitychange`,p),window.addEventListener(`focus`,p),window.addEventListener(`blur`,p),window.addEventListener(`pagehide`,h),window.addEventListener(`pageshow`,g),{clear(){r=null,t=null,n=void 0},navigate(i,a){if(e)return;let o=On(i);t===o&&n===a&&r||(u(),d(!0),t=o,n=a,c=document.visibilityState===`visible`&&document.hasFocus(),f())},stop(){e=!0,r=null,window.clearInterval(_);for(let e of v)document.removeEventListener(e,m,!0);document.removeEventListener(`visibilitychange`,p),window.removeEventListener(`focus`,p),window.removeEventListener(`blur`,p),window.removeEventListener(`pagehide`,h),window.removeEventListener(`pageshow`,g)}}}var $h=!1,eg;async function tg(e){return(await Ie({client:q,body:e,keepalive:!0})).data}function ng(){$h||typeof window>`u`||($h=!0,!(Ue()||xt())&&(eg=Qh(),vt({send:tg,onDisabled:()=>eg?.stop()}),q.interceptors.request.use((e,t)=>{let n=t.fetch??globalThis.fetch,r=typeof t.url==`string`?t.url:void 0;return t.fetch=async(t,i)=>{try{return await n(t,i)}catch(t){throw t instanceof DOMException&&t.name===`AbortError`||jt({method:e.method,route:r,network:!0}),t}},e}),q.interceptors.response.use((e,t,n)=>(jt({method:t.method,route:typeof n.url==`string`?n.url:void 0,path:ig(t.url),status:e.status}),e)),window.addEventListener(`error`,e=>{Qe({kind:`unhandled`,error:e.error})}),window.addEventListener(`unhandledrejection`,e=>{Qe({kind:`unhandled`,error:e.reason})}),lg()))}function rg(e){let t=null,n=()=>{let n=e.state.matches.at(-1);if(!n)return;eg?.navigate(n.fullPath,e.state.location?.pathname),Lt(n.fullPath);let r=e.state.location;if(!r)return;let i=r.search&&typeof r.search==`object`?r.search:{};t&&t.pathname===r.pathname&&at(t.search,i),t={pathname:r.pathname,search:i}};n();let r=e.subscribe(`onResolved`,n);return()=>{r(),eg?.clear()}}function ig(e){try{return new URL(e,window.location.origin).pathname}catch{return}}var ag={LCP:[2500,4e3],INP:[200,500],CLS:[.1,.25],FCP:[1800,3e3],TTFB:[800,1800]};function og(e,t){let[n,r]=ag[e];return t<=n?`good`:t<=r?`needs-improvement`:`poor`}function sg(){let e=0,t=0,n=-1/0,r=-1/0;return{add(i){i.hadRecentInput||(i.startTime-r<1e3&&i.startTime-n<5e3?t+=i.value:(t=i.value,n=i.startTime),r=i.startTime,e=Math.max(e,t))},value:()=>e}}function cg(){let e=0;return{add(t){t.interactionId&&(e=Math.max(e,t.duration))},value:()=>e}}function lg(){if(typeof PerformanceObserver>`u`)return;let e=new Set,t=(t,n)=>{!e.has(t)&&Number.isFinite(n)&&(e.add(t),mt(t,og(t,n)))},n=(e,t,n={})=>{try{new PerformanceObserver(e=>t(e.getEntries())).observe({type:e,buffered:!0,...n})}catch{}};try{let e=performance.getEntriesByType(`navigation`)[0];e&&e.responseStart>0&&t(`TTFB`,e.responseStart)}catch{}n(`paint`,e=>{let n=e.find(e=>e.name===`first-contentful-paint`);n&&t(`FCP`,n.startTime)});let r=0;n(`largest-contentful-paint`,e=>{let t=e.at(-1);t&&(r=t.startTime)});let i=sg();n(`layout-shift`,e=>{for(let t of e)i.add({startTime:t.startTime,value:t.value??0,hadRecentInput:t.hadRecentInput===!0})});let a=cg();n(`event`,e=>{for(let t of e)a.add(t)},{durationThreshold:40});let o=()=>{r>0&&t(`LCP`,r),t(`CLS`,i.value()),a.value()>0&&t(`INP`,a.value())};document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`hidden`&&o()}),window.addEventListener(`pagehide`,o)}var ug=6e4,dg=`Anyone with this password can sign in to this dashboard.`,fg={label:`Root API key`,help:`To create the password from here, enter the root API key (apiKey in config.yaml). It is used once and not saved.`,missing:`Enter the root API key.`,rejected:`That is not the root API key for this install.`,show:`Show passwords and key`},pg={id:`embed`,scopes:[`read`,`embed`],projectId:`embed`,readOnly:!0};function mg(){let e=(0,X.useRef)(jr()).current,[t,n]=(0,X.useState)(e?`ready`:`checking`),[r,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(e),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(``),[g,_]=(0,X.useState)(``),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(`password`),[S,C]=(0,X.useState)(!1),[w,T]=(0,X.useState)(``),[D,O]=(0,X.useState)(null),[k,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(!1),[N,ee]=(0,X.useState)(!1),[P,F]=(0,X.useState)(!1),[I]=(0,X.useState)(()=>Qi().error),L=(0,X.useRef)(null),R=(0,X.useRef)(null),z=(0,X.useRef)(null),te=()=>{let t=r?`${r.name}:${r.role}`:e?`api-key:explicit`:a?`api-key:${a.id}`:`no-accounts`;if(!L.current||z.current!==t){R.current?.clear();let e=Qr();R.current=e,L.current=qh(e),z.current=t}return{queryClient:R.current,router:L.current}},ne=t===`ready`?te().router:null;(0,X.useEffect)(()=>{if(ne)return rg(ne)},[ne]);let re=e=>e.authRequired?(u(!0),ee(e.signInMethods?.chatgpt===!0),i(e.user),o(null),c(!1),n(e.user?`ready`:`account-login`),!0):!1;(0,X.useEffect)(()=>{let t=!1,r=async(e,r=!1)=>{try{let e=await nt();if(t)return;o(e),c(!1),n(`ready`)}catch(i){if(t)return;if(r&&i instanceof ir&&i.statusCode===401)return Bt().then(()=>{t||(O(null),o(null),c(!1),M(!0),n(`login`))}).catch(r=>{t||(O(r instanceof Error?r.message:`Could not clear the invalid session`),n(e))});O(i instanceof Error?i.message:`Could not verify API key access`),n(e)}};return e?(r(`api-key-error`),()=>{t=!0}):(Promise.allSettled([Ft(),yr()]).then(([e,i])=>{if(t||e.status===`fulfilled`&&re(e.value))return;if(i.status===`rejected`){let e=i.reason;O(e instanceof Error?e.message:`Failed to reach the Canonry API`),n(`login`);return}let a=i.value;a.authenticated&&Ue()?(o(pg),c(!1),n(`ready`)):a.authenticated?(c(!0),r(`api-key-error`,!0)):(o(null),c(!1),n(a.setupRequired?`setup`:`login`))}),()=>{t=!0})},[]),(0,X.useEffect)(()=>{if(t!==`ready`||e)return;let r=setInterval(()=>{l?Ft().then(e=>{e.authRequired&&!e.user&&(M(!0),i(null),o(null),n(`account-login`))}).catch(()=>{}):yr().then(e=>{e.authenticated||(M(!0),o(null),n(e.setupRequired?`setup`:`login`))}).catch(()=>{})},ug);return tr(()=>{M(!0),i(null),o(null),c(!1),n(l?`account-login`:`login`)}),()=>{clearInterval(r),tr(null)}},[t,l,e]);let ie=async e=>{if(e.preventDefault(),!p.trim()||p.trim().length<8){O(`Password must be at least 8 characters`);return}if(p!==g){O(`Passwords do not match`);return}let t=w.trim();if(S&&!t)O(fg.missing);else{A(!0),O(null);try{if(!(await Fn(p.trim(),S?t:void 0)).authenticated){O(`Setup failed`);return}m(``),_(``),T(``),C(!1),y(!1),M(!1),o(null),c(!0),n(`checking`);try{let e=await nt();o(e),c(!1),n(`ready`)}catch(e){O(e instanceof Error?e.message:`Could not verify API key access`),n(`api-key-error`)}}catch(e){if(e instanceof ir&&e.statusCode===401&&e.code===`AUTH_REQUIRED`){O(S?fg.rejected:null),C(!0);return}O(e instanceof ir||e instanceof Error?e.message:`Setup failed`)}finally{A(!1)}}},ae=e=>{m(e),O(null)},oe=e=>{T(e),O(null)},se=e=>{_(e),O(null)},ce=async e=>{if(e.preventDefault(),p.trim()){A(!0),O(null);try{if(!(b===`api-key`?await tt(p.trim()):await st(p.trim())).authenticated){O(b===`api-key`?`Invalid API key`:`Incorrect password`);return}let e=await nt();o(e),c(!1),m(``),y(!1),M(!1),n(`ready`)}catch(e){O(e instanceof ir||e instanceof Error?e.message:`Authentication failed`)}finally{A(!1)}}},B=e=>{x(e),m(``),y(!1),O(null)},V=async e=>{if(e.preventDefault(),d.trim()&&p){A(!0),O(null);try{let e=await Kn(d.trim(),p);if(!e.user){O(`Incorrect name or password.`);return}m(``),M(!1),i(e.user),o(null),c(!1),n(`ready`)}catch(e){O(e instanceof ir?e.message:`Incorrect name or password.`)}finally{A(!1)}}};if(t===`ready`){let{queryClient:e,router:t}=te();return(0,Z.jsx)(Yr,{account:r,apiKey:a,apiKeyPending:s,children:(0,Z.jsx)(ve,{client:e,children:(0,Z.jsx)(ke,{router:t})})})}let le=p.trim(),ue=p.length>0&&le.length<8,de=g.length>0&&p!==g,fe=le.length>=8&&p===g&&(!S||w.trim().length>0),H=e=>(0,Z.jsxs)(`form`,{id:e.formId,className:`space-y-4`,onSubmit:Xr(V),children:[(0,Z.jsxs)(`label`,{className:`block space-y-1.5`,htmlFor:`account-name`,children:[(0,Z.jsx)(`span`,{className:`text-label-12-strong text-secondary`,children:`Name`}),(0,Z.jsx)(`input`,{autoFocus:!0,id:`account-name`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-label-14 text-heading outline-none transition focus:border-mono-600`,type:`text`,name:`username`,autoComplete:`username`,value:d,onChange:e=>{f(e.target.value),O(null)},"aria-invalid":!!D,"aria-describedby":D?`account-login-error`:void 0})]}),(0,Z.jsxs)(`label`,{className:`block space-y-1.5`,htmlFor:`account-password`,children:[(0,Z.jsx)(`span`,{className:`text-label-12-strong text-secondary`,children:`Password`}),(0,Z.jsx)(`input`,{id:`account-password`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-label-14 text-heading outline-none transition focus:border-mono-600`,type:`password`,name:`password`,autoComplete:`current-password`,value:p,onChange:e=>ae(e.target.value),"aria-invalid":!!D,"aria-describedby":D?`account-login-error`:void 0})]}),D?(0,Z.jsx)(`p`,{id:`account-login-error`,role:`alert`,className:`text-copy-14 text-negative-400`,children:D}):null,(0,Z.jsx)(Y,{type:`submit`,variant:e.secondary?`secondary`:`default`,disabled:k||!d.trim()||!p,children:k?`Signing in…`:`Sign in`})]});return(0,Z.jsx)(`div`,{className:`min-h-screen bg-bg px-4 py-8`,children:(0,Z.jsxs)(`div`,{className:`mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col items-center justify-center gap-5`,children:[(0,Z.jsxs)(`div`,{"data-testid":`auth-brand`,className:`flex items-center gap-2.5`,children:[(0,Z.jsx)(Ua,{className:`size-7`}),(0,Z.jsx)(`span`,{className:`text-label-18-strong text-heading`,children:`Canonry`})]}),(0,Z.jsx)(Ri,{className:`surface-card w-full`,children:t===`checking`?(0,Z.jsx)(Ii,{className:`py-8`,children:(0,Z.jsx)(`p`,{className:`supporting-copy text-center`,children:`Connecting to Canonry…`})}):t===`api-key-error`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Fi,{children:(0,Z.jsx)(`h1`,{className:`text-heading-24 text-primary`,children:`Could not verify API key access`})}),(0,Z.jsxs)(Ii,{className:`space-y-4`,children:[(0,Z.jsx)(`p`,{className:`supporting-copy`,children:D??`Canonry could not verify this session’s access, so the dashboard stayed locked.`}),(0,Z.jsx)(Y,{type:`button`,className:`w-full`,onClick:()=>{window.location.reload()},children:`Try again`})]})]}):t===`account-login`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Fi,{children:(0,Z.jsx)(`h1`,{className:`text-heading-24 text-primary`,children:`Sign in to Canonry`})}),N?(0,Z.jsxs)(Ii,{className:`space-y-4`,children:[j?(0,Z.jsx)(`p`,{className:`rounded-md border border-caution bg-caution-soft px-3 py-2 text-copy-14 text-caution`,children:`You were signed out. Sign in again.`}):I?(0,Z.jsx)(`p`,{role:`alert`,className:`rounded-md border border-caution bg-caution-soft px-3 py-2 text-copy-14 text-caution`,children:Zn[I]}):null,(0,Z.jsx)(Pc,{href:dn(`login`,$i()),className:`w-full`}),(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":P,"aria-controls":`account-password-form`,onClick:()=>F(e=>!e),className:`flex items-center gap-1 rounded-md text-label-14 text-secondary transition hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400`,children:[P?(0,Z.jsx)(E,{className:`h-4 w-4`,"aria-hidden":`true`}):(0,Z.jsx)(h,{className:`h-4 w-4`,"aria-hidden":`true`}),`Sign in with a password`]}),P?H({secondary:!0,formId:`account-password-form`}):null]}):(0,Z.jsxs)(Ii,{children:[j?(0,Z.jsx)(`p`,{className:`mb-4 rounded-md border border-caution bg-caution-soft px-3 py-2 text-copy-14 text-caution`,children:`You were signed out. Sign in again.`}):null,H({secondary:!1})]})]}):t===`setup`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Fi,{children:[(0,Z.jsx)(`h1`,{className:`text-heading-24 text-primary`,children:`Create a dashboard password`}),(0,Z.jsx)(Li,{children:dg})]}),(0,Z.jsx)(Ii,{children:(0,Z.jsxs)(`form`,{className:`space-y-4`,onSubmit:Xr(ie),children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`block text-label-12-strong text-secondary`,htmlFor:`dashboard-password-new`,children:`Password`}),(0,Z.jsx)(`input`,{autoFocus:!0,id:`dashboard-password-new`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-label-14 text-heading outline-none transition focus:border-mono-600`,type:v?`text`:`password`,name:`new-password`,autoComplete:`new-password`,minLength:8,required:!0,value:p,onChange:e=>ae(e.target.value),"aria-invalid":ue,"aria-describedby":`dashboard-password-new-help`}),(0,Z.jsx)(`span`,{id:`dashboard-password-new-help`,"aria-live":`polite`,className:ue?`block text-label-14 text-negative-400`:`block text-label-14 text-secondary`,children:ue?`Enter at least 8 characters.`:`Use at least 8 characters.`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`block text-label-12-strong text-secondary`,htmlFor:`dashboard-password-confirm`,children:`Confirm password`}),(0,Z.jsx)(`input`,{id:`dashboard-password-confirm`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-label-14 text-heading outline-none transition focus:border-mono-600`,type:v?`text`:`password`,name:`confirm-password`,autoComplete:`new-password`,minLength:8,required:!0,value:g,onChange:e=>se(e.target.value),"aria-invalid":de,"aria-describedby":`dashboard-password-confirm-help`}),(0,Z.jsx)(`span`,{id:`dashboard-password-confirm-help`,"aria-live":`polite`,className:de?`block text-label-14 text-negative-400`:`block text-label-14 text-secondary`,children:de?`Passwords do not match.`:`Enter the same password again.`})]}),S?(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`block text-label-12-strong text-secondary`,htmlFor:`dashboard-setup-root-key`,children:fg.label}),(0,Z.jsx)(`input`,{autoFocus:!0,id:`dashboard-setup-root-key`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-label-14 text-heading outline-none transition focus:border-mono-600`,type:v?`text`:`password`,name:`apiKey`,autoComplete:`off`,spellCheck:!1,required:!0,value:w,onChange:e=>oe(e.target.value),"aria-invalid":D===fg.rejected,"aria-describedby":`dashboard-setup-root-key-help`}),(0,Z.jsx)(`span`,{id:`dashboard-setup-root-key-help`,"aria-live":`polite`,className:`block text-label-14 text-secondary`,children:fg.help})]}):null,(0,Z.jsxs)(`label`,{className:`flex min-h-10 cursor-pointer items-center gap-2 text-label-14 text-secondary`,htmlFor:`dashboard-password-show`,children:[(0,Z.jsx)(`input`,{id:`dashboard-password-show`,type:`checkbox`,checked:v,onChange:e=>y(e.target.checked)}),S?fg.show:`Show passwords`]}),D?(0,Z.jsx)(`p`,{id:`dashboard-password-setup-error`,role:`alert`,className:`text-copy-14 text-negative-400`,children:D}):null,(0,Z.jsx)(Y,{type:`submit`,disabled:k||!fe,children:k?`Creating password…`:`Create password and continue`})]})})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Fi,{children:[(0,Z.jsx)(`h1`,{className:`text-heading-24 text-primary`,children:`Sign in to Canonry`}),(0,Z.jsx)(Li,{children:b===`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.`})]}),(0,Z.jsxs)(Ii,{children:[j?(0,Z.jsx)(`p`,{className:`mb-4 rounded-md border border-caution bg-caution-soft px-3 py-2 text-copy-14 text-caution`,children:`Your session expired. Sign in again.`}):null,(0,Z.jsxs)(`form`,{className:`space-y-4`,onSubmit:Xr(ce),children:[(0,Z.jsxs)(`label`,{className:`block space-y-1.5`,htmlFor:`dashboard-password-current`,children:[(0,Z.jsx)(`span`,{className:`text-label-12-strong text-secondary`,children:b===`api-key`?`Canonry API key`:`Password`}),(0,Z.jsx)(`input`,{autoFocus:!0,id:`dashboard-password-current`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-label-14 text-heading outline-none transition focus:border-mono-600`,type:v?`text`:`password`,name:b===`api-key`?`apiKey`:`password`,autoComplete:b===`api-key`?`off`:`current-password`,spellCheck:!1,required:!0,value:p,onChange:e=>ae(e.target.value),"aria-invalid":!!D,"aria-describedby":D?`dashboard-password-login-error`:void 0})]}),(0,Z.jsxs)(`label`,{className:`flex min-h-10 cursor-pointer items-center gap-2 text-label-14 text-secondary`,htmlFor:`dashboard-login-password-show`,children:[(0,Z.jsx)(`input`,{id:`dashboard-login-password-show`,type:`checkbox`,checked:v,onChange:e=>y(e.target.checked)}),b===`api-key`?`Show API key`:`Show password`]}),D?(0,Z.jsx)(`p`,{id:`dashboard-password-login-error`,role:`alert`,className:`text-copy-14 text-negative-400`,children:D}):null,(0,Z.jsx)(Y,{type:`submit`,disabled:k||!p.trim(),children:k?`Signing in…`:`Open dashboard`}),(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,onClick:()=>B(b===`api-key`?`password`:`api-key`),children:b===`api-key`?`Use dashboard password instead`:`Forgot password? Use API key`})]})]})]})})]})})}var hg=document.getElementById(`root`);if(!hg)throw Error(`Expected #root element for web app bootstrap.`);ng(),(0,Wi.createRoot)(hg).render((0,Z.jsx)(X.StrictMode,{children:(0,Z.jsx)(Za,{children:(0,Z.jsx)(mg,{})})}));export{vc as $,tf as A,ro as At,ku as B,aa as Bt,lf as C,vo as Ct,af as D,po as Dt,uf as E,ho as Et,bd as F,Ra as Ft,el as G,su as H,na as Ht,xd as I,Na as It,jc as J,Ec as K,pd as L,Pa as Lt,Fd as M,$a as Mt,Cd as N,Ka as Nt,ef as O,uo as Ot,gd as P,Ma as Pt,mc as Q,fd as R,la as Rt,Ef as S,Do as St,of as T,_o as Tt,lu as U,Xi as Ut,Ou as V,fa as Vt,au as W,xc as X,Ac as Y,gc as Z,Ff as _,ko as _t,Kp as a,Zs as at,wf as b,Oo as bt,Fp as c,Us as ct,Gf as d,Ho as dt,bc as et,Qf as f,Io as ft,Mf as g,Ao as gt,kf as h,jo as ht,Gp as i,$s as it,zd as j,io as jt,nf as k,so as kt,xp as l,Vs as lt,Vf as m,Fo as mt,Jp as n,yc as nt,Hp as o,Js as ot,zf as p,Vo as pt,Tc as q,Up as r,cc as rt,Wp as s,Ks as st,eh as t,hc as tt,op as u,_s as ut,Pf as v,yo as vt,pf as w,go as wt,Tf as x,Eo as xt,Df as y,To as yt,hd as z,da as zt};
43
+ `)),T(!0)),x(!0))},[_.queriesText,b,p,f.isPending,T,w]),(0,X.useEffect)(()=>{b&&Gd(g,{...!C.saved&&C.text!==h?{queriesText:C.text}:{},..._.competitorsText===void 0?{}:{competitorsText:_.competitorsText}})},[_.competitorsText,g,C.saved,C.text,b,h]);let{emit:E,onboardingSessionId:D}=d;(0,X.useEffect)(()=>{b&&E({flowVersion:1,onboardingSessionId:D,event:`onboarding.started`,step:i===`first-check`?`run`:`queries`,resumed:!0},`onboarding.started`)},[E,i,D,b]);let O=(0,X.useRef)(null),k=(0,X.useRef)(v);(0,X.useEffect)(()=>{if(k.current===v)return;k.current=v;let e=O.current?.querySelector(`h2, h3`);e&&(e.tabIndex=-1,e.focus())},[v]);let A=(0,X.useRef)(null),j=(0,X.useRef)(!0);(0,X.useEffect)(()=>{if(!j.current)return;let e=document.activeElement;if(e&&e!==document.body){j.current=!1;return}let t=A.current?.querySelector(`h3`);t&&(j.current=!1,t.tabIndex=-1,t.focus())});let M=Wn(),N=uf(c,v===`first-check`&&!M),ee=Op(N.data),{systemBlockReason:P,blockedReason:F}=Np(n,t,S),I=F??(f.isSuccess&&m===0?`Add at least one query before launching the first check.`:void 0),L=Hp(),[R,z]=(0,X.useState)(!1),[te,ne]=(0,X.useState)(null),re=e.displayName||c,ie=async()=>{if(!M&&!(N.isError||N.isFetching||N.data?.canStart!==!0)){if(I)ne(I),S.usesProjectProviderReadiness||E({flowVersion:1,onboardingSessionId:D,event:`run.requested`,origin:`dashboard_setup`,result:`rejected`,providerCountBucket:lr(S.runnableProviderCount),queryCountBucket:lr(m),reasonCode:P??(m===0?`no_queries`:`run_rejected`)});else{z(!0),ne(null);try{let e=await L.mutateAsync({projectName:c,projectLabel:re,sourceAction:`setup-launch`,suppressQueuedToast:!0});en(c,e.id,J[`answer-visibility`]),s(e.id),S.usesProjectProviderReadiness||E({flowVersion:1,onboardingSessionId:D,event:`run.requested`,origin:`dashboard_setup`,result:`queued`,providerCountBucket:lr(S.runnableProviderCount),queryCountBucket:lr(m)})}catch(e){ne(e instanceof Error?e.message:`Failed to queue the AI Visibility check. Retry when the instance is ready.`),S.usesProjectProviderReadiness||E({flowVersion:1,onboardingSessionId:D,event:`run.requested`,origin:`dashboard_setup`,result:`rejected`,providerCountBucket:lr(S.runnableProviderCount),queryCountBucket:lr(m),reasonCode:Zt(e,`run_rejected`)})}finally{z(!1)}}}},ae=S.isAdmin&&(S.providerFormVisible||S.inlineModelPicker),oe=S.providerReadiness===!1&&!te;return(0,Z.jsxs)(`div`,{ref:A,children:[(0,Z.jsx)(fm,{current:v,done:{engine:S.providerReadiness===!0,queries:m>0,"first-check":!1},hasBaseline:a}),(0,Z.jsx)(`div`,{ref:O,children:v===`engine`?(0,Z.jsxs)(`div`,{className:`space-y-5`,children:[(0,Z.jsx)(Tp,{engines:S,headingLevel:`h3`}),(0,Z.jsxs)(`div`,{className:`setup-nav`,children:[(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:()=>S.providerGuard.request(o),children:`Back`}),(0,Z.jsx)(Y,{type:`button`,variant:ae?`secondary`:`default`,onClick:()=>S.providerGuard.request(()=>{S.closeProviderForm(),y(`queries`)}),children:`Continue`})]})]}):v===`queries`?(0,Z.jsx)(`div`,{className:`space-y-3`,"aria-labelledby":`setup-queries-heading`,children:(0,Z.jsx)(jp,{queries:C,headingLevel:`h3`,loading:f.isPending||!b,loadFailed:f.isError,onRetryLoad:()=>{f.refetch()},onBack:()=>y(`engine`),note:(0,Z.jsxs)(`p`,{className:`text-copy-13 text-secondary`,children:[`Queries naming `,re,` are branded. Results keep branded and non-brand queries apart.`]}),saveVariant:`default`})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ep,{engines:S}),(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`div`,{className:`section-head`,children:(0,Z.jsx)(`div`,{children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-heading-16 text-heading`,children:M?`AI Visibility`:a?`Run an AI Visibility check`:`Run your first AI Visibility check`}),M?null:(0,Z.jsx)(Pi,{text:Dp(re,ee)})]})})}),M?(0,Z.jsx)(Ap,{projectName:c,error:te,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{}),(0,Z.jsx)(Y,{type:`button`,onClick:()=>{l({to:`/projects/$projectName`,params:{projectName:c},replace:!0})},children:`Open project dashboard →`})]})}):(0,Z.jsx)(kp,{preview:N,details:[{label:`Website`,value:e.canonicalDomain},{label:`Market`,value:pt(e.country,e.language)}],queries:p??[],usesAccount:ee,alert:oe?null:te??I??null,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{type:`button`,variant:`outline`,onClick:()=>y(`queries`),children:`Back`}),oe?(0,Z.jsx)(Y,{type:`button`,onClick:()=>y(`engine`),children:`Connect an AI engine`}):(0,Z.jsx)(Y,{type:`button`,disabled:R||!!I||N.isError||N.isFetching||N.data?.canStart!==!0,title:I,onClick:Xr(ie),children:R?`Starting…`:te?`Retry check`:a?`Run check`:`Run first check`})]})})]})]})}),S.providerGuard.dialog]})}var gm=`Public pages only, read by this Canonry server and stored with this project. The first scan reads up to 100 pages, then stops.`,_m=En.enum;function vm(e){return e===K.queued||e===K.running}function ym(e){return e===K.not_started||e===K.cancelled||e===K.failed}function bm(e,t,n){return`${e} ${e===1?t:n}`}function xm({projectName:e,firstRun:t,track:n}){let r=Te(),i=be(),{canWrite:a,isAdmin:o}=Jr(),s=G({...Ei({client:q,path:{name:e}}),retry:!1,refetchInterval:({state:e})=>{let t=e.data;return t&&(vm(t.tracks.agentReadiness.state)||vm(t.tracks.aiVisibility.state))?3e3:!t?.complete&&15e3}}),c=G({...ui({client:q,path:{name:e}}),retry:!1}),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)(null),p=(0,X.useRef)(null),m=(0,X.useRef)(!1),h=s.data?.tracks.aiVisibility;(0,X.useEffect)(()=>{h&&(vm(h.state)?(m.current=!0,u(null)):n===`ai-visibility`&&!m.current&&(m.current=!0,u(Am(h.blockedBy))))},[n,h]);let g=()=>i.invalidateQueries({queryKey:Oi({client:q,path:{name:e}})}),_=Sm(e,s.data);Cm(s.data);let v=s.isSuccess;(0,X.useEffect)(()=>{v&&p.current?.focus({preventScroll:!0})},[v]);let y=e=>{r({to:`/setup`,search:t=>({...t,track:e}),replace:!0})},b=e=>{u(e),y(`ai-visibility`)},x=()=>{u(null),y(void 0)};if(s.isPending)return(0,Z.jsx)(Tm,{});if(s.isError){let n=ro(s.error).code===`NOT_FOUND`;return(0,Z.jsxs)(`div`,{className:`page-container max-w-3xl`,children:[(0,Z.jsx)(`h1`,{className:`text-heading-24 text-heading`,children:t?`Set up Canonry`:`Project setup`}),(0,Z.jsxs)(`div`,{role:`alert`,className:`mt-6 rounded-md border border-negative bg-negative-soft p-4`,children:[(0,Z.jsx)(`p`,{className:`text-copy-14-strong text-heading`,children:n?`No project named ${e}.`:`Setup status could not be loaded.`}),(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:n?(0,Z.jsx)(Y,{asChild:!0,variant:`secondary`,size:`sm`,children:(0,Z.jsx)(W,{to:`/projects`,children:`View projects`})}):(0,Z.jsx)(Y,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>{s.refetch()},children:`Retry`})})]})]})}let S=s.data,C=c.data,w=S.project.displayName||S.project.name,T=Yt(S.project.canonicalDomain),E=C?pt(C.country,C.language):null,D=S.tracks.agentReadiness,O=S.tracks.aiVisibility,k=d!==null&&O.runId===d.listedRunId&&O.runId!==d.runId,A=a&&l!==null&&!vm(O.state),j=A||!a?null:ym(D.state)?`agent-readiness`:ym(O.state)&&!k?`ai-visibility`:null;return(0,Z.jsxs)(`div`,{className:`page-container max-w-3xl`,children:[(0,Z.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-x-4 gap-y-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h1`,{ref:p,tabIndex:-1,className:`text-heading-24 text-heading outline-none`,children:t?`Set up Canonry`:`Project setup`}),(0,Z.jsxs)(`p`,{className:`mt-1 text-copy-14 text-secondary`,children:[S.complete?`Setup complete · `:null,w,` · `,T]})]}),(0,Z.jsx)(Y,{asChild:!0,variant:S.complete?`default`:`ghost`,className:`shrink-0`,children:(0,Z.jsxs)(W,{to:`/projects/$projectName`,params:{projectName:e},children:[`Open project`,S.complete?null:(0,Z.jsx)(N,{className:`size-4`,"aria-hidden":`true`})]})})]}),(0,Z.jsxs)(Qd,{label:`Setup progress`,children:[(0,Z.jsx)($d,{id:`setup-website`,title:`Website`,mark:`done`,summary:E?`${T} · ${E}`:T,trailing:a?(0,Z.jsxs)(W,{className:`shrink-0 text-label-14 text-secondary underline underline-offset-4 hover:text-primary`,to:`/projects/$projectName/settings`,params:{projectName:e},children:[`Edit`,(0,Z.jsx)(`span`,{className:`sr-only`,children:` website`})]}):null}),(0,Z.jsx)(km,{projectName:e,projectId:C?.id??null,brand:w,track:D,primary:j===`agent-readiness`,canWrite:a,onStarted:async e=>{_(e,J[`site-audit`]),await g()},onCancelled:g}),(0,Z.jsx)(Mm,{projectName:e,brand:w,domain:T,track:O,panelStep:A?l:null,onOpenPanel:b,onClosePanel:x,starting:k,onLaunched:e=>{_(e,J[`answer-visibility`]),f({runId:e,listedRunId:O.runId}),x(),g()},onCancelled:g,primary:j===`ai-visibility`,canWrite:a,isAdmin:o})]}),(0,Z.jsx)(`p`,{role:`status`,className:`sr-only`,children:Em(D)}),(0,Z.jsx)(`p`,{role:`status`,className:`sr-only`,children:Dm(O,k?K.queued:O.state)}),S.complete?(0,Z.jsx)(hf,{projectName:e}):null]})}function Sm(e,t){let{emit:n,onboardingSessionId:r}=qd(`site_health`),{emit:i,onboardingSessionId:a}=qd(`wizard`),o=(0,X.useRef)(new Map);return(0,X.useEffect)(()=>{let t=Re(e);t?.kind&&o.current.set(t.runId,t.kind)},[e]),(0,X.useEffect)(()=>{if(!t)return;let e=[{...t.tracks.agentReadiness,kind:J[`site-audit`],answers:null},{...t.tracks.aiVisibility,kind:J[`answer-visibility`],answers:t.tracks.aiVisibility.result?.answers??null}];for(let{runId:t,state:s,kind:c,answers:l}of e){if(!t||o.current.get(t)!==c)continue;let e=c===J[`site-audit`]?{emit:n,onboardingSessionId:r}:{emit:i,onboardingSessionId:a},u=(s===K.completed||s===K.partial)&&l!==0,d=s===K.cancelled?`run_cancelled`:s===K.failed||(s===K.completed||s===K.partial)&&l===0?`run_failed`:null;if(u)e.emit({flowVersion:1,onboardingSessionId:e.onboardingSessionId,event:`onboarding.step_completed`,step:`run`,method:`automatic`,...l===null?{}:{countBucket:lr(l)}},`onboarding.step_completed:run:${t}`);else if(d)e.emit({flowVersion:1,onboardingSessionId:e.onboardingSessionId,event:`onboarding.blocked`,step:`run`,action:`retry_run`,reasonCode:d},`onboarding.blocked:run:${t}:${d}`);else continue;o.current.delete(t),lt(t)}},[a,i,n,r,t]),(t,i)=>{o.current.set(t,i),i===J[`site-audit`]&&(en(e,t,i),n({flowVersion:1,onboardingSessionId:r,event:`onboarding.started`,step:`run`,resumed:!1},`onboarding.started:${t}`))}}function Cm(e){let t=be(),n=e?.tracks.agentReadiness.state,r=e?.tracks.aiVisibility.state,i=(0,X.useRef)({});(0,X.useEffect)(()=>{let e=i.current;i.current={scan:n,check:r};let a=(e,t)=>e!==void 0&&t!==void 0&&vm(e)&&!vm(t);(a(e.scan,n)||a(e.check,r))&&t.invalidateQueries({queryKey:Mi({client:q})})},[n,r,t])}function wm({runIds:e,noun:t,note:n,onCancelled:r}){let[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(null),c=Fe({...yi({client:q}),meta:{skipGlobalErrorToast:!0}}),l=(0,X.useRef)(null),u=(0,X.useRef)(null),d=(0,X.useRef)(!1);(0,X.useEffect)(()=>{d.current&&(d.current=!1,(i?u:l).current?.focus())},[i]);let f=e=>{d.current=!0,s(null),a(e)},p=async()=>{if(c.isPending)return;s(null);let n=(await Promise.allSettled(e.map(e=>c.mutateAsync({path:{id:e}})))).find(e=>e.status===`rejected`&&ro(e.reason).code!==`RUN_NOT_CANCELLABLE`);n&&s(`The ${t} could not be stopped. ${dt(n.reason)}`),await r()};return i?(0,Z.jsxs)(`div`,{role:`group`,"aria-label":`Stop the ${t}`,className:`flex flex-wrap items-center justify-end gap-x-3 gap-y-2`,children:[(0,Z.jsxs)(`p`,{className:`text-copy-14 text-secondary`,children:[`Stop the `,t,`? `,n]}),(0,Z.jsxs)(`div`,{className:`flex gap-2 max-sm:w-full max-sm:[&>*]:flex-1`,children:[(0,Z.jsx)(Y,{ref:u,type:`button`,variant:`ghost`,"aria-disabled":c.isPending||void 0,onClick:()=>{c.isPending||f(!1)},children:`Keep running`}),(0,Z.jsx)(Y,{type:`button`,variant:`secondary`,"aria-disabled":c.isPending||void 0,onClick:()=>{p()},children:c.isPending?`Stopping…`:`Stop ${t}`})]}),o?(0,Z.jsx)(`p`,{role:`alert`,className:`w-full text-right text-copy-14 text-negative`,children:o}):null]}):(0,Z.jsxs)(Y,{ref:l,type:`button`,variant:`ghost`,"data-focus-skip":!0,onClick:()=>f(!0),children:[`Cancel `,t]})}function Tm(){return(0,Z.jsxs)(`div`,{className:`page-container max-w-3xl`,"aria-busy":`true`,children:[(0,Z.jsx)(`div`,{className:`skeleton-text h-6 w-40`}),(0,Z.jsx)(`div`,{className:`skeleton-text-sm mt-2 w-56`}),(0,Z.jsx)(`div`,{className:`material-base mt-6 space-y-6 p-5`,children:[1,2,3].map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`div`,{className:`skeleton-text w-32`}),(0,Z.jsx)(`div`,{className:`skeleton-text-sm w-64`})]}),(0,Z.jsx)(`div`,{className:`skeleton h-5 w-20 rounded-md`})]},e))})]})}function Em(e){switch(e.state){case K.not_started:return``;case K.queued:return`Agent Readiness audit scan queued.`;case K.running:return`Agent Readiness audit scan running.`;case K.completed:case K.partial:{let t=e.state===K.partial?`Agent Readiness audit scan stopped partway.`:`Agent Readiness audit scan complete.`,n=e.result?.score??null;return n===null?t:`${t} Score ${Math.round(n)} of 100.`}case K.failed:return`Agent Readiness audit scan failed.`;case K.cancelled:return`Agent Readiness audit scan cancelled.`;default:return e.state}}function Dm(e,t){switch(t){case K.not_started:return``;case K.queued:return`AI Visibility check queued.`;case K.running:return`AI Visibility check running.`;case K.completed:case K.partial:{let n=t===K.partial?`AI Visibility check stopped partway.`:`AI Visibility check complete.`,r=e.result;return r?`${n} ${bm(r.answers,`answer`,`answers`)} from ${bm(r.engines,`engine`,`engines`)}.`:n}case K.failed:return`AI Visibility check failed.`;case K.cancelled:return`AI Visibility check cancelled.`;default:return t}}function Om(e){let t=e.progress;if(!t)return{phase:e.state===K.queued?`Waiting to start`:`Starting the scan`,count:null,done:null,total:null};switch(t.phase){case _m.queued:return{phase:`Waiting to start`,count:null,done:null,total:null};case _m.discovering:return{phase:`Finding pages`,count:t.pagesFound===null?null:`${t.pagesFound} found`,done:null,total:null};case _m.checking:{let e=t.pagesFound,n=t.pageLimit;return e!==null&&(n===null||e<n)?{phase:`Checking pages`,count:`${t.pagesChecked} of ${e}`,done:t.pagesChecked,total:e}:{phase:`Checking pages`,count:n===null?`${t.pagesChecked} checked`:`${t.pagesChecked} of up to ${n}`,done:t.pagesChecked,total:n}}case _m[`arranging-map`]:return{phase:`Building the score`,count:bm(t.pagesChecked,`page checked`,`pages checked`),done:null,total:null};case _m.completed:case _m.partial:case _m.failed:case _m.cancelled:return{phase:`Finishing`,count:null,done:null,total:null};default:return t.phase}}function km({projectName:e,projectId:t,brand:n,track:r,primary:i,canWrite:a,onStarted:o,onCancelled:s}){let c=Wp(),{onboardingSessionId:l,emit:u}=qd(`platform`),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(!1),h=r.state,g=async()=>{if(t&&!p){f(null),m(!0);try{let r=await c.mutateAsync({projectName:e,projectId:t,projectLabel:n,suppressErrorToast:!0,suppressQueuedToast:!0,body:{checkDeadLinks:!0,maxPages:100,sites:[]}});u({flowVersion:1,onboardingSessionId:l,event:`run.requested`,origin:`dashboard_setup`,result:`queued`,kind:`site_health`,providerCountBucket:`0`,queryCountBucket:`0`}),await o(r.runId)}catch(e){f(`The audit scan could not start. ${dt(e)}`),u({flowVersion:1,onboardingSessionId:l,event:`run.requested`,origin:`dashboard_setup`,result:`rejected`,kind:`site_health`,providerCountBucket:`0`,queryCountBucket:`0`,reasonCode:Zt(e,`run_rejected`)})}finally{m(!1)}}},_=e=>a?(0,Z.jsx)(Y,{type:`button`,variant:i?`default`:`secondary`,disabled:!t,"aria-disabled":p||void 0,className:p?`opacity-50`:void 0,onClick:()=>{g()},children:p?`Starting…`:e}):null,v=null,y=null,b=null;switch(h){case K.not_started:case K.cancelled:v=(0,Z.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-1.5`,children:[h===K.cancelled?`The last scan was cancelled. `:null,`Reads up to `,100,` public pages. No AI engine needed.`,(0,Z.jsx)(Pi,{text:gm})]}),b=_(h===K.cancelled?`Run audit scan again`:`Run audit scan`);break;case K.queued:case K.running:{let e=Om(r),t=r.progress;y=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(gf,{label:`Agent Readiness audit scan progress`,noun:`scan`,phase:e.phase,count:e.count,done:e.done,total:e.total,startedAt:r.startedAt}),t?(0,Z.jsxs)(`details`,{className:`mt-2`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer py-1 text-label-14 text-secondary`,children:`Scan details`}),(0,Z.jsx)(`dl`,{className:`mt-2 grid grid-cols-2 gap-x-6 gap-y-3 sm:grid-cols-4`,children:[[`Pages found`,t.pagesFound],[`Pages checked`,t.pagesChecked],[`Links found`,t.linksFound],[`Pages failed`,t.pagesFailed]].map(([e,t])=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-label-13 text-secondary`,children:e}),(0,Z.jsx)(`dd`,{className:`text-label-14-strong tabular-nums text-heading`,children:t===null?`Unavailable`:t.toLocaleString()})]},e))})]}):null]}),b=a&&r.runId?(0,Z.jsx)(wm,{runIds:[r.runId],noun:`scan`,note:`It saves no score.`,onCancelled:s},r.runId):null;break}case K.completed:case K.partial:{let t=r.result;v=h===K.partial?`The scan stopped before it reached every page.`:null,y=t?(0,Z.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`text-heading-20 tabular-nums text-heading`,children:t.score===null?`–`:Math.round(t.score)}),(0,Z.jsxs)(`span`,{className:`text-label-14 text-secondary`,children:[t.score===null?`Score unavailable`:h===K.partial?`of 100 so far`:`of 100`,` · `,bm(t.pagesScored,`page scored`,`pages scored`)]})]}):(0,Z.jsx)(`p`,{className:`text-copy-14 text-secondary`,children:`The scan finished.`}),b=(0,Z.jsx)(Y,{asChild:!0,variant:`ghost`,children:(0,Z.jsxs)(W,{to:`/projects/$projectName/agent-readiness`,params:{projectName:e},children:[`Open Agent Readiness`,(0,Z.jsx)(N,{className:`size-4`,"aria-hidden":`true`})]})});break}case K.failed:v=`The scan did not finish.${r.error?` ${r.error}`:``}`,b=_(`Run audit scan again`);break;default:return h}return(0,Z.jsxs)($d,{id:`setup-agent-readiness`,title:`Agent Readiness`,mark:Xd(h),summary:v,trailing:(0,Z.jsx)(Yd,{state:h}),action:b,children:[y,d?(0,Z.jsx)(`p`,{role:`alert`,className:`${y?`mt-3 `:``}text-copy-14 text-negative`,children:d}):null]})}function Am(e){switch(e){case null:return`first-check`;case Dr.no_engine:case Dr.engines_failing:return`engine`;case Dr.no_queries:return`queries`;case Dr.plan_unpublished:return null;default:return e}}function jm(e,t,n){let r=`Whether AI answers mention ${t} and cite ${n}.`,i=e.baselineRunId===null;switch(e.blockedBy){case Dr.no_engine:return{line:`${r} Needs an AI engine.`,action:`Connect an AI engine`,step:`engine`};case Dr.no_queries:return{line:`${r} Add queries to check.`,action:`Add queries`,step:`queries`};case Dr.plan_unpublished:return{line:`Publish the measurement plan before the ${i?`first`:`next`} check.`,action:`Open measurement plan`,step:`plan`};case Dr.engines_failing:return{line:`${r} The AI engine connection needs attention.`,action:`Repair connection`,step:`engine`};case null:{let t=e.engines.length;return{line:`Asks ${bm(t,`engine`,`engines`)} your ${bm(e.queries.total,`query`,`queries`)}.`,action:i?`Review first check`:`Review check`,step:`first-check`}}default:return e.blockedBy}}function Mm({projectName:e,brand:t,domain:n,track:r,panelStep:i,onOpenPanel:a,onClosePanel:o,onLaunched:s,onCancelled:c,starting:l,primary:u,canWrite:d,isAdmin:f}){let p=l?K.queued:r.state,m=u?`default`:`secondary`;if(i!==null)return(0,Z.jsx)($d,{id:`setup-ai-visibility`,title:`AI Visibility`,mark:Xd(p),trailing:(0,Z.jsx)(Yd,{state:p}),childrenManageFocus:!0,children:(0,Z.jsx)(mm,{projectName:e,initialStep:i,hasBaseline:r.baselineRunId!==null,onClose:o,onLaunched:s})});let h=null,g=null,_=null;switch(p){case K.not_started:case K.cancelled:{let i=jm(r,t,n);if(h=p===K.cancelled?`The last check was cancelled. ${i.line}`:i.line,d){let t=i.step;_=t===`plan`?(0,Z.jsx)(Y,{asChild:!0,variant:m,children:(0,Z.jsx)(W,{to:`/projects/$projectName/portfolio`,params:{projectName:e},children:i.action})}):(0,Z.jsx)(Y,{type:`button`,variant:m,onClick:()=>a(t),children:i.action})}break}case K.queued:case K.running:{let e=r.progress,t=e?e.answersPlanned!==null&&e.answersSaved<=e.answersPlanned?`${e.answersSaved} of ${bm(e.answersPlanned,`answer`,`answers`)} saved`:`${bm(e.answersSaved,`answer`,`answers`)} saved`:null;g=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(gf,{label:`AI Visibility check progress`,noun:`check`,phase:p===K.queued?`Waiting to start`:`Asking engines`,count:t,done:e?.answersSaved??null,total:e?.answersPlanned??null,startedAt:r.startedAt}),Object.entries(r.providerFailures??{}).map(([e,t])=>(0,Z.jsxs)(`div`,{role:`status`,className:`mt-3 rounded-md border border-caution px-3 py-2`,children:[(0,Z.jsxs)(`p`,{className:`text-copy-14 text-primary`,children:[Pr(e),`: `,bm(t.failedQueries,`query`,`queries`),` failed`,t.stopped?`, so this check stopped asking it`:``,`.`]}),(0,Z.jsxs)(`details`,{className:`mt-1`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer text-label-13 text-secondary`,children:`Engine message`}),(0,Z.jsx)(`p`,{className:`mt-1 break-words text-copy-13 text-secondary`,children:t.message})]})]},e)),(0,Z.jsxs)(`details`,{className:`mt-2`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer py-1 text-label-14 text-secondary`,children:`Check details`}),(0,Z.jsxs)(`dl`,{className:`mt-2 grid gap-x-6 gap-y-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-label-13 text-secondary`,children:`Engines`}),(0,Z.jsx)(`dd`,{className:`text-label-14 text-heading`,children:r.engines.length>0?r.engines.map(e=>Pr(e)).join(`, `):`Unavailable`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-label-13 text-secondary`,children:`Queries`}),(0,Z.jsxs)(`dd`,{className:`text-label-14 tabular-nums text-heading`,children:[bm(r.queries.nonBrand,`non-brand`,`non-brand`),` · `,bm(r.queries.branded,`branded`,`branded`)]})]})]})]})]}),_=d&&!l&&r.runId?(0,Z.jsx)(wm,{runIds:r.runIds,noun:`check`,note:r.baselineRunId===null?`It saves no baseline.`:`Earlier results stay as they are.`,onCancelled:c},r.runId):null;break}case K.completed:case K.partial:{let t=r.result,n=r.runId!==null&&r.runId===r.baselineRunId;h=t?`${p===K.partial?`Partial results`:n?`Baseline`:`Latest check`} · ${bm(t.answers,`answer`,`answers`)} from ${bm(t.engines,`engine`,`engines`)}${r.finishedAt?` · ${Ur(r.finishedAt)}`:``}`:`The check finished.`,g=t?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Sf,{byClass:t.queryCountsByClass,pooled:t.queryCounts,caption:n?void 0:`Latest AI Visibility check by query class`}),n?(0,Z.jsx)(`p`,{className:`mt-3 text-copy-13 text-secondary`,children:`Later checks are compared with this baseline.`}):null,r.runId?(0,Z.jsx)(Nm,{runId:r.runId,projectName:e}):null]}):null,_=(0,Z.jsx)(Y,{asChild:!0,variant:`ghost`,children:(0,Z.jsxs)(W,{to:`/projects/$projectName`,params:{projectName:e},children:[`Open AI Visibility`,(0,Z.jsx)(N,{className:`size-4`,"aria-hidden":`true`})]})});break}case K.failed:{h=r.baselineRunId===null?`The check did not finish. No baseline was saved.`:`The check did not finish. Earlier results are unchanged.`;let e=f?null:(0,Z.jsx)(`p`,{className:`text-copy-14 text-secondary`,children:`Ask an administrator to check the AI engine connection.`}),t=r.failedEngines??[];g=t.length>0?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[t.map(e=>{let t=Pr(e.provider),n=Ke(e.code,Pr(xr(e.provider)));return(0,Z.jsx)(`div`,{className:`rounded-md border border-caution px-3 py-2`,children:n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`text-copy-14 text-primary`,children:n}),(0,Z.jsxs)(`details`,{className:`mt-1`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer text-label-13 text-secondary`,children:`Engine message`}),(0,Z.jsxs)(`p`,{className:`mt-1 break-words text-copy-13 text-secondary`,children:[t,`: `,e.message]})]})]}):(0,Z.jsxs)(`p`,{className:`break-words text-copy-14 text-primary`,children:[t,`: `,e.message]})},e.provider)}),e]}):r.error?(0,Z.jsxs)(`div`,{className:`rounded-md border border-caution px-3 py-2`,children:[(0,Z.jsx)(`p`,{className:`break-words text-copy-14 text-primary`,children:r.error}),e?(0,Z.jsx)(`div`,{className:`mt-1`,children:e}):null]}):null,d&&(_=(0,Z.jsxs)(Z.Fragment,{children:[f?(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,onClick:()=>a(`engine`),children:`Change AI engines`}):null,(0,Z.jsx)(Y,{type:`button`,variant:m,onClick:()=>a(`first-check`),children:`Run check again`})]}));break}default:return p}return(0,Z.jsx)($d,{id:`setup-ai-visibility`,title:`AI Visibility`,mark:Xd(p),summary:h,trailing:(0,Z.jsx)(Yd,{state:p}),action:_,children:g})}function Nm({runId:e,projectName:t}){let[n,r]=(0,X.useState)(!1),i=G({..._i({client:q,path:{id:e}}),enabled:n}),a=G({...fi({client:q,path:{name:t}}),enabled:n}),o=i.data?vf(i.data.snapshots??[],e=>a.data?.find(t=>t.id===e)?.queryClass):void 0;return(0,Z.jsxs)(`details`,{className:`mt-3`,onToggle:e=>r(e.currentTarget.open),children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer py-1 text-label-14 text-link`,children:`Example answer`}),(0,Z.jsx)(`div`,{className:`mt-3 border-t border-default pt-4`,children:i.isPending?(0,Z.jsx)(`p`,{role:`status`,className:`text-copy-14 text-secondary`,children:`Loading the answer…`}):i.isError?(0,Z.jsx)(`p`,{role:`alert`,className:`text-copy-14 text-negative`,children:`The answer could not be loaded.`}):o?(0,Z.jsx)(Cf,{answer:o}):(0,Z.jsx)(`p`,{className:`text-copy-14 text-secondary`,children:`This check saved no answer text.`})})]})}var Pm=`pointer-coarse:min-h-11 max-md:min-h-11`,Fm=`setup-input h-10 w-full max-md:text-label-16 ${Pm}`,Im=[{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`}],Lm=[{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 Rm(e,t){let n=e.trim().toUpperCase(),r=t.trim().toLowerCase();return{countryValid:Im.some(e=>e.value===n),languageValid:Lm.some(e=>e.value===r)}}function zm(e){let t=e.replace(/^\[|\]$/g,``);return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(t)||t.includes(`:`)}function Bm(e){let t=e.trim();if(!t)return null;let n=/^[a-z][a-z\d+.-]*:\/\//i.test(t)?t:`https://${t}`,r;try{r=new URL(n)}catch{return null}if(r.protocol!==`http:`&&r.protocol!==`https:`)return null;let i=r.hostname.toLowerCase().replace(/^www\./,``);if(!i||i===`localhost`||zm(i)||!i.includes(`.`))return null;let a=ht(i);return a?{canonicalDomain:i,projectName:a,displayName:Rt(i)}:null}function Vm(e,t){return e instanceof ir&&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:t}function Hm(){return(0,Z.jsxs)(`div`,{className:`page-container max-w-3xl`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,Z.jsx)(`div`,{className:`page-header`,children:(0,Z.jsxs)(`div`,{className:`page-header-left`,children:[(0,Z.jsx)(`h1`,{className:`page-title`,children:`Preparing setup`}),(0,Z.jsx)(`p`,{className:`page-subtitle`,children:`Checking the projects already on this install.`})]})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 material-base p-4 text-label-14 text-secondary`,role:`status`,children:[(0,Z.jsx)(s,{className:`size-4 motion-safe:animate-spin`,"aria-hidden":`true`}),`Loading projects…`]})]})}function Um({onRetry:e}){return(0,Z.jsxs)(`div`,{className:`page-container max-w-3xl`,children:[(0,Z.jsx)(`div`,{className:`page-header`,children:(0,Z.jsxs)(`div`,{className:`page-header-left`,children:[(0,Z.jsx)(`h1`,{className:`page-title`,children:`Can’t load projects`}),(0,Z.jsx)(`p`,{className:`page-subtitle`,children:`Canonry could not confirm whether this install already has a project.`})]})}),(0,Z.jsxs)(`div`,{className:`rounded-md border border-negative bg-negative-soft p-4`,role:`alert`,tabIndex:-1,children:[(0,Z.jsx)(`p`,{className:`text-copy-14-strong text-heading`,children:`Setup is paused to protect existing projects.`}),(0,Z.jsx)(`p`,{className:`mt-1 text-copy-14 text-secondary`,children:`Check the connection or sign in again, then retry.`}),(0,Z.jsx)(Y,{type:`button`,className:`mt-4`,variant:`secondary`,onClick:e,children:`Retry project check`})]})]})}function Wm(){let e=Ee({from:`/setup`});if(e.experience===`legacy`||e.experience!==`platform`&&ur()===`legacy`)return(0,Z.jsx)(cm,{visibilityProjectName:e.setupProject??e.project});let t=e.project??e.setupProject;if(t){let n=e.track??(e.onboarding===`site-health`?`agent-readiness`:void 0);return(0,Z.jsx)(xm,{projectName:t,firstRun:e.onboarding!==void 0,track:n},t)}let n=e.experience===`platform`;return(0,Z.jsx)(Gm,{addProject:n},n?`add-project`:`entry`)}function Gm({addProject:e}){let t=Te(),n=G({...wi({client:q}),retry:!1,refetchOnMount:`always`}),r=n.isSuccess&&n.isFetchedAfterMount,i=!e&&r&&n.data.length===1?n.data[0]:void 0,a=G({...Ei({client:q,path:{name:i?.name??``}}),enabled:i!==void 0,retry:!1}),[o,s]=(0,X.useState)(null);return(0,X.useEffect)(()=>{if(o||!r)return;let t=n.data;if(e||t.length===0)s({firstRun:t.length===0});else if(i){if(a.isPending)return;s(a.data?.complete===!0?{addProject:!0}:{redirectTo:i.name})}else s({addProject:!0})},[e,o,r,i,a.data,a.isPending,n.data]),(0,X.useEffect)(()=>{o&&(`redirectTo`in o?t({to:`/setup`,search:{project:o.redirectTo,onboarding:`first-run`},replace:!0}):`addProject`in o&&t({to:`/setup`,search:{experience:`platform`},replace:!0}))},[o,t]),!o&&n.isError?(0,Z.jsx)(Um,{onRetry:()=>{n.refetch()}}):!o||`redirectTo`in o||`addProject`in o?(0,Z.jsx)(Hm,{}):(0,Z.jsx)(Km,{firstRun:o.firstRun})}function Km({firstRun:e}){return(0,Z.jsx)(Rr,{title:e?`Set up Canonry`:`Add a project`,children:(0,Z.jsx)(qm,{firstRun:e})})}function qm({firstRun:e}){let t=Te(),n=be(),r=e&&jr(),i=G({...li({client:q}),enabled:r,retry:!1}),a=Fe(Si()),[o]=(0,X.useState)(()=>Wd(`platform`)),[c,l]=(0,X.useState)(o.domain??``),[u,d]=(0,X.useState)(o.projectName??``),[f,p]=(0,X.useState)(o.displayName??``),[m,h]=(0,X.useState)(o.country??`US`),[g,_]=(0,X.useState)(o.language??`en`),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(null),[w,T]=(0,X.useState)(null),D=G({...wi({client:q}),enabled:w!==null,retry:!1}),O=w===null?null:D.data?.find(e=>ht(e.name)===w)?.name??w,A=!r||i.isError?void 0:i.data,j=typeof A?.enabled==`boolean`?A.enabled:null,M=a.isPending?a.variables.body.enabled:j,[N,ee]=(0,X.useState)(null),P=(0,X.useRef)(null),F=(0,X.useRef)(null),I=(0,X.useRef)(null),{onboardingSessionId:L,emit:R}=qd(`platform`);(0,X.useEffect)(()=>{R({flowVersion:1,onboardingSessionId:L,event:`onboarding.started`,step:`project`,resumed:!1},`onboarding.started`)},[R,L]),(0,X.useEffect)(()=>{Gd(`platform`,{domain:c,projectName:u,displayName:f,country:m,language:g})},[c,u,f,m,g]);let z=()=>{Kd(`platform`),l(``),d(``),p(``),h(`US`),_(`en`),C(null),T(null)},te=Bm(c),ne=u.trim()||te?.projectName||``,re=f.trim()||te?.displayName||``,ie=pt(m,g),{countryValid:ae,languageValid:oe}=Rm(m,g),se=ae&&oe,ce=!!(c||u||f||m!==`US`||g!==`en`),B=!!(c&&!te&&b);(0,X.useEffect)(()=>{S&&(w!==null&&I.current?(F.current&&(F.current.open=!0),I.current.focus()):P.current?.focus())},[w,S]);let V=async r=>{if(r.preventDefault(),x(!0),te&&se&&!v){y(!0),C(null),T(null);try{let r=await Vn({name:ne,displayName:re,canonicalDomain:te.canonicalDomain,country:m,language:g});Kd(`platform`),R({flowVersion:1,onboardingSessionId:L,event:`onboarding.step_completed`,step:`project`,method:`manual`},`onboarding.step_completed:project`),await n.invalidateQueries({queryKey:Ni({client:q})}),await t({to:`/setup`,search:{project:r.name,...e?{onboarding:`first-run`}:{}},replace:!0})}catch(e){y(!1);let t=e instanceof ir&&e.statusCode===409;T(t?ht(ne):null),C(Vm(e,`Could not create the project. Try again.`)),R({flowVersion:1,onboardingSessionId:L,event:`onboarding.blocked`,step:`project`,action:`save`,reasonCode:Zt(e,`project_create_failed`)},`onboarding.blocked:project`),t&&n.invalidateQueries({queryKey:Ni({client:q})})}}},le=async e=>{ee(null);try{let t=await a.mutateAsync({client:q,body:{enabled:e}});n.setQueryData(ci({client:q}),t),t.enabled!==e&&ee(`The server kept telemetry ${t.enabled?`on`:`off`}. Check its telemetry settings.`)}catch{ee(`Could not update telemetry. Try again.`)}};return(0,Z.jsxs)(`div`,{className:`page-container max-w-3xl`,children:[(0,Z.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-x-4 gap-y-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h1`,{className:`text-heading-24 text-heading`,children:e?`Set up Canonry`:`Add a project`}),e?(0,Z.jsx)(`p`,{className:`mt-1 max-w-prose text-copy-14 text-secondary`,children:`Add your first website to get its Agent Readiness score and first AI Visibility result.`}):null]}),e?(0,Z.jsx)(Y,{asChild:!0,variant:`ghost`,className:`shrink-0`,children:(0,Z.jsxs)(W,{to:`/agent-setup`,children:[(0,Z.jsx)(k,{className:`size-4`,"aria-hidden":`true`}),`Set up with an agent`]})}):null]}),(0,Z.jsxs)(Qd,{label:`Setup progress`,children:[(0,Z.jsx)($d,{id:`setup-website`,title:`Website`,mark:`idle`,trailing:(0,Z.jsx)(br,{tone:`neutral`,className:`shrink-0`,children:`Required`}),children:(0,Z.jsxs)(`form`,{"aria-label":`Website`,className:`space-y-5`,onSubmit:Xr(V),noValidate:!0,children:[(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`label`,{className:`text-label-14-strong text-heading`,htmlFor:`launchpad-domain`,children:`Website URL`}),(0,Z.jsx)(`input`,{id:`launchpad-domain`,className:Fm,type:`text`,inputMode:`url`,autoComplete:`url`,autoCapitalize:`none`,spellCheck:!1,required:!0,"aria-invalid":B,"aria-describedby":B?`launchpad-domain-error`:void 0,placeholder:`https://example.com`,value:c,onBlur:()=>x(!0),onChange:e=>{l(e.target.value),C(null),T(null)}}),B?(0,Z.jsx)(`p`,{id:`launchpad-domain-error`,className:`text-copy-14 text-negative`,role:`alert`,children:`Enter a public domain, such as example.com.`}):null]}),(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`label`,{className:`text-label-14-strong text-heading`,htmlFor:`launchpad-display-name`,children:`Brand name`}),(0,Z.jsx)(`input`,{id:`launchpad-display-name`,className:Fm,type:`text`,autoComplete:`organization`,"aria-describedby":`launchpad-display-name-hint`,placeholder:te?.displayName??`Your brand`,value:f,onChange:e=>p(e.target.value)}),(0,Z.jsx)(`p`,{id:`launchpad-display-name-hint`,className:`text-copy-13 text-secondary`,children:`Answers that name this brand count as mentions.`})]}),(0,Z.jsxs)(`details`,{ref:F,className:`group border-t border-default`,children:[(0,Z.jsxs)(`summary`,{className:`flex min-h-9 cursor-pointer list-none items-center justify-between gap-4 py-2 text-label-14 [&::-webkit-details-marker]:hidden ${Pm}`,children:[(0,Z.jsx)(`span`,{className:`text-label-14-strong text-heading`,children:`Project details`}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-2 text-secondary`,children:[ie,(0,Z.jsx)(E,{className:`size-4 transition-transform group-open:rotate-180 motion-reduce:transition-none`,"aria-hidden":`true`})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-5 pb-4 pt-2`,children:[te?(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:max-w-[50%]`,children:[(0,Z.jsx)(`label`,{className:`text-label-14 text-secondary`,htmlFor:`launchpad-project-name`,children:`Project name`}),(0,Z.jsx)(`input`,{ref:I,id:`launchpad-project-name`,className:Fm,type:`text`,placeholder:te.projectName,"aria-invalid":w!==null,"aria-describedby":w===null?void 0:`launchpad-create-error`,value:u,onChange:e=>{d(e.target.value),w!==null&&(T(null),C(null))}})]}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`label`,{className:`text-label-14 text-secondary`,htmlFor:`launchpad-country`,children:`Country`}),(0,Z.jsx)(`select`,{id:`launchpad-country`,className:Fm,value:m,onChange:e=>h(e.target.value),children:Im.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`label`,{className:`text-label-14 text-secondary`,htmlFor:`launchpad-language`,children:`Language`}),(0,Z.jsx)(`select`,{id:`launchpad-language`,className:Fm,value:g,onChange:e=>_(e.target.value),children:Lm.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]})]})]}),S?(0,Z.jsxs)(`div`,{ref:P,className:`rounded-md border border-negative bg-negative-soft p-3`,role:`alert`,tabIndex:-1,children:[(0,Z.jsx)(`p`,{id:`launchpad-create-error`,className:`text-copy-14-strong text-heading`,children:S}),O===null?null:(0,Z.jsx)(Y,{asChild:!0,variant:`secondary`,size:`sm`,className:`mt-3`,children:(0,Z.jsxs)(W,{to:`/projects/$projectName`,params:{projectName:O},children:[`Open `,O]})})]}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 max-sm:[&>*]:w-full`,children:[ce?(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,disabled:v,onClick:z,children:`Reset unsaved fields`}):null,e?null:(0,Z.jsx)(Y,{asChild:!0,variant:`ghost`,className:Pm,children:(0,Z.jsx)(W,{to:`/projects`,onClick:()=>Kd(`platform`),children:`Cancel`})}),(0,Z.jsx)(Y,{className:Pm,type:`submit`,disabled:!te||!se||v,children:v?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(s,{className:`size-4 motion-safe:animate-spin`,"aria-hidden":`true`}),` Creating project…`]}):`Continue`})]})]})}),(0,Z.jsx)($d,{id:`setup-agent-readiness`,title:`Agent Readiness`,mark:`idle`,summary:`How well AI agents can read your site`,trailing:(0,Z.jsx)(Yd,{state:K.not_started})}),(0,Z.jsx)($d,{id:`setup-ai-visibility`,title:`AI Visibility`,mark:`idle`,summary:`Whether AI answers mention your brand and cite your site`,trailing:(0,Z.jsx)(Yd,{state:K.not_started})})]}),j===null?null:(0,Z.jsxs)(`section`,{className:`mt-6 border-t border-default pt-5`,"aria-labelledby":`telemetry-title`,children:[(0,Z.jsxs)(`label`,{className:`flex min-h-11 items-start gap-3 py-2 ${a.isPending?`cursor-wait`:`cursor-pointer`}`,children:[(0,Z.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:M??!1,disabled:a.isPending,onChange:e=>{le(e.target.checked)},"aria-describedby":`telemetry-detail`}),(0,Z.jsxs)(`span`,{className:`grid gap-0.5`,children:[(0,Z.jsx)(`span`,{id:`telemetry-title`,className:`text-label-14 text-heading`,children:`Share anonymous product telemetry`}),(0,Z.jsx)(`span`,{id:`telemetry-detail`,className:`max-w-[70ch] text-label-14 text-secondary`,children:`Helps prioritize improvements. Canonry does not send raw domains, URLs, queries, answer content, or credentials.`})]})]}),a.isPending?(0,Z.jsx)(`p`,{className:`mt-1 text-copy-14 text-secondary`,role:`status`,children:`Saving preference…`}):null,N?(0,Z.jsx)(`p`,{className:`mt-1 text-copy-14 text-negative`,role:`alert`,children:N}):null]})]})}function Jm(){return(0,Z.jsx)(`div`,{className:`page-container`,children:(0,Z.jsx)(`section`,{className:`page-section`,children:(0,Z.jsxs)(Ri,{className:`surface-card empty-card`,children:[(0,Z.jsx)(`h1`,{children:`Page not found`}),(0,Z.jsx)(`p`,{children:`This page may have moved. Choose a project to continue.`}),(0,Z.jsx)(Y,{asChild:!0,children:(0,Z.jsx)(W,{to:`/projects`,children:`View projects`})})]})})})}var Ym=`modulepreload`,Xm=function(e,t){return new URL(e,t).href},Zm={},Qm=function(e){return e.pathname.endsWith(`.css`)},$m=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},eh=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=Xm(t,n);let r=s(t),i=Qm(r);return $m(Zm,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:Ym,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},th=U(()=>eh(()=>import(`./ProjectPage-DnDw0Cvk.js`).then(e=>e.t),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]),import.meta.url),`ProjectPage`),nh=U(()=>eh(()=>import(`./RunsPage-DG43ZJib.js`),__vite__mapDeps([23,1,2,3,4,5,6,7,8,9,10,11,13,14,15,16]),import.meta.url),`RunsPage`),rh=U(()=>eh(()=>import(`./HistoryPage-DMmZ0fSd.js`),__vite__mapDeps([24,4,1,2,18,5,6,3,7,14,11]),import.meta.url),`HistoryPage`),ih=U(()=>eh(()=>import(`./SettingsPage-CJlAiPn3.js`),__vite__mapDeps([25,1,2,4,5,6,3,7,8,9,10,11,12,13]),import.meta.url),`SettingsPage`),ah=U(()=>eh(()=>import(`./AgentSetupPage-H8VoauIK.js`),__vite__mapDeps([26,1,2,4,7,3,6,10,12]),import.meta.url),`AgentSetupPage`),oh=U(()=>eh(()=>import(`./BacklinksPage-Dg6IJr83.js`),__vite__mapDeps([27,1,2,4,7,3,6,12,11,17,16]),import.meta.url),`BacklinksPage`),sh=U(()=>eh(()=>import(`./TrafficPage-Dlp26Fvy.js`),__vite__mapDeps([28,1,2,4,5,6,3,7,14,11,22,12,13,15,16,20]),import.meta.url),`TrafficPage`),ch=U(()=>eh(()=>import(`./TrafficSourceDetailPage-D-x32dzk.js`),__vite__mapDeps([29,1,2,4,5,6,3,7,9,15,16,11,20,13,14,21]),import.meta.url),`TrafficSourceDetailPage`),lh=U(()=>eh(()=>import(`./MeasurementPropertyPage-x4S_SV30.js`),__vite__mapDeps([30,1,2,4,5,6,3,7,8,9,10,11,14,15,16,19]),import.meta.url),`MeasurementPropertyPage`);function uh(){return(0,Z.jsx)(Du,{children:(0,Z.jsx)(ta,{children:(0,Z.jsx)(Su,{})})})}var dh=we()({component:uh,notFoundComponent:Jm,validateSearch:e=>({manageQueries:e.manageQueries===!0||e.manageQueries===`true`||void 0,runId:typeof e.runId==`string`?e.runId:void 0,siteHealthRunId:typeof e.siteHealthRunId==`string`?e.siteHealthRunId:void 0,seoProfileId:typeof e.seoProfileId==`string`?e.seoProfileId:void 0,seoRunId:typeof e.seoRunId==`string`?e.seoRunId:void 0,seoView:typeof e.seoView==`string`?e.seoView:void 0,seoTrendDays:nr.safeParse(typeof e.seoTrendDays==`string`?Number(e.seoTrendDays):e.seoTrendDays).data,seoTrendMetric:In.safeParse(e.seoTrendMetric).data,seoTrendKeyword:mr.safeParse(e.seoTrendKeyword).data,seoRegion:typeof e.seoRegion==`string`&&e.seoRegion?e.seoRegion:void 0,seoMarket:typeof e.seoMarket==`string`&&e.seoMarket?e.seoMarket:void 0,seoShow:typeof e.seoShow==`string`&&e.seoShow?e.seoShow:void 0,seoSort:typeof e.seoSort==`string`&&e.seoSort?e.seoSort:void 0,seoQ:typeof e.seoQ==`string`&&e.seoQ?e.seoQ:void 0,evidenceId:typeof e.evidenceId==`string`?e.evidenceId:void 0,runStatus:typeof e.runStatus==`string`?e.runStatus:void 0,runKind:typeof e.runKind==`string`?e.runKind:void 0,runProject:typeof e.runProject==`string`?e.runProject:void 0,runWindow:typeof e.runWindow==`string`?e.runWindow:void 0,runQuery:typeof e.runQuery==`string`?e.runQuery:void 0,onboarding:e.onboarding===`site-health`||e.onboarding===`first-run`||e.onboarding===`complete`?e.onboarding:void 0,experience:e.experience===`legacy`||e.experience===`platform`?e.experience:void 0,siteScan:e.siteScan===`skip`||e.siteScan===`scan`?e.siteScan:void 0,skipped:e.skipped===`visibility`?`visibility`:void 0,setupProject:typeof e.setupProject==`string`?e.setupProject:void 0,project:typeof e.project==`string`&&e.project?e.project:void 0,track:e.track===`agent-readiness`||e.track===`ai-visibility`?e.track: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`,`journeyView`,`journeyDays`,`journeyVisitor`,`journeyEngine`,`journeyReturned`,`journeyOffset`,`agentHours`].map(t=>[t,typeof e[t]==`string`&&e[t]?e[t]:void 0]))})}),fh=Ae({getParentRoute:()=>dh,path:`/`,component:Ld,beforeLoad:async({context:e})=>{let t=e.queryClient.getQueryData(Ni({client:q}));if(t===void 0)try{t=await e.queryClient.ensureQueryData(wi({client:q}))}catch{return}if(t.length===0)throw De({to:`/setup`})}}),ph=Ae({getParentRoute:()=>dh,path:`/projects`,component:Vd}),mh=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,hh=Ae({getParentRoute:()=>dh,path:`/projects/$projectName`,component:()=>(0,Z.jsx)(Ne,{}),beforeLoad:async({context:e,params:t,location:n})=>{let r=t.projectName;if(!mh.test(r))return;let i=e.queryClient.getQueryData(Ni({client:q}));if(!i)try{i=await e.queryClient.ensureQueryData(wi({client:q}))}catch{return}let a=i.find(e=>e.id===r);if(a)throw De({to:n.pathname.replace(`/projects/${r}`,`/projects/${encodeURIComponent(a.name)}`),replace:!0})}}),gh=Ae({getParentRoute:()=>hh,path:`/`,component:()=>(0,Z.jsx)(th,{tab:`overview`})}),_h=Ae({getParentRoute:()=>hh,path:`/portfolio`,component:()=>(0,Z.jsx)(th,{tab:`portfolio`})}),vh=Ae({getParentRoute:()=>hh,path:`/search-console`,component:()=>(0,Z.jsx)(th,{tab:`search-console`})}),yh=Ae({getParentRoute:()=>hh,path:`/seo-data`,component:()=>(0,Z.jsx)(th,{tab:`seo-data`})}),bh=Ae({getParentRoute:()=>hh,path:`/journeys`,component:()=>(0,Z.jsx)(th,{tab:`journeys`})}),xh=Ae({getParentRoute:()=>hh,path:`/conversions`,component:()=>(0,Z.jsx)(th,{tab:`conversions`})}),Sh=Ae({getParentRoute:()=>hh,path:`/local`,component:()=>(0,Z.jsx)(th,{tab:`local`})}),Ch=Ae({getParentRoute:()=>hh,path:`/discovery`,component:()=>(0,Z.jsx)(th,{tab:`discovery`})}),wh=Ae({getParentRoute:()=>hh,path:`/queries`,component:()=>(0,Z.jsx)(th,{tab:`queries`})}),Th=Ae({getParentRoute:()=>hh,path:`/client-queries`,component:()=>(0,Z.jsx)(th,{tab:`client-queries`})}),Eh=Ae({getParentRoute:()=>hh,path:`/properties/$targetKey`,component:()=>(0,Z.jsx)(lh,{})}),Dh=Ae({getParentRoute:()=>hh,path:`/report`,beforeLoad:({params:e})=>{throw De({to:`/projects/$projectName`,params:e,replace:!0})}}),Oh=Ae({getParentRoute:()=>hh,path:`/activity`,component:()=>(0,Z.jsx)(th,{tab:`activity`})}),kh=Ae({getParentRoute:()=>hh,path:`/traffic`,component:()=>(0,Z.jsx)(th,{tab:`traffic`})}),Ah=Ae({getParentRoute:()=>hh,path:`/backlinks`,component:()=>(0,Z.jsx)(th,{tab:`backlinks`})}),jh=Ae({getParentRoute:()=>hh,path:`/agent-readiness`,component:()=>(0,Z.jsx)(th,{tab:`agent-readiness`})}),Mh=Ae({getParentRoute:()=>hh,path:`/technical-aeo`,beforeLoad:({params:e,location:t})=>{throw De({to:`/projects/$projectName/agent-readiness`,params:e,search:t.search,hash:t.hash,replace:!0})}}),Nh=Ae({getParentRoute:()=>hh,path:`/history`,component:()=>(0,Z.jsx)(th,{tab:`history`})}),Ph=Ae({getParentRoute:()=>hh,path:`/settings`,component:()=>(0,Z.jsx)(th,{tab:`settings`})}),Fh=Ae({getParentRoute:()=>dh,path:`/runs`,component:nh}),Ih=Ae({getParentRoute:()=>dh,path:`/history`,component:rh}),Lh=Ae({getParentRoute:()=>dh,path:`/settings`,component:ih,beforeLoad:({context:e})=>{}}),Rh=Ae({getParentRoute:()=>dh,path:`/setup`,component:Wm}),zh=Ae({getParentRoute:()=>dh,path:`/agent-setup`,component:ah}),Bh=Ae({getParentRoute:()=>dh,path:`/backlinks`,component:oh}),Vh=Ae({getParentRoute:()=>dh,path:`/traffic`,component:sh}),Hh=Ae({getParentRoute:()=>dh,path:`/traffic/$projectName/$sourceId`,component:ch}),Uh=dh.addChildren([fh,ph,hh.addChildren([gh,_h,vh,yh,bh,xh,Sh,Ch,wh,Th,Eh,Dh,Oh,kh,Ah,jh,Mh,Nh,Ph]),Fh,Ih,Lh,Rh,zh,Bh,Vh,Hh]);function Wh(){return typeof window<`u`&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath:`/`}var Gh=Wh(),Kh=Gh===`/`?``:Gh.replace(/\/$/,``);function qh(e,t){return Se({routeTree:Uh,basepath:Kh||`/`,context:{queryClient:e},...t?.initialEntries&&{history:Oe({initialEntries:t.initialEntries})}})}var Jh=6e4,Yh=6e4,Xh=1e4,Zh=3e4;function Qh(){let e=!1,t=null,n,r=null,i=performance.now(),a=Date.now(),o=i,s=i,c=document.visibilityState===`visible`&&document.hasFocus(),l=0,u=()=>{let e=performance.now(),t=Date.now(),n=e-i;if(r&&c&&n>=0&&n<=Zh&&t-a<=Zh){let e=bn-r.foregroundMs,t=Math.min(n,e);r.foregroundMs+=t,r.activeMs+=Math.min(t,Math.max(0,o+Jh-i))}i=e,a=t},d=(e=!1)=>{!r||!t||r.foregroundMs<1||(e||Math.floor(r.foregroundMs)!==l)&&(l=Math.floor(r.foregroundMs),s=i,qt({event:`ui.page_time`,page:t,visitId:r.id,foregroundMs:l,activeMs:Math.floor(r.activeMs),completed:e}))},f=()=>{r={id:Xt(),foregroundMs:0,activeMs:0},l=0,s=i,o=i},p=()=>{u();let e=document.visibilityState===`visible`&&document.hasFocus();c&&!e&&d(),!c&&e&&(o=i),c=e},m=()=>{u(),c&&(o=i)},h=()=>{u(),d(!0),r=null,c=!1},g=()=>{p(),t&&!r&&f()},_=window.setInterval(()=>{u(),i-s>=Yh&&d()},Xh),v=[`pointerdown`,`pointermove`,`keydown`,`scroll`,`touchstart`];for(let e of v)document.addEventListener(e,m,{passive:!0,capture:!0});return document.addEventListener(`visibilitychange`,p),window.addEventListener(`focus`,p),window.addEventListener(`blur`,p),window.addEventListener(`pagehide`,h),window.addEventListener(`pageshow`,g),{clear(){r=null,t=null,n=void 0},navigate(i,a){if(e)return;let o=On(i);t===o&&n===a&&r||(u(),d(!0),t=o,n=a,c=document.visibilityState===`visible`&&document.hasFocus(),f())},stop(){e=!0,r=null,window.clearInterval(_);for(let e of v)document.removeEventListener(e,m,!0);document.removeEventListener(`visibilitychange`,p),window.removeEventListener(`focus`,p),window.removeEventListener(`blur`,p),window.removeEventListener(`pagehide`,h),window.removeEventListener(`pageshow`,g)}}}var $h=!1,eg;async function tg(e){return(await Ie({client:q,body:e,keepalive:!0})).data}function ng(){$h||typeof window>`u`||($h=!0,!(Ue()||xt())&&(eg=Qh(),vt({send:tg,onDisabled:()=>eg?.stop()}),q.interceptors.request.use((e,t)=>{let n=t.fetch??globalThis.fetch,r=typeof t.url==`string`?t.url:void 0;return t.fetch=async(t,i)=>{try{return await n(t,i)}catch(t){throw t instanceof DOMException&&t.name===`AbortError`||jt({method:e.method,route:r,network:!0}),t}},e}),q.interceptors.response.use((e,t,n)=>(jt({method:t.method,route:typeof n.url==`string`?n.url:void 0,path:ig(t.url),status:e.status}),e)),window.addEventListener(`error`,e=>{Qe({kind:`unhandled`,error:e.error})}),window.addEventListener(`unhandledrejection`,e=>{Qe({kind:`unhandled`,error:e.reason})}),lg()))}function rg(e){let t=null,n=()=>{let n=e.state.matches.at(-1);if(!n)return;eg?.navigate(n.fullPath,e.state.location?.pathname),Lt(n.fullPath);let r=e.state.location;if(!r)return;let i=r.search&&typeof r.search==`object`?r.search:{};t&&t.pathname===r.pathname&&at(t.search,i),t={pathname:r.pathname,search:i}};n();let r=e.subscribe(`onResolved`,n);return()=>{r(),eg?.clear()}}function ig(e){try{return new URL(e,window.location.origin).pathname}catch{return}}var ag={LCP:[2500,4e3],INP:[200,500],CLS:[.1,.25],FCP:[1800,3e3],TTFB:[800,1800]};function og(e,t){let[n,r]=ag[e];return t<=n?`good`:t<=r?`needs-improvement`:`poor`}function sg(){let e=0,t=0,n=-1/0,r=-1/0;return{add(i){i.hadRecentInput||(i.startTime-r<1e3&&i.startTime-n<5e3?t+=i.value:(t=i.value,n=i.startTime),r=i.startTime,e=Math.max(e,t))},value:()=>e}}function cg(){let e=0;return{add(t){t.interactionId&&(e=Math.max(e,t.duration))},value:()=>e}}function lg(){if(typeof PerformanceObserver>`u`)return;let e=new Set,t=(t,n)=>{!e.has(t)&&Number.isFinite(n)&&(e.add(t),mt(t,og(t,n)))},n=(e,t,n={})=>{try{new PerformanceObserver(e=>t(e.getEntries())).observe({type:e,buffered:!0,...n})}catch{}};try{let e=performance.getEntriesByType(`navigation`)[0];e&&e.responseStart>0&&t(`TTFB`,e.responseStart)}catch{}n(`paint`,e=>{let n=e.find(e=>e.name===`first-contentful-paint`);n&&t(`FCP`,n.startTime)});let r=0;n(`largest-contentful-paint`,e=>{let t=e.at(-1);t&&(r=t.startTime)});let i=sg();n(`layout-shift`,e=>{for(let t of e)i.add({startTime:t.startTime,value:t.value??0,hadRecentInput:t.hadRecentInput===!0})});let a=cg();n(`event`,e=>{for(let t of e)a.add(t)},{durationThreshold:40});let o=()=>{r>0&&t(`LCP`,r),t(`CLS`,i.value()),a.value()>0&&t(`INP`,a.value())};document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`hidden`&&o()}),window.addEventListener(`pagehide`,o)}var ug=6e4,dg=`Anyone with this password can sign in to this dashboard.`,fg={label:`Root API key`,help:`To create the password from here, enter the root API key (apiKey in config.yaml). It is used once and not saved.`,missing:`Enter the root API key.`,rejected:`That is not the root API key for this install.`,show:`Show passwords and key`},pg={id:`embed`,scopes:[`read`,`embed`],projectId:`embed`,readOnly:!0};function mg(){let e=(0,X.useRef)(jr()).current,[t,n]=(0,X.useState)(e?`ready`:`checking`),[r,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(e),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(``),[g,_]=(0,X.useState)(``),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(`password`),[S,C]=(0,X.useState)(!1),[w,T]=(0,X.useState)(``),[D,O]=(0,X.useState)(null),[k,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(!1),[N,ee]=(0,X.useState)(!1),[P,F]=(0,X.useState)(!1),[I]=(0,X.useState)(()=>Qi().error),L=(0,X.useRef)(null),R=(0,X.useRef)(null),z=(0,X.useRef)(null),te=()=>{let t=r?`${r.name}:${r.role}`:e?`api-key:explicit`:a?`api-key:${a.id}`:`no-accounts`;if(!L.current||z.current!==t){R.current?.clear();let e=Qr();R.current=e,L.current=qh(e),z.current=t}return{queryClient:R.current,router:L.current}},ne=t===`ready`?te().router:null;(0,X.useEffect)(()=>{if(ne)return rg(ne)},[ne]);let re=e=>e.authRequired?(u(!0),ee(e.signInMethods?.chatgpt===!0),i(e.user),o(null),c(!1),n(e.user?`ready`:`account-login`),!0):!1;(0,X.useEffect)(()=>{let t=!1,r=async(e,r=!1)=>{try{let e=await nt();if(t)return;o(e),c(!1),n(`ready`)}catch(i){if(t)return;if(r&&i instanceof ir&&i.statusCode===401)return Bt().then(()=>{t||(O(null),o(null),c(!1),M(!0),n(`login`))}).catch(r=>{t||(O(r instanceof Error?r.message:`Could not clear the invalid session`),n(e))});O(i instanceof Error?i.message:`Could not verify API key access`),n(e)}};return e?(r(`api-key-error`),()=>{t=!0}):(Promise.allSettled([Ft(),yr()]).then(([e,i])=>{if(t||e.status===`fulfilled`&&re(e.value))return;if(i.status===`rejected`){let e=i.reason;O(e instanceof Error?e.message:`Failed to reach the Canonry API`),n(`login`);return}let a=i.value;a.authenticated&&Ue()?(o(pg),c(!1),n(`ready`)):a.authenticated?(c(!0),r(`api-key-error`,!0)):(o(null),c(!1),n(a.setupRequired?`setup`:`login`))}),()=>{t=!0})},[]),(0,X.useEffect)(()=>{if(t!==`ready`||e)return;let r=setInterval(()=>{l?Ft().then(e=>{e.authRequired&&!e.user&&(M(!0),i(null),o(null),n(`account-login`))}).catch(()=>{}):yr().then(e=>{e.authenticated||(M(!0),o(null),n(e.setupRequired?`setup`:`login`))}).catch(()=>{})},ug);return tr(()=>{M(!0),i(null),o(null),c(!1),n(l?`account-login`:`login`)}),()=>{clearInterval(r),tr(null)}},[t,l,e]);let ie=async e=>{if(e.preventDefault(),!p.trim()||p.trim().length<8){O(`Password must be at least 8 characters`);return}if(p!==g){O(`Passwords do not match`);return}let t=w.trim();if(S&&!t)O(fg.missing);else{A(!0),O(null);try{if(!(await Fn(p.trim(),S?t:void 0)).authenticated){O(`Setup failed`);return}m(``),_(``),T(``),C(!1),y(!1),M(!1),o(null),c(!0),n(`checking`);try{let e=await nt();o(e),c(!1),n(`ready`)}catch(e){O(e instanceof Error?e.message:`Could not verify API key access`),n(`api-key-error`)}}catch(e){if(e instanceof ir&&e.statusCode===401&&e.code===`AUTH_REQUIRED`){O(S?fg.rejected:null),C(!0);return}O(e instanceof ir||e instanceof Error?e.message:`Setup failed`)}finally{A(!1)}}},ae=e=>{m(e),O(null)},oe=e=>{T(e),O(null)},se=e=>{_(e),O(null)},ce=async e=>{if(e.preventDefault(),p.trim()){A(!0),O(null);try{if(!(b===`api-key`?await tt(p.trim()):await st(p.trim())).authenticated){O(b===`api-key`?`Invalid API key`:`Incorrect password`);return}let e=await nt();o(e),c(!1),m(``),y(!1),M(!1),n(`ready`)}catch(e){O(e instanceof ir||e instanceof Error?e.message:`Authentication failed`)}finally{A(!1)}}},B=e=>{x(e),m(``),y(!1),O(null)},V=async e=>{if(e.preventDefault(),d.trim()&&p){A(!0),O(null);try{let e=await Kn(d.trim(),p);if(!e.user){O(`Incorrect name or password.`);return}m(``),M(!1),i(e.user),o(null),c(!1),n(`ready`)}catch(e){O(e instanceof ir?e.message:`Incorrect name or password.`)}finally{A(!1)}}};if(t===`ready`){let{queryClient:e,router:t}=te();return(0,Z.jsx)(Yr,{account:r,apiKey:a,apiKeyPending:s,children:(0,Z.jsx)(ve,{client:e,children:(0,Z.jsx)(ke,{router:t})})})}let le=p.trim(),ue=p.length>0&&le.length<8,de=g.length>0&&p!==g,fe=le.length>=8&&p===g&&(!S||w.trim().length>0),H=e=>(0,Z.jsxs)(`form`,{id:e.formId,className:`space-y-4`,onSubmit:Xr(V),children:[(0,Z.jsxs)(`label`,{className:`block space-y-1.5`,htmlFor:`account-name`,children:[(0,Z.jsx)(`span`,{className:`text-label-12-strong text-secondary`,children:`Name`}),(0,Z.jsx)(`input`,{autoFocus:!0,id:`account-name`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-label-14 text-heading outline-none transition focus:border-mono-600`,type:`text`,name:`username`,autoComplete:`username`,value:d,onChange:e=>{f(e.target.value),O(null)},"aria-invalid":!!D,"aria-describedby":D?`account-login-error`:void 0})]}),(0,Z.jsxs)(`label`,{className:`block space-y-1.5`,htmlFor:`account-password`,children:[(0,Z.jsx)(`span`,{className:`text-label-12-strong text-secondary`,children:`Password`}),(0,Z.jsx)(`input`,{id:`account-password`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-label-14 text-heading outline-none transition focus:border-mono-600`,type:`password`,name:`password`,autoComplete:`current-password`,value:p,onChange:e=>ae(e.target.value),"aria-invalid":!!D,"aria-describedby":D?`account-login-error`:void 0})]}),D?(0,Z.jsx)(`p`,{id:`account-login-error`,role:`alert`,className:`text-copy-14 text-negative-400`,children:D}):null,(0,Z.jsx)(Y,{type:`submit`,variant:e.secondary?`secondary`:`default`,disabled:k||!d.trim()||!p,children:k?`Signing in…`:`Sign in`})]});return(0,Z.jsx)(`div`,{className:`min-h-screen bg-bg px-4 py-8`,children:(0,Z.jsxs)(`div`,{className:`mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col items-center justify-center gap-5`,children:[(0,Z.jsxs)(`div`,{"data-testid":`auth-brand`,className:`flex items-center gap-2.5`,children:[(0,Z.jsx)(Ua,{className:`size-7`}),(0,Z.jsx)(`span`,{className:`text-label-18-strong text-heading`,children:`Canonry`})]}),(0,Z.jsx)(Ri,{className:`surface-card w-full`,children:t===`checking`?(0,Z.jsx)(Ii,{className:`py-8`,children:(0,Z.jsx)(`p`,{className:`supporting-copy text-center`,children:`Connecting to Canonry…`})}):t===`api-key-error`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Fi,{children:(0,Z.jsx)(`h1`,{className:`text-heading-24 text-primary`,children:`Could not verify API key access`})}),(0,Z.jsxs)(Ii,{className:`space-y-4`,children:[(0,Z.jsx)(`p`,{className:`supporting-copy`,children:D??`Canonry could not verify this session’s access, so the dashboard stayed locked.`}),(0,Z.jsx)(Y,{type:`button`,className:`w-full`,onClick:()=>{window.location.reload()},children:`Try again`})]})]}):t===`account-login`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Fi,{children:(0,Z.jsx)(`h1`,{className:`text-heading-24 text-primary`,children:`Sign in to Canonry`})}),N?(0,Z.jsxs)(Ii,{className:`space-y-4`,children:[j?(0,Z.jsx)(`p`,{className:`rounded-md border border-caution bg-caution-soft px-3 py-2 text-copy-14 text-caution`,children:`You were signed out. Sign in again.`}):I?(0,Z.jsx)(`p`,{role:`alert`,className:`rounded-md border border-caution bg-caution-soft px-3 py-2 text-copy-14 text-caution`,children:Zn[I]}):null,(0,Z.jsx)(Pc,{href:dn(`login`,$i()),className:`w-full`}),(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":P,"aria-controls":`account-password-form`,onClick:()=>F(e=>!e),className:`flex items-center gap-1 rounded-md text-label-14 text-secondary transition hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400`,children:[P?(0,Z.jsx)(E,{className:`h-4 w-4`,"aria-hidden":`true`}):(0,Z.jsx)(h,{className:`h-4 w-4`,"aria-hidden":`true`}),`Sign in with a password`]}),P?H({secondary:!0,formId:`account-password-form`}):null]}):(0,Z.jsxs)(Ii,{children:[j?(0,Z.jsx)(`p`,{className:`mb-4 rounded-md border border-caution bg-caution-soft px-3 py-2 text-copy-14 text-caution`,children:`You were signed out. Sign in again.`}):null,H({secondary:!1})]})]}):t===`setup`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Fi,{children:[(0,Z.jsx)(`h1`,{className:`text-heading-24 text-primary`,children:`Create a dashboard password`}),(0,Z.jsx)(Li,{children:dg})]}),(0,Z.jsx)(Ii,{children:(0,Z.jsxs)(`form`,{className:`space-y-4`,onSubmit:Xr(ie),children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`block text-label-12-strong text-secondary`,htmlFor:`dashboard-password-new`,children:`Password`}),(0,Z.jsx)(`input`,{autoFocus:!0,id:`dashboard-password-new`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-label-14 text-heading outline-none transition focus:border-mono-600`,type:v?`text`:`password`,name:`new-password`,autoComplete:`new-password`,minLength:8,required:!0,value:p,onChange:e=>ae(e.target.value),"aria-invalid":ue,"aria-describedby":`dashboard-password-new-help`}),(0,Z.jsx)(`span`,{id:`dashboard-password-new-help`,"aria-live":`polite`,className:ue?`block text-label-14 text-negative-400`:`block text-label-14 text-secondary`,children:ue?`Enter at least 8 characters.`:`Use at least 8 characters.`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`block text-label-12-strong text-secondary`,htmlFor:`dashboard-password-confirm`,children:`Confirm password`}),(0,Z.jsx)(`input`,{id:`dashboard-password-confirm`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-label-14 text-heading outline-none transition focus:border-mono-600`,type:v?`text`:`password`,name:`confirm-password`,autoComplete:`new-password`,minLength:8,required:!0,value:g,onChange:e=>se(e.target.value),"aria-invalid":de,"aria-describedby":`dashboard-password-confirm-help`}),(0,Z.jsx)(`span`,{id:`dashboard-password-confirm-help`,"aria-live":`polite`,className:de?`block text-label-14 text-negative-400`:`block text-label-14 text-secondary`,children:de?`Passwords do not match.`:`Enter the same password again.`})]}),S?(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`block text-label-12-strong text-secondary`,htmlFor:`dashboard-setup-root-key`,children:fg.label}),(0,Z.jsx)(`input`,{autoFocus:!0,id:`dashboard-setup-root-key`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-label-14 text-heading outline-none transition focus:border-mono-600`,type:v?`text`:`password`,name:`apiKey`,autoComplete:`off`,spellCheck:!1,required:!0,value:w,onChange:e=>oe(e.target.value),"aria-invalid":D===fg.rejected,"aria-describedby":`dashboard-setup-root-key-help`}),(0,Z.jsx)(`span`,{id:`dashboard-setup-root-key-help`,"aria-live":`polite`,className:`block text-label-14 text-secondary`,children:fg.help})]}):null,(0,Z.jsxs)(`label`,{className:`flex min-h-10 cursor-pointer items-center gap-2 text-label-14 text-secondary`,htmlFor:`dashboard-password-show`,children:[(0,Z.jsx)(`input`,{id:`dashboard-password-show`,type:`checkbox`,checked:v,onChange:e=>y(e.target.checked)}),S?fg.show:`Show passwords`]}),D?(0,Z.jsx)(`p`,{id:`dashboard-password-setup-error`,role:`alert`,className:`text-copy-14 text-negative-400`,children:D}):null,(0,Z.jsx)(Y,{type:`submit`,disabled:k||!fe,children:k?`Creating password…`:`Create password and continue`})]})})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Fi,{children:[(0,Z.jsx)(`h1`,{className:`text-heading-24 text-primary`,children:`Sign in to Canonry`}),(0,Z.jsx)(Li,{children:b===`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.`})]}),(0,Z.jsxs)(Ii,{children:[j?(0,Z.jsx)(`p`,{className:`mb-4 rounded-md border border-caution bg-caution-soft px-3 py-2 text-copy-14 text-caution`,children:`Your session expired. Sign in again.`}):null,(0,Z.jsxs)(`form`,{className:`space-y-4`,onSubmit:Xr(ce),children:[(0,Z.jsxs)(`label`,{className:`block space-y-1.5`,htmlFor:`dashboard-password-current`,children:[(0,Z.jsx)(`span`,{className:`text-label-12-strong text-secondary`,children:b===`api-key`?`Canonry API key`:`Password`}),(0,Z.jsx)(`input`,{autoFocus:!0,id:`dashboard-password-current`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-label-14 text-heading outline-none transition focus:border-mono-600`,type:v?`text`:`password`,name:b===`api-key`?`apiKey`:`password`,autoComplete:b===`api-key`?`off`:`current-password`,spellCheck:!1,required:!0,value:p,onChange:e=>ae(e.target.value),"aria-invalid":!!D,"aria-describedby":D?`dashboard-password-login-error`:void 0})]}),(0,Z.jsxs)(`label`,{className:`flex min-h-10 cursor-pointer items-center gap-2 text-label-14 text-secondary`,htmlFor:`dashboard-login-password-show`,children:[(0,Z.jsx)(`input`,{id:`dashboard-login-password-show`,type:`checkbox`,checked:v,onChange:e=>y(e.target.checked)}),b===`api-key`?`Show API key`:`Show password`]}),D?(0,Z.jsx)(`p`,{id:`dashboard-password-login-error`,role:`alert`,className:`text-copy-14 text-negative-400`,children:D}):null,(0,Z.jsx)(Y,{type:`submit`,disabled:k||!p.trim(),children:k?`Signing in…`:`Open dashboard`}),(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,onClick:()=>B(b===`api-key`?`password`:`api-key`),children:b===`api-key`?`Use dashboard password instead`:`Forgot password? Use API key`})]})]})]})})]})})}var hg=document.getElementById(`root`);if(!hg)throw Error(`Expected #root element for web app bootstrap.`);ng(),(0,Wi.createRoot)(hg).render((0,Z.jsx)(X.StrictMode,{children:(0,Z.jsx)(Za,{children:(0,Z.jsx)(mg,{})})}));export{vc as $,tf as A,ro as At,ku as B,aa as Bt,lf as C,vo as Ct,af as D,po as Dt,uf as E,ho as Et,bd as F,Ra as Ft,el as G,su as H,na as Ht,xd as I,Na as It,jc as J,Ec as K,pd as L,Pa as Lt,Fd as M,$a as Mt,Cd as N,Ka as Nt,ef as O,uo as Ot,gd as P,Ma as Pt,mc as Q,fd as R,la as Rt,Ef as S,Do as St,of as T,_o as Tt,lu as U,Xi as Ut,Ou as V,fa as Vt,au as W,xc as X,Ac as Y,gc as Z,Ff as _,ko as _t,Kp as a,Zs as at,wf as b,Oo as bt,Fp as c,Us as ct,Gf as d,Ho as dt,bc as et,Qf as f,Io as ft,Mf as g,Ao as gt,kf as h,jo as ht,Gp as i,$s as it,zd as j,io as jt,nf as k,so as kt,xp as l,Vs as lt,Vf as m,Fo as mt,Jp as n,yc as nt,Hp as o,Js as ot,zf as p,Vo as pt,Tc as q,Up as r,cc as rt,Wp as s,Ks as st,eh as t,hc as tt,op as u,_s as ut,Pf as v,yo as vt,pf as w,go as wt,Tf as x,Eo as xt,Df as y,To as yt,hd as z,da as zt};
@@ -1,4 +1,4 @@
1
- import{r as e,t}from"./rolldown-runtime-XKyaHtl9.js";import{ft as n}from"./vendor-lucide-iE5MEh2-.js";import{n as r,r as i}from"./ProjectPage-2oJ95fiK.js";var a=e(n(),1);function o(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){if(e){if(typeof e==`string`)return o(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}function c(e){if(Array.isArray(e))return e}function l(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function u(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{r as e,t}from"./rolldown-runtime-XKyaHtl9.js";import{ft as n}from"./vendor-lucide-iE5MEh2-.js";import{n as r,r as i}from"./ProjectPage-DnDw0Cvk.js";var a=e(n(),1);function o(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){if(e){if(typeof e==`string`)return o(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}function c(e){if(Array.isArray(e))return e}function l(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function u(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function d(e,t){return c(e)||l(e,t)||s(e,t)||u()}function f(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=s(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
3
3
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){c=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(c)throw a}}}}function p(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function m(e,t,n){return e[0]=t,e[4]=typeof n==`number`?n:t,e}function h(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[3]=-n,e[4]=r,e}function g(e,t,n){return e[6]=t,e[7]=n,e}function _(e,t){var n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7],u=e[8],d=t[0],f=t[1],p=t[2],m=t[3],h=t[4],g=t[5],_=t[6],v=t[7],y=t[8];return e[0]=d*n+f*a+p*c,e[1]=d*r+f*o+p*l,e[2]=d*i+f*s+p*u,e[3]=m*n+h*a+g*c,e[4]=m*r+h*o+g*l,e[5]=m*i+h*s+g*u,e[6]=_*n+v*a+y*c,e[7]=_*r+v*o+y*l,e[8]=_*i+v*s+y*u,e}function v(e,t){var n=Math.cos(t),r=Math.sin(t);return{x:n*e.x+r*e.y,y:-r*e.x+n*e.y}}function y(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=e[0],i=e[1],a=e[3],o=e[4],s=e[6],c=e[7],l=t.x,u=t.y;return{x:l*r+u*a+s*n,y:l*i+u*o+c*n}}function b(e,t){var n=e.height/e.width,r=t.height/t.width;return n<1&&r>1||n>1&&r<1?1:Math.min(Math.max(r,1/r),Math.max(1/n,n))}function x(e,t,n,r,i){var a=e.angle,o=e.ratio,s=e.x,c=e.y,l=t.width,u=t.height,d=p(),f=Math.min(l,u)-2*r,v=b(t,n);return i?(_(d,g(p(),s,c)),_(d,m(p(),o)),_(d,h(p(),a)),_(d,m(p(),l/f/2/v,u/f/2/v))):(_(d,m(p(),f/l*2*v,f/u*2*v)),_(d,h(p(),-a)),_(d,m(p(),1/o)),_(d,g(p(),-s,-c))),d}function S(e,t,n){var r=y(e,{x:Math.cos(t.angle),y:Math.sin(t.angle)},0),i=r.x,a=r.y;return 1/Math.sqrt(i**2+a**2)/n.width}function C(e,t,n,r,i){return[Math.floor(t/i*r),Math.floor(e.drawingBufferHeight/i-n/i*r)]}var w={black:`#000000`,silver:`#C0C0C0`,gray:`#808080`,grey:`#808080`,white:`#FFFFFF`,maroon:`#800000`,red:`#FF0000`,purple:`#800080`,fuchsia:`#FF00FF`,green:`#008000`,lime:`#00FF00`,olive:`#808000`,yellow:`#FFFF00`,navy:`#000080`,blue:`#0000FF`,teal:`#008080`,aqua:`#00FFFF`,darkblue:`#00008B`,mediumblue:`#0000CD`,darkgreen:`#006400`,darkcyan:`#008B8B`,deepskyblue:`#00BFFF`,darkturquoise:`#00CED1`,mediumspringgreen:`#00FA9A`,springgreen:`#00FF7F`,cyan:`#00FFFF`,midnightblue:`#191970`,dodgerblue:`#1E90FF`,lightseagreen:`#20B2AA`,forestgreen:`#228B22`,seagreen:`#2E8B57`,darkslategray:`#2F4F4F`,darkslategrey:`#2F4F4F`,limegreen:`#32CD32`,mediumseagreen:`#3CB371`,turquoise:`#40E0D0`,royalblue:`#4169E1`,steelblue:`#4682B4`,darkslateblue:`#483D8B`,mediumturquoise:`#48D1CC`,indigo:`#4B0082`,darkolivegreen:`#556B2F`,cadetblue:`#5F9EA0`,cornflowerblue:`#6495ED`,rebeccapurple:`#663399`,mediumaquamarine:`#66CDAA`,dimgray:`#696969`,dimgrey:`#696969`,slateblue:`#6A5ACD`,olivedrab:`#6B8E23`,slategray:`#708090`,slategrey:`#708090`,lightslategray:`#778899`,lightslategrey:`#778899`,mediumslateblue:`#7B68EE`,lawngreen:`#7CFC00`,chartreuse:`#7FFF00`,aquamarine:`#7FFFD4`,skyblue:`#87CEEB`,lightskyblue:`#87CEFA`,blueviolet:`#8A2BE2`,darkred:`#8B0000`,darkmagenta:`#8B008B`,saddlebrown:`#8B4513`,darkseagreen:`#8FBC8F`,lightgreen:`#90EE90`,mediumpurple:`#9370DB`,darkviolet:`#9400D3`,palegreen:`#98FB98`,darkorchid:`#9932CC`,yellowgreen:`#9ACD32`,sienna:`#A0522D`,brown:`#A52A2A`,darkgray:`#A9A9A9`,darkgrey:`#A9A9A9`,lightblue:`#ADD8E6`,greenyellow:`#ADFF2F`,paleturquoise:`#AFEEEE`,lightsteelblue:`#B0C4DE`,powderblue:`#B0E0E6`,firebrick:`#B22222`,darkgoldenrod:`#B8860B`,mediumorchid:`#BA55D3`,rosybrown:`#BC8F8F`,darkkhaki:`#BDB76B`,mediumvioletred:`#C71585`,indianred:`#CD5C5C`,peru:`#CD853F`,chocolate:`#D2691E`,tan:`#D2B48C`,lightgray:`#D3D3D3`,lightgrey:`#D3D3D3`,thistle:`#D8BFD8`,orchid:`#DA70D6`,goldenrod:`#DAA520`,palevioletred:`#DB7093`,crimson:`#DC143C`,gainsboro:`#DCDCDC`,plum:`#DDA0DD`,burlywood:`#DEB887`,lightcyan:`#E0FFFF`,lavender:`#E6E6FA`,darksalmon:`#E9967A`,violet:`#EE82EE`,palegoldenrod:`#EEE8AA`,lightcoral:`#F08080`,khaki:`#F0E68C`,aliceblue:`#F0F8FF`,honeydew:`#F0FFF0`,azure:`#F0FFFF`,sandybrown:`#F4A460`,wheat:`#F5DEB3`,beige:`#F5F5DC`,whitesmoke:`#F5F5F5`,mintcream:`#F5FFFA`,ghostwhite:`#F8F8FF`,salmon:`#FA8072`,antiquewhite:`#FAEBD7`,linen:`#FAF0E6`,lightgoldenrodyellow:`#FAFAD2`,oldlace:`#FDF5E6`,magenta:`#FF00FF`,deeppink:`#FF1493`,orangered:`#FF4500`,tomato:`#FF6347`,hotpink:`#FF69B4`,coral:`#FF7F50`,darkorange:`#FF8C00`,lightsalmon:`#FFA07A`,orange:`#FFA500`,lightpink:`#FFB6C1`,pink:`#FFC0CB`,gold:`#FFD700`,peachpuff:`#FFDAB9`,navajowhite:`#FFDEAD`,moccasin:`#FFE4B5`,bisque:`#FFE4C4`,mistyrose:`#FFE4E1`,blanchedalmond:`#FFEBCD`,papayawhip:`#FFEFD5`,lavenderblush:`#FFF0F5`,seashell:`#FFF5EE`,cornsilk:`#FFF8DC`,lemonchiffon:`#FFFACD`,floralwhite:`#FFFAF0`,snow:`#FFFAFA`,lightyellow:`#FFFFE0`,ivory:`#FFFFF0`},T=new Int8Array(4),E=new Int32Array(T.buffer,0,1),D=new Float32Array(T.buffer,0,1),O=/^\s*rgba?\s*\(/,k=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function A(e){var t=0,n=0,r=0,i=1,a=e.toLowerCase();if(a===`transparent`)return{r:0,g:0,b:0,a:0};if(a in w)return A(w[a]);if(e[0]===`#`)e.length===4?(t=parseInt(e.charAt(1)+e.charAt(1),16),n=parseInt(e.charAt(2)+e.charAt(2),16),r=parseInt(e.charAt(3)+e.charAt(3),16)):(t=parseInt(e.charAt(1)+e.charAt(2),16),n=parseInt(e.charAt(3)+e.charAt(4),16),r=parseInt(e.charAt(5)+e.charAt(6),16)),e.length===9&&(i=parseInt(e.charAt(7)+e.charAt(8),16)/255);else if(O.test(e)){var o=e.match(k);o&&(t=+o[1],n=+o[2],r=+o[3],o[4]&&(i=+o[4]))}return{r:t,g:n,b:r,a:i}}function j(e){var t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=A(e),r=n.r,i=n.g,a=n.b,o=n.a;return t?[r/255*o,i/255*o,a/255*o,o]:[r/255,i/255,a/255,o]}var M={};for(var N in w)M[N]=F(w[N]),M[w[N]]=M[N];function P(e,t,n,r,i){return E[0]=r<<24|n<<16|t<<8|e,i&&(E[0]&=4278190079),D[0]}function F(e){if(e=e.toLowerCase(),M[e]!==void 0)return M[e];var t=A(e),n=t.r,r=t.g,i=t.b,a=t.a;a=a*255|0;var o=P(n,r,i,a,!0);return M[e]=o,o}function I(e,t){D[0]=F(e);var n=E[0];return t&&(n|=16777216),[n&255,n>>8&255,n>>16&255,n>>24&255]}function ee(e){var t=e>>>8&255,n=e>>>16&255,r=e>>>24&255;return((e&255)<<24|r<<16|n<<8|t)>>>0}function te(e,t,n,r){return(n<<24|t<<16|e<<8|r)>>>0}function L(e,t,n,r,i,a){var o=d(C(e,n,r,i,a),2),s=o[0],c=o[1],l=new Uint8Array(4);e.bindFramebuffer(e.FRAMEBUFFER,t),e.readPixels(s,c,1,1,e.RGBA,e.UNSIGNED_BYTE,l);var u=d(l,4);return[u[0],u[1],u[2],u[3]]}function ne(e){var t=A(e),n=t.r,r=t.g,i=t.b,a=t.a;return`vec4(${(n/255).toFixed(6)}, ${(r/255).toFixed(6)}, ${(i/255).toFixed(6)}, ${a.toFixed(6)})`}function re(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ie(e){var t=re(e,`string`);return typeof t==`symbol`?t:t+``}function R(e,t,n){return(t=ie(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ae(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ae(Object(n),!0).forEach(function(t){R(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ae(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function B(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function oe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,ie(r.key),r)}}function V(e,t,n){return t&&oe(e.prototype,t),n&&oe(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function se(e){return se=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},se(e)}function ce(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ce=function(){return!!e})()}function le(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function ue(e,t){if(t&&(typeof t==`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return le(e)}function H(e,t,n){return t=se(t),ue(e,ce()?Reflect.construct(t,n||[],se(e).constructor):t.apply(e,n))}function de(e,t){return de=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},de(e,t)}function U(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&de(e,t)}function fe(e){if(Array.isArray(e))return o(e)}function pe(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function me(){throw TypeError(`Invalid attempt to spread non-iterable instance.
4
4
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function W(e){return fe(e)||pe(e)||s(e)||me()}function G(e){"@babel/helpers - typeof";return G=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},G(e)}function he(e){return G(e)===`object`&&e!==null&&`attribute`in e}function ge(){return{name:`circle`,glsl:`
package/assets/index.html CHANGED
@@ -12,7 +12,7 @@
12
12
  <link rel="icon" type="image/png" sizes="32x32" href="./favicon-32.png" />
13
13
  <link rel="apple-touch-icon" href="./apple-touch-icon.png" />
14
14
  <title>Canonry</title>
15
- <script type="module" crossorigin src="./assets/index-CyETulrn.js"></script>
15
+ <script type="module" crossorigin src="./assets/index-C05Wdzzv.js"></script>
16
16
  <link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-XKyaHtl9.js">
17
17
  <link rel="modulepreload" crossorigin href="./assets/vendor-lucide-iE5MEh2-.js">
18
18
  <link rel="modulepreload" crossorigin href="./assets/vendor-markdown-BBGbNklj.js">
@@ -47,7 +47,7 @@ function queueServeHandoff() {
47
47
  async function runPendingServeHandoff(format) {
48
48
  if (!pendingServeHandoff) return;
49
49
  pendingServeHandoff = false;
50
- const { serveCommand } = await import("./serve-NI5YIJIJ.js");
50
+ const { serveCommand } = await import("./serve-IURZ4D4U.js");
51
51
  await serveCommand(format);
52
52
  }
53
53
 
@@ -7345,7 +7345,7 @@ var SYSTEM_CLI_COMMANDS = [
7345
7345
  options: { access: stringOption() },
7346
7346
  run: async (input) => {
7347
7347
  if (input.positionals.length > 1) throw usageError("Expected at most one command group");
7348
- const [{ printCliCatalog }, { REGISTERED_CLI_COMMANDS: REGISTERED_CLI_COMMANDS2 }] = await Promise.all([import("./cli-catalog-2IKVWAJ7.js"), import("./cli-commands-RQNXVVYE.js")]);
7348
+ const [{ printCliCatalog }, { REGISTERED_CLI_COMMANDS: REGISTERED_CLI_COMMANDS2 }] = await Promise.all([import("./cli-catalog-2IKVWAJ7.js"), import("./cli-commands-SEYCDGTO.js")]);
7349
7349
  printCliCatalog(REGISTERED_CLI_COMMANDS2, input.format, input.positionals[0], getString(input.values, "access"));
7350
7350
  }
7351
7351
  },
@@ -7394,7 +7394,7 @@ var SYSTEM_CLI_COMMANDS = [
7394
7394
  },
7395
7395
  allowPositionals: false,
7396
7396
  run: async (input) => {
7397
- const { initCommand } = await import("./init-PYBQBY4K.js");
7397
+ const { initCommand } = await import("./init-KAEFZHQB.js");
7398
7398
  await initCommand({
7399
7399
  force: getBoolean(input.values, "force"),
7400
7400
  ref: getString(input.values, "ref"),
@@ -7449,7 +7449,7 @@ var SYSTEM_CLI_COMMANDS = [
7449
7449
  allowPositionals: false,
7450
7450
  run: async (input) => {
7451
7451
  applyServerEnv(input.values);
7452
- const { serveCommand } = await import("./serve-NI5YIJIJ.js");
7452
+ const { serveCommand } = await import("./serve-IURZ4D4U.js");
7453
7453
  await serveCommand(input.format);
7454
7454
  }
7455
7455
  },
@@ -6458,7 +6458,7 @@ function nonBlank(value) {
6458
6458
  return trimmed ? trimmed : void 0;
6459
6459
  }
6460
6460
  function resolveBuildCommit(env = process.env) {
6461
- const embedded = true ? "8ab5f2b03d2cb3084bbd9cd8e49bebe96b188e38" : void 0;
6461
+ const embedded = true ? "2afcb570cb01acf757180548ea75c7101073721e" : void 0;
6462
6462
  return nonBlank(embedded) ?? nonBlank(env.CANONRY_COMMIT);
6463
6463
  }
6464
6464
  function resolveInstanceIdentity(env = process.env) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  REGISTERED_CLI_COMMANDS
3
- } from "./chunk-JRG52PSI.js";
3
+ } from "./chunk-L6G22DGG.js";
4
4
  import "./chunk-6GO5VVAC.js";
5
5
  import "./chunk-VJWDBFSL.js";
6
6
  import "./chunk-LU3TWJX7.js";
package/dist/cli.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node --import tsx
2
2
  import {
3
3
  REGISTERED_CLI_COMMANDS
4
- } from "./chunk-JRG52PSI.js";
4
+ } from "./chunk-L6G22DGG.js";
5
5
  import "./chunk-6GO5VVAC.js";
6
6
  import {
7
7
  buildSetupState,
8
8
  runPendingServeHandoff
9
- } from "./chunk-VHXEXBGL.js";
9
+ } from "./chunk-J7RHAKTA.js";
10
10
  import "./chunk-VJWDBFSL.js";
11
11
  import "./chunk-LU3TWJX7.js";
12
12
  import "./chunk-TSENU4GG.js";