@carlonicora/nextjs-jsonapi 6.24.0 → 6.25.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 (246) hide show
  1. package/dist/{BlockNoteEditor-MONT74RQ.js → BlockNoteEditor-TNX77GCD.js} +28 -25
  2. package/dist/BlockNoteEditor-TNX77GCD.js.map +1 -0
  3. package/dist/{BlockNoteEditor-ENDOVTAW.mjs → BlockNoteEditor-Z5LDF47Z.mjs} +13 -10
  4. package/dist/{BlockNoteEditor-ENDOVTAW.mjs.map → BlockNoteEditor-Z5LDF47Z.mjs.map} +1 -1
  5. package/dist/{BlockNoteViewer-K2HBF3IP.js → BlockNoteViewer-6KQJODNF.js} +9 -7
  6. package/dist/BlockNoteViewer-6KQJODNF.js.map +1 -0
  7. package/dist/{BlockNoteViewer-2TJZ6JET.mjs → BlockNoteViewer-TQ452ZYW.mjs} +8 -6
  8. package/dist/{BlockNoteViewer-2TJZ6JET.mjs.map → BlockNoteViewer-TQ452ZYW.mjs.map} +1 -1
  9. package/dist/JsonApiRequest-OKNQZLS6.js +26 -0
  10. package/dist/{JsonApiRequest-KC6DOHKT.js.map → JsonApiRequest-OKNQZLS6.js.map} +1 -1
  11. package/dist/{JsonApiRequest-ADLBJ5RX.mjs → JsonApiRequest-WNPDS356.mjs} +2 -2
  12. package/dist/billing/index.js +504 -517
  13. package/dist/billing/index.js.map +1 -1
  14. package/dist/billing/index.mjs +20 -33
  15. package/dist/billing/index.mjs.map +1 -1
  16. package/dist/{chunk-VNUT2D27.mjs → chunk-2PWYG2WJ.mjs} +2 -2
  17. package/dist/{chunk-W4ML6D2X.mjs → chunk-3U7YJ73T.mjs} +7 -7
  18. package/dist/{chunk-BQ2WAG4K.js → chunk-3VNDFKT7.js} +19 -19
  19. package/dist/{chunk-BQ2WAG4K.js.map → chunk-3VNDFKT7.js.map} +1 -1
  20. package/dist/{chunk-BE6UMM5X.mjs → chunk-47HNJQ7U.mjs} +3 -3
  21. package/dist/chunk-5T2AQMQ2.mjs +90 -0
  22. package/dist/chunk-5T2AQMQ2.mjs.map +1 -0
  23. package/dist/{chunk-A5M3MORY.js → chunk-5WM72MLE.js} +3 -3
  24. package/dist/{chunk-A5M3MORY.js.map → chunk-5WM72MLE.js.map} +1 -1
  25. package/dist/{chunk-S7SPAC6X.mjs → chunk-73NKUBMP.mjs} +3 -3
  26. package/dist/chunk-743M4TIB.mjs +76 -0
  27. package/dist/chunk-743M4TIB.mjs.map +1 -0
  28. package/dist/{chunk-HN7L6RRW.js → chunk-CSBQAPHD.js} +903 -955
  29. package/dist/chunk-CSBQAPHD.js.map +1 -0
  30. package/dist/{chunk-YTDGYI62.mjs → chunk-DWPHHUMV.mjs} +3 -3
  31. package/dist/{chunk-53SD4YRF.js → chunk-FBHUUPRV.js} +5 -5
  32. package/dist/{chunk-53SD4YRF.js.map → chunk-FBHUUPRV.js.map} +1 -1
  33. package/dist/{chunk-T6G2F2BK.mjs → chunk-HJT7TXGG.mjs} +16 -68
  34. package/dist/chunk-HJT7TXGG.mjs.map +1 -0
  35. package/dist/chunk-HROKKUBQ.js +156 -0
  36. package/dist/chunk-HROKKUBQ.js.map +1 -0
  37. package/dist/{chunk-TMV7TL7O.mjs → chunk-JELEQV5T.mjs} +8 -6
  38. package/dist/{chunk-TMV7TL7O.mjs.map → chunk-JELEQV5T.mjs.map} +1 -1
  39. package/dist/{chunk-TNTCLVUR.js → chunk-JGL4P3DS.js} +17 -15
  40. package/dist/chunk-JGL4P3DS.js.map +1 -0
  41. package/dist/{chunk-7OIWOPM5.mjs → chunk-K7KLUYS7.mjs} +4 -3
  42. package/dist/chunk-K7KLUYS7.mjs.map +1 -0
  43. package/dist/{chunk-OZADFYE7.mjs → chunk-KVYYPKRO.mjs} +308 -241
  44. package/dist/chunk-KVYYPKRO.mjs.map +1 -0
  45. package/dist/{chunk-RCOKQ3R4.js → chunk-LNO2JLU3.js} +2 -2
  46. package/dist/{chunk-RCOKQ3R4.js.map → chunk-LNO2JLU3.js.map} +1 -1
  47. package/dist/{chunk-BDWV4KYR.js → chunk-M6SNTMK6.js} +1386 -1319
  48. package/dist/chunk-M6SNTMK6.js.map +1 -0
  49. package/dist/{chunk-GMMDXINC.js → chunk-N3NQS7X6.js} +12 -12
  50. package/dist/{chunk-GMMDXINC.js.map → chunk-N3NQS7X6.js.map} +1 -1
  51. package/dist/chunk-NP3AFULU.js +76 -0
  52. package/dist/chunk-NP3AFULU.js.map +1 -0
  53. package/dist/{chunk-SO3YUCL6.js → chunk-OOM54Z5Z.js} +6 -5
  54. package/dist/chunk-OOM54Z5Z.js.map +1 -0
  55. package/dist/{chunk-YSE2Z4RB.js → chunk-PQQFOONG.js} +12 -12
  56. package/dist/{chunk-YSE2Z4RB.js.map → chunk-PQQFOONG.js.map} +1 -1
  57. package/dist/chunk-RW6XZGZG.mjs +156 -0
  58. package/dist/chunk-RW6XZGZG.mjs.map +1 -0
  59. package/dist/chunk-SYMI4IDW.js +90 -0
  60. package/dist/chunk-SYMI4IDW.js.map +1 -0
  61. package/dist/{chunk-N2BFT7KI.mjs → chunk-W7U6O3OE.mjs} +2 -71
  62. package/dist/chunk-W7U6O3OE.mjs.map +1 -0
  63. package/dist/{chunk-YMCL3JXZ.mjs → chunk-YPBIPE2B.mjs} +2 -2
  64. package/dist/{chunk-P7L6OFX5.js → chunk-Z6T2575A.js} +12 -81
  65. package/dist/chunk-Z6T2575A.js.map +1 -0
  66. package/dist/client/index.js +13 -10
  67. package/dist/client/index.js.map +1 -1
  68. package/dist/client/index.mjs +17 -14
  69. package/dist/components/forms/DatePickerPopover.d.ts.map +1 -1
  70. package/dist/components/forms/DateRangeSelector.d.ts.map +1 -1
  71. package/dist/components/forms/FormDate.d.ts.map +1 -1
  72. package/dist/components/forms/FormDateTime.d.ts.map +1 -1
  73. package/dist/components/forms/time-cycle.d.ts +14 -0
  74. package/dist/components/forms/time-cycle.d.ts.map +1 -0
  75. package/dist/components/index.js +11 -8
  76. package/dist/components/index.js.map +1 -1
  77. package/dist/components/index.mjs +10 -7
  78. package/dist/components/tables/cells/cell.date.d.ts.map +1 -1
  79. package/dist/components/tables/cells/cell.dateTime.d.ts.map +1 -1
  80. package/dist/contexts/DateLocaleContext.d.ts +56 -0
  81. package/dist/contexts/DateLocaleContext.d.ts.map +1 -0
  82. package/dist/contexts/index.d.ts +1 -0
  83. package/dist/contexts/index.d.ts.map +1 -1
  84. package/dist/contexts/index.js +24 -8
  85. package/dist/contexts/index.js.map +1 -1
  86. package/dist/contexts/index.mjs +23 -7
  87. package/dist/core/index.js +17 -6
  88. package/dist/core/index.js.map +1 -1
  89. package/dist/core/index.mjs +19 -8
  90. package/dist/date-locale/index.d.ts +2 -0
  91. package/dist/date-locale/index.d.ts.map +1 -0
  92. package/dist/date-locale/index.js +21 -0
  93. package/dist/date-locale/index.js.map +1 -0
  94. package/dist/date-locale/index.mjs +21 -0
  95. package/dist/email-automations/index.js +131 -123
  96. package/dist/email-automations/index.js.map +1 -1
  97. package/dist/email-automations/index.mjs +23 -15
  98. package/dist/email-automations/index.mjs.map +1 -1
  99. package/dist/features/account-deletion/components/AccountDeletionAdminTrigger.d.ts.map +1 -1
  100. package/dist/features/analytics/components/AnalyticsJourneyContainer.d.ts.map +1 -1
  101. package/dist/features/analytics/components/AnalyticsSessionsTable.d.ts.map +1 -1
  102. package/dist/features/analytics/index.js +154 -147
  103. package/dist/features/analytics/index.js.map +1 -1
  104. package/dist/features/analytics/index.mjs +32 -25
  105. package/dist/features/analytics/index.mjs.map +1 -1
  106. package/dist/features/analytics/server.js +11 -9
  107. package/dist/features/analytics/server.js.map +1 -1
  108. package/dist/features/analytics/server.mjs +9 -7
  109. package/dist/features/analytics/server.mjs.map +1 -1
  110. package/dist/features/billing/components/utils/date.d.ts +3 -3
  111. package/dist/features/billing/components/utils/format-options.d.ts +6 -4
  112. package/dist/features/billing/components/utils/format-options.d.ts.map +1 -1
  113. package/dist/features/billing/components/utils/useBillingFormatOptions.d.ts +5 -1
  114. package/dist/features/billing/components/utils/useBillingFormatOptions.d.ts.map +1 -1
  115. package/dist/features/billing/stripe-usage/components/details/UsageSummaryCard.d.ts.map +1 -1
  116. package/dist/features/billing/stripe-usage/components/lists/UsageHistoryTable.d.ts.map +1 -1
  117. package/dist/features/blog/components/admin/BlogTranslationStatus.d.ts.map +1 -1
  118. package/dist/features/blog/components/public/BlogPostMeta.d.ts.map +1 -1
  119. package/dist/features/blog/hooks/useBlogPostTableStructure.d.ts.map +1 -1
  120. package/dist/features/blog/index.js +168 -162
  121. package/dist/features/blog/index.js.map +1 -1
  122. package/dist/features/blog/index.mjs +25 -19
  123. package/dist/features/blog/index.mjs.map +1 -1
  124. package/dist/features/blog/server.js +29 -27
  125. package/dist/features/blog/server.js.map +1 -1
  126. package/dist/features/blog/server.mjs +8 -6
  127. package/dist/features/blog/server.mjs.map +1 -1
  128. package/dist/features/email-automation/hooks/useEmailAutomationEnrollmentTableStructure.d.ts.map +1 -1
  129. package/dist/features/handbook/components/parts/HandbookIndexStatus.d.ts.map +1 -1
  130. package/dist/features/help/components/HelpArticleBody.d.ts.map +1 -1
  131. package/dist/features/help/index.js +48 -43
  132. package/dist/features/help/index.js.map +1 -1
  133. package/dist/features/help/index.mjs +15 -10
  134. package/dist/features/help/index.mjs.map +1 -1
  135. package/dist/features/notification/components/notifications/Notification.d.ts +2 -1
  136. package/dist/features/notification/components/notifications/Notification.d.ts.map +1 -1
  137. package/dist/features/notification/contexts/NotificationContext.d.ts.map +1 -1
  138. package/dist/features/notification/hooks/useNotificationTableStructure.d.ts.map +1 -1
  139. package/dist/features/oauth/components/OAuthClientCard.d.ts.map +1 -1
  140. package/dist/features/oauth/components/OAuthClientDetail.d.ts.map +1 -1
  141. package/dist/features/tokenusage/index.js +133 -130
  142. package/dist/features/tokenusage/index.js.map +1 -1
  143. package/dist/features/tokenusage/index.mjs +10 -7
  144. package/dist/features/tokenusage/index.mjs.map +1 -1
  145. package/dist/features/tokenusage/lib/formatters.d.ts +6 -3
  146. package/dist/features/tokenusage/lib/formatters.d.ts.map +1 -1
  147. package/dist/index.js +19 -7
  148. package/dist/index.js.map +1 -1
  149. package/dist/index.mjs +23 -11
  150. package/dist/local-transport-AT4TE264.js +15 -0
  151. package/dist/{local-transport-MJPOKPTU.js.map → local-transport-AT4TE264.js.map} +1 -1
  152. package/dist/{local-transport-RVD4FZGA.mjs → local-transport-KWEUZ4GX.mjs} +5 -5
  153. package/dist/offline/index.js +56 -54
  154. package/dist/offline/index.js.map +1 -1
  155. package/dist/offline/index.mjs +23 -21
  156. package/dist/offline/index.mjs.map +1 -1
  157. package/dist/{request-4AWGPIGH.mjs → request-6GAIWWTG.mjs} +2 -2
  158. package/dist/{request-H5FZBZA2.js → request-BWO4Y434.js} +3 -3
  159. package/dist/{request-H5FZBZA2.js.map → request-BWO4Y434.js.map} +1 -1
  160. package/dist/server/ServerSession.d.ts +2 -0
  161. package/dist/server/ServerSession.d.ts.map +1 -1
  162. package/dist/server/index.js +10 -8
  163. package/dist/server/index.js.map +1 -1
  164. package/dist/server/index.mjs +9 -7
  165. package/dist/utils/date-formatter.d.ts +45 -4
  166. package/dist/utils/date-formatter.d.ts.map +1 -1
  167. package/dist/utils/index.d.ts +1 -1
  168. package/dist/utils/index.d.ts.map +1 -1
  169. package/dist/write-through-KNRI5L4V.mjs +15 -0
  170. package/dist/write-through-KNRI5L4V.mjs.map +1 -0
  171. package/dist/write-through-MYHQ6GJU.js +15 -0
  172. package/dist/{write-through-HE2QSOVI.js.map → write-through-MYHQ6GJU.js.map} +1 -1
  173. package/messages/en.json +1 -0
  174. package/messages/it.json +1 -0
  175. package/package.json +6 -1
  176. package/src/components/forms/DatePickerPopover.tsx +5 -3
  177. package/src/components/forms/DateRangeSelector.tsx +9 -7
  178. package/src/components/forms/FormDate.tsx +5 -3
  179. package/src/components/forms/FormDateTime.tsx +75 -39
  180. package/src/components/forms/__tests__/time-cycle.spec.ts +37 -0
  181. package/src/components/forms/time-cycle.ts +27 -0
  182. package/src/components/tables/cells/cell.date.tsx +3 -5
  183. package/src/components/tables/cells/cell.dateTime.tsx +3 -7
  184. package/src/contexts/DateLocaleContext.tsx +106 -0
  185. package/src/contexts/__tests__/DateLocaleContext.spec.tsx +175 -0
  186. package/src/contexts/index.ts +1 -0
  187. package/src/date-locale/index.ts +12 -0
  188. package/src/features/account-deletion/components/AccountDeletionAdminTrigger.tsx +3 -4
  189. package/src/features/analytics/components/AnalyticsJourneyContainer.tsx +8 -8
  190. package/src/features/analytics/components/AnalyticsSessionsTable.tsx +4 -6
  191. package/src/features/auth/components/two-factor/PasskeyList.tsx +3 -3
  192. package/src/features/auth/components/two-factor/TotpAuthenticatorList.tsx +3 -3
  193. package/src/features/billing/components/utils/__tests__/billing-formatters.spec.ts +14 -6
  194. package/src/features/billing/components/utils/date.ts +5 -5
  195. package/src/features/billing/components/utils/format-options.ts +6 -4
  196. package/src/features/billing/components/utils/useBillingFormatOptions.ts +8 -2
  197. package/src/features/billing/stripe-usage/components/details/UsageSummaryCard.tsx +4 -12
  198. package/src/features/billing/stripe-usage/components/lists/UsageHistoryTable.tsx +4 -17
  199. package/src/features/blog/components/admin/BlogTranslationStatus.tsx +3 -2
  200. package/src/features/blog/components/public/BlogPostMeta.tsx +5 -4
  201. package/src/features/blog/components/public/__tests__/BlogList.spec.tsx +1 -2
  202. package/src/features/blog/components/public/__tests__/BlogPostView.spec.tsx +2 -3
  203. package/src/features/blog/hooks/useBlogPostTableStructure.tsx +4 -8
  204. package/src/features/email-automation/hooks/useEmailAutomationEnrollmentTableStructure.tsx +11 -5
  205. package/src/features/email-blast/components/containers/EmailBlastContainer.tsx +3 -3
  206. package/src/features/email-blast/hooks/useEmailBlastTableStructure.tsx +4 -4
  207. package/src/features/handbook/components/parts/HandbookIndexStatus.tsx +4 -3
  208. package/src/features/help/components/HelpArticleBody.tsx +4 -3
  209. package/src/features/notification/components/notifications/Notification.tsx +38 -7
  210. package/src/features/notification/contexts/NotificationContext.tsx +6 -3
  211. package/src/features/notification/hooks/useNotificationTableStructure.tsx +6 -5
  212. package/src/features/oauth/components/OAuthClientCard.tsx +8 -5
  213. package/src/features/oauth/components/OAuthClientDetail.tsx +3 -6
  214. package/src/features/tokenusage/lib/__tests__/formatters.spec.ts +19 -0
  215. package/src/features/tokenusage/lib/formatters.ts +11 -6
  216. package/src/features/waitlist/hooks/useWaitlistTableStructure.tsx +5 -5
  217. package/src/server/ServerSession.ts +3 -0
  218. package/src/server/__tests__/ServerSession.read.spec.ts +18 -1
  219. package/src/utils/__tests__/date-formatter.spec.ts +134 -10
  220. package/src/utils/date-formatter.ts +200 -44
  221. package/src/utils/index.ts +11 -1
  222. package/dist/BlockNoteEditor-MONT74RQ.js.map +0 -1
  223. package/dist/BlockNoteViewer-K2HBF3IP.js.map +0 -1
  224. package/dist/JsonApiRequest-KC6DOHKT.js +0 -26
  225. package/dist/chunk-7OIWOPM5.mjs.map +0 -1
  226. package/dist/chunk-BDWV4KYR.js.map +0 -1
  227. package/dist/chunk-HN7L6RRW.js.map +0 -1
  228. package/dist/chunk-N2BFT7KI.mjs.map +0 -1
  229. package/dist/chunk-OZADFYE7.mjs.map +0 -1
  230. package/dist/chunk-P7L6OFX5.js.map +0 -1
  231. package/dist/chunk-SO3YUCL6.js.map +0 -1
  232. package/dist/chunk-T6G2F2BK.mjs.map +0 -1
  233. package/dist/chunk-TNTCLVUR.js.map +0 -1
  234. package/dist/local-transport-MJPOKPTU.js +0 -15
  235. package/dist/write-through-7I3LA2WN.mjs +0 -15
  236. package/dist/write-through-HE2QSOVI.js +0 -15
  237. /package/dist/{JsonApiRequest-ADLBJ5RX.mjs.map → JsonApiRequest-WNPDS356.mjs.map} +0 -0
  238. /package/dist/{chunk-VNUT2D27.mjs.map → chunk-2PWYG2WJ.mjs.map} +0 -0
  239. /package/dist/{chunk-W4ML6D2X.mjs.map → chunk-3U7YJ73T.mjs.map} +0 -0
  240. /package/dist/{chunk-BE6UMM5X.mjs.map → chunk-47HNJQ7U.mjs.map} +0 -0
  241. /package/dist/{chunk-S7SPAC6X.mjs.map → chunk-73NKUBMP.mjs.map} +0 -0
  242. /package/dist/{chunk-YTDGYI62.mjs.map → chunk-DWPHHUMV.mjs.map} +0 -0
  243. /package/dist/{chunk-YMCL3JXZ.mjs.map → chunk-YPBIPE2B.mjs.map} +0 -0
  244. /package/dist/{local-transport-RVD4FZGA.mjs.map → date-locale/index.mjs.map} +0 -0
  245. /package/dist/{request-4AWGPIGH.mjs.map → local-transport-KWEUZ4GX.mjs.map} +0 -0
  246. /package/dist/{write-through-7I3LA2WN.mjs.map → request-6GAIWWTG.mjs.map} +0 -0
