@bessemer/cornerstone 0.5.114 → 0.5.116

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 (247) hide show
  1. package/dist/array.d.ts.map +1 -1
  2. package/dist/array.js +28 -28
  3. package/dist/array.js.map +1 -1
  4. package/dist/aspect-ratio.d.ts +3 -3
  5. package/dist/aspect-ratio.d.ts.map +1 -1
  6. package/dist/aspect-ratio.js +13 -12
  7. package/dist/aspect-ratio.js.map +1 -1
  8. package/dist/assertion.d.ts.map +1 -1
  9. package/dist/assertion.js +5 -5
  10. package/dist/assertion.js.map +1 -1
  11. package/dist/async-value.js +2 -2
  12. package/dist/async-value.js.map +1 -1
  13. package/dist/async.d.ts.map +1 -1
  14. package/dist/async.js +2 -2
  15. package/dist/async.js.map +1 -1
  16. package/dist/cache.d.ts.map +1 -1
  17. package/dist/cache.js +11 -12
  18. package/dist/cache.js.map +1 -1
  19. package/dist/combinable.js +5 -5
  20. package/dist/combinable.js.map +1 -1
  21. package/dist/comparator.js +8 -8
  22. package/dist/comparator.js.map +1 -1
  23. package/dist/data-size.d.ts +2 -1
  24. package/dist/data-size.d.ts.map +1 -1
  25. package/dist/data-size.js +3 -3
  26. package/dist/data-size.js.map +1 -1
  27. package/dist/either.js +5 -5
  28. package/dist/either.js.map +1 -1
  29. package/dist/equalitor.d.ts.map +1 -1
  30. package/dist/equalitor.js +2 -2
  31. package/dist/equalitor.js.map +1 -1
  32. package/dist/error/error-cause.d.ts.map +1 -1
  33. package/dist/error/error-cause.js +14 -14
  34. package/dist/error/error-cause.js.map +1 -1
  35. package/dist/error/error-code.js +2 -2
  36. package/dist/error/error-code.js.map +1 -1
  37. package/dist/error/error-event.d.ts +3 -2
  38. package/dist/error/error-event.d.ts.map +1 -1
  39. package/dist/error/error-event.js +28 -28
  40. package/dist/error/error-event.js.map +1 -1
  41. package/dist/error/error-type.d.ts +2 -1
  42. package/dist/error/error-type.d.ts.map +1 -1
  43. package/dist/error/error-type.js +2 -2
  44. package/dist/error/error-type.js.map +1 -1
  45. package/dist/error/error.js +5 -5
  46. package/dist/error/error.js.map +1 -1
  47. package/dist/expression/array-expression.js +3 -3
  48. package/dist/expression/array-expression.js.map +1 -1
  49. package/dist/expression/core-expression.d.ts.map +1 -1
  50. package/dist/expression/core-expression.js +19 -19
  51. package/dist/expression/core-expression.js.map +1 -1
  52. package/dist/expression/expression-evaluator.js +2 -2
  53. package/dist/expression/expression-evaluator.js.map +1 -1
  54. package/dist/expression/expression-mapper.js +4 -4
  55. package/dist/expression/expression-mapper.js.map +1 -1
  56. package/dist/expression/internal.js +3 -3
  57. package/dist/expression/internal.js.map +1 -1
  58. package/dist/expression/numeric-expression.js +13 -13
  59. package/dist/expression/numeric-expression.js.map +1 -1
  60. package/dist/expression/string-expression.js +4 -4
  61. package/dist/expression/string-expression.js.map +1 -1
  62. package/dist/glob.d.ts +3 -3
  63. package/dist/glob.d.ts.map +1 -1
  64. package/dist/glob.js +11 -12
  65. package/dist/glob.js.map +1 -1
  66. package/dist/global-variable.d.ts.map +1 -1
  67. package/dist/global-variable.js +5 -5
  68. package/dist/global-variable.js.map +1 -1
  69. package/dist/hex-code.d.ts +3 -3
  70. package/dist/hex-code.d.ts.map +1 -1
  71. package/dist/hex-code.js +11 -10
  72. package/dist/hex-code.js.map +1 -1
  73. package/dist/index.d.ts +10 -0
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +4 -0
  76. package/dist/index.js.map +1 -1
  77. package/dist/intl/country-code.d.ts +3 -3
  78. package/dist/intl/country-code.d.ts.map +1 -1
  79. package/dist/intl/country-code.js +9 -10
  80. package/dist/intl/country-code.js.map +1 -1
  81. package/dist/intl/country-subdivision-code.d.ts +3 -3
  82. package/dist/intl/country-subdivision-code.d.ts.map +1 -1
  83. package/dist/intl/country-subdivision-code.js +13 -11
  84. package/dist/intl/country-subdivision-code.js.map +1 -1
  85. package/dist/intl/currency-code.d.ts +3 -3
  86. package/dist/intl/currency-code.d.ts.map +1 -1
  87. package/dist/intl/currency-code.js +9 -10
  88. package/dist/intl/currency-code.js.map +1 -1
  89. package/dist/intl/language-code.d.ts +3 -3
  90. package/dist/intl/language-code.d.ts.map +1 -1
  91. package/dist/intl/language-code.js +9 -10
  92. package/dist/intl/language-code.js.map +1 -1
  93. package/dist/intl/locale.d.ts +3 -3
  94. package/dist/intl/locale.d.ts.map +1 -1
  95. package/dist/intl/locale.js +18 -19
  96. package/dist/intl/locale.js.map +1 -1
  97. package/dist/json.d.ts.map +1 -1
  98. package/dist/json.js +2 -2
  99. package/dist/json.js.map +1 -1
  100. package/dist/logger.d.ts.map +1 -1
  101. package/dist/logger.js +12 -12
  102. package/dist/logger.js.map +1 -1
  103. package/dist/map.js +8 -8
  104. package/dist/map.js.map +1 -1
  105. package/dist/mime-type.d.ts +3 -3
  106. package/dist/mime-type.d.ts.map +1 -1
  107. package/dist/mime-type.js +9 -10
  108. package/dist/mime-type.js.map +1 -1
  109. package/dist/misc.js +4 -4
  110. package/dist/misc.js.map +1 -1
  111. package/dist/monetary-amount.d.ts +3 -2
  112. package/dist/monetary-amount.d.ts.map +1 -1
  113. package/dist/monetary-amount.js +16 -16
  114. package/dist/monetary-amount.js.map +1 -1
  115. package/dist/net/content-type.d.ts +2 -1
  116. package/dist/net/content-type.d.ts.map +1 -1
  117. package/dist/net/content-type.js +2 -2
  118. package/dist/net/content-type.js.map +1 -1
  119. package/dist/net/domain-name.d.ts +3 -3
  120. package/dist/net/domain-name.d.ts.map +1 -1
  121. package/dist/net/domain-name.js +10 -11
  122. package/dist/net/domain-name.js.map +1 -1
  123. package/dist/net/http-method.d.ts.map +1 -1
  124. package/dist/net/http-method.js +9 -9
  125. package/dist/net/http-method.js.map +1 -1
  126. package/dist/net/ipv4-address.d.ts +3 -3
  127. package/dist/net/ipv4-address.d.ts.map +1 -1
  128. package/dist/net/ipv4-address.js +10 -11
  129. package/dist/net/ipv4-address.js.map +1 -1
  130. package/dist/net/ipv6-address.d.ts +3 -3
  131. package/dist/net/ipv6-address.d.ts.map +1 -1
  132. package/dist/net/ipv6-address.js +10 -11
  133. package/dist/net/ipv6-address.js.map +1 -1
  134. package/dist/net/uri-host-name.d.ts +3 -3
  135. package/dist/net/uri-host-name.d.ts.map +1 -1
  136. package/dist/net/uri-host-name.js +15 -16
  137. package/dist/net/uri-host-name.js.map +1 -1
  138. package/dist/net/uri.d.ts +1 -2
  139. package/dist/net/uri.d.ts.map +1 -1
  140. package/dist/net/uri.js +5 -3
  141. package/dist/net/uri.js.map +1 -1
  142. package/dist/net/url.d.ts.map +1 -1
  143. package/dist/net/url.js +6 -7
  144. package/dist/net/url.js.map +1 -1
  145. package/dist/object/object-path.d.ts.map +1 -1
  146. package/dist/object/object-path.js +23 -28
  147. package/dist/object/object-path.js.map +1 -1
  148. package/dist/object/type-path.js +19 -19
  149. package/dist/object/type-path.js.map +1 -1
  150. package/dist/patch.js +4 -4
  151. package/dist/patch.js.map +1 -1
  152. package/dist/promise.js +2 -2
  153. package/dist/promise.js.map +1 -1
  154. package/dist/property.d.ts.map +1 -1
  155. package/dist/property.js +7 -7
  156. package/dist/property.js.map +1 -1
  157. package/dist/proxy.js +2 -2
  158. package/dist/proxy.js.map +1 -1
  159. package/dist/range.js +2 -2
  160. package/dist/range.js.map +1 -1
  161. package/dist/reference.d.ts +2 -1
  162. package/dist/reference.d.ts.map +1 -1
  163. package/dist/reference.js +13 -13
  164. package/dist/reference.js.map +1 -1
  165. package/dist/resource-key.js +2 -2
  166. package/dist/resource-key.js.map +1 -1
  167. package/dist/result.js +5 -5
  168. package/dist/result.js.map +1 -1
  169. package/dist/retry.d.ts.map +1 -1
  170. package/dist/retry.js +12 -12
  171. package/dist/retry.js.map +1 -1
  172. package/dist/rich-text.js +2 -2
  173. package/dist/rich-text.js.map +1 -1
  174. package/dist/signature.d.ts.map +1 -1
  175. package/dist/signature.js +9 -9
  176. package/dist/signature.js.map +1 -1
  177. package/dist/sql/sql-expression-parser.js +2 -2
  178. package/dist/sql/sql-expression-parser.js.map +1 -1
  179. package/dist/store.d.ts.map +1 -1
  180. package/dist/store.js +9 -9
  181. package/dist/store.js.map +1 -1
  182. package/dist/string.js +4 -4
  183. package/dist/string.js.map +1 -1
  184. package/dist/tag.d.ts.map +1 -1
  185. package/dist/tag.js +10 -10
  186. package/dist/tag.js.map +1 -1
  187. package/dist/temporal/clock.d.ts +13 -13
  188. package/dist/temporal/clock.d.ts.map +1 -1
  189. package/dist/temporal/clock.js +10 -10
  190. package/dist/temporal/clock.js.map +1 -1
  191. package/dist/temporal/duration.d.ts +15 -9
  192. package/dist/temporal/duration.d.ts.map +1 -1
  193. package/dist/temporal/duration.js +30 -31
  194. package/dist/temporal/duration.js.map +1 -1
  195. package/dist/temporal/instant.d.ts +18 -15
  196. package/dist/temporal/instant.d.ts.map +1 -1
  197. package/dist/temporal/instant.js +42 -43
  198. package/dist/temporal/instant.js.map +1 -1
  199. package/dist/temporal/plain-date-time.d.ts +16 -13
  200. package/dist/temporal/plain-date-time.d.ts.map +1 -1
  201. package/dist/temporal/plain-date-time.js +36 -38
  202. package/dist/temporal/plain-date-time.js.map +1 -1
  203. package/dist/temporal/plain-date.d.ts +16 -13
  204. package/dist/temporal/plain-date.d.ts.map +1 -1
  205. package/dist/temporal/plain-date.js +35 -37
  206. package/dist/temporal/plain-date.js.map +1 -1
  207. package/dist/temporal/plain-month-day.d.ts +37 -0
  208. package/dist/temporal/plain-month-day.d.ts.map +1 -0
  209. package/dist/temporal/plain-month-day.js +84 -0
  210. package/dist/temporal/plain-month-day.js.map +1 -0
  211. package/dist/temporal/plain-time.d.ts +19 -17
  212. package/dist/temporal/plain-time.d.ts.map +1 -1
  213. package/dist/temporal/plain-time.js +43 -42
  214. package/dist/temporal/plain-time.js.map +1 -1
  215. package/dist/temporal/plain-year-month.d.ts +57 -0
  216. package/dist/temporal/plain-year-month.d.ts.map +1 -0
  217. package/dist/temporal/plain-year-month.js +109 -0
  218. package/dist/temporal/plain-year-month.js.map +1 -0
  219. package/dist/temporal/time-zone-id.d.ts +5 -4
  220. package/dist/temporal/time-zone-id.d.ts.map +1 -1
  221. package/dist/temporal/time-zone-id.js +11 -11
  222. package/dist/temporal/time-zone-id.js.map +1 -1
  223. package/dist/temporal/time-zone-offset.d.ts +12 -11
  224. package/dist/temporal/time-zone-offset.d.ts.map +1 -1
  225. package/dist/temporal/time-zone-offset.js +42 -50
  226. package/dist/temporal/time-zone-offset.js.map +1 -1
  227. package/dist/temporal/zoned-date-time.d.ts +16 -13
  228. package/dist/temporal/zoned-date-time.d.ts.map +1 -1
  229. package/dist/temporal/zoned-date-time.js +35 -36
  230. package/dist/temporal/zoned-date-time.js.map +1 -1
  231. package/dist/uuid/ulid.d.ts +3 -3
  232. package/dist/uuid/ulid.d.ts.map +1 -1
  233. package/dist/uuid/ulid.js +9 -10
  234. package/dist/uuid/ulid.js.map +1 -1
  235. package/dist/uuid/uuid-v4.d.ts +3 -3
  236. package/dist/uuid/uuid-v4.d.ts.map +1 -1
  237. package/dist/uuid/uuid-v4.js +13 -14
  238. package/dist/uuid/uuid-v4.js.map +1 -1
  239. package/dist/uuid/uuid-v7.d.ts +1 -2
  240. package/dist/uuid/uuid-v7.d.ts.map +1 -1
  241. package/dist/uuid/uuid-v7.js +1 -2
  242. package/dist/uuid/uuid-v7.js.map +1 -1
  243. package/dist/zod-util.d.ts +4 -21
  244. package/dist/zod-util.d.ts.map +1 -1
  245. package/dist/zod-util.js +21 -11
  246. package/dist/zod-util.js.map +1 -1
  247. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/temporal/plain-time.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill'\nimport { createNamespace } from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport { fromComparator } from '@bessemer/cornerstone/equalitor'\nimport * as Results from '@bessemer/cornerstone/result'\nimport { failure, Result, success } from '@bessemer/cornerstone/result'\nimport { ErrorEvent, invalidValue, unpackResult } from '@bessemer/cornerstone/error/error-event'\nimport { isError } from '@bessemer/cornerstone/error/error'\nimport { structuredTransform } from '@bessemer/cornerstone/zod-util'\nimport Zod from 'zod'\nimport { Default as DefaultClock } from '@bessemer/cornerstone/temporal/clock'\nimport { Duration, DurationLike, from as _fromDuration } from '@bessemer/cornerstone/temporal/duration'\nimport { from as _fromInstant, InstantLike } from '@bessemer/cornerstone/temporal/instant'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\nimport { TimeUnit } from '@bessemer/cornerstone/temporal/chrono'\nimport { isString } from '@bessemer/cornerstone/string'\nimport { isNil } from '@bessemer/cornerstone/object'\nimport { Locale } from '@bessemer/cornerstone/intl/locale'\n\nexport type PlainTime = Temporal.PlainTime\nexport const Namespace = createNamespace('plain-time')\nexport type PlainTimeLiteral = NominalType<string, typeof Namespace>\nexport type PlainTimeBuilder = {\n hour: number\n minute?: number\n second?: number\n millisecond?: number\n microsecond?: number\n nanosecond?: number\n}\nexport type PlainTimeLike = PlainTime | PlainTimeLiteral | PlainTimeBuilder\n\nexport function from(value: PlainTimeLike | string): PlainTime\nexport function from(value: PlainTimeLike | string | null): PlainTime | null\nexport function from(value: PlainTimeLike | string | undefined): PlainTime | undefined\nexport function from(value: PlainTimeLike | string | null | undefined): PlainTime | null | undefined\nexport function from(value: PlainTimeLike | string | null | undefined): PlainTime | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.PlainTime) {\n return value\n }\n if (isString(value)) {\n return unpackResult(parseString(value))\n }\n\n return Temporal.PlainTime.from(value)\n}\n\nexport const CompareBy: Comparator<PlainTime> = (first: PlainTime, second: PlainTime): number => Temporal.PlainTime.compare(first, second)\nexport const EqualBy = fromComparator(CompareBy)\n\nexport const parseString = (value: string): Result<PlainTime, ErrorEvent> => {\n try {\n return success(Temporal.PlainTime.from(value))\n } catch (e) {\n if (!isError(e)) {\n throw e\n }\n\n return failure(invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport const fromDuration = (duration: DurationLike): PlainTime => {\n return Midnight.add(_fromDuration(duration))\n}\n\nexport const fromInstant = (instant: InstantLike, zone: TimeZoneId): PlainTime => {\n return _fromInstant(instant).toZonedDateTimeISO(zone).toPlainTime()\n}\n\nexport function toLiteral(likeValue: PlainTimeLike): PlainTimeLiteral\nexport function toLiteral(likeValue: PlainTimeLike | null): PlainTimeLiteral | null\nexport function toLiteral(likeValue: PlainTimeLike | undefined): PlainTimeLiteral | undefined\nexport function toLiteral(likeValue: PlainTimeLike | null | undefined): PlainTimeLiteral | null | undefined\nexport function toLiteral(likeValue: PlainTimeLike | null | undefined): PlainTimeLiteral | null | undefined {\n if (isNil(likeValue)) {\n return likeValue\n }\n\n const value = from(likeValue)\n\n if (value.second === 0 && value.millisecond === 0 && value.microsecond === 0 && value.nanosecond === 0) {\n return `${value.hour.toString().padStart(2, '0')}:${value.minute.toString().padStart(2, '0')}` as PlainTimeLiteral\n }\n\n return value.toString() as PlainTimeLiteral\n}\n\nexport const SchemaLiteral = structuredTransform(Zod.string(), (it: string) => Results.map(parseString(it), (it) => toLiteral(it)))\nexport const SchemaInstance = structuredTransform(Zod.string(), parseString)\n\nexport const isPlainTime = (value: unknown): value is PlainTime => {\n return value instanceof Temporal.PlainTime\n}\n\nexport const now = (zone: TimeZoneId, clock = DefaultClock): PlainTime => {\n return fromInstant(clock.instant(), zone)\n}\n\nexport const merge = (element: PlainTimeLike, builder: Partial<PlainTimeBuilder>): PlainTime => {\n return from(element).with(builder)\n}\n\nexport const add = (element: PlainTimeLike, duration: DurationLike): PlainTime => {\n return from(element).add(_fromDuration(duration))\n}\n\nexport const subtract = (element: PlainTimeLike, duration: DurationLike): PlainTime => {\n return from(element).subtract(_fromDuration(duration))\n}\n\nexport const until = (element: PlainTimeLike, other: PlainTimeLike): Duration => {\n return from(element).until(from(other))\n}\n\nexport const round = (element: PlainTimeLike, unit: TimeUnit): PlainTime => {\n return from(element).round({ smallestUnit: unit })\n}\n\nexport function isEqual(element: PlainTimeLike, other: PlainTimeLike): boolean\nexport function isEqual(element: PlainTimeLike | null, other: PlainTimeLike | null): boolean\nexport function isEqual(element: PlainTimeLike | undefined, other: PlainTimeLike | undefined): boolean\nexport function isEqual(element: PlainTimeLike | null | undefined, other: PlainTimeLike | null | undefined): boolean {\n if (isNil(element) || isNil(other)) {\n return element === other\n }\n\n return EqualBy(from(element), from(other))\n}\n\nexport const isBefore = (element: PlainTimeLike, other: PlainTimeLike): boolean => {\n return CompareBy(from(element), from(other)) < 0\n}\n\nexport const isAfter = (element: PlainTimeLike, other: PlainTimeLike): boolean => {\n return CompareBy(from(element), from(other)) > 0\n}\n\nexport type TimeFormatOptions = {\n hour12?: boolean | undefined\n hour?: 'numeric' | '2-digit' | undefined\n minute?: 'numeric' | '2-digit' | undefined\n second?: 'numeric' | '2-digit' | undefined\n}\n\nexport const format = (element: PlainTimeLike, locale: Locale, options?: TimeFormatOptions): string => {\n const plainTime = from(element)\n\n // Create a Date at Unix epoch with the time components\n const date = new Date(1970, 0, 1, plainTime.hour, plainTime.minute, plainTime.second, plainTime.millisecond)\n\n if (isNil(options) || (isNil(options.hour) && isNil(options.minute) && isNil(options.second))) {\n options = { ...options, hour: 'numeric', minute: '2-digit', ...(plainTime.second > 0 || plainTime.millisecond > 0 ? { second: '2-digit' } : {}) }\n }\n\n const formatter = new Intl.DateTimeFormat(locale, options)\n return formatter.format(date)\n}\n\nexport const Midnight = from({ hour: 0 })\nexport const Noon = from({ hour: 12 })\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAGhC,SAAS,sBAAsB;AAC/B,YAAY,aAAa;AACzB,SAAS,SAAiB,eAAe;AACzC,SAAqB,cAAc,oBAAoB;AACvD,SAAS,eAAe;AACxB,SAAS,2BAA2B;AACpC,OAAO,SAAS;AAChB,SAAS,WAAW,oBAAoB;AACxC,SAAiC,QAAQ,qBAAqB;AAC9D,SAAS,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,CAAC,IAAI;AACjD;AASO,IAAM,SAAS,CAAC,SAAwB,QAAgB,YAAwC;AACrG,QAAM,YAAY,KAAK,OAAO;AAG9B,QAAM,OAAO,IAAI,KAAK,MAAM,GAAG,GAAG,UAAU,MAAM,UAAU,QAAQ,UAAU,QAAQ,UAAU,WAAW;AAE3G,MAAI,MAAM,OAAO,KAAM,MAAM,QAAQ,IAAI,KAAK,MAAM,QAAQ,MAAM,KAAK,MAAM,QAAQ,MAAM,GAAI;AAC7F,cAAU,EAAE,GAAG,SAAS,MAAM,WAAW,QAAQ,WAAW,GAAI,UAAU,SAAS,KAAK,UAAU,cAAc,IAAI,EAAE,QAAQ,UAAU,IAAI,CAAC,EAAG;AAAA,EAClJ;AAEA,QAAM,YAAY,IAAI,KAAK,eAAe,QAAQ,OAAO;AACzD,SAAO,UAAU,OAAO,IAAI;AAC9B;AAEO,IAAM,WAAW,KAAK,EAAE,MAAM,EAAE,CAAC;AACjC,IAAM,OAAO,KAAK,EAAE,MAAM,GAAG,CAAC;","names":["it"]}
