@canonry/canonry 4.174.0 → 4.176.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{r as c,j as e,h as V,u as U,f as E,L}from"./vendor-tanstack-Dock0eH1.js";import{cT as O,cU as z,cV as I,cW as F,cX as A,B as N,f as B,cY as W,bU as $,k as D,i as w,d as S,cZ as H,T as G}from"./index-CQ2ysGTv.js";import{b as J,c as M,d as Q,a as T,f as _,t as K}from"./extract-error-message-p-Yg_eOO.js";import{G as Y,w as X,x as Z,y as ee,p as q,A as te}from"./vendor-lucide-nYKv-BB7.js";import"./vendor-radix-4UOaVWza.js";import"./vendor-recharts-D8rt5lKn.js";import"./vendor-markdown-Bn7fRwrx.js";import"./vendor-yaml-GWJz5H2G.js";function re({open:t,onOpenChange:a,projectName:n}){const[r,s]=c.useState("pick");c.useEffect(()=>{t&&s("pick")},[t]);const o=()=>{a(!1),s("pick")};return e.jsx(O,{open:t,onOpenChange:i=>{i?a(!0):o()},children:e.jsx(z,{children:r==="pick"?e.jsx(ne,{onPick:s}):r==="wordpress"?e.jsx(ie,{projectName:n,onBack:()=>s("pick"),onClose:o}):r==="vercel"?e.jsx(ce,{projectName:n,onBack:()=>s("pick"),onClose:o}):e.jsx(le,{projectName:n,onBack:()=>s("pick"),onClose:o})})})}const se=[{type:"wordpress",name:"WordPress",action:"Install the traffic plugin",icon:Y},{type:"cloud-run",name:"Google Cloud Run",action:"Read request logs",icon:X},{type:"vercel",name:"Vercel",action:"Read request logs",icon:Z}];function ne({onPick:t}){return e.jsxs(e.Fragment,{children:[e.jsxs(I,{children:[e.jsx(F,{children:"Connect a traffic source"}),e.jsx(A,{children:"Choose where Canonry should read traffic logs."})]}),e.jsx("div",{className:"mt-6 flex flex-col gap-3",children:se.map(({type:a,name:n,action:r,icon:s})=>e.jsxs("button",{type:"button",onClick:()=>t(a),className:"group flex items-center gap-3 rounded-md border border-base bg-bg-elevated/30 px-3 py-3 text-left transition-colors hover:border-mono-600 hover:bg-bg-elevated/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:[e.jsx("span",{className:"mt-0.5 inline-flex size-9 shrink-0 items-center justify-center rounded-md border border-base bg-bg text-neutral group-hover:text-heading",children:e.jsx(s,{className:"size-4"})}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline justify-between gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-heading",children:n}),e.jsx("span",{className:"text-sm text-secondary",children:r})]})]},a))})]})}function oe({title:t,description:a,onBack:n}){return e.jsxs(I,{children:[e.jsxs("button",{type:"button",onClick:n,className:"mb-1 inline-flex w-fit items-center gap-1 rounded text-sm text-secondary transition-colors hover:text-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:[e.jsx(ee,{className:"size-3"}),"Choose a different source"]}),e.jsx(F,{children:t}),e.jsx(A,{children:a})]})}function ae(t,a){const n=V();return async(r,s)=>{await W(t,r),s?.(),a(),n({to:"/traffic/$projectName/$sourceId",params:{projectName:t,sourceId:r}})}}function k(t,a){const[n,r]=c.useState(null),s=ae(t,a);return{error:n,runConnect:async i=>{r(null);const d=i.validate();if(d){r(d);return}let u;try{u=await i.mutate()}catch(l){r(T(l));return}try{await s(u.id,i.onConnected)}catch(l){r(`Source connected, but starting the initial backfill failed: ${T(l)}`)}}}}function P({title:t,description:a,projectName:n,onBack:r,onClose:s,onSubmit:o,isPending:i,error:d,children:u}){return e.jsxs(e.Fragment,{children:[e.jsx(oe,{title:t,description:a,onBack:r}),e.jsxs("form",{onSubmit:B(async l=>{l.preventDefault(),await o()}),className:"mt-6 flex flex-col gap-5 overflow-y-auto pr-1",children:[e.jsx(p,{label:"Project",description:"Canonry project this source attaches to.",children:e.jsx("input",{type:"text",value:n,disabled:!0,className:"w-full rounded border border-strong bg-bg-elevated/50 px-2 py-1.5 text-sm text-neutral"})}),u,d?e.jsx("p",{className:"rounded-md border border-negative-800/50 bg-negative-950/30 px-3 py-2 text-xs text-negative-200",children:d}):null,e.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2 border-t border-default pt-4",children:[e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:s,children:"Close"}),e.jsx(N,{type:"submit",disabled:i,size:"sm",children:i?"Connecting…":"Connect"})]})]})]})}function ie({projectName:t,onBack:a,onClose:n}){const[r,s]=c.useState(""),[o,i]=c.useState(""),[d,u]=c.useState(""),[l,j]=c.useState(""),f=J(t||null),{error:g,runConnect:b}=k(t,n),y=()=>b({validate:()=>r.trim()?o.trim()?d.trim()?null:"Application Password is required.":"Username is required.":"WordPress site URL is required.",mutate:()=>f.mutateAsync({baseUrl:r.trim(),username:o.trim(),applicationPassword:d.trim(),displayName:l.trim()||void 0}),onConnected:()=>u("")});return e.jsxs(P,{title:"Connect a WordPress site",description:e.jsxs(e.Fragment,{children:["Pulls request events from the Canonry Traffic Logger plugin. The Application Password is stored in ",e.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),projectName:t,onBack:a,onClose:n,onSubmit:y,isPending:f.isPending,error:g,children:[e.jsx(p,{label:"WordPress site URL",description:"Base URL of the site running the Canonry Traffic Logger plugin.",required:!0,children:e.jsx("input",{type:"url",value:r,onChange:x=>s(x.target.value),required:!0,autoComplete:"url",placeholder:"https://example.com",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Username",description:"WordPress user that owns the Application Password.",required:!0,children:e.jsx("input",{type:"text",value:o,onChange:x=>i(x.target.value),required:!0,autoComplete:"username",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Application Password",description:"Create one in wp-admin under Users -> Profile -> Application Passwords.",required:!0,children:e.jsx("input",{type:"password",value:d,onChange:x=>u(x.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the WordPress host.",children:e.jsx("input",{type:"text",value:l,onChange:x=>j(x.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})})]})}function le({projectName:t,onBack:a,onClose:n}){const[r,s]=c.useState(""),[o,i]=c.useState(""),[d,u]=c.useState(""),[l,j]=c.useState(""),[f,g]=c.useState(""),b=Q(t||null),{error:y,runConnect:x}=k(t,n),C=()=>x({validate:()=>r.trim()?f.trim()?null:"Service-account JSON content is required.":"GCP project ID is required.",mutate:()=>b.mutateAsync({gcpProjectId:r.trim(),serviceName:o.trim()||void 0,location:d.trim()||void 0,displayName:l.trim()||void 0,keyJson:f.trim()}),onConnected:()=>g("")}),h=async m=>{if(!m)return;const R=await m.text();g(R)};return e.jsxs(P,{title:"Connect a Cloud Run service",description:e.jsxs(e.Fragment,{children:["v1 supports service-account JSON only. The private key is stored in"," ",e.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),projectName:t,onBack:a,onClose:n,onSubmit:C,isPending:b.isPending,error:y,children:[e.jsx(p,{label:"GCP project ID",description:"The Google Cloud project hosting the Cloud Run service (e.g. my-prod-foo).",required:!0,children:e.jsx("input",{type:"text",value:r,onChange:m=>s(m.target.value),required:!0,autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Service name (optional)",description:"Restrict log pulls to a specific Cloud Run service. Omit to pull all services in the project.",children:e.jsx("input",{type:"text",value:o,onChange:m=>i(m.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Location (optional)",description:"Region of the Cloud Run service (e.g. us-central1). Helpful when multiple regions emit logs.",children:e.jsx("input",{type:"text",value:d,onChange:m=>u(m.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the project + service combo.",children:e.jsx("input",{type:"text",value:l,onChange:m=>j(m.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsxs(p,{label:"Service-account JSON",description:"Paste the contents of the SA key (JSON). The SA needs roles/logging.viewer (or any role granting logging.logEntries.list).",required:!0,children:[e.jsx("textarea",{value:f,onChange:m=>g(m.target.value),rows:6,spellCheck:!1,autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 font-mono text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:'{"type":"service_account","project_id":"…","private_key":"…"}',required:!0}),e.jsxs("label",{className:"mt-2 inline-flex cursor-pointer items-center gap-2 text-sm text-secondary hover:text-strong",children:[e.jsx("input",{type:"file",accept:"application/json,.json",className:"hidden",onChange:m=>{h(m.target.files?.[0]??null)}}),e.jsx("span",{className:"rounded-md border border-base px-2 py-1",children:"Or upload a key file"})]})]})]})}function ce({projectName:t,onBack:a,onClose:n}){const[r,s]=c.useState(""),[o,i]=c.useState(""),[d,u]=c.useState(""),[l,j]=c.useState("production"),[f,g]=c.useState(""),b=M(t||null),{error:y,runConnect:x}=k(t,n),C=()=>x({validate:()=>r.trim()?o.trim()?d.trim()?null:"Vercel personal access token is required.":"Vercel team / account ID is required.":"Vercel project ID is required.",mutate:()=>b.mutateAsync({projectId:r.trim(),teamId:o.trim(),token:d.trim(),environment:l,displayName:f.trim()||void 0}),onConnected:()=>u("")});return e.jsxs(P,{title:"Connect a Vercel project",description:e.jsxs(e.Fragment,{children:["Pulls request logs straight from Vercel, no in-app instrumentation needed. The personal access token is stored in ",e.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),projectName:t,onBack:a,onClose:n,onSubmit:C,isPending:b.isPending,error:y,children:[e.jsx(p,{label:"Vercel project ID",description:"The prj_… id from the Vercel dashboard or .vercel/project.json.",required:!0,children:e.jsx("input",{type:"text",value:r,onChange:h=>s(h.target.value),required:!0,autoComplete:"off",placeholder:"prj_…",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Vercel team / account ID",description:"The Vercel team or personal account that owns the project. Find it as orgId in your .vercel/project.json.",required:!0,children:e.jsx("input",{type:"text",value:o,onChange:h=>i(h.target.value),required:!0,autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Personal access token",description:"Create a Vercel personal access token under Account Settings → Tokens. Tokens can expire, so use a long-lived one.",required:!0,children:e.jsx("input",{type:"password",value:d,onChange:h=>u(h.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Environment",description:"Which deployment environment's request logs to pull.",children:e.jsxs("select",{value:l,onChange:h=>j(h.target.value),className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong focus:border-mono-500 focus:outline-none",children:[e.jsx("option",{value:"production",children:"production"}),e.jsx("option",{value:"preview",children:"preview"})]})}),e.jsx(p,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the Vercel project ID.",children:e.jsx("input",{type:"text",value:f,onChange:h=>g(h.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})})]})}function p({label:t,description:a,required:n,children:r}){return e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"text-sm font-medium text-strong",children:[t,n?e.jsx("span",{className:"ml-1 text-negative-400",children:"*"}):null]}),r,e.jsx("span",{className:"text-[13px] leading-5 text-secondary",children:a})]})}function de(t){if(!t)return"never";const a=Date.now()-new Date(t).getTime(),n=Math.floor(a/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function v(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toLocaleString()}function ye(){const[t,a]=c.useState(""),[n,r]=c.useState(!1),o=U($({client:D})).data??[],i=c.useMemo(()=>t||(o[0]?.name??""),[t,o]),d=_(i||null),u=d.data?.sources??[];return e.jsxs("div",{className:"page-container",children:[e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{className:"page-header-left",children:[e.jsx("h1",{className:"page-title",children:"Traffic sources"}),e.jsx("p",{className:"page-subtitle",children:"AI crawler hits and referral sessions from your server logs."})]}),!w()&&e.jsx("div",{className:"flex flex-wrap items-center justify-end gap-2",children:e.jsxs(N,{type:"button",variant:"outline",size:"sm",onClick:()=>r(!0),disabled:!i,children:[e.jsx(q,{className:"size-3.5"}),"Connect a source"]})})]}),e.jsxs("section",{children:[o.length>1&&e.jsxs("label",{className:"mb-4 flex w-fit items-center gap-2 text-sm font-medium text-secondary",htmlFor:"traffic-project",children:["Project",e.jsx("select",{id:"traffic-project",className:"h-8 min-w-44 rounded-md border border-base bg-bg px-2 text-sm text-heading outline-none transition focus:border-mono-500 focus:ring-1 focus:ring-mono-500",value:i,onChange:l=>a(l.target.value),children:o.map(l=>e.jsx("option",{value:l.name,children:l.displayName??l.name},l.id))})]}),i?d.isLoading?e.jsx(S,{className:"p-6 text-center text-sm text-muted",children:"Loading sources…"}):u.length===0?e.jsxs(S,{className:"p-8 text-center",children:[e.jsxs("p",{className:"text-sm text-neutral",children:["No traffic sources connected for ",i,"."]}),!w()&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Connect a source to start collecting traffic."}),e.jsx("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-2",children:e.jsxs(N,{type:"button",variant:"outline",size:"sm",onClick:()=>r(!0),children:[e.jsx(q,{className:"size-3.5"}),"Connect a source"]})})]})]}):e.jsx(ue,{projectName:i,sources:u}):e.jsx(S,{className:"p-6 text-center text-sm text-muted",children:"No projects yet."})]}),!w()&&e.jsx(re,{open:n,onOpenChange:r,projectName:i})]})}function ue({projectName:t,sources:a}){const n=E({queries:a.map(s=>({...H({client:D,path:{name:t,id:s.id}}),staleTime:3e4}))}),r=a.map((s,o)=>({source:s,detail:n[o]?.data,isLoading:n[o]?.isLoading??!1}));return e.jsx("div",{className:"rounded-xl border border-default bg-surface overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-bg-elevated/50 text-[10px] font-semibold uppercase tracking-wider text-muted",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2 text-left",children:"Source"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Status"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Last sync"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Content crawls"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Infra crawls"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"AI fetches"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"AI referrals"}),e.jsx("th",{className:"px-4 py-2 text-right"})]})}),e.jsx("tbody",{className:"divide-y divide-mono-800/60",children:r.map(({source:s,detail:o,isLoading:i})=>e.jsxs("tr",{className:"hover:bg-bg-elevated/40 transition-colors",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"font-medium text-heading",children:s.displayName})}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx(G,{tone:K(s.status),children:s.status}),s.lastError?e.jsx("p",{className:"mt-1 max-w-[18rem] truncate text-sm text-negative-400",title:s.lastError,children:s.lastError}):null]}),e.jsx("td",{className:"px-4 py-3 text-neutral",children:de(s.lastSyncedAt)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-heading",title:o?`${o.totals24h.crawlerHits.toLocaleString("en-US")} total crawler hits`:void 0,children:i?"—":v(o?.totals24h.crawlerContentHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-muted",children:i?"—":v(o?.totals24h.crawlerInfraHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-heading",children:i?"—":v(o?.totals24h.aiUserFetchHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-heading",children:i?"—":v(o?.totals24h.aiReferralHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsxs(L,{to:"/traffic/$projectName/$sourceId",params:{projectName:t,sourceId:s.id},className:"inline-flex items-center gap-1 text-sm text-secondary hover:text-heading",children:["View",e.jsx(te,{className:"size-3.5"})]})})]},s.id))})]})})}export{ye as TrafficPage};
1
+ import{r as c,j as e,h as V,u as U,f as E,L}from"./vendor-tanstack-Dock0eH1.js";import{cT as O,cU as z,cV as I,cW as F,cX as A,B as N,f as B,cY as W,bU as $,k as D,i as w,d as S,cZ as H,T as G}from"./index-CiQNKNMG.js";import{b as J,c as M,d as Q,a as T,f as _,t as K}from"./extract-error-message-DlPqK0mV.js";import{G as Y,w as X,x as Z,y as ee,p as q,A as te}from"./vendor-lucide-nYKv-BB7.js";import"./vendor-radix-4UOaVWza.js";import"./vendor-recharts-D8rt5lKn.js";import"./vendor-markdown-Bn7fRwrx.js";import"./vendor-yaml-GWJz5H2G.js";function re({open:t,onOpenChange:a,projectName:n}){const[r,s]=c.useState("pick");c.useEffect(()=>{t&&s("pick")},[t]);const o=()=>{a(!1),s("pick")};return e.jsx(O,{open:t,onOpenChange:i=>{i?a(!0):o()},children:e.jsx(z,{children:r==="pick"?e.jsx(ne,{onPick:s}):r==="wordpress"?e.jsx(ie,{projectName:n,onBack:()=>s("pick"),onClose:o}):r==="vercel"?e.jsx(ce,{projectName:n,onBack:()=>s("pick"),onClose:o}):e.jsx(le,{projectName:n,onBack:()=>s("pick"),onClose:o})})})}const se=[{type:"wordpress",name:"WordPress",action:"Install the traffic plugin",icon:Y},{type:"cloud-run",name:"Google Cloud Run",action:"Read request logs",icon:X},{type:"vercel",name:"Vercel",action:"Read request logs",icon:Z}];function ne({onPick:t}){return e.jsxs(e.Fragment,{children:[e.jsxs(I,{children:[e.jsx(F,{children:"Connect a traffic source"}),e.jsx(A,{children:"Choose where Canonry should read traffic logs."})]}),e.jsx("div",{className:"mt-6 flex flex-col gap-3",children:se.map(({type:a,name:n,action:r,icon:s})=>e.jsxs("button",{type:"button",onClick:()=>t(a),className:"group flex items-center gap-3 rounded-md border border-base bg-bg-elevated/30 px-3 py-3 text-left transition-colors hover:border-mono-600 hover:bg-bg-elevated/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:[e.jsx("span",{className:"mt-0.5 inline-flex size-9 shrink-0 items-center justify-center rounded-md border border-base bg-bg text-neutral group-hover:text-heading",children:e.jsx(s,{className:"size-4"})}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline justify-between gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-heading",children:n}),e.jsx("span",{className:"text-sm text-secondary",children:r})]})]},a))})]})}function oe({title:t,description:a,onBack:n}){return e.jsxs(I,{children:[e.jsxs("button",{type:"button",onClick:n,className:"mb-1 inline-flex w-fit items-center gap-1 rounded text-sm text-secondary transition-colors hover:text-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:[e.jsx(ee,{className:"size-3"}),"Choose a different source"]}),e.jsx(F,{children:t}),e.jsx(A,{children:a})]})}function ae(t,a){const n=V();return async(r,s)=>{await W(t,r),s?.(),a(),n({to:"/traffic/$projectName/$sourceId",params:{projectName:t,sourceId:r}})}}function k(t,a){const[n,r]=c.useState(null),s=ae(t,a);return{error:n,runConnect:async i=>{r(null);const d=i.validate();if(d){r(d);return}let u;try{u=await i.mutate()}catch(l){r(T(l));return}try{await s(u.id,i.onConnected)}catch(l){r(`Source connected, but starting the initial backfill failed: ${T(l)}`)}}}}function P({title:t,description:a,projectName:n,onBack:r,onClose:s,onSubmit:o,isPending:i,error:d,children:u}){return e.jsxs(e.Fragment,{children:[e.jsx(oe,{title:t,description:a,onBack:r}),e.jsxs("form",{onSubmit:B(async l=>{l.preventDefault(),await o()}),className:"mt-6 flex flex-col gap-5 overflow-y-auto pr-1",children:[e.jsx(p,{label:"Project",description:"Canonry project this source attaches to.",children:e.jsx("input",{type:"text",value:n,disabled:!0,className:"w-full rounded border border-strong bg-bg-elevated/50 px-2 py-1.5 text-sm text-neutral"})}),u,d?e.jsx("p",{className:"rounded-md border border-negative-800/50 bg-negative-950/30 px-3 py-2 text-xs text-negative-200",children:d}):null,e.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2 border-t border-default pt-4",children:[e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:s,children:"Close"}),e.jsx(N,{type:"submit",disabled:i,size:"sm",children:i?"Connecting…":"Connect"})]})]})]})}function ie({projectName:t,onBack:a,onClose:n}){const[r,s]=c.useState(""),[o,i]=c.useState(""),[d,u]=c.useState(""),[l,j]=c.useState(""),f=J(t||null),{error:g,runConnect:b}=k(t,n),y=()=>b({validate:()=>r.trim()?o.trim()?d.trim()?null:"Application Password is required.":"Username is required.":"WordPress site URL is required.",mutate:()=>f.mutateAsync({baseUrl:r.trim(),username:o.trim(),applicationPassword:d.trim(),displayName:l.trim()||void 0}),onConnected:()=>u("")});return e.jsxs(P,{title:"Connect a WordPress site",description:e.jsxs(e.Fragment,{children:["Pulls request events from the Canonry Traffic Logger plugin. The Application Password is stored in ",e.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),projectName:t,onBack:a,onClose:n,onSubmit:y,isPending:f.isPending,error:g,children:[e.jsx(p,{label:"WordPress site URL",description:"Base URL of the site running the Canonry Traffic Logger plugin.",required:!0,children:e.jsx("input",{type:"url",value:r,onChange:x=>s(x.target.value),required:!0,autoComplete:"url",placeholder:"https://example.com",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Username",description:"WordPress user that owns the Application Password.",required:!0,children:e.jsx("input",{type:"text",value:o,onChange:x=>i(x.target.value),required:!0,autoComplete:"username",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Application Password",description:"Create one in wp-admin under Users -> Profile -> Application Passwords.",required:!0,children:e.jsx("input",{type:"password",value:d,onChange:x=>u(x.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the WordPress host.",children:e.jsx("input",{type:"text",value:l,onChange:x=>j(x.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})})]})}function le({projectName:t,onBack:a,onClose:n}){const[r,s]=c.useState(""),[o,i]=c.useState(""),[d,u]=c.useState(""),[l,j]=c.useState(""),[f,g]=c.useState(""),b=Q(t||null),{error:y,runConnect:x}=k(t,n),C=()=>x({validate:()=>r.trim()?f.trim()?null:"Service-account JSON content is required.":"GCP project ID is required.",mutate:()=>b.mutateAsync({gcpProjectId:r.trim(),serviceName:o.trim()||void 0,location:d.trim()||void 0,displayName:l.trim()||void 0,keyJson:f.trim()}),onConnected:()=>g("")}),h=async m=>{if(!m)return;const R=await m.text();g(R)};return e.jsxs(P,{title:"Connect a Cloud Run service",description:e.jsxs(e.Fragment,{children:["v1 supports service-account JSON only. The private key is stored in"," ",e.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),projectName:t,onBack:a,onClose:n,onSubmit:C,isPending:b.isPending,error:y,children:[e.jsx(p,{label:"GCP project ID",description:"The Google Cloud project hosting the Cloud Run service (e.g. my-prod-foo).",required:!0,children:e.jsx("input",{type:"text",value:r,onChange:m=>s(m.target.value),required:!0,autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Service name (optional)",description:"Restrict log pulls to a specific Cloud Run service. Omit to pull all services in the project.",children:e.jsx("input",{type:"text",value:o,onChange:m=>i(m.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Location (optional)",description:"Region of the Cloud Run service (e.g. us-central1). Helpful when multiple regions emit logs.",children:e.jsx("input",{type:"text",value:d,onChange:m=>u(m.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the project + service combo.",children:e.jsx("input",{type:"text",value:l,onChange:m=>j(m.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsxs(p,{label:"Service-account JSON",description:"Paste the contents of the SA key (JSON). The SA needs roles/logging.viewer (or any role granting logging.logEntries.list).",required:!0,children:[e.jsx("textarea",{value:f,onChange:m=>g(m.target.value),rows:6,spellCheck:!1,autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 font-mono text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:'{"type":"service_account","project_id":"…","private_key":"…"}',required:!0}),e.jsxs("label",{className:"mt-2 inline-flex cursor-pointer items-center gap-2 text-sm text-secondary hover:text-strong",children:[e.jsx("input",{type:"file",accept:"application/json,.json",className:"hidden",onChange:m=>{h(m.target.files?.[0]??null)}}),e.jsx("span",{className:"rounded-md border border-base px-2 py-1",children:"Or upload a key file"})]})]})]})}function ce({projectName:t,onBack:a,onClose:n}){const[r,s]=c.useState(""),[o,i]=c.useState(""),[d,u]=c.useState(""),[l,j]=c.useState("production"),[f,g]=c.useState(""),b=M(t||null),{error:y,runConnect:x}=k(t,n),C=()=>x({validate:()=>r.trim()?o.trim()?d.trim()?null:"Vercel personal access token is required.":"Vercel team / account ID is required.":"Vercel project ID is required.",mutate:()=>b.mutateAsync({projectId:r.trim(),teamId:o.trim(),token:d.trim(),environment:l,displayName:f.trim()||void 0}),onConnected:()=>u("")});return e.jsxs(P,{title:"Connect a Vercel project",description:e.jsxs(e.Fragment,{children:["Pulls request logs straight from Vercel, no in-app instrumentation needed. The personal access token is stored in ",e.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),projectName:t,onBack:a,onClose:n,onSubmit:C,isPending:b.isPending,error:y,children:[e.jsx(p,{label:"Vercel project ID",description:"The prj_… id from the Vercel dashboard or .vercel/project.json.",required:!0,children:e.jsx("input",{type:"text",value:r,onChange:h=>s(h.target.value),required:!0,autoComplete:"off",placeholder:"prj_…",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Vercel team / account ID",description:"The Vercel team or personal account that owns the project. Find it as orgId in your .vercel/project.json.",required:!0,children:e.jsx("input",{type:"text",value:o,onChange:h=>i(h.target.value),required:!0,autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Personal access token",description:"Create a Vercel personal access token under Account Settings → Tokens. Tokens can expire, so use a long-lived one.",required:!0,children:e.jsx("input",{type:"password",value:d,onChange:h=>u(h.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Environment",description:"Which deployment environment's request logs to pull.",children:e.jsxs("select",{value:l,onChange:h=>j(h.target.value),className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong focus:border-mono-500 focus:outline-none",children:[e.jsx("option",{value:"production",children:"production"}),e.jsx("option",{value:"preview",children:"preview"})]})}),e.jsx(p,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the Vercel project ID.",children:e.jsx("input",{type:"text",value:f,onChange:h=>g(h.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})})]})}function p({label:t,description:a,required:n,children:r}){return e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"text-sm font-medium text-strong",children:[t,n?e.jsx("span",{className:"ml-1 text-negative-400",children:"*"}):null]}),r,e.jsx("span",{className:"text-[13px] leading-5 text-secondary",children:a})]})}function de(t){if(!t)return"never";const a=Date.now()-new Date(t).getTime(),n=Math.floor(a/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function v(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toLocaleString()}function ye(){const[t,a]=c.useState(""),[n,r]=c.useState(!1),o=U($({client:D})).data??[],i=c.useMemo(()=>t||(o[0]?.name??""),[t,o]),d=_(i||null),u=d.data?.sources??[];return e.jsxs("div",{className:"page-container",children:[e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{className:"page-header-left",children:[e.jsx("h1",{className:"page-title",children:"Traffic sources"}),e.jsx("p",{className:"page-subtitle",children:"AI crawler hits and referral sessions from your server logs."})]}),!w()&&e.jsx("div",{className:"flex flex-wrap items-center justify-end gap-2",children:e.jsxs(N,{type:"button",variant:"outline",size:"sm",onClick:()=>r(!0),disabled:!i,children:[e.jsx(q,{className:"size-3.5"}),"Connect a source"]})})]}),e.jsxs("section",{children:[o.length>1&&e.jsxs("label",{className:"mb-4 flex w-fit items-center gap-2 text-sm font-medium text-secondary",htmlFor:"traffic-project",children:["Project",e.jsx("select",{id:"traffic-project",className:"h-8 min-w-44 rounded-md border border-base bg-bg px-2 text-sm text-heading outline-none transition focus:border-mono-500 focus:ring-1 focus:ring-mono-500",value:i,onChange:l=>a(l.target.value),children:o.map(l=>e.jsx("option",{value:l.name,children:l.displayName??l.name},l.id))})]}),i?d.isLoading?e.jsx(S,{className:"p-6 text-center text-sm text-muted",children:"Loading sources…"}):u.length===0?e.jsxs(S,{className:"p-8 text-center",children:[e.jsxs("p",{className:"text-sm text-neutral",children:["No traffic sources connected for ",i,"."]}),!w()&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Connect a source to start collecting traffic."}),e.jsx("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-2",children:e.jsxs(N,{type:"button",variant:"outline",size:"sm",onClick:()=>r(!0),children:[e.jsx(q,{className:"size-3.5"}),"Connect a source"]})})]})]}):e.jsx(ue,{projectName:i,sources:u}):e.jsx(S,{className:"p-6 text-center text-sm text-muted",children:"No projects yet."})]}),!w()&&e.jsx(re,{open:n,onOpenChange:r,projectName:i})]})}function ue({projectName:t,sources:a}){const n=E({queries:a.map(s=>({...H({client:D,path:{name:t,id:s.id}}),staleTime:3e4}))}),r=a.map((s,o)=>({source:s,detail:n[o]?.data,isLoading:n[o]?.isLoading??!1}));return e.jsx("div",{className:"rounded-xl border border-default bg-surface overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-bg-elevated/50 text-[10px] font-semibold uppercase tracking-wider text-muted",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2 text-left",children:"Source"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Status"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Last sync"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Content crawls"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Infra crawls"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"AI fetches"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"AI referrals"}),e.jsx("th",{className:"px-4 py-2 text-right"})]})}),e.jsx("tbody",{className:"divide-y divide-mono-800/60",children:r.map(({source:s,detail:o,isLoading:i})=>e.jsxs("tr",{className:"hover:bg-bg-elevated/40 transition-colors",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"font-medium text-heading",children:s.displayName})}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx(G,{tone:K(s.status),children:s.status}),s.lastError?e.jsx("p",{className:"mt-1 max-w-[18rem] truncate text-sm text-negative-400",title:s.lastError,children:s.lastError}):null]}),e.jsx("td",{className:"px-4 py-3 text-neutral",children:de(s.lastSyncedAt)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-heading",title:o?`${o.totals24h.crawlerHits.toLocaleString("en-US")} total crawler hits`:void 0,children:i?"—":v(o?.totals24h.crawlerContentHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-muted",children:i?"—":v(o?.totals24h.crawlerInfraHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-heading",children:i?"—":v(o?.totals24h.aiUserFetchHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-heading",children:i?"—":v(o?.totals24h.aiReferralHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsxs(L,{to:"/traffic/$projectName/$sourceId",params:{projectName:t,sourceId:s.id},className:"inline-flex items-center gap-1 text-sm text-secondary hover:text-heading",children:["View",e.jsx(te,{className:"size-3.5"})]})})]},s.id))})]})})}export{ye as TrafficPage};
@@ -0,0 +1 @@
1
+ import{j as e,C as Ee,E as $e,r as i,L as Fe}from"./vendor-tanstack-Dock0eH1.js";import{c_ as W,c$ as o,d as H,I as P,T as He,i as ae,B as Pe,d0 as Ue}from"./index-CiQNKNMG.js";import{g as Oe,h as Me,i as _e,t as De,a as Be}from"./extract-error-message-DlPqK0mV.js";import{e as Y,h as Ke,C as re,a as ne,c as ze}from"./ChartPrimitives-BoYe2M-i.js";import{q as Ge,z as We,e as Ve,y as le,X as qe}from"./vendor-lucide-nYKv-BB7.js";import{R as Xe,B as Qe,a as Ye,X as Ze,Y as Je,T as et,f as V,g as q}from"./vendor-recharts-D8rt5lKn.js";import"./vendor-radix-4UOaVWza.js";import"./vendor-markdown-Bn7fRwrx.js";import"./vendor-yaml-GWJz5H2G.js";const tt=[{value:"all",label:"All status"},{value:"2xx",label:"2xx success"},{value:"3xx",label:"3xx redirect"},{value:"4xx",label:"4xx client error"},{value:"5xx",label:"5xx server error"}],me=[{value:"all",label:"All claims"},{value:W.verified,label:"Verified"},{value:W.claimed_unverified,label:"Claimed unverified"},{value:W.unknown_ai_like,label:"Unknown AI-like"}];function st(s){return s==="all"?null:Number.parseInt(s[0],10)}function fe(s){switch(s.kind){case o.crawler:case o["ai-user-fetch"]:return s.botId;case o["ai-referral"]:return s.product}}function pe(s){switch(s.kind){case o.crawler:case o["ai-user-fetch"]:return s.pathNormalized;case o["ai-referral"]:return s.landingPathNormalized}}function at(s){switch(s.kind){case o.crawler:case o["ai-user-fetch"]:return s.verificationStatus;case o["ai-referral"]:return null}}function rt(s,a){if(a==="hour")return s;const r=new Date(s),n=r.getFullYear(),u=String(r.getMonth()+1).padStart(2,"0"),f=String(r.getDate()).padStart(2,"0");return`${n}-${u}-${f}`}function nt(s,a,r){const n=a.pathQuery.trim().toLowerCase(),u=st(a.statusClass);return s.filter(f=>!(a.selectedBucket&&rt(f.tsHour,r)!==a.selectedBucket||a.identity&&fe(f)!==a.identity||a.operator&&f.operator!==a.operator||n&&!pe(f).toLowerCase().includes(n)||u!==null&&Math.floor(f.status/100)!==u||a.verification!=="all"&&at(f)!==a.verification))}function lt(s,a){if(!s||typeof s!="object")return null;const r=s.activeTooltipIndex;let n;if(typeof r=="number")n=r;else if(typeof r=="string"&&r!=="")n=Number(r);else return null;return!Number.isInteger(n)||n<0||n>=a.length?null:a[n]?.bucket??null}const U=[{value:60,label:"1h",granularity:"hour",fetchLimit:500},{value:360,label:"6h",granularity:"hour",fetchLimit:500},{value:1440,label:"24h",granularity:"hour",fetchLimit:500},{value:10080,label:"7d",granularity:"hour",fetchLimit:1e3},{value:720*60,label:"30d",granularity:"day",fetchLimit:2e3},{value:2160*60,label:"90d",granularity:"day",fetchLimit:5e3}],ie=U.find(s=>s.label==="24h")??U[2],I=50,oe=Y[0],ce=Y[2],de=Y[1],ue=Ue();function be(s){const a=new Date(s);return`${a.getMonth()+1}/${a.getDate()} ${String(a.getHours()).padStart(2,"0")}:00`}function it(s){const a=new Date(`${s}T00:00:00`);return`${a.getMonth()+1}/${a.getDate()}`}function xe(s){if(!s)return"never";const a=Date.now()-new Date(s).getTime(),r=Math.floor(a/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const n=Math.floor(r/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}function ot(s){return s.size===1?[...s][0]:"all"}function he({canGoBack:s,className:a}){const r="inline-flex items-center gap-1";if(s){const n=()=>{window.history.back()};return e.jsxs("button",{type:"button",onClick:n,className:`${r} ${a??""}`,children:[e.jsx(le,{className:"size-3"})," Back"]})}return e.jsxs(Fe,{to:"/traffic",className:`${r} ${a??""}`,children:[e.jsx(le,{className:"size-3"})," All sources"]})}function wt(){const s=Ee({strict:!1}),a=s.projectName??"",r=$e(),n=s.sourceId??"",[u,f]=i.useState(ie.value),[x,ye]=i.useState(()=>new Set(["crawler","ai-user-fetch","ai-referral"])),[c,A]=i.useState(null),[p,O]=i.useState(""),[b,M]=i.useState(""),[v,_]=i.useState(""),[N,D]=i.useState("all"),[S,B]=i.useState("all"),[je,K]=i.useState(1),[Z,J]=i.useState(null),[ee,te]=i.useState(null),h=i.useMemo(()=>U.find(t=>t.value===u)??ie,[u]),ve=i.useMemo(()=>ot(x),[x]),z=Oe(a||null,n||null),g=Me(a||null,{kind:ve,sourceId:n||void 0,sinceMinutes:u,limit:h.fetchLimit,granularity:h.granularity}),R=_e(a||null,n||null),l=z.data,w=g.data?.events??[],y=g.data?.totals,T=g.data?.eventRows,E=i.useMemo(()=>w.filter(t=>{switch(t.kind){case o.crawler:return x.has("crawler");case o["ai-user-fetch"]:return x.has("ai-user-fetch");case o["ai-referral"]:return x.has("ai-referral")}}),[w,x]),Ne=i.useMemo(()=>{const t=new Set;for(const d of w)t.add(fe(d));return p&&t.add(p),[...t].sort((d,m)=>d.localeCompare(m))},[w,p]),Se=i.useMemo(()=>{const t=new Set;for(const d of w)t.add(d.operator);return b&&t.add(b),[...t].sort((d,m)=>d.localeCompare(m))},[w,b]),j=i.useMemo(()=>nt(E,{selectedBucket:c,identity:p,operator:b,pathQuery:v,statusClass:N,verification:S},h.granularity),[E,c,p,b,v,N,S,h.granularity]);i.useEffect(()=>{K(1)},[E,c,p,b,v,N,S]);const $=Math.max(1,Math.ceil(j.length/I)),F=Math.min(Math.max(1,je),$),L=(F-1)*I,we=i.useMemo(()=>j.slice(L,L+I),[j,L]),Ce=j.length>I,ke=j.length===0?0:L+1,Te=Math.min(L+I,j.length),se=i.useMemo(()=>c?ge(c,h.granularity):null,[c,h.granularity]),C=i.useMemo(()=>ct(g.data?.series.points??[],h.granularity),[g.data?.series.points,h.granularity]),G=t=>{ye(d=>{const m=new Set(d);return m.has(t)?m.size>1&&m.delete(t):m.add(t),m})},Le=t=>{const d=lt(t,C);d&&A(m=>m===d?null:d)},Ie=()=>{A(null),O(""),M(""),_(""),D("all"),B("all")},Ae=!!(c||p||b||v.trim()||N!=="all"||S!=="all"),Re=async()=>{J(null),te(null);try{const t=await R.mutateAsync({sinceMinutes:60});te(`Pulled ${t.pulledEvents} entries · ${t.crawlerHits} crawler · ${t.aiUserFetchHits} AI user fetch · ${t.aiReferralHits} AI referral · ${t.unknownHits} unknown`)}catch(t){J(Be(t))}};return!a||!n?e.jsx("div",{className:"page-container",children:e.jsx("p",{className:"text-sm text-muted",children:"Missing project name or source id in URL."})}):z.isLoading?e.jsx("div",{className:"page-container",children:e.jsx("p",{className:"text-sm text-muted",children:"Loading source…"})}):z.isError||!l?e.jsxs("div",{className:"page-container",children:[e.jsx("p",{className:"text-sm text-negative",children:"Could not load this source."}),e.jsx(he,{canGoBack:r,className:"mt-2 text-xs text-secondary hover:text-strong"})]}):e.jsxs("div",{className:"page-container space-y-8",children:[e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{className:"page-header-left",children:[e.jsx(he,{canGoBack:r,className:"text-xs text-muted hover:text-strong"}),e.jsx("h1",{className:"page-title mt-2",children:l.displayName}),e.jsxs("p",{className:"page-subtitle",children:[l.sourceType," source for ",a]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(He,{tone:De(l.status),children:l.status}),!ae()&&e.jsxs(Pe,{type:"button",variant:"outline",size:"sm",disabled:R.isPending,onClick:()=>{Re()},children:[e.jsx(Ge,{className:`size-3.5 ${R.isPending?"animate-spin":""}`}),R.isPending?"Syncing…":"Sync now"]})]})]}),Z?e.jsx("div",{className:"rounded-md border border-negative-800/50 bg-negative-950/30 px-3 py-2 text-sm text-negative-200",children:Z}):null,ee?e.jsx("div",{className:"rounded-md border border-positive-800/50 bg-positive-950/30 px-3 py-2 text-sm text-positive-200",children:ee}):null,e.jsxs("section",{"aria-labelledby":"traffic-24h-heading",children:[e.jsx("h2",{id:"traffic-24h-heading",className:"mb-3 text-sm font-medium text-heading",children:"Last 24 hours"}),e.jsxs("div",{className:"grid grid-cols-1 divide-y divide-default border-y border-default sm:grid-cols-3 sm:divide-x sm:divide-y-0",children:[e.jsx(Q,{label:"Content crawls",value:l.totals24h.crawlerContentHits,tooltip:`Content and document paths only. Excludes sitemap ${l.totals24h.crawlerSegments.sitemap.toLocaleString("en-US")}, robots ${l.totals24h.crawlerSegments.robots.toLocaleString("en-US")}, assets ${l.totals24h.crawlerSegments.asset.toLocaleString("en-US")}, and ${l.totals24h.crawlerSegments.other.toLocaleString("en-US")} other requests such as feeds, API paths, or downloads. Total crawler hits: ${l.totals24h.crawlerHits.toLocaleString("en-US")}.`}),e.jsx(Q,{label:"AI user fetches",value:l.totals24h.aiUserFetchHits,tooltip:"ChatGPT-User/Perplexity-User fetches initiated by a real user in an AI surface."}),e.jsx(Q,{label:"AI referral sessions",value:l.totals24h.aiReferralHits,tooltip:"Browser click-throughs from AI surfaces, identified by Referer or UTM evidence."})]})]}),e.jsxs("section",{children:[e.jsx("p",{className:"eyebrow mb-4",children:"Latest sync run"}),l.latestRun?e.jsxs(H,{className:"p-4 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-1.5",children:[e.jsxs("span",{className:"text-heading",children:["Status: ",e.jsx("span",{className:"font-medium",children:l.latestRun.status})]}),e.jsxs("span",{className:"text-muted",children:["Started: ",xe(l.latestRun.startedAt)]}),l.latestRun.finishedAt?e.jsxs("span",{className:"text-muted",children:["Finished: ",xe(l.latestRun.finishedAt)]}):null]}),e.jsxs("details",{className:"mt-3",children:[e.jsx("summary",{className:"cursor-pointer text-sm text-secondary hover:text-strong",children:"Run details"}),e.jsx("code",{className:"mt-2 block text-xs text-muted",children:l.latestRun.runId})]}),l.latestRun.error?e.jsx("p",{className:"mt-2 rounded border border-negative-900/40 bg-negative-950/30 px-3 py-2 text-xs text-negative",children:l.latestRun.error}):null]}):e.jsx(H,{className:"px-4 py-3 text-sm text-muted",children:ae()?"No traffic-sync runs recorded yet.":'No traffic-sync runs recorded yet. Hit "Sync now" above to create one.'})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-end justify-between gap-x-4 gap-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted",children:"Events"}),e.jsx("h2",{className:"mt-1 text-base font-semibold text-primary",children:h.granularity==="day"?"Daily rollups":"Hourly rollups"}),y?e.jsxs("p",{className:"mt-1.5 text-xs text-muted",children:[y.crawlerContentHits.toLocaleString("en-US")," content crawls ·"," ",y.crawlerInfraHits.toLocaleString("en-US")," infra (sitemap/robots/assets) ·"," ",y.aiUserFetchHits.toLocaleString("en-US")," AI user fetches ·"," ",y.aiReferralHits.toLocaleString("en-US")," AI referral sessions · last ",h.label," · ",ue]}):null]}),e.jsx("div",{className:"inline-flex rounded-md border border-base p-0.5",role:"toolbar","aria-label":"Window",children:U.map(t=>e.jsx("button",{type:"button",className:`rounded px-2.5 py-1 text-xs ${u===t.value?"bg-bg-elevated text-heading":"text-secondary hover:text-strong"}`,"aria-pressed":u===t.value,onClick:()=>{f(t.value),A(null)},children:t.label},t.value))})]}),e.jsxs(H,{className:"p-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",role:"toolbar","aria-label":"Series",children:[e.jsx(X,{label:"Crawler",color:oe,count:y?.crawlerHits??0,active:x.has("crawler"),onToggle:()=>G("crawler")}),e.jsx(X,{label:"AI user fetches",color:ce,count:y?.aiUserFetchHits??0,active:x.has("ai-user-fetch"),onToggle:()=>G("ai-user-fetch")}),e.jsx(X,{label:"AI referral sessions",color:de,count:y?.aiReferralHits??0,active:x.has("ai-referral"),onToggle:()=>G("ai-referral")})]}),g.isError?e.jsxs("p",{className:"py-12 text-center text-xs text-negative-400",children:["Failed to load events: ",g.error instanceof Error?g.error.message:"Unknown error"]}):g.isLoading?e.jsx("p",{className:"py-12 text-center text-xs text-muted",children:"Loading events…"}):C.length===0?e.jsx("p",{className:"py-12 text-center text-xs text-muted",children:"No events in this window."}):e.jsx("div",{className:"h-72",children:e.jsx(Xe,{children:e.jsxs(Qe,{data:C,margin:{top:4,right:4,bottom:0,left:0},onClick:Le,style:{cursor:"pointer"},children:[e.jsx(Ye,{stroke:Ke,strokeDasharray:"3 3"}),e.jsx(Ze,{dataKey:"label",tick:ne,stroke:re,interval:"preserveStartEnd",minTickGap:h.granularity==="day"?24:32}),e.jsx(Je,{tick:ne,stroke:re,allowDecimals:!1}),e.jsx(et,{...ze}),x.has("crawler")?e.jsx(V,{dataKey:"crawler",name:"Crawler",fill:oe,stackId:"a",children:C.map(t=>e.jsx(q,{fillOpacity:c&&c!==t.bucket?.25:1},t.bucket))}):null,x.has("ai-user-fetch")?e.jsx(V,{dataKey:"aiUserFetch",name:"AI user fetch",fill:ce,stackId:"a",children:C.map(t=>e.jsx(q,{fillOpacity:c&&c!==t.bucket?.25:1},t.bucket))}):null,x.has("ai-referral")?e.jsx(V,{dataKey:"aiReferral",name:"AI referral",fill:de,stackId:"a",children:C.map(t=>e.jsx(q,{fillOpacity:c&&c!==t.bucket?.25:1},t.bucket))}):null]})})})]})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-end justify-between gap-x-4 gap-y-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted",children:"Event rows"}),e.jsxs("p",{className:"mt-1 text-xs text-muted",children:["Showing ",e.jsx("span",{className:"tabular-nums text-neutral",children:j.length.toLocaleString("en-US")})," of"," ",e.jsx("span",{className:"tabular-nums text-muted",children:E.length.toLocaleString("en-US")})," ",T?.truncated?"loaded events":"events",T?.truncated?e.jsxs(e.Fragment,{children:[" ","· loaded ",e.jsx("span",{className:"tabular-nums text-neutral",children:T.returned.toLocaleString("en-US")})," of"," ",e.jsx("span",{className:"tabular-nums text-muted",children:T.total.toLocaleString("en-US")})," rows"]}):null," ","· ",ue]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center text-secondary",children:[e.jsxs("select",{"aria-label":"Filter by identity",value:p,onChange:t=>O(t.target.value),className:"rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:[e.jsx("option",{value:"",children:"All identities"}),Ne.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx(P,{text:"The specific bot or AI product making the request (e.g., GPTBot, ChatGPT-User, Perplexity). One operator usually runs several identities."})]}),e.jsxs("span",{className:"inline-flex items-center text-secondary",children:[e.jsxs("select",{"aria-label":"Filter by operator",value:b,onChange:t=>M(t.target.value),className:"rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:[e.jsx("option",{value:"",children:"All operators"}),Se.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx(P,{text:"The company that runs the bot or product (e.g., OpenAI, Anthropic, Perplexity). Filtering by operator includes every identity under that company."})]}),e.jsx("select",{"aria-label":"Filter by HTTP status class",value:N,onChange:t=>D(t.target.value),className:"rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:tt.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))}),e.jsx("select",{"aria-label":"Filter by verification claim",value:S,onChange:t=>B(t.target.value),className:"rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:me.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))}),e.jsx("input",{type:"search","aria-label":"Filter by path",placeholder:"path contains…",value:v,onChange:t=>_(t.target.value),className:"w-44 rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong placeholder:text-faint focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600"})]})]}),Ae?e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[se?e.jsx(k,{label:`Bucket: ${se}`,onClear:()=>A(null)}):null,p?e.jsx(k,{label:`Identity: ${p}`,onClear:()=>O("")}):null,b?e.jsx(k,{label:`Operator: ${b}`,onClear:()=>M("")}):null,v.trim()?e.jsx(k,{label:`Path: ${v.trim()}`,onClear:()=>_("")}):null,N!=="all"?e.jsx(k,{label:`Status: ${N}`,onClear:()=>D("all")}):null,S!=="all"?e.jsx(k,{label:`Claim: ${dt(S)}`,onClear:()=>B("all")}):null,e.jsx("button",{type:"button",onClick:Ie,className:"text-xs text-muted underline-offset-4 hover:text-strong hover:underline",children:"Clear all"})]}):null,e.jsx(mt,{events:we,truncated:T?.truncated??!1}),Ce?e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-x-4 gap-y-2 text-xs text-secondary",children:[e.jsxs("p",{className:"tabular-nums",children:["Showing ",e.jsx("span",{className:"text-neutral",children:ke.toLocaleString("en-US")}),"–",e.jsx("span",{className:"text-neutral",children:Te.toLocaleString("en-US")})," of"," ",e.jsx("span",{className:"text-neutral",children:j.length.toLocaleString("en-US")})," events"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>K(t=>Math.max(1,t-1)),disabled:F<=1,"aria-label":"Previous page",className:"inline-flex items-center gap-1 rounded-md border border-base bg-bg px-2.5 py-1.5 text-strong transition hover:border-strong hover:text-primary disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:border-base disabled:hover:text-strong",children:[e.jsx(We,{className:"size-3.5"}),"Prev"]}),e.jsxs("span",{className:"tabular-nums",children:["Page ",e.jsx("span",{className:"text-strong",children:F})," of"," ",e.jsx("span",{className:"text-strong",children:$})]}),e.jsxs("button",{type:"button",onClick:()=>K(t=>Math.min($,t+1)),disabled:F>=$,"aria-label":"Next page",className:"inline-flex items-center gap-1 rounded-md border border-base bg-bg px-2.5 py-1.5 text-strong transition hover:border-strong hover:text-primary disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:border-base disabled:hover:text-strong",children:["Next",e.jsx(Ve,{className:"size-3.5"})]})]})]}):null]}),e.jsxs("details",{className:"border-t border-default pt-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm text-secondary hover:text-strong",children:"How traffic is classified"}),e.jsx("p",{className:"mt-2 max-w-3xl text-sm text-secondary",children:"Crawler requests, AI user fetches, and referrals are recorded separately. Filters expose the underlying evidence."})]})]})}function ge(s,a){return a==="day"?it(s):be(s)}function ct(s,a){return s.map(r=>({bucket:r.bucket,label:ge(r.bucket,a),crawler:r.crawlerHits,aiUserFetch:r.aiUserFetchHits,aiReferral:r.aiReferralHits}))}function dt(s){return me.find(a=>a.value===s)?.label??s}function k({label:s,onClear:a}){return e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded border border-strong bg-surface-inset px-2.5 py-1 text-sm text-strong",children:[s,e.jsx("button",{type:"button",onClick:a,"aria-label":`Clear ${s}`,className:"rounded p-0.5 text-secondary hover:bg-mono-700/60 hover:text-heading",children:e.jsx(qe,{className:"size-3"})})]})}function X({label:s,color:a,count:r,active:n,onToggle:u}){return e.jsxs("button",{type:"button",onClick:u,"aria-pressed":n,className:`inline-flex items-center gap-2 rounded border px-3 py-1.5 text-xs font-medium transition ${n?"border-strong bg-surface-inset text-heading":"border-base bg-transparent text-muted hover:text-neutral"}`,children:[e.jsx("span",{"aria-hidden":"true",className:`flex size-3 items-center justify-center rounded-sm border transition-opacity ${n?"border-transparent opacity-100":"border-strong opacity-60"}`,style:n?{backgroundColor:a}:void 0,children:n?"✓":""}),e.jsx("span",{children:s}),e.jsx("span",{className:`tabular-nums ${n?"text-secondary":"text-faint"}`,children:r.toLocaleString("en-US")})]})}function Q({label:s,value:a,tooltip:r}){return e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("p",{className:"flex items-center gap-1 text-sm text-secondary",children:[s,r?e.jsx(P,{text:r}):null]}),e.jsx("p",{className:"mt-1 text-2xl font-semibold tabular-nums text-heading",children:a.toLocaleString("en-US")})]})}function ut(s){switch(s){case o.crawler:return"Crawler";case o["ai-user-fetch"]:return"AI hit";case o["ai-referral"]:return"AI referral"}}function xt(s){switch(s.kind){case o.crawler:case o["ai-user-fetch"]:return s.botId;case o["ai-referral"]:return s.product}}function ht(s){switch(s.kind){case o.crawler:case o["ai-user-fetch"]:return`${s.verificationStatus} · HTTP ${s.status}`;case o["ai-referral"]:return`${s.evidenceType} · ${s.sourceDomain}`}}function mt({events:s,truncated:a=!1}){return s.length===0?e.jsx(H,{className:"p-6 text-center text-sm text-muted",children:a?"No matches in the rows loaded so far. More rows exist beyond the load limit, so narrow the time window to search them.":"No event rows match the current filters."}):e.jsx("div",{className:"rounded-xl border border-default bg-surface overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-bg-elevated/50 text-[10px] font-semibold uppercase tracking-wider text-muted",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2 text-left",children:"Hour"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Kind"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Identity"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Evidence / status"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Path"}),e.jsx("th",{className:"px-4 py-2 text-right",children:e.jsxs("span",{className:"inline-flex items-center",children:["Hits",e.jsx(P,{text:"Each row is one hour-bucket, not one request. Hits is the number of requests in that hour that shared the same identity, path, HTTP status, and verification claim."})]})})]})}),e.jsx("tbody",{className:"divide-y divide-mono-800/60",children:s.map((r,n)=>e.jsxs("tr",{className:"hover:bg-bg-elevated/40 transition-colors",children:[e.jsx("td",{className:"px-4 py-2 font-mono text-xs text-neutral",children:be(r.tsHour)}),e.jsx("td",{className:"px-4 py-2 text-neutral",children:ut(r.kind)}),e.jsxs("td",{className:"px-4 py-2 text-heading",children:[xt(r),e.jsx("span",{className:"ml-2 text-[11px] text-muted",children:r.operator})]}),e.jsx("td",{className:"px-4 py-2 text-neutral",children:ht(r)}),e.jsx("td",{className:"px-4 py-2 truncate font-mono text-xs text-neutral",children:pe(r)}),e.jsx("td",{className:"px-4 py-2 text-right tabular-nums text-heading",children:r.hits})]},`${r.kind}:${r.tsHour}:${n}`))})]})})}export{mt as EventsTable,Q as TrafficKpi,wt as TrafficSourceDetailPage,ot as trafficFetchKind};
@@ -1 +1 @@
1
- import{u as s,r as m,n as o,o as u}from"./vendor-tanstack-Dock0eH1.js";import{g as c,d1 as l,cZ as g,d2 as S,aJ as y,k as t,d3 as v,d4 as i,e as T,d5 as p,d6 as C,d7 as h,d8 as q}from"./index-CQ2ysGTv.js";function F(e){switch(e){case i.connected:return"positive";case i.paused:return"caution";case i.error:return"negative";case i.archived:return"neutral"}}function w(e){const n={};return e.kind&&e.kind!=="all"&&(n.kind=e.kind),e.sourceId&&(n.sourceId=e.sourceId),e.sinceMinutes!==void 0&&(n.since=new Date(Date.now()-e.sinceMinutes*6e4).toISOString()),e.limit!==void 0&&(n.limit=String(e.limit)),e.granularity!==void 0&&(n.granularity=e.granularity),n}function f(e){T(e,"traffic")}function A(e){return s({...l({client:t,path:{name:e??""}}),enabled:!!e,staleTime:c})}function M(e){return s({...q({client:t,path:{name:e??""}}),enabled:!!e,staleTime:c})}function V(e,n){return s({...g({client:t,path:{name:e??"",id:n??""}}),enabled:!!(e&&n),staleTime:c})}function b(e,n){const r=m.useMemo(()=>w(n),[n.kind,n.sourceId,n.sinceMinutes,n.limit,n.granularity]);return s({...S({client:t,path:{name:e??""},query:r}),enabled:!!e,staleTime:c})}function I(e){const n=o();return u({mutationFn:r=>{if(!e)throw new Error("Project is required to connect a Cloud Run source");return h(e,r)},onSuccess:()=>{e&&f(n)}})}function Q(e){const n=o();return u({mutationFn:r=>{if(!e)throw new Error("Project is required to connect a WordPress source");return p(e,r)},onSuccess:()=>{e&&f(n)}})}function R(e){const n=o();return u({mutationFn:r=>{if(!e)throw new Error("Project is required to connect a Vercel source");return C(e,r)},onSuccess:()=>{e&&f(n)}})}function k(e,n){const r=o();return u({mutationFn:d=>{if(!e||!n)throw new Error("Project and sourceId are required to sync");return v(e,n,d??void 0)},onSuccess:()=>{e&&(f(r),r.invalidateQueries({queryKey:y({client:t})}))}})}function a(e){return typeof e=="object"&&e!==null}function E(e){if(e instanceof Error){const n=e;return{message:e.message,code:typeof n.code=="string"?n.code:void 0,details:a(n.details)?n.details:void 0}}if(a(e)){const n=e.error;if(a(n))return{message:typeof n.message=="string"?n.message:"Request failed",code:typeof n.code=="string"?n.code:void 0,details:a(n.details)?n.details:void 0};if(typeof n=="string")return{message:n};const r=e.message;if(typeof r=="string")return{message:r}}return typeof e=="string"?{message:e}:{message:String(e)}}function O(e){return E(e).message}export{O as a,Q as b,R as c,I as d,E as e,A as f,V as g,b as h,k as i,F as t,M as u};
1
+ import{u as s,r as m,n as o,o as u}from"./vendor-tanstack-Dock0eH1.js";import{g as c,d1 as l,cZ as g,d2 as S,aJ as y,k as t,d3 as v,d4 as i,e as T,d5 as p,d6 as C,d7 as h,d8 as q}from"./index-CiQNKNMG.js";function F(e){switch(e){case i.connected:return"positive";case i.paused:return"caution";case i.error:return"negative";case i.archived:return"neutral"}}function w(e){const n={};return e.kind&&e.kind!=="all"&&(n.kind=e.kind),e.sourceId&&(n.sourceId=e.sourceId),e.sinceMinutes!==void 0&&(n.since=new Date(Date.now()-e.sinceMinutes*6e4).toISOString()),e.limit!==void 0&&(n.limit=String(e.limit)),e.granularity!==void 0&&(n.granularity=e.granularity),n}function f(e){T(e,"traffic")}function A(e){return s({...l({client:t,path:{name:e??""}}),enabled:!!e,staleTime:c})}function M(e){return s({...q({client:t,path:{name:e??""}}),enabled:!!e,staleTime:c})}function V(e,n){return s({...g({client:t,path:{name:e??"",id:n??""}}),enabled:!!(e&&n),staleTime:c})}function b(e,n){const r=m.useMemo(()=>w(n),[n.kind,n.sourceId,n.sinceMinutes,n.limit,n.granularity]);return s({...S({client:t,path:{name:e??""},query:r}),enabled:!!e,staleTime:c})}function I(e){const n=o();return u({mutationFn:r=>{if(!e)throw new Error("Project is required to connect a Cloud Run source");return h(e,r)},onSuccess:()=>{e&&f(n)}})}function Q(e){const n=o();return u({mutationFn:r=>{if(!e)throw new Error("Project is required to connect a WordPress source");return p(e,r)},onSuccess:()=>{e&&f(n)}})}function R(e){const n=o();return u({mutationFn:r=>{if(!e)throw new Error("Project is required to connect a Vercel source");return C(e,r)},onSuccess:()=>{e&&f(n)}})}function k(e,n){const r=o();return u({mutationFn:d=>{if(!e||!n)throw new Error("Project and sourceId are required to sync");return v(e,n,d??void 0)},onSuccess:()=>{e&&(f(r),r.invalidateQueries({queryKey:y({client:t})}))}})}function a(e){return typeof e=="object"&&e!==null}function E(e){if(e instanceof Error){const n=e;return{message:e.message,code:typeof n.code=="string"?n.code:void 0,details:a(n.details)?n.details:void 0}}if(a(e)){const n=e.error;if(a(n))return{message:typeof n.message=="string"?n.message:"Request failed",code:typeof n.code=="string"?n.code:void 0,details:a(n.details)?n.details:void 0};if(typeof n=="string")return{message:n};const r=e.message;if(typeof r=="string")return{message:r}}return typeof e=="string"?{message:e}:{message:String(e)}}function O(e){return E(e).message}export{O as a,Q as b,R as c,I as d,E as e,A as f,V as g,b as h,k as i,F as t,M as u};
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SiteHealthSection-vGzpNzMx.js","./vendor-tanstack-Dock0eH1.js","./vendor-lucide-nYKv-BB7.js","./ChartPrimitives-BoYe2M-i.js","./vendor-recharts-D8rt5lKn.js","./ProjectPage-BAiCXEdR.js","./RunRow-t5iSzB9b.js","./extract-error-message-p-Yg_eOO.js","./AuditHistoryPanel-BRh-VMv0.js","./v2-overview-adapter-COMP5UGt.js","./vendor-radix-4UOaVWza.js","./vendor-markdown-Bn7fRwrx.js","./vendor-yaml-GWJz5H2G.js","./RunsPage-DR8qc686.js","./HistoryPage-Dtr3UICp.js","./SettingsPage-CCqitKyF.js","./BacklinksPage-C2jbDAhv.js","./TrafficPage-DpFRbcIy.js","./TrafficSourceDetailPage-CToOAg5Y.js","./MeasurementPropertyPage-D-z4CVyy.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SiteHealthSection-B9WF97sJ.js","./vendor-tanstack-Dock0eH1.js","./vendor-lucide-nYKv-BB7.js","./ChartPrimitives-BoYe2M-i.js","./vendor-recharts-D8rt5lKn.js","./ProjectPage-CoRkwGec.js","./RunRow--3y-0dSr.js","./extract-error-message-DlPqK0mV.js","./AuditHistoryPanel-aEUCJheK.js","./v2-overview-adapter-COMP5UGt.js","./vendor-radix-4UOaVWza.js","./vendor-markdown-Bn7fRwrx.js","./vendor-yaml-GWJz5H2G.js","./RunsPage-7wdCl_J3.js","./HistoryPage-D0BWQK0c.js","./SettingsPage-D37dV5-m.js","./BacklinksPage-BcWequGL.js","./TrafficPage-Bn1yDSRr.js","./TrafficSourceDetailPage-CURlB_yO.js","./MeasurementPropertyPage-D96eQnYJ.js"])))=>i.map(i=>d[i]);
2
2
  import{c as ij,d as sj,r as D,j as c,Q as oj,M as rj,q as pe,e as uu,L as et,a as lj,t as ro,u as Ft,f as cj,h as ms,k as Tv,l as uj,m as Rv,O as zp,n as Vn,o as ps,p as dj,s as xt,v as Ov,x as Ci,y as mj,z as pj,A as hj}from"./vendor-tanstack-Dock0eH1.js";import{S as fj,O as r0,P as Bv,C as l0,a as qv,T as c0,D as Mv,R as Pv}from"./vendor-radix-4UOaVWza.js";import{c as Iv}from"./vendor-recharts-D8rt5lKn.js";import{A as gj,X as zo,S as yj,L as bo,C as u0,R as yy,a as Vv,M as bj,b as vj,c as xj,d as d0,T as Lv,W as kj,e as m0,f as Uv,g as wj,G as Sj,P as jj,H as Aj,h as Cj,i as Nj,j as _j,k as zj,l as Dj,B as Ej,F as Tj,m as Rj,n as Oj,o as Bj,p as by,E as qj}from"./vendor-lucide-nYKv-BB7.js";import{M as Mj}from"./vendor-markdown-Bn7fRwrx.js";import{p as Pj}from"./vendor-yaml-GWJz5H2G.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))r(u);new MutationObserver(u=>{for(const f of u)if(f.type==="childList")for(const g of f.addedNodes)g.tagName==="LINK"&&g.rel==="modulepreload"&&r(g)}).observe(document,{childList:!0,subtree:!0});function s(u){const f={};return u.integrity&&(f.integrity=u.integrity),u.referrerPolicy&&(f.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?f.credentials="include":u.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function r(u){if(u.ep)return;u.ep=!0;const f=s(u);fetch(u.href,f)}})();var Jm={exports:{}},Or={},Wm={exports:{}},ep={};var vy;function Ij(){return vy||(vy=1,(function(e){function n(V,ne){var fe=V.length;V.push(ne);e:for(;0<fe;){var De=fe-1>>>1,le=V[De];if(0<u(le,ne))V[De]=ne,V[fe]=le,fe=De;else break e}}function s(V){return V.length===0?null:V[0]}function r(V){if(V.length===0)return null;var ne=V[0],fe=V.pop();if(fe!==ne){V[0]=fe;e:for(var De=0,le=V.length,at=le>>>1;De<at;){var H=2*(De+1)-1,ue=V[H],ie=H+1,re=V[ie];if(0>u(ue,fe))ie<le&&0>u(re,ue)?(V[De]=re,V[ie]=fe,De=ie):(V[De]=ue,V[H]=fe,De=H);else if(ie<le&&0>u(re,fe))V[De]=re,V[ie]=fe,De=ie;else break e}}return ne}function u(V,ne){var fe=V.sortIndex-ne.sortIndex;return fe!==0?fe:V.id-ne.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;e.unstable_now=function(){return f.now()}}else{var g=Date,b=g.now();e.unstable_now=function(){return g.now()-b}}var x=[],k=[],S=1,C=null,j=3,E=!1,B=!1,q=!1,U=!1,G=typeof setTimeout=="function"?setTimeout:null,te=typeof clearTimeout=="function"?clearTimeout:null,X=typeof setImmediate<"u"?setImmediate:null;function ae(V){for(var ne=s(k);ne!==null;){if(ne.callback===null)r(k);else if(ne.startTime<=V)r(k),ne.sortIndex=ne.expirationTime,n(x,ne);else break;ne=s(k)}}function oe(V){if(q=!1,ae(V),!B)if(s(x)!==null)B=!0,ge||(ge=!0,Oe());else{var ne=s(k);ne!==null&&ye(oe,ne.startTime-V)}}var ge=!1,M=-1,J=5,_e=-1;function he(){return U?!0:!(e.unstable_now()-_e<J)}function we(){if(U=!1,ge){var V=e.unstable_now();_e=V;var ne=!0;try{e:{B=!1,q&&(q=!1,te(M),M=-1),E=!0;var fe=j;try{t:{for(ae(V),C=s(x);C!==null&&!(C.expirationTime>V&&he());){var De=C.callback;if(typeof De=="function"){C.callback=null,j=C.priorityLevel;var le=De(C.expirationTime<=V);if(V=e.unstable_now(),typeof le=="function"){C.callback=le,ae(V),ne=!0;break t}C===s(x)&&r(x),ae(V)}else r(x);C=s(x)}if(C!==null)ne=!0;else{var at=s(k);at!==null&&ye(oe,at.startTime-V),ne=!1}}break e}finally{C=null,j=fe,E=!1}ne=void 0}}finally{ne?Oe():ge=!1}}}var Oe;if(typeof X=="function")Oe=function(){X(we)};else if(typeof MessageChannel<"u"){var je=new MessageChannel,Fe=je.port2;je.port1.onmessage=we,Oe=function(){Fe.postMessage(null)}}else Oe=function(){G(we,0)};function ye(V,ne){M=G(function(){V(e.unstable_now())},ne)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(V){V.callback=null},e.unstable_forceFrameRate=function(V){0>V||125<V?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):J=0<V?Math.floor(1e3/V):5},e.unstable_getCurrentPriorityLevel=function(){return j},e.unstable_next=function(V){switch(j){case 1:case 2:case 3:var ne=3;break;default:ne=j}var fe=j;j=ne;try{return V()}finally{j=fe}},e.unstable_requestPaint=function(){U=!0},e.unstable_runWithPriority=function(V,ne){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var fe=j;j=V;try{return ne()}finally{j=fe}},e.unstable_scheduleCallback=function(V,ne,fe){var De=e.unstable_now();switch(typeof fe=="object"&&fe!==null?(fe=fe.delay,fe=typeof fe=="number"&&0<fe?De+fe:De):fe=De,V){case 1:var le=-1;break;case 2:le=250;break;case 5:le=1073741823;break;case 4:le=1e4;break;default:le=5e3}return le=fe+le,V={id:S++,callback:ne,priorityLevel:V,startTime:fe,expirationTime:le,sortIndex:-1},fe>De?(V.sortIndex=fe,n(k,V),s(x)===null&&V===s(k)&&(q?(te(M),M=-1):q=!0,ye(oe,fe-De))):(V.sortIndex=le,n(x,V),B||E||(B=!0,ge||(ge=!0,Oe()))),V},e.unstable_shouldYield=he,e.unstable_wrapCallback=function(V){var ne=j;return function(){var fe=j;j=ne;try{return V.apply(this,arguments)}finally{j=fe}}}})(ep)),ep}var xy;function Vj(){return xy||(xy=1,Wm.exports=Ij()),Wm.exports}var ky;function Lj(){if(ky)return Or;ky=1;var e=Vj(),n=ij(),s=sj();function r(t){var a="https://react.dev/errors/"+t;if(1<arguments.length){a+="?args[]="+encodeURIComponent(arguments[1]);for(var i=2;i<arguments.length;i++)a+="&args[]="+encodeURIComponent(arguments[i])}return"Minified React error #"+t+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function u(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function f(t){var a=t,i=t;if(t.alternate)for(;a.return;)a=a.return;else{t=a;do a=t,(a.flags&4098)!==0&&(i=a.return),t=a.return;while(t)}return a.tag===3?i:null}function g(t){if(t.tag===13){var a=t.memoizedState;if(a===null&&(t=t.alternate,t!==null&&(a=t.memoizedState)),a!==null)return a.dehydrated}return null}function b(t){if(t.tag===31){var a=t.memoizedState;if(a===null&&(t=t.alternate,t!==null&&(a=t.memoizedState)),a!==null)return a.dehydrated}return null}function x(t){if(f(t)!==t)throw Error(r(188))}function k(t){var a=t.alternate;if(!a){if(a=f(t),a===null)throw Error(r(188));return a!==t?null:t}for(var i=t,l=a;;){var d=i.return;if(d===null)break;var h=d.alternate;if(h===null){if(l=d.return,l!==null){i=l;continue}break}if(d.child===h.child){for(h=d.child;h;){if(h===i)return x(d),t;if(h===l)return x(d),a;h=h.sibling}throw Error(r(188))}if(i.return!==l.return)i=d,l=h;else{for(var v=!1,w=d.child;w;){if(w===i){v=!0,i=d,l=h;break}if(w===l){v=!0,l=d,i=h;break}w=w.sibling}if(!v){for(w=h.child;w;){if(w===i){v=!0,i=h,l=d;break}if(w===l){v=!0,l=h,i=d;break}w=w.sibling}if(!v)throw Error(r(189))}}if(i.alternate!==l)throw Error(r(190))}if(i.tag!==3)throw Error(r(188));return i.stateNode.current===i?t:a}function S(t){var a=t.tag;if(a===5||a===26||a===27||a===6)return t;for(t=t.child;t!==null;){if(a=S(t),a!==null)return a;t=t.sibling}return null}var C=Object.assign,j=Symbol.for("react.element"),E=Symbol.for("react.transitional.element"),B=Symbol.for("react.portal"),q=Symbol.for("react.fragment"),U=Symbol.for("react.strict_mode"),G=Symbol.for("react.profiler"),te=Symbol.for("react.consumer"),X=Symbol.for("react.context"),ae=Symbol.for("react.forward_ref"),oe=Symbol.for("react.suspense"),ge=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),_e=Symbol.for("react.activity"),he=Symbol.for("react.memo_cache_sentinel"),we=Symbol.iterator;function Oe(t){return t===null||typeof t!="object"?null:(t=we&&t[we]||t["@@iterator"],typeof t=="function"?t:null)}var je=Symbol.for("react.client.reference");function Fe(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===je?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case q:return"Fragment";case G:return"Profiler";case U:return"StrictMode";case oe:return"Suspense";case ge:return"SuspenseList";case _e:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case B:return"Portal";case X:return t.displayName||"Context";case te:return(t._context.displayName||"Context")+".Consumer";case ae:var a=t.render;return t=t.displayName,t||(t=a.displayName||a.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case M:return a=t.displayName||null,a!==null?a:Fe(t.type)||"Memo";case J:a=t._payload,t=t._init;try{return Fe(t(a))}catch{}}return null}var ye=Array.isArray,V=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,fe={pending:!1,data:null,method:null,action:null},De=[],le=-1;function at(t){return{current:t}}function H(t){0>le||(t.current=De[le],De[le]=null,le--)}function ue(t,a){le++,De[le]=t.current,t.current=a}var ie=at(null),re=at(null),W=at(null),Z=at(null);function Ne(t,a){switch(ue(W,a),ue(re,t),ue(ie,null),a.nodeType){case 9:case 11:t=(t=a.documentElement)&&(t=t.namespaceURI)?V1(t):0;break;default:if(t=a.tagName,a=a.namespaceURI)a=V1(a),t=L1(a,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}H(ie),ue(ie,t)}function Ae(){H(ie),H(re),H(W)}function st(t){t.memoizedState!==null&&ue(Z,t);var a=ie.current,i=L1(a,t.type);a!==i&&(ue(re,t),ue(ie,i))}function Qe(t){re.current===t&&(H(ie),H(re)),Z.current===t&&(H(Z),Dr._currentValue=fe)}var Pt,jt;function Ct(t){if(Pt===void 0)try{throw Error()}catch(i){var a=i.stack.trim().match(/\n( *(at )?)/);Pt=a&&a[1]||"",jt=-1<i.stack.indexOf(`
3
3
  at`)?" (<anonymous>)":-1<i.stack.indexOf("@")?"@unknown:0:0":""}return`
4
4
  `+Pt+t+jt}var Gn=!1;function Ri(t,a){if(!t||Gn)return"";Gn=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(a){var ee=function(){throw Error()};if(Object.defineProperty(ee.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ee,[])}catch($){var L=$}Reflect.construct(t,[],ee)}else{try{ee.call()}catch($){L=$}t.call(ee.prototype)}}else{try{throw Error()}catch($){L=$}(ee=t())&&typeof ee.catch=="function"&&ee.catch(function(){})}}catch($){if($&&L&&typeof $.stack=="string")return[$.stack,L.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var d=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");d&&d.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var h=l.DetermineComponentFrameRoot(),v=h[0],w=h[1];if(v&&w){var N=v.split(`
@@ -80,4 +80,4 @@ spec:
80
80
  `);Ri(qe),ta(!0)}}catch(F){$n(F instanceof Error?F.message:"Failed to generate queries"),B({flowVersion:zt,onboardingSessionId:j,event:"onboarding.blocked",step:"queries",action:"generate_queries",reasonCode:Nv(F,"unknown")},"onboarding.blocked:queries:generate")}finally{fl(!1)}}},Zn=async()=>{if(!Ne)return;const F=Dt;if(F.length!==0){Mi(!0),bl(null);try{await xA(Ne,F),Gu(!0),await r(),B({flowVersion:zt,onboardingSessionId:j,event:"onboarding.step_completed",step:"competitors",method:"manual",countBucket:cn(F.length)},"onboarding.step_completed:competitors"),je(4)}catch(qe){bl(qe instanceof Error?qe.message:"Failed to save competitors"),B({flowVersion:zt,onboardingSessionId:j,event:"onboarding.blocked",step:"competitors",action:"save",reasonCode:"unknown"},"onboarding.blocked:competitors:save")}finally{Mi(!1)}}},$i=async()=>{const F=Ss.trim();if(F){js(!0),$o(null);try{await AA("gemini",{apiKey:F}),Yt({title:"Gemini configured",detail:"Provider is ready — continuing setup.",tone:"positive",dedupeKey:"setup:gemini:configured",dedupeMode:"drop"}),Uo(""),await r(),Oi(b.providerStatuses.find(qe=>qe.name.toLowerCase()==="gemini")?.name??"gemini"),B({flowVersion:zt,onboardingSessionId:j,event:"onboarding.step_completed",step:"system",method:"inline"},"onboarding.step_completed:system")}catch(qe){$o(qe instanceof Error?qe.message:"Failed to save Gemini key"),B({flowVersion:zt,onboardingSessionId:j,event:"onboarding.blocked",step:"system",action:"configure_provider",reasonCode:"provider_save_failed"},"onboarding.blocked:system:provider_save_failed")}finally{js(!1)}}},hn=async()=>{if(!Ne||Ha){ws(Ha??"Complete setup before launching the first sweep.");const F=Kn??(Ne?Da===0?"no_queries":"run_rejected":"unknown");B({flowVersion:zt,onboardingSessionId:j,event:"run.requested",origin:"dashboard_setup",result:"rejected",providerCountBucket:cn(xa.length),queryCountBucket:cn(Da),reasonCode:F});return}Hn(!0),ws(null);try{const F=await $u.mutateAsync({projectName:Ne,projectLabel:fe||V||Ne,sourceAction:"setup-launch"});Vi(F.id),dn(!0),B({flowVersion:zt,onboardingSessionId:j,event:"run.requested",origin:"dashboard_setup",result:"queued",providerCountBucket:cn(xa.length),queryCountBucket:cn(Da)}),await r()}catch(F){ws(F instanceof Error?F.message:"Failed to queue the visibility sweep. Retry when the instance is ready."),B({flowVersion:zt,onboardingSessionId:j,event:"run.requested",origin:"dashboard_setup",result:"rejected",providerCountBucket:cn(xa.length),queryCountBucket:cn(Da),reasonCode:Nv(F,"run_rejected")})}finally{Hn(!1)}},mt=()=>je(F=>Math.max(0,F-1)),As=(F,qe,gn)=>{B({flowVersion:zt,onboardingSessionId:j,event:"onboarding.step_completed",step:F,method:"existing",...gn===void 0?{}:{countBucket:cn(gn)}},`onboarding.step_completed:${F}`),je(qe)},vl=()=>{B({flowVersion:zt,onboardingSessionId:j,event:"onboarding.step_completed",step:"queries",method:"skipped",countBucket:"0"},"onboarding.step_completed:queries"),je(3)},fn=()=>{B({flowVersion:zt,onboardingSessionId:j,event:"onboarding.step_completed",step:"competitors",method:"skipped",countBucket:"0"},"onboarding.step_completed:competitors"),je(4)},Fn=(()=>{switch(Oe){case 0:return c.jsxs(_a,{className:"surface-card step-card",children:[c.jsx("div",{className:"section-head",children:c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 1 of 5"}),c.jsx("h2",{children:"System check"})]})}),c.jsx("p",{className:"supporting-copy",children:"Checking that your Canonry instance is configured and reachable."}),c.jsx("div",{className:"compact-stack",children:S.healthChecks.map(F=>c.jsxs("div",{className:"health-check-row",children:[c.jsxs("div",{children:[c.jsx("p",{className:"run-row-title",children:F.label}),c.jsx("p",{className:"supporting-copy",children:F.detail}),F.id==="provider"&&F.state!=="ready"&&c.jsxs("div",{className:"mt-3 rounded-md border border-default bg-bg-elevated/40 p-3 space-y-2",children:[c.jsxs("p",{className:"text-xs text-secondary",children:["Paste a Gemini key to enable visibility checks (free at"," ",c.jsx("a",{href:"https://aistudio.google.com/apikey",target:"_blank",rel:"noreferrer",className:"text-positive-400 hover:text-positive underline underline-offset-2",children:"aistudio.google.com"}),")."]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"password",value:Ss,onChange:qe=>Uo(qe.target.value),placeholder:"AI... (paste here)",className:"flex-1 rounded-md border border-base bg-bg px-2.5 py-1.5 text-sm text-heading placeholder:text-faint focus:border-mono-600 focus:outline-none font-mono",disabled:Li}),c.jsx(xe,{type:"button",size:"sm",disabled:Li||!Ss.trim(),onClick:$t($i),children:Li?"Saving...":"Save"})]}),Go&&c.jsxs("div",{role:"alert",className:"space-y-1 text-xs text-negative",children:[c.jsx("p",{children:Go}),c.jsx("p",{children:"Check that the key is complete, then retry Save."})]}),c.jsxs("p",{className:"text-sm text-secondary",children:["Connect more answer engines later in"," ",c.jsx(et,{to:"/settings",className:"text-link hover:underline",children:"Settings"}),"."]})]})]}),c.jsx(ga,{tone:F.state==="ready"?"positive":"caution",title:F.id==="api"?No(k.apiStatus):F.id==="worker"?No(k.workerStatus):F.detail,children:F.state==="ready"?"Ready":"Attention"})]},F.id))}),c.jsxs("div",{className:"setup-nav",children:[S.launchState.blockedReason?c.jsx("p",{role:"status",className:"supporting-copy text-negative",children:S.launchState.blockedReason}):c.jsx("span",{}),c.jsx(xe,{type:"button",disabled:!S.launchState.enabled,title:S.launchState.blockedReason,onClick:()=>{B({flowVersion:zt,onboardingSessionId:j,event:"onboarding.step_completed",step:"system",method:"automatic"},"onboarding.step_completed:system"),je(we)},children:"Continue"})]})]});case 1:return c.jsxs(_a,{className:"surface-card step-card",children:[c.jsxs("div",{className:"section-head",children:[c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 2 of 5"}),c.jsx("h2",{children:"Create project"})]}),Ne?c.jsx(ga,{tone:"positive",children:"Created"}):null]}),Ne?c.jsxs("div",{className:"compact-stack",children:[c.jsxs("p",{className:"text-neutral",children:["Project ",c.jsx("span",{className:"text-heading font-medium",children:Ne})," created successfully."]}),c.jsxs("div",{className:"setup-nav",children:[c.jsx(xe,{type:"button",variant:"outline",onClick:mt,children:"Back"}),c.jsx(xe,{type:"button",onClick:()=>As("project",2),children:"Continue"})]})]}):c.jsxs("div",{className:"compact-stack",children:[c.jsxs("div",{className:"setup-field",children:[c.jsx("label",{className:"setup-label",htmlFor:"project-name",children:"Project name"}),c.jsx("input",{id:"project-name",className:"setup-input",type:"text",placeholder:"my-website",value:V,onChange:F=>ne(F.target.value)}),Wt&&Wt!==V?c.jsxs("p",{className:"supporting-copy",children:["Slug: ",Wt]}):null]}),c.jsxs("div",{className:"setup-field",children:[c.jsx("label",{className:"setup-label",htmlFor:"display-name",children:"Display name (optional)"}),c.jsx("input",{id:"display-name",className:"setup-input",type:"text",placeholder:"My Website",value:fe,onChange:F=>De(F.target.value)})]}),c.jsxs("div",{className:"setup-field",children:[c.jsx("label",{className:"setup-label",htmlFor:"domain",children:"Canonical domain"}),c.jsx("input",{id:"domain",className:"setup-input",type:"text",placeholder:"example.com",value:le,onChange:F=>at(F.target.value)})]}),c.jsxs("div",{className:"setup-field-row",children:[c.jsxs("div",{className:"setup-field",children:[c.jsx("label",{className:"setup-label",htmlFor:"country",children:"Country"}),c.jsx("input",{id:"country",className:"setup-input",type:"text",placeholder:"US",maxLength:2,value:H,onChange:F=>ue(F.target.value.toUpperCase())})]}),c.jsxs("div",{className:"setup-field",children:[c.jsx("label",{className:"setup-label",htmlFor:"language",children:"Language"}),c.jsx("input",{id:"language",className:"setup-input",type:"text",placeholder:"en",maxLength:5,value:ie,onChange:F=>re(F.target.value.toLowerCase())})]})]}),c.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-default bg-surface p-3 cursor-pointer hover:border-strong",children:[c.jsx("input",{type:"checkbox",className:"mt-0.5 h-4 w-4 rounded border-strong bg-bg",checked:W,onChange:F=>Z(F.target.checked)}),c.jsxs("span",{className:"flex-1",children:[c.jsx("span",{className:"block text-sm text-heading",children:"Auto-extract backlinks"}),c.jsxs("span",{className:"block text-xs text-muted mt-0.5",children:["When a new Common Crawl release syncs, automatically extract backlinks for this project."," ",c.jsx(et,{to:"/backlinks",className:"text-positive-400 hover:text-positive underline underline-offset-2",children:"Manage backlinks"})]})]})]}),st?c.jsx("p",{className:"text-negative-400 text-sm",children:st}):null,c.jsxs("div",{className:"setup-nav",children:[c.jsx(xe,{type:"button",variant:"outline",onClick:mt,children:"Back"}),c.jsx(xe,{type:"button",disabled:!Wt||!le||Pt,onClick:$t(Gi),children:Pt?"Creating...":"Create project"})]})]})]});case 2:return c.jsxs(_a,{className:"surface-card step-card",children:[c.jsxs("div",{className:"section-head",children:[c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 3 of 5"}),c.jsx("h2",{children:"Add queries"})]}),X.isError?c.jsx(ga,{tone:"negative",children:"Load failed"}):Io?c.jsxs(ga,{tone:"positive",children:[lt.length," saved"]}):c.jsxs(ga,{tone:"neutral",children:[lt.length," quer",lt.length!==1?"ies":"y"]})]}),c.jsx("p",{className:"supporting-copy",children:"Enter the queries you want to track, one per line. A rough first list is fine: you can edit them, research more, and add to them at any time from the project."}),X.isError?c.jsxs("div",{className:"compact-stack",children:[c.jsx("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:"Saved queries could not be loaded. Retry before changing the query basket."}),c.jsxs("div",{className:"setup-nav",children:[c.jsx(xe,{type:"button",variant:"outline",onClick:mt,children:"Back"}),c.jsx(xe,{type:"button",onClick:()=>{X.refetch()},children:"Retry loading queries"})]})]}):Io?c.jsxs("div",{className:"compact-stack",children:[c.jsx("ul",{className:"detail-list",children:lt.map(F=>c.jsx("li",{children:F},F))}),c.jsxs("div",{className:"setup-nav",children:[c.jsx(xe,{type:"button",variant:"outline",onClick:mt,children:"Back"}),c.jsx(xe,{type:"button",onClick:()=>As("queries",3,lt.length),children:"Continue"})]})]}):c.jsxs("div",{className:"compact-stack",children:[xa.length>0?c.jsxs("div",{className:"compact-stack",children:[c.jsxs("div",{className:"flex items-center gap-2 text-muted text-xs uppercase tracking-wide",children:[c.jsx("span",{className:"flex-1 border-t border-base"}),"auto-generate",c.jsx("span",{className:"flex-1 border-t border-base"})]}),c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsxs("div",{className:"setup-field flex-1",children:[c.jsx("label",{className:"setup-label",htmlFor:"gen-provider",children:"Provider"}),c.jsx("select",{id:"gen-provider",className:"setup-input",value:un,onChange:F=>Oi(F.target.value),children:xa.map(F=>c.jsxs("option",{value:F.name,children:[F.displayName??F.name,F.model?` (${F.model})`:""]},F.name))})]}),c.jsxs("div",{className:"setup-field",children:[c.jsx("label",{className:"setup-label",htmlFor:"gen-count",children:"Count"}),c.jsx("select",{id:"gen-count",className:"setup-input",value:Bi,onChange:F=>Uu(Number(F.target.value)),children:[3,5,10,15,20].map(F=>c.jsx("option",{value:F,children:F},F))})]}),c.jsx(xe,{type:"button",variant:"outline",disabled:Lo||!un,onClick:$t(Qn),children:Lo?"Analyzing site...":"Generate"})]}),gl?c.jsx("p",{className:"text-negative-400 text-sm",children:gl}):null]}):null,c.jsxs("div",{className:"flex items-center gap-2 text-muted text-xs uppercase tracking-wide",children:[c.jsx("span",{className:"flex-1 border-t border-base"}),"or type manually",c.jsx("span",{className:"flex-1 border-t border-base"})]}),c.jsxs("div",{className:"setup-field",children:[c.jsx("label",{className:"setup-label",htmlFor:"queries",children:"Queries (one per line)"}),c.jsx("textarea",{id:"queries",className:"setup-textarea",rows:6,placeholder:`emergency dentist brooklyn
81
81
  best invisalign downtown brooklyn
82
82
  pediatric dentist brooklyn heights`,value:Gn,onChange:F=>Ri(F.target.value)})]}),vs?c.jsx("p",{className:"text-negative-400 text-sm",children:vs}):null,c.jsxs("div",{className:"setup-nav",children:[c.jsx(xe,{type:"button",variant:"outline",onClick:mt,children:"Back"}),c.jsx(xe,{type:"button",variant:"ghost",onClick:vl,children:"Skip for now"}),c.jsx(xe,{type:"button",disabled:lt.length===0||ks,onClick:$t(Ho),children:ks?"Saving...":`Save ${lt.length} quer${lt.length!==1?"ies":"y"}`})]})]})]});case 3:return c.jsxs(_a,{className:"surface-card step-card",children:[c.jsxs("div",{className:"section-head",children:[c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 4 of 5"}),c.jsx("h2",{children:"Add competitors"})]}),Jt?c.jsx(ga,{tone:"positive",children:"Saved"}):null]}),c.jsx("p",{className:"supporting-copy",children:"Domains that compete for the same queries. One per line."}),Jt?c.jsxs("div",{className:"compact-stack",children:[c.jsx("ul",{className:"detail-list",children:Dt.map(F=>c.jsx("li",{children:F},F))}),c.jsxs("div",{className:"setup-nav",children:[c.jsx(xe,{type:"button",variant:"outline",onClick:mt,children:"Back"}),c.jsx(xe,{type:"button",onClick:()=>As("competitors",4,Dt.length),children:"Continue"})]})]}):c.jsxs("div",{className:"compact-stack",children:[c.jsxs("div",{className:"setup-field",children:[c.jsx("label",{className:"setup-label",htmlFor:"competitors",children:"Competitor domains (one per line)"}),c.jsx("textarea",{id:"competitors",className:"setup-textarea",rows:4,placeholder:`competitor1.com
83
- competitor2.com`,value:Xt,onChange:F=>tn(F.target.value)})]}),yl?c.jsx("p",{className:"text-negative-400 text-sm",children:yl}):null,c.jsxs("div",{className:"setup-nav",children:[c.jsx(xe,{type:"button",variant:"outline",onClick:mt,children:"Back"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(xe,{type:"button",variant:"outline",onClick:fn,children:"Skip"}),c.jsx(xe,{type:"button",disabled:Dt.length===0||qi,onClick:$t(Zn),children:qi?"Saving...":`Save ${Dt.length} competitor${Dt.length!==1?"s":""}`})]})]})]})]});case 4:{const F=an.data,qe=F?.status??(Ii===M?.id?M.status:void 0),gn=qe==="completed"||qe==="partial"||qe==="failed"||qe==="cancelled",Yn=F?.snapshots??[],Cs=Yn.filter(nn=>nn.citationState==="cited").length,Ns=Yn.filter(nn=>nn.answerMentioned===!0).length,Ea=new Set(Yn.map(nn=>nn.query).filter(nn=>!!nn)).size,aa=qe?_v(qe,Yn.length):!1,Ko=J&&!$a,Hu=Pi??(F?.error?eM(F.error):qe==="cancelled"?"The sweep was cancelled before it produced a baseline.":(qe==="completed"||qe==="partial")&&Yn.length===0?"The sweep finished without producing any snapshots. Confirm the query set and provider configuration, then retry.":M?.statusDetail||"The sweep did not produce a baseline. Review provider configuration, then retry.");let yn=null;return Ko||aa?yn=c.jsx(ga,{tone:"positive",children:"Complete"}):Pi&&!$a?yn=c.jsx(ga,{tone:"negative",children:"Failed"}):gn?yn=c.jsx(ga,{tone:"negative",children:qe==="cancelled"?"Cancelled":"Failed"}):$a&&(yn=c.jsx(ga,{tone:"caution",children:"Running"})),c.jsxs(_a,{className:"surface-card step-card",children:[c.jsxs("div",{className:"section-head",children:[c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 5 of 5"}),c.jsx("h2",{children:"Launch first run"})]}),yn]}),Ko?c.jsxs("div",{className:"compact-stack",children:[c.jsxs("p",{className:"text-secondary",children:["Setup is complete. ",c.jsx("span",{className:"text-strong font-medium",children:Ne})," already has a successful answer-visibility baseline."]}),c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(xe,{type:"button",onClick:Ct,children:g?"Finish and open project":"Open project dashboard →"})]})]}):$a?gn?aa?c.jsxs("div",{className:"compact-stack",children:[c.jsxs("p",{className:"text-neutral",children:["Sweep complete. Your first answer-visibility snapshot for"," ",c.jsx("span",{className:"text-heading font-medium",children:Ne}),":"]}),c.jsxs("div",{className:"grid grid-cols-3 gap-2 mt-1",children:[c.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[c.jsx("p",{className:"text-xs font-medium text-secondary",children:"Mentioned"}),c.jsxs("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:[Ns,c.jsxs("span",{className:"text-faint text-lg",children:[" / ",Ea]})]}),c.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"queries naming your brand"})]}),c.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[c.jsx("p",{className:"text-xs font-medium text-secondary",children:"Cited"}),c.jsxs("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:[Cs,c.jsxs("span",{className:"text-faint text-lg",children:[" / ",Ea]})]}),c.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"queries citing your site"})]}),c.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[c.jsx("p",{className:"text-xs font-medium text-secondary",children:"Results"}),c.jsx("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:Yn.length}),c.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"completed engine checks"})]})]}),c.jsx("p",{className:"mt-1 text-sm text-secondary",children:g?"Your project is ready. Review the evidence in the project.":"Open the project to review the evidence."}),c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(xe,{type:"button",onClick:Ct,children:g?"Finish and open project":"Open project dashboard →"})]})]}):c.jsxs("div",{className:"compact-stack",children:[c.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[c.jsx("p",{children:Hu}),c.jsx("p",{className:"mt-1 text-xs text-secondary",children:"Fix provider or query configuration if needed, then retry without leaving setup."})]}),c.jsxs("div",{className:"setup-nav",children:[c.jsx(xe,{type:"button",variant:"outline",asChild:!0,children:c.jsx(et,{to:"/settings",children:"Configure providers"})}),c.jsx(xe,{type:"button",disabled:mn||!!Ha,onClick:$t(hn),children:mn?"Retrying...":"Retry visibility sweep"})]})]}):c.jsxs("div",{className:"compact-stack",children:[c.jsx("p",{className:"text-neutral",children:"Sweep running. This usually takes 30 to 60 seconds."}),c.jsx("div",{className:"rounded-md border border-default bg-surface p-3 text-xs text-muted",children:c.jsxs("p",{children:["Status: ",c.jsx("span",{className:"text-neutral",children:qe??"queued"})]})}),an.isError&&c.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[c.jsx("p",{children:an.error instanceof Error?an.error.message:"Could not refresh the sweep status."}),c.jsx(xe,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:()=>{an.refetch()},children:"Retry status check"})]}),c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(xe,{type:"button",variant:"outline",onClick:Ct,children:g?"Finish and open project":"Watch on project page"})]})]}):c.jsxs("div",{className:"compact-stack",children:[c.jsxs("p",{className:"supporting-copy",children:["Setup is done. You can run a first sweep now to get a baseline for"," ",c.jsx("span",{className:"text-heading font-medium",children:Ne}),", or finish and run it later from the project. A sweep calls the answer engines, so it costs provider usage."]}),(Ha||Pi)&&c.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[c.jsx("p",{children:Pi??Ha}),c.jsx("p",{className:"mt-1 text-xs text-secondary",children:"Resolve the blocker above, then retry the sweep here."})]}),c.jsxs("div",{className:"setup-nav",children:[c.jsx(xe,{type:"button",variant:"outline",onClick:mt,children:"Back"}),c.jsx(xe,{type:"button",variant:"ghost",onClick:Ct,children:"Finish without running"}),c.jsx(xe,{type:"button",disabled:mn||!!Ha,title:Ha,onClick:$t(hn),children:mn?"Launching...":Pi?"Retry visibility sweep":"Launch visibility sweep"})]})]})]})}default:return null}})();return c.jsxs("div",{className:"page-container",children:[g?c.jsx(_o,{current:"visibility"}):null,c.jsxs("div",{className:"page-header",children:[c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{ref:u?f:void 0,tabIndex:u?-1:void 0,className:"page-title",children:u?"Set up AI Visibility":"Setup"}),c.jsx("p",{className:"page-subtitle",children:u?"Choose what to track, then run your first visibility sweep.":"Create a project and run its first visibility check."})]}),g?c.jsx("div",{className:"page-header-right",children:c.jsx(xe,{type:"button",variant:"outline",onClick:Ct,children:"Skip AI Visibility"})}):null]}),c.jsx(IL,{current:Oe,labels:ML}),c.jsx("section",{className:"setup-wizard",children:Fn})]})}const GL=D.lazy(async()=>({default:(await Ln(()=>import("./SiteHealthSection-vGzpNzMx.js").then(n=>n.d),__vite__mapDeps([0,1,2,3,4]),import.meta.url)).SiteHealthSection})),$L=1800,HL="https://github.com/Canonry/canonry#or-use-any-shell-capable-coding-agent",KL="Help me set up Canonry for my public site.\n\nUse Canonry's official docs:\n- Agent quickstart: https://github.com/Canonry/canonry#or-use-any-shell-capable-coding-agent\n- CLI reference: https://github.com/Canonry/canonry/blob/main/skills/canonry/references/canonry-cli.md\n- Plugin setup: https://github.com/Canonry/canonry/blob/main/docs/plugins.md\n- MCP setup: https://github.com/Canonry/canonry/blob/main/docs/mcp.md\n\nUse an existing Canonry installation or connected plugin/MCP if one is already available. Do not create a duplicate. The `cnry` and `canonry` commands are interchangeable.\n\n1. Ask for my public domain, country, and language. Do not create or scan anything yet.\n2. Check the local setup with `command -v cnry`, `cnry --version`, `cnry doctor --format json`, and `cnry project list --format json`. If Canonry is missing, propose `npm install -g @canonry/canonry` and wait for approval. If initialization is required, tell me to run `cnry init` in my private terminal and wait. Never ask me to paste passwords, API keys, OAuth credentials, or `cnry init` output.\n3. Show the normalized domain, proposed project name, exact `cnry project create ...` command, and wait for explicit approval before creating it.\n4. Propose a bounded Site Health scan, including `--max-pages` and whether dead-link checking is enabled. Show the exact `cnry technical-aeo run ... --wait --format json` command and wait for separate approval before scanning.\n5. After the crawl, summarize the findings and propose AI Visibility setup. Ask before adding queries, connecting providers, starting any provider-backed or quota-consuming run, editing files, or publishing.";function QL(e,n){return e==="legacy"?"legacy":e==="platform"?"platform":n.state==="success"?n.projectCount===0?"platform":"legacy":n.state==="error"?"retry":"loading"}function ZL(e,n){try{const s=new Intl.DisplayNames(["en"],{type:"region"}),r=new Intl.DisplayNames(["en"],{type:"language"}),u=e.length===2?s.of(e.toUpperCase()):void 0,f=n?r.of(n.toLowerCase()):void 0;return`${u??(e||"Country")} · ${f??(n||"Language")}`}catch{return`${e||"Country"} · ${n||"Language"}`}}function FL(e){const n=e.replace(/^\[|\]$/g,"");return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(n)||n.includes(":")}function YL(e){const n=e.trim();if(!n)return null;const s=/^[a-z][a-z\d+.-]*:\/\//i.test(n)?n:`https://${n}`;let r;try{r=new URL(s)}catch{return null}if(r.protocol!=="http:"&&r.protocol!=="https:")return null;const u=r.hostname.toLowerCase().replace(/^www\./,"");if(!u||u==="localhost"||FL(u)||!u.includes("."))return null;const f=u.replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return f?{canonicalDomain:u,projectName:f,displayName:u}:null}async function XL(e,n=$L){let s;const r=new Promise(f=>{s=setTimeout(()=>f({state:"timed-out"}),n)}),u=await Promise.race([e.then(f=>({state:"queued",run:f})),r]);return s&&clearTimeout(s),u}function JL(e,n){e.catch(()=>{Yt({title:"Site Health scan did not start",detail:"The project is safe. Choose Run scan in Site Health to retry.",tone:"negative",dedupeKey:`site-health-dispatch:${n}`})})}function Dv(e,n){return e instanceof oa&&e.statusCode===409?"A project with this name already exists. Change the project name, or open the existing project.":e instanceof Error&&e.message?e.message:n}function WL(){return c.jsxs("div",{className:"page-container max-w-3xl","aria-busy":"true","aria-live":"polite",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Preparing setup"}),c.jsx("p",{className:"page-subtitle",children:"Checking the projects already on this install."})]})}),c.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-default bg-surface p-4 text-sm text-secondary",role:"status",children:[c.jsx(bo,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading projects…"]})]})}function eU({onRetry:e}){return c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Can’t load projects"}),c.jsx("p",{className:"page-subtitle",children:"Canonry could not confirm whether this install already has a project."})]})}),c.jsxs("div",{className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",tabIndex:-1,children:[c.jsx("p",{className:"text-sm font-medium text-heading",children:"Setup is paused to protect existing projects."}),c.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Check the connection or sign in again, then retry."}),c.jsx(xe,{type:"button",className:"mt-4",variant:"secondary",onClick:e,children:"Retry project check"})]})]})}function tU({projectName:e,initialRunId:n}){return c.jsx(Th,{title:"Site Health setup",children:c.jsx(aU,{projectName:e,initialRunId:n})})}function aU({projectName:e,initialRunId:n}){const s=ms(),r=Ft({...gs({client:se}),enabled:!!e,retry:!1,refetchOnMount:"always"});if(!e)return c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Project not found"}),c.jsx("p",{className:"page-subtitle",children:"This setup link does not identify a project."})]})}),c.jsx(xe,{type:"button",variant:"secondary",onClick:()=>{s({to:"/projects"})},children:"View projects"})]});if(r.isPending)return c.jsxs("div",{className:"page-container max-w-3xl","aria-busy":"true","aria-live":"polite",children:[c.jsx(_o,{current:"site"}),c.jsxs("div",{className:"mt-8 flex items-center gap-3 text-sm text-secondary",role:"status",children:[c.jsx(bo,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading Site Health setup…"]})]});if(r.isError)return c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Can’t resume setup"}),c.jsx("p",{className:"page-subtitle",children:"Canonry could not load the project for this Site Health scan."})]})}),c.jsxs("div",{className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",children:[c.jsx("p",{className:"text-sm text-secondary",children:"Check the connection or sign in again, then retry."}),c.jsx(xe,{type:"button",className:"mt-4",variant:"secondary",onClick:()=>{r.refetch()},children:"Retry project check"})]})]});const u=r.data.find(x=>x.name===e);if(!u)return c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Project not found"}),c.jsxs("p",{className:"page-subtitle",children:["Canonry could not find ",e,". It will not open a different project."]})]})}),c.jsx(xe,{type:"button",variant:"secondary",onClick:()=>{s({to:"/projects"})},children:"View projects"})]});const f=()=>{s({to:"/setup",search:{onboarding:"site-health",setupProject:u.name},replace:!0})},g=()=>{s({to:"/setup",search:{experience:"legacy",onboarding:"site-health",setupProject:u.name},replace:!0})},b=()=>{s({to:"/projects/$projectName",params:{projectName:u.name},replace:!0})};return c.jsxs("div",{className:"page-container max-w-7xl py-8 md:py-10",children:[c.jsx("h1",{className:"sr-only",children:"Set up Canonry"}),c.jsx(D.Suspense,{fallback:c.jsxs("div",{className:"space-y-5",children:[c.jsx(_o,{current:"site"}),c.jsxs("div",{className:"flex min-h-72 items-center justify-center gap-3 text-sm text-secondary",role:"status",children:[c.jsx(bo,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading Site Health…"]})]}),children:c.jsx(GL,{projectName:u.name,projectId:u.id,initialRunId:n,onReleaseInitialRun:f,showOnboardingActions:!0,onContinueOnboarding:g,onSkipOnboarding:b})})]})}function nU(){const e=Tv({from:"/setup"}),n=e.onboarding==="site-health"&&!e.setupProject,s=e.onboarding==="site-health"&&e.experience!=="legacy",r=W6(),u=e.experience==="legacy"?"legacy":r,[f,g]=D.useState(!1),b=Ft({...gs({client:se}),enabled:u==="auto",retry:!1,refetchOnMount:"always"}),x=u==="auto"&&b.isSuccess&&b.isFetchedAfterMount&&b.data.length===0;D.useEffect(()=>{x&&g(!0)},[x]);const k=u!=="auto"?{state:"idle"}:b.isSuccess&&b.isFetchedAfterMount?{state:"success",projectCount:b.data.length}:b.isError?{state:"error"}:{state:"loading"},S=u==="legacy"?"legacy":f||x?"platform":QL(u,k);return n||s?c.jsx(tU,{projectName:e.setupProject,initialRunId:e.siteHealthRunId}):S==="legacy"?c.jsx(VL,{visibilityProjectName:e.setupProject,siteHealthOnboarding:e.onboarding==="site-health"}):S==="loading"?c.jsx(WL,{}):S==="retry"?c.jsx(eU,{onRetry:()=>{b.refetch()}}):c.jsx(iU,{onActivationStarted:()=>g(!0)})}function iU({onActivationStarted:e}){return c.jsx(Th,{title:"Site Health setup",children:c.jsx(sU,{onActivationStarted:e})})}function sU({onActivationStarted:e}){const n=ms(),s=Vn(),r=zL(),[u,f]=D.useState(""),[g,b]=D.useState(""),[x,k]=D.useState(""),[S,C]=D.useState("US"),[j,E]=D.useState("en"),[B,q]=D.useState(!1),[U,G]=D.useState("idle"),[te,X]=D.useState(null),[ae,oe]=D.useState(null),[ge,M]=D.useState(!1),[J,_e]=D.useState(null),[he,we]=D.useState(!1),Oe=D.useRef(null),je=YL(u),Fe=g||je?.projectName||"",ye=x||je?.displayName||"",V=U==="creating"||U==="dispatching",ne=ae??J,fe=ZL(S,j);D.useEffect(()=>{ne&&Oe.current?.focus()},[ne]);const De=(re,W)=>n({to:"/setup",search:{...W?{siteHealthRunId:W}:{},onboarding:"site-health",setupProject:re.name},replace:!0}),le=async re=>{G("dispatching"),_e(null);try{const W=r.mutateAsync({projectName:re.name,projectId:re.id,projectLabel:re.displayName||re.name,suppressErrorToast:!0,body:{checkDeadLinks:!0}}),Z=await XL(W);if(Z.state==="queued"){await De(re,Z.run.runId);return}JL(W,re.id),await De(re)}catch(W){G("recovery"),_e(Dv(W,"The project was created, but the Site Health scan could not be started."))}},at=async re=>{if(re.preventDefault(),!(!je||!B||V)){G("creating"),oe(null),M(!1),_e(null);try{const W=await ux({name:Fe,displayName:ye,canonicalDomain:je.canonicalDomain,country:S,language:j});e(),X(W),await s.invalidateQueries({queryKey:Ai({client:se})}),await le(W)}catch(W){G("idle");const Z=W instanceof oa&&W.statusCode===409;M(Z),oe(Dv(W,"Could not create the project. Try again.")),Z&&(e(),s.invalidateQueries({queryKey:Ai({client:se})}))}}},H=()=>{te&&!V&&le(te)},ue=()=>{V||n({to:"/projects"})},ie=async()=>{try{await navigator.clipboard.writeText(KL),we(!0)}catch{Yt({tone:"negative",title:"Could not copy setup request",detail:"Open the agent quickstart to continue with the CLI instead."})}};return te&&U==="recovery"?c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx(_o,{current:"site"}),c.jsx("div",{className:"page-header mt-8",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Project created"}),c.jsxs("p",{className:"page-subtitle",children:[te.displayName||te.name," is ready. The Site Health scan needs another try."]})]})}),c.jsxs("div",{ref:Oe,className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",tabIndex:-1,children:[c.jsx("p",{className:"text-sm font-medium text-heading",children:J}),c.jsx("p",{className:"mt-1 text-sm text-secondary",children:"You can retry the scan or continue setup and retry from Site Health."}),c.jsxs("div",{className:"mt-4 flex flex-wrap gap-3",children:[c.jsx(xe,{type:"button",onClick:H,children:"Retry Site Health scan"}),c.jsx(xe,{type:"button",variant:"secondary",onClick:()=>{De(te)},children:"Continue setup"})]})]})]}):c.jsxs("div",{className:"page-container max-w-xl py-8 md:py-12",children:[c.jsx(_o,{current:"site"}),c.jsxs("header",{className:"mb-8 mt-8",children:[c.jsx("h1",{id:"site-map-setup-title",className:"text-2xl font-semibold tracking-[-0.025em] text-heading",children:"Map your site"}),c.jsx("p",{className:"mt-2 max-w-lg text-sm leading-6 text-secondary",children:"Enter your public website to see its pages, structure, and internal links."})]}),c.jsxs("form",{"aria-labelledby":"site-map-setup-title",className:"space-y-6",onSubmit:$t(at),noValidate:!0,children:[c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm font-medium text-heading",htmlFor:"launchpad-domain",children:"Website URL"}),c.jsx("input",{id:"launchpad-domain",className:"h-11 w-full rounded-md border border-strong bg-bg-elevated/50 px-3 text-base text-heading outline-none transition placeholder:text-muted focus:border-mono-500 focus:ring-1 focus:ring-mono-500",type:"text",inputMode:"url",autoComplete:"url",autoCapitalize:"none",spellCheck:!1,required:!0,"aria-invalid":!!(u&&!je),"aria-describedby":u&&!je?"launchpad-domain-hint launchpad-domain-error":"launchpad-domain-hint",placeholder:"https://example.com",value:u,onChange:re=>{f(re.target.value),oe(null),M(!1)}}),c.jsxs("p",{id:"launchpad-domain-hint",className:"text-sm text-secondary",children:["Only public pages are scanned."," ",c.jsx(et,{to:"/setup",search:{experience:"legacy"},className:"font-medium text-link underline-offset-4 hover:underline",children:"Set up without a site scan"})]}),u&&!je?c.jsx("p",{id:"launchpad-domain-error",className:"text-sm text-negative",role:"alert",children:"Enter a public domain, such as example.com."}):null]}),c.jsxs("details",{className:"group border-y border-default",children:[c.jsxs("summary",{className:"flex min-h-11 cursor-pointer list-none items-center justify-between gap-4 py-3 text-sm [&::-webkit-details-marker]:hidden",children:[c.jsx("span",{className:"font-medium text-heading",children:"Advanced settings"}),c.jsxs("span",{className:"flex items-center gap-2 text-secondary",children:[fe,c.jsx(u0,{className:"size-4 transition-transform group-open:rotate-180 motion-reduce:transition-none","aria-hidden":"true"})]})]}),c.jsxs("div",{className:"space-y-5 border-t border-default py-4",children:[je?c.jsxs("div",{children:[c.jsx("p",{className:"mb-3 text-sm font-medium text-heading",children:"Project"}),c.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-project-name",children:"Project name"}),c.jsx("input",{id:"launchpad-project-name",className:"setup-input h-10",type:"text",value:Fe,onChange:re=>b(re.target.value)})]}),c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-display-name",children:"Display name"}),c.jsx("input",{id:"launchpad-display-name",className:"setup-input h-10",type:"text",value:ye,onChange:re=>k(re.target.value)})]})]})]}):null,c.jsxs("div",{children:[c.jsx("p",{className:"mb-3 text-sm font-medium text-heading",children:"Locale"}),c.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-country",children:"Country"}),c.jsx("input",{id:"launchpad-country",className:"setup-input h-10",type:"text",maxLength:2,value:S,onChange:re=>C(re.target.value.toUpperCase())})]}),c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-language",children:"Language"}),c.jsx("input",{id:"launchpad-language",className:"setup-input h-10",type:"text",maxLength:5,value:j,onChange:re=>E(re.target.value.toLowerCase())})]})]})]})]})]}),c.jsxs("label",{className:"flex min-h-11 cursor-pointer items-start gap-3 py-2",children:[c.jsx("input",{className:"mt-0.5 size-4 shrink-0 rounded border-strong bg-bg",type:"checkbox",checked:B,onChange:re=>q(re.target.checked),"aria-label":"Allow Canonry to scan this public site.","aria-describedby":"local-crawl-note"}),c.jsxs("span",{className:"grid gap-0.5",children:[c.jsx("span",{className:"text-sm leading-5 text-heading",children:"Allow Canonry to scan this public site."}),c.jsx("span",{id:"local-crawl-note",className:"text-sm leading-5 text-secondary",children:"The crawl runs on this Canonry instance, follows internal links, and stores its results locally."})]})]}),ne?c.jsxs("div",{ref:Oe,className:"rounded-md border border-negative bg-negative-soft p-3",role:"alert",tabIndex:-1,children:[c.jsx("p",{className:"text-sm font-medium text-heading",children:ne}),ge?c.jsx(xe,{type:"button",variant:"secondary",size:"sm",className:"mt-3",onClick:ue,children:"View projects"}):null]}):null,c.jsxs("div",{className:"grid gap-2",children:[c.jsx(xe,{className:"h-11 w-full",type:"submit",disabled:!je||!B||V,children:U==="creating"||U==="dispatching"?c.jsxs(c.Fragment,{children:[c.jsx(bo,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"})," Mapping site…"]}):"Map site"}),c.jsx(xe,{className:"w-full",type:"button",variant:"ghost",disabled:V,onClick:ue,children:"Cancel"}),U==="dispatching"?c.jsx("span",{className:"text-center text-sm text-secondary",role:"status",children:"Opening Site Health when the scan is ready."}):null]})]}),c.jsxs("section",{className:"mt-8 border-t border-default pt-6","aria-labelledby":"agent-setup-title",children:[c.jsx("p",{id:"agent-setup-title",className:"text-sm font-medium text-heading",children:"Use your agent instead"}),c.jsx("p",{className:"mt-1 text-sm leading-5 text-secondary",children:"Copy a complete CLI setup request into any coding agent."}),c.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-1",children:[c.jsxs(xe,{type:"button",variant:"ghost",size:"sm",className:"-ml-3",onClick:$t(ie),children:[he?c.jsx(d0,{className:"size-3.5","aria-hidden":"true"}):c.jsx(Uv,{className:"size-3.5","aria-hidden":"true"}),c.jsx("span",{"aria-live":"polite",children:he?"Copied setup request":"Copy setup request"})]}),c.jsx(xe,{asChild:!0,variant:"ghost",size:"sm",children:c.jsxs("a",{href:HL,target:"_blank",rel:"noopener noreferrer",children:["Agent quickstart",c.jsx(qj,{className:"size-3.5","aria-hidden":"true"}),c.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]})})]})]})]})}function oU(){return c.jsx("div",{className:"page-container",children:c.jsx("section",{className:"page-section",children:c.jsxs(_a,{className:"surface-card empty-card",children:[c.jsx("h1",{children:"Route not found"}),c.jsx("p",{children:"The current path does not map to a dashboard view."}),c.jsx(xe,{asChild:!0,children:c.jsx(et,{to:"/",children:"Return to overview"})})]})})})}const Ga=Ci(()=>Ln(()=>import("./ProjectPage-BAiCXEdR.js"),__vite__mapDeps([5,1,6,0,2,3,4,7,8,9,10,11,12]),import.meta.url),"ProjectPage"),rU=Ci(()=>Ln(()=>import("./RunsPage-DR8qc686.js"),__vite__mapDeps([13,1,6,10,4,2,11,12]),import.meta.url),"RunsPage"),lU=Ci(()=>Ln(()=>import("./HistoryPage-Dtr3UICp.js"),__vite__mapDeps([14,1,8,10,4,2,11,12]),import.meta.url),"HistoryPage"),cU=Ci(()=>Ln(()=>import("./SettingsPage-CCqitKyF.js"),__vite__mapDeps([15,1,10,4,2,11,12]),import.meta.url),"SettingsPage"),uU=Ci(()=>Ln(()=>import("./BacklinksPage-C2jbDAhv.js"),__vite__mapDeps([16,1,2,10,4,11,12]),import.meta.url),"BacklinksPage"),dU=Ci(()=>Ln(()=>import("./TrafficPage-DpFRbcIy.js"),__vite__mapDeps([17,1,7,2,10,4,11,12]),import.meta.url),"TrafficPage"),mU=Ci(()=>Ln(()=>import("./TrafficSourceDetailPage-CToOAg5Y.js"),__vite__mapDeps([18,1,7,3,4,2,10,11,12]),import.meta.url),"TrafficSourceDetailPage"),pU=Ci(()=>Ln(()=>import("./MeasurementPropertyPage-D-z4CVyy.js"),__vite__mapDeps([19,1,3,4,9,2,10,11,12]),import.meta.url),"MeasurementPropertyPage");function hU(){return c.jsx(fL,{children:c.jsx(hL,{})})}const ra=dj()({component:hU,validateSearch:e=>({manageQueries:e.manageQueries===!0||e.manageQueries==="true"?!0:void 0,runId:typeof e.runId=="string"?e.runId:void 0,siteHealthRunId:typeof e.siteHealthRunId=="string"?e.siteHealthRunId:void 0,evidenceId:typeof e.evidenceId=="string"?e.evidenceId:void 0,runStatus:typeof e.runStatus=="string"?e.runStatus:void 0,runKind:typeof e.runKind=="string"?e.runKind:void 0,runProject:typeof e.runProject=="string"?e.runProject:void 0,runWindow:typeof e.runWindow=="string"?e.runWindow:void 0,runQuery:typeof e.runQuery=="string"?e.runQuery:void 0,onboarding:e.onboarding==="site-health"?"site-health":void 0,experience:e.experience==="legacy"?"legacy":void 0,setupProject:typeof e.setupProject=="string"?e.setupProject:void 0,scope:typeof e.scope=="string"?e.scope:void 0,class:typeof e.class=="string"?e.class:void 0})}),fU=xt({getParentRoute:()=>ra,path:"/",component:xL,beforeLoad:async({context:e})=>{let n=e.queryClient.getQueryData(Ai({client:se}));if(n===void 0)try{n=await e.queryClient.ensureQueryData(gs({client:se}))}catch{return}if(n.length===0)throw Ov({to:"/setup"})}}),gU=xt({getParentRoute:()=>ra,path:"/projects",component:wL}),yU=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,va=xt({getParentRoute:()=>ra,path:"/projects/$projectName",component:()=>c.jsx(zp,{}),beforeLoad:async({context:e,params:n,location:s})=>{const r=n.projectName;if(!yU.test(r))return;let u=e.queryClient.getQueryData(Ai({client:se}));if(!u)try{u=await e.queryClient.ensureQueryData(gs({client:se}))}catch{return}const f=u.find(g=>g.id===r);if(f)throw Ov({to:s.pathname.replace(`/projects/${r}`,`/projects/${encodeURIComponent(f.name)}`),replace:!0})}}),bU=xt({getParentRoute:()=>va,path:"/",component:()=>c.jsx(Ga,{tab:"overview"})}),vU=xt({getParentRoute:()=>va,path:"/portfolio",component:()=>c.jsx(Ga,{tab:"portfolio"})}),xU=xt({getParentRoute:()=>va,path:"/search-console",component:()=>c.jsx(Ga,{tab:"search-console"})}),kU=xt({getParentRoute:()=>va,path:"/conversions",component:()=>c.jsx(Ga,{tab:"conversions"})}),wU=xt({getParentRoute:()=>va,path:"/local",component:()=>c.jsx(Ga,{tab:"local"})}),SU=xt({getParentRoute:()=>va,path:"/discovery",component:()=>c.jsx(Ga,{tab:"discovery"})}),jU=xt({getParentRoute:()=>va,path:"/properties/$targetKey",component:()=>c.jsx(pU,{})}),AU=xt({getParentRoute:()=>va,path:"/report",component:()=>c.jsx(Ga,{tab:"report"})}),CU=xt({getParentRoute:()=>va,path:"/activity",component:()=>c.jsx(Ga,{tab:"activity"})}),NU=xt({getParentRoute:()=>va,path:"/backlinks",component:()=>c.jsx(Ga,{tab:"backlinks"})}),_U=xt({getParentRoute:()=>va,path:"/technical-aeo",component:()=>c.jsx(Ga,{tab:"technical-aeo"})}),zU=xt({getParentRoute:()=>va,path:"/history",component:()=>c.jsx(Ga,{tab:"history"})}),DU=xt({getParentRoute:()=>va,path:"/settings",component:()=>c.jsx(Ga,{tab:"settings"})}),EU=xt({getParentRoute:()=>ra,path:"/runs",component:rU}),TU=xt({getParentRoute:()=>ra,path:"/history",component:lU}),RU=xt({getParentRoute:()=>ra,path:"/settings",component:cU,beforeLoad:({context:e})=>{}}),OU=xt({getParentRoute:()=>ra,path:"/setup",component:nU}),BU=xt({getParentRoute:()=>ra,path:"/backlinks",component:uU}),qU=xt({getParentRoute:()=>ra,path:"/traffic",component:dU}),MU=xt({getParentRoute:()=>ra,path:"/traffic/$projectName/$sourceId",component:mU}),PU=xt({getParentRoute:()=>ra,path:"*",component:oU}),IU=ra.addChildren([fU,gU,va.addChildren([bU,vU,xU,kU,wU,SU,jU,AU,CU,NU,_U,zU,DU]),EU,TU,RU,OU,BU,qU,MU,PU]);function VU(){return typeof window<"u"&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath:"/"}const Ev=VU(),LU=Ev==="/"?"":Ev.replace(/\/$/,"");function UU(e,n){return mj({routeTree:IU,basepath:LU||"/",context:{queryClient:e},...n?.initialEntries})}const GU=6e4;function $U(){const[e,n]=D.useState(ap()?"ready":"checking"),[s,r]=D.useState(null),[u,f]=D.useState(!1),[g,b]=D.useState(""),[x,k]=D.useState(""),[S,C]=D.useState(""),[j,E]=D.useState(null),[B,q]=D.useState(!1),[U,G]=D.useState(!1),te=D.useRef(null),X=D.useRef(null),ae=D.useRef(null),oe=()=>{const he=s?`${s.name}:${s.role}`:"no-accounts";if(!te.current||ae.current!==he){X.current?.clear();const we=ZA();X.current=we,te.current=UU(we),ae.current=he}return{queryClient:X.current,router:te.current}},ge=he=>he.authRequired?(f(!0),r(he.user),n(he.user?"ready":"account-login"),!0):!1;D.useEffect(()=>{if(ap())return;let he=!1;return Promise.allSettled([Ny(),Cy()]).then(([we,Oe])=>{if(he||we.status==="fulfilled"&&ge(we.value))return;if(Oe.status==="rejected"){const Fe=Oe.reason;E(Fe instanceof Error?Fe.message:"Failed to reach the Canonry API"),n("login");return}const je=Oe.value;je.authenticated?n("ready"):n(je.setupRequired?"setup":"login")}),()=>{he=!0}},[]),D.useEffect(()=>{if(e!=="ready"||ap())return;const he=setInterval(()=>{if(u){Ny().then(we=>{we.authRequired&&!we.user&&(G(!0),r(null),n("account-login"))}).catch(()=>{});return}Cy().then(we=>{we.authenticated||(G(!0),n(we.setupRequired?"setup":"login"))}).catch(()=>{})},GU);return Ay(()=>{G(!0),r(null),n(u?"account-login":"login")}),()=>{clearInterval(he),Ay(null)}},[e,u]);const M=async he=>{if(he.preventDefault(),!x.trim()||x.trim().length<8){E("Password must be at least 8 characters");return}if(x!==S){E("Passwords do not match");return}q(!0),E(null);try{if(!(await wA(x.trim())).authenticated){E("Setup failed");return}k(""),C(""),G(!1),n("ready")}catch(we){E(we instanceof oa||we instanceof Error?we.message:"Setup failed")}finally{q(!1)}},J=async he=>{if(he.preventDefault(),!!x.trim()){q(!0),E(null);try{if(!(await SA(x.trim())).authenticated){E("Incorrect password");return}k(""),G(!1),n("ready")}catch(we){E(we instanceof oa||we instanceof Error?we.message:"Authentication failed")}finally{q(!1)}}},_e=async he=>{if(he.preventDefault(),!(!g.trim()||!x)){q(!0),E(null);try{const we=await jA(g.trim(),x);if(!we.user){E("Incorrect name or password.");return}k(""),G(!1),r(we.user),n("ready")}catch(we){E(we instanceof oa?we.message:"Incorrect name or password.")}finally{q(!1)}}};if(e==="ready"){const{queryClient:he,router:we}=oe();return c.jsx(PA,{account:s,children:c.jsx(pj,{client:he,children:c.jsx(hj,{router:we})})})}return c.jsx("div",{className:"min-h-screen bg-bg px-4 py-8",children:c.jsxs("div",{className:"mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col items-center justify-center gap-5",children:[c.jsxs("div",{"data-testid":"auth-brand",className:"flex items-center gap-2.5",children:[c.jsx("img",{className:"size-7",src:"./favicon.svg",alt:"","aria-hidden":"true"}),c.jsx("span",{className:"text-lg font-semibold tracking-tight text-heading",children:"Canonry"})]}),c.jsx(_a,{className:"surface-card w-full",children:e==="checking"?c.jsx(ho,{className:"py-8",children:c.jsx("p",{className:"supporting-copy text-center",children:"Connecting to Canonry…"})}):e==="account-login"?c.jsxs(c.Fragment,{children:[c.jsxs(Qr,{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),c.jsx(Zr,{children:"Sign in to Canonry"})]}),c.jsxs(ho,{children:[U?c.jsx("p",{className:"mb-4 rounded-md border border-caution bg-caution-soft px-3 py-2 text-sm text-caution",children:"You were signed out — please sign in again."}):null,c.jsxs("form",{className:"space-y-4",onSubmit:$t(_e),children:[c.jsxs("label",{className:"block space-y-1.5",htmlFor:"account-name",children:[c.jsx("span",{className:"text-xs font-medium text-secondary",children:"Name"}),c.jsx("input",{autoFocus:!0,id:"account-name",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"text",autoComplete:"username",value:g,onChange:he=>b(he.target.value)})]}),c.jsxs("label",{className:"block space-y-1.5",htmlFor:"account-password",children:[c.jsx("span",{className:"text-xs font-medium text-secondary",children:"Password"}),c.jsx("input",{id:"account-password",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"password",autoComplete:"current-password",value:x,onChange:he=>k(he.target.value)})]}),j?c.jsx("p",{className:"text-sm text-negative-400",children:j}):null,c.jsx(xe,{type:"submit",disabled:B||!g.trim()||!x,children:B?"Signing in…":"Sign in"})]})]})]}):e==="setup"?c.jsxs(c.Fragment,{children:[c.jsxs(Qr,{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"First-time setup"}),c.jsx(Zr,{children:"Create a dashboard password"}),c.jsx(cu,{children:"Choose a password to protect the Canonry dashboard."})]}),c.jsx(ho,{children:c.jsxs("form",{className:"space-y-4",onSubmit:$t(M),children:[c.jsxs("label",{className:"block space-y-1.5",children:[c.jsx("span",{className:"text-xs font-medium text-secondary",children:"Password"}),c.jsx("input",{autoFocus:!0,className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"password",value:x,onChange:he=>k(he.target.value),placeholder:"At least 8 characters"})]}),c.jsxs("label",{className:"block space-y-1.5",children:[c.jsx("span",{className:"text-xs font-medium text-secondary",children:"Confirm password"}),c.jsx("input",{className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"password",value:S,onChange:he=>C(he.target.value),placeholder:"Re-enter password"})]}),j?c.jsx("p",{className:"text-sm text-negative-400",children:j}):null,c.jsx(xe,{type:"submit",disabled:B||!x.trim()||!S.trim(),children:B?"Setting up…":"Create password & open dashboard"})]})})]}):c.jsxs(c.Fragment,{children:[c.jsxs(Qr,{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),c.jsx(Zr,{children:"Sign in to Canonry"}),c.jsx(cu,{children:"Enter your dashboard password to continue."})]}),c.jsxs(ho,{children:[U?c.jsx("p",{className:"mb-4 rounded-md border border-caution bg-caution-soft px-3 py-2 text-sm text-caution",children:"Your session expired — please sign in again."}):null,c.jsxs("form",{className:"space-y-4",onSubmit:$t(J),children:[c.jsxs("label",{className:"block space-y-1.5",children:[c.jsx("span",{className:"text-xs font-medium text-secondary",children:"Password"}),c.jsx("input",{autoFocus:!0,className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"password",value:x,onChange:he=>k(he.target.value),placeholder:"Dashboard password"})]}),j?c.jsx("p",{className:"text-sm text-negative-400",children:j}):null,c.jsx(xe,{type:"submit",disabled:B||!x.trim(),children:B?"Signing in…":"Open dashboard"})]})]})]})})]})})}const X3=document.getElementById("root");if(!X3)throw new Error("Expected #root element for web app bootstrap.");Gj.createRoot(X3).render(c.jsx(D.StrictMode,{children:c.jsx($U,{})}));export{YH as $,zG as A,xe as B,su as C,LH as D,$H as E,GH as F,N$ as G,IG as H,Vr as I,PG as J,YG as K,Yt as L,VK as M,QH as N,ZH as O,$I as P,$G as Q,FH as R,Wq as S,ga as T,HG as U,LG as V,GG as W,HH as X,KH as Y,UH as Z,VG as _,PK as a,OH as a$,nK as a0,WH as a1,tK as a2,eK as a3,aK as a4,BA as a5,wh as a6,Te as a7,JH as a8,v3 as a9,fH as aA,Z$ as aB,F$ as aC,kK as aD,wK as aE,SK as aF,KG as aG,Ai as aH,QG as aI,xh as aJ,fK as aK,jM as aL,xH as aM,al as aN,wH as aO,zH as aP,PH as aQ,NH as aR,qH as aS,VH as aT,jH as aU,EH as aV,TH as aW,RH as aX,SH as aY,DH as aZ,AH as a_,In as aa,XH as ab,KK as ac,yT as ad,bT as ae,D$ as af,z$ as ag,g$ as ah,w$ as ai,S$ as aj,oa as ak,j$ as al,xG as am,eM as an,ZP as ao,Zc as ap,A$ as aq,Op as ar,gK as as,q_ as at,UG as au,_$ as av,dM as aw,DM as ax,hH as ay,gH as az,jz as b,yH as b$,CH as b0,BH as b1,_H as b2,MH as b3,IH as b4,jL as b5,de as b6,yG as b7,gG as b8,fG as b9,$$ as bA,H$ as bB,P$ as bC,U$ as bD,NG as bE,CG as bF,AG as bG,s$ as bH,EG as bI,aH as bJ,Jb as bK,tH as bL,TG as bM,RG as bN,eH as bO,OG as bP,BG as bQ,MG as bR,qG as bS,pl as bT,gs as bU,OV as bV,sx as bW,iH as bX,sH as bY,$K as bZ,_L as b_,hG as ba,dG as bb,uG as bc,pG as bd,mG as be,cG as bf,lG as bg,tG as bh,aG as bi,rG as bj,oG as bk,sG as bl,nG as bm,iG as bn,eG as bo,WU as bp,JU as bq,XU as br,h4 as bs,V$ as bt,hK as bu,I$ as bv,i$ as bw,HK as bx,G$ as by,L$ as bz,IK as c,fh as c$,kH as c0,oH as c1,lH as c2,uH as c3,rH as c4,sa as c5,gA as c6,sM as c7,wG as c8,SG as c9,cA,bG as cB,vG as cC,DG as cD,ZG as cE,FG as cF,Th as cG,Iu as cH,Ch as cI,n$ as cJ,No as cK,ev as cL,h$ as cM,y$ as cN,v$ as cO,x$ as cP,f$ as cQ,b$ as cR,k$ as cS,HI as cT,M3 as cU,YI as cV,P3 as cW,I3 as cX,p$ as cY,vK as cZ,Q$ as c_,kG as ca,bA as cb,jG as cc,uM as cd,_G as ce,iK as cf,oK as cg,DA as ch,t$ as ci,rK as cj,lK as ck,sK as cl,X$ as cm,XG as cn,JG as co,WG as cp,a$ as cq,e$ as cr,vo as cs,kh as ct,LK as cu,Pu as cv,Ah as cw,bH as cx,vH as cy,AA as cz,_a as d,nH as d0,yK as d1,xK as d2,m$ as d3,K$ as d4,u$ as d5,d$ as d6,c$ as d7,bK as d8,h9 as d9,B$ as dA,TK as dB,tR as dC,M$ as dD,q$ as dE,dH as da,cH as db,pH as dc,mH as dd,R$ as de,Ln as df,Ua as dg,T$ as dh,jK as di,CK as dj,AK as dk,zL as dl,O$ as dm,BK as dn,qK as dp,MK as dq,NK as dr,_K as ds,E$ as dt,EK as du,OK as dv,DK as dw,RK as dx,zK as dy,_o as dz,fa as e,$t as f,C$ as g,dv as h,sA as i,cK as j,se as k,uK as l,dK as m,pK as n,mK as o,o$ as p,l$ as q,r$ as r,UK as s,aM as t,Nh as u,GK as v,s0 as w,J$ as x,Y$ as y,W$ as z};
83
+ competitor2.com`,value:Xt,onChange:F=>tn(F.target.value)})]}),yl?c.jsx("p",{className:"text-negative-400 text-sm",children:yl}):null,c.jsxs("div",{className:"setup-nav",children:[c.jsx(xe,{type:"button",variant:"outline",onClick:mt,children:"Back"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(xe,{type:"button",variant:"outline",onClick:fn,children:"Skip"}),c.jsx(xe,{type:"button",disabled:Dt.length===0||qi,onClick:$t(Zn),children:qi?"Saving...":`Save ${Dt.length} competitor${Dt.length!==1?"s":""}`})]})]})]})]});case 4:{const F=an.data,qe=F?.status??(Ii===M?.id?M.status:void 0),gn=qe==="completed"||qe==="partial"||qe==="failed"||qe==="cancelled",Yn=F?.snapshots??[],Cs=Yn.filter(nn=>nn.citationState==="cited").length,Ns=Yn.filter(nn=>nn.answerMentioned===!0).length,Ea=new Set(Yn.map(nn=>nn.query).filter(nn=>!!nn)).size,aa=qe?_v(qe,Yn.length):!1,Ko=J&&!$a,Hu=Pi??(F?.error?eM(F.error):qe==="cancelled"?"The sweep was cancelled before it produced a baseline.":(qe==="completed"||qe==="partial")&&Yn.length===0?"The sweep finished without producing any snapshots. Confirm the query set and provider configuration, then retry.":M?.statusDetail||"The sweep did not produce a baseline. Review provider configuration, then retry.");let yn=null;return Ko||aa?yn=c.jsx(ga,{tone:"positive",children:"Complete"}):Pi&&!$a?yn=c.jsx(ga,{tone:"negative",children:"Failed"}):gn?yn=c.jsx(ga,{tone:"negative",children:qe==="cancelled"?"Cancelled":"Failed"}):$a&&(yn=c.jsx(ga,{tone:"caution",children:"Running"})),c.jsxs(_a,{className:"surface-card step-card",children:[c.jsxs("div",{className:"section-head",children:[c.jsxs("div",{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 5 of 5"}),c.jsx("h2",{children:"Launch first run"})]}),yn]}),Ko?c.jsxs("div",{className:"compact-stack",children:[c.jsxs("p",{className:"text-secondary",children:["Setup is complete. ",c.jsx("span",{className:"text-strong font-medium",children:Ne})," already has a successful answer-visibility baseline."]}),c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(xe,{type:"button",onClick:Ct,children:g?"Finish and open project":"Open project dashboard →"})]})]}):$a?gn?aa?c.jsxs("div",{className:"compact-stack",children:[c.jsxs("p",{className:"text-neutral",children:["Sweep complete. Your first answer-visibility snapshot for"," ",c.jsx("span",{className:"text-heading font-medium",children:Ne}),":"]}),c.jsxs("div",{className:"grid grid-cols-3 gap-2 mt-1",children:[c.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[c.jsx("p",{className:"text-xs font-medium text-secondary",children:"Mentioned"}),c.jsxs("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:[Ns,c.jsxs("span",{className:"text-faint text-lg",children:[" / ",Ea]})]}),c.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"queries naming your brand"})]}),c.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[c.jsx("p",{className:"text-xs font-medium text-secondary",children:"Cited"}),c.jsxs("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:[Cs,c.jsxs("span",{className:"text-faint text-lg",children:[" / ",Ea]})]}),c.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"queries citing your site"})]}),c.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[c.jsx("p",{className:"text-xs font-medium text-secondary",children:"Results"}),c.jsx("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:Yn.length}),c.jsx("p",{className:"mt-0.5 text-sm text-secondary",children:"completed engine checks"})]})]}),c.jsx("p",{className:"mt-1 text-sm text-secondary",children:g?"Your project is ready. Review the evidence in the project.":"Open the project to review the evidence."}),c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(xe,{type:"button",onClick:Ct,children:g?"Finish and open project":"Open project dashboard →"})]})]}):c.jsxs("div",{className:"compact-stack",children:[c.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[c.jsx("p",{children:Hu}),c.jsx("p",{className:"mt-1 text-xs text-secondary",children:"Fix provider or query configuration if needed, then retry without leaving setup."})]}),c.jsxs("div",{className:"setup-nav",children:[c.jsx(xe,{type:"button",variant:"outline",asChild:!0,children:c.jsx(et,{to:"/settings",children:"Configure providers"})}),c.jsx(xe,{type:"button",disabled:mn||!!Ha,onClick:$t(hn),children:mn?"Retrying...":"Retry visibility sweep"})]})]}):c.jsxs("div",{className:"compact-stack",children:[c.jsx("p",{className:"text-neutral",children:"Sweep running. This usually takes 30 to 60 seconds."}),c.jsx("div",{className:"rounded-md border border-default bg-surface p-3 text-xs text-muted",children:c.jsxs("p",{children:["Status: ",c.jsx("span",{className:"text-neutral",children:qe??"queued"})]})}),an.isError&&c.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[c.jsx("p",{children:an.error instanceof Error?an.error.message:"Could not refresh the sweep status."}),c.jsx(xe,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:()=>{an.refetch()},children:"Retry status check"})]}),c.jsxs("div",{className:"setup-nav",children:[c.jsx("span",{}),c.jsx(xe,{type:"button",variant:"outline",onClick:Ct,children:g?"Finish and open project":"Watch on project page"})]})]}):c.jsxs("div",{className:"compact-stack",children:[c.jsxs("p",{className:"supporting-copy",children:["Setup is done. You can run a first sweep now to get a baseline for"," ",c.jsx("span",{className:"text-heading font-medium",children:Ne}),", or finish and run it later from the project. A sweep calls the answer engines, so it costs provider usage."]}),(Ha||Pi)&&c.jsxs("div",{role:"alert",className:"rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative",children:[c.jsx("p",{children:Pi??Ha}),c.jsx("p",{className:"mt-1 text-xs text-secondary",children:"Resolve the blocker above, then retry the sweep here."})]}),c.jsxs("div",{className:"setup-nav",children:[c.jsx(xe,{type:"button",variant:"outline",onClick:mt,children:"Back"}),c.jsx(xe,{type:"button",variant:"ghost",onClick:Ct,children:"Finish without running"}),c.jsx(xe,{type:"button",disabled:mn||!!Ha,title:Ha,onClick:$t(hn),children:mn?"Launching...":Pi?"Retry visibility sweep":"Launch visibility sweep"})]})]})]})}default:return null}})();return c.jsxs("div",{className:"page-container",children:[g?c.jsx(_o,{current:"visibility"}):null,c.jsxs("div",{className:"page-header",children:[c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{ref:u?f:void 0,tabIndex:u?-1:void 0,className:"page-title",children:u?"Set up AI Visibility":"Setup"}),c.jsx("p",{className:"page-subtitle",children:u?"Choose what to track, then run your first visibility sweep.":"Create a project and run its first visibility check."})]}),g?c.jsx("div",{className:"page-header-right",children:c.jsx(xe,{type:"button",variant:"outline",onClick:Ct,children:"Skip AI Visibility"})}):null]}),c.jsx(IL,{current:Oe,labels:ML}),c.jsx("section",{className:"setup-wizard",children:Fn})]})}const GL=D.lazy(async()=>({default:(await Ln(()=>import("./SiteHealthSection-B9WF97sJ.js").then(n=>n.d),__vite__mapDeps([0,1,2,3,4]),import.meta.url)).SiteHealthSection})),$L=1800,HL="https://github.com/Canonry/canonry#or-use-any-shell-capable-coding-agent",KL="Help me set up Canonry for my public site.\n\nUse Canonry's official docs:\n- Agent quickstart: https://github.com/Canonry/canonry#or-use-any-shell-capable-coding-agent\n- CLI reference: https://github.com/Canonry/canonry/blob/main/skills/canonry/references/canonry-cli.md\n- Plugin setup: https://github.com/Canonry/canonry/blob/main/docs/plugins.md\n- MCP setup: https://github.com/Canonry/canonry/blob/main/docs/mcp.md\n\nUse an existing Canonry installation or connected plugin/MCP if one is already available. Do not create a duplicate. The `cnry` and `canonry` commands are interchangeable.\n\n1. Ask for my public domain, country, and language. Do not create or scan anything yet.\n2. Check the local setup with `command -v cnry`, `cnry --version`, `cnry doctor --format json`, and `cnry project list --format json`. If Canonry is missing, propose `npm install -g @canonry/canonry` and wait for approval. If initialization is required, tell me to run `cnry init` in my private terminal and wait. Never ask me to paste passwords, API keys, OAuth credentials, or `cnry init` output.\n3. Show the normalized domain, proposed project name, exact `cnry project create ...` command, and wait for explicit approval before creating it.\n4. Propose a bounded Site Health scan, including `--max-pages` and whether dead-link checking is enabled. Show the exact `cnry technical-aeo run ... --wait --format json` command and wait for separate approval before scanning.\n5. After the crawl, summarize the findings and propose AI Visibility setup. Ask before adding queries, connecting providers, starting any provider-backed or quota-consuming run, editing files, or publishing.";function QL(e,n){return e==="legacy"?"legacy":e==="platform"?"platform":n.state==="success"?n.projectCount===0?"platform":"legacy":n.state==="error"?"retry":"loading"}function ZL(e,n){try{const s=new Intl.DisplayNames(["en"],{type:"region"}),r=new Intl.DisplayNames(["en"],{type:"language"}),u=e.length===2?s.of(e.toUpperCase()):void 0,f=n?r.of(n.toLowerCase()):void 0;return`${u??(e||"Country")} · ${f??(n||"Language")}`}catch{return`${e||"Country"} · ${n||"Language"}`}}function FL(e){const n=e.replace(/^\[|\]$/g,"");return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(n)||n.includes(":")}function YL(e){const n=e.trim();if(!n)return null;const s=/^[a-z][a-z\d+.-]*:\/\//i.test(n)?n:`https://${n}`;let r;try{r=new URL(s)}catch{return null}if(r.protocol!=="http:"&&r.protocol!=="https:")return null;const u=r.hostname.toLowerCase().replace(/^www\./,"");if(!u||u==="localhost"||FL(u)||!u.includes("."))return null;const f=u.replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return f?{canonicalDomain:u,projectName:f,displayName:u}:null}async function XL(e,n=$L){let s;const r=new Promise(f=>{s=setTimeout(()=>f({state:"timed-out"}),n)}),u=await Promise.race([e.then(f=>({state:"queued",run:f})),r]);return s&&clearTimeout(s),u}function JL(e,n){e.catch(()=>{Yt({title:"Site Health scan did not start",detail:"The project is safe. Choose Run scan in Site Health to retry.",tone:"negative",dedupeKey:`site-health-dispatch:${n}`})})}function Dv(e,n){return e instanceof oa&&e.statusCode===409?"A project with this name already exists. Change the project name, or open the existing project.":e instanceof Error&&e.message?e.message:n}function WL(){return c.jsxs("div",{className:"page-container max-w-3xl","aria-busy":"true","aria-live":"polite",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Preparing setup"}),c.jsx("p",{className:"page-subtitle",children:"Checking the projects already on this install."})]})}),c.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-default bg-surface p-4 text-sm text-secondary",role:"status",children:[c.jsx(bo,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading projects…"]})]})}function eU({onRetry:e}){return c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Can’t load projects"}),c.jsx("p",{className:"page-subtitle",children:"Canonry could not confirm whether this install already has a project."})]})}),c.jsxs("div",{className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",tabIndex:-1,children:[c.jsx("p",{className:"text-sm font-medium text-heading",children:"Setup is paused to protect existing projects."}),c.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Check the connection or sign in again, then retry."}),c.jsx(xe,{type:"button",className:"mt-4",variant:"secondary",onClick:e,children:"Retry project check"})]})]})}function tU({projectName:e,initialRunId:n}){return c.jsx(Th,{title:"Site Health setup",children:c.jsx(aU,{projectName:e,initialRunId:n})})}function aU({projectName:e,initialRunId:n}){const s=ms(),r=Ft({...gs({client:se}),enabled:!!e,retry:!1,refetchOnMount:"always"});if(!e)return c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Project not found"}),c.jsx("p",{className:"page-subtitle",children:"This setup link does not identify a project."})]})}),c.jsx(xe,{type:"button",variant:"secondary",onClick:()=>{s({to:"/projects"})},children:"View projects"})]});if(r.isPending)return c.jsxs("div",{className:"page-container max-w-3xl","aria-busy":"true","aria-live":"polite",children:[c.jsx(_o,{current:"site"}),c.jsxs("div",{className:"mt-8 flex items-center gap-3 text-sm text-secondary",role:"status",children:[c.jsx(bo,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading Site Health setup…"]})]});if(r.isError)return c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Can’t resume setup"}),c.jsx("p",{className:"page-subtitle",children:"Canonry could not load the project for this Site Health scan."})]})}),c.jsxs("div",{className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",children:[c.jsx("p",{className:"text-sm text-secondary",children:"Check the connection or sign in again, then retry."}),c.jsx(xe,{type:"button",className:"mt-4",variant:"secondary",onClick:()=>{r.refetch()},children:"Retry project check"})]})]});const u=r.data.find(x=>x.name===e);if(!u)return c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx("div",{className:"page-header",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Project not found"}),c.jsxs("p",{className:"page-subtitle",children:["Canonry could not find ",e,". It will not open a different project."]})]})}),c.jsx(xe,{type:"button",variant:"secondary",onClick:()=>{s({to:"/projects"})},children:"View projects"})]});const f=()=>{s({to:"/setup",search:{onboarding:"site-health",setupProject:u.name},replace:!0})},g=()=>{s({to:"/setup",search:{experience:"legacy",onboarding:"site-health",setupProject:u.name},replace:!0})},b=()=>{s({to:"/projects/$projectName",params:{projectName:u.name},replace:!0})};return c.jsxs("div",{className:"page-container max-w-7xl py-8 md:py-10",children:[c.jsx("h1",{className:"sr-only",children:"Set up Canonry"}),c.jsx(D.Suspense,{fallback:c.jsxs("div",{className:"space-y-5",children:[c.jsx(_o,{current:"site"}),c.jsxs("div",{className:"flex min-h-72 items-center justify-center gap-3 text-sm text-secondary",role:"status",children:[c.jsx(bo,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"}),"Loading Site Health…"]})]}),children:c.jsx(GL,{projectName:u.name,projectId:u.id,initialRunId:n,onReleaseInitialRun:f,showOnboardingActions:!0,onContinueOnboarding:g,onSkipOnboarding:b})})]})}function nU(){const e=Tv({from:"/setup"}),n=e.onboarding==="site-health"&&!e.setupProject,s=e.onboarding==="site-health"&&e.experience!=="legacy",r=W6(),u=e.experience==="legacy"?"legacy":r,[f,g]=D.useState(!1),b=Ft({...gs({client:se}),enabled:u==="auto",retry:!1,refetchOnMount:"always"}),x=u==="auto"&&b.isSuccess&&b.isFetchedAfterMount&&b.data.length===0;D.useEffect(()=>{x&&g(!0)},[x]);const k=u!=="auto"?{state:"idle"}:b.isSuccess&&b.isFetchedAfterMount?{state:"success",projectCount:b.data.length}:b.isError?{state:"error"}:{state:"loading"},S=u==="legacy"?"legacy":f||x?"platform":QL(u,k);return n||s?c.jsx(tU,{projectName:e.setupProject,initialRunId:e.siteHealthRunId}):S==="legacy"?c.jsx(VL,{visibilityProjectName:e.setupProject,siteHealthOnboarding:e.onboarding==="site-health"}):S==="loading"?c.jsx(WL,{}):S==="retry"?c.jsx(eU,{onRetry:()=>{b.refetch()}}):c.jsx(iU,{onActivationStarted:()=>g(!0)})}function iU({onActivationStarted:e}){return c.jsx(Th,{title:"Site Health setup",children:c.jsx(sU,{onActivationStarted:e})})}function sU({onActivationStarted:e}){const n=ms(),s=Vn(),r=zL(),[u,f]=D.useState(""),[g,b]=D.useState(""),[x,k]=D.useState(""),[S,C]=D.useState("US"),[j,E]=D.useState("en"),[B,q]=D.useState(!1),[U,G]=D.useState("idle"),[te,X]=D.useState(null),[ae,oe]=D.useState(null),[ge,M]=D.useState(!1),[J,_e]=D.useState(null),[he,we]=D.useState(!1),Oe=D.useRef(null),je=YL(u),Fe=g||je?.projectName||"",ye=x||je?.displayName||"",V=U==="creating"||U==="dispatching",ne=ae??J,fe=ZL(S,j);D.useEffect(()=>{ne&&Oe.current?.focus()},[ne]);const De=(re,W)=>n({to:"/setup",search:{...W?{siteHealthRunId:W}:{},onboarding:"site-health",setupProject:re.name},replace:!0}),le=async re=>{G("dispatching"),_e(null);try{const W=r.mutateAsync({projectName:re.name,projectId:re.id,projectLabel:re.displayName||re.name,suppressErrorToast:!0,body:{checkDeadLinks:!0}}),Z=await XL(W);if(Z.state==="queued"){await De(re,Z.run.runId);return}JL(W,re.id),await De(re)}catch(W){G("recovery"),_e(Dv(W,"The project was created, but the Site Health scan could not be started."))}},at=async re=>{if(re.preventDefault(),!(!je||!B||V)){G("creating"),oe(null),M(!1),_e(null);try{const W=await ux({name:Fe,displayName:ye,canonicalDomain:je.canonicalDomain,country:S,language:j});e(),X(W),await s.invalidateQueries({queryKey:Ai({client:se})}),await le(W)}catch(W){G("idle");const Z=W instanceof oa&&W.statusCode===409;M(Z),oe(Dv(W,"Could not create the project. Try again.")),Z&&(e(),s.invalidateQueries({queryKey:Ai({client:se})}))}}},H=()=>{te&&!V&&le(te)},ue=()=>{V||n({to:"/projects"})},ie=async()=>{try{await navigator.clipboard.writeText(KL),we(!0)}catch{Yt({tone:"negative",title:"Could not copy setup request",detail:"Open the agent quickstart to continue with the CLI instead."})}};return te&&U==="recovery"?c.jsxs("div",{className:"page-container max-w-3xl",children:[c.jsx(_o,{current:"site"}),c.jsx("div",{className:"page-header mt-8",children:c.jsxs("div",{className:"page-header-left",children:[c.jsx("h1",{className:"page-title",children:"Project created"}),c.jsxs("p",{className:"page-subtitle",children:[te.displayName||te.name," is ready. The Site Health scan needs another try."]})]})}),c.jsxs("div",{ref:Oe,className:"rounded-lg border border-negative bg-negative-soft p-4",role:"alert",tabIndex:-1,children:[c.jsx("p",{className:"text-sm font-medium text-heading",children:J}),c.jsx("p",{className:"mt-1 text-sm text-secondary",children:"You can retry the scan or continue setup and retry from Site Health."}),c.jsxs("div",{className:"mt-4 flex flex-wrap gap-3",children:[c.jsx(xe,{type:"button",onClick:H,children:"Retry Site Health scan"}),c.jsx(xe,{type:"button",variant:"secondary",onClick:()=>{De(te)},children:"Continue setup"})]})]})]}):c.jsxs("div",{className:"page-container max-w-xl py-8 md:py-12",children:[c.jsx(_o,{current:"site"}),c.jsxs("header",{className:"mb-8 mt-8",children:[c.jsx("h1",{id:"site-map-setup-title",className:"text-2xl font-semibold tracking-[-0.025em] text-heading",children:"Map your site"}),c.jsx("p",{className:"mt-2 max-w-lg text-sm leading-6 text-secondary",children:"Enter your public website to see its pages, structure, and internal links."})]}),c.jsxs("form",{"aria-labelledby":"site-map-setup-title",className:"space-y-6",onSubmit:$t(at),noValidate:!0,children:[c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm font-medium text-heading",htmlFor:"launchpad-domain",children:"Website URL"}),c.jsx("input",{id:"launchpad-domain",className:"h-11 w-full rounded-md border border-strong bg-bg-elevated/50 px-3 text-base text-heading outline-none transition placeholder:text-muted focus:border-mono-500 focus:ring-1 focus:ring-mono-500",type:"text",inputMode:"url",autoComplete:"url",autoCapitalize:"none",spellCheck:!1,required:!0,"aria-invalid":!!(u&&!je),"aria-describedby":u&&!je?"launchpad-domain-hint launchpad-domain-error":"launchpad-domain-hint",placeholder:"https://example.com",value:u,onChange:re=>{f(re.target.value),oe(null),M(!1)}}),c.jsxs("p",{id:"launchpad-domain-hint",className:"text-sm text-secondary",children:["Only public pages are scanned."," ",c.jsx(et,{to:"/setup",search:{experience:"legacy"},className:"font-medium text-link underline-offset-4 hover:underline",children:"Set up without a site scan"})]}),u&&!je?c.jsx("p",{id:"launchpad-domain-error",className:"text-sm text-negative",role:"alert",children:"Enter a public domain, such as example.com."}):null]}),c.jsxs("details",{className:"group border-y border-default",children:[c.jsxs("summary",{className:"flex min-h-11 cursor-pointer list-none items-center justify-between gap-4 py-3 text-sm [&::-webkit-details-marker]:hidden",children:[c.jsx("span",{className:"font-medium text-heading",children:"Advanced settings"}),c.jsxs("span",{className:"flex items-center gap-2 text-secondary",children:[fe,c.jsx(u0,{className:"size-4 transition-transform group-open:rotate-180 motion-reduce:transition-none","aria-hidden":"true"})]})]}),c.jsxs("div",{className:"space-y-5 border-t border-default py-4",children:[je?c.jsxs("div",{children:[c.jsx("p",{className:"mb-3 text-sm font-medium text-heading",children:"Project"}),c.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-project-name",children:"Project name"}),c.jsx("input",{id:"launchpad-project-name",className:"setup-input h-10",type:"text",value:Fe,onChange:re=>b(re.target.value)})]}),c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-display-name",children:"Display name"}),c.jsx("input",{id:"launchpad-display-name",className:"setup-input h-10",type:"text",value:ye,onChange:re=>k(re.target.value)})]})]})]}):null,c.jsxs("div",{children:[c.jsx("p",{className:"mb-3 text-sm font-medium text-heading",children:"Locale"}),c.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-country",children:"Country"}),c.jsx("input",{id:"launchpad-country",className:"setup-input h-10",type:"text",maxLength:2,value:S,onChange:re=>C(re.target.value.toUpperCase())})]}),c.jsxs("div",{className:"grid gap-2",children:[c.jsx("label",{className:"text-sm text-secondary",htmlFor:"launchpad-language",children:"Language"}),c.jsx("input",{id:"launchpad-language",className:"setup-input h-10",type:"text",maxLength:5,value:j,onChange:re=>E(re.target.value.toLowerCase())})]})]})]})]})]}),c.jsxs("label",{className:"flex min-h-11 cursor-pointer items-start gap-3 py-2",children:[c.jsx("input",{className:"mt-0.5 size-4 shrink-0 rounded border-strong bg-bg",type:"checkbox",checked:B,onChange:re=>q(re.target.checked),"aria-label":"Allow Canonry to scan this public site.","aria-describedby":"local-crawl-note"}),c.jsxs("span",{className:"grid gap-0.5",children:[c.jsx("span",{className:"text-sm leading-5 text-heading",children:"Allow Canonry to scan this public site."}),c.jsx("span",{id:"local-crawl-note",className:"text-sm leading-5 text-secondary",children:"The crawl runs on this Canonry instance, follows internal links, and stores its results locally."})]})]}),ne?c.jsxs("div",{ref:Oe,className:"rounded-md border border-negative bg-negative-soft p-3",role:"alert",tabIndex:-1,children:[c.jsx("p",{className:"text-sm font-medium text-heading",children:ne}),ge?c.jsx(xe,{type:"button",variant:"secondary",size:"sm",className:"mt-3",onClick:ue,children:"View projects"}):null]}):null,c.jsxs("div",{className:"grid gap-2",children:[c.jsx(xe,{className:"h-11 w-full",type:"submit",disabled:!je||!B||V,children:U==="creating"||U==="dispatching"?c.jsxs(c.Fragment,{children:[c.jsx(bo,{className:"size-4 motion-safe:animate-spin","aria-hidden":"true"})," Mapping site…"]}):"Map site"}),c.jsx(xe,{className:"w-full",type:"button",variant:"ghost",disabled:V,onClick:ue,children:"Cancel"}),U==="dispatching"?c.jsx("span",{className:"text-center text-sm text-secondary",role:"status",children:"Opening Site Health when the scan is ready."}):null]})]}),c.jsxs("section",{className:"mt-8 border-t border-default pt-6","aria-labelledby":"agent-setup-title",children:[c.jsx("p",{id:"agent-setup-title",className:"text-sm font-medium text-heading",children:"Use your agent instead"}),c.jsx("p",{className:"mt-1 text-sm leading-5 text-secondary",children:"Copy a complete CLI setup request into any coding agent."}),c.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-1",children:[c.jsxs(xe,{type:"button",variant:"ghost",size:"sm",className:"-ml-3",onClick:$t(ie),children:[he?c.jsx(d0,{className:"size-3.5","aria-hidden":"true"}):c.jsx(Uv,{className:"size-3.5","aria-hidden":"true"}),c.jsx("span",{"aria-live":"polite",children:he?"Copied setup request":"Copy setup request"})]}),c.jsx(xe,{asChild:!0,variant:"ghost",size:"sm",children:c.jsxs("a",{href:HL,target:"_blank",rel:"noopener noreferrer",children:["Agent quickstart",c.jsx(qj,{className:"size-3.5","aria-hidden":"true"}),c.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]})})]})]})]})}function oU(){return c.jsx("div",{className:"page-container",children:c.jsx("section",{className:"page-section",children:c.jsxs(_a,{className:"surface-card empty-card",children:[c.jsx("h1",{children:"Route not found"}),c.jsx("p",{children:"The current path does not map to a dashboard view."}),c.jsx(xe,{asChild:!0,children:c.jsx(et,{to:"/",children:"Return to overview"})})]})})})}const Ga=Ci(()=>Ln(()=>import("./ProjectPage-CoRkwGec.js"),__vite__mapDeps([5,1,6,0,2,3,4,7,8,9,10,11,12]),import.meta.url),"ProjectPage"),rU=Ci(()=>Ln(()=>import("./RunsPage-7wdCl_J3.js"),__vite__mapDeps([13,1,6,10,4,2,11,12]),import.meta.url),"RunsPage"),lU=Ci(()=>Ln(()=>import("./HistoryPage-D0BWQK0c.js"),__vite__mapDeps([14,1,8,10,4,2,11,12]),import.meta.url),"HistoryPage"),cU=Ci(()=>Ln(()=>import("./SettingsPage-D37dV5-m.js"),__vite__mapDeps([15,1,10,4,2,11,12]),import.meta.url),"SettingsPage"),uU=Ci(()=>Ln(()=>import("./BacklinksPage-BcWequGL.js"),__vite__mapDeps([16,1,2,10,4,11,12]),import.meta.url),"BacklinksPage"),dU=Ci(()=>Ln(()=>import("./TrafficPage-Bn1yDSRr.js"),__vite__mapDeps([17,1,7,2,10,4,11,12]),import.meta.url),"TrafficPage"),mU=Ci(()=>Ln(()=>import("./TrafficSourceDetailPage-CURlB_yO.js"),__vite__mapDeps([18,1,7,3,4,2,10,11,12]),import.meta.url),"TrafficSourceDetailPage"),pU=Ci(()=>Ln(()=>import("./MeasurementPropertyPage-D96eQnYJ.js"),__vite__mapDeps([19,1,3,4,9,2,10,11,12]),import.meta.url),"MeasurementPropertyPage");function hU(){return c.jsx(fL,{children:c.jsx(hL,{})})}const ra=dj()({component:hU,validateSearch:e=>({manageQueries:e.manageQueries===!0||e.manageQueries==="true"?!0:void 0,runId:typeof e.runId=="string"?e.runId:void 0,siteHealthRunId:typeof e.siteHealthRunId=="string"?e.siteHealthRunId:void 0,evidenceId:typeof e.evidenceId=="string"?e.evidenceId:void 0,runStatus:typeof e.runStatus=="string"?e.runStatus:void 0,runKind:typeof e.runKind=="string"?e.runKind:void 0,runProject:typeof e.runProject=="string"?e.runProject:void 0,runWindow:typeof e.runWindow=="string"?e.runWindow:void 0,runQuery:typeof e.runQuery=="string"?e.runQuery:void 0,onboarding:e.onboarding==="site-health"?"site-health":void 0,experience:e.experience==="legacy"?"legacy":void 0,setupProject:typeof e.setupProject=="string"?e.setupProject:void 0,scope:typeof e.scope=="string"?e.scope:void 0,class:typeof e.class=="string"?e.class:void 0})}),fU=xt({getParentRoute:()=>ra,path:"/",component:xL,beforeLoad:async({context:e})=>{let n=e.queryClient.getQueryData(Ai({client:se}));if(n===void 0)try{n=await e.queryClient.ensureQueryData(gs({client:se}))}catch{return}if(n.length===0)throw Ov({to:"/setup"})}}),gU=xt({getParentRoute:()=>ra,path:"/projects",component:wL}),yU=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,va=xt({getParentRoute:()=>ra,path:"/projects/$projectName",component:()=>c.jsx(zp,{}),beforeLoad:async({context:e,params:n,location:s})=>{const r=n.projectName;if(!yU.test(r))return;let u=e.queryClient.getQueryData(Ai({client:se}));if(!u)try{u=await e.queryClient.ensureQueryData(gs({client:se}))}catch{return}const f=u.find(g=>g.id===r);if(f)throw Ov({to:s.pathname.replace(`/projects/${r}`,`/projects/${encodeURIComponent(f.name)}`),replace:!0})}}),bU=xt({getParentRoute:()=>va,path:"/",component:()=>c.jsx(Ga,{tab:"overview"})}),vU=xt({getParentRoute:()=>va,path:"/portfolio",component:()=>c.jsx(Ga,{tab:"portfolio"})}),xU=xt({getParentRoute:()=>va,path:"/search-console",component:()=>c.jsx(Ga,{tab:"search-console"})}),kU=xt({getParentRoute:()=>va,path:"/conversions",component:()=>c.jsx(Ga,{tab:"conversions"})}),wU=xt({getParentRoute:()=>va,path:"/local",component:()=>c.jsx(Ga,{tab:"local"})}),SU=xt({getParentRoute:()=>va,path:"/discovery",component:()=>c.jsx(Ga,{tab:"discovery"})}),jU=xt({getParentRoute:()=>va,path:"/properties/$targetKey",component:()=>c.jsx(pU,{})}),AU=xt({getParentRoute:()=>va,path:"/report",component:()=>c.jsx(Ga,{tab:"report"})}),CU=xt({getParentRoute:()=>va,path:"/activity",component:()=>c.jsx(Ga,{tab:"activity"})}),NU=xt({getParentRoute:()=>va,path:"/backlinks",component:()=>c.jsx(Ga,{tab:"backlinks"})}),_U=xt({getParentRoute:()=>va,path:"/technical-aeo",component:()=>c.jsx(Ga,{tab:"technical-aeo"})}),zU=xt({getParentRoute:()=>va,path:"/history",component:()=>c.jsx(Ga,{tab:"history"})}),DU=xt({getParentRoute:()=>va,path:"/settings",component:()=>c.jsx(Ga,{tab:"settings"})}),EU=xt({getParentRoute:()=>ra,path:"/runs",component:rU}),TU=xt({getParentRoute:()=>ra,path:"/history",component:lU}),RU=xt({getParentRoute:()=>ra,path:"/settings",component:cU,beforeLoad:({context:e})=>{}}),OU=xt({getParentRoute:()=>ra,path:"/setup",component:nU}),BU=xt({getParentRoute:()=>ra,path:"/backlinks",component:uU}),qU=xt({getParentRoute:()=>ra,path:"/traffic",component:dU}),MU=xt({getParentRoute:()=>ra,path:"/traffic/$projectName/$sourceId",component:mU}),PU=xt({getParentRoute:()=>ra,path:"*",component:oU}),IU=ra.addChildren([fU,gU,va.addChildren([bU,vU,xU,kU,wU,SU,jU,AU,CU,NU,_U,zU,DU]),EU,TU,RU,OU,BU,qU,MU,PU]);function VU(){return typeof window<"u"&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath:"/"}const Ev=VU(),LU=Ev==="/"?"":Ev.replace(/\/$/,"");function UU(e,n){return mj({routeTree:IU,basepath:LU||"/",context:{queryClient:e},...n?.initialEntries})}const GU=6e4;function $U(){const[e,n]=D.useState(ap()?"ready":"checking"),[s,r]=D.useState(null),[u,f]=D.useState(!1),[g,b]=D.useState(""),[x,k]=D.useState(""),[S,C]=D.useState(""),[j,E]=D.useState(null),[B,q]=D.useState(!1),[U,G]=D.useState(!1),te=D.useRef(null),X=D.useRef(null),ae=D.useRef(null),oe=()=>{const he=s?`${s.name}:${s.role}`:"no-accounts";if(!te.current||ae.current!==he){X.current?.clear();const we=ZA();X.current=we,te.current=UU(we),ae.current=he}return{queryClient:X.current,router:te.current}},ge=he=>he.authRequired?(f(!0),r(he.user),n(he.user?"ready":"account-login"),!0):!1;D.useEffect(()=>{if(ap())return;let he=!1;return Promise.allSettled([Ny(),Cy()]).then(([we,Oe])=>{if(he||we.status==="fulfilled"&&ge(we.value))return;if(Oe.status==="rejected"){const Fe=Oe.reason;E(Fe instanceof Error?Fe.message:"Failed to reach the Canonry API"),n("login");return}const je=Oe.value;je.authenticated?n("ready"):n(je.setupRequired?"setup":"login")}),()=>{he=!0}},[]),D.useEffect(()=>{if(e!=="ready"||ap())return;const he=setInterval(()=>{if(u){Ny().then(we=>{we.authRequired&&!we.user&&(G(!0),r(null),n("account-login"))}).catch(()=>{});return}Cy().then(we=>{we.authenticated||(G(!0),n(we.setupRequired?"setup":"login"))}).catch(()=>{})},GU);return Ay(()=>{G(!0),r(null),n(u?"account-login":"login")}),()=>{clearInterval(he),Ay(null)}},[e,u]);const M=async he=>{if(he.preventDefault(),!x.trim()||x.trim().length<8){E("Password must be at least 8 characters");return}if(x!==S){E("Passwords do not match");return}q(!0),E(null);try{if(!(await wA(x.trim())).authenticated){E("Setup failed");return}k(""),C(""),G(!1),n("ready")}catch(we){E(we instanceof oa||we instanceof Error?we.message:"Setup failed")}finally{q(!1)}},J=async he=>{if(he.preventDefault(),!!x.trim()){q(!0),E(null);try{if(!(await SA(x.trim())).authenticated){E("Incorrect password");return}k(""),G(!1),n("ready")}catch(we){E(we instanceof oa||we instanceof Error?we.message:"Authentication failed")}finally{q(!1)}}},_e=async he=>{if(he.preventDefault(),!(!g.trim()||!x)){q(!0),E(null);try{const we=await jA(g.trim(),x);if(!we.user){E("Incorrect name or password.");return}k(""),G(!1),r(we.user),n("ready")}catch(we){E(we instanceof oa?we.message:"Incorrect name or password.")}finally{q(!1)}}};if(e==="ready"){const{queryClient:he,router:we}=oe();return c.jsx(PA,{account:s,children:c.jsx(pj,{client:he,children:c.jsx(hj,{router:we})})})}return c.jsx("div",{className:"min-h-screen bg-bg px-4 py-8",children:c.jsxs("div",{className:"mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col items-center justify-center gap-5",children:[c.jsxs("div",{"data-testid":"auth-brand",className:"flex items-center gap-2.5",children:[c.jsx("img",{className:"size-7",src:"./favicon.svg",alt:"","aria-hidden":"true"}),c.jsx("span",{className:"text-lg font-semibold tracking-tight text-heading",children:"Canonry"})]}),c.jsx(_a,{className:"surface-card w-full",children:e==="checking"?c.jsx(ho,{className:"py-8",children:c.jsx("p",{className:"supporting-copy text-center",children:"Connecting to Canonry…"})}):e==="account-login"?c.jsxs(c.Fragment,{children:[c.jsxs(Qr,{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),c.jsx(Zr,{children:"Sign in to Canonry"})]}),c.jsxs(ho,{children:[U?c.jsx("p",{className:"mb-4 rounded-md border border-caution bg-caution-soft px-3 py-2 text-sm text-caution",children:"You were signed out — please sign in again."}):null,c.jsxs("form",{className:"space-y-4",onSubmit:$t(_e),children:[c.jsxs("label",{className:"block space-y-1.5",htmlFor:"account-name",children:[c.jsx("span",{className:"text-xs font-medium text-secondary",children:"Name"}),c.jsx("input",{autoFocus:!0,id:"account-name",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"text",autoComplete:"username",value:g,onChange:he=>b(he.target.value)})]}),c.jsxs("label",{className:"block space-y-1.5",htmlFor:"account-password",children:[c.jsx("span",{className:"text-xs font-medium text-secondary",children:"Password"}),c.jsx("input",{id:"account-password",className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"password",autoComplete:"current-password",value:x,onChange:he=>k(he.target.value)})]}),j?c.jsx("p",{className:"text-sm text-negative-400",children:j}):null,c.jsx(xe,{type:"submit",disabled:B||!g.trim()||!x,children:B?"Signing in…":"Sign in"})]})]})]}):e==="setup"?c.jsxs(c.Fragment,{children:[c.jsxs(Qr,{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"First-time setup"}),c.jsx(Zr,{children:"Create a dashboard password"}),c.jsx(cu,{children:"Choose a password to protect the Canonry dashboard."})]}),c.jsx(ho,{children:c.jsxs("form",{className:"space-y-4",onSubmit:$t(M),children:[c.jsxs("label",{className:"block space-y-1.5",children:[c.jsx("span",{className:"text-xs font-medium text-secondary",children:"Password"}),c.jsx("input",{autoFocus:!0,className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"password",value:x,onChange:he=>k(he.target.value),placeholder:"At least 8 characters"})]}),c.jsxs("label",{className:"block space-y-1.5",children:[c.jsx("span",{className:"text-xs font-medium text-secondary",children:"Confirm password"}),c.jsx("input",{className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"password",value:S,onChange:he=>C(he.target.value),placeholder:"Re-enter password"})]}),j?c.jsx("p",{className:"text-sm text-negative-400",children:j}):null,c.jsx(xe,{type:"submit",disabled:B||!x.trim()||!S.trim(),children:B?"Setting up…":"Create password & open dashboard"})]})})]}):c.jsxs(c.Fragment,{children:[c.jsxs(Qr,{children:[c.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),c.jsx(Zr,{children:"Sign in to Canonry"}),c.jsx(cu,{children:"Enter your dashboard password to continue."})]}),c.jsxs(ho,{children:[U?c.jsx("p",{className:"mb-4 rounded-md border border-caution bg-caution-soft px-3 py-2 text-sm text-caution",children:"Your session expired — please sign in again."}):null,c.jsxs("form",{className:"space-y-4",onSubmit:$t(J),children:[c.jsxs("label",{className:"block space-y-1.5",children:[c.jsx("span",{className:"text-xs font-medium text-secondary",children:"Password"}),c.jsx("input",{autoFocus:!0,className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"password",value:x,onChange:he=>k(he.target.value),placeholder:"Dashboard password"})]}),j?c.jsx("p",{className:"text-sm text-negative-400",children:j}):null,c.jsx(xe,{type:"submit",disabled:B||!x.trim(),children:B?"Signing in…":"Open dashboard"})]})]})]})})]})})}const X3=document.getElementById("root");if(!X3)throw new Error("Expected #root element for web app bootstrap.");Gj.createRoot(X3).render(c.jsx(D.StrictMode,{children:c.jsx($U,{})}));export{YH as $,zG as A,xe as B,su as C,LH as D,$H as E,GH as F,N$ as G,IG as H,Vr as I,PG as J,YG as K,Yt as L,VK as M,QH as N,ZH as O,$I as P,$G as Q,FH as R,Wq as S,ga as T,HG as U,LG as V,GG as W,HH as X,KH as Y,UH as Z,VG as _,PK as a,OH as a$,nK as a0,WH as a1,tK as a2,eK as a3,aK as a4,BA as a5,wh as a6,Te as a7,JH as a8,v3 as a9,fH as aA,Z$ as aB,F$ as aC,kK as aD,wK as aE,SK as aF,KG as aG,Ai as aH,QG as aI,xh as aJ,fK as aK,jM as aL,xH as aM,al as aN,wH as aO,zH as aP,PH as aQ,NH as aR,qH as aS,VH as aT,jH as aU,EH as aV,TH as aW,RH as aX,SH as aY,DH as aZ,AH as a_,In as aa,XH as ab,KK as ac,yT as ad,bT as ae,D$ as af,z$ as ag,g$ as ah,w$ as ai,S$ as aj,oa as ak,j$ as al,xG as am,eM as an,ZP as ao,Zc as ap,A$ as aq,Op as ar,gK as as,q_ as at,UG as au,_$ as av,dM as aw,DM as ax,hH as ay,gH as az,jz as b,yH as b$,CH as b0,BH as b1,_H as b2,MH as b3,IH as b4,jL as b5,de as b6,yG as b7,gG as b8,fG as b9,$$ as bA,H$ as bB,P$ as bC,U$ as bD,NG as bE,CG as bF,AG as bG,s$ as bH,EG as bI,aH as bJ,Jb as bK,tH as bL,TG as bM,RG as bN,eH as bO,OG as bP,BG as bQ,MG as bR,qG as bS,pl as bT,gs as bU,OV as bV,sx as bW,iH as bX,sH as bY,$K as bZ,_L as b_,hG as ba,dG as bb,uG as bc,pG as bd,mG as be,cG as bf,lG as bg,tG as bh,aG as bi,rG as bj,oG as bk,sG as bl,nG as bm,iG as bn,eG as bo,WU as bp,JU as bq,XU as br,h4 as bs,V$ as bt,hK as bu,I$ as bv,i$ as bw,HK as bx,G$ as by,L$ as bz,IK as c,fh as c$,kH as c0,oH as c1,lH as c2,uH as c3,rH as c4,sa as c5,gA as c6,sM as c7,wG as c8,SG as c9,cA,bG as cB,vG as cC,DG as cD,ZG as cE,FG as cF,Th as cG,Iu as cH,Ch as cI,n$ as cJ,No as cK,ev as cL,h$ as cM,y$ as cN,v$ as cO,x$ as cP,f$ as cQ,b$ as cR,k$ as cS,HI as cT,M3 as cU,YI as cV,P3 as cW,I3 as cX,p$ as cY,vK as cZ,Q$ as c_,kG as ca,bA as cb,jG as cc,uM as cd,_G as ce,iK as cf,DA as cg,t$ as ch,oK as ci,rK as cj,lK as ck,sK as cl,X$ as cm,XG as cn,JG as co,WG as cp,a$ as cq,e$ as cr,vo as cs,kh as ct,LK as cu,Pu as cv,Ah as cw,bH as cx,vH as cy,AA as cz,_a as d,nH as d0,yK as d1,xK as d2,m$ as d3,K$ as d4,u$ as d5,d$ as d6,c$ as d7,bK as d8,h9 as d9,B$ as dA,TK as dB,tR as dC,M$ as dD,q$ as dE,dH as da,cH as db,pH as dc,mH as dd,R$ as de,Ln as df,Ua as dg,T$ as dh,jK as di,CK as dj,AK as dk,zL as dl,O$ as dm,BK as dn,qK as dp,MK as dq,NK as dr,_K as ds,E$ as dt,EK as du,OK as dv,DK as dw,RK as dx,zK as dy,_o as dz,fa as e,$t as f,C$ as g,dv as h,sA as i,cK as j,se as k,uK as l,dK as m,pK as n,mK as o,o$ as p,l$ as q,r$ as r,UK as s,aM as t,Nh as u,GK as v,s0 as w,J$ as x,Y$ as y,W$ as z};
@@ -1,4 +1,4 @@
1
- import{g as Bt,t as S,r as C}from"./vendor-tanstack-Dock0eH1.js";import{e as Ht,G as Wt}from"./SiteHealthSection-vGzpNzMx.js";import"./index-CQ2ysGTv.js";import"./vendor-radix-4UOaVWza.js";import"./vendor-recharts-D8rt5lKn.js";import"./vendor-lucide-nYKv-BB7.js";import"./vendor-markdown-Bn7fRwrx.js";import"./vendor-yaml-GWJz5H2G.js";import"./ChartPrimitives-BoYe2M-i.js";function Vt(r,n){if(typeof r!="object"||!r)return r;var i=r[Symbol.toPrimitive];if(i!==void 0){var e=i.call(r,n);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function ae(r){var n=Vt(r,"string");return typeof n=="symbol"?n:n+""}function A(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function He(r,n){for(var i=0;i<n.length;i++){var e=n[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(r,ae(e.key),e)}}function L(r,n,i){return n&&He(r.prototype,n),i&&He(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r}function Q(r){return Q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Q(r)}function yt(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(yt=function(){return!!r})()}function jt(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Zt(r,n){if(n&&(typeof n=="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return jt(r)}function I(r,n,i){return n=Q(n),Zt(r,yt()?Reflect.construct(n,i||[],Q(r).constructor):n.apply(r,i))}function xe(r,n){return xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,e){return i.__proto__=e,i},xe(r,n)}function G(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),n&&xe(r,n)}function qt(r){if(Array.isArray(r))return r}function Yt(r,n){var i=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(i!=null){var e,t,a,o,s=[],l=!0,h=!1;try{if(a=(i=i.call(r)).next,n===0){if(Object(i)!==i)return;l=!1}else for(;!(l=(e=a.call(i)).done)&&(s.push(e.value),s.length!==n);l=!0);}catch(u){h=!0,t=u}finally{try{if(!l&&i.return!=null&&(o=i.return(),Object(o)!==o))return}finally{if(h)throw t}}return s}}function Se(r,n){(n==null||n>r.length)&&(n=r.length);for(var i=0,e=Array(n);i<n;i++)e[i]=r[i];return e}function Tt(r,n){if(r){if(typeof r=="string")return Se(r,n);var i={}.toString.call(r).slice(8,-1);return i==="Object"&&r.constructor&&(i=r.constructor.name),i==="Map"||i==="Set"?Array.from(r):i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Se(r,n):void 0}}function Xt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{g as Bt,t as S,r as C}from"./vendor-tanstack-Dock0eH1.js";import{e as Ht,G as Wt}from"./SiteHealthSection-B9WF97sJ.js";import"./index-CiQNKNMG.js";import"./vendor-radix-4UOaVWza.js";import"./vendor-recharts-D8rt5lKn.js";import"./vendor-lucide-nYKv-BB7.js";import"./vendor-markdown-Bn7fRwrx.js";import"./vendor-yaml-GWJz5H2G.js";import"./ChartPrimitives-BoYe2M-i.js";function Vt(r,n){if(typeof r!="object"||!r)return r;var i=r[Symbol.toPrimitive];if(i!==void 0){var e=i.call(r,n);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function ae(r){var n=Vt(r,"string");return typeof n=="symbol"?n:n+""}function A(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function He(r,n){for(var i=0;i<n.length;i++){var e=n[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(r,ae(e.key),e)}}function L(r,n,i){return n&&He(r.prototype,n),i&&He(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r}function Q(r){return Q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Q(r)}function yt(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(yt=function(){return!!r})()}function jt(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Zt(r,n){if(n&&(typeof n=="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return jt(r)}function I(r,n,i){return n=Q(n),Zt(r,yt()?Reflect.construct(n,i||[],Q(r).constructor):n.apply(r,i))}function xe(r,n){return xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,e){return i.__proto__=e,i},xe(r,n)}function G(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),n&&xe(r,n)}function qt(r){if(Array.isArray(r))return r}function Yt(r,n){var i=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(i!=null){var e,t,a,o,s=[],l=!0,h=!1;try{if(a=(i=i.call(r)).next,n===0){if(Object(i)!==i)return;l=!1}else for(;!(l=(e=a.call(i)).done)&&(s.push(e.value),s.length!==n);l=!0);}catch(u){h=!0,t=u}finally{try{if(!l&&i.return!=null&&(o=i.return(),Object(o)!==o))return}finally{if(h)throw t}}return s}}function Se(r,n){(n==null||n>r.length)&&(n=r.length);for(var i=0,e=Array(n);i<n;i++)e[i]=r[i];return e}function Tt(r,n){if(r){if(typeof r=="string")return Se(r,n);var i={}.toString.call(r).slice(8,-1);return i==="Object"&&r.constructor&&(i=r.constructor.name),i==="Map"||i==="Set"?Array.from(r):i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Se(r,n):void 0}}function Xt(){throw new 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 ee(r,n){return qt(r)||Yt(r,n)||Tt(r,n)||Xt()}var pe={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"},Ct=new Int8Array(4),be=new Int32Array(Ct.buffer,0,1),$t=new Float32Array(Ct.buffer,0,1),Kt=/^\s*rgba?\s*\(/,Jt=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Qt(r){var n=0,i=0,e=0,t=1;if(r[0]==="#")r.length===4?(n=parseInt(r.charAt(1)+r.charAt(1),16),i=parseInt(r.charAt(2)+r.charAt(2),16),e=parseInt(r.charAt(3)+r.charAt(3),16)):(n=parseInt(r.charAt(1)+r.charAt(2),16),i=parseInt(r.charAt(3)+r.charAt(4),16),e=parseInt(r.charAt(5)+r.charAt(6),16)),r.length===9&&(t=parseInt(r.charAt(7)+r.charAt(8),16)/255);else if(Kt.test(r)){var a=r.match(Jt);a&&(n=+a[1],i=+a[2],e=+a[3],a[4]&&(t=+a[4]))}return{r:n,g:i,b:e,a:t}}var J={};for(var le in pe)J[le]=oe(pe[le]),J[pe[le]]=J[le];function Rt(r,n,i,e,t){return be[0]=e<<24|i<<16|n<<8|r,be[0]=be[0]&4278190079,$t[0]}function oe(r){if(r=r.toLowerCase(),typeof J[r]<"u")return J[r];var n=Qt(r),i=n.r,e=n.g,t=n.b,a=n.a;a=a*255|0;var o=Rt(i,e,t,a);return J[r]=o,o}var Ee={};function _t(r){if(typeof Ee[r]<"u")return Ee[r];var n=(r&16711680)>>>16,i=(r&65280)>>>8,e=r&255,t=255,a=Rt(n,i,e,t);return Ee[r]=a,a}function We(r,n,i,e){return i+(n<<8)+(r<<16)}function Ve(r,n,i,e,t,a){var o=Math.floor(i/a*t),s=Math.floor(r.drawingBufferHeight/a-e/a*t),l=new Uint8Array(4);r.bindFramebuffer(r.FRAMEBUFFER,n),r.readPixels(o,s,1,1,r.RGBA,r.UNSIGNED_BYTE,l);var h=ee(l,4),u=h[0],d=h[1],f=h[2],g=h[3];return[u,d,f,g]}function c(r,n,i){return(n=ae(n))in r?Object.defineProperty(r,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[n]=i,r}function je(r,n){var i=Object.keys(r);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(r);n&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})),i.push.apply(i,e)}return i}function b(r){for(var n=1;n<arguments.length;n++){var i=arguments[n]!=null?arguments[n]:{};n%2?je(Object(i),!0).forEach(function(e){c(r,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):je(Object(i)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}function ei(r,n){for(;!{}.hasOwnProperty.call(r,n)&&(r=Q(r))!==null;);return r}function Ae(){return Ae=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(r,n,i){var e=ei(r,n);if(e){var t=Object.getOwnPropertyDescriptor(e,n);return t.get?t.get.call(arguments.length<3?r:i):t.value}},Ae.apply(null,arguments)}function wt(r,n,i,e){var t=Ae(Q(r.prototype),n,i);return typeof t=="function"?function(a){return t.apply(i,a)}:t}function ti(r){return r.normalized?1:r.size}function ye(r){var n=0;return r.forEach(function(i){return n+=ti(i)}),n}function xt(r,n,i){var e=r==="VERTEX"?n.VERTEX_SHADER:n.FRAGMENT_SHADER,t=n.createShader(e);if(t===null)throw new Error("loadShader: error while creating the shader");n.shaderSource(t,i),n.compileShader(t);var a=n.getShaderParameter(t,n.COMPILE_STATUS);if(!a){var o=n.getShaderInfoLog(t);throw n.deleteShader(t),new Error(`loadShader: error while compiling the shader:
3
3
  `.concat(o,`
4
4
  `).concat(i))}return t}function ii(r,n){return xt("VERTEX",r,n)}function ri(r,n){return xt("FRAGMENT",r,n)}function ni(r,n){var i=r.createProgram();if(i===null)throw new Error("loadProgram: error while creating the program.");var e,t;for(e=0,t=n.length;e<t;e++)r.attachShader(i,n[e]);r.linkProgram(i);var a=r.getProgramParameter(i,r.LINK_STATUS);if(!a){var o=r.getProgramInfoLog(i);throw r.deleteProgram(i),new Error("loadProgram: error while linking the program: ".concat(o))}return i}function Ze(r){var n=r.gl,i=r.buffer,e=r.program,t=r.vertexShader,a=r.fragmentShader;n.deleteShader(t),n.deleteShader(a),n.deleteProgram(e),n.deleteBuffer(i)}var qe=`#define PICKING_MODE
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-CQ2ysGTv.js"></script>
15
+ <script type="module" crossorigin src="./assets/index-CiQNKNMG.js"></script>
16
16
  <link rel="modulepreload" crossorigin href="./assets/vendor-tanstack-Dock0eH1.js">
17
17
  <link rel="modulepreload" crossorigin href="./assets/vendor-radix-4UOaVWza.js">
18
18
  <link rel="modulepreload" crossorigin href="./assets/vendor-recharts-D8rt5lKn.js">