@commentkit/comment-kit 0.6.8 → 0.7.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 (339) hide show
  1. package/CHANGELOG.md +71 -2
  2. package/LICENSE +18 -2
  3. package/README.md +198 -125
  4. package/SECURITY.md +48 -0
  5. package/dist/THIRD_PARTY_NOTICES.txt +284 -0
  6. package/dist/angular.es.js +68 -3419
  7. package/dist/comment-kit.es.js +33 -3192
  8. package/dist/demo.es.js +472 -0
  9. package/dist/headless.es.js +4 -0
  10. package/dist/preact.es.js +79 -3443
  11. package/dist/qwik.es.js +1 -3474
  12. package/dist/qwik.qwik.mjs +114 -0
  13. package/dist/react.es.js +80 -28447
  14. package/dist/shared/ShadowRootContext-Bv-4aElu.js +13 -0
  15. package/dist/shared/annotation-icons-Dh-bmNYK.js +172 -0
  16. package/dist/shared/annotation-toolbar-B9SxYqoF.js +1093 -0
  17. package/dist/shared/bridge-CJoGYngu.js +177 -0
  18. package/dist/shared/button-By0hGrJK.js +505 -0
  19. package/dist/shared/button-group-Cl9CrvvU.js +93 -0
  20. package/dist/shared/comment-drawing-canvas-Dzb5YoFw.js +124 -0
  21. package/dist/shared/comment-image-lightbox-BPYJT1sB.js +183 -0
  22. package/dist/shared/comment-kit-core-BaSuMzp9.js +3381 -0
  23. package/dist/shared/comment-kit-ui-CzfdAZs2.js +20181 -0
  24. package/dist/shared/comment-screenshot-annotator-C7X-_bm6.js +151 -0
  25. package/dist/shared/comment-screenshot-overlay-wIrZrcRy.js +206 -0
  26. package/dist/shared/comment-utils-BycYTSxA.js +602 -0
  27. package/dist/shared/createReactComponent-BZHeRbD0.js +45 -0
  28. package/dist/shared/dev-export-panel-FwFVdady.js +208 -0
  29. package/dist/shared/dev-grab-DDqg0LQf.js +203 -0
  30. package/dist/shared/dist-De294MVF.js +623 -0
  31. package/dist/{core/dom-x9svfpMk.js → shared/dom-Bhf4WFtY.js} +2 -2
  32. package/dist/shared/element-selector-BhJm-NSs.js +858 -0
  33. package/dist/shared/errors-Bu5ajEmB.js +22 -0
  34. package/dist/shared/icons-nzMOLzrm.js +266 -0
  35. package/dist/shared/mount-ui--ijs8pWT.js +193 -0
  36. package/dist/{angular/pusher-Vs-W-c8I.js → shared/pusher-ipHMJnO_.js} +93 -127
  37. package/dist/shared/realtime-Dk41VwKg.js +302 -0
  38. package/dist/shared/separator-XDBsaWyw.js +4021 -0
  39. package/dist/shared/shadow-root-C5v-T8lQ.js +135 -0
  40. package/dist/shared/styles-D3yMtaec.js +2 -0
  41. package/dist/shared/useValueChanged-CrzfD8l-.js +92 -0
  42. package/dist/{angular/limits-AEqOBweE.js → shared/validation-C7QG8j7Z.js} +2 -28
  43. package/dist/{core/websocket-manager-D1_TEuy_.js → shared/websocket-manager-DhLWh3Jr.js} +90 -148
  44. package/dist/solid.es.js +63 -3427
  45. package/dist/svelte.es.js +78 -3442
  46. package/dist/types/adapters/bridge.d.ts +10 -13
  47. package/dist/types/angular/index.d.ts +17 -7
  48. package/dist/types/core/api-client.d.ts +16 -17
  49. package/dist/types/core/comment-kit-core.d.ts +29 -12
  50. package/dist/types/core/local-demo.d.ts +60 -0
  51. package/dist/types/core/types.d.ts +68 -0
  52. package/dist/types/demo.d.ts +17 -0
  53. package/dist/types/headless.d.ts +8 -0
  54. package/dist/types/index.d.ts +22 -20
  55. package/dist/types/qwik/index.d.ts +4 -1
  56. package/dist/vue.es.js +80 -3443
  57. package/docs/api-reference.md +372 -0
  58. package/docs/local-demo.md +60 -0
  59. package/package.json +69 -41
  60. package/dist/angular/chunk-Cyg4N8Ue.js +0 -11
  61. package/dist/angular/comment-kit-ui-D-LUFD6n.js +0 -24898
  62. package/dist/angular/dom-Cx1nMbdI.js +0 -104
  63. package/dist/angular/mount-ui-C9PJ5aK_.js +0 -72
  64. package/dist/angular/realtime-VrKV0lPI.js +0 -567
  65. package/dist/angular/shadow-root-yMOaW9pk.js +0 -93
  66. package/dist/angular/styles-CMz7-p8x.js +0 -2
  67. package/dist/angular/widget-theme-CYPYAwhR.js +0 -24
  68. package/dist/comment-kit.css +0 -2
  69. package/dist/core/chunk-t7YoJN_i.js +0 -11
  70. package/dist/core/comment-kit-ui-Ct4E18do.js +0 -24898
  71. package/dist/core/error-boundary-CN_BGsYl.js +0 -21
  72. package/dist/core/mount-ui-Bfnuuesk.js +0 -72
  73. package/dist/core/pusher-CizoY5NA.js +0 -2504
  74. package/dist/core/realtime-C3_O7gi2.js +0 -278
  75. package/dist/core/shadow-root-DAtdjHG2.js +0 -93
  76. package/dist/core/styles-ClRoB6ro.js +0 -2
  77. package/dist/core/widget-theme-BWDYr7VR.js +0 -24
  78. package/dist/preact/chunk-CZ0PdaaN.js +0 -11
  79. package/dist/preact/comment-kit-ui-DEzn7J_P.js +0 -24898
  80. package/dist/preact/dom-_ULpq7rg.js +0 -104
  81. package/dist/preact/error-boundary-B4-Bfy3g.js +0 -21
  82. package/dist/preact/limits-C3ZEKcL_.js +0 -71
  83. package/dist/preact/mount-ui-Dx8en--W.js +0 -72
  84. package/dist/preact/pusher-BP4kCufH.js +0 -2504
  85. package/dist/preact/realtime-COin_nJF.js +0 -567
  86. package/dist/preact/shadow-root-D-NcwruG.js +0 -93
  87. package/dist/preact/styles-D6i7be5-.js +0 -2
  88. package/dist/preact/widget-theme-B7Z2pbaA.js +0 -24
  89. package/dist/qwik/chunk-CKKKzG2Q.js +0 -11
  90. package/dist/qwik/comment-kit-ui-Dvwee2tw.js +0 -24898
  91. package/dist/qwik/dom-Dm3gzBBJ.js +0 -104
  92. package/dist/qwik/error-boundary-C4hlYQwS.js +0 -21
  93. package/dist/qwik/limits-DK35yjGY.js +0 -71
  94. package/dist/qwik/mount-ui-DSAwNk_d.js +0 -72
  95. package/dist/qwik/pusher-B1KgC4iB.js +0 -2504
  96. package/dist/qwik/realtime-DhfcBrwF.js +0 -567
  97. package/dist/qwik/shadow-root-PkjcnvPe.js +0 -93
  98. package/dist/qwik/styles-DmEmq5Lh.js +0 -2
  99. package/dist/qwik/widget-theme-lbPF3I0A.js +0 -24
  100. package/dist/react/chunk--MHYZ-zp.js +0 -12
  101. package/dist/react/limits-CpprSem3.js +0 -175
  102. package/dist/react/pusher-3dki8s2l.js +0 -2505
  103. package/dist/react/realtime-DGqScuox.js +0 -567
  104. package/dist/solid/chunk-B2NCWFvW.js +0 -11
  105. package/dist/solid/comment-kit-ui-ACW8BpEm.js +0 -24898
  106. package/dist/solid/dom-DqDH-Gml.js +0 -104
  107. package/dist/solid/error-boundary-9mimpbZA.js +0 -21
  108. package/dist/solid/limits-B_69IbLl.js +0 -71
  109. package/dist/solid/mount-ui-Dq1wj_tx.js +0 -72
  110. package/dist/solid/pusher-_RVNpj1f.js +0 -2504
  111. package/dist/solid/realtime-DbUJK4gU.js +0 -567
  112. package/dist/solid/shadow-root-CssU3bQb.js +0 -93
  113. package/dist/solid/styles-DbueS9xx.js +0 -2
  114. package/dist/solid/widget-theme-B4DJ14fI.js +0 -24
  115. package/dist/svelte/chunk-Pi70BKld.js +0 -11
  116. package/dist/svelte/comment-kit-ui-Cx4u1g77.js +0 -24898
  117. package/dist/svelte/dom-MyTrWzy_.js +0 -104
  118. package/dist/svelte/error-boundary-C3GWI_IX.js +0 -21
  119. package/dist/svelte/limits-CURF22v3.js +0 -71
  120. package/dist/svelte/mount-ui-CBoNGLNS.js +0 -72
  121. package/dist/svelte/pusher-DN1BiUDw.js +0 -2504
  122. package/dist/svelte/realtime-M1CJbCBA.js +0 -567
  123. package/dist/svelte/shadow-root-DG8inbf6.js +0 -93
  124. package/dist/svelte/styles-BK_MaUpD.js +0 -2
  125. package/dist/svelte/widget-theme-CkfJNysI.js +0 -24
  126. package/dist/types/adapters/errors.d.ts +0 -3
  127. package/dist/types/core/auth.d.ts +0 -18
  128. package/dist/types/core/comments.d.ts +0 -43
  129. package/dist/types/core/dev-grab.d.ts +0 -14
  130. package/dist/types/core/keyboard.d.ts +0 -12
  131. package/dist/types/core/limits.d.ts +0 -52
  132. package/dist/types/core/offline-queue.d.ts +0 -23
  133. package/dist/types/core/realtime.d.ts +0 -9
  134. package/dist/types/core/screenshot.d.ts +0 -12
  135. package/dist/types/core/session.d.ts +0 -9
  136. package/dist/types/core/source-resolver.d.ts +0 -19
  137. package/dist/types/core/state.d.ts +0 -24
  138. package/dist/types/react/comment-kit-ui.d.ts +0 -9
  139. package/dist/types/react/comments/comment-flow.d.ts +0 -8
  140. package/dist/types/react/comments/outcomes.d.ts +0 -28
  141. package/dist/types/react/comments/pin-geometry.d.ts +0 -12
  142. package/dist/types/react/comments/view-model.d.ts +0 -66
  143. package/dist/types/react/components/annotation-toolbar.d.ts +0 -36
  144. package/dist/types/react/components/build-panel-shared-props.d.ts +0 -25
  145. package/dist/types/react/components/comment-actions.d.ts +0 -19
  146. package/dist/types/react/components/comment-body.d.ts +0 -8
  147. package/dist/types/react/components/comment-branch-filter.d.ts +0 -15
  148. package/dist/types/react/components/comment-composer-actions.d.ts +0 -26
  149. package/dist/types/react/components/comment-composer-extras-fields.d.ts +0 -32
  150. package/dist/types/react/components/comment-composer-extras-toolbar.d.ts +0 -9
  151. package/dist/types/react/components/comment-composer-extras.d.ts +0 -10
  152. package/dist/types/react/components/comment-composer-extras.state.d.ts +0 -24
  153. package/dist/types/react/components/comment-composer-hook.d.ts +0 -1
  154. package/dist/types/react/components/comment-composer-media.d.ts +0 -17
  155. package/dist/types/react/components/comment-composer.d.ts +0 -4
  156. package/dist/types/react/components/comment-composer.types.d.ts +0 -41
  157. package/dist/types/react/components/comment-composer.utils.d.ts +0 -3
  158. package/dist/types/react/components/comment-connection-alert.d.ts +0 -7
  159. package/dist/types/react/components/comment-cursor-layer.d.ts +0 -14
  160. package/dist/types/react/components/comment-custom-cursor.d.ts +0 -14
  161. package/dist/types/react/components/comment-drawing-canvas.d.ts +0 -10
  162. package/dist/types/react/components/comment-emoji-picker.d.ts +0 -12
  163. package/dist/types/react/components/comment-error-banner.d.ts +0 -8
  164. package/dist/types/react/components/comment-extension-banner.d.ts +0 -8
  165. package/dist/types/react/components/comment-fab-tools.d.ts +0 -37
  166. package/dist/types/react/components/comment-fab.d.ts +0 -34
  167. package/dist/types/react/components/comment-filter-assignee.d.ts +0 -9
  168. package/dist/types/react/components/comment-filter-bar.d.ts +0 -27
  169. package/dist/types/react/components/comment-filter-popover.d.ts +0 -20
  170. package/dist/types/react/components/comment-format-toolbar.constants.d.ts +0 -34
  171. package/dist/types/react/components/comment-format-toolbar.d.ts +0 -6
  172. package/dist/types/react/components/comment-header.d.ts +0 -34
  173. package/dist/types/react/components/comment-highlight-layer.d.ts +0 -11
  174. package/dist/types/react/components/comment-highlight-marker.d.ts +0 -9
  175. package/dist/types/react/components/comment-image-lightbox.d.ts +0 -10
  176. package/dist/types/react/components/comment-images.d.ts +0 -7
  177. package/dist/types/react/components/comment-item.d.ts +0 -26
  178. package/dist/types/react/components/comment-keyboard-shortcuts.d.ts +0 -7
  179. package/dist/types/react/components/comment-kit-overlays.d.ts +0 -15
  180. package/dist/types/react/components/comment-kit.d.ts +0 -12
  181. package/dist/types/react/components/comment-list-filters.d.ts +0 -14
  182. package/dist/types/react/components/comment-login-modal.d.ts +0 -20
  183. package/dist/types/react/components/comment-marker-layer-composer.d.ts +0 -21
  184. package/dist/types/react/components/comment-marker-layer.d.ts +0 -27
  185. package/dist/types/react/components/comment-marker-popover.d.ts +0 -12
  186. package/dist/types/react/components/comment-marker.d.ts +0 -15
  187. package/dist/types/react/components/comment-member-list.d.ts +0 -10
  188. package/dist/types/react/components/comment-mode-bar.d.ts +0 -15
  189. package/dist/types/react/components/comment-online-users.d.ts +0 -8
  190. package/dist/types/react/components/comment-page-ref.d.ts +0 -9
  191. package/dist/types/react/components/comment-panel-header.d.ts +0 -22
  192. package/dist/types/react/components/comment-panel-mobile.d.ts +0 -9
  193. package/dist/types/react/components/comment-panel-utils.d.ts +0 -6
  194. package/dist/types/react/components/comment-panel-view-body.d.ts +0 -23
  195. package/dist/types/react/components/comment-panel.d.ts +0 -37
  196. package/dist/types/react/components/comment-quoted-text.d.ts +0 -9
  197. package/dist/types/react/components/comment-reactions.d.ts +0 -11
  198. package/dist/types/react/components/comment-remote-cursor.d.ts +0 -11
  199. package/dist/types/react/components/comment-screenshot-annotator.d.ts +0 -11
  200. package/dist/types/react/components/comment-screenshot-overlay.d.ts +0 -10
  201. package/dist/types/react/components/comment-search-bar.d.ts +0 -7
  202. package/dist/types/react/components/comment-settings-view.d.ts +0 -20
  203. package/dist/types/react/components/comment-skeletons.d.ts +0 -9
  204. package/dist/types/react/components/comment-thread-detail-badges.d.ts +0 -16
  205. package/dist/types/react/components/comment-thread-detail-meta.d.ts +0 -9
  206. package/dist/types/react/components/comment-thread-detail-replies.d.ts +0 -13
  207. package/dist/types/react/components/comment-thread-detail.d.ts +0 -13
  208. package/dist/types/react/components/comment-thread-footer.d.ts +0 -12
  209. package/dist/types/react/components/comment-thread-list-item.d.ts +0 -15
  210. package/dist/types/react/components/comment-thread-list.d.ts +0 -16
  211. package/dist/types/react/components/comment-user-avatar-tooltip.d.ts +0 -12
  212. package/dist/types/react/components/comment-users-context.d.ts +0 -15
  213. package/dist/types/react/components/comment-utils.d.ts +0 -20
  214. package/dist/types/react/components/comment.d.ts +0 -26
  215. package/dist/types/react/components/constants.d.ts +0 -50
  216. package/dist/types/react/components/dev-export-panel.d.ts +0 -10
  217. package/dist/types/react/components/drawing-path-renderer.d.ts +0 -10
  218. package/dist/types/react/components/element-selector.d.ts +0 -11
  219. package/dist/types/react/components/live-region.d.ts +0 -16
  220. package/dist/types/react/components/screenshot-capture.d.ts +0 -17
  221. package/dist/types/react/components/status-indicator.d.ts +0 -43
  222. package/dist/types/react/components/ui.d.ts +0 -44
  223. package/dist/types/react/components/use-comment-composer.d.ts +0 -28
  224. package/dist/types/react/error-boundary.d.ts +0 -25
  225. package/dist/types/react/hooks/use-comment-fab-drag.d.ts +0 -21
  226. package/dist/types/react/hooks/use-comment-hash-link.d.ts +0 -20
  227. package/dist/types/react/hooks/use-comment-kit-filters.d.ts +0 -19
  228. package/dist/types/react/hooks/use-comment-kit-keyboard.d.ts +0 -11
  229. package/dist/types/react/hooks/use-comment-kit-prop-sync.d.ts +0 -12
  230. package/dist/types/react/hooks/use-comment-marker-drag.d.ts +0 -23
  231. package/dist/types/react/hooks/use-comment-panel-navigation.d.ts +0 -21
  232. package/dist/types/react/hooks/use-comment-realtime.d.ts +0 -6
  233. package/dist/types/react/hooks/use-comment-thread-actions.d.ts +0 -15
  234. package/dist/types/react/hooks/use-connection-retry.d.ts +0 -9
  235. package/dist/types/react/hooks/use-drawing.d.ts +0 -32
  236. package/dist/types/react/hooks/use-extension-conflicts.d.ts +0 -13
  237. package/dist/types/react/hooks/use-filtered-threads.d.ts +0 -7
  238. package/dist/types/react/hooks/use-marker-layer.d.ts +0 -19
  239. package/dist/types/react/hooks/use-screenshot.d.ts +0 -18
  240. package/dist/types/react/hooks/use-text-selection.d.ts +0 -17
  241. package/dist/types/react/hooks/use-websocket.d.ts +0 -9
  242. package/dist/types/react/is-local-host.d.ts +0 -2
  243. package/dist/types/react/mount-ui.d.ts +0 -19
  244. package/dist/types/react/shadow-root.d.ts +0 -23
  245. package/dist/types/react/shims/use-sync-external-store-with-selector.d.ts +0 -4
  246. package/dist/types/react/shims/use-sync-external-store.d.ts +0 -1
  247. package/dist/types/react/ui/lib/ShadowRootContext.d.ts +0 -10
  248. package/dist/types/react/ui/lib/cn.d.ts +0 -12
  249. package/dist/types/react/ui/lib/widget-theme.d.ts +0 -7
  250. package/dist/types/react/ui/primitives/alert/alert.d.ts +0 -8
  251. package/dist/types/react/ui/primitives/alert/index.d.ts +0 -1
  252. package/dist/types/react/ui/primitives/alert-dialog/alert-dialog.d.ts +0 -23
  253. package/dist/types/react/ui/primitives/alert-dialog/index.d.ts +0 -1
  254. package/dist/types/react/ui/primitives/avatar/avatar.d.ts +0 -10
  255. package/dist/types/react/ui/primitives/avatar/index.d.ts +0 -1
  256. package/dist/types/react/ui/primitives/badge/badge.d.ts +0 -5
  257. package/dist/types/react/ui/primitives/badge/index.d.ts +0 -1
  258. package/dist/types/react/ui/primitives/breadcrumb/breadcrumb.d.ts +0 -10
  259. package/dist/types/react/ui/primitives/breadcrumb/index.d.ts +0 -1
  260. package/dist/types/react/ui/primitives/button/button.d.ts +0 -6
  261. package/dist/types/react/ui/primitives/button/index.d.ts +0 -1
  262. package/dist/types/react/ui/primitives/button-group/button-group.d.ts +0 -9
  263. package/dist/types/react/ui/primitives/button-group/index.d.ts +0 -1
  264. package/dist/types/react/ui/primitives/card/card.d.ts +0 -11
  265. package/dist/types/react/ui/primitives/card/index.d.ts +0 -1
  266. package/dist/types/react/ui/primitives/checkbox/checkbox.d.ts +0 -3
  267. package/dist/types/react/ui/primitives/checkbox/index.d.ts +0 -1
  268. package/dist/types/react/ui/primitives/dialog/dialog.d.ts +0 -17
  269. package/dist/types/react/ui/primitives/dialog/index.d.ts +0 -1
  270. package/dist/types/react/ui/primitives/dropdown-menu/dropdown-menu.d.ts +0 -29
  271. package/dist/types/react/ui/primitives/dropdown-menu/index.d.ts +0 -1
  272. package/dist/types/react/ui/primitives/empty/empty.d.ts +0 -10
  273. package/dist/types/react/ui/primitives/empty/index.d.ts +0 -1
  274. package/dist/types/react/ui/primitives/field/field.d.ts +0 -22
  275. package/dist/types/react/ui/primitives/field/index.d.ts +0 -1
  276. package/dist/types/react/ui/primitives/hover-card/hover-card.d.ts +0 -6
  277. package/dist/types/react/ui/primitives/hover-card/index.d.ts +0 -1
  278. package/dist/types/react/ui/primitives/input/index.d.ts +0 -1
  279. package/dist/types/react/ui/primitives/input/input.d.ts +0 -3
  280. package/dist/types/react/ui/primitives/input-group/index.d.ts +0 -1
  281. package/dist/types/react/ui/primitives/input-group/input-group.d.ts +0 -16
  282. package/dist/types/react/ui/primitives/input-otp/index.d.ts +0 -1
  283. package/dist/types/react/ui/primitives/input-otp/input-otp.d.ts +0 -11
  284. package/dist/types/react/ui/primitives/kbd/index.d.ts +0 -1
  285. package/dist/types/react/ui/primitives/kbd/kbd.d.ts +0 -4
  286. package/dist/types/react/ui/primitives/label/index.d.ts +0 -1
  287. package/dist/types/react/ui/primitives/label/label.d.ts +0 -3
  288. package/dist/types/react/ui/primitives/native-select/index.d.ts +0 -1
  289. package/dist/types/react/ui/primitives/native-select/native-select.d.ts +0 -7
  290. package/dist/types/react/ui/primitives/popover/index.d.ts +0 -1
  291. package/dist/types/react/ui/primitives/popover/popover.d.ts +0 -9
  292. package/dist/types/react/ui/primitives/preview/component-preview.d.ts +0 -8
  293. package/dist/types/react/ui/primitives/progress/index.d.ts +0 -1
  294. package/dist/types/react/ui/primitives/progress/progress.d.ts +0 -7
  295. package/dist/types/react/ui/primitives/radio-group/index.d.ts +0 -1
  296. package/dist/types/react/ui/primitives/radio-group/radio-group.d.ts +0 -6
  297. package/dist/types/react/ui/primitives/scroll-area/index.d.ts +0 -1
  298. package/dist/types/react/ui/primitives/scroll-area/scroll-area.d.ts +0 -6
  299. package/dist/types/react/ui/primitives/select/index.d.ts +0 -1
  300. package/dist/types/react/ui/primitives/select/select.d.ts +0 -15
  301. package/dist/types/react/ui/primitives/separator/index.d.ts +0 -1
  302. package/dist/types/react/ui/primitives/separator/separator.d.ts +0 -3
  303. package/dist/types/react/ui/primitives/sheet/index.d.ts +0 -1
  304. package/dist/types/react/ui/primitives/sheet/sheet.d.ts +0 -14
  305. package/dist/types/react/ui/primitives/skeleton/index.d.ts +0 -1
  306. package/dist/types/react/ui/primitives/skeleton/skeleton.d.ts +0 -3
  307. package/dist/types/react/ui/primitives/slider/index.d.ts +0 -1
  308. package/dist/types/react/ui/primitives/slider/slider.d.ts +0 -7
  309. package/dist/types/react/ui/primitives/sonner/index.d.ts +0 -1
  310. package/dist/types/react/ui/primitives/sonner/sonner.d.ts +0 -4
  311. package/dist/types/react/ui/primitives/spinner/index.d.ts +0 -1
  312. package/dist/types/react/ui/primitives/spinner/spinner.d.ts +0 -3
  313. package/dist/types/react/ui/primitives/switch/index.d.ts +0 -1
  314. package/dist/types/react/ui/primitives/switch/switch.d.ts +0 -5
  315. package/dist/types/react/ui/primitives/tabs/index.d.ts +0 -1
  316. package/dist/types/react/ui/primitives/tabs/tabs.d.ts +0 -8
  317. package/dist/types/react/ui/primitives/textarea/index.d.ts +0 -1
  318. package/dist/types/react/ui/primitives/textarea/textarea.d.ts +0 -3
  319. package/dist/types/react/ui/primitives/toggle/index.d.ts +0 -1
  320. package/dist/types/react/ui/primitives/toggle/toggle.d.ts +0 -7
  321. package/dist/types/react/ui/primitives/toggle-group/index.d.ts +0 -1
  322. package/dist/types/react/ui/primitives/toggle-group/toggle-group.d.ts +0 -14
  323. package/dist/types/react/ui/primitives/tooltip/index.d.ts +0 -1
  324. package/dist/types/react/ui/primitives/tooltip/tooltip.d.ts +0 -7
  325. package/dist/types/utils/freeze-animations.d.ts +0 -8
  326. package/dist/types/utils/text.d.ts +0 -9
  327. package/dist/types/utils/validation.d.ts +0 -10
  328. package/dist/vue/chunk-DHrubWSL.js +0 -11
  329. package/dist/vue/comment-kit-ui-C3zijClM.js +0 -24898
  330. package/dist/vue/dom-C7krZAR8.js +0 -104
  331. package/dist/vue/error-boundary-DW6uGR8U.js +0 -21
  332. package/dist/vue/limits-B6csdQeI.js +0 -71
  333. package/dist/vue/mount-ui-18BnLwCO.js +0 -72
  334. package/dist/vue/pusher-cmjNbW6a.js +0 -2504
  335. package/dist/vue/realtime-B0B5cE-E.js +0 -567
  336. package/dist/vue/shadow-root-zwd_wUIP.js +0 -93
  337. package/dist/vue/styles-B0NAkbKu.js +0 -2
  338. package/dist/vue/widget-theme-D7Vkagk7.js +0 -24
  339. /package/dist/{angular/error-boundary-CxhCm8iF.js → shared/error-boundary-D3PD74vI.js} +0 -0