1
+ {"version":3,"sources":["../../src/temporal/plain-time.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill'\nimport * as ResourceKeys from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport * as Equalitors from '@bessemer/cornerstone/equalitor'\nimport * as Results from '@bessemer/cornerstone/result'\nimport * as ErrorEvents from '@bessemer/cornerstone/error/error-event'\nimport * as Errors from '@bessemer/cornerstone/error/error'\nimport * as ZodUtil from '@bessemer/cornerstone/zod-util'\nimport * as Clocks from '@bessemer/cornerstone/temporal/clock'\nimport * as Durations from '@bessemer/cornerstone/temporal/duration'\nimport * as Instants from '@bessemer/cornerstone/temporal/instant'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\nimport { TimeUnit } from '@bessemer/cornerstone/temporal/chrono'\nimport * as Strings from '@bessemer/cornerstone/string'\nimport * as Objects from '@bessemer/cornerstone/object'\nimport { Locale } from '@bessemer/cornerstone/intl/locale'\n\nexport type PlainTime = Temporal.PlainTime\nexport const Namespace = ResourceKeys.createNamespace('plain-time')\nexport type PlainTimeLiteral = NominalType<string, typeof Namespace>\nexport type PlainTimeBuilder = {\n hour: number\n minute?: number\n second?: number\n millisecond?: number\n microsecond?: number\n nanosecond?: number\n}\nexport type PlainTimeLike = PlainTime | PlainTimeLiteral | PlainTimeBuilder\n\nexport function from(value: PlainTimeLike | string): PlainTime\nexport function from(value: PlainTimeLike | string | null): PlainTime | null\nexport function from(value: PlainTimeLike | string | undefined): PlainTime | undefined\nexport function from(value: PlainTimeLike | string | null | undefined): PlainTime | null | undefined\nexport function from(value: PlainTimeLike | string | null | undefined): PlainTime | null | undefined {\n if (Objects.isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.PlainTime) {\n return value\n }\n if (Strings.isString(value)) {\n return ErrorEvents.unpackResult(parseString(value))\n }\n\n return Temporal.PlainTime.from(value)\n}\n\nexport const CompareBy: Comparator<PlainTime> = (first: PlainTime, second: PlainTime): number => Temporal.PlainTime.compare(first, second)\nexport const EqualBy = Equalitors.fromComparator(CompareBy)\n\nexport const parseString = (value: string): Results.Result<PlainTime, ErrorEvents.ErrorEvent> => {\n try {\n return Results.success(Temporal.PlainTime.from(value))\n } catch (e) {\n if (!Errors.isError(e)) {\n throw e\n }\n\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport const fromDuration = (duration: Durations.DurationLike): PlainTime => {\n return Midnight.add(Durations.from(duration))\n}\n\nexport const fromInstant = (instant: Instants.InstantLike, zone: TimeZoneId): PlainTime => {\n return Instants.from(instant).toZonedDateTimeISO(zone).toPlainTime()\n}\n\nexport function toLiteral(likeValue: PlainTimeLike): PlainTimeLiteral\nexport function toLiteral(likeValue: PlainTimeLike | null): PlainTimeLiteral | null\nexport function toLiteral(likeValue: PlainTimeLike | undefined): PlainTimeLiteral | undefined\nexport function toLiteral(likeValue: PlainTimeLike | null | undefined): PlainTimeLiteral | null | undefined\nexport function toLiteral(likeValue: PlainTimeLike | null | undefined): PlainTimeLiteral | null | undefined {\n if (Objects.isNil(likeValue)) {\n return likeValue\n }\n\n const value = from(likeValue)\n\n if (value.second === 0 && value.millisecond === 0 && value.microsecond === 0 && value.nanosecond === 0) {\n return `${value.hour.toString().padStart(2, '0')}:${value.minute.toString().padStart(2, '0')}` as PlainTimeLiteral\n }\n\n return value.toString() as PlainTimeLiteral\n}\n\nexport const SchemaLiteral = ZodUtil.structuredRefine<PlainTimeLiteral>(ZodUtil.string(), (it: string) =>\n Results.map(parseString(it), (it) => toLiteral(it))\n)\nexport const SchemaInstance = ZodUtil.structuredTransform(ZodUtil.string(), parseString)\n\nexport const isPlainTime = (value: unknown): value is PlainTime => {\n return value instanceof Temporal.PlainTime\n}\n\nexport const now = (zone: TimeZoneId, clock = Clocks.Default): PlainTime => {\n return fromInstant(clock.instant(), zone)\n}\n\nexport const merge = (element: PlainTimeLike, builder: Partial<PlainTimeBuilder>): PlainTime => {\n return from(element).with(builder)\n}\n\nexport const add = (element: PlainTimeLike, duration: Durations.DurationLike): PlainTime => {\n return from(element).add(Durations.from(duration))\n}\n\nexport const subtract = (element: PlainTimeLike, duration: Durations.DurationLike): PlainTime => {\n return from(element).subtract(Durations.from(duration))\n}\n\nexport const until = (element: PlainTimeLike, other: PlainTimeLike): Durations.Duration => {\n return from(element).until(from(other))\n}\n\nexport const round = (element: PlainTimeLike, unit: TimeUnit): PlainTime => {\n return from(element).round({ smallestUnit: unit })\n}\n\nexport function isEqual(element: PlainTimeLike, other: PlainTimeLike): boolean\nexport function isEqual(element: PlainTimeLike | null, other: PlainTimeLike | null): boolean\nexport function isEqual(element: PlainTimeLike | undefined, other: PlainTimeLike | undefined): boolean\nexport function isEqual(element: PlainTimeLike | null | undefined, other: PlainTimeLike | null | undefined): boolean {\n if (Objects.isNil(element) || Objects.isNil(other)) {\n return element === other\n }\n\n return EqualBy(from(element), from(other))\n}\n\nexport const isBefore = (element: PlainTimeLike, other: PlainTimeLike): boolean => {\n return CompareBy(from(element), from(other)) < 0\n}\n\nexport const isAfter = (element: PlainTimeLike, other: PlainTimeLike): boolean => {\n return CompareBy(from(element), from(other)) > 0\n}\n\nexport type TimeFormatOptions = {\n hour12?: boolean | undefined\n hour?: 'numeric' | '2-digit' | undefined\n minute?: 'numeric' | '2-digit' | undefined\n second?: 'numeric' | '2-digit' | undefined\n}\n\nexport const format = (element: PlainTimeLike, locale: Locale, options?: TimeFormatOptions): string => {\n const plainTime = from(element)\n\n const date = new Date(1970, 0, 1, plainTime.hour, plainTime.minute, plainTime.second, plainTime.millisecond)\n\n if (Objects.isNil(options) || (Objects.isNil(options.hour) && Objects.isNil(options.minute) && Objects.isNil(options.second))) {\n options = { ...options, hour: 'numeric', minute: '2-digit', ...(plainTime.second > 0 || plainTime.millisecond > 0 ? { second: '2-digit' } : {}) }\n }\n\n const formatter = new Intl.DateTimeFormat(locale, options)\n return formatter.format(date)\n}\n\nexport const Midnight = from({ hour: 0 })\nexport const Noon = from({ hour: 12 })\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,YAAY,kBAAkB;AAG9B,YAAY,gBAAgB;AAC5B,YAAY,aAAa;AACzB,YAAY,iBAAiB;AAC7B,YAAY,YAAY;AACxB,YAAY,aAAa;AACzB,YAAY,YAAY;AACxB,YAAY,eAAe;AAC3B,YAAY,cAAc;AAG1B,YAAY,aAAa;AACzB,YAAY,aAAa;AAIlB,IAAM,YAAyB,6BAAgB,YAAY;AAgB3D,SAASA,MAAK,OAAgF;AACnG,MAAY,cAAM,KAAK,GAAG;AACxB,WAAO;AAAA,EACT;AAEA,MAAI,iBAAiB,SAAS,WAAW;AACvC,WAAO;AAAA,EACT;AACA,MAAY,iBAAS,KAAK,GAAG;AAC3B,WAAmB,yBAAa,YAAY,KAAK,CAAC;AAAA,EACpD;AAEA,SAAO,SAAS,UAAU,KAAK,KAAK;AACtC;AAE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AG,SAAS,MAAM,WAAW,QAAQ,WAAW,GAAI,UAAU,SAAS,KAAK,UAAU,cAAc,IAAI,EAAE,QAAQ,UAAU,IAAI,CAAC,EAAG;AAAA,EAClJ;AAEA,QAAM,YAAY,IAAI,KAAK,eAAe,QAAQ,OAAO;AACzD,SAAO,UAAU,OAAO,IAAI;AAC9B;AAEO,IAAM,WAAWA,MAAK,EAAE,MAAM,EAAE,CAAC;AACjC,IAAM,OAAOA,MAAK,EAAE,MAAM,GAAG,CAAC;","names":["from","it"]}
@@ -0,0 +1,57 @@
1
+ import { Temporal } from '@js-temporal/polyfill';
2
+ import * as ResourceKeys from '@bessemer/cornerstone/resource-key';
3
+ import { NominalType } from '@bessemer/cornerstone/types';
4
+ import { Comparator } from '@bessemer/cornerstone/comparator';
5
+ import * as Equalitors from '@bessemer/cornerstone/equalitor';
6
+ import * as Results from '@bessemer/cornerstone/result';
7
+ import * as ErrorEvents from '@bessemer/cornerstone/error/error-event';
8
+ import Zod from 'zod';
9
+ import * as Clocks from '@bessemer/cornerstone/temporal/clock';
10
+ import * as Durations from '@bessemer/cornerstone/temporal/duration';
11
+ import * as Instants from '@bessemer/cornerstone/temporal/instant';
12
+ import { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id';
13
+ import { Locale } from '@bessemer/cornerstone/intl/locale';
14
+ export type PlainYearMonth = Temporal.PlainYearMonth;
15
+ export declare const Namespace: ResourceKeys.ResourceNamespace<"plain-year-month">;
16
+ export type PlainYearMonthLiteral = NominalType<string, typeof Namespace>;
17
+ export type PlainYearMonthBuilder = {
18
+ year: number;
19
+ month: number;
20
+ };
21
+ export type PlainYearMonthLike = PlainYearMonth | PlainYearMonthLiteral | PlainYearMonthBuilder;
22
+ export declare function from(value: PlainYearMonthLike | string): PlainYearMonth;
23
+ export declare function from(value: PlainYearMonthLike | string | null): PlainYearMonth | null;
24
+ export declare function from(value: PlainYearMonthLike | string | undefined): PlainYearMonth | undefined;
25
+ export declare function from(value: PlainYearMonthLike | string | null | undefined): PlainYearMonth | null | undefined;
26
+ export declare const CompareBy: Comparator<PlainYearMonth>;
27
+ export declare const EqualBy: Equalitors.Equalitor<Temporal.PlainYearMonth>;
28
+ export declare const parseString: (value: string) => Results.Result<PlainYearMonth, ErrorEvents.ErrorEvent>;
29
+ export declare const fromInstant: (instant: Instants.InstantLike, zone: TimeZoneId) => PlainYearMonth;
30
+ export declare function toLiteral(likeValue: PlainYearMonthLike): PlainYearMonthLiteral;
31
+ export declare function toLiteral(likeValue: PlainYearMonthLike | null): PlainYearMonthLiteral | null;
32
+ export declare function toLiteral(likeValue: PlainYearMonthLike | undefined): PlainYearMonthLiteral | undefined;
33
+ export declare function toLiteral(likeValue: PlainYearMonthLike | null | undefined): PlainYearMonthLiteral | null | undefined;
34
+ export declare const SchemaLiteral: Zod.ZodPipe<Zod.ZodString, Zod.ZodTransform<PlainYearMonthLiteral, string>>;
35
+ export declare const SchemaInstance: Zod.ZodPipe<Zod.ZodString, Zod.ZodTransform<Temporal.PlainYearMonth, string>>;
36
+ export declare const isPlainYearMonth: (value: unknown) => value is PlainYearMonth;
37
+ export declare const now: (zone: TimeZoneId, clock?: {
38
+ readonly zone: TimeZoneId;
39
+ instant(): Instants.Instant;
40
+ withZone(zone: TimeZoneId): Clocks.Clock;
41
+ }) => PlainYearMonth;
42
+ export declare const merge: (element: PlainYearMonthLike, builder: Partial<PlainYearMonthBuilder>) => PlainYearMonth;
43
+ export declare const add: (element: PlainYearMonthLike, duration: Durations.DurationLike) => PlainYearMonth;
44
+ export declare const subtract: (element: PlainYearMonthLike, duration: Durations.DurationLike) => PlainYearMonth;
45
+ export declare const until: (element: PlainYearMonthLike, other: PlainYearMonthLike) => Durations.Duration;
46
+ export declare function isEqual(element: PlainYearMonthLike, other: PlainYearMonthLike): boolean;
47
+ export declare function isEqual(element: PlainYearMonthLike | null, other: PlainYearMonthLike | null): boolean;
48
+ export declare function isEqual(element: PlainYearMonthLike | undefined, other: PlainYearMonthLike | undefined): boolean;
49
+ export declare const isBefore: (element: PlainYearMonthLike, other: PlainYearMonthLike) => boolean;
50
+ export declare const isAfter: (element: PlainYearMonthLike, other: PlainYearMonthLike) => boolean;
51
+ export type YearMonthFormatOptions = {
52
+ era?: 'long' | 'short' | 'narrow' | undefined;
53
+ year?: 'numeric' | '2-digit' | undefined;
54
+ month?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow' | undefined;
55
+ };
56
+ export declare const format: (element: PlainYearMonthLike, locale: Locale, options: YearMonthFormatOptions) => string;
57
+ //# sourceMappingURL=plain-year-month.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plain-year-month.d.ts","sourceRoot":"","sources":["../../src/temporal/plain-year-month.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,KAAK,YAAY,MAAM,oCAAoC,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAC7D,OAAO,KAAK,UAAU,MAAM,iCAAiC,CAAA;AAC7D,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAA;AACvD,OAAO,KAAK,WAAW,MAAM,yCAAyC,CAAA;AAGtE,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,KAAK,MAAM,MAAM,sCAAsC,CAAA;AAC9D,OAAO,KAAK,SAAS,MAAM,yCAAyC,CAAA;AACpE,OAAO,KAAK,QAAQ,MAAM,wCAAwC,CAAA;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAA;AAGxE,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;AAE1D,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAA;AACpD,eAAO,MAAM,SAAS,oDAAmD,CAAA;AACzE,MAAM,MAAM,qBAAqB,GAAG,WAAW,CAAC,MAAM,EAAE,OAAO,SAAS,CAAC,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CAAA;IAC7C,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAA;IACxC,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAA;CACxE,CAAA;AAED,eAAO,MAAM,MAAM,GAAI,SAAS,kBAAkB,EAAE,QAAQ,MAAM,EAAE,SAAS,sBAAsB,KAAG,MAOrG,CAAA"}
@@ -0,0 +1,109 @@
1
+ // src/temporal/plain-year-month.ts
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import * as ResourceKeys from "@bessemer/cornerstone/resource-key";
4
+ import * as Equalitors from "@bessemer/cornerstone/equalitor";
5
+ import * as Results from "@bessemer/cornerstone/result";
6
+ import * as ErrorEvents from "@bessemer/cornerstone/error/error-event";
7
+ import * as Errors from "@bessemer/cornerstone/error/error";
8
+ import * as ZodUtil from "@bessemer/cornerstone/zod-util";
9
+ import Zod from "zod";
10
+ import * as Clocks from "@bessemer/cornerstone/temporal/clock";
11
+ import * as Durations from "@bessemer/cornerstone/temporal/duration";
12
+ import * as Instants from "@bessemer/cornerstone/temporal/instant";
13
+ import * as Strings from "@bessemer/cornerstone/string";
14
+ import * as Objects from "@bessemer/cornerstone/object";
15
+ var Namespace = ResourceKeys.createNamespace("plain-year-month");
16
+ function from3(value) {
17
+ if (Objects.isNil(value)) {
18
+ return value;
19
+ }
20
+ if (value instanceof Temporal.PlainYearMonth) {
21
+ return value;
22
+ }
23
+ if (Strings.isString(value)) {
24
+ return ErrorEvents.unpackResult(parseString(value));
25
+ }
26
+ return Temporal.PlainYearMonth.from(value);
27
+ }
28
+ var CompareBy = (first, second) => Temporal.PlainYearMonth.compare(first, second);
29
+ var EqualBy = Equalitors.fromComparator(CompareBy);
30
+ var parseString = (value) => {
31
+ try {
32
+ return Results.success(Temporal.PlainYearMonth.from(value));
33
+ } catch (e) {
34
+ if (!Errors.isError(e)) {
35
+ throw e;
36
+ }
37
+ return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: e.message }));
38
+ }
39
+ };
40
+ var fromInstant = (instant, zone) => {
41
+ return Instants.from(instant).toZonedDateTimeISO(zone).toPlainDate().toPlainYearMonth();
42
+ };
43
+ function toLiteral(likeValue) {
44
+ if (Objects.isNil(likeValue)) {
45
+ return likeValue;
46
+ }
47
+ const value = from3(likeValue);
48
+ return value.toString();
49
+ }
50
+ var SchemaLiteral = ZodUtil.structuredTransform(Zod.string(), (it) => Results.map(parseString(it), (it2) => toLiteral(it2)));
51
+ var SchemaInstance = ZodUtil.structuredTransform(Zod.string(), parseString);
52
+ var isPlainYearMonth = (value) => {
53
+ return value instanceof Temporal.PlainYearMonth;
54
+ };
55
+ var now = (zone, clock = Clocks.Default) => {
56
+ return fromInstant(clock.instant(), zone);
57
+ };
58
+ var merge = (element, builder) => {
59
+ return from3(element).with(builder);
60
+ };
61
+ var add = (element, duration) => {
62
+ return from3(element).add(Durations.from(duration));
63
+ };
64
+ var subtract = (element, duration) => {
65
+ return from3(element).subtract(Durations.from(duration));
66
+ };
67
+ var until = (element, other) => {
68
+ return from3(element).until(from3(other));
69
+ };
70
+ function isEqual(element, other) {
71
+ if (Objects.isNil(element) || Objects.isNil(other)) {
72
+ return element === other;
73
+ }
74
+ return EqualBy(from3(element), from3(other));
75
+ }
76
+ var isBefore = (element, other) => {
77
+ return CompareBy(from3(element), from3(other)) < 0;
78
+ };
79
+ var isAfter = (element, other) => {
80
+ return CompareBy(from3(element), from3(other)) > 0;
81
+ };
82
+ var format = (element, locale, options) => {
83
+ const plainYearMonth = from3(element);
84
+ const date = new Date(plainYearMonth.year, plainYearMonth.month - 1, 1);
85
+ const formatter = new Intl.DateTimeFormat(locale, options);
86
+ return formatter.format(date);
87
+ };
88
+ export {
89
+ CompareBy,
90
+ EqualBy,
91
+ Namespace,
92
+ SchemaInstance,
93
+ SchemaLiteral,
94
+ add,
95
+ format,
96
+ from3 as from,
97
+ fromInstant,
98
+ isAfter,
99
+ isBefore,
100
+ isEqual,
101
+ isPlainYearMonth,
102
+ merge,
103
+ now,
104
+ parseString,
105
+ subtract,
106
+ toLiteral,
107
+ until
108
+ };
109
+ //# sourceMappingURL=plain-year-month.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/temporal/plain-year-month.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill'\nimport * as ResourceKeys from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport * as Equalitors from '@bessemer/cornerstone/equalitor'\nimport * as Results from '@bessemer/cornerstone/result'\nimport * as ErrorEvents from '@bessemer/cornerstone/error/error-event'\nimport * as Errors from '@bessemer/cornerstone/error/error'\nimport * as ZodUtil from '@bessemer/cornerstone/zod-util'\nimport Zod from 'zod'\nimport * as Clocks from '@bessemer/cornerstone/temporal/clock'\nimport * as Durations from '@bessemer/cornerstone/temporal/duration'\nimport * as Instants from '@bessemer/cornerstone/temporal/instant'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\nimport * as Strings from '@bessemer/cornerstone/string'\nimport * as Objects from '@bessemer/cornerstone/object'\nimport { Locale } from '@bessemer/cornerstone/intl/locale'\n\nexport type PlainYearMonth = Temporal.PlainYearMonth\nexport const Namespace = ResourceKeys.createNamespace('plain-year-month')\nexport type PlainYearMonthLiteral = NominalType<string, typeof Namespace>\nexport type PlainYearMonthBuilder = {\n year: number\n month: number\n}\n\nexport type PlainYearMonthLike = PlainYearMonth | PlainYearMonthLiteral | PlainYearMonthBuilder\n\nexport function from(value: PlainYearMonthLike | string): PlainYearMonth\nexport function from(value: PlainYearMonthLike | string | null): PlainYearMonth | null\nexport function from(value: PlainYearMonthLike | string | undefined): PlainYearMonth | undefined\nexport function from(value: PlainYearMonthLike | string | null | undefined): PlainYearMonth | null | undefined\nexport function from(value: PlainYearMonthLike | string | null | undefined): PlainYearMonth | null | undefined {\n if (Objects.isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.PlainYearMonth) {\n return value\n }\n\n if (Strings.isString(value)) {\n return ErrorEvents.unpackResult(parseString(value))\n }\n\n return Temporal.PlainYearMonth.from(value)\n}\n\nexport const CompareBy: Comparator<PlainYearMonth> = (first: PlainYearMonth, second: PlainYearMonth): number =>\n Temporal.PlainYearMonth.compare(first, second)\nexport const EqualBy = Equalitors.fromComparator(CompareBy)\n\nexport const parseString = (value: string): Results.Result<PlainYearMonth, ErrorEvents.ErrorEvent> => {\n try {\n return Results.success(Temporal.PlainYearMonth.from(value))\n } catch (e) {\n if (!Errors.isError(e)) {\n throw e\n }\n\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport const fromInstant = (instant: Instants.InstantLike, zone: TimeZoneId): PlainYearMonth => {\n return Instants.from(instant).toZonedDateTimeISO(zone).toPlainDate().toPlainYearMonth()\n}\n\nexport function toLiteral(likeValue: PlainYearMonthLike): PlainYearMonthLiteral\nexport function toLiteral(likeValue: PlainYearMonthLike | null): PlainYearMonthLiteral | null\nexport function toLiteral(likeValue: PlainYearMonthLike | undefined): PlainYearMonthLiteral | undefined\nexport function toLiteral(likeValue: PlainYearMonthLike | null | undefined): PlainYearMonthLiteral | null | undefined\nexport function toLiteral(likeValue: PlainYearMonthLike | null | undefined): PlainYearMonthLiteral | null | undefined {\n if (Objects.isNil(likeValue)) {\n return likeValue\n }\n\n const value = from(likeValue)\n return value.toString() as PlainYearMonthLiteral\n}\n\nexport const SchemaLiteral = ZodUtil.structuredTransform(Zod.string(), (it: string) => Results.map(parseString(it), (it) => toLiteral(it)))\nexport const SchemaInstance = ZodUtil.structuredTransform(Zod.string(), parseString)\n\nexport const isPlainYearMonth = (value: unknown): value is PlainYearMonth => {\n return value instanceof Temporal.PlainYearMonth\n}\n\nexport const now = (zone: TimeZoneId, clock = Clocks.Default): PlainYearMonth => {\n return fromInstant(clock.instant(), zone)\n}\n\nexport const merge = (element: PlainYearMonthLike, builder: Partial<PlainYearMonthBuilder>): PlainYearMonth => {\n return from(element).with(builder)\n}\n\nexport const add = (element: PlainYearMonthLike, duration: Durations.DurationLike): PlainYearMonth => {\n return from(element).add(Durations.from(duration))\n}\n\nexport const subtract = (element: PlainYearMonthLike, duration: Durations.DurationLike): PlainYearMonth => {\n return from(element).subtract(Durations.from(duration))\n}\n\nexport const until = (element: PlainYearMonthLike, other: PlainYearMonthLike): Durations.Duration => {\n return from(element).until(from(other))\n}\n\nexport function isEqual(element: PlainYearMonthLike, other: PlainYearMonthLike): boolean\nexport function isEqual(element: PlainYearMonthLike | null, other: PlainYearMonthLike | null): boolean\nexport function isEqual(element: PlainYearMonthLike | undefined, other: PlainYearMonthLike | undefined): boolean\nexport function isEqual(element: PlainYearMonthLike | null | undefined, other: PlainYearMonthLike | null | undefined): boolean {\n if (Objects.isNil(element) || Objects.isNil(other)) {\n return element === other\n }\n\n return EqualBy(from(element), from(other))\n}\n\nexport const isBefore = (element: PlainYearMonthLike, other: PlainYearMonthLike): boolean => {\n return CompareBy(from(element), from(other)) < 0\n}\n\nexport const isAfter = (element: PlainYearMonthLike, other: PlainYearMonthLike): boolean => {\n return CompareBy(from(element), from(other)) > 0\n}\n\nexport type YearMonthFormatOptions = {\n era?: 'long' | 'short' | 'narrow' | undefined\n year?: 'numeric' | '2-digit' | undefined\n month?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow' | undefined\n}\n\nexport const format = (element: PlainYearMonthLike, locale: Locale, options: YearMonthFormatOptions): string => {\n const plainYearMonth = from(element)\n\n const date = new Date(plainYearMonth.year, plainYearMonth.month - 1, 1)\n\n const formatter = new Intl.DateTimeFormat(locale, options)\n return formatter.format(date)\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,YAAY,kBAAkB;AAG9B,YAAY,gBAAgB;AAC5B,YAAY,aAAa;AACzB,YAAY,iBAAiB;AAC7B,YAAY,YAAY;AACxB,YAAY,aAAa;AACzB,OAAO,SAAS;AAChB,YAA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as Results from '@bessemer/cornerstone/result';
2
2
  import Zod from 'zod';
