@ainyc/canonry 4.55.1 → 4.55.3

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 (24) hide show
  1. package/assets/agent-workspace/skills/canonry/references/server-side-traffic.md +9 -4
  2. package/assets/assets/{BacklinksPage-DVmaM864.js → BacklinksPage-buvZ4ZOd.js} +1 -1
  3. package/assets/assets/{ProjectPage-DtL3LFne.js → ProjectPage-D0UqSqe7.js} +1 -1
  4. package/assets/assets/{RunRow-BRqiLxj2.js → RunRow-D-DTu1PA.js} +1 -1
  5. package/assets/assets/{RunsPage-UxZ93-cg.js → RunsPage-CrBpgwkO.js} +1 -1
  6. package/assets/assets/{SettingsPage-Cr5_EGbk.js → SettingsPage-Bgsi9tZ2.js} +1 -1
  7. package/assets/assets/{TrafficPage-CUC_lfTe.js → TrafficPage-DAHXrzqz.js} +1 -1
  8. package/assets/assets/TrafficSourceDetailPage-DCcDN3VD.js +1 -0
  9. package/assets/assets/{extract-error-message-DD5MibWI.js → extract-error-message-BGhWiJPr.js} +1 -1
  10. package/assets/assets/{index-nnF1LnyK.js → index-CbDkoDBH.js} +2 -2
  11. package/assets/assets/{index-Bm3JQsW0.css → index-dxdJhCQO.css} +1 -1
  12. package/assets/assets/{server-traffic-DjRISEZ-.js → server-traffic-3xxyOEIX.js} +1 -1
  13. package/assets/assets/{trash-2-CJ5M--Le.js → trash-2-dppRdHYI.js} +1 -1
  14. package/assets/index.html +2 -2
  15. package/dist/{chunk-2OI7HFAB.js → chunk-5EAGNVCJ.js} +131 -188
  16. package/dist/{chunk-ZY3EDW3S.js → chunk-UOQ62KDD.js} +8 -3
  17. package/dist/{chunk-UTM3FPAJ.js → chunk-XB6Y63NI.js} +181 -3
  18. package/dist/{chunk-OFY3Z2F7.js → chunk-XHU35P3S.js} +359 -361
  19. package/dist/cli.js +12 -10
  20. package/dist/index.js +4 -4
  21. package/dist/{intelligence-service-NKAEHHJ5.js → intelligence-service-4PT22FED.js} +2 -2
  22. package/dist/mcp.js +2 -2
  23. package/package.json +6 -6
  24. package/assets/assets/TrafficSourceDetailPage-DARPL2TU.js +0 -1
package/dist/cli.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  setTelemetrySource,
24
24
  showFirstRunNotice,
25
25
  trackEvent
26
- } from "./chunk-2OI7HFAB.js";
26
+ } from "./chunk-5EAGNVCJ.js";
27
27
  import {
28
28
  CliError,
29
29
  EXIT_SYSTEM_ERROR,
@@ -39,14 +39,14 @@ import {
39
39
  saveConfig,
40
40
  saveConfigPatch,
41
41
  usageError
42
- } from "./chunk-ZY3EDW3S.js";
42
+ } from "./chunk-UOQ62KDD.js";
43
43
  import {
44
44
  apiKeys,
45
45
  createClient,
46
46
  migrate,
47
47
  projects,
48
48
  queries
49
- } from "./chunk-UTM3FPAJ.js";
49
+ } from "./chunk-XB6Y63NI.js";
50
50
  import {
51
51
  CcReleaseSyncStatuses,
52
52
  CheckScopes,
@@ -65,7 +65,7 @@ import {
65
65
  providerQuotaPolicySchema,
66
66
  resolveProviderInput,
67
67
  skillsClientSchema
68
- } from "./chunk-OFY3Z2F7.js";
68
+ } from "./chunk-XHU35P3S.js";
69
69
 
70
70
  // src/cli.ts
71
71
  import { pathToFileURL } from "url";
@@ -6811,7 +6811,7 @@ async function showRun(id, format) {
6811
6811
  }
