@utk09/ui-observability 0.9.5 → 0.11.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 (259) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +315 -99
  3. package/bin/uiobs.mjs +8 -0
  4. package/dist/{batch-BQFtb3i5.cjs → batch-C8OcWR2L.cjs} +2 -2
  5. package/dist/{batch-BQFtb3i5.cjs.map → batch-C8OcWR2L.cjs.map} +1 -1
  6. package/dist/{batch-BUJh-1jZ.js → batch-CL9uWYY3.js} +5 -6
  7. package/dist/{batch-BUJh-1jZ.js.map → batch-CL9uWYY3.js.map} +1 -1
  8. package/dist/bus/bus.d.ts +15 -0
  9. package/dist/{bus-DeOPHWaD.js → bus-BZ0GldpT.js} +125 -112
  10. package/dist/bus-BZ0GldpT.js.map +1 -0
  11. package/dist/bus-VWlmM5xs.cjs +2 -0
  12. package/dist/bus-VWlmM5xs.cjs.map +1 -0
  13. package/dist/capture/interactions.d.ts +18 -0
  14. package/dist/capture/lifecycle.d.ts +20 -0
  15. package/dist/capture/reports.d.ts +17 -0
  16. package/dist/capture/resource-timing.d.ts +14 -0
  17. package/dist/capture/server-timing.d.ts +19 -0
  18. package/dist/capture/types.d.ts +13 -0
  19. package/dist/capture/unclean-exit.d.ts +31 -0
  20. package/dist/capture/user-timing.d.ts +22 -0
  21. package/dist/console-BPZCuSLc.cjs +2 -0
  22. package/dist/console-BPZCuSLc.cjs.map +1 -0
  23. package/dist/{console-DbAZYJuy.js → console-BeCF7n59.js} +20 -20
  24. package/dist/{console-DbAZYJuy.js.map → console-BeCF7n59.js.map} +1 -1
  25. package/dist/constants-DqKJH_MP.cjs +2 -0
  26. package/dist/constants-DqKJH_MP.cjs.map +1 -0
  27. package/dist/constants-zyrqveN4.js +304 -0
  28. package/dist/constants-zyrqveN4.js.map +1 -0
  29. package/dist/constants.d.ts +58 -2
  30. package/dist/context-storage-BjzeBSxH.cjs.map +1 -1
  31. package/dist/{context-storage-DxZf4Gfh.js → context-storage-BzkoHzkQ.js} +2 -3
  32. package/dist/{context-storage-DxZf4Gfh.js.map → context-storage-BzkoHzkQ.js.map} +1 -1
  33. package/dist/core/debug-buffer.d.ts +34 -0
  34. package/dist/core/debug-bundle.d.ts +12 -0
  35. package/dist/core/deferred.d.ts +7 -0
  36. package/dist/core/logger.d.ts +7 -2
  37. package/dist/core/measure.d.ts +19 -0
  38. package/dist/core/pipeline.d.ts +6 -1
  39. package/dist/core/record.d.ts +20 -1
  40. package/dist/core/remote-sampling.d.ts +5 -1
  41. package/dist/core/runtime.d.ts +45 -2
  42. package/dist/core/sampling.d.ts +5 -4
  43. package/dist/core/sender.d.ts +3 -1
  44. package/dist/core/spans.d.ts +5 -0
  45. package/dist/{deadline-5_PecIl5.js → deadline-BOjOxNHj.js} +3 -5
  46. package/dist/{deadline-5_PecIl5.js.map → deadline-BOjOxNHj.js.map} +1 -1
  47. package/dist/deadline-XSnm95pg.cjs.map +1 -1
  48. package/dist/debug-bundle-BzJNpbF0.cjs +2 -0
  49. package/dist/debug-bundle-BzJNpbF0.cjs.map +1 -0
  50. package/dist/debug-bundle-C7UkHZ-q.js +25 -0
  51. package/dist/debug-bundle-C7UkHZ-q.js.map +1 -0
  52. package/dist/doctor.cjs +2 -0
  53. package/dist/doctor.cjs.map +1 -0
  54. package/dist/doctor.d.ts +23 -0
  55. package/dist/doctor.js +98 -0
  56. package/dist/doctor.js.map +1 -0
  57. package/dist/{emergency-queue-Cs1hrjsC.cjs → emergency-queue-CNTRui5t.cjs} +2 -2
  58. package/dist/{emergency-queue-Cs1hrjsC.cjs.map → emergency-queue-CNTRui5t.cjs.map} +1 -1
  59. package/dist/{emergency-queue-BYUyDHGD.js → emergency-queue-Zy6lNafo.js} +17 -19
  60. package/dist/{emergency-queue-BYUyDHGD.js.map → emergency-queue-Zy6lNafo.js.map} +1 -1
  61. package/dist/{error-like-Ywo5uRHo.js → error-like-B11pB4aL.js} +2 -3
  62. package/dist/{error-like-Ywo5uRHo.js.map → error-like-B11pB4aL.js.map} +1 -1
  63. package/dist/error-like-gGRx2s36.cjs.map +1 -1
  64. package/dist/{errors-BhC7HTSt.js → errors-Dh7kef0i.js} +5 -6
  65. package/dist/{errors-BhC7HTSt.js.map → errors-Dh7kef0i.js.map} +1 -1
  66. package/dist/{errors-CgY633cG.cjs → errors-tfEr48bS.cjs} +2 -2
  67. package/dist/{errors-CgY633cG.cjs.map → errors-tfEr48bS.cjs.map} +1 -1
  68. package/dist/{factory-C5TujXlU.js → factory-BonqI3NL.js} +16 -20
  69. package/dist/{factory-C5TujXlU.js.map → factory-BonqI3NL.js.map} +1 -1
  70. package/dist/{factory-CNj4DH3n.cjs → factory-CJXVYp0R.cjs} +2 -2
  71. package/dist/{factory-CNj4DH3n.cjs.map → factory-CJXVYp0R.cjs.map} +1 -1
  72. package/dist/fixed-window-CvESpFYV.cjs.map +1 -1
  73. package/dist/{fixed-window-CtaFHanJ.js → fixed-window-Dq3MLUUv.js} +2 -3
  74. package/dist/{fixed-window-CtaFHanJ.js.map → fixed-window-Dq3MLUUv.js.map} +1 -1
  75. package/dist/global-scope-BN-Io_yv.cjs.map +1 -1
  76. package/dist/{global-scope-dp2jADRl.js → global-scope-D9I8s-oN.js} +2 -3
  77. package/dist/{global-scope-dp2jADRl.js.map → global-scope-D9I8s-oN.js.map} +1 -1
  78. package/dist/guards-Cidk71ME.js +7 -0
  79. package/dist/guards-Cidk71ME.js.map +1 -0
  80. package/dist/guards-nJ70syPt.cjs +2 -0
  81. package/dist/guards-nJ70syPt.cjs.map +1 -0
  82. package/dist/{identity-Da9TkuKd.cjs → identity-Cxgj6pZX.cjs} +2 -2
  83. package/dist/{identity-Da9TkuKd.cjs.map → identity-Cxgj6pZX.cjs.map} +1 -1
  84. package/dist/{identity-8vKkyAWm.js → identity-DT5VmvXy.js} +15 -16
  85. package/dist/{identity-8vKkyAWm.js.map → identity-DT5VmvXy.js.map} +1 -1
  86. package/dist/index.cjs +1 -1
  87. package/dist/index.cjs.map +1 -1
  88. package/dist/index.d.ts +27 -7
  89. package/dist/index.js +980 -604
  90. package/dist/index.js.map +1 -1
  91. package/dist/{indexeddb-storage-CCA1LvtO.js → indexeddb-storage-BJVtiQKm.js} +29 -30
  92. package/dist/{indexeddb-storage-CCA1LvtO.js.map → indexeddb-storage-BJVtiQKm.js.map} +1 -1
  93. package/dist/{indexeddb-storage-BTfIFRHF.cjs → indexeddb-storage-CIoW21Xd.cjs} +2 -2
  94. package/dist/{indexeddb-storage-BTfIFRHF.cjs.map → indexeddb-storage-CIoW21Xd.cjs.map} +1 -1
  95. package/dist/interactions-DTgKy_6K.js +119 -0
  96. package/dist/interactions-DTgKy_6K.js.map +1 -0
  97. package/dist/interactions-fEN6FbVo.cjs +2 -0
  98. package/dist/interactions-fEN6FbVo.cjs.map +1 -0
  99. package/dist/{journey-BUJ4WJxP.js → journey-CuJrHzEg.js} +18 -19
  100. package/dist/{journey-BUJ4WJxP.js.map → journey-CuJrHzEg.js.map} +1 -1
  101. package/dist/{journey-B_tTnvac.cjs → journey-pffMVMfa.cjs} +2 -2
  102. package/dist/{journey-B_tTnvac.cjs.map → journey-pffMVMfa.cjs.map} +1 -1
  103. package/dist/keys-BHhw_0Wh.cjs.map +1 -1
  104. package/dist/{keys-D5r_GH9q.js → keys-BU9j5YqW.js} +2 -3
  105. package/dist/{keys-D5r_GH9q.js.map → keys-BU9j5YqW.js.map} +1 -1
  106. package/dist/library-console-C1m6g1BR.js +13 -0
  107. package/dist/library-console-C1m6g1BR.js.map +1 -0
  108. package/dist/library-console-D2GY9Or6.cjs +2 -0
  109. package/dist/library-console-D2GY9Or6.cjs.map +1 -0
  110. package/dist/{library-request-BaZOi4eg.cjs → library-request-1BX_UlaX.cjs} +2 -2
  111. package/dist/{library-request-BaZOi4eg.cjs.map → library-request-1BX_UlaX.cjs.map} +1 -1
  112. package/dist/library-request-BQBT9N9Q.js +24 -0
  113. package/dist/{library-request-BKOcaKtQ.js.map → library-request-BQBT9N9Q.js.map} +1 -1
  114. package/dist/lifecycle-2EtUaRpo.cjs +2 -0
  115. package/dist/lifecycle-2EtUaRpo.cjs.map +1 -0
  116. package/dist/lifecycle-BaKx_-32.js +55 -0
  117. package/dist/lifecycle-BaKx_-32.js.map +1 -0
  118. package/dist/log-record-CAoGBBf3.js +16 -0
  119. package/dist/log-record-CAoGBBf3.js.map +1 -0
  120. package/dist/log-record-i9zOTkpQ.cjs +2 -0
  121. package/dist/log-record-i9zOTkpQ.cjs.map +1 -0
  122. package/dist/{long-frames-CF3qiSAX.cjs → long-frames-BVg4i5SC.cjs} +2 -2
  123. package/dist/{long-frames-CF3qiSAX.cjs.map → long-frames-BVg4i5SC.cjs.map} +1 -1
  124. package/dist/{long-frames-DI5ypfAF.js → long-frames-Czk7IupC.js} +4 -5
  125. package/dist/{long-frames-DI5ypfAF.js.map → long-frames-Czk7IupC.js.map} +1 -1
  126. package/dist/models/config.d.ts +168 -4
  127. package/dist/models/health.d.ts +25 -0
  128. package/dist/models/metric.d.ts +13 -0
  129. package/dist/models/storage.d.ts +5 -0
  130. package/dist/{network-DdzXDI3J.js → network-DBNwApoF.js} +117 -70
  131. package/dist/network-DBNwApoF.js.map +1 -0
  132. package/dist/network-xbbuvG_6.cjs +2 -0
  133. package/dist/network-xbbuvG_6.cjs.map +1 -0
  134. package/dist/openfin-Bxelt0yg.js +7 -0
  135. package/dist/{openfin-BwEN0uj4.js.map → openfin-Bxelt0yg.js.map} +1 -1
  136. package/dist/openfin-DtH2f7zX.cjs.map +1 -1
  137. package/dist/otlp-BDvFrLnc.cjs +2 -0
  138. package/dist/otlp-BDvFrLnc.cjs.map +1 -0
  139. package/dist/otlp-BTJdIa6F.js +81 -0
  140. package/dist/otlp-BTJdIa6F.js.map +1 -0
  141. package/dist/patch-BX8KrPCT.cjs.map +1 -1
  142. package/dist/{patch-CCWfuEY7.js → patch-UdPz1ea8.js} +2 -3
  143. package/dist/{patch-CCWfuEY7.js.map → patch-UdPz1ea8.js.map} +1 -1
  144. package/dist/{platform-DBSKTvFn.cjs → platform-C2Ez5kDc.cjs} +2 -2
  145. package/dist/{platform-DBSKTvFn.cjs.map → platform-C2Ez5kDc.cjs.map} +1 -1
  146. package/dist/{platform-Bw1btWCT.js → platform-DkcuXwe-.js} +5 -6
  147. package/dist/{platform-Bw1btWCT.js.map → platform-DkcuXwe-.js.map} +1 -1
  148. package/dist/remote-rules-Cfb4K-Nl.js +98 -0
  149. package/dist/remote-rules-Cfb4K-Nl.js.map +1 -0
  150. package/dist/remote-rules-vzvk7aKf.cjs +2 -0
  151. package/dist/remote-rules-vzvk7aKf.cjs.map +1 -0
  152. package/dist/reports-Dk2YhKIh.cjs +2 -0
  153. package/dist/reports-Dk2YhKIh.cjs.map +1 -0
  154. package/dist/reports-TA-zInnq.js +70 -0
  155. package/dist/reports-TA-zInnq.js.map +1 -0
  156. package/dist/resource-timing-BLv3EA2A.js +76 -0
  157. package/dist/resource-timing-BLv3EA2A.js.map +1 -0
  158. package/dist/resource-timing-Cysw1S1f.cjs +2 -0
  159. package/dist/resource-timing-Cysw1S1f.cjs.map +1 -0
  160. package/dist/sampling-C4VV-1MS.js +60 -0
  161. package/dist/sampling-C4VV-1MS.js.map +1 -0
  162. package/dist/sampling-Ckh2yW9k.cjs +2 -0
  163. package/dist/sampling-Ckh2yW9k.cjs.map +1 -0
  164. package/dist/sanitize-6ymPlVvP.js +112 -0
  165. package/dist/sanitize-6ymPlVvP.js.map +1 -0
  166. package/dist/sanitize-BAWzkZt0.cjs +2 -0
  167. package/dist/sanitize-BAWzkZt0.cjs.map +1 -0
  168. package/dist/select-ZF4by-lF.cjs +3 -0
  169. package/dist/select-ZF4by-lF.cjs.map +1 -0
  170. package/dist/select-xtQaenIi.js +270 -0
  171. package/dist/select-xtQaenIi.js.map +1 -0
  172. package/dist/{sender-DUUmSglb.js → sender-CiMHC9YG.js} +202 -509
  173. package/dist/sender-CiMHC9YG.js.map +1 -0
  174. package/dist/sender-D5wBoXA8.cjs +2 -0
  175. package/dist/sender-D5wBoXA8.cjs.map +1 -0
  176. package/dist/storage/persistence.d.ts +8 -0
  177. package/dist/storage-BA9RqRO-.cjs.map +1 -1
  178. package/dist/{storage-w7Tslvlq.js → storage-DZwed89z.js} +2 -3
  179. package/dist/storage-DZwed89z.js.map +1 -0
  180. package/dist/storm-CYi9Swpx.cjs +2 -0
  181. package/dist/{storm-CNZjsw4T.cjs.map → storm-CYi9Swpx.cjs.map} +1 -1
  182. package/dist/{storm-Daq2jGHU.js → storm-VR024_QN.js} +4 -5
  183. package/dist/{storm-Daq2jGHU.js.map → storm-VR024_QN.js.map} +1 -1
  184. package/dist/transport/headers.d.ts +8 -0
  185. package/dist/transport/http-transport.d.ts +2 -6
  186. package/dist/transport/serializers/otlp.d.ts +14 -0
  187. package/dist/transport/status-transport.d.ts +5 -2
  188. package/dist/transport/worker-client.d.ts +14 -0
  189. package/dist/transport/worker-entry.d.ts +5 -0
  190. package/dist/transport/worker-protocol.d.ts +36 -0
  191. package/dist/transport/worker-server.d.ts +3 -0
  192. package/dist/transport/worker-transport.d.ts +9 -0
  193. package/dist/{types-BR9t_w28.js → types-BAerHgCq.js} +2 -3
  194. package/dist/types-BAerHgCq.js.map +1 -0
  195. package/dist/types-C7WNpnG1.cjs.map +1 -1
  196. package/dist/unclean-exit-CwcUhFOn.js +62 -0
  197. package/dist/unclean-exit-CwcUhFOn.js.map +1 -0
  198. package/dist/unclean-exit-DFUN57wY.cjs +2 -0
  199. package/dist/unclean-exit-DFUN57wY.cjs.map +1 -0
  200. package/dist/user-timing-C9kfRq3J.cjs +2 -0
  201. package/dist/user-timing-C9kfRq3J.cjs.map +1 -0
  202. package/dist/user-timing-_jZIhDKI.js +63 -0
  203. package/dist/user-timing-_jZIhDKI.js.map +1 -0
  204. package/dist/{web-socket-BacvKOvD.cjs → web-socket-BWUoqBh8.cjs} +2 -2
  205. package/dist/{web-socket-BacvKOvD.cjs.map → web-socket-BWUoqBh8.cjs.map} +1 -1
  206. package/dist/{web-socket-CpsD8WAa.js → web-socket-CV7yIMnm.js} +7 -8
  207. package/dist/{web-socket-CpsD8WAa.js.map → web-socket-CV7yIMnm.js.map} +1 -1
  208. package/dist/{web-vitals-Bflr5jSA.js → web-vitals-Bq4WFHQo.js} +2 -3
  209. package/dist/{web-vitals-Bflr5jSA.js.map → web-vitals-Bq4WFHQo.js.map} +1 -1
  210. package/dist/web-vitals-DFuoTQbZ.cjs.map +1 -1
  211. package/dist/worker-protocol-Bai7GAIA.cjs +2 -0
  212. package/dist/worker-protocol-Bai7GAIA.cjs.map +1 -0
  213. package/dist/worker-protocol-CrsdSDLn.js +49 -0
  214. package/dist/worker-protocol-CrsdSDLn.js.map +1 -0
  215. package/dist/worker-server-BrIYkfoa.cjs +2 -0
  216. package/dist/worker-server-BrIYkfoa.cjs.map +1 -0
  217. package/dist/worker-server-Dp5HYm4b.js +83 -0
  218. package/dist/worker-server-Dp5HYm4b.js.map +1 -0
  219. package/dist/worker-transport-Bwej4N2e.cjs +2 -0
  220. package/dist/worker-transport-Bwej4N2e.cjs.map +1 -0
  221. package/dist/worker-transport-D6jtgpqN.js +199 -0
  222. package/dist/worker-transport-D6jtgpqN.js.map +1 -0
  223. package/package.json +31 -41
  224. package/dist/bus-BW6N-pY8.cjs +0 -2
  225. package/dist/bus-BW6N-pY8.cjs.map +0 -1
  226. package/dist/bus-DeOPHWaD.js.map +0 -1
  227. package/dist/console-Ce6heqZZ.cjs +0 -2
  228. package/dist/console-Ce6heqZZ.cjs.map +0 -1
  229. package/dist/constants-CN7GE1Lt.js +0 -246
  230. package/dist/constants-CN7GE1Lt.js.map +0 -1
  231. package/dist/constants-CW-MlHdY.cjs +0 -2
  232. package/dist/constants-CW-MlHdY.cjs.map +0 -1
  233. package/dist/interactions-BUDLxbv1.js +0 -74
  234. package/dist/interactions-BUDLxbv1.js.map +0 -1
  235. package/dist/interactions-NHbLKrqe.cjs +0 -2
  236. package/dist/interactions-NHbLKrqe.cjs.map +0 -1
  237. package/dist/library-request-BKOcaKtQ.js +0 -25
  238. package/dist/network-CF8UO5PK.cjs +0 -2
  239. package/dist/network-CF8UO5PK.cjs.map +0 -1
  240. package/dist/network-DdzXDI3J.js.map +0 -1
  241. package/dist/openfin-BwEN0uj4.js +0 -8
  242. package/dist/remote-rules-DIcC5vVC.js +0 -91
  243. package/dist/remote-rules-DIcC5vVC.js.map +0 -1
  244. package/dist/remote-rules-DpFmOef2.cjs +0 -2
  245. package/dist/remote-rules-DpFmOef2.cjs.map +0 -1
  246. package/dist/sampling-BVjspJWu.cjs +0 -2
  247. package/dist/sampling-BVjspJWu.cjs.map +0 -1
  248. package/dist/sampling-Cm3WhI0a.js +0 -76
  249. package/dist/sampling-Cm3WhI0a.js.map +0 -1
  250. package/dist/sanitize-C-ahCFsG.js +0 -123
  251. package/dist/sanitize-C-ahCFsG.js.map +0 -1
  252. package/dist/sanitize-DHucKGdi.cjs +0 -2
  253. package/dist/sanitize-DHucKGdi.cjs.map +0 -1
  254. package/dist/sender-D3fRCR8d.cjs +0 -3
  255. package/dist/sender-D3fRCR8d.cjs.map +0 -1
  256. package/dist/sender-DUUmSglb.js.map +0 -1
  257. package/dist/storage-w7Tslvlq.js.map +0 -1
  258. package/dist/storm-CNZjsw4T.cjs +0 -2
  259. package/dist/types-BR9t_w28.js.map +0 -1
