@tinkerlandai/indiana-sdk 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { OpenRouter } from '@openrouter/sdk';
2
2
  import { ChatUsage } from '@openrouter/sdk/models';
3
- import { c as createAiPricing, F as FoundationApi, a as AiUsageContext, b as AiTokenUsage, d as AiTokenQuote } from './ai-usage-D_mBF5Gp.js';
3
+ import { c as createAiPricing, F as FoundationApi, a as AiUsageContext, b as AiTokenUsage, d as AiTokenQuote } from './ai-usage-D9xVKhvu.js';
4
4
  import '@ai-sdk/provider';
5
5
  import './screen-Keau_Qa2.js';
6
6
  import 'zod';
@@ -1 +1 @@
1
- import{a as i}from"./chunk-CRJJ4EA2.js";import"./chunk-D37O6FAW.js";import"./chunk-MJG7X7LM.js";import{z as R}from"zod";var c=R.number().int().min(0).max(1e9);function k(e,o){let a=c.parse(e.promptTokens),p=c.parse(e.completionTokens),s=c.parse(e.promptTokensDetails?.cachedTokens??0),t=c.parse(e.promptTokensDetails?.cacheWriteTokens??0),r=c.parse(e.promptTokensDetails?.audioTokens??0),l=c.parse(e.completionTokensDetails?.audioTokens??0),n=c.parse(e.completionTokensDetails?.reasoningTokens??0);if(c.parse(e.totalTokens)!==a+p||s+t+r>a||n+l>p||(e.promptTokensDetails?.videoTokens??0)>0)throw new i("AI_USAGE_UNAVAILABLE","Token pools must conserve usage; video needs an explicit token mapper");return{input:a-s-t-r,output:p-l-(o==="separate"?n:0),cache_read:s,cache_write:t,input_audio:r,output_audio:l,reasoning:o==="separate"?n:0}}function I(e){if(!Number.isFinite(e)||e<0)throw new i("AI_USAGE_UNAVAILABLE","Provider cost must be a nonnegative USD amount");let o=String(e),a=o.includes("e")?e.toFixed(18).replace(/0+$/,"").replace(/\.$/,""):o;if(!/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/.test(a)||Number(a)!==e)throw new i("AI_USAGE_UNAVAILABLE","Provider cost exceeds the supported precision");return a}async function h(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning)||!e.modelId||!e.generationId)throw new i("INVALID_REQUEST","Actual model, generation ID and reasoning pricing are required");let o={context:e.context,generationId:e.generationId,modelId:`openrouter/${e.modelId}`,usage:e.usage,tokens:null,quote:null,receipt:null,phase:"captured"};await e.persist(o);let a=e.mapTokens?e.mapTokens(e.usage):k(e.usage,e.reasoning),p=e.usage.cost==null?void 0:I(e.usage.cost),s=e.quote??await e.pricing.quoteTokens({modelId:o.modelId,tokens:a});if(s.pricing.modelId!==o.modelId||Object.keys(a).some(l=>a[l]!==s.tokens[l]))throw new i("INVALID_REQUEST","Saved quote must match the provider model and token pools");await e.persist({...o,tokens:a,quote:s,phase:"quoted"});let t=await e.pricing.trackTokens(e.client,{...e.context,quote:s,providerCostUsd:p,generationId:e.generationId});if(!t.receipt.accepted)throw new i("AI_BALANCE_REJECTED","OpenRouter usage was saved but the balance request was rejected");let r={...o,tokens:a,quote:s,receipt:t,phase:"settled"};return await e.persist(r),r}function T(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning))throw new i("INVALID_REQUEST","Reasoning pricing is required");let o=e.openRouter.chat;async function a(t){if(!t.usage||!t.modelId||!t.generationId)throw new i("AI_USAGE_UNAVAILABLE","OpenRouter did not return final usage and the actual model");await h({...e,context:t.context,generationId:t.generationId,modelId:t.modelId.slice(11),usage:t.usage})}let p=async(t,r)=>{let n={context:await e.context(),generationId:null,modelId:null,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"},d;try{d=await o.send(t,r)}catch(g){throw await e.persist(n),g}if(!(d instanceof ReadableStream)){if(n={...n,generationId:d.id,modelId:d.model?`openrouter/${d.model}`:null,usage:d.usage??null},!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter omitted final accounting");return await a(n),d}let w=d.getReader(),m=!1;return new ReadableStream({async pull(g){try{let{value:u,done:A}=await w.read();if(A){if(m=!0,!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter stream ended without final accounting");await a(n),g.close();return}if(u.error)throw new i("AI_PROVIDER_ERROR",u.error.message);u.usage&&(n={...n,generationId:u.id,modelId:u.model?`openrouter/${u.model}`:null,usage:u.usage}),g.enqueue(u)}catch(u){m||(m=!0,await e.persist(n)),await w.cancel(u),g.error(u)}},async cancel(g){m||(m=!0,await e.persist(n)),await w.cancel(g)}})},s=new Proxy(o,{get(t,r){return r==="send"?p:Reflect.get(t,r,t)}});return new Proxy(e.openRouter,{get(t,r){return r==="chat"?s:Reflect.get(t,r,t)}})}export{T as createOpenRouterUsageClient,h as trackOpenRouterUsage};
1
+ import{a as i}from"./chunk-LFNFVYC2.js";import"./chunk-PVJKOUNE.js";import"./chunk-TZ6REIUE.js";import{z as R}from"zod";var c=R.number().int().min(0).max(1e9);function k(e,o){let a=c.parse(e.promptTokens),p=c.parse(e.completionTokens),s=c.parse(e.promptTokensDetails?.cachedTokens??0),t=c.parse(e.promptTokensDetails?.cacheWriteTokens??0),r=c.parse(e.promptTokensDetails?.audioTokens??0),l=c.parse(e.completionTokensDetails?.audioTokens??0),n=c.parse(e.completionTokensDetails?.reasoningTokens??0);if(c.parse(e.totalTokens)!==a+p||s+t+r>a||n+l>p||(e.promptTokensDetails?.videoTokens??0)>0)throw new i("AI_USAGE_UNAVAILABLE","Token pools must conserve usage; video needs an explicit token mapper");return{input:a-s-t-r,output:p-l-(o==="separate"?n:0),cache_read:s,cache_write:t,input_audio:r,output_audio:l,reasoning:o==="separate"?n:0}}function I(e){if(!Number.isFinite(e)||e<0)throw new i("AI_USAGE_UNAVAILABLE","Provider cost must be a nonnegative USD amount");let o=String(e),a=o.includes("e")?e.toFixed(18).replace(/0+$/,"").replace(/\.$/,""):o;if(!/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/.test(a)||Number(a)!==e)throw new i("AI_USAGE_UNAVAILABLE","Provider cost exceeds the supported precision");return a}async function h(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning)||!e.modelId||!e.generationId)throw new i("INVALID_REQUEST","Actual model, generation ID and reasoning pricing are required");let o={context:e.context,generationId:e.generationId,modelId:`openrouter/${e.modelId}`,usage:e.usage,tokens:null,quote:null,receipt:null,phase:"captured"};await e.persist(o);let a=e.mapTokens?e.mapTokens(e.usage):k(e.usage,e.reasoning),p=e.usage.cost==null?void 0:I(e.usage.cost),s=e.quote??await e.pricing.quoteTokens({modelId:o.modelId,tokens:a});if(s.pricing.modelId!==o.modelId||Object.keys(a).some(l=>a[l]!==s.tokens[l]))throw new i("INVALID_REQUEST","Saved quote must match the provider model and token pools");await e.persist({...o,tokens:a,quote:s,phase:"quoted"});let t=await e.pricing.trackTokens(e.client,{...e.context,quote:s,providerCostUsd:p,generationId:e.generationId});if(!t.receipt.accepted)throw new i("AI_BALANCE_REJECTED","OpenRouter usage was saved but the balance request was rejected");let r={...o,tokens:a,quote:s,receipt:t,phase:"settled"};return await e.persist(r),r}function T(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning))throw new i("INVALID_REQUEST","Reasoning pricing is required");let o=e.openRouter.chat;async function a(t){if(!t.usage||!t.modelId||!t.generationId)throw new i("AI_USAGE_UNAVAILABLE","OpenRouter did not return final usage and the actual model");await h({...e,context:t.context,generationId:t.generationId,modelId:t.modelId.slice(11),usage:t.usage})}let p=async(t,r)=>{let n={context:await e.context(),generationId:null,modelId:null,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"},d;try{d=await o.send(t,r)}catch(g){throw await e.persist(n),g}if(!(d instanceof ReadableStream)){if(n={...n,generationId:d.id,modelId:d.model?`openrouter/${d.model}`:null,usage:d.usage??null},!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter omitted final accounting");return await a(n),d}let w=d.getReader(),m=!1;return new ReadableStream({async pull(g){try{let{value:u,done:A}=await w.read();if(A){if(m=!0,!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter stream ended without final accounting");await a(n),g.close();return}if(u.error)throw new i("AI_PROVIDER_ERROR",u.error.message);u.usage&&(n={...n,generationId:u.id,modelId:u.model?`openrouter/${u.model}`:null,usage:u.usage}),g.enqueue(u)}catch(u){m||(m=!0,await e.persist(n)),await w.cancel(u),g.error(u)}},async cancel(g){m||(m=!0,await e.persist(n)),await w.cancel(g)}})},s=new Proxy(o,{get(t,r){return r==="send"?p:Reflect.get(t,r,t)}});return new Proxy(e.openRouter,{get(t,r){return r==="chat"?s:Reflect.get(t,r,t)}})}export{T as createOpenRouterUsageClient,h as trackOpenRouterUsage};
package/dist/page.d.ts CHANGED
@@ -4,6 +4,7 @@ import { z } from 'zod';
4
4
  /** GET /api/v1/page-experiments/{environmentId}: page experiments and the saved groups they reference only. */
5
5
  declare const pageExperimentPayloadSchema: z.ZodObject<{
6
6
  environmentId: z.ZodUUID;
7
+ trackExposures: z.ZodBoolean;
7
8
  generation: z.ZodString;
8
9
  experiments: z.ZodArray<z.ZodObject<{
9
10
  condition: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
package/dist/page.js CHANGED
@@ -1,4 +1 @@
1
- import{c as U,d as S,f as I}from"./chunk-MJG7X7LM.js";/*!
2
- Portions ported from GrowthBook sdk-js @ ed29827 (GrowthBook.ts auto experiments, util.ts mergeQueryStrings,
3
- plugins/auto-attributes.ts). Copyright (c) GrowthBook, Inc. MIT License.
4
- */function D(t,e){let a,n;try{a=new URL(t),n=new URL(e)}catch{return e}return a.searchParams.forEach((o,c)=>{n.searchParams.has(c)||n.searchParams.set(c,o)}),n.toString()}function G(t){let e=`${t}=`;for(let a of document.cookie.split(";")){let n=a.trim();if(n.startsWith(e))return decodeURIComponent(n.slice(e.length))}return""}function V(t){let e=G(t);return/^[A-Za-z0-9_-]{8,128}$/.test(e)||(e=crypto.randomUUID(),document.cookie=`${t}=${encodeURIComponent(e)}; path=/; max-age=${400*24*3600}; SameSite=Lax`),e}function _(){try{let t=sessionStorage.getItem("indiana_sid");return t||(t=crypto.randomUUID(),sessionStorage.setItem("indiana_sid",t)),t}catch{return}}function j(t,e){let a=navigator.userAgent,n=new URLSearchParams(e.search),o={};for(let c of["source","medium","campaign","term","content"]){let u=n.get(`utm_${c}`);u!==null&&(o[`utm${c[0].toUpperCase()}${c.slice(1)}`]=u)}return{id:t,deviceId:t,url:e.href,path:e.pathname,host:e.host,query:e.search,pageTitle:typeof document>"u"?"":document.title,browser:/Edg/.test(a)?"edge":/Chrome/.test(a)?"chrome":/Firefox/.test(a)?"firefox":/Safari/.test(a)?"safari":"unknown",deviceType:/Mobi/.test(a)?"mobile":"desktop",...o}}function J(t){let e=new URL(t),a=["localhost","127.0.0.1","[::1]"].includes(e.hostname);if(e.protocol!=="https:"&&!(e.protocol==="http:"&&a)||e.username||e.password||e.search||e.hash)throw new Error("baseUrl must be an https origin without credentials");return e.origin}function N(t){let e=t;if(!(!!e&&typeof e=="object"&&typeof e.environmentId=="string"&&/^[a-f0-9]{64}$/.test(e.generation??"")&&Array.isArray(e.experiments)&&e.experiments.length<=100&&e.experiments.every(n=>!!n&&!["namespace","status","url","groups"].some(o=>Object.hasOwn(n,o))&&(n.hashVersion===void 0||n.hashVersion===2)&&typeof n.key=="string"&&Array.isArray(n.variations)&&n.variations.length>=2&&n.variations.every(o=>!!o&&typeof o.urlRedirect=="string")&&(n.urlPatterns===void 0||Array.isArray(n.urlPatterns)))&&!!e.savedGroups&&typeof e.savedGroups=="object"&&!Array.isArray(e.savedGroups)))throw new Error("Invalid page experiment payload");return e}function M(t){let e=J(t.baseUrl);if(!/^[0-9a-f-]{36}$/i.test(t.environmentId))throw new Error("environmentId must be the App environment ID");let a=t.fetch??globalThis.fetch.bind(globalThis),n=`${e}/api/v1/page-experiments/${t.environmentId}`,o=V(t.deviceIdCookie??"indiana_did"),c=_(),u=null,R={...t.attributes??{}},d="",x=!1,w=new Map,P=[],p;function L(r){return r.length?a(`${n}/events`,{method:"POST",body:JSON.stringify({events:r}),headers:{"Content-Type":"text/plain"},keepalive:!0,credentials:"omit"}).then(()=>{}).catch(i=>t.log?.("Exposure not sent",{error:i})):Promise.resolve()}function m(){return clearTimeout(p),p=void 0,L(P.splice(0,20))}let g={trackedExperiments:new Set,log:t.log,onExperimentViewed:(r,i)=>{t.trackExposures!==!1&&(P.push({eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),deviceId:o,...c?{sessionId:c}:{},url:location.href,pageTitle:document.title.slice(0,512),experimentKey:r.key,variationKey:i.key}),p||(p=setTimeout(()=>{m()},1e3)))}},T=()=>{g.url=location.href,g.attributes={...j(o,location),...R}};function A(r){if(!t.disableCrossOriginUrlRedirects)return!1;try{let i=new URL(location.href);return r.variations.some(s=>{if(!s.urlRedirect)return!1;let v=new URL(s.urlRedirect);return v.protocol!==i.protocol||v.host!==i.host})}catch{return!0}}function C(r,i){d=r;let s=t.navigate??(l=>location.replace(l)),v=t.navigateDelay??(t.navigate?0:100),O=t.maxNavigateDelay??1e3;Promise.all([Promise.race([i,new Promise(l=>setTimeout(l,O))]),new Promise(l=>setTimeout(l,v))]).then(()=>{x||s(r)})}function h(){if(!(!u||x)){T();for(let r of u.experiments){if(A(r)){t.log?.("Auto experiment blocked",{id:r.key});continue}let i;try{i=I(r,g)}catch(s){t.log?.("Skipping page experiment",{id:r.key,error:String(s)});continue}if(w.set(r.key,i),!!i.inExperiment){if(i.value.urlRedirect){let s=r.persistQueryString?D(location.href,i.value.urlRedirect):i.value.urlRedirect;U(s,r.urlPatterns??[])?t.log?.("Skipping redirect because original URL matches redirect URL",{id:r.key}):s!==d&&C(s,m())}break}}}}let E="",f=()=>{location.href!==E&&(E=location.href,d="",h())},y={push:history.pushState,replace:history.replaceState};function $(){history.pushState=function(...r){y.push.apply(this,r),f()},history.replaceState=function(...r){y.replace.apply(this,r),f()},addEventListener("popstate",f),addEventListener("pagehide",b)}let b=()=>{m()};async function k(){let r=await a(n,{cache:"no-cache",credentials:"omit"});if(!r.ok)throw new Error(`Page experiments unavailable (${r.status})`);let i=N(await r.json());if(i.environmentId.toLowerCase()!==t.environmentId.toLowerCase())throw new Error("Page experiment payload scope changed");u=i,g.savedGroups=S(i.savedGroups)}return{async start(){await k(),$(),E=location.href,h()},async refresh(){await k(),d="",h()},setAttributes(r){R={...r},h()},getResults(){return new Map(w)},get generation(){return u?.generation??null},destroy(){x=!0,history.pushState=y.push,history.replaceState=y.replace,removeEventListener("popstate",f),removeEventListener("pagehide",b),m()}}}export{M as createPageExperiments,D as mergeQueryStrings,j as pageAttributes,N as readPayload};
1
+ import{g as a,h as b,i as c,j as d}from"./chunk-2UFPTDCV.js";import"./chunk-TZ6REIUE.js";export{d as createPageExperiments,a as mergeQueryStrings,b as pageAttributes,c as readPayload};
@@ -1 +1 @@
1
- import{a as H}from"./chunk-6X42DWOM.js";import{a as m}from"./chunk-CRJJ4EA2.js";import{Ie as U,Vl as B,hf as V,y as M}from"./chunk-D37O6FAW.js";import"./chunk-MJG7X7LM.js";async function F(y,t,d){if(t.status!=="complete")throw new m("INVALID_RESPONSE","A verified completed purchase is required");if(await d.onComplete?.(t),!y||!d.check)return;let i=U.parse(await d.check());if(i.internal_feature_id!==y.internal_feature_id||i.quantity!==y.quantity)throw new m("INVALID_RESPONSE","The access requirement changed");i.allowed&&await d.onAccessGranted?.(i)}async function re(y,t){let d=t.check?U.parse(await t.check()):null;if(d?.allowed)return await t.onAccessGranted?.(d),{check:d,host:null};let i=await t.start(),p=i.view;if(!p)throw new m("INVALID_RESPONSE","Paywall presentation is missing");let{mountScreenPreview:j}=await import("./popup.js"),n=y.ownerDocument,R=new AbortController,v=n.createElement("section"),$=n.createElement("div"),I=n.createElement("div"),P=n.createElement("p"),E=n.createElement("button"),D=n.createElement("button"),f=n.createElement("dialog"),L=n.activeElement,w=p.document.screen.strings.defaultLocale.startsWith("zh");v.dataset.indianaPaywall="",v.setAttribute("aria-label",p.document.name),v.style.cssText="width:100%;box-sizing:border-box;background:#fff;color:#172033;font:14px/1.5 system-ui,sans-serif",I.style.cssText="display:flex;gap:12px;padding:12px 20px;align-items:center;flex-wrap:wrap",P.setAttribute("role","status"),D.textContent=w?"\u5173\u95ED":"Close",E.textContent=w?"\u91CD\u8BD5":"Retry",E.hidden=!0,I.append(P,E,D),v.append($,I);let N=p.document.presentation,g,u=!1,_=!1,l=null,T=!1,a=null,x=null,S=e=>{P.textContent=e instanceof Error?e.message:w?"\u8BF7\u6C42\u5931\u8D25":"Request failed",H(t.onError,e),E.hidden=a===null};async function b(e){if(!(_||u)){_=!0,E.hidden=!0,P.textContent="";try{await e()}catch(o){u||S(o)}finally{_=!1}}}async function W(e){await F(d,e,t)}async function O(e){if(u)return;if(P.textContent=e.status,e.status==="complete"){a=null,await W(e);return}if(e.status!=="pending"){a=null,l=null;return}let o=Date.now()+6e5,c=2e3;for(;!u&&Date.now()<o;){if(await new Promise(h=>{let A=()=>{clearTimeout(C),h()},C=setTimeout(()=>{R.signal.removeEventListener("abort",A),h()},c);R.signal.addEventListener("abort",A,{once:!0})}),u)return;let r=await i.read();if(r.status!=="pending"){await O(r);return}c=Math.min(c*1.5,3e4)}a=async()=>O(await i.read()),E.hidden=!1}async function z(){x?.remove(),x=null,a=z;let e=await i.confirm();if(e.status==="pending"){if(e.checkoutUrl)t.onCheckoutUrl?await t.onCheckoutUrl(e.checkoutUrl):n.defaultView?.location.assign(e.checkoutUrl);else if(e.execution||e.nativePurchase){if(!t.onPurchase)throw new m("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await t.onPurchase({operation:e,signal:R.signal})}}a=async()=>O(await i.read()),await O(e)}function J(e){x?.remove();let o=n.createElement("div"),c=n.createElement("button"),r=n.createElement("button"),h=n.createElement("p");h.textContent=e.lines.map(s=>s.productName).join(", ")+" \xB7 "+M(e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),e.currency),c.textContent=w?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",r.textContent=w?"\u53D6\u6D88":"Cancel",c.onclick=()=>{b(z)};let A=async()=>{await i.cancel(),!u&&(l=null,a=null,o.remove(),x=null)};r.onclick=()=>{a=A,b(A)};let C=n.createElement("div");for(let s of e.lines){let q=n.createElement("p");if(q.textContent=`${s.productName} \xB7 ${M(s.catalogAmountMinor,e.currency)}${B(s.interval,w?"zh-CN":"en",s.intervalCount??1)}`,C.append(q),s.trial){let G=n.createElement("p");G.textContent=w?`\u8BD5\u7528 ${s.trial.days} \u5929\uFF1B${s.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${s.trial.days}; ${s.trial.cardRequired?"a payment method is required":"no payment method is required"}`,C.append(G)}}if(!e.charge){let s=n.createElement("p");s.textContent=w?"\u76EE\u5F55\u4EF7\u683C\uFF1B\u6700\u7EC8\u91D1\u989D\u4EE5\u7ED3\u8D26\u65F6\u7A0E\u8D39\u548C\u8BD5\u7528\u89C4\u5219\u4E3A\u51C6\u3002":"Catalog price; the final charge depends on checkout taxes and trial terms.",C.append(s)}o.append(h,C,c,r),I.prepend(o),x=o,a=null}async function Q(){if(!l)return;if(a=Q,!T){let o=i.view,c=o?.document.buttons[l.actionId],r=o&&c?.type==="checkout"?V(c.product,l.selection,o.capabilities):null;if(!r)throw new m("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let h=await t.resolveOfferId?.({actionId:l.actionId,productVersionId:r});if(u)return;h!==void 0&&(l.offerId=h),T=!0}let e=await i.preview(l);u||J(e)}function k(e="destroy"){u||(u=!0,R.abort(),g?.destroy(),i.destroy(),f.open&&f.close(),f.remove(),v.remove(),L instanceof HTMLElement&&L.isConnected&&L.focus(),e==="dismiss"&&H(t.onDismiss))}D.onclick=()=>k("dismiss"),f.addEventListener("cancel",e=>{e.preventDefault(),k("dismiss")}),E.onclick=()=>{a&&b(a)};try{if(N.type==="inline")y.append(v);else{let e={sm:420,md:640,lg:900};f.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in N?e[N.size]+"px":"100vw"}`,f.setAttribute("aria-label",p.document.name),f.append(v),y.append(f),f.showModal()}g=j($,{mode:"live",rendererUrl:i.webViewUrl,title:p.document.name,onAction(e,o={}){let c=i.view,r=c?.document.buttons[e];if(r){if(r.type==="close"){b(async()=>{await t.onAction?.(e),k(t.onAction?"action":"dismiss")});return}if(r.type==="action"){a=async()=>{if(r.action.type==="event"){if(!t.onEvent)throw new m("EVENT_HANDLER_REQUIRED","Provide the event handler");await t.onEvent(r.action.event)}else t.onOpenUrl?await t.onOpenUrl(r.action.url):n.defaultView?.location.assign(r.action.url);await t.onAction?.(e),a=null},b(a);return}if(!c||!V(r.product,o,c.capabilities)){S(new m("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(l&&l.actionId!==e){S(new m("COMMAND_PENDING","Finish the current purchase"));return}l||(l={requestId:crypto.randomUUID(),actionId:e,selection:o},T=!1),b(Q)}},onEscape:()=>k("dismiss"),onError:e=>S(new Error(e))}),g.update(p.document.screen,p.document.screen.strings.defaultLocale,{capabilities:p.capabilities,serverInput:{bindings:[],answers:{}}}),await g.ready}catch(e){throw k(),e}return{check:d,host:{destroy:k,refresh:async()=>{let e=await i.refresh();return u||g?.updateCapabilities(e.capabilities),e}}}}export{re as showPaywall};
1
+ import{a as H}from"./chunk-6X42DWOM.js";import{a as m}from"./chunk-LFNFVYC2.js";import{$l as B,Ie as U,hf as V,y as M}from"./chunk-PVJKOUNE.js";import"./chunk-TZ6REIUE.js";async function F(y,t,d){if(t.status!=="complete")throw new m("INVALID_RESPONSE","A verified completed purchase is required");if(await d.onComplete?.(t),!y||!d.check)return;let i=U.parse(await d.check());if(i.internal_feature_id!==y.internal_feature_id||i.quantity!==y.quantity)throw new m("INVALID_RESPONSE","The access requirement changed");i.allowed&&await d.onAccessGranted?.(i)}async function re(y,t){let d=t.check?U.parse(await t.check()):null;if(d?.allowed)return await t.onAccessGranted?.(d),{check:d,host:null};let i=await t.start(),p=i.view;if(!p)throw new m("INVALID_RESPONSE","Paywall presentation is missing");let{mountScreenPreview:j}=await import("./popup.js"),n=y.ownerDocument,R=new AbortController,v=n.createElement("section"),$=n.createElement("div"),I=n.createElement("div"),P=n.createElement("p"),E=n.createElement("button"),D=n.createElement("button"),f=n.createElement("dialog"),L=n.activeElement,w=p.document.screen.strings.defaultLocale.startsWith("zh");v.dataset.indianaPaywall="",v.setAttribute("aria-label",p.document.name),v.style.cssText="width:100%;box-sizing:border-box;background:#fff;color:#172033;font:14px/1.5 system-ui,sans-serif",I.style.cssText="display:flex;gap:12px;padding:12px 20px;align-items:center;flex-wrap:wrap",P.setAttribute("role","status"),D.textContent=w?"\u5173\u95ED":"Close",E.textContent=w?"\u91CD\u8BD5":"Retry",E.hidden=!0,I.append(P,E,D),v.append($,I);let N=p.document.presentation,g,u=!1,_=!1,l=null,T=!1,a=null,x=null,S=e=>{P.textContent=e instanceof Error?e.message:w?"\u8BF7\u6C42\u5931\u8D25":"Request failed",H(t.onError,e),E.hidden=a===null};async function b(e){if(!(_||u)){_=!0,E.hidden=!0,P.textContent="";try{await e()}catch(o){u||S(o)}finally{_=!1}}}async function W(e){await F(d,e,t)}async function O(e){if(u)return;if(P.textContent=e.status,e.status==="complete"){a=null,await W(e);return}if(e.status!=="pending"){a=null,l=null;return}let o=Date.now()+6e5,c=2e3;for(;!u&&Date.now()<o;){if(await new Promise(h=>{let A=()=>{clearTimeout(C),h()},C=setTimeout(()=>{R.signal.removeEventListener("abort",A),h()},c);R.signal.addEventListener("abort",A,{once:!0})}),u)return;let r=await i.read();if(r.status!=="pending"){await O(r);return}c=Math.min(c*1.5,3e4)}a=async()=>O(await i.read()),E.hidden=!1}async function z(){x?.remove(),x=null,a=z;let e=await i.confirm();if(e.status==="pending"){if(e.checkoutUrl)t.onCheckoutUrl?await t.onCheckoutUrl(e.checkoutUrl):n.defaultView?.location.assign(e.checkoutUrl);else if(e.execution||e.nativePurchase){if(!t.onPurchase)throw new m("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await t.onPurchase({operation:e,signal:R.signal})}}a=async()=>O(await i.read()),await O(e)}function J(e){x?.remove();let o=n.createElement("div"),c=n.createElement("button"),r=n.createElement("button"),h=n.createElement("p");h.textContent=e.lines.map(s=>s.productName).join(", ")+" \xB7 "+M(e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),e.currency),c.textContent=w?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",r.textContent=w?"\u53D6\u6D88":"Cancel",c.onclick=()=>{b(z)};let A=async()=>{await i.cancel(),!u&&(l=null,a=null,o.remove(),x=null)};r.onclick=()=>{a=A,b(A)};let C=n.createElement("div");for(let s of e.lines){let q=n.createElement("p");if(q.textContent=`${s.productName} \xB7 ${M(s.catalogAmountMinor,e.currency)}${B(s.interval,w?"zh-CN":"en",s.intervalCount??1)}`,C.append(q),s.trial){let G=n.createElement("p");G.textContent=w?`\u8BD5\u7528 ${s.trial.days} \u5929\uFF1B${s.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${s.trial.days}; ${s.trial.cardRequired?"a payment method is required":"no payment method is required"}`,C.append(G)}}if(!e.charge){let s=n.createElement("p");s.textContent=w?"\u76EE\u5F55\u4EF7\u683C\uFF1B\u6700\u7EC8\u91D1\u989D\u4EE5\u7ED3\u8D26\u65F6\u7A0E\u8D39\u548C\u8BD5\u7528\u89C4\u5219\u4E3A\u51C6\u3002":"Catalog price; the final charge depends on checkout taxes and trial terms.",C.append(s)}o.append(h,C,c,r),I.prepend(o),x=o,a=null}async function Q(){if(!l)return;if(a=Q,!T){let o=i.view,c=o?.document.buttons[l.actionId],r=o&&c?.type==="checkout"?V(c.product,l.selection,o.capabilities):null;if(!r)throw new m("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let h=await t.resolveOfferId?.({actionId:l.actionId,productVersionId:r});if(u)return;h!==void 0&&(l.offerId=h),T=!0}let e=await i.preview(l);u||J(e)}function k(e="destroy"){u||(u=!0,R.abort(),g?.destroy(),i.destroy(),f.open&&f.close(),f.remove(),v.remove(),L instanceof HTMLElement&&L.isConnected&&L.focus(),e==="dismiss"&&H(t.onDismiss))}D.onclick=()=>k("dismiss"),f.addEventListener("cancel",e=>{e.preventDefault(),k("dismiss")}),E.onclick=()=>{a&&b(a)};try{if(N.type==="inline")y.append(v);else{let e={sm:420,md:640,lg:900};f.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in N?e[N.size]+"px":"100vw"}`,f.setAttribute("aria-label",p.document.name),f.append(v),y.append(f),f.showModal()}g=j($,{mode:"live",rendererUrl:i.webViewUrl,title:p.document.name,onAction(e,o={}){let c=i.view,r=c?.document.buttons[e];if(r){if(r.type==="close"){b(async()=>{await t.onAction?.(e),k(t.onAction?"action":"dismiss")});return}if(r.type==="action"){a=async()=>{if(r.action.type==="event"){if(!t.onEvent)throw new m("EVENT_HANDLER_REQUIRED","Provide the event handler");await t.onEvent(r.action.event)}else t.onOpenUrl?await t.onOpenUrl(r.action.url):n.defaultView?.location.assign(r.action.url);await t.onAction?.(e),a=null},b(a);return}if(!c||!V(r.product,o,c.capabilities)){S(new m("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(l&&l.actionId!==e){S(new m("COMMAND_PENDING","Finish the current purchase"));return}l||(l={requestId:crypto.randomUUID(),actionId:e,selection:o},T=!1),b(Q)}},onEscape:()=>k("dismiss"),onError:e=>S(new Error(e))}),g.update(p.document.screen,p.document.screen.strings.defaultLocale,{capabilities:p.capabilities,serverInput:{bindings:[],answers:{}}}),await g.ready}catch(e){throw k(),e}return{check:d,host:{destroy:k,refresh:async()=>{let e=await i.refresh();return u||g?.updateCapabilities(e.capabilities),e}}}}export{re as showPaywall};
package/dist/popup.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as V}from"./chunk-6X42DWOM.js";import{a as St}from"./chunk-CRJJ4EA2.js";import{Af as We,Ag as xe,Bg as bt,Cg as Ve,Ef as De,gj as xt,hj as vt,kj as kt,ng as yt,qg as $e,sf as mt,wi as wt,xf as Be,xg as qe,yf as ht,yg as Je}from"./chunk-D37O6FAW.js";import"./chunk-MJG7X7LM.js";function Et(c){let p=new Intl.Locale(c);if(p.language==="zh")return p.maximize().script==="Hant"?"\u95DC\u9589\u5F48\u7A97":"\u5173\u95ED\u5F39\u7A97";let A={en:"Close popup",ja:"\u30DD\u30C3\u30D7\u30A2\u30C3\u30D7\u3092\u9589\u3058\u308B",ko:"\uD31D\uC5C5 \uB2EB\uAE30",es:"Cerrar ventana emergente",fr:"Fermer la fen\xEAtre contextuelle",de:"Popup schlie\xDFen",pt:"Fechar janela pop-up",it:"Chiudi popup",ru:"\u0417\u0430\u043A\u0440\u044B\u0442\u044C \u0432\u0441\u043F\u043B\u044B\u0432\u0430\u044E\u0449\u0435\u0435 \u043E\u043A\u043D\u043E",vi:"\u0110\xF3ng c\u1EEDa s\u1ED5 b\u1EADt l\xEAn",th:"\u0E1B\u0E34\u0E14\u0E2B\u0E19\u0E49\u0E32\u0E15\u0E48\u0E32\u0E07\u0E1B\u0E4A\u0E2D\u0E1B\u0E2D\u0E31\u0E1B",id:"Tutup pop-up",ar:"\u0625\u063A\u0644\u0627\u0642 \u0627\u0644\u0646\u0627\u0641\u0630\u0629 \u0627\u0644\u0645\u0646\u0628\u062B\u0642\u0629",he:"\u05E1\u05D2\u05D9\u05E8\u05EA \u05D4\u05D7\u05DC\u05D5\u05DF \u05D4\u05E7\u05D5\u05E4\u05E5",fa:"\u0628\u0633\u062A\u0646 \u067E\u0646\u062C\u0631\u0647\u0654 \u0628\u0627\u0632\u0634\u0648",ur:"\u067E\u0627\u067E \u0627\u067E \u0628\u0646\u062F \u06A9\u0631\u06CC\u06BA"};return A[p.language]??A.en}import Jt from"dompurify";import{parse as Bt,generate as Wt,walk as qt}from"css-tree";function At(c){if(!c.trim())return"";if(/[\\<]/.test(c))throw new Error("CSS \u6682\u4E0D\u652F\u6301\u53CD\u659C\u6760\u8F6C\u4E49\u6216 HTML \u6807\u7B7E\u3002");let p=Bt(c,{onParseError:I=>{throw Object.assign(new Error("CSS \u683C\u5F0F\u4E0D\u6B63\u786E\u3002"),{offset:I.offset})}}),A=0;return qt(p,I=>{if(++A>5e3)throw new Error("CSS \u8FC7\u4E8E\u590D\u6742\u3002");if(I.type==="Raw"||I.type==="Url"||I.type==="Atrule"&&!["media","supports","keyframes"].includes(I.name.toLowerCase())||I.type==="Function"&&["image-set","-webkit-image-set","image","src","paint"].includes(I.name.toLowerCase()))throw new Error("CSS \u4E0D\u652F\u6301\u5916\u90E8\u8D44\u6E90\u3001\u5BFC\u5165\u6216\u672A\u77E5\u8BED\u6CD5\uFF1B\u56FE\u7247\u8BF7\u4F7F\u7528 HTML img \u6807\u7B7E\u3002")}),Wt(p)}import{parse as Vt,walk as Kt}from"css-tree";function Zt(c,p,A,I){return{html:ze(c,A,I),css:Ke(p)}}function Ke(c){return At(c)}function ze(c,p,A,I){if(!c.trim())return"";let y=We(c);if(y.length)throw new Error(y[0]);let T=Jt(A),C=T.sanitize(c,{ALLOWED_TAGS:["main","section","article","header","footer","div","span","p","h1","h2","h3","h4","strong","em","b","i","small","br","hr","ul","ol","li","button","img"],ALLOWED_ATTR:["class","alt","src","width","height","title","type","disabled","data-grow-action","aria-label"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1,ADD_URI_SAFE_ATTR:["data-grow-action"],ALLOWED_URI_REGEXP:/^https:\/\//i,RETURN_DOM:!0});if(!(C instanceof A.Element))throw new Error("\u65E0\u6CD5\u89E3\u6790 HTML\u3002");if(I){let b=new Set;for(let v of T.removed){let N="element"in v?v.element.nodeName.toLowerCase():void 0,H="attribute"in v?v.attribute?.name:void 0;if(!N&&!H)continue;let F=H?/<[^>]+>/g:new RegExp(`<\\s*${N}\\b[^>]*>`,"gi"),W=[...c.matchAll(F)].find($=>!b.has(`${H??N}:${$.index}`)&&(!H||new RegExp(`\\b${H}\\s*=`,"i").test($[0])));if(!W)continue;let x=W.index;b.add(`${H??N}:${x}`);let L=H==="style"?"\u5185\u8054\u6837\u5F0F\u4E0D\u4FDD\u7559\uFF0C\u8BF7\u5199\u5728 CSS \u4E2D\u3002":H?.startsWith("on")?"\u811A\u672C\u4E8B\u4EF6\u4E0D\u5141\u8BB8\uFF0C\u8BF7\u4F7F\u7528\u52A8\u4F5C\u6309\u94AE\u3002":H==="src"?"\u56FE\u7247\u53EA\u652F\u6301 https \u5730\u5740\u3002":"\u8FD9\u4E2A\u5C5E\u6027\u4E0D\u5728\u5141\u8BB8\u7684\u5E03\u5C40\u3001\u56FE\u7247\u4E0E\u52A8\u4F5C\u5C5E\u6027\u4E2D\u3002";I.push({language:"html",from:x,to:x+W[0].length,severity:"warning",message:H?`\u5DF2\u79FB\u9664\u5C5E\u6027 ${H}\uFF1A${L}`:`\u5DF2\u79FB\u9664 <${N}>\uFF1A\u8FD9\u4E2A\u6807\u7B7E\u4E0D\u5728\u5141\u8BB8\u7684\u6392\u7248\u6807\u7B7E\u4E2D\u3002`})}}let P=We(C.innerHTML);if(P.length)throw new Error(P[0]);if(C.querySelectorAll("*").length>500)throw new Error("HTML \u6700\u591A\u652F\u6301 500 \u4E2A\u5143\u7D20\u3002");for(let b of C.querySelectorAll("[data-grow-action]")){let v=b.getAttribute("data-grow-action");if(b.tagName!=="BUTTON"||!p.includes(v))throw new Error(`\u81EA\u5B9A\u4E49 HTML \u91CC\u7684\u6309\u94AE ${v.slice(0,64)} \u6CA1\u6709\u5BF9\u5E94\u7684\u52A8\u4F5C\uFF0C\u8BF7\u5148\u5728\u300C\u70B9\u51FB\u52A8\u4F5C\u300D\u91CC\u6DFB\u52A0\uFF0C\u5E76\u4F7F\u7528 button \u5143\u7D20\u3002`)}if(!C.textContent?.trim()&&!C.querySelector("img"))throw new Error("\u81EA\u5B9A\u4E49 HTML \u6E05\u6D17\u540E\u6CA1\u6709\u53EF\u663E\u793A\u7684\u5185\u5BB9\u3002");return C.innerHTML}var It=2e3,Lt=1e4,Dt=new WeakMap;function Nt(c,p,A){let I=A.document;if(!I)throw new Error("A content document is required");let y=Dt.get(A)??new Map;Dt.set(A,y);let T=(b,v)=>{let N=y.get(b);if(N!==void 0)return N;let H=v();y.set(b,H);let F=[...y.keys()].reduce((W,x)=>W+x.length,0);for(;y.size>64||F>256e3;){let W=y.keys().next().value;y.delete(W),F-=W.length}return H},C=b=>T(`html:${b}`,()=>{let v=I.createElement("div");return v.innerHTML=b,v.querySelectorAll("*").length}),P=b=>T(`css:${b}`,()=>{let v=0;return b.trim()&&Kt(Vt(b),()=>{v++}),v});for(let b of c.pages){let v=0,N=0,H=F=>{if(F.hidden||(F.type==="stack"&&F.children.forEach(H),F.type!=="custom_html"))return;let W=p?.nodes[F.id],x=[...Object.values(F.html),W?.base.html??"",...Object.values(W?.byPlan??{}).map(L=>L.html??"")];if(v+=Math.max(0,...x.map(C)),N+=P(F.css),v>It)throw new Error(`Page custom HTML exceeds ${It} elements`);if(N>Lt)throw new Error(`Page custom CSS exceeds ${Lt} syntax nodes`)};H(b.root)}}function Gt(c,p,A,I){let y=[],T="",C="";for(let P of["html","css"])try{P==="html"?T=ze(c,A,I,y):C=Ke(p)}catch(b){let v=P==="html"?c:p,N=P==="html"?/\{\{|data-grow-action/:/@import\b|url\s*\(|image-set\s*\(|[\\<]/i,H=b instanceof Error?b.message:"\u5185\u5BB9\u65E0\u6CD5\u89E3\u6790",F=P==="html"?H.match(/未知变量:(.+)/)?.[1]:void 0,W=F?v.indexOf(F):-1,x=typeof b=="object"&&b!==null&&"offset"in b&&typeof b.offset=="number"?b.offset:W>=0?v.lastIndexOf("{{",W):v.search(N);y.push({language:P,from:Math.max(0,x),to:Math.min(v.length,Math.max(0,x)+2),severity:"error",message:H})}return{html:T,css:C,diagnostics:y,valid:!y.some(P=>P.severity==="error")}}function Re(c,p,A){if(!c)return;let I={},y=p.actions.map(C=>C.id);for(let[C,P]of Object.entries(c.nodes)){let b=v=>{if(v.html===void 0)return v;if(xe(p,C)?.type!=="custom_html")throw new Error("HTML \u5546\u54C1\u6570\u636E\u53EA\u80FD\u7528\u4E8E\u81EA\u5B9A\u4E49 HTML \u7EC4\u4EF6");return{...v,html:ze(v.html,y,A)}};I[C]={...P,base:b(P.base),...P.byPlan?{byPlan:Object.fromEntries(Object.entries(P.byPlan).map(([v,N])=>[v,b(N)]))}:{}}}let T={...c,nodes:I};return Nt(p,T,A),T}var Rt=new WeakMap;function Ne(c,p){let A=$e.parse(c),I=JSON.stringify(A),y=Rt.get(p);y||(y=new Map,Rt.set(p,y));let T=Date.now();for(let[x,L]of y)L.expires<=T&&y.delete(x);let C=y.get(I);if(C)return y.delete(I),y.set(I,C),JSON.parse(C.json);let P=A.actions.map(x=>x.id),b=x=>{if(x.type==="stack")return{...x,children:x.children.map(b)};if(x.type!=="custom_html")return x;let L={};for(let[$,te]of Object.entries(x.html))L[$]=ze(te,P,p);return{...x,html:L,css:Ke(x.css)}},v={...A,pages:A.pages.map(x=>({...x,root:b(x.root)}))};Nt(v,void 0,p);let N=JSON.stringify(v),H=new TextEncoder,F=H.encode(N).length;if(F>De.documentBytes)throw new Error(`\u754C\u9762\u5185\u5BB9\u8FC7\u5927\uFF08\u4E0A\u9650 ${De.documentBytes/1e3} KB\uFF09\u3002`);let W=H.encode(I).length;if(W<=De.documentBytes){y.set(I,{json:N,bytes:W+F,expires:T+6e4});let x=[...y.values()].reduce((L,$)=>L+$.bytes,0);for(;y.size>16||x>2*1024*1024;){let[L,$]=y.entries().next().value;y.delete(L),x-=$.bytes}}return v}function Ze(c){function p(e){return e.type==="stack"&&e.interaction?.type==="select"&&e.interaction.purpose==="product"&&!!e.interaction.pickerId}function A(e){let a={};function t(r){if(p(r)){let i=a[r.interaction.pickerId]??={ids:[],defaultId:null};for(let n of r.children){let l=n.type==="stack"?n.bind?.plan:void 0;l&&!i.ids.includes(l)&&i.ids.push(l)}let s=r.children[r.interaction.defaultIndex];!i.defaultId&&s?.type==="stack"&&(i.defaultId=s.bind?.plan??null)}r.type==="stack"&&r.children.forEach(t)}return e.pages.forEach(r=>t(r.root)),a}function I(e,a,t){let r={};function i(d){if(d.hidden||d.type!=="stack")return;let u=d.children.filter(o=>!o.hidden),h=d.interaction;if(p(d)){let o=r[d.interaction.pickerId]??={ids:[],defaults:[],remembered:[]},f=t.pickers[d.interaction.pickerId]?.options??[];for(let w of u){let z=w.type==="stack"?w.bind?.plan:void 0;z&&f.includes(z)&&!o.ids.includes(z)&&o.ids.push(z),z&&w.id===a[d.id]&&o.remembered.push(z)}let m=d.children[d.interaction.defaultIndex];m?.type==="stack"&&!m.hidden&&m.bind?.plan&&o.defaults.push(m.bind.plan)}if(h?.type==="tabs"){let o=u.find(f=>f.id===a[d.id])??d.children[h.defaultIndex];o&&i(o)}else if(h?.type==="toggle"){let o=typeof a[d.id]=="boolean"?a[d.id]:h.defaultEnabled,f=d.children[o?0:1];f&&i(f)}else u.forEach(i)}let s=typeof a.__page=="string"?a.__page:e.initialPageId??e.pages[0]?.id,n=e.pages.find(d=>d.id===s);n&&i(n.root);let l={};for(let[d,u]of Object.entries(r)){let h=a[d],o=u.remembered[0]??(u.ids.includes(t.pickers[d]?.selected??"")?t.pickers[d]?.selected:u.defaults[0]);l[d]=typeof h=="string"?u.ids.includes(h)?h:"":o&&u.ids.includes(o)?o:""}for(let d of Object.keys(A(e)))l[d]??="";return l}let y=window;for(let e=0;e<c.hostDepth;e++)y=y.parent;let T=window,C={none:0,xs:4,sm:8,md:12,lg:20,xl:32},P={none:0,sm:4,md:8,lg:14,full:9999},b={system:'system-ui,-apple-system,"Segoe UI",Roboto,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","Noto Sans CJK SC",sans-serif',serif:'Georgia,"Times New Roman","Songti SC","Noto Serif CJK SC",serif',rounded:'ui-rounded,"SF Pro Rounded","Hiragino Maru Gothic ProN",system-ui,sans-serif',mono:"ui-monospace,SFMono-Regular,Menlo,Consolas,monospace"},v={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},N={start:"flex-start",center:"center",end:"flex-end",between:"space-between"},H={start:"start",center:"center",end:"end",between:"stretch"},F={start:"start",center:"center",end:"end",stretch:"stretch"},W={"1:1":"1 / 1","4:3":"4 / 3","16:9":"16 / 9","3:1":"3 / 1"},x=`
1
+ import{a as Z}from"./chunk-6X42DWOM.js";import{a as Et}from"./chunk-LFNFVYC2.js";import{Af as We,Ai as xt,Bg as xe,Cg as wt,Dg as Ve,Ef as Re,kj as vt,lj as kt,ng as bt,oj as St,qg as ze,sf as ht,xf as Be,yf as yt,yg as qe,zg as Je}from"./chunk-PVJKOUNE.js";import"./chunk-TZ6REIUE.js";function At(c){let p=new Intl.Locale(c);if(p.language==="zh")return p.maximize().script==="Hant"?"\u95DC\u9589\u5F48\u7A97":"\u5173\u95ED\u5F39\u7A97";let I={en:"Close popup",ja:"\u30DD\u30C3\u30D7\u30A2\u30C3\u30D7\u3092\u9589\u3058\u308B",ko:"\uD31D\uC5C5 \uB2EB\uAE30",es:"Cerrar ventana emergente",fr:"Fermer la fen\xEAtre contextuelle",de:"Popup schlie\xDFen",pt:"Fechar janela pop-up",it:"Chiudi popup",ru:"\u0417\u0430\u043A\u0440\u044B\u0442\u044C \u0432\u0441\u043F\u043B\u044B\u0432\u0430\u044E\u0449\u0435\u0435 \u043E\u043A\u043D\u043E",vi:"\u0110\xF3ng c\u1EEDa s\u1ED5 b\u1EADt l\xEAn",th:"\u0E1B\u0E34\u0E14\u0E2B\u0E19\u0E49\u0E32\u0E15\u0E48\u0E32\u0E07\u0E1B\u0E4A\u0E2D\u0E1B\u0E2D\u0E31\u0E1B",id:"Tutup pop-up",ar:"\u0625\u063A\u0644\u0627\u0642 \u0627\u0644\u0646\u0627\u0641\u0630\u0629 \u0627\u0644\u0645\u0646\u0628\u062B\u0642\u0629",he:"\u05E1\u05D2\u05D9\u05E8\u05EA \u05D4\u05D7\u05DC\u05D5\u05DF \u05D4\u05E7\u05D5\u05E4\u05E5",fa:"\u0628\u0633\u062A\u0646 \u067E\u0646\u062C\u0631\u0647\u0654 \u0628\u0627\u0632\u0634\u0648",ur:"\u067E\u0627\u067E \u0627\u067E \u0628\u0646\u062F \u06A9\u0631\u06CC\u06BA"};return I[p.language]??I.en}import Vt from"dompurify";import{parse as Wt,generate as qt,walk as Jt}from"css-tree";function It(c){if(!c.trim())return"";if(/[\\<]/.test(c))throw new Error("CSS \u6682\u4E0D\u652F\u6301\u53CD\u659C\u6760\u8F6C\u4E49\u6216 HTML \u6807\u7B7E\u3002");let p=Wt(c,{onParseError:L=>{throw Object.assign(new Error("CSS \u683C\u5F0F\u4E0D\u6B63\u786E\u3002"),{offset:L.offset})}}),I=0;return Jt(p,L=>{if(++I>5e3)throw new Error("CSS \u8FC7\u4E8E\u590D\u6742\u3002");if(L.type==="Raw"||L.type==="Url"||L.type==="Atrule"&&!["media","supports","keyframes"].includes(L.name.toLowerCase())||L.type==="Function"&&["image-set","-webkit-image-set","image","src","paint"].includes(L.name.toLowerCase()))throw new Error("CSS \u4E0D\u652F\u6301\u5916\u90E8\u8D44\u6E90\u3001\u5BFC\u5165\u6216\u672A\u77E5\u8BED\u6CD5\uFF1B\u56FE\u7247\u8BF7\u4F7F\u7528 HTML img \u6807\u7B7E\u3002")}),qt(p)}import{parse as Kt,walk as Zt}from"css-tree";function Gt(c,p,I,L){return{html:He(c,I,L),css:Ke(p)}}function Ke(c){return It(c)}function He(c,p,I,L){if(!c.trim())return"";let m=We(c);if(m.length)throw new Error(m[0]);let $=Vt(I),M=$.sanitize(c,{ALLOWED_TAGS:["main","section","article","header","footer","div","span","p","h1","h2","h3","h4","strong","em","b","i","small","br","hr","ul","ol","li","button","img"],ALLOWED_ATTR:["class","alt","src","width","height","title","type","disabled","data-grow-action","aria-label"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1,ADD_URI_SAFE_ATTR:["data-grow-action"],ALLOWED_URI_REGEXP:/^https:\/\//i,RETURN_DOM:!0});if(!(M instanceof I.Element))throw new Error("\u65E0\u6CD5\u89E3\u6790 HTML\u3002");if(L){let S=new Set;for(let f of $.removed){let P="element"in f?f.element.nodeName.toLowerCase():void 0,R="attribute"in f?f.attribute?.name:void 0;if(!P&&!R)continue;let H=R?/<[^>]+>/g:new RegExp(`<\\s*${P}\\b[^>]*>`,"gi"),F=[...c.matchAll(H)].find(U=>!S.has(`${R??P}:${U.index}`)&&(!R||new RegExp(`\\b${R}\\s*=`,"i").test(U[0])));if(!F)continue;let b=F.index;S.add(`${R??P}:${b}`);let E=R==="style"?"\u5185\u8054\u6837\u5F0F\u4E0D\u4FDD\u7559\uFF0C\u8BF7\u5199\u5728 CSS \u4E2D\u3002":R?.startsWith("on")?"\u811A\u672C\u4E8B\u4EF6\u4E0D\u5141\u8BB8\uFF0C\u8BF7\u4F7F\u7528\u52A8\u4F5C\u6309\u94AE\u3002":R==="src"?"\u56FE\u7247\u53EA\u652F\u6301 https \u5730\u5740\u3002":"\u8FD9\u4E2A\u5C5E\u6027\u4E0D\u5728\u5141\u8BB8\u7684\u5E03\u5C40\u3001\u56FE\u7247\u4E0E\u52A8\u4F5C\u5C5E\u6027\u4E2D\u3002";L.push({language:"html",from:b,to:b+F[0].length,severity:"warning",message:R?`\u5DF2\u79FB\u9664\u5C5E\u6027 ${R}\uFF1A${E}`:`\u5DF2\u79FB\u9664 <${P}>\uFF1A\u8FD9\u4E2A\u6807\u7B7E\u4E0D\u5728\u5141\u8BB8\u7684\u6392\u7248\u6807\u7B7E\u4E2D\u3002`})}}let N=We(M.innerHTML);if(N.length)throw new Error(N[0]);if(M.querySelectorAll("*").length>500)throw new Error("HTML \u6700\u591A\u652F\u6301 500 \u4E2A\u5143\u7D20\u3002");for(let S of M.querySelectorAll("[data-grow-action]")){let f=S.getAttribute("data-grow-action");if(S.tagName!=="BUTTON"||!p.includes(f))throw new Error(`\u81EA\u5B9A\u4E49 HTML \u91CC\u7684\u6309\u94AE ${f.slice(0,64)} \u6CA1\u6709\u5BF9\u5E94\u7684\u52A8\u4F5C\uFF0C\u8BF7\u5148\u5728\u300C\u70B9\u51FB\u52A8\u4F5C\u300D\u91CC\u6DFB\u52A0\uFF0C\u5E76\u4F7F\u7528 button \u5143\u7D20\u3002`)}if(!M.textContent?.trim()&&!M.querySelector("img"))throw new Error("\u81EA\u5B9A\u4E49 HTML \u6E05\u6D17\u540E\u6CA1\u6709\u53EF\u663E\u793A\u7684\u5185\u5BB9\u3002");return M.innerHTML}var Lt=2e3,Dt=1e4,Rt=new WeakMap;function Nt(c,p,I){let L=I.document;if(!L)throw new Error("A content document is required");let m=Rt.get(I)??new Map;Rt.set(I,m);let $=(S,f)=>{let P=m.get(S);if(P!==void 0)return P;let R=f();m.set(S,R);let H=[...m.keys()].reduce((F,b)=>F+b.length,0);for(;m.size>64||H>256e3;){let F=m.keys().next().value;m.delete(F),H-=F.length}return R},M=S=>$(`html:${S}`,()=>{let f=L.createElement("div");return f.innerHTML=S,f.querySelectorAll("*").length}),N=S=>$(`css:${S}`,()=>{let f=0;return S.trim()&&Zt(Kt(S),()=>{f++}),f});for(let S of c.pages){let f=0,P=0,R=H=>{if(H.hidden||(H.type==="stack"&&H.children.forEach(R),H.type!=="custom_html"))return;let F=p?.nodes[H.id],b=[...Object.values(H.html),F?.base.html??"",...Object.values(F?.byPlan??{}).map(E=>E.html??"")];if(f+=Math.max(0,...b.map(M)),P+=N(H.css),f>Lt)throw new Error(`Page custom HTML exceeds ${Lt} elements`);if(P>Dt)throw new Error(`Page custom CSS exceeds ${Dt} syntax nodes`)};R(S.root)}}function Yt(c,p,I,L){let m=[],$="",M="";for(let N of["html","css"])try{N==="html"?$=He(c,I,L,m):M=Ke(p)}catch(S){let f=N==="html"?c:p,P=N==="html"?/\{\{|data-grow-action/:/@import\b|url\s*\(|image-set\s*\(|[\\<]/i,R=S instanceof Error?S.message:"\u5185\u5BB9\u65E0\u6CD5\u89E3\u6790",H=N==="html"?R.match(/未知变量:(.+)/)?.[1]:void 0,F=H?f.indexOf(H):-1,b=typeof S=="object"&&S!==null&&"offset"in S&&typeof S.offset=="number"?S.offset:F>=0?f.lastIndexOf("{{",F):f.search(P);m.push({language:N,from:Math.max(0,b),to:Math.min(f.length,Math.max(0,b)+2),severity:"error",message:R})}return{html:$,css:M,diagnostics:m,valid:!m.some(N=>N.severity==="error")}}function _e(c,p,I){if(!c)return;let L={},m=p.actions.map(M=>M.id);for(let[M,N]of Object.entries(c.nodes)){let S=f=>{if(f.html===void 0)return f;if(xe(p,M)?.type!=="custom_html")throw new Error("HTML \u5546\u54C1\u6570\u636E\u53EA\u80FD\u7528\u4E8E\u81EA\u5B9A\u4E49 HTML \u7EC4\u4EF6");return{...f,html:He(f.html,m,I)}};L[M]={...N,base:S(N.base),...N.byPlan?{byPlan:Object.fromEntries(Object.entries(N.byPlan).map(([f,P])=>[f,S(P)]))}:{}}}let $={...c,nodes:L};return Nt(p,$,I),$}var _t=new WeakMap;function Ne(c,p){let I=ze.parse(c),L=JSON.stringify(I),m=_t.get(p);m||(m=new Map,_t.set(p,m));let $=Date.now();for(let[b,E]of m)E.expires<=$&&m.delete(b);let M=m.get(L);if(M)return m.delete(L),m.set(L,M),JSON.parse(M.json);let N=I.actions.map(b=>b.id),S=b=>{if(b.type==="stack")return{...b,children:b.children.map(S)};if(b.type!=="custom_html")return b;let E={};for(let[U,G]of Object.entries(b.html))E[U]=He(G,N,p);return{...b,html:E,css:Ke(b.css)}},f={...I,pages:I.pages.map(b=>({...b,root:S(b.root)}))};Nt(f,void 0,p);let P=JSON.stringify(f),R=new TextEncoder,H=R.encode(P).length;if(H>Re.documentBytes)throw new Error(`\u754C\u9762\u5185\u5BB9\u8FC7\u5927\uFF08\u4E0A\u9650 ${Re.documentBytes/1e3} KB\uFF09\u3002`);let F=R.encode(L).length;if(F<=Re.documentBytes){m.set(L,{json:P,bytes:F+H,expires:$+6e4});let b=[...m.values()].reduce((E,U)=>E+U.bytes,0);for(;m.size>16||b>2*1024*1024;){let[E,U]=m.entries().next().value;m.delete(E),b-=U.bytes}}return f}function Ze(c){function p(e){return e.type==="stack"&&e.interaction?.type==="select"&&e.interaction.purpose==="product"&&!!e.interaction.pickerId}function I(e){let a={};function t(r){if(p(r)){let i=a[r.interaction.pickerId]??={ids:[],defaultId:null};for(let n of r.children){let l=n.type==="stack"?n.bind?.plan:void 0;l&&!i.ids.includes(l)&&i.ids.push(l)}let s=r.children[r.interaction.defaultIndex];!i.defaultId&&s?.type==="stack"&&(i.defaultId=s.bind?.plan??null)}r.type==="stack"&&r.children.forEach(t)}return e.pages.forEach(r=>t(r.root)),a}function L(e,a,t){let r={};function i(d){if(d.hidden||d.type!=="stack")return;let u=d.children.filter(o=>!o.hidden),w=d.interaction;if(p(d)){let o=r[d.interaction.pickerId]??={ids:[],defaults:[],remembered:[]},h=t.pickers[d.interaction.pickerId]?.options??[];for(let x of u){let T=x.type==="stack"?x.bind?.plan:void 0;T&&h.includes(T)&&!o.ids.includes(T)&&o.ids.push(T),T&&x.id===a[d.id]&&o.remembered.push(T)}let y=d.children[d.interaction.defaultIndex];y?.type==="stack"&&!y.hidden&&y.bind?.plan&&o.defaults.push(y.bind.plan)}if(w?.type==="tabs"){let o=u.find(h=>h.id===a[d.id])??d.children[w.defaultIndex];o&&i(o)}else if(w?.type==="toggle"){let o=typeof a[d.id]=="boolean"?a[d.id]:w.defaultEnabled,h=d.children[o?0:1];h&&i(h)}else u.forEach(i)}let s=typeof a.__page=="string"?a.__page:e.initialPageId??e.pages[0]?.id,n=e.pages.find(d=>d.id===s);n&&i(n.root);let l={};for(let[d,u]of Object.entries(r)){let w=a[d],o=u.remembered[0]??(u.ids.includes(t.pickers[d]?.selected??"")?t.pickers[d]?.selected:u.defaults[0]);l[d]=typeof w=="string"?u.ids.includes(w)?w:"":o&&u.ids.includes(o)?o:""}for(let d of Object.keys(I(e)))l[d]??="";return l}let m=window;for(let e=0;e<c.hostDepth;e++)m=m.parent;let $=window,M={none:0,xs:4,sm:8,md:12,lg:20,xl:32},N={none:0,sm:4,md:8,lg:14,full:9999},S={system:'system-ui,-apple-system,"Segoe UI",Roboto,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","Noto Sans CJK SC",sans-serif',serif:'Georgia,"Times New Roman","Songti SC","Noto Serif CJK SC",serif',rounded:'ui-rounded,"SF Pro Rounded","Hiragino Maru Gothic ProN",system-ui,sans-serif',mono:"ui-monospace,SFMono-Regular,Menlo,Consolas,monospace"},f={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},P={start:"flex-start",center:"center",end:"flex-end",between:"space-between"},R={start:"start",center:"center",end:"end",between:"stretch"},H={start:"start",center:"center",end:"end",stretch:"stretch"},F={"1:1":"1 / 1","4:3":"4 / 3","16:9":"16 / 9","3:1":"3 / 1"},b=`
2
2
  *,*::before,*::after{box-sizing:border-box}
3
3
  html,body{margin:0;padding:0;background:transparent}
4
4
  body{font-family:var(--g-font);color:var(--g-text);-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}
@@ -12,7 +12,8 @@ body{font-family:var(--g-font);color:var(--g-text);-webkit-font-smoothing:antial
12
12
  .g-v{flex-direction:column}
13
13
  .g-h{flex-direction:row;flex-wrap:wrap}
14
14
  .g-o{display:grid;grid-template-columns:minmax(0,1fr)}
15
- .g-o>*{grid-area:1/1;min-width:0}
15
+ /* Each authored overlay layer paints as a unit in document order. */
16
+ .g-o>*{grid-area:1/1;min-width:0;isolation:isolate}
16
17
  .g-text{margin:0;white-space:pre-line;overflow-wrap:anywhere;min-width:0}
17
18
  .g-title{font-size:26px;line-height:1.2;font-weight:700;letter-spacing:-.01em}
18
19
  .g-heading{font-size:20px;line-height:1.3;font-weight:650}
@@ -167,7 +168,7 @@ body{font-family:var(--g-font);color:var(--g-text);-webkit-font-smoothing:antial
167
168
  @media(max-width:560px){.g-data[data-source=credit_transactions][data-layout=compact] .g-data-row{grid-template-columns:minmax(0,1fr) minmax(95px,.45fr);gap:12px}.g-data[data-source=credit_transactions][data-layout=compact] .g-data-row-status{grid-column:1;grid-row:2;margin-inline-start:46px;justify-self:start}.g-data[data-source=credit_transactions][data-layout=compact] .g-data-row-extra{grid-column:2;grid-row:1/3}}
168
169
  @media(max-width:560px){.g-data[data-source=membership] .g-data-row-no-value .g-data-row-status{grid-column:2;grid-row:1;align-self:start;justify-self:end}}
169
170
  @media (prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}}
170
- `,L=null,$,te=new Set,j,ee,se=new Map,pe=new Map,le,X={},M=null,E=Object.create(null),ne=Object.create(null),ue=Object.create(null),R="",k=!1,S=-1,ae=!1,me="",Z=null,Ee=null,ve=null,q=document.createElement("div");q.id="g-card";let ge=document.createElement("div"),de=document.createElement("div");ge.className=de.className="g-box",de.dataset.kind="select",ge.append(document.createElement("span")),de.append(document.createElement("span"));function K(e){let a={...e,channel:c.channel};try{y.postMessage(a,c.parentOrigin)}catch{}}function He(e){let a=parseInt(e.slice(1),16);return[a>>16&255,a>>8&255,a&255]}function _e(e,a,t){let r=He(e),i=He(a),s=r.map((n,l)=>Math.round(n*t+i[l]*(1-t)));return`rgb(${s[0]},${s[1]},${s[2]})`}function Ct(e){let[a,t,r]=He(e).map(i=>{let s=i/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4});return .2126*a+.7152*t+.0722*r}function Ae(e){return typeof e!="string"?"":e.startsWith("#")?e:`var(--g-${e==="background"?"bg":e})`}function Mt(e){let a=e.theme,t=document.documentElement.style,r=Ct(a.primary),i=(r+.05)/.05>1.05/(r+.05)?"#111318":"#FFFFFF";t.setProperty("--g-primary",a.primary),t.setProperty("--g-on-primary",i),t.setProperty("--g-bg",a.background),t.setProperty("--g-text",a.text),t.setProperty("--g-muted",_e(a.text,a.background,.62)),t.setProperty("--g-surface",_e(a.text,a.background,.05)),t.setProperty("--g-border",_e(a.text,a.background,.16)),t.setProperty("--g-focus",_e(a.primary,a.background,.45)),t.setProperty("--g-radius",`${P[a.radius]??8}px`),t.setProperty("--g-font",b[a.font]??b.system),t.setProperty("--g-edit","#2C3C96")}function J(e){let a=L?.strings.locales[R]?.[e];return a&&a.trim()?{value:a,missing:!1}:{value:L?.strings.locales[L.strings.defaultLocale]?.[e]??"",missing:!0}}function he(e){let a=j?.nodes[e];if(!a)return;let t=a.picker?E[a.picker]??j?.pickers[a.picker]?.selected:void 0;if(!(a.picker&&t===""))return typeof t=="string"?a.byPlan?.[t]??a.base:a.base}function Xe(){return{...L?.surface==="paywall"&&M?{__page:M}:{},...Object.fromEntries(Object.entries(E).filter(e=>!Array.isArray(e[1])))}}function Ie(e,a,t){let r=he(e.id),i=r?.[a],s=i!==void 0?{value:i,missing:!!r?.missing?.length}:J(t);if(c.mode==="live"&&$){let n=!1,l=s.value.replace(/\{\{\s*(input|params)\.([a-zA-Z][a-zA-Z0-9_.-]{0,63})\s*\}\}/g,(d,u,h)=>{let o=u==="params"?X[h]:$?.answers[h];return o==null||o===""||Array.isArray(o)&&!o.length?(n=!0,""):Array.isArray(o)?o.join(", "):String(o)});if(n)return{value:e.fallback?J(e.fallback).value:"",missing:!0};if(!l.includes("{{"))return{value:l,missing:s.missing}}return i!==void 0?s:s.value.includes("{{")&&c.mode==="live"?{value:e.fallback?J(e.fallback).value:"",missing:!0}:{value:s.value,missing:s.missing||s.value.includes("{{")}}function Tt(e){if(e.name)return e.name;let a=c.editorMessages?.nodeTypes?.[e.type];return c.mode==="editor"&&typeof a=="string"?a:{stack:"\u5BB9\u5668",text:"\u6587\u672C",image:"\u56FE\u7247",button:"\u6309\u94AE",divider:"\u5206\u9694\u7EBF",spacer:"\u7559\u767D",custom_html:"\u81EA\u5B9A\u4E49 HTML",price:"\u4EF7\u683C",coupon_code:"\u4F18\u60E0\u7801",countdown:"\u5012\u8BA1\u65F6",plan_picker:"\u771F\u5B9E\u5957\u9910\u9009\u62E9"}[e.type]??e.type}function $t(e,a){if(a.type==="color")e.background="none",e.backgroundColor=Ae(a.color);else if(a.type==="linear"){let t=a.stops.map(r=>`${Ae(r.color)} ${Number(r.at)}%`).join(",");e.backgroundColor="transparent",e.backgroundImage=`linear-gradient(${Number(a.angle)}deg,${t})`}else if(a.type==="image"&&typeof a.src=="string"){let t=/^data:image\/(?:svg\+xml|jpeg|png);base64,[A-Za-z0-9+/]+={0,2}$/.test(a.src)?a.src:a.src.replace(/[^A-Za-z0-9\-._~:/?#[\]@!$&*+;=%]/gu,i=>i.length===1&&i.charCodeAt(0)<128?`%${i.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`:encodeURIComponent(i));e.backgroundImage=`url("${t}")`;let r=a.position;e.backgroundPosition=r?`${r.x}% ${r.y}%`:"center",e.backgroundSize=a.fit==="contain"?"contain":"cover",e.backgroundRepeat="no-repeat"}}function Qe(e){return`${Number(e.top)}px ${Number(e.right)}px ${Number(e.bottom)}px ${Number(e.left)}px`}function et(e,a,t,r,i){if(a===void 0)return;let s=r?.direction??"vertical",n=s!=="overlay"&&t==="width"==(s==="horizontal"),l=t==="width"?"minWidth":"minHeight";a==="fill"?s==="overlay"?(e.style[t]="100%",e.style[t==="width"?"justifySelf":"alignSelf"]="stretch"):n?(e.style.flex="1 1 0",e.style[l]="0"):(e.style.alignSelf="stretch",e.style[t]="auto"):a==="fit"?(e.style[t]="fit-content",t==="width"&&(e.style.maxWidth="100%"),!n&&s!=="overlay"&&(!r||r.align==="stretch")&&(e.style.alignSelf=i==="center"?"center":i==="end"?"flex-end":"flex-start")):typeof a=="number"&&(e.style[t]=`${a}px`,t==="width"&&(e.style.maxWidth="100%"),n&&(e.style.flex="0 0 auto"))}function Le(e,a,t){let r=a.style,i=r.text??{},s=e.style;if(a.type==="customer_data"&&(i.font&&s.setProperty("--g-data-display-font",b[String(i.font)]??b.system),a.data.source==="membership"&&(typeof i.size=="number"&&s.setProperty("--g-data-display-size",`clamp(${Math.min(i.size,28)}px, ${i.size/12}vw, ${i.size}px)`),typeof i.weight=="number"&&s.setProperty("--g-data-display-weight",String(i.weight)))),a.type==="customer_data"&&a.data.source==="credit_balance"&&(typeof i.size=="number"&&s.setProperty("--g-data-number-size",`clamp(${Math.min(i.size,48)}px, ${i.size/10}vw, ${i.size}px)`),i.font&&s.setProperty("--g-data-number-font",b[String(i.font)]??b.system),typeof i.weight=="number"&&s.setProperty("--g-data-number-weight",String(i.weight))),a.type==="customer_data"&&i.color){let u=Ae(i.color);s.setProperty("--g-data-ink",u),s.setProperty("--g-data-muted",`color-mix(in srgb, ${u} 72%, transparent)`),s.setProperty("--g-data-line",`color-mix(in srgb, ${u} 20%, transparent)`),s.setProperty("--g-data-surface",`color-mix(in srgb, ${u} 8%, transparent)`)}r.padding&&(s.padding=Qe(r.padding)),r.margin&&(s.margin=Qe(r.margin)),typeof r.gap=="number"&&a.type==="stack"&&(s.gap=`${r.gap}px`),r.background&&$t(s,r.background),typeof r.opacity=="number"&&(s.opacity=String(r.opacity));let n=r.shape;if(n?.type==="pill")s.borderRadius="9999px";else if(n?.type==="rect"){let u=n.radius;s.borderRadius=typeof u=="number"?`${u}px`:`${Number(u.topLeft)}px ${Number(u.topRight)}px ${Number(u.bottomRight)}px ${Number(u.bottomLeft)}px`}(r.clipContent===!0||r.clipContent!==!1&&n&&(r.background||a.type==="image"))&&(s.overflow="hidden");let l=r.border;l&&(s.border=Number(l.width)>0?`${Number(l.width)}px ${l.style==="dashed"?"dashed":"solid"} ${Ae(l.color)}`:"0");let d=r.shadow;d&&(s.boxShadow=`${Number(d.x)}px ${Number(d.y)}px ${Number(d.blur)}px ${Number(d.spread)}px ${Ae(d.color)}`),["text","button","price","coupon_code","countdown","plan_picker"].includes(a.type)&&(i.font&&(s.fontFamily=b[String(i.font)]??""),typeof i.size=="number"&&(s.fontSize=`${i.size}px`),typeof i.weight=="number"&&(s.fontWeight=String(i.weight)),typeof i.lineHeight=="number"&&(s.lineHeight=String(i.lineHeight)),typeof i.letterSpacing=="number"&&(s.letterSpacing=`${i.letterSpacing}px`),i.color&&(s.color=Ae(i.color)),i.align&&(s.textAlign=String(i.align)),i.italic&&(s.fontStyle="italic"),i.decoration&&(s.textDecoration=String(i.decoration)),i.transform&&(s.textTransform=String(i.transform))),et(e,r.width,"width",t,i.align),et(e,r.height,"height",t,i.align),t?.direction==="horizontal"&&r.grow!==void 0&&(s.flexGrow=String(r.grow===!0?1:r.grow===!1?0:r.grow))}function Pe(e,a){if($){let t=$.bindings.find(r=>r.componentId===e);if(!t)return;$.answers[t.key]=a,te.add(e),K({type:"answers",answers:tt()});return}}function tt(){let e={};for(let a of $?.bindings??[]){let t=E[a.componentId];t!==void 0&&(e[a.key]=t)}return e}function zt(e){let a=document.createElement("section");a.className="g-data",a.dataset.layout=e.data.layout,a.dataset.source=e.data.source;let t=ee?.nodes[e.id];a.dataset.status=t?.status??"idle",a.dataset.preview=String(!!t?.preview);let r=t?.status==="loading",i=R.startsWith("zh"),s=(g,D)=>i?g:D;a.setAttribute("aria-busy",String(!!r));let n=(g,D,G)=>{let _=document.createElement(g);return _.className=D,G!==void 0&&(_.textContent=G),_},l=g=>{let D=document.createElementNS("http://www.w3.org/2000/svg","svg");D.setAttribute("viewBox","0 0 24 24"),D.setAttribute("fill","none"),D.setAttribute("stroke","currentColor"),D.setAttribute("stroke-width","1.7"),D.setAttribute("stroke-linecap","round"),D.setAttribute("stroke-linejoin","round"),D.setAttribute("aria-hidden","true"),D.classList.add("g-data-icon");let G={refresh:["M20 7v5h-5","M4 17v-5h5","M6.1 7a7 7 0 0 1 11.5-1.5L20 8M4 16l2.4 2.5A7 7 0 0 0 18 17"],down:["M7 7l10 10M7 17h10V7"],up:["M7 17L17 7M7 7h10v10"],chevron:["M6 9l6 6 6-6"],empty:["M4 8l8-4 8 4v10l-8 4-8-4V8Z","M4 8l8 4 8-4M12 12v10"],credit:["M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Z","M12 7v10M8 12h8"]};for(let _ of G[g]){let B=document.createElementNS("http://www.w3.org/2000/svg","path");B.setAttribute("d",_),D.append(B)}return D},d=(g,D,G,_=!1,B=D)=>{let re=n("button","g-data-button",g);return re.type="button",re.disabled=_||!!r&&D!=="refresh"||!!t?.preview||c.mode!=="live",r&&D==="refresh"&&re.setAttribute("aria-disabled","true"),re.dataset.gDataFocus=`${e.id}:${B}:${G??""}`,re.addEventListener("click",ce=>{!ce.isTrusted||re.disabled||r||K({type:"customer-data-intent",intent:{nodeId:e.id,action:D,...G?{value:G}:{}}})}),re},u=n("div","g-data-header"),h=n("h2","g-data-heading",J(e.title).value);h.id=`g-data-title-${e.id}`,a.setAttribute("aria-labelledby",h.id);let o=n("div","g-data-controls"),f=[],m=g=>{g.hidden||(g.type==="customer_data"&&f.push(g),g.type==="stack"&&g.children.forEach(m))},w=L?.pages[0];w&&m(w.root);let z=f.every(g=>ee?.nodes[g.id]?.preview),U=f.find(g=>g.data.source==="credit_balance")??f[0];t?.preview&&(!z||U?.id===e.id)&&o.append(n("span","g-data-preview",s("\u793A\u4F8B\u6570\u636E","Sample data")));let O=r?s("\u66F4\u65B0\u4E2D\u2026","Updating\u2026"):s("\u5237\u65B0","Refresh"),Q=d(O,"refresh");if(Q.replaceChildren(l("refresh")),Q.setAttribute("aria-label",O),Q.title=O,Q.classList.add("g-data-refresh"),r&&Q.classList.add("g-data-refreshing"),o.append(Q),e.data.source==="billing"&&e.data.outputs?.billing_portal&&o.append(d(t?.billingBusy?s("\u6B63\u5728\u51C6\u5907\u2026","Preparing\u2026"):s("\u7BA1\u7406\u652F\u4ED8\u65B9\u5F0F","Manage payment method"),"billing_portal",void 0,!!t?.billingBusy||t?.status!=="ready")),e.data.source==="credit_balance"&&(h.prepend(l("credit")),t?.resources.length===1&&h.append(n("span","g-data-resource-label",t.resources[0].name)),t?.updatedAt)){let g=n("time","g-data-updated",`${s("\u66F4\u65B0\u4E8E","Updated")} ${new Intl.DateTimeFormat(R,{timeStyle:"short"}).format(new Date(t.updatedAt))}`);g.dateTime=t.updatedAt,g.title=new Intl.DateTimeFormat(R,{dateStyle:"medium",timeStyle:"short"}).format(new Date(t.updatedAt)),o.prepend(g)}if(u.append(h,o),a.append(u),!t||t.source!==e.data.source)return a.append(n("p","g-data-empty",s("\u8FDE\u63A5\u5BA2\u6237\u6570\u636E\u540E\u663E\u793A\u6B64\u5185\u5BB9\u3002","Connect customer data to display this content."))),a;if(t.errorMessage){let g=n("div","g-data-error",t.errorMessage);g.setAttribute("role","alert"),a.append(g);let D=n("div","g-data-recovery");D.append(d(s("\u91CD\u8BD5","Retry"),"refresh")),a.append(D)}if(t.membershipResult){let g=n("p","g-data-note",t.membershipResult);g.setAttribute("role","status"),a.append(g)}if(t.membershipReview){let g=t.membershipReview,D=n("section","g-data-resource");D.dataset.gDataReview="",D.setAttribute("aria-label",g.title),D.setAttribute("aria-busy",String(!!t.membershipBusy));let G=n("h3","g-data-row-label",g.title);G.tabIndex=-1,D.append(G);let _=n("dl","g-data-facts");for(let re of g.facts){let ce=n("div","");ce.append(n("dt","",re.label),n("dd","",re.value)),_.append(ce)}D.append(_,n("p","g-data-note",g.note));let B=n("div","g-data-controls");B.append(d(s("\u8FD4\u56DE","Back"),"membership_dismiss",void 0,!!t.membershipBusy),d(t.membershipBusy?s("\u6B63\u5728\u5904\u7406\u2026","Processing\u2026"):s("\u786E\u8BA4","Confirm"),"membership_confirm",void 0,!!t.membershipBusy)),D.append(B),a.append(D)}if(t.stale&&(t.resources.length||t.rows.length)&&a.append(n("p",r?"g-data-live-status":"g-data-note",r?s("\u6B63\u5728\u66F4\u65B0\u8D26\u6237\u6570\u636E\u3002","Updating account data."):s("\u663E\u793A\u4E0A\u6B21\u8BFB\u53D6\u7684\u7ED3\u679C\uFF0C\u6B63\u5728\u7B49\u5F85\u66F4\u65B0\u3002","Showing the last result while awaiting an update."))),r&&!t.resources.length&&!t.rows.length){let g=n("div","g-data-skeleton");if(g.setAttribute("aria-hidden","true"),e.data.source==="credit_balance")g.append(n("span","g-data-skeleton-line g-data-skeleton-value"),n("span","g-data-skeleton-line g-data-skeleton-meta"));else{let G=Math.min(e.data.pageSize,e.data.layout==="compact"?2:4);for(let _=0;_<G;_++){let B=n("div","g-data-skeleton-row");B.append(n("span","g-data-skeleton-line"),n("span","g-data-skeleton-line")),g.append(B)}}let D=n("p","g-data-live-status",s("\u6B63\u5728\u8BFB\u53D6\u8D26\u6237\u6570\u636E\u2026","Loading account data\u2026"));return D.setAttribute("role","status"),a.append(g,D),a}let ie={credit_transactions:[["all","\u5168\u90E8\u8BB0\u5F55","All activity"],["consume","\u6D88\u8D39","Usage"],["reserve","\u9884\u6263","Reserved"],["confirm","\u786E\u8BA4\u6263\u8D39","Confirmed"],["release","\u91CA\u653E","Released"],["refund","\u9000\u56DE","Refund"]],credit_pack_orders:[["all","\u5168\u90E8\u8BA2\u5355","All orders"],["pending","\u7B49\u5F85\u4ED8\u6B3E","Pending"],["paid","\u5DF2\u4ED8\u6B3E","Paid"],["expired","\u5DF2\u8FC7\u671F","Expired"],["refunded","\u5DF2\u9000\u6B3E","Refunded"],["disputed","\u4E89\u8BAE\u4E2D","Disputed"]],offer_history:[["all","\u5168\u90E8\u8BB0\u5F55","All offers"],["issued","\u53EF\u7528","Available"],["redeemed","\u5DF2\u4F7F\u7528","Redeemed"],["expired","\u5DF2\u5230\u671F","Expired"],["revoked","\u5DF2\u64A4\u9500","Revoked"]]};if(ie[e.data.source]){let g=n("select","g-data-select");g.setAttribute("aria-label",s("\u7B5B\u9009\u8BB0\u5F55","Filter records")),g.dataset.gDataFocus=`${e.id}:filter`,g.disabled=!!r||t.preview||c.mode!=="live";for(let[D,G,_]of ie[e.data.source]){let B=document.createElement("option");B.value=D,B.textContent=s(G,_),g.append(B)}g.value=t.filter,g.addEventListener("change",()=>{!g.disabled&&c.mode==="live"&&K({type:"customer-data-intent",intent:{nodeId:e.id,action:"filter",value:g.value}})}),o.prepend(g)}let ut=(g,D=!1)=>{let G=n("ul","g-data-list");if(e.data.source==="credit_transactions"&&g.length&&!D){let _=n("div","g-data-table-head");_.setAttribute("aria-hidden","true"),_.append(n("span","",s("\u8BB0\u5F55","Record")),n("span","",s("\u7C7B\u578B","Type")),n("span","",s("\u79EF\u5206","Credits"))),a.append(_)}for(let _ of g){let B=n("li","g-data-row"),re=n("div","g-data-row-main"),ce=n("div","g-data-row-copy");ce.append(n("p","g-data-row-label",_.label));for(let Y of _.detail)Y!==_.status&&ce.append(n("div","g-data-row-detail",Y));if(e.data.source==="credit_transactions"&&!D){let Y=n("span","g-data-row-mark");Y.append(l(["Refund","\u9000\u56DE"].includes(_.status??"")?"up":"down")),re.append(Y)}if(re.append(ce),B.append(re),_.status?B.append(n("div","g-data-row-status",_.status)):B.classList.add("g-data-row-no-status"),_.value?B.append(n("div","g-data-row-value",_.value)):B.classList.add("g-data-row-no-value"),_.facts.length||_.purchaseId||_.membershipActions?.length||_.billingActions?.length){let Y=n("div","g-data-row-extra"),fe=n("div","g-data-facts"),we=(oe,Te)=>{for(let gt of oe){let ft=n("span","",gt.label);ft.append(n("strong","",gt.value)),Te.append(ft)}};if(we(_.facts.slice(0,3),fe),_.facts.length>3){let oe=n("details","g-data-sources");oe.dataset.gDataSources=`facts:${_.id}`,oe.append(n("summary","",`${e.data.source==="billing"?s("\u8D26\u5355\u8BE6\u60C5","Invoice details"):s("\u5168\u90E8\u6263\u8D39\u660E\u7EC6","All allocations")} \xB7 ${_.facts.length}`));let Te=n("div","g-data-facts");we(_.facts.slice(3),Te),oe.append(Te),fe.append(oe)}if(Y.append(fe),!D)for(let oe of _.billingActions??[])Y.append(d(oe.label,oe.action,_.id,!!t.billingBusy));if(_.purchaseId&&e.data.allowPurchase&&!D){let oe=d(t.buyingId===_.purchaseId?s("\u6B63\u5728\u51C6\u5907\u2026","Preparing\u2026"):s("\u8D2D\u4E70\u79EF\u5206","Buy credits"),"buy_pack",_.purchaseId,!!t.preview||!!t.buyingId);oe.classList.add("g-data-buy"),Y.append(oe)}if(e.data.allowPurchase&&!D)for(let oe of _.membershipActions??[])Y.append(d(oe.label,"membership_preview",oe.value,!!t.preview||!!t.membershipBusy||!!t.membershipReview));B.append(Y)}G.append(B)}return G};for(let g of t.resources){let D=n("article","g-data-resource");D.setAttribute("aria-label",g.name),t.resources.length>1&&D.append(n("p","g-data-name",g.name));let G=n("div","g-data-balance"),_=new Intl.NumberFormat(R).formatToParts(1.1).find(Y=>Y.type==="decimal")?.value??".",B=g.spendable.lastIndexOf(_),re=n("strong","g-data-number",B<0?g.spendable:g.spendable.slice(0,B));B>=0&&re.append(n("span","g-data-fraction",g.spendable.slice(B))),G.append(re,n("span","g-data-unit",s("\u53EF\u7528\u79EF\u5206","Spendable credits"))),D.append(G);let ce=n("div","g-data-facts");for(let[Y,fe]of[[s("\u4F59\u989D","Balance"),g.available],[s("\u51BB\u7ED3","Reserved"),g.reserved]]){let we=n("span","",Y);we.append(n("strong","",fe)),ce.append(we)}if(g.expiry&&ce.append(n("span","g-data-expiry",`${s("\u6700\u8FD1\u5230\u671F","Next expiry")} \xB7 ${g.expiry}`)),D.append(ce),e.data.showSources&&g.sourceCount){let Y=n("details","g-data-sources");if(Y.dataset.gDataSources=g.key,Y.append(n("summary","",`${s("\u79EF\u5206\u6765\u6E90","Credit sources")} \xB7 ${g.sourceCount}`),ut(g.sources,!0)),Y.querySelector("summary")?.append(l("chevron")),g.hasNextSources||g.hasPreviousSources){let fe=n("div","g-data-footer");fe.append(n("span","",`${s("\u7B2C","Page")} ${g.sourcePage}`));let we=n("div","g-data-controls");we.append(d(s("\u4E0A\u4E00\u9875","Previous"),"sources_previous",g.key,!g.hasPreviousSources),d(s("\u4E0B\u4E00\u9875","Next"),"sources_next",g.key,!g.hasNextSources)),fe.append(we),Y.append(fe)}D.append(Y)}a.append(D)}if(t.rows.length&&a.append(ut(t.rows)),e.data.source==="billing_controls"&&(e.data.outputs?.billing_authorization||e.data.outputs?.billing_adjustment)){let g=n("div","g-data-controls");e.data.outputs?.billing_authorization&&g.append(d(s("\u8BBE\u7F6E\u81EA\u52A8\u4ED8\u6B3E\u6388\u6743","Set up payment authorization"),"billing_authorization")),e.data.outputs?.billing_adjustment&&g.append(d(s("\u67E5\u770B\u5F85\u786E\u8BA4\u8865\u6B3E","Review pending adjustment"),"billing_adjustment")),a.append(g)}if(!t.rows.length&&!t.resources.length&&t.status!=="error"){let g=n("p","g-data-empty",r?s("\u6B63\u5728\u8BFB\u53D6\u8D26\u6237\u6570\u636E\u2026","Loading account data\u2026"):t.status==="idle"?s("\u767B\u5F55\u540E\u67E5\u770B\u4F60\u7684\u8D26\u6237\u6570\u636E\u3002","Sign in to view your account data."):t.filter!=="all"?s("\u6CA1\u6709\u7B26\u5408\u7B5B\u9009\u6761\u4EF6\u7684\u8BB0\u5F55\u3002","No records match this filter."):e.data.source==="credit_pack_orders"?s("\u6682\u65E0\u8D2D\u4E70\u8BB0\u5F55","No purchases yet"):e.data.source==="credit_balance"?s("\u6682\u65E0\u79EF\u5206\u6765\u6E90","No credit balances yet"):e.data.source==="membership"?s("\u6682\u65E0\u4F1A\u5458\u65B9\u6848","No memberships yet"):e.data.source==="customer_plans"?s("\u6682\u65E0\u53EF\u9009\u5957\u9910","No plans available"):e.data.source==="credit_packs"?s("\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u79EF\u5206\u5305","No credit packs available"):e.data.source==="billing_controls"?s("\u5C1A\u672A\u8BBE\u7F6E\u7528\u91CF\u9650\u5236\u6216\u81EA\u52A8\u4ED8\u6B3E\u6388\u6743","No usage limits or payment authorizations configured"):e.data.source==="offer_history"?s("\u6682\u65E0\u4F18\u60E0\u8BB0\u5F55","No offers yet"):e.data.source==="billing"?s("\u6682\u65E0\u8D26\u5355","No invoices yet"):s("\u8FD9\u91CC\u8FD8\u6CA1\u6709\u8BB0\u5F55\u3002","There are no records yet."));g.prepend(l("empty")),g.setAttribute("role","status"),a.append(g)}if(t.hasNext||t.hasPrevious){let g=n("div","g-data-footer");g.append(n("span","",`${s("\u7B2C","Page")} ${t.page}`));let D=n("div","g-data-controls");D.append(d(s("\u4E0A\u4E00\u9875","Previous"),"previous",void 0,!t.hasPrevious),d(s("\u4E0B\u4E00\u9875","Next"),"next",void 0,!t.hasNext)),g.append(D),a.append(g)}return t.updatedAt&&e.data.source!=="credit_balance"&&a.append(n("p","g-data-note g-data-updated",`${s("\u6570\u636E\u66F4\u65B0\u4E8E","Updated")} ${new Intl.DateTimeFormat(R,{dateStyle:"medium",timeStyle:"short"}).format(new Date(t.updatedAt))}`)),a}let ke=new Map,Oe=new Map,at=e=>{let a=e.target;for(let t of ke.keys())a&&!Se(t)?.contains(a)&&ke.delete(t)};document.addEventListener("focusin",at),document.addEventListener("pointerdown",at);function Ht(e){let a=ee;if(ee=e,!L)return;let t=(i,s)=>{if(i.type==="stack"){i.children.forEach(w=>t(w,i));return}if(i.type!=="customer_data"||JSON.stringify(a?.nodes[i.id])===JSON.stringify(e.nodes[i.id]))return;let n=Se(i.id);if(!n)return;let l=document.activeElement;l&&n.contains(l)&&l.dataset.gDataFocus&&ke.set(i.id,l.dataset.gDataFocus);let d=new Set([...n.querySelectorAll("details[data-g-data-sources]")].filter(w=>w.open).map(w=>w.dataset.gDataSources)),u=Ce(i,s);if(!u)return;for(let w of u.querySelectorAll("details[data-g-data-sources]"))w.open=d.has(w.dataset.gDataSources);let h=n.scrollTop;n.replaceWith(u),u.scrollTop=h;let o=!!e.nodes[i.id]?.membershipReview&&!a?.nodes[i.id]?.membershipReview,f=!e.nodes[i.id]?.membershipReview&&!!a?.nodes[i.id]?.membershipReview;o&&ke.get(i.id)&&Oe.set(i.id,ke.get(i.id));let m=f?Oe.get(i.id):ke.get(i.id);m&&[...u.querySelectorAll("[data-g-data-focus]")].find(w=>w.dataset.gDataFocus===m)?.focus({preventScroll:!0}),o&&u.querySelector("[data-g-data-review] h3")?.focus({preventScroll:!0}),f&&Oe.delete(i.id),u.animate&&e.nodes[i.id]?.status==="ready"&&!window.matchMedia("(prefers-reduced-motion:reduce)").matches&&u.animate([{opacity:.7},{opacity:1}],{duration:140,easing:"ease-out"})},r=L.pages.find(i=>i.id===M)??L.pages[0];t(r.root,null),be()}function Ce(e,a){if(e.hidden)return null;let t;if(e.type==="customer_data")t=zt(e);else if(e.type==="stack"){t=document.createElement(e.purchaseAction?"button":"div"),e.purchaseAction&&(t.type="button",t.dataset.gAction=e.purchaseAction),t.className=`${e.purchaseAction?`g-btn g-btn-${e.buttonVariant??"primary"} `:""}g-stack ${e.direction==="horizontal"?"g-h":e.direction==="overlay"?"g-o":"g-v"}`,e.direction==="overlay"?(t.style.alignItems=F[e.align]??"stretch",t.style.justifyItems=H[e.justify]??"stretch"):(t.style.alignItems=v[e.align]??"stretch",t.style.justifyContent=N[e.justify]??"flex-start");for(let r of e.children){let i=Ce(r,e);i&&t.append(i)}if(e.interaction&&Ot(t,e),e.purchaseAction&&c.mode==="live"){let r=j?.nodes[e.id],i=r?.picker;i&&(t.disabled=!j?.pickers[i]?.options.includes(String(E[i]??""))),he(e.id)?.unavailable&&(t.disabled=!0)}c.mode==="editor"&&!t.childElementCount&&(t.classList.add("g-empty"),t.dataset.gEditorPlaceholder=c.editorMessages?.emptyContainer??"\u62D6\u5165\u7EC4\u4EF6")}else if(e.type==="text"){let r=e.variant==="title"?"h1":e.variant==="heading"?"h2":"p";t=document.createElement(r),t.className=`g-text g-${e.variant}`;let i=Ie(e,"text",e.text);t.textContent=i.value,i.missing&&c.mode==="editor"&&t.classList.add("g-missing")}else if(e.type==="button"){t=document.createElement("button"),t.type="button",t.className=`g-btn g-btn-${e.variant}`;let r=Ie(e,"label",e.label);t.textContent=r.value,r.missing&&c.mode==="editor"&&t.classList.add("g-missing"),t.dataset.gAction=e.action;let i=j?.nodes[e.id]?.picker;if(i&&c.mode==="live"){let s=i,n=j?.pickers[s],l=E[s]??n?.selected;t.disabled=!n?.options.includes(String(l)),t.disabled&&t.setAttribute("aria-disabled","true")}c.mode==="live"&&he(e.id)?.unavailable&&(t.disabled=!0,t.setAttribute("aria-disabled","true")),c.mode==="editor"&&(t.tabIndex=-1)}else if(e.type==="image"){t=document.createElement("div"),t.className="g-img",W[e.aspect]&&(t.dataset.aspect=e.aspect,t.style.aspectRatio=W[e.aspect]);let r=document.createElement("img");r.src=e.localizedSrc?.[R]??e.localizedSrc?.[L.strings.defaultLocale]??e.src,r.alt=Ie(e,"alt",e.alt).value,r.referrerPolicy="no-referrer",r.decoding="async",r.style.objectFit=e.fit,e.position&&(r.style.objectPosition=`${e.position.x}% ${e.position.y}%`),r.addEventListener("load",be),t.append(r)}else if(e.type==="price"){t=document.createElement("div"),t.className="g-price",t.style.cssText="display:flex;align-items:baseline;gap:8px;flex-wrap:wrap;font-variant-numeric:tabular-nums";let r=he(e.id);if(!r?.price)t.textContent=r?.text??J(e.fallback).value,c.mode==="editor"&&t.classList.add("g-missing");else for(let i of["current","original","period"]){let s=r.price[i];if(!s)continue;let n=document.createElement(i==="original"?"s":"span");n.textContent=s,i==="original"&&(n.style.opacity=".6"),e.parts?.[i]&&Le(n,{type:"text",id:e.id,text:e.fallback,variant:"body",style:e.parts[i]},null),t.append(n)}}else if(e.type==="coupon_code"){t=document.createElement("div"),t.style.cssText="display:flex;align-items:center;gap:12px;flex-wrap:wrap";let r=he(e.id);if(r?.code){let i=document.createElement("code");i.textContent=r.code;let s=document.createElement("button");s.type="button",s.className="g-btn g-btn-secondary",s.textContent=J(e.label).value,s.addEventListener("click",n=>{c.mode!=="editor"&&(n.stopPropagation(),K({type:"copy",nodeId:e.id}))}),t.append(i,s)}else t.textContent=r?.text??J(e.fallback).value,c.mode==="editor"&&t.classList.add("g-missing")}else if(e.type==="countdown"){t=document.createElement("span"),t.setAttribute("role","timer"),t.style.fontVariantNumeric="tabular-nums";let r=he(e.id),i=r?.countdownAt?Date.parse(r.countdownAt):NaN;!Number.isFinite(i)&&c.mode==="editor"&&t.classList.add("g-missing");let s=()=>{if(!Number.isFinite(i)){t.textContent=r?.text??J(e.fallback).value;return}let n=Math.max(0,Math.ceil((i-Date.now())/1e3));if(!n){t.textContent=J(e.expired).value;let u=se.get(e.id);u!==void 0&&clearInterval(u),se.delete(e.id);return}let l=e.granularity,d=l==="day"?86400:l==="hour"?3600:l==="minute"?60:1;l!=="second"?t.textContent=new Intl.NumberFormat(R,{style:"unit",unit:l,unitDisplay:"short"}).format(Math.ceil(n/d)):t.textContent=[Math.floor(n/86400),Math.floor(n/3600)%24,Math.floor(n/60)%60,n%60].map(u=>String(u).padStart(2,"0")).join(":")};s(),Number.isFinite(i)&&i>Date.now()&&se.set(e.id,setInterval(s,1e3))}else if(e.type==="plan_picker"){t=document.createElement("div"),t.setAttribute("role",e.grouping?"group":"radiogroup"),t.setAttribute("aria-label",J(e.label).value),t.style.cssText="display:flex;flex-direction:column;gap:8px";let r=j?.pickers[e.id],i=e.grouping;if(!r?.options.length)E[e.id]="",t.textContent=J(e.fallback).value,c.mode==="editor"&&t.classList.add("g-missing");else{let s=typeof E[e.id]=="string"?String(E[e.id]):r.selected,n=ue[e.id];if(i){if(!n){let U=i.assignments.find(O=>O.productVersionId===s);n={period:U?.period??"month",tierId:U?.tierId??i.tiers[0].id},ue[e.id]=n}let o=i.assignments.find(U=>U.tierId===n.tierId&&U.period===n.period);s=o&&r.options.includes(o.productVersionId)?o.productVersionId:"";let f=document.createElement("div");f.setAttribute("role","radiogroup"),f.setAttribute("aria-label",`${J(i.monthLabel).value} / ${J(i.yearLabel).value}`),f.style.cssText="display:flex;gap:4px;padding:4px;border:1px solid var(--g-border);border-radius:10px";let m=["month","year"],w=m.filter(U=>i.assignments.some(O=>O.period===U&&r.options.includes(O.productVersionId))),z=U=>{n.period=U;let O=i.assignments.find(Q=>Q.tierId===n.tierId&&Q.period===U);E[e.id]=O&&r.options.includes(O.productVersionId)?O.productVersionId:"",ye(),Se(e.id)?.querySelector(`[data-product-period="${U}"]`)?.focus()};for(let U of m){let O=document.createElement("button");O.type="button",O.className=`g-btn g-btn-${U===n.period?"primary":"secondary"}`,O.style.cssText="flex:1;min-width:0;min-height:40px",O.dataset.productPeriod=U,O.setAttribute("role","radio"),O.setAttribute("aria-checked",String(U===n.period)),O.textContent=J(U==="month"?i.monthLabel:i.yearLabel).value,O.disabled=!w.includes(U),O.tabIndex=c.mode==="editor"||O.disabled?-1:U===n.period||!w.includes(n.period)&&U===w[0]?0:-1,O.addEventListener("click",Q=>{c.mode!=="editor"&&(Q.stopPropagation(),z(U))}),O.addEventListener("keydown",Q=>{if(c.mode==="editor"||!w.length)return;let ie;["ArrowRight","ArrowDown"].includes(Q.key)?ie=(w.indexOf(U)+1)%w.length:["ArrowLeft","ArrowUp"].includes(Q.key)?ie=(w.indexOf(U)-1+w.length)%w.length:Q.key==="Home"?ie=0:Q.key==="End"&&(ie=w.length-1),ie!==void 0&&(Q.preventDefault(),z(w[ie]))}),f.append(O)}t.append(f)}E[e.id]=s??"";let l=i?i.tiers.map(o=>({tier:o,id:i.assignments.find(f=>f.tierId===o.id&&f.period===n.period)?.productVersionId})):r.options.map(o=>({id:o,tier:void 0})),d=l.filter(o=>o.id&&r.options.includes(o.id)),u=i?document.createElement("div"):t;i&&(u.setAttribute("role","radiogroup"),u.setAttribute("aria-label",J(e.label).value),u.style.cssText="display:flex;flex-direction:column;gap:8px",t.append(u));let h=o=>{!o.id||!r.options.includes(o.id)||(i&&o.tier&&(n.tierId=o.tier.id),E[e.id]=o.id,ye(),Se(e.id)?.querySelector(`[data-plan-id="${o.id}"]`)?.focus())};for(let o of l){let f=o.id?j.plans[o.id]:void 0,m=!!f&&r.options.includes(o.id),w=document.createElement("button");w.type="button",w.className="g-btn g-btn-secondary",w.style.cssText="width:100%;text-align:start;min-height:44px",w.setAttribute("role","radio");let z=i?o.tier?.id===n.tierId:o.id===s;w.setAttribute("aria-checked",String(z)),w.disabled=!m,w.tabIndex=c.mode==="editor"||!m?-1:z||!s&&o===d[0]?0:-1,o.id&&(w.dataset.planId=o.id),o.tier&&(w.dataset.productTier=o.tier.id);let U=o.id?j.nodes[e.id]?.byPlan?.[o.id]?.price:void 0;w.textContent=m?`${o.tier?.name??f.name} \xB7 ${U?.current??f.price}${U?.period??f.period}`:`${o.tier?.name??""} \xB7 ${J(i?.unavailableLabel??e.fallback).value}`,z&&(w.style.borderColor="var(--g-primary)",w.style.boxShadow="inset 0 0 0 1px var(--g-primary)",e.states?.selected&&Le(w,{type:"text",id:e.id,text:e.label,variant:"body",style:e.states.selected},null)),w.addEventListener("click",O=>{c.mode==="editor"||!m||(O.stopPropagation(),h(o))}),w.addEventListener("keydown",O=>{if(c.mode==="editor"||!d.length)return;let Q=d.indexOf(o),ie;["ArrowRight","ArrowDown"].includes(O.key)?ie=(Q+1)%d.length:["ArrowLeft","ArrowUp"].includes(O.key)?ie=(Q-1+d.length)%d.length:O.key==="Home"?ie=0:O.key==="End"&&(ie=d.length-1),ie!==void 0&&(O.preventDefault(),h(d[ie]))}),u.append(w)}if(i&&!s){let o=document.createElement("p");o.setAttribute("role","status"),o.textContent=J(i.unavailableLabel).value,t.append(o)}}}else if(e.type==="divider")t=document.createElement("hr"),t.className="g-divider";else if(e.type==="spacer")t=document.createElement("div"),t.setAttribute("aria-hidden","true"),t.style.flex="0 0 auto",t.style.width=t.style.height=`${C[e.size]??0}px`;else if(e.type==="custom_html"){t=document.createElement("div"),t.className="g-custom";let r=t.attachShadow({mode:"open"}),i=e.html[R],s=i&&i.trim()?i:e.html[L?.strings.defaultLocale??""]??"",n=he(e.id);n?.html!==void 0?s=n.html:s.includes("{{")&&c.mode==="live"&&(s=J(e.fallback??"").value.replace(/[&<>"']/g,o=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[o])),(n?.missing?.length||!n&&s.includes("{{"))&&c.mode==="editor"&&t.classList.add("g-missing"),!(i&&i.trim())&&c.mode==="editor"&&t.classList.add("g-missing");let l=document.createElement("style"),d="@media(prefers-reduced-motion:reduce){:host,:host::before,:host::after,*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}";l.textContent=`:host{display:block}${d}@layer indiana-accessibility{${d}}${e.css}`;let u=document.createElement("div");u.innerHTML=s,r.append(l,u);for(let h of u.querySelectorAll("img"))h.addEventListener("load",be)}else return null;return e.style&&Le(t,e,a),t.dataset.gNode=e.id,t.dataset.gLabel=Tt(e),t}function Ot(e,a){let t=a.interaction,r=[...e.children];e.setAttribute("aria-label",J(t.label).value);let i=$?.bindings.find(n=>n.componentId===a.id),s=i?{id:i.key,source:i.componentId,required:i.required}:void 0;if(s){let n=document.createElement("p");n.className="g-text g-body",n.textContent=J(t.label).value+(s.required?" *":""),e.prepend(n),s.required&&e.setAttribute("aria-required","true")}if(t.type==="input"){let n=document.createElement("input");n.type=t.keyboard,n.maxLength=t.maxLength,n.autocomplete="off",n.setAttribute("aria-label",J(t.label).value),n.setAttribute("aria-required",String(!!s?.required)),n.value=typeof E[a.id]=="string"?String(E[a.id]):"",n.style.cssText="box-sizing:border-box;width:100%;min-height:44px;padding:10px 14px;border:1px solid var(--g-border);border-radius:8px;background:var(--g-surface);color:var(--g-text);font:inherit",n.disabled=c.mode!=="live",n.addEventListener("input",()=>{E[a.id]=n.value,Pe(a.id,n.value)}),e.append(n);return}if(!(c.mode!=="live"||!r.length&&t.type!=="toggle")){if(t.type==="multiselect"){e.setAttribute("role","group"),e.dataset.gMin=String(t.min);let n=a.children.filter(u=>!u.hidden),l=new Set(Array.isArray(E[a.id])?E[a.id]:[]),d=()=>r.forEach((u,h)=>{let o=l.has(n[h].id);u.setAttribute("aria-checked",String(o)),u.setAttribute("aria-disabled",String(!o&&l.size>=t.max)),u.style.outline=o?"2px solid var(--g-primary)":"",u.style.outlineOffset="-2px"});r.forEach((u,h)=>{u.setAttribute("role","checkbox"),u.tabIndex=0,u.setAttribute("aria-label",u.textContent?.trim()||String(h+1)),u.style.cursor="pointer";let o=()=>{let f=n[h].id;if(l.has(f))l.delete(f);else if(l.size<t.max)l.add(f);else return;let m=n.filter(w=>l.has(w.id)).map(w=>w.id);E[a.id]=m,d(),Pe(a.id,m)};u.addEventListener("click",f=>{f.stopPropagation(),o()}),u.addEventListener("keydown",f=>{[" ","Enter"].includes(f.key)&&(f.preventDefault(),f.stopPropagation(),o())})}),d();return}if(t.type==="select"){e.setAttribute("role","radiogroup");let n=a.children.filter(h=>!h.hidden),l=p(a)?a.interaction.pickerId:void 0,d=n.findIndex(h=>l?h.type==="stack"&&h.bind?.plan===E[l]:h.id===E[a.id]);!l&&d<0&&!s?.required&&(d=Math.min(t.defaultIndex,r.length-1));let u=(h,o=!1,f=!0)=>{if(l&&f&&h>=0){let m=n[h],w=m.type==="stack"?m.bind?.plan:void 0;if(!w||!j?.pickers[l]?.options.includes(w))return;E[a.id]=m.id,E[l]=w,ye(),o&&q.querySelector(`[data-g-node="${m.id}"]`)?.focus({preventScroll:!0});return}d=h,h>=0&&(E[a.id]=n[h].id),f&&h>=0&&Pe(a.id,n[h].id),r.forEach((m,w)=>{m.setAttribute("aria-checked",String(w===h)),m.tabIndex=w===(h<0?0:h)?0:-1,m.style.cssText="";let z=n[w];z.type==="stack"&&(m.style.alignItems=v[z.align]??"stretch",m.style.justifyContent=N[z.justify]??"flex-start"),z.style&&Le(m,z,a),w===h&&(t.selectedStyle&&Le(m,{...z,style:t.selectedStyle},a),z.type==="stack"&&z.states?.selected&&Le(m,{...z,style:z.states.selected},a),!t.selectedStyle?.border&&!(z.type==="stack"&&z.states?.selected?.border)&&(m.style.outline="2px solid var(--g-primary)",m.style.outlineOffset="-2px")),m.style.cursor="pointer"}),o&&h>=0&&r[h].focus()};r.forEach((h,o)=>{if(h.setAttribute("role","radio"),l){let f=n[o],m=f.type==="stack"?f.bind?.plan:void 0;h.setAttribute("aria-disabled",String(!m||!j?.pickers[l]?.options.includes(m)))}h.setAttribute("aria-label",h.textContent?.trim()||String(o+1)),h.addEventListener("click",f=>{f.stopPropagation(),u(o)}),h.addEventListener("keydown",f=>{let m=f.key;if(!["ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"," ","Enter"].includes(m))return;f.preventDefault(),f.stopPropagation();let w=d<0?o:d;u(m==="Home"?0:m==="End"?r.length-1:m==="ArrowRight"||m==="ArrowDown"?(w+1)%r.length:m==="ArrowLeft"||m==="ArrowUp"?(w+r.length-1)%r.length:o,!0)})}),u(d,!1,!1)}else if(t.type==="tabs"){let n=a.children.filter(o=>!o.hidden),l=document.createElement("div");l.setAttribute("role","tablist"),l.setAttribute("aria-label",J(t.label).value),l.style.cssText="display:flex;gap:4px;padding:4px;border:1px solid var(--g-border);border-radius:12px";let d=r.map((o,f)=>{let m=document.createElement("button");return m.type="button",m.setAttribute("role","tab"),m.textContent=je(n[f])||String(f+1),m.style.cssText="flex:1;min-width:0;min-height:44px;padding:8px 16px;border:0;border-radius:8px;font:inherit;cursor:pointer",o.id=`g-${a.id}-${n[f].id}`,o.setAttribute("role","tabpanel"),m.setAttribute("aria-controls",o.id),l.append(m),m}),u=(o,f=!1,m=!1)=>{if(E[a.id]=n[o].id,m&&L&&Object.keys(A(L)).length){for(let w of Object.keys(A(L)))delete E[w];ye(),f&&q.querySelector(`[data-g-node="${a.id}"] [role="tab"][aria-selected="true"]`)?.focus({preventScroll:!0});return}r.forEach((w,z)=>{w.hidden=z!==o,d[z].setAttribute("aria-selected",String(z===o)),d[z].tabIndex=z===o?0:-1,d[z].style.background=z===o?"var(--g-primary)":"transparent",d[z].style.color=z===o?"var(--g-on-primary)":"var(--g-text)"}),f&&d[o].focus(),be()};d.forEach((o,f)=>{o.addEventListener("click",m=>{m.stopPropagation(),u(f,!1,!0)}),o.addEventListener("keydown",m=>{["ArrowLeft","ArrowRight","Home","End"].includes(m.key)&&(m.preventDefault(),m.stopPropagation(),u(m.key==="Home"?0:m.key==="End"?r.length-1:(f+(m.key==="ArrowRight"?1:r.length-1))%r.length,!0,!0))})}),e.prepend(l);let h=n.findIndex(o=>o.id===E[a.id]);u(h>=0?h:Math.min(t.defaultIndex,r.length-1))}else if(t.type==="toggle"){let n=document.createElement("button");n.type="button",n.setAttribute("role","switch"),n.className="g-btn g-btn-secondary",n.style.cssText="display:flex;align-items:center;justify-content:space-between;gap:16px;color:var(--g-text)";let l=document.createElement("span");l.textContent=J(t.label).value;let d=document.createElement("span");d.setAttribute("aria-hidden","true"),d.style.cssText="position:relative;display:block;flex:none;width:44px;height:24px;border-radius:12px;background:var(--g-border)";let u=document.createElement("span");u.style.cssText="position:absolute;top:3px;left:3px;width:18px;height:18px;border-radius:50%;background:#fff;box-shadow:0 1px 3px #0003",d.append(u),n.append(l,d);let h=(o,f=!1)=>{if(E[a.id]=o,f&&L&&Object.keys(A(L)).length){for(let m of Object.keys(A(L)))delete E[m];ye(),q.querySelector(`[data-g-node="${a.id}"] [role="switch"]`)?.focus({preventScroll:!0});return}n.setAttribute("aria-checked",String(o)),d.style.background=o?"var(--g-primary)":"var(--g-border)",u.style.left=o?"23px":"3px",u.style.background=o?"var(--g-on-primary)":"#FFFFFF",r.forEach((m,w)=>m.hidden=w!==(o?0:1)),be()};n.addEventListener("click",o=>{o.stopPropagation(),h(!E[a.id],!0),Pe(a.id,!!E[a.id])}),e.prepend(n),h(typeof E[a.id]=="boolean"?E[a.id]:t.defaultEnabled)}else{e.setAttribute("role","region"),e.setAttribute("aria-roledescription","carousel");let n=document.createElement("div");n.style.cssText="display:flex;align-items:center;justify-content:center;gap:10px";let l=document.createElement("button"),d=document.createElement("button"),u=document.createElement("span"),h=R.startsWith("zh");l.textContent="\u2190",d.textContent="\u2192",l.setAttribute("aria-label",h?"\u4E0A\u4E00\u6761\u8BC4\u4EF7":"Previous review"),d.setAttribute("aria-label",h?"\u4E0B\u4E00\u6761\u8BC4\u4EF7":"Next review");for(let f of[l,d])f.type="button",f.className="g-btn g-btn-secondary",f.style.color="var(--g-text)";u.setAttribute("aria-live","polite");let o=f=>{ne[a.id]=f,r.forEach((m,w)=>m.hidden=w!==f),u.textContent=`${f+1} / ${r.length}`,be()};l.addEventListener("click",f=>{f.stopPropagation(),o((ne[a.id]+r.length-1)%r.length)}),d.addEventListener("click",f=>{f.stopPropagation(),o((ne[a.id]+1)%r.length)}),n.append(l,u,d),e.append(n),o(ne[a.id]??0)}}}function je(e){if(e.hidden)return"";if(e.type==="text"&&(e.variant==="title"||e.variant==="heading"))return J(e.text).value;if(e.type==="stack")for(let a of e.children){let t=je(a);if(t)return t}return""}function rt(e){return e.type==="stack"&&!e.interaction&&!e.purchaseAction}function nt(e){let a=[],t=r=>{let i=j?.nodes[r.id];if(a.push(r.id,he(r.id)),i?.picker&&a.push(E[i.picker],j?.pickers[i.picker]),r.type==="text")a.push(Ie(r,"text",r.text));else if(r.type==="button")a.push(Ie(r,"label",r.label));else if(r.type==="image")a.push(Ie(r,"alt",r.alt));else if(r.type==="custom_html")a.push(X,$?.answers);else if(r.type==="customer_data")a.push(ee?.nodes[r.id]);else if(r.type==="plan_picker"){let s=j?.pickers[r.id];a.push(E[r.id],ue[r.id],s,i,s?.options.map(n=>j?.plans[n]))}else r.type==="stack"&&(r.interaction?.type!=="input"&&a.push(E[r.id],ne[r.id]),p(r)&&a.push(E[r.interaction.pickerId],j?.pickers[r.interaction.pickerId]),r.children.forEach(t))};return t(e),JSON.stringify(a)}function it(e){e.hidden||(rt(e)?e.children.forEach(it):pe.set(e.id,nt(e)))}function st(e){let a=se.get(e.id);a!==void 0&&clearInterval(a),se.delete(e.id),e.type==="stack"&&e.children.forEach(st)}function ot(e,a){if(e.hidden)return;if(rt(e)){e.children.forEach(i=>ot(i,e));return}if(pe.get(e.id)===nt(e))return;let t=Se(e.id);if(!t)return;st(e);let r=Ce(e,a);r&&t.replaceWith(r)}function jt(){let e=document.activeElement;if(!(e instanceof HTMLElement)||!q.contains(e))return;let a=e.closest("[data-g-node]");if(!a)return;let t=[];for(let r=e;r!==a;){let i=r.parentElement;if(!i)return;t.unshift(Array.prototype.indexOf.call(i.children,r)),r=i}return{active:e,nodeId:a.dataset.gNode,path:t,identity:["productPeriod","planId","productTier","gDataFocus"].map(r=>[r,e.dataset[r]]).find(([,r])=>r!==void 0),selection:e instanceof HTMLInputElement&&e.selectionStart!==null?{start:e.selectionStart,end:e.selectionEnd,direction:e.selectionDirection}:void 0}}function Ft(e){if(!e||e.active.isConnected)return;let a=Se(e.nodeId);if(!a)return;let t=a;if(e.identity){let[r,i]=e.identity;t=[...a.querySelectorAll("*")].find(s=>s.dataset[r]===i)}else for(let r of e.path)t=t?.children[r];!t||t.hasAttribute("disabled")||(t.focus({preventScroll:!0}),e.selection&&t instanceof HTMLInputElement&&["text","search","tel","url","password"].includes(t.type)&&t.setSelectionRange(e.selection.start,e.selection.end,e.selection.direction??void 0))}function ye(e=!1){if(!L)return;let a=e?void 0:jt(),t=L.pages.find(s=>s.id===(M??L.initialPageId))??L.pages[0];M=t.id,j&&Object.assign(E,I({...L,pages:[t]},Xe(),j));let r=s=>{if(s.type==="stack"&&s.children.forEach(r),s.type!=="plan_picker"||!s.grouping)return;let n=s.grouping,l=j?.pickers[s.id],d=ue[s.id];if(!d){let h=n.assignments.find(o=>o.productVersionId===(E[s.id]??l?.selected));d={period:h?.period??"month",tierId:h?.tierId??n.tiers[0].id},ue[s.id]=d}let u=n.assignments.find(h=>h.tierId===d.tierId&&h.period===d.period);E[s.id]=u&&l?.options.includes(u.productVersionId)?u.productVersionId:""};if(r(t.root),e||le!==t){se.forEach(l=>clearInterval(l)),se.clear(),pe.clear(),q.style.cssText="",Mt(t.theme?{...L,theme:t.theme}:L);let s=R.split("-")[0];document.documentElement.lang=R,document.documentElement.dir=["ar","he","fa","ur"].includes(s)?"rtl":"ltr",q.dataset.gPresentation=L.presentation.type;let n=Ce(t.root,null);q.replaceChildren(...n?[n]:[]),le=t}else ot(t.root,null);it(t.root),Ft(a),q.dataset.gPage=t.id,c.mode==="live"&&K({type:"page",pageId:t.id}),Ue(),Fe();let i=Math.ceil(q.getBoundingClientRect().height);k?be():(k=!0,S=i,K({type:"rendered",height:i,label:je(t.root)||L.name}))}function be(){let e=Math.ceil(q.getBoundingClientRect().height);e!==S&&(S=e,K({type:"resize",height:e})),Ue(),Fe()}function dt(){ae||(ae=!0,window.requestAnimationFrame(()=>{ae=!1,be()}))}function Fe(){if(c.mode!=="editor")return;let e=[];for(let t of q.querySelectorAll("[data-g-node]")){let r=t.getBoundingClientRect();!r.width||!r.height||e.push({id:t.dataset.gNode,x:r.x,y:r.y,width:r.width,height:r.height})}let a=JSON.stringify(e);a!==me&&(me=a,K({type:"layout",nodes:e}))}function Se(e){return!e||!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(e)?null:q.querySelector(`[data-g-node="${e}"]`)}function ct(e,a){let t=Se(a);if(!t){e.style.display="none";return}let r=t.getBoundingClientRect();e.style.display="block",e.style.left=`${r.left+window.scrollX}px`,e.style.top=`${r.top+window.scrollY}px`,e.style.width=`${r.width}px`,e.style.height=`${r.height}px`,e.toggleAttribute("data-below",r.top<20),e.firstChild.textContent=t.dataset.gLabel??""}function Ue(){c.mode==="editor"&&(ct(de,Ee),ct(ge,Z&&Z!==Ee?Z:null))}function Me(e){for(let a of e.composedPath()){if(a instanceof HTMLElement&&a.dataset.gNode)return a.dataset.gNode;if(a===q)break}return null}function Ut(e){if(e.isTrusted){if(c.mode==="editor"){e.preventDefault(),e.stopPropagation(),K({type:"select",id:Me(e)});return}for(let a of e.composedPath()){if(!(a instanceof HTMLElement))continue;let t=a.dataset.gAction??(a.tagName==="BUTTON"?a.getAttribute("data-grow-action"):null);if(t&&!a.disabled){e.preventDefault();let r=L?.actions.find(i=>i.id===t);if(r?.type==="navigate"){if(M=r.pageId,L)for(let i of Object.keys(A(L)))delete E[i];ye(),q.querySelector("h1,h2")?.focus({preventScroll:!0});return}K({type:"action",actionId:t,nodeId:Me(e)??void 0,...Object.keys(E).length?{selection:Xe()}:{},...$?{answers:tt()}:{}});return}if(a===q)return}}}function lt(e){let a=e;if(!(!a||a.channel!==c.channel))try{if(a.type==="render"){let t=c.document??a.doc;if(!t||t.kind!=="screen"||t.schemaVersion!==4||Object.hasOwn(t,"funnel")||!t.pages?.length||t.pages.length>(t.surface==="paywall"?10:1)||t.pages.some(r=>Object.hasOwn(r,"source"))||t.actions?.some(r=>!["event","close","open_url","claim_offer",...t.surface==="paywall"?["navigate"]:[]].includes(r.type)))throw new Error("Unsupported screen document; use the current Funnel runtime for flows");L=t,M=null,R=String(a.locale),te=new Set,X=a.parameters??{},$=a.serverInput,E=Object.create(null),ue=Object.create(null),j=a.capabilities,ee=a.customerData,ke.clear();for(let[r,i]of Object.entries(j?.pickers??{}))i.selected&&(E[r]=i.selected);if(a.selection&&typeof a.selection=="object"&&!Array.isArray(a.selection)){let r=a.selection,i=n=>{let l=r[n.id];if(n.type==="plan_picker"&&typeof l=="string"&&n.planIds?.includes(l)&&(E[n.id]=l),n.type==="stack"){if(n.interaction?.type==="toggle"&&typeof l=="boolean"&&(E[n.id]=l),n.interaction&&["select","tabs"].includes(n.interaction.type)&&typeof l=="string"&&n.children.some(d=>d.id===l)&&(E[n.id]=l),p(n)){let d=r[n.interaction.pickerId];typeof d=="string"&&n.children.some(u=>u.type==="stack"&&u.bind?.plan===d)&&(E[n.interaction.pickerId]=d)}n.children.forEach(i)}};L.pages.forEach(n=>i(n.root));let s=r.__page;typeof s=="string"&&L.pages.some(n=>n.id===s)&&(M=s)}for(let r of $?.bindings??[])Object.hasOwn($.answers,r.key)&&(E[r.componentId]=$.answers[r.key],te.add(r.componentId));ne=Object.create(null),R=String(a.locale),ye(!0)}else if(a.type==="capabilities"){j=a.capabilities;for(let[t,r]of Object.entries(j.pickers))!ue[t]&&E[t]===void 0&&(E[t]=r.selected??"");ye()}else a.type==="customer-data"?Ht(a.data):a.type==="restore-action-focus"&&c.mode==="live"?[...q.querySelectorAll("button[data-g-node]")].find(t=>t.dataset.gNode===a.nodeId&&!t.disabled)?.focus({preventScroll:!0}):a.type==="highlight"&&c.mode==="editor"&&(Z=a.hoverId??null,Ee=a.selectedId??null,Ue())}catch(t){K({type:"error",message:t instanceof Error?t.message:"render failed"})}}let pt=document.createElement("style");if(pt.textContent=x,document.head.append(pt),document.body.append(q),c.mode==="editor"){document.body.dataset.gEditor="",document.body.append(ge,de),document.addEventListener("mouseover",a=>{let t=Me(a);t!==ve&&(ve=t,K({type:"hover",id:t}))}),document.documentElement.addEventListener("mouseleave",()=>{ve!==null&&(ve=null,K({type:"hover",id:null}))}),document.addEventListener("dblclick",a=>{let t=Me(a);t&&a.isTrusted&&K({type:"edit",id:t})}),document.addEventListener("click",a=>{q.contains(a.target)||K({type:"select",id:null})});let e=(a,t)=>{if(!a.isTrusted)return;let r=a.metaKey||a.ctrlKey,i=a.key;(i===" "||t==="down"&&(["Delete","Backspace","Escape"].includes(i)||r&&/^[zysdcvg0=+-]$/i.test(i)))&&((r||i===" ")&&a.preventDefault(),K({type:"key",key:{key:i,phase:t,meta:a.metaKey,ctrl:a.ctrlKey,shift:a.shiftKey,alt:a.altKey}}))};document.addEventListener("keydown",a=>e(a,"down")),document.addEventListener("keyup",a=>e(a,"up")),document.addEventListener("wheel",a=>{!a.isTrusted||!(a.ctrlKey||a.metaKey)||(a.preventDefault(),K({type:"zoom",delta:a.deltaY}))},{passive:!1})}q.addEventListener("click",Ut),document.addEventListener("keydown",e=>{e.key==="Escape"&&e.isTrusted&&K({type:"escape"})}),typeof ResizeObserver=="function"&&new ResizeObserver(dt).observe(q),window.addEventListener("resize",dt),c.mode==="editor"&&window.addEventListener("scroll",Fe),window.addEventListener("message",e=>{e.source===y&&lt(e.data)}),T.__indianaReceive=lt,K(c.document?{type:"ready",document:c.document}:{type:"ready"})}var Yt=`(${Ze.toString()})(JSON.parse(document.getElementById("grow-renderer-boot").textContent))`;function _t(c,p){let A=JSON.stringify(c).replace(/</g,"\\u003c");return`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'nonce-${p}'; style-src 'unsafe-inline'; img-src https: data:; connect-src 'none'; font-src 'none'; media-src 'none'; frame-src 'none'; base-uri 'none'; form-action 'none'"></head><body><script type="application/json" id="grow-renderer-boot">${A}<\/script><script nonce="${p}">${Yt}<\/script></body></html>`}function Xt(){return`(() => {
171
+ `,E=null,U,G=new Set,O,te,ne=new Map,ce=new Map,ue,J={},C=null,A=Object.create(null),ie=Object.create(null),ge=Object.create(null),ae="",j=!1,v=-1,k=!1,se="",fe=null,Y=null,ve=null,V=document.createElement("div");V.id="g-card";let ke=document.createElement("div"),pe=document.createElement("div");ke.className=pe.className="g-box",pe.dataset.kind="select",ke.append(document.createElement("span")),pe.append(document.createElement("span"));function B(e){let a={...e,channel:c.channel};try{m.postMessage(a,c.parentOrigin)}catch{}}function Se(e){let a=parseInt(e.slice(1),16);return[a>>16&255,a>>8&255,a&255]}function Pe(e,a,t){let r=Se(e),i=Se(a),s=r.map((n,l)=>Math.round(n*t+i[l]*(1-t)));return`rgb(${s[0]},${s[1]},${s[2]})`}function Ct(e){let[a,t,r]=Se(e).map(i=>{let s=i/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4});return .2126*a+.7152*t+.0722*r}function Ie(e){return typeof e!="string"?"":e.startsWith("#")?e:`var(--g-${e==="background"?"bg":e})`}function Tt(e){let a=e.theme,t=document.documentElement.style,r=Ct(a.primary),i=(r+.05)/.05>1.05/(r+.05)?"#111318":"#FFFFFF";t.setProperty("--g-primary",a.primary),t.setProperty("--g-on-primary",i),t.setProperty("--g-bg",a.background),t.setProperty("--g-text",a.text),t.setProperty("--g-muted",Pe(a.text,a.background,.62)),t.setProperty("--g-surface",Pe(a.text,a.background,.05)),t.setProperty("--g-border",Pe(a.text,a.background,.16)),t.setProperty("--g-focus",Pe(a.primary,a.background,.45)),t.setProperty("--g-radius",`${N[a.radius]??8}px`),t.setProperty("--g-font",S[a.font]??S.system),t.setProperty("--g-edit","#2C3C96")}function K(e){let a=E?.strings.locales[ae]?.[e];return a&&a.trim()?{value:a,missing:!1}:{value:E?.strings.locales[E.strings.defaultLocale]?.[e]??"",missing:!0}}function he(e){let a=O?.nodes[e];if(!a)return;let t=a.picker?A[a.picker]??O?.pickers[a.picker]?.selected:void 0;if(!(a.picker&&t===""))return typeof t=="string"?a.byPlan?.[t]??a.base:a.base}function Qe(){return{...E?.surface==="paywall"&&C?{__page:C}:{},...Object.fromEntries(Object.entries(A).filter(e=>!Array.isArray(e[1])))}}function Le(e,a,t){let r=he(e.id),i=r?.[a],s=i!==void 0?{value:i,missing:!!r?.missing?.length}:K(t);if(c.mode==="live"&&U){let n=!1,l=s.value.replace(/\{\{\s*(input|params)\.([a-zA-Z][a-zA-Z0-9_.-]{0,63})\s*\}\}/g,(d,u,w)=>{let o=u==="params"?J[w]:U?.answers[w];return o==null||o===""||Array.isArray(o)&&!o.length?(n=!0,""):Array.isArray(o)?o.join(", "):String(o)});if(n)return{value:e.fallback?K(e.fallback).value:"",missing:!0};if(!l.includes("{{"))return{value:l,missing:s.missing}}return i!==void 0?s:s.value.includes("{{")&&c.mode==="live"?{value:e.fallback?K(e.fallback).value:"",missing:!0}:{value:s.value,missing:s.missing||s.value.includes("{{")}}function $t(e){if(e.name)return e.name;let a=c.editorMessages?.nodeTypes?.[e.type];return c.mode==="editor"&&typeof a=="string"?a:{stack:"\u5BB9\u5668",text:"\u6587\u672C",image:"\u56FE\u7247",button:"\u6309\u94AE",divider:"\u5206\u9694\u7EBF",spacer:"\u7559\u767D",custom_html:"\u81EA\u5B9A\u4E49 HTML",price:"\u4EF7\u683C",coupon_code:"\u4F18\u60E0\u7801",countdown:"\u5012\u8BA1\u65F6",plan_picker:"\u771F\u5B9E\u5957\u9910\u9009\u62E9"}[e.type]??e.type}function zt(e,a){if(a.type==="color")e.background="none",e.backgroundColor=Ie(a.color);else if(a.type==="linear"){let t=a.stops.map(r=>`${Ie(r.color)} ${Number(r.at)}%`).join(",");e.backgroundColor="transparent",e.backgroundImage=`linear-gradient(${Number(a.angle)}deg,${t})`}else if(a.type==="image"&&typeof a.src=="string"){let t=/^data:image\/(?:svg\+xml|jpeg|png);base64,[A-Za-z0-9+/]+={0,2}$/.test(a.src)?a.src:a.src.replace(/[^A-Za-z0-9\-._~:/?#[\]@!$&*+;=%]/gu,i=>i.length===1&&i.charCodeAt(0)<128?`%${i.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`:encodeURIComponent(i));e.backgroundImage=`url("${t}")`;let r=a.position;e.backgroundPosition=r?`${r.x}% ${r.y}%`:"center",e.backgroundSize=a.fit==="contain"?"contain":"cover",e.backgroundRepeat="no-repeat"}}function et(e){return`${Number(e.top)}px ${Number(e.right)}px ${Number(e.bottom)}px ${Number(e.left)}px`}function tt(e,a,t,r,i){if(a===void 0)return;let s=r?.direction??"vertical",n=s!=="overlay"&&t==="width"==(s==="horizontal"),l=t==="width"?"minWidth":"minHeight";a==="fill"?s==="overlay"?(e.style[t]="100%",e.style[t==="width"?"justifySelf":"alignSelf"]="stretch"):n?(e.style.flex="1 1 0",e.style[l]="0"):(e.style.alignSelf="stretch",e.style[t]="auto"):a==="fit"?(e.style[t]="fit-content",t==="width"&&(e.style.maxWidth="100%"),!n&&s!=="overlay"&&(!r||r.align==="stretch")&&(e.style.alignSelf=i==="center"?"center":i==="end"?"flex-end":"flex-start")):typeof a=="number"&&(e.style[t]=`${a}px`,t==="width"&&(e.style.maxWidth="100%"),n&&(e.style.flex="0 0 auto"))}function De(e,a,t){let r=a.style,i=r.text??{},s=e.style;if(a.type==="customer_data"&&(i.font&&s.setProperty("--g-data-display-font",S[String(i.font)]??S.system),a.data.source==="membership"&&(typeof i.size=="number"&&s.setProperty("--g-data-display-size",`clamp(${Math.min(i.size,28)}px, ${i.size/12}vw, ${i.size}px)`),typeof i.weight=="number"&&s.setProperty("--g-data-display-weight",String(i.weight)))),a.type==="customer_data"&&a.data.source==="credit_balance"&&(typeof i.size=="number"&&s.setProperty("--g-data-number-size",`clamp(${Math.min(i.size,48)}px, ${i.size/10}vw, ${i.size}px)`),i.font&&s.setProperty("--g-data-number-font",S[String(i.font)]??S.system),typeof i.weight=="number"&&s.setProperty("--g-data-number-weight",String(i.weight))),a.type==="customer_data"&&i.color){let u=Ie(i.color);s.setProperty("--g-data-ink",u),s.setProperty("--g-data-muted",`color-mix(in srgb, ${u} 72%, transparent)`),s.setProperty("--g-data-line",`color-mix(in srgb, ${u} 20%, transparent)`),s.setProperty("--g-data-surface",`color-mix(in srgb, ${u} 8%, transparent)`)}r.padding&&(s.padding=et(r.padding)),r.margin&&(s.margin=et(r.margin)),typeof r.gap=="number"&&a.type==="stack"&&(s.gap=`${r.gap}px`),r.background&&zt(s,r.background),typeof r.opacity=="number"&&(s.opacity=String(r.opacity));let n=r.shape;if(n?.type==="pill")s.borderRadius="9999px";else if(n?.type==="rect"){let u=n.radius;s.borderRadius=typeof u=="number"?`${u}px`:`${Number(u.topLeft)}px ${Number(u.topRight)}px ${Number(u.bottomRight)}px ${Number(u.bottomLeft)}px`}(r.clipContent===!0||r.clipContent!==!1&&n&&(r.background||a.type==="image"))&&(s.overflow="hidden");let l=r.border;l&&(s.border=Number(l.width)>0?`${Number(l.width)}px ${l.style==="dashed"?"dashed":"solid"} ${Ie(l.color)}`:"0");let d=r.shadow;d&&(s.boxShadow=`${Number(d.x)}px ${Number(d.y)}px ${Number(d.blur)}px ${Number(d.spread)}px ${Ie(d.color)}`),["text","button","price","coupon_code","countdown","plan_picker"].includes(a.type)&&(i.font&&(s.fontFamily=S[String(i.font)]??""),typeof i.size=="number"&&(s.fontSize=`${i.size}px`),typeof i.weight=="number"&&(s.fontWeight=String(i.weight)),typeof i.lineHeight=="number"&&(s.lineHeight=String(i.lineHeight)),typeof i.letterSpacing=="number"&&(s.letterSpacing=`${i.letterSpacing}px`),i.color&&(s.color=Ie(i.color)),i.align&&(s.textAlign=String(i.align)),i.italic&&(s.fontStyle="italic"),i.decoration&&(s.textDecoration=String(i.decoration)),i.transform&&(s.textTransform=String(i.transform))),tt(e,r.width,"width",t,i.align),tt(e,r.height,"height",t,i.align),t?.direction==="horizontal"&&r.grow!==void 0&&(s.flexGrow=String(r.grow===!0?1:r.grow===!1?0:r.grow))}function Me(e,a){if(U){let t=U.bindings.find(r=>r.componentId===e);if(!t)return;U.answers[t.key]=a,G.add(e),B({type:"answers",answers:at()});return}}function at(){let e={};for(let a of U?.bindings??[]){let t=A[a.componentId];t!==void 0&&(e[a.key]=t)}return e}function Ht(e){let a=document.createElement("section");a.className="g-data",a.dataset.layout=e.data.layout,a.dataset.source=e.data.source;let t=te?.nodes[e.id];a.dataset.status=t?.status??"idle",a.dataset.preview=String(!!t?.preview);let r=t?.status==="loading",i=ae.startsWith("zh"),s=(g,D)=>i?g:D;a.setAttribute("aria-busy",String(!!r));let n=(g,D,X)=>{let _=document.createElement(g);return _.className=D,X!==void 0&&(_.textContent=X),_},l=g=>{let D=document.createElementNS("http://www.w3.org/2000/svg","svg");D.setAttribute("viewBox","0 0 24 24"),D.setAttribute("fill","none"),D.setAttribute("stroke","currentColor"),D.setAttribute("stroke-width","1.7"),D.setAttribute("stroke-linecap","round"),D.setAttribute("stroke-linejoin","round"),D.setAttribute("aria-hidden","true"),D.classList.add("g-data-icon");let X={refresh:["M20 7v5h-5","M4 17v-5h5","M6.1 7a7 7 0 0 1 11.5-1.5L20 8M4 16l2.4 2.5A7 7 0 0 0 18 17"],down:["M7 7l10 10M7 17h10V7"],up:["M7 17L17 7M7 7h10v10"],chevron:["M6 9l6 6 6-6"],empty:["M4 8l8-4 8 4v10l-8 4-8-4V8Z","M4 8l8 4 8-4M12 12v10"],credit:["M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18Z","M12 7v10M8 12h8"]};for(let _ of X[g]){let q=document.createElementNS("http://www.w3.org/2000/svg","path");q.setAttribute("d",_),D.append(q)}return D},d=(g,D,X,_=!1,q=D)=>{let re=n("button","g-data-button",g);return re.type="button",re.disabled=_||!!r&&D!=="refresh"||!!t?.preview||c.mode!=="live",r&&D==="refresh"&&re.setAttribute("aria-disabled","true"),re.dataset.gDataFocus=`${e.id}:${q}:${X??""}`,re.addEventListener("click",le=>{!le.isTrusted||re.disabled||r||B({type:"customer-data-intent",intent:{nodeId:e.id,action:D,...X?{value:X}:{}}})}),re},u=n("div","g-data-header"),w=n("h2","g-data-heading",K(e.title).value);w.id=`g-data-title-${e.id}`,a.setAttribute("aria-labelledby",w.id);let o=n("div","g-data-controls"),h=[],y=g=>{g.hidden||(g.type==="customer_data"&&h.push(g),g.type==="stack"&&g.children.forEach(y))},x=E?.pages[0];x&&y(x.root);let T=h.every(g=>te?.nodes[g.id]?.preview),W=h.find(g=>g.data.source==="credit_balance")??h[0];t?.preview&&(!T||W?.id===e.id)&&o.append(n("span","g-data-preview",s("\u793A\u4F8B\u6570\u636E","Sample data")));let z=r?s("\u66F4\u65B0\u4E2D\u2026","Updating\u2026"):s("\u5237\u65B0","Refresh"),ee=d(z,"refresh");if(ee.replaceChildren(l("refresh")),ee.setAttribute("aria-label",z),ee.title=z,ee.classList.add("g-data-refresh"),r&&ee.classList.add("g-data-refreshing"),o.append(ee),e.data.source==="billing"&&e.data.outputs?.billing_portal&&o.append(d(t?.billingBusy?s("\u6B63\u5728\u51C6\u5907\u2026","Preparing\u2026"):s("\u7BA1\u7406\u652F\u4ED8\u65B9\u5F0F","Manage payment method"),"billing_portal",void 0,!!t?.billingBusy||t?.status!=="ready")),e.data.source==="credit_balance"&&(w.prepend(l("credit")),t?.resources.length===1&&w.append(n("span","g-data-resource-label",t.resources[0].name)),t?.updatedAt)){let g=n("time","g-data-updated",`${s("\u66F4\u65B0\u4E8E","Updated")} ${new Intl.DateTimeFormat(ae,{timeStyle:"short"}).format(new Date(t.updatedAt))}`);g.dateTime=t.updatedAt,g.title=new Intl.DateTimeFormat(ae,{dateStyle:"medium",timeStyle:"short"}).format(new Date(t.updatedAt)),o.prepend(g)}if(u.append(w,o),a.append(u),!t||t.source!==e.data.source)return a.append(n("p","g-data-empty",s("\u8FDE\u63A5\u5BA2\u6237\u6570\u636E\u540E\u663E\u793A\u6B64\u5185\u5BB9\u3002","Connect customer data to display this content."))),a;if(t.errorMessage){let g=n("div","g-data-error",t.errorMessage);g.setAttribute("role","alert"),a.append(g);let D=n("div","g-data-recovery");D.append(d(s("\u91CD\u8BD5","Retry"),"refresh")),a.append(D)}if(t.membershipResult){let g=n("p","g-data-note",t.membershipResult);g.setAttribute("role","status"),a.append(g)}if(t.membershipReview){let g=t.membershipReview,D=n("section","g-data-resource");D.dataset.gDataReview="",D.setAttribute("aria-label",g.title),D.setAttribute("aria-busy",String(!!t.membershipBusy));let X=n("h3","g-data-row-label",g.title);X.tabIndex=-1,D.append(X);let _=n("dl","g-data-facts");for(let re of g.facts){let le=n("div","");le.append(n("dt","",re.label),n("dd","",re.value)),_.append(le)}D.append(_,n("p","g-data-note",g.note));let q=n("div","g-data-controls");q.append(d(s("\u8FD4\u56DE","Back"),"membership_dismiss",void 0,!!t.membershipBusy),d(t.membershipBusy?s("\u6B63\u5728\u5904\u7406\u2026","Processing\u2026"):s("\u786E\u8BA4","Confirm"),"membership_confirm",void 0,!!t.membershipBusy)),D.append(q),a.append(D)}if(t.stale&&(t.resources.length||t.rows.length)&&a.append(n("p",r?"g-data-live-status":"g-data-note",r?s("\u6B63\u5728\u66F4\u65B0\u8D26\u6237\u6570\u636E\u3002","Updating account data."):s("\u663E\u793A\u4E0A\u6B21\u8BFB\u53D6\u7684\u7ED3\u679C\uFF0C\u6B63\u5728\u7B49\u5F85\u66F4\u65B0\u3002","Showing the last result while awaiting an update."))),r&&!t.resources.length&&!t.rows.length){let g=n("div","g-data-skeleton");if(g.setAttribute("aria-hidden","true"),e.data.source==="credit_balance")g.append(n("span","g-data-skeleton-line g-data-skeleton-value"),n("span","g-data-skeleton-line g-data-skeleton-meta"));else{let X=Math.min(e.data.pageSize,e.data.layout==="compact"?2:4);for(let _=0;_<X;_++){let q=n("div","g-data-skeleton-row");q.append(n("span","g-data-skeleton-line"),n("span","g-data-skeleton-line")),g.append(q)}}let D=n("p","g-data-live-status",s("\u6B63\u5728\u8BFB\u53D6\u8D26\u6237\u6570\u636E\u2026","Loading account data\u2026"));return D.setAttribute("role","status"),a.append(g,D),a}let oe={credit_transactions:[["all","\u5168\u90E8\u8BB0\u5F55","All activity"],["consume","\u6D88\u8D39","Usage"],["reserve","\u9884\u6263","Reserved"],["confirm","\u786E\u8BA4\u6263\u8D39","Confirmed"],["release","\u91CA\u653E","Released"],["refund","\u9000\u56DE","Refund"]],credit_pack_orders:[["all","\u5168\u90E8\u8BA2\u5355","All orders"],["pending","\u7B49\u5F85\u4ED8\u6B3E","Pending"],["paid","\u5DF2\u4ED8\u6B3E","Paid"],["expired","\u5DF2\u8FC7\u671F","Expired"],["refunded","\u5DF2\u9000\u6B3E","Refunded"],["disputed","\u4E89\u8BAE\u4E2D","Disputed"]],offer_history:[["all","\u5168\u90E8\u8BB0\u5F55","All offers"],["issued","\u53EF\u7528","Available"],["redeemed","\u5DF2\u4F7F\u7528","Redeemed"],["expired","\u5DF2\u5230\u671F","Expired"],["revoked","\u5DF2\u64A4\u9500","Revoked"]]};if(oe[e.data.source]){let g=n("select","g-data-select");g.setAttribute("aria-label",s("\u7B5B\u9009\u8BB0\u5F55","Filter records")),g.dataset.gDataFocus=`${e.id}:filter`,g.disabled=!!r||t.preview||c.mode!=="live";for(let[D,X,_]of oe[e.data.source]){let q=document.createElement("option");q.value=D,q.textContent=s(X,_),g.append(q)}g.value=t.filter,g.addEventListener("change",()=>{!g.disabled&&c.mode==="live"&&B({type:"customer-data-intent",intent:{nodeId:e.id,action:"filter",value:g.value}})}),o.prepend(g)}let gt=(g,D=!1)=>{let X=n("ul","g-data-list");if(e.data.source==="credit_transactions"&&g.length&&!D){let _=n("div","g-data-table-head");_.setAttribute("aria-hidden","true"),_.append(n("span","",s("\u8BB0\u5F55","Record")),n("span","",s("\u7C7B\u578B","Type")),n("span","",s("\u79EF\u5206","Credits"))),a.append(_)}for(let _ of g){let q=n("li","g-data-row"),re=n("div","g-data-row-main"),le=n("div","g-data-row-copy");le.append(n("p","g-data-row-label",_.label));for(let Q of _.detail)Q!==_.status&&le.append(n("div","g-data-row-detail",Q));if(e.data.source==="credit_transactions"&&!D){let Q=n("span","g-data-row-mark");Q.append(l(["Refund","\u9000\u56DE"].includes(_.status??"")?"up":"down")),re.append(Q)}if(re.append(le),q.append(re),_.status?q.append(n("div","g-data-row-status",_.status)):q.classList.add("g-data-row-no-status"),_.value?q.append(n("div","g-data-row-value",_.value)):q.classList.add("g-data-row-no-value"),_.facts.length||_.purchaseId||_.membershipActions?.length||_.billingActions?.length){let Q=n("div","g-data-row-extra"),me=n("div","g-data-facts"),we=(de,$e)=>{for(let ft of de){let mt=n("span","",ft.label);mt.append(n("strong","",ft.value)),$e.append(mt)}};if(we(_.facts.slice(0,3),me),_.facts.length>3){let de=n("details","g-data-sources");de.dataset.gDataSources=`facts:${_.id}`,de.append(n("summary","",`${e.data.source==="billing"?s("\u8D26\u5355\u8BE6\u60C5","Invoice details"):s("\u5168\u90E8\u6263\u8D39\u660E\u7EC6","All allocations")} \xB7 ${_.facts.length}`));let $e=n("div","g-data-facts");we(_.facts.slice(3),$e),de.append($e),me.append(de)}if(Q.append(me),!D)for(let de of _.billingActions??[])Q.append(d(de.label,de.action,_.id,!!t.billingBusy));if(_.purchaseId&&e.data.allowPurchase&&!D){let de=d(t.buyingId===_.purchaseId?s("\u6B63\u5728\u51C6\u5907\u2026","Preparing\u2026"):s("\u8D2D\u4E70\u79EF\u5206","Buy credits"),"buy_pack",_.purchaseId,!!t.preview||!!t.buyingId);de.classList.add("g-data-buy"),Q.append(de)}if(e.data.allowPurchase&&!D)for(let de of _.membershipActions??[])Q.append(d(de.label,"membership_preview",de.value,!!t.preview||!!t.membershipBusy||!!t.membershipReview));q.append(Q)}X.append(q)}return X};for(let g of t.resources){let D=n("article","g-data-resource");D.setAttribute("aria-label",g.name),t.resources.length>1&&D.append(n("p","g-data-name",g.name));let X=n("div","g-data-balance"),_=new Intl.NumberFormat(ae).formatToParts(1.1).find(Q=>Q.type==="decimal")?.value??".",q=g.spendable.lastIndexOf(_),re=n("strong","g-data-number",q<0?g.spendable:g.spendable.slice(0,q));q>=0&&re.append(n("span","g-data-fraction",g.spendable.slice(q))),X.append(re,n("span","g-data-unit",s("\u53EF\u7528\u79EF\u5206","Spendable credits"))),D.append(X);let le=n("div","g-data-facts");for(let[Q,me]of[[s("\u4F59\u989D","Balance"),g.available],[s("\u51BB\u7ED3","Reserved"),g.reserved]]){let we=n("span","",Q);we.append(n("strong","",me)),le.append(we)}if(g.expiry&&le.append(n("span","g-data-expiry",`${s("\u6700\u8FD1\u5230\u671F","Next expiry")} \xB7 ${g.expiry}`)),D.append(le),e.data.showSources&&g.sourceCount){let Q=n("details","g-data-sources");if(Q.dataset.gDataSources=g.key,Q.append(n("summary","",`${s("\u79EF\u5206\u6765\u6E90","Credit sources")} \xB7 ${g.sourceCount}`),gt(g.sources,!0)),Q.querySelector("summary")?.append(l("chevron")),g.hasNextSources||g.hasPreviousSources){let me=n("div","g-data-footer");me.append(n("span","",`${s("\u7B2C","Page")} ${g.sourcePage}`));let we=n("div","g-data-controls");we.append(d(s("\u4E0A\u4E00\u9875","Previous"),"sources_previous",g.key,!g.hasPreviousSources),d(s("\u4E0B\u4E00\u9875","Next"),"sources_next",g.key,!g.hasNextSources)),me.append(we),Q.append(me)}D.append(Q)}a.append(D)}if(t.rows.length&&a.append(gt(t.rows)),e.data.source==="billing_controls"&&(e.data.outputs?.billing_authorization||e.data.outputs?.billing_adjustment)){let g=n("div","g-data-controls");e.data.outputs?.billing_authorization&&g.append(d(s("\u8BBE\u7F6E\u81EA\u52A8\u4ED8\u6B3E\u6388\u6743","Set up payment authorization"),"billing_authorization")),e.data.outputs?.billing_adjustment&&g.append(d(s("\u67E5\u770B\u5F85\u786E\u8BA4\u8865\u6B3E","Review pending adjustment"),"billing_adjustment")),a.append(g)}if(!t.rows.length&&!t.resources.length&&t.status!=="error"){let g=n("p","g-data-empty",r?s("\u6B63\u5728\u8BFB\u53D6\u8D26\u6237\u6570\u636E\u2026","Loading account data\u2026"):t.status==="idle"?s("\u767B\u5F55\u540E\u67E5\u770B\u4F60\u7684\u8D26\u6237\u6570\u636E\u3002","Sign in to view your account data."):t.filter!=="all"?s("\u6CA1\u6709\u7B26\u5408\u7B5B\u9009\u6761\u4EF6\u7684\u8BB0\u5F55\u3002","No records match this filter."):e.data.source==="credit_pack_orders"?s("\u6682\u65E0\u8D2D\u4E70\u8BB0\u5F55","No purchases yet"):e.data.source==="credit_balance"?s("\u6682\u65E0\u79EF\u5206\u6765\u6E90","No credit balances yet"):e.data.source==="membership"?s("\u6682\u65E0\u4F1A\u5458\u65B9\u6848","No memberships yet"):e.data.source==="customer_plans"?s("\u6682\u65E0\u53EF\u9009\u5957\u9910","No plans available"):e.data.source==="credit_packs"?s("\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u79EF\u5206\u5305","No credit packs available"):e.data.source==="billing_controls"?s("\u5C1A\u672A\u8BBE\u7F6E\u7528\u91CF\u9650\u5236\u6216\u81EA\u52A8\u4ED8\u6B3E\u6388\u6743","No usage limits or payment authorizations configured"):e.data.source==="offer_history"?s("\u6682\u65E0\u4F18\u60E0\u8BB0\u5F55","No offers yet"):e.data.source==="billing"?s("\u6682\u65E0\u8D26\u5355","No invoices yet"):s("\u8FD9\u91CC\u8FD8\u6CA1\u6709\u8BB0\u5F55\u3002","There are no records yet."));g.prepend(l("empty")),g.setAttribute("role","status"),a.append(g)}if(t.hasNext||t.hasPrevious){let g=n("div","g-data-footer");g.append(n("span","",`${s("\u7B2C","Page")} ${t.page}`));let D=n("div","g-data-controls");D.append(d(s("\u4E0A\u4E00\u9875","Previous"),"previous",void 0,!t.hasPrevious),d(s("\u4E0B\u4E00\u9875","Next"),"next",void 0,!t.hasNext)),g.append(D),a.append(g)}return t.updatedAt&&e.data.source!=="credit_balance"&&a.append(n("p","g-data-note g-data-updated",`${s("\u6570\u636E\u66F4\u65B0\u4E8E","Updated")} ${new Intl.DateTimeFormat(ae,{dateStyle:"medium",timeStyle:"short"}).format(new Date(t.updatedAt))}`)),a}let Ee=new Map,Oe=new Map,rt=e=>{let a=e.target;for(let t of Ee.keys())a&&!Ae(t)?.contains(a)&&Ee.delete(t)};document.addEventListener("focusin",rt),document.addEventListener("pointerdown",rt);function Ot(e){let a=te;if(te=e,!E)return;let t=(i,s)=>{if(i.type==="stack"){i.children.forEach(x=>t(x,i));return}if(i.type!=="customer_data"||JSON.stringify(a?.nodes[i.id])===JSON.stringify(e.nodes[i.id]))return;let n=Ae(i.id);if(!n)return;let l=document.activeElement;l&&n.contains(l)&&l.dataset.gDataFocus&&Ee.set(i.id,l.dataset.gDataFocus);let d=new Set([...n.querySelectorAll("details[data-g-data-sources]")].filter(x=>x.open).map(x=>x.dataset.gDataSources)),u=Ce(i,s);if(!u)return;for(let x of u.querySelectorAll("details[data-g-data-sources]"))x.open=d.has(x.dataset.gDataSources);let w=n.scrollTop;n.replaceWith(u),u.scrollTop=w;let o=!!e.nodes[i.id]?.membershipReview&&!a?.nodes[i.id]?.membershipReview,h=!e.nodes[i.id]?.membershipReview&&!!a?.nodes[i.id]?.membershipReview;o&&Ee.get(i.id)&&Oe.set(i.id,Ee.get(i.id));let y=h?Oe.get(i.id):Ee.get(i.id);y&&[...u.querySelectorAll("[data-g-data-focus]")].find(x=>x.dataset.gDataFocus===y)?.focus({preventScroll:!0}),o&&u.querySelector("[data-g-data-review] h3")?.focus({preventScroll:!0}),h&&Oe.delete(i.id),u.animate&&e.nodes[i.id]?.status==="ready"&&!window.matchMedia("(prefers-reduced-motion:reduce)").matches&&u.animate([{opacity:.7},{opacity:1}],{duration:140,easing:"ease-out"})},r=E.pages.find(i=>i.id===C)??E.pages[0];t(r.root,null),be()}function Ce(e,a){if(e.hidden)return null;let t;if(e.type==="customer_data")t=Ht(e);else if(e.type==="stack"){t=document.createElement(e.purchaseAction?"button":"div"),e.purchaseAction&&(t.type="button",t.dataset.gAction=e.purchaseAction),t.className=`${e.purchaseAction?`g-btn g-btn-${e.buttonVariant??"primary"} `:""}g-stack ${e.direction==="horizontal"?"g-h":e.direction==="overlay"?"g-o":"g-v"}`,e.direction==="overlay"?(t.style.alignItems=H[e.align]??"stretch",t.style.justifyItems=R[e.justify]??"stretch"):(t.style.alignItems=f[e.align]??"stretch",t.style.justifyContent=P[e.justify]??"flex-start");for(let r of e.children){let i=Ce(r,e);i&&t.append(i)}if(e.interaction&&jt(t,e),e.purchaseAction&&c.mode==="live"){let r=O?.nodes[e.id],i=r?.picker;i&&(t.disabled=!O?.pickers[i]?.options.includes(String(A[i]??""))),he(e.id)?.unavailable&&(t.disabled=!0)}c.mode==="editor"&&!t.childElementCount&&(t.classList.add("g-empty"),t.dataset.gEditorPlaceholder=c.editorMessages?.emptyContainer??"\u62D6\u5165\u7EC4\u4EF6")}else if(e.type==="text"){let r=e.variant==="title"?"h1":e.variant==="heading"?"h2":"p";t=document.createElement(r),t.className=`g-text g-${e.variant}`;let i=Le(e,"text",e.text);t.textContent=i.value,i.missing&&c.mode==="editor"&&t.classList.add("g-missing")}else if(e.type==="button"){t=document.createElement("button"),t.type="button",t.className=`g-btn g-btn-${e.variant}`;let r=Le(e,"label",e.label);t.textContent=r.value,r.missing&&c.mode==="editor"&&t.classList.add("g-missing"),t.dataset.gAction=e.action;let i=O?.nodes[e.id]?.picker;if(i&&c.mode==="live"){let s=i,n=O?.pickers[s],l=A[s]??n?.selected;t.disabled=!n?.options.includes(String(l)),t.disabled&&t.setAttribute("aria-disabled","true")}c.mode==="live"&&he(e.id)?.unavailable&&(t.disabled=!0,t.setAttribute("aria-disabled","true")),c.mode==="editor"&&(t.tabIndex=-1)}else if(e.type==="image"){t=document.createElement("div"),t.className="g-img",F[e.aspect]&&(t.dataset.aspect=e.aspect,t.style.aspectRatio=F[e.aspect]);let r=document.createElement("img");r.src=e.localizedSrc?.[ae]??e.localizedSrc?.[E.strings.defaultLocale]??e.src,r.alt=Le(e,"alt",e.alt).value,r.referrerPolicy="no-referrer",r.decoding="async",r.style.objectFit=e.fit,e.position&&(r.style.objectPosition=`${e.position.x}% ${e.position.y}%`),r.addEventListener("load",be),t.append(r)}else if(e.type==="price"){t=document.createElement("div"),t.className="g-price",t.style.cssText="display:flex;align-items:baseline;gap:8px;flex-wrap:wrap;font-variant-numeric:tabular-nums";let r=he(e.id);if(!r?.price)t.textContent=r?.text??K(e.fallback).value,c.mode==="editor"&&t.classList.add("g-missing");else for(let i of["current","original","period"]){let s=r.price[i];if(!s)continue;let n=document.createElement(i==="original"?"s":"span");n.textContent=s,i==="original"&&(n.style.opacity=".6"),e.parts?.[i]&&De(n,{type:"text",id:e.id,text:e.fallback,variant:"body",style:e.parts[i]},null),t.append(n)}}else if(e.type==="coupon_code"){t=document.createElement("div"),t.style.cssText="display:flex;align-items:center;gap:12px;flex-wrap:wrap";let r=he(e.id);if(r?.code){let i=document.createElement("code");i.textContent=r.code;let s=document.createElement("button");s.type="button",s.className="g-btn g-btn-secondary",s.textContent=K(e.label).value,s.addEventListener("click",n=>{c.mode!=="editor"&&(n.stopPropagation(),B({type:"copy",nodeId:e.id}))}),t.append(i,s)}else t.textContent=r?.text??K(e.fallback).value,c.mode==="editor"&&t.classList.add("g-missing")}else if(e.type==="countdown"){t=document.createElement("span"),t.setAttribute("role","timer"),t.style.fontVariantNumeric="tabular-nums";let r=he(e.id),i=r?.countdownAt?Date.parse(r.countdownAt):NaN;!Number.isFinite(i)&&c.mode==="editor"&&t.classList.add("g-missing");let s=()=>{if(!Number.isFinite(i)){t.textContent=r?.text??K(e.fallback).value;return}let n=Math.max(0,Math.ceil((i-Date.now())/1e3));if(!n){t.textContent=K(e.expired).value;let u=ne.get(e.id);u!==void 0&&clearInterval(u),ne.delete(e.id);return}let l=e.granularity,d=l==="day"?86400:l==="hour"?3600:l==="minute"?60:1;l!=="second"?t.textContent=new Intl.NumberFormat(ae,{style:"unit",unit:l,unitDisplay:"short"}).format(Math.ceil(n/d)):t.textContent=[Math.floor(n/86400),Math.floor(n/3600)%24,Math.floor(n/60)%60,n%60].map(u=>String(u).padStart(2,"0")).join(":")};s(),Number.isFinite(i)&&i>Date.now()&&ne.set(e.id,setInterval(s,1e3))}else if(e.type==="plan_picker"){t=document.createElement("div"),t.setAttribute("role",e.grouping?"group":"radiogroup"),t.setAttribute("aria-label",K(e.label).value),t.style.cssText="display:flex;flex-direction:column;gap:8px";let r=O?.pickers[e.id],i=e.grouping;if(!r?.options.length)A[e.id]="",t.textContent=K(e.fallback).value,c.mode==="editor"&&t.classList.add("g-missing");else{let s=typeof A[e.id]=="string"?String(A[e.id]):r.selected,n=ge[e.id];if(i){if(!n){let W=i.assignments.find(z=>z.productVersionId===s);n={period:W?.period??"month",tierId:W?.tierId??i.tiers[0].id},ge[e.id]=n}let o=i.assignments.find(W=>W.tierId===n.tierId&&W.period===n.period);s=o&&r.options.includes(o.productVersionId)?o.productVersionId:"";let h=document.createElement("div");h.setAttribute("role","radiogroup"),h.setAttribute("aria-label",`${K(i.monthLabel).value} / ${K(i.yearLabel).value}`),h.style.cssText="display:flex;gap:4px;padding:4px;border:1px solid var(--g-border);border-radius:10px";let y=["month","year"],x=y.filter(W=>i.assignments.some(z=>z.period===W&&r.options.includes(z.productVersionId))),T=W=>{n.period=W;let z=i.assignments.find(ee=>ee.tierId===n.tierId&&ee.period===W);A[e.id]=z&&r.options.includes(z.productVersionId)?z.productVersionId:"",ye(),Ae(e.id)?.querySelector(`[data-product-period="${W}"]`)?.focus()};for(let W of y){let z=document.createElement("button");z.type="button",z.className=`g-btn g-btn-${W===n.period?"primary":"secondary"}`,z.style.cssText="flex:1;min-width:0;min-height:40px",z.dataset.productPeriod=W,z.setAttribute("role","radio"),z.setAttribute("aria-checked",String(W===n.period)),z.textContent=K(W==="month"?i.monthLabel:i.yearLabel).value,z.disabled=!x.includes(W),z.tabIndex=c.mode==="editor"||z.disabled?-1:W===n.period||!x.includes(n.period)&&W===x[0]?0:-1,z.addEventListener("click",ee=>{c.mode!=="editor"&&(ee.stopPropagation(),T(W))}),z.addEventListener("keydown",ee=>{if(c.mode==="editor"||!x.length)return;let oe;["ArrowRight","ArrowDown"].includes(ee.key)?oe=(x.indexOf(W)+1)%x.length:["ArrowLeft","ArrowUp"].includes(ee.key)?oe=(x.indexOf(W)-1+x.length)%x.length:ee.key==="Home"?oe=0:ee.key==="End"&&(oe=x.length-1),oe!==void 0&&(ee.preventDefault(),T(x[oe]))}),h.append(z)}t.append(h)}A[e.id]=s??"";let l=i?i.tiers.map(o=>({tier:o,id:i.assignments.find(h=>h.tierId===o.id&&h.period===n.period)?.productVersionId})):r.options.map(o=>({id:o,tier:void 0})),d=l.filter(o=>o.id&&r.options.includes(o.id)),u=i?document.createElement("div"):t;i&&(u.setAttribute("role","radiogroup"),u.setAttribute("aria-label",K(e.label).value),u.style.cssText="display:flex;flex-direction:column;gap:8px",t.append(u));let w=o=>{!o.id||!r.options.includes(o.id)||(i&&o.tier&&(n.tierId=o.tier.id),A[e.id]=o.id,ye(),Ae(e.id)?.querySelector(`[data-plan-id="${o.id}"]`)?.focus())};for(let o of l){let h=o.id?O.plans[o.id]:void 0,y=!!h&&r.options.includes(o.id),x=document.createElement("button");x.type="button",x.className="g-btn g-btn-secondary",x.style.cssText="width:100%;text-align:start;min-height:44px",x.setAttribute("role","radio");let T=i?o.tier?.id===n.tierId:o.id===s;x.setAttribute("aria-checked",String(T)),x.disabled=!y,x.tabIndex=c.mode==="editor"||!y?-1:T||!s&&o===d[0]?0:-1,o.id&&(x.dataset.planId=o.id),o.tier&&(x.dataset.productTier=o.tier.id);let W=o.id?O.nodes[e.id]?.byPlan?.[o.id]?.price:void 0;x.textContent=y?`${o.tier?.name??h.name} \xB7 ${W?.current??h.price}${W?.period??h.period}`:`${o.tier?.name??""} \xB7 ${K(i?.unavailableLabel??e.fallback).value}`,T&&(x.style.borderColor="var(--g-primary)",x.style.boxShadow="inset 0 0 0 1px var(--g-primary)",e.states?.selected&&De(x,{type:"text",id:e.id,text:e.label,variant:"body",style:e.states.selected},null)),x.addEventListener("click",z=>{c.mode==="editor"||!y||(z.stopPropagation(),w(o))}),x.addEventListener("keydown",z=>{if(c.mode==="editor"||!d.length)return;let ee=d.indexOf(o),oe;["ArrowRight","ArrowDown"].includes(z.key)?oe=(ee+1)%d.length:["ArrowLeft","ArrowUp"].includes(z.key)?oe=(ee-1+d.length)%d.length:z.key==="Home"?oe=0:z.key==="End"&&(oe=d.length-1),oe!==void 0&&(z.preventDefault(),w(d[oe]))}),u.append(x)}if(i&&!s){let o=document.createElement("p");o.setAttribute("role","status"),o.textContent=K(i.unavailableLabel).value,t.append(o)}}}else if(e.type==="divider")t=document.createElement("hr"),t.className="g-divider";else if(e.type==="spacer")t=document.createElement("div"),t.setAttribute("aria-hidden","true"),t.style.flex="0 0 auto",t.style.width=t.style.height=`${M[e.size]??0}px`;else if(e.type==="custom_html"){t=document.createElement("div"),t.className="g-custom";let r=t.attachShadow({mode:"open"}),i=e.html[ae],s=i&&i.trim()?i:e.html[E?.strings.defaultLocale??""]??"",n=he(e.id);n?.html!==void 0?s=n.html:s.includes("{{")&&c.mode==="live"&&(s=K(e.fallback??"").value.replace(/[&<>"']/g,o=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[o])),(n?.missing?.length||!n&&s.includes("{{"))&&c.mode==="editor"&&t.classList.add("g-missing"),!(i&&i.trim())&&c.mode==="editor"&&t.classList.add("g-missing");let l=document.createElement("style"),d="@media(prefers-reduced-motion:reduce){:host,:host::before,:host::after,*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}";l.textContent=`:host{display:block}${d}@layer indiana-accessibility{${d}}${e.css}`;let u=document.createElement("div");u.innerHTML=s,r.append(l,u);for(let w of u.querySelectorAll("img"))w.addEventListener("load",be)}else return null;return e.style&&De(t,e,a),t.dataset.gNode=e.id,t.dataset.gLabel=$t(e),t}function jt(e,a){let t=a.interaction,r=[...e.children];e.setAttribute("aria-label",K(t.label).value);let i=U?.bindings.find(n=>n.componentId===a.id),s=i?{id:i.key,source:i.componentId,required:i.required}:void 0;if(s){let n=document.createElement("p");n.className="g-text g-body",n.textContent=K(t.label).value+(s.required?" *":""),e.prepend(n),s.required&&e.setAttribute("aria-required","true")}if(t.type==="input"){let n=document.createElement("input");n.type=t.keyboard,n.maxLength=t.maxLength,n.autocomplete="off",n.setAttribute("aria-label",K(t.label).value),n.setAttribute("aria-required",String(!!s?.required)),n.value=typeof A[a.id]=="string"?String(A[a.id]):"",n.style.cssText="box-sizing:border-box;width:100%;min-height:44px;padding:10px 14px;border:1px solid var(--g-border);border-radius:8px;background:var(--g-surface);color:var(--g-text);font:inherit",n.disabled=c.mode!=="live",n.addEventListener("input",()=>{A[a.id]=n.value,Me(a.id,n.value)}),e.append(n);return}if(!(c.mode!=="live"||!r.length&&t.type!=="toggle")){if(t.type==="multiselect"){e.setAttribute("role","group"),e.dataset.gMin=String(t.min);let n=a.children.filter(u=>!u.hidden),l=new Set(Array.isArray(A[a.id])?A[a.id]:[]),d=()=>r.forEach((u,w)=>{let o=l.has(n[w].id);u.setAttribute("aria-checked",String(o)),u.setAttribute("aria-disabled",String(!o&&l.size>=t.max)),u.style.outline=o?"2px solid var(--g-primary)":"",u.style.outlineOffset="-2px"});r.forEach((u,w)=>{u.setAttribute("role","checkbox"),u.tabIndex=0,u.setAttribute("aria-label",u.textContent?.trim()||String(w+1)),u.style.cursor="pointer";let o=()=>{let h=n[w].id;if(l.has(h))l.delete(h);else if(l.size<t.max)l.add(h);else return;let y=n.filter(x=>l.has(x.id)).map(x=>x.id);A[a.id]=y,d(),Me(a.id,y)};u.addEventListener("click",h=>{h.stopPropagation(),o()}),u.addEventListener("keydown",h=>{[" ","Enter"].includes(h.key)&&(h.preventDefault(),h.stopPropagation(),o())})}),d();return}if(t.type==="select"){e.setAttribute("role","radiogroup");let n=a.children.filter(w=>!w.hidden),l=p(a)?a.interaction.pickerId:void 0,d=n.findIndex(w=>l?w.type==="stack"&&w.bind?.plan===A[l]:w.id===A[a.id]);!l&&d<0&&!s?.required&&(d=Math.min(t.defaultIndex,r.length-1));let u=(w,o=!1,h=!0)=>{if(l&&h&&w>=0){let y=n[w],x=y.type==="stack"?y.bind?.plan:void 0;if(!x||!O?.pickers[l]?.options.includes(x))return;A[a.id]=y.id,A[l]=x,ye(),o&&V.querySelector(`[data-g-node="${y.id}"]`)?.focus({preventScroll:!0});return}d=w,w>=0&&(A[a.id]=n[w].id),h&&w>=0&&Me(a.id,n[w].id),r.forEach((y,x)=>{y.setAttribute("aria-checked",String(x===w)),y.tabIndex=x===(w<0?0:w)?0:-1,y.style.cssText="";let T=n[x];T.type==="stack"&&(y.style.alignItems=f[T.align]??"stretch",y.style.justifyContent=P[T.justify]??"flex-start"),T.style&&De(y,T,a),x===w&&(t.selectedStyle&&De(y,{...T,style:t.selectedStyle},a),T.type==="stack"&&T.states?.selected&&De(y,{...T,style:T.states.selected},a),!t.selectedStyle?.border&&!(T.type==="stack"&&T.states?.selected?.border)&&(y.style.outline="2px solid var(--g-primary)",y.style.outlineOffset="-2px")),y.style.cursor="pointer"}),o&&w>=0&&r[w].focus()};r.forEach((w,o)=>{if(w.setAttribute("role","radio"),l){let h=n[o],y=h.type==="stack"?h.bind?.plan:void 0;w.setAttribute("aria-disabled",String(!y||!O?.pickers[l]?.options.includes(y)))}w.setAttribute("aria-label",w.textContent?.trim()||String(o+1)),w.addEventListener("click",h=>{h.stopPropagation(),u(o)}),w.addEventListener("keydown",h=>{let y=h.key;if(!["ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"," ","Enter"].includes(y))return;h.preventDefault(),h.stopPropagation();let x=d<0?o:d;u(y==="Home"?0:y==="End"?r.length-1:y==="ArrowRight"||y==="ArrowDown"?(x+1)%r.length:y==="ArrowLeft"||y==="ArrowUp"?(x+r.length-1)%r.length:o,!0)})}),u(d,!1,!1)}else if(t.type==="tabs"){let n=a.children.filter(o=>!o.hidden),l=document.createElement("div");l.setAttribute("role","tablist"),l.setAttribute("aria-label",K(t.label).value),l.style.cssText="display:flex;gap:4px;padding:4px;border:1px solid var(--g-border);border-radius:12px";let d=r.map((o,h)=>{let y=document.createElement("button");return y.type="button",y.setAttribute("role","tab"),y.textContent=je(n[h])||String(h+1),y.style.cssText="flex:1;min-width:0;min-height:44px;padding:8px 16px;border:0;border-radius:8px;font:inherit;cursor:pointer",o.id=`g-${a.id}-${n[h].id}`,o.setAttribute("role","tabpanel"),y.setAttribute("aria-controls",o.id),l.append(y),y}),u=(o,h=!1,y=!1)=>{if(A[a.id]=n[o].id,y&&E&&Object.keys(I(E)).length){for(let x of Object.keys(I(E)))delete A[x];ye(),h&&V.querySelector(`[data-g-node="${a.id}"] [role="tab"][aria-selected="true"]`)?.focus({preventScroll:!0});return}r.forEach((x,T)=>{x.hidden=T!==o,d[T].setAttribute("aria-selected",String(T===o)),d[T].tabIndex=T===o?0:-1,d[T].style.background=T===o?"var(--g-primary)":"transparent",d[T].style.color=T===o?"var(--g-on-primary)":"var(--g-text)"}),h&&d[o].focus(),be()};d.forEach((o,h)=>{o.addEventListener("click",y=>{y.stopPropagation(),u(h,!1,!0)}),o.addEventListener("keydown",y=>{["ArrowLeft","ArrowRight","Home","End"].includes(y.key)&&(y.preventDefault(),y.stopPropagation(),u(y.key==="Home"?0:y.key==="End"?r.length-1:(h+(y.key==="ArrowRight"?1:r.length-1))%r.length,!0,!0))})}),e.prepend(l);let w=n.findIndex(o=>o.id===A[a.id]);u(w>=0?w:Math.min(t.defaultIndex,r.length-1))}else if(t.type==="toggle"){let n=document.createElement("button");n.type="button",n.setAttribute("role","switch"),n.className="g-btn g-btn-secondary",n.style.cssText="display:flex;align-items:center;justify-content:space-between;gap:16px;color:var(--g-text)";let l=document.createElement("span");l.textContent=K(t.label).value;let d=document.createElement("span");d.setAttribute("aria-hidden","true"),d.style.cssText="position:relative;display:block;flex:none;width:44px;height:24px;border-radius:12px;background:var(--g-border)";let u=document.createElement("span");u.style.cssText="position:absolute;top:3px;left:3px;width:18px;height:18px;border-radius:50%;background:#fff;box-shadow:0 1px 3px #0003",d.append(u),n.append(l,d);let w=(o,h=!1)=>{if(A[a.id]=o,h&&E&&Object.keys(I(E)).length){for(let y of Object.keys(I(E)))delete A[y];ye(),V.querySelector(`[data-g-node="${a.id}"] [role="switch"]`)?.focus({preventScroll:!0});return}n.setAttribute("aria-checked",String(o)),d.style.background=o?"var(--g-primary)":"var(--g-border)",u.style.left=o?"23px":"3px",u.style.background=o?"var(--g-on-primary)":"#FFFFFF",r.forEach((y,x)=>y.hidden=x!==(o?0:1)),be()};n.addEventListener("click",o=>{o.stopPropagation(),w(!A[a.id],!0),Me(a.id,!!A[a.id])}),e.prepend(n),w(typeof A[a.id]=="boolean"?A[a.id]:t.defaultEnabled)}else{e.setAttribute("role","region"),e.setAttribute("aria-roledescription","carousel");let n=document.createElement("div");n.style.cssText="display:flex;align-items:center;justify-content:center;gap:10px";let l=document.createElement("button"),d=document.createElement("button"),u=document.createElement("span"),w=ae.startsWith("zh");l.textContent="\u2190",d.textContent="\u2192",l.setAttribute("aria-label",w?"\u4E0A\u4E00\u6761\u8BC4\u4EF7":"Previous review"),d.setAttribute("aria-label",w?"\u4E0B\u4E00\u6761\u8BC4\u4EF7":"Next review");for(let h of[l,d])h.type="button",h.className="g-btn g-btn-secondary",h.style.color="var(--g-text)";u.setAttribute("aria-live","polite");let o=h=>{ie[a.id]=h,r.forEach((y,x)=>y.hidden=x!==h),u.textContent=`${h+1} / ${r.length}`,be()};l.addEventListener("click",h=>{h.stopPropagation(),o((ie[a.id]+r.length-1)%r.length)}),d.addEventListener("click",h=>{h.stopPropagation(),o((ie[a.id]+1)%r.length)}),n.append(l,u,d),e.append(n),o(ie[a.id]??0)}}}function je(e){if(e.hidden)return"";if(e.type==="text"&&(e.variant==="title"||e.variant==="heading"))return K(e.text).value;if(e.type==="stack")for(let a of e.children){let t=je(a);if(t)return t}return""}function nt(e){return e.type==="stack"&&!e.interaction&&!e.purchaseAction}function it(e){let a=[],t=r=>{let i=O?.nodes[r.id];if(a.push(r.id,he(r.id)),i?.picker&&a.push(A[i.picker],O?.pickers[i.picker]),r.type==="text")a.push(Le(r,"text",r.text));else if(r.type==="button")a.push(Le(r,"label",r.label));else if(r.type==="image")a.push(Le(r,"alt",r.alt));else if(r.type==="custom_html")a.push(J,U?.answers);else if(r.type==="customer_data")a.push(te?.nodes[r.id]);else if(r.type==="plan_picker"){let s=O?.pickers[r.id];a.push(A[r.id],ge[r.id],s,i,s?.options.map(n=>O?.plans[n]))}else r.type==="stack"&&(r.interaction?.type!=="input"&&a.push(A[r.id],ie[r.id]),p(r)&&a.push(A[r.interaction.pickerId],O?.pickers[r.interaction.pickerId]),r.children.forEach(t))};return t(e),JSON.stringify(a)}function st(e){e.hidden||(nt(e)?e.children.forEach(st):ce.set(e.id,it(e)))}function ot(e){let a=ne.get(e.id);a!==void 0&&clearInterval(a),ne.delete(e.id),e.type==="stack"&&e.children.forEach(ot)}function dt(e,a){if(e.hidden)return;if(nt(e)){e.children.forEach(i=>dt(i,e));return}if(ce.get(e.id)===it(e))return;let t=Ae(e.id);if(!t)return;ot(e);let r=Ce(e,a);r&&t.replaceWith(r)}function Ft(){let e=document.activeElement;if(!(e instanceof HTMLElement)||!V.contains(e))return;let a=e.closest("[data-g-node]");if(!a)return;let t=[];for(let r=e;r!==a;){let i=r.parentElement;if(!i)return;t.unshift(Array.prototype.indexOf.call(i.children,r)),r=i}return{active:e,nodeId:a.dataset.gNode,path:t,identity:["productPeriod","planId","productTier","gDataFocus"].map(r=>[r,e.dataset[r]]).find(([,r])=>r!==void 0),selection:e instanceof HTMLInputElement&&e.selectionStart!==null?{start:e.selectionStart,end:e.selectionEnd,direction:e.selectionDirection}:void 0}}function Ut(e){if(!e||e.active.isConnected)return;let a=Ae(e.nodeId);if(!a)return;let t=a;if(e.identity){let[r,i]=e.identity;t=[...a.querySelectorAll("*")].find(s=>s.dataset[r]===i)}else for(let r of e.path)t=t?.children[r];!t||t.hasAttribute("disabled")||(t.focus({preventScroll:!0}),e.selection&&t instanceof HTMLInputElement&&["text","search","tel","url","password"].includes(t.type)&&t.setSelectionRange(e.selection.start,e.selection.end,e.selection.direction??void 0))}function ye(e=!1){if(!E)return;let a=e?void 0:Ft(),t=E.pages.find(s=>s.id===(C??E.initialPageId))??E.pages[0];C=t.id,O&&Object.assign(A,L({...E,pages:[t]},Qe(),O));let r=s=>{if(s.type==="stack"&&s.children.forEach(r),s.type!=="plan_picker"||!s.grouping)return;let n=s.grouping,l=O?.pickers[s.id],d=ge[s.id];if(!d){let w=n.assignments.find(o=>o.productVersionId===(A[s.id]??l?.selected));d={period:w?.period??"month",tierId:w?.tierId??n.tiers[0].id},ge[s.id]=d}let u=n.assignments.find(w=>w.tierId===d.tierId&&w.period===d.period);A[s.id]=u&&l?.options.includes(u.productVersionId)?u.productVersionId:""};if(r(t.root),e||ue!==t){ne.forEach(l=>clearInterval(l)),ne.clear(),ce.clear(),V.style.cssText="",Tt(t.theme?{...E,theme:t.theme}:E);let s=ae.split("-")[0];document.documentElement.lang=ae,document.documentElement.dir=["ar","he","fa","ur"].includes(s)?"rtl":"ltr",V.dataset.gPresentation=E.presentation.type;let n=Ce(t.root,null);V.replaceChildren(...n?[n]:[]),ue=t}else dt(t.root,null);st(t.root),Ut(a),V.dataset.gPage=t.id,c.mode==="live"&&B({type:"page",pageId:t.id}),Ue(),Fe();let i=Math.ceil(V.getBoundingClientRect().height);j?be():(j=!0,v=i,B({type:"rendered",height:i,label:je(t.root)||E.name}))}function be(){let e=Math.ceil(V.getBoundingClientRect().height);e!==v&&(v=e,B({type:"resize",height:e})),Ue(),Fe()}function ct(){k||(k=!0,window.requestAnimationFrame(()=>{k=!1,be()}))}function Fe(){if(c.mode!=="editor")return;let e=[];for(let t of V.querySelectorAll("[data-g-node]")){let r=t.getBoundingClientRect();!r.width||!r.height||e.push({id:t.dataset.gNode,x:r.x,y:r.y,width:r.width,height:r.height})}let a=JSON.stringify(e);a!==se&&(se=a,B({type:"layout",nodes:e}))}function Ae(e){return!e||!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(e)?null:V.querySelector(`[data-g-node="${e}"]`)}function lt(e,a){let t=Ae(a);if(!t){e.style.display="none";return}let r=t.getBoundingClientRect();e.style.display="block",e.style.left=`${r.left+window.scrollX}px`,e.style.top=`${r.top+window.scrollY}px`,e.style.width=`${r.width}px`,e.style.height=`${r.height}px`,e.toggleAttribute("data-below",r.top<20),e.firstChild.textContent=t.dataset.gLabel??""}function Ue(){c.mode==="editor"&&(lt(pe,Y),lt(ke,fe&&fe!==Y?fe:null))}function Te(e){for(let a of e.composedPath()){if(a instanceof HTMLElement&&a.dataset.gNode)return a.dataset.gNode;if(a===V)break}return null}function Bt(e){if(e.isTrusted){if(c.mode==="editor"){e.preventDefault(),e.stopPropagation(),B({type:"select",id:Te(e)});return}for(let a of e.composedPath()){if(!(a instanceof HTMLElement))continue;let t=a.dataset.gAction??(a.tagName==="BUTTON"?a.getAttribute("data-grow-action"):null);if(t&&!a.disabled){e.preventDefault();let r=E?.actions.find(i=>i.id===t);if(r?.type==="navigate"){if(C=r.pageId,E)for(let i of Object.keys(I(E)))delete A[i];ye(),V.querySelector("h1,h2")?.focus({preventScroll:!0});return}B({type:"action",actionId:t,nodeId:Te(e)??void 0,...Object.keys(A).length?{selection:Qe()}:{},...U?{answers:at()}:{}});return}if(a===V)return}}}function pt(e){let a=e;if(!(!a||a.channel!==c.channel))try{if(a.type==="render"){let t=c.document??a.doc;if(!t||t.kind!=="screen"||t.schemaVersion!==4||Object.hasOwn(t,"funnel")||!t.pages?.length||t.pages.length>(t.surface==="paywall"?10:1)||t.pages.some(r=>Object.hasOwn(r,"source"))||t.actions?.some(r=>!["event","close","open_url","claim_offer",...t.surface==="paywall"?["navigate"]:[]].includes(r.type)))throw new Error("Unsupported screen document; use the current Funnel runtime for flows");E=t,C=null,ae=String(a.locale),G=new Set,J=a.parameters??{},U=a.serverInput,A=Object.create(null),ge=Object.create(null),O=a.capabilities,te=a.customerData,Ee.clear();for(let[r,i]of Object.entries(O?.pickers??{}))i.selected&&(A[r]=i.selected);if(a.selection&&typeof a.selection=="object"&&!Array.isArray(a.selection)){let r=a.selection,i=n=>{let l=r[n.id];if(n.type==="plan_picker"&&typeof l=="string"&&n.planIds?.includes(l)&&(A[n.id]=l),n.type==="stack"){if(n.interaction?.type==="toggle"&&typeof l=="boolean"&&(A[n.id]=l),n.interaction&&["select","tabs"].includes(n.interaction.type)&&typeof l=="string"&&n.children.some(d=>d.id===l)&&(A[n.id]=l),p(n)){let d=r[n.interaction.pickerId];typeof d=="string"&&n.children.some(u=>u.type==="stack"&&u.bind?.plan===d)&&(A[n.interaction.pickerId]=d)}n.children.forEach(i)}};E.pages.forEach(n=>i(n.root));let s=r.__page;typeof s=="string"&&E.pages.some(n=>n.id===s)&&(C=s)}for(let r of U?.bindings??[])Object.hasOwn(U.answers,r.key)&&(A[r.componentId]=U.answers[r.key],G.add(r.componentId));ie=Object.create(null),ae=String(a.locale),ye(!0)}else if(a.type==="capabilities"){O=a.capabilities;for(let[t,r]of Object.entries(O.pickers))!ge[t]&&A[t]===void 0&&(A[t]=r.selected??"");ye()}else a.type==="customer-data"?Ot(a.data):a.type==="restore-action-focus"&&c.mode==="live"?[...V.querySelectorAll("button[data-g-node]")].find(t=>t.dataset.gNode===a.nodeId&&!t.disabled)?.focus({preventScroll:!0}):a.type==="highlight"&&c.mode==="editor"&&(fe=a.hoverId??null,Y=a.selectedId??null,Ue())}catch(t){B({type:"error",message:t instanceof Error?t.message:"render failed"})}}let ut=document.createElement("style");if(ut.textContent=b,document.head.append(ut),document.body.append(V),c.mode==="editor"){document.body.dataset.gEditor="",document.body.append(ke,pe),document.addEventListener("mouseover",a=>{let t=Te(a);t!==ve&&(ve=t,B({type:"hover",id:t}))}),document.documentElement.addEventListener("mouseleave",()=>{ve!==null&&(ve=null,B({type:"hover",id:null}))}),document.addEventListener("dblclick",a=>{let t=Te(a);t&&a.isTrusted&&B({type:"edit",id:t})}),document.addEventListener("click",a=>{V.contains(a.target)||B({type:"select",id:null})});let e=(a,t)=>{if(!a.isTrusted)return;let r=a.metaKey||a.ctrlKey,i=a.key;(i===" "||t==="down"&&(["Delete","Backspace","Escape"].includes(i)||r&&/^[zysdcvg0=+-]$/i.test(i)))&&((r||i===" ")&&a.preventDefault(),B({type:"key",key:{key:i,phase:t,meta:a.metaKey,ctrl:a.ctrlKey,shift:a.shiftKey,alt:a.altKey}}))};document.addEventListener("keydown",a=>e(a,"down")),document.addEventListener("keyup",a=>e(a,"up")),document.addEventListener("wheel",a=>{!a.isTrusted||!(a.ctrlKey||a.metaKey)||(a.preventDefault(),B({type:"zoom",delta:a.deltaY}))},{passive:!1})}V.addEventListener("click",Bt),document.addEventListener("keydown",e=>{e.key==="Escape"&&e.isTrusted&&B({type:"escape"})}),typeof ResizeObserver=="function"&&new ResizeObserver(ct).observe(V),window.addEventListener("resize",ct),c.mode==="editor"&&window.addEventListener("scroll",Fe),window.addEventListener("message",e=>{e.source===m&&pt(e.data)}),$.__indianaReceive=pt,B(c.document?{type:"ready",document:c.document}:{type:"ready"})}var Xt=`(${Ze.toString()})(JSON.parse(document.getElementById("grow-renderer-boot").textContent))`;function Pt(c,p){let I=JSON.stringify(c).replace(/</g,"\\u003c");return`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'nonce-${p}'; style-src 'unsafe-inline'; img-src https: data:; connect-src 'none'; font-src 'none'; media-src 'none'; frame-src 'none'; base-uri 'none'; form-action 'none'"></head><body><script type="application/json" id="grow-renderer-boot">${I}<\/script><script nonce="${p}">${Xt}<\/script></body></html>`}function Qt(){return`(() => {
171
172
  try {
172
173
  const input = JSON.parse(decodeURIComponent(location.hash.slice(1)));
173
174
  if (!input || !/^[a-f0-9-]{36}$/.test(input.channel) || input.mode !== "live" || !Number.isInteger(input.hostDepth) || input.hostDepth < 1 || input.hostDepth > 16) return;
@@ -178,7 +179,7 @@ body{font-family:var(--g-font);color:var(--g-text);-webkit-font-smoothing:antial
178
179
  const boot = { channel: input.channel, parentOrigin: origin.origin, hostDepth: input.hostDepth, mode: "live", document: data.document };
179
180
  (${Ze.toString()})(boot);
180
181
  } catch { /* No valid host bridge: leave the published screen inert. */ }
181
- })();`}function Qt(){return`(() => {
182
+ })();`}function ea(){return`(() => {
182
183
  try {
183
184
  const input = JSON.parse(decodeURIComponent(location.hash.slice(1)));
184
185
  if (!input || !/^[a-f0-9-]{36}$/.test(input.channel) || input.mode !== "live" || !Number.isInteger(input.hostDepth) || input.hostDepth < 1 || input.hostDepth > 16) return;
@@ -187,4 +188,4 @@ body{font-family:var(--g-font);color:var(--g-text);-webkit-font-smoothing:antial
187
188
  const boot = { channel: input.channel, parentOrigin: origin.origin, hostDepth: input.hostDepth, mode: "live" };
188
189
  (${Ze.toString()})(boot);
189
190
  } catch { /* No valid host bridge: leave the public shell empty. */ }
190
- })();`}function Ge(c,p){let A=(()=>{let N=c.defaultView;if(!N)throw new Error("Renderer host has no browser window");return N})(),I=5e3,y=0,T,C=!1;function P(){T!==void 0&&(A.clearTimeout(T),T=void 0,I=Math.max(0,I-(performance.now()-y)))}function b(){C||(C=!0,P(),c.removeEventListener("visibilitychange",v))}function v(){if(!C){if(c.visibilityState==="hidden"){P();return}T===void 0&&(y=performance.now(),T=A.setTimeout(()=>{T=void 0,b(),p()},I))}}return c.addEventListener("visibilitychange",v),v(),b}function ea(c,p){if(!/^(0|[1-9]\d*)(\.\d{1,12})?$/.test(c))throw new St("INVALID_RESPONSE","Invalid credit amount");let[A,I]=c.split("."),y=new Intl.NumberFormat(p),T=y.formatToParts(1.1).find(P=>P.type==="decimal")?.value??".",C=Array.from({length:10},(P,b)=>new Intl.NumberFormat(p,{useGrouping:!1}).format(b));return y.format(BigInt(A))+(I?T+I.replace(/\d/g,P=>C[Number(P)]):"")}var Ye=new WeakMap,ta=new WeakMap;function aa(c){let p=window.open("about:blank","_blank");if(!p)throw new Error("External URL window was blocked");try{p.opener=null;let A=p.document.createElement("a");A.href=c,A.target="_self",A.rel="noopener noreferrer",A.referrerPolicy="no-referrer",p.document.body.append(A),A.click()}catch(A){throw p.close(),A}}function ra(){return typeof navigator>"u"?[]:[...navigator.languages??[],navigator.language].filter(Boolean)}function Pt(c,p,A,I,y=document,T){let C=crypto.randomUUID(),P=crypto.randomUUID().replaceAll("-",""),b=y.createElement("iframe");b.title=p,b.setAttribute("sandbox","allow-scripts"),b.referrerPolicy="no-referrer";let v=y.defaultView,N=1;for(;v!==window&&N<16;)v=v.parent,N++;if(v!==window)throw new Error("Renderer container must belong to this host or a descendant window");let H={channel:C,parentOrigin:window.origin,hostDepth:N,mode:c,...c==="editor"?{editorMessages:A}:{}};if(T){if(c!=="live")throw new Error("Published screen renders only support live rendering");let x=new URL(T);if(x.username||x.password||x.search||x.hash||!wt(x.pathname)||x.protocol!=="https:"&&!(x.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(x.hostname)))throw new Error("Invalid published screen render URL");x.hash=encodeURIComponent(JSON.stringify(H)),b.src=x.href}else if(I){if(c!=="live")throw new Error("Hosted Web Views only support live rendering");let x=new URL(I);if(x.username||x.password||x.search||x.hash||!/^\/web-view\/renderer\/[a-f0-9]{64}$/.test(x.pathname)||x.protocol!=="https:"&&!(x.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(x.hostname)))throw new Error("Invalid hosted renderer URL");x.hash=encodeURIComponent(JSON.stringify(H)),b.src=x.href}else b.srcdoc=_t(H,P);return{frame:b,post:x=>b.contentWindow?.postMessage({...x,channel:C},"*"),accept:x=>x.source===b.contentWindow&&x.origin==="null"&&x.data&&x.data.channel===C?x.data:null}}function ka(c,p={}){let A=Ne(c,window);p.capabilities=Re(p.capabilities,A,window);let I=qe(A,[p.locale,...ra()]),y=Je(A,I);if(Ye.has(document))throw new Error("\u5DF2\u6709\u5F39\u7A97\u6B63\u5728\u5C55\u793A\uFF0C\u8BF7\u5148\u5173\u95ED\u3002");if(!document.body||!["https:","http:"].includes(location.protocol))throw new Error("\u5F39\u7A97\u9700\u8981 HTTP(S) \u9875\u9762\u3002");let T=document.activeElement,C=document.createElement("div");C.dataset.indianaPopup="";let P=C.attachShadow({mode:"open"}),b=document.createElement("style");b.textContent=":host{all:initial;position:fixed!important;inset:0!important;z-index:2147483647!important;font-family:system-ui,sans-serif;pointer-events:none} dialog{pointer-events:auto;box-sizing:border-box;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);padding:0;border:0;border-radius:14px;background:white;box-shadow:0 24px 80px #0003;overflow:hidden}dialog::backdrop{background:#16142577}button{position:absolute;z-index:1;inset-inline-end:8px;top:8px;width:30px;height:30px;border:1px solid #e5e5eb;border-radius:50%;background:#fff;color:#383344;font-size:20px;line-height:1;cursor:pointer}button:focus-visible{outline:3px solid #635bdf}iframe{display:block;border:0;width:100%;height:100%}";let v=document.createElement("dialog");v.lang=I,v.dir=bt(I)?"rtl":"ltr",v.setAttribute("aria-label",y.name),v.dataset.presentation=y.presentation.type,v.style.width=y.presentation.type==="fullscreen"?"100vw":`${yt[y.presentation.size]}px`,y.presentation.type==="fullscreen"?v.style.cssText+=";max-width:100vw;max-height:100dvh;height:100dvh;margin:0;border-radius:0":y.presentation.type==="sheet"&&(v.style.cssText+=";margin:auto auto 0;max-width:100vw;max-height:100dvh;border-radius:14px 14px 0 0"),v.style.background=y.theme.background;let N=document.createElement("button");N.type="button",N.textContent="\xD7",N.setAttribute("aria-label",Et(I));let{frame:H,post:F,accept:W}=Pt("live",y.name,void 0,p.rendererUrl),x=!1,L=!1,$=X=>{y.presentation.type!=="fullscreen"&&(v.style.height=`min(${Math.max(X,40)}px, calc(100dvh - ${y.presentation.type==="sheet"?0:32}px))`)};function te(X){try{Promise.resolve(p.onEvent?.(X)).catch(M=>V(p.onError,M))}catch(M){V(p.onError,M)}}function j(){return x?!1:(x=!0,pe(),window.removeEventListener("message",se),v.close(),C.remove(),Ye.delete(document),T instanceof HTMLElement&&T.isConnected&&T.focus({preventScroll:!0}),!0)}function ee(X){j()&&te({type:"closed",reason:X})}function se(X){let M=x?null:W(X);if(M){if(M.type==="ready")F({type:"render",doc:y,locale:I,capabilities:p.capabilities});else if(M.type==="rendered"&&!L)L=!0,pe(),$(M.height),M.label&&v.setAttribute("aria-label",M.label),v.showModal(),N.focus(),te({type:"shown"});else if(M.type==="resize"&&L)$(M.height);else if(M.type==="copy"&&L){let E=xe(y,M.nodeId),ne=mt(p.capabilities,M.nodeId);E?.type==="coupon_code"&&ne?.code&&navigator.clipboard?.writeText(ne.code).catch(()=>{})}else if(M.type==="escape"&&L)ee("escape");else if(M.type==="action"&&L&&typeof M.actionId=="string"){let E=y.actions.find(ne=>ne.id===M.actionId);if(!E)return;if(E.close&&j(),te({type:"action",actionId:E.id,...typeof M.nodeId=="string"&&xe(y,M.nodeId)?{nodeId:M.nodeId}:{},name:E.event,properties:{...E.properties},...M.selection?{selection:Ve(y,M.selection,p.capabilities)}:{}}),E.type==="open_url")try{aa(E.url)}catch(ne){V(p.onError,ne)}E.close&&te({type:"closed",reason:"action"})}}}let pe=Ge(document,()=>{V(p.onError,new Error("Web View renderer did not start")),ee("timeout")}),le={destroy:()=>ee("destroy"),updateCapabilities:X=>{let M=Re(X,y,window);p.capabilities=M,F({type:"capabilities",capabilities:M})}};return ta.set(le,X=>{x||F({type:"restore-action-focus",nodeId:X})}),N.addEventListener("click",()=>ee("close_button")),v.addEventListener("cancel",X=>{X.preventDefault(),ee("escape")}),v.append(N,H),P.append(b,v),window.addEventListener("message",se),Ye.set(document,le),document.body.append(C),le}function Sa(c,p={}){let A=(()=>{let R=c.ownerDocument.defaultView;if(!R)throw new Error("Preview container has no browser window");return R})(),I=p.mode??"editor",{frame:y,post:T,accept:C}=Pt(I,p.title??"\u5F39\u7A97\u9884\u89C8",p.editorMessages,p.rendererUrl,c.ownerDocument,p.screenUrl);y.style.cssText="display:block;border:0;width:100%;height:0";let P=!1,b=null,v=null,N=!1,H,F,W=new Promise((R,k)=>{H=R,F=k});W.catch(()=>{});let x=Ge(c.ownerDocument,()=>{if(N||P)return;let R=new Error("Web View renderer did not start");F(R),V(p.onError,R.message),L()});function L(){N||(N=!0,x(),P||F(new Error("Web View mount cancelled")),window.removeEventListener("message",ne),P=!1,b=null,v=null,$=null,j=null,ee=null,te=void 0,pe.clear(),y.remove(),y.removeAttribute("srcdoc"),y.removeAttribute("src"))}let $=null,te,j=null,ee=null,se="modal",pe=new Set,le=p.viewportHeight,X=0,M=R=>{X=R;let k=le,S=k?se==="fullscreen"?k:Math.max(1,Math.min(R,k-(se==="sheet"?0:32))):R;y.style.height=`${S}px`,V(p.onResize,S)};function E(R){if(!te)return;let k=xt.safeParse(R);if(!k.success||Object.keys(k.data).some(S=>!te.bindings.some(ae=>ae.key===S))){V(p.onError,"Invalid current-screen answers");return}return k.data}function ne(R){let k=N?null:C(R);if(k)if(k.type==="ready"){if(p.screenUrl){let S=$e.safeParse(k.document);if(!S.success){V(p.onError,"Invalid published screen render"),L();return}j=Ne(S.data,A),y.title=j.name}if(P=!0,x(),H(),ee){let[,S,ae]=ee;ee=null,ue.update(null,S,ae)}b&&T(b),v&&T(v)}else if(k.type==="rendered"||k.type==="resize")M(k.height),k.type==="rendered"&&V(p.onRendered);else if(k.type==="layout"&&I==="editor")Array.isArray(k.nodes)&&k.nodes.length<=($?De.nodes:0)&&k.nodes.every(S=>S&&typeof S.id=="string"&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(S.id)&&[S.x,S.y,S.width,S.height].every(ae=>typeof ae=="number"&&Number.isFinite(ae))&&S.width>0&&S.height>0)&&V(p.onLayout,k.nodes);else if(k.type==="page"&&I==="live"&&pe.has(k.pageId))V(p.onPageChange,k.pageId);else if(k.type==="escape"&&I==="live")V(p.onEscape);else if(k.type==="hover")V(p.onHover,k.id);else if(k.type==="select")V(p.onSelect,k.id);else if(k.type==="edit")V(p.onEdit,k.id);else if(k.type==="key"&&I==="editor"){let S=k.key;S&&typeof S.key=="string"&&S.key.length<=16&&(S.phase==="down"||S.phase==="up")&&[S.meta,S.ctrl,S.shift,S.alt].every(ae=>typeof ae=="boolean")&&V(p.onKey,{key:S.key,phase:S.phase,meta:S.meta,ctrl:S.ctrl,shift:S.shift,alt:S.alt})}else if(k.type==="zoom"&&I==="editor"&&typeof k.delta=="number"&&Number.isFinite(k.delta))V(p.onZoom,k.delta);else if(k.type==="customer-data-intent"&&I==="live"&&$){let S=ht.safeParse(k.intent);S.success&&xe($,S.data.nodeId)?.type==="customer_data"&&V(p.onCustomerDataIntent,S.data)}else if(k.type==="answers"&&I==="live"&&te){let S=E(k.answers);S&&V(p.onAnswers,S)}else if(k.type==="action"&&$?.actions.some(S=>S.id===k.actionId)){let S=E(k.answers);if(te&&!S)return;V(p.onAction,k.actionId,Ve($,k.selection,b?.type==="render"?b.capabilities:void 0),S)}else k.type==="error"&&V(p.onError,k.message)}window.addEventListener("message",ne),c.append(y);let ue={ready:W,get document(){return $},updateCustomerData(R){if(N||!$)return;let k=Be.parse(R),S={nodes:Object.fromEntries(Object.entries(k.nodes).filter(([ae,me])=>{let Z=xe($,ae);return Z?.type==="customer_data"&&Z.data.source===me.source}))};b?.type==="render"&&(b.customerData=S),P&&T({type:"customer-data",data:S})},updateCapabilities(R){if(N||!$)return;let k=Re(R,$,A);k&&(b?.type==="render"&&JSON.stringify(b.capabilities)===JSON.stringify(k)||(b?.type==="render"&&(b.capabilities=k),P&&T({type:"capabilities",capabilities:k})))},update(R,k,S){if(N)return;if(p.screenUrl?R!==null:R===null){V(p.onError,"A published screen render takes its document from the frame");return}if(R===null&&!j){ee=[null,k,S];return}let ae=R??j,me;try{let Z=R?Ne(ae,A):ae,Ee=I==="live"&&!!S?.serverInput,ve=Ee?qe(Z,[k]):k,q=Ee?Je(Z,ve):Z,ge=S?.serverInput?kt.parse(S.serverInput):void 0;if(ge&&(Z.surface!=="paywall"&&Z.pages.length!==1||Z.actions.some(de=>de.type!=="event"&&!(Z.surface==="paywall"&&de.type==="navigate")||de.close)||ge.bindings.some(de=>{let K=xe(Z,de.componentId);return K?.type!=="stack"||!K.interaction||!["input","multiselect","select","tabs","toggle"].includes(K.interaction.type)})))throw new Error("Current Funnel input requires one screen with bound interactive controls and output actions");$=q,te=ge,se=Z.presentation.type,pe=new Set(Z.pages.map(de=>de.id)),me={type:"render",...p.screenUrl?{}:{doc:q},...ge?{serverInput:ge}:{},locale:ve,parameters:vt.parse(S?.parameters??{}),capabilities:Re(S?.capabilities,Z,A),...S?.selection?{selection:S.selection}:{},customerData:S?.customerData?Be.parse(S.customerData):void 0},se==="fullscreen"&&le&&M(le)}catch(Z){V(p.onError,Z instanceof Error?Z.message:"\u5185\u5BB9\u4E0D\u6B63\u786E");return}b=me,P&&T(me)},resizeViewport(R){N||!Number.isFinite(R)||R<=0||(le=R,M(X))},highlight(R,k){N||(v={type:"highlight",hoverId:R,selectedId:k},P&&T(v))},destroy:L};return ue}export{ea as formatCustomerDecimal,Qt as hostedRendererScript,Xt as hostedScreenScript,Gt as inspectCustomHtml,Sa as mountScreenPreview,Ne as prepareScreen,Zt as sanitizeCustomHtml,ka as showPopup};
191
+ })();`}function Ge(c){return Object.assign(new Error(`Web View renderer did not start (${c.phase} timeout)`),{name:"RendererStartupError",code:"RENDERER_STARTUP_TIMEOUT",details:c})}function Ye(c,p,I){let L=(()=>{let E=c.defaultView;if(!E)throw new Error("Renderer host has no browser window");return E})(),m=I?.hasAttribute("src")?"navigation":"handshake",$=m==="navigation"?1e4:5e3,M=0,N=0,S,f=!1;function P(){if(S===void 0)return;L.clearTimeout(S),S=void 0;let E=Math.max(0,performance.now()-N);M+=E,$=Math.max(0,$-E)}function R(){f||(f=!0,P(),c.removeEventListener("visibilitychange",H),I?.removeEventListener("load",b))}function H(){if(!f){if(c.visibilityState==="hidden"){P();return}S===void 0&&(N=performance.now(),S=L.setTimeout(()=>{M+=Math.max(0,performance.now()-N),S=void 0,R(),p({phase:m,visibleMs:Math.round(M)})},$))}}function F(E){f||m===E||m==="render"||(P(),m=E,$=5e3,H())}function b(){m==="navigation"&&F("handshake")}return I?.addEventListener("load",b,{once:!0}),c.addEventListener("visibilitychange",H),H(),Object.assign(R,{ready:()=>F("render")})}function ta(c,p){if(!/^(0|[1-9]\d*)(\.\d{1,12})?$/.test(c))throw new Et("INVALID_RESPONSE","Invalid credit amount");let[I,L]=c.split("."),m=new Intl.NumberFormat(p),$=m.formatToParts(1.1).find(N=>N.type==="decimal")?.value??".",M=Array.from({length:10},(N,S)=>new Intl.NumberFormat(p,{useGrouping:!1}).format(S));return m.format(BigInt(I))+(L?$+L.replace(/\d/g,N=>M[Number(N)]):"")}var Xe=new WeakMap,aa=new WeakMap;function ra(c){let p=window.open("about:blank","_blank");if(!p)throw new Error("External URL window was blocked");try{p.opener=null;let I=p.document.createElement("a");I.href=c,I.target="_self",I.rel="noopener noreferrer",I.referrerPolicy="no-referrer",p.document.body.append(I),I.click()}catch(I){throw p.close(),I}}function na(){return typeof navigator>"u"?[]:[...navigator.languages??[],navigator.language].filter(Boolean)}function Mt(c,p,I,L,m=document,$){let M=crypto.randomUUID(),N=crypto.randomUUID().replaceAll("-",""),S=m.createElement("iframe");S.title=p,S.setAttribute("sandbox","allow-scripts"),S.referrerPolicy="no-referrer";let f=m.defaultView,P=1;for(;f!==window&&P<16;)f=f.parent,P++;if(f!==window)throw new Error("Renderer container must belong to this host or a descendant window");let R={channel:M,parentOrigin:window.origin,hostDepth:P,mode:c,...c==="editor"?{editorMessages:I}:{}};if($){if(c!=="live")throw new Error("Published screen renders only support live rendering");let b=new URL($);if(b.username||b.password||b.search||b.hash||!xt(b.pathname)||b.protocol!=="https:"&&!(b.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(b.hostname)))throw new Error("Invalid published screen render URL");b.hash=encodeURIComponent(JSON.stringify(R)),S.src=b.href}else if(L){if(c!=="live")throw new Error("Hosted Web Views only support live rendering");let b=new URL(L);if(b.username||b.password||b.search||b.hash||!/^\/web-view\/renderer\/[a-f0-9]{64}$/.test(b.pathname)||b.protocol!=="https:"&&!(b.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(b.hostname)))throw new Error("Invalid hosted renderer URL");b.hash=encodeURIComponent(JSON.stringify(R)),S.src=b.href}else S.srcdoc=Pt(R,N);return{frame:S,post:b=>S.contentWindow?.postMessage({...b,channel:M},"*"),accept:b=>b.source===S.contentWindow&&b.origin==="null"&&b.data&&b.data.channel===M?b.data:null}}function Sa(c,p={}){let I=Ne(c,window);p.capabilities=_e(p.capabilities,I,window);let L=qe(I,[p.locale,...na()]),m=Je(I,L);if(Xe.has(document))throw new Error("\u5DF2\u6709\u5F39\u7A97\u6B63\u5728\u5C55\u793A\uFF0C\u8BF7\u5148\u5173\u95ED\u3002");if(!document.body||!["https:","http:"].includes(location.protocol))throw new Error("\u5F39\u7A97\u9700\u8981 HTTP(S) \u9875\u9762\u3002");let $=document.activeElement,M=document.createElement("div");M.dataset.indianaPopup="";let N=M.attachShadow({mode:"open"}),S=document.createElement("style");S.textContent=":host{all:initial;position:fixed!important;inset:0!important;z-index:2147483647!important;font-family:system-ui,sans-serif;pointer-events:none} dialog{pointer-events:auto;box-sizing:border-box;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);padding:0;border:0;border-radius:14px;background:white;box-shadow:0 24px 80px #0003;overflow:hidden}dialog::backdrop{background:#16142577}button{position:absolute;z-index:1;inset-inline-end:8px;top:8px;width:30px;height:30px;border:1px solid #e5e5eb;border-radius:50%;background:#fff;color:#383344;font-size:20px;line-height:1;cursor:pointer}button:focus-visible{outline:3px solid #635bdf}iframe{display:block;border:0;width:100%;height:100%}";let f=document.createElement("dialog");f.lang=L,f.dir=wt(L)?"rtl":"ltr",f.setAttribute("aria-label",m.name),f.dataset.presentation=m.presentation.type,f.style.width=m.presentation.type==="fullscreen"?"100vw":`${bt[m.presentation.size]}px`,m.presentation.type==="fullscreen"?f.style.cssText+=";max-width:100vw;max-height:100dvh;height:100dvh;margin:0;border-radius:0":m.presentation.type==="sheet"&&(f.style.cssText+=";margin:auto auto 0;max-width:100vw;max-height:100dvh;border-radius:14px 14px 0 0"),f.style.background=m.theme.background;let P=document.createElement("button");P.type="button",P.textContent="\xD7",P.setAttribute("aria-label",At(L));let{frame:R,post:H,accept:F}=Mt("live",m.name,void 0,p.rendererUrl),b=!1,E=!1,U=J=>{m.presentation.type!=="fullscreen"&&(f.style.height=`min(${Math.max(J,40)}px, calc(100dvh - ${m.presentation.type==="sheet"?0:32}px))`)};function G(J){try{Promise.resolve(p.onEvent?.(J)).catch(C=>Z(p.onError,C))}catch(C){Z(p.onError,C)}}function O(){return b?!1:(b=!0,ce(),window.removeEventListener("message",ne),f.close(),M.remove(),Xe.delete(document),$ instanceof HTMLElement&&$.isConnected&&$.focus({preventScroll:!0}),!0)}function te(J){O()&&G({type:"closed",reason:J})}function ne(J){let C=b?null:F(J);if(C){if(C.type==="ready")ce.ready(),H({type:"render",doc:m,locale:L,capabilities:p.capabilities});else if(C.type==="rendered"&&!E)E=!0,ce(),U(C.height),C.label&&f.setAttribute("aria-label",C.label),f.showModal(),P.focus(),G({type:"shown"});else if(C.type==="resize"&&E)U(C.height);else if(C.type==="copy"&&E){let A=xe(m,C.nodeId),ie=ht(p.capabilities,C.nodeId);A?.type==="coupon_code"&&ie?.code&&navigator.clipboard?.writeText(ie.code).catch(()=>{})}else if(C.type==="escape"&&E)te("escape");else if(C.type==="action"&&E&&typeof C.actionId=="string"){let A=m.actions.find(ie=>ie.id===C.actionId);if(!A)return;if(A.close&&O(),G({type:"action",actionId:A.id,...typeof C.nodeId=="string"&&xe(m,C.nodeId)?{nodeId:C.nodeId}:{},name:A.event,properties:{...A.properties},...C.selection?{selection:Ve(m,C.selection,p.capabilities)}:{}}),A.type==="open_url")try{ra(A.url)}catch(ie){Z(p.onError,ie)}A.close&&G({type:"closed",reason:"action"})}}}let ce=Ye(document,J=>{Z(p.onError,Ge(J)),te("timeout")},R),ue={destroy:()=>te("destroy"),updateCapabilities:J=>{let C=_e(J,m,window);p.capabilities=C,H({type:"capabilities",capabilities:C})}};return aa.set(ue,J=>{b||H({type:"restore-action-focus",nodeId:J})}),P.addEventListener("click",()=>te("close_button")),f.addEventListener("cancel",J=>{J.preventDefault(),te("escape")}),f.append(P,R),N.append(S,f),window.addEventListener("message",ne),Xe.set(document,ue),document.body.append(M),ue}function Ea(c,p={}){let I=(()=>{let j=c.ownerDocument.defaultView;if(!j)throw new Error("Preview container has no browser window");return j})(),L=p.mode??"editor",{frame:m,post:$,accept:M}=Mt(L,p.title??"\u5F39\u7A97\u9884\u89C8",p.editorMessages,p.rendererUrl,c.ownerDocument,p.screenUrl);m.style.cssText="display:block;border:0;width:100%;height:0";let N=!1,S=!1,f=null,P=null,R=!1,H,F,b=new Promise((j,v)=>{H=j,F=v});b.catch(()=>{});let E=Ye(c.ownerDocument,j=>{if(R||S)return;let v=Ge(j);F(v),Z(p.onError,v.message),U()},m);function U(){R||(R=!0,E(),N||F(new Error("Web View mount cancelled")),window.removeEventListener("message",ge),N=!1,f=null,P=null,G=null,te=null,ne=null,O=void 0,ue.clear(),m.remove(),m.removeAttribute("srcdoc"),m.removeAttribute("src"))}let G=null,O,te=null,ne=null,ce="modal",ue=new Set,J=p.viewportHeight,C=0,A=j=>{C=j;let v=J,k=v?ce==="fullscreen"?v:Math.max(1,Math.min(j,v-(ce==="sheet"?0:32))):j;m.style.height=`${k}px`,Z(p.onResize,k)};function ie(j){if(!O)return;let v=vt.safeParse(j);if(!v.success||Object.keys(v.data).some(k=>!O.bindings.some(se=>se.key===k))){Z(p.onError,"Invalid current-screen answers");return}return v.data}function ge(j){let v=R?null:M(j);if(v)if(v.type==="ready"){if(p.screenUrl){let k=ze.safeParse(v.document);if(!k.success){Z(p.onError,"Invalid published screen render"),U();return}te=Ne(k.data,I),m.title=te.name}if(N=!0,E.ready(),H(),ne){let[,k,se]=ne;ne=null,ae.update(null,k,se)}f&&$(f),P&&$(P)}else if(v.type==="rendered"||v.type==="resize")A(v.height),v.type==="rendered"&&(S=!0,E(),Z(p.onRendered));else if(v.type==="layout"&&L==="editor")Array.isArray(v.nodes)&&v.nodes.length<=(G?Re.nodes:0)&&v.nodes.every(k=>k&&typeof k.id=="string"&&/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(k.id)&&[k.x,k.y,k.width,k.height].every(se=>typeof se=="number"&&Number.isFinite(se))&&k.width>0&&k.height>0)&&Z(p.onLayout,v.nodes);else if(v.type==="page"&&L==="live"&&ue.has(v.pageId))Z(p.onPageChange,v.pageId);else if(v.type==="escape"&&L==="live")Z(p.onEscape);else if(v.type==="hover")Z(p.onHover,v.id);else if(v.type==="select")Z(p.onSelect,v.id);else if(v.type==="edit")Z(p.onEdit,v.id);else if(v.type==="key"&&L==="editor"){let k=v.key;k&&typeof k.key=="string"&&k.key.length<=16&&(k.phase==="down"||k.phase==="up")&&[k.meta,k.ctrl,k.shift,k.alt].every(se=>typeof se=="boolean")&&Z(p.onKey,{key:k.key,phase:k.phase,meta:k.meta,ctrl:k.ctrl,shift:k.shift,alt:k.alt})}else if(v.type==="zoom"&&L==="editor"&&typeof v.delta=="number"&&Number.isFinite(v.delta))Z(p.onZoom,v.delta);else if(v.type==="customer-data-intent"&&L==="live"&&G){let k=yt.safeParse(v.intent);k.success&&xe(G,k.data.nodeId)?.type==="customer_data"&&Z(p.onCustomerDataIntent,k.data)}else if(v.type==="answers"&&L==="live"&&O){let k=ie(v.answers);k&&Z(p.onAnswers,k)}else if(v.type==="action"&&G?.actions.some(k=>k.id===v.actionId)){let k=ie(v.answers);if(O&&!k)return;Z(p.onAction,v.actionId,Ve(G,v.selection,f?.type==="render"?f.capabilities:void 0),k)}else v.type==="error"&&Z(p.onError,v.message)}window.addEventListener("message",ge),c.append(m);let ae={ready:b,get document(){return G},updateCustomerData(j){if(R||!G)return;let v=Be.parse(j),k={nodes:Object.fromEntries(Object.entries(v.nodes).filter(([se,fe])=>{let Y=xe(G,se);return Y?.type==="customer_data"&&Y.data.source===fe.source}))};f?.type==="render"&&(f.customerData=k),N&&$({type:"customer-data",data:k})},updateCapabilities(j){if(R||!G)return;let v=_e(j,G,I);v&&(f?.type==="render"&&JSON.stringify(f.capabilities)===JSON.stringify(v)||(f?.type==="render"&&(f.capabilities=v),N&&$({type:"capabilities",capabilities:v})))},update(j,v,k){if(R)return;if(p.screenUrl?j!==null:j===null){Z(p.onError,"A published screen render takes its document from the frame");return}if(j===null&&!te){ne=[null,v,k];return}let se=j??te,fe;try{let Y=j?Ne(se,I):se,ve=L==="live"&&!!k?.serverInput,V=ve?qe(Y,[v]):v,ke=ve?Je(Y,V):Y,pe=k?.serverInput?St.parse(k.serverInput):void 0;if(pe&&(Y.surface!=="paywall"&&Y.pages.length!==1||Y.actions.some(B=>B.type!=="event"&&!(Y.surface==="paywall"&&B.type==="navigate")||B.close)||pe.bindings.some(B=>{let Se=xe(Y,B.componentId);return Se?.type!=="stack"||!Se.interaction||!["input","multiselect","select","tabs","toggle"].includes(Se.interaction.type)})))throw new Error("Current Funnel input requires one screen with bound interactive controls and output actions");G=ke,O=pe,ce=Y.presentation.type,ue=new Set(Y.pages.map(B=>B.id)),fe={type:"render",...p.screenUrl?{}:{doc:ke},...pe?{serverInput:pe}:{},locale:V,parameters:kt.parse(k?.parameters??{}),capabilities:_e(k?.capabilities,Y,I),...k?.selection?{selection:k.selection}:{},customerData:k?.customerData?Be.parse(k.customerData):void 0},ce==="fullscreen"&&J&&A(J)}catch(Y){Z(p.onError,Y instanceof Error?Y.message:"\u5185\u5BB9\u4E0D\u6B63\u786E");return}f=fe,N&&$(fe)},resizeViewport(j){R||!Number.isFinite(j)||j<=0||(J=j,A(C))},highlight(j,v){R||(P={type:"highlight",hoverId:j,selectedId:v},N&&$(P))},destroy:U};return ae}export{ta as formatCustomerDecimal,ea as hostedRendererScript,Qt as hostedScreenScript,Yt as inspectCustomHtml,Ea as mountScreenPreview,Ne as prepareScreen,Gt as sanitizeCustomHtml,Sa as showPopup};
package/dist/server.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import 'zod';
2
- export { f as FeatureClient, d as FeatureClientOptions, n as FunnelDecisionInput, o as FunnelDecisionTimeoutError, p as FunnelDecisionUsedInput, g as FunnelNodeEvaluationContext, q as FunnelSignalInput, e as FunnelStartInput, h as IndianaError, r as IndianaServerOptions, k as createFeatureClient, s as createFunnelCampaignClient, t as createFunnelDecisionClient, u as createFunnelOrchestrationClient, v as createFunnelStartClient, w as createGuestToken, x as createIndianaServer, y as createNativeReceiptClient, z as createPaywallStartClient, m as evaluateFunnelNode, A as renewFunnelRun } from './funnel-runtime-start-CQhy2kx1.js';
3
- export { e as AiPricingOptions, d as AiTokenQuote, b as AiTokenUsage, a as AiUsageContext, f as AiUsageMiddlewareOptions, g as AiUsageRecord, h as aiPriceSnapshotSchema, i as aiTokenQuoteSchema, c as createAiPricing, j as createAiUsageMiddleware, k as createConfiguredAiPricing } from './ai-usage-D_mBF5Gp.js';
2
+ export { f as FeatureClient, d as FeatureClientOptions, n as FunnelDecisionInput, o as FunnelDecisionTimeoutError, p as FunnelDecisionUsedInput, g as FunnelNodeEvaluationContext, q as FunnelSignalInput, e as FunnelStartInput, h as IndianaError, r as IndianaServerOptions, k as createFeatureClient, s as createFunnelCampaignClient, t as createFunnelDecisionClient, u as createFunnelOrchestrationClient, v as createFunnelStartClient, w as createGuestToken, x as createIndianaServer, y as createNativeReceiptClient, z as createPaywallStartClient, m as evaluateFunnelNode, A as renewFunnelRun } from './funnel-runtime-start-B93fV5gJ.js';
3
+ export { e as AiPricingOptions, d as AiTokenQuote, b as AiTokenUsage, a as AiUsageContext, f as AiUsageMiddlewareOptions, g as AiUsageRecord, h as aiPriceSnapshotSchema, i as aiTokenQuoteSchema, c as createAiPricing, j as createAiUsageMiddleware, k as createConfiguredAiPricing } from './ai-usage-D9xVKhvu.js';
4
4
  import './screen-Keau_Qa2.js';
5
5
  import './growth-rules-D64pEvg9.js';
6
6
  import '@ai-sdk/provider';