3
3
  import { NominalType } from '@bessemer/cornerstone/types';
4
- import { ErrorEvent } from '@bessemer/cornerstone/error/error-event';
5
- export declare const Namespace: import("@bessemer/cornerstone/resource-key").ResourceNamespace<"time-zone-id">;
4
+ import * as ResourceKeys from '@bessemer/cornerstone/resource-key';
5
+ import * as ErrorEvents from '@bessemer/cornerstone/error/error-event';
6
+ export declare const Namespace: ResourceKeys.ResourceNamespace<"time-zone-id">;
6
7
  export type TimeZoneId = NominalType<string, typeof Namespace>;
7
- export declare const parseString: (value: string) => Result<TimeZoneId, ErrorEvent>;
8
+ export declare const parseString: (value: string) => Results.Result<TimeZoneId, ErrorEvents.ErrorEvent>;
8
9
  export declare const from: (value: string) => TimeZoneId;
9
10
  export declare const Schema: Zod.ZodPipe<Zod.ZodString, Zod.ZodTransform<TimeZoneId, string>>;
10
11
  export declare const Utc: TimeZoneId;
@@ -1 +1 @@
1
- {"version":3,"file":"time-zone-id.d.ts","sourceRoot":"","sources":["../../src/temporal/time-zone-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAW,MAAM,8BAA8B,CAAA;AACvE,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEzD,OAAO,EAAE,UAAU,EAA8B,MAAM,yCAAyC,CAAA;AAIhG,eAAO,MAAM,SAAS,gFAAkC,CAAA;AACxD,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,EAAE,OAAO,SAAS,CAAC,CAAA;AAE9D,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,MAAM,CAAC,UAAU,EAAE,UAAU,CAWxE,CAAA;AAED,eAAO,MAAM,IAAI,GAAI,OAAO,MAAM,KAAG,UAEpC,CAAA;AAED,eAAO,MAAM,MAAM,kEAAiD,CAAA;AAEpE,eAAO,MAAM,GAAG,EAAY,UAAU,CAAA;AACtC,eAAO,MAAM,gBAAgB,QAAO,UAEnC,CAAA"}
1
+ {"version":3,"file":"time-zone-id.d.ts","sourceRoot":"","sources":["../../src/temporal/time-zone-id.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAA;AACvD,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,YAAY,MAAM,oCAAoC,CAAA;AAClE,OAAO,KAAK,WAAW,MAAM,yCAAyC,CAAA;AAItE,eAAO,MAAM,SAAS,gDAA+C,CAAA;AACrE,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,EAAE,OAAO,SAAS,CAAC,CAAA;AAE9D,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,UAAU,CAW5F,CAAA;AAED,eAAO,MAAM,IAAI,GAAI,OAAO,MAAM,KAAG,UAEpC,CAAA;AAED,eAAO,MAAM,MAAM,kEAAyD,CAAA;AAE5E,eAAO,MAAM,GAAG,EAAY,UAAU,CAAA;AACtC,eAAO,MAAM,gBAAgB,QAAO,UAEnC,CAAA"}
@@ -1,27 +1,27 @@
1
1
  // src/temporal/time-zone-id.ts
2
- import { failure, success } from "@bessemer/cornerstone/result";
2
+ import * as Results from "@bessemer/cornerstone/result";
3
3
  import Zod from "zod";
4
- import { createNamespace } from "@bessemer/cornerstone/resource-key";
5
- import { invalidValue, unpackResult } from "@bessemer/cornerstone/error/error-event";
6
- import { isError } from "@bessemer/cornerstone/error/error";
7
- import { structuredTransform } from "@bessemer/cornerstone/zod-util";
8
- var Namespace = createNamespace("time-zone-id");
4
+ import * as ResourceKeys from "@bessemer/cornerstone/resource-key";
5
+ import * as ErrorEvents from "@bessemer/cornerstone/error/error-event";
6
+ import * as Errors from "@bessemer/cornerstone/error/error";
7
+ import * as ZodUtil from "@bessemer/cornerstone/zod-util";
8
+ var Namespace = ResourceKeys.createNamespace("time-zone-id");
9
9
  var parseString = (value) => {
10
10
  try {
11
11
  const fmt = new Intl.DateTimeFormat(void 0, { timeZone: value });
12
- return success(fmt.resolvedOptions().timeZone);
12
+ return Results.success(fmt.resolvedOptions().timeZone);
13
13
  } catch (e) {
14
- if (isError(e)) {
15
- return failure(invalidValue(value, { namespace: Namespace, message: e.message }));
14
+ if (Errors.isError(e)) {
15
+ return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: e.message }));
16
16
  } else {
17
17
  throw e;
18
18
  }
19
19
  }
20
20
  };
