@canonry/canonry 7.64.5 → 7.65.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.
Files changed (131) hide show
  1. package/assets/agent-workspace/skills/canonry/references/canonry-cli.md +2 -1
  2. package/assets/assets/{AgentSetupPage-DYw_Srwu.js → AgentSetupPage-DPHRo4OR.js} +1 -1
  3. package/assets/assets/{AuditHistoryPanel-6_-mgHbw.js → AuditHistoryPanel-qhIB8KRK.js} +1 -1
  4. package/assets/assets/{BacklinksPage-DFzYKntv.js → BacklinksPage-iWrZ0-Pp.js} +1 -1
  5. package/assets/assets/{HistoryPage-C4pZxBYX.js → HistoryPage-BP1_GGlT.js} +1 -1
  6. package/assets/assets/{MeasurementPropertyPage-C7TkC3Ja.js → MeasurementPropertyPage-DfPHZNGo.js} +1 -1
  7. package/assets/assets/{ProjectPage-CmT2Vghx.js → ProjectPage-D4n2oqPP.js} +2 -2
  8. package/assets/assets/RunsPage-Cc98Px3T.js +1 -0
  9. package/assets/assets/{SettingsPage-Cl6ni4_w.js → SettingsPage-CMyCE-H2.js} +1 -1
  10. package/assets/assets/{SiteHealthSection-D8D2mIsJ.js → SiteHealthSection-CGKKUtqQ.js} +2 -2
  11. package/assets/assets/ToneBadge-CJ6ObMRe.js +60 -0
  12. package/assets/assets/{TrafficPage-jAQRK1Xq.js → TrafficPage-DAef3d2A.js} +1 -1
  13. package/assets/assets/{TrafficSourceDetailPage-VuKDrAGn.js → TrafficSourceDetailPage-CdoL5Dt9.js} +1 -1
  14. package/assets/assets/{account-context-haz0f6Tu.js → account-context-CWRd3KeS.js} +1 -1
  15. package/assets/assets/{card-BAimTqa8.js → card-Cb_fM36G.js} +1 -1
  16. package/assets/assets/{extract-error-message-BBG79rN-.js → extract-error-message-DSIAoHTR.js} +1 -1
  17. package/assets/assets/{format-helpers-DQRYsYjD.js → format-helpers-CxNDa1oa.js} +1 -1
  18. package/assets/assets/{index-DyLlYKrZ.js → index-DEXKV7TW.js} +6 -6
  19. package/assets/assets/{query-client-DhJ8vlMi.js → query-client-DLdAMlsX.js} +1 -1
  20. package/assets/assets/{react-query-CRJlZpE1.js → react-query-BktZZtSC.js} +1 -1
  21. package/assets/assets/{react-sigma_core.esm.min-Ctdaaevn.js → react-sigma_core.esm.min-DgK5sRqv.js} +1 -1
  22. package/assets/assets/{service-83e6qD-8.js → service-Dv9FDyFY.js} +1 -1
  23. package/assets/index.html +7 -7
  24. package/dist/{ads-XBJFILES.js → ads-D4WQOT5K.js} +3 -3
  25. package/dist/{agent-LWL4G3YX.js → agent-E3IYC7OJ.js} +7 -7
  26. package/dist/{agent-ask-2SBUWTSS.js → agent-ask-ZSKRPB2Z.js} +3 -3
  27. package/dist/{agent-conversations-S465NNT2.js → agent-conversations-YHPYPQE2.js} +3 -3
  28. package/dist/{agent-memory-KS26TRAX.js → agent-memory-6OWOOD5O.js} +3 -3
  29. package/dist/{agent-providers-GLKRFX7S.js → agent-providers-7KZK37UO.js} +3 -3
  30. package/dist/{agent-transcript-WBDL4RTP.js → agent-transcript-3O7GPML6.js} +3 -3
  31. package/dist/{analytics-UUINEXLR.js → analytics-P2LLIUYK.js} +3 -3
  32. package/dist/{apply-HOEJMCHJ.js → apply-VBNNJOCT.js} +3 -3
  33. package/dist/{backfill-X46FWWGQ.js → backfill-F5SSURCH.js} +9 -9
  34. package/dist/{backlinks-NKZXQWXU.js → backlinks-4RE3TNNA.js} +3 -3
  35. package/dist/{bing-JVHVTKGP.js → bing-V6UN7D44.js} +3 -3
  36. package/dist/{bootstrap-SL2I6R6N.js → bootstrap-SHTSPAI5.js} +10 -10
  37. package/dist/{cdp-QBXJ3CN3.js → cdp-GDL2VFI3.js} +7 -7
  38. package/dist/{chunk-7RZFTNWT.js → chunk-2AROR73F.js} +5 -5
  39. package/dist/{chunk-56ISY5RC.js → chunk-2Y7RN5HG.js} +3 -3
  40. package/dist/{chunk-ZTNH6H2F.js → chunk-3QKKHU7D.js} +8 -8
  41. package/dist/{chunk-ZZIFS4RW.js → chunk-66DPEVLJ.js} +3 -3
  42. package/dist/{chunk-YXXJFOVG.js → chunk-6FN2OQKL.js} +340 -340
  43. package/dist/{chunk-VXKMJFPV.js → chunk-737TOG2F.js} +1 -1
  44. package/dist/{chunk-BMOMIECJ.js → chunk-AE6HJZBU.js} +3 -3
  45. package/dist/{chunk-C2DURF57.js → chunk-BV6NXSAH.js} +3 -3
  46. package/dist/{chunk-VXTI3APQ.js → chunk-C2PYKUD3.js} +1 -1
  47. package/dist/{chunk-XRE7XAYH.js → chunk-CRKOGLKJ.js} +18 -4
  48. package/dist/{chunk-T3QZVIPV.js → chunk-DQVJB6CZ.js} +1 -1
  49. package/dist/{chunk-IQVD3UND.js → chunk-F7NZEUXP.js} +2 -2
  50. package/dist/{chunk-S42DBIIC.js → chunk-GM5ZOWBK.js} +3 -3
  51. package/dist/{chunk-LEGBODMN.js → chunk-GQXSZE2Z.js} +62 -20
  52. package/dist/{chunk-UL2XEPI6.js → chunk-GZPGDAAF.js} +2 -2
  53. package/dist/{chunk-DEO75ZSC.js → chunk-H6HIJAIU.js} +2 -2
  54. package/dist/{chunk-XQTLLBJG.js → chunk-HI2HCYLB.js} +2 -2
  55. package/dist/{chunk-LITW7QNO.js → chunk-HO5W6QC7.js} +1 -1
  56. package/dist/{chunk-UGVEFUZ4.js → chunk-HPUZMBS6.js} +2 -2
  57. package/dist/{chunk-R62SF6QP.js → chunk-IJKKK7F4.js} +1 -1
  58. package/dist/{chunk-565ZI72D.js → chunk-IYB3EGSD.js} +1 -1
  59. package/dist/{chunk-STEYZ24N.js → chunk-LTX3TJ3E.js} +1 -1
  60. package/dist/{chunk-NE4KRQYV.js → chunk-M3OZL6PQ.js} +4 -4
  61. package/dist/{chunk-SSBJIBK7.js → chunk-O3INLME6.js} +4 -4
  62. package/dist/{chunk-Q62B3ISV.js → chunk-Q2WZAD5W.js} +1 -1
  63. package/dist/{chunk-PNDART6A.js → chunk-QNRMYDK6.js} +1 -1
  64. package/dist/{chunk-SFHUS5N4.js → chunk-S4VCXCRQ.js} +1 -1
  65. package/dist/{chunk-FBHW62IM.js → chunk-SL3Y7IOX.js} +1 -1
  66. package/dist/{chunk-GPNOJVM2.js → chunk-X4AHYJCE.js} +5 -5
  67. package/dist/{chunk-XFZPSZKU.js → chunk-XMKXXWMO.js} +2 -2
  68. package/dist/{chunk-DMNRYTX7.js → chunk-XOMUSIM7.js} +2 -2
  69. package/dist/{chunk-PKRH4UKJ.js → chunk-Z2EENWM3.js} +96 -30
  70. package/dist/{chunk-EII2VL22.js → chunk-ZPRJCSSR.js} +1 -1
  71. package/dist/{chunk-BTWB3ZAW.js → chunk-ZWZOQNLD.js} +1 -1
  72. package/dist/{citations-AW63LMXP.js → citations-GO4SPZYS.js} +3 -3
  73. package/dist/{cli-catalog-FBB6DN3W.js → cli-catalog-6XYQY3PI.js} +3 -3
  74. package/dist/{cli-commands-MXWXQSSX.js → cli-commands-AMURHC27.js} +7 -7
  75. package/dist/cli.js +13 -13
  76. package/dist/{competitor-YVI2IA7R.js → competitor-JBTKRJ6Y.js} +3 -3
  77. package/dist/{content-EJVE6ZCL.js → content-LKXXQ7X4.js} +3 -3
  78. package/dist/{dashboard-XPVUV6UT.js → dashboard-LUA7UX6B.js} +6 -6
  79. package/dist/{demo-6XBNMZ6F.js → demo-I7JDZJUW.js} +1 -1
  80. package/dist/{demo-server-S3XRNSHH.js → demo-server-GNGGWERV.js} +11 -11
  81. package/dist/{discover-4GZERX62.js → discover-TODAYYJ2.js} +3 -3
  82. package/dist/{discover-eval-F5RD6Q3H.js → discover-eval-FWQESEYB.js} +3 -3
  83. package/dist/{doctor-P2MOEW3V.js → doctor-AXNJT2UC.js} +3 -3
  84. package/dist/{evidence-SUWXYKIW.js → evidence-2XGEY4ZC.js} +3 -3
  85. package/dist/{export-cmd-F3VXILID.js → export-cmd-7RMYBIBZ.js} +3 -3
  86. package/dist/{ga-44LAMZLT.js → ga-HZDIZGCO.js} +3 -3
  87. package/dist/{gbp-WUMYLWJR.js → gbp-SMRBWJEL.js} +3 -3
  88. package/dist/{google-L7YBFK2M.js → google-2CN345XS.js} +4 -4
  89. package/dist/{google-marketing-ZSXMIOO5.js → google-marketing-W7T2VTVW.js} +1 -1
  90. package/dist/{health-cmd-IIE77FT5.js → health-cmd-W7OWZ4ZI.js} +3 -3
  91. package/dist/{history-RK4UG5YE.js → history-UVNCBHTE.js} +3 -3
  92. package/dist/index.d.ts +9 -5
  93. package/dist/index.js +24 -24
  94. package/dist/{init-X2ADJGSC.js → init-MDGOTK2L.js} +11 -11
  95. package/dist/{insights-Z5IGGJMR.js → insights-PQ52G5LU.js} +3 -3
  96. package/dist/intelligence-service-IAUGKMDO.js +15 -0
  97. package/dist/{journeys-CHA56BCH.js → journeys-3PP5GYVJ.js} +3 -3
  98. package/dist/{keys-ATLI7E4N.js → keys-CWZUX7IQ.js} +3 -3
  99. package/dist/{keyword-MICVFKNQ.js → keyword-5OMMULLY.js} +3 -3
  100. package/dist/{logs-BTAFJPMJ.js → logs-3FTE42E3.js} +3 -3
  101. package/dist/{mcp-6GPRFCSX.js → mcp-FK5DTI7I.js} +2 -2
  102. package/dist/mcp.js +9 -9
  103. package/dist/{measurement-plan-PC2YTZ5L.js → measurement-plan-ICO2BQNT.js} +5 -5
  104. package/dist/{notify-UUO7K7PR.js → notify-ML4PYD3L.js} +3 -3
  105. package/dist/{organic-evidence-NLJZMQEH.js → organic-evidence-4U4H3DCR.js} +3 -3
  106. package/dist/{overview-B6NHPCSJ.js → overview-NF427VFO.js} +4 -4
  107. package/dist/{project-TZRDJVYR.js → project-AAO65OF7.js} +3 -3
  108. package/dist/{query-IS5DNPEZ.js → query-7ZOUQNF5.js} +3 -3
  109. package/dist/{research-4Q25MXA6.js → research-UQ7AF5N3.js} +3 -3
  110. package/dist/{results-export-AQXKBDV2.js → results-export-CZCLC4ZH.js} +3 -3
  111. package/dist/{run-NFQRNNMQ.js → run-4XJZW52R.js} +4 -4
  112. package/dist/{schedule-VID5OMNW.js → schedule-D3E5FDBE.js} +3 -3
  113. package/dist/{search-YKIYLRSE.js → search-DYET2IL4.js} +3 -3
  114. package/dist/{serve-DSPCXBV3.js → serve-R2CI3RWQ.js} +25 -25
  115. package/dist/{session-PZ5TREWF.js → session-7CW2V5EH.js} +12 -12
  116. package/dist/{settings-RMGOJNRU.js → settings-ZISHACFX.js} +3 -3
  117. package/dist/{skills-Q3FCYWQK.js → skills-WU6IN3NL.js} +2 -2
  118. package/dist/{snapshot-ZWWYWBMG.js → snapshot-KCKQDJ2W.js} +3 -3
  119. package/dist/{src-IBMZTBVL.js → src-WIOU5G4V.js} +2 -2
  120. package/dist/{status-6MTUPM2Y.js → status-CYZFVMYA.js} +4 -4
  121. package/dist/{technical-aeo-7CWV55RA.js → technical-aeo-P5CS22AR.js} +3 -3
  122. package/dist/{telemetry-PBRCF7MV.js → telemetry-LPK5F2WU.js} +4 -4
  123. package/dist/{tools-AUPH4K65.js → tools-E3B2GZ6Q.js} +11 -11
  124. package/dist/{traffic-24T4MSRG.js → traffic-5KZYXXIQ.js} +5 -5
  125. package/dist/{users-4WBWD7IO.js → users-2F346HIW.js} +3 -3
  126. package/dist/{visibility-stats-H6QWQUNH.js → visibility-stats-ITA6DNF3.js} +3 -3
  127. package/dist/{wordpress-QSAHAV7S.js → wordpress-ZHCFT6V3.js} +3 -3
  128. package/package.json +1 -1
  129. package/assets/assets/RunsPage-B-eTk2cT.js +0 -1
  130. package/assets/assets/ToneBadge-yx6FMD6v.js +0 -60
  131. package/dist/intelligence-service-JYOJ63Z2.js +0 -15
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SiteHealthSection-D8D2mIsJ.js","./rolldown-runtime-XKyaHtl9.js","./vendor-lucide-4KkDquAu.js","./vendor-markdown-9SSeLNHZ.js","./vendor-tanstack-pEsPGDvT.js","./vendor-recharts-qIim36Mt.js","./vendor-radix-BuErWiA2.js","./ToneBadge-yx6FMD6v.js","./account-context-haz0f6Tu.js","./query-client-DhJ8vlMi.js","./react-query-CRJlZpE1.js","./ChartPrimitives-CksxPvHn.js","./InfoTooltip-BbdxCAup.js","./card-BAimTqa8.js","./ProjectPage-CmT2Vghx.js","./format-helpers-DQRYsYjD.js","./async-handler-Bj3TnIRw.js","./Hint-C0TmIzHX.js","./AuditHistoryPanel-6_-mgHbw.js","./service-83e6qD-8.js","./extract-error-message-BBG79rN-.js","./RunsPage-B-eTk2cT.js","./HistoryPage-C4pZxBYX.js","./SettingsPage-Cl6ni4_w.js","./AgentSetupPage-DYw_Srwu.js","./BacklinksPage-DFzYKntv.js","./TrafficPage-jAQRK1Xq.js","./TrafficSourceDetailPage-VuKDrAGn.js","./MeasurementPropertyPage-C7TkC3Ja.js"])))=>i.map(i=>d[i]);
2
- import{r as e,t}from"./rolldown-runtime-XKyaHtl9.js";import{$ as n,A as r,D as i,F as a,G as o,I as s,J as c,K as l,M as u,N as d,O as f,P as p,Q as m,R as h,S as g,T as _,U as v,X as y,Z as b,_ as x,b as S,c as C,et as w,f as T,g as E,h as D,j as O,k as ee,l as k,n as A,o as j,p as te,q as ne,rt as re,t as ie,w as ae,x as M,y as N,z as oe}from"./vendor-lucide-4KkDquAu.js";import{a as se,c as ce,i as le,n as ue,o as de,r as fe,s as pe,t as P,u as me}from"./vendor-radix-BuErWiA2.js";import{n as F,r as I,t as he}from"./vendor-markdown-9SSeLNHZ.js";import{E as ge,T as _e,_ as L,a as ve,b as R,c as ye,d as be,f as xe,h as Se,i as Ce,l as z,m as we,n as Te,o as Ee,r as De,s as Oe,u as B,x as ke}from"./vendor-tanstack-pEsPGDvT.js";import{$ as Ae,$r as je,$t as Me,Ai as Ne,An as Pe,Bn as Fe,Ci as Ie,Cn as Le,Cr as Re,Ct as ze,D as Be,Di as Ve,Dt as He,E as Ue,Ei as We,En as Ge,Fn as Ke,Hr as qe,In as Je,J as Ye,Jt as Xe,K as Ze,Kt as Qe,Ln as $e,Mi as et,Mn as tt,Mr as nt,Ni as rt,Nn as it,Nr as at,Oi as ot,Ot as st,Pi as ct,Pn as lt,Q as ut,Qt as dt,Rn as ft,Rr as pt,Si as mt,Sn as ht,Sr as gt,St as _t,T as vt,Tn as yt,Tt as bt,W as xt,Wt as St,X as Ct,Xr as wt,Xt as Tt,Y as Et,Yn as Dt,Yt as Ot,Z as kt,Zr as At,Zt as jt,_i as Mt,_n as Nt,a as Pt,ar as Ft,at as It,bi as Lt,bn as Rt,bt as zt,cn as Bt,d as Vt,dt as Ht,ei as V,en as Ut,et as Wt,ft as Gt,gi as Kt,gn as qt,hi as Jt,i as Yt,ii as Xt,it as Zt,j as Qt,ji as $t,jn as en,jr as tn,jt as nn,ki as rn,kn as an,kt as on,li as sn,mi as cn,n as ln,ni as H,nn as un,nt as dn,os as fn,ot as pn,pn as mn,pt as U,qt as hn,r as W,ri as gn,rn as _n,rt as vn,sn as yn,st as bn,t as xn,ti as G,tt as Sn,u as Cn,un as wn,v as Tn,vn as En,w as Dn,wi as On,wn as kn,wr as An,wt as jn,xn as Mn,xr as Nn,xt as Pn,yn as Fn,yt as In,z as Ln,zn as Rn,zt as zn}from"./ToneBadge-yx6FMD6v.js";import{d as Bn,f as Vn,l as Hn,s as Un,u as Wn,v as Gn,y as Kn}from"./format-helpers-DQRYsYjD.js";import{n as qn,r as Jn,t as Yn}from"./account-context-haz0f6Tu.js";import{t as Xn}from"./async-handler-Bj3TnIRw.js";import{a as Zn,c as Qn,d as $n,f as er,i as tr,l as nr,m as rr,o as ir,p as ar,r as or}from"./query-client-DhJ8vlMi.js";import{$t as sr,Jt as cr,Qt as lr,Xt as ur,Yt as dr,Zt as fr,_t as pr,a as mr,bn as hr,ct as gr,en as _r,gt as vr,lt as yr,ot as br,r as xr,st as Sr,tn as Cr}from"./react-query-CRJlZpE1.js";import{h as wr}from"./ChartPrimitives-CksxPvHn.js";import{t as Tr}from"./InfoTooltip-BbdxCAup.js";import{a as Er,i as Dr,n as Or,r as kr,t as Ar}from"./card-BAimTqa8.js";import{t as jr}from"./vendor-yaml-Y43rmNgW.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Mr=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&A(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&A(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var ee=new MessageChannel,k=ee.port2;ee.port1.onmessage=D,O=function(){k.postMessage(null)}}else O=function(){_(D,0)};function A(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,A(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Nr=t(((e,t)=>{t.exports=Mr()})),Pr=t((e=>{var t=Nr(),n=re(),r=me();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function x(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function S(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function C(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var w=Object.assign,T=Symbol.for(`react.element`),E=Symbol.for(`react.transitional.element`),D=Symbol.for(`react.portal`),O=Symbol.for(`react.fragment`),ee=Symbol.for(`react.strict_mode`),k=Symbol.for(`react.profiler`),A=Symbol.for(`react.consumer`),j=Symbol.for(`react.context`),te=Symbol.for(`react.forward_ref`),ne=Symbol.for(`react.suspense`),ie=Symbol.for(`react.suspense_list`),ae=Symbol.for(`react.memo`),M=Symbol.for(`react.lazy`),N=Symbol.for(`react.activity`),oe=Symbol.for(`react.legacy_hidden`),se=Symbol.for(`react.memo_cache_sentinel`),ce=Symbol.for(`react.view_transition`),le=Symbol.for(`react.recoverable`),ue=Symbol.iterator;function de(e){return typeof e!=`object`||!e?null:(e=ue&&e[ue]||e[`@@iterator`],typeof e==`function`?e:null)}var fe=Symbol.for(`react.client.reference`);function pe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===fe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case O:return`Fragment`;case k:return`Profiler`;case ee:return`StrictMode`;case ne:return`Suspense`;case ie:return`SuspenseList`;case N:return`Activity`;case ce:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case D:return`Portal`;case j:return e.displayName||`Context`;case A:return(e._context.displayName||`Context`)+`.Consumer`;case te:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ae:return t=e.displayName||null,t===null?pe(e.type)||`Memo`:t;case M:t=e._payload,e=e._init;try{return pe(e(t))}catch{}}return null}var P=Array.isArray,F=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,he={pending:!1,data:null,method:null,action:null},ge=[],_e=-1;function L(e){return{current:e}}function ve(e){0>_e||(e.current=ge[_e],ge[_e]=null,_e--)}function R(e,t){_e++,ge[_e]=e.current,e.current=t}var ye=L(null),be=L(null),xe=L(null),Se=L(null);function Ce(e,t){switch(R(xe,t),R(be,e),R(ye,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ve(ye),R(ye,e)}function z(){ve(ye),ve(be),ve(xe)}function we(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,R(Se,e)),t=ye.current;var n=dp(t,e.type);t!==n&&(R(be,e),R(ye,n))}function Te(e){be.current===e&&(ve(ye),ve(be)),Se.current===e&&(ve(Se),sh._currentValue=he)}var Ee,De;function Oe(e){if(Ee===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ee=t&&t[1]||``,De=-1<e.stack.indexOf(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SiteHealthSection-CGKKUtqQ.js","./rolldown-runtime-XKyaHtl9.js","./vendor-lucide-4KkDquAu.js","./vendor-markdown-9SSeLNHZ.js","./vendor-tanstack-pEsPGDvT.js","./vendor-recharts-qIim36Mt.js","./vendor-radix-BuErWiA2.js","./ToneBadge-CJ6ObMRe.js","./account-context-CWRd3KeS.js","./query-client-DLdAMlsX.js","./react-query-BktZZtSC.js","./ChartPrimitives-CksxPvHn.js","./InfoTooltip-BbdxCAup.js","./card-Cb_fM36G.js","./ProjectPage-D4n2oqPP.js","./format-helpers-CxNDa1oa.js","./async-handler-Bj3TnIRw.js","./Hint-C0TmIzHX.js","./AuditHistoryPanel-qhIB8KRK.js","./service-Dv9FDyFY.js","./extract-error-message-DSIAoHTR.js","./RunsPage-Cc98Px3T.js","./HistoryPage-BP1_GGlT.js","./SettingsPage-CMyCE-H2.js","./AgentSetupPage-DPHRo4OR.js","./BacklinksPage-iWrZ0-Pp.js","./TrafficPage-DAef3d2A.js","./TrafficSourceDetailPage-CdoL5Dt9.js","./MeasurementPropertyPage-DfPHZNGo.js"])))=>i.map(i=>d[i]);
2
+ import{r as e,t}from"./rolldown-runtime-XKyaHtl9.js";import{$ as n,A as r,D as i,F as a,G as o,I as s,J as c,K as l,M as u,N as d,O as f,P as p,Q as m,R as h,S as g,T as _,U as v,X as y,Z as b,_ as x,b as S,c as C,et as w,f as T,g as E,h as D,j as O,k as ee,l as k,n as A,o as j,p as te,q as ne,rt as re,t as ie,w as ae,x as M,y as N,z as oe}from"./vendor-lucide-4KkDquAu.js";import{a as se,c as ce,i as le,n as ue,o as de,r as fe,s as pe,t as P,u as me}from"./vendor-radix-BuErWiA2.js";import{n as F,r as I,t as he}from"./vendor-markdown-9SSeLNHZ.js";import{E as ge,T as _e,_ as L,a as ve,b as R,c as ye,d as be,f as xe,h as Se,i as Ce,l as z,m as we,n as Te,o as Ee,r as De,s as Oe,u as B,x as ke}from"./vendor-tanstack-pEsPGDvT.js";import{$ as Ae,$r as je,$t as Me,Ai as Ne,An as Pe,Bn as Fe,Ci as Ie,Cn as Le,Cr as Re,Ct as ze,D as Be,Di as Ve,Dt as He,E as Ue,Ei as We,En as Ge,Fn as Ke,Hr as qe,In as Je,J as Ye,Jt as Xe,K as Ze,Kt as Qe,Ln as $e,Mi as et,Mn as tt,Mr as nt,Ni as rt,Nn as it,Nr as at,Oi as ot,Ot as st,Pi as ct,Pn as lt,Q as ut,Qt as dt,Rn as ft,Rr as pt,Si as mt,Sn as ht,Sr as gt,St as _t,T as vt,Tn as yt,Tt as bt,W as xt,Wt as St,X as Ct,Xr as wt,Xt as Tt,Y as Et,Yn as Dt,Yt as Ot,Z as kt,Zr as At,Zt as jt,_i as Mt,_n as Nt,a as Pt,ar as Ft,at as It,bi as Lt,bn as Rt,bt as zt,cn as Bt,d as Vt,dt as Ht,ei as V,en as Ut,et as Wt,ft as Gt,gi as Kt,gn as qt,hi as Jt,i as Yt,ii as Xt,it as Zt,j as Qt,ji as $t,jn as en,jr as tn,jt as nn,ki as rn,kn as an,kt as on,li as sn,mi as cn,n as ln,ni as H,nn as un,nt as dn,os as fn,ot as pn,pn as mn,pt as U,qt as hn,r as W,ri as gn,rn as _n,rt as vn,sn as yn,st as bn,t as xn,ti as G,tt as Sn,u as Cn,un as wn,v as Tn,vn as En,w as Dn,wi as On,wn as kn,wr as An,wt as jn,xn as Mn,xr as Nn,xt as Pn,yn as Fn,yt as In,z as Ln,zn as Rn,zt as zn}from"./ToneBadge-CJ6ObMRe.js";import{d as Bn,f as Vn,l as Hn,s as Un,u as Wn,v as Gn,y as Kn}from"./format-helpers-CxNDa1oa.js";import{n as qn,r as Jn,t as Yn}from"./account-context-CWRd3KeS.js";import{t as Xn}from"./async-handler-Bj3TnIRw.js";import{a as Zn,c as Qn,d as $n,f as er,i as tr,l as nr,m as rr,o as ir,p as ar,r as or}from"./query-client-DLdAMlsX.js";import{$t as sr,Jt as cr,Qt as lr,Xt as ur,Yt as dr,Zt as fr,_t as pr,a as mr,bn as hr,ct as gr,en as _r,gt as vr,lt as yr,ot as br,r as xr,st as Sr,tn as Cr}from"./react-query-BktZZtSC.js";import{h as wr}from"./ChartPrimitives-CksxPvHn.js";import{t as Tr}from"./InfoTooltip-BbdxCAup.js";import{a as Er,i as Dr,n as Or,r as kr,t as Ar}from"./card-Cb_fM36G.js";import{t as jr}from"./vendor-yaml-Y43rmNgW.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Mr=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&A(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&A(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var ee=new MessageChannel,k=ee.port2;ee.port1.onmessage=D,O=function(){k.postMessage(null)}}else O=function(){_(D,0)};function A(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,A(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Nr=t(((e,t)=>{t.exports=Mr()})),Pr=t((e=>{var t=Nr(),n=re(),r=me();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function x(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function S(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function C(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var w=Object.assign,T=Symbol.for(`react.element`),E=Symbol.for(`react.transitional.element`),D=Symbol.for(`react.portal`),O=Symbol.for(`react.fragment`),ee=Symbol.for(`react.strict_mode`),k=Symbol.for(`react.profiler`),A=Symbol.for(`react.consumer`),j=Symbol.for(`react.context`),te=Symbol.for(`react.forward_ref`),ne=Symbol.for(`react.suspense`),ie=Symbol.for(`react.suspense_list`),ae=Symbol.for(`react.memo`),M=Symbol.for(`react.lazy`),N=Symbol.for(`react.activity`),oe=Symbol.for(`react.legacy_hidden`),se=Symbol.for(`react.memo_cache_sentinel`),ce=Symbol.for(`react.view_transition`),le=Symbol.for(`react.recoverable`),ue=Symbol.iterator;function de(e){return typeof e!=`object`||!e?null:(e=ue&&e[ue]||e[`@@iterator`],typeof e==`function`?e:null)}var fe=Symbol.for(`react.client.reference`);function pe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===fe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case O:return`Fragment`;case k:return`Profiler`;case ee:return`StrictMode`;case ne:return`Suspense`;case ie:return`SuspenseList`;case N:return`Activity`;case ce:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case D:return`Portal`;case j:return e.displayName||`Context`;case A:return(e._context.displayName||`Context`)+`.Consumer`;case te:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ae:return t=e.displayName||null,t===null?pe(e.type)||`Memo`:t;case M:t=e._payload,e=e._init;try{return pe(e(t))}catch{}}return null}var P=Array.isArray,F=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,he={pending:!1,data:null,method:null,action:null},ge=[],_e=-1;function L(e){return{current:e}}function ve(e){0>_e||(e.current=ge[_e],ge[_e]=null,_e--)}function R(e,t){_e++,ge[_e]=e.current,e.current=t}var ye=L(null),be=L(null),xe=L(null),Se=L(null);function Ce(e,t){switch(R(xe,t),R(be,e),R(ye,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ve(ye),R(ye,e)}function z(){ve(ye),ve(be),ve(xe)}function we(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,R(Se,e)),t=ye.current;var n=dp(t,e.type);t!==n&&(R(be,e),R(ye,n))}function Te(e){be.current===e&&(ve(ye),ve(be)),Se.current===e&&(ve(Se),sh._currentValue=he)}var Ee,De;function Oe(e){if(Ee===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ee=t&&t[1]||``,De=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+Ee+e+De}var B=!1;function ke(e,t){if(!e||B)return``;B=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
5
5
  `),l=s.split(`
@@ -10,12 +10,12 @@ Error generating stack: `+e.message+`
10
10
  `).replace(Zf,``)}function $f(e,t){return t=Qf(t),Qf(e)===t}function ep(e,t,n,r,a,o){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||sn(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&sn(e,``+r);else return;break;case`className`:Gt(e,`class`,r);break;case`tabIndex`:Gt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Gt(e,n,r);break;case`style`:H(e,r,o);return;case`data`:if(t!==`object`){Gt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=pn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&ep(e,t,`name`,a.name,a,null),ep(e,t,`formEncType`,a.formEncType,a,null),ep(e,t,`formMethod`,a.formMethod,a,null),ep(e,t,`formTarget`,a.formTarget,a,null)):(ep(e,t,`encType`,a.encType,a,null),ep(e,t,`method`,a.method,a,null),ep(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=pn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=mn);return;case`onScroll`:r!=null&&$(`scroll`,e);return;case`onScrollEnd`:r!=null&&$(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=pn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:$(`beforetoggle`,e),$(`toggle`,e),Wt(e,`popover`,r);break;case`xlinkActuate`:Kt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Kt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Kt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Kt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Kt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Kt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Kt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Kt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Kt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Wt(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=dn.get(n)||n,Wt(e,n,r);else return}V=!0}function tp(e,t,n,r,a,o){switch(n){case`style`:H(e,r,o);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)sn(e,r);else if(typeof r==`number`||typeof r==`bigint`)sn(e,``+r);else return;break;case`onScroll`:r!=null&&$(`scroll`,e);return;case`onScrollEnd`:r!=null&&$(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=mn);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!It.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),o=n.slice(2,a?n.length-7:void 0),t=e[bt]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(o,t,a),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(o,r,a);break a}V=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):Wt(e,n,r)}return}V=!0}function np(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:$(`error`,e),$(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:ep(e,t,o,s,n,null)}}a&&ep(e,t,`srcSet`,n.srcSet,n,null),r&&ep(e,t,`src`,n.src,n,null);return;case`input`:$(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:ep(e,t,r,d,n,null)}}tn(e,o,c,l,u,s,a,!1);return;case`select`:for(a in $(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:ep(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&rn(e,!!r,n,!0):rn(e,!!r,t,!1);return;case`textarea`:for(s in $(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:ep(e,t,s,c,n,null)}on(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:ep(e,t,l,r,n,null)}return;case`dialog`:$(`beforetoggle`,e),$(`toggle`,e),$(`cancel`,e),$(`close`,e);break;case`iframe`:case`object`:$(`load`,e);break;case`video`:case`audio`:for(r=0;r<Rf.length;r++)$(Rf[r],e);break;case`image`:$(`error`,e),$(`load`,e);break;case`details`:$(`toggle`,e);break;case`embed`:case`source`:case`link`:$(`error`,e),$(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:ep(e,t,u,r,n,null)}return;default:if(un(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&tp(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&ep(e,t,c,r,n,null))}var rp={};function ip(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||ep(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(V=!0),o=m;break;case`name`:m!==f&&(V=!0),a=m;break;case`checked`:m!==f&&(V=!0),u=m;break;case`defaultChecked`:m!==f&&(V=!0),d=m;break;case`value`:m!==f&&(V=!0),s=m;break;case`defaultValue`:m!==f&&(V=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&ep(e,t,p,m,r,f)}}en(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||ep(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:o!==l&&(V=!0),p=o;break;case`defaultValue`:o!==l&&(V=!0),c=o;break;case`multiple`:o!==l&&(V=!0),s=o;default:o!==l&&ep(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?rn(e,!!n,n?[]:``,!1):rn(e,!!n,t,!0)):rn(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:ep(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:a!==o&&(V=!0),p=a;break;case`defaultValue`:a!==o&&(V=!0),m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&ep(e,t,s,a,r,o)}an(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:ep(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(V=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:ep(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&ep(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:ep(e,t,u,p,r,m)}return;default:if(un(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&tp(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||tp(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&ep(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||ep(e,t,f,p,r,m)}function ap(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function op(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&ap(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&ap(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var sp=null,cp=null;function lp(e){return e.nodeType===9?e:e.ownerDocument}function up(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function dp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function fp(e,t,n,r){return n=lp(n).createElement(e),n[yt]=r,n[bt]=t,np(n,e,t),Nt(n),n}function pp(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var mp=null;function hp(){var e=window.event;return e&&e.type===`popstate`?e!==mp&&(mp=e,!0):(mp=null,!1)}var gp=typeof setTimeout==`function`?setTimeout:void 0,_p=typeof clearTimeout==`function`?clearTimeout:void 0,vp=typeof Promise==`function`?Promise:void 0,yp=typeof requestAnimationFrame==`function`?requestAnimationFrame:gp,bp=typeof queueMicrotask==`function`?queueMicrotask:vp===void 0?gp:function(e){return vp.resolve(null).then(e).catch(xp)};function xp(e){setTimeout(function(){throw e})}function Sp(e){return e===`head`}function Cp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Hh(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)_m(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,_m(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[Et]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&_m(e.ownerDocument.body)}n=i}while(n);Hh(t)}function wp(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function Tp(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Ep(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function Dp(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function Op(e){return Dp(e.getBoundingClientRect(),getComputedStyle(e),e)}function kp(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return Dp(t,n,e)}function Ap(e){return e.documentElement.clientHeight}function jp(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Mp(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(Ap(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=Xm(f),u>$m){s.length=o;break}f=new Promise(jp.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Np(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Np.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:w({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Np.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Np.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Pp(e){return{name:e,group:new Np(`group`,e),imagePair:new Np(`image-pair`,e),old:new Np(`old`,e),new:new Np(`new`,e)}}function Fp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Fp.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(Bp(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=Rp(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),f(this._fragmentFiber.child,!1,Ip,e,s,r)}this._eventListeners=a}};function Ip(e,t,n,r){return _(e).addEventListener(t,n,r),!1}Fp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Bp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=Rp(i.optionsOrUseCapture),f(this._fragmentFiber.child,!1,Lp,e,n,i),r.splice(t,1),a!==null&&a()}};function Lp(e,t,n,r){return _(e).removeEventListener(t,n,r),!1}function Rp(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function zp(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Bp(e,t,n,r){if(e.length===0)return-1;r=zp(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&zp(a.optionsOrUseCapture)===r)return i}return-1}Fp.prototype.dispatchEvent=function(e){var t=p(this._fragmentFiber);if(t===null)return!0;t=_(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,Rp(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,Rp(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Fp.prototype.focus=function(e){f(this._fragmentFiber.child,!0,Vp,e,void 0,void 0)};function Vp(e,t){return e.tag!==6&&(e=_(e),pm(e,t))}Fp.prototype.focusLast=function(e){var t=[];f(this._fragmentFiber.child,!0,Hp,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Vp(t[n],e);n--);};function Hp(e,t){return t.push(e),!1}Fp.prototype.blur=function(){var e=p(this._fragmentFiber);e!==null&&(e=_(e),e=lp(e).activeElement,e!==null&&f(this._fragmentFiber.child,!1,Up,e,void 0,void 0))};function Up(e,t){return e.tag!==6&&(e=_(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Fp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),f(this._fragmentFiber.child,!1,Wp,e,void 0,void 0)};function Wp(e,t){return e.tag===6||(e=_(e),t.observe(e)),!1}Fp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),f(this._fragmentFiber.child,!1,Gp,e,void 0,void 0);for(var n=t=0;n<Kp.length;n++){var r=Kp[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):Kp[t++]=r}Kp.length=t}};function Gp(e,t){return e.tag===6||(e=_(e),t.unobserve(e)),!1}var Kp=[],qp=!1;function Jp(e,t,n){Kp.push({fragmentInstance:e,observer:t,instance:n}),qp||(qp=!0,mm(function(){qp=!1;var e=Kp;Kp=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Fp.prototype.getClientRects=function(){var e=[];return f(this._fragmentFiber.child,!1,Yp,e,void 0,void 0),e};function Yp(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=_(e),t.push.apply(t,e.getClientRects());return!1}Fp.prototype.getRootNode=function(e){var t=p(this._fragmentFiber);return t===null?this:_(t).getRootNode(e)},Fp.prototype.compareDocumentPosition=function(e){var t=p(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];f(this._fragmentFiber.child,!1,Hp,n,void 0,void 0);var r=_(t);if(n.length===0){if(n=r,m(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=h(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=_(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=_(n[0]),i=_(n[n.length-1]);var a=m(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||Xp(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function Xp(e,t,n,r,i){var a=kt(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=p(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=C(n,a,S),t===null?t=!1:(f(t,!0,b,a,n),a=v,v=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=C(r,a,S),t===null?t=!1:(f(t,!0,x,a,r),a=v,y=v=null,t=a!==null)),t):!1}function Zp(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Fp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(i(566));var t=[];f(this._fragmentFiber.child,!1,Hp,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=h(this._fragmentFiber);if(r=n?r[1]||r[0]||p(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=_(r),Zp(e,n);return}if(r=_(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var a=t[r];a.tag===6?(a=_(a),Zp(a,n)):_(a).scrollIntoView(e),r+=n?-1:1}};function Qp(e,t){return e=_(e),$p(e,t),!1}function $p(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function em(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,Rp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<Kp.length;i++){var a=Kp[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(Kp[r++]=a)}Kp.length=r,n.observe(e)}),$p(e,t))}function tm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,Rp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?Jp(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function nm(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:nm(n),Ot(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function rm(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[Et])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=lm(e.nextSibling),e===null)break}return null}function im(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=lm(e.nextSibling),e===null))return null;return e}function am(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=lm(e.nextSibling),e===null))return null;return e}function om(e){return e.data===`$?`||e.data===`$~`}function sm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function cm(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function lm(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var um=null;function dm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return lm(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function fm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function pm(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function mm(e){yp(function(){yp(function(t){return e(t)})})}function hm(e,t,n){switch(t=lp(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function gm(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&ep(e,t,r,null,rp,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===mn&&(e.onclick=null),Ot(e)}function _m(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Ot(e)}var vm=new Map,ym=new Set;function bm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var xm=I.d;I.d={f:Sm,r:Cm,D:Em,C:Dm,L:Om,m:km,X:jm,S:Am,M:Mm};function Sm(){var e=xm.f(),t=Ld();return e||t}function Cm(e){var t=At(e);t!==null&&t.tag===5&&t.type===`form`?Ys(t):xm.r(e)}var wm=typeof document>`u`?null:document;function Tm(e,t,n){var r=wm;if(r&&typeof t==`string`&&t){var i=$t(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),ym.has(i)||(ym.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),np(t,`link`,e),Nt(t),r.head.appendChild(t)))}}function Em(e){xm.D(e),Tm(`dns-prefetch`,e,null)}function Dm(e,t){xm.C(e,t),Tm(`preconnect`,e,t)}function Om(e,t,n){xm.L(e,t,n);var r=wm;if(r&&e&&t){var i=`link[rel="preload"][as="`+$t(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+$t(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+$t(n.imageSizes)+`"]`)):i+=`[href="`+$t(e)+`"]`;var a=i;switch(t){case`style`:a=Pm(e);break;case`script`:a=Rm(e)}if(!(vm.has(a)||(e=w({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Fm(a))||t===`script`&&r.querySelector(zm(a))))){var o=r.createElement(`link`);np(o,`link`,e),t===`style`&&(o[Dt]=!0,o.onload=o.onerror=function(){Pt(o)}),Nt(o),r.head.appendChild(o)}}}function km(e,t){xm.m(e,t);var n=wm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+$t(r)+`"][href="`+$t(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rm(e)}if(!vm.has(a)&&(e=w({rel:`modulepreload`,href:e},t),vm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zm(a)))return}r=n.createElement(`link`),np(r,`link`,e),Nt(r),n.head.appendChild(r)}}}function Am(e,t,n){xm.S(e,t,n);var r=wm;if(r&&e){var i=Mt(r).hoistableStyles,a=Pm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Fm(a)))s.loading=5;else{e=w({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vm.get(a))&&Hm(e,n);var c=o=r.createElement(`link`);Nt(c),np(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jm(e,t){xm.X(e,t);var n=wm;if(n&&e){var r=Mt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=w({src:e,async:!0},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Nt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mm(e,t){xm.M(e,t);var n=wm;if(n&&e){var r=Mt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=w({src:e,async:!0,type:`module`},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Nt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t,n,r){var a=(a=xe.current)?bm(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Pm(n.href),t=Mt(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pm(n.href);var o=Mt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Fm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=vm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vm.set(e,o)),Lm(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Rm(n),t=Mt(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Pm(e){return`href="`+$t(e)+`"`}function Fm(e){return`link[rel="stylesheet"][`+e+`]`}function Im(e){return w({},e,{"data-precedence":e.precedence,precedence:null})}function Lm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Dt]){r.loading=1;return}}else t=e.createElement(`link`),t[Dt]=!0,t.onload=t.onerror=Pt.bind(null,t),np(t,`link`,n),Nt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Rm(e){return`[src="`+$t(e)+`"]`}function zm(e){return`script[async]`+e}function Bm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+$t(n.href)+`"]`);if(r)return t.instance=r,Nt(r),r;var a=w({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Nt(r),np(r,`style`,a),Vm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Pm(n.href);var o=e.querySelector(Fm(a));if(o)return t.state.loading|=4,t.instance=o,Nt(o),o;r=Im(n),(a=vm.get(a))&&Hm(r,a),o=(e.ownerDocument||e).createElement(`link`),Nt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),np(o,`link`,r),t.state.loading|=4,Vm(o,n.precedence,e),t.instance=o;case`script`:return o=Rm(n.src),(a=e.querySelector(zm(o)))?(t.instance=a,Nt(a),a):(r=n,(a=vm.get(o))&&(r=w({},n),Um(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Nt(a),np(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vm(r,n.precedence,e));return t.instance}function Vm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Hm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Um(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Wm=null;function Gm(e,t,n){if(Wm===null){var r=new Map,i=Wm=new Map;i.set(n,r)}else i=Wm,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[Et]||a[yt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Km(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function qm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Ym(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Xm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Zm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Xm(t),e.suspenseyImages.push(t)),e=rh.bind(e),t.decode().then(e,e))}function Qm(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pm(r.href),a=t.querySelector(Fm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Nt(a);return}a=t.ownerDocument||t,r=Im(r),(i=vm.get(i))&&Hm(r,i),a=a.createElement(`link`),Nt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=nh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $m=0;function eh(e,t){return e.stylesheets&&e.count===0&&ah(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&ah(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&$m===0&&($m=62500*op());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&ah(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>$m?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function th(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)ah(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function nh(){this.count--,th(this)}function rh(){this.imgCount--,th(this)}var ih=null;function ah(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ih=new Map,t.forEach(oh,e),ih=null,nh.call(e))}function oh(e,t){if(!(t.state.loading&4)){var n=ih.get(e);if(n)var r=n.get(null);else{n=new Map,ih.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=nh.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var sh={$$typeof:j,Provider:null,Consumer:null,_currentValue:he,_currentValue2:he,_threadCount:0};function ch(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ct(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ct(0),this.hiddenUpdates=ct(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function lh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new ch(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=wi(3,null,null,t),e.current=a,a.stateNode=e,t=Ca(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},ao(a),e}function uh(e){return e?(e=Si,e):Si}function dh(e,t,n,r,i,a){i=uh(i),r.context===null?r.context=i:r.pendingContext=i,r=so(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=co(e,r,t),n!==null&&(Md(n,e,t),lo(n,e,t))}function fh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ph(e,t){fh(e,t),(e=e.alternate)&&fh(e,t)}function mh(e){if(e.tag===13||e.tag===31){var t=yi(e,67108864);t!==null&&Md(t,e,67108864),ph(e,67108864)}}function hh(e){if(e.tag===13||e.tag===31){var t=kd();t=mt(t);var n=yi(e,t);n!==null&&Md(n,e,t),ph(e,t)}}var gh=!0;function _h(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=2,yh(e,t,n,r)}finally{I.p=a,F.T=i}}function vh(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=8,yh(e,t,n,r)}finally{I.p=a,F.T=i}}function yh(e,t,n,r){if(gh){var i=bh(r);if(i===null)Gf(e,t,r,xh,n),Mh(e,r);else if(Ph(i,e,t,n,r))r.stopPropagation();else if(Mh(e,r),t&4&&-1<jh.indexOf(e)){for(;i!==null;){var a=At(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=nt(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Ye(o);s.entanglements[1]|=c,o&=~c}Tf(a),!(Ju&6)&&(md=Le()+500,Ef(0,!1))}}break;case 31:case 13:s=yi(a,2),s!==null&&Md(s,a,2),Ld(),ph(a,2)}if(a=bh(r),a===null&&Gf(e,t,r,xh,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Gf(e,t,r,null,n)}}function bh(e){return e=hn(e),Sh(e)}var xh=null;function Sh(e){if(xh=null,e=kt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return xh=e,null}function Ch(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`fullscreenerror`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Re()){case ze:return 2;case Be:return 8;case Ve:case He:return 32;case Ue:return 268435456;default:return 32}default:return 32}}var wh=!1,Th=null,Eh=null,Dh=null,Oh=new Map,kh=new Map,Ah=[],jh=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Mh(e,t){switch(e){case`focusin`:case`focusout`:Th=null;break;case`dragenter`:case`dragleave`:Eh=null;break;case`mouseover`:case`mouseout`:Dh=null;break;case`pointerover`:case`pointerout`:Oh.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:kh.delete(t.pointerId)}}function Nh(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=At(t),t!==null&&mh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ph(e,t,n,r,i){switch(t){case`focusin`:return Th=Nh(Th,e,t,n,r,i),!0;case`dragenter`:return Eh=Nh(Eh,e,t,n,r,i),!0;case`mouseover`:return Dh=Nh(Dh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Oh.set(a,Nh(Oh.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,kh.set(a,Nh(kh.get(a)||null,e,t,n,r,i)),!0}return!1}function Fh(e){var t=kt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,_t(e.priority,function(){hh(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,_t(e.priority,function(){hh(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ih(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=bh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);U=r,n.target.dispatchEvent(r),U=null}else return t=At(n),t!==null&&mh(t),e.blockedOn=n,!1;t.shift()}return!0}function Lh(e,t,n){Ih(e)&&n.delete(t)}function Rh(){wh=!1,Th!==null&&Ih(Th)&&(Th=null),Eh!==null&&Ih(Eh)&&(Eh=null),Dh!==null&&Ih(Dh)&&(Dh=null),Oh.forEach(Lh),kh.forEach(Lh)}function zh(e,n){e.blockedOn===n&&(e.blockedOn=null,wh||(wh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Rh)))}var Bh=null;function Vh(e){Bh!==e&&(Bh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Bh===e&&(Bh=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Sh(r||n)===null)continue;break}var a=At(n);a!==null&&(e.splice(t,3),t-=3,qs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Hh(e){function t(t){return zh(t,e)}Th!==null&&zh(Th,e),Eh!==null&&zh(Eh,e),Dh!==null&&zh(Dh,e),Oh.forEach(t),kh.forEach(t);for(var n=0;n<Ah.length;n++){var r=Ah[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Ah.length&&(n=Ah[0],n.blockedOn===null);)Fh(n),n.blockedOn===null&&Ah.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[bt]||null;if(typeof a==`function`)o||Vh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[bt]||null)s=o.formAction;else if(Sh(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Vh(n)}}}function Uh(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Wh(e){this._internalRoot=e}Gh.prototype.render=Wh.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;dh(n,kd(),e,t,null,null)},Gh.prototype.unmount=Wh.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;dh(e.current,2,null,e,null,null),Ld(),t[xt]=null}};function Gh(e){this._internalRoot=e}Gh.prototype.unstable_scheduleHydration=function(e){if(e){var t=gt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ah.length&&t!==0&&t<Ah[n].priority;n++);Ah.splice(n,0,e),n===0&&Fh(e)}};var Kh=n.version;if(Kh!==`19.3.1`)throw Error(i(527,Kh,`19.3.1`));I.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var qh={bundleType:0,version:`19.3.1`,rendererPackageName:`react-dom`,currentDispatcherRef:F,reconcilerVersion:`19.3.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Jh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Jh.isDisabled&&Jh.supportsFiber)try{Ke=Jh.inject(qh),qe=Jh}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=gc,s=_c,c=vc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=lh(e,1,!1,null,null,n,r,null,o,s,c,Uh),e[xt]=t.current,Uf(e),new Wh(t)}})),Fr=t(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Pr()})),K=e(re(),1),Ir=Fr();function Lr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Rr(e){if(e?.some(e=>e.trim().toLowerCase()===`report`))return`The report embed tab has been retired. Remove report from the allowed tabs; explicitly configure overview to display AI Visibility.`}function zr(e){return e.length<4}function Br(e){return e!==``&&/^[\w./:@%+=,-]+$/.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`}var q=I(),Vr=(0,K.createContext)({view:null,publish:()=>()=>{}});function Hr({children:e}){let[t,n]=(0,K.useState)(null),r=(0,K.useCallback)(e=>(n(e),()=>n(t=>t===e?null:t)),[]);return(0,q.jsx)(Vr.Provider,{value:(0,K.useMemo)(()=>({view:t,publish:r}),[t,r]),children:e})}function Ur(e,t){let{publish:n}=(0,K.useContext)(Vr),r=JSON.stringify(t);(0,K.useEffect)(()=>n({project:e,context:JSON.parse(r)}),[n,e,r])}function Wr(e,t){let{view:n}=(0,K.useContext)(Vr);return n?.project===e&&n.context.view===t.view?n.context:t}function Gr(e){let t=e.replace(/\/+$/,``)||`/`;return t===`/`?`overview`:t===`/projects`?`projects`:t.startsWith(`/projects/`)?`project`:t===`/runs`?`runs`:t===`/traffic`||t.startsWith(`/traffic/`)?`traffic`:t===`/backlinks`?`backlinks`:t===`/settings`?`settings`:t===`/setup`?`setup`:`other`}function Kr(e,t){return!t||t.includes(e)}var qr=[`overview`,`search-console`,`seo-data`,`local`,`activity`,`backlinks`,`technical-aeo`,`history`,`settings`],Jr=new Set(qr);function Yr(e){if(Rr(e))return[];let t=[...new Set((e??qr).filter(e=>Jr.has(e)))];return t.length>0?t:[`overview`]}function Xr(e){return e?Yr(e.projectTabs):void 0}function Zr(e,t){return Kr(e,t)||!t?e:t.includes(`overview`)?`overview`:t[0]??`overview`}var Qr={bg:`--canonry-embed-bg`,fg:`--canonry-embed-fg`,accent:`--color-link`},$r=/^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([0-9.,%\s/]+\)|hsla?\([0-9.,%\s/a-z]+\))$/i;function ei(e){let t=e?.mode?.trim();return t===`light`||t===`dark`?t:void 0}function ti(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e)){let e=Object.hasOwn(Qr,n)?Qr[n]:void 0;if(!e||typeof r!=`string`)continue;let i=r.trim();$r.test(i)&&(t[e]=i)}return t}function ni(e){return e.state===`ok`?`positive`:e.state===`checking`||e.state===`disabled`?`neutral`:`negative`}function ri(e){switch(e){case`completed`:return`positive`;case`partial`:return`caution`;case`failed`:return`negative`;case`cancelled`:return`caution`;case`queued`:case`running`:return`neutral`;default:return`neutral`}}function ii(e){switch(e){case`cited`:return`positive`;case`emerging`:return`caution`;case`not-cited`:return`caution`;case`lost`:return`negative`;case`pending`:return`neutral`;default:return`neutral`}}var ai={positive:`text-positive-400`,caution:`text-caution-400`,negative:`text-negative-400`,neutral:`text-secondary`};function oi(e){return e>=50?`positive`:e>=25?`caution`:`negative`}function si(e){return e.state===`ready`&&An(e)}function ci(e){return e.displayName??e.name.charAt(0).toUpperCase()+e.name.slice(1)}function li(e){let t=[e.detail,e.hint].filter(Boolean);return t.length>0?t.join(`
11
11
  `):void 0}function ui(e,t,n){let r=e.filter(e=>e.id!==`mcp`).map(e=>{if(e.id===`api`)return{...e,tone:ni(t.apiStatus),detail:t.apiStatus.state===`ok`?`Healthy`:`Needs attention`,meta:t.apiStatus.detail};if(e.id===`worker`)return{...e,tone:ni(t.workerStatus),detail:t.workerStatus.state===`ok`?`Healthy`:t.workerStatus.state===`disabled`?`Disabled`:`Needs attention`,meta:t.workerStatus.detail};let r=n.providerStatuses.filter(e=>e.state===`ready`).length,i=n.providerStatuses.length,a=n.providerStatuses.some(si),o=n.providerStatuses.filter(e=>e.state===`ready`).map(e=>ci(e)).join(` · `);return{...e,label:`Providers`,tone:a?`positive`:`caution`,detail:`${r} of ${i} configured`,meta:o||`None configured`}}),i=t.apiStatus.mcp,a={id:`mcp`,label:`MCP`,tone:`neutral`,detail:`Unknown`,meta:`MCP status is not available from this server.`};return t.apiStatus.state===`checking`?(a.detail=`Checking`,a.meta=`Checking MCP availability.`):t.apiStatus.state===`ok`&&i&&(i.status===`available`?(a.tone=`positive`,a.detail=`Available`,a.meta=`MCP is available for agent connections. This checks the server transport, not an individual client connection.`):i.status===`unavailable`?(a.tone=`negative`,a.detail=`Unavailable`,a.meta=`The MCP transport is not fully available. Contact your Canonry team.`):(a.detail=`Not enabled`,a.meta=`This server does not provide an MCP endpoint.`)),r.splice(Math.max(0,r.findIndex(e=>e.id===`api`)+1),0,a),r}function di(e,t){if(e.apiStatus.state!==`ok`)return`Launch is blocked until the API responds cleanly.`;if(e.apiStatus.databaseConfigured===!1)return`Launch is blocked until the API has a database connection configured.`;if(e.workerStatus.state!==`ok`)return`Launch is blocked until the worker is healthy and heartbeats are current.`;if(!t.providerStatuses.some(si))return`Launch is blocked until at least one provider is configured.`}function fi(e,t,n){let r=di(t,n),i=structuredClone(e);return i.healthChecks=i.healthChecks.map(e=>{if(e.id===`api`)return{...e,detail:t.apiStatus.detail,state:t.apiStatus.state===`ok`?`ready`:`attention`};if(e.id===`worker`)return{...e,detail:t.workerStatus.detail,state:t.workerStatus.state===`ok`?`ready`:`attention`};let r=n.providerStatuses.some(si);return{...e,detail:r?`At least one provider configured.`:`No providers configured.`,state:r?`ready`:`attention`}}),i.launchState.enabled=r===void 0,i.launchState.blockedReason=r,i.launchState.summary=r??`Queue an AI Visibility check first, then follow with a Technical AEO audit to explain movement.`,i}var pi=`canonry.run-tracker`,mi=new Set,hi=!1,gi=0,_i={runs:{},batches:{}};function vi(){let e=Ci();for(let t of mi)t(e)}function yi(e){if(!e)return{runs:{},batches:{}};try{let t=JSON.parse(e);return{runs:t.runs??{},batches:t.batches??{}}}catch{return{runs:{},batches:{}}}}function bi(){typeof window<`u`&&window.sessionStorage.setItem(pi,JSON.stringify(_i))}function xi(){hi||(hi=!0,typeof window<`u`&&(_i=yi(window.sessionStorage.getItem(pi))))}function Si(e){_i=e,bi(),vi()}function Ci(){return xi(),_i}function wi(e){return xi(),mi.add(e),()=>{mi.delete(e)}}function Ti(e){let t=Ci();Si({...t,runs:{...t.runs,[e.id]:{runId:e.id,projectId:e.projectId,projectLabel:e.projectLabel,kind:e.kind,sourceAction:e.sourceAction,lastAnnouncedStatus:e.lastAnnouncedStatus??`queued`,trackedAt:e.trackedAt??Date.now()}}})}function Ei(e){let t=Ci();if(!t.runs[e])return;let{[e]:n,...r}=t.runs;Si({...t,runs:r})}function Di(e){let t=Ci(),n=`batch_${Date.now()}_${++gi}`;return Si({...t,batches:{...t.batches,[n]:{batchId:n,runIds:e.runIds,queuedCount:e.queuedCount,skippedCount:e.skippedCount}}}),n}function Oi(e){let t=Ci();if(!t.batches[e])return;let{[e]:n,...r}=t.batches;Si({...t,batches:r})}function ki(e){return e===`completed`||e===`partial`||e===`failed`||e===`cancelled`}var Ai=6e5;function ji(e,t,n,r){return e.filter(e=>!t.has(e.runId)&&n-(e.trackedAt??0)>=r)}function Mi(e,t){let n=0,r=0,i=0,a=0,o=0;for(let s of e){let e=t[s]?.status;e===`completed`?n+=1:e===`partial`?r+=1:e===`failed`?i+=1:e===`cancelled`?a+=1:o+=1}return{completed:n,partial:r,failed:i,cancelled:a,pending:o,finished:o===0}}var Ni=220;function Pi({compact:e=!1,version:t,updateAvailable:n,onDismissUpdate:r}){let i=!e&&t&&t!==`unknown`,[a,o]=(0,K.useState)(!1),s=!e&&n&&r;return e?(0,q.jsxs)(B,{to:`/`,className:`brand-lockup brand-lockup-compact`,"aria-label":`Canonry home`,children:[(0,q.jsx)(`img`,{className:`brand-icon`,src:`./favicon.svg`,alt:``,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`brand-copy`,children:(0,q.jsx)(`span`,{className:`brand-mark`,children:`Canonry`})})]}):(0,q.jsxs)(`div`,{className:`brand-lockup brand-lockup-wrapper`,children:[(0,q.jsx)(B,{to:`/`,className:`brand-icon-link`,"aria-label":`Canonry home`,tabIndex:-1,children:(0,q.jsx)(`img`,{className:`brand-icon`,src:`./favicon.svg`,alt:``,"aria-hidden":`true`})}),(0,q.jsxs)(`div`,{className:`brand-copy`,children:[(0,q.jsx)(B,{to:`/`,className:`brand-mark`,children:`Canonry`}),!s&&i?(0,q.jsxs)(`span`,{className:`brand-version`,children:[`v`,t]}):null]}),s?(0,q.jsxs)(`span`,{className:`brand-update-bubble ${a?`brand-update-bubble-closing`:``}`,role:`status`,"aria-live":`polite`,children:[(0,q.jsxs)(`a`,{className:`brand-update-bubble-link`,href:n.url,target:`_blank`,rel:`noopener noreferrer`,title:`Open release: ${n.upgradeCommand}`,"aria-label":`New version v${n.latest} available — open release page`,children:[(0,q.jsxs)(`span`,{className:`brand-update-bubble-from`,children:[`v`,n.current]}),(0,q.jsx)(w,{className:`brand-update-bubble-arrow size-3`,"aria-hidden":`true`}),(0,q.jsxs)(`span`,{className:`brand-update-bubble-to`,children:[`v`,n.latest]})]}),(0,q.jsx)(`button`,{type:`button`,className:`brand-update-bubble-dismiss`,onClick:()=>{o(!0),window.setTimeout(()=>{r?.(),o(!1)},Ni)},"aria-label":`Dismiss update notification for v${n.latest}`,children:(0,q.jsx)(ie,{className:`size-3`,"aria-hidden":`true`})})]}):null]})}var Fi=`__cited__`,Ii=`__mentioned__`,Li=`__mentionShare__`;function Ri(e){let t=e,{dataStartDate:n,dataEndDate:r}=t;return typeof n!=`string`||typeof r!=`string`?null:{start:wr(n),end:wr(r),sweepCount:t.sweepCount??1}}function zi(e,t=new Date){return Wn(e,t)}function Bi(e,t=new Date){let n=Ri(e);if(!n)return null;let r=zi(n.start,t),i=zi(n.end,t);return r===i?r:`${r} to ${i}`}function Vi(e,t=new Date){let n=Ri(e),r=Bi(e,t);return!n||!r?`Check date unavailable`:`${r} · ${n.sweepCount} ${n.sweepCount===1?`check`:`checks`}`}function Hi(e){let t=Ri(e);return t?Hn(t.start):``}function Ui(e){return e.trim().toLowerCase()}function Wi(e,t={}){return e.map(e=>{let n=e.trim().toLowerCase(),r=(t[e]??[]).map(e=>e.trim().toLowerCase()).filter(Boolean).sort();return n&&r.length>0?`${n}=${r.join(`|`)}`:n}).filter(Boolean).sort().join(`
12
12
  `)}var Gi={claude:`Claude`,openai:`OpenAI`,gemini:`Gemini`,perplexity:`Perplexity`,muse:`Muse`,local:`Local`,openrouter:`OpenRouter`};function Ki(e,t){let n=t?.find(t=>t.name===e)?.displayName?.trim();if(n)return n;let r=We(e);return r?`${r} via OpenRouter`:Gi[Ui(e)]??e.charAt(0).toUpperCase()+e.slice(1)}function qi(e){return Math.round(e*1e3)/10}function Ji(e){return e.byProvider??{}}function Yi(e,t,n){let r=e.buckets.length>0,i=e.buckets.length===1;if(n===`overall`){let n=t===`cited`?Fi:Ii,a=t===`cited`?`citationRate`:`mentionRate`;return{rows:e.buckets.map(e=>({date:e.startDate,[n]:qi(e[a])})),series:[n],hasData:r,singleBucket:i}}let a=t===`mentioned`?`mentionRate`:`citationRate`,o=[...new Set(e.buckets.flatMap(e=>Object.keys(Ji(e))))].sort();return{rows:e.buckets.map(e=>{let t={date:e.startDate},n=Ji(e);for(let e of o){let r=n[e];t[e]=r?qi(r[a]):null}return t}),series:o,hasData:r,singleBucket:i}}function Xi(e){let t=e;return Object.hasOwn(t,`modelEvidenceByProvider`)?t.modelEvidenceByProvider??{}:null}function J(e){let t=e;return Object.hasOwn(t,`modelAttribution`)?t.modelAttribution??{}:null}function Zi(e){return e.servedModelAttribution??{}}function Qi(e){return e.modelServiceMismatch??{}}function $i(e){return e.modelPointerChanges??{}}function ea(e){return e.length<=1?e[0]??``:`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}function ta(e){switch(e.status){case`known`:return e.model;case`unknown`:return`Unknown model`;case`mixed`:return e.models.length===0?`Unknown model`:`${e.models.join(`, `)}${e.includesUnknown?` and an unknown model`:``}`}}function na(e){return ea([...e.models,...e.includesUnknown?[`an unknown model`]:[]])}function ra(e){let t=new Map;for(let[n,r]of Object.entries(e))for(let e of r.events){let r=t.get(e.bucketStartDate)??[];r.push({provider:n,event:e}),t.set(e.bucketStartDate,r)}return[...t.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({bucketStartDate:e,events:[...t].sort((e,t)=>e.provider.localeCompare(t.provider)||e.event.observedAt.localeCompare(t.event.observedAt))}))}function ia(e){let t={},n=[];for(let[r,i]of Object.entries(e)){let e=i.events.filter(e=>!e.fromPreWindowAnchor);for(let e of i.events)e.fromPreWindowAnchor&&n.push({provider:r,event:e});e.length>0&&(t[r]={...i,events:e})}return{buckets:ra(t),beforeWindow:n.sort((e,t)=>e.event.observedAt.localeCompare(t.event.observedAt)||e.provider.localeCompare(t.provider))}}function aa(e){let t=[];for(let[n,r]of Object.entries(e)){let e=r.eventTotal??r.events.length;e>r.events.length&&t.push({provider:n,shown:r.events.length,total:e})}return t.sort((e,t)=>e.provider.localeCompare(t.provider))}function oa(e){let t=e.buckets.map(e=>{let t=e.mentionShare;return{date:e.startDate,[Li]:t?.rate==null?null:qi(t.rate)}}),n=t.map(e=>e[Li]).filter(e=>typeof e==`number`&&Number.isFinite(e));return{rows:t,series:[Li],hasData:n.length>0,singleBucket:n.length===1}}function sa(e,t,n){return t===`mentionShare`?oa(e):Yi(e,t,n)}function ca(e,t){if(t===`mentionShare`)return e.buckets.flatMap(e=>{let t=e.mentionShare?.rate;return typeof t==`number`&&Number.isFinite(t)?[t]:[]});let n=t===`cited`?`citationRate`:`mentionRate`;return e.buckets.map(e=>e[n])}function la(e,t){let n=e.windowChange;if(!n)return null;switch(t){case`cited`:return n.citationRate;case`mentioned`:return n.mentionRate;case`mentionShare`:return n.mentionShare}}function ua(e,t,n){let r=n===`mentioned`?`mentionRate`:`citationRate`;for(let n=e.buckets.length-1;n>=0;n--){let i=Ji(e.buckets[n])[t];if(i)return i[r]}return null}function Y(e){return Date.parse(e)}function da(e,t){let n=Ri(e);if(!n)return!1;let r=Y(t);return r>=Y(n.start)&&r<=Y(n.end)}function fa(e){return e.basketChanges??[]}function pa(e,t){return t.filter(t=>da(e,t.at)).sort((e,t)=>Y(e.at)-Y(t.at))}function ma(e,t){return Ui(e)===`perplexity`&&t.status===`known`&&!t.model.includes(`/`)}function ha(e){return Object.entries(e).filter(([e,t])=>!ma(e,t.configured)).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({provider:e,mismatch:t}))}function ga(e){return[...fa(e)].sort((e,t)=>Y(t.at)-Y(e.at)).map(e=>({at:wr(e.at),added:e.added,removed:e.removed}))}function _a(e,t){let n=[...e.events].sort((e,t)=>Y(e.observedAt)-Y(t.observedAt)),r=n[0]?.from??e.latestObservation.state;for(let e of n)Y(e.observedAt)<=Y(t)&&(r=e.to);return r}function va(e,t,n,r){return{provider:e,at:wr(t.observedAt),onOrBefore:t.fromPreWindowAnchor===!0,anchorAt:t.anchorObservedAt?wr(t.anchorObservedAt):null,from:t.from,to:t.to,served:n,reroute:r}}function ya(e,t){let n=[];for(let[r,i]of Object.entries(e)){let e=t[r]?.events??[],a=new Set(i.events.map(e=>e.observedAt));for(let t of i.events){let i=ma(r,t.to)?e.find(e=>e.observedAt===t.observedAt):void 0;n.push(va(r,t,i?{from:i.from,to:i.to}:null,!1))}for(let t of e)a.has(t.observedAt)||ma(r,_a(i,t.observedAt))&&n.push(va(r,t,null,!0))}return n.sort((e,t)=>Y(t.at)-Y(e.at)||e.provider.localeCompare(t.provider))}function ba({latest:e,queryChanges:t,modelRows:n,now:r=new Date}){let i=[...t.map(e=>e.at),...n.map(e=>e.at)];if(i.length===0)return null;let a=t=>e!==void 0&&da(e,t),o=t.filter(e=>a(e.at)),s=o.reduce((e,t)=>e+t.added.length,0),c=o.reduce((e,t)=>e+t.removed.length,0),l=n.filter(e=>a(e.at)).length,u=e?Bi(e,r):null;if(u===null||s+c+l===0)return`No changes since ${zi(i.reduce((e,t)=>Y(t)>Y(e)?t:e),r)}`;let d=[u];return s>0&&d.push(`${s} ${s===1?`query`:`queries`} added`),c>0&&d.push(`${c} ${c===1?`query`:`queries`} removed`),l>0&&d.push(`${l} new ${l===1?`model`:`models`}`),d.join(` · `)}function xa(e,t,n,r=null){let i=Y(e);if(!Number.isFinite(i))return null;let a=t.filter(e=>Y(e)<i);if(a.length>0)return wr(a.reduce((e,t)=>Y(t)>Y(e)?t:e));let o=n.map(e=>Ri(e)).filter(e=>e!==null).sort((e,t)=>Y(e.start)-Y(t.start)),s=o.findIndex(e=>Y(e.start)<=i&&i<=Y(e.end));if(s===-1)return null;let c=o[s];return Y(c.start)===i?s>0?o[s-1].end:r&&Y(r)<i?wr(r):null:c.sweepCount===2&&Y(c.end)===i?c.start:null}function Sa(e){let t=new Map,n=(e,n)=>{let r=t.get(e);r?r.push(n):t.set(e,[n])};for(let t of[...e].sort((e,t)=>e.revision-t.revision)){let e=Y(t.at);for(let r of t.removed)n(r,{at:e,member:!1});for(let r of t.added)n(r,{at:e,member:!0})}return new Map([...t].filter(([,e])=>e.at(-1).member))}function Ca(e,t){let n=!e[0].member;for(let r of e)r.at<=t&&(n=r.member);return n}function wa(e,t,n){return e.some(e=>e.at>t&&e.at<=n)}function Ta(e,t){let n=Y(t.start),r=Y(t.end);return t.sweepCount>2?wa(e,n,r):Ca(e,n)!==Ca(e,r)}function Ea(e,t,n,r){let i=Y(t),a=Y(n),o={added:[],removed:[],removedAndAddedBack:[],addedAndRemovedAgain:[]},s=new Set;for(let[t,n]of Sa(e)){if(!r(n))continue;s.add(t);let e=Ca(n,i),c=Ca(n,a);e===c?(e?o.removedAndAddedBack:o.addedAndRemovedAgain).push(t):(c?o.added:o.removed).push(t)}if(s.size===0)return null;let c=e=>[...e.added,...e.removed].some(e=>s.has(e)),l=e.filter(e=>Y(e.at)>i&&Y(e.at)<=a&&c(e)).sort((e,t)=>Y(e.at)-Y(t.at));return{changes:l,keys:[...new Set(l.flatMap(e=>[...e.added,...e.removed]))].filter(e=>s.has(e)),moves:o}}function Da(e,t){if(e.length<2)return null;let n=e[0],r=e.at(-1),i=Ri(n),a=Ri(r),o=i?.start??n.startDate,s=a?.end??r.endDate,c=Ea(t,o,s,e=>Ca(e,Y(o))!==Ca(e,Y(s))||i!==null&&Ta(e,i)||a!==null&&Ta(e,a));return!c&&n.queryCount===r.queryCount?null:{...c??{changes:[],keys:[],moves:{added:[],removed:[],removedAndAddedBack:[],addedAndRemovedAgain:[]}},firstCount:n.queryCount,latestCount:r.queryCount}}function Oa(e,t){let n=Ri(e);if(!n)return null;let r=Ea(t,n.start,n.end,e=>Ta(e,n));return r?{...r,firstCount:e.queryCount,latestCount:e.queryCount}:null}function ka(e){return`${e} ${e===1?`query`:`queries`}`}function Aa(e){let t=[],n=e=>t.length===0?ka(e):String(e);return e.added.length>0&&t.push(`${n(e.added.length)} added`),e.removed.length>0&&t.push(`${n(e.removed.length)} removed`),e.removedAndAddedBack.length>0&&t.push(`${ka(e.removedAndAddedBack.length)} removed and added back`),e.addedAndRemovedAgain.length>0&&t.push(`${ka(e.addedAndRemovedAgain.length)} added and removed again`),ea(t)}function ja(e,t,n,r){return e?t!==`mentionShare`||n!==`non-brand`||!r?!1:e.keys.length>0&&e.keys.every(e=>r(e)===`branded`):!0}function Ma({provider:e}){let t={gemini:`border-blue-800/50 bg-blue-950/40 text-blue-300`,openai:`border-green-800/50 bg-green-950/40 text-green-300`,claude:`border-amber-800/50 bg-amber-950/40 text-amber-300`,perplexity:`border-teal-800/50 bg-teal-950/40 text-teal-300`,muse:`border-indigo-800/50 bg-indigo-950/40 text-indigo-300`,local:`border-purple-800/50 bg-purple-950/40 text-purple-300`},n=Object.hasOwn(t,e)?`provider-badge--${e} ${t[e]}`:`border-zinc-700 bg-zinc-800 text-zinc-300`;return(0,q.jsx)(`span`,{className:`inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide ${n}`,children:On(e)?Ki(e):e})}function Na({status:e}){return(0,q.jsx)(xn,{tone:ri(e),children:Kn(e)})}var Pa=P,Fa=de,Ia=K.forwardRef(({className:e,...t},n)=>(0,q.jsx)(se,{ref:n,className:Yt(`fixed inset-0 z-50 bg-overlay-scrim/70 backdrop-blur-sm`,e),...t}));Ia.displayName=se.displayName;var La=400,Ra=1200,za=720,Ba=K.forwardRef(({className:e,children:t,...n},r)=>{let[i,a]=K.useState(za),o=K.useRef(!1),s=K.useRef(0),c=K.useRef(0),l=K.useCallback(e=>{o.current=!0,s.current=e.clientX,c.current=i,e.target.setPointerCapture(e.pointerId),e.preventDefault()},[i]),u=K.useCallback(e=>{if(!o.current)return;let t=s.current-e.clientX,n=Math.min(Ra,Math.max(La,c.current+t));a(n)},[]),d=K.useCallback(()=>{o.current=!1},[]);return(0,q.jsxs)(Fa,{children:[(0,q.jsx)(Ia,{}),(0,q.jsxs)(fe,{ref:r,className:Yt(`fixed z-50 flex flex-col bg-bg px-5 py-4 shadow-2xl overflow-hidden`,`max-md:inset-x-0 max-md:bottom-0 max-md:top-auto max-md:max-h-[88vh] max-md:rounded-t-2xl max-md:border-t`,`md:inset-y-0 md:right-0 md:h-full md:border-l`,`border-base`,e),style:{width:`min(${i}px, 100vw)`},...n,children:[(0,q.jsx)(`div`,{className:`absolute inset-y-0 left-0 w-1.5 cursor-col-resize hover:bg-mono-700/50 active:bg-mono-600/50 transition-colors max-md:hidden`,onPointerDown:l,onPointerMove:u,onPointerUp:d}),t,(0,q.jsxs)(ue,{className:`absolute right-4 top-4 inline-flex size-8 items-center justify-center rounded-md text-muted transition hover:bg-bg-elevated hover:text-heading focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400`,children:[(0,q.jsx)(ie,{className:`size-4`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})});Ba.displayName=fe.displayName;var Va=({className:e,...t})=>(0,q.jsx)(`div`,{className:Yt(`flex flex-col gap-1.5 pr-10`,e),...t}),Ha=K.forwardRef(({className:e,...t},n)=>(0,q.jsx)(pe,{ref:n,className:Yt(`text-lg font-medium text-primary`,e),...t}));Ha.displayName=pe.displayName;var Ua=K.forwardRef(({className:e,...t},n)=>(0,q.jsx)(le,{ref:n,className:Yt(`text-sm text-muted`,e),...t}));Ua.displayName=le.displayName;function Wa({title:e,subtitle:t,children:n,open:r,onClose:i}){return(0,q.jsx)(Pa,{open:r,onOpenChange:e=>e?void 0:i(),children:(0,q.jsxs)(Ba,{children:[(0,q.jsxs)(Va,{className:`drawer-head`,children:[(0,q.jsx)(`p`,{className:`eyebrow eyebrow-soft`,children:t}),(0,q.jsx)(Ha,{id:`drawer-title`,children:e}),(0,q.jsx)(Ua,{className:`sr-only`,children:t})]}),(0,q.jsx)(`div`,{className:`drawer-body`,children:n})]})})}var Ga={label:`Different subject`,project:`The answer uses your name, but sentiment found it is about something else, so it does not count as a mention.`,property:`The answer uses this Property’s name, but sentiment found it is about something else, so it does not count as a mention.`};function Ka(e){let t=(e??``).trim();return t&&(t.startsWith(`/`)||/^https?:\/\//i.test(t)||/^mailto:/i.test(t))?t:null}function qa({url:e,title:t}){let n=Ka(e),r=n&&/^https?:\/\//i.test(n)?n:null;return(0,q.jsxs)(`span`,{className:`block min-w-0 text-sm leading-6 [overflow-wrap:anywhere]`,children:[t&&t!==e?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`mb-1 block font-medium text-heading`,children:t}),` `]}):null,r?(0,q.jsx)(`a`,{href:r,target:`_blank`,rel:`noopener noreferrer`,className:`text-link underline underline-offset-2 hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400`,children:e}):(0,q.jsx)(`span`,{className:`text-secondary`,children:e})]})}function Ja(e){return[...e.mentionedCompetitorTerms??(e.mentionedCompetitorDomains??[]).flatMap(e=>{let t=Mt(e);return t.length>=4?[t]:[]}),...e.recommendedCompetitors??[]].filter(e=>e.trim().length>2)}var Ya=/[\s\-_]+/;function Xa(e){let t=e.split(Ya).filter(Boolean);return t.length===0?null:t.map(Lr).join(`[\\s\\-_]*`)}function Za(e,t){let n=Qa(t),r=e.split(/(\*\*[^*]+\*\*)/).filter(Boolean).map(e=>e.startsWith(`**`)&&e.endsWith(`**`)?{type:`bold`,value:e.slice(2,-2)}:{type:`text`,value:e}),i=n.flatMap(e=>e.terms).filter(e=>e.trim().length>1);if(i.length===0)return r.map((e,t)=>e.type===`bold`?K.createElement(`strong`,{key:`b-${t}`,className:`text-strong font-semibold`},e.value):e.value).filter(Boolean);let a=[...i].sort((e,t)=>t.length-e.length).map(Xa).filter(e=>!!e);if(a.length===0)return r.map((e,t)=>e.type===`bold`?K.createElement(`strong`,{key:`b-${t}`,className:`text-strong font-semibold`},e.value):e.value).filter(Boolean);let o=RegExp(`(${a.join(`|`)})`,`gi`),s=new Map;for(let e of n)for(let t of e.terms){let n=cn(t);n&&!s.has(n)&&s.set(n,e.className)}return r.flatMap((e,t)=>e.value.split(o).map((n,r)=>{if(!n)return null;if(r%2==1){let i=s.get(cn(n))??`answer-highlight`;return e.type===`bold`?K.createElement(`mark`,{key:`hl-${t}-${r}`,className:i},K.createElement(`strong`,{className:`text-strong font-semibold`},n)):K.createElement(`mark`,{key:`hl-${t}-${r}`,className:i},n)}return e.type===`bold`?K.createElement(`strong`,{key:`b-${t}-${r}`,className:`text-strong font-semibold`},n):n})).filter(Boolean)}function Qa(e){return e.length===0?[]:typeof e[0]==`string`?[{terms:e,className:`answer-highlight`}]:e}function $a(e,t){let n=e.mentionedCompetitorDomains===void 0?t:e,r=n?.mentionedCompetitorTerms;return{citedCompetitorDomains:[...e.citedCompetitorDomains??t?.citedCompetitorDomains??[]],mentionedCompetitorDomains:[...n?.mentionedCompetitorDomains??[]],...r===void 0?{}:{mentionedCompetitorTerms:[...r]}}}function eo(e,t){switch(e){case`new`:return`First observation`;case`emerging`:return`First mention`;case`lost`:return`Lost since last run`;default:return t===`mentioned`||t===`visible`?`Mentioned in latest run`:t===`pending`?`Awaiting first run`:`Not mentioned in latest run`}}function to({evidence:e,project:t,onClose:n}){let[r,i]=(0,K.useState)(!1),[a,o]=(0,K.useState)(`mentions`),[s,c]=(0,K.useState)(-1),[l,u]=(0,K.useState)(null),[d,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)({}),h=at(t.project),g=new Set(h.map(Lt)),_=e.runHistory,v=_.length>1,[y,b]=(0,K.useState)(null),x=(0,K.useRef)(!1);(0,K.useEffect)(()=>{if(x.current||e.answerSnippet&&(e.visibilityState!=null||e.answerMentioned!=null))return;let t=_.at(-1);t&&(x.current=!0,Ye(t.runId).then(n=>{let r=n.snapshots?.find(t=>t.query===e.query&&t.provider===e.provider);r&&b({citationState:r.citationState,answerMentioned:r.answerMentioned,visibilityState:r.visibilityState,visibilityTransition:t.visibilityTransition,provider:r.provider,model:r.model??e.model,answerSnippet:r.answerText??e.answerSnippet,citedDomains:r.citedDomains??e.citedDomains,...$a(r,e),recommendedCompetitors:r.recommendedCompetitors??e.recommendedCompetitors??[],matchedTerms:r.matchedTerms??e.matchedTerms??[],mentionIdentity:r.mentionIdentity??null,groundingSources:r.groundingSources??e.groundingSources,searchQueries:r.searchQueries,evidenceUrls:r.citedUrls??[],changeLabel:e.visibilityChangeLabel??e.changeLabel,summary:e.summary})}).catch(()=>{}))},[e,_]);let S=s>=0&&l!==null,C=S?l:y||{citationState:e.citationState,answerMentioned:e.answerMentioned,visibilityState:e.visibilityState,visibilityTransition:_.at(-1)?.visibilityTransition,provider:e.provider,model:e.model,answerSnippet:e.answerSnippet,citedDomains:e.citedDomains,...$a(e),recommendedCompetitors:e.recommendedCompetitors??[],matchedTerms:e.matchedTerms??[],mentionIdentity:e.mentionIdentity??null,groundingSources:e.groundingSources,searchQueries:e.searchQueries??[],evidenceUrls:e.evidenceUrls,changeLabel:e.visibilityChangeLabel??e.changeLabel,summary:e.summary},w=C.visibilityState===`pending`||C.citationState===`pending`,T=w?!1:C.visibilityState==null?C.answerMentioned==null?C.citationState===V.cited||C.citationState===`emerging`:C.answerMentioned:C.visibilityState===`visible`,E=C.answerMentioned!=null||C.visibilityState!=null||C.mentionedCompetitorDomains.length>0||C.recommendedCompetitors.length>0,D=C.citedDomains.length>0||C.citedCompetitorDomains.length>0||C.groundingSources.length>0||C.evidenceUrls.length>0,O=t.project.displayName||t.project.name,ee=[...h.map(Lt),O,O.split(` `).slice(0,2).join(` `),...C.matchedTerms].filter(e=>e.trim().length>2),k=Ja(C),A=[{terms:ee,className:`answer-highlight-brand`},...k.length>0?[{terms:k,className:`answer-highlight-competitor`}]:[]],j=w?`pending`:C.visibilityTransition===`lost`?`lost`:T?`mentioned`:`not-mentioned`,ne=(0,K.useRef)(0),re=(0,K.useCallback)(async t=>{let n=++ne.current;if(t===-1||t===_.length-1){c(-1),u(null),i(!1);return}c(t),i(!1);let r=_[t],a=`${r.runId}::${e.query}::${e.provider}`;if(p[a])u(p[a]);else{f(!0);try{let t=await Ye(r.runId);if(n!==ne.current)return;let i=t.snapshots?.find(t=>t.query===e.query&&t.provider===e.provider)??t.snapshots?.find(t=>t.query===e.query),o=i?{citationState:i.citationState,answerMentioned:i.answerMentioned,visibilityState:i.visibilityState,visibilityTransition:r.visibilityTransition,provider:i.provider,model:i.model??null,answerSnippet:i.answerText??``,citedDomains:i.citedDomains,...$a(i),recommendedCompetitors:i.recommendedCompetitors??[],matchedTerms:i.matchedTerms??[],mentionIdentity:i.mentionIdentity??null,groundingSources:i.groundingSources,searchQueries:i.searchQueries,evidenceUrls:i.citedUrls??[],changeLabel:eo(r.mentionTransition??r.visibilityTransition,r.mentionState??r.visibilityState),summary:``}:{citationState:r.citationState,answerMentioned:r.answerMentioned,visibilityState:r.visibilityState,visibilityTransition:r.visibilityTransition,provider:e.provider,model:r.model??null,answerSnippet:``,citedDomains:[],citedCompetitorDomains:[],mentionedCompetitorDomains:[],recommendedCompetitors:[],matchedTerms:[],groundingSources:[],searchQueries:[],evidenceUrls:[],changeLabel:eo(r.mentionTransition??r.visibilityTransition,r.mentionState??r.visibilityState),summary:`Snapshot data not available for this run.`};m(e=>({...e,[a]:o})),u(o)}catch{if(n!==ne.current)return;u({citationState:r.citationState,answerMentioned:r.answerMentioned,visibilityState:r.visibilityState,visibilityTransition:r.visibilityTransition,provider:e.provider,model:r.model??null,answerSnippet:``,citedDomains:[],citedCompetitorDomains:[],mentionedCompetitorDomains:[],recommendedCompetitors:[],matchedTerms:[],groundingSources:[],searchQueries:[],evidenceUrls:[],changeLabel:eo(r.mentionTransition??r.visibilityTransition,r.mentionState??r.visibilityState),summary:`Failed to load historical run data.`})}finally{n===ne.current&&f(!1)}}},[_,e.query,e.provider,p]),ae=(S||e.historyScope!==`provider`)&&C.model?`${Ki(C.provider)} (${C.model}) \u00b7 ${C.changeLabel.toLowerCase()}`:`${Ki(C.provider)} \u00b7 ${C.changeLabel.toLowerCase()}`,M=!S&&e.historyScope===`provider`?[e.model?`Current model: ${e.model}`:null,e.modelsSeen&&e.modelsSeen.length>1?`History spans ${e.modelsSeen.length} models`:null].filter(Boolean).join(` · `):``,N=T?{label:`Mentioned in answer`,title:`Your brand or domain is mentioned in this answer`,meta:ae}:!w&&C.mentionIdentity===`wrong-subject`?{label:Ga.label,title:Ga.project,meta:ae}:C.visibilityTransition===`lost`?{label:`Mention lost`,title:`Your brand no longer appears in this answer`,meta:ae}:w?{label:`Pending`,title:`Awaiting first run`,meta:`No provider data yet`}:{label:`Not mentioned in answer`,title:`Your brand or domain was not mentioned in this answer`,meta:ae};return(0,q.jsx)(P,{open:!0,onOpenChange:e=>{e||n()},children:(0,q.jsxs)(de,{children:[(0,q.jsx)(se,{className:`fixed inset-0 z-50 bg-overlay-scrim/80 backdrop-blur-sm`}),(0,q.jsxs)(fe,{className:`evidence-modal`,"aria-describedby":void 0,children:[(0,q.jsxs)(`div`,{className:`evidence-modal-header`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`p`,{className:`eyebrow eyebrow-soft`,children:[t.project.name,` `,`·`,` `,C.provider||`All providers`]}),(0,q.jsx)(pe,{className:`text-lg font-semibold text-primary truncate`,children:e.query})]}),(0,q.jsxs)(ue,{className:`inline-flex size-8 items-center justify-center rounded-md text-muted transition hover:bg-mono-800 hover:text-heading focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400 shrink-0`,children:[(0,q.jsx)(ie,{className:`size-4`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]}),v&&(0,q.jsxs)(`div`,{className:`evidence-modal-timeline`,children:[(0,q.jsx)(`p`,{className:`drawer-section-label mb-1.5`,children:`Run history`}),(0,q.jsx)(`div`,{className:`flex items-center gap-1 overflow-x-auto pb-1`,children:_.map((e,t)=>{let n=s===-1&&t===_.length-1||s===t,r=e.visibilityState??(e.answerMentioned?`visible`:`not-visible`),i=e.visibilityTransition??r,a=r===`visible`?`bg-positive-400`:i===`emerging`?`bg-caution-400`:i===`lost`?`bg-negative-400`:`bg-mono-600`,o=new Date(e.createdAt).toLocaleDateString(void 0,{month:`short`,day:`numeric`}),c=!!(e.model&&t>0&&_[t-1]?.model&&_[t-1].model!==e.model);return(0,q.jsxs)(`button`,{type:`button`,className:`evidence-run-dot ${n?`evidence-run-dot--selected`:``}`,onClick:()=>{re(t===_.length-1?-1:t)},"aria-label":[`Run ${o}: ${r}`,e.model?`model ${e.model}`:null,c?`model changed`:null].filter(Boolean).join(` — `),"aria-pressed":n,children:[(0,q.jsx)(`span`,{className:`size-2 rounded-full ${a} ${c?`ring-1 ring-caution-300/80 ring-offset-2 ring-offset-bg`:``}`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted`,children:o})]},t)})}),s>=0&&s<_.length&&(0,q.jsxs)(`p`,{className:`text-[11px] text-muted mt-1`,children:[`Viewing run from `,new Date(_[s].createdAt).toLocaleString(),` `,`—`,` `,(0,q.jsx)(`span`,{className:`capitalize`,children:_[s].visibilityState??(_[s].answerMentioned?`visible`:`not-visible`)}),(0,q.jsxs)(`button`,{type:`button`,className:`text-secondary hover:text-strong ml-2`,onClick:()=>{re(-1)},children:[`←`,` Back to latest`]})]}),!S&&(e.modelTransitions?.length??0)>0&&(0,q.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:e.modelTransitions.map(e=>(0,q.jsx)(`span`,{className:`inline-flex items-center rounded-full border border-caution-400/30 bg-caution-400/10 px-2 py-1 text-[10px] text-caution-100`,children:`${e.fromModel??`unknown`} -> ${e.toModel??`unknown`} on ${new Date(e.createdAt).toLocaleDateString()}`},`${e.runId}:${e.toModel??`unknown`}`))})]}),(0,q.jsxs)(`div`,{className:`evidence-modal-body`,children:[d&&(0,q.jsxs)(`div`,{className:`md:col-span-2 flex items-center justify-center py-12 text-muted text-sm`,children:[`Loading historical run data`,`…`]}),!d&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`evidence-modal-main`,children:[(0,q.jsxs)(`div`,{className:`evidence-position-hero evidence-position-hero--${j}`,children:[(0,q.jsx)(`p`,{className:`evidence-position-label evidence-position-label--${j}`,children:N.label}),(0,q.jsx)(`p`,{className:`evidence-position-title evidence-position-title--${j}`,children:N.title}),(0,q.jsx)(`p`,{className:`evidence-position-meta`,children:N.meta}),M&&(0,q.jsx)(`p`,{className:`mt-1 text-[11px] text-muted`,children:M})]}),C.answerSnippet&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`drawer-section-label`,children:`What the AI said`}),(0,q.jsx)(`div`,{className:`answer-snippet-block ${r?`evidence-answer-expanded`:`evidence-answer-collapsed`}`,children:(()=>{if(!C.answerSnippet)return null;let e=C.answerSnippet.split(`
13
- `),t=[],n=[],r=0,i=()=>{if(n.length===0)return;let e=n.join(` `).trim();e&&t.push((0,q.jsx)(`p`,{className:t.length>0?`mt-2.5`:``,children:Za(e,A)},r++)),n=[]};for(let a of e){let e=a.trim();if(/^[-\u2013\u2014]{3,}$/.test(e)){i(),t.push((0,q.jsx)(`hr`,{className:`border-default my-3`},r++));continue}let o=e.match(/^(#{1,3})\s+(\S.*)$/);if(o){i();let e=o[1].length,n=o[2].replace(/^[\p{Emoji}\p{Emoji_Component}\s]+/u,``).trim()||o[2],a=e===1?`text-[13px] font-semibold text-heading mt-4 mb-1`:e===2?`text-xs font-semibold text-strong mt-3 mb-0.5`:`text-xs font-medium text-neutral mt-2`;t.push((0,q.jsx)(`p`,{className:a,children:Za(n,A)},r++))}else e===``?i():n.push(e)}return i(),t})()}),C.answerSnippet.length>280&&(0,q.jsx)(`button`,{type:`button`,className:`mt-1.5 text-xs text-muted hover:text-neutral transition-colors`,onClick:()=>i(!r),children:r?`↑ Collapse`:`↓ Show full answer`})]}),!C.answerSnippet&&!d&&(0,q.jsx)(`div`,{className:`rounded-lg border border-subtle bg-surface-subtle px-4 py-8 text-center text-faint text-sm`,children:`No answer text recorded for this run`}),C.searchQueries.length>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`drawer-section-label flex items-center`,children:[(0,q.jsx)(`span`,{children:`Web searches the model ran`}),(0,q.jsx)(Tr,{text:`The search queries this AI model issued while researching your prompt. They reveal how the model reformulated your query — the phrasings worth optimizing your content for. Distinct from grounding sources (what it found) and citations (what it linked).`})]}),(0,q.jsx)(`ul`,{className:`grid gap-1`,children:C.searchQueries.map((e,t)=>(0,q.jsxs)(`li`,{className:`flex items-start gap-2 text-sm text-neutral`,children:[(0,q.jsx)(te,{className:`size-3.5 mt-0.5 shrink-0 text-faint`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`break-words`,children:e})]},`${t}-${e}`))})]}),!S&&e.relatedTechnicalSignals.length>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`drawer-section-label`,children:T?`Why you're visible`:`What to fix`}),(0,q.jsx)(`div`,{className:`action-items-list`,children:e.relatedTechnicalSignals.map((e,t)=>(0,q.jsxs)(`div`,{className:`action-item`,children:[(0,q.jsx)(`svg`,{className:`action-item-icon ${T?`text-positive-400`:`text-caution-400`}`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:T?(0,q.jsx)(`path`,{d:`M3 8l3.5 3.5L13 4.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`circle`,{cx:`8`,cy:`8`,r:`7`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,q.jsx)(`path`,{d:`M8 5v3.5M8 10.5v0`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}),(0,q.jsx)(`span`,{className:`action-item-text`,children:e})]},t))})]}),C.summary&&(0,q.jsx)(`p`,{className:`text-xs text-faint border-t border-subtle pt-3 mt-1`,children:C.summary})]}),(0,q.jsxs)(`div`,{className:`evidence-modal-sidebar`,children:[(E||D)&&(0,q.jsxs)(`div`,{className:`sidebar-tabs`,children:[(0,q.jsx)(`button`,{className:`sidebar-tab ${a===`mentions`?`sidebar-tab--active`:``}`,onClick:()=>o(`mentions`),type:`button`,title:`Canonry's answer-level visibility assessment and any company names extracted from the answer text.`,children:`Mentions`}),(0,q.jsx)(`button`,{className:`sidebar-tab ${a===`sources`?`sidebar-tab--active`:``}`,onClick:()=>o(`sources`),type:`button`,title:`Grounding links the model used to build the answer. These are supporting sources, not the primary visibility signal.`,children:`Sources`})]}),a===`mentions`&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`drawer-section-label flex items-center`,children:[(0,q.jsx)(`span`,{children:`Mention in answer`}),(0,q.jsx)(Tr,{text:`Canonry scans the AI answer for your owned domains and project name. This is independent from grounding or citation sources.`})]}),(0,q.jsxs)(`div`,{className:`mention-status mention-status--${T?`mentioned`:`not-mentioned`}`,children:[(0,q.jsx)(`span`,{className:`mention-status-icon`,children:w?`…`:T?`✓`:`—`}),(0,q.jsx)(`span`,{className:`mention-status-label`,children:w?`Pending`:T?`Mentioned`:`Not mentioned`})]}),!w&&!T&&C.mentionIdentity===`wrong-subject`&&(0,q.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1 text-[11px] text-muted`,children:[(0,q.jsx)(`span`,{children:Ga.label}),(0,q.jsx)(Tr,{text:Ga.project})]}),C.matchedTerms.length>0&&(0,q.jsxs)(`div`,{className:`mt-2`,children:[(0,q.jsx)(`p`,{className:`text-[10px] uppercase tracking-wide text-muted mb-1.5`,children:`Matched in answer`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:C.matchedTerms.map(e=>(0,q.jsx)(`span`,{className:`mention-chip mention-chip--brand`,children:e},e))})]}),!w&&!T&&C.matchedTerms.length===0&&(0,q.jsxs)(`div`,{className:`mt-2`,children:[(0,q.jsx)(`p`,{className:`text-[10px] uppercase tracking-wide text-muted mb-1.5`,children:`Searched for`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:ee.map(e=>(0,q.jsx)(`span`,{className:`mention-chip mention-chip--muted`,children:e},e))}),(0,q.jsx)(`p`,{className:`text-[11px] text-faint mt-1.5`,children:`None of these appear in the answer text.`})]})]}),(C.recommendedCompetitors.length>0||C.mentionedCompetitorDomains.length>0)&&(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`drawer-section-label flex items-center`,children:[(0,q.jsx)(`span`,{children:`Competitors in answer`}),(0,q.jsx)(Tr,{text:`Competitors detected in the answer text. Includes tracked competitor brands and names extracted by Canonry; source-link competitors stay in the Sources tab.`})]}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:(()=>{let e=C.mentionedCompetitorDomains.map(e=>e.replace(/^www\./,``)),t=new Set(e.map(e=>cn(e.replace(/\.[^.]+$/,``))));return[...C.recommendedCompetitors.filter(e=>!t.has(cn(e))),...e].map(e=>(0,q.jsx)(`span`,{className:`mention-chip mention-chip--competitor`,children:e},e))})()})]})]}),a===`sources`&&(0,q.jsxs)(q.Fragment,{children:[C.citedDomains.length>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`drawer-section-label flex items-center`,children:[(0,q.jsx)(`span`,{children:`Domains from source links`}),(0,q.jsx)(Tr,{text:`These domains were extracted from grounding or citation URLs. They are supporting-source metadata, not proof that the answer text mentioned them.`})]}),(0,q.jsx)(`div`,{className:`citation-leaderboard`,children:C.citedDomains.map((e,t)=>{let n=e.toLowerCase().replace(/^www\./,``),r=g.has(n),i=!r&&C.citedCompetitorDomains.some(e=>e.toLowerCase().replace(/^www\./,``)===n);return(0,q.jsxs)(`div`,{className:`citation-leaderboard-item citation-leaderboard-item--${r?`you`:i?`competitor`:`other`}`,children:[(0,q.jsxs)(`span`,{className:`citation-leaderboard-rank`,children:[`#`,t+1]}),(0,q.jsx)(`span`,{className:`citation-leaderboard-domain`,children:e}),r&&(0,q.jsx)(`span`,{className:`citation-leaderboard-tag`,children:`You`}),i&&(0,q.jsx)(`span`,{className:`citation-leaderboard-tag`,children:`Competitor`})]},e)})})]}),C.groundingSources.length>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`drawer-section-label flex items-center`,children:[(0,q.jsxs)(`span`,{children:[`Grounding source links (`,C.groundingSources.length,`)`]}),(0,q.jsx)(Tr,{text:`Links the model used as grounding or supporting context while producing the answer. These are not the same thing as answer visibility.`})]}),(0,q.jsx)(`ul`,{className:`grid min-w-0 gap-3`,children:C.groundingSources.map((e,t)=>(0,q.jsx)(`li`,{className:`min-w-0`,children:(0,q.jsx)(qa,{url:e.uri,title:e.title})},t))})]}),C.evidenceUrls.length>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`drawer-section-label`,children:`Evidence URLs`}),(0,q.jsx)(`ul`,{className:`grid min-w-0 gap-3`,children:C.evidenceUrls.map(e=>(0,q.jsx)(`li`,{className:`min-w-0`,children:(0,q.jsx)(qa,{url:e})},e))})]}),C.citedDomains.length===0&&C.groundingSources.length===0&&C.evidenceUrls.length===0&&(0,q.jsxs)(`div`,{className:`flex items-center justify-center h-24 text-faint text-sm`,children:[`No source data `,S?`for this run`:`yet`]})]}),!E&&!D&&(0,q.jsxs)(`div`,{className:`flex items-center justify-center h-24 text-faint text-sm`,children:[`No answer visibility data `,S?`for this run`:`yet`]})]})]})]})]})]})})}function no(e){let t=e.match(/^\/projects\/([^/]+)/);if(!t)return null;try{return decodeURIComponent(t[1])}catch{return t[1]}}function ro(e,t){return e?(t?.projects.find(t=>t.project.name===e||t.project.id===e))?.project.name??e:null}function io(e,t){return ro(no(e),t)}function ao(e){let t=new Date(`2026-02-20`);return e.map((e,n)=>({runId:`run_mock_${n+1}`,citationState:e,createdAt:new Date(t.getTime()+n*2*24*60*60*1e3).toISOString()}))}var oo=[{id:`project_citypoint`,name:`Citypoint Dental NYC`,canonicalDomain:`citypointdental.com`,ownedDomains:[],aliases:[],qualifiedAliases:[],country:`US`,language:`en`,tags:[`local intent`,`priority`],labels:{},providers:[],providerModels:{},providerDispatchModes:{},measurement:Jt,locations:[],defaultLocation:null,autoExtractBacklinks:!1,siteAuditMaxPages:null,configSource:`cli`,configRevision:1},{id:`project_harbor`,name:`Harbor Legal Group`,canonicalDomain:`harborlegal.com`,ownedDomains:[],aliases:[],qualifiedAliases:[],country:`US`,language:`en`,tags:[`lead gen`],labels:{},providers:[],providerModels:{},providerDispatchModes:{},measurement:Jt,locations:[],defaultLocation:null,autoExtractBacklinks:!1,siteAuditMaxPages:null,configSource:`cli`,configRevision:1},{id:`project_northstar`,name:`Northstar Orthopedics`,canonicalDomain:`northstarortho.com`,ownedDomains:[],aliases:[],qualifiedAliases:[],country:`US`,language:`en`,tags:[`multi-location`],labels:{},providers:[],providerModels:{},providerDispatchModes:{},measurement:Jt,locations:[],defaultLocation:null,autoExtractBacklinks:!1,siteAuditMaxPages:null,configSource:`cli`,configRevision:1}];function so(e){return{id:e.id,projectId:e.projectId,projectName:e.projectName,kind:e.kind,kindLabel:e.kindLabel,status:e.status,trigger:e.trigger??`manual`,createdAt:e.createdAt,startedAt:e.startedAt,duration:e.duration,statusDetail:e.statusDetail,summary:e.summary,triggerLabel:e.triggerLabel}}so({id:`run_citypoint_visibility_20260308`,projectId:`project_citypoint`,projectName:`Citypoint Dental NYC`,kind:`answer-visibility`,kindLabel:`AI Visibility check`,status:`completed`,createdAt:`2026-03-08T12:15:00.000Z`,startedAt:`Mar 8, 12:15 PM`,duration:`6 minutes 12 seconds`,statusDetail:`18 tracked queries checked; 3 citation losses detected on emergency-intent prompts.`,summary:`Citation losses on emergency-intent prompts`,triggerLabel:`Scheduled`}),so({id:`run_citypoint_queued_20260309`,projectId:`project_citypoint`,projectName:`Citypoint Dental NYC`,kind:`answer-visibility`,kindLabel:`AI Visibility check`,status:`queued`,createdAt:`2026-03-09T08:05:00.000Z`,startedAt:`Mar 9, 8:05 AM`,duration:`Waiting`,statusDetail:`Ready to enqueue after the next provider rate window clears.`,summary:`Queued follow-up after local ranking movement`,triggerLabel:`Manual`}),so({id:`run_harbor_visibility_20260308`,projectId:`project_harbor`,projectName:`Harbor Legal Group`,kind:`answer-visibility`,kindLabel:`AI Visibility check`,status:`completed`,createdAt:`2026-03-08T11:05:00.000Z`,startedAt:`Mar 8, 11:05 AM`,duration:`5 minutes 7 seconds`,statusDetail:`12 tracked queries checked; local-intent visibility held steady across branded prompts.`,summary:`Branded prompts remain stable`,triggerLabel:`Scheduled`}),so({id:`run_northstar_visibility_20260308`,projectId:`project_northstar`,projectName:`Northstar Orthopedics`,kind:`answer-visibility`,kindLabel:`AI Visibility check`,status:`running`,createdAt:`2026-03-08T13:40:00.000Z`,startedAt:`Mar 8, 1:40 PM`,duration:`Running`,statusDetail:`Provider responses still in flight for 9 multi-location prompts.`,summary:`Mid-run on treatment-location prompts`,triggerLabel:`Manual`}),ao([`cited`,`cited`,`cited`,`cited`,`cited`,`cited`,`cited`,`not-cited`,`not-cited`]),ao([`not-cited`,`cited`,`cited`,`cited`,`cited`,`cited`,`cited`]),ao([`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`]),ao([`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`cited`]),ao([`cited`,`cited`,`cited`,`cited`,`cited`,`cited`,`cited`,`cited`]),ao([`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`]),ao([`not-cited`,`not-cited`,`not-cited`,`not-cited`]),ao([`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`]),ao([`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`cited`]),oo[0],oo[1],ao([`cited`,`cited`,`cited`,`cited`,`cited`]),oo[2],ao([`not-cited`,`not-cited`,`not-cited`,`cited`]),oo[0],oo[1],oo[2];function co(e,t){return e.runs.find(e=>e.id===t)}function lo(e,t){for(let n of e.projects){let e=n.visibilityEvidence.find(e=>e.id===t);if(e)return{project:n,evidence:e}}}function uo(e,t,n){if(e){let t=e.visibilityEvidence.find(e=>e.id===n);if(t)return{project:e,evidence:t}}if(t)return lo(t,n)}var fo={regression:`negative`,gain:`positive`,opportunity:`caution`,"first-citation":`positive`,"provider-pickup":`positive`,"persistent-gap":`caution`,"competitor-gained":`negative`,"competitor-lost":`neutral`,"gbp-lodging-gap":`negative`,"gbp-listing-discrepancy":`negative`,"gbp-cta-gap":`caution`,"gbp-description-missing":`caution`,"gbp-metric-drop":`negative`,"gbp-keyword-drop":`negative`},po={regression:`lost`,gain:`emerging`,opportunity:`not-cited`,"first-citation":`emerging`,"provider-pickup":`emerging`,"persistent-gap":`not-cited`,"competitor-gained":`cited`,"competitor-lost":`not-cited`,"gbp-lodging-gap":`not-cited`,"gbp-listing-discrepancy":`not-cited`,"gbp-cta-gap":`not-cited`,"gbp-description-missing":`not-cited`,"gbp-metric-drop":`lost`,"gbp-keyword-drop":`lost`},mo={regression:!0,gain:!0,opportunity:!0,"first-citation":!0,"provider-pickup":!0,"persistent-gap":!0,"competitor-gained":!1,"competitor-lost":!1,"gbp-lodging-gap":!1,"gbp-listing-discrepancy":!1,"gbp-cta-gap":!1,"gbp-description-missing":!1,"gbp-metric-drop":!1,"gbp-keyword-drop":!1},ho={regression:`Regression`,gain:`Gain`,opportunity:`Opportunity`,"first-citation":`First citation`,"provider-pickup":`Pickup`,"persistent-gap":`Gap`,"competitor-gained":`Competitor`,"competitor-lost":`Competitor`,"gbp-lodging-gap":`Lodging gap`,"gbp-listing-discrepancy":`Listing gap`,"gbp-cta-gap":`Booking CTA`,"gbp-description-missing":`Description gap`,"gbp-metric-drop":`Metric drop`,"gbp-keyword-drop":`Keyword drop`};function go(e){return{id:e.id,tone:fo[e.type],title:e.title,detail:e.cause?.details??e.cause?.cause??``,actionLabel:e.recommendation?.action??ho[e.type],actionGroup:Ft[e.type],affectedPhrases:[{query:e.query,evidenceId:``,provider:e.provider,citationState:po[e.type],siteCitation:mo[e.type]}]}}function _o(e){return e.filter(e=>!e.dismissed).map(go)}function vo(e){return{id:e.id,name:e.name,displayName:e.displayName,canonicalDomain:e.canonicalDomain,ownedDomains:e.ownedDomains??[],aliases:e.aliases??[],qualifiedAliases:e.qualifiedAliases,country:e.country,language:e.language,tags:e.tags,labels:e.labels,providers:e.providers??[],providerModels:e.providerModels??{},providerDispatchModes:e.providerDispatchModes??{},measurement:e.measurement,locations:e.locations??[],defaultLocation:e.defaultLocation??null,autoExtractBacklinks:e.autoExtractBacklinks??!1,siteAuditMaxPages:e.siteAuditMaxPages??null,configSource:e.configSource,configRevision:e.configRevision,createdAt:e.createdAt,updatedAt:e.updatedAt}}function yo(e,t){return`${e} ${t}${e===1?``:`s`}`}function bo(e,t){if(!e)return`Waiting`;if(!t)return`Running`;let n=new Date(t).getTime()-new Date(e).getTime();if(n<1e3)return`under 1 second`;let r=Math.floor(n/1e3),i=Math.floor(r/3600),a=Math.floor(r%3600/60),o=r%60;return i>0?a>0?`${yo(i,`hour`)} ${yo(a,`minute`)}`:yo(i,`hour`):a>0?o>0?`${yo(a,`minute`)} ${yo(o,`second`)}`:yo(a,`minute`):yo(o,`second`)}function xo(e){switch(e){case G[`answer-visibility`]:return`AI Visibility check`;case G[`gsc-sync`]:return`GSC sync`;case G[`inspect-sitemap`]:return`Sitemap inspection`;case G[`ga-sync`]:return`GA sync`;case G[`traffic-sync`]:return`Traffic sync`;case G[`bing-inspect`]:return`Bing URL inspection`;case G[`bing-inspect-sitemap`]:return`Bing sitemap inspection`;case G[`site-audit`]:return`Technical AEO audit`;case G[`backlink-extract`]:return`Backlink extract`;case G[`aeo-discover-seed`]:return`Discovery (seed phase)`;case G[`aeo-discover-probe`]:return`Discovery (probe phase)`;case G[`gbp-sync`]:return`Business Profile sync`;case G[`ads-sync`]:return`ChatGPT ads sync`;case G[`google-ads-sync`]:return`Google Ads sync`;case G[`gtm-sync`]:return`Tag Manager sync`;case G[`seo-sync`]:return`SEO data refresh`;default:return`Unknown job type`}}function So(e){switch(e){case gn.manual:return`Manual`;case gn.scheduled:return`Scheduled`;case gn[`config-apply`]:return`Config apply`;case gn.probe:return`Spot check`;default:return e}}function Co(e,t){return{id:e.id,projectId:e.projectId,projectName:t,kind:e.kind,kindLabel:xo(e.kind),status:e.status,trigger:e.trigger??`manual`,location:e.location??null,createdAt:e.createdAt,startedAt:Bn(e.startedAt||e.createdAt),duration:bo(e.startedAt??null,e.finishedAt??null),statusDetail:e.error?wo(e.error):To(e),summary:Eo(e),triggerLabel:So(e.trigger)}}function wo(e){let t=Xt(e);return t.length>200?t.slice(0,200)+`…`:t}function To(e){if(e.kind===G[`seo-sync`])return`View the saved scope and task results in SEO.`;switch(e.status){case H.queued:return`Waiting for execution slot.`;case H.running:return`Provider queries in progress.`;case H.completed:return`All queries checked.`;case H.partial:return`Run completed with some queries skipped.`;case H.failed:return e.error?wo(e.error):`Run failed.`;case H.cancelled:return`Run was cancelled.`;default:return``}}function Eo(e){let t=xo(e.kind);switch(e.status){case H.queued:return`${t} queued`;case H.running:return`${t} in progress`;case H.completed:return`${t} completed`;case H.partial:return`${t} partially completed`;case H.failed:return`${t} failed`;case H.cancelled:return`${t} cancelled`;default:return e.status}}function Do(e,t,n,r,i){let a=[],o=0,s=new Set;if(n.length>0){let r=n.flatMap(e=>e.snapshots??[]),c=new Map;for(let e of r)if(e.query){let t=`${e.query}::${e.provider}::${e.location??``}`;c.set(t,e)}let l=new Set(r.map(e=>e.location??null));l.size===0&&l.add(null);let u=new Set(r.map(e=>e.provider)),d=new Set(t.flatMap(e=>Object.keys(e.providerRuns??{}))),f=[...new Set([...u,...d])].sort(),p=f.length>0?f:[`gemini`],m=new Set(r.flatMap(e=>e.query?[e.query]:[]));for(let n of t){if(n.runs.length===0&&!m.has(n.query))continue;s.add(n.query);let t=n.runs.at(-1),r=t?.transition??`not-cited`;for(let s of p){let u=[...l].filter(e=>c.has(`${n.query}::${s}::${e??``}`)),d=(n.providerRuns?.[s]?.length??0)>0,f=u.length>0?u:d?[null]:[];for(let l of f){let d=l??``,f=c.get(`${n.query}::${s}::${d}`),p=f?.model??null,m=p?`${s}:${p}`:null,h=n.providerRuns?.[s],g=m?n.modelRuns?.[m]:void 0,_=e=>e?.filter(e=>(e.location??null)===l),v=u.length>0?_(h):h,y=u.length>0?_(g):g,b=(v?.length?v:null)??(y?.length?y:null),x=v?.length?`provider`:y?.length?`model`:`query`,S=f&&b?b.findIndex(e=>e.runId===f.runId):-1,C=f?S>=0?b.slice(0,S+1):null:b,w=f!==void 0&&C===null,T=C?C.at(-1).transition:w?f.citationState===V.cited?`cited`:`not-cited`:r,E=C?C.at(-1).visibilityTransition??(C.at(-1).visibilityState===`visible`?`visible`:`not-visible`):w?f.visibilityState===`visible`?`visible`:`not-visible`:t?.visibilityTransition??(t?.visibilityState===`visible`?`visible`:`not-visible`),D=b?.at(-1)?.citationState,O=b?.at(-1)?.visibilityState,ee=f?T===`lost`?`lost`:T===`emerging`?`emerging`:f.citationState===V.cited?`cited`:`not-cited`:D===V.cited?`cited`:`not-cited`,k=f?.visibilityState??(O===`visible`?`visible`:O===`pending`?`pending`:`not-visible`),A=C?jo(C):w?1:jo(n.runs),j=C?Mo(C):w?1:Mo(n.runs),te=Oo(n,s),ne=(b??n.runs).map(e=>({runId:e.runId,citationState:e.citationState,createdAt:e.createdAt,model:te.get(e.runId)??null,answerMentioned:e.answerMentioned,visibilityState:e.visibilityState,visibilityTransition:e.visibilityTransition,mentionState:e.mentionState,mentionTransition:e.mentionTransition})),re=ko(ne),ie=x===`provider`&&re.length<=1?`model`:x,ae=Ao(ne),M=f?.citedCompetitorDomains??[],N=f?.mentionedCompetitorDomains??[],oe=[...new Set([...M,...N,...f?.competitorOverlap??[]])];a.push({id:`evidence_${e}_${o++}`,query:n.query,queryId:f?.queryId??null,sourceSnapshotId:f?.id??null,sourceRunId:f?.runId??null,queryClass:i?.classify(n.query)??null,provider:f?.provider??s,model:f?.model??null,location:f?.location??l,citationState:ee,answerMentioned:f?.answerMentioned,visibilityState:k,visibilityChangeLabel:No(E,j,{positive:`visible`,negative:`not visible`,first:`first visibility`}),changeLabel:No(T,A),answerSnippet:f?.answerText??``,citedDomains:f?.citedDomains??[],evidenceUrls:f?.citedUrls??[],citedCompetitorDomains:M,mentionedCompetitorDomains:N,mentionedCompetitorTerms:f?.mentionedCompetitorTerms??[],competitorDomains:oe,recommendedCompetitors:f?.recommendedCompetitors??[],matchedTerms:f?.matchedTerms??[],mentionIdentity:f?.mentionIdentity??null,relatedTechnicalSignals:[],groundingSources:f?.groundingSources??[],searchQueries:f?.searchQueries??[],summary:Po(k,E,n.query),runHistory:ne,historyScope:ie,modelsSeen:re,modelTransitions:ae})}}}}for(let t of r)s.has(t.query)||a.push({id:`evidence_${e}_${o++}`,query:t.query,queryId:t.id,sourceSnapshotId:null,sourceRunId:null,queryClass:i?.classify(t.query)??null,provider:``,model:null,location:null,citationState:`pending`,visibilityState:`pending`,visibilityChangeLabel:`Awaiting first run`,changeLabel:`Awaiting first run`,answerSnippet:``,citedDomains:[],evidenceUrls:[],citedCompetitorDomains:[],mentionedCompetitorDomains:[],mentionedCompetitorTerms:[],competitorDomains:[],recommendedCompetitors:[],matchedTerms:[],relatedTechnicalSignals:[],groundingSources:[],searchQueries:[],summary:`"${t.query}" has been added but no visibility run has been triggered yet.`,runHistory:[],historyScope:`query`,modelsSeen:[],modelTransitions:[]});return a}function Oo(e,t){let n=new Map,r=`${t}:`;for(let[t,i]of Object.entries(e.modelRuns??{})){if(!t.startsWith(r))continue;let e=t.slice(r.length),a=e===`unknown`?null:e;for(let e of i)n.set(e.runId,a)}return n}function ko(e){let t=new Set;for(let n of e)n.model&&t.add(n.model);return[...t]}function Ao(e){let t=[],n=null;for(let r of e){let e=r.model??null;e!==n&&n!==null&&t.push({runId:r.runId,createdAt:r.createdAt,fromModel:n,toModel:e}),n=e}return t}function jo(e){if(e.length===0)return 0;let t=e[e.length-1].citationState,n=0;for(let r=e.length-1;r>=0&&e[r].citationState===t;r--)n++;return n}function Mo(e){if(e.length===0)return 0;let t=e[e.length-1].visibilityState??`not-visible`,n=0;for(let r=e.length-1;r>=0&&(e[r].visibilityState??`not-visible`)===t;r--)n++;return n}function No(e,t,n){let r={positive:n?.positive??`cited`,negative:n?.negative??`not cited`,first:n?.first??`first citation`};switch(e){case`new`:return`First observation`;case`cited`:case`visible`:return t<=1?`${X(r.positive)} in latest run`:`${X(r.positive)} for ${t} runs`;case`lost`:return`Lost since last run`;case`emerging`:return X(r.first);case`not-cited`:case`not-visible`:return t<=1?`${X(r.negative)} in latest run`:`${X(r.negative)} across ${t} runs`;default:return e}}function X(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Po(e,t,n){switch(t){case`lost`:return`Mention was lost for "${n}". Your brand no longer appeared in the latest answer.`;case`emerging`:return`Your brand started appearing in AI answers for "${n}".`}switch(e){case`visible`:return`Your brand or domain is mentioned in AI answers for "${n}".`;case`pending`:return`"${n}" has been added but no run has been triggered yet.`;default:return`Your brand or domain was not mentioned in AI answers for "${n}".`}}function Fo(e){let t=vo(e.project),n=sn(nt(e.project)),r=Do(t.name,e.timeline,e.latestRunDetails,e.queries,n),i=[...e.runs].sort((e,t)=>t.createdAt.localeCompare(e.createdAt)).map(t=>Co(t,e.project.displayName||e.project.name));return e.overview?Lo(t,e.overview,r,i):zo(t,r,i)}function Io(e){return e.filter(e=>e.kind===G[`answer-visibility`]&&e.trigger!==gn.probe&&(e.status===H.completed||e.status===H.partial))}function Lo(e,t,n,r){let i=_o(t.topInsights);for(let e of t.attentionItems)e.id.startsWith(`insight_`)||i.push({id:e.id,tone:e.tone,title:e.title,detail:e.detail,actionLabel:e.actionLabel,actionGroup:`investigate`,affectedPhrases:[]});return{project:e,contextLabel:t.contextLabel,mentionSummary:t.scores.mention,visibilitySummary:t.scores.visibility,mentionShareSummary:t.scores.mentionShare,queryCounts:{cited:t.queryCounts.citedQueries,total:t.queryCounts.totalQueries},gapQueries:t.scores.gapQueries,mentionGaps:t.scores.mentionGaps,indexCoverage:t.scores.indexCoverage,providerScores:t.providerScores,competitorPressure:t.scores.competitorPressure,runStatus:t.scores.runStatus,movementComparison:t.movementComparison,insights:i,visibilityEvidence:n,competitors:t.competitors.map(e=>({id:e.id,domain:e.domain,aliases:e.aliases??[],autoAliases:e.autoAliasNames??[],citationCount:e.citationCount,totalQueries:e.totalQueries,pressureLabel:e.pressureLabel,citedQueries:e.citedQueries,movement:``,notes:``})),recentRuns:r.slice(0,5),visibilitySweeps:Io(r),suggestedQueries:t.suggestedQueries}}function Ro(){return{projectMentionSnapshots:0,competitorMentionSnapshots:0,combinedMentionSnapshots:0,perCompetitor:[],ranking:[],snapshotsWithAnswerText:0,snapshotsTotal:0,score:null}}function zo(e,t,n){let r={label:``,value:`No data`,delta:`Loading…`,tone:`neutral`,description:``,tooltip:``,trend:[]};return{project:e,contextLabel:`${e.country} / ${e.language.toUpperCase()}`,mentionSummary:{...r,label:`Mention Coverage`},visibilitySummary:{...r,label:`Citation Coverage`},mentionShareSummary:{...r,label:`Mention Share`,scope:`non-brand`,unavailable:!0,breakdown:Ro(),branded:Ro()},queryCounts:{cited:0,total:0},gapQueries:{...r,label:`Citation Gaps`},mentionGaps:{...r,label:`Mention Gaps`},indexCoverage:{...r,label:`Index Coverage`},providerScores:[],competitorPressure:{...r,label:`Competitor Pressure`},runStatus:{...r,label:`Run Status`},movementComparison:{hasPreviousRun:!1,comparable:!1,querySetChanged:!1,previousRunAt:null,currentQueryCount:0,previousQueryCount:0,comparableQueryCount:0,addedQueryCount:0,removedQueryCount:0,addedQueries:[],removedQueries:[]},insights:[],visibilityEvidence:t,competitors:[],recentRuns:n.slice(0,5),visibilitySweeps:Io(n),suggestedQueries:{rows:[],totalCandidates:0,skippedAlreadyTracked:0}}}function Bo(e){let t=vo(e.project),n=[...e.runs].sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),r=n.find(e=>e.kind===G[`answer-visibility`])??n[0]??e.overview?.latestRun?.run??void 0,i=e.project.displayName||e.project.name,a=r?Co(r,i):Vo(e.project.id,i),o=e.overview;if(!o)return{project:t,hasMeasurement:!1,mentionScore:0,mentionDelta:`No data`,mentionTone:`neutral`,lastRun:a,insight:`No runs completed yet.`,trend:[],competitorPressureLabel:`None`};let s=o.scores.mention,c=s.progress??0,l=o.queryCounts.mentionedQueries,u=o.queryCounts.totalQueries,d=o.providers.length;return{project:t,hasMeasurement:u>0&&s.progress!=null,mentionScore:c,mentionDelta:u>0?`${l} of ${u} queries`:`No data`,mentionTone:s.tone,providerCoverage:s.providerCoverage,lastRun:a,insight:u>0?`${l} of ${u} queries mentioned across ${d} provider${d===1?``:`s`}.`:`No runs completed yet.`,trend:s.trend??[],competitorPressureLabel:o.scores.competitorPressure.value,sentiment:o.sentiment}}function Vo(e,t){return{id:`none`,projectId:e,projectName:t,kind:G[`answer-visibility`],kindLabel:`No runs yet`,status:H.queued,trigger:gn.manual,createdAt:``,startedAt:``,duration:``,statusDetail:``,summary:`No runs yet`,triggerLabel:``}}function Ho(e,t){let n=[],r=[],i=[];for(let t of e){r.push(Fo(t)),i.push(Bo(t));let e=[...t.runs].sort((e,t)=>t.createdAt.localeCompare(e.createdAt));for(let r of e)n.push(Co(r,t.project.displayName||t.project.name))}n.sort((e,t)=>t.createdAt.localeCompare(e.createdAt));let a=e.length>0;return{portfolioOverview:{projects:i,attentionItems:a?Uo(r):[{id:`attention_setup`,tone:`neutral`,title:`No projects yet`,detail:`Create your first project using the setup wizard, CLI, or API.`,actionLabel:`Open setup`,href:`/setup`}],recentRuns:n.slice(0,5),systemHealth:[{id:`api`,label:`API`,tone:`positive`,detail:`Connected`,meta:`Real-time data`},{id:`provider`,label:`Gemini`,tone:`positive`,detail:`Configured`,meta:`Provider active`}],...a?{}:{emptyState:{title:`No projects yet`,detail:`Canonry becomes useful after one project, a small query set, and one competitor list are in place.`,ctaLabel:`Launch setup`,ctaHref:`/setup`}}},projects:r,runs:n,setup:{healthChecks:[{id:`api`,label:`API reachable`,detail:`API is responding.`,state:`ready`,guidance:`Required for project creation and run history.`},{id:`provider`,label:`Provider configured`,detail:`Gemini key is configured.`,state:`ready`,guidance:`Required for AI Visibility checks.`}],projectDraft:{name:``,canonicalDomain:``,country:`US`,language:`en`},queryImportState:{mode:`paste`,queryCount:0,preview:[]},competitorDraft:{domains:[],notes:`Use the CLI to add competitors.`},launchState:{enabled:a,ctaLabel:a?`Trigger run`:`Create a project first`,summary:a?`Ready to run.`:`Create a project first to launch a run.`}},settings:{providerStatuses:(t?.providers??[]).map(e=>({name:e.name,displayName:e.displayName,...e.kind?{kind:e.kind}:{},keyUrl:e.keyUrl,modelHint:e.modelHint,model:e.model,defaultModel:e.defaultModel,state:e.configured?`ready`:`needs-config`,detail:e.configured?`Provider is configured.`:e.name.toLowerCase()===`local`?`Base URL is missing.`:`API key is missing.`,quota:e.quota})),google:{state:t?.google?.configured?`ready`:`needs-config`,detail:t?.google?.configured?`Google OAuth app credentials are configured. Project-level GSC connections can be created from the dashboard.`:`Google OAuth client ID and client secret are not configured yet.`},bing:{state:t?.bing?.configured?`ready`:`needs-config`,detail:t?.bing?.configured?`Bing Webmaster Tools API key is configured. Project-level Bing connections can be created from the dashboard.`:`Bing Webmaster Tools API key is not configured yet.`},selfHostNotes:[`Configuration is stored in ~/.canonry/config.yaml.`,`The local config file is the source of truth for authentication credentials.`,`Google OAuth app credentials and per-domain Google tokens are stored in local config, not the database.`,`Database is SQLite at ~/.canonry/data.db.`,`API key was auto-generated during canonry init.`],bootstrapNote:`Use the UI, CLI, or ~/.canonry/config.yaml to manage settings. Authentication credentials persist to local config.`}}}function Uo(e){let t=[];for(let n of e){let e=n.visibilityEvidence.filter(e=>e.citationState===`lost`);e.length>0&&t.push({id:`attention_${n.project.id}_lost`,tone:`negative`,title:`${n.project.displayName||n.project.name} lost citations`,detail:`${e.length} quer${e.length>1?`ies`:`y`} lost citation.`,actionLabel:`Open project`,href:`/projects/${encodeURIComponent(n.project.name)}`});let r=n.recentRuns.filter(e=>e.status===H.running||e.status===H.queued);r.length>0&&t.push({id:`attention_${n.project.id}_active`,tone:`neutral`,title:`${n.project.displayName||n.project.name} has active runs`,detail:`${r.length} run${r.length>1?`s`:``} in progress.`,actionLabel:`View runs`,href:`/runs`})}return t.length===0&&t.push({id:`attention_stable`,tone:`positive`,title:`All projects stable`,detail:`No citation losses or active runs to flag.`}),t}var Wo=(0,K.createContext)(null);Wo.Provider;function Go(){return(0,K.useContext)(Wo)}function Ko(e,t={}){let n=Go(),r=e??n?.dashboard??null,i=t.includeSettings??!0,a=t.includeOverviews??!0,o=t.pauseProjectPolling??!1,{isAdmin:s}=Jn(),c=!r&&a&&!ze(),l=R({...fr({client:U,query:{kind:`answer-visibility`}}),enabled:!r,staleTime:Zn,refetchInterval:e=>e.state.data?.some(e=>e.status===`running`||e.status===`queued`)?3e3:Zn}),u=R({...fr({client:U,query:{excludeKinds:[G[`bing-inspect`],G[`traffic-sync`]],limit:5}}),enabled:c,staleTime:Zn,refetchInterval:e=>e.state.data?.some(e=>e.status===H.running||e.status===H.queued)?3e3:Zn}),d=R({...cr({client:U}),enabled:!r,refetchInterval:o?!1:e=>{let t=e.state.data,n=l.data?.some(e=>e.status===`running`||e.status===`queued`);return(t?.length??0)===0||n?tr:or}}),f=R({...sr({client:U}),enabled:!r&&i&&s}),p=d.data??[],m=l.data??[],h=ke({queries:p.map(e=>{let t=m.filter(t=>t.projectId===e.id),n=t.filter(e=>(e.status===`completed`||e.status===`partial`)&&e.kind===`answer-visibility`&&e.trigger!==`probe`).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),i=n.length>0?n[0].id:`no-run`;return{queryKey:[`project-overview-slim`,e.id,i],queryFn:async()=>{let n=await xt(e.name).catch(()=>null);return{project:e,runs:t,queries:[],competitors:[],timeline:[],latestRunDetails:[],previousRunDetails:[],gscCoverage:null,bingCoverage:null,dbInsights:null,overview:n}},enabled:!r&&a&&d.isSuccess&&l.isSuccess,staleTime:ir}})}),g=!a||h.every(e=>e.isSuccess),_=(0,K.useMemo)(()=>{if(r)return r;if(!d.data||!l.data||p.length>0&&!g)return null;let e=new Map(p.map(e=>[e.id,e])),t=Ho(a?h.map(t=>{if(!t.data)return null;let n=e.get(t.data.project.id);return n?{...t.data,project:n,runs:m.filter(e=>e.projectId===n.id)}:null}).filter(e=>e!=null):p.map((e,t)=>{let n=h[t]?.data;return{project:e,runs:m.filter(t=>t.projectId===e.id),queries:[],competitors:[],timeline:[],latestRunDetails:[],previousRunDetails:[],gscCoverage:null,bingCoverage:null,dbInsights:null,overview:n?.overview??null}}),f.data??null);return c&&(t.portfolioOverview.recentRuns=(u.data??[]).filter(t=>t.trigger!==gn.probe&&e.has(t.projectId)).map(t=>{let n=e.get(t.projectId);return Co(t,n.displayName||n.name)})),t},[r,d.data,l.data,f.data,a,g,h,p,m,c,u.data]),v=!r&&(d.isError||l.isError),y=!r&&!_&&!v,b=(0,K.useCallback)(async()=>{let e=[d.refetch(),l.refetch(),...c?[u.refetch()]:[],...a?h.map(e=>e.refetch()):[]];i&&s&&e.push(f.refetch()),await Promise.all(e)},[i,s,a,c,u.refetch,h,d.refetch,l.refetch,f.refetch]);return{dashboard:_,isLoading:y,isError:v,activityLoading:c&&u.isPending,activityError:c&&u.isError,refetch:b}}function qo(e){return JSON.stringify(e.filter(e=>e.kind===`answer-visibility`&&e.trigger!==`probe`&&(e.status===`completed`||e.status===`partial`)).map(e=>[e.id,e.status]).sort(([e],[t])=>e.localeCompare(t)))}async function Jo(e,t,n=`active`){let r=e=>{let n=e.queryKey[0];return n?._id===`getApiV1ProjectsByNameAnalyticsCompetitors`&&n.path?.name===t};return n===`active`&&await e.cancelQueries({predicate:r}),e.invalidateQueries({predicate:r,refetchType:n})}function Yo(e,t,n){let r=ge(),i=(0,K.useRef)({projectName:e,revision:t,enabled:n});(0,K.useEffect)(()=>{let a=i.current;i.current={projectName:e,revision:t,enabled:n},n&&a.enabled&&a.projectName===e&&a.revision!==t&&Jo(r,e)},[n,e,r,t])}var Xo=20;function Zo(e,t={}){let n=ge(),r=Go(),i=(0,K.useMemo)(()=>!r||!e?null:r.dashboard.projects.find(t=>t.project.name===e)??null,[r,e]),a=R({...Sr({client:U,path:{name:e??``}}),enabled:!!e&&!i,staleTime:ir,refetchOnWindowFocus:`always`}),o=R({...vr({client:U,path:{name:e??``},query:{kind:`answer-visibility`}}),enabled:!!e,staleTime:Zn,refetchOnWindowFocus:`always`,refetchInterval:e=>e.state.data?.some(e=>e.projectId===a.data?.id&&(e.status===`running`||e.status===`queued`))?3e3:Zn}),s=a.data??null,c=(0,K.useMemo)(()=>s?(o.data??[]).filter(e=>e.projectId===s.id):[],[s,o.data]),{latestRunIds:l,latestRunIdsKey:u,latestVisibilityRevision:d}=(0,K.useMemo)(()=>{let e=c.filter(e=>(e.status===`completed`||e.status===`partial`)&&e.kind===`answer-visibility`&&e.trigger!==`probe`).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),t=e[0]?.createdAt??null,n=t?e.filter(e=>e.createdAt===t).map(e=>e.id):[];return{latestRunIds:n,latestRunIdsKey:[...n].sort().join(`,`),latestVisibilityRevision:t?`${t}:${[...n].sort().join(`,`)}`:`none`}},[c]),f=!!s&&!!e&&o.isSuccess,p=R({queryKey:[`project-dashboard-full`,s?.id??null,u||`none`,`overview`],queryFn:async()=>({project:s,overview:await xt(e)}),enabled:f&&t.overview===!0,staleTime:ir,refetchOnWindowFocus:`always`}),m=R({queryKey:[`project-dashboard-full`,s?.id??null,u||`none`,`evidence`],queryFn:async()=>{let[t,n,r]=await Promise.all([Ze(e),vn(e,void 0,Xo),Promise.all(l.map(e=>Ye(e)))]);return{project:s,queries:t,timeline:n,latestRunDetails:r}},enabled:f&&t.evidence===!0,staleTime:ir,refetchOnWindowFocus:`always`}),h=(0,K.useMemo)(()=>{if(!s||!o.data)return i;let e=t.evidence?m.data:void 0,n=Fo({project:s,runs:c,queries:e?.queries??[],timeline:e?.timeline??[],latestRunDetails:e?.latestRunDetails??[],previousRunDetails:[],competitors:[],overview:t.overview?p.data?.overview??null:null});return i&&!(t.overview&&p.data)?{...i,project:n.project,recentRuns:n.recentRuns,visibilitySweeps:n.visibilitySweeps,visibilityEvidence:e?n.visibilityEvidence:i.visibilityEvidence}:n},[s,c,m.data,p.data,i,t.evidence,t.overview,o.data]),g=(0,K.useCallback)(async()=>{await Promise.all([a.refetch(),o.refetch(),n.invalidateQueries({queryKey:[`project-dashboard-full`,s?.id??null]})])},[a.refetch,o.refetch,n,s?.id]),_=a.isError||o.isError,v=!i&&(a.isLoading||o.isLoading),y=!!e&&t.overview===!0&&!i&&!_&&p.isPending,b=!!e&&t.evidence===!0&&!i&&!_&&m.isPending;return{commandCenter:h,project:s,isLoading:v,isError:_,overviewLoading:y,overviewError:t.overview===!0&&p.isError&&!p.data,evidenceLoading:b,evidenceError:t.evidence===!0&&m.isError&&!m.data,latestVisibilityRevision:d,competitorHistoryRevision:qo(c),refetch:g}}var Qo=[`health`];async function $o(){let e=await Wt(`/health`,`API`);return{apiStatus:e,workerStatus:jn()&&e.state===`ok`?{label:`Worker`,state:`disabled`,detail:`Background execution is disabled in this public demo.`}:e.state===`ok`?{label:`Worker`,state:`ok`,detail:`In-process job runner`}:{label:`Worker`,state:e.state,detail:`Depends on API health check · ${e.detail}`,statusCode:e.statusCode,hint:e.hint?`Worker status is inferred from API health in this deployment mode. ${e.hint}`:`Worker status is inferred from API health in this deployment mode.`}}}function es(e,t){return R({queryKey:Qo,queryFn:$o,enabled:e,refetchInterval:15e3,initialData:t})}function ts(e){return R({...ur({client:U,path:{id:e??``}}),enabled:!!e,refetchInterval:e=>{let t=e.state.data?.status;return t===`running`||t===`queued`?3e3:!1}})}function ns(){let e=be(),t=xe({strict:!1}),n=De({select:e=>e.location.pathname});return{runId:t.runId??null,evidenceId:t.evidenceId??null,openRun:t=>{e({to:n,from:Uf.to,search:e=>({...e,runId:t,evidenceId:void 0})})},openEvidence:t=>{e({to:n,from:Uf.to,search:e=>({...e,evidenceId:t,runId:void 0})})},closeDrawer:()=>{e({to:n,from:Uf.to,search:e=>({...e,runId:void 0,evidenceId:void 0})})}}}var rs={negative:`toast-card-negative`,caution:`toast-card-caution`,positive:`toast-card-positive`,neutral:`toast-card-neutral`};function is(e){if(e.cta)return`${e.cta.label}: ${e.title}`}function as(){let e=(0,K.useSyncExternalStore)(rr,ar,ar),t=be(),{openRun:n}=ns(),r=(0,K.useCallback)(e=>{er(e)},[]),i=(0,K.useCallback)(e=>{e.cta&&(e.cta.intent===`open-run-drawer`?n(e.cta.runId):t({to:`/runs`}),er(e.id))},[t,n]);return e.length===0?null:(0,q.jsx)(`div`,{className:`toast-viewport`,"aria-label":`Notifications`,children:e.map(e=>(0,q.jsxs)(`section`,{role:e.tone===`negative`?`alert`:`status`,"aria-live":e.tone===`negative`?`assertive`:`polite`,"data-state":e.state,className:`toast-card ${rs[e.tone]}`,children:[(0,q.jsxs)(`div`,{className:`toast-copy`,children:[(0,q.jsx)(`p`,{className:`toast-title`,children:e.title}),e.detail?(0,q.jsx)(`p`,{className:`toast-detail`,children:e.detail}):null,e.cta?(0,q.jsx)(`button`,{type:`button`,className:`toast-action`,onClick:()=>i(e),"aria-label":is(e),children:e.cta.label}):null]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>r(e.id),className:`toast-dismiss`,"aria-label":`Dismiss`,children:(0,q.jsx)(ie,{className:`size-3.5`})})]},e.id))})}var os=`https://github.com/Canonry/canonry`,ss=`https://canonry.ai`,cs=`Run it from your agent with the MCP server, API, CLI, and plugins for Claude Code and Codex.`,ls=[{title:`Visibility`,links:[[`AI visibility`,`/projects/summit-roofing`],[`Search engines`,`/projects/summit-roofing/search-console`],[`Traffic & conversions`,`/projects/summit-roofing/conversions`]]},{title:`Portfolio`,links:[[`Properties & markets`,`/projects/harbor-resorts`],[`Queries & research`,`/projects/harbor-resorts/queries`],[`Activity`,`/projects/harbor-resorts/activity`]]},{title:`Website`,links:[[`Site health`,`/projects/summit-roofing/technical-aeo`],[`Local presence`,`/projects/summit-roofing/local`],[`Backlinks`,`/projects/summit-roofing/backlinks`]]}];function us(){let e=(0,K.useId)();if(!jn())return null;let t=bn(),r=`${e}-new-tab`,i={target:`_blank`,rel:`noopener noreferrer`,"aria-describedby":r};return(0,q.jsxs)(`aside`,{className:`demo-banner`,"aria-label":`Public demo`,children:[(0,q.jsx)(`p`,{className:`demo-banner-name`,children:`Canonry demo`}),(0,q.jsx)(`p`,{className:`demo-banner-facts`,children:`View only. Fictional data.`}),(0,q.jsx)(`p`,{className:`demo-banner-agent`,children:cs}),(0,q.jsxs)(`div`,{className:`demo-banner-actions`,children:[(0,q.jsxs)(`a`,{className:`demo-banner-primary`,href:ss,...i,children:[`canonry.ai`,(0,q.jsx)(n,{"aria-hidden":`true`,size:14})]}),(0,q.jsxs)(`a`,{className:`demo-banner-secondary`,href:os,...i,children:[(0,q.jsx)(oe,{"aria-hidden":`true`,size:15}),`GitHub`]}),(0,q.jsxs)(`details`,{onKeyDown:e=>{e.key===`Escape`&&(e.currentTarget.open=!1,e.currentTarget.querySelector(`summary`)?.focus())},children:[(0,q.jsxs)(`summary`,{children:[`Explore `,(0,q.jsx)(o,{"aria-hidden":`true`,size:14})]}),(0,q.jsxs)(`div`,{className:`demo-banner-panel`,children:[(0,q.jsx)(`p`,{className:`demo-banner-panel-agent`,children:cs}),(0,q.jsxs)(`nav`,{className:`demo-banner-examples`,"aria-label":`Demo examples`,children:[(0,q.jsx)(`a`,{href:`${t}/projects/summit-roofing`,children:`Standard business`}),(0,q.jsx)(`a`,{href:`${t}/projects/harbor-resorts`,children:`Property portfolio`})]}),(0,q.jsx)(`nav`,{className:`demo-banner-features`,"aria-label":`Demo feature directory`,children:ls.map(({title:e,links:n})=>(0,q.jsxs)(`section`,{"aria-label":e,children:[(0,q.jsx)(`h2`,{children:e}),(0,q.jsx)(`ul`,{children:n.map(([e,n])=>(0,q.jsx)(`li`,{children:(0,q.jsx)(`a`,{href:`${t}${n}`,children:e})},n))})]},e))})]})]})]}),(0,q.jsx)(`span`,{id:r,hidden:!0,children:`Opens in a new tab`})]})}function ds(e){switch(e){case G[`answer-visibility`]:return`AI Visibility check`;case G[`gsc-sync`]:return`GSC sync`;case G[`inspect-sitemap`]:return`Sitemap inspection`;case G[`ga-sync`]:return`GA sync`;case G[`traffic-sync`]:return`Traffic sync`;case G[`bing-inspect`]:return`Bing URL inspection`;case G[`bing-inspect-sitemap`]:return`Bing sitemap inspection`;case G[`site-audit`]:return`Technical AEO audit`;case G[`backlink-extract`]:return`Backlink extract`;case G[`aeo-discover-seed`]:return`Discovery (seed phase)`;case G[`aeo-discover-probe`]:return`Discovery (probe phase)`;case G[`gbp-sync`]:return`Business Profile sync`;case G[`ads-sync`]:return`ChatGPT ads sync`;case G[`google-ads-sync`]:return`Google Ads sync`;case G[`gtm-sync`]:return`Tag Manager sync`;case G[`seo-sync`]:return`SEO data refresh`}}function fs(e){return e===`running`?`Running`:e===`queued`?`Queued`:e===`partial`?`Partial`:e===`completed`?`Completed`:e===`failed`?`Failed`:e===`cancelled`?`Cancelled`:`Starting`}function ps(){let e=(0,K.useSyncExternalStore)(wi,Ci,Ci),t=(0,K.useMemo)(()=>Object.values(e.runs),[e.runs]),n=t.length>0,r=R({...fr({client:U}),enabled:n,staleTime:Zn}),i=(0,K.useMemo)(()=>new Map((r.data??[]).map(e=>[e.id,e.status])),[r.data]);if(!n)return null;let a=t.map(e=>({...e,status:i.get(e.runId)??e.lastAnnouncedStatus})),s=a.length===1?ds(a[0].kind):`${a.length} active tasks`;return(0,q.jsxs)(`div`,{className:`task-center`,children:[(0,q.jsxs)(`p`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:[a.length,` active `,a.length===1?`task`:`tasks`,`.`,` `,a.map(e=>`${ds(e.kind)} ${fs(e.status)}`).join(`. `),`.`]}),(0,q.jsxs)(`details`,{className:`task-center-details`,children:[(0,q.jsxs)(`summary`,{className:`task-center-trigger`,children:[(0,q.jsx)(O,{className:`size-3.5 shrink-0 motion-safe:animate-spin`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`task-center-summary`,children:s}),(0,q.jsx)(`span`,{className:`task-center-count`,"aria-hidden":`true`,children:a.length}),(0,q.jsx)(o,{className:`task-center-chevron size-3.5 shrink-0`,"aria-hidden":`true`})]}),(0,q.jsxs)(`div`,{className:`task-center-panel`,children:[(0,q.jsxs)(`div`,{className:`task-center-heading`,children:[(0,q.jsx)(`span`,{children:`Active tasks`}),(0,q.jsx)(`span`,{className:`tabular-nums text-faint`,children:a.length})]}),(0,q.jsx)(`ul`,{className:`task-center-list`,children:a.map(e=>(0,q.jsxs)(`li`,{className:`task-center-item`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`p`,{className:`truncate text-[13px] font-medium text-strong`,children:ds(e.kind)}),(0,q.jsx)(`p`,{className:`mt-0.5 truncate text-xs text-muted`,children:e.projectLabel??e.projectId})]}),(0,q.jsx)(xn,{tone:e.status===`failed`?`negative`:e.status===`partial`?`caution`:`neutral`,children:fs(e.status)})]},e.runId))}),(0,q.jsx)(B,{to:`/runs`,className:`task-center-footer-link`,children:`View all runs`})]})]})]})}var ms={scope:`all`,queryClass:`all`},hs=[`all`,`non-brand`,`branded`];function gs(e){return typeof e==`string`&&hs.includes(e)}function _s(e){let t=gs(e.class)?e.class:ms.queryClass,n=e.scope;if(typeof n!=`string`||n===`all`||n.length===0)return{scope:`all`,queryClass:t};let r=n.startsWith(`group:`)?n.slice(6):``;return r?{scope:`group`,groupKey:r,queryClass:t}:{scope:`all`,queryClass:t}}function vs(e,t){return t===null||e===null?!1:e!==t}function ys(e){return{scope:e.scope===`group`&&e.groupKey?`group:${e.groupKey}`:void 0,class:e.queryClass===ms.queryClass?void 0:e.queryClass}}function bs(e,t){if(!(typeof e!=`string`||e.length>16384||!t))try{let n=JSON.parse(e);if(typeof n!=`object`||!n||Array.isArray(n))return;let r=n,i=e=>typeof e==`string`&&e.trim().length>0,a=e=>e===null||i(e);return r.queryKey!==t||!i(r.provider)||r.queryClass!==`branded`&&r.queryClass!==`non-brand`&&r.queryClass!==`unknown`||!a(r.model)||!a(r.location)||!a(r.runId)||r.revision!==null&&(typeof r.revision!=`number`||!Number.isSafeInteger(r.revision)||r.revision<=0)?void 0:{queryKey:t,queryClass:r.queryClass,provider:r.provider,model:r.model,location:r.location,runId:r.runId,revision:r.revision}}catch{return}}function xs(e){let t=t=>typeof e[t]==`string`&&e[t]!==``?e[t]:void 0,n=_s({scope:t(`scope`),class:t(`class`)}),r=t(`measurementScope`)??(n.scope===`group`?`group`:`project`),i=t(`measurementScopeKey`)??(t(`measurementScope`)?void 0:n.groupKey),a=t(`queryClass`)??t(`class`),o={measurementScope:i&&(r===`group`||r===`market`||r===`property`)?r:`project`,queryClass:a===`unknown`||gs(a)?a:ms.queryClass};o.measurementScope!==`project`&&(o.measurementScopeKey=i);for(let[e,n]of[[`measurementMarketKey`,`marketKey`],[`measurementProvider`,`provider`],[`measurementModel`,`model`],[`measurementLocation`,`location`],[`measurementFrom`,`from`],[`measurementTo`,`to`],[`measurementRunId`,`measurementRunId`],[`measurementQueryKey`,`queryKey`]]){let r=t(e);r!==void 0&&(o[n]=r)}let s=Number(e.measurementRevision);Number.isSafeInteger(s)&&s>0&&(o.revision=s);let c=bs(e.measurementAnswer,o.queryKey);return c&&(o.answer=c),o}function Ss(e){return{scope:e.measurementScope,scopeKey:e.measurementScopeKey,marketKey:e.marketKey,queryClass:e.queryClass,provider:e.provider,model:e.model,location:e.location,from:e.from,to:e.to,revision:e.revision,runId:e.measurementRunId,limit:25}}function Cs(e,t){let n={...e,...t};return[`measurementScope`,`measurementScopeKey`,`measurementMarketKey`,`queryClass`,`measurementProvider`,`measurementModel`,`measurementLocation`,`measurementFrom`,`measurementTo`,`measurementRevision`,`measurementRunId`].some(e=>e in t)?(n.measurementQueryKey=t.measurementQueryKey,n.measurementAnswer=t.measurementAnswer):`measurementQueryKey`in t&&!(`measurementAnswer`in t)&&(n.measurementAnswer=void 0),`measurementScope`in t&&(n.scope=void 0,`measurementMarketKey`in t||(n.measurementMarketKey=void 0),n.measurementQueryKey=void 0,t.measurementScope===`project`&&(n.measurementScopeKey=void 0)),`queryClass`in t&&(n.class=void 0),n}function ws(e){return{...e,onboarding:void 0,manageQueries:void 0,siteHealthRunId:void 0,siteScan:void 0,setupProject:void 0}}function Ts(e,t){let n=/\/properties\/([^/]+)/.exec(e),r=xs(t);if(n)return{view:`property`,selection:tn.parse({scope:`property`,scopeKey:decodeURIComponent(n[1]),queryClass:r.queryClass,limit:10})};if(e.endsWith(`/technical-aeo`))return{view:`site-health`};if(e.endsWith(`/seo-data`))return{view:`seo`,...typeof t.seoProfileId==`string`?{seoProfileId:t.seoProfileId}:{},...typeof t.seoRunId==`string`?{seoRunId:t.seoRunId}:{}};if(e.endsWith(`/queries`)&&t.queryWorkspace===`research`)return{view:`project`};let i=/^\/projects\/[^/]+\/?$/.test(e);if(i||e.endsWith(`/queries`)){let t=tn.safeParse(Ss(e.endsWith(`/queries`)?{measurementScope:r.measurementScope,measurementScopeKey:r.measurementScopeKey,queryClass:r.queryClass}:r));return{view:i?`visibility`:`queries`,...t.success?{selection:t.data}:{unavailableReason:`The current measurement filters are invalid. Correct them before asking Aero about this view.`}}}return{view:`project`}}var Es=e(me(),1);function Ds(e,t={}){let{threshold:n=80}=t,r=(0,K.useRef)(null),i=(0,K.useRef)({scrollHeight:0,wasAtEnd:!0});function a(e){return e.scrollHeight-e.scrollTop-e.clientHeight}function o(){let e=r.current;return!e||a(e)<=n}function s(){let e=r.current;e&&(e.scrollTop=e.scrollHeight,i.current.wasAtEnd=!0,i.current.scrollHeight=e.scrollHeight)}return(0,K.useEffect)(()=>{let e=r.current;if(!e)return;let t=()=>{i.current.wasAtEnd=a(e)<=n};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[n]),(0,K.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=e.scrollHeight;t>i.current.scrollHeight&&i.current.wasAtEnd&&(e.scrollTop=t),i.current.scrollHeight=t},e),(0,K.useEffect)(()=>{let e=r.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{let t=e.scrollHeight;t>i.current.scrollHeight&&i.current.wasAtEnd&&(e.scrollTop=t),i.current.scrollHeight=t});return t.observe(e),e.firstElementChild&&t.observe(e.firstElementChild),()=>t.disconnect()},[]),{ref:r,scrollToEnd:s,isAtEnd:o}}var Os=`AI Visibility checks are run by your Canonry team`,ks=`Scans are run by your Canonry team`,As=`Next check unavailable`,js=`Check running…`,Ms=`Next check:`;function Ns(e,t){try{return new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,timeZone:t??`UTC`}).format(new Date(e))}catch{return null}}function Ps({projectName:e,kind:t=G[`answer-visibility`],running:n=!1,loadSchedule:r=!0}){let i=t===G[`site-audit`],a=R({...pr({client:U,path:{name:e},query:{kind:t}}),enabled:r&&!!e,retry:!1,refetchInterval:6e4}),o=a.isError?void 0:a.data,s=o?.enabled&&o.nextRunAt?new Date(o.nextRunAt):null,c=s&&Number.isFinite(s.getTime())?i?s.toLocaleString(`en-GB`,{weekday:`long`,day:`numeric`,month:`short`,hour:`2-digit`,minute:`2-digit`,timeZone:`UTC`,hourCycle:`h23`}):Ns(s.toISOString(),o?.timezone):null,l=(a.error instanceof Pt?a.error.code:a.error?.error?.code)===`NOT_FOUND`,u=!c||l||!o?.enabled;return(0,q.jsx)(`p`,{className:`text-sm text-secondary`,role:`status`,children:i?(0,q.jsxs)(q.Fragment,{children:[n&&(0,q.jsx)(`span`,{className:`text-neutral`,children:`Scan running… · `}),c&&s?(0,q.jsxs)(q.Fragment,{children:[`Next scan `,(0,q.jsxs)(`time`,{dateTime:s.toISOString(),children:[c,` UTC`]}),` · managed by your Canonry team`]}):ks]}):n?js:u?As:c&&s?(0,q.jsxs)(q.Fragment,{children:[Ms,` `,(0,q.jsx)(`time`,{dateTime:s.toISOString(),children:c})]}):As})}var Fs=300,Is=400,Ls=900,Rs=32,zs=28,Bs=0;function Vs(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Hs(){return new DOMException(`Preview stopped`,`AbortError`)}function Us(e,t){return t?.aborted?Promise.reject(Hs()):new Promise((n,r)=>{let i=()=>{clearTimeout(a),r(Hs())},a=setTimeout(()=>{t?.removeEventListener(`abort`,i),n()},e);t?.addEventListener(`abort`,i,{once:!0})})}function Ws(e){let t=e.match(/\S+\s*|\s+/g)??[];if(t.length<2)return[];let n=Math.ceil(t.length/Rs),r=[];for(let e=n;e<t.length;e+=n)r.push(t.slice(0,e).join(``));return r}function Gs(e){return typeof e==`string`?e:JSON.stringify(e??null)}async function Ks({starter:e,signal:t,onEvent:n,reducedMotion:r=!1}){let i=async e=>{if(t?.aborted)throw Hs();r||await Us(e,t)},a=Date.now(),o=++Bs;await i(Fs);for(let[t,r]of e.steps.entries()){let{name:a,label:s,arguments:c,result:l,durationMs:u}=r.tool,d=`preview-${e.id}-${o}-${t}`;n({type:`message_end`,message:{role:`assistant`,timestamp:Date.now(),stopReason:`toolUse`,content:[...r.text?[{type:`text`,text:r.text}]:[],{type:`toolCall`,id:d,name:a,arguments:c}]}}),n({type:`tool_execution_start`,toolCallId:d,toolName:a,label:s,args:c}),await i(Math.min(Ls,Math.max(Is,u))),n({type:`tool_execution_end`,toolCallId:d,toolName:a,result:l,isError:!1}),n({type:`message_end`,message:{role:`toolResult`,toolCallId:d,timestamp:Date.now(),isError:!1,aeroToolLabel:s,aeroDurationMs:u,content:[{type:`text`,text:Gs(l)}]}})}if(!r){for(let t of Ws(e.answer))await i(zs),n({type:`message_update`,message:{role:`assistant`,content:[{type:`text`,text:t}]},assistantMessageEvent:{}});await i(zs)}n({type:`message_end`,message:{role:`assistant`,timestamp:Date.now(),stopReason:`stop`,content:[{type:`text`,text:e.answer}]}}),n({type:`aero_turn_status`,status:{reason:`completed`,toolCalls:e.steps.length,modelCalls:e.steps.length+1,durationMs:Date.now()-a}})}async function qs(e){try{return await e.json()}catch{return{}}}function Js(){return typeof window<`u`&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath.replace(/\/$/,``)+`/api/v1`:`/api/v1`}var Ys=Js();function Xs(e){e===401&&Ht()}async function Zs(e){let t=await fetch(`${Ys}/projects/${encodeURIComponent(e)}/agent/transcript`,{credentials:`include`});if(!t.ok){Xs(t.status);let e=await qs(t);throw new Pt(e.error?.message??`transcript fetch failed: ${t.status}`,t.status,e.error?.code)}return await t.json()}async function Qs(e){let t=await fetch(`${Ys}/projects/${encodeURIComponent(e)}/agent/preview`,{credentials:`include`});if(!t.ok){Xs(t.status);let e=await qs(t);throw new Pt(e.error?.message??`preview fetch failed: ${t.status}`,t.status,e.error?.code)}return await t.json()}async function $s(e){let t=await fetch(`${Ys}/projects/${encodeURIComponent(e)}/agent/transcript`,{method:`DELETE`,credentials:`include`});if(!t.ok){Xs(t.status);let e=await qs(t);throw new Pt(e.error?.message??`reset failed: ${t.status}`,t.status,e.error?.code)}}async function ec({project:e,prompt:t,conversationId:n,provider:r,modelId:i,scope:a,profile:o,context:s,limits:c,signal:l,onEvent:u}){let d={prompt:t};n!==void 0&&(d.conversationId=n),r&&(d.provider=r),i&&(d.modelId=i),a&&(d.scope=a),o&&(d.profile=o),s&&(d.context=s),c&&(d.limits=c);let f=await fetch(`${Ys}/projects/${encodeURIComponent(e)}/agent/prompt`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify(d),signal:l});if(!f.ok||!f.body){Xs(f.status),Mn({method:`POST`,route:`/api/v1/projects/{name}/agent/prompt`,status:f.status});let e=await qs(f);throw new Pt(e.error?.message??`prompt failed: ${f.status}`,f.status,e.error?.code)}Ge(`aero.send`);let p=!1,m=f.body.getReader(),h=new TextDecoder,g=``,_=()=>{m.cancel().catch(()=>{})};l?.addEventListener(`abort`,_,{once:!0}),l?.aborted&&_();try{for(;;){let{value:e,done:t}=await m.read();if(t)break;g+=h.decode(e,{stream:!0});let n=g.indexOf(`
13
+ `),t=[],n=[],r=0,i=()=>{if(n.length===0)return;let e=n.join(` `).trim();e&&t.push((0,q.jsx)(`p`,{className:t.length>0?`mt-2.5`:``,children:Za(e,A)},r++)),n=[]};for(let a of e){let e=a.trim();if(/^[-\u2013\u2014]{3,}$/.test(e)){i(),t.push((0,q.jsx)(`hr`,{className:`border-default my-3`},r++));continue}let o=e.match(/^(#{1,3})\s+(\S.*)$/);if(o){i();let e=o[1].length,n=o[2].replace(/^[\p{Emoji}\p{Emoji_Component}\s]+/u,``).trim()||o[2],a=e===1?`text-[13px] font-semibold text-heading mt-4 mb-1`:e===2?`text-xs font-semibold text-strong mt-3 mb-0.5`:`text-xs font-medium text-neutral mt-2`;t.push((0,q.jsx)(`p`,{className:a,children:Za(n,A)},r++))}else e===``?i():n.push(e)}return i(),t})()}),C.answerSnippet.length>280&&(0,q.jsx)(`button`,{type:`button`,className:`mt-1.5 text-xs text-muted hover:text-neutral transition-colors`,onClick:()=>i(!r),children:r?`↑ Collapse`:`↓ Show full answer`})]}),!C.answerSnippet&&!d&&(0,q.jsx)(`div`,{className:`rounded-lg border border-subtle bg-surface-subtle px-4 py-8 text-center text-faint text-sm`,children:`No answer text recorded for this run`}),C.searchQueries.length>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`drawer-section-label flex items-center`,children:[(0,q.jsx)(`span`,{children:`Web searches the model ran`}),(0,q.jsx)(Tr,{text:`The search queries this AI model issued while researching your prompt. They reveal how the model reformulated your query — the phrasings worth optimizing your content for. Distinct from grounding sources (what it found) and citations (what it linked).`})]}),(0,q.jsx)(`ul`,{className:`grid gap-1`,children:C.searchQueries.map((e,t)=>(0,q.jsxs)(`li`,{className:`flex items-start gap-2 text-sm text-neutral`,children:[(0,q.jsx)(te,{className:`size-3.5 mt-0.5 shrink-0 text-faint`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`break-words`,children:e})]},`${t}-${e}`))})]}),!S&&e.relatedTechnicalSignals.length>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`drawer-section-label`,children:T?`Why you're visible`:`What to fix`}),(0,q.jsx)(`div`,{className:`action-items-list`,children:e.relatedTechnicalSignals.map((e,t)=>(0,q.jsxs)(`div`,{className:`action-item`,children:[(0,q.jsx)(`svg`,{className:`action-item-icon ${T?`text-positive-400`:`text-caution-400`}`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:T?(0,q.jsx)(`path`,{d:`M3 8l3.5 3.5L13 4.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`circle`,{cx:`8`,cy:`8`,r:`7`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,q.jsx)(`path`,{d:`M8 5v3.5M8 10.5v0`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}),(0,q.jsx)(`span`,{className:`action-item-text`,children:e})]},t))})]}),C.summary&&(0,q.jsx)(`p`,{className:`text-xs text-faint border-t border-subtle pt-3 mt-1`,children:C.summary})]}),(0,q.jsxs)(`div`,{className:`evidence-modal-sidebar`,children:[(E||D)&&(0,q.jsxs)(`div`,{className:`sidebar-tabs`,children:[(0,q.jsx)(`button`,{className:`sidebar-tab ${a===`mentions`?`sidebar-tab--active`:``}`,onClick:()=>o(`mentions`),type:`button`,title:`Canonry's answer-level visibility assessment and any company names extracted from the answer text.`,children:`Mentions`}),(0,q.jsx)(`button`,{className:`sidebar-tab ${a===`sources`?`sidebar-tab--active`:``}`,onClick:()=>o(`sources`),type:`button`,title:`Grounding links the model used to build the answer. These are supporting sources, not the primary visibility signal.`,children:`Sources`})]}),a===`mentions`&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`drawer-section-label flex items-center`,children:[(0,q.jsx)(`span`,{children:`Mention in answer`}),(0,q.jsx)(Tr,{text:`Canonry scans the AI answer for your owned domains and project name. This is independent from grounding or citation sources.`})]}),(0,q.jsxs)(`div`,{className:`mention-status mention-status--${T?`mentioned`:`not-mentioned`}`,children:[(0,q.jsx)(`span`,{className:`mention-status-icon`,children:w?`…`:T?`✓`:`—`}),(0,q.jsx)(`span`,{className:`mention-status-label`,children:w?`Pending`:T?`Mentioned`:`Not mentioned`})]}),!w&&!T&&C.mentionIdentity===`wrong-subject`&&(0,q.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1 text-[11px] text-muted`,children:[(0,q.jsx)(`span`,{children:Ga.label}),(0,q.jsx)(Tr,{text:Ga.project})]}),C.matchedTerms.length>0&&(0,q.jsxs)(`div`,{className:`mt-2`,children:[(0,q.jsx)(`p`,{className:`text-[10px] uppercase tracking-wide text-muted mb-1.5`,children:`Matched in answer`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:C.matchedTerms.map(e=>(0,q.jsx)(`span`,{className:`mention-chip mention-chip--brand`,children:e},e))})]}),!w&&!T&&C.matchedTerms.length===0&&(0,q.jsxs)(`div`,{className:`mt-2`,children:[(0,q.jsx)(`p`,{className:`text-[10px] uppercase tracking-wide text-muted mb-1.5`,children:`Searched for`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:ee.map(e=>(0,q.jsx)(`span`,{className:`mention-chip mention-chip--muted`,children:e},e))}),(0,q.jsx)(`p`,{className:`text-[11px] text-faint mt-1.5`,children:`None of these appear in the answer text.`})]})]}),(C.recommendedCompetitors.length>0||C.mentionedCompetitorDomains.length>0)&&(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`drawer-section-label flex items-center`,children:[(0,q.jsx)(`span`,{children:`Competitors in answer`}),(0,q.jsx)(Tr,{text:`Competitors detected in the answer text. Includes tracked competitor brands and names extracted by Canonry; source-link competitors stay in the Sources tab.`})]}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:(()=>{let e=C.mentionedCompetitorDomains.map(e=>e.replace(/^www\./,``)),t=new Set(e.map(e=>cn(e.replace(/\.[^.]+$/,``))));return[...C.recommendedCompetitors.filter(e=>!t.has(cn(e))),...e].map(e=>(0,q.jsx)(`span`,{className:`mention-chip mention-chip--competitor`,children:e},e))})()})]})]}),a===`sources`&&(0,q.jsxs)(q.Fragment,{children:[C.citedDomains.length>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`drawer-section-label flex items-center`,children:[(0,q.jsx)(`span`,{children:`Domains from source links`}),(0,q.jsx)(Tr,{text:`These domains were extracted from grounding or citation URLs. They are supporting-source metadata, not proof that the answer text mentioned them.`})]}),(0,q.jsx)(`div`,{className:`citation-leaderboard`,children:C.citedDomains.map((e,t)=>{let n=e.toLowerCase().replace(/^www\./,``),r=g.has(n),i=!r&&C.citedCompetitorDomains.some(e=>e.toLowerCase().replace(/^www\./,``)===n);return(0,q.jsxs)(`div`,{className:`citation-leaderboard-item citation-leaderboard-item--${r?`you`:i?`competitor`:`other`}`,children:[(0,q.jsxs)(`span`,{className:`citation-leaderboard-rank`,children:[`#`,t+1]}),(0,q.jsx)(`span`,{className:`citation-leaderboard-domain`,children:e}),r&&(0,q.jsx)(`span`,{className:`citation-leaderboard-tag`,children:`You`}),i&&(0,q.jsx)(`span`,{className:`citation-leaderboard-tag`,children:`Competitor`})]},e)})})]}),C.groundingSources.length>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`drawer-section-label flex items-center`,children:[(0,q.jsxs)(`span`,{children:[`Grounding source links (`,C.groundingSources.length,`)`]}),(0,q.jsx)(Tr,{text:`Links the model used as grounding or supporting context while producing the answer. These are not the same thing as answer visibility.`})]}),(0,q.jsx)(`ul`,{className:`grid min-w-0 gap-3`,children:C.groundingSources.map((e,t)=>(0,q.jsx)(`li`,{className:`min-w-0`,children:(0,q.jsx)(qa,{url:e.uri,title:e.title})},t))})]}),C.evidenceUrls.length>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`drawer-section-label`,children:`Evidence URLs`}),(0,q.jsx)(`ul`,{className:`grid min-w-0 gap-3`,children:C.evidenceUrls.map(e=>(0,q.jsx)(`li`,{className:`min-w-0`,children:(0,q.jsx)(qa,{url:e})},e))})]}),C.citedDomains.length===0&&C.groundingSources.length===0&&C.evidenceUrls.length===0&&(0,q.jsxs)(`div`,{className:`flex items-center justify-center h-24 text-faint text-sm`,children:[`No source data `,S?`for this run`:`yet`]})]}),!E&&!D&&(0,q.jsxs)(`div`,{className:`flex items-center justify-center h-24 text-faint text-sm`,children:[`No answer visibility data `,S?`for this run`:`yet`]})]})]})]})]})]})})}function no(e){let t=e.match(/^\/projects\/([^/]+)/);if(!t)return null;try{return decodeURIComponent(t[1])}catch{return t[1]}}function ro(e,t){return e?(t?.projects.find(t=>t.project.name===e||t.project.id===e))?.project.name??e:null}function io(e,t){return ro(no(e),t)}function ao(e){let t=new Date(`2026-02-20`);return e.map((e,n)=>({runId:`run_mock_${n+1}`,citationState:e,createdAt:new Date(t.getTime()+n*2*24*60*60*1e3).toISOString()}))}var oo=[{id:`project_citypoint`,name:`Citypoint Dental NYC`,canonicalDomain:`citypointdental.com`,ownedDomains:[],aliases:[],qualifiedAliases:[],country:`US`,language:`en`,tags:[`local intent`,`priority`],labels:{},providers:[],providerModels:{},providerDispatchModes:{},measurement:Jt,locations:[],defaultLocation:null,autoExtractBacklinks:!1,siteAuditMaxPages:null,configSource:`cli`,configRevision:1},{id:`project_harbor`,name:`Harbor Legal Group`,canonicalDomain:`harborlegal.com`,ownedDomains:[],aliases:[],qualifiedAliases:[],country:`US`,language:`en`,tags:[`lead gen`],labels:{},providers:[],providerModels:{},providerDispatchModes:{},measurement:Jt,locations:[],defaultLocation:null,autoExtractBacklinks:!1,siteAuditMaxPages:null,configSource:`cli`,configRevision:1},{id:`project_northstar`,name:`Northstar Orthopedics`,canonicalDomain:`northstarortho.com`,ownedDomains:[],aliases:[],qualifiedAliases:[],country:`US`,language:`en`,tags:[`multi-location`],labels:{},providers:[],providerModels:{},providerDispatchModes:{},measurement:Jt,locations:[],defaultLocation:null,autoExtractBacklinks:!1,siteAuditMaxPages:null,configSource:`cli`,configRevision:1}];function so(e){return{id:e.id,projectId:e.projectId,projectName:e.projectName,kind:e.kind,kindLabel:e.kindLabel,status:e.status,trigger:e.trigger??`manual`,createdAt:e.createdAt,startedAt:e.startedAt,duration:e.duration,statusDetail:e.statusDetail,summary:e.summary,triggerLabel:e.triggerLabel,opensSeoWorkspace:!1}}so({id:`run_citypoint_visibility_20260308`,projectId:`project_citypoint`,projectName:`Citypoint Dental NYC`,kind:`answer-visibility`,kindLabel:`AI Visibility check`,status:`completed`,createdAt:`2026-03-08T12:15:00.000Z`,startedAt:`Mar 8, 12:15 PM`,duration:`6 minutes 12 seconds`,statusDetail:`18 tracked queries checked; 3 citation losses detected on emergency-intent prompts.`,summary:`Citation losses on emergency-intent prompts`,triggerLabel:`Scheduled`}),so({id:`run_citypoint_queued_20260309`,projectId:`project_citypoint`,projectName:`Citypoint Dental NYC`,kind:`answer-visibility`,kindLabel:`AI Visibility check`,status:`queued`,createdAt:`2026-03-09T08:05:00.000Z`,startedAt:`Mar 9, 8:05 AM`,duration:`Waiting`,statusDetail:`Ready to enqueue after the next provider rate window clears.`,summary:`Queued follow-up after local ranking movement`,triggerLabel:`Manual`}),so({id:`run_harbor_visibility_20260308`,projectId:`project_harbor`,projectName:`Harbor Legal Group`,kind:`answer-visibility`,kindLabel:`AI Visibility check`,status:`completed`,createdAt:`2026-03-08T11:05:00.000Z`,startedAt:`Mar 8, 11:05 AM`,duration:`5 minutes 7 seconds`,statusDetail:`12 tracked queries checked; local-intent visibility held steady across branded prompts.`,summary:`Branded prompts remain stable`,triggerLabel:`Scheduled`}),so({id:`run_northstar_visibility_20260308`,projectId:`project_northstar`,projectName:`Northstar Orthopedics`,kind:`answer-visibility`,kindLabel:`AI Visibility check`,status:`running`,createdAt:`2026-03-08T13:40:00.000Z`,startedAt:`Mar 8, 1:40 PM`,duration:`Running`,statusDetail:`Provider responses still in flight for 9 multi-location prompts.`,summary:`Mid-run on treatment-location prompts`,triggerLabel:`Manual`}),ao([`cited`,`cited`,`cited`,`cited`,`cited`,`cited`,`cited`,`not-cited`,`not-cited`]),ao([`not-cited`,`cited`,`cited`,`cited`,`cited`,`cited`,`cited`]),ao([`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`]),ao([`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`cited`]),ao([`cited`,`cited`,`cited`,`cited`,`cited`,`cited`,`cited`,`cited`]),ao([`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`]),ao([`not-cited`,`not-cited`,`not-cited`,`not-cited`]),ao([`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`]),ao([`not-cited`,`not-cited`,`not-cited`,`not-cited`,`not-cited`,`cited`]),oo[0],oo[1],ao([`cited`,`cited`,`cited`,`cited`,`cited`]),oo[2],ao([`not-cited`,`not-cited`,`not-cited`,`cited`]),oo[0],oo[1],oo[2];function co(e,t){return e.runs.find(e=>e.id===t)}function lo(e,t){for(let n of e.projects){let e=n.visibilityEvidence.find(e=>e.id===t);if(e)return{project:n,evidence:e}}}function uo(e,t,n){if(e){let t=e.visibilityEvidence.find(e=>e.id===n);if(t)return{project:e,evidence:t}}if(t)return lo(t,n)}var fo={regression:`negative`,gain:`positive`,opportunity:`caution`,"first-citation":`positive`,"provider-pickup":`positive`,"persistent-gap":`caution`,"competitor-gained":`negative`,"competitor-lost":`neutral`,"gbp-lodging-gap":`negative`,"gbp-listing-discrepancy":`negative`,"gbp-cta-gap":`caution`,"gbp-description-missing":`caution`,"gbp-metric-drop":`negative`,"gbp-keyword-drop":`negative`},po={regression:`lost`,gain:`emerging`,opportunity:`not-cited`,"first-citation":`emerging`,"provider-pickup":`emerging`,"persistent-gap":`not-cited`,"competitor-gained":`cited`,"competitor-lost":`not-cited`,"gbp-lodging-gap":`not-cited`,"gbp-listing-discrepancy":`not-cited`,"gbp-cta-gap":`not-cited`,"gbp-description-missing":`not-cited`,"gbp-metric-drop":`lost`,"gbp-keyword-drop":`lost`},mo={regression:!0,gain:!0,opportunity:!0,"first-citation":!0,"provider-pickup":!0,"persistent-gap":!0,"competitor-gained":!1,"competitor-lost":!1,"gbp-lodging-gap":!1,"gbp-listing-discrepancy":!1,"gbp-cta-gap":!1,"gbp-description-missing":!1,"gbp-metric-drop":!1,"gbp-keyword-drop":!1},ho={regression:`Regression`,gain:`Gain`,opportunity:`Opportunity`,"first-citation":`First citation`,"provider-pickup":`Pickup`,"persistent-gap":`Gap`,"competitor-gained":`Competitor`,"competitor-lost":`Competitor`,"gbp-lodging-gap":`Lodging gap`,"gbp-listing-discrepancy":`Listing gap`,"gbp-cta-gap":`Booking CTA`,"gbp-description-missing":`Description gap`,"gbp-metric-drop":`Metric drop`,"gbp-keyword-drop":`Keyword drop`};function go(e){return{id:e.id,tone:fo[e.type],title:e.title,detail:e.cause?.details??e.cause?.cause??``,actionLabel:e.recommendation?.action??ho[e.type],actionGroup:Ft[e.type],affectedPhrases:[{query:e.query,evidenceId:``,provider:e.provider,citationState:po[e.type],siteCitation:mo[e.type]}]}}function _o(e){return e.filter(e=>!e.dismissed).map(go)}function vo(e){return{id:e.id,name:e.name,displayName:e.displayName,canonicalDomain:e.canonicalDomain,ownedDomains:e.ownedDomains??[],aliases:e.aliases??[],qualifiedAliases:e.qualifiedAliases,country:e.country,language:e.language,tags:e.tags,labels:e.labels,providers:e.providers??[],providerModels:e.providerModels??{},providerDispatchModes:e.providerDispatchModes??{},measurement:e.measurement,locations:e.locations??[],defaultLocation:e.defaultLocation??null,autoExtractBacklinks:e.autoExtractBacklinks??!1,siteAuditMaxPages:e.siteAuditMaxPages??null,configSource:e.configSource,configRevision:e.configRevision,createdAt:e.createdAt,updatedAt:e.updatedAt}}function yo(e,t){return`${e} ${t}${e===1?``:`s`}`}function bo(e,t){if(!e)return`Waiting`;if(!t)return`Running`;let n=new Date(t).getTime()-new Date(e).getTime();if(n<1e3)return`under 1 second`;let r=Math.floor(n/1e3),i=Math.floor(r/3600),a=Math.floor(r%3600/60),o=r%60;return i>0?a>0?`${yo(i,`hour`)} ${yo(a,`minute`)}`:yo(i,`hour`):a>0?o>0?`${yo(a,`minute`)} ${yo(o,`second`)}`:yo(a,`minute`):yo(o,`second`)}function xo(e){switch(e){case G[`answer-visibility`]:return`AI Visibility check`;case G[`gsc-sync`]:return`GSC sync`;case G[`inspect-sitemap`]:return`Sitemap inspection`;case G[`ga-sync`]:return`GA sync`;case G[`traffic-sync`]:return`Traffic sync`;case G[`bing-inspect`]:return`Bing URL inspection`;case G[`bing-inspect-sitemap`]:return`Bing sitemap inspection`;case G[`site-audit`]:return`Technical AEO audit`;case G[`backlink-extract`]:return`Backlink extract`;case G[`aeo-discover-seed`]:return`Discovery (seed phase)`;case G[`aeo-discover-probe`]:return`Discovery (probe phase)`;case G[`gbp-sync`]:return`Business Profile sync`;case G[`ads-sync`]:return`ChatGPT ads sync`;case G[`google-ads-sync`]:return`Google Ads sync`;case G[`gtm-sync`]:return`Tag Manager sync`;case G[`seo-sync`]:return`SEO data refresh`;default:return`Unknown job type`}}function So(e){switch(e){case gn.manual:return`Manual`;case gn.scheduled:return`Scheduled`;case gn[`config-apply`]:return`Config apply`;case gn.probe:return`Spot check`;default:return e}}function Co(e,t){return{id:e.id,projectId:e.projectId,projectName:t,kind:e.kind,kindLabel:xo(e.kind),status:e.status,trigger:e.trigger??`manual`,location:e.location??null,createdAt:e.createdAt,startedAt:Bn(e.startedAt||e.createdAt),duration:bo(e.startedAt??null,e.finishedAt??null),statusDetail:e.error?wo(e.error):To(e),summary:Eo(e),triggerLabel:So(e.trigger),opensSeoWorkspace:e.kind===G[`seo-sync`]&&!(e.status===H.failed&&!e.startedAt)}}function wo(e){let t=Xt(e);return t.length>200?t.slice(0,200)+`…`:t}function To(e){if(e.kind===G[`seo-sync`])return`View the saved scope and task results in SEO.`;switch(e.status){case H.queued:return`Waiting for execution slot.`;case H.running:return`Provider queries in progress.`;case H.completed:return`All queries checked.`;case H.partial:return`Run completed with some queries skipped.`;case H.failed:return e.error?wo(e.error):`Run failed.`;case H.cancelled:return`Run was cancelled.`;default:return``}}function Eo(e){let t=xo(e.kind);switch(e.status){case H.queued:return`${t} queued`;case H.running:return`${t} in progress`;case H.completed:return`${t} completed`;case H.partial:return`${t} partially completed`;case H.failed:return`${t} failed`;case H.cancelled:return`${t} cancelled`;default:return e.status}}function Do(e,t,n,r,i){let a=[],o=0,s=new Set;if(n.length>0){let r=n.flatMap(e=>e.snapshots??[]),c=new Map;for(let e of r)if(e.query){let t=`${e.query}::${e.provider}::${e.location??``}`;c.set(t,e)}let l=new Set(r.map(e=>e.location??null));l.size===0&&l.add(null);let u=new Set(r.map(e=>e.provider)),d=new Set(t.flatMap(e=>Object.keys(e.providerRuns??{}))),f=[...new Set([...u,...d])].sort(),p=f.length>0?f:[`gemini`],m=new Set(r.flatMap(e=>e.query?[e.query]:[]));for(let n of t){if(n.runs.length===0&&!m.has(n.query))continue;s.add(n.query);let t=n.runs.at(-1),r=t?.transition??`not-cited`;for(let s of p){let u=[...l].filter(e=>c.has(`${n.query}::${s}::${e??``}`)),d=(n.providerRuns?.[s]?.length??0)>0,f=u.length>0?u:d?[null]:[];for(let l of f){let d=l??``,f=c.get(`${n.query}::${s}::${d}`),p=f?.model??null,m=p?`${s}:${p}`:null,h=n.providerRuns?.[s],g=m?n.modelRuns?.[m]:void 0,_=e=>e?.filter(e=>(e.location??null)===l),v=u.length>0?_(h):h,y=u.length>0?_(g):g,b=(v?.length?v:null)??(y?.length?y:null),x=v?.length?`provider`:y?.length?`model`:`query`,S=f&&b?b.findIndex(e=>e.runId===f.runId):-1,C=f?S>=0?b.slice(0,S+1):null:b,w=f!==void 0&&C===null,T=C?C.at(-1).transition:w?f.citationState===V.cited?`cited`:`not-cited`:r,E=C?C.at(-1).visibilityTransition??(C.at(-1).visibilityState===`visible`?`visible`:`not-visible`):w?f.visibilityState===`visible`?`visible`:`not-visible`:t?.visibilityTransition??(t?.visibilityState===`visible`?`visible`:`not-visible`),D=b?.at(-1)?.citationState,O=b?.at(-1)?.visibilityState,ee=f?T===`lost`?`lost`:T===`emerging`?`emerging`:f.citationState===V.cited?`cited`:`not-cited`:D===V.cited?`cited`:`not-cited`,k=f?.visibilityState??(O===`visible`?`visible`:O===`pending`?`pending`:`not-visible`),A=C?jo(C):w?1:jo(n.runs),j=C?Mo(C):w?1:Mo(n.runs),te=Oo(n,s),ne=(b??n.runs).map(e=>({runId:e.runId,citationState:e.citationState,createdAt:e.createdAt,model:te.get(e.runId)??null,answerMentioned:e.answerMentioned,visibilityState:e.visibilityState,visibilityTransition:e.visibilityTransition,mentionState:e.mentionState,mentionTransition:e.mentionTransition})),re=ko(ne),ie=x===`provider`&&re.length<=1?`model`:x,ae=Ao(ne),M=f?.citedCompetitorDomains??[],N=f?.mentionedCompetitorDomains??[],oe=[...new Set([...M,...N,...f?.competitorOverlap??[]])];a.push({id:`evidence_${e}_${o++}`,query:n.query,queryId:f?.queryId??null,sourceSnapshotId:f?.id??null,sourceRunId:f?.runId??null,queryClass:i?.classify(n.query)??null,provider:f?.provider??s,model:f?.model??null,location:f?.location??l,citationState:ee,answerMentioned:f?.answerMentioned,visibilityState:k,visibilityChangeLabel:No(E,j,{positive:`visible`,negative:`not visible`,first:`first visibility`}),changeLabel:No(T,A),answerSnippet:f?.answerText??``,citedDomains:f?.citedDomains??[],evidenceUrls:f?.citedUrls??[],citedCompetitorDomains:M,mentionedCompetitorDomains:N,mentionedCompetitorTerms:f?.mentionedCompetitorTerms??[],competitorDomains:oe,recommendedCompetitors:f?.recommendedCompetitors??[],matchedTerms:f?.matchedTerms??[],mentionIdentity:f?.mentionIdentity??null,relatedTechnicalSignals:[],groundingSources:f?.groundingSources??[],searchQueries:f?.searchQueries??[],summary:Po(k,E,n.query),runHistory:ne,historyScope:ie,modelsSeen:re,modelTransitions:ae})}}}}for(let t of r)s.has(t.query)||a.push({id:`evidence_${e}_${o++}`,query:t.query,queryId:t.id,sourceSnapshotId:null,sourceRunId:null,queryClass:i?.classify(t.query)??null,provider:``,model:null,location:null,citationState:`pending`,visibilityState:`pending`,visibilityChangeLabel:`Awaiting first run`,changeLabel:`Awaiting first run`,answerSnippet:``,citedDomains:[],evidenceUrls:[],citedCompetitorDomains:[],mentionedCompetitorDomains:[],mentionedCompetitorTerms:[],competitorDomains:[],recommendedCompetitors:[],matchedTerms:[],relatedTechnicalSignals:[],groundingSources:[],searchQueries:[],summary:`"${t.query}" has been added but no visibility run has been triggered yet.`,runHistory:[],historyScope:`query`,modelsSeen:[],modelTransitions:[]});return a}function Oo(e,t){let n=new Map,r=`${t}:`;for(let[t,i]of Object.entries(e.modelRuns??{})){if(!t.startsWith(r))continue;let e=t.slice(r.length),a=e===`unknown`?null:e;for(let e of i)n.set(e.runId,a)}return n}function ko(e){let t=new Set;for(let n of e)n.model&&t.add(n.model);return[...t]}function Ao(e){let t=[],n=null;for(let r of e){let e=r.model??null;e!==n&&n!==null&&t.push({runId:r.runId,createdAt:r.createdAt,fromModel:n,toModel:e}),n=e}return t}function jo(e){if(e.length===0)return 0;let t=e[e.length-1].citationState,n=0;for(let r=e.length-1;r>=0&&e[r].citationState===t;r--)n++;return n}function Mo(e){if(e.length===0)return 0;let t=e[e.length-1].visibilityState??`not-visible`,n=0;for(let r=e.length-1;r>=0&&(e[r].visibilityState??`not-visible`)===t;r--)n++;return n}function No(e,t,n){let r={positive:n?.positive??`cited`,negative:n?.negative??`not cited`,first:n?.first??`first citation`};switch(e){case`new`:return`First observation`;case`cited`:case`visible`:return t<=1?`${X(r.positive)} in latest run`:`${X(r.positive)} for ${t} runs`;case`lost`:return`Lost since last run`;case`emerging`:return X(r.first);case`not-cited`:case`not-visible`:return t<=1?`${X(r.negative)} in latest run`:`${X(r.negative)} across ${t} runs`;default:return e}}function X(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Po(e,t,n){switch(t){case`lost`:return`Mention was lost for "${n}". Your brand no longer appeared in the latest answer.`;case`emerging`:return`Your brand started appearing in AI answers for "${n}".`}switch(e){case`visible`:return`Your brand or domain is mentioned in AI answers for "${n}".`;case`pending`:return`"${n}" has been added but no run has been triggered yet.`;default:return`Your brand or domain was not mentioned in AI answers for "${n}".`}}function Fo(e){let t=vo(e.project),n=sn(nt(e.project)),r=Do(t.name,e.timeline,e.latestRunDetails,e.queries,n),i=[...e.runs].sort((e,t)=>t.createdAt.localeCompare(e.createdAt)).map(t=>Co(t,e.project.displayName||e.project.name));return e.overview?Lo(t,e.overview,r,i):zo(t,r,i)}function Io(e){return e.filter(e=>e.kind===G[`answer-visibility`]&&e.trigger!==gn.probe&&(e.status===H.completed||e.status===H.partial))}function Lo(e,t,n,r){let i=_o(t.topInsights);for(let e of t.attentionItems)e.id.startsWith(`insight_`)||i.push({id:e.id,tone:e.tone,title:e.title,detail:e.detail,actionLabel:e.actionLabel,actionGroup:`investigate`,affectedPhrases:[]});return{project:e,contextLabel:t.contextLabel,mentionSummary:t.scores.mention,visibilitySummary:t.scores.visibility,mentionShareSummary:t.scores.mentionShare,queryCounts:{cited:t.queryCounts.citedQueries,total:t.queryCounts.totalQueries},gapQueries:t.scores.gapQueries,mentionGaps:t.scores.mentionGaps,indexCoverage:t.scores.indexCoverage,providerScores:t.providerScores,competitorPressure:t.scores.competitorPressure,runStatus:t.scores.runStatus,movementComparison:t.movementComparison,insights:i,visibilityEvidence:n,competitors:t.competitors.map(e=>({id:e.id,domain:e.domain,aliases:e.aliases??[],autoAliases:e.autoAliasNames??[],citationCount:e.citationCount,totalQueries:e.totalQueries,pressureLabel:e.pressureLabel,citedQueries:e.citedQueries,movement:``,notes:``})),recentRuns:r.slice(0,5),visibilitySweeps:Io(r),suggestedQueries:t.suggestedQueries}}function Ro(){return{projectMentionSnapshots:0,competitorMentionSnapshots:0,combinedMentionSnapshots:0,perCompetitor:[],ranking:[],snapshotsWithAnswerText:0,snapshotsTotal:0,score:null}}function zo(e,t,n){let r={label:``,value:`No data`,delta:`Loading…`,tone:`neutral`,description:``,tooltip:``,trend:[]};return{project:e,contextLabel:`${e.country} / ${e.language.toUpperCase()}`,mentionSummary:{...r,label:`Mention Coverage`},visibilitySummary:{...r,label:`Citation Coverage`},mentionShareSummary:{...r,label:`Mention Share`,scope:`non-brand`,unavailable:!0,breakdown:Ro(),branded:Ro()},queryCounts:{cited:0,total:0},gapQueries:{...r,label:`Citation Gaps`},mentionGaps:{...r,label:`Mention Gaps`},indexCoverage:{...r,label:`Index Coverage`},providerScores:[],competitorPressure:{...r,label:`Competitor Pressure`},runStatus:{...r,label:`Run Status`},movementComparison:{hasPreviousRun:!1,comparable:!1,querySetChanged:!1,previousRunAt:null,currentQueryCount:0,previousQueryCount:0,comparableQueryCount:0,addedQueryCount:0,removedQueryCount:0,addedQueries:[],removedQueries:[]},insights:[],visibilityEvidence:t,competitors:[],recentRuns:n.slice(0,5),visibilitySweeps:Io(n),suggestedQueries:{rows:[],totalCandidates:0,skippedAlreadyTracked:0}}}function Bo(e){let t=vo(e.project),n=[...e.runs].sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),r=n.find(e=>e.kind===G[`answer-visibility`])??n[0]??e.overview?.latestRun?.run??void 0,i=e.project.displayName||e.project.name,a=r?Co(r,i):Vo(e.project.id,i),o=e.overview;if(!o)return{project:t,hasMeasurement:!1,mentionScore:0,mentionDelta:`No data`,mentionTone:`neutral`,lastRun:a,insight:`No runs completed yet.`,trend:[],competitorPressureLabel:`None`};let s=o.scores.mention,c=s.progress??0,l=o.queryCounts.mentionedQueries,u=o.queryCounts.totalQueries,d=o.providers.length;return{project:t,hasMeasurement:u>0&&s.progress!=null,mentionScore:c,mentionDelta:u>0?`${l} of ${u} queries`:`No data`,mentionTone:s.tone,providerCoverage:s.providerCoverage,lastRun:a,insight:u>0?`${l} of ${u} queries mentioned across ${d} provider${d===1?``:`s`}.`:`No runs completed yet.`,trend:s.trend??[],competitorPressureLabel:o.scores.competitorPressure.value,sentiment:o.sentiment}}function Vo(e,t){return{id:`none`,projectId:e,projectName:t,kind:G[`answer-visibility`],kindLabel:`No runs yet`,status:H.queued,trigger:gn.manual,createdAt:``,startedAt:``,duration:``,statusDetail:``,summary:`No runs yet`,triggerLabel:``,opensSeoWorkspace:!1}}function Ho(e,t){let n=[],r=[],i=[];for(let t of e){r.push(Fo(t)),i.push(Bo(t));let e=[...t.runs].sort((e,t)=>t.createdAt.localeCompare(e.createdAt));for(let r of e)n.push(Co(r,t.project.displayName||t.project.name))}n.sort((e,t)=>t.createdAt.localeCompare(e.createdAt));let a=e.length>0;return{portfolioOverview:{projects:i,attentionItems:a?Uo(r):[{id:`attention_setup`,tone:`neutral`,title:`No projects yet`,detail:`Create your first project using the setup wizard, CLI, or API.`,actionLabel:`Open setup`,href:`/setup`}],recentRuns:n.slice(0,5),systemHealth:[{id:`api`,label:`API`,tone:`positive`,detail:`Connected`,meta:`Real-time data`},{id:`provider`,label:`Gemini`,tone:`positive`,detail:`Configured`,meta:`Provider active`}],...a?{}:{emptyState:{title:`No projects yet`,detail:`Canonry becomes useful after one project, a small query set, and one competitor list are in place.`,ctaLabel:`Launch setup`,ctaHref:`/setup`}}},projects:r,runs:n,setup:{healthChecks:[{id:`api`,label:`API reachable`,detail:`API is responding.`,state:`ready`,guidance:`Required for project creation and run history.`},{id:`provider`,label:`Provider configured`,detail:`Gemini key is configured.`,state:`ready`,guidance:`Required for AI Visibility checks.`}],projectDraft:{name:``,canonicalDomain:``,country:`US`,language:`en`},queryImportState:{mode:`paste`,queryCount:0,preview:[]},competitorDraft:{domains:[],notes:`Use the CLI to add competitors.`},launchState:{enabled:a,ctaLabel:a?`Trigger run`:`Create a project first`,summary:a?`Ready to run.`:`Create a project first to launch a run.`}},settings:{providerStatuses:(t?.providers??[]).map(e=>({name:e.name,displayName:e.displayName,...e.kind?{kind:e.kind}:{},keyUrl:e.keyUrl,modelHint:e.modelHint,model:e.model,defaultModel:e.defaultModel,state:e.configured?`ready`:`needs-config`,detail:e.configured?`Provider is configured.`:e.name.toLowerCase()===`local`?`Base URL is missing.`:`API key is missing.`,quota:e.quota})),google:{state:t?.google?.configured?`ready`:`needs-config`,detail:t?.google?.configured?`Google OAuth app credentials are configured. Project-level GSC connections can be created from the dashboard.`:`Google OAuth client ID and client secret are not configured yet.`},bing:{state:t?.bing?.configured?`ready`:`needs-config`,detail:t?.bing?.configured?`Bing Webmaster Tools API key is configured. Project-level Bing connections can be created from the dashboard.`:`Bing Webmaster Tools API key is not configured yet.`},selfHostNotes:[`Configuration is stored in ~/.canonry/config.yaml.`,`The local config file is the source of truth for authentication credentials.`,`Google OAuth app credentials and per-domain Google tokens are stored in local config, not the database.`,`Database is SQLite at ~/.canonry/data.db.`,`API key was auto-generated during canonry init.`],bootstrapNote:`Use the UI, CLI, or ~/.canonry/config.yaml to manage settings. Authentication credentials persist to local config.`}}}function Uo(e){let t=[];for(let n of e){let e=n.visibilityEvidence.filter(e=>e.citationState===`lost`);e.length>0&&t.push({id:`attention_${n.project.id}_lost`,tone:`negative`,title:`${n.project.displayName||n.project.name} lost citations`,detail:`${e.length} quer${e.length>1?`ies`:`y`} lost citation.`,actionLabel:`Open project`,href:`/projects/${encodeURIComponent(n.project.name)}`});let r=n.recentRuns.filter(e=>e.status===H.running||e.status===H.queued);r.length>0&&t.push({id:`attention_${n.project.id}_active`,tone:`neutral`,title:`${n.project.displayName||n.project.name} has active runs`,detail:`${r.length} run${r.length>1?`s`:``} in progress.`,actionLabel:`View runs`,href:`/runs`})}return t.length===0&&t.push({id:`attention_stable`,tone:`positive`,title:`All projects stable`,detail:`No citation losses or active runs to flag.`}),t}var Wo=(0,K.createContext)(null);Wo.Provider;function Go(){return(0,K.useContext)(Wo)}function Ko(e,t={}){let n=Go(),r=e??n?.dashboard??null,i=t.includeSettings??!0,a=t.includeOverviews??!0,o=t.pauseProjectPolling??!1,{isAdmin:s}=Jn(),c=!r&&a&&!ze(),l=R({...fr({client:U,query:{kind:`answer-visibility`}}),enabled:!r,staleTime:Zn,refetchInterval:e=>e.state.data?.some(e=>e.status===`running`||e.status===`queued`)?3e3:Zn}),u=R({...fr({client:U,query:{excludeKinds:[G[`bing-inspect`],G[`traffic-sync`]],limit:5}}),enabled:c,staleTime:Zn,refetchInterval:e=>e.state.data?.some(e=>e.status===H.running||e.status===H.queued)?3e3:Zn}),d=R({...cr({client:U}),enabled:!r,refetchInterval:o?!1:e=>{let t=e.state.data,n=l.data?.some(e=>e.status===`running`||e.status===`queued`);return(t?.length??0)===0||n?tr:or}}),f=R({...sr({client:U}),enabled:!r&&i&&s}),p=d.data??[],m=l.data??[],h=ke({queries:p.map(e=>{let t=m.filter(t=>t.projectId===e.id),n=t.filter(e=>(e.status===`completed`||e.status===`partial`)&&e.kind===`answer-visibility`&&e.trigger!==`probe`).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),i=n.length>0?n[0].id:`no-run`;return{queryKey:[`project-overview-slim`,e.id,i],queryFn:async()=>{let n=await xt(e.name).catch(()=>null);return{project:e,runs:t,queries:[],competitors:[],timeline:[],latestRunDetails:[],previousRunDetails:[],gscCoverage:null,bingCoverage:null,dbInsights:null,overview:n}},enabled:!r&&a&&d.isSuccess&&l.isSuccess,staleTime:ir}})}),g=!a||h.every(e=>e.isSuccess),_=(0,K.useMemo)(()=>{if(r)return r;if(!d.data||!l.data||p.length>0&&!g)return null;let e=new Map(p.map(e=>[e.id,e])),t=Ho(a?h.map(t=>{if(!t.data)return null;let n=e.get(t.data.project.id);return n?{...t.data,project:n,runs:m.filter(e=>e.projectId===n.id)}:null}).filter(e=>e!=null):p.map((e,t)=>{let n=h[t]?.data;return{project:e,runs:m.filter(t=>t.projectId===e.id),queries:[],competitors:[],timeline:[],latestRunDetails:[],previousRunDetails:[],gscCoverage:null,bingCoverage:null,dbInsights:null,overview:n?.overview??null}}),f.data??null);return c&&(t.portfolioOverview.recentRuns=(u.data??[]).filter(t=>t.trigger!==gn.probe&&e.has(t.projectId)).map(t=>{let n=e.get(t.projectId);return Co(t,n.displayName||n.name)})),t},[r,d.data,l.data,f.data,a,g,h,p,m,c,u.data]),v=!r&&(d.isError||l.isError),y=!r&&!_&&!v,b=(0,K.useCallback)(async()=>{let e=[d.refetch(),l.refetch(),...c?[u.refetch()]:[],...a?h.map(e=>e.refetch()):[]];i&&s&&e.push(f.refetch()),await Promise.all(e)},[i,s,a,c,u.refetch,h,d.refetch,l.refetch,f.refetch]);return{dashboard:_,isLoading:y,isError:v,activityLoading:c&&u.isPending,activityError:c&&u.isError,refetch:b}}function qo(e){return JSON.stringify(e.filter(e=>e.kind===`answer-visibility`&&e.trigger!==`probe`&&(e.status===`completed`||e.status===`partial`)).map(e=>[e.id,e.status]).sort(([e],[t])=>e.localeCompare(t)))}async function Jo(e,t,n=`active`){let r=e=>{let n=e.queryKey[0];return n?._id===`getApiV1ProjectsByNameAnalyticsCompetitors`&&n.path?.name===t};return n===`active`&&await e.cancelQueries({predicate:r}),e.invalidateQueries({predicate:r,refetchType:n})}function Yo(e,t,n){let r=ge(),i=(0,K.useRef)({projectName:e,revision:t,enabled:n});(0,K.useEffect)(()=>{let a=i.current;i.current={projectName:e,revision:t,enabled:n},n&&a.enabled&&a.projectName===e&&a.revision!==t&&Jo(r,e)},[n,e,r,t])}var Xo=20;function Zo(e,t={}){let n=ge(),r=Go(),i=(0,K.useMemo)(()=>!r||!e?null:r.dashboard.projects.find(t=>t.project.name===e)??null,[r,e]),a=R({...Sr({client:U,path:{name:e??``}}),enabled:!!e&&!i,staleTime:ir,refetchOnWindowFocus:`always`}),o=R({...vr({client:U,path:{name:e??``},query:{kind:`answer-visibility`}}),enabled:!!e,staleTime:Zn,refetchOnWindowFocus:`always`,refetchInterval:e=>e.state.data?.some(e=>e.projectId===a.data?.id&&(e.status===`running`||e.status===`queued`))?3e3:Zn}),s=a.data??null,c=(0,K.useMemo)(()=>s?(o.data??[]).filter(e=>e.projectId===s.id):[],[s,o.data]),{latestRunIds:l,latestRunIdsKey:u,latestVisibilityRevision:d}=(0,K.useMemo)(()=>{let e=c.filter(e=>(e.status===`completed`||e.status===`partial`)&&e.kind===`answer-visibility`&&e.trigger!==`probe`).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),t=e[0]?.createdAt??null,n=t?e.filter(e=>e.createdAt===t).map(e=>e.id):[];return{latestRunIds:n,latestRunIdsKey:[...n].sort().join(`,`),latestVisibilityRevision:t?`${t}:${[...n].sort().join(`,`)}`:`none`}},[c]),f=!!s&&!!e&&o.isSuccess,p=R({queryKey:[`project-dashboard-full`,s?.id??null,u||`none`,`overview`],queryFn:async()=>({project:s,overview:await xt(e)}),enabled:f&&t.overview===!0,staleTime:ir,refetchOnWindowFocus:`always`}),m=R({queryKey:[`project-dashboard-full`,s?.id??null,u||`none`,`evidence`],queryFn:async()=>{let[t,n,r]=await Promise.all([Ze(e),vn(e,void 0,Xo),Promise.all(l.map(e=>Ye(e)))]);return{project:s,queries:t,timeline:n,latestRunDetails:r}},enabled:f&&t.evidence===!0,staleTime:ir,refetchOnWindowFocus:`always`}),h=(0,K.useMemo)(()=>{if(!s||!o.data)return i;let e=t.evidence?m.data:void 0,n=Fo({project:s,runs:c,queries:e?.queries??[],timeline:e?.timeline??[],latestRunDetails:e?.latestRunDetails??[],previousRunDetails:[],competitors:[],overview:t.overview?p.data?.overview??null:null});return i&&!(t.overview&&p.data)?{...i,project:n.project,recentRuns:n.recentRuns,visibilitySweeps:n.visibilitySweeps,visibilityEvidence:e?n.visibilityEvidence:i.visibilityEvidence}:n},[s,c,m.data,p.data,i,t.evidence,t.overview,o.data]),g=(0,K.useCallback)(async()=>{await Promise.all([a.refetch(),o.refetch(),n.invalidateQueries({queryKey:[`project-dashboard-full`,s?.id??null]})])},[a.refetch,o.refetch,n,s?.id]),_=a.isError||o.isError,v=!i&&(a.isLoading||o.isLoading),y=!!e&&t.overview===!0&&!i&&!_&&p.isPending,b=!!e&&t.evidence===!0&&!i&&!_&&m.isPending;return{commandCenter:h,project:s,isLoading:v,isError:_,overviewLoading:y,overviewError:t.overview===!0&&p.isError&&!p.data,evidenceLoading:b,evidenceError:t.evidence===!0&&m.isError&&!m.data,latestVisibilityRevision:d,competitorHistoryRevision:qo(c),refetch:g}}var Qo=[`health`];async function $o(){let e=await Wt(`/health`,`API`);return{apiStatus:e,workerStatus:jn()&&e.state===`ok`?{label:`Worker`,state:`disabled`,detail:`Background execution is disabled in this public demo.`}:e.state===`ok`?{label:`Worker`,state:`ok`,detail:`In-process job runner`}:{label:`Worker`,state:e.state,detail:`Depends on API health check · ${e.detail}`,statusCode:e.statusCode,hint:e.hint?`Worker status is inferred from API health in this deployment mode. ${e.hint}`:`Worker status is inferred from API health in this deployment mode.`}}}function es(e,t){return R({queryKey:Qo,queryFn:$o,enabled:e,refetchInterval:15e3,initialData:t})}function ts(e){return R({...ur({client:U,path:{id:e??``}}),enabled:!!e,refetchInterval:e=>{let t=e.state.data?.status;return t===`running`||t===`queued`?3e3:!1}})}function ns(){let e=be(),t=xe({strict:!1}),n=De({select:e=>e.location.pathname});return{runId:t.runId??null,evidenceId:t.evidenceId??null,openRun:t=>{e({to:n,from:Uf.to,search:e=>({...e,runId:t,evidenceId:void 0})})},openEvidence:t=>{e({to:n,from:Uf.to,search:e=>({...e,evidenceId:t,runId:void 0})})},closeDrawer:()=>{e({to:n,from:Uf.to,search:e=>({...e,runId:void 0,evidenceId:void 0})})}}}var rs={negative:`toast-card-negative`,caution:`toast-card-caution`,positive:`toast-card-positive`,neutral:`toast-card-neutral`};function is(e){if(e.cta)return`${e.cta.label}: ${e.title}`}function as(){let e=(0,K.useSyncExternalStore)(rr,ar,ar),t=be(),{openRun:n}=ns(),r=(0,K.useCallback)(e=>{er(e)},[]),i=(0,K.useCallback)(e=>{e.cta&&(e.cta.intent===`open-run-drawer`?n(e.cta.runId):t({to:`/runs`}),er(e.id))},[t,n]);return e.length===0?null:(0,q.jsx)(`div`,{className:`toast-viewport`,"aria-label":`Notifications`,children:e.map(e=>(0,q.jsxs)(`section`,{role:e.tone===`negative`?`alert`:`status`,"aria-live":e.tone===`negative`?`assertive`:`polite`,"data-state":e.state,className:`toast-card ${rs[e.tone]}`,children:[(0,q.jsxs)(`div`,{className:`toast-copy`,children:[(0,q.jsx)(`p`,{className:`toast-title`,children:e.title}),e.detail?(0,q.jsx)(`p`,{className:`toast-detail`,children:e.detail}):null,e.cta?(0,q.jsx)(`button`,{type:`button`,className:`toast-action`,onClick:()=>i(e),"aria-label":is(e),children:e.cta.label}):null]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>r(e.id),className:`toast-dismiss`,"aria-label":`Dismiss`,children:(0,q.jsx)(ie,{className:`size-3.5`})})]},e.id))})}var os=`https://github.com/Canonry/canonry`,ss=`https://canonry.ai`,cs=`Run it from your agent with the MCP server, API, CLI, and plugins for Claude Code and Codex.`,ls=[{title:`Visibility`,links:[[`AI visibility`,`/projects/summit-roofing`],[`Search engines`,`/projects/summit-roofing/search-console`],[`Traffic & conversions`,`/projects/summit-roofing/conversions`]]},{title:`Portfolio`,links:[[`Properties & markets`,`/projects/harbor-resorts`],[`Queries & research`,`/projects/harbor-resorts/queries`],[`Activity`,`/projects/harbor-resorts/activity`]]},{title:`Website`,links:[[`Site health`,`/projects/summit-roofing/technical-aeo`],[`Local presence`,`/projects/summit-roofing/local`],[`Backlinks`,`/projects/summit-roofing/backlinks`]]}];function us(){let e=(0,K.useId)();if(!jn())return null;let t=bn(),r=`${e}-new-tab`,i={target:`_blank`,rel:`noopener noreferrer`,"aria-describedby":r};return(0,q.jsxs)(`aside`,{className:`demo-banner`,"aria-label":`Public demo`,children:[(0,q.jsx)(`p`,{className:`demo-banner-name`,children:`Canonry demo`}),(0,q.jsx)(`p`,{className:`demo-banner-facts`,children:`View only. Fictional data.`}),(0,q.jsx)(`p`,{className:`demo-banner-agent`,children:cs}),(0,q.jsxs)(`div`,{className:`demo-banner-actions`,children:[(0,q.jsxs)(`a`,{className:`demo-banner-primary`,href:ss,...i,children:[`canonry.ai`,(0,q.jsx)(n,{"aria-hidden":`true`,size:14})]}),(0,q.jsxs)(`a`,{className:`demo-banner-secondary`,href:os,...i,children:[(0,q.jsx)(oe,{"aria-hidden":`true`,size:15}),`GitHub`]}),(0,q.jsxs)(`details`,{onKeyDown:e=>{e.key===`Escape`&&(e.currentTarget.open=!1,e.currentTarget.querySelector(`summary`)?.focus())},children:[(0,q.jsxs)(`summary`,{children:[`Explore `,(0,q.jsx)(o,{"aria-hidden":`true`,size:14})]}),(0,q.jsxs)(`div`,{className:`demo-banner-panel`,children:[(0,q.jsx)(`p`,{className:`demo-banner-panel-agent`,children:cs}),(0,q.jsxs)(`nav`,{className:`demo-banner-examples`,"aria-label":`Demo examples`,children:[(0,q.jsx)(`a`,{href:`${t}/projects/summit-roofing`,children:`Standard business`}),(0,q.jsx)(`a`,{href:`${t}/projects/harbor-resorts`,children:`Property portfolio`})]}),(0,q.jsx)(`nav`,{className:`demo-banner-features`,"aria-label":`Demo feature directory`,children:ls.map(({title:e,links:n})=>(0,q.jsxs)(`section`,{"aria-label":e,children:[(0,q.jsx)(`h2`,{children:e}),(0,q.jsx)(`ul`,{children:n.map(([e,n])=>(0,q.jsx)(`li`,{children:(0,q.jsx)(`a`,{href:`${t}${n}`,children:e})},n))})]},e))})]})]})]}),(0,q.jsx)(`span`,{id:r,hidden:!0,children:`Opens in a new tab`})]})}function ds(e){switch(e){case G[`answer-visibility`]:return`AI Visibility check`;case G[`gsc-sync`]:return`GSC sync`;case G[`inspect-sitemap`]:return`Sitemap inspection`;case G[`ga-sync`]:return`GA sync`;case G[`traffic-sync`]:return`Traffic sync`;case G[`bing-inspect`]:return`Bing URL inspection`;case G[`bing-inspect-sitemap`]:return`Bing sitemap inspection`;case G[`site-audit`]:return`Technical AEO audit`;case G[`backlink-extract`]:return`Backlink extract`;case G[`aeo-discover-seed`]:return`Discovery (seed phase)`;case G[`aeo-discover-probe`]:return`Discovery (probe phase)`;case G[`gbp-sync`]:return`Business Profile sync`;case G[`ads-sync`]:return`ChatGPT ads sync`;case G[`google-ads-sync`]:return`Google Ads sync`;case G[`gtm-sync`]:return`Tag Manager sync`;case G[`seo-sync`]:return`SEO data refresh`}}function fs(e){return e===`running`?`Running`:e===`queued`?`Queued`:e===`partial`?`Partial`:e===`completed`?`Completed`:e===`failed`?`Failed`:e===`cancelled`?`Cancelled`:`Starting`}function ps(){let e=(0,K.useSyncExternalStore)(wi,Ci,Ci),t=(0,K.useMemo)(()=>Object.values(e.runs),[e.runs]),n=t.length>0,r=R({...fr({client:U}),enabled:n,staleTime:Zn}),i=(0,K.useMemo)(()=>new Map((r.data??[]).map(e=>[e.id,e.status])),[r.data]);if(!n)return null;let a=t.map(e=>({...e,status:i.get(e.runId)??e.lastAnnouncedStatus})),s=a.length===1?ds(a[0].kind):`${a.length} active tasks`;return(0,q.jsxs)(`div`,{className:`task-center`,children:[(0,q.jsxs)(`p`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:[a.length,` active `,a.length===1?`task`:`tasks`,`.`,` `,a.map(e=>`${ds(e.kind)} ${fs(e.status)}`).join(`. `),`.`]}),(0,q.jsxs)(`details`,{className:`task-center-details`,children:[(0,q.jsxs)(`summary`,{className:`task-center-trigger`,children:[(0,q.jsx)(O,{className:`size-3.5 shrink-0 motion-safe:animate-spin`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`task-center-summary`,children:s}),(0,q.jsx)(`span`,{className:`task-center-count`,"aria-hidden":`true`,children:a.length}),(0,q.jsx)(o,{className:`task-center-chevron size-3.5 shrink-0`,"aria-hidden":`true`})]}),(0,q.jsxs)(`div`,{className:`task-center-panel`,children:[(0,q.jsxs)(`div`,{className:`task-center-heading`,children:[(0,q.jsx)(`span`,{children:`Active tasks`}),(0,q.jsx)(`span`,{className:`tabular-nums text-faint`,children:a.length})]}),(0,q.jsx)(`ul`,{className:`task-center-list`,children:a.map(e=>(0,q.jsxs)(`li`,{className:`task-center-item`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`p`,{className:`truncate text-[13px] font-medium text-strong`,children:ds(e.kind)}),(0,q.jsx)(`p`,{className:`mt-0.5 truncate text-xs text-muted`,children:e.projectLabel??e.projectId})]}),(0,q.jsx)(xn,{tone:e.status===`failed`?`negative`:e.status===`partial`?`caution`:`neutral`,children:fs(e.status)})]},e.runId))}),(0,q.jsx)(B,{to:`/runs`,className:`task-center-footer-link`,children:`View all runs`})]})]})]})}var ms={scope:`all`,queryClass:`all`},hs=[`all`,`non-brand`,`branded`];function gs(e){return typeof e==`string`&&hs.includes(e)}function _s(e){let t=gs(e.class)?e.class:ms.queryClass,n=e.scope;if(typeof n!=`string`||n===`all`||n.length===0)return{scope:`all`,queryClass:t};let r=n.startsWith(`group:`)?n.slice(6):``;return r?{scope:`group`,groupKey:r,queryClass:t}:{scope:`all`,queryClass:t}}function vs(e,t){return t===null||e===null?!1:e!==t}function ys(e){return{scope:e.scope===`group`&&e.groupKey?`group:${e.groupKey}`:void 0,class:e.queryClass===ms.queryClass?void 0:e.queryClass}}function bs(e,t){if(!(typeof e!=`string`||e.length>16384||!t))try{let n=JSON.parse(e);if(typeof n!=`object`||!n||Array.isArray(n))return;let r=n,i=e=>typeof e==`string`&&e.trim().length>0,a=e=>e===null||i(e);return r.queryKey!==t||!i(r.provider)||r.queryClass!==`branded`&&r.queryClass!==`non-brand`&&r.queryClass!==`unknown`||!a(r.model)||!a(r.location)||!a(r.runId)||r.revision!==null&&(typeof r.revision!=`number`||!Number.isSafeInteger(r.revision)||r.revision<=0)?void 0:{queryKey:t,queryClass:r.queryClass,provider:r.provider,model:r.model,location:r.location,runId:r.runId,revision:r.revision}}catch{return}}function xs(e){let t=t=>typeof e[t]==`string`&&e[t]!==``?e[t]:void 0,n=_s({scope:t(`scope`),class:t(`class`)}),r=t(`measurementScope`)??(n.scope===`group`?`group`:`project`),i=t(`measurementScopeKey`)??(t(`measurementScope`)?void 0:n.groupKey),a=t(`queryClass`)??t(`class`),o={measurementScope:i&&(r===`group`||r===`market`||r===`property`)?r:`project`,queryClass:a===`unknown`||gs(a)?a:ms.queryClass};o.measurementScope!==`project`&&(o.measurementScopeKey=i);for(let[e,n]of[[`measurementMarketKey`,`marketKey`],[`measurementProvider`,`provider`],[`measurementModel`,`model`],[`measurementLocation`,`location`],[`measurementFrom`,`from`],[`measurementTo`,`to`],[`measurementRunId`,`measurementRunId`],[`measurementQueryKey`,`queryKey`]]){let r=t(e);r!==void 0&&(o[n]=r)}let s=Number(e.measurementRevision);Number.isSafeInteger(s)&&s>0&&(o.revision=s);let c=bs(e.measurementAnswer,o.queryKey);return c&&(o.answer=c),o}function Ss(e){return{scope:e.measurementScope,scopeKey:e.measurementScopeKey,marketKey:e.marketKey,queryClass:e.queryClass,provider:e.provider,model:e.model,location:e.location,from:e.from,to:e.to,revision:e.revision,runId:e.measurementRunId,limit:25}}function Cs(e,t){let n={...e,...t};return[`measurementScope`,`measurementScopeKey`,`measurementMarketKey`,`queryClass`,`measurementProvider`,`measurementModel`,`measurementLocation`,`measurementFrom`,`measurementTo`,`measurementRevision`,`measurementRunId`].some(e=>e in t)?(n.measurementQueryKey=t.measurementQueryKey,n.measurementAnswer=t.measurementAnswer):`measurementQueryKey`in t&&!(`measurementAnswer`in t)&&(n.measurementAnswer=void 0),`measurementScope`in t&&(n.scope=void 0,`measurementMarketKey`in t||(n.measurementMarketKey=void 0),n.measurementQueryKey=void 0,t.measurementScope===`project`&&(n.measurementScopeKey=void 0)),`queryClass`in t&&(n.class=void 0),n}function ws(e){return{...e,onboarding:void 0,manageQueries:void 0,siteHealthRunId:void 0,siteScan:void 0,setupProject:void 0}}function Ts(e,t){let n=/\/properties\/([^/]+)/.exec(e),r=xs(t);if(n)return{view:`property`,selection:tn.parse({scope:`property`,scopeKey:decodeURIComponent(n[1]),queryClass:r.queryClass,limit:10})};if(e.endsWith(`/technical-aeo`))return{view:`site-health`};if(e.endsWith(`/seo-data`))return{view:`seo`,...typeof t.seoProfileId==`string`?{seoProfileId:t.seoProfileId}:{},...typeof t.seoRunId==`string`?{seoRunId:t.seoRunId}:{}};if(e.endsWith(`/queries`)&&t.queryWorkspace===`research`)return{view:`project`};let i=/^\/projects\/[^/]+\/?$/.test(e);if(i||e.endsWith(`/queries`)){let t=tn.safeParse(Ss(e.endsWith(`/queries`)?{measurementScope:r.measurementScope,measurementScopeKey:r.measurementScopeKey,queryClass:r.queryClass}:r));return{view:i?`visibility`:`queries`,...t.success?{selection:t.data}:{unavailableReason:`The current measurement filters are invalid. Correct them before asking Aero about this view.`}}}return{view:`project`}}var Es=e(me(),1);function Ds(e,t={}){let{threshold:n=80}=t,r=(0,K.useRef)(null),i=(0,K.useRef)({scrollHeight:0,wasAtEnd:!0});function a(e){return e.scrollHeight-e.scrollTop-e.clientHeight}function o(){let e=r.current;return!e||a(e)<=n}function s(){let e=r.current;e&&(e.scrollTop=e.scrollHeight,i.current.wasAtEnd=!0,i.current.scrollHeight=e.scrollHeight)}return(0,K.useEffect)(()=>{let e=r.current;if(!e)return;let t=()=>{i.current.wasAtEnd=a(e)<=n};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[n]),(0,K.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=e.scrollHeight;t>i.current.scrollHeight&&i.current.wasAtEnd&&(e.scrollTop=t),i.current.scrollHeight=t},e),(0,K.useEffect)(()=>{let e=r.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{let t=e.scrollHeight;t>i.current.scrollHeight&&i.current.wasAtEnd&&(e.scrollTop=t),i.current.scrollHeight=t});return t.observe(e),e.firstElementChild&&t.observe(e.firstElementChild),()=>t.disconnect()},[]),{ref:r,scrollToEnd:s,isAtEnd:o}}var Os=`AI Visibility checks are run by your Canonry team`,ks=`Scans are run by your Canonry team`,As=`Next check unavailable`,js=`Check running…`,Ms=`Next check:`;function Ns(e,t){try{return new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,timeZone:t??`UTC`}).format(new Date(e))}catch{return null}}function Ps({projectName:e,kind:t=G[`answer-visibility`],running:n=!1,loadSchedule:r=!0}){let i=t===G[`site-audit`],a=R({...pr({client:U,path:{name:e},query:{kind:t}}),enabled:r&&!!e,retry:!1,refetchInterval:6e4}),o=a.isError?void 0:a.data,s=o?.enabled&&o.nextRunAt?new Date(o.nextRunAt):null,c=s&&Number.isFinite(s.getTime())?i?s.toLocaleString(`en-GB`,{weekday:`long`,day:`numeric`,month:`short`,hour:`2-digit`,minute:`2-digit`,timeZone:`UTC`,hourCycle:`h23`}):Ns(s.toISOString(),o?.timezone):null,l=(a.error instanceof Pt?a.error.code:a.error?.error?.code)===`NOT_FOUND`,u=!c||l||!o?.enabled;return(0,q.jsx)(`p`,{className:`text-sm text-secondary`,role:`status`,children:i?(0,q.jsxs)(q.Fragment,{children:[n&&(0,q.jsx)(`span`,{className:`text-neutral`,children:`Scan running… · `}),c&&s?(0,q.jsxs)(q.Fragment,{children:[`Next scan `,(0,q.jsxs)(`time`,{dateTime:s.toISOString(),children:[c,` UTC`]}),` · managed by your Canonry team`]}):ks]}):n?js:u?As:c&&s?(0,q.jsxs)(q.Fragment,{children:[Ms,` `,(0,q.jsx)(`time`,{dateTime:s.toISOString(),children:c})]}):As})}var Fs=300,Is=400,Ls=900,Rs=32,zs=28,Bs=0;function Vs(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Hs(){return new DOMException(`Preview stopped`,`AbortError`)}function Us(e,t){return t?.aborted?Promise.reject(Hs()):new Promise((n,r)=>{let i=()=>{clearTimeout(a),r(Hs())},a=setTimeout(()=>{t?.removeEventListener(`abort`,i),n()},e);t?.addEventListener(`abort`,i,{once:!0})})}function Ws(e){let t=e.match(/\S+\s*|\s+/g)??[];if(t.length<2)return[];let n=Math.ceil(t.length/Rs),r=[];for(let e=n;e<t.length;e+=n)r.push(t.slice(0,e).join(``));return r}function Gs(e){return typeof e==`string`?e:JSON.stringify(e??null)}async function Ks({starter:e,signal:t,onEvent:n,reducedMotion:r=!1}){let i=async e=>{if(t?.aborted)throw Hs();r||await Us(e,t)},a=Date.now(),o=++Bs;await i(Fs);for(let[t,r]of e.steps.entries()){let{name:a,label:s,arguments:c,result:l,durationMs:u}=r.tool,d=`preview-${e.id}-${o}-${t}`;n({type:`message_end`,message:{role:`assistant`,timestamp:Date.now(),stopReason:`toolUse`,content:[...r.text?[{type:`text`,text:r.text}]:[],{type:`toolCall`,id:d,name:a,arguments:c}]}}),n({type:`tool_execution_start`,toolCallId:d,toolName:a,label:s,args:c}),await i(Math.min(Ls,Math.max(Is,u))),n({type:`tool_execution_end`,toolCallId:d,toolName:a,result:l,isError:!1}),n({type:`message_end`,message:{role:`toolResult`,toolCallId:d,timestamp:Date.now(),isError:!1,aeroToolLabel:s,aeroDurationMs:u,content:[{type:`text`,text:Gs(l)}]}})}if(!r){for(let t of Ws(e.answer))await i(zs),n({type:`message_update`,message:{role:`assistant`,content:[{type:`text`,text:t}]},assistantMessageEvent:{}});await i(zs)}n({type:`message_end`,message:{role:`assistant`,timestamp:Date.now(),stopReason:`stop`,content:[{type:`text`,text:e.answer}]}}),n({type:`aero_turn_status`,status:{reason:`completed`,toolCalls:e.steps.length,modelCalls:e.steps.length+1,durationMs:Date.now()-a}})}async function qs(e){try{return await e.json()}catch{return{}}}function Js(){return typeof window<`u`&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath.replace(/\/$/,``)+`/api/v1`:`/api/v1`}var Ys=Js();function Xs(e){e===401&&Ht()}async function Zs(e){let t=await fetch(`${Ys}/projects/${encodeURIComponent(e)}/agent/transcript`,{credentials:`include`});if(!t.ok){Xs(t.status);let e=await qs(t);throw new Pt(e.error?.message??`transcript fetch failed: ${t.status}`,t.status,e.error?.code)}return await t.json()}async function Qs(e){let t=await fetch(`${Ys}/projects/${encodeURIComponent(e)}/agent/preview`,{credentials:`include`});if(!t.ok){Xs(t.status);let e=await qs(t);throw new Pt(e.error?.message??`preview fetch failed: ${t.status}`,t.status,e.error?.code)}return await t.json()}async function $s(e){let t=await fetch(`${Ys}/projects/${encodeURIComponent(e)}/agent/transcript`,{method:`DELETE`,credentials:`include`});if(!t.ok){Xs(t.status);let e=await qs(t);throw new Pt(e.error?.message??`reset failed: ${t.status}`,t.status,e.error?.code)}}async function ec({project:e,prompt:t,conversationId:n,provider:r,modelId:i,scope:a,profile:o,context:s,limits:c,signal:l,onEvent:u}){let d={prompt:t};n!==void 0&&(d.conversationId=n),r&&(d.provider=r),i&&(d.modelId=i),a&&(d.scope=a),o&&(d.profile=o),s&&(d.context=s),c&&(d.limits=c);let f=await fetch(`${Ys}/projects/${encodeURIComponent(e)}/agent/prompt`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify(d),signal:l});if(!f.ok||!f.body){Xs(f.status),Mn({method:`POST`,route:`/api/v1/projects/{name}/agent/prompt`,status:f.status});let e=await qs(f);throw new Pt(e.error?.message??`prompt failed: ${f.status}`,f.status,e.error?.code)}Ge(`aero.send`);let p=!1,m=f.body.getReader(),h=new TextDecoder,g=``,_=()=>{m.cancel().catch(()=>{})};l?.addEventListener(`abort`,_,{once:!0}),l?.aborted&&_();try{for(;;){let{value:e,done:t}=await m.read();if(t)break;g+=h.decode(e,{stream:!0});let n=g.indexOf(`
14
14
 
15
15
  `);for(;n!==-1;){let e=g.slice(0,n);g=g.slice(n+2);for(let t of e.split(`
16
16
  `)){if(!t.startsWith(`data:`))continue;let e=t.slice(5).trim();if(!e)continue;let n;try{n=JSON.parse(e)}catch{continue}n.type===`stream_close`&&(p=!0),u(n)}n=g.indexOf(`
17
17
 
18
- `)}}if(l?.aborted)throw new DOMException(`Turn stopped`,`AbortError`);if(!p)throw Error(`Connection ended before Aero finished. Review the partial answer before retrying.`)}finally{l?.removeEventListener(`abort`,_);try{m.releaseLock()}catch{}}}function tc(e){return!e||e.role!==`assistant`?``:e.content.filter(e=>e.type===`text`).map(e=>e.text).join(``)}var nc=[{id:`status`,label:`Status`,prompt:`Give me a quick status: the latest check, which engines answered, and anything that needs attention.`},{id:`changes`,label:`What changed`,prompt:`Compare the latest complete check with the one before it. Lead with mentions, then citations. Keep branded and non-brand queries separate if the project splits them, and say which changes are bigger than normal run-to-run noise.`},{id:`gaps`,label:`Biggest gaps`,prompt:`Which tracked queries does no engine mention us on, and who gets named instead? Group them by topic or market.`},{id:`insights`,label:`Top insights`,prompt:`Walk me through the 3 most severe active insights and what to do about each.`}],rc=`https://canonry.ai`,ic=`This demo plays sample answers only. Pick a starting point, or type / to choose one.`,ac=`Stopped. The sample answer so far is kept.`;function oc(e){return{queryKey:[`aero-preview`,e],queryFn:()=>Qs(e),staleTime:1/0,gcTime:1/0}}var sc=[{command:`/status`,label:`Status`,prompt:`Give me a quick status: the latest check, which engines answered, and anything that needs attention.`},{command:`/changes`,label:`What changed`,prompt:`Compare the latest complete check with the one before it. Lead with mentions, then citations. Keep branded and non-brand queries separate if the project splits them, and say which changes are bigger than normal run-to-run noise.`},{command:`/gaps`,label:`Biggest gaps`,prompt:`Which tracked queries does no engine mention us on, and who gets named instead? Group them by topic or market.`},{command:`/insights`,label:`Top insights`,prompt:`Walk me through the 3 most severe active insights and what to do about each.`},{command:`/last-run`,label:`Last run`,prompt:`Summarize the latest run for this project: which engines answered, what moved in mentions and citations, and anything that failed.`},{command:`/run-sweep`,label:`Run check now`,prompt:`Run a new AI Visibility check for this project now and tell me when it lands.`},{command:`/queries`,label:`Queries`,prompt:`List the tracked queries for this project and flag any that are obvious duplicates or underperformers.`},{command:`/competitors`,label:`Competitors`,prompt:`Which competitors do engines name most often on queries where we are not named, and on which engines?`},{command:`/new`,label:`New conversation (save current)`,action:`new`}],cc=e=>`canonry:aero:provider:${e}`,lc=(e,t)=>`canonry:aero:model:${e}:${t}`,uc=e=>`canonry:aero:openrouter-model:${e}`;function dc(e){let t={};for(let n of Object.values(Nn)){let r=pc(lc(e,n))??(n===Nn.openrouter?pc(uc(e)):null);r&&(t[n]=r)}return t}var fc=e=>`canonry:aero:scope:${e}`;function pc(e){if(typeof window>`u`)return null;try{return window.localStorage.getItem(e)}catch{return null}}function mc(e,t){if(typeof window<`u`)try{window.localStorage.setItem(e,t)}catch{}}function hc(e){if(typeof window<`u`)try{window.localStorage.removeItem(e)}catch{}}function gc({projectName:e,context:t,preview:r=zt()}){let a=_t(),{canWrite:o,account:s}=Jn(),c=ge(),l=s?.role===`viewer`,[u,d]=(0,K.useState)(!1),[f,p]=(0,K.useState)(!1),[h,g]=(0,K.useState)([]),[_,v]=(0,K.useState)(void 0),y=(0,K.useRef)(!1),[b,x]=(0,K.useState)(!1),[S,C]=(0,K.useState)(!1),[w,T]=(0,K.useState)(null),[D,O]=(0,K.useState)(!1),[A,j]=(0,K.useState)(!1),[te,ne]=(0,K.useState)(null),re=(0,K.useRef)(!1),[ae,oe]=(0,K.useState)(``),[se,ce]=(0,K.useState)(!1),[le,ue]=(0,K.useState)([]),[de,fe]=(0,K.useState)(``),[pe,P]=(0,K.useState)(null),[me,F]=(0,K.useState)(null),[I,he]=(0,K.useState)(null),_e=(0,K.useRef)(!0),[L,ve]=(0,K.useState)(()=>pc(cc(e))??null),ye=a||l||r?null:L,[be,xe]=(0,K.useState)(()=>dc(e)),[Se,Ce]=(0,K.useState)(null),[z]=(0,K.useState)(()=>pc(fc(e))===`all`?`all`:`read-only`),we=a||l||r?`read-only`:z,Te=(0,K.useRef)(null),Ee=(0,K.useRef)(null),De=(0,K.useRef)(null),Oe=(0,K.useRef)(null),{ref:ke}=Ds([h,de,le]),Ae=(0,K.useRef)(null);(0,K.useLayoutEffect)(()=>{let e=Ae.current;if(!e)return;e.style.height=`auto`;let t=f?xc:bc;e.scrollHeight>0&&(e.style.height=`${Math.min(e.scrollHeight,t)}px`)},[ae,f,u]);let[je,Me]=(0,K.useState)(0),Ne=(0,K.useMemo)(()=>{let e=ae.trimStart();if(!e.startsWith(`/`)||/\s/.test(e))return[];let t=e.toLowerCase();return sc.filter(e=>(!(a||l)||e.command!==`/run-sweep`)&&(!l||e.action!==`new`)&&(!r||nc.some(t=>t.prompt===e.prompt))&&(e.command.startsWith(t)||e.label.toLowerCase().includes(t.slice(1))))},[ae,a,l,r]);(0,K.useEffect)(()=>{Me(e=>Ne.length===0?0:Math.min(e,Ne.length-1))},[Ne.length]);let Pe=R({...mr({client:U,path:{name:e}}),enabled:!l&&!r,staleTime:6e4}),Fe=(0,K.useMemo)(()=>{let e=Pe.data?.providers??[];if(ye){let t=e.find(e=>e.id===ye&&e.configured);if(t)return t}let t=Se?e.find(e=>e.id===Se.provider&&e.configured):void 0;if(t)return t;let n=Pe.data?.defaultProvider;return n?e.find(e=>e.id===n)??null:null},[ye,Pe.data,Se]),Ie=l||r||Fe!==null,Le=Fe?be[Fe.id]??``:``,Re=!ye&&Fe&&Se?.provider===Fe.id?Se.modelId:void 0,ze=!a&&!l&&!r&&Fe&&Le.trim()?Le.trim():void 0,Ve=(ze?Fe?.id:void 0)??ye??void 0,He=(0,K.useCallback)((t,n)=>{let r=n.trim();xe(e=>({...e,[t]:n})),r?mc(lc(e,t),r):hc(lc(e,t)),t===Nn.openrouter&&hc(uc(e))},[e]);R({...oc(e),enabled:r&&u}),(0,K.useEffect)(()=>{Pe.data&&ye&&(Pe.data.providers.find(e=>e.id===ye&&e.configured)||(ve(null),hc(cc(e))))},[Pe.data,ye,e]);let Ue=(0,K.useCallback)(t=>{ve(t),t?mc(cc(e),t):hc(cc(e))},[e]);(0,K.useEffect)(()=>{if(!u)return;let e=e=>{e.key===`Escape`&&(S?C(!1):f?p(!1):d(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u,f,S]);let We=(0,K.useRef)(null);(0,K.useEffect)(()=>{u||(We.current=null)},[u]),(0,K.useEffect)(()=>{if(!u||!Ie||r)return;let t=!1;We.current!==e&&(We.current=e,P(null));let n=()=>{t||se||re.current||Zs(e).then(e=>{t||re.current||(j(e.isStreaming??!1),v(e.conversationId??null),Ce(e.nextTurn??null),!t&&!e.isStreaming&&(Ee.current===null||e.updatedAt&&e.updatedAt!==Ee.current.previous)&&(g(e.messages),Te.current=e.updatedAt,Ee.current=null))}).catch(e=>{t||P(mt(e))})};n();let i=window.setInterval(n,15e3);return()=>{t=!0,window.clearInterval(i)}},[u,e,se,Ie,D,r]),(0,K.useEffect)(()=>(_e.current=!0,()=>{_e.current=!1,Oe.current?.abort()}),[e]);async function Ke(n,i=t){let o=n.trim();if(!o||S||se||D||re.current||A||!Ie)return;if(r){await qe(o);return}if(a&&/^\/run-sweep(?:\s|$)/i.test(o)){P(Os);return}P(null),F(null),he({prompt:o,context:i}),oe(``),ce(!0),fe(``),De.current=null,ue([]),Ee.current={previous:Te.current};let s={role:`user`,content:o,timestamp:Date.now(),aeroContext:i};g(e=>[...e,s]);let c=new AbortController;Oe.current=c;try{await ec({project:e,prompt:o,conversationId:_,provider:Ve,modelId:ze,scope:we,context:i,signal:c.signal,onEvent:Je});let t=await Zs(e);_e.current&&!t.isStreaming&&(v(t.conversationId??null),Ce(t.nextTurn??null),g(t.messages),Te.current=t.updatedAt,Ee.current=null)}catch(e){if(!_e.current)return;l&&(Ee.current=null);let t=De.current;t&&tc(t).trim()&&g(e=>[...e,t]),c.signal.aborted?F(`Stopped. Partial response preserved. An action already dispatched may still finish.`):P(mt(e))}finally{_e.current&&(ce(!1),fe(``),ue(e=>e.map(e=>e.endedAt===void 0?{...e,interrupted:!0}:e))),Oe.current=null}}async function qe(t){let n=sc.find(e=>e.command===t.toLowerCase())?.prompt??t,r=nc.find(e=>e.prompt===n)?.id;if(!r){P(null),he(null),F(ic);return}P(null),F(null),he({prompt:n}),oe(``),ce(!0),fe(``),De.current=null,ue([]),g(e=>[...e,{role:`user`,content:n,timestamp:Date.now()}]);let i=new AbortController;Oe.current=i;try{let t=await c.ensureQueryData(oc(e));if(i.signal.aborted)throw new DOMException(`Preview stopped`,`AbortError`);let n=t.starters.find(e=>e.id===r);if(!n)throw Error(`This demo has no sample answer for that starting point.`);await Ks({starter:n,signal:i.signal,onEvent:Je,reducedMotion:Vs()})}catch(e){if(!_e.current)return;let t=De.current;t&&tc(t).trim()&&g(e=>[...e,t]),i.signal.aborted?F(ac):P(mt(e))}finally{_e.current&&(ce(!1),fe(``),ue(e=>e.map(e=>e.endedAt===void 0?{...e,interrupted:!0}:e))),Oe.current=null}}function Je(e){if(_e.current)switch(e.type){case`message_update`:e.message.role===`assistant`&&(De.current=e.message),fe(tc(e.message));break;case`message_end`:if(e.message.role!==`user`){let t=e.message;g(e=>[...e,t])}e.message.role===`assistant`&&(De.current=null,fe(``),e.message.errorMessage&&P(e.message.errorMessage));break;case`aero_turn_status`:e.status?.reason===`tool-limit`?F(`Tool-call limit reached. Partial response preserved.`):e.status?.reason===`time-limit`?F(`Time limit reached. Partial response preserved.`):e.status?.reason===`completed`?he(null):e.status?.reason===`error`&&P(e=>e??`Aero could not finish this answer. Retry to ask again.`);break;case`tool_execution_start`:ue(t=>[...t,{id:e.toolCallId,name:e.toolName,label:e.label,args:e.args,startedAt:Date.now()}]);break;case`tool_execution_end`:ue(t=>t.map(t=>t.id===e.toolCallId?{...t,endedAt:Date.now(),isError:e.isError,result:e.result}:t));break;case`error`:P(e.message)}}async function Ye(t,n=!1){if(!(se||A||re.current)){re.current=!0,O(!0),P(null);try{await t();let r=await Zs(e);if(!_e.current)return;Ee.current=null,Te.current=r.updatedAt,v(r.conversationId??null),Ce(r.nextTurn??null),g(r.messages),ue([]),fe(``),F(null),he(null),ne(null),C(n),T(n?await bt(e):null),Ae.current?.focus()}catch(e){_e.current&&P(mt(e))}finally{re.current=!1,_e.current&&O(!1)}}}async function Xe(){if(r){if(se)return;g([]),ue([]),fe(``),P(null),F(null),he(null),Ae.current?.focus()}else await Ye(()=>l?$s(e):Dn(e,crypto.randomUUID()))}async function Ze(t=!1){if(!(re.current||y.current)){y.current=!0,x(!0),C(!0),P(null);try{let n=await bt(e,{offset:t?w?.nextOffset??0:0});_e.current&&T(e=>t&&e?{...n,conversations:[...e.conversations,...n.conversations]}:n)}catch(e){_e.current&&P(mt(e))}finally{y.current=!1,_e.current&&x(!1)}}}let Qe=h.length===0,$e=!(l||r);if($e&&Pe.isPending)return null;if($e&&Pe.isError)return(0,q.jsx)(`div`,{className:`pointer-events-none fixed inset-x-0 bottom-0 z-40 flex justify-center p-3`,children:(0,q.jsxs)(`div`,{role:`status`,className:`flex w-full max-w-3xl flex-wrap items-center gap-x-2 gap-y-1 rounded-lg border border-base bg-bg/95 px-4 py-2 text-sm shadow-lg`,children:[(0,q.jsx)(N,{className:`h-4 w-4 text-muted`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`font-medium text-strong`,children:`Aero could not check provider availability.`}),(0,q.jsx)(W,{variant:`outline`,size:`sm`,className:`pointer-events-auto ml-auto`,onClick:()=>{Pe.refetch()},children:`Try again`})]})});let et=Fe&&!Fe.configured?Fe:null;if($e&&(!Fe||et))return(0,q.jsx)(`div`,{className:`pointer-events-none fixed inset-x-0 bottom-0 z-40 flex justify-center p-3`,children:(0,q.jsxs)(`div`,{role:`status`,className:`flex w-full max-w-3xl flex-wrap items-center gap-x-2 gap-y-1 rounded-lg border border-base bg-bg/95 px-4 py-2 text-sm shadow-lg`,children:[(0,q.jsx)(N,{className:`h-4 w-4 text-muted`,"aria-hidden":`true`}),(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5 font-medium text-strong`,children:[et?`Aero is set to ${et.label.replace(/\s+\(.+\)$/,``)}, which has no API key.`:`Aero needs an answer-engine provider.`,(0,q.jsx)(Tr,{text:et?`Set ${Tc(et.id)} on the server, or providers.${et.id}.apiKey in its config.yaml.`:`Aero is the built-in AEO analyst. It reads your Canonry data with you once a provider is connected.`})]}),et?null:o?(0,q.jsx)(W,{asChild:!0,variant:`outline`,size:`sm`,className:`pointer-events-auto ml-auto`,children:(0,q.jsx)(B,{to:`/settings`,children:`Open Settings`})}):(0,q.jsx)(`span`,{className:`ml-auto text-secondary`,children:`Ask an administrator to configure one.`})]})});let tt=u&&f?`pointer-events-auto fixed inset-0 z-40 flex items-stretch justify-center bg-bg/70 p-4 sm:p-8 backdrop-blur-sm`:`pointer-events-none fixed inset-x-0 bottom-0 z-40 flex justify-center p-3`,nt=f?`pointer-events-auto flex h-full w-full max-w-5xl flex-col overflow-hidden rounded-2xl border border-mono-800/80 bg-bg/95 shadow-2xl`:`pointer-events-auto w-full max-w-3xl`,rt=f?`flex-1 overflow-y-auto px-6 py-5 text-sm text-strong`:`max-h-[40vh] min-h-[120px] overflow-y-auto px-4 py-3 text-sm text-strong`;return(0,q.jsx)(`div`,{className:tt,onClick:e=>{f&&e.target===e.currentTarget&&p(!1)},children:(0,q.jsx)(`div`,{className:nt,children:u?(0,q.jsxs)(`div`,{"data-aero-panel":!0,className:f?`flex h-full flex-col`:`flex flex-col overflow-hidden rounded-2xl border border-mono-800/80 bg-bg/95 shadow-xl backdrop-blur`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-mono-800/70 px-4 py-2.5`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(N,{className:`h-4 w-4 shrink-0 text-positive-400`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`text-sm font-medium text-heading`,children:`Aero`}),(0,q.jsx)(`span`,{className:`hidden min-w-0 truncate text-[10px] uppercase tracking-wider text-muted sm:inline`,children:se||A?`working…`:e})]}),(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[!a&&!l&&!r&&(0,q.jsx)(vc,{providers:Pe.data?.providers??[],active:Fe,override:ye,onPick:Ue,modelId:Le,fallbackModel:Re,onModelChange:e=>{Fe&&He(Fe.id,e)},disabled:se}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>p(e=>!e),className:`shrink-0 rounded-md p-1.5 text-muted transition hover:bg-surface-inset hover:text-strong`,"aria-label":f?`Collapse`:`Expand`,title:f?`Collapse`:`Expand`,children:f?(0,q.jsx)(i,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}):(0,q.jsx)(ee,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{p(!1),d(!1)},className:`shrink-0 rounded-md p-1.5 text-muted transition hover:bg-surface-inset hover:text-strong`,"aria-label":`Close Aero`,children:(0,q.jsx)(ie,{className:`h-4 w-4`,"aria-hidden":`true`})})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-subtle px-4 py-2`,children:[(0,q.jsxs)(W,{variant:`outline`,size:`sm`,disabled:se||A||D,onClick:Xn(Xe),title:l||r?`Clear this conversation and start fresh.`:`Save this conversation and start fresh. Shared project notes are kept.`,children:[(0,q.jsx)(M,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),` New conversation`]}),!l&&!r&&(0,q.jsxs)(W,{variant:`ghost`,size:`sm`,"aria-expanded":S,"aria-controls":`aero-history`,disabled:D,onClick:()=>{S?C(!1):Ze()},children:[(0,q.jsx)(E,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),` History`]})]}),S?(0,q.jsxs)(`div`,{id:`aero-history`,className:rt,"aria-label":`Conversation history`,children:[(0,q.jsxs)(`h3`,{className:`mb-2 text-sm font-medium text-heading`,children:[`Conversations in `,e]}),w?w.conversations.length===0?(0,q.jsx)(`p`,{className:`text-sm text-secondary`,children:`No saved conversations yet. Your conversations will appear here.`}):(0,q.jsx)(`ul`,{className:`divide-y divide-default`,children:w.conversations.map(t=>(0,q.jsxs)(`li`,{className:`py-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(`button`,{className:`min-w-0 flex-1 rounded-md px-2 py-1 text-left hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-positive-500`,disabled:se||A||D,onClick:()=>{t.active?C(!1):Ye(()=>zn(e,t.id))},children:[(0,q.jsx)(`span`,{className:`block truncate text-sm text-heading`,children:t.title}),(0,q.jsxs)(`span`,{className:`text-xs text-secondary`,children:[t.active?`Current · `:``,new Date(t.updatedAt).toLocaleString()]})]}),(0,q.jsx)(W,{variant:`ghost`,size:`sm`,disabled:se||A||D,"aria-label":`Delete conversation: ${t.title}`,onClick:()=>ne(t.id),children:`Delete`})]}),te===t.id&&(0,q.jsxs)(`div`,{role:`group`,"aria-label":`Confirm conversation deletion`,className:`mt-2 rounded-md border border-default p-3 text-sm text-secondary`,children:[(0,q.jsx)(`p`,{children:`Delete this conversation permanently? Shared project notes will be kept.`}),(0,q.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,q.jsx)(W,{variant:`destructive`,size:`sm`,disabled:D,onClick:()=>{Ye(async()=>{await Be(e,t.id)},!0)},children:`Delete conversation`}),(0,q.jsx)(W,{variant:`ghost`,size:`sm`,disabled:D,onClick:()=>ne(null),children:`Cancel`})]})]})]},t.id))}):(0,q.jsx)(`p`,{className:`text-sm text-secondary`,children:b?`Loading history…`:`History could not be loaded. Close and reopen History to retry.`}),w?.nextOffset!=null&&(0,q.jsx)(W,{variant:`ghost`,size:`sm`,disabled:b,onClick:()=>{Ze(!0)},children:b?`Loading…`:`Load more`})]}):(0,q.jsxs)(`div`,{ref:ke,className:rt,children:[Qe&&!se&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 py-2`,children:[(0,q.jsx)(`p`,{className:`text-sm text-secondary`,children:r?(0,q.jsxs)(q.Fragment,{children:[`See how Aero answers about `,(0,q.jsx)(`span`,{className:`text-strong`,children:e}),`. Choose a starting point.`]}):(0,q.jsxs)(q.Fragment,{children:[`Ask about `,(0,q.jsx)(`span`,{className:`text-strong`,children:e}),` or choose a starting point.`]})}),(0,q.jsx)(wc,{onPick:e=>{Ke(e)}})]}),Dc(h,e,Ve??null,we,le,se,!!de.trim(),!l&&!r,ze),se&&de&&(0,q.jsxs)(`div`,{className:`mt-3`,children:[(0,q.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wider text-positive-400`,children:`Aero`}),(0,q.jsx)(qc,{content:de})]}),se&&!de&&le.every(e=>e.endedAt!==void 0)&&(0,q.jsx)(Jc,{}),r&&!Qe&&!se&&(0,q.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-subtle pt-3`,children:[(0,q.jsx)(`p`,{className:`text-xs text-secondary`,children:`Try another starting point.`}),(0,q.jsx)(wc,{onPick:e=>{Ke(e)}})]})]}),(pe||me)&&(0,q.jsxs)(`div`,{role:pe?`alert`:`status`,className:`mx-3 my-2 flex flex-wrap items-center gap-2 rounded-md border border-base bg-surface px-3 py-2 text-sm text-secondary`,children:[(0,q.jsx)(`span`,{className:`flex-1`,children:pe??me}),I&&!se&&(0,q.jsx)(W,{variant:`outline`,size:`sm`,onClick:()=>{we===`all`?(oe(I.prompt),Ae.current?.focus()):Ke(I.prompt,I.context)},children:we===`all`?`Review prompt`:`Retry`})]}),r&&(0,q.jsxs)(`p`,{className:`border-t border-subtle px-4 py-2 text-xs text-secondary`,children:[`Sample answers on demo data.`,` `,(0,q.jsxs)(`a`,{href:rc,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-0.5 text-positive-400 underline decoration-positive-700 hover:decoration-positive-400`,children:[`Aero answers from your own Canonry data.`,(0,q.jsx)(n,{className:`h-3 w-3`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`sr-only`,children:` (opens in a new tab)`})]})]}),(0,q.jsxs)(`div`,{className:`relative`,children:[!S&&Ne.length>0&&(0,q.jsx)(Cc,{title:r?`Starting points`:`Commands`,matches:Ne,selectedIndex:je,onHover:Me,onPick:e=>{oe(``),Ae.current?.focus(),e.action===`new`?Xe():Ke(e.prompt)}}),(0,q.jsxs)(`form`,{className:`flex items-end gap-2 border-t border-mono-800/70 bg-bg/80 px-3 py-2.5`,onSubmit:e=>{if(e.preventDefault(),Ne.length>0){let e=Ne[je];oe(``),e.action===`new`?Xe():Ke(e.prompt)}else Ke(ae)},children:[(0,q.jsx)(`textarea`,{ref:Ae,value:ae,onChange:e=>oe(e.target.value),onKeyDown:e=>{if(Ne.length>0){if(e.key===`ArrowDown`){e.preventDefault(),Me(e=>(e+1)%Ne.length);return}if(e.key===`ArrowUp`){e.preventDefault(),Me(e=>(e-1+Ne.length)%Ne.length);return}if(e.key===`Tab`){e.preventDefault();let t=Ne[je];oe(`${t.command} `);return}if(e.key===`Escape`){e.preventDefault(),oe(``);return}}if(e.key===`Enter`&&!e.shiftKey){if(e.preventDefault(),Ne.length>0){let e=Ne[je];oe(``),e.action===`new`?Xe():Ke(e.prompt)}else Ke(ae)}},disabled:S||D,placeholder:S?`Open a conversation to continue…`:r?`Type / for a starting point`:`Ask Aero, or / for commands…`,"aria-label":`Message Aero`,rows:f?3:1,className:`flex-1 resize-none overflow-y-auto bg-transparent text-sm text-heading placeholder:text-mono-600 focus:outline-none disabled:opacity-60`}),se?(0,q.jsxs)(W,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>Oe.current?.abort(),"aria-label":`Stop Aero`,children:[(0,q.jsx)(k,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),` Stop`]}):(0,q.jsx)(W,{type:`submit`,size:`sm`,disabled:!ae.trim()||S||D||A,"aria-label":`Send`,children:(0,q.jsx)(m,{className:`h-4 w-4`,"aria-hidden":`true`})})]})]})]}):(0,q.jsx)(`button`,{type:`button`,onClick:()=>{d(!0),Ge(`aero.open`)},className:`flex w-full items-center justify-between rounded-lg border border-mono-800/80 bg-bg/95 px-4 py-2 text-left text-sm text-secondary shadow-lg transition hover:border-strong hover:bg-bg-elevated/90 hover:text-strong`,children:(0,q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(N,{className:`h-4 w-4 text-positive-400`,"aria-hidden":`true`}),`Ask Aero about `,e,`…`]})})})})}function _c(e,t){return/\s/.test(t)?`Model IDs have no spaces.`:e===Nn.openrouter&&!rn.test(t)?`Use publisher/model, for example openai/gpt-6-luna.`:null}function vc({providers:e,active:t,override:n,onPick:r,modelId:i,fallbackModel:a,onModelChange:s,disabled:c}){let[u,d]=(0,K.useState)(!1),[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(``),[v,y]=(0,K.useState)(null),b=(0,K.useRef)(null),x=(0,K.useRef)(null),S=(0,K.useRef)(null),C=(0,K.useId)(),w=(0,K.useId)(),T=(0,K.useId)(),E=(0,K.useCallback)(e=>{d(!1),p(null),h(!1),y(null),e&&b.current?.focus()},[]),D=(0,K.useCallback)(()=>{let e=b.current?.getBoundingClientRect();if(!e)return;let t=window.innerHeight-e.bottom-8,n=e.top-8,r=Math.max(8,window.innerWidth-e.right);p(t>=n?{top:e.bottom+4,right:r,maxHeight:t-4}:{bottom:window.innerHeight-e.top+4,right:r,maxHeight:n-4})},[]);(0,K.useLayoutEffect)(()=>{u&&D()},[u,D]);let O=f!==null;if((0,K.useEffect)(()=>{if(!u||!O)return;let e=yc(x.current);(e.find(e=>e.getAttribute(`aria-checked`)===`true`&&e.closest(`[data-menu-group="model"]`))??e[0])?.focus()},[u,O]),(0,K.useEffect)(()=>{m&&S.current?.focus()},[m]),(0,K.useEffect)(()=>{if(!u)return;let e=e=>{let t=e.target;b.current?.contains(t)||x.current?.contains(t)||E(!1)},t=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),E(!0))};return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t,!0),window.addEventListener(`resize`,D),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t,!0),window.removeEventListener(`resize`,D)}},[u,E,D]),e.length===0)return null;let ee=e.filter(e=>e.configured),k=ee.length<e.length,A=t?.configured?t.models??[]:[],j=i.trim()||a||t?.defaultModel||``,te=A.find(e=>e.id===j)?.displayName??j,ne=!!(t?.configured&&j&&!A.some(e=>e.id===j)),re=t?t.label.replace(/\s+\(.+\)$/,``):`No provider`,ie=e=>{let t=e.target;if(e.key===`Tab`){let n=t.closest(`[data-other-model-form]`),r=t.tagName===`INPUT`;if(n&&(r&&!e.shiftKey||!r&&e.shiftKey))return;e.preventDefault(),E(!0);return}if(!t.matches(`[role^="menuitem"]`))return;let n=yc(x.current),r=n.indexOf(t),i=e.key===`ArrowDown`?n[(r+1)%n.length]:e.key===`ArrowUp`?n[(r-1+n.length)%n.length]:e.key===`Home`?n[0]:e.key===`End`?n[n.length-1]:void 0;i&&(e.preventDefault(),i.focus())},ae=()=>{if(!t)return;let e=g.trim();if(!e){y(`Enter a model ID.`);return}let n=_c(t.id,e);n?y(n):(s(e),E(!0))},M=`flex min-h-10 w-full items-center gap-2 px-3 py-2 text-left text-sm text-heading transition outline-none hover:bg-bg-elevated focus-visible:bg-bg-elevated focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-mono-400 disabled:opacity-60`,N=e=>(0,q.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center`,children:e?(0,q.jsx)(l,{className:`h-3.5 w-3.5 text-positive-400`,"aria-hidden":`true`}):null});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`button`,{ref:b,type:`button`,onClick:()=>u?E(!1):d(!0),onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),d(!0))},disabled:c,className:`flex min-h-8 min-w-0 items-center gap-1 rounded-md px-2 py-1 text-sm text-secondary transition hover:bg-surface-inset hover:text-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400 disabled:opacity-50`,"aria-haspopup":`menu`,"aria-expanded":u,"aria-controls":u?C:void 0,title:t?`${t.label} · ${j}`:`Pick a provider`,children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Aero model: `}),(0,q.jsx)(`span`,{className:`min-w-0 truncate font-medium text-strong`,children:t?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`span`,{className:`hidden sm:inline`,children:[re,` · `]}),te]}):re}),(0,q.jsx)(o,{className:`h-3 w-3 shrink-0`,"aria-hidden":`true`})]}),u&&f&&(0,Es.createPortal)((0,q.jsxs)(`div`,{ref:x,id:C,role:`menu`,"aria-label":`Aero model`,onKeyDown:ie,style:{position:`fixed`,top:f.top,bottom:f.bottom,right:f.right,maxHeight:f.maxHeight},className:`z-50 w-72 max-w-[calc(100vw-1rem)] overflow-y-auto rounded-lg border border-base bg-bg py-1 shadow-xl`,children:[(0,q.jsxs)(`div`,{role:`group`,"aria-labelledby":w,children:[(0,q.jsx)(`div`,{id:w,className:`px-3 pb-1 pt-2 text-sm font-medium text-secondary`,children:`Provider`}),ee.map(e=>{let n=t?.id===e.id;return(0,q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":n,tabIndex:-1,onClick:()=>{n||r(e.id),E(!0)},className:M,children:[N(n),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label.replace(/\s+\(.+\)$/,``)})]},e.id)}),n&&(0,q.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,onClick:()=>{r(null),E(!0)},className:`${M} text-secondary`,children:[N(!1),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Use default provider`})]}),k&&(0,q.jsxs)(B,{to:`/settings`,role:`menuitem`,tabIndex:-1,onClick:()=>E(!1),className:`${M} text-secondary`,children:[N(!1),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Connect another provider`})]})]}),t?.configured&&(0,q.jsxs)(`div`,{role:`group`,"aria-labelledby":T,"data-menu-group":`model`,className:`mt-1 border-t border-default`,children:[(0,q.jsx)(`div`,{id:T,className:`px-3 pb-1 pt-2 text-sm font-medium text-secondary`,children:`Model`}),A.map(e=>{let n=e.id===j,r=e.id===t.defaultModel;return(0,q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":n,tabIndex:-1,onClick:()=>{s(e.id),E(!0)},className:M,title:e.id,children:[N(n),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.displayName}),r&&(0,q.jsx)(`span`,{className:`shrink-0 text-sm text-secondary`,children:`Default`})]},e.id)}),ne&&(0,q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!0,tabIndex:-1,onClick:()=>E(!0),className:M,title:j,children:[N(!0),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[13px]`,children:j})]}),(0,q.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-expanded":m,tabIndex:-1,onClick:()=>{_(ne?j:``),y(null),h(e=>!e)},className:`${M} text-secondary`,children:[N(!1),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Other model…`})]}),m&&(0,q.jsxs)(`form`,{"data-other-model-form":!0,className:`px-3 pb-2 pt-1`,onSubmit:e=>{e.preventDefault(),ae()},children:[(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`input`,{ref:S,className:`setup-input min-w-0 flex-1`,"aria-label":`Other model ID`,"aria-invalid":v?!0:void 0,"aria-describedby":v?`${C}-other-error`:void 0,value:g,placeholder:t.id===Nn.openrouter?`publisher/model`:`Model ID`,autoComplete:`off`,spellCheck:!1,onChange:e=>{_(e.target.value),y(null)}}),(0,q.jsx)(W,{type:`submit`,variant:`secondary`,size:`sm`,className:`h-auto self-stretch md:h-auto`,children:`Use`})]}),v&&(0,q.jsx)(`p`,{id:`${C}-other-error`,role:`alert`,className:`mt-1.5 text-sm text-negative-400`,children:v})]}),(0,q.jsx)(`p`,{className:`px-3 pb-2 pt-1 text-sm text-secondary`,children:`Applies to Aero only.`})]})]}),document.body)]})}function yc(e){return Array.from(e?.querySelectorAll(`[role^="menuitem"]`)??[])}var bc=144,xc=288,Sc=288;function Cc({title:e,matches:t,selectedIndex:n,onHover:r,onPick:i}){let a=(0,K.useRef)(null),o=(0,K.useRef)(null),s=(0,K.useRef)(null),[c,l]=(0,K.useState)(Sc);return(0,K.useLayoutEffect)(()=>{let e=a.current,t=e?.closest(`[data-aero-panel]`),n=e?.parentElement;if(!e||!t||!n)return;let r=n.getBoundingClientRect().top-t.getBoundingClientRect().top-16-(o.current?.getBoundingClientRect().height??0);l(r>0?Math.min(Sc,Math.floor(r)):Sc)},[t.length]),(0,K.useEffect)(()=>{(s.current?.querySelector(`[aria-selected="true"]`))?.scrollIntoView?.({block:`nearest`})},[n]),(0,q.jsxs)(`div`,{ref:a,className:`absolute inset-x-3 bottom-full mb-2 overflow-hidden rounded-lg border border-base bg-bg/98 shadow-2xl`,children:[(0,q.jsx)(`div`,{ref:o,className:`border-b border-default px-3 py-1.5 text-[10px] uppercase tracking-wider text-muted`,children:e}),(0,q.jsx)(`ul`,{ref:s,role:`listbox`,className:`overflow-y-auto py-1`,style:{maxHeight:c},children:t.map((e,t)=>{let a=t===n;return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":a,onMouseEnter:()=>r(t),onClick:()=>i(e),className:`flex w-full items-center gap-3 px-3 py-2 text-left text-sm transition ${a?`bg-bg-elevated text-heading`:`text-neutral hover:bg-bg-elevated/60`}`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:e.label}),(0,q.jsx)(`span`,{className:`ml-auto font-mono text-[11px] text-secondary`,children:e.command})]})},e.command)})})]})}function wc({onPick:e}){return(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:nc.map(t=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>e(t.prompt),className:`rounded-md border border-base bg-bg-elevated/70 px-3 py-1.5 text-sm text-neutral transition hover:border-strong hover:bg-mono-800/70 hover:text-heading`,children:t.label},t.label))})}function Tc(e){switch(e){case Nn.claude:return`ANTHROPIC_API_KEY`;case Nn.openai:return`OPENAI_API_KEY`;case Nn.gemini:return`GEMINI_API_KEY`;case Nn.zai:return`ZAI_API_KEY`;case Nn.openrouter:return`OPENROUTER_API_KEY`}}function Ec(e,t){let n=e.timestamp??0;return`${e.role}:${n}:${t}`}function Dc(e,t,n,r,i,a,o,s=!0,c){let l=[],u=[],d=0;for(let t=e.length-1;t>=0;t--)if(e[t].role===`user`){d=t+1;break}let f=(e=!1)=>{u.length!==0&&(l.push((0,q.jsx)(Uc,{trails:u,betweenSteps:e&&a&&!o},`tools:${u[0].id}`)),u=[])};for(let o=0;o<e.length;o++){let p=e[o],m=Ec(p,o);if(p.role===`user`){f();let e=typeof p.content==`string`?p.content:JSON.stringify(p.content);if(e.startsWith(`[system]`))continue;l.push((0,q.jsx)(Oc,{text:e,projectName:t,providerOverride:n,modelOverride:c,scope:r,context:p.aeroContext,cliCopy:s},m))}else if(p.role===`assistant`){let t=new Map,n=o+1;for(;n<e.length&&e[n].role===`toolResult`;){let r=e[n];t.set(r.toolCallId,r),n++}let r=a&&o>=d,s=Ac(p,t).map(e=>{let t=i.find(t=>t.id===e.id),n={...e,...t,label:e.label??t?.label};return{...n,interrupted:n.endedAt===void 0&&(!r||n.interrupted)}}),c=tc(p);c.trim()&&(f(),l.push((0,q.jsxs)(`div`,{className:`mt-3`,children:[(0,q.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wider text-positive-400`,children:`Aero`}),(0,q.jsx)(qc,{content:c})]},m))),u.push(...s),o=n-1}}return f(!0),l}function Oc({text:e,projectName:t,providerOverride:n,modelOverride:r,scope:i,context:a,cliCopy:o=!0}){let[s,c]=(0,K.useState)(!1),u=(0,K.useMemo)(()=>kc(t,e,n,i,a,r),[t,e,n,i,a,r]);async function d(){try{await navigator.clipboard.writeText(u),c(!0),window.setTimeout(()=>c(!1),1500)}catch{}}return(0,q.jsxs)(`div`,{className:`group relative mt-3 rounded-md bg-bg-elevated/60 px-3 py-2 text-strong`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted`,children:`You`}),o&&(0,q.jsx)(`button`,{type:`button`,onClick:Xn(d),className:`inline-flex items-center gap-1 rounded border border-mono-800/70 bg-bg/60 px-1.5 py-0.5 text-[10px] text-secondary opacity-0 transition hover:border-strong hover:text-heading group-hover:opacity-100 focus:opacity-100`,"aria-label":`Copy as CLI command`,title:u,children:s?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(l,{className:`h-2.5 w-2.5 text-positive-400`,"aria-hidden":`true`}),`Copied`]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(h,{className:`h-2.5 w-2.5`,"aria-hidden":`true`}),`Copy as CLI`]})})]}),(0,q.jsx)(`div`,{className:`whitespace-pre-wrap`,children:e})]})}function kc(e,t,n,r,i,a){let o=[`canonry`,`agent`,`ask`,Br(e),Br(t)];return n&&o.push(`--provider`,n),a&&o.push(`--model`,Br(a)),r===`read-only`&&o.push(`--scope`,`read-only`),i&&o.push(`--context`,Br(JSON.stringify(i))),o.join(` `)}function Ac(e,t){let n=[];for(let r of e.content){if(r.type!==`toolCall`)continue;let e=r,i=t.get(e.id);n.push({id:e.id,name:e.name,args:e.arguments,label:i?.aeroToolLabel,durationMs:i?.aeroDurationMs,endedAt:i?.timestamp,isError:i?.isError,result:i?.content})}return n}var jc=new Set([`aero_list_toolkits`,`aero_load_toolkit`]),Mc=new Map([[`Read`,`Reading`],[`List`,`Listing`],[`Get`,`Getting`],[`Load`,`Loading`],[`Find`,`Finding`],[`Check`,`Checking`],[`Compare`,`Comparing`],[`Inspect`,`Inspecting`],[`Preview`,`Previewing`],[`Search`,`Searching`],[`Show`,`Showing`],[`Run`,`Running`]]);function Nc(e){return e.endedAt===void 0&&!e.interrupted}function Pc(e){return e.label??e.name.replace(/^(?:canonry|aero)_/,``).replace(/_/g,` `)}function Fc(e){let t=e.durationMs??(e.endedAt!=null&&e.startedAt!=null?e.endedAt-e.startedAt:null);return t==null||t<0?null:t}function Ic(e){let t=null;for(let n of e){let e=Fc(n);e!=null&&(t=(t??0)+e)}return t}function Lc(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Rc(e){let t=Math.floor(Math.max(0,e)/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function zc(e,t,n){return`${e} ${e===1?t:n}`}function Bc(e=``){return Mc.get(e.charAt(0).toUpperCase()+e.slice(1))}function Vc(e){let[t,...n]=e.trim().split(/\s+/),r=Bc(t);if(!r)return`Working…`;if(n[0]===`or`||n[0]===`and`){let e=Bc(n[1]);return e?`${[r,n[0],e.toLowerCase(),...n.slice(2)].join(` `)}…`:`Working…`}return`${[r,...n].join(` `)}…`}function Hc(e){let[t,n]=(0,K.useState)(()=>Date.now());return(0,K.useEffect)(()=>{if(!e)return;let t=()=>n(Date.now()),r=window.setTimeout(t,0),i=window.setInterval(t,1e3);return()=>{window.clearTimeout(r),window.clearInterval(i)}},[e]),t}function Uc({trails:e,betweenSteps:t}){let[n,r]=(0,K.useState)(!1),i=(0,K.useId)(),a=e.filter(e=>!jc.has(e.name)),o=e.filter(e=>jc.has(e.name)),s=a.filter(Nc),c=s.length>0?s[s.length-1]:void 0,u=o.some(Nc),d=c!==void 0||u||t,f=a.length>0?a:o,p=f.filter(e=>!Nc(e)&&e.isError===!0).length,m=e.some(e=>e.interrupted),h=e.flatMap(e=>e.startedAt===void 0?[]:[e.startedAt]),g=h.length>0?Math.min(...h):void 0,_=Hc(d),y=Ic(f),b=d?c?Vc(Pc(c)):u?`Loading tools…`:`Working…`:a.length>0?zc(a.length,`step`,`steps`):zc(o.length,`setup step`,`setup steps`),x=new Map;for(let e of a){let t=Pc(e),n=x.get(t);n?n.push(e):x.set(t,[e])}return(0,q.jsxs)(`div`,{className:`mt-3 rounded-md border border-mono-800/70 bg-surface-hover`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left`,"aria-expanded":n,"aria-controls":i,children:[(0,q.jsx)(`span`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center`,children:d?(0,q.jsx)(O,{className:`h-3 w-3 animate-spin text-positive-400 motion-reduce:animate-none`,"aria-hidden":`true`}):p>0?(0,q.jsx)(j,{className:`h-3 w-3 text-negative-400`,"aria-hidden":`true`}):m?(0,q.jsx)(k,{className:`h-3 w-3 text-muted`,"aria-hidden":`true`}):(0,q.jsx)(l,{className:`h-3 w-3 text-muted`,"aria-hidden":`true`})}),(0,q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-heading`,children:b}),p>0&&(0,q.jsxs)(`span`,{className:`shrink-0 rounded-md border border-negative-800/50 bg-negative-950/20 px-1.5 py-0.5 text-[10px] text-negative-400`,children:[p,` failed`]}),m&&(0,q.jsx)(`span`,{className:`shrink-0 rounded-md border border-mono-800/70 px-1.5 py-0.5 text-[10px] text-muted`,children:`interrupted`}),(0,q.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 text-[10px] text-muted`,children:[d?(0,q.jsxs)(q.Fragment,{children:[c&&(0,q.jsxs)(`span`,{children:[`step `,a.indexOf(c)+1]}),g!==void 0&&(0,q.jsx)(`span`,{className:`tabular-nums`,"aria-hidden":`true`,children:Rc(_-g)})]}):y!=null&&(0,q.jsx)(`span`,{className:`tabular-nums`,children:Lc(y)}),(0,q.jsx)(v,{className:`h-3 w-3 transition-transform ${n?`rotate-90`:``}`,"aria-hidden":`true`})]})]}),n&&(0,q.jsxs)(`div`,{id:i,className:`space-y-1.5 border-t border-default px-2.5 py-2`,children:[[...x].map(([e,t])=>(0,q.jsx)(Wc,{trails:t,title:e},`label:${e}`)),o.length>0&&(0,q.jsx)(Wc,{trails:o,title:`+ ${zc(o.length,`setup step`,`setup steps`)}`,muted:!0},`setup`)]})]})}function Wc({trails:e,title:t,muted:n=!1}){let[r,i]=(0,K.useState)(!1),a=(0,K.useId)(),o=!n&&e.length===1,s=e.some(Nc),c=e.filter(e=>!Nc(e)&&e.isError===!0).length,l=e.some(e=>e.interrupted),u=Ic(e),d=o?()=>i(!0):void 0;return(0,q.jsxs)(`div`,{className:o?void 0:n?`rounded-md`:`rounded-md border border-mono-800/70 bg-surface-hover`,onFocus:d,onClick:d,children:[!o&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left`,"aria-expanded":r,"aria-controls":a,children:[!n&&(0,q.jsx)(`span`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center`,children:s?(0,q.jsx)(O,{className:`h-3 w-3 animate-spin text-positive-400 motion-reduce:animate-none`,"aria-hidden":`true`}):c>0?(0,q.jsx)(j,{className:`h-3 w-3 text-negative-400`,"aria-hidden":`true`}):(0,q.jsx)(A,{className:`h-3 w-3 text-muted`,"aria-hidden":`true`})}),(0,q.jsx)(`span`,{className:n?`text-xs text-muted`:`text-sm font-medium text-heading`,children:t}),!n&&(0,q.jsxs)(`span`,{className:`text-[10px] text-muted`,children:[`×`,e.length]}),(0,q.jsxs)(`span`,{className:`ml-auto flex items-center gap-2 text-[10px] text-muted`,children:[s?(0,q.jsx)(`span`,{className:`text-positive-400`,children:`running…`}):(0,q.jsxs)(q.Fragment,{children:[c>0?(0,q.jsxs)(`span`,{className:`text-negative-400`,children:[c,` failed`]}):(0,q.jsx)(`span`,{children:l?`interrupted`:`done`}),u!=null&&(0,q.jsx)(`span`,{className:`tabular-nums`,children:Lc(u)})]}),(0,q.jsx)(v,{className:`h-3 w-3 transition-transform ${r?`rotate-90`:``}`,"aria-hidden":`true`})]})]}),(o||r)&&(0,q.jsx)(`div`,{id:a,className:o?void 0:`space-y-1.5 px-2.5 pb-2`,children:e.map(e=>(0,q.jsx)(Gc,{trail:e},e.id))})]})}function Gc({trail:e}){let[t,n]=(0,K.useState)(!1),r=Nc(e),i=!r&&e.isError===!0,a=Fc(e),o=a==null?null:Lc(a);return(0,q.jsxs)(`div`,{className:`rounded-md border ${i?`border-negative-800/50`:r?`border-positive-800/50`:`border-mono-800/70`} ${i?`bg-negative-950/20`:r?`bg-positive-950/20`:`bg-surface-hover`}`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left`,"aria-expanded":t,children:[(0,q.jsx)(`span`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center`,children:r?(0,q.jsx)(O,{className:`h-3 w-3 animate-spin text-positive-400`,"aria-hidden":`true`}):i?(0,q.jsx)(j,{className:`h-3 w-3 text-negative-400`,"aria-hidden":`true`}):(0,q.jsx)(A,{className:`h-3 w-3 text-muted`,"aria-hidden":`true`})}),(0,q.jsx)(`span`,{className:`text-sm font-medium text-heading`,children:Pc(e)}),(0,q.jsxs)(`span`,{className:`ml-auto flex items-center gap-2 text-[10px] text-muted`,children:[r?(0,q.jsx)(`span`,{className:`text-positive-400`,children:`running…`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{children:e.interrupted?`interrupted`:i?`failed`:`done`}),o&&(0,q.jsx)(`span`,{children:o})]}),(0,q.jsx)(v,{className:`h-3 w-3 transition-transform ${t?`rotate-90`:``}`,"aria-hidden":`true`})]})]}),t&&(0,q.jsxs)(`div`,{className:`border-t border-default px-2.5 py-2 text-[11px] text-secondary`,children:[(0,q.jsx)(`div`,{className:`mb-2 text-xs text-secondary`,children:e.name}),(0,q.jsx)(`div`,{className:`mb-1 text-xs text-secondary`,children:`Inputs`}),(0,q.jsx)(`pre`,{className:`mb-2 overflow-x-auto whitespace-pre-wrap break-all text-xs text-neutral`,children:Kc(e.args)}),!r&&e.result!==void 0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`mb-1 text-[9px] uppercase tracking-wider text-faint`,children:i?`Error`:`Result`}),(0,q.jsx)(`pre`,{className:`overflow-x-auto whitespace-pre-wrap break-all text-xs text-neutral`,children:Kc(e.result)})]})]})]})}function Kc(e){try{let t=typeof e==`string`?e:JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}\n… (${t.length-2e3} more chars)`:t}catch{return String(e)}}function qc({content:e}){return(0,q.jsx)(`div`,{className:`text-heading`,children:(0,q.jsx)(F,{remarkPlugins:[he],components:{h1:e=>(0,q.jsx)(`h1`,{...e,className:`mt-3 mb-2 text-base font-semibold text-primary`}),h2:e=>(0,q.jsx)(`h2`,{...e,className:`mt-3 mb-2 text-sm font-semibold text-primary`}),h3:e=>(0,q.jsx)(`h3`,{...e,className:`mt-3 mb-1.5 text-sm font-semibold text-heading`}),h4:e=>(0,q.jsx)(`h4`,{...e,className:`mt-2 mb-1 text-xs font-semibold uppercase tracking-wide text-neutral`}),p:e=>(0,q.jsx)(`p`,{...e,className:`mb-2 leading-relaxed`}),ul:e=>(0,q.jsx)(`ul`,{...e,className:`mb-2 ml-4 list-disc space-y-1`}),ol:e=>(0,q.jsx)(`ol`,{...e,className:`mb-2 ml-4 list-decimal space-y-1`}),li:e=>(0,q.jsx)(`li`,{...e,className:`marker:text-mono-600`}),strong:e=>(0,q.jsx)(`strong`,{...e,className:`font-semibold text-primary`}),em:e=>(0,q.jsx)(`em`,{...e,className:`text-strong`}),code:({children:e,...t})=>(0,q.jsx)(`code`,{...t,className:`rounded bg-mono-800/70 px-1 py-0.5 font-mono text-[12px] text-positive-200`,children:e}),pre:e=>(0,q.jsx)(`pre`,{...e,className:`mb-2 overflow-x-auto rounded-md border border-base bg-bg-elevated/70 p-3 font-mono text-xs text-strong`}),a:e=>(0,q.jsx)(`a`,{...e,className:`text-positive-400 underline decoration-positive-700 hover:decoration-positive-400`,target:`_blank`,rel:`noopener noreferrer`}),table:e=>(0,q.jsx)(`div`,{className:`mb-2 overflow-x-auto`,children:(0,q.jsx)(`table`,{...e,className:`w-full border-collapse text-xs`})}),thead:e=>(0,q.jsx)(`thead`,{...e,className:`border-b border-base`}),th:e=>(0,q.jsx)(`th`,{...e,className:`px-2 py-1 text-left font-semibold text-neutral`}),tr:e=>(0,q.jsx)(`tr`,{...e,className:`border-b border-mono-900`}),td:e=>(0,q.jsx)(`td`,{...e,className:`px-2 py-1 text-strong`}),blockquote:e=>(0,q.jsx)(`blockquote`,{...e,className:`mb-2 border-l-2 border-strong pl-3 italic text-secondary`}),hr:()=>(0,q.jsx)(`hr`,{className:`my-3 border-base`})},children:e})})}function Jc(){return(0,q.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-positive-400`,children:`Aero`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,"aria-label":`Aero is thinking`,children:[(0,q.jsx)(`span`,{className:`aero-dot h-1.5 w-1.5 rounded-full bg-positive-400/80`}),(0,q.jsx)(`span`,{className:`aero-dot aero-dot-2 h-1.5 w-1.5 rounded-full bg-positive-400/60`}),(0,q.jsx)(`span`,{className:`aero-dot aero-dot-3 h-1.5 w-1.5 rounded-full bg-positive-400/40`})]})]})}function Yc({isAdmin:e,account:t}){return e||t?.role===`viewer`&&In()}function Xc(){let{isAdmin:e,account:t}=Jn(),n=Te(),r=/^\/projects\/([^/]+)/.exec(n.pathname),i=r?decodeURIComponent(r[1]):null,a=R({...cr({client:U}),enabled:i!==null,staleTime:6e4}),o=Ts(n.pathname,n.search),s=a.data??[],c=s.find(e=>e.id===i)??s.find(e=>e.name===i),l=Wr(c?.name??i??``,o),u=zt(),d=u||Yc({isAdmin:e,account:t});return!i||!d||!c?null:(0,q.jsx)(gc,{projectName:c.name,context:l,preview:u},c.name)}function Zc(e,t,n){switch(e.invalidateQueries({queryKey:lr({client:U})}),e.invalidateQueries({queryKey:dr({client:U})}),nr(e,`runs`),t){case G[`answer-visibility`]:Jo(e,n,`none`),nr(e,`visibilityReport`),nr(e,`queryTracking`);return;case G[`backlink-extract`]:return;case G[`seo-sync`]:nr(e,`seo`,{projectName:n});return;case G[`site-audit`]:nr(e,`technicalAeo`);return;case G[`gsc-sync`]:case G[`inspect-sitemap`]:nr(e,`gsc`);return;case G[`ga-sync`]:nr(e,`ga`);return;case G[`traffic-sync`]:nr(e,`ga`),nr(e,`traffic`);return;case G[`bing-inspect`]:case G[`bing-inspect-sitemap`]:nr(e,`bing`);return;case G[`aeo-discover-seed`]:case G[`aeo-discover-probe`]:Jo(e,n);return;case G[`gbp-sync`]:nr(e,`gbp`);return;case G[`ads-sync`]:nr(e,`ads`);return;case G[`google-ads-sync`]:nr(e,`googleAds`),nr(e,`conversionTracking`);return;case G[`gtm-sync`]:nr(e,`gtm`),nr(e,`conversionTracking`);return;default:return t}}var Qc=[{label:`GitHub`,href:`https://github.com/Canonry/canonry`,Icon:oe},{label:`Docs`,href:`https://github.com/Canonry/canonry/tree/main/docs`,Icon:y},{label:`Changelog`,href:`https://github.com/Canonry/canonry/releases`,Icon:a}],$c=e=>({label:e,state:`checking`,detail:`Checking service health`}),el={apiStatus:$c(`API`),workerStatus:$c(`Worker`)};function tl(e){return e===`completed`?`positive`:e===`partial`?`caution`:`negative`}function nl(e){let t=ds(e.kind);return e.status===`completed`?`${t} completed`:e.status===`partial`?`${t} completed with partial results`:e.status===`cancelled`?`${t} cancelled`:`${t} failed`}function rl(e,t){return e.error?`${t}: ${Xt(e.error)}`:e.location?`${t} · ${e.location}`:t}function il(e,t,n){if(t)return t;let r=n.find(t=>t.id===e);return r?.displayName||r?.name||e}function al(e,t){return[e.completed>0?`${e.completed} completed`:null,e.partial>0?`${e.partial} partial`:null,e.failed>0?`${e.failed} failed`:null,e.cancelled>0?`${e.cancelled} cancelled`:null,t>0?`${t} skipped at queue time`:null].filter(Boolean).join(`, `)}function ol(e){return e.failed>0||e.cancelled>0?`negative`:e.partial>0?`caution`:`positive`}function sl(){let e=ge(),t=(0,K.useSyncExternalStore)(wi,Ci,Ci),n=Object.keys(t.runs).length>0||Object.keys(t.batches).length>0,r=R({...fr({client:U}),enabled:n,staleTime:Zn,refetchInterval:3e3}),i=R({...cr({client:U}),enabled:n}),a=(0,K.useRef)({}),o=(0,K.useCallback)(()=>{r.refetch()},[r.refetch]);return(0,K.useEffect)(()=>{n&&o()},[n,o]),(0,K.useEffect)(()=>{if(!n||typeof window>`u`)return;let e=()=>{document.visibilityState===`visible`&&o()};return window.addEventListener(`focus`,o),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,o),document.removeEventListener(`visibilitychange`,e)}},[n,o]),(0,K.useEffect)(()=>{let n=r.data??[],o=i.data??[],s=Object.fromEntries(n.map(e=>[e.id,e])),c=Object.fromEntries(n.map(e=>[e.id,e.status]));for(let n of Object.values(t.runs)){let t=s[n.runId];if(!t||!ki(t.status)||(a.current[t.id]??n.lastAnnouncedStatus)===t.status)continue;let r=o.find(e=>e.id===t.projectId);if(r&&Zc(e,t.kind,r.name),n.sourceAction===`run-all`){Ei(t.id);continue}let i=il(t.projectId,n.projectLabel,o);$n({title:nl(t),detail:rl(t,i),tone:tl(t.status),dedupeKey:`run:${t.id}`,dedupeMode:`replace`,cta:{label:`View run`,intent:`open-run-drawer`,runId:t.id}}),Ei(t.id)}if(r.data!==void 0){let r=new Set(n.map(e=>e.id)),i=ji(Object.values(t.runs),r,Date.now(),Ai);for(let t of i){let n=o.find(e=>e.id===t.projectId);n&&Zc(e,t.kind,n.name),t.sourceAction!==`run-all`&&$n({title:`${ds(t.kind)} status unavailable`,detail:il(t.projectId,t.projectLabel,o),tone:`neutral`,dedupeKey:`run-stale:${t.runId}`,dedupeMode:`replace`}),Ei(t.runId)}}for(let e of Object.values(t.batches)){let t=Mi(e.runIds,s);t.finished&&($n({title:`Run-all batch finished`,detail:al(t,e.skippedCount),tone:ol(t),dedupeKey:`batch:${e.batchId}`,dedupeMode:`replace`,cta:{label:`View runs`,intent:`go-to-runs`}}),Oi(e.batchId))}a.current=c},[i.data,r.data,t,e]),null}function cl(){let{account:e,isAdmin:t}=Jn(),n=Go(),r=(0,K.useMemo)(()=>It(),[]),i=(0,K.useMemo)(jt,[]),a=(0,K.useMemo)(Ot,[]),o=zt()||a&&Yc({isAdmin:t,account:e}),s=(0,K.useMemo)(dt,[]),c=Te(),{dashboard:l,isLoading:m,refetch:h}=Ko(void 0,{includeSettings:!r,includeOverviews:!1,pauseProjectPolling:c.pathname===`/setup`}),y=es(!n,n?.health).data??n?.health??el,{runId:b,evidenceId:w,closeDrawer:D}=ns(),[O,ee]=(0,K.useState)(!1),[k,A]=(0,K.useState)(()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`canonry:sidebarHidden`)===`true`}catch{return!1}}),[j,te]=(0,K.useState)(()=>{if(typeof window>`u`)return null;try{return window.localStorage.getItem(`canonry:dismissedUpdateVersion`)}catch{return null}}),[ne]=(0,K.useState)(()=>typeof window>`u`?null:new URLSearchParams(window.location.search).get(`force-update`)),re=ne?{current:y.apiStatus.version??`0.0.0`,latest:ne,url:`https://www.npmjs.com/package/@canonry/canonry`,upgradeCommand:`npm install -g @canonry/canonry`}:y.apiStatus.updateAvailable,M=s&&re&&re.latest!==j,N=()=>{if(re){try{window.localStorage.setItem(`canonry:dismissedUpdateVersion`,re.latest)}catch{}te(re.latest)}},oe=()=>{let e=!k;try{e?window.localStorage.setItem(`canonry:sidebarHidden`,`true`):window.localStorage.removeItem(`canonry:sidebarHidden`)}catch{}A(e)},le=ts(b),me=le.data??null,F=le.isLoading;(0,K.useEffect)(()=>{me&&me.status!==`running`&&me.status!==`queued`&&h()},[me?.status,h]),(0,K.useEffect)(()=>{ee(!1)},[c.pathname]),(0,K.useEffect)(()=>{if(typeof window>`u`||O||!b&&!w)return;let e=e=>{e.key===`Escape`&&D()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[b,w,D,O]);let I=l??n?.dashboard??null,he=c.pathname===`/setup`,ge=he&&I!==null&&I.portfolioOverview.projects.length===0,_e=he&&(c.search.onboarding===`site-health`||c.search.onboarding===`first-run`||c.search.onboarding===`complete`),[L,ve]=(0,K.useState)(ge);(0,K.useEffect)(()=>{he?ge&&ve(!0):ve(!1)},[ge,he]);let R=he&&(_e||ge||L||he&&I===null),ye=R?`app-shell-focus`:k?`app-shell-sidebar-hidden`:``,be=b?(I?co(I,b):void 0)??(me?Co(me,I?.projects.find(e=>e.project.id===me.projectId)?.project.displayName??I?.projects.find(e=>e.project.id===me.projectId)?.project.name??`Unknown project`):void 0):void 0,xe=(0,K.useMemo)(()=>io(c.pathname,I),[c.pathname,I]),{commandCenter:Se,evidenceLoading:Ce,evidenceError:z,isError:we,refetch:De}=Zo(w?xe:null,{evidence:!0}),Oe=(0,K.useMemo)(()=>{if(w)return uo(Se,I,w)},[w,Se,I]),ke=(()=>{let e=c.pathname;if(e===`/`)return`All projects`;if(e===`/projects`)return`Projects`;if(e===`/runs`)return`Runs`;if(e===`/history`)return`History`;if(e===`/settings`)return`Settings`;if(e===`/setup`)return`Setup`;if(e===`/agent-setup`)return`Agent setup`;if(e===`/backlinks`)return`Backlink data`;if(e===`/traffic`||e.startsWith(`/traffic/`))return`Traffic sources`;if(e.startsWith(`/projects/`)){let e=I?.projects.find(e=>e.project.name===xe);return e?.project.displayName||e?.project.name||xe||`Projects`}return`Not found`})();if(r){let e=Rr(r.projectTabs),t=!r.views||r.views.includes(Gr(c.pathname));return(0,q.jsxs)(`div`,{className:`app-shell app-shell-embed`,"data-theme":ei(r.theme),style:ti(r.theme),children:[(0,q.jsx)(`a`,{className:`skip-link`,href:`#content`,children:`Skip to content`}),(0,q.jsx)(`main`,{id:`content`,className:`page-shell`,children:e?(0,q.jsx)(`div`,{className:`embed-view-unavailable`,role:`status`,children:`This embed uses the retired Report tab. Update its allowed tabs to show AI Visibility.`}):t?(0,q.jsx)(Ee,{}):(0,q.jsx)(`div`,{className:`embed-view-unavailable`,role:`status`,children:`This view is not available in embed mode.`})})]})}let Ae=(0,q.jsxs)(`footer`,{className:`footer`,children:[(0,q.jsxs)(`span`,{className:`footer-brand`,children:[(0,q.jsx)(`span`,{children:(0,q.jsx)(`a`,{href:`https://canonry.ai`,children:`Canonry`})}),y.apiStatus.version&&y.apiStatus.version!==`unknown`?(0,q.jsxs)(`span`,{className:`footer-version`,children:[`v`,y.apiStatus.version]}):null]}),i?(0,q.jsx)(`div`,{className:`footer-links`,children:Qc.map(({label:e,href:t,Icon:n})=>(0,q.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,title:e,"aria-label":e,className:`footer-icon`,children:(0,q.jsx)(n,{className:`size-3.5`})},t))}):null]});return(0,q.jsxs)(P,{open:O,onOpenChange:ee,children:[(0,q.jsx)(`a`,{className:`skip-link`,href:`#content`,children:`Skip to content`}),(0,q.jsx)(us,{}),(0,q.jsxs)(`div`,{className:`app-shell ${ye}${jn()?` app-shell-demo`:``}`,children:[!R&&!k&&(0,q.jsxs)(`aside`,{id:`desktop-sidebar`,className:`sidebar`,"aria-label":`Primary navigation`,children:[(0,q.jsx)(`div`,{className:`sidebar-brand`,children:(0,q.jsx)(Pi,{version:y.apiStatus.version,updateAvailable:M?re:null,onDismissUpdate:N})}),(0,q.jsxs)(`nav`,{className:`sidebar-nav`,children:[(0,q.jsxs)(B,{to:`/`,className:`sidebar-link`,activeProps:{className:`sidebar-link sidebar-link-active`},activeOptions:{exact:!0},children:[(0,q.jsx)(d,{className:`sidebar-icon`}),(0,q.jsx)(`span`,{children:`All projects`})]}),(0,q.jsxs)(B,{to:`/projects`,className:`sidebar-link`,activeProps:{className:`sidebar-link sidebar-link-active`},activeOptions:{exact:!1},children:[(0,q.jsx)(p,{className:`sidebar-icon`}),(0,q.jsx)(`span`,{children:`Projects`})]}),(0,q.jsxs)(B,{to:`/runs`,className:`sidebar-link`,activeProps:{className:`sidebar-link sidebar-link-active`},activeOptions:{exact:!0},children:[(0,q.jsx)(g,{className:`sidebar-icon`}),(0,q.jsx)(`span`,{children:`Runs`})]}),(0,q.jsxs)(B,{to:`/history`,className:`sidebar-link`,activeProps:{className:`sidebar-link sidebar-link-active`},activeOptions:{exact:!0},children:[(0,q.jsx)(E,{className:`sidebar-icon`}),(0,q.jsx)(`span`,{children:`History`})]}),(0,q.jsxs)(B,{to:`/traffic`,className:`sidebar-link`,activeProps:{className:`sidebar-link sidebar-link-active`},activeOptions:{exact:!1},children:[(0,q.jsx)(S,{className:`sidebar-icon`}),(0,q.jsx)(`span`,{children:`Traffic sources`})]}),!jn()&&(0,q.jsxs)(B,{to:`/backlinks`,className:`sidebar-link`,activeProps:{className:`sidebar-link sidebar-link-active`},activeOptions:{exact:!0},children:[(0,q.jsx)(u,{className:`sidebar-icon`}),(0,q.jsx)(`span`,{children:`Backlink data`})]}),!jn()&&(0,q.jsxs)(B,{to:`/agent-setup`,className:`sidebar-link`,activeProps:{className:`sidebar-link sidebar-link-active`},activeOptions:{exact:!0},children:[(0,q.jsx)(C,{className:`sidebar-icon`}),(0,q.jsx)(`span`,{children:`Agent setup`})]}),t&&(0,q.jsxs)(B,{to:`/settings`,className:`sidebar-link`,activeProps:{className:`sidebar-link sidebar-link-active`},activeOptions:{exact:!0},children:[(0,q.jsx)(T,{className:`sidebar-icon`}),(0,q.jsx)(`span`,{children:`Settings`})]}),m?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`sidebar-section-title`,children:`Tracked projects`}),[1,2,3].map(e=>(0,q.jsxs)(`div`,{className:`sidebar-skeleton-item`,children:[(0,q.jsx)(`span`,{className:`skeleton-circle size-2`}),(0,q.jsx)(`span`,{className:`skeleton-text flex-1`,style:{width:`${50+e*15}%`}})]},e))]}):I&&I.projects.length>0?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`sidebar-section-title`,children:`Tracked projects`}),I.projects.map(e=>{let t=e.visibilitySummary.tone;return(0,q.jsxs)(B,{to:`/projects/$projectName`,params:{projectName:e.project.name},className:`sidebar-project`,activeProps:{className:`sidebar-project sidebar-project-active`},children:[(0,q.jsx)(`span`,{className:`sidebar-dot sidebar-dot-${t}`}),(0,q.jsx)(`span`,{children:e.project.displayName||e.project.name})]},e.project.id)})]}):m?null:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`sidebar-section-title`,children:`Resources`}),t&&(0,q.jsxs)(B,{to:`/setup`,className:`sidebar-link`,activeProps:{className:`sidebar-link sidebar-link-active`},activeOptions:{exact:!0},children:[(0,q.jsx)(x,{className:`sidebar-icon`}),(0,q.jsx)(`span`,{children:`Setup`})]})]})]}),e&&(0,q.jsxs)(`div`,{className:`sidebar-account`,children:[(0,q.jsxs)(`div`,{className:`sidebar-account-identity`,children:[(0,q.jsx)(`span`,{className:`sidebar-account-name`,children:e.name}),e.role===`viewer`?(0,q.jsx)(`span`,{className:`sidebar-account-role`,children:Fn()}):null]}),(0,q.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:Xn(async()=>{await Ut(),window.location.reload()}),children:`Sign out`})]}),Ae]}),(0,q.jsxs)(`div`,{className:`main-area ${o&&xe?`main-area-agent-bar`:``}`.trim(),children:[(0,q.jsxs)(`header`,{className:`topbar`,children:[(0,q.jsxs)(`div`,{className:`topbar-left`,children:[!R&&(0,q.jsx)(W,{className:`sidebar-privacy-toggle`,variant:`ghost`,size:`icon`,type:`button`,"aria-label":k?`Show sidebar`:`Hide sidebar`,"aria-controls":k?void 0:`desktop-sidebar`,"aria-expanded":!k,title:k?`Show sidebar`:`Hide sidebar`,onClick:oe,children:k?(0,q.jsx)(ae,{className:`size-4`}):(0,q.jsx)(_,{className:`size-4`})}),(0,q.jsx)(`div`,{className:`topbar-brand-mobile`,children:(0,q.jsx)(Pi,{compact:!0})}),(0,q.jsxs)(`nav`,{className:`breadcrumb`,"aria-label":`Breadcrumb`,children:[(0,q.jsx)(B,{to:`/`,children:`Home`}),(0,q.jsx)(v,{className:`breadcrumb-sep size-3`}),(0,q.jsx)(`span`,{className:`breadcrumb-current`,children:ke})]})]}),(0,q.jsxs)(`div`,{className:`topbar-actions`,children:[(0,q.jsx)(ps,{}),(0,q.jsxs)(`div`,{className:`health-pill-row`,children:[(0,q.jsxs)(`span`,{className:`health-pill health-pill-${y.apiStatus.state}`,title:li(y.apiStatus),children:[`API `,y.apiStatus.state===`ok`?`ok`:y.apiStatus.state]}),(0,q.jsx)(`span`,{className:`health-pill health-pill-${y.workerStatus.state}`,title:li(y.workerStatus),children:`Worker ${y.workerStatus.state===`ok`?`ok`:y.workerStatus.state}`})]}),R?null:(0,q.jsx)(ce,{asChild:!0,children:(0,q.jsxs)(W,{className:`nav-toggle`,variant:`secondary`,size:`icon`,type:`button`,children:[(0,q.jsx)(f,{className:`size-4`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Open navigation`})]})})]})]}),R?null:(0,q.jsxs)(de,{children:[(0,q.jsx)(se,{className:`fixed inset-0 z-40`}),(0,q.jsxs)(fe,{className:`mobile-nav mobile-nav-open`,"aria-describedby":void 0,children:[(0,q.jsx)(pe,{className:`sr-only`,children:`Navigation`}),(0,q.jsx)(ue,{asChild:!0,children:(0,q.jsxs)(W,{className:`mobile-nav-close`,variant:`ghost`,size:`icon`,type:`button`,children:[(0,q.jsx)(ie,{className:`size-5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Close navigation`})]})}),(0,q.jsx)(B,{to:`/`,className:`mobile-nav-link`,activeProps:{className:`mobile-nav-link mobile-nav-link-active`},activeOptions:{exact:!0},children:`All projects`}),(0,q.jsx)(B,{to:`/projects`,className:`mobile-nav-link`,activeProps:{className:`mobile-nav-link mobile-nav-link-active`},activeOptions:{exact:!1},children:`Projects`}),(0,q.jsx)(B,{to:`/runs`,className:`mobile-nav-link`,activeProps:{className:`mobile-nav-link mobile-nav-link-active`},activeOptions:{exact:!0},children:`Runs`}),(0,q.jsx)(B,{to:`/history`,className:`mobile-nav-link`,activeProps:{className:`mobile-nav-link mobile-nav-link-active`},activeOptions:{exact:!0},children:`History`}),(0,q.jsx)(B,{to:`/traffic`,className:`mobile-nav-link`,activeProps:{className:`mobile-nav-link mobile-nav-link-active`},activeOptions:{exact:!1},children:`Traffic sources`}),!jn()&&(0,q.jsx)(B,{to:`/backlinks`,className:`mobile-nav-link`,activeProps:{className:`mobile-nav-link mobile-nav-link-active`},activeOptions:{exact:!0},children:`Backlink data`}),!jn()&&(0,q.jsx)(B,{to:`/agent-setup`,className:`mobile-nav-link`,activeProps:{className:`mobile-nav-link mobile-nav-link-active`},activeOptions:{exact:!0},children:`Agent setup`}),t&&(0,q.jsx)(B,{to:`/settings`,className:`mobile-nav-link`,activeProps:{className:`mobile-nav-link mobile-nav-link-active`},activeOptions:{exact:!0},children:`Settings`}),I&&I.projects.length>0?(0,q.jsxs)(`div`,{className:`mobile-nav-section`,children:[(0,q.jsx)(`p`,{className:`mobile-nav-section-title`,children:`Tracked projects`}),I.projects.map(e=>(0,q.jsx)(B,{to:`/projects/$projectName`,params:{projectName:e.project.name},className:`mobile-nav-link`,children:e.project.name},e.project.id))]}):null,e&&(0,q.jsxs)(`div`,{className:`mobile-nav-section`,children:[(0,q.jsx)(`p`,{className:`mobile-nav-section-title`,children:`Signed in`}),(0,q.jsxs)(`div`,{className:`sidebar-account`,children:[(0,q.jsxs)(`div`,{className:`sidebar-account-identity`,children:[(0,q.jsx)(`span`,{className:`sidebar-account-name`,children:e.name}),e.role===`viewer`?(0,q.jsx)(`span`,{className:`sidebar-account-role`,children:Fn()}):null]}),(0,q.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`mobile-sign-out`,onClick:Xn(async()=>{await Ut(),window.location.reload()}),children:`Sign out`})]})]}),Ae]})]}),(0,q.jsx)(`main`,{id:`content`,className:`page-shell`,children:m&&!n?(0,q.jsxs)(`div`,{className:`page-skeleton`,children:[(0,q.jsxs)(`div`,{className:`page-skeleton-header`,children:[(0,q.jsx)(`div`,{className:`skeleton-text h-6 w-40`}),(0,q.jsx)(`div`,{className:`skeleton-text-sm w-72`})]}),(0,q.jsx)(`div`,{className:`page-skeleton-grid`,children:[1,2,3].map(e=>(0,q.jsxs)(`div`,{className:`page-skeleton-card`,children:[(0,q.jsx)(`div`,{className:`skeleton-text w-24`}),(0,q.jsx)(`div`,{className:`skeleton-text w-full`}),(0,q.jsx)(`div`,{className:`skeleton-text-sm w-3/4`})]},e))}),(0,q.jsx)(`div`,{className:`page-skeleton-grid`,style:{gridTemplateColumns:`1fr 1fr`},children:[1,2].map(e=>(0,q.jsxs)(`div`,{className:`page-skeleton-card`,children:[(0,q.jsx)(`div`,{className:`skeleton-text w-20`}),(0,q.jsx)(`div`,{className:`space-y-2`,children:[1,2,3].map(e=>(0,q.jsx)(`div`,{className:`skeleton-text-sm w-full`},e))})]},e))})]}):(0,q.jsx)(Ee,{})})]}),b&&!be&&F?(0,q.jsx)(Wa,{open:!0,title:`Loading run details`,subtitle:`Fetching the durable run record`,onClose:D,children:(0,q.jsx)(`p`,{className:`text-sm text-muted`,role:`status`,children:`Loading run details…`})}):null,b&&!be&&le.isError?(0,q.jsx)(Wa,{open:!0,title:`Run unavailable`,subtitle:`The run could not be loaded`,onClose:D,children:(0,q.jsx)(`p`,{className:`text-sm text-negative`,children:le.error instanceof Error?le.error.message:`Run details are unavailable.`})}):null,be?(0,q.jsxs)(Wa,{open:!0,title:be.summary,subtitle:`${be.projectName} \u00b7 ${be.kindLabel}`,onClose:D,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-5 gap-y-1 text-sm`,children:[(0,q.jsx)(Na,{status:be.status}),(0,q.jsx)(`span`,{className:`text-secondary`,children:be.startedAt}),(0,q.jsx)(`span`,{className:`text-muted`,children:be.duration}),(0,q.jsx)(`span`,{className:`text-faint`,children:be.triggerLabel})]}),be.status===`failed`&&be.statusDetail&&(0,q.jsx)(`p`,{className:`mt-2 text-sm text-negative`,children:be.statusDetail}),(0,q.jsxs)(`div`,{className:`mt-4`,children:[(0,q.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted mb-2`,children:`Activity Log`}),F?(0,q.jsx)(`p`,{className:`text-sm text-muted`,children:`Loading run details...`}):me?.snapshots&&me.snapshots.length>0?(0,q.jsxs)(`div`,{className:`space-y-2`,children:[me.snapshots.map(e=>(0,q.jsxs)(`div`,{className:`rounded-lg border border-default bg-surface p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-strong truncate`,children:e.query??`Unknown query`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(Ma,{provider:e.provider}),(0,q.jsx)(ln,{variant:e.citationState===V.cited?`success`:`neutral`,children:e.citationState})]})]}),e.model&&(0,q.jsx)(`p`,{className:`text-[11px] text-muted font-mono`,children:e.model}),e.citedDomains.length>0&&(0,q.jsxs)(`p`,{className:`text-xs text-muted mt-1`,children:[(0,q.jsx)(`span`,{className:`text-secondary`,children:`Sources:`}),` `,e.citedDomains.join(`, `)]}),e.citedCompetitorDomains.length>0&&(0,q.jsxs)(`p`,{className:`text-xs text-negative-400/80 mt-0.5`,children:[`Competitor cited: `,e.citedCompetitorDomains.join(`, `)]}),e.mentionedCompetitorDomains.length>0&&(0,q.jsxs)(`p`,{className:`text-xs text-negative-400/80 mt-0.5`,children:[`Competitor mentioned: `,e.mentionedCompetitorDomains.join(`, `)]}),e.groundingSources&&e.groundingSources.length>0&&(0,q.jsxs)(`details`,{className:`mt-2`,children:[(0,q.jsxs)(`summary`,{className:`text-xs text-muted cursor-pointer hover:text-secondary`,children:[e.groundingSources.length,` grounding source`,e.groundingSources.length===1?``:`s`]}),(0,q.jsx)(`ul`,{className:`mt-2 space-y-3`,children:e.groundingSources.map((e,t)=>(0,q.jsx)(`li`,{className:`min-w-0`,children:(0,q.jsx)(qa,{url:e.uri,title:e.title})},t))})]}),e.answerText&&(0,q.jsxs)(`details`,{className:`mt-1`,children:[(0,q.jsx)(`summary`,{className:`text-xs text-muted cursor-pointer hover:text-secondary`,children:`Answer preview`}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-secondary leading-relaxed whitespace-pre-wrap`,children:e.answerText})]})]},e.id)),me.status===`running`&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2 p-3 text-sm text-muted`,children:[(0,q.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-caution-500 animate-pulse`}),`Running remaining queries...`]})]}):me&&me.status===H.running?(0,q.jsxs)(`div`,{className:`flex items-center gap-2 p-3 text-sm text-muted`,children:[(0,q.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-caution-500 animate-pulse`}),me.kind===G[`answer-visibility`]?`Waiting for first query result...`:`Run is in progress...`]}):me&&me.status===H.queued?(0,q.jsxs)(`div`,{className:`flex items-center gap-2 p-3 text-sm text-muted`,children:[(0,q.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-mono-500 animate-pulse`}),`Run queued, waiting for execution slot...`]}):me&&me.error?(0,q.jsxs)(`div`,{className:`rounded-lg border border-negative-800/40 bg-negative-950/20 p-3`,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-negative mb-2`,children:`Run failed`}),(0,q.jsx)(`pre`,{className:`max-h-48 overflow-y-auto whitespace-pre-wrap break-words font-mono text-xs leading-5 text-negative`,children:Un(me.error)})]}):be.kind===G[`answer-visibility`]?(0,q.jsx)(`p`,{className:`text-sm text-muted`,children:`No snapshot data available.`}):(0,q.jsx)(`p`,{className:`text-sm text-secondary`,children:be.status===H.completed?`Run completed.`:be.status===H.partial?`Run completed with partial results.`:be.status===H.cancelled?`Run cancelled.`:be.status===H.failed?`Run failed.`:`No run details available.`})]})]}):null,w&&!Oe?(0,q.jsx)(Wa,{open:!0,title:Ce?`Loading answer`:`Answer unavailable`,subtitle:`Query evidence`,onClose:D,children:Ce?(0,q.jsx)(`p`,{role:`status`,className:`text-sm text-secondary`,children:`Loading answer…`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-secondary`,children:z||we?`Could not load this answer.`:`This answer is not in the available query evidence.`}),(0,q.jsx)(W,{type:`button`,variant:`outline`,onClick:()=>{De()},children:`Retry`})]})}):null,Oe?(0,q.jsx)(to,{evidence:Oe.evidence,project:Oe.project,onClose:D}):null,(0,q.jsx)(sl,{}),(0,q.jsx)(as,{}),o?(0,q.jsx)(Xc,{}):null]})]})}var ll=class extends K.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary]`,e,t.componentStack),ht({kind:`render`,error:e,component:this.props.name??`root`})}handleReset=()=>{this.setState({error:null})};render(){return this.state.error?(0,q.jsx)(`div`,{className:`page-container`,children:(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 py-20 text-center`,children:[(0,q.jsx)(`div`,{className:`rounded-full bg-negative-950/40 p-3`,children:(0,q.jsx)(j,{className:`size-6 text-negative-400`})}),(0,q.jsx)(`h2`,{className:`text-lg font-semibold text-heading`,children:`Something went wrong`}),(0,q.jsx)(`p`,{className:`text-sm text-secondary max-w-md`,children:this.state.error.message||`An unexpected error occurred while rendering this page.`}),(0,q.jsxs)(`div`,{className:`flex gap-3 mt-2`,children:[(0,q.jsxs)(W,{variant:`secondary`,size:`sm`,onClick:this.handleReset,children:[(0,q.jsx)(D,{className:`size-3.5 mr-1.5`}),`Try again`]}),(0,q.jsx)(W,{variant:`secondary`,size:`sm`,onClick:()=>{let e=window.__CANONRY_CONFIG__?.basePath?.replace(/\/$/,``)??``;window.location.href=e||`/`},children:`Go home`})]})]})}):this.props.children}};function ul({disabled:e,title:t,...n}){let{canWrite:r}=Jn();return r?(0,q.jsx)(W,{disabled:e,title:t,...n}):(0,q.jsx)(W,{...n,disabled:!0,title:qn})}function dl({title:e,children:t}){let{isAdmin:n}=Jn();return n?(0,q.jsx)(q.Fragment,{children:t}):(0,q.jsxs)(Ar,{className:`surface-card mx-auto mt-8 max-w-lg`,children:[(0,q.jsxs)(Dr,{children:[(0,q.jsxs)(Er,{children:[e,` is for administrators`]}),(0,q.jsx)(kr,{children:`Your account has view-only access. You can read everything this install has measured; changing how it is set up needs an administrator account.`})]}),(0,q.jsx)(Or,{children:(0,q.jsx)(`p`,{className:`supporting-copy`,children:`If you need to make a change here, ask an administrator on this install.`})})]})}function fl(e,t,n){return{mode:t,scope:e.measurementScope,scopeKey:e.measurementScopeKey,marketKey:e.marketKey,queryClass:e.queryClass===`non-brand`?`non-brand`:`branded`,provider:e.provider,model:e.model,location:e.location,runId:e.measurementRunId,revision:e.revision,evaluationDefinitionId:n}}function pl(e,t,n){let r=[...new Set(t.filter(e=>!n||e.provider===n).map(e=>e.sourceRunId).filter(e=>!!e))].sort();return{...e,mode:`simple`,scope:`project`,scopeKey:void 0,marketKey:void 0,provider:n||void 0,model:void 0,revision:void 0,runId:r.length===1?r[0]:void 0,runIds:r.length>1?r:void 0}}function ml(e,t,n,r){return[`sentiment`,e,t,n??null,r??null]}var hl=5e3,gl=new Set([`pending`,`running`,`waiting-to-retry`]);function _l(e){return gl.has(e.state)}function vl(e){let t=e?.coverage.counts;return!!(t&&t.pending+t.running+t[`waiting-to-retry`]>0)}function yl(e,t){return vl(e)||t?hl:!1}function bl(e,t,n=!0){let r=R({queryKey:ml(e,`settings`),queryFn:()=>Ae(e),retry:!1,staleTime:0,refetchOnWindowFocus:`always`}),i=R({queryKey:ml(e,`jobs`),queryFn:()=>ut(e),enabled:!!r.data?.actions.configure,retry:!1,refetchOnWindowFocus:`always`,refetchInterval:e=>e.state.data?.jobs.some(_l)?hl:!1}),a=!!i.data?.jobs.some(_l),o=i=>{let o={...t,queryClass:i};return{queryKey:ml(e,`summary`,o),queryFn:()=>Et(e,o),enabled:n&&!!(r.data?.enabled&&r.data.installEnabled),retry:!1,staleTime:0,refetchOnWindowFocus:`always`,refetchInterval:e=>yl(e.state.data,a)}};return{settings:r,branded:R(o(`branded`)),nonBrand:R(o(`non-brand`)),jobs:i}}var xl={branded:`Branded`,"non-brand":`Non-brand`};function Sl(e){return e>=10}var Z={states:{disabled:`Sentiment is off.`,"not-measured":`No ratings yet.`,processing:`Analyzing sentiment…`,canceled:`Analysis canceled.`,partial:`Partial results.`,failed:`Analysis failed.`,complete:`Analysis complete.`,unsupported:`Sentiment unavailable.`},noJudgments:`No ratings available.`,tooFew:`too few`,minRated:`Shown from 10 ratings`,partial:`Partial results`,columns:{favorable:`Favorable`,rated:`With opinion`},title:`Sentiment`,subtitle:`How AI answers describe you in queries that name you`,rated:`Share of answers that give an opinion (favorable, mixed or unfavorable) about who they name`,noAnswers:`No answers yet`,ratedUnavailable:`Unavailable`,details:{ratedAnswers:`Answers with an opinion`,unadmitted:`Checks not yet analyzed`,checksCaption:`Not counted in the favorable share:`,interval:`Likely range (95%)`},nonBrand:{label:`Non-brand queries`,none:`No unfavorable or mixed answers in non-brand queries.`,noneSoFar:`No unfavorable or mixed answers in non-brand queries so far.`,notRated:`Non-brand answers are not rated yet.`,view:`View answers`,evidence:`Non-brand queries, unfavorable and mixed`,rowNone:`No unfavorable or mixed answers`,rowLabel:`Unfavorable or mixed`,help:`A non-brand answer almost always names you to recommend you, so its favorable share is near 100% and says little. Sentiment is measured on branded queries; unfavorable or mixed answers to non-brand queries are listed here when they happen.`},properties:{title:`Most criticized properties`,evidence:`unfavorable and mixed`,viewAll:`View all unfavorable and mixed answers`,allEvidence:`Branded queries, unfavorable and mixed`},overall:`Favorable share of ratings in answers to branded queries. Each saved answer-subject assessment counts once. Answers with no opinion, or where it is unclear who they name, are left out.`,favorable:`The favorable share of favorable, mixed and unfavorable ratings in answers to branded queries. Each rating covers one subject named in an answer; answers with no opinion are left out.`},Cl=`—`,wl={factual:`Named, no opinion`,"subject-not-mentioned":`Not named in the answer`,"wrong-subject":`Named someone else`,"ambiguous-subject":`Unclear which one was meant`,"ambiguous-judgment":`Opinion unclear`,"subject-not-applicable":`Not applicable`,"unsupported-language":`Not in English`,"missing-source-text":`No answer text`,"input-too-large":`Answer too long to rate`,"invalid-conclusion-evidence":`Rating set aside`,pending:`Waiting to be rated`,running:`Being rated`,"waiting-to-retry":`Retrying`};function Tl(e){return wl[e]??e.replaceAll(`-`,` `).replace(/^./,e=>e.toUpperCase())}var El=[`favorable`,`mixed`,`unfavorable`];function Dl(e){return e===`favorable`?`positive`:e===`unfavorable`?`negative`:e===`mixed`?`caution`:`neutral`}var Ol=[`mixed`,`unfavorable`];function kl(e){return e.interval?`${pt(e.interval.low,Kt.fraction)} to ${pt(e.interval.high,Kt.fraction)}`:null}var Al={favorable:`progress-fill-info`,mixed:`progress-fill-caution`,unfavorable:`progress-fill-negative`};function jl(e){return`${e} ${e===1?`rating`:`ratings`}`}function Ml(e){return e.score.favorableRate!==null&&e.coverage.judged>0}function Nl(e){return e.state===`complete`&&!e.provisional&&e.coverage.unadmittedAssessments===0}function Pl(e){return e.state===`complete`?Z.partial:Z.states[e.state]}function Fl(e){return e?Ml(e)&&Sl(e.coverage.judged):!1}function Il({value:e,label:t}){let{counts:n,judged:r}=e.coverage;if(!Ml(e))return(0,q.jsx)(`div`,{className:`sentiment-bar sentiment-bar-track`,"data-sentiment-bar":`empty`,"aria-hidden":`true`});let i=El.map(e=>`${n[e]} ${e}`).join(`, `);return Fl(e)?(0,q.jsx)(`div`,{role:`img`,"aria-label":`${t}: ${i}, ${e.score.favorableDisplay} favorable of ${jl(r)}`,className:`sentiment-bar`,"data-sentiment-bar":`rated`,children:El.filter(e=>n[e]>0).map(e=>(0,q.jsx)(`span`,{"data-outcome":e,className:`sentiment-bar-segment ${Al[e]}`,style:{flexGrow:n[e]},title:`${Tl(e)}: ${n[e]} of ${jl(r)}`},e))}):(0,q.jsx)(`div`,{role:`img`,"aria-label":`${t}: ${i}, ${jl(r)}, favorable share ${Z.minRated.toLowerCase()}`,className:`sentiment-bar sentiment-bar-track`,"data-sentiment-bar":`too-few`})}function Ll({value:e,label:t}){let{counts:n,judged:r}=e.coverage;return(0,q.jsx)(`div`,{role:`img`,"aria-label":`${t}: ${El.map(e=>`${n[e]} ${e}`).join(`, `)}, ${jl(r)}`,className:`sentiment-property-bar`,children:El.filter(e=>n[e]>0).map(e=>(0,q.jsx)(`span`,{"data-outcome":e,className:`sentiment-bar-segment ${Al[e]}`,style:{flexGrow:n[e]}},e))})}function Rl(e){let t=new Map(e.breakdowns.filter(e=>e.dimension===`property`).map(e=>[e.key,e]));return(e.criticizedProperties?.keys??[]).flatMap(e=>t.get(e)??[])}function zl({value:e,label:t}){return(0,q.jsx)(`div`,{role:`group`,"aria-label":`${t} favorable share`,className:`sentiment-class-favorable`,children:Fl(e)?(0,q.jsx)(`span`,{className:`sentiment-class-share`,children:e.score.favorableDisplay}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`sentiment-class-empty`,title:Z.minRated,children:Cl}),(0,q.jsx)(`span`,{className:`sr-only`,children:Z.minRated})]})})}function Bl({ratedAnswers:e=0,eligibleAnswers:t=0}){return`${e} of ${t} ${t===1?`answer`:`answers`} rated`}function Vl(e){let{eligibleAnswers:t}=e;return t===void 0?{display:Cl,detail:Z.ratedUnavailable,empty:!0}:t<=0?{display:Cl,detail:Z.noAnswers,empty:!0}:e.ratedAnswerRate===null||e.ratedAnswerRate===void 0?{display:Cl,detail:Z.states.disabled,empty:!0}:{display:pt(e.ratedAnswerRate,Kt.fraction),detail:Bl(e),empty:!1}}function Hl({coverage:e,label:t}){let{display:n,detail:r,empty:i}=Vl(e);return(0,q.jsxs)(`div`,{role:`group`,"aria-label":`${t} share rated`,className:`sentiment-class-ratings`,children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:i?`sentiment-class-empty`:void 0,title:r,children:n}),(0,q.jsx)(`span`,{className:`sr-only`,children:i?r:`${n}, ${r}`})]})}function Ul({value:e}){return Ml(e)?e.provisional?(0,q.jsx)(`p`,{className:`sentiment-class-note text-caution`,children:Z.partial}):null:(0,q.jsx)(`p`,{className:`sentiment-class-note`,children:e.state===`complete`?Z.noJudgments:Z.states[e.state]})}function Wl(e){return!!(e.coverage.selected||e.coverage.eligibleAssessments||e.reason)}function Gl({value:e,queryClass:t,open:n,setOpenClass:r}){let i=(0,K.useContext)(Jl),a=(0,K.useId)(),s=(0,K.useId)(),c=(0,K.useId)(),l=(0,K.useRef)(null),u=(0,K.useRef)(null),d=(0,K.useCallback)(()=>r(e=>e===t?null:e),[r,t]);(0,K.useEffect)(()=>{if(!n)return;let e=e=>e instanceof Node&&!!(l.current?.contains(e)||u.current?.contains(e)),t=t=>{e(t.target)||d()},r=t=>{e(t.target)||d()},i=e=>{e.key===`Escape`&&(d(),l.current?.focus())};return document.addEventListener(`pointerdown`,t),document.addEventListener(`focusin`,r),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`pointerdown`,t),document.removeEventListener(`focusin`,r),document.removeEventListener(`keydown`,i)}},[n,d]);let{coverage:f,score:p}=e,m=kl(p),h=f.judged>0&&!Sl(f.judged),g=t===`branded`?Rl(e):[];return Wl(e)?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{ref:l,type:`button`,className:`sentiment-class-details-toggle`,"aria-label":`${xl[t]} details`,"aria-expanded":n,"aria-controls":a,onClick:()=>r(e=>e===t?null:t),children:(0,q.jsx)(o,{className:`sentiment-class-details-chevron`,"aria-hidden":`true`})}),(0,q.jsxs)(`div`,{ref:u,id:a,role:`group`,"aria-labelledby":s,className:`sentiment-class-details`,hidden:!n,children:[(0,q.jsx)(`p`,{id:s,className:`sentiment-class-details-title`,children:xl[t]}),(0,q.jsxs)(`dl`,{className:`sentiment-details-list`,children:[(f.eligibleAnswers??0)>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{children:Z.details.ratedAnswers}),(0,q.jsxs)(`dd`,{children:[f.ratedAnswers??0,` of `,f.eligibleAnswers]})]}),h&&El.filter(e=>f.counts[e]>0).map(e=>(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{children:Tl(e)}),(0,q.jsx)(`dd`,{children:f.counts[e]})]},e)),h&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{children:`Favorable share`}),(0,q.jsx)(`dd`,{children:Z.minRated})]}),m&&(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`dt`,{children:[Z.details.interval,` `,(0,q.jsx)(Tr,{text:p.limitation,placement:`bottom`})]}),(0,q.jsx)(`dd`,{children:m})]})]}),i&&g.length>0&&(0,q.jsxs)(`div`,{className:`sentiment-details-properties`,role:`group`,"aria-labelledby":c,children:[(0,q.jsxs)(`p`,{id:c,className:`sentiment-details-subtitle`,children:[Z.properties.title,e.criticizedProperties&&e.criticizedProperties.total>g.length?(0,q.jsxs)(`span`,{className:`sentiment-details-subtitle-count`,children:[` · `,g.length,` of `,e.criticizedProperties.total]}):null]}),(0,q.jsx)(`ul`,{children:g.map(n=>(0,q.jsxs)(`li`,{className:`sentiment-property`,children:[(0,q.jsx)(`button`,{type:`button`,className:`sentiment-property-name`,"aria-label":`View ${Z.properties.evidence} answers for ${n.label}`,onClick:()=>{if(!l.current)return;let r=Yl(i,e);i.openEvidence({...r,queryClass:t,scope:`property`,scopeKey:n.key,marketKey:r.scope===`market`?r.scopeKey:r.marketKey,outcome:Ol},`${n.label}, ${Z.properties.evidence}`,l.current)},children:n.label}),(0,q.jsxs)(`span`,{className:`sentiment-property-count`,children:[n.coverage.counts.favorable,` of `,n.coverage.judged,` favorable`]}),(0,q.jsx)(Ll,{value:n,label:n.label})]},n.key))}),(0,q.jsx)(`button`,{type:`button`,className:`sentiment-property-name sentiment-details-view-all`,onClick:()=>{l.current&&i.openEvidence({...Yl(i,e),queryClass:t,outcome:Ol},Z.properties.allEvidence,l.current)},children:Z.properties.viewAll})]}),(f.unadmittedAssessments>0||Object.entries(f.counts).some(([e,t])=>t>0&&!El.includes(e)))&&(0,q.jsx)(`p`,{className:`sentiment-details-caption`,children:Z.details.checksCaption}),(0,q.jsxs)(`dl`,{className:`sentiment-details-list`,children:[f.unadmittedAssessments>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{children:Z.details.unadmitted}),(0,q.jsx)(`dd`,{children:f.unadmittedAssessments})]}),Object.entries(f.counts).filter(([e,t])=>t>0&&![`favorable`,`mixed`,`unfavorable`].includes(e)).map(([e,t])=>(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{children:Tl(e)}),(0,q.jsx)(`dd`,{children:t})]},e))]}),e.reason&&(0,q.jsx)(`p`,{className:`sentiment-class-details-reason`,children:e.reason})]})]}):null}function Kl(e){return!!(e?.configured&&e.branded.coverage.judged>0&&e.branded.score.favorableRate!==null)&&!ze()}function ql({value:e}){if(!Kl(e))return null;let t=e.branded,n=t.coverage.judged,r=kl(t.score),i=`${Z.overall} ${n} of ${t.coverage.selected} judged${r?`, 95% interval ${r}`:``}. ${t.provisional?`Provisional. `:``}${Z.states[t.state]}${t.reason?` ${t.reason}`:``}`;return(0,q.jsx)(`div`,{className:`project-row-stat`,"data-sentiment-score":!0,children:(0,q.jsxs)(`div`,{className:`metric-inline-block`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`p`,{className:`metric-inline-label`,children:`Sentiment`}),(0,q.jsx)(`span`,{className:`relative z-10`,children:(0,q.jsx)(Tr,{text:i,placement:`bottom`})})]}),Sl(n)?(0,q.jsxs)(`p`,{className:`metric-inline-value`,children:[t.score.favorableDisplay,(0,q.jsx)(`span`,{className:`sr-only`,children:` favorable judgments, branded queries`})]}):(0,q.jsxs)(`p`,{className:`metric-inline-value text-secondary`,children:[Z.tooFew,(0,q.jsxs)(`span`,{className:`sr-only`,children:[` ratings for a favorable share, `,n,` of `,10,` needed, branded queries`]})]}),(0,q.jsx)(`p`,{className:`metric-inline-caption`,"aria-hidden":`true`})]})})}var Jl=(0,K.createContext)(null);function Yl(e,t){let{selection:n}=t;return{...e.selection,...n,runId:n.runId??void 0,runIds:n.runId?void 0:n.runIds,revision:n.revision??void 0,evaluationDefinitionId:n.evaluationDefinitionId??void 0}}function Xl(){return(0,K.useContext)(Jl)?.configured??!1}function Zl({projectName:e,selection:t,runOptions:n=[],waitForResolvedRun:r=!1,evidenceReady:i=!0,hasSourceEvidence:a=!0,children:o}){return(0,q.jsx)(Ql,{projectName:e,selection:t,runOptions:n,waitForResolvedRun:r,evidenceReady:i,hasSourceEvidence:a,children:o})}function Ql({projectName:e,selection:t,runOptions:n,waitForResolvedRun:r,evidenceReady:i,hasSourceEvidence:a,children:o}){let s=JSON.stringify([e,t]),[c,l]=(0,K.useState)(null),u=(0,K.useCallback)(e=>l(t=>t?.key===s&&t?.runId===e?.runId&&t?.revision===e?.revision?t:e?{...e,key:s}:null),[s]),d=i&&(!r||c?.key===s),f=r&&d&&c?{...t,runId:c.runId,revision:c.revision}:t,p=JSON.stringify([e,f]),{settings:m,branded:h,nonBrand:g,jobs:_}=bl(e,f,d&&a),[v,y]=(0,K.useState)(!1),[b,x]=(0,K.useState)(null),S=(0,K.useRef)(null);(0,K.useEffect)(()=>{y(!1),x(null)},[p]);let C=d&&!!(m.data?.enabled&&m.data.installEnabled),w=(t.queryClass===`non-brand`?g.data:h.data)?.selection,T={...f,...w?{...w,runId:w.runId??void 0,runIds:w.runId?void 0:w.runIds,revision:w.revision??void 0,evaluationDefinitionId:w.evaluationDefinitionId??void 0}:{}},E=T.runId&&!n.some(e=>e.id===T.runId)?[{id:T.runId,label:`Displayed check`},...n]:n,D=e=>{e.preventDefault(),S.current?.focus()};return(0,q.jsxs)(Jl.Provider,{value:{projectName:e,selection:f,resolveSource:u,settings:m,summaries:{branded:h,"non-brand":g},configured:C,hasSourceEvidence:a,openManage:e=>{S.current=e,y(!0)},openEvidence:(e,t,n)=>{S.current=n,x({selection:e,label:t})}},children:[o,(0,q.jsx)(Pa,{open:v&&!!m.data?.actions.configure,onOpenChange:y,children:(0,q.jsxs)(Ba,{onCloseAutoFocus:D,className:`overflow-y-auto`,children:[(0,q.jsxs)(Va,{children:[(0,q.jsx)(Ha,{children:`Manage sentiment`}),(0,q.jsx)(Ua,{children:`Classify saved answers and review the cost before submitting a backfill.`})]}),m.data?.actions.configure&&(0,q.jsx)(vu,{projectName:e,settings:m.data,selection:T,runOptions:E},JSON.stringify([m.data.evaluationDefinitionId,m.data.enabled,m.data.enablementEpoch])),_.data&&(0,q.jsx)(fu,{projectName:e,jobs:_.data.jobs})]})}),(0,q.jsx)(Pa,{open:b!==null,onOpenChange:e=>{e||x(null)},children:(0,q.jsxs)(Ba,{onCloseAutoFocus:D,className:`overflow-y-auto`,children:[(0,q.jsxs)(Va,{children:[(0,q.jsxs)(Ha,{children:[`Sentiment evidence`,b?`: ${b.label}`:``]}),(0,q.jsx)(Ua,{children:`Stored judgments and exact quotations for the selected query and scope.`})]}),b&&(0,q.jsx)(lu,{projectName:e,selection:b.selection},JSON.stringify(b.selection))]})})]})}function $l(e,t){let n=(0,K.useContext)(Jl)?.resolveSource;(0,K.useEffect)(()=>{n?.(e?{runId:e,revision:t??void 0}:null)},[n,e,t])}function eu(){let e=(0,K.useContext)(Jl);return e?.settings.data?.actions.configure?(0,q.jsx)(ul,{type:`button`,variant:`outline`,size:`sm`,onClick:t=>e.openManage(t.currentTarget),children:e.settings.data.enabled?`Manage sentiment`:`Enable sentiment`}):null}function tu(e,t){return!e?.configured||t===`unknown`||t===`unclassified`?null:[`branded`]}function nu({queryClass:e=`all`}){let t=(0,K.useContext)(Jl),n=tu(t,e);return!t?.hasSourceEvidence||!n?.some(e=>Fl(t.summaries[e].data))?null:(0,q.jsx)(`ul`,{className:`sentiment-legend`,"aria-hidden":`true`,children:El.map(e=>(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`sentiment-legend-swatch ${Al[e]}`}),Tl(e)]},e))})}function ru({queryClass:e}){let t=(0,K.useContext)(Jl);if(!t?.hasSourceEvidence)return null;let n=t.summaries[`non-brand`],r=n.data,i=e===`non-brand`;if(!r)return i?n.isError?(0,q.jsxs)(`p`,{role:`alert`,className:`sentiment-nonbrand-note`,children:[`Couldn’t load non-brand sentiment. `,(0,q.jsx)(W,{variant:`ghost`,onClick:()=>{n.refetch()},children:`Retry`})]}):(0,q.jsx)(`p`,{role:`status`,className:`sentiment-nonbrand-note`,children:`Loading non-brand sentiment…`}):null;let a=r.coverage.counts;return a.unfavorable===0&&a.mixed===0?i?Nl(r)?(0,q.jsx)(`p`,{className:`sentiment-nonbrand-note`,children:Z.nonBrand.none}):Ml(r)?(0,q.jsx)(`p`,{className:`sentiment-nonbrand-note`,children:Z.nonBrand.noneSoFar}):(0,q.jsx)(`p`,{className:`sentiment-nonbrand-note`,children:r.state===`not-measured`?Z.nonBrand.notRated:`${Z.nonBrand.label}: ${Pl(r)}`}):null:(0,q.jsx)(`div`,{className:`sentiment-nonbrand`,role:`group`,"aria-label":Z.nonBrand.label,children:(0,q.jsxs)(`div`,{className:`sentiment-nonbrand-line`,children:[(0,q.jsxs)(`span`,{className:`sentiment-nonbrand-label`,children:[Z.nonBrand.label,(0,q.jsx)(Tr,{text:Z.nonBrand.help})]}),(0,q.jsxs)(`span`,{className:`sentiment-nonbrand-counts`,children:[Ol.slice().reverse().filter(e=>a[e]>0).map(e=>(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`sentiment-legend-swatch ${Al[e]}`}),a[e],` `,e]},e)),!Nl(r)&&(0,q.jsx)(`span`,{className:`text-caution`,children:Z.partial})]}),(0,q.jsx)(W,{type:`button`,variant:`outline`,size:`sm`,onClick:e=>t.openEvidence({...Yl(t,r),queryClass:`non-brand`,outcome:Ol},Z.nonBrand.evidence,e.currentTarget),children:Z.nonBrand.view})]})})}function iu({queryClass:e=`all`,legend:t=!0,manage:n=!1}){let r=(0,K.useContext)(Jl),i=tu(r,e),[a,o]=(0,K.useState)(null);if(!r)return null;if(!i){let e=r.settings.data;return!n||!e?.actions.configure?null:(0,q.jsxs)(`div`,{className:`sentiment-headlines-title`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`sentiment-headlines-heading`,children:Z.title}),!(e.enabled&&e.installEnabled)&&(0,q.jsx)(`p`,{className:`sentiment-headlines-subtitle`,children:Z.states.disabled})]}),(0,q.jsx)(eu,{})]})}let s=r.hasSourceEvidence&&i.some(e=>r.summaries[e].data);return(0,q.jsxs)(`div`,{className:`sentiment-headlines`,role:`group`,"aria-label":`Favorable answer scores`,children:[(0,q.jsxs)(`div`,{className:`sentiment-headlines-title`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`sentiment-headlines-heading`,children:Z.title}),(0,q.jsx)(`p`,{className:`sentiment-headlines-subtitle`,children:Z.subtitle})]}),n&&(0,q.jsx)(eu,{})]}),t&&(0,q.jsx)(nu,{queryClass:e}),s&&(0,q.jsxs)(`div`,{className:`sentiment-headlines-columns`,"aria-hidden":`true`,children:[(0,q.jsx)(`span`,{className:`sentiment-headlines-favorable`,children:Z.columns.favorable}),(0,q.jsx)(`span`,{className:`sentiment-headlines-ratings`,title:Z.rated,children:Z.columns.rated})]}),i.map(e=>{let t=r.summaries[e];return(0,q.jsxs)(`div`,{className:`sentiment-class`,"data-query-class":e,children:[(0,q.jsxs)(`div`,{className:`sentiment-class-label`,children:[(0,q.jsx)(`span`,{children:xl[e]}),(0,q.jsx)(Tr,{text:Z.favorable})]}),r.hasSourceEvidence?t.data?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Il,{value:t.data,label:xl[e]}),(0,q.jsx)(zl,{value:t.data,label:xl[e]}),(0,q.jsx)(Hl,{coverage:t.data.coverage,label:xl[e]}),(0,q.jsx)(Ul,{value:t.data}),(0,q.jsx)(Gl,{value:t.data,queryClass:e,open:a===e,setOpenClass:o})]}):t.isError?(0,q.jsxs)(`p`,{role:`alert`,className:`sentiment-class-status`,children:[`Couldn’t load sentiment. `,(0,q.jsx)(W,{variant:`ghost`,onClick:()=>{t.refetch()},children:`Retry`})]}):(0,q.jsx)(`p`,{role:`status`,className:`sentiment-class-status`,children:`Loading sentiment…`}):(0,q.jsx)(`p`,{className:`sentiment-class-status`,children:`No saved answers.`})]},e)}),e!==`branded`&&(0,q.jsx)(ru,{queryClass:e})]})}function au({queryId:e,sourceSnapshotIds:t=[],queryClass:n,location:r,showLabel:i=!1}){let a=(0,K.useContext)(Jl);if(!a?.configured)return null;let o=n?a.summaries[n]:void 0,s=a.hasSourceEvidence?o?.data:void 0,c=s?.queries.filter(r=>r.queryClass===n&&(e?r.queryId===e:t.length>0)&&t.every(e=>r.sourceSnapshotIds.includes(e)))??[],l=c.length===1?c[0]:void 0,u=r===void 0?l:l?.locations.find(e=>e.location===r);if(!l||!u)return(0,q.jsx)(`span`,{className:`text-sm text-secondary`,children:a.hasSourceEvidence&&o?.isPending&&(e||t.length)?`Loading…`:`Unavailable`});let d={...a.selection,...s.selection,runId:s.selection.runId??void 0,runIds:s.selection.runId?void 0:s.selection.runIds,revision:s.selection.revision??void 0,evaluationDefinitionId:s.selection.evaluationDefinitionId??void 0,queryClass:l.queryClass,queryId:l.queryId,executionNodeKey:l.executionNodeKey??void 0,...r===void 0?{}:{location:r??`none`}};if(l.queryClass===`non-brand`){if(u.state===`unsupported`)return(0,q.jsx)(`span`,{className:`text-sm text-secondary`,children:`Unavailable`});let{unfavorable:e,mixed:t}=u.coverage.counts;if(e===0&&t===0){let e=i&&(0,q.jsx)(`span`,{className:`block text-sm font-normal text-secondary`,children:Z.nonBrand.rowLabel});return Nl(u)?(0,q.jsxs)(`span`,{className:`text-sm text-muted`,children:[e,(0,q.jsx)(`span`,{"aria-hidden":`true`,title:Z.nonBrand.rowNone,children:Cl}),(0,q.jsx)(`span`,{className:`sr-only`,children:Z.nonBrand.rowNone})]}):(0,q.jsxs)(`span`,{className:`text-sm text-secondary`,children:[e,(0,q.jsx)(`span`,{children:Pl(u)})]})}return(0,q.jsxs)(W,{type:`button`,variant:`ghost`,className:`h-auto min-h-11 flex-col items-start gap-0 px-1`,"aria-label":`View unfavorable and mixed answers for ${l.queryText}`,onKeyDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),a.openEvidence({...d,outcome:Ol},`${l.queryText}, unfavorable and mixed`,e.currentTarget)},children:[i&&(0,q.jsx)(`span`,{className:`text-sm font-normal text-secondary`,children:Z.nonBrand.rowLabel}),e>0&&(0,q.jsxs)(`span`,{className:`text-sm text-negative`,children:[e,` unfavorable`]}),t>0&&(0,q.jsxs)(`span`,{className:`text-sm text-caution`,children:[t,` mixed`]}),u.provisional&&(0,q.jsx)(`span`,{className:`text-xs font-normal text-caution`,children:`Provisional`})]})}return(0,q.jsxs)(W,{type:`button`,variant:`ghost`,className:`h-auto min-h-11 flex-col items-start gap-0 px-1`,"aria-label":`View ${xl[l.queryClass]} sentiment evidence for ${l.queryText}`,onKeyDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),a.openEvidence(d,l.queryText,e.currentTarget)},children:[i&&(0,q.jsx)(`span`,{className:`text-sm font-normal text-secondary`,children:`Favorable`}),(0,q.jsx)(`span`,{className:`font-mono text-primary`,children:u.score.favorableDisplay}),(0,q.jsxs)(`span`,{className:`text-sm font-normal text-secondary`,children:[u.coverage.judged,` judged`]}),u.provisional&&(0,q.jsx)(`span`,{className:`text-xs font-normal text-caution`,children:`Provisional`})]})}function ou(e){return e.outcome===`subject-not-mentioned`?`Not mentioned`:e.outcome===`running`?`Classifying`:e.outcome===`waiting-to-retry`?`Retrying`:e.outcome?Tl(e.outcome):e.state===`not-measured`?`Not classified`:e.state===`processing`?`Classifying`:e.state===`failed`?`Failed`:e.state===`canceled`?`Canceled`:`Unavailable`}function su({queryId:e,sourceSnapshotIds:t,queryClass:n,provider:r,model:i,location:a,showSubjects:o=!1,showLabel:s=!1}){let c=(0,K.useContext)(Jl);if(!c?.configured)return null;let l=n?c.summaries[n]:void 0,u=c.hasSourceEvidence?l?.data:void 0,d=u?.queries.filter(r=>r.queryClass===n&&(!e||r.queryId===e)&&t.length>0&&t.every(e=>r.sourceSnapshotIds.includes(e)))??[],f=d.length===1?d[0]:void 0,p=f?.assessments?.filter(e=>t.includes(e.sourceSnapshotId)&&e.provider===r&&e.location===a&&(i===void 0||e.servedModel===i))??[];return(0,q.jsxs)(`div`,{role:`group`,className:`text-sm text-secondary`,"aria-label":`${r||`Saved answer`} sentiment`,children:[s&&(0,q.jsx)(`span`,{className:`block text-sm text-secondary`,children:`Sentiment`}),p.length?p.map(e=>{let t=ou(e),n=Dl(e.outcome),r=(0,q.jsxs)(q.Fragment,{children:[o&&(0,q.jsxs)(`span`,{children:[e.subjectLabel,` · `]}),(0,q.jsx)(xn,{tone:n,className:`max-w-full shrink-0 rounded-none border-0 bg-transparent p-0 text-sm font-normal tracking-normal [overflow-wrap:normal]`,children:t})]}),i={...c.selection,...u.selection,runId:u.selection.runId??void 0,runIds:u.selection.runId?void 0:u.selection.runIds,revision:u.selection.revision??void 0,evaluationDefinitionId:u.selection.evaluationDefinitionId??void 0,queryClass:f.queryClass,queryId:f.queryId,executionNodeKey:f.executionNodeKey??void 0,assessmentId:e.assessmentId??void 0};return(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.assessmentId?(0,q.jsx)(W,{type:`button`,variant:`ghost`,className:`h-auto min-h-11 flex-wrap justify-start whitespace-normal px-1 text-left text-sm`,"aria-label":`View ${e.provider} sentiment evidence for ${e.subjectLabel}: ${t}`,onKeyDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),c.openEvidence(i,`${f.queryText} · ${e.provider} · ${e.subjectLabel}`,t.currentTarget)},children:r}):(0,q.jsx)(`span`,{children:r}),e.reason&&(0,q.jsx)(Tr,{text:e.reason})]},JSON.stringify([e.sourceSnapshotId,e.subjectId,e.assessmentId]))}):(0,q.jsx)(`span`,{children:c.hasSourceEvidence&&l?.isPending&&t.length?`Loading…`:`Unavailable`})]})}function cu({item:e}){return(0,q.jsxs)(`article`,{className:`space-y-4 border-b border-default py-5 text-sm text-secondary`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`strong`,{className:`text-primary`,children:e.subject.displayName}),(0,q.jsx)(xn,{tone:Dl(e.outcome),children:Tl(e.outcome)}),(0,q.jsx)(`span`,{children:xl[e.context.queryClass]}),(0,q.jsx)(`span`,{children:Ki(e.context.provider)}),(0,q.jsx)(`span`,{children:e.context.servedModel??`Source model unavailable`}),(0,q.jsx)(`span`,{children:e.context.location??`No location`})]}),e.reason&&(0,q.jsx)(`p`,{children:e.reason}),(0,q.jsxs)(`section`,{children:[(0,q.jsx)(`h3`,{className:`mb-2 text-heading`,children:`Conclusion evidence`}),e.conclusion.length?e.conclusion.map(e=>(0,q.jsx)(`blockquote`,{className:`mb-2 border-l border-strong pl-3 text-primary`,children:e.text},`${e.id}:${e.start}`)):(0,q.jsx)(`p`,{children:`No valid conclusion evidence is available.`})]}),(0,q.jsxs)(`section`,{children:[(0,q.jsx)(`h3`,{className:`mb-2 text-heading`,children:`Complaint evidence`}),e.complaint?.length?e.complaint.map(e=>(0,q.jsx)(`blockquote`,{className:`mb-2 border-l border-strong pl-3 text-primary`,children:e.text},`${e.id}:${e.start}`)):(0,q.jsx)(`p`,{children:`No complaint was identified.`})]}),(0,q.jsxs)(`details`,{children:[(0,q.jsx)(`summary`,{className:`cursor-pointer`,children:`Original source answer`}),(0,q.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-primary`,children:e.sourceText})]}),(0,q.jsxs)(`details`,{children:[(0,q.jsx)(`summary`,{className:`cursor-pointer`,children:`Assessment provenance`}),(0,q.jsxs)(`dl`,{className:`mt-3 space-y-2 break-all`,children:[(0,q.jsx)(`dt`,{children:`Query`}),(0,q.jsx)(`dd`,{children:e.context.queryText}),(0,q.jsx)(`dt`,{children:`Subject`}),(0,q.jsxs)(`dd`,{children:[e.subject.displayName,` (`,e.subject.id,`)`]}),(0,q.jsx)(`dt`,{children:`Run`}),(0,q.jsx)(`dd`,{children:e.runId}),(0,q.jsx)(`dt`,{children:`Revision`}),(0,q.jsx)(`dd`,{children:e.context.revision??`Unavailable`}),(0,q.jsx)(`dt`,{children:`Evaluator`}),(0,q.jsx)(`dd`,{children:e.returnedModel??`Unavailable`}),(0,q.jsx)(`dt`,{children:`Evaluation definition`}),(0,q.jsx)(`dd`,{children:e.evaluationDefinitionId}),(0,q.jsx)(`dt`,{children:`Source snapshot`}),(0,q.jsx)(`dd`,{children:e.sourceSnapshotId}),(0,q.jsx)(`dt`,{children:`Source hash`}),(0,q.jsx)(`dd`,{children:e.sourceTextHash}),e.context.usageEdges.map((e,t)=>(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{children:`Assignment`}),(0,q.jsxs)(`dd`,{children:[`Target `,e.targetId,`; Property `,e.propertyId??`None`,`; market `,e.marketId??`None`,`; `,e.queryClass]})]},t))]})]})]})}function lu({projectName:e,selection:t}){let[n,r]=(0,K.useState)(),i=R({queryKey:ml(e,`evidence`,t,n),queryFn:()=>Ct(e,t,n),retry:!1});return i.isPending?(0,q.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-secondary`,children:`Loading sentiment evidence…`}):i.isError?(0,q.jsxs)(`p`,{role:`alert`,className:`mt-4 text-sm text-secondary`,children:[`Could not load sentiment evidence. `,(0,q.jsx)(W,{variant:`outline`,onClick:()=>{i.refetch()},children:`Retry evidence`})]}):(0,q.jsxs)(q.Fragment,{children:[i.data.items.length?i.data.items.map(e=>(0,q.jsx)(cu,{item:e},e.assessmentId)):(0,q.jsx)(`p`,{className:`mt-4 text-sm text-secondary`,children:`No stored sentiment evidence for this query and scope.`}),(0,q.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[n&&(0,q.jsx)(W,{variant:`outline`,onClick:()=>r(void 0),children:`First evidence page`}),i.data.nextCursor&&(0,q.jsx)(W,{variant:`outline`,onClick:()=>r(i.data.nextCursor??void 0),children:`Next evidence page`})]})]})}function uu({projectName:e,jobId:t}){let[n,r]=(0,K.useState)(),i=R({queryKey:ml(e,`job:${t}`,void 0,n),queryFn:()=>kt(e,t,n),retry:!1});return i.isPending?(0,q.jsx)(`p`,{role:`status`,children:`Loading attempts…`}):i.isError?(0,q.jsxs)(`p`,{role:`alert`,children:[`Could not load attempts. `,(0,q.jsx)(W,{variant:`outline`,onClick:()=>{i.refetch()},children:`Retry attempts`})]}):(0,q.jsxs)(q.Fragment,{children:[i.data.attempts.map(e=>(0,q.jsxs)(`p`,{children:[e.errorCode??`Request complete`,`; `,e.usage.kind===`unknown`?`Usage unknown`:`${e.usage.inputTokens??`Unknown`} input tokens (${e.usage.kind})`]},e.id)),(0,q.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[n&&(0,q.jsx)(W,{variant:`outline`,onClick:()=>r(void 0),children:`Newest attempts`}),i.data.nextAttemptCursor&&(0,q.jsx)(W,{variant:`outline`,onClick:()=>r(i.data.nextAttemptCursor??void 0),children:`Older attempts`})]})]})}function du({projectName:e,job:t}){let[n,r]=(0,K.useState)(!1);return(0,q.jsxs)(`details`,{onToggle:e=>r(e.currentTarget.open),children:[(0,q.jsx)(`summary`,{children:`Job details`}),t.cancellationReason&&(0,q.jsx)(`p`,{children:t.cancellationReason}),Object.entries(t.counts).filter(([,e])=>e>0).map(([e,t])=>(0,q.jsxs)(`p`,{children:[Tl(e),`: `,t]},e)),(0,q.jsxs)(`p`,{children:[`Attempts: `,t.attemptCount]}),n&&t.attemptCount>0&&(0,q.jsx)(uu,{projectName:e,jobId:t.id})]})}function fu({projectName:e,jobs:t}){return(0,q.jsxs)(`details`,{className:`mt-6 text-sm text-secondary`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer`,children:`Recent sentiment jobs`}),t.length===0?(0,q.jsx)(`p`,{className:`mt-2`,children:`No sentiment jobs have been submitted.`}):(0,q.jsx)(`div`,{className:`data-table-wrapper mt-3`,children:(0,q.jsxs)(`table`,{className:`data-table`,"aria-label":`Sentiment jobs`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`th`,{children:`Submitted`}),(0,q.jsx)(`th`,{children:`State`}),(0,q.jsx)(`th`,{children:`Selected`}),(0,q.jsx)(`th`,{children:`Details`})]})}),(0,q.jsx)(`tbody`,{children:t.map(t=>(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`td`,{children:Vn(t.createdAt)}),(0,q.jsx)(`td`,{children:Tl(t.state)}),(0,q.jsx)(`td`,{children:t.selected}),(0,q.jsx)(`td`,{children:(0,q.jsx)(du,{projectName:e,job:t})})]},t.id))})]})})]})}var pu={probe:`Probe checks`,"unsupported-run-kind":`Not an AI Visibility check`,"failed-run":`Failed check`,"incomplete-run":`Incomplete check`,"legacy-missing-provenance":`Saved without its frozen query and subject record`,"legacy-missing-language":`Saved before the answer language was recorded`,"excluded-branded":`Branded answers (backfill that class separately)`,"excluded-non-brand":`Non-brand answers (backfill that class separately)`};function mu(e){return pu[e]??Tl(e)}function hu(e){return[e.provider&&`engine ${e.provider}`,e.model&&`model ${e.model}`,e.location&&(e.location===`none`?`no location`:`location ${e.location}`),e.scope!==`project`&&e.scopeKey&&`${e.scope} ${e.scopeKey}`,e.marketKey&&`market ${e.marketKey}`,e.queryId&&`query ${e.queryId}`,e.revision!==void 0&&`revision ${e.revision}`].filter(e=>!!e)}function gu(e){let t=hu(e);return[`${xl[e.queryClass]} queries`,...t.length?t:[`whole check`]].join(` · `)}function _u(e,t,n,r){return r?{...e,queryClass:n,queryId:void 0,runIds:void 0,runId:t}:{mode:`auto`,scope:`project`,queryClass:n,runId:t}}function vu({projectName:e,settings:t,selection:n,runOptions:r}){let i=ge(),[a,o]=(0,K.useState)(t.enabled),[s,c]=(0,K.useState)(n.runId??``),[l,u]=(0,K.useState)(n.queryClass),[d,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)(null),h=(0,K.useRef)(null),g=hu({...n,queryId:void 0}),_=()=>i.invalidateQueries({queryKey:[`sentiment`,e]}),v=()=>{m(null),h.current=null},y=L({mutationFn:async()=>{if(!(await Ae(e)).actions.configure)throw Error(`Administrator permission is required to configure sentiment.`);return En(e,{enabled:a})},onSuccess:async()=>{v(),await _(),await i.invalidateQueries({queryKey:[`project-overview-slim`]})},onError:_}),b=L({mutationFn:async()=>{if(!(await Ae(e)).actions.backfill)throw Error(`Administrator permission is required to backfill sentiment.`);return on(e,_u(n,s,l,d&&g.length>0))},onSuccess:e=>{m(e),h.current=crypto.randomUUID()},onError:_}),x=L({mutationFn:async()=>{if(!p?.previewToken||!h.current)throw Error(`Create and review a backfill preview first.`);if(!(await Ae(e)).actions.backfill)throw Error(`Administrator permission is required to backfill sentiment.`);return un(e,p.previewToken,h.current)},onSuccess:async()=>{v(),await _()},onError:_}),S=y.isPending||b.isPending||x.isPending;return(0,q.jsxs)(`div`,{className:`mt-5 space-y-5 text-sm text-secondary`,children:[(0,q.jsx)(`dl`,{className:`definition-list`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{children:`Evaluator`}),(0,q.jsxs)(`dd`,{children:[t.model,` · `,t.provider===`openrouter`?`OpenRouter`:`TypeSafe`]})]})}),(0,q.jsx)(`p`,{children:t.disclosure}),!t.ready&&(0,q.jsx)(`p`,{children:t.readinessReasons.join(`; `)||`An operator must configure sentiment on this installation.`}),(0,q.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),y.mutate()},children:[(0,q.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:a,disabled:S,onChange:e=>{o(e.target.checked),v()}}),`Enable project sentiment`]}),(0,q.jsx)(`p`,{children:`Enabling applies to future completed checks. Past checks require an explicit backfill.`}),(0,q.jsx)(ul,{type:`submit`,disabled:S,children:y.isPending?`Saving…`:`Save sentiment settings`}),y.isError&&(0,q.jsx)(`p`,{role:`alert`,children:mt(y.error)}),y.isSuccess&&(0,q.jsx)(`p`,{role:`status`,children:`Sentiment settings saved.`})]}),t.actions.backfill&&(0,q.jsxs)(`section`,{className:`space-y-3`,children:[(0,q.jsx)(`h3`,{children:`Backfill a saved check`}),(0,q.jsxs)(`label`,{className:`block`,children:[`Saved check`,(0,q.jsxs)(`select`,{className:`mt-1 block w-full rounded-md border border-default bg-bg p-2 text-primary`,value:s,disabled:S,onChange:e=>{c(e.target.value),v()},children:[(0,q.jsx)(`option`,{value:``,children:`Select a saved check`}),r.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),(0,q.jsxs)(`label`,{className:`block`,children:[`Query class`,(0,q.jsxs)(`select`,{className:`mt-1 block w-full rounded-md border border-default bg-bg p-2 text-primary`,value:l,disabled:S,onChange:e=>{u(e.target.value),v()},children:[(0,q.jsx)(`option`,{value:`non-brand`,children:`Non-brand`}),(0,q.jsx)(`option`,{value:`branded`,children:`Branded`})]})]}),(0,q.jsx)(`p`,{children:`The backfill covers every engine, location and query of the chosen check for this query class.`}),g.length>0&&(0,q.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:d,disabled:S,onChange:e=>{f(e.target.checked),v()}}),(0,q.jsxs)(`span`,{children:[`Limit to the current view`,(0,q.jsx)(`span`,{className:`block`,children:g.join(` · `)})]})]}),(0,q.jsx)(W,{variant:`outline`,disabled:S||!s||!t.enabled||!t.ready,onClick:()=>{v(),b.mutate()},children:b.isPending?`Preparing preview…`:`Preview sentiment backfill`}),b.isError&&(0,q.jsx)(`p`,{role:`alert`,children:mt(b.error)}),p&&(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsxs)(`dl`,{className:`grid grid-cols-[1fr_auto] gap-2`,children:[(0,q.jsx)(`dt`,{children:`Selection`}),(0,q.jsx)(`dd`,{className:`text-right`,children:gu(p.selection)}),(0,q.jsx)(`dt`,{children:`Eligible assessments`}),(0,q.jsx)(`dd`,{children:p.eligibleAssessments}),(0,q.jsx)(`dt`,{children:`Already classified`}),(0,q.jsx)(`dd`,{children:p.alreadyClassified}),(0,q.jsx)(`dt`,{children:`Estimated input tokens`}),(0,q.jsx)(`dd`,{children:p.estimatedInputTokens}),(0,q.jsx)(`dt`,{children:`Estimated cost (USD)`}),(0,q.jsx)(`dd`,{children:p.estimatedCostUsd??`Unavailable`})]}),(0,q.jsx)(Tr,{text:p.estimateMethod}),p.eligibleAssessments===0&&(0,q.jsx)(`p`,{children:`No saved answers in this selection can be classified.`}),p.skipped.length>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{children:`Not included:`}),(0,q.jsx)(`ul`,{"aria-label":`Skipped assessments`,className:`list-disc pl-5`,children:p.skipped.map(e=>(0,q.jsxs)(`li`,{children:[mu(e.reason),`: `,e.count]},`${e.runId}:${e.reason}`))})]}),(0,q.jsx)(ul,{disabled:S||!p.previewToken||p.eligibleAssessments===0,onClick:()=>x.mutate(),children:x.isPending?`Submitting…`:`Confirm sentiment backfill`})]}),x.isError&&(0,q.jsxs)(`p`,{role:`alert`,children:[mt(x.error),` Retry uses the same request key.`]}),x.isSuccess&&(0,q.jsx)(`p`,{role:`status`,children:`Backfill submitted. Progress is available in Recent jobs.`})]})]})}var yu=20;function bu({points:e,tone:t}){let n=(0,K.useId)();if(e.length===0)return null;let r=t=>5+t/Math.max(e.length-1,1)*122,i=zr(e),a=Math.min(...e),o=Math.max(...e),s=Math.max(o-a,yu),c=(o+a)/2-s/2,l=e.map((e,t)=>({x:r(t),y:5+(1-(e-c)/s)*26}));return(0,q.jsxs)(`svg`,{className:`sparkline sparkline-${t}${i?` sparkline-provisional`:``}`,viewBox:`0 0 132 42`,"aria-hidden":`true`,children:[(0,q.jsx)(`defs`,{children:(0,q.jsx)(`clipPath`,{id:n,children:(0,q.jsx)(`rect`,{x:5,y:5,width:122,height:32,rx:`8`})})}),(0,q.jsx)(`line`,{className:`sparkline-guide`,x1:5,x2:127,y1:37,y2:37}),l.length===1?(0,q.jsx)(`circle`,{className:`sparkline-point`,cx:l[0].x,cy:l[0].y,r:`3`}):(0,q.jsx)(`polyline`,{clipPath:`url(#${n})`,points:l.map(e=>`${e.x},${e.y}`).join(` `),vectorEffect:`non-scaling-stroke`})]})}function xu({run:e,projectName:t,children:n,className:r,label:i}){let{openRun:a}=ns();return e.kind===G[`seo-sync`]?t?(0,q.jsx)(B,{to:`/projects/$projectName/seo-data`,params:{projectName:t},search:t=>({...t,seoRunId:e.id,seoProfileId:void 0,runId:void 0,evidenceId:void 0}),className:r,"aria-label":i,children:n}):(0,q.jsx)(`button`,{type:`button`,disabled:!0,className:r,"aria-label":i,title:`Project unavailable`,children:n}):(0,q.jsx)(`button`,{type:`button`,className:r,"aria-label":i,onClick:()=>a(e.id),children:n})}function Su({project:e,sentimentColumn:t}){return(0,q.jsxs)(`div`,{className:`project-row relative${t?` project-row-with-sentiment`:``}`,children:[(0,q.jsx)(`div`,{className:`project-row-chart`,children:(0,q.jsx)(bu,{points:e.trend,tone:ri(e.lastRun.status)})}),(0,q.jsxs)(`div`,{className:`project-row-primary`,children:[(0,q.jsxs)(B,{to:`/projects/$projectName`,params:{projectName:e.project.name},className:`after:absolute after:inset-0 after:rounded-xl focus-visible:outline-none focus-visible:after:ring-2 focus-visible:after:ring-mono-400`,children:[(0,q.jsx)(`p`,{className:`project-name`,children:e.project.name}),(0,q.jsx)(`p`,{className:`project-domain`,children:e.project.canonicalDomain})]}),(0,q.jsx)(`p`,{className:`project-insight`,children:e.insight})]}),(0,q.jsx)(`div`,{className:`project-row-stat`,children:(0,q.jsxs)(`div`,{className:`metric-inline-block`,children:[(0,q.jsx)(`p`,{className:`metric-inline-label`,children:`Mentioned`}),(0,q.jsx)(`p`,{className:`metric-inline-value ${e.mentionTone===`caution`?`text-caution-400`:``}`,children:e.hasMeasurement===!1?`Not measured`:pt(e.mentionScore,Kt.percent)}),(0,q.jsx)(`p`,{className:`metric-inline-caption${e.providerCoverage?` text-caution`:``}`,title:e.providerCoverage,children:e.providerCoverage?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Partial check: `}),e.providerCoverage]}):e.mentionDelta})]})}),(0,q.jsx)(`div`,{className:`project-row-stat`,children:(0,q.jsxs)(`div`,{className:`metric-inline-block`,children:[(0,q.jsxs)(`p`,{className:`metric-inline-label`,children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`Pressure`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Competitor pressure`})]}),(0,q.jsx)(`p`,{className:`metric-inline-value`,children:e.hasMeasurement===!1?`Not measured`:e.competitorPressureLabel}),(0,q.jsx)(`p`,{className:`metric-inline-caption`,"aria-hidden":`true`})]})}),Kl(e.sentiment)?(0,q.jsx)(ql,{value:e.sentiment}):t&&(0,q.jsx)(`div`,{className:`project-row-stat`,"aria-hidden":`true`,"data-sentiment-placeholder":!0}),(0,q.jsx)(`span`,{className:`project-row-link`,children:(0,q.jsx)(v,{className:`h-4 w-4 text-muted`})})]})}function Cu(){let{isAdmin:e}=Jn(),t=Go(),{dashboard:n,isLoading:r,isError:i,activityLoading:a,activityError:o,refetch:s}=Ko(),c=n??t?.dashboard,l=es(!t,t?.health);if(i&&!c)return(0,q.jsxs)(`div`,{className:`page-container`,children:[(0,q.jsx)(`div`,{className:`page-header`,children:(0,q.jsxs)(`div`,{className:`page-header-left`,children:[(0,q.jsx)(`h1`,{className:`page-title`,children:`All projects unavailable`}),(0,q.jsx)(`p`,{className:`page-subtitle`,children:`Canonry could not load the project list.`})]})}),(0,q.jsxs)(`div`,{className:`max-w-xl rounded-lg border border-negative bg-negative-soft p-4`,role:`alert`,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-heading`,children:`Your projects have not been changed.`}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-secondary`,children:`Check the connection or sign in again, then retry.`}),(0,q.jsx)(W,{type:`button`,variant:`secondary`,className:`mt-4`,onClick:()=>{s()},children:`Retry loading projects`})]})]});if(!c||r)return(0,q.jsxs)(`div`,{className:`page-skeleton`,children:[(0,q.jsxs)(`div`,{className:`page-skeleton-header`,children:[(0,q.jsx)(`div`,{className:`skeleton-text h-6 w-32`}),(0,q.jsx)(`div`,{className:`skeleton-text-sm w-64`})]}),(0,q.jsx)(`div`,{className:`space-y-3`,children:[1,2,3].map(e=>(0,q.jsxs)(`div`,{className:`rounded-xl border border-default bg-surface p-4 flex items-center gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,q.jsx)(`div`,{className:`skeleton-text w-36`}),(0,q.jsx)(`div`,{className:`skeleton-text-sm w-48`})]}),(0,q.jsx)(`div`,{className:`skeleton-text w-16`}),(0,q.jsx)(`div`,{className:`skeleton-text w-16`}),(0,q.jsx)(`div`,{className:`skeleton h-8 w-20 rounded`})]},e))})]});let u=c.portfolioOverview,d=u.projects.length>0&&u.projects.every(e=>e.hasMeasurement===!1),f=u.projects.some(e=>Kl(e.sentiment)),p=u.attentionItems.map(e=>d&&e.id===`attention_stable`?{...e,tone:`neutral`,title:`Awaiting first measurement`,detail:`Visibility results will appear after the first check.`}:e),m=l.data??t?.health??{apiStatus:{label:`API`,state:`checking`,detail:`Checking service health`},workerStatus:{label:`Worker`,state:`checking`,detail:`Checking service health`}},h=ui(u.systemHealth.filter(t=>e||t.id===`api`||t.id===`worker`),m,c.settings);return(0,q.jsxs)(`div`,{className:`page-container`,children:[(0,q.jsx)(`div`,{className:`page-header`,children:(0,q.jsxs)(`div`,{className:`page-header-left`,children:[(0,q.jsx)(`h1`,{className:`page-title`,children:`All projects`}),(0,q.jsx)(`p`,{className:`page-subtitle`,children:`Visibility across all projects.`})]})}),u.projects.length>0?(0,q.jsx)(`div`,{className:`project-list project-list-scrollable`,children:u.projects.map(e=>(0,q.jsx)(Su,{project:e,sentimentColumn:f},e.project.id))}):(0,q.jsxs)(Ar,{className:`surface-card empty-card`,children:[(0,q.jsx)(`h3`,{children:u.emptyState?.title??`No projects yet`}),(0,q.jsx)(`p`,{className:`supporting-copy`,children:u.emptyState?.detail}),(0,q.jsx)(W,{size:`sm`,asChild:!0,children:(0,q.jsx)(B,{to:u.emptyState?.ctaHref===`/setup`||!u.emptyState?.ctaHref?`/setup`:`/`,children:u.emptyState?.ctaLabel??`Launch setup`})})]}),(0,q.jsxs)(`div`,{className:`overview-secondary-grid`,children:[p.length>0&&(0,q.jsxs)(`section`,{className:`overview-secondary-section`,children:[(0,q.jsx)(`div`,{className:`section-head section-head-inline`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`eyebrow eyebrow-soft`,children:`Needs attention`}),(0,q.jsx)(`h2`,{className:`section-title-sm`,children:`What changed`})]})}),(0,q.jsx)(`div`,{className:`attention-list attention-list-scrollable`,children:p.map(e=>e.href?(0,q.jsxs)(B,{to:e.href,className:`attention-item attention-item-${e.tone}`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`attention-title`,children:e.title}),(0,q.jsx)(`p`,{className:`attention-detail`,children:e.detail})]}),e.actionLabel&&(0,q.jsx)(`span`,{className:`attention-action`,children:e.actionLabel})]},e.id):(0,q.jsxs)(`div`,{className:`attention-item attention-item-static attention-item-${e.tone}`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`attention-title`,children:e.title}),(0,q.jsx)(`p`,{className:`attention-detail`,children:e.detail})]}),e.actionLabel&&(0,q.jsx)(`span`,{className:`attention-action`,children:e.actionLabel})]},e.id))})]}),(0,q.jsxs)(`section`,{className:`overview-secondary-section`,children:[(0,q.jsx)(`div`,{className:`section-head section-head-inline`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`eyebrow eyebrow-soft`,children:`Recent runs`}),(0,q.jsx)(`h2`,{className:`section-title-sm`,children:`Activity`})]})}),(0,q.jsx)(`div`,{className:`compact-stack compact-stack-scrollable`,children:o?(0,q.jsxs)(`div`,{role:`alert`,children:[(0,q.jsx)(`p`,{className:`text-sm text-secondary`,children:`Recent jobs could not be loaded.`}),(0,q.jsx)(W,{type:`button`,variant:`secondary`,className:`mt-3`,onClick:()=>{s()},children:`Retry loading activity`})]}):a?(0,q.jsx)(`p`,{className:`supporting-copy`,role:`status`,children:`Loading recent jobs…`}):u.recentRuns.length>0?u.recentRuns.map(e=>(0,q.jsxs)(xu,{run:e,projectName:u.projects.find(t=>t.project.id===e.projectId)?.project.name,className:`compact-run`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`compact-run-title`,children:e.projectName}),(0,q.jsx)(`p`,{className:`compact-run-detail`,children:e.summary})]}),(0,q.jsx)(Na,{status:e.status})]},e.id)):(0,q.jsx)(`p`,{className:`supporting-copy`,children:`Run history appears here after the first launch.`})})]})]}),(0,q.jsxs)(`section`,{className:`page-section`,children:[(0,q.jsx)(`div`,{className:`section-head section-head-inline`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`eyebrow eyebrow-soft`,children:`System health`}),(0,q.jsx)(`h2`,{className:`section-title-sm`,children:`Infrastructure`})]})}),(0,q.jsx)(`div`,{className:`divide-y divide-default border-y border-default`,children:h.map(e=>{let t=e.id===`api`?m.apiStatus:e.id===`worker`?m.workerStatus:void 0,n=t?t.state===`ok`?void 0:li(t):e.tone===`positive`?void 0:e.meta;return(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-heading`,children:e.label}),n&&(0,q.jsx)(`p`,{className:`mt-1 text-sm text-secondary`,children:n})]}),(0,q.jsx)(xn,{tone:e.tone,title:t?li(t):e.meta,children:e.detail})]},e.id)})})]})]})}var wu=`a, button, input, select, textarea, label, [role="button"], [role="link"], [role="checkbox"], [role="menuitem"]`;function Tu(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!1;let t=e.target;if(t&&typeof t.closest==`function`&&t.closest(wu))return!1;let n=typeof window<`u`?window.getSelection():null;return!(n&&!n.isCollapsed&&n.toString().trim()!==``)}function Eu({onApplied:e}){let{canWrite:t}=Jn(),[n,r]=(0,K.useState)(``),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)([]),[c,l]=(0,K.useState)([]);return ze()||!t?null:(0,q.jsxs)(`section`,{className:`mt-8`,children:[(0,q.jsx)(`div`,{className:`page-section-divider`}),(0,q.jsx)(`div`,{className:`section-head mt-6`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`eyebrow eyebrow-soft`,children:`Config as code`}),(0,q.jsx)(`h2`,{className:`text-sm font-medium text-strong`,children:`Apply YAML`})]})}),(0,q.jsxs)(`p`,{className:`text-muted text-sm mb-3`,children:[`Paste a `,(0,q.jsx)(`code`,{className:`text-secondary`,children:`canonry.yaml`}),` config (multi-document YAML with `,(0,q.jsx)(`code`,{className:`text-secondary`,children:`---`}),` separators supported).`]}),(0,q.jsx)(`textarea`,{className:`setup-input w-full font-mono text-xs`,rows:10,placeholder:`apiVersion: canonry/v1
18
+ `)}}if(l?.aborted)throw new DOMException(`Turn stopped`,`AbortError`);if(!p)throw Error(`Connection ended before Aero finished. Review the partial answer before retrying.`)}finally{l?.removeEventListener(`abort`,_);try{m.releaseLock()}catch{}}}function tc(e){return!e||e.role!==`assistant`?``:e.content.filter(e=>e.type===`text`).map(e=>e.text).join(``)}var nc=[{id:`status`,label:`Status`,prompt:`Give me a quick status: the latest check, which engines answered, and anything that needs attention.`},{id:`changes`,label:`What changed`,prompt:`Compare the latest complete check with the one before it. Lead with mentions, then citations. Keep branded and non-brand queries separate if the project splits them, and say which changes are bigger than normal run-to-run noise.`},{id:`gaps`,label:`Biggest gaps`,prompt:`Which tracked queries does no engine mention us on, and who gets named instead? Group them by topic or market.`},{id:`insights`,label:`Top insights`,prompt:`Walk me through the 3 most severe active insights and what to do about each.`}],rc=`https://canonry.ai`,ic=`This demo plays sample answers only. Pick a starting point, or type / to choose one.`,ac=`Stopped. The sample answer so far is kept.`;function oc(e){return{queryKey:[`aero-preview`,e],queryFn:()=>Qs(e),staleTime:1/0,gcTime:1/0}}var sc=[{command:`/status`,label:`Status`,prompt:`Give me a quick status: the latest check, which engines answered, and anything that needs attention.`},{command:`/changes`,label:`What changed`,prompt:`Compare the latest complete check with the one before it. Lead with mentions, then citations. Keep branded and non-brand queries separate if the project splits them, and say which changes are bigger than normal run-to-run noise.`},{command:`/gaps`,label:`Biggest gaps`,prompt:`Which tracked queries does no engine mention us on, and who gets named instead? Group them by topic or market.`},{command:`/insights`,label:`Top insights`,prompt:`Walk me through the 3 most severe active insights and what to do about each.`},{command:`/last-run`,label:`Last run`,prompt:`Summarize the latest run for this project: which engines answered, what moved in mentions and citations, and anything that failed.`},{command:`/run-sweep`,label:`Run check now`,prompt:`Run a new AI Visibility check for this project now and tell me when it lands.`},{command:`/queries`,label:`Queries`,prompt:`List the tracked queries for this project and flag any that are obvious duplicates or underperformers.`},{command:`/competitors`,label:`Competitors`,prompt:`Which competitors do engines name most often on queries where we are not named, and on which engines?`},{command:`/new`,label:`New conversation (save current)`,action:`new`}],cc=e=>`canonry:aero:provider:${e}`,lc=(e,t)=>`canonry:aero:model:${e}:${t}`,uc=e=>`canonry:aero:openrouter-model:${e}`;function dc(e){let t={};for(let n of Object.values(Nn)){let r=pc(lc(e,n))??(n===Nn.openrouter?pc(uc(e)):null);r&&(t[n]=r)}return t}var fc=e=>`canonry:aero:scope:${e}`;function pc(e){if(typeof window>`u`)return null;try{return window.localStorage.getItem(e)}catch{return null}}function mc(e,t){if(typeof window<`u`)try{window.localStorage.setItem(e,t)}catch{}}function hc(e){if(typeof window<`u`)try{window.localStorage.removeItem(e)}catch{}}function gc({projectName:e,context:t,preview:r=zt()}){let a=_t(),{canWrite:o,account:s}=Jn(),c=ge(),l=s?.role===`viewer`,[u,d]=(0,K.useState)(!1),[f,p]=(0,K.useState)(!1),[h,g]=(0,K.useState)([]),[_,v]=(0,K.useState)(void 0),y=(0,K.useRef)(!1),[b,x]=(0,K.useState)(!1),[S,C]=(0,K.useState)(!1),[w,T]=(0,K.useState)(null),[D,O]=(0,K.useState)(!1),[A,j]=(0,K.useState)(!1),[te,ne]=(0,K.useState)(null),re=(0,K.useRef)(!1),[ae,oe]=(0,K.useState)(``),[se,ce]=(0,K.useState)(!1),[le,ue]=(0,K.useState)([]),[de,fe]=(0,K.useState)(``),[pe,P]=(0,K.useState)(null),[me,F]=(0,K.useState)(null),[I,he]=(0,K.useState)(null),_e=(0,K.useRef)(!0),[L,ve]=(0,K.useState)(()=>pc(cc(e))??null),ye=a||l||r?null:L,[be,xe]=(0,K.useState)(()=>dc(e)),[Se,Ce]=(0,K.useState)(null),[z]=(0,K.useState)(()=>pc(fc(e))===`all`?`all`:`read-only`),we=a||l||r?`read-only`:z,Te=(0,K.useRef)(null),Ee=(0,K.useRef)(null),De=(0,K.useRef)(null),Oe=(0,K.useRef)(null),{ref:ke}=Ds([h,de,le]),Ae=(0,K.useRef)(null);(0,K.useLayoutEffect)(()=>{let e=Ae.current;if(!e)return;e.style.height=`auto`;let t=f?xc:bc;e.scrollHeight>0&&(e.style.height=`${Math.min(e.scrollHeight,t)}px`)},[ae,f,u]);let[je,Me]=(0,K.useState)(0),Ne=(0,K.useMemo)(()=>{let e=ae.trimStart();if(!e.startsWith(`/`)||/\s/.test(e))return[];let t=e.toLowerCase();return sc.filter(e=>(!(a||l)||e.command!==`/run-sweep`)&&(!l||e.action!==`new`)&&(!r||nc.some(t=>t.prompt===e.prompt))&&(e.command.startsWith(t)||e.label.toLowerCase().includes(t.slice(1))))},[ae,a,l,r]);(0,K.useEffect)(()=>{Me(e=>Ne.length===0?0:Math.min(e,Ne.length-1))},[Ne.length]);let Pe=R({...mr({client:U,path:{name:e}}),enabled:!l&&!r,staleTime:6e4}),Fe=(0,K.useMemo)(()=>{let e=Pe.data?.providers??[];if(ye){let t=e.find(e=>e.id===ye&&e.configured);if(t)return t}let t=Se?e.find(e=>e.id===Se.provider&&e.configured):void 0;if(t)return t;let n=Pe.data?.defaultProvider;return n?e.find(e=>e.id===n)??null:null},[ye,Pe.data,Se]),Ie=l||r||Fe!==null,Le=Fe?be[Fe.id]??``:``,Re=!ye&&Fe&&Se?.provider===Fe.id?Se.modelId:void 0,ze=!a&&!l&&!r&&Fe&&Le.trim()?Le.trim():void 0,Ve=(ze?Fe?.id:void 0)??ye??void 0,He=(0,K.useCallback)((t,n)=>{let r=n.trim();xe(e=>({...e,[t]:n})),r?mc(lc(e,t),r):hc(lc(e,t)),t===Nn.openrouter&&hc(uc(e))},[e]);R({...oc(e),enabled:r&&u}),(0,K.useEffect)(()=>{Pe.data&&ye&&(Pe.data.providers.find(e=>e.id===ye&&e.configured)||(ve(null),hc(cc(e))))},[Pe.data,ye,e]);let Ue=(0,K.useCallback)(t=>{ve(t),t?mc(cc(e),t):hc(cc(e))},[e]);(0,K.useEffect)(()=>{if(!u)return;let e=e=>{e.key===`Escape`&&(S?C(!1):f?p(!1):d(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u,f,S]);let We=(0,K.useRef)(null);(0,K.useEffect)(()=>{u||(We.current=null)},[u]),(0,K.useEffect)(()=>{if(!u||!Ie||r)return;let t=!1;We.current!==e&&(We.current=e,P(null));let n=()=>{t||se||re.current||Zs(e).then(e=>{t||re.current||(j(e.isStreaming??!1),v(e.conversationId??null),Ce(e.nextTurn??null),!t&&!e.isStreaming&&(Ee.current===null||e.updatedAt&&e.updatedAt!==Ee.current.previous)&&(g(e.messages),Te.current=e.updatedAt,Ee.current=null))}).catch(e=>{t||P(mt(e))})};n();let i=window.setInterval(n,15e3);return()=>{t=!0,window.clearInterval(i)}},[u,e,se,Ie,D,r]),(0,K.useEffect)(()=>(_e.current=!0,()=>{_e.current=!1,Oe.current?.abort()}),[e]);async function Ke(n,i=t){let o=n.trim();if(!o||S||se||D||re.current||A||!Ie)return;if(r){await qe(o);return}if(a&&/^\/run-sweep(?:\s|$)/i.test(o)){P(Os);return}P(null),F(null),he({prompt:o,context:i}),oe(``),ce(!0),fe(``),De.current=null,ue([]),Ee.current={previous:Te.current};let s={role:`user`,content:o,timestamp:Date.now(),aeroContext:i};g(e=>[...e,s]);let c=new AbortController;Oe.current=c;try{await ec({project:e,prompt:o,conversationId:_,provider:Ve,modelId:ze,scope:we,context:i,signal:c.signal,onEvent:Je});let t=await Zs(e);_e.current&&!t.isStreaming&&(v(t.conversationId??null),Ce(t.nextTurn??null),g(t.messages),Te.current=t.updatedAt,Ee.current=null)}catch(e){if(!_e.current)return;l&&(Ee.current=null);let t=De.current;t&&tc(t).trim()&&g(e=>[...e,t]),c.signal.aborted?F(`Stopped. Partial response preserved. An action already dispatched may still finish.`):P(mt(e))}finally{_e.current&&(ce(!1),fe(``),ue(e=>e.map(e=>e.endedAt===void 0?{...e,interrupted:!0}:e))),Oe.current=null}}async function qe(t){let n=sc.find(e=>e.command===t.toLowerCase())?.prompt??t,r=nc.find(e=>e.prompt===n)?.id;if(!r){P(null),he(null),F(ic);return}P(null),F(null),he({prompt:n}),oe(``),ce(!0),fe(``),De.current=null,ue([]),g(e=>[...e,{role:`user`,content:n,timestamp:Date.now()}]);let i=new AbortController;Oe.current=i;try{let t=await c.ensureQueryData(oc(e));if(i.signal.aborted)throw new DOMException(`Preview stopped`,`AbortError`);let n=t.starters.find(e=>e.id===r);if(!n)throw Error(`This demo has no sample answer for that starting point.`);await Ks({starter:n,signal:i.signal,onEvent:Je,reducedMotion:Vs()})}catch(e){if(!_e.current)return;let t=De.current;t&&tc(t).trim()&&g(e=>[...e,t]),i.signal.aborted?F(ac):P(mt(e))}finally{_e.current&&(ce(!1),fe(``),ue(e=>e.map(e=>e.endedAt===void 0?{...e,interrupted:!0}:e))),Oe.current=null}}function Je(e){if(_e.current)switch(e.type){case`message_update`:e.message.role===`assistant`&&(De.current=e.message),fe(tc(e.message));break;case`message_end`:if(e.message.role!==`user`){let t=e.message;g(e=>[...e,t])}e.message.role===`assistant`&&(De.current=null,fe(``),e.message.errorMessage&&P(e.message.errorMessage));break;case`aero_turn_status`:e.status?.reason===`tool-limit`?F(`Tool-call limit reached. Partial response preserved.`):e.status?.reason===`time-limit`?F(`Time limit reached. Partial response preserved.`):e.status?.reason===`completed`?he(null):e.status?.reason===`error`&&P(e=>e??`Aero could not finish this answer. Retry to ask again.`);break;case`tool_execution_start`:ue(t=>[...t,{id:e.toolCallId,name:e.toolName,label:e.label,args:e.args,startedAt:Date.now()}]);break;case`tool_execution_end`:ue(t=>t.map(t=>t.id===e.toolCallId?{...t,endedAt:Date.now(),isError:e.isError,result:e.result}:t));break;case`error`:P(e.message)}}async function Ye(t,n=!1){if(!(se||A||re.current)){re.current=!0,O(!0),P(null);try{await t();let r=await Zs(e);if(!_e.current)return;Ee.current=null,Te.current=r.updatedAt,v(r.conversationId??null),Ce(r.nextTurn??null),g(r.messages),ue([]),fe(``),F(null),he(null),ne(null),C(n),T(n?await bt(e):null),Ae.current?.focus()}catch(e){_e.current&&P(mt(e))}finally{re.current=!1,_e.current&&O(!1)}}}async function Xe(){if(r){if(se)return;g([]),ue([]),fe(``),P(null),F(null),he(null),Ae.current?.focus()}else await Ye(()=>l?$s(e):Dn(e,crypto.randomUUID()))}async function Ze(t=!1){if(!(re.current||y.current)){y.current=!0,x(!0),C(!0),P(null);try{let n=await bt(e,{offset:t?w?.nextOffset??0:0});_e.current&&T(e=>t&&e?{...n,conversations:[...e.conversations,...n.conversations]}:n)}catch(e){_e.current&&P(mt(e))}finally{y.current=!1,_e.current&&x(!1)}}}let Qe=h.length===0,$e=!(l||r);if($e&&Pe.isPending)return null;if($e&&Pe.isError)return(0,q.jsx)(`div`,{className:`pointer-events-none fixed inset-x-0 bottom-0 z-40 flex justify-center p-3`,children:(0,q.jsxs)(`div`,{role:`status`,className:`flex w-full max-w-3xl flex-wrap items-center gap-x-2 gap-y-1 rounded-lg border border-base bg-bg/95 px-4 py-2 text-sm shadow-lg`,children:[(0,q.jsx)(N,{className:`h-4 w-4 text-muted`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`font-medium text-strong`,children:`Aero could not check provider availability.`}),(0,q.jsx)(W,{variant:`outline`,size:`sm`,className:`pointer-events-auto ml-auto`,onClick:()=>{Pe.refetch()},children:`Try again`})]})});let et=Fe&&!Fe.configured?Fe:null;if($e&&(!Fe||et))return(0,q.jsx)(`div`,{className:`pointer-events-none fixed inset-x-0 bottom-0 z-40 flex justify-center p-3`,children:(0,q.jsxs)(`div`,{role:`status`,className:`flex w-full max-w-3xl flex-wrap items-center gap-x-2 gap-y-1 rounded-lg border border-base bg-bg/95 px-4 py-2 text-sm shadow-lg`,children:[(0,q.jsx)(N,{className:`h-4 w-4 text-muted`,"aria-hidden":`true`}),(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5 font-medium text-strong`,children:[et?`Aero is set to ${et.label.replace(/\s+\(.+\)$/,``)}, which has no API key.`:`Aero needs an answer-engine provider.`,(0,q.jsx)(Tr,{text:et?`Set ${Tc(et.id)} on the server, or providers.${et.id}.apiKey in its config.yaml.`:`Aero is the built-in AEO analyst. It reads your Canonry data with you once a provider is connected.`})]}),et?null:o?(0,q.jsx)(W,{asChild:!0,variant:`outline`,size:`sm`,className:`pointer-events-auto ml-auto`,children:(0,q.jsx)(B,{to:`/settings`,children:`Open Settings`})}):(0,q.jsx)(`span`,{className:`ml-auto text-secondary`,children:`Ask an administrator to configure one.`})]})});let tt=u&&f?`pointer-events-auto fixed inset-0 z-40 flex items-stretch justify-center bg-bg/70 p-4 sm:p-8 backdrop-blur-sm`:`pointer-events-none fixed inset-x-0 bottom-0 z-40 flex justify-center p-3`,nt=f?`pointer-events-auto flex h-full w-full max-w-5xl flex-col overflow-hidden rounded-2xl border border-mono-800/80 bg-bg/95 shadow-2xl`:`pointer-events-auto w-full max-w-3xl`,rt=f?`flex-1 overflow-y-auto px-6 py-5 text-sm text-strong`:`max-h-[40vh] min-h-[120px] overflow-y-auto px-4 py-3 text-sm text-strong`;return(0,q.jsx)(`div`,{className:tt,onClick:e=>{f&&e.target===e.currentTarget&&p(!1)},children:(0,q.jsx)(`div`,{className:nt,children:u?(0,q.jsxs)(`div`,{"data-aero-panel":!0,className:f?`flex h-full flex-col`:`flex flex-col overflow-hidden rounded-2xl border border-mono-800/80 bg-bg/95 shadow-xl backdrop-blur`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-mono-800/70 px-4 py-2.5`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(N,{className:`h-4 w-4 shrink-0 text-positive-400`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`text-sm font-medium text-heading`,children:`Aero`}),(0,q.jsx)(`span`,{className:`hidden min-w-0 truncate text-[10px] uppercase tracking-wider text-muted sm:inline`,children:se||A?`working…`:e})]}),(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[!a&&!l&&!r&&(0,q.jsx)(vc,{providers:Pe.data?.providers??[],active:Fe,override:ye,onPick:Ue,modelId:Le,fallbackModel:Re,onModelChange:e=>{Fe&&He(Fe.id,e)},disabled:se}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>p(e=>!e),className:`shrink-0 rounded-md p-1.5 text-muted transition hover:bg-surface-inset hover:text-strong`,"aria-label":f?`Collapse`:`Expand`,title:f?`Collapse`:`Expand`,children:f?(0,q.jsx)(i,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}):(0,q.jsx)(ee,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{p(!1),d(!1)},className:`shrink-0 rounded-md p-1.5 text-muted transition hover:bg-surface-inset hover:text-strong`,"aria-label":`Close Aero`,children:(0,q.jsx)(ie,{className:`h-4 w-4`,"aria-hidden":`true`})})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-subtle px-4 py-2`,children:[(0,q.jsxs)(W,{variant:`outline`,size:`sm`,disabled:se||A||D,onClick:Xn(Xe),title:l||r?`Clear this conversation and start fresh.`:`Save this conversation and start fresh. Shared project notes are kept.`,children:[(0,q.jsx)(M,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),` New conversation`]}),!l&&!r&&(0,q.jsxs)(W,{variant:`ghost`,size:`sm`,"aria-expanded":S,"aria-controls":`aero-history`,disabled:D,onClick:()=>{S?C(!1):Ze()},children:[(0,q.jsx)(E,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),` History`]})]}),S?(0,q.jsxs)(`div`,{id:`aero-history`,className:rt,"aria-label":`Conversation history`,children:[(0,q.jsxs)(`h3`,{className:`mb-2 text-sm font-medium text-heading`,children:[`Conversations in `,e]}),w?w.conversations.length===0?(0,q.jsx)(`p`,{className:`text-sm text-secondary`,children:`No saved conversations yet. Your conversations will appear here.`}):(0,q.jsx)(`ul`,{className:`divide-y divide-default`,children:w.conversations.map(t=>(0,q.jsxs)(`li`,{className:`py-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(`button`,{className:`min-w-0 flex-1 rounded-md px-2 py-1 text-left hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-positive-500`,disabled:se||A||D,onClick:()=>{t.active?C(!1):Ye(()=>zn(e,t.id))},children:[(0,q.jsx)(`span`,{className:`block truncate text-sm text-heading`,children:t.title}),(0,q.jsxs)(`span`,{className:`text-xs text-secondary`,children:[t.active?`Current · `:``,new Date(t.updatedAt).toLocaleString()]})]}),(0,q.jsx)(W,{variant:`ghost`,size:`sm`,disabled:se||A||D,"aria-label":`Delete conversation: ${t.title}`,onClick:()=>ne(t.id),children:`Delete`})]}),te===t.id&&(0,q.jsxs)(`div`,{role:`group`,"aria-label":`Confirm conversation deletion`,className:`mt-2 rounded-md border border-default p-3 text-sm text-secondary`,children:[(0,q.jsx)(`p`,{children:`Delete this conversation permanently? Shared project notes will be kept.`}),(0,q.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,q.jsx)(W,{variant:`destructive`,size:`sm`,disabled:D,onClick:()=>{Ye(async()=>{await Be(e,t.id)},!0)},children:`Delete conversation`}),(0,q.jsx)(W,{variant:`ghost`,size:`sm`,disabled:D,onClick:()=>ne(null),children:`Cancel`})]})]})]},t.id))}):(0,q.jsx)(`p`,{className:`text-sm text-secondary`,children:b?`Loading history…`:`History could not be loaded. Close and reopen History to retry.`}),w?.nextOffset!=null&&(0,q.jsx)(W,{variant:`ghost`,size:`sm`,disabled:b,onClick:()=>{Ze(!0)},children:b?`Loading…`:`Load more`})]}):(0,q.jsxs)(`div`,{ref:ke,className:rt,children:[Qe&&!se&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 py-2`,children:[(0,q.jsx)(`p`,{className:`text-sm text-secondary`,children:r?(0,q.jsxs)(q.Fragment,{children:[`See how Aero answers about `,(0,q.jsx)(`span`,{className:`text-strong`,children:e}),`. Choose a starting point.`]}):(0,q.jsxs)(q.Fragment,{children:[`Ask about `,(0,q.jsx)(`span`,{className:`text-strong`,children:e}),` or choose a starting point.`]})}),(0,q.jsx)(wc,{onPick:e=>{Ke(e)}})]}),Dc(h,e,Ve??null,we,le,se,!!de.trim(),!l&&!r,ze),se&&de&&(0,q.jsxs)(`div`,{className:`mt-3`,children:[(0,q.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wider text-positive-400`,children:`Aero`}),(0,q.jsx)(qc,{content:de})]}),se&&!de&&le.every(e=>e.endedAt!==void 0)&&(0,q.jsx)(Jc,{}),r&&!Qe&&!se&&(0,q.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-subtle pt-3`,children:[(0,q.jsx)(`p`,{className:`text-xs text-secondary`,children:`Try another starting point.`}),(0,q.jsx)(wc,{onPick:e=>{Ke(e)}})]})]}),(pe||me)&&(0,q.jsxs)(`div`,{role:pe?`alert`:`status`,className:`mx-3 my-2 flex flex-wrap items-center gap-2 rounded-md border border-base bg-surface px-3 py-2 text-sm text-secondary`,children:[(0,q.jsx)(`span`,{className:`flex-1`,children:pe??me}),I&&!se&&(0,q.jsx)(W,{variant:`outline`,size:`sm`,onClick:()=>{we===`all`?(oe(I.prompt),Ae.current?.focus()):Ke(I.prompt,I.context)},children:we===`all`?`Review prompt`:`Retry`})]}),r&&(0,q.jsxs)(`p`,{className:`border-t border-subtle px-4 py-2 text-xs text-secondary`,children:[`Sample answers on demo data.`,` `,(0,q.jsxs)(`a`,{href:rc,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-0.5 text-positive-400 underline decoration-positive-700 hover:decoration-positive-400`,children:[`Aero answers from your own Canonry data.`,(0,q.jsx)(n,{className:`h-3 w-3`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`sr-only`,children:` (opens in a new tab)`})]})]}),(0,q.jsxs)(`div`,{className:`relative`,children:[!S&&Ne.length>0&&(0,q.jsx)(Cc,{title:r?`Starting points`:`Commands`,matches:Ne,selectedIndex:je,onHover:Me,onPick:e=>{oe(``),Ae.current?.focus(),e.action===`new`?Xe():Ke(e.prompt)}}),(0,q.jsxs)(`form`,{className:`flex items-end gap-2 border-t border-mono-800/70 bg-bg/80 px-3 py-2.5`,onSubmit:e=>{if(e.preventDefault(),Ne.length>0){let e=Ne[je];oe(``),e.action===`new`?Xe():Ke(e.prompt)}else Ke(ae)},children:[(0,q.jsx)(`textarea`,{ref:Ae,value:ae,onChange:e=>oe(e.target.value),onKeyDown:e=>{if(Ne.length>0){if(e.key===`ArrowDown`){e.preventDefault(),Me(e=>(e+1)%Ne.length);return}if(e.key===`ArrowUp`){e.preventDefault(),Me(e=>(e-1+Ne.length)%Ne.length);return}if(e.key===`Tab`){e.preventDefault();let t=Ne[je];oe(`${t.command} `);return}if(e.key===`Escape`){e.preventDefault(),oe(``);return}}if(e.key===`Enter`&&!e.shiftKey){if(e.preventDefault(),Ne.length>0){let e=Ne[je];oe(``),e.action===`new`?Xe():Ke(e.prompt)}else Ke(ae)}},disabled:S||D,placeholder:S?`Open a conversation to continue…`:r?`Type / for a starting point`:`Ask Aero, or / for commands…`,"aria-label":`Message Aero`,rows:f?3:1,className:`flex-1 resize-none overflow-y-auto bg-transparent text-sm text-heading placeholder:text-mono-600 focus:outline-none disabled:opacity-60`}),se?(0,q.jsxs)(W,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>Oe.current?.abort(),"aria-label":`Stop Aero`,children:[(0,q.jsx)(k,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),` Stop`]}):(0,q.jsx)(W,{type:`submit`,size:`sm`,disabled:!ae.trim()||S||D||A,"aria-label":`Send`,children:(0,q.jsx)(m,{className:`h-4 w-4`,"aria-hidden":`true`})})]})]})]}):(0,q.jsx)(`button`,{type:`button`,onClick:()=>{d(!0),Ge(`aero.open`)},className:`flex w-full items-center justify-between rounded-lg border border-mono-800/80 bg-bg/95 px-4 py-2 text-left text-sm text-secondary shadow-lg transition hover:border-strong hover:bg-bg-elevated/90 hover:text-strong`,children:(0,q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(N,{className:`h-4 w-4 text-positive-400`,"aria-hidden":`true`}),`Ask Aero about `,e,`…`]})})})})}function _c(e,t){return/\s/.test(t)?`Model IDs have no spaces.`:e===Nn.openrouter&&!rn.test(t)?`Use publisher/model, for example openai/gpt-6-luna.`:null}function vc({providers:e,active:t,override:n,onPick:r,modelId:i,fallbackModel:a,onModelChange:s,disabled:c}){let[u,d]=(0,K.useState)(!1),[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(``),[v,y]=(0,K.useState)(null),b=(0,K.useRef)(null),x=(0,K.useRef)(null),S=(0,K.useRef)(null),C=(0,K.useId)(),w=(0,K.useId)(),T=(0,K.useId)(),E=(0,K.useCallback)(e=>{d(!1),p(null),h(!1),y(null),e&&b.current?.focus()},[]),D=(0,K.useCallback)(()=>{let e=b.current?.getBoundingClientRect();if(!e)return;let t=window.innerHeight-e.bottom-8,n=e.top-8,r=Math.max(8,window.innerWidth-e.right);p(t>=n?{top:e.bottom+4,right:r,maxHeight:t-4}:{bottom:window.innerHeight-e.top+4,right:r,maxHeight:n-4})},[]);(0,K.useLayoutEffect)(()=>{u&&D()},[u,D]);let O=f!==null;if((0,K.useEffect)(()=>{if(!u||!O)return;let e=yc(x.current);(e.find(e=>e.getAttribute(`aria-checked`)===`true`&&e.closest(`[data-menu-group="model"]`))??e[0])?.focus()},[u,O]),(0,K.useEffect)(()=>{m&&S.current?.focus()},[m]),(0,K.useEffect)(()=>{if(!u)return;let e=e=>{let t=e.target;b.current?.contains(t)||x.current?.contains(t)||E(!1)},t=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),E(!0))};return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t,!0),window.addEventListener(`resize`,D),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t,!0),window.removeEventListener(`resize`,D)}},[u,E,D]),e.length===0)return null;let ee=e.filter(e=>e.configured),k=ee.length<e.length,A=t?.configured?t.models??[]:[],j=i.trim()||a||t?.defaultModel||``,te=A.find(e=>e.id===j)?.displayName??j,ne=!!(t?.configured&&j&&!A.some(e=>e.id===j)),re=t?t.label.replace(/\s+\(.+\)$/,``):`No provider`,ie=e=>{let t=e.target;if(e.key===`Tab`){let n=t.closest(`[data-other-model-form]`),r=t.tagName===`INPUT`;if(n&&(r&&!e.shiftKey||!r&&e.shiftKey))return;e.preventDefault(),E(!0);return}if(!t.matches(`[role^="menuitem"]`))return;let n=yc(x.current),r=n.indexOf(t),i=e.key===`ArrowDown`?n[(r+1)%n.length]:e.key===`ArrowUp`?n[(r-1+n.length)%n.length]:e.key===`Home`?n[0]:e.key===`End`?n[n.length-1]:void 0;i&&(e.preventDefault(),i.focus())},ae=()=>{if(!t)return;let e=g.trim();if(!e){y(`Enter a model ID.`);return}let n=_c(t.id,e);n?y(n):(s(e),E(!0))},M=`flex min-h-10 w-full items-center gap-2 px-3 py-2 text-left text-sm text-heading transition outline-none hover:bg-bg-elevated focus-visible:bg-bg-elevated focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-mono-400 disabled:opacity-60`,N=e=>(0,q.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center`,children:e?(0,q.jsx)(l,{className:`h-3.5 w-3.5 text-positive-400`,"aria-hidden":`true`}):null});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`button`,{ref:b,type:`button`,onClick:()=>u?E(!1):d(!0),onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),d(!0))},disabled:c,className:`flex min-h-8 min-w-0 items-center gap-1 rounded-md px-2 py-1 text-sm text-secondary transition hover:bg-surface-inset hover:text-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400 disabled:opacity-50`,"aria-haspopup":`menu`,"aria-expanded":u,"aria-controls":u?C:void 0,title:t?`${t.label} · ${j}`:`Pick a provider`,children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Aero model: `}),(0,q.jsx)(`span`,{className:`min-w-0 truncate font-medium text-strong`,children:t?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`span`,{className:`hidden sm:inline`,children:[re,` · `]}),te]}):re}),(0,q.jsx)(o,{className:`h-3 w-3 shrink-0`,"aria-hidden":`true`})]}),u&&f&&(0,Es.createPortal)((0,q.jsxs)(`div`,{ref:x,id:C,role:`menu`,"aria-label":`Aero model`,onKeyDown:ie,style:{position:`fixed`,top:f.top,bottom:f.bottom,right:f.right,maxHeight:f.maxHeight},className:`z-50 w-72 max-w-[calc(100vw-1rem)] overflow-y-auto rounded-lg border border-base bg-bg py-1 shadow-xl`,children:[(0,q.jsxs)(`div`,{role:`group`,"aria-labelledby":w,children:[(0,q.jsx)(`div`,{id:w,className:`px-3 pb-1 pt-2 text-sm font-medium text-secondary`,children:`Provider`}),ee.map(e=>{let n=t?.id===e.id;return(0,q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":n,tabIndex:-1,onClick:()=>{n||r(e.id),E(!0)},className:M,children:[N(n),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label.replace(/\s+\(.+\)$/,``)})]},e.id)}),n&&(0,q.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,onClick:()=>{r(null),E(!0)},className:`${M} text-secondary`,children:[N(!1),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Use default provider`})]}),k&&(0,q.jsxs)(B,{to:`/settings`,role:`menuitem`,tabIndex:-1,onClick:()=>E(!1),className:`${M} text-secondary`,children:[N(!1),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Connect another provider`})]})]}),t?.configured&&(0,q.jsxs)(`div`,{role:`group`,"aria-labelledby":T,"data-menu-group":`model`,className:`mt-1 border-t border-default`,children:[(0,q.jsx)(`div`,{id:T,className:`px-3 pb-1 pt-2 text-sm font-medium text-secondary`,children:`Model`}),A.map(e=>{let n=e.id===j,r=e.id===t.defaultModel;return(0,q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":n,tabIndex:-1,onClick:()=>{s(e.id),E(!0)},className:M,title:e.id,children:[N(n),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.displayName}),r&&(0,q.jsx)(`span`,{className:`shrink-0 text-sm text-secondary`,children:`Default`})]},e.id)}),ne&&(0,q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!0,tabIndex:-1,onClick:()=>E(!0),className:M,title:j,children:[N(!0),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[13px]`,children:j})]}),(0,q.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-expanded":m,tabIndex:-1,onClick:()=>{_(ne?j:``),y(null),h(e=>!e)},className:`${M} text-secondary`,children:[N(!1),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Other model…`})]}),m&&(0,q.jsxs)(`form`,{"data-other-model-form":!0,className:`px-3 pb-2 pt-1`,onSubmit:e=>{e.preventDefault(),ae()},children:[(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`input`,{ref:S,className:`setup-input min-w-0 flex-1`,"aria-label":`Other model ID`,"aria-invalid":v?!0:void 0,"aria-describedby":v?`${C}-other-error`:void 0,value:g,placeholder:t.id===Nn.openrouter?`publisher/model`:`Model ID`,autoComplete:`off`,spellCheck:!1,onChange:e=>{_(e.target.value),y(null)}}),(0,q.jsx)(W,{type:`submit`,variant:`secondary`,size:`sm`,className:`h-auto self-stretch md:h-auto`,children:`Use`})]}),v&&(0,q.jsx)(`p`,{id:`${C}-other-error`,role:`alert`,className:`mt-1.5 text-sm text-negative-400`,children:v})]}),(0,q.jsx)(`p`,{className:`px-3 pb-2 pt-1 text-sm text-secondary`,children:`Applies to Aero only.`})]})]}),document.body)]})}function yc(e){return Array.from(e?.querySelectorAll(`[role^="menuitem"]`)??[])}var bc=144,xc=288,Sc=288;function Cc({title:e,matches:t,selectedIndex:n,onHover:r,onPick:i}){let a=(0,K.useRef)(null),o=(0,K.useRef)(null),s=(0,K.useRef)(null),[c,l]=(0,K.useState)(Sc);return(0,K.useLayoutEffect)(()=>{let e=a.current,t=e?.closest(`[data-aero-panel]`),n=e?.parentElement;if(!e||!t||!n)return;let r=n.getBoundingClientRect().top-t.getBoundingClientRect().top-16-(o.current?.getBoundingClientRect().height??0);l(r>0?Math.min(Sc,Math.floor(r)):Sc)},[t.length]),(0,K.useEffect)(()=>{(s.current?.querySelector(`[aria-selected="true"]`))?.scrollIntoView?.({block:`nearest`})},[n]),(0,q.jsxs)(`div`,{ref:a,className:`absolute inset-x-3 bottom-full mb-2 overflow-hidden rounded-lg border border-base bg-bg/98 shadow-2xl`,children:[(0,q.jsx)(`div`,{ref:o,className:`border-b border-default px-3 py-1.5 text-[10px] uppercase tracking-wider text-muted`,children:e}),(0,q.jsx)(`ul`,{ref:s,role:`listbox`,className:`overflow-y-auto py-1`,style:{maxHeight:c},children:t.map((e,t)=>{let a=t===n;return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":a,onMouseEnter:()=>r(t),onClick:()=>i(e),className:`flex w-full items-center gap-3 px-3 py-2 text-left text-sm transition ${a?`bg-bg-elevated text-heading`:`text-neutral hover:bg-bg-elevated/60`}`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:e.label}),(0,q.jsx)(`span`,{className:`ml-auto font-mono text-[11px] text-secondary`,children:e.command})]})},e.command)})})]})}function wc({onPick:e}){return(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:nc.map(t=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>e(t.prompt),className:`rounded-md border border-base bg-bg-elevated/70 px-3 py-1.5 text-sm text-neutral transition hover:border-strong hover:bg-mono-800/70 hover:text-heading`,children:t.label},t.label))})}function Tc(e){switch(e){case Nn.claude:return`ANTHROPIC_API_KEY`;case Nn.openai:return`OPENAI_API_KEY`;case Nn.gemini:return`GEMINI_API_KEY`;case Nn.zai:return`ZAI_API_KEY`;case Nn.openrouter:return`OPENROUTER_API_KEY`}}function Ec(e,t){let n=e.timestamp??0;return`${e.role}:${n}:${t}`}function Dc(e,t,n,r,i,a,o,s=!0,c){let l=[],u=[],d=0;for(let t=e.length-1;t>=0;t--)if(e[t].role===`user`){d=t+1;break}let f=(e=!1)=>{u.length!==0&&(l.push((0,q.jsx)(Uc,{trails:u,betweenSteps:e&&a&&!o},`tools:${u[0].id}`)),u=[])};for(let o=0;o<e.length;o++){let p=e[o],m=Ec(p,o);if(p.role===`user`){f();let e=typeof p.content==`string`?p.content:JSON.stringify(p.content);if(e.startsWith(`[system]`))continue;l.push((0,q.jsx)(Oc,{text:e,projectName:t,providerOverride:n,modelOverride:c,scope:r,context:p.aeroContext,cliCopy:s},m))}else if(p.role===`assistant`){let t=new Map,n=o+1;for(;n<e.length&&e[n].role===`toolResult`;){let r=e[n];t.set(r.toolCallId,r),n++}let r=a&&o>=d,s=Ac(p,t).map(e=>{let t=i.find(t=>t.id===e.id),n={...e,...t,label:e.label??t?.label};return{...n,interrupted:n.endedAt===void 0&&(!r||n.interrupted)}}),c=tc(p);c.trim()&&(f(),l.push((0,q.jsxs)(`div`,{className:`mt-3`,children:[(0,q.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wider text-positive-400`,children:`Aero`}),(0,q.jsx)(qc,{content:c})]},m))),u.push(...s),o=n-1}}return f(!0),l}function Oc({text:e,projectName:t,providerOverride:n,modelOverride:r,scope:i,context:a,cliCopy:o=!0}){let[s,c]=(0,K.useState)(!1),u=(0,K.useMemo)(()=>kc(t,e,n,i,a,r),[t,e,n,i,a,r]);async function d(){try{await navigator.clipboard.writeText(u),c(!0),window.setTimeout(()=>c(!1),1500)}catch{}}return(0,q.jsxs)(`div`,{className:`group relative mt-3 rounded-md bg-bg-elevated/60 px-3 py-2 text-strong`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted`,children:`You`}),o&&(0,q.jsx)(`button`,{type:`button`,onClick:Xn(d),className:`inline-flex items-center gap-1 rounded border border-mono-800/70 bg-bg/60 px-1.5 py-0.5 text-[10px] text-secondary opacity-0 transition hover:border-strong hover:text-heading group-hover:opacity-100 focus:opacity-100`,"aria-label":`Copy as CLI command`,title:u,children:s?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(l,{className:`h-2.5 w-2.5 text-positive-400`,"aria-hidden":`true`}),`Copied`]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(h,{className:`h-2.5 w-2.5`,"aria-hidden":`true`}),`Copy as CLI`]})})]}),(0,q.jsx)(`div`,{className:`whitespace-pre-wrap`,children:e})]})}function kc(e,t,n,r,i,a){let o=[`canonry`,`agent`,`ask`,Br(e),Br(t)];return n&&o.push(`--provider`,n),a&&o.push(`--model`,Br(a)),r===`read-only`&&o.push(`--scope`,`read-only`),i&&o.push(`--context`,Br(JSON.stringify(i))),o.join(` `)}function Ac(e,t){let n=[];for(let r of e.content){if(r.type!==`toolCall`)continue;let e=r,i=t.get(e.id);n.push({id:e.id,name:e.name,args:e.arguments,label:i?.aeroToolLabel,durationMs:i?.aeroDurationMs,endedAt:i?.timestamp,isError:i?.isError,result:i?.content})}return n}var jc=new Set([`aero_list_toolkits`,`aero_load_toolkit`]),Mc=new Map([[`Read`,`Reading`],[`List`,`Listing`],[`Get`,`Getting`],[`Load`,`Loading`],[`Find`,`Finding`],[`Check`,`Checking`],[`Compare`,`Comparing`],[`Inspect`,`Inspecting`],[`Preview`,`Previewing`],[`Search`,`Searching`],[`Show`,`Showing`],[`Run`,`Running`]]);function Nc(e){return e.endedAt===void 0&&!e.interrupted}function Pc(e){return e.label??e.name.replace(/^(?:canonry|aero)_/,``).replace(/_/g,` `)}function Fc(e){let t=e.durationMs??(e.endedAt!=null&&e.startedAt!=null?e.endedAt-e.startedAt:null);return t==null||t<0?null:t}function Ic(e){let t=null;for(let n of e){let e=Fc(n);e!=null&&(t=(t??0)+e)}return t}function Lc(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Rc(e){let t=Math.floor(Math.max(0,e)/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function zc(e,t,n){return`${e} ${e===1?t:n}`}function Bc(e=``){return Mc.get(e.charAt(0).toUpperCase()+e.slice(1))}function Vc(e){let[t,...n]=e.trim().split(/\s+/),r=Bc(t);if(!r)return`Working…`;if(n[0]===`or`||n[0]===`and`){let e=Bc(n[1]);return e?`${[r,n[0],e.toLowerCase(),...n.slice(2)].join(` `)}…`:`Working…`}return`${[r,...n].join(` `)}…`}function Hc(e){let[t,n]=(0,K.useState)(()=>Date.now());return(0,K.useEffect)(()=>{if(!e)return;let t=()=>n(Date.now()),r=window.setTimeout(t,0),i=window.setInterval(t,1e3);return()=>{window.clearTimeout(r),window.clearInterval(i)}},[e]),t}function Uc({trails:e,betweenSteps:t}){let[n,r]=(0,K.useState)(!1),i=(0,K.useId)(),a=e.filter(e=>!jc.has(e.name)),o=e.filter(e=>jc.has(e.name)),s=a.filter(Nc),c=s.length>0?s[s.length-1]:void 0,u=o.some(Nc),d=c!==void 0||u||t,f=a.length>0?a:o,p=f.filter(e=>!Nc(e)&&e.isError===!0).length,m=e.some(e=>e.interrupted),h=e.flatMap(e=>e.startedAt===void 0?[]:[e.startedAt]),g=h.length>0?Math.min(...h):void 0,_=Hc(d),y=Ic(f),b=d?c?Vc(Pc(c)):u?`Loading tools…`:`Working…`:a.length>0?zc(a.length,`step`,`steps`):zc(o.length,`setup step`,`setup steps`),x=new Map;for(let e of a){let t=Pc(e),n=x.get(t);n?n.push(e):x.set(t,[e])}return(0,q.jsxs)(`div`,{className:`mt-3 rounded-md border border-mono-800/70 bg-surface-hover`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left`,"aria-expanded":n,"aria-controls":i,children:[(0,q.jsx)(`span`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center`,children:d?(0,q.jsx)(O,{className:`h-3 w-3 animate-spin text-positive-400 motion-reduce:animate-none`,"aria-hidden":`true`}):p>0?(0,q.jsx)(j,{className:`h-3 w-3 text-negative-400`,"aria-hidden":`true`}):m?(0,q.jsx)(k,{className:`h-3 w-3 text-muted`,"aria-hidden":`true`}):(0,q.jsx)(l,{className:`h-3 w-3 text-muted`,"aria-hidden":`true`})}),(0,q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-heading`,children:b}),p>0&&(0,q.jsxs)(`span`,{className:`shrink-0 rounded-md border border-negative-800/50 bg-negative-950/20 px-1.5 py-0.5 text-[10px] text-negative-400`,children:[p,` failed`]}),m&&(0,q.jsx)(`span`,{className:`shrink-0 rounded-md border border-mono-800/70 px-1.5 py-0.5 text-[10px] text-muted`,children:`interrupted`}),(0,q.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 text-[10px] text-muted`,children:[d?(0,q.jsxs)(q.Fragment,{children:[c&&(0,q.jsxs)(`span`,{children:[`step `,a.indexOf(c)+1]}),g!==void 0&&(0,q.jsx)(`span`,{className:`tabular-nums`,"aria-hidden":`true`,children:Rc(_-g)})]}):y!=null&&(0,q.jsx)(`span`,{className:`tabular-nums`,children:Lc(y)}),(0,q.jsx)(v,{className:`h-3 w-3 transition-transform ${n?`rotate-90`:``}`,"aria-hidden":`true`})]})]}),n&&(0,q.jsxs)(`div`,{id:i,className:`space-y-1.5 border-t border-default px-2.5 py-2`,children:[[...x].map(([e,t])=>(0,q.jsx)(Wc,{trails:t,title:e},`label:${e}`)),o.length>0&&(0,q.jsx)(Wc,{trails:o,title:`+ ${zc(o.length,`setup step`,`setup steps`)}`,muted:!0},`setup`)]})]})}function Wc({trails:e,title:t,muted:n=!1}){let[r,i]=(0,K.useState)(!1),a=(0,K.useId)(),o=!n&&e.length===1,s=e.some(Nc),c=e.filter(e=>!Nc(e)&&e.isError===!0).length,l=e.some(e=>e.interrupted),u=Ic(e),d=o?()=>i(!0):void 0;return(0,q.jsxs)(`div`,{className:o?void 0:n?`rounded-md`:`rounded-md border border-mono-800/70 bg-surface-hover`,onFocus:d,onClick:d,children:[!o&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left`,"aria-expanded":r,"aria-controls":a,children:[!n&&(0,q.jsx)(`span`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center`,children:s?(0,q.jsx)(O,{className:`h-3 w-3 animate-spin text-positive-400 motion-reduce:animate-none`,"aria-hidden":`true`}):c>0?(0,q.jsx)(j,{className:`h-3 w-3 text-negative-400`,"aria-hidden":`true`}):(0,q.jsx)(A,{className:`h-3 w-3 text-muted`,"aria-hidden":`true`})}),(0,q.jsx)(`span`,{className:n?`text-xs text-muted`:`text-sm font-medium text-heading`,children:t}),!n&&(0,q.jsxs)(`span`,{className:`text-[10px] text-muted`,children:[`×`,e.length]}),(0,q.jsxs)(`span`,{className:`ml-auto flex items-center gap-2 text-[10px] text-muted`,children:[s?(0,q.jsx)(`span`,{className:`text-positive-400`,children:`running…`}):(0,q.jsxs)(q.Fragment,{children:[c>0?(0,q.jsxs)(`span`,{className:`text-negative-400`,children:[c,` failed`]}):(0,q.jsx)(`span`,{children:l?`interrupted`:`done`}),u!=null&&(0,q.jsx)(`span`,{className:`tabular-nums`,children:Lc(u)})]}),(0,q.jsx)(v,{className:`h-3 w-3 transition-transform ${r?`rotate-90`:``}`,"aria-hidden":`true`})]})]}),(o||r)&&(0,q.jsx)(`div`,{id:a,className:o?void 0:`space-y-1.5 px-2.5 pb-2`,children:e.map(e=>(0,q.jsx)(Gc,{trail:e},e.id))})]})}function Gc({trail:e}){let[t,n]=(0,K.useState)(!1),r=Nc(e),i=!r&&e.isError===!0,a=Fc(e),o=a==null?null:Lc(a);return(0,q.jsxs)(`div`,{className:`rounded-md border ${i?`border-negative-800/50`:r?`border-positive-800/50`:`border-mono-800/70`} ${i?`bg-negative-950/20`:r?`bg-positive-950/20`:`bg-surface-hover`}`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left`,"aria-expanded":t,children:[(0,q.jsx)(`span`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center`,children:r?(0,q.jsx)(O,{className:`h-3 w-3 animate-spin text-positive-400`,"aria-hidden":`true`}):i?(0,q.jsx)(j,{className:`h-3 w-3 text-negative-400`,"aria-hidden":`true`}):(0,q.jsx)(A,{className:`h-3 w-3 text-muted`,"aria-hidden":`true`})}),(0,q.jsx)(`span`,{className:`text-sm font-medium text-heading`,children:Pc(e)}),(0,q.jsxs)(`span`,{className:`ml-auto flex items-center gap-2 text-[10px] text-muted`,children:[r?(0,q.jsx)(`span`,{className:`text-positive-400`,children:`running…`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{children:e.interrupted?`interrupted`:i?`failed`:`done`}),o&&(0,q.jsx)(`span`,{children:o})]}),(0,q.jsx)(v,{className:`h-3 w-3 transition-transform ${t?`rotate-90`:``}`,"aria-hidden":`true`})]})]}),t&&(0,q.jsxs)(`div`,{className:`border-t border-default px-2.5 py-2 text-[11px] text-secondary`,children:[(0,q.jsx)(`div`,{className:`mb-2 text-xs text-secondary`,children:e.name}),(0,q.jsx)(`div`,{className:`mb-1 text-xs text-secondary`,children:`Inputs`}),(0,q.jsx)(`pre`,{className:`mb-2 overflow-x-auto whitespace-pre-wrap break-all text-xs text-neutral`,children:Kc(e.args)}),!r&&e.result!==void 0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`mb-1 text-[9px] uppercase tracking-wider text-faint`,children:i?`Error`:`Result`}),(0,q.jsx)(`pre`,{className:`overflow-x-auto whitespace-pre-wrap break-all text-xs text-neutral`,children:Kc(e.result)})]})]})]})}function Kc(e){try{let t=typeof e==`string`?e:JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}\n… (${t.length-2e3} more chars)`:t}catch{return String(e)}}function qc({content:e}){return(0,q.jsx)(`div`,{className:`text-heading`,children:(0,q.jsx)(F,{remarkPlugins:[he],components:{h1:e=>(0,q.jsx)(`h1`,{...e,className:`mt-3 mb-2 text-base font-semibold text-primary`}),h2:e=>(0,q.jsx)(`h2`,{...e,className:`mt-3 mb-2 text-sm font-semibold text-primary`}),h3:e=>(0,q.jsx)(`h3`,{...e,className:`mt-3 mb-1.5 text-sm font-semibold text-heading`}),h4:e=>(0,q.jsx)(`h4`,{...e,className:`mt-2 mb-1 text-xs font-semibold uppercase tracking-wide text-neutral`}),p:e=>(0,q.jsx)(`p`,{...e,className:`mb-2 leading-relaxed`}),ul:e=>(0,q.jsx)(`ul`,{...e,className:`mb-2 ml-4 list-disc space-y-1`}),ol:e=>(0,q.jsx)(`ol`,{...e,className:`mb-2 ml-4 list-decimal space-y-1`}),li:e=>(0,q.jsx)(`li`,{...e,className:`marker:text-mono-600`}),strong:e=>(0,q.jsx)(`strong`,{...e,className:`font-semibold text-primary`}),em:e=>(0,q.jsx)(`em`,{...e,className:`text-strong`}),code:({children:e,...t})=>(0,q.jsx)(`code`,{...t,className:`rounded bg-mono-800/70 px-1 py-0.5 font-mono text-[12px] text-positive-200`,children:e}),pre:e=>(0,q.jsx)(`pre`,{...e,className:`mb-2 overflow-x-auto rounded-md border border-base bg-bg-elevated/70 p-3 font-mono text-xs text-strong`}),a:e=>(0,q.jsx)(`a`,{...e,className:`text-positive-400 underline decoration-positive-700 hover:decoration-positive-400`,target:`_blank`,rel:`noopener noreferrer`}),table:e=>(0,q.jsx)(`div`,{className:`mb-2 overflow-x-auto`,children:(0,q.jsx)(`table`,{...e,className:`w-full border-collapse text-xs`})}),thead:e=>(0,q.jsx)(`thead`,{...e,className:`border-b border-base`}),th:e=>(0,q.jsx)(`th`,{...e,className:`px-2 py-1 text-left font-semibold text-neutral`}),tr:e=>(0,q.jsx)(`tr`,{...e,className:`border-b border-mono-900`}),td:e=>(0,q.jsx)(`td`,{...e,className:`px-2 py-1 text-strong`}),blockquote:e=>(0,q.jsx)(`blockquote`,{...e,className:`mb-2 border-l-2 border-strong pl-3 italic text-secondary`}),hr:()=>(0,q.jsx)(`hr`,{className:`my-3 border-base`})},children:e})})}function Jc(){return(0,q.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-positive-400`,children:`Aero`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,"aria-label":`Aero is thinking`,children:[(0,q.jsx)(`span`,{className:`aero-dot h-1.5 w-1.5 rounded-full bg-positive-400/80`}),(0,q.jsx)(`span`,{className:`aero-dot aero-dot-2 h-1.5 w-1.5 rounded-full bg-positive-400/60`}),(0,q.jsx)(`span`,{className:`aero-dot aero-dot-3 h-1.5 w-1.5 rounded-full bg-positive-400/40`})]})]})}function Yc({isAdmin:e,account:t}){return e||t?.role===`viewer`&&In()}function Xc(){let{isAdmin:e,account:t}=Jn(),n=Te(),r=/^\/projects\/([^/]+)/.exec(n.pathname),i=r?decodeURIComponent(r[1]):null,a=R({...cr({client:U}),enabled:i!==null,staleTime:6e4}),o=Ts(n.pathname,n.search),s=a.data??[],c=s.find(e=>e.id===i)??s.find(e=>e.name===i),l=Wr(c?.name??i??``,o),u=zt(),d=u||Yc({isAdmin:e,account:t});return!i||!d||!c?null:(0,q.jsx)(gc,{projectName:c.name,context:l,preview:u},c.name)}function Zc(e,t,n){switch(e.invalidateQueries({queryKey:lr({client:U})}),e.invalidateQueries({queryKey:dr({client:U})}),nr(e,`runs`),t){case G[`answer-visibility`]:Jo(e,n,`none`),nr(e,`visibilityReport`),nr(e,`queryTracking`);return;case G[`backlink-extract`]:return;case G[`seo-sync`]:nr(e,`seo`,{projectName:n});return;case G[`site-audit`]:nr(e,`technicalAeo`);return;case G[`gsc-sync`]:case G[`inspect-sitemap`]:nr(e,`gsc`);return;case G[`ga-sync`]:nr(e,`ga`);return;case G[`traffic-sync`]:nr(e,`ga`),nr(e,`traffic`);return;case G[`bing-inspect`]:case G[`bing-inspect-sitemap`]:nr(e,`bing`);return;case G[`aeo-discover-seed`]:case G[`aeo-discover-probe`]:Jo(e,n);return;case G[`gbp-sync`]:nr(e,`gbp`);return;case G[`ads-sync`]:nr(e,`ads`);return;case G[`google-ads-sync`]:nr(e,`googleAds`),nr(e,`conversionTracking`);return;case G[`gtm-sync`]:nr(e,`gtm`),nr(e,`conversionTracking`);return;default:return t}}var Qc=[{label:`GitHub`,href:`https://github.com/Canonry/canonry`,Icon:oe},{label:`Docs`,href:`https://github.com/Canonry/canonry/tree/main/docs`,Icon:y},{label:`Changelog`,href:`https://github.com/Canonry/canonry/releases`,Icon:a}],$c=e=>({label:e,state:`checking`,detail:`Checking service health`}),el={apiStatus:$c(`API`),workerStatus:$c(`Worker`)};function tl(e){return e===`completed`?`positive`:e===`partial`?`caution`:`negative`}function nl(e){let t=ds(e.kind);return e.status===`completed`?`${t} completed`:e.status===`partial`?`${t} completed with partial results`:e.status===`cancelled`?`${t} cancelled`:`${t} failed`}function rl(e,t){return e.error?`${t}: ${Xt(e.error)}`:e.location?`${t} · ${e.location}`:t}function il(e,t,n){if(t)return t;let r=n.find(t=>t.id===e);return r?.displayName||r?.name||e}function al(e,t){return[e.completed>0?`${e.completed} completed`:null,e.partial>0?`${e.partial} partial`:null,e.failed>0?`${e.failed} failed`:null,e.cancelled>0?`${e.cancelled} cancelled`:null,t>0?`${t} skipped at queue time`:null].filter(Boolean).join(`, `)}function ol(e){return e.failed>0||e.cancelled>0?`negative`:e.partial>0?`caution`:`positive`}function sl(){let e=ge(),t=(0,K.useSyncExternalStore)(wi,Ci,Ci),n=Object.keys(t.runs).length>0||Object.keys(t.batches).length>0,r=R({...fr({client:U}),enabled:n,staleTime:Zn,refetchInterval:3e3}),i=R({...cr({client:U}),enabled:n}),a=(0,K.useRef)({}),o=(0,K.useCallback)(()=>{r.refetch()},[r.refetch]);return(0,K.useEffect)(()=>{n&&o()},[n,o]),(0,K.useEffect)(()=>{if(!n||typeof window>`u`)return;let e=()=>{document.visibilityState===`visible`&&o()};return window.addEventListener(`focus`,o),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,o),document.removeEventListener(`visibilitychange`,e)}},[n,o]),(0,K.useEffect)(()=>{let n=r.data??[],o=i.data??[],s=Object.fromEntries(n.map(e=>[e.id,e])),c=Object.fromEntries(n.map(e=>[e.id,e.status]));for(let n of Object.values(t.runs)){let t=s[n.runId];if(!t||!ki(t.status)||(a.current[t.id]??n.lastAnnouncedStatus)===t.status)continue;let r=o.find(e=>e.id===t.projectId);if(r&&Zc(e,t.kind,r.name),n.sourceAction===`run-all`){Ei(t.id);continue}let i=il(t.projectId,n.projectLabel,o);$n({title:nl(t),detail:rl(t,i),tone:tl(t.status),dedupeKey:`run:${t.id}`,dedupeMode:`replace`,cta:{label:`View run`,intent:`open-run-drawer`,runId:t.id}}),Ei(t.id)}if(r.data!==void 0){let r=new Set(n.map(e=>e.id)),i=ji(Object.values(t.runs),r,Date.now(),Ai);for(let t of i){let n=o.find(e=>e.id===t.projectId);n&&Zc(e,t.kind,n.name),t.sourceAction!==`run-all`&&$n({title:`${ds(t.kind)} status unavailable`,detail:il(t.projectId,t.projectLabel,o),tone:`neutral`,dedupeKey:`run-stale:${t.runId}`,dedupeMode:`replace`}),Ei(t.runId)}}for(let e of Object.values(t.batches)){let t=Mi(e.runIds,s);t.finished&&($n({title:`Run-all batch finished`,detail:al(t,e.skippedCount),tone:ol(t),dedupeKey:`batch:${e.batchId}`,dedupeMode:`replace`,cta:{label:`View runs`,intent:`go-to-runs`}}),Oi(e.batchId))}a.current=c},[i.data,r.data,t,e]),null}function cl(){let{account:e,isAdmin:t}=Jn(),n=Go(),r=(0,K.useMemo)(()=>It(),[]),i=(0,K.useMemo)(jt,[]),a=(0,K.useMemo)(Ot,[]),o=zt()||a&&Yc({isAdmin:t,account:e}),s=(0,K.useMemo)(dt,[]),c=Te(),{dashboard:l,isLoading:m,refetch:h}=Ko(void 0,{includeSettings:!r,includeOverviews:!1,pauseProjectPolling:c.pathname===`/setup`}),y=es(!n,n?.health).data??n?.health??el,{runId:b,evidenceId:w,closeDrawer:D}=ns(),[O,ee]=(0,K.useState)(!1),[k,A]=(0,K.useState)(()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`canonry:sidebarHidden`)===`true`}catch{return!1}}),[j,te]=(0,K.useState)(()=>{if(typeof window>`u`)return null;try{return window.localStorage.getItem(`canonry:dismissedUpdateVersion`)}catch{return null}}),[ne]=(0,K.useState)(()=>typeof window>`u`?null:new URLSearchParams(window.location.search).get(`force-update`)),re=ne?{current:y.apiStatus.version??`0.0.0`,latest:ne,url:`https://www.npmjs.com/package/@canonry/canonry`,upgradeCommand:`npm install -g @canonry/canonry`}:y.apiStatus.updateAvailable,M=s&&re&&re.latest!==j,N=()=>{if(re){try{window.localStorage.setItem(`canonry:dismissedUpdateVersion`,re.latest)}catch{}te(re.latest)}},oe=()=>{let e=!k;try{e?window.localStorage.setItem(`canonry:sidebarHidden`,`true`):window.localStorage.removeItem(`canonry:sidebarHidden`)}catch{}A(e)},le=ts(b),me=le.data??null,F=le.isLoading;(0,K.useEffect)(()=>{me&&me.status!==`running`&&me.status!==`queued`&&h()},[me?.status,h]),(0,K.useEffect)(()=>{ee(!1)},[c.pathname]),(0,K.useEffect)(()=>{if(typeof window>`u`||O||!b&&!w)return;let e=e=>{e.key===`Escape`&&D()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[b,w,D,O]);let I=l??n?.dashboard??null,he=c.pathname===`/setup`,ge=he&&I!==null&&I.portfolioOverview.projects.length===0,_e=he&&(c.search.onboarding===`site-health`||c.search.onboarding===`first-run`||c.search.onboarding===`complete`),[L,ve]=(0,K.useState)(ge);(0,K.useEffect)(()=>{he?ge&&ve(!0):ve(!1)},[ge,he]);let R=he&&(_e||ge||L||he&&I===null),ye=R?`app-shell-focus`:k?`app-shell-sidebar-hidden`:``,be=b?(I?co(I,b):void 0)??(me?Co(me,I?.projects.find(e=>e.project.id===me.projectId)?.project.displayName??I?.projects.find(e=>e.project.id===me.projectId)?.project.name??`Unknown project`):void 0):void 0,xe=(0,K.useMemo)(()=>io(c.pathname,I),[c.pathname,I]),{commandCenter:Se,evidenceLoading:Ce,evidenceError:z,isError:we,refetch:De}=Zo(w?xe:null,{evidence:!0}),Oe=(0,K.useMemo)(()=>{if(w)return uo(Se,I,w)},[w,Se,I]),ke=(()=>{let e=c.pathname;if(e===`/`)return`All projects`;if(e===`/projects`)return`Projects`;if(e===`/runs`)return`Runs`;if(e===`/history`)return`History`;if(e===`/settings`)return`Settings`;if(e===`/setup`)return`Setup`;if(e===`/agent-setup`)return`Agent setup`;if(e===`/backlinks`)return`Backlink data`;if(e===`/traffic`||e.startsWith(`/traffic/`))return`Traffic sources`;if(e.startsWith(`/projects/`)){let e=I?.projects.find(e=>e.project.name===xe);return e?.project.displayName||e?.project.name||xe||`Projects`}return`Not found`})();if(r){let e=Rr(r.projectTabs),t=!r.views||r.views.includes(Gr(c.pathname));return(0,q.jsxs)(`div`,{className:`app-shell app-shell-embed`,"data-theme":ei(r.theme),style:ti(r.theme),children:[(0,q.jsx)(`a`,{className:`skip-link`,href:`#content`,children:`Skip to content`}),(0,q.jsx)(`main`,{id:`content`,className:`page-shell`,children:e?(0,q.jsx)(`div`,{className:`embed-view-unavailable`,role:`status`,children:`This embed uses the retired Report tab. Update its allowed tabs to show AI Visibility.`}):t?(0,q.jsx)(Ee,{}):(0,q.jsx)(`div`,{className:`embed-view-unavailable`,role:`status`,children:`This view is not available in embed mode.`})})]})}let Ae=(0,q.jsxs)(`footer`,{className:`footer`,children:[(0,q.jsxs)(`span`,{className:`footer-brand`,children:[(0,q.jsx)(`span`,{children:(0,q.jsx)(`a`,{href:`https://canonry.ai`,children:`Canonry`})}),y.apiStatus.version&&y.apiStatus.version!==`unknown`?(0,q.jsxs)(`span`,{className:`footer-version`,children:[`v`,y.apiStatus.version]}):null]}),i?(0,q.jsx)(`div`,{className:`footer-links`,children:Qc.map(({label:e,href:t,Icon:n})=>(0,q.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,title:e,"aria-label":e,className:`footer-icon`,children:(0,q.jsx)(n,{className:`size-3.5`})},t))}):null]});return(0,q.jsxs)(P,{open:O,onOpenChange:ee,children:[(0,q.jsx)(`a`,{className:`skip-link`,href:`#content`,children:`Skip to content`}),(0,q.jsx)(us,{}),(0,q.jsxs)(`div`,{className:`app-shell ${ye}${jn()?` app-shell-demo`:``}`,children:[!R&&!k&&(0,q.jsxs)(`aside`,{id:`desktop-sidebar`,className:`sidebar`,"aria-label":`Primary navigation`,children:[(0,q.jsx)(`div`,{className:`sidebar-brand`,children:(0,q.jsx)(Pi,{version:y.apiStatus.version,updateAvailable:M?re:null,onDismissUpdate:N})}),(0,q.jsxs)(`nav`,{className:`sidebar-nav`,children:[(0,q.jsxs)(B,{to:`/`,className:`sidebar-link`,activeProps:{className:`sidebar-link sidebar-link-active`},activeOptions:{exact:!0},children:[(0,q.jsx)(d,{className:`sidebar-icon`}),(0,q.jsx)(`span`,{children:`All projects`})]}),(0,q.jsxs)(B,{to:`/projects`,className:`sidebar-link`,activeProps:{className:`sidebar-link sidebar-link-active`},activeOptions:{exact:!1},children:[(0,q.jsx)(p,{className:`sidebar-icon`}),(0,q.jsx)(`span`,{children:`Projects`})]}),(0,q.jsxs)(B,{to:`/runs`,className:`sidebar-link`,activeProps:{className:`sidebar-link sidebar-link-active`},activeOptions:{exact:!0},children:[(0,q.jsx)(g,{className:`sidebar-icon`}),(0,q.jsx)(`span`,{children:`Runs`})]}),(0,q.jsxs)(B,{to:`/history`,className:`sidebar-link`,activeProps:{className:`sidebar-link sidebar-link-active`},activeOptions:{exact:!0},children:[(0,q.jsx)(E,{className:`sidebar-icon`}),(0,q.jsx)(`span`,{children:`History`})]}),(0,q.jsxs)(B,{to:`/traffic`,className:`sidebar-link`,activeProps:{className:`sidebar-link sidebar-link-active`},activeOptions:{exact:!1},children:[(0,q.jsx)(S,{className:`sidebar-icon`}),(0,q.jsx)(`span`,{children:`Traffic sources`})]}),!jn()&&(0,q.jsxs)(B,{to:`/backlinks`,className:`sidebar-link`,activeProps:{className:`sidebar-link sidebar-link-active`},activeOptions:{exact:!0},children:[(0,q.jsx)(u,{className:`sidebar-icon`}),(0,q.jsx)(`span`,{children:`Backlink data`})]}),!jn()&&(0,q.jsxs)(B,{to:`/agent-setup`,className:`sidebar-link`,activeProps:{className:`sidebar-link sidebar-link-active`},activeOptions:{exact:!0},children:[(0,q.jsx)(C,{className:`sidebar-icon`}),(0,q.jsx)(`span`,{children:`Agent setup`})]}),t&&(0,q.jsxs)(B,{to:`/settings`,className:`sidebar-link`,activeProps:{className:`sidebar-link sidebar-link-active`},activeOptions:{exact:!0},children:[(0,q.jsx)(T,{className:`sidebar-icon`}),(0,q.jsx)(`span`,{children:`Settings`})]}),m?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`sidebar-section-title`,children:`Tracked projects`}),[1,2,3].map(e=>(0,q.jsxs)(`div`,{className:`sidebar-skeleton-item`,children:[(0,q.jsx)(`span`,{className:`skeleton-circle size-2`}),(0,q.jsx)(`span`,{className:`skeleton-text flex-1`,style:{width:`${50+e*15}%`}})]},e))]}):I&&I.projects.length>0?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`sidebar-section-title`,children:`Tracked projects`}),I.projects.map(e=>{let t=e.visibilitySummary.tone;return(0,q.jsxs)(B,{to:`/projects/$projectName`,params:{projectName:e.project.name},className:`sidebar-project`,activeProps:{className:`sidebar-project sidebar-project-active`},children:[(0,q.jsx)(`span`,{className:`sidebar-dot sidebar-dot-${t}`}),(0,q.jsx)(`span`,{children:e.project.displayName||e.project.name})]},e.project.id)})]}):m?null:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`sidebar-section-title`,children:`Resources`}),t&&(0,q.jsxs)(B,{to:`/setup`,className:`sidebar-link`,activeProps:{className:`sidebar-link sidebar-link-active`},activeOptions:{exact:!0},children:[(0,q.jsx)(x,{className:`sidebar-icon`}),(0,q.jsx)(`span`,{children:`Setup`})]})]})]}),e&&(0,q.jsxs)(`div`,{className:`sidebar-account`,children:[(0,q.jsxs)(`div`,{className:`sidebar-account-identity`,children:[(0,q.jsx)(`span`,{className:`sidebar-account-name`,children:e.name}),e.role===`viewer`?(0,q.jsx)(`span`,{className:`sidebar-account-role`,children:Fn()}):null]}),(0,q.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:Xn(async()=>{await Ut(),window.location.reload()}),children:`Sign out`})]}),Ae]}),(0,q.jsxs)(`div`,{className:`main-area ${o&&xe?`main-area-agent-bar`:``}`.trim(),children:[(0,q.jsxs)(`header`,{className:`topbar`,children:[(0,q.jsxs)(`div`,{className:`topbar-left`,children:[!R&&(0,q.jsx)(W,{className:`sidebar-privacy-toggle`,variant:`ghost`,size:`icon`,type:`button`,"aria-label":k?`Show sidebar`:`Hide sidebar`,"aria-controls":k?void 0:`desktop-sidebar`,"aria-expanded":!k,title:k?`Show sidebar`:`Hide sidebar`,onClick:oe,children:k?(0,q.jsx)(ae,{className:`size-4`}):(0,q.jsx)(_,{className:`size-4`})}),(0,q.jsx)(`div`,{className:`topbar-brand-mobile`,children:(0,q.jsx)(Pi,{compact:!0})}),(0,q.jsxs)(`nav`,{className:`breadcrumb`,"aria-label":`Breadcrumb`,children:[(0,q.jsx)(B,{to:`/`,children:`Home`}),(0,q.jsx)(v,{className:`breadcrumb-sep size-3`}),(0,q.jsx)(`span`,{className:`breadcrumb-current`,children:ke})]})]}),(0,q.jsxs)(`div`,{className:`topbar-actions`,children:[(0,q.jsx)(ps,{}),(0,q.jsxs)(`div`,{className:`health-pill-row`,children:[(0,q.jsxs)(`span`,{className:`health-pill health-pill-${y.apiStatus.state}`,title:li(y.apiStatus),children:[`API `,y.apiStatus.state===`ok`?`ok`:y.apiStatus.state]}),(0,q.jsx)(`span`,{className:`health-pill health-pill-${y.workerStatus.state}`,title:li(y.workerStatus),children:`Worker ${y.workerStatus.state===`ok`?`ok`:y.workerStatus.state}`})]}),R?null:(0,q.jsx)(ce,{asChild:!0,children:(0,q.jsxs)(W,{className:`nav-toggle`,variant:`secondary`,size:`icon`,type:`button`,children:[(0,q.jsx)(f,{className:`size-4`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Open navigation`})]})})]})]}),R?null:(0,q.jsxs)(de,{children:[(0,q.jsx)(se,{className:`fixed inset-0 z-40`}),(0,q.jsxs)(fe,{className:`mobile-nav mobile-nav-open`,"aria-describedby":void 0,children:[(0,q.jsx)(pe,{className:`sr-only`,children:`Navigation`}),(0,q.jsx)(ue,{asChild:!0,children:(0,q.jsxs)(W,{className:`mobile-nav-close`,variant:`ghost`,size:`icon`,type:`button`,children:[(0,q.jsx)(ie,{className:`size-5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Close navigation`})]})}),(0,q.jsx)(B,{to:`/`,className:`mobile-nav-link`,activeProps:{className:`mobile-nav-link mobile-nav-link-active`},activeOptions:{exact:!0},children:`All projects`}),(0,q.jsx)(B,{to:`/projects`,className:`mobile-nav-link`,activeProps:{className:`mobile-nav-link mobile-nav-link-active`},activeOptions:{exact:!1},children:`Projects`}),(0,q.jsx)(B,{to:`/runs`,className:`mobile-nav-link`,activeProps:{className:`mobile-nav-link mobile-nav-link-active`},activeOptions:{exact:!0},children:`Runs`}),(0,q.jsx)(B,{to:`/history`,className:`mobile-nav-link`,activeProps:{className:`mobile-nav-link mobile-nav-link-active`},activeOptions:{exact:!0},children:`History`}),(0,q.jsx)(B,{to:`/traffic`,className:`mobile-nav-link`,activeProps:{className:`mobile-nav-link mobile-nav-link-active`},activeOptions:{exact:!1},children:`Traffic sources`}),!jn()&&(0,q.jsx)(B,{to:`/backlinks`,className:`mobile-nav-link`,activeProps:{className:`mobile-nav-link mobile-nav-link-active`},activeOptions:{exact:!0},children:`Backlink data`}),!jn()&&(0,q.jsx)(B,{to:`/agent-setup`,className:`mobile-nav-link`,activeProps:{className:`mobile-nav-link mobile-nav-link-active`},activeOptions:{exact:!0},children:`Agent setup`}),t&&(0,q.jsx)(B,{to:`/settings`,className:`mobile-nav-link`,activeProps:{className:`mobile-nav-link mobile-nav-link-active`},activeOptions:{exact:!0},children:`Settings`}),I&&I.projects.length>0?(0,q.jsxs)(`div`,{className:`mobile-nav-section`,children:[(0,q.jsx)(`p`,{className:`mobile-nav-section-title`,children:`Tracked projects`}),I.projects.map(e=>(0,q.jsx)(B,{to:`/projects/$projectName`,params:{projectName:e.project.name},className:`mobile-nav-link`,children:e.project.name},e.project.id))]}):null,e&&(0,q.jsxs)(`div`,{className:`mobile-nav-section`,children:[(0,q.jsx)(`p`,{className:`mobile-nav-section-title`,children:`Signed in`}),(0,q.jsxs)(`div`,{className:`sidebar-account`,children:[(0,q.jsxs)(`div`,{className:`sidebar-account-identity`,children:[(0,q.jsx)(`span`,{className:`sidebar-account-name`,children:e.name}),e.role===`viewer`?(0,q.jsx)(`span`,{className:`sidebar-account-role`,children:Fn()}):null]}),(0,q.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`mobile-sign-out`,onClick:Xn(async()=>{await Ut(),window.location.reload()}),children:`Sign out`})]})]}),Ae]})]}),(0,q.jsx)(`main`,{id:`content`,className:`page-shell`,children:m&&!n?(0,q.jsxs)(`div`,{className:`page-skeleton`,children:[(0,q.jsxs)(`div`,{className:`page-skeleton-header`,children:[(0,q.jsx)(`div`,{className:`skeleton-text h-6 w-40`}),(0,q.jsx)(`div`,{className:`skeleton-text-sm w-72`})]}),(0,q.jsx)(`div`,{className:`page-skeleton-grid`,children:[1,2,3].map(e=>(0,q.jsxs)(`div`,{className:`page-skeleton-card`,children:[(0,q.jsx)(`div`,{className:`skeleton-text w-24`}),(0,q.jsx)(`div`,{className:`skeleton-text w-full`}),(0,q.jsx)(`div`,{className:`skeleton-text-sm w-3/4`})]},e))}),(0,q.jsx)(`div`,{className:`page-skeleton-grid`,style:{gridTemplateColumns:`1fr 1fr`},children:[1,2].map(e=>(0,q.jsxs)(`div`,{className:`page-skeleton-card`,children:[(0,q.jsx)(`div`,{className:`skeleton-text w-20`}),(0,q.jsx)(`div`,{className:`space-y-2`,children:[1,2,3].map(e=>(0,q.jsx)(`div`,{className:`skeleton-text-sm w-full`},e))})]},e))})]}):(0,q.jsx)(Ee,{})})]}),b&&!be&&F?(0,q.jsx)(Wa,{open:!0,title:`Loading run details`,subtitle:`Fetching the durable run record`,onClose:D,children:(0,q.jsx)(`p`,{className:`text-sm text-muted`,role:`status`,children:`Loading run details…`})}):null,b&&!be&&le.isError?(0,q.jsx)(Wa,{open:!0,title:`Run unavailable`,subtitle:`The run could not be loaded`,onClose:D,children:(0,q.jsx)(`p`,{className:`text-sm text-negative`,children:le.error instanceof Error?le.error.message:`Run details are unavailable.`})}):null,be?(0,q.jsxs)(Wa,{open:!0,title:be.summary,subtitle:`${be.projectName} \u00b7 ${be.kindLabel}`,onClose:D,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-5 gap-y-1 text-sm`,children:[(0,q.jsx)(Na,{status:be.status}),(0,q.jsx)(`span`,{className:`text-secondary`,children:be.startedAt}),(0,q.jsx)(`span`,{className:`text-muted`,children:be.duration}),(0,q.jsx)(`span`,{className:`text-faint`,children:be.triggerLabel})]}),be.status===`failed`&&be.statusDetail&&(0,q.jsx)(`p`,{className:`mt-2 text-sm text-negative`,children:be.statusDetail}),(0,q.jsxs)(`div`,{className:`mt-4`,children:[(0,q.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted mb-2`,children:`Activity Log`}),F?(0,q.jsx)(`p`,{className:`text-sm text-muted`,children:`Loading run details...`}):me?.snapshots&&me.snapshots.length>0?(0,q.jsxs)(`div`,{className:`space-y-2`,children:[me.snapshots.map(e=>(0,q.jsxs)(`div`,{className:`rounded-lg border border-default bg-surface p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-strong truncate`,children:e.query??`Unknown query`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(Ma,{provider:e.provider}),(0,q.jsx)(ln,{variant:e.citationState===V.cited?`success`:`neutral`,children:e.citationState})]})]}),e.model&&(0,q.jsx)(`p`,{className:`text-[11px] text-muted font-mono`,children:e.model}),e.citedDomains.length>0&&(0,q.jsxs)(`p`,{className:`text-xs text-muted mt-1`,children:[(0,q.jsx)(`span`,{className:`text-secondary`,children:`Sources:`}),` `,e.citedDomains.join(`, `)]}),e.citedCompetitorDomains.length>0&&(0,q.jsxs)(`p`,{className:`text-xs text-negative-400/80 mt-0.5`,children:[`Competitor cited: `,e.citedCompetitorDomains.join(`, `)]}),e.mentionedCompetitorDomains.length>0&&(0,q.jsxs)(`p`,{className:`text-xs text-negative-400/80 mt-0.5`,children:[`Competitor mentioned: `,e.mentionedCompetitorDomains.join(`, `)]}),e.groundingSources&&e.groundingSources.length>0&&(0,q.jsxs)(`details`,{className:`mt-2`,children:[(0,q.jsxs)(`summary`,{className:`text-xs text-muted cursor-pointer hover:text-secondary`,children:[e.groundingSources.length,` grounding source`,e.groundingSources.length===1?``:`s`]}),(0,q.jsx)(`ul`,{className:`mt-2 space-y-3`,children:e.groundingSources.map((e,t)=>(0,q.jsx)(`li`,{className:`min-w-0`,children:(0,q.jsx)(qa,{url:e.uri,title:e.title})},t))})]}),e.answerText&&(0,q.jsxs)(`details`,{className:`mt-1`,children:[(0,q.jsx)(`summary`,{className:`text-xs text-muted cursor-pointer hover:text-secondary`,children:`Answer preview`}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-secondary leading-relaxed whitespace-pre-wrap`,children:e.answerText})]})]},e.id)),me.status===`running`&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2 p-3 text-sm text-muted`,children:[(0,q.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-caution-500 animate-pulse`}),`Running remaining queries...`]})]}):me&&me.status===H.running?(0,q.jsxs)(`div`,{className:`flex items-center gap-2 p-3 text-sm text-muted`,children:[(0,q.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-caution-500 animate-pulse`}),me.kind===G[`answer-visibility`]?`Waiting for first query result...`:`Run is in progress...`]}):me&&me.status===H.queued?(0,q.jsxs)(`div`,{className:`flex items-center gap-2 p-3 text-sm text-muted`,children:[(0,q.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-mono-500 animate-pulse`}),`Run queued, waiting for execution slot...`]}):me&&me.error?(0,q.jsxs)(`div`,{className:`rounded-lg border border-negative-800/40 bg-negative-950/20 p-3`,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-negative mb-2`,children:`Run failed`}),(0,q.jsx)(`pre`,{className:`max-h-48 overflow-y-auto whitespace-pre-wrap break-words font-mono text-xs leading-5 text-negative`,children:Un(me.error)})]}):be.kind===G[`answer-visibility`]?(0,q.jsx)(`p`,{className:`text-sm text-muted`,children:`No snapshot data available.`}):(0,q.jsx)(`p`,{className:`text-sm text-secondary`,children:be.status===H.completed?`Run completed.`:be.status===H.partial?`Run completed with partial results.`:be.status===H.cancelled?`Run cancelled.`:be.status===H.failed?`Run failed.`:`No run details available.`})]})]}):null,w&&!Oe?(0,q.jsx)(Wa,{open:!0,title:Ce?`Loading answer`:`Answer unavailable`,subtitle:`Query evidence`,onClose:D,children:Ce?(0,q.jsx)(`p`,{role:`status`,className:`text-sm text-secondary`,children:`Loading answer…`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-secondary`,children:z||we?`Could not load this answer.`:`This answer is not in the available query evidence.`}),(0,q.jsx)(W,{type:`button`,variant:`outline`,onClick:()=>{De()},children:`Retry`})]})}):null,Oe?(0,q.jsx)(to,{evidence:Oe.evidence,project:Oe.project,onClose:D}):null,(0,q.jsx)(sl,{}),(0,q.jsx)(as,{}),o?(0,q.jsx)(Xc,{}):null]})]})}var ll=class extends K.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary]`,e,t.componentStack),ht({kind:`render`,error:e,component:this.props.name??`root`})}handleReset=()=>{this.setState({error:null})};render(){return this.state.error?(0,q.jsx)(`div`,{className:`page-container`,children:(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 py-20 text-center`,children:[(0,q.jsx)(`div`,{className:`rounded-full bg-negative-950/40 p-3`,children:(0,q.jsx)(j,{className:`size-6 text-negative-400`})}),(0,q.jsx)(`h2`,{className:`text-lg font-semibold text-heading`,children:`Something went wrong`}),(0,q.jsx)(`p`,{className:`text-sm text-secondary max-w-md`,children:this.state.error.message||`An unexpected error occurred while rendering this page.`}),(0,q.jsxs)(`div`,{className:`flex gap-3 mt-2`,children:[(0,q.jsxs)(W,{variant:`secondary`,size:`sm`,onClick:this.handleReset,children:[(0,q.jsx)(D,{className:`size-3.5 mr-1.5`}),`Try again`]}),(0,q.jsx)(W,{variant:`secondary`,size:`sm`,onClick:()=>{let e=window.__CANONRY_CONFIG__?.basePath?.replace(/\/$/,``)??``;window.location.href=e||`/`},children:`Go home`})]})]})}):this.props.children}};function ul({disabled:e,title:t,...n}){let{canWrite:r}=Jn();return r?(0,q.jsx)(W,{disabled:e,title:t,...n}):(0,q.jsx)(W,{...n,disabled:!0,title:qn})}function dl({title:e,children:t}){let{isAdmin:n}=Jn();return n?(0,q.jsx)(q.Fragment,{children:t}):(0,q.jsxs)(Ar,{className:`surface-card mx-auto mt-8 max-w-lg`,children:[(0,q.jsxs)(Dr,{children:[(0,q.jsxs)(Er,{children:[e,` is for administrators`]}),(0,q.jsx)(kr,{children:`Your account has view-only access. You can read everything this install has measured; changing how it is set up needs an administrator account.`})]}),(0,q.jsx)(Or,{children:(0,q.jsx)(`p`,{className:`supporting-copy`,children:`If you need to make a change here, ask an administrator on this install.`})})]})}function fl(e,t,n){return{mode:t,scope:e.measurementScope,scopeKey:e.measurementScopeKey,marketKey:e.marketKey,queryClass:e.queryClass===`non-brand`?`non-brand`:`branded`,provider:e.provider,model:e.model,location:e.location,runId:e.measurementRunId,revision:e.revision,evaluationDefinitionId:n}}function pl(e,t,n){let r=[...new Set(t.filter(e=>!n||e.provider===n).map(e=>e.sourceRunId).filter(e=>!!e))].sort();return{...e,mode:`simple`,scope:`project`,scopeKey:void 0,marketKey:void 0,provider:n||void 0,model:void 0,revision:void 0,runId:r.length===1?r[0]:void 0,runIds:r.length>1?r:void 0}}function ml(e,t,n,r){return[`sentiment`,e,t,n??null,r??null]}var hl=5e3,gl=new Set([`pending`,`running`,`waiting-to-retry`]);function _l(e){return gl.has(e.state)}function vl(e){let t=e?.coverage.counts;return!!(t&&t.pending+t.running+t[`waiting-to-retry`]>0)}function yl(e,t){return vl(e)||t?hl:!1}function bl(e,t,n=!0){let r=R({queryKey:ml(e,`settings`),queryFn:()=>Ae(e),retry:!1,staleTime:0,refetchOnWindowFocus:`always`}),i=R({queryKey:ml(e,`jobs`),queryFn:()=>ut(e),enabled:!!r.data?.actions.configure,retry:!1,refetchOnWindowFocus:`always`,refetchInterval:e=>e.state.data?.jobs.some(_l)?hl:!1}),a=!!i.data?.jobs.some(_l),o=i=>{let o={...t,queryClass:i};return{queryKey:ml(e,`summary`,o),queryFn:()=>Et(e,o),enabled:n&&!!(r.data?.enabled&&r.data.installEnabled),retry:!1,staleTime:0,refetchOnWindowFocus:`always`,refetchInterval:e=>yl(e.state.data,a)}};return{settings:r,branded:R(o(`branded`)),nonBrand:R(o(`non-brand`)),jobs:i}}var xl={branded:`Branded`,"non-brand":`Non-brand`};function Sl(e){return e>=10}var Z={states:{disabled:`Sentiment is off.`,"not-measured":`No ratings yet.`,processing:`Analyzing sentiment…`,canceled:`Analysis canceled.`,partial:`Partial results.`,failed:`Analysis failed.`,complete:`Analysis complete.`,unsupported:`Sentiment unavailable.`},noJudgments:`No ratings available.`,tooFew:`too few`,minRated:`Shown from 10 ratings`,partial:`Partial results`,columns:{favorable:`Favorable`,rated:`With opinion`},title:`Sentiment`,subtitle:`How AI answers describe you in queries that name you`,rated:`Share of answers that give an opinion (favorable, mixed or unfavorable) about who they name`,noAnswers:`No answers yet`,ratedUnavailable:`Unavailable`,details:{ratedAnswers:`Answers with an opinion`,unadmitted:`Checks not yet analyzed`,checksCaption:`Not counted in the favorable share:`,interval:`Likely range (95%)`},nonBrand:{label:`Non-brand queries`,none:`No unfavorable or mixed answers in non-brand queries.`,noneSoFar:`No unfavorable or mixed answers in non-brand queries so far.`,notRated:`Non-brand answers are not rated yet.`,view:`View answers`,evidence:`Non-brand queries, unfavorable and mixed`,rowNone:`No unfavorable or mixed answers`,rowLabel:`Unfavorable or mixed`,help:`A non-brand answer almost always names you to recommend you, so its favorable share is near 100% and says little. Sentiment is measured on branded queries; unfavorable or mixed answers to non-brand queries are listed here when they happen.`},properties:{title:`Most criticized properties`,evidence:`unfavorable and mixed`,viewAll:`View all unfavorable and mixed answers`,allEvidence:`Branded queries, unfavorable and mixed`},overall:`Favorable share of ratings in answers to branded queries. Each saved answer-subject assessment counts once. Answers with no opinion, or where it is unclear who they name, are left out.`,favorable:`The favorable share of favorable, mixed and unfavorable ratings in answers to branded queries. Each rating covers one subject named in an answer; answers with no opinion are left out.`},Cl=`—`,wl={factual:`Named, no opinion`,"subject-not-mentioned":`Not named in the answer`,"wrong-subject":`Named someone else`,"ambiguous-subject":`Unclear which one was meant`,"ambiguous-judgment":`Opinion unclear`,"subject-not-applicable":`Not applicable`,"unsupported-language":`Not in English`,"missing-source-text":`No answer text`,"input-too-large":`Answer too long to rate`,"invalid-conclusion-evidence":`Rating set aside`,pending:`Waiting to be rated`,running:`Being rated`,"waiting-to-retry":`Retrying`};function Tl(e){return wl[e]??e.replaceAll(`-`,` `).replace(/^./,e=>e.toUpperCase())}var El=[`favorable`,`mixed`,`unfavorable`];function Dl(e){return e===`favorable`?`positive`:e===`unfavorable`?`negative`:e===`mixed`?`caution`:`neutral`}var Ol=[`mixed`,`unfavorable`];function kl(e){return e.interval?`${pt(e.interval.low,Kt.fraction)} to ${pt(e.interval.high,Kt.fraction)}`:null}var Al={favorable:`progress-fill-info`,mixed:`progress-fill-caution`,unfavorable:`progress-fill-negative`};function jl(e){return`${e} ${e===1?`rating`:`ratings`}`}function Ml(e){return e.score.favorableRate!==null&&e.coverage.judged>0}function Nl(e){return e.state===`complete`&&!e.provisional&&e.coverage.unadmittedAssessments===0}function Pl(e){return e.state===`complete`?Z.partial:Z.states[e.state]}function Fl(e){return e?Ml(e)&&Sl(e.coverage.judged):!1}function Il({value:e,label:t}){let{counts:n,judged:r}=e.coverage;if(!Ml(e))return(0,q.jsx)(`div`,{className:`sentiment-bar sentiment-bar-track`,"data-sentiment-bar":`empty`,"aria-hidden":`true`});let i=El.map(e=>`${n[e]} ${e}`).join(`, `);return Fl(e)?(0,q.jsx)(`div`,{role:`img`,"aria-label":`${t}: ${i}, ${e.score.favorableDisplay} favorable of ${jl(r)}`,className:`sentiment-bar`,"data-sentiment-bar":`rated`,children:El.filter(e=>n[e]>0).map(e=>(0,q.jsx)(`span`,{"data-outcome":e,className:`sentiment-bar-segment ${Al[e]}`,style:{flexGrow:n[e]},title:`${Tl(e)}: ${n[e]} of ${jl(r)}`},e))}):(0,q.jsx)(`div`,{role:`img`,"aria-label":`${t}: ${i}, ${jl(r)}, favorable share ${Z.minRated.toLowerCase()}`,className:`sentiment-bar sentiment-bar-track`,"data-sentiment-bar":`too-few`})}function Ll({value:e,label:t}){let{counts:n,judged:r}=e.coverage;return(0,q.jsx)(`div`,{role:`img`,"aria-label":`${t}: ${El.map(e=>`${n[e]} ${e}`).join(`, `)}, ${jl(r)}`,className:`sentiment-property-bar`,children:El.filter(e=>n[e]>0).map(e=>(0,q.jsx)(`span`,{"data-outcome":e,className:`sentiment-bar-segment ${Al[e]}`,style:{flexGrow:n[e]}},e))})}function Rl(e){let t=new Map(e.breakdowns.filter(e=>e.dimension===`property`).map(e=>[e.key,e]));return(e.criticizedProperties?.keys??[]).flatMap(e=>t.get(e)??[])}function zl({value:e,label:t}){return(0,q.jsx)(`div`,{role:`group`,"aria-label":`${t} favorable share`,className:`sentiment-class-favorable`,children:Fl(e)?(0,q.jsx)(`span`,{className:`sentiment-class-share`,children:e.score.favorableDisplay}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`sentiment-class-empty`,title:Z.minRated,children:Cl}),(0,q.jsx)(`span`,{className:`sr-only`,children:Z.minRated})]})})}function Bl({ratedAnswers:e=0,eligibleAnswers:t=0}){return`${e} of ${t} ${t===1?`answer`:`answers`} rated`}function Vl(e){let{eligibleAnswers:t}=e;return t===void 0?{display:Cl,detail:Z.ratedUnavailable,empty:!0}:t<=0?{display:Cl,detail:Z.noAnswers,empty:!0}:e.ratedAnswerRate===null||e.ratedAnswerRate===void 0?{display:Cl,detail:Z.states.disabled,empty:!0}:{display:pt(e.ratedAnswerRate,Kt.fraction),detail:Bl(e),empty:!1}}function Hl({coverage:e,label:t}){let{display:n,detail:r,empty:i}=Vl(e);return(0,q.jsxs)(`div`,{role:`group`,"aria-label":`${t} share rated`,className:`sentiment-class-ratings`,children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:i?`sentiment-class-empty`:void 0,title:r,children:n}),(0,q.jsx)(`span`,{className:`sr-only`,children:i?r:`${n}, ${r}`})]})}function Ul({value:e}){return Ml(e)?e.provisional?(0,q.jsx)(`p`,{className:`sentiment-class-note text-caution`,children:Z.partial}):null:(0,q.jsx)(`p`,{className:`sentiment-class-note`,children:e.state===`complete`?Z.noJudgments:Z.states[e.state]})}function Wl(e){return!!(e.coverage.selected||e.coverage.eligibleAssessments||e.reason)}function Gl({value:e,queryClass:t,open:n,setOpenClass:r}){let i=(0,K.useContext)(Jl),a=(0,K.useId)(),s=(0,K.useId)(),c=(0,K.useId)(),l=(0,K.useRef)(null),u=(0,K.useRef)(null),d=(0,K.useCallback)(()=>r(e=>e===t?null:e),[r,t]);(0,K.useEffect)(()=>{if(!n)return;let e=e=>e instanceof Node&&!!(l.current?.contains(e)||u.current?.contains(e)),t=t=>{e(t.target)||d()},r=t=>{e(t.target)||d()},i=e=>{e.key===`Escape`&&(d(),l.current?.focus())};return document.addEventListener(`pointerdown`,t),document.addEventListener(`focusin`,r),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`pointerdown`,t),document.removeEventListener(`focusin`,r),document.removeEventListener(`keydown`,i)}},[n,d]);let{coverage:f,score:p}=e,m=kl(p),h=f.judged>0&&!Sl(f.judged),g=t===`branded`?Rl(e):[];return Wl(e)?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{ref:l,type:`button`,className:`sentiment-class-details-toggle`,"aria-label":`${xl[t]} details`,"aria-expanded":n,"aria-controls":a,onClick:()=>r(e=>e===t?null:t),children:(0,q.jsx)(o,{className:`sentiment-class-details-chevron`,"aria-hidden":`true`})}),(0,q.jsxs)(`div`,{ref:u,id:a,role:`group`,"aria-labelledby":s,className:`sentiment-class-details`,hidden:!n,children:[(0,q.jsx)(`p`,{id:s,className:`sentiment-class-details-title`,children:xl[t]}),(0,q.jsxs)(`dl`,{className:`sentiment-details-list`,children:[(f.eligibleAnswers??0)>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{children:Z.details.ratedAnswers}),(0,q.jsxs)(`dd`,{children:[f.ratedAnswers??0,` of `,f.eligibleAnswers]})]}),h&&El.filter(e=>f.counts[e]>0).map(e=>(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{children:Tl(e)}),(0,q.jsx)(`dd`,{children:f.counts[e]})]},e)),h&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{children:`Favorable share`}),(0,q.jsx)(`dd`,{children:Z.minRated})]}),m&&(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`dt`,{children:[Z.details.interval,` `,(0,q.jsx)(Tr,{text:p.limitation,placement:`bottom`})]}),(0,q.jsx)(`dd`,{children:m})]})]}),i&&g.length>0&&(0,q.jsxs)(`div`,{className:`sentiment-details-properties`,role:`group`,"aria-labelledby":c,children:[(0,q.jsxs)(`p`,{id:c,className:`sentiment-details-subtitle`,children:[Z.properties.title,e.criticizedProperties&&e.criticizedProperties.total>g.length?(0,q.jsxs)(`span`,{className:`sentiment-details-subtitle-count`,children:[` · `,g.length,` of `,e.criticizedProperties.total]}):null]}),(0,q.jsx)(`ul`,{children:g.map(n=>(0,q.jsxs)(`li`,{className:`sentiment-property`,children:[(0,q.jsx)(`button`,{type:`button`,className:`sentiment-property-name`,"aria-label":`View ${Z.properties.evidence} answers for ${n.label}`,onClick:()=>{if(!l.current)return;let r=Yl(i,e);i.openEvidence({...r,queryClass:t,scope:`property`,scopeKey:n.key,marketKey:r.scope===`market`?r.scopeKey:r.marketKey,outcome:Ol},`${n.label}, ${Z.properties.evidence}`,l.current)},children:n.label}),(0,q.jsxs)(`span`,{className:`sentiment-property-count`,children:[n.coverage.counts.favorable,` of `,n.coverage.judged,` favorable`]}),(0,q.jsx)(Ll,{value:n,label:n.label})]},n.key))}),(0,q.jsx)(`button`,{type:`button`,className:`sentiment-property-name sentiment-details-view-all`,onClick:()=>{l.current&&i.openEvidence({...Yl(i,e),queryClass:t,outcome:Ol},Z.properties.allEvidence,l.current)},children:Z.properties.viewAll})]}),(f.unadmittedAssessments>0||Object.entries(f.counts).some(([e,t])=>t>0&&!El.includes(e)))&&(0,q.jsx)(`p`,{className:`sentiment-details-caption`,children:Z.details.checksCaption}),(0,q.jsxs)(`dl`,{className:`sentiment-details-list`,children:[f.unadmittedAssessments>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{children:Z.details.unadmitted}),(0,q.jsx)(`dd`,{children:f.unadmittedAssessments})]}),Object.entries(f.counts).filter(([e,t])=>t>0&&![`favorable`,`mixed`,`unfavorable`].includes(e)).map(([e,t])=>(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{children:Tl(e)}),(0,q.jsx)(`dd`,{children:t})]},e))]}),e.reason&&(0,q.jsx)(`p`,{className:`sentiment-class-details-reason`,children:e.reason})]})]}):null}function Kl(e){return!!(e?.configured&&e.branded.coverage.judged>0&&e.branded.score.favorableRate!==null)&&!ze()}function ql({value:e}){if(!Kl(e))return null;let t=e.branded,n=t.coverage.judged,r=kl(t.score),i=`${Z.overall} ${n} of ${t.coverage.selected} judged${r?`, 95% interval ${r}`:``}. ${t.provisional?`Provisional. `:``}${Z.states[t.state]}${t.reason?` ${t.reason}`:``}`;return(0,q.jsx)(`div`,{className:`project-row-stat`,"data-sentiment-score":!0,children:(0,q.jsxs)(`div`,{className:`metric-inline-block`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`p`,{className:`metric-inline-label`,children:`Sentiment`}),(0,q.jsx)(`span`,{className:`relative z-10`,children:(0,q.jsx)(Tr,{text:i,placement:`bottom`})})]}),Sl(n)?(0,q.jsxs)(`p`,{className:`metric-inline-value`,children:[t.score.favorableDisplay,(0,q.jsx)(`span`,{className:`sr-only`,children:` favorable judgments, branded queries`})]}):(0,q.jsxs)(`p`,{className:`metric-inline-value text-secondary`,children:[Z.tooFew,(0,q.jsxs)(`span`,{className:`sr-only`,children:[` ratings for a favorable share, `,n,` of `,10,` needed, branded queries`]})]}),(0,q.jsx)(`p`,{className:`metric-inline-caption`,"aria-hidden":`true`})]})})}var Jl=(0,K.createContext)(null);function Yl(e,t){let{selection:n}=t;return{...e.selection,...n,runId:n.runId??void 0,runIds:n.runId?void 0:n.runIds,revision:n.revision??void 0,evaluationDefinitionId:n.evaluationDefinitionId??void 0}}function Xl(){return(0,K.useContext)(Jl)?.configured??!1}function Zl({projectName:e,selection:t,runOptions:n=[],waitForResolvedRun:r=!1,evidenceReady:i=!0,hasSourceEvidence:a=!0,children:o}){return(0,q.jsx)(Ql,{projectName:e,selection:t,runOptions:n,waitForResolvedRun:r,evidenceReady:i,hasSourceEvidence:a,children:o})}function Ql({projectName:e,selection:t,runOptions:n,waitForResolvedRun:r,evidenceReady:i,hasSourceEvidence:a,children:o}){let s=JSON.stringify([e,t]),[c,l]=(0,K.useState)(null),u=(0,K.useCallback)(e=>l(t=>t?.key===s&&t?.runId===e?.runId&&t?.revision===e?.revision?t:e?{...e,key:s}:null),[s]),d=i&&(!r||c?.key===s),f=r&&d&&c?{...t,runId:c.runId,revision:c.revision}:t,p=JSON.stringify([e,f]),{settings:m,branded:h,nonBrand:g,jobs:_}=bl(e,f,d&&a),[v,y]=(0,K.useState)(!1),[b,x]=(0,K.useState)(null),S=(0,K.useRef)(null);(0,K.useEffect)(()=>{y(!1),x(null)},[p]);let C=d&&!!(m.data?.enabled&&m.data.installEnabled),w=(t.queryClass===`non-brand`?g.data:h.data)?.selection,T={...f,...w?{...w,runId:w.runId??void 0,runIds:w.runId?void 0:w.runIds,revision:w.revision??void 0,evaluationDefinitionId:w.evaluationDefinitionId??void 0}:{}},E=T.runId&&!n.some(e=>e.id===T.runId)?[{id:T.runId,label:`Displayed check`},...n]:n,D=e=>{e.preventDefault(),S.current?.focus()};return(0,q.jsxs)(Jl.Provider,{value:{projectName:e,selection:f,resolveSource:u,settings:m,summaries:{branded:h,"non-brand":g},configured:C,hasSourceEvidence:a,openManage:e=>{S.current=e,y(!0)},openEvidence:(e,t,n)=>{S.current=n,x({selection:e,label:t})}},children:[o,(0,q.jsx)(Pa,{open:v&&!!m.data?.actions.configure,onOpenChange:y,children:(0,q.jsxs)(Ba,{onCloseAutoFocus:D,className:`overflow-y-auto`,children:[(0,q.jsxs)(Va,{children:[(0,q.jsx)(Ha,{children:`Manage sentiment`}),(0,q.jsx)(Ua,{children:`Classify saved answers and review the cost before submitting a backfill.`})]}),m.data?.actions.configure&&(0,q.jsx)(vu,{projectName:e,settings:m.data,selection:T,runOptions:E},JSON.stringify([m.data.evaluationDefinitionId,m.data.enabled,m.data.enablementEpoch])),_.data&&(0,q.jsx)(fu,{projectName:e,jobs:_.data.jobs})]})}),(0,q.jsx)(Pa,{open:b!==null,onOpenChange:e=>{e||x(null)},children:(0,q.jsxs)(Ba,{onCloseAutoFocus:D,className:`overflow-y-auto`,children:[(0,q.jsxs)(Va,{children:[(0,q.jsxs)(Ha,{children:[`Sentiment evidence`,b?`: ${b.label}`:``]}),(0,q.jsx)(Ua,{children:`Stored judgments and exact quotations for the selected query and scope.`})]}),b&&(0,q.jsx)(lu,{projectName:e,selection:b.selection},JSON.stringify(b.selection))]})})]})}function $l(e,t){let n=(0,K.useContext)(Jl)?.resolveSource;(0,K.useEffect)(()=>{n?.(e?{runId:e,revision:t??void 0}:null)},[n,e,t])}function eu(){let e=(0,K.useContext)(Jl);return e?.settings.data?.actions.configure?(0,q.jsx)(ul,{type:`button`,variant:`outline`,size:`sm`,onClick:t=>e.openManage(t.currentTarget),children:e.settings.data.enabled?`Manage sentiment`:`Enable sentiment`}):null}function tu(e,t){return!e?.configured||t===`unknown`||t===`unclassified`?null:[`branded`]}function nu({queryClass:e=`all`}){let t=(0,K.useContext)(Jl),n=tu(t,e);return!t?.hasSourceEvidence||!n?.some(e=>Fl(t.summaries[e].data))?null:(0,q.jsx)(`ul`,{className:`sentiment-legend`,"aria-hidden":`true`,children:El.map(e=>(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`sentiment-legend-swatch ${Al[e]}`}),Tl(e)]},e))})}function ru({queryClass:e}){let t=(0,K.useContext)(Jl);if(!t?.hasSourceEvidence)return null;let n=t.summaries[`non-brand`],r=n.data,i=e===`non-brand`;if(!r)return i?n.isError?(0,q.jsxs)(`p`,{role:`alert`,className:`sentiment-nonbrand-note`,children:[`Couldn’t load non-brand sentiment. `,(0,q.jsx)(W,{variant:`ghost`,onClick:()=>{n.refetch()},children:`Retry`})]}):(0,q.jsx)(`p`,{role:`status`,className:`sentiment-nonbrand-note`,children:`Loading non-brand sentiment…`}):null;let a=r.coverage.counts;return a.unfavorable===0&&a.mixed===0?i?Nl(r)?(0,q.jsx)(`p`,{className:`sentiment-nonbrand-note`,children:Z.nonBrand.none}):Ml(r)?(0,q.jsx)(`p`,{className:`sentiment-nonbrand-note`,children:Z.nonBrand.noneSoFar}):(0,q.jsx)(`p`,{className:`sentiment-nonbrand-note`,children:r.state===`not-measured`?Z.nonBrand.notRated:`${Z.nonBrand.label}: ${Pl(r)}`}):null:(0,q.jsx)(`div`,{className:`sentiment-nonbrand`,role:`group`,"aria-label":Z.nonBrand.label,children:(0,q.jsxs)(`div`,{className:`sentiment-nonbrand-line`,children:[(0,q.jsxs)(`span`,{className:`sentiment-nonbrand-label`,children:[Z.nonBrand.label,(0,q.jsx)(Tr,{text:Z.nonBrand.help})]}),(0,q.jsxs)(`span`,{className:`sentiment-nonbrand-counts`,children:[Ol.slice().reverse().filter(e=>a[e]>0).map(e=>(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`sentiment-legend-swatch ${Al[e]}`}),a[e],` `,e]},e)),!Nl(r)&&(0,q.jsx)(`span`,{className:`text-caution`,children:Z.partial})]}),(0,q.jsx)(W,{type:`button`,variant:`outline`,size:`sm`,onClick:e=>t.openEvidence({...Yl(t,r),queryClass:`non-brand`,outcome:Ol},Z.nonBrand.evidence,e.currentTarget),children:Z.nonBrand.view})]})})}function iu({queryClass:e=`all`,legend:t=!0,manage:n=!1}){let r=(0,K.useContext)(Jl),i=tu(r,e),[a,o]=(0,K.useState)(null);if(!r)return null;if(!i){let e=r.settings.data;return!n||!e?.actions.configure?null:(0,q.jsxs)(`div`,{className:`sentiment-headlines-title`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`sentiment-headlines-heading`,children:Z.title}),!(e.enabled&&e.installEnabled)&&(0,q.jsx)(`p`,{className:`sentiment-headlines-subtitle`,children:Z.states.disabled})]}),(0,q.jsx)(eu,{})]})}let s=r.hasSourceEvidence&&i.some(e=>r.summaries[e].data);return(0,q.jsxs)(`div`,{className:`sentiment-headlines`,role:`group`,"aria-label":`Favorable answer scores`,children:[(0,q.jsxs)(`div`,{className:`sentiment-headlines-title`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`sentiment-headlines-heading`,children:Z.title}),(0,q.jsx)(`p`,{className:`sentiment-headlines-subtitle`,children:Z.subtitle})]}),n&&(0,q.jsx)(eu,{})]}),t&&(0,q.jsx)(nu,{queryClass:e}),s&&(0,q.jsxs)(`div`,{className:`sentiment-headlines-columns`,"aria-hidden":`true`,children:[(0,q.jsx)(`span`,{className:`sentiment-headlines-favorable`,children:Z.columns.favorable}),(0,q.jsx)(`span`,{className:`sentiment-headlines-ratings`,title:Z.rated,children:Z.columns.rated})]}),i.map(e=>{let t=r.summaries[e];return(0,q.jsxs)(`div`,{className:`sentiment-class`,"data-query-class":e,children:[(0,q.jsxs)(`div`,{className:`sentiment-class-label`,children:[(0,q.jsx)(`span`,{children:xl[e]}),(0,q.jsx)(Tr,{text:Z.favorable})]}),r.hasSourceEvidence?t.data?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Il,{value:t.data,label:xl[e]}),(0,q.jsx)(zl,{value:t.data,label:xl[e]}),(0,q.jsx)(Hl,{coverage:t.data.coverage,label:xl[e]}),(0,q.jsx)(Ul,{value:t.data}),(0,q.jsx)(Gl,{value:t.data,queryClass:e,open:a===e,setOpenClass:o})]}):t.isError?(0,q.jsxs)(`p`,{role:`alert`,className:`sentiment-class-status`,children:[`Couldn’t load sentiment. `,(0,q.jsx)(W,{variant:`ghost`,onClick:()=>{t.refetch()},children:`Retry`})]}):(0,q.jsx)(`p`,{role:`status`,className:`sentiment-class-status`,children:`Loading sentiment…`}):(0,q.jsx)(`p`,{className:`sentiment-class-status`,children:`No saved answers.`})]},e)}),e!==`branded`&&(0,q.jsx)(ru,{queryClass:e})]})}function au({queryId:e,sourceSnapshotIds:t=[],queryClass:n,location:r,showLabel:i=!1}){let a=(0,K.useContext)(Jl);if(!a?.configured)return null;let o=n?a.summaries[n]:void 0,s=a.hasSourceEvidence?o?.data:void 0,c=s?.queries.filter(r=>r.queryClass===n&&(e?r.queryId===e:t.length>0)&&t.every(e=>r.sourceSnapshotIds.includes(e)))??[],l=c.length===1?c[0]:void 0,u=r===void 0?l:l?.locations.find(e=>e.location===r);if(!l||!u)return(0,q.jsx)(`span`,{className:`text-sm text-secondary`,children:a.hasSourceEvidence&&o?.isPending&&(e||t.length)?`Loading…`:`Unavailable`});let d={...a.selection,...s.selection,runId:s.selection.runId??void 0,runIds:s.selection.runId?void 0:s.selection.runIds,revision:s.selection.revision??void 0,evaluationDefinitionId:s.selection.evaluationDefinitionId??void 0,queryClass:l.queryClass,queryId:l.queryId,executionNodeKey:l.executionNodeKey??void 0,...r===void 0?{}:{location:r??`none`}};if(l.queryClass===`non-brand`){if(u.state===`unsupported`)return(0,q.jsx)(`span`,{className:`text-sm text-secondary`,children:`Unavailable`});let{unfavorable:e,mixed:t}=u.coverage.counts;if(e===0&&t===0){let e=i&&(0,q.jsx)(`span`,{className:`block text-sm font-normal text-secondary`,children:Z.nonBrand.rowLabel});return Nl(u)?(0,q.jsxs)(`span`,{className:`text-sm text-muted`,children:[e,(0,q.jsx)(`span`,{"aria-hidden":`true`,title:Z.nonBrand.rowNone,children:Cl}),(0,q.jsx)(`span`,{className:`sr-only`,children:Z.nonBrand.rowNone})]}):(0,q.jsxs)(`span`,{className:`text-sm text-secondary`,children:[e,(0,q.jsx)(`span`,{children:Pl(u)})]})}return(0,q.jsxs)(W,{type:`button`,variant:`ghost`,className:`h-auto min-h-11 flex-col items-start gap-0 px-1`,"aria-label":`View unfavorable and mixed answers for ${l.queryText}`,onKeyDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),a.openEvidence({...d,outcome:Ol},`${l.queryText}, unfavorable and mixed`,e.currentTarget)},children:[i&&(0,q.jsx)(`span`,{className:`text-sm font-normal text-secondary`,children:Z.nonBrand.rowLabel}),e>0&&(0,q.jsxs)(`span`,{className:`text-sm text-negative`,children:[e,` unfavorable`]}),t>0&&(0,q.jsxs)(`span`,{className:`text-sm text-caution`,children:[t,` mixed`]}),u.provisional&&(0,q.jsx)(`span`,{className:`text-xs font-normal text-caution`,children:`Provisional`})]})}return(0,q.jsxs)(W,{type:`button`,variant:`ghost`,className:`h-auto min-h-11 flex-col items-start gap-0 px-1`,"aria-label":`View ${xl[l.queryClass]} sentiment evidence for ${l.queryText}`,onKeyDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),a.openEvidence(d,l.queryText,e.currentTarget)},children:[i&&(0,q.jsx)(`span`,{className:`text-sm font-normal text-secondary`,children:`Favorable`}),(0,q.jsx)(`span`,{className:`font-mono text-primary`,children:u.score.favorableDisplay}),(0,q.jsxs)(`span`,{className:`text-sm font-normal text-secondary`,children:[u.coverage.judged,` judged`]}),u.provisional&&(0,q.jsx)(`span`,{className:`text-xs font-normal text-caution`,children:`Provisional`})]})}function ou(e){return e.outcome===`subject-not-mentioned`?`Not mentioned`:e.outcome===`running`?`Classifying`:e.outcome===`waiting-to-retry`?`Retrying`:e.outcome?Tl(e.outcome):e.state===`not-measured`?`Not classified`:e.state===`processing`?`Classifying`:e.state===`failed`?`Failed`:e.state===`canceled`?`Canceled`:`Unavailable`}function su({queryId:e,sourceSnapshotIds:t,queryClass:n,provider:r,model:i,location:a,showSubjects:o=!1,showLabel:s=!1}){let c=(0,K.useContext)(Jl);if(!c?.configured)return null;let l=n?c.summaries[n]:void 0,u=c.hasSourceEvidence?l?.data:void 0,d=u?.queries.filter(r=>r.queryClass===n&&(!e||r.queryId===e)&&t.length>0&&t.every(e=>r.sourceSnapshotIds.includes(e)))??[],f=d.length===1?d[0]:void 0,p=f?.assessments?.filter(e=>t.includes(e.sourceSnapshotId)&&e.provider===r&&e.location===a&&(i===void 0||e.servedModel===i))??[];return(0,q.jsxs)(`div`,{role:`group`,className:`text-sm text-secondary`,"aria-label":`${r||`Saved answer`} sentiment`,children:[s&&(0,q.jsx)(`span`,{className:`block text-sm text-secondary`,children:`Sentiment`}),p.length?p.map(e=>{let t=ou(e),n=Dl(e.outcome),r=(0,q.jsxs)(q.Fragment,{children:[o&&(0,q.jsxs)(`span`,{children:[e.subjectLabel,` · `]}),(0,q.jsx)(xn,{tone:n,className:`max-w-full shrink-0 rounded-none border-0 bg-transparent p-0 text-sm font-normal tracking-normal [overflow-wrap:normal]`,children:t})]}),i={...c.selection,...u.selection,runId:u.selection.runId??void 0,runIds:u.selection.runId?void 0:u.selection.runIds,revision:u.selection.revision??void 0,evaluationDefinitionId:u.selection.evaluationDefinitionId??void 0,queryClass:f.queryClass,queryId:f.queryId,executionNodeKey:f.executionNodeKey??void 0,assessmentId:e.assessmentId??void 0};return(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.assessmentId?(0,q.jsx)(W,{type:`button`,variant:`ghost`,className:`h-auto min-h-11 flex-wrap justify-start whitespace-normal px-1 text-left text-sm`,"aria-label":`View ${e.provider} sentiment evidence for ${e.subjectLabel}: ${t}`,onKeyDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),c.openEvidence(i,`${f.queryText} · ${e.provider} · ${e.subjectLabel}`,t.currentTarget)},children:r}):(0,q.jsx)(`span`,{children:r}),e.reason&&(0,q.jsx)(Tr,{text:e.reason})]},JSON.stringify([e.sourceSnapshotId,e.subjectId,e.assessmentId]))}):(0,q.jsx)(`span`,{children:c.hasSourceEvidence&&l?.isPending&&t.length?`Loading…`:`Unavailable`})]})}function cu({item:e}){return(0,q.jsxs)(`article`,{className:`space-y-4 border-b border-default py-5 text-sm text-secondary`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`strong`,{className:`text-primary`,children:e.subject.displayName}),(0,q.jsx)(xn,{tone:Dl(e.outcome),children:Tl(e.outcome)}),(0,q.jsx)(`span`,{children:xl[e.context.queryClass]}),(0,q.jsx)(`span`,{children:Ki(e.context.provider)}),(0,q.jsx)(`span`,{children:e.context.servedModel??`Source model unavailable`}),(0,q.jsx)(`span`,{children:e.context.location??`No location`})]}),e.reason&&(0,q.jsx)(`p`,{children:e.reason}),(0,q.jsxs)(`section`,{children:[(0,q.jsx)(`h3`,{className:`mb-2 text-heading`,children:`Conclusion evidence`}),e.conclusion.length?e.conclusion.map(e=>(0,q.jsx)(`blockquote`,{className:`mb-2 border-l border-strong pl-3 text-primary`,children:e.text},`${e.id}:${e.start}`)):(0,q.jsx)(`p`,{children:`No valid conclusion evidence is available.`})]}),(0,q.jsxs)(`section`,{children:[(0,q.jsx)(`h3`,{className:`mb-2 text-heading`,children:`Complaint evidence`}),e.complaint?.length?e.complaint.map(e=>(0,q.jsx)(`blockquote`,{className:`mb-2 border-l border-strong pl-3 text-primary`,children:e.text},`${e.id}:${e.start}`)):(0,q.jsx)(`p`,{children:`No complaint was identified.`})]}),(0,q.jsxs)(`details`,{children:[(0,q.jsx)(`summary`,{className:`cursor-pointer`,children:`Original source answer`}),(0,q.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-primary`,children:e.sourceText})]}),(0,q.jsxs)(`details`,{children:[(0,q.jsx)(`summary`,{className:`cursor-pointer`,children:`Assessment provenance`}),(0,q.jsxs)(`dl`,{className:`mt-3 space-y-2 break-all`,children:[(0,q.jsx)(`dt`,{children:`Query`}),(0,q.jsx)(`dd`,{children:e.context.queryText}),(0,q.jsx)(`dt`,{children:`Subject`}),(0,q.jsxs)(`dd`,{children:[e.subject.displayName,` (`,e.subject.id,`)`]}),(0,q.jsx)(`dt`,{children:`Run`}),(0,q.jsx)(`dd`,{children:e.runId}),(0,q.jsx)(`dt`,{children:`Revision`}),(0,q.jsx)(`dd`,{children:e.context.revision??`Unavailable`}),(0,q.jsx)(`dt`,{children:`Evaluator`}),(0,q.jsx)(`dd`,{children:e.returnedModel??`Unavailable`}),(0,q.jsx)(`dt`,{children:`Evaluation definition`}),(0,q.jsx)(`dd`,{children:e.evaluationDefinitionId}),(0,q.jsx)(`dt`,{children:`Source snapshot`}),(0,q.jsx)(`dd`,{children:e.sourceSnapshotId}),(0,q.jsx)(`dt`,{children:`Source hash`}),(0,q.jsx)(`dd`,{children:e.sourceTextHash}),e.context.usageEdges.map((e,t)=>(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{children:`Assignment`}),(0,q.jsxs)(`dd`,{children:[`Target `,e.targetId,`; Property `,e.propertyId??`None`,`; market `,e.marketId??`None`,`; `,e.queryClass]})]},t))]})]})]})}function lu({projectName:e,selection:t}){let[n,r]=(0,K.useState)(),i=R({queryKey:ml(e,`evidence`,t,n),queryFn:()=>Ct(e,t,n),retry:!1});return i.isPending?(0,q.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-secondary`,children:`Loading sentiment evidence…`}):i.isError?(0,q.jsxs)(`p`,{role:`alert`,className:`mt-4 text-sm text-secondary`,children:[`Could not load sentiment evidence. `,(0,q.jsx)(W,{variant:`outline`,onClick:()=>{i.refetch()},children:`Retry evidence`})]}):(0,q.jsxs)(q.Fragment,{children:[i.data.items.length?i.data.items.map(e=>(0,q.jsx)(cu,{item:e},e.assessmentId)):(0,q.jsx)(`p`,{className:`mt-4 text-sm text-secondary`,children:`No stored sentiment evidence for this query and scope.`}),(0,q.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[n&&(0,q.jsx)(W,{variant:`outline`,onClick:()=>r(void 0),children:`First evidence page`}),i.data.nextCursor&&(0,q.jsx)(W,{variant:`outline`,onClick:()=>r(i.data.nextCursor??void 0),children:`Next evidence page`})]})]})}function uu({projectName:e,jobId:t}){let[n,r]=(0,K.useState)(),i=R({queryKey:ml(e,`job:${t}`,void 0,n),queryFn:()=>kt(e,t,n),retry:!1});return i.isPending?(0,q.jsx)(`p`,{role:`status`,children:`Loading attempts…`}):i.isError?(0,q.jsxs)(`p`,{role:`alert`,children:[`Could not load attempts. `,(0,q.jsx)(W,{variant:`outline`,onClick:()=>{i.refetch()},children:`Retry attempts`})]}):(0,q.jsxs)(q.Fragment,{children:[i.data.attempts.map(e=>(0,q.jsxs)(`p`,{children:[e.errorCode??`Request complete`,`; `,e.usage.kind===`unknown`?`Usage unknown`:`${e.usage.inputTokens??`Unknown`} input tokens (${e.usage.kind})`]},e.id)),(0,q.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[n&&(0,q.jsx)(W,{variant:`outline`,onClick:()=>r(void 0),children:`Newest attempts`}),i.data.nextAttemptCursor&&(0,q.jsx)(W,{variant:`outline`,onClick:()=>r(i.data.nextAttemptCursor??void 0),children:`Older attempts`})]})]})}function du({projectName:e,job:t}){let[n,r]=(0,K.useState)(!1);return(0,q.jsxs)(`details`,{onToggle:e=>r(e.currentTarget.open),children:[(0,q.jsx)(`summary`,{children:`Job details`}),t.cancellationReason&&(0,q.jsx)(`p`,{children:t.cancellationReason}),Object.entries(t.counts).filter(([,e])=>e>0).map(([e,t])=>(0,q.jsxs)(`p`,{children:[Tl(e),`: `,t]},e)),(0,q.jsxs)(`p`,{children:[`Attempts: `,t.attemptCount]}),n&&t.attemptCount>0&&(0,q.jsx)(uu,{projectName:e,jobId:t.id})]})}function fu({projectName:e,jobs:t}){return(0,q.jsxs)(`details`,{className:`mt-6 text-sm text-secondary`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer`,children:`Recent sentiment jobs`}),t.length===0?(0,q.jsx)(`p`,{className:`mt-2`,children:`No sentiment jobs have been submitted.`}):(0,q.jsx)(`div`,{className:`data-table-wrapper mt-3`,children:(0,q.jsxs)(`table`,{className:`data-table`,"aria-label":`Sentiment jobs`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`th`,{children:`Submitted`}),(0,q.jsx)(`th`,{children:`State`}),(0,q.jsx)(`th`,{children:`Selected`}),(0,q.jsx)(`th`,{children:`Details`})]})}),(0,q.jsx)(`tbody`,{children:t.map(t=>(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`td`,{children:Vn(t.createdAt)}),(0,q.jsx)(`td`,{children:Tl(t.state)}),(0,q.jsx)(`td`,{children:t.selected}),(0,q.jsx)(`td`,{children:(0,q.jsx)(du,{projectName:e,job:t})})]},t.id))})]})})]})}var pu={probe:`Probe checks`,"unsupported-run-kind":`Not an AI Visibility check`,"failed-run":`Failed check`,"incomplete-run":`Incomplete check`,"legacy-missing-provenance":`Saved without its frozen query and subject record`,"legacy-missing-language":`Saved before the answer language was recorded`,"excluded-branded":`Branded answers (backfill that class separately)`,"excluded-non-brand":`Non-brand answers (backfill that class separately)`};function mu(e){return pu[e]??Tl(e)}function hu(e){return[e.provider&&`engine ${e.provider}`,e.model&&`model ${e.model}`,e.location&&(e.location===`none`?`no location`:`location ${e.location}`),e.scope!==`project`&&e.scopeKey&&`${e.scope} ${e.scopeKey}`,e.marketKey&&`market ${e.marketKey}`,e.queryId&&`query ${e.queryId}`,e.revision!==void 0&&`revision ${e.revision}`].filter(e=>!!e)}function gu(e){let t=hu(e);return[`${xl[e.queryClass]} queries`,...t.length?t:[`whole check`]].join(` · `)}function _u(e,t,n,r){return r?{...e,queryClass:n,queryId:void 0,runIds:void 0,runId:t}:{mode:`auto`,scope:`project`,queryClass:n,runId:t}}function vu({projectName:e,settings:t,selection:n,runOptions:r}){let i=ge(),[a,o]=(0,K.useState)(t.enabled),[s,c]=(0,K.useState)(n.runId??``),[l,u]=(0,K.useState)(n.queryClass),[d,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)(null),h=(0,K.useRef)(null),g=hu({...n,queryId:void 0}),_=()=>i.invalidateQueries({queryKey:[`sentiment`,e]}),v=()=>{m(null),h.current=null},y=L({mutationFn:async()=>{if(!(await Ae(e)).actions.configure)throw Error(`Administrator permission is required to configure sentiment.`);return En(e,{enabled:a})},onSuccess:async()=>{v(),await _(),await i.invalidateQueries({queryKey:[`project-overview-slim`]})},onError:_}),b=L({mutationFn:async()=>{if(!(await Ae(e)).actions.backfill)throw Error(`Administrator permission is required to backfill sentiment.`);return on(e,_u(n,s,l,d&&g.length>0))},onSuccess:e=>{m(e),h.current=crypto.randomUUID()},onError:_}),x=L({mutationFn:async()=>{if(!p?.previewToken||!h.current)throw Error(`Create and review a backfill preview first.`);if(!(await Ae(e)).actions.backfill)throw Error(`Administrator permission is required to backfill sentiment.`);return un(e,p.previewToken,h.current)},onSuccess:async()=>{v(),await _()},onError:_}),S=y.isPending||b.isPending||x.isPending;return(0,q.jsxs)(`div`,{className:`mt-5 space-y-5 text-sm text-secondary`,children:[(0,q.jsx)(`dl`,{className:`definition-list`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{children:`Evaluator`}),(0,q.jsxs)(`dd`,{children:[t.model,` · `,t.provider===`openrouter`?`OpenRouter`:`TypeSafe`]})]})}),(0,q.jsx)(`p`,{children:t.disclosure}),!t.ready&&(0,q.jsx)(`p`,{children:t.readinessReasons.join(`; `)||`An operator must configure sentiment on this installation.`}),(0,q.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),y.mutate()},children:[(0,q.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:a,disabled:S,onChange:e=>{o(e.target.checked),v()}}),`Enable project sentiment`]}),(0,q.jsx)(`p`,{children:`Enabling applies to future completed checks. Past checks require an explicit backfill.`}),(0,q.jsx)(ul,{type:`submit`,disabled:S,children:y.isPending?`Saving…`:`Save sentiment settings`}),y.isError&&(0,q.jsx)(`p`,{role:`alert`,children:mt(y.error)}),y.isSuccess&&(0,q.jsx)(`p`,{role:`status`,children:`Sentiment settings saved.`})]}),t.actions.backfill&&(0,q.jsxs)(`section`,{className:`space-y-3`,children:[(0,q.jsx)(`h3`,{children:`Backfill a saved check`}),(0,q.jsxs)(`label`,{className:`block`,children:[`Saved check`,(0,q.jsxs)(`select`,{className:`mt-1 block w-full rounded-md border border-default bg-bg p-2 text-primary`,value:s,disabled:S,onChange:e=>{c(e.target.value),v()},children:[(0,q.jsx)(`option`,{value:``,children:`Select a saved check`}),r.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),(0,q.jsxs)(`label`,{className:`block`,children:[`Query class`,(0,q.jsxs)(`select`,{className:`mt-1 block w-full rounded-md border border-default bg-bg p-2 text-primary`,value:l,disabled:S,onChange:e=>{u(e.target.value),v()},children:[(0,q.jsx)(`option`,{value:`non-brand`,children:`Non-brand`}),(0,q.jsx)(`option`,{value:`branded`,children:`Branded`})]})]}),(0,q.jsx)(`p`,{children:`The backfill covers every engine, location and query of the chosen check for this query class.`}),g.length>0&&(0,q.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:d,disabled:S,onChange:e=>{f(e.target.checked),v()}}),(0,q.jsxs)(`span`,{children:[`Limit to the current view`,(0,q.jsx)(`span`,{className:`block`,children:g.join(` · `)})]})]}),(0,q.jsx)(W,{variant:`outline`,disabled:S||!s||!t.enabled||!t.ready,onClick:()=>{v(),b.mutate()},children:b.isPending?`Preparing preview…`:`Preview sentiment backfill`}),b.isError&&(0,q.jsx)(`p`,{role:`alert`,children:mt(b.error)}),p&&(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsxs)(`dl`,{className:`grid grid-cols-[1fr_auto] gap-2`,children:[(0,q.jsx)(`dt`,{children:`Selection`}),(0,q.jsx)(`dd`,{className:`text-right`,children:gu(p.selection)}),(0,q.jsx)(`dt`,{children:`Eligible assessments`}),(0,q.jsx)(`dd`,{children:p.eligibleAssessments}),(0,q.jsx)(`dt`,{children:`Already classified`}),(0,q.jsx)(`dd`,{children:p.alreadyClassified}),(0,q.jsx)(`dt`,{children:`Estimated input tokens`}),(0,q.jsx)(`dd`,{children:p.estimatedInputTokens}),(0,q.jsx)(`dt`,{children:`Estimated cost (USD)`}),(0,q.jsx)(`dd`,{children:p.estimatedCostUsd??`Unavailable`})]}),(0,q.jsx)(Tr,{text:p.estimateMethod}),p.eligibleAssessments===0&&(0,q.jsx)(`p`,{children:`No saved answers in this selection can be classified.`}),p.skipped.length>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{children:`Not included:`}),(0,q.jsx)(`ul`,{"aria-label":`Skipped assessments`,className:`list-disc pl-5`,children:p.skipped.map(e=>(0,q.jsxs)(`li`,{children:[mu(e.reason),`: `,e.count]},`${e.runId}:${e.reason}`))})]}),(0,q.jsx)(ul,{disabled:S||!p.previewToken||p.eligibleAssessments===0,onClick:()=>x.mutate(),children:x.isPending?`Submitting…`:`Confirm sentiment backfill`})]}),x.isError&&(0,q.jsxs)(`p`,{role:`alert`,children:[mt(x.error),` Retry uses the same request key.`]}),x.isSuccess&&(0,q.jsx)(`p`,{role:`status`,children:`Backfill submitted. Progress is available in Recent jobs.`})]})]})}var yu=20;function bu({points:e,tone:t}){let n=(0,K.useId)();if(e.length===0)return null;let r=t=>5+t/Math.max(e.length-1,1)*122,i=zr(e),a=Math.min(...e),o=Math.max(...e),s=Math.max(o-a,yu),c=(o+a)/2-s/2,l=e.map((e,t)=>({x:r(t),y:5+(1-(e-c)/s)*26}));return(0,q.jsxs)(`svg`,{className:`sparkline sparkline-${t}${i?` sparkline-provisional`:``}`,viewBox:`0 0 132 42`,"aria-hidden":`true`,children:[(0,q.jsx)(`defs`,{children:(0,q.jsx)(`clipPath`,{id:n,children:(0,q.jsx)(`rect`,{x:5,y:5,width:122,height:32,rx:`8`})})}),(0,q.jsx)(`line`,{className:`sparkline-guide`,x1:5,x2:127,y1:37,y2:37}),l.length===1?(0,q.jsx)(`circle`,{className:`sparkline-point`,cx:l[0].x,cy:l[0].y,r:`3`}):(0,q.jsx)(`polyline`,{clipPath:`url(#${n})`,points:l.map(e=>`${e.x},${e.y}`).join(` `),vectorEffect:`non-scaling-stroke`})]})}function xu({run:e,projectName:t,children:n,className:r,label:i}){let{openRun:a}=ns();return e.kind===G[`seo-sync`]&&e.opensSeoWorkspace!==!1?t?(0,q.jsx)(B,{to:`/projects/$projectName/seo-data`,params:{projectName:t},search:t=>({...t,seoRunId:e.id,seoProfileId:void 0,runId:void 0,evidenceId:void 0}),className:r,"aria-label":i,children:n}):(0,q.jsx)(`button`,{type:`button`,disabled:!0,className:r,"aria-label":i,title:`Project unavailable`,children:n}):(0,q.jsx)(`button`,{type:`button`,className:r,"aria-label":i,onClick:()=>a(e.id),children:n})}function Su({project:e,sentimentColumn:t}){return(0,q.jsxs)(`div`,{className:`project-row relative${t?` project-row-with-sentiment`:``}`,children:[(0,q.jsx)(`div`,{className:`project-row-chart`,children:(0,q.jsx)(bu,{points:e.trend,tone:ri(e.lastRun.status)})}),(0,q.jsxs)(`div`,{className:`project-row-primary`,children:[(0,q.jsxs)(B,{to:`/projects/$projectName`,params:{projectName:e.project.name},className:`after:absolute after:inset-0 after:rounded-xl focus-visible:outline-none focus-visible:after:ring-2 focus-visible:after:ring-mono-400`,children:[(0,q.jsx)(`p`,{className:`project-name`,children:e.project.name}),(0,q.jsx)(`p`,{className:`project-domain`,children:e.project.canonicalDomain})]}),(0,q.jsx)(`p`,{className:`project-insight`,children:e.insight})]}),(0,q.jsx)(`div`,{className:`project-row-stat`,children:(0,q.jsxs)(`div`,{className:`metric-inline-block`,children:[(0,q.jsx)(`p`,{className:`metric-inline-label`,children:`Mentioned`}),(0,q.jsx)(`p`,{className:`metric-inline-value ${e.mentionTone===`caution`?`text-caution-400`:``}`,children:e.hasMeasurement===!1?`Not measured`:pt(e.mentionScore,Kt.percent)}),(0,q.jsx)(`p`,{className:`metric-inline-caption${e.providerCoverage?` text-caution`:``}`,title:e.providerCoverage,children:e.providerCoverage?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Partial check: `}),e.providerCoverage]}):e.mentionDelta})]})}),(0,q.jsx)(`div`,{className:`project-row-stat`,children:(0,q.jsxs)(`div`,{className:`metric-inline-block`,children:[(0,q.jsxs)(`p`,{className:`metric-inline-label`,children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`Pressure`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Competitor pressure`})]}),(0,q.jsx)(`p`,{className:`metric-inline-value`,children:e.hasMeasurement===!1?`Not measured`:e.competitorPressureLabel}),(0,q.jsx)(`p`,{className:`metric-inline-caption`,"aria-hidden":`true`})]})}),Kl(e.sentiment)?(0,q.jsx)(ql,{value:e.sentiment}):t&&(0,q.jsx)(`div`,{className:`project-row-stat`,"aria-hidden":`true`,"data-sentiment-placeholder":!0}),(0,q.jsx)(`span`,{className:`project-row-link`,children:(0,q.jsx)(v,{className:`h-4 w-4 text-muted`})})]})}function Cu(){let{isAdmin:e}=Jn(),t=Go(),{dashboard:n,isLoading:r,isError:i,activityLoading:a,activityError:o,refetch:s}=Ko(),c=n??t?.dashboard,l=es(!t,t?.health);if(i&&!c)return(0,q.jsxs)(`div`,{className:`page-container`,children:[(0,q.jsx)(`div`,{className:`page-header`,children:(0,q.jsxs)(`div`,{className:`page-header-left`,children:[(0,q.jsx)(`h1`,{className:`page-title`,children:`All projects unavailable`}),(0,q.jsx)(`p`,{className:`page-subtitle`,children:`Canonry could not load the project list.`})]})}),(0,q.jsxs)(`div`,{className:`max-w-xl rounded-lg border border-negative bg-negative-soft p-4`,role:`alert`,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-heading`,children:`Your projects have not been changed.`}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-secondary`,children:`Check the connection or sign in again, then retry.`}),(0,q.jsx)(W,{type:`button`,variant:`secondary`,className:`mt-4`,onClick:()=>{s()},children:`Retry loading projects`})]})]});if(!c||r)return(0,q.jsxs)(`div`,{className:`page-skeleton`,children:[(0,q.jsxs)(`div`,{className:`page-skeleton-header`,children:[(0,q.jsx)(`div`,{className:`skeleton-text h-6 w-32`}),(0,q.jsx)(`div`,{className:`skeleton-text-sm w-64`})]}),(0,q.jsx)(`div`,{className:`space-y-3`,children:[1,2,3].map(e=>(0,q.jsxs)(`div`,{className:`rounded-xl border border-default bg-surface p-4 flex items-center gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,q.jsx)(`div`,{className:`skeleton-text w-36`}),(0,q.jsx)(`div`,{className:`skeleton-text-sm w-48`})]}),(0,q.jsx)(`div`,{className:`skeleton-text w-16`}),(0,q.jsx)(`div`,{className:`skeleton-text w-16`}),(0,q.jsx)(`div`,{className:`skeleton h-8 w-20 rounded`})]},e))})]});let u=c.portfolioOverview,d=u.projects.length>0&&u.projects.every(e=>e.hasMeasurement===!1),f=u.projects.some(e=>Kl(e.sentiment)),p=u.attentionItems.map(e=>d&&e.id===`attention_stable`?{...e,tone:`neutral`,title:`Awaiting first measurement`,detail:`Visibility results will appear after the first check.`}:e),m=l.data??t?.health??{apiStatus:{label:`API`,state:`checking`,detail:`Checking service health`},workerStatus:{label:`Worker`,state:`checking`,detail:`Checking service health`}},h=ui(u.systemHealth.filter(t=>e||t.id===`api`||t.id===`worker`),m,c.settings);return(0,q.jsxs)(`div`,{className:`page-container`,children:[(0,q.jsx)(`div`,{className:`page-header`,children:(0,q.jsxs)(`div`,{className:`page-header-left`,children:[(0,q.jsx)(`h1`,{className:`page-title`,children:`All projects`}),(0,q.jsx)(`p`,{className:`page-subtitle`,children:`Visibility across all projects.`})]})}),u.projects.length>0?(0,q.jsx)(`div`,{className:`project-list project-list-scrollable`,children:u.projects.map(e=>(0,q.jsx)(Su,{project:e,sentimentColumn:f},e.project.id))}):(0,q.jsxs)(Ar,{className:`surface-card empty-card`,children:[(0,q.jsx)(`h3`,{children:u.emptyState?.title??`No projects yet`}),(0,q.jsx)(`p`,{className:`supporting-copy`,children:u.emptyState?.detail}),(0,q.jsx)(W,{size:`sm`,asChild:!0,children:(0,q.jsx)(B,{to:u.emptyState?.ctaHref===`/setup`||!u.emptyState?.ctaHref?`/setup`:`/`,children:u.emptyState?.ctaLabel??`Launch setup`})})]}),(0,q.jsxs)(`div`,{className:`overview-secondary-grid`,children:[p.length>0&&(0,q.jsxs)(`section`,{className:`overview-secondary-section`,children:[(0,q.jsx)(`div`,{className:`section-head section-head-inline`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`eyebrow eyebrow-soft`,children:`Needs attention`}),(0,q.jsx)(`h2`,{className:`section-title-sm`,children:`What changed`})]})}),(0,q.jsx)(`div`,{className:`attention-list attention-list-scrollable`,children:p.map(e=>e.href?(0,q.jsxs)(B,{to:e.href,className:`attention-item attention-item-${e.tone}`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`attention-title`,children:e.title}),(0,q.jsx)(`p`,{className:`attention-detail`,children:e.detail})]}),e.actionLabel&&(0,q.jsx)(`span`,{className:`attention-action`,children:e.actionLabel})]},e.id):(0,q.jsxs)(`div`,{className:`attention-item attention-item-static attention-item-${e.tone}`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`attention-title`,children:e.title}),(0,q.jsx)(`p`,{className:`attention-detail`,children:e.detail})]}),e.actionLabel&&(0,q.jsx)(`span`,{className:`attention-action`,children:e.actionLabel})]},e.id))})]}),(0,q.jsxs)(`section`,{className:`overview-secondary-section`,children:[(0,q.jsx)(`div`,{className:`section-head section-head-inline`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`eyebrow eyebrow-soft`,children:`Recent runs`}),(0,q.jsx)(`h2`,{className:`section-title-sm`,children:`Activity`})]})}),(0,q.jsx)(`div`,{className:`compact-stack compact-stack-scrollable`,children:o?(0,q.jsxs)(`div`,{role:`alert`,children:[(0,q.jsx)(`p`,{className:`text-sm text-secondary`,children:`Recent jobs could not be loaded.`}),(0,q.jsx)(W,{type:`button`,variant:`secondary`,className:`mt-3`,onClick:()=>{s()},children:`Retry loading activity`})]}):a?(0,q.jsx)(`p`,{className:`supporting-copy`,role:`status`,children:`Loading recent jobs…`}):u.recentRuns.length>0?u.recentRuns.map(e=>(0,q.jsxs)(xu,{run:e,projectName:u.projects.find(t=>t.project.id===e.projectId)?.project.name,className:`compact-run`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`compact-run-title`,children:e.projectName}),(0,q.jsx)(`p`,{className:`compact-run-detail`,children:e.summary})]}),(0,q.jsx)(Na,{status:e.status})]},e.id)):(0,q.jsx)(`p`,{className:`supporting-copy`,children:`Run history appears here after the first launch.`})})]})]}),(0,q.jsxs)(`section`,{className:`page-section`,children:[(0,q.jsx)(`div`,{className:`section-head section-head-inline`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`eyebrow eyebrow-soft`,children:`System health`}),(0,q.jsx)(`h2`,{className:`section-title-sm`,children:`Infrastructure`})]})}),(0,q.jsx)(`div`,{className:`divide-y divide-default border-y border-default`,children:h.map(e=>{let t=e.id===`api`?m.apiStatus:e.id===`worker`?m.workerStatus:void 0,n=t?t.state===`ok`?void 0:li(t):e.tone===`positive`?void 0:e.meta;return(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-heading`,children:e.label}),n&&(0,q.jsx)(`p`,{className:`mt-1 text-sm text-secondary`,children:n})]}),(0,q.jsx)(xn,{tone:e.tone,title:t?li(t):e.meta,children:e.detail})]},e.id)})})]})]})}var wu=`a, button, input, select, textarea, label, [role="button"], [role="link"], [role="checkbox"], [role="menuitem"]`;function Tu(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!1;let t=e.target;if(t&&typeof t.closest==`function`&&t.closest(wu))return!1;let n=typeof window<`u`?window.getSelection():null;return!(n&&!n.isCollapsed&&n.toString().trim()!==``)}function Eu({onApplied:e}){let{canWrite:t}=Jn(),[n,r]=(0,K.useState)(``),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)([]),[c,l]=(0,K.useState)([]);return ze()||!t?null:(0,q.jsxs)(`section`,{className:`mt-8`,children:[(0,q.jsx)(`div`,{className:`page-section-divider`}),(0,q.jsx)(`div`,{className:`section-head mt-6`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`eyebrow eyebrow-soft`,children:`Config as code`}),(0,q.jsx)(`h2`,{className:`text-sm font-medium text-strong`,children:`Apply YAML`})]})}),(0,q.jsxs)(`p`,{className:`text-muted text-sm mb-3`,children:[`Paste a `,(0,q.jsx)(`code`,{className:`text-secondary`,children:`canonry.yaml`}),` config (multi-document YAML with `,(0,q.jsx)(`code`,{className:`text-secondary`,children:`---`}),` separators supported).`]}),(0,q.jsx)(`textarea`,{className:`setup-input w-full font-mono text-xs`,rows:10,placeholder:`apiVersion: canonry/v1
19
19
  kind: Project
20
20
  metadata:
21
21
  name: my-project
@@ -41,7 +41,7 @@ spec:
41
41
  `);ke(t),ze(!0)}}catch(e){Tt(e instanceof Error?e.message:`Failed to generate queries`),y({flowVersion:1,onboardingSessionId:_,event:`onboarding.blocked`,step:`queries`,action:`generate_queries`,reasonCode:$e(e,`unknown`)},`onboarding.blocked:queries:generate`)}finally{Ct(!1)}}},Nn=async()=>{if(!L)return;let e=Cn;if(e.length!==0){Yt(!0),Kt(null);try{await St(L,e),Wt(!0),await r(),y({flowVersion:1,onboardingSessionId:_,event:`onboarding.step_completed`,step:`competitors`,method:`manual`,countBucket:Dt(e.length)},`onboarding.step_completed:competitors`),M(4)}catch(e){Kt(e instanceof Error?e.message:`Failed to save competitors`),y({flowVersion:1,onboardingSessionId:_,event:`onboarding.blocked`,step:`competitors`,action:`save`,reasonCode:`unknown`},`onboarding.blocked:competitors:save`)}finally{Yt(!1)}}},Pn=async()=>{let e=pn.trim();if(e){_n(!0),yn(null);try{await Nt(`gemini`,{apiKey:e}),$n({title:`Gemini configured`,detail:`Provider is ready — continuing setup.`,tone:`positive`,dedupeKey:`setup:gemini:configured`,dedupeMode:`drop`}),mn(``),await r(),vt(c.providerStatuses.find(e=>e.name.toLowerCase()===`gemini`)?.name??`gemini`),y({flowVersion:1,onboardingSessionId:_,event:`onboarding.step_completed`,step:`system`,method:`inline`},`onboarding.step_completed:system`)}catch(e){yn(e instanceof Error?e.message:`Failed to save Gemini key`),y({flowVersion:1,onboardingSessionId:_,event:`onboarding.blocked`,step:`system`,action:`configure_provider`,reasonCode:`provider_save_failed`},`onboarding.blocked:system:provider_save_failed`)}finally{_n(!1)}}},Fn=async e=>{let t=ye?.name??L;if(!t)throw Error(`Create a project before choosing models.`);let n=await qt(t,e);xe(n),await r()},In=async()=>{if(!_t()){if(!L||En){cn(En??`Complete setup before launching the first check.`);let e=Tn??(L?wn===0?`no_queries`:`run_rejected`:`unknown`);tt||y({flowVersion:1,onboardingSessionId:_,event:`run.requested`,origin:`dashboard_setup`,result:`rejected`,providerCountBucket:Dt(ht),queryCountBucket:Dt(wn),reasonCode:e})}else{on(!0),cn(null);try{let e=await un.mutateAsync({projectName:L,projectLabel:ue||ce||L,sourceAction:`setup-launch`});H(e.id),rn(!0),Je(L,e.id),$t.current=e.id,tt||y({flowVersion:1,onboardingSessionId:_,event:`run.requested`,origin:`dashboard_setup`,result:`queued`,providerCountBucket:Dt(ht),queryCountBucket:Dt(wn)}),await r()}catch(e){cn(e instanceof Error?e.message:`Failed to queue the AI Visibility check. Retry when the instance is ready.`),tt||y({flowVersion:1,onboardingSessionId:_,event:`run.requested`,origin:`dashboard_setup`,result:`rejected`,providerCountBucket:Dt(ht),queryCountBucket:Dt(wn),reasonCode:$e(e,`run_rejected`)})}finally{on(!1)}}}},Ln=()=>M(e=>m?2:Math.max(0,e-1)),zn=(e,t,n)=>{y({flowVersion:1,onboardingSessionId:_,event:`onboarding.step_completed`,step:e,method:`existing`,...n===void 0?{}:{countBucket:Dt(n)}},`onboarding.step_completed:${e}`),M(t)},Bn=()=>{y({flowVersion:1,onboardingSessionId:_,event:`onboarding.step_completed`,step:`queries`,method:`skipped`,countBucket:`0`},`onboarding.step_completed:queries`),m?De():M(3)},Vn=()=>{y({flowVersion:1,onboardingSessionId:_,event:`onboarding.step_completed`,step:`competitors`,method:`skipped`,countBucket:`0`},`onboarding.step_completed:competitors`),M(4)},Hn=m?`section`:Ar,Un=ct!==!0||st===!0?(0,q.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,className:Bd,onClick:()=>{r(),et&&ot.refetch(),dt&&pt.refetch()},children:`Check again`}):null,Wn=(ut||jt)&&!!zt,Kn=m&&(ae===2||ae===4)?l?(0,q.jsxs)(`section`,{"aria-labelledby":`setup-provider-heading`,className:`space-y-3 border-b border-default pb-6 mb-6`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,q.jsx)(`h2`,{id:`setup-provider-heading`,className:`text-lg font-semibold text-heading`,children:`AI engines`}),(0,q.jsx)(xn,{tone:ct===!0?`positive`:lt?`caution`:`neutral`,children:ct===!0?`Ready`:lt?`Choose models`:ut?`Not connected`:`Checking`}),(0,q.jsx)(Tr,{text:ct===!0?Ye.length>0?`AI Visibility checks and Research use your provider account.`:`ChatGPT in Chrome runs AI Visibility checks. Query Research needs an API provider.`:lt?`OpenRouter is connected. Choose the models your AI Visibility checks ask. You can save queries now.`:ut?`AI Visibility checks need an AI engine. You can save queries now and connect one later.`:`Checking connected AI engines. You can choose queries meanwhile.`})]}),ct===!0&&(Ye.length>0||st===!0)?(0,q.jsxs)(`ul`,{"aria-label":`Connected AI engines`,className:`divide-y divide-default rounded-lg border border-default`,children:[Ye.map(e=>{let t=On(e.name),n=e.displayName??e.name;return(0,q.jsxs)(`li`,{className:`flex min-h-11 items-center justify-between gap-3 px-3.5 py-2 text-sm`,title:t?We(e.name):void 0,children:[(0,q.jsx)(`span`,{className:`min-w-0 truncate text-heading`,children:t?n.replace(/ via OpenRouter$/,``):n}),(0,q.jsx)(`span`,{className:`shrink-0 text-secondary`,children:t?`OpenRouter`:e.model??``})]},e.name)}),Ye.length===0?(0,q.jsx)(`li`,{className:`flex min-h-11 items-center px-3.5 py-2 text-sm text-heading`,children:`ChatGPT in Chrome`}):null]}):null,dt?mt?(0,q.jsx)(dd,{inline:!0,catalog:mt,selected:Be,onAdd:e=>Fn({providers:e,providerModels:{}})}):pt.isPending?(0,q.jsx)(`p`,{role:`status`,className:`text-sm text-secondary`,children:`Loading OpenRouter models…`}):(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-negative`,children:`Couldn't load OpenRouter's model list.`}),(0,q.jsx)(W,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{pt.refetch()},children:`Retry`})]}):null,ut||jt?zt?(0,q.jsx)(`div`,{children:(0,q.jsx)(ed,{compact:!0,leadingField:(0,q.jsxs)(`div`,{className:`min-w-0 space-y-1.5`,children:[(0,q.jsx)(`label`,{className:`block text-sm font-medium text-secondary`,htmlFor:`setup-provider`,children:`Provider to connect`}),(0,q.jsx)(`select`,{ref:At,id:`setup-provider`,className:`setup-input`,value:zt.name,onChange:e=>{e.target.value!==zt.name&&(kt.current=document.activeElement===e.currentTarget,Ot(e.target.value))},children:Rt.map(e=>(0,q.jsx)(`option`,{value:e.name,children:e.displayName??e.name},e.name))})]}),secondaryActions:Un,offerFreeTier:ut,providerName:zt.name,keyUrl:zt.keyUrl,modelHint:zt.modelHint,onSaved:()=>{Mt(!1),r()}},zt.name)}):(0,q.jsx)(`p`,{className:`max-w-prose text-sm text-secondary`,children:Be.length>0?`This project's provider selection is ${Be.join(`, `)}. Configure an allowed provider in Settings, or change the selection in project Settings.`:`Provider configuration is unavailable here. Open Settings to connect an answer engine, then check again.`}):null,(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(ct===!0||lt)&&!jt&&zt?(0,q.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,className:`-ml-3 text-sm`,onClick:()=>Mt(!0),children:`Use a different provider`}):null,!zt||st===!0?(0,q.jsx)(W,{type:`button`,variant:`outline`,size:`sm`,asChild:!0,children:(0,q.jsx)(B,{to:`/settings`,target:`_blank`,rel:`noopener noreferrer`,children:`Open provider settings`})}):null,!Wn&&!dt?Un:null]})]}):(0,q.jsxs)(`section`,{"aria-labelledby":`setup-provider-heading`,className:`space-y-2 border-b border-default pb-6 mb-6`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,q.jsx)(`h2`,{id:`setup-provider-heading`,className:`text-lg font-semibold text-heading`,children:`AI engines`}),at?null:(0,q.jsxs)(`span`,{role:`status`,className:`flex items-center gap-2`,children:[(0,q.jsx)(xn,{tone:ct===!0?`positive`:`neutral`,children:ct===!0?`Ready`:ct===!1?`Not connected`:`Checking`}),(0,q.jsx)(Tr,{text:ct===!0?`An AI engine is available for this project. An administrator manages provider settings.`:ct===!1?`Ask an administrator to connect an AI engine for this project. You can save queries now.`:`Checking for a connected AI engine. An administrator manages provider settings. You can save queries now.`})]})]}),at?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-negative`,children:`Provider readiness could not be checked. Try again.`}):null,(0,q.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,className:Bd,disabled:nt.isFetching,onClick:()=>{nt.refetch()},children:at?`Retry provider check`:`Check again`})]}):null,qn=(()=>{switch(ae){case 0:return(0,q.jsxs)(Ar,{className:`surface-card step-card`,children:[(0,q.jsx)(`div`,{className:`section-head`,children:(0,q.jsx)(`div`,{children:(0,q.jsx)(`h2`,{children:`System check`})})}),(0,q.jsx)(`p`,{className:`supporting-copy`,children:`Checking that your Canonry instance is configured and reachable.`}),(0,q.jsx)(`div`,{className:`compact-stack`,children:d.healthChecks.map(e=>(0,q.jsxs)(`div`,{className:`health-check-row`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`run-row-title`,children:e.label}),(0,q.jsx)(`p`,{className:`supporting-copy`,children:e.id===`provider`&&f?`OpenRouter connected. Choose models before your first check.`:e.detail}),e.id===`provider`&&e.state!==`ready`&&(0,q.jsxs)(`div`,{className:`mt-3 rounded-md border border-default bg-bg-elevated/40 p-3 space-y-2`,children:[(0,q.jsxs)(`p`,{className:`text-xs text-secondary`,children:[`Paste a Gemini key to enable visibility checks (free at`,` `,(0,q.jsx)(`a`,{href:`https://aistudio.google.com/apikey`,target:`_blank`,rel:`noreferrer`,className:`text-positive-400 hover:text-positive underline underline-offset-2`,children:`aistudio.google.com`}),`).`]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`password`,value:pn,onChange:e=>mn(e.target.value),placeholder:`AI... (paste here)`,className:`flex-1 rounded-md border border-base bg-bg px-2.5 py-1.5 text-sm text-heading placeholder:text-faint focus:border-mono-600 focus:outline-none font-mono`,disabled:gn}),(0,q.jsx)(W,{type:`button`,size:`sm`,disabled:gn||!pn.trim(),onClick:Xn(Pn),children:gn?`Saving...`:`Save`})]}),vn&&(0,q.jsxs)(`div`,{role:`alert`,className:`space-y-1 text-xs text-negative`,children:[(0,q.jsx)(`p`,{children:vn}),(0,q.jsx)(`p`,{children:`Check that the key is complete, then retry Save.`})]}),(0,q.jsxs)(`p`,{className:`text-sm text-secondary`,children:[`Connect more answer engines later in`,` `,(0,q.jsx)(B,{to:`/settings`,className:`text-link hover:underline`,children:`Settings`}),`.`]}),c.providerStatuses.some(e=>e.name===`openrouter`)&&(0,q.jsxs)(`details`,{children:[(0,q.jsx)(`summary`,{className:`min-h-11 cursor-pointer py-3 text-sm text-link`,children:`Connect OpenRouter`}),(0,q.jsx)(ed,{providerName:`openrouter`,compact:!0,keyUrl:c.providerStatuses.find(e=>e.name===`openrouter`)?.keyUrl,onSaved:()=>{r()}})]})]})]}),(0,q.jsx)(xn,{tone:e.state===`ready`?`positive`:`caution`,title:e.id===`api`?li(u.apiStatus):e.id===`worker`?li(u.workerStatus):e.detail,children:e.state===`ready`?`Ready`:`Attention`})]},e.id))}),(0,q.jsxs)(`div`,{className:`setup-nav`,children:[d.launchState.blockedReason?(0,q.jsx)(`p`,{role:`status`,className:`supporting-copy text-negative`,children:d.launchState.blockedReason}):(0,q.jsx)(`span`,{}),(0,q.jsx)(W,{type:`button`,disabled:!p,title:d.launchState.blockedReason,onClick:()=>{y({flowVersion:1,onboardingSessionId:_,event:`onboarding.step_completed`,step:`system`,method:`automatic`},`onboarding.step_completed:system`),M(ne)},children:`Continue`})]})]});case 1:return(0,q.jsxs)(Ar,{className:`surface-card step-card`,children:[(0,q.jsxs)(`div`,{className:`section-head`,children:[(0,q.jsx)(`div`,{children:(0,q.jsx)(`h2`,{children:`Create project`})}),L?(0,q.jsx)(xn,{tone:`positive`,children:`Created`}):null]}),L?(0,q.jsxs)(`div`,{className:`compact-stack`,children:[(0,q.jsxs)(`p`,{className:`text-neutral`,children:[`Project `,(0,q.jsx)(`span`,{className:`text-heading font-medium`,children:L}),` created successfully.`]}),(0,q.jsxs)(`div`,{className:`setup-nav`,children:[(0,q.jsx)(W,{type:`button`,variant:`outline`,onClick:Ln,children:`Back`}),(0,q.jsx)(W,{type:`button`,onClick:()=>zn(`project`,2),children:`Continue`})]})]}):(0,q.jsxs)(`div`,{className:`compact-stack`,children:[(0,q.jsxs)(`div`,{className:`setup-field`,children:[(0,q.jsx)(`label`,{className:`setup-label`,htmlFor:`project-name`,children:`Project name`}),(0,q.jsx)(`input`,{id:`project-name`,className:`setup-input`,type:`text`,placeholder:`my-website`,value:ce,onChange:e=>le(e.target.value)}),bn&&bn!==ce?(0,q.jsxs)(`p`,{className:`supporting-copy`,children:[`Slug: `,bn]}):null]}),(0,q.jsxs)(`div`,{className:`setup-field`,children:[(0,q.jsx)(`label`,{className:`setup-label`,htmlFor:`display-name`,children:`Display name (optional)`}),(0,q.jsx)(`input`,{id:`display-name`,className:`setup-input`,type:`text`,placeholder:`My Website`,value:ue,onChange:e=>de(e.target.value)})]}),(0,q.jsxs)(`div`,{className:`setup-field`,children:[(0,q.jsx)(`label`,{className:`setup-label`,htmlFor:`domain`,children:`Canonical domain`}),(0,q.jsx)(`input`,{id:`domain`,className:`setup-input`,type:`text`,placeholder:`example.com`,value:fe,onChange:e=>pe(e.target.value)})]}),(0,q.jsxs)(`div`,{className:`setup-field-row`,children:[(0,q.jsxs)(`div`,{className:`setup-field`,children:[(0,q.jsx)(`label`,{className:`setup-label`,htmlFor:`country`,children:`Country`}),(0,q.jsx)(`input`,{id:`country`,className:`setup-input`,type:`text`,placeholder:`US`,maxLength:2,value:P,onChange:e=>me(e.target.value.toUpperCase())})]}),(0,q.jsxs)(`div`,{className:`setup-field`,children:[(0,q.jsx)(`label`,{className:`setup-label`,htmlFor:`language`,children:`Language`}),(0,q.jsx)(`input`,{id:`language`,className:`setup-input`,type:`text`,placeholder:`en`,maxLength:5,value:F,onChange:e=>I(e.target.value.toLowerCase())})]})]}),(0,q.jsxs)(`label`,{className:`flex items-start gap-3 rounded-md border border-default bg-surface p-3 cursor-pointer hover:border-strong`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 h-4 w-4 rounded border-strong bg-bg`,checked:he,onChange:e=>_e(e.target.checked)}),(0,q.jsxs)(`span`,{className:`flex-1`,children:[(0,q.jsx)(`span`,{className:`block text-sm text-heading`,children:`Auto-extract backlinks`}),(0,q.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.`,` `,(0,q.jsx)(B,{to:`/backlinks`,className:`text-positive-400 hover:text-positive underline underline-offset-2`,children:`Manage backlinks`})]})]})]}),Se?(0,q.jsx)(`p`,{className:`text-negative-400 text-sm`,children:Se}):null,(0,q.jsxs)(`div`,{className:`setup-nav`,children:[(0,q.jsx)(W,{type:`button`,variant:`outline`,onClick:Ln,children:`Back`}),(0,q.jsx)(W,{type:`button`,disabled:!bn||!fe||z,onClick:Xn(An),children:z?`Creating...`:`Create project`})]})]})]});case 2:return(0,q.jsxs)(Hn,{className:m?`visibility-setup-section step-card`:`surface-card step-card`,"aria-labelledby":`setup-queries-heading`,children:[(0,q.jsxs)(`div`,{className:`section-head`,children:[(0,q.jsx)(`div`,{children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`h2`,{id:`setup-queries-heading`,children:`Add queries`}),(0,q.jsx)(Tr,{text:`Queries your customers ask AI assistants, one per line. You can refine the list later.`})]})}),se?(0,q.jsx)(xn,{tone:`neutral`,children:`Loading`}):E.isError?(0,q.jsx)(xn,{tone:`negative`,children:`Load failed`}):Ae?(0,q.jsxs)(xn,{tone:`positive`,children:[Sn.length,` saved`]}):(0,q.jsxs)(xn,{tone:`neutral`,children:[Sn.length,` quer`,Sn.length===1?`y`:`ies`]})]}),(0,q.jsxs)(`div`,{className:`space-y-2 border-b border-default pb-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,q.jsx)(`div`,{className:`min-w-0 space-y-1`,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-semibold text-heading`,children:`Research queries with your agent`}),(0,q.jsx)(Tr,{text:`Ask your agent to compare answers and available sources with Canonry Research, then recommend queries. Research does not change your tracked queries.`})]})}),(0,q.jsx)(W,{type:`button`,variant:`outline`,size:`sm`,className:`shrink-0 self-start ${Bd}`,onClick:Xn(Vt),children:Pt?`Research prompt copied`:`Copy research prompt`})]}),(0,q.jsxs)(`details`,{open:It||void 0,className:`text-sm text-secondary`,children:[(0,q.jsx)(`summary`,{className:`min-h-9 cursor-pointer py-2 text-link pointer-coarse:py-3 max-md:py-3 ${Bd}`,children:`View agent prompt`}),(0,q.jsx)(`textarea`,{"aria-label":`Agent query research prompt`,readOnly:!0,className:`setup-textarea mt-2 w-full`,rows:8,value:Bt})]}),It?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-negative`,children:`Could not copy. Select and copy the prompt above.`}):null]}),se?(0,q.jsx)(`div`,{className:`rounded-md border border-default bg-bg-elevated/40 p-4 text-sm text-secondary`,role:`status`,children:`Loading saved queries…`}):E.isError?(0,q.jsxs)(`div`,{className:`compact-stack`,children:[(0,q.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.`}),(0,q.jsxs)(`div`,{className:`setup-nav`,children:[(0,q.jsx)(W,{type:`button`,variant:`outline`,onClick:m?Te:Ln,children:`Back`}),(0,q.jsx)(W,{type:`button`,onClick:()=>{E.refetch()},children:`Retry loading queries`})]})]}):Ae?(0,q.jsxs)(`div`,{className:`compact-stack`,children:[(0,q.jsx)(`ul`,{className:`detail-list`,children:Sn.map(e=>(0,q.jsx)(`li`,{children:e},e))}),(0,q.jsxs)(`div`,{className:`setup-nav`,children:[(0,q.jsx)(W,{type:`button`,variant:`outline`,onClick:m?Te:Ln,children:`Back`}),(0,q.jsx)(W,{type:`button`,variant:`outline`,onClick:()=>je(!1),children:`Edit queries`}),(0,q.jsx)(W,{type:`button`,onClick:()=>zn(`queries`,m?4:3,Sn.length),children:`Continue`})]})]}):(0,q.jsxs)(`div`,{className:`compact-stack`,children:[Ye.length>0?(0,q.jsxs)(`div`,{className:`compact-stack`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-muted text-xs uppercase tracking-wide`,children:[(0,q.jsx)(`span`,{className:`flex-1 border-t border-base`}),`auto-generate`,(0,q.jsx)(`span`,{className:`flex-1 border-t border-base`})]}),(0,q.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,q.jsxs)(`div`,{className:`setup-field flex-1`,children:[(0,q.jsx)(`label`,{className:`setup-label`,htmlFor:`gen-provider`,children:`Provider`}),(0,q.jsx)(`select`,{id:`gen-provider`,className:`setup-input`,value:gt,onChange:e=>vt(e.target.value),children:Ye.map(e=>(0,q.jsxs)(`option`,{value:e.name,children:[e.displayName??e.name,e.model&&!On(e.name)?` (${e.model})`:``]},e.name))})]}),(0,q.jsxs)(`div`,{className:`setup-field`,children:[(0,q.jsx)(`label`,{className:`setup-label`,htmlFor:`gen-count`,children:`Count`}),(0,q.jsx)(`select`,{id:`gen-count`,className:`setup-input`,value:yt,onChange:e=>bt(Number(e.target.value)),children:[3,5,10,15,20].map(e=>(0,q.jsx)(`option`,{value:e,children:e},e))})]}),(0,q.jsx)(W,{type:`button`,variant:`outline`,disabled:xt||!gt,onClick:Xn(Mn),children:xt?`Analyzing site...`:`Generate`})]}),wt?(0,q.jsx)(`p`,{className:`text-negative-400 text-sm`,children:wt}):null]}):null,m?null:(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-muted text-xs uppercase tracking-wide`,children:[(0,q.jsx)(`span`,{className:`flex-1 border-t border-base`}),`or type manually`,(0,q.jsx)(`span`,{className:`flex-1 border-t border-base`})]}),(0,q.jsxs)(`div`,{className:`setup-field`,children:[(0,q.jsx)(`label`,{className:`setup-label`,htmlFor:`queries`,children:`Queries (one per line)`}),(0,q.jsx)(`textarea`,{id:`queries`,className:`setup-textarea`,rows:6,placeholder:`emergency dentist brooklyn
42
42
  best invisalign downtown brooklyn
43
43
  pediatric dentist brooklyn heights`,value:Oe,onChange:e=>ke(e.target.value)})]}),Me?(0,q.jsx)(`p`,{className:`text-negative-400 text-sm`,children:Me}):null,(0,q.jsxs)(`div`,{className:`setup-nav`,children:[(0,q.jsx)(W,{type:`button`,variant:`outline`,onClick:m?Te:Ln,children:`Back`}),(0,q.jsx)(W,{type:`button`,variant:`ghost`,onClick:Bn,children:m?`Finish without AI Visibility`:`Skip for now`}),(0,q.jsx)(W,{type:`button`,disabled:Sn.length===0||Ie,onClick:Xn(jn),children:Ie?`Saving...`:`Save ${Sn.length} quer${Sn.length===1?`y`:`ies`}`})]})]})]});case 3:return(0,q.jsxs)(Ar,{className:`surface-card step-card`,children:[(0,q.jsxs)(`div`,{className:`section-head`,children:[(0,q.jsx)(`div`,{children:(0,q.jsx)(`h2`,{children:`Add competitors`})}),Ut?(0,q.jsx)(xn,{tone:`positive`,children:`Saved`}):null]}),(0,q.jsx)(`p`,{className:`supporting-copy`,children:`Optional. Domains that compete for the same queries, one per line. You can add them later from the project.`}),Ut?(0,q.jsxs)(`div`,{className:`compact-stack`,children:[(0,q.jsx)(`ul`,{className:`detail-list`,children:Cn.map(e=>(0,q.jsx)(`li`,{children:e},e))}),(0,q.jsxs)(`div`,{className:`setup-nav`,children:[(0,q.jsx)(W,{type:`button`,variant:`outline`,onClick:Ln,children:`Back`}),(0,q.jsx)(W,{type:`button`,onClick:()=>zn(`competitors`,4,Cn.length),children:`Continue`})]})]}):(0,q.jsxs)(`div`,{className:`compact-stack`,children:[(0,q.jsxs)(`div`,{className:`setup-field`,children:[(0,q.jsx)(`label`,{className:`setup-label`,htmlFor:`competitors`,children:`Competitor domains (one per line)`}),(0,q.jsx)(`textarea`,{id:`competitors`,className:`setup-textarea`,rows:4,placeholder:`competitor1.com
44
- competitor2.com`,value:Ht,onChange:e=>V(e.target.value)})]}),Gt?(0,q.jsx)(`p`,{className:`text-negative-400 text-sm`,children:Gt}):null,(0,q.jsxs)(`div`,{className:`setup-nav`,children:[(0,q.jsx)(W,{type:`button`,variant:`outline`,onClick:Ln,children:`Back`}),(0,q.jsx)(`div`,{className:`flex gap-2`,children:Cn.length===0?(0,q.jsx)(W,{type:`button`,onClick:Vn,children:`Continue without competitors`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(W,{type:`button`,variant:`outline`,onClick:Vn,children:`Skip`}),(0,q.jsx)(W,{type:`button`,disabled:Jt,onClick:Xn(Nn),children:Jt?`Saving...`:`Save ${Cn.length} competitor${Cn.length===1?``:`s`}`})]})})]})]})]});case 4:{let e=fn.data,t=e?.status??(ln===k?.id?k.status:void 0),n=t===`completed`||t===`partial`||t===`failed`||t===`cancelled`,r=e?.snapshots??[],i=e?.queryCounts,a=t?Ud(t,r.length):!1,c=A&&!tn,u=sn??(e?.error?Gn(e.error):t===`cancelled`?`The check was cancelled before it produced a baseline.`:(t===`completed`||t===`partial`)&&r.length===0?`The check finished without producing any snapshots.`:k?.statusDetail||`The check did not produce a baseline.`),d=null;return c||a?d=(0,q.jsx)(xn,{tone:`positive`,children:`Complete`}):sn&&!tn?d=(0,q.jsx)(xn,{tone:`negative`,children:`Failed`}):n?d=(0,q.jsx)(xn,{tone:`negative`,children:t===`cancelled`?`Cancelled`:`Failed`}):tn&&(d=(0,q.jsx)(xn,{tone:`caution`,children:`Running`})),(0,q.jsxs)(Ar,{className:`surface-card step-card`,children:[(0,q.jsxs)(`div`,{className:`section-head`,children:[(0,q.jsx)(`div`,{children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`h2`,{children:_t()?`AI Visibility`:`Run your first AI Visibility check`}),_t()?null:(0,q.jsx)(Tr,{text:`Asks each AI engine your queries and records whether ${L??`your site`} is mentioned and cited. It uses your provider account. You can also finish now and run it later from the project.`})]})}),d]}),c?(0,q.jsxs)(`div`,{className:`compact-stack`,children:[(0,q.jsxs)(`p`,{className:`text-secondary`,children:[`Setup is complete. `,(0,q.jsx)(`span`,{className:`text-strong font-medium`,children:L}),` already has a successful answer-visibility baseline.`]}),(0,q.jsxs)(`div`,{className:`setup-nav`,children:[(0,q.jsx)(`span`,{}),(0,q.jsx)(W,{type:`button`,onClick:()=>Ee(),children:o?`Finish setup`:`Open project dashboard →`})]})]}):!tn&&_t()?(0,q.jsxs)(`div`,{className:`compact-stack`,children:[L?(0,q.jsx)(Ps,{projectName:L}):(0,q.jsx)(`p`,{className:`text-sm text-secondary`,children:Os}),sn&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-negative`,children:sn}),(0,q.jsxs)(`div`,{className:`setup-nav`,children:[(0,q.jsx)(`span`,{}),(0,q.jsx)(W,{type:`button`,onClick:Te,children:`Open project dashboard →`})]})]}):tn?n?a?(0,q.jsxs)(`div`,{className:`compact-stack`,children:[(0,q.jsxs)(`p`,{className:`text-neutral`,children:[`Check complete. Your first AI Visibility snapshot for`,` `,(0,q.jsx)(`span`,{className:`text-heading font-medium`,children:L}),`:`]}),(0,q.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 mt-1`,children:[(0,q.jsxs)(`div`,{className:`rounded-md border border-default bg-surface p-3`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-secondary`,children:`Mentioned`}),(0,q.jsx)(`p`,{className:`text-2xl font-bold tabular-nums text-primary mt-1`,children:i?(0,q.jsxs)(q.Fragment,{children:[i.mentionedQueries,(0,q.jsxs)(`span`,{className:`text-faint text-lg`,children:[` / `,i.totalQueries]})]}):`Unavailable`}),(0,q.jsx)(`p`,{className:`mt-0.5 text-sm text-secondary`,children:`queries naming your brand`})]}),(0,q.jsxs)(`div`,{className:`rounded-md border border-default bg-surface p-3`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-secondary`,children:`Cited`}),(0,q.jsx)(`p`,{className:`text-2xl font-bold tabular-nums text-primary mt-1`,children:i?(0,q.jsxs)(q.Fragment,{children:[i.citedQueries,(0,q.jsxs)(`span`,{className:`text-faint text-lg`,children:[` / `,i.totalQueries]})]}):`Unavailable`}),(0,q.jsx)(`p`,{className:`mt-0.5 text-sm text-secondary`,children:`queries citing your site`})]}),(0,q.jsxs)(`div`,{className:`rounded-md border border-default bg-surface p-3`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-secondary`,children:`Results`}),(0,q.jsx)(`p`,{className:`text-2xl font-bold tabular-nums text-primary mt-1`,children:r.length}),(0,q.jsx)(`p`,{className:`mt-0.5 text-sm text-secondary`,children:`completed engine checks`})]})]}),!s&&L?(0,q.jsx)($u,{projectName:L}):null,(0,q.jsxs)(`div`,{className:`setup-nav`,children:[(0,q.jsx)(`span`,{}),(0,q.jsx)(W,{type:`button`,onClick:()=>Ee(),children:o?`Finish setup`:`Open project dashboard →`})]})]}):(0,q.jsxs)(`div`,{className:`compact-stack`,children:[(0,q.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative`,children:[(0,q.jsx)(`p`,{children:u}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-secondary`,children:_t()?Os:l?`Fix provider or query configuration if needed, then retry without leaving setup.`:`Ask an administrator to review the provider and query configuration.`})]}),(0,q.jsxs)(`div`,{className:`setup-nav`,children:[l&&!_t()?(0,q.jsx)(W,{type:`button`,variant:`outline`,asChild:!0,children:(0,q.jsx)(B,{to:`/settings`,children:`Configure providers`})}):(0,q.jsx)(`span`,{}),_t()||!l?(0,q.jsx)(W,{type:`button`,onClick:Te,children:`Open project dashboard →`}):(0,q.jsx)(W,{type:`button`,disabled:an||!!En,onClick:Xn(In),children:an?`Retrying…`:`Retry check`})]})]}):(0,q.jsxs)(`div`,{className:`compact-stack`,children:[(0,q.jsx)(`p`,{className:`text-neutral`,children:`Check running. This usually takes 30 to 60 seconds.`}),(0,q.jsx)(`div`,{className:`rounded-md border border-default bg-surface p-3 text-xs text-muted`,children:(0,q.jsxs)(`p`,{children:[`Status: `,(0,q.jsx)(`span`,{className:`text-neutral`,children:t??`queued`})]})}),fn.isError&&(0,q.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative`,children:[(0,q.jsx)(`p`,{children:fn.error instanceof Error?fn.error.message:`Could not refresh the check status.`}),(0,q.jsx)(W,{type:`button`,variant:`outline`,size:`sm`,className:`mt-2`,onClick:()=>{fn.refetch()},children:`Retry status check`})]}),(0,q.jsxs)(`div`,{className:`setup-nav`,children:[(0,q.jsx)(`span`,{}),(0,q.jsx)(W,{type:`button`,variant:`outline`,onClick:o?()=>Ee():Te,children:o?`Finish setup`:`Watch on project page`})]})]}):(0,q.jsxs)(`div`,{className:`compact-stack`,children:[(0,q.jsxs)(`p`,{className:`text-sm text-secondary`,children:[(0,q.jsx)(`span`,{className:`font-mono tabular-nums text-heading`,children:Sn.length}),` `,Sn.length===1?`query`:`queries`,ht>0?(0,q.jsxs)(q.Fragment,{children:[` · `,(0,q.jsx)(`span`,{className:`font-mono tabular-nums text-heading`,children:ht}),` `,ht===1?`engine`:`engines`]}):null]}),(En||sn)&&(0,q.jsx)(`div`,{role:`alert`,className:`rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative`,children:(0,q.jsx)(`p`,{children:sn??En})}),(0,q.jsxs)(`div`,{className:`setup-nav`,children:[(0,q.jsx)(W,{type:`button`,variant:`outline`,onClick:Ln,children:`Back`}),(0,q.jsx)(W,{type:`button`,variant:`ghost`,onClick:De,children:`Finish without running`}),Tn===`no_provider`&&!m?(0,q.jsx)(W,{type:`button`,asChild:!0,children:(0,q.jsx)(B,{to:`/settings`,children:`Configure a provider`})}):(0,q.jsx)(W,{type:`button`,disabled:an||!!En,title:En,onClick:Xn(In),children:an?`Starting…`:sn?`Retry check`:`Run check`})]})]})]})}default:return null}})();return(0,q.jsxs)(`div`,{className:m?`page-container visibility-setup`:`page-container`,children:[o?(0,q.jsx)(Zu,{current:`visibility`,outcomes:{site:T,fixes:T}}):null,(0,q.jsxs)(`div`,{className:`page-header`,children:[(0,q.jsxs)(`div`,{className:`page-header-left`,children:[(0,q.jsx)(`h1`,{ref:i?a:void 0,tabIndex:i?-1:void 0,className:`page-title outline-none`,children:i?`Set up AI Visibility`:`Setup`}),(0,q.jsx)(`p`,{className:`page-subtitle`,children:i?`Connect an AI engine, then choose queries for your first check.`:`Create a project and run its first visibility check.`})]}),o?(0,q.jsx)(`div`,{className:`page-header-right`,children:(0,q.jsx)(W,{type:`button`,variant:`outline`,className:Bd,onClick:De,children:`Skip AI Visibility`})}):null]}),o?null:(0,q.jsx)(qd,{current:m?+(ae===4):ae,labels:m?Hd:Vd}),(0,q.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-2 text-[13px] text-secondary`,children:[(0,q.jsx)(`p`,{children:`Draft fields use tab storage when available. Credentials are excluded from drafts.`}),(0,q.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,disabled:!!C&&!E.isSuccess||z||Ie||Jt||an,onClick:Xt,children:`Reset unsaved fields`})]}),(0,q.jsxs)(`section`,{className:`setup-wizard`,children:[Kn,ae===4&&!tn&&l&&f&&ye&&!dt&&(0,q.jsx)(yd,{project:ye,onSave:Fn}),qn]})]})}var Zd=`modulepreload`,Qd=function(e,t){return new URL(e,t).href},$d={},ef=function(e){return e.pathname.endsWith(`.css`)},tf=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},nf=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=Qd(t,n);let r=s(t),i=ef(r);return tf($d,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:Zd,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},rf=(0,K.lazy)(async()=>({default:(await nf(()=>import(`./SiteHealthSection-D8D2mIsJ.js`).then(e=>e.n),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]),import.meta.url)).SiteHealthSection})),af=`Public pages only, crawled from this computer and stored locally. The first scan reads up to 100 pages, then stops.`,of=1800,sf=`https://github.com/Canonry/canonry#or-use-any-shell-capable-coding-agent`,cf=`Use the official Canonry docs:
44
+ competitor2.com`,value:Ht,onChange:e=>V(e.target.value)})]}),Gt?(0,q.jsx)(`p`,{className:`text-negative-400 text-sm`,children:Gt}):null,(0,q.jsxs)(`div`,{className:`setup-nav`,children:[(0,q.jsx)(W,{type:`button`,variant:`outline`,onClick:Ln,children:`Back`}),(0,q.jsx)(`div`,{className:`flex gap-2`,children:Cn.length===0?(0,q.jsx)(W,{type:`button`,onClick:Vn,children:`Continue without competitors`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(W,{type:`button`,variant:`outline`,onClick:Vn,children:`Skip`}),(0,q.jsx)(W,{type:`button`,disabled:Jt,onClick:Xn(Nn),children:Jt?`Saving...`:`Save ${Cn.length} competitor${Cn.length===1?``:`s`}`})]})})]})]})]});case 4:{let e=fn.data,t=e?.status??(ln===k?.id?k.status:void 0),n=t===`completed`||t===`partial`||t===`failed`||t===`cancelled`,r=e?.snapshots??[],i=e?.queryCounts,a=t?Ud(t,r.length):!1,c=A&&!tn,u=sn??(e?.error?Gn(e.error):t===`cancelled`?`The check was cancelled before it produced a baseline.`:(t===`completed`||t===`partial`)&&r.length===0?`The check finished without producing any snapshots.`:k?.statusDetail||`The check did not produce a baseline.`),d=null;return c||a?d=(0,q.jsx)(xn,{tone:`positive`,children:`Complete`}):sn&&!tn?d=(0,q.jsx)(xn,{tone:`negative`,children:`Failed`}):n?d=(0,q.jsx)(xn,{tone:`negative`,children:t===`cancelled`?`Cancelled`:`Failed`}):tn&&(d=(0,q.jsx)(xn,{tone:`caution`,children:`Running`})),(0,q.jsxs)(Ar,{className:`surface-card step-card`,children:[(0,q.jsxs)(`div`,{className:`section-head`,children:[(0,q.jsx)(`div`,{children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`h2`,{children:_t()?`AI Visibility`:`Run your first AI Visibility check`}),_t()?null:(0,q.jsx)(Tr,{text:`Asks each AI engine your queries and records whether ${L??`your site`} is mentioned and cited. It uses your provider account. You can also finish now and run it later from the project.`})]})}),d]}),c?(0,q.jsxs)(`div`,{className:`compact-stack`,children:[(0,q.jsxs)(`p`,{className:`text-secondary`,children:[`Setup is complete. `,(0,q.jsx)(`span`,{className:`text-strong font-medium`,children:L}),` already has a successful answer-visibility baseline.`]}),(0,q.jsxs)(`div`,{className:`setup-nav`,children:[(0,q.jsx)(`span`,{}),(0,q.jsx)(W,{type:`button`,onClick:()=>Ee(),children:o?`Finish setup`:`Open project dashboard →`})]})]}):!tn&&_t()?(0,q.jsxs)(`div`,{className:`compact-stack`,children:[L?(0,q.jsx)(Ps,{projectName:L}):(0,q.jsx)(`p`,{className:`text-sm text-secondary`,children:Os}),sn&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-negative`,children:sn}),(0,q.jsxs)(`div`,{className:`setup-nav`,children:[(0,q.jsx)(`span`,{}),(0,q.jsx)(W,{type:`button`,onClick:Te,children:`Open project dashboard →`})]})]}):tn?n?a?(0,q.jsxs)(`div`,{className:`compact-stack`,children:[(0,q.jsxs)(`p`,{className:`text-neutral`,children:[`Check complete. Your first AI Visibility snapshot for`,` `,(0,q.jsx)(`span`,{className:`text-heading font-medium`,children:L}),`:`]}),(0,q.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 mt-1`,children:[(0,q.jsxs)(`div`,{className:`rounded-md border border-default bg-surface p-3`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-secondary`,children:`Mentioned`}),(0,q.jsx)(`p`,{className:`text-2xl font-bold tabular-nums text-primary mt-1`,children:i?(0,q.jsxs)(q.Fragment,{children:[i.mentionedQueries,(0,q.jsxs)(`span`,{className:`text-faint text-lg`,children:[` / `,i.totalQueries]})]}):`Unavailable`}),(0,q.jsx)(`p`,{className:`mt-0.5 text-sm text-secondary`,children:`queries naming your brand`})]}),(0,q.jsxs)(`div`,{className:`rounded-md border border-default bg-surface p-3`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-secondary`,children:`Cited`}),(0,q.jsx)(`p`,{className:`text-2xl font-bold tabular-nums text-primary mt-1`,children:i?(0,q.jsxs)(q.Fragment,{children:[i.citedQueries,(0,q.jsxs)(`span`,{className:`text-faint text-lg`,children:[` / `,i.totalQueries]})]}):`Unavailable`}),(0,q.jsx)(`p`,{className:`mt-0.5 text-sm text-secondary`,children:`queries citing your site`})]}),(0,q.jsxs)(`div`,{className:`rounded-md border border-default bg-surface p-3`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-secondary`,children:`Results`}),(0,q.jsx)(`p`,{className:`text-2xl font-bold tabular-nums text-primary mt-1`,children:r.length}),(0,q.jsx)(`p`,{className:`mt-0.5 text-sm text-secondary`,children:`completed engine checks`})]})]}),!s&&L?(0,q.jsx)($u,{projectName:L}):null,(0,q.jsxs)(`div`,{className:`setup-nav`,children:[(0,q.jsx)(`span`,{}),(0,q.jsx)(W,{type:`button`,onClick:()=>Ee(),children:o?`Finish setup`:`Open project dashboard →`})]})]}):(0,q.jsxs)(`div`,{className:`compact-stack`,children:[(0,q.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative`,children:[(0,q.jsx)(`p`,{children:u}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-secondary`,children:_t()?Os:l?`Fix provider or query configuration if needed, then retry without leaving setup.`:`Ask an administrator to review the provider and query configuration.`})]}),(0,q.jsxs)(`div`,{className:`setup-nav`,children:[l&&!_t()?(0,q.jsx)(W,{type:`button`,variant:`outline`,asChild:!0,children:(0,q.jsx)(B,{to:`/settings`,children:`Configure providers`})}):(0,q.jsx)(`span`,{}),_t()||!l?(0,q.jsx)(W,{type:`button`,onClick:Te,children:`Open project dashboard →`}):(0,q.jsx)(W,{type:`button`,disabled:an||!!En,onClick:Xn(In),children:an?`Retrying…`:`Retry check`})]})]}):(0,q.jsxs)(`div`,{className:`compact-stack`,children:[(0,q.jsx)(`p`,{className:`text-neutral`,children:`Check running. This usually takes 30 to 60 seconds.`}),(0,q.jsx)(`div`,{className:`rounded-md border border-default bg-surface p-3 text-xs text-muted`,children:(0,q.jsxs)(`p`,{children:[`Status: `,(0,q.jsx)(`span`,{className:`text-neutral`,children:t??`queued`})]})}),fn.isError&&(0,q.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative`,children:[(0,q.jsx)(`p`,{children:fn.error instanceof Error?fn.error.message:`Could not refresh the check status.`}),(0,q.jsx)(W,{type:`button`,variant:`outline`,size:`sm`,className:`mt-2`,onClick:()=>{fn.refetch()},children:`Retry status check`})]}),(0,q.jsxs)(`div`,{className:`setup-nav`,children:[(0,q.jsx)(`span`,{}),(0,q.jsx)(W,{type:`button`,variant:`outline`,onClick:o?()=>Ee():Te,children:o?`Finish setup`:`Watch on project page`})]})]}):(0,q.jsxs)(`div`,{className:`compact-stack`,children:[(0,q.jsxs)(`p`,{className:`text-sm text-secondary`,children:[(0,q.jsx)(`span`,{className:`font-mono tabular-nums text-heading`,children:Sn.length}),` `,Sn.length===1?`query`:`queries`,ht>0?(0,q.jsxs)(q.Fragment,{children:[` · `,(0,q.jsx)(`span`,{className:`font-mono tabular-nums text-heading`,children:ht}),` `,ht===1?`engine`:`engines`]}):null]}),(En||sn)&&(0,q.jsx)(`div`,{role:`alert`,className:`rounded-md border border-negative bg-negative-soft p-3 text-sm text-negative`,children:(0,q.jsx)(`p`,{children:sn??En})}),(0,q.jsxs)(`div`,{className:`setup-nav`,children:[(0,q.jsx)(W,{type:`button`,variant:`outline`,onClick:Ln,children:`Back`}),(0,q.jsx)(W,{type:`button`,variant:`ghost`,onClick:De,children:`Finish without running`}),Tn===`no_provider`&&!m?(0,q.jsx)(W,{type:`button`,asChild:!0,children:(0,q.jsx)(B,{to:`/settings`,children:`Configure a provider`})}):(0,q.jsx)(W,{type:`button`,disabled:an||!!En,title:En,onClick:Xn(In),children:an?`Starting…`:sn?`Retry check`:`Run check`})]})]})]})}default:return null}})();return(0,q.jsxs)(`div`,{className:m?`page-container visibility-setup`:`page-container`,children:[o?(0,q.jsx)(Zu,{current:`visibility`,outcomes:{site:T,fixes:T}}):null,(0,q.jsxs)(`div`,{className:`page-header`,children:[(0,q.jsxs)(`div`,{className:`page-header-left`,children:[(0,q.jsx)(`h1`,{ref:i?a:void 0,tabIndex:i?-1:void 0,className:`page-title outline-none`,children:i?`Set up AI Visibility`:`Setup`}),(0,q.jsx)(`p`,{className:`page-subtitle`,children:i?`Connect an AI engine, then choose queries for your first check.`:`Create a project and run its first visibility check.`})]}),o?(0,q.jsx)(`div`,{className:`page-header-right`,children:(0,q.jsx)(W,{type:`button`,variant:`outline`,className:Bd,onClick:De,children:`Skip AI Visibility`})}):null]}),o?null:(0,q.jsx)(qd,{current:m?+(ae===4):ae,labels:m?Hd:Vd}),(0,q.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-2 text-[13px] text-secondary`,children:[(0,q.jsx)(`p`,{children:`Draft fields use tab storage when available. Credentials are excluded from drafts.`}),(0,q.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,disabled:!!C&&!E.isSuccess||z||Ie||Jt||an,onClick:Xt,children:`Reset unsaved fields`})]}),(0,q.jsxs)(`section`,{className:`setup-wizard`,children:[Kn,ae===4&&!tn&&l&&f&&ye&&!dt&&(0,q.jsx)(yd,{project:ye,onSave:Fn}),qn]})]})}var Zd=`modulepreload`,Qd=function(e,t){return new URL(e,t).href},$d={},ef=function(e){return e.pathname.endsWith(`.css`)},tf=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},nf=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=Qd(t,n);let r=s(t),i=ef(r);return tf($d,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:Zd,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},rf=(0,K.lazy)(async()=>({default:(await nf(()=>import(`./SiteHealthSection-CGKKUtqQ.js`).then(e=>e.n),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]),import.meta.url)).SiteHealthSection})),af=`Public pages only, crawled from this computer and stored locally. The first scan reads up to 100 pages, then stops.`,of=1800,sf=`https://github.com/Canonry/canonry#or-use-any-shell-capable-coding-agent`,cf=`Use the official Canonry docs:
45
45
  - Agent quickstart: https://github.com/Canonry/canonry#or-use-any-shell-capable-coding-agent
46
46
  - CLI reference: https://github.com/Canonry/canonry/blob/main/skills/canonry/references/canonry-cli.md
47
47
  - Plugin setup: https://github.com/Canonry/canonry/blob/main/docs/plugins.md
@@ -57,4 +57,4 @@ ${cf}Pick one path and stay on it. Use connected Canonry tools (plugin or MCP) o
57
57
  4. List projects with the connected project tool or \`cnry project list --format json\`, and reuse one whose domain matches. Confirm the proposed name is not already assigned to a different domain. To find out whether a project has already been scanned, run \`cnry technical-aeo score <project> --format json\` with no \`--run-id\`, which reports the latest run. Read the \`hasData\` field, not the score: this command exits 0 and reports \`aggregateScore: 0\` for a project that has never been scanned, so reading the score alone would have you tell me my site scored zero. If \`hasData\` is true and \`runStatus\` is \`completed\` or \`partial\`, read that scan instead of starting a new one. If no project matches, show the exact create operation and wait for approval.
58
58
  5. Propose a bounded Site Health scan: \`--max-pages 100\` for a first look, plus whether dead-link checking is on (it is off unless you pass \`--check-dead-links\`). Show the connected operation or the exact \`cnry technical-aeo run <project> --max-pages 100 --wait --format json\` command with the project name filled in, and wait for separate approval before scanning. \`--wait\` polls for up to 15 minutes and returns only the run id and status. If the status it returns is still \`queued\` or \`running\`, the scan has not finished: do not rerun it or report results, poll \`cnry technical-aeo progress <project> --run-id <run-id> --format json\` until it is terminal. If \`--wait\` outruns your own tool timeout first, recover the run id with \`cnry technical-aeo score <project> --format json\` and poll the same way.
59
59
  6. When the run is \`completed\` or \`partial\`, read \`cnry technical-aeo crawl <project> --run-id <run-id> --format json\` first. It is the only one of these commands that carries \`termination\` and \`complete\`; the score and pages commands do not. Then read \`cnry technical-aeo score <project> --run-id <run-id> --format json\` and \`cnry technical-aeo pages <project> --run-id <run-id> --sort score-asc --limit 10 --format jsonl\`. Tell me the termination reason in plain words and whether the scan covered the whole site or stopped at a page, link, depth, or time limit. A \`partial\` run scored the pages it reached and not my site, so never present it as a full-site result. If it stopped early, the fix depends on the reason, so say which: a page or depth limit needs a larger budget, a time limit needs a smaller scan (a lower \`--max-pages\` or \`--max-depth\`). If the run failed or was cancelled, inspect the run error and stop.
60
- 7. Summarize only completed evidence, then propose AI Visibility setup. Ask before you add queries, connect providers, start a provider-backed or quota-consuming run, edit files, or publish.`;function uf(e,t){return e===`legacy`?`legacy`:e===`platform`?`platform`:t.state===`success`?t.projectCount===0?`platform`:`legacy`:t.state===`error`?`retry`:`loading`}var df=`pointer-coarse:min-h-11 max-md:min-h-11`,ff=`2000-01-01T00:00:00.000Z`,pf=5e3;function mf(e,t){let n=new Set,r=new Map;for(let e of t)e.trigger!==gn.probe&&(r.has(e.projectId)||r.set(e.projectId,e.id),(e.status===H.completed||e.status===H.partial)&&n.add(e.projectId));let i=(e.every(e=>e.createdAt)?[...e].sort((e,t)=>(e.createdAt??``).localeCompare(t.createdAt??``)||e.name.localeCompare(t.name)):e).find(e=>!n.has(e.id));return i?{projectName:i.name,runId:r.get(i.id)}:null}var hf=[{value:`US`,label:`United States`},{value:`CA`,label:`Canada`},{value:`GB`,label:`United Kingdom`},{value:`AU`,label:`Australia`},{value:`NZ`,label:`New Zealand`},{value:`IE`,label:`Ireland`},{value:`DE`,label:`Germany`},{value:`FR`,label:`France`},{value:`ES`,label:`Spain`},{value:`IT`,label:`Italy`},{value:`NL`,label:`Netherlands`},{value:`BR`,label:`Brazil`},{value:`MX`,label:`Mexico`},{value:`IN`,label:`India`},{value:`SG`,label:`Singapore`},{value:`JP`,label:`Japan`}],gf=[{value:`en`,label:`English`},{value:`es`,label:`Spanish`},{value:`fr`,label:`French`},{value:`de`,label:`German`},{value:`it`,label:`Italian`},{value:`pt`,label:`Portuguese`},{value:`nl`,label:`Dutch`},{value:`ja`,label:`Japanese`}];function _f(e,t){try{let n=new Intl.DisplayNames([`en`],{type:`region`}),r=new Intl.DisplayNames([`en`],{type:`language`}),i=e.length===2?n.of(e.toUpperCase()):void 0,a=t?r.of(t.toLowerCase()):void 0;return`${i??(e||`Country`)} · ${a??(t||`Language`)}`}catch{return`${e||`Country`} · ${t||`Language`}`}}function vf(e,t){let n=e.trim().toUpperCase(),r=t.trim().toLowerCase();return{countryValid:hf.some(e=>e.value===n),languageValid:gf.some(e=>e.value===r)}}function yf(e){let t=e.replace(/^\[|\]$/g,``);return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(t)||t.includes(`:`)}function bf(e){let t=e.trim();if(!t)return null;let n=/^[a-z][a-z\d+.-]*:\/\//i.test(t)?t:`https://${t}`,r;try{r=new URL(n)}catch{return null}if(r.protocol!==`http:`&&r.protocol!==`https:`)return null;let i=r.hostname.toLowerCase().replace(/^www\./,``);if(!i||i===`localhost`||yf(i)||!i.includes(`.`))return null;let a=i.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);return a?{canonicalDomain:i,projectName:a,displayName:i}:null}async function xf(e,t=of){let n,r=new Promise(e=>{n=setTimeout(()=>e({state:`timed-out`}),t)}),i=await Promise.race([e.then(e=>({state:`queued`,run:e})),r]);return n&&clearTimeout(n),i}function Sf(e,t){e.catch(()=>{$n({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:${t}`})})}function Cf(e){let t=(0,K.useRef)(en()).current,n=(0,K.useRef)(new Set);return{onboardingSessionId:t,emit:(0,K.useCallback)((t,r)=>{if(r){if(n.current.has(r))return;n.current.add(r)}nn({...t,surface:e,eventId:Pe()})},[e])}}function wf(e,t){return e instanceof Pt&&e.statusCode===409?`A project with this name already exists. Change the project name, or open the existing project.`:e instanceof Error&&e.message?e.message:t}function Tf(){return(0,q.jsxs)(`div`,{className:`page-container max-w-3xl`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,q.jsx)(`div`,{className:`page-header`,children:(0,q.jsxs)(`div`,{className:`page-header-left`,children:[(0,q.jsx)(`h1`,{className:`page-title`,children:`Preparing setup`}),(0,q.jsx)(`p`,{className:`page-subtitle`,children:`Checking the projects already on this install.`})]})}),(0,q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-default bg-surface p-4 text-sm text-secondary`,role:`status`,children:[(0,q.jsx)(O,{className:`size-4 motion-safe:animate-spin`,"aria-hidden":`true`}),`Loading projects…`]})]})}function Ef({onRetry:e}){return(0,q.jsxs)(`div`,{className:`page-container max-w-3xl`,children:[(0,q.jsx)(`div`,{className:`page-header`,children:(0,q.jsxs)(`div`,{className:`page-header-left`,children:[(0,q.jsx)(`h1`,{className:`page-title`,children:`Can’t load projects`}),(0,q.jsx)(`p`,{className:`page-subtitle`,children:`Canonry could not confirm whether this install already has a project.`})]})}),(0,q.jsxs)(`div`,{className:`rounded-lg border border-negative bg-negative-soft p-4`,role:`alert`,tabIndex:-1,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-heading`,children:`Setup is paused to protect existing projects.`}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-secondary`,children:`Check the connection or sign in again, then retry.`}),(0,q.jsx)(W,{type:`button`,className:`mt-4`,variant:`secondary`,onClick:e,children:`Retry project check`})]})]})}function Df({projectName:e,initialRunId:t}){return(0,q.jsx)(dl,{title:`Site Health setup`,children:(0,q.jsx)(Of,{projectName:e,initialRunId:t})})}function Of({projectName:e,initialRunId:t}){let n=be(),r=R({...cr({client:U}),enabled:!!e,retry:!1,refetchOnMount:`always`}),{onboardingSessionId:i,emit:a}=Cf(`site_health`),[o]=(0,K.useState)(()=>tt(t));(0,K.useEffect)(()=>{o&&an()},[o]),(0,K.useEffect)(()=>{e&&a({flowVersion:1,onboardingSessionId:i,event:`onboarding.started`,step:`run`,resumed:!!t&&!o},`onboarding.started`)},[a,o,t,i,e]),(0,K.useEffect)(()=>{e&&t&&Fe(e)?.runId!==t&&Je(e,t)},[t,e]);let s=R({...ur({client:U,path:{id:t??``}}),enabled:!!t,refetchInterval:({state:e})=>{let t=e.data?.status;return t===`completed`||t===`partial`||t===`failed`||t===`cancelled`?!1:2e3},refetchIntervalInBackground:!0}).data?.status;if((0,K.useEffect)(()=>{if(!e||!t||!s)return;if(s===`completed`||s===`partial`){a({flowVersion:1,onboardingSessionId:i,event:`onboarding.step_completed`,step:`run`,method:`automatic`},`onboarding.step_completed:run`),Ke(t);return}if(s!==`failed`&&s!==`cancelled`)return;let n=s===`cancelled`?`run_cancelled`:`run_failed`;a({flowVersion:1,onboardingSessionId:i,event:`onboarding.blocked`,step:`run`,action:`retry_run`,reasonCode:n},`onboarding.blocked:run:${n}`),Ke(t)},[a,t,i,e,s]),!e)return(0,q.jsxs)(`div`,{className:`page-container max-w-3xl`,children:[(0,q.jsx)(`div`,{className:`page-header`,children:(0,q.jsxs)(`div`,{className:`page-header-left`,children:[(0,q.jsx)(`h1`,{className:`page-title`,children:`Project not found`}),(0,q.jsx)(`p`,{className:`page-subtitle`,children:`This setup link does not identify a project.`})]})}),(0,q.jsx)(W,{type:`button`,variant:`secondary`,onClick:()=>{n({to:`/projects`})},children:`View projects`})]});if(r.isPending)return(0,q.jsxs)(`div`,{className:`page-container max-w-3xl`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,q.jsx)(Zu,{current:`site`}),(0,q.jsxs)(`div`,{className:`mt-8 flex items-center gap-3 text-sm text-secondary`,role:`status`,children:[(0,q.jsx)(O,{className:`size-4 motion-safe:animate-spin`,"aria-hidden":`true`}),`Loading Site Health setup…`]})]});if(r.isError)return(0,q.jsxs)(`div`,{className:`page-container max-w-3xl`,children:[(0,q.jsx)(`div`,{className:`page-header`,children:(0,q.jsxs)(`div`,{className:`page-header-left`,children:[(0,q.jsx)(`h1`,{className:`page-title`,children:`Can’t resume setup`}),(0,q.jsx)(`p`,{className:`page-subtitle`,children:`Canonry could not load the project for this Site Health scan.`})]})}),(0,q.jsxs)(`div`,{className:`rounded-lg border border-negative bg-negative-soft p-4`,role:`alert`,children:[(0,q.jsx)(`p`,{className:`text-sm text-secondary`,children:`Check the connection or sign in again, then retry.`}),(0,q.jsx)(W,{type:`button`,className:`mt-4`,variant:`secondary`,onClick:()=>{r.refetch()},children:`Retry project check`})]})]});let c=r.data.find(t=>t.name===e);return c?(0,q.jsxs)(`div`,{className:`page-container max-w-7xl py-8 md:py-10`,children:[(0,q.jsx)(`h1`,{className:`sr-only`,children:`Set up Canonry`}),(0,q.jsx)(K.Suspense,{fallback:(0,q.jsxs)(`div`,{className:`space-y-5`,children:[(0,q.jsx)(Zu,{current:`site`}),(0,q.jsxs)(`div`,{className:`flex min-h-72 items-center justify-center gap-3 text-sm text-secondary`,role:`status`,children:[(0,q.jsx)(O,{className:`size-4 motion-safe:animate-spin`,"aria-hidden":`true`}),`Loading Site Health…`]})]}),children:(0,q.jsx)(rf,{projectName:c.name,projectId:c.id,initialRunId:t,onReleaseInitialRun:()=>{n({to:`/setup`,search:{onboarding:`site-health`,setupProject:c.name},replace:!0})},showOnboardingActions:!0,onContinueOnboarding:()=>{t||Nu(c.name),n({to:`/setup`,search:{experience:`legacy`,onboarding:`site-health`,setupProject:c.name},replace:!0})},onSkipOnboarding:()=>{t||Nu(c.name),a({flowVersion:1,onboardingSessionId:i,event:`onboarding.step_completed`,step:`run`,method:`skipped`},`onboarding.step_completed:run`),n({to:`/setup`,search:{onboarding:`complete`,setupProject:c.name,skipped:`visibility`},replace:!0})}})})]}):(0,q.jsxs)(`div`,{className:`page-container max-w-3xl`,children:[(0,q.jsx)(`div`,{className:`page-header`,children:(0,q.jsxs)(`div`,{className:`page-header-left`,children:[(0,q.jsx)(`h1`,{className:`page-title`,children:`Project not found`}),(0,q.jsxs)(`p`,{className:`page-subtitle`,children:[`Canonry could not find `,e,`. It will not open a different project.`]})]})}),(0,q.jsx)(W,{type:`button`,variant:`secondary`,onClick:()=>{n({to:`/projects`})},children:`View projects`})]})}function kf(){let e=xe({from:`/setup`}),t=e.onboarding===`site-health`&&!e.setupProject,n=e.onboarding===`site-health`&&e.experience!==`legacy`,r=pn(),i=e.experience===`legacy`?`legacy`:e.experience===`platform`?`platform`:r,[a,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(void 0),l=R({...cr({client:U}),enabled:i===`auto`,retry:!1,refetchOnMount:`always`}),u=R({...fr({client:U,query:{kind:G[`site-audit`],since:ff,limit:pf}}),enabled:i===`auto`,retry:!1,refetchOnMount:`always`}),d=i===`auto`&&l.isSuccess&&l.isFetchedAfterMount&&l.data.length===0;(0,K.useEffect)(()=>{d&&o(!0)},[d]);let f=i===`auto`?l.isSuccess&&l.isFetchedAfterMount?{state:`success`,projectCount:l.data.length}:l.isError?{state:`error`}:{state:`loading`}:{state:`idle`},p=i===`legacy`?`legacy`:a||d?`platform`:uf(i,f);if(e.onboarding===`complete`&&e.setupProject)return(0,q.jsx)(Od,{projectName:e.setupProject,skippedVisibility:e.skipped===`visibility`});if(t||n)return(0,q.jsx)(Df,{projectName:e.setupProject,initialRunId:e.siteHealthRunId});let m=i===`auto`&&p===`legacy`&&!e.setupProject&&l.isSuccess;if(m&&s===void 0)return u.isError?c(null):u.isSuccess&&u.isFetchedAfterMount&&c(mf(l.data,u.data)),(0,q.jsx)(Tf,{});let h=m?s:null;return h?(0,q.jsx)(Af,{projectName:h.projectName,runId:h.runId}):p===`legacy`?(0,q.jsx)(Jd,{visibilityProjectName:e.setupProject,siteHealthOnboarding:e.onboarding===`site-health`,onboardingFinish:e.onboarding===`site-health`||e.onboarding===`first-run`}):p===`loading`?(0,q.jsx)(Tf,{}):p===`retry`?(0,q.jsx)(Ef,{onRetry:()=>{l.refetch()}}):(0,q.jsx)(jf,{onActivationStarted:()=>o(!0),skipSiteScan:e.siteScan===`skip`})}function Af({projectName:e,runId:t}){let n=be();return(0,K.useEffect)(()=>{n({to:`/setup`,search:{onboarding:`site-health`,setupProject:e,...t?{siteHealthRunId:t}:{}},replace:!0})},[n,e,t]),(0,q.jsx)(Tf,{})}function jf({onActivationStarted:e,skipSiteScan:t}){return(0,q.jsx)(dl,{title:`Site Health setup`,children:(0,q.jsx)(Mf,{onActivationStarted:e,skipSiteScan:t})})}function Mf({onActivationStarted:e,skipSiteScan:t}){let n=be(),r=ge(),i=Gu(),a=R({..._r({client:U}),retry:!1}),c=L(hr()),[u]=(0,K.useState)(()=>Au(`platform`)),[d,f]=(0,K.useState)(u.domain??``),[p,m]=(0,K.useState)(u.projectName??``),[g,_]=(0,K.useState)(u.displayName??``),[v,y]=(0,K.useState)(u.country??`US`),[b,x]=(0,K.useState)(u.language??`en`),[S,C]=(0,K.useState)(!1),[w,T]=(0,K.useState)(`idle`),[E,D]=(0,K.useState)(null),[ee,k]=(0,K.useState)(null),[A,j]=(0,K.useState)(!1),[te,ne]=(0,K.useState)(null),[re,ie]=(0,K.useState)(!1),ae=Tt(),M=jt(),N=a.isError?void 0:a.data,oe=typeof N?.enabled==`boolean`?N.enabled:null,se=c.isPending?c.variables.body.enabled:oe,[ce,le]=(0,K.useState)(null),ue=(0,K.useRef)(null),{onboardingSessionId:de,emit:fe}=Cf(`platform`);(0,K.useEffect)(()=>{fe({flowVersion:1,onboardingSessionId:de,event:`onboarding.started`,step:`project`,resumed:!1},`onboarding.started`)},[fe,de]),(0,K.useEffect)(()=>{E||ju(`platform`,{domain:d,projectName:p,displayName:g,country:v,language:b})},[E,d,p,g,v,b]);let pe=()=>{Mu(`platform`),f(``),m(``),_(``),y(`US`),x(`en`),C(!1),k(null),j(!1)},P=bf(d),me=p||P?.projectName||``,F=g||P?.displayName||``,I=w===`creating`||w===`dispatching`,he=ee??te,_e=_f(v,b),{countryValid:ve,languageValid:ye}=vf(v,b),xe=ve&&ye;(0,K.useEffect)(()=>{he&&ue.current?.focus()},[he]);let Se=(e,t)=>n({to:`/setup`,search:{...t?{siteHealthRunId:t}:{},onboarding:`site-health`,setupProject:e.name},replace:!0}),Ce=async e=>{T(`dispatching`),ne(null);try{let t=i.mutateAsync({projectName:e.name,projectId:e.id,projectLabel:e.displayName||e.name,suppressErrorToast:!0,body:{checkDeadLinks:!0,maxPages:100}}),n=await xf(t);if(n.state===`queued`){fe({flowVersion:1,onboardingSessionId:de,event:`run.requested`,origin:`dashboard_setup`,result:`queued`,kind:`site_health`,providerCountBucket:`0`,queryCountBucket:`0`}),lt(n.run.runId),await Se(e,n.run.runId);return}t.then(()=>{fe({flowVersion:1,onboardingSessionId:de,event:`run.requested`,origin:`dashboard_setup`,result:`queued`,kind:`site_health`,providerCountBucket:`0`,queryCountBucket:`0`})},e=>{fe({flowVersion:1,onboardingSessionId:de,event:`run.requested`,origin:`dashboard_setup`,result:`rejected`,kind:`site_health`,providerCountBucket:`0`,queryCountBucket:`0`,reasonCode:$e(e,`run_rejected`)})}),Sf(t,e.id),await Se(e)}catch(e){T(`recovery`),ne(wf(e,`The project was created, but the Site Health scan could not be started.`));let t=$e(e,`run_rejected`);fe({flowVersion:1,onboardingSessionId:de,event:`run.requested`,origin:`dashboard_setup`,result:`rejected`,kind:`site_health`,providerCountBucket:`0`,queryCountBucket:`0`,reasonCode:t}),fe({flowVersion:1,onboardingSessionId:de,event:`onboarding.blocked`,step:`run`,action:`retry_run`,reasonCode:t},`onboarding.blocked:run:${t}`)}},z=async i=>{if(i.preventDefault(),P&&(t||S)&&xe&&!I){T(`creating`),k(null),j(!1),ne(null);try{let i=await vt({name:me,displayName:F,canonicalDomain:P.canonicalDomain,country:v,language:b});if(e(),D(i),Mu(`platform`),fe({flowVersion:1,onboardingSessionId:de,event:`onboarding.step_completed`,step:`project`,method:`manual`},`onboarding.step_completed:project`),await r.invalidateQueries({queryKey:dr({client:U})}),t){Nu(i.name),await n({to:`/setup`,search:{experience:`legacy`,onboarding:`first-run`,setupProject:i.name},replace:!0});return}await Ce(i)}catch(t){T(`idle`);let n=t instanceof Pt&&t.statusCode===409;j(n),k(wf(t,`Could not create the project. Try again.`)),fe({flowVersion:1,onboardingSessionId:de,event:`onboarding.blocked`,step:`project`,action:`save`,reasonCode:$e(t,`project_create_failed`)},`onboarding.blocked:project`),n&&(e(),r.invalidateQueries({queryKey:dr({client:U})}))}}},we=()=>{E&&!I&&Ce(E)},Te=()=>{I||n({to:`/projects`})},Ee=async()=>{try{await navigator.clipboard.writeText(M?lf:lf.replace(cf,``)),ie(!0)}catch{$n({tone:`negative`,title:`Could not copy setup request`,detail:M?`Open the agent quickstart to continue with the CLI instead.`:`Check your browser’s clipboard permission and try again.`})}},De=async e=>{le(null);try{let t=await c.mutateAsync({client:U,body:{enabled:e}});r.setQueryData(Cr({client:U}),t),t.enabled!==e&&le(`The server kept telemetry ${t.enabled?`on`:`off`}. Check its telemetry settings.`)}catch{le(`Could not update telemetry. Try again.`)}};return E&&w===`recovery`?(0,q.jsxs)(`div`,{className:`page-container max-w-3xl`,children:[(0,q.jsx)(Zu,{current:`site`}),(0,q.jsx)(`div`,{className:`page-header mt-8`,children:(0,q.jsxs)(`div`,{className:`page-header-left`,children:[(0,q.jsx)(`h1`,{className:`page-title`,children:`Project created`}),(0,q.jsxs)(`p`,{className:`page-subtitle`,children:[E.displayName||E.name,` is ready. The Site Health scan needs another try.`]})]})}),(0,q.jsxs)(`div`,{ref:ue,className:`rounded-lg border border-negative bg-negative-soft p-4`,role:`alert`,tabIndex:-1,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-heading`,children:te}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-secondary`,children:`You can retry the scan or continue setup and retry from Site Health.`}),(0,q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-3`,children:[(0,q.jsx)(W,{type:`button`,onClick:we,children:`Retry Site Health scan`}),(0,q.jsx)(W,{type:`button`,variant:`secondary`,onClick:()=>{Se(E)},children:`Continue setup`})]})]})]}):(0,q.jsxs)(`div`,{className:`page-container max-w-xl py-8 md:py-12`,children:[t?null:(0,q.jsx)(Zu,{current:`site`}),(0,q.jsxs)(`header`,{className:`mb-8 ${t?``:`mt-8`}`,children:[(0,q.jsx)(`h1`,{id:`site-map-setup-title`,className:`text-2xl font-semibold tracking-[-0.025em] text-heading`,children:t?`Create a project`:`Scan your site`}),(0,q.jsx)(`p`,{className:`mt-2 max-w-lg text-sm leading-6 text-secondary`,children:t?`Add a public domain, then choose the queries you want to track. No site scan will run.`:`Enter your public website to see its pages, structure, internal links, and Technical AEO scores.`})]}),(0,q.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-2 text-[13px] text-secondary`,children:[(0,q.jsx)(`p`,{children:`Draft fields use tab storage when available. Scan permission resets on reload.`}),(0,q.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,disabled:I,onClick:pe,children:`Reset draft`})]}),(0,q.jsxs)(`form`,{"aria-labelledby":`site-map-setup-title`,className:`space-y-6`,onSubmit:Xn(z),noValidate:!0,children:[(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(`label`,{className:`text-sm font-medium text-heading`,htmlFor:`launchpad-domain`,children:`Website URL`}),(0,q.jsx)(`input`,{id:`launchpad-domain`,className:`h-10 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 md:h-9 md:text-sm ${df}`,type:`text`,inputMode:`url`,autoComplete:`url`,autoCapitalize:`none`,spellCheck:!1,required:!0,"aria-invalid":!(!d||P),"aria-describedby":d&&!P?`launchpad-domain-hint launchpad-domain-error`:`launchpad-domain-hint`,placeholder:`https://example.com`,value:d,onChange:e=>{f(e.target.value),k(null),j(!1)}}),(0,q.jsx)(`p`,{id:`launchpad-domain-hint`,className:`text-sm text-secondary`,children:t?(0,q.jsxs)(q.Fragment,{children:[`A public domain is still required.`,` `,(0,q.jsx)(B,{to:`/setup`,search:{experience:`platform`},className:`font-medium text-link underline-offset-4 hover:underline`,children:`Map with Site Health instead`})]}):(0,q.jsxs)(q.Fragment,{children:[`Only public pages are scanned.`,` `,(0,q.jsx)(B,{to:`/setup`,search:{experience:`platform`,onboarding:`first-run`,siteScan:`skip`},className:`font-medium text-link underline-offset-4 hover:underline`,children:`Set up without a site scan`})]})}),d&&!P?(0,q.jsx)(`p`,{id:`launchpad-domain-error`,className:`text-sm text-negative`,role:`alert`,children:`Enter a public domain, such as example.com.`}):null]}),(0,q.jsxs)(`details`,{className:`group border-y border-default`,children:[(0,q.jsxs)(`summary`,{className:`flex min-h-9 cursor-pointer list-none items-center justify-between gap-4 py-2 text-sm [&::-webkit-details-marker]:hidden ${df}`,children:[(0,q.jsx)(`span`,{className:`font-medium text-heading`,children:`Project name and locale`}),(0,q.jsxs)(`span`,{className:`flex items-center gap-2 text-secondary`,children:[_e,(0,q.jsx)(o,{className:`size-4 transition-transform group-open:rotate-180 motion-reduce:transition-none`,"aria-hidden":`true`})]})]}),(0,q.jsxs)(`div`,{className:`space-y-5 border-t border-default py-4`,children:[P?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`mb-3 text-sm font-medium text-heading`,children:`Project`}),(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(`label`,{className:`text-sm text-secondary`,htmlFor:`launchpad-project-name`,children:`Project name`}),(0,q.jsx)(`input`,{id:`launchpad-project-name`,className:`setup-input h-10`,type:`text`,value:me,onChange:e=>m(e.target.value)})]}),(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(`label`,{className:`text-sm text-secondary`,htmlFor:`launchpad-display-name`,children:`Display name`}),(0,q.jsx)(`input`,{id:`launchpad-display-name`,className:`setup-input h-10`,type:`text`,value:F,onChange:e=>_(e.target.value)})]})]})]}):null,(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`mb-3 text-sm font-medium text-heading`,children:`Locale`}),(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(`label`,{className:`text-sm text-secondary`,htmlFor:`launchpad-country`,children:`Country`}),(0,q.jsx)(`select`,{id:`launchpad-country`,className:`setup-input h-10`,value:v,onChange:e=>y(e.target.value),children:hf.map(e=>(0,q.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(`label`,{className:`text-sm text-secondary`,htmlFor:`launchpad-language`,children:`Language`}),(0,q.jsx)(`select`,{id:`launchpad-language`,className:`setup-input h-10`,value:b,onChange:e=>x(e.target.value),children:gf.map(e=>(0,q.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]})]})]})]}),t?null:(0,q.jsxs)(`p`,{className:`text-sm text-secondary`,children:[`First scan: up to `,100,` pages. A limited scan describes the pages reached, not the whole site.`]}),t?null:(0,q.jsxs)(`label`,{className:`flex min-h-11 cursor-pointer items-start gap-3 py-2`,children:[(0,q.jsx)(`input`,{className:`mt-0.5 size-4 shrink-0 rounded border-strong bg-bg`,type:`checkbox`,checked:S,onChange:e=>C(e.target.checked),"aria-label":`Allow Canonry to scan this public site.`}),(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-sm leading-5 text-heading`,children:`Allow Canonry to scan this public site.`}),(0,q.jsx)(Tr,{text:af})]})]}),he?(0,q.jsxs)(`div`,{ref:ue,className:`rounded-md border border-negative bg-negative-soft p-3`,role:`alert`,tabIndex:-1,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-heading`,children:he}),A?(0,q.jsx)(W,{type:`button`,variant:`secondary`,size:`sm`,className:`mt-3`,onClick:Te,children:`View projects`}):null]}):null,(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(W,{className:`w-full ${df}`,type:`submit`,disabled:!P||!t&&!S||!xe||I,children:w===`creating`||w===`dispatching`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(O,{className:`size-4 motion-safe:animate-spin`,"aria-hidden":`true`}),` `,t?`Creating project…`:`Mapping site…`]}):t?`Create project`:`Scan site`}),w===`dispatching`?(0,q.jsx)(`span`,{className:`text-center text-sm text-secondary`,role:`status`,children:`Opening Site Health when the scan is ready.`}):null]})]}),(0,q.jsxs)(`section`,{className:`mt-8 border-t border-default pt-6`,"aria-labelledby":`agent-setup-title`,children:[(0,q.jsx)(`p`,{id:`agent-setup-title`,className:`text-sm font-medium text-heading`,children:`Use your agent instead`}),(0,q.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-secondary`,children:ae?`Connect your agent to this instance, or copy a request for a new local installation.`:`Connect ChatGPT or Claude Desktop to this instance.`}),(0,q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1`,children:[(0,q.jsx)(W,{asChild:!0,variant:`secondary`,size:`sm`,children:(0,q.jsx)(B,{to:`/agent-setup`,children:`Agent setup`})}),ae?(0,q.jsxs)(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:Xn(Ee),children:[re?(0,q.jsx)(l,{className:`size-3.5`,"aria-hidden":`true`}):(0,q.jsx)(h,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{"aria-live":`polite`,children:re?`Copied new-install request`:`Copy new-install request`})]}):null,ae&&M?(0,q.jsx)(W,{asChild:!0,variant:`ghost`,size:`sm`,children:(0,q.jsxs)(`a`,{href:sf,target:`_blank`,rel:`noopener noreferrer`,children:[`Agent quickstart`,(0,q.jsx)(s,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`sr-only`,children:` (opens in a new tab)`})]})}):null]})]}),oe===null?null:(0,q.jsxs)(`section`,{className:`mt-6 border-t border-default pt-5`,"aria-labelledby":`telemetry-title`,children:[(0,q.jsxs)(`label`,{className:`flex min-h-11 items-start gap-3 py-2 ${c.isPending?`cursor-wait`:`cursor-pointer`}`,children:[(0,q.jsx)(`input`,{className:`mt-0.5 size-4 shrink-0 rounded border-strong bg-bg accent-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-mono-500 disabled:cursor-wait`,type:`checkbox`,checked:se??!1,disabled:c.isPending,onChange:e=>{De(e.target.checked)},"aria-describedby":`telemetry-detail`}),(0,q.jsxs)(`span`,{className:`grid gap-0.5`,children:[(0,q.jsx)(`span`,{id:`telemetry-title`,className:`text-sm leading-5 text-heading`,children:`Share anonymous product telemetry`}),(0,q.jsx)(`span`,{id:`telemetry-detail`,className:`max-w-[70ch] text-sm leading-5 text-secondary`,children:`Helps prioritize improvements. Canonry does not send raw domains, URLs, queries, answer content, or credentials.`})]})]}),c.isPending?(0,q.jsx)(`p`,{className:`mt-1 text-sm text-secondary`,role:`status`,children:`Saving preference…`}):null,ce?(0,q.jsx)(`p`,{className:`mt-1 text-sm text-negative`,role:`alert`,children:ce}):null]})]})}function Nf(){return(0,q.jsx)(`div`,{className:`page-container`,children:(0,q.jsx)(`section`,{className:`page-section`,children:(0,q.jsxs)(Ar,{className:`surface-card empty-card`,children:[(0,q.jsx)(`h1`,{children:`Route not found`}),(0,q.jsx)(`p`,{children:`The current path does not map to a dashboard view.`}),(0,q.jsx)(W,{asChild:!0,children:(0,q.jsx)(B,{to:`/`,children:`Return to overview`})})]})})})}var Pf=Oe(()=>nf(()=>import(`./ProjectPage-CmT2Vghx.js`),__vite__mapDeps([14,1,2,3,4,5,6,7,15,8,16,9,10,11,12,13,0,17,18,19,20]),import.meta.url),`ProjectPage`),Ff=Oe(()=>nf(()=>import(`./RunsPage-B-eTk2cT.js`),__vite__mapDeps([21,1,2,3,4,5,6,7,15,9,10,13]),import.meta.url),`RunsPage`),If=Oe(()=>nf(()=>import(`./HistoryPage-C4pZxBYX.js`),__vite__mapDeps([22,3,1,2,18,4,5,6,7,10,13]),import.meta.url),`HistoryPage`),Lf=Oe(()=>nf(()=>import(`./SettingsPage-Cl6ni4_w.js`),__vite__mapDeps([23,1,2,3,4,5,6,7,16,9,13]),import.meta.url),`SettingsPage`),Rf=Oe(()=>nf(()=>import(`./AgentSetupPage-DYw_Srwu.js`),__vite__mapDeps([24,1,2,3,7,6,5,8,16]),import.meta.url),`AgentSetupPage`),zf=Oe(()=>nf(()=>import(`./BacklinksPage-DFzYKntv.js`),__vite__mapDeps([25,1,2,3,7,6,5,16,13,17]),import.meta.url),`BacklinksPage`),Bf=Oe(()=>nf(()=>import(`./TrafficPage-jAQRK1Xq.js`),__vite__mapDeps([26,1,2,3,4,5,6,7,16,9,10,12,13,20]),import.meta.url),`TrafficPage`),$=Oe(()=>nf(()=>import(`./TrafficSourceDetailPage-VuKDrAGn.js`),__vite__mapDeps([27,1,2,3,4,5,6,7,15,11,12,13,20,9,10]),import.meta.url),`TrafficSourceDetailPage`),Vf=Oe(()=>nf(()=>import(`./MeasurementPropertyPage-C7TkC3Ja.js`),__vite__mapDeps([28,1,2,3,4,5,6,7,15,8,10,11,12,19]),import.meta.url),`MeasurementPropertyPage`);function Hf(){return(0,q.jsx)(ll,{children:(0,q.jsx)(Hr,{children:(0,q.jsx)(cl,{})})})}var Uf=ye()({component:Hf,validateSearch:e=>({manageQueries:e.manageQueries===!0||e.manageQueries===`true`||void 0,runId:typeof e.runId==`string`?e.runId:void 0,siteHealthRunId:typeof e.siteHealthRunId==`string`?e.siteHealthRunId:void 0,seoProfileId:typeof e.seoProfileId==`string`?e.seoProfileId:void 0,seoRunId:typeof e.seoRunId==`string`?e.seoRunId:void 0,evidenceId:typeof e.evidenceId==`string`?e.evidenceId:void 0,runStatus:typeof e.runStatus==`string`?e.runStatus:void 0,runKind:typeof e.runKind==`string`?e.runKind:void 0,runProject:typeof e.runProject==`string`?e.runProject:void 0,runWindow:typeof e.runWindow==`string`?e.runWindow:void 0,runQuery:typeof e.runQuery==`string`?e.runQuery:void 0,onboarding:e.onboarding===`site-health`||e.onboarding===`first-run`||e.onboarding===`complete`?e.onboarding:void 0,experience:e.experience===`legacy`||e.experience===`platform`?e.experience:void 0,siteScan:e.siteScan===`skip`?`skip`:void 0,skipped:e.skipped===`visibility`?`visibility`:void 0,setupProject:typeof e.setupProject==`string`?e.setupProject:void 0,scope:typeof e.scope==`string`?e.scope:void 0,class:typeof e.class==`string`?e.class:void 0,...Object.fromEntries([`queryWorkspace`,`researchMode`,`trackingQueryId`,`measurementScope`,`measurementScopeKey`,`measurementMarketKey`,`queryClass`,`measurementProvider`,`measurementModel`,`measurementLocation`,`measurementFrom`,`measurementTo`,`measurementRevision`,`measurementRunId`,`measurementQueryKey`,`measurementAnswer`].map(t=>[t,typeof e[t]==`string`?e[t]:void 0]))})}),Wf=z({getParentRoute:()=>Uf,path:`/`,component:Cu,beforeLoad:async({context:e})=>{let t=e.queryClient.getQueryData(dr({client:U}));if(t===void 0)try{t=await e.queryClient.ensureQueryData(cr({client:U}))}catch{return}if(t.length===0)throw Se({to:`/setup`})}}),Gf=z({getParentRoute:()=>Uf,path:`/projects`,component:Du}),Kf=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,qf=z({getParentRoute:()=>Uf,path:`/projects/$projectName`,component:()=>(0,q.jsx)(Ee,{}),beforeLoad:async({context:e,params:t,location:n})=>{let r=t.projectName;if(!Kf.test(r))return;let i=e.queryClient.getQueryData(dr({client:U}));if(!i)try{i=await e.queryClient.ensureQueryData(cr({client:U}))}catch{return}let a=i.find(e=>e.id===r);if(a)throw Se({to:n.pathname.replace(`/projects/${r}`,`/projects/${encodeURIComponent(a.name)}`),replace:!0})}}),Jf=z({getParentRoute:()=>qf,path:`/`,component:()=>(0,q.jsx)(Pf,{tab:`overview`})}),Yf=z({getParentRoute:()=>qf,path:`/portfolio`,component:()=>(0,q.jsx)(Pf,{tab:`portfolio`})}),Xf=z({getParentRoute:()=>qf,path:`/search-console`,component:()=>(0,q.jsx)(Pf,{tab:`search-console`})}),Zf=z({getParentRoute:()=>qf,path:`/seo-data`,component:()=>(0,q.jsx)(Pf,{tab:`seo-data`})}),Qf=z({getParentRoute:()=>qf,path:`/conversions`,component:()=>(0,q.jsx)(Pf,{tab:`conversions`})}),$f=z({getParentRoute:()=>qf,path:`/local`,component:()=>(0,q.jsx)(Pf,{tab:`local`})}),ep=z({getParentRoute:()=>qf,path:`/discovery`,component:()=>(0,q.jsx)(Pf,{tab:`discovery`})}),tp=z({getParentRoute:()=>qf,path:`/queries`,component:()=>(0,q.jsx)(Pf,{tab:`queries`})}),np=z({getParentRoute:()=>qf,path:`/properties/$targetKey`,component:()=>(0,q.jsx)(Vf,{})}),rp=z({getParentRoute:()=>qf,path:`/report`,beforeLoad:({params:e})=>{throw Se({to:`/projects/$projectName`,params:e,replace:!0})}}),ip=z({getParentRoute:()=>qf,path:`/activity`,component:()=>(0,q.jsx)(Pf,{tab:`activity`})}),ap=z({getParentRoute:()=>qf,path:`/backlinks`,component:()=>(0,q.jsx)(Pf,{tab:`backlinks`})}),op=z({getParentRoute:()=>qf,path:`/technical-aeo`,component:()=>(0,q.jsx)(Pf,{tab:`technical-aeo`})}),sp=z({getParentRoute:()=>qf,path:`/history`,component:()=>(0,q.jsx)(Pf,{tab:`history`})}),cp=z({getParentRoute:()=>qf,path:`/settings`,component:()=>(0,q.jsx)(Pf,{tab:`settings`})}),lp=z({getParentRoute:()=>Uf,path:`/runs`,component:Ff}),up=z({getParentRoute:()=>Uf,path:`/history`,component:If}),dp=z({getParentRoute:()=>Uf,path:`/settings`,component:Lf,beforeLoad:({context:e})=>{}}),fp=z({getParentRoute:()=>Uf,path:`/setup`,component:kf}),pp=z({getParentRoute:()=>Uf,path:`/agent-setup`,component:Rf}),mp=z({getParentRoute:()=>Uf,path:`/backlinks`,component:zf}),hp=z({getParentRoute:()=>Uf,path:`/traffic`,component:Bf}),gp=z({getParentRoute:()=>Uf,path:`/traffic/$projectName/$sourceId`,component:$}),_p=z({getParentRoute:()=>Uf,path:`*`,component:Nf}),vp=Uf.addChildren([Wf,Gf,qf.addChildren([Jf,Yf,Xf,Zf,Qf,$f,ep,tp,np,rp,ip,ap,op,sp,cp]),lp,up,dp,fp,pp,mp,hp,gp,_p]);function yp(){return typeof window<`u`&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath:`/`}var bp=yp(),xp=bp===`/`?``:bp.replace(/\/$/,``);function Sp(e,t){return ve({routeTree:vp,basepath:xp||`/`,context:{queryClient:e},...t?.initialEntries&&{history:we({initialEntries:t.initialEntries})}})}var Cp=!1;async function wp(e){return(await fn({client:U,body:e,keepalive:!0})).data}function Tp(){Cp||typeof window>`u`||(Cp=!0,!(ze()||jn())&&(Rt({send:wp}),U.interceptors.request.use((e,t)=>{let n=t.fetch??globalThis.fetch,r=typeof t.url==`string`?t.url:void 0;return t.fetch=async(t,i)=>{try{return await n(t,i)}catch(t){throw t instanceof DOMException&&t.name===`AbortError`||Mn({method:e.method,route:r,network:!0}),t}},e}),U.interceptors.response.use((e,t,n)=>(Mn({method:t.method,route:typeof n.url==`string`?n.url:void 0,path:Dp(t.url),status:e.status}),e)),window.addEventListener(`error`,e=>{ht({kind:`unhandled`,error:e.error})}),window.addEventListener(`unhandledrejection`,e=>{ht({kind:`unhandled`,error:e.reason})}),Mp()))}function Ep(e){let t=null,n=()=>{let n=e.state.matches.at(-1);if(!n)return;yt(n.fullPath);let r=e.state.location;if(!r)return;let i=r.search&&typeof r.search==`object`?r.search:{};t&&t.pathname===r.pathname&&Le(t.search,i),t={pathname:r.pathname,search:i}};return n(),e.subscribe(`onResolved`,n)}function Dp(e){try{return new URL(e,window.location.origin).pathname}catch{return}}var Op={LCP:[2500,4e3],INP:[200,500],CLS:[.1,.25],FCP:[1800,3e3],TTFB:[800,1800]};function kp(e,t){let[n,r]=Op[e];return t<=n?`good`:t<=r?`needs-improvement`:`poor`}function Ap(){let e=0,t=0,n=-1/0,r=-1/0;return{add(i){i.hadRecentInput||(i.startTime-r<1e3&&i.startTime-n<5e3?t+=i.value:(t=i.value,n=i.startTime),r=i.startTime,e=Math.max(e,t))},value:()=>e}}function jp(){let e=0;return{add(t){t.interactionId&&(e=Math.max(e,t.duration))},value:()=>e}}function Mp(){if(typeof PerformanceObserver>`u`)return;let e=new Set,t=(t,n)=>{!e.has(t)&&Number.isFinite(n)&&(e.add(t),kn(t,kp(t,n)))},n=(e,t,n={})=>{try{new PerformanceObserver(e=>t(e.getEntries())).observe({type:e,buffered:!0,...n})}catch{}};try{let e=performance.getEntriesByType(`navigation`)[0];e&&e.responseStart>0&&t(`TTFB`,e.responseStart)}catch{}n(`paint`,e=>{let n=e.find(e=>e.name===`first-contentful-paint`);n&&t(`FCP`,n.startTime)});let r=0;n(`largest-contentful-paint`,e=>{let t=e.at(-1);t&&(r=t.startTime)});let i=Ap();n(`layout-shift`,e=>{for(let t of e)i.add({startTime:t.startTime,value:t.value??0,hadRecentInput:t.hadRecentInput===!0})});let a=jp();n(`event`,e=>{for(let t of e)a.add(t)},{durationThreshold:40});let o=()=>{r>0&&t(`LCP`,r),t(`CLS`,i.value()),a.value()>0&&t(`INP`,a.value())};document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`hidden`&&o()}),window.addEventListener(`pagehide`,o)}var Np=6e4,Pp=`Anyone with this password can sign in to this dashboard.`,Fp={label:`Root API key`,help:`To create the password from here, enter the root API key (apiKey in config.yaml). It is used once and not saved.`,missing:`Enter the root API key.`,rejected:`That is not the root API key for this install.`,show:`Show passwords and key`};function Ip(){let e=(0,K.useRef)(Gt()).current,[t,n]=(0,K.useState)(e?`ready`:`checking`),[r,i]=(0,K.useState)(null),[a,o]=(0,K.useState)(null),[s,c]=(0,K.useState)(e),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(``),[h,g]=(0,K.useState)(``),[_,v]=(0,K.useState)(!1),[y,b]=(0,K.useState)(`password`),[x,S]=(0,K.useState)(!1),[C,w]=(0,K.useState)(``),[T,E]=(0,K.useState)(null),[D,O]=(0,K.useState)(!1),[ee,k]=(0,K.useState)(!1),A=(0,K.useRef)(null),j=(0,K.useRef)(null),te=(0,K.useRef)(null),ne=()=>{let t=r?`${r.name}:${r.role}`:e?`api-key:explicit`:a?`api-key:${a.id}`:`no-accounts`;if(!A.current||te.current!==t){j.current?.clear();let e=Qn();j.current=e,A.current=Sp(e),Ep(A.current),te.current=t}return{queryClient:j.current,router:A.current}},re=e=>e.authRequired?(u(!0),i(e.user),o(null),c(!1),n(e.user?`ready`:`account-login`),!0):!1;(0,K.useEffect)(()=>{let t=!1,r=async(e,r=!1)=>{try{let e=await Ln();if(t)return;o(e),c(!1),n(`ready`)}catch(i){if(t)return;if(r&&i instanceof Pt&&i.statusCode===401)return Tn().then(()=>{t||(E(null),o(null),c(!1),k(!0),n(`login`))}).catch(r=>{t||(E(r instanceof Error?r.message:`Could not clear the invalid session`),n(e))});E(i instanceof Error?i.message:`Could not verify API key access`),n(e)}};return e?(r(`api-key-error`),()=>{t=!0}):(Promise.allSettled([Qt(),Sn()]).then(([e,i])=>{if(t||e.status===`fulfilled`&&re(e.value))return;if(i.status===`rejected`){let e=i.reason;E(e instanceof Error?e.message:`Failed to reach the Canonry API`),n(`login`);return}let a=i.value;a.authenticated?(c(!0),r(`api-key-error`,!0)):(o(null),c(!1),n(a.setupRequired?`setup`:`login`))}),()=>{t=!0})},[]),(0,K.useEffect)(()=>{if(t!==`ready`||e)return;let r=setInterval(()=>{l?Qt().then(e=>{e.authRequired&&!e.user&&(k(!0),i(null),o(null),n(`account-login`))}).catch(()=>{}):Sn().then(e=>{e.authenticated||(k(!0),o(null),n(e.setupRequired?`setup`:`login`))}).catch(()=>{})},Np);return Qe(()=>{k(!0),i(null),o(null),c(!1),n(l?`account-login`:`login`)}),()=>{clearInterval(r),Qe(null)}},[t,l,e]);let ie=async e=>{if(e.preventDefault(),!p.trim()||p.trim().length<8){E(`Password must be at least 8 characters`);return}if(p!==h){E(`Passwords do not match`);return}let t=C.trim();if(x&&!t)E(Fp.missing);else{O(!0),E(null);try{if(!(await Xe(p.trim(),x?t:void 0)).authenticated){E(`Setup failed`);return}m(``),g(``),w(``),S(!1),v(!1),k(!1),o(null),c(!0),n(`checking`);try{let e=await Ln();o(e),c(!1),n(`ready`)}catch(e){E(e instanceof Error?e.message:`Could not verify API key access`),n(`api-key-error`)}}catch(e){if(e instanceof Pt&&e.statusCode===401&&e.code===`AUTH_REQUIRED`){E(x?Fp.rejected:null),S(!0);return}E(e instanceof Pt||e instanceof Error?e.message:`Setup failed`)}finally{O(!1)}}},ae=e=>{m(e),E(null)},M=e=>{w(e),E(null)},N=e=>{g(e),E(null)},oe=async e=>{if(e.preventDefault(),p.trim()){O(!0),E(null);try{if(!(y===`api-key`?await He(p.trim()):await st(p.trim())).authenticated){E(y===`api-key`?`Invalid API key`:`Incorrect password`);return}let e=await Ln();o(e),c(!1),m(``),v(!1),k(!1),n(`ready`)}catch(e){E(e instanceof Pt||e instanceof Error?e.message:`Authentication failed`)}finally{O(!1)}}},se=e=>{b(e),m(``),v(!1),E(null)},ce=async e=>{if(e.preventDefault(),d.trim()&&p){O(!0),E(null);try{let e=await Me(d.trim(),p);if(!e.user){E(`Incorrect name or password.`);return}m(``),k(!1),i(e.user),o(null),c(!1),n(`ready`)}catch(e){E(e instanceof Pt?e.message:`Incorrect name or password.`)}finally{O(!1)}}};if(t===`ready`){let{queryClient:e,router:t}=ne();return(0,q.jsx)(Yn,{account:r,apiKey:a,apiKeyPending:s,children:(0,q.jsx)(_e,{client:e,children:(0,q.jsx)(Ce,{router:t})})})}let le=p.trim(),ue=p.length>0&&le.length<8,de=h.length>0&&p!==h,fe=le.length>=8&&p===h&&(!x||C.trim().length>0);return(0,q.jsx)(`div`,{className:`min-h-screen bg-bg px-4 py-8`,children:(0,q.jsxs)(`div`,{className:`mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col items-center justify-center gap-5`,children:[(0,q.jsxs)(`div`,{"data-testid":`auth-brand`,className:`flex items-center gap-2.5`,children:[(0,q.jsx)(`img`,{className:`size-7`,src:`./favicon.svg`,alt:``,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-heading`,children:`Canonry`})]}),(0,q.jsx)(Ar,{className:`surface-card w-full`,children:t===`checking`?(0,q.jsx)(Or,{className:`py-8`,children:(0,q.jsx)(`p`,{className:`supporting-copy text-center`,children:`Connecting to Canonry…`})}):t===`api-key-error`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(Dr,{children:[(0,q.jsx)(`p`,{className:`eyebrow eyebrow-soft`,children:`Dashboard access`}),(0,q.jsx)(`h1`,{className:`font-medium tracking-tight text-primary`,children:`Could not verify API key access`})]}),(0,q.jsxs)(Or,{className:`space-y-4`,children:[(0,q.jsx)(`p`,{className:`supporting-copy`,children:T??`Canonry could not verify this session’s access, so the dashboard stayed locked.`}),(0,q.jsx)(W,{type:`button`,className:`w-full`,onClick:()=>{window.location.reload()},children:`Try again`})]})]}):t===`account-login`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(Dr,{children:[(0,q.jsx)(`p`,{className:`eyebrow eyebrow-soft`,children:`Dashboard access`}),(0,q.jsx)(`h1`,{className:`font-medium tracking-tight text-primary`,children:`Sign in to Canonry`})]}),(0,q.jsxs)(Or,{children:[ee?(0,q.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,(0,q.jsxs)(`form`,{className:`space-y-4`,onSubmit:Xn(ce),children:[(0,q.jsxs)(`label`,{className:`block space-y-1.5`,htmlFor:`account-name`,children:[(0,q.jsx)(`span`,{className:`text-xs font-medium text-secondary`,children:`Name`}),(0,q.jsx)(`input`,{autoFocus:!0,id:`account-name`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600`,type:`text`,name:`username`,autoComplete:`username`,value:d,onChange:e=>{f(e.target.value),E(null)},"aria-invalid":!!T,"aria-describedby":T?`account-login-error`:void 0})]}),(0,q.jsxs)(`label`,{className:`block space-y-1.5`,htmlFor:`account-password`,children:[(0,q.jsx)(`span`,{className:`text-xs font-medium text-secondary`,children:`Password`}),(0,q.jsx)(`input`,{id:`account-password`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600`,type:`password`,name:`password`,autoComplete:`current-password`,value:p,onChange:e=>ae(e.target.value),"aria-invalid":!!T,"aria-describedby":T?`account-login-error`:void 0})]}),T?(0,q.jsx)(`p`,{id:`account-login-error`,role:`alert`,className:`text-sm text-negative-400`,children:T}):null,(0,q.jsx)(W,{type:`submit`,disabled:D||!d.trim()||!p,children:D?`Signing in…`:`Sign in`})]})]})]}):t===`setup`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(Dr,{children:[(0,q.jsx)(`p`,{className:`eyebrow eyebrow-soft`,children:`First-time setup`}),(0,q.jsx)(`h1`,{className:`font-medium tracking-tight text-primary`,children:`Create a dashboard password`}),(0,q.jsx)(kr,{children:Pp})]}),(0,q.jsx)(Or,{children:(0,q.jsxs)(`form`,{className:`space-y-4`,onSubmit:Xn(ie),children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{className:`block text-xs font-medium text-secondary`,htmlFor:`dashboard-password-new`,children:`Password`}),(0,q.jsx)(`input`,{autoFocus:!0,id:`dashboard-password-new`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600`,type:_?`text`:`password`,name:`new-password`,autoComplete:`new-password`,minLength:8,required:!0,value:p,onChange:e=>ae(e.target.value),"aria-invalid":ue,"aria-describedby":`dashboard-password-new-help`}),(0,q.jsx)(`span`,{id:`dashboard-password-new-help`,"aria-live":`polite`,className:ue?`block text-sm text-negative-400`:`block text-sm text-secondary`,children:ue?`Enter at least 8 characters.`:`Use at least 8 characters.`})]}),(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{className:`block text-xs font-medium text-secondary`,htmlFor:`dashboard-password-confirm`,children:`Confirm password`}),(0,q.jsx)(`input`,{id:`dashboard-password-confirm`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600`,type:_?`text`:`password`,name:`confirm-password`,autoComplete:`new-password`,minLength:8,required:!0,value:h,onChange:e=>N(e.target.value),"aria-invalid":de,"aria-describedby":`dashboard-password-confirm-help`}),(0,q.jsx)(`span`,{id:`dashboard-password-confirm-help`,"aria-live":`polite`,className:de?`block text-sm text-negative-400`:`block text-sm text-secondary`,children:de?`Passwords do not match.`:`Enter the same password again.`})]}),x?(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{className:`block text-xs font-medium text-secondary`,htmlFor:`dashboard-setup-root-key`,children:Fp.label}),(0,q.jsx)(`input`,{autoFocus:!0,id:`dashboard-setup-root-key`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600`,type:_?`text`:`password`,name:`apiKey`,autoComplete:`off`,spellCheck:!1,required:!0,value:C,onChange:e=>M(e.target.value),"aria-invalid":T===Fp.rejected,"aria-describedby":`dashboard-setup-root-key-help`}),(0,q.jsx)(`span`,{id:`dashboard-setup-root-key-help`,"aria-live":`polite`,className:`block text-sm text-secondary`,children:Fp.help})]}):null,(0,q.jsxs)(`label`,{className:`flex min-h-10 cursor-pointer items-center gap-2 text-sm text-secondary`,htmlFor:`dashboard-password-show`,children:[(0,q.jsx)(`input`,{id:`dashboard-password-show`,type:`checkbox`,checked:_,onChange:e=>v(e.target.checked)}),x?Fp.show:`Show passwords`]}),T?(0,q.jsx)(`p`,{id:`dashboard-password-setup-error`,role:`alert`,className:`text-sm text-negative-400`,children:T}):null,(0,q.jsx)(W,{type:`submit`,disabled:D||!fe,children:D?`Creating password…`:`Create password and continue`})]})})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(Dr,{children:[(0,q.jsx)(`p`,{className:`eyebrow eyebrow-soft`,children:`Dashboard access`}),(0,q.jsx)(`h1`,{className:`font-medium tracking-tight text-primary`,children:`Sign in to Canonry`}),(0,q.jsx)(kr,{children:y===`api-key`?`Enter an API key from this Canonry install. This opens the dashboard with that key’s access and does not change the password.`:`Enter your dashboard password to continue.`})]}),(0,q.jsxs)(Or,{children:[ee?(0,q.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,(0,q.jsxs)(`form`,{className:`space-y-4`,onSubmit:Xn(oe),children:[(0,q.jsxs)(`label`,{className:`block space-y-1.5`,htmlFor:`dashboard-password-current`,children:[(0,q.jsx)(`span`,{className:`text-xs font-medium text-secondary`,children:y===`api-key`?`Canonry API key`:`Password`}),(0,q.jsx)(`input`,{autoFocus:!0,id:`dashboard-password-current`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600`,type:_?`text`:`password`,name:y===`api-key`?`apiKey`:`password`,autoComplete:y===`api-key`?`off`:`current-password`,spellCheck:!1,required:!0,value:p,onChange:e=>ae(e.target.value),"aria-invalid":!!T,"aria-describedby":T?`dashboard-password-login-error`:void 0})]}),(0,q.jsxs)(`label`,{className:`flex min-h-10 cursor-pointer items-center gap-2 text-sm text-secondary`,htmlFor:`dashboard-login-password-show`,children:[(0,q.jsx)(`input`,{id:`dashboard-login-password-show`,type:`checkbox`,checked:_,onChange:e=>v(e.target.checked)}),y===`api-key`?`Show API key`:`Show password`]}),T?(0,q.jsx)(`p`,{id:`dashboard-password-login-error`,role:`alert`,className:`text-sm text-negative-400`,children:T}):null,(0,q.jsx)(W,{type:`submit`,disabled:D||!p.trim(),children:D?`Signing in…`:`Open dashboard`}),(0,q.jsx)(W,{type:`button`,variant:`ghost`,onClick:()=>se(y===`api-key`?`password`:`api-key`),children:y===`api-key`?`Use dashboard password instead`:`Forgot password? Use API key`})]})]})]})})]})})}var Lp=document.getElementById(`root`);if(!Lp)throw Error(`Expected #root element for web app bootstrap.`);Tp(),(0,Ir.createRoot)(Lp).render((0,q.jsx)(K.StrictMode,{children:(0,q.jsx)(Ip,{})}));export{Ko as $,wi as $t,au as A,ya as At,Ps as B,Xi as Bt,Iu as C,na as Ct,su as D,ea as Dt,xu as E,ma as Et,fl as F,Ki as Ft,xs as G,Zi as Gt,ws as H,J as Ht,dl as I,ga as It,Ss as J,xa as Jt,Cs as K,ja as Kt,ul as L,Aa as Lt,Xl as M,ia as Mt,$l as N,ca as Nt,eu as O,ua as Ot,pl as P,Oa as Pt,Yo as Q,ki as Qt,ks as R,Da as Rt,Gu as S,Bi as St,Tu as T,zi as Tt,ys as U,$i as Ut,Ns as V,Ri as Vt,_s as W,Qi as Wt,es as X,ba as Xt,ns as Y,aa as Yt,Zo as Z,Ci as Zt,Yu as _,pa as _t,yd as a,ni as an,Ka as at,qu as b,Vi as bt,fd as c,Zr as cn,Ba as ct,nd as d,Ha as dt,Ti as en,Go as et,ad as f,Na as ft,Zu as g,Li as gt,ed as h,Ii as ht,zd as i,ii as in,qa as it,Zl as j,Ui as jt,iu as k,la as kt,md as l,Ur as ln,Ua as lt,sd as m,Fi as mt,Ld as n,ai as nn,Ja as nt,Ed as o,Xr as on,Ga as ot,cd as p,Ma as pt,vs as q,ha as qt,Rd as r,oi as rn,Za as rt,gd as s,Kr as sn,Pa as st,nf as t,li as tn,Co as tt,pd as u,Br as un,Va as ut,Wu as v,sa as vt,Pu as w,ta as wt,Uu as x,Hi as xt,Ku as y,Wi as yt,Os as z,fa as zt};
60
+ 7. Summarize only completed evidence, then propose AI Visibility setup. Ask before you add queries, connect providers, start a provider-backed or quota-consuming run, edit files, or publish.`;function uf(e,t){return e===`legacy`?`legacy`:e===`platform`?`platform`:t.state===`success`?t.projectCount===0?`platform`:`legacy`:t.state===`error`?`retry`:`loading`}var df=`pointer-coarse:min-h-11 max-md:min-h-11`,ff=`2000-01-01T00:00:00.000Z`,pf=5e3;function mf(e,t){let n=new Set,r=new Map;for(let e of t)e.trigger!==gn.probe&&(r.has(e.projectId)||r.set(e.projectId,e.id),(e.status===H.completed||e.status===H.partial)&&n.add(e.projectId));let i=(e.every(e=>e.createdAt)?[...e].sort((e,t)=>(e.createdAt??``).localeCompare(t.createdAt??``)||e.name.localeCompare(t.name)):e).find(e=>!n.has(e.id));return i?{projectName:i.name,runId:r.get(i.id)}:null}var hf=[{value:`US`,label:`United States`},{value:`CA`,label:`Canada`},{value:`GB`,label:`United Kingdom`},{value:`AU`,label:`Australia`},{value:`NZ`,label:`New Zealand`},{value:`IE`,label:`Ireland`},{value:`DE`,label:`Germany`},{value:`FR`,label:`France`},{value:`ES`,label:`Spain`},{value:`IT`,label:`Italy`},{value:`NL`,label:`Netherlands`},{value:`BR`,label:`Brazil`},{value:`MX`,label:`Mexico`},{value:`IN`,label:`India`},{value:`SG`,label:`Singapore`},{value:`JP`,label:`Japan`}],gf=[{value:`en`,label:`English`},{value:`es`,label:`Spanish`},{value:`fr`,label:`French`},{value:`de`,label:`German`},{value:`it`,label:`Italian`},{value:`pt`,label:`Portuguese`},{value:`nl`,label:`Dutch`},{value:`ja`,label:`Japanese`}];function _f(e,t){try{let n=new Intl.DisplayNames([`en`],{type:`region`}),r=new Intl.DisplayNames([`en`],{type:`language`}),i=e.length===2?n.of(e.toUpperCase()):void 0,a=t?r.of(t.toLowerCase()):void 0;return`${i??(e||`Country`)} · ${a??(t||`Language`)}`}catch{return`${e||`Country`} · ${t||`Language`}`}}function vf(e,t){let n=e.trim().toUpperCase(),r=t.trim().toLowerCase();return{countryValid:hf.some(e=>e.value===n),languageValid:gf.some(e=>e.value===r)}}function yf(e){let t=e.replace(/^\[|\]$/g,``);return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(t)||t.includes(`:`)}function bf(e){let t=e.trim();if(!t)return null;let n=/^[a-z][a-z\d+.-]*:\/\//i.test(t)?t:`https://${t}`,r;try{r=new URL(n)}catch{return null}if(r.protocol!==`http:`&&r.protocol!==`https:`)return null;let i=r.hostname.toLowerCase().replace(/^www\./,``);if(!i||i===`localhost`||yf(i)||!i.includes(`.`))return null;let a=i.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);return a?{canonicalDomain:i,projectName:a,displayName:i}:null}async function xf(e,t=of){let n,r=new Promise(e=>{n=setTimeout(()=>e({state:`timed-out`}),t)}),i=await Promise.race([e.then(e=>({state:`queued`,run:e})),r]);return n&&clearTimeout(n),i}function Sf(e,t){e.catch(()=>{$n({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:${t}`})})}function Cf(e){let t=(0,K.useRef)(en()).current,n=(0,K.useRef)(new Set);return{onboardingSessionId:t,emit:(0,K.useCallback)((t,r)=>{if(r){if(n.current.has(r))return;n.current.add(r)}nn({...t,surface:e,eventId:Pe()})},[e])}}function wf(e,t){return e instanceof Pt&&e.statusCode===409?`A project with this name already exists. Change the project name, or open the existing project.`:e instanceof Error&&e.message?e.message:t}function Tf(){return(0,q.jsxs)(`div`,{className:`page-container max-w-3xl`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,q.jsx)(`div`,{className:`page-header`,children:(0,q.jsxs)(`div`,{className:`page-header-left`,children:[(0,q.jsx)(`h1`,{className:`page-title`,children:`Preparing setup`}),(0,q.jsx)(`p`,{className:`page-subtitle`,children:`Checking the projects already on this install.`})]})}),(0,q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-default bg-surface p-4 text-sm text-secondary`,role:`status`,children:[(0,q.jsx)(O,{className:`size-4 motion-safe:animate-spin`,"aria-hidden":`true`}),`Loading projects…`]})]})}function Ef({onRetry:e}){return(0,q.jsxs)(`div`,{className:`page-container max-w-3xl`,children:[(0,q.jsx)(`div`,{className:`page-header`,children:(0,q.jsxs)(`div`,{className:`page-header-left`,children:[(0,q.jsx)(`h1`,{className:`page-title`,children:`Can’t load projects`}),(0,q.jsx)(`p`,{className:`page-subtitle`,children:`Canonry could not confirm whether this install already has a project.`})]})}),(0,q.jsxs)(`div`,{className:`rounded-lg border border-negative bg-negative-soft p-4`,role:`alert`,tabIndex:-1,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-heading`,children:`Setup is paused to protect existing projects.`}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-secondary`,children:`Check the connection or sign in again, then retry.`}),(0,q.jsx)(W,{type:`button`,className:`mt-4`,variant:`secondary`,onClick:e,children:`Retry project check`})]})]})}function Df({projectName:e,initialRunId:t}){return(0,q.jsx)(dl,{title:`Site Health setup`,children:(0,q.jsx)(Of,{projectName:e,initialRunId:t})})}function Of({projectName:e,initialRunId:t}){let n=be(),r=R({...cr({client:U}),enabled:!!e,retry:!1,refetchOnMount:`always`}),{onboardingSessionId:i,emit:a}=Cf(`site_health`),[o]=(0,K.useState)(()=>tt(t));(0,K.useEffect)(()=>{o&&an()},[o]),(0,K.useEffect)(()=>{e&&a({flowVersion:1,onboardingSessionId:i,event:`onboarding.started`,step:`run`,resumed:!!t&&!o},`onboarding.started`)},[a,o,t,i,e]),(0,K.useEffect)(()=>{e&&t&&Fe(e)?.runId!==t&&Je(e,t)},[t,e]);let s=R({...ur({client:U,path:{id:t??``}}),enabled:!!t,refetchInterval:({state:e})=>{let t=e.data?.status;return t===`completed`||t===`partial`||t===`failed`||t===`cancelled`?!1:2e3},refetchIntervalInBackground:!0}).data?.status;if((0,K.useEffect)(()=>{if(!e||!t||!s)return;if(s===`completed`||s===`partial`){a({flowVersion:1,onboardingSessionId:i,event:`onboarding.step_completed`,step:`run`,method:`automatic`},`onboarding.step_completed:run`),Ke(t);return}if(s!==`failed`&&s!==`cancelled`)return;let n=s===`cancelled`?`run_cancelled`:`run_failed`;a({flowVersion:1,onboardingSessionId:i,event:`onboarding.blocked`,step:`run`,action:`retry_run`,reasonCode:n},`onboarding.blocked:run:${n}`),Ke(t)},[a,t,i,e,s]),!e)return(0,q.jsxs)(`div`,{className:`page-container max-w-3xl`,children:[(0,q.jsx)(`div`,{className:`page-header`,children:(0,q.jsxs)(`div`,{className:`page-header-left`,children:[(0,q.jsx)(`h1`,{className:`page-title`,children:`Project not found`}),(0,q.jsx)(`p`,{className:`page-subtitle`,children:`This setup link does not identify a project.`})]})}),(0,q.jsx)(W,{type:`button`,variant:`secondary`,onClick:()=>{n({to:`/projects`})},children:`View projects`})]});if(r.isPending)return(0,q.jsxs)(`div`,{className:`page-container max-w-3xl`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,q.jsx)(Zu,{current:`site`}),(0,q.jsxs)(`div`,{className:`mt-8 flex items-center gap-3 text-sm text-secondary`,role:`status`,children:[(0,q.jsx)(O,{className:`size-4 motion-safe:animate-spin`,"aria-hidden":`true`}),`Loading Site Health setup…`]})]});if(r.isError)return(0,q.jsxs)(`div`,{className:`page-container max-w-3xl`,children:[(0,q.jsx)(`div`,{className:`page-header`,children:(0,q.jsxs)(`div`,{className:`page-header-left`,children:[(0,q.jsx)(`h1`,{className:`page-title`,children:`Can’t resume setup`}),(0,q.jsx)(`p`,{className:`page-subtitle`,children:`Canonry could not load the project for this Site Health scan.`})]})}),(0,q.jsxs)(`div`,{className:`rounded-lg border border-negative bg-negative-soft p-4`,role:`alert`,children:[(0,q.jsx)(`p`,{className:`text-sm text-secondary`,children:`Check the connection or sign in again, then retry.`}),(0,q.jsx)(W,{type:`button`,className:`mt-4`,variant:`secondary`,onClick:()=>{r.refetch()},children:`Retry project check`})]})]});let c=r.data.find(t=>t.name===e);return c?(0,q.jsxs)(`div`,{className:`page-container max-w-7xl py-8 md:py-10`,children:[(0,q.jsx)(`h1`,{className:`sr-only`,children:`Set up Canonry`}),(0,q.jsx)(K.Suspense,{fallback:(0,q.jsxs)(`div`,{className:`space-y-5`,children:[(0,q.jsx)(Zu,{current:`site`}),(0,q.jsxs)(`div`,{className:`flex min-h-72 items-center justify-center gap-3 text-sm text-secondary`,role:`status`,children:[(0,q.jsx)(O,{className:`size-4 motion-safe:animate-spin`,"aria-hidden":`true`}),`Loading Site Health…`]})]}),children:(0,q.jsx)(rf,{projectName:c.name,projectId:c.id,initialRunId:t,onReleaseInitialRun:()=>{n({to:`/setup`,search:{onboarding:`site-health`,setupProject:c.name},replace:!0})},showOnboardingActions:!0,onContinueOnboarding:()=>{t||Nu(c.name),n({to:`/setup`,search:{experience:`legacy`,onboarding:`site-health`,setupProject:c.name},replace:!0})},onSkipOnboarding:()=>{t||Nu(c.name),a({flowVersion:1,onboardingSessionId:i,event:`onboarding.step_completed`,step:`run`,method:`skipped`},`onboarding.step_completed:run`),n({to:`/setup`,search:{onboarding:`complete`,setupProject:c.name,skipped:`visibility`},replace:!0})}})})]}):(0,q.jsxs)(`div`,{className:`page-container max-w-3xl`,children:[(0,q.jsx)(`div`,{className:`page-header`,children:(0,q.jsxs)(`div`,{className:`page-header-left`,children:[(0,q.jsx)(`h1`,{className:`page-title`,children:`Project not found`}),(0,q.jsxs)(`p`,{className:`page-subtitle`,children:[`Canonry could not find `,e,`. It will not open a different project.`]})]})}),(0,q.jsx)(W,{type:`button`,variant:`secondary`,onClick:()=>{n({to:`/projects`})},children:`View projects`})]})}function kf(){let e=xe({from:`/setup`}),t=e.onboarding===`site-health`&&!e.setupProject,n=e.onboarding===`site-health`&&e.experience!==`legacy`,r=pn(),i=e.experience===`legacy`?`legacy`:e.experience===`platform`?`platform`:r,[a,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(void 0),l=R({...cr({client:U}),enabled:i===`auto`,retry:!1,refetchOnMount:`always`}),u=R({...fr({client:U,query:{kind:G[`site-audit`],since:ff,limit:pf}}),enabled:i===`auto`,retry:!1,refetchOnMount:`always`}),d=i===`auto`&&l.isSuccess&&l.isFetchedAfterMount&&l.data.length===0;(0,K.useEffect)(()=>{d&&o(!0)},[d]);let f=i===`auto`?l.isSuccess&&l.isFetchedAfterMount?{state:`success`,projectCount:l.data.length}:l.isError?{state:`error`}:{state:`loading`}:{state:`idle`},p=i===`legacy`?`legacy`:a||d?`platform`:uf(i,f);if(e.onboarding===`complete`&&e.setupProject)return(0,q.jsx)(Od,{projectName:e.setupProject,skippedVisibility:e.skipped===`visibility`});if(t||n)return(0,q.jsx)(Df,{projectName:e.setupProject,initialRunId:e.siteHealthRunId});let m=i===`auto`&&p===`legacy`&&!e.setupProject&&l.isSuccess;if(m&&s===void 0)return u.isError?c(null):u.isSuccess&&u.isFetchedAfterMount&&c(mf(l.data,u.data)),(0,q.jsx)(Tf,{});let h=m?s:null;return h?(0,q.jsx)(Af,{projectName:h.projectName,runId:h.runId}):p===`legacy`?(0,q.jsx)(Jd,{visibilityProjectName:e.setupProject,siteHealthOnboarding:e.onboarding===`site-health`,onboardingFinish:e.onboarding===`site-health`||e.onboarding===`first-run`}):p===`loading`?(0,q.jsx)(Tf,{}):p===`retry`?(0,q.jsx)(Ef,{onRetry:()=>{l.refetch()}}):(0,q.jsx)(jf,{onActivationStarted:()=>o(!0),skipSiteScan:e.siteScan===`skip`})}function Af({projectName:e,runId:t}){let n=be();return(0,K.useEffect)(()=>{n({to:`/setup`,search:{onboarding:`site-health`,setupProject:e,...t?{siteHealthRunId:t}:{}},replace:!0})},[n,e,t]),(0,q.jsx)(Tf,{})}function jf({onActivationStarted:e,skipSiteScan:t}){return(0,q.jsx)(dl,{title:`Site Health setup`,children:(0,q.jsx)(Mf,{onActivationStarted:e,skipSiteScan:t})})}function Mf({onActivationStarted:e,skipSiteScan:t}){let n=be(),r=ge(),i=Gu(),a=R({..._r({client:U}),retry:!1}),c=L(hr()),[u]=(0,K.useState)(()=>Au(`platform`)),[d,f]=(0,K.useState)(u.domain??``),[p,m]=(0,K.useState)(u.projectName??``),[g,_]=(0,K.useState)(u.displayName??``),[v,y]=(0,K.useState)(u.country??`US`),[b,x]=(0,K.useState)(u.language??`en`),[S,C]=(0,K.useState)(!1),[w,T]=(0,K.useState)(`idle`),[E,D]=(0,K.useState)(null),[ee,k]=(0,K.useState)(null),[A,j]=(0,K.useState)(!1),[te,ne]=(0,K.useState)(null),[re,ie]=(0,K.useState)(!1),ae=Tt(),M=jt(),N=a.isError?void 0:a.data,oe=typeof N?.enabled==`boolean`?N.enabled:null,se=c.isPending?c.variables.body.enabled:oe,[ce,le]=(0,K.useState)(null),ue=(0,K.useRef)(null),{onboardingSessionId:de,emit:fe}=Cf(`platform`);(0,K.useEffect)(()=>{fe({flowVersion:1,onboardingSessionId:de,event:`onboarding.started`,step:`project`,resumed:!1},`onboarding.started`)},[fe,de]),(0,K.useEffect)(()=>{E||ju(`platform`,{domain:d,projectName:p,displayName:g,country:v,language:b})},[E,d,p,g,v,b]);let pe=()=>{Mu(`platform`),f(``),m(``),_(``),y(`US`),x(`en`),C(!1),k(null),j(!1)},P=bf(d),me=p||P?.projectName||``,F=g||P?.displayName||``,I=w===`creating`||w===`dispatching`,he=ee??te,_e=_f(v,b),{countryValid:ve,languageValid:ye}=vf(v,b),xe=ve&&ye;(0,K.useEffect)(()=>{he&&ue.current?.focus()},[he]);let Se=(e,t)=>n({to:`/setup`,search:{...t?{siteHealthRunId:t}:{},onboarding:`site-health`,setupProject:e.name},replace:!0}),Ce=async e=>{T(`dispatching`),ne(null);try{let t=i.mutateAsync({projectName:e.name,projectId:e.id,projectLabel:e.displayName||e.name,suppressErrorToast:!0,body:{checkDeadLinks:!0,maxPages:100}}),n=await xf(t);if(n.state===`queued`){fe({flowVersion:1,onboardingSessionId:de,event:`run.requested`,origin:`dashboard_setup`,result:`queued`,kind:`site_health`,providerCountBucket:`0`,queryCountBucket:`0`}),lt(n.run.runId),await Se(e,n.run.runId);return}t.then(()=>{fe({flowVersion:1,onboardingSessionId:de,event:`run.requested`,origin:`dashboard_setup`,result:`queued`,kind:`site_health`,providerCountBucket:`0`,queryCountBucket:`0`})},e=>{fe({flowVersion:1,onboardingSessionId:de,event:`run.requested`,origin:`dashboard_setup`,result:`rejected`,kind:`site_health`,providerCountBucket:`0`,queryCountBucket:`0`,reasonCode:$e(e,`run_rejected`)})}),Sf(t,e.id),await Se(e)}catch(e){T(`recovery`),ne(wf(e,`The project was created, but the Site Health scan could not be started.`));let t=$e(e,`run_rejected`);fe({flowVersion:1,onboardingSessionId:de,event:`run.requested`,origin:`dashboard_setup`,result:`rejected`,kind:`site_health`,providerCountBucket:`0`,queryCountBucket:`0`,reasonCode:t}),fe({flowVersion:1,onboardingSessionId:de,event:`onboarding.blocked`,step:`run`,action:`retry_run`,reasonCode:t},`onboarding.blocked:run:${t}`)}},z=async i=>{if(i.preventDefault(),P&&(t||S)&&xe&&!I){T(`creating`),k(null),j(!1),ne(null);try{let i=await vt({name:me,displayName:F,canonicalDomain:P.canonicalDomain,country:v,language:b});if(e(),D(i),Mu(`platform`),fe({flowVersion:1,onboardingSessionId:de,event:`onboarding.step_completed`,step:`project`,method:`manual`},`onboarding.step_completed:project`),await r.invalidateQueries({queryKey:dr({client:U})}),t){Nu(i.name),await n({to:`/setup`,search:{experience:`legacy`,onboarding:`first-run`,setupProject:i.name},replace:!0});return}await Ce(i)}catch(t){T(`idle`);let n=t instanceof Pt&&t.statusCode===409;j(n),k(wf(t,`Could not create the project. Try again.`)),fe({flowVersion:1,onboardingSessionId:de,event:`onboarding.blocked`,step:`project`,action:`save`,reasonCode:$e(t,`project_create_failed`)},`onboarding.blocked:project`),n&&(e(),r.invalidateQueries({queryKey:dr({client:U})}))}}},we=()=>{E&&!I&&Ce(E)},Te=()=>{I||n({to:`/projects`})},Ee=async()=>{try{await navigator.clipboard.writeText(M?lf:lf.replace(cf,``)),ie(!0)}catch{$n({tone:`negative`,title:`Could not copy setup request`,detail:M?`Open the agent quickstart to continue with the CLI instead.`:`Check your browser’s clipboard permission and try again.`})}},De=async e=>{le(null);try{let t=await c.mutateAsync({client:U,body:{enabled:e}});r.setQueryData(Cr({client:U}),t),t.enabled!==e&&le(`The server kept telemetry ${t.enabled?`on`:`off`}. Check its telemetry settings.`)}catch{le(`Could not update telemetry. Try again.`)}};return E&&w===`recovery`?(0,q.jsxs)(`div`,{className:`page-container max-w-3xl`,children:[(0,q.jsx)(Zu,{current:`site`}),(0,q.jsx)(`div`,{className:`page-header mt-8`,children:(0,q.jsxs)(`div`,{className:`page-header-left`,children:[(0,q.jsx)(`h1`,{className:`page-title`,children:`Project created`}),(0,q.jsxs)(`p`,{className:`page-subtitle`,children:[E.displayName||E.name,` is ready. The Site Health scan needs another try.`]})]})}),(0,q.jsxs)(`div`,{ref:ue,className:`rounded-lg border border-negative bg-negative-soft p-4`,role:`alert`,tabIndex:-1,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-heading`,children:te}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-secondary`,children:`You can retry the scan or continue setup and retry from Site Health.`}),(0,q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-3`,children:[(0,q.jsx)(W,{type:`button`,onClick:we,children:`Retry Site Health scan`}),(0,q.jsx)(W,{type:`button`,variant:`secondary`,onClick:()=>{Se(E)},children:`Continue setup`})]})]})]}):(0,q.jsxs)(`div`,{className:`page-container max-w-xl py-8 md:py-12`,children:[t?null:(0,q.jsx)(Zu,{current:`site`}),(0,q.jsxs)(`header`,{className:`mb-8 ${t?``:`mt-8`}`,children:[(0,q.jsx)(`h1`,{id:`site-map-setup-title`,className:`text-2xl font-semibold tracking-[-0.025em] text-heading`,children:t?`Create a project`:`Scan your site`}),(0,q.jsx)(`p`,{className:`mt-2 max-w-lg text-sm leading-6 text-secondary`,children:t?`Add a public domain, then choose the queries you want to track. No site scan will run.`:`Enter your public website to see its pages, structure, internal links, and Technical AEO scores.`})]}),(0,q.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-2 text-[13px] text-secondary`,children:[(0,q.jsx)(`p`,{children:`Draft fields use tab storage when available. Scan permission resets on reload.`}),(0,q.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,disabled:I,onClick:pe,children:`Reset draft`})]}),(0,q.jsxs)(`form`,{"aria-labelledby":`site-map-setup-title`,className:`space-y-6`,onSubmit:Xn(z),noValidate:!0,children:[(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(`label`,{className:`text-sm font-medium text-heading`,htmlFor:`launchpad-domain`,children:`Website URL`}),(0,q.jsx)(`input`,{id:`launchpad-domain`,className:`h-10 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 md:h-9 md:text-sm ${df}`,type:`text`,inputMode:`url`,autoComplete:`url`,autoCapitalize:`none`,spellCheck:!1,required:!0,"aria-invalid":!(!d||P),"aria-describedby":d&&!P?`launchpad-domain-hint launchpad-domain-error`:`launchpad-domain-hint`,placeholder:`https://example.com`,value:d,onChange:e=>{f(e.target.value),k(null),j(!1)}}),(0,q.jsx)(`p`,{id:`launchpad-domain-hint`,className:`text-sm text-secondary`,children:t?(0,q.jsxs)(q.Fragment,{children:[`A public domain is still required.`,` `,(0,q.jsx)(B,{to:`/setup`,search:{experience:`platform`},className:`font-medium text-link underline-offset-4 hover:underline`,children:`Map with Site Health instead`})]}):(0,q.jsxs)(q.Fragment,{children:[`Only public pages are scanned.`,` `,(0,q.jsx)(B,{to:`/setup`,search:{experience:`platform`,onboarding:`first-run`,siteScan:`skip`},className:`font-medium text-link underline-offset-4 hover:underline`,children:`Set up without a site scan`})]})}),d&&!P?(0,q.jsx)(`p`,{id:`launchpad-domain-error`,className:`text-sm text-negative`,role:`alert`,children:`Enter a public domain, such as example.com.`}):null]}),(0,q.jsxs)(`details`,{className:`group border-y border-default`,children:[(0,q.jsxs)(`summary`,{className:`flex min-h-9 cursor-pointer list-none items-center justify-between gap-4 py-2 text-sm [&::-webkit-details-marker]:hidden ${df}`,children:[(0,q.jsx)(`span`,{className:`font-medium text-heading`,children:`Project name and locale`}),(0,q.jsxs)(`span`,{className:`flex items-center gap-2 text-secondary`,children:[_e,(0,q.jsx)(o,{className:`size-4 transition-transform group-open:rotate-180 motion-reduce:transition-none`,"aria-hidden":`true`})]})]}),(0,q.jsxs)(`div`,{className:`space-y-5 border-t border-default py-4`,children:[P?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`mb-3 text-sm font-medium text-heading`,children:`Project`}),(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(`label`,{className:`text-sm text-secondary`,htmlFor:`launchpad-project-name`,children:`Project name`}),(0,q.jsx)(`input`,{id:`launchpad-project-name`,className:`setup-input h-10`,type:`text`,value:me,onChange:e=>m(e.target.value)})]}),(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(`label`,{className:`text-sm text-secondary`,htmlFor:`launchpad-display-name`,children:`Display name`}),(0,q.jsx)(`input`,{id:`launchpad-display-name`,className:`setup-input h-10`,type:`text`,value:F,onChange:e=>_(e.target.value)})]})]})]}):null,(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`mb-3 text-sm font-medium text-heading`,children:`Locale`}),(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(`label`,{className:`text-sm text-secondary`,htmlFor:`launchpad-country`,children:`Country`}),(0,q.jsx)(`select`,{id:`launchpad-country`,className:`setup-input h-10`,value:v,onChange:e=>y(e.target.value),children:hf.map(e=>(0,q.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(`label`,{className:`text-sm text-secondary`,htmlFor:`launchpad-language`,children:`Language`}),(0,q.jsx)(`select`,{id:`launchpad-language`,className:`setup-input h-10`,value:b,onChange:e=>x(e.target.value),children:gf.map(e=>(0,q.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]})]})]})]}),t?null:(0,q.jsxs)(`p`,{className:`text-sm text-secondary`,children:[`First scan: up to `,100,` pages. A limited scan describes the pages reached, not the whole site.`]}),t?null:(0,q.jsxs)(`label`,{className:`flex min-h-11 cursor-pointer items-start gap-3 py-2`,children:[(0,q.jsx)(`input`,{className:`mt-0.5 size-4 shrink-0 rounded border-strong bg-bg`,type:`checkbox`,checked:S,onChange:e=>C(e.target.checked),"aria-label":`Allow Canonry to scan this public site.`}),(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-sm leading-5 text-heading`,children:`Allow Canonry to scan this public site.`}),(0,q.jsx)(Tr,{text:af})]})]}),he?(0,q.jsxs)(`div`,{ref:ue,className:`rounded-md border border-negative bg-negative-soft p-3`,role:`alert`,tabIndex:-1,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-heading`,children:he}),A?(0,q.jsx)(W,{type:`button`,variant:`secondary`,size:`sm`,className:`mt-3`,onClick:Te,children:`View projects`}):null]}):null,(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(W,{className:`w-full ${df}`,type:`submit`,disabled:!P||!t&&!S||!xe||I,children:w===`creating`||w===`dispatching`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(O,{className:`size-4 motion-safe:animate-spin`,"aria-hidden":`true`}),` `,t?`Creating project…`:`Mapping site…`]}):t?`Create project`:`Scan site`}),w===`dispatching`?(0,q.jsx)(`span`,{className:`text-center text-sm text-secondary`,role:`status`,children:`Opening Site Health when the scan is ready.`}):null]})]}),(0,q.jsxs)(`section`,{className:`mt-8 border-t border-default pt-6`,"aria-labelledby":`agent-setup-title`,children:[(0,q.jsx)(`p`,{id:`agent-setup-title`,className:`text-sm font-medium text-heading`,children:`Use your agent instead`}),(0,q.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-secondary`,children:ae?`Connect your agent to this instance, or copy a request for a new local installation.`:`Connect ChatGPT or Claude Desktop to this instance.`}),(0,q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1`,children:[(0,q.jsx)(W,{asChild:!0,variant:`secondary`,size:`sm`,children:(0,q.jsx)(B,{to:`/agent-setup`,children:`Agent setup`})}),ae?(0,q.jsxs)(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:Xn(Ee),children:[re?(0,q.jsx)(l,{className:`size-3.5`,"aria-hidden":`true`}):(0,q.jsx)(h,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{"aria-live":`polite`,children:re?`Copied new-install request`:`Copy new-install request`})]}):null,ae&&M?(0,q.jsx)(W,{asChild:!0,variant:`ghost`,size:`sm`,children:(0,q.jsxs)(`a`,{href:sf,target:`_blank`,rel:`noopener noreferrer`,children:[`Agent quickstart`,(0,q.jsx)(s,{className:`size-3.5`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`sr-only`,children:` (opens in a new tab)`})]})}):null]})]}),oe===null?null:(0,q.jsxs)(`section`,{className:`mt-6 border-t border-default pt-5`,"aria-labelledby":`telemetry-title`,children:[(0,q.jsxs)(`label`,{className:`flex min-h-11 items-start gap-3 py-2 ${c.isPending?`cursor-wait`:`cursor-pointer`}`,children:[(0,q.jsx)(`input`,{className:`mt-0.5 size-4 shrink-0 rounded border-strong bg-bg accent-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-mono-500 disabled:cursor-wait`,type:`checkbox`,checked:se??!1,disabled:c.isPending,onChange:e=>{De(e.target.checked)},"aria-describedby":`telemetry-detail`}),(0,q.jsxs)(`span`,{className:`grid gap-0.5`,children:[(0,q.jsx)(`span`,{id:`telemetry-title`,className:`text-sm leading-5 text-heading`,children:`Share anonymous product telemetry`}),(0,q.jsx)(`span`,{id:`telemetry-detail`,className:`max-w-[70ch] text-sm leading-5 text-secondary`,children:`Helps prioritize improvements. Canonry does not send raw domains, URLs, queries, answer content, or credentials.`})]})]}),c.isPending?(0,q.jsx)(`p`,{className:`mt-1 text-sm text-secondary`,role:`status`,children:`Saving preference…`}):null,ce?(0,q.jsx)(`p`,{className:`mt-1 text-sm text-negative`,role:`alert`,children:ce}):null]})]})}function Nf(){return(0,q.jsx)(`div`,{className:`page-container`,children:(0,q.jsx)(`section`,{className:`page-section`,children:(0,q.jsxs)(Ar,{className:`surface-card empty-card`,children:[(0,q.jsx)(`h1`,{children:`Route not found`}),(0,q.jsx)(`p`,{children:`The current path does not map to a dashboard view.`}),(0,q.jsx)(W,{asChild:!0,children:(0,q.jsx)(B,{to:`/`,children:`Return to overview`})})]})})})}var Pf=Oe(()=>nf(()=>import(`./ProjectPage-D4n2oqPP.js`),__vite__mapDeps([14,1,2,3,4,5,6,7,15,8,16,9,10,11,12,13,0,17,18,19,20]),import.meta.url),`ProjectPage`),Ff=Oe(()=>nf(()=>import(`./RunsPage-Cc98Px3T.js`),__vite__mapDeps([21,1,2,3,4,5,6,7,15,9,10,13]),import.meta.url),`RunsPage`),If=Oe(()=>nf(()=>import(`./HistoryPage-BP1_GGlT.js`),__vite__mapDeps([22,3,1,2,18,4,5,6,7,10,13]),import.meta.url),`HistoryPage`),Lf=Oe(()=>nf(()=>import(`./SettingsPage-CMyCE-H2.js`),__vite__mapDeps([23,1,2,3,4,5,6,7,16,9,13]),import.meta.url),`SettingsPage`),Rf=Oe(()=>nf(()=>import(`./AgentSetupPage-DPHRo4OR.js`),__vite__mapDeps([24,1,2,3,7,6,5,8,16]),import.meta.url),`AgentSetupPage`),zf=Oe(()=>nf(()=>import(`./BacklinksPage-iWrZ0-Pp.js`),__vite__mapDeps([25,1,2,3,7,6,5,16,13,17]),import.meta.url),`BacklinksPage`),Bf=Oe(()=>nf(()=>import(`./TrafficPage-DAef3d2A.js`),__vite__mapDeps([26,1,2,3,4,5,6,7,16,9,10,12,13,20]),import.meta.url),`TrafficPage`),$=Oe(()=>nf(()=>import(`./TrafficSourceDetailPage-CdoL5Dt9.js`),__vite__mapDeps([27,1,2,3,4,5,6,7,15,11,12,13,20,9,10]),import.meta.url),`TrafficSourceDetailPage`),Vf=Oe(()=>nf(()=>import(`./MeasurementPropertyPage-DfPHZNGo.js`),__vite__mapDeps([28,1,2,3,4,5,6,7,15,8,10,11,12,19]),import.meta.url),`MeasurementPropertyPage`);function Hf(){return(0,q.jsx)(ll,{children:(0,q.jsx)(Hr,{children:(0,q.jsx)(cl,{})})})}var Uf=ye()({component:Hf,validateSearch:e=>({manageQueries:e.manageQueries===!0||e.manageQueries===`true`||void 0,runId:typeof e.runId==`string`?e.runId:void 0,siteHealthRunId:typeof e.siteHealthRunId==`string`?e.siteHealthRunId:void 0,seoProfileId:typeof e.seoProfileId==`string`?e.seoProfileId:void 0,seoRunId:typeof e.seoRunId==`string`?e.seoRunId:void 0,evidenceId:typeof e.evidenceId==`string`?e.evidenceId:void 0,runStatus:typeof e.runStatus==`string`?e.runStatus:void 0,runKind:typeof e.runKind==`string`?e.runKind:void 0,runProject:typeof e.runProject==`string`?e.runProject:void 0,runWindow:typeof e.runWindow==`string`?e.runWindow:void 0,runQuery:typeof e.runQuery==`string`?e.runQuery:void 0,onboarding:e.onboarding===`site-health`||e.onboarding===`first-run`||e.onboarding===`complete`?e.onboarding:void 0,experience:e.experience===`legacy`||e.experience===`platform`?e.experience:void 0,siteScan:e.siteScan===`skip`?`skip`:void 0,skipped:e.skipped===`visibility`?`visibility`:void 0,setupProject:typeof e.setupProject==`string`?e.setupProject:void 0,scope:typeof e.scope==`string`?e.scope:void 0,class:typeof e.class==`string`?e.class:void 0,...Object.fromEntries([`queryWorkspace`,`researchMode`,`trackingQueryId`,`measurementScope`,`measurementScopeKey`,`measurementMarketKey`,`queryClass`,`measurementProvider`,`measurementModel`,`measurementLocation`,`measurementFrom`,`measurementTo`,`measurementRevision`,`measurementRunId`,`measurementQueryKey`,`measurementAnswer`].map(t=>[t,typeof e[t]==`string`?e[t]:void 0]))})}),Wf=z({getParentRoute:()=>Uf,path:`/`,component:Cu,beforeLoad:async({context:e})=>{let t=e.queryClient.getQueryData(dr({client:U}));if(t===void 0)try{t=await e.queryClient.ensureQueryData(cr({client:U}))}catch{return}if(t.length===0)throw Se({to:`/setup`})}}),Gf=z({getParentRoute:()=>Uf,path:`/projects`,component:Du}),Kf=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,qf=z({getParentRoute:()=>Uf,path:`/projects/$projectName`,component:()=>(0,q.jsx)(Ee,{}),beforeLoad:async({context:e,params:t,location:n})=>{let r=t.projectName;if(!Kf.test(r))return;let i=e.queryClient.getQueryData(dr({client:U}));if(!i)try{i=await e.queryClient.ensureQueryData(cr({client:U}))}catch{return}let a=i.find(e=>e.id===r);if(a)throw Se({to:n.pathname.replace(`/projects/${r}`,`/projects/${encodeURIComponent(a.name)}`),replace:!0})}}),Jf=z({getParentRoute:()=>qf,path:`/`,component:()=>(0,q.jsx)(Pf,{tab:`overview`})}),Yf=z({getParentRoute:()=>qf,path:`/portfolio`,component:()=>(0,q.jsx)(Pf,{tab:`portfolio`})}),Xf=z({getParentRoute:()=>qf,path:`/search-console`,component:()=>(0,q.jsx)(Pf,{tab:`search-console`})}),Zf=z({getParentRoute:()=>qf,path:`/seo-data`,component:()=>(0,q.jsx)(Pf,{tab:`seo-data`})}),Qf=z({getParentRoute:()=>qf,path:`/conversions`,component:()=>(0,q.jsx)(Pf,{tab:`conversions`})}),$f=z({getParentRoute:()=>qf,path:`/local`,component:()=>(0,q.jsx)(Pf,{tab:`local`})}),ep=z({getParentRoute:()=>qf,path:`/discovery`,component:()=>(0,q.jsx)(Pf,{tab:`discovery`})}),tp=z({getParentRoute:()=>qf,path:`/queries`,component:()=>(0,q.jsx)(Pf,{tab:`queries`})}),np=z({getParentRoute:()=>qf,path:`/properties/$targetKey`,component:()=>(0,q.jsx)(Vf,{})}),rp=z({getParentRoute:()=>qf,path:`/report`,beforeLoad:({params:e})=>{throw Se({to:`/projects/$projectName`,params:e,replace:!0})}}),ip=z({getParentRoute:()=>qf,path:`/activity`,component:()=>(0,q.jsx)(Pf,{tab:`activity`})}),ap=z({getParentRoute:()=>qf,path:`/backlinks`,component:()=>(0,q.jsx)(Pf,{tab:`backlinks`})}),op=z({getParentRoute:()=>qf,path:`/technical-aeo`,component:()=>(0,q.jsx)(Pf,{tab:`technical-aeo`})}),sp=z({getParentRoute:()=>qf,path:`/history`,component:()=>(0,q.jsx)(Pf,{tab:`history`})}),cp=z({getParentRoute:()=>qf,path:`/settings`,component:()=>(0,q.jsx)(Pf,{tab:`settings`})}),lp=z({getParentRoute:()=>Uf,path:`/runs`,component:Ff}),up=z({getParentRoute:()=>Uf,path:`/history`,component:If}),dp=z({getParentRoute:()=>Uf,path:`/settings`,component:Lf,beforeLoad:({context:e})=>{}}),fp=z({getParentRoute:()=>Uf,path:`/setup`,component:kf}),pp=z({getParentRoute:()=>Uf,path:`/agent-setup`,component:Rf}),mp=z({getParentRoute:()=>Uf,path:`/backlinks`,component:zf}),hp=z({getParentRoute:()=>Uf,path:`/traffic`,component:Bf}),gp=z({getParentRoute:()=>Uf,path:`/traffic/$projectName/$sourceId`,component:$}),_p=z({getParentRoute:()=>Uf,path:`*`,component:Nf}),vp=Uf.addChildren([Wf,Gf,qf.addChildren([Jf,Yf,Xf,Zf,Qf,$f,ep,tp,np,rp,ip,ap,op,sp,cp]),lp,up,dp,fp,pp,mp,hp,gp,_p]);function yp(){return typeof window<`u`&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath:`/`}var bp=yp(),xp=bp===`/`?``:bp.replace(/\/$/,``);function Sp(e,t){return ve({routeTree:vp,basepath:xp||`/`,context:{queryClient:e},...t?.initialEntries&&{history:we({initialEntries:t.initialEntries})}})}var Cp=!1;async function wp(e){return(await fn({client:U,body:e,keepalive:!0})).data}function Tp(){Cp||typeof window>`u`||(Cp=!0,!(ze()||jn())&&(Rt({send:wp}),U.interceptors.request.use((e,t)=>{let n=t.fetch??globalThis.fetch,r=typeof t.url==`string`?t.url:void 0;return t.fetch=async(t,i)=>{try{return await n(t,i)}catch(t){throw t instanceof DOMException&&t.name===`AbortError`||Mn({method:e.method,route:r,network:!0}),t}},e}),U.interceptors.response.use((e,t,n)=>(Mn({method:t.method,route:typeof n.url==`string`?n.url:void 0,path:Dp(t.url),status:e.status}),e)),window.addEventListener(`error`,e=>{ht({kind:`unhandled`,error:e.error})}),window.addEventListener(`unhandledrejection`,e=>{ht({kind:`unhandled`,error:e.reason})}),Mp()))}function Ep(e){let t=null,n=()=>{let n=e.state.matches.at(-1);if(!n)return;yt(n.fullPath);let r=e.state.location;if(!r)return;let i=r.search&&typeof r.search==`object`?r.search:{};t&&t.pathname===r.pathname&&Le(t.search,i),t={pathname:r.pathname,search:i}};return n(),e.subscribe(`onResolved`,n)}function Dp(e){try{return new URL(e,window.location.origin).pathname}catch{return}}var Op={LCP:[2500,4e3],INP:[200,500],CLS:[.1,.25],FCP:[1800,3e3],TTFB:[800,1800]};function kp(e,t){let[n,r]=Op[e];return t<=n?`good`:t<=r?`needs-improvement`:`poor`}function Ap(){let e=0,t=0,n=-1/0,r=-1/0;return{add(i){i.hadRecentInput||(i.startTime-r<1e3&&i.startTime-n<5e3?t+=i.value:(t=i.value,n=i.startTime),r=i.startTime,e=Math.max(e,t))},value:()=>e}}function jp(){let e=0;return{add(t){t.interactionId&&(e=Math.max(e,t.duration))},value:()=>e}}function Mp(){if(typeof PerformanceObserver>`u`)return;let e=new Set,t=(t,n)=>{!e.has(t)&&Number.isFinite(n)&&(e.add(t),kn(t,kp(t,n)))},n=(e,t,n={})=>{try{new PerformanceObserver(e=>t(e.getEntries())).observe({type:e,buffered:!0,...n})}catch{}};try{let e=performance.getEntriesByType(`navigation`)[0];e&&e.responseStart>0&&t(`TTFB`,e.responseStart)}catch{}n(`paint`,e=>{let n=e.find(e=>e.name===`first-contentful-paint`);n&&t(`FCP`,n.startTime)});let r=0;n(`largest-contentful-paint`,e=>{let t=e.at(-1);t&&(r=t.startTime)});let i=Ap();n(`layout-shift`,e=>{for(let t of e)i.add({startTime:t.startTime,value:t.value??0,hadRecentInput:t.hadRecentInput===!0})});let a=jp();n(`event`,e=>{for(let t of e)a.add(t)},{durationThreshold:40});let o=()=>{r>0&&t(`LCP`,r),t(`CLS`,i.value()),a.value()>0&&t(`INP`,a.value())};document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`hidden`&&o()}),window.addEventListener(`pagehide`,o)}var Np=6e4,Pp=`Anyone with this password can sign in to this dashboard.`,Fp={label:`Root API key`,help:`To create the password from here, enter the root API key (apiKey in config.yaml). It is used once and not saved.`,missing:`Enter the root API key.`,rejected:`That is not the root API key for this install.`,show:`Show passwords and key`};function Ip(){let e=(0,K.useRef)(Gt()).current,[t,n]=(0,K.useState)(e?`ready`:`checking`),[r,i]=(0,K.useState)(null),[a,o]=(0,K.useState)(null),[s,c]=(0,K.useState)(e),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(``),[h,g]=(0,K.useState)(``),[_,v]=(0,K.useState)(!1),[y,b]=(0,K.useState)(`password`),[x,S]=(0,K.useState)(!1),[C,w]=(0,K.useState)(``),[T,E]=(0,K.useState)(null),[D,O]=(0,K.useState)(!1),[ee,k]=(0,K.useState)(!1),A=(0,K.useRef)(null),j=(0,K.useRef)(null),te=(0,K.useRef)(null),ne=()=>{let t=r?`${r.name}:${r.role}`:e?`api-key:explicit`:a?`api-key:${a.id}`:`no-accounts`;if(!A.current||te.current!==t){j.current?.clear();let e=Qn();j.current=e,A.current=Sp(e),Ep(A.current),te.current=t}return{queryClient:j.current,router:A.current}},re=e=>e.authRequired?(u(!0),i(e.user),o(null),c(!1),n(e.user?`ready`:`account-login`),!0):!1;(0,K.useEffect)(()=>{let t=!1,r=async(e,r=!1)=>{try{let e=await Ln();if(t)return;o(e),c(!1),n(`ready`)}catch(i){if(t)return;if(r&&i instanceof Pt&&i.statusCode===401)return Tn().then(()=>{t||(E(null),o(null),c(!1),k(!0),n(`login`))}).catch(r=>{t||(E(r instanceof Error?r.message:`Could not clear the invalid session`),n(e))});E(i instanceof Error?i.message:`Could not verify API key access`),n(e)}};return e?(r(`api-key-error`),()=>{t=!0}):(Promise.allSettled([Qt(),Sn()]).then(([e,i])=>{if(t||e.status===`fulfilled`&&re(e.value))return;if(i.status===`rejected`){let e=i.reason;E(e instanceof Error?e.message:`Failed to reach the Canonry API`),n(`login`);return}let a=i.value;a.authenticated?(c(!0),r(`api-key-error`,!0)):(o(null),c(!1),n(a.setupRequired?`setup`:`login`))}),()=>{t=!0})},[]),(0,K.useEffect)(()=>{if(t!==`ready`||e)return;let r=setInterval(()=>{l?Qt().then(e=>{e.authRequired&&!e.user&&(k(!0),i(null),o(null),n(`account-login`))}).catch(()=>{}):Sn().then(e=>{e.authenticated||(k(!0),o(null),n(e.setupRequired?`setup`:`login`))}).catch(()=>{})},Np);return Qe(()=>{k(!0),i(null),o(null),c(!1),n(l?`account-login`:`login`)}),()=>{clearInterval(r),Qe(null)}},[t,l,e]);let ie=async e=>{if(e.preventDefault(),!p.trim()||p.trim().length<8){E(`Password must be at least 8 characters`);return}if(p!==h){E(`Passwords do not match`);return}let t=C.trim();if(x&&!t)E(Fp.missing);else{O(!0),E(null);try{if(!(await Xe(p.trim(),x?t:void 0)).authenticated){E(`Setup failed`);return}m(``),g(``),w(``),S(!1),v(!1),k(!1),o(null),c(!0),n(`checking`);try{let e=await Ln();o(e),c(!1),n(`ready`)}catch(e){E(e instanceof Error?e.message:`Could not verify API key access`),n(`api-key-error`)}}catch(e){if(e instanceof Pt&&e.statusCode===401&&e.code===`AUTH_REQUIRED`){E(x?Fp.rejected:null),S(!0);return}E(e instanceof Pt||e instanceof Error?e.message:`Setup failed`)}finally{O(!1)}}},ae=e=>{m(e),E(null)},M=e=>{w(e),E(null)},N=e=>{g(e),E(null)},oe=async e=>{if(e.preventDefault(),p.trim()){O(!0),E(null);try{if(!(y===`api-key`?await He(p.trim()):await st(p.trim())).authenticated){E(y===`api-key`?`Invalid API key`:`Incorrect password`);return}let e=await Ln();o(e),c(!1),m(``),v(!1),k(!1),n(`ready`)}catch(e){E(e instanceof Pt||e instanceof Error?e.message:`Authentication failed`)}finally{O(!1)}}},se=e=>{b(e),m(``),v(!1),E(null)},ce=async e=>{if(e.preventDefault(),d.trim()&&p){O(!0),E(null);try{let e=await Me(d.trim(),p);if(!e.user){E(`Incorrect name or password.`);return}m(``),k(!1),i(e.user),o(null),c(!1),n(`ready`)}catch(e){E(e instanceof Pt?e.message:`Incorrect name or password.`)}finally{O(!1)}}};if(t===`ready`){let{queryClient:e,router:t}=ne();return(0,q.jsx)(Yn,{account:r,apiKey:a,apiKeyPending:s,children:(0,q.jsx)(_e,{client:e,children:(0,q.jsx)(Ce,{router:t})})})}let le=p.trim(),ue=p.length>0&&le.length<8,de=h.length>0&&p!==h,fe=le.length>=8&&p===h&&(!x||C.trim().length>0);return(0,q.jsx)(`div`,{className:`min-h-screen bg-bg px-4 py-8`,children:(0,q.jsxs)(`div`,{className:`mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col items-center justify-center gap-5`,children:[(0,q.jsxs)(`div`,{"data-testid":`auth-brand`,className:`flex items-center gap-2.5`,children:[(0,q.jsx)(`img`,{className:`size-7`,src:`./favicon.svg`,alt:``,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-heading`,children:`Canonry`})]}),(0,q.jsx)(Ar,{className:`surface-card w-full`,children:t===`checking`?(0,q.jsx)(Or,{className:`py-8`,children:(0,q.jsx)(`p`,{className:`supporting-copy text-center`,children:`Connecting to Canonry…`})}):t===`api-key-error`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(Dr,{children:[(0,q.jsx)(`p`,{className:`eyebrow eyebrow-soft`,children:`Dashboard access`}),(0,q.jsx)(`h1`,{className:`font-medium tracking-tight text-primary`,children:`Could not verify API key access`})]}),(0,q.jsxs)(Or,{className:`space-y-4`,children:[(0,q.jsx)(`p`,{className:`supporting-copy`,children:T??`Canonry could not verify this session’s access, so the dashboard stayed locked.`}),(0,q.jsx)(W,{type:`button`,className:`w-full`,onClick:()=>{window.location.reload()},children:`Try again`})]})]}):t===`account-login`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(Dr,{children:[(0,q.jsx)(`p`,{className:`eyebrow eyebrow-soft`,children:`Dashboard access`}),(0,q.jsx)(`h1`,{className:`font-medium tracking-tight text-primary`,children:`Sign in to Canonry`})]}),(0,q.jsxs)(Or,{children:[ee?(0,q.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,(0,q.jsxs)(`form`,{className:`space-y-4`,onSubmit:Xn(ce),children:[(0,q.jsxs)(`label`,{className:`block space-y-1.5`,htmlFor:`account-name`,children:[(0,q.jsx)(`span`,{className:`text-xs font-medium text-secondary`,children:`Name`}),(0,q.jsx)(`input`,{autoFocus:!0,id:`account-name`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600`,type:`text`,name:`username`,autoComplete:`username`,value:d,onChange:e=>{f(e.target.value),E(null)},"aria-invalid":!!T,"aria-describedby":T?`account-login-error`:void 0})]}),(0,q.jsxs)(`label`,{className:`block space-y-1.5`,htmlFor:`account-password`,children:[(0,q.jsx)(`span`,{className:`text-xs font-medium text-secondary`,children:`Password`}),(0,q.jsx)(`input`,{id:`account-password`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600`,type:`password`,name:`password`,autoComplete:`current-password`,value:p,onChange:e=>ae(e.target.value),"aria-invalid":!!T,"aria-describedby":T?`account-login-error`:void 0})]}),T?(0,q.jsx)(`p`,{id:`account-login-error`,role:`alert`,className:`text-sm text-negative-400`,children:T}):null,(0,q.jsx)(W,{type:`submit`,disabled:D||!d.trim()||!p,children:D?`Signing in…`:`Sign in`})]})]})]}):t===`setup`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(Dr,{children:[(0,q.jsx)(`p`,{className:`eyebrow eyebrow-soft`,children:`First-time setup`}),(0,q.jsx)(`h1`,{className:`font-medium tracking-tight text-primary`,children:`Create a dashboard password`}),(0,q.jsx)(kr,{children:Pp})]}),(0,q.jsx)(Or,{children:(0,q.jsxs)(`form`,{className:`space-y-4`,onSubmit:Xn(ie),children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{className:`block text-xs font-medium text-secondary`,htmlFor:`dashboard-password-new`,children:`Password`}),(0,q.jsx)(`input`,{autoFocus:!0,id:`dashboard-password-new`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600`,type:_?`text`:`password`,name:`new-password`,autoComplete:`new-password`,minLength:8,required:!0,value:p,onChange:e=>ae(e.target.value),"aria-invalid":ue,"aria-describedby":`dashboard-password-new-help`}),(0,q.jsx)(`span`,{id:`dashboard-password-new-help`,"aria-live":`polite`,className:ue?`block text-sm text-negative-400`:`block text-sm text-secondary`,children:ue?`Enter at least 8 characters.`:`Use at least 8 characters.`})]}),(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{className:`block text-xs font-medium text-secondary`,htmlFor:`dashboard-password-confirm`,children:`Confirm password`}),(0,q.jsx)(`input`,{id:`dashboard-password-confirm`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600`,type:_?`text`:`password`,name:`confirm-password`,autoComplete:`new-password`,minLength:8,required:!0,value:h,onChange:e=>N(e.target.value),"aria-invalid":de,"aria-describedby":`dashboard-password-confirm-help`}),(0,q.jsx)(`span`,{id:`dashboard-password-confirm-help`,"aria-live":`polite`,className:de?`block text-sm text-negative-400`:`block text-sm text-secondary`,children:de?`Passwords do not match.`:`Enter the same password again.`})]}),x?(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(`label`,{className:`block text-xs font-medium text-secondary`,htmlFor:`dashboard-setup-root-key`,children:Fp.label}),(0,q.jsx)(`input`,{autoFocus:!0,id:`dashboard-setup-root-key`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600`,type:_?`text`:`password`,name:`apiKey`,autoComplete:`off`,spellCheck:!1,required:!0,value:C,onChange:e=>M(e.target.value),"aria-invalid":T===Fp.rejected,"aria-describedby":`dashboard-setup-root-key-help`}),(0,q.jsx)(`span`,{id:`dashboard-setup-root-key-help`,"aria-live":`polite`,className:`block text-sm text-secondary`,children:Fp.help})]}):null,(0,q.jsxs)(`label`,{className:`flex min-h-10 cursor-pointer items-center gap-2 text-sm text-secondary`,htmlFor:`dashboard-password-show`,children:[(0,q.jsx)(`input`,{id:`dashboard-password-show`,type:`checkbox`,checked:_,onChange:e=>v(e.target.checked)}),x?Fp.show:`Show passwords`]}),T?(0,q.jsx)(`p`,{id:`dashboard-password-setup-error`,role:`alert`,className:`text-sm text-negative-400`,children:T}):null,(0,q.jsx)(W,{type:`submit`,disabled:D||!fe,children:D?`Creating password…`:`Create password and continue`})]})})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(Dr,{children:[(0,q.jsx)(`p`,{className:`eyebrow eyebrow-soft`,children:`Dashboard access`}),(0,q.jsx)(`h1`,{className:`font-medium tracking-tight text-primary`,children:`Sign in to Canonry`}),(0,q.jsx)(kr,{children:y===`api-key`?`Enter an API key from this Canonry install. This opens the dashboard with that key’s access and does not change the password.`:`Enter your dashboard password to continue.`})]}),(0,q.jsxs)(Or,{children:[ee?(0,q.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,(0,q.jsxs)(`form`,{className:`space-y-4`,onSubmit:Xn(oe),children:[(0,q.jsxs)(`label`,{className:`block space-y-1.5`,htmlFor:`dashboard-password-current`,children:[(0,q.jsx)(`span`,{className:`text-xs font-medium text-secondary`,children:y===`api-key`?`Canonry API key`:`Password`}),(0,q.jsx)(`input`,{autoFocus:!0,id:`dashboard-password-current`,className:`w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600`,type:_?`text`:`password`,name:y===`api-key`?`apiKey`:`password`,autoComplete:y===`api-key`?`off`:`current-password`,spellCheck:!1,required:!0,value:p,onChange:e=>ae(e.target.value),"aria-invalid":!!T,"aria-describedby":T?`dashboard-password-login-error`:void 0})]}),(0,q.jsxs)(`label`,{className:`flex min-h-10 cursor-pointer items-center gap-2 text-sm text-secondary`,htmlFor:`dashboard-login-password-show`,children:[(0,q.jsx)(`input`,{id:`dashboard-login-password-show`,type:`checkbox`,checked:_,onChange:e=>v(e.target.checked)}),y===`api-key`?`Show API key`:`Show password`]}),T?(0,q.jsx)(`p`,{id:`dashboard-password-login-error`,role:`alert`,className:`text-sm text-negative-400`,children:T}):null,(0,q.jsx)(W,{type:`submit`,disabled:D||!p.trim(),children:D?`Signing in…`:`Open dashboard`}),(0,q.jsx)(W,{type:`button`,variant:`ghost`,onClick:()=>se(y===`api-key`?`password`:`api-key`),children:y===`api-key`?`Use dashboard password instead`:`Forgot password? Use API key`})]})]})]})})]})})}var Lp=document.getElementById(`root`);if(!Lp)throw Error(`Expected #root element for web app bootstrap.`);Tp(),(0,Ir.createRoot)(Lp).render((0,q.jsx)(K.StrictMode,{children:(0,q.jsx)(Ip,{})}));export{Ko as $,wi as $t,au as A,ya as At,Ps as B,Xi as Bt,Iu as C,na as Ct,su as D,ea as Dt,xu as E,ma as Et,fl as F,Ki as Ft,xs as G,Zi as Gt,ws as H,J as Ht,dl as I,ga as It,Ss as J,xa as Jt,Cs as K,ja as Kt,ul as L,Aa as Lt,Xl as M,ia as Mt,$l as N,ca as Nt,eu as O,ua as Ot,pl as P,Oa as Pt,Yo as Q,ki as Qt,ks as R,Da as Rt,Gu as S,Bi as St,Tu as T,zi as Tt,ys as U,$i as Ut,Ns as V,Ri as Vt,_s as W,Qi as Wt,es as X,ba as Xt,ns as Y,aa as Yt,Zo as Z,Ci as Zt,Yu as _,pa as _t,yd as a,ni as an,Ka as at,qu as b,Vi as bt,fd as c,Zr as cn,Ba as ct,nd as d,Ha as dt,Ti as en,Go as et,ad as f,Na as ft,Zu as g,Li as gt,ed as h,Ii as ht,zd as i,ii as in,qa as it,Zl as j,Ui as jt,iu as k,la as kt,md as l,Ur as ln,Ua as lt,sd as m,Fi as mt,Ld as n,ai as nn,Ja as nt,Ed as o,Xr as on,Ga as ot,cd as p,Ma as pt,vs as q,ha as qt,Rd as r,oi as rn,Za as rt,gd as s,Kr as sn,Pa as st,nf as t,li as tn,Co as tt,pd as u,Br as un,Va as ut,Wu as v,sa as vt,Pu as w,ta as wt,Uu as x,Hi as xt,Ku as y,Wi as yt,Os as z,fa as zt};