@journeeze/sdk 0.1.0 → 0.3.0-rc.1

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 (59) hide show
  1. package/AGENTS.md +2 -2
  2. package/CHANGELOG.md +25 -1
  3. package/LICENSE +202 -0
  4. package/NOTICE +7 -0
  5. package/README.md +22 -20
  6. package/dist/anchor-bnZCZtbG.js +1 -0
  7. package/dist/attach-EfetX0Vi.js +21 -0
  8. package/dist/chat-Coze4aH0.js +64 -0
  9. package/dist/claims-VKhPNjA7.js +1 -0
  10. package/dist/consent-bPengyOI.js +1 -0
  11. package/dist/contract.js +1 -1
  12. package/dist/feedback-DeMvbZnh.js +1 -0
  13. package/dist/help-phTc32Gg.js +105 -0
  14. package/dist/highlight-pU9nE3Qj.js +2 -0
  15. package/dist/{hook-DGWypoEO.js → hook-M34sajh9.js} +1 -1
  16. package/dist/index.js +6 -8
  17. package/dist/loader-DHgG5Y7t.js +127 -0
  18. package/dist/mask-audit-KFvSiJU0.js +5 -0
  19. package/dist/react.js +1 -1
  20. package/dist/resolve-CRDmtd4b.js +1 -0
  21. package/dist/script.js +1 -1
  22. package/dist/{signals-amjMQyOy.js → signals-C_WxFykA.js} +1 -1
  23. package/dist/telemetry-CdwMjZZZ.js +1 -0
  24. package/dist/{transport-B64CfIcF.js → transport-Wrkorx6z.js} +1 -1
  25. package/dist/types/chat/capture/attach.d.ts +2 -0
  26. package/dist/types/chat/shell/chat.d.ts +4 -2
  27. package/dist/types/chat/shell/converse.d.ts +2 -0
  28. package/dist/types/chat/shell/guide.d.ts +12 -0
  29. package/dist/types/chat/shell/session.d.ts +6 -0
  30. package/dist/types/chat/shell/walk.d.ts +49 -0
  31. package/dist/types/chat/transport.d.ts +1 -1
  32. package/dist/types/claims.d.ts +37 -0
  33. package/dist/types/help/core/client.d.ts +3 -0
  34. package/dist/types/help/core/events.d.ts +1 -1
  35. package/dist/types/help/core/routing.d.ts +2 -0
  36. package/dist/types/loader.d.ts +3 -0
  37. package/dist/types/preview/mask-audit.d.ts +3 -1
  38. package/dist/types/telemetry/telemetry.d.ts +4 -0
  39. package/dist/types/types.d.ts +34 -0
  40. package/dist/types/widget/feedback.d.ts +7 -1
  41. package/dist/types/widget/upload.d.ts +3 -2
  42. package/dist/{upload-Fu2qvSJV.js → upload-KvsGqMEV.js} +6 -6
  43. package/dist/walk-BEGYyGG3.js +1 -0
  44. package/dist/widget-BA2WH0yi.js +118 -0
  45. package/package.json +4 -3
  46. package/LICENSE.md +0 -27
  47. package/dist/anchor-cPvFFTOS.js +0 -1
  48. package/dist/attach-DpioALxW.js +0 -21
  49. package/dist/chat-BgmB0rnW.js +0 -64
  50. package/dist/consent-DckCUvYR.js +0 -1
  51. package/dist/context-UnG6_X61.js +0 -17
  52. package/dist/feedback-CtH1a_kQ.js +0 -1
  53. package/dist/help-w0O5Qu-4.js +0 -105
  54. package/dist/index-CwG2LrhO.js +0 -20
  55. package/dist/loader-BZiIDD1D.js +0 -96
  56. package/dist/mask-audit-Du3NPoG_.js +0 -5
  57. package/dist/resolve-BfWByuTp.js +0 -1
  58. package/dist/telemetry-CyRJDaVs.js +0 -1
  59. package/dist/widget-B6mR1J3P.js +0 -118
package/AGENTS.md CHANGED
@@ -12,7 +12,7 @@ The public types in this package (`dist/types`) follow them.
12
12
  - `siteKey` (`pk_` + 32 hex, `SITE_KEY_PATTERN`) is **public** runtime config per site. It is not a secret.
13
13
  - Direct mode is the default: the browser calls `https://app.journeeze.dev` with CORS for the
14
14
  site's allowlisted origins. Set `apiHost` (script tag: `data-journeeze-api-host`) in every
15
- environment except production: `https://app.staging.journeeze.dev` for a staging site key,
15
+ environment except production: `https://staging.journeeze.dev` for a staging site key,
16
16
  `http://localhost:8080` for the local stack, or the host's own origin when it runs a same-origin
17
17
  proxy (then `apiPath` for a sub-path). Keep it in the same runtime config as the site key. The
18
18
  SDK never infers it from where the script was loaded. `http:` is accepted only for
@@ -20,7 +20,7 @@ The public types in this package (`dist/types`) follow them.
20
20
  - CSP, if the host sends one: `script-src 'self' https://app.journeeze.dev` (+ `'wasm-unsafe-eval'`
21
21
  only with signals), `connect-src 'self' https://app.journeeze.dev`, `img-src 'self' blob:
22
22
  https://app.journeeze.dev`, `media-src 'self' https://app.journeeze.dev`, and pass your `nonce`.
23
- Use `app.staging.journeeze.dev` for staging.
23
+ Use `staging.journeeze.dev` for staging.
24
24
 
25
25
  ## Identity
26
26
  - `userId` is optional. It must be `HMAC-SHA256(per-environment secret, internal user id)` computed