21
21
  var from = (value) => {
22
- return unpackResult(parseString(value));
22
+ return ErrorEvents.unpackResult(parseString(value));
23
23
  };
24
- var Schema = structuredTransform(Zod.string(), parseString);
24
+ var Schema = ZodUtil.structuredTransform(Zod.string(), parseString);
25
25
  var Utc = "UTC";
26
26
  var getSystemDefault = () => {
27
27
  return Intl.DateTimeFormat().resolvedOptions().timeZone;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/temporal/time-zone-id.ts"],"sourcesContent":["import { failure, Result, success } from '@bessemer/cornerstone/result'\nimport Zod from 'zod'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { createNamespace } from '@bessemer/cornerstone/resource-key'\nimport { ErrorEvent, invalidValue, unpackResult } from '@bessemer/cornerstone/error/error-event'\nimport { isError } from '@bessemer/cornerstone/error/error'\nimport { structuredTransform } from '@bessemer/cornerstone/zod-util'\n\nexport const Namespace = createNamespace('time-zone-id')\nexport type TimeZoneId = NominalType<string, typeof Namespace>\n\nexport const parseString = (value: string): Result<TimeZoneId, ErrorEvent> => {\n try {\n const fmt = new Intl.DateTimeFormat(undefined, { timeZone: value })\n return success(fmt.resolvedOptions().timeZone as TimeZoneId)\n } catch (e) {\n if (isError(e)) {\n return failure(invalidValue(value, { namespace: Namespace, message: e.message }))\n } else {\n throw e\n }\n }\n}\n\nexport const from = (value: string): TimeZoneId => {\n return unpackResult(parseString(value))\n}\n\nexport const Schema = structuredTransform(Zod.string(), parseString)\n\nexport const Utc = 'UTC' as TimeZoneId\nexport const getSystemDefault = (): TimeZoneId => {\n return Intl.DateTimeFormat().resolvedOptions().timeZone as TimeZoneId\n}\n"],"mappings":";AAAA,SAAS,SAAiB,eAAe;AACzC,OAAO,SAAS;AAEhB,SAAS,uBAAuB;AAChC,SAAqB,cAAc,oBAAoB;AACvD,SAAS,eAAe;AACxB,SAAS,2BAA2B;AAE7B,IAAM,YAAY,gBAAgB,cAAc;AAGhD,IAAM,cAAc,CAAC,UAAkD;AAC5E,MAAI;AACF,UAAM,MAAM,IAAI,KAAK,eAAe,QAAW,EAAE,UAAU,MAAM,CAAC;AAClE,WAAO,QAAQ,IAAI,gBAAgB,EAAE,QAAsB;AAAA,EAC7D,SAAS,GAAG;AACV,QAAI,QAAQ,CAAC,GAAG;AACd,aAAO,QAAQ,aAAa,OAAO,EAAE,WAAW,WAAW,SAAS,EAAE,QAAQ,CAAC,CAAC;AAAA,IAClF,OAAO;AACL,YAAM;AAAA,IACR;AAAA,EACF;AACF;AAEO,IAAM,OAAO,CAAC,UAA8B;AACjD,SAAO,aAAa,YAAY,KAAK,CAAC;AACxC;AAEO,IAAM,SAAS,oBAAoB,IAAI,OAAO,GAAG,WAAW;AAE5D,IAAM,MAAM;AACZ,IAAM,mBAAmB,MAAkB;AAChD,SAAO,KAAK,eAAe,EAAE,gBAAgB,EAAE;AACjD;","names":[]}
1
+ {"version":3,"sources":["../../src/temporal/time-zone-id.ts"],"sourcesContent":["import * as Results from '@bessemer/cornerstone/result'\nimport Zod from 'zod'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport * as ResourceKeys from '@bessemer/cornerstone/resource-key'\nimport * as ErrorEvents from '@bessemer/cornerstone/error/error-event'\nimport * as Errors from '@bessemer/cornerstone/error/error'\nimport * as ZodUtil from '@bessemer/cornerstone/zod-util'\n\nexport const Namespace = ResourceKeys.createNamespace('time-zone-id')\nexport type TimeZoneId = NominalType<string, typeof Namespace>\n\nexport const parseString = (value: string): Results.Result<TimeZoneId, ErrorEvents.ErrorEvent> => {\n try {\n const fmt = new Intl.DateTimeFormat(undefined, { timeZone: value })\n return Results.success(fmt.resolvedOptions().timeZone as TimeZoneId)\n } catch (e) {\n if (Errors.isError(e)) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: e.message }))\n } else {\n throw e\n }\n }\n}\n\nexport const from = (value: string): TimeZoneId => {\n return ErrorEvents.unpackResult(parseString(value))\n}\n\nexport const Schema = ZodUtil.structuredTransform(Zod.string(), parseString)\n\nexport const Utc = 'UTC' as TimeZoneId\nexport const getSystemDefault = (): TimeZoneId => {\n return Intl.DateTimeFormat().resolvedOptions().timeZone as TimeZoneId\n}\n"],"mappings":";AAAA,YAAY,aAAa;AACzB,OAAO,SAAS;AAEhB,YAAY,kBAAkB;AAC9B,YAAY,iBAAiB;AAC7B,YAAY,YAAY;AACxB,YAAY,aAAa;AAElB,IAAM,YAAyB,6BAAgB,cAAc;AAG7D,IAAM,cAAc,CAAC,UAAsE;AAChG,MAAI;AACF,UAAM,MAAM,IAAI,KAAK,eAAe,QAAW,EAAE,UAAU,MAAM,CAAC;AAClE,WAAe,gBAAQ,IAAI,gBAAgB,EAAE,QAAsB;AAAA,EACrE,SAAS,GAAG;AACV,QAAW,eAAQ,CAAC,GAAG;AACrB,aAAe,gBAAoB,yBAAa,OAAO,EAAE,WAAW,WAAW,SAAS,EAAE,QAAQ,CAAC,CAAC;AAAA,IACtG,OAAO;AACL,YAAM;AAAA,IACR;AAAA,EACF;AACF;AAEO,IAAM,OAAO,CAAC,UAA8B;AACjD,SAAmB,yBAAa,YAAY,KAAK,CAAC;AACpD;AAEO,IAAM,SAAiB,4BAAoB,IAAI,OAAO,GAAG,WAAW;AAEpE,IAAM,MAAM;AACZ,IAAM,mBAAmB,MAAkB;AAChD,SAAO,KAAK,eAAe,EAAE,gBAAgB,EAAE;AACjD;","names":[]}
@@ -1,21 +1,22 @@
1
1
  import { NominalType } from '@bessemer/cornerstone/types';
2
- import { Duration, DurationLike } from '@bessemer/cornerstone/temporal/duration';
3
- import { Result } from '@bessemer/cornerstone/result';
2
+ import * as Durations from '@bessemer/cornerstone/temporal/duration';
3
+ import * as Results from '@bessemer/cornerstone/result';
4
4
  import Zod from 'zod';
5
- import { ErrorEvent } from '@bessemer/cornerstone/error/error-event';
6
- import { Instant } from '@bessemer/cornerstone/temporal/instant';
5
+ import * as ErrorEvents from '@bessemer/cornerstone/error/error-event';
6
+ import * as ResourceKeys from '@bessemer/cornerstone/resource-key';
7
7
  import { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id';
8
- export declare const Namespace: import("@bessemer/cornerstone/resource-key").ResourceNamespace<"time-zone-offset">;
8
+ import * as Instants from '@bessemer/cornerstone/temporal/instant';
9
+ export declare const Namespace: ResourceKeys.ResourceNamespace<"time-zone-offset">;
9
10
  export type TimeZoneOffset = NominalType<number, typeof Namespace>;
10
- export declare const parseMinutes: (value: number) => Result<TimeZoneOffset, ErrorEvent>;
11
- export declare const parseDuration: (value: Duration) => Result<TimeZoneOffset, ErrorEvent>;
11
+ export declare const parseMinutes: (value: number) => Results.Result<TimeZoneOffset, ErrorEvents.ErrorEvent>;
12
+ export declare const parseDuration: (value: Durations.Duration) => Results.Result<TimeZoneOffset, ErrorEvents.ErrorEvent>;
12
13
  export declare const fromMinutes: (value: number) => TimeZoneOffset;
13
- export declare const fromDuration: (value: DurationLike) => TimeZoneOffset;
14
- export declare const fromTimeZone: (timeZone: TimeZoneId, instant: Instant) => TimeZoneOffset;
15
- export declare const parseString: (value: string) => Result<TimeZoneOffset, ErrorEvent>;
14
+ export declare const fromDuration: (value: Durations.DurationLike) => TimeZoneOffset;
15
+ export declare const fromTimeZone: (timeZone: TimeZoneId, instant: Instants.Instant) => TimeZoneOffset;
16
+ export declare const parseString: (value: string) => Results.Result<TimeZoneOffset, ErrorEvents.ErrorEvent>;
16
17
  export declare const from: (value: string) => TimeZoneOffset;
17
18
  export declare const Schema: Zod.ZodUnion<readonly [Zod.ZodPipe<Zod.ZodNumber, Zod.ZodTransform<TimeZoneOffset, number>>, Zod.ZodPipe<Zod.ZodString, Zod.ZodTransform<TimeZoneOffset, string>>]>;
18
- export declare const toDuration: (offset: TimeZoneOffset) => Duration;
19
+ export declare const toDuration: (offset: TimeZoneOffset) => Durations.Duration;
19
20
  export declare const toMilliseconds: (offset: TimeZoneOffset) => number;
20
21
  export declare const toString: (offset: TimeZoneOffset) => string;
21
22
  export declare const Utc: TimeZoneOffset;
@@ -1 +1 @@
1
- {"version":3,"file":"time-zone-offset.d.ts","sourceRoot":"","sources":["../../src/temporal/time-zone-offset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EACL,QAAQ,EACR,YAAY,EAQb,MAAM,yCAAyC,CAAA;AAEhD,OAAO,EAAW,MAAM,EAAW,MAAM,8BAA8B,CAAA;AACvE,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAE,UAAU,EAA8B,MAAM,yCAAyC,CAAA;AAGhG,OAAO,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAA;AAExE,eAAO,MAAM,SAAS,oFAAsC,CAAA;AAC5D,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,EAAE,OAAO,SAAS,CAAC,CAAA;AAIlE,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,MAAM,CAAC,cAAc,EAAE,UAAU,CAU7E,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,OAAO,QAAQ,KAAG,MAAM,CAAC,cAAc,EAAE,UAAU,CAEhF,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,cAE3C,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,OAAO,YAAY,KAAG,cAElD,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,UAAU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AAc,EAAE,WAAW,CAAC,UAAU,CAE9G,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,cAE3C,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,OAAO,SAAS,CAAC,YAAY,KAAG,cAE5D,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,UAAU,UAAU,EAAE,SAAS,QAAQ,CAAC,OAAO,KAAG,cAsB9E,CAAA;AAGD,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,WAAW,CAAC,UAAU,CAyEhG,CAAA;AAED,eAAO,MAAM,IAAI,GAAI,OAAO,MAAM,KAAG,cAEpC,CAAA;AAED,eAAO,MAAM,MAAM,qKAA+H,CAAA;AAElJ,eAAO,MAAM,UAAU,GAAI,QAAQ,cAAc,KAAG,SAAS,CAAC,QAE7D,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,QAAQ,cAAc,KAAG,MAEvD,CAAA;AAED,eAAO,MAAM,QAAQ,GAAI,QAAQ,cAAc,KAAG,MASjD,CAAA;AAED,eAAO,MAAM,GAAG,EAAQ,cAAc,CAAA"}
@@ -1,38 +1,30 @@
1
1
  // src/temporal/time-zone-offset.ts
2
- import {
3
- from as _fromDuration,
4
- fromHours,
5
- fromMilliseconds,
6
- fromMinutes as durationFromMinutes,
7
- isGreater,
8
- isLess,
9
- toMinutes
10
- } from "@bessemer/cornerstone/temporal/duration";
11
- import { fromDuration as plainTimeFromDuration, toLiteral as plainTimeToLiteral } from "@bessemer/cornerstone/temporal/plain-time";
12
- import { failure, success } from "@bessemer/cornerstone/result";
2
+ import * as Durations from "@bessemer/cornerstone/temporal/duration";
3
+ import * as PlainTimes from "@bessemer/cornerstone/temporal/plain-time";
4
+ import * as Results from "@bessemer/cornerstone/result";
13
5
  import Zod from "zod";
14
- import { invalidValue, unpackResult } from "@bessemer/cornerstone/error/error-event";
15
- import { createNamespace } from "@bessemer/cornerstone/resource-key";
16
- import { structuredTransform } from "@bessemer/cornerstone/zod-util";
17
- var Namespace = createNamespace("time-zone-offset");
18
- var EighteenHours = fromHours(18);
6
+ import * as ErrorEvents from "@bessemer/cornerstone/error/error-event";
7
+ import * as ResourceKeys from "@bessemer/cornerstone/resource-key";
8
+ import * as ZodUtil from "@bessemer/cornerstone/zod-util";
9
+ var Namespace = ResourceKeys.createNamespace("time-zone-offset");
10
+ var EighteenHours = Durations.fromHours(18);
19
11
  var parseMinutes = (value) => {
20
12
  if (!Number.isInteger(value)) {
21
- return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be a round number of minutes.` }));
13
+ return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be a round number of minutes.` }));
22
14
  }
23
- if (value < toMinutes(EighteenHours.negated()) || value > toMinutes(EighteenHours)) {
24
- return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be between -18:00 and +18:00 inclusive.` }));
15
+ if (value < Durations.toMinutes(EighteenHours.negated()) || value > Durations.toMinutes(EighteenHours)) {
16
+ return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be between -18:00 and +18:00 inclusive.` }));
25
17
  }