@@ -0,0 +1,156 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-PAWJFY3S.mjs";
4
+
5
+ // src/utils/date-formatter.ts
6
+ var formatLocalDate = /* @__PURE__ */ __name((d) => {
7
+ const year = d.getFullYear();
8
+ const month = String(d.getMonth() + 1).padStart(2, "0");
9
+ const day = String(d.getDate()).padStart(2, "0");
10
+ return `${year}-${month}-${day}`;
11
+ }, "formatLocalDate");
12
+ var NUMERIC_DATE = { day: "2-digit", month: "2-digit", year: "numeric" };
13
+ var DATE_STYLE_OPTIONS = {
14
+ date: NUMERIC_DATE,
15
+ dateMedium: { dateStyle: "medium" },
16
+ dateLong: { dateStyle: "long" },
17
+ dateTime: { ...NUMERIC_DATE, hour: "numeric", minute: "2-digit" },
18
+ dateTimeMedium: { dateStyle: "medium", timeStyle: "short" },
19
+ dateTimeLong: { day: "numeric", month: "long", year: "numeric", hour: "numeric", minute: "2-digit" },
20
+ dateTimeSeconds: { ...NUMERIC_DATE, hour: "numeric", minute: "2-digit", second: "2-digit" },
21
+ time: { hour: "numeric", minute: "2-digit" },
22
+ weekdayDateTime: { weekday: "short", day: "numeric", month: "short", hour: "numeric", minute: "2-digit" },
23
+ weekdayDay: { weekday: "short", day: "numeric", month: "long", year: "numeric" },
24
+ monthYear: { month: "short", year: "numeric" },
25
+ monthYearLong: { month: "long", year: "numeric" },
26
+ month: { month: "short" },
27
+ monthLong: { month: "long" },
28
+ dayMonth: { day: "numeric", month: "short" },
29
+ weekday: { weekday: "short" },
30
+ weekdayLong: { weekday: "long" }
31
+ };
32
+ var PUBLIC_STYLE_MAP = {
33
+ date: "dateMedium",
34
+ dateTime: "dateTimeMedium",
35
+ dateTimeSeconds: "dateTimeMedium"
36
+ };
37
+ var formatterCache = /* @__PURE__ */ new Map();
38
+ var cachedDateTimeFormat = /* @__PURE__ */ __name((locale, key, options, timeZone) => {
39
+ const cacheKey = `${locale}|${key}|${timeZone ?? ""}`;
40
+ let formatter = formatterCache.get(cacheKey);
41
+ if (!formatter) {
42
+ formatter = new Intl.DateTimeFormat(locale, timeZone ? { ...options, timeZone } : options);
43
+ formatterCache.set(cacheKey, formatter);
44
+ }
45
+ return formatter;
46
+ }, "cachedDateTimeFormat");
47
+ var relativeCache = /* @__PURE__ */ new Map();
48
+ var cachedRelativeTimeFormat = /* @__PURE__ */ __name((locale) => {
49
+ let formatter = relativeCache.get(locale);
50
+ if (!formatter) {
51
+ formatter = new Intl.RelativeTimeFormat(locale, { numeric: "always" });
52
+ relativeCache.set(locale, formatter);
53
+ }
54
+ return formatter;
55
+ }, "cachedRelativeTimeFormat");
56
+ var toValidDate = /* @__PURE__ */ __name((date) => {
57
+ if (date === void 0 || date === null) return void 0;
58
+ const value = date instanceof Date ? date : new Date(date);
59
+ return Number.isNaN(value.getTime()) ? void 0 : value;
60
+ }, "toValidDate");
61
+ var languageOf = /* @__PURE__ */ __name((tag) => tag.split("-")[0].toLowerCase(), "languageOf");
62
+ var MAX_ACCEPT_LANGUAGE_ENTRIES = 50;
63
+ function resolveDateLocale(params) {
64
+ const { appLocale, acceptLanguage } = params;
65
+ if (!acceptLanguage) return appLocale;
66
+ const appLanguage = languageOf(appLocale);
67
+ const entries = [];
68
+ const parts = acceptLanguage.split(",");
69
+ for (let index = 0; index < parts.length && entries.length < MAX_ACCEPT_LANGUAGE_ENTRIES; index++) {
70
+ const [rawTag, ...rawParams] = parts[index].split(";");
71
+ const tag = rawTag.trim();
72
+ if (!tag || tag === "*") continue;
73
+ let quality = 1;
74
+ const qualityParam = rawParams.map((param) => param.trim()).find((param) => param.startsWith("q="));
75
+ if (qualityParam !== void 0) {
76
+ const raw = qualityParam.slice(2);
77
+ quality = /^\d+(\.\d+)?$/.test(raw) ? Number(raw) : NaN;
78
+ }
79
+ if (!(quality > 0)) continue;
80
+ if (languageOf(tag) !== appLanguage) continue;
81
+ entries.push({ tag, quality, index });
82
+ }
83
+ entries.sort((a, b) => b.quality - a.quality || a.index - b.index);
84
+ for (const entry of entries) {
85
+ try {
86
+ const [supported] = Intl.DateTimeFormat.supportedLocalesOf([entry.tag]);
87
+ if (supported && languageOf(supported) === appLanguage) return supported;
88
+ } catch {
89
+ }
90
+ }
91
+ return appLocale;
92
+ }
93
+ __name(resolveDateLocale, "resolveDateLocale");
94
+ function formatDateStyle(params) {
95
+ const value = toValidDate(params.date);
96
+ if (!value) return "";
97
+ const style = params.isPublic && PUBLIC_STYLE_MAP[params.style] || params.style;
98
+ return cachedDateTimeFormat(params.locale, style, DATE_STYLE_OPTIONS[style], params.timeZone).format(value);
99
+ }
100
+ __name(formatDateStyle, "formatDateStyle");
101
+ function formatRelativeDate(params) {
102
+ const value = toValidDate(params.date);
103
+ if (!value) return "";
104
+ const now = params.now ?? /* @__PURE__ */ new Date();
105
+ const diff = now.getTime() - value.getTime();
106
+ const sign = diff < 0 ? 1 : -1;
107
+ const seconds = Math.floor(Math.abs(diff) / 1e3);
108
+ const minutes = Math.floor(seconds / 60);
109
+ const hours = Math.floor(minutes / 60);
110
+ const days = Math.floor(hours / 24);
111
+ const relative = cachedRelativeTimeFormat(params.locale);
112
+ if (days > 0) return relative.format(sign * days, "day");
113
+ if (hours > 0) return relative.format(sign * hours, "hour");
114
+ if (minutes > 0) return relative.format(sign * minutes, "minute");
115
+ return relative.format(sign * seconds, "second");
116
+ }
117
+ __name(formatRelativeDate, "formatRelativeDate");
118
+ function usesTwelveHourClock(locale) {
119
+ const hourCycle = cachedDateTimeFormat(locale, "__hourCycle", { hour: "numeric" }).resolvedOptions().hourCycle;
120
+ return hourCycle === "h11" || hourCycle === "h12";
121
+ }
122
+ __name(usesTwelveHourClock, "usesTwelveHourClock");
123
+ var dateFormatLocale = /* @__PURE__ */ __name((appLocale) => appLocale ?? "en", "dateFormatLocale");
124
+ var LEGACY_DATE_OPTIONS = { year: "numeric", month: "2-digit", day: "2-digit" };
125
+ var LEGACY_TIME_OPTIONS = { hour: "2-digit", minute: "2-digit" };
126
+ var formatDate = /* @__PURE__ */ __name((eventDate, formatOption, locale = "en-GB", now) => {
127
+ const reference = now ?? /* @__PURE__ */ new Date();
128
+ const diff = reference.getTime() - eventDate.getTime();
129
+ if (formatOption === "default") {
130
+ if (diff < 24 * 60 * 60 * 1e3) formatOption = "timeSince";
131
+ else formatOption = "dateTime";
132
+ }
133
+ switch (formatOption) {
134
+ case "timeSince":
135
+ return formatRelativeDate({ date: eventDate, locale, now: reference });
136
+ case "date":
137
+ return cachedDateTimeFormat(locale, "__legacyDate", LEGACY_DATE_OPTIONS).format(eventDate);
138
+ case "time":
139
+ return cachedDateTimeFormat(locale, "__legacyTime", LEGACY_TIME_OPTIONS).format(eventDate);
140
+ case "dateTime":
141
+ return `${cachedDateTimeFormat(locale, "__legacyDate", LEGACY_DATE_OPTIONS).format(eventDate)} ${cachedDateTimeFormat(locale, "__legacyTime", LEGACY_TIME_OPTIONS).format(eventDate)}`;
142
+ default:
143
+ throw new Error("Invalid format option");
144
+ }
145
+ }, "formatDate");
146
+
147
+ export {
148
+ formatLocalDate,
149
+ resolveDateLocale,
150
+ formatDateStyle,
151
+ formatRelativeDate,
152
+ usesTwelveHourClock,
153
+ dateFormatLocale,
154
+ formatDate
155
+ };
156
+ //# sourceMappingURL=chunk-RW6XZGZG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/date-formatter.ts"],"sourcesContent":["type FormatOption = \"date\" | \"time\" | \"dateTime\" | \"timeSince\" | \"default\";\n\n/**\n * Format a `Date` as `YYYY-MM-DD` using the value's local-time components.\n *\n * Use for JSON:API attributes whose backend field type is `\"date\"` (calendar\n * date with no time component). `JSON.stringify(new Date(...))` would call\n * `.toISOString()`, which UTC-shifts and can lose a day west of UTC; this\n * helper avoids that by emitting the local-date components verbatim.\n *\n * For `\"datetime\"` fields use `.toISOString()` instead — those represent an\n * instant in time and the UTC shift is correct.\n */\nexport const formatLocalDate = (d: Date): string => {\n const year = d.getFullYear();\n const month = String(d.getMonth() + 1).padStart(2, \"0\");\n const day = String(d.getDate()).padStart(2, \"0\");\n return `${year}-${month}-${day}`;\n};\n\nexport type DateFormatStyle =\n | \"date\"\n | \"dateMedium\"\n | \"dateLong\"\n | \"dateTime\"\n | \"dateTimeMedium\"\n | \"dateTimeLong\"\n | \"dateTimeSeconds\"\n | \"time\"\n | \"weekdayDateTime\"\n | \"weekdayDay\"\n | \"monthYear\"\n | \"monthYearLong\"\n | \"month\"\n | \"monthLong\"\n | \"dayMonth\"\n | \"weekday\"\n | \"weekdayLong\";\n\nconst NUMERIC_DATE: Intl.DateTimeFormatOptions = { day: \"2-digit\", month: \"2-digit\", year: \"numeric\" };\n\n/**\n * The option set behind each named style. No style pins `hour12` / `hourCycle`:\n * the clock (12 or 24 hours) follows the locale.\n */\nexport const DATE_STYLE_OPTIONS: Record<DateFormatStyle, Intl.DateTimeFormatOptions> = {\n date: NUMERIC_DATE,\n dateMedium: { dateStyle: \"medium\" },\n dateLong: { dateStyle: \"long\" },\n dateTime: { ...NUMERIC_DATE, hour: \"numeric\", minute: \"2-digit\" },\n dateTimeMedium: { dateStyle: \"medium\", timeStyle: \"short\" },\n dateTimeLong: { day: \"numeric\", month: \"long\", year: \"numeric\", hour: \"numeric\", minute: \"2-digit\" },\n dateTimeSeconds: { ...NUMERIC_DATE, hour: \"numeric\", minute: \"2-digit\", second: \"2-digit\" },\n time: { hour: \"numeric\", minute: \"2-digit\" },\n weekdayDateTime: { weekday: \"short\", day: \"numeric\", month: \"short\", hour: \"numeric\", minute: \"2-digit\" },\n weekdayDay: { weekday: \"short\", day: \"numeric\", month: \"long\", year: \"numeric\" },\n monthYear: { month: \"short\", year: \"numeric\" },\n monthYearLong: { month: \"long\", year: \"numeric\" },\n month: { month: \"short\" },\n monthLong: { month: \"long\" },\n dayMonth: { day: \"numeric\", month: \"short\" },\n weekday: { weekday: \"short\" },\n weekdayLong: { weekday: \"long\" },\n};\n\n/** Public pages never show an all-numeric date: the month is spelled out. */\nexport const PUBLIC_STYLE_MAP: Partial<Record<DateFormatStyle, DateFormatStyle>> = {\n date: \"dateMedium\",\n dateTime: \"dateTimeMedium\",\n dateTimeSeconds: \"dateTimeMedium\",\n};\n\nconst formatterCache = new Map<string, Intl.DateTimeFormat>();\n\n/** One cached `Intl.DateTimeFormat` per locale + option-set key + time zone. */\nconst cachedDateTimeFormat = (\n locale: string,\n key: string,\n options: Intl.DateTimeFormatOptions,\n timeZone?: string,\n): Intl.DateTimeFormat => {\n const cacheKey = `${locale}|${key}|${timeZone ?? \"\"}`;\n let formatter = formatterCache.get(cacheKey);\n if (!formatter) {\n formatter = new Intl.DateTimeFormat(locale, timeZone ? { ...options, timeZone } : options);\n formatterCache.set(cacheKey, formatter);\n }\n return formatter;\n};\n\nconst relativeCache = new Map<string, Intl.RelativeTimeFormat>();\n\nconst cachedRelativeTimeFormat = (locale: string): Intl.RelativeTimeFormat => {\n let formatter = relativeCache.get(locale);\n if (!formatter) {\n formatter = new Intl.RelativeTimeFormat(locale, { numeric: \"always\" });\n relativeCache.set(locale, formatter);\n }\n return formatter;\n};\n\nconst toValidDate = (date: Date | string | undefined): Date | undefined => {\n if (date === undefined || date === null) return undefined;\n const value = date instanceof Date ? date : new Date(date);\n return Number.isNaN(value.getTime()) ? undefined : value;\n};\n\nconst languageOf = (tag: string): string => tag.split(\"-\")[0].toLowerCase();\n\nconst MAX_ACCEPT_LANGUAGE_ENTRIES = 50;\n\n/**\n * The locale every real-world date is formatted in.\n *\n * The first `Accept-Language` entry (quality order) whose language equals the\n * app language's and that `Intl` supports; otherwise the app language. A\n * malformed entry (`*`, an unparseable or zero quality, an unknown tag) is\n * skipped, never thrown on.\n */\nexport function resolveDateLocale(params: { appLocale: string; acceptLanguage?: string }): string {\n const { appLocale, acceptLanguage } = params;\n if (!acceptLanguage) return appLocale;\n\n const appLanguage = languageOf(appLocale);\n const entries: { tag: string; quality: number; index: number }[] = [];\n\n const parts = acceptLanguage.split(\",\");\n for (let index = 0; index < parts.length && entries.length < MAX_ACCEPT_LANGUAGE_ENTRIES; index++) {\n const [rawTag, ...rawParams] = parts[index].split(\";\");\n const tag = rawTag.trim();\n if (!tag || tag === \"*\") continue;\n\n let quality = 1;\n const qualityParam = rawParams.map((param) => param.trim()).find((param) => param.startsWith(\"q=\"));\n if (qualityParam !== undefined) {\n const raw = qualityParam.slice(2);\n quality = /^\\d+(\\.\\d+)?$/.test(raw) ? Number(raw) : NaN;\n }\n if (!(quality > 0)) continue;\n if (languageOf(tag) !== appLanguage) continue;\n\n entries.push({ tag, quality, index });\n }\n\n entries.sort((a, b) => b.quality - a.quality || a.index - b.index);\n\n for (const entry of entries) {\n try {\n const [supported] = Intl.DateTimeFormat.supportedLocalesOf([entry.tag]);\n if (supported && languageOf(supported) === appLanguage) return supported;\n } catch {\n // An invalid language tag: skip it.\n }\n }\n\n return appLocale;\n}\n\n/**\n * Formats a date in a named style. Returns \"\" for `undefined` or a value that\n * does not parse. `isPublic` swaps the all-numeric styles for month-as-word.\n */\nexport function formatDateStyle(params: {\n date: Date | string | undefined;\n style: DateFormatStyle;\n locale: string;\n timeZone?: string;\n isPublic?: boolean;\n}): string {\n const value = toValidDate(params.date);\n if (!value) return \"\";\n const style = (params.isPublic && PUBLIC_STYLE_MAP[params.style]) || params.style;\n return cachedDateTimeFormat(params.locale, style, DATE_STYLE_OPTIONS[style], params.timeZone).format(value);\n}\n\n/** \"3 hours ago\" / \"3 ore fa\", always numeric (\"1 day ago\", never \"yesterday\"). */\nexport function formatRelativeDate(params: { date: Date | string; locale: string; now?: Date }): string {\n const value = toValidDate(params.date);\n if (!value) return \"\";\n const now = params.now ?? new Date();\n const diff = now.getTime() - value.getTime();\n const sign = diff < 0 ? 1 : -1;\n const seconds = Math.floor(Math.abs(diff) / 1000);\n const minutes = Math.floor(seconds / 60);\n const hours = Math.floor(minutes / 60);\n const days = Math.floor(hours / 24);\n\n const relative = cachedRelativeTimeFormat(params.locale);\n if (days > 0) return relative.format(sign * days, \"day\");\n if (hours > 0) return relative.format(sign * hours, \"hour\");\n if (minutes > 0) return relative.format(sign * minutes, \"minute\");\n return relative.format(sign * seconds, \"second\");\n}\n\n/** True when the locale's clock is 12-hour (hour cycle h11 / h12). */\nexport function usesTwelveHourClock(locale: string): boolean {\n const hourCycle = cachedDateTimeFormat(locale, \"__hourCycle\", { hour: \"numeric\" }).resolvedOptions().hourCycle;\n return hourCycle === \"h11\" || hourCycle === \"h12\";\n}\n\n/** The locale to format dates in for an app locale: the app locale itself, English when missing. */\nexport const dateFormatLocale = (appLocale?: string): string => appLocale ?? \"en\";\n\nconst LEGACY_DATE_OPTIONS: Intl.DateTimeFormatOptions = { year: \"numeric\", month: \"2-digit\", day: \"2-digit\" };\nconst LEGACY_TIME_OPTIONS: Intl.DateTimeFormatOptions = { hour: \"2-digit\", minute: \"2-digit\" };\n\n/**\n * @deprecated Use `formatDateStyle` (or `useDateFormatter().format`) and\n * `formatRelativeDate` (or `useDateFormatter().relative`). Kept for other nja\n * apps: same default locale and the same \"date\" / \"time\" / \"dateTime\" output.\n * Pass `now` from render code; the `new Date()` fallback is for legacy callers.\n */\nexport const formatDate = (\n eventDate: Date,\n formatOption: FormatOption,\n locale: string = \"en-GB\",\n now?: Date,\n): string => {\n const reference = now ?? new Date();\n const diff = reference.getTime() - eventDate.getTime();\n\n if (formatOption === \"default\") {\n if (diff < 24 * 60 * 60 * 1000) formatOption = \"timeSince\";\n else formatOption = \"dateTime\";\n }\n\n switch (formatOption) {\n case \"timeSince\":\n return formatRelativeDate({ date: eventDate, locale, now: reference });\n case \"date\":\n return cachedDateTimeFormat(locale, \"__legacyDate\", LEGACY_DATE_OPTIONS).format(eventDate);\n case \"time\":\n return cachedDateTimeFormat(locale, \"__legacyTime\", LEGACY_TIME_OPTIONS).format(eventDate);\n case \"dateTime\":\n return `${cachedDateTimeFormat(locale, \"__legacyDate\", LEGACY_DATE_OPTIONS).format(eventDate)} ${cachedDateTimeFormat(locale, \"__legacyTime\", LEGACY_TIME_OPTIONS).format(eventDate)}`;\n default:\n throw new Error(\"Invalid format option\");\n }\n};\n\nexport type { FormatOption };\n"],"mappings":";;;;;AAaO,IAAM,kBAAkB,wBAAC,MAAoB;AAClD,QAAM,OAAO,EAAE,YAAY;AAC3B,QAAM,QAAQ,OAAO,EAAE,SAAS,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG;AACtD,QAAM,MAAM,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;AAC/C,SAAO,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG;AAChC,GAL+B;AA0B/B,IAAM,eAA2C,EAAE,KAAK,WAAW,OAAO,WAAW,MAAM,UAAU;AAM9F,IAAM,qBAA0E;AAAA,EACrF,MAAM;AAAA,EACN,YAAY,EAAE,WAAW,SAAS;AAAA,EAClC,UAAU,EAAE,WAAW,OAAO;AAAA,EAC9B,UAAU,EAAE,GAAG,cAAc,MAAM,WAAW,QAAQ,UAAU;AAAA,EAChE,gBAAgB,EAAE,WAAW,UAAU,WAAW,QAAQ;AAAA,EAC1D,cAAc,EAAE,KAAK,WAAW,OAAO,QAAQ,MAAM,WAAW,MAAM,WAAW,QAAQ,UAAU;AAAA,EACnG,iBAAiB,EAAE,GAAG,cAAc,MAAM,WAAW,QAAQ,WAAW,QAAQ,UAAU;AAAA,EAC1F,MAAM,EAAE,MAAM,WAAW,QAAQ,UAAU;AAAA,EAC3C,iBAAiB,EAAE,SAAS,SAAS,KAAK,W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AAEhC,IAAM,sBAAkD,EAAE,MAAM,WAAW,OAAO,WAAW,KAAK,UAAU;AAC5G,IAAM,sBAAkD,EAAE,MAAM,WAAW,QAAQ,UAAU;AAQtF,IAAM,aAAa,wBACxB,WACA,cACA,SAAiB,SACjB,QACW;AACX,QAAM,YAAY,OAAO,oBAAI,KAAK;AAClC,QAAM,OAAO,UAAU,QAAQ,IAAI,UAAU,QAAQ;AAErD,MAAI,iBAAiB,WAAW;AAC9B,QAAI,OAAO,KAAK,KAAK,KAAK,IAAM,gBAAe;AAAA,QAC1C,gBAAe;AAAA,EACtB;AAEA,UAAQ,cAAc;AAAA,IACpB,KAAK;AACH,aAAO,mBAAmB,EAAE,MAAM,WAAW,QAAQ,KAAK,UAAU,CAAC;AAAA,IACvE,KAAK;AACH,aAAO,qBAAqB,QAAQ,gBAAgB,mBAAmB,EAAE,OAAO,SAAS;AAAA,IAC3F,KAAK;AACH,aAAO,qBAAqB,QAAQ,gBAAgB,mBAAmB,EAAE,OAAO,SAAS;AAAA,IAC3F,KAAK;AACH,aAAO,GAAG,qBAAqB,QAAQ,gBAAgB,mBAAmB,EAAE,OAAO,SAAS,CAAC,IAAI,qBAAqB,QAAQ,gBAAgB,mBAAmB,EAAE,OAAO,SAAS,CAAC;AAAA,IACtL;AACE,YAAM,IAAI,MAAM,uBAAuB;AAAA,EAC3C;AACF,GA1B0B;","names":[]}
@@ -0,0 +1,90 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+
5
+
6
+ var _chunkHROKKUBQjs = require('./chunk-HROKKUBQ.js');
7
+
8
+
9
+ var _chunkNP3AFULUjs = require('./chunk-NP3AFULU.js');
10
+
11
+
12
+ var _chunk7QVYU63Ejs = require('./chunk-7QVYU63E.js');
13
+
14
+ // src/contexts/DateLocaleContext.tsx
15
+ var _react = require('react'); var React = _interopRequireWildcard(_react);
16
+
17
+ // src/utils/map-thenable.ts
18
+ function mapThenable(thenable, map) {
19
+ return new Promise((resolve, reject) => {
20
+ thenable.then((value) => resolve(map(value)), reject);
21
+ });
22
+ }
23
+ _chunk7QVYU63Ejs.__name.call(void 0, mapThenable, "mapThenable");
24
+
25
+ // src/contexts/DateLocaleContext.tsx
26
+ var _jsxruntime = require('react/jsx-runtime');
27
+ var DateLocaleContext = React.createContext(null);
28
+ function DateLocaleProvider(props) {
29
+ const { session, children } = props;
30
+ const value = React.useMemo(
31
+ () => props.mode === "public" || !session ? { mode: "public" } : { mode: "session", acceptLanguage: mapThenable(session, (snapshot) => snapshot.acceptLanguage) },
32
+ // Created once, like ViewportProvider's seed.
33
+ []
34
+ );
35
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DateLocaleContext.Provider, { value, children });
36
+ }
37
+ _chunk7QVYU63Ejs.__name.call(void 0, DateLocaleProvider, "DateLocaleProvider");
38
+ function useDateLocaleSource() {
39
+ return React.useContext(DateLocaleContext);
40
+ }
41
+ _chunk7QVYU63Ejs.__name.call(void 0, useDateLocaleSource, "useDateLocaleSource");
42
+ function DateLocaleSourceProvider({
43
+ value,
44
+ children
45
+ }) {
46
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DateLocaleContext.Provider, { value, children });
47
+ }
48
+ _chunk7QVYU63Ejs.__name.call(void 0, DateLocaleSourceProvider, "DateLocaleSourceProvider");
49
+ function useDateLocale() {
50
+ const source = React.useContext(DateLocaleContext);
51
+ const appLocale = _chunkNP3AFULUjs.useI18nLocale.call(void 0, );
52
+ const acceptLanguage = _optionalChain([source, 'optionalAccess', _ => _.mode]) === "session" ? React.use(source.acceptLanguage) : void 0;
53
+ const isPublic = _optionalChain([source, 'optionalAccess', _2 => _2.mode]) === "public";
54
+ const locale = _optionalChain([source, 'optionalAccess', _3 => _3.mode]) === "session" ? _chunkHROKKUBQjs.resolveDateLocale.call(void 0, { appLocale, acceptLanguage }) : appLocale;
55
+ return React.useMemo(() => ({ locale, isPublic }), [locale, isPublic]);
56
+ }
57
+ _chunk7QVYU63Ejs.__name.call(void 0, useDateLocale, "useDateLocale");
58
+ function useDateFormatter() {
59
+ const { locale, isPublic } = useDateLocale();
60
+ return React.useMemo(
61
+ () => ({
62
+ locale,
63
+ isPublic,
64
+ format: /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (date, style, options) => _chunkHROKKUBQjs.formatDateStyle.call(void 0, { date, style, locale, timeZone: _optionalChain([options, 'optionalAccess', _4 => _4.timeZone]), isPublic }), "format"),
65
+ relative: /* @__PURE__ */ _chunk7QVYU63Ejs.__name.call(void 0, (date, options) => _chunkHROKKUBQjs.formatRelativeDate.call(void 0, { date, locale, now: options.now }), "relative"),
66
+ twelveHourClock: _chunkHROKKUBQjs.usesTwelveHourClock.call(void 0, locale)
67
+ }),
68
+ [locale, isPublic]
69
+ );
70
+ }
71
+ _chunk7QVYU63Ejs.__name.call(void 0, useDateFormatter, "useDateFormatter");
72
+ function useMountedNow() {
73
+ const [now, setNow] = React.useState(void 0);
74
+ React.useEffect(() => {
75
+ setNow(/* @__PURE__ */ new Date());
76
+ }, []);
77
+ return now;
78
+ }
79
+ _chunk7QVYU63Ejs.__name.call(void 0, useMountedNow, "useMountedNow");
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+ exports.mapThenable = mapThenable; exports.DateLocaleProvider = DateLocaleProvider; exports.useDateLocaleSource = useDateLocaleSource; exports.DateLocaleSourceProvider = DateLocaleSourceProvider; exports.useDateLocale = useDateLocale; exports.useDateFormatter = useDateFormatter; exports.useMountedNow = useMountedNow;
90
+ //# sourceMappingURL=chunk-SYMI4IDW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-SYMI4IDW.js","../src/contexts/DateLocaleContext.tsx","../src/utils/map-thenable.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACXA,2EAAuB;ADavB;AACA;AENO,SAAS,WAAA,CAAkB,QAAA,EAA0B,GAAA,EAAkC;AAC5F,EAAA,OAAO,IAAI,OAAA,CAAW,CAAC,OAAA,EAAS,MAAA,EAAA,GAAW;AACzC,IAAA,QAAA,CAAS,IAAA,CAAK,CAAC,KAAA,EAAA,GAAU,OAAA,CAAQ,GAAA,CAAI,KAAK,CAAC,CAAA,EAAG,MAAM,CAAA;AAAA,EACtD,CAAC,CAAA;AACH;AAJgB,qCAAA,WAAA,EAAA,aAAA,CAAA;AFahB;AACA;ACsBS,+CAAA;AAjBT,IAAM,kBAAA,EAA0B,KAAA,CAAA,aAAA,CAAuC,IAAI,CAAA;AAEpE,SAAS,kBAAA,CACd,KAAA,EAGA;AACA,EAAA,MAAM,EAAE,OAAA,EAAS,SAAS,EAAA,EAAI,KAAA;AAC9B,EAAA,MAAM,MAAA,EAAc,KAAA,CAAA,OAAA;AAAA,IAClB,CAAA,EAAA,GACE,KAAA,CAAM,KAAA,IAAS,SAAA,GAAY,CAAC,QAAA,EACxB,EAAE,IAAA,EAAM,SAAS,EAAA,EACjB,EAAE,IAAA,EAAM,SAAA,EAAW,cAAA,EAAgB,WAAA,CAAY,OAAA,EAAS,CAAC,QAAA,EAAA,GAAa,QAAA,CAAS,cAAc,EAAE,CAAA;AAAA;AAA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,MAAM,EAAE,MAAA,EAAQ,SAAS,EAAA,EAAI,aAAA,CAAc,CAAA;AAE3C,EAAA,OAAa,KAAA,CAAA,OAAA;AAAA,IACX,CAAA,EAAA,GAAA,CAAO;AAAA,MACL,MAAA;AAAA,MACA,QAAA;AAAA,MACA,MAAA,kBAAQ,qCAAA,CAAC,IAAA,EAAM,KAAA,EAAO,OAAA,EAAA,GAAY,8CAAA,EAAkB,IAAA,EAAM,KAAA,EAAO,MAAA,EAAQ,QAAA,kBAAU,OAAA,6BAAS,UAAA,EAAU,SAAS,CAAC,CAAA,EAAxG,QAAA,CAAA;AAAA,MACR,QAAA,kBAAU,qCAAA,CAAC,IAAA,EAAM,OAAA,EAAA,GAAY,iDAAA,EAAqB,IAAA,EAAM,MAAA,EAAQ,GAAA,EAAK,OAAA,CAAQ,IAAI,CAAC,CAAA,EAAxE,UAAA,CAAA;AAAA,MACV,eAAA,EAAiB,kDAAA,MAA0B;AAAA,IAC7C,CAAA,CAAA;AAAA,IACA,CAAC,MAAA,EAAQ,QAAQ;AAAA,EACnB,CAAA;AACF;AAbgB,qCAAA,gBAAA,EAAA,kBAAA,CAAA;AAgBT,SAAS,aAAA,CAAA,EAAkC;AAChD,EAAA,MAAM,CAAC,GAAA,EAAK,MAAM,EAAA,EAAU,KAAA,CAAA,QAAA,CAA2B,KAAA,CAAS,CAAA;AAChE,EAAM,KAAA,CAAA,SAAA,CAAU,CAAA,EAAA,GAAM;AACpB,IAAA,MAAA,iBAAO,IAAI,IAAA,CAAK,CAAC,CAAA;AAAA,EACnB,CAAA,EAAG,CAAC,CAAC,CAAA;AACL,EAAA,OAAO,GAAA;AACT;AANgB,qCAAA,aAAA,EAAA,eAAA,CAAA;ADpBhB;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,8TAAC","file":"/home/runner/work/nextjs-jsonapi/nextjs-jsonapi/dist/chunk-SYMI4IDW.js","sourcesContent":[null,"\"use client\";\n\nimport * as React from \"react\";\nimport { useI18nLocale } from \"../i18n/config\";\nimport type { SessionSnapshot } from \"../server/ServerSession\";\nimport {\n type DateFormatStyle,\n formatDateStyle,\n formatRelativeDate,\n resolveDateLocale,\n usesTwelveHourClock,\n} from \"../utils/date-formatter\";\nimport { mapThenable } from \"../utils/map-thenable\";\n\n/**\n * The locale every real-world date is formatted in.\n *\n * Signed-in shells pass the request's session promise: the provider maps it to\n * the `Accept-Language` header once and never awaits it, so its children render\n * at once; only `useDateLocale()` callers suspend until it settles (the shape of\n * `ViewportProvider`). Public layouts pass `mode=\"public\"`: the app language,\n * with all-numeric styles spelled out. Without a provider: the app language.\n *\n * THIS LIVES IN `contexts/` for the same reason as `ViewportProvider`: the\n * server layouts render it directly, so it needs the \"use client\" boundary that\n * tsup stamps onto `dist/contexts/*`.\n */\nexport type DateLocaleSource = { mode: \"session\"; acceptLanguage: Promise<string | undefined> } | { mode: \"public\" };\n\nconst DateLocaleContext = React.createContext<DateLocaleSource | null>(null);\n\nexport function DateLocaleProvider(\n props:\n | { session: Promise<SessionSnapshot>; mode?: \"session\"; children: React.ReactNode }\n | { mode: \"public\"; session?: never; children: React.ReactNode },\n) {\n const { session, children } = props;\n const value = React.useMemo<DateLocaleSource>(\n () =>\n props.mode === \"public\" || !session\n ? { mode: \"public\" }\n : { mode: \"session\", acceptLanguage: mapThenable(session, (snapshot) => snapshot.acceptLanguage) },\n // Created once, like ViewportProvider's seed.\n [],\n );\n\n return <DateLocaleContext.Provider value={value}>{children}</DateLocaleContext.Provider>;\n}\n\n/** The provider's raw context value (mapped thenable + mode), read WITHOUT suspending — for re-providing it to a tree rendered outside the provider (sonner toasts). */\nexport function useDateLocaleSource(): DateLocaleSource | null {\n return React.useContext(DateLocaleContext);\n}\n\nexport function DateLocaleSourceProvider({\n value,\n children,\n}: {\n value: DateLocaleSource | null;\n children: React.ReactNode;\n}) {\n return <DateLocaleContext.Provider value={value}>{children}</DateLocaleContext.Provider>;\n}\n\nexport type DateLocale = { locale: string; isPublic: boolean };\n\n/** Suspends on the session (put the caller behind its own `<Suspense>`) when a session provider is above it. */\nexport function useDateLocale(): DateLocale {\n const source = React.useContext(DateLocaleContext);\n const appLocale = useI18nLocale();\n const acceptLanguage = source?.mode === \"session\" ? React.use(source.acceptLanguage) : undefined;\n const isPublic = source?.mode === \"public\";\n const locale = source?.mode === \"session\" ? resolveDateLocale({ appLocale, acceptLanguage }) : appLocale;\n\n return React.useMemo(() => ({ locale, isPublic }), [locale, isPublic]);\n}\n\nexport type DateFormatter = DateLocale & {\n format(date: Date | string | undefined, style: DateFormatStyle, options?: { timeZone?: string }): string;\n relative(date: Date | string, options: { now: Date }): string;\n twelveHourClock: boolean;\n};\n\nexport function useDateFormatter(): DateFormatter {\n const { locale, isPublic } = useDateLocale();\n\n return React.useMemo<DateFormatter>(\n () => ({\n locale,\n isPublic,\n format: (date, style, options) => formatDateStyle({ date, style, locale, timeZone: options?.timeZone, isPublic }),\n relative: (date, options) => formatRelativeDate({ date, locale, now: options.now }),\n twelveHourClock: usesTwelveHourClock(locale),\n }),\n [locale, isPublic],\n );\n}\n\n/** undefined on the server render and the first client render; the current time after mount (set in useEffect). */\nexport function useMountedNow(): Date | undefined {\n const [now, setNow] = React.useState<Date | undefined>(undefined);\n React.useEffect(() => {\n setNow(new Date());\n }, []);\n return now;\n}\n","/**\n * Derives a native Promise from a thenable.\n *\n * A promise passed from a Server Component to a Client Component arrives as\n * React's deserialised chunk. It inherits from Promise.prototype, but its\n * `then()` only registers callbacks and returns undefined, so\n * `session.then(fn)` yields undefined and `Promise.resolve(session)` hands the\n * same chunk back. Wrapping it in `new Promise` adopts it and gives a real\n * promise to chain, store in context or pass to `use()`.\n */\nexport function mapThenable<T, R>(thenable: PromiseLike<T>, map: (value: T) => R): Promise<R> {\n return new Promise<R>((resolve, reject) => {\n thenable.then((value) => resolve(map(value)), reject);\n });\n}\n"]}
@@ -2,7 +2,7 @@ import {
2
2
  DataClassRegistry,
3
3
  hasBootstrapper,
4
4
  tryBootstrap
5
- } from "./chunk-YMCL3JXZ.mjs";
5
+ } from "./chunk-YPBIPE2B.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-PAWJFY3S.mjs";
@@ -286,66 +286,6 @@ var AbstractApiData = class _AbstractApiData {
286
286
  }