@@ -1,3191 +1,20 @@
1
- import { a as e, c as t, d as n, f as r, i, l as a, n as o, r as s, s as c, t as l, u } from "./core/websocket-manager-D1_TEuy_.js";
2
- import { a as d, c as f, d as p, f as m, i as h, l as g, m as _, n as v, o as y, p as ee, r as b, s as te, t as ne, u as re } from "./core/dom-x9svfpMk.js";
3
- var ie = "https://api.commentkit.dev/api", ae = 3e4, oe = 10 * 1024 * 1024, se = 10, ce = 1e4, le = 5e3, ue = 254, de = 6, fe = 4096, pe = [
4
- ".png",
5
- ".jpg",
6
- ".jpeg",
7
- ".gif",
8
- ".webp"
9
- ], me = [
10
- "image/png",
11
- "image/jpeg",
12
- "image/gif",
13
- "image/webp"
14
- ], he = /@\[([^\]]+)\]\(([^)]+)\)/g, ge = {
15
- invalid_api_key: "Authentication failed. Please check your API key.",
16
- missing_api_key: "Authentication failed. Please check your API key.",
17
- origin_not_allowed: "This domain is not allowed to use this project's API key.",
18
- invalid_email: "A valid email address is required.",
19
- invalid_otp: "A valid OTP code is required.",
20
- invalid_token: "A valid invite token is required.",
21
- network_error: "Unable to connect to servers. Please check your connection.",
22
- timeout: "Request timed out. Please try again.",
23
- rate_limit: "Too many requests. Please wait before trying again.",
24
- unauthorized: "You are not authorized to perform this action.",
25
- not_found: "The requested resource was not found.",
26
- validation_error: "Invalid input. Please check your data.",
27
- invalid_response: "Invalid server response.",
28
- auth_failed: "Sign-in failed. Please check your email and try again.",
29
- otp_cooldown: "A code was sent recently — please wait a minute before requesting another.",
30
- otp_not_found: "No verification code found. Request a new one.",
31
- otp_expired: "That verification code has expired. Request a new one.",
32
- otp_max_attempts: "Too many incorrect attempts. Request a new code.",
33
- otp_invalid: "Incorrect verification code. Please try again.",
34
- invalid_invite: "This invite link is invalid or has expired.",
35
- email_mismatch: "This invite was issued for a different email address.",
36
- quota_exceeded: "This project has reached its plan limit."
37
- };
38
- function _e(e, t) {
39
- let n = {};
40
- return e.content !== void 0 && (n.content = e.content), e.status !== void 0 && (n.status = e.status), e.priority !== void 0 && (n.priority = e.priority), e.description !== void 0 && (n.description = e.description), e.assignees !== void 0 && (n.assignees = e.assignees.map((e) => e.id)), e.checklist !== void 0 && (n.checklist = e.checklist.map((e) => ({
41
- ...e,
42
- id: /^\d+$/.test(e.id) ? Number(e.id) : null
43
- }))), e.textSelection !== void 0 && (n.text_selection = e.textSelection), e.drawingData !== void 0 && (n.drawing_data = e.drawingData), e.attachmentIds !== void 0 && (n.attachment_ids = e.attachmentIds.map((e) => typeof e == "number" ? e : Number(e)).filter((e) => Number.isInteger(e) && e > 0).slice(0, 20)), t && t.length > 0 && (n.mentions = t), n;
44
- }
45
- function ve(e) {
46
- return e === "localhost" || e === "127.0.0.1" || e === "[::1]" || e.endsWith(".localhost");
47
- }
48
- function ye(e) {
49
- let t = (e || ie).trim().replace(/\/+$/, "");
50
- try {
51
- let e = new URL(t);
52
- if (e.protocol !== "https:" && e.protocol !== "http:") throw Error("unsupported protocol");
53
- if (e.protocol === "http:" && !ve(e.hostname)) throw Error("insecure protocol");
54
- } catch {
55
- throw new T("invalid_base_url", "Invalid API base URL", 400);
56
- }
57
- return t;
58
- }
59
- function x(e) {
60
- let t = String(e).trim();
61
- if (!t || i(t)) throw new T("invalid_id", "Invalid identifier", 400);
62
- return encodeURIComponent(t);
63
- }
64
- function S(e) {
65
- if (typeof e != "string" || i(e)) throw new T("invalid_email", "A valid email address is required", 400);
66
- let t = e.trim();
67
- if (!r(t, ue)) throw new T("invalid_email", "A valid email address is required", 400);
68
- return t;
69
- }
70
- function be(e) {
71
- if (i(e)) throw new T("invalid_otp", "A valid OTP code is required", 400);
72
- let t = e.trim();
73
- if (t.length !== de || /\s/.test(t)) throw new T("invalid_otp", "A valid OTP code is required", 400);
74
- return t;
75
- }
76
- function xe(e) {
77
- if (i(e)) throw new T("invalid_token", "A valid invite token is required", 400);
78
- let t = e.trim();
79
- if (t.length !== 64 || !/^[\w-]+$/.test(t)) throw new T("invalid_token", "A valid invite token is required", 400);
80
- return t;
81
- }
82
- function C(e, t, n = ce) {
83
- let r = e.trim();
84
- if (!r) throw new T("invalid_content", `${t} cannot be empty`, 400);
85
- if (r.length > n) throw new T("content_too_long", `${t} exceeds maximum length of ${n} characters`, 400);
86
- return r;
87
- }
88
- function Se(e) {
89
- if (!t(e)) return;
90
- let n = {};
91
- for (let [t, r] of Object.entries(e).slice(0, 20)) /^[\w.-]{1,64}$/.test(t) && (t === "__proto__" || t === "constructor" || t === "prototype" || (typeof r == "string" ? n[t] = r.slice(0, 200) : typeof r == "number" || typeof r == "boolean" || r === null ? n[t] = r : Array.isArray(r) && (n[t] = r.filter((e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null).slice(0, 10).map((e) => typeof e == "string" ? e.slice(0, 200) : e))));
92
- return Object.keys(n).length > 0 ? n : void 0;
93
- }
94
- var Ce = class {
95
- constructor(e) {
96
- this.projectId = null, this.userEmail = null, this.authToken = null, this.environment = null, this.onAuthExpired = null, this.baseUrl = ye(e.baseUrl), this.apiKey = e.apiKey, this.projectId = e.projectId || null, this.environment = e.environment || null;
97
- }
98
- setProject(e) {
99
- this.projectId = String(e).trim();
100
- }
101
- setUserEmail(e) {
102
- this.userEmail = e ? S(e) : null;
103
- }
104
- setAuthToken(e) {
105
- if (e && (i(e) || e.length > fe)) throw new T("invalid_token", "A valid auth token is required", 400);
106
- let t = e?.trim() || null;
107
- this.authToken = t;
108
- }
109
- setEnvironment(e) {
110
- this.environment = e;
111
- }
112
- setOnAuthExpired(e) {
113
- this.onAuthExpired = e;
114
- }
115
- buildHeaders(e) {
116
- if (typeof this.apiKey != "string" || i(this.apiKey)) throw new T("invalid_api_key", "Authentication failed. Please check your API key.", 401);
117
- return {
118
- "X-API-Key": this.apiKey,
119
- ...this.userEmail ? { "X-User-Email": this.userEmail } : {},
120
- ...this.authToken ? { Authorization: `Bearer ${this.authToken}` } : {},
121
- ...e
122
- };
123
- }
124
- async executeRequest(e, n, r, i) {
125
- let a = new AbortController(), o = setTimeout(() => a.abort(), ae);
126
- try {
127
- let o = await fetch(e, {
128
- ...n,
129
- signal: a.signal
130
- }), s = await this.parseResponseBody(o);
131
- if (!o.ok) {
132
- o.status === 401 && this.authToken && (this.authToken = null, this.onAuthExpired?.());
133
- let e = t(s) ? s : {}, n = typeof e.error == "string" ? e.error : r;
134
- throw new T(n, ge[n] ?? i, o.status, Se(e.details));
135
- }
136
- return s;
137
- } catch (e) {
138
- if (e instanceof T) throw e;
139
- if (e instanceof DOMException && e.name === "AbortError") throw new T("timeout", "Request timed out. Please try again.", 408);
140
- if (e instanceof TypeError) throw new T("network_error", "Unable to connect to servers. Please check your connection.", 0);
141
- let t = new T("unknown_error", "An unexpected error occurred", 500);
142
- throw t.cause = e, t;
143
- } finally {
144
- clearTimeout(o);
145
- }
146
- }
147
- async parseResponseBody(e) {
148
- if (e.status === 204 || e.status === 205) return {};
149
- let t = e.headers?.get?.("content-type") ?? "";
150
- if (typeof e.text == "function") {
151
- let n = await e.text();
152
- if (!n) return {};
153
- if (t && !t.toLowerCase().includes("application/json")) {
154
- if (e.ok) throw new T("invalid_response", "Invalid server response", 502);
155
- return {};
156
- }
157
- try {
158
- return JSON.parse(n);
159
- } catch {
160
- if (e.ok) throw new T("invalid_response", "Invalid server response", 502);
161
- return {};
162
- }
163
- }
164
- if (typeof e.json == "function") try {
165
- return await e.json();
166
- } catch {
167
- if (e.ok) throw new T("invalid_response", "Invalid server response", 502);
168
- }
169
- return {};
170
- }
171
- async request(e, t = {}) {
172
- let n = `${this.baseUrl}${e}`, r = this.buildHeaders({
173
- "Content-Type": "application/json",
174
- ...t.headers
175
- });
176
- return this.executeRequest(n, {
177
- ...t,
178
- headers: r
179
- }, "request_failed", "An error occurred");
180
- }
181
- async requestFormData(e, t) {
182
- let n = `${this.baseUrl}${e}`, r = this.buildHeaders();
183
- return this.executeRequest(n, {
184
- method: "POST",
185
- headers: r,
186
- body: t
187
- }, "upload_failed", "Upload failed");
188
- }
189
- requireProjectId() {
190
- if (!this.projectId) throw new T("missing_project_id", "Project ID is required", 400);
191
- return this.projectId;
192
- }
193
- async validateApiKey() {
194
- return this.request("/auth/validate-key", {
195
- method: "POST",
196
- body: JSON.stringify({})
197
- });
198
- }
199
- async requestOtp(e) {
200
- let t = S(e);
201
- return this.request("/auth/otp/request", {
202
- method: "POST",
203
- body: JSON.stringify({ email: t })
204
- });
205
- }
206
- async verifyOtp(e, t) {
207
- let n = S(e), r = be(t);
208
- return this.request("/auth/otp/verify", {
209
- method: "POST",
210
- body: JSON.stringify({
211
- email: n,
212
- otp: r
213
- })
214
- });
215
- }
216
- async validateInvite(e, t) {
217
- let n = xe(e), r = S(t);
218
- return this.request("/auth/validate-invite", {
219
- method: "POST",
220
- body: JSON.stringify({
221
- token: n,
222
- email: r
223
- })
224
- });
225
- }
226
- async getComments(e, t = "all", n = 1, r = 50, i) {
227
- let a = this.requireProjectId(), o = new URLSearchParams();
228
- e && o.append("page_path", e), t !== "all" && o.append("status", t), i && o.append("environment", i);
229
- let s = Number.isFinite(n) ? Math.max(1, Math.floor(n)) : 1, c = Number.isFinite(r) ? Math.min(100, Math.max(1, Math.floor(r))) : 50;
230
- o.append("page", String(s)), o.append("limit", String(c));
231
- let l = o.toString(), u = `/projects/${x(a)}/comments${l ? `?${l}` : ""}`, d = await this.request(u), f = d.comments ?? [];
232
- return {
233
- comments: f,
234
- pagination: d.pagination ?? {
235
- total: f.length,
236
- hasMore: f.length >= c,
237
- page: s,
238
- limit: c
239
- }
240
- };
241
- }
242
- idempotencyHeaders(e) {
243
- return typeof e == "string" && e.length > 0 && e.length <= 256 && !i(e) ? { "Idempotency-Key": e } : {};
244
- }
245
- async createComment(e, t, n, r, i = "medium", a, o, s, c) {
246
- let l = C(t, "Comment content"), u = this.requireProjectId(), d = s?.mentions ?? w(l);
247
- return (await this.request(`/projects/${x(u)}/comments`, {
248
- method: "POST",
249
- headers: this.idempotencyHeaders(c),
250
- body: JSON.stringify({
251
- type: e,
252
- position: n,
253
- page_url: r.url,
254
- page_path: r.path,
255
- page_title: r.title,
256
- environment: this.environment || void 0,
257
- ..._e({
258
- content: l,
259
- priority: i,
260
- description: s?.description,
261
- assignees: s?.assignees,
262
- checklist: s?.checklist,
263
- textSelection: a,
264
- drawingData: o,
265
- attachmentIds: s?.attachmentIds
266
- }, d)
267
- })
268
- })).comment;
269
- }
270
- async updateComment(e, t) {
271
- let n = this.requireProjectId(), r = t.content === void 0 ? void 0 : C(t.content, "Comment content"), i = r ? w(r) : void 0, a = _e({
272
- ...t,
273
- ...r === void 0 ? {} : { content: r }
274
- }, i);
275
- return (await this.request(`/projects/${x(n)}/comments/${x(e)}`, {
276
- method: "PUT",
277
- body: JSON.stringify(a)
278
- })).comment;
279
- }
280
- async deleteComment(e) {
281
- let t = this.requireProjectId();
282
- await this.request(`/projects/${x(t)}/comments/${x(e)}`, { method: "DELETE" });
283
- }
284
- async addReply(e, t, n) {
285
- let r = this.requireProjectId(), i = C(t, "Reply content", le), a = w(i);
286
- return (await this.request(`/projects/${x(r)}/comments/${x(e)}/replies`, {
287
- method: "POST",
288
- headers: this.idempotencyHeaders(n),
289
- body: JSON.stringify({
290
- content: i,
291
- ...a.length > 0 ? { mentions: a } : {}
292
- })
293
- })).reply;
294
- }
295
- async updateReply(e, t, n) {
296
- let r = this.requireProjectId(), i = C(n, "Reply content", le);
297
- return (await this.request(`/projects/${x(r)}/comments/${x(e)}/replies/${x(t)}`, {
298
- method: "PUT",
299
- body: JSON.stringify({ content: i })
300
- })).reply;
301
- }
302
- async deleteReply(e, t) {
303
- let n = this.requireProjectId();
304
- await this.request(`/projects/${x(n)}/comments/${x(e)}/replies/${x(t)}`, { method: "DELETE" });
305
- }
306
- async resolveComment(e) {
307
- let t = this.requireProjectId();
308
- return (await this.request(`/projects/${x(t)}/comments/${x(e)}/resolve`, { method: "POST" })).comment;
309
- }
310
- async unresolveComment(e) {
311
- let t = this.requireProjectId();
312
- return (await this.request(`/projects/${x(t)}/comments/${x(e)}/unresolve`, { method: "POST" })).comment;
313
- }
314
- async markComplete(e) {
315
- let t = this.requireProjectId();
316
- return (await this.request(`/projects/${x(t)}/comments/${x(e)}/complete`, { method: "POST" })).comment;
317
- }
318
- async addReaction(e, t) {
319
- let n = this.requireProjectId();
320
- await this.request(`/projects/${x(n)}/comments/${x(e)}/reactions`, {
321
- method: "POST",
322
- body: JSON.stringify({ emoji: t })
323
- });
324
- }
325
- async removeReaction(e, t) {
326
- let n = this.requireProjectId();
327
- await this.request(`/projects/${x(n)}/comments/${x(e)}/reactions`, {
328
- method: "DELETE",
329
- body: JSON.stringify({ emoji: t })
330
- });
331
- }
332
- async updatePosition(e, t) {
333
- let n = this.requireProjectId();
334
- return (await this.request(`/projects/${x(n)}/comments/${x(e)}/position`, {
335
- method: "PUT",
336
- body: JSON.stringify({ position: t })
337
- })).comment;
338
- }
339
- async createHighlight(e, t, n, r = "medium", i) {
340
- return this.createComment("highlight", e, {
341
- x: 0,
342
- y: 0
343
- }, n, r, t, void 0, void 0, i);
344
- }
345
- async createDrawing(e, t, n, r, i) {
346
- return this.createComment("drawing", e, n, r, "medium", void 0, t, void 0, i);
347
- }
348
- validateFile(e, t = !1) {
349
- if (e.size > oe) throw new T("file_too_large", `File size (${Math.round(e.size / 1024 / 1024)}MB) exceeds maximum of ${oe / 1024 / 1024}MB`, 400);
350
- if (i(e.name) || e.name.includes("/") || e.name.includes("\\")) throw new T("invalid_filename", "Filename contains invalid characters", 400);
351
- if (t) {
352
- /* v8 ignore next -- pop() always returns a value since file has a name */
353
- let t = "." + (e.name.split(".").pop()?.toLowerCase() ?? "");
354
- if ((e.name.match(/\./g) || []).length > 1) throw new T("invalid_filename", "Filenames with multiple extensions are not allowed", 400);
355
- if (!me.includes(e.type) || !pe.includes(t)) throw new T("invalid_file_type", `Only image files are allowed (${pe.join(", ")})`, 400);
356
- }
357
- if (s(e.name)) throw new T("invalid_file_type", "This file type is not allowed", 400);
358
- }
359
- async uploadFile(e, t, n) {
360
- this.validateFile(e, t === "screenshot" || t === "drawing");
361
- let r = this.requireProjectId(), i = new FormData();
362
- i.append("file", e), i.append("type", t === "attachment" ? "file" : t), n?.commentId && i.append("comment_id", n.commentId), n?.replyId && i.append("reply_id", n.replyId);
363
- let a = await this.requestFormData(`/projects/${x(r)}/files`, i);
364
- return {
365
- id: String(a.attachment.id),
366
- type: a.attachment.type,
367
- url: a.attachment.url,
368
- thumbnail: a.attachment.thumbnail,
369
- filename: a.attachment.filename,
370
- size: a.attachment.size
371
- };
372
- }
373
- async uploadScreenshot(e, t) {
374
- this.validateFile(e, !0);
375
- let n = C(t.content, "Screenshot comment"), r = this.requireProjectId(), i = new FormData();
376
- return i.append("file", e), i.append("content", n), i.append("position_x", String(t.position.x)), i.append("position_y", String(t.position.y)), i.append("page_url", t.page.url), i.append("page_path", t.page.path), i.append("page_title", t.page.title), (await this.requestFormData(`/projects/${x(r)}/screenshots`, i)).comment;
377
- }
378
- async uploadFiles(e, t) {
379
- if (e.length > se) throw new T("too_many_files", `Cannot upload more than ${se} files at once`, 400);
380
- let n = await Promise.allSettled(e.map((e) => {
381
- /* v8 ignore next -- pop() always returns a value since file has a name */
382
- let n = "." + (e.name.split(".").pop()?.toLowerCase() ?? ""), r = me.includes(e.type) && pe.includes(n);
383
- return this.uploadFile(e, r ? "screenshot" : "attachment", t);
384
- })), r = n.filter((e) => e.status === "fulfilled").map((e) => e.value.id), i = n.find((e) => e.status === "rejected");
385
- if (i) {
386
- let e = i.reason;
387
- throw e instanceof T ? new T(e.error, e.message, e.code, {
388
- ...e.details,
389
- uploadedIds: r
390
- }) : new T("upload_failed", "Upload failed", 0, { uploadedIds: r });
391
- }
392
- return r;
393
- }
394
- async getProjectMembers() {
395
- let e = this.requireProjectId();
396
- return (await this.request(`/projects/${x(e)}/members`)).members ?? [];
397
- }
398
- };
399
- function w(e) {
400
- let t = [], n;
401
- for (he.lastIndex = 0; (n = he.exec(e)) !== null;) {
402
- let e = n[1]?.trim(), r = n[2]?.trim();
403
- !e || !r || !/^[\w-]+$/.test(r) || t.push({
404
- name: e,
405
- userId: r,
406
- index: n.index
407
- });
408
- }
409
- return t;
410
- }
411
- function we(e) {
412
- return `@[${e.name.replace(/\]/g, "")}](${e.id.replace(/\)/g, "")})`;
413
- }
414
- function Te(e) {
415
- return e.replace(he, "@$1");
416
- }
417
- var T = class extends Error {
418
- constructor(e, t, n, r) {
419
- super(t), this.name = "ApiClientError", this.error = e, this.code = n, this.details = r;
420
- }
421
- isAuthError() {
422
- return this.code === 401 || this.error === "invalid_api_key";
423
- }
424
- isNetworkError() {
425
- return this.code === 0 || this.error === "network_error";
426
- }
427
- isRateLimitError() {
428
- return this.code === 429;
429
- }
430
- isPremiumFeatureError() {
431
- return this.code === 402;
432
- }
433
- };
434
- function Ee(e, t) {
435
- return (e ?? "").replace(/\s+/g, " ").trim().slice(0, t);
436
- }
437
- function E(e, t) {
438
- return (e ?? "").replace(/\s+/g, " ").replace(/`/g, "'").trim().slice(0, t);
439
- }
440
- var D = null, De = 0, Oe = 3;
441
- function ke() {
442
- return D || (D = (async () => {
443
- try {
444
- let e = await import("element-source");
445
- return typeof e?.resolveElementInfo == "function" ? e : null;
446
- } catch {
447
- return De += 1, De < Oe && (D = null), null;
448
- }
449
- })(), D);
450
- }
451
- async function Ae(e) {
452
- let t = await ke();
453
- if (!t) return null;
454
- try {
455
- return await t.resolveElementInfo(e);
456
- } catch {
457
- return null;
458
- }
459
- }
460
- var je = 200, Me = 500, Ne = 500, Pe = 2e3, Fe = "application/x-commentkit-agent-context", Ie = "Use this CommentKit context to understand unresolved UI feedback. Each comment includes page, selector/XPath, viewport position, resolved DOM metadata when available, and thread replies.";
461
- function Le(e) {
462
- return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
463
- }
464
- function Re(e) {
465
- return e === void 0 ? je : !Number.isFinite(e) || e <= 0 ? 0 : Math.min(Me, Math.floor(e));
466
- }
467
- function ze(e) {
468
- return {
469
- id: e.id,
470
- name: e.name,
471
- email: e.email
472
- };
473
- }
474
- function Be(e, t) {
475
- return e.page.path === t.path || e.page.url === t.url;
476
- }
477
- function Ve(e, t, n, r) {
478
- return !(!n.includeResolved && e.status !== "open" || n.currentPageOnly && !Be(e, t) || r && !r.has(e.id));
479
- }
480
- function He(e) {
481
- let t = e.getBoundingClientRect();
482
- return {
483
- top: t.top,
484
- left: t.left,
485
- width: t.width,
486
- height: t.height
487
- };
488
- }
489
- function Ue(e, t) {
490
- let n = v(e.element ?? "", e.xpath), r = {
491
- ...e.element ? { selector: e.element } : {},
492
- ...e.xpath ? { xpath: e.xpath } : {}
493
- };
494
- if (!n) return {
495
- ...r,
496
- found: !1
497
- };
498
- let i = Ee(n.textContent, Ne), a = t ? Ee(n.outerHTML, Pe) : "", o = n.getAttribute("class"), s = n.getAttribute("role"), c = n.getAttribute("aria-label");
499
- return {
500
- ...r,
501
- found: !0,
502
- tagName: n.tagName.toLowerCase(),
503
- ...n.id ? { id: n.id } : {},
504
- ...o ? { className: o } : {},
505
- ...s ? { role: s } : {},
506
- ...c ? { ariaLabel: c } : {},
507
- ...i ? { text: i } : {},
508
- rect: He(n),
509
- ...a ? { htmlPreview: a } : {}
510
- };
511
- }
512
- function We(e) {
513
- return {
514
- id: e.id,
515
- content: e.content,
516
- author: ze(e.author),
517
- createdAt: e.createdAt
518
- };
519
- }
520
- function Ge(e) {
521
- return e.attachments?.find((e) => e.url && e.type === "screenshot")?.url;
522
- }
523
- function Ke(e, t) {
524
- let n = Ge(e);
525
- return {
526
- id: e.id,
527
- type: e.type,
528
- status: e.status,
529
- priority: e.priority,
530
- content: e.content,
531
- author: ze(e.author),
532
- createdAt: e.createdAt,
533
- updatedAt: e.updatedAt,
534
- page: e.page,
535
- position: e.position,
536
- element: Ue(e.position, t.includeHtml === !0),
537
- ...n ? { screenshotUrl: n } : {},
538
- replies: e.replies.map(We)
539
- };
540
- }
541
- function qe(e) {
542
- return {
543
- filePath: e.filePath,
544
- lineNumber: e.lineNumber,
545
- columnNumber: e.columnNumber,
546
- componentName: e.componentName
547
- };
548
- }
549
- function Je(e, t = {}) {
550
- let n = y(), r = {
551
- url: n.url,
552
- path: n.path,
553
- title: n.title
554
- }, i = t.commentIds?.length ? new Set(t.commentIds) : null, a = Re(t.maxComments), o = e.comments.filter((e) => Ve(e, r, t, i)).slice(0, a).map((e) => Ke(e, t));
555
- return {
556
- version: 1,
557
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
558
- instructions: E(t.instructions, 2e3) || Ie,
559
- page: r,
560
- comments: o,
561
- sourceResolved: !1
562
- };
563
- }
564
- async function Ye(e) {
565
- let t = !1, n = await Promise.all(e.comments.map(async (e) => {
566
- if (!e.element.found) return e;
567
- let n = v(e.element.selector ?? "", e.element.xpath);
568
- if (!n) return e;
569
- let r = await Ae(n);
570
- if (!r || !r.source) return e;
571
- t = !0;
572
- let i = qe(r.source), a = r.stack.map(qe), o = r.componentName ?? void 0;
573
- return {
574
- ...e,
575
- element: {
576
- ...e.element,
577
- source: i,
578
- stack: a,
579
- ...o ? { componentName: o } : {}
580
- }
581
- };
582
- }));
583
- return {
584
- ...e,
585
- comments: n,
586
- sourceResolved: t
587
- };
588
- }
589
- function Xe(e) {
590
- let t = `${e.filePath}${e.lineNumber === null ? "" : `:${e.lineNumber}`}${e.columnNumber === null ? "" : `:${e.columnNumber}`}`;
591
- return e.componentName ? `${e.componentName} (${t})` : t;
592
- }
593
- function O(e) {
594
- return [
595
- "# CommentKit Agent Context",
596
- "",
597
- e.instructions,
598
- "",
599
- `Current page: ${E(e.page.title, 300) || "Untitled"} (${e.page.url || e.page.path || "unknown"})`,
600
- `Comments: ${e.comments.length}${e.sourceResolved ? " (source-resolved)" : ""}`,
601
- "",
602
- ...e.comments.map((e, t) => {
603
- let n = e.element.found ? `${e.element.tagName}${e.element.id ? `#${e.element.id}` : ""}` : "not found", r = [
604
- `## ${t + 1}. ${E(e.content, 300)}`,
605
- `- Status: ${e.status}`,
606
- `- Priority: ${e.priority}`,
607
- `- Author: ${e.author.name} <${e.author.email}>`,
608
- `- Page: ${e.page.url}`,
609
- `- Element: ${n}`
610
- ];
611
- return e.element.source && r.push(`- Source: ${Xe(e.element.source)}`), e.element.stack && e.element.stack.length > 0 && r.push("- Stack:", ...e.element.stack.map((e) => ` - ${Xe(e)}`)), e.element.source || r.push(`- Selector: ${e.element.selector ?? "none"}`, `- XPath: ${e.element.xpath ?? "none"}`), e.screenshotUrl && r.push(`- Screenshot: ${e.screenshotUrl}`), r.push(e.replies.length > 0 ? `- Replies: ${e.replies.length}` : "- Replies: 0", ""), r.join("\n");
612
- }),
613
- "```json",
614
- JSON.stringify(e, null, 2),
615
- "```"
616
- ].join("\n");
617
- }
618
- function Ze(e) {
619
- return {
620
- version: e?.version ?? 1,
621
- generatedAt: e?.generatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
622
- commentCount: e?.comments.length ?? 0,
623
- context: e
624
- };
625
- }
626
- function Qe(e, t) {
627
- if (typeof document > "u" || !document.body || typeof document.execCommand != "function") return !1;
628
- let n = JSON.stringify(t), r = (t) => {
629
- t.preventDefault(), t.clipboardData?.setData("text/plain", e), t.clipboardData?.setData("text/html", `<meta charset="utf-8"><pre><code>${Le(e)}</code></pre>`), t.clipboardData?.setData(Fe, n);
630
- }, i = document.createElement("textarea");
631
- i.value = e, i.setAttribute("readonly", ""), i.setAttribute("aria-hidden", "true"), i.style.position = "fixed", i.style.left = "-9999px", document.addEventListener("copy", r), document.body.appendChild(i), i.select();
632
- try {
633
- return document.execCommand("copy");
634
- } finally {
635
- document.removeEventListener("copy", r), i.remove();
636
- }
637
- }
638
- async function $e(e, t) {
639
- if (typeof navigator > "u" || typeof navigator.clipboard?.write != "function" || typeof ClipboardItem > "u") return !1;
640
- try {
641
- let n = new Blob([`<meta charset="utf-8"><pre><code>${Le(e)}</code></pre>`], { type: "text/html" }), r = new Blob([e], { type: "text/plain" }), i = t.type && t.type.startsWith("image/") ? t.type : "image/png";
642
- return await navigator.clipboard.write([new ClipboardItem({
643
- "text/plain": r,
644
- "text/html": n,
645
- [i]: t
646
- })]), !0;
647
- } catch {
648
- return !1;
649
- }
650
- }
651
- async function et(e, t) {
652
- return t && await $e(e, t) ? !0 : (await k(e), !1);
653
- }
654
- async function k(e, t = null) {
655
- if (!Qe(e, Ze(t))) {
656
- if (typeof navigator < "u" && typeof navigator.clipboard?.writeText == "function") {
657
- await navigator.clipboard.writeText(e);
658
- return;
659
- }
660
- throw Error("Clipboard is unavailable");
661
- }
662
- }
663
- var tt = 100, nt = () => {};
664
- function rt(e) {
665
- return typeof e == "function";
666
- }
667
- var it = class {
668
- constructor() {
669
- this.listeners = /* @__PURE__ */ new Map(), this.onceWrappers = /* @__PURE__ */ new Map();
670
- }
671
- on(e, t) {
672
- if (!rt(t)) return console.warn(`[CommentKit] Ignoring non-function listener for '${String(e)}'`), nt;
673
- let n = this.listeners.get(e);
674
- return n || (n = /* @__PURE__ */ new Set(), this.listeners.set(e, n)), !n.has(t) && n.size >= tt && console.warn(`[CommentKit] Max listeners (${tt}) reached for '${String(e)}' - possible memory leak`), n.add(t), () => this.off(e, t);
675
- }
676
- off(e, t) {
677
- if (!rt(t)) return;
678
- let n = this.listeners.get(e);
679
- if (n) {
680
- n.delete(t);
681
- let r = this.onceWrappers.get(e), i = r?.get(t);
682
- r && i && (n.delete(i), r.delete(t), r.size === 0 && this.onceWrappers.delete(e)), n.size === 0 && this.listeners.delete(e);
683
- }
684
- }
685
- emit(e, t) {
686
- let n = this.listeners.get(e);
687
- if (n) for (let r of Array.from(n)) try {
688
- r(t);
689
- } catch (t) {
690
- console.error(`[CommentKit] Error in '${e}' listener:`, t);
691
- }
692
- }
693
- once(e, t) {
694
- if (!rt(t)) return console.warn(`[CommentKit] Ignoring non-function listener for '${String(e)}'`), nt;
695
- let n = (n) => {
696
- this.off(e, t), t(n);
697
- }, r = this.onceWrappers.get(e);
698
- return r || (r = /* @__PURE__ */ new Map(), this.onceWrappers.set(e, r)), r.set(t, n), this.on(e, n);
699
- }
700
- removeAllListeners(e) {
701
- e ? (this.listeners.delete(e), this.onceWrappers.delete(e)) : (this.listeners.clear(), this.onceWrappers.clear());
702
- }
703
- listenerCount(e) {
704
- return this.listeners.get(e)?.size ?? 0;
705
- }
706
- }, at = "commentkit:session:", ot = 4096;
707
- function st() {
708
- try {
709
- return typeof sessionStorage > "u" ? null : sessionStorage;
710
- } catch {
711
- return null;
712
- }
713
- }
714
- function A(e) {
715
- return `${at}${e}`;
716
- }
717
- function ct(e) {
718
- return t(e) && n(e.id, o.ID) && n(e.name, o.NAME) && typeof e.email == "string" && r(e.email, o.EMAIL);
719
- }
720
- function lt(e) {
721
- return t(e) && n(e.token, ot) && typeof e.email == "string" && r(e.email, o.EMAIL) && ct(e.user);
722
- }
723
- function ut(e, t) {
724
- if (!e) return;
725
- let n = st();
726
- if (n) try {
727
- n.setItem(A(e), JSON.stringify(t));
728
- } catch {}
729
- }
730
- function dt(e) {
731
- if (!e) return null;
732
- let t = st();
733
- if (!t) return null;
734
- try {
735
- let n = t.getItem(A(e));
736
- if (!n) return null;
737
- let r = JSON.parse(n);
738
- return lt(r) ? {
739
- token: r.token.trim(),
740
- email: r.email.trim(),
741
- user: {
742
- id: r.user.id.trim(),
743
- name: r.user.name.trim(),
744
- email: r.user.email.trim(),
745
- ...r.user.avatar ? { avatar: r.user.avatar } : {}
746
- }
747
- } : (t.removeItem(A(e)), null);
748
- } catch {
749
- return null;
750
- }
751
- }
752
- function ft(e) {
753
- if (!e) return;
754
- let t = st();
755
- if (t) try {
756
- t.removeItem(A(e));
757
- } catch {}
758
- }
759
- function pt(e, t) {
760
- for (let n of e.getState().pendingMutations) e.emit("offline:failed", {
761
- id: n.id,
762
- error: {
763
- error: "auth_cleared",
764
- message: t,
765
- code: 401
766
- }
767
- });
768
- }
769
- var mt = o.EMAIL, ht = o.NAME, gt = o.ID, _t = 4096, vt = 6;
770
- function j(e) {
771
- if (typeof e != "string") return null;
772
- let t = e.trim();
773
- return r(t, mt) ? t : null;
774
- }
775
- function yt(e) {
776
- return i(e) ? !1 : e.trim().length === vt;
777
- }
778
- function bt(e) {
779
- return t(e) && n(e.id, gt) && n(e.name, ht) && typeof e.email == "string" && j(e.email) !== null;
780
- }
781
- function xt(e) {
782
- return t(e) && n(e.id, gt);
783
- }
784
- function M(e, t, n) {
785
- return {
786
- error: e,
787
- message: t,
788
- code: n
789
- };
790
- }
791
- async function St(e, t) {
792
- let n = j(t);
793
- if (!n) {
794
- e.setState({
795
- isLoading: !1,
796
- otpStep: "idle",
797
- otpEmail: null
798
- }), e.handleError(M("invalid_email", "A valid email address is required", 400));
799
- return;
800
- }
801
- try {
802
- e.setState({
803
- isLoading: !0,
804
- error: null,
805
- otpStep: "requesting",
806
- otpEmail: n
807
- });
808
- let t = await e.apiClient.requestOtp(n);
809
- t.success ? (e.setState({
810
- otpStep: "verifying",
811
- isLoading: !1
812
- }), e.emit("auth:otp-requested", {
813
- email: n,
814
- expiresIn: t.expiresIn
815
- })) : (e.setState({
816
- isLoading: !1,
817
- otpStep: "idle",
818
- otpEmail: null
819
- }), e.handleError(M("otp_failed", "Failed to send OTP. Please try again.", 500)));
820
- } catch (t) {
821
- e.setState({
822
- isLoading: !1,
823
- otpStep: "idle",
824
- otpEmail: null
825
- }), e.handleError(t);
826
- }
827
- }
828
- async function Ct(e, t, r) {
829
- let { onAuthenticated: i, onWrongOtp: a, onSuccess: o } = typeof r == "function" ? { onAuthenticated: r } : r, s = e.getState().otpEmail;
830
- if (!s) {
831
- e.handleError(M("no_email", "No OTP request in progress", 400));
832
- return;
833
- }
834
- if (!yt(t)) {
835
- e.setState({ isLoading: !1 }), e.handleError(M("invalid_otp", "Invalid or expired OTP code", 401));
836
- return;
837
- }
838
- try {
839
- e.setState({
840
- isLoading: !0,
841
- error: null
842
- });
843
- let r = await e.apiClient.verifyOtp(s, t);
844
- r.verified && n(r.token, _t) && bt(r.user) && xt(r.project) ? (e.apiClient.setAuthToken(r.token), e.apiClient.setUserEmail(r.user.email), ut(e.config.projectId, {
845
- token: r.token,
846
- email: r.user.email,
847
- user: r.user
848
- }), e.setState({
849
- currentUser: r.user,
850
- project: r.project,
851
- isAuthenticated: !0,
852
- isLoginModalVisible: !1,
853
- isOverlayVisible: !0,
854
- isLoading: !1,
855
- otpStep: "idle",
856
- otpEmail: null
857
- }), o?.(), e.emit("auth:otp-verified", r.user), e.emit("auth:login", r.user), await i()) : (e.setState({ isLoading: !1 }), a?.(), e.handleError(M("invalid_otp", "Invalid or expired OTP code", 401)));
858
- } catch (t) {
859
- e.setState({ isLoading: !1 }), e.handleError(t);
860
- }
861
- }
862
- function wt(e) {
863
- e.setState({
864
- otpStep: "idle",
865
- otpEmail: null,
866
- error: null,
867
- isLoading: !1
868
- });
869
- }
870
- async function Tt(e) {
871
- let t = e.getState().otpEmail;
872
- t && await St(e, t);
873
- }
874
- function Et(e, t) {
875
- pt(e, "Pending offline changes were discarded on logout"), ft(e.config.projectId), e.apiClient.setUserEmail(null), e.apiClient.setAuthToken(null), t(), e.setState({
876
- isAuthenticated: !1,
877
- currentUser: null,
878
- comments: [],
879
- activeTool: null,
880
- selectedComment: null,
881
- activeComment: null,
882
- activeDrawing: null,
883
- activeScreenshot: null,
884
- onlineUsers: [],
885
- isOverlayVisible: !1,
886
- isCommentModeActive: !1,
887
- isDrawingModeActive: !1,
888
- isHighlightModeActive: !1,
889
- isScreenshotModeActive: !1,
890
- isSidebarVisible: !1,
891
- otpStep: "idle",
892
- otpEmail: null,
893
- pagination: null,
894
- pendingMutations: [],
895
- activities: [],
896
- seenThreadIds: /* @__PURE__ */ new Set(),
897
- panelView: "list",
898
- connectionStatus: "disconnected",
899
- error: null,
900
- isLoading: !1
901
- }), e.emit("auth:logout", void 0);
902
- }
903
- function Dt(e) {
904
- pt(e, "Pending offline changes were discarded because the session expired"), ft(e.config.projectId), e.apiClient.setUserEmail(null), e.apiClient.setAuthToken(null), e.setState({
905
- isAuthenticated: !1,
906
- currentUser: null,
907
- comments: [],
908
- selectedComment: null,
909
- activeComment: null,
910
- activeDrawing: null,
911
- activeScreenshot: null,
912
- onlineUsers: [],
913
- pendingMutations: [],
914
- activities: [],
915
- seenThreadIds: /* @__PURE__ */ new Set(),
916
- panelView: "list",
917
- connectionStatus: "disconnected",
918
- isLoginModalVisible: !0,
919
- error: "Your session has expired. Please sign in again.",
920
- isLoading: !1
921
- }), e.emit("error", {
922
- error: "auth_expired",
923
- message: "Session expired",
924
- code: 401
925
- });
926
- }
927
- function Ot(e) {
928
- e.setState({ isLoginModalVisible: !e.getState().isLoginModalVisible });
929
- }
930
- async function kt(e, t, n) {
931
- let r = e.config.inviteToken;
932
- if (!r) {
933
- e.handleError(M("no_invite", "No invite token found", 400));
934
- return;
935
- }
936
- let i = j(t);
937
- if (!i) {
938
- e.setState({ isLoading: !1 }), e.handleError(M("invalid_email", "A valid email address is required", 400));
939
- return;
940
- }
941
- try {
942
- e.setState({
943
- isLoading: !0,
944
- error: null
945
- }), (await e.apiClient.validateInvite(r, i)).success ? await n(i) : (e.setState({ isLoading: !1 }), e.handleError(M("invite_invalid", "Invite validation failed", 400)));
946
- } catch (t) {
947
- e.setState({ isLoading: !1 }), e.handleError(t);
948
- }
949
- }
950
- var N = o.ID, At = o.CONTENT, jt = o.REPLY_CONTENT, Mt = o.SELECTOR, Nt = o.TEXT_SELECTION, Pt = o.DESCRIPTION, Ft = o.ASSIGNEES, It = o.CHECKLIST_ITEMS, Lt = o.CHECKLIST_LABEL, Rt = o.DRAWING_PATHS, zt = o.DRAWING_PATH_DATA, Bt = o.DRAWING_TEXT, Vt = o.REACTION_COUNT, Ht = o.EMOJI, Ut = new Set([
951
- "pin",
952
- "highlight",
953
- "drawing"
954
- ]), Wt = new Set([
955
- "low",
956
- "medium",
957
- "high",
958
- "urgent"
959
- ]), Gt = new Set([
960
- "open",
961
- "resolved",
962
- "complete"
963
- ]), Kt = new Set([
964
- "path",
965
- "line",
966
- "rectangle",
967
- "circle",
968
- "text"
969
- ]);
970
- function P(e, t, n) {
971
- e.handleError(new T(t, n, 400));
972
- }
973
- function F(e) {
974
- return n(e, N);
975
- }
976
- function I(t, n = At) {
977
- if (typeof t != "string") return null;
978
- let r = t.trim();
979
- return !r || r.length > n || e(r) ? null : r;
980
- }
981
- function L(t, n) {
982
- if (t === void 0) return;
983
- if (typeof t != "string") return null;
984
- let r = t.trim();
985
- return r.length > n || e(r) ? null : r;
986
- }
987
- function R(t) {
988
- if (t === void 0) return;
989
- if (typeof t != "string") return null;
990
- let n = t.trim();
991
- return !n || n.length > Mt || e(n) ? null : n;
992
- }
993
- function qt(e) {
994
- if (!t(e) || !c(e.x) || !c(e.y)) return null;
995
- let n = R(e.element), r = R(e.xpath);
996
- return n === null || r === null ? null : {
997
- x: e.x,
998
- y: e.y,
999
- ...n === void 0 ? {} : { element: n },
1000
- ...r === void 0 ? {} : { xpath: r }
1001
- };
1002
- }
1003
- function Jt(n) {
1004
- if (!t(n)) return null;
1005
- let r = L(n.avatar, Mt), i = L(n.organizationId, N);
1006
- return !F(n.id) || typeof n.name != "string" || !n.name.trim() || n.name.length > o.NAME || e(n.name) || typeof n.email != "string" || !n.email.trim() || n.email.length > o.EMAIL || /\s/.test(n.email.trim()) || e(n.email) || r === null || i === null ? null : {
1007
- id: n.id.trim(),
1008
- name: n.name.trim(),
1009
- email: n.email.trim(),
1010
- ...r === void 0 ? {} : { avatar: r },
1011
- ...i === void 0 ? {} : { organizationId: i }
1012
- };
1013
- }
1014
- function Yt(e) {
1015
- if (e === void 0) return;
1016
- if (!Array.isArray(e) || e.length > Ft) return null;
1017
- let t = [];
1018
- for (let n of e) {
1019
- let e = Jt(n);
1020
- if (!e) return null;
1021
- t.push(e);
1022
- }
1023
- return t;
1024
- }
1025
- function Xt(e) {
1026
- if (e === void 0) return;
1027
- if (!Array.isArray(e) || e.length > It) return null;
1028
- let n = [];
1029
- for (let r of e) {
1030
- if (!t(r)) return null;
1031
- let e = I(r.label);
1032
- if (!F(r.id) || !e || typeof r.done != "boolean" || r.sortOrder !== void 0 && (typeof r.sortOrder != "number" || !Number.isFinite(r.sortOrder)) || e.length > Lt) return null;
1033
- n.push({
1034
- id: r.id.trim(),
1035
- label: e,
1036
- done: r.done,
1037
- ...r.sortOrder === void 0 ? {} : { sortOrder: r.sortOrder }
1038
- });
1039
- }
1040
- return n;
1041
- }
1042
- function Zt(n) {
1043
- if (n === void 0) return;
1044
- if (!t(n) || typeof n.text != "string") return null;
1045
- let r = n.text.trim(), i = R(n.element), a = R(n.xpath);
1046
- return !r || r.length > Nt || e(r) || typeof n.startOffset != "number" || typeof n.endOffset != "number" || !Number.isInteger(n.startOffset) || !Number.isInteger(n.endOffset) || n.startOffset < 0 || n.endOffset < n.startOffset || i === null || a === null || i === void 0 || a === void 0 ? null : {
1047
- text: r,
1048
- startOffset: n.startOffset,
1049
- endOffset: n.endOffset,
1050
- element: i,
1051
- xpath: a
1052
- };
1053
- }
1054
- function Qt(t) {
1055
- return typeof t == "string" && t.length > 0 && t.length <= o.COLOR && !e(t);
1056
- }
1057
- function z(e) {
1058
- return e === void 0 || typeof e == "number" && Number.isFinite(e);
1059
- }
1060
- function $t(n) {
1061
- if (n === void 0) return;
1062
- if (!t(n) || n.type !== "svg" || !Array.isArray(n.paths) || n.paths.length > Rt || !t(n.viewport) || typeof n.viewport.width != "number" || typeof n.viewport.height != "number" || !Number.isFinite(n.viewport.width) || !Number.isFinite(n.viewport.height) || n.viewport.width <= 0 || n.viewport.height <= 0) return null;
1063
- let r = [];
1064
- for (let i of n.paths) {
1065
- if (!t(i) || !Kt.has(String(i.type))) return null;
1066
- let n = L(i.text, Bt);
1067
- if (!Qt(i.stroke) || !Qt(i.fill) || typeof i.strokeWidth != "number" || !Number.isFinite(i.strokeWidth) || i.strokeWidth < 0 || i.d !== void 0 && (typeof i.d != "string" || i.d.length > zt || e(i.d)) || !z(i.x) || !z(i.y) || !z(i.width) || !z(i.height) || n === null) return null;
1068
- r.push({
1069
- type: i.type,
1070
- stroke: i.stroke,
1071
- strokeWidth: i.strokeWidth,
1072
- fill: i.fill,
1073
- ...i.d === void 0 ? {} : { d: i.d },
1074
- ...i.x === void 0 ? {} : { x: i.x },
1075
- ...i.y === void 0 ? {} : { y: i.y },
1076
- ...i.width === void 0 ? {} : { width: i.width },
1077
- ...i.height === void 0 ? {} : { height: i.height },
1078
- ...n === void 0 ? {} : { text: n }
1079
- });
1080
- }
1081
- return {
1082
- type: "svg",
1083
- paths: r,
1084
- viewport: {
1085
- width: n.viewport.width,
1086
- height: n.viewport.height
1087
- }
1088
- };
1089
- }
1090
- function en(e) {
1091
- if (e === void 0) return;
1092
- if (!t(e)) return null;
1093
- let n = L(e.description, Pt), r = Yt(e.assignees), i = Xt(e.checklist);
1094
- if (n === null || r === null || i === null) return null;
1095
- let a = Array.isArray(e.files) ? e.files.filter((e) => typeof File < "u" && e instanceof File) : void 0, o = Array.isArray(e.attachmentIds) ? e.attachmentIds.map((e) => String(e).trim()).filter((e) => e.length > 0 && e.length <= N).slice(0, 20) : void 0;
1096
- return {
1097
- ...n === void 0 ? {} : { description: n },
1098
- ...r === void 0 ? {} : { assignees: r },
1099
- ...i === void 0 ? {} : { checklist: i },
1100
- ...a && a.length > 0 ? { files: a } : {},
1101
- ...o && o.length > 0 ? { attachmentIds: o } : {}
1102
- };
1103
- }
1104
- function tn(e) {
1105
- if (!t(e)) return null;
1106
- let n = {};
1107
- if ("content" in e) {
1108
- let t = I(e.content);
1109
- if (!t) return null;
1110
- n.content = t;
1111
- }
1112
- if ("status" in e) {
1113
- if (!Gt.has(e.status)) return null;
1114
- n.status = e.status;
1115
- }
1116
- if ("priority" in e) {
1117
- if (!Wt.has(e.priority)) return null;
1118
- n.priority = e.priority;
1119
- }
1120
- if ("description" in e) {
1121
- let t = L(e.description, Pt);
1122
- if (t === null) return null;
1123
- n.description = t;
1124
- }
1125
- if ("assignees" in e) {
1126
- let t = Yt(e.assignees);
1127
- if (t === null) return null;
1128
- n.assignees = t;
1129
- }
1130
- if ("checklist" in e) {
1131
- let t = Xt(e.checklist);
1132
- if (t === null) return null;
1133
- n.checklist = t;
1134
- }
1135
- if ("textSelection" in e) {
1136
- let t = Zt(e.textSelection);
1137
- if (t === null) return null;
1138
- n.textSelection = t;
1139
- }
1140
- if ("drawingData" in e) {
1141
- let t = $t(e.drawingData);
1142
- if (t === null) return null;
1143
- n.drawingData = t;
1144
- }
1145
- if ("attachmentIds" in e) {
1146
- let t = e.attachmentIds;
1147
- if (!Array.isArray(t)) return null;
1148
- n.attachmentIds = t.map((e) => String(e).trim()).filter((e) => e.length > 0 && e.length <= N).slice(0, 20);
1149
- }
1150
- return Object.keys(n).length > 0 ? n : void 0;
1151
- }
1152
- function B(e) {
1153
- return `${e}_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
1154
- }
1155
- function V(e, t) {
1156
- return e.getState().comments.some((e) => e.id === t);
1157
- }
1158
- function H(e, t, n) {
1159
- let r = e.getState().comments.filter((e) => e.id !== n.id), i = r.some((e) => e.id === t);
1160
- e.setState({ comments: i ? r.map((e) => e.id === t ? n : e) : [...r, n] });
1161
- }
1162
- function nn(e, t, n, r) {
1163
- e.setState({ comments: e.getState().comments.map((e) => {
1164
- if (e.id !== t) return e;
1165
- let i = e.replies.filter((e) => e.id !== r.id), a = i.some((e) => e.id === n);
1166
- return {
1167
- ...e,
1168
- replies: a ? i.map((e) => e.id === n ? r : e) : [...i, r]
1169
- };
1170
- }) });
1171
- }
1172
- function rn(e, t, n) {
1173
- return e.getState().comments.some((e) => e.id === t && e.replies.some((e) => e.id === n));
1174
- }
1175
- async function U(e) {
1176
- try {
1177
- let t = y(), n = await e.apiClient.getComments(t.path);
1178
- e.setState({
1179
- comments: n.comments,
1180
- pagination: n.pagination
1181
- });
1182
- } catch (t) {
1183
- e.handleError(t);
1184
- }
1185
- }
1186
- async function an(e, t) {
1187
- let n = e.getState().pagination;
1188
- if (!(!n || !n.hasMore) && !t.current) {
1189
- t.current = !0;
1190
- try {
1191
- e.setState({ isLoading: !0 });
1192
- let t = y(), r = await e.apiClient.getComments(t.path, "all", n.page + 1, n.limit), i = new Set(e.getState().comments.map((e) => e.id)), a = r.comments.filter((e) => !i.has(e.id));
1193
- e.setState({
1194
- comments: [...e.getState().comments, ...a],
1195
- pagination: r.pagination,
1196
- isLoading: !1
1197
- });
1198
- } catch (t) {
1199
- e.setState({ isLoading: !1 }), e.handleError(t);
1200
- } finally {
1201
- t.current = !1;
1202
- }
1203
- }
1204
- }
1205
- async function on(e, t, n, r, i, a, o = "medium", s, c, l) {
1206
- let u = e.getState().currentUser;
1207
- if (!u) return;
1208
- let d = I(i), f = qt(a), p = Zt(s), m = $t(c), h = en(l);
1209
- if (!Ut.has(r) || !d || !f || !Wt.has(o) || p === null || m === null || h === null) {
1210
- P(e, "invalid_comment", "Comment data is invalid");
1211
- return;
1212
- }
1213
- let g = `create:${r}:${d.slice(0, 50)}:${f.x}:${f.y}`;
1214
- if (n.has(g)) return;
1215
- n.add(g);
1216
- let _ = y(), v = h?.files ?? [], ee = v.map((e, t) => ({
1217
- id: B(`pending-att-${t}`),
1218
- type: e.type.startsWith("image/") ? "screenshot" : "file",
1219
- url: "",
1220
- filename: e.name,
1221
- size: e.size
1222
- })), b = B("temp"), te = {
1223
- id: b,
1224
- type: r,
1225
- content: d,
1226
- position: f,
1227
- status: "open",
1228
- priority: o,
1229
- author: u,
1230
- userId: u.id,
1231
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1232
- updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1233
- page: {
1234
- url: _.url,
1235
- path: _.path,
1236
- title: _.title
1237
- },
1238
- description: h?.description,
1239
- assignees: h?.assignees,
1240
- checklist: h?.checklist,
1241
- replies: [],
1242
- attachments: ee,
1243
- textSelection: p,
1244
- drawingData: m
1245
- };
1246
- e.setState({
1247
- comments: [...e.getState().comments, te],
1248
- activeComment: null,
1249
- activeTool: null,
1250
- isCommentModeActive: !1,
1251
- isDrawingModeActive: !1,
1252
- isHighlightModeActive: !1
1253
- });
1254
- try {
1255
- let { files: n, ...i } = h ?? {}, a = await e.apiClient.createComment(r, d, f, _, o, p, m, i, b), s = a;
1256
- if (v.length > 0) try {
1257
- let t = (await Promise.all(v.map(async (t) => {
1258
- let n = "." + (t.name.split(".").pop()?.toLowerCase() ?? ""), r = t.type.startsWith("image/") && [
1259
- ".jpg",
1260
- ".jpeg",
1261
- ".png",
1262
- ".gif",
1263
- ".webp"
1264
- ].includes(n);
1265
- return e.apiClient.uploadFile(t, r ? "screenshot" : "attachment", { commentId: a.id });
1266
- }))).map((e) => ({
1267
- id: e.id,
1268
- type: e.type === "screenshot" || e.type === "drawing" ? e.type : "file",
1269
- url: e.url,
1270
- thumbnail: e.thumbnail,
1271
- filename: e.filename,
1272
- size: e.size
1273
- }));
1274
- s = {
1275
- ...a,
1276
- attachments: t
1277
- };
1278
- } catch (t) {
1279
- e.handleError(t), s = {
1280
- ...a,
1281
- attachments: a.attachments ?? []
1282
- };
1283
- }
1284
- H(e, b, s), e.emit("comment:created", s), t.addActivity({
1285
- type: "comment_created",
1286
- threadId: s.id,
1287
- message: "created a new comment"
1288
- });
1289
- } catch (n) {
1290
- t.shouldQueueMutation(n) && t.queueMutation("createComment", [
1291
- r,
1292
- d,
1293
- f,
1294
- o,
1295
- p,
1296
- m,
1297
- h ? {
1298
- description: h.description,
1299
- assignees: h.assignees,
1300
- checklist: h.checklist,
1301
- attachmentIds: h.attachmentIds
1302
- } : void 0,
1303
- {
1304
- url: _.url,
1305
- path: _.path,
1306
- title: _.title
1307
- }
1308
- ], b) || (e.setState({ comments: e.getState().comments.filter((e) => e.id !== b) }), e.handleError(n));
1309
- } finally {
1310
- n.delete(g);
1311
- }
1312
- }
1313
- async function sn(e, t, n, r) {
1314
- if (!F(n)) return;
1315
- let i = tn(r);
1316
- if (i === null) {
1317
- P(e, "invalid_comment_update", "Comment update data is invalid");
1318
- return;
1319
- }
1320
- if (i === void 0) return;
1321
- let a = e.getState().comments, o = a.find((e) => e.id === n);
1322
- if (o) {
1323
- e.setState({ comments: a.map((e) => e.id === n ? {
1324
- ...e,
1325
- ...i
1326
- } : e) });
1327
- try {
1328
- let t = await e.apiClient.updateComment(n, i);
1329
- e.setState({ comments: e.getState().comments.map((e) => e.id === n ? t : e) }), e.emit("comment:updated", t);
1330
- } catch (r) {
1331
- t.shouldQueueMutation(r) && t.queueMutation("updateComment", [n, i]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n ? o : e) }), e.handleError(r));
1332
- }
1333
- }
1334
- }
1335
- async function cn(e, t, n) {
1336
- if (!F(n)) return;
1337
- let r = e.getState().comments, i = r.find((e) => e.id === n);
1338
- if (!i) return;
1339
- let a = e.getState().selectedComment;
1340
- e.setState({
1341
- comments: r.filter((e) => e.id !== n),
1342
- selectedComment: a?.id === n ? null : a
1343
- });
1344
- try {
1345
- await e.apiClient.deleteComment(n), e.emit("comment:deleted", { id: n });
1346
- } catch (r) {
1347
- if (!(t.shouldQueueMutation(r) && t.queueMutation("deleteComment", [n]))) {
1348
- let t = e.getState().comments;
1349
- e.setState({
1350
- comments: t.some((e) => e.id === n) ? t : [...t, i],
1351
- selectedComment: a
1352
- }), e.handleError(r);
1353
- }
1354
- }
1355
- }
1356
- async function ln(e, t, n, r) {
1357
- let i = e.getState().currentUser;
1358
- if (!i || !F(n) || !V(e, n)) return;
1359
- let a = I(r, jt);
1360
- if (!a) {
1361
- P(e, "invalid_reply", "Reply content is invalid");
1362
- return;
1363
- }
1364
- let o = B("temp_reply"), s = {
1365
- id: o,
1366
- content: a,
1367
- author: i,
1368
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
1369
- };
1370
- e.setState({ comments: e.getState().comments.map((e) => e.id === n ? {
1371
- ...e,
1372
- replies: [...e.replies, s]
1373
- } : e) });
1374
- try {
1375
- nn(e, n, o, await e.apiClient.addReply(n, a, o));
1376
- let t = e.getState().comments.find((e) => e.id === n);
1377
- t && e.emit("comment:updated", t);
1378
- } catch (r) {
1379
- t.shouldQueueMutation(r) && t.queueMutation("addReply", [n, a], o) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n ? {
1380
- ...e,
1381
- replies: e.replies.filter((e) => e.id !== o)
1382
- } : e) }), e.handleError(r));
1383
- }
1384
- }
1385
- async function un(e, t, n, r) {
1386
- if (!F(t) || !F(n) || !rn(e, t, n)) return;
1387
- let i = I(r, jt);
1388
- if (!i) {
1389
- P(e, "invalid_reply", "Reply content is invalid");
1390
- return;
1391
- }
1392
- let a = e.getState().comments, o = a.find((e) => e.id === t)?.replies.find((e) => e.id === n);
1393
- e.setState({ comments: a.map((e) => e.id === t ? {
1394
- ...e,
1395
- replies: e.replies.map((e) => e.id === n ? {
1396
- ...e,
1397
- content: i,
1398
- isEdited: !0
1399
- } : e)
1400
- } : e) });
1401
- try {
1402
- let r = await e.apiClient.updateReply(t, n, i);
1403
- e.setState({ comments: e.getState().comments.map((e) => e.id === t ? {
1404
- ...e,
1405
- replies: e.replies.map((e) => e.id === n ? r : e)
1406
- } : e) });
1407
- let a = e.getState().comments.find((e) => e.id === t);
1408
- a && e.emit("comment:updated", a);
1409
- } catch (r) {
1410
- e.setState({ comments: e.getState().comments.map((e) => e.id === t && o ? {
1411
- ...e,
1412
- replies: e.replies.map((e) => e.id === n ? o : e)
1413
- } : e) }), e.handleError(r);
1414
- }
1415
- }
1416
- async function dn(e, t, n) {
1417
- if (!F(t) || !F(n) || !rn(e, t, n)) return;
1418
- let r = e.getState().comments, i = r.find((e) => e.id === t)?.replies.find((e) => e.id === n);
1419
- e.setState({ comments: r.map((e) => e.id === t ? {
1420
- ...e,
1421
- replies: e.replies.filter((e) => e.id !== n)
1422
- } : e) });
1423
- try {
1424
- await e.apiClient.deleteReply(t, n);
1425
- let r = e.getState().comments.find((e) => e.id === t);
1426
- r && e.emit("comment:updated", r);
1427
- } catch (r) {
1428
- e.setState({ comments: e.getState().comments.map((e) => e.id === t && i && !e.replies.some((e) => e.id === n) ? {
1429
- ...e,
1430
- replies: [...e.replies, i]
1431
- } : e) }), e.handleError(r);
1432
- }
1433
- }
1434
- async function fn(e, t, n) {
1435
- if (!F(n) || !V(e, n)) return;
1436
- let r = e.getState().comments, i = r.find((e) => e.id === n);
1437
- e.setState({ comments: r.map((e) => e.id === n ? {
1438
- ...e,
1439
- status: "resolved"
1440
- } : e) });
1441
- try {
1442
- let r = await e.apiClient.resolveComment(n);
1443
- e.setState({ comments: e.getState().comments.map((e) => e.id === n ? r : e) }), e.emit("comment:resolved", r), e.emit("comment:updated", r), t.addActivity({
1444
- type: "comment_resolved",
1445
- threadId: n,
1446
- message: "resolved a comment"
1447
- });
1448
- } catch (r) {
1449
- t.shouldQueueMutation(r) && t.queueMutation("resolveComment", [n]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n && i ? i : e) }), e.handleError(r));
1450
- }
1451
- }
1452
- async function pn(e, t, n) {
1453
- if (!F(n) || !V(e, n)) return;
1454
- let r = e.getState().comments, i = r.find((e) => e.id === n);
1455
- e.setState({ comments: r.map((e) => e.id === n ? {
1456
- ...e,
1457
- status: "open"
1458
- } : e) });
1459
- try {
1460
- let t = await e.apiClient.unresolveComment(n);
1461
- e.setState({ comments: e.getState().comments.map((e) => e.id === n ? t : e) }), e.emit("comment:updated", t);
1462
- } catch (r) {
1463
- t.shouldQueueMutation(r) && t.queueMutation("unresolveComment", [n]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n && i ? i : e) }), e.handleError(r));
1464
- }
1465
- }
1466
- async function mn(e, t, n) {
1467
- if (!F(n) || !V(e, n)) return;
1468
- let r = e.getState().comments, i = r.find((e) => e.id === n);
1469
- e.setState({ comments: r.map((e) => e.id === n ? {
1470
- ...e,
1471
- status: "complete"
1472
- } : e) });
1473
- try {
1474
- let r = await e.apiClient.markComplete(n);
1475
- e.setState({ comments: e.getState().comments.map((e) => e.id === n ? r : e) }), e.emit("comment:completed", r), t.addActivity({
1476
- type: "comment_completed",
1477
- threadId: n,
1478
- message: "marked a comment as complete"
1479
- });
1480
- } catch (r) {
1481
- t.shouldQueueMutation(r) && t.queueMutation("completeComment", [n]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n && i ? i : e) }), e.handleError(r));
1482
- }
1483
- }
1484
- async function hn(t, n, r, i) {
1485
- if (!F(r) || typeof i != "string") return;
1486
- let a = i.trim();
1487
- if (!a || a.length > Ht || e(a)) return;
1488
- let o = t.getState().comments.find((e) => e.id === r);
1489
- if (!o) return;
1490
- let s = (o.reactions ?? []).filter((t) => typeof t.emoji == "string" && t.emoji.length > 0 && t.emoji.length <= Ht && !e(t.emoji) && typeof t.count == "number" && Number.isInteger(t.count) && t.count >= 0 && t.count <= Vt), c = s.find((e) => e.emoji === a)?.reacted, l = [...s];
1491
- if (c) {
1492
- let e = l.findIndex((e) => e.emoji === a), t = l[e];
1493
- t.count <= 1 ? l.splice(e, 1) : l[e] = {
1494
- ...t,
1495
- count: t.count - 1,
1496
- reacted: !1
1497
- };
1498
- } else {
1499
- let e = l.findIndex((e) => e.emoji === a), t = e === -1 ? void 0 : l[e];
1500
- t ? l[e] = {
1501
- ...t,
1502
- count: Math.min(t.count + 1, Vt),
1503
- reacted: !0
1504
- } : l.push({
1505
- emoji: a,
1506
- count: 1,
1507
- reacted: !0
1508
- });
1509
- }
1510
- let u = t.getState().comments;
1511
- t.setState({ comments: u.map((e) => e.id === r ? {
1512
- ...e,
1513
- reactions: l
1514
- } : e) });
1515
- try {
1516
- c ? await t.apiClient.removeReaction(r, a) : await t.apiClient.addReaction(r, a);
1517
- let e = t.getState().comments.find((e) => e.id === r);
1518
- e && t.emit("comment:reaction", {
1519
- commentId: r,
1520
- emoji: a,
1521
- comment: e
1522
- });
1523
- } catch (e) {
1524
- n.shouldQueueMutation(e) && n.queueMutation("reactToComment", [
1525
- r,
1526
- a,
1527
- c ? "remove" : "add"
1528
- ]) || (t.setState({ comments: t.getState().comments.map((e) => e.id === r ? {
1529
- ...e,
1530
- reactions: s
1531
- } : e) }), t.handleError(e));
1532
- }
1533
- }
1534
- async function gn(e, t, n, r, i) {
1535
- if (!F(n) || !V(e, n)) return;
1536
- let a = qt({
1537
- x: r,
1538
- y: i
1539
- });
1540
- if (!a) {
1541
- P(e, "invalid_position", "Comment position is invalid");
1542
- return;
1543
- }
1544
- let o = e.getState().comments, s = o.find((e) => e.id === n);
1545
- e.setState({ comments: o.map((e) => e.id === n ? {
1546
- ...e,
1547
- position: a
1548
- } : e) });
1549
- try {
1550
- let t = await e.apiClient.updatePosition(n, a);
1551
- e.setState({ comments: e.getState().comments.map((e) => e.id === n ? t : e) }), e.emit("comment:position", {
1552
- commentId: n,
1553
- position: a
1554
- });
1555
- } catch (r) {
1556
- t.shouldQueueMutation(r) && t.queueMutation("updatePosition", [n, a]) || (e.setState({ comments: e.getState().comments.map((e) => e.id === n && s ? {
1557
- ...e,
1558
- position: s.position
1559
- } : e) }), e.handleError(r));
1560
- }
1561
- }
1562
- function _n(e, t) {
1563
- e.setState({ selectedComment: t });
1564
- }
1565
- async function vn(e, t, n, r, i) {
1566
- let a = e.getState().currentUser;
1567
- if (!a) return;
1568
- let o = I(i), s = Zt(r);
1569
- if (!o || s == null) {
1570
- P(e, "invalid_highlight", "Highlight data is invalid");
1571
- return;
1572
- }
1573
- let c = `highlight:${s.xpath}:${s.startOffset}:${o.slice(0, 50)}`;
1574
- if (n.has(c)) return;
1575
- n.add(c);
1576
- let l = y(), u = B("temp"), d = {
1577
- id: u,
1578
- type: "highlight",
1579
- content: o,
1580
- position: {
1581
- x: 0,
1582
- y: 0
1583
- },
1584
- status: "open",
1585
- priority: "medium",
1586
- author: a,
1587
- userId: a.id,
1588
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1589
- updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1590
- page: {
1591
- url: l.url,
1592
- path: l.path,
1593
- title: l.title
1594
- },
1595
- replies: [],
1596
- attachments: [],
1597
- textSelection: s
1598
- };
1599
- e.setState({ comments: [...e.getState().comments, d] });
1600
- try {
1601
- let t = await e.apiClient.createHighlight(o, s, l, "medium", u);
1602
- H(e, u, t), e.emit("comment:created", t);
1603
- } catch (n) {
1604
- t.shouldQueueMutation(n) && t.queueMutation("createHighlight", [
1605
- o,
1606
- s,
1607
- {
1608
- url: l.url,
1609
- path: l.path,
1610
- title: l.title
1611
- }
1612
- ], u) || (e.setState({ comments: e.getState().comments.filter((e) => e.id !== u) }), e.handleError(n));
1613
- } finally {
1614
- n.delete(c);
1615
- }
1616
- }
1617
- async function yn(e, t, n, r, i, a) {
1618
- let o = e.getState().currentUser;
1619
- if (!o) return;
1620
- let s = I(a), c = qt(i), l = $t(r);
1621
- if (!s || !c || l == null) {
1622
- P(e, "invalid_drawing", "Drawing comment data is invalid");
1623
- return;
1624
- }
1625
- let u = `drawing:${c.x}:${c.y}:${s.slice(0, 50)}`;
1626
- if (n.has(u)) return;
1627
- n.add(u);
1628
- let d = y(), f = B("temp"), p = {
1629
- id: f,
1630
- type: "drawing",
1631
- content: s,
1632
- position: c,
1633
- status: "open",
1634
- priority: "medium",
1635
- author: o,
1636
- userId: o.id,
1637
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1638
- updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1639
- page: {
1640
- url: d.url,
1641
- path: d.path,
1642
- title: d.title
1643
- },
1644
- replies: [],
1645
- attachments: [],
1646
- drawingData: l
1647
- };
1648
- e.setState({ comments: [...e.getState().comments, p] });
1649
- try {
1650
- let t = await e.apiClient.createDrawing(s, l, c, d, f);
1651
- H(e, f, t), e.emit("comment:created", t);
1652
- } catch (n) {
1653
- t.shouldQueueMutation(n) && t.queueMutation("createDrawing", [
1654
- s,
1655
- l,
1656
- c,
1657
- {
1658
- url: d.url,
1659
- path: d.path,
1660
- title: d.title
1661
- }
1662
- ], f) || (e.setState({ comments: e.getState().comments.filter((e) => e.id !== f) }), e.handleError(n));
1663
- } finally {
1664
- n.delete(u);
1665
- }
1666
- }
1667
- var bn = 1e4, xn = 2048, Sn = 10 * 1024 * 1024, Cn = 20 * 1024 * 1024, W = 16384, wn = 32e6, Tn = 10, En = 10 * 1024 * 1024, Dn = 25 * 1024 * 1024, On = new Set([
1668
- "jpg",
1669
- "jpeg",
1670
- "png",
1671
- "gif",
1672
- "webp",
1673
- "pdf",
1674
- "doc",
1675
- "docx",
1676
- "txt",
1677
- "csv"
1678
- ]), kn = 15e3, An = 1e4, jn = {
1679
- "image/gif": "gif",
1680
- "image/jpeg": "jpg",
1681
- "image/png": "png",
1682
- "image/webp": "webp"
1683
- };
1684
- function G(e, t) {
1685
- let n = Error(t);
1686
- return n.error = e, n.code = 400, n;
1687
- }
1688
- function Mn(e) {
1689
- if (typeof e != "string") throw G("invalid_position", "Invalid position");
1690
- let t = e.trim();
1691
- if (!t || t.length > xn || i(t)) throw G("invalid_position", "Invalid position");
1692
- return t;
1693
- }
1694
- function Nn(e) {
1695
- if (!t(e) || !c(e.x) || !c(e.y)) throw G("invalid_position", "Invalid position");
1696
- return {
1697
- x: e.x,
1698
- y: e.y,
1699
- ...e.element === void 0 ? {} : { element: Mn(e.element) },
1700
- ...e.xpath === void 0 ? {} : { xpath: Mn(e.xpath) }
1701
- };
1702
- }
1703
- function Pn(e) {
1704
- if (typeof e != "string") throw G("invalid_content", "Screenshot comment is required");
1705
- let t = e.trim();
1706
- if (!t || t.length > bn || i(t)) throw G("invalid_content", "Screenshot comment is required");
1707
- return t;
1708
- }
1709
- function Fn(e) {
1710
- return typeof Blob < "u" && e instanceof Blob;
1711
- }
1712
- function In(e) {
1713
- return typeof File < "u" && e instanceof File;
1714
- }
1715
- function Ln(e) {
1716
- return typeof HTMLElement < "u" && e instanceof HTMLElement;
1717
- }
1718
- function Rn(e) {
1719
- if (e !== void 0) {
1720
- if (!Ln(e)) throw G("invalid_element", "Invalid screenshot target");
1721
- return e;
1722
- }
1723
- if (typeof document > "u" || !document.body) throw G("invalid_element", "A browser document is required to capture screenshots");
1724
- return document.body;
1725
- }
1726
- function zn(e) {
1727
- let t = /^data:(image\/(?:png|jpeg|gif|webp));base64,/i.exec(e)?.[1];
1728
- return t ? t.toLowerCase() : null;
1729
- }
1730
- function Bn(e) {
1731
- if (!t(e)) throw G("invalid_screenshot", "Invalid screenshot result");
1732
- let n = typeof e.dataUrl == "string" ? e.dataUrl.trim() : "", r = e.blob, i = e.dimensions;
1733
- if (!zn(n) || n.length > Cn || !Fn(r) || r.size <= 0 || r.size > Sn || r.type && !Object.prototype.hasOwnProperty.call(jn, r.type)) throw G("invalid_screenshot", "Invalid screenshot result");
1734
- if (!t(i)) throw G("invalid_screenshot", "Invalid screenshot dimensions");
1735
- let { width: a, height: o } = i;
1736
- if (typeof a != "number" || typeof o != "number" || !Number.isFinite(a) || !Number.isFinite(o) || a <= 0 || o <= 0 || a > W || o > W) throw G("invalid_screenshot", "Invalid screenshot dimensions");
1737
- return {
1738
- dataUrl: n,
1739
- blob: r,
1740
- dimensions: {
1741
- width: a,
1742
- height: o
1743
- }
1744
- };
1745
- }
1746
- function Vn(e) {
1747
- let t = zn(e.dataUrl);
1748
- return e.blob.type || t;
1749
- }
1750
- function Hn(e) {
1751
- return `screenshot.${jn[Vn(e)]}`;
1752
- }
1753
- function Un(e, t, n) {
1754
- let r = null;
1755
- return new Promise((i, a) => {
1756
- r = setTimeout(() => {
1757
- r = null, a(Error(n));
1758
- }, t), e.then((e) => {
1759
- r && clearTimeout(r), r = null, i(e);
1760
- }, (e) => {
1761
- r && clearTimeout(r), r = null, a(e);
1762
- });
1763
- });
1764
- }
1765
- function Wn(e) {
1766
- return new Promise((t, n) => {
1767
- let r = !1, i = setTimeout(() => {
1768
- r = !0, n(/* @__PURE__ */ Error("toBlob timed out"));
1769
- }, An);
1770
- e.toBlob((e) => {
1771
- r || (r = !0, clearTimeout(i), e ? t(e) : n(/* @__PURE__ */ Error("toBlob returned null")));
1772
- }, "image/png");
1773
- });
1774
- }
1775
- function Gn(e) {
1776
- let t = e.lastIndexOf(".");
1777
- return t >= 0 ? e.slice(t + 1).toLowerCase() : "";
1778
- }
1779
- function Kn(e) {
1780
- if (!Array.isArray(e)) throw G("invalid_files", "Files must be an array");
1781
- if (e.length > Tn) throw G("too_many_files", `Cannot upload more than ${Tn} files at once`);
1782
- let t = 0;
1783
- for (let n of e) {
1784
- if (!In(n)) throw G("invalid_files", "Invalid file upload");
1785
- if (n.size > En) throw G("file_too_large", `File "${n.name}" exceeds the ${En / 1024 / 1024}MB limit`);
1786
- if (t += n.size, t > Dn) throw G("upload_too_large", `Total upload size exceeds the ${Dn / 1024 / 1024}MB limit`);
1787
- if (i(n.name) || n.name.includes("/") || n.name.includes("\\")) throw G("invalid_filename", "Filename contains invalid characters");
1788
- if (s(n.name)) throw G("invalid_file_type", `File type ".${Gn(n.name)}" is not allowed`);
1789
- if (!On.has(Gn(n.name))) throw G("invalid_file_type", `File type ".${Gn(n.name)}" is not supported. Allowed: ${[...On].map((e) => `.${e}`).join(", ")}`);
1790
- }
1791
- return e;
1792
- }
1793
- function qn(e) {
1794
- try {
1795
- return e.matches?.("input[type=\"password\"],[data-commentkit-redact],[data-html2canvas-ignore],[autocomplete*=\"cc-\"],[autocomplete=\"current-password\"],[autocomplete=\"new-password\"]") ?? !1;
1796
- } catch {
1797
- return !1;
1798
- }
1799
- }
1800
- async function Jn(e, t, n, r = {}) {
1801
- try {
1802
- let e = Rn(n);
1803
- if (t) return Bn(await t(e));
1804
- let r;
1805
- try {
1806
- r = (await import("html2canvas")).default;
1807
- } catch {
1808
- /* v8 ignore next 3 -- dynamic import() can't be intercepted by vi.mock */
1809
- throw Error("Screenshot requires either a custom screenshotProvider in config or html2canvas installed. Install html2canvas: npm install html2canvas — or provide config.screenshotProvider.");
1810
- }
1811
- let i = await Un(r(e, {
1812
- useCORS: !0,
1813
- allowTaint: !1,
1814
- scale: 2,
1815
- logging: !1,
1816
- ignoreElements: qn
1817
- }), kn, "html2canvas timed out after 15s");
1818
- if (i.width > W || i.height > W || i.width * i.height > wn) throw G("screenshot_too_large", "Captured area is too large to screenshot");
1819
- return Bn({
1820
- dataUrl: i.toDataURL("image/png"),
1821
- blob: await Wn(i),
1822
- dimensions: {
1823
- width: i.width,
1824
- height: i.height
1825
- }
1826
- });
1827
- } catch (t) {
1828
- return r.reportErrors !== !1 && (console.error("[CommentKit] Screenshot failed:", t), e.handleError({
1829
- error: "screenshot_failed",
1830
- message: "Failed to capture screenshot",
1831
- code: 500
1832
- })), null;
1833
- }
1834
- }
1835
- async function Yn(e, t, n, r) {
1836
- try {
1837
- let i = Bn(t), a = Pn(n), o = Nn(r);
1838
- e.setState({ isLoading: !0 });
1839
- let s = new File([i.blob], Hn(i), { type: Vn(i) }), c = y(), l = await e.apiClient.uploadScreenshot(s, {
1840
- content: a,
1841
- position: o,
1842
- page: c
1843
- });
1844
- return e.setState({
1845
- comments: [...e.getState().comments, l],
1846
- isLoading: !1,
1847
- activeScreenshot: null
1848
- }), e.emit("comment:created", l), l;
1849
- } catch (t) {
1850
- return e.setState({ isLoading: !1 }), e.handleError(t), null;
1851
- }
1852
- }
1853
- async function Xn(e, t, n) {
1854
- try {
1855
- let r = Kn(t);
1856
- return r.length === 0 ? [] : await e.apiClient.uploadFiles(r, n);
1857
- } catch (t) {
1858
- return e.handleError(t), [];
1859
- }
1860
- }
1861
- var Zn = 4e3, Qn = 500, $n = 2e3, er = 1e3, tr = 5, nr = 25, rr = 3 * 1024 * 1024;
1862
- function ir(e) {
1863
- let t = E(e?.comment, $n);
1864
- return t.length > 0 ? t : null;
1865
- }
1866
- function ar(e) {
1867
- return (e?.attachments ?? []).slice(0, tr).flatMap((e) => {
1868
- let t = E(e.name, er), n = E(e.path, er);
1869
- return !t || !n ? [] : [{
1870
- name: t,
1871
- path: n,
1872
- ...e.pathSource ? { pathSource: e.pathSource } : {},
1873
- ...e.type ? { type: E(e.type, er) } : {},
1874
- ...typeof e.size == "number" ? { size: e.size } : {},
1875
- ...typeof e.lastModified == "number" ? { lastModified: e.lastModified } : {}
1876
- }];
1877
- });
1878
- }
1879
- function or(e) {
1880
- return typeof HTMLElement < "u" && e instanceof HTMLElement;
1881
- }
1882
- function sr(e, t, n, r) {
1883
- let i = e.getBoundingClientRect(), a = h(e), o = d(e), s = e.getAttribute("class"), c = e.getAttribute("role"), l = e.getAttribute("aria-label"), u = E(e.textContent, Qn), f = E(e.outerHTML, Zn);
1884
- return {
1885
- found: !0,
1886
- tagName: e.tagName.toLowerCase(),
1887
- ...e.id ? { id: e.id } : {},
1888
- ...s ? { className: s } : {},
1889
- ...c ? { role: c } : {},
1890
- ...l ? { ariaLabel: l } : {},
1891
- ...u ? { text: u } : {},
1892
- rect: {
1893
- top: i.top,
1894
- left: i.left,
1895
- width: i.width,
1896
- height: i.height
1897
- },
1898
- ...f ? { htmlPreview: f } : {},
1899
- ...a ? { selector: a } : {},
1900
- ...o ? { xpath: o } : {},
1901
- ...t ? {
1902
- source: cr(t),
1903
- stack: n.map(cr)
1904
- } : {},
1905
- ...r ? { componentName: r } : {}
1906
- };
1907
- }
1908
- function cr(e) {
1909
- return {
1910
- filePath: e.filePath,
1911
- lineNumber: e.lineNumber,
1912
- columnNumber: e.columnNumber,
1913
- componentName: e.componentName
1914
- };
1915
- }
1916
- function lr(e) {
1917
- let t = `${e.filePath}${e.lineNumber === null ? "" : `:${e.lineNumber}`}${e.columnNumber === null ? "" : `:${e.columnNumber}`}`;
1918
- return e.componentName ? `${e.componentName} (${t})` : t;
1919
- }
1920
- function ur(e, t, n, r, i, a) {
1921
- let o = ["# CommentKit Element Grab", ""], s = t.tagName ?? "element", c = t.id ? `#${t.id}` : "";
1922
- if (o.push(`**Tag:** \`${s}${c}\``), i && o.push(`**Comment:** ${i}`), a.length > 0) {
1923
- o.push("", "**Attachments:**");
1924
- for (let e of a) {
1925
- let t = [
1926
- e.type ? `type: \`${e.type}\`` : null,
1927
- typeof e.size == "number" ? `size: ${e.size} bytes` : null,
1928
- e.pathSource ? `path source: ${e.pathSource}` : null
1929
- ].filter(Boolean).join(", ");
1930
- o.push(`- \`${e.name}\` - path: \`${e.path}\`${t ? ` (${t})` : ""}`);
1931
- }
1932
- }
1933
- if (t.componentName && o.push(`**Component:** \`${t.componentName}\``), t.source && o.push(`**Source:** ${lr(t.source)}`), t.stack && t.stack.length > 1) {
1934
- o.push("", "**Stack:**");
1935
- for (let e of t.stack) o.push(`- ${lr(e)}`);
1936
- }
1937
- return t.source || (t.selector && o.push(`**Selector:** \`${t.selector}\``), t.xpath && o.push(`**XPath:** \`${t.xpath}\``)), o.push(`**Page:** ${e.title || "Untitled"} — ${e.url || e.path}`), o.push(""), o.push("**HTML:**", "```html", n, "```", ""), r && o.push("**Screenshot:** attached to clipboard as an image (paste below this text).", ""), o.join("\n");
1938
- }
1939
- function dr(e) {
1940
- let t = e.element;
1941
- return {
1942
- tagName: t.tagName,
1943
- id: t.id,
1944
- className: t.className,
1945
- textContent: t.text,
1946
- componentName: t.componentName,
1947
- filePath: t.source?.filePath,
1948
- lineNumber: t.source?.lineNumber ?? void 0,
1949
- columnNumber: t.source?.columnNumber ?? void 0,
1950
- comment: e.comment ?? void 0,
1951
- attachments: e.attachments,
1952
- selector: t.selector,
1953
- xpath: t.xpath
1954
- };
1955
- }
1956
- function fr(e) {
1957
- if (typeof window > "u" || typeof window.dispatchEvent != "function") return;
1958
- let t = e[0];
1959
- t && window.dispatchEvent(new CustomEvent("commentkit:element-selected", { detail: {
1960
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1961
- page: t.page,
1962
- elements: e.map(dr)
1963
- } }));
1964
- }
1965
- async function pr(e, t, n, r) {
1966
- if (!e || typeof Element > "u" || !(e instanceof Element) || typeof e.getBoundingClientRect != "function") return null;
1967
- let i = (or(e), e), a = await Ae(e), o = a?.source ?? null, s = a?.stack ?? [], c = a?.componentName ?? null, l = await Jn(t, n, i, { reportErrors: !1 }), u = l?.dataUrl ?? null, d = l?.blob ?? null, f = sr(e, o, s, c), p = f.htmlPreview ?? E(e.outerHTML, Zn), m = y(), h = ir(r), g = ar(r), _ = ur({
1968
- url: m.url,
1969
- path: m.path,
1970
- title: m.title
1971
- }, f, p, u, h, g);
1972
- try {
1973
- d ? await et(_, d) : await k(_);
1974
- } catch {}
1975
- let v = {
1976
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1977
- page: {
1978
- url: m.url,
1979
- path: m.path,
1980
- title: m.title
1981
- },
1982
- element: f,
1983
- comment: h,
1984
- attachments: g,
1985
- html: p,
1986
- screenshotDataUrl: u,
1987
- markdown: _
1988
- };
1989
- return fr([v]), v;
1990
- }
1991
- function mr(e, t, n, r) {
1992
- let i = [
1993
- "# CommentKit Element Grab",
1994
- "",
1995
- `**Elements:** ${t.length}`,
1996
- `**Page:** ${e.title || "Untitled"} — ${e.url || e.path}`
1997
- ];
1998
- if (n && i.push(`**Comment:** ${n}`), r.length > 0) {
1999
- i.push("", "**Attachments:**");
2000
- for (let e of r) i.push(`- \`${e.name}\` - path: \`${e.path}\`${e.pathSource ? ` (path source: ${e.pathSource})` : ""}`);
2001
- }
2002
- return i.push(""), t.forEach((e, t) => {
2003
- let { element: n } = e, r = n.tagName ?? "element", a = n.id ? `#${n.id}` : "";
2004
- i.push(`## [${t + 1}] \`${r}${a}\``), n.componentName && i.push(`- Component: \`${n.componentName}\``), n.source && i.push(`- Source: ${lr(n.source)}`), n.stack && n.stack.length > 1 && i.push(`- Stack: ${n.stack.map((e) => e.componentName ?? e.filePath).join(" → ")}`), n.source || (n.selector && i.push(`- Selector: \`${n.selector}\``), n.xpath && i.push(`- XPath: \`${n.xpath}\``)), i.push("", "```html", e.html, "```", ""), e.screenshotDataUrl && i.push(`![screenshot](${e.screenshotDataUrl})`, "");
2005
- }), i.join("\n");
2006
- }
2007
- async function hr(e, t, n, r) {
2008
- let i = e.filter((e) => !!e && typeof Element < "u" && e instanceof Element && typeof e.getBoundingClientRect == "function");
2009
- if (i.length === 0) return null;
2010
- let a = i.slice(0, nr);
2011
- i.length > nr && typeof console < "u" && console.warn(`[CommentKit] grabElements was called with ${i.length} elements — capped to ${nr} for clipboard size. Pass fewer elements to avoid truncation.`);
2012
- let o = [], s = 0, c = 0, l = ir(r), u = ar(r);
2013
- for (let e of a) {
2014
- let r = (or(e), e), i = await Ae(e), a = i?.source ?? null, d = i?.stack ?? [], f = i?.componentName ?? null, p = null;
2015
- if (s < rr) {
2016
- let e = (await Jn(t, n, r, { reportErrors: !1 }))?.dataUrl ?? null;
2017
- e && s + e.length <= rr ? (p = e, s += e.length) : e && c++;
2018
- } else c++;
2019
- let m = sr(e, a, d, f), h = m.htmlPreview ?? E(e.outerHTML, Zn), g = y(), _ = ur({
2020
- url: g.url,
2021
- path: g.path,
2022
- title: g.title
2023
- }, m, h, p, l, u);
2024
- o.push({
2025
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
2026
- page: {
2027
- url: g.url,
2028
- path: g.path,
2029
- title: g.title
2030
- },
2031
- element: m,
2032
- comment: l,
2033
- attachments: u,
2034
- html: h,
2035
- screenshotDataUrl: p,
2036
- markdown: _
2037
- });
2038
- }
2039
- c > 0 && typeof console < "u" && console.warn(`[CommentKit] grabElements dropped ${c} screenshot${c === 1 ? "" : "s"} to stay under the ${Math.round(rr / 1024 / 1024)}MB clipboard budget.`);
2040
- let d = y(), f = mr({
2041
- url: d.url,
2042
- path: d.path,
2043
- title: d.title
2044
- }, o, l, u);
2045
- try {
2046
- await k(f);
2047
- } catch {}
2048
- let p = {
2049
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
2050
- page: {
2051
- url: d.url,
2052
- path: d.path,
2053
- title: d.title
2054
- },
2055
- results: o,
2056
- attachments: u,
2057
- markdown: f
2058
- };
2059
- return fr(o), p;
2060
- }
2061
- var gr = {
2062
- c: "comment",
2063
- e: "select",
2064
- d: "draw",
2065
- h: "highlight",
2066
- s: "screenshot"
2067
- };
2068
- function _r(e) {
2069
- return typeof e.composedPath == "function" ? e.composedPath() : e.target ? [e.target] : [];
2070
- }
2071
- function vr(e) {
2072
- return typeof Element < "u" && e instanceof Element;
2073
- }
2074
- function yr(e) {
2075
- if (!vr(e)) return !1;
2076
- let t = e.tagName.toLowerCase();
2077
- return t === "input" || t === "textarea" || t === "select" || e.isContentEditable || e.getAttribute("role") === "textbox";
2078
- }
2079
- function br(e) {
2080
- let t = e.activeElement;
2081
- for (; t?.shadowRoot?.activeElement;) t = t.shadowRoot.activeElement;
2082
- return t;
2083
- }
2084
- function xr(e) {
2085
- return _r(e).some(yr) ? !0 : typeof document > "u" ? !1 : yr(br(document));
2086
- }
2087
- function Sr(e) {
2088
- return _r(e).some((e) => vr(e) && (e.hasAttribute("data-commentkit") || e.hasAttribute("data-commentkit-ui") || e.hasAttribute("data-commentkit-host")));
2089
- }
2090
- function Cr(e) {
2091
- return (e.ctrlKey || e.metaKey) && e.shiftKey && (e.key === "K" || e.key === "k" || e.code === "KeyK");
2092
- }
2093
- function wr(e) {
2094
- let t = e.key.toLowerCase(), n = e.code.startsWith("Key") ? e.code.slice(3).toLowerCase() : "";
2095
- return gr[t] ?? gr[n] ?? null;
2096
- }
2097
- function K(e) {
2098
- e.preventDefault(), e.stopPropagation();
2099
- }
2100
- function Tr(e, t) {
2101
- if (e.isLoginModalVisible) t.toggleLoginModal();
2102
- else if (e.isShortcutsOverlayVisible) t.toggleShortcutsOverlay();
2103
- else if (e.activeComment) t.setState({ activeComment: null });
2104
- else if (e.selectedComment) t.selectComment(null);
2105
- else if (e.activeTool) t.setTool(null);
2106
- else if (e.isSidebarVisible) t.toggleSidebar();
2107
- else if (e.isOverlayVisible) t.toggleOverlay();
2108
- else return !1;
2109
- return !0;
2110
- }
2111
- function Er(e, t) {
2112
- e.isAuthenticated ? t.toggleOverlay() : t.toggleLoginModal();
2113
- }
2114
- function Dr(e, t, n) {
2115
- if (e.defaultPrevented || e.repeat || e.isComposing) return;
2116
- let r = xr(e), i = Sr(e);
2117
- if (Cr(e)) {
2118
- if (r) return;
2119
- K(e), Er(t, n);
2120
- return;
2121
- }
2122
- if (e.key === "Escape") {
2123
- if (r && !i) return;
2124
- Tr(t, n) && K(e);
2125
- return;
2126
- }
2127
- if (t.isAuthenticated && (t.isOverlayVisible || t.activeTool !== null) && !r && !e.ctrlKey && !e.metaKey && !e.altKey) {
2128
- if (e.key === "?") {
2129
- K(e), n.toggleShortcutsOverlay();
2130
- return;
2131
- }
2132
- let r = wr(e);
2133
- r && (K(e), n.setTool(t.activeTool === r ? null : r));
2134
- }
2135
- }
2136
- function q(e) {
2137
- return Object.freeze(e);
2138
- }
2139
- var Or = Object.freeze({
2140
- auth: q([
2141
- "isAuthenticated",
2142
- "currentUser",
2143
- "project",
2144
- "isLoginModalVisible",
2145
- "otpStep",
2146
- "otpEmail"
2147
- ]),
2148
- ui: q([
2149
- "isOverlayVisible",
2150
- "isSidebarVisible",
2151
- "isShortcutsOverlayVisible",
2152
- "activeTool",
2153
- "isCommentModeActive",
2154
- "isDrawingModeActive",
2155
- "isHighlightModeActive",
2156
- "isScreenshotModeActive",
2157
- "selectedComment",
2158
- "activeComment",
2159
- "activeDrawing",
2160
- "activeScreenshot",
2161
- "panelView",
2162
- "activities",
2163
- "isLoading",
2164
- "error"
2165
- ]),
2166
- comments: q([
2167
- "comments",
2168
- "pagination",
2169
- "seenThreadIds"
2170
- ]),
2171
- realtime: q([
2172
- "onlineUsers",
2173
- "connectionStatus",
2174
- "pendingMutations",
2175
- "isOnline"
2176
- ])
2177
- });
2178
- function kr() {
2179
- return typeof navigator < "u" && typeof navigator.onLine == "boolean" ? navigator.onLine : !0;
2180
- }
2181
- var Ar = 2e3;
2182
- function jr() {
2183
- return {
2184
- isAuthenticated: !1,
2185
- isOverlayVisible: !0,
2186
- isCommentModeActive: !1,
2187
- isDrawingModeActive: !1,
2188
- isHighlightModeActive: !1,
2189
- isScreenshotModeActive: !1,
2190
- isSidebarVisible: !1,
2191
- isLoginModalVisible: !1,
2192
- isShortcutsOverlayVisible: !1,
2193
- currentUser: null,
2194
- project: null,
2195
- comments: [],
2196
- activeTool: null,
2197
- selectedComment: null,
2198
- activeComment: null,
2199
- activeDrawing: null,
2200
- activeScreenshot: null,
2201
- onlineUsers: [],
2202
- connectionStatus: "disconnected",
2203
- activities: [],
2204
- seenThreadIds: /* @__PURE__ */ new Set(),
2205
- panelView: "list",
2206
- isLoading: !1,
2207
- error: null,
2208
- otpStep: "idle",
2209
- otpEmail: null,
2210
- pagination: null,
2211
- pendingMutations: [],
2212
- isOnline: kr()
2213
- };
2214
- }
2215
- var Mr = o.PENDING_MUTATIONS, Nr = o.RETRY_DELAY, J = o.ID, Pr = o.CONTENT, Fr = o.REPLY_CONTENT, Ir = o.SELECTOR, Lr = o.EMOJI, Rr = new Set([
2216
- "createComment",
2217
- "createHighlight",
2218
- "createDrawing",
2219
- "updateComment",
2220
- "deleteComment",
2221
- "resolveComment",
2222
- "unresolveComment",
2223
- "completeComment",
2224
- "addReply",
2225
- "reactToComment",
2226
- "updatePosition"
2227
- ]), zr = new Set([
2228
- "pin",
2229
- "highlight",
2230
- "drawing"
2231
- ]), Br = new Set([
2232
- "low",
2233
- "medium",
2234
- "high",
2235
- "urgent"
2236
- ]), Vr = new Set(["add", "remove"]);
2237
- function Hr(e) {
2238
- return t(e) && c(e.x) && c(e.y) && u(e.element, Ir) && u(e.xpath, Ir);
2239
- }
2240
- function Ur(e) {
2241
- return typeof e == "string" && e.length <= o.PAGE && !i(e);
2242
- }
2243
- function Wr(e) {
2244
- return e === void 0 ? !0 : t(e) && Ur(e.url) && Ur(e.path) && Ur(e.title);
2245
- }
2246
- function Gr(e) {
2247
- return typeof e == "string" && Rr.has(e);
2248
- }
2249
- function Kr(e) {
2250
- return Number.isInteger(e) && Number(e) >= 0;
2251
- }
2252
- function qr(e) {
2253
- return Kr(e) ? Math.min(e, 5) : 0;
2254
- }
2255
- function Jr(e) {
2256
- return e.isNetworkError() || e.code === 408 || e.isRateLimitError();
2257
- }
2258
- function Yr(e) {
2259
- return e instanceof T ? Jr(e) : !0;
2260
- }
2261
- function Xr(e) {
2262
- return e instanceof T ? {
2263
- error: e.error,
2264
- message: e.message,
2265
- code: e.code,
2266
- ...e.details ? { details: e.details } : {}
2267
- } : {
2268
- error: "retry_failed",
2269
- message: "Operation failed after maximum retries",
2270
- code: 0
2271
- };
2272
- }
2273
- function Zr(e = Date.now()) {
2274
- return `mutation_${e}_${typeof globalThis.crypto?.randomUUID == "function" ? globalThis.crypto.randomUUID() : Math.random().toString(36).slice(2, 12)}`;
2275
- }
2276
- function Qr(e) {
2277
- return Array.isArray(e) ? e.map((e) => Qr(e)) : t(e) ? Object.fromEntries(Object.entries(e).map(([e, t]) => [e, Qr(t)])) : e;
2278
- }
2279
- function $r(e) {
2280
- try {
2281
- if (typeof structuredClone == "function") return structuredClone(e);
2282
- } catch {}
2283
- return Qr(e);
2284
- }
2285
- function ei(e, r) {
2286
- switch (e) {
2287
- case "createComment": {
2288
- let [e, n, i, o, s, c, l, u] = r;
2289
- return r.length >= 3 && r.length <= 8 && zr.has(String(e)) && a(n, Pr) && Hr(i) && (o === void 0 || Br.has(String(o))) && (s === void 0 || t(s)) && (c === void 0 || t(c)) && (l === void 0 || t(l)) && Wr(u);
2290
- }
2291
- case "createHighlight": {
2292
- let [e, n, i] = r;
2293
- return r.length >= 2 && r.length <= 3 && a(e, Pr) && t(n) && Wr(i);
2294
- }
2295
- case "createDrawing": {
2296
- let [e, n, i, o] = r;
2297
- return r.length >= 3 && r.length <= 4 && a(e, Pr) && t(n) && Hr(i) && Wr(o);
2298
- }
2299
- case "updateComment": return r.length === 2 && n(r[0], J) && t(r[1]);
2300
- case "deleteComment":
2301
- case "resolveComment":
2302
- case "unresolveComment":
2303
- case "completeComment": return r.length === 1 && n(r[0], J);
2304
- case "addReply": return r.length === 2 && n(r[0], J) && a(r[1], Fr);
2305
- case "reactToComment": return r.length >= 2 && r.length <= 3 && n(r[0], J) && n(r[1], Lr) && (r[2] === void 0 || Vr.has(String(r[2])));
2306
- case "updatePosition": return r.length === 2 && n(r[0], J) && Hr(r[1]);
2307
- }
2308
- }
2309
- function ti(e) {
2310
- return t(e) ? n(e.id, J) ? Gr(e.type) ? Array.isArray(e.args) ? Number.isFinite(e.timestamp) ? Kr(e.retries) ? u(e.tempId, J) ? ei(e.type, e.args) ? null : "Queued mutation args are invalid" : "Queued mutation has an invalid temp id" : "Queued mutation has an invalid retry count" : "Queued mutation has an invalid timestamp" : "Queued mutation args must be an array" : "Queued mutation has an unsupported type" : "Queued mutation has an invalid id" : "Queued mutation must be an object";
2311
- }
2312
- function ni(e) {
2313
- let t = ti(e);
2314
- if (t) throw new T("invalid_mutation", t, 400);
2315
- }
2316
- var ri = "commentkit:offline-queue:";
2317
- function ii() {
2318
- try {
2319
- return typeof localStorage > "u" ? null : localStorage;
2320
- } catch {
2321
- return null;
2322
- }
2323
- }
2324
- function ai(e) {
2325
- return `${ri}${e}`;
2326
- }
2327
- function oi(e, t) {
2328
- if (!e) return;
2329
- let n = ii();
2330
- if (n) try {
2331
- t.length === 0 ? n.removeItem(ai(e)) : n.setItem(ai(e), JSON.stringify(t));
2332
- } catch {}
2333
- }
2334
- function si(e) {
2335
- if (!e) return [];
2336
- let t = ii();
2337
- if (!t) return [];
2338
- try {
2339
- let n = t.getItem(ai(e));
2340
- if (!n) return [];
2341
- let r = JSON.parse(n);
2342
- if (!Array.isArray(r)) return [];
2343
- let i = [];
2344
- for (let e of r) {
2345
- if (i.length >= Mr) break;
2346
- ti(e) === null && i.push(e);
2347
- }
2348
- return i;
2349
- } catch {
2350
- return [];
2351
- }
2352
- }
2353
- function Y(e) {
2354
- Promise.resolve().then(e);
2355
- }
2356
- function ci(e, t) {
2357
- return e.type === t.type ? (t.type === "updatePosition" || t.type === "updateComment") && e.args[0] === t.args[0] : !1;
2358
- }
2359
- function li(e, n) {
2360
- return n.type === "updateComment" && t(e.args[1]) ? {
2361
- ...n,
2362
- args: [n.args[0], {
2363
- ...e.args[1],
2364
- ...n.args[1]
2365
- }]
2366
- } : n;
2367
- }
2368
- function ui(e, t) {
2369
- let n = e.findIndex((e) => ci(e, t));
2370
- if (n !== -1) {
2371
- let r = [...e];
2372
- return r[n] = li(r[n], t), r;
2373
- }
2374
- return e.length >= Mr ? null : [...e, t];
2375
- }
2376
- function X(e, t, n) {
2377
- e.emit("offline:failed", {
2378
- id: t,
2379
- error: n
2380
- });
2381
- }
2382
- function di(e, t) {
2383
- return e.isOnline ? t instanceof T ? Jr(t) : !1 : !0;
2384
- }
2385
- function fi(e, t, n, r, i) {
2386
- let a = Zr();
2387
- if (!Gr(n) || !Array.isArray(r) || !ei(n, r) || !u(i, J)) return X(e, a, {
2388
- error: "invalid_mutation",
2389
- message: "Queued mutation args are invalid",
2390
- code: 400
2391
- }), !1;
2392
- let o = {
2393
- id: a,
2394
- type: n,
2395
- args: $r(r),
2396
- timestamp: Date.now(),
2397
- retries: 0,
2398
- ...i === void 0 ? {} : { tempId: i }
2399
- }, s = ui(e.getState().pendingMutations, o);
2400
- return s ? (e.setState({ pendingMutations: s }), e.emit("offline:queued", o), e.getState().isOnline && Y(t), !0) : (X(e, a, {
2401
- error: "queue_full",
2402
- message: "Offline mutation queue is full",
2403
- code: 0
2404
- }), !1);
2405
- }
2406
- function pi(e, t, n) {
2407
- if (t.current || e.getState().pendingMutations.length === 0) return;
2408
- let r = e.getState().pendingMutations[0];
2409
- if (!r) return;
2410
- let i = qr(r.retries), a = Math.min(Nr, Ar * 2 ** i);
2411
- t.current = setTimeout(() => {
2412
- t.current = null, n();
2413
- }, a);
2414
- }
2415
- async function mi(e, t, r, i) {
2416
- let a = e.getState();
2417
- if (!a.isOnline || a.pendingMutations.length === 0 || !a.isAuthenticated || t.current) return;
2418
- t.current = !0;
2419
- let o = e.getState().pendingMutations[0];
2420
- if (!o) {
2421
- t.current = !1;
2422
- return;
2423
- }
2424
- let s = ti(o);
2425
- if (s) {
2426
- let i = e.getState().pendingMutations.filter((e) => e !== o);
2427
- e.setState({ pendingMutations: i }), X(e, n(o.id, J) ? o.id : "invalid", {
2428
- error: "invalid_mutation",
2429
- message: s,
2430
- code: 400
2431
- }), i.length > 0 && Y(r), t.current = !1;
2432
- return;
2433
- }
2434
- e.emit("offline:retrying", {
2435
- id: o.id,
2436
- attempt: o.retries + 1
2437
- });
2438
- let c = i ?? ((t) => gi(e, t));
2439
- try {
2440
- await c(o);
2441
- let n = e.getState().pendingMutations.filter((e) => e.id !== o.id);
2442
- e.setState({ pendingMutations: n }), e.emit("offline:completed", { id: o.id }), n.length > 0 ? Y(r) : t.reconcileAfterDrain && (t.reconcileAfterDrain = !1, U(e));
2443
- } catch (n) {
2444
- let i = {
2445
- ...o,
2446
- retries: qr(o.retries) + 1
2447
- };
2448
- if (Yr(n) && i.retries < 5) {
2449
- let t = e.getState().pendingMutations.map((e) => e.id === o.id ? i : e);
2450
- e.setState({ pendingMutations: t }), Y(r);
2451
- } else {
2452
- let i = e.getState().pendingMutations.filter((e) => e.id !== o.id);
2453
- e.setState({ pendingMutations: i }), X(e, o.id, Xr(n)), i.length > 0 ? (t.reconcileAfterDrain = !0, Y(r)) : (t.reconcileAfterDrain = !1, U(e));
2454
- }
2455
- } finally {
2456
- t.current = !1;
2457
- }
2458
- }
2459
- function hi(e, t, n) {
2460
- let r = !1, i = e.getState().pendingMutations.map((e) => e.type !== "createComment" && e.args[0] === t ? (r = !0, {
2461
- ...e,
2462
- args: [n, ...e.args.slice(1)]
2463
- }) : e);
2464
- r && e.setState({ pendingMutations: i });
2465
- }
2466
- async function gi(e, t) {
2467
- switch (ni(t), t.type) {
2468
- case "createComment": {
2469
- let [n, r, i, a, o, s, c, l] = t.args, u = await e.apiClient.createComment(n, r, i, l ?? y(), a, o, s, c, t.tempId);
2470
- u && t.tempId && (H(e, t.tempId, u), hi(e, t.tempId, u.id));
2471
- break;
2472
- }
2473
- case "createHighlight": {
2474
- let [n, r, i] = t.args, a = await e.apiClient.createHighlight(n, r, i ?? y(), "medium", t.tempId);
2475
- a && t.tempId && (H(e, t.tempId, a), hi(e, t.tempId, a.id));
2476
- break;
2477
- }
2478
- case "createDrawing": {
2479
- let [n, r, i, a] = t.args, o = await e.apiClient.createDrawing(n, r, i, a ?? y(), t.tempId);
2480
- o && t.tempId && (H(e, t.tempId, o), hi(e, t.tempId, o.id));
2481
- break;
2482
- }
2483
- case "updateComment": {
2484
- let [n, r] = t.args;
2485
- await e.apiClient.updateComment(n, r);
2486
- break;
2487
- }
2488
- case "deleteComment": {
2489
- let [n] = t.args;
2490
- await e.apiClient.deleteComment(n);
2491
- break;
2492
- }
2493
- case "resolveComment": {
2494
- let [n] = t.args;
2495
- await e.apiClient.resolveComment(n);
2496
- break;
2497
- }
2498
- case "unresolveComment": {
2499
- let [n] = t.args;
2500
- await e.apiClient.unresolveComment(n);
2501
- break;
2502
- }
2503
- case "completeComment": {
2504
- let [n] = t.args;
2505
- await e.apiClient.markComplete(n);
2506
- break;
2507
- }
2508
- case "addReply": {
2509
- let [n, r] = t.args, i = await e.apiClient.addReply(n, r, t.tempId);
2510
- i && t.tempId && nn(e, n, t.tempId, i);
2511
- break;
2512
- }
2513
- case "reactToComment": {
2514
- let [n, r, i] = t.args, a;
2515
- a = i === "add" || i === "remove" ? i === "remove" : e.getState().comments.find((e) => e.id === n)?.reactions?.find((e) => e.emoji === r)?.reacted === !0, a ? await e.apiClient.removeReaction(n, r) : await e.apiClient.addReaction(n, r);
2516
- break;
2517
- }
2518
- case "updatePosition": {
2519
- let [n, r] = t.args;
2520
- await e.apiClient.updatePosition(n, r);
2521
- break;
2522
- }
2523
- }
2524
- }
2525
- var Z = null;
2526
- async function _i() {
2527
- return Z || (Z = await import("./core/realtime-C3_O7gi2.js"), Z);
2528
- }
2529
- var vi = typeof window < "u", yi = new Set([
2530
- "list",
2531
- "detail",
2532
- "settings",
2533
- "activity",
2534
- "dev-export"
2535
- ]), bi = new Set([
2536
- "comment",
2537
- "draw",
2538
- "highlight",
2539
- "screenshot",
2540
- "select",
2541
- null
2542
- ]), xi = 256, Q = "0.6.8";
2543
- function Si(e) {
2544
- let t = e.trim().match(/^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:[-+].*)?$/);
2545
- return t ? [
2546
- Number(t[1]),
2547
- Number(t[2] ?? 0),
2548
- Number(t[3] ?? 0)
2549
- ] : null;
2550
- }
2551
- function Ci(e) {
2552
- return /^v?\d+(?:\.\d+)?(?:\.\d+)?-/.test(e.trim());
2553
- }
2554
- function wi(e, t) {
2555
- if (Ci(e)) return !1;
2556
- let n = Si(e), r = Si(t);
2557
- if (!n || !r) return !1;
2558
- for (let e = 0; e < 3; e++) {
2559
- let t = n[e] ?? 0, i = r[e] ?? 0;
2560
- if (t > i) return !0;
2561
- if (t < i) return !1;
2562
- }
2563
- return !1;
2564
- }
2565
- var Ti = class extends it {
2566
- get isProcessingQueue() {
2567
- return this.queueGuard.current;
2568
- }
2569
- set isProcessingQueue(e) {
2570
- this.queueGuard.current = e;
2571
- }
2572
- get isLoadingMore() {
2573
- return this.loadMoreGuard.current;
2574
- }
2575
- set isLoadingMore(e) {
2576
- this.loadMoreGuard.current = e;
2577
- }
2578
- get retryTimer() {
2579
- return this.retryTimerRef.current;
2580
- }
2581
- set retryTimer(e) {
2582
- this.retryTimerRef.current = e;
2583
- }
2584
- constructor(e) {
2585
- super(), this.wsManager = null, this.wsUnsubscribers = [], this.keyboardHandler = null, this.holdActivationHandler = null, this.holdBlurHandler = null, this.toggleHandler = null, this.mouseMoveHandler = null, this.hashChangeHandler = null, this.onlineHandler = null, this.offlineHandler = null, this.initialized = !1, this.destroyed = !1, this.screenshotProvider = null, this.bootRetryTimer = null, this.bootAttempts = 0, this.pendingStateUpdates = null, this.flushScheduled = !1, this.isFlushing = !1, this.queueGuard = { current: !1 }, this.activeMutations = /* @__PURE__ */ new Set(), this.sliceSubscribers = /* @__PURE__ */ new Map(), this.retryTimerRef = { current: null }, this.otpFailedAttempts = 0, this.otpCooldownUntil = 0, this.overlayBeforeTool = null, this.loadMoreGuard = { current: !1 }, this.offlinePersistUnsub = null, this.escapeBlockers = /* @__PURE__ */ new Set(), this.config = { ...e }, vi && !this.config.environment && (this.config.environment = this.detectEnvironment()), this.apiClient = new Ce(this.config), this.apiClient.setOnAuthExpired(() => this.handleAuthExpired()), this.state = jr(), this.requiresShortcut() && (this.state.isOverlayVisible = !1), this.screenshotProvider = e.screenshotProvider || null, this.ctx = {
2586
- getState: () => this.getInternalState(),
2587
- setState: (e) => this.setState(e),
2588
- apiClient: this.apiClient,
2589
- emit: (e, t) => {
2590
- this.destroyed || this.emit(e, t);
2591
- },
2592
- handleError: (e) => this.handleError(e),
2593
- config: this.config
2594
- }, this.kbdCallbacks = {
2595
- toggleLoginModal: () => this.toggleLoginModal(),
2596
- toggleOverlay: () => this.toggleOverlay(),
2597
- toggleSidebar: () => this.toggleSidebar(),
2598
- toggleShortcutsOverlay: () => this.toggleShortcutsOverlay(),
2599
- setTool: (e) => this.setTool(e),
2600
- selectComment: (e) => this.selectComment(e),
2601
- setState: (e) => this.setState(e)
2602
- }, this.commentCb = {
2603
- shouldQueueMutation: (e) => this.shouldQueueMutation(e),
2604
- queueMutation: (e, t, n) => this.queueMutation(e, t, n),
2605
- addActivity: (e) => this.addActivity(e)
2606
- }, this.realtimeRefs = {
2607
- wsManager: this.wsManager,
2608
- wsUnsubscribers: this.wsUnsubscribers,
2609
- mouseMoveHandler: this.mouseMoveHandler
2610
- }, e.enabled !== !1 && vi && Promise.resolve().then(() => this.boot()).catch((e) => this.handleError(e));
2611
- /* v8 ignore stop */
2612
- }
2613
- detectEnvironment() {
2614
- let e = window.location.hostname;
2615
- return e === "localhost" || e === "127.0.0.1" || e === "[::1]" || e.endsWith(".localhost") ? "development" : e.endsWith(".vercel.app") || e.endsWith(".netlify.app") || e.endsWith(".pages.dev") || e.includes("-preview.") || e.endsWith("-preview") || /-preview-\d/.test(e) ? "preview" : e.startsWith("staging.") || e.startsWith("stage.") || e.includes(".staging.") || e.endsWith(".staging") ? "staging" : "production";
2616
- }
2617
- async boot() {
2618
- if (this.destroyed) return;
2619
- this.keyboardHandler = this.handleKeyboardShortcuts.bind(this), window.addEventListener("keydown", this.keyboardHandler, !0);
2620
- let e = this.config.ui?.activation;
2621
- e?.mode === "hold" && e.key && (this.holdActivationHandler = (e) => {
2622
- if (this.destroyed || !this.matchesHoldKey(e)) return;
2623
- let t = this.getInternalState().activeTool;
2624
- e.type === "keydown" && !t ? this.setTool("select") : e.type === "keyup" && t === "select" && this.setTool(null);
2625
- }, window.addEventListener("keydown", this.holdActivationHandler), window.addEventListener("keyup", this.holdActivationHandler), this.holdBlurHandler = () => {
2626
- this.destroyed || this.getInternalState().activeTool === "select" && this.setTool(null);
2627
- }, window.addEventListener("blur", this.holdBlurHandler)), this.toggleHandler = () => this.handleToggleRequest(), window.addEventListener("commentkit:toggle-overlay", this.toggleHandler), this.hashChangeHandler = () => this.handleDeepLink(), window.addEventListener("hashchange", this.hashChangeHandler), this.handleDeepLink(), this.onlineHandler = () => {
2628
- this.destroyed || (this.setState({ isOnline: !0 }), this.processOfflineQueue());
2629
- }, this.offlineHandler = () => {
2630
- this.destroyed || this.setState({ isOnline: !1 });
2631
- }, window.addEventListener("online", this.onlineHandler), window.addEventListener("offline", this.offlineHandler), this.autoDetectInviteToken(), this.config.apiKey && await this.initialize();
2632
- }
2633
- autoDetectInviteToken() {
2634
- try {
2635
- let e = new URLSearchParams(window.location.search), t = e.get("ck_invite");
2636
- if (!t) return;
2637
- /^[\w-]{64}$/.test(t) && (this.config.inviteToken = t), e.delete("ck_invite");
2638
- let n = e.toString(), r = window.location.pathname + (n ? `?${n}` : "") + window.location.hash;
2639
- window.history.replaceState(window.history.state, "", r);
2640
- } catch {}
2641
- }
2642
- async initialize() {
2643
- if (!(this.initialized || this.destroyed)) {
2644
- this.initialized = !0, this.bootAttempts += 1;
2645
- try {
2646
- this.setState({
2647
- isLoading: !0,
2648
- error: null
2649
- });
2650
- let e = await this.apiClient.validateApiKey();
2651
- if (this.destroyed) return;
2652
- if (!e.valid) {
2653
- this.handleError({
2654
- error: "invalid_api_key",
2655
- message: "Invalid API key",
2656
- code: 401
2657
- });
2658
- return;
2659
- }
2660
- e.project?.id && (this.config.projectId = String(e.project.id), this.hydrateOfflineQueue());
2661
- let t = e.project?.slug ?? e.project?.id;
2662
- if (t && this.apiClient.setProject(String(t)), e.project?.features && (this.config.features = e.project.features), e.project?.reverb && e.project.features?.realtime) {
2663
- let t = e.project.reverb;
2664
- this.config.reverb = {
2665
- key: t.key,
2666
- host: t.host,
2667
- port: t.port ?? 443,
2668
- scheme: t.scheme ?? "wss"
2669
- };
2670
- }
2671
- let n = e.project?.sdkLatestVersion;
2672
- n && wi(n, "0.6.8") && (console.warn(`[CommentKit] You are using v${Q}. Update to v${n}: npm update @commentkit/comment-kit`), this.emit("sdk:outdated", {
2673
- current: Q,
2674
- latest: n
2675
- })), this.setState({
2676
- project: e.project,
2677
- isLoading: !1
2678
- }), await this.restorePersistedSession();
2679
- } catch (e) {
2680
- if (this.initialized = !1, this.handleError(e), this.bootAttempts < 3 && !this.destroyed) {
2681
- let e = 2e3 * 2 ** (this.bootAttempts - 1);
2682
- this.bootRetryTimer = setTimeout(() => {
2683
- this.bootRetryTimer = null, this.initialize();
2684
- }, e);
2685
- }
2686
- }
2687
- }
2688
- }
2689
- setState(e) {
2690
- this.destroyed || (this.pendingStateUpdates ? Object.assign(this.pendingStateUpdates, e) : this.pendingStateUpdates = { ...e }, this.flushScheduled || (this.flushScheduled = !0, Promise.resolve().then(() => this.flushState())));
2691
- }
2692
- getInternalState() {
2693
- return this.pendingStateUpdates ? {
2694
- ...this.state,
2695
- ...this.pendingStateUpdates
2696
- } : this.state;
2697
- }
2698
- cloneStateSnapshot(e) {
2699
- return {
2700
- ...e,
2701
- currentUser: e.currentUser ? structuredClone(e.currentUser) : null,
2702
- project: e.project ? structuredClone(e.project) : null,
2703
- comments: structuredClone(e.comments),
2704
- selectedComment: e.selectedComment ? structuredClone(e.selectedComment) : null,
2705
- activeComment: e.activeComment ? structuredClone(e.activeComment) : null,
2706
- activeDrawing: e.activeDrawing ? structuredClone(e.activeDrawing) : null,
2707
- activeScreenshot: e.activeScreenshot ? {
2708
- ...e.activeScreenshot,
2709
- dimensions: { ...e.activeScreenshot.dimensions }
2710
- } : null,
2711
- onlineUsers: structuredClone(e.onlineUsers),
2712
- pendingMutations: structuredClone(e.pendingMutations),
2713
- activities: structuredClone(e.activities),
2714
- seenThreadIds: new Set(e.seenThreadIds),
2715
- pagination: e.pagination ? { ...e.pagination } : null
2716
- };
2717
- }
2718
- flushState() {
2719
- if (this.destroyed) {
2720
- this.pendingStateUpdates = null, this.flushScheduled = !1;
2721
- return;
2722
- }
2723
- if (this.isFlushing) return;
2724
- this.flushScheduled = !1;
2725
- let e = this.pendingStateUpdates;
2726
- if (!e) return;
2727
- this.pendingStateUpdates = null;
2728
- let t = this.state;
2729
- this.state = {
2730
- ...t,
2731
- ...e
2732
- }, this.isFlushing = !0;
2733
- try {
2734
- this.notifySubscribers(e, t);
2735
- } finally {
2736
- this.isFlushing = !1;
2737
- }
2738
- this.pendingStateUpdates && !this.flushScheduled && (this.flushScheduled = !0, Promise.resolve().then(() => this.flushState()));
2739
- }
2740
- notifySubscribers(e, t) {
2741
- e.activeTool !== void 0 && e.activeTool !== t.activeTool && this.emit("tool:changed", e.activeTool), e.isOverlayVisible !== void 0 && e.isOverlayVisible !== t.isOverlayVisible && this.emit("overlay:toggled", e.isOverlayVisible), e.isSidebarVisible !== void 0 && e.isSidebarVisible !== t.isSidebarVisible && this.emit("sidebar:toggled", e.isSidebarVisible), e.isLoginModalVisible !== void 0 && e.isLoginModalVisible !== t.isLoginModalVisible && this.emit("loginmodal:toggled", e.isLoginModalVisible), e.isShortcutsOverlayVisible !== void 0 && e.isShortcutsOverlayVisible !== t.isShortcutsOverlayVisible && this.emit("shortcuts:toggled", e.isShortcutsOverlayVisible), e.connectionStatus !== void 0 && e.connectionStatus !== t.connectionStatus && this.emit("connection:changed", e.connectionStatus);
2742
- let n = Object.keys(e);
2743
- for (let [e, t] of this.sliceSubscribers) {
2744
- let r = Or[e];
2745
- if (n.some((e) => r.includes(e))) for (let n of t) try {
2746
- n(this.state);
2747
- } catch (t) {
2748
- console.error(`[CommentKit] Error in ${e} slice subscriber:`, t);
2749
- }
2750
- }
2751
- this.emit("state:changed", this.state);
2752
- }
2753
- flushStateSync() {
2754
- this.pendingStateUpdates && !this.isFlushing && this.flushState();
2755
- }
2756
- getState() {
2757
- return this.flushStateSync(), this.cloneStateSnapshot(this.state);
2758
- }
2759
- getFeatures() {
2760
- return {
2761
- comments: this.config.features?.comments ?? !0,
2762
- drawing: this.config.features?.drawing ?? !0,
2763
- highlighting: this.config.features?.highlighting ?? !0,
2764
- screenshots: this.config.features?.screenshots ?? !0,
2765
- realtime: this.config.features?.realtime ?? !0
2766
- };
2767
- }
2768
- getConfig() {
2769
- return {
2770
- apiKey: this.config.apiKey,
2771
- ...this.config.baseUrl !== void 0 && { baseUrl: this.config.baseUrl },
2772
- ...this.config.enabled !== void 0 && { enabled: this.config.enabled },
2773
- screenshotProvider: this.config.screenshotProvider,
2774
- ui: this.config.ui ? { ...this.config.ui } : void 0
2775
- };
2776
- }
2777
- async validateInvite(e) {
2778
- if (!this.destroyed) return kt(this.ctx, e, (e) => this.login(e));
2779
- }
2780
- onSlice(e, t) {
2781
- if (!Or[e] || typeof t != "function" || this.destroyed) return () => {};
2782
- let n = this.sliceSubscribers.get(e);
2783
- return n || (n = /* @__PURE__ */ new Set(), this.sliceSubscribers.set(e, n)), n.add(t), () => n.delete(t);
2784
- }
2785
- select(e, t) {
2786
- if (typeof e != "function" || typeof t != "function" || this.destroyed) return () => {};
2787
- let n;
2788
- try {
2789
- n = e(this.getInternalState());
2790
- } catch (e) {
2791
- return this.handleError(e), () => {};
2792
- }
2793
- return this.on("state:changed", (r) => {
2794
- try {
2795
- let i = e(r);
2796
- i !== n && (n = i, t(i));
2797
- } catch (e) {
2798
- this.handleError(e);
2799
- }
2800
- });
2801
- }
2802
- handleError(e) {
2803
- if (this.destroyed) return;
2804
- let t = e && typeof e == "object" ? e : null, n = typeof t?.message == "string" && t.message ? t.message : String(e ?? "Unknown error"), r = {
2805
- error: typeof t?.error == "string" && t.error ? t.error : "unknown",
2806
- message: n,
2807
- code: typeof t?.code == "number" && Number.isFinite(t.code) ? t.code : 0,
2808
- ...t?.details && typeof t.details == "object" ? { details: t.details } : {}
2809
- };
2810
- console.error("[CommentKit]", r.message), this.setState({
2811
- error: r.message,
2812
- isLoading: !1
2813
- }), this.emit("error", r);
2814
- }
2815
- async restorePersistedSession() {
2816
- if (this.destroyed) return;
2817
- let e = dt(this.config.projectId);
2818
- if (e) try {
2819
- this.apiClient.setAuthToken(e.token), this.apiClient.setUserEmail(e.email), this.setState({
2820
- currentUser: e.user,
2821
- isAuthenticated: !0,
2822
- isLoginModalVisible: !1,
2823
- otpStep: "idle",
2824
- otpEmail: null,
2825
- error: null
2826
- }), this.emit("auth:login", e.user), await this.afterAuthenticated();
2827
- } catch {
2828
- this.handleAuthExpired();
2829
- }
2830
- }
2831
- async afterAuthenticated() {
2832
- this.destroyed || (this.getFeatures().realtime && this.initializeWebSocket(), await this.loadComments(), this.handleDeepLink(), this.getInternalState().pendingMutations.length > 0 && this.scheduleRetry());
2833
- }
2834
- async login(e) {
2835
- if (!this.destroyed) return St(this.ctx, e);
2836
- }
2837
- async verifyOtp(e) {
2838
- if (this.destroyed) return;
2839
- let t = Date.now();
2840
- if (t < this.otpCooldownUntil) {
2841
- let e = Math.ceil((this.otpCooldownUntil - t) / 1e3);
2842
- this.handleError({
2843
- error: "otp_throttled",
2844
- message: `Too many attempts. Please wait ${e}s and try again.`,
2845
- code: 429
2846
- });
2847
- return;
2848
- }
2849
- return Ct(this.ctx, e, {
2850
- onAuthenticated: async () => {
2851
- await this.afterAuthenticated();
2852
- },
2853
- onSuccess: () => {
2854
- this.otpFailedAttempts = 0, this.otpCooldownUntil = 0;
2855
- },
2856
- onWrongOtp: () => {
2857
- if (this.otpFailedAttempts += 1, this.otpFailedAttempts >= 3) {
2858
- let e = Math.min(3e4, 2e3 * 2 ** (this.otpFailedAttempts - 3));
2859
- this.otpCooldownUntil = Date.now() + e;
2860
- }
2861
- }
2862
- });
2863
- }
2864
- cancelOtp() {
2865
- this.destroyed || wt(this.ctx);
2866
- }
2867
- async resendOtp() {
2868
- if (!this.destroyed) return Tt(this.ctx);
2869
- }
2870
- logout() {
2871
- this.destroyed || (this.overlayBeforeTool = null, Et(this.ctx, () => {
2872
- this.disconnectRealtime(!0);
2873
- }));
2874
- }
2875
- handleAuthExpired() {
2876
- this.overlayBeforeTool = null, this.disconnectRealtime(!0), Dt(this.ctx);
2877
- }
2878
- toggleLoginModal() {
2879
- this.destroyed || Ot(this.ctx);
2880
- }
2881
- requiresShortcut() {
2882
- return this.config.environment !== "development";
2883
- }
2884
- toggleOverlay() {
2885
- if (this.destroyed) return;
2886
- let e = !this.getInternalState().isOverlayVisible;
2887
- this.overlayBeforeTool = null, this.setState({
2888
- isOverlayVisible: e,
2889
- ...!e && {
2890
- selectedComment: null,
2891
- activeComment: null
2892
- }
2893
- });
2894
- }
2895
- toggleSidebar() {
2896
- this.destroyed || this.setState({ isSidebarVisible: !this.getInternalState().isSidebarVisible });
2897
- }
2898
- setTool(e) {
2899
- if (this.destroyed || !bi.has(e)) return;
2900
- let t = this.getInternalState();
2901
- if (!t.isAuthenticated && e !== "select" && e !== null) {
2902
- this.toggleLoginModal();
2903
- return;
2904
- }
2905
- let n;
2906
- e === null ? (n = this.overlayBeforeTool ?? t.isOverlayVisible, this.overlayBeforeTool = null) : (this.overlayBeforeTool === null && (this.overlayBeforeTool = t.isOverlayVisible), n = !1), this.setState({
2907
- activeTool: e,
2908
- isCommentModeActive: e === "comment",
2909
- isDrawingModeActive: e === "draw",
2910
- isHighlightModeActive: e === "highlight",
2911
- isScreenshotModeActive: e === "screenshot",
2912
- isOverlayVisible: n,
2913
- selectedComment: null,
2914
- activeComment: null,
2915
- activeDrawing: null,
2916
- activeScreenshot: null
2917
- });
2918
- }
2919
- async loadComments() {
2920
- return U(this.ctx);
2921
- }
2922
- async loadMoreComments() {
2923
- this.destroyed || await an(this.ctx, this.loadMoreGuard);
2924
- }
2925
- async reloadComments() {
2926
- if (!this.destroyed) return U(this.ctx);
2927
- }
2928
- async createComment(e, t, n, r = "medium", i, a, o) {
2929
- if (!this.destroyed) return on(this.ctx, this.commentCb, this.activeMutations, e, t, n, r, i, a, o);
2930
- }
2931
- async updateComment(e, t) {
2932
- if (!this.destroyed) return sn(this.ctx, this.commentCb, e, t);
2933
- }
2934
- async deleteComment(e) {
2935
- if (!this.destroyed) return cn(this.ctx, this.commentCb, e);
2936
- }
2937
- async addReply(e, t) {
2938
- if (!this.destroyed) return ln(this.ctx, this.commentCb, e, t);
2939
- }
2940
- async updateReply(e, t, n) {
2941
- if (!this.destroyed) return un(this.ctx, e, t, n);
2942
- }
2943
- async deleteReply(e, t) {
2944
- if (!this.destroyed) return dn(this.ctx, e, t);
2945
- }
2946
- async resolveComment(e) {
2947
- if (!this.destroyed) return fn(this.ctx, this.commentCb, e);
2948
- }
2949
- async unresolveComment(e) {
2950
- if (!this.destroyed) return pn(this.ctx, this.commentCb, e);
2951
- }
2952
- selectComment(e) {
2953
- this.destroyed || _n(this.ctx, e);
2954
- }
2955
- async completeComment(e) {
2956
- if (!this.destroyed) return mn(this.ctx, this.commentCb, e);
2957
- }
2958
- async reactToComment(e, t) {
2959
- if (!this.destroyed) return hn(this.ctx, this.commentCb, e, t);
2960
- }
2961
- async updateCommentPosition(e, t, n) {
2962
- if (!this.destroyed) return gn(this.ctx, this.commentCb, e, t, n);
2963
- }
2964
- hydrateOfflineQueue() {
2965
- let e = si(this.config.projectId);
2966
- if (e.length > 0) {
2967
- let t = this.getInternalState().pendingMutations, n = new Set(t.map((e) => e.id)), r = [...t, ...e.filter((e) => !n.has(e.id))];
2968
- this.setState({ pendingMutations: r }), this.getInternalState().isOnline && this.scheduleRetry();
2969
- }
2970
- this.offlinePersistUnsub?.(), this.offlinePersistUnsub = this.select((e) => e.pendingMutations, (e) => oi(this.config.projectId, e));
2971
- }
2972
- shouldQueueMutation(e) {
2973
- return di(this.getInternalState(), e);
2974
- }
2975
- queueMutation(e, t, n) {
2976
- return fi(this.ctx, () => this.scheduleRetry(), e, t, n);
2977
- }
2978
- scheduleRetry() {
2979
- pi(this.ctx, this.retryTimerRef, () => this.processOfflineQueue());
2980
- }
2981
- async processOfflineQueue() {
2982
- await mi(this.ctx, this.queueGuard, () => this.scheduleRetry(), (e) => this.executeMutation(e));
2983
- }
2984
- async executeMutation(e) {
2985
- return gi(this.ctx, e);
2986
- }
2987
- getPendingMutationCount() {
2988
- return this.getInternalState().pendingMutations.length;
2989
- }
2990
- clearError() {
2991
- this.destroyed || this.getInternalState().error == null || this.setState({ error: null });
2992
- }
2993
- retryConnection() {
2994
- if (!(this.destroyed || !this.getInternalState().isAuthenticated)) {
2995
- if (this.wsManager) {
2996
- this.wsManager.reconnect();
2997
- return;
2998
- }
2999
- this.initializeWebSocket();
3000
- }
3001
- }
3002
- markThreadSeen(e) {
3003
- if (this.destroyed || typeof e != "string" || !e.trim() || e.length > xi) return;
3004
- let t = new Set(this.getInternalState().seenThreadIds);
3005
- if (t.add(e), t.size > 1e3) {
3006
- let e = Array.from(t);
3007
- t.clear();
3008
- for (let n of e.slice(-1e3)) t.add(n);
3009
- }
3010
- this.setState({ seenThreadIds: t });
3011
- }
3012
- isThreadNew(e) {
3013
- return typeof e != "string" || !e.trim() ? !1 : !this.getInternalState().seenThreadIds.has(e);
3014
- }
3015
- setPanelView(e) {
3016
- this.destroyed || !yi.has(e) || this.setState({ panelView: e });
3017
- }
3018
- toggleShortcutsOverlay() {
3019
- this.destroyed || this.setState({ isShortcutsOverlayVisible: !this.getInternalState().isShortcutsOverlayVisible });
3020
- }
3021
- addActivity(e) {
3022
- if (this.destroyed) return;
3023
- let t = this.getInternalState(), n = t.currentUser;
3024
- if (!n) return;
3025
- let r = {
3026
- id: `activity-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
3027
- user: {
3028
- id: n.id,
3029
- name: n.name,
3030
- avatarUrl: n.avatar
3031
- },
3032
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
3033
- read: !1,
3034
- ...e
3035
- }, i = [r, ...t.activities].slice(0, 500);
3036
- this.setState({ activities: i }), this.emit("activity:new", r);
3037
- }
3038
- markAllActivitiesRead() {
3039
- if (this.destroyed) return;
3040
- let e = this.getInternalState();
3041
- this.setState({ activities: e.activities.map((e) => ({
3042
- ...e,
3043
- read: !0
3044
- })) });
3045
- }
3046
- getUnreadActivityCount() {
3047
- return this.getInternalState().activities.filter((e) => !e.read).length;
3048
- }
3049
- handleDeepLink() {
3050
- if (this.destroyed) return;
3051
- let e = window.location.hash.match(/^#comment-(.+)$/);
3052
- if (!e?.[1]) return;
3053
- let t = e[1];
3054
- this.emit("deeplink:navigate", { commentId: t });
3055
- let n = this.getInternalState().comments.find((e) => e.id === t);
3056
- n && (this.selectComment(n), this.setState({
3057
- isSidebarVisible: !0,
3058
- panelView: "detail"
3059
- }));
3060
- }
3061
- async createHighlight(e, t) {
3062
- if (!this.destroyed) return vn(this.ctx, this.commentCb, this.activeMutations, e, t);
3063
- }
3064
- async createDrawing(e, t, n) {
3065
- if (!this.destroyed) return yn(this.ctx, this.commentCb, this.activeMutations, e, t, n);
3066
- }
3067
- setActiveDrawing(e) {
3068
- this.destroyed || this.setState({ activeDrawing: e });
3069
- }
3070
- sendDrawingStroke(e) {
3071
- this.destroyed || this.wsManager?.sendDrawingStroke(e);
3072
- }
3073
- async captureScreenshot(e) {
3074
- return this.destroyed ? null : Jn(this.ctx, this.screenshotProvider, e);
3075
- }
3076
- async uploadScreenshot(e, t, n) {
3077
- return this.destroyed ? null : Yn(this.ctx, e, t, n);
3078
- }
3079
- setActiveScreenshot(e) {
3080
- this.destroyed || this.setState({ activeScreenshot: e });
3081
- }
3082
- async uploadFiles(e, t) {
3083
- return this.destroyed ? [] : Xn(this.ctx, e, t);
3084
- }
3085
- getAgentContext(e) {
3086
- return Je(this.getInternalState(), e);
3087
- }
3088
- async getAgentContextAsync(e) {
3089
- return Ye(Je(this.getInternalState(), e));
3090
- }
3091
- formatAgentContext(e) {
3092
- return O(this.getAgentContext(e));
3093
- }
3094
- async formatAgentContextAsync(e) {
3095
- return O(await this.getAgentContextAsync(e));
3096
- }
3097
- async copyAgentContext(e) {
3098
- if (this.destroyed) return "";
3099
- let t = await this.getAgentContextAsync(e), n = O(t);
3100
- return await k(n, t), this.emit("agent:context-copied", {
3101
- commentCount: t.comments.length,
3102
- sourceResolved: t.sourceResolved
3103
- }), n;
3104
- }
3105
- async grabElement(e, t) {
3106
- if (this.destroyed) return null;
3107
- let n = await pr(e, this.ctx, this.screenshotProvider, t);
3108
- return n && this.emit("agent:element-grabbed", {
3109
- source: n.element.source?.filePath ?? null,
3110
- componentName: n.element.componentName ?? null
3111
- }), n;
3112
- }
3113
- async grabElements(e, t) {
3114
- if (this.destroyed) return null;
3115
- let n = await hr(e, this.ctx, this.screenshotProvider, t);
3116
- return n && this.emit("agent:elements-grabbed", { count: n.results.length }), n;
3117
- }
3118
- async getProjectMembers() {
3119
- if (this.destroyed) return [];
3120
- try {
3121
- return await this.apiClient.getProjectMembers();
3122
- } catch (e) {
3123
- return this.handleError(e), [];
3124
- }
3125
- }
3126
- handleToggleRequest() {
3127
- this.destroyed || Er(this.getInternalState(), this.kbdCallbacks);
3128
- }
3129
- handleKeyboardShortcuts(e) {
3130
- this.destroyed || e.key === "Escape" && this.escapeBlockers.size > 0 || Dr(e, this.getInternalState(), this.kbdCallbacks);
3131
- }
3132
- matchesHoldKey(e) {
3133
- let t = this.config.ui?.activation?.key;
3134
- return t ? t === "Alt" ? e.key === "Alt" || e.code === "AltLeft" || e.code === "AltRight" : t === "Meta" ? e.key === "Meta" || e.code === "MetaLeft" || e.code === "MetaRight" : t === "Control" ? e.key === "Control" || e.code === "ControlLeft" || e.code === "ControlRight" : t === "Shift" ? e.key === "Shift" || e.code === "ShiftLeft" || e.code === "ShiftRight" : !1 : !1;
3135
- }
3136
- blockEscape() {
3137
- let e = Symbol();
3138
- return this.escapeBlockers.add(e), () => {
3139
- this.escapeBlockers.delete(e);
3140
- };
3141
- }
3142
- initializeWebSocket() {
3143
- this.destroyed || _i().then((e) => {
3144
- this.destroyed || this.getInternalState().isAuthenticated && (this.syncRealtimeRefs(), e.initializeWebSocket(this.ctx, this.realtimeRefs), this.syncFromRealtimeRefs());
3145
- }).catch((e) => {
3146
- this.ctx.handleError(e);
3147
- });
3148
- }
3149
- getOnlineUsers() {
3150
- /* v8 ignore next -- onlineUsers is always initialized as array */
3151
- return structuredClone(this.getInternalState().onlineUsers || []);
3152
- }
3153
- syncRealtimeRefs() {
3154
- this.realtimeRefs.wsManager = this.wsManager, this.realtimeRefs.wsUnsubscribers = this.wsUnsubscribers, this.realtimeRefs.mouseMoveHandler = this.mouseMoveHandler;
3155
- }
3156
- syncFromRealtimeRefs() {
3157
- this.wsManager = this.realtimeRefs.wsManager, this.wsUnsubscribers = this.realtimeRefs.wsUnsubscribers, this.mouseMoveHandler = this.realtimeRefs.mouseMoveHandler;
3158
- }
3159
- removeMouseMoveListener() {
3160
- Z && (this.syncRealtimeRefs(), Z.removeMouseMoveListener(this.realtimeRefs), this.syncFromRealtimeRefs());
3161
- }
3162
- disconnectRealtime(e) {
3163
- for (let e of this.wsUnsubscribers) try {
3164
- e();
3165
- } catch (e) {
3166
- console.error("[CommentKit] Error during realtime cleanup:", e);
3167
- }
3168
- if (this.wsUnsubscribers = [], this.wsManager) {
3169
- try {
3170
- e && this.wsManager.sendCursorLeave();
3171
- } catch {}
3172
- this.wsManager.destroy(), this.wsManager = null;
3173
- }
3174
- this.removeMouseMoveListener(), this.syncRealtimeRefs();
3175
- }
3176
- destroy() {
3177
- this.destroyed || (this.destroyed = !0, vi && (this.keyboardHandler && window.removeEventListener("keydown", this.keyboardHandler, !0), this.holdActivationHandler && (window.removeEventListener("keydown", this.holdActivationHandler), window.removeEventListener("keyup", this.holdActivationHandler)), this.holdBlurHandler && window.removeEventListener("blur", this.holdBlurHandler), this.toggleHandler && window.removeEventListener("commentkit:toggle-overlay", this.toggleHandler), this.hashChangeHandler && window.removeEventListener("hashchange", this.hashChangeHandler), this.onlineHandler && window.removeEventListener("online", this.onlineHandler), this.offlineHandler && window.removeEventListener("offline", this.offlineHandler)), this.pendingStateUpdates = null, this.flushScheduled = !1, this.activeMutations.clear(), this.offlinePersistUnsub?.(), this.offlinePersistUnsub = null, this.retryTimer &&= (clearTimeout(this.retryTimer), null), this.bootRetryTimer &&= (clearTimeout(this.bootRetryTimer), null), this.disconnectRealtime(!0), this.sliceSubscribers.clear(), this.removeAllListeners());
3178
- }
3179
- }, Ei = typeof window < "u", $ = class {
1
+ import { t as e } from "./shared/websocket-manager-DhLWh3Jr.js";
2
+ import { a as t, c as n, f as r, g as i, h as a, l as o, m as s, n as c, t as l } from "./shared/comment-kit-core-BaSuMzp9.js";
3
+ import { a as u, c as d, d as f, f as p, i as m, l as h, m as g, n as _, o as v, p as y, r as b, s as x, t as S, u as C } from "./shared/dom-Bhf4WFtY.js";
4
+ import "./headless.es.js";
5
+ async function w(e) {
6
+ return (await import("./demo.es.js")).createCommentKitDemo(e);
7
+ }
8
+ var T = typeof window < "u", E = class {
3180
9
  constructor(e) {
3181
10
  /* v8 ignore start -- isBrowser always true in jsdom */
3182
- this.mountedUI = null, this.destroyed = !1, this.core = new Ti(e), e.enabled !== !1 && Ei && this.mount();
11
+ this.mountedUI = null, this.destroyed = !1, this.core = new l(e), e.enabled !== !1 && T && this.mount();
3183
12
  /* v8 ignore stop */
3184
13
  }
3185
14
  async mount() {
3186
15
  let e = this.core;
3187
16
  try {
3188
- let { mountCommentKitUI: t } = await import("./core/mount-ui-Bfnuuesk.js");
17
+ let { mountCommentKitUI: t } = await import("./shared/mount-ui--ijs8pWT.js").then((e) => e.n);
3189
18
  if (this.destroyed) return;
3190
19
  let n = await t(e);
3191
20
  if (this.destroyed) {
@@ -3262,21 +91,30 @@ var Ti = class extends it {
3262
91
  selectComment(e) {
3263
92
  this.core.selectComment(e);
3264
93
  }
3265
- addReply(e, t) {
3266
- return this.core.addReply(e, t);
94
+ addReply(...e) {
95
+ return this.core.addReply(...e);
3267
96
  }
3268
- updateReply(e, t, n) {
3269
- return this.core.updateReply(e, t, n);
97
+ updateReply(...e) {
98
+ return this.core.updateReply(...e);
3270
99
  }
3271
100
  deleteReply(e, t) {
3272
101
  return this.core.deleteReply(e, t);
3273
102
  }
3274
- reactToComment(e, t) {
3275
- return this.core.reactToComment(e, t);
103
+ reactToComment(...e) {
104
+ return this.core.reactToComment(...e);
3276
105
  }
3277
106
  updateCommentPosition(e, t, n) {
3278
107
  return this.core.updateCommentPosition(e, t, n);
3279
108
  }
109
+ setBranch(e) {
110
+ return this.core.setBranch(e);
111
+ }
112
+ reloadProjectContext() {
113
+ return this.core.reloadProjectContext();
114
+ }
115
+ reloadComments() {
116
+ return this.core.reloadComments();
117
+ }
3280
118
  loadMoreComments() {
3281
119
  return this.core.loadMoreComments();
3282
120
  }
@@ -3301,8 +139,8 @@ var Ti = class extends it {
3301
139
  setActiveScreenshot(e) {
3302
140
  this.core.setActiveScreenshot(e);
3303
141
  }
3304
- uploadFiles(e) {
3305
- return this.core.uploadFiles(e);
142
+ uploadFiles(...e) {
143
+ return this.core.uploadFiles(...e);
3306
144
  }
3307
145
  getOnlineUsers() {
3308
146
  return this.core.getOnlineUsers();
@@ -3319,6 +157,9 @@ var Ti = class extends it {
3319
157
  isThreadNew(e) {
3320
158
  return this.core.isThreadNew(e);
3321
159
  }
160
+ blockEscape() {
161
+ return this.core.blockEscape();
162
+ }
3322
163
  setPanelView(e) {
3323
164
  this.core.setPanelView(e);
3324
165
  }
@@ -3368,10 +209,10 @@ var Ti = class extends it {
3368
209
  return this.core;
3369
210
  }
3370
211
  destroy() {
3371
- this.destroyed || (this.destroyed = !0, this.mountedUI?.unmount(), this.mountedUI = null, this.core.destroy(), Ei && window.CommentKitInstance === this && (window.CommentKitInstance = void 0));
212
+ this.destroyed || (this.destroyed = !0, this.mountedUI?.unmount(), this.mountedUI = null, this.core.destroy(), T && window.CommentKitInstance === this && (window.CommentKitInstance = void 0));
3372
213
  }
3373
214
  };
3374
215
  /* v8 ignore start */
3375
- Ei && (window.CommentKit = $, window.CommentKitConfig && !window.CommentKitInstance && (window.CommentKitInstance = new $(window.CommentKitConfig)));
216
+ T && (window.CommentKit = E, window.CommentKitConfig && !window.CommentKitInstance && (window.CommentKitInstance = new E(window.CommentKitConfig)));
3376
217
  /* v8 ignore stop */
3377
- export { Ce as ApiClient, $ as CommentKit, Ti as CommentKitCore, it as EventEmitter, Q as SDK_VERSION, l as WebSocketManager, Je as createAgentContext, ne as debounce, v as findElement, O as formatAgentContext, we as formatMention, b as generateId, h as generateSelector, d as generateXPath, y as getCurrentPage, te as getElementBounds, f as getSelectionRange, g as getSelectionText, re as isElementVisible, p as isInteractiveElement, w as parseMentions, m as percentageToViewport, Te as stripMentionMarkup, ee as throttle, _ as viewportToPercentage };
218
+ export { r as ApiClient, E as CommentKit, l as CommentKitCore, t as EventEmitter, c as SDK_VERSION, e as WebSocketManager, n as createAgentContext, w as createCommentKitDemo, S as debounce, _ as findElement, o as formatAgentContext, s as formatMention, b as generateId, m as generateSelector, u as generateXPath, v as getCurrentPage, x as getElementBounds, d as getSelectionRange, h as getSelectionText, C as isElementVisible, f as isInteractiveElement, a as parseMentions, p as percentageToViewport, i as stripMentionMarkup, y as throttle, g as viewportToPercentage };