26
- return success(value);
18
+ return Results.success(value);
27
19
  };
28
20
  var parseDuration = (value) => {
29
- return parseMinutes(toMinutes(value));
21
+ return parseMinutes(Durations.toMinutes(value));
30
22
  };
31
- var fromMinutes = (value) => {
32
- return unpackResult(parseMinutes(value));
23
+ var fromMinutes2 = (value) => {
24
+ return ErrorEvents.unpackResult(parseMinutes(value));
33
25
  };
34
- var fromDuration = (value) => {
35
- return unpackResult(parseDuration(_fromDuration(value)));
26
+ var fromDuration2 = (value) => {
27
+ return ErrorEvents.unpackResult(parseDuration(Durations.from(value)));
36
28
  };
37
29
  var fromTimeZone = (timeZone, instant) => {
38
30
  const instantWithoutMs = new Date(Math.floor(instant.epochMilliseconds / 1e3) * 1e3);
@@ -49,14 +41,14 @@ var fromTimeZone = (timeZone, instant) => {
49
41
  const formatted = formatter.format(instantWithoutMs);
50
42
  const localTime = (/* @__PURE__ */ new Date(formatted + "Z")).getTime();
51
43
  const offsetMs = localTime - instantWithoutMs.getTime();
52
- return fromDuration({ milliseconds: offsetMs });
44
+ return fromDuration2({ milliseconds: offsetMs });
53
45
  };
54
46
  var parseString = (value) => {
55
47
  if (value === "Z") {
56
- return success(0);
48
+ return Results.success(0);
57
49
  }
58
50
  if (!value.startsWith("+") && !value.startsWith("-")) {
59
- return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must start with +, -, or be Z.` }));
51
+ return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must start with +, -, or be Z.` }));
60
52
  }
61
53
  const sign = value[0] === "+" ? 1 : -1;
62
54
  const offsetStr = value.slice(1);
@@ -65,55 +57,55 @@ var parseString = (value) => {
65
57
  if (offsetStr.length === 1) {
66
58
  hours = parseInt(offsetStr, 10);
67
59
  if (isNaN(hours)) {
68
- return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid hour value in time zone offset.` }));
60
+ return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid hour value in time zone offset.` }));
69
61
  }
