@commentkit/comment-kit 0.7.7 → 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +172 -732
  3. package/SECURITY.md +24 -14
  4. package/dist/npm/THIRD_PARTY_NOTICES.txt +73 -0
  5. package/dist/npm/chunks/Guest-CKoV6pEK.js +157 -0
  6. package/dist/npm/chunks/MarkupEditor-DAo4qppg.js +199 -0
  7. package/dist/npm/chunks/Panel-BRBDHlGg.js +399 -0
  8. package/dist/npm/chunks/Shortcuts-CHMcrjAM.js +56 -0
  9. package/dist/npm/chunks/ThreadCard-D8FzIxbs.js +570 -0
  10. package/dist/npm/chunks/anchor-DT-Ynhh1.js +270 -0
  11. package/dist/npm/chunks/ar-D3SPpN1T.js +195 -0
  12. package/dist/npm/chunks/client-D1NizpDK.js +627 -0
  13. package/dist/{shared/capture-colors-D0uLr-vZ.js → npm/chunks/colors-CX-IPjvb.js} +2 -0
  14. package/dist/npm/chunks/de-C8eC6c6f.js +187 -0
  15. package/dist/npm/chunks/es-Bczf42tm.js +187 -0
  16. package/dist/npm/chunks/extension--it1LAj-.js +54 -0
  17. package/dist/npm/chunks/extension-XfuRGu2o.js +26 -0
  18. package/dist/npm/chunks/format-Bw_tNOh9.js +524 -0
  19. package/dist/npm/chunks/fr-BaQw-v2e.js +187 -0
  20. package/dist/npm/chunks/hi-BamV-yXv.js +187 -0
  21. package/dist/npm/chunks/html2canvas-DfGb8yka.js +4024 -0
  22. package/dist/npm/chunks/it-DC14_EjN.js +187 -0
  23. package/dist/npm/chunks/ja-B1mmTN7Y.js +187 -0
  24. package/dist/npm/chunks/mount-5fFig0k6.js +1447 -0
  25. package/dist/npm/chunks/nl-BfhqUsmX.js +187 -0
  26. package/dist/npm/chunks/privacy-DLhezjyi.js +30 -0
  27. package/dist/npm/chunks/pt-BR-CEPu4W5U.js +187 -0
  28. package/dist/{shared/pusher-CnhQgAvF.js → npm/chunks/pusher-BSsQoE1K.js} +224 -222
  29. package/dist/npm/chunks/realtime-CBRW9BB3.js +34 -0
  30. package/dist/npm/chunks/report-Dh4fxd4J.js +27 -0
  31. package/dist/npm/chunks/rolldown-runtime-Y_bBpyJl.js +20 -0
  32. package/dist/npm/chunks/src-DujplxfI.js +517 -0
  33. package/dist/npm/chunks/zh-CN-kgqjYwHQ.js +187 -0
  34. package/dist/npm/element.js +41 -0
  35. package/dist/npm/headless.js +3 -0
  36. package/dist/npm/index.js +3 -0
  37. package/dist/npm/react.js +26 -0
  38. package/dist/npm/svelte.js +17 -0
  39. package/dist/npm/types/adapters/react.d.ts +11 -0
  40. package/dist/npm/types/adapters/svelte.d.ts +9 -0
  41. package/dist/npm/types/adapters/vue.d.ts +118 -0
  42. package/dist/npm/types/anchor/index.d.ts +49 -0
  43. package/dist/npm/types/core/api.d.ts +31 -0
  44. package/dist/npm/types/core/auth.d.ts +87 -0
  45. package/dist/npm/types/core/client.d.ts +114 -0
  46. package/dist/npm/types/core/store.d.ts +7 -0
  47. package/dist/npm/types/core/types.d.ts +303 -0
  48. package/dist/npm/types/element.d.ts +13 -0
  49. package/dist/npm/types/headless.d.ts +7 -0
  50. package/dist/npm/types/index.d.ts +32 -0
  51. package/dist/npm/vue.js +71 -0
  52. package/package.json +71 -173
  53. package/dist/THIRD_PARTY_NOTICES.txt +0 -284
  54. package/dist/angular.es.js +0 -321
  55. package/dist/comment-kit.es.js +0 -218
  56. package/dist/demo.es.js +0 -483
  57. package/dist/headless.es.js +0 -4
  58. package/dist/preact.es.js +0 -117
  59. package/dist/qwik.es.js +0 -1
  60. package/dist/qwik.qwik.mjs +0 -114
  61. package/dist/react.es.js +0 -98
  62. package/dist/shared/ShadowRootContext-DD6a0QaI.js +0 -11
  63. package/dist/shared/annotation-icons-Dh-bmNYK.js +0 -172
  64. package/dist/shared/annotation-toolbar-zeiCmKIr.js +0 -1086
  65. package/dist/shared/attachment-refresh-DAacLaRu.js +0 -94
  66. package/dist/shared/bridge-CJoGYngu.js +0 -177
  67. package/dist/shared/button-D4GHW6oZ.js +0 -474
  68. package/dist/shared/button-group-BVR7iT-S.js +0 -91
  69. package/dist/shared/capture-privacy-CiOrcAlt.js +0 -101
  70. package/dist/shared/comment-drawing-canvas-Btc12IsS.js +0 -124
  71. package/dist/shared/comment-icon-D8JTCEJ7.js +0 -607
  72. package/dist/shared/comment-image-lightbox--QpbcAtH.js +0 -190
  73. package/dist/shared/comment-images-content-C_r4SHM-.js +0 -214
  74. package/dist/shared/comment-kit-core-CmLUFujd.js +0 -3682
  75. package/dist/shared/comment-kit-ui-BHwYuSIi.js +0 -19391
  76. package/dist/shared/comment-screenshot-annotator-zJZyO-XM.js +0 -151
  77. package/dist/shared/comment-screenshot-overlay-CoKTYB0J.js +0 -205
  78. package/dist/shared/comment-shortcut-groups-CfEmkitU.js +0 -153
  79. package/dist/shared/createReactComponent-BZHeRbD0.js +0 -45
  80. package/dist/shared/dev-export-panel-Cnt6oCZU.js +0 -207
  81. package/dist/shared/dev-grab-B85jo9AS.js +0 -197
  82. package/dist/shared/dist-D9A5k-N4.js +0 -617
  83. package/dist/shared/dom-Bhf4WFtY.js +0 -223
  84. package/dist/shared/element-selector-Cng84xC7.js +0 -902
  85. package/dist/shared/error-boundary-D3PD74vI.js +0 -21
  86. package/dist/shared/errors-Bu5ajEmB.js +0 -22
  87. package/dist/shared/icons-nzMOLzrm.js +0 -266
  88. package/dist/shared/input-UPtAj0M6.js +0 -111
  89. package/dist/shared/mount-ui-Dz7FB_Ak.js +0 -208
  90. package/dist/shared/realtime-recovery-BjlV-ewc.js +0 -162
  91. package/dist/shared/realtime-yGLX4wMK.js +0 -334
  92. package/dist/shared/request-activity-DQrAUwfA.js +0 -11
  93. package/dist/shared/screenshot-B5-hwpmt.js +0 -199
  94. package/dist/shared/separator-UhJb0Row.js +0 -3955
  95. package/dist/shared/shadow-root-B58ZI2yz.js +0 -133
  96. package/dist/shared/styles-CnYsLS2f.js +0 -2
  97. package/dist/shared/text-B4HHZNaa.js +0 -23
  98. package/dist/shared/token-session-D92MYbNu.js +0 -25
  99. package/dist/shared/useLabelableId-8n0QmH8N.js +0 -154
  100. package/dist/shared/useRender-Uxk1OPK-.js +0 -5
  101. package/dist/shared/useValueChanged-DKq5cMot.js +0 -92
  102. package/dist/shared/validation-3wbbbuX0.js +0 -70
  103. package/dist/shared/websocket-manager-KhH4hL0Q.js +0 -381
  104. package/dist/solid.es.js +0 -98
  105. package/dist/svelte.es.js +0 -130
  106. package/dist/types/adapters/bridge.d.ts +0 -122
  107. package/dist/types/angular/index.d.ts +0 -145
  108. package/dist/types/core/agent-context.d.ts +0 -17
  109. package/dist/types/core/api-client.d.ts +0 -155
  110. package/dist/types/core/comment-kit-core.d.ts +0 -254
  111. package/dist/types/core/local-demo.d.ts +0 -60
  112. package/dist/types/core/types.d.ts +0 -770
  113. package/dist/types/core/websocket-manager.d.ts +0 -125
  114. package/dist/types/core/write-access.d.ts +0 -11
  115. package/dist/types/demo.d.ts +0 -17
  116. package/dist/types/headless.d.ts +0 -8
  117. package/dist/types/index.d.ts +0 -87
  118. package/dist/types/preact/index.d.ts +0 -25
  119. package/dist/types/qwik/index.d.ts +0 -73
  120. package/dist/types/react/client.d.ts +0 -31
  121. package/dist/types/react/index.d.ts +0 -4
  122. package/dist/types/solid/index.d.ts +0 -37
  123. package/dist/types/svelte/index.d.ts +0 -55
  124. package/dist/types/utils/dom.d.ts +0 -59
  125. package/dist/types/utils/event-emitter.d.ts +0 -11
  126. package/dist/types/vue/index.d.ts +0 -87
  127. package/dist/vue.es.js +0 -148
  128. package/docs/api-reference.md +0 -405
  129. package/docs/local-demo.md +0 -60
