panoma 0.10.0 → 0.10.2
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/app/BUILD-INFO.json +2 -2
- package/app/apps/web/.next-bundle/BUILD_ID +1 -1
- package/app/apps/web/.next-bundle/app-build-manifest.json +343 -343
- package/app/apps/web/.next-bundle/app-path-routes-manifest.json +42 -42
- package/app/apps/web/.next-bundle/build-manifest.json +3 -3
- package/app/apps/web/.next-bundle/prerender-manifest.json +9 -9
- package/app/apps/web/.next-bundle/required-server-files.json +3 -3
- package/app/apps/web/.next-bundle/server/app/(app)/agents/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/agents/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/ai/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/ai/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/apps/[id]/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/apps/[id]/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/apps/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/apps/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/bridge/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/bridge/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/copies/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/copies/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/credentials/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/credentials/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/disk/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/disk/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/handoff/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/handoff/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/hidden/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/hidden/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/p/[slug]/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/p/[slug]/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/p/[slug]/video/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/p/[slug]/video/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/packages/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/packages/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/runs/[id]/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/runs/[id]/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/runs/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/runs/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/search/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/search/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/spend/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/spend/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/twin/look/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/twin/look/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/twin/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/twin/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/(app)/unsaved/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/(app)/unsaved/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/_not-found/page.js +2 -2
- package/app/apps/web/.next-bundle/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/accounts/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/accounts/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/apps/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/apps/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/consult/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/consult/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/context/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/context/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/conversations/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/conversations/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/handoff/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/handoff/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/hello/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/hello/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/journal/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/journal/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/keys/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/keys/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/log/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/log/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/mcp/route.js +2 -2
- package/app/apps/web/.next-bundle/server/app/api/agent/mcp/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/notes/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/notes/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/tasks/[id]/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/tasks/[id]/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/tasks/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/tasks/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/video/cancel/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/video/cancel/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/video/jobs/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/video/jobs/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/video/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/agent/video/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/ai/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/ai/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/[id]/[operation]/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/[id]/[operation]/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/[id]/credentials/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/[id]/credentials/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/[id]/jobs/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/[id]/jobs/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/[id]/legal/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/[id]/legal/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/[id]/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/[id]/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/[id]/settings/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/[id]/settings/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/jobs/[jobId]/artifact/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/jobs/[jobId]/artifact/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/jobs/[jobId]/cancel/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/jobs/[jobId]/cancel/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/jobs/[jobId]/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/jobs/[jobId]/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/apps/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/assets/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/assets/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/assignments/launch/route.js +2 -2
- package/app/apps/web/.next-bundle/server/app/api/assignments/launch/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/assignments/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/assignments/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/catalog/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/catalog/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/check/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/check/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/consultations/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/consultations/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/describe/route.js +2 -2
- package/app/apps/web/.next-bundle/server/app/api/describe/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/disk/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/disk/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/enrich/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/enrich/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/environment/route.js +2 -2
- package/app/apps/web/.next-bundle/server/app/api/environment/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/handoff/[id]/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/handoff/[id]/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/handoff/digest/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/handoff/digest/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/handoff/launch/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/handoff/launch/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/handoff/record/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/handoff/record/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/handoff/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/handoff/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/hooks/route.js +2 -2
- package/app/apps/web/.next-bundle/server/app/api/hooks/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/ingest/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/ingest/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/md/apply/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/md/apply/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/md/context/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/md/context/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/md/inspect/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/md/inspect/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/md/repair/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/md/repair/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/md/review/route.js +2 -2
- package/app/apps/web/.next-bundle/server/app/api/md/review/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/memory/export/route.js +2 -2
- package/app/apps/web/.next-bundle/server/app/api/memory/export/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/north/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/north/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/notes/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/notes/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/open/all/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/open/all/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/open/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/open/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/project/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/project/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/rescan/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/rescan/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/roots/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/roots/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/runs/[id]/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/runs/[id]/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/runs/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/runs/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/scale/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/scale/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/search/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/search/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/secrets/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/secrets/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/spend/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/spend/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/tasks/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/tasks/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/today/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/today/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/assign/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/assign/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/classify/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/classify/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/critique/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/critique/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/design/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/design/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/distill/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/distill/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/episodes/learn/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/episodes/learn/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/episodes/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/episodes/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/look/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/look/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/mine/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/mine/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/rehearse/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/rehearse/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/score/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/score/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/shot/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/shot/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/sources/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/sources/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/synthesize/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/synthesize/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/taste/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/taste/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/verdicts/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/twin/verdicts/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/watch/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/api/watch/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/apple-icon.png/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/icon/[id]/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app/icon/[id]/route_client-reference-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/app/icon.png/route.js +1 -1
- package/app/apps/web/.next-bundle/server/app-paths-manifest.json +42 -42
- package/app/apps/web/.next-bundle/server/chunks/1454.js +2 -0
- package/app/apps/web/.next-bundle/server/chunks/1646.js +5 -5
- package/app/apps/web/.next-bundle/server/chunks/2791.js +1 -0
- package/app/apps/web/.next-bundle/server/chunks/3863.js +1 -1
- package/app/apps/web/.next-bundle/server/chunks/6131.js +1 -0
- package/app/apps/web/.next-bundle/server/chunks/6206.js +1 -1
- package/app/apps/web/.next-bundle/server/chunks/6384.js +1 -1
- package/app/apps/web/.next-bundle/server/chunks/7245.js +1 -1
- package/app/apps/web/.next-bundle/server/chunks/8463.js +1 -1
- package/app/apps/web/.next-bundle/server/chunks/9128.js +1 -1
- package/app/apps/web/.next-bundle/server/functions-config-manifest.json +6 -6
- package/app/apps/web/.next-bundle/server/middleware-build-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/middleware-manifest.json +5 -5
- package/app/apps/web/.next-bundle/server/middleware.js +2 -2
- package/app/apps/web/.next-bundle/server/next-font-manifest.js +1 -1
- package/app/apps/web/.next-bundle/server/next-font-manifest.json +1 -1
- package/app/apps/web/.next-bundle/server/pages/500.html +1 -1
- package/app/apps/web/.next-bundle/server/server-reference-manifest.json +1 -1
- package/app/apps/web/.next-bundle/static/chunks/{1369-514f421b74ddd546.js → 1369-2c988debdc250f63.js} +1 -1
- package/app/apps/web/.next-bundle/static/chunks/2575-61e3c59775a07058.js +1 -0
- package/app/apps/web/.next-bundle/static/chunks/2921-abf2bd91adbc76d4.js +1 -0
- package/app/apps/web/.next-bundle/static/chunks/2948-e207a4e3dee8fa26.js +1 -0
- package/app/apps/web/.next-bundle/static/chunks/7f092448-8ec90a5d5349d5de.js +1 -0
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/agents/page-cae57c1555749574.js +1 -0
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/ai/{page-beb96e7f7a56ac65.js → page-f63553805baaea0c.js} +1 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/apps/[id]/{page-7fd561dfea561bee.js → page-da64889cd7413e00.js} +1 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/apps/{page-ba0da767076b59ee.js → page-3cf7accd30ae08c7.js} +1 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/bridge/page-f1661f3e36e93d98.js +1 -0
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/copies/page-44ebbc5d00245788.js +1 -0
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/credentials/{page-db952949fd680244.js → page-c1d8a21174d6bba2.js} +1 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/disk/{page-58dba9a693f3efd1.js → page-79c4c0af255ea5db.js} +1 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/{error-2c3f75f2c68c6bab.js → error-bc8b33871ce6ee62.js} +1 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/handoff/{page-af0790c554af2371.js → page-41198249f6480477.js} +1 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/hidden/page-0eec0c39fae7b922.js +1 -0
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/{layout-2f357c79701ed83e.js → layout-f4763a241faa2e25.js} +1 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/p/[slug]/{page-ea0ecbae2d960666.js → page-bf90188e9460900b.js} +1 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/p/[slug]/video/page-8ac2b429692e90c6.js +1 -0
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/page-a6579330ff0a1c45.js +1 -0
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/runs/[id]/page-71e91e2f82fbcd0a.js +1 -0
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/runs/page-44ebbc5d00245788.js +1 -0
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/search/{page-5f61bffc868d47cc.js → page-0788d039d155cdf2.js} +1 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/spend/{page-fce603598ab4b457.js → page-9b43a28c5537214d.js} +1 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/twin/look/{page-e8582a3dd4da47bb.js → page-47bc811a5a4bbed5.js} +1 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/twin/{page-6e103fc5ed54eabe.js → page-12d36b362fc4d2d2.js} +1 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/unsaved/{page-433663c1b9556d04.js → page-4bffe36641979e0c.js} +1 -1
- package/app/apps/web/.next-bundle/static/chunks/app/global-not-found-44ebbc5d00245788.js +1 -0
- package/app/apps/web/.next-bundle/static/chunks/app/not-found-44ebbc5d00245788.js +1 -0
- package/app/apps/web/.next-bundle/static/chunks/{main-app-0bad81d9bc79bc82.js → main-app-ec5cb301dd9fc61e.js} +1 -1
- package/app/apps/web/.next-bundle/static/css/b1d2cc9ccd4e30bf.css +1 -0
- package/app/apps/web/server.js +1 -1
- package/app/node_modules/drizzle-orm/node_modules/.bin/gel +3 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/app/apps/web/.next-bundle/server/chunks/5839.js +0 -1
- package/app/apps/web/.next-bundle/server/chunks/7498.js +0 -2
- package/app/apps/web/.next-bundle/static/chunks/2575-e53eff318f43e123.js +0 -1
- package/app/apps/web/.next-bundle/static/chunks/2921-92c9a83559025278.js +0 -1
- package/app/apps/web/.next-bundle/static/chunks/2948-db3dde2d3c76f184.js +0 -1
- package/app/apps/web/.next-bundle/static/chunks/7f092448-875cfd730dc78b44.js +0 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/agents/page-be3b13d1301a5855.js +0 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/bridge/page-b8cc7ef93c7a01f7.js +0 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/copies/page-1c5bac527b81fbfb.js +0 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/hidden/page-a2f95d21457cf062.js +0 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/p/[slug]/video/page-51409af610218587.js +0 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/page-ad2cd4e236fd2f60.js +0 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/runs/[id]/page-75c179ccca63a724.js +0 -1
- package/app/apps/web/.next-bundle/static/chunks/app/(app)/runs/page-1c5bac527b81fbfb.js +0 -1
- package/app/apps/web/.next-bundle/static/chunks/app/global-not-found-1c5bac527b81fbfb.js +0 -1
- package/app/apps/web/.next-bundle/static/chunks/app/not-found-1c5bac527b81fbfb.js +0 -1
- package/app/apps/web/.next-bundle/static/css/5fdcdf46b29ffe26.css +0 -1
- /package/app/apps/web/.next-bundle/static/{phRAJdip0Dtgh1L1Yw0jm → w6oDX-SYfedAnhX2GThXZ}/_buildManifest.js +0 -0
- /package/app/apps/web/.next-bundle/static/{phRAJdip0Dtgh1L1Yw0jm → w6oDX-SYfedAnhX2GThXZ}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2229,2966,4345,4709],{60259:(e,s,_)=>{Promise.resolve().then(_.t.bind(_,3953,23))}},e=>{e.O(0,[3953,1305,6823,7358],()=>e(e.s=60259)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7712],{9144:(e,t,r)=>{"use strict";r.d(t,{I18nProvider:()=>i,Ym:()=>o,Zs:()=>u,kj:()=>d});var n=r(38657),a=r(32165),s=r(2575);let l=(0,a.createContext)("en"),c=(0,a.createContext)("panoma");function i(e){let{locale:t,cli:r,children:a}=e;return(0,n.jsx)(l.Provider,{value:t,children:(0,n.jsx)(c.Provider,{value:r,children:a})})}function o(){return(0,a.useContext)(l)}function u(){return(0,a.useContext)(c)}function d(){let e=(0,a.useContext)(l),t=(0,a.useContext)(c);return(0,a.useCallback)((r,n)=>(0,s.t)(e,r,{cli:t,...n}),[e,t])}},13e3:(e,t,r)=>{"use strict";let n;r.d(t,{R:()=>i,b:()=>l});var a=r(32165);let s={remote:!1,editor:null,editors:[],desktopApps:[],agents:[]};function l(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],[t,r]=(0,a.useState)(s);return(0,a.useEffect)(()=>{if(!e)return;null!=n||(n=fetch("/api/open").then(e=>e.json()).catch(()=>s));let t=!0;return n.then(e=>{t&&r(e)}),()=>{t=!1}},[e]),t}let c={cursor:"cursor",code:"vscode",windsurf:"windsurf",zed:"zed"};function i(e,t,r,n){let a=c[null!=e?e:"code"];if(!a)return null;let s=encodeURI("".concat(t.replace(/\/$/,""),"/").concat(r)).replace(/#/g,"%23").replace(/\?/g,"%3F");return"".concat(a,"://file").concat(s.startsWith("/")?"":"/").concat(s,":").concat(n)}},
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7712],{9144:(e,t,r)=>{"use strict";r.d(t,{I18nProvider:()=>i,Ym:()=>o,Zs:()=>u,kj:()=>d});var n=r(38657),a=r(32165),s=r(2575);let l=(0,a.createContext)("en"),c=(0,a.createContext)("panoma");function i(e){let{locale:t,cli:r,children:a}=e;return(0,n.jsx)(l.Provider,{value:t,children:(0,n.jsx)(c.Provider,{value:r,children:a})})}function o(){return(0,a.useContext)(l)}function u(){return(0,a.useContext)(c)}function d(){let e=(0,a.useContext)(l),t=(0,a.useContext)(c);return(0,a.useCallback)((r,n)=>(0,s.t)(e,r,{cli:t,...n}),[e,t])}},13e3:(e,t,r)=>{"use strict";let n;r.d(t,{R:()=>i,b:()=>l});var a=r(32165);let s={remote:!1,editor:null,editors:[],desktopApps:[],agents:[]};function l(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],[t,r]=(0,a.useState)(s);return(0,a.useEffect)(()=>{if(!e)return;null!=n||(n=fetch("/api/open").then(e=>e.json()).catch(()=>s));let t=!0;return n.then(e=>{t&&r(e)}),()=>{t=!1}},[e]),t}let c={cursor:"cursor",code:"vscode",windsurf:"windsurf",zed:"zed"};function i(e,t,r,n){let a=c[null!=e?e:"code"];if(!a)return null;let s=encodeURI("".concat(t.replace(/\/$/,""),"/").concat(r)).replace(/#/g,"%23").replace(/\?/g,"%3F");return"".concat(a,"://file").concat(s.startsWith("/")?"":"/").concat(s,":").concat(n)}},17981:(e,t,r)=>{Promise.resolve().then(r.bind(r,82582))},56684:(e,t,r)=>{"use strict";r.d(t,{k5:()=>u});var n=r(32165),a={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},s=n.createContext&&n.createContext(a),l=["attr","size","title"];function c(){return(c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(null,arguments)}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach(function(t){var n,a,s;n=e,a=t,s=r[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in n?Object.defineProperty(n,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):n[a]=s}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function u(e){return t=>n.createElement(d,c({attr:o({},e.attr)},t),function e(t){return t&&t.map((t,r)=>n.createElement(t.tag,o({key:r},t.attr),e(t.child)))}(e.child))}function d(e){var t=t=>{var r,a=e.attr,s=e.size,i=e.title,u=function(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r={};for(var n in e)if(({}).hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n<s.length;n++)r=s[n],-1===t.indexOf(r)&&({}).propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}(e,l),d=s||t.size||"1em";return t.className&&(r=t.className),e.className&&(r=(r?r+" ":"")+e.className),n.createElement("svg",c({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,a,u,{className:r,style:o(o({color:e.color||t.color},t.style),e.style),height:d,width:d,xmlns:"http://www.w3.org/2000/svg"}),i&&n.createElement("title",null,i),e.children)};return void 0!==s?n.createElement(s.Consumer,null,e=>t(e)):t(a)}},82582:(e,t,r)=>{"use strict";r.d(t,{CodeSearch:()=>o});var n=r(38657),a=r(32165),s=r(3043),l=r(9144),c=r(52948),i=r(13e3);function o(e){let{initialQuery:t}=e,r=(0,l.kj)(),[o,d]=(0,a.useState)(t),[h,p]=(0,a.useState)("ready"),[f,m]=(0,a.useState)(null),[x,j]=(0,a.useState)(null),b=(0,a.useRef)(null),{remote:y,editor:v}=(0,i.b)(),g=(0,a.useCallback)(async e=>{if(!(e.trim().length<2)){p("searching"),j(null);try{var t;let n=await fetch("/api/search?q=".concat(encodeURIComponent(e.trim()))),a=await n.json();n.ok?m(a):j(null!=(t=a.error)?t:r("search.failed"))}catch(e){j(r("search.unreachable"))}finally{p("ready")}}},[r]);return(0,a.useEffect)(()=>{var e;t.trim().length>=2?g(t):null==(e=b.current)||e.focus()},[t,g]),(0,n.jsxs)("div",{children:[(0,n.jsxs)("form",{className:"flex flex-wrap items-center gap-2",onSubmit:e=>{e.preventDefault(),g(o);let t=new URL(window.location.href);t.searchParams.set("q",o.trim()),window.history.replaceState(null,"",t)},children:[(0,n.jsx)(s.JJh,{"aria-hidden":!0}),(0,n.jsx)("input",{ref:b,value:o,onChange:e=>d(e.target.value),placeholder:"stripe.webhook, TODO, API_KEY…","aria-label":r("search.fieldLabel"),className:"min-w-0 flex-1 rounded border border-edge bg-raised px-2.5 py-1.5 text-xs text-chalk placeholder:text-faint focus:border-accent focus:outline-none"}),(0,n.jsx)(c.rA,{tone:"raised",type:"submit",busy:"searching"===h,busyLabel:r("search.searching"),disabled:"searching"===h||o.trim().length<2,children:r("search.submit")})]}),(0,n.jsxs)("p",{className:"mt-2 font-mono text-[11px] text-faint",children:[r("search.scopeNote")," ",r("search.scopeVendors")," ",(0,n.jsx)("code",{children:"Pods"}),", ",(0,n.jsx)("code",{children:"vendor"}),","," ",(0,n.jsx)("code",{children:"third_party"}),", ",(0,n.jsx)("code",{children:"node_modules"}),"."]}),x&&(0,n.jsx)("p",{className:"mt-3 font-mono text-xs text-fail",children:x}),f&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("p",{className:"mt-6 flex flex-wrap gap-x-4 font-mono text-xs text-faint",children:[(0,n.jsxs)("span",{className:"text-chalk",children:[r(1===f.total?"search.matchOne":"search.matchMany",{n:f.total})," ",r(1===f.results.length?"search.inProjectOne":"search.inProjectMany",{n:f.results.length})]}),(0,n.jsx)("span",{children:r("search.reposSearched",{n:f.searched})}),f.skipped>0&&(0,n.jsx)("span",{className:"text-idle",title:r("search.skippedTitle"),children:r("search.skipped",{n:f.skipped})}),!y&&f.results.length>0&&(0,n.jsx)("span",{className:"ml-auto",children:r("search.clickToOpen")})]}),0===f.results.length?(0,n.jsx)(c.pp,{className:"mt-4",title:r("search.noMatch",{query:f.query})}):(0,n.jsx)("ul",{className:"mt-4 space-y-3",children:f.results.map(e=>(0,n.jsxs)(c.Zp,{as:"li",pad:"none",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 border-b border-edge px-4 py-2.5",children:[(0,n.jsx)("a",{href:"/p/".concat(e.slug),className:"text-sm font-medium hover:text-accent",children:e.name}),(0,n.jsx)("span",{className:"font-mono text-[11px] text-faint",title:e.root,children:function(e){let t=e.split("/");return t.length<=3?e:"…/".concat(t.slice(-2).join("/"))}(e.root)}),(0,n.jsxs)("span",{className:"ml-auto font-mono text-[11px] text-accent",children:[e.matches.length,e.truncated&&"+"]}),!y&&(0,n.jsx)(u,{id:e.id})]}),(0,n.jsx)("ul",{className:"divide-y divide-edge/50",children:e.matches.map(t=>{let a=y?null:(0,i.R)(v,e.root,t.file,t.line),s=(0,n.jsxs)(n.Fragment,{children:[t.file,(0,n.jsxs)("span",{className:"text-accent",children:[":",t.line]})]});return(0,n.jsxs)("li",{className:"flex gap-3 px-4 py-1.5 font-mono text-[11px]",children:[a?(0,n.jsx)("a",{href:a,className:"w-56 shrink-0 truncate text-faint hover:text-accent",title:r("search.openAt",{file:t.file,line:t.line}),children:s}):(0,n.jsx)("span",{className:"w-56 shrink-0 truncate text-faint",title:t.file,children:s}),(0,n.jsx)("code",{className:"min-w-0 flex-1 truncate text-smoke",children:t.text})]},"".concat(t.file,":").concat(t.line))})}),e.truncated&&(0,n.jsx)("p",{className:"px-4 py-1.5 font-mono text-[10px] text-faint",children:r("search.truncated",{n:e.matches.length})})]},e.id))})]})]})}function u(e){let{id:t}=e,r=(0,l.kj)(),[c,i]=(0,a.useState)(null);return(0,n.jsx)("button",{type:"button",title:null!=c?c:r("search.openFolder"),onClick:async()=>{try{let n=await fetch("/api/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!n.ok){var e;let t=await n.json();i(null!=(e=t.error)?e:r("search.openFailed"))}}catch(e){i(r("search.unreachable"))}},className:"shrink-0 ".concat(c?"text-fail":"text-faint hover:text-accent"),"aria-label":r("search.openFolderAria"),children:(0,n.jsx)(s.gBk,{className:"h-4 w-4","aria-hidden":!0})})}}},e=>{e.O(0,[6587,2575,2948,1305,6823,7358],()=>e(e.s=17981)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5172],{9144:(e,t,s)=>{"use strict";s.d(t,{I18nProvider:()=>o,Ym:()=>c,Zs:()=>d,kj:()=>p});var n=s(38657),a=s(32165),r=s(2575);let l=(0,a.createContext)("en"),i=(0,a.createContext)("panoma");function o(e){let{locale:t,cli:s,children:a}=e;return(0,n.jsx)(l.Provider,{value:t,children:(0,n.jsx)(i.Provider,{value:s,children:a})})}function c(){return(0,a.useContext)(l)}function d(){return(0,a.useContext)(i)}function p(){let e=(0,a.useContext)(l),t=(0,a.useContext)(i);return(0,a.useCallback)((s,n)=>(0,r.t)(e,s,{cli:t,...n}),[e,t])}},10354:(e,t,s)=>{"use strict";var n=s(61990);s.o(n,"usePathname")&&s.d(t,{usePathname:function(){return n.usePathname}}),s.o(n,"useRouter")&&s.d(t,{useRouter:function(){return n.useRouter}}),s.o(n,"useSearchParams")&&s.d(t,{useSearchParams:function(){return n.useSearchParams}})},44653:(e,t,s)=>{"use strict";s.d(t,{SpendControls:()=>f});var n=s(38657),a=s(10354),r=s(32165),l=s(9144),i=s(52948);function o(e){return"es"===e?"es-ES":"en-US"}function c(e,t){return new Intl.NumberFormat(o(t)).format(e)}let d={read:"spend.family.read",look:"spend.family.look",memory:"spend.family.memory",ask:"spend.family.ask",rehearse:"spend.family.rehearse",episodes:"spend.family.episodes",card:"spend.family.card",app:"spend.family.app",handoff:"spend.family.handoff"},p={read:"spend.familyHint.read",look:"spend.familyHint.look",memory:"spend.familyHint.memory",ask:"spend.familyHint.ask",rehearse:"spend.familyHint.rehearse",episodes:"spend.familyHint.episodes",card:"spend.familyHint.card",app:"spend.familyHint.app",handoff:"spend.familyHint.handoff"},m={factory:"spend.source.factory",file:"spend.source.file",env:"spend.source.env",paused:"spend.source.paused"};function u(e){return Object.fromEntries(e.map(e=>[e.key,{input:e.rate?String(e.rate.input):"",output:e.rate?String(e.rate.output):""}]))}function x(e){return Object.fromEntries(e.families.map(t=>{let s=e.chosen[t.family];return[t.family,void 0===s?"":String(s)]}))}function h(e){return e&&(""!==e.input.trim()||""!==e.output.trim())?{input:Number(e.input||0),output:Number(e.output||0)}:null}function f(e){let{initial:t}=e,s=(0,l.kj)(),d=(0,l.Ym)(),p=(0,a.useRouter)(),[m,f]=(0,r.useState)(()=>x(t)),[j,v]=(0,r.useState)(()=>u(t.models)),[g,N]=(0,r.useState)(t.currency),[k,w]=(0,r.useState)(t.paused),[O,C]=(0,r.useState)(t.shots),[S,P]=(0,r.useState)(!1),[E,H]=(0,r.useState)(!1),[D,F]=(0,r.useState)(!1),[z,R]=(0,r.useState)(null),M=(0,r.useRef)(!1),A=3===g.trim().length?g.trim().toUpperCase():t.currency;function I(){F(!0),H(!1),R(null)}function _(e,t,s){v(n=>{var a;return{...n,[e]:{...null!=(a=n[e])?a:{input:"",output:""},[t]:s}}}),I()}function L(e){C(e),I()}async function U(e){if(e.preventDefault(),M.current)return;M.current=!0,P(!0),I();let n={caps:Object.fromEntries(t.families.filter(e=>void 0===e.env).map(e=>{var t;let s=(null!=(t=m[e.family])?t:"").trim();return[e.family,""===s?null:Number(s)]})),rates:{...t.rates,...Object.fromEntries(t.models.map(e=>[e.key,h(j[e.key])]))},currency:g.trim().toUpperCase(),paused:k,shots:O};try{let e=await fetch("/api/spend",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),t=await e.json().catch(()=>({}));if(!e.ok){var a;R([null!=(a=t.error)?a:s("spend.failed"),t.hint].filter(Boolean).join(" "));return}if(!Array.isArray(t.families)||!Array.isArray(t.models))return void R(s("spend.failed"));f(x(t)),v(u(t.models)),N(t.currency),w(t.paused),C(t.shots),H(!0),F(!1),p.refresh()}catch(e){R(s("project.unreachable"))}finally{M.current=!1,P(!1)}}return(0,n.jsxs)("form",{onSubmit:U,"aria-busy":S,className:"mt-6 space-y-4",children:[(0,n.jsxs)(i.Zp,{as:"section","aria-labelledby":"spend-caps-title",children:[(0,n.jsx)("h2",{id:"spend-caps-title",className:"text-base font-semibold",children:s("spend.caps")}),(0,n.jsx)("p",{className:"mt-2 max-w-2xl text-xs leading-relaxed text-smoke",children:s("spend.capsHint")}),(0,n.jsx)("div",{className:"mt-4 border-b border-edge pb-4",children:(0,n.jsxs)(i.Jl,{checked:k,disabled:S,onChange:e=>{w(e.target.checked),I()},children:[s("spend.pause"),(0,n.jsx)("span",{className:"mt-1 block text-xs leading-relaxed text-smoke",children:s("spend.pauseHint")})]})}),(0,n.jsx)("ul",{className:"mt-4 space-y-4",children:t.families.map(e=>{var t;return(0,n.jsx)(b,{line:e,value:null!=(t=m[e.family])?t:"",disabled:S,onChange:t=>{f(s=>({...s,[e.family]:t})),I()}},e.family)})})]}),(0,n.jsxs)(i.Zp,{as:"section","aria-labelledby":"spend-rates-title",children:[(0,n.jsx)("h2",{id:"spend-rates-title",className:"text-base font-semibold",children:s("spend.byModel")}),(0,n.jsx)("p",{className:"mt-2 max-w-2xl text-xs leading-relaxed text-smoke",children:s("spend.rateHint")}),(0,n.jsxs)("div",{className:"mt-4",children:[(0,n.jsx)(i.D0,{label:s("spend.currency"),"aria-describedby":"spend-currency-hint",type:"text",maxLength:3,autoCapitalize:"characters",spellCheck:!1,value:g,disabled:S,onChange:e=>{N(e.target.value),I()},className:"w-24"}),(0,n.jsx)("p",{id:"spend-currency-hint",className:"mt-1 max-w-2xl text-xs leading-relaxed text-smoke",children:s("spend.currencyHint")})]}),0===t.models.length?(0,n.jsx)(i.pp,{variant:"bare",className:"mt-4",title:s("spend.monthEmpty"),children:s("spend.modelsEmptyHint")}):(0,n.jsx)("div",{className:"mt-4 overflow-x-auto",children:(0,n.jsxs)("table",{className:"w-full min-w-[40rem] text-sm",children:[(0,n.jsxs)("caption",{className:"sr-only",children:[s("spend.byModel")," \xb7 ",s("spend.month")]}),(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{className:"text-left font-mono text-[11px] text-smoke",children:[(0,n.jsx)("th",{scope:"col",className:"py-1 pr-3 font-normal",children:s("spend.model")}),(0,n.jsx)("th",{scope:"col",className:"py-1 pr-3 text-right font-normal",children:s("spend.colCalls")}),(0,n.jsx)("th",{scope:"col",className:"py-1 pr-3 text-right font-normal",children:s("spend.colIn")}),(0,n.jsx)("th",{scope:"col",className:"py-1 pr-3 text-right font-normal",children:s("spend.colOut")}),(0,n.jsx)("th",{scope:"col",className:"py-1 pr-3 text-right font-normal",children:s("spend.colUnmetered")}),(0,n.jsx)("th",{scope:"col",className:"py-1 pr-3 font-normal",children:s("spend.colRateIn")}),(0,n.jsx)("th",{scope:"col",className:"py-1 pr-3 font-normal",children:s("spend.colRateOut")}),(0,n.jsx)("th",{scope:"col",className:"py-1 text-right font-normal",children:s("spend.colCost")})]})}),(0,n.jsx)("tbody",{children:t.models.map(e=>{var t,a;let r=null!=(t=j[e.key])?t:{input:"",output:""},l=(a=h(r))?e.input/1e6*a.input+e.output/1e6*a.output:null;return(0,n.jsxs)("tr",{className:"border-t border-edge",children:[(0,n.jsx)("th",{scope:"row",className:"py-2 pr-3 text-left font-mono text-xs font-normal",children:e.key}),(0,n.jsx)("td",{className:"py-2 pr-3 text-right font-mono text-xs",children:c(e.calls,d)}),(0,n.jsx)("td",{className:"py-2 pr-3 text-right font-mono text-xs",children:c(e.input,d)}),(0,n.jsx)("td",{className:"py-2 pr-3 text-right font-mono text-xs",children:c(e.output,d)}),(0,n.jsx)("td",{className:"py-2 pr-3 text-right font-mono text-xs",children:c(e.unmetered,d)}),(0,n.jsx)("td",{className:"py-2 pr-3",children:(0,n.jsx)(i.D0,{label:s("spend.rateInLabel",{model:e.key}),hideLabel:!0,size:"sm",className:"w-24",type:"number",min:0,step:"any",inputMode:"decimal",placeholder:"—",value:r.input,disabled:S,onChange:t=>_(e.key,"input",t.target.value)})}),(0,n.jsx)("td",{className:"py-2 pr-3",children:(0,n.jsx)(i.D0,{label:s("spend.rateOutLabel",{model:e.key}),hideLabel:!0,size:"sm",className:"w-24",type:"number",min:0,step:"any",inputMode:"decimal",placeholder:"—",value:r.output,disabled:S,onChange:t=>_(e.key,"output",t.target.value)})}),(0,n.jsx)("td",{className:"py-2 text-right font-mono text-xs",children:e.calls>0&&e.unmetered===e.calls&&e.input+e.output===0?s("spend.rateUnmetered"):null===l?s("spend.rateMissing"):function(e,t,s){try{return new Intl.NumberFormat(o(s),{style:"currency",currency:t,minimumFractionDigits:2,maximumFractionDigits:4}).format(e)}catch(s){return"".concat(e.toFixed(2)," ").concat(t)}}(l,A,d)})]},e.key)})})]})})]}),(0,n.jsxs)(i.Zp,{as:"section","aria-labelledby":"spend-shots-title",children:[(0,n.jsx)("h2",{id:"spend-shots-title",className:"text-base font-semibold",children:s("spend.shots")}),(0,n.jsx)("p",{id:"spend-shots-hint",className:"mt-2 max-w-2xl text-xs leading-relaxed text-smoke",children:s("spend.shotsHint")}),(0,n.jsxs)("fieldset",{"aria-labelledby":"spend-shots-title","aria-describedby":"spend-shots-hint",className:"mt-4 flex flex-col gap-3 border-0 p-0",children:[(0,n.jsx)(y,{value:"full",chosen:O,disabled:S,label:s("spend.shotFull"),hint:s("spend.shotFullHint"),onChoose:L}),(0,n.jsx)(y,{value:"fit",chosen:O,disabled:S,label:s("spend.shotFit",{n:c(t.shotEdge,d)}),hint:s("spend.shotFitHint"),onChoose:L})]}),(0,n.jsx)("p",{className:"mt-3 max-w-2xl text-xs leading-relaxed text-smoke",children:s("spend.shotsPng")})]}),(0,n.jsxs)("div",{className:D||S||E?"sticky bottom-[calc(var(--dock-height)+env(safe-area-inset-bottom,0px)+var(--space-2))] rounded-lg border border-edge bg-surface p-3 min-[761px]:bottom-4":"py-2",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,n.jsx)(i.rA,{type:"submit",tone:"accent",busy:S,busyLabel:s("spend.saving"),children:s("spend.save")}),(0,n.jsx)("p",{role:"status","aria-live":"polite",className:"text-xs text-smoke",children:D?s("spend.dirty"):E?s("spend.saved"):""})]}),z&&(0,n.jsx)(i.lZ,{text:z,className:"mt-3"})]})]})}function y(e){let{value:t,chosen:s,disabled:a,label:r,hint:l,onChoose:i}=e,o="spend-shots-".concat(t);return(0,n.jsxs)("label",{htmlFor:o,className:"flex items-start gap-2 text-sm",children:[(0,n.jsx)("input",{id:o,type:"radio",name:"spend-shots",value:t,checked:s===t,disabled:a,onChange:()=>i(t),className:"mt-1"}),(0,n.jsxs)("span",{className:"max-w-2xl",children:[r,(0,n.jsx)("span",{className:"mt-0.5 block text-xs leading-relaxed text-smoke",children:l})]})]})}function b(e){var t,s,a,r;let{line:o,value:u,disabled:x,onChange:h}=e,f=(0,l.kj)(),y=(0,l.Ym)(),b="spend-cap-".concat(o.family),v=void 0!==o.env,g="paused"===o.source,N=0===o.cap,k=o.used>=o.cap,w="env"===o.source?f("spend.source.env",{name:o.variable}):f(m[o.source]);return(0,n.jsxs)("li",{className:"border-t border-edge pt-4 first:border-0 first:pt-0",children:[(0,n.jsxs)("div",{className:"grid gap-3 sm:grid-cols-[minmax(0,1fr)_7rem] sm:gap-x-6",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-baseline gap-2",children:[(0,n.jsx)("label",{id:"".concat(b,"-name"),htmlFor:b,className:"text-sm font-semibold",children:f(d[o.family])}),(0,n.jsx)(i.vw,{tone:g||N||k?"strong":"neutral",size:"md",children:f(g?"spend.state.paused":N?"spend.state.disabled":k?"spend.state.exhausted":"spend.state.enabled")})]}),(0,n.jsx)("p",{id:"".concat(b,"-hint"),className:"mt-1 text-xs leading-relaxed text-smoke",children:f(p[o.family])}),(0,n.jsx)("p",{className:"mt-2 font-mono text-xs text-smoke",children:f("app"===o.family?"spend.usageAttempts":"spend.usageCalls",{used:c(o.used,y),cap:c(o.cap,y)})}),(0,n.jsx)("div",{className:"mt-2 h-1 overflow-hidden rounded-full bg-raised","aria-hidden":!0,children:(0,n.jsx)("div",{className:"h-full bg-chalk",style:{width:"".concat((a=o.used,(r=o.cap)<=0?100*(a>0):Math.min(100,Math.round(a/r*100))),"%")}})}),(0,n.jsxs)("div",{className:"mt-2 flex flex-wrap items-baseline gap-2 text-xs text-smoke",children:[(0,n.jsx)(i.vw,{size:"md",children:w}),"factory"!==o.source&&(0,n.jsx)("span",{children:f("spend.factory",{n:c(o.factory,y)})})]}),(0,n.jsx)(j,{row:o})]}),(0,n.jsxs)("div",{className:"max-w-28",children:[(0,n.jsx)("span",{id:"".concat(b,"-unit"),className:"mb-1 block text-xs leading-relaxed text-smoke",children:f("app"===o.family?"spend.capAttempts":"spend.capCalls")}),(0,n.jsx)("input",{id:b,"aria-labelledby":"".concat(b,"-name ").concat(b,"-unit"),"aria-describedby":"".concat(b,"-hint").concat(v?" ".concat(b,"-env"):""),type:"number",min:0,max:1e5,step:1,inputMode:"numeric",placeholder:String(o.factory),value:v?String(o.cap):u,disabled:x||v,onChange:e=>h(e.target.value),className:"block w-full rounded border border-edge bg-surface px-2 py-1.5 font-mono text-xs disabled:opacity-50"})]})]}),v&&(0,n.jsx)("p",{id:"".concat(b,"-env"),className:"mt-2 text-xs leading-relaxed text-smoke",children:!1===o.envReadable?f("spend.envUnread",{name:o.variable,value:null!=(t=o.env)?t:"",factory:o.factory}):f("spend.envDecides",{name:o.variable,value:null!=(s=o.env)?s:""})}),"app"===o.family&&(0,n.jsx)("p",{className:"mt-2 text-xs leading-relaxed text-smoke",children:f("spend.appReservationsHint")})]})}function j(e){let{row:t}=e,s=(0,l.kj)(),a=(0,l.Ym)();if(!(t.input>0||t.output>0||t.unmetered>0||t.images>0))return null;let r=[];return t.input+t.output>0&&r.push(s("spend.tokens",{input:c(t.input,a),output:c(t.output,a)})),t.unmetered>0&&r.push(s("spend.unmetered",{n:c(t.unmetered,a)})),t.images>0&&r.push(s("spend.images",{n:c(t.images,a)})),(0,n.jsx)("p",{className:"mt-2 font-mono text-xs leading-relaxed text-smoke",children:r.join(" \xb7 ")})}},56684:(e,t,s)=>{"use strict";s.d(t,{k5:()=>d});var n=s(32165),a={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},r=n.createContext&&n.createContext(a),l=["attr","size","title"];function i(){return(i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)({}).hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e}).apply(null,arguments)}function o(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),s.push.apply(s,n)}return s}function c(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?o(Object(s),!0).forEach(function(t){var n,a,r;n=e,a=t,r=s[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var n=s.call(e,t||"default");if("object"!=typeof n)return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in n?Object.defineProperty(n,a,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[a]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):o(Object(s)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))})}return e}function d(e){return t=>n.createElement(p,i({attr:c({},e.attr)},t),function e(t){return t&&t.map((t,s)=>n.createElement(t.tag,c({key:s},t.attr),e(t.child)))}(e.child))}function p(e){var t=t=>{var s,a=e.attr,r=e.size,o=e.title,d=function(e,t){if(null==e)return{};var s,n,a=function(e,t){if(null==e)return{};var s={};for(var n in e)if(({}).hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;s[n]=e[n]}return s}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n<r.length;n++)s=r[n],-1===t.indexOf(s)&&({}).propertyIsEnumerable.call(e,s)&&(a[s]=e[s])}return a}(e,l),p=r||t.size||"1em";return t.className&&(s=t.className),e.className&&(s=(s?s+" ":"")+e.className),n.createElement("svg",i({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,a,d,{className:s,style:c(c({color:e.color||t.color},t.style),e.style),height:p,width:p,xmlns:"http://www.w3.org/2000/svg"}),o&&n.createElement("title",null,o),e.children)};return void 0!==r?n.createElement(r.Consumer,null,e=>t(e)):t(a)}},81535:(e,t,s)=>{Promise.resolve().then(s.bind(s,44653))}},e=>{e.O(0,[6587,2575,2948,1305,6823,7358],()=>e(e.s=81535)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5172],{9144:(e,t,s)=>{"use strict";s.d(t,{I18nProvider:()=>o,Ym:()=>c,Zs:()=>d,kj:()=>p});var n=s(38657),a=s(32165),r=s(2575);let l=(0,a.createContext)("en"),i=(0,a.createContext)("panoma");function o(e){let{locale:t,cli:s,children:a}=e;return(0,n.jsx)(l.Provider,{value:t,children:(0,n.jsx)(i.Provider,{value:s,children:a})})}function c(){return(0,a.useContext)(l)}function d(){return(0,a.useContext)(i)}function p(){let e=(0,a.useContext)(l),t=(0,a.useContext)(i);return(0,a.useCallback)((s,n)=>(0,r.t)(e,s,{cli:t,...n}),[e,t])}},10354:(e,t,s)=>{"use strict";var n=s(61990);s.o(n,"usePathname")&&s.d(t,{usePathname:function(){return n.usePathname}}),s.o(n,"useRouter")&&s.d(t,{useRouter:function(){return n.useRouter}}),s.o(n,"useSearchParams")&&s.d(t,{useSearchParams:function(){return n.useSearchParams}})},44653:(e,t,s)=>{"use strict";s.d(t,{SpendControls:()=>f});var n=s(38657),a=s(10354),r=s(32165),l=s(9144),i=s(52948);function o(e){return"es"===e?"es-ES":"en-US"}function c(e,t){return new Intl.NumberFormat(o(t)).format(e)}let d={read:"spend.family.read",look:"spend.family.look",memory:"spend.family.memory",ask:"spend.family.ask",rehearse:"spend.family.rehearse",episodes:"spend.family.episodes",card:"spend.family.card",app:"spend.family.app",handoff:"spend.family.handoff"},p={read:"spend.familyHint.read",look:"spend.familyHint.look",memory:"spend.familyHint.memory",ask:"spend.familyHint.ask",rehearse:"spend.familyHint.rehearse",episodes:"spend.familyHint.episodes",card:"spend.familyHint.card",app:"spend.familyHint.app",handoff:"spend.familyHint.handoff"},m={factory:"spend.source.factory",file:"spend.source.file",env:"spend.source.env",paused:"spend.source.paused"};function u(e){return Object.fromEntries(e.map(e=>[e.key,{input:e.rate?String(e.rate.input):"",output:e.rate?String(e.rate.output):""}]))}function x(e){return Object.fromEntries(e.families.map(t=>{let s=e.chosen[t.family];return[t.family,void 0===s?"":String(s)]}))}function h(e){return e&&(""!==e.input.trim()||""!==e.output.trim())?{input:Number(e.input||0),output:Number(e.output||0)}:null}function f(e){let{initial:t}=e,s=(0,l.kj)(),d=(0,l.Ym)(),p=(0,a.useRouter)(),[m,f]=(0,r.useState)(()=>x(t)),[j,v]=(0,r.useState)(()=>u(t.models)),[g,N]=(0,r.useState)(t.currency),[k,w]=(0,r.useState)(t.paused),[O,C]=(0,r.useState)(t.shots),[S,P]=(0,r.useState)(!1),[E,H]=(0,r.useState)(!1),[D,F]=(0,r.useState)(!1),[z,R]=(0,r.useState)(null),M=(0,r.useRef)(!1),A=3===g.trim().length?g.trim().toUpperCase():t.currency;function I(){F(!0),H(!1),R(null)}function _(e,t,s){v(n=>{var a;return{...n,[e]:{...null!=(a=n[e])?a:{input:"",output:""},[t]:s}}}),I()}function L(e){C(e),I()}async function U(e){if(e.preventDefault(),M.current)return;M.current=!0,P(!0),I();let n={caps:Object.fromEntries(t.families.filter(e=>void 0===e.env).map(e=>{var t;let s=(null!=(t=m[e.family])?t:"").trim();return[e.family,""===s?null:Number(s)]})),rates:{...t.rates,...Object.fromEntries(t.models.map(e=>[e.key,h(j[e.key])]))},currency:g.trim().toUpperCase(),paused:k,shots:O};try{let e=await fetch("/api/spend",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),t=await e.json().catch(()=>({}));if(!e.ok){var a;R([null!=(a=t.error)?a:s("spend.failed"),t.hint].filter(Boolean).join(" "));return}if(!Array.isArray(t.families)||!Array.isArray(t.models))return void R(s("spend.failed"));f(x(t)),v(u(t.models)),N(t.currency),w(t.paused),C(t.shots),H(!0),F(!1),p.refresh()}catch(e){R(s("project.unreachable"))}finally{M.current=!1,P(!1)}}return(0,n.jsxs)("form",{onSubmit:U,"aria-busy":S,className:"mt-6 space-y-4",children:[(0,n.jsxs)(i.Zp,{as:"section","aria-labelledby":"spend-caps-title",children:[(0,n.jsx)("h2",{id:"spend-caps-title",className:"text-base font-semibold",children:s("spend.caps")}),(0,n.jsx)("p",{className:"mt-2 max-w-2xl text-xs leading-relaxed text-smoke",children:s("spend.capsHint")}),(0,n.jsx)("div",{className:"mt-4 border-b border-edge pb-4",children:(0,n.jsxs)(i.Jl,{checked:k,disabled:S,onChange:e=>{w(e.target.checked),I()},children:[s("spend.pause"),(0,n.jsx)("span",{className:"mt-1 block text-xs leading-relaxed text-smoke",children:s("spend.pauseHint")})]})}),(0,n.jsx)("ul",{className:"mt-4 space-y-4",children:t.families.map(e=>{var t;return(0,n.jsx)(b,{line:e,value:null!=(t=m[e.family])?t:"",disabled:S,onChange:t=>{f(s=>({...s,[e.family]:t})),I()}},e.family)})})]}),(0,n.jsxs)(i.Zp,{as:"section","aria-labelledby":"spend-rates-title",children:[(0,n.jsx)("h2",{id:"spend-rates-title",className:"text-base font-semibold",children:s("spend.byModel")}),(0,n.jsx)("p",{className:"mt-2 max-w-2xl text-xs leading-relaxed text-smoke",children:s("spend.rateHint")}),(0,n.jsxs)("div",{className:"mt-4",children:[(0,n.jsx)(i.D0,{label:s("spend.currency"),"aria-describedby":"spend-currency-hint",type:"text",maxLength:3,autoCapitalize:"characters",spellCheck:!1,value:g,disabled:S,onChange:e=>{N(e.target.value),I()},className:"w-24"}),(0,n.jsx)("p",{id:"spend-currency-hint",className:"mt-1 max-w-2xl text-xs leading-relaxed text-smoke",children:s("spend.currencyHint")})]}),0===t.models.length?(0,n.jsx)(i.pp,{variant:"bare",className:"mt-4",title:s("spend.monthEmpty"),children:s("spend.modelsEmptyHint")}):(0,n.jsx)("div",{className:"mt-4 overflow-x-auto",children:(0,n.jsxs)("table",{className:"w-full min-w-[40rem] text-sm",children:[(0,n.jsxs)("caption",{className:"sr-only",children:[s("spend.byModel")," \xb7 ",s("spend.month")]}),(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{className:"text-left font-mono text-[11px] text-smoke",children:[(0,n.jsx)("th",{scope:"col",className:"py-1 pr-3 font-normal",children:s("spend.model")}),(0,n.jsx)("th",{scope:"col",className:"py-1 pr-3 text-right font-normal",children:s("spend.colCalls")}),(0,n.jsx)("th",{scope:"col",className:"py-1 pr-3 text-right font-normal",children:s("spend.colIn")}),(0,n.jsx)("th",{scope:"col",className:"py-1 pr-3 text-right font-normal",children:s("spend.colOut")}),(0,n.jsx)("th",{scope:"col",className:"py-1 pr-3 text-right font-normal",children:s("spend.colUnmetered")}),(0,n.jsx)("th",{scope:"col",className:"py-1 pr-3 font-normal",children:s("spend.colRateIn")}),(0,n.jsx)("th",{scope:"col",className:"py-1 pr-3 font-normal",children:s("spend.colRateOut")}),(0,n.jsx)("th",{scope:"col",className:"py-1 text-right font-normal",children:s("spend.colCost")})]})}),(0,n.jsx)("tbody",{children:t.models.map(e=>{var t,a;let r=null!=(t=j[e.key])?t:{input:"",output:""},l=(a=h(r))?e.input/1e6*a.input+e.output/1e6*a.output:null;return(0,n.jsxs)("tr",{className:"border-t border-edge",children:[(0,n.jsx)("th",{scope:"row",className:"py-2 pr-3 text-left font-mono text-xs font-normal",children:e.key}),(0,n.jsx)("td",{className:"py-2 pr-3 text-right font-mono text-xs",children:c(e.calls,d)}),(0,n.jsx)("td",{className:"py-2 pr-3 text-right font-mono text-xs",children:c(e.input,d)}),(0,n.jsx)("td",{className:"py-2 pr-3 text-right font-mono text-xs",children:c(e.output,d)}),(0,n.jsx)("td",{className:"py-2 pr-3 text-right font-mono text-xs",children:c(e.unmetered,d)}),(0,n.jsx)("td",{className:"py-2 pr-3",children:(0,n.jsx)(i.D0,{label:s("spend.rateInLabel",{model:e.key}),hideLabel:!0,size:"sm",className:"w-24",type:"number",min:0,step:"any",inputMode:"decimal",placeholder:"—",value:r.input,disabled:S,onChange:t=>_(e.key,"input",t.target.value)})}),(0,n.jsx)("td",{className:"py-2 pr-3",children:(0,n.jsx)(i.D0,{label:s("spend.rateOutLabel",{model:e.key}),hideLabel:!0,size:"sm",className:"w-24",type:"number",min:0,step:"any",inputMode:"decimal",placeholder:"—",value:r.output,disabled:S,onChange:t=>_(e.key,"output",t.target.value)})}),(0,n.jsx)("td",{className:"py-2 text-right font-mono text-xs",children:e.calls>0&&e.unmetered===e.calls&&e.input+e.output===0?s("spend.rateUnmetered"):null===l?s("spend.rateMissing"):function(e,t,s){try{return new Intl.NumberFormat(o(s),{style:"currency",currency:t,minimumFractionDigits:2,maximumFractionDigits:4}).format(e)}catch(s){return"".concat(e.toFixed(2)," ").concat(t)}}(l,A,d)})]},e.key)})})]})})]}),(0,n.jsxs)(i.Zp,{as:"section","aria-labelledby":"spend-shots-title",children:[(0,n.jsx)("h2",{id:"spend-shots-title",className:"text-base font-semibold",children:s("spend.shots")}),(0,n.jsx)("p",{id:"spend-shots-hint",className:"mt-2 max-w-2xl text-xs leading-relaxed text-smoke",children:s("spend.shotsHint")}),(0,n.jsxs)("fieldset",{"aria-labelledby":"spend-shots-title","aria-describedby":"spend-shots-hint",className:"mt-4 flex flex-col gap-3 border-0 p-0",children:[(0,n.jsx)(y,{value:"full",chosen:O,disabled:S,label:s("spend.shotFull"),hint:s("spend.shotFullHint"),onChoose:L}),(0,n.jsx)(y,{value:"fit",chosen:O,disabled:S,label:s("spend.shotFit",{n:c(t.shotEdge,d)}),hint:s("spend.shotFitHint"),onChoose:L})]}),(0,n.jsx)("p",{className:"mt-3 max-w-2xl text-xs leading-relaxed text-smoke",children:s("spend.shotsPng")})]}),(0,n.jsxs)("div",{className:D||S||E?"sticky bottom-[calc(var(--dock-height)+env(safe-area-inset-bottom,0px)+var(--space-2))] rounded-lg border border-edge bg-surface p-3 min-[761px]:bottom-4":"py-2",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,n.jsx)(i.rA,{type:"submit",tone:"accent",busy:S,busyLabel:s("spend.saving"),children:s("spend.save")}),(0,n.jsx)("p",{role:"status","aria-live":"polite",className:"text-xs text-smoke",children:D?s("spend.dirty"):E?s("spend.saved"):""})]}),z&&(0,n.jsx)(i.lZ,{text:z,className:"mt-3"})]})]})}function y(e){let{value:t,chosen:s,disabled:a,label:r,hint:l,onChoose:i}=e,o="spend-shots-".concat(t);return(0,n.jsxs)("label",{htmlFor:o,className:"flex items-start gap-2 text-sm",children:[(0,n.jsx)("input",{id:o,type:"radio",name:"spend-shots",value:t,checked:s===t,disabled:a,onChange:()=>i(t),className:"mt-1"}),(0,n.jsxs)("span",{className:"max-w-2xl",children:[r,(0,n.jsx)("span",{className:"mt-0.5 block text-xs leading-relaxed text-smoke",children:l})]})]})}function b(e){var t,s,a,r;let{line:o,value:u,disabled:x,onChange:h}=e,f=(0,l.kj)(),y=(0,l.Ym)(),b="spend-cap-".concat(o.family),v=void 0!==o.env,g="paused"===o.source,N=0===o.cap,k=o.used>=o.cap,w="env"===o.source?f("spend.source.env",{name:o.variable}):f(m[o.source]);return(0,n.jsxs)("li",{className:"border-t border-edge pt-4 first:border-0 first:pt-0",children:[(0,n.jsxs)("div",{className:"grid gap-3 sm:grid-cols-[minmax(0,1fr)_7rem] sm:gap-x-6",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-baseline gap-2",children:[(0,n.jsx)("label",{id:"".concat(b,"-name"),htmlFor:b,className:"text-sm font-semibold",children:f(d[o.family])}),(0,n.jsx)(i.vw,{tone:g||N||k?"strong":"neutral",size:"md",children:f(g?"spend.state.paused":N?"spend.state.disabled":k?"spend.state.exhausted":"spend.state.enabled")})]}),(0,n.jsx)("p",{id:"".concat(b,"-hint"),className:"mt-1 text-xs leading-relaxed text-smoke",children:f(p[o.family])}),(0,n.jsx)("p",{className:"mt-2 font-mono text-xs text-smoke",children:f("app"===o.family?"spend.usageAttempts":"spend.usageCalls",{used:c(o.used,y),cap:c(o.cap,y)})}),(0,n.jsx)("div",{className:"mt-2 h-1 overflow-hidden rounded-full bg-raised","aria-hidden":!0,children:(0,n.jsx)("div",{className:"h-full bg-chalk",style:{width:"".concat((a=o.used,(r=o.cap)<=0?100*(a>0):Math.min(100,Math.round(a/r*100))),"%")}})}),(0,n.jsxs)("div",{className:"mt-2 flex flex-wrap items-baseline gap-2 text-xs text-smoke",children:[(0,n.jsx)(i.vw,{size:"md",children:w}),"factory"!==o.source&&(0,n.jsx)("span",{children:f("spend.factory",{n:c(o.factory,y)})})]}),(0,n.jsx)(j,{row:o})]}),(0,n.jsxs)("div",{className:"max-w-28",children:[(0,n.jsx)("span",{id:"".concat(b,"-unit"),className:"mb-1 block text-xs leading-relaxed text-smoke",children:f("app"===o.family?"spend.capAttempts":"spend.capCalls")}),(0,n.jsx)("input",{id:b,"aria-labelledby":"".concat(b,"-name ").concat(b,"-unit"),"aria-describedby":"".concat(b,"-hint").concat(v?" ".concat(b,"-env"):""),type:"number",min:0,max:1e5,step:1,inputMode:"numeric",placeholder:String(o.factory),value:v?String(o.cap):u,disabled:x||v,onChange:e=>h(e.target.value),className:"block w-full rounded border border-edge bg-surface px-2 py-1.5 font-mono text-xs disabled:opacity-50"})]})]}),v&&(0,n.jsx)("p",{id:"".concat(b,"-env"),className:"mt-2 text-xs leading-relaxed text-smoke",children:!1===o.envReadable?f("spend.envUnread",{name:o.variable,value:null!=(t=o.env)?t:"",factory:o.factory}):f("spend.envDecides",{name:o.variable,value:null!=(s=o.env)?s:""})}),"app"===o.family&&(0,n.jsx)("p",{className:"mt-2 text-xs leading-relaxed text-smoke",children:f("spend.appReservationsHint")})]})}function j(e){let{row:t}=e,s=(0,l.kj)(),a=(0,l.Ym)();if(!(t.input>0||t.output>0||t.unmetered>0||t.images>0))return null;let r=[];return t.input+t.output>0&&r.push(s("spend.tokens",{input:c(t.input,a),output:c(t.output,a)})),t.unmetered>0&&r.push(s("spend.unmetered",{n:c(t.unmetered,a)})),t.images>0&&r.push(s("spend.images",{n:c(t.images,a)})),(0,n.jsx)("p",{className:"mt-2 font-mono text-xs leading-relaxed text-smoke",children:r.join(" \xb7 ")})}},56684:(e,t,s)=>{"use strict";s.d(t,{k5:()=>d});var n=s(32165),a={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},r=n.createContext&&n.createContext(a),l=["attr","size","title"];function i(){return(i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)({}).hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e}).apply(null,arguments)}function o(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),s.push.apply(s,n)}return s}function c(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?o(Object(s),!0).forEach(function(t){var n,a,r;n=e,a=t,r=s[t],(a=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var n=s.call(e,t||"default");if("object"!=typeof n)return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(a))in n?Object.defineProperty(n,a,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[a]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):o(Object(s)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))})}return e}function d(e){return t=>n.createElement(p,i({attr:c({},e.attr)},t),function e(t){return t&&t.map((t,s)=>n.createElement(t.tag,c({key:s},t.attr),e(t.child)))}(e.child))}function p(e){var t=t=>{var s,a=e.attr,r=e.size,o=e.title,d=function(e,t){if(null==e)return{};var s,n,a=function(e,t){if(null==e)return{};var s={};for(var n in e)if(({}).hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;s[n]=e[n]}return s}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n<r.length;n++)s=r[n],-1===t.indexOf(s)&&({}).propertyIsEnumerable.call(e,s)&&(a[s]=e[s])}return a}(e,l),p=r||t.size||"1em";return t.className&&(s=t.className),e.className&&(s=(s?s+" ":"")+e.className),n.createElement("svg",i({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,a,d,{className:s,style:c(c({color:e.color||t.color},t.style),e.style),height:p,width:p,xmlns:"http://www.w3.org/2000/svg"}),o&&n.createElement("title",null,o),e.children)};return void 0!==r?n.createElement(r.Consumer,null,e=>t(e)):t(a)}},98617:(e,t,s)=>{Promise.resolve().then(s.bind(s,44653))}},e=>{e.O(0,[6587,2575,2948,1305,6823,7358],()=>e(e.s=98617)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2168],{9144:(e,t,n)=>{"use strict";n.d(t,{I18nProvider:()=>i,Ym:()=>c,Zs:()=>u,kj:()=>d});var l=n(38657),o=n(32165),a=n(2575);let r=(0,o.createContext)("en"),s=(0,o.createContext)("panoma");function i(e){let{locale:t,cli:n,children:o}=e;return(0,l.jsx)(r.Provider,{value:t,children:(0,l.jsx)(s.Provider,{value:n,children:o})})}function c(){return(0,o.useContext)(r)}function u(){return(0,o.useContext)(s)}function d(){let e=(0,o.useContext)(r),t=(0,o.useContext)(s);return(0,o.useCallback)((n,l)=>(0,a.t)(e,n,{cli:t,...l}),[e,t])}},10354:(e,t,n)=>{"use strict";var l=n(61990);n.o(l,"usePathname")&&n.d(t,{usePathname:function(){return l.usePathname}}),n.o(l,"useRouter")&&n.d(t,{useRouter:function(){return l.useRouter}}),n.o(l,"useSearchParams")&&n.d(t,{useSearchParams:function(){return l.useSearchParams}})},31821:(e,t,n)=>{"use strict";let l;n.d(t,{q:()=>a});var o=n(32165);function a(){let[e,t]=(0,o.useState)({available:!1,agent:null});return(0,o.useEffect)(()=>{null!=l||(l=fetch("/api/assignments/launch").then(e=>e.json()).catch(()=>({available:!1,agent:null})));let e=!0;return l.then(n=>{e&&t(n)}),()=>{e=!1}},[]),e}},38444:(e,t,n)=>{"use strict";n.d(t,{LookFindings:()=>f,TwinLook:()=>m});var l=n(38657),o=n(32165),a=n(10354),r=n(9144),s=n(31821),i=n(52948);let c=["image/png","image/jpeg","image/webp","image/gif"],u={format:"look.whyFormat",variant:"look.whyVariant",already:"look.whyAlready",broken:"look.whyBroken",huge:"look.whyHuge"};function d(e,t){var n,l,o;return void 0===t||"fit"!==t.policy?null:void 0===t.fitted?e("look.fitAsked",{edge:t.maxEdge}):t.fitted?e("look.fitSent",{size:"".concat(t.width,"\xd7").concat(t.height),from:"".concat(null==(n=t.from)?void 0:n.width,"\xd7").concat(null==(l=t.from)?void 0:l.height)}):e("look.fitWhole",{why:e(u[null!=(o=t.why)?o:"broken"])})}function m(e){var t,n;let{boards:s,projects:u,maxBytes:m,shots:f}=e,h=(0,r.kj)(),g=(0,r.Ym)(),b=(0,a.useRouter)(),k=(0,o.useRef)(null),[j,y]=(0,o.useState)(null),[v,w]=(0,o.useState)(null),[N,O]=(0,o.useState)(null),[S,C]=(0,o.useState)(null!=(n=null==(t=u[0])?void 0:t.slug)?n:"");async function P(e,t,n){y(t),w(null),O(null);try{var l,o,a,r;let t=await p({...(r=e,Object.fromEntries(Object.entries(r).filter(e=>{let[t]=e;return"image"!==t}))),dryRun:!0});if(t.error)return void w(t.error);let s=void 0!==t.width&&void 0!==t.height?" \xb7 ".concat(t.width,"\xd7").concat(t.height):"",c=d(h,t.sent);w(h("look.estimate",{statements:null!=(l=t.statements)?l:0,tokens:null!=(o=t.estimatedTokens)?o:0,size:(0,i.z3)(null!=(a=t.imageBytes)?a:0)})+s+(null===c?"":" \xb7 ".concat(c)));let u=await p({...e,dryRun:!1});if(u.error)return void w(u.error);O({subject:n,receipt:u}),w(null),b.refresh()}catch(e){w(h("project.unreachable"))}finally{y(null)}}async function E(e){if(!c.includes(e.type))return void w(h("look.badType"));if(e.size>m)return void w(h("look.tooBig",{size:(0,i.z3)(e.size),cap:(0,i.z3)(m)}));let t=function(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}(new Uint8Array(await e.arrayBuffer()));await P({slug:S,image:t,mediaType:e.type,imageBytes:e.size},"upload",e.name)}return(0,l.jsxs)("section",{className:"mt-8 flex flex-col gap-6",children:[(0,l.jsx)("p",{className:"font-mono text-xs text-idle",children:h("look.notRedacted")}),0===s.length?(0,l.jsxs)(i.Zp,{tone:"plain",children:[(0,l.jsx)("p",{className:"eyebrow",children:h("look.inboxTitle")}),(0,l.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed",children:h("look.noInbox")}),(0,l.jsx)("p",{className:"mt-1 max-w-2xl font-mono text-xs text-smoke",children:h("look.noInboxHint")})]}):s.map(e=>(0,l.jsxs)(i.Zp,{tone:"plain",children:[(0,l.jsx)("p",{className:"eyebrow",children:h("look.inboxOf",{project:e.name})}),(0,l.jsx)("p",{className:"mt-1 font-mono text-xs text-faint",children:e.dir}),0===e.shots.length?(0,l.jsx)("p",{className:"mt-3 max-w-2xl text-sm leading-relaxed text-smoke",children:h("look.inboxEmpty")}):(0,l.jsx)("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:e.shots.map(t=>{let n="".concat(e.slug,"/").concat(t.name);return(0,l.jsxs)("div",{className:"flex gap-3 rounded border border-edge p-2",children:[(0,l.jsx)("img",{src:"/api/twin/shot?slug=".concat(encodeURIComponent(e.slug),"&name=").concat(encodeURIComponent(t.name)),alt:t.name,className:"h-20 w-28 shrink-0 rounded border border-edge bg-raised object-cover"}),(0,l.jsxs)("div",{className:"flex min-w-0 flex-col gap-1",children:[(0,l.jsx)("span",{className:"truncate font-mono text-xs",children:t.name}),(0,l.jsxs)("span",{className:"font-mono text-xs text-faint",children:[(0,i.z3)(t.bytes)," \xb7 ",new Date(t.at).toLocaleString(g)]}),null!==t.findings&&(0,l.jsx)("span",{className:"font-mono text-xs text-smoke",children:0===t.findings?h("look.lookedClean"):h("look.looked",{n:t.findings})}),(0,l.jsx)(i.rA,{tone:"plain",type:"button",onClick:()=>P({slug:e.slug,shot:t.name},n,t.name),busy:j===n,busyLabel:h("look.looking"),disabled:null!==j,className:"mt-auto self-start",children:h(null===t.findings?"look.button":"look.buttonAgain")})]})]},n)})}),e.skipped>0&&(0,l.jsx)("p",{className:"mt-2 font-mono text-xs text-faint",children:h("look.inboxSkipped",{n:e.skipped})})]},e.slug)),u.length>0&&(0,l.jsxs)(i.Zp,{tone:"plain",children:[(0,l.jsx)("p",{className:"eyebrow",children:h("look.uploadTitle")}),(0,l.jsx)("p",{className:"mt-1 max-w-2xl text-sm leading-relaxed text-smoke",children:h("look.uploadHint")}),(0,l.jsx)("p",{className:"mt-1 font-mono text-xs text-faint",children:h("fit"===f?"look.uploadCapFit":"look.uploadCapFull",{cap:(0,i.z3)(m)})}),(0,l.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,l.jsx)("select",{value:S,onChange:e=>C(e.target.value),"aria-label":h("look.uploadTarget"),className:"rounded border border-edge bg-transparent px-2 py-1 font-mono text-xs",children:u.map(e=>(0,l.jsx)("option",{value:e.slug,children:e.name},e.slug))}),(0,l.jsx)("input",{ref:k,type:"file",accept:c.join(","),className:"hidden",onChange:e=>{var t;let n=null==(t=e.target.files)?void 0:t[0];e.target.value="",n&&E(n)}}),(0,l.jsx)(i.rA,{tone:"plain",type:"button",onClick:()=>{var e;return null==(e=k.current)?void 0:e.click()},busy:"upload"===j,busyLabel:h("look.looking"),disabled:null!==j||""===S,children:h("look.uploadPick")})]})]}),v&&(0,l.jsx)("p",{className:"font-mono text-xs text-smoke",children:v}),N&&(0,l.jsx)(x,{subject:N.subject,receipt:N.receipt})]})}function x(e){var t,n,o,a,s;let{subject:c,receipt:u}=e,m=(0,r.kj)(),x=null!=(t=u.findings)?t:[],p=d(m,u.sent);return(0,l.jsxs)(i.Zp,{tone:"plain",children:[(0,l.jsx)("p",{className:"eyebrow",children:m("look.verdictOf",{subject:c})}),u.unreadable?(0,l.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-idle",children:m("look.unreadable")}):0===x.length?(0,l.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed",children:m("look.clean")}):(0,l.jsx)(f,{lookId:null!=(n=u.lookId)?n:"",findings:x,assigned:{}}),(0,l.jsxs)("p",{className:"mt-3 font-mono text-xs text-faint",children:[m("look.measured",{statements:null!=(o=u.statements)?o:0}),u.model?" \xb7 ".concat(u.model):""]}),null!==p&&(0,l.jsx)("p",{className:"mt-1 font-mono text-xs text-faint",children:p}),(null!=(a=u.dropped)?a:0)>0&&(0,l.jsx)("p",{className:"mt-1 font-mono text-xs text-faint",children:m("look.dropped",{n:null!=(s=u.dropped)?s:0})})]})}function f(e){let{lookId:t,findings:n,assigned:c,launched:u=[],discarded:d=[]}=e,m=(0,r.kj)(),x=(0,a.useRouter)(),f=(0,s.q)(),[p,h]=(0,o.useState)(c),[g,b]=(0,o.useState)(()=>new Set(u)),[k,j]=(0,o.useState)(()=>new Set(d)),[y,v]=(0,o.useState)(null),[w,N]=(0,o.useState)({});function O(e,t){N(n=>({...n,[e]:t}))}async function S(e){v(e);try{var n,l,o;let a=await fetch("/api/twin/assign",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lookId:t,finding:e})}),r=await a.json();if(!a.ok){r.id&&h(t=>({...t,[e]:r.id})),O(e,null!=(n=r.error)?n:String(a.status));return}r.id&&h(t=>({...t,[e]:r.id})),j(t=>{let n=new Set(t);return n.delete(e),n}),O(e,m("look.assignDone",{project:null!=(l=r.project)?l:"",title:null!=(o=r.title)?o:""})),x.refresh()}catch(t){O(e,m("project.unreachable"))}finally{v(null)}}async function C(e){v(e);try{let l=await fetch("/api/twin/assign",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lookId:t,finding:e,decision:"discard"})}),o=await l.json();if(!l.ok){var n;O(e,null!=(n=o.error)?n:String(l.status));return}j(t=>new Set(t).add(e)),h(t=>{let n={...t};return delete n[e],n}),O(e,m("look.dismissDone")),x.refresh()}catch(t){O(e,m("project.unreachable"))}finally{v(null)}}async function P(e,t){v(e);try{var n,l;let o=await fetch("/api/assignments/launch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:t})}),a=await o.json();o.ok&&b(e=>new Set(e).add(t)),O(e,o.ok?m("look.assignLaunched",{agent:null!=(n=a.agent)?n:""}):null!=(l=a.error)?l:String(o.status))}catch(t){O(e,m("project.unreachable"))}finally{v(null)}}return(0,l.jsx)("ol",{className:"mt-3 flex flex-col gap-4",role:"list",children:n.map((e,n)=>{let o=p[n],a=k.has(n);return(0,l.jsxs)("li",{className:"flex flex-col gap-1",children:[(0,l.jsx)("p",{className:"max-w-2xl text-sm leading-relaxed",children:e.what}),(0,l.jsx)("p",{className:"max-w-2xl font-mono text-xs text-faint",children:e.where}),(0,l.jsx)("p",{className:"max-w-2xl text-sm leading-relaxed text-smoke",children:m("look.fix",{fix:e.fix})}),e.cites.map(e=>(0,l.jsx)("p",{className:"max-w-2xl font-mono text-xs text-faint",children:m("look.against",{statement:e})},e)),""!==t&&(0,l.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(0,l.jsx)(i.rA,{tone:"plain",type:"button",onClick:()=>void S(n),busy:y===n&&void 0===o,busyLabel:m("look.assigning"),disabled:null!==y||void 0!==o,children:void 0!==o?m("look.assigned"):m("look.assignButton")}),!a&&(0,l.jsx)(i.rA,{tone:"quiet",type:"button",onClick:()=>void C(n),disabled:null!==y,children:m("look.dismissButton")}),a&&(0,l.jsx)("span",{className:"font-mono text-xs text-faint",children:m("look.dismissed")}),void 0!==o&&f.available&&(0,l.jsx)(i.rA,{tone:"accent",type:"button",onClick:()=>void P(n,o),disabled:null!==y,children:m(g.has(o)?"look.assignAgain":"look.assignNow")})]}),w[n]&&(0,l.jsx)("p",{className:"max-w-2xl font-mono text-xs text-smoke",children:w[n]})]},n)})})}async function p(e){var t;let n=await fetch("/api/twin/look",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),l=await n.json();return n.ok?l:{...l,error:null!=(t=l.error)?t:String(n.status)}}},56684:(e,t,n)=>{"use strict";n.d(t,{k5:()=>u});var l=n(32165),o={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},a=l.createContext&&l.createContext(o),r=["attr","size","title"];function s(){return(s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var l in n)({}).hasOwnProperty.call(n,l)&&(e[l]=n[l])}return e}).apply(null,arguments)}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,l)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach(function(t){var l,o,a;l=e,o=t,a=n[t],(o=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var l=n.call(e,t||"default");if("object"!=typeof l)return l;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(o))in l?Object.defineProperty(l,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):l[o]=a}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function u(e){return t=>l.createElement(d,s({attr:c({},e.attr)},t),function e(t){return t&&t.map((t,n)=>l.createElement(t.tag,c({key:n},t.attr),e(t.child)))}(e.child))}function d(e){var t=t=>{var n,o=e.attr,a=e.size,i=e.title,u=function(e,t){if(null==e)return{};var n,l,o=function(e,t){if(null==e)return{};var n={};for(var l in e)if(({}).hasOwnProperty.call(e,l)){if(-1!==t.indexOf(l))continue;n[l]=e[l]}return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(l=0;l<a.length;l++)n=a[l],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,r),d=a||t.size||"1em";return t.className&&(n=t.className),e.className&&(n=(n?n+" ":"")+e.className),l.createElement("svg",s({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,o,u,{className:n,style:c(c({color:e.color||t.color},t.style),e.style),height:d,width:d,xmlns:"http://www.w3.org/2000/svg"}),i&&l.createElement("title",null,i),e.children)};return void 0!==a?l.createElement(a.Consumer,null,e=>t(e)):t(o)}},94254:(e,t,n)=>{Promise.resolve().then(n.bind(n,38444))}},e=>{e.O(0,[6587,2575,2948,1305,6823,7358],()=>e(e.s=94254)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2168],{9144:(e,t,n)=>{"use strict";n.d(t,{I18nProvider:()=>i,Ym:()=>c,Zs:()=>u,kj:()=>d});var l=n(38657),o=n(32165),a=n(2575);let r=(0,o.createContext)("en"),s=(0,o.createContext)("panoma");function i(e){let{locale:t,cli:n,children:o}=e;return(0,l.jsx)(r.Provider,{value:t,children:(0,l.jsx)(s.Provider,{value:n,children:o})})}function c(){return(0,o.useContext)(r)}function u(){return(0,o.useContext)(s)}function d(){let e=(0,o.useContext)(r),t=(0,o.useContext)(s);return(0,o.useCallback)((n,l)=>(0,a.t)(e,n,{cli:t,...l}),[e,t])}},10354:(e,t,n)=>{"use strict";var l=n(61990);n.o(l,"usePathname")&&n.d(t,{usePathname:function(){return l.usePathname}}),n.o(l,"useRouter")&&n.d(t,{useRouter:function(){return l.useRouter}}),n.o(l,"useSearchParams")&&n.d(t,{useSearchParams:function(){return l.useSearchParams}})},31821:(e,t,n)=>{"use strict";let l;n.d(t,{q:()=>a});var o=n(32165);function a(){let[e,t]=(0,o.useState)({available:!1,agent:null});return(0,o.useEffect)(()=>{null!=l||(l=fetch("/api/assignments/launch").then(e=>e.json()).catch(()=>({available:!1,agent:null})));let e=!0;return l.then(n=>{e&&t(n)}),()=>{e=!1}},[]),e}},38444:(e,t,n)=>{"use strict";n.d(t,{LookFindings:()=>f,TwinLook:()=>m});var l=n(38657),o=n(32165),a=n(10354),r=n(9144),s=n(31821),i=n(52948);let c=["image/png","image/jpeg","image/webp","image/gif"],u={format:"look.whyFormat",variant:"look.whyVariant",already:"look.whyAlready",broken:"look.whyBroken",huge:"look.whyHuge"};function d(e,t){var n,l,o;return void 0===t||"fit"!==t.policy?null:void 0===t.fitted?e("look.fitAsked",{edge:t.maxEdge}):t.fitted?e("look.fitSent",{size:"".concat(t.width,"\xd7").concat(t.height),from:"".concat(null==(n=t.from)?void 0:n.width,"\xd7").concat(null==(l=t.from)?void 0:l.height)}):e("look.fitWhole",{why:e(u[null!=(o=t.why)?o:"broken"])})}function m(e){var t,n;let{boards:s,projects:u,maxBytes:m,shots:f}=e,h=(0,r.kj)(),g=(0,r.Ym)(),b=(0,a.useRouter)(),k=(0,o.useRef)(null),[j,y]=(0,o.useState)(null),[v,w]=(0,o.useState)(null),[N,O]=(0,o.useState)(null),[S,C]=(0,o.useState)(null!=(n=null==(t=u[0])?void 0:t.slug)?n:"");async function P(e,t,n){y(t),w(null),O(null);try{var l,o,a,r;let t=await p({...(r=e,Object.fromEntries(Object.entries(r).filter(e=>{let[t]=e;return"image"!==t}))),dryRun:!0});if(t.error)return void w(t.error);let s=void 0!==t.width&&void 0!==t.height?" \xb7 ".concat(t.width,"\xd7").concat(t.height):"",c=d(h,t.sent);w(h("look.estimate",{statements:null!=(l=t.statements)?l:0,tokens:null!=(o=t.estimatedTokens)?o:0,size:(0,i.z3)(null!=(a=t.imageBytes)?a:0)})+s+(null===c?"":" \xb7 ".concat(c)));let u=await p({...e,dryRun:!1});if(u.error)return void w(u.error);O({subject:n,receipt:u}),w(null),b.refresh()}catch(e){w(h("project.unreachable"))}finally{y(null)}}async function E(e){if(!c.includes(e.type))return void w(h("look.badType"));if(e.size>m)return void w(h("look.tooBig",{size:(0,i.z3)(e.size),cap:(0,i.z3)(m)}));let t=function(e){let t="";for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)}(new Uint8Array(await e.arrayBuffer()));await P({slug:S,image:t,mediaType:e.type,imageBytes:e.size},"upload",e.name)}return(0,l.jsxs)("section",{className:"mt-8 flex flex-col gap-6",children:[(0,l.jsx)("p",{className:"font-mono text-xs text-idle",children:h("look.notRedacted")}),0===s.length?(0,l.jsxs)(i.Zp,{tone:"plain",children:[(0,l.jsx)("p",{className:"eyebrow",children:h("look.inboxTitle")}),(0,l.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed",children:h("look.noInbox")}),(0,l.jsx)("p",{className:"mt-1 max-w-2xl font-mono text-xs text-smoke",children:h("look.noInboxHint")})]}):s.map(e=>(0,l.jsxs)(i.Zp,{tone:"plain",children:[(0,l.jsx)("p",{className:"eyebrow",children:h("look.inboxOf",{project:e.name})}),(0,l.jsx)("p",{className:"mt-1 font-mono text-xs text-faint",children:e.dir}),0===e.shots.length?(0,l.jsx)("p",{className:"mt-3 max-w-2xl text-sm leading-relaxed text-smoke",children:h("look.inboxEmpty")}):(0,l.jsx)("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:e.shots.map(t=>{let n="".concat(e.slug,"/").concat(t.name);return(0,l.jsxs)("div",{className:"flex gap-3 rounded border border-edge p-2",children:[(0,l.jsx)("img",{src:"/api/twin/shot?slug=".concat(encodeURIComponent(e.slug),"&name=").concat(encodeURIComponent(t.name)),alt:t.name,className:"h-20 w-28 shrink-0 rounded border border-edge bg-raised object-cover"}),(0,l.jsxs)("div",{className:"flex min-w-0 flex-col gap-1",children:[(0,l.jsx)("span",{className:"truncate font-mono text-xs",children:t.name}),(0,l.jsxs)("span",{className:"font-mono text-xs text-faint",children:[(0,i.z3)(t.bytes)," \xb7 ",new Date(t.at).toLocaleString(g)]}),null!==t.findings&&(0,l.jsx)("span",{className:"font-mono text-xs text-smoke",children:0===t.findings?h("look.lookedClean"):h("look.looked",{n:t.findings})}),(0,l.jsx)(i.rA,{tone:"plain",type:"button",onClick:()=>P({slug:e.slug,shot:t.name},n,t.name),busy:j===n,busyLabel:h("look.looking"),disabled:null!==j,className:"mt-auto self-start",children:h(null===t.findings?"look.button":"look.buttonAgain")})]})]},n)})}),e.skipped>0&&(0,l.jsx)("p",{className:"mt-2 font-mono text-xs text-faint",children:h("look.inboxSkipped",{n:e.skipped})})]},e.slug)),u.length>0&&(0,l.jsxs)(i.Zp,{tone:"plain",children:[(0,l.jsx)("p",{className:"eyebrow",children:h("look.uploadTitle")}),(0,l.jsx)("p",{className:"mt-1 max-w-2xl text-sm leading-relaxed text-smoke",children:h("look.uploadHint")}),(0,l.jsx)("p",{className:"mt-1 font-mono text-xs text-faint",children:h("fit"===f?"look.uploadCapFit":"look.uploadCapFull",{cap:(0,i.z3)(m)})}),(0,l.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,l.jsx)("select",{value:S,onChange:e=>C(e.target.value),"aria-label":h("look.uploadTarget"),className:"rounded border border-edge bg-transparent px-2 py-1 font-mono text-xs",children:u.map(e=>(0,l.jsx)("option",{value:e.slug,children:e.name},e.slug))}),(0,l.jsx)("input",{ref:k,type:"file",accept:c.join(","),className:"hidden",onChange:e=>{var t;let n=null==(t=e.target.files)?void 0:t[0];e.target.value="",n&&E(n)}}),(0,l.jsx)(i.rA,{tone:"plain",type:"button",onClick:()=>{var e;return null==(e=k.current)?void 0:e.click()},busy:"upload"===j,busyLabel:h("look.looking"),disabled:null!==j||""===S,children:h("look.uploadPick")})]})]}),v&&(0,l.jsx)("p",{className:"font-mono text-xs text-smoke",children:v}),N&&(0,l.jsx)(x,{subject:N.subject,receipt:N.receipt})]})}function x(e){var t,n,o,a,s;let{subject:c,receipt:u}=e,m=(0,r.kj)(),x=null!=(t=u.findings)?t:[],p=d(m,u.sent);return(0,l.jsxs)(i.Zp,{tone:"plain",children:[(0,l.jsx)("p",{className:"eyebrow",children:m("look.verdictOf",{subject:c})}),u.unreadable?(0,l.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-idle",children:m("look.unreadable")}):0===x.length?(0,l.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed",children:m("look.clean")}):(0,l.jsx)(f,{lookId:null!=(n=u.lookId)?n:"",findings:x,assigned:{}}),(0,l.jsxs)("p",{className:"mt-3 font-mono text-xs text-faint",children:[m("look.measured",{statements:null!=(o=u.statements)?o:0}),u.model?" \xb7 ".concat(u.model):""]}),null!==p&&(0,l.jsx)("p",{className:"mt-1 font-mono text-xs text-faint",children:p}),(null!=(a=u.dropped)?a:0)>0&&(0,l.jsx)("p",{className:"mt-1 font-mono text-xs text-faint",children:m("look.dropped",{n:null!=(s=u.dropped)?s:0})})]})}function f(e){let{lookId:t,findings:n,assigned:c,launched:u=[],discarded:d=[]}=e,m=(0,r.kj)(),x=(0,a.useRouter)(),f=(0,s.q)(),[p,h]=(0,o.useState)(c),[g,b]=(0,o.useState)(()=>new Set(u)),[k,j]=(0,o.useState)(()=>new Set(d)),[y,v]=(0,o.useState)(null),[w,N]=(0,o.useState)({});function O(e,t){N(n=>({...n,[e]:t}))}async function S(e){v(e);try{var n,l,o;let a=await fetch("/api/twin/assign",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lookId:t,finding:e})}),r=await a.json();if(!a.ok){r.id&&h(t=>({...t,[e]:r.id})),O(e,null!=(n=r.error)?n:String(a.status));return}r.id&&h(t=>({...t,[e]:r.id})),j(t=>{let n=new Set(t);return n.delete(e),n}),O(e,m("look.assignDone",{project:null!=(l=r.project)?l:"",title:null!=(o=r.title)?o:""})),x.refresh()}catch(t){O(e,m("project.unreachable"))}finally{v(null)}}async function C(e){v(e);try{let l=await fetch("/api/twin/assign",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lookId:t,finding:e,decision:"discard"})}),o=await l.json();if(!l.ok){var n;O(e,null!=(n=o.error)?n:String(l.status));return}j(t=>new Set(t).add(e)),h(t=>{let n={...t};return delete n[e],n}),O(e,m("look.dismissDone")),x.refresh()}catch(t){O(e,m("project.unreachable"))}finally{v(null)}}async function P(e,t){v(e);try{var n,l;let o=await fetch("/api/assignments/launch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:t})}),a=await o.json();o.ok&&b(e=>new Set(e).add(t)),O(e,o.ok?m("look.assignLaunched",{agent:null!=(n=a.agent)?n:""}):null!=(l=a.error)?l:String(o.status))}catch(t){O(e,m("project.unreachable"))}finally{v(null)}}return(0,l.jsx)("ol",{className:"mt-3 flex flex-col gap-4",role:"list",children:n.map((e,n)=>{let o=p[n],a=k.has(n);return(0,l.jsxs)("li",{className:"flex flex-col gap-1",children:[(0,l.jsx)("p",{className:"max-w-2xl text-sm leading-relaxed",children:e.what}),(0,l.jsx)("p",{className:"max-w-2xl font-mono text-xs text-faint",children:e.where}),(0,l.jsx)("p",{className:"max-w-2xl text-sm leading-relaxed text-smoke",children:m("look.fix",{fix:e.fix})}),e.cites.map(e=>(0,l.jsx)("p",{className:"max-w-2xl font-mono text-xs text-faint",children:m("look.against",{statement:e})},e)),""!==t&&(0,l.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(0,l.jsx)(i.rA,{tone:"plain",type:"button",onClick:()=>void S(n),busy:y===n&&void 0===o,busyLabel:m("look.assigning"),disabled:null!==y||void 0!==o,children:void 0!==o?m("look.assigned"):m("look.assignButton")}),!a&&(0,l.jsx)(i.rA,{tone:"quiet",type:"button",onClick:()=>void C(n),disabled:null!==y,children:m("look.dismissButton")}),a&&(0,l.jsx)("span",{className:"font-mono text-xs text-faint",children:m("look.dismissed")}),void 0!==o&&f.available&&(0,l.jsx)(i.rA,{tone:"accent",type:"button",onClick:()=>void P(n,o),disabled:null!==y,children:m(g.has(o)?"look.assignAgain":"look.assignNow")})]}),w[n]&&(0,l.jsx)("p",{className:"max-w-2xl font-mono text-xs text-smoke",children:w[n]})]},n)})})}async function p(e){var t;let n=await fetch("/api/twin/look",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),l=await n.json();return n.ok?l:{...l,error:null!=(t=l.error)?t:String(n.status)}}},56684:(e,t,n)=>{"use strict";n.d(t,{k5:()=>u});var l=n(32165),o={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},a=l.createContext&&l.createContext(o),r=["attr","size","title"];function s(){return(s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var l in n)({}).hasOwnProperty.call(n,l)&&(e[l]=n[l])}return e}).apply(null,arguments)}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,l)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach(function(t){var l,o,a;l=e,o=t,a=n[t],(o=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var l=n.call(e,t||"default");if("object"!=typeof l)return l;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(o))in l?Object.defineProperty(l,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):l[o]=a}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function u(e){return t=>l.createElement(d,s({attr:c({},e.attr)},t),function e(t){return t&&t.map((t,n)=>l.createElement(t.tag,c({key:n},t.attr),e(t.child)))}(e.child))}function d(e){var t=t=>{var n,o=e.attr,a=e.size,i=e.title,u=function(e,t){if(null==e)return{};var n,l,o=function(e,t){if(null==e)return{};var n={};for(var l in e)if(({}).hasOwnProperty.call(e,l)){if(-1!==t.indexOf(l))continue;n[l]=e[l]}return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(l=0;l<a.length;l++)n=a[l],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,r),d=a||t.size||"1em";return t.className&&(n=t.className),e.className&&(n=(n?n+" ":"")+e.className),l.createElement("svg",s({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,o,u,{className:n,style:c(c({color:e.color||t.color},t.style),e.style),height:d,width:d,xmlns:"http://www.w3.org/2000/svg"}),i&&l.createElement("title",null,i),e.children)};return void 0!==a?l.createElement(a.Consumer,null,e=>t(e)):t(o)}},92052:(e,t,n)=>{Promise.resolve().then(n.bind(n,38444))}},e=>{e.O(0,[6587,2575,2948,1305,6823,7358],()=>e(e.s=92052)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1162],{3030:(e,t,n)=>{"use strict";n.d(t,{TwinLab:()=>c});var s=n(38657),i=n(32165),l=n(3043),a=n(9144),r=n(26488),o=n(52948),d=n(59916);function c(e){let{projects:t,hasBeliefs:n}=e,c=(0,a.kj)(),[u,x]=(0,i.useState)(""),[p,h]=(0,i.useState)(""),[w,f]=(0,i.useState)(null),[b,y]=(0,i.useState)(null),[g,j]=(0,i.useState)(null),[v,N]=(0,i.useState)(null),k=(0,i.useRef)(!1),M=t.find(e=>e.slug===p);function S(){y(null),j(null)}async function C(e){if(k.current)return;let t=u.trim();if(!t||t.length>r.s)return void j(c("twinLab.invalidRequest",{max:r.s}));if(e||(null==b?void 0:b.status)==="preview"&&b.evidence.length){k.current=!0,f(e?"preview":"draft"),j(null),e&&y(null);try{let s=await fetch("/api/twin/rehearse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({question:t,...p?{slug:p}:{},dryRun:e})}),i=await s.json();if("number"==typeof i.remainingCalls&&N(i.remainingCalls),!s.ok){var n;j(429===s.status?c("twinLab.budgetReached"):[null!=(n=i.error)?n:c("twinLab.failed"),i.hint].filter(Boolean).join(" "));return}if(!Array.isArray(i.evidence)||!["preview","drafted","abstained"].includes(i.status))return void j(c("twinLab.failed"));y(i)}catch(e){j(c("project.unreachable"))}finally{k.current=!1,f(null)}}}let L=(null==b?void 0:b.reason)==="no-beliefs"?"twinLab.noBeliefs":(null==b?void 0:b.reason)==="no-match"?"twinLab.noMatch":"twinLab.unsupported";return(0,s.jsxs)("section",{id:"decision-lab",tabIndex:-1,"aria-labelledby":"twin-lab-title",className:"page-shell__section scroll-mt-24 rounded-lg border border-edge bg-surface",children:[(0,s.jsxs)("div",{className:"border-b border-edge px-5 py-5 sm:px-6",children:[(0,s.jsxs)("p",{className:"flex items-center gap-2 font-mono text-xs text-smoke",children:[(0,s.jsx)(l.qRK,{"aria-hidden":!0,className:"h-4 w-4"}),c("twinLab.eyebrow")]}),(0,s.jsx)("h2",{id:"twin-lab-title",className:"mt-2 text-base font-semibold",children:c("twinLab.title")}),(0,s.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-smoke",children:c("twinLab.lead")})]}),(0,s.jsxs)("div",{className:"grid lg:grid-cols-2",children:[(0,s.jsxs)("form",{onSubmit:function(e){e.preventDefault(),C(!0)},className:"min-w-0 px-5 py-5 sm:px-6","aria-busy":null!==w,children:[(0,s.jsx)(o.fs,{label:c("twinLab.question"),value:u,onChange:e=>{x(e.target.value),S()},maxLength:r.s,rows:4,required:!0,disabled:null!==w||!n,"aria-describedby":"twin-lab-question-hint twin-lab-count".concat(n?"":" twin-lab-untrained"),placeholder:c("twinLab.placeholder")}),!n&&(0,s.jsx)("p",{id:"twin-lab-untrained",className:"mt-2 text-xs leading-relaxed text-smoke",children:c("twinLab.firstTitle")}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap justify-between gap-2 text-xs text-smoke",children:[(0,s.jsx)("p",{id:"twin-lab-question-hint",children:c("twinLab.questionHint")}),(0,s.jsx)("p",{id:"twin-lab-count",className:"font-mono",children:c("twinLab.characters",{n:u.length,max:r.s})})]}),(0,s.jsxs)(o.l6,{label:c("twinLab.project"),className:"mt-5",value:p,onChange:e=>{h(e.target.value),S()},disabled:null!==w||!n,"aria-describedby":"twin-lab-scope-hint",children:[(0,s.jsx)("option",{value:"",children:c("twinLab.global")}),t.map(e=>(0,s.jsx)("option",{value:e.slug,children:e.label},e.slug))]}),(0,s.jsx)("p",{id:"twin-lab-scope-hint",className:"mt-2 text-xs leading-relaxed text-smoke",children:c("twinLab.scopeHint")}),(0,s.jsxs)("div",{className:"mt-5 flex flex-wrap items-center gap-3",children:[(0,s.jsx)(o.rA,{type:"submit",tone:"surface",busy:"preview"===w,busyLabel:c("twinLab.previewing"),disabled:null!==w||!u.trim()||!n,children:c("twinLab.preview")}),(0,s.jsx)("span",{className:"text-xs text-smoke",children:c("twinLab.previewCost")})]}),g&&(0,s.jsx)(o.lZ,{text:g,className:"mt-4"})]}),(0,s.jsxs)("div",{className:"min-w-0 border-t border-edge bg-ground px-5 py-5 sm:px-6 lg:border-t-0 lg:border-l",children:[(0,s.jsx)("p",{role:"status","aria-live":"polite",className:"font-mono text-xs text-smoke",children:"preview"===w?c("twinLab.previewing"):"draft"===w?c("twinLab.drafting"):(null==b?void 0:b.status)==="drafted"?c("twinLab.draftReady"):(null==b?void 0:b.status)==="abstained"?c("twinLab.abstained"):(null==b?void 0:b.status)==="preview"?c("twinLab.evidenceCount",{n:b.evidence.length}):c("twinLab.waiting")}),!b&&(0,s.jsx)(o.pp,{variant:"bare",className:"mt-4 max-w-md",title:c(n?"twinLab.emptyTitle":"twinLab.firstTitle"),action:!n&&(0,s.jsx)(m,{}),children:c(n?"twinLab.emptyBody":"twinLab.noBeliefs")}),(null==b?void 0:b.status)==="abstained"&&(0,s.jsxs)("div",{className:"mt-3",children:[(0,s.jsx)("h3",{className:"text-base font-semibold",children:c("twinLab.abstainedTitle")}),(0,s.jsx)("p",{className:"mt-2 text-sm leading-relaxed text-smoke",children:c(L)}),(0,s.jsx)(m,{className:"mt-3"})]}),(null==b?void 0:b.status)==="drafted"&&(0,s.jsxs)(o.Zp,{className:"mt-3",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:c("twinLab.draftTitle")}),(0,s.jsx)("p",{className:"mt-2 whitespace-pre-wrap break-words text-base leading-relaxed",children:b.answer}),(0,s.jsx)("p",{className:"mt-3 text-xs leading-relaxed text-smoke",children:c("twinLab.draftHint")}),(0,s.jsx)("p",{className:"mt-3 text-xs leading-relaxed text-smoke",children:c("twinLab.disagree")}),(0,s.jsx)(m,{className:"mt-3"})]}),b&&b.evidence.length>0&&(0,s.jsxs)("div",{className:"mt-4",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:c("drafted"===b.status?"twinLab.citations":"twinLab.evidence")}),(0,s.jsx)("ol",{className:"mt-3 flex flex-col gap-2",role:"list",children:b.evidence.map((e,t)=>{var n;let i=(0,d.Jj)(e.topic);return(0,s.jsxs)(o.Zp,{as:"li",pad:"sm",children:[(0,s.jsxs)("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 font-mono text-[11px] text-smoke",children:[(0,s.jsx)("span",{"aria-hidden":!0,children:String(t+1).padStart(2,"0")}),(0,s.jsx)("span",{children:c("episode"===e.kind?"twinLab.episode":"signed"===e.state?"twin.badgeSigned":"twin.badgeStanding")}),"episode"!==e.kind&&(0,s.jsxs)("span",{children:["\xb7 ",i?c(i):e.topic]})]}),(0,s.jsxs)("a",{href:"episode"===e.kind?"/twin?episode=".concat(encodeURIComponent(e.id),"#episode-").concat(e.id):"#belief-".concat(e.id),className:"mt-1.5 flex items-start gap-2 text-sm leading-relaxed underline-offset-4 hover:underline",children:[(0,s.jsx)("span",{className:"min-w-0 flex-1 whitespace-pre-line break-words",children:e.statement}),(0,s.jsx)(l.OvC,{"aria-hidden":!0,className:"mt-0.5 h-4 w-4 shrink-0 text-smoke"}),(0,s.jsx)("span",{className:"sr-only",children:c("episode"===e.kind?"twinLab.openEpisode":"twinLab.openEvidence")})]}),(0,s.jsx)("p",{className:"mt-2 text-xs text-smoke",children:"episode"===e.kind?c("twinLab.episodeScope"):e.scope?c("twinLab.projectRule",{project:null!=(n=null==M?void 0:M.label)?n:e.scope}):c("twinLab.globalRule")})]},e.id)})})]}),b&&b.omittedBeliefs>0&&(0,s.jsx)("p",{className:"mt-3 font-mono text-xs text-smoke",children:c("twinLab.omitted",{n:b.omittedBeliefs})}),null!==v&&(0,s.jsx)("p",{className:"mt-3 font-mono text-xs text-smoke",children:c("twinLab.remaining",{n:v})}),(null==b?void 0:b.status)==="preview"&&b.evidence.length>0&&(0,s.jsxs)("div",{className:"mt-5 border-t border-edge pt-4",children:[(0,s.jsx)(o.rA,{type:"button",tone:"accent",busy:"draft"===w,busyLabel:c("twinLab.drafting"),disabled:null!==w||0===v,onClick:()=>void C(!1),children:c("twinLab.rehearse")}),(0,s.jsx)("p",{className:"mt-2 text-xs leading-relaxed text-smoke",children:c(0===v?"twinLab.budgetReached":"twinLab.draftCost")})]})]})]}),(0,s.jsx)("p",{className:"border-t border-edge px-5 py-3 text-xs leading-relaxed text-smoke sm:px-6",children:c("twinLab.boundary")})]})}function m(e){let{className:t}=e,n=(0,a.kj)();return(0,s.jsxs)("a",{href:"#teach",className:"inline-flex items-center gap-1 text-sm underline underline-offset-4".concat(t?" ".concat(t):""),children:[n("twinLab.teach"),(0,s.jsx)(l.OvC,{"aria-hidden":!0,className:"h-4 w-4"})]})}},4733:(e,t,n)=>{"use strict";n.d(t,{TwinMemory:()=>w});var s=n(38657),i=n(32165),l=n(10354),a=n(3043),r=n(9144),o=n(52948);let d=["goal","context","constraints","alternatives","decision","rationale","outcome","conditions","exceptions"],c={goal:{label:"twinMemory.fieldGoal",hint:"twinMemory.hintGoal"},context:{label:"twinMemory.fieldContext",hint:"twinMemory.hintContext"},constraints:{label:"twinMemory.fieldConstraints",hint:"twinMemory.hintConstraints"},alternatives:{label:"twinMemory.fieldAlternatives",hint:"twinMemory.hintAlternatives"},decision:{label:"twinMemory.fieldDecision",hint:"twinMemory.hintDecision"},rationale:{label:"twinMemory.fieldRationale",hint:"twinMemory.hintRationale"},outcome:{label:"twinMemory.fieldOutcome",hint:"twinMemory.hintOutcome"},conditions:{label:"twinMemory.fieldConditions",hint:"twinMemory.hintConditions"},exceptions:{label:"twinMemory.fieldExceptions",hint:"twinMemory.hintExceptions"}};function m(e){var t,n,s;return(null==(t=e.fields.decision)?void 0:t.text.trim())||(null==(n=e.fields.goal)?void 0:n.text.trim())||(null==(s=e.fields.context)?void 0:s.text.trim())||null}function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();return null!==e.validUntil&&Date.parse(e.validUntil)<=t}let x={opening:"twinMemory.kindOpening",reaction:"twinMemory.kindReaction",brief:"twinMemory.kindBrief"};async function p(e,t,n){let s=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),i=await s.json();if(!s.ok){var l;throw Error([null!=(l=i.error)?l:n,i.hint].filter(Boolean).join(" "))}return i}function h(e,t){return e instanceof Error?e.message:t("project.unreachable")}function w(e){var t;let{projects:n,episodes:l,coverage:d,dailyCalls:c,focusId:m,olderCursor:u,conflicts:x}=e,p=(0,r.kj)(),w=(null==(t=l.find(e=>e.id===m))?void 0:t.status)==="dismissed",[j,v]=(0,i.useState)(w),[N,k]=(0,i.useState)(null),[M,S]=(0,i.useState)(null),[C,L]=(0,i.useState)(null),[T,O]=(0,i.useState)(null),P=(0,i.useRef)(!1),[R,A]=(0,i.useState)(l),[E,I]=(0,i.useState)(l),[U,D]=(0,i.useState)(u),[q,B]=(0,i.useState)(""),[F,z]=(0,i.useState)(""),[Z,_]=(0,i.useState)(null),[J,H]=(0,i.useState)(null),G=(0,i.useRef)(!1);R!==l&&(A(l),I(l),D(u));let W=E.filter(e=>j||"active"===e.status),V=E.filter(e=>"dismissed"===e.status).length;function Y(e){var t,s;return{...e,projectName:e.identity&&null!=(s=null==(t=n.find(t=>t.identity===e.identity))?void 0:t.label)?s:null}}async function K(e,t){var n,s;let i=new URLSearchParams;e&&i.set("q",e),t&&i.set("before",t);let l=i.toString(),a=await fetch("/api/twin/episodes".concat(l?"?".concat(l):"")),r=await a.json();if(!a.ok||!Array.isArray(r.episodes))throw Error(null!=(n=r.error)?n:p("twinMemory.requestFailed"));return{episodes:r.episodes.map(Y),nextCursor:null!=(s=r.nextCursor)?s:null}}async function Q(e){if(G.current)return;let t=e.trim();if(!t){z(""),I(l),D(u),H(null);return}G.current=!0,_("search"),H(null);try{let e=await K(t,null);z(t),I(e.episodes),D(e.nextCursor)}catch(e){H(h(e,p))}finally{G.current=!1,_(null)}}async function X(){if(!G.current&&U){G.current=!0,_("older"),H(null);try{let e=await K(F,U);I(t=>{let n=new Set(t.map(e=>e.id));return[...t,...e.episodes.filter(e=>!n.has(e.id))]}),D(e.nextCursor)}catch(e){H(h(e,p))}finally{G.current=!1,_(null)}}}return(0,i.useEffect)(()=>{var e;m&&(w&&v(!0),O(m),null==(e=document.getElementById("episode-".concat(m)))||e.focus())},[m,w]),(0,i.useEffect)(()=>{var e;T&&(null==(e=document.getElementById("episode-".concat(T)))||e.focus())},[T,j]),(0,i.useEffect)(()=>{F&&Q(F)},[l]),(0,s.jsxs)("section",{id:"decision-memory",tabIndex:-1,"aria-labelledby":"twin-memory-title",className:"page-shell__section scroll-mt-24 overflow-hidden rounded-lg border border-edge bg-surface",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4 border-b border-edge px-5 py-5 sm:px-6",children:[(0,s.jsxs)("div",{className:"max-w-2xl",children:[(0,s.jsxs)("p",{className:"flex items-center gap-2 font-mono text-xs text-smoke",children:[(0,s.jsx)(a.lPA,{"aria-hidden":!0,className:"h-4 w-4"}),p("twinMemory.eyebrow")]}),(0,s.jsx)("h2",{id:"twin-memory-title",className:"mt-2 text-base font-semibold",children:p("twinMemory.title")}),(0,s.jsx)("p",{className:"mt-2 text-sm leading-relaxed text-smoke",children:p("twinMemory.lead")})]}),(0,s.jsxs)("div",{className:"rounded-lg border border-edge bg-ground px-3 py-2 font-mono text-xs text-smoke",children:[(0,s.jsx)("p",{children:p("twinMemory.captured",{n:d.total})}),(0,s.jsx)("p",{className:"mt-1",children:p("twinMemory.awaiting",{n:d.pending})})]})]}),(0,s.jsxs)("div",{className:"grid lg:grid-cols-[1.3fr_1fr]",children:[(0,s.jsx)(b,{projects:n,revision:N,blocked:M,dirty:P,savedMessage:C,onCancel:()=>{k(null),S(null),L(null)},onClear:()=>{k(M),S(null)},onSaved:()=>{L(p(N?"twinMemory.savedRevision":"twinMemory.savedNew")),k(null),S(null)}}),(0,s.jsx)(y,{pendingCount:d.pending,deferred:d.deferred,dailyCalls:c})]}),x.length>0&&(0,s.jsxs)("div",{id:"competing-versions",tabIndex:-1,"aria-labelledby":"twin-competing-title",className:"scroll-mt-24 border-t border-edge px-5 py-5 sm:px-6",children:[(0,s.jsx)("h3",{id:"twin-competing-title",className:"text-base font-semibold",children:p("twinMemory.competingTitle")}),(0,s.jsx)("p",{className:"mt-2 max-w-2xl text-xs leading-relaxed text-smoke",children:p("twinMemory.competingLead")}),(0,s.jsx)("p",{className:"mt-2 font-mono text-xs text-smoke",children:p("twinMemory.competingFamilies",{n:x.length})}),(0,s.jsx)("ul",{className:"mt-4 grid items-start gap-3 xl:grid-cols-2",role:"list",children:x.map(e=>(0,s.jsx)(f,{family:e},e.map(e=>e.id).join(",")))})]}),(0,s.jsxs)("div",{className:"border-t border-edge px-5 py-5 sm:px-6",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,s.jsx)("h3",{className:"text-base font-semibold",children:p("twinMemory.recentTitle")}),V>0&&(0,s.jsx)(o.Jl,{size:"sm",checked:j,onChange:e=>v(e.target.checked),children:p("twinMemory.includeDismissed",{n:V})})]}),(0,s.jsxs)("form",{role:"search","aria-busy":"search"===Z,className:"mt-3 flex flex-wrap items-end gap-2",onSubmit:e=>{e.preventDefault(),Q(q)},children:[(0,s.jsx)(o.D0,{label:p("twinMemory.searchLabel"),className:"min-w-0 grow sm:max-w-md",type:"search",value:q,maxLength:200,disabled:null!==Z,"aria-describedby":"memory-search-hint",onChange:e=>{B(e.target.value),!e.target.value.trim()&&F&&Q("")}}),(0,s.jsx)(o.rA,{type:"submit",tone:"surface",busy:"search"===Z,busyLabel:p("twinMemory.searching"),disabled:null!==Z,children:p("twinMemory.search")}),F&&(0,s.jsx)(o.rA,{type:"button",tone:"plain",disabled:null!==Z,onClick:()=>{B(""),Q("")},children:p("twinMemory.clearSearch")})]}),(0,s.jsx)("p",{id:"memory-search-hint",className:"mt-1 text-xs leading-relaxed text-smoke",children:p("twinMemory.searchHint")}),J&&(0,s.jsx)(o.lZ,{text:J,className:"mt-2"}),(0,s.jsx)("p",{className:"mt-3 text-xs text-smoke",children:F?p("twinMemory.shownMatches",{query:F,n:W.length}):p("twinMemory.shown",{n:W.length})}),0===W.length&&F?(0,s.jsx)(o.pp,{variant:"note",role:"status",className:"mt-4",title:p("twinMemory.noMatches",{query:F})}):0===W.length?(0,s.jsx)(o.pp,{className:"mt-4",title:p("twinMemory.emptyTitle"),children:p("twinMemory.emptyBody")}):(0,s.jsx)("ul",{className:"mt-4 grid items-start gap-3 xl:grid-cols-2",role:"list",children:W.map(e=>(0,s.jsx)(g,{episode:e,previousAvailable:!!(e.supersedesId&&E.some(t=>t.id===e.supersedesId)),hasActiveSuccessor:!!e.activeRevisionId,onPrevious:()=>{var t,n;v(!0),O(null!=(n=e.supersedesId)?n:null),null==(t=document.getElementById("episode-".concat(e.supersedesId)))||t.focus()},onRevise:()=>{var t;L(null),e.id!==(null==N?void 0:N.id)&&(P.current?S(e):(S(null),k(e))),null==(t=document.getElementById("memory-capture-form"))||t.scrollIntoView({block:"start",behavior:"instant"})}},e.id))}),U&&(0,s.jsx)(o.rA,{type:"button",tone:"surface",className:"mt-4",busy:"older"===Z,busyLabel:p("twinMemory.loadingOlder"),disabled:null!==Z,onClick:()=>void X(),children:p("twinMemory.loadOlder")}),(0,s.jsx)("p",{className:"mt-4 text-xs leading-relaxed text-smoke",children:p("twinMemory.boundary")})]})]})}function f(e){let{family:t}=e,n=(0,r.kj)(),a=(0,l.useRouter)(),[d,c]=(0,i.useState)(null),[u,x]=(0,i.useState)(null),w=(0,i.useRef)(!1);async function f(e){if(w.current)return;w.current=!0,c(e.id),x(null);let s=!1;try{for(let i of t)i.id!==e.id&&(await p("/api/twin/episodes",{id:i.id,status:"dismissed",expectedUpdatedAt:i.updatedAt},n("twinMemory.requestFailed")),s=!0)}catch(e){x(h(e,n))}finally{w.current=!1,c(null),s&&a.refresh()}}return(0,s.jsxs)("li",{className:"min-w-0 rounded-lg border border-edge bg-ground p-4",children:[(0,s.jsx)("ol",{className:"space-y-3",role:"list",children:t.map(e=>{var t,i;return(0,s.jsxs)("li",{className:"flex flex-wrap items-start justify-between gap-3 border-t border-edge pt-3 first:border-t-0 first:pt-0",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("p",{className:"flex flex-wrap gap-x-2 gap-y-1 font-mono text-[11px] text-smoke",children:[(0,s.jsx)("span",{children:n("owner"===e.origin?"twinMemory.byOwner":"twinMemory.fromHistory")}),(0,s.jsxs)("span",{children:["\xb7 ",null!=(t=e.projectName)?t:n(e.identity?"twinMemory.unlinkedProject":"twinMemory.noProject")]}),(0,s.jsxs)("time",{dateTime:e.createdAt,children:["\xb7 ",e.createdAt.slice(0,10)]})]}),(0,s.jsx)("p",{className:"mt-1 line-clamp-3 break-words text-sm leading-relaxed",children:null!=(i=m(e))?i:n("twinMemory.untitled")}),(0,s.jsx)("a",{href:"#episode-".concat(e.id),className:"mt-1 inline-block text-xs underline underline-offset-4",children:n("twinMemory.explore")})]}),(0,s.jsx)(o.rA,{type:"button",tone:"surface",busy:d===e.id,busyLabel:n("twinMemory.keeping"),disabled:null!==d,onClick:()=>void f(e),children:n("twinMemory.keepThis")})]},e.id)})}),u&&(0,s.jsx)(o.lZ,{text:u,className:"mt-3"})]})}function b(e){var t,n,a,m,u;let{projects:x,revision:w,blocked:f,dirty:b,savedMessage:y,onSaved:g,onCancel:j,onClear:v}=e,N=(0,r.kj)(),k=(0,l.useRouter)(),[M,S]=(0,i.useState)({}),[C,L]=(0,i.useState)(""),[T,O]=(0,i.useState)(new Set),[P,R]=(0,i.useState)(null),[A,E]=(0,i.useState)(""),[I,U]=(0,i.useState)(!1),[D,q]=(0,i.useState)(null),[B,F]=(0,i.useState)(!1),z=(0,i.useRef)(!1),Z=(0,i.useRef)(null),_=!!((null==(t=M.goal)?void 0:t.trim())||(null==(n=M.decision)?void 0:n.trim())),J=d.filter(e=>"goal"!==e&&"decision"!==e),H=J.filter(e=>{var t;return T.has(e)||!!(null==(t=M[e])?void 0:t.trim())}),G=J.filter(e=>!H.includes(e)),W=(null==w?void 0:w.identity)&&null!=(m=null==(a=x.find(e=>e.identity===w.identity))?void 0:a.slug)?m:"";async function V(e){if(e.preventDefault(),!z.current&&_){z.current=!0,U(!0),q(null);try{await p("/api/twin/episodes",{fields:M,...A?{validUntil:A}:{},...w?{replacesId:w.id,expectedUpdatedAt:w.updatedAt}:C?{slug:C}:{}},N("twinMemory.requestFailed")),S({}),O(new Set),R(null),E(""),F(!1),b.current=!1,g(),k.refresh()}catch(e){q(h(e,N))}finally{z.current=!1,U(!1)}}}function Y(e){var t;let n=null!=(t=M[e])?t:"";return(0,s.jsxs)("div",{children:[(0,s.jsx)(o.fs,{label:N(c[e].label),id:"memory-".concat(e),value:n,maxLength:1200,rows:"decision"===e?3:2,disabled:I,placeholder:N(c[e].hint),"aria-describedby":"memory-".concat(e,"-count"),onChange:t=>{S(n=>({...n,[e]:t.target.value})),F(!0),b.current=!0}}),(0,s.jsx)("p",{id:"memory-".concat(e,"-count"),className:"mt-1 text-right font-mono text-[11px] text-smoke",children:N("twinMemory.characters",{n:n.length,max:1200})})]},e)}return(0,i.useEffect)(()=>{var e,t,n,s;S(w?Object.fromEntries(d.map(e=>{var t,n;return[e,null!=(n=null==(t=w.fields[e])?void 0:t.text)?n:""]})):{}),O(new Set(w?d.filter(e=>{var t;return null==(t=w.fields[e])?void 0:t.text.trim()}):[])),R(null),E(null!=(s=null==w||null==(e=w.validUntil)?void 0:e.slice(0,10))?s:""),L(W),F(!1),b.current=!1,w&&(null==(n=Z.current)||null==(t=n.querySelector("textarea"))||t.focus({preventScroll:!0}))},[w,W,b]),(0,i.useEffect)(()=>{var e;P&&(null==(e=document.getElementById("memory-".concat(P)))||e.focus())},[P]),(0,s.jsxs)("form",{id:"memory-capture-form",ref:Z,onSubmit:V,"aria-busy":I,"aria-labelledby":"memory-capture-title",className:"min-w-0 scroll-mt-24 px-5 py-5 sm:px-6",children:[(0,s.jsx)("h3",{id:"memory-capture-title",className:"text-base font-semibold",children:N(w?"twinMemory.reviseTitle":"twinMemory.captureTitle")}),(0,s.jsx)("p",{className:"mt-2 text-xs leading-relaxed text-smoke",children:N(w?"twinMemory.reviseHint":"twinMemory.captureHint")}),(0,s.jsx)("div",{role:"status","aria-live":"polite",children:f&&(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-3 rounded-lg border border-edge bg-ground px-3 py-3",children:[(0,s.jsx)("p",{className:"text-xs leading-relaxed text-smoke",children:N("twinMemory.unsavedDraft")}),(0,s.jsx)(o.rA,{type:"button",tone:"surface",disabled:I,onClick:v,children:N("twinMemory.clearDraft")})]})}),(0,s.jsxs)("div",{className:"mt-4 space-y-3",children:[Y("goal"),Y("decision"),(0,s.jsxs)(o.l6,{label:N("twinMemory.projectContext"),value:C,disabled:I||null!==w,onChange:e=>L(e.target.value),children:[(0,s.jsx)("option",{value:"",children:(null==w?void 0:w.identity)&&!C?null!=(u=w.projectName)?u:N("twinMemory.originalProject"):N("twinMemory.noProject")}),x.map(e=>(0,s.jsx)("option",{value:e.slug,children:e.label},e.slug))]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(o.D0,{label:N("twinMemory.validUntilLabel"),type:"date",value:A,disabled:I,"aria-describedby":"memory-valid-until-hint",onChange:e=>{E(e.target.value),F(!0),b.current=!0}}),(0,s.jsx)("p",{id:"memory-valid-until-hint",className:"mt-1 text-xs leading-relaxed text-smoke",children:N("twinMemory.validUntilHint")})]}),H.map(Y),G.length>0&&(0,s.jsxs)("div",{className:"rounded-lg border border-edge px-3 py-3",children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:N("twinMemory.moreFields")}),(0,s.jsx)("div",{className:"mt-3 flex flex-wrap gap-2",children:G.map(e=>(0,s.jsx)(o.rA,{type:"button",tone:"surface",disabled:I,"aria-label":N("twinMemory.addField",{field:N(c[e].label).toLocaleLowerCase()}),onClick:()=>{O(t=>new Set(t).add(e)),R(e)},children:N(c[e].label)},e))})]})]}),(0,s.jsxs)("div",{className:"mt-4 flex flex-wrap items-center gap-3",children:[(0,s.jsx)(o.rA,{type:"submit",tone:"accent",busy:I,busyLabel:N("twinMemory.saving"),disabled:I||!_,children:N(w?"twinMemory.saveRevision":"twinMemory.saveEpisode")}),w&&(0,s.jsx)(o.rA,{type:"button",tone:"plain",disabled:I,onClick:j,children:N("twinMemory.cancelRevision")}),(0,s.jsx)("span",{className:"text-xs text-smoke",children:N("twinMemory.localSave")})]}),D&&(0,s.jsx)(o.lZ,{text:D,className:"mt-3"}),(0,s.jsx)("div",{role:"status","aria-live":"polite",children:y&&!B&&(0,s.jsx)("p",{className:"mt-3 text-sm text-smoke",children:y})})]})}function y(e){var t,n;let{pendingCount:d,deferred:c,dailyCalls:m}=e,u=(0,r.kj)(),x=(0,l.useRouter)(),[w,f]=(0,i.useState)(null),[b,y]=(0,i.useState)(null),[g,j]=(0,i.useState)(null),[v,N]=(0,i.useState)(null),k=(0,i.useRef)(!1),M=m>0&&d>0?Math.max(1,Math.ceil(d/(12*m))):null;async function S(e){if(k.current||"learn"===e&&(!b||!b.selected||b.remainingCalls<b.calls))return;k.current=!0,f(e),j(null),N(null);let t=u("twinMemory.requestFailed");try{var n,s,i,l,a;if("capture"===e){let e=await p("/api/twin/mine",{captureNarratives:!0},t);y(null),N([u("twinMemory.capturedNew",{n:null!=(s=e.narrativesSaved)?s:0}),e.saved?u("twin.minedQuotes",{n:e.saved}):"",(null==(n=e.denied)?void 0:n.length)?u("twinMemory.capturedDenied",{n:e.denied.length}):"",e.narrativesUnmatched?u("twinMemory.capturedUnmatched",{n:e.narrativesUnmatched}):"",e.narrativesUndated?u("twinMemory.capturedUndated",{n:e.narrativesUndated}):""].filter(Boolean).join(" ")),x.refresh()}else if("preview"===e)y(await p("/api/twin/episodes/learn",{dryRun:!0},t));else{let e=await p("/api/twin/episodes/learn",{},t);y(null),N([u("twinMemory.learnStored",{stored:null!=(i=e.stored)?i:0,processed:null!=(l=e.processed)?l:0,remaining:null!=(a=e.remaining)?a:0}),e.dropped?u("twinMemory.learnDropped",{n:e.dropped}):"",e.failed?u("cut"===e.failed.reason?"twinMemory.learnCut":"twinMemory.learnUnsupported"):"",e.failed?u("twinMemory.learnDeferred",{n:e.failed.records}):""].filter(Boolean).join(" ")),x.refresh()}}catch(t){j(h(t,u)),"learn"===e&&(y(null),x.refresh())}finally{k.current=!1,f(null)}}return(0,s.jsxs)("div",{className:"min-w-0 border-t border-edge bg-ground px-5 py-5 sm:px-6 lg:border-t-0 lg:border-l","aria-busy":null!==w,children:[(0,s.jsxs)("h3",{className:"flex items-center gap-2 text-base font-semibold",children:[(0,s.jsx)(a.tZt,{"aria-hidden":!0,className:"h-4 w-4 text-smoke"}),u("twinMemory.learnTitle")]}),(0,s.jsx)("p",{className:"mt-2 text-sm leading-relaxed text-smoke",children:u("twinMemory.learnLead")}),(0,s.jsxs)("div",{className:"mt-5 rounded-lg border border-edge bg-surface p-4",children:[(0,s.jsx)("p",{className:"font-mono text-xs text-smoke",children:u("twinMemory.step1")}),(0,s.jsx)("p",{className:"mt-2 text-xs leading-relaxed text-smoke",children:u("twinMemory.step1Hint")}),(0,s.jsxs)(o.rA,{type:"button",tone:"surface",className:"mt-3",busy:"capture"===w,busyLabel:u("twinMemory.capturing"),disabled:null!==w,onClick:()=>void S("capture"),children:[(0,s.jsx)(a.Dho,{"aria-hidden":!0,className:"h-4 w-4"}),u("twinMemory.capture")]}),(0,s.jsx)("p",{className:"mt-2 text-xs text-smoke",children:u("twinMemory.noCall")})]}),(0,s.jsxs)("div",{className:"mt-3 rounded-lg border border-edge bg-surface p-4",children:[(0,s.jsx)("p",{className:"font-mono text-xs text-smoke",children:u("twinMemory.step2")}),(0,s.jsx)("p",{className:"mt-2 text-xs leading-relaxed text-smoke",children:u("twinMemory.step2Hint")}),(0,s.jsx)(o.rA,{type:"button",tone:"surface",className:"mt-3",busy:"preview"===w,busyLabel:u("twinMemory.previewing"),disabled:null!==w,onClick:()=>void S("preview"),children:u("twinMemory.preview")}),!b&&(0,s.jsxs)("div",{className:"mt-2 space-y-1 text-xs text-smoke",children:[(0,s.jsx)("p",{children:u("twinMemory.awaiting",{n:d})}),c>0&&(0,s.jsx)("p",{children:u("twinMemory.deferred",{n:c})}),m>0?(0,s.jsx)("p",{children:u("twinMemory.passReads",{n:24})}):(0,s.jsx)("p",{children:u("twinMemory.extractionOff")}),null!==M&&(0,s.jsx)("p",{children:u("twinMemory.queueDays",{n:M})})]}),b&&(0,s.jsxs)("div",{className:"mt-4 border-t border-edge pt-4",children:[(0,s.jsxs)("dl",{className:"grid grid-cols-[1fr_auto] gap-x-3 gap-y-2 text-xs",children:[(0,s.jsx)("dt",{className:"text-smoke",children:u("twinMemory.selected")}),(0,s.jsx)("dd",{className:"font-mono",children:b.selected}),(0,s.jsx)("dt",{className:"text-smoke",children:u("twinMemory.inputTokens")}),(0,s.jsx)("dd",{className:"font-mono",children:b.inputTokens}),(0,s.jsx)("dt",{className:"text-smoke",children:u("twinMemory.outputTokens")}),(0,s.jsx)("dd",{className:"font-mono",children:b.outputTokens}),(0,s.jsx)("dt",{className:"text-smoke",children:u("twinMemory.calls")}),(0,s.jsx)("dd",{className:"font-mono",children:b.calls}),(0,s.jsx)("dt",{className:"text-smoke",children:u("twinMemory.remainingCalls")}),(0,s.jsx)("dd",{className:"font-mono",children:b.remainingCalls})]}),b.contextOnly>0&&(0,s.jsx)("p",{className:"mt-2 text-xs text-smoke",children:u("twinMemory.contextOnly",{n:b.contextOnly})}),(null!=(t=b.retrying)?t:0)>0&&(0,s.jsx)("p",{className:"mt-2 text-xs text-smoke",children:u("twinMemory.learnRetrying",{n:null!=(n=b.retrying)?n:0})}),(b.provider||b.model)&&(0,s.jsx)("p",{className:"mt-3 break-words font-mono text-[11px] text-smoke",children:[b.provider,b.model].filter(Boolean).join(" / ")}),0===b.selected?(0,s.jsx)(o.pp,{variant:"note",className:"mt-3",title:u("twinMemory.nothingUnread")}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.rA,{type:"button",tone:"accent",className:"mt-4",busy:"learn"===w,busyLabel:u("twinMemory.learning"),disabled:null!==w||b.remainingCalls<b.calls,onClick:()=>void S("learn"),children:u("twinMemory.learn")}),(0,s.jsx)("p",{className:"mt-2 text-xs leading-relaxed text-smoke",children:u(b.remainingCalls<b.calls?"twinMemory.budgetShort":"twinMemory.learnCost")})]})]})]}),g&&(0,s.jsx)(o.lZ,{text:g,className:"mt-3"}),(0,s.jsx)("p",{role:"status","aria-live":"polite",className:"mt-3 text-xs leading-relaxed text-smoke",children:"learn"===w?u("twinMemory.extracting"):v})]})}function g(e){var t,n,a,w,f,b,y,g;let{episode:j,onRevise:v,previousAvailable:N,hasActiveSuccessor:k,onPrevious:M}=e,S=(0,r.kj)(),C=(0,r.Ym)(),L=(0,l.useRouter)(),{recorded:T,missing:O}=function(e){let t=d.filter(t=>{var n;return!!(null==(n=e.fields[t])?void 0:n.text.trim())});return{recorded:t,missing:d.filter(e=>!t.includes(e))}}(j),[P,R]=(0,i.useState)(null),[A,E]=(0,i.useState)(null),[I,U]=(0,i.useState)(null),[D,q]=(0,i.useState)(!1),[B,F]=(0,i.useState)(null),[z,Z]=(0,i.useState)(null),[_,J]=(0,i.useState)(j.validUntil),[H,G]=(0,i.useState)(null!=(a=null==(t=j.validUntil)?void 0:t.slice(0,10))?a:"");_!==j.validUntil&&(J(j.validUntil),G(null!=(f=null==(w=j.validUntil)?void 0:w.slice(0,10))?f:""));let W=(0,i.useRef)(!1),V=(0,i.useRef)(!1),Y=(0,i.useRef)(null),K=T.some(e=>{var t;return!!(null==(t=j.fields[e])?void 0:t.narrativeId)}),Q=null!=(b=m(j))?b:S("twinMemory.untitled"),X=e=>e.map(e=>S(c[e].label).toLocaleLowerCase()).join(", "),$="dismissed"===j.status&&!k,ee="active"===j.status&&k,et=u(j),en=j.validUntil?new Date(j.validUntil).toLocaleDateString(C,{timeZone:"UTC"}):null;async function es(){if(!W.current){W.current=!0,R("status"),E(null);try{await p("/api/twin/episodes",{id:j.id,status:"active"===j.status?"dismissed":"active",expectedUpdatedAt:j.updatedAt},S("twinMemory.requestFailed")),L.refresh()}catch(e){E(h(e,S))}finally{W.current=!1,R(null)}}}async function ei(e){if(!W.current){W.current=!0,R(null===e?"clearExpiry":"expiry"),E(null);try{await p("/api/twin/episodes",{id:j.id,validUntil:e,expectedUpdatedAt:j.updatedAt},S("twinMemory.requestFailed")),L.refresh()}catch(e){E(h(e,S))}finally{W.current=!1,R(null)}}}async function el(){if(null===I&&!V.current){V.current=!0,q(!0),F(null);try{let t=await fetch("/api/twin/episodes?id=".concat(encodeURIComponent(j.id))),n=await t.json();if(!t.ok||!Array.isArray(n.evidence)){var e;throw Error(null!=(e=n.error)?e:S("twinMemory.evidenceFailed"))}U(n.evidence)}catch(e){F(h(e,S))}finally{V.current=!1,q(!1)}}}return(0,i.useEffect)(()=>{var e;I&&z&&(null==(e=document.getElementById("episode-".concat(j.id,"-source-").concat(z)))||e.focus())},[I,j.id,z]),(0,s.jsxs)("li",{id:"episode-".concat(j.id),tabIndex:-1,className:"min-w-0 scroll-mt-24 rounded-lg border border-edge bg-ground p-4",children:[(0,s.jsxs)("p",{className:"flex flex-wrap gap-x-2 gap-y-1 font-mono text-[11px] text-smoke",children:[(0,s.jsx)("span",{children:S("owner"===j.origin?"twinMemory.byOwner":"twinMemory.fromHistory")}),(0,s.jsxs)("span",{children:["\xb7 ",null!=(y=j.projectName)?y:S(j.identity?"twinMemory.unlinkedProject":"twinMemory.noProject")]}),"dismissed"===j.status&&(0,s.jsxs)("span",{children:["\xb7 ",S("twinMemory.dismissed")]})]}),(0,s.jsx)("h4",{className:"mt-2 line-clamp-3 break-words text-sm font-medium leading-relaxed",children:Q}),j.supersedesId&&(0,s.jsx)("p",{className:"mt-2 text-xs text-smoke",children:N?(0,s.jsx)("a",{href:"#episode-".concat(j.supersedesId),onClick:M,className:"underline underline-offset-4",children:S("twinMemory.previousVersion")}):(0,s.jsxs)("a",{href:"/twin?episode=".concat(encodeURIComponent(j.supersedesId),"#episode-").concat(j.supersedesId),className:"underline underline-offset-4",children:[S("twinMemory.previousVersion")," ",(0,s.jsx)("span",{className:"sr-only",children:S("twinMemory.outsideView")})]})}),(0,s.jsx)("p",{className:"mt-3 font-mono text-[11px] text-smoke",children:S("twinMemory.recorded",{list:X(T)})}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-smoke",children:S("dismissed"===j.status?"twinMemory.reachNowhere":u(j)?"twinMemory.reachExpired":ee?"twinMemory.reachWithheld":"history"===j.origin?"twinMemory.reachLabOnly":(null==(g=j.fields.decision)?void 0:g.text.trim())?j.identity?"twinMemory.reachProject":"twinMemory.reachGeneral":"twinMemory.reachNoDecision")}),en&&(0,s.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-smoke",children:S(et?"twinMemory.expiredOn":"twinMemory.appliesThrough",{date:en})}),(0,s.jsxs)("details",{className:"mt-3",children:[(0,s.jsx)("summary",{className:"cursor-pointer text-xs font-medium underline-offset-4 hover:underline",children:S("twinMemory.explore")}),(0,s.jsx)("dl",{className:"mt-3 space-y-3",children:T.map(e=>{var t;return(0,s.jsxs)("div",{children:[(0,s.jsx)("dt",{className:"text-xs font-medium",children:S(c[e].label)}),(0,s.jsxs)("dd",{className:"mt-1 whitespace-pre-wrap break-words text-sm leading-relaxed text-smoke",children:[j.fields[e].text,(null==(t=j.fields[e])?void 0:t.narrativeId)&&(0,s.jsx)("button",{type:"button",className:"mt-1 block text-xs underline underline-offset-4","aria-label":S("twinMemory.viewSourceFor",{field:S(c[e].label).toLocaleLowerCase()}),onClick:()=>{var t;let n=j.fields[e].narrativeId;Y.current&&(Y.current.open=!0),Z(n),I&&(null==(t=document.getElementById("episode-".concat(j.id,"-source-").concat(n)))||t.focus()),el()},children:S("twinMemory.viewSource")})]})]},e)})}),O.length>0&&(0,s.jsx)("p",{className:"mt-4 border-t border-edge pt-3 text-xs leading-relaxed text-smoke",children:S("twinMemory.notRecorded",{list:X(O)})}),(0,s.jsxs)("div",{className:"mt-4 border-t border-edge pt-3",children:[(0,s.jsx)("p",{className:"text-xs font-medium",children:S("twinMemory.expiryTitle")}),(0,s.jsx)(o.D0,{label:S("twinMemory.validUntilLabel"),className:"mt-2",size:"sm",type:"date",value:H,disabled:null!==P,"aria-describedby":"episode-".concat(j.id,"-expiry-hint"),onChange:e=>G(e.target.value)}),(0,s.jsx)("p",{id:"episode-".concat(j.id,"-expiry-hint"),className:"mt-1 text-xs leading-relaxed text-smoke",children:S("twinMemory.validUntilHint")}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[(0,s.jsx)(o.rA,{type:"button",tone:"surface",busy:"expiry"===P,busyLabel:S("twinMemory.savingExpiry"),disabled:null!==P||!H||H===(null==(n=j.validUntil)?void 0:n.slice(0,10)),onClick:()=>void ei(H),children:S("twinMemory.saveExpiry")}),j.validUntil&&(0,s.jsx)(o.rA,{type:"button",tone:"plain",busy:"clearExpiry"===P,busyLabel:S("twinMemory.clearingExpiry"),disabled:null!==P,onClick:()=>void ei(null),children:S("twinMemory.clearExpiry")})]})]})]}),K&&(0,s.jsxs)("details",{ref:Y,className:"mt-3",onToggle:e=>{e.currentTarget.open&&el()},children:[(0,s.jsx)("summary",{className:"cursor-pointer text-xs font-medium underline-offset-4 hover:underline",children:S("twinMemory.viewEvidence")}),D&&(0,s.jsx)("p",{role:"status",className:"mt-2 text-xs text-smoke",children:S("twinMemory.loadingEvidence")}),B&&(0,s.jsxs)("div",{className:"mt-2",children:[(0,s.jsx)(o.lZ,{text:B}),(0,s.jsx)(o.rA,{type:"button",tone:"surface",className:"mt-2",onClick:()=>void el(),children:S("twinMemory.retryEvidence")})]}),I&&0===I.length&&(0,s.jsx)("p",{className:"mt-2 text-xs text-smoke",children:S("twinMemory.sourceGone")}),null==I?void 0:I.map(e=>{let t=x[e.kind];return(0,s.jsxs)("div",{id:"episode-".concat(j.id,"-source-").concat(e.id),tabIndex:-1,className:"mt-3 scroll-mt-24 rounded border border-edge bg-surface p-3",children:[(0,s.jsxs)("p",{className:"break-words font-mono text-[10px] text-smoke",children:[e.source," \xb7 ",t?S(t):e.kind," \xb7 ",e.at.slice(0,10)]}),(0,s.jsx)("p",{className:"mt-2 text-xs font-medium",children:S("brief"===e.kind?"twinMemory.briefText":"twinMemory.ownerText")}),(0,s.jsx)("blockquote",{className:"mt-1 whitespace-pre-wrap break-words text-xs leading-relaxed text-smoke",children:e.text}),e.truncated&&(0,s.jsx)("p",{className:"mt-2 text-xs text-smoke",children:S("twinMemory.truncated")}),e.context&&(0,s.jsxs)("details",{className:"mt-3 border-t border-edge pt-2",children:[(0,s.jsx)("summary",{className:"cursor-pointer text-xs text-smoke",children:S("twinMemory.agentContext")}),(0,s.jsx)("p",{className:"mt-2 whitespace-pre-wrap break-words text-xs leading-relaxed text-smoke",children:e.context})]})]},e.id)})]}),(0,s.jsxs)("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2 border-t border-edge pt-3",children:[(0,s.jsx)("time",{dateTime:j.createdAt,className:"font-mono text-[10px] text-smoke",children:j.createdAt.slice(0,10)}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(o.rA,{type:"button",tone:"surface",disabled:null!==P||k,onClick:v,children:S("twinMemory.revise")}),("active"===j.status||$)&&(0,s.jsx)(o.rA,{type:"button",tone:"plain",busy:"status"===P,busyLabel:S("twin.saving"),disabled:null!==P,onClick:()=>void es(),children:S("active"===j.status?"twinMemory.dismiss":"twinMemory.restore")})]})]}),k&&(0,s.jsxs)("p",{className:"mt-2 text-xs leading-relaxed text-smoke",children:[S(ee?"twinMemory.competingActive":"twinMemory.successorActive")," ",ee?(0,s.jsx)("a",{href:"#competing-versions",className:"underline underline-offset-4",children:S("twinMemory.competingOpen")}):(0,s.jsx)("a",{href:"/twin?episode=".concat(encodeURIComponent(j.activeRevisionId),"#episode-").concat(j.activeRevisionId),className:"underline underline-offset-4",children:S("twinMemory.currentVersion")})]}),A&&(0,s.jsx)(o.lZ,{text:A,className:"mt-2"})]})}},9144:(e,t,n)=>{"use strict";n.d(t,{I18nProvider:()=>o,Ym:()=>d,Zs:()=>c,kj:()=>m});var s=n(38657),i=n(32165),l=n(2575);let a=(0,i.createContext)("en"),r=(0,i.createContext)("panoma");function o(e){let{locale:t,cli:n,children:i}=e;return(0,s.jsx)(a.Provider,{value:t,children:(0,s.jsx)(r.Provider,{value:n,children:i})})}function d(){return(0,i.useContext)(a)}function c(){return(0,i.useContext)(r)}function m(){let e=(0,i.useContext)(a),t=(0,i.useContext)(r);return(0,i.useCallback)((n,s)=>(0,l.t)(e,n,{cli:t,...s}),[e,t])}},10354:(e,t,n)=>{"use strict";var s=n(61990);n.o(s,"usePathname")&&n.d(t,{usePathname:function(){return s.usePathname}}),n.o(s,"useRouter")&&n.d(t,{useRouter:function(){return s.useRouter}}),n.o(s,"useSearchParams")&&n.d(t,{useSearchParams:function(){return s.useSearchParams}})},15797:(e,t,n)=>{"use strict";n.d(t,{TwinSynthesize:()=>o});var s=n(38657),i=n(32165),l=n(10354),a=n(9144),r=n(52948);function o(e){let{pending:t,ready:n,compact:o}=e,d=(0,a.kj)(),c=(0,l.useRouter)(),[m,u]=(0,i.useState)(!1),[x,p]=(0,i.useState)(null);async function h(){u(!0),p(null);try{var e,n,s,i,l,a,r,o,m;let u=0;if(t>0){let t=await fetch("/api/twin/classify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),s=await t.json();if(!t.ok)return void p(null!=(e=s.error)?e:d("twin.synthFailed"));u+=null!=(n=s.truncated)?n:0}let x=await fetch("/api/twin/synthesize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),h=await x.json();if(!x.ok)return void p(null!=(s=h.error)?s:d("twin.synthFailed"));u+=null!=(i=h.truncated)?i:0;let w=null!=(l=h.created)?l:0,f=null!=(a=h.refined)?a:0,b=null!=(r=h.retired)?r:0,y=null!=(o=h.proposed)?o:0,g=w+f+b+y,j=null!=(m=h.unchanged)?m:0,v=0===h.topics?j>0?d("twin.synthUpToDate"):d("twin.synthNothing"):d("twin.synthSame"),N=d("twin.synthDone",{created:w,refined:f,retired:b}),k=0===g?v:0===y?N:"".concat(N," ").concat(d("twin.synthAsks",{n:y}));p(u>0?"".concat(k," ").concat(d("twin.synthTruncated",{n:u})):k),c.refresh()}catch(e){p(d("project.unreachable"))}finally{u(!1)}}return(0,s.jsxs)("div",{className:o?"flex items-center gap-2":"mt-3 flex flex-col gap-1",children:[(0,s.jsx)(r.rA,{tone:"plain",type:"button",onClick:h,busy:m,busyLabel:d("twin.synthesizing"),disabled:!n,"aria-describedby":n?void 0:"twin-synth-why",className:"self-start",children:d("twin.synthesize")}),n?(0,s.jsx)("div",{role:"status","aria-live":"polite",children:x?(0,s.jsx)("p",{className:"font-mono text-xs text-smoke",children:x}):o?null:(0,s.jsx)("p",{className:"text-xs leading-relaxed text-smoke",children:d("twin.synthHint")})}):(0,s.jsx)("p",{id:"twin-synth-why",className:"text-xs leading-relaxed text-smoke",children:d("twin.synthNothing")})]})}},18557:(e,t,n)=>{"use strict";n.d(t,{BeliefEditor:()=>c});var s=n(38657),i=n(32165),l=n(10354),a=n(9144),r=n(59916),o=n(52948);let d={signed:"twin.badgeSigned",standing:"twin.badgeStanding",forming:"twin.badgeForming"};function c(e){let{beliefs:t,graveyard:n,proposals:r,unpublished:d,locale:c}=e,h=(0,a.kj)(),w=(0,l.useRouter)(),[f,b]=(0,i.useState)(new Map),[y,g]=(0,i.useState)(new Map),[j,v]=(0,i.useState)(null),[N,k]=(0,i.useState)(!1),[M,S]=(0,i.useState)(null),C=(0,i.useMemo)(()=>{let e=new Map;for(let n of t){let t=e.get(n.topic);t?t.push(n):e.set(n.topic,[n])}return[...e]},[t]),L=f.size>0||y.size>0;function T(e,t){b(n=>{let s=new Map(n);return void 0===t?s.delete(e):s.set(e,t),s})}async function O(){k(!0),S(null);let e=[],t=[],n=[];for(let[s,i]of f)"sign"===i.kind?e.push({id:s,...i.statement?{statement:i.statement}:{}}):"veto"===i.kind?t.push(s):n.push({id:s,identity:i.identity});let s=[...y].map(e=>{let[t,n]=e;return{id:t,accept:n}});try{let l=await fetch("/api/twin/taste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sign:e,veto:t,scope:n,resolve:s})}),a=await l.json();if(!l.ok){var i;S(null!=(i=a.error)?i:String(l.status));return}b(new Map),g(new Map),v(null),w.refresh()}catch(e){S(h("project.unreachable"))}finally{k(!1)}}return(0,s.jsxs)(s.Fragment,{children:[r.length>0&&(0,s.jsxs)("section",{className:"mt-8",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:h("twin.proposalsTitle")}),(0,s.jsx)("p",{className:"mt-1 max-w-2xl text-sm leading-relaxed text-smoke",children:h("twin.proposalsNote")}),(0,s.jsx)("ul",{className:"mt-4 flex flex-col gap-3",role:"list",children:r.map(e=>{var t;return(0,s.jsxs)("li",{className:"rounded-lg border px-4 py-4 ".concat(y.has(e.id)?"border-l-2 border-l-chalk border-edge":"border-edge"),children:[(0,s.jsxs)("p",{className:"eyebrow",children:[m(e.topic,h),e.supersedes&&e.supersedes.length>1?" \xb7 ".concat(h("twin.proposalJoins",{n:e.supersedes.length})):""]}),null==(t=e.supersedes)?void 0:t.map(e=>(0,s.jsx)("p",{className:"mt-1 max-w-2xl text-sm leading-relaxed text-smoke line-through decoration-faint",children:e},e)),(0,s.jsx)("p",{className:"mt-2 max-w-2xl text-base leading-relaxed",children:e.statement}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[(0,s.jsx)(p,{label:h("twin.proposalAccept"),toggle:!0,active:!0===y.get(e.id),onClick:()=>g(u(y,e.id,!0))}),(0,s.jsx)(p,{label:h("twin.proposalReject"),toggle:!0,active:!1===y.get(e.id),onClick:()=>g(u(y,e.id,!1))})]})]},e.id)})})]}),C.map(e=>{let[t,n]=e;return(0,s.jsxs)("section",{className:"mt-8",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:m(t,h)}),(0,s.jsx)("ul",{className:"mt-4 flex flex-col gap-3",role:"list",children:n.map(e=>(0,s.jsx)(x,{belief:e,locale:c,gesture:f.get(e.id),stranded:"forming"!==e.badge&&d.has(e.id),editing:j===e.id,onEdit:t=>v(t?e.id:null),onGesture:t=>(function(e,t){let n=f.get(e),s=(null==n?void 0:n.kind)==="sign"&&void 0!==n.statement;n&&n.kind===t.kind&&!s?T(e,void 0):T(e,t)})(e.id,t),onWrite:t=>T(e.id,{kind:"sign",statement:t}),translate:h},e.id))})]},t)}),n.length>0&&(0,s.jsxs)("section",{className:"mt-8",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:h("twin.graveyardTitle")}),(0,s.jsx)("p",{className:"mt-1 max-w-2xl text-sm leading-relaxed text-smoke",children:h("twin.graveyardNote")}),(0,s.jsx)("ul",{className:"mt-4 flex flex-col gap-2",role:"list",children:n.map(e=>(0,s.jsx)("li",{className:"rounded-lg border border-edge px-4 py-3 opacity-60",children:(0,s.jsx)("p",{className:"text-sm leading-relaxed text-smoke line-through decoration-faint",children:e.statement})},e.id))})]}),L&&(0,s.jsxs)("div",{className:"sticky bottom-4 z-10 mt-8 flex flex-wrap items-center gap-3 rounded-lg border border-edge bg-surface/95 px-4 py-3 shadow-lg backdrop-blur",children:[(0,s.jsx)("span",{className:"font-mono text-xs text-smoke",children:h("twin.markedGestures",{n:f.size+y.size})}),(0,s.jsx)(o.rA,{tone:"accent",type:"button",onClick:O,busy:N,busyLabel:h("twin.saving"),children:h("twin.save")}),(0,s.jsx)(o.rA,{tone:"quiet",type:"button",onClick:()=>{b(new Map),g(new Map),v(null)},disabled:N,children:h("twin.cancel")}),M&&(0,s.jsx)("span",{className:"font-mono text-xs text-fail",children:h("twin.saveFailed",{detail:M})})]})]})}function m(e,t){let n=(0,r.Jj)(e);return n?t(n):e}function u(e,t,n){let s=new Map(e);return s.get(t)===n?s.delete(t):s.set(t,n),s}function x(e){let{belief:t,locale:n,gesture:l,stranded:a,editing:c,onEdit:m,onGesture:u,onWrite:x,translate:h}=e,[w,f]=(0,i.useState)(!1),[b,y]=(0,i.useState)(t.statement),g=(null==l?void 0:l.kind)==="sign"?l.statement:void 0;return(0,s.jsxs)("li",{id:"belief-".concat(t.id),tabIndex:-1,className:["scroll-mt-24 rounded-lg border px-4 py-4 transition-colors",(null==l?void 0:l.kind)==="sign"?"border-l-2 border-l-live border-edge bg-live/[0.05]":(null==l?void 0:l.kind)==="veto"?"border-l-2 border-l-faint border-edge opacity-60":void 0!==l?"border-l-2 border-l-chalk border-edge":"border-edge"].join(" "),children:[(0,s.jsxs)("p",{className:"eyebrow",children:[(0,s.jsx)("span",{className:"forming"===t.badge?"text-idle":"",children:h(d[t.badge])}),t.scope?" \xb7 ".concat(h("twin.scopedTag",{project:t.scope})):"",a?(0,s.jsx)("span",{className:"text-idle",children:" \xb7 ".concat(h("twin.notInFile"))}):null]}),a?(0,s.jsx)("p",{className:"mt-1 max-w-2xl text-xs leading-relaxed text-smoke",children:h("twin.notInFileWhy")}):null,c?(0,s.jsxs)("div",{className:"mt-2",children:[(0,s.jsx)(o.fs,{label:h("twin.editText"),hideLabel:!0,rows:3,className:"max-w-2xl",value:b,onChange:e=>y(e.target.value)}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap gap-2",children:[(0,s.jsx)(p,{label:h("twin.editSave"),active:!0,onClick:()=>{""!==b.trim()&&(x(b.trim()),m(!1))}}),(0,s.jsx)(p,{label:h("twin.cancel"),onClick:()=>{y(t.statement),m(!1)}})]})]}):(0,s.jsx)("p",{className:"mt-1 max-w-2xl text-base leading-relaxed",children:null!=g?g:t.statement}),(0,s.jsxs)("p",{className:"mt-2 font-mono text-xs text-smoke",children:[t.authored?h("twinTeach.ownerEvidence"):h("twin.support",{observations:t.support.observations,projects:t.support.projects,days:t.support.days}),"forming"===t.badge?(0,s.jsx)("span",{className:"text-idle",children:" \xb7 ".concat(h("twin.formingWhy"))}):null,t.citations.length>0&&(0,s.jsxs)(s.Fragment,{children:[" \xb7 ",(0,s.jsx)("button",{type:"button",onClick:()=>f(e=>!e),className:"underline-offset-2 hover:underline",children:h(w?"twin.hideCitations":"twin.showCitations",{n:t.citations.length})})]})]}),w&&(0,s.jsx)("ul",{className:"mt-3 flex flex-col gap-2.5 border-l border-edge pl-3",role:"list",children:t.citations.map(e=>(0,s.jsxs)("li",{children:[(0,s.jsxs)("p",{className:"line-clamp-2 text-sm italic leading-snug text-smoke",title:e.quote,children:["\xab",e.quote,"\xbb"]}),(0,s.jsxs)("p",{className:"mt-0.5 font-mono text-xs text-faint",children:[(0,r.mL)(e.at,n),e.project?" \xb7 ".concat(h("twin.citedIn",{project:e.project})):""]})]},e.verdictId))}),!c&&(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:["signed"!==t.badge&&(0,s.jsx)(p,{label:h("twin.sign"),toggle:!0,active:(null==l?void 0:l.kind)==="sign"&&void 0===g,onClick:()=>u({kind:"sign"})}),(0,s.jsx)(p,{label:h("twin.edit"),toggle:!0,active:void 0!==g,onClick:()=>{y(null!=g?g:t.statement),m(!0)}}),(0,s.jsx)(p,{label:h("twin.veto"),toggle:!0,active:(null==l?void 0:l.kind)==="veto",onClick:()=>u({kind:"veto"})}),t.scope?(0,s.jsx)(p,{label:h("twin.scopeAll"),toggle:!0,active:(null==l?void 0:l.kind)==="scope"&&null===l.identity,onClick:()=>u({kind:"scope",identity:null})}):t.learnedIn?(0,s.jsx)(p,{label:h("twin.scopeOnly",{project:t.learnedIn.name}),toggle:!0,active:(null==l?void 0:l.kind)==="scope",onClick:()=>{var e,n;return u({kind:"scope",identity:null!=(n=null==(e=t.learnedIn)?void 0:e.identity)?n:null})}}):null]})]})}function p(e){let{label:t,active:n,toggle:i=!1,onClick:l}=e;return(0,s.jsx)(o.rA,{tone:n?"accent":"plain",type:"button",...i?{"aria-pressed":null!=n&&n}:{},onClick:l,children:t})}},26488:(e,t,n)=>{"use strict";n.d(t,{P:()=>s,s:()=>i});let s=300,i=300},35823:(e,t,n)=>{Promise.resolve().then(n.bind(n,18557)),Promise.resolve().then(n.bind(n,66229)),Promise.resolve().then(n.bind(n,92458)),Promise.resolve().then(n.bind(n,3030)),Promise.resolve().then(n.bind(n,4733)),Promise.resolve().then(n.bind(n,88145)),Promise.resolve().then(n.bind(n,15797)),Promise.resolve().then(n.bind(n,73856)),Promise.resolve().then(n.t.bind(n,3953,23))},56684:(e,t,n)=>{"use strict";n.d(t,{k5:()=>c});var s=n(32165),i={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},l=s.createContext&&s.createContext(i),a=["attr","size","title"];function r(){return(r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)({}).hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(null,arguments)}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,s)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach(function(t){var s,i,l;s=e,i=t,l=n[t],(i=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(i))in s?Object.defineProperty(s,i,{value:l,enumerable:!0,configurable:!0,writable:!0}):s[i]=l}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function c(e){return t=>s.createElement(m,r({attr:d({},e.attr)},t),function e(t){return t&&t.map((t,n)=>s.createElement(t.tag,d({key:n},t.attr),e(t.child)))}(e.child))}function m(e){var t=t=>{var n,i=e.attr,l=e.size,o=e.title,c=function(e,t){if(null==e)return{};var n,s,i=function(e,t){if(null==e)return{};var n={};for(var s in e)if(({}).hasOwnProperty.call(e,s)){if(-1!==t.indexOf(s))continue;n[s]=e[s]}return n}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(s=0;s<l.length;s++)n=l[s],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(e,a),m=l||t.size||"1em";return t.className&&(n=t.className),e.className&&(n=(n?n+" ":"")+e.className),s.createElement("svg",r({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,i,c,{className:n,style:d(d({color:e.color||t.color},t.style),e.style),height:m,width:m,xmlns:"http://www.w3.org/2000/svg"}),o&&s.createElement("title",null,o),e.children)};return void 0!==l?s.createElement(l.Consumer,null,e=>t(e)):t(i)}},59916:(e,t,n)=>{"use strict";n.d(t,{Jj:()=>i,Wv:()=>s,mL:()=>l});let s={design:"twin.topicDesign",frontend:"twin.topicFrontend",backend:"twin.topicBackend",cli:"twin.topicCli",testing:"twin.topicTesting",copy:"twin.topicCopy",workflow:"twin.topicWorkflow",tooling:"twin.topicTooling",data:"twin.topicData",other:"twin.topicOther"};function i(e){return s[e]}function l(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e.slice(0,10);let s=String(n.getMonth()+1).padStart(2,"0"),i=String(n.getDate()).padStart(2,"0");return"en"===t?"".concat(n.getFullYear(),"-").concat(s,"-").concat(i):"".concat(i,"/").concat(s,"/").concat(n.getFullYear())}},66229:(e,t,n)=>{"use strict";n.d(t,{TwinConsent:()=>o});var s=n(38657),i=n(32165),l=n(10354),a=n(9144),r=n(52948);function o(e){let{standing:t,chars:n,cap:o}=e,d=(0,a.kj)(),c=(0,l.useRouter)(),[m,u]=(0,i.useState)(!1),[x,p]=(0,i.useState)(null);async function h(e){u(!0),p(null);try{var t;let n=await fetch("/api/twin/taste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({publishInferred:e})}),s=await n.json();n.ok||p(null!=(t=s.error)?t:String(n.status)),c.refresh()}catch(e){p(d("project.unreachable"))}finally{u(!1)}}return(0,s.jsxs)(r.Zp,{as:"section",tone:"plain",className:"mt-8","aria-labelledby":"twin-consent-title",children:[(0,s.jsx)("h2",{id:"twin-consent-title",className:"text-base font-semibold",children:d("twin.consentTitle")}),(0,s.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed",children:d("twin.consentBody")}),(0,s.jsxs)("p",{className:"mt-2 max-w-2xl font-mono text-xs ".concat(n>o?"text-idle":"text-smoke"),children:[d("twin.consentCount",{n:t,chars:n}),n>o?" \xb7 ".concat(d("twin.consentOver",{cap:o})):""]}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,s.jsx)(r.rA,{tone:"accent",type:"button",onClick:()=>h(!0),busy:m,busyLabel:d("twin.saving"),children:d("twin.consentAllow")}),(0,s.jsx)("span",{className:"font-mono text-xs text-faint",children:d("twin.consentRevoke")})]}),x&&(0,s.jsx)(r.lZ,{text:d("twin.saveFailed",{detail:x}),className:"mt-2"})]})}},73856:(e,t,n)=>{"use strict";n.d(t,{TwinTeach:()=>m});var s=n(38657),i=n(32165),l=n(10354),a=n(3043),r=n(9144),o=n(52948),d=n(59916),c=n(26488);function m(e){let{projects:t,omitted:n}=e,m=(0,r.kj)(),u=(0,l.useRouter)(),[x,p]=(0,i.useState)(""),[h,w]=(0,i.useState)("workflow"),[f,b]=(0,i.useState)(""),[y,g]=(0,i.useState)(!1),[j,v]=(0,i.useState)(null),[N,k]=(0,i.useState)(null),M=(0,i.useRef)(!1);async function S(e){if(e.preventDefault(),!M.current&&x.trim()){M.current=!0,g(!0),v(null),k(null);try{let e=await fetch("/api/twin/taste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({teach:{statement:x,topic:h,...f?{slug:f}:{}}})}),n=await e.json();if(!e.ok||!n.beliefId){var t;v(null!=(t=n.error)?t:m("twinTeach.failed"));return}p(""),k(n.beliefId),u.refresh()}catch(e){v(m("project.unreachable"))}finally{M.current=!1,g(!1)}}}return(0,s.jsx)("section",{id:"teach",tabIndex:-1,"aria-labelledby":"twin-teach-title",className:"page-shell__section scroll-mt-24 rounded-lg border border-edge bg-surface p-5 sm:p-6",children:(0,s.jsxs)("div",{className:"grid gap-6 lg:grid-cols-[1fr_1.4fr]",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"flex items-center gap-2 font-mono text-xs text-smoke",children:[(0,s.jsx)(a.YUE,{"aria-hidden":!0,className:"h-4 w-4"}),m("twinTeach.eyebrow")]}),(0,s.jsx)("h2",{id:"twin-teach-title",className:"mt-2 text-base font-semibold",children:m("twinTeach.title")}),(0,s.jsx)("p",{className:"mt-3 max-w-md text-sm leading-relaxed text-smoke",children:m("twinTeach.lead")}),(0,s.jsx)("p",{className:"mt-3 max-w-md text-xs leading-relaxed text-smoke",children:m("twinTeach.control")})]}),(0,s.jsxs)("form",{onSubmit:S,"aria-busy":y,children:[(0,s.jsx)(o.fs,{label:m("twinTeach.statement"),value:x,onChange:e=>{p(e.target.value),k(null)},required:!0,maxLength:c.P,rows:3,disabled:y,placeholder:m("twinTeach.placeholder"),"aria-describedby":"twin-teach-count"}),(0,s.jsx)("p",{id:"twin-teach-count",className:"mt-1 text-right font-mono text-xs text-smoke",children:m("twinTeach.characters",{n:x.length,max:c.P})}),(0,s.jsxs)("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[(0,s.jsx)(o.l6,{label:m("twinTeach.topic"),value:h,disabled:y,onChange:e=>w(e.target.value),children:Object.entries(d.Wv).map(e=>{let[t,n]=e;return(0,s.jsx)("option",{value:t,children:m(n)},t)})}),(0,s.jsxs)("div",{children:[(0,s.jsxs)(o.l6,{label:m("twinTeach.scope"),value:f,disabled:y,"aria-describedby":n>0?"twin-teach-scope-note":void 0,onChange:e=>b(e.target.value),children:[(0,s.jsx)("option",{value:"",children:m("twinTeach.global")}),t.map(e=>(0,s.jsx)("option",{value:e.slug,children:e.label},e.slug))]}),n>0&&(0,s.jsx)("p",{id:"twin-teach-scope-note",className:"mt-2 text-xs leading-relaxed text-smoke",children:m("twinTeach.scopeOmitted",{n:n})})]})]}),(0,s.jsxs)("div",{className:"mt-4 flex flex-wrap items-center gap-3",children:[(0,s.jsx)(o.rA,{type:"submit",tone:"accent",busy:y,busyLabel:m("twinTeach.saving"),disabled:y||!x.trim(),children:m("twinTeach.save")}),(0,s.jsx)("span",{className:"text-xs text-smoke",children:m("twinTeach.cost")})]}),j&&(0,s.jsx)(o.lZ,{text:j,className:"mt-3"}),(0,s.jsx)("div",{role:"status","aria-live":"polite",children:N&&(0,s.jsxs)("p",{className:"mt-3 text-sm text-smoke",children:[m("twinTeach.saved")," "," ",(0,s.jsx)("a",{href:"#belief-".concat(N),className:"underline underline-offset-4",children:m("twinTeach.view")})]})})]})]})})}},88145:(e,t,n)=>{"use strict";n.d(t,{TwinSources:()=>o});var s=n(38657),i=n(32165),l=n(10354),a=n(9144),r=n(52948);function o(e){let{sources:t}=e,n=(0,a.kj)(),o=(0,l.useRouter)(),[d,c]=(0,i.useState)(null),[m,u]=(0,i.useState)(null),[x,p]=(0,i.useState)(t);async function h(e,t){c(e),u(null);try{let n=await fetch("/api/twin/sources",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:e,allowed:t})}),i=await n.json();if(!n.ok){var s;u(null!=(s=i.error)?s:String(n.status));return}i.sources&&p(i.sources),o.refresh()}catch(e){u(n("project.unreachable"))}finally{c(null)}}let w=x.filter(e=>"absent"!==e.state);return 0===w.length?(0,s.jsxs)(r.Zp,{as:"section",tone:"plain","aria-labelledby":"twin-sources-title",children:[(0,s.jsx)("h2",{id:"twin-sources-title",className:"text-base font-semibold",children:n("twin.sourcesTitle")}),(0,s.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed",children:n("twin.sourcesNone")})]}):(0,s.jsxs)(r.Zp,{as:"section",tone:"plain","aria-labelledby":"twin-sources-title",children:[(0,s.jsx)("h2",{id:"twin-sources-title",className:"text-base font-semibold",children:n("twin.sourcesTitle")}),(0,s.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed",children:n("twin.sourcesLead")}),(0,s.jsx)("div",{className:"mt-3 flex flex-col gap-2",children:w.map(e=>(0,s.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 gap-y-1",children:[(0,s.jsxs)("span",{className:"min-w-0",children:[(0,s.jsx)("span",{className:"font-mono text-xs",children:e.label})," ",(0,s.jsx)("span",{className:"font-mono text-xs text-smoke",children:e.present?n("twin.sourceSize",{files:e.files,size:(0,r.z3)(e.bytes)}):n("twin.sourceGone")})]}),"noReader"===e.state?(0,s.jsx)("span",{className:"justify-self-end font-mono text-xs text-idle",children:n("twin.sourceNoReader")}):(0,s.jsx)(r.rA,{tone:"allowed"===e.state?"plain":"accent",type:"button",onClick:()=>h(e.id,"allowed"!==e.state),busy:d===e.id,busyLabel:n("twin.saving"),disabled:null!==d,className:"justify-self-end",children:n("allowed"===e.state?"twin.sourceRevoke":"twin.sourceAllow")})]},e.id))}),(0,s.jsx)("p",{className:"mt-3 max-w-2xl font-mono text-xs text-faint",children:n("twin.sourcesRevokeNote")}),m&&(0,s.jsx)(r.lZ,{text:m,className:"mt-2"})]})}},92458:(e,t,n)=>{"use strict";n.d(t,{TwinDistill:()=>o});var s=n(38657),i=n(32165),l=n(10354),a=n(9144),r=n(52948);function o(e){let{left:t,granted:n}=e,o=(0,a.kj)(),m=(0,l.useRouter)(),[u,x]=(0,i.useState)(!1),[p,h]=(0,i.useState)(null),[w,f]=(0,i.useState)(null);async function b(){x(!0),h(null),f(null);try{var e,t,n,s,i,l,a,r;h(o("twin.mining"));let u=await d();if(u.unreachable)h(o("project.unreachable"));else if(void 0!==u.error){if(h(u.error),u.blocked)return}else{let a=null!=(t=u.saved)?t:0,r=null!=(n=null==(e=u.denied)?void 0:e.length)?n:0,d=[0===a?o("twin.minedNone"):o("twin.mined",{saved:a,duplicates:null!=(s=u.duplicates)?s:0})];(null!=(i=u.narrativesSaved)?i:0)>0&&d.push(o("twin.minedRecords",{n:null!=(l=u.narrativesSaved)?l:0})),r>0&&d.push(o("twin.minedDenied",{n:r})),h(d.join(" \xb7 "))}let x=await c({dryRun:!0});if(x.error)return void h(x.hint?"".concat(x.error," ").concat(x.hint):x.error);if(!x.verdicts)return void h(o("twin.distillNothing"));f({verdicts:x.verdicts,tokens:null!=(a=x.estimatedTokens)?a:0}),h(o("twin.distillEstimate",{verdicts:x.verdicts,tokens:null!=(r=x.estimatedTokens)?r:0})),m.refresh()}catch(e){h(o("project.unreachable"))}finally{x(!1)}}async function y(){x(!0),f(null);try{let i=0,l=0,a=0;for(let r=1;r<=20;r+=1){var e,t,n,s;let r=await c({});if(i+=null!=(e=r.verdicts)?e:0,l+=null!=(t=r.saved)?t:0,a+=null!=(n=r.truncated)?n:0,r.error){h(r.hint?"".concat(r.error," ").concat(r.hint):r.error);break}let d=r.corpus?Math.max(r.corpus.total-r.corpus.read,0):0,m=null!=(s=r.thin)?s:0,u=[o("twin.distillProgress",{read:i,saved:l,left:d})];if(m>0&&u.push(o("twin.distillThin",{n:m})),a>0&&u.push(o("twin.distillTruncated",{n:a})),h(u.join(" \xb7 ")),!r.verdicts||d<=0)break}m.refresh()}catch(e){h(o("project.unreachable"))}finally{x(!1)}}return(0,s.jsxs)("div",{className:"mt-2 flex flex-col gap-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(r.rA,{tone:"plain",type:"button",onClick:b,busy:u&&null===w,busyLabel:o("twin.distilling"),disabled:!n||u,"aria-describedby":n?void 0:"twin-distill-why",className:"self-start",children:t>0?o("twin.mineButtonLeft",{n:t}):o("twin.mineButton")}),null!==w&&(0,s.jsx)(r.rA,{tone:"accent",type:"button",onClick:y,busy:u,busyLabel:o("twin.distillingPaid"),disabled:u,children:o("twin.distillGo",{n:w.verdicts})})]}),n&&(0,s.jsx)("p",{className:"text-xs leading-relaxed text-smoke",children:o("twin.distillCost")}),!n&&(0,s.jsx)("p",{id:"twin-distill-why",className:"text-xs leading-relaxed text-smoke",children:o("twin.distillNoConsent")}),(0,s.jsx)("div",{role:"status","aria-live":"polite",children:p&&(0,s.jsx)("p",{className:"font-mono text-xs text-smoke",children:p})})]})}async function d(){try{var e;let t=await fetch("/api/twin/mine",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),n=await t.json();if(t.ok)return n;return{error:null!=(e=n.error)?e:String(t.status),...409===t.status?{blocked:!0}:{}}}catch(e){return{unreachable:!0}}}async function c(e){var t;let n=await fetch("/api/twin/distill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await n.json();return n.ok?s:{...s,error:null!=(t=s.error)?t:String(n.status)}}}},e=>{e.O(0,[6587,3953,2575,2948,1305,6823,7358],()=>e(e.s=35823)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1162],{3030:(e,t,n)=>{"use strict";n.d(t,{TwinLab:()=>c});var s=n(38657),i=n(32165),l=n(3043),a=n(9144),r=n(26488),o=n(52948),d=n(59916);function c(e){let{projects:t,hasBeliefs:n}=e,c=(0,a.kj)(),[u,x]=(0,i.useState)(""),[p,h]=(0,i.useState)(""),[w,f]=(0,i.useState)(null),[b,y]=(0,i.useState)(null),[g,j]=(0,i.useState)(null),[v,N]=(0,i.useState)(null),k=(0,i.useRef)(!1),M=t.find(e=>e.slug===p);function S(){y(null),j(null)}async function C(e){if(k.current)return;let t=u.trim();if(!t||t.length>r.s)return void j(c("twinLab.invalidRequest",{max:r.s}));if(e||(null==b?void 0:b.status)==="preview"&&b.evidence.length){k.current=!0,f(e?"preview":"draft"),j(null),e&&y(null);try{let s=await fetch("/api/twin/rehearse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({question:t,...p?{slug:p}:{},dryRun:e})}),i=await s.json();if("number"==typeof i.remainingCalls&&N(i.remainingCalls),!s.ok){var n;j(429===s.status?c("twinLab.budgetReached"):[null!=(n=i.error)?n:c("twinLab.failed"),i.hint].filter(Boolean).join(" "));return}if(!Array.isArray(i.evidence)||!["preview","drafted","abstained"].includes(i.status))return void j(c("twinLab.failed"));y(i)}catch(e){j(c("project.unreachable"))}finally{k.current=!1,f(null)}}}let L=(null==b?void 0:b.reason)==="no-beliefs"?"twinLab.noBeliefs":(null==b?void 0:b.reason)==="no-match"?"twinLab.noMatch":"twinLab.unsupported";return(0,s.jsxs)("section",{id:"decision-lab",tabIndex:-1,"aria-labelledby":"twin-lab-title",className:"page-shell__section scroll-mt-24 rounded-lg border border-edge bg-surface",children:[(0,s.jsxs)("div",{className:"border-b border-edge px-5 py-5 sm:px-6",children:[(0,s.jsxs)("p",{className:"flex items-center gap-2 font-mono text-xs text-smoke",children:[(0,s.jsx)(l.qRK,{"aria-hidden":!0,className:"h-4 w-4"}),c("twinLab.eyebrow")]}),(0,s.jsx)("h2",{id:"twin-lab-title",className:"mt-2 text-base font-semibold",children:c("twinLab.title")}),(0,s.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-smoke",children:c("twinLab.lead")})]}),(0,s.jsxs)("div",{className:"grid lg:grid-cols-2",children:[(0,s.jsxs)("form",{onSubmit:function(e){e.preventDefault(),C(!0)},className:"min-w-0 px-5 py-5 sm:px-6","aria-busy":null!==w,children:[(0,s.jsx)(o.fs,{label:c("twinLab.question"),value:u,onChange:e=>{x(e.target.value),S()},maxLength:r.s,rows:4,required:!0,disabled:null!==w||!n,"aria-describedby":"twin-lab-question-hint twin-lab-count".concat(n?"":" twin-lab-untrained"),placeholder:c("twinLab.placeholder")}),!n&&(0,s.jsx)("p",{id:"twin-lab-untrained",className:"mt-2 text-xs leading-relaxed text-smoke",children:c("twinLab.firstTitle")}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap justify-between gap-2 text-xs text-smoke",children:[(0,s.jsx)("p",{id:"twin-lab-question-hint",children:c("twinLab.questionHint")}),(0,s.jsx)("p",{id:"twin-lab-count",className:"font-mono",children:c("twinLab.characters",{n:u.length,max:r.s})})]}),(0,s.jsxs)(o.l6,{label:c("twinLab.project"),className:"mt-5",value:p,onChange:e=>{h(e.target.value),S()},disabled:null!==w||!n,"aria-describedby":"twin-lab-scope-hint",children:[(0,s.jsx)("option",{value:"",children:c("twinLab.global")}),t.map(e=>(0,s.jsx)("option",{value:e.slug,children:e.label},e.slug))]}),(0,s.jsx)("p",{id:"twin-lab-scope-hint",className:"mt-2 text-xs leading-relaxed text-smoke",children:c("twinLab.scopeHint")}),(0,s.jsxs)("div",{className:"mt-5 flex flex-wrap items-center gap-3",children:[(0,s.jsx)(o.rA,{type:"submit",tone:"surface",busy:"preview"===w,busyLabel:c("twinLab.previewing"),disabled:null!==w||!u.trim()||!n,children:c("twinLab.preview")}),(0,s.jsx)("span",{className:"text-xs text-smoke",children:c("twinLab.previewCost")})]}),g&&(0,s.jsx)(o.lZ,{text:g,className:"mt-4"})]}),(0,s.jsxs)("div",{className:"min-w-0 border-t border-edge bg-ground px-5 py-5 sm:px-6 lg:border-t-0 lg:border-l",children:[(0,s.jsx)("p",{role:"status","aria-live":"polite",className:"font-mono text-xs text-smoke",children:"preview"===w?c("twinLab.previewing"):"draft"===w?c("twinLab.drafting"):(null==b?void 0:b.status)==="drafted"?c("twinLab.draftReady"):(null==b?void 0:b.status)==="abstained"?c("twinLab.abstained"):(null==b?void 0:b.status)==="preview"?c("twinLab.evidenceCount",{n:b.evidence.length}):c("twinLab.waiting")}),!b&&(0,s.jsx)(o.pp,{variant:"bare",className:"mt-4 max-w-md",title:c(n?"twinLab.emptyTitle":"twinLab.firstTitle"),action:!n&&(0,s.jsx)(m,{}),children:c(n?"twinLab.emptyBody":"twinLab.noBeliefs")}),(null==b?void 0:b.status)==="abstained"&&(0,s.jsxs)("div",{className:"mt-3",children:[(0,s.jsx)("h3",{className:"text-base font-semibold",children:c("twinLab.abstainedTitle")}),(0,s.jsx)("p",{className:"mt-2 text-sm leading-relaxed text-smoke",children:c(L)}),(0,s.jsx)(m,{className:"mt-3"})]}),(null==b?void 0:b.status)==="drafted"&&(0,s.jsxs)(o.Zp,{className:"mt-3",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:c("twinLab.draftTitle")}),(0,s.jsx)("p",{className:"mt-2 whitespace-pre-wrap break-words text-base leading-relaxed",children:b.answer}),(0,s.jsx)("p",{className:"mt-3 text-xs leading-relaxed text-smoke",children:c("twinLab.draftHint")}),(0,s.jsx)("p",{className:"mt-3 text-xs leading-relaxed text-smoke",children:c("twinLab.disagree")}),(0,s.jsx)(m,{className:"mt-3"})]}),b&&b.evidence.length>0&&(0,s.jsxs)("div",{className:"mt-4",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:c("drafted"===b.status?"twinLab.citations":"twinLab.evidence")}),(0,s.jsx)("ol",{className:"mt-3 flex flex-col gap-2",role:"list",children:b.evidence.map((e,t)=>{var n;let i=(0,d.Jj)(e.topic);return(0,s.jsxs)(o.Zp,{as:"li",pad:"sm",children:[(0,s.jsxs)("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 font-mono text-[11px] text-smoke",children:[(0,s.jsx)("span",{"aria-hidden":!0,children:String(t+1).padStart(2,"0")}),(0,s.jsx)("span",{children:c("episode"===e.kind?"twinLab.episode":"signed"===e.state?"twin.badgeSigned":"twin.badgeStanding")}),"episode"!==e.kind&&(0,s.jsxs)("span",{children:["\xb7 ",i?c(i):e.topic]})]}),(0,s.jsxs)("a",{href:"episode"===e.kind?"/twin?episode=".concat(encodeURIComponent(e.id),"#episode-").concat(e.id):"#belief-".concat(e.id),className:"mt-1.5 flex items-start gap-2 text-sm leading-relaxed underline-offset-4 hover:underline",children:[(0,s.jsx)("span",{className:"min-w-0 flex-1 whitespace-pre-line break-words",children:e.statement}),(0,s.jsx)(l.OvC,{"aria-hidden":!0,className:"mt-0.5 h-4 w-4 shrink-0 text-smoke"}),(0,s.jsx)("span",{className:"sr-only",children:c("episode"===e.kind?"twinLab.openEpisode":"twinLab.openEvidence")})]}),(0,s.jsx)("p",{className:"mt-2 text-xs text-smoke",children:"episode"===e.kind?c("twinLab.episodeScope"):e.scope?c("twinLab.projectRule",{project:null!=(n=null==M?void 0:M.label)?n:e.scope}):c("twinLab.globalRule")})]},e.id)})})]}),b&&b.omittedBeliefs>0&&(0,s.jsx)("p",{className:"mt-3 font-mono text-xs text-smoke",children:c("twinLab.omitted",{n:b.omittedBeliefs})}),null!==v&&(0,s.jsx)("p",{className:"mt-3 font-mono text-xs text-smoke",children:c("twinLab.remaining",{n:v})}),(null==b?void 0:b.status)==="preview"&&b.evidence.length>0&&(0,s.jsxs)("div",{className:"mt-5 border-t border-edge pt-4",children:[(0,s.jsx)(o.rA,{type:"button",tone:"accent",busy:"draft"===w,busyLabel:c("twinLab.drafting"),disabled:null!==w||0===v,onClick:()=>void C(!1),children:c("twinLab.rehearse")}),(0,s.jsx)("p",{className:"mt-2 text-xs leading-relaxed text-smoke",children:c(0===v?"twinLab.budgetReached":"twinLab.draftCost")})]})]})]}),(0,s.jsx)("p",{className:"border-t border-edge px-5 py-3 text-xs leading-relaxed text-smoke sm:px-6",children:c("twinLab.boundary")})]})}function m(e){let{className:t}=e,n=(0,a.kj)();return(0,s.jsxs)("a",{href:"#teach",className:"inline-flex items-center gap-1 text-sm underline underline-offset-4".concat(t?" ".concat(t):""),children:[n("twinLab.teach"),(0,s.jsx)(l.OvC,{"aria-hidden":!0,className:"h-4 w-4"})]})}},4733:(e,t,n)=>{"use strict";n.d(t,{TwinMemory:()=>w});var s=n(38657),i=n(32165),l=n(10354),a=n(3043),r=n(9144),o=n(52948);let d=["goal","context","constraints","alternatives","decision","rationale","outcome","conditions","exceptions"],c={goal:{label:"twinMemory.fieldGoal",hint:"twinMemory.hintGoal"},context:{label:"twinMemory.fieldContext",hint:"twinMemory.hintContext"},constraints:{label:"twinMemory.fieldConstraints",hint:"twinMemory.hintConstraints"},alternatives:{label:"twinMemory.fieldAlternatives",hint:"twinMemory.hintAlternatives"},decision:{label:"twinMemory.fieldDecision",hint:"twinMemory.hintDecision"},rationale:{label:"twinMemory.fieldRationale",hint:"twinMemory.hintRationale"},outcome:{label:"twinMemory.fieldOutcome",hint:"twinMemory.hintOutcome"},conditions:{label:"twinMemory.fieldConditions",hint:"twinMemory.hintConditions"},exceptions:{label:"twinMemory.fieldExceptions",hint:"twinMemory.hintExceptions"}};function m(e){var t,n,s;return(null==(t=e.fields.decision)?void 0:t.text.trim())||(null==(n=e.fields.goal)?void 0:n.text.trim())||(null==(s=e.fields.context)?void 0:s.text.trim())||null}function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();return null!==e.validUntil&&Date.parse(e.validUntil)<=t}let x={opening:"twinMemory.kindOpening",reaction:"twinMemory.kindReaction",brief:"twinMemory.kindBrief"};async function p(e,t,n){let s=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),i=await s.json();if(!s.ok){var l;throw Error([null!=(l=i.error)?l:n,i.hint].filter(Boolean).join(" "))}return i}function h(e,t){return e instanceof Error?e.message:t("project.unreachable")}function w(e){var t;let{projects:n,episodes:l,coverage:d,dailyCalls:c,focusId:m,olderCursor:u,conflicts:x}=e,p=(0,r.kj)(),w=(null==(t=l.find(e=>e.id===m))?void 0:t.status)==="dismissed",[j,v]=(0,i.useState)(w),[N,k]=(0,i.useState)(null),[M,S]=(0,i.useState)(null),[C,L]=(0,i.useState)(null),[T,O]=(0,i.useState)(null),P=(0,i.useRef)(!1),[R,A]=(0,i.useState)(l),[E,I]=(0,i.useState)(l),[U,D]=(0,i.useState)(u),[q,B]=(0,i.useState)(""),[F,z]=(0,i.useState)(""),[Z,_]=(0,i.useState)(null),[J,H]=(0,i.useState)(null),G=(0,i.useRef)(!1);R!==l&&(A(l),I(l),D(u));let W=E.filter(e=>j||"active"===e.status),V=E.filter(e=>"dismissed"===e.status).length;function Y(e){var t,s;return{...e,projectName:e.identity&&null!=(s=null==(t=n.find(t=>t.identity===e.identity))?void 0:t.label)?s:null}}async function K(e,t){var n,s;let i=new URLSearchParams;e&&i.set("q",e),t&&i.set("before",t);let l=i.toString(),a=await fetch("/api/twin/episodes".concat(l?"?".concat(l):"")),r=await a.json();if(!a.ok||!Array.isArray(r.episodes))throw Error(null!=(n=r.error)?n:p("twinMemory.requestFailed"));return{episodes:r.episodes.map(Y),nextCursor:null!=(s=r.nextCursor)?s:null}}async function Q(e){if(G.current)return;let t=e.trim();if(!t){z(""),I(l),D(u),H(null);return}G.current=!0,_("search"),H(null);try{let e=await K(t,null);z(t),I(e.episodes),D(e.nextCursor)}catch(e){H(h(e,p))}finally{G.current=!1,_(null)}}async function X(){if(!G.current&&U){G.current=!0,_("older"),H(null);try{let e=await K(F,U);I(t=>{let n=new Set(t.map(e=>e.id));return[...t,...e.episodes.filter(e=>!n.has(e.id))]}),D(e.nextCursor)}catch(e){H(h(e,p))}finally{G.current=!1,_(null)}}}return(0,i.useEffect)(()=>{var e;m&&(w&&v(!0),O(m),null==(e=document.getElementById("episode-".concat(m)))||e.focus())},[m,w]),(0,i.useEffect)(()=>{var e;T&&(null==(e=document.getElementById("episode-".concat(T)))||e.focus())},[T,j]),(0,i.useEffect)(()=>{F&&Q(F)},[l]),(0,s.jsxs)("section",{id:"decision-memory",tabIndex:-1,"aria-labelledby":"twin-memory-title",className:"page-shell__section scroll-mt-24 overflow-hidden rounded-lg border border-edge bg-surface",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4 border-b border-edge px-5 py-5 sm:px-6",children:[(0,s.jsxs)("div",{className:"max-w-2xl",children:[(0,s.jsxs)("p",{className:"flex items-center gap-2 font-mono text-xs text-smoke",children:[(0,s.jsx)(a.lPA,{"aria-hidden":!0,className:"h-4 w-4"}),p("twinMemory.eyebrow")]}),(0,s.jsx)("h2",{id:"twin-memory-title",className:"mt-2 text-base font-semibold",children:p("twinMemory.title")}),(0,s.jsx)("p",{className:"mt-2 text-sm leading-relaxed text-smoke",children:p("twinMemory.lead")})]}),(0,s.jsxs)("div",{className:"rounded-lg border border-edge bg-ground px-3 py-2 font-mono text-xs text-smoke",children:[(0,s.jsx)("p",{children:p("twinMemory.captured",{n:d.total})}),(0,s.jsx)("p",{className:"mt-1",children:p("twinMemory.awaiting",{n:d.pending})})]})]}),(0,s.jsxs)("div",{className:"grid lg:grid-cols-[1.3fr_1fr]",children:[(0,s.jsx)(b,{projects:n,revision:N,blocked:M,dirty:P,savedMessage:C,onCancel:()=>{k(null),S(null),L(null)},onClear:()=>{k(M),S(null)},onSaved:()=>{L(p(N?"twinMemory.savedRevision":"twinMemory.savedNew")),k(null),S(null)}}),(0,s.jsx)(y,{pendingCount:d.pending,deferred:d.deferred,dailyCalls:c})]}),x.length>0&&(0,s.jsxs)("div",{id:"competing-versions",tabIndex:-1,"aria-labelledby":"twin-competing-title",className:"scroll-mt-24 border-t border-edge px-5 py-5 sm:px-6",children:[(0,s.jsx)("h3",{id:"twin-competing-title",className:"text-base font-semibold",children:p("twinMemory.competingTitle")}),(0,s.jsx)("p",{className:"mt-2 max-w-2xl text-xs leading-relaxed text-smoke",children:p("twinMemory.competingLead")}),(0,s.jsx)("p",{className:"mt-2 font-mono text-xs text-smoke",children:p("twinMemory.competingFamilies",{n:x.length})}),(0,s.jsx)("ul",{className:"mt-4 grid items-start gap-3 xl:grid-cols-2",role:"list",children:x.map(e=>(0,s.jsx)(f,{family:e},e.map(e=>e.id).join(",")))})]}),(0,s.jsxs)("div",{className:"border-t border-edge px-5 py-5 sm:px-6",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,s.jsx)("h3",{className:"text-base font-semibold",children:p("twinMemory.recentTitle")}),V>0&&(0,s.jsx)(o.Jl,{size:"sm",checked:j,onChange:e=>v(e.target.checked),children:p("twinMemory.includeDismissed",{n:V})})]}),(0,s.jsxs)("form",{role:"search","aria-busy":"search"===Z,className:"mt-3 flex flex-wrap items-end gap-2",onSubmit:e=>{e.preventDefault(),Q(q)},children:[(0,s.jsx)(o.D0,{label:p("twinMemory.searchLabel"),className:"min-w-0 grow sm:max-w-md",type:"search",value:q,maxLength:200,disabled:null!==Z,"aria-describedby":"memory-search-hint",onChange:e=>{B(e.target.value),!e.target.value.trim()&&F&&Q("")}}),(0,s.jsx)(o.rA,{type:"submit",tone:"surface",busy:"search"===Z,busyLabel:p("twinMemory.searching"),disabled:null!==Z,children:p("twinMemory.search")}),F&&(0,s.jsx)(o.rA,{type:"button",tone:"plain",disabled:null!==Z,onClick:()=>{B(""),Q("")},children:p("twinMemory.clearSearch")})]}),(0,s.jsx)("p",{id:"memory-search-hint",className:"mt-1 text-xs leading-relaxed text-smoke",children:p("twinMemory.searchHint")}),J&&(0,s.jsx)(o.lZ,{text:J,className:"mt-2"}),(0,s.jsx)("p",{className:"mt-3 text-xs text-smoke",children:F?p("twinMemory.shownMatches",{query:F,n:W.length}):p("twinMemory.shown",{n:W.length})}),0===W.length&&F?(0,s.jsx)(o.pp,{variant:"note",role:"status",className:"mt-4",title:p("twinMemory.noMatches",{query:F})}):0===W.length?(0,s.jsx)(o.pp,{className:"mt-4",title:p("twinMemory.emptyTitle"),children:p("twinMemory.emptyBody")}):(0,s.jsx)("ul",{className:"mt-4 grid items-start gap-3 xl:grid-cols-2",role:"list",children:W.map(e=>(0,s.jsx)(g,{episode:e,previousAvailable:!!(e.supersedesId&&E.some(t=>t.id===e.supersedesId)),hasActiveSuccessor:!!e.activeRevisionId,onPrevious:()=>{var t,n;v(!0),O(null!=(n=e.supersedesId)?n:null),null==(t=document.getElementById("episode-".concat(e.supersedesId)))||t.focus()},onRevise:()=>{var t;L(null),e.id!==(null==N?void 0:N.id)&&(P.current?S(e):(S(null),k(e))),null==(t=document.getElementById("memory-capture-form"))||t.scrollIntoView({block:"start",behavior:"instant"})}},e.id))}),U&&(0,s.jsx)(o.rA,{type:"button",tone:"surface",className:"mt-4",busy:"older"===Z,busyLabel:p("twinMemory.loadingOlder"),disabled:null!==Z,onClick:()=>void X(),children:p("twinMemory.loadOlder")}),(0,s.jsx)("p",{className:"mt-4 text-xs leading-relaxed text-smoke",children:p("twinMemory.boundary")})]})]})}function f(e){let{family:t}=e,n=(0,r.kj)(),a=(0,l.useRouter)(),[d,c]=(0,i.useState)(null),[u,x]=(0,i.useState)(null),w=(0,i.useRef)(!1);async function f(e){if(w.current)return;w.current=!0,c(e.id),x(null);let s=!1;try{for(let i of t)i.id!==e.id&&(await p("/api/twin/episodes",{id:i.id,status:"dismissed",expectedUpdatedAt:i.updatedAt},n("twinMemory.requestFailed")),s=!0)}catch(e){x(h(e,n))}finally{w.current=!1,c(null),s&&a.refresh()}}return(0,s.jsxs)("li",{className:"min-w-0 rounded-lg border border-edge bg-ground p-4",children:[(0,s.jsx)("ol",{className:"space-y-3",role:"list",children:t.map(e=>{var t,i;return(0,s.jsxs)("li",{className:"flex flex-wrap items-start justify-between gap-3 border-t border-edge pt-3 first:border-t-0 first:pt-0",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("p",{className:"flex flex-wrap gap-x-2 gap-y-1 font-mono text-[11px] text-smoke",children:[(0,s.jsx)("span",{children:n("owner"===e.origin?"twinMemory.byOwner":"twinMemory.fromHistory")}),(0,s.jsxs)("span",{children:["\xb7 ",null!=(t=e.projectName)?t:n(e.identity?"twinMemory.unlinkedProject":"twinMemory.noProject")]}),(0,s.jsxs)("time",{dateTime:e.createdAt,children:["\xb7 ",e.createdAt.slice(0,10)]})]}),(0,s.jsx)("p",{className:"mt-1 line-clamp-3 break-words text-sm leading-relaxed",children:null!=(i=m(e))?i:n("twinMemory.untitled")}),(0,s.jsx)("a",{href:"#episode-".concat(e.id),className:"mt-1 inline-block text-xs underline underline-offset-4",children:n("twinMemory.explore")})]}),(0,s.jsx)(o.rA,{type:"button",tone:"surface",busy:d===e.id,busyLabel:n("twinMemory.keeping"),disabled:null!==d,onClick:()=>void f(e),children:n("twinMemory.keepThis")})]},e.id)})}),u&&(0,s.jsx)(o.lZ,{text:u,className:"mt-3"})]})}function b(e){var t,n,a,m,u;let{projects:x,revision:w,blocked:f,dirty:b,savedMessage:y,onSaved:g,onCancel:j,onClear:v}=e,N=(0,r.kj)(),k=(0,l.useRouter)(),[M,S]=(0,i.useState)({}),[C,L]=(0,i.useState)(""),[T,O]=(0,i.useState)(new Set),[P,R]=(0,i.useState)(null),[A,E]=(0,i.useState)(""),[I,U]=(0,i.useState)(!1),[D,q]=(0,i.useState)(null),[B,F]=(0,i.useState)(!1),z=(0,i.useRef)(!1),Z=(0,i.useRef)(null),_=!!((null==(t=M.goal)?void 0:t.trim())||(null==(n=M.decision)?void 0:n.trim())),J=d.filter(e=>"goal"!==e&&"decision"!==e),H=J.filter(e=>{var t;return T.has(e)||!!(null==(t=M[e])?void 0:t.trim())}),G=J.filter(e=>!H.includes(e)),W=(null==w?void 0:w.identity)&&null!=(m=null==(a=x.find(e=>e.identity===w.identity))?void 0:a.slug)?m:"";async function V(e){if(e.preventDefault(),!z.current&&_){z.current=!0,U(!0),q(null);try{await p("/api/twin/episodes",{fields:M,...A?{validUntil:A}:{},...w?{replacesId:w.id,expectedUpdatedAt:w.updatedAt}:C?{slug:C}:{}},N("twinMemory.requestFailed")),S({}),O(new Set),R(null),E(""),F(!1),b.current=!1,g(),k.refresh()}catch(e){q(h(e,N))}finally{z.current=!1,U(!1)}}}function Y(e){var t;let n=null!=(t=M[e])?t:"";return(0,s.jsxs)("div",{children:[(0,s.jsx)(o.fs,{label:N(c[e].label),id:"memory-".concat(e),value:n,maxLength:1200,rows:"decision"===e?3:2,disabled:I,placeholder:N(c[e].hint),"aria-describedby":"memory-".concat(e,"-count"),onChange:t=>{S(n=>({...n,[e]:t.target.value})),F(!0),b.current=!0}}),(0,s.jsx)("p",{id:"memory-".concat(e,"-count"),className:"mt-1 text-right font-mono text-[11px] text-smoke",children:N("twinMemory.characters",{n:n.length,max:1200})})]},e)}return(0,i.useEffect)(()=>{var e,t,n,s;S(w?Object.fromEntries(d.map(e=>{var t,n;return[e,null!=(n=null==(t=w.fields[e])?void 0:t.text)?n:""]})):{}),O(new Set(w?d.filter(e=>{var t;return null==(t=w.fields[e])?void 0:t.text.trim()}):[])),R(null),E(null!=(s=null==w||null==(e=w.validUntil)?void 0:e.slice(0,10))?s:""),L(W),F(!1),b.current=!1,w&&(null==(n=Z.current)||null==(t=n.querySelector("textarea"))||t.focus({preventScroll:!0}))},[w,W,b]),(0,i.useEffect)(()=>{var e;P&&(null==(e=document.getElementById("memory-".concat(P)))||e.focus())},[P]),(0,s.jsxs)("form",{id:"memory-capture-form",ref:Z,onSubmit:V,"aria-busy":I,"aria-labelledby":"memory-capture-title",className:"min-w-0 scroll-mt-24 px-5 py-5 sm:px-6",children:[(0,s.jsx)("h3",{id:"memory-capture-title",className:"text-base font-semibold",children:N(w?"twinMemory.reviseTitle":"twinMemory.captureTitle")}),(0,s.jsx)("p",{className:"mt-2 text-xs leading-relaxed text-smoke",children:N(w?"twinMemory.reviseHint":"twinMemory.captureHint")}),(0,s.jsx)("div",{role:"status","aria-live":"polite",children:f&&(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-3 rounded-lg border border-edge bg-ground px-3 py-3",children:[(0,s.jsx)("p",{className:"text-xs leading-relaxed text-smoke",children:N("twinMemory.unsavedDraft")}),(0,s.jsx)(o.rA,{type:"button",tone:"surface",disabled:I,onClick:v,children:N("twinMemory.clearDraft")})]})}),(0,s.jsxs)("div",{className:"mt-4 space-y-3",children:[Y("goal"),Y("decision"),(0,s.jsxs)(o.l6,{label:N("twinMemory.projectContext"),value:C,disabled:I||null!==w,onChange:e=>L(e.target.value),children:[(0,s.jsx)("option",{value:"",children:(null==w?void 0:w.identity)&&!C?null!=(u=w.projectName)?u:N("twinMemory.originalProject"):N("twinMemory.noProject")}),x.map(e=>(0,s.jsx)("option",{value:e.slug,children:e.label},e.slug))]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(o.D0,{label:N("twinMemory.validUntilLabel"),type:"date",value:A,disabled:I,"aria-describedby":"memory-valid-until-hint",onChange:e=>{E(e.target.value),F(!0),b.current=!0}}),(0,s.jsx)("p",{id:"memory-valid-until-hint",className:"mt-1 text-xs leading-relaxed text-smoke",children:N("twinMemory.validUntilHint")})]}),H.map(Y),G.length>0&&(0,s.jsxs)("div",{className:"rounded-lg border border-edge px-3 py-3",children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:N("twinMemory.moreFields")}),(0,s.jsx)("div",{className:"mt-3 flex flex-wrap gap-2",children:G.map(e=>(0,s.jsx)(o.rA,{type:"button",tone:"surface",disabled:I,"aria-label":N("twinMemory.addField",{field:N(c[e].label).toLocaleLowerCase()}),onClick:()=>{O(t=>new Set(t).add(e)),R(e)},children:N(c[e].label)},e))})]})]}),(0,s.jsxs)("div",{className:"mt-4 flex flex-wrap items-center gap-3",children:[(0,s.jsx)(o.rA,{type:"submit",tone:"accent",busy:I,busyLabel:N("twinMemory.saving"),disabled:I||!_,children:N(w?"twinMemory.saveRevision":"twinMemory.saveEpisode")}),w&&(0,s.jsx)(o.rA,{type:"button",tone:"plain",disabled:I,onClick:j,children:N("twinMemory.cancelRevision")}),(0,s.jsx)("span",{className:"text-xs text-smoke",children:N("twinMemory.localSave")})]}),D&&(0,s.jsx)(o.lZ,{text:D,className:"mt-3"}),(0,s.jsx)("div",{role:"status","aria-live":"polite",children:y&&!B&&(0,s.jsx)("p",{className:"mt-3 text-sm text-smoke",children:y})})]})}function y(e){var t,n;let{pendingCount:d,deferred:c,dailyCalls:m}=e,u=(0,r.kj)(),x=(0,l.useRouter)(),[w,f]=(0,i.useState)(null),[b,y]=(0,i.useState)(null),[g,j]=(0,i.useState)(null),[v,N]=(0,i.useState)(null),k=(0,i.useRef)(!1),M=m>0&&d>0?Math.max(1,Math.ceil(d/(12*m))):null;async function S(e){if(k.current||"learn"===e&&(!b||!b.selected||b.remainingCalls<b.calls))return;k.current=!0,f(e),j(null),N(null);let t=u("twinMemory.requestFailed");try{var n,s,i,l,a;if("capture"===e){let e=await p("/api/twin/mine",{captureNarratives:!0},t);y(null),N([u("twinMemory.capturedNew",{n:null!=(s=e.narrativesSaved)?s:0}),e.saved?u("twin.minedQuotes",{n:e.saved}):"",(null==(n=e.denied)?void 0:n.length)?u("twinMemory.capturedDenied",{n:e.denied.length}):"",e.narrativesUnmatched?u("twinMemory.capturedUnmatched",{n:e.narrativesUnmatched}):"",e.narrativesUndated?u("twinMemory.capturedUndated",{n:e.narrativesUndated}):""].filter(Boolean).join(" ")),x.refresh()}else if("preview"===e)y(await p("/api/twin/episodes/learn",{dryRun:!0},t));else{let e=await p("/api/twin/episodes/learn",{},t);y(null),N([u("twinMemory.learnStored",{stored:null!=(i=e.stored)?i:0,processed:null!=(l=e.processed)?l:0,remaining:null!=(a=e.remaining)?a:0}),e.dropped?u("twinMemory.learnDropped",{n:e.dropped}):"",e.failed?u("cut"===e.failed.reason?"twinMemory.learnCut":"twinMemory.learnUnsupported"):"",e.failed?u("twinMemory.learnDeferred",{n:e.failed.records}):""].filter(Boolean).join(" ")),x.refresh()}}catch(t){j(h(t,u)),"learn"===e&&(y(null),x.refresh())}finally{k.current=!1,f(null)}}return(0,s.jsxs)("div",{className:"min-w-0 border-t border-edge bg-ground px-5 py-5 sm:px-6 lg:border-t-0 lg:border-l","aria-busy":null!==w,children:[(0,s.jsxs)("h3",{className:"flex items-center gap-2 text-base font-semibold",children:[(0,s.jsx)(a.tZt,{"aria-hidden":!0,className:"h-4 w-4 text-smoke"}),u("twinMemory.learnTitle")]}),(0,s.jsx)("p",{className:"mt-2 text-sm leading-relaxed text-smoke",children:u("twinMemory.learnLead")}),(0,s.jsxs)("div",{className:"mt-5 rounded-lg border border-edge bg-surface p-4",children:[(0,s.jsx)("p",{className:"font-mono text-xs text-smoke",children:u("twinMemory.step1")}),(0,s.jsx)("p",{className:"mt-2 text-xs leading-relaxed text-smoke",children:u("twinMemory.step1Hint")}),(0,s.jsxs)(o.rA,{type:"button",tone:"surface",className:"mt-3",busy:"capture"===w,busyLabel:u("twinMemory.capturing"),disabled:null!==w,onClick:()=>void S("capture"),children:[(0,s.jsx)(a.Dho,{"aria-hidden":!0,className:"h-4 w-4"}),u("twinMemory.capture")]}),(0,s.jsx)("p",{className:"mt-2 text-xs text-smoke",children:u("twinMemory.noCall")})]}),(0,s.jsxs)("div",{className:"mt-3 rounded-lg border border-edge bg-surface p-4",children:[(0,s.jsx)("p",{className:"font-mono text-xs text-smoke",children:u("twinMemory.step2")}),(0,s.jsx)("p",{className:"mt-2 text-xs leading-relaxed text-smoke",children:u("twinMemory.step2Hint")}),(0,s.jsx)(o.rA,{type:"button",tone:"surface",className:"mt-3",busy:"preview"===w,busyLabel:u("twinMemory.previewing"),disabled:null!==w,onClick:()=>void S("preview"),children:u("twinMemory.preview")}),!b&&(0,s.jsxs)("div",{className:"mt-2 space-y-1 text-xs text-smoke",children:[(0,s.jsx)("p",{children:u("twinMemory.awaiting",{n:d})}),c>0&&(0,s.jsx)("p",{children:u("twinMemory.deferred",{n:c})}),m>0?(0,s.jsx)("p",{children:u("twinMemory.passReads",{n:24})}):(0,s.jsx)("p",{children:u("twinMemory.extractionOff")}),null!==M&&(0,s.jsx)("p",{children:u("twinMemory.queueDays",{n:M})})]}),b&&(0,s.jsxs)("div",{className:"mt-4 border-t border-edge pt-4",children:[(0,s.jsxs)("dl",{className:"grid grid-cols-[1fr_auto] gap-x-3 gap-y-2 text-xs",children:[(0,s.jsx)("dt",{className:"text-smoke",children:u("twinMemory.selected")}),(0,s.jsx)("dd",{className:"font-mono",children:b.selected}),(0,s.jsx)("dt",{className:"text-smoke",children:u("twinMemory.inputTokens")}),(0,s.jsx)("dd",{className:"font-mono",children:b.inputTokens}),(0,s.jsx)("dt",{className:"text-smoke",children:u("twinMemory.outputTokens")}),(0,s.jsx)("dd",{className:"font-mono",children:b.outputTokens}),(0,s.jsx)("dt",{className:"text-smoke",children:u("twinMemory.calls")}),(0,s.jsx)("dd",{className:"font-mono",children:b.calls}),(0,s.jsx)("dt",{className:"text-smoke",children:u("twinMemory.remainingCalls")}),(0,s.jsx)("dd",{className:"font-mono",children:b.remainingCalls})]}),b.contextOnly>0&&(0,s.jsx)("p",{className:"mt-2 text-xs text-smoke",children:u("twinMemory.contextOnly",{n:b.contextOnly})}),(null!=(t=b.retrying)?t:0)>0&&(0,s.jsx)("p",{className:"mt-2 text-xs text-smoke",children:u("twinMemory.learnRetrying",{n:null!=(n=b.retrying)?n:0})}),(b.provider||b.model)&&(0,s.jsx)("p",{className:"mt-3 break-words font-mono text-[11px] text-smoke",children:[b.provider,b.model].filter(Boolean).join(" / ")}),0===b.selected?(0,s.jsx)(o.pp,{variant:"note",className:"mt-3",title:u("twinMemory.nothingUnread")}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.rA,{type:"button",tone:"accent",className:"mt-4",busy:"learn"===w,busyLabel:u("twinMemory.learning"),disabled:null!==w||b.remainingCalls<b.calls,onClick:()=>void S("learn"),children:u("twinMemory.learn")}),(0,s.jsx)("p",{className:"mt-2 text-xs leading-relaxed text-smoke",children:u(b.remainingCalls<b.calls?"twinMemory.budgetShort":"twinMemory.learnCost")})]})]})]}),g&&(0,s.jsx)(o.lZ,{text:g,className:"mt-3"}),(0,s.jsx)("p",{role:"status","aria-live":"polite",className:"mt-3 text-xs leading-relaxed text-smoke",children:"learn"===w?u("twinMemory.extracting"):v})]})}function g(e){var t,n,a,w,f,b,y,g;let{episode:j,onRevise:v,previousAvailable:N,hasActiveSuccessor:k,onPrevious:M}=e,S=(0,r.kj)(),C=(0,r.Ym)(),L=(0,l.useRouter)(),{recorded:T,missing:O}=function(e){let t=d.filter(t=>{var n;return!!(null==(n=e.fields[t])?void 0:n.text.trim())});return{recorded:t,missing:d.filter(e=>!t.includes(e))}}(j),[P,R]=(0,i.useState)(null),[A,E]=(0,i.useState)(null),[I,U]=(0,i.useState)(null),[D,q]=(0,i.useState)(!1),[B,F]=(0,i.useState)(null),[z,Z]=(0,i.useState)(null),[_,J]=(0,i.useState)(j.validUntil),[H,G]=(0,i.useState)(null!=(a=null==(t=j.validUntil)?void 0:t.slice(0,10))?a:"");_!==j.validUntil&&(J(j.validUntil),G(null!=(f=null==(w=j.validUntil)?void 0:w.slice(0,10))?f:""));let W=(0,i.useRef)(!1),V=(0,i.useRef)(!1),Y=(0,i.useRef)(null),K=T.some(e=>{var t;return!!(null==(t=j.fields[e])?void 0:t.narrativeId)}),Q=null!=(b=m(j))?b:S("twinMemory.untitled"),X=e=>e.map(e=>S(c[e].label).toLocaleLowerCase()).join(", "),$="dismissed"===j.status&&!k,ee="active"===j.status&&k,et=u(j),en=j.validUntil?new Date(j.validUntil).toLocaleDateString(C,{timeZone:"UTC"}):null;async function es(){if(!W.current){W.current=!0,R("status"),E(null);try{await p("/api/twin/episodes",{id:j.id,status:"active"===j.status?"dismissed":"active",expectedUpdatedAt:j.updatedAt},S("twinMemory.requestFailed")),L.refresh()}catch(e){E(h(e,S))}finally{W.current=!1,R(null)}}}async function ei(e){if(!W.current){W.current=!0,R(null===e?"clearExpiry":"expiry"),E(null);try{await p("/api/twin/episodes",{id:j.id,validUntil:e,expectedUpdatedAt:j.updatedAt},S("twinMemory.requestFailed")),L.refresh()}catch(e){E(h(e,S))}finally{W.current=!1,R(null)}}}async function el(){if(null===I&&!V.current){V.current=!0,q(!0),F(null);try{let t=await fetch("/api/twin/episodes?id=".concat(encodeURIComponent(j.id))),n=await t.json();if(!t.ok||!Array.isArray(n.evidence)){var e;throw Error(null!=(e=n.error)?e:S("twinMemory.evidenceFailed"))}U(n.evidence)}catch(e){F(h(e,S))}finally{V.current=!1,q(!1)}}}return(0,i.useEffect)(()=>{var e;I&&z&&(null==(e=document.getElementById("episode-".concat(j.id,"-source-").concat(z)))||e.focus())},[I,j.id,z]),(0,s.jsxs)("li",{id:"episode-".concat(j.id),tabIndex:-1,className:"min-w-0 scroll-mt-24 rounded-lg border border-edge bg-ground p-4",children:[(0,s.jsxs)("p",{className:"flex flex-wrap gap-x-2 gap-y-1 font-mono text-[11px] text-smoke",children:[(0,s.jsx)("span",{children:S("owner"===j.origin?"twinMemory.byOwner":"twinMemory.fromHistory")}),(0,s.jsxs)("span",{children:["\xb7 ",null!=(y=j.projectName)?y:S(j.identity?"twinMemory.unlinkedProject":"twinMemory.noProject")]}),"dismissed"===j.status&&(0,s.jsxs)("span",{children:["\xb7 ",S("twinMemory.dismissed")]})]}),(0,s.jsx)("h4",{className:"mt-2 line-clamp-3 break-words text-sm font-medium leading-relaxed",children:Q}),j.supersedesId&&(0,s.jsx)("p",{className:"mt-2 text-xs text-smoke",children:N?(0,s.jsx)("a",{href:"#episode-".concat(j.supersedesId),onClick:M,className:"underline underline-offset-4",children:S("twinMemory.previousVersion")}):(0,s.jsxs)("a",{href:"/twin?episode=".concat(encodeURIComponent(j.supersedesId),"#episode-").concat(j.supersedesId),className:"underline underline-offset-4",children:[S("twinMemory.previousVersion")," ",(0,s.jsx)("span",{className:"sr-only",children:S("twinMemory.outsideView")})]})}),(0,s.jsx)("p",{className:"mt-3 font-mono text-[11px] text-smoke",children:S("twinMemory.recorded",{list:X(T)})}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-smoke",children:S("dismissed"===j.status?"twinMemory.reachNowhere":u(j)?"twinMemory.reachExpired":ee?"twinMemory.reachWithheld":"history"===j.origin?"twinMemory.reachLabOnly":(null==(g=j.fields.decision)?void 0:g.text.trim())?j.identity?"twinMemory.reachProject":"twinMemory.reachGeneral":"twinMemory.reachNoDecision")}),en&&(0,s.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-smoke",children:S(et?"twinMemory.expiredOn":"twinMemory.appliesThrough",{date:en})}),(0,s.jsxs)("details",{className:"mt-3",children:[(0,s.jsx)("summary",{className:"cursor-pointer text-xs font-medium underline-offset-4 hover:underline",children:S("twinMemory.explore")}),(0,s.jsx)("dl",{className:"mt-3 space-y-3",children:T.map(e=>{var t;return(0,s.jsxs)("div",{children:[(0,s.jsx)("dt",{className:"text-xs font-medium",children:S(c[e].label)}),(0,s.jsxs)("dd",{className:"mt-1 whitespace-pre-wrap break-words text-sm leading-relaxed text-smoke",children:[j.fields[e].text,(null==(t=j.fields[e])?void 0:t.narrativeId)&&(0,s.jsx)("button",{type:"button",className:"mt-1 block text-xs underline underline-offset-4","aria-label":S("twinMemory.viewSourceFor",{field:S(c[e].label).toLocaleLowerCase()}),onClick:()=>{var t;let n=j.fields[e].narrativeId;Y.current&&(Y.current.open=!0),Z(n),I&&(null==(t=document.getElementById("episode-".concat(j.id,"-source-").concat(n)))||t.focus()),el()},children:S("twinMemory.viewSource")})]})]},e)})}),O.length>0&&(0,s.jsx)("p",{className:"mt-4 border-t border-edge pt-3 text-xs leading-relaxed text-smoke",children:S("twinMemory.notRecorded",{list:X(O)})}),(0,s.jsxs)("div",{className:"mt-4 border-t border-edge pt-3",children:[(0,s.jsx)("p",{className:"text-xs font-medium",children:S("twinMemory.expiryTitle")}),(0,s.jsx)(o.D0,{label:S("twinMemory.validUntilLabel"),className:"mt-2",size:"sm",type:"date",value:H,disabled:null!==P,"aria-describedby":"episode-".concat(j.id,"-expiry-hint"),onChange:e=>G(e.target.value)}),(0,s.jsx)("p",{id:"episode-".concat(j.id,"-expiry-hint"),className:"mt-1 text-xs leading-relaxed text-smoke",children:S("twinMemory.validUntilHint")}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[(0,s.jsx)(o.rA,{type:"button",tone:"surface",busy:"expiry"===P,busyLabel:S("twinMemory.savingExpiry"),disabled:null!==P||!H||H===(null==(n=j.validUntil)?void 0:n.slice(0,10)),onClick:()=>void ei(H),children:S("twinMemory.saveExpiry")}),j.validUntil&&(0,s.jsx)(o.rA,{type:"button",tone:"plain",busy:"clearExpiry"===P,busyLabel:S("twinMemory.clearingExpiry"),disabled:null!==P,onClick:()=>void ei(null),children:S("twinMemory.clearExpiry")})]})]})]}),K&&(0,s.jsxs)("details",{ref:Y,className:"mt-3",onToggle:e=>{e.currentTarget.open&&el()},children:[(0,s.jsx)("summary",{className:"cursor-pointer text-xs font-medium underline-offset-4 hover:underline",children:S("twinMemory.viewEvidence")}),D&&(0,s.jsx)("p",{role:"status",className:"mt-2 text-xs text-smoke",children:S("twinMemory.loadingEvidence")}),B&&(0,s.jsxs)("div",{className:"mt-2",children:[(0,s.jsx)(o.lZ,{text:B}),(0,s.jsx)(o.rA,{type:"button",tone:"surface",className:"mt-2",onClick:()=>void el(),children:S("twinMemory.retryEvidence")})]}),I&&0===I.length&&(0,s.jsx)("p",{className:"mt-2 text-xs text-smoke",children:S("twinMemory.sourceGone")}),null==I?void 0:I.map(e=>{let t=x[e.kind];return(0,s.jsxs)("div",{id:"episode-".concat(j.id,"-source-").concat(e.id),tabIndex:-1,className:"mt-3 scroll-mt-24 rounded border border-edge bg-surface p-3",children:[(0,s.jsxs)("p",{className:"break-words font-mono text-[10px] text-smoke",children:[e.source," \xb7 ",t?S(t):e.kind," \xb7 ",e.at.slice(0,10)]}),(0,s.jsx)("p",{className:"mt-2 text-xs font-medium",children:S("brief"===e.kind?"twinMemory.briefText":"twinMemory.ownerText")}),(0,s.jsx)("blockquote",{className:"mt-1 whitespace-pre-wrap break-words text-xs leading-relaxed text-smoke",children:e.text}),e.truncated&&(0,s.jsx)("p",{className:"mt-2 text-xs text-smoke",children:S("twinMemory.truncated")}),e.context&&(0,s.jsxs)("details",{className:"mt-3 border-t border-edge pt-2",children:[(0,s.jsx)("summary",{className:"cursor-pointer text-xs text-smoke",children:S("twinMemory.agentContext")}),(0,s.jsx)("p",{className:"mt-2 whitespace-pre-wrap break-words text-xs leading-relaxed text-smoke",children:e.context})]})]},e.id)})]}),(0,s.jsxs)("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2 border-t border-edge pt-3",children:[(0,s.jsx)("time",{dateTime:j.createdAt,className:"font-mono text-[10px] text-smoke",children:j.createdAt.slice(0,10)}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(o.rA,{type:"button",tone:"surface",disabled:null!==P||k,onClick:v,children:S("twinMemory.revise")}),("active"===j.status||$)&&(0,s.jsx)(o.rA,{type:"button",tone:"plain",busy:"status"===P,busyLabel:S("twin.saving"),disabled:null!==P,onClick:()=>void es(),children:S("active"===j.status?"twinMemory.dismiss":"twinMemory.restore")})]})]}),k&&(0,s.jsxs)("p",{className:"mt-2 text-xs leading-relaxed text-smoke",children:[S(ee?"twinMemory.competingActive":"twinMemory.successorActive")," ",ee?(0,s.jsx)("a",{href:"#competing-versions",className:"underline underline-offset-4",children:S("twinMemory.competingOpen")}):(0,s.jsx)("a",{href:"/twin?episode=".concat(encodeURIComponent(j.activeRevisionId),"#episode-").concat(j.activeRevisionId),className:"underline underline-offset-4",children:S("twinMemory.currentVersion")})]}),A&&(0,s.jsx)(o.lZ,{text:A,className:"mt-2"})]})}},9144:(e,t,n)=>{"use strict";n.d(t,{I18nProvider:()=>o,Ym:()=>d,Zs:()=>c,kj:()=>m});var s=n(38657),i=n(32165),l=n(2575);let a=(0,i.createContext)("en"),r=(0,i.createContext)("panoma");function o(e){let{locale:t,cli:n,children:i}=e;return(0,s.jsx)(a.Provider,{value:t,children:(0,s.jsx)(r.Provider,{value:n,children:i})})}function d(){return(0,i.useContext)(a)}function c(){return(0,i.useContext)(r)}function m(){let e=(0,i.useContext)(a),t=(0,i.useContext)(r);return(0,i.useCallback)((n,s)=>(0,l.t)(e,n,{cli:t,...s}),[e,t])}},10354:(e,t,n)=>{"use strict";var s=n(61990);n.o(s,"usePathname")&&n.d(t,{usePathname:function(){return s.usePathname}}),n.o(s,"useRouter")&&n.d(t,{useRouter:function(){return s.useRouter}}),n.o(s,"useSearchParams")&&n.d(t,{useSearchParams:function(){return s.useSearchParams}})},15797:(e,t,n)=>{"use strict";n.d(t,{TwinSynthesize:()=>o});var s=n(38657),i=n(32165),l=n(10354),a=n(9144),r=n(52948);function o(e){let{pending:t,ready:n,compact:o}=e,d=(0,a.kj)(),c=(0,l.useRouter)(),[m,u]=(0,i.useState)(!1),[x,p]=(0,i.useState)(null);async function h(){u(!0),p(null);try{var e,n,s,i,l,a,r,o,m;let u=0;if(t>0){let t=await fetch("/api/twin/classify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),s=await t.json();if(!t.ok)return void p(null!=(e=s.error)?e:d("twin.synthFailed"));u+=null!=(n=s.truncated)?n:0}let x=await fetch("/api/twin/synthesize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),h=await x.json();if(!x.ok)return void p(null!=(s=h.error)?s:d("twin.synthFailed"));u+=null!=(i=h.truncated)?i:0;let w=null!=(l=h.created)?l:0,f=null!=(a=h.refined)?a:0,b=null!=(r=h.retired)?r:0,y=null!=(o=h.proposed)?o:0,g=w+f+b+y,j=null!=(m=h.unchanged)?m:0,v=0===h.topics?j>0?d("twin.synthUpToDate"):d("twin.synthNothing"):d("twin.synthSame"),N=d("twin.synthDone",{created:w,refined:f,retired:b}),k=0===g?v:0===y?N:"".concat(N," ").concat(d("twin.synthAsks",{n:y}));p(u>0?"".concat(k," ").concat(d("twin.synthTruncated",{n:u})):k),c.refresh()}catch(e){p(d("project.unreachable"))}finally{u(!1)}}return(0,s.jsxs)("div",{className:o?"flex items-center gap-2":"mt-3 flex flex-col gap-1",children:[(0,s.jsx)(r.rA,{tone:"plain",type:"button",onClick:h,busy:m,busyLabel:d("twin.synthesizing"),disabled:!n,"aria-describedby":n?void 0:"twin-synth-why",className:"self-start",children:d("twin.synthesize")}),n?(0,s.jsx)("div",{role:"status","aria-live":"polite",children:x?(0,s.jsx)("p",{className:"font-mono text-xs text-smoke",children:x}):o?null:(0,s.jsx)("p",{className:"text-xs leading-relaxed text-smoke",children:d("twin.synthHint")})}):(0,s.jsx)("p",{id:"twin-synth-why",className:"text-xs leading-relaxed text-smoke",children:d("twin.synthNothing")})]})}},18557:(e,t,n)=>{"use strict";n.d(t,{BeliefEditor:()=>c});var s=n(38657),i=n(32165),l=n(10354),a=n(9144),r=n(59916),o=n(52948);let d={signed:"twin.badgeSigned",standing:"twin.badgeStanding",forming:"twin.badgeForming"};function c(e){let{beliefs:t,graveyard:n,proposals:r,unpublished:d,locale:c}=e,h=(0,a.kj)(),w=(0,l.useRouter)(),[f,b]=(0,i.useState)(new Map),[y,g]=(0,i.useState)(new Map),[j,v]=(0,i.useState)(null),[N,k]=(0,i.useState)(!1),[M,S]=(0,i.useState)(null),C=(0,i.useMemo)(()=>{let e=new Map;for(let n of t){let t=e.get(n.topic);t?t.push(n):e.set(n.topic,[n])}return[...e]},[t]),L=f.size>0||y.size>0;function T(e,t){b(n=>{let s=new Map(n);return void 0===t?s.delete(e):s.set(e,t),s})}async function O(){k(!0),S(null);let e=[],t=[],n=[];for(let[s,i]of f)"sign"===i.kind?e.push({id:s,...i.statement?{statement:i.statement}:{}}):"veto"===i.kind?t.push(s):n.push({id:s,identity:i.identity});let s=[...y].map(e=>{let[t,n]=e;return{id:t,accept:n}});try{let l=await fetch("/api/twin/taste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sign:e,veto:t,scope:n,resolve:s})}),a=await l.json();if(!l.ok){var i;S(null!=(i=a.error)?i:String(l.status));return}b(new Map),g(new Map),v(null),w.refresh()}catch(e){S(h("project.unreachable"))}finally{k(!1)}}return(0,s.jsxs)(s.Fragment,{children:[r.length>0&&(0,s.jsxs)("section",{className:"mt-8",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:h("twin.proposalsTitle")}),(0,s.jsx)("p",{className:"mt-1 max-w-2xl text-sm leading-relaxed text-smoke",children:h("twin.proposalsNote")}),(0,s.jsx)("ul",{className:"mt-4 flex flex-col gap-3",role:"list",children:r.map(e=>{var t;return(0,s.jsxs)("li",{className:"rounded-lg border px-4 py-4 ".concat(y.has(e.id)?"border-l-2 border-l-chalk border-edge":"border-edge"),children:[(0,s.jsxs)("p",{className:"eyebrow",children:[m(e.topic,h),e.supersedes&&e.supersedes.length>1?" \xb7 ".concat(h("twin.proposalJoins",{n:e.supersedes.length})):""]}),null==(t=e.supersedes)?void 0:t.map(e=>(0,s.jsx)("p",{className:"mt-1 max-w-2xl text-sm leading-relaxed text-smoke line-through decoration-faint",children:e},e)),(0,s.jsx)("p",{className:"mt-2 max-w-2xl text-base leading-relaxed",children:e.statement}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[(0,s.jsx)(p,{label:h("twin.proposalAccept"),toggle:!0,active:!0===y.get(e.id),onClick:()=>g(u(y,e.id,!0))}),(0,s.jsx)(p,{label:h("twin.proposalReject"),toggle:!0,active:!1===y.get(e.id),onClick:()=>g(u(y,e.id,!1))})]})]},e.id)})})]}),C.map(e=>{let[t,n]=e;return(0,s.jsxs)("section",{className:"mt-8",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:m(t,h)}),(0,s.jsx)("ul",{className:"mt-4 flex flex-col gap-3",role:"list",children:n.map(e=>(0,s.jsx)(x,{belief:e,locale:c,gesture:f.get(e.id),stranded:"forming"!==e.badge&&d.has(e.id),editing:j===e.id,onEdit:t=>v(t?e.id:null),onGesture:t=>(function(e,t){let n=f.get(e),s=(null==n?void 0:n.kind)==="sign"&&void 0!==n.statement;n&&n.kind===t.kind&&!s?T(e,void 0):T(e,t)})(e.id,t),onWrite:t=>T(e.id,{kind:"sign",statement:t}),translate:h},e.id))})]},t)}),n.length>0&&(0,s.jsxs)("section",{className:"mt-8",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:h("twin.graveyardTitle")}),(0,s.jsx)("p",{className:"mt-1 max-w-2xl text-sm leading-relaxed text-smoke",children:h("twin.graveyardNote")}),(0,s.jsx)("ul",{className:"mt-4 flex flex-col gap-2",role:"list",children:n.map(e=>(0,s.jsx)("li",{className:"rounded-lg border border-edge px-4 py-3 opacity-60",children:(0,s.jsx)("p",{className:"text-sm leading-relaxed text-smoke line-through decoration-faint",children:e.statement})},e.id))})]}),L&&(0,s.jsxs)("div",{className:"sticky bottom-4 z-10 mt-8 flex flex-wrap items-center gap-3 rounded-lg border border-edge bg-surface/95 px-4 py-3 shadow-lg backdrop-blur",children:[(0,s.jsx)("span",{className:"font-mono text-xs text-smoke",children:h("twin.markedGestures",{n:f.size+y.size})}),(0,s.jsx)(o.rA,{tone:"accent",type:"button",onClick:O,busy:N,busyLabel:h("twin.saving"),children:h("twin.save")}),(0,s.jsx)(o.rA,{tone:"quiet",type:"button",onClick:()=>{b(new Map),g(new Map),v(null)},disabled:N,children:h("twin.cancel")}),M&&(0,s.jsx)("span",{className:"font-mono text-xs text-fail",children:h("twin.saveFailed",{detail:M})})]})]})}function m(e,t){let n=(0,r.Jj)(e);return n?t(n):e}function u(e,t,n){let s=new Map(e);return s.get(t)===n?s.delete(t):s.set(t,n),s}function x(e){let{belief:t,locale:n,gesture:l,stranded:a,editing:c,onEdit:m,onGesture:u,onWrite:x,translate:h}=e,[w,f]=(0,i.useState)(!1),[b,y]=(0,i.useState)(t.statement),g=(null==l?void 0:l.kind)==="sign"?l.statement:void 0;return(0,s.jsxs)("li",{id:"belief-".concat(t.id),tabIndex:-1,className:["scroll-mt-24 rounded-lg border px-4 py-4 transition-colors",(null==l?void 0:l.kind)==="sign"?"border-l-2 border-l-live border-edge bg-live/[0.05]":(null==l?void 0:l.kind)==="veto"?"border-l-2 border-l-faint border-edge opacity-60":void 0!==l?"border-l-2 border-l-chalk border-edge":"border-edge"].join(" "),children:[(0,s.jsxs)("p",{className:"eyebrow",children:[(0,s.jsx)("span",{className:"forming"===t.badge?"text-idle":"",children:h(d[t.badge])}),t.scope?" \xb7 ".concat(h("twin.scopedTag",{project:t.scope})):"",a?(0,s.jsx)("span",{className:"text-idle",children:" \xb7 ".concat(h("twin.notInFile"))}):null]}),a?(0,s.jsx)("p",{className:"mt-1 max-w-2xl text-xs leading-relaxed text-smoke",children:h("twin.notInFileWhy")}):null,c?(0,s.jsxs)("div",{className:"mt-2",children:[(0,s.jsx)(o.fs,{label:h("twin.editText"),hideLabel:!0,rows:3,className:"max-w-2xl",value:b,onChange:e=>y(e.target.value)}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap gap-2",children:[(0,s.jsx)(p,{label:h("twin.editSave"),active:!0,onClick:()=>{""!==b.trim()&&(x(b.trim()),m(!1))}}),(0,s.jsx)(p,{label:h("twin.cancel"),onClick:()=>{y(t.statement),m(!1)}})]})]}):(0,s.jsx)("p",{className:"mt-1 max-w-2xl text-base leading-relaxed",children:null!=g?g:t.statement}),(0,s.jsxs)("p",{className:"mt-2 font-mono text-xs text-smoke",children:[t.authored?h("twinTeach.ownerEvidence"):h("twin.support",{observations:t.support.observations,projects:t.support.projects,days:t.support.days}),"forming"===t.badge?(0,s.jsx)("span",{className:"text-idle",children:" \xb7 ".concat(h("twin.formingWhy"))}):null,t.citations.length>0&&(0,s.jsxs)(s.Fragment,{children:[" \xb7 ",(0,s.jsx)("button",{type:"button",onClick:()=>f(e=>!e),className:"underline-offset-2 hover:underline",children:h(w?"twin.hideCitations":"twin.showCitations",{n:t.citations.length})})]})]}),w&&(0,s.jsx)("ul",{className:"mt-3 flex flex-col gap-2.5 border-l border-edge pl-3",role:"list",children:t.citations.map(e=>(0,s.jsxs)("li",{children:[(0,s.jsxs)("p",{className:"line-clamp-2 text-sm italic leading-snug text-smoke",title:e.quote,children:["\xab",e.quote,"\xbb"]}),(0,s.jsxs)("p",{className:"mt-0.5 font-mono text-xs text-faint",children:[(0,r.mL)(e.at,n),e.project?" \xb7 ".concat(h("twin.citedIn",{project:e.project})):""]})]},e.verdictId))}),!c&&(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:["signed"!==t.badge&&(0,s.jsx)(p,{label:h("twin.sign"),toggle:!0,active:(null==l?void 0:l.kind)==="sign"&&void 0===g,onClick:()=>u({kind:"sign"})}),(0,s.jsx)(p,{label:h("twin.edit"),toggle:!0,active:void 0!==g,onClick:()=>{y(null!=g?g:t.statement),m(!0)}}),(0,s.jsx)(p,{label:h("twin.veto"),toggle:!0,active:(null==l?void 0:l.kind)==="veto",onClick:()=>u({kind:"veto"})}),t.scope?(0,s.jsx)(p,{label:h("twin.scopeAll"),toggle:!0,active:(null==l?void 0:l.kind)==="scope"&&null===l.identity,onClick:()=>u({kind:"scope",identity:null})}):t.learnedIn?(0,s.jsx)(p,{label:h("twin.scopeOnly",{project:t.learnedIn.name}),toggle:!0,active:(null==l?void 0:l.kind)==="scope",onClick:()=>{var e,n;return u({kind:"scope",identity:null!=(n=null==(e=t.learnedIn)?void 0:e.identity)?n:null})}}):null]})]})}function p(e){let{label:t,active:n,toggle:i=!1,onClick:l}=e;return(0,s.jsx)(o.rA,{tone:n?"accent":"plain",type:"button",...i?{"aria-pressed":null!=n&&n}:{},onClick:l,children:t})}},26488:(e,t,n)=>{"use strict";n.d(t,{P:()=>s,s:()=>i});let s=300,i=300},56684:(e,t,n)=>{"use strict";n.d(t,{k5:()=>c});var s=n(32165),i={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},l=s.createContext&&s.createContext(i),a=["attr","size","title"];function r(){return(r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)({}).hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(null,arguments)}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,s)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach(function(t){var s,i,l;s=e,i=t,l=n[t],(i=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(i))in s?Object.defineProperty(s,i,{value:l,enumerable:!0,configurable:!0,writable:!0}):s[i]=l}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function c(e){return t=>s.createElement(m,r({attr:d({},e.attr)},t),function e(t){return t&&t.map((t,n)=>s.createElement(t.tag,d({key:n},t.attr),e(t.child)))}(e.child))}function m(e){var t=t=>{var n,i=e.attr,l=e.size,o=e.title,c=function(e,t){if(null==e)return{};var n,s,i=function(e,t){if(null==e)return{};var n={};for(var s in e)if(({}).hasOwnProperty.call(e,s)){if(-1!==t.indexOf(s))continue;n[s]=e[s]}return n}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(s=0;s<l.length;s++)n=l[s],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(e,a),m=l||t.size||"1em";return t.className&&(n=t.className),e.className&&(n=(n?n+" ":"")+e.className),s.createElement("svg",r({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,i,c,{className:n,style:d(d({color:e.color||t.color},t.style),e.style),height:m,width:m,xmlns:"http://www.w3.org/2000/svg"}),o&&s.createElement("title",null,o),e.children)};return void 0!==l?s.createElement(l.Consumer,null,e=>t(e)):t(i)}},59916:(e,t,n)=>{"use strict";n.d(t,{Jj:()=>i,Wv:()=>s,mL:()=>l});let s={design:"twin.topicDesign",frontend:"twin.topicFrontend",backend:"twin.topicBackend",cli:"twin.topicCli",testing:"twin.topicTesting",copy:"twin.topicCopy",workflow:"twin.topicWorkflow",tooling:"twin.topicTooling",data:"twin.topicData",other:"twin.topicOther"};function i(e){return s[e]}function l(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e.slice(0,10);let s=String(n.getMonth()+1).padStart(2,"0"),i=String(n.getDate()).padStart(2,"0");return"en"===t?"".concat(n.getFullYear(),"-").concat(s,"-").concat(i):"".concat(i,"/").concat(s,"/").concat(n.getFullYear())}},66229:(e,t,n)=>{"use strict";n.d(t,{TwinConsent:()=>o});var s=n(38657),i=n(32165),l=n(10354),a=n(9144),r=n(52948);function o(e){let{standing:t,chars:n,cap:o}=e,d=(0,a.kj)(),c=(0,l.useRouter)(),[m,u]=(0,i.useState)(!1),[x,p]=(0,i.useState)(null);async function h(e){u(!0),p(null);try{var t;let n=await fetch("/api/twin/taste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({publishInferred:e})}),s=await n.json();n.ok||p(null!=(t=s.error)?t:String(n.status)),c.refresh()}catch(e){p(d("project.unreachable"))}finally{u(!1)}}return(0,s.jsxs)(r.Zp,{as:"section",tone:"plain",className:"mt-8","aria-labelledby":"twin-consent-title",children:[(0,s.jsx)("h2",{id:"twin-consent-title",className:"text-base font-semibold",children:d("twin.consentTitle")}),(0,s.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed",children:d("twin.consentBody")}),(0,s.jsxs)("p",{className:"mt-2 max-w-2xl font-mono text-xs ".concat(n>o?"text-idle":"text-smoke"),children:[d("twin.consentCount",{n:t,chars:n}),n>o?" \xb7 ".concat(d("twin.consentOver",{cap:o})):""]}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,s.jsx)(r.rA,{tone:"accent",type:"button",onClick:()=>h(!0),busy:m,busyLabel:d("twin.saving"),children:d("twin.consentAllow")}),(0,s.jsx)("span",{className:"font-mono text-xs text-faint",children:d("twin.consentRevoke")})]}),x&&(0,s.jsx)(r.lZ,{text:d("twin.saveFailed",{detail:x}),className:"mt-2"})]})}},73856:(e,t,n)=>{"use strict";n.d(t,{TwinTeach:()=>m});var s=n(38657),i=n(32165),l=n(10354),a=n(3043),r=n(9144),o=n(52948),d=n(59916),c=n(26488);function m(e){let{projects:t,omitted:n}=e,m=(0,r.kj)(),u=(0,l.useRouter)(),[x,p]=(0,i.useState)(""),[h,w]=(0,i.useState)("workflow"),[f,b]=(0,i.useState)(""),[y,g]=(0,i.useState)(!1),[j,v]=(0,i.useState)(null),[N,k]=(0,i.useState)(null),M=(0,i.useRef)(!1);async function S(e){if(e.preventDefault(),!M.current&&x.trim()){M.current=!0,g(!0),v(null),k(null);try{let e=await fetch("/api/twin/taste",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({teach:{statement:x,topic:h,...f?{slug:f}:{}}})}),n=await e.json();if(!e.ok||!n.beliefId){var t;v(null!=(t=n.error)?t:m("twinTeach.failed"));return}p(""),k(n.beliefId),u.refresh()}catch(e){v(m("project.unreachable"))}finally{M.current=!1,g(!1)}}}return(0,s.jsx)("section",{id:"teach",tabIndex:-1,"aria-labelledby":"twin-teach-title",className:"page-shell__section scroll-mt-24 rounded-lg border border-edge bg-surface p-5 sm:p-6",children:(0,s.jsxs)("div",{className:"grid gap-6 lg:grid-cols-[1fr_1.4fr]",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"flex items-center gap-2 font-mono text-xs text-smoke",children:[(0,s.jsx)(a.YUE,{"aria-hidden":!0,className:"h-4 w-4"}),m("twinTeach.eyebrow")]}),(0,s.jsx)("h2",{id:"twin-teach-title",className:"mt-2 text-base font-semibold",children:m("twinTeach.title")}),(0,s.jsx)("p",{className:"mt-3 max-w-md text-sm leading-relaxed text-smoke",children:m("twinTeach.lead")}),(0,s.jsx)("p",{className:"mt-3 max-w-md text-xs leading-relaxed text-smoke",children:m("twinTeach.control")})]}),(0,s.jsxs)("form",{onSubmit:S,"aria-busy":y,children:[(0,s.jsx)(o.fs,{label:m("twinTeach.statement"),value:x,onChange:e=>{p(e.target.value),k(null)},required:!0,maxLength:c.P,rows:3,disabled:y,placeholder:m("twinTeach.placeholder"),"aria-describedby":"twin-teach-count"}),(0,s.jsx)("p",{id:"twin-teach-count",className:"mt-1 text-right font-mono text-xs text-smoke",children:m("twinTeach.characters",{n:x.length,max:c.P})}),(0,s.jsxs)("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[(0,s.jsx)(o.l6,{label:m("twinTeach.topic"),value:h,disabled:y,onChange:e=>w(e.target.value),children:Object.entries(d.Wv).map(e=>{let[t,n]=e;return(0,s.jsx)("option",{value:t,children:m(n)},t)})}),(0,s.jsxs)("div",{children:[(0,s.jsxs)(o.l6,{label:m("twinTeach.scope"),value:f,disabled:y,"aria-describedby":n>0?"twin-teach-scope-note":void 0,onChange:e=>b(e.target.value),children:[(0,s.jsx)("option",{value:"",children:m("twinTeach.global")}),t.map(e=>(0,s.jsx)("option",{value:e.slug,children:e.label},e.slug))]}),n>0&&(0,s.jsx)("p",{id:"twin-teach-scope-note",className:"mt-2 text-xs leading-relaxed text-smoke",children:m("twinTeach.scopeOmitted",{n:n})})]})]}),(0,s.jsxs)("div",{className:"mt-4 flex flex-wrap items-center gap-3",children:[(0,s.jsx)(o.rA,{type:"submit",tone:"accent",busy:y,busyLabel:m("twinTeach.saving"),disabled:y||!x.trim(),children:m("twinTeach.save")}),(0,s.jsx)("span",{className:"text-xs text-smoke",children:m("twinTeach.cost")})]}),j&&(0,s.jsx)(o.lZ,{text:j,className:"mt-3"}),(0,s.jsx)("div",{role:"status","aria-live":"polite",children:N&&(0,s.jsxs)("p",{className:"mt-3 text-sm text-smoke",children:[m("twinTeach.saved")," "," ",(0,s.jsx)("a",{href:"#belief-".concat(N),className:"underline underline-offset-4",children:m("twinTeach.view")})]})})]})]})})}},87885:(e,t,n)=>{Promise.resolve().then(n.bind(n,18557)),Promise.resolve().then(n.bind(n,66229)),Promise.resolve().then(n.bind(n,92458)),Promise.resolve().then(n.bind(n,3030)),Promise.resolve().then(n.bind(n,4733)),Promise.resolve().then(n.bind(n,88145)),Promise.resolve().then(n.bind(n,15797)),Promise.resolve().then(n.bind(n,73856)),Promise.resolve().then(n.t.bind(n,3953,23))},88145:(e,t,n)=>{"use strict";n.d(t,{TwinSources:()=>o});var s=n(38657),i=n(32165),l=n(10354),a=n(9144),r=n(52948);function o(e){let{sources:t}=e,n=(0,a.kj)(),o=(0,l.useRouter)(),[d,c]=(0,i.useState)(null),[m,u]=(0,i.useState)(null),[x,p]=(0,i.useState)(t);async function h(e,t){c(e),u(null);try{let n=await fetch("/api/twin/sources",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:e,allowed:t})}),i=await n.json();if(!n.ok){var s;u(null!=(s=i.error)?s:String(n.status));return}i.sources&&p(i.sources),o.refresh()}catch(e){u(n("project.unreachable"))}finally{c(null)}}let w=x.filter(e=>"absent"!==e.state);return 0===w.length?(0,s.jsxs)(r.Zp,{as:"section",tone:"plain","aria-labelledby":"twin-sources-title",children:[(0,s.jsx)("h2",{id:"twin-sources-title",className:"text-base font-semibold",children:n("twin.sourcesTitle")}),(0,s.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed",children:n("twin.sourcesNone")})]}):(0,s.jsxs)(r.Zp,{as:"section",tone:"plain","aria-labelledby":"twin-sources-title",children:[(0,s.jsx)("h2",{id:"twin-sources-title",className:"text-base font-semibold",children:n("twin.sourcesTitle")}),(0,s.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed",children:n("twin.sourcesLead")}),(0,s.jsx)("div",{className:"mt-3 flex flex-col gap-2",children:w.map(e=>(0,s.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 gap-y-1",children:[(0,s.jsxs)("span",{className:"min-w-0",children:[(0,s.jsx)("span",{className:"font-mono text-xs",children:e.label})," ",(0,s.jsx)("span",{className:"font-mono text-xs text-smoke",children:e.present?n("twin.sourceSize",{files:e.files,size:(0,r.z3)(e.bytes)}):n("twin.sourceGone")})]}),"noReader"===e.state?(0,s.jsx)("span",{className:"justify-self-end font-mono text-xs text-idle",children:n("twin.sourceNoReader")}):(0,s.jsx)(r.rA,{tone:"allowed"===e.state?"plain":"accent",type:"button",onClick:()=>h(e.id,"allowed"!==e.state),busy:d===e.id,busyLabel:n("twin.saving"),disabled:null!==d,className:"justify-self-end",children:n("allowed"===e.state?"twin.sourceRevoke":"twin.sourceAllow")})]},e.id))}),(0,s.jsx)("p",{className:"mt-3 max-w-2xl font-mono text-xs text-faint",children:n("twin.sourcesRevokeNote")}),m&&(0,s.jsx)(r.lZ,{text:m,className:"mt-2"})]})}},92458:(e,t,n)=>{"use strict";n.d(t,{TwinDistill:()=>o});var s=n(38657),i=n(32165),l=n(10354),a=n(9144),r=n(52948);function o(e){let{left:t,granted:n}=e,o=(0,a.kj)(),m=(0,l.useRouter)(),[u,x]=(0,i.useState)(!1),[p,h]=(0,i.useState)(null),[w,f]=(0,i.useState)(null);async function b(){x(!0),h(null),f(null);try{var e,t,n,s,i,l,a,r;h(o("twin.mining"));let u=await d();if(u.unreachable)h(o("project.unreachable"));else if(void 0!==u.error){if(h(u.error),u.blocked)return}else{let a=null!=(t=u.saved)?t:0,r=null!=(n=null==(e=u.denied)?void 0:e.length)?n:0,d=[0===a?o("twin.minedNone"):o("twin.mined",{saved:a,duplicates:null!=(s=u.duplicates)?s:0})];(null!=(i=u.narrativesSaved)?i:0)>0&&d.push(o("twin.minedRecords",{n:null!=(l=u.narrativesSaved)?l:0})),r>0&&d.push(o("twin.minedDenied",{n:r})),h(d.join(" \xb7 "))}let x=await c({dryRun:!0});if(x.error)return void h(x.hint?"".concat(x.error," ").concat(x.hint):x.error);if(!x.verdicts)return void h(o("twin.distillNothing"));f({verdicts:x.verdicts,tokens:null!=(a=x.estimatedTokens)?a:0}),h(o("twin.distillEstimate",{verdicts:x.verdicts,tokens:null!=(r=x.estimatedTokens)?r:0})),m.refresh()}catch(e){h(o("project.unreachable"))}finally{x(!1)}}async function y(){x(!0),f(null);try{let i=0,l=0,a=0;for(let r=1;r<=20;r+=1){var e,t,n,s;let r=await c({});if(i+=null!=(e=r.verdicts)?e:0,l+=null!=(t=r.saved)?t:0,a+=null!=(n=r.truncated)?n:0,r.error){h(r.hint?"".concat(r.error," ").concat(r.hint):r.error);break}let d=r.corpus?Math.max(r.corpus.total-r.corpus.read,0):0,m=null!=(s=r.thin)?s:0,u=[o("twin.distillProgress",{read:i,saved:l,left:d})];if(m>0&&u.push(o("twin.distillThin",{n:m})),a>0&&u.push(o("twin.distillTruncated",{n:a})),h(u.join(" \xb7 ")),!r.verdicts||d<=0)break}m.refresh()}catch(e){h(o("project.unreachable"))}finally{x(!1)}}return(0,s.jsxs)("div",{className:"mt-2 flex flex-col gap-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(r.rA,{tone:"plain",type:"button",onClick:b,busy:u&&null===w,busyLabel:o("twin.distilling"),disabled:!n||u,"aria-describedby":n?void 0:"twin-distill-why",className:"self-start",children:t>0?o("twin.mineButtonLeft",{n:t}):o("twin.mineButton")}),null!==w&&(0,s.jsx)(r.rA,{tone:"accent",type:"button",onClick:y,busy:u,busyLabel:o("twin.distillingPaid"),disabled:u,children:o("twin.distillGo",{n:w.verdicts})})]}),n&&(0,s.jsx)("p",{className:"text-xs leading-relaxed text-smoke",children:o("twin.distillCost")}),!n&&(0,s.jsx)("p",{id:"twin-distill-why",className:"text-xs leading-relaxed text-smoke",children:o("twin.distillNoConsent")}),(0,s.jsx)("div",{role:"status","aria-live":"polite",children:p&&(0,s.jsx)("p",{className:"font-mono text-xs text-smoke",children:p})})]})}async function d(){try{var e;let t=await fetch("/api/twin/mine",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),n=await t.json();if(t.ok)return n;return{error:null!=(e=n.error)?e:String(t.status),...409===t.status?{blocked:!0}:{}}}catch(e){return{unreachable:!0}}}async function c(e){var t;let n=await fetch("/api/twin/distill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await n.json();return n.ok?s:{...s,error:null!=(t=s.error)?t:String(n.status)}}}},e=>{e.O(0,[6587,3953,2575,2948,1305,6823,7358],()=>e(e.s=87885)),_N_E=e.O()}]);
|