package/CHANGELOG.md CHANGED
@@ -1,6 +1,30 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.0-rc.3 (not yet published)
3
+ ## 0.3.0 (unreleased)
4
+
5
+ Additive: integrations without `chat: true` see no change.
6
+
7
+ - **In-page walkthrough in the help chat:** when the chat (`chat: true`) is on a guide step, it outlines the step's element on the host page with the v1 help panel's highlighter. It uses the same targets (tflo id, test id, role and name, CSS) and the same lazy fallback resolver. The outline follows Next and Back, the host's route changes (`setContext`) and scrolling. Leaving the guide, closing the chat or `reset()` removes it.
8
+ - The guide's targets come from `GetGuide`, which needs no consent and sends only the site key, reviewer token and claims.
9
+ - If the loaded guide's step count differs from the server's step card, nothing is outlined, so the outline never points at the wrong element.
10
+ - The walkthrough is its own lazy chunk (`walk`, ≤ 3 KB gz), loaded the first time a guide starts.
11
+ - If the chunk or the guide can't load, the step cards still guide.
12
+ - **Per-persona guides in the chat:** a job chip's step count now uses the guide the server plays for the viewer: the job's own guide, else the persona guide for the host's `context.persona`, as `Converse` picks it. Before, a job whose guides were all per persona read "No guide yet".
13
+ - **Size budgets:** chat 12 KB gz (was 11.5 KB), help 15 KB + 128 B. Help's code is unchanged; the highlighter and help client it now shares with the walkthrough are a separate chunk.
14
+
15
+ ## 0.2.0 (2026-10-29)
16
+
17
+ First stable release after 0.1.0. Additive: existing 0.1.x integrations need no change.
18
+
19
+ - **Signed claims v2 (contract §15; released by owner decision 2026-10-29, journeeze-saas#298, Allumata review to follow):** opt-in; sites keep accepting v1 identities until their `min_claims_version` is raised. new `claims` option (the host server's signed token) and `getToken()` refresh callback. The SDK sends the token on feedback, screenshot uploads, help reads, intent routing and chat turns while it is well formed and more than 60 s from its `exp`, asks `getToken()` for a fresh one otherwise, and never reuses a token after `reset()`. Entitlement-gated guides are served only with a verified token, and help picks persona guides for the verified `profile.kind`. A token's life is measured from when the page saw it (`exp − iat`), so a wrong page clock does not matter; `getToken()` is called at most once per 15 s while the current token works; feedback and telemetry sends never wait for it. The loader only forgets the token on `reset()`; the checks live in the lazy chunks.
20
+
21
+ - **License:** the SDK is now open source under the Apache License 2.0 (owner decision 2026-10-18, #245). `LICENSE` and `NOTICE` replace the proprietary `LICENSE.md`; npm metadata reads `Apache-2.0`. Versions up to 0.1.0-rc.3 were published under the previous proprietary terms.
22
+
23
+ ## 0.1.0 (2026-10-18)
24
+
25
+ Stable release published from commit 3df591d (no separate entry was recorded at the time).
26
+
27
+ ## 0.1.0-rc.3 (2026-10-18)
4
28
 
5
29
  - **Setup documentation:** the README is a self-contained setup guide: what the Journeeze team sends you, install with a pinned version, `apiHost` per environment, CSP, signed identity with a test vector, privacy and masking, help, feedback, signals, the Journeeze GitHub App and its permissions, a checklist and troubleshooting. Examples use `window.Journeeze` only after `DOMContentLoaded`. The license line matches `LICENSE.md`.
6
30
  - **Help chat on the live `Converse` (HC8c):** each turn carries the reviewer token (when the host has one), and on consented turns the signed user id (`userId`, `userIdExp`, `userIdSig`) and the detector's over-masking counts (`overMasked`, counts per rule only). Closing the chat (✕ or Esc) ends a started conversation with a `cancel` turn; opening it again starts a new one.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,7 @@
1
+ Journeeze SDK (@journeeze/sdk)
2
+ Copyright 2026 Matt Cochran Products
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
5
+
6
+ Third-party components bundled into dist/ are licensed under their own terms; see
7
+ dist/THIRD_PARTY_LICENSES.txt.
package/README.md CHANGED
@@ -42,7 +42,7 @@ the Journeeze team ([Before you start](#before-you-start)).
42
42
  With your production site key:
43
43
 
44
44
  ```sh
45
- npm install @journeeze/sdk@rc --save-exact
45
+ npm install @journeeze/sdk@latest --save-exact
46
46
  ```
47
47
 
48
48
  `rc` selects the current release candidate; `--save-exact` pins the resolved version. Commit your
@@ -67,7 +67,7 @@ document.querySelector("#send-feedback")?.addEventListener("click", () => {
67
67
  });
68
68
  ```
69
69
 
70
- For a staging site key, also set `apiHost: "https://app.staging.journeeze.dev"`; see
70
+ For a staging site key, also set `apiHost: "https://staging.journeeze.dev"`; see
71
71
  [Environments](#environments-and-apihost). Mark customer content with `data-jz-mask` before testing.
72
72
 
73
73
  1. Open your registered app origin and click **Send feedback**.
@@ -108,13 +108,12 @@ Pick one way. Both load the same code.
108
108
  ### npm (bundled apps)
109
109
 
110
110
  ```sh
111
- npm install @journeeze/sdk@rc --save-exact
111
+ npm install @journeeze/sdk@latest --save-exact
112
112
  ```
113
113
 
114
- The command resolves `rc` and pins that exact version. To choose a particular release, use
115
- `npm install @journeeze/sdk@<version> --save-exact`. Release candidates (`-rc.N`) are on the `rc`
116
- tag; stable releases use `latest`. Check the package's version tags before choosing a channel:
117
- an unqualified `npm install @journeeze/sdk` can select an older version than `rc`.
114
+ The command resolves `latest` (the newest stable release) and pins that exact version. To choose
115
+ a particular release, use `npm install @journeeze/sdk@<version> --save-exact`. Release candidates
116
+ (`-rc.N`) are on the `rc` tag; install them only when the Journeeze team asks you to test one.
118
117
 
119
118
  **React:**
120
119
 
@@ -152,7 +151,7 @@ function HelpButton() {
152
151
  ```ts
153
152
  import { createJourneeze } from "@journeeze/sdk";
154
153
 
155
- const jz = createJourneeze({ siteKey: "pk_...", apiHost: "https://app.staging.journeeze.dev" });
154
+ const jz = createJourneeze({ siteKey: "pk_...", apiHost: "https://staging.journeeze.dev" });
156
155
  document.querySelector("#help")?.addEventListener("click", () => jz.enableHelp());
157
156
  ```
158
157
 
@@ -197,7 +196,7 @@ refused, so set `apiHost` next to the site key in each environment's config:
197
196
  | Environment | `apiHost` / `data-journeeze-api-host` |
198
197
  |---|---|
199
198
  | Production | leave it out |
200
- | Staging | `https://app.staging.journeeze.dev` |
199
+ | Staging | `https://staging.journeeze.dev` |
201
200
  | Local Journeeze stack | `http://localhost:8080` |
202
201
  | Your own same-origin proxy | your origin, for example `https://www.example.com` |
203
202
 
@@ -208,7 +207,7 @@ proxy guide (gateway key, the paths to forward, reference Worker and server code
208
207
 
209
208
  ## Content Security Policy
210
209
 
211
- If your site sends a CSP, add these. Use `https://app.staging.journeeze.dev` on staging.
210
+ If your site sends a CSP, add these. Use `https://staging.journeeze.dev` on staging.
212
211
 
213
212
  ```
214
213
  script-src 'self' https://app.journeeze.dev;
@@ -361,8 +360,10 @@ Each call uses a one-hour token limited to that repository. You can remove the A
361
360
  (GitHub → Settings → Applications → Installed GitHub Apps). Journeeze then stops reading and
362
361
  filing.
363
362
 
364
- **After installing, tell the Journeeze team.** They link the repository to your project. This is
365
- one step on their side until the board does it for you.
363
+ **Then connect it on the board.** On the Journeeze board, open **Onboarding** and click
364
+ **Connect GitHub**. Sign in with GitHub, pick the repository (only repositories where the App is
365
+ installed and you are an admin are listed) and its catalog folder (default `.jevitate/`). Only
366
+ project owners can connect a repository.
366
367
 
367
368
  **Your journey catalog.** Journeeze reads the [Jevitate](https://jevitate.com) catalog in your repository's `.jevitate/`
368
369
  folder (personas, jobs and journeys) on each push. Guides with screenshots and video are imported
@@ -370,9 +371,9 @@ from your approved journeys as drafts. A triager reviews each one on the board (
370
371
  lightly edit the step text, and publishes it. Only published guides appear in help.
371
372
 
372
373
  **Without the App: upload from CI.** Your CI can upload the catalog as a bundle instead:
373
- `POST https://app.journeeze.dev/api/upload/v1/bundles` with `Authorization: Bearer jzu_…`. The
374
- Journeeze team creates upload keys for now and sends them as a one-time 1Password link. Ask them
375
- for the bundle format and a CI example. Never put an upload key in a URL or a log.
374
+ `POST https://app.journeeze.dev/api/upload/v1/bundles` with `Authorization: Bearer jzu_…`. A
375
+ project owner creates the key on the board (**Settings → Upload keys**); it is shown once. Store it
376
+ as the CI secret `JOURNEEZE_UPLOAD_KEY`. Never put an upload key in a URL or a log.
376
377
 
377
378
  ## Setup checklist
378
379
 
@@ -384,7 +385,7 @@ for the bundle format and a CI example. Never put an upload key in a URL or a lo
384
385
  - [ ] `data-tflow-id` on every element a guide points at; `journeyStep` set per route.
385
386
  - [ ] Signed-in users: user id and signature made on your server and delivered `no-store`;
386
387
  `reset()` on every logout path.
387
- - [ ] Journeeze GitHub App installed on your repository, and the Journeeze team told.
388
+ - [ ] Journeeze GitHub App installed on your repository, and the repository connected on the board (Onboarding → Connect GitHub).
388
389
  - [ ] Help switched on for the site on the board, audience chosen, guides published.
389
390
  - [ ] One test feedback item sent from each site and seen on the board.
390
391
 
@@ -401,7 +402,7 @@ for the bundle format and a CI example. Never put an upload key in a URL or a lo
401
402
  | Feedback is anonymous although `userId` is set | The signature is missing, wrong, expired, or made for another site key. |
402
403
  | `userId` ignored with a console warning | It is not a 64-hex or 43-base64url hash (for example a raw UUID or an email). |
403
404
  | `429` responses from an office or CI | Many users share one IP address. Use a proxy, or ask for a higher quota. |
404
- | Issues are never filed | The Journeeze GitHub App is not installed on the repository, or the Journeeze team has not linked it yet. |
405
+ | Issues are never filed | The Journeeze GitHub App is not installed on the repository, or the repository is not connected on the board (Onboarding shows its state). |
405
406
 
406
407
  ## Versions and license
407
408
 
@@ -409,6 +410,7 @@ Changes are listed in `CHANGELOG.md` in this package. Public types ship in `dist
409
410
  `@journeeze/sdk/contract` exports `SITE_KEY_PATTERN` and `USER_ID_PATTERN` for your server's
410
411
  tests.
411
412
 
412
- Proprietary: see `LICENSE.md`. You may install this package and include it, unmodified, in
413
- websites and applications solely to connect them to the Journeeze service, under your agreement for
414
- that service. It is not open source.
413
+ Licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
414
+ (`LICENSE` and `NOTICE` in this package). You may read, modify and redistribute it under those
415
+ terms. Using the hosted Journeeze service is governed by your agreement for that service, not by
416
+ this license.
@@ -0,0 +1 @@
1
+ import{a as f}from"./loader-DHgG5Y7t.js";const g=512,p=12;function b(t){const n=[];let o=t,e=false;for(let i=0;o&&i<p;i++){const r=o.hasAttribute("data-tflow-id")?f(o):void 0;if(r!==void 0&&o.getAttribute("data-tflow-id")===r){n.unshift(`[data-tflow-id="${r}"]`),e=true;break}const s=o.tagName.toLowerCase();if(s==="body"||s==="html"){n.unshift(s),e=true;break}const c=o,l=c.parentElement;let d=s;if(l){const u=Array.from(l.children).filter(m=>m.tagName===c.tagName);u.length>1&&(d+=`:nth-of-type(${u.indexOf(c)+1})`)}n.unshift(d),o=l}const a=n.join(" > ");return e&&a.length<=g?a:void 0}const h=t=>Number.isFinite(t)?Math.min(1,Math.max(0,t)):.5;function v(t,n,o){const e=t.getBoundingClientRect(),a={xRatio:h(e.width>0?(n-e.left)/e.width:.5),yRatio:h(e.height>0?(o-e.top)/e.height:.5)},i=f(t);i!==void 0&&(a.tflowId=i);const r=b(t);return r!==void 0&&(a.cssSelector=r),a}function A(t){return f(t)??t.tagName.toLowerCase()}function k(t){return t.closest("[data-jz-block]")!==null}function C(t){return t<768?"mobile":t<1024?"tablet":"desktop"}export{v as a,C as d,A as e,k as i};
@@ -0,0 +1,21 @@
1
+ import{a as K}from"./loader-DHgG5Y7t.js";import{i as q}from"./anchor-bnZCZtbG.js";import{a as V,p as G}from"./upload-KvsGqMEV.js";import{m as Se}from"./upload-KvsGqMEV.js";import{M as T,u as J}from"./chat-Coze4aH0.js";const R=10,j=.02,z=.01,h=(e,n,t)=>Number.isFinite(e)?Math.min(t,Math.max(n,e)):n,p=e=>Math.round(e*1e4)/1e4;function Q(e,n,t){return{x:h(t.width>0?(e-t.left)/t.width:0,0,1),y:h(t.height>0?(n-t.top)/t.height:0,0,1)}}function $(e,n,t){const i=h(n.x,0,1),a=h(n.y,0,1),r=h(t.x,0,1),s=h(t.y,0,1);return e==="arrow"?{type:e,x:p(i),y:p(a),w:p(r-i),h:p(s-a)}:{type:e,x:p(Math.min(i,r)),y:p(Math.min(a,s)),w:p(Math.abs(r-i)),h:p(Math.abs(s-a))}}function Z(e){return Math.abs(e.w)<z&&Math.abs(e.h)<z}function ee(e){return e==="arrow"?{type:e,x:.35,y:.35,w:.15,h:.15}:{type:e,x:.35,y:.4,w:.3,h:.2}}function te(e,n,t,i){const a=e.type==="arrow";if(i){const c=a?h(e.w+n,-e.x,1-e.x):h(e.w+n,z,1-e.x),u=a?h(e.h+t,-e.y,1-e.y):h(e.h+t,z,1-e.y);return{...e,w:p(c),h:p(u)}}const r=h(e.x+n,Math.max(0,-e.w),Math.min(1,1-e.w)),s=h(e.y+t,Math.max(0,-e.h),Math.min(1,1-e.h));return{...e,x:p(r),y:p(s)}}function U(e,n,t,i,a){const r=Math.atan2(i-n,t-e),s=c=>`${p(t-a*Math.cos(r+c))},${p(i-a*Math.sin(r+c))}`;return`${p(t)},${p(i)} ${s(Math.PI/7)} ${s(-Math.PI/7)}`}function ne(e,n,t,i){e.strokeStyle=e.fillStyle="#B42318",e.lineWidth=Math.max(2,Math.round(Math.max(t,i)/160));for(const a of n)if(e.beginPath(),a.type==="box"?e.rect(a.x*t,a.y*i,a.w*t,a.h*i):a.type==="circle"?e.ellipse((a.x+a.w/2)*t,(a.y+a.h/2)*i,a.w/2*t,a.h/2*i,0,0,Math.PI*2):(e.moveTo(a.x*t,a.y*i),e.lineTo((a.x+a.w)*t,(a.y+a.h)*i)),e.stroke(),a.type==="arrow"){const r=U(a.x*t,a.y*i,(a.x+a.w)*t,(a.y+a.h)*i,e.lineWidth*4).split(" ").map(s=>s.split(",").map(Number));e.beginPath(),r.forEach(([s,c],u)=>u?e.lineTo(s,c):e.moveTo(s,c)),e.fill()}}const ae="http://www.w3.org/2000/svg",B=["box","circle","arrow"];function m(e,n={},...t){const i=document.createElement(e);for(const[a,r]of Object.entries(n))i.setAttribute(a,r);return i.append(...t),i}function M(e,n){const t=document.createElementNS(ae,e);for(const[i,a]of Object.entries(n))t.setAttribute(i,String(a));return t}function ie(e,n,t){const i={fill:"none",stroke:"#B42318","stroke-width":3,"vector-effect":"non-scaling-stroke"};if(e.type==="box")return M("rect",{x:e.x*n,y:e.y*t,width:e.w*n,height:e.h*t,...i});if(e.type==="circle")return M("ellipse",{cx:(e.x+e.w/2)*n,cy:(e.y+e.h/2)*t,rx:e.w/2*n,ry:e.h/2*t,...i});const[a,r,s,c]=[e.x*n,e.y*t,(e.x+e.w)*n,(e.y+e.h)*t],u=M("g",{});return u.append(M("line",{x1:a,y1:r,x2:s,y2:c,...i}),M("polygon",{points:U(a,r,s,c,Math.max(n,t)/50),fill:"#B42318"})),u}function oe(e,n,t,i){return new Promise(a=>{let r="box",s=[],c,u;const v=B.map(o=>{const d=m("button",{type:"button",class:"tool","aria-pressed":String(o===r)},i(`draw.${o}`));return d.addEventListener("click",()=>{r=o,v.forEach((g,b)=>g.setAttribute("aria-pressed",String(B[b]===o)))}),d}),l=(o,d,g)=>{const b=m("button",{type:"button",class:d},o);return b.addEventListener("click",g),b},w=l(i("draw.undo"),"tool",()=>A(s.slice(0,-1),i("draw.removed_last"))),y=l(i("draw.clear"),"tool",()=>A([],i("draw.cleared"))),N=l(i("cancel"),"btn",()=>P(void 0)),X=l(i("draw.done"),"btn pri",()=>P(s)),I=M("svg",{viewBox:`0 0 ${t.w} ${t.h}`,preserveAspectRatio:"none","aria-hidden":"true"}),H=m("img",{src:n,alt:i("draw.image"),draggable:"false"}),W=m("span",{id:"jzd-k",class:"sr"},i("draw.keys")),f=m("div",{class:"stage",tabindex:"0",role:"group","aria-label":i("draw.stage"),"aria-describedby":"jzd-k"},H,I,W),L=m("p",{class:"msg",role:"status"}),E=m("div",{class:"jzd",role:"dialog","aria-modal":"true","aria-labelledby":"jzd-t","aria-describedby":"jzd-h"},m("header",{},m("h2",{id:"jzd-t"},i("draw.title")),m("p",{id:"jzd-h"},i("draw.hint"))),m("div",{class:"bar",role:"toolbar","aria-label":i("draw.tools")},...v,m("span",{class:"sep","aria-hidden":"true"}),w,y,m("span",{class:"end"},N,X)),m("div",{class:"wrap"},f),L);function k(){I.replaceChildren(...[...s,...u?[u]:[]].map(o=>ie(o,t.w,t.h))),w.disabled=y.disabled=s.length===0}function A(o,d){s=o,L.textContent=d,k()}function O(o){if(s.length>=R){L.textContent=i("draw.shape_limit",{max:R});return}A([...s,o],i(`draw.added.${o.type}`,{n:s.length+1,max:R}))}function S(){const o=f.parentElement,d=getComputedStyle(o),g=Math.max(1,o.clientWidth-parseFloat(d.paddingLeft||"0")-parseFloat(d.paddingRight||"0")),b=Math.max(1,o.clientHeight-parseFloat(d.paddingTop||"0")-parseFloat(d.paddingBottom||"0")),C=Math.min(g/t.w,b/t.h);f.style.width=`${Math.floor(t.w*C)}px`,f.style.height=`${Math.floor(t.h*C)}px`}const _=o=>Q(o.clientX,o.clientY,f.getBoundingClientRect());f.addEventListener("pointerdown",o=>{o.button===0&&(o.preventDefault(),f.setPointerCapture?.(o.pointerId),c=_(o))}),f.addEventListener("pointermove",o=>{c&&(u=$(r,c,_(o)),k())});const Y=o=>{if(!c)return;const d=$(r,c,_(o));c=u=void 0,Z(d)?k():O(d)};f.addEventListener("pointerup",Y),f.addEventListener("pointercancel",()=>{c=u=void 0,k()}),f.addEventListener("keydown",o=>{const d={ArrowLeft:[-j,0],ArrowRight:[j,0],ArrowUp:[0,-j],ArrowDown:[0,j]};if(o.key==="Enter"||o.key===" ")o.preventDefault(),O(ee(r));else if(d[o.key]&&s.length>0){o.preventDefault();const[g,b]=d[o.key];s=[...s.slice(0,-1),te(s[s.length-1],g,b,o.shiftKey)],k()}}),E.addEventListener("keydown",o=>{if(o.stopPropagation(),o.key==="Escape")o.preventDefault(),P(void 0);else if(o.key==="Tab"){const d=[...E.querySelectorAll("button:not([disabled]), [tabindex='0']")],g=d.indexOf(e.activeElement);(o.shiftKey?g<=0:g===d.length-1)&&(o.preventDefault(),d[o.shiftKey?d.length-1:0]?.focus())}}),window.addEventListener("resize",S);function P(o){window.removeEventListener("resize",S),E.remove(),a(o)}e.append(E),k(),S(),v[0].focus()})}const re=`
2
+ .jzd{position:fixed;inset:0;z-index:2147483647;display:flex;flex-direction:column;background:var(--c);color:var(--i)}
3
+ .jzd header{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 12px;padding:12px 16px;border-bottom:1px solid var(--l);background:var(--s)}
4
+ .jzd h2{margin:0;font-size:14px;font-weight:600}
5
+ .jzd header p{margin:0;font-size:12px;color:var(--m)}
6
+ .jzd .bar{display:flex;flex-wrap:wrap;align-items:center;gap:6px;padding:8px 16px;border-bottom:1px solid var(--l);background:var(--s)}
7
+ .jzd .bar .sep{width:1px;height:28px;background:var(--l);margin:0 4px}
8
+ .jzd .bar .end{margin-left:auto;display:flex;gap:6px}
9
+ .jzd .tool{min-width:44px;min-height:44px;padding:0 12px;border:1px solid var(--l);border-radius:6px;background:var(--s)}
10
+ .jzd .tool[aria-pressed=true]{background:var(--as);border-color:var(--a);color:var(--a);font-weight:600}
11
+ .jzd .wrap{flex:1;min-height:0;display:grid;place-items:center;padding:16px}
12
+ .jzd .stage{position:relative;border:1px solid var(--l);border-radius:6px;overflow:hidden;background:var(--r);touch-action:none;cursor:crosshair;user-select:none;-webkit-user-select:none}
13
+ .jzd .stage img,.jzd .stage svg{position:absolute;inset:0;width:100%;height:100%;display:block}
14
+ .jzd .stage svg{overflow:visible}
15
+ .jzd .stage *{pointer-events:none}
16
+ .jzd .msg{min-height:20px;margin:0;padding:0 16px 8px;font-size:12px;color:var(--m)}
17
+ .pick{position:fixed;inset:0;z-index:2147483647;cursor:crosshair;touch-action:none}
18
+ .pick .hl{position:fixed;border:2px solid var(--a);border-radius:4px;background:var(--as);pointer-events:none}
19
+ .pick .hint{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);display:flex;align-items:center;gap:8px;max-width:calc(100vw - 32px);padding:4px 4px 4px 16px;border:1px solid var(--l);border-radius:10px;background:var(--s);box-shadow:var(--sh);font-size:13px}
20
+ @media (max-width:640px){.jzd .bar .end{margin-left:0;width:100%}.jzd .bar .end .btn{flex:1}.jzd .wrap{padding:8px}}
21
+ `,D=["image/png","image/jpeg","image/webp","image/gif"],se=10*1024*1024,ce=2*1024*1024,de=1600,le="[data-journeeze], [data-journeeze-chat]",x=(e,n)=>e.session.note(e.session.t(n,{max:T}));async function ze(e,n){return pe(n),e==="point_at_it"?ge(n):n.options.reviewerToken||n.options.userId||n.options.claims||n.options.getToken?n.session.attachments.length>=T?x(n,"note.attachment_limit"):e==="show_us_where"?he(n):xe(n):x(n,"note.signed_out")}function pe(e){if(e.root.querySelector("style[data-jz-capture]"))return;const n=document.createElement("style");n.setAttribute("data-jz-capture",""),n.textContent=re,e.options.nonce&&(n.nonce=e.options.nonce),e.root.append(n)}async function ue(e){const n=await e.config(),t=Array.isArray(n.maskSelectors)?n.maskSelectors:[],{maskSelectors:i,maskAllText:a}=e.options;return{...i?{maskSelectors:i}:{},...t.length?{configMaskSelectors:t}:{},...a?{maskAllText:a}:{}}}async function me(e){try{const n=await V(document.body,await ue(e));if(n.blob)for(const[t,i]of Object.entries(n.detectorCounts))i&&e.session.overMask.set(t,(e.session.overMask.get(t)??0)+i);return n.blob}catch{return}}async function he(e){const n=e.suspend(),t=await me(e);if(!t)return n(),x(e,"note.masking_failed");const i={w:Math.max(1,window.innerWidth),h:Math.max(1,window.innerHeight)},a=URL.createObjectURL(t),r=await oe(e.root,a,i,e.session.t);URL.revokeObjectURL(a),n(),r&&await F(e,t,i,r,"attachment.screenshot")}async function F(e,n,t,i,a){const r=await fe(n,t,i);e.session.addAttachment({id:J(),thumbnail:r,label:e.session.t(a,{n:e.session.attachments.length+1}),...i.length?{shapes:i}:{},upload:async()=>G(e.endpoint,e.options,n,void 0,await e.claims?.()),release:()=>URL.revokeObjectURL(r)})||(URL.revokeObjectURL(r),x(e,"note.attachment_limit"))}async function fe(e,n,t){try{const i=await createImageBitmap(e),a=document.createElement("canvas");a.width=256,a.height=Math.max(1,Math.round(256*n.h/n.w));const r=a.getContext("2d");r.drawImage(i,0,0,a.width,a.height),ne(r,t,a.width,a.height);const s=await new Promise(c=>a.toBlob(c,"image/webp",.8));if(s)return URL.createObjectURL(s)}catch{}return URL.createObjectURL(e)}async function ge(e){const n=e.suspend(),t=await be(e.root,e.session.t);if(n(),!t)return;const i=q(t)?void 0:K(t);i?e.session.setAnchor({tflowId:i}):x(e,"note.no_name")}function we(e,n){return document.elementsFromPoint(e,n).find(t=>!t.closest(le)&&t!==document.documentElement)}function be(e,n){return new Promise(t=>{const i=document.createElement("div");i.className="hl",i.hidden=true;const a=document.createElement("button");a.type="button",a.className="btn",a.textContent=n("cancel");const r=document.createElement("div");r.className="hint",r.setAttribute("role","dialog"),r.setAttribute("aria-label",n("point.label")),r.append(n("point.hint"),a);const s=document.createElement("div");s.className="pick",s.append(i,r);const c=l=>{const w=we(l.clientX,l.clientY);return w?.closest("[data-tflow-id]")??w};s.addEventListener("pointermove",l=>{const w=c(l);if(i.hidden=!w,!w)return;const y=w.getBoundingClientRect();Object.assign(i.style,{left:`${y.left}px`,top:`${y.top}px`,width:`${y.width}px`,height:`${y.height}px`})}),s.addEventListener("pointerup",l=>{r.contains(l.target)||v(c(l))}),a.addEventListener("click",()=>v(void 0));const u=l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),v(void 0))};document.addEventListener("keydown",u,true);function v(l){document.removeEventListener("keydown",u,true),s.remove(),t(l)}e.append(s),a.focus()})}function xe(e){return new Promise(n=>{const t=document.createElement("input");t.type="file",t.accept=D.join(","),t.hidden=true,e.root.append(t),t.addEventListener("change",()=>{const i=t.files?.[0];t.remove(),i?ve(e,i).then(n):n()}),t.addEventListener("cancel",()=>{t.remove(),n()}),t.click()})}async function ve(e,n){if(!D.includes(n.type)||n.size>se)return x(e,"note.file_type");if(e.session.attachments.length>=T)return x(e,"note.attachment_limit");const t=await ye(n).catch(()=>{});if(!t)return x(e,"note.file_read");await F(e,t.blob,t.size,[],"attachment.image")}async function ye(e){const n=await createImageBitmap(e,{imageOrientation:"from-image"});let t=Math.min(1,de/Math.max(n.width,n.height));for(const i of[.85,.7,.5]){const a=document.createElement("canvas");a.width=Math.max(1,Math.round(n.width*t)),a.height=Math.max(1,Math.round(n.height*t)),a.getContext("2d").drawImage(n,0,0,a.width,a.height);const r=await new Promise(s=>a.toBlob(s,"image/webp",i));if(!r||r.type!=="image/webp"&&r.type!=="image/png")return;if(r.size<=ce)return{blob:r,size:{w:a.width,h:a.height}};t*=.75}}export{D as IMAGE_TYPES,se as MAX_FILE_BYTES,ve as addFile,ue as maskOptions,me as maskedCapture,Se as maskedSnapshotSvg,we as pageElementAt,be as pick,ze as plusItem,ye as reencode};
@@ -0,0 +1,64 @@
1
+ var Y=Object.defineProperty;var Q=(n,e,t)=>e in n?Y(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var p=(n,e,t)=>Q(n,typeof e!="symbol"?e+"":e,t);import{c as U,C as Z,k as ee,d as te,j as ne,g as G,h as ie,s as re,f as ae}from"./consent-bPengyOI.js";const oe="journeeze.turn/v1";class se extends Error{constructor(t,i){super(t);p(this,"kind");p(this,"status");this.kind=t,this.status=i}}function K(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const n=crypto.getRandomValues(new Uint8Array(16));n[6]=n[6]&15|64,n[8]=n[8]&63|128;const e=[...n].map(t=>t.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}function de(n){const e=n instanceof Z?n.status:0,t=e===429?"busy":e===400?"invalid":"unavailable";return new se(t,e)}function le(n,e=(...t)=>fetch(...t)){return{turn:t=>U(n,"Converse",t,e).then(i=>({...i,messages:i.messages??[],actions:i.actions??[],requiresConsent:!!i.requiresConsent}),i=>{throw de(i)})}}function ce(n,e,t,i){const r=le(n,t);return{turn:async d=>{const u=await i?.();return r.turn({...d,...e.reviewerToken&&{reviewerToken:e.reviewerToken},...d.consentGiven&&e.userId&&{userId:e.userId,...ee(e)},...u&&{claims:u}})}}}const pe="Help";function he(n){return(e,t)=>(n?.["widget.ui."+e]??"").replace(/\{(\w+)\}/g,(i,r)=>String(t?.[r]??""))}function ue(n,e){const t=e.toLowerCase().split(/\s+/).filter(Boolean);return n.filter(i=>t.every(r=>i.title.toLowerCase().includes(r)))}function fe(n){return typeof n.steps=="number"&&n.steps>0?n.steps:void 0}function be(n){return/Edg\//.test(n)?"Edge":/Firefox\//.test(n)?"Firefox":/Chrome\/|CriOS\//.test(n)?"Chrome":/Safari\//.test(n)?"Safari":"Other"}function me(n,e,t){const i=[],r=(d,u,s=true)=>{u&&!e.has(d)&&i.push({key:d,label:u,removable:s})};return r("page",n.pagePath&&t("context.page",{value:n.pagePath})),r("job",n.job,false),r("step",n.step!==void 0&&t("context.step",{step:n.step}),false),r("persona",n.persona&&t("context.persona",{value:n.persona})),r("browser",n.browser),r("device",n.device&&(n.viewport?`${n.device} · ${n.viewport.w}×${n.viewport.h}`:n.device)),r("build",n.build&&t("context.build",{value:n.build})),i}const ve=["page","persona","browser","device","viewport","build"];function ge(n,e){const t=new Set(e);t.has("device")&&t.add("viewport");const i={pagePath:t.has("page")?"":n.pagePath};n.persona&&!t.has("persona")&&(i.persona=n.persona),n.browser&&!t.has("browser")&&(i.browser=n.browser),n.device&&!t.has("device")&&(i.device=n.device),n.viewport&&!t.has("viewport")&&(i.viewport=n.viewport),n.build&&!t.has("build")&&(i.build=n.build);const r=ve.filter(d=>t.has(d));return r.length>0&&(i.removed=r),i}const xe=5,ke="clarify_tap_only";class W{constructor(e){p(this,"deps");p(this,"conversationId",K());p(this,"entries",[]);p(this,"state","choose_job");p(this,"actions",[]);p(this,"requiresConsent",false);p(this,"pending",false);p(this,"error");p(this,"tapOnly",false);p(this,"consentAsked",false);p(this,"filed");p(this,"attachments",[]);p(this,"anchor");p(this,"removed",new Set);p(this,"team",{});p(this,"job");p(this,"step",0);p(this,"last");p(this,"ended",false);p(this,"opening",{chips:[]});p(this,"overMask",new Map);p(this,"listeners",new Set);p(this,"consent");p(this,"t");this.deps=e,this.consent=e.hasConsent(),this.t=e.t}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(){for(const e of this.listeners)e()}start(e){this.opening={chips:e},this.entries=[{kind:"assistant",copyId:"ask_job",text:this.t("greeting")}],this.actions=[...e,{type:"other_need",label:this.t("other_need")}],this.emit()}close(){if(this.ended||(this.ended=true,this.emit(),!this.last))return;const e=this.conversationId,t={kind:"action",action:"cancel"};this.send({turnId:K(),input:t}).then(i=>{e===this.conversationId&&(this.apply(t,i),this.emit())},()=>{})}reopen(){if(!this.ended)return;for(const t of this.attachments)t.release?.();const{chips:e}=this.opening;Object.assign(this,new W(this.deps),{listeners:this.listeners,overMask:this.overMask}),this.start(e)}guidePosition(){if(!(this.ended||this.state!=="guide_step"||!this.job||this.step<1))return{jobId:this.job.id,step:this.step,of:this.job.of}}offers(e){return this.actions.some(t=>t.type===e)}label(e){return this.actions.find(t=>t.type===e)?.label??""}chips(){return this.actions.filter(e=>e.type==="chip")}plusItems(){for(const e of this.actions)if(e.type==="plus_menu")return e.menu??e.items.map(t=>({id:t,label:""}));return[]}needsConsent(){return!this.consent&&(this.requiresConsent||this.offers("consent"))}allow(){this.deps.giveConsent(),this.consent=true,this.consentAsked=false,this.emit()}contextChips(){return me(this.facts(),this.removed,this.t)}removeContext(e){this.removed.add(e),this.emit()}setTeam(e){this.team={...this.team,...e}}teamOnWire(){const e={};return this.team.verdict&&(e.verdict=this.team.verdict),this.team.severity&&(e.severity=this.team.severity),e}addAttachment(e){const t=this.attachments.filter(i=>i.id!==e.id);return t.length>=xe?false:(this.attachments=[...t,e],this.emit(),true)}removeAttachment(e){this.attachments.find(t=>t.id===e)?.release?.(),this.attachments=this.attachments.filter(t=>t.id!==e),this.emit()}setAnchor(e){this.anchor=e,this.emit()}note(e){this.entries=[...this.entries,{kind:"note",text:e}],this.emit()}async uploadPending(){if(!this.consent)return;const e=this.attachments.filter(r=>!r.screenshotId&&r.upload),t=await Promise.all(e.map(r=>r.upload().catch(()=>{})));let i=false;e.forEach((r,d)=>{const u=t[d];u?this.attachments=this.attachments.map(s=>s===r?{...r,screenshotId:u}:s):(i=true,r.release?.(),this.attachments=this.attachments.filter(s=>s!==r))}),i&&(this.entries=[...this.entries,{kind:"note",text:this.t("note.upload_failed")}])}draft(){if(!this.consent)return;const e=this.attachments.flatMap(i=>i.screenshotId?[{screenshotId:i.screenshotId,...i.shapes?.length?{shapes:i.shapes}:{}}]:[]),t={};return e.length>0&&(t.attachments=e),this.anchor&&(t.anchor=this.anchor.tflowId),t.attachments||t.anchor?t:void 0}pickJob(e){this.job={id:e.jobId,title:e.title,of:fe(e)},this.run({kind:"action",action:"pick_job",jobId:e.jobId},e.title)}other(){this.run({kind:"action",action:"other_need"},this.label("other_need"))}next(){this.job&&this.run({kind:"action",action:"guide_next",jobId:this.job.id,step:this.step})}back(){this.state==="guide_step"&&this.job?this.run({kind:"action",action:"guide_back",jobId:this.job.id,step:this.step}):this.run({kind:"action",action:"guide_back"})}didntWork(){this.run({kind:"action",action:"didnt_work"},this.label("didnt_work"))}talk(){this.run({kind:"action",action:"talk_to_assistant"},this.label("talk_to_assistant"))}reportProblem(){this.run({kind:"action",action:"report_problem"},this.t("report_problem"))}sendText(e){const t=e.trim().slice(0,2e3);return!t||this.tapOnly||this.pending?false:this.needsConsent()?this.askConsent():(this.run({kind:"text",text:t},t),true)}sendReport(){return this.needsConsent()?this.askConsent():(this.run({kind:"action",action:"send"},this.label("send")),true)}retry(){this.last&&!this.pending&&this.exec(this.last)}askConsent(){return this.consentAsked=true,this.emit(),false}facts(){const e=this.deps.facts();return this.job?{...e,job:this.job.title,...this.step>0?{step:this.step}:{}}:e}run(e,t){this.pending||(t&&(this.entries=[...this.entries,{kind:"user",text:t}]),this.exec(this.last={turnId:K(),input:e}))}exec(e){this.pending=true,this.error=void 0,this.emit();const t=this.conversationId;this.uploadPending().then(()=>this.send(e)).then(i=>{t===this.conversationId&&this.apply(e.input,i)},i=>{t===this.conversationId&&(this.error=i.kind??"unavailable",this.error==="unavailable"&&(this.tapOnly=true))}).finally(()=>{this.pending=false,this.emit()})}send(e){const t=this.draft(),i=this.consent?[...this.overMask].map(([r,d])=>({rule:r,count:d})):[];return this.deps.transport.turn({siteKey:this.deps.siteKey,conversationId:this.conversationId,turnId:e.turnId,consentGiven:this.consent,context:ge(this.facts(),this.removed),schema:oe,payload:{input:e.input,...t?{draft:t}:{},...this.deps.reviewer&&(this.team.verdict||this.team.severity)?{team:this.teamOnWire()}:{}},...i.length?{overMasked:i}:{}}).then(r=>(i.length&&this.overMask.clear(),r))}apply(e,t){const i=this.state,r=e.kind==="action"?e.action:void 0;t.state==="guide_step"&&(r==="pick_job"?this.step=1:r==="guide_next"?this.step+=1:r==="guide_back"&&(this.step=Math.max(1,this.step-1)));const d=this.entries.map(s=>s.kind==="card"&&s.live?{...s,live:false}:s);let u;for(const s of t.messages)d.push({kind:"assistant",copyId:s.copyId,text:s.text}),s.card&&(s.card.step&&(this.step=s.card.step),this.job&&s.card.of&&(this.job.of=s.card.of),u={kind:"card",job:this.job?.title??"",step:this.step,of:s.card.of??this.job?.of,title:s.card.title,instruction:s.card.instruction,live:true});if(t.state==="guide_step"&&this.job&&d.push(u??{kind:"card",job:this.job.title,step:this.step,of:this.job.of,live:true}),t.state==="unmet_need"&&i!=="unmet_need"&&d.push({kind:"note",text:this.t("note.unmet")}),this.entries=d,this.tapOnly=t.messages.some(s=>s.copyId===ke),this.actions=t.actions,this.requiresConsent=t.requiresConsent,this.state=t.state,this.filed=t.filed?t.filed.kind??"problem":void 0,t.filed){for(const s of this.attachments)s.release?.();this.attachments=[],this.anchor=void 0,this.removed.clear(),this.team={}}["guide_step","didnt_work","gather","confirm_send"].includes(t.state)||(this.job=void 0,this.step=0)}}const ye=`
2
+ :host{all:initial;--c:#F7F7F5;--s:#FFF;--r:#F0F0EC;--i:#1D2024;--m:#5D636B;--f:#6C727B;--l:rgb(29 32 36/12%);--a:#3D63C9;--ai:#FFF;--as:rgb(61 99 201/10%);--sh:0 1px 3px rgb(0 0 0/12%),0 4px 12px rgb(0 0 0/8%);
3
+ font:400 13px/1.45 Inter,system-ui,-apple-system,"Segoe UI",sans-serif;color:var(--i);-webkit-font-smoothing:antialiased}
4
+ @media (prefers-color-scheme:dark){:host{--c:#111316;--s:#181B1F;--r:#20242A;--i:#E8EAED;--m:#A3A9B2;--f:#8A919B;--l:rgb(232 234 237/12%);--a:#7F9CF0;--ai:#111316;--as:rgb(127 156 240/14%)}}
5
+ *,*::before,*::after{box-sizing:border-box}
6
+ button,input,select{font:inherit;color:inherit}
7
+ button{cursor:pointer}
8
+ button:disabled,input:disabled{cursor:not-allowed;opacity:.55}
9
+ :focus-visible{outline:2px solid var(--a);outline-offset:2px}
10
+ [hidden]{display:none!important}
11
+ .sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
12
+ .launcher{position:fixed;right:24px;bottom:24px;z-index:2147483646;width:56px;height:56px;border-radius:999px;border:0;background:var(--a);color:var(--ai);font-size:24px;font-weight:600;box-shadow:var(--sh)}
13
+ .panel{position:fixed;right:24px;bottom:92px;z-index:2147483646;width:min(360px,calc(100vw - 48px));height:min(600px,calc(100vh - 116px));display:flex;flex-direction:column;background:var(--s);border:1px solid var(--l);border-radius:10px;box-shadow:var(--sh);overflow:hidden}
14
+ .head{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:8px 8px 8px 16px;border-bottom:1px solid var(--l);background:var(--c)}
15
+ .head h2{margin:0;font-size:13px;font-weight:600}
16
+ .head p{margin:0;font-size:12px;color:var(--f)}
17
+ .x{width:44px;height:44px;border:0;border-radius:6px;background:transparent;color:var(--m);font-size:20px}
18
+ .log{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:12px}
19
+ .msg{max-width:85%;padding:8px 12px;border:1px solid var(--l);border-radius:12px;white-space:pre-wrap;overflow-wrap:anywhere}
20
+ .as{align-self:flex-start;background:var(--s);border-bottom-left-radius:2px}
21
+ .us{align-self:flex-end;background:var(--as);border-bottom-right-radius:2px}
22
+ .note{align-self:flex-start;margin:0;font-size:12px;color:var(--m)}
23
+ .card{align-self:flex-start;width:90%;padding:12px;border:1px solid var(--l);border-radius:10px;background:var(--c)}
24
+ .card h3{margin:0 0 4px;font-size:12px;font-weight:600;color:var(--a)}
25
+ .card p{margin:0 0 8px;color:var(--m)}
26
+ .row{display:flex;gap:8px;flex-wrap:wrap}
27
+ .btn{min-height:44px;padding:0 16px;border:1px solid var(--l);border-radius:6px;background:var(--s)}
28
+ .pri{background:var(--a);border-color:var(--a);color:var(--ai);font-weight:600}
29
+ .link{min-height:44px;padding:0 4px;border:0;background:none;color:var(--a);text-decoration:underline}
30
+ .foot{border-top:1px solid var(--l);padding:12px;display:flex;flex-direction:column;gap:8px;background:var(--s)}
31
+ .dyn{display:flex;flex-direction:column;gap:8px}.dyn:empty{display:none}
32
+ .chips{display:flex;flex-wrap:wrap;gap:6px}
33
+ .chip{min-height:44px;padding:0 12px;border:1px solid var(--l);border-radius:999px;background:var(--s);color:var(--m)}
34
+ .chip.job{border-color:var(--a);color:var(--a)}
35
+ .err{margin:0;padding:8px;border-radius:6px;background:var(--r);color:var(--i)}
36
+ .consent{margin:0;font-size:12px;color:var(--m)}
37
+ .consent.ask{color:var(--i);font-weight:600}
38
+ details{font-size:12px;color:var(--m)}
39
+ summary{cursor:pointer;min-height:24px}
40
+ .ctx{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px;padding:0;list-style:none}
41
+ .ctx li{display:flex;align-items:center;gap:2px;padding-left:8px;border:1px solid var(--l);border-radius:6px;background:var(--r);color:var(--i)}
42
+ .ctx li.fixed{padding-right:8px;min-height:32px}
43
+ .ctx button,.att button{width:32px;height:32px;border:0;background:none;color:var(--m)}
44
+ .team{display:flex;gap:8px;margin-top:6px}
45
+ .team label{display:flex;flex-direction:column;gap:2px;color:var(--i)}
46
+ .team select{min-height:32px;border:1px solid var(--l);border-radius:6px;background:var(--s)}
47
+ .atts{display:flex;flex-wrap:wrap;gap:8px;margin:0;padding:0;list-style:none}
48
+ .att{position:relative;width:64px;height:48px;border:1px solid var(--l);border-radius:6px;overflow:hidden;background:var(--r)}
49
+ .att img{width:100%;height:100%;object-fit:cover}
50
+ .pt{display:flex;align-items:center;gap:2px;padding-left:8px;border:1px solid var(--l);border-radius:6px;background:var(--r);font-size:12px;max-width:100%;overflow-wrap:anywhere}
51
+ .pt button{width:32px;height:32px;border:0;background:none;color:var(--m)}
52
+ .att button{position:absolute;top:0;right:0;background:var(--i);color:var(--s);border-radius:0 0 0 6px}
53
+ .comp{position:relative;display:flex;gap:6px;align-items:center}
54
+ .comp input{flex:1;min-width:0;min-height:44px;padding:0 12px;border:1px solid var(--l);border-radius:6px;background:var(--c)}
55
+ .ico{width:44px;height:44px;flex:none;border:1px solid var(--l);border-radius:6px;background:var(--s);font-size:18px}
56
+ .send{background:var(--a);border-color:var(--a);color:var(--ai)}
57
+ .menu{position:absolute;left:0;right:0;bottom:52px;z-index:1;padding:4px;margin:0;list-style:none;background:var(--s);border:1px solid var(--l);border-radius:10px;box-shadow:var(--sh)}
58
+ .menu button{display:block;width:100%;min-height:44px;padding:4px 12px;border:0;border-radius:6px;background:none;text-align:left}
59
+ .menu button:hover,.menu button:focus-visible{background:var(--c)}
60
+ .menu small{display:block;color:var(--f)}
61
+ .dots{align-self:flex-start;color:var(--f)}
62
+ @media (max-width:640px){.panel{inset:0;width:auto;height:auto;border-radius:0;border:0}.launcher[aria-expanded=true]{display:none}}
63
+ @media (prefers-reduced-motion:reduce){*{transition-duration:1ms!important}}
64
+ `,we=["unreviewed","polished","needs_polish","broken"],_e=["low","medium","high","critical"],je=["didnt_work","gather","confirm_send","unmet_need"];function o(n,e={},...t){const i=document.createElement(n);for(const[r,d]of Object.entries(e))i.setAttribute(r,d);for(const r of t)r&&i.append(r);return i}function x(n,e,t,i={}){const r=o("button",{type:"button",class:e,...i},n);return r.addEventListener("click",t),r}function Ie(n,e,t){const i=e.t,r=o("button",{type:"button",class:"launcher","aria-label":i("launcher")||pe,"aria-expanded":"false","aria-controls":"jz-chat"},"?"),d=o("div",{class:"log",role:"log","aria-live":"polite","aria-label":i("conversation")}),u=o("div",{class:"dyn"});o("div");const s=o("input",{id:"jz-in",type:"text",autocomplete:"off",maxlength:"2000","aria-describedby":"jz-hint"}),z=o("span",{id:"jz-hint",class:"sr"}),k=o("button",{type:"button",class:"ico","aria-label":i("add_to_message"),"aria-haspopup":"menu","aria-expanded":"false","aria-controls":"jz-menu"},"+"),g=o("ul",{id:"jz-menu",class:"menu",role:"menu","aria-label":i("add_to_message")}),P=o("button",{type:"submit",class:"ico send","aria-label":i("send")},"➤"),F=o("form",{class:"comp"},g,k,o("label",{for:"jz-in",class:"sr"},i("message")),s,z,P),m=o("section",{id:"jz-chat",class:"panel",role:"dialog","aria-modal":"false","aria-labelledby":"jz-title"},o("header",{class:"head"},o("div",{},o("h2",{id:"jz-title"},i("title")),o("p",{},i("subtitle"))),x("✕","x",()=>c(),{"aria-label":i("close")})),d,o("div",{class:"foot"},u,F));m.hidden=true,g.hidden=true,n.append(r,m);let C=[],E=[];const M={ctx:false,team:false};r.addEventListener("click",()=>m.hidden?L():c()),s.addEventListener("input",()=>j()),F.addEventListener("submit",a=>{a.preventDefault(),e.sendText(s.value)&&(s.value="")}),k.addEventListener("click",()=>g.hidden?S():_(true)),g.addEventListener("keydown",a=>{const l=[...g.querySelectorAll("button")],b=l.indexOf(n.activeElement);a.key==="ArrowDown"||a.key==="ArrowUp"?(a.preventDefault(),l[(b+(a.key==="ArrowDown"?1:l.length-1))%l.length]?.focus()):a.key==="Tab"&&_(false)}),m.addEventListener("keydown",a=>{a.key==="Escape"&&(a.stopPropagation(),g.hidden?c():_(true))});function S(){g.replaceChildren(...e.plusItems().map(a=>{const l=o("button",{type:"button",role:"menuitem"},a.label,a.hint&&o("small",{},a.hint));return l.addEventListener("click",()=>{_(true),t.onPlusItem(a.id)}),o("li",{role:"none"},l)})),g.hidden=false,k.setAttribute("aria-expanded","true"),g.querySelector("button")?.focus()}function _(a){g.hidden=true,k.setAttribute("aria-expanded","false"),a&&k.focus()}function L(){e.reopen(),m.hidden=false,r.setAttribute("aria-expanded","true"),$(),(s.disabled?u.querySelector("button"):s)?.focus()}function c(){_(false),e.close(),m.hidden=true,r.setAttribute("aria-expanded","false"),r.focus()}function y(a){if(a.kind==="assistant")return o("div",{class:"msg as"},o("span",{class:"sr"},`${i("speaker.assistant")} `),a.text);if(a.kind==="user")return o("div",{class:"msg us"},o("span",{class:"sr"},`${i("speaker.you")} `),a.text);if(a.kind==="note")return o("p",{class:"note"},a.text);const l=`${a.job} · ${i(a.of?"card.step_of":"card.step",{step:a.step,of:a.of??""})}`,b=o("div",{class:"card",role:"group","aria-label":l},o("h3",{},l),a.title&&o("p",{},o("strong",{},a.title)),a.instruction&&o("p",{},a.instruction));if(a.live){const h=e.pending,A=x(e.label("guide_back"),"btn",()=>e.back(),{"data-back":""});A.disabled=h||a.step<=1;const I=x(e.label("guide_next"),"btn pri",()=>e.next());I.disabled=h;const w=x(e.label("didnt_work"),"link",()=>e.didntWork());w.disabled=h,b.append(o("div",{class:"row"},A,I),w)}return b}function O(){const a=e.entries;(a.length<E.length||a[0]!==E[0])&&(d.replaceChildren(),C=[],E=[]),a.forEach((l,b)=>{if(E[b]===l)return;const h=y(l);C[b]?l.kind==="card"?C[b].querySelectorAll(".row, .link").forEach(A=>A.remove()):C[b].replaceWith(h):(C[b]=h,d.append(h))}),a.forEach((l,b)=>{l.kind==="card"&&l.live&&C[b].querySelectorAll("button").forEach(h=>h.disabled=e.pending||h.hasAttribute("data-back")&&l.step<=1)}),E=[...a],d.querySelector(".dots")?.remove(),d.setAttribute("aria-busy",String(e.pending)),e.pending&&d.append(o("p",{class:"dots","aria-hidden":"true"},"…")),d.scrollTop=d.scrollHeight}function j(){const a=n.activeElement,l=a&&u.contains(a)?a.dataset.k:void 0,b=e.pending,h=[];e.error&&h.push(o("p",{class:"err",role:"status"},i(`error.${e.error}`)," ",x(i("try_again"),"link",()=>e.retry(),{"data-k":"retry"})));const A=e.tapOnly?e.chips():ue(e.chips(),s.value),I=e.offers("other_need");if(A.length>0||I){const v=o("div",{class:"chips",role:"group","aria-label":i("suggestions")});for(const f of A){const T=x(f.badge?`${f.title} · ${f.badge}`:f.title,"chip job",()=>e.pickJob(f),{"data-k":`job:${f.jobId}`});T.disabled=b,v.append(T)}if(I){const f=x(e.label("other_need"),"chip",()=>e.other(),{"data-k":"other"});f.disabled=b,v.append(f)}h.push(v)}const w=o("div",{class:"row"});if(e.offers("guide_back")&&e.state!=="guide_step"&&w.append(x(e.label("guide_back"),"btn",()=>e.back(),{"data-k":"back"})),e.offers("talk_to_assistant")&&w.append(x(e.label("talk_to_assistant"),"btn",()=>e.talk(),{"data-k":"talk"})),e.offers("send")&&w.append(x(e.label("send"),"btn pri",()=>e.sendReport(),{"data-k":"send",...e.needsConsent()?{"aria-describedby":"jz-consent"}:{}})),w.querySelectorAll("button").forEach(v=>v.disabled=b),w.childElementCount>0&&h.push(w),e.needsConsent()){const v=x(e.label("consent")||i("allow"),"link",()=>{e.allow(),s.focus()},{"data-k":"allow"});h.push(o("p",{id:"jz-consent",class:e.consentAsked?"consent ask":"consent"},`${i("consent_line")} · `,v))}if(je.includes(e.state)||e.offers("send")){const v=o("ul",{class:"ctx"});for(const f of e.contextChips()){const T=o("li",f.removable?{}:{class:"fixed"},f.label);f.removable&&T.append(x("✕","",()=>e.removeContext(f.key),{"aria-label":i("remove",{name:f.label}),"data-k":`ctx:${f.key}`})),v.append(T)}h.push(q("ctx",i("context.title"),v)),t.reviewer&&h.push(q("team",i("team.title"),D()))}if(e.attachments.length>0||e.anchor){const v=o("ul",{class:"atts","aria-label":i("attachments")});if(e.anchor){const f=i("pointed_at",{name:e.anchor.tflowId});v.append(o("li",{class:"pt"},f,x("✕","",()=>e.setAnchor(void 0),{"aria-label":i("remove",{name:f}),"data-k":"anchor"})))}e.attachments.forEach((f,T)=>{const B=f.label??i("attachment.screenshot",{n:T+1});v.append(o("li",{class:"att"},o("img",{src:f.thumbnail,alt:B}),x("✕","",()=>e.removeAttachment(f.id),{"aria-label":i("remove",{name:B}),"data-k":`att:${f.id}`})))}),h.push(v)}const X=e.state==="closed";s.disabled=e.tapOnly||X,s.placeholder=i(e.tapOnly?"input.tap_only":"input.placeholder"),z.textContent=e.tapOnly?i("input.paused"):"",P.disabled=s.disabled||b,k.hidden=e.plusItems().length===0,k.hidden&&!g.hidden&&_(false),u.replaceChildren(...h.filter(v=>!!v&&typeof v!="string")),e.consentAsked?u.querySelector("[data-k=allow]")?.focus():l&&(u.querySelector(`[data-k="${l}"]`)??(s.disabled?u.querySelector("button"):s))?.focus()}function q(a,l,b){const h=o("details",{},o("summary",{},l),b);return h.open=M[a],h.addEventListener("toggle",()=>M[a]=h.open),h}function D(){const a=(l,b,h,A)=>{const I=o("select",{},o("option",{value:""},"—"),...b.map(w=>o("option",{value:w},i(`team.${l}.${w}`))));return I.value=h??"",I.addEventListener("change",()=>A(I.value)),o("label",{},i(`team.${l}`),I)};return o("div",{class:"team"},a("verdict",we,e.team.verdict,l=>e.setTeam({verdict:l||void 0})),a("severity",_e,e.team.severity,l=>e.setTeam({severity:l||void 0})))}function $(){m.hidden||(O(),j())}const R=e.subscribe($);return{open:L,close:c,isOpen:()=>!m.hidden,suspend(){_(false);const a=!m.hidden;return m.hidden=true,r.hidden=true,()=>{r.hidden=false,a&&(m.hidden=false,$(),(k.hidden?s:k).focus())}},destroy(){R(),r.remove(),m.remove()}}}function H(n,e){if(n.journeyId)return{journeyId:n.journeyId,stepCount:n.stepCount??0};const t=e?n.personaGuides?.find(i=>i.persona===e&&i.journeyId):void 0;return t?.journeyId?{journeyId:t.journeyId,stepCount:t.stepCount??0}:void 0}const Ce=["desktop","tablet","mobile"];function N(n,e){const t=window.innerWidth,i=e.device&&Ce.includes(e.device)?e.device:t<768?"mobile":t<1024?"tablet":"desktop",r=n.signals?.appVersion;return{pagePath:n.pagePath==="none"?"":re(location.href).slice(0,512),persona:e.persona,browser:be(navigator.userAgent),device:i,viewport:{w:Math.min(t,2e4),h:Math.min(window.innerHeight,2e4)},build:r&&r.length<=64?r:void 0}}async function Ae(n,e,t){const i=await t?.(),r={siteKey:e.siteKey,...e.reviewerToken?{reviewerToken:e.reviewerToken}:{},...i?{claims:i}:{}};return U(n,"GetHelpIndex",r).then(d=>d.jobs??[])}function V(n,e,t){return n.flatMap(i=>{if(!i.jobId||!i.title)return[];const r=H(i,t)?.stepCount??i.stepCount;return[{type:"chip",jobId:i.jobId,title:i.title,label:i.title,badge:r?r===1?e("chip.one_step"):e("chip.steps",{n:r}):e("chip.no_guide"),...r?{steps:r}:{}}]})}function J(n,e,t={}){const i=te(n),r=n.claims!==void 0||n.getToken?import("./claims-VKhPNjA7.js").then(c=>c.claimsSource(n)):void 0,d=r&&(()=>r.then(c=>c.token()));d?.();const u=document.createElement("div");u.setAttribute("data-journeeze-chat","");const s=u.attachShadow({mode:"closed"}),z=document.createElement("style");z.textContent=ye,n.nonce&&(z.nonce=n.nonce),s.append(z),document.body.append(u);let k;const g=()=>k??(k=U(i,"GetWidgetConfig",{siteKey:n.siteKey}).catch(c=>{throw k=void 0,c})),P=(t.loadJobs??(()=>Ae(i,n,d)))().catch(()=>[]),F=new Map;let m,C;const E=c=>{m?.then(y=>{y&&!_&&c(y)})},M=c=>{C=c,c&&!m&&(m=import("./walk-BEGYyGG3.js").then(y=>y.createWalk({endpoint:i,siteKey:n.siteKey,reviewerToken:n.reviewerToken,claims:d,root:s,nonce:n.nonce,journeyFor:O=>F.get(O),loadGuide:t.loadGuide}),()=>{})),E(y=>y.walker.sync(C))};let S,_=false;const L=g().then(c=>c.copy,()=>{}).then(async c=>{if(_)return;const y=he(c),O=()=>n.reviewerToken||n.userId?void 0:null,j=new W({siteKey:n.siteKey,reviewer:!!n.reviewerToken,transport:t.transport??ce(i,n,void 0,d),t:y,facts:()=>N(n,e()),hasConsent:()=>ie(G(n),O()),giveConsent:()=>ne(G(n),O())}),q=a=>import("./attach-EfetX0Vi.js").then(l=>l.plusItem(a,{session:j,root:s,options:n,endpoint:i,claims:d,config:g,suspend:()=>D.suspend()}),()=>j.note(y("note.capture_unavailable"))),D=Ie(s,j,{reviewer:!!n.reviewerToken,onPlusItem:t.onPlusItem??(a=>{q(a)})});S={session:j,view:D};const $=await P,R=e().persona;for(const a of $){const l=a.jobId?H(a,R):void 0;l&&a.jobId&&F.set(a.jobId,l.journeyId)}j.subscribe(()=>M(j.guidePosition())),j.start(V($,y,R))});return{unmount(){_=true,m?.then(c=>c?.dispose()),r?.then(c=>c.stop()),S?.view.destroy(),u.remove()},report(){L.then(()=>{S?.view.open(),S?.session.reportProblem()})},contextChanged:()=>E(c=>c.walker.refresh()),addAttachment:c=>!!S?.session.addAttachment(c),removeAttachment:c=>S?.session.removeAttachment(c)}}const Ee=(n,e)=>J(n,()=>ae(e())),ze=Object.freeze(Object.defineProperty({__proto__:null,jobChips:V,mount:Ee,mountChat:J,pageFacts:N},Symbol.toStringTag,{value:"Module"}));export{xe as M,ze as c,K as u};
@@ -0,0 +1 @@
1
+ import{w as f}from"./loader-DHgG5Y7t.js";const g=/^[A-Za-z0-9_-]{1,4000}\.[A-Za-z0-9_-]{43}$/,E=4096,A=60,S=15e3;function _(e){return typeof e=="string"&&e.length<=E&&g.test(e)}function p(e){try{const t=(e.split(".")[0]??"").replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(t+"=".repeat((4-t.length%4)%4)))}catch{return{}}}const d=e=>typeof e=="number"&&Number.isInteger(e)?e:void 0;function M(e){return d(p(e).exp)}const l=new Map;function y(e,t=Date.now()){const i=p(e),r=d(i.exp),s=d(i.iat);if(r===void 0||s===void 0)return;let c=l.get(e);return c===void 0&&(l.size>=32&&l.clear(),l.set(e,c=t)),c+(r-s)*1e3}function a(e,t=0,i=Date.now()){if(!_(e))return;const r=y(e,i);return r!==void 0&&r-i>t*1e3?e:void 0}function N(e,t=Date.now){let i=false,r,s=-1/0;const c=async o=>{let n;s=t();try{n=await o()}catch{f("getToken failed")}if(!i)return a(n,0,t())?(e.claims=n,n):(n!==void 0&&f("invalid claims token ignored"),a(e.claims,0,t()))},m={token(){if(i)return Promise.resolve(void 0);const o=t(),n=a(e.claims,A,o);if(n)return Promise.resolve(n);const v=e.getToken,u=a(e.claims,0,o);return typeof v!="function"?(e.claims!==void 0&&!_(e.claims)&&f("invalid claims token ignored"),Promise.resolve(u)):!r&&u&&o-s<S?Promise.resolve(u):(r??(r=c(v).finally(()=>r=void 0)),r)},current(){if(!i)return m.token(),a(e.claims,0,t())},stop(){i=true}};return m}export{S as CLAIMS_MIN_REFRESH_INTERVAL_MS,A as CLAIMS_REFRESH_MARGIN_S,E as CLAIMS_TOKEN_MAX_LEN,g as CLAIMS_TOKEN_PATTERN,y as claimsEnd,M as claimsExp,N as claimsSource,a as usableClaims,_ as wellFormedClaims};
@@ -0,0 +1 @@
1
+ var v=Object.defineProperty;var w=(e,t,n)=>t in e?v(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var u=(e,t,n)=>w(e,typeof t!="symbol"?t+"":t,n);import{CONTEXT_FIELDS as S,CONTEXT_VALUE_MAX_LEN as T,CONTEXT_ID_PATTERN as E,API_PATH_PATTERN as N}from"./contract.js";import{w as c,p as _}from"./loader-DHgG5Y7t.js";class m extends Error{constructor(n,r,o=0,i){super(r);u(this,"code");u(this,"status");u(this,"retryAfterMs");this.code=n,this.status=o,this.retryAfterMs=i}}const I="https://app.journeeze.dev",b=15e3;function C(e,t=b){return typeof AbortSignal<"u"&&typeof AbortSignal.timeout=="function"?{...e,signal:AbortSignal.timeout(t)}:e}function $(e,t=location.href){try{return new URL(e,t).origin!==new URL(t).origin}catch{return true}}const k="text/plain;charset=UTF-8";function A(e,t){return`${e.replace(/\/+$/,"")}/journeeze.collector.v1.CollectorService/${t}`}function O(e,t){const n=$(e)?{"content-type":k}:{"content-type":"application/json","connect-protocol-version":"1"};return t?{...n,"if-none-match":t}:n}function y(e,t,n,r,o){const i=C({method:"POST",headers:O(e,o.etag),body:JSON.stringify(n),credentials:"omit",cache:"no-store",referrerPolicy:"no-referrer",...o.keepalive?{keepalive:true}:{}});return r(A(e,t),i)}const x=6e4;function j(e,t=Date.now()){if(!e)return;const n=Number(e.trim()),r=Number.isFinite(n)&&/^\d+$/.test(e.trim())?n*1e3:Date.parse(e)-t;return Number.isFinite(r)?Math.min(Math.max(r,0),x):void 0}async function g(e){const t=await e.json().catch(()=>{});if(!e.ok){const n=typeof t?.code=="string"?t.code:M(e.status);throw new m(n,String(t?.message??e.statusText),e.status,j(e.headers.get("retry-after")))}if(t===void 0||typeof t!="object"||t===null)throw new m("unavailable","the collector did not answer with Connect JSON",e.status);return t}async function D(e,t,n,r=fetch,o={}){return g(await y(e,t,n,r,o.keepalive?{keepalive:true}:{}))}async function F(e,t,n,r,o=fetch){const i=await y(e,t,n,o,r?{etag:r}:{});if(i.status===304)return{notModified:true};const s=await g(i),a=i.headers.get("etag");return a?{notModified:false,value:s,etag:a}:{notModified:false,value:s}}function H(e,t){return t?`${e.replace(/\/+$/,"")}${t.startsWith("/")?"":"/"}${t}`:void 0}function M(e){return e===401?"unauthenticated":e===403?"permission_denied":e===409?"already_exists":e===412?"failed_precondition":e===429?"resource_exhausted":e===404||e===408||e>=500?"unavailable":e>=400?"invalid_argument":"unknown"}function X(e,t=location.href){const{endpoint:n,apiHost:r,apiPath:o}=e;if(n!==void 0)return c("endpoint is deprecated; use apiHost"),new URL(n,t).href.replace(/\/+$/,"");let i=I;if(r!==void 0){const s=r.replace(/\/$/,"");let a=false;try{const f=new URL(s);a=f.origin===s&&(f.protocol==="https:"||/^(localhost|127\.0\.0\.1)$/.test(f.hostname))}catch{}a?i=s:c("invalid apiHost ignored")}return o===void 0?i:N.test(o)?i+o:(c("invalid apiPath ignored"),i)}function z(e){const t={};for(const n of S){if(!(n in e))continue;const r=e[n]||void 0;if(r!==void 0&&(typeof r!="string"||r.length>T||/[\0-\x1f\x7f]/.test(r))){c(`context.${n} dropped (1..=128 printable characters)`),t[n]=void 0;continue}r!==void 0&&!E.test(r)&&c(`context.${n} should be an id`),t[n]=r}return t}const P=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$|[0-9a-f]{16}|@|^[\w-]{24,}$/i;function J(e){return _(e).split("/").map(t=>{let n=t;try{n=decodeURIComponent(t)}catch{}return P.test(n)?":id":t}).join("/")}function Y(e){const t=e.signature===void 0?e.userIdSig:e.signature?e.signature.sig:void 0,n=e.signature===void 0?e.userIdExp:e.signature?e.signature.exp:void 0;return typeof t!="string"||!/^[A-Za-z0-9_-]{43}$/.test(t)?{}:typeof n!="number"||!Number.isInteger(n)||n*1e3<=Date.now()?{}:{userIdSig:t,userIdExp:n}}const d=1,q="Feedback mode captures the element you point at, a screenshot of this page with form fields hidden, your comment, and your persona and journey step. It never records keystrokes, form contents or query strings. Your feedback is visible to the project's review team.",V="Feedback mode captures the element you point at, your comment, and your persona and journey step. No screenshot is sent. It never records keystrokes, form contents or query strings. Your feedback is visible to the project's review team.",l=e=>`jz:consent:v${d}:${e}`,p=new Set,B=e=>e.userId?`${e.siteKey}:u:${e.userId}`:e.siteKey;function G(e,t=h()){p.delete(e);try{t?.removeItem(l(e))}catch{}}function h(){try{return window.localStorage}catch{return}}function K(e,t=h()){if(p.has(e))return true;try{const n=t?.getItem(l(e));return n?JSON.parse(n).v===d:false}catch{return false}}function W(e,t=h()){p.add(e);try{t?.setItem(l(e),JSON.stringify({v:d,at:new Date().toISOString()}))}catch{}}export{m as C,q as D,x as R,k as T,h as a,G as b,D as c,X as d,F as e,z as f,B as g,K as h,V as i,W as j,Y as k,H as l,A as r,J as s,C as w};
package/dist/contract.js CHANGED
@@ -1,4 +1,4 @@
1
- import { S as t, U as A } from "./loader-BZiIDD1D.js";
1
+ import { S as t, U as A } from "./loader-DHgG5Y7t.js";
2
2
  const T = /^(?:\/[A-Za-z0-9._~-]+)+$/, _ = 128, E = /^[a-z0-9._:-]{1,96}$/, e = ["persona", "journeyId", "journeyStep", "device", "businessType", "state"];
3
3
  export {
4
4
  T as API_PATH_PATTERN,
@@ -0,0 +1 @@
1
+ var I=Object.defineProperty;var _=(s,e,t)=>e in s?I(s,e,{enumerable:true,configurable:true,writable:true,value:t}):s[e]=t;var h=(s,e,t)=>_(s,typeof e!="symbol"?e+"":e,t);import{C as w,a as v,c as f,b as q,d as x}from"./consent-bPengyOI.js";import{usableClaims as y}from"./claims-VKhPNjA7.js";const A=new Set(["invalid_argument","failed_precondition","permission_denied","unauthenticated","not_found","already_exists","unimplemented"]),g=50,O=1e3,T=6e4,b=1440*60*1e3;function L(s){return Math.min(T,O*2**Math.max(0,s))}function M(s){return s instanceof w&&A.has(s.code)}class D{constructor(e){h(this,"deps");h(this,"items",[]);h(this,"inFlight");h(this,"attempt",0);h(this,"flushing");h(this,"timer");h(this,"disposed",false);h(this,"schedule");h(this,"cancel");h(this,"now");this.deps=e,this.schedule=e.schedule??((t,i)=>setTimeout(t,i)),this.cancel=e.cancel??(t=>clearTimeout(t)),this.now=e.now??Date.now,this.claim()}get size(){return this.items.length}enqueue(e){return new Promise(t=>{const i={request:e,settle:t};this.add(i),this.flush().then(()=>{this.items.includes(i)&&u(i,"queued")})})}stash(e){this.add({request:e})}flush(){return this.disposed?Promise.resolve():(this.timer!==void 0&&(this.cancel(this.timer),this.timer=void 0),this.flushing?this.flushing.then(()=>this.timer===void 0?this.flush():void 0):(this.flushing=this.drain().finally(()=>{this.flushing=void 0}),this.flushing))}persist(){const e=this.items.filter(t=>t!==this.inFlight);if(!(e.length===0||!this.deps.storage))try{const t=this.read(),i=this.now(),n=this.deps.user?.(),a=[...t,...e.map(r=>({owner:this.deps.owner,request:r.request,at:r.at??i,...n?{user:n}:{}}))].slice(-g);this.deps.storage?.setItem(this.deps.storageKey,JSON.stringify(a));for(const r of e)u(r,"queued");this.items=this.items.filter(r=>r===this.inFlight)}catch{}}claim(){try{const e=this.read(),t=e.filter(n=>n.owner===this.deps.owner);if(t.length===0)return;const i=e.filter(n=>n.owner!==this.deps.owner);i.length===0?this.deps.storage?.removeItem(this.deps.storageKey):this.deps.storage?.setItem(this.deps.storageKey,JSON.stringify(i));for(const n of t)this.fresh(n)&&this.add({request:n.request,at:n.at})}catch{}}dispose(){this.persist(),this.disposed=true,this.timer!==void 0&&this.cancel(this.timer),this.timer=void 0}add(e){var t;for((t=e.request).submissionId??(t.submissionId=P()),this.items.push(e);this.items.length>g;){const i=this.items[0]===this.inFlight?1:0,[n]=this.items.splice(i,1);n&&u(n,"dropped")}}async drain(){for(;!this.disposed;){const e=this.items[0];if(!e){this.attempt=0;return}this.inFlight=e;try{await this.deps.send(e.request),this.remove(e),this.attempt=0,u(e,"sent")}catch(t){if(M(t)){this.remove(e),u(e,"dropped"),this.deps.onDropped?.(t);continue}if(this.disposed){this.inFlight=void 0,this.persist();return}const i=L(this.attempt++);this.timer=this.schedule(()=>{this.timer=void 0,this.flush()},i);return}finally{this.inFlight=void 0}}}fresh(e){return e.at===void 0?true:typeof e.at=="number"&&Number.isFinite(e.at)&&this.now()-e.at<=b}remove(e){const t=this.items.indexOf(e);t>=0&&this.items.splice(t,1)}read(){const e=this.deps.storage?.getItem(this.deps.storageKey),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(i=>typeof i=="object"&&i!==null&&typeof i.owner=="string"&&typeof i.request=="object"&&i.request!==null):[]}}function F(s){if(!s)return"";let e=2166136261;for(let t=0;t<s.length;t++)e^=s.charCodeAt(t),e=Math.imul(e,16777619)>>>0;return e.toString(16).padStart(8,"0")}function P(){return crypto.randomUUID()}function u(s,e){const t=s.settle;s.settle=void 0,t?.(e)}function C(s,e,t,i=Date.now()){try{const n=s?.getItem(e),a=n?JSON.parse(n):[],r=Array.isArray(a)?a:[],c=r.filter(o=>o?.owner===t),d=r.filter(o=>o?.owner!==t);return d.length===0?s?.removeItem(e):s?.setItem(e,JSON.stringify(d)),c.filter(o=>o.request&&(o.at===void 0||i-o.at<=b)).sort((o,l)=>(o.at??0)-(l.at??0)).map(o=>o.request)}catch{return[]}}const S=s=>F(s.reviewerToken||(s.userId?`u:${s.userId}`:void 0)),N=32*1024;async function z(s){const e=C(v(),`jz:outbox:v2:${s.siteKey}`,S(s));if(q(s.siteKey),e.length===0)return;const t=x(s);let i=N;const n=(c,d)=>f(t,"SubmitFeedback",c,fetch,{keepalive:d}),r=(await Promise.allSettled(e.map(c=>{const d=E(s,c,y(s.claims)),o=new Blob([JSON.stringify(d)]).size,l=o<=i;l&&(i-=o);const m=n(d,l);return l?m.catch(p=>p instanceof w?Promise.reject(p):n(d,false)):m}))).filter(c=>c.status==="rejected").length;r&&console.warn(`[journeeze] ${r} feedback item(s) could not be sent at logout and were discarded`)}function E(s,e,t){const i=s.reviewerToken?{...e,reviewerToken:s.reviewerToken}:{...e};if(t&&(i.claims=t),s.pagePath==="none"){const{pagePath:n,...a}=i.context;i.context=a}return i}function J(s,e,t={}){const i=d=>(t.claims?.(),f(e,"SubmitFeedback",E(s,d,y(s.claims)),fetch,{keepalive:true}).then(()=>{})),n=new D({send:i,storage:t.memoryOnly?void 0:v(),storageKey:`jz:outbox:v2:${s.siteKey}`,owner:S(s),user:()=>s.userId,...t.onDropped?{onDropped:t.onDropped}:{}}),a=()=>{n.flush()},r=()=>{t.beforePersist?.(),n.persist()},c=d=>{d.persisted&&(n.claim(),n.flush())};return window.addEventListener("online",a),window.addEventListener("pagehide",r),window.addEventListener("pageshow",c),{outbox:n,dispose(){window.removeEventListener("online",a),window.removeEventListener("pagehide",r),window.removeEventListener("pageshow",c),n.dispose()}}}function B(s,e){return f(s,"GetWidgetConfig",{siteKey:e})}export{J as feedbackChannel,z as logout,S as ownerOf,B as widgetConfig};