sendproof-core 0.1.0.alpha.1

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 (229) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +55 -0
  4. data/lib/sendproof/assets.rb +70 -0
  5. data/lib/sendproof/attribution.rb +98 -0
  6. data/lib/sendproof/capture.rb +66 -0
  7. data/lib/sendproof/clock.rb +54 -0
  8. data/lib/sendproof/configuration.rb +241 -0
  9. data/lib/sendproof/data_store.rb +34 -0
  10. data/lib/sendproof/dynamodb/store.rb +183 -0
  11. data/lib/sendproof/dynamodb.rb +17 -0
  12. data/lib/sendproof/elasticsearch/store.rb +24 -0
  13. data/lib/sendproof/elasticsearch.rb +17 -0
  14. data/lib/sendproof/firestore/interceptor.rb +38 -0
  15. data/lib/sendproof/firestore/store.rb +150 -0
  16. data/lib/sendproof/firestore.rb +99 -0
  17. data/lib/sendproof/handler.rb +23 -0
  18. data/lib/sendproof/identity.rb +37 -0
  19. data/lib/sendproof/limits.rb +113 -0
  20. data/lib/sendproof/middleware.rb +68 -0
  21. data/lib/sendproof/mongo/engine.rb +692 -0
  22. data/lib/sendproof/mongo/guarded.rb +100 -0
  23. data/lib/sendproof/mongo/plain.rb +45 -0
  24. data/lib/sendproof/mongo/store.rb +54 -0
  25. data/lib/sendproof/mongo/subscriber.rb +21 -0
  26. data/lib/sendproof/mongo.rb +41 -0
  27. data/lib/sendproof/mongoid/store.rb +58 -0
  28. data/lib/sendproof/mongoid.rb +65 -0
  29. data/lib/sendproof/observed_request.rb +108 -0
  30. data/lib/sendproof/opensearch/store.rb +21 -0
  31. data/lib/sendproof/opensearch.rb +17 -0
  32. data/lib/sendproof/operation_matcher.rb +28 -0
  33. data/lib/sendproof/pool_hooks.rb +80 -0
  34. data/lib/sendproof/preview_request.rb +44 -0
  35. data/lib/sendproof/preview_transport.rb +331 -0
  36. data/lib/sendproof/protocol.rb +81 -0
  37. data/lib/sendproof/provider.rb +83 -0
  38. data/lib/sendproof/recorder.rb +298 -0
  39. data/lib/sendproof/redaction.rb +98 -0
  40. data/lib/sendproof/redis/commands.rb +76 -0
  41. data/lib/sendproof/redis/store.rb +205 -0
  42. data/lib/sendproof/redis.rb +18 -0
  43. data/lib/sendproof/search/middleware.rb +39 -0
  44. data/lib/sendproof/search/store.rb +213 -0
  45. data/lib/sendproof/search.rb +82 -0
  46. data/lib/sendproof/stores/classify.rb +346 -0
  47. data/lib/sendproof/stores/guard.rb +127 -0
  48. data/lib/sendproof/stores/tables.rb +1328 -0
  49. data/lib/sendproof/stores.rb +12 -0
  50. data/lib/sendproof/trace_store.rb +110 -0
  51. data/lib/sendproof/transaction_control.rb +187 -0
  52. data/lib/sendproof/ui/action-bar.js +91 -0
  53. data/lib/sendproof/ui/api.js +239 -0
  54. data/lib/sendproof/ui/app.css +848 -0
  55. data/lib/sendproof/ui/app.js +742 -0
  56. data/lib/sendproof/ui/autofill.js +137 -0
  57. data/lib/sendproof/ui/code-copy.js +71 -0
  58. data/lib/sendproof/ui/code-picker.js +149 -0
  59. data/lib/sendproof/ui/commands.js +197 -0
  60. data/lib/sendproof/ui/components.js +77 -0
  61. data/lib/sendproof/ui/context-bar.js +82 -0
  62. data/lib/sendproof/ui/copy.js +92 -0
  63. data/lib/sendproof/ui/coverage-popover.js +35 -0
  64. data/lib/sendproof/ui/crumb-fit.js +80 -0
  65. data/lib/sendproof/ui/deprecation.js +164 -0
  66. data/lib/sendproof/ui/display-settings.js +175 -0
  67. data/lib/sendproof/ui/doc-diff.js +209 -0
  68. data/lib/sendproof/ui/docs-view.js +347 -0
  69. data/lib/sendproof/ui/favicon.png +0 -0
  70. data/lib/sendproof/ui/favicon.svg +1 -0
  71. data/lib/sendproof/ui/field-help.js +52 -0
  72. data/lib/sendproof/ui/field-modules.js +23 -0
  73. data/lib/sendproof/ui/fields/controls.js +179 -0
  74. data/lib/sendproof/ui/fields/dom.js +36 -0
  75. data/lib/sendproof/ui/fields/infer.js +71 -0
  76. data/lib/sendproof/ui/fields/lookup-source.js +63 -0
  77. data/lib/sendproof/ui/fields/lookup.js +285 -0
  78. data/lib/sendproof/ui/fields/render.js +496 -0
  79. data/lib/sendproof/ui/fields/select.js +175 -0
  80. data/lib/sendproof/ui/fields/validate.js +363 -0
  81. data/lib/sendproof/ui/fields/validation-formats.js +164 -0
  82. data/lib/sendproof/ui/fields/validation-references.js +68 -0
  83. data/lib/sendproof/ui/fields/validation-values.js +137 -0
  84. data/lib/sendproof/ui/generate-menu.js +44 -0
  85. data/lib/sendproof/ui/generate.js +184 -0
  86. data/lib/sendproof/ui/header-editor.js +777 -0
  87. data/lib/sendproof/ui/headers.js +188 -0
  88. data/lib/sendproof/ui/highlight.js +257 -0
  89. data/lib/sendproof/ui/history-popover.js +24 -0
  90. data/lib/sendproof/ui/i18n.js +253 -0
  91. data/lib/sendproof/ui/icons.js +87 -0
  92. data/lib/sendproof/ui/index.html +70 -0
  93. data/lib/sendproof/ui/issues.js +187 -0
  94. data/lib/sendproof/ui/json-view.js +166 -0
  95. data/lib/sendproof/ui/lang-icons.js +62 -0
  96. data/lib/sendproof/ui/layout.js +262 -0
  97. data/lib/sendproof/ui/listbox.js +334 -0
  98. data/lib/sendproof/ui/locales/ar-capture.js +366 -0
  99. data/lib/sendproof/ui/locales/ar-stores.js +116 -0
  100. data/lib/sendproof/ui/locales/ar.js +561 -0
  101. data/lib/sendproof/ui/locales/cs-capture.js +442 -0
  102. data/lib/sendproof/ui/locales/cs-stores.js +116 -0
  103. data/lib/sendproof/ui/locales/cs.js +689 -0
  104. data/lib/sendproof/ui/locales/da-capture.js +347 -0
  105. data/lib/sendproof/ui/locales/da-stores.js +116 -0
  106. data/lib/sendproof/ui/locales/da.js +522 -0
  107. data/lib/sendproof/ui/locales/de-capture.js +347 -0
  108. data/lib/sendproof/ui/locales/de-stores.js +116 -0
  109. data/lib/sendproof/ui/locales/de.js +519 -0
  110. data/lib/sendproof/ui/locales/el-capture.js +347 -0
  111. data/lib/sendproof/ui/locales/el-stores.js +116 -0
  112. data/lib/sendproof/ui/locales/el.js +520 -0
  113. data/lib/sendproof/ui/locales/en-capture.js +349 -0
  114. data/lib/sendproof/ui/locales/en-stores.js +95 -0
  115. data/lib/sendproof/ui/locales/en.js +522 -0
  116. data/lib/sendproof/ui/locales/es-capture.js +353 -0
  117. data/lib/sendproof/ui/locales/es-stores.js +116 -0
  118. data/lib/sendproof/ui/locales/es.js +525 -0
  119. data/lib/sendproof/ui/locales/fa-capture.js +348 -0
  120. data/lib/sendproof/ui/locales/fa-stores.js +116 -0
  121. data/lib/sendproof/ui/locales/fa.js +521 -0
  122. data/lib/sendproof/ui/locales/fi-capture.js +347 -0
  123. data/lib/sendproof/ui/locales/fi-stores.js +116 -0
  124. data/lib/sendproof/ui/locales/fi.js +523 -0
  125. data/lib/sendproof/ui/locales/fr-capture.js +353 -0
  126. data/lib/sendproof/ui/locales/fr-stores.js +116 -0
  127. data/lib/sendproof/ui/locales/fr.js +525 -0
  128. data/lib/sendproof/ui/locales/he-capture.js +358 -0
  129. data/lib/sendproof/ui/locales/he-stores.js +116 -0
  130. data/lib/sendproof/ui/locales/he.js +529 -0
  131. data/lib/sendproof/ui/locales/hi-capture.js +348 -0
  132. data/lib/sendproof/ui/locales/hi-stores.js +116 -0
  133. data/lib/sendproof/ui/locales/hi.js +523 -0
  134. data/lib/sendproof/ui/locales/id-capture.js +347 -0
  135. data/lib/sendproof/ui/locales/id-stores.js +116 -0
  136. data/lib/sendproof/ui/locales/id.js +521 -0
  137. data/lib/sendproof/ui/locales/it-capture.js +361 -0
  138. data/lib/sendproof/ui/locales/it-stores.js +116 -0
  139. data/lib/sendproof/ui/locales/it.js +523 -0
  140. data/lib/sendproof/ui/locales/ja-capture.js +346 -0
  141. data/lib/sendproof/ui/locales/ja-stores.js +116 -0
  142. data/lib/sendproof/ui/locales/ja.js +521 -0
  143. data/lib/sendproof/ui/locales/ko-capture.js +346 -0
  144. data/lib/sendproof/ui/locales/ko-stores.js +116 -0
  145. data/lib/sendproof/ui/locales/ko.js +522 -0
  146. data/lib/sendproof/ui/locales/nb-capture.js +349 -0
  147. data/lib/sendproof/ui/locales/nb-stores.js +116 -0
  148. data/lib/sendproof/ui/locales/nb.js +521 -0
  149. data/lib/sendproof/ui/locales/nl-capture.js +355 -0
  150. data/lib/sendproof/ui/locales/nl-stores.js +116 -0
  151. data/lib/sendproof/ui/locales/nl.js +520 -0
  152. data/lib/sendproof/ui/locales/pl-capture.js +432 -0
  153. data/lib/sendproof/ui/locales/pl-stores.js +116 -0
  154. data/lib/sendproof/ui/locales/pl.js +528 -0
  155. data/lib/sendproof/ui/locales/pt-BR-capture.js +350 -0
  156. data/lib/sendproof/ui/locales/pt-BR-stores.js +116 -0
  157. data/lib/sendproof/ui/locales/pt-BR.js +523 -0
  158. data/lib/sendproof/ui/locales/pt-PT-capture.js +350 -0
  159. data/lib/sendproof/ui/locales/pt-PT-stores.js +116 -0
  160. data/lib/sendproof/ui/locales/pt-PT.js +523 -0
  161. data/lib/sendproof/ui/locales/ru-capture.js +437 -0
  162. data/lib/sendproof/ui/locales/ru-stores.js +116 -0
  163. data/lib/sendproof/ui/locales/ru.js +624 -0
  164. data/lib/sendproof/ui/locales/sv-capture.js +349 -0
  165. data/lib/sendproof/ui/locales/sv-stores.js +116 -0
  166. data/lib/sendproof/ui/locales/sv.js +518 -0
  167. data/lib/sendproof/ui/locales/th-capture.js +347 -0
  168. data/lib/sendproof/ui/locales/th-stores.js +116 -0
  169. data/lib/sendproof/ui/locales/th.js +521 -0
  170. data/lib/sendproof/ui/locales/tr-capture.js +348 -0
  171. data/lib/sendproof/ui/locales/tr-stores.js +116 -0
  172. data/lib/sendproof/ui/locales/tr.js +521 -0
  173. data/lib/sendproof/ui/locales/uk-capture.js +442 -0
  174. data/lib/sendproof/ui/locales/uk-stores.js +116 -0
  175. data/lib/sendproof/ui/locales/uk.js +630 -0
  176. data/lib/sendproof/ui/locales/vi-capture.js +346 -0
  177. data/lib/sendproof/ui/locales/vi-stores.js +116 -0
  178. data/lib/sendproof/ui/locales/vi.js +523 -0
  179. data/lib/sendproof/ui/locales/zh-Hans-capture.js +347 -0
  180. data/lib/sendproof/ui/locales/zh-Hans-stores.js +116 -0
  181. data/lib/sendproof/ui/locales/zh-Hans.js +523 -0
  182. data/lib/sendproof/ui/locales/zh-Hant-capture.js +346 -0
  183. data/lib/sendproof/ui/locales/zh-Hant-stores.js +116 -0
  184. data/lib/sendproof/ui/locales/zh-Hant.js +522 -0
  185. data/lib/sendproof/ui/manifest.json +866 -0
  186. data/lib/sendproof/ui/markdown.js +39 -0
  187. data/lib/sendproof/ui/model-view.js +182 -0
  188. data/lib/sendproof/ui/navigation.js +233 -0
  189. data/lib/sendproof/ui/operation-header.js +76 -0
  190. data/lib/sendproof/ui/operations.js +7 -0
  191. data/lib/sendproof/ui/overview-view.js +63 -0
  192. data/lib/sendproof/ui/personas.js +59 -0
  193. data/lib/sendproof/ui/popover.js +71 -0
  194. data/lib/sendproof/ui/preview-false.js +108 -0
  195. data/lib/sendproof/ui/request-editor.js +496 -0
  196. data/lib/sendproof/ui/response-metadata.js +354 -0
  197. data/lib/sendproof/ui/response-viewer.js +618 -0
  198. data/lib/sendproof/ui/result-blocked.js +155 -0
  199. data/lib/sendproof/ui/result-capture.js +25 -0
  200. data/lib/sendproof/ui/result-database.js +185 -0
  201. data/lib/sendproof/ui/result-effects.js +176 -0
  202. data/lib/sendproof/ui/result-headers.js +106 -0
  203. data/lib/sendproof/ui/result-logs.js +408 -0
  204. data/lib/sendproof/ui/result-states.js +213 -0
  205. data/lib/sendproof/ui/results.js +371 -0
  206. data/lib/sendproof/ui/router.js +118 -0
  207. data/lib/sendproof/ui/schema-model.js +336 -0
  208. data/lib/sendproof/ui/schema-tree.js +344 -0
  209. data/lib/sendproof/ui/schema.js +397 -0
  210. data/lib/sendproof/ui/security.js +31 -0
  211. data/lib/sendproof/ui/seeded-menu.js +69 -0
  212. data/lib/sendproof/ui/settings.js +93 -0
  213. data/lib/sendproof/ui/shortcuts-sheet.js +73 -0
  214. data/lib/sendproof/ui/shortcuts.js +190 -0
  215. data/lib/sendproof/ui/sidebar.js +289 -0
  216. data/lib/sendproof/ui/signin.js +259 -0
  217. data/lib/sendproof/ui/snippets.js +530 -0
  218. data/lib/sendproof/ui/store-marks.js +47 -0
  219. data/lib/sendproof/ui/stores.js +131 -0
  220. data/lib/sendproof/ui/styles.css +971 -0
  221. data/lib/sendproof/ui/toggletip.js +53 -0
  222. data/lib/sendproof/ui/uuid.js +10 -0
  223. data/lib/sendproof/ui/view.js +122 -0
  224. data/lib/sendproof/ui/views.css +653 -0
  225. data/lib/sendproof/version.rb +9 -0
  226. data/lib/sendproof/workbench.rb +102 -0
  227. data/lib/sendproof-core.rb +3 -0
  228. data/lib/sendproof.rb +121 -0
  229. metadata +292 -0
