@g9tm/lynxcontrols-foundation 0.0.0-stage → 1.4.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 (164) hide show
  1. package/README.md +4 -2
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/collections.d.ts +16 -0
  4. package/dist/collections.d.ts.map +1 -0
  5. package/dist/collections.js +40 -0
  6. package/dist/collections.js.map +1 -0
  7. package/dist/culture/calendar.d.ts +122 -0
  8. package/dist/culture/calendar.d.ts.map +1 -0
  9. package/dist/culture/calendar.js +379 -0
  10. package/dist/culture/calendar.js.map +1 -0
  11. package/dist/culture/culture.d.ts +91 -0
  12. package/dist/culture/culture.d.ts.map +1 -0
  13. package/dist/culture/culture.js +173 -0
  14. package/dist/culture/culture.js.map +1 -0
  15. package/dist/culture/date-format.d.ts +19 -0
  16. package/dist/culture/date-format.d.ts.map +1 -0
  17. package/dist/culture/date-format.js +101 -0
  18. package/dist/culture/date-format.js.map +1 -0
  19. package/dist/culture/digits.d.ts +29 -0
  20. package/dist/culture/digits.d.ts.map +1 -0
  21. package/dist/culture/digits.js +43 -0
  22. package/dist/culture/digits.js.map +1 -0
  23. package/dist/culture/duration.d.ts +38 -0
  24. package/dist/culture/duration.d.ts.map +1 -0
  25. package/dist/culture/duration.js +41 -0
  26. package/dist/culture/duration.js.map +1 -0
  27. package/dist/culture/index.d.ts +9 -0
  28. package/dist/culture/index.d.ts.map +1 -0
  29. package/dist/culture/index.js +8 -0
  30. package/dist/culture/numbers.d.ts +38 -0
  31. package/dist/culture/numbers.d.ts.map +1 -0
  32. package/dist/culture/numbers.js +64 -0
  33. package/dist/culture/numbers.js.map +1 -0
  34. package/dist/culture/relative-time.d.ts +50 -0
  35. package/dist/culture/relative-time.d.ts.map +1 -0
  36. package/dist/culture/relative-time.js +63 -0
  37. package/dist/culture/relative-time.js.map +1 -0
  38. package/dist/culture/strings.d.ts +145 -0
  39. package/dist/culture/strings.d.ts.map +1 -0
  40. package/dist/culture/strings.js +345 -0
  41. package/dist/culture/strings.js.map +1 -0
  42. package/dist/enums/index.d.ts +195 -0
  43. package/dist/enums/index.d.ts.map +1 -0
  44. package/dist/enums/index.js +130 -0
  45. package/dist/enums/index.js.map +1 -0
  46. package/dist/errors.d.ts +10 -0
  47. package/dist/errors.d.ts.map +1 -0
  48. package/dist/errors.js +21 -0
  49. package/dist/errors.js.map +1 -0
  50. package/dist/exec/diagnostics.d.ts +74 -0
  51. package/dist/exec/diagnostics.d.ts.map +1 -0
  52. package/dist/exec/diagnostics.js +73 -0
  53. package/dist/exec/diagnostics.js.map +1 -0
  54. package/dist/exec/index.d.ts +5 -0
  55. package/dist/exec/index.d.ts.map +1 -0
  56. package/dist/exec/index.js +4 -0
  57. package/dist/exec/options.d.ts +75 -0
  58. package/dist/exec/options.d.ts.map +1 -0
  59. package/dist/exec/options.js +107 -0
  60. package/dist/exec/options.js.map +1 -0
  61. package/dist/exec/safe-executor.d.ts +138 -0
  62. package/dist/exec/safe-executor.d.ts.map +1 -0
  63. package/dist/exec/safe-executor.js +401 -0
  64. package/dist/exec/safe-executor.js.map +1 -0
  65. package/dist/exec/trace.d.ts +59 -0
  66. package/dist/exec/trace.d.ts.map +1 -0
  67. package/dist/exec/trace.js +108 -0
  68. package/dist/exec/trace.js.map +1 -0
  69. package/dist/icons/generated/glyph-svg.d.ts +37 -0
  70. package/dist/icons/generated/glyph-svg.d.ts.map +1 -0
  71. package/dist/icons/generated/glyph-svg.js +33 -0
  72. package/dist/icons/generated/glyph-svg.js.map +1 -0
  73. package/dist/icons/glyph-slots.d.ts +79 -0
  74. package/dist/icons/glyph-slots.d.ts.map +1 -0
  75. package/dist/icons/glyph-slots.js +50 -0
  76. package/dist/icons/glyph-slots.js.map +1 -0
  77. package/dist/icons/glyph.d.ts +76 -0
  78. package/dist/icons/glyph.d.ts.map +1 -0
  79. package/dist/icons/glyph.js +42 -0
  80. package/dist/icons/glyph.js.map +1 -0
  81. package/dist/icons/icon-fonts.d.ts +55 -0
  82. package/dist/icons/icon-fonts.d.ts.map +1 -0
  83. package/dist/icons/icon-fonts.js +74 -0
  84. package/dist/icons/icon-fonts.js.map +1 -0
  85. package/dist/icons/icon.d.ts +102 -0
  86. package/dist/icons/icon.d.ts.map +1 -0
  87. package/dist/icons/icon.js +132 -0
  88. package/dist/icons/icon.js.map +1 -0
  89. package/dist/icons/index.d.ts +7 -0
  90. package/dist/icons/index.d.ts.map +1 -0
  91. package/dist/icons/index.js +6 -0
  92. package/dist/icons/svg.d.ts +28 -0
  93. package/dist/icons/svg.d.ts.map +1 -0
  94. package/dist/icons/svg.js +59 -0
  95. package/dist/icons/svg.js.map +1 -0
  96. package/dist/index.d.ts +10 -0
  97. package/dist/index.d.ts.map +1 -0
  98. package/dist/index.js +9 -0
  99. package/dist/services/abort.d.ts +31 -0
  100. package/dist/services/abort.d.ts.map +1 -0
  101. package/dist/services/abort.js +47 -0
  102. package/dist/services/abort.js.map +1 -0
  103. package/dist/services/clock.d.ts +35 -0
  104. package/dist/services/clock.d.ts.map +1 -0
  105. package/dist/services/clock.js +37 -0
  106. package/dist/services/clock.js.map +1 -0
  107. package/dist/services/contracts.d.ts +200 -0
  108. package/dist/services/contracts.d.ts.map +1 -0
  109. package/dist/services/contracts.js +37 -0
  110. package/dist/services/contracts.js.map +1 -0
  111. package/dist/services/index.d.ts +5 -0
  112. package/dist/services/index.d.ts.map +1 -0
  113. package/dist/services/index.js +4 -0
  114. package/dist/services/preferences.d.ts +105 -0
  115. package/dist/services/preferences.d.ts.map +1 -0
  116. package/dist/services/preferences.js +253 -0
  117. package/dist/services/preferences.js.map +1 -0
  118. package/dist/theme/color.d.ts +94 -0
  119. package/dist/theme/color.d.ts.map +1 -0
  120. package/dist/theme/color.js +150 -0
  121. package/dist/theme/color.js.map +1 -0
  122. package/dist/theme/control-colors.d.ts +46 -0
  123. package/dist/theme/control-colors.d.ts.map +1 -0
  124. package/dist/theme/control-colors.js +46 -0
  125. package/dist/theme/control-colors.js.map +1 -0
  126. package/dist/theme/index.d.ts +5 -0
  127. package/dist/theme/index.d.ts.map +1 -0
  128. package/dist/theme/index.js +4 -0
  129. package/dist/theme/theme.d.ts +88 -0
  130. package/dist/theme/theme.d.ts.map +1 -0
  131. package/dist/theme/theme.js +190 -0
  132. package/dist/theme/theme.js.map +1 -0
  133. package/dist/theme/variants.d.ts +33 -0
  134. package/dist/theme/variants.d.ts.map +1 -0
  135. package/dist/theme/variants.js +53 -0
  136. package/dist/theme/variants.js.map +1 -0
  137. package/dist/tokens/css-vars.d.ts +35 -0
  138. package/dist/tokens/css-vars.d.ts.map +1 -0
  139. package/dist/tokens/css-vars.js +49 -0
  140. package/dist/tokens/css-vars.js.map +1 -0
  141. package/dist/tokens/generated/metrics.d.ts +184 -0
  142. package/dist/tokens/generated/metrics.d.ts.map +1 -0
  143. package/dist/tokens/generated/metrics.js +349 -0
  144. package/dist/tokens/generated/metrics.js.map +1 -0
  145. package/dist/tokens/generated/palettes.d.ts +113 -0
  146. package/dist/tokens/generated/palettes.d.ts.map +1 -0
  147. package/dist/tokens/generated/palettes.js +391 -0
  148. package/dist/tokens/generated/palettes.js.map +1 -0
  149. package/dist/tokens/index.d.ts +5 -0
  150. package/dist/tokens/index.d.ts.map +1 -0
  151. package/dist/tokens/index.js +4 -0
  152. package/dist/tokens/layout-metrics.d.ts +120 -0
  153. package/dist/tokens/layout-metrics.d.ts.map +1 -0
  154. package/dist/tokens/layout-metrics.js +111 -0
  155. package/dist/tokens/layout-metrics.js.map +1 -0
  156. package/docs/api.md +368 -0
  157. package/docs/foundation.md +369 -0
  158. package/docs/migration/Core.Controls.Shared.md +475 -0
  159. package/docs/migration/Core.Helpers.md +132 -0
  160. package/docs/migration/Core.Icons.md +135 -0
  161. package/docs/migration/Core.Localization.md +118 -0
  162. package/docs/migration/Core.Storage.md +54 -0
  163. package/docs/migration/Core.Theming.md +328 -0
  164. package/package.json +59 -4
