@mrrocket/sdk 0.24.0 → 0.26.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 +16 -1
- package/README.md +22 -1
- package/dist/browser/mrrocket-flows.js +3 -3
- 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/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 +1 -1
- package/dist/react-native/index.d.ts +1 -1
- package/dist/react-native/index.js +1 -1
- package/dist/react-native/index.js.map +1 -1
- package/dist/server.d.ts +18 -0
- package/dist/server.js +31 -0
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,22 @@
|
|
|
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.26.0 (not published yet; MRRocket's `/api/sdk/preview` must be live first)
|
|
6
|
+
|
|
7
|
+
- **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.
|
|
8
|
+
- **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.
|
|
9
|
+
- **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.
|
|
10
|
+
- **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.
|
|
11
|
+
- **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.
|
|
12
|
+
- **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.
|
|
13
|
+
- Version reported in event batches: `0.26.0`.
|
|
14
|
+
|
|
15
|
+
## 0.25.0 (not published yet)
|
|
16
|
+
|
|
17
|
+
- **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".
|
|
18
|
+
- Version reported in event batches: `0.25.0`.
|
|
19
|
+
|
|
20
|
+
## 0.24.0 (includes 0.23.1)
|
|
6
21
|
|
|
7
22
|
- **A/B tests keep a cookieless visitor in one version all day (web, script tag, Next.js server and React Native).** The config now carries `unit`, the daily visitor hash MRRocket's event ingest gives that visitor. Without a signed-in id or a `ck_id` cookie, tests assign by it, so a reload no longer reshuffles the version. Nothing is stored on the visitor's device: the unit lives in memory, and React Native leaves it out of the cached config. Cookieless events carry it as their id, so exposures and conversions are counted under the id that chose the version. An `identify()` id or the provider's `distinctId` still comes first, then `ck_id`.
|
|
8
23
|
- **Until the unit is there, a running test shows control and records nothing**, so no visitor is counted in a version they then leave. A shipped winner shows at once.
|
package/README.md
CHANGED
|
@@ -118,6 +118,27 @@ 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
|
+
|
|
127
|
+
### Tests your server decides (0.25.0)
|
|
128
|
+
|
|
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.
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
// app/api/checkout/route.ts
|
|
133
|
+
import { getCockpitConfig, trackVariant } from "@mrrocket/sdk/next/server";
|
|
134
|
+
|
|
135
|
+
const config = await getCockpitConfig();
|
|
136
|
+
const version = await trackVariant("checkout-game-picture", { config, distinctId: user.id }); // "control" or "a"
|
|
137
|
+
const session = await stripe.checkout.sessions.create({ ...(version === "a" ? { line_items: withPicture } : { line_items }) });
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
It needs the server key (`MRROCKET_SERVER_KEY`) next to the public key, sends nothing while the test is not running, and never holds the request longer than 2.5 seconds. Pass the same `distinctId` your app gives `identify()`, so the purchase or signup that follows counts for that person. Call it only for people your product may count, as for its other MRRocket events.
|
|
141
|
+
|
|
121
142
|
With `consent="cookies"`, give first-time visitors their `ck_id` before the page renders. This writes a cookie, so only do it once the visitor agreed:
|
|
122
143
|
|
|
123
144
|
```ts
|
|
@@ -134,7 +155,7 @@ export function proxy(request: NextRequest) {
|
|
|
134
155
|
|
|
135
156
|
## 5. Cloudflare Workers (OpenNext)
|
|
136
157
|
|
|
137
|
-
The server helpers (`getCockpitConfig`, `getVariant`, `getTexts`, `previewFrom`) and the proxy helper use only `fetch`, `AbortController` and plain objects, so they run on Node, the Edge runtime and Workers via `@opennextjs/cloudflare`. Put the two variables where `next build` reads them (`.env`, `.env.production`, or your CI environment), because Next.js inlines `NEXT_PUBLIC_*` during the build, not at request time.
|
|
158
|
+
The server helpers (`getCockpitConfig`, `getVariant`, `trackVariant`, `getTexts`, `previewFrom`) and the proxy helper use only `fetch`, `AbortController` and plain objects, so they run on Node, the Edge runtime and Workers via `@opennextjs/cloudflare`. Put the two variables where `next build` reads them (`.env`, `.env.production`, or your CI environment), because Next.js inlines `NEXT_PUBLIC_*` during the build, not at request time.
|
|
138
159
|
|
|
139
160
|
## 6. Previews in MRRocket
|
|
140
161
|
|
|
@@ -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};})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){'use strict';var F="mrr_edit",U="data-mrr-preview",k="data-mrr-preview-missed",P="mrr-preview-ready";var N=(t,e)=>{var d,m,b,x,h;let n=t!=null?t:{project:"",experiments:[]},o=((d=e.experiments)!=null?d:[]).filter(g=>g&&typeof g.key=="string"&&Array.isArray(g.variants)),l=new Set(o.map(g=>g.key)),{redirects:i,...u}=n;return {config:{...u,...(m=e.config)!=null?m:{},experiments:[...n.experiments.filter(g=>!l.has(g.key)),...o],...n.texts||e.texts?{texts:{...(b=n.texts)!=null?b:{},...(x=e.texts)!=null?x:{}}}:{}},force:{...(h=e.force)!=null?h:{}}}};var W=async(t,e,n,o=fetch)=>{let l=await o(`${t}/api/sdk/preview?token=${encodeURIComponent(e)}`),i=l.ok?await l.json().catch(()=>null):null;return i&&typeof i=="object"?{payload:i,...N(n,i)}:null},f=t=>(t!=null?t:"").replace(/\s+/g," ").trim(),H="script,style,noscript,svg,template,iframe,textarea,input,select,option,[data-mrr-bar]",B="h1,h2,h3,h4,h5,h6,p,li,a,button,blockquote,figcaption,label,span,td,th,dt,dd,summary,strong,em,b,i,small,div",R="data-mrr-wrap",A=t=>{let e=t.children.length===1?t.children[0]:null;return e&&e.getAttribute(R)!==null&&f(e.textContent)===f(t.textContent)?e:null},K=t=>{var e;return t.getAttribute("data-ck-text")||((e=A(t))==null?void 0:e.getAttribute("data-ck-text"))||void 0},X=t=>{if(!f(t.textContent))return false;if(A(t))return true;for(let e of Array.from(t.childNodes))if(e.nodeType!==3&&!(e.nodeType===1&&e.tagName.toLowerCase()==="br"))return false;return true},j=t=>{let e=[],n=t;for(;n;){let o=n.tagName.toLowerCase();if(o==="body"||o==="html"){e.unshift("body");break}if(n.id&&/^[A-Za-z][\w-]*$/.test(n.id)){e.unshift(`${o}#${n.id}`);break}let l=n.parentElement,i=l?Array.from(l.children).filter(u=>u.tagName===n.tagName):[n];e.unshift(i.length>1?`${o}:nth-of-type(${i.indexOf(n)+1})`:o),n=l;}return e.join(" > ")},Y=t=>{var l,i,u;let e=t.querySelector("[data-mrr-body]");if(e)return e;let n=new Map;for(let d of Array.from(t.querySelectorAll("p"))){let m=f(d.textContent).length;m<40||!d.parentElement||d.closest("header, footer, nav, aside")||n.set(d.parentElement,((l=n.get(d.parentElement))!=null?l:0)+m);}let o=null;for(let[d,m]of n)(!o||m>((i=n.get(o))!=null?i:0))&&(o=d);return (u=o!=null?o:t.querySelector("article"))!=null?u:t.querySelector("main")},z=(t,e)=>{if(e.op==="set"){let n=null;try{n=t.querySelector(e.selector);}catch(l){return `${e.selector} (not a selector)`}if(!n)return `${e.selector} (not on the page)`;let o=f(n.textContent);return e.from!==void 0&&o!==f(e.from)&&o!==f(e.text)?`${e.selector} (reads something else now)`:(n.textContent=e.text,n.setAttribute("data-mrr-changed",""),null)}if(e.op==="body"){let n=Y(t);return n?(n.innerHTML=e.html,n.setAttribute("data-mrr-changed",""),null):"the page's text (no text block found)"}if(e.title&&(t.title=e.title),e.description!==void 0){let n=t.querySelector('meta[name="description"]');!n&&t.head&&(n=t.createElement("meta"),n.setAttribute("name","description"),t.head.appendChild(n)),n==null||n.setAttribute("content",e.description);}return null},J=(t,e)=>{var o,l;let n=[];for(let i of (o=e.changed)!=null?o:[]){let u=Array.from(t.querySelectorAll("[data-ck-text]")).filter(d=>d.getAttribute("data-ck-text")===i);u.length||n.push(`${i} (the page does not mark this text)`);for(let d of u)(d.getAttribute(R)!==null&&d.parentElement?d.parentElement:d).setAttribute("data-mrr-changed","");}for(let i of (l=e.ops)!=null?l:[]){let u=z(t,i);u&&n.push(u);}return n},Q=(t,e,n=[])=>{let o=t.documentElement,l=n.slice(0,20).map(u=>u.slice(0,200));if(o.setAttribute(U,e),l.length?o.setAttribute(k,JSON.stringify(l)):o.removeAttribute(k),!t.body)return;let i=t.querySelector("[data-mrr-preview-status]");i||(i=t.createElement("div"),i.setAttribute("data-mrr-preview-status",""),i.setAttribute("role","status"),i.setAttribute("style","position:fixed;left:0;top:0;width:1px;height:1px;overflow:hidden;opacity:0;pointer-events:none"),t.body.appendChild(i)),i.textContent=l.length?`${P} missed: ${l.join(" | ")}`:P;},Z=t=>Array.from(t.querySelectorAll(B)).filter(e=>!e.closest(H)&&e.getAttribute(R)===null&&X(e)),G="[data-mrr-bar]{position:fixed;top:0;left:0;right:0;z-index:2147483647;display:flex;align-items:center;gap:12px;height:44px;padding:0 12px;background:#fff;color:#1d2939;border-bottom:1px solid #e4e7ec;font:500 13px/1 Inter,system-ui,-apple-system,sans-serif;box-sizing:border-box}[data-mrr-bar] b{font-weight:600}[data-mrr-bar] span[data-mrr-note]{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#667085}[data-mrr-bar] button{all:unset;box-sizing:border-box;cursor:pointer;height:28px;padding:0 10px;border-radius:6px;font:600 13px/28px Inter,system-ui,sans-serif;color:#344054;box-shadow:inset 0 0 0 1px #d0d5dd;background:#fff}[data-mrr-bar] button[data-mrr-save]{color:#fff;background:#3f76ff;box-shadow:none}[data-mrr-bar] button[disabled]{opacity:.5;cursor:default}[data-mrr-bar] button:focus-visible{outline:2px solid #3f76ff;outline-offset:2px}html[data-mrr-editing]{scroll-padding-top:52px}html[data-mrr-editing] body{margin-top:44px!important}[data-mrr-edit]{cursor:text;outline:1px dashed transparent;outline-offset:2px;border-radius:2px}[data-mrr-edit]:hover{outline-color:#98a2b3}[data-mrr-edit][data-mrr-changed]{outline:1px solid #3f76ff}[data-mrr-edit]:focus{outline:2px solid #3f76ff}[data-mrr-edit][data-mrr-edited]{background:rgba(63,118,255,.08)}",tt=t=>{var n;if(!t.ok)return t.error||"Could not save. Open the page from MRRocket again.";let e=[];return t.saved&&e.push(`${t.saved} saved`),t.handed&&e.push(`${t.handed} handed to the agent`),(n=t.missed)!=null&&n.length&&e.push(`${t.missed.length} not saved (${t.missed[0].reason})`),e.length?`${e.join(" \xB7 ")}. The request in MRRocket shows the new version.`:"Nothing changed."},et=(t,e,n)=>{var V,M,L;let o=t.documentElement;o.setAttribute("data-mrr-editing","");let l=t.createElement("style");l.setAttribute("data-mrr-bar-style",""),l.textContent=G,((V=t.head)!=null?V:o).appendChild(l);let i=t.createElement("div");i.setAttribute("data-mrr-bar",""),i.setAttribute("role","toolbar"),i.setAttribute("aria-label","MRRocket page editor");let u=t.createElement("b");u.textContent="MRRocket";let d=t.createElement("span");d.setAttribute("data-mrr-note",""),d.setAttribute("aria-live","polite");let m=`Editing ${[e.title,e.version].filter(Boolean).join(" \xB7 ")||"this page"}. Click any text to change it.`;d.textContent=m;let b=t.createElement("button");b.setAttribute("type","button"),b.textContent="Cancel";let x=t.createElement("button");x.setAttribute("type","button"),x.setAttribute("data-mrr-save",""),x.textContent="Save",i.appendChild(u),i.appendChild(d),i.appendChild(b),i.appendChild(x),((M=t.body)!=null?M:o).appendChild(i);let h=new Map,g=Z(t);for(let r of g)h.set(r,(L=r.textContent)!=null?L:""),r.setAttribute("data-mrr-edit",""),r.setAttribute("contenteditable","plaintext-only"),r.contentEditable!==void 0&&r.contentEditable!=="plaintext-only"&&r.setAttribute("contenteditable","true"),r.setAttribute("spellcheck","true");let w=()=>g.filter(r=>f(r.textContent)!==f(h.get(r))).map(r=>({selector:j(r),...K(r)?{textId:K(r)}:{},from:f(h.get(r)),to:f(r.textContent)})),E=r=>{var s;return !!(r&&((s=r.closest)!=null&&s.call(r,"[data-mrr-bar]")))},v=r=>{E(r.target)||(r.preventDefault(),r.stopPropagation());},_=r=>{var a,c,p,y;let s=r;E(s.target)||(s.key==="Enter"&&(s.preventDefault(),(c=(a=s.target)==null?void 0:a.blur)==null||c.call(a)),s.key==="Escape"&&((y=(p=s.target)==null?void 0:p.blur)==null||y.call(p)),s.stopPropagation());},S=r=>{var p,y,D;let s=r;if(E(s.target))return;s.preventDefault();let a=(y=(p=s.clipboardData)==null?void 0:p.getData("text/plain"))!=null?y:"",c=(D=t.getSelection)==null?void 0:D.call(t);c!=null&&c.rangeCount&&(c.deleteFromDocument(),c.getRangeAt(0).insertNode(t.createTextNode(a.replace(/\s+/g," "))),c.collapseToEnd());},I=r=>{var c,p;let s=(p=(c=r.target)==null?void 0:c.closest)==null?void 0:p.call(c,"[data-mrr-edit]");if(!s)return;f(s.textContent)!==f(h.get(s))?s.setAttribute("data-mrr-edited",""):s.removeAttribute("data-mrr-edited");let a=w().length;d.textContent=a?`${a} ${a===1?"change":"changes"} not saved yet.`:m;},$=r=>{var a,c;let s=(c=(a=r.target)==null?void 0:a.closest)==null?void 0:c.call(a,"[data-mrr-edit]");s&&s.children.length&&!A(s)&&(s.textContent=f(s.textContent));};t.addEventListener("click",v,true),t.addEventListener("submit",v,true),t.addEventListener("keydown",_,true),t.addEventListener("paste",S,true),t.addEventListener("input",I,true),t.addEventListener("blur",$,true);let O=()=>{t.removeEventListener("click",v,true),t.removeEventListener("submit",v,true),t.removeEventListener("keydown",_,true),t.removeEventListener("paste",S,true),t.removeEventListener("input",I,true),t.removeEventListener("blur",$,true);for(let r of g)r.removeAttribute("contenteditable"),r.removeAttribute("data-mrr-edit"),r.removeAttribute("data-mrr-edited"),r.removeAttribute("spellcheck");i.remove(),l.remove(),o.removeAttribute("data-mrr-editing");},C=false,T=async()=>{var s;let r=w();if(!r.length)return {ok:true,saved:0};try{let a=await((s=n.fetch)!=null?s:fetch)(`${n.host}/api/sdk/preview/edit`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({token:n.token,path:n.path,edits:r})}),c=await a.json().catch(()=>null);return a.ok?c!=null?c:{ok:!1,error:"MRRocket's answer could not be read."}:{ok:!1,error:(c==null?void 0:c.error)||(a.status===401?"This edit link has expired. Open the page from MRRocket again.":`MRRocket answered ${a.status}.`)}}catch(a){return {ok:false,error:"MRRocket could not be reached. Nothing was saved."}}};return x.addEventListener("click",()=>{C||(C=true,x.setAttribute("disabled",""),d.textContent="Saving\u2026",T().then(r=>{var a,c;if(C=false,x.removeAttribute("disabled"),d.textContent=tt(r),!r.ok)return;let s=new Set(((a=r.missed)!=null?a:[]).map(p=>p.selector));for(let p of g)s.has(j(p))||(h.set(p,(c=p.textContent)!=null?c:""),p.removeAttribute("data-mrr-edited"));b.textContent="Done";}));}),b.addEventListener("click",()=>{var r,s;for(let a of g)f(a.textContent)!==f(h.get(a))&&(a.textContent=(r=h.get(a))!=null?r:"");O(),(s=n.leave)==null||s.call(n);}),{edits:w,save:T,stop:O}},nt=(t,e,n)=>{let o=J(t,e);return Q(t,"ready",o),{missed:o,editor:n.edit&&e.edit&&!t.querySelector("[data-mrr-bar]")?et(t,e,n):null}},q=async(t,e,n)=>{let o=await W(t,e,n);if(!o)return null;let l=new URLSearchParams(window.location.search).get(F)==="1";return {config:o.config,force:o.force,show:()=>{nt(document,o.payload,{host:t,token:e,edit:l,path:window.location.pathname,leave:()=>window.close()});}}};window.__mrrocketPreview={bootPreview:q};})();
|