@eifi1/ui-kit 0.18.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/README.md +67 -6
  2. package/dist/chart.d.ts +4 -1
  3. package/dist/components/amount-input.d.ts +4 -1
  4. package/dist/components/button-group.d.ts +4 -1
  5. package/dist/components/calculator.d.ts +4 -1
  6. package/dist/components/copy-button.d.ts +4 -1
  7. package/dist/components/facing-pair.d.ts +4 -1
  8. package/dist/components/file-button.d.ts +4 -1
  9. package/dist/components/file-dropzone.d.ts +4 -1
  10. package/dist/components/floating-panel.d.ts +4 -1
  11. package/dist/components/floating-panel.js +15 -1
  12. package/dist/components/floating-panel.js.map +1 -1
  13. package/dist/components/form-actions.d.ts +4 -1
  14. package/dist/components/legal.d.ts +84 -0
  15. package/dist/components/legal.js +55 -0
  16. package/dist/components/legal.js.map +1 -0
  17. package/dist/components/money-field.d.ts +4 -1
  18. package/dist/components/number-field.d.ts +4 -1
  19. package/dist/components/number-input.d.ts +4 -1
  20. package/dist/components/numpad-sheet.d.ts +4 -1
  21. package/dist/components/series-chart.d.ts +4 -1
  22. package/dist/components/server-wake.d.ts +4 -2
  23. package/dist/components/server-wake.js +23 -2
  24. package/dist/components/server-wake.js.map +1 -1
  25. package/dist/components/settings-fields.d.ts +4 -1
  26. package/dist/components/share-card.d.ts +4 -1
  27. package/dist/components/text-link.d.ts +4 -1
  28. package/dist/components/time-input.d.ts +4 -1
  29. package/dist/components/translation-review-editor.d.ts +56 -0
  30. package/dist/components/translation-review-editor.js +159 -0
  31. package/dist/components/translation-review-editor.js.map +1 -0
  32. package/dist/components/translation-review-labels.d.ts +92 -0
  33. package/dist/components/translation-review-labels.js +67 -0
  34. package/dist/components/translation-review-labels.js.map +1 -0
  35. package/dist/components/translation-review-parts.d.ts +97 -0
  36. package/dist/components/translation-review-parts.js +163 -0
  37. package/dist/components/translation-review-parts.js.map +1 -0
  38. package/dist/components/translation-review.d.ts +94 -0
  39. package/dist/components/translation-review.js +344 -0
  40. package/dist/components/translation-review.js.map +1 -0
  41. package/dist/components/ui.d.ts +4 -1
  42. package/dist/hooks/use-file-drop.d.ts +4 -1
  43. package/dist/i18n/defaults.d.ts +4 -1
  44. package/dist/i18n/defaults.js +5 -1
  45. package/dist/i18n/defaults.js.map +1 -1
  46. package/dist/i18n/german.d.ts +4 -1
  47. package/dist/i18n/german.js +51 -0
  48. package/dist/i18n/german.js.map +1 -1
  49. package/dist/i18n/kit-labels.d.ts +4 -1
  50. package/dist/i18n/kit-labels.js.map +1 -1
  51. package/dist/i18n/languages.d.ts +268 -0
  52. package/dist/i18n/languages.js +112 -0
  53. package/dist/i18n/languages.js.map +1 -0
  54. package/dist/i18n/locales/de-CH.d.ts +4 -1
  55. package/dist/i18n/locales/en.d.ts +4 -1
  56. package/dist/i18n/locales/en.js +8 -0
  57. package/dist/i18n/locales/en.js.map +1 -1
  58. package/dist/i18n/locales/es.d.ts +4 -1
  59. package/dist/i18n/locales/es.js +83 -33
  60. package/dist/i18n/locales/es.js.map +1 -1
  61. package/dist/i18n/locales/fr.d.ts +4 -1
  62. package/dist/i18n/locales/fr.js +50 -0
  63. package/dist/i18n/locales/fr.js.map +1 -1
  64. package/dist/i18n/locales/hu.d.ts +4 -1
  65. package/dist/i18n/locales/hu.js +51 -0
  66. package/dist/i18n/locales/hu.js.map +1 -1
  67. package/dist/i18n/locales/it.d.ts +4 -1
  68. package/dist/i18n/locales/it.js +90 -40
  69. package/dist/i18n/locales/it.js.map +1 -1
  70. package/dist/i18n/locales/zh.d.ts +4 -1
  71. package/dist/i18n/locales/zh.js +51 -0
  72. package/dist/i18n/locales/zh.js.map +1 -1
  73. package/dist/i18n/plurals.d.ts +23 -0
  74. package/dist/i18n/plurals.js +26 -0
  75. package/dist/i18n/plurals.js.map +1 -0
  76. package/dist/i18n/review.d.ts +102 -0
  77. package/dist/i18n/review.js +158 -0
  78. package/dist/i18n/review.js.map +1 -0
  79. package/dist/index.d.ts +10 -1
  80. package/dist/index.js +66 -0
  81. package/dist/index.js.map +1 -1
  82. package/dist/{kit-labels-CPbsjlXr.d.ts → kit-labels-D1J2_jyD.d.ts} +7 -0
  83. package/dist/lib/floating-stack.d.ts +31 -0
  84. package/dist/lib/floating-stack.js +42 -0
  85. package/dist/lib/floating-stack.js.map +1 -0
  86. package/dist/lib/server-wake.d.ts +24 -8
  87. package/dist/lib/server-wake.js +6 -5
  88. package/dist/lib/server-wake.js.map +1 -1
  89. package/dist/lib/translation-review.d.ts +232 -0
  90. package/dist/lib/translation-review.js +194 -0
  91. package/dist/lib/translation-review.js.map +1 -0
  92. package/dist/rhf/fields.d.ts +4 -1
  93. package/dist/rhf/form.d.ts +4 -1
  94. package/dist/rhf.d.ts +4 -1
  95. package/dist/shell/app-shell.d.ts +4 -1
  96. package/dist/shell/top-bar-brand.d.ts +4 -1
  97. package/dist/shell.d.ts +4 -1
  98. package/dist/wizard/stepper-nav.d.ts +4 -1
  99. package/dist/wizard.d.ts +4 -1
  100. package/package.json +1 -1
  101. package/src/components/floating-panel.tsx +19 -1
  102. package/src/components/legal.tsx +159 -0
  103. package/src/components/server-wake.tsx +37 -5
  104. package/src/components/translation-review-editor.tsx +261 -0
  105. package/src/components/translation-review-labels.ts +152 -0
  106. package/src/components/translation-review-parts.tsx +269 -0
  107. package/src/components/translation-review.tsx +502 -0
  108. package/src/i18n/defaults.ts +4 -0
  109. package/src/i18n/german.ts +52 -0
  110. package/src/i18n/kit-labels.tsx +7 -0
  111. package/src/i18n/languages.ts +355 -0
  112. package/src/i18n/locales/en.ts +8 -0
  113. package/src/i18n/locales/es.ts +84 -33
  114. package/src/i18n/locales/fr.ts +51 -0
  115. package/src/i18n/locales/hu.ts +52 -0
  116. package/src/i18n/locales/it.ts +91 -40
  117. package/src/i18n/locales/zh.ts +52 -0
  118. package/src/i18n/plurals.ts +44 -0
  119. package/src/i18n/review.ts +193 -0
  120. package/src/index.ts +65 -0
  121. package/src/lib/floating-stack.ts +66 -0
  122. package/src/lib/server-wake.ts +34 -13
  123. package/src/lib/translation-review.ts +465 -0
package/dist/index.js CHANGED
@@ -161,6 +161,40 @@ export * from "./search/search-index.js";
161
161
  export * from "./search/global-search.js";
162
162
  export * from "./i18n/kit-labels.js";
163
163
  export * from "./i18n/defaults.js";