package/SECURITY.md CHANGED
@@ -32,25 +32,35 @@ We will credit reporters in release notes unless you prefer to remain anonymous.
32
32
 
33
33
  This policy covers:
34
34
 
35
- - **The CommentKit SDK** (`@commentkit/comment-kit` npm package) — all framework entry points (core, React, Vue, Svelte, Angular, Solid, Qwik, Preact)
36
- - **The MCP server** (`comment-kit-mcp` sibling package in `mcp/`)
35
+ - **The CommentKit SDK** (`@commentkit/comment-kit`): the script-tag loader, `init()`, the `<comment-kit>` element, and the React, Vue and Svelte helpers.
36
+ - **The MCP server** (`comment-kit-mcp`, in `mcp/`).
37
37
 
38
- Vulnerabilities in the hosted CommentKit backend (`api.commentkit.dev`, the dashboard) are also welcome at the same address, but are handled by the platform team.
38
+ Vulnerabilities in the hosted service (`commentkit.dev`, the dashboard and API) are welcome at the same address.
39
39
 
40
- ## Hardening Guidance for Hosts
40
+ ## How CommentKit protects you
41
41
 
42
- CommentKit executes with the embedding page's JavaScript privileges. Shadow DOM isolates styles, not JavaScript or data. No in-page SDK, dependency audit, or test suite can guarantee that a customer website cannot be compromised. A compromised SDK release or another script already running on the page could access page data and JavaScript-readable storage. Installing the widget does not give CommentKit access to a host's server filesystem, but the host must still authorize every server request independently.
42
+ - **The project key identifies, it does not authorise.** `pk_…` keys are public. The API only accepts browser calls from the website addresses you list in Project → Setup (exact scheme, host and port; `*.` wildcards for preview links), and every action is checked against the signed-in person's role.
43
+ - **Sessions are bound to one website.** Sign-in happens on the CommentKit domain (popup or same-tab redirect) with PKCE. Access tokens last 15 minutes and only work from the website they were issued to; refresh tokens rotate on every use, and replaying an old one ends the whole session. The refresh token is stored in `localStorage` for that website, so scripts already running on your page could read it; it is useless from any other origin.
44
+ - **Agent tokens are server-side only.** They are scoped to one project, read-only unless a person grants reply or ready-for-review, refused when sent from a browser, and stop working when that person loses access.
45
+ - **Screenshots leave out private data.** Password, payment and one-time-code fields, hidden inputs, iframes, the widget itself and anything matching `data-commentkit-redact` or your dashboard privacy selectors are omitted before the image is created. Uploaded images are re-encoded on the server, which strips EXIF/GPS metadata.
46
+ - **Feedback is untrusted.** It is rendered as text with safe links only, and agent output wraps it in `<untrusted-user-content>` fences.
43
47
 
