@roxyapi/ui 0.40.1 → 0.42.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 (120) hide show
  1. package/AGENTS.md +1 -0
  2. package/README.md +1 -0
  3. package/components-catalog.json +194 -149
  4. package/dist/cdn/components/choghadiya-grid.js +1 -1
  5. package/dist/cdn/components/choghadiya-grid.js.map +2 -2
  6. package/dist/cdn/components/endpoint-form.js +1 -1
  7. package/dist/cdn/components/endpoint-form.js.map +1 -1
  8. package/dist/cdn/components/hora-table.js +1 -1
  9. package/dist/cdn/components/hora-table.js.map +2 -2
  10. package/dist/cdn/components/kp-finance-card.js +350 -0
  11. package/dist/cdn/components/kp-finance-card.js.map +7 -0
  12. package/dist/cdn/components/vedic-daily.js +4 -4
  13. package/dist/cdn/components/vedic-daily.js.map +3 -3
  14. package/dist/cdn/locales/de.js +1 -1
  15. package/dist/cdn/locales/de.js.map +2 -2
  16. package/dist/cdn/locales/es.js +1 -1
  17. package/dist/cdn/locales/es.js.map +2 -2
  18. package/dist/cdn/locales/fr.js +1 -1
  19. package/dist/cdn/locales/fr.js.map +2 -2
  20. package/dist/cdn/locales/hi.js +1 -1
  21. package/dist/cdn/locales/hi.js.map +2 -2
  22. package/dist/cdn/locales/pt.js +1 -1
  23. package/dist/cdn/locales/pt.js.map +2 -2
  24. package/dist/cdn/locales/ru.js +1 -1
  25. package/dist/cdn/locales/ru.js.map +2 -2
  26. package/dist/cdn/locales/tr.js +1 -1
  27. package/dist/cdn/locales/tr.js.map +2 -2
  28. package/dist/cdn/roxy-ui.js +68 -68
  29. package/dist/cdn/roxy-ui.js.map +4 -4
  30. package/dist/cdn/widgets.js +1 -1
  31. package/dist/components/choghadiya-grid.js +1 -1
  32. package/dist/components/choghadiya-grid.js.map +2 -2
  33. package/dist/components/endpoint-form.js +1 -1
  34. package/dist/components/endpoint-form.js.map +1 -1
  35. package/dist/components/hora-table.js +1 -1
  36. package/dist/components/hora-table.js.map +2 -2
  37. package/dist/components/kp-finance-card.d.ts +53 -0
  38. package/dist/components/kp-finance-card.d.ts.map +1 -0
  39. package/dist/components/kp-finance-card.js +2 -0
  40. package/dist/components/kp-finance-card.js.map +7 -0
  41. package/dist/components/vedic-daily.d.ts +7 -0
  42. package/dist/components/vedic-daily.d.ts.map +1 -1
  43. package/dist/components/vedic-daily.js +1 -1
  44. package/dist/components/vedic-daily.js.map +3 -3
  45. package/dist/generated/endpoint-bindings.d.ts.map +1 -1
  46. package/dist/generated/tool-components.d.ts.map +1 -1
  47. package/dist/i18n/chrome-strings.d.ts +1 -1
  48. package/dist/i18n/chrome-strings.d.ts.map +1 -1
  49. package/dist/index.cjs +81 -81
  50. package/dist/index.cjs.map +4 -4
  51. package/dist/index.d.ts +1 -0
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +85 -85
  54. package/dist/index.js.map +4 -4
  55. package/dist/locales/de.d.ts.map +1 -1
  56. package/dist/locales/de.js +1 -1
  57. package/dist/locales/de.js.map +2 -2
  58. package/dist/locales/es.d.ts.map +1 -1
  59. package/dist/locales/es.js +1 -1
  60. package/dist/locales/es.js.map +2 -2
  61. package/dist/locales/fr.d.ts.map +1 -1
  62. package/dist/locales/fr.js +1 -1
  63. package/dist/locales/fr.js.map +2 -2
  64. package/dist/locales/hi.d.ts.map +1 -1
  65. package/dist/locales/hi.js +1 -1
  66. package/dist/locales/hi.js.map +2 -2
  67. package/dist/locales/pt.d.ts.map +1 -1
  68. package/dist/locales/pt.js +1 -1
  69. package/dist/locales/pt.js.map +2 -2
  70. package/dist/locales/ru.d.ts.map +1 -1
  71. package/dist/locales/ru.js +1 -1
  72. package/dist/locales/ru.js.map +2 -2
  73. package/dist/locales/tr.d.ts.map +1 -1
  74. package/dist/locales/tr.js +1 -1
  75. package/dist/locales/tr.js.map +2 -2
  76. package/dist/manifest.d.ts.map +1 -1
  77. package/dist/manifest.json +1 -0
  78. package/dist/schemas/post--kabbalah-compatibility.json +1 -1
  79. package/dist/schemas/post--kabbalah-gematria.json +1 -1
  80. package/dist/schemas/post--kabbalah-name-profile.json +1 -1
  81. package/dist/schemas/post--vedic-astrology-dasha-current.json +1 -1
  82. package/dist/schemas/post--vedic-astrology-kp-daily-finance.json +1 -0
  83. package/dist/styles/themes/practitioner.css +5 -5
  84. package/dist/tool-component.cjs +1 -1
  85. package/dist/tool-component.cjs.map +2 -2
  86. package/dist/tool-component.js +1 -1
  87. package/dist/tool-component.js.map +2 -2
  88. package/dist/types/index.d.ts +1 -1
  89. package/dist/types/index.d.ts.map +1 -1
  90. package/dist/types/types.gen.d.ts +594 -30
  91. package/dist/types/types.gen.d.ts.map +1 -1
  92. package/dist/version.d.ts +1 -1
  93. package/package.json +1 -1
  94. package/src/components/choghadiya-grid.ts +1 -1
  95. package/src/components/hora-table.ts +1 -1
  96. package/src/components/kp-finance-card.ts +586 -0
  97. package/src/components/vedic-daily.ts +65 -0
  98. package/src/generated/endpoint-bindings.ts +8 -0
  99. package/src/generated/tool-components.ts +5 -0
  100. package/src/i18n/chrome-strings.ts +43 -1
  101. package/src/index.ts +1 -0
  102. package/src/locales/de.ts +33 -1
  103. package/src/locales/es.ts +33 -1
  104. package/src/locales/field-labels/de.ts +10 -1
  105. package/src/locales/field-labels/es.ts +9 -1
  106. package/src/locales/field-labels/fr.ts +11 -1
  107. package/src/locales/field-labels/hi.ts +9 -1
  108. package/src/locales/field-labels/pt.ts +9 -1
  109. package/src/locales/field-labels/ru.ts +9 -1
  110. package/src/locales/field-labels/tr.ts +9 -1
  111. package/src/locales/fr.ts +32 -1
  112. package/src/locales/hi.ts +35 -1
  113. package/src/locales/pt.ts +32 -1
  114. package/src/locales/ru.ts +32 -1
  115. package/src/locales/tr.ts +37 -1
  116. package/src/manifest.ts +13 -0
  117. package/src/styles/themes/practitioner.css +5 -5
  118. package/src/types/index.ts +1 -1
  119. package/src/types/types.gen.ts +601 -30
  120. package/src/version.ts +1 -1
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const ROXY_UI_VERSION = "0.40.1";
1
+ export declare const ROXY_UI_VERSION = "0.42.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roxyapi/ui",
3
- "version": "0.40.1",
3
+ "version": "0.42.0",
4
4
  "description": "Web components for the RoxyAPI catalog. Drop-in charts, tables, cards, forms for astrology, tarot, numerology, biorhythm, I Ching, crystals, dreams, angel numbers, and more. One key, beautiful in 30 minutes.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -183,7 +183,7 @@ export class RoxyChoghadiyaGrid extends RoxyDataElement<GetChoghadiyaResponse> {