70
62
  } else if (offsetStr.length === 2) {
71
63
  hours = parseInt(offsetStr, 10);
72
64
  if (isNaN(hours)) {
73
- return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid hour value in time zone offset.` }));
65
+ return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid hour value in time zone offset.` }));
74
66
  }
75
67
  } else if (offsetStr.includes(":")) {
76
68
  const parts = offsetStr.split(":");
77
69
  if (parts.length < 2 || parts.length > 3) {
78
- return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time zone offset format.` }));
70
+ return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time zone offset format.` }));
79
71
  }
80
72
  hours = parseInt(parts[0], 10);
81
73
  minutes = parseInt(parts[1], 10);
82
74
  if (parts.length === 3) {
83
- return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }));
75
+ return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }));
84
76
  }
85
77
  if (isNaN(hours) || isNaN(minutes)) {
86
- return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }));
78
+ return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }));
87
79
  }
88
80
  } else if (offsetStr.length === 4) {
89
81
  hours = parseInt(offsetStr.slice(0, 2), 10);
90
82
  minutes = parseInt(offsetStr.slice(2, 4), 10);
91
83
  if (isNaN(hours) || isNaN(minutes)) {
92
- return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }));
84
+ return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }));
93
85
  }
94
86
  } else {
95
- return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time zone offset format.` }));
87
+ return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time zone offset format.` }));
96
88
  }