6812
6812
  async function listRuns(project, opts) {
6813
6813
  const client = getClient17();
6814
- const runs = await client.listRuns(project, opts?.limit);
6814
+ const runs = await client.listRuns(project, opts?.limit, opts?.kind);
6815
6815
  if (opts?.format === "json") {
6816
6816
  console.log(JSON.stringify(runs, null, 2));
6817
6817
  return;
@@ -6961,19 +6961,21 @@ var RUN_CLI_COMMANDS = [
6961
6961
  },
6962
6962
  {
6963
6963
  path: ["runs"],
6964
- usage: "canonry runs <project> [--limit <n>] [--format json]",
6964
+ usage: "canonry runs <project> [--limit <n>] [--kind <kind>] [--format json]",
6965
6965
  options: {
6966
- limit: stringOption()
6966
+ limit: stringOption(),
6967
+ kind: stringOption()
6967
6968
  },
6968
6969
  run: async (input) => {
6969
- const project = requireProject(input, "runs", "canonry runs <project> [--limit <n>] [--format json]");
6970
+ const project = requireProject(input, "runs", "canonry runs <project> [--limit <n>] [--kind <kind>] [--format json]");
6970
6971
  await listRuns(project, {
6971
6972
  format: input.format,
6972
6973
  limit: parseIntegerOption(input, "limit", {
6973
6974
  command: "runs",
6974
- usage: "canonry runs <project> [--limit <n>] [--format json]",
6975
+ usage: "canonry runs <project> [--limit <n>] [--kind <kind>] [--format json]",
6975
6976
  message: "--limit must be an integer"
6976
- })
6977
+ }),
6978
+ kind: getString(input.values, "kind")
6977
6979
  });
6978
6980
  }
6979
6981
  }
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  createServer
3
- } from "./chunk-2OI7HFAB.js";
3
+ } from "./chunk-5EAGNVCJ.js";
4
4
  import {
5
5
  loadConfig
6
- } from "./chunk-ZY3EDW3S.js";
7
- import "./chunk-UTM3FPAJ.js";
8
- import "./chunk-OFY3Z2F7.js";
6
+ } from "./chunk-UOQ62KDD.js";
7
+ import "./chunk-XB6Y63NI.js";
8
+ import "./chunk-XHU35P3S.js";
9
9
  export {
10
10
  createServer,
11
11
  loadConfig
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  IntelligenceService
3
- } from "./chunk-UTM3FPAJ.js";
4
- import "./chunk-OFY3Z2F7.js";
3
+ } from "./chunk-XB6Y63NI.js";
4
+ import "./chunk-XHU35P3S.js";
5
5
  export {
6
6
  IntelligenceService
7
7
  };
package/dist/mcp.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  CliError,
3
3
  canonryMcpTools,
4
4
  createApiClient
5
- } from "./chunk-ZY3EDW3S.js";
6
- import "./chunk-OFY3Z2F7.js";
5
+ } from "./chunk-UOQ62KDD.js";
6
+ import "./chunk-XHU35P3S.js";
7
7
 
8
8
  // src/mcp/cli.ts
9
9
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ainyc/canonry",
3
- "version": "4.55.1",
3
+ "version": "4.55.3",
4
4
  "type": "module",
5
5
  "description": "Agent-first open-source AEO operating platform - track how answer engines cite your domain",
6
6
  "license": "FSL-1.1-ALv2",
@@ -62,20 +62,20 @@
62
62
  "tsup": "^8.5.1",
63
63
  "tsx": "^4.19.0",
64
64
  "@ainyc/canonry-api-client": "0.0.0",
65
- "@ainyc/canonry-api-routes": "0.0.0",
66
65
  "@ainyc/canonry-config": "0.0.0",
67
66
  "@ainyc/canonry-contracts": "0.0.0",
68
67
  "@ainyc/canonry-db": "0.0.0",
69
68
  "@ainyc/canonry-integration-bing": "0.0.0",
69
+ "@ainyc/canonry-api-routes": "0.0.0",
70
70
  "@ainyc/canonry-integration-cloud-run": "0.0.0",
