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