287
287
  };
288
288
 
289
- // src/i18n/config.ts
290
- var _config = null;
291
- function configureI18n(config) {
292
- _config = config;
293
- }
294
- __name(configureI18n, "configureI18n");
295
- function useI18nRouter() {
296
- if (!_config?.useRouter) {
297
- throw new Error("i18n not configured. Call configureI18n() at app startup.");
298
- }
299
- return _config.useRouter();
300
- }
301
- __name(useI18nRouter, "useI18nRouter");
302
- function useI18nTranslations(namespace) {
303
- if (!_config?.useTranslations) {
304
- return (key) => key;
305
- }
306
- return _config.useTranslations(namespace);
307
- }
308
- __name(useI18nTranslations, "useI18nTranslations");
309
- function getI18nLink() {
310
- if (!_config?.Link) {
311
- throw new Error("i18n not configured. Call configureI18n() at app startup.");
312
- }
313
- return _config.Link;
314
- }
315
- __name(getI18nLink, "getI18nLink");
316
- function useI18nLocale() {
317
- if (_config?.useLocale) {
318
- return _config.useLocale();
319
- }
320
- return "en";
321
- }
322
- __name(useI18nLocale, "useI18nLocale");
323
- async function getI18nServerLocale() {
324
- if (!_config?.getLocale) {
325
- throw new Error("i18n not configured. Call configureI18n() with getLocale at app startup.");
326
- }
327
- return _config.getLocale();
328
- }
329
- __name(getI18nServerLocale, "getI18nServerLocale");
330
- function useI18nDateFnsLocale() {
331
- if (_config?.useDateFnsLocale) {
332
- return _config.useDateFnsLocale();
333
- }
334
- return void 0;
335
- }
336
- __name(useI18nDateFnsLocale, "useI18nDateFnsLocale");
337
- function getI18nSupportedLocales() {
338
- if (_config?.supportedLocales && _config.supportedLocales.length > 0) {
339
- return _config.supportedLocales;
340
- }
341
- return ["en"];
342
- }
343
- __name(getI18nSupportedLocales, "getI18nSupportedLocales");
344
- function getI18nDefaultLocale() {
345
- return getI18nSupportedLocales()[0];
346
- }
347
- __name(getI18nDefaultLocale, "getI18nDefaultLocale");
348
-
349
289
  // src/core/registry/ModuleRegistry.ts
