sea-dev 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/tasks/README.md +89 -0
- package/.cursor/rules/commits.mdc +31 -0
- package/.cursor/rules/general.mdc +84 -0
- package/.github/workflows/ci-cd.yml +141 -0
- package/CLAUDE.md +337 -0
- package/README.md +129 -0
- package/apps/api/.prettierignore +6 -0
- package/apps/api/.prettierrc.js +3 -0
- package/apps/api/dotenvx-safe.sh +11 -0
- package/apps/api/eslint.config.mjs +3 -0
- package/apps/api/package.json +58 -0
- package/apps/api/src/clients/posthog.ts +25 -0
- package/apps/api/src/dal/submission.ts +59 -0
- package/apps/api/src/errors.ts +55 -0
- package/apps/api/src/index.ts +21 -0
- package/apps/api/src/lib/channel.ts +28 -0
- package/apps/api/src/lib/config.ts +9 -0
- package/apps/api/src/lib/fmt.test.ts +9 -0
- package/apps/api/src/lib/fmt.ts +62 -0
- package/apps/api/src/lib/invariant.ts +23 -0
- package/apps/api/src/middleware/auth.ts +66 -0
- package/apps/api/src/routes/index.ts +20 -0
- package/apps/api/src/routes/v2/chat/handlers.ts +693 -0
- package/apps/api/src/routes/v2/chat/index.ts +257 -0
- package/apps/api/src/routes/v2/chat/schemas.ts +43 -0
- package/apps/api/src/routes/v2/deals/handlers.ts +64 -0
- package/apps/api/src/routes/v2/deals/index.ts +88 -0
- package/apps/api/src/routes/v2/deals/schemas.ts +38 -0
- package/apps/api/src/routes/v2/forms/handlers.ts +415 -0
- package/apps/api/src/routes/v2/forms/index.ts +382 -0
- package/apps/api/src/routes/v2/forms/schemas.ts +243 -0
- package/apps/api/src/routes/v2/index.ts +19 -0
- package/apps/api/src/routes/v2/pipelines/handlers.ts +261 -0
- package/apps/api/src/routes/v2/pipelines/index.ts +224 -0
- package/apps/api/src/routes/v2/pipelines/schemas.ts +173 -0
- package/apps/api/src/routes/v2/submissions/handlers.ts +555 -0
- package/apps/api/src/routes/v2/submissions/index.ts +366 -0
- package/apps/api/src/routes/v2/submissions/schemas.ts +233 -0
- package/apps/api/src/routes/v2/workflows/handlers.ts +81 -0
- package/apps/api/src/routes/v2/workflows/index.ts +88 -0
- package/apps/api/src/routes/v2/workflows/schemas.ts +40 -0
- package/apps/api/src/server.ts +146 -0
- package/apps/api/src/static/favicon.ico +0 -0
- package/apps/api/src/types/api.ts +14 -0
- package/apps/api/src/types/result.ts +3 -0
- package/apps/api/tsconfig.json +22 -0
- package/apps/api/vite.config.ts +28 -0
- package/apps/api/vitest.config.ts +14 -0
- package/apps/conversion-worker/Dockerfile +59 -0
- package/apps/conversion-worker/package.json +31 -0
- package/apps/conversion-worker/src/lib/config.ts +7 -0
- package/apps/conversion-worker/src/main.ts +22 -0
- package/apps/conversion-worker/src/workflows/convert-pptx.ts +116 -0
- package/apps/conversion-worker/tsconfig.json +27 -0
- package/apps/conversion-worker/vite.config.ts +33 -0
- package/apps/main/.prettierignore +6 -0
- package/apps/main/.prettierrc.js +3 -0
- package/apps/main/CLAUDE.md +245 -0
- package/apps/main/Procfile +1 -0
- package/apps/main/README.md +193 -0
- package/apps/main/db-tests.jsonl +116 -0
- package/apps/main/dotenvx-safe.sh +11 -0
- package/apps/main/drizzle/meta/_journal.json +1 -0
- package/apps/main/drizzle.config.ts +25 -0
- package/apps/main/eslint.config.mjs +3 -0
- package/apps/main/generate-routes.mjs +5 -0
- package/apps/main/package.json +131 -0
- package/apps/main/playwright.config.ts +23 -0
- package/apps/main/postcss.config.ts +5 -0
- package/apps/main/public/bg-dark.svg +10 -0
- package/apps/main/public/bg.svg +10 -0
- package/apps/main/public/favicon.ico +0 -0
- package/apps/main/run.sh +146 -0
- package/apps/main/scripts/browser.ts +14 -0
- package/apps/main/scripts/db-test-cov.ts +277 -0
- package/apps/main/scripts/login.ts +78 -0
- package/apps/main/scripts/repl.ts +61 -0
- package/apps/main/src/_foo.ts +31 -0
- package/apps/main/src/_tests/db.test.ts +19 -0
- package/apps/main/src/_tests/mock-db.ts +60 -0
- package/apps/main/src/client.tsx +13 -0
- package/apps/main/src/clients/loops.ts +13 -0
- package/apps/main/src/clients/polar.ts +12 -0
- package/apps/main/src/clients/posthog.ts +12 -0
- package/apps/main/src/components/chat/chat-context.tsx +99 -0
- package/apps/main/src/components/chat/chat-messages.tsx +184 -0
- package/apps/main/src/components/chat/chat-status.tsx +140 -0
- package/apps/main/src/components/chat/chat.tsx +458 -0
- package/apps/main/src/components/chat/citation-modal.tsx +54 -0
- package/apps/main/src/components/cta.tsx +21 -0
- package/apps/main/src/components/data-display/derived.tsx +40 -0
- package/apps/main/src/components/data-display/group-single.tsx +57 -0
- package/apps/main/src/components/data-display/group-table.tsx +165 -0
- package/apps/main/src/components/data-display/group-wrapper.tsx +54 -0
- package/apps/main/src/components/data-display/item.tsx +678 -0
- package/apps/main/src/components/error.tsx +45 -0
- package/apps/main/src/components/forms/error.tsx +22 -0
- package/apps/main/src/components/grid.tsx +7 -0
- package/apps/main/src/components/header/container.tsx +73 -0
- package/apps/main/src/components/header/header-bar.tsx +102 -0
- package/apps/main/src/components/modals/copy-display.tsx +37 -0
- package/apps/main/src/components/modals/copy-form.tsx +152 -0
- package/apps/main/src/components/modals/duplicate-workflow.tsx +89 -0
- package/apps/main/src/components/modals/field-correction.tsx +323 -0
- package/apps/main/src/components/modals/form-viewer.tsx +126 -0
- package/apps/main/src/components/modals/modals.tsx +44 -0
- package/apps/main/src/components/modals/new-deal.tsx +78 -0
- package/apps/main/src/components/modals/new-form.tsx +133 -0
- package/apps/main/src/components/modals/new-pipeline.tsx +70 -0
- package/apps/main/src/components/modals/new-submission.tsx +321 -0
- package/apps/main/src/components/modals/new-workflow.tsx +342 -0
- package/apps/main/src/components/modals/transformation-sources-modal.tsx +157 -0
- package/apps/main/src/components/modals/view-report.tsx +193 -0
- package/apps/main/src/components/not-found.tsx +14 -0
- package/apps/main/src/components/search/search-bar.tsx +178 -0
- package/apps/main/src/components/sheet-selector.tsx +135 -0
- package/apps/main/src/components/side-panel/doc-list.tsx +480 -0
- package/apps/main/src/components/sidebar/admin-sidebar.tsx +75 -0
- package/apps/main/src/components/sidebar/app-sidebar.tsx +417 -0
- package/apps/main/src/components/sidebar/model-select.tsx +134 -0
- package/apps/main/src/components/sidebar/settings-sidebar.tsx +132 -0
- package/apps/main/src/components/sidebar/sidebar-right.tsx +22 -0
- package/apps/main/src/components/sidebar/stop-impersonate.tsx +21 -0
- package/apps/main/src/components/svg/loading.tsx +33 -0
- package/apps/main/src/components/theme-selector.tsx +43 -0
- package/apps/main/src/components/unsaved-badge.tsx +19 -0
- package/apps/main/src/components/upload/file-upload.tsx +354 -0
- package/apps/main/src/fns/submission-groups.ts +28 -0
- package/apps/main/src/fns/submission-items.ts +11 -0
- package/apps/main/src/global-middleware.ts +16 -0
- package/apps/main/src/hooks/use-update-state.ts +18 -0
- package/apps/main/src/lib/auth-client.ts +16 -0
- package/apps/main/src/lib/auth.test.ts +359 -0
- package/apps/main/src/lib/auth.ts +144 -0
- package/apps/main/src/lib/billing.ts +23 -0
- package/apps/main/src/lib/config-iso.ts +76 -0
- package/apps/main/src/lib/config.ts +61 -0
- package/apps/main/src/lib/excel.ts +16 -0
- package/apps/main/src/lib/feedback-cache.ts +70 -0
- package/apps/main/src/lib/logger.ts +44 -0
- package/apps/main/src/lib/models.ts +22 -0
- package/apps/main/src/lib/not-found.ts +17 -0
- package/apps/main/src/lib/pdf.ts +16 -0
- package/apps/main/src/lib/tabularize.ts +54 -0
- package/apps/main/src/lib/utils.ts +10 -0
- package/apps/main/src/lib/zfd.ts +217 -0
- package/apps/main/src/middleware.ts +55 -0
- package/apps/main/src/routeTree.gen.ts +1255 -0
- package/apps/main/src/router.tsx +24 -0
- package/apps/main/src/routes/__root.tsx +92 -0
- package/apps/main/src/routes/_authed/_app/(dashboard)/index.tsx +227 -0
- package/apps/main/src/routes/_authed/_app/agents/$agentId/config.tsx +224 -0
- package/apps/main/src/routes/_authed/_app/agents/$agentId/index.tsx +206 -0
- package/apps/main/src/routes/_authed/_app/agents/-components/agent-actions-menu.tsx +94 -0
- package/apps/main/src/routes/_authed/_app/agents/-components/agent-artifacts.tsx +153 -0
- package/apps/main/src/routes/_authed/_app/agents/-components/agent-chat.tsx +220 -0
- package/apps/main/src/routes/_authed/_app/agents/-components/agent-history-menu.tsx +81 -0
- package/apps/main/src/routes/_authed/_app/agents/-components/agent-model-select.tsx +84 -0
- package/apps/main/src/routes/_authed/_app/agents/-components/agent-relevant-items.tsx +226 -0
- package/apps/main/src/routes/_authed/_app/agents/-components/agent-upload-button.tsx +298 -0
- package/apps/main/src/routes/_authed/_app/agents/-components/context-modal.tsx +187 -0
- package/apps/main/src/routes/_authed/_app/agents/-fns.ts +560 -0
- package/apps/main/src/routes/_authed/_app/agents/index.tsx +65 -0
- package/apps/main/src/routes/_authed/_app/deals/$dealId/$subId/-components/citation-tree.tsx +268 -0
- package/apps/main/src/routes/_authed/_app/deals/$dealId/$subId.tsx +655 -0
- package/apps/main/src/routes/_authed/_app/deals/$dealId/-components/doc-loading.tsx +37 -0
- package/apps/main/src/routes/_authed/_app/deals/$dealId/-components/share-link.tsx +42 -0
- package/apps/main/src/routes/_authed/_app/deals/$dealId/-components/submission-card.tsx +89 -0
- package/apps/main/src/routes/_authed/_app/deals/$dealId/-components/submission-filter.tsx +193 -0
- package/apps/main/src/routes/_authed/_app/deals/$dealId/-components/submissions.tsx +36 -0
- package/apps/main/src/routes/_authed/_app/deals/$dealId/-components/summary.tsx +82 -0
- package/apps/main/src/routes/_authed/_app/deals/$dealId/-components/upload-doc.tsx +120 -0
- package/apps/main/src/routes/_authed/_app/deals/$dealId/-fns.ts +653 -0
- package/apps/main/src/routes/_authed/_app/deals/$dealId/index.tsx +259 -0
- package/apps/main/src/routes/_authed/_app/deals/$dealId/route.tsx +29 -0
- package/apps/main/src/routes/_authed/_app/deals/index.tsx +104 -0
- package/apps/main/src/routes/_authed/_app/feedback/index.tsx +639 -0
- package/apps/main/src/routes/_authed/_app/feedback/insights.tsx +250 -0
- package/apps/main/src/routes/_authed/_app/pipelines/$pipelineId/$runId/-components/blockers-panel.tsx +260 -0
- package/apps/main/src/routes/_authed/_app/pipelines/$pipelineId/$runId/-components/manual-input-panel.tsx +301 -0
- package/apps/main/src/routes/_authed/_app/pipelines/$pipelineId/$runId/-components/submission-selector-modal.tsx +143 -0
- package/apps/main/src/routes/_authed/_app/pipelines/$pipelineId/$runId/-components/upload-doc.tsx +120 -0
- package/apps/main/src/routes/_authed/_app/pipelines/$pipelineId/$runId/index.tsx +1485 -0
- package/apps/main/src/routes/_authed/_app/pipelines/$pipelineId/-components/dag-view.tsx +296 -0
- package/apps/main/src/routes/_authed/_app/pipelines/$pipelineId/-components/step-config-modal.tsx +634 -0
- package/apps/main/src/routes/_authed/_app/pipelines/$pipelineId/index.tsx +911 -0
- package/apps/main/src/routes/_authed/_app/pipelines/-fns.ts +510 -0
- package/apps/main/src/routes/_authed/_app/pipelines/index.tsx +103 -0
- package/apps/main/src/routes/_authed/_app/reports/$reportId.tsx +397 -0
- package/apps/main/src/routes/_authed/_app/reports/-fns.ts +11 -0
- package/apps/main/src/routes/_authed/_app/reports/index.tsx +22 -0
- package/apps/main/src/routes/_authed/_app/route.tsx +48 -0
- package/apps/main/src/routes/_authed/_app/submissions/-columns.tsx +161 -0
- package/apps/main/src/routes/_authed/_app/submissions/-fns.ts +128 -0
- package/apps/main/src/routes/_authed/_app/submissions/index.tsx +190 -0
- package/apps/main/src/routes/_authed/_app/workflows/$wfSlug/$formId.tsx +542 -0
- package/apps/main/src/routes/_authed/_app/workflows/$wfSlug/-components/derived.tsx +154 -0
- package/apps/main/src/routes/_authed/_app/workflows/$wfSlug/-components/field.tsx +369 -0
- package/apps/main/src/routes/_authed/_app/workflows/$wfSlug/-components/group.tsx +475 -0
- package/apps/main/src/routes/_authed/_app/workflows/$wfSlug/index.tsx +263 -0
- package/apps/main/src/routes/_authed/_app/workflows/$wfSlug/route.tsx +33 -0
- package/apps/main/src/routes/_authed/_app/workflows/-components/form-card.tsx +315 -0
- package/apps/main/src/routes/_authed/_app/workflows/index.tsx +86 -0
- package/apps/main/src/routes/_authed/admin/index.tsx +12 -0
- package/apps/main/src/routes/_authed/admin/route.tsx +42 -0
- package/apps/main/src/routes/_authed/admin/users/-columns.tsx +124 -0
- package/apps/main/src/routes/_authed/admin/users/-fns.ts +30 -0
- package/apps/main/src/routes/_authed/admin/users/index.tsx +29 -0
- package/apps/main/src/routes/_authed/catchNotFound.tsx +114 -0
- package/apps/main/src/routes/_authed/redirects/forms.$id.tsx +29 -0
- package/apps/main/src/routes/_authed/redirects/submissions.$id.tsx +27 -0
- package/apps/main/src/routes/_authed/redirects/workflows.$id.tsx +27 -0
- package/apps/main/src/routes/_authed/route.tsx +51 -0
- package/apps/main/src/routes/_authed/settings/-components/new-api-key.tsx +85 -0
- package/apps/main/src/routes/_authed/settings/-components/new-invite.tsx +100 -0
- package/apps/main/src/routes/_authed/settings/analytics.tsx +1710 -0
- package/apps/main/src/routes/_authed/settings/billing/-components/price-table.tsx +129 -0
- package/apps/main/src/routes/_authed/settings/billing/-fns.ts +76 -0
- package/apps/main/src/routes/_authed/settings/billing/index.tsx +119 -0
- package/apps/main/src/routes/_authed/settings/embed.tsx +337 -0
- package/apps/main/src/routes/_authed/settings/index.tsx +12 -0
- package/apps/main/src/routes/_authed/settings/keys.tsx +157 -0
- package/apps/main/src/routes/_authed/settings/members.tsx +276 -0
- package/apps/main/src/routes/_authed/settings/route.tsx +22 -0
- package/apps/main/src/routes/_authed/settings/user.tsx +87 -0
- package/apps/main/src/routes/_authed/settings/workspace.tsx +206 -0
- package/apps/main/src/routes/_public/-components/sign-in-up.tsx +96 -0
- package/apps/main/src/routes/_public/embedded.tsx +57 -0
- package/apps/main/src/routes/_public/invite.$inviteId.tsx +143 -0
- package/apps/main/src/routes/_public/no-access.tsx +38 -0
- package/apps/main/src/routes/_public/no-invite.tsx +39 -0
- package/apps/main/src/routes/_public/otp.tsx +103 -0
- package/apps/main/src/routes/_public/route.tsx +15 -0
- package/apps/main/src/routes/_public/sign-in.tsx +111 -0
- package/apps/main/src/routes/_public/sign-up.tsx +114 -0
- package/apps/main/src/routes/api/auth/$.ts +11 -0
- package/apps/main/src/routes/api/billing/paid.ts +42 -0
- package/apps/main/src/routes/api/billing/webhooks.ts +70 -0
- package/apps/main/src/routes/api/chat/agent.ts +40 -0
- package/apps/main/src/routes/api/chat/key.ts +42 -0
- package/apps/main/src/routes/api/chat/member.ts +35 -0
- package/apps/main/src/routes/api/test/index.ts +19 -0
- package/apps/main/src/server.tsx +6 -0
- package/apps/main/src/styles/app.css +23 -0
- package/apps/main/src/vite-env.d.ts +7 -0
- package/apps/main/test.http +6 -0
- package/apps/main/tsconfig.json +17 -0
- package/apps/main/vite.config.ts +24 -0
- package/apps/main/vitest.config.js +17 -0
- package/apps/mcp/README.md +171 -0
- package/apps/mcp/eslint.config.mjs +3 -0
- package/apps/mcp/package.json +37 -0
- package/apps/mcp/src/index.ts +414 -0
- package/apps/mcp/tsconfig.json +19 -0
- package/apps/mcp/vite.config.ts +22 -0
- package/apps/posthog-proxy/index.html +9 -0
- package/apps/workers/.prettierignore +7 -0
- package/apps/workers/.prettierrc.js +3 -0
- package/apps/workers/dotenvx-safe.sh +11 -0
- package/apps/workers/eslint.config.mjs +3 -0
- package/apps/workers/package.json +65 -0
- package/apps/workers/src/lib/config.ts +7 -0
- package/apps/workers/src/lib/messages.ts +0 -0
- package/apps/workers/src/lib/posthog.ts +25 -0
- package/apps/workers/src/main.ts +58 -0
- package/apps/workers/src/workflows/extraction.ts +866 -0
- package/apps/workers/src/workflows/index.ts +3 -0
- package/apps/workers/src/workflows/pipeline-dag.ts +210 -0
- package/apps/workers/src/workflows/pipeline-steps.ts +1393 -0
- package/apps/workers/tsconfig.json +16 -0
- package/apps/workers/vite.config.ts +35 -0
- package/docs/CHANGELOG.md +84 -0
- package/docs/agent-templates-and-runs.md +859 -0
- package/docs/aws-migration-plan.md +267 -0
- package/docs/impl-p0-form-builder-improvements.md +683 -0
- package/docs/on-prem-deployment-spec.docx +0 -0
- package/docs/on-prem-deployment-spec.md +378 -0
- package/docs/prd-form-builder-strategy.md +1120 -0
- package/docs/widget-ng-apf-packaging-spec.md +43 -0
- package/infra/k8s/charts/seadotdev/Chart.yaml +6 -0
- package/infra/k8s/charts/seadotdev/templates/_helpers.tpl +27 -0
- package/infra/k8s/charts/seadotdev/templates/api-v2.yaml +105 -0
- package/infra/k8s/charts/seadotdev/templates/external-secrets.yaml +83 -0
- package/infra/k8s/charts/seadotdev/templates/ingress.yaml +54 -0
- package/infra/k8s/charts/seadotdev/templates/main-app.yaml +104 -0
- package/infra/k8s/charts/seadotdev/templates/workers.yaml +182 -0
- package/infra/k8s/charts/seadotdev/values.yaml +143 -0
- package/infra/terraform/main.tf +399 -0
- package/libs/ai/.prettierignore +2 -0
- package/libs/ai/.prettierrc.js +5 -0
- package/libs/ai/README.md +139 -0
- package/libs/ai/eslint.config.mjs +3 -0
- package/libs/ai/package.json +42 -0
- package/libs/ai/src/index.ts +5 -0
- package/libs/ai/src/models.ts +19 -0
- package/libs/ai/src/rag/index.ts +1 -0
- package/libs/ai/src/rag/rag.test.ts +99 -0
- package/libs/ai/src/rag/rag.ts +510 -0
- package/libs/ai/tsconfig.json +21 -0
- package/libs/ai/vite.config.ts +38 -0
- package/libs/cache/.prettierignore +2 -0
- package/libs/cache/eslint.config.mjs +3 -0
- package/libs/cache/package.json +35 -0
- package/libs/cache/src/feedback.ts +77 -0
- package/libs/cache/src/index.ts +2 -0
- package/libs/cache/tsconfig.json +19 -0
- package/libs/cache/vite.config.ts +36 -0
- package/libs/clients/.prettierignore +6 -0
- package/libs/clients/eslint.config.mjs +3 -0
- package/libs/clients/package.json +59 -0
- package/libs/clients/src/azure.ts +249 -0
- package/libs/clients/src/gcp.ts +220 -0
- package/libs/clients/src/hatchet.ts +86 -0
- package/libs/clients/src/index.ts +8 -0
- package/libs/clients/src/loops.ts +86 -0
- package/libs/clients/src/polar.ts +77 -0
- package/libs/clients/src/posthog.ts +55 -0
- package/libs/clients/tsconfig.json +19 -0
- package/libs/clients/vite.config.ts +35 -0
- package/libs/config/.prettierignore +6 -0
- package/libs/config/.prettierrc.js +12 -0
- package/libs/config/eslint.config.mjs +3 -0
- package/libs/config/package.json +50 -0
- package/libs/config/src/azure.ts +54 -0
- package/libs/config/src/db.ts +18 -0
- package/libs/config/src/gcp.ts +53 -0
- package/libs/config/src/google.ts +17 -0
- package/libs/config/src/hatchet.ts +20 -0
- package/libs/config/src/index.ts +108 -0
- package/libs/config/src/llm.ts +17 -0
- package/libs/config/src/polar.ts +24 -0
- package/libs/config/src/util.ts +8 -0
- package/libs/config/src/vercel.ts +26 -0
- package/libs/config/tsconfig.json +19 -0
- package/libs/config/vite.config.ts +34 -0
- package/libs/core/.prettierignore +2 -0
- package/libs/core/eslint.config.mjs +3 -0
- package/libs/core/package.json +59 -0
- package/libs/core/src/chat/derived.ts +97 -0
- package/libs/core/src/chat/feedback.ts +293 -0
- package/libs/core/src/chat/index.ts +6 -0
- package/libs/core/src/chat/model.ts +92 -0
- package/libs/core/src/chat/prepare-tools.ts +286 -0
- package/libs/core/src/chat/prompts.ts +623 -0
- package/libs/core/src/chat/stream.ts +311 -0
- package/libs/core/src/chat/summarize.ts +168 -0
- package/libs/core/src/chat/tools/agent.ts +403 -0
- package/libs/core/src/chat/tools/chart-agent.ts +526 -0
- package/libs/core/src/chat/tools/chart-helpers/sandbox.ts +47 -0
- package/libs/core/src/chat/tools/chart.ts +86 -0
- package/libs/core/src/chat/tools/credit-agent.ts +1383 -0
- package/libs/core/src/chat/tools/credit.ts +1435 -0
- package/libs/core/src/chat/tools/deep-dive-agent.ts +100 -0
- package/libs/core/src/chat/tools/deep-dive.ts +141 -0
- package/libs/core/src/chat/tools/form.ts +449 -0
- package/libs/core/src/chat/tools/helpers.ts +91 -0
- package/libs/core/src/chat/tools/index.ts +42 -0
- package/libs/core/src/chat/tools/pipeline-artifact.ts +76 -0
- package/libs/core/src/chat/tools/report.ts +40 -0
- package/libs/core/src/chat/tools/search.ts +390 -0
- package/libs/core/src/chat/tools/submission.ts +227 -0
- package/libs/core/src/chat/tools/workflow.ts +684 -0
- package/libs/core/src/chat/types.ts +3 -0
- package/libs/core/src/data-extraction/classification/azure.ts +168 -0
- package/libs/core/src/data-extraction/classification/index.ts +1 -0
- package/libs/core/src/data-extraction/dal.ts +246 -0
- package/libs/core/src/data-extraction/form-structure-extractor.ts +294 -0
- package/libs/core/src/data-extraction/index.ts +4 -0
- package/libs/core/src/data-extraction/layout/azure.ts +730 -0
- package/libs/core/src/data-extraction/layout/excel.ts +180 -0
- package/libs/core/src/data-extraction/layout/gcp.ts +1071 -0
- package/libs/core/src/data-extraction/layout/index.ts +266 -0
- package/libs/core/src/data-extraction/layout/plaintext.ts +45 -0
- package/libs/core/src/data-extraction/models.ts +38 -0
- package/libs/core/src/data-extraction/pdf-utils.ts +96 -0
- package/libs/core/src/data-extraction/structuring/bank-statement.ts +1182 -0
- package/libs/core/src/data-extraction/structuring/custom.ts +495 -0
- package/libs/core/src/data-extraction/structuring/index.ts +290 -0
- package/libs/core/src/data-extraction/structuring/prompts.ts +69 -0
- package/libs/core/src/data-extraction/type-guards.ts +110 -0
- package/libs/core/src/data-extraction/types.ts +84 -0
- package/libs/core/src/data-extraction/utils.ts +31 -0
- package/libs/core/src/data-extraction/validation/bank-statement.ts +127 -0
- package/libs/core/src/deals.ts +17 -0
- package/libs/core/src/documents.ts +152 -0
- package/libs/core/src/index.ts +5 -0
- package/libs/core/src/pipelines/display.ts +678 -0
- package/libs/core/src/pipelines/execute.ts +2342 -0
- package/libs/core/src/pipelines/index.ts +4 -0
- package/libs/core/src/pipelines/list.ts +12 -0
- package/libs/core/src/pipelines/runs.ts +53 -0
- package/libs/core/tsconfig.json +20 -0
- package/libs/core/vite.config.ts +56 -0
- package/libs/dal/.prettierignore +6 -0
- package/libs/dal/.prettierrc.js +12 -0
- package/libs/dal/eslint.config.mjs +3 -0
- package/libs/dal/package.json +57 -0
- package/libs/dal/src/_tests/db.test.ts +19 -0
- package/libs/dal/src/_tests/mock-db.ts +60 -0
- package/libs/dal/src/api-key.test.ts +397 -0
- package/libs/dal/src/api-key.ts +110 -0
- package/libs/dal/src/billing.ts +23 -0
- package/libs/dal/src/conversation.test.ts +655 -0
- package/libs/dal/src/conversation.ts +532 -0
- package/libs/dal/src/deal.test.ts +45 -0
- package/libs/dal/src/deal.ts +87 -0
- package/libs/dal/src/defaults-consumer-lending-uk.ts +33 -0
- package/libs/dal/src/defaults-consumer-lending-us.ts +33 -0
- package/libs/dal/src/defaults-private-credit.ts +57 -0
- package/libs/dal/src/defaults-private-equity.ts +51 -0
- package/libs/dal/src/defaults-smb-lending-us.ts +1569 -0
- package/libs/dal/src/defaults-sme-lending-uk-express.ts +1527 -0
- package/libs/dal/src/defaults-sme-lending-uk.ts +1669 -0
- package/libs/dal/src/defaults-types.ts +23 -0
- package/libs/dal/src/defaults.ts +550 -0
- package/libs/dal/src/document.test.ts +70 -0
- package/libs/dal/src/document.ts +192 -0
- package/libs/dal/src/feedback.ts +255 -0
- package/libs/dal/src/form.test.ts +637 -0
- package/libs/dal/src/form.ts +1165 -0
- package/libs/dal/src/index.ts +20 -0
- package/libs/dal/src/invitation.test.ts +746 -0
- package/libs/dal/src/invitation.ts +207 -0
- package/libs/dal/src/member.test.ts +185 -0
- package/libs/dal/src/member.ts +80 -0
- package/libs/dal/src/organization.ts +116 -0
- package/libs/dal/src/permission.ts +25 -0
- package/libs/dal/src/pipeline.test.ts +388 -0
- package/libs/dal/src/pipeline.ts +4222 -0
- package/libs/dal/src/report.ts +199 -0
- package/libs/dal/src/result.ts +16 -0
- package/libs/dal/src/search.ts +172 -0
- package/libs/dal/src/session.test.ts +110 -0
- package/libs/dal/src/session.ts +31 -0
- package/libs/dal/src/submission.test.ts +1304 -0
- package/libs/dal/src/submission.ts +1396 -0
- package/libs/dal/src/tool.ts +159 -0
- package/libs/dal/src/user.ts +16 -0
- package/libs/dal/src/workflow.test.ts +89 -0
- package/libs/dal/src/workflow.ts +262 -0
- package/libs/dal/tsconfig.build.json +4 -0
- package/libs/dal/tsconfig.json +22 -0
- package/libs/dal/vite.config.ts +34 -0
- package/libs/db/.prettierignore +6 -0
- package/libs/db/.prettierrc.js +12 -0
- package/libs/db/eslint.config.mjs +3 -0
- package/libs/db/package.json +52 -0
- package/libs/db/src/index.ts +24 -0
- package/libs/db/src/relations.ts +549 -0
- package/libs/db/src/schema.ts +2 -0
- package/libs/db/src/schemas/api.ts +35 -0
- package/libs/db/src/schemas/conversations.ts +175 -0
- package/libs/db/src/schemas/core.ts +359 -0
- package/libs/db/src/schemas/documents.ts +181 -0
- package/libs/db/src/schemas/feedback.ts +40 -0
- package/libs/db/src/schemas/index.ts +26 -0
- package/libs/db/src/schemas/organisations.ts +97 -0
- package/libs/db/src/schemas/pipelines.ts +440 -0
- package/libs/db/src/schemas/users.ts +95 -0
- package/libs/db/src/types.ts +190 -0
- package/libs/db/src/utils.ts +14 -0
- package/libs/db/tsconfig.json +19 -0
- package/libs/db/vite.config.ts +31 -0
- package/libs/lint/.prettierignore +6 -0
- package/libs/lint/eslint.config.mjs +61 -0
- package/libs/lint/package.json +29 -0
- package/libs/lint/prettier.config.js +12 -0
- package/libs/schemas/.prettierignore +6 -0
- package/libs/schemas/.prettierrc.js +12 -0
- package/libs/schemas/README.md +15 -0
- package/libs/schemas/eslint.config.mjs +3 -0
- package/libs/schemas/package.json +67 -0
- package/libs/schemas/src/core/chat.ts +67 -0
- package/libs/schemas/src/core/core-result.ts +15 -0
- package/libs/schemas/src/core/data-extraction.ts +184 -0
- package/libs/schemas/src/core/layout.ts +478 -0
- package/libs/schemas/src/core/pipeline.ts +128 -0
- package/libs/schemas/src/core/submission.ts +97 -0
- package/libs/schemas/src/db/account.ts +57 -0
- package/libs/schemas/src/db/apiKey.ts +57 -0
- package/libs/schemas/src/db/context.ts +33 -0
- package/libs/schemas/src/db/conversation.ts +65 -0
- package/libs/schemas/src/db/deal.ts +42 -0
- package/libs/schemas/src/db/document.ts +103 -0
- package/libs/schemas/src/db/documentCitation.ts +58 -0
- package/libs/schemas/src/db/documentExtraction.ts +69 -0
- package/libs/schemas/src/db/fieldCorrection.ts +85 -0
- package/libs/schemas/src/db/form.ts +45 -0
- package/libs/schemas/src/db/formField.ts +59 -0
- package/libs/schemas/src/db/formGroup.ts +42 -0
- package/libs/schemas/src/db/impersonation.ts +39 -0
- package/libs/schemas/src/db/index.ts +25 -0
- package/libs/schemas/src/db/invitation.ts +42 -0
- package/libs/schemas/src/db/member.ts +36 -0
- package/libs/schemas/src/db/message.ts +58 -0
- package/libs/schemas/src/db/organization.ts +62 -0
- package/libs/schemas/src/db/session.ts +48 -0
- package/libs/schemas/src/db/submission.ts +54 -0
- package/libs/schemas/src/db/submissionGroup.ts +36 -0
- package/libs/schemas/src/db/submissionItem.ts +33 -0
- package/libs/schemas/src/db/submissionItemVersion.ts +70 -0
- package/libs/schemas/src/db/user.ts +51 -0
- package/libs/schemas/src/db/utils.ts +3 -0
- package/libs/schemas/src/db/verification.ts +36 -0
- package/libs/schemas/src/db/workflow.ts +42 -0
- package/libs/schemas/src/index.ts +10 -0
- package/libs/schemas/tsconfig.json +21 -0
- package/libs/schemas/vite.config.ts +38 -0
- package/libs/ui/.prettierignore +6 -0
- package/libs/ui/.prettierrc.js +12 -0
- package/libs/ui/components.json +24 -0
- package/libs/ui/eslint.config.mjs +3 -0
- package/libs/ui/package.json +142 -0
- package/libs/ui/src/components/chart-viz/chart.tsx +255 -0
- package/libs/ui/src/components/chart-viz/converters.ts +474 -0
- package/libs/ui/src/components/chart-viz/dashboard.tsx +146 -0
- package/libs/ui/src/components/chart-viz/index.ts +37 -0
- package/libs/ui/src/components/chart-viz/markdown.tsx +344 -0
- package/libs/ui/src/components/chart-viz/table.tsx +446 -0
- package/libs/ui/src/components/chart-viz/theme-context.tsx +70 -0
- package/libs/ui/src/components/chart-viz/themes/dark.ts +98 -0
- package/libs/ui/src/components/chart-viz/themes/index.ts +69 -0
- package/libs/ui/src/components/chart-viz/themes/light.ts +98 -0
- package/libs/ui/src/components/chart-viz/themes/tailwind.ts +326 -0
- package/libs/ui/src/components/chart-viz/themes/types.ts +99 -0
- package/libs/ui/src/components/chart-viz/tool-display.tsx +150 -0
- package/libs/ui/src/components/chart-viz/types.ts +95 -0
- package/libs/ui/src/components/doc-viewers/excel/index.tsx +431 -0
- package/libs/ui/src/components/doc-viewers/excel/themes.ts +160 -0
- package/libs/ui/src/components/doc-viewers/image/index.tsx +410 -0
- package/libs/ui/src/components/doc-viewers/pdf/index.tsx +258 -0
- package/libs/ui/src/components/doc-viewers/pdf/virtualized-pdf.tsx +556 -0
- package/libs/ui/src/components/misc/rel-date.tsx +52 -0
- package/libs/ui/src/components/misc/styled-link.tsx +2 -0
- package/libs/ui/src/components/table/data-table.tsx +546 -0
- package/libs/ui/src/components/table/report-table.tsx +305 -0
- package/libs/ui/src/components/table/sortable-column.tsx +34 -0
- package/libs/ui/src/components/ui/accordion.tsx +62 -0
- package/libs/ui/src/components/ui/alert-dialog.tsx +142 -0
- package/libs/ui/src/components/ui/alert.tsx +62 -0
- package/libs/ui/src/components/ui/artifact.tsx +118 -0
- package/libs/ui/src/components/ui/attachments.tsx +388 -0
- package/libs/ui/src/components/ui/avatar.tsx +39 -0
- package/libs/ui/src/components/ui/badge.tsx +43 -0
- package/libs/ui/src/components/ui/breadcrumb.tsx +102 -0
- package/libs/ui/src/components/ui/button-group.tsx +78 -0
- package/libs/ui/src/components/ui/button.tsx +79 -0
- package/libs/ui/src/components/ui/card.tsx +32 -0
- package/libs/ui/src/components/ui/carousel.tsx +228 -0
- package/libs/ui/src/components/ui/chain-of-thought.tsx +198 -0
- package/libs/ui/src/components/ui/checkbox.tsx +27 -0
- package/libs/ui/src/components/ui/citation.tsx +34 -0
- package/libs/ui/src/components/ui/code-block.tsx +500 -0
- package/libs/ui/src/components/ui/collapsible.tsx +19 -0
- package/libs/ui/src/components/ui/command.tsx +161 -0
- package/libs/ui/src/components/ui/conversation.tsx +90 -0
- package/libs/ui/src/components/ui/dialog.tsx +142 -0
- package/libs/ui/src/components/ui/dropdown-menu.tsx +246 -0
- package/libs/ui/src/components/ui/highlight.tsx +3 -0
- package/libs/ui/src/components/ui/hover-card.tsx +36 -0
- package/libs/ui/src/components/ui/inline-citation.tsx +251 -0
- package/libs/ui/src/components/ui/input-group.tsx +156 -0
- package/libs/ui/src/components/ui/input-otp.tsx +78 -0
- package/libs/ui/src/components/ui/input.tsx +21 -0
- package/libs/ui/src/components/ui/label.tsx +19 -0
- package/libs/ui/src/components/ui/model-selector.tsx +174 -0
- package/libs/ui/src/components/ui/multisidebar.tsx +750 -0
- package/libs/ui/src/components/ui/popover.tsx +43 -0
- package/libs/ui/src/components/ui/progress.tsx +28 -0
- package/libs/ui/src/components/ui/reasoning.tsx +178 -0
- package/libs/ui/src/components/ui/resizable.tsx +49 -0
- package/libs/ui/src/components/ui/scroll-area.tsx +54 -0
- package/libs/ui/src/components/ui/select.tsx +171 -0
- package/libs/ui/src/components/ui/separator.tsx +26 -0
- package/libs/ui/src/components/ui/sheet.tsx +128 -0
- package/libs/ui/src/components/ui/shimmer.tsx +53 -0
- package/libs/ui/src/components/ui/skeleton.tsx +13 -0
- package/libs/ui/src/components/ui/sonner.tsx +23 -0
- package/libs/ui/src/components/ui/switch.tsx +26 -0
- package/libs/ui/src/components/ui/table.tsx +96 -0
- package/libs/ui/src/components/ui/tabs.tsx +52 -0
- package/libs/ui/src/components/ui/textarea.tsx +41 -0
- package/libs/ui/src/components/ui/tool.tsx +209 -0
- package/libs/ui/src/components/ui/tooltip.tsx +58 -0
- package/libs/ui/src/components/ui/typography.tsx +113 -0
- package/libs/ui/src/fonts/manrope-v15-latin-300.woff2 +0 -0
- package/libs/ui/src/fonts/manrope-v15-latin-400.woff2 +0 -0
- package/libs/ui/src/fonts/manrope-v15-latin-500.woff2 +0 -0
- package/libs/ui/src/fonts/manrope-v15-latin-600.woff2 +0 -0
- package/libs/ui/src/hooks/use-mobile.ts +19 -0
- package/libs/ui/src/lib/utils.ts +6 -0
- package/libs/ui/src/styles/fonts.css +35 -0
- package/libs/ui/src/styles/style.css +218 -0
- package/libs/ui/tsconfig.json +21 -0
- package/libs/ui/vite.config.ts +80 -0
- package/libs/ui-lit/README.md +245 -0
- package/libs/ui-lit/TESTING_GUIDE.md +296 -0
- package/libs/ui-lit/eslint.config.mjs +3 -0
- package/libs/ui-lit/package.json +41 -0
- package/libs/ui-lit/scripts/build-css.js +43 -0
- package/libs/ui-lit/src/components/sea-alert.ts +132 -0
- package/libs/ui-lit/src/components/sea-button.ts +95 -0
- package/libs/ui-lit/src/components/sea-card.ts +113 -0
- package/libs/ui-lit/src/components/sea-input.ts +184 -0
- package/libs/ui-lit/src/components/sea-spinner.ts +65 -0
- package/libs/ui-lit/src/index.ts +15 -0
- package/libs/ui-lit/src/lib/utils.ts +6 -0
- package/libs/ui-lit/src/styles/tailwind.css +76 -0
- package/libs/ui-lit/src/theme.css +66 -0
- package/libs/ui-lit/src/theme.ts +79 -0
- package/libs/ui-lit/src/vite-env.d.ts +6 -0
- package/libs/ui-lit/tailwind.config.ts +50 -0
- package/libs/ui-lit/test.html +289 -0
- package/libs/ui-lit/tsconfig.json +23 -0
- package/libs/ui-lit/vite.config.ts +31 -0
- package/libs/ui-lit/vite.css.config.ts +20 -0
- package/libs/util/.prettierignore +6 -0
- package/libs/util/.prettierrc.js +12 -0
- package/libs/util/eslint.config.mjs +3 -0
- package/libs/util/package.json +45 -0
- package/libs/util/src/billing.ts +10 -0
- package/libs/util/src/data-transform.ts +19 -0
- package/libs/util/src/encryption.ts +45 -0
- package/libs/util/src/fmt.test.ts +9 -0
- package/libs/util/src/fmt.ts +71 -0
- package/libs/util/src/fuzzy.ts +47 -0
- package/libs/util/src/id.ts +24 -0
- package/libs/util/src/invariant.ts +31 -0
- package/libs/util/src/sub-name.ts +7 -0
- package/libs/util/tsconfig.json +19 -0
- package/libs/util/vite.config.ts +34 -0
- package/package.json +28 -0
- package/packages/widget/.prettierignore +6 -0
- package/packages/widget/.prettierrc.js +12 -0
- package/packages/widget/README.md +95 -0
- package/packages/widget/eslint.config.mjs +11 -0
- package/packages/widget/openapi-ts.config.ts +8 -0
- package/packages/widget/package.json +89 -0
- package/packages/widget/postcss.config.mjs +10 -0
- package/packages/widget/src/clients/api/client/client.ts +187 -0
- package/packages/widget/src/clients/api/client/index.ts +22 -0
- package/packages/widget/src/clients/api/client/types.ts +192 -0
- package/packages/widget/src/clients/api/client/utils.ts +394 -0
- package/packages/widget/src/clients/api/client.gen.ts +18 -0
- package/packages/widget/src/clients/api/core/auth.ts +39 -0
- package/packages/widget/src/clients/api/core/bodySerializer.ts +74 -0
- package/packages/widget/src/clients/api/core/params.ts +132 -0
- package/packages/widget/src/clients/api/core/pathSerializer.ts +169 -0
- package/packages/widget/src/clients/api/core/types.ts +80 -0
- package/packages/widget/src/clients/api/index.ts +3 -0
- package/packages/widget/src/clients/api/sdk.gen.ts +805 -0
- package/packages/widget/src/clients/api/types.gen.ts +2085 -0
- package/packages/widget/src/components/container.tsx +42 -0
- package/packages/widget/src/components/data-display.tsx +384 -0
- package/packages/widget/src/components/data-viewer.tsx +311 -0
- package/packages/widget/src/components/doc-list.tsx +102 -0
- package/packages/widget/src/components/field-correction-modal.tsx +265 -0
- package/packages/widget/src/components/header.tsx +71 -0
- package/packages/widget/src/components/new-submission.tsx +290 -0
- package/packages/widget/src/components/sidebar-right.tsx +19 -0
- package/packages/widget/src/components/submission-card.tsx +66 -0
- package/packages/widget/src/components/submission-page.tsx +75 -0
- package/packages/widget/src/components/upload-doc.tsx +241 -0
- package/packages/widget/src/components/widget.tsx +101 -0
- package/packages/widget/src/index.tsx +167 -0
- package/packages/widget/src/lib/config.ts +2 -0
- package/packages/widget/src/lib/util.ts +40 -0
- package/packages/widget/src/styles/index.css +5 -0
- package/packages/widget/src/styles/tw-properties.css +337 -0
- package/packages/widget/src/vite-env.d.ts +3 -0
- package/packages/widget/tsconfig.app.json +35 -0
- package/packages/widget/tsconfig.json +4 -0
- package/packages/widget/tsconfig.node.json +24 -0
- package/packages/widget/vite.config.ts +116 -0
- package/packages/widget-lit/BOTTLENECKS.md +250 -0
- package/packages/widget-lit/IMPLEMENTATION_SUMMARY.md +295 -0
- package/packages/widget-lit/README.md +232 -0
- package/packages/widget-lit/eslint.config.mjs +3 -0
- package/packages/widget-lit/package.json +52 -0
- package/packages/widget-lit/src/api-client.ts +230 -0
- package/packages/widget-lit/src/api-client.ts.backup +218 -0
- package/packages/widget-lit/src/components/sea-chat.ts +382 -0
- package/packages/widget-lit/src/components/sea-submission-viewer.ts +267 -0
- package/packages/widget-lit/src/components/sea-widget.ts +317 -0
- package/packages/widget-lit/src/index.ts +48 -0
- package/packages/widget-lit/src/react.ts +58 -0
- package/packages/widget-lit/src/style.css +47 -0
- package/packages/widget-lit/tsconfig.json +24 -0
- package/packages/widget-lit/vite.config.ts +29 -0
- package/packages/widget-ng/DEVELOPMENT.md +74 -0
- package/packages/widget-ng/README.md +657 -0
- package/packages/widget-ng/dev.sh +14 -0
- package/packages/widget-ng/eslint.config.mjs +24 -0
- package/packages/widget-ng/ng-package.json +9 -0
- package/packages/widget-ng/package.json +85 -0
- package/packages/widget-ng/src/index.ts +45 -0
- package/packages/widget-ng/src/lib/components/sea-chat.component.ts +737 -0
- package/packages/widget-ng/src/lib/components/sea-data-viewer.component.ts +2240 -0
- package/packages/widget-ng/src/lib/components/sea-deal-form-modal.component.ts +702 -0
- package/packages/widget-ng/src/lib/components/sea-document-list.component.ts +350 -0
- package/packages/widget-ng/src/lib/components/sea-feedback-modal.component.ts +461 -0
- package/packages/widget-ng/src/lib/components/sea-file-upload.component.ts +655 -0
- package/packages/widget-ng/src/lib/components/sea-model-selection-modal.component.ts +367 -0
- package/packages/widget-ng/src/lib/components/sea-new-submission-modal.component.ts +414 -0
- package/packages/widget-ng/src/lib/components/sea-pdf-viewer.component.ts +869 -0
- package/packages/widget-ng/src/lib/components/sea-submission-card.component.ts +251 -0
- package/packages/widget-ng/src/lib/components/sea-widget.component.ts +684 -0
- package/packages/widget-ng/src/lib/models/submission.model.ts +170 -0
- package/packages/widget-ng/src/lib/pipes/markdown.pipe.ts +57 -0
- package/packages/widget-ng/src/lib/services/api-client.service.ts +715 -0
- package/packages/widget-ng/src/lib/services/chat.service.ts +330 -0
- package/packages/widget-ng/src/lib/services/config.service.ts +107 -0
- package/packages/widget-ng/src/web-component.ts +56 -0
- package/packages/widget-ng/tsconfig.json +25 -0
- package/packages/widget-ng/tsconfig.lib.json +9 -0
- package/packages/widget-ng/vite.config.elements.ts +26 -0
- package/packages/widget-ng/vitest.config.ts +19 -0
- package/packages/widget-ng/vitest.setup.ts +13 -0
- package/pnpm-workspace.yaml +18 -0
- package/render.yaml +136 -0
- package/scripts/README.md +57 -0
- package/scripts/package.json +22 -0
- package/scripts/python/.python-version +1 -0
- package/scripts/python/README.md +3 -0
- package/scripts/python/export-org-data.py +693 -0
- package/scripts/python/pyproject.toml +29 -0
- package/scripts/python/requirements-dev.lock +36 -0
- package/scripts/python/requirements.lock +36 -0
- package/scripts/python/src/gen.py +297 -0
- package/scripts/python/test.py +34 -0
- package/scripts/src/fix-storage-provider-mismatch.ts +239 -0
- package/scripts/src/sync-render-yaml.ts +290 -0
- package/scripts/src/test-chat-stream.ts +300 -0
- package/scripts/src/test-reconciliation.ts +230 -0
- package/scripts/tsconfig.json +15 -0
- package/tests/angular-test-app/.vscode/extensions.json +4 -0
- package/tests/angular-test-app/.vscode/launch.json +13 -0
- package/tests/angular-test-app/.vscode/tasks.json +24 -0
- package/tests/angular-test-app/README.md +59 -0
- package/tests/angular-test-app/angular.json +111 -0
- package/tests/angular-test-app/clean-start.sh +14 -0
- package/tests/angular-test-app/package.json +36 -0
- package/tests/angular-test-app/public/favicon.ico +0 -0
- package/tests/angular-test-app/src/app/app.component.ts +220 -0
- package/tests/angular-test-app/src/app/app.config.ts +5 -0
- package/tests/angular-test-app/src/env.d.ts +13 -0
- package/tests/angular-test-app/src/index.html +13 -0
- package/tests/angular-test-app/src/main.ts +6 -0
- package/tests/angular-test-app/src/styles.css +8 -0
- package/tests/angular-test-app/tsconfig.app.json +15 -0
- package/tests/angular-test-app/tsconfig.json +27 -0
- package/tests/crm-viewer-app/API_INTEGRATION_SUMMARY.md +295 -0
- package/tests/crm-viewer-app/CURRENT_ASSETS_FIELDS.md +148 -0
- package/tests/crm-viewer-app/FIELD_ID_MAPPING.md +206 -0
- package/tests/crm-viewer-app/INTEGRATION_GUIDE.md +309 -0
- package/tests/crm-viewer-app/README.md +174 -0
- package/tests/crm-viewer-app/REAL_API_INTEGRATION.md +240 -0
- package/tests/crm-viewer-app/UPDATED_IMPLEMENTATION.md +279 -0
- package/tests/crm-viewer-app/angular.json +114 -0
- package/tests/crm-viewer-app/package.json +35 -0
- package/tests/crm-viewer-app/src/app/app.component.ts +534 -0
- package/tests/crm-viewer-app/src/app/citation.service.ts +316 -0
- package/tests/crm-viewer-app/src/env.d.ts +16 -0
- package/tests/crm-viewer-app/src/index.html +19 -0
- package/tests/crm-viewer-app/src/main.ts +7 -0
- package/tests/crm-viewer-app/src/styles.css +409 -0
- package/tests/crm-viewer-app/src/template.html +2678 -0
- package/tests/crm-viewer-app/tsconfig.app.json +15 -0
- package/tests/crm-viewer-app/tsconfig.json +27 -0
- package/tests/e2e/package.json +17 -0
- package/tests/e2e/playwright.config.ts +75 -0
- package/tests/e2e/tests/api/health.spec.ts +10 -0
- package/tests/e2e/tests/app/example.spec.ts +10 -0
- package/tests/widget-test-app/.prettierignore +6 -0
- package/tests/widget-test-app/README.md +48 -0
- package/tests/widget-test-app/index.html +12 -0
- package/tests/widget-test-app/package.json +24 -0
- package/tests/widget-test-app/src/App.css +192 -0
- package/tests/widget-test-app/src/App.tsx +80 -0
- package/tests/widget-test-app/src/main.tsx +9 -0
- package/tests/widget-test-app/src/vite-env.d.ts +4 -0
- package/tests/widget-test-app/tsconfig.json +25 -0
- package/tests/widget-test-app/tsconfig.node.json +11 -0
- package/tests/widget-test-app/vite.config.ts +14 -0
|
@@ -0,0 +1,2240 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
Input,
|
|
4
|
+
OnInit,
|
|
5
|
+
OnDestroy,
|
|
6
|
+
OnChanges,
|
|
7
|
+
SimpleChanges,
|
|
8
|
+
signal,
|
|
9
|
+
inject,
|
|
10
|
+
ChangeDetectionStrategy,
|
|
11
|
+
Output,
|
|
12
|
+
EventEmitter,
|
|
13
|
+
ViewChild,
|
|
14
|
+
ElementRef,
|
|
15
|
+
} from "@angular/core";
|
|
16
|
+
import { CommonModule } from "@angular/common";
|
|
17
|
+
import { FormsModule } from "@angular/forms";
|
|
18
|
+
import { interval, Subscription, Subject } from "rxjs";
|
|
19
|
+
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
|
|
20
|
+
import { LucideAngularModule, LocateFixed, Pencil } from "lucide-angular";
|
|
21
|
+
import { SeaApiClientService } from "../services/api-client.service";
|
|
22
|
+
import { SeaWidgetConfigService } from "../services/config.service";
|
|
23
|
+
import type {
|
|
24
|
+
Submission,
|
|
25
|
+
SubmissionData,
|
|
26
|
+
Field,
|
|
27
|
+
Document,
|
|
28
|
+
DataGroup,
|
|
29
|
+
} from "../models/submission.model";
|
|
30
|
+
import { SeaPdfViewerComponent } from "./sea-pdf-viewer.component";
|
|
31
|
+
import { SeaFeedbackModalComponent } from "./sea-feedback-modal.component";
|
|
32
|
+
import { SeaDocumentListComponent } from "./sea-document-list.component";
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Data viewer component for displaying extracted submission data
|
|
36
|
+
* Shows fields with optional editing capabilities
|
|
37
|
+
*/
|
|
38
|
+
@Component({
|
|
39
|
+
selector: "sea-data-viewer",
|
|
40
|
+
standalone: true,
|
|
41
|
+
imports: [
|
|
42
|
+
CommonModule,
|
|
43
|
+
FormsModule,
|
|
44
|
+
LucideAngularModule,
|
|
45
|
+
SeaPdfViewerComponent,
|
|
46
|
+
SeaFeedbackModalComponent,
|
|
47
|
+
SeaDocumentListComponent,
|
|
48
|
+
],
|
|
49
|
+
template: `
|
|
50
|
+
<div class="sea-data-viewer">
|
|
51
|
+
<div
|
|
52
|
+
class="sea-data-viewer__content"
|
|
53
|
+
[class.sea-data-viewer__content--with-sidebar]="selectedDocument()"
|
|
54
|
+
>
|
|
55
|
+
@if (loading()) {
|
|
56
|
+
<div class="sea-data-viewer__loading">
|
|
57
|
+
<svg class="sea-spinner" viewBox="0 0 24 24">
|
|
58
|
+
<circle
|
|
59
|
+
cx="12"
|
|
60
|
+
cy="12"
|
|
61
|
+
r="10"
|
|
62
|
+
fill="none"
|
|
63
|
+
stroke="currentColor"
|
|
64
|
+
stroke-width="3"
|
|
65
|
+
opacity="0.25"
|
|
66
|
+
/>
|
|
67
|
+
<circle
|
|
68
|
+
cx="12"
|
|
69
|
+
cy="12"
|
|
70
|
+
r="10"
|
|
71
|
+
fill="none"
|
|
72
|
+
stroke="currentColor"
|
|
73
|
+
stroke-width="3"
|
|
74
|
+
stroke-dasharray="63"
|
|
75
|
+
stroke-dashoffset="50"
|
|
76
|
+
/>
|
|
77
|
+
</svg>
|
|
78
|
+
<p>Loading submission data...</p>
|
|
79
|
+
</div>
|
|
80
|
+
} @else if (error()) {
|
|
81
|
+
<div class="sea-data-viewer__error">
|
|
82
|
+
<svg class="sea-error-icon" viewBox="0 0 24 24">
|
|
83
|
+
<circle
|
|
84
|
+
cx="12"
|
|
85
|
+
cy="12"
|
|
86
|
+
r="10"
|
|
87
|
+
fill="none"
|
|
88
|
+
stroke="currentColor"
|
|
89
|
+
stroke-width="2"
|
|
90
|
+
/>
|
|
91
|
+
<path
|
|
92
|
+
d="M12 8v4m0 4h.01"
|
|
93
|
+
stroke="currentColor"
|
|
94
|
+
stroke-width="2"
|
|
95
|
+
stroke-linecap="round"
|
|
96
|
+
/>
|
|
97
|
+
</svg>
|
|
98
|
+
<p>{{ error()?.message || "Failed to load submission" }}</p>
|
|
99
|
+
</div>
|
|
100
|
+
} @else {
|
|
101
|
+
@if (submissionData(); as data) {
|
|
102
|
+
<div class="sea-data-viewer__header">
|
|
103
|
+
<h2 class="sea-data-viewer__title">Data</h2>
|
|
104
|
+
<div class="sea-data-viewer__meta">
|
|
105
|
+
<span
|
|
106
|
+
class="sea-data-viewer__status"
|
|
107
|
+
[class]="'sea-data-viewer__status--' + data.status"
|
|
108
|
+
>
|
|
109
|
+
{{ data.status }}
|
|
110
|
+
</span>
|
|
111
|
+
@if (
|
|
112
|
+
data.status === "draft" ||
|
|
113
|
+
data.status === "final" ||
|
|
114
|
+
data.status === "finalised"
|
|
115
|
+
) {
|
|
116
|
+
<button
|
|
117
|
+
class="sea-data-viewer__status-button"
|
|
118
|
+
[class.sea-data-viewer__status-button--finalise]="
|
|
119
|
+
data.status === 'draft'
|
|
120
|
+
"
|
|
121
|
+
[class.sea-data-viewer__status-button--draft]="
|
|
122
|
+
data.status === 'final' || data.status === 'finalised'
|
|
123
|
+
"
|
|
124
|
+
[disabled]="updatingStatus()"
|
|
125
|
+
(click)="toggleSubmissionStatus()"
|
|
126
|
+
type="button"
|
|
127
|
+
>
|
|
128
|
+
@if (updatingStatus()) {
|
|
129
|
+
<svg
|
|
130
|
+
class="sea-spinner sea-spinner--small"
|
|
131
|
+
viewBox="0 0 24 24"
|
|
132
|
+
>
|
|
133
|
+
<circle
|
|
134
|
+
cx="12"
|
|
135
|
+
cy="12"
|
|
136
|
+
r="10"
|
|
137
|
+
fill="none"
|
|
138
|
+
stroke="currentColor"
|
|
139
|
+
stroke-width="3"
|
|
140
|
+
opacity="0.25"
|
|
141
|
+
/>
|
|
142
|
+
<circle
|
|
143
|
+
cx="12"
|
|
144
|
+
cy="12"
|
|
145
|
+
r="10"
|
|
146
|
+
fill="none"
|
|
147
|
+
stroke="currentColor"
|
|
148
|
+
stroke-width="3"
|
|
149
|
+
stroke-dasharray="63"
|
|
150
|
+
stroke-dashoffset="50"
|
|
151
|
+
/>
|
|
152
|
+
</svg>
|
|
153
|
+
} @else {
|
|
154
|
+
{{
|
|
155
|
+
data.status === "draft" ? "Finalise" : "Revert to Draft"
|
|
156
|
+
}}
|
|
157
|
+
}
|
|
158
|
+
</button>
|
|
159
|
+
}
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
|
|
163
|
+
@if (data.formGroups && data.formGroups.length > 0) {
|
|
164
|
+
<div class="sea-data-viewer__groups">
|
|
165
|
+
@for (formGroup of data.formGroups; track formGroup.id) {
|
|
166
|
+
@let dataGroups = getDataGroupsForFormGroup(formGroup.id);
|
|
167
|
+
|
|
168
|
+
<div class="sea-form-group">
|
|
169
|
+
<div class="sea-form-group__header">
|
|
170
|
+
<div class="sea-form-group__heading">
|
|
171
|
+
<h3 class="sea-form-group__title">
|
|
172
|
+
{{ formGroup.name }}
|
|
173
|
+
</h3>
|
|
174
|
+
@if (formGroup.hint) {
|
|
175
|
+
<p class="sea-form-group__hint">
|
|
176
|
+
{{ formGroup.hint }}
|
|
177
|
+
</p>
|
|
178
|
+
}
|
|
179
|
+
</div>
|
|
180
|
+
<div class="sea-form-group__meta">
|
|
181
|
+
@if (formGroup.multi) {
|
|
182
|
+
<span
|
|
183
|
+
>{{ dataGroups.length }}
|
|
184
|
+
{{ dataGroups.length === 1 ? "row" : "rows" }}</span
|
|
185
|
+
>
|
|
186
|
+
} @else {
|
|
187
|
+
<span
|
|
188
|
+
>{{ formGroup.fields.length }}
|
|
189
|
+
{{
|
|
190
|
+
formGroup.fields.length === 1 ? "field" : "fields"
|
|
191
|
+
}}</span
|
|
192
|
+
>
|
|
193
|
+
}
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
|
|
197
|
+
<div class="sea-form-group__body">
|
|
198
|
+
@if (formGroup.multi && dataGroups.length > 0) {
|
|
199
|
+
<!-- Collection/Array: Render as table -->
|
|
200
|
+
<div class="sea-table-wrapper">
|
|
201
|
+
<table class="sea-table">
|
|
202
|
+
<thead>
|
|
203
|
+
<tr>
|
|
204
|
+
@for (
|
|
205
|
+
field of formGroup.fields;
|
|
206
|
+
track field.id
|
|
207
|
+
) {
|
|
208
|
+
<th
|
|
209
|
+
[attr.aria-sort]="
|
|
210
|
+
sortState()?.columnId === field.id
|
|
211
|
+
? sortState()?.direction === 'asc'
|
|
212
|
+
? 'ascending'
|
|
213
|
+
: 'descending'
|
|
214
|
+
: 'none'
|
|
215
|
+
"
|
|
216
|
+
>
|
|
217
|
+
<button
|
|
218
|
+
type="button"
|
|
219
|
+
class="sea-table__header--sortable"
|
|
220
|
+
(click)="onColumnHeaderClick(field.id)"
|
|
221
|
+
[attr.aria-label]="
|
|
222
|
+
'Sort by ' + field.name
|
|
223
|
+
"
|
|
224
|
+
>
|
|
225
|
+
<span class="sea-table__header-content">
|
|
226
|
+
{{ field.name }}
|
|
227
|
+
@if (getSortIcon(field.id)) {
|
|
228
|
+
<span class="sea-table__sort-icon">{{
|
|
229
|
+
getSortIcon(field.id)
|
|
230
|
+
}}</span>
|
|
231
|
+
}
|
|
232
|
+
</span>
|
|
233
|
+
</button>
|
|
234
|
+
</th>
|
|
235
|
+
}
|
|
236
|
+
</tr>
|
|
237
|
+
</thead>
|
|
238
|
+
<tbody>
|
|
239
|
+
@for (
|
|
240
|
+
group of getSortedDataGroups(dataGroups);
|
|
241
|
+
track group.id
|
|
242
|
+
) {
|
|
243
|
+
<tr>
|
|
244
|
+
@for (
|
|
245
|
+
field of formGroup.fields;
|
|
246
|
+
track field.id
|
|
247
|
+
) {
|
|
248
|
+
@let item =
|
|
249
|
+
getItemForField(group, field.id);
|
|
250
|
+
<td
|
|
251
|
+
[class.sea-table__cell--selected]="
|
|
252
|
+
isItemSelected(item)
|
|
253
|
+
"
|
|
254
|
+
[class.sea-table__cell--unsaved]="
|
|
255
|
+
isItemUnsaved(item)
|
|
256
|
+
"
|
|
257
|
+
>
|
|
258
|
+
<div class="sea-table-cell">
|
|
259
|
+
<div class="sea-button-group">
|
|
260
|
+
@if (item?.documentCitationId) {
|
|
261
|
+
<button
|
|
262
|
+
class="sea-icon-button sea-icon-button--table sea-citation-btn"
|
|
263
|
+
(click)="
|
|
264
|
+
onItemCitationClick(item)
|
|
265
|
+
"
|
|
266
|
+
type="button"
|
|
267
|
+
aria-label="View source in document"
|
|
268
|
+
>
|
|
269
|
+
<lucide-icon
|
|
270
|
+
[img]="TargetIcon"
|
|
271
|
+
[size]="12"
|
|
272
|
+
></lucide-icon>
|
|
273
|
+
<span
|
|
274
|
+
class="sea-tooltip"
|
|
275
|
+
aria-hidden="true"
|
|
276
|
+
>View source</span
|
|
277
|
+
>
|
|
278
|
+
</button>
|
|
279
|
+
}
|
|
280
|
+
@if (editable) {
|
|
281
|
+
<button
|
|
282
|
+
class="sea-icon-button sea-icon-button--table sea-feedback-btn"
|
|
283
|
+
(click)="
|
|
284
|
+
openFeedbackModal(item, field)
|
|
285
|
+
"
|
|
286
|
+
type="button"
|
|
287
|
+
aria-label="Report incorrect extraction"
|
|
288
|
+
>
|
|
289
|
+
<lucide-icon
|
|
290
|
+
[img]="PencilIcon"
|
|
291
|
+
[size]="12"
|
|
292
|
+
></lucide-icon>
|
|
293
|
+
<span
|
|
294
|
+
class="sea-tooltip"
|
|
295
|
+
aria-hidden="true"
|
|
296
|
+
>Report feedback</span
|
|
297
|
+
>
|
|
298
|
+
</button>
|
|
299
|
+
}
|
|
300
|
+
</div>
|
|
301
|
+
<span class="sea-table-cell__value">{{
|
|
302
|
+
getItemValue(item) || "—"
|
|
303
|
+
}}</span>
|
|
304
|
+
</div>
|
|
305
|
+
</td>
|
|
306
|
+
}
|
|
307
|
+
</tr>
|
|
308
|
+
}
|
|
309
|
+
</tbody>
|
|
310
|
+
</table>
|
|
311
|
+
</div>
|
|
312
|
+
} @else if (!formGroup.multi && dataGroups.length > 0) {
|
|
313
|
+
<!-- Single object: Render as key-value pairs -->
|
|
314
|
+
@let group = dataGroups[0];
|
|
315
|
+
<div class="sea-data-viewer__fields">
|
|
316
|
+
@for (field of formGroup.fields; track field.id) {
|
|
317
|
+
@let item = getItemForField(group, field.id);
|
|
318
|
+
<div
|
|
319
|
+
class="sea-field"
|
|
320
|
+
[class.sea-field--selected]="isItemSelected(item)"
|
|
321
|
+
[class.sea-field--unsaved]="isItemUnsaved(item)"
|
|
322
|
+
>
|
|
323
|
+
<label
|
|
324
|
+
class="sea-field__label"
|
|
325
|
+
[attr.for]="'sea-field-' + field.id"
|
|
326
|
+
>{{ field.name }}</label
|
|
327
|
+
>
|
|
328
|
+
<div class="sea-field__input-wrapper">
|
|
329
|
+
<div class="sea-button-group">
|
|
330
|
+
@if (item?.documentCitationId) {
|
|
331
|
+
<button
|
|
332
|
+
class="sea-icon-button sea-citation-btn"
|
|
333
|
+
(click)="onItemCitationClick(item)"
|
|
334
|
+
type="button"
|
|
335
|
+
aria-label="View source in document"
|
|
336
|
+
>
|
|
337
|
+
<lucide-icon
|
|
338
|
+
[img]="TargetIcon"
|
|
339
|
+
[size]="12"
|
|
340
|
+
></lucide-icon>
|
|
341
|
+
<span
|
|
342
|
+
class="sea-tooltip"
|
|
343
|
+
aria-hidden="true"
|
|
344
|
+
>View source</span
|
|
345
|
+
>
|
|
346
|
+
</button>
|
|
347
|
+
}
|
|
348
|
+
@if (editable) {
|
|
349
|
+
<button
|
|
350
|
+
class="sea-icon-button sea-feedback-btn"
|
|
351
|
+
(click)="openFeedbackModal(item, field)"
|
|
352
|
+
type="button"
|
|
353
|
+
aria-label="Report incorrect extraction"
|
|
354
|
+
>
|
|
355
|
+
<lucide-icon
|
|
356
|
+
[img]="PencilIcon"
|
|
357
|
+
[size]="12"
|
|
358
|
+
></lucide-icon>
|
|
359
|
+
<span
|
|
360
|
+
class="sea-tooltip"
|
|
361
|
+
aria-hidden="true"
|
|
362
|
+
>Report feedback</span
|
|
363
|
+
>
|
|
364
|
+
</button>
|
|
365
|
+
}
|
|
366
|
+
</div>
|
|
367
|
+
<input
|
|
368
|
+
type="text"
|
|
369
|
+
class="sea-field__input"
|
|
370
|
+
[attr.id]="'sea-field-' + field.id"
|
|
371
|
+
[value]="getItemValue(item)"
|
|
372
|
+
(input)="onValueChange(item, $event)"
|
|
373
|
+
placeholder="Empty"
|
|
374
|
+
/>
|
|
375
|
+
</div>
|
|
376
|
+
</div>
|
|
377
|
+
}
|
|
378
|
+
</div>
|
|
379
|
+
} @else {
|
|
380
|
+
<div
|
|
381
|
+
class="sea-data-viewer__empty sea-data-viewer__empty--group"
|
|
382
|
+
>
|
|
383
|
+
<p>No data extracted for this group yet</p>
|
|
384
|
+
</div>
|
|
385
|
+
}
|
|
386
|
+
</div>
|
|
387
|
+
</div>
|
|
388
|
+
}
|
|
389
|
+
</div>
|
|
390
|
+
} @else if (isProcessing()) {
|
|
391
|
+
<div class="sea-data-viewer__processing">
|
|
392
|
+
<div class="sea-processing-indicator">
|
|
393
|
+
<svg class="sea-spinner" viewBox="0 0 24 24">
|
|
394
|
+
<circle
|
|
395
|
+
cx="12"
|
|
396
|
+
cy="12"
|
|
397
|
+
r="10"
|
|
398
|
+
fill="none"
|
|
399
|
+
stroke="currentColor"
|
|
400
|
+
stroke-width="3"
|
|
401
|
+
opacity="0.25"
|
|
402
|
+
/>
|
|
403
|
+
<circle
|
|
404
|
+
cx="12"
|
|
405
|
+
cy="12"
|
|
406
|
+
r="10"
|
|
407
|
+
fill="none"
|
|
408
|
+
stroke="currentColor"
|
|
409
|
+
stroke-width="3"
|
|
410
|
+
stroke-dasharray="63"
|
|
411
|
+
stroke-dashoffset="50"
|
|
412
|
+
/>
|
|
413
|
+
</svg>
|
|
414
|
+
<div class="sea-processing-indicator__content">
|
|
415
|
+
<h3 class="sea-processing-indicator__title">
|
|
416
|
+
Processing Document
|
|
417
|
+
</h3>
|
|
418
|
+
<p class="sea-processing-indicator__message">
|
|
419
|
+
Your document is being analyzed and data is being
|
|
420
|
+
extracted. This may take a few moments depending on
|
|
421
|
+
document complexity.
|
|
422
|
+
</p>
|
|
423
|
+
<p class="sea-processing-indicator__status">
|
|
424
|
+
<span class="sea-processing-indicator__pulse"></span>
|
|
425
|
+
Checking for updates automatically...
|
|
426
|
+
</p>
|
|
427
|
+
</div>
|
|
428
|
+
</div>
|
|
429
|
+
</div>
|
|
430
|
+
} @else {
|
|
431
|
+
<div class="sea-data-viewer__empty">
|
|
432
|
+
<p>No data extracted yet</p>
|
|
433
|
+
</div>
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
</div>
|
|
438
|
+
|
|
439
|
+
@if (selectedDocument() || showDocumentList()) {
|
|
440
|
+
<div
|
|
441
|
+
class="sea-data-viewer__resize-handle"
|
|
442
|
+
(mousedown)="onResizeStart($event)"
|
|
443
|
+
></div>
|
|
444
|
+
<div
|
|
445
|
+
class="sea-data-viewer__sidebar"
|
|
446
|
+
[style.flex-basis.px]="sidebarWidth()"
|
|
447
|
+
>
|
|
448
|
+
@if (selectedDocument()) {
|
|
449
|
+
<sea-pdf-viewer
|
|
450
|
+
[document]="selectedDocument()!"
|
|
451
|
+
[selectedCitationId]="selectedCitationId()"
|
|
452
|
+
(closed)="closePdfViewer()"
|
|
453
|
+
(citationClicked)="onPdfCitationClick($event)"
|
|
454
|
+
></sea-pdf-viewer>
|
|
455
|
+
} @else if (showDocumentList()) {
|
|
456
|
+
<sea-document-list
|
|
457
|
+
[documents]="submissionData()?.documents || []"
|
|
458
|
+
(documentClicked)="onDocumentSelected($event)"
|
|
459
|
+
></sea-document-list>
|
|
460
|
+
}
|
|
461
|
+
</div>
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
<sea-feedback-modal
|
|
465
|
+
[fieldName]="feedbackFieldName()"
|
|
466
|
+
[fieldHint]="feedbackFieldHint()"
|
|
467
|
+
[extractedValue]="feedbackExtractedValue()"
|
|
468
|
+
[submissionItemId]="feedbackSubmissionItemId()"
|
|
469
|
+
(feedbackSubmitted)="onFeedbackSubmitted($event)"
|
|
470
|
+
></sea-feedback-modal>
|
|
471
|
+
</div>
|
|
472
|
+
`,
|
|
473
|
+
styles: [
|
|
474
|
+
`
|
|
475
|
+
:host {
|
|
476
|
+
--sea-color-surface: #ffffff;
|
|
477
|
+
--sea-color-surface-muted: #f8fafc;
|
|
478
|
+
--sea-color-border: #e2e8f0;
|
|
479
|
+
--sea-color-border-strong: #cbd5e1;
|
|
480
|
+
--sea-color-text: #0f172a;
|
|
481
|
+
--sea-color-text-muted: #64748b;
|
|
482
|
+
--sea-color-brand-50: #f8fafc;
|
|
483
|
+
--sea-color-brand-100: #f1f5f9;
|
|
484
|
+
--sea-color-brand-200: #e2e8f0;
|
|
485
|
+
--sea-color-brand-500: #64748b;
|
|
486
|
+
--sea-color-brand-600: #475569;
|
|
487
|
+
--sea-color-brand-700: #334155;
|
|
488
|
+
--sea-color-success-100: #dcfce7;
|
|
489
|
+
--sea-color-success-600: #059669;
|
|
490
|
+
--sea-color-warning-100: #fef3c7;
|
|
491
|
+
--sea-color-warning-600: #b45309;
|
|
492
|
+
--sea-color-error-100: #fee2e2;
|
|
493
|
+
--sea-color-error-600: #b91c1c;
|
|
494
|
+
font-family:
|
|
495
|
+
"Inter",
|
|
496
|
+
system-ui,
|
|
497
|
+
-apple-system,
|
|
498
|
+
BlinkMacSystemFont,
|
|
499
|
+
"Segoe UI",
|
|
500
|
+
sans-serif;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
.sea-data-viewer {
|
|
504
|
+
position: relative;
|
|
505
|
+
display: flex;
|
|
506
|
+
flex-direction: row;
|
|
507
|
+
gap: 0;
|
|
508
|
+
height: 100%;
|
|
509
|
+
width: 100%;
|
|
510
|
+
max-width: 100%;
|
|
511
|
+
background: var(--sea-color-surface);
|
|
512
|
+
border: none;
|
|
513
|
+
border-radius: 0;
|
|
514
|
+
overflow: hidden;
|
|
515
|
+
box-shadow: none;
|
|
516
|
+
transition: none;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
.sea-data-viewer__content {
|
|
520
|
+
flex: 1 1 0;
|
|
521
|
+
min-width: 0;
|
|
522
|
+
max-height: 100%;
|
|
523
|
+
padding: 0.5rem;
|
|
524
|
+
overflow-y: auto;
|
|
525
|
+
overflow-x: hidden;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
.sea-data-viewer__content--with-sidebar {
|
|
529
|
+
flex: 1 1 0;
|
|
530
|
+
min-width: 200px;
|
|
531
|
+
border-right: 1px solid var(--sea-color-border);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
.sea-data-viewer__resize-handle {
|
|
535
|
+
width: 1px;
|
|
536
|
+
min-height: 100%;
|
|
537
|
+
background: #cbd5e1;
|
|
538
|
+
cursor: col-resize;
|
|
539
|
+
position: relative;
|
|
540
|
+
flex-shrink: 0;
|
|
541
|
+
transition: background-color 0.2s ease;
|
|
542
|
+
z-index: 10;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
.sea-data-viewer__resize-handle:hover,
|
|
546
|
+
.sea-data-viewer__resize-handle:active {
|
|
547
|
+
background: #3b82f6;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
.sea-data-viewer__resize-handle::after {
|
|
551
|
+
content: "";
|
|
552
|
+
position: absolute;
|
|
553
|
+
top: 0;
|
|
554
|
+
left: -4px;
|
|
555
|
+
right: -4px;
|
|
556
|
+
bottom: 0;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
.sea-data-viewer__sidebar {
|
|
560
|
+
min-width: 200px;
|
|
561
|
+
max-width: calc(100% - 200px);
|
|
562
|
+
max-height: 100%;
|
|
563
|
+
background: var(--sea-color-surface);
|
|
564
|
+
overflow-y: auto;
|
|
565
|
+
overflow-x: hidden;
|
|
566
|
+
display: flex;
|
|
567
|
+
flex-direction: column;
|
|
568
|
+
flex: 0 1 auto;
|
|
569
|
+
border-left: 1px solid var(--sea-color-border);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
.sea-data-viewer__loading,
|
|
573
|
+
.sea-data-viewer__error {
|
|
574
|
+
display: flex;
|
|
575
|
+
flex-direction: column;
|
|
576
|
+
align-items: center;
|
|
577
|
+
justify-content: center;
|
|
578
|
+
padding: 3rem 1.5rem;
|
|
579
|
+
gap: 1.25rem;
|
|
580
|
+
color: var(--sea-color-text-muted);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
.sea-data-viewer__error svg {
|
|
584
|
+
color: var(--sea-color-error-600);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
.sea-spinner {
|
|
588
|
+
width: 3rem;
|
|
589
|
+
height: 3rem;
|
|
590
|
+
animation: rotate 1.5s linear infinite;
|
|
591
|
+
color: var(--sea-color-brand-600);
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
@keyframes rotate {
|
|
595
|
+
100% {
|
|
596
|
+
transform: rotate(360deg);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
.sea-error-icon {
|
|
601
|
+
width: 3rem;
|
|
602
|
+
height: 3rem;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
.sea-data-viewer__header {
|
|
606
|
+
display: flex;
|
|
607
|
+
align-items: center;
|
|
608
|
+
justify-content: space-between;
|
|
609
|
+
flex-wrap: wrap;
|
|
610
|
+
gap: 1rem;
|
|
611
|
+
margin-bottom: 1rem;
|
|
612
|
+
padding-bottom: 0.75rem;
|
|
613
|
+
border-bottom: 1px solid var(--sea-color-border);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
.sea-data-viewer__title {
|
|
617
|
+
margin: 0;
|
|
618
|
+
font-size: 1.5rem;
|
|
619
|
+
line-height: 1.4;
|
|
620
|
+
font-weight: 600;
|
|
621
|
+
letter-spacing: -0.01em;
|
|
622
|
+
color: var(--sea-color-text);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
.sea-data-viewer__meta {
|
|
626
|
+
display: flex;
|
|
627
|
+
align-items: center;
|
|
628
|
+
justify-content: flex-end;
|
|
629
|
+
gap: 1rem;
|
|
630
|
+
flex-wrap: wrap;
|
|
631
|
+
font-size: 0.875rem;
|
|
632
|
+
color: var(--sea-color-text-muted);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
.sea-data-viewer__status {
|
|
636
|
+
display: inline-flex;
|
|
637
|
+
align-items: center;
|
|
638
|
+
gap: 0.35rem;
|
|
639
|
+
padding: 0.35rem 0.85rem;
|
|
640
|
+
border-radius: 9999px;
|
|
641
|
+
font-size: 0.75rem;
|
|
642
|
+
font-weight: 600;
|
|
643
|
+
letter-spacing: 0.02em;
|
|
644
|
+
text-transform: capitalize;
|
|
645
|
+
background: var(--sea-color-brand-50);
|
|
646
|
+
color: var(--sea-color-brand-700);
|
|
647
|
+
border: 1px solid rgba(148, 163, 184, 0.15);
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
.sea-data-viewer__status--pending {
|
|
651
|
+
background: var(--sea-color-warning-100);
|
|
652
|
+
color: var(--sea-color-warning-600);
|
|
653
|
+
border-color: rgba(180, 83, 9, 0.18);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
.sea-data-viewer__status--processing {
|
|
657
|
+
background: var(--sea-color-brand-100);
|
|
658
|
+
color: var(--sea-color-brand-600);
|
|
659
|
+
border-color: rgba(148, 163, 184, 0.2);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
.sea-data-viewer__status--completed,
|
|
663
|
+
.sea-data-viewer__status--finalised {
|
|
664
|
+
background: var(--sea-color-success-100);
|
|
665
|
+
color: var(--sea-color-success-600);
|
|
666
|
+
border-color: rgba(5, 150, 105, 0.25);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
.sea-data-viewer__status--failed {
|
|
670
|
+
background: var(--sea-color-error-100);
|
|
671
|
+
color: var(--sea-color-error-600);
|
|
672
|
+
border-color: rgba(185, 28, 28, 0.2);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
.sea-data-viewer__status--draft {
|
|
676
|
+
background: var(--sea-color-brand-50);
|
|
677
|
+
color: var(--sea-color-brand-700);
|
|
678
|
+
border-color: rgba(148, 163, 184, 0.18);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
.sea-data-viewer__status-button {
|
|
682
|
+
display: inline-flex;
|
|
683
|
+
align-items: center;
|
|
684
|
+
justify-content: center;
|
|
685
|
+
gap: 0.5rem;
|
|
686
|
+
padding: 0.5rem 1rem;
|
|
687
|
+
border-radius: 0.375rem;
|
|
688
|
+
border: 1px solid transparent;
|
|
689
|
+
font-size: 0.875rem;
|
|
690
|
+
font-weight: 500;
|
|
691
|
+
letter-spacing: 0;
|
|
692
|
+
cursor: pointer;
|
|
693
|
+
transition: background-color 0.2s ease;
|
|
694
|
+
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
.sea-data-viewer__status-button:focus-visible {
|
|
698
|
+
outline: 2px solid rgba(148, 163, 184, 0.35);
|
|
699
|
+
outline-offset: 3px;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
.sea-data-viewer__status-button:disabled {
|
|
703
|
+
opacity: 0.65;
|
|
704
|
+
cursor: not-allowed;
|
|
705
|
+
box-shadow: none;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
.sea-data-viewer__status-button--finalise {
|
|
709
|
+
background: var(--sea-color-brand-600);
|
|
710
|
+
color: #ffffff;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
.sea-data-viewer__status-button--finalise:hover:not(:disabled) {
|
|
714
|
+
background: var(--sea-color-brand-700);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
.sea-data-viewer__status-button--draft {
|
|
718
|
+
background: var(--sea-color-surface);
|
|
719
|
+
color: var(--sea-color-text);
|
|
720
|
+
border-color: var(--sea-color-border);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
.sea-data-viewer__status-button--draft:hover:not(:disabled) {
|
|
724
|
+
background: var(--sea-color-surface-muted);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
.sea-spinner--small {
|
|
728
|
+
width: 18px;
|
|
729
|
+
height: 18px;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
.sea-data-viewer__groups {
|
|
733
|
+
display: flex;
|
|
734
|
+
flex-direction: column;
|
|
735
|
+
gap: 1rem;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
.sea-form-group {
|
|
739
|
+
display: flex;
|
|
740
|
+
flex-direction: column;
|
|
741
|
+
gap: 0;
|
|
742
|
+
background: var(--sea-color-surface);
|
|
743
|
+
border: 1px solid var(--sea-color-border);
|
|
744
|
+
border-radius: 0.5rem;
|
|
745
|
+
box-shadow:
|
|
746
|
+
0 1px 3px 0 rgba(0, 0, 0, 0.1),
|
|
747
|
+
0 1px 2px -1px rgba(0, 0, 0, 0.1);
|
|
748
|
+
overflow: hidden;
|
|
749
|
+
transition: none;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
.sea-form-group__header {
|
|
753
|
+
display: flex;
|
|
754
|
+
flex-wrap: wrap;
|
|
755
|
+
align-items: flex-start;
|
|
756
|
+
justify-content: space-between;
|
|
757
|
+
gap: 1rem;
|
|
758
|
+
padding: 1rem 1.5rem;
|
|
759
|
+
background: var(--sea-color-surface);
|
|
760
|
+
border-bottom: 1px solid var(--sea-color-border);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
.sea-form-group__heading {
|
|
764
|
+
display: flex;
|
|
765
|
+
flex-direction: column;
|
|
766
|
+
gap: 0.35rem;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
.sea-form-group__title {
|
|
770
|
+
margin: 0;
|
|
771
|
+
font-size: 1.25rem;
|
|
772
|
+
font-weight: 600;
|
|
773
|
+
color: var(--sea-color-text);
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
.sea-form-group__hint {
|
|
777
|
+
margin: 0;
|
|
778
|
+
font-size: 0.875rem;
|
|
779
|
+
color: var(--sea-color-text-muted);
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
.sea-form-group__meta {
|
|
783
|
+
display: flex;
|
|
784
|
+
align-items: center;
|
|
785
|
+
justify-content: flex-end;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
.sea-form-group__meta span {
|
|
789
|
+
display: inline-flex;
|
|
790
|
+
align-items: center;
|
|
791
|
+
justify-content: center;
|
|
792
|
+
padding: 0.35rem 0.85rem;
|
|
793
|
+
border-radius: 9999px;
|
|
794
|
+
border: 1px solid var(--sea-color-border);
|
|
795
|
+
background: var(--sea-color-surface);
|
|
796
|
+
color: var(--sea-color-text-muted);
|
|
797
|
+
font-size: 0.75rem;
|
|
798
|
+
font-weight: 600;
|
|
799
|
+
letter-spacing: 0.04em;
|
|
800
|
+
text-transform: uppercase;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
.sea-form-group__body {
|
|
804
|
+
display: flex;
|
|
805
|
+
flex-direction: column;
|
|
806
|
+
gap: 0;
|
|
807
|
+
padding: 0;
|
|
808
|
+
background: var(--sea-color-surface);
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
.sea-table-wrapper {
|
|
812
|
+
width: 100%;
|
|
813
|
+
overflow-x: auto;
|
|
814
|
+
background: var(--sea-color-surface);
|
|
815
|
+
border: none;
|
|
816
|
+
border-radius: 0;
|
|
817
|
+
box-shadow: none;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
.sea-data-viewer__content--with-sidebar .sea-table-wrapper {
|
|
821
|
+
max-width: 100%;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
.sea-table {
|
|
825
|
+
width: 100%;
|
|
826
|
+
border-collapse: separate;
|
|
827
|
+
border-spacing: 0;
|
|
828
|
+
font-size: 0.875rem;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
.sea-table thead {
|
|
832
|
+
background: rgba(248, 250, 252, 0.6);
|
|
833
|
+
border-bottom: 1px solid var(--sea-color-border);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
.sea-table th {
|
|
837
|
+
padding: 0.75rem 1rem;
|
|
838
|
+
text-align: left;
|
|
839
|
+
font-weight: 500;
|
|
840
|
+
color: var(--sea-color-text-muted);
|
|
841
|
+
font-size: 0.875rem;
|
|
842
|
+
letter-spacing: 0;
|
|
843
|
+
text-transform: none;
|
|
844
|
+
white-space: nowrap;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
.sea-table th:first-child {
|
|
848
|
+
padding-left: 1.5rem;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
.sea-table th:last-child {
|
|
852
|
+
padding-right: 1.5rem;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
.sea-table__header--sortable {
|
|
856
|
+
border: none;
|
|
857
|
+
background: transparent;
|
|
858
|
+
font: inherit;
|
|
859
|
+
color: inherit;
|
|
860
|
+
display: inline-flex;
|
|
861
|
+
align-items: center;
|
|
862
|
+
gap: 0.5rem;
|
|
863
|
+
cursor: pointer;
|
|
864
|
+
padding: 0;
|
|
865
|
+
transition: color 0.2s ease;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
.sea-table__header--sortable:hover,
|
|
869
|
+
.sea-table th[aria-sort="ascending"] .sea-table__header--sortable,
|
|
870
|
+
.sea-table th[aria-sort="descending"] .sea-table__header--sortable {
|
|
871
|
+
color: var(--sea-color-brand-600);
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
.sea-table__header--sortable:focus-visible {
|
|
875
|
+
outline: 2px solid rgba(148, 163, 184, 0.35);
|
|
876
|
+
outline-offset: 4px;
|
|
877
|
+
border-radius: 9999px;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
.sea-table__header-content {
|
|
881
|
+
display: inline-flex;
|
|
882
|
+
align-items: center;
|
|
883
|
+
gap: 0.35rem;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
.sea-table__sort-icon {
|
|
887
|
+
font-size: 0.75rem;
|
|
888
|
+
color: var(--sea-color-brand-500);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
.sea-table tbody tr {
|
|
892
|
+
transition: background-color 0.2s ease;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
.sea-table tbody tr:hover {
|
|
896
|
+
background: var(--sea-color-brand-50);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
.sea-table td {
|
|
900
|
+
padding: 0.75rem 1rem;
|
|
901
|
+
border-top: 1px solid var(--sea-color-border);
|
|
902
|
+
color: var(--sea-color-text);
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
.sea-table td:first-child {
|
|
906
|
+
padding-left: 1.5rem;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
.sea-table td:last-child {
|
|
910
|
+
padding-right: 1.5rem;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
.sea-table__cell--selected {
|
|
914
|
+
background: linear-gradient(to right, #fdf2f8 0%, #fce7f3 100%);
|
|
915
|
+
box-shadow: inset 0 0 0 1.5px rgba(236, 72, 153, 0.2);
|
|
916
|
+
border-radius: 0.375rem;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
.sea-table__cell--unsaved {
|
|
920
|
+
background: var(--sea-color-warning-100);
|
|
921
|
+
box-shadow: inset 0 0 0 1px rgba(180, 83, 9, 0.35);
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
.sea-table-cell {
|
|
925
|
+
display: flex;
|
|
926
|
+
align-items: center;
|
|
927
|
+
gap: 0.25rem;
|
|
928
|
+
min-height: 32px;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
.sea-table-cell__value {
|
|
932
|
+
padding-left: 0.25rem;
|
|
933
|
+
color: var(--sea-color-text);
|
|
934
|
+
line-height: 1.5;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
.sea-data-viewer__fields {
|
|
938
|
+
display: flex;
|
|
939
|
+
flex-direction: column;
|
|
940
|
+
gap: 0;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
.sea-field {
|
|
944
|
+
display: flex;
|
|
945
|
+
align-items: flex-start;
|
|
946
|
+
gap: 1rem;
|
|
947
|
+
padding: 0.75rem 1rem;
|
|
948
|
+
border-top: 1px solid var(--sea-color-border);
|
|
949
|
+
background: var(--sea-color-surface);
|
|
950
|
+
transition: background-color 0.15s ease;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
.sea-field:first-of-type {
|
|
954
|
+
border-top: none;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
.sea-field:hover,
|
|
958
|
+
.sea-field:focus-within {
|
|
959
|
+
background: #f8fafc;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
.sea-field--selected {
|
|
963
|
+
background: linear-gradient(to right, #fdf2f8 0%, #fce7f3 100%);
|
|
964
|
+
box-shadow: inset 0 0 0 1.5px rgba(236, 72, 153, 0.2);
|
|
965
|
+
border-radius: 0.5rem;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
.sea-field--unsaved {
|
|
969
|
+
background: var(--sea-color-warning-100);
|
|
970
|
+
box-shadow: inset 0 0 0 1px rgba(180, 83, 9, 0.3);
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
.sea-field__label {
|
|
974
|
+
flex-basis: 28%;
|
|
975
|
+
max-width: 28%;
|
|
976
|
+
font-size: 0.9rem;
|
|
977
|
+
font-weight: 600;
|
|
978
|
+
color: var(--sea-color-text);
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
.sea-field__input-wrapper {
|
|
982
|
+
display: flex;
|
|
983
|
+
align-items: center;
|
|
984
|
+
gap: 0.5rem;
|
|
985
|
+
flex: 1;
|
|
986
|
+
min-height: 42px;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
.sea-field__input {
|
|
990
|
+
flex: 1;
|
|
991
|
+
padding: 0.5rem 0;
|
|
992
|
+
background: transparent;
|
|
993
|
+
border: none;
|
|
994
|
+
font-size: 0.95rem;
|
|
995
|
+
color: var(--sea-color-text);
|
|
996
|
+
transition:
|
|
997
|
+
border-color 0.2s ease,
|
|
998
|
+
box-shadow 0.2s ease;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
.sea-field__input::placeholder {
|
|
1002
|
+
color: rgba(100, 116, 139, 0.8);
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
.sea-field__input:focus {
|
|
1006
|
+
outline: none;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
.sea-field--unsaved .sea-field__input {
|
|
1010
|
+
border-color: var(--sea-color-warning-600);
|
|
1011
|
+
color: var(--sea-color-warning-600);
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
.sea-table-cell__input {
|
|
1015
|
+
width: 100%;
|
|
1016
|
+
padding: 0.4rem 0.25rem;
|
|
1017
|
+
background: transparent;
|
|
1018
|
+
border: none;
|
|
1019
|
+
border-bottom: 1px solid transparent;
|
|
1020
|
+
font-size: 0.875rem;
|
|
1021
|
+
color: var(--sea-color-text);
|
|
1022
|
+
transition:
|
|
1023
|
+
border-color 0.2s ease,
|
|
1024
|
+
box-shadow 0.2s ease;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
.sea-table-cell__input:hover {
|
|
1028
|
+
border-bottom-color: var(--sea-color-border);
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
.sea-table-cell__input:focus {
|
|
1032
|
+
outline: none;
|
|
1033
|
+
border-bottom-color: var(--sea-color-brand-600);
|
|
1034
|
+
box-shadow: 0 1px 0 0 var(--sea-color-brand-600);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
.sea-button-group {
|
|
1038
|
+
display: flex;
|
|
1039
|
+
flex-direction: row;
|
|
1040
|
+
gap: 0.25rem;
|
|
1041
|
+
align-items: center;
|
|
1042
|
+
flex-shrink: 0;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
.sea-icon-button {
|
|
1046
|
+
position: relative;
|
|
1047
|
+
display: inline-flex;
|
|
1048
|
+
align-items: center;
|
|
1049
|
+
justify-content: center;
|
|
1050
|
+
width: 1.75rem;
|
|
1051
|
+
height: 1.75rem;
|
|
1052
|
+
min-width: 1.75rem;
|
|
1053
|
+
border-radius: 0.5rem;
|
|
1054
|
+
border: none;
|
|
1055
|
+
background: transparent;
|
|
1056
|
+
color: #64748b;
|
|
1057
|
+
cursor: pointer;
|
|
1058
|
+
transition:
|
|
1059
|
+
background-color 0.2s ease,
|
|
1060
|
+
color 0.2s ease,
|
|
1061
|
+
transform 0.15s ease;
|
|
1062
|
+
opacity: 1;
|
|
1063
|
+
transform: none;
|
|
1064
|
+
pointer-events: auto;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
.sea-icon-button svg {
|
|
1068
|
+
width: 13px;
|
|
1069
|
+
height: 13px;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
.sea-icon-button--table {
|
|
1073
|
+
width: 20px;
|
|
1074
|
+
height: 20px;
|
|
1075
|
+
min-width: 20px;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
.sea-icon-button:hover,
|
|
1079
|
+
.sea-icon-button:focus-visible {
|
|
1080
|
+
background: #f8fafc;
|
|
1081
|
+
color: #0f172a;
|
|
1082
|
+
transform: scale(1.05);
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
.sea-icon-button:focus-visible {
|
|
1086
|
+
outline: 2px solid rgba(148, 163, 184, 0.35);
|
|
1087
|
+
outline-offset: 2px;
|
|
1088
|
+
/* Reveal when keyboard focusing the button */
|
|
1089
|
+
opacity: 1;
|
|
1090
|
+
transform: translateY(0);
|
|
1091
|
+
pointer-events: auto;
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
.sea-feedback-btn {
|
|
1095
|
+
color: #94a3b8;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
.sea-feedback-btn svg {
|
|
1099
|
+
color: currentColor;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
.sea-feedback-btn:hover,
|
|
1103
|
+
.sea-feedback-btn:focus-visible {
|
|
1104
|
+
background: rgba(148, 163, 184, 0.15);
|
|
1105
|
+
box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.3);
|
|
1106
|
+
color: #64748b;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
.sea-tooltip {
|
|
1110
|
+
position: absolute;
|
|
1111
|
+
bottom: calc(100% + 0.5rem);
|
|
1112
|
+
left: 50%;
|
|
1113
|
+
transform: translate(-50%, 0.25rem);
|
|
1114
|
+
padding: 0.35rem 0.5rem;
|
|
1115
|
+
border-radius: 8px;
|
|
1116
|
+
background: rgba(15, 23, 42, 0.95);
|
|
1117
|
+
color: #ffffff;
|
|
1118
|
+
font-size: 0.7rem;
|
|
1119
|
+
font-weight: 600;
|
|
1120
|
+
letter-spacing: 0.03em;
|
|
1121
|
+
white-space: nowrap;
|
|
1122
|
+
box-shadow: 0 20px 35px rgba(15, 23, 42, 0.28);
|
|
1123
|
+
opacity: 0;
|
|
1124
|
+
visibility: hidden;
|
|
1125
|
+
transition:
|
|
1126
|
+
opacity 0.15s ease,
|
|
1127
|
+
transform 0.15s ease;
|
|
1128
|
+
pointer-events: none;
|
|
1129
|
+
z-index: 20;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
.sea-tooltip::after {
|
|
1133
|
+
content: "";
|
|
1134
|
+
position: absolute;
|
|
1135
|
+
top: 100%;
|
|
1136
|
+
left: 50%;
|
|
1137
|
+
transform: translateX(-50%);
|
|
1138
|
+
border-width: 6px;
|
|
1139
|
+
border-style: solid;
|
|
1140
|
+
border-color: rgba(15, 23, 42, 0.95) transparent transparent transparent;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
.sea-icon-button:hover .sea-tooltip,
|
|
1144
|
+
.sea-icon-button:focus-visible .sea-tooltip {
|
|
1145
|
+
opacity: 1;
|
|
1146
|
+
visibility: visible;
|
|
1147
|
+
transform: translate(-50%, 0);
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
.sea-data-viewer__empty {
|
|
1151
|
+
padding: 3rem 1.5rem;
|
|
1152
|
+
border-radius: 16px;
|
|
1153
|
+
border: 1px dashed var(--sea-color-border);
|
|
1154
|
+
background: var(--sea-color-surface);
|
|
1155
|
+
text-align: center;
|
|
1156
|
+
color: var(--sea-color-text-muted);
|
|
1157
|
+
font-size: 0.95rem;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
.sea-data-viewer__empty--group {
|
|
1161
|
+
background: rgba(248, 250, 252, 0.35);
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
.sea-data-viewer__processing {
|
|
1165
|
+
display: flex;
|
|
1166
|
+
align-items: center;
|
|
1167
|
+
justify-content: center;
|
|
1168
|
+
padding: 3.5rem 1.5rem;
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
.sea-processing-indicator {
|
|
1172
|
+
display: flex;
|
|
1173
|
+
align-items: center;
|
|
1174
|
+
gap: 1.75rem;
|
|
1175
|
+
padding: 1.75rem 2rem;
|
|
1176
|
+
border-radius: 18px;
|
|
1177
|
+
background: linear-gradient(
|
|
1178
|
+
135deg,
|
|
1179
|
+
rgba(248, 250, 252, 0.45),
|
|
1180
|
+
rgba(255, 255, 255, 0.9)
|
|
1181
|
+
);
|
|
1182
|
+
border: 1px solid rgba(148, 163, 184, 0.18);
|
|
1183
|
+
box-shadow: 0 24px 55px rgba(15, 23, 42, 0.12);
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
.sea-processing-indicator__content {
|
|
1187
|
+
display: flex;
|
|
1188
|
+
flex-direction: column;
|
|
1189
|
+
gap: 0.75rem;
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
.sea-processing-indicator__title {
|
|
1193
|
+
margin: 0;
|
|
1194
|
+
font-size: 1.15rem;
|
|
1195
|
+
font-weight: 600;
|
|
1196
|
+
color: var(--sea-color-text);
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
.sea-processing-indicator__message {
|
|
1200
|
+
margin: 0;
|
|
1201
|
+
font-size: 0.9rem;
|
|
1202
|
+
color: var(--sea-color-text-muted);
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
.sea-processing-indicator__status {
|
|
1206
|
+
display: inline-flex;
|
|
1207
|
+
align-items: center;
|
|
1208
|
+
gap: 0.5rem;
|
|
1209
|
+
font-size: 0.85rem;
|
|
1210
|
+
color: var(--sea-color-brand-700);
|
|
1211
|
+
font-weight: 600;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
.sea-processing-indicator__pulse {
|
|
1215
|
+
display: inline-flex;
|
|
1216
|
+
width: 10px;
|
|
1217
|
+
height: 10px;
|
|
1218
|
+
border-radius: 9999px;
|
|
1219
|
+
background: var(--sea-color-brand-600);
|
|
1220
|
+
box-shadow: 0 0 0 0 rgba(71, 85, 105, 0.6);
|
|
1221
|
+
animation: seaPulse 1.4s ease-in-out infinite;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
@keyframes seaPulse {
|
|
1225
|
+
0% {
|
|
1226
|
+
box-shadow: 0 0 0 0 rgba(71, 85, 105, 0.6);
|
|
1227
|
+
}
|
|
1228
|
+
70% {
|
|
1229
|
+
box-shadow: 0 0 0 10px rgba(71, 85, 105, 0);
|
|
1230
|
+
}
|
|
1231
|
+
100% {
|
|
1232
|
+
box-shadow: 0 0 0 0 rgba(71, 85, 105, 0);
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
@media (max-width: 1200px) {
|
|
1237
|
+
.sea-data-viewer {
|
|
1238
|
+
flex-direction: column;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
.sea-data-viewer__content--with-sidebar {
|
|
1242
|
+
flex: 1 1 auto;
|
|
1243
|
+
border-right: none;
|
|
1244
|
+
border-bottom: 1px solid var(--sea-color-border);
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
.sea-data-viewer__sidebar {
|
|
1248
|
+
flex: 0 0 50vh;
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
@media (max-width: 960px) {
|
|
1253
|
+
.sea-form-group__header {
|
|
1254
|
+
flex-direction: column;
|
|
1255
|
+
align-items: flex-start;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
.sea-form-group__meta {
|
|
1259
|
+
width: 100%;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
.sea-form-group__meta span {
|
|
1263
|
+
align-self: flex-start;
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
.sea-field {
|
|
1267
|
+
flex-direction: column;
|
|
1268
|
+
gap: 0.75rem;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
.sea-field__label {
|
|
1272
|
+
flex-basis: auto;
|
|
1273
|
+
max-width: 100%;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
.sea-field__input-wrapper {
|
|
1277
|
+
width: 100%;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
@media (max-width: 720px) {
|
|
1282
|
+
.sea-data-viewer {
|
|
1283
|
+
padding: 1.5rem;
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
.sea-data-viewer__header {
|
|
1287
|
+
align-items: flex-start;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
.sea-data-viewer__meta {
|
|
1291
|
+
justify-content: flex-start;
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1296
|
+
.sea-data-viewer,
|
|
1297
|
+
.sea-data-viewer *,
|
|
1298
|
+
.sea-form-group,
|
|
1299
|
+
.sea-icon-button,
|
|
1300
|
+
.sea-tooltip {
|
|
1301
|
+
transition-duration: 0.01ms !important;
|
|
1302
|
+
animation-duration: 0.01ms !important;
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
`,
|
|
1306
|
+
],
|
|
1307
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1308
|
+
})
|
|
1309
|
+
export class SeaDataViewerComponent implements OnInit, OnDestroy, OnChanges {
|
|
1310
|
+
@Input() submissionId!: string;
|
|
1311
|
+
@Input() editable = false;
|
|
1312
|
+
@Input() hasRecentUpload = false;
|
|
1313
|
+
|
|
1314
|
+
@Output() fieldChanged = new EventEmitter<{ field: Field; value: unknown }>();
|
|
1315
|
+
@Output() citationClicked = new EventEmitter<Field>();
|
|
1316
|
+
@Output() processingComplete = new EventEmitter<void>();
|
|
1317
|
+
/**
|
|
1318
|
+
* Non-blocking error surface for host apps. Emits when an action fails (e.g. save, status update, feedback).
|
|
1319
|
+
*/
|
|
1320
|
+
@Output() actionError = new EventEmitter<{
|
|
1321
|
+
action:
|
|
1322
|
+
| "load"
|
|
1323
|
+
| "poll"
|
|
1324
|
+
| "save-value"
|
|
1325
|
+
| "update-status"
|
|
1326
|
+
| "submit-feedback";
|
|
1327
|
+
error: unknown;
|
|
1328
|
+
}>();
|
|
1329
|
+
|
|
1330
|
+
@ViewChild(SeaFeedbackModalComponent)
|
|
1331
|
+
feedbackModal?: SeaFeedbackModalComponent;
|
|
1332
|
+
|
|
1333
|
+
private readonly api = inject(SeaApiClientService);
|
|
1334
|
+
private readonly config = inject(SeaWidgetConfigService);
|
|
1335
|
+
private readonly elementRef = inject(ElementRef);
|
|
1336
|
+
private pollSubscription?: Subscription;
|
|
1337
|
+
private valueChangesSubscription?: Subscription;
|
|
1338
|
+
private submissionDataSubscription?: Subscription;
|
|
1339
|
+
|
|
1340
|
+
protected readonly submission = signal<Submission | null>(null);
|
|
1341
|
+
protected readonly submissionData = signal<SubmissionData | null>(null);
|
|
1342
|
+
protected readonly loading = signal(true);
|
|
1343
|
+
protected readonly error = signal<Error | null>(null);
|
|
1344
|
+
protected readonly isProcessing = signal(false);
|
|
1345
|
+
protected readonly selectedDocument = signal<Document | null>(null);
|
|
1346
|
+
protected readonly selectedCitationId = signal<string | undefined>(undefined);
|
|
1347
|
+
protected readonly selectedItemId = signal<string | undefined>(undefined);
|
|
1348
|
+
protected readonly updatingStatus = signal(false);
|
|
1349
|
+
protected readonly showDocumentList = signal(false);
|
|
1350
|
+
|
|
1351
|
+
// Feedback modal state
|
|
1352
|
+
protected readonly feedbackFieldName = signal<string | undefined>(undefined);
|
|
1353
|
+
protected readonly feedbackFieldHint = signal<string | undefined>(undefined);
|
|
1354
|
+
protected readonly feedbackExtractedValue = signal<any>(null);
|
|
1355
|
+
protected readonly feedbackSubmissionItemId = signal<string | undefined>(
|
|
1356
|
+
undefined,
|
|
1357
|
+
);
|
|
1358
|
+
|
|
1359
|
+
// Inline editing state
|
|
1360
|
+
private valueChanges$ = new Subject<{ itemId: string; value: any }>();
|
|
1361
|
+
protected itemValues = new Map<string, any>();
|
|
1362
|
+
protected unsavedItems = new Set<string>();
|
|
1363
|
+
|
|
1364
|
+
// Table sorting state
|
|
1365
|
+
protected sortState = signal<{
|
|
1366
|
+
columnId: string;
|
|
1367
|
+
direction: "asc" | "desc";
|
|
1368
|
+
} | null>(null);
|
|
1369
|
+
|
|
1370
|
+
// Sidebar resize state
|
|
1371
|
+
protected readonly sidebarWidth = signal<number>(500);
|
|
1372
|
+
private isResizing = false;
|
|
1373
|
+
private resizeStartX = 0;
|
|
1374
|
+
private resizeStartWidth = 0;
|
|
1375
|
+
private resizeContainerWidth = 0;
|
|
1376
|
+
|
|
1377
|
+
// Lucide icons
|
|
1378
|
+
protected readonly TargetIcon = LocateFixed;
|
|
1379
|
+
protected readonly PencilIcon = Pencil;
|
|
1380
|
+
|
|
1381
|
+
ngOnInit(): void {
|
|
1382
|
+
if (!this.submissionId) {
|
|
1383
|
+
this.error.set(new Error("Submission ID is required"));
|
|
1384
|
+
this.loading.set(false);
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
// Set up debounced value changes
|
|
1389
|
+
this.valueChangesSubscription = this.valueChanges$
|
|
1390
|
+
.pipe(
|
|
1391
|
+
debounceTime(2000),
|
|
1392
|
+
distinctUntilChanged(
|
|
1393
|
+
(prev, curr) =>
|
|
1394
|
+
prev.itemId === curr.itemId && prev.value === curr.value,
|
|
1395
|
+
),
|
|
1396
|
+
)
|
|
1397
|
+
.subscribe(({ itemId, value }) => {
|
|
1398
|
+
this.saveItemValue(itemId, value);
|
|
1399
|
+
});
|
|
1400
|
+
|
|
1401
|
+
// Set up resize event listeners
|
|
1402
|
+
this.setupResizeListeners();
|
|
1403
|
+
|
|
1404
|
+
this.loadSubmission();
|
|
1405
|
+
this.startPollingIfProcessing();
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
/**
|
|
1409
|
+
* Set up global mouse event listeners for resizing
|
|
1410
|
+
*/
|
|
1411
|
+
private setupResizeListeners(): void {
|
|
1412
|
+
const onMouseMove = (e: MouseEvent) => {
|
|
1413
|
+
if (this.isResizing) {
|
|
1414
|
+
this.onResizeMove(e);
|
|
1415
|
+
}
|
|
1416
|
+
};
|
|
1417
|
+
|
|
1418
|
+
const onMouseUp = () => {
|
|
1419
|
+
if (this.isResizing) {
|
|
1420
|
+
this.onResizeEnd();
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
1423
|
+
|
|
1424
|
+
document.addEventListener("mousemove", onMouseMove);
|
|
1425
|
+
document.addEventListener("mouseup", onMouseUp);
|
|
1426
|
+
|
|
1427
|
+
// Store for cleanup
|
|
1428
|
+
this.resizeCleanup = () => {
|
|
1429
|
+
document.removeEventListener("mousemove", onMouseMove);
|
|
1430
|
+
document.removeEventListener("mouseup", onMouseUp);
|
|
1431
|
+
};
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
private resizeCleanup?: () => void;
|
|
1435
|
+
|
|
1436
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
1437
|
+
if (!("submissionId" in changes)) {
|
|
1438
|
+
return;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
const change = changes["submissionId"];
|
|
1442
|
+
if (change.firstChange) {
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
if (change.previousValue === change.currentValue) {
|
|
1447
|
+
return;
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
this.stopPolling();
|
|
1451
|
+
this.submissionDataSubscription?.unsubscribe();
|
|
1452
|
+
this.submissionDataSubscription = undefined;
|
|
1453
|
+
|
|
1454
|
+
this.resetSubmissionState();
|
|
1455
|
+
|
|
1456
|
+
const nextSubmissionId = change.currentValue as string | undefined;
|
|
1457
|
+
if (!nextSubmissionId) {
|
|
1458
|
+
// Keep behavior neutral when the parent clears the submission ID.
|
|
1459
|
+
// Do not surface an error; just stop loading and remain reset.
|
|
1460
|
+
this.loading.set(false);
|
|
1461
|
+
return;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
this.loadSubmission();
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
ngOnDestroy(): void {
|
|
1468
|
+
this.stopPolling();
|
|
1469
|
+
this.valueChangesSubscription?.unsubscribe();
|
|
1470
|
+
this.submissionDataSubscription?.unsubscribe();
|
|
1471
|
+
this.resizeCleanup?.();
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
/**
|
|
1475
|
+
* Start resizing the sidebar
|
|
1476
|
+
*/
|
|
1477
|
+
protected onResizeStart(event: MouseEvent): void {
|
|
1478
|
+
event.preventDefault();
|
|
1479
|
+
this.isResizing = true;
|
|
1480
|
+
this.resizeStartX = event.clientX;
|
|
1481
|
+
this.resizeStartWidth = this.sidebarWidth();
|
|
1482
|
+
|
|
1483
|
+
const container =
|
|
1484
|
+
this.elementRef.nativeElement.querySelector(".sea-data-viewer");
|
|
1485
|
+
this.resizeContainerWidth = container
|
|
1486
|
+
? container.clientWidth
|
|
1487
|
+
: window.innerWidth;
|
|
1488
|
+
|
|
1489
|
+
document.body.style.cursor = "col-resize";
|
|
1490
|
+
document.body.style.userSelect = "none";
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
/**
|
|
1494
|
+
* Handle resize movement
|
|
1495
|
+
*/
|
|
1496
|
+
private onResizeMove(event: MouseEvent): void {
|
|
1497
|
+
if (!this.isResizing) return;
|
|
1498
|
+
|
|
1499
|
+
// Dragging left increases sidebar, dragging right decreases it
|
|
1500
|
+
const deltaX = this.resizeStartX - event.clientX;
|
|
1501
|
+
const newWidth = this.resizeStartWidth + deltaX;
|
|
1502
|
+
|
|
1503
|
+
// Constrain width between 200px and container width minus minimum content width
|
|
1504
|
+
// This ensures the content area always has at least 200px
|
|
1505
|
+
const minWidth = 200;
|
|
1506
|
+
const minContentWidth = 200;
|
|
1507
|
+
const maxWidth = Math.min(
|
|
1508
|
+
this.resizeContainerWidth * 0.8,
|
|
1509
|
+
this.resizeContainerWidth - minContentWidth,
|
|
1510
|
+
);
|
|
1511
|
+
const constrainedWidth = Math.max(minWidth, Math.min(newWidth, maxWidth));
|
|
1512
|
+
|
|
1513
|
+
this.sidebarWidth.set(constrainedWidth);
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
/**
|
|
1517
|
+
* End resizing
|
|
1518
|
+
*/
|
|
1519
|
+
private onResizeEnd(): void {
|
|
1520
|
+
this.isResizing = false;
|
|
1521
|
+
document.body.style.cursor = "";
|
|
1522
|
+
document.body.style.userSelect = "";
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
/**
|
|
1526
|
+
* Reload submission data (can be called externally after processing completes)
|
|
1527
|
+
*/
|
|
1528
|
+
public reloadData(): void {
|
|
1529
|
+
this.loadSubmission();
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
/**
|
|
1533
|
+
* Load submission data from API
|
|
1534
|
+
*/
|
|
1535
|
+
private loadSubmission(): void {
|
|
1536
|
+
if (!this.submissionId) {
|
|
1537
|
+
this.loading.set(false);
|
|
1538
|
+
return;
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
this.loading.set(true);
|
|
1542
|
+
this.error.set(null);
|
|
1543
|
+
|
|
1544
|
+
this.submissionDataSubscription?.unsubscribe();
|
|
1545
|
+
|
|
1546
|
+
const submissionId = this.submissionId;
|
|
1547
|
+
|
|
1548
|
+
// Fetch submission data from API
|
|
1549
|
+
this.submissionDataSubscription = this.api
|
|
1550
|
+
.getSubmissionData(submissionId)
|
|
1551
|
+
.subscribe({
|
|
1552
|
+
next: (data) => {
|
|
1553
|
+
if (this.config.debug())
|
|
1554
|
+
console.warn("[SeaDataViewer] Submission data loaded:", {
|
|
1555
|
+
submissionId: data.submissionId,
|
|
1556
|
+
status: data.status,
|
|
1557
|
+
formGroupsCount: data.formGroups?.length ?? 0,
|
|
1558
|
+
groupsCount: data.groups?.length ?? 0,
|
|
1559
|
+
});
|
|
1560
|
+
|
|
1561
|
+
this.submissionData.set(data);
|
|
1562
|
+
this.loading.set(false);
|
|
1563
|
+
|
|
1564
|
+
// Show document list if there are documents and no PDF is selected
|
|
1565
|
+
if (
|
|
1566
|
+
data.documents &&
|
|
1567
|
+
data.documents.length > 0 &&
|
|
1568
|
+
!this.selectedDocument()
|
|
1569
|
+
) {
|
|
1570
|
+
this.showDocumentList.set(true);
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
// Check if submission is processing
|
|
1574
|
+
const hasGroups = data.groups && data.groups.length > 0;
|
|
1575
|
+
const hasData =
|
|
1576
|
+
hasGroups && data.groups.some((g) => g.items?.length > 0);
|
|
1577
|
+
|
|
1578
|
+
const isCurrentlyProcessing =
|
|
1579
|
+
data.status === "processing" ||
|
|
1580
|
+
data.status === "pending" ||
|
|
1581
|
+
(this.hasRecentUpload && !hasData);
|
|
1582
|
+
|
|
1583
|
+
if (this.config.debug())
|
|
1584
|
+
console.warn("[SeaDataViewer] Processing check:", {
|
|
1585
|
+
status: data.status,
|
|
1586
|
+
hasRecentUpload: this.hasRecentUpload,
|
|
1587
|
+
hasData,
|
|
1588
|
+
isProcessing: isCurrentlyProcessing,
|
|
1589
|
+
});
|
|
1590
|
+
|
|
1591
|
+
this.isProcessing.set(isCurrentlyProcessing);
|
|
1592
|
+
|
|
1593
|
+
// If data has appeared and we were tracking a recent upload, notify parent
|
|
1594
|
+
if (hasData && this.hasRecentUpload) {
|
|
1595
|
+
if (this.config.debug())
|
|
1596
|
+
console.warn(
|
|
1597
|
+
"[SeaDataViewer] Data detected, processing complete!",
|
|
1598
|
+
);
|
|
1599
|
+
this.processingComplete.emit();
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
// Polling is now handled by the upload component
|
|
1603
|
+
// The viewer will reload data when upload emits processingComplete
|
|
1604
|
+
// No need to poll here
|
|
1605
|
+
},
|
|
1606
|
+
error: (err) => {
|
|
1607
|
+
console.error("[SeaDataViewer] Failed to load submission data:", err);
|
|
1608
|
+
this.error.set(err);
|
|
1609
|
+
this.loading.set(false);
|
|
1610
|
+
this.actionError.emit({ action: "load", error: err });
|
|
1611
|
+
},
|
|
1612
|
+
});
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
private resetSubmissionState(): void {
|
|
1616
|
+
this.submission.set(null);
|
|
1617
|
+
this.submissionData.set(null);
|
|
1618
|
+
this.selectedDocument.set(null);
|
|
1619
|
+
this.selectedCitationId.set(undefined);
|
|
1620
|
+
this.selectedItemId.set(undefined);
|
|
1621
|
+
this.showDocumentList.set(false);
|
|
1622
|
+
this.itemValues.clear();
|
|
1623
|
+
this.unsavedItems.clear();
|
|
1624
|
+
this.feedbackFieldName.set(undefined);
|
|
1625
|
+
this.feedbackFieldHint.set(undefined);
|
|
1626
|
+
this.feedbackExtractedValue.set(null);
|
|
1627
|
+
this.feedbackSubmissionItemId.set(undefined);
|
|
1628
|
+
this.isProcessing.set(false);
|
|
1629
|
+
this.updatingStatus.set(false);
|
|
1630
|
+
this.error.set(null);
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
/**
|
|
1634
|
+
* Start polling if submission is processing
|
|
1635
|
+
*/
|
|
1636
|
+
private startPollingIfProcessing(): void {
|
|
1637
|
+
const submission = this.submission();
|
|
1638
|
+
if (submission && this.isProcessing()) {
|
|
1639
|
+
this.startPolling();
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
/**
|
|
1644
|
+
* Start polling for submission updates
|
|
1645
|
+
*/
|
|
1646
|
+
private startPolling(): void {
|
|
1647
|
+
// Poll every 5 seconds
|
|
1648
|
+
this.pollSubscription = interval(5000).subscribe(() => {
|
|
1649
|
+
// Refresh submissions list from API using last filters
|
|
1650
|
+
this.api.refreshSubmissions().subscribe({
|
|
1651
|
+
next: () => {
|
|
1652
|
+
// After API call completes, reload from cache
|
|
1653
|
+
this.loadSubmission();
|
|
1654
|
+
},
|
|
1655
|
+
error: (error) => {
|
|
1656
|
+
console.error("Failed to poll submission:", error);
|
|
1657
|
+
this.actionError.emit({ action: "poll", error });
|
|
1658
|
+
},
|
|
1659
|
+
});
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
/**
|
|
1664
|
+
* Stop polling
|
|
1665
|
+
*/
|
|
1666
|
+
private stopPolling(): void {
|
|
1667
|
+
if (this.pollSubscription) {
|
|
1668
|
+
this.pollSubscription.unsubscribe();
|
|
1669
|
+
this.pollSubscription = undefined;
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
/**
|
|
1674
|
+
* Handle field value change
|
|
1675
|
+
*/
|
|
1676
|
+
protected onFieldChange(field: Field, event: Event): void {
|
|
1677
|
+
if (!this.submissionId) {
|
|
1678
|
+
if (this.config.debug())
|
|
1679
|
+
console.warn(
|
|
1680
|
+
"[SeaDataViewer] Cannot update field without submission ID",
|
|
1681
|
+
);
|
|
1682
|
+
return;
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
const input = event.target as HTMLInputElement;
|
|
1686
|
+
const value = this.parseValue(input.value, field.type);
|
|
1687
|
+
|
|
1688
|
+
this.fieldChanged.emit({ field, value });
|
|
1689
|
+
|
|
1690
|
+
// Optimistically update local state
|
|
1691
|
+
const current = this.submission();
|
|
1692
|
+
if (current && current.fields) {
|
|
1693
|
+
const updatedFields = current.fields.map((f) =>
|
|
1694
|
+
f.id === field.id ? { ...f, value } : f,
|
|
1695
|
+
);
|
|
1696
|
+
this.submission.set({ ...current, fields: updatedFields });
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
// Update on server
|
|
1700
|
+
this.api
|
|
1701
|
+
.updateSubmissionField(this.submissionId, field.id, value)
|
|
1702
|
+
.subscribe({
|
|
1703
|
+
error: (error) => {
|
|
1704
|
+
console.error("Failed to update field:", error);
|
|
1705
|
+
// Revert optimistic update
|
|
1706
|
+
this.loadSubmission();
|
|
1707
|
+
},
|
|
1708
|
+
});
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
/**
|
|
1712
|
+
* Get data groups for a form group ID
|
|
1713
|
+
*/
|
|
1714
|
+
protected getDataGroupsForFormGroup(formGroupId: string): DataGroup[] {
|
|
1715
|
+
const data = this.submissionData();
|
|
1716
|
+
if (!data?.groups) return [];
|
|
1717
|
+
return data.groups.filter((g) => g.formGroupId === formGroupId);
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
/**
|
|
1721
|
+
* Get data item for a field in a group
|
|
1722
|
+
*/
|
|
1723
|
+
protected getItemForField(group: DataGroup, fieldId: string): any {
|
|
1724
|
+
return group.items?.find((item) => item.formField?.id === fieldId);
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
/**
|
|
1728
|
+
* Check if an item is selected
|
|
1729
|
+
*/
|
|
1730
|
+
protected isItemSelected(item: any): boolean {
|
|
1731
|
+
const selectedId = this.selectedItemId();
|
|
1732
|
+
if (!selectedId || !item) return false;
|
|
1733
|
+
return item.id === selectedId;
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
/**
|
|
1737
|
+
* Mark a table item as selected when focused
|
|
1738
|
+
*/
|
|
1739
|
+
protected onTableItemFocus(item: any): void {
|
|
1740
|
+
if (item) {
|
|
1741
|
+
this.selectedItemId.set(item.id);
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
/**
|
|
1746
|
+
* Handle citation click from data item
|
|
1747
|
+
*/
|
|
1748
|
+
protected onItemCitationClick(item: any): void {
|
|
1749
|
+
if (this.config.debug())
|
|
1750
|
+
console.warn("[SeaDataViewer] Item citation clicked:", {
|
|
1751
|
+
itemId: item.id,
|
|
1752
|
+
documentCitationId: item.documentCitationId,
|
|
1753
|
+
documentExtractionId: item.documentExtractionId,
|
|
1754
|
+
});
|
|
1755
|
+
|
|
1756
|
+
if (!item.documentCitationId) {
|
|
1757
|
+
if (this.config.debug())
|
|
1758
|
+
console.warn("[SeaDataViewer] No citation data for item");
|
|
1759
|
+
return;
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
// Get documents from the already-loaded submission data
|
|
1763
|
+
const data = this.submissionData();
|
|
1764
|
+
if (!data?.documents) {
|
|
1765
|
+
if (this.config.debug())
|
|
1766
|
+
console.warn("[SeaDataViewer] No documents in submission data");
|
|
1767
|
+
return;
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
const documents = data.documents;
|
|
1771
|
+
if (this.config.debug())
|
|
1772
|
+
console.warn("[SeaDataViewer] Looking for document with citation:", {
|
|
1773
|
+
citationId: item.documentCitationId,
|
|
1774
|
+
documentCount: documents.length,
|
|
1775
|
+
});
|
|
1776
|
+
|
|
1777
|
+
// Find document by citation ID
|
|
1778
|
+
const document = documents.find((doc) =>
|
|
1779
|
+
doc.citations?.some((c: any) => c.id === item.documentCitationId),
|
|
1780
|
+
);
|
|
1781
|
+
|
|
1782
|
+
if (document) {
|
|
1783
|
+
if (this.config.debug())
|
|
1784
|
+
console.warn("[SeaDataViewer] Found document:", {
|
|
1785
|
+
documentId: (document as any).documentId,
|
|
1786
|
+
name: document.name,
|
|
1787
|
+
});
|
|
1788
|
+
|
|
1789
|
+
// Map the document to the expected Document type
|
|
1790
|
+
this.selectedDocument.set({
|
|
1791
|
+
id: (document as any).documentId,
|
|
1792
|
+
documentExtractionId: document.documentExtractionId,
|
|
1793
|
+
name: document.name,
|
|
1794
|
+
url: document.url,
|
|
1795
|
+
urlExpiry: document.urlExpiry,
|
|
1796
|
+
citations: document.citations,
|
|
1797
|
+
status: document.status,
|
|
1798
|
+
});
|
|
1799
|
+
this.selectedCitationId.set(item.documentCitationId);
|
|
1800
|
+
this.selectedItemId.set(item.id);
|
|
1801
|
+
this.showDocumentList.set(false);
|
|
1802
|
+
} else {
|
|
1803
|
+
if (this.config.debug())
|
|
1804
|
+
console.warn(
|
|
1805
|
+
"[SeaDataViewer] No document found with citation ID:",
|
|
1806
|
+
item.documentCitationId,
|
|
1807
|
+
);
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
/**
|
|
1812
|
+
* Handle citation click from PDF viewer
|
|
1813
|
+
*/
|
|
1814
|
+
protected onPdfCitationClick(citationId: string): void {
|
|
1815
|
+
if (this.config.debug())
|
|
1816
|
+
console.warn("[SeaDataViewer] PDF citation clicked:", citationId);
|
|
1817
|
+
|
|
1818
|
+
// Find the data item with this citation ID
|
|
1819
|
+
const data = this.submissionData();
|
|
1820
|
+
if (!data?.groups) {
|
|
1821
|
+
if (this.config.debug())
|
|
1822
|
+
console.warn("[SeaDataViewer] No data groups available");
|
|
1823
|
+
return;
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
// Search through all groups and items to find the one with this citation
|
|
1827
|
+
for (const group of data.groups) {
|
|
1828
|
+
for (const item of group.items || []) {
|
|
1829
|
+
if (item.documentCitationId === citationId) {
|
|
1830
|
+
if (this.config.debug())
|
|
1831
|
+
console.warn("[SeaDataViewer] Found matching item:", item.id);
|
|
1832
|
+
this.selectedItemId.set(item.id);
|
|
1833
|
+
this.selectedCitationId.set(citationId);
|
|
1834
|
+
return;
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
if (this.config.debug())
|
|
1840
|
+
console.warn(
|
|
1841
|
+
"[SeaDataViewer] No item found with citation ID:",
|
|
1842
|
+
citationId,
|
|
1843
|
+
);
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
protected closePdfViewer(): void {
|
|
1847
|
+
this.selectedDocument.set(null);
|
|
1848
|
+
this.selectedCitationId.set(undefined);
|
|
1849
|
+
this.selectedItemId.set(undefined);
|
|
1850
|
+
|
|
1851
|
+
// Show document list again if there are documents
|
|
1852
|
+
const data = this.submissionData();
|
|
1853
|
+
if (data?.documents && data.documents.length > 0) {
|
|
1854
|
+
this.showDocumentList.set(true);
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
/**
|
|
1859
|
+
* Handle document selection from document list
|
|
1860
|
+
*/
|
|
1861
|
+
protected onDocumentSelected(document: Document): void {
|
|
1862
|
+
if (this.config.debug())
|
|
1863
|
+
console.warn("[SeaDataViewer] Document selected from list:", document);
|
|
1864
|
+
|
|
1865
|
+
this.selectedDocument.set(document);
|
|
1866
|
+
this.showDocumentList.set(false);
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
/**
|
|
1870
|
+
* Toggle submission status between draft and final
|
|
1871
|
+
*/
|
|
1872
|
+
protected toggleSubmissionStatus(): void {
|
|
1873
|
+
const data = this.submissionData();
|
|
1874
|
+
if (!data || !this.submissionId) {
|
|
1875
|
+
return;
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
const currentStatus = data.status;
|
|
1879
|
+
const normalizedStatus =
|
|
1880
|
+
currentStatus === "finalised" ? "final" : currentStatus;
|
|
1881
|
+
if (normalizedStatus !== "draft" && normalizedStatus !== "final") {
|
|
1882
|
+
if (this.config.debug())
|
|
1883
|
+
console.warn(
|
|
1884
|
+
"[SeaDataViewer] Unsupported submission status for toggle:",
|
|
1885
|
+
currentStatus,
|
|
1886
|
+
);
|
|
1887
|
+
return;
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
const newStatus = normalizedStatus === "draft" ? "final" : "draft";
|
|
1891
|
+
|
|
1892
|
+
if (this.config.debug())
|
|
1893
|
+
console.warn(
|
|
1894
|
+
"[SeaDataViewer] Updating submission status from",
|
|
1895
|
+
currentStatus,
|
|
1896
|
+
"to",
|
|
1897
|
+
newStatus,
|
|
1898
|
+
);
|
|
1899
|
+
if (this.config.debug())
|
|
1900
|
+
console.warn("[SeaDataViewer] Submission ID:", this.submissionId);
|
|
1901
|
+
|
|
1902
|
+
this.updatingStatus.set(true);
|
|
1903
|
+
|
|
1904
|
+
this.api.updateSubmissionStatus(this.submissionId, newStatus).subscribe({
|
|
1905
|
+
next: (submission) => {
|
|
1906
|
+
if (this.config.debug())
|
|
1907
|
+
console.warn(
|
|
1908
|
+
"[SeaDataViewer] Submission status updated successfully:",
|
|
1909
|
+
submission,
|
|
1910
|
+
);
|
|
1911
|
+
this.updatingStatus.set(false);
|
|
1912
|
+
|
|
1913
|
+
// Update the local submission data
|
|
1914
|
+
const currentData = this.submissionData();
|
|
1915
|
+
if (currentData) {
|
|
1916
|
+
this.submissionData.set({
|
|
1917
|
+
...currentData,
|
|
1918
|
+
status: newStatus,
|
|
1919
|
+
});
|
|
1920
|
+
}
|
|
1921
|
+
},
|
|
1922
|
+
error: (err) => {
|
|
1923
|
+
console.error(
|
|
1924
|
+
"[SeaDataViewer] Failed to update submission status:",
|
|
1925
|
+
err,
|
|
1926
|
+
);
|
|
1927
|
+
this.updatingStatus.set(false);
|
|
1928
|
+
this.actionError.emit({ action: "update-status", error: err });
|
|
1929
|
+
},
|
|
1930
|
+
});
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1933
|
+
/**
|
|
1934
|
+
* Get HTML input type for field type
|
|
1935
|
+
*/
|
|
1936
|
+
protected getInputType(fieldType: string): string {
|
|
1937
|
+
switch (fieldType) {
|
|
1938
|
+
case "number":
|
|
1939
|
+
case "currency":
|
|
1940
|
+
return "number";
|
|
1941
|
+
case "email":
|
|
1942
|
+
return "email";
|
|
1943
|
+
case "phone":
|
|
1944
|
+
return "tel";
|
|
1945
|
+
case "url":
|
|
1946
|
+
return "url";
|
|
1947
|
+
case "date":
|
|
1948
|
+
return "date";
|
|
1949
|
+
default:
|
|
1950
|
+
return "text";
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
/**
|
|
1955
|
+
* Format field value for display
|
|
1956
|
+
*/
|
|
1957
|
+
protected formatValue(value: unknown): string {
|
|
1958
|
+
if (value === null || value === undefined) return "";
|
|
1959
|
+
if (typeof value === "object") return JSON.stringify(value);
|
|
1960
|
+
return String(value);
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1963
|
+
/**
|
|
1964
|
+
* Parse input value based on field type
|
|
1965
|
+
*/
|
|
1966
|
+
private parseValue(value: string, fieldType: string): unknown {
|
|
1967
|
+
switch (fieldType) {
|
|
1968
|
+
case "number":
|
|
1969
|
+
case "currency":
|
|
1970
|
+
return parseFloat(value);
|
|
1971
|
+
case "boolean":
|
|
1972
|
+
return value === "true" || value === "1";
|
|
1973
|
+
case "date":
|
|
1974
|
+
return new Date(value).toISOString();
|
|
1975
|
+
default:
|
|
1976
|
+
return value;
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
/**
|
|
1981
|
+
* Format date for display
|
|
1982
|
+
*/
|
|
1983
|
+
protected formatDate(dateString: string): string {
|
|
1984
|
+
const date = new Date(dateString);
|
|
1985
|
+
const now = new Date();
|
|
1986
|
+
const diffMs = now.getTime() - date.getTime();
|
|
1987
|
+
const diffMins = Math.floor(diffMs / 60000);
|
|
1988
|
+
const diffHours = Math.floor(diffMs / 3600000);
|
|
1989
|
+
const diffDays = Math.floor(diffMs / 86400000);
|
|
1990
|
+
|
|
1991
|
+
if (diffMins < 1) return "just now";
|
|
1992
|
+
if (diffMins < 60) return `${diffMins}m ago`;
|
|
1993
|
+
if (diffHours < 24) return `${diffHours}h ago`;
|
|
1994
|
+
if (diffDays < 7) return `${diffDays}d ago`;
|
|
1995
|
+
|
|
1996
|
+
return date.toLocaleDateString();
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
/**
|
|
2000
|
+
* Get item value (from editing state or original value)
|
|
2001
|
+
*/
|
|
2002
|
+
protected getItemValue(item: any): any {
|
|
2003
|
+
if (!item) return "";
|
|
2004
|
+
return this.itemValues.has(item.id)
|
|
2005
|
+
? this.itemValues.get(item.id)
|
|
2006
|
+
: item.value;
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
/**
|
|
2010
|
+
* Check if item is unsaved
|
|
2011
|
+
*/
|
|
2012
|
+
protected isItemUnsaved(item: any): boolean {
|
|
2013
|
+
return item ? this.unsavedItems.has(item.id) : false;
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
/**
|
|
2017
|
+
* Handle value change from input
|
|
2018
|
+
*/
|
|
2019
|
+
protected onValueChange(item: any, event: Event): void {
|
|
2020
|
+
if (!item) return;
|
|
2021
|
+
|
|
2022
|
+
const input = event.target as HTMLInputElement;
|
|
2023
|
+
const value = input.value;
|
|
2024
|
+
|
|
2025
|
+
this.selectedItemId.set(item.id);
|
|
2026
|
+
|
|
2027
|
+
if (this.config.debug())
|
|
2028
|
+
console.warn(
|
|
2029
|
+
"[SeaDataViewer] Value changed for item:",
|
|
2030
|
+
item.id,
|
|
2031
|
+
"new value:",
|
|
2032
|
+
value,
|
|
2033
|
+
);
|
|
2034
|
+
|
|
2035
|
+
// Update local state
|
|
2036
|
+
this.itemValues.set(item.id, value);
|
|
2037
|
+
this.unsavedItems.add(item.id);
|
|
2038
|
+
|
|
2039
|
+
// Emit to debounced subject
|
|
2040
|
+
this.valueChanges$.next({ itemId: item.id, value });
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2043
|
+
/**
|
|
2044
|
+
* Save item value to API
|
|
2045
|
+
*/
|
|
2046
|
+
private saveItemValue(itemId: string, value: any): void {
|
|
2047
|
+
if (!this.submissionId) {
|
|
2048
|
+
if (this.config.debug())
|
|
2049
|
+
console.warn(
|
|
2050
|
+
"[SeaDataViewer] Cannot save item value without submission ID",
|
|
2051
|
+
);
|
|
2052
|
+
return;
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
if (this.config.debug())
|
|
2056
|
+
console.warn("[SeaDataViewer] Saving item value:", itemId, value);
|
|
2057
|
+
|
|
2058
|
+
this.api
|
|
2059
|
+
.updateSubmissionItemValue(this.submissionId, itemId, value)
|
|
2060
|
+
.subscribe({
|
|
2061
|
+
next: () => {
|
|
2062
|
+
if (this.config.debug())
|
|
2063
|
+
console.warn("[SeaDataViewer] Item value saved successfully");
|
|
2064
|
+
this.unsavedItems.delete(itemId);
|
|
2065
|
+
this.itemValues.delete(itemId);
|
|
2066
|
+
this.updateItemValueLocally(itemId, value);
|
|
2067
|
+
},
|
|
2068
|
+
error: (err) => {
|
|
2069
|
+
console.error("[SeaDataViewer] Failed to save item value:", err);
|
|
2070
|
+
this.actionError.emit({ action: "save-value", error: err });
|
|
2071
|
+
// Keep in unsaved state on error
|
|
2072
|
+
},
|
|
2073
|
+
});
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
/**
|
|
2077
|
+
* Update submission data locally so UI reflects latest value
|
|
2078
|
+
*/
|
|
2079
|
+
private updateItemValueLocally(itemId: string, value: unknown): void {
|
|
2080
|
+
const data = this.submissionData();
|
|
2081
|
+
if (!data?.groups) {
|
|
2082
|
+
return;
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
const updatedGroups = data.groups.map((group) => ({
|
|
2086
|
+
...group,
|
|
2087
|
+
items:
|
|
2088
|
+
group.items?.map((item) =>
|
|
2089
|
+
item.id === itemId ? { ...item, value } : item,
|
|
2090
|
+
) ?? [],
|
|
2091
|
+
}));
|
|
2092
|
+
|
|
2093
|
+
this.submissionData.set({
|
|
2094
|
+
...data,
|
|
2095
|
+
groups: updatedGroups,
|
|
2096
|
+
});
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
/**
|
|
2100
|
+
* Open feedback modal for a field
|
|
2101
|
+
*/
|
|
2102
|
+
protected openFeedbackModal(item: any, field: any): void {
|
|
2103
|
+
if (this.config.debug())
|
|
2104
|
+
console.warn(
|
|
2105
|
+
"[SeaDataViewer] Opening feedback modal for item:",
|
|
2106
|
+
item,
|
|
2107
|
+
"field:",
|
|
2108
|
+
field,
|
|
2109
|
+
);
|
|
2110
|
+
|
|
2111
|
+
if (!item) {
|
|
2112
|
+
if (this.config.debug())
|
|
2113
|
+
console.warn("[SeaDataViewer] Cannot open feedback modal without item");
|
|
2114
|
+
return;
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
// Set the feedback modal state
|
|
2118
|
+
this.feedbackFieldName.set(field?.name);
|
|
2119
|
+
this.feedbackFieldHint.set(field?.hint);
|
|
2120
|
+
this.feedbackExtractedValue.set(item.value);
|
|
2121
|
+
this.feedbackSubmissionItemId.set(item.id);
|
|
2122
|
+
|
|
2123
|
+
// Open the modal using ViewChild
|
|
2124
|
+
setTimeout(() => {
|
|
2125
|
+
this.feedbackModal?.open();
|
|
2126
|
+
}, 0);
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
/**
|
|
2130
|
+
* Handle feedback submission
|
|
2131
|
+
*/
|
|
2132
|
+
protected onFeedbackSubmitted(event: {
|
|
2133
|
+
submissionItemId: string;
|
|
2134
|
+
extractedValue: any;
|
|
2135
|
+
correctedValue: string;
|
|
2136
|
+
feedback: string;
|
|
2137
|
+
}): void {
|
|
2138
|
+
if (this.config.debug())
|
|
2139
|
+
console.warn("[SeaDataViewer] Feedback submitted:", event);
|
|
2140
|
+
|
|
2141
|
+
if (!this.submissionId) {
|
|
2142
|
+
if (this.config.debug())
|
|
2143
|
+
console.warn(
|
|
2144
|
+
"[SeaDataViewer] Cannot submit feedback without submission ID",
|
|
2145
|
+
);
|
|
2146
|
+
return;
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
// Call API to submit feedback
|
|
2150
|
+
this.api
|
|
2151
|
+
.submitFieldFeedback(
|
|
2152
|
+
this.submissionId,
|
|
2153
|
+
event.submissionItemId,
|
|
2154
|
+
event.extractedValue,
|
|
2155
|
+
event.correctedValue,
|
|
2156
|
+
event.feedback,
|
|
2157
|
+
)
|
|
2158
|
+
.subscribe({
|
|
2159
|
+
next: () => {
|
|
2160
|
+
if (this.config.debug())
|
|
2161
|
+
console.warn("[SeaDataViewer] Feedback submitted successfully");
|
|
2162
|
+
const corrected = event.correctedValue.trim();
|
|
2163
|
+
if (corrected) {
|
|
2164
|
+
this.unsavedItems.delete(event.submissionItemId);
|
|
2165
|
+
this.itemValues.delete(event.submissionItemId);
|
|
2166
|
+
this.updateItemValueLocally(event.submissionItemId, corrected);
|
|
2167
|
+
}
|
|
2168
|
+
// Reload submission data to ensure everything is in sync
|
|
2169
|
+
this.loadSubmission();
|
|
2170
|
+
},
|
|
2171
|
+
error: (err) => {
|
|
2172
|
+
console.error("[SeaDataViewer] Failed to submit feedback:", err);
|
|
2173
|
+
this.actionError.emit({ action: "submit-feedback", error: err });
|
|
2174
|
+
},
|
|
2175
|
+
});
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
/**
|
|
2179
|
+
* Handle column header click for sorting
|
|
2180
|
+
*/
|
|
2181
|
+
protected onColumnHeaderClick(fieldId: string): void {
|
|
2182
|
+
const current = this.sortState();
|
|
2183
|
+
|
|
2184
|
+
// Toggle direction if same column, otherwise start with asc
|
|
2185
|
+
if (current && current.columnId === fieldId) {
|
|
2186
|
+
const newDirection = current.direction === "asc" ? "desc" : "asc";
|
|
2187
|
+
this.sortState.set({ columnId: fieldId, direction: newDirection });
|
|
2188
|
+
} else {
|
|
2189
|
+
this.sortState.set({ columnId: fieldId, direction: "asc" });
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
/**
|
|
2194
|
+
* Get sorted data groups based on current sort state
|
|
2195
|
+
*/
|
|
2196
|
+
protected getSortedDataGroups(groups: DataGroup[]): DataGroup[] {
|
|
2197
|
+
const sort = this.sortState();
|
|
2198
|
+
|
|
2199
|
+
if (!sort) {
|
|
2200
|
+
return groups;
|
|
2201
|
+
}
|
|
2202
|
+
|
|
2203
|
+
// Create a copy to avoid mutating the original
|
|
2204
|
+
return [...groups].sort((a, b) => {
|
|
2205
|
+
const itemA = this.getItemForField(a, sort.columnId);
|
|
2206
|
+
const itemB = this.getItemForField(b, sort.columnId);
|
|
2207
|
+
|
|
2208
|
+
const valueA = this.getItemValue(itemA);
|
|
2209
|
+
const valueB = this.getItemValue(itemB);
|
|
2210
|
+
|
|
2211
|
+
// Handle empty values (always sort to bottom)
|
|
2212
|
+
if (!valueA && !valueB) return 0;
|
|
2213
|
+
if (!valueA) return 1;
|
|
2214
|
+
if (!valueB) return -1;
|
|
2215
|
+
|
|
2216
|
+
// Try numeric comparison first
|
|
2217
|
+
const numA = parseFloat(valueA);
|
|
2218
|
+
const numB = parseFloat(valueB);
|
|
2219
|
+
|
|
2220
|
+
let comparison = 0;
|
|
2221
|
+
if (!isNaN(numA) && !isNaN(numB)) {
|
|
2222
|
+
comparison = numA - numB;
|
|
2223
|
+
} else {
|
|
2224
|
+
// String comparison
|
|
2225
|
+
comparison = String(valueA).localeCompare(String(valueB));
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2228
|
+
return sort.direction === "asc" ? comparison : -comparison;
|
|
2229
|
+
});
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
/**
|
|
2233
|
+
* Get sort icon for a field
|
|
2234
|
+
*/
|
|
2235
|
+
protected getSortIcon(fieldId: string): string {
|
|
2236
|
+
const sort = this.sortState();
|
|
2237
|
+
if (!sort || sort.columnId !== fieldId) return "";
|
|
2238
|
+
return sort.direction === "asc" ? "↑" : "↓";
|
|
2239
|
+
}
|
|
2240
|
+
}
|