44
- Use these controls before enabling a production integration:
48
+ ## Hardening guidance for hosts
45
49
 
46
- 1. **Review and pin the release.** Install an exact reviewed version, commit the lockfile, build it with your application, and deploy through your normal review process. Avoid a mutable CDN `latest` URL. Audit the resolved dependency graph and the optional peers you install. SRI applies to supported external script tags; it is not a replacement for checking your application bundle and lockfile.
47
- 2. **Separate public project identity from user authentication.** The browser project API key is visible to visitors. Never embed an admin token, server secret, npm token, or a pre-authenticated user's SDK token in application code. Configure exact allowed origins, verify membership and permissions on the backend, and keep legacy email-only authentication disabled. A hidden launcher, an `enabled` flag, or an origin allowlist alone is not authorization.
48
- 3. **Constrain the network.** Use HTTPS and a canonical API URL with no redirects, embedded credentials, query, or fragment. HTTP is supported only for local loopback development. SDK API fetches omit ambient cookies and the referrer, reject redirects, and use explicit SDK authentication headers. Allow only the required API and realtime hosts in CSP `connect-src`; limit image and font origins to the sources your integration needs. Leave `ui.loadRemoteFonts` off unless explicitly approved.
49
- 4. **Keep script policy strict.** CommentKit does not require `unsafe-eval` or executable user HTML. Test your actual CSP in staging before deployment. The widget uses inline style elements and dynamic style attributes; compatibility with a nonce-only style policy is not established. Do not weaken `script-src` to fix a styling failure. CSP reduces attack paths; it does not make a compromised trusted script harmless.
50
- 5. **Exclude private surfaces.** Avoid mounting on payment, password-reset, medical, financial, or other sensitive workflows unless their data handling has been reviewed. Mark private regions with `data-commentkit-redact`. Built-in capture excludes marked regions and password, hidden, payment-autocomplete, and one-time-code fields. DOM context export also omits form values, scripts/templates/embedded documents, arbitrary data attributes, event handlers, and URL attributes. It retains useful element identifiers and page metadata; it is not a general-purpose secret detector. Page URLs, titles, selections, submitted text, and attachments can still contain personal or confidential information.
51
- 6. **Review custom capture and exports.** A custom `screenshotProvider` receives the host element and is responsible for masking sensitive descendants in its image; the SDK cannot inspect its pixels for secrets. Agent exports are an explicit local clipboard action and may include feedback, authors, page context, and optional source locations. Review the preview before sharing it with an agent or external service. Treat feedback as untrusted data, not agent instructions.
52
- 7. **Limit access and preserve recovery.** Invite only authorized reviewers, use the least permissions they need, review team access, and test logout and revoked access. The session token is tab-scoped but readable by same-origin scripts. The offline retry queue can retain feedback in local storage until replay or logout. Confirm backup, retention, incident response, and rollback procedures with your CommentKit operator.
50
+ CommentKit runs with your page's JavaScript privileges. Shadow DOM isolates styles, not scripts or data. A compromised release or another script on your page could read what the widget can read.
51
+
52
+ 1. **Pin and review releases.** Install an exact version, commit your lockfile, and deploy through your normal review. For the script tag, prefer a versioned URL and Subresource Integrity once you pin a version.
53
+ 2. **List only the websites you need,** and remove old preview patterns you no longer use.
54
+ 3. **Content Security Policy.** CommentKit does not need `unsafe-eval` or `unsafe-inline` and does not execute user HTML. The exact hosts for your server are on [commentkit.dev/docs/csp](https://commentkit.dev/docs/csp). Allow:
55
+ - `script-src`: `https://commentkit.dev` (script tag only; with the npm package the code is in your bundle).
56
+ - `connect-src`: `https://commentkit.dev` (the API), the file storage host (screenshots and attachments upload straight to it), and the realtime host (`wss://…`) if live updates are on. List the realtime host itself: older browsers don't match `wss:` from an `https:` source.
57
+ - `img-src`: `https://commentkit.dev`, the file storage host and `blob:` (the screenshot preview before it is uploaded). Add `https://lh3.googleusercontent.com` to show Google profile pictures; without it, initials are shown.
58
+ - Styles come through constructable stylesheets in the widget's Shadow DOM, so a strict `style-src` keeps working.
59
+ - **Trusted Types** (`require-trusted-types-for 'script'`): the widget writes no HTML strings. The screenshot engine's two fixed HTML writes go through one narrow policy, `commentkit-capture`, which accepts only those strings. If your page lists allowed policies with `trusted-types`, add `commentkit-capture`.
60
+ 4. **Exclude sensitive pages.** Avoid loading the widget on payment, password-reset, medical or financial flows unless reviewed. Mark private regions with `data-commentkit-redact`. Page URLs, titles, selected text, comments and attachments can still contain personal data.
61
+ 5. **Keep console and network capture off** unless your team needs it. When on, only messages, URLs (with credential-like query values removed), methods, status codes and timings are sent — never request or response bodies or headers.
62
+ 6. **Review agent handoffs.** Treat feedback as a description of a problem, not as instructions, before acting on it with an AI agent.
53
63
 
54
64
  ## Verification boundaries
55
65
 
56
- Automated tests exercise escaping, unsafe links and SVG paint, API transport settings, private DOM capture, authentication, and lifecycle cleanup. A passing dependency audit means no known advisory was reported for that dependency graph at that time. Neither result is a penetration-test certificate or a guarantee against future vulnerabilities. Revalidate the packed artifact, host integration, backend authorization, and CSP for every release; keep independent security review and incident response in the release process.
66
+ Automated tests cover origin and session binding, refresh-token rotation, scope enforcement, screenshot redaction in real browsers, safe rendering, upload content checks, and package contents. A passing dependency audit only means no known advisory was reported at that time. Neither is a penetration-test certificate. Revalidate the packed artifact, your integration and your CSP for every release.
@@ -0,0 +1,73 @@
1
+ CommentKit bundles the following open-source software.
2
+
3
+ preact@11.0.1 (MIT)
4
+ The MIT License (MIT)
5
+
6
+ Copyright (c) 2015-present Jason Miller
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
25
+
26
+ ---
27
+
28
+ html2canvas@1.4.1 (MIT)
29
+ Copyright (c) 2012 Niklas von Hertzen
30
+
31
+ Permission is hereby granted, free of charge, to any person
32
+ obtaining a copy of this software and associated documentation
33
+ files (the "Software"), to deal in the Software without
34
+ restriction, including without limitation the rights to use,
35
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
36
+ copies of the Software, and to permit persons to whom the
37
+ Software is furnished to do so, subject to the following
38
+ conditions:
39
+
40
+ The above copyright notice and this permission notice shall be
41
+ included in all copies or substantial portions of the Software.
42
+
43
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
44
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
45
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
46
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
47
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
48
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
49
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
50
+ OTHER DEALINGS IN THE SOFTWARE.
51
+
52
+ ---
53
+
54
+ pusher-js@8.6.0 (MIT)
55
+ Copyright (c) 2020 Pusher, Ltd (https://pusher.com)
56
+
57
+ Permission is hereby granted, free of charge, to any person obtaining a copy
58
+ of this software and associated documentation files (the "Software"), to deal
59
+ in the Software without restriction, including without limitation the rights
60
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
61
+ copies of the Software, and to permit persons to whom the Software is
62
+ furnished to do so, subject to the following conditions:
63
+
64
+ The above copyright notice and this permission notice shall be included in
65
+ all copies or substantial portions of the Software.
66
+
67
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
68
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
69
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
70
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
71
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
72
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
73
+ THE SOFTWARE.
@@ -0,0 +1,157 @@
1
+ import { a as e } from "./src-DujplxfI.js";
2
+ import { c as t } from "./client-D1NizpDK.js";
3
+ import { d as n, f as r, h as i, n as a, p as o } from "./format-Bw_tNOh9.js";
4
+ import { a as s } from "./mount-5fFig0k6.js";
5
+ //#region src/ui/Guest.tsx
6
+ async function c(n, r) {
7
+ try {
8
+ let e = await n.api.request("/guest/start", {
9
+ method: "POST",
10
+ anonymous: !0,
11
+ body: {
12
+ client_id: n.options.project,
13
+ share: r.share,
14
+ name: r.name.trim(),
15
+ email: r.email.trim()
16
+ }
17
+ }), t = Date.parse(e.pending_session.expires_at);
18
+ return n.auth.setPending({
19
+ token: e.access_token,
20
+ email: e.pending_session.email,
21
+ expiresAt: Number.isFinite(t) ? t : Date.now() + e.expires_in * 1e3
22
+ }), "started";
23
+ } catch (n) {
24
+ if (n instanceof t && n.code === "origin_not_allowed") return "popup";
25
+ throw n instanceof t && n.errors?.share ? new t(422, "share_expired", e("shareExpired")) : n;
26
+ }
27
+ }
28
+ function l({ client: c, email: l, onDone: d, onDifferentEmail: f, onClose: p }) {
29
+ let [m, h] = i(""), [g, _] = i(!1), [v, y] = i(null), [b, x] = i(null), S = o(null);
30
+ r(() => S.current?.focus({ preventScroll: !0 }), []);
31
+ let C = async () => {
32
+ if (/^\d{6}$/.test(m) && !g) {
33
+ _(!0), y(null);
34
+ try {
35
+ let e = await c.api.request("/guest/verify", {
36
+ method: "POST",
37
+ body: { code: m }
38
+ });
39
+ c.auth.adopt(e), await c.loadSession().catch(() => null), d(e.published_thread_ids ?? []);
40
+ } catch (n) {
41
+ if ((n instanceof t ? n.status : 0) === 422) return y({
42
+ text: e("verifyWrong"),
43
+ tone: "warning"
44
+ });
45
+ let r = u(n);
46
+ r && (c.auth.setPending(null), x(r === "expired" ? "again" : "stop")), y({
47
+ text: r ? e(r === "link" ? "verifyLinkExpired" : r === "removed" ? "verifyRemoved" : "verifyExpired") : n instanceof t ? n.message : e("errorGeneric"),
48
+ tone: "warning"
49
+ });
50
+ } finally {
51
+ _(!1);
52
+ }
53
+ }
54
+ }, w = async () => {
55
+ try {
56
+ await c.api.request("/guest/resend", { method: "POST" }), y({ text: e("verifyResent") });
57
+ } catch (n) {
58
+ y({
59
+ text: n instanceof t && n.status === 429 ? e("verifyWait") : e("errorGeneric"),
60
+ tone: "warning"
61
+ });
62
+ }
63
+ };
64
+ return /* @__PURE__ */ n("div", {
65
+ class: "ck-card",
66
+ style: s({
67
+ x: innerWidth / 2 - 190,
68
+ y: 80
69
+ }),
70
+ role: "dialog",
71
+ "aria-labelledby": "ck-verify-title",
72
+ "data-commentkit-ui": !0,
73
+ onKeyDown: (e) => e.key === "Escape" && p(),
74
+ children: [
75
+ /* @__PURE__ */ n("div", {
76
+ class: "ck-card-head",
77
+ children: [/* @__PURE__ */ n("h2", {
78
+ class: "ck-card-title",
79
+ id: "ck-verify-title",
80
+ children: e("verifyTitle")
81
+ }), /* @__PURE__ */ n("button", {
82
+ class: "ck-ghost",
83
+ "aria-label": e("close"),
84
+ onClick: p,
85
+ children: /* @__PURE__ */ n(a, { name: "close" })
86
+ })]
87
+ }),
88
+ /* @__PURE__ */ n("div", {
89
+ class: "ck-card-body",
90
+ children: [
91
+ /* @__PURE__ */ n("p", {
92
+ class: "ck-verify-text",
93
+ children: e("verifyBody", { email: l })
94
+ }),
95
+ /* @__PURE__ */ n("label", {
96
+ class: "ck-field",
97
+ children: [/* @__PURE__ */ n("span", { children: e("verifyCode") }), /* @__PURE__ */ n("input", {
98
+ ref: S,
99
+ class: "ck-input ck-code",
100
+ inputMode: "numeric",
101
+ autoComplete: "one-time-code",
102
+ pattern: "[0-9]*",
103
+ maxLength: 6,
104
+ value: m,
105
+ onInput: (e) => h(e.target.value.replace(/\D/g, "").slice(0, 6)),
106
+ onKeyDown: (e) => {
107
+ e.stopPropagation(), e.key === "Enter" && C(), e.key === "Escape" && p();
108
+ }
109
+ })]
110
+ }),
111
+ v ? /* @__PURE__ */ n("div", {
112
+ class: "ck-note",
113
+ role: v.tone ? "alert" : "status",
114
+ "data-tone": v.tone,
115
+ children: v.text
116
+ }) : null,
117
+ b ? null : /* @__PURE__ */ n("div", {
118
+ class: "ck-actions",
119
+ children: [/* @__PURE__ */ n("button", {
120
+ class: "ck-chip",
121
+ onClick: () => void w(),
122
+ children: e("verifyResend")
123
+ }), /* @__PURE__ */ n("button", {
124
+ class: "ck-chip",
125
+ onClick: () => {
126
+ c.auth.setPending(null), f();
127
+ },
128
+ children: e("verifyDifferent")
129
+ })]
130
+ })
131
+ ]
132
+ }),
133
+ /* @__PURE__ */ n("div", {
134
+ class: "ck-card-foot",
135
+ children: [/* @__PURE__ */ n("span", { class: "ck-spacer" }), b === "again" ? /* @__PURE__ */ n("button", {
136
+ class: "ck-btn ck-primary",
137
+ onClick: f,
138
+ children: e("writeAgain")
139
+ }) : b === "stop" ? /* @__PURE__ */ n("button", {
140
+ class: "ck-btn",
141
+ onClick: p,
142
+ children: e("close")
143
+ }) : /* @__PURE__ */ n("button", {
144
+ class: "ck-btn ck-primary",
145
+ disabled: g || m.length !== 6,
146
+ onClick: () => void C(),
147
+ children: e(g ? "sending" : "verifyPublish")
148
+ })]
149
+ })
150
+ ]
151
+ });
152
+ }
153
+ function u(e) {
154
+ return e instanceof t ? e.code === "share_expired" || e.status === 410 ? "link" : e.code === "guest_removed" ? "removed" : e.status === 403 ? /\blink\b/i.test(e.message) ? "link" : "removed" : e.status === 409 || e.status === 401 ? "expired" : null : null;
155
+ }
156
+ //#endregion
157
+ export { l as GuestVerify, c as startGuest };
@@ -0,0 +1,199 @@
1
+ import { a as e } from "./src-DujplxfI.js";
2
+ import { a as t, d as n, f as r, h as i, p as a } from "./format-Bw_tNOh9.js";
3
+ //#region src/ui/MarkupEditor.tsx
4
+ var o = [
5
+ "#ff3b30",
6
+ "#ff9500",
7
+ "#34c759",
8
+ "#007aff",
9
+ "#121316"
10
+ ], s = [
11
+ "color_red",
12
+ "color_orange",
13
+ "color_green",
14
+ "color_blue",
15
+ "color_black"
16
+ ];
17
+ function c({ image: c, onDone: u, onCancel: d }) {
18
+ let f = a(null), [p, m] = i(null), [h, g] = i("arrow"), [_, v] = i(o[0]), [y, b] = i([]), x = a(null), [S, C] = i(null), w = a(null), T = a(null);
19
+ r(() => (w.current ?? T.current)?.focus({ preventScroll: !0 }), [!!S]);
20
+ let E = () => {
21
+ let e = S?.text.trim().slice(0, 500);
22
+ S && e && b([...y, {
23
+ tool: "text",
24
+ color: _,
25
+ points: [S.x, S.y],
26
+ text: e
27
+ }]), T.current?.focus({ preventScroll: !0 }), C(null);
28
+ };
29
+ r(() => {
30
+ createImageBitmap(c).then(m);
31
+ }, [c]), r(() => D(), [p, y]);
32
+ let D = (e) => {
33
+ let t = f.current;
34
+ if (!t || !p) return;
35
+ t.width = p.width, t.height = p.height;
36
+ let n = t.getContext("2d");
37
+ n.drawImage(p, 0, 0);
38
+ for (let t of e ? [...y, e] : y) l(n, t, p);
39
+ }, O = (e) => {
40
+ let t = f.current, n = t.getBoundingClientRect();
41
+ return [Math.round((e.clientX - n.left) / n.width * t.width), Math.round((e.clientY - n.top) / n.height * t.height)];
42
+ };
43
+ return /* @__PURE__ */ n("div", {
44
+ class: "ck-markup",
45
+ ref: T,
46
+ tabIndex: -1,
47
+ role: "dialog",
48
+ "aria-label": e("markup"),
49
+ "data-commentkit-ui": !0,
50
+ onKeyDown: (e) => {
51
+ e.key === "Escape" && (e.stopPropagation(), S ? (T.current?.focus({ preventScroll: !0 }), C(null)) : d());
52
+ },
53
+ children: [
54
+ /* @__PURE__ */ n("div", {
55
+ class: "ck-markup-tools",
56
+ children: [
57
+ [
58
+ "arrow",
59
+ "rect",
60
+ "pen",
61
+ "blur",
62
+ "text"
63
+ ].map((t) => /* @__PURE__ */ n("button", {
64
+ class: "ck-chip",
65
+ "aria-pressed": h === t,
66
+ onClick: () => g(t),
67
+ children: e(`tool_${t}`)
68
+ })),
69
+ o.map((t, r) => /* @__PURE__ */ n("button", {
70
+ class: "ck-chip",
71
+ "aria-pressed": _ === t,
72
+ "aria-label": e(s[r]),
73
+ style: {
74
+ width: "28px",
75
+ padding: 0,
76
+ background: t
77
+ },
78
+ onClick: () => v(t)
79
+ })),
80
+ /* @__PURE__ */ n("button", {
81
+ class: "ck-chip",
82
+ disabled: !y.length,
83
+ onClick: () => b(y.slice(0, -1)),
84
+ children: e("undo")
85
+ }),
86
+ /* @__PURE__ */ n("button", {
87
+ class: "ck-chip",
88
+ onClick: d,
89
+ children: e("cancel")
90
+ }),
91
+ /* @__PURE__ */ n("button", {
92
+ class: "ck-chip ck-primary",
93
+ onClick: () => {
94
+ let e = S?.text.trim().slice(0, 500), t = S && e ? {
95
+ tool: "text",
96
+ color: _,
97
+ points: [S.x, S.y],
98
+ text: e
99
+ } : null;
100
+ t && D(t), f.current?.toBlob((e) => e && u(e, t ? [...y, t] : y), "image/webp", .88);
101
+ },
102
+ children: e("markupDone")
103
+ })
104
+ ]
105
+ }),
106
+ /* @__PURE__ */ n("canvas", {
107
+ ref: f,
108
+ onPointerDown: (e) => {
109
+ let [t, n] = O(e);
110
+ h === "text" ? (e.preventDefault(), E(), C({
111
+ x: t,
112
+ y: n,
113
+ left: Math.min(e.clientX, innerWidth - 240),
114
+ top: Math.max(8, e.clientY - 18),
115
+ text: ""
116
+ })) : (x.current = {
117
+ tool: h,
118
+ color: _,
119
+ points: [
120
+ t,
121
+ n,
122
+ t,
123
+ n
124
+ ]
125
+ }, f.current?.setPointerCapture(e.pointerId));
126
+ },
127
+ onPointerMove: (e) => {
128
+ let t = x.current;
129
+ if (!t?.points) return;
130
+ let [n, r] = O(e);
131
+ t.tool === "pen" ? t.points.length < 4e3 && t.points.push(n, r) : (t.points[2] = n, t.points[3] = r), D(t);
132
+ },
133
+ onPointerUp: () => {
134
+ x.current && b([...y, x.current]), x.current = null;
135
+ }
136
+ }),
137
+ S ? /* @__PURE__ */ n("div", {
138
+ class: "ck-label-box",
139
+ style: t(S.left, S.top),
140
+ children: [/* @__PURE__ */ n("input", {
141
+ ref: w,
142
+ class: "ck-input",
143
+ maxLength: 500,
144
+ value: S.text,
145
+ placeholder: e("markupTextPrompt"),
146
+ "aria-label": e("markupTextPrompt"),
147
+ style: { color: _ },
148
+ onInput: (e) => C({
149
+ ...S,
150
+ text: e.target.value
151
+ }),
152
+ onKeyDown: (e) => {
153
+ e.key === "Enter" && (e.preventDefault(), E());
154
+ }
155
+ }), /* @__PURE__ */ n("button", {
156
+ class: "ck-chip ck-primary",
157
+ onMouseDown: (e) => e.preventDefault(),
158
+ onClick: E,
159
+ children: e("markupTextAdd")
160
+ })]
161
+ }) : null
162
+ ]
163
+ });
164
+ }
165
+ function l(e, t, n) {
166
+ let r = t.points ?? [], i = Math.max(3, Math.round(n.width / 300));
167
+ e.save(), e.strokeStyle = e.fillStyle = t.color ?? "#ff3b30", e.lineWidth = i, e.lineCap = e.lineJoin = "round";
168
+ let [a = 0, o = 0, s = 0, c = 0] = r;
169
+ switch (t.tool) {
170
+ case "rect":
171
+ e.strokeRect(Math.min(a, s), Math.min(o, c), Math.abs(s - a), Math.abs(c - o));
172
+ break;
173
+ case "arrow": {
174
+ let t = Math.atan2(c - o, s - a), n = i * 5;
175
+ e.beginPath(), e.moveTo(a, o), e.lineTo(s, c), e.stroke(), e.beginPath(), e.moveTo(s, c), e.lineTo(s - n * Math.cos(t - .45), c - n * Math.sin(t - .45)), e.lineTo(s - n * Math.cos(t + .45), c - n * Math.sin(t + .45)), e.closePath(), e.fill();
176
+ break;
177
+ }
178
+ case "pen":
179
+ e.beginPath();
180
+ for (let t = 0; t < r.length; t += 2) (t ? e.lineTo : e.moveTo).call(e, r[t], r[t + 1]);
181
+ e.stroke();
182
+ break;
183
+ case "blur": {
184
+ let t = Math.min(a, s), n = Math.min(o, c), r = Math.abs(s - a), i = Math.abs(c - o);
185
+ if (r > 2 && i > 2) {
186
+ let a = Math.max(8, Math.round(Math.min(r, i) / 6)), o = e.getImageData(t, n, r, i);
187
+ for (let s = 0; s < i; s += a) for (let i = 0; i < r; i += a) {
188
+ let c = (s * r + i) * 4;
189
+ e.fillStyle = `rgb(${o.data[c]},${o.data[c + 1]},${o.data[c + 2]})`, e.fillRect(t + i, n + s, a, a);
190
+ }
191
+ }
192
+ break;
193
+ }
194
+ case "text": e.font = `bold ${i * 6}px system-ui, sans-serif`, e.lineWidth = i * 1.5, e.strokeStyle = "#ffffff", e.strokeText(t.text ?? "", a, o), e.fillText(t.text ?? "", a, o);
195
+ }
196
+ e.restore();
197
+ }
198
+ //#endregion
199
+ export { c as MarkupEditor };