97
89
  if (minutes >= 60) {
98
- return failure(
99
- invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid minutes in time zone offset: must be less than 60.` })
90
+ return Results.failure(
91
+ ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid minutes in time zone offset: must be less than 60.` })
100
92
  );
101
93
  }
102
- let duration = _fromDuration({ hours, minutes });
94
+ let duration = Durations.from({ hours, minutes });
103
95
  if (sign === -1) {
104
96
  duration = duration.negated();
105
97
  }
106
- if (isLess(duration, EighteenHours.negated()) || isGreater(duration, EighteenHours)) {
107
- return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be between -18:00 and +18:00 inclusive.` }));
98
+ if (Durations.isLess(duration, EighteenHours.negated()) || Durations.isGreater(duration, EighteenHours)) {
99
+ return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be between -18:00 and +18:00 inclusive.` }));
108
100
  }
109
- return success(toMinutes(duration));
101
+ return Results.success(Durations.toMinutes(duration));
110
102
  };
111
- var from = (value) => {
112
- return unpackResult(parseString(value));
103
+ var from2 = (value) => {
104
+ return ErrorEvents.unpackResult(parseString(value));
113
105
  };
114
- var Schema = Zod.union([structuredTransform(Zod.number(), parseMinutes), structuredTransform(Zod.string(), parseString)]);
106
+ var Schema = Zod.union([ZodUtil.structuredTransform(Zod.number(), parseMinutes), ZodUtil.structuredTransform(Zod.string(), parseString)]);
115
107
  var toDuration = (offset) => {
116
- return fromMilliseconds(offset);
108
+ return Durations.fromMilliseconds(offset);
117
109
  };
118
110
  var toMilliseconds = (offset) => {
119
111
  return offset;
@@ -123,17 +115,17 @@ var toString = (offset) => {
123
115
  return "Z";
124
116
  }
125
117
  const sign = offset > 0 ? "+" : "-";
126
- const time = plainTimeFromDuration(durationFromMinutes(Math.abs(offset)));
127
- return `${sign}${plainTimeToLiteral(time)}`;
118
+ const time = PlainTimes.fromDuration(Durations.fromMinutes(Math.abs(offset)));
119
+ return `${sign}${PlainTimes.toLiteral(time)}`;
128
120
  };
129
121
  var Utc = 0;
130
122
  export {
131
123
  Namespace,
132
124
  Schema,
133
125
  Utc,
134
- from,
135
- fromDuration,
136
- fromMinutes,
126
+ from2 as from,
127
+ fromDuration2 as fromDuration,
128
+ fromMinutes2 as fromMinutes,
137
129
  fromTimeZone,
138
130
  parseDuration,
139
131
  parseMinutes,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/temporal/time-zone-offset.ts"],"sourcesContent":["import { NominalType } from '@bessemer/cornerstone/types'\nimport {\n Duration,\n DurationLike,\n from as _fromDuration,\n fromHours,\n fromMilliseconds,\n fromMinutes as durationFromMinutes,\n isGreater,\n isLess,\n toMinutes,\n} from '@bessemer/cornerstone/temporal/duration'\nimport { fromDuration as plainTimeFromDuration, toLiteral as plainTimeToLiteral } from '@bessemer/cornerstone/temporal/plain-time'\nimport { failure, Result, success } from '@bessemer/cornerstone/result'\nimport Zod from 'zod'\nimport { ErrorEvent, invalidValue, unpackResult } from '@bessemer/cornerstone/error/error-event'\nimport { createNamespace } from '@bessemer/cornerstone/resource-key'\nimport { structuredTransform } from '@bessemer/cornerstone/zod-util'\nimport { Instant } from '@bessemer/cornerstone/temporal/instant'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\n\nexport const Namespace = createNamespace('time-zone-offset')\nexport type TimeZoneOffset = NominalType<number, typeof Namespace>\n\nconst EighteenHours = fromHours(18)\n\nexport const parseMinutes = (value: number): Result<TimeZoneOffset, ErrorEvent> => {\n if (!Number.isInteger(value)) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be a round number of minutes.` }))\n }\n\n if (value < toMinutes(EighteenHours.negated()) || value > toMinutes(EighteenHours)) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be between -18:00 and +18:00 inclusive.` }))\n }\n\n return success(value as TimeZoneOffset)\n}\n\nexport const parseDuration = (value: Duration): Result<TimeZoneOffset, ErrorEvent> => {\n return parseMinutes(toMinutes(value))\n}\n\nexport const fromMinutes = (value: number): TimeZoneOffset => {\n return unpackResult(parseMinutes(value))\n}\n\nexport const fromDuration = (value: DurationLike): TimeZoneOffset => {\n return unpackResult(parseDuration(_fromDuration(value)))\n}\n\nexport const fromTimeZone = (timeZone: TimeZoneId, instant: Instant): TimeZoneOffset => {\n const instantWithoutMs = new Date(Math.floor(instant.epochMilliseconds / 1000) * 1000)\n\n // Note: We use 'en-CA' locale because it produces ISO 8601 format (YYYY-MM-DD, HH:MM:SS)\n // which is predictable and easily parseable. The locale only affects the output format,\n // not the timezone conversion - that's handled by the timeZone parameter.\n const formatter = new Intl.DateTimeFormat('en-CA', {\n timeZone: timeZone,\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: false,\n })\n\n const formatted = formatter.format(instantWithoutMs)\n const localTime = new Date(formatted + 'Z').getTime()\n\n const offsetMs = localTime - instantWithoutMs.getTime()\n return fromDuration({ milliseconds: offsetMs })\n}\n\n// JOHN maybe this parsing could be consolidated with LocalTime?\nexport const parseString = (value: string): Result<TimeZoneOffset, ErrorEvent> => {\n if (value === 'Z') {\n return success(0 as TimeZoneOffset)\n }\n\n if (!value.startsWith('+') && !value.startsWith('-')) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must start with +, -, or be Z.` }))\n }\n\n const sign = value[0] === '+' ? 1 : -1\n const offsetStr = value.slice(1)\n\n let hours = 0\n let minutes = 0\n\n // Parse different formats\n if (offsetStr.length === 1) {\n // +h format\n hours = parseInt(offsetStr, 10)\n if (isNaN(hours)) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid hour value in time zone offset.` }))\n }\n } else if (offsetStr.length === 2) {\n // +hh format\n hours = parseInt(offsetStr, 10)\n if (isNaN(hours)) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid hour value in time zone offset.` }))\n }\n } else if (offsetStr.includes(':')) {\n // Formats with colons: +hh:mm or +hh:mm:ss\n const parts = offsetStr.split(':')\n if (parts.length < 2 || parts.length > 3) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time zone offset format.` }))\n }\n\n hours = parseInt(parts[0]!, 10)\n minutes = parseInt(parts[1]!, 10)\n\n if (parts.length === 3) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }))\n }\n\n if (isNaN(hours) || isNaN(minutes)) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }))\n }\n } else if (offsetStr.length === 4) {\n // +hhmm format\n hours = parseInt(offsetStr.slice(0, 2), 10)\n minutes = parseInt(offsetStr.slice(2, 4), 10)\n\n if (isNaN(hours) || isNaN(minutes)) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }))\n }\n } else {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time zone offset format.` }))\n }\n\n if (minutes >= 60) {\n return failure(\n invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid minutes in time zone offset: must be less than 60.` })\n )\n }\n\n let duration = _fromDuration({ hours, minutes })\n if (sign === -1) {\n duration = duration.negated()\n }\n\n if (isLess(duration, EighteenHours.negated()) || isGreater(duration, EighteenHours)) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be between -18:00 and +18:00 inclusive.` }))\n }\n\n return success(toMinutes(duration) as TimeZoneOffset)\n}\n\nexport const from = (value: string): TimeZoneOffset => {\n return unpackResult(parseString(value))\n}\n\nexport const Schema = Zod.union([structuredTransform(Zod.number(), parseMinutes), structuredTransform(Zod.string(), parseString)])\n\nexport const toDuration = (offset: TimeZoneOffset): Duration => {\n return fromMilliseconds(offset)\n}\n\nexport const toMilliseconds = (offset: TimeZoneOffset): number => {\n return offset\n}\n\nexport const toString = (offset: TimeZoneOffset): string => {\n if (offset === 0) {\n return 'Z'\n }\n\n const sign = offset > 0 ? '+' : '-'\n\n const time = plainTimeFromDuration(durationFromMinutes(Math.abs(offset)))\n return `${sign}${plainTimeToLiteral(time)}`\n}\n\nexport const Utc = 0 as TimeZoneOffset\n"],"mappings":";AACA;AAAA,EAGE,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB,uBAAuB,aAAa,0BAA0B;AACvF,SAAS,SAAiB,eAAe;A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WAAW,CAAC,WAAmC;AAC1D,MAAI,WAAW,GAAG;AAChB,WAAO;AAAA,EACT;AAEA,QAAM,OAAO,SAAS,IAAI,MAAM;AAEhC,QAAM,OAAO,sBAAsB,oBAAoB,KAAK,IAAI,MAAM,CAAC,CAAC;AACxE,SAAO,GAAG,IAAI,GAAG,mBAAmB,IAAI,CAAC;AAC3C;AAEO,IAAM,MAAM;","names":[]}
1
+ {"version":3,"sources":["../../src/temporal/time-zone-offset.ts"],"sourcesContent":["import { NominalType } from '@bessemer/cornerstone/types'\nimport * as Durations from '@bessemer/cornerstone/temporal/duration'\nimport * as PlainTimes from '@bessemer/cornerstone/temporal/plain-time'\nimport * as Results from '@bessemer/cornerstone/result'\nimport Zod from 'zod'\nimport * as ErrorEvents from '@bessemer/cornerstone/error/error-event'\nimport * as ResourceKeys from '@bessemer/cornerstone/resource-key'\nimport * as ZodUtil from '@bessemer/cornerstone/zod-util'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\nimport * as Instants from '@bessemer/cornerstone/temporal/instant'\n\nexport const Namespace = ResourceKeys.createNamespace('time-zone-offset')\nexport type TimeZoneOffset = NominalType<number, typeof Namespace>\n\nconst EighteenHours = Durations.fromHours(18)\n\nexport const parseMinutes = (value: number): Results.Result<TimeZoneOffset, ErrorEvents.ErrorEvent> => {\n if (!Number.isInteger(value)) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be a round number of minutes.` }))\n }\n\n if (value < Durations.toMinutes(EighteenHours.negated()) || value > Durations.toMinutes(EighteenHours)) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be between -18:00 and +18:00 inclusive.` }))\n }\n\n return Results.success(value as TimeZoneOffset)\n}\n\nexport const parseDuration = (value: Durations.Duration): Results.Result<TimeZoneOffset, ErrorEvents.ErrorEvent> => {\n return parseMinutes(Durations.toMinutes(value))\n}\n\nexport const fromMinutes = (value: number): TimeZoneOffset => {\n return ErrorEvents.unpackResult(parseMinutes(value))\n}\n\nexport const fromDuration = (value: Durations.DurationLike): TimeZoneOffset => {\n return ErrorEvents.unpackResult(parseDuration(Durations.from(value)))\n}\n\nexport const fromTimeZone = (timeZone: TimeZoneId, instant: Instants.Instant): TimeZoneOffset => {\n const instantWithoutMs = new Date(Math.floor(instant.epochMilliseconds / 1000) * 1000)\n\n // Note: We use 'en-CA' locale because it produces ISO 8601 format (YYYY-MM-DD, HH:MM:SS)\n // which is predictable and easily parseable. The locale only affects the output format,\n // not the timezone conversion - that's handled by the timeZone parameter.\n const formatter = new Intl.DateTimeFormat('en-CA', {\n timeZone: timeZone,\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: false,\n })\n\n const formatted = formatter.format(instantWithoutMs)\n const localTime = new Date(formatted + 'Z').getTime()\n\n const offsetMs = localTime - instantWithoutMs.getTime()\n return fromDuration({ milliseconds: offsetMs })\n}\n\n// JOHN maybe this parsing could be consolidated with LocalTime?\nexport const parseString = (value: string): Results.Result<TimeZoneOffset, ErrorEvents.ErrorEvent> => {\n if (value === 'Z') {\n return Results.success(0 as TimeZoneOffset)\n }\n\n if (!value.startsWith('+') && !value.startsWith('-')) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must start with +, -, or be Z.` }))\n }\n\n const sign = value[0] === '+' ? 1 : -1\n const offsetStr = value.slice(1)\n\n let hours = 0\n let minutes = 0\n\n // Parse different formats\n if (offsetStr.length === 1) {\n // +h format\n hours = parseInt(offsetStr, 10)\n if (isNaN(hours)) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid hour value in time zone offset.` }))\n }\n } else if (offsetStr.length === 2) {\n // +hh format\n hours = parseInt(offsetStr, 10)\n if (isNaN(hours)) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid hour value in time zone offset.` }))\n }\n } else if (offsetStr.includes(':')) {\n // Formats with colons: +hh:mm or +hh:mm:ss\n const parts = offsetStr.split(':')\n if (parts.length < 2 || parts.length > 3) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time zone offset format.` }))\n }\n\n hours = parseInt(parts[0]!, 10)\n minutes = parseInt(parts[1]!, 10)\n\n if (parts.length === 3) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }))\n }\n\n if (isNaN(hours) || isNaN(minutes)) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }))\n }\n } else if (offsetStr.length === 4) {\n // +hhmm format\n hours = parseInt(offsetStr.slice(0, 2), 10)\n minutes = parseInt(offsetStr.slice(2, 4), 10)\n\n if (isNaN(hours) || isNaN(minutes)) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }))\n }\n } else {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time zone offset format.` }))\n }\n\n if (minutes >= 60) {\n return Results.failure(\n ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid minutes in time zone offset: must be less than 60.` })\n )\n }\n\n let duration = Durations.from({ hours, minutes })\n if (sign === -1) {\n duration = duration.negated()\n }\n\n if (Durations.isLess(duration, EighteenHours.negated()) || Durations.isGreater(duration, EighteenHours)) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be between -18:00 and +18:00 inclusive.` }))\n }\n\n return Results.success(Durations.toMinutes(duration) as TimeZoneOffset)\n}\n\nexport const from = (value: string): TimeZoneOffset => {\n return ErrorEvents.unpackResult(parseString(value))\n}\n\nexport const Schema = Zod.union([ZodUtil.structuredTransform(Zod.number(), parseMinutes), ZodUtil.structuredTransform(Zod.string(), parseString)])\n\nexport const toDuration = (offset: TimeZoneOffset): Durations.Duration => {\n return Durations.fromMilliseconds(offset)\n}\n\nexport const toMilliseconds = (offset: TimeZoneOffset): number => {\n return offset\n}\n\nexport const toString = (offset: TimeZoneOffset): string => {\n if (offset === 0) {\n return 'Z'\n }\n\n const sign = offset > 0 ? '+' : '-'\n\n const time = PlainTimes.fromDuration(Durations.fromMinutes(Math.abs(offset)))\n return `${sign}${PlainTimes.toLiteral(time)}`\n}\n\nexport const Utc = 0 as TimeZoneOffset\n"],"mappings":";AACA,YAAY,eAAe;AAC3B,YAAY,gBAAgB;AAC5B,YAAY,aAAa;AACzB,OAAO,SAAS;AAChB,YAAY,iBAAiB;AAC7B,YAAY,kBAAkB;AAC9B,YAAY,aAAa;AAIlB,IAAM,YAAyB,6BAAgB,kBAAkB;AAGxE,IAAM,gBAA0B,oBAAU,EAAE;AAErC,IAAM,eAAe,CAAC,UAA0E;AACrG,MAAI,CAAC,OAAO,UAAU,KAAK,GAAG;AAC5B,WAAe,gBAAoB,yBAAa,OAAO,EAAE,WAAW,WAAW,SAAS,oDAAoD,CAAC,CAAC;AAAA,EAChJ;AAEA,MAAI,QAAkB,oBAAU,cAAc,QAAQ,CAAC,KAAK,QAAkB,oBAAU,aAAa,GAAG;AACtG,WAAe,gBAAoB,yBAAa,OAAO,EAAE,WAAW,WAAW,SAAS,8DAA8D,CAAC,CAAC;AAAA,EAC1J;AAEA,SAAe,gBAAQ,KAAuB;AAChD;AAEO,IAAM,gBAAgB,CAAC,UAAsF;AAClH,SAAO,aAAuB,oBAAU,KAAK,CAAC;AAChD;AAEO,IAAMA,eAAc,CAAC,UAAkC;AAC5D,SAAmB,yBAAa,aAAa,KAAK,CAAC;AACrD;AAEO,IAAMC,gBAAe,CAAC,UAAkD;AAC7E,SAAmB,yBAAa,cAAwB,eAAK,KAAK,CAAC,CAAC;AACtE;AAEO,IAAM,eAAe,CAAC,UAAsB,YAA8C;AAC/F,Q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