183
183
 
184
184
  <div class="cho-grid" part="table">
185
185
  <section class="period-col" aria-label=${this.t('Day muhurta periods')}>
186
- <h3 class="period-heading">${this.t('Day')}</h3>
186
+ <h3 class="period-heading">${this.t('Daytime')}</h3>
187
187
  <div role="list" aria-label=${this.t('Daytime choghadiya')}>
188
188
  ${
189
189
  dayChoghadiya && dayChoghadiya.length > 0
@@ -115,7 +115,7 @@ export class RoxyHoraTable extends RoxyDataElement<GetHoraResponse> {
115
115
  ${d.date ? html`<p class="subtitle">${formatDate(this.effectiveLang(), d.date)}</p>` : nothing}
116
116
  </div>
117
117
  <div class="cols" part="table">
118
- ${this.renderColumn(this.t('Day'), day)}
118
+ ${this.renderColumn(this.t('Daytime'), day)}
119
119
  ${this.renderColumn(this.t('Night'), night)}
120
120
  </div>
121
121
  </div>`;
@@ -0,0 +1,586 @@
1
+ import { css, html, nothing, type TemplateResult } from 'lit';
2
+ import { customElement } from 'lit/decorators.js';
3
+ import type { ChromeString } from '../i18n/chrome-strings.js';
4
+ import { planetGlyph } from '../tokens/index.js';
5
+ import type { GetKpDailyFinanceResponse } from '../types/index.js';
6
+ import { RoxyDataElement } from '../utils/base-element.js';
7
+ import { baseStyles } from '../utils/base-styles.js';
8
+ import {
9
+ formatDateTime,
10
+ formatList,
11
+ formatNumber,
12
+ formatTime,
13
+ } from '../utils/format.js';
14
+ import { frameCaptionStyles, renderFrameCaption } from '../utils/frame.js';
15
+
16
+ type Finance = GetKpDailyFinanceResponse;
17
+ type Layers = Finance['layers'];
18
+ type LayerKey = keyof Layers;
19
+ type CuspRow = Layers['cusps']['rows'][number];
20
+ type DashaRow = Layers['dasha']['rows'][number];
21
+ type RulingRow = Layers['rulingPlanets']['rows'][number];
22
+ type WindowRow = Layers['moonWindows']['rows'][number];
23
+ type Verdict = CuspRow['verdict'];
24
+
25
+ /**
26
+ * The five bands the day score lands in, each beside the English source its label is looked up by.
27
+ *
28
+ * @remarks
29
+ * Keyed by the response enum rather than a string built at the call site, so a band added upstream fails to typecheck here instead of rendering its raw wire value.
30
+ */
31
+ const BAND_LABEL: Record<Finance['band'], ChromeString> = {
32
+ strong: 'Strong',
33
+ favourable: 'Favourable',
34
+ mixed: 'Mixed',
35
+ caution: 'Caution',
36
+ unfavourable: 'Unfavourable',
37
+ };
38
+
39
+ /** The one verdict every layer row carries, in the words the catalogue already holds for a planet state. */
40
+ const VERDICT_LABEL: Record<Verdict, ChromeString> = {
41
+ favourable: 'Favourable',
42
+ mixed: 'Mixed',
43
+ unfavourable: 'Unfavourable',
44
+ neutral: 'Neutral',
45
+ };
46
+
47
+ /** The four layers in the order the response publishes them, which is the order the score weighs them. */
48
+ const LAYER_LABEL: Record<LayerKey, ChromeString> = {
49
+ cusps: 'Cusps',
50
+ dasha: 'Dasha',
51
+ rulingPlanets: 'Ruling planets',
52
+ moonWindows: 'Moon windows',
53
+ };
54
+
55
+ /** Which of the two house sets a row belongs to. */
56
+ const GROUP_LABEL: Record<'gain' | 'loss', ChromeString> = {
57
+ gain: 'Gain',
58
+ loss: 'Loss',
59
+ };
60
+
61
+ /** The four Vimshottari levels the dasha layer can run. */
62
+ const LEVEL_LABEL: Record<DashaRow['level'], ChromeString> = {
63
+ mahadasha: 'Mahadasha',
64
+ antardasha: 'Antardasha',
65
+ pratyantardasha: 'Pratyantardasha',
66
+ sookshmaDasha: 'Sookshma',
67
+ };
68
+
69
+ /**
70
+ * KP daily finance. Renders POST /vedic-astrology/kp/daily-finance: one native, one civil day, four sub lord layers weighed into one score for money.
71
+ *
72
+ * @remarks
73
+ * **The band is the answer and every number under it is the evidence.** The score is a weight-sum of four layers, each the mean of the rows printed in its own table, so a reader can redo the arithmetic from the card: the cusp sub lords of the gain and loss houses, the running Vimshottari lords at the reading moment, the ruling planets of that moment, and the sub lord windows the Moon passes through across the day. No meter, bar or percentage badge, for the same reason the Vedic daily card draws none: the scale is a weighed classification and not a share of anything, so a filled gauge would read an ordinary day as a bad one.
74
+ *
75
+ * **Every planet is judged against the two significator sets, and the sets come first.** A row is favourable when its planet signifies a gain house and no loss house, mixed when both, unfavourable when a loss house alone, neutral when neither, so the card prints the gain and loss houses the reading used, the planets that signify each, and the per-house evidence behind those two lists before any layer table, because that is what every verdict below is read against. A loss cusp inverts its verdict score and is marked as a loss house on its row.
76
+ *
77
+ * **Every clock time is the request timezone's wall clock, never the viewer's.** `readingAt` and the Moon windows arrive as naive local datetimes, so the shared formatters pin them and a reader in another zone sees the native's day, not a shifted one. The dasha boundaries are instants and follow the viewer.
78
+ *
79
+ * The card is data end to end and carries no written interpretation, so `hide-readings` leaves it whole.
80
+ */
81
+ @customElement('roxy-kp-finance-card')
82
+ export class RoxyKpFinanceCard extends RoxyDataElement<Finance> {
83
+ static styles = [
84
+ baseStyles,
85
+ frameCaptionStyles,
86
+ css`
87
+ .wrap {
88
+ background: var(--roxy-surface, #fff);
89
+ color: var(--roxy-fg, #0a0a0a);
90
+ border: 1px solid var(--roxy-border, #e4e4e7);
91
+ border-radius: var(--roxy-radius-md, 8px);
92
+ box-shadow: var(--roxy-shadow-sm);
93
+ display: grid;
94
+ grid-template-columns: minmax(0, 1fr);
95
+ overflow: hidden;
96
+ }
97
+ .head {
98
+ padding: var(--roxy-space-md, 1rem);
99
+ display: grid;
100
+ gap: var(--roxy-space-sm, 0.5rem);
101
+ }
102
+ .title-row {
103
+ display: flex;
104
+ align-items: baseline;
105
+ justify-content: space-between;
106
+ gap: var(--roxy-space-sm, 0.5rem);
107
+ flex-wrap: wrap;
108
+ }
109
+ .title {
110
+ margin: 0;
111
+ font-size: var(--roxy-text-lg, 1.125rem);
112
+ font-weight: var(--roxy-weight-bold, 600);
113
+ }
114
+ .when {
115
+ color: var(--roxy-muted, #71717a);
116
+ font-size: var(--roxy-text-xs, 0.75rem);
117
+ }
118
+ /* The band word leads and the number follows it: the band is the
119
+ * reading of the day and the score is the evidence for it. */
120
+ .verdict-row {
121
+ display: flex;
122
+ align-items: center;
123
+ gap: var(--roxy-space-sm, 0.5rem);
124
+ flex-wrap: wrap;
125
+ }
126
+ .verdict {
127
+ font-size: var(--roxy-text-lg, 1.125rem);
128
+ font-weight: var(--roxy-weight-bold, 600);
129
+ padding: 0.15rem 0.6rem;
130
+ border-radius: var(--roxy-radius-full, 9999px);
131
+ background: color-mix(in srgb, var(--roxy-muted, #71717a) 14%, transparent);
132
+ }
133
+ .verdict.strong,
134
+ .verdict.favourable {
135
+ background: color-mix(in srgb, var(--roxy-success, #16a34a) 16%, transparent);
136
+ color: var(--roxy-success-fg, #14532d);
137
+ }
138
+ .verdict.mixed,
139
+ .verdict.caution {
140
+ background: color-mix(in srgb, var(--roxy-accent, #f59e0b) 18%, transparent);
141
+ color: var(--roxy-accent-ink, #b45309);
142
+ }
143
+ .verdict.unfavourable {
144
+ background: color-mix(in srgb, var(--roxy-danger, #dc2626) 14%, transparent);
145
+ color: var(--roxy-danger-fg, #991b1b);
146
+ }
147
+ .evidence {
148
+ color: var(--roxy-secondary, #475569);
149
+ font-size: var(--roxy-text-sm, 0.875rem);
150
+ font-variant-numeric: tabular-nums;
151
+ }
152
+ .block {
153
+ padding: var(--roxy-space-md, 1rem);
154
+ border-top: 1px solid var(--roxy-border, #e4e4e7);
155
+ display: grid;
156
+ gap: var(--roxy-space-sm, 0.5rem);
157
+ }
158
+ .block h3 {
159
+ margin: 0;
160
+ font-size: var(--roxy-text-xs, 0.75rem);
161
+ font-weight: var(--roxy-weight-bold, 600);
162
+ text-transform: uppercase;
163
+ letter-spacing: 0.06em;
164
+ color: var(--roxy-muted, #71717a);
165
+ }
166
+ .block-head {
167
+ display: flex;
168
+ align-items: baseline;
169
+ justify-content: space-between;
170
+ gap: var(--roxy-space-sm, 0.5rem);
171
+ flex-wrap: wrap;
172
+ }
173
+ .facts {
174
+ display: grid;
175
+ grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
176
+ gap: var(--roxy-space-sm, 0.5rem);
177
+ margin: 0;
178
+ }
179
+ .fact {
180
+ display: grid;
181
+ gap: 2px;
182
+ }
183
+ .fact dt {
184
+ color: var(--roxy-muted, #71717a);
185
+ font-size: var(--roxy-text-xs, 0.75rem);
186
+ text-transform: uppercase;
187
+ letter-spacing: 0.05em;
188
+ }
189
+ .fact dd {
190
+ margin: 0;
191
+ font-size: var(--roxy-text-sm, 0.875rem);
192
+ }
193
+ .chips {
194
+ display: flex;
195
+ flex-wrap: wrap;
196
+ gap: 0.35rem;
197
+ }
198
+ .chip {
199
+ font-size: var(--roxy-text-xs, 0.75rem);
200
+ padding: 1px 8px;
201
+ border-radius: var(--roxy-radius-full, 9999px);
202
+ border: 1px solid var(--roxy-border, #e4e4e7);
203
+ color: var(--roxy-secondary, #475569);
204
+ }
205
+ .scroll {
206
+ overflow-x: auto;
207
+ -webkit-overflow-scrolling: touch;
208
+ min-width: 0;
209
+ }
210
+ table {
211
+ width: 100%;
212
+ border-collapse: collapse;
213
+ font-size: var(--roxy-text-sm, 0.875rem);
214
+ }
215
+ th,
216
+ td {
217
+ text-align: left;
218
+ padding: 0.35rem 0.5rem;
219
+ border-bottom: 1px solid var(--roxy-border, #e4e4e7);
220
+ white-space: nowrap;
221
+ }
222
+ th {
223
+ color: var(--roxy-muted, #71717a);
224
+ font-size: var(--roxy-text-xs, 0.75rem);
225
+ text-transform: uppercase;
226
+ letter-spacing: 0.05em;
227
+ font-weight: var(--roxy-weight-bold, 600);
228
+ }
229
+ td.num {
230
+ font-variant-numeric: tabular-nums;
231
+ }
232
+ /* A list of names wraps in place: the table has two columns, so a
233
+ * wrapped cell reads better than a scroll box on a phone. */
234
+ td.names {
235
+ white-space: normal;
236
+ }
237
+ .glyph {
238
+ margin-right: 0.35em;
239
+ color: var(--roxy-muted, #71717a);
240
+ }
241
+ .retro {
242
+ margin-left: 0.3em;
243
+ color: var(--roxy-muted, #71717a);
244
+ font-size: var(--roxy-text-xs, 0.75rem);
245
+ }
246
+ /* One chip per verdict, tinted by what it means, the same three tints
247
+ * the band above uses so a reader learns one scale for the card. */
248
+ .state {
249
+ font-size: var(--roxy-text-xs, 0.75rem);
250
+ padding: 1px 8px;
251
+ border-radius: var(--roxy-radius-full, 9999px);
252
+ background: color-mix(in srgb, var(--roxy-muted, #71717a) 14%, transparent);
253
+ }
254
+ .state.favourable {
255
+ background: color-mix(in srgb, var(--roxy-success, #16a34a) 16%, transparent);
256
+ color: var(--roxy-success-fg, #14532d);
257
+ }
258
+ .state.mixed {
259
+ background: color-mix(in srgb, var(--roxy-accent, #f59e0b) 16%, transparent);
260
+ color: var(--roxy-accent-ink, #b45309);
261
+ }
262
+ .state.unfavourable {
263
+ background: color-mix(in srgb, var(--roxy-danger, #dc2626) 14%, transparent);
264
+ color: var(--roxy-danger-fg, #991b1b);
265
+ }
266
+ .window {
267
+ display: grid;
268
+ gap: 1px;
269
+ padding: 0.3rem 0.6rem;
270
+ border: 1px solid var(--roxy-border, #e4e4e7);
271
+ border-radius: var(--roxy-radius-md, 8px);
272
+ font-size: var(--roxy-text-sm, 0.875rem);
273
+ }
274
+ .window small {
275
+ color: var(--roxy-muted, #71717a);
276
+ font-size: var(--roxy-text-xs, 0.75rem);
277
+ font-variant-numeric: tabular-nums;
278
+ }
279
+ .window.best {
280
+ border-color: color-mix(in srgb, var(--roxy-success, #16a34a) 45%, transparent);
281
+ }
282
+ .window.worst {
283
+ border-color: color-mix(in srgb, var(--roxy-danger, #dc2626) 35%, transparent);
284
+ }
285
+ `,
286
+ ];
287
+
288
+ protected renderData(d: Finance) {
289
+ if (!d.layers) return this.renderEmpty();
290
+ return html`<div class="wrap" part="card" aria-label=${this.t('KP daily finance')}>
291
+ ${this.renderHead(d)}
292
+ ${this.renderSignificators(d)}
293
+ <section class="block" part="section cusps">
294
+ ${this.renderLayer('cusps', d.layers.cusps, this.renderCuspRows(d.layers.cusps.rows))}
295
+ </section>
296
+ <section class="block" part="section dasha">
297
+ ${this.renderLayer('dasha', d.layers.dasha, this.renderDashaRows(d.layers.dasha.rows))}
298
+ </section>
299
+ <section class="block" part="section ruling-planets">
300
+ ${this.renderLayer(
301
+ 'rulingPlanets',
302
+ d.layers.rulingPlanets,
303
+ this.renderRulingRows(d.layers.rulingPlanets.rows),
304
+ )}
305
+ </section>
306
+ <section class="block" part="section moon-windows">
307
+ ${this.renderLayer(
308
+ 'moonWindows',
309
+ d.layers.moonWindows,
310
+ this.renderWindowRows(d.layers.moonWindows.rows),
311
+ )}
312
+ </section>
313
+ ${this.renderWindows(d)}
314
+ <section class="block" part="section frame">
315
+ ${renderFrameCaption(
316
+ this.effectiveLang(),
317
+ { ayanamsa: d.ayanamsa, ayanamsaDegrees: d.ayanamsaDegrees },
318
+ this.translator,
319
+ )}
320
+ </section>
321
+ </div>`;
322
+ }
323
+
324
+ /** The band, the score behind it, the day and the moment it was read at, and the two house sets. */
325
+ private renderHead(d: Finance) {
326
+ const locale = this.effectiveLang();
327
+ return html`<header class="head" part="header">
328
+ <div class="title-row">
329
+ <h2 class="title">${this.t('KP daily finance')}</h2>
330
+ <span class="when">${formatDateTime(locale, d.date)}</span>
331
+ </div>
332
+ <div class="verdict-row">
333
+ <span class="verdict ${d.band}">${this.t(BAND_LABEL[d.band])}</span>
334
+ <span class="evidence">${formatNumber(locale, d.score, 1)}</span>
335
+ </div>
336
+ <dl class="facts" part="details">
337
+ <div class="fact">
338
+ <dt>${this.t('Reading moment')}</dt>
339
+ <dd>${formatDateTime(locale, d.readingAt)}</dd>
340
+ </div>
341
+ <div class="fact">
342
+ <dt>${this.t('Gain houses')}</dt>
343
+ <dd>${formatList(locale, d.houses.gain.map(String))}</dd>
344
+ </div>
345
+ <div class="fact">
346
+ <dt>${this.t('Loss houses')}</dt>
347
+ <dd>${formatList(locale, d.houses.loss.map(String))}</dd>
348
+ </div>
349
+ </dl>
350
+ </header>`;
351
+ }
352
+
353
+ /**
354
+ * The two planet sets every verdict is judged against, and the per-house evidence they were built from.
355
+ *
356
+ * @remarks
357
+ * A house lists its four tier significators strongest tier first, and a planet that qualifies at more than one tier is listed once per tier. It is named once here, at its strongest, because the row answers which planets signify the house and the two sets above are built from exactly that.
358
+ */
359
+ private renderSignificators(d: Finance) {
360
+ const s = d.significators;
361
+ const locale = this.effectiveLang();
362
+ const chips = (planets: readonly string[]) =>
363
+ html`<div class="chips">
364
+ ${planets.map((p) => html`<span class="chip">${this.glyphName(p)}</span>`)}
365
+ </div>`;
366
+ return html`<section class="block" part="section significators">
367
+ <h3>${this.t('Significators')}</h3>
368
+ <dl class="facts">
369
+ <div class="fact">
370
+ <dt>${this.t('Gain')}</dt>
371
+ <dd>${chips(s.gain)}</dd>
372
+ </div>
373
+ <div class="fact">
374
+ <dt>${this.t('Loss')}</dt>
375
+ <dd>${chips(s.loss)}</dd>
376
+ </div>
377
+ </dl>
378
+ ${
379
+ s.byHouse.length
380
+ ? html`<div class="scroll" part="table" tabindex="0">
381
+ <table>
382
+ <thead>
383
+ <tr>
384
+ <th scope="col">${this.t('House')}</th>
385
+ <th scope="col">${this.t('Significators')}</th>
386
+ </tr>
387
+ </thead>
388
+ <tbody>
389
+ ${s.byHouse.map(
390
+ (h) => html`<tr>
391
+ <td class="num">${h.house} ${this.groupChip(h.group)}</td>
392
+ <td class="names">${formatList(locale, [...new Set(h.significators)])}</td>
393
+ </tr>`,
394
+ )}
395
+ </tbody>
396
+ </table>
397
+ </div>`
398
+ : nothing
399
+ }
400
+ </section>`;
401
+ }
402
+
403
+ /** One layer: its name, the weight it carries and the score it contributed, over the rows it was scored from. */
404
+ private renderLayer(
405
+ key: LayerKey,
406
+ layer: Layers[LayerKey],
407
+ rows: TemplateResult,
408
+ ) {
409
+ const locale = this.effectiveLang();
410
+ return html`<div class="block-head">
411
+ <h3>${this.t(LAYER_LABEL[key])}</h3>
412
+ <span class="evidence">
413
+ ${this.t('Weight')} ${formatNumber(locale, layer.weight, 0)}% · ${this.t('Score')}
414
+ ${formatNumber(locale, layer.score, 1)}
415
+ </span>
416
+ </div>
417
+ <div class="scroll" part="table" tabindex="0">${rows}</div>`;
418
+ }
419
+
420
+ private renderCuspRows(rows: readonly CuspRow[]) {
421
+ return html`<table>
422
+ <thead>
423
+ <tr>
424
+ <th scope="col">${this.t('House')}</th>
425
+ <th scope="col">${this.t('Sub lord')}</th>
426
+ <th scope="col">${this.t('Star lord')}</th>
427
+ <th scope="col">${this.t('Sign lord')}</th>
428
+ <th scope="col">${this.t('Verdict')}</th>
429
+ <th scope="col">${this.t('Score')}</th>
430
+ </tr>
431
+ </thead>
432
+ <tbody>
433
+ ${rows.map(
434
+ (r) => html`<tr>
435
+ <td class="num">${r.house} ${this.groupChip(r.inverted ? 'loss' : 'gain')}</td>
436
+ <td>${this.glyphName(r.subLord)}</td>
437
+ <td>${this.glyphName(r.starLord)}</td>
438
+ <td>${this.glyphName(r.signLord)}</td>
439
+ <td>${this.verdictChip(r.verdict)}</td>
440
+ <td class="num">${formatNumber(this.effectiveLang(), r.score, 0)}</td>
441
+ </tr>`,
442
+ )}
443
+ </tbody>
444
+ </table>`;
445
+ }
446
+
447
+ private renderDashaRows(rows: readonly DashaRow[]) {
448
+ const locale = this.effectiveLang();
449
+ return html`<table>
450
+ <thead>
451
+ <tr>
452
+ <th scope="col">${this.t('Level')}</th>
453
+ <th scope="col">${this.t('Lord')}</th>
454
+ <th scope="col">${this.t('From')}</th>
455
+ <th scope="col">${this.t('To')}</th>
456
+ <th scope="col">${this.t('Verdict')}</th>
457
+ <th scope="col">${this.t('Score')}</th>
458
+ <th scope="col">${this.t('Weight')}</th>
459
+ </tr>
460
+ </thead>
461
+ <tbody>
462
+ ${rows.map(
463
+ (r) => html`<tr>
464
+ <td>${this.t(LEVEL_LABEL[r.level])}</td>
465
+ <td>${this.glyphName(r.lord, r.retrograde)}</td>
466
+ <td>${formatDateTime(locale, r.startDate)}</td>
467
+ <td>${formatDateTime(locale, r.endDate)}</td>
468
+ <td>${this.verdictChip(r.verdict)}</td>
469
+ <td class="num">${formatNumber(locale, r.score, 0)}</td>
470
+ <td class="num">${formatNumber(locale, r.weight, 0)}%</td>
471
+ </tr>`,
472
+ )}
473
+ </tbody>
474
+ </table>`;
475
+ }
476
+
477
+ private renderRulingRows(rows: readonly RulingRow[]) {
478
+ return html`<table>
479
+ <thead>
480
+ <tr>
481
+ <th scope="col">${this.t('Planet')}</th>
482
+ <th scope="col">${this.t('Verdict')}</th>
483
+ <th scope="col">${this.t('Score')}</th>
484
+ </tr>
485
+ </thead>
486
+ <tbody>
487
+ ${rows.map(
488
+ (r) => html`<tr>
489
+ <td>${this.glyphName(r.planet, r.retrograde)}</td>
490
+ <td>${this.verdictChip(r.verdict)}</td>
491
+ <td class="num">${formatNumber(this.effectiveLang(), r.score, 0)}</td>
492
+ </tr>`,
493
+ )}
494
+ </tbody>
495
+ </table>`;
496
+ }
497
+
498
+ private renderWindowRows(rows: readonly WindowRow[]) {
499
+ const locale = this.effectiveLang();
500
+ return html`<table>
501
+ <thead>
502
+ <tr>
503
+ <th scope="col">${this.t('From')}</th>
504
+ <th scope="col">${this.t('To')}</th>
505
+ <th scope="col">${this.t('Sub lord')}</th>
506
+ <th scope="col">${this.t('Verdict')}</th>
507
+ <th scope="col">${this.t('Score')}</th>
508
+ </tr>
509
+ </thead>
510
+ <tbody>
511
+ ${rows.map(
512
+ (r) => html`<tr>
513
+ <td>${formatTime(locale, r.from)}</td>
514
+ <td>${formatTime(locale, r.to)}</td>
515
+ <td>${this.glyphName(r.subLord)}</td>
516
+ <td>${this.verdictChip(r.verdict)}</td>
517
+ <td class="num">${formatNumber(locale, r.score, 0)}</td>
518
+ </tr>`,
519
+ )}
520
+ </tbody>
521
+ </table>`;
522
+ }
523
+
524
+ /**
525
+ * The favourable window of the day and every unfavourable one, lifted out of the Moon table so a reader planning the day finds them without reading nine rows.
526
+ *
527
+ * @remarks
528
+ * `bestWindow` is null on a day with no favourable window, which is a fact about the day and not a missing value, so the block prints the worst windows alone rather than an empty slot.
529
+ */
530
+ private renderWindows(d: Finance) {
531
+ const locale = this.effectiveLang();
532
+ const best = d.bestWindow;
533
+ const worst = d.worstWindows ?? [];
534
+ if (!best && !worst.length) return nothing;
535
+ const window = (w: WindowRow, kind: 'best' | 'worst') =>
536
+ html`<span class="window ${kind}">
537
+ <span>${this.glyphName(w.subLord)}</span>
538
+ <small>${formatTime(locale, w.from)} — ${formatTime(locale, w.to)}</small>
539
+ </span>`;
540
+ return html`<section class="block" part="section windows">
541
+ <dl class="facts">
542
+ ${
543
+ best
544
+ ? html`<div class="fact">
545
+ <dt>${this.t('Best window')}</dt>
546
+ <dd><div class="chips">${window(best, 'best')}</div></dd>
547
+ </div>`
548
+ : nothing
549
+ }
550
+ ${
551
+ worst.length
552
+ ? html`<div class="fact">
553
+ <dt>${this.t('Worst windows')}</dt>
554
+ <dd><div class="chips">${worst.map((w) => window(w, 'worst'))}</div></dd>
555
+ </div>`
556
+ : nothing
557
+ }
558
+ </dl>
559
+ </section>`;
560
+ }
561
+
562
+ /** A planet with its glyph in front, and the retrograde mark after it where the row says so. */
563
+ private glyphName(name: string, retrograde = false) {
564
+ const glyph = planetGlyph(name);
565
+ return html`${glyph ? html`<span class="glyph" aria-hidden="true">${glyph}</span>` : nothing}${name}${
566
+ retrograde
567
+ ? html` <span class="retro">${this.t('retrograde')}</span>`
568
+ : nothing
569
+ }`;
570
+ }
571
+
572
+ private verdictChip(verdict: Verdict) {
573
+ return html`<span class="state ${verdict}">${this.t(VERDICT_LABEL[verdict])}</span>`;
574
+ }
575
+
576
+ /** Which of the two sets a house belongs to, beside its number. */
577
+ private groupChip(group: 'gain' | 'loss') {
578
+ return html`<span class="chip">${this.t(GROUP_LABEL[group])}</span>`;
579
+ }
580
+ }
581
+
582
+ declare global {
583
+ interface HTMLElementTagNameMap {
584
+ 'roxy-kp-finance-card': RoxyKpFinanceCard;
585
+ }
586
+ }