sanity-plugin-seo-copilot 0.2.5 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ import { definePlugin } from "sanity";
5
5
  import { createElement } from "react";
6
6
 
7
7
  // src/components/SEOCopilotPanel.tsx
8
- import { useState as useState16, useRef as useRef10, useCallback as useCallback5, useEffect as useEffect10, useMemo as useMemo5, Suspense } from "react";
8
+ import { useState as useState16, useRef as useRef11, useCallback as useCallback5, useEffect as useEffect11, useMemo as useMemo5, Suspense } from "react";
9
9
  import { useWorkspace } from "sanity";
10
10
  import { createPortal } from "react-dom";
11
11
 
@@ -115,7 +115,14 @@ function detectAuthor(val) {
115
115
  "Authors"
116
116
  // PascalCase variants
117
117
  ];
118
- for (const f of candidateFields) {
118
+ const dynamic = Object.keys(val).filter(
119
+ // Author/byline-ish names, but never fact-check/reviewer fields, nor image/url/
120
+ // id sidecars (e.g. authorPhoto, authorImageUrl, authorId) that could otherwise
121
+ // be mistaken for a reference-typed author.
122
+ (k) => /author|byline/i.test(k) && !/fact|check|review|photo|image|avatar|picture|url|link|count|id$/i.test(k)
123
+ );
124
+ const fields = Array.from(/* @__PURE__ */ new Set([...candidateFields, ...dynamic]));
125
+ for (const f of fields) {
119
126
  const raw = val[f];
120
127
  if (!raw) continue;
121
128
  const first = Array.isArray(raw) ? raw[0] : raw;
@@ -127,8 +134,8 @@ function detectAuthor(val) {
127
134
  }
128
135
  if (typeof first === "object" && first !== null) {
129
136
  const o = first;
130
- const name = o.name || o.fullName || o.displayName;
131
- const creds = o.credentials || o.title || o.suffix;
137
+ const name = [o.name, o.fullName, o.displayName].find((v) => typeof v === "string" && v.trim().length > 0);
138
+ const creds = [o.credentials, o.title, o.suffix].find((v) => typeof v === "string" && v.trim().length > 0);
132
139
  const slug = o.slug?.current;
133
140
  const bio = o.bioUrl || (slug ? `/author/${slug}` : void 0);
134
141
  if (name) {
@@ -176,14 +183,14 @@ function extractImageMeta(value) {
176
183
  }
177
184
  function buildDocumentFields(value) {
178
185
  const val = value;
179
- const title = val?.title;
186
+ const title = typeof val?.title === "string" ? val.title : void 0;
180
187
  const body = val?.body;
181
188
  const { authorName, authorCredentials, authorBioUrl, authorIsReference } = detectAuthor(val);
182
189
  const imageMeta = val ? extractImageMeta(val) : { names: [], titles: [], count: 0 };
183
190
  return {
184
191
  title: title || void 0,
185
192
  // MJH uses `summary`; standard Sanity SEO plugins use `metaDescription`
186
- metaDescription: val?.metaDescription || val?.summary || val?.description || val?.seoDescription,
193
+ metaDescription: [val?.metaDescription, val?.summary, val?.description, val?.seoDescription].find((v) => typeof v === "string" && v.trim().length > 0),
187
194
  slug: detectSlug(val),
188
195
  imageNames: imageMeta.names,
189
196
  imageTitles: imageMeta.titles,
@@ -191,18 +198,18 @@ function buildDocumentFields(value) {
191
198
  headings: extractHeadings(body),
192
199
  headingsDetailed: extractHeadingsDetailed(body),
193
200
  bodyLinks: extractBodyLinks(body),
194
- contentCategory: val?.contentCategory || val?.category,
201
+ contentCategory: typeof val?.contentCategory === "string" ? val.contentCategory : typeof val?.category === "string" ? val.category : void 0,
195
202
  contentPlacement: Array.isArray(val?.contentPlacement) ? val.contentPlacement : void 0,
196
203
  authorName,
197
204
  authorCredentials,
198
205
  authorBioUrl,
199
206
  authorIsReference,
200
207
  // `published` is MJH's date field; `publishedAt`/`publishDate` cover other schemas
201
- publishedAt: val?.published || val?.publishedAt || val?.publishDate || val?._createdAt,
208
+ publishedAt: [val?.publishedAt, val?.publishDate, val?.published, val?._createdAt].find((v) => typeof v === "string" && v.trim().length > 0),
202
209
  // `updatedOn` is MJH's "Updated On" field. `updatedAt` is the standard Sanity convention.
203
210
  // `_updatedAt` is the Sanity-managed timestamp as a final fallback.
204
- updatedAt: val?.updatedOn || val?.updatedAt || val?._updatedAt,
205
- lastReviewedAt: val?.lastReviewedAt || val?.lastReviewed || val?.medicallyReviewedAt
211
+ updatedAt: [val?.updatedOn, val?.updatedAt, val?._updatedAt].find((v) => typeof v === "string" && v.trim().length > 0),
212
+ lastReviewedAt: [val?.lastReviewedAt, val?.lastReviewed, val?.medicallyReviewedAt].find((v) => typeof v === "string" && v.trim().length > 0)
206
213
  };
207
214
  }
208
215
 
@@ -210,6 +217,7 @@ function buildDocumentFields(value) {
210
217
  function useDocumentContent() {
211
218
  const { value, ready } = useDocumentPane();
212
219
  const documentId = value?._id || void 0;
220
+ const documentType = value?._type || void 0;
213
221
  const title = value?.title;
214
222
  const body = value?.body;
215
223
  const [debouncedText, setDebouncedText] = useState("");
@@ -237,7 +245,7 @@ function useDocumentContent() {
237
245
  if (timerRef.current) clearTimeout(timerRef.current);
238
246
  };
239
247
  }, [title, body, value]);
240
- return { text: debouncedText, isLoading, documentFields, documentId };
248
+ return { text: debouncedText, isLoading, documentFields, documentId, documentType };
241
249
  }
242
250
 
243
251
  // src/hooks/useKeywordAnalysis.ts
@@ -260,28 +268,34 @@ function safeParseJson(text) {
260
268
  throw new Error("Invalid JSON response from server");
261
269
  }
262
270
  }
263
- async function fetchAnalysis(apiUrl, content, mode, publication, seedKeywords, documentFields, focusKeyword) {
271
+ async function fetchAnalysis(apiUrl, content, mode, publication, seedKeywords, documentFields, focusKeyword, signal) {
264
272
  const response = await fetch(`${apiUrl}/api/seo-copilot/analyze`, {
265
273
  method: "POST",
266
274
  headers: { "Content-Type": "application/json" },
267
- body: JSON.stringify({ content, mode, publication, seedKeywords, documentFields, focusKeyword })
275
+ body: JSON.stringify({ content, mode, publication, seedKeywords, documentFields, focusKeyword }),
276
+ signal
268
277
  });
269
278
  const text = await response.text();
270
279
  if (!response.ok) {
271
280
  const err = safeParseJson(text);
272
- throw new Error(err.error || `HTTP ${response.status}`);
281
+ if (response.status === 429) throw new Error("Analysis service is busy. Please try again.");
282
+ if (response.status >= 500) throw new Error("Could not reach the SEO service.");
283
+ throw new Error("Something went wrong analyzing this document.");
273
284
  }
274
285
  return safeParseJson(text);
275
286
  }
276
- async function fetchChatStream(apiUrl, messages, documentContext, publication, keywordPanelData) {
287
+ async function fetchChatStream(apiUrl, messages, documentContext, publication, keywordPanelData, signal) {
277
288
  const response = await fetch(`${apiUrl}/api/seo-copilot/chat`, {
278
289
  method: "POST",
279
290
  headers: { "Content-Type": "application/json" },
280
- body: JSON.stringify({ messages, documentContext, publication, keywordPanelData })
291
+ body: JSON.stringify({ messages, documentContext, publication, keywordPanelData }),
292
+ signal
281
293
  });
282
294
  if (!response.ok) {
283
295
  const err = await response.json().catch(() => ({ error: "Request failed" }));
284
- throw new Error(err.error || `HTTP ${response.status}`);
296
+ if (response.status === 429) throw new Error("Analysis service is busy. Please try again.");
297
+ if (response.status >= 500) throw new Error("Could not reach the SEO service.");
298
+ throw new Error("Something went wrong. Please try again.");
285
299
  }
286
300
  return response.body;
287
301
  }
@@ -292,15 +306,18 @@ async function submitFeedback(apiUrl, data) {
292
306
  body: JSON.stringify(data)
293
307
  });
294
308
  }
295
- async function lookupKeywords(apiUrl, keywords) {
309
+ async function lookupKeywords(apiUrl, keywords, signal) {
296
310
  const response = await fetch(`${apiUrl}/api/seo-copilot/keywords`, {
297
311
  method: "POST",
298
312
  headers: { "Content-Type": "application/json" },
299
- body: JSON.stringify({ keywords })
313
+ body: JSON.stringify({ keywords }),
314
+ signal
300
315
  });
301
316
  if (!response.ok) {
302
317
  const err = await response.json().catch(() => ({ error: "Request failed" }));
303
- throw new Error(err.error || `HTTP ${response.status}`);
318
+ if (response.status === 429) throw new Error("Analysis service is busy. Please try again.");
319
+ if (response.status >= 500) throw new Error("Could not reach the SEO service.");
320
+ throw new Error("Something went wrong. Please try again.");
304
321
  }
305
322
  return response.json();
306
323
  }
@@ -316,13 +333,14 @@ async function loadChatHistory(apiUrl, userId, documentId) {
316
333
  return [];
317
334
  }
318
335
  }
319
- async function fetchContentSuggestions(apiUrl, content, primaryKeyword, publication) {
336
+ async function fetchContentSuggestions(apiUrl, content, primaryKeyword, publication, signal) {
320
337
  const empty = { keyTakeaways: [], infographicOpportunities: [], bulletListItems: [] };
321
338
  try {
322
339
  const res = await fetch(`${apiUrl}/api/seo-copilot/content-suggestions`, {
323
340
  method: "POST",
324
341
  headers: { "Content-Type": "application/json" },
325
- body: JSON.stringify({ content, primaryKeyword, publication })
342
+ body: JSON.stringify({ content, primaryKeyword, publication }),
343
+ signal
326
344
  });
327
345
  if (!res.ok) return empty;
328
346
  const data = await res.json().catch(() => null);
@@ -336,13 +354,14 @@ async function fetchContentSuggestions(apiUrl, content, primaryKeyword, publicat
336
354
  return empty;
337
355
  }
338
356
  }
339
- async function fetchLinkingSuggestions(apiUrl, content, primaryKeyword, supportingKeywords, currentDocumentId, publication) {
357
+ async function fetchLinkingSuggestions(apiUrl, content, primaryKeyword, supportingKeywords, currentDocumentId, publication, signal) {
340
358
  if (!content || content.trim().length < 50) return [];
341
359
  try {
342
360
  const res = await fetch(`${apiUrl}/api/seo-copilot/linking-suggestions`, {
343
361
  method: "POST",
344
362
  headers: { "Content-Type": "application/json" },
345
- body: JSON.stringify({ content, primaryKeyword, supportingKeywords, currentDocumentId, publication })
363
+ body: JSON.stringify({ content, primaryKeyword, supportingKeywords, currentDocumentId, publication }),
364
+ signal
346
365
  });
347
366
  if (!res.ok) return [];
348
367
  const data = await res.json().catch(() => null);
@@ -437,6 +456,10 @@ function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFie
437
456
  return;
438
457
  }
439
458
  docVersionRef.current += 1;
459
+ volumeAbortRef.current?.abort();
460
+ volumeAbortRef.current = null;
461
+ deepAbortRef.current?.abort();
462
+ deepAbortRef.current = null;
440
463
  const fresh = loadCached();
441
464
  cached.current = fresh;
442
465
  setAnalysisRaw(fresh.analysis);
@@ -474,43 +497,12 @@ function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFie
474
497
  }, [text, deepAnalysis, aeoTextSnapshot]);
475
498
  const lastAnalysisRef = useRef2(null);
476
499
  const docVersionRef = useRef2(0);
477
- useEffect2(() => {
478
- if ((!text || text.trim().length < 20) && (!effectiveSeeds || effectiveSeeds.length === 0)) {
479
- setAnalysis(null);
480
- return;
481
- }
482
- let cancelled = false;
483
- setIsLoading(true);
484
- setError(null);
485
- fetchAnalysis(apiUrl, text, "realtime", publication, effectiveSeeds, documentFields, focusPrimary).then((result) => {
486
- if (cancelled) return;
487
- const analysisResult = result;
488
- lastAnalysisRef.current = analysisResult;
489
- setAnalysis(analysisResult);
490
- setIsLoading(false);
491
- const candidateTerms = (analysisResult.primaryKeywordCandidates || []).map((c) => c.term);
492
- const allTerms = [
493
- .../* @__PURE__ */ new Set([
494
- ...candidateTerms,
495
- analysisResult.primaryKeyword.term,
496
- ...(analysisResult.supportingKeywords || []).map((kw) => kw.term),
497
- ...analysisResult.missingKeywords.map((kw) => kw.term)
498
- ])
499
- ];
500
- const uncachedTerms = allTerms.filter((t) => !volumeMapRef.current.has(t.toLowerCase()));
501
- if (uncachedTerms.length > 0) {
502
- doVolumeLookup(analysisResult, uncachedTerms);
503
- }
504
- }).catch((err) => {
505
- if (!cancelled) {
506
- setError(err.message);
507
- setIsLoading(false);
508
- }
509
- });
510
- return () => {
511
- cancelled = true;
512
- };
513
- }, [text, apiUrl, publication, effectiveSeeds?.join(","), focusPrimary]);
500
+ const volumeAbortRef = useRef2(null);
501
+ const deepAbortRef = useRef2(null);
502
+ useEffect2(() => () => {
503
+ volumeAbortRef.current?.abort();
504
+ deepAbortRef.current?.abort();
505
+ }, []);
514
506
  const doVolumeLookup = useCallback((analysisResult, terms) => {
515
507
  setIsVolumesLoading(true);
516
508
  const myVersion = docVersionRef.current;
@@ -529,7 +521,10 @@ function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFie
529
521
  setIsVolumesLoading(false);
530
522
  return;
531
523
  }
532
- lookupKeywords(apiUrl, lookupTerms).then(({ results }) => {
524
+ volumeAbortRef.current?.abort();
525
+ const controller = new AbortController();
526
+ volumeAbortRef.current = controller;
527
+ lookupKeywords(apiUrl, lookupTerms, controller.signal).then(({ results }) => {
533
528
  if (docVersionRef.current !== myVersion) return;
534
529
  results.forEach((r) => volumeMapRef.current.set(r.keyword.toLowerCase(), r));
535
530
  const current = lastAnalysisRef.current || analysisResult;
@@ -542,11 +537,56 @@ function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFie
542
537
  } catch {
543
538
  }
544
539
  setIsVolumesLoading(false);
545
- }).catch(() => {
540
+ }).catch((err) => {
541
+ if (err instanceof Error && err.name === "AbortError") return;
546
542
  if (docVersionRef.current !== myVersion) return;
547
543
  setIsVolumesLoading(false);
548
544
  });
549
545
  }, [apiUrl, cacheKey]);
546
+ const doVolumeLookupRef = useRef2(doVolumeLookup);
547
+ useEffect2(() => {
548
+ doVolumeLookupRef.current = doVolumeLookup;
549
+ }, [doVolumeLookup]);
550
+ useEffect2(() => {
551
+ if ((!text || text.trim().length < 20) && (!effectiveSeeds || effectiveSeeds.length === 0)) {
552
+ setAnalysis(null);
553
+ return;
554
+ }
555
+ let cancelled = false;
556
+ const controller = new AbortController();
557
+ setIsLoading(true);
558
+ setError(null);
559
+ fetchAnalysis(apiUrl, text, "realtime", publication, effectiveSeeds, documentFields, focusPrimary, controller.signal).then((result) => {
560
+ if (cancelled) return;
561
+ const analysisResult = result;
562
+ lastAnalysisRef.current = analysisResult;
563
+ setAnalysis(analysisResult);
564
+ setIsLoading(false);
565
+ const candidateTerms = (analysisResult.primaryKeywordCandidates || []).map((c) => c.term);
566
+ const allTerms = [
567
+ .../* @__PURE__ */ new Set([
568
+ ...candidateTerms,
569
+ analysisResult.primaryKeyword.term,
570
+ ...(analysisResult.supportingKeywords || []).map((kw) => kw.term),
571
+ ...analysisResult.missingKeywords.map((kw) => kw.term)
572
+ ])
573
+ ];
574
+ const uncachedTerms = allTerms.filter((t) => !volumeMapRef.current.has(t.toLowerCase()));
575
+ if (uncachedTerms.length > 0) {
576
+ doVolumeLookupRef.current(analysisResult, uncachedTerms);
577
+ }
578
+ }).catch((err) => {
579
+ if (err instanceof Error && err.name === "AbortError") return;
580
+ if (!cancelled) {
581
+ setError(err.message);
582
+ setIsLoading(false);
583
+ }
584
+ });
585
+ return () => {
586
+ cancelled = true;
587
+ controller.abort();
588
+ };
589
+ }, [text, apiUrl, publication, effectiveSeeds?.join(","), focusPrimary, JSON.stringify(documentFields)]);
550
590
  const refreshVolumes = useCallback(() => {
551
591
  const current = lastAnalysisRef.current || analysis;
552
592
  if (!current) return;
@@ -559,16 +599,20 @@ function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFie
559
599
  setAeoContentChanged(false);
560
600
  setAeoTextSnapshot(text);
561
601
  const myVersion = docVersionRef.current;
562
- fetchAnalysis(apiUrl, text, "deep", publication, effectiveSeeds, documentFields, focusPrimary).then((result) => {
602
+ deepAbortRef.current?.abort();
603
+ const deepController = new AbortController();
604
+ deepAbortRef.current = deepController;
605
+ fetchAnalysis(apiUrl, text, "deep", publication, effectiveSeeds, documentFields, focusPrimary, deepController.signal).then((result) => {
563
606
  if (docVersionRef.current !== myVersion) return;
564
607
  setDeepAnalysis(result);
565
608
  setIsDeepLoading(false);
566
609
  }).catch((err) => {
610
+ if (deepController.signal.aborted || err?.name === "AbortError") return;
567
611
  if (docVersionRef.current !== myVersion) return;
568
612
  setError(err.message);
569
613
  setIsDeepLoading(false);
570
614
  });
571
- }, [text, apiUrl, publication, effectiveSeeds?.join(","), documentFields]);
615
+ }, [text, apiUrl, publication, effectiveSeeds?.join(","), documentFields, focusPrimary]);
572
616
  return {
573
617
  analysis,
574
618
  isLoading,
@@ -586,6 +630,7 @@ function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFie
586
630
  import { useState as useState3, useCallback as useCallback2, useEffect as useEffect3, useRef as useRef3 } from "react";
587
631
  import { useCurrentUser } from "sanity";
588
632
  function getLocalUserId() {
633
+ if (typeof window === "undefined") return "anonymous";
589
634
  const key = "seo-copilot-user-id";
590
635
  try {
591
636
  let id = localStorage.getItem(key);
@@ -609,16 +654,10 @@ function useSEOChat(apiUrl, documentText, publication, keywordPanelData, documen
609
654
  }
610
655
  }, [chatCacheKey]);
611
656
  const [messages, setMessagesRaw] = useState3(loadCachedMessages);
657
+ const messagesRef = useRef3([]);
612
658
  const setMessages = useCallback2((msgs) => {
613
- setMessagesRaw((prev) => {
614
- const next = typeof msgs === "function" ? msgs(prev) : msgs;
615
- try {
616
- localStorage.setItem(chatCacheKey, JSON.stringify(next));
617
- } catch {
618
- }
619
- return next;
620
- });
621
- }, [chatCacheKey]);
659
+ setMessagesRaw(msgs);
660
+ }, []);
622
661
  const [isStreaming, setIsStreaming] = useState3(false);
623
662
  const [historyLoaded, setHistoryLoaded] = useState3(false);
624
663
  const sanityUser = useCurrentUser();
@@ -628,6 +667,25 @@ function useSEOChat(apiUrl, documentText, publication, keywordPanelData, documen
628
667
  userId.current = sanityUser.id;
629
668
  }
630
669
  }, [sanityUser?.id]);
670
+ useEffect3(() => {
671
+ messagesRef.current = messages;
672
+ }, [messages]);
673
+ useEffect3(() => {
674
+ const timer = setTimeout(() => {
675
+ try {
676
+ localStorage.setItem(chatCacheKey, JSON.stringify(messages));
677
+ } catch {
678
+ }
679
+ }, 500);
680
+ return () => clearTimeout(timer);
681
+ }, [messages, chatCacheKey]);
682
+ const streamAbortRef = useRef3(null);
683
+ useEffect3(() => {
684
+ return () => {
685
+ streamAbortRef.current?.abort();
686
+ if (saveTimerRef.current) clearTimeout(saveTimerRef.current);
687
+ };
688
+ }, []);
631
689
  const saveTimerRef = useRef3(null);
632
690
  const opVersionRef = useRef3(0);
633
691
  const didInitRef = useRef3(false);
@@ -637,6 +695,8 @@ function useSEOChat(apiUrl, documentText, publication, keywordPanelData, documen
637
695
  return;
638
696
  }
639
697
  opVersionRef.current += 1;
698
+ streamAbortRef.current?.abort();
699
+ streamAbortRef.current = null;
640
700
  setMessagesRaw(loadCachedMessages());
641
701
  setIsStreaming(false);
642
702
  setHistoryLoaded(false);
@@ -671,16 +731,19 @@ function useSEOChat(apiUrl, documentText, publication, keywordPanelData, documen
671
731
  async (text) => {
672
732
  const myVersion = opVersionRef.current;
673
733
  const userMessage = { role: "user", content: text };
674
- const updatedMessages = [...messages, userMessage];
734
+ const updatedMessages = [...messagesRef.current, userMessage];
675
735
  setMessages(updatedMessages);
676
736
  setIsStreaming(true);
737
+ const controller = new AbortController();
738
+ streamAbortRef.current = controller;
677
739
  try {
678
740
  const stream = await fetchChatStream(
679
741
  apiUrl,
680
742
  updatedMessages,
681
743
  documentText,
682
744
  publication,
683
- keywordPanelData
745
+ keywordPanelData,
746
+ controller.signal
684
747
  );
685
748
  if (!stream) {
686
749
  setIsStreaming(false);
@@ -740,6 +803,10 @@ function useSEOChat(apiUrl, documentText, publication, keywordPanelData, documen
740
803
  scheduleSave(finalMessages);
741
804
  }
742
805
  } catch (err) {
806
+ if (err instanceof Error && err.name === "AbortError") {
807
+ setIsStreaming(false);
808
+ return;
809
+ }
743
810
  if (opVersionRef.current !== myVersion) {
744
811
  setIsStreaming(false);
745
812
  return;
@@ -752,7 +819,7 @@ function useSEOChat(apiUrl, documentText, publication, keywordPanelData, documen
752
819
  }
753
820
  if (opVersionRef.current === myVersion) setIsStreaming(false);
754
821
  },
755
- [messages, apiUrl, documentText, publication, keywordPanelData, scheduleSave]
822
+ [apiUrl, documentText, publication, keywordPanelData, scheduleSave]
756
823
  );
757
824
  const clearChat = useCallback2(() => {
758
825
  setMessages([]);
@@ -882,6 +949,14 @@ var INJECTED_CSS = `
882
949
  0%, 100% { opacity: 0.5; }
883
950
  50% { opacity: 1; }
884
951
  }
952
+ @keyframes onboard-in {
953
+ from { opacity: 0; transform: translateY(-6px) scale(0.97); }
954
+ to { opacity: 1; transform: translateY(0) scale(1); }
955
+ }
956
+ @keyframes onboard-out {
957
+ from { opacity: 1; transform: translateY(0) scale(1); }
958
+ to { opacity: 0; transform: translateY(-6px) scale(0.97); }
959
+ }
885
960
  .prose-chat { font-size: 12.5px; line-height: 1.65; color: #475569; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; }
886
961
  .prose-chat h1 { font-size: 14px; font-weight: 700; color: #1e293b; margin: 10px 0 5px 0; line-height: 1.35; }
887
962
  .prose-chat h2, .prose-chat h3 { font-size: 13px; font-weight: 700; color: #1e293b; margin: 10px 0 5px 0; line-height: 1.35; }
@@ -1093,6 +1168,12 @@ function FeedbackButton({ suggestionType, suggestionText, documentId, publicatio
1093
1168
  const [submitted, setSubmitted] = useState6(false);
1094
1169
  const popupRef = useRef5(null);
1095
1170
  const inputRef = useRef5(null);
1171
+ const submitTimerRef = useRef5(null);
1172
+ useEffect4(() => {
1173
+ return () => {
1174
+ if (submitTimerRef.current) clearTimeout(submitTimerRef.current);
1175
+ };
1176
+ }, []);
1096
1177
  useEffect4(() => {
1097
1178
  if (!showReasonPopup) return;
1098
1179
  const handler = (e) => {
@@ -1159,7 +1240,7 @@ function FeedbackButton({ suggestionType, suggestionText, documentId, publicatio
1159
1240
  }
1160
1241
  }
1161
1242
  setSubmitted(true);
1162
- setTimeout(() => {
1243
+ submitTimerRef.current = setTimeout(() => {
1163
1244
  setShowReasonPopup(false);
1164
1245
  setReason("");
1165
1246
  }, 1e3);
@@ -1365,11 +1446,13 @@ function buildSuggestedKeywords(supporting, missing, documentText, documentField
1365
1446
  const merged = [];
1366
1447
  const lowerText = documentText.toLowerCase();
1367
1448
  for (const kw of supporting) {
1449
+ if (kw == null || typeof kw.term !== "string") continue;
1368
1450
  const actuallyInContent = lowerText.includes(kw.term.toLowerCase());
1369
1451
  const livePlacement = computePlacementClient(kw.term, documentText, documentFields);
1370
1452
  merged.push({ term: kw.term, volume: kw.volume ?? 0, inContent: actuallyInContent, placement: livePlacement });
1371
1453
  }
1372
1454
  for (const kw of missing) {
1455
+ if (kw == null || typeof kw.term !== "string") continue;
1373
1456
  const actuallyInContent = lowerText.includes(kw.term.toLowerCase());
1374
1457
  const livePlacement = computePlacementClient(kw.term, documentText, documentFields);
1375
1458
  merged.push({ term: kw.term, volume: kw.volume ?? 0, inContent: actuallyInContent, reason: kw.reason, placement: livePlacement });
@@ -1420,7 +1503,7 @@ function LightbulbButton({ onClick, isLoading }) {
1420
1503
  whiteSpace: "nowrap",
1421
1504
  pointerEvents: "none",
1422
1505
  zIndex: 10
1423
- }, children: "Suggest a fix" })
1506
+ }, children: "See suggestion" })
1424
1507
  ]
1425
1508
  }
1426
1509
  );
@@ -1623,6 +1706,119 @@ function PrimaryKeywordSelector({
1623
1706
  }) })
1624
1707
  ] });
1625
1708
  }
1709
+ function SecondaryKeywordSelector({
1710
+ options,
1711
+ selectedTerm,
1712
+ onSelect
1713
+ }) {
1714
+ const [customInputOpen, setCustomInputOpen] = useState8(false);
1715
+ const [customValue, setCustomValue] = useState8("");
1716
+ const handleCustomSubmit = () => {
1717
+ const trimmed = customValue.trim();
1718
+ if (trimmed) {
1719
+ onSelect(trimmed);
1720
+ setCustomValue("");
1721
+ setCustomInputOpen(false);
1722
+ }
1723
+ };
1724
+ const opts = selectedTerm && !options.some((o) => o.term.toLowerCase() === selectedTerm.toLowerCase()) ? [...options, { term: selectedTerm, volume: null }] : options;
1725
+ return /* @__PURE__ */ jsxs4("div", { style: cardStyle, children: [
1726
+ /* @__PURE__ */ jsx5(
1727
+ SectionHeader,
1728
+ {
1729
+ label: "Secondary Keyword",
1730
+ iconColor: MJH_BLUE,
1731
+ actionButton: /* @__PURE__ */ jsxs4("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
1732
+ /* @__PURE__ */ jsx5("span", { style: { fontSize: 9, fontWeight: 700, letterSpacing: "0.05em", textTransform: "uppercase", color: "#9ca3af" }, children: "Optional" }),
1733
+ /* @__PURE__ */ jsx5(PencilButton, { onClick: () => setCustomInputOpen(!customInputOpen), active: customInputOpen })
1734
+ ] })
1735
+ }
1736
+ ),
1737
+ /* @__PURE__ */ jsx5("div", { style: { fontSize: 11, color: "#4b5563", lineHeight: 1.5, marginBottom: 8 }, children: "Pick one more keyword to optimize for. Copilot then checks your title, meta, URL, headings, and images against both keywords." }),
1738
+ customInputOpen && /* @__PURE__ */ jsxs4("div", { style: { marginBottom: 8, display: "flex", gap: 6 }, children: [
1739
+ /* @__PURE__ */ jsx5(
1740
+ "input",
1741
+ {
1742
+ type: "text",
1743
+ value: customValue,
1744
+ onChange: (e) => setCustomValue(e.target.value),
1745
+ onKeyDown: (e) => {
1746
+ if (e.key === "Enter") handleCustomSubmit();
1747
+ },
1748
+ placeholder: "Type a custom secondary keyword",
1749
+ autoFocus: true,
1750
+ style: { flex: 1, padding: "5px 8px", fontSize: 12, borderRadius: 8, border: "1px solid #e5e7eb", outline: "none", fontFamily: "inherit" }
1751
+ }
1752
+ ),
1753
+ /* @__PURE__ */ jsx5(
1754
+ "button",
1755
+ {
1756
+ onClick: handleCustomSubmit,
1757
+ disabled: !customValue.trim(),
1758
+ style: {
1759
+ padding: "5px 10px",
1760
+ fontSize: 11,
1761
+ fontWeight: 600,
1762
+ borderRadius: 6,
1763
+ border: "none",
1764
+ background: customValue.trim() ? MJH_BLUE : "#e5e7eb",
1765
+ color: customValue.trim() ? "#ffffff" : "#9ca3af",
1766
+ cursor: customValue.trim() ? "pointer" : "not-allowed"
1767
+ },
1768
+ children: "Set"
1769
+ }
1770
+ )
1771
+ ] }),
1772
+ /* @__PURE__ */ jsxs4("div", { style: { display: "flex", flexDirection: "column", gap: 6 }, children: [
1773
+ /* @__PURE__ */ jsx5(SecondaryOptionRow, { term: "", label: "None", selected: !selectedTerm, onSelect: () => onSelect("") }),
1774
+ opts.map((o) => /* @__PURE__ */ jsx5(
1775
+ SecondaryOptionRow,
1776
+ {
1777
+ term: o.term,
1778
+ label: o.term,
1779
+ volume: o.volume,
1780
+ selected: o.term === selectedTerm,
1781
+ onSelect: () => onSelect(o.term)
1782
+ },
1783
+ o.term
1784
+ ))
1785
+ ] })
1786
+ ] });
1787
+ }
1788
+ function SecondaryOptionRow({ term, label, volume, selected, onSelect }) {
1789
+ return /* @__PURE__ */ jsxs4(
1790
+ "div",
1791
+ {
1792
+ onClick: onSelect,
1793
+ style: {
1794
+ display: "flex",
1795
+ alignItems: "center",
1796
+ gap: 8,
1797
+ padding: "6px 8px",
1798
+ borderRadius: 8,
1799
+ cursor: "pointer",
1800
+ background: selected ? "rgba(0,93,172,0.06)" : "transparent",
1801
+ border: selected ? "1px solid rgba(0,93,172,0.2)" : "1px solid transparent",
1802
+ transition: "all 150ms"
1803
+ },
1804
+ children: [
1805
+ /* @__PURE__ */ jsx5("div", { style: {
1806
+ width: 14,
1807
+ height: 14,
1808
+ borderRadius: "50%",
1809
+ border: selected ? "none" : "2px solid #d1d5db",
1810
+ background: selected ? MJH_BLUE : "transparent",
1811
+ flexShrink: 0,
1812
+ display: "flex",
1813
+ alignItems: "center",
1814
+ justifyContent: "center"
1815
+ }, children: selected && /* @__PURE__ */ jsx5("div", { style: { width: 6, height: 6, borderRadius: "50%", background: "#ffffff" } }) }),
1816
+ /* @__PURE__ */ jsx5("span", { style: { fontSize: 12, fontWeight: selected ? 600 : 400, color: term ? selected ? "#00468a" : "#374151" : "#6b7280", flex: 1, minWidth: 0 }, children: label }),
1817
+ volume != null && /* @__PURE__ */ jsx5("span", { style: { fontSize: 11, fontWeight: 600, color: "#1f2937" }, children: volume === 0 ? "N/A" : `${abbrevVol(volume)}/mo` })
1818
+ ]
1819
+ }
1820
+ );
1821
+ }
1626
1822
  var PLACEMENT_FILTERS = [
1627
1823
  { key: "inBody", label: "Body", letter: "B" },
1628
1824
  { key: "inTitle", label: "Title", letter: "T" },
@@ -1635,8 +1831,8 @@ function computePlacementClient(term, content, fields) {
1635
1831
  const lower = term.toLowerCase();
1636
1832
  return {
1637
1833
  inBody: content.toLowerCase().includes(lower),
1638
- inTitle: fields?.title?.toLowerCase().includes(lower) ?? false,
1639
- inMetaDescription: fields?.metaDescription?.toLowerCase().includes(lower) ?? false,
1834
+ inTitle: typeof fields?.title === "string" ? fields.title.toLowerCase().includes(lower) : false,
1835
+ inMetaDescription: typeof fields?.metaDescription === "string" ? fields.metaDescription.toLowerCase().includes(lower) : false,
1640
1836
  inImages: fields?.imageNames?.some((name) => name.toLowerCase().includes(lower)) ?? false,
1641
1837
  inUrl: fields?.slug?.toLowerCase().includes(lower) ?? false
1642
1838
  };
@@ -1706,7 +1902,9 @@ function SuggestedKeywordsCard({
1706
1902
  const res = await fetch(`${apiUrl}/api/seo-copilot/keyword-help`, {
1707
1903
  method: "POST",
1708
1904
  headers: { "Content-Type": "application/json" },
1709
- body: JSON.stringify({ keyword: term, content: text, publication, previousSuggestions })
1905
+ // Clip to 5,000 chars: the backend only reads the first 4,000 anyway, so sending
1906
+ // the full article needlessly bloats the request on long pieces.
1907
+ body: JSON.stringify({ keyword: term, content: text.slice(0, 5e3), publication, previousSuggestions })
1710
1908
  });
1711
1909
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
1712
1910
  const data = await res.json();
@@ -2103,6 +2301,8 @@ function KeywordPanel({
2103
2301
  seedKeywords = [],
2104
2302
  onSeedsChange,
2105
2303
  onSelectPrimary,
2304
+ secondaryKeyword = "",
2305
+ onSelectSecondary,
2106
2306
  documentFields,
2107
2307
  documentId,
2108
2308
  externalAnalysis
@@ -2127,8 +2327,9 @@ function KeywordPanel({
2127
2327
  const prevDefaultRef = useRef7(defaultSelectedTerm);
2128
2328
  useEffect6(() => {
2129
2329
  if (defaultSelectedTerm && defaultSelectedTerm !== prevDefaultRef.current) {
2130
- setSelectedPrimaryTerm((prev) => prev === prevDefaultRef.current ? defaultSelectedTerm : prev);
2330
+ const oldDefault = prevDefaultRef.current;
2131
2331
  prevDefaultRef.current = defaultSelectedTerm;
2332
+ setSelectedPrimaryTerm((prev) => prev === oldDefault ? defaultSelectedTerm : prev);
2132
2333
  }
2133
2334
  }, [defaultSelectedTerm]);
2134
2335
  if ((!text || text.trim().length < 20) && (!seedKeywords || seedKeywords.length === 0)) {
@@ -2162,7 +2363,39 @@ function KeywordPanel({
2162
2363
  placement: computePlacementClient(c.term, text, documentFields)
2163
2364
  }));
2164
2365
  const activeTerm = candidates.find((c) => c.term === selectedPrimaryTerm) ? selectedPrimaryTerm : candidates[0]?.term ?? "";
2366
+ const activeTermLower = activeTerm.toLowerCase();
2367
+ const secondaryOptions = [];
2368
+ const seenSecondary = /* @__PURE__ */ new Set();
2369
+ for (const c of candidates) {
2370
+ const key = c.term.toLowerCase();
2371
+ if (key === activeTermLower) continue;
2372
+ if (!seenSecondary.has(key)) {
2373
+ seenSecondary.add(key);
2374
+ secondaryOptions.push({ term: c.term, volume: c.volume });
2375
+ }
2376
+ }
2377
+ for (const kw of suggestedKeywords) {
2378
+ const key = kw.term.toLowerCase();
2379
+ if (key === activeTermLower) continue;
2380
+ if (!seenSecondary.has(key)) {
2381
+ seenSecondary.add(key);
2382
+ secondaryOptions.push({ term: kw.term, volume: kw.volume });
2383
+ }
2384
+ }
2165
2385
  return /* @__PURE__ */ jsxs4("div", { style: { padding: 12, display: "flex", flexDirection: "column", gap: 12 }, children: [
2386
+ /* @__PURE__ */ jsx5("div", { style: {
2387
+ ...cardStyle,
2388
+ padding: "11px 13px",
2389
+ background: "rgba(0,93,172,0.05)",
2390
+ boxShadow: "inset 0 0 0 1px rgba(0,93,172,0.12)"
2391
+ }, children: /* @__PURE__ */ jsxs4("div", { style: { fontSize: 11.5, color: "#1f2937", lineHeight: 1.55 }, children: [
2392
+ /* @__PURE__ */ jsx5("strong", { style: { color: "#00468a" }, children: "Choose your target keywords." }),
2393
+ " Pick one ",
2394
+ /* @__PURE__ */ jsx5("strong", { children: "Primary" }),
2395
+ " keyword (required) and, optionally, one ",
2396
+ /* @__PURE__ */ jsx5("strong", { children: "Secondary" }),
2397
+ " keyword. Copilot optimizes the whole article - title, meta, URL, headings, and images - toward both."
2398
+ ] }) }),
2166
2399
  onSeedsChange && /* @__PURE__ */ jsx5(SeedKeywordInput, { seeds: seedKeywords, onSeedsChange }),
2167
2400
  /* @__PURE__ */ jsx5(
2168
2401
  PrimaryKeywordSelector,
@@ -2176,6 +2409,14 @@ function KeywordPanel({
2176
2409
  publication
2177
2410
  }
2178
2411
  ),
2412
+ onSelectSecondary && secondaryOptions.length > 0 && /* @__PURE__ */ jsx5(
2413
+ SecondaryKeywordSelector,
2414
+ {
2415
+ options: secondaryOptions,
2416
+ selectedTerm: secondaryKeyword,
2417
+ onSelect: (term) => onSelectSecondary(term)
2418
+ }
2419
+ ),
2179
2420
  suggestedKeywords.length > 0 && /* @__PURE__ */ jsx5(
2180
2421
  SuggestedKeywordsCard,
2181
2422
  {
@@ -2380,20 +2621,22 @@ function ChatPanel({ messages, isStreaming, sendMessage, clearChat, documentId }
2380
2621
  "button",
2381
2622
  {
2382
2623
  onClick: clearChat,
2383
- onMouseEnter: () => setClearHovered(true),
2624
+ onMouseEnter: () => !isStreaming && setClearHovered(true),
2384
2625
  onMouseLeave: () => setClearHovered(false),
2385
2626
  title: "Clear conversation",
2386
2627
  "aria-label": "Clear conversation",
2628
+ disabled: isStreaming,
2387
2629
  style: {
2388
2630
  background: "none",
2389
2631
  border: "none",
2390
- cursor: "pointer",
2632
+ cursor: isStreaming ? "not-allowed" : "pointer",
2391
2633
  padding: 4,
2392
2634
  display: "flex",
2393
2635
  alignItems: "center",
2394
- color: clearHovered ? "#ef4444" : "#9ca3af",
2636
+ color: isStreaming ? "#d1d5db" : clearHovered ? "#ef4444" : "#9ca3af",
2395
2637
  transition: "color 150ms",
2396
- flexShrink: 0
2638
+ flexShrink: 0,
2639
+ opacity: isStreaming ? 0.4 : 1
2397
2640
  },
2398
2641
  children: /* @__PURE__ */ jsx6("svg", { width: "14", height: "14", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx6("path", { fillRule: "evenodd", d: "M8.75 1A2.75 2.75 0 006 3.75v.443c-.795.077-1.584.176-2.365.298a.75.75 0 10.23 1.482l.149-.022.841 10.518A2.75 2.75 0 007.596 19h4.807a2.75 2.75 0 002.742-2.53l.841-10.519.149.023a.75.75 0 00.23-1.482A41.03 41.03 0 0014 4.193V3.75A2.75 2.75 0 0011.25 1h-2.5zM10 4c.84 0 1.673.025 2.5.075V3.75c0-.69-.56-1.25-1.25-1.25h-2.5c-.69 0-1.25.56-1.25 1.25v.325C8.327 4.025 9.16 4 10 4zM8.58 7.72a.75.75 0 00-1.5.06l.3 7.5a.75.75 0 101.5-.06l-.3-7.5zm4.34.06a.75.75 0 10-1.5-.06l-.3 7.5a.75.75 0 101.5.06l.3-7.5z", clipRule: "evenodd" }) })
2399
2642
  }
@@ -2572,6 +2815,9 @@ function TabBar({ tabs, activeTab, onTabChange }) {
2572
2815
  const duration = Math.min(560, Math.max(280, Math.round(250 + dist * 0.6)));
2573
2816
  return { ...next, ready: true, duration };
2574
2817
  });
2818
+ return () => {
2819
+ if (clickTimerRef.current) clearTimeout(clickTimerRef.current);
2820
+ };
2575
2821
  }, [activeTab, signature]);
2576
2822
  useEffect8(() => {
2577
2823
  const bar = barRef.current;
@@ -2746,12 +2992,127 @@ function TabBar({ tabs, activeTab, onTabChange }) {
2746
2992
  );
2747
2993
  }
2748
2994
 
2995
+ // src/components/OnboardingPopup.tsx
2996
+ import { Fragment as Fragment4, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
2997
+ function OnboardingInfoButton({ onClick }) {
2998
+ return /* @__PURE__ */ jsx8(
2999
+ "button",
3000
+ {
3001
+ onClick: (e) => {
3002
+ e.stopPropagation();
3003
+ onClick();
3004
+ },
3005
+ onMouseDown: (e) => e.stopPropagation(),
3006
+ style: {
3007
+ background: "rgba(0,93,172,0.08)",
3008
+ border: "none",
3009
+ borderRadius: "50%",
3010
+ width: 20,
3011
+ height: 20,
3012
+ cursor: "pointer",
3013
+ padding: 0,
3014
+ display: "flex",
3015
+ alignItems: "center",
3016
+ justifyContent: "center",
3017
+ color: MJH_BLUE,
3018
+ flexShrink: 0
3019
+ },
3020
+ title: "How SEO Copilot works",
3021
+ "aria-label": "How SEO Copilot works",
3022
+ children: /* @__PURE__ */ jsx8("svg", { width: "13", height: "13", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsx8("path", { fillRule: "evenodd", d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z", clipRule: "evenodd" }) })
3023
+ }
3024
+ );
3025
+ }
3026
+ function OnboardingCard({ onDismiss, closing }) {
3027
+ return /* @__PURE__ */ jsxs7(Fragment4, { children: [
3028
+ /* @__PURE__ */ jsx8(
3029
+ "div",
3030
+ {
3031
+ onClick: onDismiss,
3032
+ style: {
3033
+ position: "absolute",
3034
+ inset: 0,
3035
+ zIndex: 60,
3036
+ background: "transparent",
3037
+ cursor: "pointer"
3038
+ }
3039
+ }
3040
+ ),
3041
+ /* @__PURE__ */ jsxs7(
3042
+ "div",
3043
+ {
3044
+ onClick: (e) => e.stopPropagation(),
3045
+ style: {
3046
+ position: "absolute",
3047
+ top: 50,
3048
+ right: 10,
3049
+ left: 10,
3050
+ maxWidth: 320,
3051
+ marginLeft: "auto",
3052
+ zIndex: 61,
3053
+ borderRadius: 18,
3054
+ padding: "14px 16px 16px",
3055
+ // Amorphous blue glass
3056
+ background: "linear-gradient(155deg, rgba(0,93,172,0.16), rgba(0,93,172,0.08))",
3057
+ backdropFilter: "blur(20px) saturate(170%)",
3058
+ WebkitBackdropFilter: "blur(20px) saturate(170%)",
3059
+ boxShadow: "inset 0 0 0 1px rgba(255,255,255,0.55), inset 1.5px 2px 1px -1px rgba(255,255,255,0.9), 0 10px 30px rgba(0,93,172,0.22), 0 2px 8px rgba(0,0,0,0.12)",
3060
+ animation: `${closing ? "onboard-out" : "onboard-in"} ${closing ? 200 : 240}ms ease-out forwards`
3061
+ },
3062
+ children: [
3063
+ /* @__PURE__ */ jsxs7("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, marginBottom: 6 }, children: [
3064
+ /* @__PURE__ */ jsx8("span", { style: { fontSize: 13, fontWeight: 800, color: "#00468a", letterSpacing: "-0.01em" }, children: "Welcome to SEO Copilot" }),
3065
+ /* @__PURE__ */ jsx8(
3066
+ "button",
3067
+ {
3068
+ onClick: onDismiss,
3069
+ style: { background: "none", border: "none", cursor: "pointer", padding: 2, display: "flex", color: "#00468a", opacity: 1 },
3070
+ title: "Dismiss",
3071
+ "aria-label": "Dismiss",
3072
+ children: /* @__PURE__ */ jsx8("svg", { width: "14", height: "14", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx8("path", { d: "M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z" }) })
3073
+ }
3074
+ )
3075
+ ] }),
3076
+ /* @__PURE__ */ jsxs7("div", { style: { fontSize: 11.5, color: "#13335a", lineHeight: 1.6 }, children: [
3077
+ "Start on the ",
3078
+ /* @__PURE__ */ jsx8("strong", { children: "Keywords" }),
3079
+ " tab. Choose one ",
3080
+ /* @__PURE__ */ jsx8("strong", { children: "Primary" }),
3081
+ " keyword (required) and, optionally, one ",
3082
+ /* @__PURE__ */ jsx8("strong", { children: "Secondary" }),
3083
+ " keyword. Copilot then optimizes its recommendations toward both."
3084
+ ] }),
3085
+ /* @__PURE__ */ jsx8(
3086
+ "button",
3087
+ {
3088
+ onClick: onDismiss,
3089
+ style: {
3090
+ marginTop: 12,
3091
+ width: "100%",
3092
+ padding: "7px 12px",
3093
+ fontSize: 11.5,
3094
+ fontWeight: 700,
3095
+ color: "#ffffff",
3096
+ background: MJH_BLUE,
3097
+ border: "none",
3098
+ borderRadius: 8,
3099
+ cursor: "pointer"
3100
+ },
3101
+ children: "Got it"
3102
+ }
3103
+ )
3104
+ ]
3105
+ }
3106
+ )
3107
+ ] });
3108
+ }
3109
+
2749
3110
  // src/components/tabs/SummaryTab.tsx
2750
3111
  import { useMemo, useState as useState12 } from "react";
2751
3112
 
2752
3113
  // src/components/ShimmerLoader.tsx
2753
3114
  import { useEffect as useEffect9, useState as useState11 } from "react";
2754
- import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
3115
+ import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
2755
3116
  var keyframesInjected = false;
2756
3117
  var KEYFRAMES = `
2757
3118
  @keyframes seo-copilot-text-shimmer {
@@ -2760,13 +3121,13 @@ var KEYFRAMES = `
2760
3121
  }
2761
3122
  `;
2762
3123
  function LoaderBars({ color = MJH_GOLD }) {
2763
- return /* @__PURE__ */ jsx8(
3124
+ return /* @__PURE__ */ jsx9(
2764
3125
  "div",
2765
3126
  {
2766
3127
  role: "status",
2767
3128
  "aria-label": "Loading",
2768
3129
  style: { display: "inline-flex", alignItems: "flex-end", gap: 2, height: 14, flexShrink: 0 },
2769
- children: [1, 2, 3].map((i) => /* @__PURE__ */ jsx8(
3130
+ children: [1, 2, 3].map((i) => /* @__PURE__ */ jsx9(
2770
3131
  "div",
2771
3132
  {
2772
3133
  style: {
@@ -2796,6 +3157,13 @@ function ShimmerLoader({
2796
3157
  style.dataset.seoCopilotKeyframes = "1";
2797
3158
  style.innerHTML = KEYFRAMES;
2798
3159
  document.head.appendChild(style);
3160
+ return () => {
3161
+ try {
3162
+ document.head.removeChild(style);
3163
+ } catch {
3164
+ }
3165
+ keyframesInjected = false;
3166
+ };
2799
3167
  }
2800
3168
  }, []);
2801
3169
  useEffect9(() => {
@@ -2806,7 +3174,7 @@ function ShimmerLoader({
2806
3174
  return () => clearInterval(id);
2807
3175
  }, [messages.length, intervalMs]);
2808
3176
  const text = messages[idx] || messages[0] || "";
2809
- return /* @__PURE__ */ jsxs7(
3177
+ return /* @__PURE__ */ jsxs8(
2810
3178
  "div",
2811
3179
  {
2812
3180
  style: {
@@ -2818,8 +3186,8 @@ function ShimmerLoader({
2818
3186
  letterSpacing: "0.01em"
2819
3187
  },
2820
3188
  children: [
2821
- /* @__PURE__ */ jsx8(LoaderBars, { color: iconColor }),
2822
- /* @__PURE__ */ jsx8(
3189
+ /* @__PURE__ */ jsx9(LoaderBars, { color: iconColor }),
3190
+ /* @__PURE__ */ jsx9(
2823
3191
  "span",
2824
3192
  {
2825
3193
  style: {
@@ -2849,6 +3217,12 @@ var DEFAULT_GENERATE_ALL_MESSAGES = [
2849
3217
  ];
2850
3218
 
2851
3219
  // src/lib/scoring.ts
3220
+ function countWholeMatches(haystack, needle) {
3221
+ if (!needle) return 0;
3222
+ const esc = needle.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3223
+ const m = haystack.match(new RegExp(`\\b${esc}\\b`, "g"));
3224
+ return m ? m.length : 0;
3225
+ }
2852
3226
  function calculateContentScoreDetailed(content, analysis, documentFields) {
2853
3227
  if (!content || !analysis) {
2854
3228
  return { total: 0, components: [] };
@@ -2858,24 +3232,34 @@ function calculateContentScoreDetailed(content, analysis, documentFields) {
2858
3232
  const components = [];
2859
3233
  const primaryTerm = (analysis.primaryKeyword?.term || "").toLowerCase();
2860
3234
  if (primaryTerm) {
2861
- const escaped = primaryTerm.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2862
- const primaryRegex = new RegExp(escaped, "gi");
2863
- const primaryMatches = content.match(primaryRegex);
2864
- const primaryCount = primaryMatches?.length || 0;
3235
+ const tokens = primaryTerm.split(/\s+/).filter((t) => t.length > 1);
3236
+ const phraseCount = countWholeMatches(lowerContent, primaryTerm);
3237
+ let occurrences = phraseCount;
3238
+ let viaTokens = false;
3239
+ if (phraseCount === 0 && tokens.length > 0) {
3240
+ const counts = tokens.map((t) => countWholeMatches(lowerContent, t));
3241
+ if (counts.every((c) => c > 0)) {
3242
+ occurrences = Math.min(...counts);
3243
+ viaTokens = true;
3244
+ }
3245
+ }
2865
3246
  const primaryWordCount = Math.max(1, primaryTerm.split(/\s+/).filter(Boolean).length);
2866
3247
  let pts = 0;
2867
3248
  let detail;
2868
- if (primaryCount === 0) {
3249
+ if (occurrences === 0) {
2869
3250
  detail = `Primary keyword "${primaryTerm}" not found in content`;
2870
3251
  } else {
2871
3252
  pts += 12;
2872
- const density = words > 0 ? primaryCount * primaryWordCount / words * 100 : 0;
3253
+ const density = words > 0 ? (viaTokens ? occurrences : occurrences * primaryWordCount) / words * 100 : 0;
2873
3254
  if (density >= 0.5 && density <= 2.5) {
2874
3255
  pts += 13;
2875
3256
  detail = `Primary keyword present, density ${density.toFixed(2)}% (ideal range)`;
2876
3257
  } else if (density < 0.5) {
2877
3258
  pts += 7;
2878
3259
  detail = `Primary keyword present but density only ${density.toFixed(2)}% - aim for 0.5-2.5%`;
3260
+ } else if (viaTokens && density <= 6) {
3261
+ pts += 11;
3262
+ detail = `Primary keyword strongly represented (${density.toFixed(2)}%)`;
2879
3263
  } else {
2880
3264
  pts += 4;
2881
3265
  detail = `Primary keyword over-used at ${density.toFixed(2)}% density - reduce to 0.5-2.5%`;
@@ -2887,7 +3271,7 @@ function calculateContentScoreDetailed(content, analysis, documentFields) {
2887
3271
  }
2888
3272
  const supportingKws = analysis.supportingKeywords || [];
2889
3273
  if (supportingKws.length > 0) {
2890
- const inContentCount = supportingKws.filter((kw) => lowerContent.includes(kw.term.toLowerCase())).length;
3274
+ const inContentCount = supportingKws.filter((kw) => kw != null && typeof kw.term === "string" && lowerContent.includes(kw.term.toLowerCase())).length;
2891
3275
  const coverageRatio = inContentCount / supportingKws.length;
2892
3276
  const pts = Math.round(coverageRatio * 25);
2893
3277
  components.push({
@@ -2919,7 +3303,8 @@ function calculateContentScoreDetailed(content, analysis, documentFields) {
2919
3303
  if (documentFields) {
2920
3304
  hasH1orTitle = !!(documentFields.title && documentFields.title.trim());
2921
3305
  const det = documentFields.headingsDetailed;
2922
- hasSubheadings = det ? det.some((h) => h.level >= 2 && h.level <= 4) : (documentFields.headings?.length || 0) > 0;
3306
+ const detHasSub = Array.isArray(det) && det.some((h) => h.level >= 2);
3307
+ hasSubheadings = detHasSub || (documentFields.headings?.length || 0) > 0;
2923
3308
  } else {
2924
3309
  hasH1orTitle = /^#\s|<h1/im.test(content);
2925
3310
  hasSubheadings = /^##\s|^###\s|<h2|<h3/im.test(content);
@@ -2947,8 +3332,7 @@ function calculateContentScoreDetailed(content, analysis, documentFields) {
2947
3332
  if (documentFields) {
2948
3333
  qCount = (documentFields.headings || []).filter((h) => h.trim().endsWith("?")).length;
2949
3334
  } else {
2950
- const questionHeadings = content.match(/^#{1,6}\s+.*\?$/gm) || content.match(/<h[1-6][^>]*>.*\?<\/h[1-6]>/gi);
2951
- qCount = questionHeadings?.length || 0;
3335
+ qCount = (content.match(/^#{1,6}\s+.*\?$/gm) || []).length + (content.match(/<h[1-6][^>]*>.*\?<\/h[1-6]>/gi) || []).length;
2952
3336
  }
2953
3337
  let aeoPts = 0;
2954
3338
  if (qCount >= 3) aeoPts = 10;
@@ -2960,17 +3344,40 @@ function calculateContentScoreDetailed(content, analysis, documentFields) {
2960
3344
  return { total: Math.min(100, Math.max(0, total)), components };
2961
3345
  }
2962
3346
 
2963
- // src/lib/summary.ts
2964
- function tokensContain(haystack, needle) {
3347
+ // src/lib/utils.ts
3348
+ function containsKeywordTokens(haystack, needle) {
2965
3349
  if (!needle) return true;
2966
3350
  const tokens = needle.toLowerCase().split(/\s+/).filter((t) => t.length > 1);
2967
3351
  if (tokens.length === 0) return true;
2968
3352
  const lower = haystack.toLowerCase();
2969
3353
  return tokens.every((t) => lower.includes(t));
2970
3354
  }
3355
+ function keywordLeadsSlug(slug, primaryKeyword) {
3356
+ if (!primaryKeyword) return true;
3357
+ const slugWords = slug.toLowerCase().replace(/[^a-z0-9]+/g, " ").trim().split(/\s+/).filter(Boolean);
3358
+ const tokens = primaryKeyword.toLowerCase().split(/\s+/).filter((t) => t.length > 1);
3359
+ if (tokens.length === 0 || slugWords.length === 0) return true;
3360
+ let earliest = Infinity;
3361
+ for (const t of tokens) {
3362
+ const idx = slugWords.findIndex((w) => w.includes(t));
3363
+ if (idx >= 0) earliest = Math.min(earliest, idx);
3364
+ }
3365
+ return earliest <= 2;
3366
+ }
3367
+ var KNOWN_MJH_PUBLICATIONS = /* @__PURE__ */ new Set([
3368
+ "onclive",
3369
+ "hcplive",
3370
+ "ajmc",
3371
+ "pharmacytimes",
3372
+ "cancernetwork"
3373
+ ]);
3374
+
3375
+ // src/lib/summary.ts
2971
3376
  function isShortFormContent(documentFields, title) {
3377
+ const cat = (documentFields?.contentCategory || "").toLowerCase().trim();
3378
+ if (/^(videos?|podcasts?|episodes?|webinars?|video series|peer exchange)$/.test(cat)) return true;
2972
3379
  const shortFormCats = /* @__PURE__ */ new Set(["news", "brief", "preview", "recap", "update", "announcement", "roundup", "digest", "interview"]);
2973
- const catTokens = (documentFields?.contentCategory || "").toLowerCase().split(/[^a-z]+/).filter(Boolean);
3380
+ const catTokens = cat.split(/[^a-z]+/).filter(Boolean);
2974
3381
  if (catTokens.some((tok) => shortFormCats.has(tok))) return true;
2975
3382
  const t = (title || "").toLowerCase();
2976
3383
  if (/\b(preview|recap|roundup|digest)\b/.test(t)) return true;
@@ -2980,7 +3387,15 @@ function isShortFormContent(documentFields, title) {
2980
3387
  function buildSummaryItems(input) {
2981
3388
  const items = [];
2982
3389
  const { analysis, deepAnalysis, documentFields, linkingSuggestions, linkCheckResults, text } = input;
2983
- const primaryKeyword = analysis?.primaryKeyword?.term;
3390
+ const primaryKeyword = input.primaryKeyword || analysis?.primaryKeyword?.term;
3391
+ const secondaryKeyword = input.secondaryKeyword || "";
3392
+ const bodyText = (() => {
3393
+ if (!documentFields?.title) return text;
3394
+ if (!text.startsWith(documentFields.title)) return text;
3395
+ const rest = text.slice(documentFields.title.length);
3396
+ if (rest === "" || /^\s/.test(rest)) return rest.trimStart();
3397
+ return text;
3398
+ })();
2984
3399
  const title = documentFields?.title;
2985
3400
  if (!title) {
2986
3401
  items.push({
@@ -2993,7 +3408,7 @@ function buildSummaryItems(input) {
2993
3408
  jumpTo: { tab: "meta", anchorId: "anchor-meta-title" }
2994
3409
  });
2995
3410
  } else if (primaryKeyword) {
2996
- if (!tokensContain(title, primaryKeyword)) {
3411
+ if (!containsKeywordTokens(title, primaryKeyword)) {
2997
3412
  items.push({
2998
3413
  id: "meta-title-no-keyword",
2999
3414
  category: "meta",
@@ -3059,7 +3474,7 @@ function buildSummaryItems(input) {
3059
3474
  jumpTo: { tab: "meta", anchorId: "anchor-meta-description" }
3060
3475
  });
3061
3476
  }
3062
- if (primaryKeyword && !tokensContain(meta, primaryKeyword)) {
3477
+ if (primaryKeyword && !containsKeywordTokens(meta, primaryKeyword)) {
3063
3478
  items.push({
3064
3479
  id: "meta-desc-no-keyword",
3065
3480
  category: "meta",
@@ -3076,39 +3491,40 @@ function buildSummaryItems(input) {
3076
3491
  items.push({
3077
3492
  id: "meta-slug-missing",
3078
3493
  category: "meta",
3079
- severity: "error",
3494
+ severity: "warning",
3080
3495
  label: "URL slug missing",
3081
3496
  description: "No URL slug set.",
3082
- howToFix: "Add a clean, hyphenated slug 3-5 words long that contains the primary keyword.",
3083
- jumpTo: { tab: "meta", anchorId: "anchor-url-slug" }
3497
+ howToFix: "Add a short, descriptive slug that leads with your primary keyword.",
3498
+ jumpTo: { tab: "technical", anchorId: "anchor-url-slug" }
3084
3499
  });
3085
3500
  } else {
3086
- if (slug.length > 60) {
3501
+ const slugAsWords = slug.replace(/-/g, " ");
3502
+ if (primaryKeyword && !containsKeywordTokens(slugAsWords, primaryKeyword)) {
3087
3503
  items.push({
3088
- id: "meta-slug-long",
3504
+ id: "meta-slug-no-keyword",
3089
3505
  category: "meta",
3090
- severity: "warning",
3091
- label: "URL slug is long",
3092
- description: `Slug is ${slug.length} characters. 3-5 words is the 2026 sweet spot.`,
3093
- howToFix: "Shorten the slug to keep the URL clean and scannable.",
3094
- jumpTo: { tab: "meta", anchorId: "anchor-url-slug" }
3506
+ severity: "opportunity",
3507
+ label: "Primary keyword not in URL",
3508
+ description: `The URL doesn't include "${primaryKeyword}".`,
3509
+ howToFix: "Work the primary keyword into the URL, ideally at the start. Keep the URL short and descriptive.",
3510
+ jumpTo: { tab: "technical", anchorId: "anchor-url-slug" }
3095
3511
  });
3096
- }
3097
- if (primaryKeyword && !tokensContain(slug.replace(/-/g, " "), primaryKeyword)) {
3512
+ } else if (primaryKeyword && !keywordLeadsSlug(slug, primaryKeyword)) {
3098
3513
  items.push({
3099
- id: "meta-slug-no-keyword",
3514
+ id: "meta-slug-keyword-late",
3100
3515
  category: "meta",
3101
3516
  severity: "opportunity",
3102
- label: "Primary keyword not in URL",
3103
- description: `Slug doesn't contain "${primaryKeyword}".`,
3104
- howToFix: "Rework the slug to include the primary keyword (hyphenated). URLs with keywords still get a modest ranking lift.",
3105
- jumpTo: { tab: "meta", anchorId: "anchor-url-slug" }
3517
+ label: "Primary keyword late in URL",
3518
+ description: `"${primaryKeyword}" is in the URL but not near the start.`,
3519
+ howToFix: "Lead the URL with the primary keyword so it stays visible if the address gets shortened.",
3520
+ jumpTo: { tab: "technical", anchorId: "anchor-url-slug" }
3106
3521
  });
3107
3522
  }
3108
3523
  }
3109
- const wordCount2 = text ? text.trim().split(/\s+/).filter(Boolean).length : 0;
3524
+ const wordCount2 = bodyText ? bodyText.trim().split(/\s+/).filter(Boolean).length : 0;
3525
+ const isShortForm = isShortFormContent(documentFields, title);
3110
3526
  if (wordCount2 === 0) {
3111
- } else if (wordCount2 < 450) {
3527
+ } else if (wordCount2 < 450 && !isShortForm) {
3112
3528
  items.push({
3113
3529
  id: "content-too-short",
3114
3530
  category: "content",
@@ -3118,7 +3534,7 @@ function buildSummaryItems(input) {
3118
3534
  howToFix: "Add more body text. A link or image on its own doesn't count - the article needs real written substance.",
3119
3535
  jumpTo: { tab: "technical", anchorId: "anchor-word-count" }
3120
3536
  });
3121
- } else if (wordCount2 < 1500 && !isShortFormContent(documentFields, title)) {
3537
+ } else if (wordCount2 < 1500 && !isShortForm) {
3122
3538
  items.push({
3123
3539
  id: "content-short-for-clinical",
3124
3540
  category: "content",
@@ -3132,7 +3548,7 @@ function buildSummaryItems(input) {
3132
3548
  const headings = documentFields?.headings || [];
3133
3549
  const headingsDetailed = documentFields?.headingsDetailed;
3134
3550
  const h2Count = headingsDetailed ? headingsDetailed.filter((h) => h.level === 2 || h.level === 3).length : headings.length;
3135
- if (headings.length === 0 && wordCount2 > 200 && wordCount2 < 1e3) {
3551
+ if (h2Count === 0 && wordCount2 > 200 && wordCount2 < 1e3) {
3136
3552
  items.push({
3137
3553
  id: "headings-missing",
3138
3554
  category: "headings",
@@ -3238,7 +3654,7 @@ function buildSummaryItems(input) {
3238
3654
  if (GENERIC_FN_RE.test(base)) return true;
3239
3655
  if (/_/.test(base) || /\s/.test(base)) return true;
3240
3656
  const words = base.split("-").filter(Boolean);
3241
- return words.length < 2 || words.length > 7;
3657
+ return words.length < 2 || words.length > 5;
3242
3658
  });
3243
3659
  if (badFilenames.length > 0) {
3244
3660
  items.push({
@@ -3256,7 +3672,7 @@ function buildSummaryItems(input) {
3256
3672
  if (!trimmed) return false;
3257
3673
  const len = trimmed.length;
3258
3674
  const wc = trimmed.split(/\s+/).filter(Boolean).length;
3259
- return len > 125 || wc < 2;
3675
+ return len >= 125 || wc < 2;
3260
3676
  });
3261
3677
  if (badAlts.length > 0) {
3262
3678
  items.push({
@@ -3271,7 +3687,7 @@ function buildSummaryItems(input) {
3271
3687
  }
3272
3688
  const imageTitleCount = (documentFields?.imageTitles || []).length;
3273
3689
  const totalImageCount = documentFields?.imageCount ?? 0;
3274
- const missingTitles = totalImageCount > 0 ? totalImageCount - imageTitleCount : 0;
3690
+ const missingTitles = totalImageCount > 0 && imageTitleCount > 0 ? totalImageCount - imageTitleCount : 0;
3275
3691
  if (missingTitles > 0) {
3276
3692
  items.push({
3277
3693
  id: "images-titles-missing",
@@ -3285,7 +3701,7 @@ function buildSummaryItems(input) {
3285
3701
  }
3286
3702
  if (!primaryKeyword) {
3287
3703
  } else {
3288
- if (text && !tokensContain(text, primaryKeyword)) {
3704
+ if (bodyText && !containsKeywordTokens(bodyText, primaryKeyword)) {
3289
3705
  items.push({
3290
3706
  id: "keywords-primary-not-in-body",
3291
3707
  category: "keywords",
@@ -3297,7 +3713,7 @@ function buildSummaryItems(input) {
3297
3713
  });
3298
3714
  }
3299
3715
  const primaryVolume = analysis?.primaryKeyword?.volume;
3300
- if (deepAnalysis && (primaryVolume === 0 || primaryVolume === null)) {
3716
+ if (deepAnalysis && primaryVolume === 0) {
3301
3717
  items.push({
3302
3718
  id: "keywords-primary-zero-volume",
3303
3719
  category: "keywords",
@@ -3309,6 +3725,55 @@ function buildSummaryItems(input) {
3309
3725
  });
3310
3726
  }
3311
3727
  }
3728
+ if (secondaryKeyword) {
3729
+ if (bodyText && !containsKeywordTokens(bodyText, secondaryKeyword)) {
3730
+ items.push({
3731
+ id: "secondary-not-in-body",
3732
+ category: "keywords",
3733
+ severity: "opportunity",
3734
+ label: "Secondary keyword not in body",
3735
+ description: `Your secondary keyword "${secondaryKeyword}" doesn't appear in the article body.`,
3736
+ howToFix: "Work the secondary keyword into a body paragraph or two where it reads naturally.",
3737
+ jumpTo: { tab: "keywords" }
3738
+ });
3739
+ }
3740
+ const titleVal = documentFields?.title;
3741
+ if (titleVal && !containsKeywordTokens(titleVal, secondaryKeyword)) {
3742
+ items.push({
3743
+ id: "secondary-not-in-title",
3744
+ category: "meta",
3745
+ severity: "opportunity",
3746
+ label: "Secondary keyword not in title",
3747
+ description: `The title doesn't include your secondary keyword "${secondaryKeyword}".`,
3748
+ howToFix: "If it fits naturally, include the secondary keyword in the title too - but never at the cost of the primary leading.",
3749
+ jumpTo: { tab: "meta", anchorId: "anchor-meta-title" }
3750
+ });
3751
+ }
3752
+ const metaVal = documentFields?.metaDescription;
3753
+ if (metaVal && !containsKeywordTokens(metaVal, secondaryKeyword)) {
3754
+ items.push({
3755
+ id: "secondary-not-in-meta",
3756
+ category: "meta",
3757
+ severity: "opportunity",
3758
+ label: "Secondary keyword not in meta description",
3759
+ description: `The meta description doesn't include "${secondaryKeyword}".`,
3760
+ howToFix: "Add the secondary keyword to the meta description if it reads naturally.",
3761
+ jumpTo: { tab: "meta", anchorId: "anchor-meta-description" }
3762
+ });
3763
+ }
3764
+ const slugVal = documentFields?.slug;
3765
+ if (slugVal && !containsKeywordTokens(slugVal.replace(/-/g, " "), secondaryKeyword)) {
3766
+ items.push({
3767
+ id: "secondary-not-in-url",
3768
+ category: "meta",
3769
+ severity: "opportunity",
3770
+ label: "Secondary keyword not in URL",
3771
+ description: `The URL doesn't include "${secondaryKeyword}".`,
3772
+ howToFix: "Optionally include the secondary keyword in the URL after the primary - only if the slug stays short and clean.",
3773
+ jumpTo: { tab: "technical", anchorId: "anchor-url-slug" }
3774
+ });
3775
+ }
3776
+ }
3312
3777
  const actualQuestionHeadings = (documentFields?.headings || []).filter((h) => h.trim().endsWith("?"));
3313
3778
  if (deepAnalysis && actualQuestionHeadings.length === 0 && wordCount2 > 300) {
3314
3779
  items.push({
@@ -3419,7 +3884,7 @@ function buildSummaryItems(input) {
3419
3884
  }
3420
3885
 
3421
3886
  // src/components/tabs/SummaryTab.tsx
3422
- import { Fragment as Fragment4, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
3887
+ import { Fragment as Fragment5, jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
3423
3888
  var cardStyle2 = {
3424
3889
  borderRadius: 14,
3425
3890
  background: "rgba(255,255,255,0.55)",
@@ -3443,9 +3908,9 @@ function scoreColors(score) {
3443
3908
  }
3444
3909
  function ScoreBadge({ score, breakdown }) {
3445
3910
  const c = scoreColors(score);
3446
- return /* @__PURE__ */ jsxs8("div", { style: cardStyle2, children: [
3447
- /* @__PURE__ */ jsxs8("div", { style: { display: "flex", alignItems: "center", gap: 14 }, children: [
3448
- /* @__PURE__ */ jsxs8(
3911
+ return /* @__PURE__ */ jsxs9("div", { style: cardStyle2, children: [
3912
+ /* @__PURE__ */ jsxs9("div", { style: { display: "flex", alignItems: "center", gap: 14 }, children: [
3913
+ /* @__PURE__ */ jsxs9(
3449
3914
  "div",
3450
3915
  {
3451
3916
  style: {
@@ -3461,30 +3926,30 @@ function ScoreBadge({ score, breakdown }) {
3461
3926
  lineHeight: 1
3462
3927
  },
3463
3928
  children: [
3464
- /* @__PURE__ */ jsx9("span", { style: { fontSize: 20, fontWeight: 700, color: c.text }, children: score }),
3465
- /* @__PURE__ */ jsx9("span", { style: { fontSize: 8, fontWeight: 700, color: c.text, opacity: 0.7, letterSpacing: "0.06em", marginTop: 2 }, children: "/ 100" })
3929
+ /* @__PURE__ */ jsx10("span", { style: { fontSize: 20, fontWeight: 700, color: c.text }, children: score }),
3930
+ /* @__PURE__ */ jsx10("span", { style: { fontSize: 8, fontWeight: 700, color: c.text, opacity: 0.7, letterSpacing: "0.06em", marginTop: 2 }, children: "/ 100" })
3466
3931
  ]
3467
3932
  }
3468
3933
  ),
3469
- /* @__PURE__ */ jsxs8("div", { style: { flex: 1, minWidth: 0 }, children: [
3470
- /* @__PURE__ */ jsx9("div", { style: { fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#4b5563", fontWeight: 600, marginBottom: 2 }, children: "Content Score" }),
3471
- /* @__PURE__ */ jsx9("div", { style: { fontSize: 14, fontWeight: 700, color: c.text }, children: c.label })
3934
+ /* @__PURE__ */ jsxs9("div", { style: { flex: 1, minWidth: 0 }, children: [
3935
+ /* @__PURE__ */ jsx10("div", { style: { fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#4b5563", fontWeight: 600, marginBottom: 2 }, children: "Content Score" }),
3936
+ /* @__PURE__ */ jsx10("div", { style: { fontSize: 14, fontWeight: 700, color: c.text }, children: c.label })
3472
3937
  ] })
3473
3938
  ] }),
3474
- breakdown.length > 0 && /* @__PURE__ */ jsx9("div", { style: { marginTop: 12, display: "flex", flexDirection: "column", gap: 8 }, children: breakdown.map((comp, i) => {
3939
+ breakdown.length > 0 && /* @__PURE__ */ jsx10("div", { style: { marginTop: 12, display: "flex", flexDirection: "column", gap: 8 }, children: breakdown.map((comp, i) => {
3475
3940
  const pct = comp.max > 0 ? comp.points / comp.max * 100 : 0;
3476
3941
  const barColor = pct >= 75 ? "#16a34a" : pct >= 40 ? "#E6C01B" : "#dc2626";
3477
- return /* @__PURE__ */ jsxs8("div", { children: [
3478
- /* @__PURE__ */ jsxs8("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "baseline", marginBottom: 3 }, children: [
3479
- /* @__PURE__ */ jsx9("span", { style: { fontSize: 11, fontWeight: 600, color: "#1f2937" }, children: comp.label }),
3480
- /* @__PURE__ */ jsxs8("span", { style: { fontSize: 11, color: "#4b5563", fontVariantNumeric: "tabular-nums" }, children: [
3942
+ return /* @__PURE__ */ jsxs9("div", { children: [
3943
+ /* @__PURE__ */ jsxs9("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "baseline", marginBottom: 3 }, children: [
3944
+ /* @__PURE__ */ jsx10("span", { style: { fontSize: 11, fontWeight: 600, color: "#1f2937" }, children: comp.label }),
3945
+ /* @__PURE__ */ jsxs9("span", { style: { fontSize: 11, color: "#4b5563", fontVariantNumeric: "tabular-nums" }, children: [
3481
3946
  comp.points,
3482
3947
  " / ",
3483
3948
  comp.max
3484
3949
  ] })
3485
3950
  ] }),
3486
- /* @__PURE__ */ jsx9("div", { style: { height: 4, background: "#f1f5f9", borderRadius: 99, overflow: "hidden", marginBottom: 4 }, children: /* @__PURE__ */ jsx9("div", { style: { width: `${pct}%`, height: "100%", background: barColor, transition: "width 200ms" } }) }),
3487
- /* @__PURE__ */ jsx9("div", { style: { fontSize: 10.5, color: "#4b5563", lineHeight: 1.4 }, children: comp.detail })
3951
+ /* @__PURE__ */ jsx10("div", { style: { height: 4, background: "#f1f5f9", borderRadius: 99, overflow: "hidden", marginBottom: 4 }, children: /* @__PURE__ */ jsx10("div", { style: { width: `${pct}%`, height: "100%", background: barColor, transition: "width 200ms" } }) }),
3952
+ /* @__PURE__ */ jsx10("div", { style: { fontSize: 10.5, color: "#4b5563", lineHeight: 1.4 }, children: comp.detail })
3488
3953
  ] }, i);
3489
3954
  }) })
3490
3955
  ] });
@@ -3498,7 +3963,7 @@ function ItemCard({ item, onClick }) {
3498
3963
  const v = severityVisual(item.severity);
3499
3964
  const tab = item.jumpTo.tab;
3500
3965
  const tabLabel = TAB_LABEL[tab] ?? tab.charAt(0).toUpperCase() + tab.slice(1);
3501
- return /* @__PURE__ */ jsxs8(
3966
+ return /* @__PURE__ */ jsxs9(
3502
3967
  "div",
3503
3968
  {
3504
3969
  onClick,
@@ -3515,8 +3980,8 @@ function ItemCard({ item, onClick }) {
3515
3980
  cursor: "pointer"
3516
3981
  },
3517
3982
  children: [
3518
- /* @__PURE__ */ jsxs8("div", { style: { display: "flex", alignItems: "flex-start", gap: 9 }, children: [
3519
- /* @__PURE__ */ jsx9(
3983
+ /* @__PURE__ */ jsxs9("div", { style: { display: "flex", alignItems: "flex-start", gap: 9 }, children: [
3984
+ /* @__PURE__ */ jsx10(
3520
3985
  "div",
3521
3986
  {
3522
3987
  style: {
@@ -3529,12 +3994,12 @@ function ItemCard({ item, onClick }) {
3529
3994
  }
3530
3995
  }
3531
3996
  ),
3532
- /* @__PURE__ */ jsxs8("div", { style: { flex: 1, minWidth: 0 }, children: [
3533
- /* @__PURE__ */ jsx9("div", { style: { fontSize: 12, fontWeight: 700, color: "#1f2937", marginBottom: 2 }, children: item.label }),
3534
- /* @__PURE__ */ jsx9("div", { style: { fontSize: 11, color: "#374151", lineHeight: 1.5 }, children: item.description })
3997
+ /* @__PURE__ */ jsxs9("div", { style: { flex: 1, minWidth: 0 }, children: [
3998
+ /* @__PURE__ */ jsx10("div", { style: { fontSize: 12, fontWeight: 700, color: "#1f2937", marginBottom: 2 }, children: item.label }),
3999
+ /* @__PURE__ */ jsx10("div", { style: { fontSize: 11, color: "#374151", lineHeight: 1.5 }, children: item.description })
3535
4000
  ] })
3536
4001
  ] }),
3537
- /* @__PURE__ */ jsxs8(
4002
+ /* @__PURE__ */ jsxs9(
3538
4003
  "div",
3539
4004
  {
3540
4005
  style: {
@@ -3546,12 +4011,12 @@ function ItemCard({ item, onClick }) {
3546
4011
  lineHeight: 1.55
3547
4012
  },
3548
4013
  children: [
3549
- /* @__PURE__ */ jsx9("span", { style: { fontWeight: 700, color: "#4b5563", letterSpacing: "0.04em", fontSize: 9.5, textTransform: "uppercase", marginRight: 6 }, children: "Fix" }),
4014
+ /* @__PURE__ */ jsx10("span", { style: { fontWeight: 700, color: "#4b5563", letterSpacing: "0.04em", fontSize: 9.5, textTransform: "uppercase", marginRight: 6 }, children: "Fix" }),
3550
4015
  item.howToFix
3551
4016
  ]
3552
4017
  }
3553
4018
  ),
3554
- item.jumpTo.tab !== "summary" && /* @__PURE__ */ jsx9("div", { style: { display: "flex", justifyContent: "flex-end" }, children: /* @__PURE__ */ jsxs8("span", { style: { fontSize: 10, fontWeight: 700, color: MJH_BLUE }, children: [
4019
+ item.jumpTo.tab !== "summary" && /* @__PURE__ */ jsx10("div", { style: { display: "flex", justifyContent: "flex-end" }, children: /* @__PURE__ */ jsxs9("span", { style: { fontSize: 10, fontWeight: 700, color: MJH_BLUE }, children: [
3555
4020
  "Go to ",
3556
4021
  tabLabel,
3557
4022
  " \u203A"
@@ -3567,7 +4032,7 @@ function FilterChip({
3567
4032
  count,
3568
4033
  dotColor
3569
4034
  }) {
3570
- return /* @__PURE__ */ jsxs8(
4035
+ return /* @__PURE__ */ jsxs9(
3571
4036
  "button",
3572
4037
  {
3573
4038
  onClick,
@@ -3586,9 +4051,9 @@ function FilterChip({
3586
4051
  transition: "all 150ms"
3587
4052
  },
3588
4053
  children: [
3589
- dotColor && /* @__PURE__ */ jsx9("span", { style: { width: 6, height: 6, borderRadius: "50%", background: dotColor, display: "inline-block" } }),
3590
- /* @__PURE__ */ jsx9("span", { children: label }),
3591
- /* @__PURE__ */ jsx9("span", { style: { fontSize: 10, opacity: 0.8 }, children: count })
4054
+ dotColor && /* @__PURE__ */ jsx10("span", { style: { width: 6, height: 6, borderRadius: "50%", background: dotColor, display: "inline-block" } }),
4055
+ /* @__PURE__ */ jsx10("span", { children: label }),
4056
+ /* @__PURE__ */ jsx10("span", { style: { fontSize: 10, opacity: 0.8 }, children: count })
3592
4057
  ]
3593
4058
  }
3594
4059
  );
@@ -3600,14 +4065,17 @@ function SummaryTab({
3600
4065
  documentFields,
3601
4066
  linkingSuggestions,
3602
4067
  linkCheckResults,
4068
+ primaryKeyword,
4069
+ secondaryKeyword,
3603
4070
  isAnyLoading,
3604
4071
  onGenerateAll,
3605
4072
  onItemClick
3606
4073
  }) {
3607
4074
  const scoreDetail = useMemo(() => {
3608
4075
  if (!analysis) return null;
3609
- return calculateContentScoreDetailed(text, analysis, documentFields);
3610
- }, [text, analysis, documentFields]);
4076
+ const scored = primaryKeyword && analysis.primaryKeyword && primaryKeyword !== analysis.primaryKeyword.term ? { ...analysis, primaryKeyword: { ...analysis.primaryKeyword, term: primaryKeyword } } : analysis;
4077
+ return calculateContentScoreDetailed(text, scored, documentFields);
4078
+ }, [text, analysis, documentFields, primaryKeyword]);
3611
4079
  const score = scoreDetail?.total ?? null;
3612
4080
  const items = useMemo(
3613
4081
  () => buildSummaryItems({
@@ -3617,9 +4085,11 @@ function SummaryTab({
3617
4085
  contentScore: score,
3618
4086
  linkingSuggestions,
3619
4087
  linkCheckResults,
3620
- text
4088
+ text,
4089
+ primaryKeyword,
4090
+ secondaryKeyword
3621
4091
  }),
3622
- [analysis, deepAnalysis, documentFields, score, linkingSuggestions, linkCheckResults, text]
4092
+ [analysis, deepAnalysis, documentFields, score, linkingSuggestions, linkCheckResults, text, primaryKeyword, secondaryKeyword]
3623
4093
  );
3624
4094
  const [filter, setFilter] = useState12("all");
3625
4095
  const counts = useMemo(
@@ -3633,15 +4103,15 @@ function SummaryTab({
3633
4103
  );
3634
4104
  const filtered = filter === "all" ? items : items.filter((i) => i.severity === filter);
3635
4105
  if (!analysis) {
3636
- return /* @__PURE__ */ jsxs8("div", { style: { padding: 24, textAlign: "center" }, children: [
3637
- /* @__PURE__ */ jsx9("div", { style: { fontSize: 13, color: "#4b5563", fontWeight: 500 }, children: "Start with the Keywords tab" }),
3638
- /* @__PURE__ */ jsx9("div", { style: { fontSize: 11, color: "#4b5563", marginTop: 4 }, children: "Once keywords are analyzed, the summary appears here." })
4106
+ return /* @__PURE__ */ jsxs9("div", { style: { padding: 24, textAlign: "center" }, children: [
4107
+ /* @__PURE__ */ jsx10("div", { style: { fontSize: 13, color: "#4b5563", fontWeight: 500 }, children: "Start with the Keywords tab" }),
4108
+ /* @__PURE__ */ jsx10("div", { style: { fontSize: 11, color: "#4b5563", marginTop: 4 }, children: "Once keywords are analyzed, the summary appears here." })
3639
4109
  ] });
3640
4110
  }
3641
- return /* @__PURE__ */ jsxs8("div", { style: { padding: 12, display: "flex", flexDirection: "column", gap: 12 }, children: [
3642
- score != null && scoreDetail && /* @__PURE__ */ jsx9(ScoreBadge, { score, breakdown: scoreDetail.components }),
3643
- /* @__PURE__ */ jsxs8("div", { style: cardStyle2, children: [
3644
- isAnyLoading ? /* @__PURE__ */ jsx9("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", padding: "4px 0" }, children: /* @__PURE__ */ jsx9(ShimmerLoader, { messages: DEFAULT_GENERATE_ALL_MESSAGES }) }) : /* @__PURE__ */ jsx9(
4111
+ return /* @__PURE__ */ jsxs9("div", { style: { padding: 12, display: "flex", flexDirection: "column", gap: 12 }, children: [
4112
+ score != null && scoreDetail && /* @__PURE__ */ jsx10(ScoreBadge, { score, breakdown: scoreDetail.components }),
4113
+ /* @__PURE__ */ jsxs9("div", { style: cardStyle2, children: [
4114
+ isAnyLoading ? /* @__PURE__ */ jsx10("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", padding: "4px 0" }, children: /* @__PURE__ */ jsx10(ShimmerLoader, { messages: DEFAULT_GENERATE_ALL_MESSAGES }) }) : /* @__PURE__ */ jsx10(
3645
4115
  "button",
3646
4116
  {
3647
4117
  onClick: onGenerateAll,
@@ -3666,27 +4136,27 @@ function SummaryTab({
3666
4136
  transition: "all 150ms",
3667
4137
  letterSpacing: "0.01em"
3668
4138
  },
3669
- children: "Generate everything"
4139
+ children: "Run all analyses"
3670
4140
  }
3671
4141
  ),
3672
- /* @__PURE__ */ jsxs8("div", { style: { fontSize: 10.5, color: "#4b5563", marginTop: 8, lineHeight: 1.5 }, children: [
4142
+ /* @__PURE__ */ jsxs9("div", { style: { fontSize: 10.5, color: "#4b5563", marginTop: 8, lineHeight: 1.5 }, children: [
3673
4143
  "Runs the analyses that fill the ",
3674
- /* @__PURE__ */ jsx9("strong", { children: "AEO/GEO" }),
4144
+ /* @__PURE__ */ jsx10("strong", { children: "AEO/GEO" }),
3675
4145
  ", ",
3676
- /* @__PURE__ */ jsx9("strong", { children: "Linking" }),
4146
+ /* @__PURE__ */ jsx10("strong", { children: "Linking" }),
3677
4147
  ", and ",
3678
- /* @__PURE__ */ jsx9("strong", { children: "Other Recs" }),
4148
+ /* @__PURE__ */ jsx10("strong", { children: "Other Recs" }),
3679
4149
  " tabs. New issues they find appear in this Summary as each one finishes."
3680
4150
  ] })
3681
4151
  ] }),
3682
- /* @__PURE__ */ jsxs8("div", { style: { display: "flex", flexWrap: "wrap", gap: 6 }, children: [
3683
- /* @__PURE__ */ jsx9(FilterChip, { active: filter === "all", onClick: () => setFilter("all"), label: "All", count: counts.all }),
3684
- /* @__PURE__ */ jsx9(FilterChip, { active: filter === "error", onClick: () => setFilter("error"), label: "Errors", count: counts.error, dotColor: "#dc2626" }),
3685
- /* @__PURE__ */ jsx9(FilterChip, { active: filter === "warning", onClick: () => setFilter("warning"), label: "Warnings", count: counts.warning, dotColor: "#E6C01B" }),
3686
- /* @__PURE__ */ jsx9(FilterChip, { active: filter === "opportunity", onClick: () => setFilter("opportunity"), label: "Opportunities", count: counts.opportunity, dotColor: MJH_BLUE })
4152
+ /* @__PURE__ */ jsxs9("div", { style: { display: "flex", flexWrap: "wrap", gap: 6 }, children: [
4153
+ /* @__PURE__ */ jsx10(FilterChip, { active: filter === "all", onClick: () => setFilter("all"), label: "All", count: counts.all }),
4154
+ /* @__PURE__ */ jsx10(FilterChip, { active: filter === "error", onClick: () => setFilter("error"), label: "Errors", count: counts.error, dotColor: "#dc2626" }),
4155
+ /* @__PURE__ */ jsx10(FilterChip, { active: filter === "warning", onClick: () => setFilter("warning"), label: "Warnings", count: counts.warning, dotColor: "#E6C01B" }),
4156
+ /* @__PURE__ */ jsx10(FilterChip, { active: filter === "opportunity", onClick: () => setFilter("opportunity"), label: "Opportunities", count: counts.opportunity, dotColor: MJH_BLUE })
3687
4157
  ] }),
3688
- /* @__PURE__ */ jsx9("div", { id: "anchor-summary-issues", style: { display: "flex", flexDirection: "column", gap: 8 }, children: filtered.length === 0 ? /* @__PURE__ */ jsx9("div", { style: { ...cardStyle2, textAlign: "center", padding: "20px 14px" }, children: items.length === 0 ? /* @__PURE__ */ jsxs8(Fragment4, { children: [
3689
- /* @__PURE__ */ jsx9(
4158
+ /* @__PURE__ */ jsx10("div", { id: "anchor-summary-issues", style: { display: "flex", flexDirection: "column", gap: 8 }, children: filtered.length === 0 ? /* @__PURE__ */ jsx10("div", { style: { ...cardStyle2, textAlign: "center", padding: "20px 14px" }, children: items.length === 0 ? /* @__PURE__ */ jsxs9(Fragment5, { children: [
4159
+ /* @__PURE__ */ jsx10(
3690
4160
  "div",
3691
4161
  {
3692
4162
  style: {
@@ -3699,21 +4169,21 @@ function SummaryTab({
3699
4169
  justifyContent: "center",
3700
4170
  margin: "0 auto 8px"
3701
4171
  },
3702
- children: /* @__PURE__ */ jsx9("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "#16a34a", children: /* @__PURE__ */ jsx9("path", { fillRule: "evenodd", d: "M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z", clipRule: "evenodd" }) })
4172
+ children: /* @__PURE__ */ jsx10("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "#16a34a", children: /* @__PURE__ */ jsx10("path", { fillRule: "evenodd", d: "M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z", clipRule: "evenodd" }) })
3703
4173
  }
3704
4174
  ),
3705
- /* @__PURE__ */ jsx9("div", { style: { fontSize: 13, color: "#16a34a", fontWeight: 700 }, children: "Looking good" }),
3706
- /* @__PURE__ */ jsx9("div", { style: { fontSize: 11, color: "#4b5563", marginTop: 2 }, children: "No issues found for this article." })
3707
- ] }) : /* @__PURE__ */ jsx9("div", { style: { fontSize: 12, color: "#4b5563" }, children: "Nothing in this category." }) }) : filtered.map((item) => /* @__PURE__ */ jsx9(ItemCard, { item, onClick: () => onItemClick(item) }, item.id)) }),
3708
- isAnyLoading && items.length > 0 && /* @__PURE__ */ jsxs8("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", gap: 6, padding: "4px 0" }, children: [
3709
- /* @__PURE__ */ jsx9(LoadingBars, { size: "xs", color: MJH_BLUE }),
3710
- /* @__PURE__ */ jsx9("span", { style: { fontSize: 10, color: "#4b5563" }, children: "Still checking..." })
4175
+ /* @__PURE__ */ jsx10("div", { style: { fontSize: 13, color: "#16a34a", fontWeight: 700 }, children: "Looking good" }),
4176
+ /* @__PURE__ */ jsx10("div", { style: { fontSize: 11, color: "#4b5563", marginTop: 2 }, children: "No issues found for this article." })
4177
+ ] }) : /* @__PURE__ */ jsx10("div", { style: { fontSize: 12, color: "#4b5563" }, children: "Nothing in this category." }) }) : filtered.map((item) => /* @__PURE__ */ jsx10(ItemCard, { item, onClick: () => onItemClick(item) }, item.id)) }),
4178
+ isAnyLoading && items.length > 0 && /* @__PURE__ */ jsxs9("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", gap: 6, padding: "4px 0" }, children: [
4179
+ /* @__PURE__ */ jsx10(LoadingBars, { size: "xs", color: MJH_BLUE }),
4180
+ /* @__PURE__ */ jsx10("span", { style: { fontSize: 10, color: "#4b5563" }, children: "Still checking..." })
3711
4181
  ] })
3712
4182
  ] });
3713
4183
  }
3714
4184
 
3715
4185
  // src/components/tabs/AEOTab.tsx
3716
- import { useMemo as useMemo2, useState as useState13 } from "react";
4186
+ import { useEffect as useEffect10, useMemo as useMemo2, useRef as useRef10, useState as useState13 } from "react";
3717
4187
 
3718
4188
  // src/lib/geoAnalysis.ts
3719
4189
  var FACT_PATTERN = /\d+(?:\.\d+)?\s*%|\b\d{1,3}(?:,\d{3})+\b|\bn\s*=\s*\d+\b|\bp\s*[<=]\s*0?\.\d+\b|\b\d+(?:\.\d+)?\s*(?:patients|participants|subjects|cases|deaths|adverse events|mg|mcg|hours|days|weeks|months|years|fold|x)\b|\b(?:NEJM|JAMA|FDA|EMA|CDC|WHO|NIH|ACC|ASCO|ASH|ESMO|AHA|ACS)\b|\bet al\.?\b|\b(?:phase|stage)\s+(?:I{1,3}V?|1|2|3|4)\b/i;
@@ -3787,7 +4257,7 @@ function analyzeGEO(text, headings) {
3787
4257
  }
3788
4258
 
3789
4259
  // src/components/tabs/AEOTab.tsx
3790
- import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
4260
+ import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
3791
4261
  var AEO_PURPLE = "#005DAC";
3792
4262
  var GEO_TEAL = "#C9A716";
3793
4263
  var cardStyle3 = {
@@ -3799,7 +4269,7 @@ var cardStyle3 = {
3799
4269
  padding: "14px"
3800
4270
  };
3801
4271
  function AiPill() {
3802
- return /* @__PURE__ */ jsx10(
4272
+ return /* @__PURE__ */ jsx11(
3803
4273
  "span",
3804
4274
  {
3805
4275
  style: {
@@ -3818,23 +4288,29 @@ function AiPill() {
3818
4288
  );
3819
4289
  }
3820
4290
  function SectionHeader2({ label, iconColor, ai }) {
3821
- return /* @__PURE__ */ jsxs9("div", { style: { display: "flex", alignItems: "center", gap: 7, marginBottom: 4 }, children: [
3822
- /* @__PURE__ */ jsx10("div", { style: { width: 7, height: 7, borderRadius: "50%", background: iconColor, flexShrink: 0 } }),
3823
- /* @__PURE__ */ jsx10("span", { style: { fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#4b5563", fontWeight: 600, flex: 1 }, children: label }),
3824
- ai && /* @__PURE__ */ jsx10(AiPill, {})
4291
+ return /* @__PURE__ */ jsxs10("div", { style: { display: "flex", alignItems: "center", gap: 7, marginBottom: 4 }, children: [
4292
+ /* @__PURE__ */ jsx11("div", { style: { width: 7, height: 7, borderRadius: "50%", background: iconColor, flexShrink: 0 } }),
4293
+ /* @__PURE__ */ jsx11("span", { style: { fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#4b5563", fontWeight: 600, flex: 1 }, children: label }),
4294
+ ai && /* @__PURE__ */ jsx11(AiPill, {})
3825
4295
  ] });
3826
4296
  }
3827
4297
  function CopyButton({ text }) {
3828
4298
  const [copied, setCopied] = useState13(false);
4299
+ const copyTimerRef = useRef10(null);
4300
+ useEffect10(() => {
4301
+ return () => {
4302
+ if (copyTimerRef.current) clearTimeout(copyTimerRef.current);
4303
+ };
4304
+ }, []);
3829
4305
  const handleCopy = async () => {
3830
4306
  try {
3831
4307
  await navigator.clipboard.writeText(text);
3832
4308
  setCopied(true);
3833
- setTimeout(() => setCopied(false), 1500);
4309
+ copyTimerRef.current = setTimeout(() => setCopied(false), 1500);
3834
4310
  } catch {
3835
4311
  }
3836
4312
  };
3837
- return /* @__PURE__ */ jsx10(
4313
+ return /* @__PURE__ */ jsx11(
3838
4314
  "button",
3839
4315
  {
3840
4316
  onClick: handleCopy,
@@ -3853,9 +4329,9 @@ function CopyButton({ text }) {
3853
4329
  transition: "color 150ms"
3854
4330
  },
3855
4331
  title: copied ? "Copied!" : "Copy to clipboard",
3856
- children: copied ? /* @__PURE__ */ jsx10("svg", { width: "11", height: "11", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx10("path", { fillRule: "evenodd", d: "M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z", clipRule: "evenodd" }) }) : /* @__PURE__ */ jsxs9("svg", { width: "11", height: "11", viewBox: "0 0 20 20", fill: "currentColor", children: [
3857
- /* @__PURE__ */ jsx10("path", { d: "M7 3.5A1.5 1.5 0 018.5 2h3.879a1.5 1.5 0 011.06.44l3.122 3.12A1.5 1.5 0 0117 6.622V12.5a1.5 1.5 0 01-1.5 1.5h-1v-3.379a3 3 0 00-.879-2.121L10.5 5.379A3 3 0 008.379 4.5H7v-1z" }),
3858
- /* @__PURE__ */ jsx10("path", { d: "M4.5 6A1.5 1.5 0 003 7.5v9A1.5 1.5 0 004.5 18h7a1.5 1.5 0 001.5-1.5v-5.879a1.5 1.5 0 00-.44-1.06L9.44 6.439A1.5 1.5 0 008.378 6H4.5z" })
4332
+ children: copied ? /* @__PURE__ */ jsx11("svg", { width: "11", height: "11", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx11("path", { fillRule: "evenodd", d: "M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z", clipRule: "evenodd" }) }) : /* @__PURE__ */ jsxs10("svg", { width: "11", height: "11", viewBox: "0 0 20 20", fill: "currentColor", children: [
4333
+ /* @__PURE__ */ jsx11("path", { d: "M7 3.5A1.5 1.5 0 018.5 2h3.879a1.5 1.5 0 011.06.44l3.122 3.12A1.5 1.5 0 0117 6.622V12.5a1.5 1.5 0 01-1.5 1.5h-1v-3.379a3 3 0 00-.879-2.121L10.5 5.379A3 3 0 008.379 4.5H7v-1z" }),
4334
+ /* @__PURE__ */ jsx11("path", { d: "M4.5 6A1.5 1.5 0 003 7.5v9A1.5 1.5 0 004.5 18h7a1.5 1.5 0 001.5-1.5v-5.879a1.5 1.5 0 00-.44-1.06L9.44 6.439A1.5 1.5 0 008.378 6H4.5z" })
3859
4335
  ] })
3860
4336
  }
3861
4337
  );
@@ -3870,13 +4346,13 @@ function GEOCard({ geo, publication }) {
3870
4346
  const fdBg = effectiveStatus === "strong" ? "rgba(22,163,74,0.1)" : effectiveStatus === "moderate" ? "rgba(230,192,27,0.15)" : "rgba(220,38,38,0.08)";
3871
4347
  const goodCount = geo.headingAudit.filter((h) => h.status === "good").length;
3872
4348
  const totalHeadings = geo.headingAudit.length;
3873
- return /* @__PURE__ */ jsxs9("div", { style: cardStyle3, children: [
3874
- /* @__PURE__ */ jsxs9("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", marginBottom: 4 }, children: [
3875
- /* @__PURE__ */ jsx10(SectionHeader2, { label: "AI Citation Readiness", iconColor: GEO_TEAL }),
3876
- /* @__PURE__ */ jsx10(FeedbackButton, { suggestionType: "geo_summary", suggestionText: `facts/1k: ${fd.factsPerThousandWords}; short-answer headings: ${goodCount}/${totalHeadings}`, publication })
4349
+ return /* @__PURE__ */ jsxs10("div", { style: cardStyle3, children: [
4350
+ /* @__PURE__ */ jsxs10("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", marginBottom: 4 }, children: [
4351
+ /* @__PURE__ */ jsx11(SectionHeader2, { label: "AI Citation Readiness", iconColor: GEO_TEAL }),
4352
+ /* @__PURE__ */ jsx11(FeedbackButton, { suggestionType: "geo_summary", suggestionText: `facts/1k: ${fd.factsPerThousandWords}; short-answer headings: ${goodCount}/${totalHeadings}`, publication })
3877
4353
  ] }),
3878
- /* @__PURE__ */ jsx10("div", { style: { fontSize: 10, color: "#4b5563", marginBottom: 10, lineHeight: 1.5 }, children: "How easy this article is for ChatGPT, Perplexity, Gemini, and Google's AI Overviews to cite." }),
3879
- /* @__PURE__ */ jsxs9(
4354
+ /* @__PURE__ */ jsx11("div", { style: { fontSize: 10, color: "#4b5563", marginBottom: 10, lineHeight: 1.5 }, children: "How easy this article is for ChatGPT, Perplexity, Gemini, and Google's AI Overviews to cite." }),
4355
+ /* @__PURE__ */ jsxs10(
3880
4356
  "div",
3881
4357
  {
3882
4358
  style: {
@@ -3889,7 +4365,7 @@ function GEOCard({ geo, publication }) {
3889
4365
  marginBottom: 8
3890
4366
  },
3891
4367
  children: [
3892
- /* @__PURE__ */ jsxs9(
4368
+ /* @__PURE__ */ jsxs10(
3893
4369
  "div",
3894
4370
  {
3895
4371
  style: {
@@ -3905,17 +4381,17 @@ function GEOCard({ geo, publication }) {
3905
4381
  boxShadow: "0 1px 2px rgba(0,0,0,0.06)"
3906
4382
  },
3907
4383
  children: [
3908
- /* @__PURE__ */ jsx10("span", { style: { fontSize: 18, fontWeight: 700, color: fdColor, lineHeight: 1 }, children: fd.factsPerThousandWords }),
3909
- /* @__PURE__ */ jsx10("span", { style: { fontSize: 7.5, fontWeight: 700, color: fdColor, opacity: 0.75, letterSpacing: "0.05em", marginTop: 2 }, children: "PER 1K" })
4384
+ /* @__PURE__ */ jsx11("span", { style: { fontSize: 18, fontWeight: 700, color: fdColor, lineHeight: 1 }, children: fd.factsPerThousandWords }),
4385
+ /* @__PURE__ */ jsx11("span", { style: { fontSize: 7.5, fontWeight: 700, color: fdColor, opacity: 0.75, letterSpacing: "0.05em", marginTop: 2 }, children: "PER 1K" })
3910
4386
  ]
3911
4387
  }
3912
4388
  ),
3913
- /* @__PURE__ */ jsxs9("div", { style: { flex: 1, minWidth: 0 }, children: [
3914
- /* @__PURE__ */ jsxs9("div", { style: { fontSize: 11, fontWeight: 700, color: fdColor, marginBottom: 2 }, children: [
4389
+ /* @__PURE__ */ jsxs10("div", { style: { flex: 1, minWidth: 0 }, children: [
4390
+ /* @__PURE__ */ jsxs10("div", { style: { fontSize: 11, fontWeight: 700, color: fdColor, marginBottom: 2 }, children: [
3915
4391
  "Fact density: ",
3916
4392
  fdLabel
3917
4393
  ] }),
3918
- /* @__PURE__ */ jsxs9("div", { style: { fontSize: 11, color: "#1f2937", lineHeight: 1.45 }, children: [
4394
+ /* @__PURE__ */ jsxs10("div", { style: { fontSize: 11, color: "#1f2937", lineHeight: 1.45 }, children: [
3919
4395
  fd.factCount,
3920
4396
  " specific stat",
3921
4397
  fd.factCount === 1 ? "" : "s",
@@ -3931,7 +4407,7 @@ function GEOCard({ geo, publication }) {
3931
4407
  ]
3932
4408
  }
3933
4409
  ),
3934
- fd.driftPassages > 0 && /* @__PURE__ */ jsxs9(
4410
+ fd.driftPassages > 0 && /* @__PURE__ */ jsxs10(
3935
4411
  "div",
3936
4412
  {
3937
4413
  style: {
@@ -3945,15 +4421,15 @@ function GEOCard({ geo, publication }) {
3945
4421
  lineHeight: 1.45
3946
4422
  },
3947
4423
  children: [
3948
- /* @__PURE__ */ jsx10("strong", { children: fd.driftPassages }),
4424
+ /* @__PURE__ */ jsx11("strong", { children: fd.driftPassages }),
3949
4425
  " passage",
3950
4426
  fd.driftPassages === 1 ? "" : "s",
3951
4427
  " over 200 words with no specific stats or citations. AI engines tend to skip these."
3952
4428
  ]
3953
4429
  }
3954
4430
  ),
3955
- totalHeadings > 0 && /* @__PURE__ */ jsxs9("div", { style: { marginTop: 4 }, children: [
3956
- /* @__PURE__ */ jsxs9(
4431
+ totalHeadings > 0 && /* @__PURE__ */ jsxs10("div", { style: { marginTop: 4 }, children: [
4432
+ /* @__PURE__ */ jsxs10(
3957
4433
  "button",
3958
4434
  {
3959
4435
  onClick: () => setShowDetails((v) => !v),
@@ -3972,22 +4448,22 @@ function GEOCard({ geo, publication }) {
3972
4448
  color: GEO_TEAL
3973
4449
  },
3974
4450
  children: [
3975
- /* @__PURE__ */ jsxs9("span", { children: [
4451
+ /* @__PURE__ */ jsxs10("span", { children: [
3976
4452
  "Short-answer paragraphs: ",
3977
4453
  goodCount,
3978
4454
  "/",
3979
4455
  totalHeadings,
3980
4456
  " headings have one"
3981
4457
  ] }),
3982
- /* @__PURE__ */ jsx10("svg", { width: "11", height: "11", viewBox: "0 0 20 20", fill: "currentColor", style: { transform: showDetails ? "rotate(180deg)" : "none", transition: "transform 150ms" }, children: /* @__PURE__ */ jsx10("path", { fillRule: "evenodd", d: "M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z", clipRule: "evenodd" }) })
4458
+ /* @__PURE__ */ jsx11("svg", { width: "11", height: "11", viewBox: "0 0 20 20", fill: "currentColor", style: { transform: showDetails ? "rotate(180deg)" : "none", transition: "transform 150ms" }, children: /* @__PURE__ */ jsx11("path", { fillRule: "evenodd", d: "M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z", clipRule: "evenodd" }) })
3983
4459
  ]
3984
4460
  }
3985
4461
  ),
3986
- showDetails && /* @__PURE__ */ jsxs9("div", { style: { marginTop: 6, display: "flex", flexDirection: "column", gap: 4 }, children: [
3987
- /* @__PURE__ */ jsx10("div", { style: { fontSize: 10, color: "#4b5563", marginBottom: 4 }, children: "Aim for a 40-60 word answer right after each heading. That's the chunk AI engines extract." }),
4462
+ showDetails && /* @__PURE__ */ jsxs10("div", { style: { marginTop: 6, display: "flex", flexDirection: "column", gap: 4 }, children: [
4463
+ /* @__PURE__ */ jsx11("div", { style: { fontSize: 10, color: "#4b5563", marginBottom: 4 }, children: "Aim for a 40-60 word answer right after each heading. That's the chunk AI engines extract." }),
3988
4464
  geo.headingAudit.map((h, i) => {
3989
4465
  const c = h.status === "good" ? { bg: "rgba(22,163,74,0.08)", color: "#16a34a", label: `${h.words} words \u2713` } : h.status === "too-short" ? { bg: "rgba(230,192,27,0.12)", color: "#8B7310", label: `${h.words} words - too short` } : h.status === "too-long" ? { bg: "rgba(230,192,27,0.12)", color: "#8B7310", label: `${h.words} words - condense to 40-60` } : { bg: "rgba(220,38,38,0.06)", color: "#dc2626", label: "no body content" };
3990
- return /* @__PURE__ */ jsxs9(
4466
+ return /* @__PURE__ */ jsxs10(
3991
4467
  "div",
3992
4468
  {
3993
4469
  style: {
@@ -4001,8 +4477,8 @@ function GEOCard({ geo, publication }) {
4001
4477
  gap: 8
4002
4478
  },
4003
4479
  children: [
4004
- /* @__PURE__ */ jsx10("span", { style: { flex: 1, minWidth: 0, color: "#1f2937", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: h.heading }),
4005
- /* @__PURE__ */ jsx10("span", { style: { fontSize: 10, fontWeight: 600, color: c.color, flexShrink: 0 }, children: c.label })
4480
+ /* @__PURE__ */ jsx11("span", { style: { flex: 1, minWidth: 0, color: "#1f2937", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: h.heading }),
4481
+ /* @__PURE__ */ jsx11("span", { style: { fontSize: 10, fontWeight: 600, color: c.color, flexShrink: 0 }, children: c.label })
4006
4482
  ]
4007
4483
  },
4008
4484
  i
@@ -4039,8 +4515,8 @@ function AEOTab({
4039
4515
  originalHeading: void 0,
4040
4516
  rationale: h.rationale
4041
4517
  })) ?? [];
4042
- return /* @__PURE__ */ jsxs9("div", { style: { padding: 12, display: "flex", flexDirection: "column", gap: 12 }, children: [
4043
- aeoContentChanged && /* @__PURE__ */ jsxs9(
4518
+ return /* @__PURE__ */ jsxs10("div", { style: { padding: 12, display: "flex", flexDirection: "column", gap: 12 }, children: [
4519
+ aeoContentChanged && /* @__PURE__ */ jsxs10(
4044
4520
  "div",
4045
4521
  {
4046
4522
  onClick: runDeepAnalysis,
@@ -4055,30 +4531,30 @@ function AEOTab({
4055
4531
  cursor: "pointer"
4056
4532
  },
4057
4533
  children: [
4058
- /* @__PURE__ */ jsx10("span", { style: { fontSize: 11, color: "#92400e" }, children: "Content has changed since this was generated." }),
4059
- /* @__PURE__ */ jsx10("span", { style: { fontSize: 11, fontWeight: 600, color: AEO_PURPLE, textDecoration: "underline" }, children: "Update" })
4534
+ /* @__PURE__ */ jsx11("span", { style: { fontSize: 11, color: "#92400e" }, children: "Content has changed since this was generated." }),
4535
+ /* @__PURE__ */ jsx11("span", { style: { fontSize: 11, fontWeight: 600, color: AEO_PURPLE, textDecoration: "underline" }, children: "Update" })
4060
4536
  ]
4061
4537
  }
4062
4538
  ),
4063
- hasEnoughTextForGEO && /* @__PURE__ */ jsx10(GEOCard, { geo, publication }),
4064
- hasEnoughText && !hasEnoughTextForGEO && /* @__PURE__ */ jsx10("div", { style: { ...cardStyle3, textAlign: "center" }, children: /* @__PURE__ */ jsxs9("div", { style: { fontSize: 11, color: "#4b5563", lineHeight: 1.5 }, children: [
4065
- /* @__PURE__ */ jsx10("strong", { style: { color: "#C9A716" }, children: "AI citation analysis" }),
4539
+ hasEnoughTextForGEO && /* @__PURE__ */ jsx11(GEOCard, { geo, publication }),
4540
+ hasEnoughText && !hasEnoughTextForGEO && /* @__PURE__ */ jsx11("div", { style: { ...cardStyle3, textAlign: "center" }, children: /* @__PURE__ */ jsxs10("div", { style: { fontSize: 11, color: "#4b5563", lineHeight: 1.5 }, children: [
4541
+ /* @__PURE__ */ jsx11("strong", { style: { color: "#C9A716" }, children: "AI citation analysis" }),
4066
4542
  " needs at least 150 words to read fact density.",
4067
- /* @__PURE__ */ jsx10("br", {}),
4068
- /* @__PURE__ */ jsxs9("span", { style: { color: "#4b5563" }, children: [
4543
+ /* @__PURE__ */ jsx11("br", {}),
4544
+ /* @__PURE__ */ jsxs10("span", { style: { color: "#4b5563" }, children: [
4069
4545
  "Current: ",
4070
4546
  geoWordCount,
4071
4547
  " word",
4072
4548
  geoWordCount === 1 ? "" : "s"
4073
4549
  ] })
4074
4550
  ] }) }),
4075
- !deepAnalysis && isDeepLoading && /* @__PURE__ */ jsxs9("div", { style: { ...cardStyle3, display: "flex", alignItems: "center", justifyContent: "center", gap: 8 }, children: [
4076
- /* @__PURE__ */ jsx10(LoadingBars, { size: "xs", color: AEO_PURPLE }),
4077
- /* @__PURE__ */ jsx10("span", { style: { fontSize: 12, color: "#4b5563" }, children: "Generating AEO insights..." })
4551
+ !deepAnalysis && isDeepLoading && /* @__PURE__ */ jsxs10("div", { style: { ...cardStyle3, display: "flex", alignItems: "center", justifyContent: "center", gap: 8 }, children: [
4552
+ /* @__PURE__ */ jsx11(LoadingBars, { size: "xs", color: AEO_PURPLE }),
4553
+ /* @__PURE__ */ jsx11("span", { style: { fontSize: 12, color: "#4b5563" }, children: "Generating AEO insights..." })
4078
4554
  ] }),
4079
- !deepAnalysis && !isDeepLoading && /* @__PURE__ */ jsxs9("div", { style: { ...cardStyle3, textAlign: "center" }, children: [
4080
- /* @__PURE__ */ jsx10("div", { style: { fontSize: 12, color: "#4b5563" }, children: "AI citation readiness and question-style heading suggestions appear here once analysis runs." }),
4081
- /* @__PURE__ */ jsx10(
4555
+ !deepAnalysis && !isDeepLoading && /* @__PURE__ */ jsxs10("div", { style: { ...cardStyle3, textAlign: "center" }, children: [
4556
+ /* @__PURE__ */ jsx11("div", { style: { fontSize: 12, color: "#4b5563" }, children: "AI citation readiness and question-style heading suggestions appear here once analysis runs." }),
4557
+ /* @__PURE__ */ jsx11(
4082
4558
  "button",
4083
4559
  {
4084
4560
  onClick: runDeepAnalysis,
@@ -4098,11 +4574,11 @@ function AEOTab({
4098
4574
  }
4099
4575
  )
4100
4576
  ] }),
4101
- deepAnalysis && !aeo && /* @__PURE__ */ jsx10("div", { style: { ...cardStyle3, textAlign: "center" }, children: /* @__PURE__ */ jsx10("span", { style: { fontSize: 12, color: "#4b5563" }, children: "No insights came back. Try again - the analysis may have timed out." }) }),
4102
- questionHeadings.length > 0 && /* @__PURE__ */ jsxs9("div", { style: cardStyle3, children: [
4103
- /* @__PURE__ */ jsx10(SectionHeader2, { label: "Question-Style Headings", iconColor: AEO_PURPLE }),
4104
- /* @__PURE__ */ jsx10("div", { style: { fontSize: 10, color: "#4b5563", marginBottom: 8 }, children: "Rewrites of your existing headings as questions. Google often pulls these into featured snippets." }),
4105
- /* @__PURE__ */ jsx10("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: questionHeadings.map((h, i) => /* @__PURE__ */ jsxs9(
4577
+ deepAnalysis && !aeo && /* @__PURE__ */ jsx11("div", { style: { ...cardStyle3, textAlign: "center" }, children: /* @__PURE__ */ jsx11("span", { style: { fontSize: 12, color: "#4b5563" }, children: "No insights came back. Try again - the analysis may have timed out." }) }),
4578
+ questionHeadings.length > 0 && /* @__PURE__ */ jsxs10("div", { style: cardStyle3, children: [
4579
+ /* @__PURE__ */ jsx11(SectionHeader2, { label: "Question-Style Headings", iconColor: AEO_PURPLE }),
4580
+ /* @__PURE__ */ jsx11("div", { style: { fontSize: 10, color: "#4b5563", marginBottom: 8 }, children: "Rewrites of your existing headings as questions. Google often pulls these into featured snippets." }),
4581
+ /* @__PURE__ */ jsx11("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: questionHeadings.map((h, i) => /* @__PURE__ */ jsxs10(
4106
4582
  "div",
4107
4583
  {
4108
4584
  style: {
@@ -4112,26 +4588,26 @@ function AEOTab({
4112
4588
  borderLeft: `3px solid ${AEO_PURPLE}`
4113
4589
  },
4114
4590
  children: [
4115
- /* @__PURE__ */ jsxs9("div", { style: { display: "flex", alignItems: "flex-start", justifyContent: "space-between", gap: 8 }, children: [
4116
- /* @__PURE__ */ jsxs9("div", { style: { flex: 1 }, children: [
4117
- h.originalHeading && /* @__PURE__ */ jsx10("div", { style: { fontSize: 11, color: "#4b5563", textDecoration: "line-through", marginBottom: 2 }, children: h.originalHeading }),
4118
- /* @__PURE__ */ jsx10("div", { style: { fontSize: 12, fontWeight: 700, color: AEO_PURPLE, lineHeight: 1.5 }, children: h.heading })
4591
+ /* @__PURE__ */ jsxs10("div", { style: { display: "flex", alignItems: "flex-start", justifyContent: "space-between", gap: 8 }, children: [
4592
+ /* @__PURE__ */ jsxs10("div", { style: { flex: 1 }, children: [
4593
+ h.originalHeading && /* @__PURE__ */ jsx11("div", { style: { fontSize: 11, color: "#4b5563", textDecoration: "line-through", marginBottom: 2 }, children: h.originalHeading }),
4594
+ /* @__PURE__ */ jsx11("div", { style: { fontSize: 12, fontWeight: 700, color: AEO_PURPLE, lineHeight: 1.5 }, children: h.heading })
4119
4595
  ] }),
4120
- /* @__PURE__ */ jsxs9("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
4121
- /* @__PURE__ */ jsx10(CopyButton, { text: h.heading }),
4122
- /* @__PURE__ */ jsx10(FeedbackButton, { suggestionType: "aeo_heading", suggestionText: h.heading, publication })
4596
+ /* @__PURE__ */ jsxs10("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
4597
+ /* @__PURE__ */ jsx11(CopyButton, { text: h.heading }),
4598
+ /* @__PURE__ */ jsx11(FeedbackButton, { suggestionType: "aeo_heading", suggestionText: h.heading, publication })
4123
4599
  ] })
4124
4600
  ] }),
4125
- /* @__PURE__ */ jsx10("div", { style: { fontSize: 10, color: "#4b5563", marginTop: 4, fontStyle: "italic" }, children: h.rationale })
4601
+ /* @__PURE__ */ jsx11("div", { style: { fontSize: 10, color: "#4b5563", marginTop: 4, fontStyle: "italic" }, children: h.rationale })
4126
4602
  ]
4127
4603
  },
4128
4604
  i
4129
4605
  )) })
4130
4606
  ] }),
4131
- /* @__PURE__ */ jsxs9("div", { style: cardStyle3, children: [
4132
- /* @__PURE__ */ jsx10(SectionHeader2, { label: "Content Block Suggestions", iconColor: AEO_PURPLE }),
4133
- /* @__PURE__ */ jsx10("div", { style: { fontSize: 10, color: "#4b5563", marginBottom: 10 }, children: "Short, citable blocks to use inside or alongside the article - takeaways, infographic ideas, and bullet points." }),
4134
- !contentSuggestions && !isCSLoading && /* @__PURE__ */ jsx10(
4607
+ /* @__PURE__ */ jsxs10("div", { style: cardStyle3, children: [
4608
+ /* @__PURE__ */ jsx11(SectionHeader2, { label: "Content Block Suggestions", iconColor: AEO_PURPLE }),
4609
+ /* @__PURE__ */ jsx11("div", { style: { fontSize: 10, color: "#4b5563", marginBottom: 10 }, children: "Short, citable blocks to use inside or alongside the article - takeaways, infographic ideas, and bullet points." }),
4610
+ !contentSuggestions && !isCSLoading && /* @__PURE__ */ jsx11(
4135
4611
  "button",
4136
4612
  {
4137
4613
  onClick: loadContentSuggestions,
@@ -4155,15 +4631,15 @@ function AEOTab({
4155
4631
  children: "Generate suggestions"
4156
4632
  }
4157
4633
  ),
4158
- isCSLoading && /* @__PURE__ */ jsxs9("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", gap: 8, padding: "8px 0" }, children: [
4159
- /* @__PURE__ */ jsx10(LoadingBars, { size: "xs", color: AEO_PURPLE }),
4160
- /* @__PURE__ */ jsx10("span", { style: { fontSize: 11, color: "#4b5563" }, children: "Generating content suggestions..." })
4634
+ isCSLoading && /* @__PURE__ */ jsxs10("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", gap: 8, padding: "8px 0" }, children: [
4635
+ /* @__PURE__ */ jsx11(LoadingBars, { size: "xs", color: AEO_PURPLE }),
4636
+ /* @__PURE__ */ jsx11("span", { style: { fontSize: 11, color: "#4b5563" }, children: "Generating content suggestions..." })
4161
4637
  ] }),
4162
- csError && /* @__PURE__ */ jsx10("div", { style: { marginTop: 6, fontSize: 11, color: "#dc2626" }, children: csError }),
4163
- contentSuggestions && /* @__PURE__ */ jsxs9("div", { style: { display: "flex", flexDirection: "column", gap: 14, marginTop: 8 }, children: [
4164
- contentSuggestions.keyTakeaways.length > 0 && /* @__PURE__ */ jsxs9("div", { children: [
4165
- /* @__PURE__ */ jsx10("div", { style: { fontSize: 10, fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.06em", color: AEO_PURPLE, marginBottom: 6 }, children: "Key Takeaways" }),
4166
- /* @__PURE__ */ jsx10("div", { style: { display: "flex", flexDirection: "column", gap: 6 }, children: contentSuggestions.keyTakeaways.map((kt, i) => /* @__PURE__ */ jsxs9(
4638
+ csError && /* @__PURE__ */ jsx11("div", { style: { marginTop: 6, fontSize: 11, color: "#dc2626" }, children: csError }),
4639
+ contentSuggestions && /* @__PURE__ */ jsxs10("div", { style: { display: "flex", flexDirection: "column", gap: 14, marginTop: 8 }, children: [
4640
+ contentSuggestions.keyTakeaways.length > 0 && /* @__PURE__ */ jsxs10("div", { children: [
4641
+ /* @__PURE__ */ jsx11("div", { style: { fontSize: 10, fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.06em", color: AEO_PURPLE, marginBottom: 6 }, children: "Key Takeaways" }),
4642
+ /* @__PURE__ */ jsx11("div", { style: { display: "flex", flexDirection: "column", gap: 6 }, children: contentSuggestions.keyTakeaways.map((kt, i) => /* @__PURE__ */ jsxs10(
4167
4643
  "div",
4168
4644
  {
4169
4645
  style: {
@@ -4176,19 +4652,19 @@ function AEOTab({
4176
4652
  alignItems: "flex-start"
4177
4653
  },
4178
4654
  children: [
4179
- /* @__PURE__ */ jsx10("span", { style: { fontSize: 12, color: "#1f2937", lineHeight: 1.55, flex: 1 }, children: kt }),
4180
- /* @__PURE__ */ jsxs9("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
4181
- /* @__PURE__ */ jsx10(CopyButton, { text: kt }),
4182
- /* @__PURE__ */ jsx10(FeedbackButton, { suggestionType: "aeo_takeaway", suggestionText: kt, publication })
4655
+ /* @__PURE__ */ jsx11("span", { style: { fontSize: 12, color: "#1f2937", lineHeight: 1.55, flex: 1 }, children: kt }),
4656
+ /* @__PURE__ */ jsxs10("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
4657
+ /* @__PURE__ */ jsx11(CopyButton, { text: kt }),
4658
+ /* @__PURE__ */ jsx11(FeedbackButton, { suggestionType: "aeo_takeaway", suggestionText: kt, publication })
4183
4659
  ] })
4184
4660
  ]
4185
4661
  },
4186
4662
  i
4187
4663
  )) })
4188
4664
  ] }),
4189
- contentSuggestions.infographicOpportunities.length > 0 && /* @__PURE__ */ jsxs9("div", { children: [
4190
- /* @__PURE__ */ jsx10("div", { style: { fontSize: 10, fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.06em", color: AEO_PURPLE, marginBottom: 6 }, children: "Infographic Ideas" }),
4191
- /* @__PURE__ */ jsx10("div", { style: { display: "flex", flexDirection: "column", gap: 6 }, children: contentSuggestions.infographicOpportunities.map((io, i) => /* @__PURE__ */ jsxs9(
4665
+ contentSuggestions.infographicOpportunities.length > 0 && /* @__PURE__ */ jsxs10("div", { children: [
4666
+ /* @__PURE__ */ jsx11("div", { style: { fontSize: 10, fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.06em", color: AEO_PURPLE, marginBottom: 6 }, children: "Infographic Ideas" }),
4667
+ /* @__PURE__ */ jsx11("div", { style: { display: "flex", flexDirection: "column", gap: 6 }, children: contentSuggestions.infographicOpportunities.map((io, i) => /* @__PURE__ */ jsxs10(
4192
4668
  "div",
4193
4669
  {
4194
4670
  style: {
@@ -4198,23 +4674,23 @@ function AEOTab({
4198
4674
  borderLeft: `2px solid ${AEO_PURPLE}`
4199
4675
  },
4200
4676
  children: [
4201
- /* @__PURE__ */ jsxs9("div", { style: { display: "flex", alignItems: "flex-start", justifyContent: "space-between", gap: 8 }, children: [
4202
- /* @__PURE__ */ jsx10("span", { style: { fontSize: 12, fontWeight: 700, color: AEO_PURPLE }, children: io.concept }),
4203
- /* @__PURE__ */ jsx10(FeedbackButton, { suggestionType: "aeo_infographic", suggestionText: io.concept, publication })
4677
+ /* @__PURE__ */ jsxs10("div", { style: { display: "flex", alignItems: "flex-start", justifyContent: "space-between", gap: 8 }, children: [
4678
+ /* @__PURE__ */ jsx11("span", { style: { fontSize: 12, fontWeight: 700, color: AEO_PURPLE }, children: io.concept }),
4679
+ /* @__PURE__ */ jsx11(FeedbackButton, { suggestionType: "aeo_infographic", suggestionText: io.concept, publication })
4204
4680
  ] }),
4205
- /* @__PURE__ */ jsx10("div", { style: { fontSize: 11, color: "#1f2937", lineHeight: 1.5, marginTop: 3 }, children: io.description })
4681
+ /* @__PURE__ */ jsx11("div", { style: { fontSize: 11, color: "#1f2937", lineHeight: 1.5, marginTop: 3 }, children: io.description })
4206
4682
  ]
4207
4683
  },
4208
4684
  i
4209
4685
  )) })
4210
4686
  ] }),
4211
- contentSuggestions.bulletListItems.length > 0 && /* @__PURE__ */ jsxs9("div", { children: [
4212
- /* @__PURE__ */ jsx10("div", { style: { fontSize: 10, fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.06em", color: AEO_PURPLE, marginBottom: 6 }, children: "Bullets for Featured Snippets" }),
4213
- /* @__PURE__ */ jsxs9("div", { style: { display: "flex", alignItems: "flex-start", justifyContent: "space-between", gap: 8 }, children: [
4214
- /* @__PURE__ */ jsx10("ul", { style: { margin: 0, paddingLeft: 18, flex: 1 }, children: contentSuggestions.bulletListItems.map((b, i) => /* @__PURE__ */ jsx10("li", { style: { fontSize: 12, color: "#1f2937", lineHeight: 1.55, marginBottom: 4 }, children: b }, i)) }),
4215
- /* @__PURE__ */ jsxs9("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
4216
- /* @__PURE__ */ jsx10(CopyButton, { text: contentSuggestions.bulletListItems.map((b) => "- " + b).join("\n") }),
4217
- /* @__PURE__ */ jsx10(
4687
+ contentSuggestions.bulletListItems.length > 0 && /* @__PURE__ */ jsxs10("div", { children: [
4688
+ /* @__PURE__ */ jsx11("div", { style: { fontSize: 10, fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.06em", color: AEO_PURPLE, marginBottom: 6 }, children: "Bullets for Featured Snippets" }),
4689
+ /* @__PURE__ */ jsxs10("div", { style: { display: "flex", alignItems: "flex-start", justifyContent: "space-between", gap: 8 }, children: [
4690
+ /* @__PURE__ */ jsx11("ul", { style: { margin: 0, paddingLeft: 18, flex: 1 }, children: contentSuggestions.bulletListItems.map((b, i) => /* @__PURE__ */ jsx11("li", { style: { fontSize: 12, color: "#1f2937", lineHeight: 1.55, marginBottom: 4 }, children: b }, i)) }),
4691
+ /* @__PURE__ */ jsxs10("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
4692
+ /* @__PURE__ */ jsx11(CopyButton, { text: contentSuggestions.bulletListItems.map((b) => "- " + b).join("\n") }),
4693
+ /* @__PURE__ */ jsx11(
4218
4694
  FeedbackButton,
4219
4695
  {
4220
4696
  suggestionType: "aeo_bullets",
@@ -4225,7 +4701,7 @@ function AEOTab({
4225
4701
  ] })
4226
4702
  ] })
4227
4703
  ] }),
4228
- /* @__PURE__ */ jsx10(
4704
+ /* @__PURE__ */ jsx11(
4229
4705
  "button",
4230
4706
  {
4231
4707
  onClick: loadContentSuggestions,
@@ -4255,7 +4731,7 @@ function AEOTab({
4255
4731
 
4256
4732
  // src/components/ScoreDonut.tsx
4257
4733
  import { useState as useState14 } from "react";
4258
- import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
4734
+ import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
4259
4735
  var W = { topic: 0.6, freshness: 0.25, sectionFit: 0.15 };
4260
4736
  var COLORS = { topic: MJH_BLUE, freshness: MJH_GOLD, sectionFit: "#9B59B6" };
4261
4737
  var TRACK = "#eef2f7";
@@ -4280,7 +4756,7 @@ function ScoreDonut({
4280
4756
  const topicLen = seg(cTopic);
4281
4757
  const freshLen = seg(cFresh);
4282
4758
  const sectionLen = seg(cSection);
4283
- const Slice = ({ color, fullLen, offset }) => /* @__PURE__ */ jsx11(
4759
+ const Slice = ({ color, fullLen, offset }) => /* @__PURE__ */ jsx12(
4284
4760
  "circle",
4285
4761
  {
4286
4762
  cx: size / 2,
@@ -4294,20 +4770,20 @@ function ScoreDonut({
4294
4770
  strokeDashoffset: -offset
4295
4771
  }
4296
4772
  );
4297
- return /* @__PURE__ */ jsxs10(
4773
+ return /* @__PURE__ */ jsxs11(
4298
4774
  "div",
4299
4775
  {
4300
4776
  style: { position: "relative", width: size, height: size, flexShrink: 0 },
4301
4777
  onMouseEnter: () => setHovered(true),
4302
4778
  onMouseLeave: () => setHovered(false),
4303
4779
  children: [
4304
- /* @__PURE__ */ jsxs10("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, style: { transform: "rotate(-90deg)" }, children: [
4305
- /* @__PURE__ */ jsx11("circle", { cx: size / 2, cy: size / 2, r: radius, fill: "none", stroke: TRACK, strokeWidth }),
4306
- /* @__PURE__ */ jsx11(Slice, { color: COLORS.topic, fullLen: topicLen, offset: 0 }),
4307
- /* @__PURE__ */ jsx11(Slice, { color: COLORS.freshness, fullLen: freshLen, offset: topicLen }),
4308
- /* @__PURE__ */ jsx11(Slice, { color: COLORS.sectionFit, fullLen: sectionLen, offset: topicLen + freshLen })
4780
+ /* @__PURE__ */ jsxs11("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, style: { transform: "rotate(-90deg)" }, children: [
4781
+ /* @__PURE__ */ jsx12("circle", { cx: size / 2, cy: size / 2, r: radius, fill: "none", stroke: TRACK, strokeWidth }),
4782
+ /* @__PURE__ */ jsx12(Slice, { color: COLORS.topic, fullLen: topicLen, offset: 0 }),
4783
+ /* @__PURE__ */ jsx12(Slice, { color: COLORS.freshness, fullLen: freshLen, offset: topicLen }),
4784
+ /* @__PURE__ */ jsx12(Slice, { color: COLORS.sectionFit, fullLen: sectionLen, offset: topicLen + freshLen })
4309
4785
  ] }),
4310
- /* @__PURE__ */ jsxs10(
4786
+ /* @__PURE__ */ jsxs11(
4311
4787
  "div",
4312
4788
  {
4313
4789
  style: {
@@ -4321,15 +4797,15 @@ function ScoreDonut({
4321
4797
  lineHeight: 1
4322
4798
  },
4323
4799
  children: [
4324
- /* @__PURE__ */ jsxs10("span", { style: { fontSize: Math.max(11, size / 5.5), fontWeight: 700, color: "#1f2937" }, children: [
4800
+ /* @__PURE__ */ jsxs11("span", { style: { fontSize: Math.max(11, size / 5.5), fontWeight: 700, color: "#1f2937" }, children: [
4325
4801
  compositeValue,
4326
4802
  "%"
4327
4803
  ] }),
4328
- /* @__PURE__ */ jsx11("span", { style: { fontSize: Math.max(7, size / 11), fontWeight: 700, color: "#4b5563", letterSpacing: "0.05em", marginTop: 1 }, children: "MATCH" })
4804
+ /* @__PURE__ */ jsx12("span", { style: { fontSize: Math.max(7, size / 11), fontWeight: 700, color: "#4b5563", letterSpacing: "0.05em", marginTop: 1 }, children: "MATCH" })
4329
4805
  ]
4330
4806
  }
4331
4807
  ),
4332
- hovered && /* @__PURE__ */ jsxs10(
4808
+ hovered && /* @__PURE__ */ jsxs11(
4333
4809
  "div",
4334
4810
  {
4335
4811
  role: "tooltip",
@@ -4350,9 +4826,9 @@ function ScoreDonut({
4350
4826
  pointerEvents: "none"
4351
4827
  },
4352
4828
  children: [
4353
- /* @__PURE__ */ jsx11(SubScoreRow, { color: COLORS.topic, label: "Topic", value: topic }),
4354
- /* @__PURE__ */ jsx11(SubScoreRow, { color: COLORS.freshness, label: "Freshness", value: freshness }),
4355
- /* @__PURE__ */ jsx11(SubScoreRow, { color: COLORS.sectionFit, label: "Section fit", value: sectionFit })
4829
+ /* @__PURE__ */ jsx12(SubScoreRow, { color: COLORS.topic, label: "Topic", value: topic }),
4830
+ /* @__PURE__ */ jsx12(SubScoreRow, { color: COLORS.freshness, label: "Freshness", value: freshness }),
4831
+ /* @__PURE__ */ jsx12(SubScoreRow, { color: COLORS.sectionFit, label: "Section fit", value: sectionFit })
4356
4832
  ]
4357
4833
  }
4358
4834
  )
@@ -4361,31 +4837,76 @@ function ScoreDonut({
4361
4837
  );
4362
4838
  }
4363
4839
  function SubScoreRow({ color, label, value }) {
4364
- return /* @__PURE__ */ jsxs10("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
4365
- /* @__PURE__ */ jsx11("span", { style: { width: 7, height: 7, borderRadius: "50%", background: color, display: "inline-block", flexShrink: 0 } }),
4366
- /* @__PURE__ */ jsx11("span", { style: { flex: 1 }, children: label }),
4367
- /* @__PURE__ */ jsxs10("span", { style: { fontWeight: 700, fontVariantNumeric: "tabular-nums" }, children: [
4840
+ return /* @__PURE__ */ jsxs11("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
4841
+ /* @__PURE__ */ jsx12("span", { style: { width: 7, height: 7, borderRadius: "50%", background: color, display: "inline-block", flexShrink: 0 } }),
4842
+ /* @__PURE__ */ jsx12("span", { style: { flex: 1 }, children: label }),
4843
+ /* @__PURE__ */ jsxs11("span", { style: { fontWeight: 700, fontVariantNumeric: "tabular-nums" }, children: [
4368
4844
  Math.round(value),
4369
4845
  "/100"
4370
4846
  ] })
4371
4847
  ] });
4372
4848
  }
4373
4849
  function ScoreDonutLegend() {
4374
- return /* @__PURE__ */ jsxs10("div", { style: { display: "flex", gap: 10, fontSize: 9, color: "rgba(0,0,0,0.55)", alignItems: "center", flexWrap: "wrap" }, children: [
4375
- /* @__PURE__ */ jsx11(LegendDot, { color: COLORS.topic, label: "Topic match (60% of score)" }),
4376
- /* @__PURE__ */ jsx11(LegendDot, { color: COLORS.freshness, label: "Freshness (25%)" }),
4377
- /* @__PURE__ */ jsx11(LegendDot, { color: COLORS.sectionFit, label: "Section fit (15%)" })
4850
+ return /* @__PURE__ */ jsxs11("div", { style: { display: "flex", gap: 10, fontSize: 9, color: "rgba(0,0,0,0.55)", alignItems: "center", flexWrap: "wrap" }, children: [
4851
+ /* @__PURE__ */ jsx12(LegendDot, { color: COLORS.topic, label: "Topic match (60% of score)" }),
4852
+ /* @__PURE__ */ jsx12(LegendDot, { color: COLORS.freshness, label: "Freshness (25%)" }),
4853
+ /* @__PURE__ */ jsx12(LegendDot, { color: COLORS.sectionFit, label: "Section fit (15%)" })
4378
4854
  ] });
4379
4855
  }
4380
4856
  function LegendDot({ color, label }) {
4381
- return /* @__PURE__ */ jsxs10("span", { style: { display: "inline-flex", alignItems: "center", gap: 4 }, children: [
4382
- /* @__PURE__ */ jsx11("span", { style: { width: 7, height: 7, borderRadius: "50%", background: color, display: "inline-block" } }),
4857
+ return /* @__PURE__ */ jsxs11("span", { style: { display: "inline-flex", alignItems: "center", gap: 4 }, children: [
4858
+ /* @__PURE__ */ jsx12("span", { style: { width: 7, height: 7, borderRadius: "50%", background: color, display: "inline-block" } }),
4383
4859
  label
4384
4860
  ] });
4385
4861
  }
4386
4862
 
4387
4863
  // src/components/tabs/LinkingTab.tsx
4388
- import { Fragment as Fragment5, jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
4864
+ import { Fragment as Fragment6, jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
4865
+ function buildLiveUrl(publication, slug) {
4866
+ if (!slug) return null;
4867
+ const pub = (publication || "").trim().toLowerCase();
4868
+ if (!KNOWN_MJH_PUBLICATIONS.has(pub)) return null;
4869
+ const cleanSlug = slug.replace(/^\/+/, "").split("/").map(encodeURIComponent).join("/");
4870
+ return `https://www.${pub}.com/view/${cleanSlug}`;
4871
+ }
4872
+ function buildSanityUrl(baseUrl, id, type) {
4873
+ if (!baseUrl || !id) return null;
4874
+ const cleanId = id.replace(/^drafts\./, "");
4875
+ const base = baseUrl.replace(/\/+$/, "");
4876
+ const typePart = type ? `;type=${encodeURIComponent(type)}` : "";
4877
+ return `${base}/intent/edit/id=${encodeURIComponent(cleanId)}${typePart}/`;
4878
+ }
4879
+ function LinkChip({ href, label, color }) {
4880
+ return /* @__PURE__ */ jsxs12(
4881
+ "a",
4882
+ {
4883
+ href,
4884
+ target: "_blank",
4885
+ rel: "noopener noreferrer",
4886
+ style: {
4887
+ display: "inline-flex",
4888
+ alignItems: "center",
4889
+ gap: 4,
4890
+ padding: "3px 9px",
4891
+ borderRadius: 99,
4892
+ fontSize: 10.5,
4893
+ fontWeight: 700,
4894
+ color,
4895
+ background: "rgba(255,255,255,0.7)",
4896
+ border: `1px solid ${color}33`,
4897
+ textDecoration: "none",
4898
+ lineHeight: 1.2
4899
+ },
4900
+ children: [
4901
+ label,
4902
+ /* @__PURE__ */ jsxs12("svg", { width: "9", height: "9", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: [
4903
+ /* @__PURE__ */ jsx13("path", { d: "M12.5 2a.75.75 0 000 1.5h2.44l-6.97 6.97a.75.75 0 101.06 1.06L16 4.56V7a.75.75 0 001.5 0V2.75A.75.75 0 0016.75 2H12.5z" }),
4904
+ /* @__PURE__ */ jsx13("path", { d: "M4.75 4.5A2.75 2.75 0 002 7.25v8A2.75 2.75 0 004.75 18h8A2.75 2.75 0 0015.5 15.25v-3a.75.75 0 00-1.5 0v3c0 .69-.56 1.25-1.25 1.25h-8c-.69 0-1.25-.56-1.25-1.25v-8c0-.69.56-1.25 1.25-1.25h3a.75.75 0 000-1.5h-3z" })
4905
+ ] })
4906
+ ]
4907
+ }
4908
+ );
4909
+ }
4389
4910
  var cardStyle4 = {
4390
4911
  borderRadius: 14,
4391
4912
  background: "rgba(255,255,255,0.55)",
@@ -4395,7 +4916,7 @@ var cardStyle4 = {
4395
4916
  padding: "14px"
4396
4917
  };
4397
4918
  function AiPill2() {
4398
- return /* @__PURE__ */ jsx12(
4919
+ return /* @__PURE__ */ jsx13(
4399
4920
  "span",
4400
4921
  {
4401
4922
  style: {
@@ -4419,10 +4940,10 @@ function SectionHeader3({
4419
4940
  ai,
4420
4941
  action
4421
4942
  }) {
4422
- return /* @__PURE__ */ jsxs11("div", { style: { display: "flex", alignItems: "center", gap: 7, marginBottom: 8 }, children: [
4423
- /* @__PURE__ */ jsx12("div", { style: { width: 7, height: 7, borderRadius: "50%", background: iconColor, flexShrink: 0 } }),
4424
- /* @__PURE__ */ jsx12("span", { style: { fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#4b5563", fontWeight: 600, flex: 1 }, children: label }),
4425
- ai && /* @__PURE__ */ jsx12(AiPill2, {}),
4943
+ return /* @__PURE__ */ jsxs12("div", { style: { display: "flex", alignItems: "center", gap: 7, marginBottom: 8 }, children: [
4944
+ /* @__PURE__ */ jsx13("div", { style: { width: 7, height: 7, borderRadius: "50%", background: iconColor, flexShrink: 0 } }),
4945
+ /* @__PURE__ */ jsx13("span", { style: { fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#4b5563", fontWeight: 600, flex: 1 }, children: label }),
4946
+ ai && /* @__PURE__ */ jsx13(AiPill2, {}),
4426
4947
  action
4427
4948
  ] });
4428
4949
  }
@@ -4442,7 +4963,8 @@ function freshnessChip(label, score) {
4442
4963
  "very-old": { bg: "rgba(220,38,38,0.1)", color: "#dc2626", text: "Very old" }
4443
4964
  };
4444
4965
  const c = map[label];
4445
- return /* @__PURE__ */ jsx12(
4966
+ if (!c) return null;
4967
+ return /* @__PURE__ */ jsx13(
4446
4968
  "span",
4447
4969
  {
4448
4970
  style: {
@@ -4462,8 +4984,8 @@ function freshnessChip(label, score) {
4462
4984
  );
4463
4985
  }
4464
4986
  function RefreshIcon({ spinning }) {
4465
- if (spinning) return /* @__PURE__ */ jsx12(LoadingBars, { size: "xs", color: "#9ca3af" });
4466
- return /* @__PURE__ */ jsx12("svg", { width: "12", height: "12", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx12("path", { fillRule: "evenodd", d: "M15.312 11.424a5.5 5.5 0 01-9.201 2.466l-.312-.311h2.433a.75.75 0 000-1.5H4.598a.75.75 0 00-.75.75v3.634a.75.75 0 001.5 0v-2.033l.312.311a7 7 0 0011.712-3.138.75.75 0 00-1.449-.39zm-10.624-2.85a5.5 5.5 0 019.201-2.466l.312.311h-2.433a.75.75 0 000 1.5h3.634a.75.75 0 00.75-.75V3.535a.75.75 0 00-1.5 0v2.033l-.312-.311A7 7 0 002.628 8.395a.75.75 0 001.449.39z", clipRule: "evenodd" }) });
4987
+ if (spinning) return /* @__PURE__ */ jsx13(LoadingBars, { size: "xs", color: "#9ca3af" });
4988
+ return /* @__PURE__ */ jsx13("svg", { width: "12", height: "12", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx13("path", { fillRule: "evenodd", d: "M15.312 11.424a5.5 5.5 0 01-9.201 2.466l-.312-.311h2.433a.75.75 0 000-1.5H4.598a.75.75 0 00-.75.75v3.634a.75.75 0 001.5 0v-2.033l.312.311a7 7 0 0011.712-3.138.75.75 0 00-1.449-.39zm-10.624-2.85a5.5 5.5 0 019.201-2.466l.312.311h-2.433a.75.75 0 000 1.5h3.634a.75.75 0 00.75-.75V3.535a.75.75 0 00-1.5 0v2.033l-.312-.311A7 7 0 002.628 8.395a.75.75 0 001.449.39z", clipRule: "evenodd" }) });
4467
4989
  }
4468
4990
  function LinkingTab({
4469
4991
  analysis,
@@ -4474,24 +4996,26 @@ function LinkingTab({
4474
4996
  onRefresh,
4475
4997
  text,
4476
4998
  documentId,
4477
- publication
4999
+ publication,
5000
+ sanityBaseUrl,
5001
+ documentType
4478
5002
  }) {
4479
5003
  if (!analysis) {
4480
- return /* @__PURE__ */ jsxs11("div", { style: { padding: 24, textAlign: "center" }, children: [
4481
- /* @__PURE__ */ jsx12("div", { style: { fontSize: 13, color: "#4b5563", fontWeight: 500 }, children: "Run keyword analysis first" }),
4482
- /* @__PURE__ */ jsx12("div", { style: { fontSize: 11, color: "#4b5563", marginTop: 4 }, children: "Internal link suggestions need keywords to start from" })
5004
+ return /* @__PURE__ */ jsxs12("div", { style: { padding: 24, textAlign: "center" }, children: [
5005
+ /* @__PURE__ */ jsx13("div", { style: { fontSize: 13, color: "#4b5563", fontWeight: 500 }, children: "Waiting for keyword analysis" }),
5006
+ /* @__PURE__ */ jsx13("div", { style: { fontSize: 11, color: "#4b5563", marginTop: 4 }, children: "Linking reads the article keywords and topic to find related published articles. It starts on its own once the Keywords tab finishes." })
4483
5007
  ] });
4484
5008
  }
4485
5009
  const wordCount2 = text ? text.split(/\s+/).filter(Boolean).length : 0;
4486
5010
  const recommendedMin = Math.max(1, Math.round(wordCount2 / 1e3 * 2));
4487
5011
  const recommendedMax = Math.max(2, Math.round(wordCount2 / 1e3 * 5));
4488
- return /* @__PURE__ */ jsx12("div", { style: { padding: 12, display: "flex", flexDirection: "column", gap: 12 }, children: /* @__PURE__ */ jsxs11("div", { id: "anchor-linking-suggestions", style: cardStyle4, children: [
4489
- /* @__PURE__ */ jsx12(
5012
+ return /* @__PURE__ */ jsx13("div", { style: { padding: 12, display: "flex", flexDirection: "column", gap: 12 }, children: /* @__PURE__ */ jsxs12("div", { id: "anchor-linking-suggestions", style: cardStyle4, children: [
5013
+ /* @__PURE__ */ jsx13(
4490
5014
  SectionHeader3,
4491
5015
  {
4492
5016
  label: "Suggested Links",
4493
5017
  iconColor: MJH_BLUE,
4494
- action: /* @__PURE__ */ jsx12(
5018
+ action: /* @__PURE__ */ jsx13(
4495
5019
  "button",
4496
5020
  {
4497
5021
  onClick: onRefresh,
@@ -4506,20 +5030,20 @@ function LinkingTab({
4506
5030
  fontSize: 10
4507
5031
  },
4508
5032
  title: "Refresh",
4509
- children: /* @__PURE__ */ jsx12(RefreshIcon, { spinning: isLoading })
5033
+ children: /* @__PURE__ */ jsx13(RefreshIcon, { spinning: isLoading })
4510
5034
  }
4511
5035
  )
4512
5036
  }
4513
5037
  ),
4514
- /* @__PURE__ */ jsxs11("div", { style: { fontSize: 11, color: "#1f2937", marginBottom: 8, lineHeight: 1.55 }, children: [
5038
+ /* @__PURE__ */ jsxs12("div", { style: { fontSize: 11, color: "#1f2937", marginBottom: 8, lineHeight: 1.55 }, children: [
4515
5039
  "Other articles on this site that fit this topic.",
4516
- wordCount2 > 0 && /* @__PURE__ */ jsxs11(Fragment5, { children: [
5040
+ wordCount2 > 0 && /* @__PURE__ */ jsxs12(Fragment6, { children: [
4517
5041
  " ",
4518
5042
  "For a ",
4519
5043
  wordCount2.toLocaleString(),
4520
5044
  "-word article, aim for",
4521
5045
  " ",
4522
- /* @__PURE__ */ jsxs11("strong", { children: [
5046
+ /* @__PURE__ */ jsxs12("strong", { children: [
4523
5047
  recommendedMin,
4524
5048
  "-",
4525
5049
  recommendedMax,
@@ -4528,20 +5052,28 @@ function LinkingTab({
4528
5052
  "."
4529
5053
  ] })
4530
5054
  ] }),
4531
- /* @__PURE__ */ jsxs11("div", { style: { fontSize: 10, color: "#4b5563", marginBottom: 6, lineHeight: 1.5 }, children: [
5055
+ /* @__PURE__ */ jsxs12("div", { style: { fontSize: 10, color: "#4b5563", marginBottom: 6, lineHeight: 1.5 }, children: [
4532
5056
  "Each suggestion gets a 0-100% match score from three signals - ",
4533
- /* @__PURE__ */ jsx12("strong", { children: "topic match" }),
5057
+ /* @__PURE__ */ jsx13("strong", { children: "topic match" }),
4534
5058
  ", ",
4535
- /* @__PURE__ */ jsx12("strong", { children: "freshness" }),
5059
+ /* @__PURE__ */ jsx13("strong", { children: "freshness" }),
4536
5060
  ", and ",
4537
- /* @__PURE__ */ jsx12("strong", { children: "section fit" }),
5061
+ /* @__PURE__ */ jsx13("strong", { children: "section fit" }),
4538
5062
  " (where in your article the link belongs). The percentage on each card is the weighted total:"
4539
5063
  ] }),
4540
- /* @__PURE__ */ jsx12("div", { style: { marginBottom: 10 }, children: /* @__PURE__ */ jsx12(ScoreDonutLegend, {}) }),
4541
- isStale && suggestions.length > 0 && !isLoading && /* @__PURE__ */ jsxs11(
5064
+ /* @__PURE__ */ jsx13("div", { style: { marginBottom: 10 }, children: /* @__PURE__ */ jsx13(ScoreDonutLegend, {}) }),
5065
+ isStale && suggestions.length > 0 && !isLoading && /* @__PURE__ */ jsxs12(
4542
5066
  "div",
4543
5067
  {
5068
+ role: "button",
5069
+ tabIndex: 0,
4544
5070
  onClick: onRefresh,
5071
+ onKeyDown: (e) => {
5072
+ if (e.key === "Enter" || e.key === " ") {
5073
+ e.preventDefault();
5074
+ onRefresh();
5075
+ }
5076
+ },
4545
5077
  style: {
4546
5078
  display: "flex",
4547
5079
  alignItems: "center",
@@ -4555,16 +5087,16 @@ function LinkingTab({
4555
5087
  cursor: "pointer"
4556
5088
  },
4557
5089
  children: [
4558
- /* @__PURE__ */ jsx12("span", { style: { fontSize: 11, color: "#92400e" }, children: "Your article changed since these were generated." }),
4559
- /* @__PURE__ */ jsx12("span", { style: { fontSize: 11, fontWeight: 700, color: "#8B7310", textDecoration: "underline", flexShrink: 0 }, children: "Refresh" })
5090
+ /* @__PURE__ */ jsx13("span", { style: { fontSize: 11, color: "#92400e" }, children: "Your article changed since these were generated." }),
5091
+ /* @__PURE__ */ jsx13("span", { style: { fontSize: 11, fontWeight: 700, color: "#8B7310", textDecoration: "underline", flexShrink: 0 }, children: "Refresh" })
4560
5092
  ]
4561
5093
  }
4562
5094
  ),
4563
- isLoading && suggestions.length === 0 && /* @__PURE__ */ jsxs11("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", gap: 8, padding: "16px 0" }, children: [
4564
- /* @__PURE__ */ jsx12(LoadingBars, { size: "xs", color: MJH_BLUE }),
4565
- /* @__PURE__ */ jsx12("span", { style: { fontSize: 11, color: "#4b5563" }, children: "Ranking candidates..." })
5095
+ isLoading && suggestions.length === 0 && /* @__PURE__ */ jsxs12("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", gap: 8, padding: "16px 0" }, children: [
5096
+ /* @__PURE__ */ jsx13(LoadingBars, { size: "xs", color: MJH_BLUE }),
5097
+ /* @__PURE__ */ jsx13("span", { style: { fontSize: 11, color: "#4b5563" }, children: "Ranking candidates..." })
4566
5098
  ] }),
4567
- !isLoading && error && /* @__PURE__ */ jsxs11(
5099
+ !isLoading && error && /* @__PURE__ */ jsxs12(
4568
5100
  "div",
4569
5101
  {
4570
5102
  style: {
@@ -4575,9 +5107,9 @@ function LinkingTab({
4575
5107
  textAlign: "center"
4576
5108
  },
4577
5109
  children: [
4578
- /* @__PURE__ */ jsx12("div", { style: { fontSize: 11.5, color: "#b91c1c", fontWeight: 600, marginBottom: 2 }, children: "Couldn't load suggestions" }),
4579
- /* @__PURE__ */ jsx12("div", { style: { fontSize: 10.5, color: "#4b5563", marginBottom: 8 }, children: error }),
4580
- /* @__PURE__ */ jsx12(
5110
+ /* @__PURE__ */ jsx13("div", { style: { fontSize: 11.5, color: "#b91c1c", fontWeight: 600, marginBottom: 2 }, children: "Couldn't load suggestions" }),
5111
+ /* @__PURE__ */ jsx13("div", { style: { fontSize: 10.5, color: "#4b5563", marginBottom: 8 }, children: error }),
5112
+ /* @__PURE__ */ jsx13(
4581
5113
  "button",
4582
5114
  {
4583
5115
  onClick: onRefresh,
@@ -4597,11 +5129,11 @@ function LinkingTab({
4597
5129
  ]
4598
5130
  }
4599
5131
  ),
4600
- !isLoading && !error && suggestions.length === 0 && /* @__PURE__ */ jsxs11("div", { style: { fontSize: 11, color: "#1f2937", padding: "10px 12px", lineHeight: 1.55, background: "rgba(0,93,172,0.04)", borderRadius: 8, border: "1px solid rgba(0,93,172,0.12)" }, children: [
4601
- /* @__PURE__ */ jsx12("div", { style: { fontWeight: 700, marginBottom: 4, color: "#1f2937" }, children: "No related articles found yet." }),
4602
- /* @__PURE__ */ jsx12("div", { style: { color: "#4b5563" }, children: "Linking suggests published articles on closely related topics. As more related content is published, matches will appear here." })
5132
+ !isLoading && !error && suggestions.length === 0 && /* @__PURE__ */ jsxs12("div", { style: { fontSize: 11, color: "#1f2937", padding: "10px 12px", lineHeight: 1.55, background: "rgba(0,93,172,0.04)", borderRadius: 8, border: "1px solid rgba(0,93,172,0.12)" }, children: [
5133
+ /* @__PURE__ */ jsx13("div", { style: { fontWeight: 700, marginBottom: 4, color: "#1f2937" }, children: "No closely related articles found." }),
5134
+ /* @__PURE__ */ jsx13("div", { style: { color: "#4b5563" }, children: "Linking searched your publication for articles on this topic and did not find a strong match. As more related content is published, suggestions will appear here." })
4603
5135
  ] }),
4604
- suggestions.length > 0 && /* @__PURE__ */ jsx12("div", { style: { display: "flex", flexDirection: "column", gap: 10 }, children: suggestions.map((s) => /* @__PURE__ */ jsxs11(
5136
+ suggestions.length > 0 && /* @__PURE__ */ jsx13("div", { style: { display: "flex", flexDirection: "column", gap: 10 }, children: suggestions.map((s) => /* @__PURE__ */ jsxs12(
4605
5137
  "div",
4606
5138
  {
4607
5139
  style: {
@@ -4614,32 +5146,41 @@ function LinkingTab({
4614
5146
  alignItems: "flex-start"
4615
5147
  },
4616
5148
  children: [
4617
- /* @__PURE__ */ jsx12(
5149
+ /* @__PURE__ */ jsx13(
4618
5150
  ScoreDonut,
4619
5151
  {
4620
5152
  size: 64,
4621
- topic: s.topicScore,
4622
- freshness: s.freshnessScore,
4623
- sectionFit: s.sectionFitScore,
4624
- composite: s.compositeScore
5153
+ topic: Math.max(0, Math.min(100, s.topicScore)),
5154
+ freshness: Math.max(0, Math.min(100, s.freshnessScore)),
5155
+ sectionFit: Math.max(0, Math.min(100, s.sectionFitScore)),
5156
+ composite: Math.max(0, Math.min(100, s.compositeScore))
4625
5157
  }
4626
5158
  ),
4627
- /* @__PURE__ */ jsxs11("div", { style: { flex: 1, minWidth: 0 }, children: [
4628
- /* @__PURE__ */ jsxs11("div", { style: { display: "flex", alignItems: "center", gap: 6, marginBottom: 3, flexWrap: "wrap" }, children: [
5159
+ /* @__PURE__ */ jsxs12("div", { style: { flex: 1, minWidth: 0 }, children: [
5160
+ /* @__PURE__ */ jsxs12("div", { style: { display: "flex", alignItems: "center", gap: 6, marginBottom: 3, flexWrap: "wrap" }, children: [
4629
5161
  freshnessChip(s.freshnessLabel, s.freshnessScore),
4630
- s.publishedAt && /* @__PURE__ */ jsx12("span", { style: { fontSize: 10, color: "#4b5563" }, children: formatDate(s.publishedAt) })
5162
+ s.publishedAt && /* @__PURE__ */ jsx13("span", { style: { fontSize: 10, color: "#4b5563" }, children: formatDate(s.publishedAt) })
4631
5163
  ] }),
4632
- /* @__PURE__ */ jsx12("div", { style: { fontSize: 12, fontWeight: 700, color: "#1f2937", lineHeight: 1.4, marginBottom: 2 }, children: s.title }),
4633
- /* @__PURE__ */ jsxs11("div", { style: { fontSize: 10, color: "#4b5563", fontFamily: "ui-monospace, SFMono-Regular, monospace", marginBottom: 6 }, children: [
5164
+ /* @__PURE__ */ jsx13("div", { style: { fontSize: 12, fontWeight: 700, color: "#1f2937", lineHeight: 1.4, marginBottom: 2 }, children: s.title }),
5165
+ /* @__PURE__ */ jsxs12("div", { style: { fontSize: 10, color: "#4b5563", fontFamily: "ui-monospace, SFMono-Regular, monospace", marginBottom: 6 }, children: [
4634
5166
  "/",
4635
5167
  s.slug
4636
5168
  ] }),
4637
- s.relevanceReason && /* @__PURE__ */ jsxs11("div", { style: { fontSize: 11, color: "#1f2937", marginBottom: 6, lineHeight: 1.45 }, children: [
4638
- /* @__PURE__ */ jsx12("span", { style: { fontWeight: 700, color: "#4b5563" }, children: "Why it fits:" }),
5169
+ (() => {
5170
+ const liveUrl = buildLiveUrl(publication, s.slug);
5171
+ const sanityUrl = buildSanityUrl(sanityBaseUrl, s._id);
5172
+ if (!liveUrl && !sanityUrl) return null;
5173
+ return /* @__PURE__ */ jsxs12("div", { style: { display: "flex", flexWrap: "wrap", gap: 6, marginBottom: 6 }, children: [
5174
+ sanityUrl && /* @__PURE__ */ jsx13(LinkChip, { href: sanityUrl, label: "Inside Sanity", color: MJH_BLUE }),
5175
+ liveUrl && /* @__PURE__ */ jsx13(LinkChip, { href: liveUrl, label: "Live site", color: "#4b5563" })
5176
+ ] });
5177
+ })(),
5178
+ s.relevanceReason && /* @__PURE__ */ jsxs12("div", { style: { fontSize: 11, color: "#1f2937", marginBottom: 6, lineHeight: 1.45 }, children: [
5179
+ /* @__PURE__ */ jsx13("span", { style: { fontWeight: 700, color: "#4b5563" }, children: "Why it fits:" }),
4639
5180
  " ",
4640
- /* @__PURE__ */ jsx12("span", { style: { fontStyle: "italic" }, children: s.relevanceReason })
5181
+ /* @__PURE__ */ jsx13("span", { style: { fontStyle: "italic" }, children: s.relevanceReason })
4641
5182
  ] }),
4642
- s.anchorQuote && /* @__PURE__ */ jsxs11(
5183
+ s.anchorQuote && /* @__PURE__ */ jsxs12(
4643
5184
  "div",
4644
5185
  {
4645
5186
  style: {
@@ -4653,21 +5194,21 @@ function LinkingTab({
4653
5194
  lineHeight: 1.5
4654
5195
  },
4655
5196
  children: [
4656
- /* @__PURE__ */ jsxs11("div", { style: { fontSize: 9, fontWeight: 700, color: "#4b5563", textTransform: "uppercase", letterSpacing: "0.05em", marginBottom: 3 }, children: [
5197
+ /* @__PURE__ */ jsxs12("div", { style: { fontSize: 9, fontWeight: 700, color: "#4b5563", textTransform: "uppercase", letterSpacing: "0.05em", marginBottom: 3 }, children: [
4657
5198
  "Where to link from - paragraph ",
4658
5199
  s.anchorParagraph
4659
5200
  ] }),
4660
- /* @__PURE__ */ jsxs11("div", { style: { fontStyle: "italic" }, children: [
5201
+ /* @__PURE__ */ jsxs12("div", { style: { fontStyle: "italic" }, children: [
4661
5202
  '"',
4662
5203
  s.anchorQuote,
4663
5204
  '"'
4664
5205
  ] }),
4665
- s.anchorReason && /* @__PURE__ */ jsx12("div", { style: { fontSize: 10, color: "#4b5563", marginTop: 3, lineHeight: 1.45 }, children: s.anchorReason })
5206
+ s.anchorReason && /* @__PURE__ */ jsx13("div", { style: { fontSize: 10, color: "#4b5563", marginTop: 3, lineHeight: 1.45 }, children: s.anchorReason })
4666
5207
  ]
4667
5208
  }
4668
5209
  )
4669
5210
  ] }),
4670
- /* @__PURE__ */ jsx12("div", { style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx12(
5211
+ /* @__PURE__ */ jsx13("div", { style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx13(
4671
5212
  FeedbackButton,
4672
5213
  {
4673
5214
  suggestionType: "internal_link",
@@ -4684,15 +5225,8 @@ function LinkingTab({
4684
5225
  }
4685
5226
 
4686
5227
  // src/components/tabs/MetaTab.tsx
4687
- import { useMemo as useMemo3, useState as useState15 } from "react";
4688
- import { Fragment as Fragment6, jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
4689
- function containsKeywordTokens(haystack, needle) {
4690
- if (!needle) return true;
4691
- const tokens = needle.toLowerCase().split(/\s+/).filter((t) => t.length > 1);
4692
- if (tokens.length === 0) return true;
4693
- const lower = haystack.toLowerCase();
4694
- return tokens.every((t) => lower.includes(t));
4695
- }
5228
+ import { useMemo as useMemo3 } from "react";
5229
+ import { Fragment as Fragment7, jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
4696
5230
  var cardStyle5 = {
4697
5231
  borderRadius: 14,
4698
5232
  background: "rgba(255,255,255,0.55)",
@@ -4708,7 +5242,7 @@ function StatusBadge({ status }) {
4708
5242
  error: { bg: "rgba(220,38,38,0.1)", color: "#dc2626", label: "Fix" }
4709
5243
  };
4710
5244
  const c = map[status];
4711
- return /* @__PURE__ */ jsx13(
5245
+ return /* @__PURE__ */ jsx14(
4712
5246
  "span",
4713
5247
  {
4714
5248
  style: {
@@ -4727,12 +5261,12 @@ function StatusBadge({ status }) {
4727
5261
  );
4728
5262
  }
4729
5263
  function AuditCard({ label, value, status, recommendation, anchorId, footer }) {
4730
- return /* @__PURE__ */ jsxs12("div", { id: anchorId, style: cardStyle5, children: [
4731
- /* @__PURE__ */ jsxs12("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, marginBottom: 6 }, children: [
4732
- /* @__PURE__ */ jsx13("span", { style: { fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#4b5563", fontWeight: 600 }, children: label }),
4733
- /* @__PURE__ */ jsx13(StatusBadge, { status })
5264
+ return /* @__PURE__ */ jsxs13("div", { id: anchorId, style: cardStyle5, children: [
5265
+ /* @__PURE__ */ jsxs13("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, marginBottom: 6 }, children: [
5266
+ /* @__PURE__ */ jsx14("span", { style: { fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#4b5563", fontWeight: 600 }, children: label }),
5267
+ /* @__PURE__ */ jsx14(StatusBadge, { status })
4734
5268
  ] }),
4735
- /* @__PURE__ */ jsx13(
5269
+ /* @__PURE__ */ jsx14(
4736
5270
  "div",
4737
5271
  {
4738
5272
  style: {
@@ -4745,7 +5279,7 @@ function AuditCard({ label, value, status, recommendation, anchorId, footer }) {
4745
5279
  children: value
4746
5280
  }
4747
5281
  ),
4748
- recommendation && /* @__PURE__ */ jsx13(
5282
+ recommendation && /* @__PURE__ */ jsx14(
4749
5283
  "div",
4750
5284
  {
4751
5285
  style: {
@@ -4764,23 +5298,37 @@ function AuditCard({ label, value, status, recommendation, anchorId, footer }) {
4764
5298
  footer
4765
5299
  ] });
4766
5300
  }
4767
- function metaDescriptionAudit(meta, primaryKeyword) {
5301
+ function keywordCoverageNote(haystack, primaryKeyword, secondaryKeyword) {
5302
+ const hasPrimary = primaryKeyword ? containsKeywordTokens(haystack, primaryKeyword) : true;
5303
+ const hasSecondary = secondaryKeyword ? containsKeywordTokens(haystack, secondaryKeyword) : true;
5304
+ if (primaryKeyword && !hasPrimary && secondaryKeyword && !hasSecondary) {
5305
+ return `Neither your primary keyword "${primaryKeyword}" nor your secondary keyword "${secondaryKeyword}" appears here.`;
5306
+ }
5307
+ if (primaryKeyword && !hasPrimary) {
5308
+ return `Your primary keyword "${primaryKeyword}" isn't included${secondaryKeyword ? ` (secondary keyword "${secondaryKeyword}" ${hasSecondary ? "is" : "isn't"}).` : "."}`;
5309
+ }
5310
+ if (secondaryKeyword && !hasSecondary) {
5311
+ return `Your secondary keyword "${secondaryKeyword}" isn't included${primaryKeyword && hasPrimary ? ` (primary keyword "${primaryKeyword}" is present)` : ""}. Work it in if it reads naturally.`;
5312
+ }
5313
+ return "";
5314
+ }
5315
+ function metaDescriptionAudit(meta, primaryKeyword, secondaryKeyword) {
4768
5316
  if (!meta) {
4769
5317
  return {
4770
5318
  label: "Meta Description",
4771
5319
  value: "Missing",
4772
5320
  status: "error",
4773
- recommendation: "Add a 120-160 character meta description that includes your primary keyword."
5321
+ recommendation: `Add a 120-160 character meta description that includes your primary keyword${secondaryKeyword ? " (and your secondary keyword if it fits)" : ""}.`
4774
5322
  };
4775
5323
  }
4776
5324
  const len = meta.length;
4777
- const lacksKeyword = primaryKeyword && !containsKeywordTokens(meta, primaryKeyword);
5325
+ const kwNote = keywordCoverageNote(meta, primaryKeyword, secondaryKeyword);
4778
5326
  if (len < 120) {
4779
5327
  return {
4780
5328
  label: "Meta Description",
4781
5329
  value: `${meta} (${len} chars)`,
4782
5330
  status: "warning",
4783
- recommendation: `Too short - aim for 120-160 characters.${lacksKeyword ? ` Also missing primary keyword "${primaryKeyword}".` : ""}`
5331
+ recommendation: `A little short - aim for 120-160 characters.${kwNote ? ` ${kwNote}` : ""}`
4784
5332
  };
4785
5333
  }
4786
5334
  if (len > 160) {
@@ -4788,15 +5336,15 @@ function metaDescriptionAudit(meta, primaryKeyword) {
4788
5336
  label: "Meta Description",
4789
5337
  value: `${meta} (${len} chars)`,
4790
5338
  status: "warning",
4791
- recommendation: `Too long - Google may truncate beyond 160 characters.${lacksKeyword ? ` Also missing primary keyword "${primaryKeyword}".` : ""}`
5339
+ recommendation: `Over 160 characters - Google may shorten it in search, so trim it a little.${kwNote ? ` ${kwNote}` : ""}`
4792
5340
  };
4793
5341
  }
4794
- if (lacksKeyword) {
5342
+ if (kwNote) {
4795
5343
  return {
4796
5344
  label: "Meta Description",
4797
5345
  value: `${meta} (${len} chars)`,
4798
5346
  status: "warning",
4799
- recommendation: `Length is good but primary keyword "${primaryKeyword}" is not included.`
5347
+ recommendation: `Length is good. ${kwNote}`
4800
5348
  };
4801
5349
  }
4802
5350
  return {
@@ -4844,88 +5392,6 @@ function titleAudit(title, primaryKeyword) {
4844
5392
  }
4845
5393
  return { label: "Title Tag", value: `${title} (${len} chars)`, status: "good" };
4846
5394
  }
4847
- function urlAudit(slug, primaryKeyword) {
4848
- if (!slug) {
4849
- return { label: "URL Slug", value: "Missing", status: "error", recommendation: "Add a clean, hyphenated URL slug containing the primary keyword. Aim for 3-5 words." };
4850
- }
4851
- const issues = [];
4852
- if (slug.length > 60) issues.push("longer than 60 characters - aim for 3-5 words");
4853
- if (/[A-Z]/.test(slug)) issues.push("contains uppercase letters");
4854
- if (/_/.test(slug)) issues.push("uses underscores instead of hyphens");
4855
- if (/[^a-zA-Z0-9-/]/.test(slug.replace(/^\//, ""))) issues.push("contains special characters");
4856
- if (primaryKeyword && !containsKeywordTokens(slug.replace(/-/g, " "), primaryKeyword)) {
4857
- issues.push(`missing primary keyword "${primaryKeyword}"`);
4858
- }
4859
- if (issues.length === 0) {
4860
- return { label: "URL Slug", value: `/${slug}`, status: "good" };
4861
- }
4862
- return {
4863
- label: "URL Slug",
4864
- value: `/${slug}`,
4865
- status: "warning",
4866
- recommendation: `Issues: ${issues.join(", ")}.`
4867
- };
4868
- }
4869
- function SlugRedirectNotice() {
4870
- const [expanded, setExpanded] = useState15(false);
4871
- return /* @__PURE__ */ jsx13(
4872
- "div",
4873
- {
4874
- style: {
4875
- marginTop: 10,
4876
- paddingTop: 10,
4877
- borderTop: "1px solid rgba(0,0,0,0.07)"
4878
- },
4879
- children: /* @__PURE__ */ jsxs12(
4880
- "div",
4881
- {
4882
- style: {
4883
- padding: "8px 10px",
4884
- background: "rgba(245,158,11,0.08)",
4885
- borderLeft: "2px solid #f59e0b",
4886
- borderRadius: 6
4887
- },
4888
- children: [
4889
- /* @__PURE__ */ jsxs12("div", { style: { display: "flex", alignItems: "center", gap: 6, marginBottom: 4 }, children: [
4890
- /* @__PURE__ */ jsx13("svg", { width: "12", height: "12", viewBox: "0 0 20 20", fill: "#f59e0b", "aria-hidden": "true", children: /* @__PURE__ */ jsx13("path", { fillRule: "evenodd", d: "M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z", clipRule: "evenodd" }) }),
4891
- /* @__PURE__ */ jsx13("span", { style: { fontSize: 10.5, fontWeight: 700, color: "#b45309", textTransform: "uppercase", letterSpacing: "0.06em" }, children: "Changing a URL?" })
4892
- ] }),
4893
- /* @__PURE__ */ jsx13("div", { style: { fontSize: 11, color: "#1f2937", lineHeight: 1.55 }, children: "If the page has been published and indexed, you MUST add a 301 redirect from the old slug to the new one before changing it. For a brand-new page that's never been published, no redirect needed." }),
4894
- /* @__PURE__ */ jsxs12(
4895
- "button",
4896
- {
4897
- onClick: () => setExpanded((v) => !v),
4898
- style: {
4899
- display: "flex",
4900
- alignItems: "center",
4901
- gap: 3,
4902
- marginTop: 6,
4903
- padding: 0,
4904
- background: "none",
4905
- border: "none",
4906
- cursor: "pointer",
4907
- fontSize: 10.5,
4908
- fontWeight: 700,
4909
- color: "#b45309",
4910
- fontFamily: "inherit"
4911
- },
4912
- children: [
4913
- expanded ? "Show less" : "Learn more",
4914
- /* @__PURE__ */ jsx13("svg", { width: "10", height: "10", viewBox: "0 0 20 20", fill: "currentColor", style: { transform: expanded ? "rotate(180deg)" : "none", transition: "transform 150ms" }, children: /* @__PURE__ */ jsx13("path", { fillRule: "evenodd", d: "M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z", clipRule: "evenodd" }) })
4915
- ]
4916
- }
4917
- ),
4918
- expanded && /* @__PURE__ */ jsxs12("ul", { style: { margin: "6px 0 0", paddingLeft: 16, fontSize: 11, color: "#1f2937", lineHeight: 1.55 }, children: [
4919
- /* @__PURE__ */ jsx13("li", { children: "Without the 301, the page loses every search ranking and every external link to it breaks." }),
4920
- /* @__PURE__ */ jsx13("li", { children: "A 301 preserves the rankings and link equity built up on the old URL." }),
4921
- /* @__PURE__ */ jsx13("li", { children: "Set this up using vanity redirects in Sanity." })
4922
- ] })
4923
- ]
4924
- }
4925
- )
4926
- }
4927
- );
4928
- }
4929
5395
  function daysSince(iso) {
4930
5396
  if (!iso) return null;
4931
5397
  const t = new Date(iso).getTime();
@@ -4938,14 +5404,13 @@ function formatDateShort(iso) {
4938
5404
  if (isNaN(d.getTime())) return "";
4939
5405
  return d.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "numeric" });
4940
5406
  }
4941
- function MetaTab({ documentFields, primaryKeyword, isLoading }) {
5407
+ function MetaTab({ documentFields, primaryKeyword, secondaryKeyword, isLoading }) {
4942
5408
  const audits = useMemo3(() => {
4943
5409
  const list = [];
4944
5410
  list.push(titleAudit(documentFields?.title, primaryKeyword));
4945
- list.push(metaDescriptionAudit(documentFields?.metaDescription, primaryKeyword));
4946
- list.push(urlAudit(documentFields?.slug, primaryKeyword));
5411
+ list.push(metaDescriptionAudit(documentFields?.metaDescription, primaryKeyword, secondaryKeyword));
4947
5412
  return list;
4948
- }, [documentFields, primaryKeyword]);
5413
+ }, [documentFields, primaryKeyword, secondaryKeyword]);
4949
5414
  const eeatItems = useMemo3(() => {
4950
5415
  const items = [];
4951
5416
  const author = documentFields?.authorName;
@@ -4990,33 +5455,32 @@ function MetaTab({ documentFields, primaryKeyword, isLoading }) {
4990
5455
  }, [documentFields]);
4991
5456
  const hasAnyField = !!documentFields && (documentFields.title !== void 0 || documentFields.metaDescription !== void 0 || documentFields.slug !== void 0);
4992
5457
  if (isLoading && !hasAnyField) {
4993
- return /* @__PURE__ */ jsxs12("div", { style: { padding: 24, textAlign: "center" }, children: [
4994
- /* @__PURE__ */ jsx13("div", { style: { fontSize: 13, color: "#4b5563", fontWeight: 500 }, children: "Reading document fields..." }),
4995
- /* @__PURE__ */ jsx13("div", { style: { fontSize: 11, color: "#4b5563", marginTop: 4 }, children: "Audit will run once content loads" })
5458
+ return /* @__PURE__ */ jsxs13("div", { style: { padding: 24, textAlign: "center" }, children: [
5459
+ /* @__PURE__ */ jsx14("div", { style: { fontSize: 13, color: "#4b5563", fontWeight: 500 }, children: "Reading document fields..." }),
5460
+ /* @__PURE__ */ jsx14("div", { style: { fontSize: 11, color: "#4b5563", marginTop: 4 }, children: "Audit will run once content loads" })
4996
5461
  ] });
4997
5462
  }
4998
- const auditAnchors = ["anchor-meta-title", "anchor-meta-description", "anchor-url-slug"];
4999
- return /* @__PURE__ */ jsxs12("div", { style: { padding: 12, display: "flex", flexDirection: "column", gap: 10 }, children: [
5000
- audits.map((a, i) => /* @__PURE__ */ jsx13(
5463
+ const auditAnchors = ["anchor-meta-title", "anchor-meta-description"];
5464
+ return /* @__PURE__ */ jsxs13("div", { style: { padding: 12, display: "flex", flexDirection: "column", gap: 10 }, children: [
5465
+ audits.map((a, i) => /* @__PURE__ */ jsx14(
5001
5466
  AuditCard,
5002
5467
  {
5003
5468
  anchorId: auditAnchors[i],
5004
5469
  label: a.label,
5005
5470
  value: a.value,
5006
5471
  status: a.status,
5007
- recommendation: a.recommendation,
5008
- footer: a.label === "URL Slug" ? /* @__PURE__ */ jsx13(SlugRedirectNotice, {}) : void 0
5472
+ recommendation: a.recommendation
5009
5473
  },
5010
5474
  i
5011
5475
  )),
5012
- eeatItems.length > 0 && /* @__PURE__ */ jsxs12(Fragment6, { children: [
5013
- /* @__PURE__ */ jsxs12("div", { style: { display: "flex", alignItems: "center", gap: 8, margin: "6px 4px 0" }, children: [
5014
- /* @__PURE__ */ jsx13("div", { style: { height: 1, flex: 1, background: "rgba(0,0,0,0.06)" } }),
5015
- /* @__PURE__ */ jsx13("span", { style: { fontSize: 10, fontWeight: 700, color: "#4b5563", textTransform: "uppercase", letterSpacing: "0.08em" }, children: "Author & Freshness" }),
5016
- /* @__PURE__ */ jsx13("div", { style: { height: 1, flex: 1, background: "rgba(0,0,0,0.06)" } })
5476
+ eeatItems.length > 0 && /* @__PURE__ */ jsxs13(Fragment7, { children: [
5477
+ /* @__PURE__ */ jsxs13("div", { style: { display: "flex", alignItems: "center", gap: 8, margin: "6px 4px 0" }, children: [
5478
+ /* @__PURE__ */ jsx14("div", { style: { height: 1, flex: 1, background: "rgba(0,0,0,0.06)" } }),
5479
+ /* @__PURE__ */ jsx14("span", { style: { fontSize: 10, fontWeight: 700, color: "#4b5563", textTransform: "uppercase", letterSpacing: "0.08em" }, children: "Author & Freshness" }),
5480
+ /* @__PURE__ */ jsx14("div", { style: { height: 1, flex: 1, background: "rgba(0,0,0,0.06)" } })
5017
5481
  ] }),
5018
- /* @__PURE__ */ jsx13("div", { style: { fontSize: 10, color: "#4b5563", padding: "0 4px", marginTop: -4 }, children: "Google looks for a named author with credentials and recent updates on healthcare content." }),
5019
- eeatItems.map((item, i) => /* @__PURE__ */ jsx13(
5482
+ /* @__PURE__ */ jsx14("div", { style: { fontSize: 10, color: "#4b5563", padding: "0 4px", marginTop: -4 }, children: "Google looks for a named author with credentials and recent updates on healthcare content." }),
5483
+ eeatItems.map((item, i) => /* @__PURE__ */ jsx14(
5020
5484
  AuditCard,
5021
5485
  {
5022
5486
  label: item.label,
@@ -5031,8 +5495,67 @@ function MetaTab({ documentFields, primaryKeyword, isLoading }) {
5031
5495
  }
5032
5496
 
5033
5497
  // src/components/tabs/TechnicalTab.tsx
5034
- import { useMemo as useMemo4 } from "react";
5035
- import { Fragment as Fragment7, jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
5498
+ import { useMemo as useMemo4, useState as useState15 } from "react";
5499
+ import { Fragment as Fragment8, jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
5500
+ function urlAudit(slug, primaryKeyword, secondaryKeyword) {
5501
+ const SHORT_DESC = "Keep the URL short and descriptive - concise URLs are easier to read - and avoid trailing, duplicate, or excessive spaces.";
5502
+ if (!slug) {
5503
+ return {
5504
+ label: "URL Slug",
5505
+ value: "Missing",
5506
+ status: "warning",
5507
+ recommendation: `Add a URL slug that leads with your primary keyword. ${SHORT_DESC}`
5508
+ };
5509
+ }
5510
+ const slugAsWords = slug.replace(/-/g, " ");
5511
+ const hasPrimary = primaryKeyword ? containsKeywordTokens(slugAsWords, primaryKeyword) : true;
5512
+ const leads = primaryKeyword ? keywordLeadsSlug(slug, primaryKeyword) : true;
5513
+ const hasSecondary = secondaryKeyword ? containsKeywordTokens(slugAsWords, secondaryKeyword) : true;
5514
+ if (primaryKeyword && !hasPrimary) {
5515
+ const secNote = secondaryKeyword && !hasSecondary ? ` Your secondary keyword "${secondaryKeyword}" could follow it.` : "";
5516
+ return {
5517
+ label: "URL Slug",
5518
+ value: `/${slug}`,
5519
+ status: "warning",
5520
+ recommendation: `Work your primary keyword "${primaryKeyword}" into the URL, ideally at the start - if the address gets shortened, a leading keyword still shows.${secNote} ${SHORT_DESC}`
5521
+ };
5522
+ }
5523
+ if (primaryKeyword && hasPrimary && !leads) {
5524
+ return {
5525
+ label: "URL Slug",
5526
+ value: `/${slug}`,
5527
+ status: "warning",
5528
+ recommendation: `Your primary keyword is in the URL but not at the start. Leading with it reads better and holds up if the address gets shortened. ${SHORT_DESC}`
5529
+ };
5530
+ }
5531
+ return { label: "URL Slug", value: `/${slug}`, status: "good" };
5532
+ }
5533
+ function SlugRedirectNotice() {
5534
+ const [expanded, setExpanded] = useState15(false);
5535
+ return /* @__PURE__ */ jsx15("div", { style: { marginTop: 10, paddingTop: 10, borderTop: "1px solid rgba(0,0,0,0.07)" }, children: /* @__PURE__ */ jsxs14("div", { style: { padding: "8px 10px", background: "rgba(245,158,11,0.08)", borderLeft: "2px solid #f59e0b", borderRadius: 6 }, children: [
5536
+ /* @__PURE__ */ jsxs14("div", { style: { display: "flex", alignItems: "center", gap: 6, marginBottom: 4 }, children: [
5537
+ /* @__PURE__ */ jsx15("svg", { width: "12", height: "12", viewBox: "0 0 20 20", fill: "#f59e0b", "aria-hidden": "true", children: /* @__PURE__ */ jsx15("path", { fillRule: "evenodd", d: "M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z", clipRule: "evenodd" }) }),
5538
+ /* @__PURE__ */ jsx15("span", { style: { fontSize: 10.5, fontWeight: 700, color: "#b45309", textTransform: "uppercase", letterSpacing: "0.06em" }, children: "Changing a URL?" })
5539
+ ] }),
5540
+ /* @__PURE__ */ jsx15("div", { style: { fontSize: 11, color: "#1f2937", lineHeight: 1.55 }, children: "If the page has been published and indexed, you MUST add a 301 redirect from the old slug to the new one before changing it. For a brand-new page that's never been published, no redirect needed." }),
5541
+ /* @__PURE__ */ jsxs14(
5542
+ "button",
5543
+ {
5544
+ onClick: () => setExpanded((v) => !v),
5545
+ style: { display: "flex", alignItems: "center", gap: 3, marginTop: 6, padding: 0, background: "none", border: "none", cursor: "pointer", fontSize: 10.5, fontWeight: 700, color: "#b45309", fontFamily: "inherit" },
5546
+ children: [
5547
+ expanded ? "Show less" : "Learn more",
5548
+ /* @__PURE__ */ jsx15("svg", { width: "10", height: "10", viewBox: "0 0 20 20", fill: "currentColor", style: { transform: expanded ? "rotate(180deg)" : "none", transition: "transform 150ms" }, children: /* @__PURE__ */ jsx15("path", { fillRule: "evenodd", d: "M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z", clipRule: "evenodd" }) })
5549
+ ]
5550
+ }
5551
+ ),
5552
+ expanded && /* @__PURE__ */ jsxs14("ul", { style: { margin: "6px 0 0", paddingLeft: 16, fontSize: 11, color: "#1f2937", lineHeight: 1.55 }, children: [
5553
+ /* @__PURE__ */ jsx15("li", { children: "Without the 301, the page loses every search ranking and every external link to it breaks." }),
5554
+ /* @__PURE__ */ jsx15("li", { children: "A 301 preserves the rankings and link equity built up on the old URL." }),
5555
+ /* @__PURE__ */ jsx15("li", { children: "Set this up using vanity redirects in Sanity." })
5556
+ ] })
5557
+ ] }) });
5558
+ }
5036
5559
  var cardStyle6 = {
5037
5560
  borderRadius: 14,
5038
5561
  background: "rgba(255,255,255,0.55)",
@@ -5048,7 +5571,7 @@ function StatusBadge2({ status }) {
5048
5571
  error: { bg: "rgba(220,38,38,0.1)", color: "#dc2626", label: "Fix" }
5049
5572
  };
5050
5573
  const c = map[status];
5051
- return /* @__PURE__ */ jsx14(
5574
+ return /* @__PURE__ */ jsx15(
5052
5575
  "span",
5053
5576
  {
5054
5577
  style: {
@@ -5071,14 +5594,15 @@ function AuditCard2({
5071
5594
  value,
5072
5595
  status,
5073
5596
  recommendation,
5074
- anchorId
5597
+ anchorId,
5598
+ footer
5075
5599
  }) {
5076
- return /* @__PURE__ */ jsxs13("div", { id: anchorId, style: cardStyle6, children: [
5077
- /* @__PURE__ */ jsxs13("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, marginBottom: 6 }, children: [
5078
- /* @__PURE__ */ jsx14("span", { style: { fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#4b5563", fontWeight: 600 }, children: label }),
5079
- /* @__PURE__ */ jsx14(StatusBadge2, { status })
5600
+ return /* @__PURE__ */ jsxs14("div", { id: anchorId, style: cardStyle6, children: [
5601
+ /* @__PURE__ */ jsxs14("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, marginBottom: 6 }, children: [
5602
+ /* @__PURE__ */ jsx15("span", { style: { fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#4b5563", fontWeight: 600 }, children: label }),
5603
+ /* @__PURE__ */ jsx15(StatusBadge2, { status })
5080
5604
  ] }),
5081
- /* @__PURE__ */ jsx14(
5605
+ /* @__PURE__ */ jsx15(
5082
5606
  "div",
5083
5607
  {
5084
5608
  style: {
@@ -5091,7 +5615,7 @@ function AuditCard2({
5091
5615
  children: value
5092
5616
  }
5093
5617
  ),
5094
- recommendation && /* @__PURE__ */ jsx14(
5618
+ recommendation && /* @__PURE__ */ jsx15(
5095
5619
  "div",
5096
5620
  {
5097
5621
  style: {
@@ -5106,7 +5630,8 @@ function AuditCard2({
5106
5630
  },
5107
5631
  children: recommendation
5108
5632
  }
5109
- )
5633
+ ),
5634
+ footer
5110
5635
  ] });
5111
5636
  }
5112
5637
  var IMAGE_EXT_RE = /\.(jpe?g|png|gif|webp|svg|tiff?|bmp)$/i;
@@ -5140,7 +5665,7 @@ function imageFilenameAudit(filenames) {
5140
5665
  const words = base.split("-").filter(Boolean);
5141
5666
  if (words.length < 2) {
5142
5667
  issues.push({ filename: f, reason: "single word - use 2-3 descriptive hyphenated words" });
5143
- } else if (words.length > 7) {
5668
+ } else if (words.length > 5) {
5144
5669
  issues.push({ filename: f, reason: "too many words - keep to 3-5" });
5145
5670
  }
5146
5671
  }
@@ -5169,7 +5694,7 @@ function imageAltTextAudit(altTexts) {
5169
5694
  audited++;
5170
5695
  const len = trimmed.length;
5171
5696
  const wc = trimmed.split(/\s+/).filter(Boolean).length;
5172
- if (len > 125) {
5697
+ if (len >= 125) {
5173
5698
  issues.push({ alt: trimmed, reason: `${len} chars - shorten to under 125` });
5174
5699
  } else if (wc < 2) {
5175
5700
  issues.push({ alt: trimmed, reason: "just one word - use 2-5 descriptive keywords" });
@@ -5324,10 +5849,10 @@ function LinkCheckCard({
5324
5849
  const issues = results.filter((r) => r.category !== "ok");
5325
5850
  return { total, valid, redirects, broken, errored, unverified, issues };
5326
5851
  }, [results]);
5327
- return /* @__PURE__ */ jsxs13("div", { id: "anchor-link-check", style: cardStyle6, children: [
5328
- /* @__PURE__ */ jsxs13("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, marginBottom: 6 }, children: [
5329
- /* @__PURE__ */ jsx14("span", { style: { fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#4b5563", fontWeight: 600 }, children: "Link Health" }),
5330
- hasRun && !isLoading && /* @__PURE__ */ jsx14(
5852
+ return /* @__PURE__ */ jsxs14("div", { id: "anchor-link-check", style: cardStyle6, children: [
5853
+ /* @__PURE__ */ jsxs14("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8, marginBottom: 6 }, children: [
5854
+ /* @__PURE__ */ jsx15("span", { style: { fontSize: 10.5, textTransform: "uppercase", letterSpacing: "0.06em", color: "#4b5563", fontWeight: 600 }, children: "Link Health" }),
5855
+ hasRun && !isLoading && /* @__PURE__ */ jsx15(
5331
5856
  "button",
5332
5857
  {
5333
5858
  onClick: onCheck,
@@ -5345,8 +5870,8 @@ function LinkCheckCard({
5345
5870
  }
5346
5871
  )
5347
5872
  ] }),
5348
- /* @__PURE__ */ jsx14("div", { style: { fontSize: 11, color: "#1f2937", lineHeight: 1.5, marginBottom: 10 }, children: urls.length === 0 ? "No external links found in the body." : `${urls.length} link${urls.length === 1 ? "" : "s"} found in the body.` }),
5349
- urls.length > 0 && !hasRun && !isLoading && /* @__PURE__ */ jsxs13(
5873
+ /* @__PURE__ */ jsx15("div", { style: { fontSize: 11, color: "#1f2937", lineHeight: 1.5, marginBottom: 10 }, children: urls.length === 0 ? "No external links found in the body." : `${urls.length} link${urls.length === 1 ? "" : "s"} found in the body.` }),
5874
+ urls.length > 0 && !hasRun && !isLoading && /* @__PURE__ */ jsxs14(
5350
5875
  "button",
5351
5876
  {
5352
5877
  onClick: onCheck,
@@ -5371,9 +5896,9 @@ function LinkCheckCard({
5371
5896
  ]
5372
5897
  }
5373
5898
  ),
5374
- isLoading && /* @__PURE__ */ jsxs13("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", gap: 8, padding: "16px 0" }, children: [
5375
- /* @__PURE__ */ jsx14(LoadingBars, { size: "xs", color: MJH_BLUE }),
5376
- /* @__PURE__ */ jsxs13("span", { style: { fontSize: 11, color: "#4b5563" }, children: [
5899
+ isLoading && /* @__PURE__ */ jsxs14("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", gap: 8, padding: "16px 0" }, children: [
5900
+ /* @__PURE__ */ jsx15(LoadingBars, { size: "xs", color: MJH_BLUE }),
5901
+ /* @__PURE__ */ jsxs14("span", { style: { fontSize: 11, color: "#4b5563" }, children: [
5377
5902
  "Checking ",
5378
5903
  urls.length,
5379
5904
  " link",
@@ -5381,7 +5906,7 @@ function LinkCheckCard({
5381
5906
  "..."
5382
5907
  ] })
5383
5908
  ] }),
5384
- error && !isLoading && /* @__PURE__ */ jsxs13(
5909
+ error && !isLoading && /* @__PURE__ */ jsxs14(
5385
5910
  "div",
5386
5911
  {
5387
5912
  style: {
@@ -5395,7 +5920,7 @@ function LinkCheckCard({
5395
5920
  },
5396
5921
  children: [
5397
5922
  error,
5398
- /* @__PURE__ */ jsx14(
5923
+ /* @__PURE__ */ jsx15(
5399
5924
  "button",
5400
5925
  {
5401
5926
  onClick: onCheck,
@@ -5417,15 +5942,15 @@ function LinkCheckCard({
5417
5942
  ]
5418
5943
  }
5419
5944
  ),
5420
- hasRun && !isLoading && !error && /* @__PURE__ */ jsxs13(Fragment7, { children: [
5421
- /* @__PURE__ */ jsxs13("div", { style: { display: "grid", gridTemplateColumns: counts.unverified > 0 ? "repeat(5, 1fr)" : "repeat(4, 1fr)", gap: 6 }, children: [
5422
- /* @__PURE__ */ jsx14(StatTile, { label: "Checked", value: counts.total, color: "#475569" }),
5423
- /* @__PURE__ */ jsx14(StatTile, { label: "Valid", value: counts.valid, color: "#16a34a" }),
5424
- /* @__PURE__ */ jsx14(StatTile, { label: "Redirects", value: counts.redirects, color: "#8B7310" }),
5425
- /* @__PURE__ */ jsx14(StatTile, { label: "Broken", value: counts.broken + counts.errored, color: "#dc2626" }),
5426
- counts.unverified > 0 && /* @__PURE__ */ jsx14(StatTile, { label: "Blocked", value: counts.unverified, color: "#b45309" })
5945
+ hasRun && !isLoading && !error && /* @__PURE__ */ jsxs14(Fragment8, { children: [
5946
+ /* @__PURE__ */ jsxs14("div", { style: { display: "grid", gridTemplateColumns: counts.unverified > 0 ? "repeat(5, 1fr)" : "repeat(4, 1fr)", gap: 6 }, children: [
5947
+ /* @__PURE__ */ jsx15(StatTile, { label: "Checked", value: counts.total, color: "#475569" }),
5948
+ /* @__PURE__ */ jsx15(StatTile, { label: "Valid", value: counts.valid, color: "#16a34a" }),
5949
+ /* @__PURE__ */ jsx15(StatTile, { label: "Redirects", value: counts.redirects, color: "#8B7310" }),
5950
+ /* @__PURE__ */ jsx15(StatTile, { label: "Broken", value: counts.broken + counts.errored, color: "#dc2626" }),
5951
+ counts.unverified > 0 && /* @__PURE__ */ jsx15(StatTile, { label: "Blocked", value: counts.unverified, color: "#b45309" })
5427
5952
  ] }),
5428
- counts.unverified > 0 && /* @__PURE__ */ jsxs13(
5953
+ counts.unverified > 0 && /* @__PURE__ */ jsxs14(
5429
5954
  "div",
5430
5955
  {
5431
5956
  style: {
@@ -5446,8 +5971,8 @@ function LinkCheckCard({
5446
5971
  ]
5447
5972
  }
5448
5973
  ),
5449
- counts.issues.length > 0 ? /* @__PURE__ */ jsxs13("div", { style: { marginTop: 12, display: "flex", flexDirection: "column", gap: 6 }, children: [
5450
- /* @__PURE__ */ jsxs13("div", { style: { fontSize: 10, fontWeight: 700, color: "#4b5563", textTransform: "uppercase", letterSpacing: "0.06em" }, children: [
5974
+ counts.issues.length > 0 ? /* @__PURE__ */ jsxs14("div", { style: { marginTop: 12, display: "flex", flexDirection: "column", gap: 6 }, children: [
5975
+ /* @__PURE__ */ jsxs14("div", { style: { fontSize: 10, fontWeight: 700, color: "#4b5563", textTransform: "uppercase", letterSpacing: "0.06em" }, children: [
5451
5976
  counts.issues.length,
5452
5977
  " link",
5453
5978
  counts.issues.length === 1 ? "" : "s",
@@ -5455,8 +5980,8 @@ function LinkCheckCard({
5455
5980
  counts.issues.length === 1 ? "s" : "",
5456
5981
  " attention"
5457
5982
  ] }),
5458
- counts.issues.map((r) => /* @__PURE__ */ jsx14(LinkIssueRow, { result: r }, r.url))
5459
- ] }) : /* @__PURE__ */ jsxs13(
5983
+ counts.issues.map((r) => /* @__PURE__ */ jsx15(LinkIssueRow, { result: r }, r.url))
5984
+ ] }) : /* @__PURE__ */ jsxs14(
5460
5985
  "div",
5461
5986
  {
5462
5987
  style: {
@@ -5483,7 +6008,7 @@ function LinkCheckCard({
5483
6008
  ] });
5484
6009
  }
5485
6010
  function StatTile({ label, value, color }) {
5486
- return /* @__PURE__ */ jsxs13(
6011
+ return /* @__PURE__ */ jsxs14(
5487
6012
  "div",
5488
6013
  {
5489
6014
  style: {
@@ -5493,8 +6018,8 @@ function StatTile({ label, value, color }) {
5493
6018
  textAlign: "center"
5494
6019
  },
5495
6020
  children: [
5496
- /* @__PURE__ */ jsx14("div", { style: { fontSize: 18, fontWeight: 700, color, fontVariantNumeric: "tabular-nums", lineHeight: 1 }, children: value }),
5497
- /* @__PURE__ */ jsx14("div", { style: { fontSize: 9, fontWeight: 700, color: "#4b5563", textTransform: "uppercase", letterSpacing: "0.06em", marginTop: 4 }, children: label })
6021
+ /* @__PURE__ */ jsx15("div", { style: { fontSize: 18, fontWeight: 700, color, fontVariantNumeric: "tabular-nums", lineHeight: 1 }, children: value }),
6022
+ /* @__PURE__ */ jsx15("div", { style: { fontSize: 9, fontWeight: 700, color: "#4b5563", textTransform: "uppercase", letterSpacing: "0.06em", marginTop: 4 }, children: label })
5498
6023
  ]
5499
6024
  }
5500
6025
  );
@@ -5510,7 +6035,7 @@ function LinkIssueRow({ result }) {
5510
6035
  };
5511
6036
  const c = map[result.category];
5512
6037
  const tooltip = result.category === "unverified" ? `${result.url} (couldn't auto-check; likely anti-bot blocking - open manually to verify)` : result.error ? `${result.url} (${result.error})` : result.url;
5513
- return /* @__PURE__ */ jsxs13(
6038
+ return /* @__PURE__ */ jsxs14(
5514
6039
  "a",
5515
6040
  {
5516
6041
  href: result.url,
@@ -5526,7 +6051,7 @@ function LinkIssueRow({ result }) {
5526
6051
  textDecoration: "none"
5527
6052
  },
5528
6053
  children: [
5529
- /* @__PURE__ */ jsx14(
6054
+ /* @__PURE__ */ jsx15(
5530
6055
  "span",
5531
6056
  {
5532
6057
  style: {
@@ -5543,7 +6068,7 @@ function LinkIssueRow({ result }) {
5543
6068
  children: c.label
5544
6069
  }
5545
6070
  ),
5546
- /* @__PURE__ */ jsx14(
6071
+ /* @__PURE__ */ jsx15(
5547
6072
  "span",
5548
6073
  {
5549
6074
  style: {
@@ -5567,6 +6092,8 @@ function LinkIssueRow({ result }) {
5567
6092
  function TechnicalTab({
5568
6093
  text,
5569
6094
  documentFields,
6095
+ primaryKeyword,
6096
+ secondaryKeyword,
5570
6097
  isLoading,
5571
6098
  linkCheckResults,
5572
6099
  isLinkCheckLoading,
@@ -5574,9 +6101,16 @@ function TechnicalTab({
5574
6101
  hasRunLinkCheck,
5575
6102
  onCheckLinks
5576
6103
  }) {
6104
+ const urlSlugAudit = useMemo4(
6105
+ () => urlAudit(documentFields?.slug, primaryKeyword, secondaryKeyword),
6106
+ [documentFields?.slug, primaryKeyword, secondaryKeyword]
6107
+ );
5577
6108
  const headings = documentFields?.headings || [];
5578
6109
  const headingsDetailed = documentFields?.headingsDetailed;
5579
- const headingsForStructure = headingsDetailed ? headingsDetailed : headings.map((text2) => ({ text: text2, level: 2 }));
6110
+ const headingsForStructure = useMemo4(
6111
+ () => headingsDetailed ? headingsDetailed : headings.map((text2) => ({ text: text2, level: 2 })),
6112
+ [headingsDetailed, headings]
6113
+ );
5580
6114
  const wordCount2 = text ? text.split(/\s+/).filter(Boolean).length : 0;
5581
6115
  const structureAudits = useMemo4(
5582
6116
  () => computeHeadingStructureAudits(headingsForStructure, wordCount2),
@@ -5608,7 +6142,8 @@ function TechnicalTab({
5608
6142
  status: "warning",
5609
6143
  recommendation: "Add at least one hero image with descriptive alt text. Articles with images perform better on both reader engagement and search."
5610
6144
  } : null;
5611
- const wordAudit = wordCount2 === 0 ? null : wordCount2 < 450 ? {
6145
+ const isShortForm = isShortFormContent(documentFields, documentFields?.title);
6146
+ const wordAudit = wordCount2 === 0 ? null : isShortForm ? { label: "Word Count", value: `${wordCount2} words`, status: "good" } : wordCount2 < 450 ? {
5612
6147
  label: "Word Count",
5613
6148
  value: `${wordCount2} words`,
5614
6149
  status: "error",
@@ -5622,13 +6157,24 @@ function TechnicalTab({
5622
6157
  const bodyLinks = documentFields?.bodyLinks || [];
5623
6158
  const hasAnyField = !!documentFields && (documentFields.title !== void 0 || documentFields.headings && documentFields.headings.length > 0 || documentFields.imageNames && documentFields.imageNames.length > 0 || wordCount2 > 0);
5624
6159
  if (isLoading && !hasAnyField) {
5625
- return /* @__PURE__ */ jsxs13("div", { style: { padding: 24, textAlign: "center" }, children: [
5626
- /* @__PURE__ */ jsx14("div", { style: { fontSize: 13, color: "#4b5563", fontWeight: 500 }, children: "Reading document fields..." }),
5627
- /* @__PURE__ */ jsx14("div", { style: { fontSize: 11, color: "#4b5563", marginTop: 4 }, children: "Audit will run once content loads" })
6160
+ return /* @__PURE__ */ jsxs14("div", { style: { padding: 24, textAlign: "center" }, children: [
6161
+ /* @__PURE__ */ jsx15("div", { style: { fontSize: 13, color: "#4b5563", fontWeight: 500 }, children: "Reading document fields..." }),
6162
+ /* @__PURE__ */ jsx15("div", { style: { fontSize: 11, color: "#4b5563", marginTop: 4 }, children: "Audit will run once content loads" })
5628
6163
  ] });
5629
6164
  }
5630
- return /* @__PURE__ */ jsxs13("div", { style: { padding: 12, display: "flex", flexDirection: "column", gap: 10 }, children: [
5631
- wordAudit && /* @__PURE__ */ jsx14(
6165
+ return /* @__PURE__ */ jsxs14("div", { style: { padding: 12, display: "flex", flexDirection: "column", gap: 10 }, children: [
6166
+ /* @__PURE__ */ jsx15(
6167
+ AuditCard2,
6168
+ {
6169
+ anchorId: "anchor-url-slug",
6170
+ label: urlSlugAudit.label,
6171
+ value: urlSlugAudit.value,
6172
+ status: urlSlugAudit.status,
6173
+ recommendation: urlSlugAudit.recommendation,
6174
+ footer: /* @__PURE__ */ jsx15(SlugRedirectNotice, {})
6175
+ }
6176
+ ),
6177
+ wordAudit && /* @__PURE__ */ jsx15(
5632
6178
  AuditCard2,
5633
6179
  {
5634
6180
  anchorId: "anchor-word-count",
@@ -5638,7 +6184,7 @@ function TechnicalTab({
5638
6184
  recommendation: wordAudit.recommendation
5639
6185
  }
5640
6186
  ),
5641
- structureAudits.map((a, i) => /* @__PURE__ */ jsx14(
6187
+ structureAudits.map((a, i) => /* @__PURE__ */ jsx15(
5642
6188
  AuditCard2,
5643
6189
  {
5644
6190
  anchorId: i === 0 ? "anchor-headings-structure" : void 0,
@@ -5649,10 +6195,10 @@ function TechnicalTab({
5649
6195
  },
5650
6196
  `structure-${i}`
5651
6197
  )),
5652
- headings.length > 0 && /* @__PURE__ */ jsxs13("div", { id: "anchor-headings-outline", style: { ...cardStyle6, padding: "8px 14px" }, children: [
5653
- /* @__PURE__ */ jsx14("div", { style: { fontSize: 10, color: "#4b5563", textTransform: "uppercase", letterSpacing: "0.06em", fontWeight: 600, marginBottom: 6 }, children: "Heading Outline" }),
5654
- /* @__PURE__ */ jsxs13("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
5655
- (headingsDetailed ? headingsDetailed.slice(0, 12) : headings.slice(0, 12).map((h) => ({ text: h, level: 2 }))).map((h, i) => /* @__PURE__ */ jsxs13(
6198
+ headings.length > 0 && /* @__PURE__ */ jsxs14("div", { id: "anchor-headings-outline", style: { ...cardStyle6, padding: "8px 14px" }, children: [
6199
+ /* @__PURE__ */ jsx15("div", { style: { fontSize: 10, color: "#4b5563", textTransform: "uppercase", letterSpacing: "0.06em", fontWeight: 600, marginBottom: 6 }, children: "Heading Outline" }),
6200
+ /* @__PURE__ */ jsxs14("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
6201
+ (headingsDetailed ? headingsDetailed.slice(0, 12) : headings.slice(0, 12).map((h) => ({ text: h, level: 2 }))).map((h, i) => /* @__PURE__ */ jsxs14(
5656
6202
  "div",
5657
6203
  {
5658
6204
  style: {
@@ -5663,7 +6209,7 @@ function TechnicalTab({
5663
6209
  paddingLeft: Math.max(0, (h.level - 2) * 12)
5664
6210
  },
5665
6211
  children: [
5666
- /* @__PURE__ */ jsxs13("span", { style: { fontSize: 9, fontWeight: 700, color: "#4b5563", marginRight: 6 }, children: [
6212
+ /* @__PURE__ */ jsxs14("span", { style: { fontSize: 9, fontWeight: 700, color: "#4b5563", marginRight: 6 }, children: [
5667
6213
  "H",
5668
6214
  h.level
5669
6215
  ] }),
@@ -5672,14 +6218,14 @@ function TechnicalTab({
5672
6218
  },
5673
6219
  i
5674
6220
  )),
5675
- headings.length > 12 && /* @__PURE__ */ jsxs13("div", { style: { fontSize: 10, color: "#4b5563" }, children: [
6221
+ (headingsDetailed ?? headings).length > 12 && /* @__PURE__ */ jsxs14("div", { style: { fontSize: 10, color: "#4b5563" }, children: [
5676
6222
  "+ ",
5677
- headings.length - 12,
6223
+ (headingsDetailed ?? headings).length - 12,
5678
6224
  " more"
5679
6225
  ] })
5680
6226
  ] })
5681
6227
  ] }),
5682
- imagesAudit && /* @__PURE__ */ jsx14(
6228
+ imagesAudit && /* @__PURE__ */ jsx15(
5683
6229
  AuditCard2,
5684
6230
  {
5685
6231
  anchorId: "anchor-images",
@@ -5689,7 +6235,7 @@ function TechnicalTab({
5689
6235
  recommendation: imagesAudit.recommendation
5690
6236
  }
5691
6237
  ),
5692
- filenameAudit && /* @__PURE__ */ jsx14(
6238
+ filenameAudit && /* @__PURE__ */ jsx15(
5693
6239
  AuditCard2,
5694
6240
  {
5695
6241
  anchorId: "anchor-image-filenames",
@@ -5699,7 +6245,7 @@ function TechnicalTab({
5699
6245
  recommendation: filenameAudit.recommendation
5700
6246
  }
5701
6247
  ),
5702
- altTextAudit && /* @__PURE__ */ jsx14(
6248
+ altTextAudit && /* @__PURE__ */ jsx15(
5703
6249
  AuditCard2,
5704
6250
  {
5705
6251
  anchorId: "anchor-image-alt",
@@ -5709,7 +6255,7 @@ function TechnicalTab({
5709
6255
  recommendation: altTextAudit.recommendation
5710
6256
  }
5711
6257
  ),
5712
- imgTitleAudit && /* @__PURE__ */ jsx14(
6258
+ imgTitleAudit && /* @__PURE__ */ jsx15(
5713
6259
  AuditCard2,
5714
6260
  {
5715
6261
  anchorId: "anchor-image-titles",
@@ -5719,7 +6265,7 @@ function TechnicalTab({
5719
6265
  recommendation: imgTitleAudit.recommendation
5720
6266
  }
5721
6267
  ),
5722
- /* @__PURE__ */ jsx14(
6268
+ /* @__PURE__ */ jsx15(
5723
6269
  LinkCheckCard,
5724
6270
  {
5725
6271
  urls: bodyLinks,
@@ -5734,12 +6280,12 @@ function TechnicalTab({
5734
6280
  }
5735
6281
 
5736
6282
  // src/components/SEOCopilotPanel.tsx
5737
- import { Fragment as Fragment8, jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
6283
+ import { Fragment as Fragment9, jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
5738
6284
  function LogoIcon2() {
5739
- return /* @__PURE__ */ jsxs14("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: [
5740
- /* @__PURE__ */ jsx15("rect", { x: "1", y: "3", width: "4", height: "10", rx: "1", fill: MJH_GOLD, opacity: "1" }),
5741
- /* @__PURE__ */ jsx15("rect", { x: "6", y: "1", width: "4", height: "14", rx: "1", fill: MJH_GOLD, opacity: "0.85" }),
5742
- /* @__PURE__ */ jsx15("rect", { x: "11", y: "5", width: "4", height: "8", rx: "1", fill: MJH_GOLD, opacity: "0.6" })
6285
+ return /* @__PURE__ */ jsxs15("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: [
6286
+ /* @__PURE__ */ jsx16("rect", { x: "1", y: "3", width: "4", height: "10", rx: "1", fill: MJH_GOLD, opacity: "1" }),
6287
+ /* @__PURE__ */ jsx16("rect", { x: "6", y: "1", width: "4", height: "14", rx: "1", fill: MJH_GOLD, opacity: "0.85" }),
6288
+ /* @__PURE__ */ jsx16("rect", { x: "11", y: "5", width: "4", height: "8", rx: "1", fill: MJH_GOLD, opacity: "0.6" })
5743
6289
  ] });
5744
6290
  }
5745
6291
  function PanelContent({
@@ -5757,8 +6303,12 @@ function PanelContent({
5757
6303
  docLoading,
5758
6304
  documentFields,
5759
6305
  documentId,
6306
+ documentType,
6307
+ sanityBaseUrl,
5760
6308
  selectedPrimary,
5761
6309
  onSelectPrimary,
6310
+ selectedSecondary,
6311
+ onSelectSecondary,
5762
6312
  activeTab,
5763
6313
  onActiveTabChange,
5764
6314
  chatOpen,
@@ -5776,14 +6326,15 @@ function PanelContent({
5776
6326
  const isLoading = externalAnalysis.isLoading;
5777
6327
  const keywordAnalysisState = externalAnalysis;
5778
6328
  const effectivePrimary = selectedPrimary || externalAnalysis.analysis?.primaryKeyword?.term || "";
5779
- const containerRef = useRef10(null);
5780
- const dragging = useRef10(false);
6329
+ const effectiveSecondary = selectedSecondary || "";
6330
+ const containerRef = useRef11(null);
6331
+ const dragging = useRef11(false);
5781
6332
  const onMouseDown = useCallback5(() => {
5782
6333
  dragging.current = true;
5783
6334
  document.body.style.cursor = "row-resize";
5784
6335
  document.body.style.userSelect = "none";
5785
6336
  }, []);
5786
- useEffect10(() => {
6337
+ useEffect11(() => {
5787
6338
  const onMouseMove = (e) => {
5788
6339
  if (!dragging.current || !containerRef.current) return;
5789
6340
  const rect = containerRef.current.getBoundingClientRect();
@@ -5803,6 +6354,77 @@ function PanelContent({
5803
6354
  };
5804
6355
  }, [onSplitPercentChange]);
5805
6356
  const headerCursor = isFloating ? "grab" : "default";
6357
+ const onboardSite = publication || "default";
6358
+ const onboardKey = `seo-copilot-onboarded-${onboardSite}`;
6359
+ const onboardSessionKey = `seo-copilot-onboard-shown-${onboardSite}`;
6360
+ const [popupMode, setPopupMode] = useState16("hidden");
6361
+ const [popupClosing, setPopupClosing] = useState16(false);
6362
+ const onboardTimerRef = useRef11(null);
6363
+ const onboardFadeRef = useRef11(null);
6364
+ useEffect11(() => {
6365
+ let onboarded = false;
6366
+ let shownThisSession = false;
6367
+ try {
6368
+ onboarded = localStorage.getItem(onboardKey) === "1";
6369
+ } catch {
6370
+ }
6371
+ try {
6372
+ shownThisSession = sessionStorage.getItem(onboardSessionKey) === "1";
6373
+ } catch {
6374
+ }
6375
+ if (!onboarded && !shownThisSession) {
6376
+ setPopupMode("auto");
6377
+ try {
6378
+ sessionStorage.setItem(onboardSessionKey, "1");
6379
+ } catch {
6380
+ }
6381
+ onboardTimerRef.current = setTimeout(() => {
6382
+ setPopupClosing(true);
6383
+ onboardFadeRef.current = setTimeout(() => {
6384
+ setPopupMode("hidden");
6385
+ setPopupClosing(false);
6386
+ }, 180);
6387
+ }, 8e3);
6388
+ }
6389
+ return () => {
6390
+ if (onboardTimerRef.current) clearTimeout(onboardTimerRef.current);
6391
+ if (onboardFadeRef.current) clearTimeout(onboardFadeRef.current);
6392
+ };
6393
+ }, [onboardKey, onboardSessionKey]);
6394
+ const markOnboarded = useCallback5(() => {
6395
+ try {
6396
+ localStorage.setItem(onboardKey, "1");
6397
+ } catch {
6398
+ }
6399
+ }, [onboardKey]);
6400
+ const dismissPopup = useCallback5(() => {
6401
+ if (onboardTimerRef.current) clearTimeout(onboardTimerRef.current);
6402
+ if (onboardFadeRef.current) clearTimeout(onboardFadeRef.current);
6403
+ markOnboarded();
6404
+ setPopupClosing(true);
6405
+ onboardFadeRef.current = setTimeout(() => {
6406
+ setPopupMode("hidden");
6407
+ setPopupClosing(false);
6408
+ }, 180);
6409
+ }, [markOnboarded]);
6410
+ const openPopupPersistent = useCallback5(() => {
6411
+ if (onboardTimerRef.current) clearTimeout(onboardTimerRef.current);
6412
+ if (onboardFadeRef.current) clearTimeout(onboardFadeRef.current);
6413
+ markOnboarded();
6414
+ setPopupClosing(false);
6415
+ setPopupMode("persistent");
6416
+ }, [markOnboarded]);
6417
+ const handleTabChange = useCallback5((id) => {
6418
+ markOnboarded();
6419
+ if (onboardTimerRef.current) clearTimeout(onboardTimerRef.current);
6420
+ if (onboardFadeRef.current) clearTimeout(onboardFadeRef.current);
6421
+ setPopupClosing(true);
6422
+ onboardFadeRef.current = setTimeout(() => {
6423
+ setPopupMode("hidden");
6424
+ setPopupClosing(false);
6425
+ }, 120);
6426
+ onActiveTabChange(id);
6427
+ }, [markOnboarded, onActiveTabChange]);
5806
6428
  const tabDefs = [
5807
6429
  { id: "summary", label: "Summary", isHub: true, loading: summaryOps.isAnyLoading },
5808
6430
  { id: "keywords", label: "Keywords", loading: keywordAnalysisState.isLoading || keywordAnalysisState.isVolumesLoading },
@@ -5811,7 +6433,7 @@ function PanelContent({
5811
6433
  { id: "meta", label: "Meta", beta: true },
5812
6434
  { id: "technical", label: "Other Recs", beta: true, loading: technicalOps.isLinkCheckLoading }
5813
6435
  ];
5814
- return /* @__PURE__ */ jsxs14(
6436
+ return /* @__PURE__ */ jsxs15(
5815
6437
  "div",
5816
6438
  {
5817
6439
  className: "seo-copilot-panel",
@@ -5822,11 +6444,13 @@ function PanelContent({
5822
6444
  // backgroundColor (longhand) so the sheen background-image in INJECTED_CSS isn't reset
5823
6445
  backgroundColor: PANEL_BG,
5824
6446
  fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif",
5825
- opacity: 1
6447
+ opacity: 1,
6448
+ position: "relative"
5826
6449
  },
5827
6450
  children: [
5828
- /* @__PURE__ */ jsx15("style", { dangerouslySetInnerHTML: { __html: INJECTED_CSS } }),
5829
- /* @__PURE__ */ jsxs14(
6451
+ /* @__PURE__ */ jsx16("style", { dangerouslySetInnerHTML: { __html: INJECTED_CSS } }),
6452
+ popupMode !== "hidden" && /* @__PURE__ */ jsx16(OnboardingCard, { onDismiss: dismissPopup, closing: popupClosing }),
6453
+ /* @__PURE__ */ jsxs15(
5830
6454
  "div",
5831
6455
  {
5832
6456
  onMouseDown: isFloating ? onDragStart : void 0,
@@ -5844,15 +6468,16 @@ function PanelContent({
5844
6468
  flexShrink: 0
5845
6469
  },
5846
6470
  children: [
5847
- /* @__PURE__ */ jsxs14("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
5848
- /* @__PURE__ */ jsx15(LogoIcon2, {}),
5849
- /* @__PURE__ */ jsxs14("span", { style: { fontWeight: 700, fontSize: 15, letterSpacing: "-0.01em" }, children: [
5850
- /* @__PURE__ */ jsx15("span", { style: { color: MJH_GOLD }, children: "SEO" }),
5851
- /* @__PURE__ */ jsx15("span", { style: { color: MJH_SLATE }, children: " copilot" })
6471
+ /* @__PURE__ */ jsxs15("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
6472
+ /* @__PURE__ */ jsx16(LogoIcon2, {}),
6473
+ /* @__PURE__ */ jsxs15("span", { style: { fontWeight: 700, fontSize: 15, letterSpacing: "-0.01em" }, children: [
6474
+ /* @__PURE__ */ jsx16("span", { style: { color: MJH_GOLD }, children: "SEO" }),
6475
+ /* @__PURE__ */ jsx16("span", { style: { color: MJH_SLATE }, children: " copilot" })
5852
6476
  ] })
5853
6477
  ] }),
5854
- /* @__PURE__ */ jsxs14("div", { style: { display: "flex", alignItems: "center", gap: isFloating ? 4 : 6 }, children: [
5855
- isFloating && onToggleFullscreen && /* @__PURE__ */ jsx15(
6478
+ /* @__PURE__ */ jsxs15("div", { style: { display: "flex", alignItems: "center", gap: isFloating ? 4 : 6 }, children: [
6479
+ /* @__PURE__ */ jsx16(OnboardingInfoButton, { onClick: openPopupPersistent }),
6480
+ isFloating && onToggleFullscreen && /* @__PURE__ */ jsx16(
5856
6481
  "button",
5857
6482
  {
5858
6483
  onClick: (e) => {
@@ -5874,16 +6499,16 @@ function PanelContent({
5874
6499
  fontWeight: 600,
5875
6500
  transition: "all 150ms"
5876
6501
  },
5877
- children: isFullscreen ? /* @__PURE__ */ jsxs14(Fragment8, { children: [
5878
- /* @__PURE__ */ jsx15("svg", { width: "12", height: "12", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx15("path", { d: "M3.28 2.22a.75.75 0 00-1.06 1.06L5.44 6.5H3.75a.75.75 0 000 1.5h4.5A.75.75 0 009 7.25v-4.5a.75.75 0 00-1.5 0v1.69L4.28 1.22a.75.75 0 00-1 1zM16.72 17.78a.75.75 0 001.06-1.06L14.56 13.5h1.69a.75.75 0 000-1.5h-4.5a.75.75 0 00-.75.75v4.5a.75.75 0 001.5 0v-1.69l3.22 3.22z" }) }),
6502
+ children: isFullscreen ? /* @__PURE__ */ jsxs15(Fragment9, { children: [
6503
+ /* @__PURE__ */ jsx16("svg", { width: "12", height: "12", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx16("path", { d: "M3.28 2.22a.75.75 0 00-1.06 1.06L5.44 6.5H3.75a.75.75 0 000 1.5h4.5A.75.75 0 009 7.25v-4.5a.75.75 0 00-1.5 0v1.69L4.28 1.22a.75.75 0 00-1 1zM16.72 17.78a.75.75 0 001.06-1.06L14.56 13.5h1.69a.75.75 0 000-1.5h-4.5a.75.75 0 00-.75.75v4.5a.75.75 0 001.5 0v-1.69l3.22 3.22z" }) }),
5879
6504
  "Exit fullscreen"
5880
- ] }) : /* @__PURE__ */ jsxs14(Fragment8, { children: [
5881
- /* @__PURE__ */ jsx15("svg", { width: "12", height: "12", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx15("path", { d: "M13.28 7.78l3.22-3.22v1.69a.75.75 0 001.5 0v-4.5a.75.75 0 00-.75-.75h-4.5a.75.75 0 000 1.5h1.69l-3.22 3.22a.75.75 0 001.06 1.06zM2 17.25a.75.75 0 001.5 0v-1.69l3.22 3.22a.75.75 0 001.06-1.06L4.56 14.5h1.69a.75.75 0 000-1.5h-4.5a.75.75 0 00-.75.75v4.5z" }) }),
6505
+ ] }) : /* @__PURE__ */ jsxs15(Fragment9, { children: [
6506
+ /* @__PURE__ */ jsx16("svg", { width: "12", height: "12", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx16("path", { d: "M13.28 7.78l3.22-3.22v1.69a.75.75 0 001.5 0v-4.5a.75.75 0 00-.75-.75h-4.5a.75.75 0 000 1.5h1.69l-3.22 3.22a.75.75 0 001.06 1.06zM2 17.25a.75.75 0 001.5 0v-1.69l3.22 3.22a.75.75 0 001.06-1.06L4.56 14.5h1.69a.75.75 0 000-1.5h-4.5a.75.75 0 00-.75.75v4.5z" }) }),
5882
6507
  "Fullscreen"
5883
6508
  ] })
5884
6509
  }
5885
6510
  ),
5886
- isFloating && onToggleFloat && /* @__PURE__ */ jsxs14(
6511
+ isFloating && onToggleFloat && /* @__PURE__ */ jsxs15(
5887
6512
  "button",
5888
6513
  {
5889
6514
  onClick: (e) => {
@@ -5906,7 +6531,7 @@ function PanelContent({
5906
6531
  transition: "all 150ms"
5907
6532
  },
5908
6533
  children: [
5909
- /* @__PURE__ */ jsx15("svg", { width: "12", height: "12", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx15(
6534
+ /* @__PURE__ */ jsx16("svg", { width: "12", height: "12", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx16(
5910
6535
  "path",
5911
6536
  {
5912
6537
  fillRule: "evenodd",
@@ -5918,7 +6543,7 @@ function PanelContent({
5918
6543
  ]
5919
6544
  }
5920
6545
  ),
5921
- !isFloating && onToggleFloat && /* @__PURE__ */ jsx15(
6546
+ !isFloating && onToggleFloat && /* @__PURE__ */ jsx16(
5922
6547
  "button",
5923
6548
  {
5924
6549
  onClick: (e) => {
@@ -5937,13 +6562,13 @@ function PanelContent({
5937
6562
  transition: "color 150ms"
5938
6563
  },
5939
6564
  title: "Pop out",
5940
- children: /* @__PURE__ */ jsxs14("svg", { width: "14", height: "14", viewBox: "0 0 20 20", fill: "currentColor", children: [
5941
- /* @__PURE__ */ jsx15("path", { d: "M4.25 5.5a.75.75 0 00-.75.75v8.5c0 .414.336.75.75.75h8.5a.75.75 0 00.75-.75v-4a.75.75 0 011.5 0v4A2.25 2.25 0 0112.75 17h-8.5A2.25 2.25 0 012 14.75v-8.5A2.25 2.25 0 014.25 4h5a.75.75 0 010 1.5h-5z" }),
5942
- /* @__PURE__ */ jsx15("path", { d: "M6.194 12.753a.75.75 0 001.06.053L16.5 4.44v2.81a.75.75 0 001.5 0v-4.5a.75.75 0 00-.75-.75h-4.5a.75.75 0 000 1.5h2.553l-9.056 8.194a.75.75 0 00-.053 1.06z" })
6565
+ children: /* @__PURE__ */ jsxs15("svg", { width: "14", height: "14", viewBox: "0 0 20 20", fill: "currentColor", children: [
6566
+ /* @__PURE__ */ jsx16("path", { d: "M4.25 5.5a.75.75 0 00-.75.75v8.5c0 .414.336.75.75.75h8.5a.75.75 0 00.75-.75v-4a.75.75 0 011.5 0v4A2.25 2.25 0 0112.75 17h-8.5A2.25 2.25 0 012 14.75v-8.5A2.25 2.25 0 014.25 4h5a.75.75 0 010 1.5h-5z" }),
6567
+ /* @__PURE__ */ jsx16("path", { d: "M6.194 12.753a.75.75 0 001.06.053L16.5 4.44v2.81a.75.75 0 001.5 0v-4.5a.75.75 0 00-.75-.75h-4.5a.75.75 0 000 1.5h2.553l-9.056 8.194a.75.75 0 00-.053 1.06z" })
5943
6568
  ] })
5944
6569
  }
5945
6570
  ),
5946
- isLoading && /* @__PURE__ */ jsx15(
6571
+ isLoading && /* @__PURE__ */ jsx16(
5947
6572
  "div",
5948
6573
  {
5949
6574
  style: {
@@ -5955,7 +6580,7 @@ function PanelContent({
5955
6580
  }
5956
6581
  }
5957
6582
  ),
5958
- onClose && /* @__PURE__ */ jsx15(
6583
+ onClose && /* @__PURE__ */ jsx16(
5959
6584
  "button",
5960
6585
  {
5961
6586
  onClick: (e) => {
@@ -5974,11 +6599,11 @@ function PanelContent({
5974
6599
  transition: "color 150ms"
5975
6600
  },
5976
6601
  title: "Close",
5977
- children: /* @__PURE__ */ jsx15("svg", { width: "14", height: "14", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx15("path", { d: "M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z" }) })
6602
+ children: /* @__PURE__ */ jsx16("svg", { width: "14", height: "14", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx16("path", { d: "M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z" }) })
5978
6603
  }
5979
6604
  )
5980
6605
  ] }),
5981
- /* @__PURE__ */ jsx15(
6606
+ /* @__PURE__ */ jsx16(
5982
6607
  "div",
5983
6608
  {
5984
6609
  style: {
@@ -5997,8 +6622,8 @@ function PanelContent({
5997
6622
  ]
5998
6623
  }
5999
6624
  ),
6000
- /* @__PURE__ */ jsx15(TabBar, { tabs: tabDefs, activeTab, onTabChange: onActiveTabChange }),
6001
- /* @__PURE__ */ jsx15(
6625
+ /* @__PURE__ */ jsx16(TabBar, { tabs: tabDefs, activeTab, onTabChange: handleTabChange }),
6626
+ /* @__PURE__ */ jsx16(
6002
6627
  "div",
6003
6628
  {
6004
6629
  style: {
@@ -6014,8 +6639,8 @@ function PanelContent({
6014
6639
  children: "Recommendations are generated by AI. Verify details before publishing."
6015
6640
  }
6016
6641
  ),
6017
- /* @__PURE__ */ jsxs14("div", { ref: containerRef, style: { flex: 1, display: "flex", flexDirection: "column", overflow: "hidden" }, children: [
6018
- /* @__PURE__ */ jsxs14(
6642
+ /* @__PURE__ */ jsxs15("div", { ref: containerRef, style: { flex: 1, display: "flex", flexDirection: "column", overflow: "hidden" }, children: [
6643
+ /* @__PURE__ */ jsxs15(
6019
6644
  "div",
6020
6645
  {
6021
6646
  style: {
@@ -6026,7 +6651,7 @@ function PanelContent({
6026
6651
  background: RECS_ZONE_BG
6027
6652
  },
6028
6653
  children: [
6029
- /* @__PURE__ */ jsx15("div", { style: { display: activeTab === "keywords" ? "block" : "none" }, children: /* @__PURE__ */ jsx15(
6654
+ /* @__PURE__ */ jsx16("div", { style: { display: activeTab === "keywords" ? "block" : "none" }, children: /* @__PURE__ */ jsx16(
6030
6655
  KeywordPanel,
6031
6656
  {
6032
6657
  text,
@@ -6034,19 +6659,23 @@ function PanelContent({
6034
6659
  seedKeywords,
6035
6660
  onSeedsChange,
6036
6661
  onSelectPrimary,
6662
+ secondaryKeyword: effectiveSecondary,
6663
+ onSelectSecondary,
6037
6664
  documentFields,
6038
6665
  documentId,
6039
6666
  externalAnalysis: keywordAnalysisState
6040
6667
  },
6041
6668
  documentId || "default"
6042
6669
  ) }),
6043
- /* @__PURE__ */ jsx15("div", { style: { display: activeTab === "summary" ? "block" : "none" }, children: /* @__PURE__ */ jsx15(
6670
+ /* @__PURE__ */ jsx16("div", { style: { display: activeTab === "summary" ? "block" : "none" }, children: /* @__PURE__ */ jsx16(
6044
6671
  SummaryTab,
6045
6672
  {
6046
6673
  text,
6047
6674
  analysis: keywordAnalysisState.analysis,
6048
6675
  deepAnalysis: keywordAnalysisState.deepAnalysis,
6049
6676
  documentFields,
6677
+ primaryKeyword: effectivePrimary,
6678
+ secondaryKeyword: effectiveSecondary,
6050
6679
  linkingSuggestions: linkingOps.suggestions,
6051
6680
  linkCheckResults: technicalOps.linkCheckResults,
6052
6681
  isAnyLoading: summaryOps.isAnyLoading,
@@ -6054,7 +6683,7 @@ function PanelContent({
6054
6683
  onItemClick: summaryOps.onItemClick
6055
6684
  }
6056
6685
  ) }),
6057
- /* @__PURE__ */ jsx15("div", { style: { display: activeTab === "aeo" ? "block" : "none" }, children: /* @__PURE__ */ jsx15(
6686
+ /* @__PURE__ */ jsx16("div", { style: { display: activeTab === "aeo" ? "block" : "none" }, children: /* @__PURE__ */ jsx16(
6058
6687
  AEOTab,
6059
6688
  {
6060
6689
  text,
@@ -6071,7 +6700,7 @@ function PanelContent({
6071
6700
  loadContentSuggestions: aeoOps.loadContentSuggestions
6072
6701
  }
6073
6702
  ) }),
6074
- /* @__PURE__ */ jsx15("div", { style: { display: activeTab === "linking" ? "block" : "none" }, children: /* @__PURE__ */ jsx15(
6703
+ /* @__PURE__ */ jsx16("div", { style: { display: activeTab === "linking" ? "block" : "none" }, children: /* @__PURE__ */ jsx16(
6075
6704
  LinkingTab,
6076
6705
  {
6077
6706
  analysis: keywordAnalysisState.analysis,
@@ -6082,16 +6711,20 @@ function PanelContent({
6082
6711
  onRefresh: linkingOps.refresh,
6083
6712
  documentId,
6084
6713
  publication,
6085
- text
6714
+ text,
6715
+ sanityBaseUrl,
6716
+ documentType
6086
6717
  }
6087
6718
  ) }),
6088
- /* @__PURE__ */ jsx15("div", { style: { display: activeTab === "meta" ? "block" : "none" }, children: /* @__PURE__ */ jsx15(MetaTab, { documentFields, primaryKeyword: effectivePrimary, isLoading: docLoading }) }),
6089
- /* @__PURE__ */ jsx15("div", { style: { display: activeTab === "technical" ? "block" : "none" }, children: /* @__PURE__ */ jsx15(
6719
+ /* @__PURE__ */ jsx16("div", { style: { display: activeTab === "meta" ? "block" : "none" }, children: /* @__PURE__ */ jsx16(MetaTab, { documentFields, primaryKeyword: effectivePrimary, secondaryKeyword: effectiveSecondary, isLoading: docLoading }) }),
6720
+ /* @__PURE__ */ jsx16("div", { style: { display: activeTab === "technical" ? "block" : "none" }, children: /* @__PURE__ */ jsx16(
6090
6721
  TechnicalTab,
6091
6722
  {
6092
6723
  text,
6093
6724
  documentFields,
6094
6725
  isLoading: docLoading,
6726
+ primaryKeyword: effectivePrimary,
6727
+ secondaryKeyword: effectiveSecondary,
6095
6728
  linkCheckResults: technicalOps.linkCheckResults,
6096
6729
  isLinkCheckLoading: technicalOps.isLinkCheckLoading,
6097
6730
  linkCheckError: technicalOps.linkCheckError,
@@ -6102,7 +6735,7 @@ function PanelContent({
6102
6735
  ]
6103
6736
  }
6104
6737
  ),
6105
- chatOpen && /* @__PURE__ */ jsx15(
6738
+ chatOpen && /* @__PURE__ */ jsx16(
6106
6739
  "div",
6107
6740
  {
6108
6741
  onMouseDown,
@@ -6115,10 +6748,10 @@ function PanelContent({
6115
6748
  justifyContent: "center",
6116
6749
  flexShrink: 0
6117
6750
  },
6118
- children: /* @__PURE__ */ jsx15("div", { style: { width: 32, height: 2, borderRadius: 1, background: "#d1d5db" } })
6751
+ children: /* @__PURE__ */ jsx16("div", { style: { width: 32, height: 2, borderRadius: 1, background: "#d1d5db" } })
6119
6752
  }
6120
6753
  ),
6121
- /* @__PURE__ */ jsxs14(
6754
+ /* @__PURE__ */ jsxs15(
6122
6755
  "div",
6123
6756
  {
6124
6757
  style: {
@@ -6131,7 +6764,7 @@ function PanelContent({
6131
6764
  background: CHAT_ZONE_BG
6132
6765
  },
6133
6766
  children: [
6134
- /* @__PURE__ */ jsxs14(
6767
+ /* @__PURE__ */ jsxs15(
6135
6768
  "button",
6136
6769
  {
6137
6770
  onClick: () => onChatOpenChange(!chatOpen),
@@ -6152,7 +6785,7 @@ function PanelContent({
6152
6785
  flexShrink: 0
6153
6786
  },
6154
6787
  children: [
6155
- /* @__PURE__ */ jsx15(
6788
+ /* @__PURE__ */ jsx16(
6156
6789
  "span",
6157
6790
  {
6158
6791
  style: {
@@ -6165,7 +6798,7 @@ function PanelContent({
6165
6798
  children: "Chat"
6166
6799
  }
6167
6800
  ),
6168
- /* @__PURE__ */ jsx15(
6801
+ /* @__PURE__ */ jsx16(
6169
6802
  "svg",
6170
6803
  {
6171
6804
  width: "12",
@@ -6173,7 +6806,7 @@ function PanelContent({
6173
6806
  viewBox: "0 0 20 20",
6174
6807
  fill: "rgba(0,0,0,0.55)",
6175
6808
  style: { transform: chatOpen ? "rotate(0deg)" : "rotate(-90deg)", transition: "transform 200ms" },
6176
- children: /* @__PURE__ */ jsx15(
6809
+ children: /* @__PURE__ */ jsx16(
6177
6810
  "path",
6178
6811
  {
6179
6812
  fillRule: "evenodd",
@@ -6186,7 +6819,7 @@ function PanelContent({
6186
6819
  ]
6187
6820
  }
6188
6821
  ),
6189
- /* @__PURE__ */ jsx15(
6822
+ /* @__PURE__ */ jsx16(
6190
6823
  "div",
6191
6824
  {
6192
6825
  style: {
@@ -6196,7 +6829,7 @@ function PanelContent({
6196
6829
  flexDirection: "column",
6197
6830
  minHeight: 0
6198
6831
  },
6199
- children: /* @__PURE__ */ jsx15(
6832
+ children: /* @__PURE__ */ jsx16(
6200
6833
  ChatPanel,
6201
6834
  {
6202
6835
  messages: chatState.messages,
@@ -6227,12 +6860,19 @@ function SEOCopilotInner({ config, onClose }) {
6227
6860
  "seo-copilot-ui-float-size",
6228
6861
  { width: 380, height: typeof window !== "undefined" ? Math.round(window.innerHeight * 0.8) : 600 }
6229
6862
  );
6230
- const dragOffset = useRef10(null);
6231
- const resizeStart = useRef10(null);
6232
- const { text, isLoading: docLoading, documentFields, documentId } = useDocumentContent();
6863
+ const dragOffset = useRef11(null);
6864
+ const resizeStart = useRef11(null);
6865
+ const activeDragCleanupRef = useRef11(null);
6866
+ const activeResizeCleanupRef = useRef11(null);
6867
+ const { text, isLoading: docLoading, documentFields, documentId, documentType } = useDocumentContent();
6233
6868
  const { apiUrl } = useConfig();
6234
6869
  const workspace = useWorkspace();
6235
6870
  const effectivePublication = config.publication || workspace?.dataset;
6871
+ const sanityBaseUrl = useMemo5(() => {
6872
+ if (typeof window === "undefined") return void 0;
6873
+ const basePath = (workspace?.basePath || "/").replace(/\/+$/, "");
6874
+ return `${window.location.origin}${basePath}`;
6875
+ }, [workspace?.basePath]);
6236
6876
  const seedCacheKey = documentId ? `seo-copilot-cache-${documentId}` : "seo-copilot-cache-v2";
6237
6877
  const loadSeedsFromCache = useCallback5(() => {
6238
6878
  try {
@@ -6256,8 +6896,10 @@ function SEOCopilotInner({ config, onClose }) {
6256
6896
  );
6257
6897
  const selectedPrimaryKey = documentId ? `seo-copilot-primary-${documentId}` : "seo-copilot-primary-default";
6258
6898
  const [selectedPrimary, setSelectedPrimary] = usePersistentState(selectedPrimaryKey, void 0);
6259
- const seedsInitializedRef = useRef10(false);
6260
- useEffect10(() => {
6899
+ const selectedSecondaryKey = documentId ? `seo-copilot-secondary-${documentId}` : "seo-copilot-secondary-default";
6900
+ const [selectedSecondary, setSelectedSecondary] = usePersistentState(selectedSecondaryKey, "");
6901
+ const seedsInitializedRef = useRef11(false);
6902
+ useEffect11(() => {
6261
6903
  if (!seedsInitializedRef.current) {
6262
6904
  seedsInitializedRef.current = true;
6263
6905
  return;
@@ -6269,6 +6911,11 @@ function SEOCopilotInner({ config, onClose }) {
6269
6911
  const [splitPercent, setSplitPercent] = usePersistentState("seo-copilot-ui-split", 70);
6270
6912
  const keywordAnalysisState = useKeywordAnalysis(text, apiUrl, effectivePublication, seedKeywords, documentFields, selectedPrimary, documentId);
6271
6913
  const effectivePrimary = selectedPrimary || keywordAnalysisState.analysis?.primaryKeyword?.term || "";
6914
+ useEffect11(() => {
6915
+ if (selectedSecondary && effectivePrimary && selectedSecondary.toLowerCase() === effectivePrimary.toLowerCase()) {
6916
+ setSelectedSecondary("");
6917
+ }
6918
+ }, [effectivePrimary, selectedSecondary, setSelectedSecondary]);
6272
6919
  const keywordPanelData = useMemo5(() => {
6273
6920
  const analysis = keywordAnalysisState.analysis;
6274
6921
  if (!analysis) return void 0;
@@ -6289,9 +6936,10 @@ function SEOCopilotInner({ config, onClose }) {
6289
6936
  const [contentSuggestions, setContentSuggestions] = usePersistentState(contentSuggestionsKey, null);
6290
6937
  const [isCSLoading, setIsCSLoading] = useState16(false);
6291
6938
  const [csError, setCsError] = useState16(null);
6292
- const aeoOpVersionRef = useRef10(0);
6293
- const didInitAeoRef = useRef10(false);
6294
- useEffect10(() => {
6939
+ const aeoOpVersionRef = useRef11(0);
6940
+ const csAbortRef = useRef11(null);
6941
+ const didInitAeoRef = useRef11(false);
6942
+ useEffect11(() => {
6295
6943
  if (!didInitAeoRef.current) {
6296
6944
  didInitAeoRef.current = true;
6297
6945
  return;
@@ -6305,7 +6953,11 @@ function SEOCopilotInner({ config, onClose }) {
6305
6953
  setIsCSLoading(true);
6306
6954
  setCsError(null);
6307
6955
  try {
6308
- const data = await fetchContentSuggestions(apiUrl, text, effectivePrimary, effectivePublication);
6956
+ csAbortRef.current?.abort();
6957
+ const csController = new AbortController();
6958
+ csAbortRef.current = csController;
6959
+ const data = await fetchContentSuggestions(apiUrl, text, effectivePrimary, effectivePublication, csController.signal);
6960
+ if (csController.signal.aborted) return;
6309
6961
  if (aeoOpVersionRef.current !== myVersion) return;
6310
6962
  if (data.keyTakeaways.length === 0 && data.infographicOpportunities.length === 0 && data.bulletListItems.length === 0) {
6311
6963
  setCsError("No suggestions returned. Try again with more content.");
@@ -6324,10 +6976,11 @@ function SEOCopilotInner({ config, onClose }) {
6324
6976
  const [isLinkingLoading, setIsLinkingLoading] = useState16(false);
6325
6977
  const [linkingError, setLinkingError] = useState16(null);
6326
6978
  const [linkingFetchedText, setLinkingFetchedText] = useState16("");
6327
- const linkingVersionRef = useRef10(0);
6328
- const didInitLinkingRef = useRef10(false);
6329
- const lastLinkingFetchKey = useRef10("");
6330
- useEffect10(() => {
6979
+ const linkingVersionRef = useRef11(0);
6980
+ const linkingAbortRef = useRef11(null);
6981
+ const didInitLinkingRef = useRef11(false);
6982
+ const lastLinkingFetchKey = useRef11("");
6983
+ useEffect11(() => {
6331
6984
  if (!didInitLinkingRef.current) {
6332
6985
  didInitLinkingRef.current = true;
6333
6986
  return;
@@ -6338,8 +6991,10 @@ function SEOCopilotInner({ config, onClose }) {
6338
6991
  lastLinkingFetchKey.current = "";
6339
6992
  }, [documentId]);
6340
6993
  const supportingKeywordsForLinking = useMemo5(() => {
6341
- return (keywordAnalysisState.analysis?.supportingKeywords || []).map((kw) => kw.term).filter(Boolean).slice(0, 5);
6342
- }, [keywordAnalysisState.analysis]);
6994
+ const base = (keywordAnalysisState.analysis?.supportingKeywords || []).map((kw) => kw.term).filter(Boolean);
6995
+ const merged = selectedSecondary ? [selectedSecondary, ...base.filter((t) => t.toLowerCase() !== selectedSecondary.toLowerCase())] : base;
6996
+ return merged.slice(0, 5);
6997
+ }, [keywordAnalysisState.analysis, selectedSecondary]);
6343
6998
  const refreshLinkingSuggestions = useCallback5(async () => {
6344
6999
  if (!text || text.trim().length < 50) return;
6345
7000
  if (!effectivePrimary) return;
@@ -6347,14 +7002,19 @@ function SEOCopilotInner({ config, onClose }) {
6347
7002
  setIsLinkingLoading(true);
6348
7003
  setLinkingError(null);
6349
7004
  try {
7005
+ linkingAbortRef.current?.abort();
7006
+ const linkingController = new AbortController();
7007
+ linkingAbortRef.current = linkingController;
6350
7008
  const suggestions = await fetchLinkingSuggestions(
6351
7009
  apiUrl,
6352
7010
  text,
6353
7011
  effectivePrimary,
6354
7012
  supportingKeywordsForLinking,
6355
7013
  documentId,
6356
- effectivePublication
7014
+ effectivePublication,
7015
+ linkingController.signal
6357
7016
  );
7017
+ if (linkingController.signal.aborted) return;
6358
7018
  if (linkingVersionRef.current !== myVersion) return;
6359
7019
  setLinkingSuggestions(suggestions);
6360
7020
  setLinkingFetchedText(text);
@@ -6370,7 +7030,7 @@ function SEOCopilotInner({ config, onClose }) {
6370
7030
  if (Math.abs(text.length - linkingFetchedText.length) > 150) return true;
6371
7031
  return text.slice(0, 300) !== linkingFetchedText.slice(0, 300);
6372
7032
  }, [text, linkingFetchedText, linkingSuggestions.length]);
6373
- useEffect10(() => {
7033
+ useEffect11(() => {
6374
7034
  if (!text || text.trim().length < 50 || !effectivePrimary) return;
6375
7035
  const fetchKey = `${documentId || "_"}|${effectivePrimary}|${supportingKeywordsForLinking.join(",")}`;
6376
7036
  if (fetchKey === lastLinkingFetchKey.current) return;
@@ -6386,9 +7046,9 @@ function SEOCopilotInner({ config, onClose }) {
6386
7046
  const [hasRunLinkCheck, setHasRunLinkCheck] = usePersistentState(`${linkCheckKey}-ran`, false);
6387
7047
  const [isLinkCheckLoading, setIsLinkCheckLoading] = useState16(false);
6388
7048
  const [linkCheckError, setLinkCheckError] = useState16(null);
6389
- const linkCheckVersionRef = useRef10(0);
6390
- const didInitLinkCheckRef = useRef10(false);
6391
- useEffect10(() => {
7049
+ const linkCheckVersionRef = useRef11(0);
7050
+ const didInitLinkCheckRef = useRef11(false);
7051
+ useEffect11(() => {
6392
7052
  if (!didInitLinkCheckRef.current) {
6393
7053
  didInitLinkCheckRef.current = true;
6394
7054
  return;
@@ -6423,6 +7083,14 @@ function SEOCopilotInner({ config, onClose }) {
6423
7083
  if (linkCheckVersionRef.current !== myVersion) return;
6424
7084
  setIsLinkCheckLoading(false);
6425
7085
  }, [apiUrl, documentFields?.bodyLinks, setHasRunLinkCheck, setLinkCheckResults]);
7086
+ useEffect11(() => {
7087
+ return () => {
7088
+ activeDragCleanupRef.current?.();
7089
+ activeResizeCleanupRef.current?.();
7090
+ csAbortRef.current?.abort();
7091
+ linkingAbortRef.current?.abort();
7092
+ };
7093
+ }, []);
6426
7094
  const handleDragStart = useCallback5(
6427
7095
  (e) => {
6428
7096
  dragOffset.current = {
@@ -6437,6 +7105,7 @@ function SEOCopilotInner({ config, onClose }) {
6437
7105
  });
6438
7106
  };
6439
7107
  const onMouseUp = () => {
7108
+ activeDragCleanupRef.current = null;
6440
7109
  dragOffset.current = null;
6441
7110
  window.removeEventListener("mousemove", onMouseMove);
6442
7111
  window.removeEventListener("mouseup", onMouseUp);
@@ -6447,6 +7116,12 @@ function SEOCopilotInner({ config, onClose }) {
6447
7116
  document.body.style.userSelect = "none";
6448
7117
  window.addEventListener("mousemove", onMouseMove);
6449
7118
  window.addEventListener("mouseup", onMouseUp);
7119
+ activeDragCleanupRef.current = () => {
7120
+ window.removeEventListener("mousemove", onMouseMove);
7121
+ window.removeEventListener("mouseup", onMouseUp);
7122
+ document.body.style.cursor = "";
7123
+ document.body.style.userSelect = "";
7124
+ };
6450
7125
  },
6451
7126
  [floatPos]
6452
7127
  );
@@ -6464,6 +7139,7 @@ function SEOCopilotInner({ config, onClose }) {
6464
7139
  setFloatSize({ width: newW, height: newH });
6465
7140
  };
6466
7141
  const onMouseUp = () => {
7142
+ activeResizeCleanupRef.current = null;
6467
7143
  resizeStart.current = null;
6468
7144
  document.body.style.cursor = "";
6469
7145
  document.body.style.userSelect = "";
@@ -6472,10 +7148,16 @@ function SEOCopilotInner({ config, onClose }) {
6472
7148
  };
6473
7149
  window.addEventListener("mousemove", onMouseMove);
6474
7150
  window.addEventListener("mouseup", onMouseUp);
7151
+ activeResizeCleanupRef.current = () => {
7152
+ window.removeEventListener("mousemove", onMouseMove);
7153
+ window.removeEventListener("mouseup", onMouseUp);
7154
+ document.body.style.cursor = "";
7155
+ document.body.style.userSelect = "";
7156
+ };
6475
7157
  },
6476
7158
  [floatSize]
6477
7159
  );
6478
- const panelContent = /* @__PURE__ */ jsx15(
7160
+ const panelContent = /* @__PURE__ */ jsx16(
6479
7161
  PanelContent,
6480
7162
  {
6481
7163
  initialPublication: effectivePublication,
@@ -6495,8 +7177,12 @@ function SEOCopilotInner({ config, onClose }) {
6495
7177
  docLoading,
6496
7178
  documentFields,
6497
7179
  documentId,
7180
+ documentType,
7181
+ sanityBaseUrl,
6498
7182
  selectedPrimary,
6499
7183
  onSelectPrimary: setSelectedPrimary,
7184
+ selectedSecondary,
7185
+ onSelectSecondary: setSelectedSecondary,
6500
7186
  activeTab,
6501
7187
  onActiveTabChange: setActiveTab,
6502
7188
  chatOpen,
@@ -6558,7 +7244,7 @@ function SEOCopilotInner({ config, onClose }) {
6558
7244
  }
6559
7245
  }
6560
7246
  );
6561
- const floatingPanel = /* @__PURE__ */ jsxs14(
7247
+ const floatingPanel = /* @__PURE__ */ jsxs15(
6562
7248
  "div",
6563
7249
  {
6564
7250
  style: {
@@ -6576,7 +7262,7 @@ function SEOCopilotInner({ config, onClose }) {
6576
7262
  },
6577
7263
  children: [
6578
7264
  panelContent,
6579
- !isFullscreen && /* @__PURE__ */ jsx15(
7265
+ !isFullscreen && /* @__PURE__ */ jsx16(
6580
7266
  "div",
6581
7267
  {
6582
7268
  onMouseDown: handleResizeStart,
@@ -6591,9 +7277,9 @@ function SEOCopilotInner({ config, onClose }) {
6591
7277
  alignItems: "center",
6592
7278
  justifyContent: "center"
6593
7279
  },
6594
- children: /* @__PURE__ */ jsxs14("svg", { width: "10", height: "10", viewBox: "0 0 10 10", fill: "#9ca3af", children: [
6595
- /* @__PURE__ */ jsx15("path", { d: "M9 1v8H1", fill: "none", stroke: "#9ca3af", strokeWidth: "1.5", strokeLinecap: "round" }),
6596
- /* @__PURE__ */ jsx15("path", { d: "M9 5v4H5", fill: "none", stroke: "#9ca3af", strokeWidth: "1.5", strokeLinecap: "round" })
7280
+ children: /* @__PURE__ */ jsxs15("svg", { width: "10", height: "10", viewBox: "0 0 10 10", fill: "#9ca3af", children: [
7281
+ /* @__PURE__ */ jsx16("path", { d: "M9 1v8H1", fill: "none", stroke: "#9ca3af", strokeWidth: "1.5", strokeLinecap: "round" }),
7282
+ /* @__PURE__ */ jsx16("path", { d: "M9 5v4H5", fill: "none", stroke: "#9ca3af", strokeWidth: "1.5", strokeLinecap: "round" })
6597
7283
  ] })
6598
7284
  }
6599
7285
  )
@@ -6601,8 +7287,8 @@ function SEOCopilotInner({ config, onClose }) {
6601
7287
  }
6602
7288
  );
6603
7289
  if (isFloating) {
6604
- return /* @__PURE__ */ jsxs14(Fragment8, { children: [
6605
- /* @__PURE__ */ jsx15(
7290
+ return /* @__PURE__ */ jsxs15(Fragment9, { children: [
7291
+ /* @__PURE__ */ jsx16(
6606
7292
  "div",
6607
7293
  {
6608
7294
  style: {
@@ -6612,30 +7298,30 @@ function SEOCopilotInner({ config, onClose }) {
6612
7298
  alignItems: "center",
6613
7299
  justifyContent: "center"
6614
7300
  },
6615
- children: /* @__PURE__ */ jsx15("span", { style: { fontSize: 12, color: "rgba(0,0,0,0.5)" }, children: "SEO Copilot is floating" })
7301
+ children: /* @__PURE__ */ jsx16("span", { style: { fontSize: 12, color: "rgba(0,0,0,0.5)" }, children: "SEO Copilot is floating" })
6616
7302
  }
6617
7303
  ),
6618
7304
  typeof document !== "undefined" && createPortal(floatingPanel, document.body)
6619
7305
  ] });
6620
7306
  }
6621
- return /* @__PURE__ */ jsx15("div", { style: { height: "100%", background: PANEL_BG, position: "relative", zIndex: 1 }, children: panelContent });
7307
+ return /* @__PURE__ */ jsx16("div", { style: { height: "100%", background: PANEL_BG, position: "relative", zIndex: 1 }, children: panelContent });
6622
7308
  }
6623
7309
  function SEOCopilotPanel({ config, onClose }) {
6624
- return /* @__PURE__ */ jsx15(
7310
+ return /* @__PURE__ */ jsx16(
6625
7311
  Suspense,
6626
7312
  {
6627
- fallback: /* @__PURE__ */ jsxs14("div", { style: { padding: 16, display: "flex", alignItems: "center", gap: 12 }, children: [
6628
- /* @__PURE__ */ jsx15(LoadingBars, {}),
6629
- /* @__PURE__ */ jsx15("span", { style: { fontSize: 12, color: "#4b5563" }, children: "Loading SEO Copilot..." })
7313
+ fallback: /* @__PURE__ */ jsxs15("div", { style: { padding: 16, display: "flex", alignItems: "center", gap: 12 }, children: [
7314
+ /* @__PURE__ */ jsx16(LoadingBars, {}),
7315
+ /* @__PURE__ */ jsx16("span", { style: { fontSize: 12, color: "#4b5563" }, children: "Loading SEO Copilot..." })
6630
7316
  ] }),
6631
- children: /* @__PURE__ */ jsx15(ConfigProvider, { config, children: /* @__PURE__ */ jsx15(SEOCopilotInner, { config, onClose }) })
7317
+ children: /* @__PURE__ */ jsx16(ConfigProvider, { config, children: /* @__PURE__ */ jsx16(SEOCopilotInner, { config, onClose }) })
6632
7318
  }
6633
7319
  );
6634
7320
  }
6635
7321
  function LoadingBars({ size = "sm", color = MJH_GOLD }) {
6636
7322
  const barWidth = size === "xs" ? 4 : 6;
6637
7323
  const containerHeight = size === "xs" ? 10 : 14;
6638
- return /* @__PURE__ */ jsx15("div", { style: { display: "inline-flex", alignItems: "flex-end", gap: 2, height: containerHeight }, children: [1, 2, 3].map((i) => /* @__PURE__ */ jsx15(
7324
+ return /* @__PURE__ */ jsx16("div", { style: { display: "inline-flex", alignItems: "flex-end", gap: 2, height: containerHeight }, children: [1, 2, 3].map((i) => /* @__PURE__ */ jsx16(
6639
7325
  "div",
6640
7326
  {
6641
7327
  style: {
@@ -6693,8 +7379,7 @@ function seoCopilotInspector(config) {
6693
7379
  name: "seo-copilot",
6694
7380
  useMenuItem: () => ({
6695
7381
  title: "SEO Copilot",
6696
- icon: SEOIcon,
6697
- showAsAction: true
7382
+ icon: SEOIcon
6698
7383
  }),
6699
7384
  component: function SEOCopilotInspector(props) {
6700
7385
  return createElement(SEOCopilotPanel, { ...props, config });