@@ -0,0 +1,253 @@
1
+ // Locale-aware text and formatting for Sendproof's own interface.
2
+ //
3
+ // Only the workbench's chrome is translated. Text from the OpenAPI document (summaries, titles,
4
+ // descriptions) and captured data (rows, JSON, SQL, headers) is shown exactly as written or
5
+ // stored; callers mark spec text with lang="en" so screen readers switch voice.
6
+ //
7
+ // Catalogues live in ./locales/<catalogue>.js (each spreads its <catalogue>-capture.js). English
8
+ // is bundled; every other catalogue is loaded on demand with loadLanguage(), so the workbench
9
+ // downloads one language, not 34. A missing key falls back to English, then to the key.
10
+ import en from './locales/en.js';
11
+
12
+ /** Catalogues loaded so far, by catalogue id. English is always present. */
13
+ const catalogues = { en };
14
+
15
+ /**
16
+ * Every UI language (Display settings lists them in these groups). `id` is the BCP 47 tag that
17
+ * drives Intl; `catalogue` names the strings file (English variants share `en` and differ only in
18
+ * Intl formatting). `autonym` is the language in its own script, `english` its English name,
19
+ * `region` the region in that language. `review` marks machine-translated catalogues that a native
20
+ * speaker hasn't reviewed yet; the picker tags them "Preview" (see ui/locales/README.md).
21
+ */
22
+ export const LANGUAGES = [
23
+ ...[['en-IE', 'Ireland'], ['en-GB', 'United Kingdom'], ['en-US', 'United States'], ['en-CA', 'Canada'], ['en-AU', 'Australia'], ['en-IN', 'India']]
24
+ .map(([id, region]) => ({ id, group: 'english', catalogue: 'en', autonym: 'English', english: 'English', region })),
25
+ { id: 'de-DE', group: 'west', catalogue: 'de', autonym: 'Deutsch', english: 'German', region: 'Deutschland' },
26
+ { id: 'fr-FR', group: 'west', catalogue: 'fr', autonym: 'Français', english: 'French', region: 'France', review: true },
27
+ { id: 'es-ES', group: 'west', catalogue: 'es', autonym: 'Español', english: 'Spanish', region: 'España', review: true },
28
+ { id: 'it-IT', group: 'west', catalogue: 'it', autonym: 'Italiano', english: 'Italian', region: 'Italia', review: true },
29
+ { id: 'nl-NL', group: 'west', catalogue: 'nl', autonym: 'Nederlands', english: 'Dutch', region: 'Nederland', review: true },
30
+ { id: 'pt-BR', group: 'west', catalogue: 'pt-BR', autonym: 'Português', english: 'Portuguese', region: 'Brasil', review: true },
31
+ { id: 'pt-PT', group: 'west', catalogue: 'pt-PT', autonym: 'Português', english: 'Portuguese', region: 'Portugal', review: true },
32
+ { id: 'da-DK', group: 'nordic', catalogue: 'da', autonym: 'Dansk', english: 'Danish', region: 'Danmark', review: true },
33
+ { id: 'nb-NO', group: 'nordic', catalogue: 'nb', autonym: 'Norsk bokmål', english: 'Norwegian', region: 'Norge', review: true },
34
+ { id: 'fi-FI', group: 'nordic', catalogue: 'fi', autonym: 'Suomi', english: 'Finnish', region: 'Suomi', review: true },
35
+ { id: 'sv-SE', group: 'nordic', catalogue: 'sv', autonym: 'Svenska', english: 'Swedish', region: 'Sverige', review: true },
36
+ { id: 'cs-CZ', group: 'central', catalogue: 'cs', autonym: 'Čeština', english: 'Czech', region: 'Česko', review: true },
37
+ { id: 'el-GR', group: 'central', catalogue: 'el', autonym: 'Ελληνικά', english: 'Greek', region: 'Ελλάδα', review: true },
38
+ { id: 'pl-PL', group: 'central', catalogue: 'pl', autonym: 'Polski', english: 'Polish', region: 'Polska', review: true },
39
+ { id: 'ru-RU', group: 'central', catalogue: 'ru', autonym: 'Русский', english: 'Russian', region: 'Россия', review: true },
40
+ { id: 'tr-TR', group: 'central', catalogue: 'tr', autonym: 'Türkçe', english: 'Turkish', region: 'Türkiye', review: true },
41
+ { id: 'uk-UA', group: 'central', catalogue: 'uk', autonym: 'Українська', english: 'Ukrainian', region: 'Україна', review: true },
42
+ { id: 'ar', group: 'rtl', catalogue: 'ar', autonym: 'العربية', english: 'Arabic', region: '' },
43
+ { id: 'fa-IR', group: 'rtl', catalogue: 'fa', autonym: 'فارسی', english: 'Persian', region: 'ایران', review: true },
44
+ { id: 'he-IL', group: 'rtl', catalogue: 'he', autonym: 'עברית', english: 'Hebrew', region: 'ישראל', review: true },
45
+ { id: 'hi-IN', group: 'asia', catalogue: 'hi', autonym: 'हिन्दी', english: 'Hindi', region: 'भारत', review: true },
46
+ { id: 'id-ID', group: 'asia', catalogue: 'id', autonym: 'Bahasa Indonesia', english: 'Indonesian', region: 'Indonesia', review: true },
47
+ { id: 'ja-JP', group: 'asia', catalogue: 'ja', autonym: '日本語', english: 'Japanese', region: '日本', review: true },
48
+ { id: 'ko-KR', group: 'asia', catalogue: 'ko', autonym: '한국어', english: 'Korean', region: '대한민국', review: true },
49
+ { id: 'th-TH', group: 'asia', catalogue: 'th', autonym: 'ไทย', english: 'Thai', region: 'ไทย', review: true },
50
+ { id: 'vi-VN', group: 'asia', catalogue: 'vi', autonym: 'Tiếng Việt', english: 'Vietnamese', region: 'Việt Nam', review: true },
51
+ { id: 'zh-Hans', group: 'asia', catalogue: 'zh-Hans', autonym: '简体中文', english: 'Chinese, Simplified', region: '中国大陆', review: true },
52
+ { id: 'zh-Hant', group: 'asia', catalogue: 'zh-Hant', autonym: '繁體中文', english: 'Chinese, Traditional', region: '台灣', review: true },
53
+ ].map(language => ({ ...language, dir: ['ar', 'fa', 'he'].includes(language.catalogue) ? 'rtl' : 'ltr', name: languageName(language) }));
54
+
55
+ /** The order of the picker's groups; their headings are `lang.group.<id>`. */
56
+ export const LANGUAGE_GROUPS = ['english', 'west', 'nordic', 'central', 'rtl', 'asia'];
57
+
58
+ /** Every catalogue id, for tests and tools. */
59
+ export const CATALOGUES = [...new Set(LANGUAGES.map(language => language.catalogue))];
60
+
61
+ /** "English (Ireland)", "Deutsch (Deutschland)", "العربية": the autonym with its region. */
62
+ function languageName({ autonym, region }) {
63
+ return region && region !== autonym ? `${autonym} (${region})` : autonym;
64
+ }
65
+
66
+ /**
67
+ * Loads the catalogue a language needs (English is bundled). Resolves once `configure()` can use
68
+ * it; a failed download leaves English in place, so the UI is never left without strings.
69
+ */
70
+ export async function loadLanguage(language) {
71
+ const entry = LANGUAGES.find(item => item.id === language);
72
+ const id = entry?.catalogue;
73
+ if (!id || catalogues[id]) return catalogues[id] ?? en;
74
+ try { catalogues[id] = (await import(`./locales/${id}.js`)).default; }
75
+ catch { return en; }
76
+ return catalogues[id];
77
+ }
78
+
79
+ /** The loaded catalogue for a language, if any: for previews in a language that isn't active. */
80
+ export const catalogueFor = language => catalogues[LANGUAGES.find(item => item.id === language)?.catalogue];
81
+
82
+ const entities = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' };
83
+ const escape = value => String(value ?? '').replace(/[&<>"']/g, char => entities[char]);
84
+
85
+ let active = {
86
+ language: 'en-IE', locale: 'en-IE', catalogue: en, dir: 'ltr', digits: 'latn', platform: 'mac',
87
+ };
88
+
89
+ /** Picks the closest offered language for a list of BCP 47 preferences. */
90
+ export function matchLanguage(preferences = []) {
91
+ for (const wanted of preferences) {
92
+ const exact = LANGUAGES.find(language => language.id.toLowerCase() === String(wanted).toLowerCase());
93
+ if (exact) return exact.id;
94
+ }
95
+ for (const wanted of preferences) {
96
+ // zh-CN, zh-SG → Simplified; zh-TW, zh-HK, zh-MO → Traditional. Scripts win over regions.
97
+ const tag = String(wanted).toLowerCase();
98
+ if (/^zh-(hant|tw|hk|mo)\b/.test(tag)) return 'zh-Hant';
99
+ if (/^zh\b/.test(tag)) return 'zh-Hans';
100
+ const base = { no: 'nb', nn: 'nb', iw: 'he' }[tag.split('-')[0]] ?? tag.split('-')[0];
101
+ const close = LANGUAGES.find(language => language.catalogue === base || language.id.toLowerCase().split('-')[0] === base);
102
+ if (close) return close.id;
103
+ }
104
+ return 'en-IE';
105
+ }
106
+
107
+ /** The platform whose shortcut glyphs to show: macOS uses ⌘ ⌥, everything else Ctrl and Alt. */
108
+ export function detectPlatform(navigatorLike = globalThis.navigator) {
109
+ const name = navigatorLike?.userAgentData?.platform || navigatorLike?.platform || '';
110
+ return /mac|iphone|ipad/i.test(name) ? 'mac' : name ? 'win' : 'mac';
111
+ }
112
+
113
+ /** Switches language, digits (Arabic only) and platform for every later call. */
114
+ export function configure({ language = active.language, digits = active.digits, platform = active.platform } = {}) {
115
+ const entry = LANGUAGES.find(item => item.id === language) || LANGUAGES[0];
116
+ const catalogue = catalogues[entry.catalogue] || en;
117
+ // Arabic and Persian default to Latin digits (what people type in an API tool); the Digits
118
+ // setting switches to Arabic-Indic (ar) or Extended Arabic-Indic (fa) digits.
119
+ const native = { ar: 'arab', fa: 'arabext' }[entry.catalogue];
120
+ const locale = native ? `${entry.id}-u-nu-${digits === 'arab' ? native : 'latn'}` : entry.id;
121
+ active = { language: entry.id, locale, catalogue, dir: entry.dir, digits, platform, loaded: !!catalogues[entry.catalogue] };
122
+ pluralRules = new Intl.PluralRules(locale);
123
+ return active;
124
+ }
125
+
126
+ /**
127
+ * Text for a key in another, already loaded language: the language picker's RTL preview shows
128
+ * a real field in the language you're about to pick. Falls back to the active language.
129
+ */
130
+ export function tIn(language, key, vars = {}) {
131
+ const catalogue = catalogueFor(language);
132
+ const text = catalogue?.strings?.[key];
133
+ if (typeof text !== 'string') return t(key, vars);
134
+ return text.replace(/\{(\w+)\}/g, (match, name) => vars[name] ?? match);
135
+ }
136
+
137
+ /** Arabic-Indic (٠-٩) and Extended Arabic-Indic (۰-۹, Persian) digits as ASCII digits. */
138
+ export const nativeDigits = text => String(text).replace(/[٠-٩]/g, digit => String('٠١٢٣٤٥٦٧٨٩'.indexOf(digit))).replace(/[۰-۹]/g, digit => String('۰۱۲۳۴۵۶۷۸۹'.indexOf(digit)));
139
+
140
+ /** The current language, Intl locale, text direction, digits and platform. */
141
+ export const current = () => active;
142
+
143
+ let pluralRules = new Intl.PluralRules('en-IE');
144
+
145
+ function entryFor(key) {
146
+ return active.catalogue.strings?.[key] ?? en.strings[key] ?? key;
147
+ }
148
+
149
+ function pick(entry, vars) {
150
+ if (entry && typeof entry === 'object') {
151
+ const n = Number(vars?.n ?? 0);
152
+ const form = n === 0 && entry.zero ? 'zero' : pluralRules.select(n);
153
+ return { text: entry[form] ?? entry.other, vars: { ...vars, n: formatNumber(n) } };
154
+ }
155
+ return { text: String(entry), vars };
156
+ }
157
+
158
+ /** Text for a key. Placeholders such as {name} are replaced with plain values. */
159
+ export function t(key, vars = {}) {
160
+ const { text, vars: values } = pick(entryFor(key), vars);
161
+ return text.replace(/\*\*(.+?)\*\*/g, '$1').replace(/`(.+?)`/g, '$1').replace(/\{(\w+)\}/g, (match, name) => values[name] ?? match);
162
+ }
163
+
164
+ /**
165
+ * HTML for a key. The catalogue text is escaped and each placeholder value is inserted as
166
+ * trusted HTML, so callers escape data and may pass markup such as <code>. Catalogue text may
167
+ * mark **bold** and `code`, so translators can move emphasis with the words.
168
+ */
169
+ export function th(key, vars = {}) {
170
+ const { text, vars: values } = pick(entryFor(key), vars);
171
+ // Marks may span placeholders ("**{n} values are missing.**"), so values go in last.
172
+ const slots = [];
173
+ const marked = escape(text.replace(/\{(\w+)\}/g, (match, name) => Object.hasOwn(values, name) ? `\u0000${slots.push(String(values[name])) - 1}\u0000` : match))
174
+ .replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>').replace(/`(.+?)`/g, '<code>$1</code>');
175
+ return marked.replace(/\u0000(\d+)\u0000/g, (match, index) => slots[Number(index)]);
176
+ }
177
+
178
+ /** True when the active catalogue (or English) has the key. */
179
+ export const has = key => Object.hasOwn(active.catalogue.strings || {}, key) || Object.hasOwn(en.strings, key);
180
+
181
+ export const formatNumber = (n, options) => new Intl.NumberFormat(active.locale, options).format(n);
182
+ export const formatDecimal = (n, digits = 2) =>
183
+ formatNumber(n, { minimumFractionDigits: digits, maximumFractionDigits: digits });
184
+ export const formatMoney = (n, currency = 'EUR') => formatNumber(n, { style: 'currency', currency });
185
+ /** Units in the locale's short form, such as "84 ms" or "1.2 kB". */
186
+ export const formatUnit = (n, unit, digits = 0) =>
187
+ formatNumber(n, { style: 'unit', unit, unitDisplay: 'short', maximumFractionDigits: digits });
188
+ /** Bytes as B, kB or MB in the locale's short form. */
189
+ export function formatBytes(bytes) {
190
+ // Intl spells out "byte"; the short symbol B reads better next to kB.
191
+ if (bytes < 1000) return t('unit.bytes', { n: formatNumber(bytes) });
192
+ if (bytes < 1_000_000) return formatUnit(bytes / 1000, 'kilobyte', 1);
193
+ return formatUnit(bytes / 1_000_000, 'megabyte', 1);
194
+ }
195
+ /** Milliseconds below a second, seconds above. */
196
+ export const formatDuration = ms => ms < 1000 ? formatUnit(Math.round(ms), 'millisecond') : formatUnit(ms / 1000, 'second', 1);
197
+
198
+ const isoDay = iso => new Date(String(iso).slice(0, 10) + 'T00:00:00Z');
199
+ export const formatDate = (iso, options = { day: '2-digit', month: '2-digit', year: 'numeric' }) =>
200
+ new Intl.DateTimeFormat(active.locale, { ...options, timeZone: 'UTC' }).format(isoDay(iso));
201
+ export const formatWeekday = iso =>
202
+ new Intl.DateTimeFormat(active.locale, { weekday: 'short', timeZone: 'UTC' }).format(isoDay(iso));
203
+ export const formatTime = value =>
204
+ new Intl.DateTimeFormat(active.locale, { hour: '2-digit', minute: '2-digit', second: '2-digit' }).format(new Date(value));
205
+ export const formatDateTime = value =>
206
+ new Intl.DateTimeFormat(active.locale, { dateStyle: 'medium', timeStyle: 'medium' }).format(new Date(value));
207
+ export const formatList = (items, type = 'conjunction') =>
208
+ new Intl.ListFormat(active.locale, { style: 'long', type }).format(items.map(String));
209
+ export const formatRelativeDays = days =>
210
+ new Intl.RelativeTimeFormat(active.locale, { numeric: 'auto' }).format(days, 'day');
211
+
212
+ /** The order and separators of a numeric date in this locale, as letters: dd/mm/yyyy, TT.MM.JJJJ. */
213
+ export function datePattern() {
214
+ const letters = active.catalogue.dateLetters || en.dateLetters;
215
+ return new Intl.DateTimeFormat(active.locale, { day: '2-digit', month: '2-digit', year: 'numeric', timeZone: 'UTC' })
216
+ .formatToParts(new Date(Date.UTC(2006, 10, 22)))
217
+ .map(part => part.type === 'literal' ? part.value.replace(/‏|‎/g, '') : ({ day: letters.day, month: letters.month, year: letters.year })[part.type] ?? '')
218
+ .join('');
219
+ }
220
+
221
+ /**
222
+ * Reads a date typed in the locale's own order ("23/11/2026", "23.11.2026") or ISO, and returns
223
+ * { iso } or { invalid: 'format' | 'day' } so callers can say what is wrong.
224
+ */
225
+ export function parseLocalDate(text) {
226
+ const value = nativeDigits(String(text ?? '').trim());
227
+ if (!value) return {};
228
+ let year, month, day;
229
+ const iso = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
230
+ if (iso) [, year, month, day] = iso.map(Number);
231
+ else {
232
+ const numbers = value.split(/[^\d]+/).filter(Boolean).map(Number);
233
+ if (numbers.length !== 3) return { invalid: 'format' };
234
+ const order = new Intl.DateTimeFormat(active.locale, { day: '2-digit', month: '2-digit', year: 'numeric' })
235
+ .formatToParts(new Date(Date.UTC(2006, 10, 22))).filter(part => ['day', 'month', 'year'].includes(part.type)).map(part => part.type);
236
+ const parts = Object.fromEntries(order.map((type, index) => [type, numbers[index]]));
237
+ ({ year, month, day } = parts);
238
+ if (year < 100) year += 2000;
239
+ }
240
+ const date = new Date(Date.UTC(year, month - 1, day));
241
+ if (month < 1 || month > 12 || !year) return { invalid: 'format' };
242
+ if (date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day) return { invalid: 'day', year, month, day };
243
+ return { iso: date.toISOString().slice(0, 10) };
244
+ }
245
+
246
+ /** The name of a month in this locale, for messages such as "31 February 2026 doesn't exist". */
247
+ export const formatDayMonthYear = (year, month, day) => {
248
+ const name = new Intl.DateTimeFormat(active.locale, { month: 'long', timeZone: 'UTC' }).format(new Date(Date.UTC(year, month - 1, 1)));
249
+ return t('date.dayMonthYear', { day: formatNumber(day, { useGrouping: false }), month: name, year: formatNumber(year, { useGrouping: false }) });
250
+ };
251
+
252
+ /** Widths for the fixed Send and Preview buttons in this language and platform. */
253
+ export const runButtonWidths = () => (active.catalogue.widths || en.widths)[active.platform];
@@ -0,0 +1,87 @@
1
+ // Shared SVG sprite, matching the approved mocks. Decorative instances are hidden from
2
+ // assistive technology; components.js adds .i-dir to icons that mirror in right-to-left layouts.
3
+ (() => {
4
+ const paths = {
5
+ search: '<circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>',
6
+ 'chevron-down': '<path d="m6 9 6 6 6-6"/>',
7
+ 'chevron-right': '<path d="m9 6 6 6-6 6"/>',
8
+ 'chevrons-ud': '<path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/>',
9
+ lock: '<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/>',
10
+ copy: '<rect x="9" y="9" width="12" height="12" rx="2"/><path d="M5 15H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v1"/>',
11
+ flask: '<path d="M9 3h6"/><path d="M10 3v6L4.5 18.5A1.7 1.7 0 0 0 6 21h12a1.7 1.7 0 0 0 1.5-2.5L14 9V3"/><path d="M7 15h10"/>',
12
+ send: '<path d="M22 2 11 13"/><path d="m22 2-7 20-4-9-9-4 20-7z"/>',
13
+ db: '<ellipse cx="12" cy="5" rx="8" ry="3"/><path d="M4 5v14c0 1.7 3.6 3 8 3s8-1.3 8-3V5"/><path d="M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3"/>',
14
+ mail: '<rect x="3" y="5" width="18" height="14" rx="2"/><path d="m3 7 9 6 9-6"/>',
15
+ check: '<path d="M20 6 9 17l-5-5"/>',
16
+ alert: '<circle cx="12" cy="12" r="9"/><path d="M12 8v4.5"/><path d="M12 16h.01"/>',
17
+ info: '<circle cx="12" cy="12" r="9"/><path d="M12 11v5"/><path d="M12 8h.01"/>',
18
+ plus: '<path d="M12 5v14M5 12h14"/>',
19
+ x: '<path d="M18 6 6 18M6 6l12 12"/>',
20
+ moon: '<path d="M20 14.5A8 8 0 1 1 9.5 4a6.5 6.5 0 0 0 10.5 10.5z"/>',
21
+ menu: '<path d="M4 7h16M4 12h16M4 17h16"/>',
22
+ // The Sendproof mark (docs/images/logo): a faint preview dart behind the solid send dart.
23
+ mark: '<g fill="currentColor" stroke="currentColor" stroke-width="1"><path d="M1.5 5 7.57 8.15 9.11 12 7.57 15.85 1.5 19 4.3 12z" style="opacity:var(--mark-ghost,.4)"/><path d="M9 5 22.5 12 9 19 11.8 12z"/></g>',
24
+ shield: '<path d="M12 3 4 6v6c0 4.5 3.4 8.3 8 9 4.6-.7 8-4.5 8-9V6l-8-3z"/><path d="m9 12 2 2 4-4"/>',
25
+ calendar: '<rect x="3" y="5" width="18" height="16" rx="2"/><path d="M16 3v4M8 3v4M3 10h18"/>',
26
+ undo: '<path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-15-6.7L3 13"/>',
27
+ filter: '<path d="M4 5h16l-6 7.5V19l-4 2v-8.5z"/>',
28
+ more: '<circle cx="5" cy="12" r="1"/><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/>',
29
+ history: '<path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/><path d="M12 7v5l3 2"/>',
30
+ refresh: '<path d="M21 12a9 9 0 0 1-15.5 6.2L3 16"/><path d="M3 12a9 9 0 0 1 15.5-6.2L21 8"/><path d="M21 3v5h-5"/><path d="M3 21v-5h5"/>',
31
+ wand: '<path d="m15 4 1.2 2.8L19 8l-2.8 1.2L15 12l-1.2-2.8L11 8l2.8-1.2z"/><path d="M4 20 13 11"/><path d="M6 4v2M5 5h2M19 15v2M18 16h2"/>',
32
+ keyboard: '<rect x="2" y="6" width="20" height="12" rx="2"/><path d="M6 10h.01M10 10h.01M14 10h.01M18 10h.01M7 14h10"/>',
33
+ link: '<path d="M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1"/><path d="M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"/>',
34
+ at: '<circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"/>',
35
+ trash: '<path d="M4 7h16"/><path d="M10 11v6M14 11v6"/><path d="M6 7l1 13h10l1-13"/><path d="M9 7V4h6v3"/>',
36
+ globe: '<circle cx="12" cy="12" r="9"/><path d="M3 12h18"/><path d="M12 3a14 14 0 0 1 0 18a14 14 0 0 1 0-18"/>',
37
+ 'arrow-down': '<path d="M12 5v14M6 13l6 6 6-6"/>',
38
+ 'arrow-up': '<path d="M12 19V5M6 11l6-6 6 6"/>',
39
+ enter: '<path d="M20 5v7a3 3 0 0 1-3 3H5"/><path d="m9 11-4 4 4 4"/>',
40
+ grip: '<circle cx="9" cy="6" r="1"/><circle cx="15" cy="6" r="1"/><circle cx="9" cy="12" r="1"/><circle cx="15" cy="12" r="1"/><circle cx="9" cy="18" r="1"/><circle cx="15" cy="18" r="1"/>',
41
+ hash: '<path d="M5 9h14M4 15h14M10 3 8 21M16 3l-2 18"/>',
42
+ sidebar: '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M9 4v16"/>',
43
+ code: '<path d="m16 18 6-6-6-6"/><path d="m8 6-6 6 6 6"/>',
44
+ user: '<circle cx="12" cy="8" r="4"/><path d="M4 21a8 8 0 0 1 16 0"/>',
45
+ list: '<path d="M8 6h13M8 12h13M8 18h13"/><path d="M3 6h.01M3 12h.01M3 18h.01"/>',
46
+ edit: '<path d="M4 20h4L19 9l-4-4L4 16z"/><path d="m13 7 4 4"/>',
47
+ eye: '<path d="M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/>',
48
+ clock: '<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>',
49
+ logs: '<path d="M4 6h16M4 12h10M4 18h13"/>',
50
+ key: '<circle cx="8" cy="15" r="4"/><path d="m11 12 9-9"/><path d="m17 6 3 3"/>',
51
+ building: '<rect x="4" y="3" width="16" height="18" rx="1.5"/><path d="M9 7h1M14 7h1M9 11h1M14 11h1M9 15h1M14 15h1"/><path d="M10 21v-3h4v3"/>',
52
+ shuffle: '<path d="M16 3h5v5"/><path d="M4 20 21 3"/><path d="M21 16v5h-5"/><path d="m15 15 6 6"/><path d="M4 4l5 5"/>',
53
+ users: '<circle cx="9" cy="8" r="4"/><path d="M2 21a7 7 0 0 1 14 0"/><path d="M16 4a4 4 0 0 1 0 8"/><path d="M22 21a7 7 0 0 0-4-6.3"/>',
54
+ windows: '<rect x="3" y="3" width="8" height="8"/><rect x="13" y="3" width="8" height="8"/><rect x="3" y="13" width="8" height="8"/><rect x="13" y="13" width="8" height="8"/>',
55
+ corner: '<path d="M9 10 4 15l5 5"/><path d="M20 4v7a4 4 0 0 1-4 4H4"/>',
56
+ 'chevron-left': '<path d="m15 6-6 6 6 6"/>',
57
+ warn: '<path d="M10.3 3.9 2.4 18a2 2 0 0 0 1.7 3h15.8a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z"/><path d="M12 9v4"/><path d="M12 17h.01"/>',
58
+ sun: '<circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/>',
59
+ monitor: '<rect x="2" y="4" width="20" height="13" rx="2"/><path d="M8 21h8M12 17v4"/>',
60
+ 'arrow-left': '<path d="M19 12H5M11 6l-6 6 6 6"/>',
61
+ 'arrow-right': '<path d="M5 12h14M13 6l6 6-6 6"/>',
62
+ book: '<path d="M4 4.5A2.5 2.5 0 0 1 6.5 2H20v17H6.5A2.5 2.5 0 0 0 4 21.5z"/><path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"/>',
63
+ box: '<path d="M21 8 12 3 3 8v8l9 5 9-5z"/><path d="m3 8 9 5 9-5M12 13v8"/>',
64
+ braces: '<path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5a2 2 0 0 0 2 2h1"/><path d="M16 21h1a2 2 0 0 0 2-2v-5a2 2 0 0 1 2-2 2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1"/>',
65
+ sliders: '<path d="M4 21v-7M4 10V3M12 21v-9M12 8V3M20 21v-5M20 12V3"/><path d="M1 14h6M9 8h6M17 16h6"/>',
66
+ tag: '<path d="M20.6 13.4 13.4 20.6a2 2 0 0 1-2.8 0L3 13V3h10l7.6 7.6a2 2 0 0 1 0 2.8z"/><path d="M7.5 7.5h.01"/>',
67
+ 'log-in': '<path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"/><path d="m10 17 5-5-5-5M15 12H3"/>',
68
+ server: '<rect x="3" y="4" width="18" height="7" rx="2"/><rect x="3" y="13" width="18" height="7" rx="2"/><path d="M7 7.5h.01M7 16.5h.01"/>',
69
+ 'wifi-off': '<path d="m2 2 20 20"/><path d="M8.5 16.5a5 5 0 0 1 7 0M5 13a10 10 0 0 1 5.2-2.8M19 13a10 10 0 0 0-2.6-1.9M2 8.8a15 15 0 0 1 4.2-2.6M22 8.8A15 15 0 0 0 11 5"/><path d="M12 20h.01"/>',
70
+ split: '<path d="M16 3h5v5M8 3H3v5M21 3l-7 7M3 3l7 7M12 14v7"/>',
71
+ type: '<path d="M4 7V5h16v2M9 19h6M12 5v14"/>',
72
+ // v5: the attribute list, the response viewer and the language picker.
73
+ minus: '<path d="M5 12h14"/>',
74
+ wrap: '<path d="M3 6h18M3 12h15a3 3 0 0 1 0 6h-4"/><path d="m16 16-2 2 2 2"/><path d="M3 18h7"/>',
75
+ table: '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 10h18M9 10v10"/>',
76
+ external: '<path d="M14 4h6v6"/><path d="M20 4 11 13"/><path d="M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5"/>',
77
+ 'circle-check': '<circle cx="12" cy="12" r="9"/><path d="m8.5 12 2.5 2.5 4.5-5"/>',
78
+ languages: '<path d="M4 5h9M8.5 3v2M6 5c.7 3.2 2.6 5.6 5 7M11 5c-.6 3.8-3 6.8-6.5 8.5"/><path d="m12.5 21 4-10 4 10M14 17.5h5"/>',
79
+ repeat: '<path d="m17 2 4 4-4 4"/><path d="M3 11v-1a4 4 0 0 1 4-4h14M7 22l-4-4 4-4"/><path d="M21 13v1a4 4 0 0 1-4 4H3"/>',
80
+ // v6: data stores (Preview unavailable and the write guard).
81
+ 'flask-off': '<path d="M9 3h6"/><path d="M10 3v4.5M14 3v6l2.2 4.1"/><path d="M8.6 11.4 4.5 18.5A1.7 1.7 0 0 0 6 21h12a1.7 1.7 0 0 0 .9-.25"/><path d="M3 3l18 18"/>',
82
+ ban: '<circle cx="12" cy="12" r="9"/><path d="m5.7 5.7 12.6 12.6"/>',
83
+ };
84
+ document.body.insertAdjacentHTML('afterbegin',
85
+ '<svg xmlns="http://www.w3.org/2000/svg" style="display:none" aria-hidden="true">' +
86
+ Object.entries(paths).map(([k, v]) => `<symbol id="i-${k}" viewBox="0 0 24 24">${v}</symbol>`).join('') + '</svg>');
87
+ })();
@@ -0,0 +1,70 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
6
+ <title>Sendproof</title>
7
+ <link rel="icon" href="favicon.png" sizes="32x32" type="image/png" />
8
+ <link rel="icon" href="favicon.svg" type="image/svg+xml" />
9
+ <link rel="stylesheet" href="styles.css" />
10
+ <link rel="stylesheet" href="views.css" />
11
+ <link rel="stylesheet" href="app.css" />
12
+ </head>
13
+ <body>
14
+ <!-- The loading shell mirrors the final layout (mock 39), so nothing jumps when the spec arrives. -->
15
+ <div id="app">
16
+ <div class="app loading-shell" aria-busy="true">
17
+ <header class="topbar">
18
+ <span class="brand"><span class="brand-mark" aria-hidden="true"><svg class="i" aria-hidden="true"><use href="#i-mark"/></svg></span><span class="desktop-only" data-i18n="app.name">Sendproof</span></span>
19
+ <span class="crumb-sep desktop-only" aria-hidden="true">/</span>
20
+ <span class="api-switch faint" role="status" data-i18n="shell.loadingApi">Loading API…</span>
21
+ <span class="spacer"></span>
22
+ <span class="sk search-trigger desktop-only" aria-hidden="true"></span>
23
+ <span class="sk persona" style="inline-size:7.5rem" aria-hidden="true"></span>
24
+ </header>
25
+ <div class="mobile-switch" aria-hidden="true"><div class="segmented" style="inline-size:100%"><span class="sk" style="display:block;inline-size:100%;block-size:2.5rem"></span></div></div>
26
+ <div class="workspace" data-view="request" aria-hidden="true">
27
+ <div class="sidebar">
28
+ <div class="tabs"><span class="tab"><span class="sk" style="display:block;inline-size:6rem;block-size:0.7rem"></span></span><span class="tab"><span class="sk" style="display:block;inline-size:4.5rem;block-size:0.7rem"></span></span></div>
29
+ <div class="sidebar-search"><div class="input-sm sk"></div></div>
30
+ <div class="nav">
31
+ <div class="nav-item"><span class="sk" style="display:block;inline-size:40%;block-size:0.6rem"></span></div>
32
+ <div class="nav-item"><span class="sk" style="display:block;inline-size:3rem;block-size:1.25rem"></span><span class="sk" style="display:block;inline-size:58%;block-size:0.7rem"></span></div>
33
+ <div class="nav-item"><span class="sk" style="display:block;inline-size:3rem;block-size:1.25rem"></span><span class="sk" style="display:block;inline-size:80%;block-size:0.7rem"></span></div>
34
+ <div class="nav-item"><span class="sk" style="display:block;inline-size:40%;block-size:0.6rem"></span></div>
35
+ <div class="nav-item"><span class="sk" style="display:block;inline-size:3rem;block-size:1.25rem"></span><span class="sk" style="display:block;inline-size:76%;block-size:0.7rem"></span></div>
36
+ <div class="nav-item"><span class="sk" style="display:block;inline-size:3rem;block-size:1.25rem"></span><span class="sk" style="display:block;inline-size:50%;block-size:0.7rem"></span></div>
37
+ </div>
38
+ <div class="pane-bar side-bar"><span class="bar-text"><span class="sk" style="display:block;inline-size:7rem;block-size:0.7rem"></span></span></div>
39
+ </div>
40
+ <div class="pane request">
41
+ <div class="ctx-bar"><nav class="crumbs"><span class="sk" style="display:block;inline-size:9rem;block-size:0.7rem"></span></nav><div class="end"><span class="sk" style="display:block;inline-size:9rem;block-size:1.75rem"></span></div></div>
42
+ <div class="pane-scroll">
43
+ <div class="op-head">
44
+ <span class="sk" style="display:block;inline-size:16rem;block-size:1.6rem"></span>
45
+ <span class="sk" style="display:block;inline-size:min(24rem,90%);block-size:0.8rem;margin-block-start:0.75rem"></span>
46
+ <div class="urlbar sk" style="border:0"></div>
47
+ </div>
48
+ <div class="tabs" style="margin-block-start:1rem"><span class="tab"><span class="sk" style="display:block;inline-size:3.5rem;block-size:0.7rem"></span></span><span class="tab"><span class="sk" style="display:block;inline-size:4.5rem;block-size:0.7rem"></span></span><span class="tab"><span class="sk" style="display:block;inline-size:3rem;block-size:0.7rem"></span></span></div>
49
+ <div class="form"><div class="fields">
50
+ <div class="field"><span class="sk" style="display:block;inline-size:7rem;block-size:0.8rem;margin-block:0.35rem"></span><span class="control sk" style="border:0"></span><span class="assist"></span></div>
51
+ <div class="field"><span class="sk" style="display:block;inline-size:7rem;block-size:0.8rem;margin-block:0.35rem"></span><span class="control sk" style="border:0"></span><span class="assist"></span></div>
52
+ <div class="field half"><span class="sk" style="display:block;inline-size:5rem;block-size:0.8rem;margin-block:0.35rem"></span><span class="control sk" style="border:0"></span><span class="assist"></span></div>
53
+ <div class="field half"><span class="sk" style="display:block;inline-size:5rem;block-size:0.8rem;margin-block:0.35rem"></span><span class="control sk" style="border:0"></span><span class="assist"></span></div>
54
+ </div></div>
55
+ </div>
56
+ <div class="actionbar"><span class="status"><span class="spinner" aria-hidden="true"></span></span><span class="btn btn-run btn-send sk" style="border:0"></span><span class="btn btn-run btn-preview sk" style="border:0"></span></div>
57
+ </div>
58
+ <div class="pane response">
59
+ <div class="resp-head"><span class="sk" style="display:block;inline-size:8rem;block-size:0.7rem"></span></div>
60
+ <div class="tabs"><span class="tab"><span class="sk" style="display:block;inline-size:4rem;block-size:0.7rem"></span></span><span class="tab"><span class="sk" style="display:block;inline-size:4rem;block-size:0.7rem"></span></span><span class="tab"><span class="sk" style="display:block;inline-size:5rem;block-size:0.7rem"></span></span></div>
61
+ <div class="pane-scroll"><div class="result-body"><div class="state"><span class="sk" style="display:block;inline-size:2.25rem;block-size:2.25rem;border-radius:var(--r-lg)"></span><span class="sk" style="display:block;inline-size:14rem;block-size:1rem"></span><span class="sk" style="display:block;inline-size:min(20rem,90%);block-size:0.7rem"></span><span class="sk" style="display:block;inline-size:min(17rem,80%);block-size:0.7rem"></span></div></div></div>
62
+ <div class="pane-bar result-bar"><span class="bar-text"><span class="sk" style="display:block;inline-size:11rem;block-size:0.7rem"></span></span></div>
63
+ </div>
64
+ </div>
65
+ </div>
66
+ </div>
67
+ <script src="icons.js"></script>
68
+ <script type="module" src="app.js"></script>
69
+ </body>
70
+ </html>
@@ -0,0 +1,187 @@
1
+ import { esc, icon } from './components.js';
2
+ import { t, th } from './i18n.js';
3
+ import { setFieldIssue } from './schema.js';
4
+ import { title } from './fields/dom.js';
5
+ import { shortcutAttrs, shortcutHint } from './shortcuts.js';
6
+
7
+ /** What an issue points at in a field: its select, lookup, radio group or input (never Clear or Remove). */
8
+ const CONTROLS = '[role="combobox"], [role="radiogroup"], input, textarea, button:not(.info-btn):not(.wand):not(.field-clear):not(.field-remove)';
9
+
10
+ const normalization = value => value.replace(/\[(\d+)\]/g, '.$1').replace(/^\$\.?/, '');
11
+ const fieldKey = issue => JSON.stringify([issue.tab || 'Body', normalization(issue.path || ''), issue.inputId || '']);
12
+
13
+ function fieldPath(field) {
14
+ const parameter = field.closest('[data-parameter-name]')?.dataset.parameterName;
15
+ const parts = JSON.parse(field.dataset.schemaPath);
16
+ return normalization((parameter ? [parameter, ...parts] : parts).join('.'));
17
+ }
18
+
19
+ /**
20
+ * Show request validation without growing or scrolling the form: an action-bar button with the
21
+ * count, a popover listing each field, a flag on each tab that has issues, and a polite
22
+ * announcement. Messages arrive already worded by the validators.
23
+ */
24
+ export function createIssues({ $, selectTab }) {
25
+ let issues = [];
26
+ let server = false;
27
+ let current = -1;
28
+
29
+ function target(issue) {
30
+ if (issue.inputId) {
31
+ const input = document.getElementById(issue.inputId);
32
+ if (input) return { input, field: input.closest('.field') };
33
+ }
34
+ if (issue.tab === 'Headers') {
35
+ const row = [...document.querySelectorAll('[data-header-row]')]
36
+ .find(node => (node.querySelector('[data-header-field="name"]')?.value || '').toLowerCase() === issue.path.toLowerCase());
37
+ return { input: row?.querySelector('[data-header-field="value"]') };
38
+ }
39
+ if (issue.path === '$' && $('#json')) return { input: $('#json'), field: $('#json').closest('.field') };
40
+ const candidates = [...document.querySelectorAll('#editor [data-schema-path]')];
41
+ const path = normalization(issue.path || '');
42
+ const field = candidates.find(node => fieldPath(node) === path) ??
43
+ candidates.find(node => fieldPath(node).toLowerCase() === path.toLowerCase());
44
+ // The currency segment of an amount is its own field and its own control.
45
+ const input = field?.matches?.(CONTROLS) ? field : [...(field?.querySelectorAll(CONTROLS) || [])]
46
+ .find(node => node.closest('[data-schema-path]') === field);
47
+ return { field, input };
48
+ }
49
+
50
+ function close(restore = false) {
51
+ $('#issues')?.remove();
52
+ const trigger = $('.issues-btn');
53
+ trigger?.setAttribute('aria-expanded', 'false');
54
+ if (restore) trigger?.focus();
55
+ }
56
+
57
+ function focusIssue(index) {
58
+ if (!issues.length) return;
59
+ current = (index + issues.length) % issues.length;
60
+ const issue = issues[current];
61
+ close();
62
+ let { input, field } = target(issue);
63
+ if (!input) {
64
+ selectTab(issue.tab || 'Form', { report: false });
65
+ ({ input, field } = target(issue));
66
+ }
67
+ if (field) setFieldIssue(field, input, issue.message);
68
+ // A radio group focuses its checked option; every other control focuses itself.
69
+ const focusable = input || $('#editor').querySelector('textarea, input, [tabindex="0"]') || $('#editor');
70
+ if (focusable.focusControl) focusable.focusControl(); else focusable.focus();
71
+ }
72
+
73
+ function open() {
74
+ close();
75
+ const trigger = $('.issues-btn');
76
+ if (!trigger || !issues.length) return;
77
+ const count = countFields();
78
+ trigger.setAttribute('aria-expanded', 'true');
79
+ $('.actionbar').insertAdjacentHTML('beforeend', `<section class="pop issues-pop" id="issues" role="dialog" aria-labelledby="issues-title">
80
+ <div class="pop-head"><span id="issues-title">${esc(t('issues.fieldsNeed', { n: count }))}</span><span class="spacer"></span><span class="faint">${esc(t(server ? 'issues.rejected' : 'issues.notSent'))}</span></div>
81
+ <div class="pop-group">${issues.map((issue, index) => {
82
+ const { field, input } = target(issue);
83
+ const name = field?.querySelector(':scope > .label')?.firstChild?.textContent ||
84
+ (issue.path === '$' ? t('issues.body') : title((issue.path || t('issues.request')).split('.').at(-1)));
85
+ return `<button class="issue-link${index === Math.max(0, current) ? ' is-active' : ''}" data-issue-index="${index}" ${input?.id ? `data-issue-target="${esc(input.id)}"` : ''} type="button">
86
+ <span class="ico">${icon('alert', true)}</span><span class="name">${esc(name)}</span><span class="why">${esc(issue.message)}</span>
87
+ </button>`;
88
+ }).join('')}</div>
89
+ <div class="pop-foot"><span>${th('issues.next', { key: shortcutHint('issue-next') })}</span><span>${th('issues.previous', { key: shortcutHint('issue-previous') })}</span><span class="spacer"></span><span>${th('issues.close', { key: shortcutHint('escape') })}</span></div>
90
+ </section>`);
91
+ const pop = $('#issues');
92
+ pop.addEventListener('click', event => {
93
+ const button = event.target.closest('[data-issue-index]');
94
+ if (button) focusIssue(Number(button.dataset.issueIndex));
95
+ });
96
+ pop.addEventListener('keydown', event => {
97
+ if (event.altKey || !['ArrowDown', 'ArrowUp'].includes(event.key)) return;
98
+ const buttons = [...pop.querySelectorAll('button')];
99
+ const index = buttons.indexOf(document.activeElement);
100
+ buttons[(index + (event.key === 'ArrowDown' ? 1 : -1) + buttons.length) % buttons.length].focus();
101
+ event.preventDefault();
102
+ });
103
+ pop.querySelector('.is-active')?.focus();
104
+ }
105
+
106
+ const countFields = () => issues.length;
107
+ let initialStatus;
108
+ function render() {
109
+ const status = $('.actionbar .status');
110
+ if (!status) return;
111
+ initialStatus ||= status.innerHTML;
112
+ const count = countFields();
113
+ const text = count ? t('issues.fieldsNeed', { n: count }) : '';
114
+ status.classList.toggle('is-error', !!count);
115
+ status.innerHTML = count ? `<button class="issues-btn" data-action="issues" type="button" aria-haspopup="dialog"
116
+ aria-expanded="false" aria-controls="issues" ${shortcutAttrs('issue-next')}>${icon('alert', true)}<span class="issues-label">${esc(text)}</span>
117
+ ${shortcutHint('issue-next')}</button>` : initialStatus;
118
+ const announcement = $('[data-request-announcement]');
119
+ if (announcement) announcement.textContent = text;
120
+ // A tab with issues shows its flag dot. The flag and its screen-reader text are always in
121
+ // the tab, so toggling them never changes its width; the count lives in the action bar.
122
+ for (const tab of document.querySelectorAll('[data-request-tab]')) {
123
+ const flag = tab.querySelector('[data-tab-flag]');
124
+ if (!flag) continue;
125
+ const tabName = tab.dataset.requestTab;
126
+ const errors = new Set(issues.filter(issue => (issue.tab || 'Body') === tabName).map(issue => issue.path)).size;
127
+ flag.hidden = !errors;
128
+ const flagText = tab.querySelector('[data-tab-flag-text]');
129
+ if (flagText) flagText.textContent = errors ? ', ' + t('issues.tabFlag', { n: errors }) : '';
130
+ }
131
+ }
132
+
133
+ function annotate() {
134
+ for (const issue of issues) {
135
+ const { field, input } = target(issue);
136
+ if (field) setFieldIssue(field, input, issue.message);
137
+ }
138
+ }
139
+
140
+ return {
141
+ get active() { return issues.length > 0; },
142
+ get server() { return server; },
143
+ annotate,
144
+ edit(input) {
145
+ if (!server) return;
146
+ const field = input.closest('[data-schema-path]');
147
+ const path = field ? fieldPath(field) : undefined;
148
+ issues = issues.filter(issue => !(
149
+ issue.inputId && input.id === issue.inputId ||
150
+ path !== undefined && normalization(issue.path || '').toLowerCase() === path.toLowerCase()
151
+ ));
152
+ close();
153
+ annotate();
154
+ render();
155
+ },
156
+ show(next, { fromServer = false, expand = false } = {}) {
157
+ close();
158
+ // Parser diagnostics are ordered first, before general schema errors.
159
+ const unique = new Map();
160
+ for (const issue of next) {
161
+ const key = fieldKey(issue);
162
+ if (!unique.has(key)) unique.set(key, issue);
163
+ }
164
+ const controls = [...document.querySelectorAll('#editor :is(input, textarea, [role="combobox"], [role="radiogroup"])')];
165
+ issues = [...unique.values()].map(issue => {
166
+ const { input } = target(issue);
167
+ const fieldOrder = controls.indexOf(input);
168
+ return { ...issue, fieldOrder: fieldOrder < 0 ? Infinity : fieldOrder };
169
+ }).sort((first, second) => first.fieldOrder - second.fieldOrder);
170
+ server = fromServer;
171
+ current = -1;
172
+ annotate();
173
+ render();
174
+ if (expand && !matchMedia('(max-width: 56rem)').matches) open();
175
+ },
176
+ clear() {
177
+ close();
178
+ issues = [];
179
+ server = false;
180
+ current = -1;
181
+ render();
182
+ },
183
+ close,
184
+ step(direction) { focusIssue(current < 0 && direction < 0 ? issues.length - 1 : current + direction); },
185
+ toggle() { if ($('#issues')) close(true); else open(); },
186
+ };
187
+ }