71
- "@ainyc/canonry-integration-commoncrawl": "0.0.0",
72
- "@ainyc/canonry-integration-google": "0.0.0",
73
71
  "@ainyc/canonry-integration-traffic": "0.0.0",
74
- "@ainyc/canonry-integration-wordpress": "0.0.0",
72
+ "@ainyc/canonry-integration-commoncrawl": "0.0.0",
75
73
  "@ainyc/canonry-intelligence": "0.0.0",
74
+ "@ainyc/canonry-integration-google": "0.0.0",
75
+ "@ainyc/canonry-provider-cdp": "0.0.0",
76
76
  "@ainyc/canonry-provider-claude": "0.0.0",
77
+ "@ainyc/canonry-integration-wordpress": "0.0.0",
77
78
  "@ainyc/canonry-provider-gemini": "0.0.0",
78
- "@ainyc/canonry-provider-cdp": "0.0.0",
79
79
  "@ainyc/canonry-provider-local": "0.0.0",
80
80
  "@ainyc/canonry-provider-openai": "0.0.0",
81
81
  "@ainyc/canonry-provider-perplexity": "0.0.0"
@@ -1 +0,0 @@
1
- import{j as e,A as fe,B as ge,r as m,L as be}from"./vendor-tanstack-Dq7p98wZ.js";import{I as je,bB as x,T as ye,B as Ne,g as $,bC as ve,bD as we}from"./index-nnF1LnyK.js";import{A as Z,e as Se}from"./extract-error-message-DD5MibWI.js";import{d as K,e as ke,C as q,a as J,c as ze}from"./ChartPrimitives-9Kx3gzQL.js";import{e as Ce,f as Te,g as Ae,t as Re,R as Ie}from"./server-traffic-DjRISEZ-.js";import{R as $e,B as Le,a as Ue,X as Me,Y as De,T as Fe,b as O,d as B}from"./vendor-recharts-DWvKDyBF.js";import"./vendor-radix-B57xfQbP.js";import"./vendor-markdown-DK7fbRNb.js";function I({value:t,label:a,delta:n,tone:r,description:u,tooltip:i,isNumeric:c=!0,progress:o,providerCoverage:d}){const y=2*Math.PI*48,h=Number.parseInt(t,10),C=typeof o=="number"&&Number.isFinite(o)?Math.min(Math.max(o,0),100)/100:c&&!Number.isNaN(h)?Math.min(h/100,1):.5,N=y*(1-C);return e.jsxs("div",{className:"score-gauge",children:[e.jsxs("div",{className:"gauge-ring-wrapper",children:[e.jsxs("svg",{className:"gauge-ring",viewBox:"0 0 120 120","aria-hidden":"true",children:[e.jsx("circle",{className:"gauge-bg",cx:"60",cy:"60",r:48,strokeWidth:6}),e.jsx("circle",{className:`gauge-fill gauge-fill-${r}`,cx:"60",cy:"60",r:48,strokeWidth:6,strokeDasharray:y,strokeDashoffset:N,transform:"rotate(-90 60 60)"})]}),e.jsx("div",{className:"gauge-center",children:e.jsx("span",{className:c?"gauge-value":"gauge-value-text",children:t.split(" / ")[0]})})]}),e.jsxs("p",{className:"gauge-label",children:[a,i&&e.jsx(je,{text:i})]}),e.jsx("p",{className:"gauge-delta",children:n}),d&&e.jsx("p",{className:"gauge-provider-coverage",children:d}),e.jsx("p",{className:"gauge-description",children:u})]})}const He=[{value:"all",label:"All status"},{value:"2xx",label:"2xx success"},{value:"3xx",label:"3xx redirect"},{value:"4xx",label:"4xx client error"},{value:"5xx",label:"5xx server error"}];function Ee(t){return t==="all"?null:Number.parseInt(t[0],10)}function le(t){switch(t.kind){case x.crawler:case x["ai-user-fetch"]:return t.botId;case x["ai-referral"]:return t.product}}function ie(t){switch(t.kind){case x.crawler:case x["ai-user-fetch"]:return t.pathNormalized;case x["ai-referral"]:return t.landingPathNormalized}}function ce(t,a){if(a==="hour")return t;const n=new Date(t),r=n.getFullYear(),u=String(n.getMonth()+1).padStart(2,"0"),i=String(n.getDate()).padStart(2,"0");return`${r}-${u}-${i}`}function Oe(t,a,n){const r=a.pathQuery.trim().toLowerCase(),u=Ee(a.statusClass);return t.filter(i=>!(a.selectedBucket&&ce(i.tsHour,n)!==a.selectedBucket||a.identity&&le(i)!==a.identity||a.operator&&i.operator!==a.operator||r&&!ie(i).toLowerCase().includes(r)||u!==null&&Math.floor(i.status/100)!==u))}function Be(t,a){if(!t||typeof t!="object")return null;const n=t.activeTooltipIndex;let r;if(typeof n=="number")r=n;else if(typeof n=="string"&&n!=="")r=Number(n);else return null;return!Number.isInteger(r)||r<0||r>=a.length?null:a[r]?.bucket??null}const U=[{value:60,label:"1h",granularity:"hour",fetchLimit:500},{value:360,label:"6h",granularity:"hour",fetchLimit:500},{value:1440,label:"24h",granularity:"hour",fetchLimit:500},{value:10080,label:"7d",granularity:"hour",fetchLimit:1e3},{value:720*60,label:"30d",granularity:"day",fetchLimit:2e3},{value:2160*60,label:"90d",granularity:"day",fetchLimit:5e3}],ee=U.find(t=>t.label==="7d")??U[2],te=K[0],se=K[2],ae=K[1],re=ve();function oe(t){const a=new Date(t);return`${a.getMonth()+1}/${a.getDate()} ${String(a.getHours()).padStart(2,"0")}:00`}function Pe(t){const a=new Date(`${t}T00:00:00`);return`${a.getMonth()+1}/${a.getDate()}`}function T(t){if(!t)return"never";const a=Date.now()-new Date(t).getTime(),n=Math.floor(a/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function ne({canGoBack:t,className:a}){const n="inline-flex items-center gap-1";if(t){const r=()=>{window.history.back()};return e.jsxs("button",{type:"button",onClick:r,className:`${n} ${a??""}`,children:[e.jsx(Z,{className:"size-3"})," Back"]})}return e.jsxs(be,{to:"/traffic",className:`${n} ${a??""}`,children:[e.jsx(Z,{className:"size-3"})," All sources"]})}function st(){const t=fe({strict:!1}),a=t.projectName??"",n=ge(),r=t.sourceId??"",[u,i]=m.useState(ee.value),[c,o]=m.useState(()=>new Set(["crawler","ai-user-fetch","ai-referral"])),[d,w]=m.useState(null),[f,y]=m.useState(""),[h,C]=m.useState(""),[N,M]=m.useState(""),[k,D]=m.useState("all"),[W,G]=m.useState(null),[Y,X]=m.useState(null),b=m.useMemo(()=>U.find(s=>s.value===u)??ee,[u]),F=Ce(a||null,r||null),j=Te(a||null,{kind:"all",sourceId:r||void 0,sinceMinutes:u,limit:b.fetchLimit}),R=Ae(a||null,r||null),l=F.data,v=j.data?.events??[],S=j.data?.totals,H=m.useMemo(()=>v.filter(s=>{switch(s.kind){case x.crawler:return c.has("crawler");case x["ai-user-fetch"]:return c.has("ai-user-fetch");case x["ai-referral"]:return c.has("ai-referral")}}),[v,c]),ue=m.useMemo(()=>{const s=new Set;for(const p of v)s.add(le(p));return f&&s.add(f),[...s].sort((p,g)=>p.localeCompare(g))},[v,f]),de=m.useMemo(()=>{const s=new Set;for(const p of v)s.add(p.operator);return h&&s.add(h),[...s].sort((p,g)=>p.localeCompare(g))},[v,h]),Q=m.useMemo(()=>Oe(H,{selectedBucket:d,identity:f,operator:h,pathQuery:N,statusClass:k},b.granularity),[H,d,f,h,N,k,b.granularity]),V=m.useMemo(()=>d?L(d,b.granularity):null,[d,b.granularity]),z=m.useMemo(()=>_e(v,b.granularity,j.data?.windowStart,j.data?.windowEnd),[v,b.granularity,j.data?.windowStart,j.data?.windowEnd]),E=s=>{o(p=>{const g=new Set(p);return g.has(s)?g.size>1&&g.delete(s):g.add(s),g})},xe=s=>{const p=Be(s,z);p&&w(g=>g===p?null:p)},he=()=>{w(null),y(""),C(""),M(""),D("all")},me=!!(d||f||h||N.trim()||k!=="all"),pe=async()=>{G(null),X(null);try{const s=await R.mutateAsync({sinceMinutes:60});X(`Pulled ${s.pulledEvents} entries · ${s.crawlerHits} crawler · ${s.aiReferralHits} AI referral · ${s.unknownHits} unknown`)}catch(s){G(Se(s))}};return!a||!r?e.jsx("div",{className:"page-container",children:e.jsx("p",{className:"text-sm text-zinc-500",children:"Missing project name or source id in URL."})}):F.isLoading?e.jsx("div",{className:"page-container",children:e.jsx("p",{className:"text-sm text-zinc-500",children:"Loading source…"})}):F.isError||!l?e.jsxs("div",{className:"page-container",children:[e.jsx("p",{className:"text-sm text-rose-300",children:"Could not load this source."}),e.jsx(ne,{canGoBack:n,className:"mt-2 text-xs text-zinc-400 hover:text-zinc-200"})]}):e.jsxs("div",{className:"page-container space-y-8",children:[e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{className:"page-header-left",children:[e.jsx(ne,{canGoBack:n,className:"text-xs text-zinc-500 hover:text-zinc-200"}),e.jsx("h1",{className:"page-title mt-2",children:l.displayName}),e.jsxs("p",{className:"page-subtitle",children:[l.sourceType," · project ",e.jsx("span",{className:"text-zinc-300",children:a})," ·",e.jsx("span",{className:"ml-1 font-mono text-zinc-400",children:l.id})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{tone:Re(l.status),children:l.status}),e.jsxs(Ne,{type:"button",variant:"outline",size:"sm",disabled:R.isPending,onClick:()=>{pe()},children:[e.jsx(Ie,{className:`size-3.5 ${R.isPending?"animate-spin":""}`}),R.isPending?"Syncing…":"Sync now"]})]})]}),W?e.jsx("div",{className:"rounded-md border border-rose-800/50 bg-rose-950/30 px-3 py-2 text-xs text-rose-200",children:W}):null,Y?e.jsx("div",{className:"rounded-md border border-emerald-800/50 bg-emerald-950/30 px-3 py-2 text-xs text-emerald-200",children:Y}):null,e.jsxs("section",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(I,{label:"24h crawler hits",value:String(l.totals24h.crawlerHits),delta:l.lastSyncedAt?`last sync ${T(l.lastSyncedAt)}`:"never synced",tone:l.totals24h.crawlerHits>0?"positive":"neutral",description:"Bulk machine crawl — GPTBot, OAI-SearchBot, PerplexityBot, Googlebot, etc.",isNumeric:!0,progress:Math.min(100,Math.round(l.totals24h.crawlerHits/1e3*100))}),e.jsx(I,{label:"24h AI user fetches",value:String(l.totals24h.aiUserFetchHits),delta:l.lastSyncedAt?`last sync ${T(l.lastSyncedAt)}`:"never synced",tone:l.totals24h.aiUserFetchHits>0?"positive":"neutral",description:"ChatGPT-User, Perplexity-User — fetches initiated by a real user inside an AI surface (citation click, URL read).",isNumeric:!0,progress:Math.min(100,Math.round(l.totals24h.aiUserFetchHits/1e3*100))}),e.jsx(I,{label:"24h AI referral sessions",value:String(l.totals24h.aiReferralHits),delta:l.lastSyncedAt?`last sync ${T(l.lastSyncedAt)}`:"never synced",tone:l.totals24h.aiReferralHits>0?"positive":"neutral",description:"Browser click-throughs from chatgpt.com, perplexity.ai, etc. (Referer / UTM evidence).",isNumeric:!0,progress:Math.min(100,Math.round(l.totals24h.aiReferralHits/1e3*100))}),e.jsx(I,{label:"24h sample rows",value:String(l.totals24h.sampleCount),delta:"bounded per sync",tone:"neutral",description:"Per-request samples retained for evidence (capped to keep storage bounded).",isNumeric:!0,progress:Math.min(100,Math.round(l.totals24h.sampleCount/100*100))})]}),e.jsxs("section",{children:[e.jsx("p",{className:"mb-4 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:"Latest sync run"}),l.latestRun?e.jsxs($,{className:"p-4 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-1.5",children:[e.jsxs("span",{className:"text-zinc-100",children:["Status: ",e.jsx("span",{className:"font-medium",children:l.latestRun.status})]}),e.jsxs("span",{className:"text-zinc-500",children:["Started: ",T(l.latestRun.startedAt)]}),l.latestRun.finishedAt?e.jsxs("span",{className:"text-zinc-500",children:["Finished: ",T(l.latestRun.finishedAt)]}):null,e.jsx("span",{className:"font-mono text-[11px] text-zinc-600",children:l.latestRun.runId})]}),l.latestRun.error?e.jsx("p",{className:"mt-2 rounded border border-rose-900/40 bg-rose-950/30 px-3 py-2 text-xs text-rose-300",children:l.latestRun.error}):null]}):e.jsx($,{className:"px-4 py-3 text-sm text-zinc-500",children:'No traffic-sync runs recorded yet. Hit "Sync now" above to create one.'})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-end justify-between gap-x-4 gap-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:"Events"}),e.jsx("h2",{className:"mt-1 text-base font-semibold text-zinc-50",children:b.granularity==="day"?"Daily rollups":"Hourly rollups"}),S?e.jsxs("p",{className:"mt-1.5 text-xs text-zinc-500",children:[S.crawlerHits.toLocaleString("en-US")," crawler ·"," ",S.aiUserFetchHits.toLocaleString("en-US")," AI user fetches ·"," ",S.aiReferralHits.toLocaleString("en-US")," AI referral sessions · last ",b.label," · ",re]}):null]}),e.jsx("div",{className:"filter-row mb-0",role:"toolbar","aria-label":"Window",children:U.map(s=>e.jsx("button",{type:"button",className:`filter-chip ${u===s.value?"filter-chip-active":""}`,"aria-pressed":u===s.value,onClick:()=>{i(s.value),w(null)},children:s.label},s.value))})]}),e.jsxs($,{className:"p-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",role:"toolbar","aria-label":"Series",children:[e.jsx(_,{label:"Crawler",color:te,count:S?.crawlerHits??0,active:c.has("crawler"),onToggle:()=>E("crawler")}),e.jsx(_,{label:"AI user fetches",color:se,count:S?.aiUserFetchHits??0,active:c.has("ai-user-fetch"),onToggle:()=>E("ai-user-fetch")}),e.jsx(_,{label:"AI referral sessions",color:ae,count:S?.aiReferralHits??0,active:c.has("ai-referral"),onToggle:()=>E("ai-referral")})]}),j.isError?e.jsxs("p",{className:"py-12 text-center text-xs text-rose-400",children:["Failed to load events: ",j.error instanceof Error?j.error.message:"Unknown error"]}):j.isLoading?e.jsx("p",{className:"py-12 text-center text-xs text-zinc-500",children:"Loading events…"}):z.length===0?e.jsx("p",{className:"py-12 text-center text-xs text-zinc-500",children:"No events in this window."}):e.jsx("div",{className:"h-72",children:e.jsx($e,{children:e.jsxs(Le,{data:z,margin:{top:4,right:4,bottom:0,left:0},onClick:xe,style:{cursor:"pointer"},children:[e.jsx(Ue,{stroke:ke,strokeDasharray:"3 3"}),e.jsx(Me,{dataKey:"label",tick:J,stroke:q,interval:"preserveStartEnd",minTickGap:b.granularity==="day"?24:32}),e.jsx(De,{tick:J,stroke:q,allowDecimals:!1}),e.jsx(Fe,{...ze}),c.has("crawler")?e.jsx(O,{dataKey:"crawler",name:"Crawler",fill:te,stackId:"a",children:z.map(s=>e.jsx(B,{fillOpacity:d&&d!==s.bucket?.25:1},s.bucket))}):null,c.has("ai-user-fetch")?e.jsx(O,{dataKey:"aiUserFetch",name:"AI user fetch",fill:se,stackId:"a",children:z.map(s=>e.jsx(B,{fillOpacity:d&&d!==s.bucket?.25:1},s.bucket))}):null,c.has("ai-referral")?e.jsx(O,{dataKey:"aiReferral",name:"AI referral",fill:ae,stackId:"a",children:z.map(s=>e.jsx(B,{fillOpacity:d&&d!==s.bucket?.25:1},s.bucket))}):null]})})})]})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-end justify-between gap-x-4 gap-y-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:"Event rows"}),e.jsxs("p",{className:"mt-1 text-xs text-zinc-500",children:["Showing ",e.jsx("span",{className:"tabular-nums text-zinc-300",children:Q.length.toLocaleString("en-US")})," of"," ",e.jsx("span",{className:"tabular-nums text-zinc-500",children:H.length.toLocaleString("en-US")})," events · ",re]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("select",{"aria-label":"Filter by identity",value:f,onChange:s=>y(s.target.value),className:"rounded-md border border-zinc-800 bg-zinc-950 px-2.5 py-1.5 text-xs text-zinc-200 focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-600",children:[e.jsx("option",{value:"",children:"All identities"}),ue.map(s=>e.jsx("option",{value:s,children:s},s))]}),e.jsxs("select",{"aria-label":"Filter by operator",value:h,onChange:s=>C(s.target.value),className:"rounded-md border border-zinc-800 bg-zinc-950 px-2.5 py-1.5 text-xs text-zinc-200 focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-600",children:[e.jsx("option",{value:"",children:"All operators"}),de.map(s=>e.jsx("option",{value:s,children:s},s))]}),e.jsx("select",{"aria-label":"Filter by HTTP status class",value:k,onChange:s=>D(s.target.value),className:"rounded-md border border-zinc-800 bg-zinc-950 px-2.5 py-1.5 text-xs text-zinc-200 focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-600",children:He.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))}),e.jsx("input",{type:"search","aria-label":"Filter by path",placeholder:"path contains…",value:N,onChange:s=>M(s.target.value),className:"w-44 rounded-md border border-zinc-800 bg-zinc-950 px-2.5 py-1.5 text-xs text-zinc-200 placeholder:text-zinc-600 focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-600"})]})]}),me?e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[V?e.jsx(A,{label:`Bucket: ${V}`,onClear:()=>w(null)}):null,f?e.jsx(A,{label:`Identity: ${f}`,onClear:()=>y("")}):null,h?e.jsx(A,{label:`Operator: ${h}`,onClear:()=>C("")}):null,N.trim()?e.jsx(A,{label:`Path: ${N.trim()}`,onClear:()=>M("")}):null,k!=="all"?e.jsx(A,{label:`Status: ${k}`,onClear:()=>D("all")}):null,e.jsx("button",{type:"button",onClick:he,className:"text-xs text-zinc-500 underline-offset-4 hover:text-zinc-200 hover:underline",children:"Clear all"})]}):null,e.jsx(Ye,{events:Q})]})]})}function P(t,a){return{bucket:t,label:a,crawler:0,aiUserFetch:0,aiReferral:0}}function L(t,a){return a==="day"?Pe(t):oe(t)}function _e(t,a,n,r){const u=new Map;for(const i of t){const c=ce(i.tsHour,a);let o=u.get(c);switch(o||(o=P(c,L(c,a)),u.set(c,o)),i.kind){case x.crawler:o.crawler+=i.hits;break;case x["ai-user-fetch"]:o.aiUserFetch+=i.hits;break;case x["ai-referral"]:o.aiReferral+=i.hits;break}}if(n&&r){const i=new Date(n),c=new Date(r);if(a==="day"){const o=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate())),d=new Date(Date.UTC(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()));for(;o<=d;){const w=o.getUTCFullYear(),f=String(o.getUTCMonth()+1).padStart(2,"0"),y=String(o.getUTCDate()).padStart(2,"0"),h=`${w}-${f}-${y}`;u.has(h)||u.set(h,P(h,L(h,a))),o.setUTCDate(o.getUTCDate()+1)}}else{const o=new Date(i);for(o.setUTCMinutes(0,0,0);o<=c;){const d=o.toISOString();u.has(d)||u.set(d,P(d,L(d,a))),o.setUTCHours(o.getUTCHours()+1)}}}return[...u.values()].sort((i,c)=>i.bucket<c.bucket?-1:i.bucket>c.bucket?1:0)}function A({label:t,onClear:a}){return e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-zinc-700 bg-zinc-800/60 px-2.5 py-1 text-[11px] text-zinc-200",children:[t,e.jsx("button",{type:"button",onClick:a,"aria-label":`Clear ${t}`,className:"rounded-full p-0.5 text-zinc-400 hover:bg-zinc-700/60 hover:text-zinc-100",children:e.jsx(we,{className:"size-3"})})]})}function _({label:t,color:a,count:n,active:r,onToggle:u}){return e.jsxs("button",{type:"button",onClick:u,"aria-pressed":r,className:`inline-flex items-center gap-2 rounded-full border px-3 py-1 text-xs font-medium transition ${r?"border-zinc-700 bg-zinc-800/60 text-zinc-100":"border-zinc-800 bg-transparent text-zinc-500 hover:text-zinc-300"}`,children:[e.jsx("span",{"aria-hidden":"true",className:`size-2 rounded-full transition-opacity ${r?"opacity-100":"opacity-30"}`,style:{backgroundColor:a}}),e.jsx("span",{children:t}),e.jsx("span",{className:`tabular-nums ${r?"text-zinc-400":"text-zinc-600"}`,children:n.toLocaleString("en-US")})]})}function Ke(t){switch(t){case x.crawler:return"Crawler";case x["ai-user-fetch"]:return"AI hit";case x["ai-referral"]:return"AI referral"}}function We(t){switch(t.kind){case x.crawler:case x["ai-user-fetch"]:return t.botId;case x["ai-referral"]:return t.product}}function Ge(t){switch(t.kind){case x.crawler:case x["ai-user-fetch"]:return`${t.verificationStatus} · HTTP ${t.status}`;case x["ai-referral"]:return`${t.evidenceType} · ${t.sourceDomain}`}}function Ye({events:t}){return t.length===0?e.jsx($,{className:"p-6 text-center text-sm text-zinc-500",children:"No event rows match the current filters."}):e.jsx("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-zinc-900/50 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2 text-left",children:"Hour"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Kind"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Identity"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Evidence / status"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Path"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Hits"})]})}),e.jsx("tbody",{className:"divide-y divide-zinc-800/60",children:t.map((a,n)=>e.jsxs("tr",{className:"hover:bg-zinc-900/40 transition-colors",children:[e.jsx("td",{className:"px-4 py-2 font-mono text-xs text-zinc-300",children:oe(a.tsHour)}),e.jsx("td",{className:"px-4 py-2 text-zinc-300",children:Ke(a.kind)}),e.jsxs("td",{className:"px-4 py-2 text-zinc-100",children:[We(a),e.jsx("span",{className:"ml-2 text-[11px] text-zinc-500",children:a.operator})]}),e.jsx("td",{className:"px-4 py-2 text-zinc-300",children:Ge(a)}),e.jsx("td",{className:"px-4 py-2 truncate font-mono text-xs text-zinc-300",children:ie(a)}),e.jsx("td",{className:"px-4 py-2 text-right tabular-nums text-zinc-100",children:a.hits})]},`${a.kind}:${a.tsHour}:${n}`))})]})})}export{st as TrafficSourceDetailPage};