@mrrocket/sdk 0.25.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -2
- package/README.md +7 -1
- package/dist/api-client.d.ts +16 -1
- package/dist/api-client.js +5 -1
- package/dist/api-client.js.map +1 -1
- package/dist/browser/mrrocket-flows.js +3 -3
- package/dist/browser/mrrocket-messenger.js +52 -36
- package/dist/browser/mrrocket-preview.js +1 -0
- package/dist/browser/mrrocket-replay.js +3 -3
- package/dist/browser/mrrocket.js +2 -2
- package/dist/client.js +52 -3
- package/dist/client.js.map +1 -1
- package/dist/context.d.ts +2 -0
- package/dist/context.js.map +1 -1
- package/dist/core.d.ts +67 -1
- package/dist/core.js +28 -2
- package/dist/core.js.map +1 -1
- package/dist/messenger-ui.d.ts +1 -1
- package/dist/messenger-ui.js +50 -35
- package/dist/messenger-ui.js.map +1 -1
- package/dist/preview.d.ts +101 -0
- package/dist/preview.js +308 -0
- package/dist/preview.js.map +1 -0
- package/dist/react-native/index.d.cts +17 -2
- package/dist/react-native/index.d.ts +17 -2
- package/dist/react-native/index.js +6 -2
- package/dist/react-native/index.js.map +1 -1
- package/dist/styles-css.d.ts +1 -1
- package/dist/styles-css.js +49 -33
- package/dist/styles-css.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this package. It follows semantic versioning; before 1.0 a minor version may change an API.
|
|
4
4
|
|
|
5
|
-
## 0.
|
|
5
|
+
## 0.27.0
|
|
6
|
+
|
|
7
|
+
The messenger's Help tab and its articles, on the web and with the script tag. React Native is unchanged. Tables need MRRocket's side of this release (it answers `blocks=table`); against an older MRRocket an article reads as before.
|
|
8
|
+
|
|
9
|
+
- **The bar says where you are:** inside a collection it names the collection beside the back arrow, and over an article the collection the article is in, instead of "Help" over a second heading. Help's first view has no heading under the bar any more; only a search's results carry a small "Search results" line.
|
|
10
|
+
- **One search field:** the same field in the same place in every view of Help. It no longer gets thinner when the list under it is longer than the panel (it shrank to about a third of its height on a long collection). Home's "Ask a question" field and "New conversation" keep their height the same way.
|
|
11
|
+
- **One list for collections and articles:** cards like Home's conversations, 8px apart, with the name in bold, at most two gray lines under it and the arrow in the middle. A collection shows three of its articles' names and how many it holds. The rounded lines that showed between rows are gone.
|
|
12
|
+
- **Tables in articles:** a new block `{ type: "table", head, rows }` (`ArticleBlock`), drawn as a table with a head row that scrolls sideways inside the article when it is wider than the panel. `article(id, signal, "table")` asks MRRocket for it (`blocks=table`); a widget that does not ask, this package's older versions and the React Native messenger, keeps getting each row as a line of a list ("Free · Pro · Max"), as before.
|
|
13
|
+
- **Articles read calmly:** the text at 15px with more room between lines and parts, clear `h2` and `h3`, lists indented with room between their items, links in the accent color with a soft underline, inline code on a gray chip, quotes, code blocks and rules with their own room. The title stands once: a text that opens with the title as its heading starts under it, and the collection moved from above the title into the bar.
|
|
14
|
+
- Opening a collection no longer puts the cursor into the search field (Help's first view still does). A collection that is gone while a visitor is inside it shows the collections again instead of an empty list.
|
|
15
|
+
- The word "Most read articles" is no longer used; MRRocket keeps sending its translation, so older versions stay whole.
|
|
16
|
+
- Version reported in event batches: `0.27.0`.
|
|
17
|
+
|
|
18
|
+
## 0.26.0
|
|
19
|
+
|
|
20
|
+
- **Preview mode (web, script tag and Next.js):** with `?mrr_preview=<token>` in the address the SDK reads the change that waits for approval in MRRocket (new page copy, one version of a test, a rewritten page) from `GET /api/sdk/preview` and shows it on the real page like a shipped winner: published texts, the test's version forced as `ck_preview` would, and for pages that mark nothing a short list of changes (`set` one element's words, `body` the page's text, `meta` title and description). MRRocket's request view uses it for its before and after pictures. The token is signed by MRRocket, short-lived and bound to one request and product.
|
|
21
|
+
- **The page says when it is ready:** `<html data-mrr-preview="loading">` at once, `"ready"` when the change is on the page, `"failed"` when it could not be read. What found no place (a text the page does not mark, a selector that is not there, an element that reads something else) is listed in `data-mrr-preview-missed`, never dropped. Beside the attributes one unseen status line (`<div role="status" data-mrr-preview-status>`, a transparent pixel) reads `mrr-preview-ready` and what was missed, for a browser that can only wait for text.
|
|
22
|
+
- **Nothing is tracked or stored in preview mode:** no events, no heatmap clicks, no errors, no session recording, no form leads, no referral, no cookie and nothing in storage, whatever consent the site set. Page redirects and redirect tests do not carry the preview away.
|
|
23
|
+
- **Edit on page:** `&mrr_edit=1` with a token that may save shows a slim MRRocket bar (Save, Cancel) and makes the page's words editable in place: elements that hold text only (headings, paragraphs, list items, buttons, links). The request's own changes are highlighted. Text only: typed or pasted markup stays text. Save posts each changed element's selector, old and new words to `POST /api/sdk/preview/edit`; MRRocket writes them into the request as a new version, or hands words the request did not carry to its agent, and says which could not be saved.
|
|
24
|
+
- **Next.js:** in preview mode `<Text id>` renders its words inside `<span data-ck-text style="display: contents">`, so the change can be checked and edited; outside preview mode it renders as before.
|
|
25
|
+
- **Script tag:** the preview and the edit bar are a file of their own, `sdk-preview.js` (`mrrocket-preview.js` in the package), loaded only with `mrr_preview` in the address; `sdk.js` grows by the token check alone.
|
|
26
|
+
- Version reported in event batches: `0.26.0`.
|
|
27
|
+
|
|
28
|
+
## 0.25.0
|
|
6
29
|
|
|
7
30
|
- **Tests your server decides:** `trackVariant(key, { config, distinctId })` in `@mrrocket/sdk/next/server` returns the version like `getVariant` and records `$exposure {experiment, variant}` for that person with the server key (`MRROCKET_SERVER_KEY` or `serverKey`), so a checkout, a price or an email your server chooses is counted like a page test. It sends nothing while the test is not running or its winner is kept for everyone, for an unknown person, for a version a preview forces, or without the server key (one console warning), and waits at most 2.5 s (`timeoutMs`). Pairs with MRRocket's new test type "In your code".
|
|
8
31
|
- Version reported in event batches: `0.25.0`.
|
|
@@ -18,7 +41,7 @@ All notable changes to this package. It follows semantic versioning; before 1.0
|
|
|
18
41
|
- **Overlapping tests:** when two running tests change the same text, the first in the config wins and is the only one recorded; a development build warns once with both keys. `overlaps(config)` lists them.
|
|
19
42
|
- Version reported in event batches: `0.24.0`.
|
|
20
43
|
|
|
21
|
-
## 0.23.1
|
|
44
|
+
## 0.23.1
|
|
22
45
|
|
|
23
46
|
- **Withdrawing consent now reaches MRRocket from the React provider.** In 0.23.0 `$consent_off` waited in the queue, and the provider's consent effect emptied the queue before anything was sent, so it never went out. It now goes at once, by beacon or `fetch` with `keepalive`, signed with `userHash`, and arrives even if the page closes right after. Everything else in the queue is still dropped. Nothing goes out for an anonymous visitor, a page that starts with consent off, or a browser's privacy signal. The script tag and React Native sent it correctly already.
|
|
24
47
|
- Version reported in event batches: `0.23.1`.
|
package/README.md
CHANGED
|
@@ -118,6 +118,12 @@ export default async function Page({ searchParams }: { searchParams: Promise<Rec
|
|
|
118
118
|
|
|
119
119
|
The server needs an id it can read. Cookieless (the default) there is none, so pass your own, for example the signed-in user's id, to both sides: `getVariant(key, { config, searchParams: sp, distinctId: user.id })` and `<CockpitProvider distinctId={user.id}>`.
|
|
120
120
|
|
|
121
|
+
### Previews of waiting changes (0.26.0)
|
|
122
|
+
|
|
123
|
+
When an agent proposes new copy, a test or a rewritten page, MRRocket shows the request with a picture of your real page before and after. For the after picture it opens the page with `?mrr_preview=<token>`: the SDK reads the waiting change for that token and shows it like a shipped winner, then marks `<html data-mrr-preview="ready">`. Nothing is tracked, recorded or stored while the parameter is there, and the token is signed by MRRocket, short-lived and bound to one request. There is nothing to set up: texts you mark with `<Text id>` or `data-ck-text` are what a preview can change.
|
|
124
|
+
|
|
125
|
+
**Edit on page** in the request opens the same page with `&mrr_edit=1`: a slim MRRocket bar appears, the page's words become editable in place (text only), and Save writes your edits back into the request.
|
|
126
|
+
|
|
121
127
|
### Tests your server decides (0.25.0)
|
|
122
128
|
|
|
123
129
|
Some tests have no page: a checkout, a price, an email, anything your server chooses. Create them in MRRocket with **Runs on: In your code**; the test's page shows its key. Ask for the version where the person meets it, with `trackVariant`: it returns the same version as `getVariant` and records who saw which one, so MRRocket can count the goal they reach later.
|
|
@@ -519,7 +525,7 @@ A running test needs a stable id on the server (the `ck_id` cookie with `consent
|
|
|
519
525
|
|
|
520
526
|
## 18. Messenger (0.9.0)
|
|
521
527
|
|
|
522
|
-
A chat bubble like Featurebase's or Intercom's messenger, with three tabs: **Home** (greeting, "Ask a question", the open conversations, top articles), **Messages** (the chats with your team) and **Help** (your published help articles from Support › Help center, searchable, read in the panel). Every chat is a Support conversation (channel "Chat") in MRRocket's inbox: you answer there, or the Customer experience agent does (Support › Automation › AI answers). A new answer while the panel is closed plays a short sound, shows a count on the bubble and a preview card above it.
|
|
528
|
+
A chat bubble like Featurebase's or Intercom's messenger, with three tabs: **Home** (greeting, "Ask a question", the open conversations, top articles), **Messages** (the chats with your team) and **Help** (your published help articles from Support › Help center by collection, searchable, read in the panel with headings, lists, links, code and, from 0.27.0, tables that scroll sideways inside the article). Every chat is a Support conversation (channel "Chat") in MRRocket's inbox: you answer there, or the Customer experience agent does (Support › Automation › AI answers). A new answer while the panel is closed plays a short sound, shows a count on the bubble and a preview card above it.
|
|
523
529
|
|
|
524
530
|
```tsx
|
|
525
531
|
import { Messenger, useMessenger } from "@mrrocket/sdk/next";
|
package/dist/api-client.d.ts
CHANGED
|
@@ -110,6 +110,8 @@ export interface ChatMessage {
|
|
|
110
110
|
from: "visitor" | "team" | "ai" | "auto";
|
|
111
111
|
body: string;
|
|
112
112
|
at: string;
|
|
113
|
+
/** A team reply's sender, by first name (servers from 2026-11-19 on): "Lukas · Team". */
|
|
114
|
+
name?: string;
|
|
113
115
|
/** Help articles an answer drew on (servers from SDK 0.9 on). */
|
|
114
116
|
articles?: {
|
|
115
117
|
id: string;
|
|
@@ -146,6 +148,15 @@ export type ArticleBlock = {
|
|
|
146
148
|
text: string;
|
|
147
149
|
} | {
|
|
148
150
|
type: "hr";
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* A table (0.27.0): `head` is its first row when it has one (else empty), every row has the same number of cells.
|
|
154
|
+
* Sent only to a widget that asks for it (`article(id, signal, "table")`); every other one gets the rows as a list.
|
|
155
|
+
*/
|
|
156
|
+
| {
|
|
157
|
+
type: "table";
|
|
158
|
+
head: ArticleSpan[][];
|
|
159
|
+
rows: ArticleSpan[][][];
|
|
149
160
|
};
|
|
150
161
|
export interface Article {
|
|
151
162
|
id: string;
|
|
@@ -323,7 +334,11 @@ export declare const createApi: (c: Conn) => {
|
|
|
323
334
|
articles: (q?: string, signal?: AbortSignal) => Promise<{
|
|
324
335
|
articles: ArticleSummary[];
|
|
325
336
|
}>;
|
|
326
|
-
|
|
337
|
+
/**
|
|
338
|
+
* One article as blocks. `blocks` names the newer kinds of block this widget draws ("table", 0.27.0): MRRocket
|
|
339
|
+
* sends those only when asked, so a widget that draws none (older versions, the apps) keeps getting lines of text.
|
|
340
|
+
*/
|
|
341
|
+
article: (id: string, signal?: AbortSignal, blocks?: string) => Promise<Article>;
|
|
327
342
|
messengerLook: (signal?: AbortSignal) => Promise<MessengerLook>;
|
|
328
343
|
rateArticle: (id: string, helpful: boolean) => Promise<{
|
|
329
344
|
counted: boolean;
|
package/dist/api-client.js
CHANGED
|
@@ -117,7 +117,11 @@ var createApi = (c) => {
|
|
|
117
117
|
/** Where a sent file of this visitor's chat is read (an image's src, a PDF's link). */
|
|
118
118
|
attachmentUrl: (id) => `${base}/messages/attachments/${encodeURIComponent(id)}?${qs(me, "")}`,
|
|
119
119
|
articles: (q, signal) => call(`${base}/articles?${qs({ key: c.apiKey, q })}`, void 0, signal),
|
|
120
|
-
|
|
120
|
+
/**
|
|
121
|
+
* One article as blocks. `blocks` names the newer kinds of block this widget draws ("table", 0.27.0): MRRocket
|
|
122
|
+
* sends those only when asked, so a widget that draws none (older versions, the apps) keeps getting lines of text.
|
|
123
|
+
*/
|
|
124
|
+
article: (id, signal, blocks) => call(`${base}/articles/${encodeURIComponent(id)}?${qs({ ...me, blocks })}`, void 0, signal),
|
|
121
125
|
messengerLook: (signal) => call(`${base}/messenger?${qs({ key: c.apiKey })}`, void 0, signal),
|
|
122
126
|
rateArticle: (id, helpful) => post(`/articles/${encodeURIComponent(id)}/rate`, { helpful })
|
|
123
127
|
};
|
package/dist/api-client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api-client.ts"],"sourcesContent":["/**\n * The SDK's fetch client and the shapes it reads, without React, so the script tag's widgets (src/script) use it too.\n * `./api` re-exports all of it with the `useApi` hook.\n */\nimport { warnUnsigned } from \"./identity\";\nimport { currentLocale, t } from \"./i18n\";\n\nexport type PostStatus = \"review\" | \"planned\" | \"progress\" | \"shipped\";\n\n/** Read at the moment it is shown, so it follows the visitor's language. */\nexport const STATUS_LABEL: Record<PostStatus, string> = {\n get review() {\n return t(\"Under review\");\n },\n get planned() {\n return t(\"Planned\");\n },\n get progress() {\n return t(\"In progress\");\n },\n get shipped() {\n return t(\"Shipped\");\n },\n};\n\nexport interface FeedbackBoardInfo {\n id: string;\n label: string;\n}\n\nexport interface FeedbackPost {\n id: string;\n title: string;\n body: string;\n board: string;\n status: PostStatus;\n votes: number;\n comments: number;\n voted: boolean;\n createdAt: string;\n /** \"Lena K.\", \"Anonymous\" or \"Team\". Missing from servers before SDK 0.6. */\n author?: string;\n}\n\n/** The product's public face for the board's header. */\nexport interface FeedbackProduct {\n name: string;\n logo: string | null;\n /** The domain's favicon, tried when `logo` does not load. Older servers leave it out. */\n logoFallback?: string | null;\n}\n\nexport interface FeedbackList {\n boards: FeedbackBoardInfo[];\n posts: FeedbackPost[];\n product?: FeedbackProduct;\n}\n\nexport interface FeedbackRoadmap {\n /** `review` (Backlog) comes from servers of SDK 0.6 on. */\n columns: { review?: FeedbackPost[]; planned: FeedbackPost[]; progress: FeedbackPost[]; shipped: FeedbackPost[] };\n}\n\nexport interface ChangelogEntry {\n id: string;\n title: string;\n body: string;\n publishedAt: string;\n}\n\nexport interface FeedbackComment {\n id: string;\n body: string;\n author: string;\n isTeam: boolean;\n postedAt: string;\n}\n\nexport type SurveyQuestionKind = \"nps\" | \"rating\" | \"single\" | \"multi\" | \"text\";\n\nexport interface SurveyQuestion {\n key: string;\n kind: SurveyQuestionKind;\n title: string;\n description?: string;\n required: boolean;\n options?: string[];\n /**\n * 0.21.0: what each option says in the visitor's language, parallel to `options`. An answer is still recorded as the\n * `options` value, so rules and numbers do not split by language.\n */\n labels?: string[];\n scale?: number;\n low?: string;\n high?: string;\n placeholder?: string;\n}\n\nexport interface SurveyDefinition {\n id: string;\n name: string;\n type: string;\n thanks: string;\n questions: SurveyQuestion[];\n}\n\nexport type SurveyAnswer = number | string | string[];\n\n/** A file in the messenger's chat: a screenshot, a photo or a PDF the visitor sent (servers from SDK 0.15 on). */\nexport interface ChatFile {\n /** From an upload: the signed id a message sends. In a message: the file's own id (`attachmentUrl` reads it). */\n id: string;\n name: string;\n type: \"image/png\" | \"image/jpeg\" | \"image/webp\" | \"image/gif\" | \"application/pdf\";\n /** Bytes. */\n size: number;\n}\n\n/** What the messenger can send: pictures and PDFs, at most 10 MB each, 4 per message. */\nexport const CHAT_FILE_TYPES = [\"image/png\", \"image/jpeg\", \"image/webp\", \"image/gif\", \"application/pdf\"] as const;\nexport const CHAT_FILE_MAX_BYTES = 10 * 1024 * 1024;\nexport const CHAT_FILES_PER_MESSAGE = 4;\n\n/** A file to upload: a Blob or File on the web, the image picker's `{ uri, name, type }` in React Native. */\nexport type ChatUpload = Blob | { uri: string; name: string; type: string };\n\n/** The bug context a visitor message carries; the server fills browser and system from the user agent when left out. */\nexport interface ChatContext {\n browser?: string;\n os?: string;\n /** \"1440×900\". */\n viewport?: string;\n}\n\n/** One message of the messenger's chat. \"visitor\" is the person on the site; the rest come from the product's team. */\nexport interface ChatMessage {\n id: string;\n from: \"visitor\" | \"team\" | \"ai\" | \"auto\";\n body: string;\n at: string;\n /** Help articles an answer drew on (servers from SDK 0.9 on). */\n articles?: { id: string; title: string }[];\n /** Files sent with it (servers from SDK 0.15 on). */\n attachments?: ChatFile[];\n}\n\n/** A published help article in a list (the messenger's Help tab). */\nexport interface ArticleSummary {\n id: string;\n title: string;\n collection: string;\n excerpt: string;\n updatedAt: string;\n}\n\n/** A run of text inside an article block. Links are http(s), mailto or tel only. */\nexport interface ArticleSpan {\n text: string;\n href?: string;\n bold?: boolean;\n italic?: boolean;\n code?: boolean;\n}\n\n/** An article's content as blocks, written with textContent (never parsed as HTML). */\nexport type ArticleBlock =\n | { type: \"h2\" | \"h3\" | \"p\" | \"quote\"; spans: ArticleSpan[] }\n | { type: \"ul\" | \"ol\"; items: ArticleSpan[][] }\n | { type: \"code\"; text: string }\n | { type: \"hr\" };\n\nexport interface Article {\n id: string;\n title: string;\n collection: string;\n updatedAt: string;\n blocks: ArticleBlock[];\n}\n\n/** Where the chat button sits: a corner, the middle of the top or bottom edge, or the middle of a side. */\nexport type MessengerPosition = \"top-left\" | \"top-center\" | \"top-right\" | \"middle-left\" | \"middle-right\" | \"bottom-left\" | \"bottom-center\" | \"bottom-right\";\n\n/** How round the messenger is. */\nexport type MessengerCorners = \"round\" | \"soft\" | \"square\";\n\n/** The radii per corner style, in px: the panel or sheet, message bubbles (and their tail), cards, fields and buttons. */\nexport const CORNERS: Record<MessengerCorners, { panel: number; bubble: number; tail: number; card: number; field: number }> = {\n round: { panel: 22, bubble: 18, tail: 6, card: 16, field: 20 },\n soft: { panel: 14, bubble: 12, tail: 4, card: 10, field: 10 },\n square: { panel: 6, bubble: 6, tail: 2, card: 4, field: 4 },\n};\n\n/** The messenger's look and texts as set in MRRocket › Support › Messenger (servers from SDK 0.9 on). */\nexport interface MessengerLook {\n accent: string;\n /** Up to two more colors blended into Home's background glow (MRRocket from 0.16; older servers leave it out). */\n glow?: string[];\n theme: \"light\" | \"dark\" | \"auto\";\n position: MessengerPosition;\n title: string;\n greeting: string;\n label: string;\n /** How soon the team usually answers (MRRocket from 0.10; older servers leave it out). */\n replyTime?: \"minutes\" | \"hours\" | \"day\";\n /** A round chat button in the app (React Native) too. */\n appLauncher?: boolean;\n help: boolean;\n /** The Updates tab with the published changelog (MRRocket from 0.22; older servers leave it out). */\n updates?: boolean;\n sound: boolean;\n preview: boolean;\n askEmail: boolean;\n /** How round panel, bubbles, cards and fields are (MRRocket from 0.15; older servers leave it out: round). */\n corners?: MessengerCorners;\n /** The site's own font (the default) or the system's (web only; from 0.15). */\n font?: \"site\" | \"system\";\n /** Home's top: plain like the rest, or in the accent color (from 0.15; older servers leave it out: plain). */\n header?: \"plain\" | \"color\";\n /** \"Powered by MRRocket\" at the bottom; the server sends false only on plans that may hide it (from 0.15). */\n branding?: boolean;\n /** The logo at the top left of Home: the one uploaded in MRRocket, else the product's favicon; without it the title's first letter. */\n logo?: string;\n /** The product's favicon, the round mark in the chat's head (from 0.17; without it the title's first letter). */\n icon?: string;\n /** The AI agent's name on its answers (from 0.17; empty or left out: \"AI agent\"). */\n agentName?: string;\n /** The AI agent's picture beside its answers (from 0.17). */\n agentPhoto?: string;\n}\n\n/** The link behind \"Powered by MRRocket\". */\nexport const BRAND_URL = \"https://mrrocket.dev/?utm_source=messenger&utm_medium=powered-by\";\n\n/** The line under \"Send us a message\" and in the chat's head. */\nexport const replyLine = (time: MessengerLook[\"replyTime\"]) =>\n time === \"minutes\" ? t(\"We usually reply in a few minutes\") : time === \"day\" ? t(\"We usually reply within a day\") : t(\"We usually reply in a few hours\");\n\n/** Black or white, whichever reads better on the accent (a light custom color gets dark text). */\nexport const inkOn = (hex: string) => {\n const m = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(hex);\n if (!m) return \"#ffffff\";\n const [r, g, b] = [m[1], m[2], m[3]].map((x) => {\n const c = parseInt(x, 16) / 255;\n return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n });\n return 0.2126 * r + 0.7152 * g + 0.0722 * b > 0.45 ? \"#111214\" : \"#ffffff\";\n};\n\n/** One of the visitor's conversations in their list (0.19). */\nexport interface ChatSummary {\n id: string;\n status: \"open\" | \"solved\";\n /** The visitor's first words. */\n subject: string;\n /** The newest message, its body cut to a preview. */\n last: ChatMessage | null;\n /** Up to when the visitor read it, on any device (servers from 0.24.0). */\n seenAt?: string;\n}\n\n/** One chat (the one asked for, else the visitor's newest, open or closed) and its messages. */\nexport interface ChatThread {\n conversation: { id: string; status: \"open\" | \"solved\"; seenAt?: string } | null;\n messages: ChatMessage[];\n /** All the visitor's conversations, the latest activity first (0.19). */\n conversations?: ChatSummary[];\n /** The visitor gave an email already: the messenger stops asking. */\n hasEmail: boolean;\n}\n\n/**\n * For the count and the preview of unread answers, after a read: an answer the team took back and a conversation it\n * archived leave them. Of a conversation that is not on screen the list brings only the newest message, so an answer\n * newer than that one is gone.\n */\nexport const stillThere = (t: ChatThread, chats: ChatSummary[]) => (m: { id: string; at: string; chat: string }) => {\n if (m.chat === t.conversation?.id) return t.messages.some((x) => x.id === m.id);\n const last = chats.find((c) => c.id === m.chat)?.last;\n return !!last && m.at <= last.at;\n};\n\nexport class ApiError extends Error {\n status: number;\n constructor(message: string, status: number) {\n super(message);\n this.status = status;\n }\n}\n\ninterface Conn {\n host: string;\n apiKey: string;\n distinctId: string;\n user?: { id?: string; [key: string]: unknown };\n /**\n * The identity hash of `distinctId` (0.16.0, see identity.ts), sent with every request that names the visitor: a\n * JSON field next to `distinctId`, a query parameter, a form field. Leave it out for any other id.\n */\n userHash?: string;\n}\n\n// Not URLSearchParams: React Native's lacks `set` in older versions, and the apps use this client too.\n// `lang` goes along so the answer's words can be in the visitor's language; \"\" leaves it out.\nconst qs = (params: Record<string, string | undefined>, lang = currentLocale()) =>\n Object.entries({ ...params, lang })\n .filter((e): e is [string, string] => !!e[1])\n .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)\n .join(\"&\");\n\n/** A POST's address: its body names the visitor, the query only the language of the words in its answer. */\nconst withLang = (url: string) => {\n const q = qs({});\n return q ? `${url}?${q}` : url;\n};\n\nconst call = async <T>(url: string, init: RequestInit | undefined, signal?: AbortSignal): Promise<T> => {\n let res: Response;\n try {\n res = await fetch(url, {\n ...init,\n signal,\n // A form (a file upload) sets its own multipart type with the boundary.\n headers: typeof init?.body === \"string\" ? { \"content-type\": \"application/json\" } : undefined,\n });\n } catch (e) {\n if ((e as Error).name === \"AbortError\") throw e;\n throw new ApiError(t(\"Could not reach the server. Check your connection and try again.\"), 0);\n }\n if (!res.ok) {\n // A missing or wrong identity hash: the console says once how to sign the user id.\n warnUnsigned(res.status);\n let detail = \"\";\n try {\n detail = ((await res.json()) as { error?: string }).error ?? \"\";\n } catch {\n // Not JSON; the status is enough.\n }\n throw new ApiError(detail || (res.status === 429 ? t(\"Too many requests. Try again in a minute.\") : t(\"Something went wrong. Please try again.\")), res.status);\n }\n return (await res.json()) as T;\n};\n\n/** The small fetch client behind the widgets. Every read takes an AbortSignal so unmounting cancels it. */\nexport const createApi = (c: Conn) => {\n const base = `${c.host}/api/sdk`;\n const who = { key: c.apiKey, distinctId: c.distinctId, user: c.user, userHash: c.userHash };\n // Every query that names the visitor names its hash too.\n const me = { key: c.apiKey, distinctId: c.distinctId, userHash: c.userHash };\n const post = <T>(path: string, body: Record<string, unknown>, signal?: AbortSignal) =>\n call<T>(withLang(`${base}${path}`), { method: \"POST\", body: JSON.stringify({ ...who, ...body }) }, signal);\n return {\n list: (o: { board?: string; sort?: \"top\" | \"new\"; q?: string }, signal?: AbortSignal) =>\n call<FeedbackList>(`${base}/feedback?${qs({ ...me, board: o.board, sort: o.sort, q: o.q })}`, undefined, signal),\n post: (id: string, signal?: AbortSignal) =>\n call<FeedbackPost>(`${base}/feedback/${encodeURIComponent(id)}?${qs(me)}`, undefined, signal),\n roadmap: (signal?: AbortSignal) => call<FeedbackRoadmap>(`${base}/feedback/roadmap?${qs(me)}`, undefined, signal),\n changelog: (signal?: AbortSignal) => call<{ entries: ChangelogEntry[] }>(`${base}/feedback/changelog?${qs({ key: c.apiKey })}`, undefined, signal),\n submit: (p: { title: string; body?: string; board: string }) => post<FeedbackPost>(\"/feedback\", p),\n vote: (id: string) => post<{ voted: boolean; votes: number }>(`/feedback/${encodeURIComponent(id)}/vote`, {}),\n comments: (id: string, signal?: AbortSignal) =>\n call<{ comments: FeedbackComment[] }>(`${base}/feedback/${encodeURIComponent(id)}/comments?${qs({ key: c.apiKey })}`, undefined, signal),\n comment: (id: string, body: string) => post<FeedbackComment>(`/feedback/${encodeURIComponent(id)}/comments`, { body }),\n survey: (url: string, signal?: AbortSignal) =>\n call<{ survey: SurveyDefinition | null }>(`${base}/surveys?${qs({ ...me, url })}`, undefined, signal),\n seen: (id: string) => post<unknown>(`/surveys/${encodeURIComponent(id)}/seen`, { user: undefined }),\n respond: (id: string, r: { answers: Record<string, SurveyAnswer>; completed: boolean; seconds: number }) =>\n post<unknown>(`/surveys/${encodeURIComponent(id)}/respond`, r),\n /**\n * One chat by id, else the visitor's newest; `conversations` lists them all. `aiLabel`: the messenger says \"AI agent\"\n * beside an answer's name, so the answer comes without its AI notice line (from 0.22.0).\n */\n chat: (signal?: AbortSignal, conversation?: string) => call<ChatThread>(`${base}/messages?${qs({ ...me, conversation, aiLabel: \"1\" })}`, undefined, signal),\n /**\n * A message; `attachments` are upload ids from `uploadChatFile` (then the body may be empty). `conversation` is\n * the chat it answers, or \"new\" to start one; without it, the running chat or else a new one.\n */\n sendChat: (m: { body: string; conversation?: string; email?: string; url?: string; attachments?: string[]; context?: ChatContext }) => post<ChatThread>(\"/messages\", { ...m, aiLabel: true }),\n /** The visitor read a chat up to `at` (the newest message they saw): MRRocket counts it read on every device and shows \"Seen\" to the team (0.24.0). */\n seenChat: (conversation: string, at: string) => post<{ seenAt: string | null }>(\"/messages/seen\", { conversation, at, user: undefined }),\n /** Uploads one picked file for the next message (pictures and PDFs, at most 10 MB); answers its upload id. */\n uploadChatFile: (file: ChatUpload, signal?: AbortSignal) => {\n const form = new FormData();\n form.append(\"key\", c.apiKey);\n form.append(\"distinctId\", c.distinctId);\n if (c.userHash) form.append(\"userHash\", c.userHash);\n if (\"uri\" in file) form.append(\"file\", file as unknown as Blob);\n else form.append(\"file\", file, (file as Blob & { name?: string }).name || \"file\");\n return call<ChatFile>(withLang(`${base}/messages/attachments`), { method: \"POST\", body: form }, signal);\n },\n /** Where a sent file of this visitor's chat is read (an image's src, a PDF's link). */\n attachmentUrl: (id: string) => `${base}/messages/attachments/${encodeURIComponent(id)}?${qs(me, \"\")}`,\n articles: (q?: string, signal?: AbortSignal) => call<{ articles: ArticleSummary[] }>(`${base}/articles?${qs({ key: c.apiKey, q })}`, undefined, signal),\n article: (id: string, signal?: AbortSignal) =>\n call<Article>(`${base}/articles/${encodeURIComponent(id)}?${qs(me)}`, undefined, signal),\n messengerLook: (signal?: AbortSignal) => call<MessengerLook>(`${base}/messenger?${qs({ key: c.apiKey })}`, undefined, signal),\n rateArticle: (id: string, helpful: boolean) => post<{ counted: boolean }>(`/articles/${encodeURIComponent(id)}/rate`, { helpful }),\n };\n};\n\nexport type Api = ReturnType<typeof createApi>;\n"],"mappings":";AAIA,SAAS,oBAAoB;AAC7B,SAAS,eAAe,SAAS;AAK1B,IAAM,eAA2C;AAAA,EACpD,IAAI,SAAS;AACT,WAAO,EAAE,cAAc;AAAA,EAC3B;AAAA,EACA,IAAI,UAAU;AACV,WAAO,EAAE,SAAS;AAAA,EACtB;AAAA,EACA,IAAI,WAAW;AACX,WAAO,EAAE,aAAa;AAAA,EAC1B;AAAA,EACA,IAAI,UAAU;AACV,WAAO,EAAE,SAAS;AAAA,EACtB;AACJ;AAgGO,IAAM,kBAAkB,CAAC,aAAa,cAAc,cAAc,aAAa,iBAAiB;AAChG,IAAM,sBAAsB,KAAK,OAAO;AACxC,IAAM,yBAAyB;AAiE/B,IAAM,UAAkH;AAAA,EAC3H,OAAO,EAAE,OAAO,IAAI,QAAQ,IAAI,MAAM,GAAG,MAAM,IAAI,OAAO,GAAG;AAAA,EAC7D,MAAM,EAAE,OAAO,IAAI,QAAQ,IAAI,MAAM,GAAG,MAAM,IAAI,OAAO,GAAG;AAAA,EAC5D,QAAQ,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG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,aAAa,CAAC,IAAY,YAAqB,KAA2B,aAAa,mBAAmB,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;AAAA,EACrI;AACJ;","names":["t"]}
|
|
1
|
+
{"version":3,"sources":["../src/api-client.ts"],"sourcesContent":["/**\n * The SDK's fetch client and the shapes it reads, without React, so the script tag's widgets (src/script) use it too.\n * `./api` re-exports all of it with the `useApi` hook.\n */\nimport { warnUnsigned } from \"./identity\";\nimport { currentLocale, t } from \"./i18n\";\n\nexport type PostStatus = \"review\" | \"planned\" | \"progress\" | \"shipped\";\n\n/** Read at the moment it is shown, so it follows the visitor's language. */\nexport const STATUS_LABEL: Record<PostStatus, string> = {\n get review() {\n return t(\"Under review\");\n },\n get planned() {\n return t(\"Planned\");\n },\n get progress() {\n return t(\"In progress\");\n },\n get shipped() {\n return t(\"Shipped\");\n },\n};\n\nexport interface FeedbackBoardInfo {\n id: string;\n label: string;\n}\n\nexport interface FeedbackPost {\n id: string;\n title: string;\n body: string;\n board: string;\n status: PostStatus;\n votes: number;\n comments: number;\n voted: boolean;\n createdAt: string;\n /** \"Lena K.\", \"Anonymous\" or \"Team\". Missing from servers before SDK 0.6. */\n author?: string;\n}\n\n/** The product's public face for the board's header. */\nexport interface FeedbackProduct {\n name: string;\n logo: string | null;\n /** The domain's favicon, tried when `logo` does not load. Older servers leave it out. */\n logoFallback?: string | null;\n}\n\nexport interface FeedbackList {\n boards: FeedbackBoardInfo[];\n posts: FeedbackPost[];\n product?: FeedbackProduct;\n}\n\nexport interface FeedbackRoadmap {\n /** `review` (Backlog) comes from servers of SDK 0.6 on. */\n columns: { review?: FeedbackPost[]; planned: FeedbackPost[]; progress: FeedbackPost[]; shipped: FeedbackPost[] };\n}\n\nexport interface ChangelogEntry {\n id: string;\n title: string;\n body: string;\n publishedAt: string;\n}\n\nexport interface FeedbackComment {\n id: string;\n body: string;\n author: string;\n isTeam: boolean;\n postedAt: string;\n}\n\nexport type SurveyQuestionKind = \"nps\" | \"rating\" | \"single\" | \"multi\" | \"text\";\n\nexport interface SurveyQuestion {\n key: string;\n kind: SurveyQuestionKind;\n title: string;\n description?: string;\n required: boolean;\n options?: string[];\n /**\n * 0.21.0: what each option says in the visitor's language, parallel to `options`. An answer is still recorded as the\n * `options` value, so rules and numbers do not split by language.\n */\n labels?: string[];\n scale?: number;\n low?: string;\n high?: string;\n placeholder?: string;\n}\n\nexport interface SurveyDefinition {\n id: string;\n name: string;\n type: string;\n thanks: string;\n questions: SurveyQuestion[];\n}\n\nexport type SurveyAnswer = number | string | string[];\n\n/** A file in the messenger's chat: a screenshot, a photo or a PDF the visitor sent (servers from SDK 0.15 on). */\nexport interface ChatFile {\n /** From an upload: the signed id a message sends. In a message: the file's own id (`attachmentUrl` reads it). */\n id: string;\n name: string;\n type: \"image/png\" | \"image/jpeg\" | \"image/webp\" | \"image/gif\" | \"application/pdf\";\n /** Bytes. */\n size: number;\n}\n\n/** What the messenger can send: pictures and PDFs, at most 10 MB each, 4 per message. */\nexport const CHAT_FILE_TYPES = [\"image/png\", \"image/jpeg\", \"image/webp\", \"image/gif\", \"application/pdf\"] as const;\nexport const CHAT_FILE_MAX_BYTES = 10 * 1024 * 1024;\nexport const CHAT_FILES_PER_MESSAGE = 4;\n\n/** A file to upload: a Blob or File on the web, the image picker's `{ uri, name, type }` in React Native. */\nexport type ChatUpload = Blob | { uri: string; name: string; type: string };\n\n/** The bug context a visitor message carries; the server fills browser and system from the user agent when left out. */\nexport interface ChatContext {\n browser?: string;\n os?: string;\n /** \"1440×900\". */\n viewport?: string;\n}\n\n/** One message of the messenger's chat. \"visitor\" is the person on the site; the rest come from the product's team. */\nexport interface ChatMessage {\n id: string;\n from: \"visitor\" | \"team\" | \"ai\" | \"auto\";\n body: string;\n at: string;\n /** A team reply's sender, by first name (servers from 2026-11-19 on): \"Lukas · Team\". */\n name?: string;\n /** Help articles an answer drew on (servers from SDK 0.9 on). */\n articles?: { id: string; title: string }[];\n /** Files sent with it (servers from SDK 0.15 on). */\n attachments?: ChatFile[];\n}\n\n/** A published help article in a list (the messenger's Help tab). */\nexport interface ArticleSummary {\n id: string;\n title: string;\n collection: string;\n excerpt: string;\n updatedAt: string;\n}\n\n/** A run of text inside an article block. Links are http(s), mailto or tel only. */\nexport interface ArticleSpan {\n text: string;\n href?: string;\n bold?: boolean;\n italic?: boolean;\n code?: boolean;\n}\n\n/** An article's content as blocks, written with textContent (never parsed as HTML). */\nexport type ArticleBlock =\n | { type: \"h2\" | \"h3\" | \"p\" | \"quote\"; spans: ArticleSpan[] }\n | { type: \"ul\" | \"ol\"; items: ArticleSpan[][] }\n | { type: \"code\"; text: string }\n | { type: \"hr\" }\n /**\n * A table (0.27.0): `head` is its first row when it has one (else empty), every row has the same number of cells.\n * Sent only to a widget that asks for it (`article(id, signal, \"table\")`); every other one gets the rows as a list.\n */\n | { type: \"table\"; head: ArticleSpan[][]; rows: ArticleSpan[][][] };\n\nexport interface Article {\n id: string;\n title: string;\n collection: string;\n updatedAt: string;\n blocks: ArticleBlock[];\n}\n\n/** Where the chat button sits: a corner, the middle of the top or bottom edge, or the middle of a side. */\nexport type MessengerPosition = \"top-left\" | \"top-center\" | \"top-right\" | \"middle-left\" | \"middle-right\" | \"bottom-left\" | \"bottom-center\" | \"bottom-right\";\n\n/** How round the messenger is. */\nexport type MessengerCorners = \"round\" | \"soft\" | \"square\";\n\n/** The radii per corner style, in px: the panel or sheet, message bubbles (and their tail), cards, fields and buttons. */\nexport const CORNERS: Record<MessengerCorners, { panel: number; bubble: number; tail: number; card: number; field: number }> = {\n round: { panel: 22, bubble: 18, tail: 6, card: 16, field: 20 },\n soft: { panel: 14, bubble: 12, tail: 4, card: 10, field: 10 },\n square: { panel: 6, bubble: 6, tail: 2, card: 4, field: 4 },\n};\n\n/** The messenger's look and texts as set in MRRocket › Support › Messenger (servers from SDK 0.9 on). */\nexport interface MessengerLook {\n accent: string;\n /** Up to two more colors blended into Home's background glow (MRRocket from 0.16; older servers leave it out). */\n glow?: string[];\n theme: \"light\" | \"dark\" | \"auto\";\n position: MessengerPosition;\n title: string;\n greeting: string;\n label: string;\n /** How soon the team usually answers (MRRocket from 0.10; older servers leave it out). */\n replyTime?: \"minutes\" | \"hours\" | \"day\";\n /** A round chat button in the app (React Native) too. */\n appLauncher?: boolean;\n help: boolean;\n /** The Updates tab with the published changelog (MRRocket from 0.22; older servers leave it out). */\n updates?: boolean;\n sound: boolean;\n preview: boolean;\n askEmail: boolean;\n /** How round panel, bubbles, cards and fields are (MRRocket from 0.15; older servers leave it out: round). */\n corners?: MessengerCorners;\n /** The site's own font (the default) or the system's (web only; from 0.15). */\n font?: \"site\" | \"system\";\n /** Home's top: plain like the rest, or in the accent color (from 0.15; older servers leave it out: plain). */\n header?: \"plain\" | \"color\";\n /** \"Powered by MRRocket\" at the bottom; the server sends false only on plans that may hide it (from 0.15). */\n branding?: boolean;\n /** The logo at the top left of Home: the one uploaded in MRRocket, else the product's favicon; without it the title's first letter. */\n logo?: string;\n /** The product's favicon, the round mark in the chat's head (from 0.17; without it the title's first letter). */\n icon?: string;\n /** The AI agent's name on its answers (from 0.17; empty or left out: \"AI agent\"). */\n agentName?: string;\n /** The AI agent's picture beside its answers (from 0.17). */\n agentPhoto?: string;\n}\n\n/** The link behind \"Powered by MRRocket\". */\nexport const BRAND_URL = \"https://mrrocket.dev/?utm_source=messenger&utm_medium=powered-by\";\n\n/** The line under \"Send us a message\" and in the chat's head. */\nexport const replyLine = (time: MessengerLook[\"replyTime\"]) =>\n time === \"minutes\" ? t(\"We usually reply in a few minutes\") : time === \"day\" ? t(\"We usually reply within a day\") : t(\"We usually reply in a few hours\");\n\n/** Black or white, whichever reads better on the accent (a light custom color gets dark text). */\nexport const inkOn = (hex: string) => {\n const m = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(hex);\n if (!m) return \"#ffffff\";\n const [r, g, b] = [m[1], m[2], m[3]].map((x) => {\n const c = parseInt(x, 16) / 255;\n return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n });\n return 0.2126 * r + 0.7152 * g + 0.0722 * b > 0.45 ? \"#111214\" : \"#ffffff\";\n};\n\n/** One of the visitor's conversations in their list (0.19). */\nexport interface ChatSummary {\n id: string;\n status: \"open\" | \"solved\";\n /** The visitor's first words. */\n subject: string;\n /** The newest message, its body cut to a preview. */\n last: ChatMessage | null;\n /** Up to when the visitor read it, on any device (servers from 0.24.0). */\n seenAt?: string;\n}\n\n/** One chat (the one asked for, else the visitor's newest, open or closed) and its messages. */\nexport interface ChatThread {\n conversation: { id: string; status: \"open\" | \"solved\"; seenAt?: string } | null;\n messages: ChatMessage[];\n /** All the visitor's conversations, the latest activity first (0.19). */\n conversations?: ChatSummary[];\n /** The visitor gave an email already: the messenger stops asking. */\n hasEmail: boolean;\n}\n\n/**\n * For the count and the preview of unread answers, after a read: an answer the team took back and a conversation it\n * archived leave them. Of a conversation that is not on screen the list brings only the newest message, so an answer\n * newer than that one is gone.\n */\nexport const stillThere = (t: ChatThread, chats: ChatSummary[]) => (m: { id: string; at: string; chat: string }) => {\n if (m.chat === t.conversation?.id) return t.messages.some((x) => x.id === m.id);\n const last = chats.find((c) => c.id === m.chat)?.last;\n return !!last && m.at <= last.at;\n};\n\nexport class ApiError extends Error {\n status: number;\n constructor(message: string, status: number) {\n super(message);\n this.status = status;\n }\n}\n\ninterface Conn {\n host: string;\n apiKey: string;\n distinctId: string;\n user?: { id?: string; [key: string]: unknown };\n /**\n * The identity hash of `distinctId` (0.16.0, see identity.ts), sent with every request that names the visitor: a\n * JSON field next to `distinctId`, a query parameter, a form field. Leave it out for any other id.\n */\n userHash?: string;\n}\n\n// Not URLSearchParams: React Native's lacks `set` in older versions, and the apps use this client too.\n// `lang` goes along so the answer's words can be in the visitor's language; \"\" leaves it out.\nconst qs = (params: Record<string, string | undefined>, lang = currentLocale()) =>\n Object.entries({ ...params, lang })\n .filter((e): e is [string, string] => !!e[1])\n .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)\n .join(\"&\");\n\n/** A POST's address: its body names the visitor, the query only the language of the words in its answer. */\nconst withLang = (url: string) => {\n const q = qs({});\n return q ? `${url}?${q}` : url;\n};\n\nconst call = async <T>(url: string, init: RequestInit | undefined, signal?: AbortSignal): Promise<T> => {\n let res: Response;\n try {\n res = await fetch(url, {\n ...init,\n signal,\n // A form (a file upload) sets its own multipart type with the boundary.\n headers: typeof init?.body === \"string\" ? { \"content-type\": \"application/json\" } : undefined,\n });\n } catch (e) {\n if ((e as Error).name === \"AbortError\") throw e;\n throw new ApiError(t(\"Could not reach the server. Check your connection and try again.\"), 0);\n }\n if (!res.ok) {\n // A missing or wrong identity hash: the console says once how to sign the user id.\n warnUnsigned(res.status);\n let detail = \"\";\n try {\n detail = ((await res.json()) as { error?: string }).error ?? \"\";\n } catch {\n // Not JSON; the status is enough.\n }\n throw new ApiError(detail || (res.status === 429 ? t(\"Too many requests. Try again in a minute.\") : t(\"Something went wrong. Please try again.\")), res.status);\n }\n return (await res.json()) as T;\n};\n\n/** The small fetch client behind the widgets. Every read takes an AbortSignal so unmounting cancels it. */\nexport const createApi = (c: Conn) => {\n const base = `${c.host}/api/sdk`;\n const who = { key: c.apiKey, distinctId: c.distinctId, user: c.user, userHash: c.userHash };\n // Every query that names the visitor names its hash too.\n const me = { key: c.apiKey, distinctId: c.distinctId, userHash: c.userHash };\n const post = <T>(path: string, body: Record<string, unknown>, signal?: AbortSignal) =>\n call<T>(withLang(`${base}${path}`), { method: \"POST\", body: JSON.stringify({ ...who, ...body }) }, signal);\n return {\n list: (o: { board?: string; sort?: \"top\" | \"new\"; q?: string }, signal?: AbortSignal) =>\n call<FeedbackList>(`${base}/feedback?${qs({ ...me, board: o.board, sort: o.sort, q: o.q })}`, undefined, signal),\n post: (id: string, signal?: AbortSignal) =>\n call<FeedbackPost>(`${base}/feedback/${encodeURIComponent(id)}?${qs(me)}`, undefined, signal),\n roadmap: (signal?: AbortSignal) => call<FeedbackRoadmap>(`${base}/feedback/roadmap?${qs(me)}`, undefined, signal),\n changelog: (signal?: AbortSignal) => call<{ entries: ChangelogEntry[] }>(`${base}/feedback/changelog?${qs({ key: c.apiKey })}`, undefined, signal),\n submit: (p: { title: string; body?: string; board: string }) => post<FeedbackPost>(\"/feedback\", p),\n vote: (id: string) => post<{ voted: boolean; votes: number }>(`/feedback/${encodeURIComponent(id)}/vote`, {}),\n comments: (id: string, signal?: AbortSignal) =>\n call<{ comments: FeedbackComment[] }>(`${base}/feedback/${encodeURIComponent(id)}/comments?${qs({ key: c.apiKey })}`, undefined, signal),\n comment: (id: string, body: string) => post<FeedbackComment>(`/feedback/${encodeURIComponent(id)}/comments`, { body }),\n survey: (url: string, signal?: AbortSignal) =>\n call<{ survey: SurveyDefinition | null }>(`${base}/surveys?${qs({ ...me, url })}`, undefined, signal),\n seen: (id: string) => post<unknown>(`/surveys/${encodeURIComponent(id)}/seen`, { user: undefined }),\n respond: (id: string, r: { answers: Record<string, SurveyAnswer>; completed: boolean; seconds: number }) =>\n post<unknown>(`/surveys/${encodeURIComponent(id)}/respond`, r),\n /**\n * One chat by id, else the visitor's newest; `conversations` lists them all. `aiLabel`: the messenger says \"AI agent\"\n * beside an answer's name, so the answer comes without its AI notice line (from 0.22.0).\n */\n chat: (signal?: AbortSignal, conversation?: string) => call<ChatThread>(`${base}/messages?${qs({ ...me, conversation, aiLabel: \"1\" })}`, undefined, signal),\n /**\n * A message; `attachments` are upload ids from `uploadChatFile` (then the body may be empty). `conversation` is\n * the chat it answers, or \"new\" to start one; without it, the running chat or else a new one.\n */\n sendChat: (m: { body: string; conversation?: string; email?: string; url?: string; attachments?: string[]; context?: ChatContext }) => post<ChatThread>(\"/messages\", { ...m, aiLabel: true }),\n /** The visitor read a chat up to `at` (the newest message they saw): MRRocket counts it read on every device and shows \"Seen\" to the team (0.24.0). */\n seenChat: (conversation: string, at: string) => post<{ seenAt: string | null }>(\"/messages/seen\", { conversation, at, user: undefined }),\n /** Uploads one picked file for the next message (pictures and PDFs, at most 10 MB); answers its upload id. */\n uploadChatFile: (file: ChatUpload, signal?: AbortSignal) => {\n const form = new FormData();\n form.append(\"key\", c.apiKey);\n form.append(\"distinctId\", c.distinctId);\n if (c.userHash) form.append(\"userHash\", c.userHash);\n if (\"uri\" in file) form.append(\"file\", file as unknown as Blob);\n else form.append(\"file\", file, (file as Blob & { name?: string }).name || \"file\");\n return call<ChatFile>(withLang(`${base}/messages/attachments`), { method: \"POST\", body: form }, signal);\n },\n /** Where a sent file of this visitor's chat is read (an image's src, a PDF's link). */\n attachmentUrl: (id: string) => `${base}/messages/attachments/${encodeURIComponent(id)}?${qs(me, \"\")}`,\n articles: (q?: string, signal?: AbortSignal) => call<{ articles: ArticleSummary[] }>(`${base}/articles?${qs({ key: c.apiKey, q })}`, undefined, signal),\n /**\n * One article as blocks. `blocks` names the newer kinds of block this widget draws (\"table\", 0.27.0): MRRocket\n * sends those only when asked, so a widget that draws none (older versions, the apps) keeps getting lines of text.\n */\n article: (id: string, signal?: AbortSignal, blocks?: string) =>\n call<Article>(`${base}/articles/${encodeURIComponent(id)}?${qs({ ...me, blocks })}`, undefined, signal),\n messengerLook: (signal?: AbortSignal) => call<MessengerLook>(`${base}/messenger?${qs({ key: c.apiKey })}`, undefined, signal),\n rateArticle: (id: string, helpful: boolean) => post<{ counted: boolean }>(`/articles/${encodeURIComponent(id)}/rate`, { helpful }),\n };\n};\n\nexport type Api = ReturnType<typeof createApi>;\n"],"mappings":";AAIA,SAAS,oBAAoB;AAC7B,SAAS,eAAe,SAAS;AAK1B,IAAM,eAA2C;AAAA,EACpD,IAAI,SAAS;AACT,WAAO,EAAE,cAAc;AAAA,EAC3B;AAAA,EACA,IAAI,UAAU;AACV,WAAO,EAAE,SAAS;AAAA,EACtB;AAAA,EACA,IAAI,WAAW;AACX,WAAO,EAAE,aAAa;AAAA,EAC1B;AAAA,EACA,IAAI,UAAU;AACV,WAAO,EAAE,SAAS;AAAA,EACtB;AACJ;AAgGO,IAAM,kBAAkB,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,GAAY,WAAyB,KAAqC,GAAG,IAAI,aAAa,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,IAAI,QAAW,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,IAKtJ,SAAS,CAAC,IAAY,QAAsB,WACxC,KAAc,GAAG,IAAI,aAAa,mBAAmB,EAAE,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,OAAO,CAAC,CAAC,IAAI,QAAW,MAAM;AAAA,IAC1G,eAAe,CAAC,WAAyB,KAAoB,GAAG,IAAI,cAAc,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,QAAW,MAAM;AAAA,IAC5H,aAAa,CAAC,IAAY,YAAqB,KAA2B,aAAa,mBAAmB,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;AAAA,EACrI;AACJ;","names":["t"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){'use strict';var
|
|
1
|
+
(function(){'use strict';var Pe=()=>{try{return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}catch(e){return false}},ae=["#f59e0b","#10b981","#ef4444","#8b5cf6","#06b6d4","#ec4899"],Fe=(e,t)=>{e.beginPath();for(let r=0;r<10;r++){let a=Math.PI/5*r-Math.PI/2,i=r%2?t*.45:t;e[r?"lineTo":"moveTo"](Math.cos(a)*i,Math.sin(a)*i);}e.closePath(),e.fill();},Se=(e,t,r,a)=>{let i=(d,w)=>d+Math.random()*(w-d),p=()=>a[Math.floor(Math.random()*a.length)],m=[];if(e==="confetti")for(let d=0;d<110;d++){let w=d%2===0;m.push({x:w?t*.15:t*.85,y:r*.95,vx:(w?1:-1)*i(.12,.42)*(t/900+.4),vy:-i(.75,1.25)*(r/900+.35),r:i(4,7),spin:i(-0.02,.02),angle:i(0,Math.PI),color:p(),born:i(0,180),life:i(1500,2100),shape:"rect"});}else if(e==="fireworks")for(let d=0;d<4;d++){let w=i(t*.2,t*.8),c=i(r*.18,r*.5),x=p();for(let h=0;h<46;h++){let M=Math.PI*2*h/46+i(-0.05,.05),F=i(.12,.3)*(Math.min(t,r)/600+.5);m.push({x:w,y:c,vx:Math.cos(M)*F,vy:Math.sin(M)*F,r:i(1.6,2.6),spin:0,angle:0,color:x,born:d*320,life:i(900,1300),shape:"dot"});}}else for(let d=0;d<34;d++)m.push({x:i(t*.08,t*.92),y:i(r*.2,r*.85),vx:0,vy:-i(.02,.06),r:i(6,13),spin:i(-4e-3,.004),angle:i(0,Math.PI),color:p(),born:i(0,700),life:i(900,1300),shape:"star"});return m},ce=(e,t={})=>{if(!e||e==="none"||typeof document=="undefined"||!t.force&&Pe())return ()=>{};let r=document.createElement("canvas");r.setAttribute("aria-hidden","true");let a=t.host;r.style.cssText=a?"position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:5":"position:fixed;inset:0;width:100vw;height:100vh;pointer-events:none;z-index:2147483003",(a!=null?a:document.body).appendChild(r);let i=a?a.clientWidth:window.innerWidth,p=a?a.clientHeight:window.innerHeight,m=Math.min(2,window.devicePixelRatio||1);r.width=Math.max(1,Math.round(i*m)),r.height=Math.max(1,Math.round(p*m));let d=r.getContext("2d");if(!d)return r.remove(),()=>{};let w=t.accent?[t.accent,t.accent,...ae]:ae,c=Se(e,i,p,w),x=Math.max(...c.map(H=>H.born+H.life)),h=e==="confetti"?.0016:e==="fireworks"?35e-5:0,M=0,F=0,V=false,T=()=>{V||(V=true,cancelAnimationFrame(M),r.remove());},O=H=>{if(V)return;F||(F=H);let z=H-F;d.setTransform(m,0,0,m,0,0),d.clearRect(0,0,i,p);for(let y of c){let P=z-y.born;if(P<0||P>y.life)continue;let K=y.x+y.vx*P,R=y.y+y.vy*P+.5*h*P*P,o=Math.min(1,(y.life-P)/350);if(d.save(),d.globalAlpha=Math.max(0,o),d.translate(K,R),d.rotate(y.angle+y.spin*P),d.fillStyle=y.color,y.shape==="rect")d.fillRect(-y.r,-y.r/2.2,y.r*2,y.r/1.1);else if(y.shape==="dot")d.beginPath(),d.arc(0,0,y.r,0,Math.PI*2),d.fill();else {let s=Math.min(1,P/220);Fe(d,y.r*(s<1?s:1-Math.max(0,(P-y.life*.6)/(y.life*.4))*.6));}d.restore();}z<x?M=requestAnimationFrame(O):T();};return M=requestAnimationFrame(O),T};var Y=globalThis,le,q=(le=Y.__mrrocketI18n)!=null?le:Y.__mrrocketI18n={version:0,onWords:new Set,onLocale:new Set};var f=e=>{var t;return ((t=q.words)==null?void 0:t[e])||e},L=(e,t)=>f(e).replace(/\{(\w+)\}/g,(r,a)=>a in t?String(t[a]):r);var de=()=>{var e,t;return (t=(e=q.locale)!=null?e:q.device)!=null?t:typeof navigator!="undefined"&&navigator.language||void 0};var fe=()=>q.lang;var J=e=>(q.onWords.add(e),()=>{q.onWords.delete(e);});var W="other:",X=e=>{var a,i;let t=(a=e==null?void 0:e.min)!=null?a:0,r=(i=e==null?void 0:e.max)!=null?i:10;return Array.from({length:Math.max(0,Math.min(r-t,20)+1)},(p,m)=>t+m)},pe=(e,t)=>{var r;return !e||t==null?false:e.type==="choice"?e.other&&t.startsWith(W)?t.slice(W.length).trim().length>0:((r=e.options)!=null?r:[]).some(a=>a.id===t):e.type==="scale"?X(e).some(a=>String(a)===t):t.trim().length>0&&t.length<=500};var Q=e=>{let t=(e!=null?e:"").trim();if(!/^https?:\/\//i.test(t))return null;let r=t.match(/^https?:\/\/(?:www\.|m\.)?(?:youtube\.com\/(?:watch\?(?:.*&)?v=|embed\/|shorts\/|live\/)|youtu\.be\/|youtube-nocookie\.com\/embed\/)([\w-]{6,20})/i);return r?{kind:"iframe",src:`https://www.youtube-nocookie.com/embed/${r[1]}?rel=0`}:(r=t.match(/^https?:\/\/(?:www\.|player\.)?vimeo\.com\/(?:video\/)?(\d{4,12})/i),r?{kind:"iframe",src:`https://player.vimeo.com/video/${r[1]}?dnt=1`}:(r=t.match(/^https?:\/\/(?:www\.)?loom\.com\/(?:share|embed)\/([\w-]{8,64})/i),r?{kind:"iframe",src:`https://www.loom.com/embed/${r[1]}`}:/\.(mp4|webm|mov|m4v)(\?|#|$)/i.test(t)||/\/media\/uploads\//.test(t)?{kind:"file",src:t}:null))},ue=e=>{var r;let t=e.media;if(!(!t||t.kind!=="image"&&t.kind!=="video"||!/^https?:\/\//i.test((r=t.url)!=null?r:"")))return t.kind==="video"&&!Q(t.url)?void 0:t};var ge=(e,t)=>Math.round(e*(1-t/100)*100)/100,G=(e,t)=>{try{return new Intl.NumberFormat(de(),{style:"currency",currency:t}).format(e)}catch(r){return `${e.toFixed(2)} ${t}`}},me=e=>e.kind==="contact"?f("Send to the team"):e.kind==="pause"?f("Pause instead"):e.kind==="downgrade"?f("Switch plan"):f("Accept offer"),Z=e=>e===1?f("1 month"):L("{n} months",{n:e}),ee=e=>L("for {months}",{months:Z(e)});var D={check:{label:"Check",paths:["M5 12.5l4.5 4.5L19 7.5"],emoji:"\u2705"},star:{label:"Star",paths:["M12 3.5l2.6 5.3 5.9.9-4.3 4.1 1 5.8L12 16.9l-5.2 2.7 1-5.8-4.3-4.1 5.9-.9z"],emoji:"\u2B50"},rocket:{label:"Rocket",paths:["M12 3c3 2 4.5 5.5 4 10l-2 3h-4l-2-3c-.5-4.5 1-8 4-10z","M8 13.5l-3 3 3.5.5","M16 13.5l3 3-3.5.5","M13.5 9.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z","M11 19.5v1.5M13 19.5v1.5"],emoji:"\u{1F680}"},user:{label:"Person",paths:["M15.5 8a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0z","M5 20c.8-3.5 3.6-5.5 7-5.5s6.2 2 7 5.5"],emoji:"\u{1F464}"},users:{label:"Team",paths:["M13 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0z","M3.5 19c.6-3 3-4.8 6.5-4.8s5.9 1.8 6.5 4.8","M16 5.2a3 3 0 0 1 0 5.6","M18 14.6c1.5.6 2.4 2 2.7 4.4"],emoji:"\u{1F465}"},settings:{label:"Settings",paths:["M12 2.8v2.4M12 18.8v2.4M2.8 12h2.4M18.8 12h2.4M5.5 5.5l1.7 1.7M16.8 16.8l1.7 1.7M5.5 18.5l1.7-1.7M16.8 7.2l1.7-1.7","M17 12a5 5 0 1 1-10 0 5 5 0 0 1 10 0z","M14 12a2 2 0 1 1-4 0 2 2 0 0 1 4 0z"],emoji:"\u2699\uFE0F"},bell:{label:"Bell",paths:["M6 16v-5a6 6 0 0 1 12 0v5l1.5 2h-15z","M10 20.5a2 2 0 0 0 4 0"],emoji:"\u{1F514}"},mail:{label:"Mail",paths:["M4 6h16v12H4z","M4 7l8 6 8-6"],emoji:"\u2709\uFE0F"},chat:{label:"Chat",paths:["M4 5h16v11H9l-5 4z"],emoji:"\u{1F4AC}"},heart:{label:"Heart",paths:["M12 20s-7-4.4-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 10c0 5.6-7 10-7 10z"],emoji:"\u2764\uFE0F"},flag:{label:"Flag",paths:["M5 21V4","M5 4h11l-2 4 2 4H5"],emoji:"\u{1F6A9}"},bolt:{label:"Bolt",paths:["M13 3L5 13.5h6L10 21l8-10.5h-6z"],emoji:"\u26A1"},book:{label:"Book",paths:["M4 5.5C6.5 4 9.5 4 12 6c2.5-2 5.5-2 8-.5V19c-2.5-1.5-5.5-1.5-8 .5-2.5-2-5.5-2-8-.5z","M12 6v13.5"],emoji:"\u{1F4D6}"},calendar:{label:"Calendar",paths:["M4 6h16v14H4z","M4 10h16","M8 3.5v4M16 3.5v4"],emoji:"\u{1F4C5}"},camera:{label:"Camera",paths:["M4 8h3.5L9 5.5h6L16.5 8H20v11H4z","M15.5 13a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0z"],emoji:"\u{1F4F7}"},cart:{label:"Cart",paths:["M3.5 4.5H6l2 10h10l2-7H7","M9.5 19.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0z","M18.5 19.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"],emoji:"\u{1F6D2}"},chart:{label:"Chart",paths:["M4 20h16","M7 16v-4M12 16V8M17 16V9"],emoji:"\u{1F4CA}"},gift:{label:"Gift",paths:["M4 10h16v10H4z","M3 7h18v3H3z","M12 7v13","M12 7c-1.5-3-5-3-5-1s3.5 1 5 1z","M12 7c1.5-3 5-3 5-1s-3.5 1-5 1z"],emoji:"\u{1F381}"},home:{label:"Home",paths:["M4 11l8-7 8 7","M6 9.5V20h12V9.5","M10 20v-6h4v6"],emoji:"\u{1F3E0}"},link:{label:"Link",paths:["M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1","M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"],emoji:"\u{1F517}"},lock:{label:"Lock",paths:["M6 11h12v9H6z","M8.5 11V8a3.5 3.5 0 0 1 7 0v3"],emoji:"\u{1F512}"},pencil:{label:"Pencil",paths:["M4 20l1-4L16 5l3 3L8 19z","M14 7l3 3"],emoji:"\u270F\uFE0F"},plus:{label:"Plus",paths:["M12 5v14M5 12h14"],emoji:"\u2795"},search:{label:"Search",paths:["M16 10.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z","M14.5 14.5L20 20"],emoji:"\u{1F50D}"},upload:{label:"Upload",paths:["M12 15V4","M7.5 8.5L12 4l4.5 4.5","M4 15v5h16v-5"],emoji:"\u2B06\uFE0F"},play:{label:"Play",paths:["M8 5l11 7-11 7z"],emoji:"\u25B6\uFE0F"},sparkle:{label:"Sparkle",paths:["M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8z","M19 16l.7 2 2 .7-2 .7-.7 2-.7-2-2-.7 2-.7z"],emoji:"\u2728"},globe:{label:"Globe",paths:["M20 12a8 8 0 1 1-16 0 8 8 0 0 1 16 0z","M4 12h16","M12 4c2.2 2.2 3.3 4.9 3.3 8s-1.1 5.8-3.3 8c-2.2-2.2-3.3-4.9-3.3-8S9.8 6.2 12 4z"],emoji:"\u{1F310}"}},ke=e=>{if(e){if(e.kind==="builtin")return e.name&&D[e.name]?e:void 0;if(e.kind==="emoji")return e.value&&e.value.trim()&&[...e.value.trim()].length<=8?e:void 0;if(e.kind==="image")return e.url&&/^https?:\/\//i.test(e.url)?e:void 0}};var he="ckf-styles",Re=`
|
|
2
2
|
.ckf-root{--ckf-accent:#3f76ff;--ckf-accent-ink:#fff;--ckf-bg:#fff;--ckf-fg:#1c1d20;--ckf-muted:#5d6068;--ckf-soft:#f4f5f7;--ckf-line:#e4e5e8;--ckf-danger:#d92d20;--ckf-radius:14px;--ckf-font:inherit;--ckf-shadow:0 16px 40px -12px rgba(16,18,24,.28),0 0 0 1px rgba(16,18,24,.07)}
|
|
3
3
|
.ckf-root[data-theme=dark]{--ckf-bg:#17181b;--ckf-fg:#f1f2f4;--ckf-muted:#a9acb3;--ckf-soft:#232428;--ckf-line:#2e2f35;--ckf-shadow:0 16px 40px -12px rgba(0,0,0,.6),0 0 0 1px rgba(255,255,255,.08)}
|
|
4
4
|
@media (prefers-color-scheme:dark){.ckf-root[data-theme=auto]{--ckf-bg:#17181b;--ckf-fg:#f1f2f4;--ckf-muted:#a9acb3;--ckf-soft:#232428;--ckf-line:#2e2f35;--ckf-shadow:0 16px 40px -12px rgba(0,0,0,.6),0 0 0 1px rgba(255,255,255,.08)}}
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
.ckf-banner{animation-name:ckf-fade}
|
|
89
89
|
@media (max-width:520px){.ckf-scrim{align-items:flex-end;padding:0}.ckf-scrim .ckf-card{max-width:none;border-radius:var(--ckf-radius) var(--ckf-radius) 0 0;max-height:92dvh}.ckf-float{right:12px;bottom:12px}}
|
|
90
90
|
@media (prefers-reduced-motion:reduce){.ckf-root *{animation:none!important;transition:none!important}}
|
|
91
|
-
`,n=(e,t={},...r)=>{let a=document.createElement(e);for(let[i,u]of Object.entries(t))u===void 0||u===false||(typeof u=="function"?a.addEventListener(i.slice(2).toLowerCase(),u):i==="className"?a.className=String(u):a.setAttribute(i,u===true?"":u));for(let i of r)(i||i==="")&&a.append(typeof i=="string"?document.createTextNode(i):i);return a},L=(e,t,r,a={})=>n("button",{type:"button",className:`ckf-btn${t==="secondary"?"":` ckf-${t}`}`,disabled:!!a.disabled,"data-ckf-id":a.id,onClick:()=>r()},e),W=(e,t)=>n("button",{type:"button",className:"ckf-x","aria-label":e,"data-ckf-id":"x",onClick:()=>t()},"\xD7"),ne=(e,t)=>t>1?n("span",{className:"ckf-dots",role:"img","aria-label":I("Step {n} of {total}",{n:e,total:t})},...Array.from({length:t},(r,a)=>n("span",{className:"ckf-dot","data-on":a<e}))):n("span"),be=e=>{var t;return e.type==="cancel"?`c:${e.screen}:${(t=e.round)!=null?t:1}`:e.type==="step"?`s:${e.step.id}`:e.type==="checklist"?`l:${e.flow.id}`:`m:${e.message.id}`},Le=e=>e.type==="cancel"?"c":e.type==="step"&&(e.step.kind==="question"||e.step.kind==="modal")?`d:${e.flow.id}`:be(e),we=e=>{var r;if(!document.getElementById(he)){let a=document.createElement("style");a.id=he,a.textContent=Re,document.head.appendChild(a);}let t=n("div",{className:`ckf-root${e.className?` ${e.className}`:""}`,"data-theme":(r=e.theme)!=null?r:"auto"});return e.accent&&t.style.setProperty("--ckf-accent",e.accent),document.body.appendChild(t),t},xe=e=>{let t=fe();t?e.setAttribute("lang",t):e.removeAttribute("lang");},te=(e,t)=>{let r=ke(e);if(!r)return false;let a=n("span",{className:t,"aria-hidden":"true"});if(r.kind==="emoji")a.textContent=r.value;else if(r.kind==="image")a.append(n("img",{src:r.url,alt:""}));else {let i="http://www.w3.org/2000/svg",u=document.createElementNS(i,"svg");for(let[m,d]of Object.entries({viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}))u.setAttribute(m,d);for(let m of B[r.name].paths){let d=document.createElementNS(i,"path");d.setAttribute("d",m),u.append(d);}a.append(u);}return a},ye=(e,t={})=>{if(typeof document=="undefined")return ()=>{};let r=we(t),a="",i="",u="",m=null,d="",w=null,c=o=>{var k,N,$;let s="ckf-title",l=o.busy,g=[];if(o.screen==="survey")g.push(n("h2",{className:"ckf-h",id:s},o.flow.question||f("Why are you leaving?")),n("div",{className:"ckf-opts",role:"radiogroup","aria-labelledby":s},...o.flow.reasons.map(p=>n("button",{type:"button",role:"radio",className:"ckf-opt","aria-checked":String(o.reason===p.id),"data-ckf-id":`r:${p.id}`,onClick:()=>e.cancel.pick(p.id)},n("span",{className:"ckf-radio"}),p.label))),n("div",{className:"ckf-btns"},L(f("Continue"),"primary",e.cancel.next,{disabled:!o.reason,id:"go"}),L(f("Never mind, keep my plan"),"quiet",e.cancel.close)));else if(o.screen==="followup"&&o.followUp){let p=o.followUp,C;if(p.answers.length)C=n("div",{className:"ckf-opts",role:"radiogroup","aria-labelledby":s},...p.answers.map((F,b)=>{var S;return n("button",{type:"button",role:"radio",className:"ckf-opt","aria-checked":String(o.answer===F),"data-ckf-id":`a:${b}`,onClick:()=>e.cancel.answer(F)},n("span",{className:"ckf-radio"}),((S=p.answerLabels)==null?void 0:S[b])||F)}));else {let F=n("textarea",{className:"ckf-text",placeholder:f("Your answer (optional)"),"aria-labelledby":s,maxlength:"500","data-ckf-id":"answer",onInput:b=>e.cancel.answer(b.target.value)});F.value=(k=o.answer)!=null?k:"",C=F;}let v=(N=o.flow.reasons.find(F=>F.id===o.reason))==null?void 0:N.label;g.push(v?n("p",{className:"ckf-small"},I("You said: {label}",{label:v})):false,n("h2",{className:"ckf-h",id:s},p.question),C,n("div",{className:"ckf-btns"},L(f("Continue"),"primary",e.cancel.next,{id:"go"}),L(f("Never mind, keep my plan"),"quiet",e.cancel.close)));}else if(o.screen==="offer"&&o.offer){let p=o.offer,C=($=o.flow.reasons.find(b=>b.id===o.reason))==null?void 0:$.label,v=false;p.kind==="discount"&&p.percent&&(v=o.price?n("div",{className:"ckf-box"},n("span",{className:"ckf-big"},G(ge(o.price.amount,p.percent),o.price.currency)),n("span",{className:"ckf-strike"},G(o.price.amount,o.price.currency)),n("span",{className:"ckf-small"},`/${o.price.interval==="year"?f("year"):f("month")}${p.months?` ${ee(p.months)}`:""}`)):n("div",{className:"ckf-box"},n("span",{className:"ckf-big"},I("{percent}% off",{percent:p.percent})),p.months?n("span",{className:"ckf-small"},ee(p.months)):false)),p.kind==="pause"&&p.months&&(v=n("div",{className:"ckf-box"},n("span",{},I("Pause for up to {months}. Your data stays.",{months:Z(p.months)})))),p.kind==="downgrade"&&p.planName&&(v=n("div",{className:"ckf-box"},n("b",{},p.planName)));let F=p.kind==="contact"?n("textarea",{className:"ckf-text",placeholder:f("What would make you stay?"),"aria-label":f("Your message"),maxlength:"500","data-ckf-id":"comment",onInput:b=>d=b.target.value}):null;F&&(F.value=d),g.push(C?n("p",{className:"ckf-small"},I("You said: {label}",{label:C})):false,n("h2",{className:"ckf-h",id:s},p.headline),v,F!=null?F:false,n("div",{className:"ckf-btns"},L(l?f("One moment\u2026"):me(p),"primary",()=>e.cancel.accept(d),{disabled:l,id:"go"}),L(f("No thanks, continue cancelling"),"quiet",e.cancel.decline,{disabled:l})));}else {let C=o.steps===1?null:n("textarea",{className:"ckf-text",placeholder:f("Anything else we should know? (optional)"),"aria-label":f("Anything else we should know? (optional)"),maxlength:"500","data-ckf-id":"comment",onInput:v=>d=v.target.value});C&&(C.value=d),g.push(n("h2",{className:"ckf-h",id:s},o.flow.confirm.title),o.flow.confirm.body?n("p",{className:"ckf-p"},o.flow.confirm.body):false,C!=null?C:false,n("div",{className:"ckf-btns"},L(l?f("One moment\u2026"):o.flow.confirm.button,"danger",()=>e.cancel.confirm(d),{disabled:l,id:"go"}),L(f("Keep my plan"),"secondary",e.cancel.close,{disabled:l})));}return n("div",{className:"ckf-scrim",onClick:p=>p.target===p.currentTarget&&!l&&e.cancel.close()},n("div",{className:"ckf-card",role:"dialog","aria-modal":"true","aria-labelledby":s},n("div",{className:"ckf-top"},ne(o.step,o.steps),W(f("Close"),e.cancel.close)),...g,o.error?n("p",{className:"ckf-err",role:"alert"},o.error):false))},x=o=>{var g;let s=pe(o);if(!s)return false;if(s.kind==="image")return n("img",{className:"ckf-media",src:s.url,alt:(g=s.alt)!=null?g:"",onLoad:()=>E()});let l=X(s.url);return l.kind==="iframe"?n("div",{className:"ckf-video"},n("iframe",{src:l.src,title:s.alt||f("Video"),allow:"fullscreen; picture-in-picture",allowfullscreen:true,loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin"})):n("video",{className:"ckf-media",src:l.src,controls:true,playsinline:true,preload:"metadata","aria-label":s.alt||void 0,onLoadedmetadata:()=>E()})},h=o=>{var C,v,F;let s=o.step,l=s.question,g="ckf-title",k=ue(l,o.answer),N=false,$=(b,S,_)=>{let A=n("input",{type:"text",className:"ckf-input",placeholder:b,"aria-labelledby":g,maxlength:"500","data-ckf-id":"answer",onInput:j=>_(j.target.value),onKeydown:j=>j.key==="Enter"&&e.onboarding.next()});return A.value=S,A},p=(b,S,_,A)=>n("button",{type:"button",role:"radio",className:"ckf-opt","aria-checked":String(b),"data-ckf-id":`q:${S}`,onClick:A},n("span",{className:"ckf-radio"}),_);if((l==null?void 0:l.type)==="choice"){let b=!!l.other&&!!((C=o.answer)!=null&&C.startsWith(U));N=n("div",{className:"ckf-opts",role:"radiogroup","aria-labelledby":g},...((v=l.options)!=null?v:[]).map(S=>p(o.answer===S.id,S.id,S.label,()=>e.onboarding.answer(S.id))),l.other?p(b,"other",l.otherLabel||f("Other"),()=>b||e.onboarding.answer(U)):false,b?$(f("Your answer"),o.answer.slice(U.length),S=>e.onboarding.answer(U+S)):false);}else (l==null?void 0:l.type)==="scale"?N=n("div",{},n("div",{className:"ckf-scale",role:"radiogroup","aria-labelledby":g},...Q(l).map(b=>n("button",{type:"button",role:"radio",className:"ckf-num","aria-checked":String(o.answer===String(b)),"data-ckf-id":`q:${b}`,onClick:()=>e.onboarding.answer(String(b))},String(b)))),l.lowLabel||l.highLabel?n("div",{className:"ckf-ends ckf-small"},n("span",{},l.lowLabel||""),n("span",{},l.highLabel||"")):false):l&&(N=$(l.placeholder||f("Your answer"),(F=o.answer)!=null?F:"",b=>e.onboarding.answer(b)));return n("div",{className:"ckf-scrim"},n("div",{className:"ckf-card",role:"dialog","aria-modal":"true","aria-labelledby":g},n("div",{className:"ckf-top"},ne(o.index+1,o.total),W(f("Close"),e.onboarding.dismiss)),o.index===0?te(o.flow.icon,"ckf-hic"):false,n("h2",{className:"ckf-h",id:g},s.title),s.body?n("p",{className:"ckf-p"},s.body):false,N,n("div",{className:"ckf-row"},o.back?L(f("Back"),"quiet",e.onboarding.back):false,l!=null&&l.optional?L(l.skipLabel||f("Skip"),"quiet",e.onboarding.skip):false,L(s.button||(o.last?f("Done"):f("Continue")),"primary",e.onboarding.next,{disabled:!k,id:"go"}))))},M=o=>{let s=o.step;if(s.kind==="question")return h(o);let l=n("div",{className:"ckf-card",role:"dialog","aria-modal":s.kind==="modal"?"true":void 0,"aria-labelledby":"ckf-title"},n("div",{className:"ckf-top"},o.total>1?n("p",{className:"ckf-small"},I("Step {n} of {total}",{n:o.index+1,total:o.total})):n("span"),W(f("Close the tour"),e.onboarding.dismiss)),s.kind==="modal"?te(o.flow.icon,"ckf-hic"):false,x(s),n("h2",{className:"ckf-h",id:"ckf-title"},s.title),s.body?n("p",{className:"ckf-p"},s.body):false,n("div",{className:"ckf-row"},L(s.button||(o.last?f("Done"):f("Next")),"primary",e.onboarding.next,{id:"go"})));if(s.kind==="modal")return n("div",{className:"ckf-scrim"},l);let g=s.target?P(s.target):null,k=n("div",{className:"ckf-float"},l);if(g){let N=n("div",{className:"ckf-ring","aria-hidden":"true"});return k.append(n("span",{className:"ckf-arrow","aria-hidden":"true"})),w={float:k,ring:N,target:g,side:s.placement},T(k,N,g,s.placement),n("div",{},N,k)}return k},P=o=>{var l;let s=()=>document.querySelector(`[data-ck-target="${CSS.escape(o)}"]`);return /^[#.[]|[\s>:=]/.test(o)&&(l=V(o))!=null?l:s()},V=o=>{try{return document.querySelector(o)}catch(s){return null}},T=(o,s,l,g="auto")=>{var se;let k=l.getBoundingClientRect();Object.assign(s.style,{left:`${k.left-4}px`,top:`${k.top-4}px`,width:`${k.width+8}px`,height:`${k.height+8}px`});let N=window.innerWidth,$=window.innerHeight,p=Math.min(340,N-24),C=o.offsetHeight||200,v=14,F={bottom:$-k.bottom-v-12>=C,top:k.top-v-12>=C,right:N-k.right-v-12>=p,left:k.left-v-12>=p},b={top:"bottom",bottom:"top",left:"right",right:"left"},_=(se=(g==="auto"||!b[g]?["bottom","top"]:[g,b[g],"bottom","top","right","left"]).find(D=>F[D]))!=null?se:g!=="auto"&&b[g]?g:k.top>$-k.bottom?"top":"bottom",A=(D,Fe)=>Math.max(12,Math.min(D,Fe-12)),j=_==="top"||_==="bottom",oe=j?A(g==="auto"?k.left:k.left+k.width/2-p/2,N-p):_==="right"?k.right+v:k.left-v-p,ie=j?_==="bottom"?k.bottom+v:k.top-v-C:A(k.top+k.height/2-C/2,$-C);Object.assign(o.style,{left:`${oe}px`,top:`${ie}px`,right:"auto",bottom:"auto",width:`${p}px`}),o.setAttribute("data-side",_);let Ne=j?k.left+k.width/2-oe:k.top+k.height/2-ie;o.style.setProperty("--ckf-ap",`${Math.max(18,Math.min(Ne,(j?p:C)-18))}px`);},O=o=>{let s=o.items.filter(l=>l.done).length;return n("div",{className:"ckf-float"},n("div",{className:"ckf-card",role:"region","aria-labelledby":"ckf-title"},n("div",{className:"ckf-top"},n("h2",{className:"ckf-h",id:"ckf-title"},o.flow.name),W(f("Hide the checklist"),e.onboarding.dismiss)),n("p",{className:"ckf-small"},I("{done} of {total} done",{done:s,total:o.items.length})),n("div",{className:"ckf-bar",role:"progressbar","aria-valuemin":"0","aria-valuemax":String(o.items.length),"aria-valuenow":String(s)},n("i",{style:`width:${s/o.items.length*100}%`})),n("div",{className:"ckf-opts"},...o.items.map(({step:l,done:g,opens:k})=>{let N=[n("span",{className:"ckf-tick","aria-hidden":"true"},g?"\u2713":""),te(l.icon,"ckf-ic"),n("span",{},n("b",{},l.title),l.body?n("span",{className:"ckf-small"},l.body):false)];return !g&&k?n("button",{type:"button",className:"ckf-check","aria-label":I("Start \u201C{title}\u201D",{title:l.title}),"data-ckf-id":`t:${l.id}`,onClick:()=>e.onboarding.open(l.id)},...N,n("span",{className:"ckf-go","aria-hidden":"true"},"\u203A")):g||l.event?n("div",{className:"ckf-check","data-done":g,role:"listitem"},...N):n("button",{type:"button",className:"ckf-check","aria-label":I("Mark \u201C{title}\u201D done",{title:l.title}),"data-ckf-id":`i:${l.id}`,onClick:()=>e.onboarding.check(l.id)},...N)}))))},H=o=>{let s=o.message,l=s.button?L(s.button,"primary",e.message.click,{id:"go"}):false;return s.style==="banner"?n("div",{className:"ckf-banner",role:"status"},n("span",{},n("b",{},s.title),s.body?n("span",{className:"ckf-small"},s.body):false),l,W(f("Dismiss"),e.message.dismiss)):n("div",{className:"ckf-scrim",onClick:g=>g.target===g.currentTarget&&e.message.dismiss()},n("div",{className:"ckf-card",role:"dialog","aria-modal":"true","aria-labelledby":"ckf-title"},n("div",{className:"ckf-top"},n("span"),W(f("Dismiss"),e.message.dismiss)),n("h2",{className:"ckf-h",id:"ckf-title"},s.title),s.body?n("p",{className:"ckf-p"},s.body):false,l?n("div",{className:"ckf-row"},l):false))},z=()=>{var $,p,C,v,F,b,S,_;let o=e.view();xe(r);let s=(p=t.accent)!=null?p:($=e.accent)==null?void 0:$.call(e);s&&r.style.setProperty("--ckf-accent",s);let l=(C=e.finale)==null?void 0:C.call(e);l&&l.key!==a&&(a=l.key,ce(l.kind,{accent:s}));let g=o?be(o):"",k=(F=(v=document.activeElement)==null?void 0:v.closest)!=null&&F.call(v,".ckf-root")?(b=document.activeElement)==null?void 0:b.getAttribute("data-ckf-id"):null;g&&!i&&document.activeElement instanceof HTMLElement&&!document.activeElement.closest(".ckf-root")&&(m=document.activeElement),g!==i&&!g.startsWith("c:")&&(d=""),g||(d=""),w=null;let N=o?Le(o):"";if(r.toggleAttribute("data-still",!!N&&N===u),u=N,r.replaceChildren(...o?[o.type==="cancel"?c(o):o.type==="step"?M(o):o.type==="checklist"?O(o):H(o)]:[]),E(),g!==i){let A=r.querySelector("[aria-modal=true]"),j=(S=A==null?void 0:A.querySelector("[role=radio], input, [data-ckf-id=go], textarea"))!=null?S:null;j==null||j.focus(),!g&&m&&(m.focus(),m=null);}else k&&((_=r.querySelector(`[data-ckf-id="${CSS.escape(k)}"]`))==null||_.focus());i=g;},y=o=>{if(o.key!=="Escape")return;let s=e.view();(s==null?void 0:s.type)==="cancel"?e.cancel.close():(s==null?void 0:s.type)==="message"?e.message.dismiss():(s==null?void 0:s.type)==="step"&&(s.step.kind==="modal"||s.step.kind==="question")&&e.onboarding.dismiss();};function E(){w&&T(w.float,w.ring,w.target,w.side);}document.addEventListener("keydown",y),window.addEventListener("resize",E),window.addEventListener("scroll",E,{passive:true,capture:true});let K=e.subscribe(z),R=J(z);return z(),()=>{K(),R(),document.removeEventListener("keydown",y),window.removeEventListener("resize",E),window.removeEventListener("scroll",E,{capture:true}),r.remove();}},ve=(e,t={})=>{if(typeof document=="undefined")return ()=>{};let r=we(t),a="",i=null,u=()=>{var P,V,T;let c=e.view();xe(r);let x=c?`${c.paywall.id}:${c.index}`:"";if(x&&!a&&document.activeElement instanceof HTMLElement&&(i=document.activeElement),!c){r.replaceChildren(),r.removeAttribute("data-still"),a&&(i==null||i.focus()),a="";return}a&&r.setAttribute("data-still","");let h=c.page,M=h.kind==="plans"?n("div",{className:"ckf-opts",role:"radiogroup","aria-label":f("Plans")},...c.plans.map(O=>n("button",{type:"button",role:"radio",className:"ckf-opt ckf-plan","aria-checked":String(c.plan===O.id),"data-ckf-id":`p:${O.id}`,onClick:()=>e.pick(O.id)},n("span",{className:"ckf-radio"}),n("span",{},O.name,O.note?n("span",{className:"ckf-small"},O.note):false),n("b",{},O.price)))):false;r.replaceChildren(n("div",{className:"ckf-scrim",onClick:O=>O.target===O.currentTarget&&e.close()},n("div",{className:"ckf-card ckf-pw",role:"dialog","aria-modal":"true","aria-labelledby":"ckf-title"},n("div",{className:"ckf-top"},ne(c.index+1,c.total),W(f("Close"),e.close)),n("h2",{className:"ckf-h",id:"ckf-title"},h.title),h.body?n("p",{className:"ckf-p"},h.body):false,h.kind==="benefits"&&((P=h.items)!=null&&P.length)?n("div",{className:"ckf-opts"},...h.items.map(O=>n("p",{className:"ckf-li"},O))):false,h.kind==="proof"&&((V=h.quotes)!=null&&V.length)?n("div",{className:"ckf-opts"},...h.quotes.map(O=>n("blockquote",{className:"ckf-quote"},O.text,O.by?n("cite",{},O.by):false))):false,M,c.error?n("p",{className:"ckf-err",role:"alert"},c.error):false,n("div",{className:"ckf-btns"},L(c.busy?f("One moment\u2026"):h.button||f("Continue"),"primary",e.next,{disabled:c.busy||h.kind==="plans"&&!c.plan,id:"go"}),c.index?L(f("Back"),"quiet",e.back,{disabled:c.busy}):false)))),x!==a&&((T=r.querySelector("[data-ckf-id=go]"))==null||T.focus()),a=x;},m=c=>{e.view()&&c.key==="Escape"&&e.close();};document.addEventListener("keydown",m);let d=e.subscribe(u),w=J(u);return u(),()=>{d(),w(),document.removeEventListener("keydown",m),r.remove();}};var Ie=e=>{let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return (t>>>0)/4294967296};var Te=e=>typeof e.weight=="number"&&e.weight>0?e.weight:0,Ce=(e,t)=>{var m,d;let r=(d=(m=e.variants[0])==null?void 0:m.id)!=null?d:"control";if(e.winner)return e.winner;if(e.status!=="running")return r;let a=Ie(`${e.key}:${t}`),i=0,u;for(let w of e.variants){let c=Te(w);if(c&&(i+=c,u=w.id,a<i))return w.id}return u!=null?u:r},$e=(e,t,r)=>{if(!r||e.winner||e.status!=="running")return Ce(e,t);let a=`${e.key}
|
|
92
|
-
${t}`,i=r.get(a);if(i!==void 0&&e.variants.some(m=>m.id===i))return i;let
|
|
91
|
+
`,n=(e,t={},...r)=>{let a=document.createElement(e);for(let[i,p]of Object.entries(t))p===void 0||p===false||(typeof p=="function"?a.addEventListener(i.slice(2).toLowerCase(),p):i==="className"?a.className=String(p):a.setAttribute(i,p===true?"":p));for(let i of r)(i||i==="")&&a.append(typeof i=="string"?document.createTextNode(i):i);return a},I=(e,t,r,a={})=>n("button",{type:"button",className:`ckf-btn${t==="secondary"?"":` ckf-${t}`}`,disabled:!!a.disabled,"data-ckf-id":a.id,onClick:()=>r()},e),U=(e,t)=>n("button",{type:"button",className:"ckf-x","aria-label":e,"data-ckf-id":"x",onClick:()=>t()},"\xD7"),ne=(e,t)=>t>1?n("span",{className:"ckf-dots",role:"img","aria-label":L("Step {n} of {total}",{n:e,total:t})},...Array.from({length:t},(r,a)=>n("span",{className:"ckf-dot","data-on":a<e}))):n("span"),be=e=>{var t;return e.type==="cancel"?`c:${e.screen}:${(t=e.round)!=null?t:1}`:e.type==="step"?`s:${e.step.id}`:e.type==="checklist"?`l:${e.flow.id}`:`m:${e.message.id}`},Ie=e=>e.type==="cancel"?"c":e.type==="step"&&(e.step.kind==="question"||e.step.kind==="modal")?`d:${e.flow.id}`:be(e),we=e=>{var r;if(!document.getElementById(he)){let a=document.createElement("style");a.id=he,a.textContent=Re,document.head.appendChild(a);}let t=n("div",{className:`ckf-root${e.className?` ${e.className}`:""}`,"data-theme":(r=e.theme)!=null?r:"auto"});return e.accent&&t.style.setProperty("--ckf-accent",e.accent),document.body.appendChild(t),t},xe=e=>{let t=fe();t?e.setAttribute("lang",t):e.removeAttribute("lang");},te=(e,t)=>{let r=ke(e);if(!r)return false;let a=n("span",{className:t,"aria-hidden":"true"});if(r.kind==="emoji")a.textContent=r.value;else if(r.kind==="image")a.append(n("img",{src:r.url,alt:""}));else {let i="http://www.w3.org/2000/svg",p=document.createElementNS(i,"svg");for(let[m,d]of Object.entries({viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}))p.setAttribute(m,d);for(let m of D[r.name].paths){let d=document.createElementNS(i,"path");d.setAttribute("d",m),p.append(d);}a.append(p);}return a},ye=(e,t={})=>{if(typeof document=="undefined")return ()=>{};let r=we(t),a="",i="",p="",m=null,d="",w=null,c=o=>{var k,N,_;let s="ckf-title",l=o.busy,g=[];if(o.screen==="survey")g.push(n("h2",{className:"ckf-h",id:s},o.flow.question||f("Why are you leaving?")),n("div",{className:"ckf-opts",role:"radiogroup","aria-labelledby":s},...o.flow.reasons.map(u=>n("button",{type:"button",role:"radio",className:"ckf-opt","aria-checked":String(o.reason===u.id),"data-ckf-id":`r:${u.id}`,onClick:()=>e.cancel.pick(u.id)},n("span",{className:"ckf-radio"}),u.label))),n("div",{className:"ckf-btns"},I(f("Continue"),"primary",e.cancel.next,{disabled:!o.reason,id:"go"}),I(f("Never mind, keep my plan"),"quiet",e.cancel.close)));else if(o.screen==="followup"&&o.followUp){let u=o.followUp,C;if(u.answers.length)C=n("div",{className:"ckf-opts",role:"radiogroup","aria-labelledby":s},...u.answers.map((E,b)=>{var S;return n("button",{type:"button",role:"radio",className:"ckf-opt","aria-checked":String(o.answer===E),"data-ckf-id":`a:${b}`,onClick:()=>e.cancel.answer(E)},n("span",{className:"ckf-radio"}),((S=u.answerLabels)==null?void 0:S[b])||E)}));else {let E=n("textarea",{className:"ckf-text",placeholder:f("Your answer (optional)"),"aria-labelledby":s,maxlength:"500","data-ckf-id":"answer",onInput:b=>e.cancel.answer(b.target.value)});E.value=(k=o.answer)!=null?k:"",C=E;}let v=(N=o.flow.reasons.find(E=>E.id===o.reason))==null?void 0:N.label;g.push(v?n("p",{className:"ckf-small"},L("You said: {label}",{label:v})):false,n("h2",{className:"ckf-h",id:s},u.question),C,n("div",{className:"ckf-btns"},I(f("Continue"),"primary",e.cancel.next,{id:"go"}),I(f("Never mind, keep my plan"),"quiet",e.cancel.close)));}else if(o.screen==="offer"&&o.offer){let u=o.offer,C=(_=o.flow.reasons.find(b=>b.id===o.reason))==null?void 0:_.label,v=false;u.kind==="discount"&&u.percent&&(v=o.price?n("div",{className:"ckf-box"},n("span",{className:"ckf-big"},G(ge(o.price.amount,u.percent),o.price.currency)),n("span",{className:"ckf-strike"},G(o.price.amount,o.price.currency)),n("span",{className:"ckf-small"},`/${o.price.interval==="year"?f("year"):f("month")}${u.months?` ${ee(u.months)}`:""}`)):n("div",{className:"ckf-box"},n("span",{className:"ckf-big"},L("{percent}% off",{percent:u.percent})),u.months?n("span",{className:"ckf-small"},ee(u.months)):false)),u.kind==="pause"&&u.months&&(v=n("div",{className:"ckf-box"},n("span",{},L("Pause for up to {months}. Your data stays.",{months:Z(u.months)})))),u.kind==="downgrade"&&u.planName&&(v=n("div",{className:"ckf-box"},n("b",{},u.planName)));let E=u.kind==="contact"?n("textarea",{className:"ckf-text",placeholder:f("What would make you stay?"),"aria-label":f("Your message"),maxlength:"500","data-ckf-id":"comment",onInput:b=>d=b.target.value}):null;E&&(E.value=d),g.push(C?n("p",{className:"ckf-small"},L("You said: {label}",{label:C})):false,n("h2",{className:"ckf-h",id:s},u.headline),v,E!=null?E:false,n("div",{className:"ckf-btns"},I(l?f("One moment\u2026"):me(u),"primary",()=>e.cancel.accept(d),{disabled:l,id:"go"}),I(f("No thanks, continue cancelling"),"quiet",e.cancel.decline,{disabled:l})));}else {let C=o.steps===1?null:n("textarea",{className:"ckf-text",placeholder:f("Anything else we should know? (optional)"),"aria-label":f("Anything else we should know? (optional)"),maxlength:"500","data-ckf-id":"comment",onInput:v=>d=v.target.value});C&&(C.value=d),g.push(n("h2",{className:"ckf-h",id:s},o.flow.confirm.title),o.flow.confirm.body?n("p",{className:"ckf-p"},o.flow.confirm.body):false,C!=null?C:false,n("div",{className:"ckf-btns"},I(l?f("One moment\u2026"):o.flow.confirm.button,"danger",()=>e.cancel.confirm(d),{disabled:l,id:"go"}),I(f("Keep my plan"),"secondary",e.cancel.close,{disabled:l})));}return n("div",{className:"ckf-scrim",onClick:u=>u.target===u.currentTarget&&!l&&e.cancel.close()},n("div",{className:"ckf-card",role:"dialog","aria-modal":"true","aria-labelledby":s},n("div",{className:"ckf-top"},ne(o.step,o.steps),U(f("Close"),e.cancel.close)),...g,o.error?n("p",{className:"ckf-err",role:"alert"},o.error):false))},x=o=>{var g;let s=ue(o);if(!s)return false;if(s.kind==="image")return n("img",{className:"ckf-media",src:s.url,alt:(g=s.alt)!=null?g:"",onLoad:()=>P()});let l=Q(s.url);return l.kind==="iframe"?n("div",{className:"ckf-video"},n("iframe",{src:l.src,title:s.alt||f("Video"),allow:"fullscreen; picture-in-picture",allowfullscreen:true,loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin"})):n("video",{className:"ckf-media",src:l.src,controls:true,playsinline:true,preload:"metadata","aria-label":s.alt||void 0,onLoadedmetadata:()=>P()})},h=o=>{var C,v,E;let s=o.step,l=s.question,g="ckf-title",k=pe(l,o.answer),N=false,_=(b,S,$)=>{let j=n("input",{type:"text",className:"ckf-input",placeholder:b,"aria-labelledby":g,maxlength:"500","data-ckf-id":"answer",onInput:A=>$(A.target.value),onKeydown:A=>A.key==="Enter"&&e.onboarding.next()});return j.value=S,j},u=(b,S,$,j)=>n("button",{type:"button",role:"radio",className:"ckf-opt","aria-checked":String(b),"data-ckf-id":`q:${S}`,onClick:j},n("span",{className:"ckf-radio"}),$);if((l==null?void 0:l.type)==="choice"){let b=!!l.other&&!!((C=o.answer)!=null&&C.startsWith(W));N=n("div",{className:"ckf-opts",role:"radiogroup","aria-labelledby":g},...((v=l.options)!=null?v:[]).map(S=>u(o.answer===S.id,S.id,S.label,()=>e.onboarding.answer(S.id))),l.other?u(b,"other",l.otherLabel||f("Other"),()=>b||e.onboarding.answer(W)):false,b?_(f("Your answer"),o.answer.slice(W.length),S=>e.onboarding.answer(W+S)):false);}else (l==null?void 0:l.type)==="scale"?N=n("div",{},n("div",{className:"ckf-scale",role:"radiogroup","aria-labelledby":g},...X(l).map(b=>n("button",{type:"button",role:"radio",className:"ckf-num","aria-checked":String(o.answer===String(b)),"data-ckf-id":`q:${b}`,onClick:()=>e.onboarding.answer(String(b))},String(b)))),l.lowLabel||l.highLabel?n("div",{className:"ckf-ends ckf-small"},n("span",{},l.lowLabel||""),n("span",{},l.highLabel||"")):false):l&&(N=_(l.placeholder||f("Your answer"),(E=o.answer)!=null?E:"",b=>e.onboarding.answer(b)));return n("div",{className:"ckf-scrim"},n("div",{className:"ckf-card",role:"dialog","aria-modal":"true","aria-labelledby":g},n("div",{className:"ckf-top"},ne(o.index+1,o.total),U(f("Close"),e.onboarding.dismiss)),o.index===0?te(o.flow.icon,"ckf-hic"):false,n("h2",{className:"ckf-h",id:g},s.title),s.body?n("p",{className:"ckf-p"},s.body):false,N,n("div",{className:"ckf-row"},o.back?I(f("Back"),"quiet",e.onboarding.back):false,l!=null&&l.optional?I(l.skipLabel||f("Skip"),"quiet",e.onboarding.skip):false,I(s.button||(o.last?f("Done"):f("Continue")),"primary",e.onboarding.next,{disabled:!k,id:"go"}))))},M=o=>{let s=o.step;if(s.kind==="question")return h(o);let l=n("div",{className:"ckf-card",role:"dialog","aria-modal":s.kind==="modal"?"true":void 0,"aria-labelledby":"ckf-title"},n("div",{className:"ckf-top"},o.total>1?n("p",{className:"ckf-small"},L("Step {n} of {total}",{n:o.index+1,total:o.total})):n("span"),U(f("Close the tour"),e.onboarding.dismiss)),s.kind==="modal"?te(o.flow.icon,"ckf-hic"):false,x(s),n("h2",{className:"ckf-h",id:"ckf-title"},s.title),s.body?n("p",{className:"ckf-p"},s.body):false,n("div",{className:"ckf-row"},I(s.button||(o.last?f("Done"):f("Next")),"primary",e.onboarding.next,{id:"go"})));if(s.kind==="modal")return n("div",{className:"ckf-scrim"},l);let g=s.target?F(s.target):null,k=n("div",{className:"ckf-float"},l);if(g){let N=n("div",{className:"ckf-ring","aria-hidden":"true"});return k.append(n("span",{className:"ckf-arrow","aria-hidden":"true"})),w={float:k,ring:N,target:g,side:s.placement},T(k,N,g,s.placement),n("div",{},N,k)}return k},F=o=>{var l;let s=()=>document.querySelector(`[data-ck-target="${CSS.escape(o)}"]`);return /^[#.[]|[\s>:=]/.test(o)&&(l=V(o))!=null?l:s()},V=o=>{try{return document.querySelector(o)}catch(s){return null}},T=(o,s,l,g="auto")=>{var se;let k=l.getBoundingClientRect();Object.assign(s.style,{left:`${k.left-4}px`,top:`${k.top-4}px`,width:`${k.width+8}px`,height:`${k.height+8}px`});let N=window.innerWidth,_=window.innerHeight,u=Math.min(340,N-24),C=o.offsetHeight||200,v=14,E={bottom:_-k.bottom-v-12>=C,top:k.top-v-12>=C,right:N-k.right-v-12>=u,left:k.left-v-12>=u},b={top:"bottom",bottom:"top",left:"right",right:"left"},$=(se=(g==="auto"||!b[g]?["bottom","top"]:[g,b[g],"bottom","top","right","left"]).find(B=>E[B]))!=null?se:g!=="auto"&&b[g]?g:k.top>_-k.bottom?"top":"bottom",j=(B,Ee)=>Math.max(12,Math.min(B,Ee-12)),A=$==="top"||$==="bottom",oe=A?j(g==="auto"?k.left:k.left+k.width/2-u/2,N-u):$==="right"?k.right+v:k.left-v-u,ie=A?$==="bottom"?k.bottom+v:k.top-v-C:j(k.top+k.height/2-C/2,_-C);Object.assign(o.style,{left:`${oe}px`,top:`${ie}px`,right:"auto",bottom:"auto",width:`${u}px`}),o.setAttribute("data-side",$);let Ne=A?k.left+k.width/2-oe:k.top+k.height/2-ie;o.style.setProperty("--ckf-ap",`${Math.max(18,Math.min(Ne,(A?u:C)-18))}px`);},O=o=>{let s=o.items.filter(l=>l.done).length;return n("div",{className:"ckf-float"},n("div",{className:"ckf-card",role:"region","aria-labelledby":"ckf-title"},n("div",{className:"ckf-top"},n("h2",{className:"ckf-h",id:"ckf-title"},o.flow.name),U(f("Hide the checklist"),e.onboarding.dismiss)),n("p",{className:"ckf-small"},L("{done} of {total} done",{done:s,total:o.items.length})),n("div",{className:"ckf-bar",role:"progressbar","aria-valuemin":"0","aria-valuemax":String(o.items.length),"aria-valuenow":String(s)},n("i",{style:`width:${s/o.items.length*100}%`})),n("div",{className:"ckf-opts"},...o.items.map(({step:l,done:g,opens:k})=>{let N=[n("span",{className:"ckf-tick","aria-hidden":"true"},g?"\u2713":""),te(l.icon,"ckf-ic"),n("span",{},n("b",{},l.title),l.body?n("span",{className:"ckf-small"},l.body):false)];return !g&&k?n("button",{type:"button",className:"ckf-check","aria-label":L("Start \u201C{title}\u201D",{title:l.title}),"data-ckf-id":`t:${l.id}`,onClick:()=>e.onboarding.open(l.id)},...N,n("span",{className:"ckf-go","aria-hidden":"true"},"\u203A")):g||l.event?n("div",{className:"ckf-check","data-done":g,role:"listitem"},...N):n("button",{type:"button",className:"ckf-check","aria-label":L("Mark \u201C{title}\u201D done",{title:l.title}),"data-ckf-id":`i:${l.id}`,onClick:()=>e.onboarding.check(l.id)},...N)}))))},H=o=>{let s=o.message,l=s.button?I(s.button,"primary",e.message.click,{id:"go"}):false;return s.style==="banner"?n("div",{className:"ckf-banner",role:"status"},n("span",{},n("b",{},s.title),s.body?n("span",{className:"ckf-small"},s.body):false),l,U(f("Dismiss"),e.message.dismiss)):n("div",{className:"ckf-scrim",onClick:g=>g.target===g.currentTarget&&e.message.dismiss()},n("div",{className:"ckf-card",role:"dialog","aria-modal":"true","aria-labelledby":"ckf-title"},n("div",{className:"ckf-top"},n("span"),U(f("Dismiss"),e.message.dismiss)),n("h2",{className:"ckf-h",id:"ckf-title"},s.title),s.body?n("p",{className:"ckf-p"},s.body):false,l?n("div",{className:"ckf-row"},l):false))},z=()=>{var _,u,C,v,E,b,S,$;let o=e.view();xe(r);let s=(u=t.accent)!=null?u:(_=e.accent)==null?void 0:_.call(e);s&&r.style.setProperty("--ckf-accent",s);let l=(C=e.finale)==null?void 0:C.call(e);l&&l.key!==a&&(a=l.key,ce(l.kind,{accent:s}));let g=o?be(o):"",k=(E=(v=document.activeElement)==null?void 0:v.closest)!=null&&E.call(v,".ckf-root")?(b=document.activeElement)==null?void 0:b.getAttribute("data-ckf-id"):null;g&&!i&&document.activeElement instanceof HTMLElement&&!document.activeElement.closest(".ckf-root")&&(m=document.activeElement),g!==i&&!g.startsWith("c:")&&(d=""),g||(d=""),w=null;let N=o?Ie(o):"";if(r.toggleAttribute("data-still",!!N&&N===p),p=N,r.replaceChildren(...o?[o.type==="cancel"?c(o):o.type==="step"?M(o):o.type==="checklist"?O(o):H(o)]:[]),P(),g!==i){let j=r.querySelector("[aria-modal=true]"),A=(S=j==null?void 0:j.querySelector("[role=radio], input, [data-ckf-id=go], textarea"))!=null?S:null;A==null||A.focus(),!g&&m&&(m.focus(),m=null);}else k&&(($=r.querySelector(`[data-ckf-id="${CSS.escape(k)}"]`))==null||$.focus());i=g;},y=o=>{if(o.key!=="Escape")return;let s=e.view();(s==null?void 0:s.type)==="cancel"?e.cancel.close():(s==null?void 0:s.type)==="message"?e.message.dismiss():(s==null?void 0:s.type)==="step"&&(s.step.kind==="modal"||s.step.kind==="question")&&e.onboarding.dismiss();};function P(){w&&T(w.float,w.ring,w.target,w.side);}document.addEventListener("keydown",y),window.addEventListener("resize",P),window.addEventListener("scroll",P,{passive:true,capture:true});let K=e.subscribe(z),R=J(z);return z(),()=>{K(),R(),document.removeEventListener("keydown",y),window.removeEventListener("resize",P),window.removeEventListener("scroll",P,{capture:true}),r.remove();}},ve=(e,t={})=>{if(typeof document=="undefined")return ()=>{};let r=we(t),a="",i=null,p=()=>{var F,V,T;let c=e.view();xe(r);let x=c?`${c.paywall.id}:${c.index}`:"";if(x&&!a&&document.activeElement instanceof HTMLElement&&(i=document.activeElement),!c){r.replaceChildren(),r.removeAttribute("data-still"),a&&(i==null||i.focus()),a="";return}a&&r.setAttribute("data-still","");let h=c.page,M=h.kind==="plans"?n("div",{className:"ckf-opts",role:"radiogroup","aria-label":f("Plans")},...c.plans.map(O=>n("button",{type:"button",role:"radio",className:"ckf-opt ckf-plan","aria-checked":String(c.plan===O.id),"data-ckf-id":`p:${O.id}`,onClick:()=>e.pick(O.id)},n("span",{className:"ckf-radio"}),n("span",{},O.name,O.note?n("span",{className:"ckf-small"},O.note):false),n("b",{},O.price)))):false;r.replaceChildren(n("div",{className:"ckf-scrim",onClick:O=>O.target===O.currentTarget&&e.close()},n("div",{className:"ckf-card ckf-pw",role:"dialog","aria-modal":"true","aria-labelledby":"ckf-title"},n("div",{className:"ckf-top"},ne(c.index+1,c.total),U(f("Close"),e.close)),n("h2",{className:"ckf-h",id:"ckf-title"},h.title),h.body?n("p",{className:"ckf-p"},h.body):false,h.kind==="benefits"&&((F=h.items)!=null&&F.length)?n("div",{className:"ckf-opts"},...h.items.map(O=>n("p",{className:"ckf-li"},O))):false,h.kind==="proof"&&((V=h.quotes)!=null&&V.length)?n("div",{className:"ckf-opts"},...h.quotes.map(O=>n("blockquote",{className:"ckf-quote"},O.text,O.by?n("cite",{},O.by):false))):false,M,c.error?n("p",{className:"ckf-err",role:"alert"},c.error):false,n("div",{className:"ckf-btns"},I(c.busy?f("One moment\u2026"):h.button||f("Continue"),"primary",e.next,{disabled:c.busy||h.kind==="plans"&&!c.plan,id:"go"}),c.index?I(f("Back"),"quiet",e.back,{disabled:c.busy}):false)))),x!==a&&((T=r.querySelector("[data-ckf-id=go]"))==null||T.focus()),a=x;},m=c=>{e.view()&&c.key==="Escape"&&e.close();};document.addEventListener("keydown",m);let d=e.subscribe(p),w=J(p);return p(),()=>{d(),w(),document.removeEventListener("keydown",m),r.remove();}};var Le=e=>{let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return (t>>>0)/4294967296};var Te=e=>typeof e.weight=="number"&&e.weight>0?e.weight:0,Ce=(e,t)=>{var m,d;let r=(d=(m=e.variants[0])==null?void 0:m.id)!=null?d:"control";if(e.winner)return e.winner;if(e.status!=="running")return r;let a=Le(`${e.key}:${t}`),i=0,p;for(let w of e.variants){let c=Te(w);if(c&&(i+=c,p=w.id,a<i))return w.id}return p!=null?p:r},_e=(e,t,r)=>{if(!r||e.winner||e.status!=="running")return Ce(e,t);let a=`${e.key}
|
|
92
|
+
${t}`,i=r.get(a);if(i!==void 0&&e.variants.some(m=>m.id===i))return i;let p=Ce(e,t);return r.set(a,p),p};var $e=e=>e.status==="running"&&!e.winner;var Me=(e,t,r,a,i)=>{var m,d;if(a[e])return a[e];let p=t==null?void 0:t.experiments.find(w=>w.key===e);return p?r===null&&$e(p)?(d=(m=p.variants[0])==null?void 0:m.id)!=null?d:"control":_e(p,r!=null?r:"",i):"control"};var re="$paywall",Ae=(e,t,r,a)=>{var d,w;let i=t.experiment?e==null?void 0:e.experiments.find(c=>c.key===t.experiment):void 0,p=i?Me(i.key,e,r,{},a):(d=t.variants[0])==null?void 0:d.id,m=(w=t.variants.find(c=>c.id===p))!=null?w:t.variants[0];return m?{variant:m.id,pages:m.pages,test:(i==null?void 0:i.status)==="running"&&!i.winner&&r!==null?i.key:void 0}:null},Oe=e=>{let t=null,r=new Set,a=()=>{for(let c of [...r])try{c();}catch(x){}},i=()=>t?{paywall:t.w.id,placement:t.w.placement,variant:t.variant}:{},p=()=>{t&&!t.seen.has(t.index)&&(t.seen.add(t.index),e.track(re,{...i(),page:t.pages[t.index].id,index:t.index,action:"page"})),a();},m=c=>{var h,M;let x=t;x&&(t=null,c.outcome==="closed"&&((M=(h=x.options).onClose)==null||M.call(h,c)),x.resolve(c),a());},d=c=>{var x;return {outcome:c,index:(x=t==null?void 0:t.index)!=null?x:0,...t?{paywall:t.w.id,variant:t.variant}:{},...c!=="closed"&&t?{plan:t.plans.find(h=>h.id===t.plan)}:{}}},w=()=>{let c=t,x=c==null?void 0:c.plans.find(h=>h.id===c.plan);if(!(!c||!x||c.busy)){if(!c.options.onPurchase)return m(d("chosen"));c.busy=true,c.error=void 0,a(),Promise.resolve().then(()=>{var h,M;return (M=(h=c.options).onPurchase)==null?void 0:M.call(h,x)}).then(h=>{if(c.busy=false,t===c){if(h===false)return a();e.track(re,{...i(),page:c.pages[c.index].id,index:c.index,plan:x.id,action:"purchased"}),m(d("purchased"));}},()=>{c.busy=false,c.error=f("The purchase did not go through. Please try again."),a();});}};return {open:(c,x={})=>{var y,P,K;if(t)return t.promise;let h=e.config(),M=(y=h==null?void 0:h.paywalls)==null?void 0:y.find(R=>R.placement===c),F=M?Ae(h,M,e.distinctId(),e.kept):null;if(!M||!(F!=null&&F.pages.length))return Promise.resolve({outcome:"closed",index:0});let V=new Map(((P=x.plans)!=null?P:[]).map(R=>[R.id,R])),T=M.plans.map(R=>{var o;return (o=V.get(R.id))!=null?o:R}),O=()=>{},H=new Promise(R=>O=R),z=T.some(R=>R.id===M.highlight)?M.highlight:(K=T[0])==null?void 0:K.id;return t={w:M,variant:F.variant,pages:F.pages,plans:T,index:0,plan:z,busy:false,seen:new Set,options:x,resolve:O,promise:H},F.test&&e.track("$exposure",{experiment:F.test,variant:F.variant}),p(),H},view:()=>t?{paywall:t.w,variant:t.variant,page:t.pages[t.index],index:t.index,total:t.pages.length,last:t.index===t.pages.length-1,plans:t.plans,plan:t.plan,busy:t.busy,error:t.error}:null,subscribe:c=>(r.add(c),()=>r.delete(c)),next:()=>{if(!(!t||t.busy)){if(t.pages[t.index].kind==="plans"||t.index===t.pages.length-1)return w();t.index++,t.error=void 0,p();}},back:()=>{!t||t.busy||!t.index||(t.index--,t.error=void 0,a());},pick:c=>{!t||t.busy||!t.plans.some(x=>x.id===c)||(t.plan=c,t.error=void 0,a());},close:()=>{!t||t.busy||(e.track(re,{...i(),index:t.index,action:"closed"}),m(d("closed")));}}};var je=(e,t)=>{let r=Oe(e);return ve(r,t),r};window.__mrrocketFlows={mountFlows:ye,paywallHost:je};})();
|