350
290
  var MODULES_KEY = /* @__PURE__ */ Symbol.for("nextjs-jsonapi:modules");
351
291
  var globalStore = globalThis;
@@ -581,19 +521,10 @@ var RootSync = class extends AbstractApiData {
581
521
  export {
582
522
  RehydrationFactory,
583
523
  AbstractApiData,
584
- configureI18n,
585
- useI18nRouter,
586
- useI18nTranslations,
587
- getI18nLink,
588
- useI18nLocale,
589
- getI18nServerLocale,
590
- useI18nDateFnsLocale,
591
- getI18nSupportedLocales,
592
- getI18nDefaultLocale,
593
524
  ModuleRegistry,
594
525
  Modules,
595
526
  EndpointCreator,
596
527
  ROOT_SYNC_ENDPOINT,
597
528
  RootSync
598
529
  };
599
- //# sourceMappingURL=chunk-N2BFT7KI.mjs.map
530
+ //# sourceMappingURL=chunk-W7U6O3OE.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/factories/RehydrationFactory.ts","../src/core/abstracts/AbstractApiData.ts","../src/core/registry/ModuleRegistry.ts","../src/core/endpoint/EndpointCreator.ts","../src/offline/sync/models/RootSync.ts"],"sourcesContent":["import { ApiDataInterface } from \"../interfaces/ApiDataInterface\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\nimport { JsonApiHydratedDataInterface } from \"../interfaces/JsonApiHydratedDataInterface\";\nimport { DataClassRegistry } from \"../registry/DataClassRegistry\";\n\n/**\n * The resources being rehydrated right now, along the current chain of relationships. A resource\n * met again inside its own chain (A's relationship leads to B, B's back to A) is a circle in the\n * `included` data: following it would recurse until the stack overflows, so it is skipped there.\n */\nconst inProgress = new Set<string>();\n\n/**\n * The included resources already rehydrated during the current top-level `rehydrate` /\n * `rehydrateList` call, by model class and `type:id`, with the `included` array they were read from.\n * A resource reached again through another relationship reuses that model instead of being built\n * again: without it every distinct path through a densely linked `included` (a campaign, its PCs,\n * their locations, the scenes there, back to the campaign...) is rehydrated, which grows\n * exponentially with the number of linked resources. A reused model keeps what it read the first\n * time, so a relationship back to a resource that was mid-rehydration then stays unset.\n * The top-level resources are always rehydrated from scratch, so each one is complete.\n */\nlet built: Map<unknown, Map<string, { included: unknown; model: unknown }>> | undefined;\nlet depth = 0;\n\nconst keyOf = (data: JsonApiHydratedDataInterface): string | undefined => {\n const resource = data?.jsonApi;\n return resource?.type && resource?.id ? `${resource.type}:${resource.id}` : undefined;\n};\n\nfunction session<T>(run: () => T): T {\n const outermost = depth === 0;\n if (outermost) built = new Map();\n depth++;\n try {\n return run();\n } finally {\n depth--;\n if (outermost) built = undefined;\n }\n}\n\nfunction guarded<T>(factoryClass: unknown, data: JsonApiHydratedDataInterface, run: () => T): T {\n const key = keyOf(data);\n if (!key) return run();\n if (inProgress.has(key)) return undefined as T;\n\n if (inProgress.size > 0) {\n const previous = built?.get(factoryClass)?.get(key);\n if (previous && previous.included === data.included) return previous.model as T;\n }\n\n inProgress.add(key);\n try {\n const model = run();\n if (built) {\n let byKey = built.get(factoryClass);\n if (!byKey) {\n byKey = new Map();\n built.set(factoryClass, byKey);\n }\n byKey.set(key, { included: data.included, model });\n }\n return model;\n } finally {\n inProgress.delete(key);\n }\n}\n\nexport class RehydrationFactory {\n public static rehydrate<T extends ApiDataInterface>(\n classKey: ApiRequestDataTypeInterface,\n data: JsonApiHydratedDataInterface,\n ): T {\n const factoryClass = DataClassRegistry.get(classKey);\n\n return session(() => guarded(factoryClass, data, () => new factoryClass().rehydrate(data) as T));\n }\n\n public static rehydrateList<T extends ApiDataInterface>(\n classKey: ApiRequestDataTypeInterface,\n data: JsonApiHydratedDataInterface[],\n ): T[] {\n const factoryClass = DataClassRegistry.get(classKey);\n\n return session(() =>\n data.map((item: JsonApiHydratedDataInterface) =>\n guarded(factoryClass, item, () => new factoryClass().rehydrate(item) as T),\n ),\n );\n }\n}\n","import { RehydrationFactory } from \"../factories/RehydrationFactory\";\nimport { ApiDataInterface } from \"../interfaces/ApiDataInterface\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\nimport { JsonApiHydratedDataInterface } from \"../interfaces/JsonApiHydratedDataInterface\";\n\nexport abstract class AbstractApiData implements ApiDataInterface {\n static identifierFields: string[] = [\"name\"];\n\n get identifier(): string {\n const fields = (this.constructor as typeof AbstractApiData).identifierFields;\n return fields\n .map((field) => this._jsonApi?.attributes?.[field])\n .filter((v) => v != null && v !== \"\")\n .join(\" \");\n }\n\n protected _jsonApi?: any;\n protected _included?: any[];\n\n protected _id?: string;\n protected _type?: string;\n protected _createdAt?: Date;\n protected _updatedAt?: Date;\n\n protected _self?: string;\n\n get type(): string {\n if (!this._type) throw new Error(\"Type is not set.\");\n return this._type;\n }\n\n get id(): string {\n if (!this._id) throw new Error(\"Id is not set.\");\n return this._id;\n }\n\n get self(): string | undefined {\n return this._self;\n }\n\n get createdAt(): Date {\n return this._createdAt ?? new Date();\n }\n\n get updatedAt(): Date {\n return this._updatedAt ?? new Date();\n }\n\n get included(): any[] {\n return this._included ?? [];\n }\n\n get jsonApi(): any {\n return this._jsonApi;\n }\n\n ingestJsonApi(_data: JsonApiHydratedDataInterface): void {}\n\n generateApiUrl(_params?: any): string {\n throw new Error(\"Method not implemented.\");\n }\n\n createJsonApi(_data?: any): any {\n throw new Error(\"Method not implemented.\");\n }\n\n protected _readIncluded<T extends ApiDataInterface>(\n data: JsonApiHydratedDataInterface,\n type: string,\n dataType: ApiRequestDataTypeInterface,\n ): T | T[] | undefined {\n if (\n data.included === undefined ||\n data.included.length === 0 ||\n data.jsonApi.relationships === undefined ||\n data.jsonApi.relationships[type] === undefined ||\n data.jsonApi.relationships[type].data === undefined\n ) {\n return undefined;\n }\n\n if (Array.isArray(data.jsonApi.relationships[type].data)) {\n const response: T[] = data.jsonApi.relationships[type].data.map((jsonApiData: any) => {\n const includedData = data.included.find(\n (includedData: any) => includedData.id === jsonApiData.id && includedData.type === jsonApiData.type,\n );\n\n if (includedData === undefined) return undefined;\n\n return RehydrationFactory.rehydrate(dataType, {\n jsonApi: includedData,\n included: data.included,\n }) as T;\n });\n\n return response.filter((item: T | undefined) => item !== undefined) as T[];\n }\n\n const includedData = data.included.find(\n (includedData: any) =>\n includedData.id === data.jsonApi.relationships[type].data.id &&\n includedData.type === data.jsonApi.relationships[type].data.type,\n );\n\n if (includedData === undefined && data.allData !== undefined) {\n // Try to find in allData as a fallback\n const fallbackData = data.allData.find(\n (includedData: any) =>\n includedData.id === data.jsonApi.relationships[type].data.id &&\n includedData.type === data.jsonApi.relationships[type].data.type,\n );\n if (fallbackData !== undefined) {\n return RehydrationFactory.rehydrate(dataType, {\n jsonApi: fallbackData,\n included: data.included,\n }) as T;\n }\n }\n\n if (includedData === undefined) return undefined;\n\n return RehydrationFactory.rehydrate(dataType, {\n jsonApi: includedData,\n included: data.included,\n }) as T;\n }\n\n /**\n * Read included relationships with polymorphic type resolution.\n * Determines the correct model class based on the JSON:API type in included data.\n */\n protected _readIncludedPolymorphic<T extends ApiDataInterface>(\n data: JsonApiHydratedDataInterface,\n relationshipKey: string,\n candidateModules: ApiRequestDataTypeInterface[],\n ): T | T[] | undefined {\n // Validate relationship exists\n if (!data.included?.length || !data.jsonApi.relationships?.[relationshipKey]?.data) {\n return undefined;\n }\n\n const relData = data.jsonApi.relationships[relationshipKey].data;\n\n // Build lookup map: JSON:API type -> module\n const typeToModule = new Map<string, ApiRequestDataTypeInterface>();\n for (const mod of candidateModules) {\n typeToModule.set(mod.name, mod);\n }\n\n if (Array.isArray(relData)) {\n // Many relationship\n const result: T[] = [];\n for (const item of relData) {\n const includedItem = data.included.find((inc: any) => inc.id === item.id && inc.type === item.type);\n if (!includedItem) continue;\n\n // Resolve module by JSON:API type\n const module = typeToModule.get(includedItem.type);\n if (!module) continue;\n\n result.push(\n RehydrationFactory.rehydrate(module, {\n jsonApi: includedItem,\n included: data.included,\n }) as T,\n );\n }\n return result.length > 0 ? result : undefined;\n }\n\n // Single relationship\n const includedItem = data.included.find((inc: any) => inc.id === relData.id && inc.type === relData.type);\n if (!includedItem) return undefined;\n\n const module = typeToModule.get(includedItem.type);\n if (!module) return undefined;\n\n return RehydrationFactory.rehydrate(module, {\n jsonApi: includedItem,\n included: data.included,\n }) as T;\n }\n\n /**\n * Read included relationship data and augment with relationship meta properties.\n * Handles both single relationships (one-to-one) and array relationships (one-to-many).\n *\n * For single relationships: meta is read from `relationships[type].meta`\n * For array relationships: per-item meta is read from `relationships[type].data[].meta`\n *\n * @param data - Hydrated JSON:API data\n * @param type - Relationship type key (e.g., \"guide\", \"persons\")\n * @param dataType - Module reference for rehydration\n * @returns Related object(s) augmented with meta properties, or undefined\n */\n protected _readIncludedWithMeta<T extends ApiDataInterface, M extends Record<string, any>>(\n data: JsonApiHydratedDataInterface,\n type: string,\n dataType: ApiRequestDataTypeInterface,\n ): (T & M) | (T & M)[] | undefined {\n // Check if relationship exists\n if (\n data.included === undefined ||\n data.included.length === 0 ||\n data.jsonApi.relationships === undefined ||\n data.jsonApi.relationships[type] === undefined ||\n data.jsonApi.relationships[type].data === undefined\n ) {\n return undefined;\n }\n\n const relationshipData = data.jsonApi.relationships[type].data;\n\n // Handle array relationships with per-item meta\n if (Array.isArray(relationshipData)) {\n const result: (T & M)[] = [];\n\n for (const item of relationshipData) {\n const includedData = data.included.find((inc: any) => inc.id === item.id && inc.type === item.type);\n\n if (!includedData) continue;\n\n const entity = RehydrationFactory.rehydrate(dataType, {\n jsonApi: includedData,\n included: data.included,\n }) as T;\n\n // Merge per-item meta from relationships[type].data[].meta\n if (item.meta) {\n AbstractApiData._mergeMeta(entity, item.meta);\n }\n\n result.push(entity as T & M);\n }\n\n return result;\n }\n\n // Handle single relationship\n const includedData = data.included.find(\n (inc: any) => inc.id === relationshipData.id && inc.type === relationshipData.type,\n );\n\n if (!includedData) {\n // Try to find in allData as a fallback\n if (data.allData !== undefined) {\n const fallbackData = data.allData.find(\n (inc: any) => inc.id === relationshipData.id && inc.type === relationshipData.type,\n );\n if (fallbackData) {\n const entity = RehydrationFactory.rehydrate(dataType, {\n jsonApi: fallbackData,\n included: data.included,\n }) as T;\n\n // Merge relationship-level meta for single relationships\n const relationshipMeta = data.jsonApi.relationships[type].meta;\n if (relationshipMeta) {\n AbstractApiData._mergeMeta(entity, relationshipMeta);\n }\n return entity as T & M;\n }\n }\n return undefined;\n }\n\n const entity = RehydrationFactory.rehydrate(dataType, {\n jsonApi: includedData,\n included: data.included,\n }) as T;\n\n // Merge relationship-level meta for single relationships\n const relationshipMeta = data.jsonApi.relationships[type].meta;\n if (relationshipMeta) {\n AbstractApiData._mergeMeta(entity, relationshipMeta);\n }\n\n return entity as T & M;\n }\n\n /**\n * Copies relationship meta onto a rehydrated entity as own data properties. Object.assign throws\n * when the model declares a getter-only accessor of the same name (an app's `Chunk` with\n * `get relevance()`); an own property shadows that getter, so the model reads the meta value.\n */\n private static _mergeMeta(entity: object, meta: Record<string, any>): void {\n for (const [key, value] of Object.entries(meta)) {\n Object.defineProperty(entity, key, { value, writable: true, enumerable: true, configurable: true });\n }\n }\n\n dehydrate(): JsonApiHydratedDataInterface {\n return {\n jsonApi: this._jsonApi,\n included: this._included ?? [],\n };\n }\n\n rehydrate(data: JsonApiHydratedDataInterface): this {\n this._jsonApi = data.jsonApi;\n this._included = data.included;\n\n this._type = this._jsonApi.type;\n this._id = this._jsonApi.id;\n this._createdAt = this._jsonApi.meta?.createdAt !== undefined ? new Date(this._jsonApi.meta.createdAt) : undefined;\n this._updatedAt = this._jsonApi.meta?.updatedAt !== undefined ? new Date(this._jsonApi.meta.updatedAt) : undefined;\n\n this._self = this._jsonApi.links?.self ?? undefined;\n\n return this;\n }\n}\n","import { ModuleWithPermissions } from \"../../permissions/types\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\nimport { hasBootstrapper, tryBootstrap } from \"./bootstrapStore\";\n\n// Foundation module types - defined by LIBRARY\nexport interface FoundationModuleDefinitions {\n S3: ModuleWithPermissions;\n Auth: ModuleWithPermissions;\n User: ModuleWithPermissions;\n Author: ModuleWithPermissions;\n Company: ModuleWithPermissions;\n Role: ModuleWithPermissions;\n Notification: ModuleWithPermissions;\n Push: ModuleWithPermissions;\n Feature: ModuleWithPermissions;\n Module: ModuleWithPermissions;\n Content: ModuleWithPermissions;\n HowTo: ModuleWithPermissions;\n HandbookPage: ModuleWithPermissions;\n HandbookSection: ModuleWithPermissions;\n HandbookThread: ModuleWithPermissions;\n HandbookThreadMessage: ModuleWithPermissions;\n Assistant: ModuleWithPermissions;\n AssistantMessage: ModuleWithPermissions;\n AssistantAction: ModuleWithPermissions;\n Chunk: ModuleWithPermissions;\n // Billing modules - READ: all users, UPDATE: CompanyAdministrator, ADMIN: Administrator\n Billing: ModuleWithPermissions;\n StripeCustomer: ModuleWithPermissions;\n StripePaymentMethod: ModuleWithPermissions;\n StripeSubscription: ModuleWithPermissions;\n StripeInvoice: ModuleWithPermissions;\n StripeProduct: ModuleWithPermissions;\n StripePrice: ModuleWithPermissions;\n StripeUsage: ModuleWithPermissions;\n StripePromotionCode: ModuleWithPermissions;\n StripeCoupon: ModuleWithPermissions;\n StripeCouponCode: ModuleWithPermissions;\n StripeCouponOffer: ModuleWithPermissions;\n // AI connection administration\n AiConnection: ModuleWithPermissions;\n // OAuth modules\n OAuth: ModuleWithPermissions;\n // Waitlist modules\n Waitlist: ModuleWithPermissions;\n WaitlistStats: ModuleWithPermissions;\n // Email automation modules\n EmailAutomation: ModuleWithPermissions;\n EmailAutomationStep: ModuleWithPermissions;\n EmailAutomationEnrollment: ModuleWithPermissions;\n EmailAutomationTrigger: ModuleWithPermissions;\n EmailAutomationCandidate: ModuleWithPermissions;\n // Email blast modules\n EmailBlast: ModuleWithPermissions;\n EmailBlastDelivery: ModuleWithPermissions;\n EmailBlastAudience: ModuleWithPermissions;\n // Blog modules\n BlogPost: ModuleWithPermissions;\n BlogPostTranslation: ModuleWithPermissions;\n BlogCategory: ModuleWithPermissions;\n BlogCategoryTranslation: ModuleWithPermissions;\n BlogSettings: ModuleWithPermissions;\n // Referral modules\n Referral: ModuleWithPermissions;\n ReferralStats: ModuleWithPermissions;\n // Referral link visits and the administrative referral report (opt-in: registered by apps that spread referralAdminModules)\n ReferralVisit: ModuleWithPermissions;\n ReferralAdminSummary: ModuleWithPermissions;\n ReferralAdminReferrer: ModuleWithPermissions;\n ReferralAdminReferral: ModuleWithPermissions;\n // Two-factor authentication modules\n TotpAuthenticator: ModuleWithPermissions;\n TotpSetup: ModuleWithPermissions;\n TotpVerify: ModuleWithPermissions;\n TotpVerifyLogin: ModuleWithPermissions;\n Passkey: ModuleWithPermissions;\n PasskeyRegistrationOptions: ModuleWithPermissions;\n PasskeyRegistrationVerify: ModuleWithPermissions;\n PasskeyRename: ModuleWithPermissions;\n PasskeyVerifyLogin: ModuleWithPermissions;\n PasskeyAuthenticationOptions: ModuleWithPermissions;\n TwoFactorEnable: ModuleWithPermissions;\n TwoFactorChallenge: ModuleWithPermissions;\n TwoFactorStatus: ModuleWithPermissions;\n BackupCodeVerify: ModuleWithPermissions;\n // OAuth sign-up awaiting consent\n PendingRegistration: ModuleWithPermissions;\n // RBAC modules\n PermissionMapping: ModuleWithPermissions;\n ModulePaths: ModuleWithPermissions;\n RbacMatrix: ModuleWithPermissions;\n // Audit modules\n AuditLog: ModuleWithPermissions;\n // Administrative token-usage reporting modules\n TokenUsageAdminSummary: ModuleWithPermissions;\n TokenUsageAdminTimeline: ModuleWithPermissions;\n TokenUsageAdminBreakdown: ModuleWithPermissions;\n // Self-service token-usage reporting modules\n TokenUsageReportSummary: ModuleWithPermissions;\n TokenUsageReportTimeline: ModuleWithPermissions;\n TokenUsageReportBreakdown: ModuleWithPermissions;\n // First-party web analytics modules (tracker + administrative dashboard)\n AnalyticsEvent: ModuleWithPermissions;\n AnalyticsSummary: ModuleWithPermissions;\n AnalyticsTimeline: ModuleWithPermissions;\n AnalyticsDailyUniqueTimeline: ModuleWithPermissions;\n AnalyticsBreakdown: ModuleWithPermissions;\n AnalyticsSession: ModuleWithPermissions;\n AnalyticsPageView: ModuleWithPermissions;\n // Account deletion (opt-in: registered only by apps that enable it)\n AccountDeletion: ModuleWithPermissions;\n // Discord connect (registered by apps that offer it)\n DiscordConnection: ModuleWithPermissions;\n DiscordConnectIntent: ModuleWithPermissions;\n DiscordConnectConfirmation: ModuleWithPermissions;\n // Offline mode (opt-in: registered by apps that spread offlineModules)\n OfflineChangeSet: ModuleWithPermissions;\n RootSync: ModuleWithPermissions;\n}\n\n// App-specific modules - apps will augment this interface ONLY\n\nexport interface AppModuleDefinitions {}\n\n// Combined type for full autocompletion\nexport type ModuleDefinitions = FoundationModuleDefinitions & AppModuleDefinitions;\n\n// Symbol key to avoid conflicts with other globals\nconst MODULES_KEY = Symbol.for(\"nextjs-jsonapi:modules\");\n\n// Use globalThis to persist module registry across HMR reloads\nconst globalStore = globalThis as unknown as {\n [MODULES_KEY]?: Map<string, ApiRequestDataTypeInterface>;\n};\n\n// Initialize global modules map if not set\nif (!globalStore[MODULES_KEY]) {\n globalStore[MODULES_KEY] = new Map();\n}\n\nclass ModuleRegistryClass {\n private get _modules(): Map<string, ApiRequestDataTypeInterface> {\n return globalStore[MODULES_KEY]!;\n }\n\n register<K extends string>(name: K, module: ApiRequestDataTypeInterface): void {\n this._modules.set(name, module);\n }\n\n get<K extends keyof ModuleDefinitions>(name: K): ModuleDefinitions[K] {\n let module = this._modules.get(name as string);\n\n // Self-healing: if module not found, try bootstrapping first\n if (!module) {\n const didBootstrap = tryBootstrap();\n if (didBootstrap) {\n // Retry after bootstrap\n module = this._modules.get(name as string);\n }\n }\n\n if (!module) {\n // Provide helpful error message based on state\n const hint = hasBootstrapper()\n ? \"Bootstrap was called but module still not found. Check module registration.\"\n : \"No bootstrapper registered. Ensure configureJsonApi({ bootstrapper }) is called before accessing modules.\";\n throw new Error(`Module \"${String(name)}\" not registered. ${hint}`);\n }\n\n return module as ModuleDefinitions[K];\n }\n\n /**\n * True when a module is registered under `name`. Never throws, so a component\n * can check for an opt-in module the app may not have registered.\n */\n has(name: string): boolean {\n // Bootstrap only an empty registry (as findByName does): an app that never\n // registers `name` must not re-run its bootstrapper on every check.\n if (this._modules.size === 0) tryBootstrap();\n return this._modules.has(name);\n }\n\n findByName(moduleName: string): ModuleWithPermissions {\n // Self-healing: try bootstrap if registry is empty\n if (this._modules.size === 0) {\n tryBootstrap();\n }\n\n // Search by module's name property (e.g., \"topics\", \"articles\")\n for (const module of this._modules.values()) {\n if ((module as ModuleWithPermissions).name === moduleName) {\n return module as ModuleWithPermissions;\n }\n }\n throw new Error(`Module not found: ${moduleName}`);\n }\n\n getAllPageUrls(): { id: string; text: string }[] {\n if (this._modules.size === 0) {\n tryBootstrap();\n }\n\n const seen = new Set<string>();\n const result: { id: string; text: string }[] = [];\n for (const [key, module] of this._modules.entries()) {\n const m = module as ModuleWithPermissions;\n if (m.pageUrl && !seen.has(m.pageUrl)) {\n seen.add(m.pageUrl);\n result.push({ id: m.pageUrl, text: key });\n result.push({ id: `${m.pageUrl}/:id`, text: `${key} (detail)` });\n }\n }\n return result.sort((a, b) => a.text.localeCompare(b.text));\n }\n\n findByModelName(modelName: string): ModuleWithPermissions {\n // Direct lookup by registry key (e.g., \"Article\", \"Document\")\n let module = this._modules.get(modelName);\n\n // Self-healing: if not found, try bootstrapping\n if (!module) {\n const didBootstrap = tryBootstrap();\n if (didBootstrap) {\n module = this._modules.get(modelName);\n }\n }\n\n if (!module) {\n throw new Error(`Module not found for model: ${modelName}`);\n }\n return module as ModuleWithPermissions;\n }\n\n findByFeature(feature: string): ModuleWithPermissions[] {\n const response: ModuleWithPermissions[] = [];\n\n for (const module of this._modules.values()) {\n const m = module as ModuleWithPermissions;\n if (m.feature === feature) {\n response.push(m);\n }\n }\n\n return response;\n }\n\n getAll(): ApiRequestDataTypeInterface[] {\n if (this._modules.size === 0) {\n tryBootstrap();\n }\n return Array.from(this._modules.values());\n }\n}\n\nexport const ModuleRegistry = new ModuleRegistryClass();\n\n// Proxy object for Modules.X syntax with autocompletion\nexport const Modules = new Proxy({} as ModuleDefinitions, {\n get(_, prop: string) {\n if (prop === \"findByName\") {\n return (name: string) => ModuleRegistry.findByName(name);\n }\n if (prop === \"findByModelName\") {\n return (name: string) => ModuleRegistry.findByModelName(name);\n }\n if (prop === \"findByFeature\") {\n return (feature: string) => ModuleRegistry.findByFeature(feature);\n }\n return ModuleRegistry.get(prop as keyof ModuleDefinitions);\n },\n}) as ModuleDefinitions & {\n findByName: (name: string) => ModuleWithPermissions;\n findByModelName: (name: string) => ModuleWithPermissions;\n findByFeature: (feature: string) => ModuleWithPermissions[];\n};\n","import { FieldSelector } from \"../fields/FieldSelector\";\nimport { ApiRequestDataTypeInterface } from \"../interfaces/ApiRequestDataTypeInterface\";\n\nexport type EndpointQuery = {\n endpoint: ApiRequestDataTypeInterface | string;\n id?: string;\n childEndpoint?: ApiRequestDataTypeInterface | string;\n childId?: string;\n additionalParams?: { key: string; value: string | string[] }[];\n};\n\nexport class EndpointCreator {\n private _endpoint: EndpointQuery;\n\n constructor(params: {\n endpoint: ApiRequestDataTypeInterface | string;\n id?: string;\n childEndpoint?: ApiRequestDataTypeInterface | string;\n childId?: string;\n additionalParams?: { key: string; value: string }[];\n }) {\n this._endpoint = {\n endpoint: params.endpoint,\n id: params.id,\n childEndpoint: params.childEndpoint,\n childId: params.childId,\n additionalParams: params.additionalParams ?? [],\n };\n }\n\n endpoint(value: ApiRequestDataTypeInterface | string): EndpointCreator {\n this._endpoint.endpoint = value;\n return this;\n }\n\n id(value: string): EndpointCreator {\n this._endpoint.id = value;\n return this;\n }\n\n childEndpoint(value: ApiRequestDataTypeInterface | string): EndpointCreator {\n this._endpoint.childEndpoint = value;\n return this;\n }\n\n childId(value: string): EndpointCreator {\n this._endpoint.childId = value;\n return this;\n }\n\n set additionalParams(value: { key: string; value: string }[]) {\n this._endpoint.additionalParams = value;\n }\n\n addAdditionalParam(key: string, value: string | string[]): EndpointCreator {\n if (!this._endpoint.additionalParams) this._endpoint.additionalParams = [];\n this._endpoint.additionalParams.push({ key, value });\n return this;\n }\n\n limitToType(selectors: string[]): this {\n this.addAdditionalParam(`include`, selectors.join(\",\"));\n return this;\n }\n\n limitToFields(selectors: FieldSelector<any>[]): this {\n if (selectors.length === 0) return this;\n\n selectors.forEach((selector) => {\n const fieldString = selector.fields.join(\",\");\n this.addAdditionalParam(`fields[${selector.type}]`, fieldString);\n });\n\n return this;\n }\n\n generate(): string {\n let additionalParams = \"\";\n if (this._endpoint.additionalParams) {\n additionalParams = this._endpoint.additionalParams.map((param) => `${param.key}=${param.value}`).join(\"&\");\n }\n\n let response = ``;\n response += `${\n typeof this._endpoint.endpoint === \"string\" ? this._endpoint.endpoint : this._endpoint.endpoint.name\n }`;\n if (this._endpoint.id) response += `/${this._endpoint.id}`;\n if (this._endpoint.childEndpoint) {\n response += `/${\n typeof this._endpoint.childEndpoint === \"string\"\n ? this._endpoint.childEndpoint\n : this._endpoint.childEndpoint.name\n }`;\n }\n if (this._endpoint.childId) response += `/${this._endpoint.childId}`;\n if (additionalParams) response += `?${additionalParams}`;\n\n return response;\n }\n}\n","import { AbstractApiData } from \"../../../core/abstracts/AbstractApiData\";\nimport { JsonApiHydratedDataInterface } from \"../../../core/interfaces/JsonApiHydratedDataInterface\";\nimport { RootSyncEntry, RootSyncInterface, RootSyncLink } from \"./RootSyncInterface\";\n\n/**\n * Child path of the sync answer under the root module record\n * (`GET /<root endpoint>/:id/sync`), the same value as the app API's sync meta endpoint\n * (in Wyrdli, `campaignSyncMeta.endpoint`).\n */\nexport const ROOT_SYNC_ENDPOINT = \"sync\";\n\n/** The sync answer for one root record (`root-syncs`, id = root record id). Read-only. */\nexport class RootSync extends AbstractApiData implements RootSyncInterface {\n private _serverTime?: Date;\n private _locked: boolean = false;\n private _lockedFrom?: Date;\n private _entries?: RootSyncEntry[];\n private _links?: RootSyncLink[];\n\n get serverTime(): Date {\n if (!this._serverTime) throw new Error(\"serverTime is not set.\");\n return this._serverTime;\n }\n\n get locked(): boolean {\n return this._locked;\n }\n\n get lockedFrom(): Date | undefined {\n return this._lockedFrom;\n }\n\n get entries(): RootSyncEntry[] {\n return this._entries ?? [];\n }\n\n get links(): RootSyncLink[] {\n return this._links ?? [];\n }\n\n rehydrate(data: JsonApiHydratedDataInterface): this {\n super.rehydrate(data);\n\n const attributes = data.jsonApi.attributes ?? {};\n this._serverTime = attributes.serverTime ? new Date(attributes.serverTime) : undefined;\n this._locked = Boolean(attributes.locked);\n this._lockedFrom = attributes.lockedFrom ? new Date(attributes.lockedFrom) : undefined;\n this._entries = (attributes.entries ?? []).map((entry: { type: string; id: string; updatedAt: string }) => ({\n type: entry.type,\n id: entry.id,\n updatedAt: new Date(entry.updatedAt),\n }));\n this._links = (attributes.links ?? []).map((link: RootSyncLink) => ({\n fromType: link.fromType,\n fromId: link.fromId,\n toType: link.toType,\n toId: link.toId,\n kind: link.kind,\n props: link.props ?? {},\n }));\n\n return this;\n }\n\n createJsonApi(_data?: any): any {\n throw new Error(\"RootSync is read-only and cannot be created\");\n }\n}\n"],"mappings":";;;;;;;;;;AAUA,IAAM,aAAa,oBAAI,IAAY;AAYnC,IAAI;AACJ,IAAI,QAAQ;AAEZ,IAAM,QAAQ,wBAAC,SAA2D;AACxE,QAAM,WAAW,MAAM;AACvB,SAAO,UAAU,QAAQ,UAAU,KAAK,GAAG,SAAS,IAAI,IAAI,SAAS,EAAE,KAAK;AAC9E,GAHc;AAKd,SAAS,QAAW,KAAiB;AACnC,QAAM,YAAY,UAAU;AAC5B,MAAI,UAAW,SAAQ,oBAAI,IAAI;AAC/B;AACA,MAAI;AACF,WAAO,IAAI;AAAA,EACb,UAAE;AACA;AACA,QAAI,UAAW,SAAQ;AAAA,EACzB;AACF;AAVS;AAYT,SAAS,QAAW,cAAuB,MAAoC,KAAiB;AAC9F,QAAM,MAAM,MAAM,IAAI;AACtB,MAAI,CAAC,IAAK,QAAO,IAAI;AACrB,MAAI,WAAW,IAAI,GAAG,EAAG,QAAO;AAEhC,MAAI,WAAW,OAAO,GAAG;AACvB,UAAM,WAAW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AAE;AACF,SAAK,UAAU,WAAW,SAAS,CAAC,GAAG,IAAI,CAAC,UAAwB;AAAA,MAClE,UAAU,KAAK;AAAA,MACf,QAAQ,KAAK;AAAA,MACb,QAAQ,KAAK;AAAA,MACb,MAAM,KAAK;AAAA,MACX,MAAM,KAAK;AAAA,MACX,OAAO,KAAK,SAAS,CAAC;AAAA,IACxB,EAAE;AAEF,WAAO;AAAA,EACT;AAAA,EAEA,cAAc,OAAkB;AAC9B,UAAM,IAAI,MAAM,6CAA6C;AAAA,EAC/D;AACF;","names":["includedData","includedItem","module","entity","relationshipMeta"]}
@@ -292,7 +292,7 @@ __name(getToken, "getToken");
292
292
  async function makeRequest(params) {
293
293
  if (typeof window !== "undefined") {
294
294
  if (!_directFetch) {
295
- const clientModule = await import("./request-4AWGPIGH.mjs");
295
+ const clientModule = await import("./request-6GAIWWTG.mjs");
296
296
  _directFetch = clientModule.directFetch;
297
297
  }
298
298
  return _directFetch({
@@ -522,4 +522,4 @@ export {
522
522
  JsonApiPatch,
523
523
  JsonApiDelete
524
524
  };
525
- //# sourceMappingURL=chunk-YMCL3JXZ.mjs.map
525
+ //# sourceMappingURL=chunk-YPBIPE2B.mjs.map