@burdenoff/microfe-theculturepost 2026.1203.2 → 2026.1203.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/theculturepost/components/AiContextPanel.js +5 -5
- package/dist/theculturepost/components/AiContextPanel.js.map +1 -1
- package/dist/theculturepost/components/ArchiveItemCard.js +2 -2
- package/dist/theculturepost/components/ArchiveItemCard.js.map +1 -1
- package/dist/theculturepost/components/AudioRecorderControl.js +2 -2
- package/dist/theculturepost/components/AudioRecorderControl.js.map +1 -1
- package/dist/theculturepost/components/CollectionCard.js +2 -2
- package/dist/theculturepost/components/CollectionCard.js.map +1 -1
- package/dist/theculturepost/components/CommunityNorms.js +1 -1
- package/dist/theculturepost/components/CommunityNorms.js.map +1 -1
- package/dist/theculturepost/components/CreateStoryDialog.js +5 -5
- package/dist/theculturepost/components/CreateStoryDialog.js.map +1 -1
- package/dist/theculturepost/components/DiscussionCard.js +1 -1
- package/dist/theculturepost/components/DiscussionCard.js.map +1 -1
- package/dist/theculturepost/components/FileUploadField.js +1 -1
- package/dist/theculturepost/components/FileUploadField.js.map +1 -1
- package/dist/theculturepost/components/FilterTabs.js +1 -1
- package/dist/theculturepost/components/FilterTabs.js.map +1 -1
- package/dist/theculturepost/components/FollowButton.js +2 -2
- package/dist/theculturepost/components/FollowButton.js.map +1 -1
- package/dist/theculturepost/components/FramingPrompts.js +1 -1
- package/dist/theculturepost/components/FramingPrompts.js.map +1 -1
- package/dist/theculturepost/components/HistoryTimeline.js +3 -3
- package/dist/theculturepost/components/HistoryTimeline.js.map +1 -1
- package/dist/theculturepost/components/OpenDiscussionDialog.js +1 -1
- package/dist/theculturepost/components/OpenDiscussionDialog.js.map +1 -1
- package/dist/theculturepost/components/OverlayBadge.js +4 -4
- package/dist/theculturepost/components/OverlayBadge.js.map +1 -1
- package/dist/theculturepost/components/Pagination.js +2 -2
- package/dist/theculturepost/components/Pagination.js.map +1 -1
- package/dist/theculturepost/components/PendingOralHistoryPanel.js +2 -2
- package/dist/theculturepost/components/PendingOralHistoryPanel.js.map +1 -1
- package/dist/theculturepost/components/ReaderContextDrawer.js +1 -1
- package/dist/theculturepost/components/ReaderContextDrawer.js.map +1 -1
- package/dist/theculturepost/components/RecordOralHistoryDialog.js +2 -2
- package/dist/theculturepost/components/RecordOralHistoryDialog.js.map +1 -1
- package/dist/theculturepost/components/ReplyThread.js +2 -2
- package/dist/theculturepost/components/ReplyThread.js.map +1 -1
- package/dist/theculturepost/components/StoryCard.js +3 -3
- package/dist/theculturepost/components/StoryCard.js.map +1 -1
- package/dist/theculturepost/components/TopicCard.js +2 -2
- package/dist/theculturepost/components/TopicCard.js.map +1 -1
- package/dist/theculturepost/components/TopicTimelineWidget.js +1 -1
- package/dist/theculturepost/components/TopicTimelineWidget.js.map +1 -1
- package/dist/theculturepost/pages/HomePage.js +6 -6
- package/dist/theculturepost/pages/HomePage.js.map +1 -1
- package/dist/theculturepost/pages/archive/ArchiveItemDetailPage.js +8 -8
- package/dist/theculturepost/pages/archive/ArchiveItemDetailPage.js.map +1 -1
- package/dist/theculturepost/pages/archive/ArchivePage.js +8 -8
- package/dist/theculturepost/pages/archive/ArchivePage.js.map +1 -1
- package/dist/theculturepost/pages/archive/CollectionDetailPage.js +6 -6
- package/dist/theculturepost/pages/archive/CollectionDetailPage.js.map +1 -1
- package/dist/theculturepost/pages/curriculum/CurriculumPage.js +5 -5
- package/dist/theculturepost/pages/curriculum/CurriculumPage.js.map +1 -1
- package/dist/theculturepost/pages/discussions/DiscussionDetailPage.js +3 -3
- package/dist/theculturepost/pages/discussions/DiscussionDetailPage.js.map +1 -1
- package/dist/theculturepost/pages/discussions/DiscussionsPage.js +2 -2
- package/dist/theculturepost/pages/discussions/DiscussionsPage.js.map +1 -1
- package/dist/theculturepost/pages/governance/AiOpsPanel.js +5 -5
- package/dist/theculturepost/pages/governance/AiOpsPanel.js.map +1 -1
- package/dist/theculturepost/pages/stories/StoriesPage.js +3 -3
- package/dist/theculturepost/pages/stories/StoriesPage.js.map +1 -1
- package/dist/theculturepost/pages/stories/StoryCitationsPage.js +5 -5
- package/dist/theculturepost/pages/stories/StoryCitationsPage.js.map +1 -1
- package/dist/theculturepost/pages/stories/StoryDetailPage.js +17 -17
- package/dist/theculturepost/pages/stories/StoryDetailPage.js.map +1 -1
- package/dist/theculturepost/pages/studio/ContributorStudioPage.js +5 -5
- package/dist/theculturepost/pages/studio/ContributorStudioPage.js.map +1 -1
- package/dist/theculturepost/pages/timeline/TimelinePage.js +2 -2
- package/dist/theculturepost/pages/timeline/TimelinePage.js.map +1 -1
- package/dist/theculturepost/pages/topics/TopicDetailPage.js +5 -5
- package/dist/theculturepost/pages/topics/TopicDetailPage.js.map +1 -1
- package/dist/theculturepost/pages/topics/TopicsPage.js +1 -1
- package/dist/theculturepost/pages/topics/TopicsPage.js.map +1 -1
- package/package.json +5 -3
|
@@ -116,7 +116,7 @@ function I({ open: e, onOpenChange: t, useCase: n, storyId: r, collectionId: i,
|
|
|
116
116
|
onClick: C,
|
|
117
117
|
disabled: d.isPending || !f.trim(),
|
|
118
118
|
children: [/* @__PURE__ */ b(_, {
|
|
119
|
-
className: "
|
|
119
|
+
className: "me-1.5 h-4 w-4",
|
|
120
120
|
"aria-hidden": "true"
|
|
121
121
|
}), d.isPending ? "Generating…" : "Generate"]
|
|
122
122
|
})] }) })
|
|
@@ -156,7 +156,7 @@ function R({ run: e, canReview: n = !0, defaultExpanded: r = !1, onReviewed: i }
|
|
|
156
156
|
children: ["Uncertainty: ", f(e.uncertainty)]
|
|
157
157
|
}),
|
|
158
158
|
/* @__PURE__ */ b("span", {
|
|
159
|
-
className: "
|
|
159
|
+
className: "ms-auto text-xs text-text-tertiary",
|
|
160
160
|
children: p(e.createdAt)
|
|
161
161
|
})
|
|
162
162
|
]
|
|
@@ -225,7 +225,7 @@ function R({ run: e, canReview: n = !0, defaultExpanded: r = !1, onReviewed: i }
|
|
|
225
225
|
disabled: a.isPending,
|
|
226
226
|
"aria-label": "Approve AI answer",
|
|
227
227
|
children: [/* @__PURE__ */ b(g, {
|
|
228
|
-
className: "
|
|
228
|
+
className: "me-1.5 h-4 w-4",
|
|
229
229
|
"aria-hidden": "true"
|
|
230
230
|
}), " Approve"]
|
|
231
231
|
}), /* @__PURE__ */ x(S, {
|
|
@@ -235,7 +235,7 @@ function R({ run: e, canReview: n = !0, defaultExpanded: r = !1, onReviewed: i }
|
|
|
235
235
|
disabled: a.isPending,
|
|
236
236
|
"aria-label": "Reject AI answer",
|
|
237
237
|
children: [/* @__PURE__ */ b(v, {
|
|
238
|
-
className: "
|
|
238
|
+
className: "me-1.5 h-4 w-4",
|
|
239
239
|
"aria-hidden": "true"
|
|
240
240
|
}), " Reject"]
|
|
241
241
|
})]
|
|
@@ -286,7 +286,7 @@ function z({ storyId: t, collectionId: o, oralHistoryId: s, useCases: c, title:
|
|
|
286
286
|
variant: "outline",
|
|
287
287
|
onClick: () => D(e),
|
|
288
288
|
children: [/* @__PURE__ */ b(_, {
|
|
289
|
-
className: "
|
|
289
|
+
className: "me-1.5 h-4 w-4",
|
|
290
290
|
"aria-hidden": "true"
|
|
291
291
|
}), N[e]]
|
|
292
292
|
}, e))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiContextPanel.js","names":["_Fragment","Fragment$1","AI_USE_CASE_LABELS","DEFAULT_PROMPTS","GROUNDING_KIND_LABELS","GenerateAiContextDialog","generate","useTcpGenerateAiContext","prompt","setPrompt","useState","useCase","run","setRun","reset","nextOpen","onOpenChange","submit","input","storyId","collectionId","oralHistoryId","created","onGenerated","error","describeError","statusNote","ResponsiveDialog","ResponsiveDialogContent","ResponsiveDialogHeader","ResponsiveDialogTitle","ResponsiveDialogDescription","AiRunCard","Label","Textarea","event","ResponsiveDialogFooter","Button","Sparkles","UNCERTAINTY_BADGE","review","useTcpReviewAiContext","notes","setNotes","expanded","setExpanded","defaultExpanded","decide","updated","onReviewed","notify","approved","GlassCard","StatusBadge","formatEnumLabel","formatRelativeTime","value","ref","canReview","isReviewableAiRun","Check","X","AiContextSection","useTheCulturePost","permissions","useSafePermissions","resolveAiContextPermissions","workspaceId","activeUseCase","setActiveUseCase","listable","canRead","runsQuery","useTcpAiContextRuns","canCreate","runs","pendingCount","FeatureGate","className","title","description","useCases","LoadingView","ErrorView","EmptyState","open","AiReviewQueue","AiReviewQueueContent","items"],"sources":["../../../src/theculturepost/components/AiContextPanel.tsx"],"sourcesContent":["/**\n * AiContextPanel — in-app UI for the citation-grounded AI context layer.\n * @module theculturepost/components\n *\n * Surfaces the `tcpGenerateAiContext` / `tcpReviewAiContext` / `tcpAiContextRuns`\n * operations (BOFF-4127) so editors can generate, review and adopt\n * citation-grounded answers without leaving the story, collection or oral\n * history screen (BOFF-5805).\n *\n * Floors stay server-side: generation is feature-flagged, grounding only ever\n * reads PUBLIC/COMMUNITY sources, and every run lands PENDING until a human\n * approves or rejects it. This UI only calls those operations and renders\n * their results — RBAC and access-tier denials surface as errors.\n */\n\nimport { useState } from 'react';\nimport { Check, Sparkles, X } from 'lucide-react';\nimport { FeatureGate } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { useSafePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport {\n Button,\n GlassCard,\n Label,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n Textarea,\n} from '@burdenoff/fe-libs/ui';\nimport { StatusBadge } from './StatusBadge';\nimport { EmptyState } from './EmptyState';\nimport { LoadingView, ErrorView } from './StateViews';\nimport { useTheCulturePost } from '../context';\nimport { useTcpAiContextRuns, useTcpGenerateAiContext, useTcpReviewAiContext } from '../hooks';\nimport { notify, describeError } from '../lib/toast';\nimport { isReviewableAiRun, resolveAiContextPermissions } from '../utils/aiContextPermissions';\nimport { formatEnumLabel, formatRelativeTime } from '../utils/formatters';\nimport type {\n TcpAgentRun,\n TcpAiGroundingKind,\n TcpAiUseCase,\n TcpGenerateAiContextInput,\n} from '../types';\n\n// ============================================================================\n// Per-use-case presentation metadata (labels + default prompts)\n// ============================================================================\n\nexport const AI_USE_CASE_LABELS: Record<TcpAiUseCase, string> = {\n SUMMARIZE_EVIDENCE: 'Summarise evidence',\n DRAFT_FRAMING_PROMPT: 'Draft framing',\n SUGGEST_RELATED_TRADITIONS: 'Find related traditions',\n TRANSCRIBE_ORAL_HISTORY: 'Clean up transcript',\n VERIFY_CITATION: 'Verify citation proposal',\n ASSESS_SOURCE_HEALTH: 'Assess source health',\n SENSITIVITY_FRAMING: 'Sensitivity framing review',\n EXPLAIN_TERM: 'Explain term',\n TRANSLATE_STORY: 'Translate story draft',\n EDITORIAL_SWEEP: 'Editorial sweep',\n ANALYZE_ARCHIVE_IMAGE: 'Analyze archive image',\n GENERATE_SUBTITLES: 'Generate subtitles',\n SPEECH_TO_TEXT: 'Speech-to-text transcript',\n};\n\nconst DEFAULT_PROMPTS: Record<TcpAiUseCase, string> = {\n SUMMARIZE_EVIDENCE: 'What do the cited sources say about this story’s central claims?',\n DRAFT_FRAMING_PROMPT:\n 'Draft a short framing question that an editor could put to the cited sources.',\n SUGGEST_RELATED_TRADITIONS:\n 'Which traditions or practices in this collection relate to each other, and why?',\n TRANSCRIBE_ORAL_HISTORY:\n 'Clean up and format this transcript: fix punctuation and paragraph breaks, and mark speaker turns — do not add any content that is not in the original.',\n VERIFY_CITATION: 'Propose a verification status grounded strictly in this citation and excerpt.',\n ASSESS_SOURCE_HEALTH: 'Assess reachability and strength of all citations on this story.',\n SENSITIVITY_FRAMING: 'Flag any framing concerns with respectful reframing suggestions.',\n EXPLAIN_TERM: 'Explain this term using only eligible workspace sources, or abstain.',\n TRANSLATE_STORY: 'Draft a reviewable translation of this story into the requested locale.',\n EDITORIAL_SWEEP: 'Run scheduled source-health, review-queue, and embargo watch sweep.',\n ANALYZE_ARCHIVE_IMAGE:\n 'Propose respectful archival description and candidate tags for this image.',\n GENERATE_SUBTITLES: 'Draft WebVTT subtitles from consented oral history testimony.',\n SPEECH_TO_TEXT: 'Draft speech-to-text transcript proposal for editorial review.',\n};\n\nconst GROUNDING_KIND_LABELS: Record<TcpAiGroundingKind, string> = {\n CITATION: 'Citation',\n ARCHIVE_ITEM: 'Artifact',\n ORAL_HISTORY: 'Oral history',\n};\n\n// ============================================================================\n// Generate dialog\n// ============================================================================\n\nexport interface GenerateAiContextDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Preselected use case. Locked to this single action. */\n useCase: TcpAiUseCase;\n /** Exactly one grounding scope, matching the svc input contract. */\n storyId?: string;\n collectionId?: string;\n oralHistoryId?: string;\n /** Whether the caller holds `theculturepost-ai-context:update` to review inline. */\n canReview?: boolean;\n onGenerated?: (run: TcpAgentRun) => void;\n}\n\nexport function GenerateAiContextDialog({\n open,\n onOpenChange,\n useCase,\n storyId,\n collectionId,\n oralHistoryId,\n canReview = true,\n onGenerated,\n}: GenerateAiContextDialogProps) {\n const generate = useTcpGenerateAiContext();\n const [prompt, setPrompt] = useState(() => DEFAULT_PROMPTS[useCase]);\n const [run, setRun] = useState<TcpAgentRun | null>(null);\n\n const reset = (nextOpen: boolean) => {\n if (!nextOpen) {\n setPrompt(DEFAULT_PROMPTS[useCase]);\n setRun(null);\n generate.reset();\n }\n onOpenChange(nextOpen);\n };\n\n const submit = async () => {\n const input: TcpGenerateAiContextInput = {\n useCase,\n prompt: prompt.trim(),\n storyId: storyId ?? null,\n collectionId: collectionId ?? null,\n oralHistoryId: oralHistoryId ?? null,\n };\n try {\n const created = await generate.mutateAsync(input);\n setRun(created);\n onGenerated?.(created);\n } catch (error) {\n notify.error('Generation failed', describeError(error));\n }\n };\n\n const statusNote =\n run?.reviewStatus === 'APPROVED'\n ? 'Run approved — recorded in the editorial log.'\n : run?.reviewStatus === 'REJECTED'\n ? 'Run rejected — kept on record.'\n : 'Run created — it is awaiting editorial review.';\n\n return (\n <ResponsiveDialog open={open} onOpenChange={reset}>\n <ResponsiveDialogContent className=\"sm:max-w-xl\">\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>{AI_USE_CASE_LABELS[useCase]}</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n Runs on this product’s AI answer only from sources you can read (PUBLIC/COMMUNITY).\n Every run starts as pending editorial review — nothing is adopted automatically.\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n\n {run ? (\n <div className=\"flex flex-col gap-4\">\n <p className=\"text-sm text-text-secondary\">{statusNote}</p>\n <AiRunCard run={run} canReview={canReview} defaultExpanded onReviewed={setRun} />\n </div>\n ) : (\n <div className=\"flex flex-col gap-2\">\n <Label htmlFor=\"ai-context-prompt\">Your question or instruction</Label>\n <Textarea\n id=\"ai-context-prompt\"\n value={prompt}\n onChange={(event) => setPrompt(event.target.value)}\n rows={4}\n disabled={generate.isPending}\n />\n <p className=\"text-xs text-text-tertiary\">\n Combined server-side with the grounded sources — never sent to the model alone.\n </p>\n </div>\n )}\n\n <ResponsiveDialogFooter>\n {run ? (\n <Button onClick={() => reset(false)}>Done</Button>\n ) : (\n <>\n <Button variant=\"outline\" onClick={() => reset(false)} disabled={generate.isPending}>\n Cancel\n </Button>\n <Button onClick={submit} disabled={generate.isPending || !prompt.trim()}>\n <Sparkles className=\"mr-1.5 h-4 w-4\" aria-hidden=\"true\" />\n {generate.isPending ? 'Generating…' : 'Generate'}\n </Button>\n </>\n )}\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n}\n\n// ============================================================================\n// Run card (list item + inline review)\n// ============================================================================\n\nconst UNCERTAINTY_BADGE: Record<string, 'success' | 'warning' | 'destructive'> = {\n LOW: 'success',\n MEDIUM: 'warning',\n HIGH: 'destructive',\n};\n\nexport interface AiRunCardProps {\n run: TcpAgentRun;\n canReview?: boolean;\n defaultExpanded?: boolean;\n onReviewed?: (updated: TcpAgentRun) => void;\n}\n\nexport function AiRunCard({\n run,\n canReview = true,\n defaultExpanded = false,\n onReviewed,\n}: AiRunCardProps) {\n const review = useTcpReviewAiContext();\n const [notes, setNotes] = useState('');\n const [expanded, setExpanded] = useState(defaultExpanded);\n\n const decide = async (approved: boolean) => {\n try {\n const updated = await review.mutateAsync({\n id: run.id,\n approved,\n reviewNotes: notes.trim() || undefined,\n });\n onReviewed?.(updated);\n notify.success(\n approved ? 'AI answer approved' : 'AI answer rejected',\n approved ? 'It is now marked as reviewed.' : 'The run stays on record as rejected.'\n );\n } catch (error) {\n notify.error('Review failed', describeError(error));\n }\n };\n\n return (\n <GlassCard treatment=\"plain\" className=\"flex flex-col gap-3 p-4\">\n <div className=\"flex flex-wrap items-center gap-1.5\">\n <StatusBadge status={run.useCase} />\n {run.status === 'FAILED' ? (\n <StatusBadge status=\"FAILED\" />\n ) : (\n <StatusBadge status={run.reviewStatus} />\n )}\n {run.uncertainty && (\n <span\n className={`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${\n UNCERTAINTY_BADGE[run.uncertainty] === 'success'\n ? 'bg-status-success-bg-subtle text-status-success-text'\n : UNCERTAINTY_BADGE[run.uncertainty] === 'destructive'\n ? 'bg-status-error-bg-subtle text-status-error-text'\n : 'bg-status-warning-bg-subtle text-status-warning-text'\n }`}\n >\n Uncertainty: {formatEnumLabel(run.uncertainty)}\n </span>\n )}\n <span className=\"ml-auto text-xs text-text-tertiary\">\n {formatRelativeTime(run.createdAt)}\n </span>\n </div>\n\n <p className=\"text-sm text-text-secondary\">\n <span className=\"font-medium text-text-primary\">Prompt: </span>\n {run.promptSummary}\n </p>\n\n {run.error && (\n <p className=\"rounded-lg bg-status-error-bg-subtle p-2 text-xs text-status-error-text\">\n {run.error}\n </p>\n )}\n\n {run.content && (\n <div>\n <button\n type=\"button\"\n onClick={() => setExpanded((value) => !value)}\n className=\"text-xs font-medium text-text-secondary underline-offset-2 hover:underline\"\n >\n {expanded ? 'Hide answer' : 'Show answer'}\n </button>\n {expanded && (\n <p className=\"mt-2 whitespace-pre-wrap rounded-lg bg-bg-sunken p-3 text-sm text-text-primary\">\n {run.content}\n </p>\n )}\n </div>\n )}\n\n {run.groundingRefs.length > 0 && (\n <div className=\"flex flex-col gap-1.5\">\n <p className=\"text-xs font-medium text-text-tertiary\">\n Grounded in ({run.groundingRefs.length} sources)\n </p>\n <ul className=\"flex flex-wrap gap-1.5\">\n {run.groundingRefs.map((ref) => (\n <li\n key={`${ref.kind}-${ref.refId}`}\n className=\"inline-flex max-w-full items-center gap-1 rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs text-text-secondary\"\n title={ref.title}\n >\n <span className=\"shrink-0 font-medium\">\n {GROUNDING_KIND_LABELS[ref.kind] ?? formatEnumLabel(ref.kind)}\n </span>\n <span className=\"truncate\">{ref.title}</span>\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {run.reviewStatus !== 'PENDING' && (run.reviewNotes || run.reviewedAt) && (\n <p className=\"text-xs text-text-tertiary\">\n {run.reviewStatus === 'APPROVED' ? 'Approved' : 'Rejected'}\n {run.reviewNotes ? ` — ${run.reviewNotes}` : ''}\n </p>\n )}\n\n {canReview && isReviewableAiRun(run) && (\n <div className=\"flex flex-col gap-2 border-t border-border-seam pt-3\">\n <Textarea\n value={notes}\n onChange={(event) => setNotes(event.target.value)}\n rows={2}\n placeholder=\"Review notes (optional)\"\n disabled={review.isPending}\n />\n <div className=\"flex gap-2\">\n <Button\n size=\"sm\"\n onClick={() => decide(true)}\n disabled={review.isPending}\n aria-label=\"Approve AI answer\"\n >\n <Check className=\"mr-1.5 h-4 w-4\" aria-hidden=\"true\" /> Approve\n </Button>\n <Button\n size=\"sm\"\n variant=\"outline\"\n onClick={() => decide(false)}\n disabled={review.isPending}\n aria-label=\"Reject AI answer\"\n >\n <X className=\"mr-1.5 h-4 w-4\" aria-hidden=\"true\" /> Reject\n </Button>\n </div>\n </div>\n )}\n </GlassCard>\n );\n}\n\n// ============================================================================\n// Section: action buttons + run list for one grounding scope\n// ============================================================================\n\nexport interface AiContextSectionProps {\n /** Story-scoped use cases (SUMMARIZE_EVIDENCE, DRAFT_FRAMING_PROMPT). */\n storyId?: string;\n /** Collection-scoped use cases (SUGGEST_RELATED_TRADITIONS). */\n collectionId?: string;\n /** Oral-history use case (TRANSCRIBE_ORAL_HISTORY) — action only, no run list\n * filter exists for oral histories server-side. */\n oralHistoryId?: string;\n useCases: TcpAiUseCase[];\n title?: string;\n description?: string;\n className?: string;\n}\n\nexport function AiContextSection({\n storyId,\n collectionId,\n oralHistoryId,\n useCases,\n title = 'AI assistant',\n description = 'Citation-grounded answers from sources you can read. Every answer waits for editorial review before adoption.',\n className,\n}: AiContextSectionProps) {\n const { workspaceId } = useTheCulturePost();\n const permissions = useSafePermissions();\n const { canRead, canCreate, canReview } = resolveAiContextPermissions(permissions, workspaceId);\n const [activeUseCase, setActiveUseCase] = useState<TcpAiUseCase | null>(null);\n // Runs are listable per story or collection; the svc has no oralHistoryId filter.\n const listable = Boolean(storyId || collectionId) && canRead;\n const runsQuery = useTcpAiContextRuns({\n storyId,\n collectionId,\n pagination: { limit: 10 },\n enabled: listable,\n });\n\n if (!canRead && !canCreate) {\n return null;\n }\n\n const runs = listable ? (runsQuery.data?.items ?? []) : [];\n const pendingCount = runs.filter(isReviewableAiRun).length;\n\n return (\n <FeatureGate flag=\"theculturepost.ai-context\" defaultValue fallback={null}>\n <GlassCard treatment=\"plain\" className={`flex flex-col gap-4 p-5 sm:p-6 ${className ?? ''}`}>\n <div className=\"flex flex-wrap items-start justify-between gap-3\">\n <div>\n <h2 className=\"flex items-center gap-2 font-display text-xl font-semibold text-text-primary\">\n <Sparkles className=\"h-5 w-5 text-accent\" aria-hidden=\"true\" /> {title}\n {pendingCount > 0 && (\n <span className=\"rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-xs font-medium text-status-warning-text\">\n {pendingCount} pending\n </span>\n )}\n </h2>\n <p className=\"mt-1 text-sm text-text-secondary\">{description}</p>\n </div>\n {canCreate && (\n <div className=\"flex flex-wrap gap-2\">\n {useCases.map((useCase) => (\n <Button key={useCase} variant=\"outline\" onClick={() => setActiveUseCase(useCase)}>\n <Sparkles className=\"mr-1.5 h-4 w-4\" aria-hidden=\"true\" />\n {AI_USE_CASE_LABELS[useCase]}\n </Button>\n ))}\n </div>\n )}\n </div>\n\n {listable &&\n (runsQuery.isLoading ? (\n <LoadingView label=\"Loading AI runs…\" />\n ) : runsQuery.isError ? (\n <ErrorView title=\"Could not load AI runs\" onRetry={() => runsQuery.refetch()} />\n ) : runs.length === 0 ? (\n <EmptyState\n icon={<Sparkles className=\"h-9 w-9\" />}\n title=\"No AI runs yet\"\n description={\n canCreate\n ? 'Run one of the actions above to draft a citation-grounded answer.'\n : 'No citation-grounded AI runs have been created for this scope yet.'\n }\n />\n ) : (\n <div className=\"flex flex-col gap-3\">\n {runs.map((run) => (\n <AiRunCard key={run.id} run={run} canReview={canReview} />\n ))}\n </div>\n ))}\n\n {activeUseCase && (\n <GenerateAiContextDialog\n open\n onOpenChange={(open) => {\n if (!open) setActiveUseCase(null);\n }}\n useCase={activeUseCase}\n storyId={storyId}\n collectionId={collectionId}\n oralHistoryId={oralHistoryId}\n canReview={canReview}\n />\n )}\n </GlassCard>\n </FeatureGate>\n );\n}\n\n// ============================================================================\n// Editorial review queue (workspace-wide, StoriesPage overview)\n// ============================================================================\n\nexport function AiReviewQueue({ className }: { className?: string }) {\n const { workspaceId } = useTheCulturePost();\n const permissions = useSafePermissions();\n const { canRead, canReview } = resolveAiContextPermissions(permissions, workspaceId);\n\n if (!canRead) {\n return null;\n }\n\n return (\n <FeatureGate flag=\"theculturepost.ai-context\" defaultValue fallback={null}>\n <AiReviewQueueContent className={className} canReview={canReview} />\n </FeatureGate>\n );\n}\n\nfunction AiReviewQueueContent({\n className,\n canReview,\n}: {\n className?: string;\n canReview: boolean;\n}) {\n const runsQuery = useTcpAiContextRuns({ pagination: { limit: 50 } });\n const items = (runsQuery.data?.items ?? []).filter(isReviewableAiRun);\n\n if (runsQuery.isLoading) {\n return <LoadingView label=\"Loading AI review queue…\" />;\n }\n if (runsQuery.isError) {\n return (\n <ErrorView title=\"Could not load the AI review queue\" onRetry={() => runsQuery.refetch()} />\n );\n }\n if (items.length === 0) {\n return null;\n }\n\n return (\n <GlassCard treatment=\"plain\" className={`flex flex-col gap-3 p-5 sm:p-6 ${className ?? ''}`}>\n <h2 className=\"flex items-center gap-2 font-display text-xl font-semibold text-text-primary\">\n <Sparkles className=\"h-5 w-5 text-accent\" aria-hidden=\"true\" /> AI review queue\n <span className=\"rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-xs font-medium text-status-warning-text\">\n {items.length} pending\n </span>\n </h2>\n <p className=\"text-sm text-text-secondary\">\n Generated answers awaiting an editorial decision, newest first. Approve or reject them here,\n or in place on the story or collection they belong to.\n </p>\n <div className=\"flex flex-col gap-3\">\n {items.slice(0, 5).map((run) => (\n <AiRunCard key={run.id} run={run} canReview={canReview} />\n ))}\n {items.length > 5 && (\n <p className=\"text-xs text-text-tertiary\">\n {items.length - 5} more pending — open the story or collection they belong to review\n them in place.\n </p>\n )}\n </div>\n </GlassCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkDA,IAAaE,IAAmD;CAC9D,oBAAoB;CACpB,sBAAsB;CACtB,4BAA4B;CAC5B,yBAAyB;CACzB,iBAAiB;CACjB,sBAAsB;CACtB,qBAAqB;CACrB,cAAc;CACd,iBAAiB;CACjB,iBAAiB;CACjB,uBAAuB;CACvB,oBAAoB;CACpB,gBAAgB;AAClB,GAEMC,IAAgD;CACpD,oBAAoB;CACpB,sBACE;CACF,4BACE;CACF,yBACE;CACF,iBAAiB;CACjB,sBAAsB;CACtB,qBAAqB;CACrB,cAAc;CACd,iBAAiB;CACjB,iBAAiB;CACjB,uBACE;CACF,oBAAoB;CACpB,gBAAgB;AAClB,GAEMC,IAA4D;CAChE,UAAU;CACV,cAAc;CACd,cAAc;AAChB;AAoBA,SAAgBC,EAAwB,EACtC,SACA,iBACA,YACA,YACA,iBACA,kBACA,eAAY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AAd,UAAA;KACE,kBAACxC,GAAD;MAAU,WAAU;MAAsB,eAAY;KAAQ,CAAA;KAAC;KAC/D,kBAAC,QAAD;MAAM,WAAU;MAAhB,UAAA,CACGkD,EAAM,QAAO,UACV;;IACJ;;GACJ,kBAAC,KAAD;IAAG,WAAU;IAA8B,UAAA;GAGxC,CAAA;GACH,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACGA,EAAM,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,MACtB,kBAACxD,GAAD;KAA6B;KAAgB;IAAY,GAAzCpB,EAAI,EAAqC,CAC1D,GACA4E,EAAM,SAAS,KACd,kBAAC,KAAD;KAAG,WAAU;KAAb,UAAA,CACGA,EAAM,SAAS,GAAE,mFAEjB;IAEF,CAAA,CAAA;;EACI;;AAEf"}
|
|
1
|
+
{"version":3,"file":"AiContextPanel.js","names":["_Fragment","Fragment$1","AI_USE_CASE_LABELS","DEFAULT_PROMPTS","GROUNDING_KIND_LABELS","GenerateAiContextDialog","generate","useTcpGenerateAiContext","prompt","setPrompt","useState","useCase","run","setRun","reset","nextOpen","onOpenChange","submit","input","storyId","collectionId","oralHistoryId","created","onGenerated","error","describeError","statusNote","ResponsiveDialog","ResponsiveDialogContent","ResponsiveDialogHeader","ResponsiveDialogTitle","ResponsiveDialogDescription","AiRunCard","Label","Textarea","event","ResponsiveDialogFooter","Button","Sparkles","UNCERTAINTY_BADGE","review","useTcpReviewAiContext","notes","setNotes","expanded","setExpanded","defaultExpanded","decide","updated","onReviewed","notify","approved","GlassCard","StatusBadge","formatEnumLabel","formatRelativeTime","value","ref","canReview","isReviewableAiRun","Check","X","AiContextSection","useTheCulturePost","permissions","useSafePermissions","resolveAiContextPermissions","workspaceId","activeUseCase","setActiveUseCase","listable","canRead","runsQuery","useTcpAiContextRuns","canCreate","runs","pendingCount","FeatureGate","className","title","description","useCases","LoadingView","ErrorView","EmptyState","open","AiReviewQueue","AiReviewQueueContent","items"],"sources":["../../../src/theculturepost/components/AiContextPanel.tsx"],"sourcesContent":["/**\n * AiContextPanel — in-app UI for the citation-grounded AI context layer.\n * @module theculturepost/components\n *\n * Surfaces the `tcpGenerateAiContext` / `tcpReviewAiContext` / `tcpAiContextRuns`\n * operations (BOFF-4127) so editors can generate, review and adopt\n * citation-grounded answers without leaving the story, collection or oral\n * history screen (BOFF-5805).\n *\n * Floors stay server-side: generation is feature-flagged, grounding only ever\n * reads PUBLIC/COMMUNITY sources, and every run lands PENDING until a human\n * approves or rejects it. This UI only calls those operations and renders\n * their results — RBAC and access-tier denials surface as errors.\n */\n\nimport { useState } from 'react';\nimport { Check, Sparkles, X } from 'lucide-react';\nimport { FeatureGate } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { useSafePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport {\n Button,\n GlassCard,\n Label,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n Textarea,\n} from '@burdenoff/fe-libs/ui';\nimport { StatusBadge } from './StatusBadge';\nimport { EmptyState } from './EmptyState';\nimport { LoadingView, ErrorView } from './StateViews';\nimport { useTheCulturePost } from '../context';\nimport { useTcpAiContextRuns, useTcpGenerateAiContext, useTcpReviewAiContext } from '../hooks';\nimport { notify, describeError } from '../lib/toast';\nimport { isReviewableAiRun, resolveAiContextPermissions } from '../utils/aiContextPermissions';\nimport { formatEnumLabel, formatRelativeTime } from '../utils/formatters';\nimport type {\n TcpAgentRun,\n TcpAiGroundingKind,\n TcpAiUseCase,\n TcpGenerateAiContextInput,\n} from '../types';\n\n// ============================================================================\n// Per-use-case presentation metadata (labels + default prompts)\n// ============================================================================\n\nexport const AI_USE_CASE_LABELS: Record<TcpAiUseCase, string> = {\n SUMMARIZE_EVIDENCE: 'Summarise evidence',\n DRAFT_FRAMING_PROMPT: 'Draft framing',\n SUGGEST_RELATED_TRADITIONS: 'Find related traditions',\n TRANSCRIBE_ORAL_HISTORY: 'Clean up transcript',\n VERIFY_CITATION: 'Verify citation proposal',\n ASSESS_SOURCE_HEALTH: 'Assess source health',\n SENSITIVITY_FRAMING: 'Sensitivity framing review',\n EXPLAIN_TERM: 'Explain term',\n TRANSLATE_STORY: 'Translate story draft',\n EDITORIAL_SWEEP: 'Editorial sweep',\n ANALYZE_ARCHIVE_IMAGE: 'Analyze archive image',\n GENERATE_SUBTITLES: 'Generate subtitles',\n SPEECH_TO_TEXT: 'Speech-to-text transcript',\n};\n\nconst DEFAULT_PROMPTS: Record<TcpAiUseCase, string> = {\n SUMMARIZE_EVIDENCE: 'What do the cited sources say about this story’s central claims?',\n DRAFT_FRAMING_PROMPT:\n 'Draft a short framing question that an editor could put to the cited sources.',\n SUGGEST_RELATED_TRADITIONS:\n 'Which traditions or practices in this collection relate to each other, and why?',\n TRANSCRIBE_ORAL_HISTORY:\n 'Clean up and format this transcript: fix punctuation and paragraph breaks, and mark speaker turns — do not add any content that is not in the original.',\n VERIFY_CITATION: 'Propose a verification status grounded strictly in this citation and excerpt.',\n ASSESS_SOURCE_HEALTH: 'Assess reachability and strength of all citations on this story.',\n SENSITIVITY_FRAMING: 'Flag any framing concerns with respectful reframing suggestions.',\n EXPLAIN_TERM: 'Explain this term using only eligible workspace sources, or abstain.',\n TRANSLATE_STORY: 'Draft a reviewable translation of this story into the requested locale.',\n EDITORIAL_SWEEP: 'Run scheduled source-health, review-queue, and embargo watch sweep.',\n ANALYZE_ARCHIVE_IMAGE:\n 'Propose respectful archival description and candidate tags for this image.',\n GENERATE_SUBTITLES: 'Draft WebVTT subtitles from consented oral history testimony.',\n SPEECH_TO_TEXT: 'Draft speech-to-text transcript proposal for editorial review.',\n};\n\nconst GROUNDING_KIND_LABELS: Record<TcpAiGroundingKind, string> = {\n CITATION: 'Citation',\n ARCHIVE_ITEM: 'Artifact',\n ORAL_HISTORY: 'Oral history',\n};\n\n// ============================================================================\n// Generate dialog\n// ============================================================================\n\nexport interface GenerateAiContextDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Preselected use case. Locked to this single action. */\n useCase: TcpAiUseCase;\n /** Exactly one grounding scope, matching the svc input contract. */\n storyId?: string;\n collectionId?: string;\n oralHistoryId?: string;\n /** Whether the caller holds `theculturepost-ai-context:update` to review inline. */\n canReview?: boolean;\n onGenerated?: (run: TcpAgentRun) => void;\n}\n\nexport function GenerateAiContextDialog({\n open,\n onOpenChange,\n useCase,\n storyId,\n collectionId,\n oralHistoryId,\n canReview = true,\n onGenerated,\n}: GenerateAiContextDialogProps) {\n const generate = useTcpGenerateAiContext();\n const [prompt, setPrompt] = useState(() => DEFAULT_PROMPTS[useCase]);\n const [run, setRun] = useState<TcpAgentRun | null>(null);\n\n const reset = (nextOpen: boolean) => {\n if (!nextOpen) {\n setPrompt(DEFAULT_PROMPTS[useCase]);\n setRun(null);\n generate.reset();\n }\n onOpenChange(nextOpen);\n };\n\n const submit = async () => {\n const input: TcpGenerateAiContextInput = {\n useCase,\n prompt: prompt.trim(),\n storyId: storyId ?? null,\n collectionId: collectionId ?? null,\n oralHistoryId: oralHistoryId ?? null,\n };\n try {\n const created = await generate.mutateAsync(input);\n setRun(created);\n onGenerated?.(created);\n } catch (error) {\n notify.error('Generation failed', describeError(error));\n }\n };\n\n const statusNote =\n run?.reviewStatus === 'APPROVED'\n ? 'Run approved — recorded in the editorial log.'\n : run?.reviewStatus === 'REJECTED'\n ? 'Run rejected — kept on record.'\n : 'Run created — it is awaiting editorial review.';\n\n return (\n <ResponsiveDialog open={open} onOpenChange={reset}>\n <ResponsiveDialogContent className=\"sm:max-w-xl\">\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>{AI_USE_CASE_LABELS[useCase]}</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n Runs on this product’s AI answer only from sources you can read (PUBLIC/COMMUNITY).\n Every run starts as pending editorial review — nothing is adopted automatically.\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n\n {run ? (\n <div className=\"flex flex-col gap-4\">\n <p className=\"text-sm text-text-secondary\">{statusNote}</p>\n <AiRunCard run={run} canReview={canReview} defaultExpanded onReviewed={setRun} />\n </div>\n ) : (\n <div className=\"flex flex-col gap-2\">\n <Label htmlFor=\"ai-context-prompt\">Your question or instruction</Label>\n <Textarea\n id=\"ai-context-prompt\"\n value={prompt}\n onChange={(event) => setPrompt(event.target.value)}\n rows={4}\n disabled={generate.isPending}\n />\n <p className=\"text-xs text-text-tertiary\">\n Combined server-side with the grounded sources — never sent to the model alone.\n </p>\n </div>\n )}\n\n <ResponsiveDialogFooter>\n {run ? (\n <Button onClick={() => reset(false)}>Done</Button>\n ) : (\n <>\n <Button variant=\"outline\" onClick={() => reset(false)} disabled={generate.isPending}>\n Cancel\n </Button>\n <Button onClick={submit} disabled={generate.isPending || !prompt.trim()}>\n <Sparkles className=\"me-1.5 h-4 w-4\" aria-hidden=\"true\" />\n {generate.isPending ? 'Generating…' : 'Generate'}\n </Button>\n </>\n )}\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n}\n\n// ============================================================================\n// Run card (list item + inline review)\n// ============================================================================\n\nconst UNCERTAINTY_BADGE: Record<string, 'success' | 'warning' | 'destructive'> = {\n LOW: 'success',\n MEDIUM: 'warning',\n HIGH: 'destructive',\n};\n\nexport interface AiRunCardProps {\n run: TcpAgentRun;\n canReview?: boolean;\n defaultExpanded?: boolean;\n onReviewed?: (updated: TcpAgentRun) => void;\n}\n\nexport function AiRunCard({\n run,\n canReview = true,\n defaultExpanded = false,\n onReviewed,\n}: AiRunCardProps) {\n const review = useTcpReviewAiContext();\n const [notes, setNotes] = useState('');\n const [expanded, setExpanded] = useState(defaultExpanded);\n\n const decide = async (approved: boolean) => {\n try {\n const updated = await review.mutateAsync({\n id: run.id,\n approved,\n reviewNotes: notes.trim() || undefined,\n });\n onReviewed?.(updated);\n notify.success(\n approved ? 'AI answer approved' : 'AI answer rejected',\n approved ? 'It is now marked as reviewed.' : 'The run stays on record as rejected.'\n );\n } catch (error) {\n notify.error('Review failed', describeError(error));\n }\n };\n\n return (\n <GlassCard treatment=\"plain\" className=\"flex flex-col gap-3 p-4\">\n <div className=\"flex flex-wrap items-center gap-1.5\">\n <StatusBadge status={run.useCase} />\n {run.status === 'FAILED' ? (\n <StatusBadge status=\"FAILED\" />\n ) : (\n <StatusBadge status={run.reviewStatus} />\n )}\n {run.uncertainty && (\n <span\n className={`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${\n UNCERTAINTY_BADGE[run.uncertainty] === 'success'\n ? 'bg-status-success-bg-subtle text-status-success-text'\n : UNCERTAINTY_BADGE[run.uncertainty] === 'destructive'\n ? 'bg-status-error-bg-subtle text-status-error-text'\n : 'bg-status-warning-bg-subtle text-status-warning-text'\n }`}\n >\n Uncertainty: {formatEnumLabel(run.uncertainty)}\n </span>\n )}\n <span className=\"ms-auto text-xs text-text-tertiary\">\n {formatRelativeTime(run.createdAt)}\n </span>\n </div>\n\n <p className=\"text-sm text-text-secondary\">\n <span className=\"font-medium text-text-primary\">Prompt: </span>\n {run.promptSummary}\n </p>\n\n {run.error && (\n <p className=\"rounded-lg bg-status-error-bg-subtle p-2 text-xs text-status-error-text\">\n {run.error}\n </p>\n )}\n\n {run.content && (\n <div>\n <button\n type=\"button\"\n onClick={() => setExpanded((value) => !value)}\n className=\"text-xs font-medium text-text-secondary underline-offset-2 hover:underline\"\n >\n {expanded ? 'Hide answer' : 'Show answer'}\n </button>\n {expanded && (\n <p className=\"mt-2 whitespace-pre-wrap rounded-lg bg-bg-sunken p-3 text-sm text-text-primary\">\n {run.content}\n </p>\n )}\n </div>\n )}\n\n {run.groundingRefs.length > 0 && (\n <div className=\"flex flex-col gap-1.5\">\n <p className=\"text-xs font-medium text-text-tertiary\">\n Grounded in ({run.groundingRefs.length} sources)\n </p>\n <ul className=\"flex flex-wrap gap-1.5\">\n {run.groundingRefs.map((ref) => (\n <li\n key={`${ref.kind}-${ref.refId}`}\n className=\"inline-flex max-w-full items-center gap-1 rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs text-text-secondary\"\n title={ref.title}\n >\n <span className=\"shrink-0 font-medium\">\n {GROUNDING_KIND_LABELS[ref.kind] ?? formatEnumLabel(ref.kind)}\n </span>\n <span className=\"truncate\">{ref.title}</span>\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {run.reviewStatus !== 'PENDING' && (run.reviewNotes || run.reviewedAt) && (\n <p className=\"text-xs text-text-tertiary\">\n {run.reviewStatus === 'APPROVED' ? 'Approved' : 'Rejected'}\n {run.reviewNotes ? ` — ${run.reviewNotes}` : ''}\n </p>\n )}\n\n {canReview && isReviewableAiRun(run) && (\n <div className=\"flex flex-col gap-2 border-t border-border-seam pt-3\">\n <Textarea\n value={notes}\n onChange={(event) => setNotes(event.target.value)}\n rows={2}\n placeholder=\"Review notes (optional)\"\n disabled={review.isPending}\n />\n <div className=\"flex gap-2\">\n <Button\n size=\"sm\"\n onClick={() => decide(true)}\n disabled={review.isPending}\n aria-label=\"Approve AI answer\"\n >\n <Check className=\"me-1.5 h-4 w-4\" aria-hidden=\"true\" /> Approve\n </Button>\n <Button\n size=\"sm\"\n variant=\"outline\"\n onClick={() => decide(false)}\n disabled={review.isPending}\n aria-label=\"Reject AI answer\"\n >\n <X className=\"me-1.5 h-4 w-4\" aria-hidden=\"true\" /> Reject\n </Button>\n </div>\n </div>\n )}\n </GlassCard>\n );\n}\n\n// ============================================================================\n// Section: action buttons + run list for one grounding scope\n// ============================================================================\n\nexport interface AiContextSectionProps {\n /** Story-scoped use cases (SUMMARIZE_EVIDENCE, DRAFT_FRAMING_PROMPT). */\n storyId?: string;\n /** Collection-scoped use cases (SUGGEST_RELATED_TRADITIONS). */\n collectionId?: string;\n /** Oral-history use case (TRANSCRIBE_ORAL_HISTORY) — action only, no run list\n * filter exists for oral histories server-side. */\n oralHistoryId?: string;\n useCases: TcpAiUseCase[];\n title?: string;\n description?: string;\n className?: string;\n}\n\nexport function AiContextSection({\n storyId,\n collectionId,\n oralHistoryId,\n useCases,\n title = 'AI assistant',\n description = 'Citation-grounded answers from sources you can read. Every answer waits for editorial review before adoption.',\n className,\n}: AiContextSectionProps) {\n const { workspaceId } = useTheCulturePost();\n const permissions = useSafePermissions();\n const { canRead, canCreate, canReview } = resolveAiContextPermissions(permissions, workspaceId);\n const [activeUseCase, setActiveUseCase] = useState<TcpAiUseCase | null>(null);\n // Runs are listable per story or collection; the svc has no oralHistoryId filter.\n const listable = Boolean(storyId || collectionId) && canRead;\n const runsQuery = useTcpAiContextRuns({\n storyId,\n collectionId,\n pagination: { limit: 10 },\n enabled: listable,\n });\n\n if (!canRead && !canCreate) {\n return null;\n }\n\n const runs = listable ? (runsQuery.data?.items ?? []) : [];\n const pendingCount = runs.filter(isReviewableAiRun).length;\n\n return (\n <FeatureGate flag=\"theculturepost.ai-context\" defaultValue fallback={null}>\n <GlassCard treatment=\"plain\" className={`flex flex-col gap-4 p-5 sm:p-6 ${className ?? ''}`}>\n <div className=\"flex flex-wrap items-start justify-between gap-3\">\n <div>\n <h2 className=\"flex items-center gap-2 font-display text-xl font-semibold text-text-primary\">\n <Sparkles className=\"h-5 w-5 text-accent\" aria-hidden=\"true\" /> {title}\n {pendingCount > 0 && (\n <span className=\"rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-xs font-medium text-status-warning-text\">\n {pendingCount} pending\n </span>\n )}\n </h2>\n <p className=\"mt-1 text-sm text-text-secondary\">{description}</p>\n </div>\n {canCreate && (\n <div className=\"flex flex-wrap gap-2\">\n {useCases.map((useCase) => (\n <Button key={useCase} variant=\"outline\" onClick={() => setActiveUseCase(useCase)}>\n <Sparkles className=\"me-1.5 h-4 w-4\" aria-hidden=\"true\" />\n {AI_USE_CASE_LABELS[useCase]}\n </Button>\n ))}\n </div>\n )}\n </div>\n\n {listable &&\n (runsQuery.isLoading ? (\n <LoadingView label=\"Loading AI runs…\" />\n ) : runsQuery.isError ? (\n <ErrorView title=\"Could not load AI runs\" onRetry={() => runsQuery.refetch()} />\n ) : runs.length === 0 ? (\n <EmptyState\n icon={<Sparkles className=\"h-9 w-9\" />}\n title=\"No AI runs yet\"\n description={\n canCreate\n ? 'Run one of the actions above to draft a citation-grounded answer.'\n : 'No citation-grounded AI runs have been created for this scope yet.'\n }\n />\n ) : (\n <div className=\"flex flex-col gap-3\">\n {runs.map((run) => (\n <AiRunCard key={run.id} run={run} canReview={canReview} />\n ))}\n </div>\n ))}\n\n {activeUseCase && (\n <GenerateAiContextDialog\n open\n onOpenChange={(open) => {\n if (!open) setActiveUseCase(null);\n }}\n useCase={activeUseCase}\n storyId={storyId}\n collectionId={collectionId}\n oralHistoryId={oralHistoryId}\n canReview={canReview}\n />\n )}\n </GlassCard>\n </FeatureGate>\n );\n}\n\n// ============================================================================\n// Editorial review queue (workspace-wide, StoriesPage overview)\n// ============================================================================\n\nexport function AiReviewQueue({ className }: { className?: string }) {\n const { workspaceId } = useTheCulturePost();\n const permissions = useSafePermissions();\n const { canRead, canReview } = resolveAiContextPermissions(permissions, workspaceId);\n\n if (!canRead) {\n return null;\n }\n\n return (\n <FeatureGate flag=\"theculturepost.ai-context\" defaultValue fallback={null}>\n <AiReviewQueueContent className={className} canReview={canReview} />\n </FeatureGate>\n );\n}\n\nfunction AiReviewQueueContent({\n className,\n canReview,\n}: {\n className?: string;\n canReview: boolean;\n}) {\n const runsQuery = useTcpAiContextRuns({ pagination: { limit: 50 } });\n const items = (runsQuery.data?.items ?? []).filter(isReviewableAiRun);\n\n if (runsQuery.isLoading) {\n return <LoadingView label=\"Loading AI review queue…\" />;\n }\n if (runsQuery.isError) {\n return (\n <ErrorView title=\"Could not load the AI review queue\" onRetry={() => runsQuery.refetch()} />\n );\n }\n if (items.length === 0) {\n return null;\n }\n\n return (\n <GlassCard treatment=\"plain\" className={`flex flex-col gap-3 p-5 sm:p-6 ${className ?? ''}`}>\n <h2 className=\"flex items-center gap-2 font-display text-xl font-semibold text-text-primary\">\n <Sparkles className=\"h-5 w-5 text-accent\" aria-hidden=\"true\" /> AI review queue\n <span className=\"rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-xs font-medium text-status-warning-text\">\n {items.length} pending\n </span>\n </h2>\n <p className=\"text-sm text-text-secondary\">\n Generated answers awaiting an editorial decision, newest first. Approve or reject them here,\n or in place on the story or collection they belong to.\n </p>\n <div className=\"flex flex-col gap-3\">\n {items.slice(0, 5).map((run) => (\n <AiRunCard key={run.id} run={run} canReview={canReview} />\n ))}\n {items.length > 5 && (\n <p className=\"text-xs text-text-tertiary\">\n {items.length - 5} more pending — open the story or collection they belong to review\n them in place.\n </p>\n )}\n </div>\n </GlassCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkDA,IAAaE,IAAmD;CAC9D,oBAAoB;CACpB,sBAAsB;CACtB,4BAA4B;CAC5B,yBAAyB;CACzB,iBAAiB;CACjB,sBAAsB;CACtB,qBAAqB;CACrB,cAAc;CACd,iBAAiB;CACjB,iBAAiB;CACjB,uBAAuB;CACvB,oBAAoB;CACpB,gBAAgB;AAClB,GAEMC,IAAgD;CACpD,oBAAoB;CACpB,sBACE;CACF,4BACE;CACF,yBACE;CACF,iBAAiB;CACjB,sBAAsB;CACtB,qBAAqB;CACrB,cAAc;CACd,iBAAiB;CACjB,iBAAiB;CACjB,uBACE;CACF,oBAAoB;CACpB,gBAAgB;AAClB,GAEMC,IAA4D;CAChE,UAAU;CACV,cAAc;CACd,cAAc;AAChB;AAoBA,SAAgBC,EAAwB,EACtC,SACA,iBACA,YACA,YACA,iBACA,kBACA,eAAY,IACZ,kBAC+B;CAC/B,IAAMC,IAAWC,EAAwB,GACnC,CAACC,GAAQC,KAAaC,QAAeP,EAAgBQ,EAAQ,GAC7D,CAACC,GAAKC,KAAUH,EAA6B,IAAI,GAEjDI,KAAS,MAAsB;EAMnC,AALKC,MACHN,EAAUN,EAAgBQ,EAAQ,GAClCE,EAAO,IAAI,GACXP,EAAS,MAAM,IAEjBU,EAAaD,CAAQ;CACvB,GAEME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AAG,CAAC,CAAC,CAAC,KAAK,MACtB,kBAACxD,GAAD;KAA6B;KAAgB;IAAY,GAAzCpB,EAAI,EAAqC,CAC1D,GACA4E,EAAM,SAAS,KACd,kBAAC,KAAD;KAAG,WAAU;KAAb,UAAA,CACGA,EAAM,SAAS,GAAE,mFAEjB;IAEF,CAAA,CAAA;;EACI;;AAEf"}
|
|
@@ -17,7 +17,7 @@ function m({ item: m, onOpen: h }) {
|
|
|
17
17
|
children: [/* @__PURE__ */ f("button", {
|
|
18
18
|
type: "button",
|
|
19
19
|
onClick: h,
|
|
20
|
-
className: "group relative block aspect-[4/3] w-full overflow-hidden text-
|
|
20
|
+
className: "group relative block aspect-[4/3] w-full overflow-hidden text-start",
|
|
21
21
|
"aria-label": `Open ${m.title}`,
|
|
22
22
|
children: [/* @__PURE__ */ d(e, {
|
|
23
23
|
fileId: m.file?.id,
|
|
@@ -40,7 +40,7 @@ function m({ item: m, onOpen: h }) {
|
|
|
40
40
|
/* @__PURE__ */ d("button", {
|
|
41
41
|
type: "button",
|
|
42
42
|
onClick: h,
|
|
43
|
-
className: "text-
|
|
43
|
+
className: "text-start text-sm font-semibold leading-snug text-text-primary hover:underline",
|
|
44
44
|
children: m.title
|
|
45
45
|
}),
|
|
46
46
|
/* @__PURE__ */ f("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArchiveItemCard.js","names":["ArchiveItemCard","Icon","KIND_ICON","item","languageLabel","useLanguageMetadata","GlassCard","onOpen","CoverImage","OverlayBadge","createElement","formatEnumLabel","StatusBadge","MapPin","Languages","CalendarClock","formatDate"],"sources":["../../../src/theculturepost/components/ArchiveItemCard.tsx"],"sourcesContent":["/**\n * ArchiveItemCard — a tile for an archived artifact.\n * @module theculturepost/components\n *\n * Kind-icon badge overlaid on the cover, access-level badge, title, provenance/\n * origin, language names + dated chips. Image-like kinds resolve a thumbnail\n * from the file id; others fall back to the kind icon. The schema exposes a\n * single `file` (no galleries) — never render more than one. Links to detail.\n */\n\nimport { createElement } from 'react';\nimport { MapPin, CalendarClock, Languages } from 'lucide-react';\nimport { GlassCard } from '@burdenoff/fe-libs/ui';\nimport { CoverImage } from './CoverImage';\nimport { StatusBadge } from './StatusBadge';\nimport { OverlayBadge } from './OverlayBadge';\nimport { KIND_ICON } from './kindIcon';\nimport { formatDate, formatEnumLabel } from '../utils/formatters';\nimport { useLanguageMetadata } from '../hooks/useLanguageMetadata';\nimport type { TcpArchiveItem } from '../types';\n\ninterface ArchiveItemCardProps {\n item: TcpArchiveItem;\n onOpen: () => void;\n}\n\nexport function ArchiveItemCard({ item, onOpen }: ArchiveItemCardProps) {\n const Icon = KIND_ICON[item.kind];\n const languageLabel = useLanguageMetadata(item.languages);\n\n return (\n <GlassCard treatment=\"plain\" className=\"flex flex-col overflow-hidden\">\n <button\n type=\"button\"\n onClick={onOpen}\n className=\"group relative block aspect-[4/3] w-full overflow-hidden text-
|
|
1
|
+
{"version":3,"file":"ArchiveItemCard.js","names":["ArchiveItemCard","Icon","KIND_ICON","item","languageLabel","useLanguageMetadata","GlassCard","onOpen","CoverImage","OverlayBadge","createElement","formatEnumLabel","StatusBadge","MapPin","Languages","CalendarClock","formatDate"],"sources":["../../../src/theculturepost/components/ArchiveItemCard.tsx"],"sourcesContent":["/**\n * ArchiveItemCard — a tile for an archived artifact.\n * @module theculturepost/components\n *\n * Kind-icon badge overlaid on the cover, access-level badge, title, provenance/\n * origin, language names + dated chips. Image-like kinds resolve a thumbnail\n * from the file id; others fall back to the kind icon. The schema exposes a\n * single `file` (no galleries) — never render more than one. Links to detail.\n */\n\nimport { createElement } from 'react';\nimport { MapPin, CalendarClock, Languages } from 'lucide-react';\nimport { GlassCard } from '@burdenoff/fe-libs/ui';\nimport { CoverImage } from './CoverImage';\nimport { StatusBadge } from './StatusBadge';\nimport { OverlayBadge } from './OverlayBadge';\nimport { KIND_ICON } from './kindIcon';\nimport { formatDate, formatEnumLabel } from '../utils/formatters';\nimport { useLanguageMetadata } from '../hooks/useLanguageMetadata';\nimport type { TcpArchiveItem } from '../types';\n\ninterface ArchiveItemCardProps {\n item: TcpArchiveItem;\n onOpen: () => void;\n}\n\nexport function ArchiveItemCard({ item, onOpen }: ArchiveItemCardProps) {\n const Icon = KIND_ICON[item.kind];\n const languageLabel = useLanguageMetadata(item.languages);\n\n return (\n <GlassCard treatment=\"plain\" className=\"flex flex-col overflow-hidden\">\n <button\n type=\"button\"\n onClick={onOpen}\n className=\"group relative block aspect-[4/3] w-full overflow-hidden text-start\"\n aria-label={`Open ${item.title}`}\n >\n <CoverImage\n fileId={item.file?.id}\n alt={item.title}\n rounded=\"rounded-none\"\n className=\"h-full w-full transition-transform duration-500 group-hover:scale-[1.03]\"\n icon={<Icon className=\"h-8 w-8\" />}\n />\n <OverlayBadge position=\"top-left\" icon={createElement(Icon, { className: 'h-3 w-3' })}>\n {formatEnumLabel(item.kind)}\n </OverlayBadge>\n </button>\n\n <div className=\"flex flex-1 flex-col p-4\">\n <div className=\"mb-1.5\">\n <StatusBadge status={item.accessLevel} />\n </div>\n <button\n type=\"button\"\n onClick={onOpen}\n className=\"text-start text-sm font-semibold leading-snug text-text-primary hover:underline\"\n >\n {item.title}\n </button>\n\n <div className=\"mt-auto flex flex-col gap-1 pt-3 text-xs text-text-tertiary\">\n {item.origin && (\n <span className=\"inline-flex items-center gap-1 truncate\">\n <MapPin className=\"h-3.5 w-3.5 shrink-0\" /> {item.origin}\n </span>\n )}\n {languageLabel && (\n <span className=\"inline-flex items-center gap-1\">\n <Languages className=\"h-3.5 w-3.5 shrink-0\" aria-hidden=\"true\" />\n <bdi>{languageLabel}</bdi>\n </span>\n )}\n {item.datedAt && (\n <span className=\"inline-flex items-center gap-1\">\n <CalendarClock className=\"h-3.5 w-3.5 shrink-0\" /> {formatDate(item.datedAt)}\n </span>\n )}\n </div>\n </div>\n </GlassCard>\n );\n}\n"],"mappings":";;;;;;;;;;;AA0BA,SAAgBA,EAAgB,EAAE,SAAM,aAAgC;CACtE,IAAMC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
|
@@ -58,7 +58,7 @@ function h({ value: h, onRecorded: g, onClear: _, disabled: v }) {
|
|
|
58
58
|
onClick: () => {
|
|
59
59
|
T.current?.stop(), b(!1);
|
|
60
60
|
},
|
|
61
|
-
children: [/* @__PURE__ */ u(s, { className: "
|
|
61
|
+
children: [/* @__PURE__ */ u(s, { className: "me-1.5 h-4 w-4" }), " Stop recording"]
|
|
62
62
|
})] }) : /* @__PURE__ */ d(l, { children: [
|
|
63
63
|
/* @__PURE__ */ u(o, {
|
|
64
64
|
className: "h-6 w-6 text-text-tertiary",
|
|
@@ -95,7 +95,7 @@ function h({ value: h, onRecorded: g, onClear: _, disabled: v }) {
|
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
97
|
disabled: v,
|
|
98
|
-
children: [/* @__PURE__ */ u(o, { className: "
|
|
98
|
+
children: [/* @__PURE__ */ u(o, { className: "me-1.5 h-4 w-4" }), " Start recording"]
|
|
99
99
|
})
|
|
100
100
|
] }), C && /* @__PURE__ */ d("p", {
|
|
101
101
|
className: "flex items-center gap-1.5 text-xs text-status-error-text",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AudioRecorderControl.js","names":["_Fragment","Fragment$1","pickSupportedMimeType","candidate","formatElapsed","m","seconds","s","AudioRecorderControl","recording","setRecording","useState","elapsed","setElapsed","error","setError","mediaRecorderRef","useRef","chunksRef","streamRef","startedAtRef","timerRef","track","stopTimer","value","AudioPlayer","onClear","Trash2","Button","Square","Mic","isNativePlatform","stream","mimeType","recorder","event","finalMimeType","blob","AlertCircle"],"sources":["../../../src/theculturepost/components/AudioRecorderControl.tsx"],"sourcesContent":["/**\n * AudioRecorderControl — in-app microphone recording for oral-history capture.\n * @module theculturepost/components\n *\n * Uses the standard `navigator.mediaDevices.getUserMedia` + `MediaRecorder`\n * Web APIs, which work identically inside the Capacitor WebView (once the\n * host app declares `RECORD_AUDIO` / `NSMicrophoneUsageDescription`) and in a\n * desktop browser — no native Capacitor plugin is required for audio-only\n * capture. This is what makes \"record now\" possible on-device for field\n * oral-history collection (BOFF-4128), as an addition to the existing\n * upload-an-existing-file flow in {@link MediaDropzone}.\n */\n\nimport { useEffect, useRef, useState } from 'react';\nimport { Mic, Square, Trash2, AlertCircle } from 'lucide-react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { AudioPlayer } from './AudioPlayer';\nimport { isNativePlatform } from '../utils/nativeBridge';\n\nexport interface RecordedAudio {\n blob: Blob;\n mimeType: string;\n durationSecs: number;\n /** An object URL for local preview — caller must revoke it when done. */\n previewUrl: string;\n}\n\ninterface AudioRecorderControlProps {\n value: RecordedAudio | null;\n onRecorded: (audio: RecordedAudio) => void;\n onClear: () => void;\n disabled?: boolean;\n}\n\n/** Picks the first MIME type the platform's MediaRecorder actually supports. */\nfunction pickSupportedMimeType(): string {\n const candidates = ['audio/webm;codecs=opus', 'audio/webm', 'audio/mp4', 'audio/aac'];\n for (const candidate of candidates) {\n if (typeof MediaRecorder !== 'undefined' && MediaRecorder.isTypeSupported?.(candidate)) {\n return candidate;\n }\n }\n return '';\n}\n\nfunction formatElapsed(seconds: number): string {\n const m = Math.floor(seconds / 60);\n const s = Math.floor(seconds % 60);\n return `${m}:${String(s).padStart(2, '0')}`;\n}\n\nexport function AudioRecorderControl({\n value,\n onRecorded,\n onClear,\n disabled,\n}: AudioRecorderControlProps) {\n const [recording, setRecording] = useState(false);\n const [elapsed, setElapsed] = useState(0);\n const [error, setError] = useState<string | null>(null);\n\n const mediaRecorderRef = useRef<MediaRecorder | null>(null);\n const chunksRef = useRef<Blob[]>([]);\n const streamRef = useRef<MediaStream | null>(null);\n const startedAtRef = useRef<number>(0);\n const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n useEffect(\n () => () => {\n // Unmount safety: stop any in-flight recording and release the mic.\n if (timerRef.current) clearInterval(timerRef.current);\n streamRef.current?.getTracks().forEach((track) => track.stop());\n },\n []\n );\n\n const stopTimer = () => {\n if (timerRef.current) {\n clearInterval(timerRef.current);\n timerRef.current = null;\n }\n };\n\n const start = async () => {\n setError(null);\n if (typeof navigator === 'undefined' || !navigator.mediaDevices?.getUserMedia) {\n setError('Microphone recording is not supported in this browser.');\n return;\n }\n try {\n const stream = await navigator.mediaDevices.getUserMedia({ audio: true });\n streamRef.current = stream;\n const mimeType = pickSupportedMimeType();\n const recorder = mimeType\n ? new MediaRecorder(stream, { mimeType })\n : new MediaRecorder(stream);\n chunksRef.current = [];\n\n recorder.ondataavailable = (event) => {\n if (event.data.size > 0) chunksRef.current.push(event.data);\n };\n\n recorder.onstop = () => {\n stopTimer();\n stream.getTracks().forEach((track) => track.stop());\n const finalMimeType = recorder.mimeType || mimeType || 'audio/webm';\n const blob = new Blob(chunksRef.current, { type: finalMimeType });\n const durationSecs = Math.max(1, Math.round((Date.now() - startedAtRef.current) / 1000));\n onRecorded({\n blob,\n mimeType: finalMimeType,\n durationSecs,\n previewUrl: URL.createObjectURL(blob),\n });\n };\n\n mediaRecorderRef.current = recorder;\n startedAtRef.current = Date.now();\n setElapsed(0);\n recorder.start();\n setRecording(true);\n timerRef.current = setInterval(() => {\n setElapsed(Math.round((Date.now() - startedAtRef.current) / 1000));\n }, 500);\n } catch {\n setError(\n 'Microphone access was denied or is unavailable. Check app permissions and try again.'\n );\n }\n };\n\n const stop = () => {\n mediaRecorderRef.current?.stop();\n setRecording(false);\n };\n\n const discard = () => {\n if (value) URL.revokeObjectURL(value.previewUrl);\n onClear();\n setElapsed(0);\n };\n\n if (value) {\n return (\n <div className=\"flex flex-col gap-2\">\n <AudioPlayer\n src={value.previewUrl}\n seed=\"local-recording\"\n durationSecs={value.durationSecs}\n />\n <button\n type=\"button\"\n onClick={discard}\n disabled={disabled}\n className=\"inline-flex w-fit items-center gap-1 text-sm text-text-tertiary hover:text-text-primary disabled:opacity-60\"\n >\n <Trash2 className=\"h-3.5 w-3.5\" /> Discard and record again\n </button>\n </div>\n );\n }\n\n return (\n <div className=\"flex flex-col items-center gap-3 rounded-xl border border-dashed border-border-seam bg-bg-surface px-4 py-6 text-center\">\n {recording ? (\n <>\n <div className=\"flex items-center gap-2 text-status-error-text\">\n <span className=\"relative flex h-3 w-3\">\n <span className=\"absolute inline-flex h-full w-full animate-ping rounded-full bg-status-error-text opacity-75\" />\n <span className=\"relative inline-flex h-3 w-3 rounded-full bg-status-error-text\" />\n </span>\n <span className=\"font-mono text-lg tabular-nums\">{formatElapsed(elapsed)}</span>\n </div>\n <Button type=\"button\" variant=\"outline\" onClick={stop}>\n <Square className=\"mr-1.5 h-4 w-4\" /> Stop recording\n </Button>\n </>\n ) : (\n <>\n <Mic className=\"h-6 w-6 text-text-tertiary\" aria-hidden=\"true\" />\n <p className=\"text-sm text-text-secondary\">\n {isNativePlatform()\n ? 'Record the testimony directly on this device.'\n : 'Record using this device’s microphone.'}\n </p>\n <Button type=\"button\" onClick={start} disabled={disabled}>\n <Mic className=\"mr-1.5 h-4 w-4\" /> Start recording\n </Button>\n </>\n )}\n {error && (\n <p className=\"flex items-center gap-1.5 text-xs text-status-error-text\">\n <AlertCircle className=\"h-3.5 w-3.5 shrink-0\" /> {error}\n </p>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAmCA,SAASE,IAAgC;CAEvC,KAAK,IAAMC,KAAa;EADJ;EAA0B;EAAc;EAAa;CACjD,GACtB,IAAI,OAAO,gBAAkB,OAAe,cAAc,kBAAkBA,CAAS,GACnF,OAAOA;CAGX,OAAO;AACT;AAEA,SAASC,EAAc,GAAyB;CAC9C,IAAMC,IAAI,KAAK,MAAMC,IAAU,EAAE,GAC3BC,IAAI,KAAK,MAAMD,IAAU,EAAE;CACjC,OAAO,GAAGD,EAAE,GAAG,OAAOE,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;AAC1C;AAEA,SAAgBC,EAAqB,EACnC,UACA,eACA,YACA,eAC4B;CAC5B,IAAM,CAACC,GAAWC,KAAgBC,EAAS,EAAK,GAC1C,CAACC,GAASC,KAAcF,EAAS,CAAC,GAClC,CAACG,GAAOC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,EAAS,MAAM,GACfxB,EAAa,EAAI,GACjB,EAAS,UAAU,kBAAkB;OACnC,EAAW,KAAK,OAAO,KAAK,IAAI,IAAIU,EAAa,WAAW,GAAI,CAAC;MACnE,GAAG,GAAG;KACR,QAAQ;MACN,EACE,sFACF;KACF;IACF;IAwDwD;IAAhD,UAAA,CACE,kBAACU,GAAD,EAAK,WAAU,iBAAkB,CAAA,GAAC,kBAC5B;;EACR,EAAA,CAAA,GAEHhB,KACC,kBAAC,KAAD;GAAG,WAAU;GAAb,UAAA;IACE,kBAACwB,GAAD,EAAa,WAAU,uBAAwB,CAAA;IAAC;IAAExB;GACjD;EAEF,CAAA,CAAA;;AAET"}
|
|
1
|
+
{"version":3,"file":"AudioRecorderControl.js","names":["_Fragment","Fragment$1","pickSupportedMimeType","candidate","formatElapsed","m","seconds","s","AudioRecorderControl","recording","setRecording","useState","elapsed","setElapsed","error","setError","mediaRecorderRef","useRef","chunksRef","streamRef","startedAtRef","timerRef","track","stopTimer","value","AudioPlayer","onClear","Trash2","Button","Square","Mic","isNativePlatform","stream","mimeType","recorder","event","finalMimeType","blob","AlertCircle"],"sources":["../../../src/theculturepost/components/AudioRecorderControl.tsx"],"sourcesContent":["/**\n * AudioRecorderControl — in-app microphone recording for oral-history capture.\n * @module theculturepost/components\n *\n * Uses the standard `navigator.mediaDevices.getUserMedia` + `MediaRecorder`\n * Web APIs, which work identically inside the Capacitor WebView (once the\n * host app declares `RECORD_AUDIO` / `NSMicrophoneUsageDescription`) and in a\n * desktop browser — no native Capacitor plugin is required for audio-only\n * capture. This is what makes \"record now\" possible on-device for field\n * oral-history collection (BOFF-4128), as an addition to the existing\n * upload-an-existing-file flow in {@link MediaDropzone}.\n */\n\nimport { useEffect, useRef, useState } from 'react';\nimport { Mic, Square, Trash2, AlertCircle } from 'lucide-react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { AudioPlayer } from './AudioPlayer';\nimport { isNativePlatform } from '../utils/nativeBridge';\n\nexport interface RecordedAudio {\n blob: Blob;\n mimeType: string;\n durationSecs: number;\n /** An object URL for local preview — caller must revoke it when done. */\n previewUrl: string;\n}\n\ninterface AudioRecorderControlProps {\n value: RecordedAudio | null;\n onRecorded: (audio: RecordedAudio) => void;\n onClear: () => void;\n disabled?: boolean;\n}\n\n/** Picks the first MIME type the platform's MediaRecorder actually supports. */\nfunction pickSupportedMimeType(): string {\n const candidates = ['audio/webm;codecs=opus', 'audio/webm', 'audio/mp4', 'audio/aac'];\n for (const candidate of candidates) {\n if (typeof MediaRecorder !== 'undefined' && MediaRecorder.isTypeSupported?.(candidate)) {\n return candidate;\n }\n }\n return '';\n}\n\nfunction formatElapsed(seconds: number): string {\n const m = Math.floor(seconds / 60);\n const s = Math.floor(seconds % 60);\n return `${m}:${String(s).padStart(2, '0')}`;\n}\n\nexport function AudioRecorderControl({\n value,\n onRecorded,\n onClear,\n disabled,\n}: AudioRecorderControlProps) {\n const [recording, setRecording] = useState(false);\n const [elapsed, setElapsed] = useState(0);\n const [error, setError] = useState<string | null>(null);\n\n const mediaRecorderRef = useRef<MediaRecorder | null>(null);\n const chunksRef = useRef<Blob[]>([]);\n const streamRef = useRef<MediaStream | null>(null);\n const startedAtRef = useRef<number>(0);\n const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n useEffect(\n () => () => {\n // Unmount safety: stop any in-flight recording and release the mic.\n if (timerRef.current) clearInterval(timerRef.current);\n streamRef.current?.getTracks().forEach((track) => track.stop());\n },\n []\n );\n\n const stopTimer = () => {\n if (timerRef.current) {\n clearInterval(timerRef.current);\n timerRef.current = null;\n }\n };\n\n const start = async () => {\n setError(null);\n if (typeof navigator === 'undefined' || !navigator.mediaDevices?.getUserMedia) {\n setError('Microphone recording is not supported in this browser.');\n return;\n }\n try {\n const stream = await navigator.mediaDevices.getUserMedia({ audio: true });\n streamRef.current = stream;\n const mimeType = pickSupportedMimeType();\n const recorder = mimeType\n ? new MediaRecorder(stream, { mimeType })\n : new MediaRecorder(stream);\n chunksRef.current = [];\n\n recorder.ondataavailable = (event) => {\n if (event.data.size > 0) chunksRef.current.push(event.data);\n };\n\n recorder.onstop = () => {\n stopTimer();\n stream.getTracks().forEach((track) => track.stop());\n const finalMimeType = recorder.mimeType || mimeType || 'audio/webm';\n const blob = new Blob(chunksRef.current, { type: finalMimeType });\n const durationSecs = Math.max(1, Math.round((Date.now() - startedAtRef.current) / 1000));\n onRecorded({\n blob,\n mimeType: finalMimeType,\n durationSecs,\n previewUrl: URL.createObjectURL(blob),\n });\n };\n\n mediaRecorderRef.current = recorder;\n startedAtRef.current = Date.now();\n setElapsed(0);\n recorder.start();\n setRecording(true);\n timerRef.current = setInterval(() => {\n setElapsed(Math.round((Date.now() - startedAtRef.current) / 1000));\n }, 500);\n } catch {\n setError(\n 'Microphone access was denied or is unavailable. Check app permissions and try again.'\n );\n }\n };\n\n const stop = () => {\n mediaRecorderRef.current?.stop();\n setRecording(false);\n };\n\n const discard = () => {\n if (value) URL.revokeObjectURL(value.previewUrl);\n onClear();\n setElapsed(0);\n };\n\n if (value) {\n return (\n <div className=\"flex flex-col gap-2\">\n <AudioPlayer\n src={value.previewUrl}\n seed=\"local-recording\"\n durationSecs={value.durationSecs}\n />\n <button\n type=\"button\"\n onClick={discard}\n disabled={disabled}\n className=\"inline-flex w-fit items-center gap-1 text-sm text-text-tertiary hover:text-text-primary disabled:opacity-60\"\n >\n <Trash2 className=\"h-3.5 w-3.5\" /> Discard and record again\n </button>\n </div>\n );\n }\n\n return (\n <div className=\"flex flex-col items-center gap-3 rounded-xl border border-dashed border-border-seam bg-bg-surface px-4 py-6 text-center\">\n {recording ? (\n <>\n <div className=\"flex items-center gap-2 text-status-error-text\">\n <span className=\"relative flex h-3 w-3\">\n <span className=\"absolute inline-flex h-full w-full animate-ping rounded-full bg-status-error-text opacity-75\" />\n <span className=\"relative inline-flex h-3 w-3 rounded-full bg-status-error-text\" />\n </span>\n <span className=\"font-mono text-lg tabular-nums\">{formatElapsed(elapsed)}</span>\n </div>\n <Button type=\"button\" variant=\"outline\" onClick={stop}>\n <Square className=\"me-1.5 h-4 w-4\" /> Stop recording\n </Button>\n </>\n ) : (\n <>\n <Mic className=\"h-6 w-6 text-text-tertiary\" aria-hidden=\"true\" />\n <p className=\"text-sm text-text-secondary\">\n {isNativePlatform()\n ? 'Record the testimony directly on this device.'\n : 'Record using this device’s microphone.'}\n </p>\n <Button type=\"button\" onClick={start} disabled={disabled}>\n <Mic className=\"me-1.5 h-4 w-4\" /> Start recording\n </Button>\n </>\n )}\n {error && (\n <p className=\"flex items-center gap-1.5 text-xs text-status-error-text\">\n <AlertCircle className=\"h-3.5 w-3.5 shrink-0\" /> {error}\n </p>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAmCA,SAASE,IAAgC;CAEvC,KAAK,IAAMC,KAAa;EADJ;EAA0B;EAAc;EAAa;CACjD,GACtB,IAAI,OAAO,gBAAkB,OAAe,cAAc,kBAAkBA,CAAS,GACnF,OAAOA;CAGX,OAAO;AACT;AAEA,SAASC,EAAc,GAAyB;CAC9C,IAAMC,IAAI,KAAK,MAAMC,IAAU,EAAE,GAC3BC,IAAI,KAAK,MAAMD,IAAU,EAAE;CACjC,OAAO,GAAGD,EAAE,GAAG,OAAOE,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;AAC1C;AAEA,SAAgBC,EAAqB,EACnC,UACA,eACA,YACA,eAC4B;CAC5B,IAAM,CAACC,GAAWC,KAAgBC,EAAS,EAAK,GAC1C,CAACC,GAASC,KAAcF,EAAS,CAAC,GAClC,CAACG,GAAOC,KAAYJ,EAAwB,IAAI,GAEhDK,IAAmBC,EAA6B,IAAI,GACpDC,IAAYD,EAAe,CAAC,CAAC,GAC7BE,IAAYF,EAA2B,IAAI,GAC3CG,IAAeH,EAAe,CAAC,GAC/BI,IAAWJ,EAA8C,IAAI;CAEnE,cACc;EAGV,AADII,EAAS,WAAS,cAAcA,EAAS,OAAO,GACpDF,EAAU,SAAS,UAAU,CAAC,CAAC,SAAS,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AAA,CAAA,GAEHhB,KACC,kBAAC,KAAD;GAAG,WAAU;GAAb,UAAA;IACE,kBAACwB,GAAD,EAAa,WAAU,uBAAwB,CAAA;IAAC;IAAExB;GACjD;EAEF,CAAA,CAAA;;AAET"}
|
|
@@ -12,7 +12,7 @@ function c({ collection: c, onOpen: l }) {
|
|
|
12
12
|
children: [/* @__PURE__ */ o("button", {
|
|
13
13
|
type: "button",
|
|
14
14
|
onClick: l,
|
|
15
|
-
className: "group relative block aspect-[3/2] w-full overflow-hidden text-
|
|
15
|
+
className: "group relative block aspect-[3/2] w-full overflow-hidden text-start",
|
|
16
16
|
"aria-label": `Open ${c.name}`,
|
|
17
17
|
children: [/* @__PURE__ */ a(e, {
|
|
18
18
|
fileId: c.cover?.id,
|
|
@@ -35,7 +35,7 @@ function c({ collection: c, onOpen: l }) {
|
|
|
35
35
|
/* @__PURE__ */ a("button", {
|
|
36
36
|
type: "button",
|
|
37
37
|
onClick: l,
|
|
38
|
-
className: "font-display text-
|
|
38
|
+
className: "font-display text-start text-lg font-semibold text-text-primary hover:underline",
|
|
39
39
|
children: c.name
|
|
40
40
|
}),
|
|
41
41
|
c.tradition && /* @__PURE__ */ a("p", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionCard.js","names":["CollectionCard","GlassCard","onOpen","collection","CoverImage","Library","OverlayBadge","Layers","formatNumber"],"sources":["../../../src/theculturepost/components/CollectionCard.tsx"],"sourcesContent":["/**\n * CollectionCard — a tile for an archive collection.\n * @module theculturepost/components\n *\n * Cover image (collections DO carry a cover file) with the real item count as an\n * {@link OverlayBadge}; serif name, tradition (as region), description. Links to\n * the collection detail page.\n */\n\nimport { Library, Layers } from 'lucide-react';\nimport { GlassCard } from '@burdenoff/fe-libs/ui';\nimport { CoverImage } from './CoverImage';\nimport { OverlayBadge } from './OverlayBadge';\nimport { formatNumber } from '../utils/formatters';\nimport type { TcpCollection } from '../types';\n\ninterface CollectionCardProps {\n collection: TcpCollection;\n onOpen: () => void;\n}\n\nexport function CollectionCard({ collection, onOpen }: CollectionCardProps) {\n return (\n <GlassCard treatment=\"plain\" className=\"flex flex-col overflow-hidden\">\n <button\n type=\"button\"\n onClick={onOpen}\n className=\"group relative block aspect-[3/2] w-full overflow-hidden text-
|
|
1
|
+
{"version":3,"file":"CollectionCard.js","names":["CollectionCard","GlassCard","onOpen","collection","CoverImage","Library","OverlayBadge","Layers","formatNumber"],"sources":["../../../src/theculturepost/components/CollectionCard.tsx"],"sourcesContent":["/**\n * CollectionCard — a tile for an archive collection.\n * @module theculturepost/components\n *\n * Cover image (collections DO carry a cover file) with the real item count as an\n * {@link OverlayBadge}; serif name, tradition (as region), description. Links to\n * the collection detail page.\n */\n\nimport { Library, Layers } from 'lucide-react';\nimport { GlassCard } from '@burdenoff/fe-libs/ui';\nimport { CoverImage } from './CoverImage';\nimport { OverlayBadge } from './OverlayBadge';\nimport { formatNumber } from '../utils/formatters';\nimport type { TcpCollection } from '../types';\n\ninterface CollectionCardProps {\n collection: TcpCollection;\n onOpen: () => void;\n}\n\nexport function CollectionCard({ collection, onOpen }: CollectionCardProps) {\n return (\n <GlassCard treatment=\"plain\" className=\"flex flex-col overflow-hidden\">\n <button\n type=\"button\"\n onClick={onOpen}\n className=\"group relative block aspect-[3/2] w-full overflow-hidden text-start\"\n aria-label={`Open ${collection.name}`}\n >\n <CoverImage\n fileId={collection.cover?.id}\n alt={collection.name}\n rounded=\"rounded-none\"\n className=\"h-full w-full transition-transform duration-500 group-hover:scale-[1.03]\"\n icon={<Library className=\"h-8 w-8\" />}\n />\n <OverlayBadge position=\"top-right\" icon={<Layers className=\"h-3 w-3\" />}>\n {formatNumber(collection.itemCount)} {collection.itemCount === 1 ? 'item' : 'items'}\n </OverlayBadge>\n </button>\n\n <div className=\"flex flex-1 flex-col p-5\">\n <button\n type=\"button\"\n onClick={onOpen}\n className=\"font-display text-start text-lg font-semibold text-text-primary hover:underline\"\n >\n {collection.name}\n </button>\n {collection.tradition && (\n <p className=\"mt-0.5 text-sm text-text-secondary\">{collection.tradition}</p>\n )}\n {collection.description && (\n <p className=\"mt-2 line-clamp-2 text-sm text-text-secondary\">{collection.description}</p>\n )}\n </div>\n </GlassCard>\n );\n}\n"],"mappings":";;;;;;;AAqBA,SAAgBA,EAAe,EAAE,eAAY,aAA+B;CAC1E,OACE,kBAACC,GAAD;EAAW,WAAU;EAAQ,WAAU;EAAvC,UAAA,CACE,kBAAC,UAAD;GACE,MAAK;GACL,SAASC;GACT,WAAU;GACV,cAAY,QAAQC,EAAW;GAJjC,UAAA,CAME,kBAACC,GAAD;IACE,QAAQD,EAAW,OAAO;IAC1B,KAAKA,EAAW;IAChB,SAAQ;IACR,WAAU;IACV,MAAM,kBAACE,GAAD,EAAS,WAAU,UAAW,CAAA;GACrC,CAAA,GACD,kBAACC,GAAD;IAAc,UAAS;IAAY,MAAM,kBAACC,GAAD,EAAQ,WAAU,UAAW,CAAA;IAAtE,UAAA;KACGC,EAAaL,EAAW,SAAS;KAAE;KAAEA,EAAW,cAAc,IAAI,SAAS;IAChE;GACR,CAAA,CAAA;EAER,CAAA,GAAA,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA;IACE,kBAAC,UAAD;KACE,MAAK;KACL,SAASD;KACT,WAAU;KAET,UAAAC,EAAW;IACN,CAAA;IACPA,EAAW,aACV,kBAAC,KAAD;KAAG,WAAU;KAAsC,UAAAA,EAAW;IAAa,CAAA;IAE5EA,EAAW,eACV,kBAAC,KAAD;KAAG,WAAU;KAAiD,UAAAA,EAAW;IAAe,CAAA;GAEvF;EACI,CAAA,CAAA;;AAEf"}
|
|
@@ -32,7 +32,7 @@ function s({ className: s, compact: c = !1 }) {
|
|
|
32
32
|
"aria-hidden": "true"
|
|
33
33
|
}), l("norms.title", "Community norms")]
|
|
34
34
|
}), /* @__PURE__ */ i("ul", {
|
|
35
|
-
className: "mt-2 flex list-disc flex-col gap-1
|
|
35
|
+
className: "mt-2 flex list-disc flex-col gap-1 ps-5 text-sm text-text-secondary",
|
|
36
36
|
children: o.map((e) => /* @__PURE__ */ i("li", { children: l(e.key, e.fallback) }, e.key))
|
|
37
37
|
})]
|
|
38
38
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommunityNorms.js","names":["COMMUNITY_NORMS","CommunityNorms","tr","useTr","titleId","useId","cn","compact","className","HeartHandshake","norm"],"sources":["../../../src/theculturepost/components/CommunityNorms.tsx"],"sourcesContent":["/**\n * CommunityNorms — the community norms, shown up front wherever people\n * start or join a conversation (discussions list, discussion detail, and the\n * open-discussion dialog).\n * @module theculturepost/components\n *\n * Product-wide norms from i18n keys (`norms.*`); workspace-editable norms are\n * a post-launch enhancement. Semantic tokens only.\n */\n\nimport { useId } from 'react';\nimport { HeartHandshake } from 'lucide-react';\nimport { useTr } from '../hooks';\nimport { cn } from '../utils/cn';\n\nexport interface CommunityNorm {\n key: string;\n fallback: string;\n}\n\n/** The norms, in display order. Exported so tests can pin the i18n keys. */\nexport const COMMUNITY_NORMS: readonly CommunityNorm[] = [\n {\n key: 'norms.respect',\n fallback: 'Treat every tradition, faith and community with respect.',\n },\n {\n key: 'norms.ownVoice',\n fallback: 'Speak from your own experience; do not speak for others.',\n },\n {\n key: 'norms.ideas',\n fallback: 'Challenge ideas, never people, and cite sources where you can.',\n },\n];\n\ninterface CommunityNormsProps {\n className?: string;\n /** Tighter spacing for dialogs and list headers. */\n compact?: boolean;\n}\n\nexport function CommunityNorms({ className, compact = false }: CommunityNormsProps) {\n const tr = useTr();\n const titleId = useId();\n return (\n <section\n aria-labelledby={titleId}\n className={cn(\n 'rounded-xl border border-border-seam bg-[var(--color-accent-soft)]',\n compact ? 'p-3' : 'p-4',\n className\n )}\n >\n <h2 id={titleId} className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <HeartHandshake className=\"h-4 w-4 text-accent\" aria-hidden=\"true\" />\n {tr('norms.title', 'Community norms')}\n </h2>\n <ul className=\"mt-2 flex list-disc flex-col gap-1
|
|
1
|
+
{"version":3,"file":"CommunityNorms.js","names":["COMMUNITY_NORMS","CommunityNorms","tr","useTr","titleId","useId","cn","compact","className","HeartHandshake","norm"],"sources":["../../../src/theculturepost/components/CommunityNorms.tsx"],"sourcesContent":["/**\n * CommunityNorms — the community norms, shown up front wherever people\n * start or join a conversation (discussions list, discussion detail, and the\n * open-discussion dialog).\n * @module theculturepost/components\n *\n * Product-wide norms from i18n keys (`norms.*`); workspace-editable norms are\n * a post-launch enhancement. Semantic tokens only.\n */\n\nimport { useId } from 'react';\nimport { HeartHandshake } from 'lucide-react';\nimport { useTr } from '../hooks';\nimport { cn } from '../utils/cn';\n\nexport interface CommunityNorm {\n key: string;\n fallback: string;\n}\n\n/** The norms, in display order. Exported so tests can pin the i18n keys. */\nexport const COMMUNITY_NORMS: readonly CommunityNorm[] = [\n {\n key: 'norms.respect',\n fallback: 'Treat every tradition, faith and community with respect.',\n },\n {\n key: 'norms.ownVoice',\n fallback: 'Speak from your own experience; do not speak for others.',\n },\n {\n key: 'norms.ideas',\n fallback: 'Challenge ideas, never people, and cite sources where you can.',\n },\n];\n\ninterface CommunityNormsProps {\n className?: string;\n /** Tighter spacing for dialogs and list headers. */\n compact?: boolean;\n}\n\nexport function CommunityNorms({ className, compact = false }: CommunityNormsProps) {\n const tr = useTr();\n const titleId = useId();\n return (\n <section\n aria-labelledby={titleId}\n className={cn(\n 'rounded-xl border border-border-seam bg-[var(--color-accent-soft)]',\n compact ? 'p-3' : 'p-4',\n className\n )}\n >\n <h2 id={titleId} className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <HeartHandshake className=\"h-4 w-4 text-accent\" aria-hidden=\"true\" />\n {tr('norms.title', 'Community norms')}\n </h2>\n <ul className=\"mt-2 flex list-disc flex-col gap-1 ps-5 text-sm text-text-secondary\">\n {COMMUNITY_NORMS.map((norm) => (\n <li key={norm.key}>{tr(norm.key, norm.fallback)}</li>\n ))}\n </ul>\n </section>\n );\n}\n"],"mappings":";;;;;;;AAqBA,IAAaA,IAA4C;CACvD;EACE,KAAK;EACL,UAAU;CACZ;CACA;EACE,KAAK;EACL,UAAU;CACZ;CACA;EACE,KAAK;EACL,UAAU;CACZ;AACF;AAQA,SAAgBC,EAAe,EAAE,cAAW,aAAU,MAA8B;CAClF,IAAMC,IAAKC,EAAM,GACXC,IAAUC,EAAM;CACtB,OACE,kBAAC,WAAD;EACE,mBAAiBD;EACjB,WAAWE,EACT,sEACAC,IAAU,QAAQ,OAClBC,CACF;EANF,UAAA,CAQE,kBAAC,MAAD;GAAI,IAAIJ;GAAS,WAAU;GAA3B,UAAA,CACE,kBAACK,GAAD;IAAgB,WAAU;IAAsB,eAAY;GAAQ,CAAA,GACnEP,EAAG,eAAe,iBAAiB,CAClC;EACJ,CAAA,GAAA,kBAAC,MAAD;GAAI,WAAU;GACX,UAAAF,EAAgB,KAAK,MACpB,kBAAC,MAAD,EAAA,UAAoBE,EAAGQ,EAAK,KAAKA,EAAK,QAAQ,EAAM,GAA3CA,EAAK,GAAsC,CACrD;EACC,CAAA,CACG;;AAEb"}
|
|
@@ -63,7 +63,7 @@ function ae({ coverFileId: e, onUploaded: r, onCleared: i }) {
|
|
|
63
63
|
className: "max-h-52 w-full object-cover"
|
|
64
64
|
}),
|
|
65
65
|
/* @__PURE__ */ y("div", {
|
|
66
|
-
className: "absolute
|
|
66
|
+
className: "absolute end-2 top-2 flex gap-1.5",
|
|
67
67
|
children: [/* @__PURE__ */ v("button", {
|
|
68
68
|
type: "button",
|
|
69
69
|
onClick: () => a.current?.click(),
|
|
@@ -173,7 +173,7 @@ function P({ open: t, onOpenChange: n, topicId: o, onCreated: u }) {
|
|
|
173
173
|
}),
|
|
174
174
|
/* @__PURE__ */ y("div", {
|
|
175
175
|
"data-testid": "create-story-dialog-body",
|
|
176
|
-
className: "flex min-h-0 max-h-[52dvh] flex-1 flex-col gap-5 overflow-y-auto overscroll-contain py-2
|
|
176
|
+
className: "flex min-h-0 max-h-[52dvh] flex-1 flex-col gap-5 overflow-y-auto overscroll-contain py-2 pe-1 md:max-h-none",
|
|
177
177
|
children: [
|
|
178
178
|
/* @__PURE__ */ y("div", {
|
|
179
179
|
className: "grid gap-1.5",
|
|
@@ -212,9 +212,9 @@ function P({ open: t, onOpenChange: n, topicId: o, onCreated: u }) {
|
|
|
212
212
|
I(!0), F(s(e.target.value));
|
|
213
213
|
},
|
|
214
214
|
placeholder: "the-weavers-of-the-coromandel-coast",
|
|
215
|
-
className: $ ? "
|
|
215
|
+
className: $ ? "pe-9" : void 0
|
|
216
216
|
}), $ && /* @__PURE__ */ v(f, {
|
|
217
|
-
className: "pointer-events-none absolute
|
|
217
|
+
className: "pointer-events-none absolute end-3 top-1/2 h-4 w-4 -translate-y-1/2 text-status-success-text",
|
|
218
218
|
"aria-hidden": "true"
|
|
219
219
|
})]
|
|
220
220
|
}),
|
|
@@ -376,7 +376,7 @@ function P({ open: t, onOpenChange: n, topicId: o, onCreated: u }) {
|
|
|
376
376
|
},
|
|
377
377
|
disabled: p.isPending,
|
|
378
378
|
children: p.isPending ? /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v(m, {
|
|
379
|
-
className: "
|
|
379
|
+
className: "me-1.5 h-4 w-4 animate-spin",
|
|
380
380
|
"aria-hidden": "true"
|
|
381
381
|
}), " Creating…"] }) : "Create story"
|
|
382
382
|
})]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateStoryDialog.js","names":["_Fragment","Fragment$1","FORMATS","SUMMARY_MAX","COVER_MAX_MB","CoverDropzone","inputRef","useRef","uploading","setUploading","useState","dragActive","setDragActive","previewUrl","setPreviewUrl","fileName","setFileName","handleFile","file","uploaded","uploadImageToFiles","FILE_FOLDERS","onUploaded","notify","err","describeError","onInputChange","event","onDrop","clear","onCleared","hiddenInput","X","coverFileId","FileCheck2","cn","Loader2","UploadCloud","Button","CreateStoryDialog","createStory","useTcpCreateStory","topicsQuery","useTcpTopics","title","setTitle","slug","setSlug","slugTouched","setSlugTouched","summary","setSummary","body","setBody","format","setFormat","pickedTopic","setPickedTopic","topicId","languages","setLanguages","tags","setTags","readingMins","setReadingMins","setCoverFileId","error","setError","resetNonce","setResetNonce","effectiveSlug","slugify","reset","n","ResponsiveDialog","ResponsiveDialogContent","ResponsiveDialogHeader","ResponsiveDialogTitle","ResponsiveDialogDescription","Label","Input","CheckCircle2","Select","v","SelectTrigger","SelectValue","SelectContent","SelectItem","f","formatEnumLabel","topic","Textarea","FramingPrompts","TagInput","ResponsiveDialogFooter","onOpenChange","created","onCreated","message"],"sources":["../../../src/theculturepost/components/CreateStoryDialog.tsx"],"sourcesContent":["/**\n * CreateStoryDialog — draft a new story.\n * @module theculturepost/components\n *\n * Writes `tcpCreateStory`. A wide, two-column composer that mirrors the editorial\n * \"Draft a story\" surface: a real drag-and-drop cover dropzone (uploads to\n * wspace-files-svc and keeps the returned `coverFileId`), a title with an\n * auto-derived URL slug + uniqueness hint, char counters on summary/body, and\n * chip multiselects for languages/tags. New stories begin at the start of the\n * editorial lifecycle (IDEA/DRAFT on the svc). Every field maps to a real\n * `TcpCreateStoryInput` field — no bookmarks, no fabricated metadata.\n */\n\nimport { useRef, useState, type ChangeEvent, type DragEvent } from 'react';\nimport { UploadCloud, Loader2, X, CheckCircle2, FileCheck2 } from 'lucide-react';\nimport {\n Button,\n Input,\n Label,\n Textarea,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n} from '@burdenoff/fe-libs/ui';\nimport { FramingPrompts } from './FramingPrompts';\nimport { TagInput } from './TagInput';\nimport { cn } from '../utils/cn';\nimport { useTcpCreateStory, useTcpTopics, uploadImageToFiles, FILE_FOLDERS } from '../hooks';\nimport { slugify } from '../utils/slug';\nimport { formatEnumLabel } from '../utils/formatters';\nimport { notify, describeError } from '../lib/toast';\nimport type { TcpStory, TcpStoryFormat } from '../types';\n\nconst FORMATS: TcpStoryFormat[] = [\n 'ARTICLE',\n 'ESSAY',\n 'EXPLAINER',\n 'ORAL_HISTORY',\n 'PHOTO_STORY',\n 'TIMELINE',\n];\n\nconst SUMMARY_MAX = 200;\nconst COVER_MAX_MB = 25;\n\n// ---------------------------------------------------------------------------\n// Cover dropzone (real drag-and-drop → wspace-files-svc)\n// ---------------------------------------------------------------------------\n\ninterface CoverDropzoneProps {\n coverFileId: string | null;\n onUploaded: (fileId: string) => void;\n onCleared: () => void;\n}\n\nfunction CoverDropzone({ coverFileId, onUploaded, onCleared }: CoverDropzoneProps) {\n const inputRef = useRef<HTMLInputElement | null>(null);\n const [uploading, setUploading] = useState(false);\n const [dragActive, setDragActive] = useState(false);\n const [previewUrl, setPreviewUrl] = useState<string | null>(null);\n const [fileName, setFileName] = useState<string | null>(null);\n\n const handleFile = async (file: File) => {\n if (!file.type.startsWith('image/')) {\n notify.error('Unsupported file', 'Please choose an image (JPG or PNG).');\n return;\n }\n if (file.size > COVER_MAX_MB * 1024 * 1024) {\n notify.error('File too large', `Please choose an image under ${COVER_MAX_MB} MB.`);\n return;\n }\n setUploading(true);\n try {\n const uploaded = await uploadImageToFiles(file, FILE_FOLDERS.covers);\n setPreviewUrl(uploaded.url);\n setFileName(uploaded.name);\n onUploaded(uploaded.id);\n notify.success('Cover uploaded', uploaded.name);\n } catch (err) {\n notify.error('Upload failed', describeError(err));\n } finally {\n setUploading(false);\n }\n };\n\n const onInputChange = (event: ChangeEvent<HTMLInputElement>) => {\n const file = event.target.files?.[0];\n event.target.value = '';\n if (file) void handleFile(file);\n };\n\n const onDrop = (event: DragEvent<HTMLDivElement>) => {\n event.preventDefault();\n setDragActive(false);\n if (uploading) return;\n const file = event.dataTransfer.files?.[0];\n if (file) void handleFile(file);\n };\n\n const clear = () => {\n setPreviewUrl(null);\n setFileName(null);\n onCleared();\n };\n\n const hiddenInput = (\n <input\n ref={inputRef}\n type=\"file\"\n accept=\"image/*\"\n className=\"sr-only\"\n onChange={onInputChange}\n disabled={uploading}\n aria-label=\"Upload cover image\"\n />\n );\n\n // Uploaded image preview\n if (previewUrl) {\n return (\n <div className=\"relative overflow-hidden rounded-2xl border border-border-seam\">\n {hiddenInput}\n <img src={previewUrl} alt=\"Cover preview\" className=\"max-h-52 w-full object-cover\" />\n <div className=\"absolute right-2 top-2 flex gap-1.5\">\n <button\n type=\"button\"\n onClick={() => inputRef.current?.click()}\n className=\"rounded-full bg-bg-canvas/85 px-2.5 py-1 text-xs font-medium text-text-primary backdrop-blur-sm hover:bg-bg-canvas\"\n >\n Replace\n </button>\n <button\n type=\"button\"\n onClick={clear}\n aria-label=\"Remove cover\"\n className=\"rounded-full bg-bg-canvas/85 p-1.5 text-text-primary backdrop-blur-sm hover:bg-bg-canvas\"\n >\n <X className=\"h-4 w-4\" aria-hidden=\"true\" />\n </button>\n </div>\n </div>\n );\n }\n\n // Cover set but no local preview (defensive)\n if (coverFileId) {\n return (\n <div className=\"flex items-center justify-between gap-2 rounded-2xl border border-border-seam bg-bg-surface px-3 py-2.5 text-sm\">\n {hiddenInput}\n <span className=\"inline-flex min-w-0 items-center gap-2 text-text-primary\">\n <FileCheck2 className=\"h-4 w-4 shrink-0 text-status-success-text\" aria-hidden=\"true\" />\n <span className=\"truncate\">{fileName ?? 'Cover selected'}</span>\n </span>\n <button\n type=\"button\"\n onClick={clear}\n aria-label=\"Remove cover\"\n className=\"text-text-tertiary hover:text-text-primary\"\n >\n <X className=\"h-4 w-4\" aria-hidden=\"true\" />\n </button>\n </div>\n );\n }\n\n // Empty dropzone\n return (\n <div\n onDragOver={(event) => {\n event.preventDefault();\n if (!uploading) setDragActive(true);\n }}\n onDragLeave={(event) => {\n event.preventDefault();\n setDragActive(false);\n }}\n onDrop={onDrop}\n className={cn(\n 'rounded-2xl border-2 border-dashed px-4 py-6 text-center transition-colors',\n dragActive\n ? 'border-accent bg-[var(--color-accent-soft)]'\n : 'border-border-seam bg-bg-sunken/40'\n )}\n >\n {hiddenInput}\n {uploading ? (\n <div className=\"flex items-center justify-center gap-2 text-sm text-text-secondary\">\n <Loader2 className=\"h-5 w-5 animate-spin\" aria-hidden=\"true\" /> Uploading cover…\n </div>\n ) : (\n <div className=\"flex flex-col items-center justify-center gap-3 sm:flex-row\">\n <UploadCloud className=\"h-8 w-8 text-accent\" aria-hidden=\"true\" />\n <p className=\"text-sm text-text-secondary\">Drag and drop an image here, or</p>\n <Button type=\"button\" size=\"sm\" onClick={() => inputRef.current?.click()}>\n Upload cover\n </Button>\n </div>\n )}\n <p className=\"mt-3 text-xs text-text-tertiary\">\n Recommended: 16:9 ratio, min 1200×675px. JPG or PNG, up to {COVER_MAX_MB} MB.\n </p>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Dialog\n// ---------------------------------------------------------------------------\n\ninterface CreateStoryDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Pre-select a topic (e.g. from a topic detail page). */\n topicId?: string;\n onCreated?: (story: TcpStory) => void;\n}\n\nexport function CreateStoryDialog({\n open,\n onOpenChange,\n topicId,\n onCreated,\n}: CreateStoryDialogProps) {\n const createStory = useTcpCreateStory();\n const topicsQuery = useTcpTopics({ pagination: { limit: 100 } });\n\n const [title, setTitle] = useState('');\n const [slug, setSlug] = useState('');\n const [slugTouched, setSlugTouched] = useState(false);\n const [summary, setSummary] = useState('');\n const [body, setBody] = useState('');\n const [format, setFormat] = useState<TcpStoryFormat>('ARTICLE');\n const [pickedTopic, setPickedTopic] = useState(topicId ?? '');\n const [languages, setLanguages] = useState<string[]>([]);\n const [tags, setTags] = useState<string[]>([]);\n const [readingMins, setReadingMins] = useState('');\n const [coverFileId, setCoverFileId] = useState<string | null>(null);\n const [error, setError] = useState<string | null>(null);\n // Bumped on reset to force the cover dropzone to drop its local preview state.\n const [resetNonce, setResetNonce] = useState(0);\n\n const effectiveSlug = slugTouched ? slug : slugify(title);\n\n const reset = () => {\n setTitle('');\n setSlug('');\n setSlugTouched(false);\n setSummary('');\n setBody('');\n setFormat('ARTICLE');\n setPickedTopic(topicId ?? '');\n setLanguages([]);\n setTags([]);\n setReadingMins('');\n setCoverFileId(null);\n setError(null);\n setResetNonce((n) => n + 1);\n };\n\n const submit = async () => {\n if (!title.trim()) {\n setError('A title is required.');\n return;\n }\n if (!effectiveSlug) {\n setError('A URL slug is required.');\n return;\n }\n try {\n const created = await createStory.mutateAsync({\n title: title.trim(),\n slug: effectiveSlug,\n summary: summary.trim() || null,\n body: body.trim() || null,\n format,\n topicId: pickedTopic || null,\n languages: languages.length ? languages : null,\n tags: tags.length ? tags : null,\n readingMins: readingMins ? Number(readingMins) : null,\n coverFileId,\n });\n notify.success('Story created', created.title);\n onOpenChange(false);\n reset();\n onCreated?.(created);\n } catch (err) {\n // Keep the dialog open with the entered values and surface the failure in\n // both the inline alert and a toast, so a failed create is never silent.\n const message = describeError(err);\n setError(message);\n notify.error('Could not create the story', message);\n }\n };\n\n return (\n <ResponsiveDialog open={open} onOpenChange={onOpenChange}>\n <ResponsiveDialogContent\n className=\"flex max-h-[90dvh] flex-col overflow-hidden sm:max-w-3xl\"\n data-testid=\"create-story-dialog\"\n >\n <ResponsiveDialogHeader className=\"shrink-0\">\n <ResponsiveDialogTitle className=\"font-display\">Draft a story</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n Begin a new piece — it enters the editorial lifecycle as a draft you can refine and\n publish later.\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n\n <div\n data-testid=\"create-story-dialog-body\"\n className=\"flex min-h-0 max-h-[52dvh] flex-1 flex-col gap-5 overflow-y-auto overscroll-contain py-2 pr-1 md:max-h-none\"\n >\n {/* Cover image */}\n <div className=\"grid gap-1.5\">\n <Label>Cover image</Label>\n <CoverDropzone\n key={resetNonce}\n coverFileId={coverFileId}\n onUploaded={setCoverFileId}\n onCleared={() => setCoverFileId(null)}\n />\n </div>\n\n {/* Title + slug */}\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-title\">Title</Label>\n <Input\n id=\"story-title\"\n value={title}\n onChange={(e) => setTitle(e.target.value)}\n placeholder=\"e.g. The Weavers of the Coromandel Coast\"\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-slug\">URL slug</Label>\n <div className=\"relative\">\n <Input\n id=\"story-slug\"\n value={effectiveSlug}\n onChange={(e) => {\n setSlugTouched(true);\n setSlug(slugify(e.target.value));\n }}\n placeholder=\"the-weavers-of-the-coromandel-coast\"\n className={effectiveSlug ? 'pr-9' : undefined}\n />\n {effectiveSlug && (\n <CheckCircle2\n className=\"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-status-success-text\"\n aria-hidden=\"true\"\n />\n )}\n </div>\n <p className=\"text-xs text-text-tertiary\">\n Auto-derived from the title — used in the story’s URL, so keep it unique.\n </p>\n </div>\n </div>\n\n {/* Format + reading time */}\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label>Format</Label>\n <Select value={format} onValueChange={(v) => setFormat(v as TcpStoryFormat)}>\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {FORMATS.map((f) => (\n <SelectItem key={f} value={f}>\n {formatEnumLabel(f)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-reading\">Reading time (min)</Label>\n <Input\n id=\"story-reading\"\n type=\"number\"\n min={0}\n value={readingMins}\n onChange={(e) => setReadingMins(e.target.value)}\n placeholder=\"Optional\"\n />\n </div>\n </div>\n\n {/* Topic */}\n <div className=\"grid gap-1.5\">\n <Label>Topic</Label>\n <Select value={pickedTopic} onValueChange={setPickedTopic}>\n <SelectTrigger>\n <SelectValue placeholder=\"Choose a topic (optional)\" />\n </SelectTrigger>\n <SelectContent>\n {(topicsQuery.data?.items ?? []).map((topic) => (\n <SelectItem key={topic.id} value={topic.id}>\n {topic.name}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n\n {/* Summary */}\n <div className=\"grid gap-1.5\">\n <div className=\"flex items-center justify-between gap-2\">\n <Label htmlFor=\"story-summary\">Summary</Label>\n <span className=\"text-xs tabular-nums text-text-tertiary\">\n {summary.length}/{SUMMARY_MAX}\n </span>\n </div>\n <Textarea\n id=\"story-summary\"\n value={summary}\n onChange={(e) => setSummary(e.target.value.slice(0, SUMMARY_MAX))}\n maxLength={SUMMARY_MAX}\n placeholder=\"A short standfirst that introduces the story.\"\n rows={2}\n />\n </div>\n\n <FramingPrompts />\n\n {/* Body */}\n <div className=\"grid gap-1.5\">\n <div className=\"flex items-center justify-between gap-2\">\n <Label htmlFor=\"story-body\">Body</Label>\n <span className=\"text-xs tabular-nums text-text-tertiary\">\n {body.length} {body.length === 1 ? 'character' : 'characters'}\n </span>\n </div>\n <Textarea\n id=\"story-body\"\n value={body}\n onChange={(e) => setBody(e.target.value)}\n placeholder=\"Write the story… (line breaks are preserved)\"\n rows={5}\n />\n </div>\n\n {/* Languages + tags */}\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-langs\">Languages</Label>\n <TagInput\n id=\"story-langs\"\n value={languages}\n onChange={setLanguages}\n placeholder=\"e.g. English, Tamil…\"\n preserveCase\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-tags\">Tags</Label>\n <TagInput id=\"story-tags\" value={tags} onChange={setTags} placeholder=\"Add tags…\" />\n </div>\n </div>\n\n {error && <p className=\"text-sm text-status-error-text\">{error}</p>}\n </div>\n\n <ResponsiveDialogFooter\n data-testid=\"create-story-dialog-footer\"\n className=\"shrink-0 border-t border-border-seam pt-3\"\n >\n <Button variant=\"outline\" onClick={() => onOpenChange(false)}>\n Cancel\n </Button>\n <Button onClick={submit} disabled={createStory.isPending}>\n {createStory.isPending ? (\n <>\n <Loader2 className=\"mr-1.5 h-4 w-4 animate-spin\" aria-hidden=\"true\" /> Creating…\n </>\n ) : (\n 'Create story'\n )}\n </Button>\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAyCA,IAAME,KAA4B;CAChC;CACA;CACA;CACA;CACA;CACA;AACF,GAEMC,IAAc,KACdC,IAAe;AAYrB,SAASC,GAAc,EAAE,gBAAa,eAAY,gBAAiC;CACjF,IAAMC,IAAWC,EAAgC,IAAI,GAC/C,CAACC,GAAWC,KAAgBC,EAAS,EAAK,GAC1C,CAACC,GAAYC,KAAiBF,EAAS,EAAK,GAC5C,CAACG,GAAYC,KAAiBJ,EAAwB,IAAI,GAC1D,CAACK,GAAUC,KAAeN,EAAwB,IAAI,GAEtDO,IAAa,OAAO,MAAe;EACvC,IAAI,CAACC,EAAK,KAAK,WAAW,QAAQ,GAChC,EAAO,MAAM,oBAAoB,sCAAsC;OAGzE,IAAIA,EAAK,OAAOd,IAAe,OAAO,MACpC,EAAO,MAAM,kBAAkB,gCAAgCA,EAAa,KAAK;OAGnF;KAAa,EAAI;GACjB,IAAI;IACF,IAAMe,IAAW,MAAMC,EAAmBF,GAAMG,EAAa,MAAM;IAInE,AAHAP,EAAcK,EAAS,GAAG,GAC1BH,EAAYG,EAAS,IAAI,GACzBG,EAAWH,EAAS,EAAE,GACtBI,EAAO,QAAQ,kBAAkBJ,EAAS,IAAI;GAChD,SAASK,GAAK;IACZ,EAAO,MAAM,iBAAiBC,GAAcD,CAAG,CAAC;GAClD,UAAU;IACR,EAAa,EAAK;GACpB;EAXiB;CAYnB,GAEME,KAAiB,MAAyC;EAC9D,IAAMR,IAAOS,EAAM,OAAO,QAAQ;EAElC,AADA,EAAM,OAAO,QAAQ,IACjBT,KAAMD,EAAgBC,CAAI;CAChC,GAEMU,KAAU,MAAqC;EAGnD,IAFAD,EAAM,eAAe,GACrBf,EAAc,EAAK,GACfJ,GAAW;EACf,IAAMU,IAAOS,EAAM,aAAa,QAAQ;EAC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D,EAAY;MAC5C,UAAAA,EAAY,YACX,kBAAAxC,GAAA,EAAA,UAAA,CACE,kBAACoC,GAAD;OAAS,WAAU;OAA8B,eAAY;MAAQ,CAAA,GAAC,YACtE,EAAA,CAAA,IAEF;KAEI,CAAA,CACc;;GACD;;CACT,CAAA;AAEtB"}
|
|
1
|
+
{"version":3,"file":"CreateStoryDialog.js","names":["_Fragment","Fragment$1","FORMATS","SUMMARY_MAX","COVER_MAX_MB","CoverDropzone","inputRef","useRef","uploading","setUploading","useState","dragActive","setDragActive","previewUrl","setPreviewUrl","fileName","setFileName","handleFile","file","uploaded","uploadImageToFiles","FILE_FOLDERS","onUploaded","notify","err","describeError","onInputChange","event","onDrop","clear","onCleared","hiddenInput","X","coverFileId","FileCheck2","cn","Loader2","UploadCloud","Button","CreateStoryDialog","createStory","useTcpCreateStory","topicsQuery","useTcpTopics","title","setTitle","slug","setSlug","slugTouched","setSlugTouched","summary","setSummary","body","setBody","format","setFormat","pickedTopic","setPickedTopic","topicId","languages","setLanguages","tags","setTags","readingMins","setReadingMins","setCoverFileId","error","setError","resetNonce","setResetNonce","effectiveSlug","slugify","reset","n","ResponsiveDialog","ResponsiveDialogContent","ResponsiveDialogHeader","ResponsiveDialogTitle","ResponsiveDialogDescription","Label","Input","CheckCircle2","Select","v","SelectTrigger","SelectValue","SelectContent","SelectItem","f","formatEnumLabel","topic","Textarea","FramingPrompts","TagInput","ResponsiveDialogFooter","onOpenChange","created","onCreated","message"],"sources":["../../../src/theculturepost/components/CreateStoryDialog.tsx"],"sourcesContent":["/**\n * CreateStoryDialog — draft a new story.\n * @module theculturepost/components\n *\n * Writes `tcpCreateStory`. A wide, two-column composer that mirrors the editorial\n * \"Draft a story\" surface: a real drag-and-drop cover dropzone (uploads to\n * wspace-files-svc and keeps the returned `coverFileId`), a title with an\n * auto-derived URL slug + uniqueness hint, char counters on summary/body, and\n * chip multiselects for languages/tags. New stories begin at the start of the\n * editorial lifecycle (IDEA/DRAFT on the svc). Every field maps to a real\n * `TcpCreateStoryInput` field — no bookmarks, no fabricated metadata.\n */\n\nimport { useRef, useState, type ChangeEvent, type DragEvent } from 'react';\nimport { UploadCloud, Loader2, X, CheckCircle2, FileCheck2 } from 'lucide-react';\nimport {\n Button,\n Input,\n Label,\n Textarea,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n} from '@burdenoff/fe-libs/ui';\nimport { FramingPrompts } from './FramingPrompts';\nimport { TagInput } from './TagInput';\nimport { cn } from '../utils/cn';\nimport { useTcpCreateStory, useTcpTopics, uploadImageToFiles, FILE_FOLDERS } from '../hooks';\nimport { slugify } from '../utils/slug';\nimport { formatEnumLabel } from '../utils/formatters';\nimport { notify, describeError } from '../lib/toast';\nimport type { TcpStory, TcpStoryFormat } from '../types';\n\nconst FORMATS: TcpStoryFormat[] = [\n 'ARTICLE',\n 'ESSAY',\n 'EXPLAINER',\n 'ORAL_HISTORY',\n 'PHOTO_STORY',\n 'TIMELINE',\n];\n\nconst SUMMARY_MAX = 200;\nconst COVER_MAX_MB = 25;\n\n// ---------------------------------------------------------------------------\n// Cover dropzone (real drag-and-drop → wspace-files-svc)\n// ---------------------------------------------------------------------------\n\ninterface CoverDropzoneProps {\n coverFileId: string | null;\n onUploaded: (fileId: string) => void;\n onCleared: () => void;\n}\n\nfunction CoverDropzone({ coverFileId, onUploaded, onCleared }: CoverDropzoneProps) {\n const inputRef = useRef<HTMLInputElement | null>(null);\n const [uploading, setUploading] = useState(false);\n const [dragActive, setDragActive] = useState(false);\n const [previewUrl, setPreviewUrl] = useState<string | null>(null);\n const [fileName, setFileName] = useState<string | null>(null);\n\n const handleFile = async (file: File) => {\n if (!file.type.startsWith('image/')) {\n notify.error('Unsupported file', 'Please choose an image (JPG or PNG).');\n return;\n }\n if (file.size > COVER_MAX_MB * 1024 * 1024) {\n notify.error('File too large', `Please choose an image under ${COVER_MAX_MB} MB.`);\n return;\n }\n setUploading(true);\n try {\n const uploaded = await uploadImageToFiles(file, FILE_FOLDERS.covers);\n setPreviewUrl(uploaded.url);\n setFileName(uploaded.name);\n onUploaded(uploaded.id);\n notify.success('Cover uploaded', uploaded.name);\n } catch (err) {\n notify.error('Upload failed', describeError(err));\n } finally {\n setUploading(false);\n }\n };\n\n const onInputChange = (event: ChangeEvent<HTMLInputElement>) => {\n const file = event.target.files?.[0];\n event.target.value = '';\n if (file) void handleFile(file);\n };\n\n const onDrop = (event: DragEvent<HTMLDivElement>) => {\n event.preventDefault();\n setDragActive(false);\n if (uploading) return;\n const file = event.dataTransfer.files?.[0];\n if (file) void handleFile(file);\n };\n\n const clear = () => {\n setPreviewUrl(null);\n setFileName(null);\n onCleared();\n };\n\n const hiddenInput = (\n <input\n ref={inputRef}\n type=\"file\"\n accept=\"image/*\"\n className=\"sr-only\"\n onChange={onInputChange}\n disabled={uploading}\n aria-label=\"Upload cover image\"\n />\n );\n\n // Uploaded image preview\n if (previewUrl) {\n return (\n <div className=\"relative overflow-hidden rounded-2xl border border-border-seam\">\n {hiddenInput}\n <img src={previewUrl} alt=\"Cover preview\" className=\"max-h-52 w-full object-cover\" />\n <div className=\"absolute end-2 top-2 flex gap-1.5\">\n <button\n type=\"button\"\n onClick={() => inputRef.current?.click()}\n className=\"rounded-full bg-bg-canvas/85 px-2.5 py-1 text-xs font-medium text-text-primary backdrop-blur-sm hover:bg-bg-canvas\"\n >\n Replace\n </button>\n <button\n type=\"button\"\n onClick={clear}\n aria-label=\"Remove cover\"\n className=\"rounded-full bg-bg-canvas/85 p-1.5 text-text-primary backdrop-blur-sm hover:bg-bg-canvas\"\n >\n <X className=\"h-4 w-4\" aria-hidden=\"true\" />\n </button>\n </div>\n </div>\n );\n }\n\n // Cover set but no local preview (defensive)\n if (coverFileId) {\n return (\n <div className=\"flex items-center justify-between gap-2 rounded-2xl border border-border-seam bg-bg-surface px-3 py-2.5 text-sm\">\n {hiddenInput}\n <span className=\"inline-flex min-w-0 items-center gap-2 text-text-primary\">\n <FileCheck2 className=\"h-4 w-4 shrink-0 text-status-success-text\" aria-hidden=\"true\" />\n <span className=\"truncate\">{fileName ?? 'Cover selected'}</span>\n </span>\n <button\n type=\"button\"\n onClick={clear}\n aria-label=\"Remove cover\"\n className=\"text-text-tertiary hover:text-text-primary\"\n >\n <X className=\"h-4 w-4\" aria-hidden=\"true\" />\n </button>\n </div>\n );\n }\n\n // Empty dropzone\n return (\n <div\n onDragOver={(event) => {\n event.preventDefault();\n if (!uploading) setDragActive(true);\n }}\n onDragLeave={(event) => {\n event.preventDefault();\n setDragActive(false);\n }}\n onDrop={onDrop}\n className={cn(\n 'rounded-2xl border-2 border-dashed px-4 py-6 text-center transition-colors',\n dragActive\n ? 'border-accent bg-[var(--color-accent-soft)]'\n : 'border-border-seam bg-bg-sunken/40'\n )}\n >\n {hiddenInput}\n {uploading ? (\n <div className=\"flex items-center justify-center gap-2 text-sm text-text-secondary\">\n <Loader2 className=\"h-5 w-5 animate-spin\" aria-hidden=\"true\" /> Uploading cover…\n </div>\n ) : (\n <div className=\"flex flex-col items-center justify-center gap-3 sm:flex-row\">\n <UploadCloud className=\"h-8 w-8 text-accent\" aria-hidden=\"true\" />\n <p className=\"text-sm text-text-secondary\">Drag and drop an image here, or</p>\n <Button type=\"button\" size=\"sm\" onClick={() => inputRef.current?.click()}>\n Upload cover\n </Button>\n </div>\n )}\n <p className=\"mt-3 text-xs text-text-tertiary\">\n Recommended: 16:9 ratio, min 1200×675px. JPG or PNG, up to {COVER_MAX_MB} MB.\n </p>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Dialog\n// ---------------------------------------------------------------------------\n\ninterface CreateStoryDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Pre-select a topic (e.g. from a topic detail page). */\n topicId?: string;\n onCreated?: (story: TcpStory) => void;\n}\n\nexport function CreateStoryDialog({\n open,\n onOpenChange,\n topicId,\n onCreated,\n}: CreateStoryDialogProps) {\n const createStory = useTcpCreateStory();\n const topicsQuery = useTcpTopics({ pagination: { limit: 100 } });\n\n const [title, setTitle] = useState('');\n const [slug, setSlug] = useState('');\n const [slugTouched, setSlugTouched] = useState(false);\n const [summary, setSummary] = useState('');\n const [body, setBody] = useState('');\n const [format, setFormat] = useState<TcpStoryFormat>('ARTICLE');\n const [pickedTopic, setPickedTopic] = useState(topicId ?? '');\n const [languages, setLanguages] = useState<string[]>([]);\n const [tags, setTags] = useState<string[]>([]);\n const [readingMins, setReadingMins] = useState('');\n const [coverFileId, setCoverFileId] = useState<string | null>(null);\n const [error, setError] = useState<string | null>(null);\n // Bumped on reset to force the cover dropzone to drop its local preview state.\n const [resetNonce, setResetNonce] = useState(0);\n\n const effectiveSlug = slugTouched ? slug : slugify(title);\n\n const reset = () => {\n setTitle('');\n setSlug('');\n setSlugTouched(false);\n setSummary('');\n setBody('');\n setFormat('ARTICLE');\n setPickedTopic(topicId ?? '');\n setLanguages([]);\n setTags([]);\n setReadingMins('');\n setCoverFileId(null);\n setError(null);\n setResetNonce((n) => n + 1);\n };\n\n const submit = async () => {\n if (!title.trim()) {\n setError('A title is required.');\n return;\n }\n if (!effectiveSlug) {\n setError('A URL slug is required.');\n return;\n }\n try {\n const created = await createStory.mutateAsync({\n title: title.trim(),\n slug: effectiveSlug,\n summary: summary.trim() || null,\n body: body.trim() || null,\n format,\n topicId: pickedTopic || null,\n languages: languages.length ? languages : null,\n tags: tags.length ? tags : null,\n readingMins: readingMins ? Number(readingMins) : null,\n coverFileId,\n });\n notify.success('Story created', created.title);\n onOpenChange(false);\n reset();\n onCreated?.(created);\n } catch (err) {\n // Keep the dialog open with the entered values and surface the failure in\n // both the inline alert and a toast, so a failed create is never silent.\n const message = describeError(err);\n setError(message);\n notify.error('Could not create the story', message);\n }\n };\n\n return (\n <ResponsiveDialog open={open} onOpenChange={onOpenChange}>\n <ResponsiveDialogContent\n className=\"flex max-h-[90dvh] flex-col overflow-hidden sm:max-w-3xl\"\n data-testid=\"create-story-dialog\"\n >\n <ResponsiveDialogHeader className=\"shrink-0\">\n <ResponsiveDialogTitle className=\"font-display\">Draft a story</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n Begin a new piece — it enters the editorial lifecycle as a draft you can refine and\n publish later.\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n\n <div\n data-testid=\"create-story-dialog-body\"\n className=\"flex min-h-0 max-h-[52dvh] flex-1 flex-col gap-5 overflow-y-auto overscroll-contain py-2 pe-1 md:max-h-none\"\n >\n {/* Cover image */}\n <div className=\"grid gap-1.5\">\n <Label>Cover image</Label>\n <CoverDropzone\n key={resetNonce}\n coverFileId={coverFileId}\n onUploaded={setCoverFileId}\n onCleared={() => setCoverFileId(null)}\n />\n </div>\n\n {/* Title + slug */}\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-title\">Title</Label>\n <Input\n id=\"story-title\"\n value={title}\n onChange={(e) => setTitle(e.target.value)}\n placeholder=\"e.g. The Weavers of the Coromandel Coast\"\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-slug\">URL slug</Label>\n <div className=\"relative\">\n <Input\n id=\"story-slug\"\n value={effectiveSlug}\n onChange={(e) => {\n setSlugTouched(true);\n setSlug(slugify(e.target.value));\n }}\n placeholder=\"the-weavers-of-the-coromandel-coast\"\n className={effectiveSlug ? 'pe-9' : undefined}\n />\n {effectiveSlug && (\n <CheckCircle2\n className=\"pointer-events-none absolute end-3 top-1/2 h-4 w-4 -translate-y-1/2 text-status-success-text\"\n aria-hidden=\"true\"\n />\n )}\n </div>\n <p className=\"text-xs text-text-tertiary\">\n Auto-derived from the title — used in the story’s URL, so keep it unique.\n </p>\n </div>\n </div>\n\n {/* Format + reading time */}\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label>Format</Label>\n <Select value={format} onValueChange={(v) => setFormat(v as TcpStoryFormat)}>\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {FORMATS.map((f) => (\n <SelectItem key={f} value={f}>\n {formatEnumLabel(f)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-reading\">Reading time (min)</Label>\n <Input\n id=\"story-reading\"\n type=\"number\"\n min={0}\n value={readingMins}\n onChange={(e) => setReadingMins(e.target.value)}\n placeholder=\"Optional\"\n />\n </div>\n </div>\n\n {/* Topic */}\n <div className=\"grid gap-1.5\">\n <Label>Topic</Label>\n <Select value={pickedTopic} onValueChange={setPickedTopic}>\n <SelectTrigger>\n <SelectValue placeholder=\"Choose a topic (optional)\" />\n </SelectTrigger>\n <SelectContent>\n {(topicsQuery.data?.items ?? []).map((topic) => (\n <SelectItem key={topic.id} value={topic.id}>\n {topic.name}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n\n {/* Summary */}\n <div className=\"grid gap-1.5\">\n <div className=\"flex items-center justify-between gap-2\">\n <Label htmlFor=\"story-summary\">Summary</Label>\n <span className=\"text-xs tabular-nums text-text-tertiary\">\n {summary.length}/{SUMMARY_MAX}\n </span>\n </div>\n <Textarea\n id=\"story-summary\"\n value={summary}\n onChange={(e) => setSummary(e.target.value.slice(0, SUMMARY_MAX))}\n maxLength={SUMMARY_MAX}\n placeholder=\"A short standfirst that introduces the story.\"\n rows={2}\n />\n </div>\n\n <FramingPrompts />\n\n {/* Body */}\n <div className=\"grid gap-1.5\">\n <div className=\"flex items-center justify-between gap-2\">\n <Label htmlFor=\"story-body\">Body</Label>\n <span className=\"text-xs tabular-nums text-text-tertiary\">\n {body.length} {body.length === 1 ? 'character' : 'characters'}\n </span>\n </div>\n <Textarea\n id=\"story-body\"\n value={body}\n onChange={(e) => setBody(e.target.value)}\n placeholder=\"Write the story… (line breaks are preserved)\"\n rows={5}\n />\n </div>\n\n {/* Languages + tags */}\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-langs\">Languages</Label>\n <TagInput\n id=\"story-langs\"\n value={languages}\n onChange={setLanguages}\n placeholder=\"e.g. English, Tamil…\"\n preserveCase\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-tags\">Tags</Label>\n <TagInput id=\"story-tags\" value={tags} onChange={setTags} placeholder=\"Add tags…\" />\n </div>\n </div>\n\n {error && <p className=\"text-sm text-status-error-text\">{error}</p>}\n </div>\n\n <ResponsiveDialogFooter\n data-testid=\"create-story-dialog-footer\"\n className=\"shrink-0 border-t border-border-seam pt-3\"\n >\n <Button variant=\"outline\" onClick={() => onOpenChange(false)}>\n Cancel\n </Button>\n <Button onClick={submit} disabled={createStory.isPending}>\n {createStory.isPending ? (\n <>\n <Loader2 className=\"me-1.5 h-4 w-4 animate-spin\" aria-hidden=\"true\" /> Creating…\n </>\n ) : (\n 'Create story'\n )}\n </Button>\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAyCA,IAAME,KAA4B;CAChC;CACA;CACA;CACA;CACA;CACA;AACF,GAEMC,IAAc,KACdC,IAAe;AAYrB,SAASC,GAAc,EAAE,gBAAa,eAAY,gBAAiC;CACjF,IAAMC,IAAWC,EAAgC,IAAI,GAC/C,CAACC,GAAWC,KAAgBC,EAAS,EAAK,GAC1C,CAACC,GAAYC,KAAiBF,EAAS,EAAK,GAC5C,CAACG,GAAYC,KAAiBJ,EAAwB,IAAI,GAC1D,CAACK,GAAUC,KAAeN,EAAwB,IAAI,GAEtDO,IAAa,OAAO,MAAe;EACvC,IAAI,CAACC,EAAK,KAAK,WAAW,QAAQ,GAChC,EAAO,MAAM,oBAAoB,sCAAsC;OAGzE,IAAIA,EAAK,OAAOd,IAAe,OAAO,MACpC,EAAO,MAAM,kBAAkB,gCAAgCA,EAAa,KAAK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AC0B,GACH,EAAS,yBAAyB;YAGpC,IAAI;QACF,IAAM0B,IAAU,MAAMxD,EAAY,YAAY;SAC5C,OAAOI,EAAM,KAAK;SAClB,MAAM0B;SACN,SAASpB,EAAQ,KAAK,KAAK;SAC3B,MAAME,EAAK,KAAK,KAAK;SACrB;SACA,SAASI,KAAe;SACxB,WAAWG,EAAU,SAASA,IAAY;SAC1C,MAAME,EAAK,SAASA,IAAO;SAC3B,aAAaE,IAAc,OAAOA,CAAW,IAAI;SACjD;QACF,CAAC;QAID,AAHAxC,EAAO,QAAQ,iBAAiByE,EAAQ,KAAK,GAC7CD,EAAa,EAAK,GAClBvB,GAAM,GACNyB,IAAYD,CAAO;OACrB,SAASxE,GAAK;QAGZ,IAAM0E,IAAUzE,GAAcD,CAAG;QAEjC,AADA2C,EAAS+B,CAAO,GAChB3E,EAAO,MAAM,8BAA8B2E,CAAO;OACpD;MACF;MAoLiC,UAAU1D,EAAY;MAC5C,UAAAA,EAAY,YACX,kBAAAxC,GAAA,EAAA,UAAA,CACE,kBAACoC,GAAD;OAAS,WAAU;OAA8B,eAAY;MAAQ,CAAA,GAAC,YACtE,EAAA,CAAA,IAEF;KAEI,CAAA,CACc;;GACD;;CACT,CAAA;AAEtB"}
|
|
@@ -40,7 +40,7 @@ function f({ discussion: f, onOpen: p }) {
|
|
|
40
40
|
/* @__PURE__ */ l("button", {
|
|
41
41
|
type: "button",
|
|
42
42
|
onClick: p,
|
|
43
|
-
className: "font-display text-
|
|
43
|
+
className: "font-display text-start text-base font-semibold leading-snug text-text-primary hover:underline",
|
|
44
44
|
children: f.title
|
|
45
45
|
}),
|
|
46
46
|
f.prompt && /* @__PURE__ */ l("p", {
|