@@ -0,0 +1,81 @@
1
+ import { Mn as e, R as t, a as n, mn as r, tt as i } from "./constants-zyrqveN4.js";
2
+ // src/transport/compression.ts
3
+ async function a(e) {
4
+ let t = globalThis.CompressionStream;
5
+ if (t === void 0) return null;
6
+ let n = new Blob([e]).stream().pipeThrough(new t(i)), r = await new Response(n).arrayBuffer();
7
+ return new Uint8Array(r);
8
+ }
9
+ // src/transport/serializers/otlp.ts
10
+ function o(e) {
11
+ return e == null ? null : typeof e == "string" ? { stringValue: e } : typeof e == "boolean" ? { boolValue: e } : typeof e == "number" ? Number.isSafeInteger(e) ? { intValue: String(e) } : { doubleValue: e } : typeof e == "bigint" ? { intValue: e.toString() } : Array.isArray(e) ? { arrayValue: { values: e.map(o).filter((e) => e !== null) } } : typeof e == "object" ? { kvlistValue: { values: s(e) } } : null;
12
+ }
13
+ function s(e) {
14
+ let t = [];
15
+ for (let [n, r] of Object.entries(e)) {
16
+ let e = o(r);
17
+ e && t.push({
18
+ key: n,
19
+ value: e
20
+ });
21
+ }
22
+ return t;
23
+ }
24
+ var c = /* @__PURE__ */ new WeakMap();
25
+ function l(e) {
26
+ let t = c.get(e);
27
+ if (t !== void 0) return t;
28
+ let n = JSON.stringify(e);
29
+ return c.set(e, n), n;
30
+ }
31
+ function u(e) {
32
+ let t = /* @__PURE__ */ new Map();
33
+ for (let n of e) {
34
+ let e = l(n.resource), r = t.get(e);
35
+ r ? r.records.push(n) : t.set(e, {
36
+ resource: n.resource,
37
+ records: [n]
38
+ });
39
+ }
40
+ return [...t.values()];
41
+ }
42
+ function d(t) {
43
+ let r = /* @__PURE__ */ new Map();
44
+ for (let i of t) {
45
+ let t = i.attributes[n], a = typeof t == "string" && t ? t : e, o = r.get(a);
46
+ o ? o.push(i) : r.set(a, [i]);
47
+ }
48
+ return [...r].map(([e, t]) => ({
49
+ name: e,
50
+ records: t
51
+ }));
52
+ }
53
+ var f = {
54
+ name: r,
55
+ serialize(e) {
56
+ let n = u(e).map((e) => ({
57
+ resource: { attributes: s(e.resource) },
58
+ scopeLogs: d(e.records).map((e) => ({
59
+ scope: { name: e.name },
60
+ logRecords: e.records.map((e) => ({
61
+ timeUnixNano: e.timeUnixNano,
62
+ observedTimeUnixNano: e.observedTimeUnixNano ?? e.timeUnixNano,
63
+ severityNumber: e.severityNumber,
64
+ severityText: e.severityText,
65
+ body: { stringValue: e.body },
66
+ traceId: e.traceId,
67
+ spanId: e.spanId,
68
+ flags: e.traceFlags,
69
+ attributes: s(e.attributes)
70
+ }))
71
+ }))
72
+ }));
73
+ return {
74
+ body: JSON.stringify({ resourceLogs: n }),
75
+ contentType: t
76
+ };
77
+ }
78
+ };
79
+ export { a, s as i, d as n, f as r, u as t };
80
+
81
+ //# sourceMappingURL=otlp-BTJdIa6F.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otlp-BTJdIa6F.js","names":["items","nested","TELEMETRY_SDK_NAME","CONTENT_TYPE_JSON","ATTR_APP_NAMESPACE","SERIALIZER_NAME_OTLP","ENCODING_GZIP","gzip","CS","stream","text","buffer","toAnyValue","value","item","toKeyValues","out","key","raw","source","resourceKeys","resourceKey","cached","resource","groupByResource","groups","record","records","group","groupByScope","namespace","name","scoped","otlpSerializer","resourceLogs","scope"],"sources":["../src/transport/compression.ts","../src/transport/serializers/otlp.ts"],"sourcesContent":["// src/transport/compression.ts\n//\n// This module compresses payloads with the native CompressionStream API. It returns null\n// when the API is absent. It does not return raw text. The server rejects a non-gzip body\n// that has a \"Content-Encoding: gzip\" header with a 400 status.\n\nimport { ENCODING_GZIP } from \"../constants\";\n\n/**\n * Compresses a string to gzip bytes with CompressionStream. The result is a\n * Uint8Array on a non-shared ArrayBuffer. fetch accepts this result as BodyInit.\n * @param text Raw serialized payload to compress.\n * @returns Promise that resolves to the gzip bytes, or null without CompressionStream.\n */\nexport async function gzip(text: string): Promise<Uint8Array<ArrayBuffer> | null> {\n const CS = (globalThis as { CompressionStream?: typeof CompressionStream }).CompressionStream;\n if (CS === undefined) {\n return null;\n }\n\n const stream = new Blob([text]).stream().pipeThrough(new CS(ENCODING_GZIP));\n const buffer = await new Response(stream).arrayBuffer();\n\n return new Uint8Array(buffer);\n}\n","// src/transport/serializers/otlp.ts\n//\n// This module serializes log batches as OTLP/JSON log records. It groups the records by resource.\n// It gives each logger namespace its own instrumentation scope.\n// The OTLP metrics serializer uses its value encoding and its resource grouping.\n\nimport {\n ATTR_APP_NAMESPACE,\n CONTENT_TYPE_JSON,\n SERIALIZER_NAME_OTLP,\n TELEMETRY_SDK_NAME,\n} from \"../../constants\";\nimport type { LogRecord } from \"../../models/log-record\";\nimport type { LogSerializer, SerializedBatch } from \"../../models/serializer\";\n\n/** This type holds an OTLP AnyValue with typed value wrappers. */\ntype AnyValue = Record<string, unknown>;\n\n/** This interface holds an OTLP KeyValue pair. */\nexport interface KeyValue {\n /** This field holds the attribute key. */\n key: string;\n /** This field holds the typed AnyValue. */\n value: AnyValue;\n}\n\n/** This interface holds the records that share resource attributes. */\nexport interface ResourceGroup {\n /** This field holds the resource attribute map. */\n resource: Record<string, unknown>;\n /** This field holds the log records of the resource. */\n records: LogRecord[];\n}\n\n/**\n * Wraps a JavaScript value in an OTLP AnyValue.\n * @param value Raw attribute or resource value.\n * @returns Typed AnyValue object or null if unsupported.\n */\nfunction toAnyValue(value: unknown): AnyValue | null {\n if (value === null || value === undefined) {\n return null;\n }\n\n if (typeof value === \"string\") {\n return { stringValue: value };\n }\n\n if (typeof value === \"boolean\") {\n return { boolValue: value };\n }\n\n // Encode int64 as a decimal string. The OTLP protobuf JSON mapping requires it. A conforming\n // collector returns a 400 status for a number. The response does not give the cause.\n // An integer above MAX_SAFE_INTEGER goes to doubleValue. Its text can be \"1e+21\" or overflow int64.\n if (typeof value === \"number\") {\n return Number.isSafeInteger(value) ? { intValue: String(value) } : { doubleValue: value };\n }\n\n // Convert a BigInt to a decimal string. JSON.stringify throws on a BigInt and loses the\n // batch.\n if (typeof value === \"bigint\") {\n return { intValue: value.toString() };\n }\n\n if (Array.isArray(value)) {\n const items: readonly unknown[] = value;\n const values = items.map(toAnyValue).filter((item): item is AnyValue => item !== null);\n\n return { arrayValue: { values } };\n }\n\n if (typeof value === \"object\") {\n const nested = value as Record<string, unknown>;\n return { kvlistValue: { values: toKeyValues(nested) } };\n }\n\n return null;\n}\n\n/**\n * Converts a plain object to an array of OTLP KeyValue pairs.\n * @param source Key-value attribute object.\n * @returns Array of valid KeyValue pairs.\n */\nexport function toKeyValues(source: Record<string, unknown>): KeyValue[] {\n const out: KeyValue[] = [];\n\n for (const [key, raw] of Object.entries(source)) {\n const value = toAnyValue(raw);\n if (value) {\n out.push({ key, value });\n }\n }\n\n return out;\n}\n\n/** This map caches the JSON key of each resource object. It prevents a repeated stringify. */\nconst resourceKeys = new WeakMap<object, string>();\n\n/**\n * Returns the stable JSON key of a resource object. It caches the key.\n * @param resource Resource attribute object.\n * @returns JSON key string.\n */\nfunction resourceKey(resource: Record<string, unknown>): string {\n const cached = resourceKeys.get(resource);\n if (cached !== undefined) {\n return cached;\n }\n\n const key = JSON.stringify(resource);\n resourceKeys.set(resource, key);\n\n return key;\n}\n\n/**\n * Groups records by their resource attributes. It keeps the record order in each group.\n * @param records Records to group.\n * @returns One group for each resource.\n */\nexport function groupByResource(records: LogRecord[]): ResourceGroup[] {\n const groups = new Map<string, ResourceGroup>();\n\n for (const record of records) {\n const key = resourceKey(record.resource);\n const group = groups.get(key);\n\n if (group) {\n group.records.push(record);\n continue;\n }\n\n groups.set(key, { resource: record.resource, records: [record] });\n }\n\n return [...groups.values()];\n}\n\n/** This interface holds the records of one instrumentation scope. */\nexport interface ScopeGroup {\n /** This field holds the scope name. It is the logger namespace. */\n name: string;\n /** This field holds the records of the scope. */\n records: LogRecord[];\n}\n\n/**\n * Groups records by their logger namespace. It keeps the record order in each group.\n * A record without a namespace goes to the scope of the library.\n * @param records Records of one resource.\n * @returns One group for each namespace.\n */\nexport function groupByScope(records: LogRecord[]): ScopeGroup[] {\n const groups = new Map<string, LogRecord[]>();\n\n for (const record of records) {\n const namespace: unknown = record.attributes[ATTR_APP_NAMESPACE];\n const name = typeof namespace === \"string\" && namespace ? namespace : TELEMETRY_SDK_NAME;\n const group = groups.get(name);\n\n if (group) {\n group.push(record);\n continue;\n }\n\n groups.set(name, [record]);\n }\n\n return [...groups].map(([name, scoped]) => ({ name, records: scoped }));\n}\n\n/** This serializer writes log records as OTLP/JSON payloads. */\nexport const otlpSerializer: LogSerializer = {\n /** This field holds the format name. */\n name: SERIALIZER_NAME_OTLP,\n\n /**\n * Groups records by resource. It encodes them as an OTLP\n * ExportLogsServiceRequest JSON payload.\n * @param records Array of log records to serialize.\n * @returns Serialized JSON batch payload.\n */\n serialize(records: LogRecord[]): SerializedBatch {\n const resourceLogs = groupByResource(records).map((group) => ({\n resource: { attributes: toKeyValues(group.resource) },\n scopeLogs: groupByScope(group.records).map((scope) => ({\n scope: { name: scope.name },\n logRecords: scope.records.map((record) => ({\n timeUnixNano: record.timeUnixNano,\n // Use timeUnixNano when observedTimeUnixNano is not set.\n observedTimeUnixNano: record.observedTimeUnixNano ?? record.timeUnixNano,\n severityNumber: record.severityNumber,\n severityText: record.severityText,\n body: { stringValue: record.body },\n traceId: record.traceId,\n spanId: record.spanId,\n flags: record.traceFlags,\n attributes: toKeyValues(record.attributes),\n })),\n })),\n }));\n\n return {\n body: JSON.stringify({ resourceLogs }),\n contentType: CONTENT_TYPE_JSON,\n };\n },\n};\n"],"mappings":";;AAcA,eAAsBO,EAAK,GAAuD;CAChF,IAAMC,IAAM,WAAgE;CAC5E,IAAIA,MAAO,KAAA,GACT,OAAO;CAGT,IAAMC,IAAS,IAAI,KAAK,CAACC,CAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,YAAY,IAAIF,EAAGF,CAAa,CAAC,GACpEK,IAAS,MAAM,IAAI,SAASF,CAAM,CAAC,CAAC,YAAY;CAEtD,OAAO,IAAI,WAAWE,CAAM;AAC9B;;ACeA,SAASC,EAAW,GAAiC;CAsCnD,OArCIC,KAAU,OACL,OAGL,OAAOA,KAAU,WACZ,EAAE,aAAaA,EAAM,IAG1B,OAAOA,KAAU,YACZ,EAAE,WAAWA,EAAM,IAMxB,OAAOA,KAAU,WACZ,OAAO,cAAcA,CAAK,IAAI,EAAE,UAAU,OAAOA,CAAK,EAAE,IAAI,EAAE,aAAaA,EAAM,IAKtF,OAAOA,KAAU,WACZ,EAAE,UAAUA,EAAM,SAAS,EAAE,IAGlC,MAAM,QAAQA,CAAK,IAId,EAAE,YAAY,EAAE,QAFRb,EAAM,IAAIY,CAAU,CAAC,CAAC,QAAQ,MAA2BE,MAAS,IAE1D,EAAO,EAAE,IAG9B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O,CAAC,GAAGD,CAAM,CAAC,CAAC,KAAK,CAACM,GAAMC,QAAa;EAAE;EAAM,SAASA;CAAO,EAAE;AACxE;AAGA,IAAaC,IAAgC;CAE3C,MAAM5B;CAQN,UAAU,GAAuC;EAC/C,IAAM6B,IAAeV,EAAgBG,CAAO,CAAC,CAAC,KAAK,OAAW;GAC5D,UAAU,EAAE,YAAYZ,EAAYa,EAAM,QAAQ,EAAE;GACpD,WAAWC,EAAaD,EAAM,OAAO,CAAC,CAAC,KAAK,OAAW;IACrD,OAAO,EAAE,MAAMO,EAAM,KAAK;IAC1B,YAAYA,EAAM,QAAQ,KAAK,OAAY;KACzC,cAAcT,EAAO;KAErB,sBAAsBA,EAAO,wBAAwBA,EAAO;KAC5D,gBAAgBA,EAAO;KACvB,cAAcA,EAAO;KACrB,MAAM,EAAE,aAAaA,EAAO,KAAK;KACjC,SAASA,EAAO;KAChB,QAAQA,EAAO;KACf,OAAOA,EAAO;KACd,YAAYX,EAAYW,EAAO,UAAU;IAC3C,EAAE;GACJ,EAAE;EACJ,EAAE;EAEF,OAAO;GACL,MAAM,KAAK,UAAU,EAAE,gBAAa,CAAC;GACrC,aAAavB;EACf;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"patch-BX8KrPCT.cjs","names":["patch","original","target","key","wrapper","wrap"],"sources":["../src/utils/patch.ts"],"sourcesContent":["// src/utils/patch.ts\n//\n// Replaces a host function with a wrapper and gives back a safe restore. A router or a\n// second SDK can wrap the same function after the library. A blind restore removes that\n// wrapper and breaks the host page.\n\n/**\n * Replaces `target[key]` with a wrapper of the current value.\n * @param target Object that holds the function, for example `console` or `globalThis`.\n * @param key Property to replace.\n * @param wrap Makes the wrapper from the original value.\n * @returns Restore function. It writes the original back only if the property still holds\n * the wrapper. It then returns true. If not, it changes nothing. It returns false.\n */\nexport function patch<T extends object, K extends keyof T>(\n target: T,\n key: K,\n wrap: (original: T[K]) => T[K],\n): () => boolean {\n const original = target[key];\n const wrapper = wrap(original);\n target[key] = wrapper;\n\n return () => {\n // Another script wrapped the property after the library. Keep its wrapper.\n if (target[key] !== wrapper) {\n return false;\n }\n\n target[key] = original;\n return true;\n };\n}\n"],"mappings":"AAcA,SAAgBA,EACd,EACA,EACA,EACe,CACf,IAAMC,EAAWC,EAAOC,GAClBC,EAAUC,EAAKJ,CAAQ,EAG7B,MAFA,GAAOE,GAAOC,MAIRF,EAAOC,KAASC,IAIpB,EAAOD,GAAOF,EACP,GAEX"}
1
+ {"version":3,"file":"patch-BX8KrPCT.cjs","names":["patch","original","target","key","wrapper","wrap"],"sources":["../src/utils/patch.ts"],"sourcesContent":["// src/utils/patch.ts\n//\n// Replaces a host function with a wrapper and gives back a safe restore. A router or a\n// second SDK can wrap the same function after the library. A blind restore removes that\n// wrapper and breaks the host page.\n\n/**\n * Replaces `target[key]` with a wrapper of the current value.\n * @param target Object that holds the function, for example `console` or `globalThis`.\n * @param key Property to replace.\n * @param wrap Makes the wrapper from the original value.\n * @returns Restore function. It writes the original back only if the property still holds\n * the wrapper. It then returns true. If not, it changes nothing. It returns false.\n */\nexport function patch<T extends object, K extends keyof T>(\n target: T,\n key: K,\n wrap: (original: T[K]) => T[K],\n): () => boolean {\n const original = target[key];\n const wrapper = wrap(original);\n target[key] = wrapper;\n\n return () => {\n // Another script wrapped the property after the library. Keep its wrapper.\n if (target[key] !== wrapper) {\n return false;\n }\n\n target[key] = original;\n return true;\n };\n}\n"],"mappings":"AAcA,SAAgBA,EACd,EACA,EACA,EACe,CACf,IAAMC,EAAWC,EAAOC,GAClBC,EAAUC,EAAKJ,CAAQ,EAG7B,MAFA,GAAOE,GAAOC,MAIRF,EAAOC,KAASC,IAIpB,EAAOD,GAAOF,EACP,GAEX,C"}
@@ -1,9 +1,8 @@
1
- //#region src/utils/patch.ts
1
+ // src/utils/patch.ts
2
2
  function e(e, t, n) {
3
3
  let r = e[t], i = n(r);
4
4
  return e[t] = i, () => e[t] === i && (e[t] = r, !0);
5
5
  }
