@houzhen888/groove-grow 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +118 -2
- package/dist/chunk-6X42DWOM.js +1 -0
- package/dist/chunk-6ZT3HFRV.js +1 -0
- package/dist/chunk-TJCXCI4R.js +1 -0
- package/dist/index-B28lxbb1.d.ts +1971 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/dist/popup.d.ts +134 -0
- package/dist/popup.js +43 -0
- package/dist/server.d.ts +432 -0
- package/dist/server.js +1 -0
- package/dist/src-R33ZCCKV.js +1 -0
- package/dist/transport-BJDM_5sZ.d.ts +5048 -0
- package/package.json +51 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.0.1
|
|
4
|
+
|
|
5
|
+
First Web SDK Beta release, distributed as one package with core, server and popup ESM entries.
|
|
6
|
+
|
|
7
|
+
- Customer sessions, catalog, entitlements, offers, credits, membership and billing API adapters.
|
|
8
|
+
- Distribute the test release as `@houzhen888/groove-grow` with the `beta` tag.
|
|
9
|
+
- Exclude placeholder generic events and the legacy subscription management endpoint; use popup/Funnel events and membership management.
|
|
10
|
+
- Isolated popup / paywall / page rendering and server-driven Funnel lifecycle.
|
|
11
|
+
- Load the Funnel renderer only when presenting a flow.
|
|
12
|
+
- Invalidate pending Funnel authentication and node requests on identity changes.
|
|
13
|
+
- Normalize Funnel validation failures to GrooveError.
|
|
14
|
+
- Remove Funnel UI immediately on close, including telemetry failure and early close.
|
|
15
|
+
- Isolate synchronous and asynchronous host notification failures.
|
|
16
|
+
- Build before packing and verify installed artifacts outside the workspace.
|
|
17
|
+
|
|
18
|
+
Beta limits: ESM only; no automatic session refresh, retry, offline queue or generic events API. Billing needs explicit per-App Stripe Sandbox configuration. A later company scope requires updating package imports.
|
package/README.md
CHANGED
|
@@ -1,3 +1,119 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @houzhen888/groove-grow
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Groove Grow 的框架无关 Web / TypeScript SDK。首版 `0.0.1` 用于 Beta 接入测试。一个 npm 包提供三个 ESM 入口,无需内部 contracts 包、React、Next.js 或 Supabase。
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @houzhen888/groove-grow@beta
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
通过个人测试 scope 分发。正式公司包名将另行公布,迁移时需要更新依赖和导入路径。本地安装可使用 `pnpm test:sdk-package` 生成的 `.local/sdk-package-check/houzhen888-groove-grow-0.0.1.tgz`。
|
|
10
|
+
|
|
11
|
+
| 入口 | 用途 | 加载行为 |
|
|
12
|
+
| -------------------------------- | --------------------------------------------- | ---------------------------------------- |
|
|
13
|
+
| `@houzhen888/groove-grow` | 客户 API、Funnel 客户端与 `showFunnel` | 被动导入;展示 Funnel 时才加载渲染器 |
|
|
14
|
+
| `@houzhen888/groove-grow/server` | 客户管理、Session 签发、积分写入、Funnel 启动 | 被动导入;禁止在浏览器创建 Secret 客户端 |
|
|
15
|
+
| `@houzhen888/groove-grow/popup` | 远程投放、离线渲染、编辑预览 | 调用展示方法时挂载 UI |
|
|
16
|
+
|
|
17
|
+
支持现代浏览器及 Node.js 22+ ESM,暂不提供 CommonJS 或原生移动端 SDK。
|
|
18
|
+
|
|
19
|
+
## 可信后端:绑定自己的登录用户
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { createGrooveServer } from "@houzhen888/groove-grow/server";
|
|
23
|
+
const server = createGrooveServer({
|
|
24
|
+
baseUrl: "https://groove-grow.vercel.app",
|
|
25
|
+
apiKey: process.env.GROOVE_SECRET_KEY!,
|
|
26
|
+
scope: { projectId: "your-app-uuid", environment: "sandbox" },
|
|
27
|
+
});
|
|
28
|
+
// verifiedUser 必须来自应用自己的可信登录会话。
|
|
29
|
+
const { customer } = await server.getOrCreateCustomer({
|
|
30
|
+
externalUserId: verifiedUser.id,
|
|
31
|
+
name: verifiedUser.name,
|
|
32
|
+
});
|
|
33
|
+
const { customerToken } = await server.createCustomerSession(customer.id);
|
|
34
|
+
// 仅向已验证的当前用户返回 customerToken。
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
浏览器提供的 customerId 不能作为登录证明。Secret Key 不得出现在客户端代码、HTML 或日志中。每个 App / 环境单独配置 Key、权限与 allowed_origins。
|
|
38
|
+
|
|
39
|
+
## 浏览器:读取权益并显式展示
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { createGroove } from "@houzhen888/groove-grow";
|
|
43
|
+
import { showRemotePopup } from "@houzhen888/groove-grow/popup";
|
|
44
|
+
const grow = createGroove({
|
|
45
|
+
baseUrl: "https://groove-grow.vercel.app",
|
|
46
|
+
scope: { projectId: "your-app-uuid", environment: "sandbox" },
|
|
47
|
+
locale: "en",
|
|
48
|
+
});
|
|
49
|
+
grow.identify(customerToken);
|
|
50
|
+
const plans = await grow.listPlans();
|
|
51
|
+
const rights = await grow.getEntitlements();
|
|
52
|
+
const popup = await showRemotePopup(grow, "upgrade", {
|
|
53
|
+
onEvent(event) {
|
|
54
|
+
console.log(event.type);
|
|
55
|
+
},
|
|
56
|
+
onError(error) {
|
|
57
|
+
/* 向应用自己的监控报告 */
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
// 退出登录或切换账号时,先销毁展示,再清除身份。
|
|
61
|
+
popup?.destroy();
|
|
62
|
+
grow.reset();
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
客户 Token 仅在内存保存。浏览器方法绑定当前客户,不接受任意其他客户 ID。`reset()` / `identify()` 取消旧请求并丢弃迟到响应,不能撤回服务器已执行的操作。宿主负责销毁当前展示并刷新过期 Token。
|
|
66
|
+
|
|
67
|
+
## 首版能力
|
|
68
|
+
|
|
69
|
+
| 能力 | 浏览器 | 可信后端 |
|
|
70
|
+
| ---------- | ------------------------------------------------------ | -------------------------------------------------- |
|
|
71
|
+
| 客户与权益 | 身份、套餐目录、权益 | 创建 / 查询 / 更新客户、签发 Session、查询客户权益 |
|
|
72
|
+
| 优惠 | 查询、通过投放凭证领取 | 定向发放 |
|
|
73
|
+
| 积分 | 余额、检查、流水、积分包 / 订单、积分包结账 | 另有原子消费、预扣、结算、退款、授予 |
|
|
74
|
+
| 会员与订阅 | 持有情况、变更预览、会员管理、订阅查询、托管结账 | 配置与实际状态由后端及验证后的支付通知管理 |
|
|
75
|
+
| 界面 | 弹窗、付费墙、独立页面、多页流程、语言、按钮导航与分支 | 控制台配置发布版本与投放规则 |
|
|
76
|
+
| Funnel | 读取、专用事件、认证链接、业务节点确认 / 取消 | 匿名启动 / 撤销 |
|
|
77
|
+
|
|
78
|
+
支付方法要求对应 App 显式配置 Stripe Sandbox 账户、测试凭据、价格映射和 Key 权限。SDK 提供方法不代表托管环境已完成支付配置;点击、回跳与客户端事件不能证明付款成功。积分数量传十进制字符串,写入复用稳定幂等键。浏览器不提供积分消费或管理权限。
|
|
79
|
+
|
|
80
|
+
## 展示与 Funnel 生命周期
|
|
81
|
+
|
|
82
|
+
服务端 `createFunnelServer().start()` 返回 24 小时 `runToken` 和 180 天 `visitorToken` / `visitorExpiresAt`。宿主后端自行保存访客凭证(建议 HttpOnly cookie),下一次 start 传回以保持匿名 subject;SDK 不自动写 cookie。访客凭证不登录客户,也不能用于浏览器 Funnel 操作。签发 key / App / 环境必须相同,清凭证或换设备无法自动恢复匿名身份。详见仓库接入协议 `docs/growth-integration.md`。
|
|
83
|
+
|
|
84
|
+
`showRemotePopup` 获取投放、展示并上报专用事件;失败返回 `null` 或通知 `onError`。优惠领取与购买动作调用对应业务 API。`getPopup` / `trackPopup` 供宿主控制交付和重试。离线 `showPopup(document, options)` 只渲染,不自动持久化或执行远程业务操作。
|
|
85
|
+
|
|
86
|
+
内容在 sandbox iframe 内渲染,弹窗外层使用 Shadow DOM。同页最多一个弹窗;销毁清理节点、监听器、计时器并恢复焦点。预览也使用同一渲染器。宿主通知回调的同步异常与 Promise 拒绝被隔离;`onAuthenticate` 是需要等待结果的业务回调。
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { createFunnelClient, showFunnel } from "@houzhen888/groove-grow";
|
|
90
|
+
const flow = createFunnelClient({
|
|
91
|
+
baseUrl: "https://groove-grow.vercel.app",
|
|
92
|
+
runToken, // 自己的后端调用 createFunnelServer().start() 得到。
|
|
93
|
+
scope: { projectId: "your-app-uuid", environment: "sandbox" },
|
|
94
|
+
});
|
|
95
|
+
const handle = await showFunnel(container, {
|
|
96
|
+
client: flow,
|
|
97
|
+
onAuthenticate: async () => obtainCurrentUserCustomerToken(),
|
|
98
|
+
onCheckout(checkout) {
|
|
99
|
+
window.location.assign(checkout.url);
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
// 立即移除 UI;Promise 表示关闭事件是否提交成功。重复 close 不重复提交。
|
|
103
|
+
await handle.close().catch(reportError);
|
|
104
|
+
flow.reset();
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`destroy()` 只清理本地 UI,不记录服务端关闭。切换账号时销毁旧展示,为新用户创建或识别客户端。
|
|
108
|
+
|
|
109
|
+
## 错误与 Beta 边界
|
|
110
|
+
|
|
111
|
+
API 使用 `GrooveError`,包括 `INVALID_REQUEST`、`INVALID_RESPONSE`、`NOT_IDENTIFIED`、`IDENTITY_CHANGED`、`TIMEOUT`、`NETWORK_ERROR`、`SCOPE_MISMATCH` 和服务端业务码。HTTPS 或 localhost HTTP;默认超时 10 秒覆盖响应体读取;禁用重定向、Cookie 凭据与响应缓存。
|
|
112
|
+
|
|
113
|
+
没有自动网络重试、离线队列或 Session 刷新。重试写入时复用 requestId / eventId / 幂等键;页面退出不保证遥测送达。使用 `trackPopup` / Funnel 专用事件,首版不提供通用 `track()`。订阅操作使用 `manageMembership()`,首版不提供旧 `manageSubscription()`。统一 `present(trigger)`、原生恢复购买和跨平台购买尚未提供。
|
|
114
|
+
|
|
115
|
+
## 仓库验证
|
|
116
|
+
|
|
117
|
+
`pnpm test:sdk-package` 在仓库外安装实际 tarball,检查 NodeNext / Bundler 严格 TypeScript、三个 ESM 入口、被动导入、后端运行限制、模拟 API 和消费者 bundle。`prepack` 自动重新构建,避免发布旧 dist。Zod 是公开依赖,DOMPurify / CSS Tree 用于渲染器;基础 API 导入不加载它们。
|
|
118
|
+
|
|
119
|
+
详细接入见仓库 `docs/growth-integration.md`、`docs/credits-integration.md` 和 `docs/sdk-audit-2026-10-02.md`。当前标记 `UNLICENSED`,本次发布不新增开源许可证。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function o(n,...e){try{Promise.resolve(n?.(...e)).catch(()=>{})}catch{}}export{o as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as T,i as I}from"./chunk-TJCXCI4R.js";var e=class extends Error{constructor(o,f,l,u){super(f);this.code=o;this.status=l;this.requestId=u;this.name="GrooveError"}code;status;requestId},_=Symbol("GrooveNoContent");function S(c){let a=c.scope?T.parse(c.scope):void 0,o=new URL(c.baseUrl);if(o.username||o.password||o.search||o.hash)throw new e("INVALID_URL","baseUrl must not contain credentials, query, or fragment");if(o.protocol!=="https:"&&!(o.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(o.hostname)))throw new e("INVALID_URL","Use HTTPS, or HTTP on localhost during development");let f=c.fetch??globalThis.fetch.bind(globalThis),l=c.timeoutMs??1e4;if(!Number.isFinite(l)||l<=0||l>12e4)throw new e("INVALID_TIMEOUT","timeoutMs must be between 1 and 120000");let u=null,d=0,h=new Set;function g(){d+=1,u=null;for(let n of h)n.abort();h.clear()}async function v(n,E={},b="POST"){if(!u)throw new e("NOT_IDENTIFIED","Call identify with a server-issued customer token first");let w=d,t=new AbortController;h.add(t);let m=()=>w!==d?new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):new e("TIMEOUT","Groove request timed out"),p,y=new Promise((r,s)=>{p=()=>s(m()),t.signal.addEventListener("abort",p,{once:!0})}),N=setTimeout(()=>t.abort(),l),O=async()=>{let r=await f(`${o.href.replace(/\/$/,"")}/api/v1/${n}`,{method:b,headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`,...a?{"X-Groove-Project":a.projectId,"X-Groove-Environment":a.environment}:{}},body:b==="POST"?JSON.stringify(E):void 0,signal:t.signal,credentials:"omit",cache:"no-store",redirect:"error"});if(t.signal.aborted)throw m();let s=r.status===204?_:await r.json();if(t.signal.aborted)throw m();if(w!==d)throw new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight");if(!r.ok){let i=I.safeParse(s);throw new e(i.success?i.data.error.code:"HTTP_ERROR",i.success?i.data.error.message:"Groove request failed",r.status,r.headers.get("X-Request-Id")??void 0)}if(a&&s&&typeof s=="object"&&"scope"in s){let i=T.safeParse(s.scope);if(!i.success||i.data.projectId!==a.projectId||i.data.environment!==a.environment)throw new e("SCOPE_MISMATCH","Response scope does not match this SDK instance")}return s};try{return await Promise.race([O(),y])}catch(r){throw w!==d?new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):r instanceof e?r:new e(t.signal.aborted?"TIMEOUT":"NETWORK_ERROR",t.signal.aborted?"Groove request timed out":"Unable to read the Groove response")}finally{clearTimeout(N),t.signal.removeEventListener("abort",p),h.delete(t)}}return{identify(n){if(!n.trim()||/\s/.test(n)||n.length>4096)throw new e("INVALID_TOKEN","A nonempty server-issued token is required");g(),u=n},reset:g,request:v}}export{e as a,S as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as Se}from"zod";var ke=Se.enum(["sandbox","live"]),M=Se.object({projectId:Se.string().min(1),environment:ke});import{z}from"zod";var dn=z.object({minAccountAgeDays:z.number().int().min(0).max(3650),paymentStatus:z.enum(["all","unpaid","paid"])}),mn=z.object({percentOff:z.number().int().min(1).max(100),redemptionWindowHours:z.number().int().min(1).max(2160)}),fn=z.object({title:z.string().trim().min(1).max(80),description:z.string().trim().min(1).max(240),buttonLabel:z.string().trim().min(1).max(30)}),gn=z.object({name:z.string().trim().min(1).max(80),audience:dn,offer:mn,popup:fn}),Or=gn.extend({id:z.string().min(1),projectId:z.string().min(1),environment:ke,status:z.enum(["draft","active","paused"]),updatedAt:z.iso.datetime()}),_r=M.extend({id:z.string().min(1),externalUserId:z.string().min(1),name:z.string().min(1),email:z.union([z.email(),z.literal("")]),createdAt:z.iso.datetime(),paymentStatus:z.enum(["unpaid","paid"]),stripeCustomerId:z.string().nullable()}),Tr=z.object({error:z.object({code:z.string(),message:z.string()})});import{z as h}from"zod";import{z as x}from"zod";var ve=x.object({group:x.string().regex(/^[a-z][a-z0-9_]{0,63}$/).default("main"),kind:x.enum(["main","addon"]).default("main")}).strict(),Ie=x.enum(["immediate","end_of_cycle"]),Ke=x.enum(["attach","change","cancel","resume","cancel_change"]),je=x.object({action:Ke,planVersionId:x.uuid().optional(),holdingId:x.uuid().optional(),timing:Ie.optional(),requestId:x.uuid()}).strict().superRefine((e,t)=>{["attach","change"].includes(e.action)&&!e.planVersionId&&t.addIssue({code:"custom",path:["planVersionId"],message:"Target plan version required"}),!["attach","change"].includes(e.action)&&(e.planVersionId||e.timing)&&t.addIssue({code:"custom",message:"Only plan changes accept a target and timing"})}),We=x.object({direction:x.enum(["new","upgrade","downgrade","same"]),timing:Ie,group:x.string(),kind:x.enum(["main","addon"]),currentPlanVersionId:x.uuid().nullable(),targetPlanVersionId:x.uuid(),effectiveAt:x.iso.datetime(),amountDueCents:x.number().int().nullable(),currency:x.literal("USD"),requiresCheckout:x.boolean()}),Ge=x.object({id:x.uuid(),subscriptionId:x.uuid().nullable(),targetPlanVersionId:x.uuid().nullable(),action:Ke,timing:Ie,status:x.enum(["preparing","payment_pending","scheduled","completed","canceled","failed"]),effectiveAt:x.iso.datetime().nullable(),createdAt:x.iso.datetime()}),hn=x.object({id:x.uuid(),planVersionId:x.uuid(),planId:x.uuid(),name:x.string(),group:x.string(),kind:x.enum(["main","addon"]),source:x.enum(["subscription","assignment"]),status:x.string(),accessEnabled:x.boolean(),startsAt:x.iso.datetime().nullable(),endsAt:x.iso.datetime().nullable(),cancelAtPeriodEnd:x.boolean(),scheduledChange:Ge.nullable()}),Ye=x.object({customerId:x.uuid(),evaluatedAt:x.iso.datetime(),holdings:x.array(hn),changes:x.array(Ge)}),Je=x.object({changeId:x.uuid(),status:x.enum(["payment_pending","scheduled","completed"]),checkout:x.object({checkoutId:x.uuid(),url:x.url()}).nullable(),paymentUrl:x.url().nullable().optional(),effectiveAt:x.iso.datetime().nullable()});import{z as p}from"zod";var F=p.string().regex(/^(0|[1-9]\d{0,12})(\.\d{1,12})?$/),U=p.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e),K=U.refine(e=>/[1-9]/.test(e),"\u6570\u91CF\u5FC5\u987B\u5927\u4E8E 0"),W=p.string().regex(/^[a-z][a-z0-9_]{0,63}$/),bn=p.record(W,p.union([p.string().max(120),p.number().finite(),p.boolean()])).refine(e=>Object.keys(e).length<=16,"\u6700\u591A 16 \u4E2A\u8BA1\u4EF7\u5C5E\u6027").transform(e=>Object.fromEntries(Object.entries(e).map(([t,n])=>[t,String(n)]))),Qe=p.record(W,p.string().min(1).max(120)).refine(e=>Object.keys(e).length>=1&&Object.keys(e).length<=8,"\u5339\u914D\u6761\u4EF6\u9700\u8981 1\u20138 \u4E2A\u5C5E\u6027"),X=e=>{let[t,n=""]=e.split(".");return BigInt(t)*BigInt("1000000")+BigInt(n.padEnd(6,"0"))},Xe=p.array(p.object({upTo:K.nullable(),cost:U}).strict()).min(1).max(12).refine(e=>e.at(-1)?.upTo===null&&e.slice(0,-1).every((t,n)=>t.upTo!==null&&(n===0||X(t.upTo)>X(e[n-1].upTo))),"\u9636\u68AF\u4E0A\u9650\u5FC5\u987B\u9012\u589E\uFF0C\u6700\u540E\u4E00\u6863\u4E3A\u65E0\u9650"),yn=p.object({key:W,match:Qe,priority:p.number().int().min(-100).max(100).default(0),cost:U.optional(),tiers:Xe.optional()}).strict().refine(e=>e.cost!==void 0||e.tiers!==void 0,"\u7EF4\u5EA6\u9700\u8981\u6307\u5B9A\u5355\u4EF7\u6216\u9636\u68AF"),xn=p.object({key:W,match:Qe,factor:U.default("1"),add:U.default("0")}).strict(),et=p.object({featureKey:W,units:K.default("1"),cost:U,tiers:Xe.optional(),dimensions:p.array(yn).max(12).optional(),multipliers:p.array(xn).max(4).optional()}).strict().superRefine((e,t)=>{let n=e.dimensions??[],r=e.multipliers??[];(new Set(n.map(s=>s.key)).size!==n.length||new Set(r.map(s=>s.key)).size!==r.length)&&t.addIssue({code:"custom",message:"\u7EF4\u5EA6\u548C\u500D\u7387\u7684 ID \u4E0D\u80FD\u91CD\u590D"});for(let s=0;s<n.length;s++)for(let d=s+1;d<n.length;d++){let v=n[s],o=n[d];Object.keys(v.match).length===Object.keys(o.match).length&&v.priority===o.priority&&!Object.keys(v.match).some(j=>o.match[j]!==void 0&&o.match[j]!==v.match[j])&&t.addIssue({code:"custom",message:"\u7EF4\u5EA6\u53EF\u80FD\u540C\u65F6\u5339\u914D\uFF0C\u8BF7\u8C03\u6574\u4F18\u5148\u7EA7"})}let c=[e.cost,...(e.tiers??[]).map(s=>s.cost),...n.flatMap(s=>[...s.cost===void 0?[]:[s.cost],...(s.tiers??[]).map(d=>d.cost)])],i=X(e.units);for(let s of c)for(let d=0;d<1<<r.length;d++){let v=X(s),o=BigInt("1"),j=BigInt("0");for(let _=0;_<r.length;_++)d&1<<_&&(v*=X(r[_].factor),o*=BigInt("1000000"),j+=X(r[_].add));let w=(v+j*o)*BigInt("1000000"),I=o*i;(w%I!==BigInt("0")||w/I>BigInt("999999999999999999"))&&t.addIssue({code:"custom",message:"\u6BCF\u4E2A\u4E1A\u52A1\u5355\u4F4D\u7684\u6700\u7EC8\u5355\u4EF7\u5FC5\u987B\u5728\u8303\u56F4\u5185\u4E14\u80FD\u7CBE\u786E\u8868\u793A\u4E3A\u6700\u591A 6 \u4F4D\u5C0F\u6570"})}}),tt=p.object({dimension:p.string(),cycleStart:p.iso.datetime(),counterKey:p.string(),unitCost:U,units:F,amount:F,tier:p.number().int().nullable(),poolVersionId:p.uuid().nullable()}),Fr=p.object({key:W,name:p.string().trim().min(1).max(80),rates:p.array(et).min(1).max(100).refine(e=>new Set(e.map(t=>t.featureKey)).size===e.length,"\u6BCF\u4E2A\u529F\u80FD\u53EA\u80FD\u914D\u7F6E\u4E00\u6761\u57FA\u7840\u8D39\u7387")}).strict(),nt=p.object({poolVersionId:p.uuid(),amount:K,reset:p.enum(["month","lifetime"]).default("month"),rollover:p.object({cap:K,cycles:p.number().int().min(1).max(12)}).strict().optional()}).strict().refine(e=>!e.rollover||e.reset==="month","\u7ED3\u8F6C\u53EA\u9002\u7528\u4E8E\u6708\u5EA6\u79EF\u5206"),Sn=p.object({id:p.uuid(),resourceKey:p.string(),name:p.string(),source:p.string(),granted:F,available:F,reserved:F,spendable:F,consumed:F,forfeited:F,rolledOver:F.default("0"),startsAt:p.iso.datetime(),expiresAt:p.iso.datetime().nullable(),eligible:p.boolean(),rates:p.array(et)}),de=p.object({customerId:p.uuid(),evaluatedAt:p.iso.datetime(),balances:p.array(Sn),transactions:p.array(p.object({id:p.uuid(),kind:p.string(),featureKey:p.string().nullable(),quantity:F,at:p.iso.datetime(),reason:p.string(),referenceId:p.uuid().nullable(),allocations:p.array(p.object({balanceId:p.uuid(),amount:F,pricing:p.array(tt).optional()}))})),reservations:p.array(p.object({id:p.uuid(),featureKey:p.string(),quantity:F,status:p.enum(["pending","confirmed","released","expired"]),expiresAt:p.iso.datetime()}))}),G=p.object({customerId:p.uuid().optional()}).strict(),we=G.extend({featureKey:W,quantity:K.default("1"),properties:bn.optional()}).strict(),rt=p.object({allowed:p.boolean(),featureKey:W,quantity:K,reason:p.enum(["insufficient_balance","feature_unavailable"]).nullable(),allocations:p.array(p.object({balanceId:p.uuid(),amount:F,units:F,pricing:p.array(tt).optional()}))}),Ae=we.extend({customerId:p.uuid(),idempotencyKey:p.string().min(1).max(120),reason:p.string().trim().max(240).default("")}).strict(),it=Ae.extend({expiresAt:p.iso.datetime()}).strict(),ot=p.object({customerId:p.uuid(),reservationId:p.uuid(),idempotencyKey:p.string().min(1).max(120),action:p.enum(["confirm","release"]),quantity:U.optional()}).strict(),at=p.object({customerId:p.uuid(),transactionId:p.uuid(),quantity:K,idempotencyKey:p.string().min(1).max(120),reason:p.string().trim().min(1).max(240)}).strict(),st=p.object({customerId:p.uuid(),poolVersionId:p.uuid(),amount:K,expiresAt:p.iso.datetime().nullable().default(null),idempotencyKey:p.string().min(1).max(120),reason:p.string().trim().min(1).max(240)}).strict(),ee=p.object({accepted:p.boolean(),operationId:p.uuid().nullable(),reason:p.string().nullable(),account:de}),qr=p.object({projectId:p.uuid(),environmentId:p.uuid(),action:p.enum(["pool_save","pool_publish","pool_archive","grant","refund","revoke"]),id:p.uuid().nullable().default(null),revision:p.number().int().nonnegative().default(0),input:p.unknown()}).strict(),ct=p.object({at:p.iso.datetime(),id:p.uuid()}).strict(),ut=G.extend({cursor:ct.nullable().optional(),limit:p.number().int().min(1).max(100).default(50)}).strict(),pt=p.object({transactions:de.shape.transactions,nextCursor:ct.nullable()});var Ce=h.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/,"ID \u4F7F\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u4E0B\u5212\u7EBF\uFF0C\u5E76\u4EE5\u5B57\u6BCD\u5F00\u5934"),Hr=h.record(h.string().min(1).max(80),h.union([h.string().max(500),h.number().finite(),h.boolean(),h.null()])).refine(e=>Object.keys(e).length<=30,"\u6700\u591A 30 \u4E2A\u5C5E\u6027"),lt=h.object({key:Ce,name:h.string().trim().min(1).max(80),description:h.string().trim().max(240),type:h.enum(["boolean","metered"])}),Br=lt.extend({...M.shape,id:h.string().min(1),archived:h.boolean(),createdAt:h.iso.datetime()}),dt=h.object({amountCents:h.number().int().min(0).max(1e8),currency:h.literal("USD"),interval:h.enum(["free","month","year"])}).refine(e=>e.interval==="free"?e.amountCents===0:e.amountCents>0,"\u514D\u8D39\u5957\u9910\u91D1\u989D\u5FC5\u987B\u4E3A 0\uFF0C\u6708\u4ED8\u91D1\u989D\u5FC5\u987B\u5927\u4E8E 0"),kn=h.object({featureId:h.string().min(1),allowance:h.number().int().min(0).max(1e9).nullable()}),mt=h.object({name:h.string().trim().min(1).max(80),description:h.string().trim().max(240),price:dt,membership:ve.optional(),items:h.array(kn).max(100).refine(e=>new Set(e.map(t=>t.featureId)).size===e.length,"\u540C\u4E00\u529F\u80FD\u4E0D\u80FD\u91CD\u590D\u52A0\u5165\u5957\u9910")}),Zr=h.object({key:Ce,config:mt}),Kr=M.extend({id:h.string().min(1),key:Ce,draft:mt,status:h.enum(["draft","published","archived"]),publishedVersionId:h.string().nullable(),isDefault:h.boolean(),updatedAt:h.iso.datetime()}),vn=lt.pick({key:!0,name:!0,type:!0}).extend({featureId:h.string(),allowance:h.number().int().min(0).max(1e9).nullable()}).refine(e=>e.type==="boolean"?e.allowance===null:e.allowance!==null,"\u5F00\u5173\u578B\u65E0\u6570\u91CF\uFF0C\u8BA1\u91CF\u578B\u5FC5\u987B\u6307\u5B9A\u989D\u5EA6"),ze=M.extend({id:h.string().min(1),planId:h.string().min(1),version:h.number().int().positive(),name:h.string(),description:h.string(),price:dt,membership:ve.optional(),items:h.array(vn),credits:h.array(nt).optional(),publishedAt:h.iso.datetime()}),Pe=h.object({startsAt:h.iso.datetime(),endsAt:h.iso.datetime().nullable()}).refine(e=>e.endsAt===null||Date.parse(e.endsAt)>Date.parse(e.startsAt),"\u5230\u671F\u65F6\u95F4\u5FC5\u987B\u665A\u4E8E\u751F\u6548\u65F6\u95F4"),Wr=M.extend({id:h.string(),customerId:h.string(),planVersionId:h.string(),assignedAt:h.iso.datetime(),source:h.literal("demo"),validity:Pe.nullable().default(null),used:h.record(h.string(),h.number().int().min(0))}),Gr=M.extend({id:h.string(),customerId:h.string(),at:h.iso.datetime(),message:h.string()});import{z as Y}from"zod";var In=Y.object({name:Y.string().trim().min(1,"\u8BF7\u8F93\u5165\u9879\u76EE\u540D\u79F0").max(80),slug:Y.string().trim().max(63).regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"\u9879\u76EE\u6807\u8BC6\u4F7F\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26")}),ft=Y.object({description:Y.string().trim().max(240)}),Qr=Y.object({project:In.extend({id:Y.string().min(1)}),environments:Y.object({sandbox:ft,live:ft})});import{z as k}from"zod";var jn=["plan.name","plan.price","plan.period","plan.price_per_month","offer.headline","offer.name","offer.description","offer.eligibility","offer.validity","offer.terms","offer.discount","offer.price","offer.original_price","offer.months","offer.code","offer.ends_at","offer.expires_at"],ht=k.object({plan:k.uuid().optional(),coupon:k.uuid().optional(),promotionCode:k.uuid().optional(),picker:k.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/).optional()}).strict(),gt=k.object({text:k.string().optional(),label:k.string().optional(),alt:k.string().optional(),html:k.string().max(32768).optional(),price:k.object({current:k.string(),original:k.string().nullable(),period:k.string()}).optional(),code:k.string().optional(),countdownAt:k.iso.datetime().optional(),planId:k.uuid().optional(),planVersionId:k.uuid().optional(),couponId:k.uuid().optional(),offerId:k.uuid().optional(),unavailable:k.boolean().optional(),missing:k.array(k.string()).optional()}).strict(),me=k.object({nodes:k.record(k.string(),k.object({base:gt,picker:k.string().optional(),byPlan:k.record(k.string(),gt).optional()}).strict()),plans:k.record(k.string(),k.object({id:k.uuid(),versionId:k.uuid(),name:k.string(),price:k.string(),period:k.string()}).strict()),pickers:k.record(k.string(),k.object({options:k.array(k.uuid()).max(20),selected:k.uuid().nullable()}).strict()),diagnostics:k.array(k.object({nodeId:k.string(),message:k.string()}).strict())}).strict();function fe(e){return[...e.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(t=>t[1].trim())}function ge(e){let t=fe(e).filter(r=>!jn.includes(r)),n=e.replace(/\{\{\s*[^{}]+?\s*\}\}/g,"");return(n.includes("{{")||n.includes("}}"))&&t.push("\u65E0\u6548\u53D8\u91CF\u8BED\u6CD5"),[...new Set(t)]}function ti(e,t,n,r=!1){let c=fe(e).filter(i=>t[i]===void 0);return c.length&&!r?{value:n,missing:c}:{value:e.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(i,s)=>t[s.trim()]??i),missing:c}}function ni(e,t,n={}){let r=e?.nodes[t];if(!r)return;let c=r.picker?n[r.picker]??e?.pickers[r.picker]?.selected:void 0;return typeof c=="string"?r.byPlan?.[c]??r.base:r.base}import{z as A}from"zod";var bt=A.object({key:A.string().regex(/^[a-z][a-z0-9_]{0,63}$/),name:A.string().trim().min(1).max(80),poolVersionId:A.uuid(),amount:U.refine(e=>/[1-9]/.test(e)),amountCents:A.number().int().min(50).max(99999999),currency:A.literal("USD").default("USD"),expiresDays:A.number().int().min(1).max(3660).nullable().default(null),stripePriceId:A.string().regex(/^price_[A-Za-z0-9]+$/)}).strict(),yt=bt.extend({id:A.uuid(),packId:A.uuid(),version:A.number().int().positive()}),xt=G.extend({packVersionId:A.uuid(),requestId:A.uuid()}).strict(),St=A.object({id:A.uuid(),packVersionId:A.uuid(),name:A.string(),amount:U,amountCents:A.number().int(),currency:A.literal("USD"),status:A.enum(["created","pending","paid","expired","refunded","disputed"]),refundedCents:A.number().int().nonnegative(),shortfall:F,at:A.iso.datetime(),paidAt:A.iso.datetime().nullable()}),ai=A.object({projectId:A.uuid(),environmentId:A.uuid(),action:A.enum(["save","publish","archive"]),id:A.uuid().nullable().default(null),revision:A.number().int().nonnegative(),input:A.unknown()}).strict().transform((e,t)=>{let n=(e.action==="save"?bt:A.object({}).strict()).safeParse(e.input);return n.success?{...e,input:n.data}:(t.addIssue({code:"custom",message:n.error.issues[0]?.message??"\u8BF7\u68C0\u67E5\u79EF\u5206\u5305"}),A.NEVER)});import{z as l}from"zod";import{z as g}from"zod";var kt=g.union([g.string().max(500),g.number().finite(),g.boolean()]),vt=e=>{let t=g.record(g.string().min(1).max(80),e);return g.custom(n=>n!==null&&typeof n=="object"&&!Array.isArray(n)&&!Object.hasOwn(n,"__proto__"),"\u5C5E\u6027\u952E\u4E0D\u53EF\u7528").pipe(t).refine(n=>Object.keys(n).length<=30,"\u6700\u591A 30 \u4E2A\u5C5E\u6027").refine(n=>new TextEncoder().encode(JSON.stringify(n)).length<=16384,"\u5C5E\u6027\u5185\u5BB9\u8FC7\u5927")},It=vt(kt),jt=vt(kt.nullable()),Oe=g.array(g.string().trim().min(1).max(40).refine(e=>!e.includes(","),"\u6807\u7B7E\u4E0D\u80FD\u5305\u542B\u9017\u53F7")).max(20).refine(e=>new Set(e).size===e.length,"\u6807\u7B7E\u4E0D\u80FD\u91CD\u590D"),_e=g.string().trim().max(80),Te=g.union([g.email().max(254),g.literal("")]),wt=g.object({externalUserId:g.string().trim().min(1).max(255),name:_e.default(""),email:Te.default(""),tags:Oe.default([]),metadata:jt.default({})}).strict(),oe=g.object({id:g.uuid(),externalUserId:g.string().min(1).max(255),name:_e,email:Te,metadata:It,tags:Oe,revision:g.number().int().nonnegative(),createdAt:g.iso.datetime(),updatedAt:g.iso.datetime()}),At=g.object({customer:oe,changed:g.boolean(),replayed:g.boolean()}),wn=g.discriminatedUnion("type",[g.object({type:g.literal("id"),value:g.uuid()}).strict(),g.object({type:g.literal("externalUserId"),value:g.string().trim().min(1).max(255)}).strict()]),An=g.object({name:_e.optional(),email:Te.optional(),tags:Oe.optional(),metadata:jt.optional()}).strict().refine(e=>Object.keys(e).length>0,"\u8BF7\u63D0\u4F9B\u9700\u8981\u4FEE\u6539\u7684\u5B57\u6BB5"),$e=g.object({lookup:wn}).strict(),Ct=$e.extend({revision:g.number().int().nonnegative(),requestId:g.uuid(),patch:An}).strict(),zt=g.object({search:g.string().trim().max(200).default(""),tag:g.string().trim().max(40).default(""),planId:g.union([g.uuid(),g.literal("")]).default(""),versionId:g.union([g.uuid(),g.literal("")]).default(""),holdingStatus:g.enum(["","active","scheduled","expired","unavailable","none"]).default(""),subscriptionStatus:g.enum(["","active","trialing","past_due","unpaid","incomplete","canceled","incomplete_expired","paused"]).default(""),createdFrom:g.union([g.iso.datetime(),g.literal("")]).default(""),createdUntil:g.union([g.iso.datetime(),g.literal("")]).default(""),offset:g.coerce.number().int().min(0).max(1e5).default(0),limit:g.coerce.number().int().min(1).max(100).default(50)}).strict(),Pt=g.object({customers:oe.array(),hasMore:g.boolean(),total:g.number().int().nonnegative().nullable(),evaluatedAt:g.iso.datetime()});function ui(e,t){let n={...e};for(let[r,c]of Object.entries(t))c===null?delete n[r]:Object.defineProperty(n,r,{value:c,enumerable:!0,writable:!0,configurable:!0});return It.parse(n)}import{z as S}from"zod";import{z as Cn}from"zod";var _t=/^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$/,E=Cn.string().max(16).regex(_t,"\u8BED\u8A00\u4EE3\u7801\u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u4F8B\u5982 zh-CN\u3001en");function J(e){if(typeof e!="string")return null;try{let t=Intl.getCanonicalLocales(e.trim().replaceAll("_","-"))[0];if(!t)return null;let{language:n,script:r,region:c}=new Intl.Locale(t),i=[n,r,c].filter(Boolean).join("-");return _t.test(i)?i:null}catch{return null}}var zn=new Set(["TW","HK","MO"]);function Ot(e){let[t,n,r]=e.split("-");if(t!=="zh")return`${t}-${new Intl.Locale(e).maximize().script??""}`;let c=n?.length===4?n:void 0,i=n?.length===4?r:n;return c?`zh-${c}`:i&&zn.has(i)?"zh-Hant":"zh-Hans"}function he(e,t,n){let r=t.flatMap(c=>{let i=J(c);return i?[{code:E.safeParse(c).success?c:i,normalized:i}]:[]});for(let c of e){let i=J(c);if(!i)continue;let s=r.find(o=>o.normalized===i);if(s)return s.code;let d=Ot(i),v=r.filter(o=>Ot(o.normalized)===d);if(v.length>0)return(v.find(o=>!o.normalized.includes("-")||o.normalized===d)??v[0]).code}return n}var Pn=[{code:"zh-CN",label:"\u7B80\u4F53\u4E2D\u6587"},{code:"zh-TW",label:"\u7E41\u9AD4\u4E2D\u6587\uFF08\u53F0\u7063\uFF09"},{code:"zh-HK",label:"\u7E41\u9AD4\u4E2D\u6587\uFF08\u9999\u6E2F\uFF09"},{code:"en",label:"English"},{code:"ja",label:"\u65E5\u672C\u8A9E"},{code:"ko",label:"\uD55C\uAD6D\uC5B4"},{code:"es",label:"Espa\xF1ol"},{code:"fr",label:"Fran\xE7ais"},{code:"de",label:"Deutsch"},{code:"pt-BR",label:"Portugu\xEAs (Brasil)"},{code:"it",label:"Italiano"},{code:"ru",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},{code:"vi",label:"Ti\u1EBFng Vi\u1EC7t"},{code:"th",label:"\u0E44\u0E17\u0E22"},{code:"id",label:"Bahasa Indonesia"},{code:"ar",label:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629"}];function di(e){return Pn.find(t=>t.code===e)?.label??e}var De={"zh-Hans":{once:"\u9996\u671F\u51CF {discount}",repeating:"\u524D {months} \u4E2A\u6708\u6BCF\u6708\u51CF {discount}",forever:"\u6BCF\u671F\u51CF {discount}"},"zh-Hant":{once:"\u9996\u671F\u6E1B {discount}",repeating:"\u524D {months} \u500B\u6708\u6BCF\u6708\u6E1B {discount}",forever:"\u6BCF\u671F\u6E1B {discount}"},en:{once:"{discount} off your first payment",repeating:"{discount} off each month for the first {months} months",repeatingOne:"{discount} off the first month",forever:"{discount} off every payment"},ja:{once:"\u521D\u56DE\u306E\u304A\u652F\u6255\u3044\u304C {discount} \u5272\u5F15",repeating:"\u6700\u521D\u306E {months} \u304B\u6708\u9593\u3001\u6BCE\u6708 {discount} \u5272\u5F15",forever:"\u6BCE\u56DE\u306E\u304A\u652F\u6255\u3044\u304C {discount} \u5272\u5F15"},ko:{once:"\uCCAB \uACB0\uC81C {discount} \uD560\uC778",repeating:"\uCCAB {months}\uAC1C\uC6D4 \uB3D9\uC548 \uB9E4\uC6D4 {discount} \uD560\uC778",forever:"\uB9E4 \uACB0\uC81C {discount} \uD560\uC778"},es:{once:"{discount} de descuento en el primer pago",repeating:"{discount} de descuento cada mes durante los primeros {months} meses",forever:"{discount} de descuento en cada pago",repeatingOne:"{discount} de descuento durante el primer mes"},fr:{once:"{discount} de r\xE9duction sur le premier paiement",repeating:"{discount} de r\xE9duction par mois pendant les {months} premiers mois",forever:"{discount} de r\xE9duction sur chaque paiement",repeatingOne:"{discount} de r\xE9duction pendant le premier mois"},de:{once:"{discount} Rabatt auf die erste Zahlung",repeating:"{discount} Rabatt pro Monat f\xFCr die ersten {months} Monate",forever:"{discount} Rabatt auf jede Zahlung",repeatingOne:"{discount} Rabatt im ersten Monat"},pt:{once:"{discount} de desconto no primeiro pagamento",repeating:"{discount} de desconto por m\xEAs nos primeiros {months} meses",forever:"{discount} de desconto em cada pagamento",repeatingOne:"{discount} de desconto no primeiro m\xEAs"},it:{once:"{discount} di sconto sul primo pagamento",repeating:"{discount} di sconto al mese per i primi {months} mesi",forever:"{discount} di sconto su ogni pagamento",repeatingOne:"{discount} di sconto per il primo mese"},ru:{once:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043D\u0430 \u043F\u0435\u0440\u0432\u044B\u0439 \u043F\u043B\u0430\u0442\u0451\u0436",repeating:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043A\u0430\u0436\u0434\u044B\u0439 \u043C\u0435\u0441\u044F\u0446 \u0432 \u0442\u0435\u0447\u0435\u043D\u0438\u0435 \u043F\u0435\u0440\u0432\u044B\u0445 {months} \u043C\u0435\u0441.",repeatingOne:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u0432 \u043F\u0435\u0440\u0432\u044B\u0439 \u043C\u0435\u0441\u044F\u0446",forever:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043D\u0430 \u043A\u0430\u0436\u0434\u044B\u0439 \u043F\u043B\u0430\u0442\u0451\u0436"},vi:{once:"Gi\u1EA3m {discount} cho l\u1EA7n thanh to\xE1n \u0111\u1EA7u ti\xEAn",repeating:"Gi\u1EA3m {discount} m\u1ED7i th\xE1ng trong {months} th\xE1ng \u0111\u1EA7u",forever:"Gi\u1EA3m {discount} cho m\u1ED7i l\u1EA7n thanh to\xE1n"},th:{once:"\u0E25\u0E14 {discount} \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E0A\u0E33\u0E23\u0E30\u0E40\u0E07\u0E34\u0E19\u0E04\u0E23\u0E31\u0E49\u0E07\u0E41\u0E23\u0E01",repeating:"\u0E25\u0E14 {discount} \u0E15\u0E48\u0E2D\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E43\u0E19\u0E0A\u0E48\u0E27\u0E07 {months} \u0E40\u0E14\u0E37\u0E2D\u0E19\u0E41\u0E23\u0E01",forever:"\u0E25\u0E14 {discount} \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E0A\u0E33\u0E23\u0E30\u0E40\u0E07\u0E34\u0E19\u0E17\u0E38\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07"},id:{once:"Diskon {discount} untuk pembayaran pertama",repeating:"Diskon {discount} setiap bulan selama {months} bulan pertama",forever:"Diskon {discount} untuk setiap pembayaran"},ar:{once:"\u062E\u0635\u0645 {discount} \u0639\u0644\u0649 \u0627\u0644\u062F\u0641\u0639\u0629 \u0627\u0644\u0623\u0648\u0644\u0649",repeating:"\u062E\u0635\u0645 {discount} \u0634\u0647\u0631\u064A\u064B\u0627 \u0644\u0645\u062F\u0629 {period}",forever:"\u062E\u0635\u0645 {discount} \u0639\u0644\u0649 \u0643\u0644 \u062F\u0641\u0639\u0629"}},gi=["zh-CN","zh-TW","zh-HK","en","ja","ko","es","fr","de","pt-BR","it","ru","vi","th","id","ar"];function Ne(e){let t=J(e)??"en",n=t.split("-"),r=n[0]==="zh"?n.includes("Hans")?"zh-Hans":n.includes("Hant")||n.some(c=>["TW","HK","MO"].includes(c))?"zh-Hant":"zh-Hans":n[0];return De[r]?{locale:t,copy:De[r]}:{locale:"en",copy:De.en}}function On(e,t,n="zh-CN"){return new Intl.NumberFormat(Ne(n).locale,{style:"currency",currency:t,currencyDisplay:"narrowSymbol",minimumFractionDigits:e%100===0?0:2,maximumFractionDigits:2}).format(e/100)}function _n(e,t="zh-CN"){let n=Ne(t).locale;return e.type==="percent"?new Intl.NumberFormat(n,{style:"percent",maximumFractionDigits:0}).format(e.percentOff/100):On(e.amountOffCents,e.currency,n)}var Tt={zh:"\u524D {months} \u4E2A\u6708\u5185\u5F00\u51FA\u7684\u8D26\u5355\u51CF {discount}","zh-Hant":"\u524D {months} \u500B\u6708\u5167\u958B\u51FA\u7684\u5E33\u55AE\u6E1B {discount}",en:"{discount} off invoices issued within the first {months} months",ja:"\u6700\u521D\u306E {months} \u304B\u6708\u4EE5\u5185\u306E\u8ACB\u6C42\u304C {discount} \u5272\u5F15",ko:"\uCCAB {months}\uAC1C\uC6D4 \uB0B4 \uCCAD\uAD6C\uC11C {discount} \uD560\uC778",es:"{discount} de descuento en facturas emitidas durante los primeros {months} meses",fr:"{discount} de r\xE9duction sur les factures \xE9mises pendant les {months} premiers mois",de:"{discount} Rabatt auf Rechnungen innerhalb der ersten {months} Monate",pt:"{discount} de desconto nas faturas emitidas nos primeiros {months} meses",it:"{discount} di sconto sulle fatture emesse nei primi {months} mesi",ru:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043D\u0430 \u0441\u0447\u0435\u0442\u0430 \u0432 \u0442\u0435\u0447\u0435\u043D\u0438\u0435 \u043F\u0435\u0440\u0432\u044B\u0445 {months} \u043C\u0435\u0441.",vi:"Gi\u1EA3m {discount} cho h\xF3a \u0111\u01A1n trong {months} th\xE1ng \u0111\u1EA7u",th:"\u0E25\u0E14 {discount} \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E43\u0E1A\u0E41\u0E08\u0E49\u0E07\u0E2B\u0E19\u0E35\u0E49\u0E43\u0E19\u0E0A\u0E48\u0E27\u0E07 {months} \u0E40\u0E14\u0E37\u0E2D\u0E19\u0E41\u0E23\u0E01",id:"Diskon {discount} untuk tagihan dalam {months} bulan pertama",ar:"\u062E\u0635\u0645 {discount} \u0639\u0644\u0649 \u0627\u0644\u0641\u0648\u0627\u062A\u064A\u0631 \u0627\u0644\u0635\u0627\u062F\u0631\u0629 \u062E\u0644\u0627\u0644 \u0623\u0648\u0644 {period}"};function $t(e,t="zh-CN",n="month"){let r=Ne(t),c=_n(e.discount,r.locale),i=e.duration.type==="repeating"?new Intl.NumberFormat(r.locale).format(e.duration.months):"",s=r.locale.split("-")[0],d=s==="zh"&&/(?:Hant|TW|HK|MO)/.test(r.locale)?"zh-Hant":s,v=e.duration.type==="repeating"&&n!=="month"?Tt[d]??Tt.en:e.duration.type==="repeating"&&e.duration.months===1?r.copy.repeatingOne??r.copy.repeating:r.copy[e.duration.type],o=e.duration.type==="repeating"?new Intl.NumberFormat(r.locale,{style:"unit",unit:"month",unitDisplay:"long"}).format(e.duration.months):"";return v.replace("{discount}",c).replace("{months}",i).replace("{period}",o)}var xi=S.enum(["draft","active","paused","archived"]),Dt=S.discriminatedUnion("type",[S.object({type:S.literal("percent"),percentOff:S.number().int().min(1).max(100)}).strict(),S.object({type:S.literal("amount"),amountOffCents:S.number().int().min(1).max(1e8),currency:S.literal("USD")}).strict()]),Nt=S.discriminatedUnion("type",[S.object({type:S.literal("once")}).strict(),S.object({type:S.literal("repeating"),months:S.number().int().min(1).max(36)}).strict(),S.object({type:S.literal("forever")}).strict()]),Rt=S.discriminatedUnion("type",[S.object({type:S.literal("all")}).strict(),S.object({type:S.literal("plans"),planIds:S.array(S.uuid()).min(1).max(50).refine(e=>new Set(e).size===e.length,"\u5957\u9910\u4E0D\u80FD\u91CD\u590D")}).strict()]),Tn=S.string().trim().min(1).max(40).refine(e=>!e.includes(","),"\u6807\u7B7E\u4E0D\u80FD\u5305\u542B\u9017\u53F7"),$n=S.object({firstPurchaseOnly:S.boolean(),requiredTags:S.array(Tn).max(20).refine(e=>new Set(e).size===e.length,"\u6807\u7B7E\u4E0D\u80FD\u91CD\u590D")}).strict(),Si=S.object({name:S.string().trim().min(1).max(80),description:S.string().max(500),discount:Dt,duration:Nt,appliesTo:Rt,eligibility:$n,startsAt:S.iso.datetime().nullable(),endsAt:S.iso.datetime().nullable(),totalLimit:S.number().int().min(1).max(1e6).nullable(),perCustomerLimit:S.number().int().min(1).max(10),grantWindowHours:S.number().int().min(1).max(2160)}).strict().refine(e=>!e.startsAt||!e.endsAt||Date.parse(e.endsAt)>Date.parse(e.startsAt),{message:"\u7ED3\u675F\u65F6\u95F4\u5FC5\u987B\u665A\u4E8E\u5F00\u59CB\u65F6\u95F4",path:["endsAt"]}),ki=S.object({code:S.string().trim().transform(e=>e.toUpperCase()).pipe(S.string().regex(/^[A-Z0-9][A-Z0-9_-]{2,31}$/,"\u4F18\u60E0\u7801\u53EA\u80FD\u7528 3\u201332 \u4F4D\u5B57\u6BCD\u3001\u6570\u5B57\u3001- \u548C _\uFF0C\u4EE5\u5B57\u6BCD\u6216\u6570\u5B57\u5F00\u5934")),maxRedemptions:S.number().int().min(1).max(1e6).nullable(),expiresAt:S.iso.datetime().nullable(),firstPurchaseOnly:S.boolean(),minimumAmountCents:S.number().int().min(1).max(1e8).nullable()}).strict();function vi(){return{name:"\u65B0\u4F18\u60E0\u5238",description:"",discount:{type:"percent",percentOff:20},duration:{type:"once"},appliesTo:{type:"all"},eligibility:{firstPurchaseOnly:!1,requiredTags:[]},startsAt:null,endsAt:null,totalLimit:null,perCustomerLimit:1,grantWindowHours:72}}var Re=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function Ii(e,t,n){if(e==="draft")return[];if(e==="archived")return["\u5DF2\u5F52\u6863\u7684\u4F18\u60E0\u5238\u4E0D\u80FD\u4FEE\u6539"];let r=[];return Re(t.discount,n.discount)||r.push("\u751F\u6548\u540E\u4E0D\u80FD\u4FEE\u6539\u6298\u6263"),Re(t.duration,n.duration)||r.push("\u751F\u6548\u540E\u4E0D\u80FD\u4FEE\u6539\u6301\u7EED\u65B9\u5F0F"),Re(t.appliesTo,n.appliesTo)||r.push("\u751F\u6548\u540E\u4E0D\u80FD\u4FEE\u6539\u9002\u7528\u5957\u9910"),t.startsAt!==n.startsAt&&r.push("\u751F\u6548\u540E\u4E0D\u80FD\u4FEE\u6539\u5F00\u59CB\u65F6\u95F4"),t.endsAt!==n.endsAt&&(n.endsAt===null||t.endsAt!==null&&Date.parse(n.endsAt)>Date.parse(t.endsAt))&&r.push("\u751F\u6548\u540E\u7ED3\u675F\u65F6\u95F4\u53EA\u80FD\u63D0\u524D"),t.totalLimit!==n.totalLimit&&(n.totalLimit===null||t.totalLimit!==null&&n.totalLimit>t.totalLimit)&&r.push("\u751F\u6548\u540E\u603B\u6B21\u6570\u53EA\u80FD\u8C03\u4F4E"),n.perCustomerLimit>t.perCustomerLimit&&r.push("\u751F\u6548\u540E\u6BCF\u4EBA\u6B21\u6570\u53EA\u80FD\u8C03\u4F4E"),r}function ji(e,t){return t==="activate"&&e==="draft"||t==="delete"&&e==="draft"||t==="pause"&&e==="active"||t==="resume"&&e==="paused"||t==="archive"&&(e==="active"||e==="paused")}var Dn=e=>`$${(e/100).toFixed(e%100===0?0:2)}`;function wi(e,t="zh-CN"){return $t(e,t)}function Ai(e,t){if(t.interval==="free"||t.amountCents<=0)return null;let n=e.discount.type==="percent"?t.amountCents-Math.round(t.amountCents*e.discount.percentOff/100):Math.max(0,t.amountCents-e.discount.amountOffCents),r=e.duration.type==="once"?1:e.duration.type==="repeating"?e.duration.months:null;return{originalCents:t.amountCents,firstCents:n,discountedMonths:r,discountedPeriods:r===null?null:Math.ceil(r/(t.interval==="year"?12:1)),thenCents:r===null?n:t.amountCents}}function Ci(e){return Dn(e)}function zi(e,t){return e.startsAt&&Date.parse(e.startsAt)>t?"scheduled":e.endsAt&&Date.parse(e.endsAt)<=t?"ended":"open"}var Fe=S.object({id:S.uuid(),couponId:S.uuid(),status:S.enum(["issued","redeemed","revoked","expired"]),issuedAt:S.iso.datetime(),expiresAt:S.iso.datetime(),coupon:S.object({name:S.string(),discount:Dt,duration:Nt,appliesTo:Rt})}),Ft=S.enum(["inactive","outside_window","not_targeted","not_first_purchase","limit_reached","sold_out"]);import{z as C}from"zod";import{z as a}from"zod";function qe(e){let t=ge(e).map(n=>`\u672A\u77E5\u53D8\u91CF\uFF1A${n}`);for(let n=0;n<e.length;n++){if(e[n]!=="<"||!/[A-Za-z!/?{]/.test(e[n+1]??""))continue;let r=n;if(e.startsWith("<!--",n)){let c=e.indexOf("-->",n+4);n=c<0?e.length:c+2}else{let c="";for(n++;n<e.length;n++){let i=e[n];if(c)i===c&&(c="");else if(i==='"'||i==="'")c=i;else if(i===">")break}}/\{\{|\}\}/.test(e.slice(r,n+1))&&t.push("\u53D8\u91CF\u53EA\u80FD\u653E\u5728 HTML \u6587\u5B57\u4E2D\uFF0C\u4E0D\u80FD\u653E\u5165\u6807\u7B7E\u3001\u5C5E\u6027\u6216\u6CE8\u91CA")}return[...new Set(t)]}function qt(e){return e.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}function _i(e,t,n,r=!1){let c=qe(e);if(c.length)throw new Error(c[0]);let i=[...new Set(fe(e).filter(s=>t[s]===void 0))];return i.length&&!r?{value:qt(n),missing:i}:{value:e.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(s,d)=>t[d.trim()]===void 0?s:qt(t[d.trim()])),missing:i}}import{z as y}from"zod";var D=y.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Nn=y.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Et=y.object({version:y.literal(1),entry:D,questions:y.array(y.object({id:D,source:D,required:y.boolean()}).strict()).max(40),nodes:y.array(y.discriminatedUnion("type",[y.object({id:D,name:y.string().trim().min(1).max(60),type:y.literal("branch"),question:D,cases:y.array(y.object({value:y.union([D,y.boolean()]),target:D}).strict()).min(1).max(50),fallback:D,editorPosition:y.object({x:y.number().finite().min(-1e5).max(1e5),y:y.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict(),y.object({id:D,name:y.string().trim().min(1).max(60),type:y.literal("auth"),success:D,cancel:D,failure:D,editorPosition:y.object({x:y.number().finite().min(-1e5).max(1e5),y:y.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict(),y.object({id:D,name:y.string().trim().min(1).max(60),type:y.literal("purchase"),planVersionId:y.uuid(),success:D,cancel:D,failure:D,editorPosition:y.object({x:y.number().finite().min(-1e5).max(1e5),y:y.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict(),y.object({id:D,name:y.string().trim().min(1).max(60),type:y.literal("experiment"),experimentId:y.uuid(),revision:y.number().int().min(1),bucketVersion:y.number().int().min(1).max(1e9).optional(),variants:y.array(y.object({id:D,name:y.string().trim().min(1).max(60),weight:y.number().int().min(1).max(1e4),target:D}).strict()).min(2).max(5),editorPosition:y.object({x:y.number().finite().min(-1e5).max(1e5),y:y.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict(),y.object({id:D,name:y.string().trim().min(1).max(60),type:y.literal("complete"),editorPosition:y.object({x:y.number().finite().min(-1e5).max(1e5),y:y.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict()])).max(40),routes:y.array(y.object({action:Nn,target:D}).strict()).max(40)}).strict();function Di(e,t){let n={status:"running",nodeId:e.entry,pageId:null,answers:Object.create(null),history:[]},r=()=>({...n,answers:{...n.answers},history:[...n.history]}),c=i=>{let s=new Set;for(;!t.includes(i);){if(s.has(i)){n.status="failed",n.error="\u6761\u4EF6\u5206\u652F\u5F62\u6210\u5FAA\u73AF",n.pageId=null;return}s.add(i);let d=e.nodes.find(o=>o.id===i);if(n.nodeId=i,!d){n.status="failed",n.error="\u6D41\u7A0B\u76EE\u6807\u4E0D\u5B58\u5728",n.pageId=null;return}if(["auth","purchase","experiment"].includes(d.type)){n.status="waiting",n.nodeId=d.id,n.pageId=null;return}if(d.type==="complete"){n.status="completed",n.pageId=null;return}if(d.type!=="branch")return;let v=Object.hasOwn(n.answers,d.question)?n.answers[d.question]:void 0;i=d.cases.find(o=>o.value===v)?.target??d.fallback}n.status="running",n.error=void 0,n.nodeId=n.pageId=i};return{start(i=e.entry){return n={status:"running",nodeId:i,pageId:null,answers:Object.create(null),history:[]},c(i),r()},answer(i,s){return n.status==="running"&&e.questions.some(d=>d.id===i)&&(n.answers[i]=s),r()},move(i){return n.status!=="running"||(n.pageId&&i!==n.pageId&&n.history.push(n.pageId),c(i)),r()},back(){if(n.status!=="running")return r();let i=n.history.pop();return i&&c(i),r()},restore(i){if(i.status==="waiting"&&e.nodes.some(s=>s.id===i.nodeId&&["auth","purchase","experiment"].includes(s.type)))return n={...i,pageId:null,answers:{...i.answers},history:i.history.filter(s=>t.includes(s)).slice(-100)},r();if(i.status!=="running"||!i.pageId||!t.includes(i.pageId)||i.nodeId!==i.pageId)return n={status:"failed",nodeId:e.entry,pageId:null,answers:Object.create(null),history:[],error:"\u6062\u590D\u7684\u6D41\u7A0B\u72B6\u6001\u65E0\u6548"},r();n={status:"running",nodeId:i.pageId,pageId:i.pageId,answers:Object.create(null),history:i.history.filter(s=>t.includes(s)).slice(-100)};for(let s of e.questions)if(Object.hasOwn(i.answers,s.id)){let d=i.answers[s.id];(typeof d=="string"||typeof d=="boolean")&&(n.answers[s.id]=d)}return r()},resolve(i){if(n.status!=="waiting")return r();let s=e.nodes.find(v=>v.id===n.nodeId);return(s?.type==="experiment"?s.variants.map(v=>v.target):s?.type==="auth"||s?.type==="purchase"?[s.success,s.cancel,s.failure]:[]).includes(i)&&c(i),r()},snapshot:r}}function Lt(e){let t=new Map,n=(r,c,i=!0)=>{if(i=i&&!r.hidden,t.set(r.id,{node:r,page:c,visible:i}),r.type==="stack")for(let s of r.children)n(s,c,i)};for(let r of e.pages)n(r.root,r.id);return t}function Le(e){let t=[],n=[],r=e.funnel;if(!r)return{errors:t,warnings:n};e.surface!=="onboarding"&&t.push("Funnel \u53EA\u7528\u4E8E\u5F15\u5BFC\u6D41\u7A0B");let c=new Set(e.pages.map(f=>f.id));for(let f of r.nodes)(c.has(f.id)||["next","back"].includes(f.id))&&t.push(`\u6D41\u7A0B\u8282\u70B9\u6807\u8BC6\u91CD\u590D\u6216\u4FDD\u7559\uFF1A${f.id}`),c.add(f.id);let i=f=>{c.has(f)||t.push(`\u6D41\u7A0B\u76EE\u6807\u4E0D\u5B58\u5728\uFF1A${f}`)};i(r.entry);let s=Lt(e),d=new Set,v=new Set;for(let f of r.questions){(d.has(f.id)||v.has(f.source))&&t.push(`\u95EE\u9898\u6807\u8BC6\u6216\u7EC4\u4EF6\u91CD\u590D\uFF1A${f.id}`),d.add(f.id),v.add(f.source);let T=s.get(f.source);(!T?.visible||T.node.type!=="stack"||!T.node.interaction||!["select","toggle"].includes(T.node.interaction.type))&&t.push(`\u95EE\u9898 ${f.id} \u5FC5\u987B\u7ED1\u5B9A\u53EF\u89C1\u7684\u5355\u9009\u6216\u5F00\u5173\u7EC4\u4EF6`)}let o=(f,T)=>{let B=r.questions.find(R=>R.id===f),b=B&&s.get(B.source)?.node;return b?.type==="stack"&&(b.interaction?.type==="toggle"?typeof T=="boolean":b.interaction?.type==="select"&&typeof T=="string"&&b.children.some(R=>R.id===T&&!R.hidden))};for(let f of r.nodes)if(f.type==="branch"){d.has(f.question)||t.push(`\u5206\u652F ${f.name} \u5F15\u7528\u7684\u95EE\u9898\u4E0D\u5B58\u5728`);let T=new Set;for(let B of f.cases){o(f.question,B.value)||t.push(`\u5206\u652F ${f.name} \u7684\u7B54\u6848\u503C\u65E0\u6548`);let b=JSON.stringify(B.value);T.has(b)&&t.push(`\u5206\u652F ${f.name} \u7684\u6761\u4EF6\u91CD\u590D`),T.add(b),i(B.target)}i(f.fallback)}for(let f of r.nodes){for(let T of Ee(f))i(T.target);f.type==="experiment"&&new Set(f.variants.map(T=>T.id)).size!==f.variants.length&&t.push(`\u5B9E\u9A8C ${f.name} \u7684\u53D8\u4F53\u6807\u8BC6\u91CD\u590D`)}let j=new Set;for(let f of r.routes)j.has(f.action)&&t.push(`\u6D41\u7A0B\u52A8\u4F5C\u8DEF\u7531\u91CD\u590D\uFF1A${f.action}`),j.add(f.action),e.actions.some(T=>T.id===f.action&&T.type==="navigate")||t.push(`\u6D41\u7A0B\u8DEF\u7531\u5FC5\u987B\u5F15\u7528\u5BFC\u822A\u52A8\u4F5C\uFF1A${f.action}`),f.target!=="back"&&i(f.target);let w=new Map(r.nodes.filter(f=>f.type==="branch"||f.type==="experiment").map(f=>[f.id,f])),I=new Set,_=new Set,q=f=>{if(I.has(f))return!0;if(_.has(f))return!1;let T=w.get(f);if(!T)return!1;I.add(f);let B=Ee(T).some(b=>q(b.target));return I.delete(f),_.add(f),B};return[...w.keys()].some(q)&&t.push("\u6761\u4EF6\u8282\u70B9\u4E4B\u95F4\u4E0D\u80FD\u5F62\u6210\u81EA\u52A8\u8DF3\u8F6C\u5FAA\u73AF"),r.nodes.some(f=>f.type==="complete")||n.push("\u6D41\u7A0B\u5C1A\u672A\u8BBE\u7F6E\u5B8C\u6210\u8282\u70B9\uFF1B\u5173\u95ED\u9875\u9762\u4E0D\u4EE3\u8868\u5B8C\u6210\u6D41\u7A0B"),{errors:[...new Set(t)],warnings:n}}function Rn(e,t){let n={};if(!t||typeof t!="object"||Array.isArray(t))return n;let r=t,c=Lt(e);for(let i of e.funnel?.questions??[]){let s=c.get(i.source)?.node,d=Object.hasOwn(r,i.id)?r[i.id]:void 0;s?.type==="stack"&&(s.interaction?.type==="toggle"&&typeof d=="boolean"&&(n[i.id]=d),s.interaction?.type==="select"&&typeof d=="string"&&s.children.some(v=>!v.hidden&&v.id===d)&&(n[i.id]=d))}return n}function Ni(e,t){if(!e.funnel||!t||!["running","waiting","completed","failed"].includes(t.status))return null;let n=new Set(e.pages.map(c=>c.id)),r=e.funnel.nodes.find(c=>c.id===t.nodeId);return t.status==="running"&&(!n.has(t.nodeId)||t.pageId!==t.nodeId)||t.status==="completed"&&(r?.type!=="complete"||t.pageId!==null)||t.status==="waiting"&&(!r||!["auth","purchase","experiment"].includes(r.type)||t.pageId!==null)||t.status==="failed"&&!r&&!n.has(t.nodeId)?null:{status:t.status,nodeId:t.nodeId,pageId:t.status==="running"?t.pageId:null,answers:Rn(e,t.answers),history:Array.isArray(t.history)?t.history.filter(c=>n.has(c)).slice(-100):[],...typeof t.error=="string"?{error:t.error.slice(0,200)}:{}}}function Vt(e){let t=[],n=[];if(!e.funnel)return{errors:t,warnings:n};let r=e.funnel,c=new Set,i=[r.entry];for(;i.length;){let s=i.shift();if(c.has(s))continue;c.add(s);let d=r.nodes.find(I=>I.id===s);if(d){i.push(...Ee(d).map(I=>I.target));continue}let v=e.pages.findIndex(I=>I.id===s),o=e.pages[v];if(!o)continue;let j=new Set,w=I=>{if(!I.hidden){if(I.type==="button"&&j.add(I.action),I.type==="custom_html")for(let _ of Object.values(I.html))for(let q of _.matchAll(/data-grow-action\s*=\s*["']([a-zA-Z][a-zA-Z0-9_.-]*)["']/g))j.add(q[1]);I.type==="stack"&&I.children.forEach(w)}};w(o.root);for(let I of e.actions.filter(_=>j.has(_.id))){if(I.type!=="navigate")continue;let q=r.routes.find(f=>f.action===I.id)?.target??(I.target==="next"?e.pages[v+1]?.id:I.target);q&&q!=="back"&&i.push(q),q||t.push(`\u9875\u9762 ${o.name} \u7684\u4E0B\u4E00\u9875\u4E0D\u5B58\u5728\uFF0C\u8BF7\u8FDE\u63A5\u5230\u9875\u9762\u6216\u5B8C\u6210\u8282\u70B9`)}}r.nodes.some(s=>s.type==="complete"&&c.has(s.id))||t.push("Funnel \u81F3\u5C11\u9700\u8981\u4E00\u6761\u53EF\u5230\u8FBE\u5B8C\u6210\u8282\u70B9\u7684\u8DEF\u5F84");for(let s of[...e.pages,...r.nodes])c.has(s.id)||n.push(`\u6D41\u7A0B\u8282\u70B9 ${s.name} \u4ECE\u5165\u53E3\u4E0D\u53EF\u5230\u8FBE`);return{errors:t,warnings:n}}function Ee(e){return e.type==="branch"?[...e.cases.map((t,n)=>({handle:`case-${n}`,label:String(t.value),target:t.target})),{handle:"fallback",label:"\u5176\u4ED6\u60C5\u51B5",target:e.fallback}]:e.type==="experiment"?e.variants.map(t=>({handle:t.id,label:`${t.name} \xB7 ${t.weight}`,target:t.target})):e.type==="auth"||e.type==="purchase"?["success","cancel","failure"].map((t,n)=>({handle:t,label:["\u6210\u529F","\u53D6\u6D88","\u5931\u8D25"][n],target:e[t]})):[]}var Fn=3,L={nodes:150,depth:8,children:50,locales:20,actions:40,pages:20,stringLength:2e3,customHtml:32768,customCss:16384,documentBytes:2e5},ae=a.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),N=a.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),qn=a.enum(["none","xs","sm","md","lg","xl"]),En=a.enum(["none","sm","md","lg","full"]),be=a.string().regex(/^#[0-9a-fA-F]{6}$/),Mi=a.union([a.enum(["primary","text","muted","background","surface"]),be]),Bt=a.string().max(2048).refine(e=>{try{let t=new URL(e);return t.protocol==="https:"&&t.hostname.length>0}catch{return!1}},"\u53EA\u652F\u6301 https \u94FE\u63A5"),Ve=a.union([Bt,a.string().max(32768).regex(/^data:image\/svg\+xml;base64,[A-Za-z0-9+/]+={0,2}$/),a.string().max(131072).regex(/^data:image\/jpeg;base64,\/9j\/[A-Za-z0-9+/]+={0,2}$/),a.string().max(131072).regex(/^data:image\/png;base64,iVBORw0KGgo[A-Za-z0-9+/]+={0,2}$/)]),Mt=a.object({primary:be,background:be,text:be,radius:En,font:a.enum(["system","serif","rounded","mono"])}).strict(),se=a.union([a.enum(["primary","text","muted","background","surface"]),a.string().regex(/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/)]),O=(e,t)=>a.number().int().min(e).max(t),Ut=a.union([a.enum(["fit","fill"]),O(1,1200)]),Ln=a.object({top:O(0,200),right:O(0,200),bottom:O(0,200),left:O(0,200)}).strict(),Vn=a.object({top:O(-100,200),right:O(-100,200),bottom:O(-100,200),left:O(-100,200)}).strict(),Zt=a.object({x:O(0,100),y:O(0,100)}).strict(),Mn=a.discriminatedUnion("type",[a.object({type:a.literal("color"),color:se}).strict(),a.object({type:a.literal("linear"),angle:O(0,360),stops:a.array(a.object({color:se,at:O(0,100)}).strict()).min(2).max(4)}).strict(),a.object({type:a.literal("image"),src:Ve,fit:a.enum(["cover","contain"]),position:Zt.optional()}).strict()]),Un=a.discriminatedUnion("type",[a.object({type:a.literal("rect"),radius:a.union([O(0,200),a.object({topLeft:O(0,200),topRight:O(0,200),bottomRight:O(0,200),bottomLeft:O(0,200)}).strict()])}).strict(),a.object({type:a.literal("pill")}).strict()]),Hn=a.object({width:O(0,12),color:se,style:a.enum(["solid","dashed"])}).strict(),Bn=a.object({x:O(-40,40),y:O(-40,40),blur:O(0,80),spread:O(-20,40),color:se}).strict(),Zn=a.object({font:a.enum(["system","serif","rounded","mono"]),size:O(8,96),weight:a.number().int().min(100).max(900).multipleOf(100),lineHeight:a.number().min(.8).max(3),letterSpacing:a.number().min(-5).max(20),color:se,align:a.enum(["start","center","end"]),italic:a.boolean(),decoration:a.enum(["none","underline","line-through"]),transform:a.enum(["none","uppercase"])}).strict().partial(),ne=a.object({width:Ut,height:Ut,padding:Ln,margin:Vn,gap:O(0,120),grow:a.union([a.boolean(),a.number().min(0).max(12)]),background:Mn,opacity:a.number().min(0).max(1),shape:Un,border:Hn,shadow:Bn,text:Zn}).strict().partial(),H={id:ae,name:a.string().trim().min(1).max(60).optional(),hidden:a.boolean().optional(),style:ne.optional(),fallback:N.optional()},Kn=a.object({...H,type:a.literal("text"),text:N,variant:a.enum(["title","heading","body","caption"])}).strict(),Wn=a.object({...H,type:a.literal("image"),src:Ve,localizedSrc:a.record(E,Ve).optional(),alt:N,aspect:a.enum(["auto","1:1","4:3","16:9","3:1"]),fit:a.enum(["cover","contain"]),position:Zt.optional()}).strict(),Gn=a.object({...H,type:a.literal("button"),label:N,variant:a.enum(["primary","secondary","link"]),action:N}).strict(),Yn=a.object({...H,type:a.literal("divider")}).strict(),Jn=a.object({...H,type:a.literal("spacer"),size:qn}).strict(),Qn=a.object({...H,type:a.literal("custom_html"),html:a.record(E,a.string().max(L.customHtml)),css:a.string().max(L.customCss)}).strict(),Xn=a.object({...H,type:a.literal("price"),fallback:N,parts:a.object({current:ne.optional(),original:ne.optional(),period:ne.optional()}).strict().optional()}).strict(),er=a.object({...H,type:a.literal("coupon_code"),label:N,fallback:N}).strict(),tr=a.object({...H,type:a.literal("countdown"),source:a.enum(["offer.ends_at","offer.expires_at","fixed"]),at:a.iso.datetime().optional(),granularity:a.enum(["day","hour","minute","second"]),expired:N,fallback:N}).strict().refine(e=>e.source!=="fixed"||!!e.at,"\u56FA\u5B9A\u5012\u8BA1\u65F6\u9700\u8981\u7ED3\u675F\u65F6\u95F4"),nr=a.object({...H,type:a.literal("plan_picker"),label:N,fallback:N,planIds:a.array(a.uuid()).min(1).max(20).refine(e=>new Set(e).size===e.length,"\u5957\u9910\u4E0D\u80FD\u91CD\u590D").optional(),defaultPlan:a.uuid().optional(),states:a.object({selected:ne.optional()}).strict().optional()}).strict(),rr=a.discriminatedUnion("type",[a.object({type:a.literal("select"),label:N,defaultIndex:O(0,49),purpose:a.enum(["option","package","tier"]).optional(),selectedStyle:ne.optional()}).strict(),a.object({type:a.literal("tabs"),label:N,defaultIndex:O(0,49),purpose:a.literal("tier").optional()}).strict(),a.object({type:a.literal("toggle"),label:N,defaultEnabled:a.boolean()}).strict(),a.object({type:a.literal("carousel"),label:N}).strict()]),Kt=a.lazy(()=>a.object({...H,type:a.literal("stack"),direction:a.enum(["vertical","horizontal","overlay"]),align:a.enum(["start","center","end","stretch"]),justify:a.enum(["start","center","end","between"]),children:a.array(ir).max(L.children),interaction:rr.optional(),bind:ht.optional()}).strict()),ir=a.lazy(()=>a.union([Kt,Kn,Wn,Gn,Yn,Jn,Qn,Xn,er,tr,nr])),or=a.union([a.string().max(500),a.number().finite(),a.boolean(),a.null()]),te={id:N,event:N,properties:a.record(N,or).refine(e=>Object.keys(e).length<=20,"\u6700\u591A 20 \u4E2A\u53C2\u6570")},ar=a.discriminatedUnion("type",[a.object({...te,type:a.literal("purchase"),close:a.literal(!1),plan:a.union([a.literal("selected"),a.uuid()]),picker:ae.optional(),offer:a.enum(["scope","none"]),channel:a.enum(["web","native"])}).strict(),a.object({...te,type:a.literal("navigate"),target:ae,close:a.literal(!1)}).strict(),a.object({...te,type:a.literal("event"),close:a.boolean()}).strict(),a.object({...te,type:a.literal("close"),close:a.literal(!0)}).strict(),a.object({...te,type:a.literal("open_url"),close:a.boolean(),url:Bt}).strict(),a.object({...te,type:a.literal("claim_offer"),close:a.boolean(),couponId:a.uuid()}).strict()]),Ht=a.object({defaultLocale:E,locales:a.record(E,a.record(N,a.string().max(L.stringLength)))}).strict(),Ue=a.enum(["popup","paywall","onboarding","page"]),Wt={popup:"\u5F39\u7A97",paywall:"\u4ED8\u8D39\u5899",onboarding:"\u8F6C\u5316\u6F0F\u6597",page:"\u9875\u9762"},Ui={popup:"/workspace/popups",paywall:"/workspace/paywalls",onboarding:"/workspace/onboarding",page:"/workspace/pages"},sr=a.discriminatedUnion("type",[a.object({type:a.literal("modal"),size:a.enum(["sm","md","lg"])}).strict(),a.object({type:a.literal("sheet"),size:a.enum(["sm","md","lg"])}).strict(),a.object({type:a.literal("fullscreen")}).strict()]),Hi={sm:360,md:420,lg:560},cr=a.object({kind:a.literal("screen"),schemaVersion:a.literal(Fn),name:a.string().trim().min(1).max(80),surface:Ue,presentation:sr,theme:Mt,funnel:Et.optional(),pages:a.array(a.object({id:ae,name:a.string().trim().min(1).max(60),root:Kt,theme:Mt.optional(),source:a.object({campaignId:a.uuid(),versionId:a.uuid(),map:a.record(a.string(),ae),strings:Ht.optional()}).strict().optional(),editorPosition:a.object({x:a.number().finite().min(-1e5).max(1e5),y:a.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict()).min(1).max(L.pages),strings:Ht,actions:a.array(ar).max(L.actions)}).strict();function re(e,t){for(let n of e.pages)ce(n.root,t)}function Bi(e,t){return{...e,pages:e.pages.map((n,r)=>r===0?{...n,root:t}:n)}}var V=cr.superRefine((e,t)=>{e.surface==="page"&&(e.pages.length!==1||e.funnel||e.pages[0].source)&&t.addIssue({code:"custom",message:"\u72EC\u7ACB\u9875\u9762\u53EA\u80FD\u5305\u542B\u4E00\u4E2A\u9875\u9762\uFF0C\u4E0D\u80FD\u5305\u542B\u6D41\u7A0B\u6216\u5F15\u7528\u5176\u4ED6\u9875\u9762\u3002"});let n=o=>t.addIssue({code:"custom",message:o});e.pages.some(o=>o.source)&&(e.surface!=="onboarding"||!e.funnel)&&n("\u53EA\u6709 Funnel \u53EF\u4EE5\u5F15\u7528\u5DF2\u53D1\u5E03\u9875\u9762\u3002");for(let o of Le(e).errors)n(o);let r=Object.keys(e.strings.locales);r.includes(e.strings.defaultLocale)||n("\u9ED8\u8BA4\u8BED\u8A00\u5FC5\u987B\u5728\u8BED\u8A00\u5217\u8868\u91CC"),r.length>L.locales&&n(`\u6700\u591A ${L.locales} \u79CD\u8BED\u8A00`);let c=new Set;for(let o of e.actions)c.has(o.id)&&n(`\u52A8\u4F5C\u6807\u8BC6\u91CD\u590D\uFF1A${o.id}`),c.add(o.id);let i=new Set;for(let o of e.pages)["next","back"].includes(o.id)&&n(`\u9875\u9762 id \u4E0D\u80FD\u4F7F\u7528\u4FDD\u7559\u540D\u79F0\uFF1A${o.id}`),i.has(o.id)&&n(`\u9875\u9762 id \u91CD\u590D\uFF1A${o.id}`),i.add(o.id);for(let o of e.actions)o.type==="navigate"&&!["next","back"].includes(o.target)&&!i.has(o.target)&&n(`\u7FFB\u9875\u76EE\u6807\u4E0D\u5B58\u5728\uFF1A${o.target}`);let s=new Set,d=0,v=!1;re(e,(o,j)=>{if(d++,j>L.depth&&(v=!0),s.has(o.id)&&n(`\u7EC4\u4EF6 id \u91CD\u590D\uFF1A${o.id}`),s.add(o.id),o.type==="button"&&!c.has(o.action)&&n(`\u6309\u94AE ${o.id} \u5F15\u7528\u7684\u52A8\u4F5C\u4E0D\u5B58\u5728\uFF1A${o.action}`),o.type==="custom_html")for(let w of Object.keys(o.html))r.includes(w)||n(`\u81EA\u5B9A\u4E49 HTML ${o.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${w}`);if(o.type==="image")for(let w of Object.keys(o.localizedSrc??{}))r.includes(w)||n(`\u56FE\u7247 ${o.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${w}`)}),d>L.nodes&&n(`\u7EC4\u4EF6\u6700\u591A ${L.nodes} \u4E2A`),v&&n(`\u5C42\u7EA7\u6700\u591A ${L.depth} \u5C42`)});function ce(e,t,n=1,r=null){if(t(e,n,r)!==!1&&e.type==="stack")for(let c of e.children)ce(c,t,n+1,e)}function He(e){let t=[],n=new Set;return re(e,r=>{let c=(i,s,d)=>{n.has(i)||(n.add(i),t.push({key:i,nodeId:r.id,nodeType:r.type,field:s,required:d}))};r.type==="stack"&&r.interaction&&c(r.interaction.label,"label",!0),r.fallback&&c(r.fallback,"text",!0),r.type==="text"&&c(r.text,"text",!0),(r.type==="plan_picker"||r.type==="coupon_code")&&c(r.label,"label",!0),r.type==="countdown"&&c(r.expired,"text",!0),r.type==="button"&&c(r.label,"label",!0),r.type==="image"&&(c(`image:${r.id}`,"src",!1),c(r.alt,"alt",!1)),r.type==="custom_html"&&c(`html:${r.id}`,"html",!0)}),t}function ur(e,t,n){if(t.field==="html"){let r;return re(e,c=>{c.id===t.nodeId&&c.type==="custom_html"&&(r=c.html[n])}),r}if(t.field==="src"){let r=Me(e,t.nodeId);return r?.type==="image"?r.localizedSrc?.[n]??(n===e.strings.defaultLocale?r.src:void 0):void 0}return e.strings.locales[n]?.[t.key]}function Gt(e){let t=He(e).filter(r=>r.required);return Object.keys(e.strings.locales).sort((r,c)=>r===e.strings.defaultLocale?-1:c===e.strings.defaultLocale?1:0).map(r=>{let c=t.filter(i=>!ur(e,i,r)?.trim()).map(i=>i.key);return{locale:r,total:t.length,filled:t.length-c.length,missing:c,complete:c.length===0}})}function Zi(e){let t=Vt(e),n=[...t.errors],r=e.actions.some(o=>typeof o.properties.templateKey=="string"&&o.properties.templateKey.startsWith("popup-coupon-"));r&&(!e.actions.some(o=>o.type==="claim_offer")||e.actions.some(o=>o.type==="event"&&typeof o.properties.templateKey=="string"&&o.properties.templateKey.startsWith("popup-coupon-")))&&n.push("\u4F18\u60E0\u5238\u6A21\u677F\u5C1A\u672A\u7ED1\u5B9A\u771F\u5B9E\u4F18\u60E0\u5238\uFF1A\u8BF7\u5C06\u9886\u53D6\u6309\u94AE\u8BBE\u4E3A\u300C\u9886\u53D6\u4F18\u60E0\u300D\u5E76\u9009\u62E9\u751F\u6548\u4E2D\u7684\u5238");function c(o,j){let w=o.type==="stack"?o.bind?.coupon??j:j;if(r&&o.type==="text"&&Object.values(e.strings.locales).some(I=>I[o.text]?.includes("{{offer."))&&!w&&n.push("\u4F18\u60E0\u5238\u6A21\u677F\u5C1A\u672A\u7ED1\u5B9A\u771F\u5B9E\u4F18\u60E0\u5238\uFF1A\u52A8\u6001\u6587\u6848\u9700\u8981\u7EE7\u627F\u4F18\u60E0\u5238\u7ED1\u5B9A"),o.type==="button"){let I=e.actions.find(_=>_.id===o.action);I?.type==="claim_offer"&&w&&w!==I.couponId&&n.push(`\u9886\u53D6\u6309\u94AE ${o.id} \u4E0E\u5C55\u793A\u5185\u5BB9\u7ED1\u5B9A\u4E86\u4E0D\u540C\u7684\u4F18\u60E0\u5238`)}o.type==="stack"&&o.children.forEach(I=>c(I,w))}e.pages.forEach(o=>c(o.root));let i=[...Le(e).warnings,...t.warnings],s=V.safeParse(e);s.success||n.push(...s.error.issues.map(o=>o.message));for(let o of Object.values(e.strings.locales))for(let j of Object.values(o))for(let w of ge(j))n.push(`\u672A\u77E5\u53D8\u91CF\uFF1A${w}`);re(e,o=>{if((o.type==="text"?[o.text]:o.type==="button"?[o.label]:[]).some(w=>Object.values(e.strings.locales).some(I=>I[w]?.includes("{{")))&&!o.fallback&&n.push(`\u7EC4\u4EF6 ${o.id} \u4F7F\u7528\u53D8\u91CF\uFF0C\u8BF7\u586B\u5199\u5907\u7528\u6587\u6848`),o.fallback&&Object.values(e.strings.locales).some(w=>w[o.fallback]?.includes("{{"))&&n.push(`\u7EC4\u4EF6 ${o.id} \u7684\u5907\u7528\u6587\u6848\u9700\u8981\u4F7F\u7528\u9759\u6001\u6587\u5B57`),o.type==="custom_html"){for(let w of Object.values(o.html))n.push(...qe(w).map(I=>`HTML ${o.id}\uFF1A${I}`));Object.values(o.html).some(w=>w.includes("{{"))&&!o.fallback&&n.push(`HTML ${o.id} \u4F7F\u7528\u53D8\u91CF\uFF0C\u8BF7\u586B\u5199\u5907\u7528\u6587\u6848`),/\{\{|\}\}/.test(o.css)&&n.push(`HTML ${o.id} \u7684 CSS \u4E0D\u652F\u6301\u53D8\u91CF`)}o.type==="stack"&&o.bind?.picker&&Me(e,o.bind.picker)?.type!=="plan_picker"&&n.push(`\u5BB9\u5668 ${o.id} \u5F15\u7528\u7684\u5957\u9910\u9009\u62E9\u4E0D\u5B58\u5728`)});for(let o of e.actions)o.type==="purchase"&&o.picker&&Me(e,o.picker)?.type!=="plan_picker"&&n.push(`\u8D2D\u4E70\u52A8\u4F5C ${o.id} \u5F15\u7528\u7684\u5957\u9910\u9009\u62E9\u4E0D\u5B58\u5728`),o.type==="purchase"&&o.channel==="native"&&n.push("\u539F\u751F\u5E94\u7528\u5185\u8D2D\u4E70\u5C1A\u672A\u63A5\u5165\uFF0C\u8BF7\u4F7F\u7528 Web \u7ED3\u8D26");let d=Gt(e);for(let o of d)o.complete||(o.locale===e.strings.defaultLocale?n.push(`\u9ED8\u8BA4\u8BED\u8A00 ${o.locale} \u8FD8\u6709 ${o.missing.length} \u5904\u5185\u5BB9\u6CA1\u586B`):n.push(`${o.locale} \u8FD8\u6709 ${o.missing.length} \u5904\u6CA1\u7FFB\u8BD1\uFF0C\u8BF7\u8865\u9F50\u6216\u5220\u9664\u8FD9\u79CD\u8BED\u8A00\u540E\u53D1\u5E03`));He(e).length===0&&!e.pages.some(o=>pr(o.root))&&n.push("\u5F39\u7A97\u91CC\u8FD8\u6CA1\u6709\u53EF\u663E\u793A\u7684\u5185\u5BB9");let v=new Set;re(e,o=>{o.type==="button"&&v.add(o.action)});for(let o of e.actions)!v.has(o.id)&&!e.pages.some(j=>lr(j.root,o.id))&&i.push(`\u52A8\u4F5C ${o.id} \u6CA1\u6709\u88AB\u4EFB\u4F55\u6309\u94AE\u4F7F\u7528`);return{errors:n,warnings:i}}function pr(e){let t=!1;return ce(e,n=>{if(n.hidden)return!1;n.type==="image"&&(t=!0)}),t}function lr(e,t){let n=!1;return ce(e,r=>{if(r.type==="custom_html")for(let c of Object.values(r.html))c.includes(`data-grow-action="${t}"`)&&(n=!0)}),n}function dr(e){return Gt(e).filter(t=>t.complete||t.locale===e.strings.defaultLocale).map(t=>t.locale)}function Ki(e,t){return he(t,dr(e),e.strings.defaultLocale)}function Wi(e,t){let n=e.strings.locales[t]??{},r=e.strings.locales[e.strings.defaultLocale]??{},c={};for(let s of He(e)){if(s.field==="html"||s.field==="src")continue;let d=n[s.key]?.trim()?n[s.key]:r[s.key];d!==void 0&&(c[s.key]=d)}let i=s=>{if(s.type==="stack")return{...s,children:s.children.map(i)};if(s.type==="custom_html"){let d=s.html[t]?.trim()?s.html[t]:s.html[e.strings.defaultLocale];return{...s,html:d===void 0?{}:{[t]:d}}}if(s.type==="image"){let{localizedSrc:d,...v}=s;return{...v,src:d?.[t]??d?.[e.strings.defaultLocale]??s.src}}return s};return{...e,pages:e.pages.map(s=>({...s,root:i(s.root)})),strings:{defaultLocale:t,locales:{[t]:c}}}}function mr(e,t){let n=null;return ce(e,r=>{if(n)return!1;r.id===t&&(n=r)}),n}function Me(e,t){for(let n of e.pages){let r=mr(n.root,t);if(r)return r}return null}function Gi(e){let t=J(e)?.split("-")[0];return t!==void 0&&["ar","he","fa","ur"].includes(t)}function Yi(e,t,n){let r={};if(!t||typeof t!="object"||Array.isArray(t))return r;let c=t;return re(e,i=>{if(i.type==="plan_picker"){let d=c[i.id];typeof d=="string"&&n?.pickers[i.id]?.options.includes(d)&&(r[i.id]=d);return}if(i.type!=="stack"||!i.interaction)return;let s=Object.hasOwn(c,i.id)?c[i.id]:void 0;["select","tabs"].includes(i.interaction.type)&&typeof s=="string"&&i.children.some(d=>d.id===s)&&(r[i.id]=s),i.interaction.type==="toggle"&&typeof s=="boolean"&&(r[i.id]=s)}),r}var Yt=C.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),no=C.object({enabled:C.boolean(),trigger:Yt,tags:C.array(C.string().trim().min(1).max(40).refine(e=>!e.includes(","))).max(20).refine(e=>new Set(e).size===e.length),priority:C.number().int().min(-1e3).max(1e3),cooldownHours:C.number().int().min(0).max(720)}).strict(),Jt=C.object({id:C.uuid(),campaignId:C.uuid(),versionId:C.uuid(),popup:V,capabilities:me.optional(),locale:E,expiresAt:C.iso.datetime()}),Qt=C.object({locale:C.string().max(35).optional(),acceptLanguages:C.array(C.string().max(35)).max(10).optional()}),Xt=C.discriminatedUnion("type",[C.object({eventId:C.uuid(),deliveryId:C.uuid(),type:C.literal("shown"),locale:E.optional()}).strict(),C.object({eventId:C.uuid(),deliveryId:C.uuid(),type:C.literal("action"),actionId:Yt}).strict(),C.object({eventId:C.uuid(),deliveryId:C.uuid(),type:C.literal("closed"),reason:C.enum(["close_button","escape","action","destroy","timeout"])}).strict()]);var fr=l.enum(["customers:read","customers:write","plans:read","entitlements:read","sessions:create","offers:resolve","offers:grant","popups:resolve","billing:read","billing:write","events:write","credits:read","credits:consume","credits:manage"]),en={scope:M,permissions:l.array(fr),expiresAt:l.iso.datetime().nullable()},ho=l.discriminatedUnion("kind",[l.object({...en,kind:l.literal("server"),keyId:l.string().min(1)}),l.object({...en,kind:l.literal("customer"),customerId:l.string().min(1),expiresAt:l.iso.datetime()})]),P=l.object({requestId:l.uuid(),scope:M}),gr=wt.strict(),hr=P.extend({customer:oe,created:l.boolean()}),br=P.extend({plans:l.array(ze)}),yr=l.object({customerId:l.string().min(1).max(255).optional()}).strict(),xr=l.enum(["unassigned","unknown","scheduled","active","expired"]),Sr=l.object({customerId:l.string().min(1),evaluatedAt:l.iso.datetime(),status:xr,validity:Pe.nullable(),planVersion:ze.nullable(),holdings:l.array(l.object({id:l.uuid(),planVersionId:l.uuid(),source:l.enum(["subscription","assignment"])})).optional(),entitlements:l.array(l.object({featureId:l.string(),featureKey:l.string(),featureName:l.string(),type:l.enum(["boolean","metered"]),allowance:l.number().int().nonnegative().nullable(),used:l.number().finite().nonnegative(),remaining:l.number().finite().nonnegative().nullable(),allowed:l.boolean(),sources:l.array(l.object({holdingId:l.uuid(),planVersionId:l.uuid(),group:l.string(),kind:l.enum(["main","addon"]),allowance:l.number().nullable()})).optional()}))}),kr=P.extend(Sr.shape),vr=l.enum(["UNAUTHENTICATED","FORBIDDEN","SCOPE_MISMATCH","INVALID_REQUEST","NOT_FOUND","CONFLICT","PAYLOAD_TOO_LARGE","NOT_CONFIGURED","INTERNAL_ERROR"]),bo=l.object({requestId:l.uuid(),error:l.object({code:vr,message:l.string()})});function tn(){return P.extend({offer:Fe.nullable(),reason:Ft.nullable()})}var yo={listCreditPacks:{method:"POST",path:"credits/packs",permission:"credits:read",audience:"either",request:G,response:P.extend({packs:l.array(yt)})},listCreditPackOrders:{method:"POST",path:"credits/packs/orders",permission:"credits:read",audience:"either",request:G,response:P.extend({orders:l.array(St)})},createCreditPackCheckout:{method:"POST",path:"credits/packs/checkout",permission:"billing:write",audience:"either",request:xt,response:P.extend({orderId:l.uuid(),url:l.url()})},listCreditTransactions:{method:"POST",path:"credits/transactions",permission:"credits:read",audience:"either",request:ut,response:P.extend(pt.shape)},getBalances:{method:"POST",path:"credits/balances",permission:"credits:read",audience:"either",request:G,response:P.extend({account:de})},checkCredits:{method:"POST",path:"credits/check",permission:"credits:read",audience:"either",request:we,response:P.extend(rt.shape)},consumeCredits:{method:"POST",path:"credits/consume",permission:"credits:consume",audience:"server",request:Ae,response:P.extend(ee.shape)},reserveCredits:{method:"POST",path:"credits/reserve",permission:"credits:consume",audience:"server",request:it,response:P.extend(ee.shape)},finalizeCredits:{method:"POST",path:"credits/finalize",permission:"credits:consume",audience:"server",request:ot,response:P.extend(ee.shape)},refundCredits:{method:"POST",path:"credits/refund",permission:"credits:manage",audience:"server",request:at,response:P.extend(ee.shape)},grantCredits:{method:"POST",path:"credits/grant",permission:"credits:manage",audience:"server",request:st,response:P.extend(ee.shape)},refreshSurface:{method:"POST",path:"surfaces/context",permission:"popups:resolve",audience:"customer",request:l.object({deliveryId:l.uuid(),locale:l.string().max(35).optional()}).strict(),response:P.extend({capabilities:me})},purchaseSurface:{method:"POST",path:"surfaces/purchase",permission:"billing:write",audience:"customer",request:l.object({deliveryId:l.uuid(),actionId:l.string().min(1).max(64),nodeId:l.string().min(1).max(64),planId:l.uuid().optional(),requestId:l.uuid()}).strict(),response:P.extend({checkoutId:l.uuid(),url:l.url(),discount:l.object({couponId:l.uuid(),offerId:l.uuid().nullable(),promotionCode:l.string().nullable()}).nullable()})},createCheckout:{method:"POST",path:"billing/checkout",permission:"billing:write",audience:"customer",request:l.object({planVersionId:l.uuid(),requestId:l.uuid(),offerId:l.uuid().optional(),promotionCode:l.string().trim().min(3).max(32).transform(e=>e.toUpperCase()).optional()}).strict().refine(e=>!(e.offerId&&e.promotionCode),{message:"Use either offerId or promotionCode"}),response:P.extend({checkoutId:l.uuid(),url:l.url(),discount:l.object({couponId:l.uuid(),offerId:l.uuid().nullable(),promotionCode:l.string().nullable()}).nullable()})},getMemberships:{method:"GET",path:"memberships",permission:"billing:read",audience:"customer",request:l.object({}).strict(),response:P.extend({membership:Ye})},previewMembership:{method:"POST",path:"memberships/preview",permission:"billing:read",audience:"customer",request:je.refine(e=>e.action==="attach"||e.action==="change","Preview requires a plan change"),response:P.extend({preview:We})},manageMembership:{method:"POST",path:"memberships/manage",permission:"billing:write",audience:"customer",request:je,response:P.extend(Je.shape)},listSubscriptions:{method:"GET",path:"billing/subscriptions",permission:"billing:read",audience:"customer",request:l.object({}).strict(),response:P.extend({subscriptions:l.array(l.object({id:l.uuid(),status:l.string(),planVersionId:l.uuid().nullable(),startsAt:l.iso.datetime(),endsAt:l.iso.datetime(),cancelAtPeriodEnd:l.boolean(),accessEnabled:l.boolean()}))})},resolvePopup:{method:"POST",path:"popups/resolve",permission:"popups:resolve",audience:"customer",request:Qt.extend({trigger:l.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),requestId:l.uuid()}).strict(),response:P.extend({delivery:Jt.nullable()})},trackPopup:{method:"POST",path:"popups/events",permission:"events:write",audience:"customer",request:Xt,response:P.extend({accepted:l.literal(!0)})},createCustomer:{method:"POST",path:"customers",permission:"customers:write",audience:"server",request:gr,response:hr},getCustomer:{method:"POST",path:"customers/get",permission:"customers:read",audience:"server",request:$e,response:P.extend({customer:oe})},listCustomers:{method:"POST",path:"customers/list",permission:"customers:read",audience:"server",request:zt,response:P.extend(Pt.shape)},updateCustomer:{method:"POST",path:"customers/update",permission:"customers:write",audience:"server",request:Ct,response:P.extend(At.shape)},listPlans:{method:"GET",path:"plans",permission:"plans:read",audience:"either",request:l.object({}).strict(),response:br},getEntitlements:{method:"POST",path:"entitlements",permission:"entitlements:read",audience:"either",request:yr,response:kr},createSession:{method:"POST",path:"customer-sessions",permission:"sessions:create",audience:"server",request:l.object({customerId:l.string().min(1)}).strict(),response:P.extend({customerToken:l.string().min(1),expiresAt:l.iso.datetime()})},listOffers:{method:"GET",path:"offers",permission:"offers:resolve",audience:"customer",request:l.object({}).strict(),response:P.extend({offers:l.array(Fe)})},claimOffer:{method:"POST",path:"offers/claim",permission:"offers:resolve",audience:"customer",request:l.object({deliveryId:l.uuid(),actionId:l.string().min(1).max(64),couponId:l.uuid(),requestId:l.uuid()}).strict(),response:tn()},grantOffer:{method:"POST",path:"offers/grant",permission:"offers:grant",audience:"server",request:l.object({customerId:l.string().min(1).max(255),couponId:l.uuid(),requestId:l.uuid()}).strict(),response:tn()}};var on={primary:"#2C3C96",background:"#FFFFFF",text:"#1B1D24",radius:"md",font:"system"},ue=(e,t,n,r,c)=>({kind:"screen",schemaVersion:3,name:e,surface:"popup",presentation:{type:"modal",size:"md"},theme:{...on},pages:[{id:"main",name:"\u4E3B\u9875\u9762",root:t}],strings:{defaultLocale:"zh-CN",locales:{"zh-CN":n,en:r}},actions:c}),ie=e=>({type:"stack",id:"root",direction:"vertical",align:"stretch",justify:"start",children:e,style:{gap:12,padding:{top:24,right:24,bottom:24,left:24}}}),ye={id:"dismiss",type:"close",event:"popup.dismissed",properties:{},close:!0},nn=[{id:"blank",label:"\u7A7A\u767D",description:"\u4E00\u4E2A\u6807\u9898\u548C\u4E00\u4E2A\u6309\u94AE\uFF0C\u4ECE\u96F6\u5F00\u59CB\u642D\u3002",document:ue("\u672A\u547D\u540D\u5F39\u7A97",ie([{type:"text",id:"title",text:"title",variant:"heading"},{type:"button",id:"cta",label:"cta",variant:"primary",action:"dismiss",style:{width:"fill"}}]),{title:"\u6807\u9898",cta:"\u77E5\u9053\u4E86"},{title:"Title",cta:"Got it"},[ye])},{id:"announcement",label:"\u516C\u544A",description:"\u65B0\u529F\u80FD\u6216\u91CD\u8981\u901A\u77E5\uFF0C\u4E00\u4E2A\u4E3B\u6309\u94AE\u3002",document:ue("\u65B0\u529F\u80FD\u516C\u544A",ie([{type:"text",id:"eyebrow",text:"eyebrow",variant:"caption",style:{text:{color:"primary",weight:700}}},{type:"text",id:"title",text:"title",variant:"heading"},{type:"text",id:"body",text:"body",variant:"body",style:{text:{color:"muted"}}},{type:"button",id:"cta",label:"cta",variant:"primary",action:"learn_more",style:{width:"fill"}},{type:"button",id:"later",label:"later",variant:"link",action:"dismiss",style:{width:"fill"}}]),{eyebrow:"\u65B0\u529F\u80FD",title:"\u73B0\u5728\u53EF\u4EE5\u4E00\u952E\u5BFC\u51FA\u62A5\u8868",body:"\u5728\u4EFB\u610F\u6570\u636E\u9875\u70B9\u51FB\u53F3\u4E0A\u89D2\u300C\u5BFC\u51FA\u300D\uFF0C\u5373\u53EF\u4E0B\u8F7D CSV \u6216 PDF\u3002",cta:"\u53BB\u770B\u770B",later:"\u4EE5\u540E\u518D\u8BF4"},{eyebrow:"NEW",title:"Export reports in one click",body:"Click Export on any data page to download a CSV or PDF.",cta:"Take a look",later:"Not now"},[{id:"learn_more",type:"event",event:"announcement_clicked",properties:{},close:!0},ye])},{id:"upgrade",label:"\u5347\u7EA7\u5230 Pro",description:"\u5217\u51FA\u51E0\u9879\u6743\u76CA\uFF0C\u5F15\u5BFC\u5347\u7EA7\u3002",document:ue("\u5347\u7EA7\u5230 Pro",ie([{type:"text",id:"eyebrow",text:"eyebrow",variant:"caption",style:{text:{color:"primary",weight:700}}},{type:"text",id:"title",text:"title",variant:"heading"},{type:"stack",id:"benefits",name:"\u6743\u76CA\u5217\u8868",direction:"vertical",align:"stretch",justify:"start",children:[{type:"text",id:"benefit1",text:"benefit1",variant:"body"},{type:"text",id:"benefit2",text:"benefit2",variant:"body"},{type:"text",id:"benefit3",text:"benefit3",variant:"body"}],style:{background:{type:"color",color:"surface"},shape:{type:"rect",radius:8},gap:4,padding:{top:16,right:16,bottom:16,left:16}}},{type:"button",id:"cta",label:"cta",variant:"primary",action:"upgrade",style:{width:"fill"}},{type:"button",id:"later",label:"later",variant:"link",action:"dismiss",style:{width:"fill"}}]),{eyebrow:"PRO",title:"\u89E3\u9501\u5168\u90E8\u9AD8\u7EA7\u529F\u80FD",benefit1:"\u2713 \u65E0\u9650\u9879\u76EE\u4E0E\u6210\u5458",benefit2:"\u2713 \u9AD8\u7EA7\u6570\u636E\u5206\u6790",benefit3:"\u2713 \u4F18\u5148\u5BA2\u670D\u652F\u6301",cta:"\u67E5\u770B Pro \u65B9\u6848",later:"\u7EE7\u7EED\u4F7F\u7528\u514D\u8D39\u7248"},{eyebrow:"PRO",title:"Unlock every advanced feature",benefit1:"\u2713 Unlimited projects and members",benefit2:"\u2713 Advanced analytics",benefit3:"\u2713 Priority support",cta:"See Pro plans",later:"Stay on Free"},[{id:"upgrade",type:"event",event:"checkout_requested",properties:{planId:"pro"},close:!0},ye])},{id:"offer",label:"\u9650\u65F6\u4F18\u60E0",description:"\u6E10\u53D8\u5934\u56FE + \u89D2\u6807 + \u539F\u4EF7\u5212\u7EBF\u7684\u4F18\u60E0\u4EF7\uFF0C\u9002\u5408\u9886\u5238\u5F39\u7A97\u3002",document:{...ue("\u9650\u65F6\u4F18\u60E0",{type:"stack",id:"root",direction:"vertical",align:"stretch",justify:"start",children:[{type:"stack",id:"hero",name:"\u5934\u56FE",direction:"overlay",align:"start",justify:"start",children:[{type:"stack",id:"heroContent",name:"\u5934\u56FE\u5185\u5BB9",direction:"vertical",align:"center",justify:"center",children:[{type:"text",id:"eyebrow",text:"eyebrow",variant:"caption",style:{width:"fit",padding:{top:3,right:10,bottom:3,left:10},background:{type:"color",color:"#FFFFFF2E"},shape:{type:"pill"},text:{color:"#FFFFFF",weight:700,letterSpacing:1,align:"center"}}},{type:"text",id:"title",text:"title",variant:"title",style:{text:{size:40,weight:900,color:"#FFFFFF",align:"center",lineHeight:1.1}}},{type:"text",id:"subtitle",text:"subtitle",variant:"body",style:{text:{size:14,color:"#FFFFFFD9",align:"center"}}}],style:{width:"fill",padding:{top:32,right:24,bottom:28,left:24},gap:6}},{type:"text",id:"badge",name:"\u89D2\u6807",text:"badge",variant:"caption",style:{width:"fit",margin:{top:14,right:0,bottom:0,left:14},padding:{top:4,right:10,bottom:4,left:10},background:{type:"color",color:"#FFD84D"},shape:{type:"pill"},shadow:{x:0,y:4,blur:10,spread:0,color:"#00000026"},text:{color:"#3A1D00",weight:800,size:13}}}],style:{gap:0,padding:{top:0,right:0,bottom:0,left:0},background:{type:"linear",angle:135,stops:[{color:"#FF7A45",at:0},{color:"#E8336D",at:100}]}}},{type:"stack",id:"body",name:"\u4EF7\u683C\u4E0E\u6309\u94AE",direction:"vertical",align:"stretch",justify:"start",children:[{type:"stack",id:"price",name:"\u4EF7\u683C",direction:"horizontal",align:"end",justify:"center",children:[{type:"text",id:"newPrice",text:"newPrice",variant:"title",style:{text:{size:34,weight:800,color:"#E8336D",lineHeight:1}}},{type:"text",id:"period",text:"period",variant:"body",style:{text:{color:"muted",size:14,lineHeight:1.6}}},{type:"text",id:"oldPrice",text:"oldPrice",variant:"body",style:{text:{color:"muted",size:15,decoration:"line-through",lineHeight:1.6}}}],style:{gap:8,padding:{top:0,right:0,bottom:0,left:0}}},{type:"text",id:"then",text:"then",variant:"caption",style:{text:{color:"muted",align:"center"}}},{type:"button",id:"cta",label:"cta",variant:"primary",action:"claim",style:{width:"fill",height:52,background:{type:"linear",angle:90,stops:[{color:"#FF7A45",at:0},{color:"#E8336D",at:100}]},shape:{type:"pill"},shadow:{x:0,y:10,blur:24,spread:-6,color:"#E8336D66"},text:{size:17,weight:800,color:"#FFFFFF"}}},{type:"button",id:"later",label:"later",variant:"link",action:"dismiss",style:{width:"fill"}}],style:{gap:14,padding:{top:22,right:24,bottom:22,left:24}}}],style:{gap:0,padding:{top:0,right:0,bottom:0,left:0}}},{eyebrow:"\u9650\u65F6 48 \u5C0F\u65F6",title:"\u9996\u6708 7 \u6298",subtitle:"\u65B0\u7528\u6237\u4E13\u4EAB \xB7 \u9886\u53D6\u540E 3 \u5929\u5185\u6709\u6548",badge:"-30%",newPrice:"$20.30",period:"/\u9996\u6708",oldPrice:"$29",then:"\u4E4B\u540E\u6BCF\u6708 $29\uFF0C\u53EF\u968F\u65F6\u53D6\u6D88",cta:"\u7ACB\u5373\u9886\u53D6",later:"\u6682\u4E0D\u9700\u8981"},{eyebrow:"48 HOURS ONLY",title:"30% off",subtitle:"For new members \xB7 valid 3 days after claiming",badge:"-30%",newPrice:"$20.30",period:"/first month",oldPrice:"$29",then:"Then $29/month. Cancel anytime.",cta:"Claim offer",later:"Not now"},[{id:"claim",type:"event",event:"offer_claimed",properties:{discount:30},close:!0},ye]),theme:{...on,primary:"#E8336D",radius:"lg"}}},{id:"feedback",label:"\u6536\u96C6\u53CD\u9988",description:"\u4E24\u4E2A\u9009\u9879\u6309\u94AE\uFF0C\u8BB0\u5F55\u7528\u6237\u7684\u9009\u62E9\u3002",document:ue("\u6EE1\u610F\u5EA6\u8C03\u67E5",ie([{type:"text",id:"title",text:"title",variant:"heading",style:{text:{align:"center"}}},{type:"text",id:"body",text:"body",variant:"body",style:{text:{align:"center",color:"muted"}}},{type:"stack",id:"choices",name:"\u9009\u9879",direction:"horizontal",align:"stretch",justify:"center",children:[{type:"button",id:"yes",label:"yes",variant:"secondary",action:"positive",style:{width:"fill"}},{type:"button",id:"no",label:"no",variant:"secondary",action:"negative",style:{width:"fill"}}],style:{gap:8,padding:{top:0,right:0,bottom:0,left:0}}}]),{title:"\u8FD9\u4E2A\u529F\u80FD\u5BF9\u4F60\u6709\u5E2E\u52A9\u5417\uFF1F",body:"\u4F60\u7684\u53CD\u9988\u4F1A\u76F4\u63A5\u5F71\u54CD\u6211\u4EEC\u4E0B\u4E00\u6B65\u505A\u4EC0\u4E48\u3002",yes:"\u6709\u5E2E\u52A9",no:"\u6CA1\u5E2E\u52A9"},{title:"Was this feature helpful?",body:"Your answer shapes what we build next.",yes:"Yes",no:"No"},[{id:"positive",type:"event",event:"feedback_submitted",properties:{helpful:!0},close:!0},{id:"negative",type:"event",event:"feedback_submitted",properties:{helpful:!1},close:!0}])}];function xe(e="blank"){let t=nn.find(n=>n.id===e)??nn[0];return structuredClone(t.document)}var rn=(e,t,n)=>({type:"stack",id:e,name:"Web \u81EA\u9002\u5E94\u5E03\u5C40",direction:"horizontal",align:"center",justify:"center",children:[{...ie(t),id:`${e}_intro`,name:"\u4ECB\u7ECD",style:{width:480,gap:20,padding:{top:0,right:0,bottom:0,left:0}}},{...ie(n),id:`${e}_detail`,name:"\u5185\u5BB9\u4E0E\u64CD\u4F5C",style:{width:400,gap:20,padding:{top:24,right:24,bottom:24,left:24},background:{type:"color",color:"surface"},shape:{type:"rect",radius:8}}}],style:{gap:40,padding:{top:40,right:24,bottom:40,left:24}}});function So(e,t="blank"){let n=xe(t);if(e==="popup"||(n.surface=e,n.presentation={type:"fullscreen"},e==="page"))return n;if(e==="paywall"){let c=xe("upgrade");c.actions=c.actions.map(s=>s.id==="upgrade"&&s.type==="event"?{...s,event:"paywall.upgrade_clicked",properties:{},close:!1}:s),c.strings.locales["zh-CN"].cta="\u4E86\u89E3\u5347\u7EA7\u65B9\u6848",c.strings.locales.en.cta="Explore upgrade options",c.strings.locales["zh-CN"].body="\u4E3A\u4F60\u7684\u5DE5\u4F5C\u533A\u9009\u62E9\u9002\u5408\u7684\u529F\u80FD\u4E0E\u534F\u4F5C\u65B9\u5F0F\u3002",c.strings.locales.en.body="Find the right features and collaboration tools for your workspace.";let i=c.pages[0].root.children;return c.pages[0].root=rn("root",[...i.slice(0,2),{type:"text",id:"body",text:"body",variant:"body",style:{text:{color:"muted"}}}],i.slice(2)),{...c,surface:e,presentation:{type:"fullscreen"},name:"\u9AD8\u7EA7\u529F\u80FD\u4ED8\u8D39\u5899"}}n.name="\u65B0\u7528\u6237\u5F15\u5BFC",n.pages=[],n.actions=[],n.strings.locales={"zh-CN":{},en:{}};let r=[["\u6B22\u8FCE\u4F7F\u7528","\u4ECE\u8FD9\u91CC\u5F00\u59CB\uFF0C\u4E86\u89E3\u4F60\u53EF\u4EE5\u5B8C\u6210\u4EC0\u4E48\u3002","Welcome","Discover what you can do here."],["\u627E\u5230\u9002\u5408\u4F60\u7684\u65B9\u5F0F","\u6309\u81EA\u5DF1\u7684\u8282\u594F\u63A2\u7D22\uFF0C\u968F\u65F6\u8C03\u6574\u3002","Make it yours","Explore at your own pace."],["\u4E00\u5207\u51C6\u5907\u5C31\u7EEA","\u5F00\u59CB\u4F60\u7684\u7B2C\u4E00\u6B21\u4F53\u9A8C\u3002","You're ready","Start your first experience."]];for(let c=0;c<r.length;c++){let i=`step${c+1}`,[s,d,v,o]=r[c],j=rn(`${i}_root`,[{type:"text",id:`${i}_step`,text:`${i}.step`,variant:"caption",style:{text:{color:"primary",weight:700}}},{type:"text",id:`${i}_title`,text:`${i}.title`,variant:"title"},{type:"text",id:`${i}_body`,text:`${i}.body`,variant:"body",style:{text:{color:"muted"}}}],[{type:"text",id:`${i}_detail_title`,text:`${i}.detail_title`,variant:"heading"},{type:"text",id:`${i}_detail_body`,text:`${i}.detail_body`,variant:"body",style:{text:{color:"muted"}}},{type:"divider",id:`${i}_divider`},{type:"stack",id:`${i}_controls`,name:"\u9875\u9762\u64CD\u4F5C",direction:"horizontal",align:"center",justify:"end",children:[...c?[{type:"button",id:`${i}_back`,label:"back",variant:"secondary",action:"go_back",style:{width:"fit"}}]:[],{type:"button",id:`${i}_cta`,label:`${i}.cta`,variant:"primary",action:`${i}_continue`,style:{width:"fit"}}],style:{gap:8,padding:{top:0,right:0,bottom:0,left:0}}}]);n.pages.push({id:i,name:`\u7B2C ${c+1} \u9875`,root:j}),Object.assign(n.strings.locales["zh-CN"],{[`${i}.title`]:s,[`${i}.body`]:d,[`${i}.cta`]:c===2?"\u5F00\u59CB\u4F7F\u7528":"\u7EE7\u7EED",[`${i}.step`]:`\u7B2C ${c+1} / 3 \u6B65`,[`${i}.detail_title`]:["\u4E86\u89E3\u5DE5\u4F5C\u533A","\u9009\u62E9\u4F7F\u7528\u65B9\u5F0F","\u5F00\u59CB\u4F53\u9A8C"][c],[`${i}.detail_body`]:["\u5148\u719F\u6089\u529F\u80FD\u4E0E\u5E38\u7528\u64CD\u4F5C\uFF0C\u518D\u8FDB\u5165\u4E0B\u4E00\u6B65\u3002","\u6839\u636E\u81EA\u5DF1\u7684\u5DE5\u4F5C\u4E60\u60EF\u8BBE\u7F6E\uFF0C\u4E4B\u540E\u4E5F\u53EF\u4EE5\u8C03\u6574\u3002","\u5F15\u5BFC\u5DF2\u5B8C\u6210\uFF0C\u70B9\u51FB\u4E0B\u65B9\u6309\u94AE\u8FDB\u5165\u5DE5\u4F5C\u533A\u3002"][c],back:"\u8FD4\u56DE"}),Object.assign(n.strings.locales.en,{[`${i}.title`]:v,[`${i}.body`]:o,[`${i}.cta`]:c===2?"Get started":"Continue",[`${i}.step`]:`Step ${c+1} of 3`,[`${i}.detail_title`]:["Explore your workspace","Choose how you work","Start exploring"][c],[`${i}.detail_body`]:["Learn the features and common actions before moving on.","Set up your workflow. You can adjust it later.","You're all set. Use the button below to enter your workspace."][c],back:"Back"}),n.actions.push(c===2?{id:`${i}_continue`,type:"event",event:"onboarding.completed",properties:{},close:!0}:{id:`${i}_continue`,type:"navigate",target:`step${c+2}`,event:"onboarding.next",properties:{},close:!1})}return n.actions.push({id:"go_back",type:"navigate",target:"back",event:"onboarding.back",properties:{},close:!1}),n}function jo(e){let t=xe();return{...t,name:`\u672A\u547D\u540D${Wt[e]}`,surface:e,presentation:e==="popup"?{type:"modal",size:"md"}:{type:"fullscreen"},pages:[{id:"main",name:e==="onboarding"?"\u5F00\u59CB":"\u4E3B\u9875\u9762",root:{...t.pages[0].root,name:"\u753B\u5E03",style:e==="popup"?{height:280}:{},children:[]}}],strings:{defaultLocale:"zh-CN",locales:{"zh-CN":{},en:{}}},actions:[]}}import{z as $}from"zod";var zo=$.object({id:$.uuid(),key:$.string().nullable(),label:$.string().min(1).max(80),description:$.string().max(300),category:$.string().min(1).max(40),tags:$.array($.string().max(30)).max(10),surface:Ue,source:$.enum(["official","private"]),document:V,revision:$.number().int().positive(),archived_at:$.string().nullable(),created_at:$.string()}),Po=$.object({projectId:$.uuid(),environmentId:$.uuid(),label:$.string().trim().min(1).max(80),description:$.string().trim().max(300),category:$.string().trim().min(1).max(40),document:V}),Oo=$.object({projectId:$.uuid(),environmentId:$.uuid(),id:$.uuid(),revision:$.number().int().positive()});import{z as u}from"zod";var an=u.string().regex(/^gg_fr_[A-Za-z0-9_-]{43}$/),Do=u.discriminatedUnion("operation",[u.object({operation:u.literal("start"),campaignId:u.uuid(),requestId:u.uuid(),visitorToken:u.string().regex(/^gg_f[rv]_[A-Za-z0-9_-]{43}$/).optional(),customerToken:u.string().regex(/^gg_ct_[A-Za-z0-9_-]{32,128}$/).optional(),locale:u.string().max(35).optional()}).strict(),u.object({operation:u.literal("revoke"),runId:u.uuid()}).strict(),u.object({operation:u.literal("get")}).strict(),u.object({operation:u.literal("link"),runToken:an}).strict(),u.object({operation:u.literal("event"),eventId:u.uuid(),nodeId:u.string().max(64),type:u.enum(["enter","complete","close"]),back:u.boolean().optional()}).strict(),u.object({operation:u.literal("node"),nodeId:u.string().max(64),requestId:u.uuid(),outcome:u.enum(["begin","cancel","failure","confirm"]),customerToken:u.string().regex(/^gg_ct_[A-Za-z0-9_-]{32,128}$/).optional()}).strict()]),Ir=u.object({id:u.uuid(),campaignId:u.uuid(),versionId:u.uuid(),document:V,locale:u.string(),nodeId:u.string(),history:u.array(u.string()),status:u.enum(["running","completed","closed"]),customerId:u.uuid().nullable(),expiresAt:u.iso.datetime({offset:!0}),assignments:u.array(u.object({nodeId:u.string(),variantId:u.string(),target:u.string(),experimentId:u.uuid(),revision:u.number(),bucketVersion:u.number().int().positive().optional(),excluded:u.boolean()}))}),No=u.object({run:Ir.optional(),runToken:an.optional(),visitorToken:u.string().regex(/^gg_fv_[A-Za-z0-9_-]{43}$/).optional(),visitorExpiresAt:u.iso.datetime({offset:!0}).optional(),target:u.string().optional(),pending:u.boolean().optional(),checkout:u.object({checkoutId:u.uuid(),url:u.url()}).nullable().optional(),price:u.object({amountCents:u.number().int(),currency:u.string(),interval:u.string().nullable()}).optional(),accepted:u.boolean().optional()}),Ro=u.object({references:u.array(u.object({id:u.uuid(),name:u.string(),versionId:u.uuid(),version:u.number(),document:V})).default([]),pages:u.array(u.object({id:u.uuid(),name:u.string(),versionId:u.uuid(),version:u.number(),document:V})).default([]),plans:u.array(u.object({id:u.uuid(),name:u.string(),amount_cents:u.number(),currency:u.string(),price_interval:u.string()})),experiments:u.array(u.object({id:u.uuid(),revision:u.number(),node_id:u.string(),bucket_version:u.number().int().positive().optional(),status:u.enum(["draft","running","paused","ended"]),winner_variant_id:u.string().nullable().optional()}))}),Fo=u.object({overall:u.object({entered:u.number(),completed:u.number(),authenticated:u.number(),authReached:u.number(),paid:u.number(),free:u.number()}),steps:u.array(u.object({node_id:u.string(),visitors:u.number()})),edges:u.array(u.object({node_id:u.string(),target:u.string(),visitors:u.number()})),currencies:u.array(u.object({currency:u.string(),grossCents:u.number(),refundCents:u.number()})),variants:u.array(u.object({experimentId:u.uuid(),revision:u.number(),variantId:u.string(),exposed:u.number(),completed:u.number(),paid:u.number(),exposedRuns:u.number().optional(),completedRuns:u.number().optional(),paidRuns:u.number().optional()}))});var Be={zh:["\u5168\u90E8\u4ED8\u8D39\u5957\u9910","\u6307\u5B9A\u5957\u9910","\u6240\u6709\u5BA2\u6237","\u4EC5\u9996\u8D2D","\u9700\u8981\u6807\u7B7E","\u5F00\u59CB","\u622A\u6B62","\u65E0\u622A\u6B62\u65E5\u671F","\u9886\u53D6\u540E\u6709\u6548","\u5C0F\u65F6","\u6BCF\u4EBA\u6B21\u6570","\u603B\u540D\u989D"],"zh-Hant":["\u5168\u90E8\u4ED8\u8CBB\u65B9\u6848","\u6307\u5B9A\u65B9\u6848","\u6240\u6709\u5BA2\u6236","\u50C5\u9996\u8CFC","\u9700\u8981\u6A19\u7C64","\u958B\u59CB","\u622A\u6B62","\u7121\u622A\u6B62\u65E5\u671F","\u9818\u53D6\u5F8C\u6709\u6548","\u5C0F\u6642","\u6BCF\u4EBA\u6B21\u6578","\u7E3D\u540D\u984D"],en:["All paid plans","Selected plans","All customers","First purchase only","Required tags","Starts","Ends","No end date","Valid after claim","hours","Uses per customer","Total limit"],ja:["\u5168\u6709\u6599\u30D7\u30E9\u30F3","\u5BFE\u8C61\u30D7\u30E9\u30F3","\u3059\u3079\u3066\u306E\u304A\u5BA2\u69D8","\u521D\u56DE\u8CFC\u5165\u9650\u5B9A","\u5FC5\u8981\u306A\u30BF\u30B0","\u958B\u59CB","\u7D42\u4E86","\u7D42\u4E86\u65E5\u306A\u3057","\u53D7\u53D6\u5F8C\u306E\u6709\u52B9\u671F\u9593","\u6642\u9593","\u9867\u5BA2\u3054\u3068\u306E\u5229\u7528\u56DE\u6570","\u5229\u7528\u4E0A\u9650"],ko:["\uBAA8\uB4E0 \uC720\uB8CC \uC694\uAE08\uC81C","\uC9C0\uC815 \uC694\uAE08\uC81C","\uBAA8\uB4E0 \uACE0\uAC1D","\uCCAB \uAD6C\uB9E4\uB9CC","\uD544\uC218 \uD0DC\uADF8","\uC2DC\uC791","\uC885\uB8CC","\uC885\uB8CC\uC77C \uC5C6\uC74C","\uC218\uB839 \uD6C4 \uC720\uD6A8 \uAE30\uAC04","\uC2DC\uAC04","\uACE0\uAC1D\uBCC4 \uC0AC\uC6A9 \uD69F\uC218","\uCD1D \uD55C\uB3C4"],es:["Todos los planes de pago","Planes seleccionados","Todos los clientes","Solo primera compra","Etiquetas requeridas","Inicio","Fin","Sin fecha de fin","Validez tras reclamar","horas","Usos por cliente","L\xEDmite total"],fr:["Tous les forfaits payants","Forfaits s\xE9lectionn\xE9s","Tous les clients","Premier achat uniquement","\xC9tiquettes requises","D\xE9but","Fin","Sans date de fin","Validit\xE9 apr\xE8s obtention","heures","Utilisations par client","Limite totale"],de:["Alle kostenpflichtigen Tarife","Ausgew\xE4hlte Tarife","Alle Kunden","Nur erster Kauf","Erforderliche Tags","Beginn","Ende","Kein Enddatum","G\xFCltigkeit nach Erhalt","Stunden","Nutzungen pro Kunde","Gesamtlimit"],pt:["Todos os planos pagos","Planos selecionados","Todos os clientes","Apenas primeira compra","Etiquetas necess\xE1rias","In\xEDcio","Fim","Sem data final","Validade ap\xF3s resgate","horas","Usos por cliente","Limite total"],it:["Tutti i piani a pagamento","Piani selezionati","Tutti i clienti","Solo primo acquisto","Tag richiesti","Inizio","Fine","Senza data finale","Validit\xE0 dopo il ritiro","ore","Utilizzi per cliente","Limite totale"],ru:["\u0412\u0441\u0435 \u043F\u043B\u0430\u0442\u043D\u044B\u0435 \u043F\u043B\u0430\u043D\u044B","\u0412\u044B\u0431\u0440\u0430\u043D\u043D\u044B\u0435 \u043F\u043B\u0430\u043D\u044B","\u0412\u0441\u0435 \u043A\u043B\u0438\u0435\u043D\u0442\u044B","\u0422\u043E\u043B\u044C\u043A\u043E \u043F\u0435\u0440\u0432\u0430\u044F \u043F\u043E\u043A\u0443\u043F\u043A\u0430","\u041D\u0435\u043E\u0431\u0445\u043E\u0434\u0438\u043C\u044B\u0435 \u0442\u0435\u0433\u0438","\u041D\u0430\u0447\u0430\u043B\u043E","\u041E\u043A\u043E\u043D\u0447\u0430\u043D\u0438\u0435","\u0411\u0435\u0437 \u0434\u0430\u0442\u044B \u043E\u043A\u043E\u043D\u0447\u0430\u043D\u0438\u044F","\u0421\u0440\u043E\u043A \u043F\u043E\u0441\u043B\u0435 \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u0438\u044F","\u0447\u0430\u0441\u043E\u0432","\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0439 \u043D\u0430 \u043A\u043B\u0438\u0435\u043D\u0442\u0430","\u041E\u0431\u0449\u0438\u0439 \u043B\u0438\u043C\u0438\u0442"],vi:["M\u1ECDi g\xF3i tr\u1EA3 ph\xED","G\xF3i \u0111\u01B0\u1EE3c ch\u1ECDn","M\u1ECDi kh\xE1ch h\xE0ng","Ch\u1EC9 l\u1EA7n mua \u0111\u1EA7u","Th\u1EBB b\u1EAFt bu\u1ED9c","B\u1EAFt \u0111\u1EA7u","K\u1EBFt th\xFAc","Kh\xF4ng c\xF3 ng\xE0y k\u1EBFt th\xFAc","Hi\u1EC7u l\u1EF1c sau khi nh\u1EADn","gi\u1EDD","L\u01B0\u1EE3t m\u1ED7i kh\xE1ch","T\u1ED5ng gi\u1EDBi h\u1EA1n"],th:["\u0E17\u0E38\u0E01\u0E41\u0E1E\u0E47\u0E01\u0E40\u0E01\u0E08\u0E41\u0E1A\u0E1A\u0E0A\u0E33\u0E23\u0E30\u0E40\u0E07\u0E34\u0E19","\u0E41\u0E1E\u0E47\u0E01\u0E40\u0E01\u0E08\u0E17\u0E35\u0E48\u0E40\u0E25\u0E37\u0E2D\u0E01","\u0E25\u0E39\u0E01\u0E04\u0E49\u0E32\u0E17\u0E38\u0E01\u0E04\u0E19","\u0E40\u0E09\u0E1E\u0E32\u0E30\u0E01\u0E32\u0E23\u0E0B\u0E37\u0E49\u0E2D\u0E04\u0E23\u0E31\u0E49\u0E07\u0E41\u0E23\u0E01","\u0E41\u0E17\u0E47\u0E01\u0E17\u0E35\u0E48\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19","\u0E40\u0E23\u0E34\u0E48\u0E21","\u0E2A\u0E34\u0E49\u0E19\u0E2A\u0E38\u0E14","\u0E44\u0E21\u0E48\u0E21\u0E35\u0E27\u0E31\u0E19\u0E2A\u0E34\u0E49\u0E19\u0E2A\u0E38\u0E14","\u0E2D\u0E32\u0E22\u0E38\u0E2B\u0E25\u0E31\u0E07\u0E23\u0E31\u0E1A\u0E2A\u0E34\u0E17\u0E18\u0E34\u0E4C","\u0E0A\u0E31\u0E48\u0E27\u0E42\u0E21\u0E07","\u0E04\u0E23\u0E31\u0E49\u0E07\u0E15\u0E48\u0E2D\u0E25\u0E39\u0E01\u0E04\u0E49\u0E32","\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E31\u0E49\u0E07\u0E2B\u0E21\u0E14"],id:["Semua paket berbayar","Paket terpilih","Semua pelanggan","Hanya pembelian pertama","Tag wajib","Mulai","Berakhir","Tanpa tanggal akhir","Masa berlaku setelah klaim","jam","Penggunaan per pelanggan","Batas total"],ar:["\u062C\u0645\u064A\u0639 \u0627\u0644\u062E\u0637\u0637 \u0627\u0644\u0645\u062F\u0641\u0648\u0639\u0629","\u0627\u0644\u062E\u0637\u0637 \u0627\u0644\u0645\u062D\u062F\u062F\u0629","\u062C\u0645\u064A\u0639 \u0627\u0644\u0639\u0645\u0644\u0627\u0621","\u0627\u0644\u0634\u0631\u0627\u0621 \u0627\u0644\u0623\u0648\u0644 \u0641\u0642\u0637","\u0627\u0644\u0648\u0633\u0648\u0645 \u0627\u0644\u0645\u0637\u0644\u0648\u0628\u0629","\u062A\u0628\u062F\u0623","\u062A\u0646\u062A\u0647\u064A","\u0628\u0644\u0627 \u062A\u0627\u0631\u064A\u062E \u0627\u0646\u062A\u0647\u0627\u0621","\u0627\u0644\u0635\u0644\u0627\u062D\u064A\u0629 \u0628\u0639\u062F \u0627\u0644\u0645\u0637\u0627\u0644\u0628\u0629","\u0633\u0627\u0639\u0627\u062A","\u0627\u0644\u0627\u0633\u062A\u062E\u062F\u0627\u0645\u0627\u062A \u0644\u0643\u0644 \u0639\u0645\u064A\u0644","\u0627\u0644\u062D\u062F \u0627\u0644\u0625\u062C\u0645\u0627\u0644\u064A"]};function Lo(e,t,n=[]){let r=J(t)??"en",c=r.split("-")[0],i=c==="zh"&&/(?:Hant|TW|HK|MO)/.test(r)?"zh-Hant":c,s=Be[i]??Be.en,d=Be[i]?r:"en",v=_=>new Intl.NumberFormat(d).format(_),o=_=>new Intl.DateTimeFormat(d,{dateStyle:"medium",timeStyle:"short",timeZone:"UTC"}).format(new Date(_))+" UTC",j=[e.appliesTo.type==="all"?s[0]:`${s[1]}${n.length?`: ${n.slice(0,3).join(", ")+(n.length>3?` (+${v(n.length-3)})`:"")}`:""}`,e.eligibility.firstPurchaseOnly?s[3]:s[2],e.eligibility.requiredTags.length?`${s[4]}: ${e.eligibility.requiredTags.join(", ")}`:null].filter(Boolean).join(" \xB7 "),w=[e.startsAt?`${s[5]}: ${o(e.startsAt)}`:null,e.endsAt?`${s[6]}: ${o(e.endsAt)}`:s[7]].filter(Boolean).join(" \xB7 "),I=[j,w,`${s[8]}: ${v(e.grantWindowHours)} ${s[9]}`,`${s[10]}: ${v(e.perCustomerLimit)}`,e.totalLimit===null?null:`${s[11]}: ${v(e.totalLimit)}`].filter(Boolean).join(" \xB7 ");return{eligibility:j,validity:w,terms:I}}var sn={"popup-coupon-welcome-ticket":{discount:"20%",zh:"\u9996\u671F\u8BA2\u9605\u4F18\u60E0",en:"Off your first subscription payment"},"popup-coupon-return-ticket":{discount:"$5",zh:"\u56DE\u6765\u7EE7\u7EED\u4F60\u7684\u8BA1\u5212",en:"Pick up where you left off"},"popup-coupon-launch-poster":{discount:"30%",zh:"\u65B0\u7248\u672C\u4E0A\u7EBF\u4F18\u60E0",en:"A special offer for our new release"},"popup-coupon-friday-poster":{discount:"40%",zh:"\u6D3B\u52A8\u671F\u8BA2\u9605\u4F18\u60E0",en:"A subscription offer for the campaign"},"popup-coupon-studio-split":{discount:"25%",zh:"\u4E3A\u521B\u4F5C\u8005\u51C6\u5907\u7684\u8BA2\u9605\u793C\u9047",en:"A subscription offer for creators"},"popup-coupon-team-split":{discount:"$10",zh:"\u56E2\u961F\u65B9\u6848\u9996\u671F\u51CF\u514D",en:"Off the first payment on a team plan"},"popup-coupon-member-letter":{discount:"20%",zh:"\u4E00\u4EFD\u4E13\u5C5E\u7684\u4F1A\u5458\u793C\u9047",en:"A membership offer just for you"},"popup-coupon-founder-letter":{discount:"30%",zh:"\u7ED9\u65E9\u671F\u652F\u6301\u8005\u7684\u8BA2\u9605\u4F18\u60E0",en:"A subscription offer for early supporters"},"popup-coupon-gift-box":{discount:"$5",zh:"\u4F60\u7684\u4E0B\u4E00\u6B21\u8BA2\u9605\u4F18\u60E0",en:"An offer for your next subscription"},"popup-coupon-birthday-box":{discount:"25%",zh:"\u751F\u65E5\u4E3B\u9898\u4F1A\u5458\u4F18\u60E0",en:"A birthday-themed membership offer"},"popup-coupon-first-receipt":{discount:"20%",zh:"\u9996\u671F\u4ED8\u6B3E\u6298\u6263",en:"A discount on the first payment"},"popup-coupon-loyalty-receipt":{discount:"$8",zh:"\u8001\u5BA2\u6237\u8BA2\u9605\u793C\u9047",en:"A subscription offer for returning customers"},"popup-coupon-upgrade-sheet":{discount:"20%",zh:"\u4E86\u89E3\u8BA2\u9605\u4F18\u60E0",en:"Explore a subscription offer"},"popup-coupon-return-sheet":{discount:"$5",zh:"\u56DE\u5F52\u8BA2\u9605\u4F18\u60E0",en:"A returning subscriber offer"},"popup-coupon-minimal-number":{discount:"20%",zh:"\u9996\u671F\u8BA2\u9605\u51CF\u514D",en:"Off the first subscription payment"},"popup-coupon-bold-number":{discount:"50%",zh:"\u6D3B\u52A8\u8BA2\u9605\u6298\u6263",en:"A campaign subscription discount"},"popup-coupon-studio-editorial":{discount:"25%",zh:"\u4E13\u4E1A\u8BA2\u9605\u65B9\u6848\u4F18\u60E0",en:"An offer on a professional subscription"},"popup-coupon-autumn-editorial":{discount:"30%",zh:"\u79CB\u5B63\u8BA2\u9605\u6D3B\u52A8",en:"An autumn subscription campaign"},"popup-coupon-vip-pass":{discount:"20%",zh:"\u4F1A\u5458\u8BA2\u9605\u793C\u9047",en:"A membership subscription offer"},"popup-coupon-beta-pass":{discount:"35%",zh:"\u65E9\u671F\u4F53\u9A8C\u8005\u4F18\u60E0",en:"An offer for early adopters"},"popup-coupon-welcome-stamp":{discount:"20%",zh:"\u9996\u6B21\u8BA2\u9605\u793C\u9047",en:"A first subscription offer"},"popup-coupon-milestone-stamp":{discount:"$5",zh:"\u7EE7\u7EED\u524D\u884C\u7684\u8BA2\u9605\u4F18\u60E0",en:"A subscription offer for your next step"},"popup-coupon-quiet-frame":{discount:"15%",zh:"\u4E13\u6CE8\u5DE5\u4F5C\u6D41\u8BA2\u9605\u4F18\u60E0",en:"An offer for a focused workflow"},"popup-coupon-premium-frame":{discount:"25%",zh:"\u7CBE\u9009\u4F1A\u5458\u65B9\u6848\u793C\u9047",en:"An offer on selected membership plans"},"popup-coupon-starter-steps":{discount:"20%",zh:"\u4E86\u89E3\u4F18\u60E0\uFF0C\u9886\u53D6\u540E\u9009\u5957\u9910",en:"Explore the offer, then choose your plan"},"popup-coupon-comeback-steps":{discount:"$5",zh:"\u4E3A\u56DE\u5F52\u51C6\u5907\u7684\u8BA2\u9605\u4F18\u60E0",en:"A subscription offer for your return"},"popup-coupon-spring-banner":{discount:"20%",zh:"\u6625\u5B63\u8BA2\u9605\u793C\u9047",en:"A spring subscription offer"},"popup-coupon-year-banner":{discount:"30%",zh:"\u65B0\u5E74\u4F1A\u5458\u8BA2\u9605\u4F18\u60E0",en:"A new-year membership offer"},"popup-coupon-mono-card":{discount:"20%",zh:"\u4E13\u4E1A\u5DE5\u5177\u8BA2\u9605\u4F18\u60E0",en:"An offer on professional tools"},"popup-coupon-night-card":{discount:"$5",zh:"\u521B\u4F5C\u5DE5\u5177\u8BA2\u9605\u4F18\u60E0",en:"An offer on creative tools"},"popup-coupon-spotlight-panel":{discount:"30%",zh:"\u4E13\u4E1A\u7248\u8BA2\u9605\u6D3B\u52A8",en:"A professional subscription campaign"},"popup-coupon-summer-panel":{discount:"25%",zh:"\u590F\u5B63\u8BA2\u9605\u4F18\u60E0",en:"A summer subscription offer"}};var cn={"popup-coupon-welcome-ticket":{n5:"offer.discount",n6:"offer.headline",n14:"offer.terms"},"popup-coupon-return-ticket":{n8:"offer.discount",n9:"offer.headline",n12:"offer.terms"},"popup-coupon-launch-poster":{n6:"offer.discount",n10:"offer.terms"},"popup-coupon-friday-poster":{n5:"offer.discount",n8:"offer.headline",n10:"offer.terms"},"popup-coupon-studio-split":{n5:"offer.discount",n6:"offer.headline",n8:"offer.terms"},"popup-coupon-team-split":{n8:"offer.headline",n10:"offer.discount",n14:"offer.terms"},"popup-coupon-member-letter":{n5:"offer.headline",n6:"offer.discount",n8:"offer.terms"},"popup-coupon-founder-letter":{n8:"offer.discount",n14:"offer.terms"},"popup-coupon-gift-box":{n6:"offer.terms",n12:"offer.discount",n13:"offer.headline",n15:"offer.terms"},"popup-coupon-birthday-box":{n4:"offer.discount",n5:"offer.headline",n8:"offer.terms"},"popup-coupon-first-receipt":{n6:"offer.discount",n8:"offer.headline",n12:"offer.terms"},"popup-coupon-loyalty-receipt":{n4:"offer.discount",n5:"offer.headline",n9:"offer.terms"},"popup-coupon-upgrade-sheet":{n4:"offer.headline",n6:"offer.discount",n10:"offer.terms"},"popup-coupon-return-sheet":{n4:"offer.headline",n6:"offer.discount",n10:"offer.terms"},"popup-coupon-minimal-number":{n5:"offer.discount",n7:"offer.headline",n11:"offer.terms"},"popup-coupon-bold-number":{n3:"offer.discount",n6:"offer.headline",n8:"offer.terms"},"popup-coupon-studio-editorial":{n7:"offer.headline",n9:"offer.discount",n12:"offer.terms"},"popup-coupon-autumn-editorial":{n5:"offer.discount",n6:"offer.headline",n9:"offer.terms"},"popup-coupon-vip-pass":{n6:"offer.discount",n7:"offer.headline",n14:"offer.terms"},"popup-coupon-beta-pass":{n5:"offer.discount",n6:"offer.headline",n12:"offer.terms"},"popup-coupon-welcome-stamp":{n5:"offer.headline",n6:"offer.discount",n8:"offer.terms"},"popup-coupon-milestone-stamp":{n4:"offer.discount",n5:"offer.headline",n8:"offer.terms"},"popup-coupon-quiet-frame":{n4:"offer.headline",n5:"offer.discount",n7:"offer.terms"},"popup-coupon-premium-frame":{n5:"offer.discount",n6:"offer.headline",n8:"offer.terms"},"popup-coupon-starter-steps":{n6:"offer.terms",n12:"offer.discount",n13:"offer.headline",n17:"offer.terms"},"popup-coupon-comeback-steps":{n6:"offer.discount",n7:"offer.headline",n9:"offer.terms"},"popup-coupon-spring-banner":{n6:"offer.discount",n7:"offer.headline",n10:"offer.terms"},"popup-coupon-year-banner":{n5:"offer.discount",n6:"offer.headline",n11:"offer.terms"},"popup-coupon-mono-card":{n7:"offer.headline",n9:"offer.discount",n14:"offer.terms"},"popup-coupon-night-card":{n6:"offer.discount",n7:"offer.headline",n10:"offer.terms"},"popup-coupon-spotlight-panel":{n3:"offer.discount",n4:"offer.headline",n10:"offer.terms"},"popup-coupon-summer-panel":{n3:"offer.discount",n4:"offer.headline",n10:"offer.terms"}};function un(e){return e.actions.map(t=>t.properties.templateKey).find(t=>typeof t=="string"&&t.startsWith("popup-coupon-"))}function Zo(e,t){let n=un(e),r=n?cn[n]:void 0;if(!r)return e;let c=[...new Set(e.actions.flatMap(o=>o.type==="claim_offer"?[o.couponId]:[]))],i=t??(c.length===1?c[0]:void 0),s=Object.fromEntries(Object.entries(e.strings.locales).map(([o,j])=>[o,{...j}])),d=o=>{if(o.type==="stack")return{...o,children:o.children.map(d)};if(o.type!=="text"||!r[o.text])return o;let j=r[o.text],w=o.fallback??`${o.text}_fallback`;for(let[I,_]of Object.entries(s))_[o.text]=`{{${j}}}`,_[w]??=j==="offer.discount"?"\u2014":I.startsWith("zh")?"\u67E5\u770B\u5F53\u524D\u4F18\u60E0":"View available offer";return{...o,name:j,fallback:w}},v=o=>{if(!i)return{};let j={...o.root.bind,coupon:i};return o.root.bind?.coupon!==i&&delete j.promotionCode,{bind:j}};return{...e,strings:{...e.strings,locales:s},pages:e.pages.map(o=>({...o,root:{...o.root,...v(o),children:o.root.children.map(d)}})),actions:t?e.actions.map(o=>o.properties.templateKey===n&&o.type!=="navigate"&&o.type!=="close"?{id:o.id,type:"claim_offer",couponId:t,event:"offer.claimed",properties:o.properties,close:o.close}:o):e.actions}}function Ko(e){let t=un(e),n=t?sn[t]:void 0;return!n||e.actions.some(r=>r.type==="claim_offer")?e:{...e,strings:{...e.strings,locales:Object.fromEntries(Object.entries(e.strings.locales).map(([r,c])=>[r,Object.fromEntries(Object.entries(c).map(([i,s])=>[i,s.replaceAll("{{offer.discount}}",n.discount).replaceAll("{{offer.headline}}",r.startsWith("zh")?n.zh:n.en).replaceAll("{{offer.terms}}",r.startsWith("zh")?"\u6F14\u793A\u91D1\u989D \xB7 \u7ED1\u5B9A\u4F18\u60E0\u5238\u540E\u81EA\u52A8\u663E\u793A\u771F\u5B9E\u6761\u6B3E":"Demo amount \xB7 Bind a coupon to show actual terms")]))]))}}}function Yo(e,t,n,r,c){if(!e.funnel||t.pages.length!==1||t.funnel||!["page","paywall"].includes(t.surface))throw new Error("\u8BF7\u9009\u62E9\u5DF2\u53D1\u5E03\u7684\u72EC\u7ACB\u9875\u9762\u6216\u5355\u9875\u4ED8\u8D39\u5899\u3002");let i=new Set,s=e.pages.find(b=>b.id===c);if(s&&!s.source)throw new Error("\u9875\u9762\u6807\u8BC6\u5DF2\u5B58\u5728\u3002");let d=b=>{if(Array.isArray(b))b.forEach(d);else if(b&&typeof b=="object"){let R=b;typeof R.id=="string"&&i.add(R.id),Object.values(R).forEach(d)}};d(t.pages),t.actions.forEach(b=>i.add(b.id)),Object.values(t.strings.locales).forEach(b=>Object.keys(b).forEach(R=>i.add(R)));let v=Math.max(-1,...Object.values(s?.source?.map??{}).map(b=>Number(b.match(/_k(\d+)$/)?.[1]??-1)))+1,o=Object.fromEntries([...i].map(b=>[b,s?.source?.map[b]??`${c}_k${v++}`]));o[t.pages[0].id]=c;let j=(b,R="")=>typeof b=="string"?["id","text","alt","label","action","fallback","expired","picker","target"].includes(R)&&Object.hasOwn(o,b)?o[b]:b.replace(/\bdata-grow-action\s*=\s*(["'])([a-zA-Z][a-zA-Z0-9_.-]{0,63})\1/gi,(Z,Q,le)=>Object.hasOwn(o,le)?`data-grow-action=${Q}${o[le]}${Q}`:Z):Array.isArray(b)?b.map(Z=>j(Z)):b&&typeof b=="object"?Object.fromEntries(Object.entries(b).map(([Z,Q])=>[Z,j(Q,Z)])):b,w=j(t.pages[0].root),I=structuredClone(e.strings.locales),_=new Set(Object.values(s?.source?.map??{}));Object.values(I).forEach(b=>_.forEach(R=>delete b[R]));for(let[b,R]of Object.entries(I)){let Z=t.strings.locales[b]??t.strings.locales[t.strings.defaultLocale];for(let[Q,le]of Object.entries(Z))R[o[Q]]=le}let q=t.actions.map(b=>({id:o[b.id],type:"navigate",target:c,event:b.event,properties:b.properties,close:!1})),f={id:c,name:t.name.slice(0,60),root:w,theme:t.theme,source:{campaignId:n,versionId:r,map:o,strings:t.strings},...s?.editorPosition?{editorPosition:s.editorPosition}:{}},T=e.actions.filter(b=>!_.has(b.id)),B=new Set([...T,...q].map(b=>b.id));return V.parse({...e,funnel:{...e.funnel,routes:e.funnel.routes.filter(b=>B.has(b.action))},pages:s?e.pages.map(b=>b.id===c?f:b):[...e.pages,f],actions:[...T,...q],strings:{...e.strings,locales:I}})}import{z as m}from"zod";var Ze=m.array(m.string().trim().min(1).max(40)).max(20).refine(e=>new Set(e).size===e.length),pn=m.iso.datetime({offset:!0}).nullable(),jr=m.object({enabled:m.boolean(),tagsAll:Ze,tagsAny:Ze,tagsNone:Ze,countries:m.array(m.string().regex(/^[A-Z]{2}$/)).max(40).refine(e=>new Set(e).size===e.length),subscription:m.enum(["any","none","active","trialing","ended"]),ageMinDays:m.number().int().min(0).max(36500).nullable(),ageMaxDays:m.number().int().min(0).max(36500).nullable(),attributes:m.array(m.object({key:m.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,49}$/),value:m.union([m.string().max(200),m.number().finite(),m.boolean()])}).strict()).max(10).refine(e=>new Set(e.map(t=>t.key)).size===e.length),startsAt:pn,endsAt:pn}).strict().superRefine((e,t)=>{e.ageMinDays!==null&&e.ageMaxDays!==null&&e.ageMinDays>e.ageMaxDays&&t.addIssue({code:"custom",path:["ageMaxDays"],message:"Minimum age exceeds maximum age"}),e.startsAt&&e.endsAt&&Date.parse(e.startsAt)>=Date.parse(e.endsAt)&&t.addIssue({code:"custom",path:["endsAt"],message:"Start must precede end"}),e.tagsNone.some(n=>e.tagsAll.includes(n))&&t.addIssue({code:"custom",path:["tagsNone"],message:"Required tag is excluded"})}),Xo={enabled:!1,tagsAll:[],tagsAny:[],tagsNone:[],countries:[],subscription:"any",ageMinDays:null,ageMaxDays:null,attributes:[],startsAt:null,endsAt:null},ea=m.object({campaign_id:m.uuid(),revision:m.number().int().min(1),audience_id:m.uuid().nullable(),enabled:m.boolean()}),ta=m.object({matches:m.boolean(),revision:m.number().int().nullable(),reasons:m.array(m.enum(["before_start","after_end","customer_required","tags_all","tags_any","tags_none","country","subscription","age","attributes","audience_unavailable"])),audienceId:m.uuid().nullable().optional(),audienceRevision:m.number().int().nullable().optional()}),na=m.object({campaignId:m.uuid(),revision:m.number().int().min(0),audienceId:m.uuid().nullable(),enabled:m.boolean()}).strict().refine(e=>!e.enabled||e.audienceId!==null),ln=jr.refine(e=>e.enabled,"Audience conditions must remain enabled"),ra=m.object({id:m.uuid(),name:m.string().min(1).max(80),description:m.string().max(500),config:ln,revision:m.number().int().min(1),status:m.enum(["active","archived"]),created_at:m.iso.datetime({offset:!0}),updated_at:m.iso.datetime({offset:!0})}),ia=m.discriminatedUnion("action",[m.object({action:m.literal("save"),id:m.uuid().nullable(),revision:m.number().int().min(0),name:m.string().trim().min(1).max(80),description:m.string().trim().max(500),config:ln}).strict(),m.object({action:m.literal("archive"),id:m.uuid(),revision:m.number().int().min(1)}).strict()]),wr=m.object({id:m.uuid(),name:m.string().nullable(),external_user_id:m.string(),tags:m.string().array(),created_at:m.iso.datetime({offset:!0})}),oa=m.object({customers:wr.array(),hasMore:m.boolean(),offset:m.number().int().min(0),limit:m.number().int().min(1),evaluatedAt:m.iso.datetime({offset:!0}),revision:m.number().int().min(1)}),aa=m.object({campaignId:m.uuid(),experimentId:m.uuid(),revision:m.number().int().min(1),variantId:m.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/)}).strict();import{z as pe}from"zod";var pa=pe.object({defaultLocale:E,locales:pe.record(E,pe.object({name:pe.string().max(80),description:pe.string().max(500)}).strict())}).strict().superRefine((e,t)=>{let n=Object.keys(e.locales);(!n.length||n.length>20||!e.locales[e.defaultLocale])&&t.addIssue({code:"custom",message:"Invalid content languages"}),new TextEncoder().encode(JSON.stringify(e)).length>5e4&&t.addIssue({code:"custom",message:"Content exceeds 50 KB"})});function la(e,t){let n=e.displayCopy;if(!n)return{name:e.name,description:""};let r=Object.keys(n.locales).filter(d=>n.locales[d].name.trim()),c=he([t],r,n.defaultLocale),i=n.locales[c],s=n.locales[n.defaultLocale];return{name:i?.name.trim()?i.name:s?.name.trim()?s.name:e.name,description:i?.description.trim()?i.description:s?.description.trim()?s.description:""}}export{ke as a,M as b,dn as c,mn as d,fn as e,gn as f,Or as g,_r as h,Tr as i,ve as j,Ie as k,Ke as l,je as m,We as n,Ge as o,hn as p,Ye as q,Je as r,F as s,U as t,bn as u,Xe as v,yn as w,xn as x,et as y,tt as z,Fr as A,nt as B,Sn as C,de as D,G as E,we as F,rt as G,Ae as H,it as I,ot as J,at as K,st as L,ee as M,qr as N,ct as O,ut as P,pt as Q,Ce as R,Hr as S,lt as T,Br as U,dt as V,kn as W,mt as X,Zr as Y,Kr as Z,vn as _,ze as $,Pe as aa,Wr as ba,Gr as ca,In as da,ft as ea,Qr as fa,jn as ga,ht as ha,gt as ia,me as ja,fe as ka,ge as la,ti as ma,ni as na,bt as oa,yt as pa,xt as qa,St as ra,ai as sa,It as ta,jt as ua,Oe as va,wt as wa,oe as xa,At as ya,wn as za,An as Aa,$e as Ba,Ct as Ca,zt as Da,Pt as Ea,ui as Fa,E as Ga,J as Ha,he as Ia,Pn as Ja,di as Ka,gi as La,On as Ma,_n as Na,$t as Oa,xi as Pa,Dt as Qa,Nt as Ra,Rt as Sa,$n as Ta,Si as Ua,ki as Va,vi as Wa,Ii as Xa,ji as Ya,wi as Za,Ai as _a,Ci as $a,zi as ab,Fe as bb,Ft as cb,qe as db,qt as eb,_i as fb,Et as gb,Di as hb,Le as ib,Rn as jb,Ni as kb,Vt as lb,Ee as mb,Fn as nb,L as ob,ae as pb,N as qb,qn as rb,En as sb,Mi as tb,Ve as ub,Mt as vb,se as wb,Ut as xb,Ln as yb,Vn as zb,Zt as Ab,Mn as Bb,Un as Cb,Hn as Db,Bn as Eb,Zn as Fb,ne as Gb,Kn as Hb,Wn as Ib,Gn as Jb,Yn as Kb,Jn as Lb,Qn as Mb,Xn as Nb,er as Ob,tr as Pb,nr as Qb,rr as Rb,Kt as Sb,ir as Tb,ar as Ub,Ht as Vb,Ue as Wb,Wt as Xb,Ui as Yb,sr as Zb,Hi as _b,re as $b,Bi as ac,V as bc,ce as cc,He as dc,ur as ec,Gt as fc,Zi as gc,dr as hc,Ki as ic,Wi as jc,mr as kc,Me as lc,Gi as mc,Yi as nc,no as oc,Jt as pc,Qt as qc,Xt as rc,fr as sc,ho as tc,P as uc,gr as vc,hr as wc,br as xc,yr as yc,xr as zc,Sr as Ac,kr as Bc,vr as Cc,bo as Dc,yo as Ec,on as Fc,nn as Gc,xe as Hc,So as Ic,jo as Jc,zo as Kc,Po as Lc,Oo as Mc,Do as Nc,Ir as Oc,No as Pc,Ro as Qc,Fo as Rc,Lo as Sc,un as Tc,Zo as Uc,Ko as Vc,Yo as Wc,jr as Xc,Xo as Yc,ea as Zc,ta as _c,na as $c,ln as ad,ra as bd,ia as cd,wr as dd,oa as ed,aa as fd,pa as gd,la as hd};
|