@utk09/ui-observability 1.0.0 → 1.2.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 (298) hide show
  1. package/CHANGELOG.md +111 -219
  2. package/README.md +24 -26
  3. package/dist/{batch-CXmPmTse.js → batch-120Kc9jr.js} +3 -3
  4. package/dist/{batch-CXmPmTse.js.map → batch-120Kc9jr.js.map} +1 -1
  5. package/dist/{batch-mmPigCpi.cjs → batch-C3uNp5kU.cjs} +2 -2
  6. package/dist/{batch-mmPigCpi.cjs.map → batch-C3uNp5kU.cjs.map} +1 -1
  7. package/dist/bus/bus.d.cts +31 -2
  8. package/dist/bus/bus.d.ts +31 -2
  9. package/dist/bus-Dj8IEVcC.cjs +2 -0
  10. package/dist/bus-Dj8IEVcC.cjs.map +1 -0
  11. package/dist/{bus-C39wspFV.js → bus-DyNafxZN.js} +127 -104
  12. package/dist/bus-DyNafxZN.js.map +1 -0
  13. package/dist/capture/errors.d.cts +10 -0
  14. package/dist/capture/errors.d.ts +10 -0
  15. package/dist/capture/interactions.d.cts +35 -3
  16. package/dist/capture/interactions.d.ts +35 -3
  17. package/dist/capture/observed-windows.d.cts +51 -0
  18. package/dist/capture/observed-windows.d.ts +51 -0
  19. package/dist/capture/replay.d.cts +1 -1
  20. package/dist/capture/replay.d.ts +1 -1
  21. package/dist/capture/types.d.cts +5 -0
  22. package/dist/capture/types.d.ts +5 -0
  23. package/dist/capture/web-vitals.d.cts +1 -0
  24. package/dist/capture/web-vitals.d.ts +1 -0
  25. package/dist/{compression-tVtXwVjX.js → compression-BWkDWY3v.js} +2 -2
  26. package/dist/{compression-tVtXwVjX.js.map → compression-BWkDWY3v.js.map} +1 -1
  27. package/dist/{compression-CvED_Jel.cjs → compression-CEVe7NPX.cjs} +2 -2
  28. package/dist/{compression-CvED_Jel.cjs.map → compression-CEVe7NPX.cjs.map} +1 -1
  29. package/dist/config-C0PtemvC.cjs +2 -0
  30. package/dist/config-C0PtemvC.cjs.map +1 -0
  31. package/dist/config-DK1Zf7jn.js +556 -0
  32. package/dist/config-DK1Zf7jn.js.map +1 -0
  33. package/dist/{console-BGgGnjSi.js → console-CAyCQOpm.js} +5 -5
  34. package/dist/{console-BGgGnjSi.js.map → console-CAyCQOpm.js.map} +1 -1
  35. package/dist/{console-CSZ5_Vx5.cjs → console-Dk6GH4yj.cjs} +2 -2
  36. package/dist/{console-CSZ5_Vx5.cjs.map → console-Dk6GH4yj.cjs.map} +1 -1
  37. package/dist/{constants-CUyd9cTZ.js → constants-CEHN6KuY.js} +46 -25
  38. package/dist/constants-CEHN6KuY.js.map +1 -0
  39. package/dist/constants-NtiQDWL_.cjs +2 -0
  40. package/dist/constants-NtiQDWL_.cjs.map +1 -0
  41. package/dist/constants.d.cts +23 -0
  42. package/dist/constants.d.ts +23 -0
  43. package/dist/core/config.d.cts +9 -3
  44. package/dist/core/config.d.ts +9 -3
  45. package/dist/core/diagnostics.d.cts +1 -1
  46. package/dist/core/diagnostics.d.ts +1 -1
  47. package/dist/core/pipeline.d.cts +11 -0
  48. package/dist/core/pipeline.d.ts +11 -0
  49. package/dist/core/record.d.cts +2 -2
  50. package/dist/core/record.d.ts +2 -2
  51. package/dist/core/rotation.d.cts +26 -2
  52. package/dist/core/rotation.d.ts +26 -2
  53. package/dist/core/runtime.d.cts +9 -0
  54. package/dist/core/runtime.d.ts +9 -0
  55. package/dist/core/sender.d.cts +3 -2
  56. package/dist/core/sender.d.ts +3 -2
  57. package/dist/{debug-bundle-BXIlwDKM.cjs → debug-bundle-DMzUfiQc.cjs} +2 -2
  58. package/dist/{debug-bundle-BXIlwDKM.cjs.map → debug-bundle-DMzUfiQc.cjs.map} +1 -1
  59. package/dist/{debug-bundle-CRpYV_ui.js → debug-bundle-w78W46zr.js} +4 -4
  60. package/dist/{debug-bundle-CRpYV_ui.js.map → debug-bundle-w78W46zr.js.map} +1 -1
  61. package/dist/doctor.cjs +1 -1
  62. package/dist/doctor.js +36 -36
  63. package/dist/doctor.js.map +1 -1
  64. package/dist/errors-07pmZ7VY.cjs +3 -0
  65. package/dist/errors-07pmZ7VY.cjs.map +1 -0
  66. package/dist/{errors-BE_EZV7Q.js → errors-C-LYbqyB.js} +27 -24
  67. package/dist/errors-C-LYbqyB.js.map +1 -0
  68. package/dist/{factory-CTi0Is3F.js → factory-BHYrcSaU.js} +39 -28
  69. package/dist/factory-BHYrcSaU.js.map +1 -0
  70. package/dist/factory-DsaNdcXp.cjs +2 -0
  71. package/dist/factory-DsaNdcXp.cjs.map +1 -0
  72. package/dist/{identity-DdhKgrpk.js → identity-Byh3gCdT.js} +35 -24
  73. package/dist/identity-Byh3gCdT.js.map +1 -0
  74. package/dist/identity-BzAzdQyv.cjs +2 -0
  75. package/dist/identity-BzAzdQyv.cjs.map +1 -0
  76. package/dist/index.cjs +1 -1
  77. package/dist/index.cjs.map +1 -1
  78. package/dist/index.d.cts +1 -0
  79. package/dist/index.d.ts +1 -0
  80. package/dist/index.js +453 -417
  81. package/dist/index.js.map +1 -1
  82. package/dist/{indexeddb-storage-GHdl0t8A.js → indexeddb-storage-BYywz-v6.js} +17 -17
  83. package/dist/{indexeddb-storage-GHdl0t8A.js.map → indexeddb-storage-BYywz-v6.js.map} +1 -1
  84. package/dist/{indexeddb-storage-CL9uqBCy.cjs → indexeddb-storage-BfqGkLFe.cjs} +2 -2
  85. package/dist/{indexeddb-storage-CL9uqBCy.cjs.map → indexeddb-storage-BfqGkLFe.cjs.map} +1 -1
  86. package/dist/interactions-BXzEel4F.cjs +2 -0
  87. package/dist/interactions-BXzEel4F.cjs.map +1 -0
  88. package/dist/interactions-DdKPMWIN.js +207 -0
  89. package/dist/interactions-DdKPMWIN.js.map +1 -0
  90. package/dist/{journey-B4Adltjm.cjs → journey-BUmsrgaw.cjs} +2 -2
  91. package/dist/{journey-B4Adltjm.cjs.map → journey-BUmsrgaw.cjs.map} +1 -1
  92. package/dist/{journey-D2_sia57.js → journey-Nu655gEO.js} +14 -14
  93. package/dist/{journey-D2_sia57.js.map → journey-Nu655gEO.js.map} +1 -1
  94. package/dist/{library-console-CPW6bvZH.cjs → library-console-DdIlzzph.cjs} +2 -2
  95. package/dist/{library-console-CPW6bvZH.cjs.map → library-console-DdIlzzph.cjs.map} +1 -1
  96. package/dist/{library-console-Btrzt814.js → library-console-amePMnP8.js} +2 -2
  97. package/dist/{library-console-Btrzt814.js.map → library-console-amePMnP8.js.map} +1 -1
  98. package/dist/{library-request-BJ9PLRaD.js → library-request-Cv7C05jf.js} +2 -2
  99. package/dist/{library-request-BJ9PLRaD.js.map → library-request-Cv7C05jf.js.map} +1 -1
  100. package/dist/{library-request-D7OvTxZV.cjs → library-request-DO3Ec7KE.cjs} +2 -2
  101. package/dist/{library-request-D7OvTxZV.cjs.map → library-request-DO3Ec7KE.cjs.map} +1 -1
  102. package/dist/{lifecycle-IaAm1mOC.cjs → lifecycle-B5yfH5is.cjs} +2 -2
  103. package/dist/{lifecycle-IaAm1mOC.cjs.map → lifecycle-B5yfH5is.cjs.map} +1 -1
  104. package/dist/{lifecycle-22CUCrc9.js → lifecycle-CMHz2Zbs.js} +2 -2
  105. package/dist/{lifecycle-22CUCrc9.js.map → lifecycle-CMHz2Zbs.js.map} +1 -1
  106. package/dist/{log-record-BNiLfqtL.js → log-record-B_nSqxoe.js} +2 -2
  107. package/dist/{log-record-BNiLfqtL.js.map → log-record-B_nSqxoe.js.map} +1 -1
  108. package/dist/{log-record-CkivuiEl.cjs → log-record-Bdywwg0k.cjs} +2 -2
  109. package/dist/{log-record-CkivuiEl.cjs.map → log-record-Bdywwg0k.cjs.map} +1 -1
  110. package/dist/{long-frames-DNFaRnC3.js → long-frames-6NGl1-uN.js} +3 -3
  111. package/dist/{long-frames-DNFaRnC3.js.map → long-frames-6NGl1-uN.js.map} +1 -1
  112. package/dist/{long-frames-BUUbXd-B.cjs → long-frames-D9DfSWqv.cjs} +2 -2
  113. package/dist/{long-frames-BUUbXd-B.cjs.map → long-frames-D9DfSWqv.cjs.map} +1 -1
  114. package/dist/models/bus.d.cts +6 -1
  115. package/dist/models/bus.d.ts +6 -1
  116. package/dist/models/config.d.cts +27 -11
  117. package/dist/models/config.d.ts +27 -11
  118. package/dist/models/serializer.d.cts +3 -1
  119. package/dist/models/serializer.d.ts +3 -1
  120. package/dist/{network-CGMLQ-mA.cjs → network-BNHBI0Fc.cjs} +2 -2
  121. package/dist/{network-CGMLQ-mA.cjs.map → network-BNHBI0Fc.cjs.map} +1 -1
  122. package/dist/{network-on2zZT6H.js → network-Cc3tSB7e.js} +5 -5
  123. package/dist/{network-on2zZT6H.js.map → network-Cc3tSB7e.js.map} +1 -1
  124. package/dist/observed-windows-8JtCsIr1.js +64 -0
  125. package/dist/observed-windows-8JtCsIr1.js.map +1 -0
  126. package/dist/observed-windows-BlE25nrn.cjs +2 -0
  127. package/dist/observed-windows-BlE25nrn.cjs.map +1 -0
  128. package/dist/openfin-Bxelt0yg.js.map +1 -1
  129. package/dist/openfin-DtH2f7zX.cjs.map +1 -1
  130. package/dist/{otlp-DimfrRor.js → otlp-Btix3EBa.js} +7 -7
  131. package/dist/{otlp-DimfrRor.js.map → otlp-Btix3EBa.js.map} +1 -1
  132. package/dist/{otlp-BENHf3g9.cjs → otlp-CFSW-Dno.cjs} +2 -2
  133. package/dist/{otlp-BENHf3g9.cjs.map → otlp-CFSW-Dno.cjs.map} +1 -1
  134. package/dist/patch-DlcKzIi-.cjs +2 -0
  135. package/dist/patch-DlcKzIi-.cjs.map +1 -0
  136. package/dist/patch-Sr1wKg7W.js +9 -0
  137. package/dist/patch-Sr1wKg7W.js.map +1 -0
  138. package/dist/platform-BZjp9wp1.cjs +2 -0
  139. package/dist/platform-BZjp9wp1.cjs.map +1 -0
  140. package/dist/platform-Dba6R3Hp.js +75 -0
  141. package/dist/platform-Dba6R3Hp.js.map +1 -0
  142. package/dist/{profiler-BAZoh7A4.js → profiler-DNKcqu09.js} +60 -60
  143. package/dist/{profiler-BAZoh7A4.js.map → profiler-DNKcqu09.js.map} +1 -1
  144. package/dist/{profiler-D4tJpDRc.cjs → profiler-DpoPi1hH.cjs} +2 -2
  145. package/dist/{profiler-D4tJpDRc.cjs.map → profiler-DpoPi1hH.cjs.map} +1 -1
  146. package/dist/{profiler-frames-C4xr7KfH.cjs → profiler-frames-C9zJNd8_.cjs} +2 -2
  147. package/dist/{profiler-frames-C4xr7KfH.cjs.map → profiler-frames-C9zJNd8_.cjs.map} +1 -1
  148. package/dist/{profiler-frames-cJMx9wNM.js → profiler-frames-CGXZeZ_3.js} +16 -16
  149. package/dist/{profiler-frames-cJMx9wNM.js.map → profiler-frames-CGXZeZ_3.js.map} +1 -1
  150. package/dist/{remote-rules-Dz9MRAsB.js → remote-rules-DNK96vLa.js} +25 -25
  151. package/dist/{remote-rules-Dz9MRAsB.js.map → remote-rules-DNK96vLa.js.map} +1 -1
  152. package/dist/{remote-rules-_tY0zj5o.cjs → remote-rules-DuMFRlit.cjs} +2 -2
  153. package/dist/{remote-rules-_tY0zj5o.cjs.map → remote-rules-DuMFRlit.cjs.map} +1 -1
  154. package/dist/replay-Cab-lSit.cjs +2 -0
  155. package/dist/replay-Cab-lSit.cjs.map +1 -0
  156. package/dist/{replay-Ds-ANH34.js → replay-Dy6OiaOZ.js} +104 -77
  157. package/dist/replay-Dy6OiaOZ.js.map +1 -0
  158. package/dist/{reports-BDSe4dFH.cjs → reports-CGK9YQch.cjs} +2 -2
  159. package/dist/{reports-BDSe4dFH.cjs.map → reports-CGK9YQch.cjs.map} +1 -1
  160. package/dist/{reports-C-thq-bk.js → reports-CX57-S9s.js} +3 -3
  161. package/dist/{reports-C-thq-bk.js.map → reports-CX57-S9s.js.map} +1 -1
  162. package/dist/{resource-timing-eUl2dNgC.js → resource-timing-CWVDCbrY.js} +4 -4
  163. package/dist/{resource-timing-eUl2dNgC.js.map → resource-timing-CWVDCbrY.js.map} +1 -1
  164. package/dist/{resource-timing-C576gFIQ.cjs → resource-timing-DalulXiR.cjs} +2 -2
  165. package/dist/{resource-timing-C576gFIQ.cjs.map → resource-timing-DalulXiR.cjs.map} +1 -1
  166. package/dist/response-body-Cpz5__4g.cjs +3 -0
  167. package/dist/response-body-Cpz5__4g.cjs.map +1 -0
  168. package/dist/{response-body-eoSQpLiH.js → response-body-yi92Rpvo.js} +109 -109
  169. package/dist/response-body-yi92Rpvo.js.map +1 -0
  170. package/dist/{rotation-Cwct4ckk.js → rotation-ChBbNDE2.js} +27 -28
  171. package/dist/rotation-ChBbNDE2.js.map +1 -0
  172. package/dist/rotation-fTnNJcfH.cjs +2 -0
  173. package/dist/rotation-fTnNJcfH.cjs.map +1 -0
  174. package/dist/{sampling-BlrI8jor.js → sampling-DZTOD28D.js} +16 -16
  175. package/dist/{sampling-BlrI8jor.js.map → sampling-DZTOD28D.js.map} +1 -1
  176. package/dist/{sampling-mXt4dstx.cjs → sampling-wAVJIZXp.cjs} +2 -2
  177. package/dist/{sampling-mXt4dstx.cjs.map → sampling-wAVJIZXp.cjs.map} +1 -1
  178. package/dist/{sanitize-Ba0KqU06.js → sanitize-B2GKlSFp.js} +2 -2
  179. package/dist/{sanitize-Ba0KqU06.js.map → sanitize-B2GKlSFp.js.map} +1 -1
  180. package/dist/{sanitize-DQyiI_KY.cjs → sanitize-BZdhoghq.cjs} +2 -2
  181. package/dist/{sanitize-DQyiI_KY.cjs.map → sanitize-BZdhoghq.cjs.map} +1 -1
  182. package/dist/{sender-Dv8rAmpV.js → sender-BRSpc7R8.js} +192 -178
  183. package/dist/sender-BRSpc7R8.js.map +1 -0
  184. package/dist/sender-CFu98DAB.cjs +2 -0
  185. package/dist/sender-CFu98DAB.cjs.map +1 -0
  186. package/dist/storage/emergency-queue.d.cts +3 -1
  187. package/dist/storage/emergency-queue.d.ts +3 -1
  188. package/dist/storage/stored-context.d.cts +3 -2
  189. package/dist/storage/stored-context.d.ts +3 -2
  190. package/dist/stored-context-CPLlzgpm.cjs +2 -0
  191. package/dist/stored-context-CPLlzgpm.cjs.map +1 -0
  192. package/dist/{stored-context-B2EzVuYm.js → stored-context-df1dEnht.js} +12 -10
  193. package/dist/stored-context-df1dEnht.js.map +1 -0
  194. package/dist/{storm-DjKetLKZ.js → storm-U3_ek1nA.js} +2 -2
  195. package/dist/{storm-DjKetLKZ.js.map → storm-U3_ek1nA.js.map} +1 -1
  196. package/dist/{storm-C-zYSdDX.cjs → storm-qiE_AMC7.cjs} +2 -2
  197. package/dist/{storm-C-zYSdDX.cjs.map → storm-qiE_AMC7.cjs.map} +1 -1
  198. package/dist/transport/exit-flush.d.cts +23 -0
  199. package/dist/transport/exit-flush.d.ts +23 -0
  200. package/dist/transport/http-transport.d.cts +3 -2
  201. package/dist/transport/http-transport.d.ts +3 -2
  202. package/dist/transport/retry-engine.d.cts +11 -3
  203. package/dist/transport/retry-engine.d.ts +11 -3
  204. package/dist/types-BAerHgCq.js.map +1 -1
  205. package/dist/types-C7WNpnG1.cjs.map +1 -1
  206. package/dist/{unclean-exit-DQD1cT7c.js → unclean-exit-Bj6gYHeL.js} +2 -2
  207. package/dist/{unclean-exit-DQD1cT7c.js.map → unclean-exit-Bj6gYHeL.js.map} +1 -1
  208. package/dist/{unclean-exit-py99ApzT.cjs → unclean-exit-CuBh-ee5.cjs} +2 -2
  209. package/dist/{unclean-exit-py99ApzT.cjs.map → unclean-exit-CuBh-ee5.cjs.map} +1 -1
  210. package/dist/{user-timing-D6XTmpuM.cjs → user-timing-BWqzYF2Q.cjs} +2 -2
  211. package/dist/{user-timing-D6XTmpuM.cjs.map → user-timing-BWqzYF2Q.cjs.map} +1 -1
  212. package/dist/{user-timing-BePqb1uN.js → user-timing-Duz0d-OA.js} +2 -2
  213. package/dist/{user-timing-BePqb1uN.js.map → user-timing-Duz0d-OA.js.map} +1 -1
  214. package/dist/utils/identity.d.cts +5 -0
  215. package/dist/utils/identity.d.ts +5 -0
  216. package/dist/utils/lock.d.cts +3 -2
  217. package/dist/utils/lock.d.ts +3 -2
  218. package/dist/utils/openfin.d.cts +18 -6
  219. package/dist/utils/openfin.d.ts +18 -6
  220. package/dist/utils/patch.d.cts +1 -1
  221. package/dist/utils/patch.d.ts +1 -1
  222. package/dist/utils/platform.d.cts +6 -0
  223. package/dist/utils/platform.d.ts +6 -0
  224. package/dist/{web-socket-DSHgDiZ6.js → web-socket-CE_9Q22z.js} +5 -5
  225. package/dist/{web-socket-DSHgDiZ6.js.map → web-socket-CE_9Q22z.js.map} +1 -1
  226. package/dist/{web-socket-CoIUBM3C.cjs → web-socket-sm3rD-A_.cjs} +2 -2
  227. package/dist/{web-socket-CoIUBM3C.cjs.map → web-socket-sm3rD-A_.cjs.map} +1 -1
  228. package/dist/{web-vitals-4pWACwaR.js → web-vitals-CGwXGF-M.js} +4 -4
  229. package/dist/web-vitals-CGwXGF-M.js.map +1 -0
  230. package/dist/web-vitals-Df4Wsfx9.cjs +2 -0
  231. package/dist/web-vitals-Df4Wsfx9.cjs.map +1 -0
  232. package/dist/{worker-protocol-QbvqNazn.cjs → worker-protocol-D5VnCdWY.cjs} +2 -2
  233. package/dist/{worker-protocol-QbvqNazn.cjs.map → worker-protocol-D5VnCdWY.cjs.map} +1 -1
  234. package/dist/{worker-protocol-x074Rpet.js → worker-protocol-h4-tRWqy.js} +6 -6
  235. package/dist/{worker-protocol-x074Rpet.js.map → worker-protocol-h4-tRWqy.js.map} +1 -1
  236. package/dist/{worker-server-CFe4nvos.cjs → worker-server-CF1yatXq.cjs} +2 -2
  237. package/dist/{worker-server-CFe4nvos.cjs.map → worker-server-CF1yatXq.cjs.map} +1 -1
  238. package/dist/worker-server-FYfKHQhJ.js +94 -0
  239. package/dist/{worker-server-iUVSjH8L.js.map → worker-server-FYfKHQhJ.js.map} +1 -1
  240. package/dist/worker-transport-COgY4RX8.cjs +2 -0
  241. package/dist/worker-transport-COgY4RX8.cjs.map +1 -0
  242. package/dist/{worker-transport-Dy1KMA7t.js → worker-transport-jzX1IusG.js} +49 -45
  243. package/dist/worker-transport-jzX1IusG.js.map +1 -0
  244. package/llms.txt +14 -12
  245. package/package.json +13 -5
  246. package/dist/bus-C39wspFV.js.map +0 -1
  247. package/dist/bus-_EaOVPGq.cjs +0 -2
  248. package/dist/bus-_EaOVPGq.cjs.map +0 -1
  249. package/dist/config-DUs7uHHt.cjs +0 -2
  250. package/dist/config-DUs7uHHt.cjs.map +0 -1
  251. package/dist/config-SgQcCP1_.js +0 -560
  252. package/dist/config-SgQcCP1_.js.map +0 -1
  253. package/dist/constants-CUyd9cTZ.js.map +0 -1
  254. package/dist/constants-CqdJhTxH.cjs +0 -2
  255. package/dist/constants-CqdJhTxH.cjs.map +0 -1
  256. package/dist/errors-BE_EZV7Q.js.map +0 -1
  257. package/dist/errors-CNPbesMs.cjs +0 -3
  258. package/dist/errors-CNPbesMs.cjs.map +0 -1
  259. package/dist/factory-CTi0Is3F.js.map +0 -1
  260. package/dist/factory-hRrH32v5.cjs +0 -2
  261. package/dist/factory-hRrH32v5.cjs.map +0 -1
  262. package/dist/identity-DdhKgrpk.js.map +0 -1
  263. package/dist/identity-DlWRIuwy.cjs +0 -2
  264. package/dist/identity-DlWRIuwy.cjs.map +0 -1
  265. package/dist/interactions-CUkzK8sR.cjs +0 -2
  266. package/dist/interactions-CUkzK8sR.cjs.map +0 -1
  267. package/dist/interactions-DiFvCosX.js +0 -111
  268. package/dist/interactions-DiFvCosX.js.map +0 -1
  269. package/dist/patch-BX8KrPCT.cjs +0 -2
  270. package/dist/patch-BX8KrPCT.cjs.map +0 -1
  271. package/dist/patch-UdPz1ea8.js +0 -8
  272. package/dist/patch-UdPz1ea8.js.map +0 -1
  273. package/dist/platform-BaaFIPCU.js +0 -62
  274. package/dist/platform-BaaFIPCU.js.map +0 -1
  275. package/dist/platform-CfA3-7sJ.cjs +0 -2
  276. package/dist/platform-CfA3-7sJ.cjs.map +0 -1
  277. package/dist/replay-B3gFXIZd.cjs +0 -2
  278. package/dist/replay-B3gFXIZd.cjs.map +0 -1
  279. package/dist/replay-Ds-ANH34.js.map +0 -1
  280. package/dist/response-body-YdNl-HkR.cjs +0 -3
  281. package/dist/response-body-YdNl-HkR.cjs.map +0 -1
  282. package/dist/response-body-eoSQpLiH.js.map +0 -1
  283. package/dist/rotation-Cwct4ckk.js.map +0 -1
  284. package/dist/rotation-D4qUAHAu.cjs +0 -2
  285. package/dist/rotation-D4qUAHAu.cjs.map +0 -1
  286. package/dist/sender-BdRuNVhF.cjs +0 -2
  287. package/dist/sender-BdRuNVhF.cjs.map +0 -1
  288. package/dist/sender-Dv8rAmpV.js.map +0 -1
  289. package/dist/stored-context-B2EzVuYm.js.map +0 -1
  290. package/dist/stored-context-CXt7eHZL.cjs +0 -2
  291. package/dist/stored-context-CXt7eHZL.cjs.map +0 -1
  292. package/dist/web-vitals-4pWACwaR.js.map +0 -1
  293. package/dist/web-vitals-__X7t4pj.cjs +0 -2
  294. package/dist/web-vitals-__X7t4pj.cjs.map +0 -1
  295. package/dist/worker-server-iUVSjH8L.js +0 -94
  296. package/dist/worker-transport-CRAX-09c.cjs +0 -2
  297. package/dist/worker-transport-CRAX-09c.cjs.map +0 -1
  298. package/dist/worker-transport-Dy1KMA7t.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants-CqdJhTxH.cjs"),t=require("./log-record-CkivuiEl.cjs"),n=require("./error-like-gGRx2s36.cjs"),r=require("./guards-EjG3ahFp.cjs"),i=require("./unref-CU9Nyz_9.cjs"),a=require("./platform-CfA3-7sJ.cjs"),o=require("./defineProperty-X1c4tIPD.cjs"),s=require("./identity-DlWRIuwy.cjs"),c=require("./profiler-D4tJpDRc.cjs"),l=require("./library-console-CPW6bvZH.cjs"),u=require("./sanitize-DQyiI_KY.cjs"),d=require("./library-request-D7OvTxZV.cjs"),f=require("./config-DUs7uHHt.cjs"),p=require("./batch-mmPigCpi.cjs"),m=require("./journey-B4Adltjm.cjs"),h=require("./sampling-mXt4dstx.cjs");var g=new WeakMap;function _(e){let t=e.idle;t!==void 0&&(e.diagnostics.guard(`pipeline.crashed`,`The idle callback could not be cancelled.`,()=>{cancelIdleCallback(t)}),e.idle=void 0),clearTimeout(e.timer),e.timer=void 0}function v(t,n){typeof requestIdleCallback==`function`&&typeof cancelIdleCallback==`function`&&(n.idle=n.diagnostics.guard(`pipeline.crashed`,`The idle callback could not be scheduled.`,()=>requestIdleCallback(e=>{y(t,n,e)},{timeout:e.K})),n.idle!==void 0)||(n.timer=setTimeout(()=>{y(t,n)},0),i.t(n.timer))}function y(e,t,n){if(g.get(e)!==t||t.draining)return;_(t),t.draining=!0;let r=t.work;t.work=[];let i=0;for(;i<r.length&&(!n||n.didTimeout&&i===0||n.timeRemaining()>0);)if(t.diagnostics.guard(`pipeline.crashed`,`The library could not build a deferred record.`,r[i]),i++,g.get(e)!==t)return;t.work=[...r.slice(i),...t.work],t.draining=!1,t.work.length>0?v(e,t):g.delete(e)}function b(t,n,r,i){let a=g.get(t),o=i===null?e.q:Math.min(i,e.q);if(a&&a.work.length>=o&&!a.draining&&(y(t,a),a=g.get(t)),a){if(a.work.length>=o){r.count(`record.dropped_by_ceiling`);return}a.work.push(n)}else a={work:[n],diagnostics:r,draining:!1},g.set(t,a),v(t,a)}function x(e){let t=g.get(e);t&&y(e,t)}function S(e){let t=g.get(e);if(t){_(t),g.delete(e);for(let e of t.work)t.diagnostics.count(`record.dropped_by_ceiling`);t.work=[]}}var C=[e.P,e.Gn,e.J];function w(e,t){let r=t.guard(`record.sanitize_failed`,`The library could not read the error reason.`,()=>{if(!(e instanceof Error)&&!n.r(e))return;let t=Error(e.message);return t.name=e.name,t.stack=e.stack,t});if(r)return r;let i=t.guard(`record.sanitize_failed`,`The library could not convert the error reason to text.`,()=>String(e));return Error(i??typeof e)}function ee(e,t,n){return n.guard(`record.sanitize_failed`,`The library could not read the error reason.`,()=>e instanceof Error?e:t)??t}function te(e,t){if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||typeof e==`symbol`)return e;if(typeof e==`object`&&e)return t.guard(`record.sanitize_failed`,`The library could not read the properties of the error reason.`,()=>{let t=e,r=n.r(e),i={},a=0;for(let e of Object.keys(t)){let o=t[e];r&&n.t.has(e)||!n.n(o)||(i[e]=o,a++)}return a===0?void 0:i})}function ne(e){if(!r.n(e)||e instanceof Error)return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}function re(e){return C.some(t=>e===t||e.startsWith(`${t}.`))?`system`:`log`}function T(e,t){return e===void 0?{}:t.guard(`record.sanitize_failed`,`The library could not read the payload.`,()=>({...e}))??{"uiobs.sanitize_failed":!0}}var E=class n{constructor(e,t,n={}){o.t(this,`bind`,void 0),o.t(this,`namespace`,void 0),o.t(this,`options`,void 0),o.t(this,`levelType`,void 0),o.t(this,`trace`,(e,t)=>{this.write(`TRACE`,this.levelType,e,t)}),o.t(this,`debug`,(e,t)=>{this.write(`DEBUG`,this.levelType,e,t)}),o.t(this,`info`,(e,t)=>{this.write(`INFO`,this.levelType,e,t)}),o.t(this,`warn`,(e,t)=>{this.write(`WARN`,this.levelType,e,t)}),o.t(this,`error`,(e,t,n)=>{this.writeError(`ERROR`,e,t,n)}),o.t(this,`fatal`,(e,t,n)=>{this.writeError(`FATAL`,e,t,n)}),o.t(this,`logAction`,(e,t)=>{this.write(`INFO`,`action`,e,t)}),o.t(this,`logEvent`,(e,t)=>{this.write(`INFO`,`event`,e,t)}),this.bind=e,this.namespace=t,this.options=n,this.levelType=re(t)}child(e,t={}){return new n(this.bind,`${this.namespace}.${e}`,{scopedContext:{...this.options.scopedContext,...t.scopedContext}})}write(e,t,n,r){let i=this.bind();this.submit(i,e,t,a=>{this.writeNow(i,e,t,n,r,!1,a)})}submit(e,n,r,i){if(!e.isDestroyed()){if(e.isRotating())e.diagnostics.count(`record.dropped_during_rotation`);else if(e.config.payloadMode===`defer`&&e.config.enabled&&!e.config.debugBuffer.enabled&&this.namespace!==`uiobs.diagnostics`){if(!e.builder.isEnabled(n,this.namespace,r)&&!this.mirrors(e,n))return;let o=e.journey.current(),s={timeUnixNano:t.r(),trace:e.tracing.resolve(),journey:o?{...o}:null,context:e.context.getAll(),url:a.t(e.diagnostics)};b(e,()=>{i(s)},e.diagnostics,e.config.buffering.maxPendingRecords)}else i()}}writeNow(e,t,n,r,i,a,o){if(!(e.config.enabled&&e.config.debugBuffer.enabled)&&!e.builder.isEnabled(t,this.namespace,n)){this.mirrors(e,t)&&this.print(e,t,r,i,void 0,null,void 0,o);return}let s={snapshot:o,level:t,type:n,body:r,namespace:this.namespace,scoped:this.options.scopedContext,payload:a?i:T(i,e.diagnostics)},{record:c,dropped:l}=e.builder.build(s),u=!!e.config.redact||e.config.processors.length>0,d=n!==`metric`&&e.config.captureLimits.breadcrumbs>0,f=l===`sampling`&&u&&d?e.builder.build(s,!0):void 0,p=c??f?.record??null,m=p?p.body:l===`sampling`&&!u?r:void 0;d&&m!==void 0&&e.breadcrumbs.push({t:o?Number(o.timeUnixNano.slice(0,-6)):Date.now(),category:n===`action`?`action`:n===`event`?`event`:`log`,message:m}),this.print(e,t,r,i,void 0,p,f?.dropped??l,o),e.emit(c)}writeError(e,t,n,r){let i=this.bind();this.submit(i,e,this.levelType,a=>{this.writeErrorNow(i,e,t,n,r,a)})}writeErrorNow(t,n,r,i,a,o){let s=t.builder.isEnabled(n,this.namespace);if(!s&&!this.mirrors(t,n))return;let c=a===void 0&&(t.diagnostics.guard(`record.sanitize_failed`,`The library could not read the error slot.`,()=>ne(i))??!1),l=c?i:a,u=c?void 0:i,d=u===void 0?void 0:w(u,t.diagnostics),f=d===void 0?void 0:ee(u,d,t.diagnostics);if(!s){this.print(t,n,r,l,f,null,void 0,o);return}let p=d?te(u,t.diagnostics):void 0,{record:m,dropped:h}=t.builder.build({snapshot:o,level:n,type:this.levelType,body:r,namespace:this.namespace,scoped:this.options.scopedContext,payload:{...T(l,t.diagnostics),...d?{"error.type":d.name,"error.message":d.message,"error.stack_trace":d.stack}:{},...p===void 0?{}:{[e.d]:p},[e.c]:t.breadcrumbs.snapshot()}});this.print(t,n,r,l,f,m,h,o),t.emit(m)}print(e,t,n,r,i,a,o,s){if(!e.config.redact&&e.config.processors.length===0){e.console.write(this.namespace,t,n,r,i);return}if(a){e.console.write(this.namespace,t,a.body,a.attributes);return}if(o===`processor`||o===`redact`||o===`malformed`||!e.config.enabled||!e.console.accepts(t))return;let c=e.builder.build({snapshot:s,level:t,type:this.levelType,body:n,namespace:this.namespace,scoped:this.options.scopedContext,payload:{...T(r,e.diagnostics),...i?{"error.type":i.name,"error.message":i.message,"error.stack_trace":i.stack}:{}}},!0).record;c&&e.console.write(this.namespace,t,c.body,c.attributes)}mirrors(e,t){return e.config.enabled&&e.console.accepts(t)}},ie=class extends E{constructor(...t){super(...t),o.t(this,`logMetric`,(t,n,r=e.G,i=`gauge`,a,o)=>{if(!Number.isFinite(n)){this.bind().diagnostics.report(`record.dropped_malformed`,`The metric value is not a finite number. The library dropped the metric.`,{"metric.name":t});return}let s=this.bind();this.submit(s,`INFO`,`metric`,c=>{let l=T(a,s.diagnostics),u={...T(o,s.diagnostics),...l,"metric.name":t,"metric.value":n,"metric.unit":r,"metric.type":i,[e.zt.attributeKeys]:Object.keys(l)};this.writeNow(s,`INFO`,`metric`,t,u,!0,c)})})}},ae=/^[0-9a-f]{32}$/,oe=/^[0-9a-f]{16}$/,se=/[1-9a-f]/;function ce(e){return ae.test(e.traceId)&&se.test(e.traceId)&&oe.test(e.spanId)&&se.test(e.spanId)}function le(){return s.o(16)}function D(){return s.o(8)}function O(e){return{traceId:le(),spanId:D(),traceFlags:1,startedAt:Date.now(),reason:e,ended:!1}}function k(e,t,n){return`00-${e}-${t}-${(n&255).toString(16).padStart(2,`0`)}`}function ue(e){return{traceId:e.traceId,spanId:e.spanId,traceFlags:e.traceFlags}}var de=class{constructor(t,n=e.nr,r,i){o.t(this,`diagnostics`,void 0),o.t(this,`maxAgeMs`,void 0),o.t(this,`load`,void 0),o.t(this,`spans`,void 0),o.t(this,`ambient`,O(`start`)),o.t(this,`otel`,void 0),this.diagnostics=t,this.maxAgeMs=n,this.load=r,this.spans=i}setup(e,t){this.maxAgeMs=e,this.load=t}async loadOtel(){if(this.load)try{this.otel=await this.load()}catch(e){this.diagnostics.report(`trace.otel_failed`,`The library could not load @opentelemetry/api. Records use the trace ids of the library.`,void 0,e)}}resolve(){return this.activeSpanContext()??this.ambientContext()}ambientContext(){return Date.now()-this.ambient.startedAt>this.maxAgeMs&&this.rotate(`maxAge`),ue(this.ambient)}activeSpanContext(){let e=this.otel;if(e)return this.diagnostics.guard(`trace.otel_failed`,`The library could not read the active OpenTelemetry span.`,()=>{let t=e.trace.getActiveSpan();if(t===void 0)return;let n=t.spanContext();if(ce(n))return{traceId:n.traceId,spanId:n.spanId,traceFlags:n.traceFlags}})}rotate(e){let t=this.ambient;this.ambient=O(e);let n=ue(this.ambient);return this.finish(t),n}end(){this.finish(this.ambient)}finish(e){e.ended||(e.ended=!0,this.spans?.onEnd({traceId:e.traceId,spanId:e.spanId,reason:e.reason,startedAt:e.startedAt,endedAt:Date.now()}))}headers(){return this.trace(!1).headers}request(){return this.trace(!0)}trace(t){let n={},r=this.otel;if(r&&this.diagnostics.guard(`trace.otel_failed`,`The library could not add the OpenTelemetry headers.`,()=>{r.propagation.inject(r.context.active(),n)}),n.traceparent)return{headers:n};let i=this.activeSpanContext(),a=i??this.ambientContext(),o=i?void 0:this.spans;if(!o?.enabled())return n[e.tr]=k(a.traceId,a.spanId,a.traceFlags),{headers:n};let s=o.keeps(a.traceId),c=s?a.traceFlags:a.traceFlags&-2,l=t?D():a.spanId;return n[e.tr]=k(a.traceId,l,c),!t||!s?{headers:n}:{headers:n,span:{traceId:a.traceId,spanId:l,parentSpanId:a.spanId}}}},fe={name:`ui.measure.duration`,kind:`histogram`,unit:`ms`,boundaries:e.Lt},pe={name:`ui.measure.phase.duration`,kind:`histogram`,unit:`ms`,boundaries:e.Lt};function me(e,t,n,r){let i=String(e),a=Date.now(),o=performance.now(),s,c=!1,l=e=>a+e-o,u=(e,a)=>{s&&=(r.metric(pe,e-s.at,{...t,"measure.name":i,"measure.phase":s.name}),n&&r.span({name:s.name,kind:`internal`,traceId:n.traceId,spanId:D(),parentSpanId:n.spanId,startMs:l(s.at),endMs:l(e),error:a,attributes:{"measure.name":i}}),void 0)};return{phase:e=>{if(c)return;let t=performance.now();u(t,!1),s={name:String(e),at:t}},end:(e=`ok`)=>{if(c)return;c=!0;let s=performance.now(),d=e===`error`;u(s,d);let f={...t,"measure.outcome":e};r.metric(fe,s-o,{...f,"measure.name":i}),n&&r.span({...n,name:i,kind:`internal`,startMs:a,endMs:l(s),error:d,attributes:f})}}}function he(e,t,n){let r=`error`;try{let i=t(),a=n.guard(`record.sanitize_failed`,`The library could not read what the function of the measure returned. The measure ends now.`,()=>i?.then);if(typeof a!=`function`)return r=`ok`,i;let o=a.call(i,t=>(e.end(),t),t=>{throw e.end(`error`),t});return r=void 0,o}finally{r!==void 0&&e.end(r)}}var ge=`overflow`,_e=new Set([e.g,e.h,e.a,e.v,e.f,e.p,e.m]);function ve(e={}){let t={};for(let n of Object.keys(e).sort()){if(n.startsWith(`metric.`)||_e.has(n))continue;let r=e[n];(typeof r==`string`||typeof r==`boolean`||typeof r==`number`&&Number.isFinite(r))&&(t[n]=r)}return t}function ye(e,t){if(!Array.isArray(e))return null;let n=t===null?e.length:Math.min(e.length,t+1);return Array.from({length:n},(t,n)=>e[n])}function be(e,t){return Array.isArray(e)&&(t===null||e.length<=t)&&e.every((t,n)=>typeof t==`number`&&Number.isFinite(t)&&(n===0||t>e[n-1]))}function xe(t,n,r){let i={"metric.name":t.name,"metric.unit":t.unit,"metric.type":t.kind,[e.zt.start]:r,[e.zt.attributeKeys]:Object.keys(n.attributes)};return t.kind===`histogram`?{...i,[e.zt.count]:n.count,[e.zt.sum]:n.sum,[e.zt.min]:n.min,[e.zt.max]:n.max,[e.zt.bounds]:t.boundaries,[e.zt.buckets]:n.buckets}:(i[`metric.value`]=t.kind===`gauge`?n.last:n.sum,i)}function Se(e,t){try{return{unit:e.unit,boundaries:e.boundaries}}catch(e){return t(e),{unit:void 0,boundaries:void 0}}}function Ce(e,t,n,r){return{name:e,kind:t,unit:Se(n,r).unit??`count`,boundaries:[]}}function we(e,t,n,r){let i=Ce(e,`counter`,t,r);return{add:(e,t)=>{n(i,e,t)}}}function Te(e,t,n,r){let i=Ce(e,`gauge`,t,r);return{set:(e,t)=>{n(i,e,t)}}}function Ee(t,n,r,i){let{unit:a,boundaries:o}=Se(n,i),s={name:t,kind:`histogram`,unit:a??`count`,boundaries:o??e.Lt,fromApp:o!==void 0};return{record:(e,t)=>{r(s,e,t)}}}var De=class{constructor(e,t,n,r={maxSeries:100,maxInstruments:1e3,maxHistogramBoundaries:50}){o.t(this,`intervalMs`,void 0),o.t(this,`emit`,void 0),o.t(this,`diagnostics`,void 0),o.t(this,`policy`,void 0),o.t(this,`instruments`,new Map),o.t(this,`timer`,null),o.t(this,`startedAt`,0),this.intervalMs=e,this.emit=t,this.diagnostics=n,this.policy=r}record(e,t,n){!Number.isFinite(t)||e.kind===`counter`&&t<0?this.diagnostics.report(`record.dropped_malformed`,`The value of the metric ${e.name} is not valid. The library dropped it.`,{"metric.name":e.name}):this.diagnostics.guard(`record.sanitize_failed`,`The library could not read the attributes of the metric ${e.name}.`,()=>{let r=this.instrumentOf(e);r&&(this.add(r,t,ve(n)),this.arm())})}collect(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null);let e=`${String(this.startedAt)}000000`,t=[...this.instruments.values()];this.instruments.clear();for(let{def:n,series:r}of t)for(let t of r.values())this.emit(n.name,t.attributes,xe(n,t,e))}instrumentOf(t){let n=this.instruments.get(t.name);if(n)return n.def.kind===t.kind?n:(this.diagnostics.report(`record.dropped_malformed`,`The metric ${t.name} is a ${n.def.kind} and a ${t.kind}. The library dropped the value.`,{"metric.name":t.name}),null);let{maxInstruments:r}=this.policy;if(r!==null&&this.instruments.size>=r)return this.diagnostics.count(`record.dropped_by_ceiling`),null;let i=t.fromApp===!0?this.policy.maxHistogramBoundaries:null,a=ye(t.boundaries,i),o=be(a,i);t.kind===`histogram`&&!o&&this.diagnostics.report(`config.invalid`,`The boundaries of the metric ${t.name} must meet metrics.maxHistogramBoundaries and contain finite numbers in ascending order. The library uses the default boundaries.`);let s={def:{...t,boundaries:o?a:[...e.Lt]},series:new Map};return this.instruments.set(t.name,s),s}add(t,n,r){let i=JSON.stringify(r),a=t.series.get(i),o=r,{maxSeries:s}=this.policy;if(!a&&s!==null&&t.series.size>=s&&(i=ge,a=t.series.get(i),o={[e._]:!0}),!a){let e=t.def.kind===`histogram`?t.def.boundaries.length+1:0,r=Array(e).fill(0);a={attributes:o,count:0,sum:0,min:n,max:n,last:n,buckets:r},t.series.set(i,a)}if(a.count+=1,a.sum+=n,a.min=Math.min(a.min,n),a.max=Math.max(a.max,n),a.last=n,a.buckets.length>0){let e=t.def.boundaries.findIndex(e=>n<=e);a.buckets[e===-1?a.buckets.length-1:e]+=1}}arm(){this.timer===null&&(this.startedAt=Date.now(),this.timer=setTimeout(()=>{this.collect()},this.intervalMs()),i.t(this.timer))}},Oe={TRACE:`debug`,DEBUG:`debug`,INFO:`info`,WARN:`warn`,ERROR:`error`,FATAL:`error`},ke=class{constructor(t,n,r=e.on){o.t(this,`settings`,void 0),o.t(this,`diagnostics`,void 0),o.t(this,`limits`,void 0),this.settings=t,this.diagnostics=n,this.limits=r}update(e){this.settings=e}accepts(t){return this.settings.level===null||!r.t(e.kt,this.settings.level)?!1:e.kt[t]>=e.kt[this.settings.level]}write(e,t,n,r,i){if(!this.accepts(t)||typeof console>`u`||l.t())return;let a=`%c[%s]%c[${t}]%c`,{styles:o}=this.settings,s=Oe[t];this.diagnostics.guard(`handler.threw`,`The library could not print to console.${s}.`,()=>{let c=[];i!==void 0&&c.push(i),r!==void 0&&c.push(u.n(r,this.limits,this.diagnostics)),l.n(()=>{console[s](a,o.namespace,e,o[t],``,n,...c)})})}},Ae=class{constructor(){o.t(this,`value`,0)}next(){return++this.value}},je=class{constructor(e){o.t(this,`buffer`,void 0),o.t(this,`pointer`,0),o.t(this,`filled`,!1),o.t(this,`capacity`,void 0),this.capacity=e===0?0:Math.max(e,1),this.buffer=Array(this.capacity)}resize(e){let t=this.snapshot().slice(-e);if(this.capacity=e,this.buffer=Array(e),this.pointer=0,this.filled=!1,e)for(let e of t)this.push(e)}push(e){this.capacity!==0&&(this.buffer[this.pointer]=e,this.pointer=(this.pointer+1)%this.capacity,this.pointer===0&&(this.filled=!0))}retain(e){let t=this.snapshot().filter(e);this.clear();for(let e of t)this.push(e)}clear(){this.buffer.fill(void 0),this.pointer=0,this.filled=!1}snapshot(){return(this.filled?[...this.buffer.slice(this.pointer),...this.buffer.slice(0,this.pointer)]:this.buffer.slice(0,this.pointer)).filter(e=>e!==void 0)}},Me=class{constructor(){o.t(this,`map`,new Map)}merge(e){for(let[t,n]of Object.entries(e))n===null?this.map.delete(t):n!==void 0&&this.map.set(t,n)}remove(e){this.map.delete(e)}clear(){this.map.clear()}getAll(){return Object.fromEntries(this.map)}},Ne=class{constructor(e){o.t(this,`policy`,void 0),o.t(this,`kept`,[]),this.policy=e}push(e){let{enabled:t,maxRecords:n}=this.policy();t&&(this.kept.push({at:Date.now(),record:e}),this.kept.length>=n*2&&(this.kept=this.kept.slice(-n)))}drain(){let t=this.live();return this.kept=[],t.map(({record:t})=>({...t,attributes:{...t.attributes,[e.u]:!0}}))}snapshot(){return this.live().map(({record:e})=>e)}live(){let{enabled:e,maxRecords:t,maxAgeMs:n}=this.policy();if(!e)return this.kept=[],[];let r=n===null?-1/0:Date.now()-n;return this.kept.slice(-t).filter(e=>e.at>=r)}clear(){this.kept=[]}},A=class{constructor(t,n=e.Y,r=!1){o.t(this,`handler`,void 0),o.t(this,`throttleMs`,void 0),o.t(this,`consoleFallback`,void 0),o.t(this,`counters`,new Map),o.t(this,`lastEmitted`,new Map),this.handler=t,this.throttleMs=n,this.consoleFallback=r}setPolicy(e,t){this.throttleMs=e,this.consoleFallback=t}setHandler(e){this.handler=e}count(e,t=1){let n=(this.counters.get(e)??0)+t;return this.counters.set(e,n),n}report(t,n,r,i){let a=this.count(t),o=Date.now();if(o-(this.lastEmitted.get(t)??0)<this.throttleMs)return!1;this.lastEmitted.set(t,o);let s={code:t,message:n,detail:r,cause:i,at:o,count:a},{handler:c}=this;if(!c)return!0;try{l.n(()=>{c(s)})}catch{this.count(`handler.threw`),this.consoleFallback&&typeof console<`u`&&l.n(()=>{console.warn(`${e.jt} The onDiagnostic handler threw an error.`)})}return!0}guard(e,t,n){try{return n()}catch(n){this.report(e,t,void 0,n);return}}async guardAsync(e,t,n){try{return await n()}catch(n){this.report(e,t,void 0,n);return}}snapshot(){return Object.fromEntries(this.counters)}};function j(e,t){e.length<20&&!e.includes(t)&&e.push(t)}var Pe=class{constructor(e,t){o.t(this,`config`,void 0),o.t(this,`diagnostics`,void 0),o.t(this,`pending`,new Map),o.t(this,`scheduled`,!1),o.t(this,`reporting`,!1),o.t(this,`lost`,{}),this.config=e,this.diagnostics=t}add(t,n,r=[],i=n.length){if(i>0&&(this.lost[t]=(this.lost[t]??0)+i),!this.config.onDrop||this.reporting||n.length===0&&r.length===0)return;let a=this.pending.get(t);a||(a={reason:t,records:0,batchIds:[],journeyIds:[],actions:[]},this.pending.set(t,a)),a.records+=i;for(let e of r)j(a.batchIds,e);for(let t of n){let n=p.t(t,e.f);typeof n==`string`&&j(a.journeyIds,n);let r=p.r(t)?t.body:void 0;typeof r==`string`&&j(a.actions,r)}this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.flush()}))}counts(){return{...this.lost}}flush(){this.scheduled=!1;let e=[...this.pending.values()];this.pending.clear();let t=this.config.onDrop;if(t){this.reporting=!0;for(let n of e)this.diagnostics.guard(`handler.threw`,`The onDrop hook threw an error.`,()=>{d.r(()=>{l.n(()=>{t(n)})})});this.reporting=!1}}},Fe=class{constructor(e){o.t(this,`onDrop`,void 0),o.t(this,`actions`,{head:[],tail:[]}),o.t(this,`others`,{head:[],tail:[]}),o.t(this,`arrivals`,0),this.onDrop=e}get records(){return this.inOrder()}get length(){let{actions:e,others:t}=this;return e.head.length+e.tail.length+t.head.length+t.tail.length}push(t,n){let r=p.r(t),i=r?this.actions:this.others,a=r?e.j:n,o={record:t,arrival:this.arrivals};if(this.arrivals+=1,i.head.length<100)i.head.push(o);else if(i.tail.push(o),i.head.length+i.tail.length>a){let e=i.tail[0];i.tail.shift(),this.onDrop(e.record)}}take(){let e=this.inOrder();return this.actions={head:[],tail:[]},this.others={head:[],tail:[]},this.arrivals=0,e}inOrder(){let{actions:e,others:t}=this;return[...e.head,...e.tail,...t.head,...t.tail].sort((e,t)=>e.arrival-t.arrival).map(e=>e.record)}},Ie=`error.`,Le=[e.v,e.f,e.p],Re={processor:{label:`A processor`,code:`record.dropped_by_processor`,refused:`processors is not a list of functions. The library drops each record until processors is a list of functions or [].`},redact:{label:`The redact hook`,code:`record.dropped_by_redact`,refused:`redact is not a function. The library drops each record until redact is a function or null.`}},M=e=>typeof e==`number`&&Number.isFinite(e),N=e=>Array.isArray(e)&&e.every(M),P=e=>typeof e==`string`&&/^\d{1,20}$/.test(e),ze=e=>typeof e==`string`&&/^[0-9a-f]{32}$/.test(e),F=e=>typeof e==`string`&&/^[0-9a-f]{16}$/.test(e),Be=e=>e===``||F(e),Ve=e=>e===`counter`,He=e=>e===`histogram`,Ue=e=>e===`client`||e===`internal`,We=e=>e===`error`||e===`unset`,Ge={"metric.type":Ve,"metric.value":M,[e.zt.start]:P},Ke={"metric.type":He,[e.zt.start]:P,[e.zt.count]:M,[e.zt.sum]:M,[e.zt.min]:M,[e.zt.max]:M,[e.zt.bounds]:N,[e.zt.buckets]:N},qe={[e.Hn.kind]:Ue,[e.Hn.parentId]:Be,[e.Hn.start]:P,[e.Hn.end]:P,[e.Hn.status]:We},Je={[e.Hn.linkTraceId]:ze,[e.Hn.linkSpanId]:F};function Ye(t){let n=t[e.g],r=t[e.a];return n===`span`&&r===`uiobs.traces`?[qe,Je]:n!==`metric`||r!==`uiobs.metrics`?[]:t[`metric.type`]===`histogram`?[Ke]:[Ge]}function I(e){let t={};for(let n of Ye(e)){let r=Object.keys(n);if(r.every(t=>n[t](e[t])))for(let n of r)t[n]=e[n]}return t}function L(e){return e}var Xe=class{constructor(e){o.t(this,`deps`,void 0),o.t(this,`resourceCache`,null),this.deps=e}invalidateResource(){this.resourceCache=null}isEnabled(e,t,n){return this.deps.config.enabled&&this.passesLevel(e,t,n)}passesLevel(t,n,r){let{config:i}=this.deps;if(r!==void 0&&e.Ot.includes(r))return!0;let a=this.deps.remote.sampling?.minLevelFor(n)??h.n(n,i);return e.kt[t]>=e.kt[a]}keepForDebug(e){let{config:t,debug:n}=this.deps;if(!n||!t.enabled||!t.debugBuffer.enabled)return;let{record:r}=this.build(e,!0);r&&n.push(r)}build(n,r=!1){let{config:i,diagnostics:o,tracing:s,journey:c,sequence:l,limits:d,remote:f}=this.deps;if(!r&&!this.isEnabled(n.level,n.namespace,n.type))return o.count(`record.dropped_by_level`),this.keepForDebug(n),{record:null,dropped:`level`};let p=n.trace??n.snapshot?.trace??s.resolve(),m=n.snapshot?n.snapshot.journey:c.current(),g=h.o({level:n.level,type:n.type,namespace:n.namespace,journeyId:m?.id??``,traceId:p.traceId,aggregated:n.aggregated},i,f.sampling?.current()??null);if(!r&&!g)return o.count(`record.dropped_by_sampling`),this.keepForDebug(n),{record:null,dropped:`sampling`};let _=l.next(),v=n.snapshot?.url??a.t(o),y=i.metadata.pageUrl?a.i(v,i.capture.fullUrls,i.capture.urlTransform,o):``,b,x=0;try{let e=u.r(n.snapshot?.context??this.deps.context.getAll(),d,o),t=u.r(this.provided(),d,o),r=u.r(n.scoped??{},d,o),i=u.r(n.payload??{},d,o);x=e.bytes+t.bytes+r.bytes+i.bytes,b={...L(e.value),...L(t.value),...L(r.value),...L(i.value)}}catch(t){o.report(`record.sanitize_failed`,`The library could not sanitize the attributes.`,void 0,t),b={[e.y]:!0}}Object.assign(b,n.fixed),b[e.g]=n.type,b[e.h]=_,b[e.a]=n.namespace,b[e.v]=y,m&&(b[e.f]=m.id,b[e.p]=m.name,m.parentId!==void 0&&(b[e.m]=m.parentId));let S=u.i(n.body,d.maxBodyChars);S!==n.body&&o.count(`record.truncated`);let C={timeUnixNano:n.snapshot?.timeUnixNano??t.r(),traceId:p.traceId,spanId:p.spanId,traceFlags:p.traceFlags,severityNumber:e.Vn[n.level],severityText:n.level,body:S,attributes:b,resource:this.resource()},w=this.hookStages();if(w.length>0){let e=this.applyHooks(C,w,n.fixed);if(typeof e==`string`)return{record:null,dropped:e};({record:C,bytes:x}=e)}let ee={[e.g]:n.type,[e.h]:_,[e.a]:n.namespace};return{record:this.fit(C,x,ee,n.fixed)}}redactForwarded(e){let{redact:t}=this.deps.config;if(!t)return e;let n=[[t,`redact`]],r=this.applyHooks(e,n,I(e.attributes));return typeof r==`string`?null:r.record}rehook(t){let{config:n,diagnostics:r,limits:i,remote:o,debug:s}=this.deps,{attributes:c}=t,l=String(c[e.a]),d=this.passesLevel(t.severityText,l,c[e.g]),f=d&&h.a(t,n,o.sampling?.current()??null),p=n.metadata.pageUrl?a.i(String(c[e.v]),n.capture.fullUrls,n.capture.urlTransform,r):``,m=u.i(t.body,i.maxBodyChars);m!==t.body&&r.count(`record.truncated`);let g=I(c),_={...t,body:m,attributes:{...c,[e.v]:p},resource:this.resource()},v=this.applyHooks(_,this.hookStages(),g),y=typeof v==`string`?null:this.fit(v.record,v.bytes,c,g);return f?y:(r.count(d?`record.dropped_by_sampling`:`record.dropped_by_level`),y&&s&&n.enabled&&n.debugBuffer.enabled&&s.push(y),null)}fit(t,n,r,i){let{diagnostics:a,limits:o}=this.deps;if(n<=o.maxRecordBytes)return t;a.report(`record.truncated`,`The attributes are larger than the size limit. The library dropped the caller attributes.`,{bytes:n,body:t.body});let s={[e.g]:r[e.g],[e.h]:r[e.h],[e.a]:r[e.a],[e.s]:!0,[e.o]:n};for(let e of Le)e in t.attributes&&(s[e]=t.attributes[e]);for(let[e,n]of Object.entries(t.attributes))e.startsWith(Ie)&&(s[e]=n);let c=u.r(s,o,a).bytes;c>o.maxRecordBytes&&`error.data`in s&&(Reflect.deleteProperty(s,e.d),c=u.r(s,o,a).bytes);let l=t.attributes[e.c];if(l!==void 0){let t=u.r(l,o,a).bytes;c+t<=o.maxRecordBytes&&(s[e.c]=l)}return Object.assign(s,i),t.attributes=s,t}hookStages(){let{processors:e,redact:t}=this.deps.config,n=e.map(e=>[e,`processor`]);return t&&n.push([t,`redact`]),n}applyHooks(e,t,n){let r=e;for(let[e,n]of t){let t=this.runHook(e,n,r);if(typeof t==`string`)return t;r=t}let{diagnostics:i,limits:a}=this.deps,o=u.r(r.attributes,a,i),s=L(o.value);return Object.assign(s,n),{record:{...r,attributes:s},bytes:o.bytes}}runHook(n,r,i){let{diagnostics:a}=this.deps,{label:o,code:s,refused:c}=Re[r],l;try{l=n(i)}catch(e){return a.report(s,`${o} threw an error. The library dropped the record.`,void 0,e),r}if(l===null)return n===f.t?a.report(s,c):a.count(s),r;let u=l??i;return t.n(u)?t.t(u.severityText)?{...u,severityNumber:e.Vn[u.severityText]}:(a.report(`record.dropped_malformed`,`${o} set a severityText that is not a log level. The library dropped the record.`),`malformed`):u===i?(a.report(`record.dropped_malformed`,`${o} changed the record to a shape that is not a record. The library dropped it.`),`malformed`):(a.report(s,`${o} returned a value that is not a record. The library dropped the record.`),r)}provided(){let e=this.deps.config.contextProvider;if(!e)return{};let{diagnostics:t}=this.deps,n=t.guard(`handler.threw`,`The contextProvider threw an error. The record has no attributes from it.`,()=>{let t=e();return t===void 0?{}:r.n(t)&&typeof t.then!=`function`?t:null});return n===null&&t.report(`config.invalid`,`contextProvider must return an object of attributes. The library ignores the value.`),n??{}}resource(){if(this.resourceCache)return this.resourceCache;let{config:t,identity:n,platform:r}=this.deps;return this.resourceCache={[e.bn]:t.serviceName,[e.xn]:t.serviceVersion,[e.gn]:t.environment,[e.En]:e.$n,[e.Dn]:e.er,[e.Tn]:e.Qn,[e._n]:r.platform,[e.Sn]:n.sessionId,[e.wn]:n.tabId,[e.hn]:n.contextId,...t.metadata.userAgent?{[e.mn]:r.userAgent}:{},...!t.metadata.openfin||r.openfinUuid===void 0?{}:{[e.yn]:r.openfinUuid},...!t.metadata.openfin||r.openfinName===void 0?{}:{[e.vn]:r.openfinName}},this.resourceCache}},Ze=1e3,Qe={start:`ui.start`,interaction:`ui.interaction`,navigation:`ui.navigation`,explicit:`ui.trace`,maxAge:`ui.trace`};function R(e){return`${String(Math.round(e*Ze))}000`}function $e(e){return{name:Qe[e.reason],kind:`internal`,traceId:e.traceId,spanId:e.spanId,parentSpanId:``,startMs:e.startedAt,endMs:e.endedAt,error:!1,attributes:{}}}function et(t){return{[e.Hn.kind]:t.kind,[e.Hn.parentId]:t.parentSpanId,[e.Hn.start]:R(t.startMs),[e.Hn.end]:R(t.endMs),[e.Hn.status]:t.error?`error`:`unset`,...t.link?{[e.Hn.linkTraceId]:t.link.traceId,[e.Hn.linkSpanId]:t.link.spanId}:{}}}var tt={errors:async()=>(await Promise.resolve().then(()=>require("./errors-CNPbesMs.cjs"))).ErrorCapture,network:async()=>(await Promise.resolve().then(()=>require("./network-CGMLQ-mA.cjs"))).NetworkCapture,interactions:async()=>(await Promise.resolve().then(()=>require("./interactions-CUkzK8sR.cjs"))).InteractionCapture,webVitals:async()=>(await Promise.resolve().then(()=>require("./web-vitals-__X7t4pj.cjs"))).WebVitalsCapture,longFrames:async()=>(await Promise.resolve().then(()=>require("./long-frames-BUUbXd-B.cjs"))).LongFrameCapture,console:async()=>(await Promise.resolve().then(()=>require("./console-CSZ5_Vx5.cjs"))).ConsoleCapture,uncleanExit:async()=>(await Promise.resolve().then(()=>require("./unclean-exit-py99ApzT.cjs"))).UncleanExitCapture,userTiming:async()=>(await Promise.resolve().then(()=>require("./user-timing-D6XTmpuM.cjs"))).UserTimingCapture,reports:async()=>(await Promise.resolve().then(()=>require("./reports-BDSe4dFH.cjs"))).ReportCapture,resourceTiming:async()=>(await Promise.resolve().then(()=>require("./resource-timing-C576gFIQ.cjs"))).ResourceTimingCapture,lifecycle:async()=>(await Promise.resolve().then(()=>require("./lifecycle-IaAm1mOC.cjs"))).LifecycleCapture,framePhases:async()=>(await Promise.resolve().then(()=>require("./profiler-frames-C4xr7KfH.cjs"))).FramePhasesCapture,framePacing:async()=>(await Promise.resolve().then(()=>require("./profiler-frames-C4xr7KfH.cjs"))).FramePacingCapture,replay:async()=>(await Promise.resolve().then(()=>require("./replay-B3gFXIZd.cjs"))).ReplayCapture},z=new WeakMap,nt=0;function B(e){let t=z.get(e);return t===void 0&&(t=++nt,z.set(e,t)),t}var V=Symbol.for(e.Mn),H=Symbol.for(e.Nn),rt=[`batching`,`retention`],it=[`log`,`event`,`action`],at=`configure() could not read its options. The library drops each record and installs no capture until a configure() call sets redact to a function or null.`,ot=`shutdown() got invalid options. The library discards the records in memory. An invalid clearStorage removes the "context" scope.`,st=`flush() got invalid options. The library waits the default 5000 ms.`,ct=new Set([`bus.role_resolved`,`config.reconfigured`,`security.rotated`,`journey.adopted`,`journey.expired`]);function lt(e){return JSON.stringify({...e,urlTransform:e.urlTransform?B(e.urlTransform):void 0,webVitals:typeof e.webVitals==`object`?{loader:e.webVitals.loader!==void 0}:e.webVitals,ignoreUrls:e.ignoreUrls.map(String),propagateTraceHeaderTo:e.propagateTraceHeaderTo.map(String),userTiming:typeof e.userTiming==`object`?{include:e.userTiming.include?.map(String)}:e.userTiming,plugins:e.plugins.map(B)})}function ut(e){if(!r.n(e))return e;let t={...e};for(let e of[`url`,`endpoint`]){let n=t[e];typeof n==`string`&&(t[e]=a.i(n,!1))}return t}function dt(e){return{...e,endpoint:null,metricsEndpoint:null,tracesEndpoint:null,transport:null,transportOnExit:null,transportWorker:null,bus:{...e.bus,mode:`off`}}}function ft(e){return!!e.endpoint||!!e.metricsEndpoint||!!e.tracesEndpoint||!!e.transport||!!e.transportWorker}function U(e,t){return{status:e,accepted:0,stored:0,dropped:0,forwarded:0,pending:0,...t}}function W(e){return U(e.pending>0?`timeout`:`complete`,e)}function G(t){return t.sdkVersion===e.er}var K=class n{isRotating(){return this.rotating}setConfigurationLocked(e){typeof e==`boolean`&&(this.config.lockConfiguration=e)}constructor(t,n){o.t(this,`rotating`,!1),o.t(this,`rotationSeq`,0),o.t(this,`profilerOn`,!1),o.t(this,`closingContext`,!1),o.t(this,`mismatchVersion`,null),o.t(this,`contextMismatch`,!1),o.t(this,`rotation`,void 0),o.t(this,`memoryStorage`,void 0),o.t(this,`storagePersistence`,`off`),o.t(this,`recordingDiagnostic`,!1),o.t(this,`diagnosticLogger`,new E(()=>this,e.J)),o.t(this,`debugBuffer`,new Ne(()=>this.config.debugBuffer)),o.t(this,`explicitSecurityContext`,void 0),o.t(this,`ownerAdopted`,!1),o.t(this,`sdkVersion`,e.er),o.t(this,`protocol`,e.M),o.t(this,`diagnostics`,void 0),o.t(this,`config`,void 0),o.t(this,`platform`,void 0),o.t(this,`identity`,void 0),o.t(this,`backing`,s.r()),o.t(this,`stores`,{local:()=>this.backing.local(),session:()=>this.backing.session()}),o.t(this,`identityBuiltAs`,void 0),o.t(this,`sessionTouch`,void 0),o.t(this,`context`,new Me),o.t(this,`breadcrumbs`,void 0),o.t(this,`tracing`,void 0),o.t(this,`sequence`,new Ae),o.t(this,`journey`,void 0),o.t(this,`builder`,void 0),o.t(this,`remote`,{sampling:null,changed:()=>{this.refreshCaptures()}}),o.t(this,`identityEpoch`,0),o.t(this,`errorHook`,void 0),o.t(this,`replayConsent`,void 0),o.t(this,`replay`,void 0),o.t(this,`remoteCaptureTimer`,void 0),o.t(this,`installedCaptureKey`,``),o.t(this,`replayBuiltKey`,``),o.t(this,`console`,void 0),o.t(this,`drops`,void 0),o.t(this,`meter`,void 0),o.t(this,`bus`,null),o.t(this,`busBuilt`,void 0),o.t(this,`busLoad`,void 0),o.t(this,`sender`,void 0),o.t(this,`senderLoad`,void 0),o.t(this,`pendingRecords`,new Fe(e=>{this.dropHeld(e)})),o.t(this,`pausedLoss`,new WeakSet),o.t(this,`carried`,[]),o.t(this,`sessionPicked`,!1),o.t(this,`deliveryClosed`,!1),o.t(this,`parkedSender`,void 0),o.t(this,`retiring`,void 0),o.t(this,`startFailed`,!1),o.t(this,`running`,!1),o.t(this,`openGate`,void 0),o.t(this,`startGate`,new Promise(e=>{this.openGate=e})),o.t(this,`captures`,[]),o.t(this,`captureGeneration`,0),o.t(this,`captureOnce`,{webVitals:!1,navigationTiming:!1,longFrames:!1,uncleanExit:!1,userTiming:!1}),o.t(this,`bootBuffer`,new Fe(e=>{this.dropHeld(e)})),o.t(this,`forwardBuffer`,[]),o.t(this,`forwardScheduled`,!1),o.t(this,`roleResolved`,!1),o.t(this,`started`,Promise.resolve()),o.t(this,`ready`,!1),o.t(this,`destroyed`,!1),o.t(this,`stopping`,void 0),o.t(this,`lastSendAt`,null),o.t(this,`lastGapAt`,0),o.t(this,`limits`,void 0),o.t(this,`journeyOptions`,void 0),o.t(this,`tunablesLocked`,!1),o.t(this,`degraded`,void 0),o.t(this,`serverReported`,!1),o.t(this,`onPageHide`,()=>{x(this),this.dropPaused(),this.role()===`forwarder`&&(this.tracing.end(),this.sendForwarded())}),o.t(this,`busCanAccept`,(e,t)=>this.bus?.isRegistered(e,t)??!1),o.t(this,`busAccept`,(e,t,n)=>{this.destroyed||this.ensureBus().then(r=>{r&&!this.destroyed&&this.diagnostics.guard(`bus.send_failed`,`The bus could not accept a direct message from a child frame.`,()=>{r.acceptDirect(e,t,n)})})}),o.t(this,`reportLoss`,(e,t,n,r)=>{this.drops.add(e,t,n,r)}),o.t(this,`reportGap`,(t,n)=>{this.drops.add(t.reason,n.flatMap(e=>e.records),n.map(e=>e.id));let r=Date.now();r-this.lastGapAt<6e4||(this.lastGapAt=r,new E(()=>this,e.Gn).warn(`stored records were dropped before delivery`,{"gap.batches":t.batches,"gap.records":t.records,"gap.reason":t.reason}))}),this.diagnostics=new A(typeof t.onDiagnostic==`function`?t.onDiagnostic:void 0),this.platform=a.n(this.diagnostics),this.degraded=n||this.onServer(),this.config=f.r(this.allowed(t),this.diagnostics),this.explicitSecurityContext=!!t.securityContext?.id,this.config.securityContext.id||=s.i(this.diagnostics),this.diagnostics.setPolicy(this.config.diagnostics.throttleMs,this.config.diagnostics.consoleFallback),this.identityBuiltAs=this.config.identity,this.identity=s.s(this.diagnostics,this.stores,this.config.correlation.sessionIdleMs),this.sessionTouch=new s.n(this.diagnostics,this.stores,this.config.correlation.sessionIdleMs),this.breadcrumbs=new je(this.config.captureLimits.breadcrumbs);let r=e=>h.i(e,this.config.sampling.defaultRate);this.tracing=new de(this.diagnostics,this.config.correlation.traceMaxAgeMs??1/0,this.config.otelLoader,{enabled:()=>this.config.tracesEndpoint!==null,keeps:r,onEnd:e=>{r(e.traceId)&&this.recordSpan($e(e))}}),this.limits={...this.config.limits},this.console=new ke(this.config.consoleOutput,this.diagnostics,this.limits),this.drops=new Pe(this.config,this.diagnostics),this.journeyOptions={...m.t,maxAgeMs:this.config.journey.maxAgeMs},this.journey=new m.n(this.journeyOptions,this.diagnostics,this.identity.contextId,e=>{this.bus?.broadcastJourney(e)},this.stores),this.builder=new Xe({remote:this.remote,config:this.config,limits:this.limits,diagnostics:this.diagnostics,context:this.context,journey:this.journey,tracing:this.tracing,sequence:this.sequence,identity:this.identity,platform:this.platform,debug:this.debugBuffer}),this.meter=new De(()=>this.config.metrics.intervalMs,(e,t,n)=>{this.emitPoint(e,t,n)},this.diagnostics,this.config.metrics),this.diagnostics.setHandler(this.diagnosticHandler()),this.syncProfiler()}diagnosticHandler(){return this.config.diagnostics.records===!1?this.config.onDiagnostic:e=>{this.recordDiagnostic(e),this.config.onDiagnostic?.(e)}}recordDiagnostic(e){let{records:t}=this.config.diagnostics;if((t===!0||t!==!1&&t.includes(e.code))&&!this.recordingDiagnostic){this.recordingDiagnostic=!0;try{(ct.has(e.code)?this.diagnosticLogger.info:this.diagnosticLogger.warn)(e.message,{"diagnostic.code":e.code,"diagnostic.count":e.count,"diagnostic.detail":ut(e.detail)})}finally{this.recordingDiagnostic=!1}}}addBreadcrumb(e,t){this.rotating||this.destroyed||this.diagnostics.guard(`record.sanitize_failed`,`The library could not add the breadcrumb.`,()=>{let n={t:Date.now(),category:`custom`,message:u.i(String(e),this.limits.maxBodyChars)};if(t!==void 0){let e=u.n(t,this.limits,this.diagnostics);n.data=r.n(e)?e:{value:e}}this.breadcrumbs.push(n)})}recordMetric(e,t,n){!this.destroyed&&!this.rotating&&this.config.enabled&&this.meter.record(e,t,n)}startMeasure(e,t){let n=this.identityEpoch,r=()=>!this.destroyed&&!this.rotating&&(!this.config.securityContext.isolation||this.identityEpoch===n),i=this.diagnostics.guard(`record.sanitize_failed`,`The library could not read the attributes of the measure.`,()=>({...t}));return me(this.diagnostics.guard(`record.sanitize_failed`,`The library could not read the name of the measure.`,()=>`${e}`)??``,i??{},this.tracing.request().span,{metric:(e,t,n)=>{r()&&this.recordMetric(e,t,n)},span:e=>{r()&&this.recordSpan(e)}})}recordSpan(t){if(this.config.tracesEndpoint===null)return;let{record:n}=this.builder.build({level:`INFO`,type:`span`,body:t.name,namespace:e.rr,payload:t.attributes,fixed:et(t),trace:{traceId:t.traceId,spanId:t.spanId,traceFlags:1}});this.emit(n)}emitPoint(t,n,r){if(this.destroyed)return;let{record:i}=this.builder.build({level:`INFO`,type:`metric`,body:t,namespace:e.Bt,payload:n,fixed:r,aggregated:!0});this.emit(i)}syncProfiler(){let e=this.config.profiler.enabled&&this.config.enabled;if(e===this.profilerOn)return;this.profilerOn=e;let t=c.t();if(!e){t.collect(!1),t.detach();return}let n={capacity:this.config.profiler.maxProbes,intervalMs:()=>this.config.metrics.intervalMs,emit:(e,t,n)=>{this.emitPoint(e,t,n)},diagnostics:this.diagnostics,ready:()=>!this.rotating||this.closingContext,outlier:(e,t)=>{this.breadcrumbs.push({t:Date.now(),category:`profile`,message:`${e} ${String(Math.round(t))} ms`})}};t.attach(n)}setReplay(e){this.replayConsent=e,e?this.replay?.start():this.replay?.stop()}collectPoints(){this.meter.collect(),this.profilerOn&&c.t().collect(!1)}advanceIdentity(){this.identityEpoch++,this.profilerOn&&this.config.securityContext.isolation&&c.t().reset(),this.remote.sampling=null,this.refreshCaptures()}static pinned(){return globalThis[V]??null}static current(){let e=n.local;if(e)return e.destroyed?null:e;let t=n.pinned();return t&&G(t)?t:null}static stopped(){let e=n.local;if(e?.destroyed)return e;let t=globalThis[H];return t&&G(t)?t:null}isDestroyed(){return this.destroyed}static configure(e,t=!1){try{return n.startOrUpdate(e,t)}catch(e){let t=n.current();if(t?.tunablesLocked)return t.diagnostics.report(`config.invalid`,`configure() could not read its options. The library keeps the current settings.`,void 0,e),t;let r=t??n.startOrUpdate({},!0);return r.refuse(e),r}}refuse(t){this.startFailed=!0;let n=f.r({redact:f.t},new A,this.config);f.n(this.config,n),l.n(()=>{console.warn(`${e.jt} ${at}`)}),this.diagnostics.report(`config.invalid`,at,void 0,t),this.rehookHeld()}static startOrUpdate(e,t){let r=n.local;if(r&&!r.destroyed)return r.reconfigure(e),r;n.local=null;let i=n.pinned();if(i){if(!G(i))return n.startDegraded(e,i.sdkVersion,t);if(!i.destroyed)return i.reconfigure(e),i}let a=new n(e,!1);return globalThis[V]=a,Reflect.deleteProperty(globalThis,H),t||a.launch(),a}static startDegraded(t,r,i){let a=new n(t,!0);n.local=a;let o=typeof r==`string`?r:`before 0.9.0`;return a.mismatchVersion=o,a.diagnostics.report(`runtime.version_mismatch`,`Another copy of the library, version ${o}, owns the page runtime. This copy, version ${e.er}, runs in console-only mode and installs no capture. Load one version of the library on the page.`,{found:o,own:e.er}),i||a.launch(),a}reconfigure(e){if(this.rotating){this.diagnostics.report(`config.locked`,`Configuration cannot change during security-context rotation.`);return}if(this.config.lockConfiguration){let t=f.r(e,this.diagnostics,this.config);q(this.config,t)||this.diagnostics.report(`config.locked`,`Runtime configuration is locked. Use setConfigurationLocked(false) to unlock it explicitly.`);return}x(this);let t=this.keepDestination(this.keepRouting(this.allowed(e)));!this.tunablesLocked&&t.securityContext?.id&&(this.explicitSecurityContext=!0);let n=f.r(t,this.diagnostics,this.config),r=this.tunablesLocked?[`correlation`,`storage`]:[];for(let e of r)q(n[e],this.config[e])||(this.diagnostics.report(`config.invalid`,`${e} cannot change after startup. The library keeps the current settings.`),Object.assign(n,{[e]:this.config[e]}));this.keepStartupTunables(n);let{redact:i,processors:a,enabled:o}=this.config;o&&!n.enabled&&this.collectPoints(),f.n(this.config,n),this.config.redact!==f.t&&(this.startFailed=!1),(this.config.redact!==i||this.config.processors!==a)&&this.debugBuffer.clear(),this.breadcrumbs.resize(this.config.captureLimits.breadcrumbs),this.diagnostics.setHandler(this.diagnosticHandler()),this.diagnostics.setPolicy(this.config.diagnostics.throttleMs,this.config.diagnostics.consoleFallback),this.builder.invalidateResource(),this.console.update(this.config.consoleOutput),this.keepBuiltIdentity(),this.syncProfiler(),this.launch(),this.running&&o!==this.config.enabled&&this.sender?.hold(!this.config.enabled),this.refreshCaptures(),this.roleResolved&&this.syncSender(),this.diagnostics.report(`config.reconfigured`,`A later configure() call updated the runtime.`)}onServer(){return this.platform.platform===`node`}allowed(e){return this.degraded?(this.onServer()&&!this.serverReported&&ft(e)&&(this.serverReported=!0,this.diagnostics.report(`config.invalid`,`The library runs console-only on Node. It sends no record and installs no capture. It ignores endpoint, metricsEndpoint, tracesEndpoint, transport and transportWorker.`)),dt(e)):e}keepRouting(t){if(!this.tunablesLocked||this.degraded||!this.config.securityContext.isolation)return t;let n=f.r(t,new A,this.config),r=e.An.filter(e=>!q(n[e],this.config[e]));if(n.securityContext.id!==this.config.securityContext.id&&r.push(`securityContext.id`),r.length===0)return t;let i={...t};for(let t of e.An)r.includes(t)&&Reflect.deleteProperty(i,t);if(r.includes(`securityContext.id`)){let e={...t.securityContext};Reflect.deleteProperty(e,`id`),i.securityContext=e}return this.diagnostics.report(`config.invalid`,`Isolation refuses changes to ${r.join(`, `)}. Use rotateSecurityContext() for these changes. To permit them, set securityContext.isolation: false in a separate configure() call. The other settings apply.`),i}keepStartupTunables(e){if(this.senderLoad!==void 0&&this.keepSections(e,rt),!this.tunablesLocked){Object.assign(this.limits,e.limits),this.journeyOptions.maxAgeMs=e.journey.maxAgeMs;return}this.keepSections(e,[`limits`]);for(let t of[`mode`,`openFinRole`])e.bus[t]!==this.config.bus[t]&&(this.diagnostics.report(`config.invalid`,`bus.${t} cannot change after startup. The library keeps "${this.config.bus[t]}".`,{requested:e.bus[t]}),Object.assign(e.bus,{[t]:this.config.bus[t]}));let{maxAgeMs:t}=this.config.journey;e.journey.maxAgeMs!==t&&(this.diagnostics.report(`config.invalid`,`journey.maxAgeMs cannot change after startup. It stays ${String(t)}.`,{requested:e.journey.maxAgeMs}),e.journey.maxAgeMs=t);let{maxProbes:n}=this.config.profiler;e.profiler.maxProbes!==n&&(this.diagnostics.report(`config.invalid`,`profiler.maxProbes cannot change after startup. It stays ${String(n)}.`,{requested:e.profiler.maxProbes}),e.profiler.maxProbes=n)}keepSections(e,t){for(let n of t)q(e[n],this.config[n])||(this.diagnostics.report(`config.invalid`,`${n} cannot change after startup. The current values stay.`,{requested:e[n]}),Object.assign(e,{[n]:this.config[n]}))}keepDestination(e){if(this.senderLoad===void 0)return e;let t=e;for(let n of[`transport`,`transportWorker`]){let r=e[n],i=typeof r==`function`&&this.config[n]===void 0,a=r===null&&this.config[n]!==void 0;(i||a)&&(this.diagnostics.report(`config.invalid`,`You cannot add or remove ${n} after the delivery stack loads. The current transport stays.`),t={...t},Reflect.deleteProperty(t,n))}return(t.endpoint===null||t.endpoint===``)&&this.config.transport===void 0&&(this.diagnostics.report(`config.invalid`,`You cannot remove the endpoint after the delivery stack loads. The current endpoint stays.`),t={...t,endpoint:void 0}),t}keepBuiltIdentity(){if(!this.tunablesLocked){this.identityBuiltAs=this.config.identity;return}let e=this.identityBuiltAs;this.config.identity!==e&&(this.diagnostics.report(`config.invalid`,`identity cannot change after startup. It stays ${e}.`,{requested:this.config.identity}),this.config.identity=e)}launch(){this.startFailed||(this.tunablesLocked||(this.tunablesLocked=!0,this.config.enabled||this.drops.add(`disabled`,this.rehookHeld())),!this.running&&this.config.enabled&&this.start())}start(){this.running=!0,this.identityBuiltAs===`storage`&&!this.onServer()&&(this.backing=s.t);let{sessionIdleMs:e,traceMaxAgeMs:t}=this.config.correlation,{sessionId:n,tabId:r}=s.s(this.diagnostics,this.stores,e);this.sessionTouch=new s.n(this.diagnostics,this.stores,e),this.sessionPicked?this.sessionTouch.restart(this.identity.sessionId):this.identity.sessionId=n,this.identity.tabId=r,this.builder.invalidateResource(),this.breadcrumbs.retain(e=>!it.includes(e.category)),this.tracing.setup(t??1/0,this.config.otelLoader),this.tracing.loadOtel();for(let e of this.rehookHeld())this.bootBuffer.push(e,this.config.buffering.maxHeldRecords);this.openGate(),this.init()}rehookHeld(){return this.bootBuffer.take().map(e=>this.builder.rehook(e)).filter(e=>e!==null)}async init(){this.degraded||addEventListener(`pagehide`,this.onPageHide);let e=this.installCaptures();this.started=this.boot(),await this.started,await e}async boot(){try{let e=this.journey.bootstrap();this.config.bus.mode!==`off`&&await this.ensureBus(),this.roleResolved=!0,await this.syncSender(),await e}catch(e){this.diagnostics.report(`pipeline.crashed`,`Startup failed. The runtime continues with reduced function.`,void 0,e)}finally{this.ready=!0,this.releaseBootBuffer()}}ensureBus(){return this.busLoad??=this.startBus(),this.busLoad}constructBus(){return this.busBuilt??=this.buildBus(),this.busBuilt}async startBus(){let e=await this.constructBus();if(!e)return null;try{return await e.start(),e}catch(e){return this.diagnostics.report(`pipeline.crashed`,`The bus did not start. This context sends its own records.`,void 0,e),null}}async buildBus(){try{await this.startGate;let{Bus:e}=await Promise.resolve().then(()=>require("./bus-_EaOVPGq.cjs"));if(this.destroyed)return null;let t=new e(this.config,this.diagnostics,this.platform,this.identity.contextId,this.identity.tabId,{onSecurityContext:e=>{if(this.explicitSecurityContext&&this.config.securityContext.id!==e)return this.contextMismatch=!0,this.diagnostics.report(`security.context_mismatch`,`The configured security context differs from the upstream owner.`),!1;if(this.contextMismatch=!1,this.config.securityContext.id!==e){if(this.ownerAdopted){x(this),this.drops.add(`security_context`,[...this.bootBuffer.take(),...this.pendingRecords.take(),...this.forwardBuffer]),this.forwardBuffer=[],this.context.clear(),this.breadcrumbs.clear();let e=this.rotating;this.rotating=!0,this.collectPoints(),this.profilerOn&&c.t().reset();let t=this.sessionTouch.stored();this.resetSession(t!==void 0&&t!==this.identity.sessionId?t:s.i(this.diagnostics)),this.rotating=e,this.advanceIdentity()}this.config.securityContext.id=e}return this.ownerAdopted=!0,!0},onRecords:e=>{this.ingestForwarded(e)},paused:()=>!this.config.enabled,onJourney:e=>{this.journey.applyRemote(e)},onJourneyRequest:()=>this.journey.current(),onTabConflict:()=>{this.regenerateTabId()},onFlush:e=>this.flushFor(e,!1),remote:this.remote});return this.bus=t,t}catch(e){return this.diagnostics.report(`pipeline.crashed`,`The bus did not load. This context sends its own records.`,void 0,e),null}}role(){return this.bus?.getRole()??`sender`}syncSender(){return!this.running||!this.config.enabled||this.deliveryClosed||this.destroyed||!this.hasDestination()||this.role()!==`sender`?Promise.resolve():this.loadSender()}hasDestination(){return!!this.config.endpoint||this.config.transport!==void 0}loadSender(){return this.senderLoad??=this.buildSender(),this.senderLoad}async buildSender(){try{let{Sender:e}=await Promise.resolve().then(()=>require("./sender-BdRuNVhF.cjs")),t=this.destroyed?null:await e.create({storage:this.memoryStorage,onStorage:e=>{e.name===`memory`&&(this.memoryStorage=e)},onPersistence:e=>{this.storagePersistence=e},config:this.config,diagnostics:this.diagnostics,onGap:this.reportGap,onLoss:this.reportLoss,remote:this.remote,beforeExit:()=>{x(this),this.collectPoints(),this.tracing.end()},onSent:e=>{this.lastSendAt=e}});if(!t||this.destroyed){await t?.discard();return}if(this.deliveryClosed){await this.parkSender(t);return}this.sender=t,this.config.enabled||t.hold(!0)}catch(e){this.senderLoad=void 0,this.diagnostics.report(`pipeline.crashed`,`The delivery stack did not load. The library does not send records.`,{held:this.pendingRecords.length},e),this.drops.add(`load_failed`,this.pendingRecords.records)}for(let e of this.pendingRecords.take())this.sender?.push(e);let e=this.carried;this.carried=[],this.sender&&e.length>0&&await this.adoptStored(this.sender,e)}async adoptStored(e,t){await this.diagnostics.guardAsync(`storage.degraded`,`The library could not store the carried batches under the new context.`,()=>e.adopt(t,this.config.securityContext.id))}refreshCaptures(){if(clearTimeout(this.remoteCaptureTimer),this.remoteCaptureTimer=void 0,this.destroyed)return;let e=this.remote.sampling?.wire();e&&(this.remoteCaptureTimer=setTimeout(()=>{this.refreshCaptures()},e.ttlMs),i.t(this.remoteCaptureTimer)),this.captureState(this.effectiveCapture())!==this.installedCaptureKey&&this.installCaptures()}captureState(e){let{enabled:t,framePhases:n,framePacing:r}=this.config.profiler;return`${String(this.config.enabled)}${lt(e)}${String(t&&n)}${String(t&&r)}${this.replayState(e)}`}replayState(e){let{replay:t}=this.config;return t.enabled?JSON.stringify([t.loader&&B(t.loader),t.onSegment&&B(t.onSegment),B(t.recordOptions),t.endpoint,t.requireConsent,t.mode,t.maskText,t.maskInputs,t.maskSelectors,t.blockSelectors,t.recordCanvas,t.bufferMs,t.plugins.map(B),e.fullUrls,e.ignoreUrls.map(String)]):``}effectiveCapture(){let t={...this.config.capture},n=this.remote.sampling?.current()?.capture;for(let r of e.sn){let e=n?.[r];if(t.remoteToggles.includes(r)&&e!==void 0){if(e&&typeof t[r]==`object`)continue;t[r]=e}}return t}async installCaptures(){if(this.degraded||!this.running)return;let t=++this.captureGeneration,n=this.effectiveCapture();if(this.installedCaptureKey=this.captureState(n),!this.config.enabled){this.uninstallCaptures();return}let r=this.replayState(n);r!==this.replayBuiltKey&&(this.replayBuiltKey=``);let i=r!==``&&r===this.replayBuiltKey?this.replay:void 0,a=[],{profiler:o}=this.config;(n.errors||n.rejections||n.resourceErrors)&&a.push(`errors`),(n.fetch||n.xhr)&&a.push(`network`),(n.interactions||n.navigation)&&a.push(`interactions`),n.webVitals&&a.push(`webVitals`),n.longFrames&&a.push(`longFrames`),(typeof n.console==`object`?n.console.levels?.length!==0:n.console)&&a.push(`console`),n.uncleanExit&&a.push(`uncleanExit`),n.userTiming&&a.push(`userTiming`),n.reports&&a.push(`reports`),n.resourceTiming&&a.push(`resourceTiming`),n.lifecycle&&a.push(`lifecycle`),o.enabled&&o.framePhases&&a.push(`framePhases`),o.enabled&&o.framePacing&&a.push(`framePacing`),this.config.replay.enabled&&!i&&a.push(`replay`);let[s,c]=await Promise.all([Promise.all(a.map(e=>this.loadCapture(e))),n.webSocket?this.loadWebSocket():void 0]);if(t!==this.captureGeneration||this.destroyed)return;this.uninstallCaptures(i);let l={isActive:()=>!this.destroyed&&!this.rotating,config:Object.assign(Object.create(this.config),{capture:n}),diagnostics:this.diagnostics,breadcrumbs:this.breadcrumbs,tracing:this.tracing,logger:new ie(()=>this,e.P),once:this.captureOnce,recordMetric:(e,t,n)=>{this.recordMetric(e,t,n)},recordSpan:e=>{this.recordSpan(e)},sessionId:()=>this.identity.sessionId,onError:e=>{this.errorHook=e},setContext:(e,t)=>{this.context.merge({[e]:t??null})},replayConsent:()=>this.replayConsent};s.forEach((e,t)=>{if(e){let n=new e(l);this.captures.push(n),a[t]===`replay`&&(this.replay=n,this.replayBuiltKey=r)}});let u=c?[...n.plugins,new c(this.diagnostics,l.config)]:n.plugins;for(let e of u)this.captures.push(this.pluginCapture(e));for(let e of this.captures)this.diagnostics.guard(`capture.install_failed`,`The library could not install the ${e.name} capture.`,()=>{e.install()})}uninstallCaptures(e){for(let t of this.captures)t!==e&&this.diagnostics.guard(`capture.install_failed`,`The library could not uninstall the ${t.name} capture.`,()=>{t.uninstall()});this.captures.length=0,this.replay=e,e&&this.captures.push(e)}loadWebSocket(){return this.diagnostics.guardAsync(`capture.install_failed`,`The library could not load the webSocket capture.`,async()=>(await Promise.resolve().then(()=>require("./web-socket-CoIUBM3C.cjs"))).WebSocketCapture)}pluginCapture(t){let{name:n}=t,r=(e,t,n)=>{this.recordMetric(e,t,n)},i=t=>{this.diagnostics.report(`config.invalid`,e.xt,void 0,t)},a={logger:new E(()=>this,`${e.P}.${n}`),counter:(e,t={})=>we(e,t,r,i),histogram:(e,t={})=>Ee(e,t,r,i),addBreadcrumb:(e,t)=>{this.addBreadcrumb(e,t)},ownRequest:d.r};return{name:n,install:()=>{t.install(a)},uninstall:()=>{t.uninstall()}}}loadCapture(e){return this.diagnostics.guardAsync(`capture.install_failed`,`The library could not load the ${e} capture.`,tt[e])}registerWorker(e,t={}){let n=!1,r;return this.destroyed?()=>void 0:(this.constructBus().then(i=>{!i||this.destroyed||n||(this.diagnostics.guard(`bus.send_failed`,`The library could not register the worker.`,()=>{r=i.attachWorker(e,t)}),this.ensureBus())}),()=>{n=!0,r?.()})}registerFrame(e,t){let n=!1,r;return this.constructBus().then(i=>{!i||this.destroyed||n||(r=this.diagnostics.guard(`bus.send_failed`,`The frame could not be registered.`,()=>i.registerFrame(e,t)),this.ensureBus())}),()=>{n=!0,r?.()}}async destroy(e){let{discard:t,scope:n}=this.shutdownRule(e);this.stopping??=this.stop(t),await this.stopping,n!==void 0&&await this.clearStorage(n)}async stop(e){e||(x(this),this.collectPoints(),this.tracing.end()),this.profilerOn&&(this.profilerOn=!1,c.t().detach()),this.destroyed=!0,this.backing=s.r(),S(this),this.collectPoints(),clearTimeout(this.remoteCaptureTimer),this.remoteCaptureTimer=void 0,this.degraded||removeEventListener(`pagehide`,this.onPageHide),this.uninstallCaptures();let t=e?this.discardHeld():this.flushHeld();this.journey.destroy(),this.bus?.destroy(),await t,await this.senderLoad,await this.rotation?.catch(()=>void 0);let r=this.parkedSender;this.parkedSender=void 0,await this.diagnostics.guardAsync(`pipeline.crashed`,`The delivery stack of the old context did not stop at shutdown. The library leaves its stored batches in storage.`,async()=>{await(e?r?.discard():r?.retire(`retain`,0,this.config.securityContext.id))}),await this.memoryStorage?.close(),n.pinned()===this&&(Reflect.deleteProperty(globalThis,V),globalThis[H]=this)}shutdownRule(e){let t=this.readOptions(e,ot);if(t===void 0)return{discard:!0};let{pending:n,clearStorage:r}=t,i=r==null,a=i||r===`context`||r===`namespace`,o;i||(o=r===`namespace`?`namespace`:`context`);let s=n===void 0||n===`flush`;return(!a||!(s||n===`discard`)||n===`flush`&&o)&&this.diagnostics.report(`config.invalid`,ot),{discard:!s||o!==void 0,scope:o}}async flushHeld(){this.dropPaused();let e=this.sender?.destroy();this.sendForwarded(),this.drops.add(`load_failed`,this.unreported(this.pendingRecords.take())),await e}async discardHeld(){let e=[...this.bootBuffer.take(),...this.pendingRecords.take(),...this.forwardBuffer];this.forwardBuffer=[],this.breadcrumbs.clear(),this.debugBuffer.clear(),this.context.clear(),this.journey.applyRemote(null);let t=await this.sender?.discard()??[];this.drops.add(`discarded`,this.unreported([...e,...t]))}async clearStorage(e){this.tunablesLocked&&await this.diagnostics.guardAsync(`storage.degraded`,`The library could not remove the stored batches at shutdown.`,async()=>{let{clearStored:t}=await Promise.resolve().then(()=>require("./stored-context-CXt7eHZL.cjs")),n=this.carried.map(e=>e.id);this.carried=[],await t(this.storeAccess(),e,n,this.identityBuiltAs===`storage`&&!this.onServer())})}emit(e){if(!e||this.destroyed)return;if(this.rotating&&!this.closingContext){this.drops.add(`security_context`,[e]);return}this.sessionTouch.touch(this.identity.sessionId);let t=e.severityText===`ERROR`||e.severityText===`FATAL`,n=t?[...this.debugBuffer.drain(),e]:[e];t&&this.errorHook?.(e);for(let e of n)this.ready?this.route(e):this.bootBuffer.push(e,this.config.buffering.maxHeldRecords)}route(e){this.role()===`forwarder`?this.forward(e):this.deliver(e)}deliver(e){if(this.deliveryClosed){this.drops.add(`security_context`,[e]);return}if(this.sender){this.sender.push(e);return}let t=!this.config.enabled&&this.hasDestination();!this.senderLoad&&!t?(this.diagnostics.count(`record.dropped_no_destination`),this.hasDestination()&&this.drops.add(`load_failed`,[e])):this.pendingRecords.push(e,this.config.buffering.maxHeldRecords)}dropPaused(){if(this.config.enabled)return;let e=this.unreported([...this.pendingRecords.records,...this.sender?.records()??[]]);for(let t of e)this.pausedLoss.add(t);this.drops.add(`disabled`,e)}unreported(e){return e.filter(e=>!this.pausedLoss.has(e))}dropHeld(e){this.diagnostics.count(`record.dropped_boot_buffer_full`),this.drops.add(`buffer_full`,[e])}forward(e){this.forwardBuffer.push(e),this.forwardScheduled||(this.forwardScheduled=!0,queueMicrotask(()=>{this.forwardScheduled=!1,this.sendForwarded()}))}sendForwarded(){let e=this.forwardBuffer;this.forwardBuffer=[];let{bus:t}=this;return e.length===0||!t?0:t.sendRecords(e)}ingestForwarded(e){if(this.destroyed)return;if(!Array.isArray(e)){this.diagnostics.count(`record.dropped_malformed`);return}let n=[];for(let r of e){if(!t.n(r)){this.diagnostics.count(`record.dropped_malformed`);continue}if(r.attributes[`uiobs.debug_buffer`]!==!0&&!h.a(r,this.config,this.remote.sampling?.current()??null)){this.diagnostics.count(`record.dropped_by_sampling`);continue}let e=this.builder.redactForwarded(r);e&&n.push(e)}if(this.rotating)this.drops.add(`security_context`,n);else if(!this.config.enabled)this.drops.add(`disabled`,n);else for(let e of n)this.deliver(e)}releaseBootBuffer(){let e=this.bootBuffer.take(),{processors:t,redact:n}=this.config,r=t.length===0&&n===void 0?this.journey.current():null;for(let t of e)r&&!t.attributes[`journey.id`]&&(t.attributes[`journey.id`]=r.id,t.attributes[`journey.name`]=r.name),this.route(t)}regenerateTabId(){let e=s.i(this.diagnostics);this.diagnostics.report(`bus.role_resolved`,`Another context uses this tab id. A duplicated tab is the usual cause. The library makes a new tab id.`,{was:this.identity.tabId,now:e}),this.identity.tabId=e,s.a(e,this.diagnostics,this.stores),this.builder.invalidateResource()}newSession(){this.destroyed||(x(this),this.resetSession(s.i(this.diagnostics)))}resetSession(e){this.sessionPicked=!0,this.collectPoints(),this.tracing.rotate(`explicit`),this.journey.end(),this.breadcrumbs.clear(),this.debugBuffer.clear(),this.replay?.reset(),this.identity.sessionId=e,this.sessionTouch.restart(e),this.builder.invalidateResource()}rotateSecurityContext(e,t={}){if(this.destroyed)return Promise.reject(Error(`The runtime has stopped.`));if(!this.tunablesLocked)return Promise.reject(Error(`The runtime is not configured. Call configure() before rotateSecurityContext().`));x(this),this.rotating=!0;let n=++this.rotationSeq,r=(this.rotation??Promise.resolve()).catch(()=>void 0).then(()=>this.runRotation(e,t,n));this.rotation=r;let i=()=>{this.rotation===r&&(this.rotation=void 0,this.rotating=!1,this.retiring=void 0)};return r.then(i,i),r}async runRotation(e,t,n){if(this.destroyed)throw Error(`The runtime has stopped.`);if(await this.started,this.role()===`forwarder`)throw Error(`Rotate the security context on the upstream owner, or use bus.mode: sender for an independent identity.`);let r;try{r=(await Promise.resolve().then(()=>require("./rotation-D4qUAHAu.cjs"))).rotateContext}catch(e){throw this.diagnostics.report(`pipeline.crashed`,`The library could not load the security-context rotation.`,void 0,e),await this.closeDelivery(),e}if(this.isDestroyed())throw Error(`The runtime has stopped.`);await r(this.rotationHost(),e,t,n)}rotationHost(){return{runtime:this,quiet:new A,senderLoaded:async()=>{await this.senderLoad},allowed:e=>this.allowed(e),closeDelivery:()=>this.closeDelivery(),closeContext:()=>{this.closingContext=!0;try{this.collectPoints(),this.tracing.end(),this.journey.end()}finally{this.closingContext=!1}},takeOld:()=>{let e=[...this.bootBuffer.take(),...this.pendingRecords.take(),...this.forwardBuffer],t=this.sender??this.parkedSender;this.retiring=t;let n=this.carried;return this.forwardBuffer=[],this.carried=[],this.sender=void 0,this.senderLoad=void 0,this.parkedSender=void 0,{held:e,sender:t,closed:this.deliveryClosed,carried:n}},drop:e=>{this.drops.add(`security_context`,this.unreported(e))},storeAccess:()=>this.storeAccess(),advanceIdentity:()=>{this.advanceIdentity()},openDelivery:async()=>{this.deliveryClosed=!1,await this.syncSender(),this.bus?.rotateContext()},endRotation:e=>{this.rotating=e!==this.rotationSeq},route:e=>{this.route(e)},adopt:async e=>{this.config.enabled?await this.sender?.adopt(e,this.config.securityContext.id):this.carried=[...e]}}}async closeDelivery(){this.deliveryClosed=!0,this.diagnostics.report(`security.rotation_failed`,`The security-context rotation failed. The library sends no record until a rotation succeeds.`),await this.senderLoad;let e=this.sender;this.sender=void 0,this.senderLoad=void 0,e&&await this.parkSender(e),this.drops.add(`security_context`,this.unreported(this.pendingRecords.take()))}async parkSender(e){this.parkedSender=e,await this.diagnostics.guardAsync(`pipeline.crashed`,`The delivery stack of the old context did not stop. The next rotation that succeeds retires it.`,()=>e.pause(this.config.securityContext.id))}async debugBundle(t){let{configSummary:n}=await Promise.resolve().then(()=>require("./debug-bundle-BXIlwDKM.cjs")),{record:r}=this.builder.build({level:`INFO`,type:`system`,body:`debug bundle`,namespace:e.J,payload:{[e.c]:this.breadcrumbs.snapshot()}},!0),i=r?.attributes??{},a=i[e.c],o=i[e.v];return{createdAt:new Date().toISOString(),sdkVersion:this.sdkVersion,health:t,diagnostics:this.diagnostics.snapshot(),resource:r?.resource??{},pageUrl:typeof o==`string`?o:``,breadcrumbs:Array.isArray(a)?a:[],debugBuffer:this.debugBuffer.snapshot(),config:n(this.config,this.limits,this.diagnostics)}}async health(){let e=this.sender?.stats(),t=[];this.mismatchVersion&&t.push(`runtime.version_mismatch`),this.contextMismatch&&t.push(`security.context_mismatch`);let{redact:n,processors:r}=this.config;(n===f.t||r.includes(f.t))&&t.push(`records.refused`),this.deliveryClosed?t.push(`security.rotation_failed`):this.ready&&this.config.enabled&&this.hasDestination()&&this.role()===`sender`&&!this.sender&&t.push(`sender.unavailable`);let{sourcePolicy:i,maxMessageBytes:a,maxRecordsPerMessage:o,maxMessagesPerSecond:s}=this.config.bus;return{delivery:{pending:(e?.pending??0)+this.heldRecords(),inFlight:e?.inFlight??0,stored:await this.storedBatches(),lastSendAt:this.lastSendAt,lastFailureAt:e?.lastFailureAt??null,consecutiveFailures:e?.consecutiveFailures??0,throttledUntil:e?.throttledUntil??null,dropped:this.drops.counts()},sdkVersion:this.sdkVersion,owningSdkVersion:this.mismatchVersion,status:this.destroyed?`stopped`:this.tunablesLocked?this.config.enabled?this.rotating?`rotating`:t.length?`degraded`:this.ready?`ready`:`starting`:`disabled`:`unconfigured`,mode:this.role()===`forwarder`?`forwarder`:this.hasDestination()?`sender`:`console-only`,senderReady:this.sender!==void 0&&this.config.enabled&&!this.destroyed&&!this.rotating&&!this.deliveryClosed,configurationLocked:this.config.lockConfiguration,issues:t,securityContext:{...this.config.securityContext},storagePersistence:this.storagePersistence,bus:{sourcePolicy:i,maxMessageBytes:a,maxRecordsPerMessage:o,maxMessagesPerSecond:s}}}storeAccess(){return{config:this.config,diagnostics:this.diagnostics,memory:this.memoryStorage}}async storedBatches(){return await(this.sender??this.parkedSender)?.queueDepth()??0}flush(e){return this.flushFor(this.flushTimeout(e),!0)}async flushFor(e,t){x(this),t&&this.collectPoints();let n=this.idle();if(n)return n;let r=Date.now()+e,a,o=new Promise(t=>{let n=setTimeout(t,e);i.t(n),a=()=>{clearTimeout(n)}});try{return await this.flushBefore(r,o)}finally{a()}}async flushBefore(t,n){let r=this.heldRecords(),i=this.ready?this.senderLoad:this.started;if(i&&(!this.ready||!this.sender)&&!await Promise.race([i.then(()=>!0),n.then(()=>!1)]))return W({pending:this.waiting()});let{bus:a}=this,o=a?.getRole()===`forwarder`,s=this.idle();if(s)return s;if(o){let r=this.forwardBuffer.length,i=this.sendForwarded(),o=r-i,s=Math.floor(Math.max(0,t-Date.now())*e.rt),c=await a.requestFlush(s,n);return c?{...c,forwarded:i,dropped:c.dropped+o}:W({forwarded:i,pending:i,dropped:o})}let{sender:c}=this;return c?W(await c.flushUntil(n)):this.rotating?W({pending:r+this.waiting()}):U(`complete`,{dropped:r})}idle(){return this.tunablesLocked&&this.config.enabled&&!this.destroyed?null:U(`inactive`,{pending:this.destroyed?0:this.waiting()})}heldRecords(){return this.bootBuffer.length+this.pendingRecords.length+this.forwardBuffer.length}waiting(){let e=this.heldRecords();for(let t of[this.sender,this.retiring]){let n=t?.stats();e+=n?n.pending+n.inFlight:0}return e}readOptions(e,t){if(typeof e!=`object`&&e!==void 0)this.diagnostics.report(`config.invalid`,t);else return this.diagnostics.guard(`config.invalid`,t,()=>({...e}))}flushTimeout(t){let n=this.readOptions(t,st);if(!n)return e.at;let r=n.timeoutMs??5e3;return typeof r==`number`&&r>=0&&r<=6e5?r:(this.diagnostics.report(`config.invalid`,st),e.at)}};o.t(K,`local`,null);function q(e,t,n=new WeakMap){if(Object.is(e,t))return!0;if(e instanceof RegExp&&t instanceof RegExp)return String(e)===String(t);if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(n.has(e))return n.get(e)===t;n.set(e,t);let i=Object.keys(e),a=Object.keys(t);return i.length===a.length&&i.every(i=>r.t(t,i)&&q(Reflect.get(e,i),Reflect.get(t,i),n))}var J;function pt(t={}){if(J)return J;let n=new A(t.onDiagnostic);if(typeof document<`u`||typeof addEventListener!=`function`)return n.report(`config.invalid`,`Call serveTransportWorker() in a dedicated worker.`),()=>void 0;let i=!1,a,o,s=t=>{n.guard(`transport.http_error`,`The transport worker could not read its connection.`,()=>{let s=t.data;if(!r.n(s)||s.p!==`ui-observability.transport/1`||s.t!==e.sr.connect||t.ports.length===0)return;let c=t.ports[0];a||s.v!==`1.0.0`?(c.postMessage(e.or),c.close()):(a=c,Promise.resolve().then(()=>require("./worker-server-CFe4nvos.cjs")).then(e=>{i||(o=e.serveWorkerPort(c,n))}).catch(t=>{n.report(`transport.http_error`,`The transport worker delivery module could not load.`,void 0,t),n.guard(`transport.http_error`,`The failed transport port could not be closed.`,()=>{c.postMessage(e.or),c.close()})}))})},c=()=>{i||(i=!0,J=void 0,removeEventListener(`message`,s),o?.(),n.guard(`transport.http_error`,`The transport service could not close its port.`,()=>{a?.postMessage(e.or)}),n.guard(`transport.http_error`,`The transport port could not close.`,()=>{a?.close()}))};return addEventListener(`message`,s),J=c,c}function mt(){let e=[],t=[],n={status:200};return{transport:r=>(e.push(r),n.status>=200&&n.status<300&&t.push(r),Promise.resolve({...n})),records:()=>t.flatMap(e=>[...e.records]),batches:()=>[...e],clear:()=>{e.length=0,t.length=0},respondWith:(e,t)=>{n=t===void 0?{status:e}:{status:e,retryAfterMs:t}}}}var Y=new Map;function X(){return(K.current()??K.stopped())||K.configure({},!0)}function ht(e){K.configure(e),Z()}function gt(e){X().setConfigurationLocked(e)}function _t(e,t){return X().rotateSecurityContext(e,t)}async function vt(){let e=X();return Z(),{...await e.health(),loggerCache:{...e.config.loggerCache,size:Y.size}}}async function yt(){let e=await vt();return X().debugBundle(e)}function Z(){let e=(K.current()??K.stopped())?.config.loggerCache.maxEntries,t=e===void 0?256:e;if(t!==null)for(let e of Y.keys()){if(Y.size<=t)break;Y.delete(e)}return t}function bt(e,t){let n=Z();if(t||n===0)return new E(X,e,t);let r=Y.get(e);return r??=new E(X,e),Y.delete(e),Y.set(e,r),Z(),r}function Q(){return bt(`app`)}function xt(e,t){Q().trace(e,t)}function St(e,t){Q().debug(e,t)}function Ct(e,t){Q().info(e,t)}function wt(e,t){Q().warn(e,t)}function Tt(e,t,n){Q().error(e,t,n)}function Et(e,t,n){Q().fatal(e,t,n)}function Dt(e,t){Q().logAction(e,t)}function Ot(e,t){Q().logEvent(e,t)}function $(t){K.current()?.diagnostics.report(`config.invalid`,e.xt,void 0,t)}function kt(e,t={}){return we(e,t,(e,t,n)=>{X().recordMetric(e,t,n)},$)}function At(e,t={}){return Te(e,t,(e,t,n)=>{X().recordMetric(e,t,n)},$)}function jt(e,t={}){return Ee(e,t,(e,t,n)=>{X().recordMetric(e,t,n)},$)}function Mt(e,t){return X().startMeasure(e,t)}function Nt(e,t,n){let r=X();return he(r.startMeasure(e,n),t,r.diagnostics)}function Pt(){X().setReplay(!0)}function Ft(){X().setReplay(!1)}var It={probe:(e,t)=>c.t().probe(e,t,K.current()?.diagnostics),time:(e,t)=>c.t().time(e,t,K.current()?.diagnostics)};function Lt(e,t){X().addBreadcrumb(e,t)}function Rt(e){let t=X();r.n(e)?t.diagnostics.guard(`record.sanitize_failed`,`The library could not read the values of setContext().`,()=>{t.context.merge(e)}):t.diagnostics.report(`config.invalid`,`setContext() takes an object. The library keeps the current context.`)}function zt(e){X().context.remove(e)}function Bt(e,t){return X().journey.start(e,t)}function Vt(){X().journey.end()}function Ht(){return X().journey.current()}function Ut(){return X().journey.getToken()}function Wt(e){return X().journey.adopt(e,`manual`,!0)}function Gt(e,t){return X().registerWorker(e,t)}function Kt(e,t){return X().registerFrame(e,t)}function qt(){X().tracing.rotate(`explicit`)}function Jt(){return X().tracing.headers()}function Yt(e){return X().flush(e)}function Xt(){X().newSession()}function Zt(){return X().diagnostics.snapshot()}async function Qt(e){await(K.current()??K.stopped())?.destroy(e)}exports.addBreadcrumb=Lt,exports.adoptJourney=Wt,exports.collectDebugBundle=yt,exports.configure=ht,exports.counter=kt,exports.createMemoryTransport=mt,exports.currentJourney=Ht,exports.debug=St,exports.endJourney=Vt,exports.error=Tt,exports.fatal=Et,exports.flush=Yt,exports.gauge=At,exports.getDiagnosticCounters=Zt,exports.getHealth=vt,exports.getJourneyToken=Ut,exports.getLogger=bt,exports.getTraceHeaders=Jt,exports.histogram=jt,exports.info=Ct,exports.logAction=Dt,exports.logEvent=Ot,exports.measure=Nt,exports.newSession=Xt,exports.newTrace=qt,exports.profiler=It,exports.registerFrame=Kt,exports.registerWorker=Gt,exports.removeContext=zt,exports.rotateSecurityContext=_t,exports.serveTransportWorker=pt,exports.setConfigurationLocked=gt,exports.setContext=Rt,exports.shutdown=Qt,exports.startJourney=Bt,exports.startMeasure=Mt,exports.startReplay=Pt,exports.stopReplay=Ft,exports.trace=xt,exports.warn=wt;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants-NtiQDWL_.cjs"),t=require("./log-record-Bdywwg0k.cjs"),n=require("./error-like-gGRx2s36.cjs"),r=require("./guards-EjG3ahFp.cjs"),i=require("./unref-CU9Nyz_9.cjs"),a=require("./platform-BZjp9wp1.cjs"),o=require("./defineProperty-X1c4tIPD.cjs"),s=require("./identity-BzAzdQyv.cjs"),c=require("./profiler-DpoPi1hH.cjs"),l=require("./library-console-DdIlzzph.cjs"),u=require("./sanitize-BZdhoghq.cjs"),d=require("./library-request-DO3Ec7KE.cjs"),f=require("./config-C0PtemvC.cjs"),p=require("./batch-C3uNp5kU.cjs"),m=require("./journey-BUmsrgaw.cjs"),h=require("./sampling-wAVJIZXp.cjs"),g=require("./observed-windows-BlE25nrn.cjs");var _=new WeakMap;function v(e){let t=e.idle;t!==void 0&&(e.diagnostics.guard(`pipeline.crashed`,`The idle callback could not be cancelled.`,()=>{cancelIdleCallback(t)}),e.idle=void 0),clearTimeout(e.timer),e.timer=void 0}function y(t,n){typeof requestIdleCallback==`function`&&typeof cancelIdleCallback==`function`&&(n.idle=n.diagnostics.guard(`pipeline.crashed`,`The idle callback could not be scheduled.`,()=>requestIdleCallback(e=>{b(t,n,e)},{timeout:e.q})),n.idle!==void 0)||(n.timer=setTimeout(()=>{b(t,n)},0),i.t(n.timer))}function b(e,t,n){if(_.get(e)!==t||t.draining)return;v(t),t.draining=!0;let r=t.work;t.work=[];let i=0;for(;i<r.length&&(!n||n.didTimeout&&i===0||n.timeRemaining()>0);)if(t.diagnostics.guard(`pipeline.crashed`,`The library could not build a deferred record.`,r[i]),i++,_.get(e)!==t)return;t.work=[...r.slice(i),...t.work],t.draining=!1,t.work.length>0?y(e,t):_.delete(e)}function x(t,n,r,i){let a=_.get(t),o=i===null?e.J:Math.min(i,e.J);if(a&&a.work.length>=o&&!a.draining&&(b(t,a),a=_.get(t)),a){if(a.work.length>=o){r.count(`record.dropped_by_ceiling`);return}a.work.push(n)}else a={work:[n],diagnostics:r,draining:!1},_.set(t,a),y(t,a)}function S(e){let t=_.get(e);t&&b(e,t)}function C(e){let t=_.get(e);if(t){v(t),_.delete(e);for(let e of t.work)t.diagnostics.count(`record.dropped_by_ceiling`);t.work=[]}}var w=[e.P,e.Yn,e.Y];function ee(e,t){let r=t.guard(`record.sanitize_failed`,`The library could not read the error reason.`,()=>{if(!(e instanceof Error)&&!n.r(e))return;let t=Error(e.message);return t.name=e.name,t.stack=e.stack,t});if(r)return r;let i=t.guard(`record.sanitize_failed`,`The library could not convert the error reason to text.`,()=>String(e));return Error(i??typeof e)}function te(e,t,n){return n.guard(`record.sanitize_failed`,`The library could not read the error reason.`,()=>e instanceof Error?e:t)??t}function ne(e,t){if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||typeof e==`symbol`)return e;if(typeof e==`object`&&e)return t.guard(`record.sanitize_failed`,`The library could not read the properties of the error reason.`,()=>{let t=e,r=n.r(e),i={},a=0;for(let e of Object.keys(t)){let o=t[e];r&&n.t.has(e)||!n.n(o)||(i[e]=o,a++)}return a===0?void 0:i})}function re(e){if(!r.n(e)||e instanceof Error)return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}function ie(e){return w.some(t=>e===t||e.startsWith(`${t}.`))?`system`:`log`}function T(e,t){return e===void 0?{}:t.guard(`record.sanitize_failed`,`The library could not read the payload.`,()=>({...e}))??{"uiobs.sanitize_failed":!0}}var E=class n{constructor(e,t,n={}){o.t(this,`bind`,void 0),o.t(this,`namespace`,void 0),o.t(this,`options`,void 0),o.t(this,`levelType`,void 0),o.t(this,`trace`,(e,t)=>{this.write(`TRACE`,this.levelType,e,t)}),o.t(this,`debug`,(e,t)=>{this.write(`DEBUG`,this.levelType,e,t)}),o.t(this,`info`,(e,t)=>{this.write(`INFO`,this.levelType,e,t)}),o.t(this,`warn`,(e,t)=>{this.write(`WARN`,this.levelType,e,t)}),o.t(this,`error`,(e,t,n)=>{this.writeError(`ERROR`,e,t,n)}),o.t(this,`fatal`,(e,t,n)=>{this.writeError(`FATAL`,e,t,n)}),o.t(this,`logAction`,(e,t)=>{this.write(`INFO`,`action`,e,t)}),o.t(this,`logEvent`,(e,t)=>{this.write(`INFO`,`event`,e,t)}),this.bind=e,this.namespace=t,this.options=n,this.levelType=ie(t)}child(e,t={}){return new n(this.bind,`${this.namespace}.${e}`,{scopedContext:{...this.options.scopedContext,...t.scopedContext}})}write(e,t,n,r){let i=this.bind();this.submit(i,e,t,a=>{this.writeNow(i,e,t,n,r,!1,a)})}submit(e,n,r,i){if(!e.isDestroyed()){if(e.isRotating())e.diagnostics.count(`record.dropped_during_rotation`);else if(e.config.payloadMode===`defer`&&e.config.enabled&&!e.config.debugBuffer.enabled&&this.namespace!==`uiobs.diagnostics`){if(!e.builder.isEnabled(n,this.namespace,r)&&!this.mirrors(e,n))return;let o=e.journey.current(),s={timeUnixNano:t.r(),trace:e.tracing.resolve(),journey:o?{...o}:null,context:e.context.getAll(),url:a.t(e.diagnostics)};x(e,()=>{i(s)},e.diagnostics,e.config.buffering.maxPendingRecords)}else i()}}writeNow(e,t,n,r,i,a,o){if(!(e.config.enabled&&e.config.debugBuffer.enabled)&&!e.builder.isEnabled(t,this.namespace,n)){this.mirrors(e,t)&&this.print(e,t,r,i,void 0,null,void 0,o);return}let s={snapshot:o,level:t,type:n,body:r,namespace:this.namespace,scoped:this.options.scopedContext,payload:a?i:T(i,e.diagnostics)},{record:c,dropped:l}=e.builder.build(s),u=!!e.config.redact||e.config.processors.length>0,d=n!==`metric`&&e.config.captureLimits.breadcrumbs>0,f=l===`sampling`&&u&&d?e.builder.build(s,!0):void 0,p=c??f?.record??null,m=p?p.body:l===`sampling`&&!u?r:void 0;d&&m!==void 0&&e.breadcrumbs.push({t:o?Number(o.timeUnixNano.slice(0,-6)):Date.now(),category:n===`action`?`action`:n===`event`?`event`:`log`,message:m}),this.print(e,t,r,i,void 0,p,f?.dropped??l,o),e.emit(c)}writeError(e,t,n,r){let i=this.bind();this.submit(i,e,this.levelType,a=>{this.writeErrorNow(i,e,t,n,r,a)})}writeErrorNow(t,n,r,i,a,o){let s=t.builder.isEnabled(n,this.namespace);if(!s&&!this.mirrors(t,n))return;let c=a===void 0&&(t.diagnostics.guard(`record.sanitize_failed`,`The library could not read the error slot.`,()=>re(i))??!1),l=c?i:a,u=c?void 0:i,d=u===void 0?void 0:ee(u,t.diagnostics),f=d===void 0?void 0:te(u,d,t.diagnostics);if(!s){this.print(t,n,r,l,f,null,void 0,o);return}let p=d?ne(u,t.diagnostics):void 0,{record:m,dropped:h}=t.builder.build({snapshot:o,level:n,type:this.levelType,body:r,namespace:this.namespace,scoped:this.options.scopedContext,payload:{...T(l,t.diagnostics),...d?{"error.type":d.name,"error.message":d.message,"error.stack_trace":d.stack}:{},...p===void 0?{}:{[e.d]:p},[e.c]:t.breadcrumbs.snapshot()}});this.print(t,n,r,l,f,m,h,o),t.emit(m)}print(e,t,n,r,i,a,o,s){if(!e.config.redact&&e.config.processors.length===0){e.console.write(this.namespace,t,n,r,i);return}if(a){e.console.write(this.namespace,t,a.body,a.attributes);return}if(o===`processor`||o===`redact`||o===`malformed`||!e.config.enabled||!e.console.accepts(t))return;let c=e.builder.build({snapshot:s,level:t,type:this.levelType,body:n,namespace:this.namespace,scoped:this.options.scopedContext,payload:{...T(r,e.diagnostics),...i?{"error.type":i.name,"error.message":i.message,"error.stack_trace":i.stack}:{}}},!0).record;c&&e.console.write(this.namespace,t,c.body,c.attributes)}mirrors(e,t){return e.config.enabled&&e.console.accepts(t)}},ae=class extends E{constructor(...t){super(...t),o.t(this,`logMetric`,(t,n,r=e.K,i=`gauge`,a,o)=>{if(!Number.isFinite(n)){this.bind().diagnostics.report(`record.dropped_malformed`,`The metric value is not a finite number. The library dropped the metric.`,{"metric.name":t});return}let s=this.bind();this.submit(s,`INFO`,`metric`,c=>{let l=T(a,s.diagnostics),u={...T(o,s.diagnostics),...l,"metric.name":t,"metric.value":n,"metric.unit":r,"metric.type":i,[e.Bt.attributeKeys]:Object.keys(l)};this.writeNow(s,`INFO`,`metric`,t,u,!0,c)})})}},oe=/^[0-9a-f]{32}$/,se=/^[0-9a-f]{16}$/,D=/[1-9a-f]/;function ce(e){return oe.test(e.traceId)&&D.test(e.traceId)&&se.test(e.spanId)&&D.test(e.spanId)}function le(){return s.o(16)}function O(){return s.o(8)}function ue(e){return{traceId:le(),spanId:O(),traceFlags:1,startedAt:Date.now(),reason:e,ended:!1}}function de(e,t,n){return`00-${e}-${t}-${(n&255).toString(16).padStart(2,`0`)}`}function fe(e){return{traceId:e.traceId,spanId:e.spanId,traceFlags:e.traceFlags}}var pe=class{constructor(t,n=e.or,r,i){o.t(this,`diagnostics`,void 0),o.t(this,`maxAgeMs`,void 0),o.t(this,`load`,void 0),o.t(this,`spans`,void 0),o.t(this,`ambient`,ue(`start`)),o.t(this,`otel`,void 0),this.diagnostics=t,this.maxAgeMs=n,this.load=r,this.spans=i}setup(e,t){this.maxAgeMs=e,this.load=t}async loadOtel(){if(this.load)try{this.otel=await this.load()}catch(e){this.diagnostics.report(`trace.otel_failed`,`The library could not load @opentelemetry/api. Records use the trace ids of the library.`,void 0,e)}}resolve(){return this.activeSpanContext()??this.ambientContext()}ambientContext(){return Date.now()-this.ambient.startedAt>this.maxAgeMs&&this.rotate(`maxAge`),fe(this.ambient)}activeSpanContext(){let e=this.otel;if(e)return this.diagnostics.guard(`trace.otel_failed`,`The library could not read the active OpenTelemetry span.`,()=>{let t=e.trace.getActiveSpan();if(t===void 0)return;let n=t.spanContext();if(ce(n))return{traceId:n.traceId,spanId:n.spanId,traceFlags:n.traceFlags}})}rotate(e){let t=this.ambient;this.ambient=ue(e);let n=fe(this.ambient);return this.finish(t),n}end(){this.finish(this.ambient)}finish(e){e.ended||(e.ended=!0,this.spans?.onEnd({traceId:e.traceId,spanId:e.spanId,reason:e.reason,startedAt:e.startedAt,endedAt:Date.now()}))}headers(){return this.trace(!1).headers}request(){return this.trace(!0)}trace(t){let n={},r=this.otel;if(r&&this.diagnostics.guard(`trace.otel_failed`,`The library could not add the OpenTelemetry headers.`,()=>{r.propagation.inject(r.context.active(),n)}),n.traceparent)return{headers:n};let i=this.activeSpanContext(),a=i??this.ambientContext(),o=i?void 0:this.spans;if(!o?.enabled())return n[e.ar]=de(a.traceId,a.spanId,a.traceFlags),{headers:n};let s=o.keeps(a.traceId),c=s?a.traceFlags:a.traceFlags&-2,l=t?O():a.spanId;return n[e.ar]=de(a.traceId,l,c),!t||!s?{headers:n}:{headers:n,span:{traceId:a.traceId,spanId:l,parentSpanId:a.spanId}}}},me={name:`ui.measure.duration`,kind:`histogram`,unit:`ms`,boundaries:e.Rt},he={name:`ui.measure.phase.duration`,kind:`histogram`,unit:`ms`,boundaries:e.Rt};function ge(e,t,n,r){let i=String(e),a=Date.now(),o=performance.now(),s,c=!1,l=e=>a+e-o,u=(e,a)=>{s&&=(r.metric(he,e-s.at,{...t,"measure.name":i,"measure.phase":s.name}),n&&r.span({name:s.name,kind:`internal`,traceId:n.traceId,spanId:O(),parentSpanId:n.spanId,startMs:l(s.at),endMs:l(e),error:a,attributes:{"measure.name":i}}),void 0)};return{phase:e=>{if(c)return;let t=performance.now();u(t,!1),s={name:String(e),at:t}},end:(e=`ok`)=>{if(c)return;c=!0;let s=performance.now(),d=e===`error`;u(s,d);let f={...t,"measure.outcome":e};r.metric(me,s-o,{...f,"measure.name":i}),n&&r.span({...n,name:i,kind:`internal`,startMs:a,endMs:l(s),error:d,attributes:f})}}}function _e(e,t,n){let r=`error`;try{let i=t(),a=n.guard(`record.sanitize_failed`,`The library could not read what the function of the measure returned. The measure ends now.`,()=>i?.then);if(typeof a!=`function`)return r=`ok`,i;let o=a.call(i,t=>(e.end(),t),t=>{throw e.end(`error`),t});return r=void 0,o}finally{r!==void 0&&e.end(r)}}var ve=`overflow`,ye=new Set([e.g,e.h,e.a,e.v,e.f,e.p,e.m]);function be(e={}){let t={};for(let n of Object.keys(e).sort()){if(n.startsWith(`metric.`)||ye.has(n))continue;let r=e[n];(typeof r==`string`||typeof r==`boolean`||typeof r==`number`&&Number.isFinite(r))&&(t[n]=r)}return t}function xe(e,t){if(!Array.isArray(e))return null;let n=t===null?e.length:Math.min(e.length,t+1);return Array.from({length:n},(t,n)=>e[n])}function Se(e,t){return Array.isArray(e)&&(t===null||e.length<=t)&&e.every((t,n)=>typeof t==`number`&&Number.isFinite(t)&&(n===0||t>e[n-1]))}function Ce(t,n,r){let i={"metric.name":t.name,"metric.unit":t.unit,"metric.type":t.kind,[e.Bt.start]:r,[e.Bt.attributeKeys]:Object.keys(n.attributes)};return t.kind===`histogram`?{...i,[e.Bt.count]:n.count,[e.Bt.sum]:n.sum,[e.Bt.min]:n.min,[e.Bt.max]:n.max,[e.Bt.bounds]:t.boundaries,[e.Bt.buckets]:n.buckets}:(i[`metric.value`]=t.kind===`gauge`?n.last:n.sum,i)}function we(e,t){try{return{unit:e.unit,boundaries:e.boundaries}}catch(e){return t(e),{unit:void 0,boundaries:void 0}}}function Te(e,t,n,r){return{name:e,kind:t,unit:we(n,r).unit??`count`,boundaries:[]}}function k(e,t,n,r){let i=Te(e,`counter`,t,r);return{add:(e,t)=>{n(i,e,t)}}}function Ee(e,t,n,r){let i=Te(e,`gauge`,t,r);return{set:(e,t)=>{n(i,e,t)}}}function De(t,n,r,i){let{unit:a,boundaries:o}=we(n,i),s={name:t,kind:`histogram`,unit:a??`count`,boundaries:o??e.Rt,fromApp:o!==void 0};return{record:(e,t)=>{r(s,e,t)}}}var Oe=class{constructor(e,t,n,r={maxSeries:100,maxInstruments:1e3,maxHistogramBoundaries:50}){o.t(this,`intervalMs`,void 0),o.t(this,`emit`,void 0),o.t(this,`diagnostics`,void 0),o.t(this,`policy`,void 0),o.t(this,`instruments`,new Map),o.t(this,`timer`,null),o.t(this,`startedAt`,0),this.intervalMs=e,this.emit=t,this.diagnostics=n,this.policy=r}record(e,t,n){!Number.isFinite(t)||e.kind===`counter`&&t<0?this.diagnostics.report(`record.dropped_malformed`,`The value of the metric ${e.name} is not valid. The library dropped it.`,{"metric.name":e.name}):this.diagnostics.guard(`record.sanitize_failed`,`The library could not read the attributes of the metric ${e.name}.`,()=>{let r=this.instrumentOf(e);r&&(this.add(r,t,be(n)),this.arm())})}collect(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null);let e=`${String(this.startedAt)}000000`,t=[...this.instruments.values()];this.instruments.clear();for(let{def:n,series:r}of t)for(let t of r.values())this.emit(n.name,t.attributes,Ce(n,t,e))}instrumentOf(t){let n=this.instruments.get(t.name);if(n)return n.def.kind===t.kind?n:(this.diagnostics.report(`record.dropped_malformed`,`The metric ${t.name} is a ${n.def.kind} and a ${t.kind}. The library dropped the value.`,{"metric.name":t.name}),null);let{maxInstruments:r}=this.policy;if(r!==null&&this.instruments.size>=r)return this.diagnostics.count(`record.dropped_by_ceiling`),null;let i=t.fromApp===!0?this.policy.maxHistogramBoundaries:null,a=xe(t.boundaries,i),o=Se(a,i);t.kind===`histogram`&&!o&&this.diagnostics.report(`config.invalid`,`The boundaries of the metric ${t.name} must meet metrics.maxHistogramBoundaries and contain finite numbers in ascending order. The library uses the default boundaries.`);let s={def:{...t,boundaries:o?a:[...e.Rt]},series:new Map};return this.instruments.set(t.name,s),s}add(t,n,r){let i=JSON.stringify(r),a=t.series.get(i),o=r,{maxSeries:s}=this.policy;if(!a&&s!==null&&t.series.size>=s&&(i=ve,a=t.series.get(i),o={[e._]:!0}),!a){let e=t.def.kind===`histogram`?t.def.boundaries.length+1:0,r=Array(e).fill(0);a={attributes:o,count:0,sum:0,min:n,max:n,last:n,buckets:r},t.series.set(i,a)}if(a.count+=1,a.sum+=n,a.min=Math.min(a.min,n),a.max=Math.max(a.max,n),a.last=n,a.buckets.length>0){let e=t.def.boundaries.findIndex(e=>n<=e);a.buckets[e===-1?a.buckets.length-1:e]+=1}}arm(){this.timer===null&&(this.startedAt=Date.now(),this.timer=setTimeout(()=>{this.collect()},this.intervalMs()),i.t(this.timer))}},ke={TRACE:`debug`,DEBUG:`debug`,INFO:`info`,WARN:`warn`,ERROR:`error`,FATAL:`error`},Ae=class{constructor(t,n,r=e.un){o.t(this,`settings`,void 0),o.t(this,`diagnostics`,void 0),o.t(this,`limits`,void 0),this.settings=t,this.diagnostics=n,this.limits=r}update(e){this.settings=e}accepts(t){return this.settings.level===null||!r.t(e.At,this.settings.level)?!1:e.At[t]>=e.At[this.settings.level]}write(e,t,n,r,i){if(!this.accepts(t)||typeof console>`u`||l.t())return;let a=`%c[%s]%c[${t}]%c`,{styles:o}=this.settings,s=ke[t];this.diagnostics.guard(`handler.threw`,`The library could not print to console.${s}.`,()=>{let c=[];i!==void 0&&c.push(i),r!==void 0&&c.push(u.n(r,this.limits,this.diagnostics)),l.n(()=>{console[s](a,o.namespace,e,o[t],``,n,...c)})})}},je=class{constructor(){o.t(this,`value`,0)}next(){return++this.value}},Me=class{constructor(e){o.t(this,`buffer`,void 0),o.t(this,`pointer`,0),o.t(this,`filled`,!1),o.t(this,`capacity`,void 0),this.capacity=e===0?0:Math.max(e,1),this.buffer=Array(this.capacity)}resize(e){let t=this.snapshot().slice(-e);if(this.capacity=e,this.buffer=Array(e),this.pointer=0,this.filled=!1,e)for(let e of t)this.push(e)}push(e){this.capacity!==0&&(this.buffer[this.pointer]=e,this.pointer=(this.pointer+1)%this.capacity,this.pointer===0&&(this.filled=!0))}retain(e){let t=this.snapshot().filter(e);this.clear();for(let e of t)this.push(e)}clear(){this.buffer.fill(void 0),this.pointer=0,this.filled=!1}snapshot(){return(this.filled?[...this.buffer.slice(this.pointer),...this.buffer.slice(0,this.pointer)]:this.buffer.slice(0,this.pointer)).filter(e=>e!==void 0)}},Ne=class{constructor(){o.t(this,`map`,new Map)}merge(e){for(let[t,n]of Object.entries(e))n===null?this.map.delete(t):n!==void 0&&this.map.set(t,n)}remove(e){this.map.delete(e)}clear(){this.map.clear()}getAll(){return Object.fromEntries(this.map)}},Pe=class{constructor(e){o.t(this,`policy`,void 0),o.t(this,`kept`,[]),this.policy=e}push(e){let{enabled:t,maxRecords:n}=this.policy();t&&(this.kept.push({at:Date.now(),record:e}),this.kept.length>=n*2&&(this.kept=this.kept.slice(-n)))}drain(){let t=this.live();return this.kept=[],t.map(({record:t})=>({...t,attributes:{...t.attributes,[e.u]:!0}}))}snapshot(){return this.live().map(({record:e})=>e)}live(){let{enabled:e,maxRecords:t,maxAgeMs:n}=this.policy();if(!e)return this.kept=[],[];let r=n===null?-1/0:Date.now()-n;return this.kept.slice(-t).filter(e=>e.at>=r)}clear(){this.kept=[]}},A=class{constructor(t,n=e.X,r=!1){o.t(this,`handler`,void 0),o.t(this,`throttleMs`,void 0),o.t(this,`consoleFallback`,void 0),o.t(this,`counters`,new Map),o.t(this,`lastEmitted`,new Map),this.handler=t,this.throttleMs=n,this.consoleFallback=r}setPolicy(e,t){this.throttleMs=e,this.consoleFallback=t}setHandler(e){this.handler=e}count(e,t=1){let n=(this.counters.get(e)??0)+t;return this.counters.set(e,n),n}report(t,n,r,i){let a=this.count(t),o=Date.now();if(o-(this.lastEmitted.get(t)??0)<this.throttleMs)return!1;this.lastEmitted.set(t,o);let s={code:t,message:n,detail:r,cause:i,at:o,count:a},{handler:c}=this;if(!c)return!0;try{l.n(()=>{c(s)})}catch{this.count(`handler.threw`),this.consoleFallback&&typeof console<`u`&&l.n(()=>{console.warn(`${e.Mt} The onDiagnostic handler threw an error.`)})}return!0}guard(e,t,n){try{return n()}catch(n){this.report(e,t,void 0,n);return}}async guardAsync(e,t,n){try{return await n()}catch(n){this.report(e,t,void 0,n);return}}snapshot(){return Object.fromEntries(this.counters)}};function j(e,t){e.length<20&&!e.includes(t)&&e.push(t)}var Fe=class{constructor(e,t){o.t(this,`config`,void 0),o.t(this,`diagnostics`,void 0),o.t(this,`pending`,new Map),o.t(this,`scheduled`,!1),o.t(this,`reporting`,!1),o.t(this,`lost`,{}),this.config=e,this.diagnostics=t}add(t,n,r=[],i=n.length){if(i>0&&(this.lost[t]=(this.lost[t]??0)+i),!this.config.onDrop||this.reporting||n.length===0&&r.length===0)return;let a=this.pending.get(t);a||(a={reason:t,records:0,batchIds:[],journeyIds:[],actions:[]},this.pending.set(t,a)),a.records+=i;for(let e of r)j(a.batchIds,e);for(let t of n){let n=p.t(t,e.f);typeof n==`string`&&j(a.journeyIds,n);let r=p.r(t)?t.body:void 0;typeof r==`string`&&j(a.actions,r)}this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.flush()}))}counts(){return{...this.lost}}flush(){this.scheduled=!1;let e=[...this.pending.values()];this.pending.clear();let t=this.config.onDrop;if(t){this.reporting=!0;for(let n of e)this.diagnostics.guard(`handler.threw`,`The onDrop hook threw an error.`,()=>{d.r(()=>{l.n(()=>{t(n)})})});this.reporting=!1}}},Ie=class{constructor(e){o.t(this,`onDrop`,void 0),o.t(this,`actions`,{head:[],tail:[]}),o.t(this,`others`,{head:[],tail:[]}),o.t(this,`arrivals`,0),this.onDrop=e}get records(){return this.inOrder()}get length(){let{actions:e,others:t}=this;return e.head.length+e.tail.length+t.head.length+t.tail.length}push(t,n){let r=p.r(t),i=r?this.actions:this.others,a=r?e.j:n,o={record:t,arrival:this.arrivals};if(this.arrivals+=1,i.head.length<100)i.head.push(o);else if(i.tail.push(o),i.head.length+i.tail.length>a){let e=i.tail[0];i.tail.shift(),this.onDrop(e.record)}}take(){let e=this.inOrder();return this.actions={head:[],tail:[]},this.others={head:[],tail:[]},this.arrivals=0,e}inOrder(){let{actions:e,others:t}=this;return[...e.head,...e.tail,...t.head,...t.tail].sort((e,t)=>e.arrival-t.arrival).map(e=>e.record)}},Le=`error.`,Re=[e.v,e.f,e.p],ze={processor:{label:`A processor`,code:`record.dropped_by_processor`,refused:`processors is not a list of functions. The library drops each record until processors is a list of functions or [].`},redact:{label:`The redact hook`,code:`record.dropped_by_redact`,refused:`redact is not a function. The library drops each record until redact is a function or null.`}},M=e=>typeof e==`number`&&Number.isFinite(e),N=e=>Array.isArray(e)&&e.every(M),P=e=>typeof e==`string`&&/^\d{1,20}$/.test(e),Be=e=>typeof e==`string`&&/^[0-9a-f]{32}$/.test(e),Ve=e=>typeof e==`string`&&/^[0-9a-f]{16}$/.test(e),He=e=>e===``||Ve(e),Ue=e=>e===`counter`,We=e=>e===`histogram`,Ge=e=>e===`client`||e===`internal`,Ke=e=>e===`error`||e===`unset`,qe={"metric.type":Ue,"metric.value":M,[e.Bt.start]:P},Je={"metric.type":We,[e.Bt.start]:P,[e.Bt.count]:M,[e.Bt.sum]:M,[e.Bt.min]:M,[e.Bt.max]:M,[e.Bt.bounds]:N,[e.Bt.buckets]:N},Ye={[e.Kn.kind]:Ge,[e.Kn.parentId]:He,[e.Kn.start]:P,[e.Kn.end]:P,[e.Kn.status]:Ke},Xe={[e.Kn.linkTraceId]:Be,[e.Kn.linkSpanId]:Ve};function Ze(t){let n=t[e.g],r=t[e.a];return n===`span`&&r===`uiobs.traces`?[Ye,Xe]:n!==`metric`||r!==`uiobs.metrics`?[]:t[`metric.type`]===`histogram`?[Je]:[qe]}function Qe(e){let t={};for(let n of Ze(e)){let r=Object.keys(n);if(r.every(t=>n[t](e[t])))for(let n of r)t[n]=e[n]}return t}function F(e){return e}var $e=class{constructor(e){o.t(this,`deps`,void 0),o.t(this,`resourceCache`,null),this.deps=e}invalidateResource(){this.resourceCache=null}isEnabled(e,t,n){return this.deps.config.enabled&&this.passesLevel(e,t,n)}passesLevel(t,n,r){let{config:i}=this.deps;if(r!==void 0&&e.kt.includes(r))return!0;let a=this.deps.remote.sampling?.minLevelFor(n)??h.n(n,i);return e.At[t]>=e.At[a]}keepForDebug(e){let{config:t,debug:n}=this.deps;if(!n||!t.enabled||!t.debugBuffer.enabled)return;let{record:r}=this.build(e,!0);r&&n.push(r)}build(n,r=!1){let{config:i,diagnostics:o,tracing:s,journey:c,sequence:l,limits:d,remote:f}=this.deps;if(!r&&!this.isEnabled(n.level,n.namespace,n.type))return o.count(`record.dropped_by_level`),this.keepForDebug(n),{record:null,dropped:`level`};let p=n.trace??n.snapshot?.trace??s.resolve(),m=n.snapshot?n.snapshot.journey:c.current(),g=h.o({level:n.level,type:n.type,namespace:n.namespace,journeyId:m?.id??``,traceId:p.traceId,aggregated:n.aggregated},i,f.sampling?.current()??null);if(!r&&!g)return o.count(`record.dropped_by_sampling`),this.keepForDebug(n),{record:null,dropped:`sampling`};let _=l.next(),v=n.snapshot?.url??a.t(o),y=i.metadata.pageUrl?a.a(v,i.capture.fullUrls,i.capture.urlTransform,o):``,b,x=0;try{let e=u.r(n.snapshot?.context??this.deps.context.getAll(),d,o),t=u.r(this.provided(),d,o),r=u.r(n.scoped??{},d,o),i=u.r(n.payload??{},d,o);x=e.bytes+t.bytes+r.bytes+i.bytes,b={...F(e.value),...F(t.value),...F(r.value),...F(i.value)}}catch(t){o.report(`record.sanitize_failed`,`The library could not sanitize the attributes.`,void 0,t),b={[e.y]:!0}}Object.assign(b,n.fixed),b[e.g]=n.type,b[e.h]=_,b[e.a]=n.namespace,b[e.v]=y,m&&(b[e.f]=m.id,b[e.p]=m.name,m.parentId!==void 0&&(b[e.m]=m.parentId));let S=u.i(n.body,d.maxBodyChars);S!==n.body&&o.count(`record.truncated`);let C={timeUnixNano:n.snapshot?.timeUnixNano??t.r(),traceId:p.traceId,spanId:p.spanId,traceFlags:p.traceFlags,severityNumber:e.Gn[n.level],severityText:n.level,body:S,attributes:b,resource:this.resource()},w=this.hookStages();if(w.length>0){let e=this.applyHooks(C,w,n.fixed);if(typeof e==`string`)return{record:null,dropped:e};({record:C,bytes:x}=e)}let ee={[e.g]:n.type,[e.h]:_,[e.a]:n.namespace};return{record:this.fit(C,x,ee,n.fixed)}}redactForwarded(e){let{config:t,diagnostics:n,limits:r}=this.deps,i=Qe(e.attributes),a=Math.max(r.maxAttributeCount,128),o={...r,maxAttributeCount:a},s=F(u.r(e.resource,o,n).value),c=t.redact?[[t.redact,`redact`]]:[],l=this.applyHooks({...e,resource:s},c,i);return typeof l==`string`?null:l.record}rehook(t){let{config:n,diagnostics:r,limits:i,remote:o,debug:s}=this.deps,{attributes:c}=t,l=String(c[e.a]),d=this.passesLevel(t.severityText,l,c[e.g]),f=d&&h.a(t,n,o.sampling?.current()??null),p=n.metadata.pageUrl?a.a(String(c[e.v]),n.capture.fullUrls,n.capture.urlTransform,r):``,m=u.i(t.body,i.maxBodyChars);m!==t.body&&r.count(`record.truncated`);let g=Qe(c),_={...t,body:m,attributes:{...c,[e.v]:p},resource:this.resource()},v=this.applyHooks(_,this.hookStages(),g),y=typeof v==`string`?null:this.fit(v.record,v.bytes,c,g);return f?y:(r.count(d?`record.dropped_by_sampling`:`record.dropped_by_level`),y&&s&&n.enabled&&n.debugBuffer.enabled&&s.push(y),null)}fit(t,n,r,i){let{diagnostics:a,limits:o}=this.deps;if(n<=o.maxRecordBytes)return t;a.report(`record.truncated`,`The attributes are larger than the size limit. The library dropped the caller attributes.`,{bytes:n,body:t.body});let s={[e.g]:r[e.g],[e.h]:r[e.h],[e.a]:r[e.a],[e.s]:!0,[e.o]:n};for(let e of Re)e in t.attributes&&(s[e]=t.attributes[e]);for(let[e,n]of Object.entries(t.attributes))e.startsWith(Le)&&(s[e]=n);let c=u.r(s,o,a).bytes;c>o.maxRecordBytes&&`error.data`in s&&(Reflect.deleteProperty(s,e.d),c=u.r(s,o,a).bytes);let l=t.attributes[e.c];if(l!==void 0){let t=u.r(l,o,a).bytes;c+t<=o.maxRecordBytes&&(s[e.c]=l)}return Object.assign(s,i),t.attributes=s,t}hookStages(){let{processors:e,redact:t}=this.deps.config,n=e.map(e=>[e,`processor`]);return t&&n.push([t,`redact`]),n}applyHooks(e,t,n){let r=e;for(let[e,n]of t){let t=this.runHook(e,n,r);if(typeof t==`string`)return t;r=t}let{diagnostics:i,limits:a}=this.deps,o=u.r(r.attributes,a,i),s=F(o.value);return Object.assign(s,n),{record:{...r,attributes:s},bytes:o.bytes}}runHook(n,r,i){let{diagnostics:a}=this.deps,{label:o,code:s,refused:c}=ze[r],l;try{l=n(i)}catch(e){return a.report(s,`${o} threw an error. The library dropped the record.`,void 0,e),r}if(l===null)return n===f.t?a.report(s,c):a.count(s),r;let u=l??i;return t.n(u)?t.t(u.severityText)?{...u,severityNumber:e.Gn[u.severityText]}:(a.report(`record.dropped_malformed`,`${o} set a severityText that is not a log level. The library dropped the record.`),`malformed`):u===i?(a.report(`record.dropped_malformed`,`${o} changed the record to a shape that is not a record. The library dropped it.`),`malformed`):(a.report(s,`${o} returned a value that is not a record. The library dropped the record.`),r)}provided(){let e=this.deps.config.contextProvider;if(!e)return{};let{diagnostics:t}=this.deps,n=t.guard(`handler.threw`,`The contextProvider threw an error. The record has no attributes from it.`,()=>{let t=e();return t===void 0?{}:r.n(t)&&typeof t.then!=`function`?t:null});return n===null&&t.report(`config.invalid`,`contextProvider must return an object of attributes. The library ignores the value.`),n??{}}resource(){if(this.resourceCache)return this.resourceCache;let{config:t,identity:n,platform:r}=this.deps;return this.resourceCache={[e.wn]:t.serviceName,[e.Tn]:t.serviceVersion,[e.bn]:t.environment,[e.An]:e.rr,[e.jn]:e.ir,[e.kn]:e.nr,[e.xn]:r.platform,[e.En]:n.sessionId,[e.On]:n.tabId,[e.yn]:n.contextId,...t.metadata.userAgent?{[e.vn]:r.userAgent}:{},...!t.metadata.openfin||r.openfinUuid===void 0?{}:{[e.Cn]:r.openfinUuid},...!t.metadata.openfin||r.openfinName===void 0?{}:{[e.Sn]:r.openfinName}},this.resourceCache}},et=1e3,tt={start:`ui.start`,interaction:`ui.interaction`,navigation:`ui.navigation`,explicit:`ui.trace`,maxAge:`ui.trace`};function nt(e){return`${String(Math.round(e*et))}000`}function rt(e){return{name:tt[e.reason],kind:`internal`,traceId:e.traceId,spanId:e.spanId,parentSpanId:``,startMs:e.startedAt,endMs:e.endedAt,error:!1,attributes:{}}}function it(t){return{[e.Kn.kind]:t.kind,[e.Kn.parentId]:t.parentSpanId,[e.Kn.start]:nt(t.startMs),[e.Kn.end]:nt(t.endMs),[e.Kn.status]:t.error?`error`:`unset`,...t.link?{[e.Kn.linkTraceId]:t.link.traceId,[e.Kn.linkSpanId]:t.link.spanId}:{}}}var at={errors:async()=>(await Promise.resolve().then(()=>require("./errors-07pmZ7VY.cjs"))).ErrorCapture,network:async()=>(await Promise.resolve().then(()=>require("./network-BNHBI0Fc.cjs"))).NetworkCapture,interactions:async()=>(await Promise.resolve().then(()=>require("./interactions-BXzEel4F.cjs"))).InteractionCapture,webVitals:async()=>(await Promise.resolve().then(()=>require("./web-vitals-Df4Wsfx9.cjs"))).WebVitalsCapture,longFrames:async()=>(await Promise.resolve().then(()=>require("./long-frames-D9DfSWqv.cjs"))).LongFrameCapture,console:async()=>(await Promise.resolve().then(()=>require("./console-Dk6GH4yj.cjs"))).ConsoleCapture,uncleanExit:async()=>(await Promise.resolve().then(()=>require("./unclean-exit-CuBh-ee5.cjs"))).UncleanExitCapture,userTiming:async()=>(await Promise.resolve().then(()=>require("./user-timing-BWqzYF2Q.cjs"))).UserTimingCapture,reports:async()=>(await Promise.resolve().then(()=>require("./reports-CGK9YQch.cjs"))).ReportCapture,resourceTiming:async()=>(await Promise.resolve().then(()=>require("./resource-timing-DalulXiR.cjs"))).ResourceTimingCapture,lifecycle:async()=>(await Promise.resolve().then(()=>require("./lifecycle-B5yfH5is.cjs"))).LifecycleCapture,framePhases:async()=>(await Promise.resolve().then(()=>require("./profiler-frames-C9zJNd8_.cjs"))).FramePhasesCapture,framePacing:async()=>(await Promise.resolve().then(()=>require("./profiler-frames-C9zJNd8_.cjs"))).FramePacingCapture,replay:async()=>(await Promise.resolve().then(()=>require("./replay-Cab-lSit.cjs"))).ReplayCapture},ot=new WeakMap,st=0;function I(e){let t=ot.get(e);return t===void 0&&(t=++st,ot.set(e,t)),t}var L=Symbol.for(e.In),R=Symbol.for(e.Ln),ct=[`batching`,`retention`],lt=[`log`,`event`,`action`],z=`configure() could not read its options. The library drops each record and installs no capture until a configure() call sets redact to a function or null.`,B=`shutdown() got invalid options. The library discards the records in memory. An invalid clearStorage removes the "context" scope.`,V=`flush() got invalid options. The library waits the default 5000 ms.`,ut=new Set([`bus.role_resolved`,`bus.tab_id_changed`,`config.reconfigured`,`security.rotated`,`journey.adopted`,`journey.expired`]);function dt(e){return JSON.stringify({...e,urlTransform:e.urlTransform?I(e.urlTransform):void 0,webVitals:typeof e.webVitals==`object`?{loader:e.webVitals.loader!==void 0}:e.webVitals,ignoreUrls:e.ignoreUrls.map(String),propagateTraceHeaderTo:e.propagateTraceHeaderTo.map(String),userTiming:typeof e.userTiming==`object`?{include:e.userTiming.include?.map(String)}:e.userTiming,plugins:e.plugins.map(I)})}function ft(e){if(!r.n(e))return e;let t={...e};for(let e of[`url`,`endpoint`]){let n=t[e];typeof n==`string`&&(t[e]=a.a(n,!1))}return t}function pt(e){return{...e,endpoint:null,metricsEndpoint:null,tracesEndpoint:null,transport:null,transportOnExit:null,transportWorker:null,bus:{...e.bus,mode:`off`}}}function mt(e){return!!e.endpoint||!!e.metricsEndpoint||!!e.tracesEndpoint||!!e.transport||!!e.transportWorker}function H(e,t){return{status:e,accepted:0,stored:0,dropped:0,forwarded:0,pending:0,...t}}function U(e){return H(e.pending>0?`timeout`:`complete`,e)}function W(t){return t.sdkVersion===e.ir}var G=class n{isRotating(){return this.rotating}setConfigurationLocked(e){typeof e==`boolean`&&(this.config.lockConfiguration=e)}constructor(t,n){o.t(this,`rotating`,!1),o.t(this,`rotationSeq`,0),o.t(this,`profilerOn`,!1),o.t(this,`closingContext`,!1),o.t(this,`mismatchVersion`,null),o.t(this,`contextMismatch`,!1),o.t(this,`rotation`,void 0),o.t(this,`memoryStorage`,void 0),o.t(this,`storagePersistence`,`off`),o.t(this,`recordingDiagnostic`,!1),o.t(this,`holdingRecords`,!1),o.t(this,`heldDiagnostics`,[]),o.t(this,`diagnosticLogger`,new E(()=>this,e.Y)),o.t(this,`debugBuffer`,new Pe(()=>this.config.debugBuffer)),o.t(this,`explicitSecurityContext`,void 0),o.t(this,`ownerAdopted`,!1),o.t(this,`sdkVersion`,e.ir),o.t(this,`protocol`,e.M),o.t(this,`diagnostics`,void 0),o.t(this,`config`,void 0),o.t(this,`platform`,void 0),o.t(this,`identity`,void 0),o.t(this,`backing`,s.r()),o.t(this,`stores`,{local:()=>this.backing.local(),session:()=>this.backing.session(),opener:()=>this.backing.opener?.()??null}),o.t(this,`identityBuiltAs`,void 0),o.t(this,`sessionTouch`,void 0),o.t(this,`context`,new Ne),o.t(this,`breadcrumbs`,void 0),o.t(this,`tracing`,void 0),o.t(this,`sequence`,new je),o.t(this,`journey`,void 0),o.t(this,`builder`,void 0),o.t(this,`remote`,{sampling:null,changed:()=>{this.refreshCaptures()}}),o.t(this,`identityEpoch`,0),o.t(this,`errorHook`,void 0),o.t(this,`replayConsent`,void 0),o.t(this,`replay`,void 0),o.t(this,`remoteCaptureTimer`,void 0),o.t(this,`installedCaptureKey`,``),o.t(this,`replayBuiltKey`,``),o.t(this,`console`,void 0),o.t(this,`drops`,void 0),o.t(this,`meter`,void 0),o.t(this,`bus`,null),o.t(this,`busBuilt`,void 0),o.t(this,`busLoad`,void 0),o.t(this,`sender`,void 0),o.t(this,`senderLoad`,void 0),o.t(this,`pendingRecords`,new Ie(e=>{this.dropHeld(e)})),o.t(this,`pausedLoss`,new WeakSet),o.t(this,`carried`,[]),o.t(this,`sessionPicked`,!1),o.t(this,`deliveryClosed`,!1),o.t(this,`parkedSender`,void 0),o.t(this,`retiring`,void 0),o.t(this,`startFailed`,!1),o.t(this,`running`,!1),o.t(this,`openGate`,void 0),o.t(this,`startGate`,new Promise(e=>{this.openGate=e})),o.t(this,`captures`,[]),o.t(this,`captureGeneration`,0),o.t(this,`captureOnce`,{webVitals:!1,navigationTiming:!1,longFrames:!1,uncleanExit:!1,userTiming:!1}),o.t(this,`bootBuffer`,new Ie(e=>{this.dropHeld(e)})),o.t(this,`forwardBuffer`,[]),o.t(this,`forwardScheduled`,!1),o.t(this,`roleResolved`,!1),o.t(this,`started`,Promise.resolve()),o.t(this,`ready`,!1),o.t(this,`destroyed`,!1),o.t(this,`stopping`,void 0),o.t(this,`lastSendAt`,null),o.t(this,`lastGapAt`,0),o.t(this,`limits`,void 0),o.t(this,`journeyOptions`,void 0),o.t(this,`tunablesLocked`,!1),o.t(this,`degraded`,void 0),o.t(this,`serverReported`,!1),o.t(this,`onPageHide`,()=>{S(this),this.dropPaused(),this.role()===`forwarder`&&(this.tracing.end(),this.sendForwarded())}),o.t(this,`busCanAccept`,(e,t)=>this.bus?.isRegistered(e,t)??!1),o.t(this,`busAccept`,(e,t,n)=>{this.destroyed||this.ensureBus().then(r=>{r&&!this.destroyed&&this.diagnostics.guard(`bus.send_failed`,`The bus could not accept a direct message from a child frame.`,()=>{r.acceptDirect(e,t,n)})})}),o.t(this,`reportLoss`,(e,t,n,r)=>{this.drops.add(e,t,n,r)}),o.t(this,`reportGap`,(t,n)=>{this.drops.add(t.reason,n.flatMap(e=>e.records),n.map(e=>e.id));let r=Date.now();r-this.lastGapAt<6e4||(this.lastGapAt=r,new E(()=>this,e.Yn).warn(`stored records were dropped before delivery`,{"gap.batches":t.batches,"gap.records":t.records,"gap.reason":t.reason}))}),this.diagnostics=new A(typeof t.onDiagnostic==`function`?t.onDiagnostic:void 0),this.platform=a.n(this.diagnostics),this.degraded=n||this.onServer(),this.config=f.r(this.allowed(t),this.diagnostics),this.explicitSecurityContext=!!t.securityContext?.id,this.config.securityContext.id||=s.i(this.diagnostics),this.diagnostics.setPolicy(this.config.diagnostics.throttleMs,this.config.diagnostics.consoleFallback),this.identityBuiltAs=this.config.identity,this.identity=s.s(this.diagnostics,this.stores,this.config.correlation.sessionIdleMs),this.sessionTouch=new s.n(this.diagnostics,this.stores,this.config.correlation.sessionIdleMs),this.breadcrumbs=new Me(this.config.captureLimits.breadcrumbs);let r=e=>h.i(e,this.config.sampling.defaultRate);this.tracing=new pe(this.diagnostics,this.config.correlation.traceMaxAgeMs??1/0,this.config.otelLoader,{enabled:()=>this.config.tracesEndpoint!==null,keeps:r,onEnd:e=>{r(e.traceId)&&this.recordSpan(rt(e))}}),this.limits={...this.config.limits},this.console=new Ae(this.config.consoleOutput,this.diagnostics,this.limits),this.drops=new Fe(this.config,this.diagnostics),this.journeyOptions={...m.t,maxAgeMs:this.config.journey.maxAgeMs},this.journey=new m.n(this.journeyOptions,this.diagnostics,this.identity.contextId,e=>{this.bus?.broadcastJourney(e)},this.stores),this.builder=new $e({remote:this.remote,config:this.config,limits:this.limits,diagnostics:this.diagnostics,context:this.context,journey:this.journey,tracing:this.tracing,sequence:this.sequence,identity:this.identity,platform:this.platform,debug:this.debugBuffer}),this.meter=new Oe(()=>this.config.metrics.intervalMs,(e,t,n)=>{this.emitPoint(e,t,n)},this.diagnostics,this.config.metrics),this.diagnostics.setHandler(this.diagnosticHandler()),this.syncProfiler()}diagnosticHandler(){return this.config.diagnostics.records===!1?this.config.onDiagnostic:e=>{this.recordDiagnostic(e),this.config.onDiagnostic?.(e)}}recordDiagnostic(e){let{records:t}=this.config.diagnostics;if((t===!0||t!==!1&&t.includes(e.code))&&!this.recordingDiagnostic){if(this.holdingRecords)this.heldDiagnostics.push(e);else{this.recordingDiagnostic=!0;try{(ut.has(e.code)?this.diagnosticLogger.info:this.diagnosticLogger.warn)(e.message,{"diagnostic.code":e.code,"diagnostic.count":e.count,"diagnostic.detail":ft(e.detail)})}finally{this.recordingDiagnostic=!1}}}}dropHeldRecords(){let e=this.heldDiagnostics.length;this.heldDiagnostics=[],e>0&&this.diagnostics.count(`record.dropped_during_rotation`,e)}addBreadcrumb(e,t){this.rotating||this.destroyed||this.diagnostics.guard(`record.sanitize_failed`,`The library could not add the breadcrumb.`,()=>{let n={t:Date.now(),category:`custom`,message:u.i(String(e),this.limits.maxBodyChars)};if(t!==void 0){let e=u.n(t,this.limits,this.diagnostics);n.data=r.n(e)?e:{value:e}}this.breadcrumbs.push(n)})}recordMetric(e,t,n){!this.destroyed&&!this.rotating&&this.config.enabled&&this.meter.record(e,t,n)}startMeasure(e,t){let n=this.identityEpoch,r=()=>!this.destroyed&&!this.rotating&&(!this.config.securityContext.isolation||this.identityEpoch===n),i=this.diagnostics.guard(`record.sanitize_failed`,`The library could not read the attributes of the measure.`,()=>({...t}));return ge(this.diagnostics.guard(`record.sanitize_failed`,`The library could not read the name of the measure.`,()=>`${e}`)??``,i??{},this.tracing.request().span,{metric:(e,t,n)=>{r()&&this.recordMetric(e,t,n)},span:e=>{r()&&this.recordSpan(e)}})}recordSpan(t){if(this.config.tracesEndpoint===null)return;let{record:n}=this.builder.build({level:`INFO`,type:`span`,body:t.name,namespace:e.sr,payload:t.attributes,fixed:it(t),trace:{traceId:t.traceId,spanId:t.spanId,traceFlags:1}});this.emit(n)}emitPoint(t,n,r){if(this.destroyed)return;let{record:i}=this.builder.build({level:`INFO`,type:`metric`,body:t,namespace:e.Vt,payload:n,fixed:r,aggregated:!0});this.emit(i)}syncProfiler(){let e=this.config.profiler.enabled&&this.config.enabled;if(e===this.profilerOn)return;this.profilerOn=e;let t=c.t();if(!e){t.collect(!1),t.detach();return}let n={capacity:this.config.profiler.maxProbes,intervalMs:()=>this.config.metrics.intervalMs,emit:(e,t,n)=>{this.emitPoint(e,t,n)},diagnostics:this.diagnostics,ready:()=>!this.rotating||this.closingContext,outlier:(e,t)=>{this.breadcrumbs.push({t:Date.now(),category:`profile`,message:`${e} ${String(Math.round(t))} ms`})}};t.attach(n)}setReplay(e){this.replayConsent=e,e?this.replay?.start():this.replay?.stop()}collectPoints(){this.meter.collect(),this.profilerOn&&c.t().collect(!1)}advanceIdentity(){this.identityEpoch++,this.profilerOn&&this.config.securityContext.isolation&&c.t().reset(),this.remote.sampling=null,this.refreshCaptures()}static pinned(){return globalThis[L]??null}static current(){let e=n.local;if(e)return e.destroyed?null:e;let t=n.pinned();return t&&W(t)?t:null}static stopped(){let e=n.local;if(e?.destroyed)return e;let t=globalThis[R];return t&&W(t)?t:null}isDestroyed(){return this.destroyed}static configure(e,t=!1){try{return n.startOrUpdate(e,t)}catch(e){let t=n.current();if(t?.tunablesLocked)return t.diagnostics.report(`config.invalid`,`configure() could not read its options. The library keeps the current settings.`,void 0,e),t;let r=t??n.startOrUpdate({},!0);return r.refuse(e),r}}refuse(t){this.startFailed=!0;let n=f.r({redact:f.t},new A,this.config);f.n(this.config,n),l.n(()=>{console.warn(`${e.Mt} ${z}`)}),this.diagnostics.report(`config.invalid`,z,void 0,t),this.rehookHeld()}static startOrUpdate(e,t){let r=n.local;if(r&&!r.destroyed)return r.reconfigure(e),r;n.local=null;let i=n.pinned();if(i){if(!W(i))return n.startDegraded(e,i.sdkVersion,t);if(!i.destroyed)return i.reconfigure(e),i}let a=new n(e,!1);return globalThis[L]=a,Reflect.deleteProperty(globalThis,R),t||a.launch(),a}static startDegraded(t,r,i){let a=new n(t,!0);n.local=a;let o=typeof r==`string`?r:`before 0.9.0`;return a.mismatchVersion=o,a.diagnostics.report(`runtime.version_mismatch`,`Another copy of the library, version ${o}, owns the page runtime. This copy, version ${e.ir}, runs in console-only mode and installs no capture. Load one version of the library on the page.`,{found:o,own:e.ir}),i||a.launch(),a}reconfigure(e){if(this.rotating){this.diagnostics.report(`config.locked`,`Configuration cannot change during security-context rotation.`);return}if(this.config.lockConfiguration){let t=f.r(e,this.diagnostics,this.config);K(this.config,t)||this.diagnostics.report(`config.locked`,`Runtime configuration is locked. Use setConfigurationLocked(false) to unlock it explicitly.`);return}S(this);let t=this.keepDestination(this.keepRouting(this.allowed(e)));!this.tunablesLocked&&t.securityContext?.id&&(this.explicitSecurityContext=!0);let n=f.r(t,this.diagnostics,this.config),r=this.tunablesLocked?[`correlation`,`storage`]:[];for(let e of r)K(n[e],this.config[e])||(this.diagnostics.report(`config.invalid`,`${e} cannot change after startup. The library keeps the current settings.`),Object.assign(n,{[e]:this.config[e]}));this.keepStartupTunables(n);let{redact:i,processors:a,enabled:o}=this.config;o&&!n.enabled&&this.collectPoints(),f.n(this.config,n),this.config.redact!==f.t&&(this.startFailed=!1),(this.config.redact!==i||this.config.processors!==a)&&this.debugBuffer.clear(),this.breadcrumbs.resize(this.config.captureLimits.breadcrumbs),this.diagnostics.setHandler(this.diagnosticHandler()),this.diagnostics.setPolicy(this.config.diagnostics.throttleMs,this.config.diagnostics.consoleFallback),this.builder.invalidateResource(),this.console.update(this.config.consoleOutput),this.keepBuiltIdentity(),this.syncProfiler(),this.launch(),this.running&&o!==this.config.enabled&&this.sender?.hold(!this.config.enabled),this.refreshCaptures(),this.roleResolved&&this.syncSender(),this.diagnostics.report(`config.reconfigured`,`A later configure() call updated the runtime.`)}onServer(){return this.platform.platform===`node`}allowed(e){return this.degraded?(this.onServer()&&!this.serverReported&&mt(e)&&(this.serverReported=!0,this.diagnostics.report(`config.invalid`,`The library runs console-only on Node. It sends no record and installs no capture. It ignores endpoint, metricsEndpoint, tracesEndpoint, transport and transportWorker.`)),pt(e)):e}keepRouting(t){if(!this.tunablesLocked||this.degraded||!this.config.securityContext.isolation)return t;let n=f.r(t,new A,this.config),r=e.Pn.filter(e=>!K(n[e],this.config[e]));if(n.securityContext.id!==this.config.securityContext.id&&r.push(`securityContext.id`),r.length===0)return t;let i={...t};for(let t of e.Pn)r.includes(t)&&Reflect.deleteProperty(i,t);if(r.includes(`securityContext.id`)){let e={...t.securityContext};Reflect.deleteProperty(e,`id`),i.securityContext=e}return this.diagnostics.report(`config.invalid`,`Isolation refuses changes to ${r.join(`, `)}. Use rotateSecurityContext() for these changes. To permit them, set securityContext.isolation: false in a separate configure() call. The other settings apply.`),i}keepStartupTunables(e){if(this.senderLoad!==void 0&&this.keepSections(e,ct),!this.tunablesLocked){Object.assign(this.limits,e.limits),this.journeyOptions.maxAgeMs=e.journey.maxAgeMs;return}this.keepSections(e,[`limits`]);for(let t of[`mode`,`openFinRole`])e.bus[t]!==this.config.bus[t]&&(this.diagnostics.report(`config.invalid`,`bus.${t} cannot change after startup. The library keeps "${this.config.bus[t]}".`,{requested:e.bus[t]}),Object.assign(e.bus,{[t]:this.config.bus[t]}));let{maxAgeMs:t}=this.config.journey;e.journey.maxAgeMs!==t&&(this.diagnostics.report(`config.invalid`,`journey.maxAgeMs cannot change after startup. It stays ${String(t)}.`,{requested:e.journey.maxAgeMs}),e.journey.maxAgeMs=t);let{maxProbes:n}=this.config.profiler;e.profiler.maxProbes!==n&&(this.diagnostics.report(`config.invalid`,`profiler.maxProbes cannot change after startup. It stays ${String(n)}.`,{requested:e.profiler.maxProbes}),e.profiler.maxProbes=n),e.otelLoader!==this.config.otelLoader&&(this.diagnostics.report(`config.invalid`,`otelLoader cannot change after startup. The library keeps the current loader.`),e.otelLoader=this.config.otelLoader)}keepSections(e,t){for(let n of t)K(e[n],this.config[n])||(this.diagnostics.report(`config.invalid`,`${n} cannot change after startup. The current values stay.`,{requested:e[n]}),Object.assign(e,{[n]:this.config[n]}))}keepDestination(e){if(this.senderLoad===void 0)return e;let t=e;for(let n of[`transport`,`transportWorker`]){let r=e[n],i=typeof r==`function`&&this.config[n]===void 0,a=r===null&&this.config[n]!==void 0;(i||a)&&(this.diagnostics.report(`config.invalid`,`You cannot add or remove ${n} after the delivery stack loads. The current transport stays.`),t={...t},Reflect.deleteProperty(t,n))}return(t.endpoint===null||t.endpoint===``)&&this.config.transport===void 0&&(this.diagnostics.report(`config.invalid`,`You cannot remove the endpoint after the delivery stack loads. The current endpoint stays.`),t={...t,endpoint:void 0}),t}keepBuiltIdentity(){if(!this.tunablesLocked){this.identityBuiltAs=this.config.identity;return}let e=this.identityBuiltAs;this.config.identity!==e&&(this.diagnostics.report(`config.invalid`,`identity cannot change after startup. It stays ${e}.`,{requested:this.config.identity}),this.config.identity=e)}launch(){this.startFailed||(this.tunablesLocked||(this.tunablesLocked=!0,this.config.enabled||this.drops.add(`disabled`,this.rehookHeld())),!this.running&&this.config.enabled&&this.start())}start(){this.running=!0,this.identityBuiltAs===`storage`&&!this.onServer()&&(this.backing=s.t);let{sessionIdleMs:e,traceMaxAgeMs:t}=this.config.correlation,{sessionId:n,tabId:r}=s.s(this.diagnostics,this.stores,e);this.sessionTouch=new s.n(this.diagnostics,this.stores,e),this.sessionPicked?this.sessionTouch.restart(this.identity.sessionId):this.identity.sessionId=n,this.identity.tabId=r,this.builder.invalidateResource(),this.breadcrumbs.retain(e=>!lt.includes(e.category)),this.tracing.setup(t??1/0,this.config.otelLoader),this.tracing.loadOtel();for(let e of this.rehookHeld())this.bootBuffer.push(e,this.config.buffering.maxHeldRecords);this.openGate(),this.init()}rehookHeld(){return this.bootBuffer.take().map(e=>this.builder.rehook(e)).filter(e=>e!==null)}async init(){this.degraded||addEventListener(`pagehide`,this.onPageHide);let e=this.installCaptures();this.started=this.boot(),await this.started,await e}async boot(){try{let e=this.journey.bootstrap();this.config.bus.mode!==`off`&&await this.ensureBus(),this.roleResolved=!0,await this.syncSender(),await e}catch(e){this.diagnostics.report(`pipeline.crashed`,`Startup failed. The runtime continues with reduced function.`,void 0,e)}finally{this.ready=!0,this.releaseBootBuffer()}}ensureBus(){return this.busLoad??=this.startBus(),this.busLoad}constructBus(){return this.busBuilt??=this.buildBus(),this.busBuilt}async startBus(){let e=await this.constructBus();if(!e)return null;try{return await e.start(),e}catch(e){return this.diagnostics.report(`pipeline.crashed`,`The bus did not start. This context sends its own records.`,void 0,e),null}}async buildBus(){try{await this.startGate;let{Bus:e}=await Promise.resolve().then(()=>require("./bus-Dj8IEVcC.cjs"));if(this.destroyed)return null;let t=new e(this.config,this.diagnostics,this.platform,this.identity.contextId,this.identity.tabId,{onSecurityContext:e=>{if(this.explicitSecurityContext&&this.config.securityContext.id!==e)return this.contextMismatch=!0,this.diagnostics.report(`security.context_mismatch`,`The configured security context differs from the upstream owner.`),!1;if(this.contextMismatch=!1,this.config.securityContext.id!==e){if(this.ownerAdopted){S(this),this.drops.add(`security_context`,[...this.bootBuffer.take(),...this.pendingRecords.take(),...this.forwardBuffer]),this.forwardBuffer=[],this.context.clear(),this.breadcrumbs.clear();let e=this.rotating;this.rotating=!0,this.collectPoints(),this.profilerOn&&c.t().reset();let t=this.sessionTouch.stored();this.resetSession(t!==void 0&&t!==this.identity.sessionId?t:s.i(this.diagnostics)),this.rotating=e,this.advanceIdentity()}this.config.securityContext.id=e}return this.ownerAdopted=!0,!0},onRecords:e=>{this.ingestForwarded(e)},paused:()=>!this.config.enabled,onJourney:e=>{this.journey.applyRemote(e)},onJourneyRequest:()=>this.journey.current(),onTabConflict:()=>{this.regenerateTabId()},onFlush:e=>this.flushFor(e,!1),remote:this.remote});return this.bus=t,t}catch(e){return this.diagnostics.report(`pipeline.crashed`,`The bus did not load. This context sends its own records.`,void 0,e),null}}role(){return this.bus?.getRole()??`sender`}syncSender(){return!this.running||!this.config.enabled||this.deliveryClosed||this.destroyed||!this.hasDestination()||this.role()!==`sender`?Promise.resolve():this.loadSender()}hasDestination(){return!!this.config.endpoint||this.config.transport!==void 0}loadSender(){return this.senderLoad??=this.buildSender(),this.senderLoad}async buildSender(){try{let{Sender:e}=await Promise.resolve().then(()=>require("./sender-CFu98DAB.cjs")),t=this.destroyed?null:await e.create({storage:this.memoryStorage,onStorage:e=>{e.name===`memory`&&(this.memoryStorage=e)},onPersistence:e=>{this.storagePersistence=e},config:this.config,diagnostics:this.diagnostics,onGap:this.reportGap,onLoss:this.reportLoss,remote:this.remote,beforeExit:()=>{S(this),this.collectPoints(),this.tracing.end()},onSent:e=>{this.lastSendAt=e}});if(!t||this.destroyed){await t?.discard();return}if(this.deliveryClosed){await this.parkSender(t);return}this.sender=t,this.config.enabled||t.hold(!0)}catch(e){this.senderLoad=void 0,this.diagnostics.report(`pipeline.crashed`,`The delivery stack did not load. The library does not send records.`,{held:this.pendingRecords.length},e),this.drops.add(`load_failed`,this.pendingRecords.records)}for(let e of this.pendingRecords.take())this.sender?.push(e);if(this.sender&&this.carried.length>0){let e=this.carried;this.carried=[],await this.adoptStored(this.sender,e)}}async adoptStored(e,t){await this.diagnostics.guardAsync(`storage.degraded`,`The library could not store the carried batches under the new context.`,()=>e.adopt(t,this.config.securityContext.id))}refreshCaptures(){if(clearTimeout(this.remoteCaptureTimer),this.remoteCaptureTimer=void 0,this.destroyed)return;let e=this.remote.sampling?.wire();e&&(this.remoteCaptureTimer=setTimeout(()=>{this.refreshCaptures()},e.ttlMs),i.t(this.remoteCaptureTimer)),this.captureState(this.effectiveCapture())!==this.installedCaptureKey&&this.installCaptures()}captureState(e){let{enabled:t,framePhases:n,framePacing:r}=this.config.profiler;return`${String(this.config.enabled)}${dt(e)}${String(t&&n)}${String(t&&r)}${this.replayState(e)}`}replayState(e){let{replay:t}=this.config;return t.enabled?JSON.stringify([t.loader&&I(t.loader),t.onSegment&&I(t.onSegment),I(t.recordOptions),t.endpoint,t.requireConsent,t.mode,t.maskText,t.maskInputs,t.maskSelectors,t.blockSelectors,t.recordCanvas,t.bufferMs,t.plugins.map(I),e.fullUrls,e.ignoreUrls.map(String)]):``}effectiveCapture(){let t={...this.config.capture},n=this.remote.sampling?.current()?.capture;for(let r of e.dn){let e=n?.[r];if(t.remoteToggles.includes(r)&&e!==void 0){if(e&&typeof t[r]==`object`)continue;t[r]=e}}return t}async installCaptures(){if(this.degraded||!this.running)return;let t=++this.captureGeneration,n=this.effectiveCapture();if(this.installedCaptureKey=this.captureState(n),!this.config.enabled){this.uninstallCaptures();return}let r=this.replayState(n);r!==this.replayBuiltKey&&(this.replayBuiltKey=``);let i=r!==``&&r===this.replayBuiltKey?this.replay:void 0,a=[],{profiler:o}=this.config;(n.errors||n.rejections||n.resourceErrors)&&a.push(`errors`),(n.fetch||n.xhr)&&a.push(`network`),(n.interactions||n.navigation)&&a.push(`interactions`),n.webVitals&&a.push(`webVitals`),n.longFrames&&a.push(`longFrames`),(typeof n.console==`object`?n.console.levels?.length!==0:n.console)&&a.push(`console`),n.uncleanExit&&a.push(`uncleanExit`),n.userTiming&&a.push(`userTiming`),n.reports&&a.push(`reports`),n.resourceTiming&&a.push(`resourceTiming`),n.lifecycle&&a.push(`lifecycle`),o.enabled&&o.framePhases&&a.push(`framePhases`),o.enabled&&o.framePacing&&a.push(`framePacing`),this.config.replay.enabled&&!i&&a.push(`replay`);let[s,c]=await Promise.all([Promise.all(a.map(e=>this.loadCapture(e))),n.webSocket?this.loadWebSocket():void 0]);if(t!==this.captureGeneration||this.destroyed)return;this.uninstallCaptures(i);let l={isActive:()=>!this.destroyed&&!this.rotating,config:Object.assign(Object.create(this.config),{capture:n}),diagnostics:this.diagnostics,breadcrumbs:this.breadcrumbs,tracing:this.tracing,logger:new ae(()=>this,e.P),once:this.captureOnce,recordMetric:(e,t,n)=>{this.recordMetric(e,t,n)},recordSpan:e=>{this.recordSpan(e)},sessionId:()=>this.identity.sessionId,onError:e=>{this.errorHook=e},setContext:(e,t)=>{this.context.merge({[e]:t??null})},replayConsent:()=>this.replayConsent};s.forEach((e,t)=>{if(e){let n=new e(l);this.captures.push(n),a[t]===`replay`&&(this.replay=n,this.replayBuiltKey=r)}});let u=c?[...n.plugins,new c(this.diagnostics,l.config)]:n.plugins;for(let e of u)this.captures.push(this.pluginCapture(e));for(let e of this.captures)this.diagnostics.guard(`capture.install_failed`,`The library could not install the ${e.name} capture.`,()=>{e.install()})}uninstallCaptures(e){for(let t of this.captures)t!==e&&this.diagnostics.guard(`capture.install_failed`,`The library could not uninstall the ${t.name} capture.`,()=>{t.uninstall()});this.captures.length=0,this.replay=e,e&&this.captures.push(e)}loadWebSocket(){return this.diagnostics.guardAsync(`capture.install_failed`,`The library could not load the webSocket capture.`,async()=>(await Promise.resolve().then(()=>require("./web-socket-sm3rD-A_.cjs"))).WebSocketCapture)}pluginCapture(t){let{name:n}=t,r=(e,t,n)=>{this.recordMetric(e,t,n)},i=t=>{this.diagnostics.report(`config.invalid`,e.St,void 0,t)},a={logger:new E(()=>this,`${e.P}.${n}`),counter:(e,t={})=>k(e,t,r,i),histogram:(e,t={})=>De(e,t,r,i),addBreadcrumb:(e,t)=>{this.addBreadcrumb(e,t)},ownRequest:d.r};return{name:n,install:()=>{t.install(a)},uninstall:()=>{t.uninstall()}}}loadCapture(e){return this.diagnostics.guardAsync(`capture.install_failed`,`The library could not load the ${e} capture.`,at[e])}registerWorker(e,t={}){let n=!1,r;return this.destroyed?()=>void 0:(this.constructBus().then(i=>{!i||this.destroyed||n||(this.diagnostics.guard(`bus.send_failed`,`The library could not register the worker.`,()=>{r=i.attachWorker(e,t)}),this.ensureBus())}),()=>{n=!0,r?.()})}registerFrame(e,t){let n=!1,r;return this.constructBus().then(i=>{!i||this.destroyed||n||(r=this.diagnostics.guard(`bus.send_failed`,`The frame could not be registered.`,()=>i.registerFrame(e,t)),this.ensureBus())}),()=>{n=!0,r?.()}}async destroy(e){let{discard:t,scope:n}=this.shutdownRule(e);this.stopping??=this.stop(t),await this.stopping,n!==void 0&&await this.clearStorage(n)}async stop(e){e||(S(this),this.collectPoints(),this.tracing.end()),this.profilerOn&&(this.profilerOn=!1,c.t().detach()),this.destroyed=!0,this.backing=s.r(),C(this),this.collectPoints(),clearTimeout(this.remoteCaptureTimer),this.remoteCaptureTimer=void 0,this.degraded||removeEventListener(`pagehide`,this.onPageHide),this.uninstallCaptures();let t=e?this.discardHeld():this.flushHeld();this.journey.destroy(),this.bus?.destroy(),await t,await this.senderLoad,await this.rotation?.catch(()=>void 0);let r=this.parkedSender;this.parkedSender=void 0,await this.diagnostics.guardAsync(`pipeline.crashed`,`The delivery stack of the old context did not stop at shutdown. The library leaves its stored batches in storage.`,async()=>{await(e?r?.discard():r?.retire(`retain`,0,this.config.securityContext.id))}),await this.memoryStorage?.close(),n.pinned()===this&&(Reflect.deleteProperty(globalThis,L),globalThis[R]=this)}shutdownRule(e){let t=this.readOptions(e,B);if(t===void 0)return{discard:!0};let{pending:n,clearStorage:r}=t,i=r==null,a=i||r===`context`||r===`namespace`,o;i||(o=r===`namespace`?`namespace`:`context`);let s=n===void 0||n===`flush`;return(!a||!(s||n===`discard`)||n===`flush`&&o)&&this.diagnostics.report(`config.invalid`,B),{discard:!s||o!==void 0,scope:o}}async flushHeld(){this.sender&&this.releaseBootBuffer(),this.dropPaused();let e=this.sender?.destroy();this.sendForwarded();let t=[...this.bootBuffer.take(),...this.pendingRecords.take()];this.drops.add(`load_failed`,this.unreported(t)),await e}async discardHeld(){let e=[...this.bootBuffer.take(),...this.pendingRecords.take(),...this.forwardBuffer];this.forwardBuffer=[],this.breadcrumbs.clear(),this.debugBuffer.clear(),this.context.clear(),this.journey.applyRemote(null);let t=await this.sender?.discard()??[];this.drops.add(`discarded`,this.unreported([...e,...t]))}async clearStorage(e){this.tunablesLocked&&await this.diagnostics.guardAsync(`storage.degraded`,`The library could not remove the stored batches at shutdown.`,async()=>{let{clearStored:t}=await Promise.resolve().then(()=>require("./stored-context-CPLlzgpm.cjs")),n=this.carried.map(e=>e.id);this.carried=[],await t(this.storeAccess(),e,n,this.identityBuiltAs===`storage`&&!this.onServer())})}emit(e){if(!e||this.destroyed)return;if(this.rotating&&!this.closingContext){this.drops.add(`security_context`,[e]);return}this.sessionTouch.touch(this.identity.sessionId);let t=e.severityText===`ERROR`||e.severityText===`FATAL`,n=t?[...this.debugBuffer.drain(),e]:[e];t&&this.errorHook?.(e);for(let e of n)this.ready?this.route(e):this.bootBuffer.push(e,this.config.buffering.maxHeldRecords)}route(e){this.role()===`forwarder`?this.forward(e):this.deliver(e)}deliver(e){if(this.deliveryClosed){this.drops.add(`security_context`,[e]);return}if(this.sender){this.sender.push(e);return}let t=!this.config.enabled&&this.hasDestination();!this.senderLoad&&!t?(this.diagnostics.count(`record.dropped_no_destination`),this.hasDestination()&&this.drops.add(`load_failed`,[e])):this.pendingRecords.push(e,this.config.buffering.maxHeldRecords)}dropPaused(){if(this.config.enabled)return;let e=this.unreported([...this.pendingRecords.records,...this.sender?.records()??[]]);for(let t of e)this.pausedLoss.add(t);this.drops.add(`disabled`,e)}unreported(e){return e.filter(e=>!this.pausedLoss.has(e))}dropHeld(e){this.diagnostics.count(`record.dropped_boot_buffer_full`),this.drops.add(`buffer_full`,[e])}forward(e){this.forwardBuffer.push(e),this.forwardScheduled||(this.forwardScheduled=!0,queueMicrotask(()=>{this.forwardScheduled=!1,this.sendForwarded()}))}sendForwarded(){let e=this.forwardBuffer;this.forwardBuffer=[];let{bus:t}=this;return e.length===0||!t?0:t.sendRecords(e)}ingestForwarded(e){if(this.destroyed)return;if(!Array.isArray(e)){this.diagnostics.count(`record.dropped_malformed`);return}let n=[];for(let r of e){if(!t.n(r)){this.diagnostics.count(`record.dropped_malformed`);continue}if(r.attributes[`uiobs.debug_buffer`]!==!0&&!h.a(r,this.config,this.remote.sampling?.current()??null)){this.diagnostics.count(`record.dropped_by_sampling`);continue}let e=this.builder.redactForwarded(r);e&&n.push(e)}if(this.rotating)this.drops.add(`security_context`,n);else if(!this.config.enabled)this.drops.add(`disabled`,n);else for(let e of n)this.deliver(e)}releaseBootBuffer(){let e=this.bootBuffer.take(),{processors:t,redact:n}=this.config,r=t.length===0&&n===void 0?this.journey.current():null;for(let t of e)r&&!t.attributes[`journey.id`]&&(t.attributes[`journey.id`]=r.id,t.attributes[`journey.name`]=r.name),this.route(t)}regenerateTabId(){let e=s.i(this.diagnostics);this.diagnostics.report(`bus.tab_id_changed`,`Another context uses this tab id. A duplicated tab is the usual cause. The library makes a new tab id.`,{was:this.identity.tabId,now:e}),this.identity.tabId=e,s.a(e,this.diagnostics,this.stores),this.builder.invalidateResource(),this.bus?.setTabId(e)}newSession(){this.destroyed||(S(this),this.resetSession(s.i(this.diagnostics)))}resetSession(e){this.sessionPicked=!0,this.collectPoints(),this.tracing.rotate(`explicit`),this.journey.end(),this.breadcrumbs.clear(),this.debugBuffer.clear(),this.replay?.reset(),this.identity.sessionId=e,this.sessionTouch.restart(e),this.builder.invalidateResource()}rotateSecurityContext(e,t={}){if(this.destroyed)return Promise.reject(Error(`The runtime has stopped.`));if(!this.tunablesLocked)return Promise.reject(Error(`The runtime is not configured. Call configure() before rotateSecurityContext().`));S(this),this.rotating=!0;let n=++this.rotationSeq,r=(this.rotation??Promise.resolve()).catch(()=>void 0).then(()=>this.runRotation(e,t,n));this.rotation=r;let i=()=>{this.rotation===r&&(this.rotation=void 0,this.rotating=!1,this.retiring=void 0)};return r.then(i,i),r}async runRotation(e,t,n){if(this.destroyed)throw Error(`The runtime has stopped.`);if(await this.started,this.role()===`forwarder`)throw Error(`Rotate the security context on the upstream owner, or use bus.mode: sender for an independent identity.`);let r;try{r=(await Promise.resolve().then(()=>require("./rotation-fTnNJcfH.cjs"))).rotateContext}catch(e){throw this.diagnostics.report(`pipeline.crashed`,`The library could not load the security-context rotation.`,void 0,e),await this.closeDelivery(),e}if(this.isDestroyed())throw Error(`The runtime has stopped.`);try{await r(this.rotationHost(),e,t,n)}finally{this.dropHeldRecords()}}rotationHost(){return{runtime:this,quiet:new A,senderLoaded:async()=>{await this.senderLoad},holdRecords:e=>{this.holdingRecords=!0;try{return e()}finally{this.holdingRecords=!1}},allowed:e=>this.allowed(e),closeDelivery:()=>this.closeDelivery(),closeContext:()=>{this.closingContext=!0;try{this.collectPoints(),this.tracing.end(),this.journey.end()}finally{this.closingContext=!1}},takeOld:()=>{let e=[...this.bootBuffer.take(),...this.pendingRecords.take(),...this.forwardBuffer],t=this.sender??this.parkedSender;this.retiring=t;let n=this.carried;return this.forwardBuffer=[],this.carried=[],this.sender=void 0,this.senderLoad=void 0,this.parkedSender=void 0,{held:e,sender:t,closed:this.deliveryClosed,carried:n}},drop:e=>{this.drops.add(`security_context`,this.unreported(e))},storeAccess:()=>this.storeAccess(),advanceIdentity:()=>{this.advanceIdentity()},openDelivery:async()=>{this.deliveryClosed=!1,await this.syncSender(),this.bus?.rotateContext()},endRotation:e=>{if(this.rotating=e!==this.rotationSeq,this.rotating){this.dropHeldRecords();return}let t=this.heldDiagnostics;this.heldDiagnostics=[];for(let e of t)this.recordDiagnostic(e)},route:e=>{this.route(e)},adopt:async e=>{!this.config.enabled||this.destroyed?this.carried=[...e]:await this.sender?.adopt(e,this.config.securityContext.id)}}}async closeDelivery(){this.deliveryClosed=!0,this.diagnostics.report(`security.rotation_failed`,`The security-context rotation failed. The library sends no record until a rotation succeeds.`),await this.senderLoad;let e=this.sender;this.sender=void 0,this.senderLoad=void 0,e&&await this.parkSender(e),this.drops.add(`security_context`,this.unreported(this.pendingRecords.take()))}async parkSender(e){this.parkedSender=e,await this.diagnostics.guardAsync(`pipeline.crashed`,`The delivery stack of the old context did not stop. The next rotation that succeeds retires it.`,()=>e.pause(this.config.securityContext.id))}async debugBundle(t){let{configSummary:n}=await Promise.resolve().then(()=>require("./debug-bundle-DMzUfiQc.cjs")),{record:r}=this.builder.build({level:`INFO`,type:`system`,body:`debug bundle`,namespace:e.Y,payload:{[e.c]:this.breadcrumbs.snapshot()}},!0),i=r?.attributes??{},a=i[e.c],o=i[e.v];return{createdAt:new Date().toISOString(),sdkVersion:this.sdkVersion,health:t,diagnostics:this.diagnostics.snapshot(),resource:r?.resource??{},pageUrl:typeof o==`string`?o:``,breadcrumbs:Array.isArray(a)?a:[],debugBuffer:this.debugBuffer.snapshot(),config:n(this.config,this.limits,this.diagnostics)}}async health(){let e=this.sender?.stats(),t=[];this.mismatchVersion&&t.push(`runtime.version_mismatch`),this.contextMismatch&&t.push(`security.context_mismatch`);let{redact:n,processors:r}=this.config;(n===f.t||r.includes(f.t))&&t.push(`records.refused`),this.deliveryClosed?t.push(`security.rotation_failed`):this.ready&&this.config.enabled&&this.hasDestination()&&this.role()===`sender`&&!this.sender&&t.push(`sender.unavailable`);let{sourcePolicy:i,maxMessageBytes:a,maxRecordsPerMessage:o,maxMessagesPerSecond:s}=this.config.bus;return{delivery:{pending:(e?.pending??0)+this.heldRecords(),inFlight:e?.inFlight??0,stored:await this.storedBatches(),lastSendAt:this.lastSendAt,lastFailureAt:e?.lastFailureAt??null,consecutiveFailures:e?.consecutiveFailures??0,throttledUntil:e?.throttledUntil??null,dropped:this.drops.counts()},sdkVersion:this.sdkVersion,owningSdkVersion:this.mismatchVersion,status:this.destroyed?`stopped`:this.tunablesLocked?this.config.enabled?this.rotating?`rotating`:t.length?`degraded`:this.ready?`ready`:`starting`:`disabled`:`unconfigured`,mode:this.role()===`forwarder`?`forwarder`:this.hasDestination()?`sender`:`console-only`,senderReady:this.sender!==void 0&&this.config.enabled&&!this.destroyed&&!this.rotating&&!this.deliveryClosed,configurationLocked:this.config.lockConfiguration,issues:t,securityContext:{...this.config.securityContext},storagePersistence:this.storagePersistence,bus:{sourcePolicy:i,maxMessageBytes:a,maxRecordsPerMessage:o,maxMessagesPerSecond:s}}}storeAccess(){return{config:this.config,diagnostics:this.diagnostics,memory:this.memoryStorage}}async storedBatches(){return await(this.sender??this.parkedSender)?.queueDepth()??0}flush(e){return this.flushFor(this.flushTimeout(e),!0)}async flushFor(e,t){S(this),t&&this.collectPoints();let n=this.idle();if(n)return n;let r=Date.now()+e,a,o=new Promise(t=>{let n=setTimeout(t,e);i.t(n),a=()=>{clearTimeout(n)}});try{return await this.flushBefore(r,o)}finally{a()}}async flushBefore(t,n){let r=this.heldRecords(),i=this.ready?this.senderLoad:this.started;if(i&&(!this.ready||!this.sender)&&!await Promise.race([i.then(()=>!0),n.then(()=>!1)]))return U({pending:this.waiting()});let{bus:a}=this,o=a?.getRole()===`forwarder`,s=this.idle();if(s)return s;if(o){let r=this.forwardBuffer.length,i=this.sendForwarded(),o=r-i,s=Math.floor(Math.max(0,t-Date.now())*e.it),c=await a.requestFlush(s,n);return c?{...c,forwarded:i,dropped:c.dropped+o}:U({forwarded:i,pending:i,dropped:o})}let{sender:c}=this;return c?U(await c.flushUntil(n)):this.rotating?U({pending:r+this.waiting()}):H(`complete`,{dropped:r})}idle(){return this.tunablesLocked&&this.config.enabled&&!this.destroyed?null:H(`inactive`,{pending:this.destroyed?0:this.waiting()})}heldRecords(){return this.bootBuffer.length+this.pendingRecords.length+this.forwardBuffer.length}waiting(){let e=this.heldRecords();for(let t of[this.sender,this.retiring]){let n=t?.stats();e+=n?n.pending+n.inFlight:0}return e}readOptions(e,t){if(typeof e!=`object`&&e!==void 0)this.diagnostics.report(`config.invalid`,t);else return this.diagnostics.guard(`config.invalid`,t,()=>({...e}))}flushTimeout(t){let n=this.readOptions(t,V);if(!n)return e.ot;let r=n.timeoutMs??5e3;return typeof r==`number`&&r>=0&&r<=6e5?r:(this.diagnostics.report(`config.invalid`,V),e.ot)}};o.t(G,`local`,null);function K(e,t,n=new WeakMap){if(Object.is(e,t))return!0;if(e instanceof RegExp&&t instanceof RegExp)return String(e)===String(t);if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(n.has(e))return n.get(e)===t;n.set(e,t);let i=Object.keys(e),a=Object.keys(t);return i.length===a.length&&i.every(i=>r.t(t,i)&&K(Reflect.get(e,i),Reflect.get(t,i),n))}var q;function ht(t={}){if(q)return q;let n=new A(t.onDiagnostic);if(typeof document<`u`||typeof addEventListener!=`function`)return n.report(`config.invalid`,`Call serveTransportWorker() in a dedicated worker.`),()=>void 0;let i=!1,a,o,s=t=>{n.guard(`transport.http_error`,`The transport worker could not read its connection.`,()=>{let s=t.data;if(!r.n(s)||s.p!==`ui-observability.transport/1`||s.t!==e.dr.connect||t.ports.length===0)return;let c=t.ports[0];a||s.v!==`1.2.0`?(c.postMessage(e.ur),c.close()):(a=c,Promise.resolve().then(()=>require("./worker-server-CF1yatXq.cjs")).then(e=>{i||(o=e.serveWorkerPort(c,n))}).catch(t=>{n.report(`transport.http_error`,`The transport worker delivery module could not load.`,void 0,t),n.guard(`transport.http_error`,`The failed transport port could not be closed.`,()=>{c.postMessage(e.ur),c.close()})}))})},c=()=>{i||(i=!0,q=void 0,removeEventListener(`message`,s),o?.(),n.guard(`transport.http_error`,`The transport service could not close its port.`,()=>{a?.postMessage(e.ur)}),n.guard(`transport.http_error`,`The transport port could not close.`,()=>{a?.close()}))};return addEventListener(`message`,s),q=c,c}function gt(){let e=[],t=[],n={status:200};return{transport:r=>(e.push(r),n.status>=200&&n.status<300&&t.push(r),Promise.resolve({...n})),records:()=>t.flatMap(e=>[...e.records]),batches:()=>[...e],clear:()=>{e.length=0,t.length=0},respondWith:(e,t)=>{n=t===void 0?{status:e}:{status:e,retryAfterMs:t}}}}var J=new Map;function Y(){return(G.current()??G.stopped())||G.configure({},!0)}function _t(e){G.configure(e),Z()}function vt(e){Y().setConfigurationLocked(e)}function yt(e,t){return Y().rotateSecurityContext(e,t)}async function X(){let e=Y();return Z(),{...await e.health(),loggerCache:{...e.config.loggerCache,size:J.size}}}async function bt(){let e=await X();return Y().debugBundle(e)}function Z(){let e=(G.current()??G.stopped())?.config.loggerCache.maxEntries,t=e===void 0?256:e;if(t!==null)for(let e of J.keys()){if(J.size<=t)break;J.delete(e)}return t}function xt(e,t){let n=Z();if(t||n===0)return new E(Y,e,t);let r=J.get(e);return r??=new E(Y,e),J.delete(e),J.set(e,r),Z(),r}function Q(){return xt(`app`)}function St(e,t){Q().trace(e,t)}function Ct(e,t){Q().debug(e,t)}function wt(e,t){Q().info(e,t)}function Tt(e,t){Q().warn(e,t)}function Et(e,t,n){Q().error(e,t,n)}function Dt(e,t,n){Q().fatal(e,t,n)}function Ot(e,t){Q().logAction(e,t)}function kt(e,t){Q().logEvent(e,t)}function $(t){G.current()?.diagnostics.report(`config.invalid`,e.St,void 0,t)}function At(e,t={}){return k(e,t,(e,t,n)=>{Y().recordMetric(e,t,n)},$)}function jt(e,t={}){return Ee(e,t,(e,t,n)=>{Y().recordMetric(e,t,n)},$)}function Mt(e,t={}){return De(e,t,(e,t,n)=>{Y().recordMetric(e,t,n)},$)}function Nt(e,t){return Y().startMeasure(e,t)}function Pt(e,t,n){let r=Y();return _e(r.startMeasure(e,n),t,r.diagnostics)}function Ft(){Y().setReplay(!0)}function It(){Y().setReplay(!1)}var Lt={probe:(e,t)=>c.t().probe(e,t,G.current()?.diagnostics),time:(e,t)=>c.t().time(e,t,G.current()?.diagnostics)};function Rt(e,t){Y().addBreadcrumb(e,t)}function zt(e){let t=Y();r.n(e)?t.diagnostics.guard(`record.sanitize_failed`,`The library could not read the values of setContext().`,()=>{t.context.merge(e)}):t.diagnostics.report(`config.invalid`,`setContext() takes an object. The library keeps the current context.`)}function Bt(e){Y().context.remove(e)}function Vt(e,t){return Y().journey.start(e,t)}function Ht(){Y().journey.end()}function Ut(){return Y().journey.current()}function Wt(){return Y().journey.getToken()}function Gt(e){return Y().journey.adopt(e,`manual`,!0)}function Kt(e,t){return Y().registerWorker(e,t)}function qt(e,t){return Y().registerFrame(e,t)}function Jt(){Y().tracing.rotate(`explicit`)}function Yt(){return Y().tracing.headers()}function Xt(e){return Y().flush(e)}function Zt(){Y().newSession()}function Qt(){return Y().diagnostics.snapshot()}async function $t(e){await(G.current()??G.stopped())?.destroy(e)}exports.addBreadcrumb=Rt,exports.adoptJourney=Gt,exports.collectDebugBundle=bt,exports.configure=_t,exports.counter=At,exports.createMemoryTransport=gt,exports.currentJourney=Ut,exports.debug=Ct,exports.endJourney=Ht,exports.error=Et,exports.fatal=Dt,exports.flush=Xt,exports.gauge=jt,exports.getDiagnosticCounters=Qt,exports.getHealth=X,exports.getJourneyToken=Wt,exports.getLogger=xt,exports.getTraceHeaders=Yt,exports.histogram=Mt,exports.info=wt,exports.logAction=Ot,exports.logEvent=kt,exports.measure=Pt,exports.newSession=Zt,exports.newTrace=Jt,exports.observeWindow=g.r,exports.profiler=Lt,exports.registerFrame=qt,exports.registerWorker=Kt,exports.removeContext=Bt,exports.rotateSecurityContext=yt,exports.serveTransportWorker=ht,exports.setConfigurationLocked=vt,exports.setContext=zt,exports.shutdown=$t,exports.startJourney=Vt,exports.startMeasure=Nt,exports.startReplay=Ft,exports.stopReplay=It,exports.trace=St,exports.warn=Tt;
2
2
  //# sourceMappingURL=index.cjs.map