6
- //#endregion
7
6
  export { e as t };
8
7
 
9
- //# sourceMappingURL=patch-CCWfuEY7.js.map
8
+ //# sourceMappingURL=patch-UdPz1ea8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"patch-CCWfuEY7.js","names":["patch","original","target","key","wrapper","wrap"],"sources":["../src/utils/patch.ts"],"sourcesContent":["// src/utils/patch.ts\n//\n// Replaces a host function with a wrapper and gives back a safe restore. A router or a\n// second SDK can wrap the same function after the library. A blind restore removes that\n// wrapper and breaks the host page.\n\n/**\n * Replaces `target[key]` with a wrapper of the current value.\n * @param target Object that holds the function, for example `console` or `globalThis`.\n * @param key Property to replace.\n * @param wrap Makes the wrapper from the original value.\n * @returns Restore function. It writes the original back only if the property still holds\n * the wrapper. It then returns true. If not, it changes nothing. It returns false.\n */\nexport function patch<T extends object, K extends keyof T>(\n target: T,\n key: K,\n wrap: (original: T[K]) => T[K],\n): () => boolean {\n const original = target[key];\n const wrapper = wrap(original);\n target[key] = wrapper;\n\n return () => {\n // Another script wrapped the property after the library. Keep its wrapper.\n if (target[key] !== wrapper) {\n return false;\n }\n\n target[key] = original;\n return true;\n };\n}\n"],"mappings":";AAcA,SAAgBA,EACd,GACA,GACA,GACe;CACf,IAAMC,IAAWC,EAAOC,IAClBC,IAAUC,EAAKJ,CAAQ;CAG7B,OAFA,EAAOE,KAAOC,SAIRF,EAAOC,OAASC,MAIpB,EAAOD,KAAOF,GACP;AAEX"}
1
+ {"version":3,"file":"patch-UdPz1ea8.js","names":["patch","original","target","key","wrapper","wrap"],"sources":["../src/utils/patch.ts"],"sourcesContent":["// src/utils/patch.ts\n//\n// Replaces a host function with a wrapper and gives back a safe restore. A router or a\n// second SDK can wrap the same function after the library. A blind restore removes that\n// wrapper and breaks the host page.\n\n/**\n * Replaces `target[key]` with a wrapper of the current value.\n * @param target Object that holds the function, for example `console` or `globalThis`.\n * @param key Property to replace.\n * @param wrap Makes the wrapper from the original value.\n * @returns Restore function. It writes the original back only if the property still holds\n * the wrapper. It then returns true. If not, it changes nothing. It returns false.\n */\nexport function patch<T extends object, K extends keyof T>(\n target: T,\n key: K,\n wrap: (original: T[K]) => T[K],\n): () => boolean {\n const original = target[key];\n const wrapper = wrap(original);\n target[key] = wrapper;\n\n return () => {\n // Another script wrapped the property after the library. Keep its wrapper.\n if (target[key] !== wrapper) {\n return false;\n }\n\n target[key] = original;\n return true;\n };\n}\n"],"mappings":";AAcA,SAAgBA,EACd,GACA,GACA,GACe;CACf,IAAMC,IAAWC,EAAOC,IAClBC,IAAUC,EAAKJ,CAAQ;CAG7B,OAFA,EAAOE,KAAOC,SAIRF,EAAOC,OAASC,MAIpB,EAAOD,KAAOF,GACP;AAEX"}
@@ -1,2 +1,2 @@
1
- const e=require("./constants-CW-MlHdY.cjs"),t=require("./openfin-DtH2f7zX.cjs");var n=null;function r(e,t){let n=e[t];return n!==void 0&&e instanceof n}function i(i){if(n)return n;let s=globalThis,c=s.navigator?.userAgent??``,l=`browser`,u,d,f=!1,p=t.t()?.me;return r(s,`ServiceWorkerGlobalScope`)?(l=`service_worker`,f=!0):r(s,`SharedWorkerGlobalScope`)?(l=`shared_worker`,f=!0):r(s,`WorkerGlobalScope`)?(l=`web_worker`,f=!0):p===void 0?s.Capacitor!==void 0||s.Ionic!==void 0?l=`ionic`:s.cordova!==void 0||a(c)?l=`mobile_webview`:typeof document>`u`&&typeof process<`u`&&(l=`node`):(l=e.jt.test(c)?`openfin`:`openfin_web`,i.guard(`openfin.unavailable`,`The library could not read fin.me.identity.`,()=>{let e=p.identity;u=e?.uuid,d=e?.name})),n={platform:l,openfinUuid:u,openfinName:d,userAgent:c,isWorker:f,isTopLevelDocument:o(i)},n}function a(t){return e.n.test(t)?!0:(e.st.test(t)||e.xt.test(t)&&e.Et.test(t))&&t.includes(`AppleWebKit`)&&!t.includes(`Safari/`)}function o(e){if(typeof window>`u`)return!1;try{return window.self===window.top}catch{return e.count(`platform.api_blocked`),!1}}function s(e){try{return typeof location<`u`?location.href:``}catch{return e.count(`platform.api_blocked`),``}}var c=/^([a-z][a-z\d+.-]*:\/\/)[^/?#]*@/i;function l(e,t,n,r){if(n)try{let t=n(e);return typeof t==`string`?t:``}catch(e){return r?.report(`capture.record_failed`,`capture.urlTransform threw an error. The library records an empty URL.`,void 0,e),``}let i=e.replace(c,`$1`);return t?i:u(i)}function u(e){let t=e.search(/[?#]/);return t===-1?e:e.slice(0,t)}function d(){return globalThis.navigator?.onLine!==!1}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
2
- //# sourceMappingURL=platform-DBSKTvFn.cjs.map
1
+ const e=require("./constants-DqKJH_MP.cjs"),t=require("./openfin-DtH2f7zX.cjs");var n=null;function r(e,t){let n=e[t];return n!==void 0&&e instanceof n}function i(i){if(n)return n;let s=globalThis,c=s.navigator?.userAgent??``,l=`browser`,u,d,f=!1,p=t.t()?.me;return r(s,`ServiceWorkerGlobalScope`)?(l=`service_worker`,f=!0):r(s,`SharedWorkerGlobalScope`)?(l=`shared_worker`,f=!0):r(s,`WorkerGlobalScope`)?(l=`web_worker`,f=!0):p===void 0?s.Capacitor!==void 0||s.Ionic!==void 0?l=`ionic`:s.cordova!==void 0||a(c)?l=`mobile_webview`:typeof document>`u`&&typeof process<`u`&&(l=`node`):(l=e.Vt.test(c)?`openfin`:`openfin_web`,i.guard(`openfin.unavailable`,`The library could not read fin.me.identity.`,()=>{let e=p.identity;u=e?.uuid,d=e?.name})),n={platform:l,openfinUuid:u,openfinName:d,userAgent:c,isWorker:f,isTopLevelDocument:o(i)},n}function a(t){return e.i.test(t)?!0:(e._t.test(t)||e.jt.test(t)&&e.It.test(t))&&t.includes(`AppleWebKit`)&&!t.includes(`Safari/`)}function o(e){if(typeof window>`u`)return!1;try{return window.self===window.top}catch{return e.count(`platform.api_blocked`),!1}}function s(e){try{return typeof location<`u`?location.href:``}catch{return e.count(`platform.api_blocked`),``}}var c=/^([a-z][a-z\d+.-]*:\/\/)[^/?#]*@/i;function l(e,t,n,r){if(n)try{let t=n(e);return typeof t==`string`?t:``}catch(e){return r?.report(`capture.record_failed`,`capture.urlTransform threw an error. The library records an empty URL.`,void 0,e),``}let i=e.replace(c,`$1`);return t?i:u(i)}function u(e){let t=e.search(/[?#]/);return t===-1?e:e.slice(0,t)}function d(){return globalThis.navigator?.onLine!==!1}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
2
+ //# sourceMappingURL=platform-C2Ez5kDc.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform-DBSKTvFn.cjs","names":["getFin","OPENFIN_UA_PATTERN","ANDROID_WEBVIEW_UA_PATTERN","IOS_DEVICE_UA_PATTERN","MACINTOSH_UA_PATTERN","MOBILE_UA_PATTERN","require_constants","require_openfin","cached","isGlobalScope","scope","g","name","detectPlatform","ua","platform","openfinUuid","openfinName","isWorker","finMe","isWebView","diagnostics","identity","isTopLevel","currentUrl","USER_INFO_PATTERN","recordedUrl","transform","value","url","error","bare","fullUrls","stripUrlQuery","cut","isOnline"],"sources":["../src/utils/platform.ts"],"sourcesContent":["// src/utils/platform.ts\n//\n// Detects host platform capabilities, OpenFin container metadata, and worker\n// execution realms. The module caches the result. The result does not change during\n// the life of a realm. A webview is also a browser. Test for a webview first.\n\nimport {\n ANDROID_WEBVIEW_UA_PATTERN,\n IOS_DEVICE_UA_PATTERN,\n MACINTOSH_UA_PATTERN,\n MOBILE_UA_PATTERN,\n OPENFIN_UA_PATTERN,\n SAFARI_UA_TOKEN,\n WEBKIT_UA_TOKEN,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { getFin } from \"./openfin\";\n\n/** Host runtime environment classification attached to resource attributes. */\nexport type PlatformType =\n | \"openfin\"\n | \"openfin_web\"\n | \"browser\"\n | \"mobile_webview\"\n | \"ionic\"\n | \"web_worker\"\n | \"shared_worker\"\n | \"service_worker\"\n | \"node\";\n\n/** Host environment and runtime container metadata resolved at startup. */\nexport interface PlatformMetadata {\n /** Detected platform runtime classification. */\n platform: PlatformType;\n /** OpenFin application UUID if running inside an OpenFin container. */\n openfinUuid?: string;\n /** OpenFin window or view identifier. */\n openfinName?: string;\n /** Raw navigator user agent string or empty string if unavailable. */\n userAgent: string;\n /** True if the code runs in a worker realm. */\n isWorker: boolean;\n /** True if this context is the top-level document rather than an iframe. */\n isTopLevelDocument: boolean;\n}\n\n/** Indexed globalThis type for probing runtime globals. */\ntype Global = typeof globalThis & Record<string, unknown>;\n\n/** Cached platform metadata instance. */\nlet cached: PlatformMetadata | null = null;\n\n/** Abstract constructor type for global scope prototype checks. */\ntype ScopeConstructor = abstract new (...args: never[]) => object;\n\n/**\n * Tests if globalThis is an instance of a specified global scope constructor.\n * @param g Global scope object.\n * @param name Scope constructor name to check.\n * @returns True if globalThis inherits from the named scope constructor.\n */\nfunction isGlobalScope(g: Global, name: string): boolean {\n const scope = g[name];\n if (scope === undefined) {\n return false;\n }\n return g instanceof (scope as ScopeConstructor);\n}\n\n/**\n * Detects and caches host platform metadata for the active realm.\n * @param diagnostics Diagnostics reporter.\n * @returns Detected PlatformMetadata.\n */\nexport function detectPlatform(diagnostics: Diagnostics): PlatformMetadata {\n if (cached) {\n return cached;\n }\n const g = globalThis as Global;\n\n const ua = (g.navigator as Navigator | undefined)?.userAgent ?? \"\";\n let platform: PlatformType = \"browser\";\n let openfinUuid: string | undefined;\n let openfinName: string | undefined;\n let isWorker = false;\n\n const finMe = getFin()?.me;\n\n if (isGlobalScope(g, \"ServiceWorkerGlobalScope\")) {\n platform = \"service_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"SharedWorkerGlobalScope\")) {\n platform = \"shared_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"WorkerGlobalScope\")) {\n platform = \"web_worker\";\n isWorker = true;\n } else if (finMe !== undefined) {\n platform = OPENFIN_UA_PATTERN.test(ua) ? \"openfin\" : \"openfin_web\";\n diagnostics.guard(\"openfin.unavailable\", \"The library could not read fin.me.identity.\", () => {\n const identity = finMe.identity;\n openfinUuid = identity?.uuid;\n openfinName = identity?.name;\n });\n } else if (g.Capacitor !== undefined || g.Ionic !== undefined) {\n platform = \"ionic\";\n } else if (g.cordova !== undefined || isWebView(ua)) {\n platform = \"mobile_webview\";\n } else if (typeof document === \"undefined\" && typeof process !== \"undefined\") {\n platform = \"node\";\n }\n\n cached = {\n platform,\n openfinUuid,\n openfinName,\n userAgent: ua,\n isWorker,\n isTopLevelDocument: isTopLevel(diagnostics),\n };\n return cached;\n}\n\n/**\n * Tests if a user agent string represents an embedded mobile webview.\n * @param ua User agent string.\n * @returns True if user agent matches Android or iOS webview signatures.\n */\nfunction isWebView(ua: string): boolean {\n if (ANDROID_WEBVIEW_UA_PATTERN.test(ua)) {\n return true;\n }\n const ios =\n IOS_DEVICE_UA_PATTERN.test(ua) || (MACINTOSH_UA_PATTERN.test(ua) && MOBILE_UA_PATTERN.test(ua));\n return ios && ua.includes(WEBKIT_UA_TOKEN) && !ua.includes(SAFARI_UA_TOKEN);\n}\n\n/**\n * Tests if the current window is the top-level browsing context.\n * @param diagnostics Diagnostics reporter. It counts a blocked read of window.top.\n * @returns True if top-level, false if framed or inaccessible due to cross-origin boundaries.\n */\nexport function isTopLevel(diagnostics: Diagnostics): boolean {\n if (typeof window === \"undefined\") {\n return false;\n }\n try {\n return window.self === window.top;\n } catch {\n // A cross-origin parent blocks the read. That proves a frame. Count it. Do not report it.\n diagnostics.count(\"platform.api_blocked\");\n return false;\n }\n}\n\n/**\n * Retrieves the current document URL without caching.\n * @param diagnostics Diagnostics reporter. It counts a blocked read of location.href.\n * @returns Current location.href or empty string.\n */\nexport function currentUrl(diagnostics: Diagnostics): string {\n try {\n return typeof location !== \"undefined\" ? location.href : \"\";\n } catch {\n // A sandbox can block the read. Count the fault. A report on each record is noise.\n diagnostics.count(\"platform.api_blocked\");\n return \"\";\n }\n}\n\n/** Matches the user info of an absolute URL, for example \"user:pass@\". */\nconst USER_INFO_PATTERN = /^([a-z][a-z\\d+.-]*:\\/\\/)[^/?#]*@/i;\n\n/**\n * Gives the form of a URL that the library records. It always removes the user info, which is a\n * credential. Without fullUrls, it also removes the query and the fragment.\n * @param url Absolute or relative URL.\n * @param fullUrls Value of `capture.fullUrls`.\n * @param transform Value of `capture.urlTransform`. It replaces the default rule.\n * @param diagnostics Diagnostics reporter for a transform that throws.\n * @returns The URL to record.\n */\nexport function recordedUrl(\n url: string,\n fullUrls: boolean,\n transform?: (url: string) => string | null,\n diagnostics?: Diagnostics,\n): string {\n if (transform) {\n try {\n const value = transform(url);\n return typeof value === \"string\" ? value : \"\";\n } catch (error) {\n // Report the fault. Without a report, each recorded URL is empty with no visible cause.\n diagnostics?.report(\n \"capture.record_failed\",\n \"capture.urlTransform threw an error. The library records an empty URL.\",\n undefined,\n error,\n );\n return \"\";\n }\n }\n const bare = url.replace(USER_INFO_PATTERN, \"$1\");\n return fullUrls ? bare : stripUrlQuery(bare);\n}\n\n/**\n * Drops the query string and fragment from a URL.\n * It cuts the string and does not parse a URL. A relative request target has no base URL.\n * @param url Absolute or relative URL.\n * @returns The URL up to the first \"?\" or \"#\".\n */\nexport function stripUrlQuery(url: string): string {\n const cut = url.search(/[?#]/);\n\n return cut === -1 ? url : url.slice(0, cut);\n}\n\n/**\n * Tests if the browser can reach the network. A host without navigator.onLine counts as online.\n * @returns False only when navigator.onLine is false.\n */\nexport function isOnline(): boolean {\n return (globalThis as { navigator?: { onLine?: boolean } }).navigator?.onLine !== false;\n}\n\n/** Resets the cached platform metadata for testing. */\nexport function resetPlatformCache(): void {\n cached = null;\n}\n"],"mappings":"gFAkDA,IAAIQ,EAAkC,KAWtC,SAASC,EAAc,EAAW,EAAuB,CAC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AGN,OADAF,EAAY,MAAM,sBAAsB,EACjC,EACT,CACF,CAOA,SAAgBG,EAAW,EAAkC,CAC3D,GAAI,CACF,OAAO,OAAO,SAAa,IAAc,SAAS,KAAO,EAC3D,MAAQ,CAGN,OADAH,EAAY,MAAM,sBAAsB,EACjC,EACT,CACF,CAGA,IAAMI,EAAoB,oCAW1B,SAAgBC,EACd,EACA,EACA,EACA,EACQ,CACR,GAAIC,EACF,GAAI,CACF,IAAMC,EAAQD,EAAUE,CAAG,EAC3B,OAAO,OAAOD,GAAU,SAAWA,EAAQ,EAC7C,OAASE,EAAO,CAQd,OANAT,GAAa,OACX,wBACA,yEACA,IAAA,GACAS,CACF,EACO,EACT,CAEF,IAAMC,EAAOF,EAAI,QAAQJ,EAAmB,IAAI,EAChD,OAAOO,EAAWD,EAAOE,EAAcF,CAAI,CAC7C,CAQA,SAAgBE,EAAc,EAAqB,CACjD,IAAMC,EAAML,EAAI,OAAO,MAAM,EAE7B,OAAOK,IAAQ,GAAKL,EAAMA,EAAI,MAAM,EAAGK,CAAG,CAC5C,CAMA,SAAgBC,GAAoB,CAClC,OAAQ,WAAoD,WAAW,SAAW,EACpF"}
1
+ {"version":3,"file":"platform-C2Ez5kDc.cjs","names":["getFin","OPENFIN_UA_PATTERN","ANDROID_WEBVIEW_UA_PATTERN","IOS_DEVICE_UA_PATTERN","MACINTOSH_UA_PATTERN","MOBILE_UA_PATTERN","require_constants","require_openfin","cached","isGlobalScope","scope","g","name","detectPlatform","ua","platform","openfinUuid","openfinName","isWorker","finMe","isWebView","diagnostics","identity","isTopLevel","currentUrl","USER_INFO_PATTERN","recordedUrl","transform","value","url","error","bare","fullUrls","stripUrlQuery","cut","isOnline"],"sources":["../src/utils/platform.ts"],"sourcesContent":["// src/utils/platform.ts\n//\n// Detects host platform capabilities, OpenFin container metadata, and worker\n// execution realms. The module caches the result. The result does not change during\n// the life of a realm. A webview is also a browser. Test for a webview first.\n\nimport {\n ANDROID_WEBVIEW_UA_PATTERN,\n IOS_DEVICE_UA_PATTERN,\n MACINTOSH_UA_PATTERN,\n MOBILE_UA_PATTERN,\n OPENFIN_UA_PATTERN,\n SAFARI_UA_TOKEN,\n WEBKIT_UA_TOKEN,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { getFin } from \"./openfin\";\n\n/** Host runtime environment classification attached to resource attributes. */\nexport type PlatformType =\n | \"openfin\"\n | \"openfin_web\"\n | \"browser\"\n | \"mobile_webview\"\n | \"ionic\"\n | \"web_worker\"\n | \"shared_worker\"\n | \"service_worker\"\n | \"node\";\n\n/** Host environment and runtime container metadata resolved at startup. */\nexport interface PlatformMetadata {\n /** Detected platform runtime classification. */\n platform: PlatformType;\n /** OpenFin application UUID if running inside an OpenFin container. */\n openfinUuid?: string;\n /** OpenFin window or view identifier. */\n openfinName?: string;\n /** Raw navigator user agent string or empty string if unavailable. */\n userAgent: string;\n /** True if the code runs in a worker realm. */\n isWorker: boolean;\n /** True if this context is the top-level document rather than an iframe. */\n isTopLevelDocument: boolean;\n}\n\n/** Indexed globalThis type for probing runtime globals. */\ntype Global = typeof globalThis & Record<string, unknown>;\n\n/** Cached platform metadata instance. */\nlet cached: PlatformMetadata | null = null;\n\n/** Abstract constructor type for global scope prototype checks. */\ntype ScopeConstructor = abstract new (...args: never[]) => object;\n\n/**\n * Tests if globalThis is an instance of a specified global scope constructor.\n * @param g Global scope object.\n * @param name Scope constructor name to check.\n * @returns True if globalThis inherits from the named scope constructor.\n */\nfunction isGlobalScope(g: Global, name: string): boolean {\n const scope = g[name];\n if (scope === undefined) {\n return false;\n }\n return g instanceof (scope as ScopeConstructor);\n}\n\n/**\n * Detects and caches host platform metadata for the active realm.\n * @param diagnostics Diagnostics reporter.\n * @returns Detected PlatformMetadata.\n */\nexport function detectPlatform(diagnostics: Diagnostics): PlatformMetadata {\n if (cached) {\n return cached;\n }\n const g = globalThis as Global;\n\n const ua = (g.navigator as Navigator | undefined)?.userAgent ?? \"\";\n let platform: PlatformType = \"browser\";\n let openfinUuid: string | undefined;\n let openfinName: string | undefined;\n let isWorker = false;\n\n const finMe = getFin()?.me;\n\n if (isGlobalScope(g, \"ServiceWorkerGlobalScope\")) {\n platform = \"service_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"SharedWorkerGlobalScope\")) {\n platform = \"shared_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"WorkerGlobalScope\")) {\n platform = \"web_worker\";\n isWorker = true;\n } else if (finMe !== undefined) {\n platform = OPENFIN_UA_PATTERN.test(ua) ? \"openfin\" : \"openfin_web\";\n diagnostics.guard(\"openfin.unavailable\", \"The library could not read fin.me.identity.\", () => {\n const identity = finMe.identity;\n openfinUuid = identity?.uuid;\n openfinName = identity?.name;\n });\n } else if (g.Capacitor !== undefined || g.Ionic !== undefined) {\n platform = \"ionic\";\n } else if (g.cordova !== undefined || isWebView(ua)) {\n platform = \"mobile_webview\";\n } else if (typeof document === \"undefined\" && typeof process !== \"undefined\") {\n platform = \"node\";\n }\n\n cached = {\n platform,\n openfinUuid,\n openfinName,\n userAgent: ua,\n isWorker,\n isTopLevelDocument: isTopLevel(diagnostics),\n };\n return cached;\n}\n\n/**\n * Tests if a user agent string represents an embedded mobile webview.\n * @param ua User agent string.\n * @returns True if user agent matches Android or iOS webview signatures.\n */\nfunction isWebView(ua: string): boolean {\n if (ANDROID_WEBVIEW_UA_PATTERN.test(ua)) {\n return true;\n }\n const ios =\n IOS_DEVICE_UA_PATTERN.test(ua) || (MACINTOSH_UA_PATTERN.test(ua) && MOBILE_UA_PATTERN.test(ua));\n return ios && ua.includes(WEBKIT_UA_TOKEN) && !ua.includes(SAFARI_UA_TOKEN);\n}\n\n/**\n * Tests if the current window is the top-level browsing context.\n * @param diagnostics Diagnostics reporter. It counts a blocked read of window.top.\n * @returns True if top-level, false if framed or inaccessible due to cross-origin boundaries.\n */\nexport function isTopLevel(diagnostics: Diagnostics): boolean {\n if (typeof window === \"undefined\") {\n return false;\n }\n try {\n return window.self === window.top;\n } catch {\n // A cross-origin parent blocks the read. That proves a frame. Count it. Do not report it.\n diagnostics.count(\"platform.api_blocked\");\n return false;\n }\n}\n\n/**\n * Retrieves the current document URL without caching.\n * @param diagnostics Diagnostics reporter. It counts a blocked read of location.href.\n * @returns Current location.href or empty string.\n */\nexport function currentUrl(diagnostics: Diagnostics): string {\n try {\n return typeof location !== \"undefined\" ? location.href : \"\";\n } catch {\n // A sandbox can block the read. Count the fault. A report on each record is noise.\n diagnostics.count(\"platform.api_blocked\");\n return \"\";\n }\n}\n\n/** Matches the user info of an absolute URL, for example \"user:pass@\". */\nconst USER_INFO_PATTERN = /^([a-z][a-z\\d+.-]*:\\/\\/)[^/?#]*@/i;\n\n/**\n * Gives the form of a URL that the library records. It always removes the user info, which is a\n * credential. Without fullUrls, it also removes the query and the fragment.\n * @param url Absolute or relative URL.\n * @param fullUrls Value of `capture.fullUrls`.\n * @param transform Value of `capture.urlTransform`. It replaces the default rule.\n * @param diagnostics Diagnostics reporter for a transform that throws.\n * @returns The URL to record.\n */\nexport function recordedUrl(\n url: string,\n fullUrls: boolean,\n transform?: (url: string) => string | null,\n diagnostics?: Diagnostics,\n): string {\n if (transform) {\n try {\n const value = transform(url);\n return typeof value === \"string\" ? value : \"\";\n } catch (error) {\n // Report the fault. Without a report, each recorded URL is empty with no visible cause.\n diagnostics?.report(\n \"capture.record_failed\",\n \"capture.urlTransform threw an error. The library records an empty URL.\",\n undefined,\n error,\n );\n return \"\";\n }\n }\n const bare = url.replace(USER_INFO_PATTERN, \"$1\");\n return fullUrls ? bare : stripUrlQuery(bare);\n}\n\n/**\n * Drops the query string and fragment from a URL.\n * It cuts the string and does not parse a URL. A relative request target has no base URL.\n * @param url Absolute or relative URL.\n * @returns The URL up to the first \"?\" or \"#\".\n */\nexport function stripUrlQuery(url: string): string {\n const cut = url.search(/[?#]/);\n\n return cut === -1 ? url : url.slice(0, cut);\n}\n\n/**\n * Tests if the browser can reach the network. A host without navigator.onLine counts as online.\n * @returns False only when navigator.onLine is false.\n */\nexport function isOnline(): boolean {\n return (globalThis as { navigator?: { onLine?: boolean } }).navigator?.onLine !== false;\n}\n\n/** Resets the cached platform metadata for testing. */\nexport function resetPlatformCache(): void {\n cached = null;\n}\n"],"mappings":"A,gFAkDA,IAAIQ,EAAkC,KAWtC,SAASC,EAAc,EAAW,EAAuB,CACvD,IAAMC,EAAQC,EAAEC,GAIhB,OAHIF,IAAU,IAAA,IAGPC,aAAcD,CACvB,CAOA,SAAgBG,EAAe,EAA4C,CACzE,GAAIL,EACF,OAAOA,EAET,IAAMG,EAAI,WAEJG,EAAMH,EAAE,WAAqC,WAAa,GAC5DI,EAAyB,UACzBC,EACAC,EACAC,EAAW,GAETC,EAAQnB,EAAAA,EAAO,CAAC,EAAE,GAkCxB,OAhCIS,EAAcE,EAAG,0BAA0B,GAC7C,EAAW,iBACX,EAAW,IACFF,EAAcE,EAAG,yBAAyB,GACnD,EAAW,gBACX,EAAW,IACFF,EAAcE,EAAG,mBAAmB,GAC7C,EAAW,aACX,EAAW,IACFQ,IAAU,IAAA,GAOVR,EAAE,YAAc,IAAA,IAAaA,EAAE,QAAU,IAAA,GAClD,EAAW,QACFA,EAAE,UAAY,IAAA,IAAaS,EAAUN,CAAE,EAChD,EAAW,iBACF,OAAO,SAAa,KAAe,OAAO,QAAY,MAC/D,EAAW,SAXX,EAAWb,EAAAA,GAAmB,KAAKa,CAAE,EAAI,UAAY,cACrDO,EAAY,MAAM,sBAAuB,kDAAqD,CAC5F,IAAMC,EAAWH,EAAM,SACvB,EAAcG,GAAU,KACxB,EAAcA,GAAU,IAC1B,CAAC,GASH,EAAS,CACP,WACA,cACA,cACA,UAAWR,EACX,WACA,mBAAoBS,EAAWF,CAAW,CAC5C,EACOb,CACT,CAOA,SAASY,EAAU,EAAqB,CAMtC,OALIlB,EAAAA,EAA2B,KAAKY,CAAE,EAC7B,IAGPX,EAAAA,GAAsB,KAAKW,CAAE,GAAMV,EAAAA,GAAqB,KAAKU,CAAE,GAAKT,EAAAA,GAAkB,KAAKS,CAAE,IACjFA,EAAG,SAAA,aAAwB,GAAK,CAACA,EAAG,SAAA,SAAwB,CAC5E,CAOA,SAAgBS,EAAW,EAAmC,CAC5D,GAAI,OAAO,OAAW,IACpB,MAAO,GAET,GAAI,CACF,OAAO,OAAO,OAAS,OAAO,GAChC,MAAQ,CAGN,OADAF,EAAY,MAAM,sBAAsB,EACjC,EACT,CACF,CAOA,SAAgBG,EAAW,EAAkC,CAC3D,GAAI,CACF,OAAO,OAAO,SAAa,IAAc,SAAS,KAAO,EAC3D,MAAQ,CAGN,OADAH,EAAY,MAAM,sBAAsB,EACjC,EACT,CACF,CAGA,IAAMI,EAAoB,oCAW1B,SAAgBC,EACd,EACA,EACA,EACA,EACQ,CACR,GAAIC,EACF,GAAI,CACF,IAAMC,EAAQD,EAAUE,CAAG,EAC3B,OAAO,OAAOD,GAAU,SAAWA,EAAQ,EAC7C,OAASE,EAAO,CAQd,OANAT,GAAa,OACX,wBACA,yEACA,IAAA,GACAS,CACF,EACO,EACT,CAEF,IAAMC,EAAOF,EAAI,QAAQJ,EAAmB,IAAI,EAChD,OAAOO,EAAWD,EAAOE,EAAcF,CAAI,CAC7C,CAQA,SAAgBE,EAAc,EAAqB,CACjD,IAAMC,EAAML,EAAI,OAAO,MAAM,EAE7B,OAAOK,IAAQ,GAAKL,EAAMA,EAAI,MAAM,EAAGK,CAAG,CAC5C,CAMA,SAAgBC,GAAoB,CAClC,OAAQ,WAAoD,WAAW,SAAW,EACpF,C"}
@@ -1,6 +1,6 @@
1
- import { Et as e, jt as t, n, st as r, xt as i } from "./constants-CN7GE1Lt.js";
2
- import { t as a } from "./openfin-BwEN0uj4.js";
3
- //#region src/utils/platform.ts
1
+ import { It as e, Vt as t, _t as n, i as r, jt as i } from "./constants-zyrqveN4.js";
2
+ import { t as a } from "./openfin-Bxelt0yg.js";
3
+ // src/utils/platform.ts
4
4
  var o = null;
5
5
  function s(e, t) {
6
6
  let n = e[t];
@@ -22,7 +22,7 @@ function c(e) {
22
22
  }, o;
23
23
  }
24
24
  function l(t) {
25
- return n.test(t) ? !0 : (r.test(t) || i.test(t) && e.test(t)) && t.includes("AppleWebKit") && !t.includes("Safari/");
25
+ return r.test(t) ? !0 : (n.test(t) || i.test(t) && e.test(t)) && t.includes("AppleWebKit") && !t.includes("Safari/");
26
26
  }
27
27
  function u(e) {
28
28
  if (typeof window > "u") return !1;
@@ -57,7 +57,6 @@ function m(e) {
57
57
  function h() {
58
58
  return globalThis.navigator?.onLine !== !1;
59
59
  }
60
- //#endregion
61
60
  export { p as i, c as n, h as r, d as t };
62
61
 
63
- //# sourceMappingURL=platform-Bw1btWCT.js.map
62
+ //# sourceMappingURL=platform-DkcuXwe-.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform-Bw1btWCT.js","names":["MOBILE_UA_PATTERN","OPENFIN_UA_PATTERN","IOS_DEVICE_UA_PATTERN","MACINTOSH_UA_PATTERN","getFin","cached","isGlobalScope","scope","g","name","detectPlatform","ua","platform","openfinUuid","openfinName","isWorker","finMe","isWebView","diagnostics","identity","isTopLevel","ANDROID_WEBVIEW_UA_PATTERN","currentUrl","USER_INFO_PATTERN","recordedUrl","transform","value","url","error","bare","fullUrls","stripUrlQuery","cut","isOnline"],"sources":["../src/utils/platform.ts"],"sourcesContent":["// src/utils/platform.ts\n//\n// Detects host platform capabilities, OpenFin container metadata, and worker\n// execution realms. The module caches the result. The result does not change during\n// the life of a realm. A webview is also a browser. Test for a webview first.\n\nimport {\n ANDROID_WEBVIEW_UA_PATTERN,\n IOS_DEVICE_UA_PATTERN,\n MACINTOSH_UA_PATTERN,\n MOBILE_UA_PATTERN,\n OPENFIN_UA_PATTERN,\n SAFARI_UA_TOKEN,\n WEBKIT_UA_TOKEN,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { getFin } from \"./openfin\";\n\n/** Host runtime environment classification attached to resource attributes. */\nexport type PlatformType =\n | \"openfin\"\n | \"openfin_web\"\n | \"browser\"\n | \"mobile_webview\"\n | \"ionic\"\n | \"web_worker\"\n | \"shared_worker\"\n | \"service_worker\"\n | \"node\";\n\n/** Host environment and runtime container metadata resolved at startup. */\nexport interface PlatformMetadata {\n /** Detected platform runtime classification. */\n platform: PlatformType;\n /** OpenFin application UUID if running inside an OpenFin container. */\n openfinUuid?: string;\n /** OpenFin window or view identifier. */\n openfinName?: string;\n /** Raw navigator user agent string or empty string if unavailable. */\n userAgent: string;\n /** True if the code runs in a worker realm. */\n isWorker: boolean;\n /** True if this context is the top-level document rather than an iframe. */\n isTopLevelDocument: boolean;\n}\n\n/** Indexed globalThis type for probing runtime globals. */\ntype Global = typeof globalThis & Record<string, unknown>;\n\n/** Cached platform metadata instance. */\nlet cached: PlatformMetadata | null = null;\n\n/** Abstract constructor type for global scope prototype checks. */\ntype ScopeConstructor = abstract new (...args: never[]) => object;\n\n/**\n * Tests if globalThis is an instance of a specified global scope constructor.\n * @param g Global scope object.\n * @param name Scope constructor name to check.\n * @returns True if globalThis inherits from the named scope constructor.\n */\nfunction isGlobalScope(g: Global, name: string): boolean {\n const scope = g[name];\n if (scope === undefined) {\n return false;\n }\n return g instanceof (scope as ScopeConstructor);\n}\n\n/**\n * Detects and caches host platform metadata for the active realm.\n * @param diagnostics Diagnostics reporter.\n * @returns Detected PlatformMetadata.\n */\nexport function detectPlatform(diagnostics: Diagnostics): PlatformMetadata {\n if (cached) {\n return cached;\n }\n const g = globalThis as Global;\n\n const ua = (g.navigator as Navigator | undefined)?.userAgent ?? \"\";\n let platform: PlatformType = \"browser\";\n let openfinUuid: string | undefined;\n let openfinName: string | undefined;\n let isWorker = false;\n\n const finMe = getFin()?.me;\n\n if (isGlobalScope(g, \"ServiceWorkerGlobalScope\")) {\n platform = \"service_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"SharedWorkerGlobalScope\")) {\n platform = \"shared_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"WorkerGlobalScope\")) {\n platform = \"web_worker\";\n isWorker = true;\n } else if (finMe !== undefined) {\n platform = OPENFIN_UA_PATTERN.test(ua) ? \"openfin\" : \"openfin_web\";\n diagnostics.guard(\"openfin.unavailable\", \"The library could not read fin.me.identity.\", () => {\n const identity = finMe.identity;\n openfinUuid = identity?.uuid;\n openfinName = identity?.name;\n });\n } else if (g.Capacitor !== undefined || g.Ionic !== undefined) {\n platform = \"ionic\";\n } else if (g.cordova !== undefined || isWebView(ua)) {\n platform = \"mobile_webview\";\n } else if (typeof document === \"undefined\" && typeof process !== \"undefined\") {\n platform = \"node\";\n }\n\n cached = {\n platform,\n openfinUuid,\n openfinName,\n userAgent: ua,\n isWorker,\n isTopLevelDocument: isTopLevel(diagnostics),\n };\n return cached;\n}\n\n/**\n * Tests if a user agent string represents an embedded mobile webview.\n * @param ua User agent string.\n * @returns True if user agent matches Android or iOS webview signatures.\n */\nfunction isWebView(ua: string): boolean {\n if (ANDROID_WEBVIEW_UA_PATTERN.test(ua)) {\n return true;\n }\n const ios =\n IOS_DEVICE_UA_PATTERN.test(ua) || (MACINTOSH_UA_PATTERN.test(ua) && MOBILE_UA_PATTERN.test(ua));\n return ios && ua.includes(WEBKIT_UA_TOKEN) && !ua.includes(SAFARI_UA_TOKEN);\n}\n\n/**\n * Tests if the current window is the top-level browsing context.\n * @param diagnostics Diagnostics reporter. It counts a blocked read of window.top.\n * @returns True if top-level, false if framed or inaccessible due to cross-origin boundaries.\n */\nexport function isTopLevel(diagnostics: Diagnostics): boolean {\n if (typeof window === \"undefined\") {\n return false;\n }\n try {\n return window.self === window.top;\n } catch {\n // A cross-origin parent blocks the read. That proves a frame. Count it. Do not report it.\n diagnostics.count(\"platform.api_blocked\");\n return false;\n }\n}\n\n/**\n * Retrieves the current document URL without caching.\n * @param diagnostics Diagnostics reporter. It counts a blocked read of location.href.\n * @returns Current location.href or empty string.\n */\nexport function currentUrl(diagnostics: Diagnostics): string {\n try {\n return typeof location !== \"undefined\" ? location.href : \"\";\n } catch {\n // A sandbox can block the read. Count the fault. A report on each record is noise.\n diagnostics.count(\"platform.api_blocked\");\n return \"\";\n }\n}\n\n/** Matches the user info of an absolute URL, for example \"user:pass@\". */\nconst USER_INFO_PATTERN = /^([a-z][a-z\\d+.-]*:\\/\\/)[^/?#]*@/i;\n\n/**\n * Gives the form of a URL that the library records. It always removes the user info, which is a\n * credential. Without fullUrls, it also removes the query and the fragment.\n * @param url Absolute or relative URL.\n * @param fullUrls Value of `capture.fullUrls`.\n * @param transform Value of `capture.urlTransform`. It replaces the default rule.\n * @param diagnostics Diagnostics reporter for a transform that throws.\n * @returns The URL to record.\n */\nexport function recordedUrl(\n url: string,\n fullUrls: boolean,\n transform?: (url: string) => string | null,\n diagnostics?: Diagnostics,\n): string {\n if (transform) {\n try {\n const value = transform(url);\n return typeof value === \"string\" ? value : \"\";\n } catch (error) {\n // Report the fault. Without a report, each recorded URL is empty with no visible cause.\n diagnostics?.report(\n \"capture.record_failed\",\n \"capture.urlTransform threw an error. The library records an empty URL.\",\n undefined,\n error,\n );\n return \"\";\n }\n }\n const bare = url.replace(USER_INFO_PATTERN, \"$1\");\n return fullUrls ? bare : stripUrlQuery(bare);\n}\n\n/**\n * Drops the query string and fragment from a URL.\n * It cuts the string and does not parse a URL. A relative request target has no base URL.\n * @param url Absolute or relative URL.\n * @returns The URL up to the first \"?\" or \"#\".\n */\nexport function stripUrlQuery(url: string): string {\n const cut = url.search(/[?#]/);\n\n return cut === -1 ? url : url.slice(0, cut);\n}\n\n/**\n * Tests if the browser can reach the network. A host without navigator.onLine counts as online.\n * @returns False only when navigator.onLine is false.\n */\nexport function isOnline(): boolean {\n return (globalThis as { navigator?: { onLine?: boolean } }).navigator?.onLine !== false;\n}\n\n/** Resets the cached platform metadata for testing. */\nexport function resetPlatformCache(): void {\n cached = null;\n}\n"],"mappings":";;;AAkDA,IAAIK,IAAkC;AAWtC,SAASC,EAAc,GAAW,GAAuB;CACvD,IAAMC,IAAQC,EAAEC;CAIhB,OAHIF,MAAU,KAAA,KAG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AAO,OAAO,WAAa,MAAc,SAAS,OAAO;CAC3D,QAAQ;EAGN,OADAJ,EAAY,MAAM,sBAAsB,GACjC;CACT;AACF;AAGA,IAAMK,IAAoB;AAW1B,SAAgBC,EACd,GACA,GACA,GACA,GACQ;CACR,IAAIC,GACF,IAAI;EACF,IAAMC,IAAQD,EAAUE,CAAG;EAC3B,OAAO,OAAOD,KAAU,WAAWA,IAAQ;CAC7C,SAASE,GAAO;EAQd,OANAV,GAAa,OACX,yBACA,0EACA,KAAA,GACAU,CACF,GACO;CACT;CAEF,IAAMC,IAAOF,EAAI,QAAQJ,GAAmB,IAAI;CAChD,OAAOO,IAAWD,IAAOE,EAAcF,CAAI;AAC7C;AAQA,SAAgBE,EAAc,GAAqB;CACjD,IAAMC,IAAML,EAAI,OAAO,MAAM;CAE7B,OAAOK,MAAQ,KAAKL,IAAMA,EAAI,MAAM,GAAGK,CAAG;AAC5C;AAMA,SAAgBC,IAAoB;CAClC,OAAQ,WAAoD,WAAW,WAAW;AACpF"}
1
+ {"version":3,"file":"platform-DkcuXwe-.js","names":["MOBILE_UA_PATTERN","OPENFIN_UA_PATTERN","IOS_DEVICE_UA_PATTERN","ANDROID_WEBVIEW_UA_PATTERN","MACINTOSH_UA_PATTERN","getFin","cached","isGlobalScope","scope","g","name","detectPlatform","ua","platform","openfinUuid","openfinName","isWorker","finMe","isWebView","diagnostics","identity","isTopLevel","currentUrl","USER_INFO_PATTERN","recordedUrl","transform","value","url","error","bare","fullUrls","stripUrlQuery","cut","isOnline"],"sources":["../src/utils/platform.ts"],"sourcesContent":["// src/utils/platform.ts\n//\n// Detects host platform capabilities, OpenFin container metadata, and worker\n// execution realms. The module caches the result. The result does not change during\n// the life of a realm. A webview is also a browser. Test for a webview first.\n\nimport {\n ANDROID_WEBVIEW_UA_PATTERN,\n IOS_DEVICE_UA_PATTERN,\n MACINTOSH_UA_PATTERN,\n MOBILE_UA_PATTERN,\n OPENFIN_UA_PATTERN,\n SAFARI_UA_TOKEN,\n WEBKIT_UA_TOKEN,\n} from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport { getFin } from \"./openfin\";\n\n/** Host runtime environment classification attached to resource attributes. */\nexport type PlatformType =\n | \"openfin\"\n | \"openfin_web\"\n | \"browser\"\n | \"mobile_webview\"\n | \"ionic\"\n | \"web_worker\"\n | \"shared_worker\"\n | \"service_worker\"\n | \"node\";\n\n/** Host environment and runtime container metadata resolved at startup. */\nexport interface PlatformMetadata {\n /** Detected platform runtime classification. */\n platform: PlatformType;\n /** OpenFin application UUID if running inside an OpenFin container. */\n openfinUuid?: string;\n /** OpenFin window or view identifier. */\n openfinName?: string;\n /** Raw navigator user agent string or empty string if unavailable. */\n userAgent: string;\n /** True if the code runs in a worker realm. */\n isWorker: boolean;\n /** True if this context is the top-level document rather than an iframe. */\n isTopLevelDocument: boolean;\n}\n\n/** Indexed globalThis type for probing runtime globals. */\ntype Global = typeof globalThis & Record<string, unknown>;\n\n/** Cached platform metadata instance. */\nlet cached: PlatformMetadata | null = null;\n\n/** Abstract constructor type for global scope prototype checks. */\ntype ScopeConstructor = abstract new (...args: never[]) => object;\n\n/**\n * Tests if globalThis is an instance of a specified global scope constructor.\n * @param g Global scope object.\n * @param name Scope constructor name to check.\n * @returns True if globalThis inherits from the named scope constructor.\n */\nfunction isGlobalScope(g: Global, name: string): boolean {\n const scope = g[name];\n if (scope === undefined) {\n return false;\n }\n return g instanceof (scope as ScopeConstructor);\n}\n\n/**\n * Detects and caches host platform metadata for the active realm.\n * @param diagnostics Diagnostics reporter.\n * @returns Detected PlatformMetadata.\n */\nexport function detectPlatform(diagnostics: Diagnostics): PlatformMetadata {\n if (cached) {\n return cached;\n }\n const g = globalThis as Global;\n\n const ua = (g.navigator as Navigator | undefined)?.userAgent ?? \"\";\n let platform: PlatformType = \"browser\";\n let openfinUuid: string | undefined;\n let openfinName: string | undefined;\n let isWorker = false;\n\n const finMe = getFin()?.me;\n\n if (isGlobalScope(g, \"ServiceWorkerGlobalScope\")) {\n platform = \"service_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"SharedWorkerGlobalScope\")) {\n platform = \"shared_worker\";\n isWorker = true;\n } else if (isGlobalScope(g, \"WorkerGlobalScope\")) {\n platform = \"web_worker\";\n isWorker = true;\n } else if (finMe !== undefined) {\n platform = OPENFIN_UA_PATTERN.test(ua) ? \"openfin\" : \"openfin_web\";\n diagnostics.guard(\"openfin.unavailable\", \"The library could not read fin.me.identity.\", () => {\n const identity = finMe.identity;\n openfinUuid = identity?.uuid;\n openfinName = identity?.name;\n });\n } else if (g.Capacitor !== undefined || g.Ionic !== undefined) {\n platform = \"ionic\";\n } else if (g.cordova !== undefined || isWebView(ua)) {\n platform = \"mobile_webview\";\n } else if (typeof document === \"undefined\" && typeof process !== \"undefined\") {\n platform = \"node\";\n }\n\n cached = {\n platform,\n openfinUuid,\n openfinName,\n userAgent: ua,\n isWorker,\n isTopLevelDocument: isTopLevel(diagnostics),\n };\n return cached;\n}\n\n/**\n * Tests if a user agent string represents an embedded mobile webview.\n * @param ua User agent string.\n * @returns True if user agent matches Android or iOS webview signatures.\n */\nfunction isWebView(ua: string): boolean {\n if (ANDROID_WEBVIEW_UA_PATTERN.test(ua)) {\n return true;\n }\n const ios =\n IOS_DEVICE_UA_PATTERN.test(ua) || (MACINTOSH_UA_PATTERN.test(ua) && MOBILE_UA_PATTERN.test(ua));\n return ios && ua.includes(WEBKIT_UA_TOKEN) && !ua.includes(SAFARI_UA_TOKEN);\n}\n\n/**\n * Tests if the current window is the top-level browsing context.\n * @param diagnostics Diagnostics reporter. It counts a blocked read of window.top.\n * @returns True if top-level, false if framed or inaccessible due to cross-origin boundaries.\n */\nexport function isTopLevel(diagnostics: Diagnostics): boolean {\n if (typeof window === \"undefined\") {\n return false;\n }\n try {\n return window.self === window.top;\n } catch {\n // A cross-origin parent blocks the read. That proves a frame. Count it. Do not report it.\n diagnostics.count(\"platform.api_blocked\");\n return false;\n }\n}\n\n/**\n * Retrieves the current document URL without caching.\n * @param diagnostics Diagnostics reporter. It counts a blocked read of location.href.\n * @returns Current location.href or empty string.\n */\nexport function currentUrl(diagnostics: Diagnostics): string {\n try {\n return typeof location !== \"undefined\" ? location.href : \"\";\n } catch {\n // A sandbox can block the read. Count the fault. A report on each record is noise.\n diagnostics.count(\"platform.api_blocked\");\n return \"\";\n }\n}\n\n/** Matches the user info of an absolute URL, for example \"user:pass@\". */\nconst USER_INFO_PATTERN = /^([a-z][a-z\\d+.-]*:\\/\\/)[^/?#]*@/i;\n\n/**\n * Gives the form of a URL that the library records. It always removes the user info, which is a\n * credential. Without fullUrls, it also removes the query and the fragment.\n * @param url Absolute or relative URL.\n * @param fullUrls Value of `capture.fullUrls`.\n * @param transform Value of `capture.urlTransform`. It replaces the default rule.\n * @param diagnostics Diagnostics reporter for a transform that throws.\n * @returns The URL to record.\n */\nexport function recordedUrl(\n url: string,\n fullUrls: boolean,\n transform?: (url: string) => string | null,\n diagnostics?: Diagnostics,\n): string {\n if (transform) {\n try {\n const value = transform(url);\n return typeof value === \"string\" ? value : \"\";\n } catch (error) {\n // Report the fault. Without a report, each recorded URL is empty with no visible cause.\n diagnostics?.report(\n \"capture.record_failed\",\n \"capture.urlTransform threw an error. The library records an empty URL.\",\n undefined,\n error,\n );\n return \"\";\n }\n }\n const bare = url.replace(USER_INFO_PATTERN, \"$1\");\n return fullUrls ? bare : stripUrlQuery(bare);\n}\n\n/**\n * Drops the query string and fragment from a URL.\n * It cuts the string and does not parse a URL. A relative request target has no base URL.\n * @param url Absolute or relative URL.\n * @returns The URL up to the first \"?\" or \"#\".\n */\nexport function stripUrlQuery(url: string): string {\n const cut = url.search(/[?#]/);\n\n return cut === -1 ? url : url.slice(0, cut);\n}\n\n/**\n * Tests if the browser can reach the network. A host without navigator.onLine counts as online.\n * @returns False only when navigator.onLine is false.\n */\nexport function isOnline(): boolean {\n return (globalThis as { navigator?: { onLine?: boolean } }).navigator?.onLine !== false;\n}\n\n/** Resets the cached platform metadata for testing. */\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KACpB,OAAO;CAET,IAAI;EACF,OAAO,OAAO,SAAS,OAAO;CAChC,QAAQ;EAGN,OADAF,EAAY,MAAM,sBAAsB,GACjC;CACT;AACF;AAOA,SAAgBG,EAAW,GAAkC;CAC3D,IAAI;EACF,OAAO,OAAO,WAAa,MAAc,SAAS,OAAO;CAC3D,QAAQ;EAGN,OADAH,EAAY,MAAM,sBAAsB,GACjC;CACT;AACF;AAGA,IAAMI,IAAoB;AAW1B,SAAgBC,EACd,GACA,GACA,GACA,GACQ;CACR,IAAIC,GACF,IAAI;EACF,IAAMC,IAAQD,EAAUE,CAAG;EAC3B,OAAO,OAAOD,KAAU,WAAWA,IAAQ;CAC7C,SAASE,GAAO;EAQd,OANAT,GAAa,OACX,yBACA,0EACA,KAAA,GACAS,CACF,GACO;CACT;CAEF,IAAMC,IAAOF,EAAI,QAAQJ,GAAmB,IAAI;CAChD,OAAOO,IAAWD,IAAOE,EAAcF,CAAI;AAC7C;AAQA,SAAgBE,EAAc,GAAqB;CACjD,IAAMC,IAAML,EAAI,OAAO,MAAM;CAE7B,OAAOK,MAAQ,KAAKL,IAAMA,EAAI,MAAM,GAAGK,CAAG;AAC5C;AAMA,SAAgBC,IAAoB;CAClC,OAAQ,WAAoD,WAAW,WAAW;AACpF"}
@@ -0,0 +1,98 @@
1
+ import { Jt as e, Yt as t, qt as n, wt as r } from "./constants-zyrqveN4.js";
2
+ import { t as i } from "./guards-Cidk71ME.js";
3
+ import { n as a, r as o } from "./sampling-C4VV-1MS.js";
4
+ // src/core/remote-sampling.ts
5
+ var s = class {
6
+ config;
7
+ rules = null;
8
+ receivedAt = 0;
9
+ until = 0;
10
+ constructor(e) {
11
+ this.config = e;
12
+ }
13
+ apply(e) {
14
+ if (!e) {
15
+ this.rules = null;
16
+ return;
17
+ }
18
+ let t = Date.now();
19
+ this.rules = e.rules, this.receivedAt = t, this.until = t + e.ttlMs;
20
+ }
21
+ current() {
22
+ if (!this.rules) return null;
23
+ let e = Date.now();
24
+ return !this.config.sampling.remote || e < this.receivedAt || e >= this.until ? (this.rules = null, null) : this.rules;
25
+ }
26
+ minLevelFor(e) {
27
+ let t = a(e, this.config), n = this.current(), i = o(e, n?.minLevels ?? {})?.value ?? n?.minLevel;
28
+ return i !== void 0 && r[i] < r[t] ? i : t;
29
+ }
30
+ wire() {
31
+ let e = this.current();
32
+ return e ? {
33
+ ...e,
34
+ v: 1,
35
+ ttlMs: this.until - Date.now()
36
+ } : null;
37
+ }
38
+ }, c = class extends Error {};
39
+ function l(e) {
40
+ return typeof e == "number" && e >= 0 && e <= 1;
41
+ }
42
+ function u(t) {
43
+ if (t.length > 4096) throw new c(`The header is longer than ${String(e)} characters.`);
44
+ try {
45
+ return JSON.parse(t);
46
+ } catch {
47
+ throw new c("The header is not valid JSON.");
48
+ }
49
+ }
50
+ function d(e) {
51
+ if (e === void 0) return {};
52
+ let t = "rates must be an object with at most 100 rates from 0 to 1.";
53
+ if (!i(e)) throw new c(t);
54
+ let n = Object.entries(e);
55
+ if (n.length > 100 || !n.every(([, e]) => l(e))) throw new c(t);
56
+ return Object.fromEntries(n);
57
+ }
58
+ function f(e) {
59
+ let t = "minLevels must be an object with at most 100 level names.";
60
+ if (!i(e)) throw new c(t);
61
+ let n = Object.entries(e), a = n.every(([, e]) => typeof e == "string" && Object.hasOwn(r, e));
62
+ if (n.length > 100 || !a) throw new c(t);
63
+ return Object.fromEntries(n);
64
+ }
65
+ function p(e) {
66
+ if (!i(e)) throw new c("The rules must be an object.");
67
+ if (e.v !== 1) throw new c("The version must be 1.");
68
+ let { ttlMs: a, defaultRate: o, minLevel: s } = e;
69
+ if (typeof a != "number" || !(a > 0 && a <= 36e5)) throw new c(`ttlMs must be a number more than 0 and at most ${String(t)}.`);
70
+ if (o !== void 0 && !l(o)) throw new c("defaultRate must be a number from 0 to 1.");
71
+ if (s !== void 0 && !(typeof s == "string" && Object.hasOwn(r, s))) throw new c("minLevel must be a level name, for example DEBUG.");
72
+ let u = { rates: d(e.rates) };
73
+ if (o !== void 0 && (u.defaultRate = o), s !== void 0 && (u.minLevel = s), e.minLevels !== void 0 && (u.minLevels = f(e.minLevels)), e.capture !== void 0) {
74
+ let t = e.capture;
75
+ if (!i(t)) throw new c("capture must be an object of capture switches.");
76
+ let r = Object.entries(t);
77
+ if (!r.every(([e, t]) => n.some((t) => t === e) && typeof t == "boolean")) throw new c("capture must contain boolean capture switches without privacy controls.");
78
+ u.capture = Object.fromEntries(r);
79
+ }
80
+ return {
81
+ rules: u,
82
+ ttlMs: a
83
+ };
84
+ }
85
+ function m(e, t) {
86
+ try {
87
+ return p(typeof e == "string" ? u(e) : e);
88
+ } catch (e) {
89
+ let n = e instanceof c ? ` ${e.message}` : "";
90
+ return t.report("config.invalid", `The library ignores the sampling rules from the server.${n}`, void 0, e), null;
91
+ }
92
+ }
93
+ function h(e, t, n) {
94
+ n && (e.sampling ??= new s(t)), e.sampling?.apply(n), e.changed?.();
95
+ }
96
+ export { m as n, h as t };
97
+
98
+ //# sourceMappingURL=remote-rules-Cfb4K-Nl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-rules-Cfb4K-Nl.js","names":["REMOTE_SAMPLING_MAX_CHARS","REMOTE_SAMPLING_MAX_TTL_MS","REMOTE_CAPTURE_FLAGS","LEVEL_ORDER","isObject","levelFor","longestPrefix","RemoteSampling","config","update","now","local","namespace","rules","remote","RuleError","isRate","value","parseText","text","readRates","rule","entries","rate","readMinLevels","valid","level","readRules","ttlMs","defaultRate","minLevel","capture","key","flag","name","parseRemoteRules","raw","error","reason","diagnostics","applyRemote","slot"],"sources":["../src/core/remote-sampling.ts","../src/core/remote-rules.ts"],"sourcesContent":["// src/core/remote-sampling.ts\n//\n// Holds the sampling rules from the ingest server for their TTL. The rules are an overlay.\n// The library does not write them into the config. A later configure() and the TTL then stay simple.\n// Only the lazy chunks import this class. The main bundle imports the types.\n\nimport { LEVEL_ORDER, REMOTE_SAMPLING_VERSION } from \"../constants\";\nimport type { RemoteCaptureFlag, ResolvedConfig } from \"../models/config\";\nimport type { LogLevel } from \"../models/log-record\";\nimport { levelFor, longestPrefix } from \"./sampling\";\n\n/** Sampling rules from the ingest server, after validation. */\nexport interface RemoteRules {\n /** Rate when no namespace rate matches. Without it, the config rate applies. */\n defaultRate?: number;\n /** Rate for each namespace prefix. They apply over the config rates. */\n rates: Record<string, number>;\n /** Temporary capture switches. Each context applies its own allowlist. */\n capture?: Partial<Record<RemoteCaptureFlag, boolean>>;\n /** Lowest level that the library sends. It can only lower `minLevel`. */\n minLevel?: LogLevel;\n /** Lowest level for each namespace prefix. It can only lower the level of the config. */\n minLevels?: Record<string, LogLevel>;\n}\n\n/** Rules and their TTL, after validation. */\nexport interface RemoteUpdate {\n /** Validated rules. */\n rules: RemoteRules;\n /** Time that the rules stay in force, in milliseconds. */\n ttlMs: number;\n}\n\n/** Rules in the shape of the header. A context sends them to a forwarder over the bus. */\nexport interface RemoteWire extends RemoteRules {\n /** Rules version. */\n v: typeof REMOTE_SAMPLING_VERSION;\n /** Time that the rules stay in force, in milliseconds. */\n ttlMs: number;\n}\n\n/** Slot of the runtime for the overlay. The sender or the bus fills it when the first rules arrive. */\nexport interface RemoteSlot {\n /** Overlay, or null before the first rules. */\n sampling: RemoteSampling | null;\n /** Refreshes captures after a trusted rule update. */\n changed?: () => void;\n}\n\n/** Remote sampling rules in force for this context. */\nexport class RemoteSampling {\n /** Rules in force, or null. */\n private rules: RemoteRules | null = null;\n\n /** Time that the rules arrived, in epoch milliseconds. */\n private receivedAt = 0;\n\n /** Time that the rules end, in epoch milliseconds. */\n private until = 0;\n\n /**\n * @param config Active configuration instance. A reconfigure changes it in place.\n */\n constructor(private readonly config: ResolvedConfig) {}\n\n /**\n * Puts new rules in force. They replace the rules in force.\n * @param update Validated rules and their TTL, or null when the upstream has no rules.\n */\n apply(update: RemoteUpdate | null): void {\n if (!update) {\n this.rules = null;\n return;\n }\n\n const now = Date.now();\n\n this.rules = update.rules;\n this.receivedAt = now;\n this.until = now + update.ttlMs;\n }\n\n /**\n * Returns the rules in force.\n * @returns The rules, or null after the TTL or when `sampling.remote` is off.\n */\n current(): RemoteRules | null {\n if (!this.rules) {\n return null;\n }\n\n const now = Date.now();\n\n // Drop the rules when remote sampling is off. Turning it on again must not bring them back.\n // Guard against a clock that moves back. The rules then stay longer than their TTL.\n if (!this.config.sampling.remote || now < this.receivedAt || now >= this.until) {\n this.rules = null;\n return null;\n }\n\n return this.rules;\n }\n\n /**\n * Returns the lowest level that the library sends for a namespace. A remote prefix level wins\n * over the remote `minLevel`. A remote level applies only when it is lower than the config level.\n * @param namespace Target application namespace.\n * @returns The lower of the remote level and the config level of the namespace.\n */\n minLevelFor(namespace: string): LogLevel {\n const local = levelFor(namespace, this.config);\n const rules = this.current();\n const remote = longestPrefix(namespace, rules?.minLevels ?? {})?.value ?? rules?.minLevel;\n\n return remote !== undefined && LEVEL_ORDER[remote] < LEVEL_ORDER[local] ? remote : local;\n }\n\n /**\n * Returns the rules in force in the shape of the header, with the remaining TTL.\n * @returns The rules, or null if no rules are in force.\n */\n wire(): RemoteWire | null {\n const rules = this.current();\n\n if (!rules) {\n return null;\n }\n\n return { ...rules, v: REMOTE_SAMPLING_VERSION, ttlMs: this.until - Date.now() };\n }\n}\n","// src/core/remote-rules.ts\n//\n// Validates the sampling rules from the ingest server and puts them in force.\n// The sender and the bus import this module.\n// The main bundle does not include it.\n\nimport {\n LEVEL_ORDER,\n REMOTE_CAPTURE_FLAGS,\n REMOTE_SAMPLING_MAX_CHARS,\n REMOTE_SAMPLING_MAX_RATES,\n REMOTE_SAMPLING_MAX_TTL_MS,\n REMOTE_SAMPLING_VERSION,\n SAMPLING_RATE_MAX,\n SAMPLING_RATE_MIN,\n} from \"../constants\";\nimport type { ResolvedConfig } from \"../models/config\";\nimport type { LogLevel } from \"../models/log-record\";\nimport { isObject } from \"../utils/guards\";\nimport type { Diagnostics } from \"./diagnostics\";\nimport {\n type RemoteRules,\n RemoteSampling,\n type RemoteSlot,\n type RemoteUpdate,\n} from \"./remote-sampling\";\n\n/** Failure of one validation step. The message states the rule. */\nclass RuleError extends Error {}\n\n/**\n * Tests if a value is a rate.\n * @param value Value to test.\n * @returns True for a number from 0 to 1. NaN fails.\n */\nfunction isRate(value: unknown): value is number {\n return typeof value === \"number\" && value >= SAMPLING_RATE_MIN && value <= SAMPLING_RATE_MAX;\n}\n\n/**\n * Reads the header text as JSON.\n * @param text Header text.\n * @returns The parsed value.\n * @throws RuleError when the text is too long or is not JSON.\n */\nfunction parseText(text: string): unknown {\n if (text.length > REMOTE_SAMPLING_MAX_CHARS) {\n throw new RuleError(\n `The header is longer than ${String(REMOTE_SAMPLING_MAX_CHARS)} characters.`,\n );\n }\n\n try {\n return JSON.parse(text);\n } catch {\n // The caller reports the RuleError.\n throw new RuleError(\"The header is not valid JSON.\");\n }\n}\n\n/**\n * Reads the namespace rates.\n * @param value Value of `rates`.\n * @returns The rates.\n * @throws RuleError when a rate is not valid.\n */\nfunction readRates(value: unknown): Record<string, number> {\n if (value === undefined) {\n return {};\n }\n\n const rule = `rates must be an object with at most ${String(REMOTE_SAMPLING_MAX_RATES)} rates from 0 to 1.`;\n\n if (!isObject(value)) {\n throw new RuleError(rule);\n }\n\n const entries = Object.entries(value);\n\n if (entries.length > REMOTE_SAMPLING_MAX_RATES || !entries.every(([, rate]) => isRate(rate))) {\n throw new RuleError(rule);\n }\n\n // fromEntries makes own properties. A \"__proto__\" key then cannot change the prototype.\n return Object.fromEntries(entries) as Record<string, number>;\n}\n\n/**\n * Reads the level for each namespace prefix.\n * @param value Value of `minLevels`.\n * @returns The levels.\n * @throws RuleError when a level is not valid.\n */\nfunction readMinLevels(value: unknown): Record<string, LogLevel> {\n const rule = `minLevels must be an object with at most ${String(REMOTE_SAMPLING_MAX_RATES)} level names.`;\n\n if (!isObject(value)) {\n throw new RuleError(rule);\n }\n\n const entries = Object.entries(value);\n const valid = entries.every(\n ([, level]) => typeof level === \"string\" && Object.hasOwn(LEVEL_ORDER, level),\n );\n\n if (entries.length > REMOTE_SAMPLING_MAX_RATES || !valid) {\n throw new RuleError(rule);\n }\n\n // fromEntries makes own properties. A \"__proto__\" key then cannot change the prototype.\n return Object.fromEntries(entries) as Record<string, LogLevel>;\n}\n\n/**\n * Validates the rules. Sampling applies `remoteMaxRate` when it reads them.\n * @param value Parsed header value.\n * @param maxRate Highest rate that a remote rule can set.\n * @returns The rules and their TTL.\n * @throws RuleError when a field is not valid.\n */\nfunction readRules(value: unknown): RemoteUpdate {\n if (!isObject(value)) {\n throw new RuleError(\"The rules must be an object.\");\n }\n\n if (value.v !== REMOTE_SAMPLING_VERSION) {\n throw new RuleError(`The version must be ${String(REMOTE_SAMPLING_VERSION)}.`);\n }\n\n const { ttlMs, defaultRate, minLevel } = value;\n\n if (typeof ttlMs !== \"number\" || !(ttlMs > 0 && ttlMs <= REMOTE_SAMPLING_MAX_TTL_MS)) {\n throw new RuleError(\n `ttlMs must be a number more than 0 and at most ${String(REMOTE_SAMPLING_MAX_TTL_MS)}.`,\n );\n }\n\n if (defaultRate !== undefined && !isRate(defaultRate)) {\n throw new RuleError(\"defaultRate must be a number from 0 to 1.\");\n }\n\n if (\n minLevel !== undefined &&\n !(typeof minLevel === \"string\" && Object.hasOwn(LEVEL_ORDER, minLevel))\n ) {\n throw new RuleError(\"minLevel must be a level name, for example DEBUG.\");\n }\n\n const rules: RemoteRules = { rates: readRates(value.rates) };\n\n if (defaultRate !== undefined) {\n rules.defaultRate = defaultRate;\n }\n\n if (minLevel !== undefined) {\n rules.minLevel = minLevel as LogLevel;\n }\n\n if (value.minLevels !== undefined) {\n rules.minLevels = readMinLevels(value.minLevels);\n }\n\n if (value.capture !== undefined) {\n const capture = value.capture;\n if (!isObject(capture)) {\n throw new RuleError(\"capture must be an object of capture switches.\");\n }\n\n const entries = Object.entries(capture);\n if (\n !entries.every(\n ([key, flag]) =>\n REMOTE_CAPTURE_FLAGS.some((name) => name === key) && typeof flag === \"boolean\",\n )\n ) {\n throw new RuleError(\n \"capture must contain boolean capture switches without privacy controls.\",\n );\n }\n\n rules.capture = Object.fromEntries(entries);\n }\n\n return { rules, ttlMs };\n}\n\n/**\n * Validates sampling rules from the server. A rule that is not valid rejects all the rules.\n * @param raw Header text, or a parsed object from a custom transport or the bus.\n * @param diagnostics Diagnostics reporter.\n * @returns The rules and their TTL, or null if they are not valid.\n */\nexport function parseRemoteRules(raw: unknown, diagnostics: Diagnostics): RemoteUpdate | null {\n try {\n return readRules(typeof raw === \"string\" ? parseText(raw) : raw);\n } catch (error) {\n const reason = error instanceof RuleError ? ` ${error.message}` : \"\";\n\n diagnostics.report(\n \"config.invalid\",\n `The library ignores the sampling rules from the server.${reason}`,\n undefined,\n error,\n );\n return null;\n }\n}\n\n/**\n * Puts rules in force in the slot of the runtime. It makes the overlay for the first rules.\n * @param slot Slot of the runtime.\n * @param config Active configuration instance.\n * @param update Validated rules, or null when the upstream has no rules.\n */\nexport function applyRemote(\n slot: RemoteSlot,\n config: ResolvedConfig,\n update: RemoteUpdate | null,\n): void {\n if (update) {\n slot.sampling ??= new RemoteSampling(config);\n }\n\n slot.sampling?.apply(update);\n slot.changed?.();\n}\n"],"mappings":";;;;AAkDA,IAAaO,IAAb,MAA4B;CAaG;CAX7B,QAAoC;CAGpC,aAAqB;CAGrB,QAAgB;CAKhB,YAAY,GAAyC;EAAxB,KAAA,SAAAC;CAAyB;CAMtD,MAAM,GAAmC;EACvC,IAAI,CAACC,GAAQ;GACX,KAAK,QAAQ;GACb;EACF;EAEA,IAAMC,IAAM,KAAK,IAAI;EAIrB,AAFA,KAAK,QAAQD,EAAO,OACpB,KAAK,aAAaC,GAClB,KAAK,QAAQA,IAAMD,EAAO;CAC5B;CAMA,UAA8B;EAC5B,IAAI,CAAC,KAAK,OACR,OAAO;EAGT,IAAMC,IAAM,KAAK,IAAI;EASrB,OALI,CAAC,KAAK,OAAO,SAAS,UAAUA,IAAM,KAAK,cAAcA,KAAO,KAAK,SACvE,KAAK,QAAQ,MACN,QAGF,KAAK;C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EACF;EAGF,EAAM,UAAU,OAAO,YAAYO,CAAO;CAC5C;CAEA,OAAO;EAAE;EAAO;CAAM;AACxB;AAQA,SAAgBa,EAAiB,GAAc,GAA+C;CAC5F,IAAI;EACF,OAAOR,EAAU,OAAOS,KAAQ,WAAWlB,EAAUkB,CAAG,IAAIA,CAAG;CACjE,SAASC,GAAO;EACd,IAAMC,IAASD,aAAiBtB,IAAY,IAAIsB,EAAM,YAAY;EAQlE,OANAE,EAAY,OACV,kBACA,0DAA0DD,KAC1D,KAAA,GACAD,CACF,GACO;CACT;AACF;AAQA,SAAgBG,EACd,GACA,GACA,GACM;CAMN,AALI/B,MACF,EAAK,aAAa,IAAIF,EAAeC,CAAM,IAG7CiC,EAAK,UAAU,MAAMhC,CAAM,GAC3BgC,EAAK,UAAU;AACjB"}
@@ -0,0 +1,2 @@
1
+ const e=require("./constants-DqKJH_MP.cjs"),t=require("./guards-nJ70syPt.cjs"),n=require("./sampling-Ckh2yW9k.cjs");var r=class{config;rules=null;receivedAt=0;until=0;constructor(e){this.config=e}apply(e){if(!e){this.rules=null;return}let t=Date.now();this.rules=e.rules,this.receivedAt=t,this.until=t+e.ttlMs}current(){if(!this.rules)return null;let e=Date.now();return!this.config.sampling.remote||e<this.receivedAt||e>=this.until?(this.rules=null,null):this.rules}minLevelFor(t){let r=n.n(t,this.config),i=this.current(),a=n.r(t,i?.minLevels??{})?.value??i?.minLevel;return a!==void 0&&e.wt[a]<e.wt[r]?a:r}wire(){let e=this.current();return e?{...e,v:1,ttlMs:this.until-Date.now()}:null}},i=class extends Error{};function a(e){return typeof e==`number`&&e>=0&&e<=1}function o(t){if(t.length>4096)throw new i(`The header is longer than ${String(e.Jt)} characters.`);try{return JSON.parse(t)}catch{throw new i(`The header is not valid JSON.`)}}function s(e){if(e===void 0)return{};let n=`rates must be an object with at most 100 rates from 0 to 1.`;if(!t.t(e))throw new i(n);let r=Object.entries(e);if(r.length>100||!r.every(([,e])=>a(e)))throw new i(n);return Object.fromEntries(r)}function c(n){let r=`minLevels must be an object with at most 100 level names.`;if(!t.t(n))throw new i(r);let a=Object.entries(n),o=a.every(([,t])=>typeof t==`string`&&Object.hasOwn(e.wt,t));if(a.length>100||!o)throw new i(r);return Object.fromEntries(a)}function l(n){if(!t.t(n))throw new i(`The rules must be an object.`);if(n.v!==1)throw new i(`The version must be 1.`);let{ttlMs:r,defaultRate:o,minLevel:l}=n;if(typeof r!=`number`||!(r>0&&r<=36e5))throw new i(`ttlMs must be a number more than 0 and at most ${String(e.Yt)}.`);if(o!==void 0&&!a(o))throw new i(`defaultRate must be a number from 0 to 1.`);if(l!==void 0&&!(typeof l==`string`&&Object.hasOwn(e.wt,l)))throw new i(`minLevel must be a level name, for example DEBUG.`);let u={rates:s(n.rates)};if(o!==void 0&&(u.defaultRate=o),l!==void 0&&(u.minLevel=l),n.minLevels!==void 0&&(u.minLevels=c(n.minLevels)),n.capture!==void 0){let r=n.capture;if(!t.t(r))throw new i(`capture must be an object of capture switches.`);let a=Object.entries(r);if(!a.every(([t,n])=>e.qt.some(e=>e===t)&&typeof n==`boolean`))throw new i(`capture must contain boolean capture switches without privacy controls.`);u.capture=Object.fromEntries(a)}return{rules:u,ttlMs:r}}function u(e,t){try{return l(typeof e==`string`?o(e):e)}catch(e){let n=e instanceof i?` ${e.message}`:``;return t.report(`config.invalid`,`The library ignores the sampling rules from the server.${n}`,void 0,e),null}}function d(e,t,n){n&&(e.sampling??=new r(t)),e.sampling?.apply(n),e.changed?.()}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return d}});
2
+ //# sourceMappingURL=remote-rules-vzvk7aKf.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-rules-vzvk7aKf.cjs","names":["levelFor","longestPrefix","LEVEL_ORDER","REMOTE_SAMPLING_MAX_CHARS","isObject","LEVEL_ORDER","REMOTE_SAMPLING_MAX_TTL_MS","REMOTE_CAPTURE_FLAGS","require_constants","require_guards","require_sampling","RemoteSampling","config","update","now","local","namespace","rules","remote","RuleError","isRate","value","parseText","text","readRates","rule","entries","rate","readMinLevels","valid","level","readRules","ttlMs","defaultRate","minLevel","capture","key","flag","name","parseRemoteRules","raw","error","reason","diagnostics","applyRemote","slot"],"sources":["../src/core/remote-sampling.ts","../src/core/remote-rules.ts"],"sourcesContent":["// src/core/remote-sampling.ts\n//\n// Holds the sampling rules from the ingest server for their TTL. The rules are an overlay.\n// The library does not write them into the config. A later configure() and the TTL then stay simple.\n// Only the lazy chunks import this class. The main bundle imports the types.\n\nimport { LEVEL_ORDER, REMOTE_SAMPLING_VERSION } from \"../constants\";\nimport type { RemoteCaptureFlag, ResolvedConfig } from \"../models/config\";\nimport type { LogLevel } from \"../models/log-record\";\nimport { levelFor, longestPrefix } from \"./sampling\";\n\n/** Sampling rules from the ingest server, after validation. */\nexport interface RemoteRules {\n /** Rate when no namespace rate matches. Without it, the config rate applies. */\n defaultRate?: number;\n /** Rate for each namespace prefix. They apply over the config rates. */\n rates: Record<string, number>;\n /** Temporary capture switches. Each context applies its own allowlist. */\n capture?: Partial<Record<RemoteCaptureFlag, boolean>>;\n /** Lowest level that the library sends. It can only lower `minLevel`. */\n minLevel?: LogLevel;\n /** Lowest level for each namespace prefix. It can only lower the level of the config. */\n minLevels?: Record<string, LogLevel>;\n}\n\n/** Rules and their TTL, after validation. */\nexport interface RemoteUpdate {\n /** Validated rules. */\n rules: RemoteRules;\n /** Time that the rules stay in force, in milliseconds. */\n ttlMs: number;\n}\n\n/** Rules in the shape of the header. A context sends them to a forwarder over the bus. */\nexport interface RemoteWire extends RemoteRules {\n /** Rules version. */\n v: typeof REMOTE_SAMPLING_VERSION;\n /** Time that the rules stay in force, in milliseconds. */\n ttlMs: number;\n}\n\n/** Slot of the runtime for the overlay. The sender or the bus fills it when the first rules arrive. */\nexport interface RemoteSlot {\n /** Overlay, or null before the first rules. */\n sampling: RemoteSampling | null;\n /** Refreshes captures after a trusted rule update. */\n changed?: () => void;\n}\n\n/** Remote sampling rules in force for this context. */\nexport class RemoteSampling {\n /** Rules in force, or null. */\n private rules: RemoteRules | null = null;\n\n /** Time that the rules arrived, in epoch milliseconds. */\n private receivedAt = 0;\n\n /** Time that the rules end, in epoch milliseconds. */\n private until = 0;\n\n /**\n * @param config Active configuration instance. A reconfigure changes it in place.\n */\n constructor(private readonly config: ResolvedConfig) {}\n\n /**\n * Puts new rules in force. They replace the rules in force.\n * @param update Validated rules and their TTL, or null when the upstream has no rules.\n */\n apply(update: RemoteUpdate | null): void {\n if (!update) {\n this.rules = null;\n return;\n }\n\n const now = Date.now();\n\n this.rules = update.rules;\n this.receivedAt = now;\n this.until = now + update.ttlMs;\n }\n\n /**\n * Returns the rules in force.\n * @returns The rules, or null after the TTL or when `sampling.remote` is off.\n */\n current(): RemoteRules | null {\n if (!this.rules) {\n return null;\n }\n\n const now = Date.now();\n\n // Drop the rules when remote sampling is off. Turning it on again must not bring them back.\n // Guard against a clock that moves back. The rules then stay longer than their TTL.\n if (!this.config.sampling.remote || now < this.receivedAt || now >= this.until) {\n this.rules = null;\n return null;\n }\n\n return this.rules;\n }\n\n /**\n * Returns the lowest level that the library sends for a namespace. A remote prefix level wins\n * over the remote `minLevel`. A remote level applies only when it is lower than the config level.\n * @param namespace Target application namespace.\n * @returns The lower of the remote level and the config level of the namespace.\n */\n minLevelFor(namespace: string): LogLevel {\n const local = levelFor(namespace, this.config);\n const rules = this.current();\n const remote = longestPrefix(namespace, rules?.minLevels ?? {})?.value ?? rules?.minLevel;\n\n return remote !== undefined && LEVEL_ORDER[remote] < LEVEL_ORDER[local] ? remote : local;\n }\n\n /**\n * Returns the rules in force in the shape of the header, with the remaining TTL.\n * @returns The rules, or null if no rules are in force.\n */\n wire(): RemoteWire | null {\n const rules = this.current();\n\n if (!rules) {\n return null;\n }\n\n return { ...rules, v: REMOTE_SAMPLING_VERSION, ttlMs: this.until - Date.now() };\n }\n}\n","// src/core/remote-rules.ts\n//\n// Validates the sampling rules from the ingest server and puts them in force.\n// The sender and the bus import this module.\n// The main bundle does not include it.\n\nimport {\n LEVEL_ORDER,\n REMOTE_CAPTURE_FLAGS,\n REMOTE_SAMPLING_MAX_CHARS,\n REMOTE_SAMPLING_MAX_RATES,\n REMOTE_SAMPLING_MAX_TTL_MS,\n REMOTE_SAMPLING_VERSION,\n SAMPLING_RATE_MAX,\n SAMPLING_RATE_MIN,\n} from \"../constants\";\nimport type { ResolvedConfig } from \"../models/config\";\nimport type { LogLevel } from \"../models/log-record\";\nimport { isObject } from \"../utils/guards\";\nimport type { Diagnostics } from \"./diagnostics\";\nimport {\n type RemoteRules,\n RemoteSampling,\n type RemoteSlot,\n type RemoteUpdate,\n} from \"./remote-sampling\";\n\n/** Failure of one validation step. The message states the rule. */\nclass RuleError extends Error {}\n\n/**\n * Tests if a value is a rate.\n * @param value Value to test.\n * @returns True for a number from 0 to 1. NaN fails.\n */\nfunction isRate(value: unknown): value is number {\n return typeof value === \"number\" && value >= SAMPLING_RATE_MIN && value <= SAMPLING_RATE_MAX;\n}\n\n/**\n * Reads the header text as JSON.\n * @param text Header text.\n * @returns The parsed value.\n * @throws RuleError when the text is too long or is not JSON.\n */\nfunction parseText(text: string): unknown {\n if (text.length > REMOTE_SAMPLING_MAX_CHARS) {\n throw new RuleError(\n `The header is longer than ${String(REMOTE_SAMPLING_MAX_CHARS)} characters.`,\n );\n }\n\n try {\n return JSON.parse(text);\n } catch {\n // The caller reports the RuleError.\n throw new RuleError(\"The header is not valid JSON.\");\n }\n}\n\n/**\n * Reads the namespace rates.\n * @param value Value of `rates`.\n * @returns The rates.\n * @throws RuleError when a rate is not valid.\n */\nfunction readRates(value: unknown): Record<string, number> {\n if (value === undefined) {\n return {};\n }\n\n const rule = `rates must be an object with at most ${String(REMOTE_SAMPLING_MAX_RATES)} rates from 0 to 1.`;\n\n if (!isObject(value)) {\n throw new RuleError(rule);\n }\n\n const entries = Object.entries(value);\n\n if (entries.length > REMOTE_SAMPLING_MAX_RATES || !entries.every(([, rate]) => isRate(rate))) {\n throw new RuleError(rule);\n }\n\n // fromEntries makes own properties. A \"__proto__\" key then cannot change the prototype.\n return Object.fromEntries(entries) as Record<string, number>;\n}\n\n/**\n * Reads the level for each namespace prefix.\n * @param value Value of `minLevels`.\n * @returns The levels.\n * @throws RuleError when a level is not valid.\n */\nfunction readMinLevels(value: unknown): Record<string, LogLevel> {\n const rule = `minLevels must be an object with at most ${String(REMOTE_SAMPLING_MAX_RATES)} level names.`;\n\n if (!isObject(value)) {\n throw new RuleError(rule);\n }\n\n const entries = Object.entries(value);\n const valid = entries.every(\n ([, level]) => typeof level === \"string\" && Object.hasOwn(LEVEL_ORDER, level),\n );\n\n if (entries.length > REMOTE_SAMPLING_MAX_RATES || !valid) {\n throw new RuleError(rule);\n }\n\n // fromEntries makes own properties. A \"__proto__\" key then cannot change the prototype.\n return Object.fromEntries(entries) as Record<string, LogLevel>;\n}\n\n/**\n * Validates the rules. Sampling applies `remoteMaxRate` when it reads them.\n * @param value Parsed header value.\n * @param maxRate Highest rate that a remote rule can set.\n * @returns The rules and their TTL.\n * @throws RuleError when a field is not valid.\n */\nfunction readRules(value: unknown): RemoteUpdate {\n if (!isObject(value)) {\n throw new RuleError(\"The rules must be an object.\");\n }\n\n if (value.v !== REMOTE_SAMPLING_VERSION) {\n throw new RuleError(`The version must be ${String(REMOTE_SAMPLING_VERSION)}.`);\n }\n\n const { ttlMs, defaultRate, minLevel } = value;\n\n if (typeof ttlMs !== \"number\" || !(ttlMs > 0 && ttlMs <= REMOTE_SAMPLING_MAX_TTL_MS)) {\n throw new RuleError(\n `ttlMs must be a number more than 0 and at most ${String(REMOTE_SAMPLING_MAX_TTL_MS)}.`,\n );\n }\n\n if (defaultRate !== undefined && !isRate(defaultRate)) {\n throw new RuleError(\"defaultRate must be a number from 0 to 1.\");\n }\n\n if (\n minLevel !== undefined &&\n !(typeof minLevel === \"string\" && Object.hasOwn(LEVEL_ORDER, minLevel))\n ) {\n throw new RuleError(\"minLevel must be a level name, for example DEBUG.\");\n }\n\n const rules: RemoteRules = { rates: readRates(value.rates) };\n\n if (defaultRate !== undefined) {\n rules.defaultRate = defaultRate;\n }\n\n if (minLevel !== undefined) {\n rules.minLevel = minLevel as LogLevel;\n }\n\n if (value.minLevels !== undefined) {\n rules.minLevels = readMinLevels(value.minLevels);\n }\n\n if (value.capture !== undefined) {\n const capture = value.capture;\n if (!isObject(capture)) {\n throw new RuleError(\"capture must be an object of capture switches.\");\n }\n\n const entries = Object.entries(capture);\n if (\n !entries.every(\n ([key, flag]) =>\n REMOTE_CAPTURE_FLAGS.some((name) => name === key) && typeof flag === \"boolean\",\n )\n ) {\n throw new RuleError(\n \"capture must contain boolean capture switches without privacy controls.\",\n );\n }\n\n rules.capture = Object.fromEntries(entries);\n }\n\n return { rules, ttlMs };\n}\n\n/**\n * Validates sampling rules from the server. A rule that is not valid rejects all the rules.\n * @param raw Header text, or a parsed object from a custom transport or the bus.\n * @param diagnostics Diagnostics reporter.\n * @returns The rules and their TTL, or null if they are not valid.\n */\nexport function parseRemoteRules(raw: unknown, diagnostics: Diagnostics): RemoteUpdate | null {\n try {\n return readRules(typeof raw === \"string\" ? parseText(raw) : raw);\n } catch (error) {\n const reason = error instanceof RuleError ? ` ${error.message}` : \"\";\n\n diagnostics.report(\n \"config.invalid\",\n `The library ignores the sampling rules from the server.${reason}`,\n undefined,\n error,\n );\n return null;\n }\n}\n\n/**\n * Puts rules in force in the slot of the runtime. It makes the overlay for the first rules.\n * @param slot Slot of the runtime.\n * @param config Active configuration instance.\n * @param update Validated rules, or null when the upstream has no rules.\n */\nexport function applyRemote(\n slot: RemoteSlot,\n config: ResolvedConfig,\n update: RemoteUpdate | null,\n): void {\n if (update) {\n slot.sampling ??= new RemoteSampling(config);\n }\n\n slot.sampling?.apply(update);\n slot.changed?.();\n}\n"],"mappings":"A,oHAkDA,IAAaW,EAAb,KAA4B,CAaG,OAX7B,MAAoC,KAGpC,WAAqB,EAGrB,MAAgB,EAKh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,EAGzE,IAAMF,EAAqB,CAAE,MAAOO,EAAUH,EAAM,KAAK,CAAE,EAc3D,GAZIY,IAAgB,IAAA,KAClB,EAAM,YAAcA,GAGlBC,IAAa,IAAA,KACf,EAAM,SAAWA,GAGfb,EAAM,YAAc,IAAA,KACtB,EAAM,UAAYO,EAAcP,EAAM,SAAS,GAG7CA,EAAM,UAAY,IAAA,GAAW,CAC/B,IAAMc,EAAUd,EAAM,QACtB,GAAI,CAACjB,EAAAA,EAAS+B,CAAO,EACnB,MAAM,IAAIhB,EAAU,gDAAgD,EAGtE,IAAMO,EAAU,OAAO,QAAQS,CAAO,EACtC,GACE,CAACT,EAAQ,OACN,CAACU,EAAKC,KACL9B,EAAAA,GAAqB,KAAM,GAAS+B,IAASF,CAAG,GAAK,OAAOC,GAAS,SACzE,EAEA,MAAM,IAAIlB,EACR,yEACF,EAGF,EAAM,QAAU,OAAO,YAAYO,CAAO,CAC5C,CAEA,MAAO,CAAE,QAAO,OAAM,CACxB,CAQA,SAAgBa,EAAiB,EAAc,EAA+C,CAC5F,GAAI,CACF,OAAOR,EAAU,OAAOS,GAAQ,SAAWlB,EAAUkB,CAAG,EAAIA,CAAG,CACjE,OAASC,EAAO,CACd,IAAMC,EAASD,aAAiBtB,EAAY,IAAIsB,EAAM,UAAY,GAQlE,OANAE,EAAY,OACV,iBACA,0DAA0DD,IAC1D,IAAA,GACAD,CACF,EACO,IACT,CACF,CAQA,SAAgBG,EACd,EACA,EACA,EACM,CACF/B,IACF,EAAK,WAAa,IAAIF,EAAeC,CAAM,GAG7CiC,EAAK,UAAU,MAAMhC,CAAM,EAC3BgC,EAAK,UAAU,CACjB,C"}
@@ -0,0 +1,2 @@
1
+ const e=require("./platform-C2Ez5kDc.cjs"),t=require("./storm-CYi9Swpx.cjs");var n=class{ctx;name=`reports`;installed=!1;observer;window={start:0,count:0};constructor(e){this.ctx=e}install(){if(this.installed)return;this.installed=!0,document.addEventListener(`securitypolicyviolation`,this.onCsp);let e=typeof ReportingObserver>`u`?void 0:ReportingObserver;e?(this.observer=new e(e=>{for(let t of e)this.record(t)},{types:[`deprecation`,`intervention`],buffered:!1}),this.observer.observe()):this.ctx.diagnostics.report(`capture.install_failed`,`The browser does not support ReportingObserver. Only CSP events are captured.`)}uninstall(){this.installed=!1,this.observer?.disconnect(),this.observer=void 0,document.removeEventListener(`securitypolicyviolation`,this.onCsp)}onCsp=e=>{this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not read a CSP event.`,()=>{this.record({type:`csp-violation`,url:e.documentURI,body:{sourceFile:e.sourceFile,lineNumber:e.lineNumber,columnNumber:e.columnNumber,effectiveDirective:e.effectiveDirective,blockedURL:e.blockedURI}})})};record(n){if(!this.installed||this.ctx.isActive?.()===!1)return;let{capturePolicy:r,limits:i}=this.ctx.config;t.t(this.window,r.reportsPerWindow,this.ctx.diagnostics,`browser reports`,r.windowMs)&&this.ctx.diagnostics.guard(`capture.record_failed`,`The library could not record a browser report.`,()=>{if(![`deprecation`,`intervention`,`csp-violation`].includes(n.type))return;let t=n.body,r=t=>e.i(t,!1,void 0,this.ctx.diagnostics);this.ctx.logger.warn(`ui.report`,{"report.type":n.type,"report.url":r(n.url),...t.id?{"report.id":t.id.slice(0,i.maxAttributeChars)}:{},...t.sourceFile?{"report.source":r(t.sourceFile)}:{},...t.lineNumber===void 0?{}:{"report.line":t.lineNumber},...t.columnNumber===void 0?{}:{"report.column":t.columnNumber},...t.effectiveDirective?{"report.directive":t.effectiveDirective}:{},...t.blockedURL?{"report.blocked_url":r(t.blockedURL)}:{}})})}};exports.ReportCapture=n;
2
+ //# sourceMappingURL=reports-Dk2YhKIh.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reports-Dk2YhKIh.cjs","names":["allowInWindow","recordedUrl","require_platform","require_storm","ReportCapture","ctx","Observer","report","reports","event","capturePolicy","body","url","value","limits"],"sources":["../src/capture/reports.ts"],"sourcesContent":["import { recordedUrl } from \"../utils/platform\";\nimport { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext } from \"./types\";\n\n/** Report fields that this capture reads. Message text and samples stay out. */\ninterface BrowserReport {\n type: string;\n url: string;\n body: {\n id?: string;\n sourceFile?: string;\n lineNumber?: number;\n columnNumber?: number;\n effectiveDirective?: string;\n blockedURL?: string;\n };\n}\n\n/** Records browser reports without message text, code samples or URL queries. */\nexport class ReportCapture implements Capture {\n readonly name = \"reports\";\n\n private installed = false;\n\n private observer: ReportingObserver | undefined;\n\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Installs report and CSP listeners. CSP reports do not need ReportingObserver. */\n install(): void {\n if (this.installed) {\n return;\n }\n this.installed = true;\n document.addEventListener(\"securitypolicyviolation\", this.onCsp);\n\n const Observer = typeof ReportingObserver === \"undefined\" ? undefined : ReportingObserver;\n\n if (!Observer) {\n this.ctx.diagnostics.report(\n \"capture.install_failed\",\n \"The browser does not support ReportingObserver. Only CSP events are captured.\",\n );\n return;\n }\n\n this.observer = new Observer(\n (reports) => {\n for (const report of reports) {\n this.record(report as unknown as BrowserReport);\n }\n },\n { types: [\"deprecation\", \"intervention\"], buffered: false },\n );\n this.observer.observe();\n }\n\n /** Disconnects the observer and removes the CSP listener. */\n uninstall(): void {\n this.installed = false;\n this.observer?.disconnect();\n this.observer = undefined;\n document.removeEventListener(\"securitypolicyviolation\", this.onCsp);\n }\n\n private readonly onCsp = (event: SecurityPolicyViolationEvent): void => {\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read a CSP event.\",\n () => {\n this.record({\n type: \"csp-violation\",\n url: event.documentURI,\n body: {\n sourceFile: event.sourceFile,\n lineNumber: event.lineNumber,\n columnNumber: event.columnNumber,\n effectiveDirective: event.effectiveDirective,\n blockedURL: event.blockedURI,\n },\n });\n },\n );\n };\n\n /** Reads only fixed report fields. The diagnostics guard contains a failed field read. */\n private record(report: BrowserReport): void {\n if (!this.installed || this.ctx.isActive?.() === false) {\n return;\n }\n\n const { capturePolicy, limits } = this.ctx.config;\n if (\n !allowInWindow(\n this.window,\n capturePolicy.reportsPerWindow,\n this.ctx.diagnostics,\n \"browser reports\",\n capturePolicy.windowMs,\n )\n ) {\n return;\n }\n\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not record a browser report.\",\n () => {\n if (![\"deprecation\", \"intervention\", \"csp-violation\"].includes(report.type)) {\n return;\n }\n\n const body = report.body;\n const url = (value: string): string =>\n recordedUrl(value, false, undefined, this.ctx.diagnostics);\n this.ctx.logger.warn(\"ui.report\", {\n \"report.type\": report.type,\n \"report.url\": url(report.url),\n ...(body.id ? { \"report.id\": body.id.slice(0, limits.maxAttributeChars) } : {}),\n ...(body.sourceFile ? { \"report.source\": url(body.sourceFile) } : {}),\n ...(body.lineNumber !== undefined ? { \"report.line\": body.lineNumber } : {}),\n ...(body.columnNumber !== undefined ? { \"report.column\": body.columnNumber } : {}),\n ...(body.effectiveDirective ? { \"report.directive\": body.effectiveDirective } : {}),\n ...(body.blockedURL ? { \"report.blocked_url\": url(body.blockedURL) } : {}),\n });\n },\n );\n }\n}\n"],"mappings":"A,6EAmBA,IAAaI,EAAb,KAA8C,CASf,IAR7B,KAAgB,UAEhB,UAAoB,GAEpB,SAEA,OAAuC,CAAE,MAAO,EAAG,MAAO,CAAE,EAE5D,YAAY,EAAsC,CAArB,KAAA,IAAAC,CAAsB,CAGnD,SAAgB,CACd,GAAI,KAAK,UACP,OAEF,KAAK,UAAY,GACjB,SAAS,iBAAiB,0BAA2B,KAAK,KAAK,EAE/D,IAAMC,EAAW,OAAO,kBAAsB,IAAc,IAAA,GAAY,kBAEnEA,GAQL,KAAK,SAAW,IAAIA,EACjB,GAAY,CACX,IAAK,IAAMC,KAAUC,EACnB,KAAK,OAAOD,CAAkC,CAElD,EACA,CAAE,MAAO,CAAC,cAAe,cAAc,EAAG,SAAU,EAAM,CAC5D,EACA,KAAK,SAAS,QAAQ,GAfpB,KAAK,IAAI,YAAY,OACn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BAAiBA,EAAK,YAAa,EAC3E,GAAIA,EAAK,mBAAqB,CAAE,mBAAoBA,EAAK,kBAAmB,EAAI,CAAC,EACjF,GAAIA,EAAK,WAAa,CAAE,qBAAsBC,EAAID,EAAK,UAAU,CAAE,EAAI,CAAC,CAC1E,CAAC,CACH,CACF,CACF,CACF,E"}
@@ -0,0 +1,70 @@
1
+ import { i as e } from "./platform-DkcuXwe-.js";
2
+ import { t } from "./storm-VR024_QN.js";
3
+ // src/capture/reports.ts
4
+ var n = class {
5
+ ctx;
6
+ name = "reports";
7
+ installed = !1;
8
+ observer;
9
+ window = {
10
+ start: 0,
11
+ count: 0
12
+ };
13
+ constructor(e) {
14
+ this.ctx = e;
15
+ }
16
+ install() {
17
+ if (this.installed) return;
18
+ this.installed = !0, document.addEventListener("securitypolicyviolation", this.onCsp);
19
+ let e = typeof ReportingObserver > "u" ? void 0 : ReportingObserver;
20
+ e ? (this.observer = new e((e) => {
21
+ for (let t of e) this.record(t);
22
+ }, {
23
+ types: ["deprecation", "intervention"],
24
+ buffered: !1
25
+ }), this.observer.observe()) : this.ctx.diagnostics.report("capture.install_failed", "The browser does not support ReportingObserver. Only CSP events are captured.");
26
+ }
27
+ uninstall() {
28
+ this.installed = !1, this.observer?.disconnect(), this.observer = void 0, document.removeEventListener("securitypolicyviolation", this.onCsp);
29
+ }
30
+ onCsp = (e) => {
31
+ this.ctx.diagnostics.guard("capture.record_failed", "The library could not read a CSP event.", () => {
32
+ this.record({
33
+ type: "csp-violation",
34
+ url: e.documentURI,
35
+ body: {
36
+ sourceFile: e.sourceFile,
37
+ lineNumber: e.lineNumber,
38
+ columnNumber: e.columnNumber,
39
+ effectiveDirective: e.effectiveDirective,
40
+ blockedURL: e.blockedURI
41
+ }
42
+ });
43
+ });
44
+ };
45
+ record(n) {
46
+ if (!this.installed || this.ctx.isActive?.() === !1) return;
47
+ let { capturePolicy: r, limits: i } = this.ctx.config;
48
+ t(this.window, r.reportsPerWindow, this.ctx.diagnostics, "browser reports", r.windowMs) && this.ctx.diagnostics.guard("capture.record_failed", "The library could not record a browser report.", () => {
49
+ if (![
50
+ "deprecation",
51
+ "intervention",
52
+ "csp-violation"
53
+ ].includes(n.type)) return;
54
+ let t = n.body, r = (t) => e(t, !1, void 0, this.ctx.diagnostics);
55
+ this.ctx.logger.warn("ui.report", {
56
+ "report.type": n.type,
57
+ "report.url": r(n.url),
58
+ ...t.id ? { "report.id": t.id.slice(0, i.maxAttributeChars) } : {},
59
+ ...t.sourceFile ? { "report.source": r(t.sourceFile) } : {},
60
+ ...t.lineNumber === void 0 ? {} : { "report.line": t.lineNumber },
61
+ ...t.columnNumber === void 0 ? {} : { "report.column": t.columnNumber },
62
+ ...t.effectiveDirective ? { "report.directive": t.effectiveDirective } : {},
63
+ ...t.blockedURL ? { "report.blocked_url": r(t.blockedURL) } : {}
64
+ });
65
+ });
66
+ }
67
+ };
68
+ export { n as ReportCapture };
69
+
70
+ //# sourceMappingURL=reports-TA-zInnq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reports-TA-zInnq.js","names":["recordedUrl","ReportCapture","ctx","Observer","report","reports","event","allowInWindow","capturePolicy","body","url","value","limits"],"sources":["../src/capture/reports.ts"],"sourcesContent":["import { recordedUrl } from \"../utils/platform\";\nimport { allowInWindow, type StormWindow } from \"./storm\";\nimport type { Capture, CaptureContext } from \"./types\";\n\n/** Report fields that this capture reads. Message text and samples stay out. */\ninterface BrowserReport {\n type: string;\n url: string;\n body: {\n id?: string;\n sourceFile?: string;\n lineNumber?: number;\n columnNumber?: number;\n effectiveDirective?: string;\n blockedURL?: string;\n };\n}\n\n/** Records browser reports without message text, code samples or URL queries. */\nexport class ReportCapture implements Capture {\n readonly name = \"reports\";\n\n private installed = false;\n\n private observer: ReportingObserver | undefined;\n\n private readonly window: StormWindow = { start: 0, count: 0 };\n\n constructor(private readonly ctx: CaptureContext) {}\n\n /** Installs report and CSP listeners. CSP reports do not need ReportingObserver. */\n install(): void {\n if (this.installed) {\n return;\n }\n this.installed = true;\n document.addEventListener(\"securitypolicyviolation\", this.onCsp);\n\n const Observer = typeof ReportingObserver === \"undefined\" ? undefined : ReportingObserver;\n\n if (!Observer) {\n this.ctx.diagnostics.report(\n \"capture.install_failed\",\n \"The browser does not support ReportingObserver. Only CSP events are captured.\",\n );\n return;\n }\n\n this.observer = new Observer(\n (reports) => {\n for (const report of reports) {\n this.record(report as unknown as BrowserReport);\n }\n },\n { types: [\"deprecation\", \"intervention\"], buffered: false },\n );\n this.observer.observe();\n }\n\n /** Disconnects the observer and removes the CSP listener. */\n uninstall(): void {\n this.installed = false;\n this.observer?.disconnect();\n this.observer = undefined;\n document.removeEventListener(\"securitypolicyviolation\", this.onCsp);\n }\n\n private readonly onCsp = (event: SecurityPolicyViolationEvent): void => {\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not read a CSP event.\",\n () => {\n this.record({\n type: \"csp-violation\",\n url: event.documentURI,\n body: {\n sourceFile: event.sourceFile,\n lineNumber: event.lineNumber,\n columnNumber: event.columnNumber,\n effectiveDirective: event.effectiveDirective,\n blockedURL: event.blockedURI,\n },\n });\n },\n );\n };\n\n /** Reads only fixed report fields. The diagnostics guard contains a failed field read. */\n private record(report: BrowserReport): void {\n if (!this.installed || this.ctx.isActive?.() === false) {\n return;\n }\n\n const { capturePolicy, limits } = this.ctx.config;\n if (\n !allowInWindow(\n this.window,\n capturePolicy.reportsPerWindow,\n this.ctx.diagnostics,\n \"browser reports\",\n capturePolicy.windowMs,\n )\n ) {\n return;\n }\n\n this.ctx.diagnostics.guard(\n \"capture.record_failed\",\n \"The library could not record a browser report.\",\n () => {\n if (![\"deprecation\", \"intervention\", \"csp-violation\"].includes(report.type)) {\n return;\n }\n\n const body = report.body;\n const url = (value: string): string =>\n recordedUrl(value, false, undefined, this.ctx.diagnostics);\n this.ctx.logger.warn(\"ui.report\", {\n \"report.type\": report.type,\n \"report.url\": url(report.url),\n ...(body.id ? { \"report.id\": body.id.slice(0, limits.maxAttributeChars) } : {}),\n ...(body.sourceFile ? { \"report.source\": url(body.sourceFile) } : {}),\n ...(body.lineNumber !== undefined ? { \"report.line\": body.lineNumber } : {}),\n ...(body.columnNumber !== undefined ? { \"report.column\": body.columnNumber } : {}),\n ...(body.effectiveDirective ? { \"report.directive\": body.effectiveDirective } : {}),\n ...(body.blockedURL ? { \"report.blocked_url\": url(body.blockedURL) } : {}),\n });\n },\n );\n }\n}\n"],"mappings":";;;AAmBA,IAAaC,IAAb,MAA8C;CASf;CAR7B,OAAgB;CAEhB,YAAoB;CAEpB;CAEA,SAAuC;EAAE,OAAO;EAAG,OAAO;CAAE;CAE5D,YAAY,GAAsC;EAArB,KAAA,MAAAC;CAAsB;CAGnD,UAAgB;EACd,IAAI,KAAK,WACP;EAGF,AADA,KAAK,YAAY,IACjB,SAAS,iBAAiB,2BAA2B,KAAK,KAAK;EAE/D,IAAMC,IAAW,OAAO,oBAAsB,MAAc,KAAA,IAAY;EAExE,AAAKA,KAQL,KAAK,WAAW,IAAIA,GACjB,MAAY;GACX,KAAK,IAAMC,KAAUC,GACnB,KAAK,OAAOD,CAAkC;EAElD,GACA;GAAE,OAAO,CAAC,eAAe,cAAc;GAAG,UAAU;EAAM,CAC5D,GACA,KAAK,SAAS,QAAQ,KAfpB,KAAK,IAAI,YAAY,OACnB,0BACA,+EACF;CAaJ;CAGA,YAAkB;EAIhB,AAHA,KAAK,YAAY,IACjB,KAAK,UAAU,WAAW,GAC1B,KAAK,WAAW,KAAA,GAChB,SAAS,oBAAoB,2BAA2B,KAAK,KAAK;CACpE;CAEA,SAA0B,MAA8C;EACtE,KAAK,IAAI,YAAY,MACnB,yBACA,iDACM;GACJ,KAAK,OAAO;IACV,MAAM;IACN,KAAKE,EAAM;IACX,MAAM;KACJ,YAAYA,EAAM;KAClB,YAAYA,EAAM;KAClB,cAAcA,EAAM;KACpB,oBAAoBA,EAAM;KAC1B,YAAYA,EAAM;IACpB;GACF,CAAC;EACH,CACF;CACF;CAGA,OAAe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