@@ -0,0 +1,379 @@
1
+ import { CalendarDate, GregorianCalendar, PersianCalendar, toCalendar } from "@internationalized/date";
2
+ import { G9Error } from "../errors.js";
3
+ import { languageOf } from "./culture.js";
4
+ const MS_PER_DAY = 86400000;
5
+ function fail(code, message) {
6
+ throw new G9Error(code, message);
7
+ }
8
+ function checkInt(name, value, min, max) {
9
+ if (!Number.isInteger(value) || value < min || value > max) fail('date-invalid', `${name} must be an integer ${min}–${max}, got ${value}.`);
10
+ }
11
+ function isGregorianLeapYear(year) {
12
+ return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
13
+ }
14
+ function daysInGregorianMonth(year, month) {
15
+ checkInt('month', month, 1, 12);
16
+ return 2 === month ? isGregorianLeapYear(year) ? 29 : 28 : [
17
+ 4,
18
+ 6,
19
+ 9,
20
+ 11
21
+ ].includes(month) ? 30 : 31;
22
+ }
23
+ function localDate(year, month, day) {
24
+ checkInt('year', year, 1, 9999);
25
+ checkInt('month', month, 1, 12);
26
+ checkInt('day', day, 1, daysInGregorianMonth(year, month));
27
+ return Object.freeze({
28
+ year,
29
+ month,
30
+ day
31
+ });
32
+ }
33
+ function localTime(hour, minute, second = 0, millisecond = 0) {
34
+ checkInt('hour', hour, 0, 23);
35
+ checkInt('minute', minute, 0, 59);
36
+ checkInt('second', second, 0, 59);
37
+ checkInt('millisecond', millisecond, 0, 999);
38
+ return Object.freeze({
39
+ hour,
40
+ minute,
41
+ second,
42
+ millisecond
43
+ });
44
+ }
45
+ function localDateTime(year, month, day, hour = 0, minute = 0, second = 0, millisecond = 0) {
46
+ return Object.freeze({
47
+ ...localDate(year, month, day),
48
+ ...localTime(hour, minute, second, millisecond)
49
+ });
50
+ }
51
+ function toLocalDate(value) {
52
+ return localDate(value.year, value.month, value.day);
53
+ }
54
+ function combineLocalDateTime(date, time) {
55
+ return localDateTime(date.year, date.month, date.day, time.hour, time.minute, time.second, time.millisecond);
56
+ }
57
+ function hasTime(value) {
58
+ return 'number' == typeof value.hour;
59
+ }
60
+ function epochDaysOf(year, month, day) {
61
+ const y = month <= 2 ? year - 1 : year;
62
+ const era = Math.floor(y / 400);
63
+ const yoe = y - 400 * era;
64
+ const doy = Math.floor((153 * (month + (month > 2 ? -3 : 9)) + 2) / 5) + day - 1;
65
+ const doe = 365 * yoe + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;
66
+ return 146097 * era + doe - 719468;
67
+ }
68
+ function civilOf(epochDays) {
69
+ const z = epochDays + 719468;
70
+ const era = Math.floor(z / 146097);
71
+ const doe = z - 146097 * era;
72
+ const yoe = Math.floor((doe - Math.floor(doe / 1460) + Math.floor(doe / 36524) - Math.floor(doe / 146096)) / 365);
73
+ const doy = doe - (365 * yoe + Math.floor(yoe / 4) - Math.floor(yoe / 100));
74
+ const mp = Math.floor((5 * doy + 2) / 153);
75
+ const day = doy - Math.floor((153 * mp + 2) / 5) + 1;
76
+ const month = mp < 10 ? mp + 3 : mp - 9;
77
+ return {
78
+ year: yoe + 400 * era + (month <= 2 ? 1 : 0),
79
+ month,
80
+ day
81
+ };
82
+ }
83
+ function toEpochDays(date) {
84
+ const d = toLocalDate(date);
85
+ return epochDaysOf(d.year, d.month, d.day);
86
+ }
87
+ function fromEpochDays(epochDays) {
88
+ if (!Number.isInteger(epochDays)) fail('date-invalid', `epochDays must be an integer, got ${epochDays}.`);
89
+ const { year, month, day } = civilOf(epochDays);
90
+ return localDate(year, month, day);
91
+ }
92
+ function addDays(date, days) {
93
+ if (!Number.isInteger(days)) fail('date-invalid', `days must be an integer, got ${days}.`);
94
+ return fromEpochDays(toEpochDays(date) + days);
95
+ }
96
+ function dayOfWeek(date) {
97
+ return ((toEpochDays(date) + 4) % 7 + 7) % 7;
98
+ }
99
+ function timeMs(value) {
100
+ return hasTime(value) ? ((60 * value.hour + value.minute) * 60 + value.second) * 1000 + value.millisecond : 0;
101
+ }
102
+ function compareLocal(a, b) {
103
+ const days = toEpochDays(a) - toEpochDays(b);
104
+ return 0 !== days ? days : timeMs(a) - timeMs(b);
105
+ }
106
+ function checkOffset(utcOffsetMinutes) {
107
+ checkInt('utcOffsetMinutes', utcOffsetMinutes, -1080, 1080);
108
+ }
109
+ function localDateTimeToEpochMs(value, utcOffsetMinutes = 0) {
110
+ checkOffset(utcOffsetMinutes);
111
+ return toEpochDays(value) * MS_PER_DAY + timeMs(localDateTimeOf(value)) - 60000 * utcOffsetMinutes;
112
+ }
113
+ function localDateTimeOf(value) {
114
+ return hasTime(value) ? localDateTime(value.year, value.month, value.day, value.hour, value.minute, value.second, value.millisecond) : localDateTime(value.year, value.month, value.day);
115
+ }
116
+ function localDateTimeFromEpochMs(epochMs, utcOffsetMinutes = 0) {
117
+ checkOffset(utcOffsetMinutes);
118
+ if (!Number.isFinite(epochMs)) fail('date-invalid', `epochMs must be finite, got ${epochMs}.`);
119
+ const ms = Math.floor(epochMs) + 60000 * utcOffsetMinutes;
120
+ const days = Math.floor(ms / MS_PER_DAY);
121
+ let rest = ms - days * MS_PER_DAY;
122
+ const date = fromEpochDays(days);
123
+ const millisecond = rest % 1000;
124
+ rest = (rest - millisecond) / 1000;
125
+ return localDateTime(date.year, date.month, date.day, Math.floor(rest / 3600), Math.floor(rest / 60) % 60, rest % 60, millisecond);
126
+ }
127
+ function localDateTimeFromDate(date) {
128
+ if (Number.isNaN(date.getTime())) fail('date-invalid', 'Invalid Date.');
129
+ return localDateTime(date.getFullYear(), date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
130
+ }
131
+ function localDateTimeToDate(value) {
132
+ const v = localDateTimeOf(value);
133
+ const date = new Date(2000, 0, 1, v.hour, v.minute, v.second, v.millisecond);
134
+ date.setFullYear(v.year, v.month - 1, v.day);
135
+ return date;
136
+ }
137
+ const pad = (value, width)=>String(value).padStart(width, '0');
138
+ function formatIsoDate(value) {
139
+ const d = toLocalDate(value);
140
+ return `${pad(d.year, 4)}-${pad(d.month, 2)}-${pad(d.day, 2)}`;
141
+ }
142
+ function formatIsoDateTime(value) {
143
+ const v = localDateTimeOf(value);
144
+ return `${formatIsoDate(v)}T${pad(v.hour, 2)}:${pad(v.minute, 2)}:${pad(v.second, 2)}.${pad(v.millisecond, 3)}`;
145
+ }
146
+ const ISO = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,7}))?)?)?$/;
147
+ function parseIso(text) {
148
+ var _m_;
149
+ const m = 'string' == typeof text ? ISO.exec(text) : null;
150
+ if (!m) fail('date-invalid', `"${String(text)}" is not an ISO local date or date-time.`);
151
+ const n = (i)=>{
152
+ var _m_i;
153
+ return Number(null != (_m_i = m[i]) ? _m_i : 0);
154
+ };
155
+ const millisecond = Number(`${null != (_m_ = m[7]) ? _m_ : ''}00`.slice(0, 3));
156
+ return localDateTime(n(1), n(2), n(3), n(4), n(5), n(6), millisecond);
157
+ }
158
+ function parseIsoDate(text) {
159
+ if ('string' != typeof text || 10 !== text.length) fail('date-invalid', `"${String(text)}" is not YYYY-MM-DD.`);
160
+ return toLocalDate(parseIso(text));
161
+ }
162
+ function parseIsoDateTime(text) {
163
+ return parseIso(text);
164
+ }
165
+ const persian = new PersianCalendar();
166
+ const gregorian = new GregorianCalendar();
167
+ const persianMinSupportedDateTime = localDateTime(622, 3, 22);
168
+ const persianMaxSupportedDateTime = localDateTime(9999, 12, 31, 23, 59, 59, 999);
169
+ function isSupportedByPersianCalendar(value) {
170
+ return compareLocal(value, persianMinSupportedDateTime) >= 0 && compareLocal(value, persianMaxSupportedDateTime) <= 0;
171
+ }
172
+ function clampToPersianRange(value) {
173
+ if (compareLocal(value, persianMinSupportedDateTime) >= 0) return value;
174
+ return hasTime(value) ? persianMinSupportedDateTime : toLocalDate(persianMinSupportedDateTime);
175
+ }
176
+ function isLeapYear(calendar, year) {
177
+ return 'gregorian' === calendar ? 29 === daysInMonth(calendar, year, 2) : 30 === daysInMonth(calendar, year, 12);
178
+ }
179
+ function checkCalendar(calendar) {
180
+ if ('gregorian' !== calendar && 'persian' !== calendar) fail('culture-invalid-calendar', `"${String(calendar)}" is not a culture calendar.`);
181
+ }
182
+ function daysInMonth(calendar, year, month) {
183
+ checkCalendar(calendar);
184
+ if ('gregorian' === calendar) {
185
+ checkInt('year', year, 1, 9999);
186
+ return daysInGregorianMonth(year, month);
187
+ }
188
+ checkInt('year', year, 1, 9377);
189
+ checkInt('month', month, 1, 12);
190
+ return persian.getDaysInMonth(new CalendarDate(persian, year, month, 1));
191
+ }
192
+ function toCalendarDate(value, calendar) {
193
+ checkCalendar(calendar);
194
+ const d = toLocalDate(value);
195
+ if ('gregorian' === calendar) return Object.freeze({
196
+ calendar,
197
+ year: d.year,
198
+ month: d.month,
199
+ day: d.day
200
+ });
201
+ if (!isSupportedByPersianCalendar(d)) fail('calendar-out-of-range', `${formatIsoDate(d)} is before the Persian calendar's first day.`);
202
+ const source = new CalendarDate(gregorian, d.year, d.month, d.day);
203
+ const p = toCalendar(source, persian);
204
+ if (0 !== toCalendar(p, gregorian).compare(source)) fail('calendar-out-of-range', `${formatIsoDate(d)} is past the last Persian date this port can write (9999-03-20).`);
205
+ return Object.freeze({
206
+ calendar,
207
+ year: p.year,
208
+ month: p.month,
209
+ day: p.day
210
+ });
211
+ }
212
+ function fromCalendarDate(value) {
213
+ const { calendar, year, month, day } = value;
214
+ checkInt('day', day, 1, daysInMonth(calendar, year, month));
215
+ if ('gregorian' === calendar) return localDate(year, month, day);
216
+ const g = toCalendar(new CalendarDate(persian, year, month, day), gregorian);
217
+ const date = localDate(g.year, g.month, g.day);
218
+ const back = toCalendar(new CalendarDate(gregorian, date.year, date.month, date.day), persian);
219
+ if (!isSupportedByPersianCalendar(date) || back.year !== year || back.month !== month || back.day !== day) fail('calendar-out-of-range', `${year}/${month}/${day} AP is outside the supported range.`);
220
+ return date;
221
+ }
222
+ function persianNewYear(year) {
223
+ return fromCalendarDate({
224
+ calendar: 'persian',
225
+ year,
226
+ month: 1,
227
+ day: 1
228
+ });
229
+ }
230
+ const names = (table)=>Object.freeze({
231
+ en: Object.freeze(table.en),
232
+ fa: Object.freeze(table.fa),
233
+ ar: Object.freeze(table.ar)
234
+ });
235
+ const GREGORIAN_MONTHS = names({
236
+ en: [
237
+ 'January',
238
+ 'February',
239
+ 'March',
240
+ 'April',
241
+ 'May',
242
+ 'June',
243
+ 'July',
244
+ 'August',
245
+ 'September',
246
+ 'October',
247
+ 'November',
248
+ 'December'
249
+ ],
250
+ fa: [
251
+ 'ژانویه',
252
+ 'فوریه',
253
+ 'مارس',
254
+ 'آوریل',
255
+ 'مه',
256
+ 'ژوئن',
257
+ 'ژوئیه',
258
+ 'اوت',
259
+ 'سپتامبر',
260
+ 'اکتبر',
261
+ 'نوامبر',
262
+ 'دسامبر'
263
+ ],
264
+ ar: [
265
+ 'يناير',
266
+ 'فبراير',
267
+ 'مارس',
268
+ 'أبريل',
269
+ 'مايو',
270
+ 'يونيو',
271
+ 'يوليو',
272
+ 'أغسطس',
273
+ 'سبتمبر',
274
+ 'أكتوبر',
275
+ 'نوفمبر',
276
+ 'ديسمبر'
277
+ ]
278
+ });
279
+ const PERSIAN_MONTHS = names({
280
+ en: [
281
+ 'Farvardin',
282
+ 'Ordibehesht',
283
+ 'Khordad',
284
+ 'Tir',
285
+ 'Mordad',
286
+ 'Shahrivar',
287
+ 'Mehr',
288
+ 'Aban',
289
+ 'Azar',
290
+ 'Dey',
291
+ 'Bahman',
292
+ 'Esfand'
293
+ ],
294
+ fa: [
295
+ 'فروردین',
296
+ 'اردیبهشت',
297
+ 'خرداد',
298
+ 'تیر',
299
+ 'مرداد',
300
+ 'شهریور',
301
+ 'مهر',
302
+ 'آبان',
303
+ 'آذر',
304
+ 'دی',
305
+ 'بهمن',
306
+ 'اسفند'
307
+ ],
308
+ ar: [
309
+ 'فروردين',
310
+ 'أرديبهشت',
311
+ 'خرداد',
312
+ 'تير',
313
+ 'مرداد',
314
+ 'شهريور',
315
+ 'مهر',
316
+ 'آبان',
317
+ 'آذر',
318
+ 'دي',
319
+ 'بهمن',
320
+ 'إسفند'
321
+ ]
322
+ });
323
+ const WEEKDAYS = names({
324
+ en: [
325
+ 'Sunday',
326
+ 'Monday',
327
+ 'Tuesday',
328
+ 'Wednesday',
329
+ 'Thursday',
330
+ 'Friday',
331
+ 'Saturday'
332
+ ],
333
+ fa: [
334
+ 'یکشنبه',
335
+ 'دوشنبه',
336
+ 'سه‌شنبه',
337
+ 'چهارشنبه',
338
+ 'پنجشنبه',
339
+ 'جمعه',
340
+ 'شنبه'
341
+ ],
342
+ ar: [
343
+ 'الأحد',
344
+ 'الاثنين',
345
+ 'الثلاثاء',
346
+ 'الأربعاء',
347
+ 'الخميس',
348
+ 'الجمعة',
349
+ 'السبت'
350
+ ]
351
+ });
352
+ const ABBREVIATED_MONTHS = Object.freeze(GREGORIAN_MONTHS.en.map((name)=>name.slice(0, 3)));
353
+ const ABBREVIATED_WEEKDAYS = Object.freeze(WEEKDAYS.en.map((name)=>name.slice(0, 3)));
354
+ function nameLanguage(culture) {
355
+ const language = languageOf(culture);
356
+ return 'fa' === language || 'ar' === language ? language : 'en';
357
+ }
358
+ function checkWidth(width) {
359
+ if ('wide' !== width && 'abbreviated' !== width) fail('date-invalid', `"${String(width)}" is not a name width.`);
360
+ }
361
+ function getMonthNames(calendar, culture, width = 'wide') {
362
+ checkCalendar(calendar);
363
+ checkWidth(width);
364
+ const language = nameLanguage(culture);
365
+ const list = ('persian' === calendar ? PERSIAN_MONTHS : GREGORIAN_MONTHS)[language];
366
+ return 'abbreviated' === width && 'gregorian' === calendar && 'en' === language ? ABBREVIATED_MONTHS : list;
367
+ }
368
+ function getMonthName(calendar, month, culture, width = 'wide') {
369
+ checkInt('month', month, 1, 12);
370
+ return getMonthNames(calendar, culture, width)[month - 1];
371
+ }
372
+ function getWeekdayNames(culture, width = 'wide') {
373
+ checkWidth(width);
374
+ const language = nameLanguage(culture);
375
+ return 'abbreviated' === width && 'en' === language ? ABBREVIATED_WEEKDAYS : WEEKDAYS[language];
376
+ }
377
+ export { addDays, clampToPersianRange, combineLocalDateTime, compareLocal, dayOfWeek, daysInGregorianMonth, daysInMonth, formatIsoDate, formatIsoDateTime, fromCalendarDate, fromEpochDays, getMonthName, getMonthNames, getWeekdayNames, isGregorianLeapYear, isLeapYear, isSupportedByPersianCalendar, localDate, localDateTime, localDateTimeFromDate, localDateTimeFromEpochMs, localDateTimeToDate, localDateTimeToEpochMs, localTime, parseIsoDate, parseIsoDateTime, persianMaxSupportedDateTime, persianMinSupportedDateTime, persianNewYear, toCalendarDate, toEpochDays, toLocalDate };
378
+
379
+ //# sourceMappingURL=calendar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"culture/calendar.js","sources":["../../src/culture/calendar.ts"],"sourcesContent":["// Calendar values without Intl. Only the Intl-free subset of @internationalized/date is used (plan/probes E10):\n// CalendarDate, the two calendar classes and toCalendar. It stays an implementation detail; the public types are\n// plain frozen objects.\nimport { CalendarDate, GregorianCalendar, PersianCalendar, toCalendar } from '@internationalized/date';\nimport { G9Error } from '../errors';\nimport { type G9CalendarSystem, type G9Culture, languageOf } from './culture';\n\n/** A calendar day without time or zone (MAUI `DateTime.Date`), proleptic Gregorian, years 1–9999 like .NET. */\nexport interface G9LocalDate {\n readonly year: number;\n /** 1–12. */\n readonly month: number;\n /** 1–31. */\n readonly day: number;\n}\n\n/** A wall-clock time without date or zone (MAUI `TimeSpan` time of day / `TimeOnly`). */\nexport interface G9LocalTime {\n /** 0–23. */\n readonly hour: number;\n /** 0–59. */\n readonly minute: number;\n /** 0–59. */\n readonly second: number;\n /** 0–999. Precision is the millisecond; .NET ticks (100 ns) are truncated. */\n readonly millisecond: number;\n}\n\n/** A calendar day and wall-clock time without zone (MAUI `DateTime` used as a calendar value). */\nexport interface G9LocalDateTime extends G9LocalDate, G9LocalTime {}\n\n/** A date written in a given calendar (`{ calendar: 'persian', year: 1403, month: 1, day: 1 }`). */\nexport interface G9CalendarDate {\n readonly calendar: G9CalendarSystem;\n readonly year: number;\n readonly month: number;\n readonly day: number;\n}\n\nconst MS_PER_DAY = 86_400_000;\n\nfunction fail(code: string, message: string): never {\n throw new G9Error(code, message);\n}\n\nfunction checkInt(name: string, value: number, min: number, max: number): void {\n if (!Number.isInteger(value) || value < min || value > max) {\n fail('date-invalid', `${name} must be an integer ${min}–${max}, got ${value}.`);\n }\n}\n\n/** `true` for a Gregorian leap year. */\nexport function isGregorianLeapYear(year: number): boolean {\n return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;\n}\n\n/** Days in a Gregorian month. */\nexport function daysInGregorianMonth(year: number, month: number): number {\n checkInt('month', month, 1, 12);\n return month === 2 ? (isGregorianLeapYear(year) ? 29 : 28) : [4, 6, 9, 11].includes(month) ? 30 : 31;\n}\n\n/**\n * A validated, frozen {@link G9LocalDate}.\n * @throws {G9Error} `date-invalid` for a day that does not exist or a year outside 1–9999.\n */\nexport function localDate(year: number, month: number, day: number): G9LocalDate {\n checkInt('year', year, 1, 9999);\n checkInt('month', month, 1, 12);\n checkInt('day', day, 1, daysInGregorianMonth(year, month));\n return Object.freeze({ year, month, day });\n}\n\n/** A validated, frozen {@link G9LocalTime}. @throws {G9Error} `date-invalid`. */\nexport function localTime(hour: number, minute: number, second = 0, millisecond = 0): G9LocalTime {\n checkInt('hour', hour, 0, 23);\n checkInt('minute', minute, 0, 59);\n checkInt('second', second, 0, 59);\n checkInt('millisecond', millisecond, 0, 999);\n return Object.freeze({ hour, minute, second, millisecond });\n}\n\n/** A validated, frozen {@link G9LocalDateTime}; the time defaults to midnight. @throws {G9Error} `date-invalid`. */\nexport function localDateTime(\n year: number,\n month: number,\n day: number,\n hour = 0,\n minute = 0,\n second = 0,\n millisecond = 0,\n): G9LocalDateTime {\n return Object.freeze({ ...localDate(year, month, day), ...localTime(hour, minute, second, millisecond) });\n}\n\n/** The date part of a date-time (or the date itself). */\nexport function toLocalDate(value: G9LocalDate): G9LocalDate {\n return localDate(value.year, value.month, value.day);\n}\n\n/** Joins a date and a time. */\nexport function combineLocalDateTime(date: G9LocalDate, time: G9LocalTime): G9LocalDateTime {\n return localDateTime(date.year, date.month, date.day, time.hour, time.minute, time.second, time.millisecond);\n}\n\nfunction hasTime(value: G9LocalDate): value is G9LocalDateTime {\n return typeof (value as Partial<G9LocalDateTime>).hour === 'number';\n}\n\n// Howard Hinnant's days_from_civil / civil_from_days: exact integer arithmetic for the proleptic Gregorian calendar.\nfunction epochDaysOf(year: number, month: number, day: number): number {\n const y = month <= 2 ? year - 1 : year;\n const era = Math.floor(y / 400);\n const yoe = y - era * 400;\n const doy = Math.floor((153 * (month + (month > 2 ? -3 : 9)) + 2) / 5) + day - 1;\n const doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;\n return era * 146097 + doe - 719468;\n}\n\nfunction civilOf(epochDays: number): { year: number; month: number; day: number } {\n const z = epochDays + 719468;\n const era = Math.floor(z / 146097);\n const doe = z - era * 146097;\n const yoe = Math.floor((doe - Math.floor(doe / 1460) + Math.floor(doe / 36524) - Math.floor(doe / 146096)) / 365);\n const doy = doe - (365 * yoe + Math.floor(yoe / 4) - Math.floor(yoe / 100));\n const mp = Math.floor((5 * doy + 2) / 153);\n const day = doy - Math.floor((153 * mp + 2) / 5) + 1;\n const month = mp < 10 ? mp + 3 : mp - 9;\n return { year: yoe + era * 400 + (month <= 2 ? 1 : 0), month, day };\n}\n\n/** Days since 1970-01-01 (negative before). */\nexport function toEpochDays(date: G9LocalDate): number {\n const d = toLocalDate(date);\n return epochDaysOf(d.year, d.month, d.day);\n}\n\n/** The date `epochDays` after 1970-01-01. @throws {G9Error} `date-invalid` outside years 1–9999. */\nexport function fromEpochDays(epochDays: number): G9LocalDate {\n if (!Number.isInteger(epochDays)) fail('date-invalid', `epochDays must be an integer, got ${epochDays}.`);\n const { year, month, day } = civilOf(epochDays);\n return localDate(year, month, day);\n}\n\n/** The date `days` later (earlier when negative). */\nexport function addDays(date: G9LocalDate, days: number): G9LocalDate {\n if (!Number.isInteger(days)) fail('date-invalid', `days must be an integer, got ${days}.`);\n return fromEpochDays(toEpochDays(date) + days);\n}\n\n/** Day of the week, 0 = Sunday … 6 = Saturday (.NET `DayOfWeek` numbering). */\nexport function dayOfWeek(date: G9LocalDate): number {\n return (((toEpochDays(date) + 4) % 7) + 7) % 7;\n}\n\nfunction timeMs(value: G9LocalDate): number {\n return hasTime(value) ? ((value.hour * 60 + value.minute) * 60 + value.second) * 1000 + value.millisecond : 0;\n}\n\n/** Orders dates or date-times (a date compares as its midnight): negative, 0 or positive. */\nexport function compareLocal(a: G9LocalDate, b: G9LocalDate): number {\n const days = toEpochDays(a) - toEpochDays(b);\n return days !== 0 ? days : timeMs(a) - timeMs(b);\n}\n\nfunction checkOffset(utcOffsetMinutes: number): void {\n checkInt('utcOffsetMinutes', utcOffsetMinutes, -18 * 60, 18 * 60);\n}\n\n/**\n * The instant (epoch ms) of a wall-clock date-time at a fixed UTC offset (`210` for Tehran +03:30). Lynx has no\n * time-zone database (no Intl): the host supplies the offset, e.g. from its clock service.\n */\nexport function localDateTimeToEpochMs(value: G9LocalDateTime, utcOffsetMinutes = 0): number {\n checkOffset(utcOffsetMinutes);\n return toEpochDays(value) * MS_PER_DAY + timeMs(localDateTimeOf(value)) - utcOffsetMinutes * 60_000;\n}\n\nfunction localDateTimeOf(value: G9LocalDate): G9LocalDateTime {\n return hasTime(value)\n ? localDateTime(value.year, value.month, value.day, value.hour, value.minute, value.second, value.millisecond)\n : localDateTime(value.year, value.month, value.day);\n}\n\n/** The wall-clock date-time of an instant at a fixed UTC offset. @throws {G9Error} `date-invalid`. */\nexport function localDateTimeFromEpochMs(epochMs: number, utcOffsetMinutes = 0): G9LocalDateTime {\n checkOffset(utcOffsetMinutes);\n if (!Number.isFinite(epochMs)) fail('date-invalid', `epochMs must be finite, got ${epochMs}.`);\n const ms = Math.floor(epochMs) + utcOffsetMinutes * 60_000;\n const days = Math.floor(ms / MS_PER_DAY);\n let rest = ms - days * MS_PER_DAY;\n const date = fromEpochDays(days);\n const millisecond = rest % 1000;\n rest = (rest - millisecond) / 1000;\n return localDateTime(\n date.year,\n date.month,\n date.day,\n Math.floor(rest / 3600),\n Math.floor(rest / 60) % 60,\n rest % 60,\n millisecond,\n );\n}\n\n/** The wall-clock fields of a `Date` in the device's zone (Date's own getters; no Intl needed). */\nexport function localDateTimeFromDate(date: Date): G9LocalDateTime {\n if (Number.isNaN(date.getTime())) fail('date-invalid', 'Invalid Date.');\n return localDateTime(\n date.getFullYear(),\n date.getMonth() + 1,\n date.getDate(),\n date.getHours(),\n date.getMinutes(),\n date.getSeconds(),\n date.getMilliseconds(),\n );\n}\n\n/** A `Date` at this wall-clock time in the device's zone. */\nexport function localDateTimeToDate(value: G9LocalDate): Date {\n const v = localDateTimeOf(value);\n const date = new Date(2000, 0, 1, v.hour, v.minute, v.second, v.millisecond);\n date.setFullYear(v.year, v.month - 1, v.day); // years 1–99 would otherwise mean 1901–1999\n return date;\n}\n\nconst pad = (value: number, width: number) => String(value).padStart(width, '0');\n\n/** `YYYY-MM-DD`. */\nexport function formatIsoDate(value: G9LocalDate): string {\n const d = toLocalDate(value);\n return `${pad(d.year, 4)}-${pad(d.month, 2)}-${pad(d.day, 2)}`;\n}\n\n/** `YYYY-MM-DDTHH:mm:ss.sss` (no zone). */\nexport function formatIsoDateTime(value: G9LocalDate): string {\n const v = localDateTimeOf(value);\n return `${formatIsoDate(v)}T${pad(v.hour, 2)}:${pad(v.minute, 2)}:${pad(v.second, 2)}.${pad(v.millisecond, 3)}`;\n}\n\nconst ISO = /^(\\d{4})-(\\d{2})-(\\d{2})(?:T(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{1,7}))?)?)?$/;\n\nfunction parseIso(text: string): G9LocalDateTime {\n const m = typeof text === 'string' ? ISO.exec(text) : null;\n if (!m) fail('date-invalid', `\"${String(text)}\" is not an ISO local date or date-time.`);\n const n = (i: number) => Number(m[i] ?? 0);\n // Fractions finer than a millisecond (.NET \"O\" has 7 digits) are truncated, never rounded into the next second.\n const millisecond = Number(`${m[7] ?? ''}00`.slice(0, 3));\n return localDateTime(n(1), n(2), n(3), n(4), n(5), n(6), millisecond);\n}\n\n/** Reads `YYYY-MM-DD`. @throws {G9Error} `date-invalid`. */\nexport function parseIsoDate(text: string): G9LocalDate {\n if (typeof text !== 'string' || text.length !== 10) fail('date-invalid', `\"${String(text)}\" is not YYYY-MM-DD.`);\n return toLocalDate(parseIso(text));\n}\n\n/**\n * Reads `YYYY-MM-DD[THH:mm[:ss[.fffffff]]]` (no zone; .NET round-trip strings included, sub-millisecond digits\n * truncated). @throws {G9Error} `date-invalid`.\n */\nexport function parseIsoDateTime(text: string): G9LocalDateTime {\n return parseIso(text);\n}\n\n// ---------------------------------------------------------------------------------------------------------------\n// Persian (Jalali) and Gregorian calendar views.\n\nconst persian = new PersianCalendar();\nconst gregorian = new GregorianCalendar();\n\n/** First day the Persian calendar represents (MAUI `G9Calendar.PersianMinSupportedDateTime`, .NET 0622-03-22). */\nexport const persianMinSupportedDateTime: G9LocalDateTime = localDateTime(622, 3, 22);\n/** Last instant the Persian calendar represents (MAUI `PersianMaxSupportedDateTime`; .NET's last tick → last ms). */\nexport const persianMaxSupportedDateTime: G9LocalDateTime = localDateTime(9999, 12, 31, 23, 59, 59, 999);\n\n/** `true` when the value is inside the Persian calendar's range (MAUI `G9Calendar.IsSupportedByPersianCalendar`). */\nexport function isSupportedByPersianCalendar(value: G9LocalDate): boolean {\n return compareLocal(value, persianMinSupportedDateTime) >= 0 && compareLocal(value, persianMaxSupportedDateTime) <= 0;\n}\n\n/**\n * The value pulled into the Persian calendar's range (MAUI `G9Calendar.ClampToPersianRange`); a value already inside\n * is returned unchanged. A date stays a date and a date-time stays a date-time.\n */\nexport function clampToPersianRange<T extends G9LocalDate>(value: T): T {\n // Only the lower bound can bite: the upper bound is the last millisecond a G9LocalDateTime can hold.\n if (compareLocal(value, persianMinSupportedDateTime) >= 0) return value;\n return (hasTime(value) ? persianMinSupportedDateTime : toLocalDate(persianMinSupportedDateTime)) as T;\n}\n\n/** `true` for a leap year of the calendar (Persian: Esfand has 30 days). */\nexport function isLeapYear(calendar: G9CalendarSystem, year: number): boolean {\n return calendar === 'gregorian' ? daysInMonth(calendar, year, 2) === 29 : daysInMonth(calendar, year, 12) === 30;\n}\n\nfunction checkCalendar(calendar: G9CalendarSystem): void {\n if (calendar !== 'gregorian' && calendar !== 'persian') {\n fail('culture-invalid-calendar', `\"${String(calendar)}\" is not a culture calendar.`);\n }\n}\n\n/** Days in a month of the calendar. */\nexport function daysInMonth(calendar: G9CalendarSystem, year: number, month: number): number {\n checkCalendar(calendar);\n if (calendar === 'gregorian') {\n checkInt('year', year, 1, 9999);\n return daysInGregorianMonth(year, month);\n }\n checkInt('year', year, 1, 9377);\n checkInt('month', month, 1, 12);\n return persian.getDaysInMonth(new CalendarDate(persian, year, month, 1));\n}\n\n/**\n * The date written in `calendar`. Persian dates match .NET `PersianCalendar` exactly for 1200–1501 AP (golden\n * `calendar.json`); outside that span they follow @internationalized/date, which differs from .NET in some years (see\n * the Core.Controls.Shared migration table).\n * @throws {G9Error} `calendar-out-of-range` for a Persian view of a date before 0622-03-22 or after 9999-03-20\n * (9377/12/30 AP; .NET reaches 9378/10/10 AP on 9999-12-31).\n */\nexport function toCalendarDate(value: G9LocalDate, calendar: G9CalendarSystem): G9CalendarDate {\n checkCalendar(calendar);\n const d = toLocalDate(value);\n if (calendar === 'gregorian') return Object.freeze({ calendar, year: d.year, month: d.month, day: d.day });\n if (!isSupportedByPersianCalendar(d)) {\n fail('calendar-out-of-range', `${formatIsoDate(d)} is before the Persian calendar's first day.`);\n }\n const source = new CalendarDate(gregorian, d.year, d.month, d.day);\n const p = toCalendar(source, persian);\n // The library's Persian years end at 9377 AP: from 9999-03-21 (Nowruz 9378) it wraps to a wrong date instead of\n // failing. A round trip exposes that.\n if (toCalendar(p, gregorian).compare(source) !== 0) {\n fail(\n 'calendar-out-of-range',\n `${formatIsoDate(d)} is past the last Persian date this port can write (9999-03-20).`,\n );\n }\n return Object.freeze({ calendar, year: p.year, month: p.month, day: p.day });\n}\n\n/**\n * The Gregorian day of a date written in a calendar (`{ calendar: 'persian', year: 1403, month: 1, day: 1 }` →\n * 2024-03-20). @throws {G9Error} `date-invalid` for a day the calendar does not have, `calendar-out-of-range` outside\n * the supported range.\n */\nexport function fromCalendarDate(value: G9CalendarDate): G9LocalDate {\n const { calendar, year, month, day } = value;\n checkInt('day', day, 1, daysInMonth(calendar, year, month));\n if (calendar === 'gregorian') return localDate(year, month, day);\n const g = toCalendar(new CalendarDate(persian, year, month, day), gregorian);\n const date = localDate(g.year, g.month, g.day);\n // The library constrains dates past 9999-12-31 to that day instead of failing: a round trip exposes it.\n const back = toCalendar(new CalendarDate(gregorian, date.year, date.month, date.day), persian);\n if (!isSupportedByPersianCalendar(date) || back.year !== year || back.month !== month || back.day !== day) {\n fail('calendar-out-of-range', `${year}/${month}/${day} AP is outside the supported range.`);\n }\n return date;\n}\n\n/** First day (Nowruz, 1 Farvardin) of a Persian year, as a Gregorian date. */\nexport function persianNewYear(year: number): G9LocalDate {\n return fromCalendarDate({ calendar: 'persian', year, month: 1, day: 1 });\n}\n\n// ---------------------------------------------------------------------------------------------------------------\n// Month and weekday names (fa / ar / en tables; other languages use English). No Intl.\n\n/** `'wide'` (`January`) or `'abbreviated'` (`Jan`). Persian and Arabic names have no shorter form. */\nexport type G9NameWidth = 'wide' | 'abbreviated';\n\ntype NameTable = Readonly<Record<'en' | 'fa' | 'ar', readonly string[]>>;\n\nconst names = (table: Record<'en' | 'fa' | 'ar', string[]>): NameTable =>\n Object.freeze({ en: Object.freeze(table.en), fa: Object.freeze(table.fa), ar: Object.freeze(table.ar) });\n\nconst GREGORIAN_MONTHS = names({\n en: [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n ],\n fa: ['ژانویه', 'فوریه', 'مارس', 'آوریل', 'مه', 'ژوئن', 'ژوئیه', 'اوت', 'سپتامبر', 'اکتبر', 'نوامبر', 'دسامبر'],\n ar: ['يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'],\n});\n\nconst PERSIAN_MONTHS = names({\n en: [\n 'Farvardin',\n 'Ordibehesht',\n 'Khordad',\n 'Tir',\n 'Mordad',\n 'Shahrivar',\n 'Mehr',\n 'Aban',\n 'Azar',\n 'Dey',\n 'Bahman',\n 'Esfand',\n ],\n fa: ['فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند'],\n ar: ['فروردين', 'أرديبهشت', 'خرداد', 'تير', 'مرداد', 'شهريور', 'مهر', 'آبان', 'آذر', 'دي', 'بهمن', 'إسفند'],\n});\n\nconst WEEKDAYS = names({\n en: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],\n fa: ['یکشنبه', 'دوشنبه', 'سه‌شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه'],\n ar: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],\n});\n\nconst ABBREVIATED_MONTHS = Object.freeze(GREGORIAN_MONTHS.en.map((name) => name.slice(0, 3)));\nconst ABBREVIATED_WEEKDAYS = Object.freeze(WEEKDAYS.en.map((name) => name.slice(0, 3)));\n\nfunction nameLanguage(culture: G9Culture | string): 'en' | 'fa' | 'ar' {\n const language = languageOf(culture);\n return language === 'fa' || language === 'ar' ? language : 'en';\n}\n\nfunction checkWidth(width: G9NameWidth): void {\n if (width !== 'wide' && width !== 'abbreviated') fail('date-invalid', `\"${String(width)}\" is not a name width.`);\n}\n\n/**\n * The 12 month names of a calendar in the culture's language (`fa`, `ar`, otherwise English): Persian months are\n * Farvardin…Esfand, Gregorian months January…December. English Gregorian names abbreviate to three letters.\n */\nexport function getMonthNames(\n calendar: G9CalendarSystem,\n culture: G9Culture | string,\n width: G9NameWidth = 'wide',\n): readonly string[] {\n checkCalendar(calendar);\n checkWidth(width);\n const language = nameLanguage(culture);\n const list = (calendar === 'persian' ? PERSIAN_MONTHS : GREGORIAN_MONTHS)[language];\n return width === 'abbreviated' && calendar === 'gregorian' && language === 'en' ? ABBREVIATED_MONTHS : list;\n}\n\n/** One month name (`month` 1–12). */\nexport function getMonthName(\n calendar: G9CalendarSystem,\n month: number,\n culture: G9Culture | string,\n width: G9NameWidth = 'wide',\n): string {\n checkInt('month', month, 1, 12);\n return getMonthNames(calendar, culture, width)[month - 1] as string;\n}\n\n/** The 7 weekday names, index 0 = Sunday (matching {@link dayOfWeek}). English abbreviates to three letters. */\nexport function getWeekdayNames(culture: G9Culture | string, width: G9NameWidth = 'wide'): readonly string[] {\n checkWidth(width);\n const language = nameLanguage(culture);\n return width === 'abbreviated' && language === 'en' ? ABBREVIATED_WEEKDAYS : WEEKDAYS[language];\n}\n"],"names":["MS_PER_DAY","fail","code","message","G9Error","checkInt","name","value","min","max","Number","isGregorianLeapYear","year","daysInGregorianMonth","month","localDate","day","Object","localTime","hour","minute","second","millisecond","localDateTime","toLocalDate","combineLocalDateTime","date","time","hasTime","epochDaysOf","y","era","Math","yoe","doy","doe","civilOf","epochDays","z","mp","toEpochDays","d","fromEpochDays","addDays","days","dayOfWeek","timeMs","compareLocal","a","b","checkOffset","utcOffsetMinutes","localDateTimeToEpochMs","localDateTimeOf","localDateTimeFromEpochMs","epochMs","ms","rest","localDateTimeFromDate","localDateTimeToDate","v","Date","pad","width","String","formatIsoDate","formatIsoDateTime","ISO","parseIso","text","_m_","m","n","i","_m_i","parseIsoDate","parseIsoDateTime","persian","PersianCalendar","gregorian","GregorianCalendar","persianMinSupportedDateTime","persianMaxSupportedDateTime","isSupportedByPersianCalendar","clampToPersianRange","isLeapYear","calendar","daysInMonth","checkCalendar","CalendarDate","toCalendarDate","source","p","toCalendar","fromCalendarDate","g","back","persianNewYear","names","table","GREGORIAN_MONTHS","PERSIAN_MONTHS","WEEKDAYS","ABBREVIATED_MONTHS","ABBREVIATED_WEEKDAYS","nameLanguage","culture","language","languageOf","checkWidth","getMonthNames","list","getMonthName","getWeekdayNames"],"mappings":";;;AAuCA,MAAMA,aAAa;AAEnB,SAASC,KAAKC,IAAY,EAAEC,OAAe;IACzC,MAAM,IAAIC,QAAQF,MAAMC;AAC1B;AAEA,SAASE,SAASC,IAAY,EAAEC,KAAa,EAAEC,GAAW,EAAEC,GAAW;IACrE,IAAI,CAACC,OAAO,SAAS,CAACH,UAAUA,QAAQC,OAAOD,QAAQE,KACrDR,KAAK,gBAAgB,GAAGK,KAAK,oBAAoB,EAAEE,IAAI,CAAC,EAAEC,IAAI,MAAM,EAAEF,MAAM,CAAC,CAAC;AAElF;AAGO,SAASI,oBAAoBC,IAAY;IAC9C,OAAQA,OAAO,MAAM,KAAKA,OAAO,QAAQ,KAAMA,OAAO,QAAQ;AAChE;AAGO,SAASC,qBAAqBD,IAAY,EAAEE,KAAa;IAC9DT,SAAS,SAASS,OAAO,GAAG;IAC5B,OAAOA,AAAU,MAAVA,QAAeH,oBAAoBC,QAAQ,KAAK,KAAM;QAAC;QAAG;QAAG;QAAG;KAAG,CAAC,QAAQ,CAACE,SAAS,KAAK;AACpG;AAMO,SAASC,UAAUH,IAAY,EAAEE,KAAa,EAAEE,GAAW;IAChEX,SAAS,QAAQO,MAAM,GAAG;IAC1BP,SAAS,SAASS,OAAO,GAAG;IAC5BT,SAAS,OAAOW,KAAK,GAAGH,qBAAqBD,MAAME;IACnD,OAAOG,OAAO,MAAM,CAAC;QAAEL;QAAME;QAAOE;IAAI;AAC1C;AAGO,SAASE,UAAUC,IAAY,EAAEC,MAAc,EAAEC,SAAS,CAAC,EAAEC,cAAc,CAAC;IACjFjB,SAAS,QAAQc,MAAM,GAAG;IAC1Bd,SAAS,UAAUe,QAAQ,GAAG;IAC9Bf,SAAS,UAAUgB,QAAQ,GAAG;IAC9BhB,SAAS,eAAeiB,a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C,AAAa,SAAbA,YAAqBA,AAAa,SAAbA,WAAoBA,WAAW;AAC7D;AAEA,SAASE,WAAW9C,KAAkB;IACpC,IAAIA,AAAU,WAAVA,SAAoBA,AAAU,kBAAVA,OAAyB9D,KAAK,gBAAgB,CAAC,CAAC,EAAE+D,OAAOD,OAAO,sBAAsB,CAAC;AACjH;AAMO,SAAS+C,cACdxB,QAA0B,EAC1BoB,OAA2B,EAC3B3C,QAAqB,MAAM;IAE3ByB,cAAcF;IACduB,WAAW9C;IACX,MAAM4C,WAAWF,aAAaC;IAC9B,MAAMK,OAAQzB,AAAAA,CAAAA,AAAa,cAAbA,WAAyBe,iBAAiBD,gBAAe,CAAE,CAACO,SAAS;IACnF,OAAO5C,AAAU,kBAAVA,SAA2BuB,AAAa,gBAAbA,YAA4BqB,AAAa,SAAbA,WAAoBJ,qBAAqBQ;AACzG;AAGO,SAASC,aACd1B,QAA0B,EAC1BxE,KAAa,EACb4F,OAA2B,EAC3B3C,QAAqB,MAAM;IAE3B1D,SAAS,SAASS,OAAO,GAAG;IAC5B,OAAOgG,cAAcxB,UAAUoB,SAAS3C,MAAM,CAACjD,QAAQ,EAAE;AAC3D;AAGO,SAASmG,gBAAgBP,OAA2B,EAAE3C,QAAqB,MAAM;IACtF8C,WAAW9C;IACX,MAAM4C,WAAWF,aAAaC;IAC9B,OAAO3C,AAAU,kBAAVA,SAA2B4C,AAAa,SAAbA,WAAoBH,uBAAuBF,QAAQ,CAACK,SAAS;AACjG"}
@@ -0,0 +1,91 @@
1
+ import { type G9NumberingSystem } from './digits.js';
2
+ /** Reading direction (MAUI `G9Culture.IsRtl`). */
3
+ export declare const G9Direction: {
4
+ readonly Ltr: "ltr";
5
+ readonly Rtl: "rtl";
6
+ };
7
+ export type G9Direction = (typeof G9Direction)[keyof typeof G9Direction];
8
+ /** Calendar dates are shown in. Only Persian (Jalali) and Gregorian are supported, as in MAUI. */
9
+ export declare const G9CalendarSystem: {
10
+ readonly Gregorian: "gregorian";
11
+ readonly Persian: "persian";
12
+ };
13
+ export type G9CalendarSystem = (typeof G9CalendarSystem)[keyof typeof G9CalendarSystem];
14
+ /**
15
+ * An immutable culture value: what MAUI read from `CultureInfo` plus the `G9Culture` facade, as independent settings
16
+ * (plan/specs/01-Architecture.md §7). Create with {@link createCulture}; frozen.
17
+ */
18
+ export interface G9Culture {
19
+ /** BCP 47 tag as given (`'fa-IR'`, `'en-US'`); `''` is the invariant culture. */
20
+ readonly locale: string;
21
+ /** Lower-case language subtag (`'fa'`); `''` for the invariant culture. */
22
+ readonly language: string;
23
+ readonly direction: G9Direction;
24
+ readonly calendar: G9CalendarSystem;
25
+ readonly numberingSystem: G9NumberingSystem;
26
+ /** Font family for right-to-left text (MAUI `G9Culture.RtlFontFamily`); `undefined` lets the platform choose. */
27
+ readonly rtlFontFamily?: string;
28
+ /** Font family for left-to-right text (MAUI `G9Culture.LtrFontFamily`); `undefined` lets the platform choose. */
29
+ readonly ltrFontFamily?: string;
30
+ }
31
+ /** Settings that override what the locale implies. `undefined` keeps the locale default. */
32
+ export interface G9CultureOptions {
33
+ readonly direction?: G9Direction | undefined;
34
+ readonly calendar?: G9CalendarSystem | undefined;
35
+ readonly numberingSystem?: G9NumberingSystem | undefined;
36
+ /** `null` clears the family (platform default). */
37
+ readonly rtlFontFamily?: string | null | undefined;
38
+ /** `null` clears the family (platform default). */
39
+ readonly ltrFontFamily?: string | null | undefined;
40
+ }
41
+ /**
42
+ * Builds a culture value. Defaults follow the language, never the direction alone: `fa*` → Persian calendar, Persian
43
+ * digits, RTL; `ar*` → Gregorian, Arabic-Indic digits, RTL; other RTL languages (he, ur, …) and scripts (`-Arab`) →
44
+ * RTL with Gregorian and Latin digits; everything else LTR, Gregorian, Latin. `options` override any of these.
45
+ * @throws {G9Error} `culture-invalid-locale` / `-direction` / `-calendar` / `-numbering-system` / `-font`.
46
+ */
47
+ export declare function createCulture(locale: string, options?: G9CultureOptions): G9Culture;
48
+ /** The same culture with some settings replaced (`undefined` in `options` keeps the current value). */
49
+ export declare function withCultureOptions(culture: G9Culture, options: G9CultureOptions): G9Culture;
50
+ /** Lower-case language subtag of a culture or locale tag; `''` for `null`, `undefined` and the invariant culture. */
51
+ export declare function languageOf(culture: G9Culture | string | null | undefined): string;
52
+ /**
53
+ * `true` when the language is Persian (`fa`, any region), the test MAUI uses to show Jalali dates
54
+ * (`G9Calendar.IsPersianLanguage`). Dari (`prs`), Pashto, Arabic and the invariant culture are `false`.
55
+ */
56
+ export declare function isPersianLanguage(culture: G9Culture | string | null | undefined): boolean;
57
+ /** `true` when the culture reads right-to-left (MAUI `G9Culture.IsRtl`, `G9Visuals.IsRtl`). */
58
+ export declare function isRtl(culture: G9Culture): boolean;
59
+ /**
60
+ * The font family text should use now (MAUI `G9Culture.ResolveFontFamily`, `G9Visuals.ResolveCulturalFont`): a
61
+ * non-blank `explicitFontFamily` always wins, otherwise the culture's RTL or LTR family. `undefined` means "platform
62
+ * default".
63
+ */
64
+ export declare function resolveFontFamily(culture: G9Culture, explicitFontFamily?: string | null): string | undefined;
65
+ /** Field-by-field equality of two culture values. */
66
+ export declare function sameCulture(a: G9Culture, b: G9Culture): boolean;
67
+ /** Listener of {@link G9CultureStore}: receives the snapshot taken when the change was notified. */
68
+ export type G9CultureListener = (culture: G9Culture) => void;
69
+ /**
70
+ * The app's active culture (MAUI `G9Culture` facade + `CultureChanged`): one frozen snapshot, replaced on each change;
71
+ * listeners are told once per change. Works with `useSyncExternalStore` (`subscribe` / `getSnapshot`). The React
72
+ * provider (WP02) owns one.
73
+ */
74
+ export interface G9CultureStore {
75
+ /** The current culture (MAUI `CurrentCulture`); the same object until something changes. */
76
+ getSnapshot(): G9Culture;
77
+ /** Adds a listener; returns its unsubscribe function. */
78
+ subscribe(listener: G9CultureListener): () => void;
79
+ /** Switch culture (a value, or a locale tag with its defaults). Notifies only when something changed. */
80
+ setCulture(culture: G9Culture | string): void;
81
+ /** Replace some settings of the current culture (direction, calendar, digits, fonts); notifies once if changed. */
82
+ update(options: G9CultureOptions): void;
83
+ }
84
+ /**
85
+ * Creates a {@link G9CultureStore}. Notification follows MAUI `NotifyChanged`: each listener receives the snapshot of
86
+ * the change being reported, even if a listener switches the culture again (that switch is reported afterwards, in a
87
+ * new round, with its own snapshot). Every listener runs even if one throws; the first error is rethrown afterwards.
88
+ * An invalid culture throws before anything changes.
89
+ */
90
+ export declare function createCultureStore(initial: G9Culture | string): G9CultureStore;
91
+ //# sourceMappingURL=culture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"culture.d.ts","sourceRoot":"","sources":["../../src/culture/culture.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAExE,kDAAkD;AAClD,eAAO,MAAM,WAAW;;;CAAsC,CAAC;AAC/D,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAEzE,kGAAkG;AAClG,eAAO,MAAM,gBAAgB;;;CAA0D,CAAC;AACxF,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAExF;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,iFAAiF;IACjF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,eAAe,EAAE,iBAAiB,CAAC;IAC5C,iHAAiH;IACjH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,iHAAiH;IACjH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,4FAA4F;AAC5F,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,SAA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