@marinoscar/vault-web 0.0.0-bootstrap → 0.1.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/LICENSE +21 -0
  3. package/README.md +99 -0
  4. package/dist/agent/headless/agentActivity.d.ts +53 -0
  5. package/dist/agent/headless/agentActivity.js +58 -0
  6. package/dist/agent/headless/index.d.ts +2 -0
  7. package/dist/agent/headless/index.js +3 -0
  8. package/dist/agent/headless/useAgentActivity.d.ts +9 -0
  9. package/dist/agent/headless/useAgentActivity.js +30 -0
  10. package/dist/agent/ui/components/AgentActivityTable.d.ts +25 -0
  11. package/dist/agent/ui/components/AgentActivityTable.js +114 -0
  12. package/dist/agent/ui/index.d.ts +3 -0
  13. package/dist/agent/ui/index.js +4 -0
  14. package/dist/agent/ui/pages/AgentAccessSettingsPage.d.ts +7 -0
  15. package/dist/agent/ui/pages/AgentAccessSettingsPage.js +70 -0
  16. package/dist/agent/ui/pages/AgentActivityPage.d.ts +6 -0
  17. package/dist/agent/ui/pages/AgentActivityPage.js +61 -0
  18. package/dist/backups/headless/backupContents.d.ts +69 -0
  19. package/dist/backups/headless/backupContents.js +133 -0
  20. package/dist/backups/headless/backupPassword.d.ts +34 -0
  21. package/dist/backups/headless/backupPassword.js +80 -0
  22. package/dist/backups/headless/backupSchedule.d.ts +56 -0
  23. package/dist/backups/headless/backupSchedule.js +189 -0
  24. package/dist/backups/headless/index.d.ts +4 -0
  25. package/dist/backups/headless/index.js +5 -0
  26. package/dist/backups/headless/useBackupRunHistory.d.ts +36 -0
  27. package/dist/backups/headless/useBackupRunHistory.js +83 -0
  28. package/dist/backups/ui/components/AdminBackupDownloadDialog.d.ts +20 -0
  29. package/dist/backups/ui/components/AdminBackupDownloadDialog.js +65 -0
  30. package/dist/backups/ui/components/BackupContentsGroup.d.ts +17 -0
  31. package/dist/backups/ui/components/BackupContentsGroup.js +21 -0
  32. package/dist/backups/ui/components/BackupPasswordFields.d.ts +18 -0
  33. package/dist/backups/ui/components/BackupPasswordFields.js +40 -0
  34. package/dist/backups/ui/components/BackupRunsTable.d.ts +44 -0
  35. package/dist/backups/ui/components/BackupRunsTable.js +61 -0
  36. package/dist/backups/ui/components/DataBackup.d.ts +14 -0
  37. package/dist/backups/ui/components/DataBackup.js +169 -0
  38. package/dist/backups/ui/components/ScheduledBackups.d.ts +13 -0
  39. package/dist/backups/ui/components/ScheduledBackups.js +304 -0
  40. package/dist/backups/ui/index.d.ts +8 -0
  41. package/dist/backups/ui/index.js +9 -0
  42. package/dist/backups/ui/pages/BackupSettingsPage.d.ts +8 -0
  43. package/dist/backups/ui/pages/BackupSettingsPage.js +19 -0
  44. package/dist/backups/ui/pages/MyBackupsPage.d.ts +8 -0
  45. package/dist/backups/ui/pages/MyBackupsPage.js +19 -0
  46. package/dist/brand/BrandLockup.d.ts +14 -0
  47. package/dist/brand/BrandLockup.js +13 -0
  48. package/dist/brand/assets/vault-mark.png +0 -0
  49. package/dist/brand/contrast.d.ts +8 -0
  50. package/dist/brand/contrast.js +21 -0
  51. package/dist/brand/index.d.ts +7 -0
  52. package/dist/brand/index.js +8 -0
  53. package/dist/brand/mark.d.ts +6 -0
  54. package/dist/brand/mark.js +7 -0
  55. package/dist/brand/theme.d.ts +25 -0
  56. package/dist/brand/theme.js +84 -0
  57. package/dist/brand/tokens.d.ts +52 -0
  58. package/dist/brand/tokens.js +54 -0
  59. package/dist/cards/headless/cardExpiry.d.ts +57 -0
  60. package/dist/cards/headless/cardExpiry.js +138 -0
  61. package/dist/cards/headless/cardFormat.d.ts +60 -0
  62. package/dist/cards/headless/cardFormat.js +135 -0
  63. package/dist/cards/headless/cardImage.d.ts +293 -0
  64. package/dist/cards/headless/cardImage.js +518 -0
  65. package/dist/cards/headless/index.d.ts +6 -0
  66. package/dist/cards/headless/index.js +7 -0
  67. package/dist/cards/headless/useCardImport.d.ts +137 -0
  68. package/dist/cards/headless/useCardImport.js +391 -0
  69. package/dist/cards/headless/useCardRenewal.d.ts +102 -0
  70. package/dist/cards/headless/useCardRenewal.js +305 -0
  71. package/dist/cards/headless/useCards.d.ts +80 -0
  72. package/dist/cards/headless/useCards.js +114 -0
  73. package/dist/cards/ui/components/AiEgressNotice.d.ts +13 -0
  74. package/dist/cards/ui/components/AiEgressNotice.js +18 -0
  75. package/dist/cards/ui/components/CardCaptureStep.d.ts +59 -0
  76. package/dist/cards/ui/components/CardCaptureStep.js +96 -0
  77. package/dist/cards/ui/components/CardCropAdjuster.d.ts +43 -0
  78. package/dist/cards/ui/components/CardCropAdjuster.js +215 -0
  79. package/dist/cards/ui/components/CardCropReview.d.ts +51 -0
  80. package/dist/cards/ui/components/CardCropReview.js +88 -0
  81. package/dist/cards/ui/components/CardExpiryBadge.d.ts +8 -0
  82. package/dist/cards/ui/components/CardExpiryBadge.js +43 -0
  83. package/dist/cards/ui/components/CardFieldDiff.d.ts +37 -0
  84. package/dist/cards/ui/components/CardFieldDiff.js +66 -0
  85. package/dist/cards/ui/components/CardFlowStepper.d.ts +24 -0
  86. package/dist/cards/ui/components/CardFlowStepper.js +23 -0
  87. package/dist/cards/ui/components/CardReviewForm.d.ts +44 -0
  88. package/dist/cards/ui/components/CardReviewForm.js +102 -0
  89. package/dist/cards/ui/components/CardScanModelSection.d.ts +23 -0
  90. package/dist/cards/ui/components/CardScanModelSection.js +81 -0
  91. package/dist/cards/ui/components/CardTile.d.ts +40 -0
  92. package/dist/cards/ui/components/CardTile.js +94 -0
  93. package/dist/cards/ui/index.d.ts +15 -0
  94. package/dist/cards/ui/index.js +16 -0
  95. package/dist/cards/ui/pages/AiSettingsPage.d.ts +12 -0
  96. package/dist/cards/ui/pages/AiSettingsPage.js +24 -0
  97. package/dist/cards/ui/pages/CardsPage.d.ts +26 -0
  98. package/dist/cards/ui/pages/CardsPage.js +160 -0
  99. package/dist/cards/ui/pages/ImportCardPage.d.ts +24 -0
  100. package/dist/cards/ui/pages/ImportCardPage.js +343 -0
  101. package/dist/cards/ui/pages/RenewCardPage.d.ts +35 -0
  102. package/dist/cards/ui/pages/RenewCardPage.js +350 -0
  103. package/dist/core/headless/api.d.ts +272 -0
  104. package/dist/core/headless/api.js +425 -0
  105. package/dist/core/headless/cardScanAvailability.d.ts +20 -0
  106. package/dist/core/headless/cardScanAvailability.js +27 -0
  107. package/dist/core/headless/clipboard.d.ts +60 -0
  108. package/dist/core/headless/clipboard.js +101 -0
  109. package/dist/core/headless/http.d.ts +41 -0
  110. package/dist/core/headless/http.js +50 -0
  111. package/dist/core/headless/index.d.ts +12 -0
  112. package/dist/core/headless/index.js +13 -0
  113. package/dist/core/headless/relativeTime.d.ts +7 -0
  114. package/dist/core/headless/relativeTime.js +28 -0
  115. package/dist/core/headless/saveBlob.d.ts +6 -0
  116. package/dist/core/headless/saveBlob.js +21 -0
  117. package/dist/core/headless/types.d.ts +441 -0
  118. package/dist/core/headless/types.js +49 -0
  119. package/dist/core/headless/useAiStatus.d.ts +41 -0
  120. package/dist/core/headless/useAiStatus.js +42 -0
  121. package/dist/core/headless/useCopyToClipboard.d.ts +20 -0
  122. package/dist/core/headless/useCopyToClipboard.js +52 -0
  123. package/dist/core/headless/useDashboardResource.d.ts +22 -0
  124. package/dist/core/headless/useDashboardResource.js +52 -0
  125. package/dist/core/headless/useSystemSettings.d.ts +17 -0
  126. package/dist/core/headless/useSystemSettings.js +106 -0
  127. package/dist/core/headless/useUserSettings.d.ts +13 -0
  128. package/dist/core/headless/useUserSettings.js +103 -0
  129. package/dist/core/ui/ErrorBoundary.d.ts +15 -0
  130. package/dist/core/ui/ErrorBoundary.js +27 -0
  131. package/dist/core/ui/LoadingSpinner.d.ts +6 -0
  132. package/dist/core/ui/LoadingSpinner.js +14 -0
  133. package/dist/core/ui/SettingsPageFrame.d.ts +19 -0
  134. package/dist/core/ui/SettingsPageFrame.js +12 -0
  135. package/dist/core/ui/StorageSettingsLink.d.ts +19 -0
  136. package/dist/core/ui/StorageSettingsLink.js +26 -0
  137. package/dist/core/ui/index.d.ts +4 -0
  138. package/dist/core/ui/index.js +5 -0
  139. package/dist/home/headless/homeLinks.d.ts +24 -0
  140. package/dist/home/headless/homeLinks.js +24 -0
  141. package/dist/home/headless/index.d.ts +1 -0
  142. package/dist/home/headless/index.js +2 -0
  143. package/dist/home/ui/components/BackupStatusPanel.d.ts +28 -0
  144. package/dist/home/ui/components/BackupStatusPanel.js +99 -0
  145. package/dist/home/ui/components/DashboardPanel.d.ts +33 -0
  146. package/dist/home/ui/components/DashboardPanel.js +21 -0
  147. package/dist/home/ui/components/ExpiringCardsPanel.d.ts +31 -0
  148. package/dist/home/ui/components/ExpiringCardsPanel.js +35 -0
  149. package/dist/home/ui/components/FirstRunPanel.d.ts +7 -0
  150. package/dist/home/ui/components/FirstRunPanel.js +21 -0
  151. package/dist/home/ui/components/QuickActions.d.ts +14 -0
  152. package/dist/home/ui/components/QuickActions.js +40 -0
  153. package/dist/home/ui/components/RecentSecretsPanel.d.ts +19 -0
  154. package/dist/home/ui/components/RecentSecretsPanel.js +20 -0
  155. package/dist/home/ui/components/StatsRow.d.ts +19 -0
  156. package/dist/home/ui/components/StatsRow.js +46 -0
  157. package/dist/home/ui/components/WelcomeHeader.d.ts +11 -0
  158. package/dist/home/ui/components/WelcomeHeader.js +15 -0
  159. package/dist/home/ui/index.d.ts +9 -0
  160. package/dist/home/ui/index.js +10 -0
  161. package/dist/home/ui/pages/HomePage.d.ts +14 -0
  162. package/dist/home/ui/pages/HomePage.js +121 -0
  163. package/dist/index.d.ts +5 -0
  164. package/dist/index.js +5 -0
  165. package/dist/media/headless/index.d.ts +2 -0
  166. package/dist/media/headless/index.js +3 -0
  167. package/dist/media/headless/useMediaFiles.d.ts +20 -0
  168. package/dist/media/headless/useMediaFiles.js +82 -0
  169. package/dist/media/headless/useMediaFolders.d.ts +22 -0
  170. package/dist/media/headless/useMediaFolders.js +81 -0
  171. package/dist/media/ui/components/FolderList.d.ts +19 -0
  172. package/dist/media/ui/components/FolderList.js +36 -0
  173. package/dist/media/ui/components/MediaList.d.ts +20 -0
  174. package/dist/media/ui/components/MediaList.js +55 -0
  175. package/dist/media/ui/components/MediaPlayer.d.ts +7 -0
  176. package/dist/media/ui/components/MediaPlayer.js +361 -0
  177. package/dist/media/ui/index.d.ts +10 -0
  178. package/dist/media/ui/index.js +11 -0
  179. package/dist/media/ui/pages/CreateFolderPage.d.ts +1 -0
  180. package/dist/media/ui/pages/CreateFolderPage.js +39 -0
  181. package/dist/media/ui/pages/EditFolderPage.d.ts +1 -0
  182. package/dist/media/ui/pages/EditFolderPage.js +59 -0
  183. package/dist/media/ui/pages/MediaFolderPage.d.ts +1 -0
  184. package/dist/media/ui/pages/MediaFolderPage.js +68 -0
  185. package/dist/media/ui/pages/MediaFoldersPage.d.ts +1 -0
  186. package/dist/media/ui/pages/MediaFoldersPage.js +58 -0
  187. package/dist/media/ui/pages/MediaPlayerPage.d.ts +1 -0
  188. package/dist/media/ui/pages/MediaPlayerPage.js +76 -0
  189. package/dist/media/ui/pages/MediaUploadPage.d.ts +1 -0
  190. package/dist/media/ui/pages/MediaUploadPage.js +88 -0
  191. package/dist/media/ui/pages/RenameMediaFilePage.d.ts +1 -0
  192. package/dist/media/ui/pages/RenameMediaFilePage.js +63 -0
  193. package/dist/navigation/destinations.d.ts +50 -0
  194. package/dist/navigation/destinations.js +109 -0
  195. package/dist/navigation/index.d.ts +1 -0
  196. package/dist/navigation/index.js +4 -0
  197. package/dist/secrets/headless/fieldOptionsValidation.d.ts +45 -0
  198. package/dist/secrets/headless/fieldOptionsValidation.js +79 -0
  199. package/dist/secrets/headless/index.d.ts +6 -0
  200. package/dist/secrets/headless/index.js +7 -0
  201. package/dist/secrets/headless/secretFields.d.ts +86 -0
  202. package/dist/secrets/headless/secretFields.js +190 -0
  203. package/dist/secrets/headless/useSecretDetail.d.ts +33 -0
  204. package/dist/secrets/headless/useSecretDetail.js +87 -0
  205. package/dist/secrets/headless/useSecretTypes.d.ts +16 -0
  206. package/dist/secrets/headless/useSecretTypes.js +62 -0
  207. package/dist/secrets/headless/useSecrets.d.ts +24 -0
  208. package/dist/secrets/headless/useSecrets.js +59 -0
  209. package/dist/secrets/headless/useTotpCode.d.ts +24 -0
  210. package/dist/secrets/headless/useTotpCode.js +116 -0
  211. package/dist/secrets/ui/components/CardImages.d.ts +31 -0
  212. package/dist/secrets/ui/components/CardImages.js +208 -0
  213. package/dist/secrets/ui/components/DynamicSecretFields.d.ts +10 -0
  214. package/dist/secrets/ui/components/DynamicSecretFields.js +90 -0
  215. package/dist/secrets/ui/components/FieldDefinitionBuilder.d.ts +13 -0
  216. package/dist/secrets/ui/components/FieldDefinitionBuilder.js +114 -0
  217. package/dist/secrets/ui/components/FieldOptionsEditor.d.ts +15 -0
  218. package/dist/secrets/ui/components/FieldOptionsEditor.js +45 -0
  219. package/dist/secrets/ui/components/SecretAttachments.d.ts +15 -0
  220. package/dist/secrets/ui/components/SecretAttachments.js +106 -0
  221. package/dist/secrets/ui/components/SecretForm.d.ts +34 -0
  222. package/dist/secrets/ui/components/SecretForm.js +83 -0
  223. package/dist/secrets/ui/components/SecretFormDialog.d.ts +15 -0
  224. package/dist/secrets/ui/components/SecretFormDialog.js +95 -0
  225. package/dist/secrets/ui/components/SecretTypeFormDialog.d.ts +15 -0
  226. package/dist/secrets/ui/components/SecretTypeFormDialog.js +92 -0
  227. package/dist/secrets/ui/components/SecretTypeIcon.d.ts +8 -0
  228. package/dist/secrets/ui/components/SecretTypeIcon.js +16 -0
  229. package/dist/secrets/ui/components/SecretTypesList.d.ts +10 -0
  230. package/dist/secrets/ui/components/SecretTypesList.js +13 -0
  231. package/dist/secrets/ui/components/SecretValueField.d.ts +20 -0
  232. package/dist/secrets/ui/components/SecretValueField.js +52 -0
  233. package/dist/secrets/ui/components/SecretVersionDrawer.d.ts +22 -0
  234. package/dist/secrets/ui/components/SecretVersionDrawer.js +131 -0
  235. package/dist/secrets/ui/components/SecretsTable.d.ts +49 -0
  236. package/dist/secrets/ui/components/SecretsTable.js +174 -0
  237. package/dist/secrets/ui/components/TotpCodeCard.d.ts +8 -0
  238. package/dist/secrets/ui/components/TotpCodeCard.js +34 -0
  239. package/dist/secrets/ui/index.d.ts +20 -0
  240. package/dist/secrets/ui/index.js +21 -0
  241. package/dist/secrets/ui/pages/CreateSecretPage.d.ts +2 -0
  242. package/dist/secrets/ui/pages/CreateSecretPage.js +25 -0
  243. package/dist/secrets/ui/pages/CreateSecretTypePage.d.ts +1 -0
  244. package/dist/secrets/ui/pages/CreateSecretTypePage.js +62 -0
  245. package/dist/secrets/ui/pages/EditSecretPage.d.ts +5 -0
  246. package/dist/secrets/ui/pages/EditSecretPage.js +55 -0
  247. package/dist/secrets/ui/pages/EditSecretTypePage.d.ts +1 -0
  248. package/dist/secrets/ui/pages/EditSecretTypePage.js +88 -0
  249. package/dist/secrets/ui/pages/SecretDetailPage.d.ts +7 -0
  250. package/dist/secrets/ui/pages/SecretDetailPage.js +182 -0
  251. package/dist/secrets/ui/pages/SecretTypesPage.d.ts +1 -0
  252. package/dist/secrets/ui/pages/SecretTypesPage.js +23 -0
  253. package/dist/secrets/ui/pages/SecretsPage.d.ts +6 -0
  254. package/dist/secrets/ui/pages/SecretsPage.js +179 -0
  255. package/dist/settings/ui/components/FeatureFlagsList.d.ts +7 -0
  256. package/dist/settings/ui/components/FeatureFlagsList.js +46 -0
  257. package/dist/settings/ui/components/ImageUpload.d.ts +6 -0
  258. package/dist/settings/ui/components/ImageUpload.js +61 -0
  259. package/dist/settings/ui/components/ProfileSettings.d.ts +11 -0
  260. package/dist/settings/ui/components/ProfileSettings.js +55 -0
  261. package/dist/settings/ui/components/ThemeSettings.d.ts +7 -0
  262. package/dist/settings/ui/components/ThemeSettings.js +24 -0
  263. package/dist/settings/ui/components/UISettings.d.ts +9 -0
  264. package/dist/settings/ui/components/UISettings.js +25 -0
  265. package/dist/settings/ui/components/UserProfileCard.d.ts +1 -0
  266. package/dist/settings/ui/components/UserProfileCard.js +39 -0
  267. package/dist/settings/ui/components/UserSettingsSection.d.ts +23 -0
  268. package/dist/settings/ui/components/UserSettingsSection.js +29 -0
  269. package/dist/settings/ui/index.d.ts +10 -0
  270. package/dist/settings/ui/index.js +11 -0
  271. package/dist/settings/ui/pages/AppearanceSettingsPage.d.ts +6 -0
  272. package/dist/settings/ui/pages/AppearanceSettingsPage.js +11 -0
  273. package/dist/settings/ui/pages/GeneralSettingsPage.d.ts +9 -0
  274. package/dist/settings/ui/pages/GeneralSettingsPage.js +41 -0
  275. package/dist/settings/ui/pages/ProfileSettingsPage.d.ts +6 -0
  276. package/dist/settings/ui/pages/ProfileSettingsPage.js +11 -0
  277. package/package.json +146 -1
