@journeeze/sdk 0.1.0-rc.2 → 0.1.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +16 -3
- package/CHANGELOG.md +12 -1
- package/README.md +298 -119
- package/dist/anchor-cPvFFTOS.js +1 -0
- package/dist/attach-DpioALxW.js +21 -0
- package/dist/chat-BgmB0rnW.js +64 -0
- package/dist/consent-DckCUvYR.js +1 -0
- package/dist/contract.js +1 -1
- package/dist/feedback-CtH1a_kQ.js +1 -0
- package/dist/help-w0O5Qu-4.js +105 -0
- package/dist/hook-DGWypoEO.js +1 -0
- package/dist/index-B_nob8S0.js +1 -2091
- package/dist/{index-CfCbJJXa.js → index-CwG2LrhO.js} +3 -3
- package/dist/index.js +3 -3
- package/dist/jobs-CAXbM5-g.js +45 -0
- package/dist/loader-BZiIDD1D.js +96 -0
- package/dist/mask-audit-Du3NPoG_.js +5 -0
- package/dist/react.js +12 -11
- package/dist/resolve-BfWByuTp.js +1 -97
- package/dist/script.js +10 -9
- package/dist/signals-amjMQyOy.js +1 -0
- package/dist/telemetry-CyRJDaVs.js +1 -0
- package/dist/transport-B64CfIcF.js +1 -0
- package/dist/types/chat/capture/attach.d.ts +41 -0
- package/dist/types/chat/capture/draw.d.ts +10 -0
- package/dist/types/chat/capture/geometry.d.ts +30 -0
- package/dist/types/chat/capture/styles.d.ts +1 -0
- package/dist/types/chat/shell/chat.d.ts +27 -0
- package/dist/types/chat/shell/converse.d.ts +95 -0
- package/dist/types/chat/shell/copy.d.ts +8 -0
- package/dist/types/chat/shell/model.d.ts +36 -0
- package/dist/types/chat/shell/session.d.ts +148 -0
- package/dist/types/chat/shell/styles.d.ts +1 -0
- package/dist/types/chat/shell/view.d.ts +18 -0
- package/dist/types/chat/transport.d.ts +5 -0
- package/dist/types/config.d.ts +17 -0
- package/dist/types/help/core/controller.d.ts +12 -3
- package/dist/types/help/core/events.d.ts +24 -0
- package/dist/types/help/core/help.d.ts +1 -0
- package/dist/types/help/core/panel.d.ts +16 -0
- package/dist/types/help/core/routing.d.ts +21 -0
- package/dist/types/help/ui/jobs/jobs.d.ts +24 -0
- package/dist/types/help/ui/jobs/model.d.ts +33 -0
- package/dist/types/help/ui/jobs/styles.d.ts +1 -0
- package/dist/types/loader.d.ts +2 -0
- package/dist/types/mask-detector.d.ts +22 -0
- package/dist/types/preview/flag.d.ts +2 -0
- package/dist/types/preview/mask-audit.d.ts +29 -0
- package/dist/types/schemas/feedback.d.ts +76 -0
- package/dist/types/schemas/finding.d.ts +22 -0
- package/dist/types/schemas/index.d.ts +6 -0
- package/dist/types/schemas/turn.d.ts +26 -0
- package/dist/types/signals/signals.d.ts +7 -3
- package/dist/types/signals/steps.d.ts +33 -0
- package/dist/types/telemetry/telemetry.d.ts +10 -0
- package/dist/types/types.d.ts +72 -1
- package/dist/types/widget/capture.d.ts +12 -1
- package/dist/types/widget/upload.d.ts +14 -0
- package/dist/types/widget.d.ts +1 -21
- package/dist/upload-Fu2qvSJV.js +14 -0
- package/dist/widget-B6mR1J3P.js +118 -0
- package/package.json +4 -2
- package/dist/consent-CoKD33Rm.js +0 -170
- package/dist/feedback-C4CYtS2A.js +0 -196
- package/dist/help-C1x-y2f9.js +0 -878
- package/dist/hook-BdG4UL4k.js +0 -91
- package/dist/loader-Ba4X-WNl.js +0 -95
- package/dist/signals-E3VEdmWH.js +0 -477
- package/dist/telemetry-Cik-cYzw.js +0 -140
- package/dist/transport-B5YJFQEF.js +0 -60
- package/dist/types/signals/signals.conformance.d.ts +0 -2
- package/dist/widget-DQZm8sAC.js +0 -1599
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** Wire id of the `journeeze.feedback/v2` schema. */
|
|
2
|
+
export declare const FEEDBACK_SCHEMA_ID = "journeeze.feedback/v2";
|
|
3
|
+
/** `kind` — why the feedback was filed. */
|
|
4
|
+
export type FeedbackKind = "problem" | "unmet_need" | "suggestion" | "praise";
|
|
5
|
+
/** `reaction` — a one-tap mood on the reply that prompted the feedback. */
|
|
6
|
+
export type FeedbackReaction = "like" | "dislike" | "understood" | "confused";
|
|
7
|
+
/** `context.device`. */
|
|
8
|
+
export type FeedbackDevice = "desktop" | "tablet" | "mobile";
|
|
9
|
+
/** `context.removed[]` — context chips the user removed before sending. */
|
|
10
|
+
export type FeedbackRemovedChip = "page" | "persona" | "browser" | "device" | "viewport" | "build";
|
|
11
|
+
/** `team.verdict` — reviewer-only. */
|
|
12
|
+
export type FeedbackVerdict = "unreviewed" | "polished" | "needs_polish" | "broken";
|
|
13
|
+
/** `team.severity` — reviewer-only. */
|
|
14
|
+
export type FeedbackSeverity = "low" | "medium" | "high" | "critical";
|
|
15
|
+
/** `attachments[].shapes[].type`. */
|
|
16
|
+
export type FeedbackShapeType = "box" | "circle" | "arrow";
|
|
17
|
+
/** `job` — the journey job the feedback is about. */
|
|
18
|
+
export interface FeedbackJob {
|
|
19
|
+
jobId: string;
|
|
20
|
+
stepReached?: number;
|
|
21
|
+
}
|
|
22
|
+
/** `unmetNeed` — what the user could not do with the product. */
|
|
23
|
+
export interface FeedbackUnmetNeed {
|
|
24
|
+
need: string;
|
|
25
|
+
soYouCan?: string;
|
|
26
|
+
typedQuery?: string;
|
|
27
|
+
}
|
|
28
|
+
/** `context.viewport` — both sides optional. */
|
|
29
|
+
export interface FeedbackViewport {
|
|
30
|
+
w?: number;
|
|
31
|
+
h?: number;
|
|
32
|
+
}
|
|
33
|
+
/** `attachments[].shapes[]` — a normalised annotation over the screenshot. */
|
|
34
|
+
export interface FeedbackShape {
|
|
35
|
+
type: FeedbackShapeType;
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
w: number;
|
|
39
|
+
h: number;
|
|
40
|
+
}
|
|
41
|
+
/** `attachments[]` — one masked screenshot upload. */
|
|
42
|
+
export interface FeedbackAttachment {
|
|
43
|
+
screenshotId: string;
|
|
44
|
+
shapes?: FeedbackShape[];
|
|
45
|
+
}
|
|
46
|
+
/** One message in a feedback payload (also `$defs.message` reused by `journeeze.turn/v1`). */
|
|
47
|
+
export interface FeedbackMessage {
|
|
48
|
+
text?: string;
|
|
49
|
+
anchor?: string;
|
|
50
|
+
attachments?: FeedbackAttachment[];
|
|
51
|
+
}
|
|
52
|
+
/** `context` — the closed context allowlist. */
|
|
53
|
+
export interface FeedbackContext {
|
|
54
|
+
pagePath: string;
|
|
55
|
+
persona?: string;
|
|
56
|
+
browser?: string;
|
|
57
|
+
device?: FeedbackDevice;
|
|
58
|
+
viewport?: FeedbackViewport;
|
|
59
|
+
build?: string;
|
|
60
|
+
removed?: FeedbackRemovedChip[];
|
|
61
|
+
}
|
|
62
|
+
/** `team` — reviewer-only fields. */
|
|
63
|
+
export interface FeedbackTeam {
|
|
64
|
+
verdict?: FeedbackVerdict;
|
|
65
|
+
severity?: FeedbackSeverity;
|
|
66
|
+
}
|
|
67
|
+
/** A `journeeze.feedback/v2` payload. */
|
|
68
|
+
export interface Feedback {
|
|
69
|
+
kind: FeedbackKind;
|
|
70
|
+
job?: FeedbackJob;
|
|
71
|
+
unmetNeed?: FeedbackUnmetNeed;
|
|
72
|
+
reaction?: FeedbackReaction;
|
|
73
|
+
messages: FeedbackMessage[];
|
|
74
|
+
context: FeedbackContext;
|
|
75
|
+
team?: FeedbackTeam;
|
|
76
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Wire id of the `journeeze.finding/v1` schema. */
|
|
2
|
+
export declare const FINDING_SCHEMA_ID = "journeeze.finding/v1";
|
|
3
|
+
/** `rule` — which secret-detector rule matched. */
|
|
4
|
+
export type FindingRule = "autocomplete_cc" | "autocomplete_otp" | "autocomplete_password" | "input_password" | "label_sensitive" | "name_sensitive" | "value_key_shaped" | "value_card_shaped" | "value_email_shaped";
|
|
5
|
+
/** Fields shared by both branches of the `oneOf`. */
|
|
6
|
+
export interface FindingBase {
|
|
7
|
+
pagePath: string;
|
|
8
|
+
rule: FindingRule;
|
|
9
|
+
detectedAt: string;
|
|
10
|
+
}
|
|
11
|
+
/** Branch for a flagged element that has a tflo id. */
|
|
12
|
+
export interface FindingWithAnchor extends FindingBase {
|
|
13
|
+
anchor: string;
|
|
14
|
+
selector?: never;
|
|
15
|
+
}
|
|
16
|
+
/** Branch for a flagged element addressed by CSS selector. */
|
|
17
|
+
export interface FindingWithSelector extends FindingBase {
|
|
18
|
+
selector: string;
|
|
19
|
+
anchor?: never;
|
|
20
|
+
}
|
|
21
|
+
/** A `journeeze.finding/v1` payload: exactly one of `anchor` or `selector`. */
|
|
22
|
+
export type Finding = FindingWithAnchor | FindingWithSelector;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { FEEDBACK_SCHEMA_ID } from "./feedback";
|
|
2
|
+
export type { Feedback, FeedbackAttachment, FeedbackContext, FeedbackDevice, FeedbackJob, FeedbackKind, FeedbackMessage, FeedbackReaction, FeedbackRemovedChip, FeedbackSeverity, FeedbackShape, FeedbackShapeType, FeedbackTeam, FeedbackUnmetNeed, FeedbackViewport, FeedbackVerdict, } from "./feedback";
|
|
3
|
+
export { TURN_SCHEMA_ID } from "./turn";
|
|
4
|
+
export type { Turn, TurnAction, TurnActionInput, TurnInput, TurnTextInput } from "./turn";
|
|
5
|
+
export { FINDING_SCHEMA_ID } from "./finding";
|
|
6
|
+
export type { Finding, FindingBase, FindingRule, FindingWithAnchor, FindingWithSelector } from "./finding";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { FeedbackMessage, FeedbackTeam } from "./feedback";
|
|
2
|
+
/** Wire id of the `journeeze.turn/v1` schema. */
|
|
3
|
+
export declare const TURN_SCHEMA_ID = "journeeze.turn/v1";
|
|
4
|
+
/** `input.action` — the stable chat intents (ADR 0018). */
|
|
5
|
+
export type TurnAction = "pick_job" | "other_need" | "guide_next" | "guide_back" | "didnt_work" | "report_problem" | "send" | "cancel" | "affirm" | "deny" | "talk_to_assistant";
|
|
6
|
+
/** `input` branch where the user typed text. */
|
|
7
|
+
export interface TurnTextInput {
|
|
8
|
+
kind: "text";
|
|
9
|
+
text: string;
|
|
10
|
+
}
|
|
11
|
+
/** `input` branch where the user chose an action. */
|
|
12
|
+
export interface TurnActionInput {
|
|
13
|
+
kind: "action";
|
|
14
|
+
action: TurnAction;
|
|
15
|
+
jobId?: string;
|
|
16
|
+
step?: number;
|
|
17
|
+
}
|
|
18
|
+
/** `input` — the `oneOf` text|action as a discriminated union on `kind`. */
|
|
19
|
+
export type TurnInput = TurnTextInput | TurnActionInput;
|
|
20
|
+
/** A `journeeze.turn/v1` payload. */
|
|
21
|
+
export interface Turn {
|
|
22
|
+
input: TurnInput;
|
|
23
|
+
draft?: FeedbackMessage;
|
|
24
|
+
/** Reviewer-only (verdict, severity); the collector rejects it from non-reviewer sessions. */
|
|
25
|
+
team?: FeedbackTeam;
|
|
26
|
+
}
|
|
@@ -15,7 +15,8 @@ export interface SignalEnvelope {
|
|
|
15
15
|
seq: number;
|
|
16
16
|
name: string;
|
|
17
17
|
source: "SIGNAL_SOURCE_PLATFORM" | "SIGNAL_SOURCE_SITE";
|
|
18
|
-
context
|
|
18
|
+
/** The host's context ids, plus its release id (`appVersion`, ADR 0014 addendum) when set. */
|
|
19
|
+
context: Partial<Record<(typeof CONTEXT_FIELDS)[number] | "appVersion", string>>;
|
|
19
20
|
target?: string;
|
|
20
21
|
params?: Record<string, ParamValue>;
|
|
21
22
|
}
|
|
@@ -27,8 +28,11 @@ export interface RecordSignalsRequest {
|
|
|
27
28
|
/** Signals that didn't fit the page-end send and were dropped (C0d §6, field 5). */
|
|
28
29
|
droppedAtUnload?: number;
|
|
29
30
|
}
|
|
30
|
-
/**
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The platform rule set this chunk runs (C0d §4.1). Thresholds are part of the version.
|
|
33
|
+
* `jz-platform@2` adds `step_completed` (ADR 0014 addendum); the collector still accepts `@1`.
|
|
34
|
+
*/
|
|
35
|
+
export declare const RULE_SET = "jz-platform@2";
|
|
32
36
|
export declare const RAGE_WINDOW_MS = 700;
|
|
33
37
|
export declare const RAGE_CLICKS = 3;
|
|
34
38
|
export declare const HESITATION_MS = 3000;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** The platform rule's name. */
|
|
2
|
+
export declare const STEP_COMPLETED = "step_completed";
|
|
3
|
+
/** The closed duration buckets, fastest first (proto `StepDurationBucket`). */
|
|
4
|
+
export declare const DURATION_BUCKETS: readonly ["lt5s", "lt15s", "lt60s", "lt5m", "ge5m"];
|
|
5
|
+
export type DurationBucket = (typeof DURATION_BUCKETS)[number];
|
|
6
|
+
/** The bucket a measured duration falls in. */
|
|
7
|
+
export declare function durationBucket(ms: number): DurationBucket;
|
|
8
|
+
/** `step_completed`'s params: ids and a bucket, nothing else. */
|
|
9
|
+
export interface StepCompleted {
|
|
10
|
+
journey: string;
|
|
11
|
+
step: string;
|
|
12
|
+
duration_bucket: DurationBucket;
|
|
13
|
+
}
|
|
14
|
+
/** Where the page is in a published journey's checkpoints (as matched by `matchCheckpoint`). */
|
|
15
|
+
export interface ReachedAnchor {
|
|
16
|
+
journey: string;
|
|
17
|
+
/** 0-based checkpoint position. */
|
|
18
|
+
index: number;
|
|
19
|
+
/** The anchor's name: the checkpoint's step id. */
|
|
20
|
+
step: string;
|
|
21
|
+
}
|
|
22
|
+
export interface StepTimer {
|
|
23
|
+
/**
|
|
24
|
+
* Called on every context sync with the journey the host is in and the anchor matched (if any).
|
|
25
|
+
* Returns the params of the completion to send, once per anchor going forward.
|
|
26
|
+
*/
|
|
27
|
+
sync(journeyId: string | undefined, at: ReachedAnchor | undefined): StepCompleted | undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* One handle's step clock. It outlives tflo instances (a back/forward-cache restore re-arms the
|
|
31
|
+
* checkpoints but does not complete the current anchor twice); a journey change restarts it.
|
|
32
|
+
*/
|
|
33
|
+
export declare function stepTimer(now: () => number): StepTimer;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CheckinRequest, HelpState } from "../help/core/controller";
|
|
2
|
+
import type { JobEvent } from "../help/core/events";
|
|
2
3
|
/** One event of the closed plan, as the collector's `HelpEngagementEvent` (Connect JSON names). */
|
|
3
4
|
export interface WireHelpEvent {
|
|
4
5
|
event: string;
|
|
@@ -11,6 +12,13 @@ export interface WireHelpEvent {
|
|
|
11
12
|
eventId?: string;
|
|
12
13
|
/** C0b §7: 1, 2, 3… within this page load; never stored, never linked across loads. */
|
|
13
14
|
seq?: number;
|
|
15
|
+
/** Job events only (P4e1): the job, the entry version seen, the "Got it done?" answer. */
|
|
16
|
+
jobId?: string;
|
|
17
|
+
jobVersion?: string;
|
|
18
|
+
jobAnswer?: string;
|
|
19
|
+
harderThanExpected?: boolean;
|
|
20
|
+
/** Job events only (engagement.proto field 13): the host's `persona` context id. */
|
|
21
|
+
persona?: string;
|
|
14
22
|
}
|
|
15
23
|
export interface RecordHelpEventsRequest {
|
|
16
24
|
siteKey: string;
|
|
@@ -43,6 +51,8 @@ export declare function gpcRefusesTelemetry(opts: Pick<TelemetryOptions, "respec
|
|
|
43
51
|
export interface Telemetry {
|
|
44
52
|
/** A check-in answer the reader sent (help calls this after consent). */
|
|
45
53
|
checkin(req: CheckinRequest): void;
|
|
54
|
+
/** A job event the reader caused (help calls this only after consent; never with text). */
|
|
55
|
+
job(e: JobEvent): void;
|
|
46
56
|
/**
|
|
47
57
|
* Sends what is queued (page-end transport) and stops; nothing is sent afterwards. With
|
|
48
58
|
* `discard` (a logout, `reset()`) the queue is dropped instead: nothing more about this reader
|
package/dist/types/types.d.ts
CHANGED
|
@@ -124,6 +124,12 @@ export interface JourneezeSignalsConfigV1 {
|
|
|
124
124
|
rules?: readonly JourneezeSiteRule[];
|
|
125
125
|
/** The host's own tflo module, or a lazy loader for it (`() => import("tflo-browser-events")`). */
|
|
126
126
|
tflo?: JourneezeTfloModule | (() => Promise<JourneezeTfloModule>);
|
|
127
|
+
/**
|
|
128
|
+
* The host's release id, e.g. `2026.10.1` (`^[a-z0-9._:-]{1,96}$`), sent as the signals'
|
|
129
|
+
* `appVersion` context id so a release can be compared before and after (ADR 0014 addendum). It
|
|
130
|
+
* never identifies a user. Anything else is ignored.
|
|
131
|
+
*/
|
|
132
|
+
appVersion?: string;
|
|
127
133
|
}
|
|
128
134
|
/** SDK configuration, contract v1: today's options plus the v1 fields, all optional. */
|
|
129
135
|
export interface JourneezeConfigV1 extends Omit<JourneezeOptions, "endpoint">, JourneezeTransportConfig, JourneezeMaskingConfig {
|
|
@@ -166,6 +172,12 @@ export interface JourneezeConfigV1 extends Omit<JourneezeOptions, "endpoint">, J
|
|
|
166
172
|
pagePath?: JourneezePagePathMode;
|
|
167
173
|
/** Signals (signals-v1.md §3.2): derived, aggregate-only signals; off unless `enabled`. */
|
|
168
174
|
signals?: JourneezeSignalsConfigV1;
|
|
175
|
+
/**
|
|
176
|
+
* SDK 2.x help chat (direct-mode contract v2): `enableHelp()` shows one "?" launcher that opens
|
|
177
|
+
* a conversation (jobs, guides, "Report a problem") instead of the v1 help panel, and
|
|
178
|
+
* {@link JourneezeHandleV1.feedback} opens it at "Report a problem". Default `false`.
|
|
179
|
+
*/
|
|
180
|
+
chat?: boolean;
|
|
169
181
|
}
|
|
170
182
|
/**
|
|
171
183
|
* The host's signature over a user id (contract §4, v1.3). Passing it again for the same id
|
|
@@ -179,6 +191,11 @@ export interface JourneezeUserIdSignature {
|
|
|
179
191
|
}
|
|
180
192
|
/** The handle, contract v1: today's handle plus identity and logout. */
|
|
181
193
|
export interface JourneezeHandleV1 extends JourneezeHandle {
|
|
194
|
+
/**
|
|
195
|
+
* Report a problem. With `chat: true` it opens the help chat at "Report a problem" (loading the
|
|
196
|
+
* chat chunk); otherwise it switches feedback mode on, like {@link enable}. Rejects, never throws.
|
|
197
|
+
*/
|
|
198
|
+
feedback(): Promise<void>;
|
|
182
199
|
/**
|
|
183
200
|
* Set (or, with `undefined`, clear) the signed-in user's opaque id ({@link USER_ID_PATTERN}).
|
|
184
201
|
* Applies to feedback created from now on. Switching user is a logout, enforced here: a
|
|
@@ -268,6 +285,16 @@ export interface SubmitFeedbackRequest {
|
|
|
268
285
|
userIdExp?: number;
|
|
269
286
|
/** Signed host identity (C0a §4 v1.3, collector.proto `user_id_sig = 13`). */
|
|
270
287
|
userIdSig?: string;
|
|
288
|
+
/**
|
|
289
|
+
* With kind REQUEST from help's "Something else" (collector.proto `job_request = 14`, P4e1):
|
|
290
|
+
* the optional "so you can…" answer and the job it follows ("Not possible here").
|
|
291
|
+
*/
|
|
292
|
+
jobRequest?: WireJobRequest;
|
|
293
|
+
}
|
|
294
|
+
/** `JobRequest` (engagement.proto): never telemetry, only ever inside a consented request. */
|
|
295
|
+
export interface WireJobRequest {
|
|
296
|
+
soYouCan?: string;
|
|
297
|
+
jobId?: string;
|
|
271
298
|
}
|
|
272
299
|
export interface SubmitFeedbackResponse {
|
|
273
300
|
feedbackId?: string;
|
|
@@ -296,6 +323,12 @@ export interface GetWidgetConfigResponse {
|
|
|
296
323
|
}[];
|
|
297
324
|
/** The site's signals switch (signals-v1.md §4.4): when not true no signals chunk loads. */
|
|
298
325
|
signalsEnabled?: boolean;
|
|
326
|
+
/** The project's journey-configuration mask selectors (ADR 0019 §3): masked on every capture, on top of `maskSelectors`. Widen only. */
|
|
327
|
+
maskSelectors?: string[];
|
|
328
|
+
/** The site's widget chrome copy (ADR 0020 §5): every `widget.ui.*` entry by its FULL key
|
|
329
|
+
* (e.g. `"widget.ui.launcher"` → `"Help"`), resolved for the site; templates keep their
|
|
330
|
+
* `{name}` placeholders for the widget to fill. */
|
|
331
|
+
copy?: Record<string, string>;
|
|
299
332
|
}
|
|
300
333
|
/** `CreateScreenshotUpload` (collector.proto): reserve a masked PNG/WebP upload, at most 2 MiB. */
|
|
301
334
|
export interface CreateScreenshotUploadRequest {
|
|
@@ -327,10 +360,48 @@ export interface HelpIndexEntry {
|
|
|
327
360
|
/** Changes whenever the guide changes. */
|
|
328
361
|
version?: string;
|
|
329
362
|
}
|
|
363
|
+
/** A job's published guide for one persona (`PersonaGuide`, engagement.proto). */
|
|
364
|
+
export interface HelpPersonaGuide {
|
|
365
|
+
persona?: string;
|
|
366
|
+
journeyId?: string;
|
|
367
|
+
stepCount?: number;
|
|
368
|
+
}
|
|
369
|
+
/** One job of "What are you trying to do?" (`HelpJobEntry`, engagement.proto; P4e1). */
|
|
370
|
+
export interface HelpJobEntry {
|
|
371
|
+
jobId?: string;
|
|
372
|
+
/** The job in the user's words. */
|
|
373
|
+
title?: string;
|
|
374
|
+
/** The guide that answers it for any persona; absent: no published guide yet. */
|
|
375
|
+
journeyId?: string;
|
|
376
|
+
stepCount?: number;
|
|
377
|
+
/** Persona ids the job is common for ("Common for you"). */
|
|
378
|
+
commonFor?: string[];
|
|
379
|
+
/** Echoed by job events as `jobVersion`. */
|
|
380
|
+
version?: string;
|
|
381
|
+
personaGuides?: HelpPersonaGuide[];
|
|
382
|
+
}
|
|
330
383
|
export interface GetHelpIndexResponse {
|
|
331
384
|
guides?: HelpIndexEntry[];
|
|
332
|
-
/** Changes whenever any guide changes (also the ETag). */
|
|
385
|
+
/** Changes whenever any guide or job changes (also the ETag). */
|
|
333
386
|
version?: string;
|
|
387
|
+
/** The project's approved jobs, in catalog order (P4e1). */
|
|
388
|
+
jobs?: HelpJobEntry[];
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* `RouteIntent` (collector.proto, P6d): the reader's words in help's "Something else", matched to
|
|
392
|
+
* one of the site's jobs. Sent only after consent; the collector does not store the words.
|
|
393
|
+
*/
|
|
394
|
+
export interface RouteIntentRequest {
|
|
395
|
+
siteKey: string;
|
|
396
|
+
consentGiven: true;
|
|
397
|
+
/** Trimmed, 1..=500 characters. */
|
|
398
|
+
text: string;
|
|
399
|
+
reviewerToken?: string;
|
|
400
|
+
}
|
|
401
|
+
/** A routed job and its guide for any persona, or empty fields: nothing routed. Never text. */
|
|
402
|
+
export interface RouteIntentResponse {
|
|
403
|
+
jobId?: string;
|
|
404
|
+
journeyId?: string;
|
|
334
405
|
}
|
|
335
406
|
/** `GetGuide` (collector.proto): one published guide with short-lived same-origin asset links. */
|
|
336
407
|
export interface GetGuideRequest {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { type DetectorCounts } from "../mask-detector";
|
|
1
2
|
/** Screenshot masking options (contract §6): they can only widen masking, never narrow it. */
|
|
2
3
|
export interface MaskOptions {
|
|
3
4
|
/** Extra selectors replaced by a placeholder, exactly like form fields. Invalid entries warn once. */
|
|
4
5
|
maskSelectors?: readonly string[];
|
|
6
|
+
/** The project's journey-configuration selectors (site config): masked like `maskSelectors`. */
|
|
7
|
+
configMaskSelectors?: readonly string[];
|
|
5
8
|
/** Replace every text run with a same-size box. Default `false`. */
|
|
6
9
|
maskAllText?: boolean;
|
|
7
10
|
}
|
|
@@ -17,6 +20,7 @@ export declare function maskingHooks(root: Node, opts?: MaskOptions): {
|
|
|
17
20
|
onCloneEachNode: (clone: Node) => void;
|
|
18
21
|
onCloneNode: (clone: Node) => void;
|
|
19
22
|
failure: () => string | undefined;
|
|
23
|
+
detectorCounts: () => DetectorCounts;
|
|
20
24
|
};
|
|
21
25
|
/** A hatched box with the masked element's geometry. Reads layout only, never content. */
|
|
22
26
|
export declare function placeholderFor(el: Element, doc: Document): HTMLElement;
|
|
@@ -24,5 +28,12 @@ export declare function placeholderFor(el: Element, doc: Document): HTMLElement;
|
|
|
24
28
|
export declare function emptyBoxFor(el: Element, doc: Document): HTMLElement;
|
|
25
29
|
/** The visible viewport as a masked WebP (PNG where WebP encoding is unsupported), ≤ 2 MB. */
|
|
26
30
|
export declare function captureViewport(root?: Element, opts?: MaskOptions): Promise<Blob | undefined>;
|
|
31
|
+
/** A masked capture and its detector hits per rule (counts only: nothing is sent from here). */
|
|
32
|
+
export interface CaptureReport {
|
|
33
|
+
blob: Blob | undefined;
|
|
34
|
+
detectorCounts: DetectorCounts;
|
|
35
|
+
}
|
|
36
|
+
/** {@link captureViewport}, also reporting how many elements the detector over-masked, per rule. */
|
|
37
|
+
export declare function captureViewportReport(root?: Element, opts?: MaskOptions): Promise<CaptureReport>;
|
|
27
38
|
/** The masked clone as SVG markup (what gets rasterised). Used by the e2e privacy checks. */
|
|
28
|
-
export declare function maskedSnapshotSvg(root?: Element): Promise<string>;
|
|
39
|
+
export declare function maskedSnapshotSvg(root?: Element, opts?: MaskOptions): Promise<string>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MountOptions } from "../loader";
|
|
2
|
+
import { signedIdentity } from "../config";
|
|
3
|
+
export { signedIdentity };
|
|
4
|
+
/**
|
|
5
|
+
* The PUT target for a screenshot: `uploadUrl` is a path relative to the collector endpoint
|
|
6
|
+
* (collector.proto). Image bytes only ever go to the collector's own origin.
|
|
7
|
+
*/
|
|
8
|
+
export declare function uploadTarget(uploadUrl: string, endpoint: string): string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Reserves and PUTs one masked image; resolves its `screenshotId`, or `undefined` when the bytes
|
|
11
|
+
* were refused. A failed reservation rejects with the collector's error (the caller decides
|
|
12
|
+
* whether uploads are unavailable). Call only after consent.
|
|
13
|
+
*/
|
|
14
|
+
export declare function putScreenshot(endpoint: string, options: MountOptions, blob: Blob, fetchImpl?: typeof fetch): Promise<string | undefined>;
|
package/dist/types/widget.d.ts
CHANGED
|
@@ -1,27 +1,7 @@
|
|
|
1
1
|
import type { WidgetModule } from "./loader";
|
|
2
2
|
import { type JourneezeContext, type WireFeedbackContext } from "./types";
|
|
3
3
|
export { maskedSnapshotSvg } from "./widget/capture";
|
|
4
|
-
|
|
5
|
-
* The PUT target for a screenshot: `uploadUrl` is a path relative to the collector endpoint
|
|
6
|
-
* (collector.proto). Image bytes only ever go to the collector's own origin.
|
|
7
|
-
*/
|
|
8
|
-
export declare function uploadTarget(uploadUrl: string, endpoint: string): string | undefined;
|
|
4
|
+
export { signedIdentity, uploadTarget } from "./widget/upload";
|
|
9
5
|
/** Strips empty values; adds the page path and device class the widget derives. */
|
|
10
6
|
export declare function wireContext(ctx: Readonly<JourneezeContext>, href: string, width: number, tflowId?: string): WireFeedbackContext;
|
|
11
|
-
/**
|
|
12
|
-
* The host's signature over the user id (contract §4, v1.3), only while it is well formed and
|
|
13
|
-
* unexpired; otherwise the id travels unsigned (sites that require signed identity then treat
|
|
14
|
-
* the request as anonymous). Fixed into the request when it is written, like the id.
|
|
15
|
-
*/
|
|
16
|
-
export declare function signedIdentity(o: {
|
|
17
|
-
userIdSig?: string | undefined;
|
|
18
|
-
userIdExp?: number | undefined;
|
|
19
|
-
signature?: {
|
|
20
|
-
sig: string;
|
|
21
|
-
exp: number;
|
|
22
|
-
} | "" | undefined;
|
|
23
|
-
}): {
|
|
24
|
-
userIdSig?: string;
|
|
25
|
-
userIdExp?: number;
|
|
26
|
-
};
|
|
27
7
|
export declare const mount: WidgetModule["mount"];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{a as Te}from"./index-CwG2LrhO.js";import{j as Ae,c as Ne,w as ke}from"./consent-DckCUvYR.js";const xe=new Set(["cc-number","cc-csc","cc-exp","cc-exp-month","cc-exp-year"]),Re=new Set(["current-password","new-password"]),_e=/\b(?:password|passcode|ssn|social security(?: number)?|card number|cvc|cvv|iban|api key|secret|token)\b/,F=512,De=/(?:^|[^A-Za-z0-9_-])(?:sk-[A-Za-z0-9_-]{16,}|sk_(?:live|test)_[A-Za-z0-9]{16,}|ghp_[A-Za-z0-9]{36}|xox[bp]-[A-Za-z0-9-]{10,}|AKIA[0-9A-Z]{16}|eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]+)/,Ie=/(?:\d[ -]?){12,18}\d/g,Pe=/[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}/;function Fe(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z])([A-Z][a-z])/g,"$1 $2").replace(/[_.\-:[\]]+/g," ").toLowerCase()}const U=e=>!!e&&_e.test(Fe(e));function Le(e){const t=e.getAttribute("autocomplete");if(t)for(const r of t.trim().toLowerCase().split(/\s+/)){if(xe.has(r))return"autocomplete_cc";if(r==="one-time-code")return"autocomplete_otp";if(Re.has(r))return"autocomplete_password"}}function $e(e){const t=[],r=e.getAttribute("aria-label");r&&t.push(r);const n=e.ownerDocument;for(const o of(e.getAttribute("aria-labelledby")??"").split(/\s+/)){const a=o?n?.getElementById(o)?.textContent:void 0;a&&t.push(a.slice(0,F))}const s=e.labels;if(s)for(const o of Array.from(s))t.push((o.textContent??"").slice(0,F));return t}function Me(e){let t="";for(const r of Array.from(e.childNodes))if(r.nodeType===3&&(t+=r.data),t.length>=F)break;return t.slice(0,F)}function Oe(e){let t=0;for(let r=0;r<e.length;r++){let n=e.charCodeAt(e.length-1-r)-48;r%2===1&&(n*=2,n>9&&(n-=9)),t+=n}return t%10===0}function Ue(e){for(const t of e.matchAll(Ie)){const r=t[0].replace(/[ -]/g,"");if(r.length>=13&&r.length<=19&&Oe(r))return true}return false}function B(e){if(/^(?:style|script)$/i.test(e.tagName))return;const t=Le(e);if(t)return t;if(e.tagName==="INPUT"&&(e.getAttribute("type")??"").trim().toLowerCase()==="password")return"input_password";if(U(e.getAttribute("name"))||U(e.id))return"name_sensitive";if($e(e).some(U))return"label_sensitive";const r=Me(e);if(r.trim()!==""){if(De.test(r))return"value_key_shaped";if(Ue(r))return"value_card_shaped";if(Pe.test(r))return"value_email_shaped"}}function Be(e){const t=e.getAttribute("data-tflow-id");if(t)return`[data-tflow-id="${X(t)}"]`;const r=e.getAttribute("data-testid");if(r)return`[data-testid="${X(r)}"]`;const n=[];for(let s=e;s&&n.length<6;s=s.parentElement){const o=s.tagName.toLowerCase();if(o==="html"||o==="body")break;const a=s.parentElement,i=a?Array.from(a.children).filter(l=>l.tagName===s.tagName).indexOf(s)+1:1;n.unshift(`${o}:nth-of-type(${i})`)}return n.join(" > ")||e.tagName.toLowerCase()}function X(e){return e.replace(/["\\]/g,"\\$&").slice(0,96)}function gr(e,t=()=>false){const r=[],n=s=>{if(t(s))return;const o=B(s);if(o){r.push({rule:o,selector:Be(s)});return}for(const a of Array.from(s.children))n(a)};for(const s of Array.from(e.children))n(s);return r}const ne="[modern-screenshot]",N=typeof window<"u",ze=N&&"Worker"in window,j=N?window.navigator?.userAgent:"",oe=j.includes("Chrome"),L=j.includes("AppleWebKit")&&!oe,V=j.includes("Firefox"),We=e=>e&&"__CONTEXT__"in e,je=e=>e.constructor.name==="CSSFontFaceRule",Ve=e=>e.constructor.name==="CSSImportRule",qe=e=>e.constructor.name==="CSSLayerBlockRule",E=e=>e.nodeType===1,I=e=>typeof e.className=="object",se=e=>e.tagName==="image",He=e=>e.tagName==="use",R=e=>E(e)&&typeof e.style<"u"&&!I(e),Xe=e=>e.nodeType===8,Ze=e=>e.nodeType===3,k=e=>e.tagName==="IMG",$=e=>e.tagName==="VIDEO",Ke=e=>e.tagName==="CANVAS",Ge=e=>e.tagName==="TEXTAREA",Ye=e=>e.tagName==="INPUT",Je=e=>e.tagName==="STYLE",Qe=e=>e.tagName==="SCRIPT",et=e=>e.tagName==="SELECT",tt=e=>e.tagName==="SLOT",rt=e=>e.tagName==="IFRAME",nt=(...e)=>console.warn(ne,...e);function ot(e){const t=e?.createElement?.("canvas");return t&&(t.height=t.width=1),!!t&&"toDataURL"in t&&!!t.toDataURL("image/webp").includes("image/webp")}const z=e=>e.startsWith("data:");function ie(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(N&&e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i)||!N)return e;const r=M().implementation.createHTMLDocument(),n=r.createElement("base"),s=r.createElement("a");return r.head.appendChild(n),r.body.appendChild(s),t&&(n.href=t),s.href=e,s.href}function M(e){return(e&&E(e)?e?.ownerDocument:e)??window.document}const O="http://www.w3.org/2000/svg";function st(e,t,r){const n=M(r).createElementNS(O,"svg");return n.setAttributeNS(null,"width",e.toString()),n.setAttributeNS(null,"height",t.toString()),n.setAttributeNS(null,"viewBox",`0 0 ${e} ${t}`),n}function it(e,t){let r=new XMLSerializer().serializeToString(e);return t&&(r=r.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,"")),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`}function at(e,t){return new Promise((r,n)=>{const s=new FileReader;s.onload=()=>r(s.result),s.onerror=()=>n(s.error),s.onabort=()=>n(new Error(`Failed read blob to ${t}`)),s.readAsDataURL(e)})}const ct=e=>at(e,"dataUrl");function A(e,t){const r=M(t).createElement("img");return r.decoding="sync",r.loading="eager",r.src=e,r}function _(e,t){return new Promise(r=>{const{timeout:n,ownerDocument:s,onError:o,onWarn:a}=t??{},i=typeof e=="string"?A(e,M(s)):e;let l=null,m=null;function c(){r(i),l&&clearTimeout(l),m?.()}if(n&&(l=setTimeout(c,n)),$(i)){const h=i.currentSrc||i.src;if(!h)return i.poster?_(i.poster,t).then(r):c();if(i.readyState>=2)return c();const g=c,f=d=>{a?.("Failed video load",h,d),o?.(d),c()};m=()=>{i.removeEventListener("loadeddata",g),i.removeEventListener("error",f)},i.addEventListener("loadeddata",g,{once:true}),i.addEventListener("error",f,{once:true})}else{const h=se(i)?i.href.baseVal:i.currentSrc||i.src;if(!h)return c();const g=async()=>{if(k(i)&&"decode"in i)try{await i.decode()}catch(d){a?.("Failed to decode image, trying to render anyway",i.dataset.originalSrc||h,d)}c()},f=d=>{a?.("Failed image load",i.dataset.originalSrc||h,d),c()};if(k(i)&&i.complete)return g();m=()=>{i.removeEventListener("load",g),i.removeEventListener("error",f)},i.addEventListener("load",g,{once:true}),i.addEventListener("error",f,{once:true})}})}async function lt(e,t){R(e)&&(k(e)||$(e)?await _(e,t):await Promise.all(["img","video"].flatMap(r=>Array.from(e.querySelectorAll(r)).map(n=>_(n,t)))))}const ae=(function(){let t=0;const r=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${r()}${t}`)})();function ce(e){return e?.split(",").map(t=>t.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}let Z=0;function ut(e){const t=`${ne}[#${Z}]`;return Z++,{time:r=>e&&console.time(`${t} ${r}`),timeEnd:r=>e&&console.timeEnd(`${t} ${r}`),warn:(...r)=>e&&nt(...r)}}function ft(e){return{cache:e?"no-cache":"force-cache"}}async function le(e,t){return We(e)?e:dt(e,{...t,autoDestruct:true})}async function dt(e,t){const{scale:r=1,workerUrl:n,workerNumber:s=1}=t||{},o=!!t?.debug,a=t?.features??true,i=e.ownerDocument??(N?window.document:void 0),l=e.ownerDocument?.defaultView??(N?window:void 0),m=new Map,c={width:0,height:0,quality:1,type:"image/png",scale:r,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:o,fetch:{requestInit:ft(t?.fetch?.bypassingCache),placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:false,...t?.fetch},fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:s,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:false,...t,__CONTEXT__:true,log:ut(o),node:e,ownerDocument:i,ownerWindow:l,dpi:r===1?null:96*r,svgStyleElement:ue(i),svgDefsElement:i?.createElementNS(O,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:ze&&n&&s?s:0})].map(()=>{try{const f=new Worker(n);return f.onmessage=async d=>{const{url:u,result:p}=d.data;p?m.get(u)?.resolve?.(p):m.get(u)?.reject?.(new Error(`Error receiving message from worker: ${u}`))},f.onmessageerror=d=>{const{url:u}=d.data;m.get(u)?.reject?.(new Error(`Error receiving message from worker: ${u}`))},f}catch(f){return c.log.warn("Failed to new Worker",f),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[ot(i)&&"image/webp","image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:m,drawImageCount:0,tasks:[],features:a,isEnable:f=>f==="restoreScrollPosition"?typeof a=="boolean"?false:a[f]??false:typeof a=="boolean"?a:a[f]??true,shadowRoots:[]};c.log.time("wait until load"),await lt(e,{timeout:c.timeout,onWarn:c.log.warn}),c.log.timeEnd("wait until load");const{width:h,height:g}=mt(e,c);return c.width=h,c.height=g,c}function ue(e){if(!e)return;const t=e.createElement("style"),r=t.ownerDocument.createTextNode(`
|
|
2
|
+
.______background-clip--text {
|
|
3
|
+
background-clip: text;
|
|
4
|
+
-webkit-background-clip: text;
|
|
5
|
+
}
|
|
6
|
+
`);return t.appendChild(r),t}function mt(e,t){let{width:r,height:n}=t;if(E(e)&&(!r||!n)){const s=e.getBoundingClientRect();r=r||s.width||Number(e.getAttribute("width"))||0,n=n||s.height||Number(e.getAttribute("height"))||0}return{width:r,height:n}}async function gt(e,t){const{log:r,timeout:n,drawImageCount:s,drawImageInterval:o}=t;r.time("image to canvas");const a=await _(e,{timeout:n,onWarn:t.log.warn}),{canvas:i,context2d:l}=ht(e.ownerDocument,t),m=()=>{try{l?.drawImage(a,0,0,i.width,i.height)}catch(c){t.log.warn("Failed to drawImage",c)}};if(m(),t.isEnable("fixSvgXmlDecode"))for(let c=0;c<s;c++)await new Promise(h=>{setTimeout(()=>{l?.clearRect(0,0,i.width,i.height),m(),h()},c+o)});return t.drawImageCount=0,r.timeEnd("image to canvas"),i}function ht(e,t){const{width:r,height:n,scale:s,backgroundColor:o,maximumCanvasSize:a}=t,i=e.createElement("canvas");i.width=Math.floor(r*s),i.height=Math.floor(n*s),i.style.width=`${r}px`,i.style.height=`${n}px`,a&&(i.width>a||i.height>a)&&(i.width>a&&i.height>a?i.width>i.height?(i.height*=a/i.width,i.width=a):(i.width*=a/i.height,i.height=a):i.width>a?(i.height*=a/i.width,i.width=a):(i.width*=a/i.height,i.height=a));const l=i.getContext("2d");return l&&o&&(l.fillStyle=o,l.fillRect(0,0,i.width,i.height)),{canvas:i,context2d:l}}function fe(e,t){if(e.ownerDocument)try{const o=e.toDataURL();if(o!=="data:,")return A(o,e.ownerDocument)}catch(o){t.log.warn("Failed to clone canvas",o)}const r=e.cloneNode(false),n=e.getContext("2d"),s=r.getContext("2d");try{return n&&s&&s.putImageData(n.getImageData(0,0,e.width,e.height),0,0),r}catch(o){t.log.warn("Failed to clone canvas",o)}return r}function pt(e,t){try{if(e?.contentDocument?.documentElement)return q(e.contentDocument.documentElement,t)}catch(r){t.log.warn("Failed to clone iframe",r)}return e.cloneNode(false)}function wt(e){const t=e.cloneNode(false);return e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),t.loading==="lazy"&&(t.loading="eager"),t}async function yt(e,t){if(e.ownerDocument&&!e.currentSrc&&e.poster)return A(e.poster,e.ownerDocument);const r=e.cloneNode(false);r.crossOrigin="anonymous",e.currentSrc&&e.currentSrc!==e.src&&(r.src=e.currentSrc);const n=r.ownerDocument;if(n){let s=true;if(await _(r,{onError:()=>s=false,onWarn:t.log.warn}),!s)return e.poster?A(e.poster,e.ownerDocument):r;r.currentTime=e.currentTime,await new Promise(a=>{r.addEventListener("seeked",a,{once:true})});const o=n.createElement("canvas");o.width=e.offsetWidth,o.height=e.offsetHeight;try{const a=o.getContext("2d");a&&a.drawImage(r,0,0,o.width,o.height)}catch(a){return t.log.warn("Failed to clone video",a),e.poster?A(e.poster,e.ownerDocument):r}return fe(o,t)}return r}function bt(e,t){return Ke(e)?fe(e,t):rt(e)?pt(e,t):k(e)?wt(e):$(e)?yt(e,t):e.cloneNode(false)}function St(e){let t=e.sandbox;if(!t){const{ownerDocument:r}=e;try{r&&(t=r.createElement("iframe"),t.id=`__SANDBOX__${ae()}`,t.width="0",t.height="0",t.style.visibility="hidden",t.style.position="fixed",r.body.appendChild(t),t.srcdoc='<!DOCTYPE html><meta charset="UTF-8"><title></title><body>',e.sandbox=t)}catch(n){e.log.warn("Failed to getSandBox",n)}}return t}const Et=["width","height","-webkit-text-fill-color"],vt=["stroke","fill"];function de(e,t,r){const{defaultComputedStyles:n}=r,s=e.nodeName.toLowerCase(),o=I(e)&&s!=="svg",a=o?vt.map(u=>[u,e.getAttribute(u)]).filter(([,u])=>u!==null):[],i=[o&&"svg",s,a.map((u,p)=>`${u}=${p}`).join(","),t].filter(Boolean).join(":");if(n.has(i))return n.get(i);const m=St(r)?.contentWindow;if(!m)return new Map;const c=m?.document;let h,g;o?(h=c.createElementNS(O,"svg"),g=h.ownerDocument.createElementNS(h.namespaceURI,s),a.forEach(([u,p])=>{g.setAttributeNS(null,u,p)}),h.appendChild(g)):h=g=c.createElement(s),g.textContent=" ",c.body.appendChild(h);const f=m.getComputedStyle(g,t),d=new Map;for(let u=f.length,p=0;p<u;p++){const w=f.item(p);Et.includes(w)||d.set(w,f.getPropertyValue(w))}return c.body.removeChild(h),n.set(i,d),d}function me(e,t,r){const n=new Map,s=[],o=new Map;if(r)for(const i of r)a(i);else for(let i=e.length,l=0;l<i;l++){const m=e.item(l);a(m)}for(let i=s.length,l=0;l<i;l++)o.get(s[l])?.forEach((m,c)=>n.set(c,m));function a(i){const l=e.getPropertyValue(i),m=e.getPropertyPriority(i),c=i.lastIndexOf("-"),h=c>-1?i.substring(0,c):void 0;if(h){let g=o.get(h);g||(g=new Map,o.set(h,g)),g.set(i,[l,m])}t.get(i)===l&&!m||(h?s.push(h):n.set(i,[l,m]))}return n}function Ct(e,t,r,n){const{ownerWindow:s,includeStyleProperties:o,currentParentNodeStyle:a}=n,i=t.style,l=s.getComputedStyle(e),m=de(e,null,n);a?.forEach((h,g)=>{m.delete(g)});const c=me(l,m,o);c.delete("transition-property"),c.delete("all"),c.delete("d"),c.delete("content"),r&&(c.delete("position"),c.delete("margin-top"),c.delete("margin-right"),c.delete("margin-bottom"),c.delete("margin-left"),c.delete("margin-block-start"),c.delete("margin-block-end"),c.delete("margin-inline-start"),c.delete("margin-inline-end"),c.set("box-sizing",["border-box",""])),c.get("background-clip")?.[0]==="text"&&t.classList.add("______background-clip--text"),oe&&(c.has("font-kerning")||c.set("font-kerning",["normal",""]),(c.get("overflow-x")?.[0]==="hidden"||c.get("overflow-y")?.[0]==="hidden")&&c.get("text-overflow")?.[0]==="ellipsis"&&e.scrollWidth===e.clientWidth&&c.set("text-overflow",["clip",""]));for(let h=i.length,g=0;g<h;g++)i.removeProperty(i.item(g));return c.forEach(([h,g],f)=>{i.setProperty(f,h,g)}),c}function Tt(e,t){(Ge(e)||Ye(e)||et(e))&&t.setAttribute("value",e.value)}const At=["::before","::after"],Nt=["::-webkit-scrollbar","::-webkit-scrollbar-button","::-webkit-scrollbar-thumb","::-webkit-scrollbar-track","::-webkit-scrollbar-track-piece","::-webkit-scrollbar-corner","::-webkit-resizer"];function kt(e,t,r,n,s){const{ownerWindow:o,svgStyleElement:a,svgStyles:i,currentNodeStyle:l}=n;if(!a||!o)return;function m(c){const h=o.getComputedStyle(e,c);let g=h.getPropertyValue("content");if(!g||g==="none")return;s?.(g),g=g.replace(/(')|(")|(counter\(.+\))/g,"");const f=[ae()],d=de(e,c,n);l?.forEach((b,S)=>{d.delete(S)});const u=me(h,d,n.includeStyleProperties);u.delete("content"),u.delete("-webkit-locale"),u.get("background-clip")?.[0]==="text"&&t.classList.add("______background-clip--text");const p=[`content: '${g}';`];if(u.forEach(([b,S],C)=>{p.push(`${C}: ${b}${S?" !important":""};`)}),p.length===1)return;try{t.className=[t.className,...f].join(" ")}catch(b){n.log.warn("Failed to copyPseudoClass",b);return}const w=p.join(`
|
|
7
|
+
`);let y=i.get(w);y||(y=[],i.set(w,y)),y.push(`.${f[0]}${c}`)}At.forEach(m),r&&Nt.forEach(m)}const K=new Set(["symbol"]);async function G(e,t,r,n,s){if(E(r)&&(Je(r)||Qe(r))||n.filter&&!n.filter(r))return;K.has(t.nodeName)||K.has(r.nodeName)?n.currentParentNodeStyle=void 0:n.currentParentNodeStyle=n.currentNodeStyle;const o=await q(r,n,false,s);n.isEnable("restoreScrollPosition")&&xt(e,o),t.appendChild(o)}async function Y(e,t,r,n){let s=e.firstChild;E(e)&&e.shadowRoot&&(s=e.shadowRoot?.firstChild,r.shadowRoots.push(e.shadowRoot));for(let o=s;o;o=o.nextSibling)if(!Xe(o))if(E(o)&&tt(o)&&typeof o.assignedNodes=="function"){const a=o.assignedNodes();for(let i=0;i<a.length;i++)await G(e,t,a[i],r,n)}else await G(e,t,o,r,n)}function xt(e,t){if(!R(e)||!R(t))return;const{scrollTop:r,scrollLeft:n}=e;if(!r&&!n)return;const{transform:s}=t.style,o=new DOMMatrix(s),{a,b:i,c:l,d:m}=o;o.a=1,o.b=0,o.c=0,o.d=1,o.translateSelf(-n,-r),o.a=a,o.b=i,o.c=l,o.d=m,t.style.transform=o.toString()}function Rt(e,t){const{backgroundColor:r,width:n,height:s,style:o}=t,a=e.style;if(r&&a.setProperty("background-color",r,"important"),n&&a.setProperty("width",`${n}px`,"important"),s&&a.setProperty("height",`${s}px`,"important"),o)for(const i in o)a[i]=o[i]}const _t=/^[\w-:]+$/;async function q(e,t,r=false,n){const{ownerDocument:s,ownerWindow:o,fontFamilies:a,onCloneEachNode:i}=t;if(s&&Ze(e))return n&&/\S/.test(e.data)&&n(e.data),s.createTextNode(e.data);if(s&&o&&E(e)&&(R(e)||I(e))){const m=await bt(e,t);if(t.isEnable("removeAbnormalAttributes")){const u=m.getAttributeNames();for(let p=u.length,w=0;w<p;w++){const y=u[w];_t.test(y)||m.removeAttribute(y)}}const c=t.currentNodeStyle=Ct(e,m,r,t);r&&Rt(m,t);let h=false;if(t.isEnable("copyScrollbar")){const u=[c.get("overflow-x")?.[0],c.get("overflow-y")?.[0]];h=u.includes("scroll")||(u.includes("auto")||u.includes("overlay"))&&(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)}const g=c.get("text-transform")?.[0],f=ce(c.get("font-family")?.[0]),d=f?u=>{g==="uppercase"?u=u.toUpperCase():g==="lowercase"?u=u.toLowerCase():g==="capitalize"&&(u=u[0].toUpperCase()+u.substring(1)),f.forEach(p=>{let w=a.get(p);w||a.set(p,w=new Set),u.split("").forEach(y=>w.add(y))})}:void 0;return kt(e,m,h,t,d),Tt(e,m),$(e)||await Y(e,m,t,d),await i?.(m),m}const l=e.cloneNode(false);return await Y(e,l,t),await i?.(l),l}function Dt(e){if(e.ownerDocument=void 0,e.ownerWindow=void 0,e.svgStyleElement=void 0,e.svgDefsElement=void 0,e.svgStyles.clear(),e.defaultComputedStyles.clear(),e.sandbox){try{e.sandbox.remove()}catch(t){e.log.warn("Failed to destroyContext",t)}e.sandbox=void 0}e.workers=[],e.fontFamilies.clear(),e.fontCssTexts.clear(),e.requests.clear(),e.tasks=[],e.shadowRoots=[]}function It(e){const{url:t,timeout:r,responseType:n,...s}=e,o=new AbortController,a=r?setTimeout(()=>o.abort(),r):void 0;return fetch(t,{signal:o.signal,...s}).then(i=>{if(!i.ok)throw new Error("Failed fetch, not 2xx response",{cause:i});switch(n){case"arrayBuffer":return i.arrayBuffer();case"dataUrl":return i.blob().then(ct);default:return i.text()}}).finally(()=>clearTimeout(a))}function D(e,t){const{url:r,requestType:n="text",responseType:s="text",imageDom:o}=t;let a=r;const{timeout:i,acceptOfImage:l,requests:m,fetchFn:c,fetch:{requestInit:h,bypassingCache:g,placeholderImage:f},font:d,workers:u,fontFamilies:p}=e;n==="image"&&(L||V)&&e.drawImageCount++;let w=m.get(r);if(!w){g&&g instanceof RegExp&&g.test(a)&&(a+=(/\?/.test(a)?"&":"?")+new Date().getTime());const y=n.startsWith("font")&&d&&d.minify,b=new Set;y&&n.split(";")[1].split(",").forEach(P=>{p.has(P)&&p.get(P).forEach(H=>b.add(H))});const S=y&&b.size,C={url:a,timeout:i,responseType:S?"arrayBuffer":s,headers:n==="image"?{accept:l}:void 0,...h};w={type:n,resolve:void 0,reject:void 0,response:null},w.response=(async()=>{if(c&&n==="image"){const v=await c(r);if(v)return v}return!L&&r.startsWith("http")&&u.length?new Promise((v,P)=>{u[m.size&u.length-1].postMessage({rawUrl:r,...C}),w.resolve=v,w.reject=P}):It(C)})().catch(v=>{if(m.delete(r),n==="image"&&f)return e.log.warn("Failed to fetch image base64, trying to use placeholder image",a),typeof f=="string"?f:f(o);throw v}),m.set(r,w)}return w.response}async function ge(e,t,r,n){if(!he(e))return e;for(const[s,o]of Pt(e,t))try{const a=await D(r,{url:o,requestType:n?"image":"text",responseType:"dataUrl"});e=e.replace(Ft(s),`$1${a}$3`)}catch(a){r.log.warn("Failed to fetch css data url",s,a)}return e}function he(e){return/url\((['"]?)([^'"]+?)\1\)/.test(e)}const pe=/url\((['"]?)([^'"]+?)\1\)/g;function Pt(e,t){const r=[];return e.replace(pe,(n,s,o)=>(r.push([o,ie(o,t)]),n)),r.filter(([n])=>!z(n))}function Ft(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}const Lt=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];function $t(e,t){return Lt.map(r=>{const n=e.getPropertyValue(r);return!n||n==="none"?null:((L||V)&&t.drawImageCount++,ge(n,null,t,true).then(s=>{!s||n===s||e.setProperty(r,s,e.getPropertyPriority(r))}))}).filter(Boolean)}function Mt(e,t){if(k(e)){const r=e.currentSrc||e.src;if(!z(r))return[D(t,{url:r,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(n=>{n&&(e.srcset="",e.dataset.originalSrc=r,e.src=n||"")})];(L||V)&&t.drawImageCount++}else if(I(e)&&!z(e.href.baseVal)){const r=e.href.baseVal;return[D(t,{url:r,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(n=>{n&&(e.dataset.originalSrc=r,e.href.baseVal=n||"")})]}return[]}function Ot(e,t){const{ownerDocument:r,svgDefsElement:n}=t,s=e.getAttribute("href")??e.getAttribute("xlink:href");if(!s)return[];const[o,a]=s.split("#");if(a){const i=`#${a}`,l=t.shadowRoots.reduce((m,c)=>m??c.querySelector(`svg ${i}`),r?.querySelector(`svg ${i}`));if(o&&e.setAttribute("href",i),n?.querySelector(i))return[];if(l)return n?.appendChild(l.cloneNode(true)),[];if(o)return[D(t,{url:o,responseType:"text"}).then(m=>{n?.insertAdjacentHTML("beforeend",m)})]}return[]}function we(e,t){const{tasks:r}=t;E(e)&&((k(e)||se(e))&&r.push(...Mt(e,t)),He(e)&&r.push(...Ot(e,t))),R(e)&&r.push(...$t(e.style,t)),e.childNodes.forEach(n=>{we(n,t)})}async function Ut(e,t){const{ownerDocument:r,svgStyleElement:n,fontFamilies:s,fontCssTexts:o,tasks:a,font:i}=t;if(!(!r||!n||!s.size))if(i&&i.cssText){const l=Q(i.cssText,t);n.appendChild(r.createTextNode(`${l}
|
|
8
|
+
`))}else{const l=Array.from(r.styleSheets).filter(f=>{try{return"cssRules"in f&&!!f.cssRules.length}catch(d){return t.log.warn(`Error while reading CSS rules from ${f.href}`,d),false}}),m=r.implementation.createHTMLDocument(""),c=m.createElement("style");m.head.appendChild(c);const h=c.sheet;await Promise.all(l.flatMap(f=>Array.from(f.cssRules).map(async d=>{if(Ve(d)){const u=d.href;let p="";try{p=await D(t,{url:u,requestType:"text",responseType:"text"})}catch(y){t.log.warn(`Error fetch remote css import from ${u}`,y)}const w=p.replace(pe,(y,b,S)=>y.replace(S,ie(S,u)));for(const y of zt(w))try{h.insertRule(y,h.cssRules.length)}catch(b){t.log.warn("Error inserting rule from remote css import",{rule:y,error:b})}}}))),h.cssRules.length&&l.push(h);const g=[];l.forEach(f=>{W(f.cssRules,g)}),g.filter(f=>je(f)&&he(f.style.getPropertyValue("src"))&&ce(f.style.getPropertyValue("font-family"))?.some(d=>s.has(d))).forEach(f=>{const d=f,u=o.get(d.cssText);u?n.appendChild(r.createTextNode(`${u}
|
|
9
|
+
`)):a.push(ge(d.cssText,d.parentStyleSheet?d.parentStyleSheet.href:null,t).then(p=>{p=Q(p,t),o.set(d.cssText,p),n.appendChild(r.createTextNode(`${p}
|
|
10
|
+
`))}))})}}const Bt=/(\/\*[\s\S]*?\*\/)/g,J=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;function zt(e){if(e==null)return[];const t=[];let r=e.replace(Bt,"");for(;;){const o=J.exec(r);if(!o)break;t.push(o[0])}r=r.replace(J,"");const n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,s=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let o=n.exec(r);if(o)s.lastIndex=n.lastIndex;else if(o=s.exec(r),o)n.lastIndex=s.lastIndex;else break;t.push(o[0])}return t}const Wt=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,jt=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Q(e,t){const{font:r}=t,n=r?r?.preferredFormat:void 0;return n?e.replace(jt,s=>{for(;;){const[o,,a]=Wt.exec(s)||[];if(!a)return"";if(a===n)return`src: ${o};`}}):e}function W(e,t=[]){for(const r of Array.from(e))qe(r)?t.push(...W(r.cssRules)):"cssRules"in r?W(r.cssRules,t):t.push(r);return t}const Vt=/\bx?link:?href\s*=\s*["'](?!data:)[^"']+["']/i;function qt(e){return Vt.test(e.innerHTML)}async function ye(e,t){const r=await le(e,t);if(E(r.node)&&I(r.node)&&!qt(r.node))return r.node;const{ownerDocument:n,log:s,tasks:o,svgStyleElement:a,svgDefsElement:i,svgStyles:l,font:m,progress:c,autoDestruct:h,onCloneNode:g,onEmbedNode:f,onCreateForeignObjectSvg:d}=r;s.time("clone node");const u=await q(r.node,r,true);if(a&&n){let S="";l.forEach((C,v)=>{S+=`${C.join(`,
|
|
11
|
+
`)} {
|
|
12
|
+
${v}
|
|
13
|
+
}
|
|
14
|
+
`}),a.appendChild(n.createTextNode(S))}s.timeEnd("clone node"),await g?.(u),m!==false&&E(u)&&(s.time("embed web font"),await Ut(u,r),s.timeEnd("embed web font")),s.time("embed node"),we(u,r);const p=o.length;let w=0;const y=async()=>{for(;;){const S=o.pop();if(!S)break;try{await S}catch(C){r.log.warn("Failed to run task",C)}c?.(++w,p)}};c?.(w,p),await Promise.all([...Array.from({length:4})].map(y)),s.timeEnd("embed node"),await f?.(u);const b=Ht(u,r);return i&&b.insertBefore(i,b.children[0]),a&&b.insertBefore(a,b.children[0]),h&&Dt(r),await d?.(b),b}function Ht(e,t){const{width:r,height:n}=t,s=st(r,n,e.ownerDocument),o=s.ownerDocument.createElementNS(s.namespaceURI,"foreignObject");return o.setAttributeNS(null,"x","0%"),o.setAttributeNS(null,"y","0%"),o.setAttributeNS(null,"width","100%"),o.setAttributeNS(null,"height","100%"),o.append(e),s.appendChild(o),s}async function Xt(e,t){const r=await le(e,t),n=await ye(r),s=it(n,r.isEnable("removeControlCharacter"));r.autoDestruct||(r.svgStyleElement=ue(r.ownerDocument),r.svgDefsElement=r.ownerDocument?.createElementNS(O,"defs"),r.svgStyles.clear());const o=A(s,n.ownerDocument);return await gt(o,r)}const Zt="iframe, frame, object, embed, video, audio, canvas",Kt=e=>Te(e)||e.matches(Zt),Gt="[data-journeeze], [data-journeeze-chat]",Yt="[data-jz-block]",Jt=2*1024*1024,Qt=1600;class be extends Error{}const T=1,x=3,er=8;function Se(e,t={}){const r=[e],n=new Map,s=ir([...t.maskSelectors??[],...t.configMaskSelectors??[]]),o={},a=t.maskAllText===true,i=f=>Kt(f)||s.some(d=>{try{return f.matches(d)}catch{return true}});let l;const m=f=>{if(f.nodeType===T){const d=f;if(d.matches(Gt))return n.set(d,"drop"),false;if(d.matches(Yt))return n.set(d,"empty"),false;if(sr(d)||i(d))return n.set(d,"replace"),false;const u=B(d);if(u)return o[u]=(o[u]??0)+1,n.set(d,"replace"),false}return f.nodeType!==x&&r.push(f),true},c=f=>{const d=r.pop();if(!d||d.nodeName!==f.nodeName){l??(l="clone order mismatch");return}d.nodeType===T&&f.nodeType===T&&h(d,f)};function h(f,d){const u=Array.from(d.childNodes),p=d.ownerDocument??document;let w=0;for(const y of tr(f)){const b=n.get(y);if(b==="drop")continue;if(b==="replace"){d.insertBefore(nr(y,p),u[w]??null);continue}if(b==="empty"){d.insertBefore(or(y,p),u[w]??null);continue}const S=u[w];if(S===void 0){l??(l="missing clone child");return}w++,a&&y.nodeType===x&&S.nodeType===x&&y.data.trim()!==""&&d.replaceChild(ar(y,p),S)}w!==u.length&&(l??(l="unexpected clone child"))}return{filter:m,onCloneEachNode:c,onCloneNode:f=>{if(r.length!==0&&(l??(l="unbalanced clone traversal")),f.nodeType===T){const d=[f,...Array.from(f.querySelectorAll("*"))];d.some(u=>i(u)||B(u)!==void 0)&&(l??(l="maskable element in clone")),a&&d.some(ve)&&(l??(l="text in clone"))}if(l!==void 0)throw new be(l)},failure:()=>l,detectorCounts:()=>({...o})}}function tr(e){const t=[],r=e.shadowRoot?Array.from(e.shadowRoot.childNodes):Array.from(e.childNodes);for(const n of r)if(n.nodeType!==er){if(n.nodeType===T&&n.tagName==="SLOT"&&typeof n.assignedNodes=="function"){for(const s of n.assignedNodes())ee(s)||t.push(s);continue}ee(n)||t.push(n)}return t}function ee(e){return e.nodeType===T&&(e.tagName==="STYLE"||e.tagName==="SCRIPT")}const rr=["position","top","right","bottom","left","float","clear","z-index","margin-top","margin-right","margin-bottom","margin-left","flex-grow","flex-shrink","flex-basis","align-self","justify-self","order","grid-row-start","grid-row-end","grid-column-start","grid-column-end","vertical-align","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius","transform","visibility"];function nr(e,t){return Ee(e,t,true)}function or(e,t){return Ee(e,t,false)}function Ee(e,t,r){const s=e.ownerDocument.defaultView?.getComputedStyle(e),o=e.getBoundingClientRect(),a=e instanceof HTMLElement?e.offsetWidth:o.width,i=e instanceof HTMLElement?e.offsetHeight:o.height,l=s?.display??"block",m=t.createElement(l.startsWith("inline")?"span":"div"),c=m.style;for(const h of rr){const g=s?.getPropertyValue(h);g&&c.setProperty(h,g)}return c.setProperty("display",l==="none"?"none":l==="inline"||l.startsWith("inline")?"inline-block":"block"),c.setProperty("box-sizing","border-box"),c.setProperty("width",`${a}px`),c.setProperty("height",`${i}px`),c.setProperty("border",r?"1px dashed #8A9099":"0"),c.setProperty("background",r?"repeating-linear-gradient(45deg, rgb(138 144 153 / 18%) 0 4px, rgb(138 144 153 / 32%) 4px 8px)":"transparent"),m.setAttribute(r?"data-jz-masked-placeholder":"data-jz-block-placeholder",""),m}function sr(e){if(!e.tagName.toLowerCase().includes("-")||e.shadowRoot)return false;const t=e.getBoundingClientRect();if(t.width<=0||t.height<=0)return false;for(const r of Array.from(e.childNodes))if(r.nodeType===T||r.nodeType===x&&r.data.trim()!=="")return false;return true}function ir(e){for(const t of e??[])try{document.createDocumentFragment().querySelector(t)}catch{throw te||console.warn("[journeeze] invalid maskSelectors entry: screenshots are off"),te=true,new be("invalid maskSelectors")}return[...e??[]]}let te=false;function ve(e){for(const t of Array.from(e.childNodes))if(t.nodeType===x&&t.data.trim()!==""||t.nodeType===T&&ve(t))return true;return false}function ar(e,t){const r=t.createRange();r.selectNodeContents(e);const n=r.getBoundingClientRect(),s=t.createElement("span"),o=s.style;return o.setProperty("display","inline-block"),o.setProperty("width",`${n.width}px`),o.setProperty("height",`${n.height}px`),o.setProperty("background","repeating-linear-gradient(45deg, rgb(138 144 153 / 18%) 0 4px, rgb(138 144 153 / 32%) 4px 8px)"),s.setAttribute("data-jz-masked-placeholder",""),s}function re(e,t){const r=parseFloat(e.ownerDocument.defaultView?.getComputedStyle(e).getPropertyValue(t)??"0");return Number.isFinite(r)?r:0}function Ce(e,t,r,n){const s=e.ownerDocument.defaultView??window;return{width:s.innerWidth,height:s.innerHeight,scale:r,quality:n,type:"image/webp",timeout:4e3,style:{marginTop:`${re(e,"margin-top")-s.scrollY}px`,marginLeft:`${re(e,"margin-left")-s.scrollX}px`},filter:t.filter,onCloneEachNode:t.onCloneEachNode,onCloneNode:t.onCloneNode}}async function hr(e=document.body,t={}){return(await cr(e,t)).blob}async function cr(e=document.body,t={}){const r=e.ownerDocument.defaultView??window,n=Math.min(r.devicePixelRatio||1,Qt/Math.max(1,r.innerWidth)),s=Se(e,t);let o=await Xt(e,Ce(e,s,n,1));const a=s.detectorCounts();for(const i of[.8,.6,.45]){const l=await lr(o,i);if(!l||l.type!=="image/webp"&&l.type!=="image/png")return{blob:void 0,detectorCounts:a};if(l.size<=Jt)return{blob:l,detectorCounts:a};o=ur(o,.75)}return{blob:void 0,detectorCounts:a}}function lr(e,t){return new Promise(r=>e.toBlob(r,"image/webp",t))}function ur(e,t){const r=e.ownerDocument.createElement("canvas");return r.width=Math.max(1,Math.round(e.width*t)),r.height=Math.max(1,Math.round(e.height*t)),r.getContext("2d")?.drawImage(e,0,0,r.width,r.height),r}async function pr(e=document.body,t={}){const r=Se(e,t),n=await ye(e,{...Ce(e,r,1,1),font:false});return new XMLSerializer().serializeToString(n)}function fr(e,t){try{const r=new URL(t.endsWith("/")?t:`${t}/`),n=new URL(e.replace(/^\/+/,""),r);return n.origin===r.origin?n.href:void 0}catch{return}}async function wr(e,t,r,n=(...s)=>fetch(...s)){if(r.type!=="image/webp"&&r.type!=="image/png")return;const s={siteKey:t.siteKey,contentType:r.type,byteLength:r.size,...t.reviewerToken?{reviewerToken:t.reviewerToken}:{},...t.userId?{userId:t.userId,consentGiven:true,...Ae(t)}:{}},o=await Ne(e,"CreateScreenshotUpload",s,n),a=typeof o.uploadUrl=="string"?fr(o.uploadUrl,e):void 0;if(typeof o.screenshotId!="string"||!a)return;const i={"content-type":r.type};for(const[m,c]of Object.entries(o.headers??{}))typeof c=="string"&&(i[m]=c);return(await n(a,ke({method:"PUT",body:r,headers:i,credentials:"omit",cache:"no-store",referrerPolicy:"no-referrer"}))).ok?o.screenshotId:void 0}export{cr as a,hr as c,pr as m,wr as p,gr as s,fr as u};
|