164
+ import { kitLabelStrings } from "./i18n/review.js";
165
+ export * from "./i18n/languages.js";
166
+ import { withAllPlurals } from "./i18n/plurals.js";
167
+ import {
168
+ REVIEW_STATUSES,
169
+ fromApiReview,
170
+ toApiWrite,
171
+ flattenStrings,
172
+ keyNamespace,
173
+ placeholderTokens,
174
+ placeholderMismatch,
175
+ reviewStatus,
176
+ keyInArea,
177
+ keyInAreas,
178
+ translationRows,
179
+ summariseRows,
180
+ DEFAULT_TRANSLATION_REVIEW_FILTER,
181
+ filterTranslationRows,
182
+ reviewWrite,
183
+ mergeReviews,
184
+ dropReviews,
185
+ translationCorrections
186
+ } from "./lib/translation-review.js";
187
+ import {
188
+ TranslationReviewPanel,
189
+ TranslationReviewEditor,
190
+ ReviewStatusChip,
191
+ TranslationProgress,
192
+ TranslationLocaleTabs,
193
+ TranslationExportButton,
194
+ REVIEW_STATUS_TONES,
195
+ DEFAULT_TRANSLATION_REVIEW_LABELS
196
+ } from "./components/translation-review.js";
197
+ import { LegalLayout, LegalSection, LegalLinks, DEFAULT_LEGAL_LABELS } from "./components/legal.js";
164
198
  export {
165
199
  ACCOUNT_STATE_TONES,
166
200
  AccountStateChip,
@@ -169,18 +203,27 @@ export {
169
203
  DEFAULT_AUTHED_IMAGE_LABELS,
170
204
  DEFAULT_DANGER_CONFIRM_LABELS,
171
205
  DEFAULT_FILE_PICKER_LABELS,
206
+ DEFAULT_LEGAL_LABELS,
172
207
  DEFAULT_REAUTH_DIALOG_LABELS,
173
208
  DEFAULT_SERVER_WAKE_LABELS,
174
209
  DEFAULT_SHARE_CARD_LABELS,
175
210
  DEFAULT_TOAST_LABELS,
211
+ DEFAULT_TRANSLATION_REVIEW_FILTER,
212
+ DEFAULT_TRANSLATION_REVIEW_LABELS,
176
213
  DEFAULT_WRITE_LOCK_LABELS,
177
214
  DangerConfirm,
178
215
  DataTable,
179
216
  DateMark,
180
217
  FileButton,
181
218
  FilterPopover,
219
+ LegalLayout,
220
+ LegalLinks,
221
+ LegalSection,
182
222
  OVERLAY_EXIT_MS,
223
+ REVIEW_STATUSES,
224
+ REVIEW_STATUS_TONES,
183
225
  ReauthDialog,
226
+ ReviewStatusChip,
184
227
  RoleChip,
185
228
  ScrollArea,
186
229
  ServerWakeNotice,
@@ -192,6 +235,11 @@ export {
192
235
  TOAST_ACTION_DURATION,
193
236
  TextLink,
194
237
  Toaster,
238
+ TranslationExportButton,
239
+ TranslationLocaleTabs,
240
+ TranslationProgress,
241
+ TranslationReviewEditor,
242
+ TranslationReviewPanel,
195
243
  WriteLockProvider,
196
244
  anchoredPanelPlacement,
197
245
  attachServerWake,
@@ -200,16 +248,33 @@ export {
200
248
  createServerWake,
201
249
  dateColumn,
202
250
  dragHasFiles,
251
+ dropReviews,
203
252
  encodeQr,
253
+ filterTranslationRows,
254
+ flattenStrings,
255
+ fromApiReview,
256
+ keyInArea,
257
+ keyInAreas,
258
+ keyNamespace,
259
+ kitLabelStrings,
204
260
  logger,
205
261
  matchesAccept,
206
262
  matchesHotkey,
263
+ mergeReviews,
207
264
  parseHotkey,
265
+ placeholderMismatch,
266
+ placeholderTokens,
208
267
  readStored,
209
268
  readTableUrlState,
269
+ reviewStatus,
270
+ reviewWrite,
210
271
  serverWake,
211
272
  setStoreLog,
273
+ summariseRows,
274
+ toApiWrite,
212
275
  toast,
276
+ translationCorrections,
277
+ translationRows,
213
278
  typedMatches,
214
279
  useAnchoredPanel,
215
280
  useAnchoredRect,
@@ -238,6 +303,7 @@ export {
238
303
  useWindowedRows,
239
304
  useWriteLock,
240
305
  watchReadsAnd,
306
+ withAllPlurals,
241
307
  wrapFetch,
242
308
  writeStored
243
309
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// @eifi1/ui-kit — shared design-system barrel.\n//\n// Domain-free UI + theme surface shared across apps (lead app: Keksdose). Consumers import\n// components/theme from \"@eifi1/ui-kit\" and the token stylesheet from \"@eifi1/ui-kit/tokens.css\".\n\n// ── lib ────────────────────────────────────────────────────────────────────\nexport * from \"./lib/calc\";\nexport { cn } from \"./lib/cn\";\nexport { logger, setStoreLog } from \"./lib/logger\";\n// Intl number / money / percent / date / relative-time formatting, and `useKitFormat()`\n// for the same bound to the provider's locale (kastlan's formatters.ts, English \"5m ago\").\nexport * from \"./lib/format\";\n// localStorage that never throws (Safari private mode, blocked site data).\nexport { readStored, writeStored } from \"./lib/safe-storage\";\n// Date helpers are also available via the \"@eifi1/ui-kit/dates\" subpath.\n\n// ── hooks ────────────────────────────────────────────────────────────────────\nexport { useMediaQuery } from \"./hooks/use-media-query\";\nexport { useBodyScrollLock } from \"./hooks/use-body-scroll-lock\";\nexport { useAnchoredRect } from \"./hooks/use-anchored-rect\";\nexport type { AnchorRect } from \"./hooks/use-anchored-rect\";\nexport { useAnchoredPanel, anchoredPanelPlacement, useVisualViewport } from \"./hooks/use-anchored-panel\";\nexport type {\n AnchoredPanel,\n AnchoredPanelOptions,\n ViewportBox,\n} from \"./hooks/use-anchored-panel\";\nexport { useEscapeKey, useOutsideClick } from \"./hooks/use-dismiss\";\n// Focus containment for an overlay, and a live region for a change that moves no focus.\n// Both were extracted from the two components that already did them correctly (Modal and\n// CommandPalette) so the rest of the kit stops being the exception.\nexport { useFocusTrap } from \"./hooks/use-focus-trap\";\nexport type { FocusTrapOptions } from \"./hooks/use-focus-trap\";\nexport { useAnnounce } from \"./hooks/use-announce\";\nexport type { UseAnnounceReturn, UseAnnounceOptions, AnnounceRegionProps } from \"./hooks/use-announce\";\nexport { useOverlayHistory } from \"./hooks/use-overlay-history\";\nexport { useCloseTransition, OVERLAY_EXIT_MS } from \"./hooks/use-close-transition\";\nexport { useRowSwipe } from \"./hooks/use-row-swipe\";\nexport type { SwipeStage, RowSwipeOptions, RowSwipeReturn } from \"./hooks/use-row-swipe\";\n// Any element as a file drop target, screened like FileButton (kastlan).\nexport { useFileDrop, dragHasFiles } from \"./hooks/use-file-drop\";\nexport type { UseFileDropOptions, UseFileDropReturn, FileDropProps } from \"./hooks/use-file-drop\";\n// kastlan's search boxes each carried a hand-rolled copy, two without the cleanup.\nexport { useDebounce, useDebouncedCallback } from \"./hooks/use-debounce\";\nexport type { DebouncedCallbackOptions, DebouncedFunction } from \"./hooks/use-debounce\";\n// One search param as state, the active tab in `?tab=`, and a dialog's open state in the\n// URL (Modal's `urlParam`) — kastlan's and keksdose's use-search-param-state, in the kit.\nexport { useSearchParamState, useTabParam, useDialogParam } from \"./hooks/use-search-param-state\";\nexport type { SearchParamStateOptions, DialogParam } from \"./hooks/use-search-param-state\";\n// Copy that reports whether it worked — keksdose's copy buttons said \"Copied\" when it had not.\nexport { useCopyToClipboard, copyToClipboard } from \"./hooks/use-copy-to-clipboard\";\nexport type { CopyState, UseCopyToClipboardOptions, UseCopyToClipboardReturn } from \"./hooks/use-copy-to-clipboard\";\n// Keyboard shortcuts (\"Mod+K\", \"Ctrl+Shift+F\") that leave typing in fields alone.\nexport { useHotkey, parseHotkey, matchesHotkey } from \"./hooks/use-hotkey\";\nexport type { Hotkey, ParsedHotkey, UseHotkeyOptions } from \"./hooks/use-hotkey\";\n// A protected file as an object URL, fetched with the app's own auth (kastlan's AuthedImage).\nexport { useAuthedSrc } from \"./hooks/use-authed-src\";\nexport type { AuthedFetcher, AuthedSrcStatus, UseAuthedSrcOptions, UseAuthedSrcResult } from \"./hooks/use-authed-src\";\n\n// ── theme / palettes ─────────────────────────────────────────────────────────\nexport * from \"./theme/chart-palette\";\n// Colour maths (sRGB ↔ OKLCH, WCAG contrast, CVD simulation) and the palette deriver\n// that builds a whole, contrast-solved palette from one brand colour plus any colours\n// pinned by hand. `auditPalette` / `auditChartRamp` measure a palette rather than\n// trusting a comment about it.\nexport * from \"./theme/color\";\nexport * from \"./theme/palette-derive\";\nexport * from \"./theme/palette-presets\";\nexport * from \"./theme/theme-store\";\nexport * from \"./theme/palette-store\";\n\n// ── components ───────────────────────────────────────────────────────────────\nexport * from \"./components/ui\";\n// The label-ABOVE field group (label, hint, error, required), inside wizards or out.\nexport * from \"./components/field\";\nexport * from \"./components/search-field\";\nexport * from \"./components/dropdown\";\nexport * from \"./components/popover\";\nexport { SwipeableRow } from \"./components/swipeable-row\";\nexport type { SwipeAction, SwipeableRowProps } from \"./components/swipeable-row\";\nexport * from \"./components/calculator\";\nexport * from \"./components/numpad-sheet\";\nexport * from \"./components/number-input\";\nexport * from \"./components/currency-select\";\nexport * from \"./components/amount-input\";\nexport * from \"./components/money-field\";\nexport * from \"./components/combobox\";\nexport * from \"./components/picker-sheet\";\nexport * from \"./components/entity-combobox\";\nexport * from \"./components/multi-entity-combobox\";\nexport * from \"./components/multi-select\";\nexport * from \"./components/tooltip\";\nexport * from \"./components/user-avatar\";\nexport * from \"./components/settings-fields\";\n// Sync state for a database-backed field: the engine (`useFieldSync`) and the\n// affordance (`FieldSyncIndicator`), kept separate because the state is useful\n// without the dot — a form can gate its submit on any field being `pending`.\nexport * from \"./components/field-sync\";\nexport * from \"./components/month-picker\";\nexport * from \"./components/checkbox\";\nexport * from \"./components/switch\";\nexport * from \"./components/slider\";\nexport * from \"./components/time-input\";\nexport * from \"./components/number-field\";\nexport * from \"./components/sparkline\";\nexport * from \"./components/stat-tile\";\nexport * from \"./components/signature-pad\";\nexport * from \"./components/password-strength\";\nexport * from \"./components/page-contents\";\nexport * from \"./components/disclosure\";\nexport * from \"./components/dialog-frame\";\n// Named, not `*`: danger-confirm also holds the password field and pending hook that\n// ReauthDialog shares with it, which are kit-internal.\nexport { DangerConfirm, DEFAULT_DANGER_CONFIRM_LABELS, typedMatches } from \"./components/danger-confirm\";\nexport type { DangerConfirmLabels, DangerConfirmProps, TypedMatch } from \"./components/danger-confirm\";\n// 0.18: re-authentication before a sensitive action (Kurvenschmiede 4).\nexport { ReauthDialog, DEFAULT_REAUTH_DIALOG_LABELS } from \"./components/reauth-dialog\";\nexport type { ReauthDialogProps, ReauthDialogLabels } from \"./components/reauth-dialog\";\n// `useConfirm()` — the promise-based replacement for `window.confirm`, one host per app.\nexport * from \"./components/confirm-dialog\";\n// A non-modal corner panel and its round trigger (keksdose's assistant launcher).\nexport * from \"./components/floating-panel\";\n// The count / clear / actions bar a selection brings up (keksdose's three copies).\nexport * from \"./components/bulk-action-bar\";\nexport * from \"./components/swatch-picker\";\nexport * from \"./components/icon-picker\";\nexport * from \"./components/choice-card\";\nexport * from \"./components/autocomplete\";\nexport * from \"./components/measured-grid\";\nexport { useWindowedRows } from \"./hooks/use-windowed-rows\";\nexport type { WindowedRows } from \"./hooks/use-windowed-rows\";\n// Named, not `export *`: file-button.tsx also holds the screening helpers the\n// dropzone shares, which are internal.\nexport { FileButton, useFilePicker, matchesAccept, DEFAULT_FILE_PICKER_LABELS } from \"./components/file-button\";\nexport type {\n FileButtonProps,\n UseFilePickerOptions,\n UseFilePickerReturn,\n FilePickerLabels,\n FileRejection,\n FileRejectionReason,\n FileScreenOptions,\n} from \"./components/file-button\";\nexport * from \"./components/treemap\";\nexport * from \"./components/series-chart\";\nexport * from \"./components/chart-zoom\";\nexport * from \"./components/toggle-legend\";\nexport * from \"./components/facing-pair\";\nexport * from \"./components/series-chart-labels\";\nexport * from \"./components/pie-chart\";\nexport * from \"./components/pie-chart-labels\";\nexport * from \"./components/account-settings\";\n// 0.12.0: the fourth account section, and the QR code TwoFactorSetting draws its\n// otpauth URI with (encoder in lib/qr-encode.ts — no dependency, see there).\nexport * from \"./components/passkeys-setting\";\nexport * from \"./components/qr-code\";\nexport { encodeQr } from \"./lib/qr-encode\";\nexport type { QrEncodeOptions, QrErrorCorrection, QrMatrix } from \"./lib/qr-encode\";\nexport * from \"./components/alert-banner\";\nexport * from \"./components/toggle-group\";\n// A wrapping set of links/buttons marked `aria-current` — Tabs-like looks, not tabs.\nexport * from \"./components/nav-pills\";\n// A pill carrying one VALUE — inert, a link, or a toggle, depending on which prop it is\n// given — and the list field built from it. Distinct from Button on purpose: a row of\n// buttons reads as \"choose an action\", a row of chips as \"here are the things\".\nexport * from \"./components/chip\";\nexport * from \"./components/wizard-stepper\";\nexport * from \"./components/hover-menu\";\nexport * from \"./components/modal\";\nexport * from \"./components/full-bleed-dialog\";\nexport * from \"./components/grouped-picker\";\nexport * from \"./components/file-dropzone\";\nexport * from \"./components/mini-calendar\";\nexport * from \"./components/calendar-heatmap\";\nexport * from \"./components/date-picker\";\nexport * from \"./components/tree-view\";\nexport * from \"./components/chart\";\n// 0.8.0 layout and feedback primitives the apps hand-rolled or took from shadcn/Radix.\nexport * from \"./components/description-list\";\n// The Save / Cancel row forms and dialogs end in, and the editable line-item repeater\n// (journal lines, lease components, invoice positions). 0.12.0.\nexport * from \"./components/form-actions\";\n// 0.18: lock every opted-in commit under one provider, the reason in its tooltip\n// (Kurvenschmiede 2). `useCommitReason` stays internal.\nexport { WriteLockProvider, useWriteLock, DEFAULT_WRITE_LOCK_LABELS } from \"./components/write-lock\";\nexport type { WriteLock, WriteLockLabels, WriteLockProviderProps } from \"./components/write-lock\";\n// 0.18: the parts both apps' admin rosters repeat (Kurvenschmiede 6).\nexport { RoleChip, AccountStateChip, DateMark, dateColumn, DEFAULT_ACCOUNT_STATE_LABELS, ACCOUNT_STATE_TONES } from \"./components/account-chips\";\nexport type { RoleChipProps, RoleDefinition, RoleVocabulary, AccountState, AccountStateLabels, AccountStateChipProps, DateMarkProps, DateColumnOptions } from \"./components/account-chips\";\n// 0.18: the cold-start notice keksdose built (#199), for every app: a framework-free\n// watchdog over the app's requests and the corner notice that explains the wait.\nexport { createServerWake, serverWake, watchReadsAnd, attachServerWake, wrapFetch } from \"./lib/server-wake\";\nexport type { ServerWakeStage, ServerWakeFilter, ServerWakeOptions, ServerWakeRequest, ServerWakeWatcher, ServerWakeAxiosConfig, AxiosLikeInstance } from \"./lib/server-wake\";\nexport { ServerWakeNotice, useServerWakeStage, DEFAULT_SERVER_WAKE_LABELS } from \"./components/server-wake\";\nexport type { ServerWakeLabels, ServerWakeNoticeProps } from \"./components/server-wake\";\n// 0.18: sharing — grantees, roles, pending grants, candidates (Kurvenschmiede 1).\nexport { ShareCard, ShareDialog, SharePanel, DEFAULT_SHARE_CARD_LABELS } from \"./components/share-card\";\nexport type { ShareCardProps, ShareDialogProps, SharePanelProps, ShareCardLabels, ShareRole, ShareGrantee, SharePendingGrant, ShareCandidate, ShareAddRequest } from \"./components/share-card\";\nexport * from \"./components/line-items\";\nexport * from \"./components/progress-bar\";\n// Named: skeleton.tsx also holds SKELETON_CLASS, the look StatTile shares — internal.\nexport { Skeleton } from \"./components/skeleton\";\nexport type { SkeletonProps, SkeletonShape } from \"./components/skeleton\";\n// 0.12.0: a centred spinner with words, signed figures and deltas, a render-error fallback.\nexport * from \"./components/loading-state\";\nexport * from \"./components/signed-amount\";\nexport * from \"./components/error-boundary\";\nexport * from \"./components/copy-button\";\nexport { AuthedImage, DEFAULT_AUTHED_IMAGE_LABELS } from \"./components/authed-image\";\nexport type { AuthedImageProps, AuthedImageLabels } from \"./components/authed-image\";\nexport * from \"./components/image-grid\";\nexport * from \"./components/lightbox\";\nexport * from \"./components/button-group\";\nexport * from \"./components/table\";\nexport * from \"./components/separator\";\n// Named: scroll-area.tsx also holds the overflow hook and scrollbar class Table shares.\nexport { ScrollArea } from \"./components/scroll-area\";\nexport type { ScrollAreaProps } from \"./components/scroll-area\";\n// 0.10.0 rows, menu rows, text primitives and page chrome the apps drew by hand.\nexport * from \"./components/list\";\nexport * from \"./components/menu-item\";\nexport * from \"./components/text\";\nexport * from \"./components/status-dot\";\nexport * from \"./components/page-header\";\nexport * from \"./components/breadcrumbs\";\n// The one inline link (kastlan's EntityLink / CellLink / legal and source links), through\n// `<UiKitProvider linkComponent>`. Named: the file also holds the kit's internal link picker.\nexport { TextLink } from \"./components/text-link\";\nexport type {\n TextLinkProps,\n TextLinkRenderProps,\n TextLinkTone,\n TextLinkUnderline,\n TextLinkCurrent,\n} from \"./components/text-link\";\n// The toast layer over sonner (an OPTIONAL peer, loaded lazily): `toast` mirrors sonner's\n// API so apps migrate by swapping the import; `<Toaster>` carries the placement, theme,\n// tones and z-index both apps had wired by hand.\nexport { toast, Toaster, DEFAULT_TOAST_LABELS, TOAST_ACTION_DURATION } from \"./components/toast\";\nexport type {\n ToastId,\n ToastAction,\n ToastOptions,\n ToastPromiseOptions,\n ToastUndoOptions,\n ToastRedoOptions,\n ToastLabels,\n ToastPosition,\n ToastSwipeDirection,\n ToasterOffset,\n ToasterProps,\n} from \"./components/toast\";\n\n// ── data-table suite ─────────────────────────────────────────────────────────\nexport * from \"./components/data-table-labels\";\nexport * from \"./components/data-table-sort\";\nexport * from \"./components/data-table-filters\";\nexport * from \"./components/data-table-pagination\";\nexport { FilterPopover } from \"./components/data-table-filter-popover\";\n// data-table re-exports SortState internally; export the rest explicitly to\n// avoid a duplicate SortState star-export (it comes from data-table-sort).\nexport { DataTable } from \"./components/data-table\";\nexport type {\n DataTableColumn,\n DataTableCellProps,\n DataTableHeadProps,\n DataTableProps,\n ServerPagination,\n FilterState,\n MobileSwipeActions,\n DataTableDensity,\n DataTableChrome,\n DataTableRowAction,\n} from \"./components/data-table\";\n// 0.12.0: the yes/no cell, and a server table's state held by its owner, URL-synced.\nexport * from \"./components/data-table-cells\";\nexport { useTableUrlState, readTableUrlState } from \"./components/use-table-state\";\nexport type {\n TableUrlState,\n TableUrlSync,\n TableUrlStateProps,\n UseTableUrlStateOptions,\n UseTableUrlStateReturn,\n} from \"./components/use-table-state\";\n\n// ── shell (composable app chrome) ────────────────────────────────────────────\nexport * from \"./shell/topbar-controls\";\nexport * from \"./shell/top-bar\";\nexport * from \"./shell/app-shell\";\nexport * from \"./shell/option-switcher-menu\";\nexport * from \"./shell/role-switcher\";\nexport * from \"./shell/topbar-action-menu\";\nexport * from \"./shell/top-bar-brand\";\nexport * from \"./shell/auth-layout\";\n\n// ── feedback ─────────────────────────────────────────────────────────────────\n// The form somebody files a report with, and the parts an inbox is built from:\n// the status vocabulary both apps share value for value, the policy about what a\n// row may move to from where it stands, and the look of a status control, a\n// category badge and an opened report. The app still wires its own API, columns\n// and strings — see the note at the top of `feedback-inbox.tsx` for what is\n// deliberately left to it.\nexport * from \"./feedback/feedback-attachment\";\nexport * from \"./feedback/feedback-dialog\";\nexport * from \"./feedback/feedback-inbox\";\nexport * from \"./feedback/feedback-thread\";\n\n// ── multi-step wizard ────────────────────────────────────────────────────────\n// The engine (step machine, validators, collected data), the chrome around it\n// (indicator + nav bar + cancel confirm) and the review step it ends on.\n// `components/wizard-stepper` next door is a different, much smaller thing: a bare\n// step indicator for a two-step import flow, with no engine.\n//\n// Two modules were removed here rather than kept as stock. `wizard-field` held a\n// `WizardField`/`WizardSelectField` pair that had never been rendered in any app —\n// a field group nothing was built from, which this comment used to advertise. And\n// `use-rhf-wizard-step` was the only thing in the package that touched\n// react-hook-form, for a hook neither consumer called: keeping it meant an optional\n// peer, a dev dependency and a type import in every consumer's typecheck, bought\n// for nobody. A design system may carry stock; untested stock nothing has ever\n// rendered is not stock, it is a liability with an export.\nexport * from \"./wizard/types\";\nexport * from \"./wizard/use-wizard\";\nexport * from \"./wizard/wizard-context\";\nexport * from \"./wizard/validation\";\nexport * from \"./wizard/wizard-step\";\nexport * from \"./wizard/wizard-summary\";\nexport * from \"./wizard/stepper-nav\";\n\n// ── guided tours ─────────────────────────────────────────────────────────────\nexport * from \"./tour/tour\";\n\n// ── command palette / global search ──────────────────────────────────────────\nexport * from \"./search/command-palette\";\nexport * from \"./search/search-index\";\nexport * from \"./search/global-search\";\n\n// ── i18n: one label tree, one optional provider ──────────────────────────────\n// `UiKitLabels` names every string the kit renders; `<UiKitProvider labels locale>`\n// hands a translation to every component below it. Precedence: a component's own\n// prop > the provider > the English default. See src/i18n/kit-labels.tsx.\nexport * from \"./i18n/kit-lab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c;AACd,cAAc;AAMd,cAAc;AACd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// @eifi1/ui-kit — shared design-system barrel.\n//\n// Domain-free UI + theme surface shared across apps (lead app: Keksdose). Consumers import\n// components/theme from \"@eifi1/ui-kit\" and the token stylesheet from \"@eifi1/ui-kit/tokens.css\".\n\n// ── lib ────────────────────────────────────────────────────────────────────\nexport * from \"./lib/calc\";\nexport { cn } from \"./lib/cn\";\nexport { logger, setStoreLog } from \"./lib/logger\";\n// Intl number / money / percent / date / relative-time formatting, and `useKitFormat()`\n// for the same bound to the provider's locale (kastlan's formatters.ts, English \"5m ago\").\nexport * from \"./lib/format\";\n// localStorage that never throws (Safari private mode, blocked site data).\nexport { readStored, writeStored } from \"./lib/safe-storage\";\n// Date helpers are also available via the \"@eifi1/ui-kit/dates\" subpath.\n\n// ── hooks ────────────────────────────────────────────────────────────────────\nexport { useMediaQuery } from \"./hooks/use-media-query\";\nexport { useBodyScrollLock } from \"./hooks/use-body-scroll-lock\";\nexport { useAnchoredRect } from \"./hooks/use-anchored-rect\";\nexport type { AnchorRect } from \"./hooks/use-anchored-rect\";\nexport { useAnchoredPanel, anchoredPanelPlacement, useVisualViewport } from \"./hooks/use-anchored-panel\";\nexport type {\n AnchoredPanel,\n AnchoredPanelOptions,\n ViewportBox,\n} from \"./hooks/use-anchored-panel\";\nexport { useEscapeKey, useOutsideClick } from \"./hooks/use-dismiss\";\n// Focus containment for an overlay, and a live region for a change that moves no focus.\n// Both were extracted from the two components that already did them correctly (Modal and\n// CommandPalette) so the rest of the kit stops being the exception.\nexport { useFocusTrap } from \"./hooks/use-focus-trap\";\nexport type { FocusTrapOptions } from \"./hooks/use-focus-trap\";\nexport { useAnnounce } from \"./hooks/use-announce\";\nexport type { UseAnnounceReturn, UseAnnounceOptions, AnnounceRegionProps } from \"./hooks/use-announce\";\nexport { useOverlayHistory } from \"./hooks/use-overlay-history\";\nexport { useCloseTransition, OVERLAY_EXIT_MS } from \"./hooks/use-close-transition\";\nexport { useRowSwipe } from \"./hooks/use-row-swipe\";\nexport type { SwipeStage, RowSwipeOptions, RowSwipeReturn } from \"./hooks/use-row-swipe\";\n// Any element as a file drop target, screened like FileButton (kastlan).\nexport { useFileDrop, dragHasFiles } from \"./hooks/use-file-drop\";\nexport type { UseFileDropOptions, UseFileDropReturn, FileDropProps } from \"./hooks/use-file-drop\";\n// kastlan's search boxes each carried a hand-rolled copy, two without the cleanup.\nexport { useDebounce, useDebouncedCallback } from \"./hooks/use-debounce\";\nexport type { DebouncedCallbackOptions, DebouncedFunction } from \"./hooks/use-debounce\";\n// One search param as state, the active tab in `?tab=`, and a dialog's open state in the\n// URL (Modal's `urlParam`) — kastlan's and keksdose's use-search-param-state, in the kit.\nexport { useSearchParamState, useTabParam, useDialogParam } from \"./hooks/use-search-param-state\";\nexport type { SearchParamStateOptions, DialogParam } from \"./hooks/use-search-param-state\";\n// Copy that reports whether it worked — keksdose's copy buttons said \"Copied\" when it had not.\nexport { useCopyToClipboard, copyToClipboard } from \"./hooks/use-copy-to-clipboard\";\nexport type { CopyState, UseCopyToClipboardOptions, UseCopyToClipboardReturn } from \"./hooks/use-copy-to-clipboard\";\n// Keyboard shortcuts (\"Mod+K\", \"Ctrl+Shift+F\") that leave typing in fields alone.\nexport { useHotkey, parseHotkey, matchesHotkey } from \"./hooks/use-hotkey\";\nexport type { Hotkey, ParsedHotkey, UseHotkeyOptions } from \"./hooks/use-hotkey\";\n// A protected file as an object URL, fetched with the app's own auth (kastlan's AuthedImage).\nexport { useAuthedSrc } from \"./hooks/use-authed-src\";\nexport type { AuthedFetcher, AuthedSrcStatus, UseAuthedSrcOptions, UseAuthedSrcResult } from \"./hooks/use-authed-src\";\n\n// ── theme / palettes ─────────────────────────────────────────────────────────\nexport * from \"./theme/chart-palette\";\n// Colour maths (sRGB ↔ OKLCH, WCAG contrast, CVD simulation) and the palette deriver\n// that builds a whole, contrast-solved palette from one brand colour plus any colours\n// pinned by hand. `auditPalette` / `auditChartRamp` measure a palette rather than\n// trusting a comment about it.\nexport * from \"./theme/color\";\nexport * from \"./theme/palette-derive\";\nexport * from \"./theme/palette-presets\";\nexport * from \"./theme/theme-store\";\nexport * from \"./theme/palette-store\";\n\n// ── components ───────────────────────────────────────────────────────────────\nexport * from \"./components/ui\";\n// The label-ABOVE field group (label, hint, error, required), inside wizards or out.\nexport * from \"./components/field\";\nexport * from \"./components/search-field\";\nexport * from \"./components/dropdown\";\nexport * from \"./components/popover\";\nexport { SwipeableRow } from \"./components/swipeable-row\";\nexport type { SwipeAction, SwipeableRowProps } from \"./components/swipeable-row\";\nexport * from \"./components/calculator\";\nexport * from \"./components/numpad-sheet\";\nexport * from \"./components/number-input\";\nexport * from \"./components/currency-select\";\nexport * from \"./components/amount-input\";\nexport * from \"./components/money-field\";\nexport * from \"./components/combobox\";\nexport * from \"./components/picker-sheet\";\nexport * from \"./components/entity-combobox\";\nexport * from \"./components/multi-entity-combobox\";\nexport * from \"./components/multi-select\";\nexport * from \"./components/tooltip\";\nexport * from \"./components/user-avatar\";\nexport * from \"./components/settings-fields\";\n// Sync state for a database-backed field: the engine (`useFieldSync`) and the\n// affordance (`FieldSyncIndicator`), kept separate because the state is useful\n// without the dot — a form can gate its submit on any field being `pending`.\nexport * from \"./components/field-sync\";\nexport * from \"./components/month-picker\";\nexport * from \"./components/checkbox\";\nexport * from \"./components/switch\";\nexport * from \"./components/slider\";\nexport * from \"./components/time-input\";\nexport * from \"./components/number-field\";\nexport * from \"./components/sparkline\";\nexport * from \"./components/stat-tile\";\nexport * from \"./components/signature-pad\";\nexport * from \"./components/password-strength\";\nexport * from \"./components/page-contents\";\nexport * from \"./components/disclosure\";\nexport * from \"./components/dialog-frame\";\n// Named, not `*`: danger-confirm also holds the password field and pending hook that\n// ReauthDialog shares with it, which are kit-internal.\nexport { DangerConfirm, DEFAULT_DANGER_CONFIRM_LABELS, typedMatches } from \"./components/danger-confirm\";\nexport type { DangerConfirmLabels, DangerConfirmProps, TypedMatch } from \"./components/danger-confirm\";\n// 0.18: re-authentication before a sensitive action (Kurvenschmiede 4).\nexport { ReauthDialog, DEFAULT_REAUTH_DIALOG_LABELS } from \"./components/reauth-dialog\";\nexport type { ReauthDialogProps, ReauthDialogLabels } from \"./components/reauth-dialog\";\n// `useConfirm()` — the promise-based replacement for `window.confirm`, one host per app.\nexport * from \"./components/confirm-dialog\";\n// A non-modal corner panel and its round trigger (keksdose's assistant launcher).\nexport * from \"./components/floating-panel\";\n// The count / clear / actions bar a selection brings up (keksdose's three copies).\nexport * from \"./components/bulk-action-bar\";\nexport * from \"./components/swatch-picker\";\nexport * from \"./components/icon-picker\";\nexport * from \"./components/choice-card\";\nexport * from \"./components/autocomplete\";\nexport * from \"./components/measured-grid\";\nexport { useWindowedRows } from \"./hooks/use-windowed-rows\";\nexport type { WindowedRows } from \"./hooks/use-windowed-rows\";\n// Named, not `export *`: file-button.tsx also holds the screening helpers the\n// dropzone shares, which are internal.\nexport { FileButton, useFilePicker, matchesAccept, DEFAULT_FILE_PICKER_LABELS } from \"./components/file-button\";\nexport type {\n FileButtonProps,\n UseFilePickerOptions,\n UseFilePickerReturn,\n FilePickerLabels,\n FileRejection,\n FileRejectionReason,\n FileScreenOptions,\n} from \"./components/file-button\";\nexport * from \"./components/treemap\";\nexport * from \"./components/series-chart\";\nexport * from \"./components/chart-zoom\";\nexport * from \"./components/toggle-legend\";\nexport * from \"./components/facing-pair\";\nexport * from \"./components/series-chart-labels\";\nexport * from \"./components/pie-chart\";\nexport * from \"./components/pie-chart-labels\";\nexport * from \"./components/account-settings\";\n// 0.12.0: the fourth account section, and the QR code TwoFactorSetting draws its\n// otpauth URI with (encoder in lib/qr-encode.ts — no dependency, see there).\nexport * from \"./components/passkeys-setting\";\nexport * from \"./components/qr-code\";\nexport { encodeQr } from \"./lib/qr-encode\";\nexport type { QrEncodeOptions, QrErrorCorrection, QrMatrix } from \"./lib/qr-encode\";\nexport * from \"./components/alert-banner\";\nexport * from \"./components/toggle-group\";\n// A wrapping set of links/buttons marked `aria-current` — Tabs-like looks, not tabs.\nexport * from \"./components/nav-pills\";\n// A pill carrying one VALUE — inert, a link, or a toggle, depending on which prop it is\n// given — and the list field built from it. Distinct from Button on purpose: a row of\n// buttons reads as \"choose an action\", a row of chips as \"here are the things\".\nexport * from \"./components/chip\";\nexport * from \"./components/wizard-stepper\";\nexport * from \"./components/hover-menu\";\nexport * from \"./components/modal\";\nexport * from \"./components/full-bleed-dialog\";\nexport * from \"./components/grouped-picker\";\nexport * from \"./components/file-dropzone\";\nexport * from \"./components/mini-calendar\";\nexport * from \"./components/calendar-heatmap\";\nexport * from \"./components/date-picker\";\nexport * from \"./components/tree-view\";\nexport * from \"./components/chart\";\n// 0.8.0 layout and feedback primitives the apps hand-rolled or took from shadcn/Radix.\nexport * from \"./components/description-list\";\n// The Save / Cancel row forms and dialogs end in, and the editable line-item repeater\n// (journal lines, lease components, invoice positions). 0.12.0.\nexport * from \"./components/form-actions\";\n// 0.18: lock every opted-in commit under one provider, the reason in its tooltip\n// (Kurvenschmiede 2). `useCommitReason` stays internal.\nexport { WriteLockProvider, useWriteLock, DEFAULT_WRITE_LOCK_LABELS } from \"./components/write-lock\";\nexport type { WriteLock, WriteLockLabels, WriteLockProviderProps } from \"./components/write-lock\";\n// 0.18: the parts both apps' admin rosters repeat (Kurvenschmiede 6).\nexport { RoleChip, AccountStateChip, DateMark, dateColumn, DEFAULT_ACCOUNT_STATE_LABELS, ACCOUNT_STATE_TONES } from \"./components/account-chips\";\nexport type { RoleChipProps, RoleDefinition, RoleVocabulary, AccountState, AccountStateLabels, AccountStateChipProps, DateMarkProps, DateColumnOptions } from \"./components/account-chips\";\n// 0.18: the cold-start notice keksdose built (#199), for every app: a framework-free\n// watchdog over the app's requests and the corner notice that explains the wait.\nexport { createServerWake, serverWake, watchReadsAnd, attachServerWake, wrapFetch } from \"./lib/server-wake\";\nexport type { ServerWakeStage, ServerWakeFilter, ServerWakeOptions, ServerWakeRequest, ServerWakeWatcher, ServerWakeAxiosConfig, AxiosLikeInstance } from \"./lib/server-wake\";\nexport { ServerWakeNotice, useServerWakeStage, DEFAULT_SERVER_WAKE_LABELS } from \"./components/server-wake\";\nexport type { ServerWakeLabels, ServerWakeNoticeProps } from \"./components/server-wake\";\n// 0.18: sharing — grantees, roles, pending grants, candidates (Kurvenschmiede 1).\nexport { ShareCard, ShareDialog, SharePanel, DEFAULT_SHARE_CARD_LABELS } from \"./components/share-card\";\nexport type { ShareCardProps, ShareDialogProps, SharePanelProps, ShareCardLabels, ShareRole, ShareGrantee, SharePendingGrant, ShareCandidate, ShareAddRequest } from \"./components/share-card\";\nexport * from \"./components/line-items\";\nexport * from \"./components/progress-bar\";\n// Named: skeleton.tsx also holds SKELETON_CLASS, the look StatTile shares — internal.\nexport { Skeleton } from \"./components/skeleton\";\nexport type { SkeletonProps, SkeletonShape } from \"./components/skeleton\";\n// 0.12.0: a centred spinner with words, signed figures and deltas, a render-error fallback.\nexport * from \"./components/loading-state\";\nexport * from \"./components/signed-amount\";\nexport * from \"./components/error-boundary\";\nexport * from \"./components/copy-button\";\nexport { AuthedImage, DEFAULT_AUTHED_IMAGE_LABELS } from \"./components/authed-image\";\nexport type { AuthedImageProps, AuthedImageLabels } from \"./components/authed-image\";\nexport * from \"./components/image-grid\";\nexport * from \"./components/lightbox\";\nexport * from \"./components/button-group\";\nexport * from \"./components/table\";\nexport * from \"./components/separator\";\n// Named: scroll-area.tsx also holds the overflow hook and scrollbar class Table shares.\nexport { ScrollArea } from \"./components/scroll-area\";\nexport type { ScrollAreaProps } from \"./components/scroll-area\";\n// 0.10.0 rows, menu rows, text primitives and page chrome the apps drew by hand.\nexport * from \"./components/list\";\nexport * from \"./components/menu-item\";\nexport * from \"./components/text\";\nexport * from \"./components/status-dot\";\nexport * from \"./components/page-header\";\nexport * from \"./components/breadcrumbs\";\n// The one inline link (kastlan's EntityLink / CellLink / legal and source links), through\n// `<UiKitProvider linkComponent>`. Named: the file also holds the kit's internal link picker.\nexport { TextLink } from \"./components/text-link\";\nexport type {\n TextLinkProps,\n TextLinkRenderProps,\n TextLinkTone,\n TextLinkUnderline,\n TextLinkCurrent,\n} from \"./components/text-link\";\n// The toast layer over sonner (an OPTIONAL peer, loaded lazily): `toast` mirrors sonner's\n// API so apps migrate by swapping the import; `<Toaster>` carries the placement, theme,\n// tones and z-index both apps had wired by hand.\nexport { toast, Toaster, DEFAULT_TOAST_LABELS, TOAST_ACTION_DURATION } from \"./components/toast\";\nexport type {\n ToastId,\n ToastAction,\n ToastOptions,\n ToastPromiseOptions,\n ToastUndoOptions,\n ToastRedoOptions,\n ToastLabels,\n ToastPosition,\n ToastSwipeDirection,\n ToasterOffset,\n ToasterProps,\n} from \"./components/toast\";\n\n// ── data-table suite ─────────────────────────────────────────────────────────\nexport * from \"./components/data-table-labels\";\nexport * from \"./components/data-table-sort\";\nexport * from \"./components/data-table-filters\";\nexport * from \"./components/data-table-pagination\";\nexport { FilterPopover } from \"./components/data-table-filter-popover\";\n// data-table re-exports SortState internally; export the rest explicitly to\n// avoid a duplicate SortState star-export (it comes from data-table-sort).\nexport { DataTable } from \"./components/data-table\";\nexport type {\n DataTableColumn,\n DataTableCellProps,\n DataTableHeadProps,\n DataTableProps,\n ServerPagination,\n FilterState,\n MobileSwipeActions,\n DataTableDensity,\n DataTableChrome,\n DataTableRowAction,\n} from \"./components/data-table\";\n// 0.12.0: the yes/no cell, and a server table's state held by its owner, URL-synced.\nexport * from \"./components/data-table-cells\";\nexport { useTableUrlState, readTableUrlState } from \"./components/use-table-state\";\nexport type {\n TableUrlState,\n TableUrlSync,\n TableUrlStateProps,\n UseTableUrlStateOptions,\n UseTableUrlStateReturn,\n} from \"./components/use-table-state\";\n\n// ── shell (composable app chrome) ────────────────────────────────────────────\nexport * from \"./shell/topbar-controls\";\nexport * from \"./shell/top-bar\";\nexport * from \"./shell/app-shell\";\nexport * from \"./shell/option-switcher-menu\";\nexport * from \"./shell/role-switcher\";\nexport * from \"./shell/topbar-action-menu\";\nexport * from \"./shell/top-bar-brand\";\nexport * from \"./shell/auth-layout\";\n\n// ── feedback ─────────────────────────────────────────────────────────────────\n// The form somebody files a report with, and the parts an inbox is built from:\n// the status vocabulary both apps share value for value, the policy about what a\n// row may move to from where it stands, and the look of a status control, a\n// category badge and an opened report. The app still wires its own API, columns\n// and strings — see the note at the top of `feedback-inbox.tsx` for what is\n// deliberately left to it.\nexport * from \"./feedback/feedback-attachment\";\nexport * from \"./feedback/feedback-dialog\";\nexport * from \"./feedback/feedback-inbox\";\nexport * from \"./feedback/feedback-thread\";\n\n// ── multi-step wizard ────────────────────────────────────────────────────────\n// The engine (step machine, validators, collected data), the chrome around it\n// (indicator + nav bar + cancel confirm) and the review step it ends on.\n// `components/wizard-stepper` next door is a different, much smaller thing: a bare\n// step indicator for a two-step import flow, with no engine.\n//\n// Two modules were removed here rather than kept as stock. `wizard-field` held a\n// `WizardField`/`WizardSelectField` pair that had never been rendered in any app —\n// a field group nothing was built from, which this comment used to advertise. And\n// `use-rhf-wizard-step` was the only thing in the package that touched\n// react-hook-form, for a hook neither consumer called: keeping it meant an optional\n// peer, a dev dependency and a type import in every consumer's typecheck, bought\n// for nobody. A design system may carry stock; untested stock nothing has ever\n// rendered is not stock, it is a liability with an export.\nexport * from \"./wizard/types\";\nexport * from \"./wizard/use-wizard\";\nexport * from \"./wizard/wizard-context\";\nexport * from \"./wizard/validation\";\nexport * from \"./wizard/wizard-step\";\nexport * from \"./wizard/wizard-summary\";\nexport * from \"./wizard/stepper-nav\";\n\n// ── guided tours ─────────────────────────────────────────────────────────────\nexport * from \"./tour/tour\";\n\n// ── command palette / global search ──────────────────────────────────────────\nexport * from \"./search/command-palette\";\nexport * from \"./search/search-index\";\nexport * from \"./search/global-search\";\n\n// ── i18n: one label tree, one optional provider ──────────────────────────────\n// `UiKitLabels` names every string the kit renders; `<UiKitProvider labels locale>`\n// hands a translation to every component below it. Precedence: a component's own\n// prop > the provider > the English default. See src/i18n/kit-labels.tsx.\nexport * from \"./i18n/kit-labels\";\nexport * from \"./i18n/defaults\";\n// The kit's words as `key → text` rows for an app's translation review (keksdose).\nexport { kitLabelStrings } from \"./i18n/review\";\n// The seven languages, how an app resolves one, and the kit catalogue loader for it.\nexport * from \"./i18n/languages\";\n// CLDR plural categories for an app's i18next catalogue, filled from `_other`.\nexport { withAllPlurals } from \"./i18n/plurals\";\n// Translation review (0.19): one contract for kastlan's and keksdose's review pages —\n// the pure rows/status/placeholder logic and the presentational page parts.\nexport {\n REVIEW_STATUSES,\n fromApiReview,\n toApiWrite,\n flattenStrings,\n keyNamespace,\n placeholderTokens,\n placeholderMismatch,\n reviewStatus,\n keyInArea,\n keyInAreas,\n translationRows,\n summariseRows,\n DEFAULT_TRANSLATION_REVIEW_FILTER,\n filterTranslationRows,\n reviewWrite,\n mergeReviews,\n dropReviews,\n translationCorrections,\n} from \"./lib/translation-review\";\nexport type {\n TranslationVerdict,\n TranslationReview,\n TranslationReviewWrite,\n TranslationReviewKey,\n ReviewStatus,\n TranslationRow,\n ApiTranslationReview,\n ApiTranslationReviewWrite,\n TranslationRowsInput,\n TranslationSummary,\n TranslationReviewFilter,\n TranslationCorrection,\n} from \"./lib/translation-review\";\nexport {\n TranslationReviewPanel,\n TranslationReviewEditor,\n ReviewStatusChip,\n TranslationProgress,\n TranslationLocaleTabs,\n TranslationExportButton,\n REVIEW_STATUS_TONES,\n DEFAULT_TRANSLATION_REVIEW_LABELS,\n} from \"./components/translation-review\";\nexport type {\n TranslationReviewPanelProps,\n TranslationReviewEditorProps,\n ReviewStatusChipProps,\n TranslationProgressProps,\n TranslationLocaleTab,\n TranslationLocaleTabsProps,\n TranslationExportButtonProps,\n TranslationReviewLabels,\n} from \"./components/translation-review\";\n// The legal pages' shell (0.19, H10): Imprint, Privacy Policy, Terms in every app.\nexport { LegalLayout, LegalSection, LegalLinks, DEFAULT_LEGAL_LABELS } from \"./components/legal\";\nexport type { LegalLabels, LegalLink, LegalLinksProps, LegalSectionPro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Ac;AACd,cAAc;AAMd,cAAc;AACd,cAAc;AAEd,SAAS,uBAAuB;AAEhC,cAAc;AAEd,SAAS,sBAAsB;AAG/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAeP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAYP,SAAS,aAAa,cAAc,YAAY,4BAA4B;","names":[]}
@@ -43,9 +43,11 @@ import { AuthedImageLabels } from './components/authed-image.js';
43
43
  import { ImageGridLabels } from './components/image-grid.js';
44
44
  import { LightboxLabels } from './components/lightbox.js';
45
45
  import { WriteLockLabels } from './components/write-lock.js';
46
+ import { LegalLabels } from './components/legal.js';
46
47
  import { RoleDefinition, AccountStateLabels } from './components/account-chips.js';
47
48
  import { ReauthDialogLabels } from './components/reauth-dialog.js';
48
49
  import { ServerWakeLabels } from './components/server-wake.js';
50
+ import { TranslationReviewLabels } from './components/translation-review-labels.js';
49
51
 
50
52
  type ButtonVariant = "primary" | "secondary" | "ghost" | "danger" | "brand" | "link";
51
53
  type ButtonSize = "sm" | "md";
@@ -2025,6 +2027,11 @@ interface UiKitLabels {
2025
2027
  reauthDialog: ReauthDialogLabels;
2026
2028
  /** 0.18.0: `ServerWakeNotice` — keksdose's cold-start notice, for every app. */
2027
2029
  serverWake: ServerWakeLabels;
2030
+ /** 0.19.0: the translation-review parts (`TranslationReviewPanel`, its editor, chip,
2031
+ * progress, locale tabs and export) — keksdose's /translations, for every app. */
2032
+ translationReview: TranslationReviewLabels;
2033
+ /** 0.19.0: `LegalLinks`' navigation name — the legal pages' shell, for every app. */
2034
+ legal: LegalLabels;
2028
2035
  }
2029
2036
  /**
2030
2037
  * A label override, as deep as the labels go: an object of labels (a namespace, or a
@@ -0,0 +1,31 @@
1
+ /**
2
+ * What floats over the bottom of the screen right now, so a notice that comes and goes
3
+ * can sit above it instead of on it.
4
+ *
5
+ * kastlan 0.18: its offline pill is a `bottom-start` FloatingActionButton, and
6
+ * `ServerWakeNotice` sits in the same corner — right after a break both show at once
7
+ * (the photo outbox syncs while the first reads wake the server), one over the other.
8
+ * The FAB's `offset` cannot help: the notice comes and goes, and on a phone it is
9
+ * nearly as wide as the screen, so a FAB in EITHER corner can be under it.
10
+ *
11
+ * Measured, not declared: a FloatingActionButton registers its fixed element while it
12
+ * is mounted, and a notice asks {@link clearanceAbove} for the height it has to clear —
13
+ * whatever offset, `extended` label or `hidden` state the controls are in. A control
14
+ * that is `hidden` measures 0 × 0 and is skipped, so kastlan's pill, which stays
15
+ * mounted and hidden while there is nothing to report, costs the notice nothing.
16
+ *
17
+ * Internal: not exported from the barrel.
18
+ */
19
+ /** Track `element` until the returned function is called. Size changes — a label that
20
+ * grows, `hidden` toggling — notify the subscribers too. */
21
+ declare function registerFloating(element: HTMLElement): () => void;
22
+ /** Hear every registration, removal and size change. */
23
+ declare function subscribeFloating(listener: () => void): () => void;
24
+ /**
25
+ * The distance from the viewport's bottom edge to the top of the highest visible
26
+ * floating control that shares a column with `element` — what `element` has to clear —
27
+ * or `null` when nothing is under it.
28
+ */
29
+ declare function clearanceAbove(element: HTMLElement | null): number | null;
30
+
31
+ export { clearanceAbove, registerFloating, subscribeFloating };
@@ -0,0 +1,42 @@
1
+ "use client";
2
+ const occupants = /* @__PURE__ */ new Set();
3
+ const listeners = /* @__PURE__ */ new Set();
4
+ let observer = null;
5
+ function notify() {
6
+ for (const listener of listeners) listener();
7
+ }
8
+ function registerFloating(element) {
9
+ occupants.add(element);
10
+ if (observer === null && typeof ResizeObserver !== "undefined") observer = new ResizeObserver(notify);
11
+ observer?.observe(element);
12
+ notify();
13
+ return () => {
14
+ occupants.delete(element);
15
+ observer?.unobserve(element);
16
+ notify();
17
+ };
18
+ }
19
+ function subscribeFloating(listener) {
20
+ listeners.add(listener);
21
+ return () => {
22
+ listeners.delete(listener);
23
+ };
24
+ }
25
+ function clearanceAbove(element) {
26
+ if (!element) return null;
27
+ const own = element.getBoundingClientRect();
28
+ let top = Infinity;
29
+ for (const other of occupants) {
30
+ const box = other.getBoundingClientRect();
31
+ if (box.width === 0 || box.height === 0) continue;
32
+ if (box.right <= own.left || box.left >= own.right) continue;
33
+ top = Math.min(top, box.top);
34
+ }
35
+ return top === Infinity ? null : Math.max(0, window.innerHeight - top);
36
+ }
37
+ export {
38
+ clearanceAbove,
39
+ registerFloating,
40
+ subscribeFloating
41
+ };
42
+ //# sourceMappingURL=floating-stack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/floating-stack.ts"],"sourcesContent":["/**\n * What floats over the bottom of the screen right now, so a notice that comes and goes\n * can sit above it instead of on it.\n *\n * kastlan 0.18: its offline pill is a `bottom-start` FloatingActionButton, and\n * `ServerWakeNotice` sits in the same corner — right after a break both show at once\n * (the photo outbox syncs while the first reads wake the server), one over the other.\n * The FAB's `offset` cannot help: the notice comes and goes, and on a phone it is\n * nearly as wide as the screen, so a FAB in EITHER corner can be under it.\n *\n * Measured, not declared: a FloatingActionButton registers its fixed element while it\n * is mounted, and a notice asks {@link clearanceAbove} for the height it has to clear —\n * whatever offset, `extended` label or `hidden` state the controls are in. A control\n * that is `hidden` measures 0 × 0 and is skipped, so kastlan's pill, which stays\n * mounted and hidden while there is nothing to report, costs the notice nothing.\n *\n * Internal: not exported from the barrel.\n */\n\nconst occupants = new Set<HTMLElement>();\nconst listeners = new Set<() => void>();\nlet observer: ResizeObserver | null = null;\n\nfunction notify() {\n for (const listener of listeners) listener();\n}\n\n/** Track `element` until the returned function is called. Size changes — a label that\n * grows, `hidden` toggling — notify the subscribers too. */\nexport function registerFloating(element: HTMLElement): () => void {\n occupants.add(element);\n if (observer === null && typeof ResizeObserver !== \"undefined\") observer = new ResizeObserver(notify);\n observer?.observe(element);\n notify();\n return () => {\n occupants.delete(element);\n observer?.unobserve(element);\n notify();\n };\n}\n\n/** Hear every registration, removal and size change. */\nexport function subscribeFloating(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\n/**\n * The distance from the viewport's bottom edge to the top of the highest visible\n * floating control that shares a column with `element` — what `element` has to clear —\n * or `null` when nothing is under it.\n */\nexport function clearanceAbove(element: HTMLElement | null): number | null {\n if (!element) return null;\n const own = element.getBoundingClientRect();\n let top = Infinity;\n for (const other of occupants) {\n const box = other.getBoundingClientRect();\n if (box.width === 0 || box.height === 0) continue;\n if (box.right <= own.left || box.left >= own.right) continue;\n top = Math.min(top, box.top);\n }\n return top === Infinity ? null : Math.max(0, window.innerHeight - top);\n}\n"],"mappings":";AAmBA,MAAM,YAAY,oBAAI,IAAiB;AACvC,MAAM,YAAY,oBAAI,IAAgB;AACtC,IAAI,WAAkC;AAEtC,SAAS,SAAS;AAChB,aAAW,YAAY,UAAW,UAAS;AAC7C;AAIO,SAAS,iBAAiB,SAAkC;AACjE,YAAU,IAAI,OAAO;AACrB,MAAI,aAAa,QAAQ,OAAO,mBAAmB,YAAa,YAAW,IAAI,eAAe,MAAM;AACpG,YAAU,QAAQ,OAAO;AACzB,SAAO;AACP,SAAO,MAAM;AACX,cAAU,OAAO,OAAO;AACxB,cAAU,UAAU,OAAO;AAC3B,WAAO;AAAA,EACT;AACF;AAGO,SAAS,kBAAkB,UAAkC;AAClE,YAAU,IAAI,QAAQ;AACtB,SAAO,MAAM;AACX,cAAU,OAAO,QAAQ;AAAA,EAC3B;AACF;AAOO,SAAS,eAAe,SAA4C;AACzE,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,MAAM,QAAQ,sBAAsB;AAC1C,MAAI,MAAM;AACV,aAAW,SAAS,WAAW;AAC7B,UAAM,MAAM,MAAM,sBAAsB;AACxC,QAAI,IAAI,UAAU,KAAK,IAAI,WAAW,EAAG;AACzC,QAAI,IAAI,SAAS,IAAI,QAAQ,IAAI,QAAQ,IAAI,MAAO;AACpD,UAAM,KAAK,IAAI,KAAK,IAAI,GAAG;AAAA,EAC7B;AACA,SAAO,QAAQ,WAAW,OAAO,KAAK,IAAI,GAAG,OAAO,cAAc,GAAG;AACvE;","names":[]}
@@ -25,6 +25,13 @@
25
25
  * simply be false. With the default that holds by itself (an upload is a POST);
26
26
  * an app widening `shouldWatch` keeps its upload routes out of it.
27
27
  *
28
+ * Nor a DOWNLOAD, for the same reason (kastlan 0.18): axios answers only once the
29
+ * whole body is in, so a generated PDF or a large photo — a GET — ran past both
30
+ * thresholds on a warm server, and held the count for every read beside it. The
31
+ * default filter skips a request whose `responseType` is `"blob"`, `"arraybuffer"` or
32
+ * `"stream"`; a custom filter gets the request as its third argument to do the same.
33
+ * (`wrapFetch` ends the wait at the headers, so a download through it is harmless.)
34
+ *
28
35
  * It never arms while the browser is offline, whatever `shouldWatch` says: that state
29
36
  * has its own, truthful indicator, and a request that never left the device is not
30
37
  * evidence of anything about the server.
@@ -33,22 +40,27 @@
33
40
  * start is the only sensible explanation. */
34
41
  type ServerWakeStage = "idle" | "slow" | "waking";
35
42
  /** Decides which requests count. `method` arrives lower-cased (`"get"` when the
36
- * request named none — axios's and fetch's default); `url` as the client had it. */
37
- type ServerWakeFilter = (method: string, url: string) => boolean;
43
+ * request named none — axios's and fetch's default); `url` as the client had it;
44
+ * `request` is what the adapter saw — for axios the request config itself, so
45
+ * `responseType` or the app's own fields can decide. */
46
+ type ServerWakeFilter = (method: string, url: string, request: ServerWakeRequest) => boolean;
38
47
  interface ServerWakeOptions {
39
48
  /** Past this, a warm round trip is out of the question (a cold database query on a
40
49
  * free tier can still take a second, so it is not tighter). Default 2000 ms. */
41
50
  slowMs?: number;
42
51
  /** Past this, the container was almost certainly scaled to zero. Default 7000 ms. */
43
52
  wakingMs?: number;
44
- /** Which requests count. Default {@link watchReadsAnd}`()` — GETs only. The offline
45
- * guard runs before it and cannot be overridden. */
53
+ /** Which requests count. Default {@link watchReadsAnd}`()` — GETs only, downloads
54
+ * excluded. The offline guard runs before it and cannot be overridden. */
46
55
  shouldWatch?: ServerWakeFilter;
47
56
  }
48
- /** What a request is, for {@link ServerWakeWatcher.track}. */
57
+ /** What a request is, for {@link ServerWakeWatcher.track} and a {@link ServerWakeFilter}. */
49
58
  interface ServerWakeRequest {
50
59
  method?: string;
51
60
  url?: string;
61
+ /** axios's `responseType`. `"blob"`, `"arraybuffer"` and `"stream"` mark a download,
62
+ * which the default filter does not count. */
63
+ responseType?: string;
52
64
  }
53
65
  interface ServerWakeWatcher {
54
66
  /**
@@ -56,8 +68,9 @@ interface ServerWakeWatcher {
56
68
  * Returns whether it was counted — the caller MUST call {@link end} exactly once
57
69
  * for every `true`, or the counter never returns to zero and the notice sticks.
58
70
  * (The axios adapter stashes it on the request config for that reason.)
71
+ * `request` reaches the filter as its third argument; default `{ method, url }`.
59
72
  */
60
- start(method?: string, url?: string): boolean;
73
+ start(method?: string, url?: string, request?: ServerWakeRequest): boolean;
61
74
  /** A counted request settled — either way: an error still proves the server
62
75
  * answered or gave up. When the last one does, the notice goes away. Never takes
63
76
  * the counter below zero. */
@@ -75,7 +88,8 @@ interface ServerWakeWatcher {
75
88
  }
76
89
  /**
77
90
  * The usual filter: every GET, plus any other request whose URL matches `writes` —
78
- * keksdose's `/\/auth\/(login|register|demo-session)\b/`. Keep upload routes out of
91
+ * keksdose's `/\/auth\/(login|register|demo-session)\b/` — but never a download
92
+ * (`responseType` `"blob"`, `"arraybuffer"` or `"stream"`). Keep upload routes out of
79
93
  * the pattern (see the module comment).
80
94
  */
81
95
  declare function watchReadsAnd(writes?: RegExp): ServerWakeFilter;
@@ -87,10 +101,12 @@ declare function createServerWake({ slowMs, wakingMs, shouldWatch, }?: ServerWak
87
101
  * with {@link createServerWake} and passes it to both ends.
88
102
  */
89
103
  declare const serverWake: ServerWakeWatcher;
90
- /** The two config fields the watchdog reads — what axios's request config has. */
104
+ /** The config fields the watchdog reads — what axios's request config has. The whole
105
+ * config reaches the filter, so an app's filter can read the rest of it. */
91
106
  interface ServerWakeAxiosConfig {
92
107
  method?: string;
93
108
  url?: string;
109
+ responseType?: string;
94
110
  }
95
111
  /** The slice of an interceptor manager the adapter uses. A method (not a function
96
112
  * property) so axios's wider `use(onFulfilled?, onRejected?, options?)` fits it. */
@@ -1,6 +1,7 @@
1
1
  "use client";
2
+ const DOWNLOAD_RESPONSE_TYPES = /* @__PURE__ */ new Set(["blob", "arraybuffer", "stream"]);
2
3
  function watchReadsAnd(writes) {
3
- return (method, url) => method === "get" || writes !== void 0 && writes.test(url);
4
+ return (method, url, request) => !DOWNLOAD_RESPONSE_TYPES.has(request?.responseType ?? "") && (method === "get" || writes !== void 0 && writes.test(url));
4
5
  }
5
6
  function isOffline() {
6
7
  return typeof navigator !== "undefined" && navigator.onLine === false;
@@ -26,9 +27,9 @@ function createServerWake({
26
27
  slowTimer = null;
27
28
  wakingTimer = null;
28
29
  };
29
- const start = (method, url) => {
30
+ const start = (method, url, request = { method, url }) => {
30
31
  if (isOffline()) return false;
31
- if (!shouldWatch((method ?? "get").toLowerCase(), url ?? "")) return false;
32
+ if (!shouldWatch((method ?? "get").toLowerCase(), url ?? "", request)) return false;
32
33
  inFlight += 1;
33
34
  if (inFlight === 1) {
34
35
  clearTimers();
@@ -47,7 +48,7 @@ function createServerWake({
47
48
  start,
48
49
  end,
49
50
  track(work, request = {}) {
50
- const counted = start(request.method, request.url);
51
+ const counted = start(request.method, request.url, request);
51
52
  let promise;
52
53
  try {
53
54
  promise = Promise.resolve(typeof work === "function" ? work() : work);
@@ -83,7 +84,7 @@ function attachServerWake(instance, watcher = serverWake) {
83
84
  };
84
85
  const request = instance.interceptors.request.use(
85
86
  (config) => {
86
- config[COUNTED] = watcher.start(config.method, config.url);
87
+ config[COUNTED] = watcher.start(config.method, config.url, config);
87
88
  return config;
88
89
  },
89
90
  (error) => Promise.reject(error)
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/server-wake.ts"],"sourcesContent":["/**\n * \"Is the server asleep, or is the app broken?\" — the cold-start watchdog, lifted\n * from keksdose (feedback #199) so kastlan and Kurvenschmiede get it too.\n *\n * All three backends run on Cloud Run with `--min-instances=0`: after an idle\n * period the container is gone and the first request has to start it, which takes\n * several seconds and occasionally more. Nothing in the UI said so, and none of the\n * axios instances has a timeout, so the honest experience was a spinner that looked\n * stuck. This counts the in-flight requests a cold start would actually delay and\n * escalates in two steps, so a merely slow response says \"still loading\" and only a\n * genuinely long wait blames the sleeping server.\n *\n * Framework-free on purpose (no zustand, no axios, no React): a counter, two timers\n * and a listener set, read by `useServerWakeStage` through `useSyncExternalStore`.\n * The adapters below take the app's axios instance / fetch as an ARGUMENT, so the\n * kit never imports either.\n *\n * WHAT ARMS IT, and why the default is narrow:\n * - reads (GET) — what every page does on open — always;\n * - writes only when the app says so (`watchReadsAnd(/\\/auth\\/login\\b/)`): the\n * auth POSTs that gate the app are the only writes a user waits on before the\n * app exists at all, so a cold start there looks exactly like a broken login.\n * An UPLOAD must never be watched — a statement PDF or a photo takes seconds on a\n * perfectly warm server, and \"the server is waking up\" during a 4 s upload would\n * simply be false. With the default that holds by itself (an upload is a POST);\n * an app widening `shouldWatch` keeps its upload routes out of it.\n *\n * It never arms while the browser is offline, whatever `shouldWatch` says: that state\n * has its own, truthful indicator, and a request that never left the device is not\n * evidence of anything about the server.\n */\n\n/** `slow` = longer than a warm server ever takes; `waking` = long enough that a cold\n * start is the only sensible explanation. */\nexport type ServerWakeStage = \"idle\" | \"slow\" | \"waking\";\n\n/** Decides which requests count. `method` arrives lower-cased (`\"get\"` when the\n * request named none — axios's and fetch's default); `url` as the client had it. */\nexport type ServerWakeFilter = (method: string, url: string) => boolean;\n\nexport interface ServerWakeOptions {\n /** Past this, a warm round trip is out of the question (a cold database query on a\n * free tier can still take a second, so it is not tighter). Default 2000 ms. */\n slowMs?: number;\n /** Past this, the container was almost certainly scaled to zero. Default 7000 ms. */\n wakingMs?: number;\n /** Which requests count. Default {@link watchReadsAnd}`()` — GETs only. The offline\n * guard runs before it and cannot be overridden. */\n shouldWatch?: ServerWakeFilter;\n}\n\n/** What a request is, for {@link ServerWakeWatcher.track}. */\nexport interface ServerWakeRequest {\n method?: string;\n url?: string;\n}\n\nexport interface ServerWakeWatcher {\n /**\n * Count a request that is going out, and arm the escalation if it is the first.\n * Returns whether it was counted — the caller MUST call {@link end} exactly once\n * for every `true`, or the counter never returns to zero and the notice sticks.\n * (The axios adapter stashes it on the request config for that reason.)\n */\n start(method?: string, url?: string): boolean;\n /** A counted request settled — either way: an error still proves the server\n * answered or gave up. When the last one does, the notice goes away. Never takes\n * the counter below zero. */\n end(): void;\n /** `start` + `end` around a promise (or a function returning one), for a request\n * that does not go through an adapter. Resolves and rejects as the work does. */\n track<T>(work: PromiseLike<T> | (() => PromiseLike<T>), request?: ServerWakeRequest): Promise<T>;\n /** Back to a pristine watchdog — for tests, which share an instance across cases. */\n reset(): void;\n /** `useSyncExternalStore`'s pair. Listeners hear stage changes only. */\n subscribe(listener: () => void): () => void;\n getStage(): ServerWakeStage;\n /** Counted requests currently outstanding. */\n getInFlight(): number;\n}\n\n/**\n * The usual filter: every GET, plus any other request whose URL matches `writes` —\n * keksdose's `/\\/auth\\/(login|register|demo-session)\\b/`. Keep upload routes out of\n * the pattern (see the module comment).\n */\nexport function watchReadsAnd(writes?: RegExp): ServerWakeFilter {\n return (method, url) => method === \"get\" || (writes !== undefined && writes.test(url));\n}\n\nfunction isOffline(): boolean {\n return typeof navigator !== \"undefined\" && navigator.onLine === false;\n}\n\nexport function createServerWake({\n slowMs = 2000,\n wakingMs = 7000,\n shouldWatch = watchReadsAnd(),\n}: ServerWakeOptions = {}): ServerWakeWatcher {\n let inFlight = 0;\n let stage: ServerWakeStage = \"idle\";\n let slowTimer: ReturnType<typeof setTimeout> | null = null;\n let wakingTimer: ReturnType<typeof setTimeout> | null = null;\n const listeners = new Set<() => void>();\n\n const setStage = (next: ServerWakeStage) => {\n if (next === stage) return;\n stage = next;\n for (const listener of listeners) listener();\n };\n\n const clearTimers = () => {\n if (slowTimer !== null) clearTimeout(slowTimer);\n if (wakingTimer !== null) clearTimeout(wakingTimer);\n slowTimer = null;\n wakingTimer = null;\n };\n\n const start = (method?: string, url?: string): boolean => {\n if (isOffline()) return false;\n if (!shouldWatch((method ?? \"get\").toLowerCase(), url ?? \"\")) return false;\n inFlight += 1;\n // The clock runs from the FIRST outstanding request: a page firing a second read\n // at 1.9 s is still waiting on the same sleeping server, not starting afresh.\n if (inFlight === 1) {\n clearTimers();\n slowTimer = setTimeout(() => setStage(\"slow\"), slowMs);\n wakingTimer = setTimeout(() => setStage(\"waking\"), wakingMs);\n }\n return true;\n };\n\n const end = () => {\n inFlight = Math.max(0, inFlight - 1);\n if (inFlight > 0) return;\n clearTimers();\n setStage(\"idle\");\n };\n\n return {\n start,\n end,\n track<T>(work: PromiseLike<T> | (() => PromiseLike<T>), request: ServerWakeRequest = {}) {\n const counted = start(request.method, request.url);\n let promise: Promise<T>;\n try {\n promise = Promise.resolve(typeof work === \"function\" ? work() : work);\n } catch (error) {\n // A thunk that throws before it returns a promise settled too.\n promise = Promise.reject(error);\n }\n return counted ? promise.finally(end) : promise;\n },\n reset() {\n inFlight = 0;\n clearTimers();\n setStage(\"idle\");\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n getStage: () => stage,\n getInFlight: () => inFlight,\n };\n}\n\n/**\n * The shared instance: what `<ServerWakeNotice />`, `useServerWakeStage()`,\n * {@link attachServerWake} and {@link wrapFetch} use when no watcher is passed. GETs\n * only, default timings — an app that also watches its login POST creates its own\n * with {@link createServerWake} and passes it to both ends.\n */\nexport const serverWake: ServerWakeWatcher = createServerWake();\n\n// ── axios ─────────────────────────────────────────────────────────────────────\n\n/** The two config fields the watchdog reads — what axios's request config has. */\nexport interface ServerWakeAxiosConfig {\n method?: string;\n url?: string;\n}\n\n/** The slice of an interceptor manager the adapter uses. A method (not a function\n * property) so axios's wider `use(onFulfilled?, onRejected?, options?)` fits it. */\ninterface InterceptorManagerLike<V> {\n use(onFulfilled: (value: V) => V | Promise<V>, onRejected: (error: unknown) => unknown): number;\n eject(id: number): void;\n}\n\n/** An axios instance, structurally — so the kit types the adapter without importing\n * axios. `axios.create()`'s result fits it as is. */\nexport interface AxiosLikeInstance<C extends ServerWakeAxiosConfig, R extends { config: C }> {\n interceptors: {\n request: InterceptorManagerLike<C>;\n response: InterceptorManagerLike<R>;\n };\n}\n\n/** Whether the watchdog counted this request — the response side owes a matching\n * `end()` only then. On the config, as keksdose's `_wake` was: it travels with the\n * request onto the response and onto an error. Cleared once settled, so a 401 replay\n * of the same config re-enters the request interceptor and is counted afresh — the\n * pairing stays balanced. */\nconst COUNTED = \"_serverWake\";\ntype Marked = { [COUNTED]?: boolean };\n\n/**\n * Drive a watcher from an axios instance's interceptors: `attachServerWake(api)`.\n * Returns a function that ejects both interceptors again.\n *\n * Attach it BEFORE the app's own response interceptors: axios runs those in the order\n * they were added, so the wake one ends the wait before a 401 handler awaits a token\n * refresh — otherwise the notice would keep counting a request that has already been\n * answered. (Request-side order does not matter.)\n */\nexport function attachServerWake<C extends ServerWakeAxiosConfig, R extends { config: C }>(\n instance: AxiosLikeInstance<C, R>,\n watcher: ServerWakeWatcher = serverWake,\n): () => void {\n const settle = (config: unknown) => {\n const marked = config as Marked | undefined;\n if (marked?.[COUNTED]) {\n marked[COUNTED] = false;\n watcher.end();\n }\n };\n const request = instance.interceptors.request.use(\n (config) => {\n (config as C & Marked)[COUNTED] = watcher.start(config.method, config.url);\n return config;\n },\n (error) => Promise.reject(error),\n );\n const response = instance.interceptors.response.use(\n (res) => {\n settle(res.config);\n return res;\n },\n (error) => {\n settle((error as { config?: unknown } | null)?.config);\n return Promise.reject(error);\n },\n );\n return () => {\n instance.interceptors.request.eject(request);\n instance.interceptors.response.eject(response);\n };\n}\n\n// ── fetch ─────────────────────────────────────────────────────────────────────\n\n/**\n * A `fetch` that drives a watcher: `const apiFetch = wrapFetch(fetch)`. The wait ends\n * when the response's HEADERS arrive (or the call fails) — the server is awake by then,\n * however long the body takes.\n */\nexport function wrapFetch(\n fetchImpl: typeof fetch = globalThis.fetch,\n watcher: ServerWakeWatcher = serverWake,\n): typeof fetch {\n return (input, init) => {\n const request = typeof Request !== \"undefined\" && input instanceof Request ? input : undefined;\n const method = init?.method ?? request?.method;\n const url = typeof input === \"string\" ? input : input instanceof URL ? input.href : (request?.url ?? \"\");\n return watcher.track(() => fetchImpl(input, init), { method, url });\n };\n}\n"],"mappings":";AAsFO,SAAS,cAAc,QAAmC;AAC/D,SAAO,CAAC,QAAQ,QAAQ,WAAW,SAAU,WAAW,UAAa,OAAO,KAAK,GAAG;AACtF;AAEA,SAAS,YAAqB;AAC5B,SAAO,OAAO,cAAc,eAAe,UAAU,WAAW;AAClE;AAEO,SAAS,iBAAiB;AAAA,EAC/B,SAAS;AAAA,EACT,WAAW;AAAA,EACX,cAAc,cAAc;AAC9B,IAAuB,CAAC,GAAsB;AAC5C,MAAI,WAAW;AACf,MAAI,QAAyB;AAC7B,MAAI,YAAkD;AACtD,MAAI,cAAoD;AACxD,QAAM,YAAY,oBAAI,IAAgB;AAEtC,QAAM,WAAW,CAAC,SAA0B;AAC1C,QAAI,SAAS,MAAO;AACpB,YAAQ;AACR,eAAW,YAAY,UAAW,UAAS;AAAA,EAC7C;AAEA,QAAM,cAAc,MAAM;AACxB,QAAI,cAAc,KAAM,cAAa,SAAS;AAC9C,QAAI,gBAAgB,KAAM,cAAa,WAAW;AAClD,gBAAY;AACZ,kBAAc;AAAA,EAChB;AAEA,QAAM,QAAQ,CAAC,QAAiB,QAA0B;AACxD,QAAI,UAAU,EAAG,QAAO;AACxB,QAAI,CAAC,aAAa,UAAU,OAAO,YAAY,GAAG,OAAO,EAAE,EAAG,QAAO;AACrE,gBAAY;AAGZ,QAAI,aAAa,GAAG;AAClB,kBAAY;AACZ,kBAAY,WAAW,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A,CAAC,UAAU,QAAQ,OAAO,KAAK;AAAA,EACjC;AACA,QAAM,WAAW,SAAS,aAAa,SAAS;AAAA,IAC9C,CAAC,QAAQ;AACP,aAAO,IAAI,MAAM;AACjB,aAAO;AAAA,IACT;AAAA,IACA,CAAC,UAAU;AACT,aAAQ,OAAuC,MAAM;AACrD,aAAO,QAAQ,OAAO,KAAK;AAAA,IAC7B;AAAA,EACF;AACA,SAAO,MAAM;AACX,aAAS,aAAa,QAAQ,MAAM,OAAO;AAC3C,aAAS,aAAa,SAAS,MAAM,QAAQ;AAAA,EAC/C;AACF;AASO,SAAS,UACd,YAA0B,WAAW,OACrC,UAA6B,YACf;AACd,SAAO,CAAC,OAAO,SAAS;AACtB,UAAM,UAAU,OAAO,YAAY,eAAe,iBAAiB,UAAU,QAAQ;AACrF,UAAM,SAAS,MAAM,UAAU,SAAS;AACxC,UAAM,MAAM,OAAO,UAAU,WAAW,QAAQ,iBAAiB,MAAM,MAAM,OAAQ,SAAS,OAAO;AACrG,WAAO,QAAQ,MAAM,MAAM,UAAU,OAAO,IAAI,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACpE;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/lib/server-wake.ts"],"sourcesContent":["/**\n * \"Is the server asleep, or is the app broken?\" — the cold-start watchdog, lifted\n * from keksdose (feedback #199) so kastlan and Kurvenschmiede get it too.\n *\n * All three backends run on Cloud Run with `--min-instances=0`: after an idle\n * period the container is gone and the first request has to start it, which takes\n * several seconds and occasionally more. Nothing in the UI said so, and none of the\n * axios instances has a timeout, so the honest experience was a spinner that looked\n * stuck. This counts the in-flight requests a cold start would actually delay and\n * escalates in two steps, so a merely slow response says \"still loading\" and only a\n * genuinely long wait blames the sleeping server.\n *\n * Framework-free on purpose (no zustand, no axios, no React): a counter, two timers\n * and a listener set, read by `useServerWakeStage` through `useSyncExternalStore`.\n * The adapters below take the app's axios instance / fetch as an ARGUMENT, so the\n * kit never imports either.\n *\n * WHAT ARMS IT, and why the default is narrow:\n * - reads (GET) — what every page does on open — always;\n * - writes only when the app says so (`watchReadsAnd(/\\/auth\\/login\\b/)`): the\n * auth POSTs that gate the app are the only writes a user waits on before the\n * app exists at all, so a cold start there looks exactly like a broken login.\n * An UPLOAD must never be watched — a statement PDF or a photo takes seconds on a\n * perfectly warm server, and \"the server is waking up\" during a 4 s upload would\n * simply be false. With the default that holds by itself (an upload is a POST);\n * an app widening `shouldWatch` keeps its upload routes out of it.\n *\n * Nor a DOWNLOAD, for the same reason (kastlan 0.18): axios answers only once the\n * whole body is in, so a generated PDF or a large photo — a GET — ran past both\n * thresholds on a warm server, and held the count for every read beside it. The\n * default filter skips a request whose `responseType` is `\"blob\"`, `\"arraybuffer\"` or\n * `\"stream\"`; a custom filter gets the request as its third argument to do the same.\n * (`wrapFetch` ends the wait at the headers, so a download through it is harmless.)\n *\n * It never arms while the browser is offline, whatever `shouldWatch` says: that state\n * has its own, truthful indicator, and a request that never left the device is not\n * evidence of anything about the server.\n */\n\n/** `slow` = longer than a warm server ever takes; `waking` = long enough that a cold\n * start is the only sensible explanation. */\nexport type ServerWakeStage = \"idle\" | \"slow\" | \"waking\";\n\n/** Decides which requests count. `method` arrives lower-cased (`\"get\"` when the\n * request named none — axios's and fetch's default); `url` as the client had it;\n * `request` is what the adapter saw — for axios the request config itself, so\n * `responseType` or the app's own fields can decide. */\nexport type ServerWakeFilter = (method: string, url: string, request: ServerWakeRequest) => boolean;\n\nexport interface ServerWakeOptions {\n /** Past this, a warm round trip is out of the question (a cold database query on a\n * free tier can still take a second, so it is not tighter). Default 2000 ms. */\n slowMs?: number;\n /** Past this, the container was almost certainly scaled to zero. Default 7000 ms. */\n wakingMs?: number;\n /** Which requests count. Default {@link watchReadsAnd}`()` — GETs only, downloads\n * excluded. The offline guard runs before it and cannot be overridden. */\n shouldWatch?: ServerWakeFilter;\n}\n\n/** What a request is, for {@link ServerWakeWatcher.track} and a {@link ServerWakeFilter}. */\nexport interface ServerWakeRequest {\n method?: string;\n url?: string;\n /** axios's `responseType`. `\"blob\"`, `\"arraybuffer\"` and `\"stream\"` mark a download,\n * which the default filter does not count. */\n responseType?: string;\n}\n\nexport interface ServerWakeWatcher {\n /**\n * Count a request that is going out, and arm the escalation if it is the first.\n * Returns whether it was counted — the caller MUST call {@link end} exactly once\n * for every `true`, or the counter never returns to zero and the notice sticks.\n * (The axios adapter stashes it on the request config for that reason.)\n * `request` reaches the filter as its third argument; default `{ method, url }`.\n */\n start(method?: string, url?: string, request?: ServerWakeRequest): boolean;\n /** A counted request settled — either way: an error still proves the server\n * answered or gave up. When the last one does, the notice goes away. Never takes\n * the counter below zero. */\n end(): void;\n /** `start` + `end` around a promise (or a function returning one), for a request\n * that does not go through an adapter. Resolves and rejects as the work does. */\n track<T>(work: PromiseLike<T> | (() => PromiseLike<T>), request?: ServerWakeRequest): Promise<T>;\n /** Back to a pristine watchdog — for tests, which share an instance across cases. */\n reset(): void;\n /** `useSyncExternalStore`'s pair. Listeners hear stage changes only. */\n subscribe(listener: () => void): () => void;\n getStage(): ServerWakeStage;\n /** Counted requests currently outstanding. */\n getInFlight(): number;\n}\n\n/** Response types that make a request a download — see the module comment. */\nconst DOWNLOAD_RESPONSE_TYPES = new Set([\"blob\", \"arraybuffer\", \"stream\"]);\n\n/**\n * The usual filter: every GET, plus any other request whose URL matches `writes` —\n * keksdose's `/\\/auth\\/(login|register|demo-session)\\b/` — but never a download\n * (`responseType` `\"blob\"`, `\"arraybuffer\"` or `\"stream\"`). Keep upload routes out of\n * the pattern (see the module comment).\n */\nexport function watchReadsAnd(writes?: RegExp): ServerWakeFilter {\n return (method, url, request) =>\n !DOWNLOAD_RESPONSE_TYPES.has(request?.responseType ?? \"\") &&\n (method === \"get\" || (writes !== undefined && writes.test(url)));\n}\n\nfunction isOffline(): boolean {\n return typeof navigator !== \"undefined\" && navigator.onLine === false;\n}\n\nexport function createServerWake({\n slowMs = 2000,\n wakingMs = 7000,\n shouldWatch = watchReadsAnd(),\n}: ServerWakeOptions = {}): ServerWakeWatcher {\n let inFlight = 0;\n let stage: ServerWakeStage = \"idle\";\n let slowTimer: ReturnType<typeof setTimeout> | null = null;\n let wakingTimer: ReturnType<typeof setTimeout> | null = null;\n const listeners = new Set<() => void>();\n\n const setStage = (next: ServerWakeStage) => {\n if (next === stage) return;\n stage = next;\n for (const listener of listeners) listener();\n };\n\n const clearTimers = () => {\n if (slowTimer !== null) clearTimeout(slowTimer);\n if (wakingTimer !== null) clearTimeout(wakingTimer);\n slowTimer = null;\n wakingTimer = null;\n };\n\n const start = (method?: string, url?: string, request: ServerWakeRequest = { method, url }): boolean => {\n if (isOffline()) return false;\n if (!shouldWatch((method ?? \"get\").toLowerCase(), url ?? \"\", request)) return false;\n inFlight += 1;\n // The clock runs from the FIRST outstanding request: a page firing a second read\n // at 1.9 s is still waiting on the same sleeping server, not starting afresh.\n if (inFlight === 1) {\n clearTimers();\n slowTimer = setTimeout(() => setStage(\"slow\"), slowMs);\n wakingTimer = setTimeout(() => setStage(\"waking\"), wakingMs);\n }\n return true;\n };\n\n const end = () => {\n inFlight = Math.max(0, inFlight - 1);\n if (inFlight > 0) return;\n clearTimers();\n setStage(\"idle\");\n };\n\n return {\n start,\n end,\n track<T>(work: PromiseLike<T> | (() => PromiseLike<T>), request: ServerWakeRequest = {}) {\n const counted = start(request.method, request.url, request);\n let promise: Promise<T>;\n try {\n promise = Promise.resolve(typeof work === \"function\" ? work() : work);\n } catch (error) {\n // A thunk that throws before it returns a promise settled too.\n promise = Promise.reject(error);\n }\n return counted ? promise.finally(end) : promise;\n },\n reset() {\n inFlight = 0;\n clearTimers();\n setStage(\"idle\");\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n getStage: () => stage,\n getInFlight: () => inFlight,\n };\n}\n\n/**\n * The shared instance: what `<ServerWakeNotice />`, `useServerWakeStage()`,\n * {@link attachServerWake} and {@link wrapFetch} use when no watcher is passed. GETs\n * only, default timings — an app that also watches its login POST creates its own\n * with {@link createServerWake} and passes it to both ends.\n */\nexport const serverWake: ServerWakeWatcher = createServerWake();\n\n// ── axios ─────────────────────────────────────────────────────────────────────\n\n/** The config fields the watchdog reads — what axios's request config has. The whole\n * config reaches the filter, so an app's filter can read the rest of it. */\nexport interface ServerWakeAxiosConfig {\n method?: string;\n url?: string;\n responseType?: string;\n}\n\n/** The slice of an interceptor manager the adapter uses. A method (not a function\n * property) so axios's wider `use(onFulfilled?, onRejected?, options?)` fits it. */\ninterface InterceptorManagerLike<V> {\n use(onFulfilled: (value: V) => V | Promise<V>, onRejected: (error: unknown) => unknown): number;\n eject(id: number): void;\n}\n\n/** An axios instance, structurally — so the kit types the adapter without importing\n * axios. `axios.create()`'s result fits it as is. */\nexport interface AxiosLikeInstance<C extends ServerWakeAxiosConfig, R extends { config: C }> {\n interceptors: {\n request: InterceptorManagerLike<C>;\n response: InterceptorManagerLike<R>;\n };\n}\n\n/** Whether the watchdog counted this request — the response side owes a matching\n * `end()` only then. On the config, as keksdose's `_wake` was: it travels with the\n * request onto the response and onto an error. Cleared once settled, so a 401 replay\n * of the same config re-enters the request interceptor and is counted afresh — the\n * pairing stays balanced. */\nconst COUNTED = \"_serverWake\";\ntype Marked = { [COUNTED]?: boolean };\n\n/**\n * Drive a watcher from an axios instance's interceptors: `attachServerWake(api)`.\n * Returns a function that ejects both interceptors again.\n *\n * Attach it BEFORE the app's own response interceptors: axios runs those in the order\n * they were added, so the wake one ends the wait before a 401 handler awaits a token\n * refresh — otherwise the notice would keep counting a request that has already been\n * answered. (Request-side order does not matter.)\n */\nexport function attachServerWake<C extends ServerWakeAxiosConfig, R extends { config: C }>(\n instance: AxiosLikeInstance<C, R>,\n watcher: ServerWakeWatcher = serverWake,\n): () => void {\n const settle = (config: unknown) => {\n const marked = config as Marked | undefined;\n if (marked?.[COUNTED]) {\n marked[COUNTED] = false;\n watcher.end();\n }\n };\n const request = instance.interceptors.request.use(\n (config) => {\n (config as C & Marked)[COUNTED] = watcher.start(config.method, config.url, config);\n return config;\n },\n (error) => Promise.reject(error),\n );\n const response = instance.interceptors.response.use(\n (res) => {\n settle(res.config);\n return res;\n },\n (error) => {\n settle((error as { config?: unknown } | null)?.config);\n return Promise.reject(error);\n },\n );\n return () => {\n instance.interceptors.request.eject(request);\n instance.interceptors.response.eject(response);\n };\n}\n\n// ── fetch ─────────────────────────────────────────────────────────────────────\n\n/**\n * A `fetch` that drives a watcher: `const apiFetch = wrapFetch(fetch)`. The wait ends\n * when the response's HEADERS arrive (or the call fails) — the server is awake by then,\n * however long the body takes.\n */\nexport function wrapFetch(\n fetchImpl: typeof fetch = globalThis.fetch,\n watcher: ServerWakeWatcher = serverWake,\n): typeof fetch {\n return (input, init) => {\n const request = typeof Request !== \"undefined\" && input instanceof Request ? input : undefined;\n const method = init?.method ?? request?.method;\n const url = typeof input === \"string\" ? input : input instanceof URL ? input.href : (request?.url ?? \"\");\n return watcher.track(() => fetchImpl(input, init), { method, url });\n };\n}\n"],"mappings":";AA+FA,MAAM,0BAA0B,oBAAI,IAAI,CAAC,QAAQ,eAAe,QAAQ,CAAC;AAQlE,SAAS,cAAc,QAAmC;AAC/D,SAAO,CAAC,QAAQ,KAAK,YACnB,CAAC,wBAAwB,IAAI,SAAS,gBAAgB,EAAE,MACvD,WAAW,SAAU,WAAW,UAAa,OAAO,KAAK,GAAG;AACjE;AAEA,SAAS,YAAqB;AAC5B,SAAO,OAAO,cAAc,eAAe,UAAU,WAAW;AAClE;AAEO,SAAS,iBAAiB;AAAA,EAC/B,SAAS;AAAA,EACT,WAAW;AAAA,EACX,cAAc,cAAc;AAC9B,IAAuB,CAAC,GAAsB;AAC5C,MAAI,WAAW;AACf,MAAI,QAAyB;AAC7B,MAAI,YAAkD;AACtD,MAAI,cAAoD;AACxD,QAAM,YAAY,oBAAI,IAAgB;AAEtC,QAAM,WAAW,CAAC,SAA0B;AAC1C,QAAI,SAAS,MAAO;AACpB,YAAQ;AACR,eAAW,YAAY,UAAW,UAAS;AAAA,EA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