@@ -0,0 +1,293 @@
1
+ /**
2
+ * ISO/IEC 7810 ID-1, the physical format every payment card uses:
3
+ * 85.60 mm x 53.98 mm, i.e. ~1.586:1.
4
+ *
5
+ * Locking the crop to this ratio is what lets the user frame a shot roughly and
6
+ * still hand the model a rectangle whose proportions match a real card.
7
+ */
8
+ export declare const CARD_ASPECT_RATIO: number;
9
+ /**
10
+ * Longest edge of the encoded image.
11
+ *
12
+ * Generous on purpose. An earlier 1400px cap assumed pixels past that point
13
+ * bought nothing, which proved false in practice: faint engraving (metal
14
+ * cards) photographed without filling the frame came out too small to read
15
+ * after crop + downscale. The provider downsizes internally anyway, so
16
+ * sending more pixels just lets IT decide what to keep — the only real cost
17
+ * is upload size, which the quality ladder below still bounds.
18
+ */
19
+ export declare const CARD_IMAGE_MAX_LONG_EDGE = 2048;
20
+ /** Starting JPEG quality. The ladder below drops from here only if it must. */
21
+ export declare const CARD_IMAGE_JPEG_QUALITY = 0.9;
22
+ /** Upper bound of the user-adjustable crop zoom (1 = the auto-fit rect). */
23
+ export declare const CARD_IMAGE_MAX_ZOOM = 4;
24
+ export declare const CARD_IMAGE_MIME_TYPE = "image/jpeg";
25
+ /**
26
+ * Largest data URL the API accepts, mirroring `MAX_IMAGE_DATA_URL_LENGTH` in
27
+ * `apps/api/src/ai/ai.constants.ts`. Measured in characters, not bytes, because
28
+ * that is what the server-side `.max()` checks.
29
+ */
30
+ export declare const MAX_IMAGE_DATA_URL_LENGTH = 6000000;
31
+ /**
32
+ * Longest edge of the FULL photo prepared for extraction.
33
+ *
34
+ * Higher than {@link CARD_IMAGE_MAX_LONG_EDGE} because the card typically
35
+ * occupies only part of the frame: after the model's box is cropped out, the
36
+ * card itself lands at a fraction of this. The photo is downscaled only when
37
+ * it exceeds this — never cropped, never rotated, aspect untouched — because
38
+ * the returned box is expressed in fractions of the image exactly as sent.
39
+ */
40
+ export declare const CARD_PHOTO_MAX_LONG_EDGE = 3072;
41
+ /**
42
+ * Margin added around an AI-returned card box before cropping, as a fraction
43
+ * of the box's longer edge. A sliver of context absorbs a slightly-tight box
44
+ * without visibly shrinking the card in the stored attachment.
45
+ */
46
+ export declare const CROP_BOX_MARGIN_FRACTION = 0.04;
47
+ export interface CropRect {
48
+ x: number;
49
+ y: number;
50
+ width: number;
51
+ height: number;
52
+ }
53
+ export interface OutputSize {
54
+ width: number;
55
+ height: number;
56
+ /** Factor applied to the crop rect to reach the output size; never above 1. */
57
+ scale: number;
58
+ }
59
+ export interface CardCropPlan {
60
+ /**
61
+ * In EFFECTIVE source coordinates: the source frame after `quarterTurns`
62
+ * clockwise quarter-turns have been applied. For odd turn counts the
63
+ * effective width/height are the source's swapped.
64
+ */
65
+ crop: CropRect;
66
+ output: OutputSize;
67
+ /** Clockwise quarter-turns (0-3) the renderer must apply at draw time. */
68
+ quarterTurns: number;
69
+ }
70
+ /**
71
+ * User adjustments to the crop, all optional and all defaulting to the
72
+ * auto-fit behavior (zoom 1, no pan, no rotation).
73
+ */
74
+ export interface CardAdjustments {
75
+ /** 1 = the auto-fit maximal rect; up to {@link CARD_IMAGE_MAX_ZOOM}. */
76
+ zoom?: number;
77
+ /** Pan offset from center, in effective source pixels. Clamped internally. */
78
+ panX?: number;
79
+ panY?: number;
80
+ /** Clockwise quarter-turns, 0-3. */
81
+ quarterTurns?: number;
82
+ }
83
+ export interface CardCropOptions extends CardAdjustments {
84
+ aspectRatio?: number;
85
+ maxLongEdge?: number;
86
+ }
87
+ /** Clamp `value` into `[min, max]`. Non-finite values clamp to `min`. */
88
+ export declare function clamp(value: number, min: number, max: number): number;
89
+ /** Normalize any number (or undefined) of quarter-turns into 0..3. */
90
+ export declare function normalizeQuarterTurns(turns: number | undefined): number;
91
+ /**
92
+ * The source frame's dimensions AFTER rotation. An odd number of quarter-turns
93
+ * swaps width and height; the crop rect is always computed against these
94
+ * effective dimensions, never the raw ones.
95
+ */
96
+ export declare function effectiveSourceSize(sourceWidth: number, sourceHeight: number, quarterTurns: number | undefined): {
97
+ width: number;
98
+ height: number;
99
+ };
100
+ /**
101
+ * The largest rectangle of `aspectRatio` that fits inside the source frame,
102
+ * centred.
103
+ *
104
+ * This is the STARTING point, not the final word: it is what the user sees at
105
+ * zoom 1 before adjusting. The centred maximal rect is right often enough to
106
+ * be a good default, but a card that does not fill the frame (or arrives
107
+ * rotated) is fixed by the user via {@link computeAdjustedCropRect} rather
108
+ * than by retaking the shot.
109
+ *
110
+ * Results are integers because they index pixels. Every value is clamped into
111
+ * the source frame so a rounding step can never produce a rect that hangs off
112
+ * the edge, and never a zero-width rect for a source only a few pixels across.
113
+ */
114
+ export declare function computeCardCropRect(sourceWidth: number, sourceHeight: number, aspectRatio?: number): CropRect;
115
+ /**
116
+ * How far the crop rect can move from center, per axis, in effective source
117
+ * pixels, at a given zoom. Zero on an axis the crop already fills.
118
+ *
119
+ * The UI uses this to clamp the STORED pan as the user drags or zooms out, so
120
+ * pan offsets never silently accumulate past the edge of the frame.
121
+ */
122
+ export declare function computeMaxPan(sourceWidth: number, sourceHeight: number, zoom: number, aspectRatio?: number): {
123
+ x: number;
124
+ y: number;
125
+ };
126
+ /**
127
+ * The user-adjusted crop rect: the auto-fit rect of
128
+ * {@link computeCardCropRect}, shrunk by `zoom` and moved by `(panX, panY)`
129
+ * from center.
130
+ *
131
+ * `zoom` is clamped into `[1, CARD_IMAGE_MAX_ZOOM]` and the rect is clamped so
132
+ * it never leaves the source frame, whatever pan is passed in. With
133
+ * `zoom = 1, panX = 0, panY = 0` this returns exactly the auto-fit rect.
134
+ *
135
+ * NOTE ON ROTATION: rotation is applied at draw time, not here. Callers
136
+ * cropping a rotated source must pass the EFFECTIVE dimensions (see
137
+ * {@link effectiveSourceSize}) — for odd quarter-turns width and height swap.
138
+ */
139
+ export declare function computeAdjustedCropRect(sourceWidth: number, sourceHeight: number, zoom: number, panX: number, panY: number, aspectRatio?: number): CropRect;
140
+ /**
141
+ * A card's location within a photo, as the extraction API reports it.
142
+ *
143
+ * `x`/`y`/`width`/`height` are fractions (0-1) of the image EXACTLY as it was
144
+ * sent for extraction. Fractions survive uniform scaling, so they apply
145
+ * equally to the raw capture the prepared photo was downscaled from — which is
146
+ * what the crop is actually rendered from, at full resolution.
147
+ */
148
+ export interface FractionalCropBox {
149
+ x: number;
150
+ y: number;
151
+ width: number;
152
+ height: number;
153
+ /** Clockwise quarter-turns (0-3) that make the card upright. */
154
+ quarterTurns?: number;
155
+ }
156
+ /**
157
+ * Convert an AI-returned fractional box into a pixel crop rect ready for
158
+ * {@link drawCardCrop}: fractions -> pixels, a small margin added, snapped to
159
+ * the card aspect ratio around the box centre, clamped inside the image.
160
+ *
161
+ * `imageWidth`/`imageHeight` are the RAW dimensions of the image the crop is
162
+ * rendered from. The returned rect is in EFFECTIVE coordinates — the frame
163
+ * after the box's `quarterTurns` have been applied (see
164
+ * {@link effectiveSourceSize}) — and must be paired with those same
165
+ * `quarterTurns` at draw time.
166
+ *
167
+ * The aspect snap only ever GROWS the box (the short axis is extended), so a
168
+ * tight box never cuts into the card; if growth would overflow the frame the
169
+ * rect is scaled down uniformly, preserving the aspect, and shifted inside.
170
+ *
171
+ * Throws `RangeError` for a degenerate box (no area inside the image), which
172
+ * callers treat as "no usable box" and fall back to the auto-fit crop.
173
+ */
174
+ export declare function cropRectFromBox(imageWidth: number, imageHeight: number, box: FractionalCropBox, aspectRatio?: number, marginFraction?: number): CropRect;
175
+ /**
176
+ * Express an explicit crop rect (EFFECTIVE coordinates) in the adjuster's
177
+ * zoom/pan/turns model, so {@link computeAdjustedCropRect} reproduces it (up
178
+ * to rounding).
179
+ *
180
+ * `zoom` is the ratio of the auto-fit rect to this one, clamped into the
181
+ * adjuster's `[1, CARD_IMAGE_MAX_ZOOM]` range — a rect outside that range is
182
+ * approximated by the nearest representable framing. Pan is the offset of the
183
+ * rect's centre from the frame's centre.
184
+ */
185
+ export declare function adjustmentsFromCropRect(sourceWidth: number, sourceHeight: number, crop: CropRect, quarterTurns: number | undefined, aspectRatio?: number): Required<CardAdjustments>;
186
+ /**
187
+ * Seed the adjuster from an AI-returned box: {@link cropRectFromBox} then
188
+ * {@link adjustmentsFromCropRect}, so the adjuster opens showing (as near as
189
+ * its model allows) exactly the crop the box produced.
190
+ */
191
+ export declare function adjustmentsFromCropBox(sourceWidth: number, sourceHeight: number, box: FractionalCropBox, aspectRatio?: number): Required<CardAdjustments>;
192
+ /**
193
+ * Downscale the crop so its longest edge is at most `maxLongEdge`.
194
+ *
195
+ * Never upscales: a low-resolution capture stays low-resolution rather than
196
+ * being inflated into a bigger file that carries no extra detail.
197
+ */
198
+ export declare function computeOutputSize(cropWidth: number, cropHeight: number, maxLongEdge?: number): OutputSize;
199
+ /**
200
+ * Crop rect plus the size it will be encoded at.
201
+ *
202
+ * With no adjustments in `options` this plans exactly the auto-fit centred
203
+ * crop it always has. With adjustments, the crop rect is computed against the
204
+ * ROTATED (effective) frame; the returned `quarterTurns` tells the renderer
205
+ * which rotation to apply at draw time so the rect lands where the user aimed.
206
+ */
207
+ export declare function planCardCrop(sourceWidth: number, sourceHeight: number, options?: CardCropOptions): CardCropPlan;
208
+ /**
209
+ * Decode a base64 data URL into a Blob.
210
+ *
211
+ * Used instead of `canvas.toBlob` so the canvas is encoded exactly once: the
212
+ * data URL measured against the size cap and the file uploaded to storage are
213
+ * guaranteed to be the same bytes, not two encodes that merely look alike.
214
+ */
215
+ export declare function dataUrlToBlob(dataUrl: string): Blob;
216
+ export interface CroppedCardImage {
217
+ /** JPEG data URL of the cropped card — the stored-attachment bytes. */
218
+ dataUrl: string;
219
+ /** The same bytes as a File, ready for the storage upload endpoint. */
220
+ file: File;
221
+ /** Object URL for on-screen preview. Callers must revoke it when done. */
222
+ previewUrl: string;
223
+ width: number;
224
+ height: number;
225
+ }
226
+ /** The full photo prepared for `POST /api/secrets/cards/extract`. */
227
+ export interface PreparedCardPhoto {
228
+ /** JPEG data URL of the FULL frame, exactly what the extraction call sends. */
229
+ dataUrl: string;
230
+ /**
231
+ * Dimensions of the encoded image. Box fractions in the extraction response
232
+ * apply to exactly this image (and, being fractions, equally to the raw
233
+ * capture it was scaled from).
234
+ */
235
+ width: number;
236
+ height: number;
237
+ }
238
+ /**
239
+ * Draw a planned card crop onto a destination rectangle, applying the plan's
240
+ * rotation.
241
+ *
242
+ * Shared by the final encode in {@link cropImageFileToCard} and the live
243
+ * preview in the adjust UI, so what the user sees while adjusting is drawn by
244
+ * the same code as what gets encoded. `destWidth`/`destHeight` need not match
245
+ * `plan.output` — the preview draws at screen resolution.
246
+ *
247
+ * The unrotated path is the exact `drawImage` source-rect call this module has
248
+ * always made. The rotated paths compose translate/rotate so that a point
249
+ * `(u, v)` of the raw source lands where the effective (rotated) frame puts
250
+ * it, then shift/scale the crop rect onto the destination.
251
+ */
252
+ export declare function drawCardCrop(context: CanvasRenderingContext2D, image: CanvasImageSource, sourceWidth: number, sourceHeight: number, plan: Pick<CardCropPlan, 'crop' | 'quarterTurns'>, destWidth: number, destHeight: number): void;
253
+ /**
254
+ * Prepare the FULL photo for extraction: decode, downscale only when the long
255
+ * edge exceeds {@link CARD_PHOTO_MAX_LONG_EDGE} — no crop, no aspect change,
256
+ * no rotation — and JPEG-encode under the API's size cap.
257
+ *
258
+ * The returned `dataUrl` is what goes to `POST /api/secrets/cards/extract`;
259
+ * the returned dimensions are the frame the response's box fractions apply to.
260
+ *
261
+ * Throws with a user-presentable message when the file is not decodable or
262
+ * cannot be squeezed under the cap.
263
+ */
264
+ export declare function prepareCardPhoto(file: File): Promise<PreparedCardPhoto>;
265
+ /**
266
+ * Crop, downscale and JPEG-encode a captured file to the card rectangle.
267
+ *
268
+ * `options` may carry user adjustments (`zoom`, `panX`, `panY`,
269
+ * `quarterTurns`); with none supplied the behavior is the historical auto-fit
270
+ * centred crop, unchanged.
271
+ *
272
+ * Throws with a user-presentable message when the file is not decodable or
273
+ * cannot be squeezed under the API's size cap.
274
+ */
275
+ export declare function cropImageFileToCard(file: File, options?: CardCropOptions & {
276
+ fileName?: string;
277
+ }): Promise<CroppedCardImage>;
278
+ /**
279
+ * Crop, downscale and JPEG-encode a captured file from an explicit fractional
280
+ * box — the AI-located card. The rect comes from {@link cropRectFromBox}
281
+ * (margin, aspect snap, clamping) and is rendered by the same
282
+ * {@link drawCardCrop} + quality-ladder path as every other crop.
283
+ *
284
+ * The crop is rendered from the RAW capture at full resolution: the box's
285
+ * fractions apply to the (possibly downscaled) prepared photo and to the raw
286
+ * frame alike, and the raw frame has more pixels to give.
287
+ */
288
+ export declare function cropImageFileToBox(file: File, box: FractionalCropBox, options?: {
289
+ fileName?: string;
290
+ aspectRatio?: number;
291
+ marginFraction?: number;
292
+ maxLongEdge?: number;
293
+ }): Promise<CroppedCardImage>;