@tinkerlandai/indiana-sdk 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -1
- package/README.md +177 -8
- package/README.zh-CN.md +94 -6
- package/dist/{ai-usage-BzydP8eN.d.ts → ai-usage-B4W5m4Ie.d.ts} +21 -4
- package/dist/chunk-4JBIKJMU.js +4 -0
- package/dist/chunk-5TEZEOHX.js +1 -0
- package/dist/chunk-5WY3AXSS.js +1 -0
- package/dist/chunk-HU2HIDVT.js +11 -0
- package/dist/chunk-OHDY27EI.js +1 -0
- package/dist/chunk-OK2Q6IJD.js +1 -0
- package/dist/chunk-PCVQHHEE.js +1 -0
- package/dist/chunk-RMJJOSVZ.js +1 -0
- package/dist/chunk-S2MSIA57.js +17 -0
- package/dist/chunk-S5TVMQRC.js +1 -0
- package/dist/configuration-sync-Bnu8s4pc.d.ts +1314 -0
- package/dist/{customer-page-aZb5Twue.d.ts → customer-page-B4FGCVpt.d.ts} +3 -0
- package/dist/funnel-runtime-host-L3WILUHK.js +1 -0
- package/dist/funnel-runtime-start-Zbd5ro5r.d.ts +30920 -0
- package/dist/{growth-rules-D64pEvg9.d.ts → growth-rules-B4YYy64R.d.ts} +8 -1
- package/dist/index.d.ts +14950 -5193
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +1 -1
- package/dist/openrouter.js +1 -1
- package/dist/page.d.ts +6 -8
- package/dist/page.js +1 -1
- package/dist/paywall-TCE5DE5T.js +1 -0
- package/dist/popup.d.ts +5 -2
- package/dist/popup.js +6 -6
- package/dist/server.d.ts +4 -3
- package/dist/server.js +1 -1
- package/dist/src-VGIVVM27.js +1 -0
- package/dist/{visual-editor-agent-FDCV3BXP.js → visual-editor-agent-WW65CMKW.js} +1 -1
- package/dist/visual.d.ts +4 -2
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-3OSMEG44.js +0 -17
- package/dist/chunk-GA6X57BO.js +0 -1
- package/dist/chunk-GTBD4BJ4.js +0 -11
- package/dist/chunk-QUW4UOKZ.js +0 -4
- package/dist/chunk-RMFH5TWV.js +0 -1
- package/dist/chunk-YNUVRZRQ.js +0 -1
- package/dist/funnel-runtime-host-RZRB2CY6.js +0 -1
- package/dist/funnel-runtime-start-JHA9ES24.d.ts +0 -9199
- package/dist/paywall-MYBEOVTQ.js +0 -1
- package/dist/src-E2GXK6WA.js +0 -1
- /package/dist/{chunk-ZT523F45.js → chunk-BIFEEVQO.js} +0 -0
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import 'zod';
|
|
2
|
-
export {
|
|
3
|
-
export { f as AiPricingOptions, d as AiTokenQuote, b as AiTokenUsage, a as AiUsageContext, g as AiUsageMiddlewareOptions, h as AiUsageRecord, i as aiPriceSnapshotSchema, j as aiTokenQuoteSchema, c as createAiPricing, k as createAiUsageMiddleware, l as createConfiguredAiPricing } from './ai-usage-
|
|
2
|
+
export { h as FeatureClient, e as FeatureClientOptions, s as FunnelDecisionInput, t as FunnelDecisionTimeoutError, u as FunnelDecisionUsedInput, v as FunnelLocalEvaluation, w as FunnelLocalEvaluator, x as FunnelLocalEvaluatorOptions, y as FunnelLocalSession, z as FunnelLocalSessionOptions, i as FunnelNodeEvaluationContext, A as FunnelSignalInput, g as FunnelStartInput, k as IndianaError, B as IndianaServerOptions, L as LocalFunnelClient, l as LocalFunnelClientOptions, o as createFeatureClient, C as createFunnelCampaignClient, D as createFunnelDecisionClient, E as createFunnelLocalEvaluator, G as createFunnelOrchestrationClient, H as createFunnelStartClient, J as createGuestToken, K as createIndianaServer, p as createLocalFunnelClient, M as createNativeReceiptClient, N as createPaywallStartClient, O as createSynchronizedFunnelLocalEvaluator, r as evaluateFunnelNode, Q as renewFunnelRun } from './funnel-runtime-start-Zbd5ro5r.js';
|
|
3
|
+
export { f as AiPricingOptions, d as AiTokenQuote, b as AiTokenUsage, a as AiUsageContext, g as AiUsageMiddlewareOptions, h as AiUsageRecord, i as aiPriceSnapshotSchema, j as aiTokenQuoteSchema, c as createAiPricing, k as createAiUsageMiddleware, l as createConfiguredAiPricing } from './ai-usage-B4W5m4Ie.js';
|
|
4
4
|
import './screen-16d-xADb.js';
|
|
5
|
-
|
|
5
|
+
export { C as ConfigurationSync, c as createConfigurationSync } from './configuration-sync-Bnu8s4pc.js';
|
|
6
|
+
import './growth-rules-B4YYy64R.js';
|
|
6
7
|
import '@ai-sdk/provider';
|
|
7
8
|
import 'zod/v4';
|
package/dist/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as v,b as g,d as U,e as L,f as F}from"./chunk-GA6X57BO.js";import{a as x,b as V,c as b,d as M}from"./chunk-RMFH5TWV.js";import{a as i,b as w}from"./chunk-YNUVRZRQ.js";import{Bi as s,Kj as S,Lj as R,Nj as _,Pk as E,Qk as O,Rj as q,Sj as h,Sk as D,Tj as N,Yl as T,Zl as P}from"./chunk-GTBD4BJ4.js";import{J as C}from"./chunk-3OSMEG44.js";function c(a,r){try{return a.parse(r)}catch{throw new i("INVALID_RESPONSE","Invalid gateway response")}}function B(a){if(typeof window<"u")throw new i("SERVER_ONLY","Secret API keys must stay on the backend");return{start:r=>U(a,r)}}var I=class extends i{constructor(t,e){super("DECISION_PENDING","Decision is still pending; read this decision ID or retry the original request ID",202,e);this.decisionId=t;this.decisionRequestId=e}decisionId;decisionRequestId};function A(a){if("remoteEval"in a)throw new i("INVALID_REQUEST","Configure evaluation mode on the Funnel; remoteEval is not supported");if(typeof window<"u")throw new i("SERVER_ONLY","Funnel decisions are requested by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(a.apiKey))throw new i("INVALID_TOKEN","A server API key is required");async function r(n,o,p=!1){let u=w({...a,fetch:(d,l)=>{let m=new Headers(l?.headers);return m.set("Accept-Encoding","identity"),p&&m.set("Prefer","respond-async"),(a.fetch??globalThis.fetch)(d,{...l,headers:m})},timeoutMs:Math.min(a.timeoutMs??1e4,o?Math.max(1,o-Date.now()):12e4)});return u.identify(a.apiKey),u.request("funnels",n)}async function t(n,o){let p=h.parse(await r(q.parse({operation:"read_decision",decisionId:n}),o));if(p.decisionId!==n)throw new i("INVALID_RESPONSE","Decision identity changed");return p}async function e(n,o,p=!1){let u=q.options[0].parse({...n,operation:"decide",funnelId:a.funnelId}),d;try{d=h.parse(await r(u,o,p))}catch(l){throw l instanceof i&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE"].includes(l.code)?new i("DECISION_ACCEPTANCE_UNKNOWN","Decision acceptance is unknown; retry the original request ID and input",l.status,n.requestId):l}if(d.requestId!==n.requestId||d.decision&&!g(d.decision,u.customer))throw new i("INVALID_RESPONSE","Decision request or customer changed");return{response:d,customer:u.customer}}return{async configuration(){let n=D.parse(await r({operation:"configuration",funnelId:a.funnelId}));if(n.scope.projectId!==a.scope.projectId||n.scope.environment!==a.scope.environment||n.funnelId!==a.funnelId)throw new i("SCOPE_MISMATCH","Configuration scope changed");return n},features(n={}){return v({...n,scope:a.scope,load:async()=>C.parse(await r({operation:"feature_config",funnelId:a.funnelId}))})},read:n=>t(n),async submit(n){return(await e(n,void 0,!0)).response},async decide(n){let o=Date.now()+3e4,p=await e(n,o),u=p.response,d=u.decisionId,l=250;for(;;){if(u.requestId!==n.requestId||u.decision&&!g(u.decision,p.customer))throw new i("INVALID_RESPONSE","Decision request or customer changed");if(u.decision)return u.decision;if(u.status==="failed")throw new i("DECISION_FAILED","Decision execution failed",503,n.requestId);if(Date.now()>=o)throw new I(d,n.requestId);if(await new Promise(m=>setTimeout(m,Math.min(l,o-Date.now()))),Date.now()>=o)throw new I(d,n.requestId);try{l=Math.min(1e3,l*2),u=await t(d,o)}catch(m){if(m instanceof i&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE","RATE_LIMITED"].includes(m.code))continue;throw m}}},async reportUsed(n){let o=N.parse(await r(q.parse({...n,operation:"report_used"})));if(o.decisionId!==n.decisionId||o.eventId!==n.eventId)throw new i("INVALID_RESPONSE","Usage receipt identity changed");return o}}}function K(a){if(typeof window<"u")throw new i("SERVER_ONLY","Native receipts are verified by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(a.apiKey))throw new i("INVALID_TOKEN","Server API key required");let r=w({...a,timeoutMs:a.timeoutMs??35e3});return r.identify(a.apiKey),{async recover(t){let e=T.parse(t);if(e.orderId!==e.receiptId)throw new i("INVALID_REQUEST","Native recovery requires the accepted commercial intent");let n=e.nativeEvidence,o={requestId:e.requestId,customerToken:e.customerToken,purchaseIntentId:e.orderId,...n===null?{intent:"read"}:n.provider==="apple"?{provider:"apple",signedTransaction:n.signedTransaction}:{provider:"google",purchaseToken:n.purchaseToken}},p=s.restoreNativePurchase.response.parse(await r.request(s.restoreNativePurchase.path,o));if(p.operation.requestId!==e.requestId)throw new i("INVALID_RESPONSE","Native receipt request identity changed");let u=P.parse({scope:p.scope,requestId:e.requestId,orderId:p.operation.orderId,receiptId:p.operation.orderId,orderStatus:p.operation.status,refunded:p.operation.refunded,...p.operation.completion===null?{}:{nativeCompletion:{orderId:p.operation.orderId,receiptId:p.operation.orderId,...p.operation.completion}}});if(u.requestId!==e.requestId||u.orderId!==e.orderId||u.receiptId!==e.receiptId||u.scope.projectId!==a.scope.projectId||u.scope.environment!==a.scope.environment)throw new i("INVALID_RESPONSE","Current order receipt scope changed");return u}}}import{z as G}from"zod";var f=G.number().int().min(0).max(Number.MAX_SAFE_INTEGER);function j(a,r){let t=f.parse(a.inputTokens.total),e=f.parse(a.outputTokens.total),n=f.parse(a.inputTokens.cacheRead??0),o=f.parse(a.inputTokens.cacheWrite??0),p=f.parse(a.outputTokens.reasoning??0);if(n+o>t||p>e||a.inputTokens.noCache!==void 0&&f.parse(a.inputTokens.noCache)!==t-n-o||a.outputTokens.text!==void 0&&f.parse(a.outputTokens.text)!==e-p)throw new i("AI_USAGE_UNAVAILABLE","Provider token counts do not conserve total usage");return{input:t-n-o,cache_read:n,cache_write:o,output:r==="output"?e:e-p,reasoning:r==="separate"?p:0,input_audio:0,output_audio:0}}function Q(a){if(typeof window<"u")throw new i("SERVER_ONLY","AI usage belongs on the trusted backend");if(!a.modelId||!["output","separate"].includes(a.reasoning))throw new i("INVALID_REQUEST","Model ID and reasoning pricing are required");async function r(e){await a.persist({context:e,modelId:a.modelId,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"})}async function t(e,n){let o={context:e,modelId:a.modelId,usage:n,tokens:null,quote:null,receipt:null,phase:"captured"};await a.persist(o);let p=a.mapTokens?a.mapTokens(n):j(n,a.reasoning),u=await a.pricing.quoteTokens({modelId:a.modelId,tokens:p});await a.persist({...o,tokens:p,quote:u,phase:"quoted"});let d=await a.pricing.trackTokens(a.client,{...e,quote:u});if(!d.receipt.accepted)throw new i("AI_BALANCE_REJECTED","AI usage was captured but the balance operation was rejected");await a.persist({...o,tokens:p,quote:u,receipt:d,phase:"settled"})}return{specificationVersion:"v4",async wrapGenerate({doGenerate:e}){let n=await a.context(),o;try{o=await e()}catch(p){throw await r(n),p}return await t(n,o.usage),o},async wrapStream({doStream:e}){let n=await a.context(),o;try{o=await e()}catch(m){throw await r(n),m}let p=!1,u=!1,d=o.stream.getReader();async function l(){p||u||(u=!0,await r(n))}return{...o,stream:new ReadableStream({async pull(m){try{let{value:y,done:k}=await d.read();if(k){if(!p)throw await l(),new i("AI_USAGE_UNAVAILABLE","Stream ended without final usage; no amount was invented");m.close();return}if(y.type==="finish"){if(p)throw new i("AI_USAGE_UNAVAILABLE","Provider sent more than one final usage record");p=!0,await t(n,y.usage)}m.enqueue(y)}catch(y){try{await l()}finally{m.error(y),await d.cancel(y)}}},async cancel(m){try{await l()}finally{await d.cancel(m)}}})}}}}function Y(a){if(typeof window<"u")throw new i("SERVER_ONLY","Funnel receipts are sent by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(a.apiKey))throw new i("INVALID_TOKEN","A server API key is required");let r=w(a);return r.identify(a.apiKey),{async signal(t){let e=S.parse({...t,operation:"signal"}),n=R.parse(await r.request("funnels",e));if(n.runId!==t.runId||n.eventId!==t.eventId||n.scope.projectId!==a.scope.projectId||n.scope.environment!==a.scope.environment)throw new i("INVALID_RESPONSE","Receipt identity changed");return n},async readResults(t){let e=S.parse({operation:"read_results",runId:t}),n=_.parse(await r.request("funnels",e));if(n.runId!==t||n.scope.projectId!==a.scope.projectId||n.scope.environment!==a.scope.environment)throw new i("INVALID_RESPONSE","Result identity changed");return n}}}function H(a){if(typeof window<"u")throw new i("SERVER_ONLY","Campaign entry requires your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(a.apiKey))throw new i("INVALID_TOKEN","A server API key is required");let r=w({...a,timeoutMs:a.timeoutMs??35e3});r.identify(a.apiKey);let t=A(a);return{async decide(e){let n=E.parse({...e,funnelId:a.funnelId,operation:"campaign_decide"}),o=h.parse(await r.request("funnels",n));if(o.scope.projectId!==a.scope.projectId||o.scope.environment!==a.scope.environment)throw new i("SCOPE_MISMATCH","Campaign scope changed");let p=o.decisionId,u=o.requestId,d=Date.now()+(a.timeoutMs??3e4);for(;o.status==="pending";){if(Date.now()>=d)throw new I(p,u);if(await new Promise(l=>setTimeout(l,250)),o=await t.read(p),o.requestId!==u)throw new i("INVALID_RESPONSE","Campaign decision identity changed")}if(o.status==="failed")throw new i("DECISION_FAILED","Campaign decision execution failed");if(!o.decision||!g(o.decision,n.customer))throw new i("INVALID_RESPONSE","Campaign Customer changed");return o.decision},async start(e){let n=E.parse({...e,funnelId:a.funnelId,operation:"campaign_start"}),o=O.parse(await r.request("funnels",n));if(o.scope.projectId!==a.scope.projectId||o.scope.environment!==a.scope.environment)throw new i("SCOPE_MISMATCH","Campaign scope changed");if(!("suppressed"in o)&&(o.run.source.id!==a.funnelId||!o.customerId||n.customer.type==="id"&&o.customerId!==n.customer.value))throw new i("INVALID_RESPONSE","Campaign Funnel or Customer changed");return o}}}function Se(){if(typeof window<"u")throw new i("SERVER_ONLY","Guest identity is issued by your backend");let a=crypto.getRandomValues(new Uint8Array(32));return"gg_gc_"+btoa(String.fromCharCode(...a)).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function Ee(a){if(typeof window<"u")throw new i("SERVER_ONLY","Secret API keys must stay on your backend");let r=w(a);return r.identify(a.apiKey),{async listInvoiceTemplates(t={}){let e=s.listInvoiceTemplates;return c(e.response,await r.request(e.path,e.request.parse(t)))},async previewInvoice(t){let e=s.previewInvoice;return c(e.response,await r.request(e.path,e.request.parse(t)))},async createInvoice(t){let e=s.createInvoice;return c(e.response,await r.request(e.path,e.request.parse(t)))},async manageInvoice(t){let e=s.manageInvoice;return c(e.response,await r.request(e.path,e.request.parse(t)))},async readInvoiceOperation(t){let e=s.readInvoiceOperation;return c(e.response,await r.request(e.path,e.request.parse(t)))},async listInvoices(t){let e=s.listInvoices;return c(e.response,await r.request(e.path,e.request.parse(t)))},async getInvoice(t){let e=s.getInvoice;return c(e.response,await r.request(e.path,e.request.parse(t)))},async recordCouponRedemption(t){let e=s.recordCouponRedemption,n=e.request.safeParse(t);if(!n.success)throw new i("INVALID_REQUEST","Invalid Coupon redemption facts");return c(e.response,await r.request(e.path,n.data))},async getFeatures(t={}){let e=s.getFeatures;return c(e.response,await r.request(e.path,e.request.parse(t),e.method))},async evaluateFeatures(t){let e=s.evaluateFeatures;return c(e.response,await r.request(e.path,e.request.parse(t),e.method))},async trackEvents(t){let e=s.trackEvents;return c(e.response,await r.request(e.path,e.request.parse(t),e.method))},async resolvePaywall(t){let e=s.resolvePaywall;return c(e.response,await r.request(e.path,e.request.parse(t)))},async resolveOffering(t){let e=s.resolveOffering;return c(e.response,await r.request(e.path,e.request.parse(t)))},async checkEntitlement(t){let e=s.checkEntitlement;return c(e.response,await r.request(e.path,e.request.parse(t)))},async setupPayment(t){let e=s.setupPayment;return c(e.response,await r.request(e.path,e.request.parse(t)))},async readPaymentSetup(t){let e=s.readPaymentSetup;return c(e.response,await r.request(e.path,e.request.parse(t)))},async previewSubscriptionBatch(t){let e=s.previewSubscriptionBatch;return c(e.response,await r.request(e.path,e.request.parse(t)))},async confirmSubscriptionBatch(t){let e=s.confirmSubscriptionBatch;return c(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionBatch(t){let e=s.readSubscriptionBatch;return c(e.response,await r.request(e.path,e.request.parse(t)))},async abandonSubscriptionBatch(t){let e=s.abandonSubscriptionBatch;return c(e.response,await r.request(e.path,e.request.parse(t)))},async manageSubscriptionTrial(t){let e=s.manageSubscriptionTrial;return c(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionTrial(t){let e=s.readSubscriptionTrial;return c(e.response,await r.request(e.path,e.request.parse(t)))},async listSubscriptions(t){let e=s.listSubscriptions;return c(e.response,await r.request(e.path,e.request.parse(t)))},async listPurchases(t){let e=s.listPurchases;return c(e.response,await r.request(e.path,e.request.parse(t)))},async listSubscriptionConflicts(t){let e=s.listSubscriptionConflicts;return c(e.response,await r.request(e.path,e.request.parse(t)))},async retrySubscriptionConflict(t){let e=s.retrySubscriptionConflict;return c(e.response,await r.request(e.path,e.request.parse(t)))},async previewRefund(t){let e=s.previewRefund;return c(e.response,await r.request(e.path,e.request.parse(t)))},async refund(t){let e=s.refund;return c(e.response,await r.request(e.path,e.request.parse(t)))},async readRefund(t){let e=s.readRefund;return c(e.response,await r.request(e.path,e.request.parse(t)))},async previewUpdate(t){let e=s.previewUpdate;return c(e.response,await r.request(e.path,e.request.parse(t)))},async update(t){let e=s.update;return c(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionUpdate(t){let e=s.readSubscriptionUpdate;return c(e.response,await r.request(e.path,e.request.parse(t)))},async restoreNativePurchase(t){let e=s.restoreNativePurchase;return c(e.response,await r.request(e.path,e.request.parse(t)))},async verifySubscriptions(t){let e=s.verifySubscriptions;return c(e.response,await r.request(e.path,e.request.parse(t)))},async previewAttach(t){let e=s.previewAttach;return c(e.response,await r.request(e.path,e.request.parse(t)))},async attach(t){let e=s.attach;return c(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionOperation(t){let e=s.readSubscriptionOperation;return c(e.response,await r.request(e.path,e.request.parse(t)))},async readAiPricing(t){let e=s.readAiPricing;return c(e.response,await r.request(e.path,e.request.parse(t)))},async readUsage(t){let e=s.readUsage;return c(e.response,await r.request(e.path,e.request.parse(t)))},async setUsage(t){let e=s.setUsage;return c(e.response,await r.request(e.path,e.request.parse(t)))},async manageBalanceGrant(t){let e=s.manageBalanceGrant;return c(e.response,await r.request(e.path,e.request.parse(t)))},async readBalanceSource(t){let e=s.readBalanceSource;return c(e.response,await r.request(e.path,e.request.parse(t)))},async adjustBalance(t){let e=s.adjustBalance;return c(e.response,await r.request(e.path,e.request.parse(t)))},async listBalanceGrants(t){let e=s.listBalanceGrants;return c(e.response,await r.request(e.path,e.request.parse(t)))},async manageBillingLimits(t){let e=s.manageBillingLimits;return c(e.response,await r.request(e.path,e.request.parse(t)))},async readSeats(t){let e=s.readSeats;return c(e.response,await r.request(e.path,e.request.parse(t)))},async manageSeat(t){let e=s.manageSeat;return c(e.response,await r.request(e.path,e.request.parse(t)))},async manageUsageEntity(t){let e=s.manageUsageEntity;return c(e.response,await r.request(e.path,e.request.parse(t)))},async readUsageAnalytics(t){let e=s.readUsageAnalytics;return c(e.response,await r.request(e.path,e.request.parse(t)))},async readCreditAnalytics(t){let e=s.readCreditAnalytics;return c(e.response,await r.request(e.path,e.request.parse(t)))},async submitUsageBatch(t){let e=s.submitUsageBatch;return c(e.response,await r.request(e.path,e.request.parse(t)))},async readUsageBatch(t){let e=s.readUsageBatch;return c(e.response,await r.request(e.path,e.request.parse(t)))},async readHoldings(t){let e=s.readHoldings;return c(e.response,await r.request(e.path,e.request.parse(t)))},async readLedger(t){let e=s.readLedger;return c(e.response,await r.request(e.path,e.request.parse(t)))},async readBillingInvoice(t){let e=s.readBillingInvoice;return c(e.response,await r.request(e.path,e.request.parse(t)))},async readCreditStatement(t){let e=s.readCreditStatement;return c(e.response,await r.request(e.path,e.request.parse(t)))},async quoteBalance(t){let e=s.quoteBalance;return c(e.response,await r.request(e.path,e.request.parse(t)))},async trackUsage(t){let e=s.trackUsage;return c(e.response,await r.request(e.path,e.request.parse(t)))},async mutateBalance(t){let e=s.mutateBalance;return c(e.response,await r.request(e.path,e.request.parse(t)))},async getCustomer(t){let e=s.getCustomer,n=e.request.safeParse(t);if(!n.success)throw new i("INVALID_REQUEST","Invalid customer lookup");let o=e.response.safeParse(await r.request(e.path,n.data));if(!o.success)throw new i("INVALID_RESPONSE","Invalid customer response");return o.data},async listCustomers(t={}){let e=s.listCustomers,n=e.request.safeParse(t);if(!n.success)throw new i("INVALID_REQUEST","Invalid customer filters");let o=e.response.safeParse(await r.request(e.path,n.data));if(!o.success)throw new i("INVALID_RESPONSE","Invalid customer response");return o.data},async updateCustomer(t){let e=s.updateCustomer,n=e.request.safeParse(t);if(!n.success)throw new i("INVALID_REQUEST","Invalid customer patch");let o=e.response.safeParse(await r.request(e.path,n.data));if(!o.success)throw new i("INVALID_RESPONSE","Invalid customer response");return o.data},async createGuestCustomer(t){let e=s.createGuestCustomer;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async resumeGuestSession(t){let e=s.resumeGuestSession;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async claimGuestCustomer(t){let e=s.claimGuestCustomer;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async renewCustomerSession(t){let e=s.renewSession;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async revokeCustomerSessions(t){let e=s.revokeSessions;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async createCustomerSession(t){let e=s.createSession.request.safeParse({customerId:t});if(!e.success)throw new i("INVALID_REQUEST","A customer ID is required");let n=s.createSession.response.safeParse(await r.request("customer-sessions",e.data));if(!n.success)throw new i("INVALID_RESPONSE","Invalid customer session response");return n.data},async getOrCreateCustomer(t){let e=s.createCustomer.request.safeParse(t);if(!e.success)throw new i("INVALID_REQUEST","Invalid customer input");let n=s.createCustomer.response.safeParse(await r.request("customers",e.data));if(!n.success)throw new i("INVALID_RESPONSE","Invalid customer response");return n.data},async grantOffer(t){let e=s.grantOffer.request.safeParse({...t,requestId:t.requestId??crypto.randomUUID()});if(!e.success)throw new i("INVALID_REQUEST","Invalid offer grant");let n=s.grantOffer.response.safeParse(await r.request("offers/grant",e.data));if(!n.success)throw new i("INVALID_RESPONSE","Invalid offer response");return n.data}}}async function ve(a,r){if(typeof window<"u")throw new i("SERVER_ONLY","Renewal requires your backend");let{funnelCredentialCommandSchema:t,funnelCredentialResponseSchema:e}=await import("./src-E2GXK6WA.js"),n=w(a);return n.identify(a.apiKey),e.parse(await n.request("funnels",t.parse({...r,operation:"renew_run"})))}export{I as FunnelDecisionTimeoutError,i as IndianaError,x as aiPriceSnapshotSchema,V as aiTokenQuoteSchema,b as createAiPricing,Q as createAiUsageMiddleware,M as createConfiguredAiPricing,v as createFeatureClient,H as createFunnelCampaignClient,A as createFunnelDecisionClient,Y as createFunnelOrchestrationClient,F as createFunnelStartClient,Se as createGuestToken,Ee as createIndianaServer,K as createNativeReceiptClient,B as createPaywallStartClient,L as evaluateFunnelNode,ve as renewFunnelRun};
|
|
1
|
+
import{a as j,b,c as pe,d as le,e as Se,f as de,g as me,j as fe,k as Ee,l as qe,m as Ae}from"./chunk-5WY3AXSS.js";import{a as Ce,b as Re,c as Fe,d as Le}from"./chunk-PCVQHHEE.js";import{a as q}from"./chunk-OK2Q6IJD.js";import{a as s}from"./chunk-5TEZEOHX.js";import"./chunk-S5TVMQRC.js";import{Bi as B,Ci as se,Ei as _,Fi as oe,Ig as U,Lg as X,Mj as ie,Ng as Z,Nj as ce,Rh as M,Sk as ue,Tg as te,Vf as o,ch as V,dh as ne,fh as re,qh as N,rh as R,sh as ae}from"./chunk-HU2HIDVT.js";import{Rb as ee}from"./chunk-RMJJOSVZ.js";import{b as Y,h as W}from"./chunk-OHDY27EI.js";import{B as $,b as H,m as J}from"./chunk-S2MSIA57.js";function p(n,r){try{return n.parse(r)}catch{throw new s("INVALID_RESPONSE","Invalid gateway response")}}function we(n){let r=le(n),t=i=>{throw new s("INVALID_RESPONSE",i)};r.nodes.size!==n.topology.nodes.length&&t("Duplicate local node identity"),r.nodes.get(n.topology.entry)?.type!=="entry"&&t("A local Funnel must start at Entry");let e=new Set(["entry","condition","feature","split","end","output"]);for(let i of r.nodes.values()){if(!e.has(i.type))throw new s("SERVER_REQUIRED","This Funnel requires authoritative server execution");if(i.type==="entry"&&i.id!==n.topology.entry&&t("Unexpected Entry node"),["entry","feature"].includes(i.type)&&!i.outputs.next&&t("Local next exit is unavailable"),i.type==="feature"){let c=i.resources.featureKey;(!c||!Object.hasOwn(n.evaluation.variables,i.writes.value)||!Object.hasOwn(r.features,c))&&t("Local Feature definition or declaration is unavailable")}if(i.type==="condition"){let c=n.conditions[i.id];(!c||!i.outputs.default||c.some((f,m)=>f.port!==`case:${m}`||!i.outputs[f.port]))&&t("Local Condition exits are unavailable")}if(i.type==="split"&&(!i.resources.experimentId||!Object.hasOwn(n.growth.experiments,i.resources.experimentId)||!i.outputs.notParticipating)&&t("Local Experiment definition or exit is unavailable"),i.type==="end"||i.type==="output"){let c=n.evaluation.terminals[i.id];if(!c)throw new s("SERVER_REQUIRED","Terminal resource delivery requires the server");Object.keys(i.outputs).length&&t("A terminal cannot have outgoing edges"),c.output?.type==="feature"&&!Object.hasOwn(r.features,c.output.featureKey)&&t("Terminal Feature definition is unavailable")}for(let c of Object.values(i.outputs))r.nodes.has(c)||t("Local target is unavailable")}let a=new Set,u=new Set;function l(i){if(u.has(i)&&t("Local graph contains a cycle"),!a.has(i)){u.add(i);for(let c of Object.values(r.nodes.get(i).outputs))l(c);u.delete(i),a.add(i)}}return l(n.topology.entry),a.size!==r.nodes.size&&t("Local graph contains unreachable nodes"),{evaluate(i){let c={},f=i.context;f.features=r.features,f.savedGroups=r.savedGroups;let m=()=>{f.attributes=Z({declarations:n.evaluation.variables,attributes:i.attributes,parameters:i.parameters,answers:{},results:c,savedGroups:r.savedGroups})};m();let I=n.topology.entry,d=0;for(;;){let w=r.nodes.get(I);if(w.type==="end"||w.type==="output"){let y=n.evaluation.terminals[I],h=y.output,v=h?.type==="feature"?r.feature(h.featureKey,f):h?.type==="variable"?te({source:"variable",key:h.key,...h.path?{path:h.path}:{}},{declarations:n.evaluation.variables,answers:{},results:c,parameters:i.parameters,attributes:i.attributes,savedGroups:r.savedGroups}):h?.value??null;return U(n.evaluation.outputSchema,v)||t("Local output does not match its declaration"),{outcome:y.outcome,value:v}}if(d++>=n.evaluation.maxTransitions)throw new s("TRANSITION_LIMIT","Local Funnel transition budget exceeded");if(w.type==="entry")I=w.outputs.next;else{let y=r.evaluate(I,f);if(w.type==="feature"){let h=w.writes.value,v=y.value??null;U(n.evaluation.variables[h],v)||t("Local Feature value does not match its declaration"),X(n.evaluation.variables,{writes:w.writes},{[h]:v}),c[h]=v,m()}I=y.target}}}}}import{z as ye}from"zod";function Ie(n,r,t){let e=J.parse(n.attributes);if(["parameters","answers","results"].some(S=>Object.hasOwn(e,S)))throw new s("INVALID_REQUEST","Flow namespaces cannot be caller attributes");let a=ee.parse(n.parameters??{}),u=ye.record(ye.string(),$).parse(n.stickyBucketAssignmentDocs??{});for(let[S,g]of Object.entries(u))if(S!==`${g.attributeName}||${g.attributeValue}`||!Object.hasOwn(e,g.attributeName)||H(e[g.attributeName])!==g.attributeValue)throw new s("INVALID_REQUEST","Sticky document identity does not match this session");let l=n.saveStickyBucketAssignmentDoc,i=n.onFeatureUsage,c=n.onExperimentViewed,f=n.onError,m=new Map,I=new Set,d={},w=Promise.resolve();function y(S){let g=w.then(()=>(t(),S()));return w=g.catch(()=>{}),g}function h(S){try{f?.(S)}catch{}}function v(S){try{let g=S();g&&typeof g.catch=="function"&&g.catch(h)}catch(g){h(g)}}async function L(){for(let[S,g]of m){if(t(),l)try{await l(structuredClone(g))}catch{throw new s("STICKY_SAVE_FAILED","Persist the pending Sticky assignment before using this evaluation")}t(),m.delete(S)}}return{evaluate(S={}){let g=S.track===!0;return y(async()=>{let D=await r();t(D);let K=new Set(I),z={...d},Q=new Map,T=[],he={stickyBucketAssignmentDocs:structuredClone(u),saveStickyBucketAssignmentDoc(E){Q.set(`${E.attributeName}||${E.attributeValue}`,structuredClone(E))},...g?{trackedExperiments:K,trackedFeatureUsage:z,onExperimentViewed(E,C){let P=structuredClone(E),ve=structuredClone(C);c&&T.push(()=>c(structuredClone(P),structuredClone(ve)))},onFeatureUsage(E,C){let P=structuredClone(C);i&&T.push(()=>i(E,structuredClone(P)))}}:{}},ge=D.program.evaluate({attributes:e,parameters:a,context:he});t(D);for(let[E,C]of Q)u[E]=C,m.set(E,C);await L(),t(D),g&&(I=K,d=z);for(let E of T)v(E);let O=D.configuration;return structuredClone({evaluationMode:"local",scope:O.scope,funnelId:O.funnelId,versionId:O.versionId,evaluationRevision:O.evaluationRevision,generation:O.growth.generation,...ge})})},flush:()=>y(L),get stickyBucketAssignmentDocs(){return t(),structuredClone(u)}}}var De=6e4;function x(n){if(typeof window<"u")throw new s("SERVER_ONLY","Local Funnel sessions run on your backend");let r=Y.parse(n.scope),t=n.funnelId,e=n.load,a,u,l,i=0,c=I=>Date.now()>=I.expiresAt;async function f(){if(u)return u;let I=i;a=void 0;let d=(async()=>{let w=await e();if(I!==i)throw new s("IDENTITY_CHANGED","Local evaluator was reset");if(w&&typeof w=="object"&&"evaluationMode"in w&&w.evaluationMode==="remote")throw p(_,w),new s("EVALUATION_MODE","This Funnel requires remote decide");let y=p(oe,w);if(I!==i)throw new s("IDENTITY_CHANGED","Local evaluator was reset");if(y.scope.projectId!==r.projectId||y.scope.environment!==r.environment||y.funnelId!==t)throw new s("SCOPE_MISMATCH","Local configuration scope changed");if(y.growth.scope.projectId!==r.projectId||y.growth.scope.environment!==r.environment||y.growth.expiresAt!==y.expiresAt)throw new s("INVALID_RESPONSE","GB configuration scope or expiry changed");let h=Math.min(Date.now()+De,y.expiresAt?Date.parse(y.expiresAt):1/0);if(Date.now()>=h)throw new s("CONFIGURATION_EXPIRED","Refresh expired local rules");let v=JSON.stringify([r.projectId,r.environment,t,y.versionId,y.evaluationRevision,y.growth.generation]),L=[y.topology,y.conditions,y.evaluation,y.growth.features,y.growth.experiments,y.growth.savedGroups];if(l?.key===v&&!pe(l.body,L))throw new s("INVALID_RESPONSE","Immutable local configuration identity changed");return l?.key!==v&&(l={key:v,body:L,program:we(y)}),a={key:v,configuration:y,expiresAt:h,program:l.program},a})();u=d;try{return await d}finally{u===d&&(u=void 0)}}function m(){return u??(a&&!c(a)?Promise.resolve(a):f())}return{session(I){let d=i;return Ie(I,m,w=>{if(n.assertUsable?.(),d!==i)throw new s("IDENTITY_CHANGED","Local evaluator was reset");if(w&&(c(w)||a?.key!==w.key))throw new s("CONFIGURATION_EXPIRED","Refresh local rules before using this result")})},async refresh(){return structuredClone((await f()).configuration)},reset(){i++,a=void 0,u=void 0,l=void 0}}}function Oe(n,r){let t=n.snapshot?.generation,e=x({scope:{projectId:n.scope.projectId,environment:n.scope.environment},funnelId:r,load:()=>n.localFunnel(r),assertUsable:()=>n.assertFunnel(r)}),a=n.subscribe(()=>{let l=n.snapshot?.generation;n.fresh&&l!==t&&(t=l,e.refresh().catch(()=>{}))}),u=e.session;return Object.assign(e,{session(l){let i=u(l),c=i.evaluate;return Object.assign(i,{async evaluate(...f){return n.fresh||await n.refresh(),c(...f)}})},destroy(){a(),e.reset()}})}function _e(n){if(typeof window<"u")throw new s("SERVER_ONLY","Secret API keys must stay on the backend");return{start:r=>fe(n,r)}}var F=class extends s{constructor(t,e){super("DECISION_PENDING","Decision is still pending; read this decision ID or retry the original request ID",202,e);this.decisionId=t;this.decisionRequestId=e}decisionId;decisionRequestId};async function k(n,r,t,e){let{decisionId:a,requestId:u}=n,l=n,i=250;for(;;){if(l.decisionId!==a||l.requestId!==u||l.decision&&!b(l.decision,r))throw new s("INVALID_RESPONSE","Decision request or customer changed");if(l.decision)return l.decision;if(l.status==="failed")throw new s("DECISION_FAILED","Decision execution failed",503,u);if(Date.now()>=t)throw new F(a,u);if(await new Promise(c=>setTimeout(c,Math.min(i,t-Date.now()))),Date.now()>=t)throw new F(a,u);i=Math.min(1e3,i*2);try{l=await e(a,t)}catch(c){if(c instanceof s&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE","RATE_LIMITED"].includes(c.code))continue;throw c}}}function G(n){if("remoteEval"in n)throw new s("INVALID_REQUEST","Configure evaluation mode on the Funnel; remoteEval is not supported");if(typeof window<"u")throw new s("SERVER_ONLY","Funnel decisions are requested by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new s("INVALID_TOKEN","A server API key is required");let r,t,e=new Map;async function a(c,f){let m=c;m.status!=="pending"&&e.delete(m.decisionId);for(let I=0;I<32&&m.evaluation;I++){let d=m.evaluation;if(d.runId!==m.decisionId)throw new s("INVALID_RESPONSE","Local evaluation Run changed");let w=e.get(m.decisionId);if(!w&&d.type==="evaluate_segment"){let h=ue.parse(await u({operation:"segment_configuration",funnelId:n.funnelId,versionId:d.versionId},f));if(h.configuration.scope.projectId!==n.scope.projectId||h.configuration.scope.environment!==n.scope.environment||h.configuration.funnelId!==n.funnelId||h.configuration.versionId!==d.versionId||h.configuration.evaluationRevision!==d.policyRevision)throw new s("SCOPE_MISMATCH","Original decision segment configuration changed");if(e.size>=128)throw new s("COMMAND_PENDING","Reconcile outstanding decisions first");w={operation:"commit_decision_segment",decisionId:m.decisionId,requestId:M(m.decisionId,d.visit,`segment:${d.revision}`),nodeId:d.nodeId,visit:d.visit,revision:d.revision,policyRevision:d.policyRevision,generation:h.configuration.growth.generation,...me(h.configuration,h.document,d)},e.set(m.decisionId,w)}if(!w){if(d.type!=="evaluate")throw new s("INVALID_RESPONSE","Unknown decision instruction");if((!t||t.versionId!==d.versionId||t.evaluationRevision!==d.policyRevision||t.expiresAt&&Date.parse(t.expiresAt)<=Date.now())&&(t=_.parse(await u({operation:"configuration",funnelId:n.funnelId,versionId:d.versionId},f))),t.scope.projectId!==n.scope.projectId||t.scope.environment!==n.scope.environment||t.funnelId!==n.funnelId)throw new s("SCOPE_MISMATCH","Local evaluation configuration scope changed");if(t.evaluationMode!=="local"||t.versionId!==d.versionId||t.evaluationRevision!==d.policyRevision)throw new s("EVALUATION_MODE","Original Local evaluation policy is unavailable");if(e.size>=128)throw new s("COMMAND_PENDING","Reconcile outstanding Local decisions first");w={operation:"evaluate_decision",decisionId:m.decisionId,requestId:M(m.decisionId,d.visit,"evaluation"),nodeId:d.nodeId,visit:d.visit,revision:d.revision,receiptId:d.receiptId,policyRevision:d.policyRevision,generation:t.growth.generation,result:de(t,d.nodeId,d)},e.set(m.decisionId,w)}let y=R.parse(await u(w,f));if(y.decisionId!==c.decisionId||y.requestId!==c.requestId)throw new s("INVALID_RESPONSE","Decision identity changed during local evaluation");e.delete(m.decisionId),m=y}return m}async function u(c,f,m=!1){let I=q({...n,fetch:(d,w)=>{let y=new Headers(w?.headers);return y.set("Accept-Encoding","identity"),m&&y.set("Prefer","respond-async"),(n.fetch??globalThis.fetch)(d,{...w,headers:y})},timeoutMs:Math.min(n.timeoutMs??1e4,f?Math.max(1,f-Date.now()):12e4)});return I.identify(n.apiKey),I.request("funnels",c)}async function l(c,f){let m=R.parse(await u(N.parse({operation:"read_decision",decisionId:c}),f));if(m.decisionId!==c)throw new s("INVALID_RESPONSE","Decision identity changed");return a(m,f)}async function i(c,f,m=!1){let I=N.options[0].parse({...c,operation:"decide",funnelId:n.funnelId}),d;try{d=R.parse(await u(I,f,m))}catch(w){throw w instanceof s&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE"].includes(w.code)?new s("DECISION_ACCEPTANCE_UNKNOWN","Decision acceptance is unknown; retry the original request ID and input",w.status,c.requestId):w}if(d.requestId!==c.requestId||d.decision&&!b(d.decision,I.customer))throw new s("INVALID_RESPONSE","Decision request or customer changed");return{response:await a(d,f),customer:I.customer}}return{local(){return r??=x({scope:n.scope,funnelId:n.funnelId,load:()=>u({operation:"local_configuration",funnelId:n.funnelId})})},async configuration(){let c=_.parse(await u({operation:"configuration",funnelId:n.funnelId}));if(c.scope.projectId!==n.scope.projectId||c.scope.environment!==n.scope.environment||c.funnelId!==n.funnelId)throw new s("SCOPE_MISMATCH","Configuration scope changed");return c},features(c={}){return j({...c,scope:n.scope,load:async()=>W.parse(await u({operation:"feature_config",funnelId:n.funnelId}))})},read:c=>l(c),async submit(c){return(await i(c,void 0,!0)).response},async decide(c){let f=Date.now()+3e4,m=await i(c,f);return k(m.response,m.customer,f,l)},async reportUsed(c){let f=ae.parse(await u(N.parse({...c,operation:"report_used"})));if(f.decisionId!==c.decisionId||f.eventId!==c.eventId)throw new s("INVALID_RESPONSE","Usage receipt identity changed");return f}}}function Ne(n){if(typeof window<"u")throw new s("SERVER_ONLY","Native receipts are verified by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new s("INVALID_TOKEN","Server API key required");let r=q({...n,timeoutMs:n.timeoutMs??35e3});return r.identify(n.apiKey),{async recover(t){let e=ie.parse(t);if(e.orderId!==e.receiptId)throw new s("INVALID_REQUEST","Native recovery requires the accepted commercial intent");let a=e.nativeEvidence,u={requestId:e.requestId,customerToken:e.customerToken,purchaseIntentId:e.orderId,...a===null?{intent:"read"}:a.provider==="apple"?{provider:"apple",signedTransaction:a.signedTransaction}:{provider:"google",purchaseToken:a.purchaseToken}},l=o.restoreNativePurchase.response.parse(await r.request(o.restoreNativePurchase.path,u));if(l.operation.requestId!==e.requestId)throw new s("INVALID_RESPONSE","Native receipt request identity changed");let i=ce.parse({scope:l.scope,requestId:e.requestId,orderId:l.operation.orderId,receiptId:l.operation.orderId,orderStatus:l.operation.status,refunded:l.operation.refunded,...l.operation.completion===null?{}:{nativeCompletion:{orderId:l.operation.orderId,receiptId:l.operation.orderId,...l.operation.completion}}});if(i.requestId!==e.requestId||i.orderId!==e.orderId||i.receiptId!==e.receiptId||i.scope.projectId!==n.scope.projectId||i.scope.environment!==n.scope.environment)throw new s("INVALID_RESPONSE","Current order receipt scope changed");return i}}}import{z as be}from"zod";var A=be.number().int().min(0).max(Number.MAX_SAFE_INTEGER);function xe(n,r){let t=A.parse(n.inputTokens.total),e=A.parse(n.outputTokens.total),a=A.parse(n.inputTokens.cacheRead??0),u=A.parse(n.inputTokens.cacheWrite??0),l=A.parse(n.outputTokens.reasoning??0);if(a+u>t||l>e||n.inputTokens.noCache!==void 0&&A.parse(n.inputTokens.noCache)!==t-a-u||n.outputTokens.text!==void 0&&A.parse(n.outputTokens.text)!==e-l)throw new s("AI_USAGE_UNAVAILABLE","Provider token counts do not conserve total usage");return{input:t-a-u,cache_read:a,cache_write:u,output:r==="output"?e:e-l,reasoning:r==="separate"?l:0,input_audio:0,output_audio:0}}function ke(n){if(typeof window<"u")throw new s("SERVER_ONLY","AI usage belongs on the trusted backend");if(!n.modelId||!["output","separate"].includes(n.reasoning))throw new s("INVALID_REQUEST","Model ID and reasoning pricing are required");async function r(e){await n.persist({context:e,modelId:n.modelId,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"})}async function t(e,a){let u={context:e,modelId:n.modelId,usage:a,tokens:null,quote:null,receipt:null,phase:"captured"};await n.persist(u);let l=n.mapTokens?n.mapTokens(a):xe(a,n.reasoning),i=await n.pricing.quoteTokens({modelId:n.modelId,tokens:l});await n.persist({...u,tokens:l,quote:i,phase:"quoted"});let c=await n.pricing.trackTokens(n.client,{...e,quote:i});if(!c.receipt.accepted)throw new s("AI_BALANCE_REJECTED","AI usage was captured but the balance operation was rejected");await n.persist({...u,tokens:l,quote:i,receipt:c,phase:"settled"})}return{specificationVersion:"v4",async wrapGenerate({doGenerate:e}){let a=await n.context(),u;try{u=await e()}catch(l){throw await r(a),l}return await t(a,u.usage),u},async wrapStream({doStream:e}){let a=await n.context(),u;try{u=await e()}catch(m){throw await r(a),m}let l=!1,i=!1,c=u.stream.getReader();async function f(){l||i||(i=!0,await r(a))}return{...u,stream:new ReadableStream({async pull(m){try{let{value:I,done:d}=await c.read();if(d){if(!l)throw await f(),new s("AI_USAGE_UNAVAILABLE","Stream ended without final usage; no amount was invented");m.close();return}if(I.type==="finish"){if(l)throw new s("AI_USAGE_UNAVAILABLE","Provider sent more than one final usage record");l=!0,await t(a,I.usage)}m.enqueue(I)}catch(I){try{await f()}finally{m.error(I),await c.cancel(I)}}},async cancel(m){try{await f()}finally{await c.cancel(m)}}})}}}}function Te(n){if(typeof window<"u")throw new s("SERVER_ONLY","Funnel receipts are sent by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new s("INVALID_TOKEN","A server API key is required");let r=q(n);return r.identify(n.apiKey),{async signal(t){let e=V.parse({...t,operation:"signal"}),a=ne.parse(await r.request("funnels",e));if(a.runId!==t.runId||a.eventId!==t.eventId||a.scope.projectId!==n.scope.projectId||a.scope.environment!==n.scope.environment)throw new s("INVALID_RESPONSE","Receipt identity changed");return a},async readResults(t){let e=V.parse({operation:"read_results",runId:t}),a=re.parse(await r.request("funnels",e));if(a.runId!==t||a.scope.projectId!==n.scope.projectId||a.scope.environment!==n.scope.environment)throw new s("INVALID_RESPONSE","Result identity changed");return a}}}function Pe(n){if("remoteEval"in n)throw new s("INVALID_REQUEST","Configure evaluation mode on the Funnel; remoteEval is not supported");if(typeof window<"u")throw new s("SERVER_ONLY","Campaign entry requires your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new s("INVALID_TOKEN","A server API key is required");let r=q({...n,timeoutMs:n.timeoutMs??35e3});return r.identify(n.apiKey),{async decide(t){let e=Date.now()+(n.timeoutMs??3e4),a=B.parse({...t,funnelId:n.funnelId,operation:"campaign_decide"}),u=q({...n,timeoutMs:Math.min(n.timeoutMs??35e3,Math.max(1,e-Date.now()))});u.identify(n.apiKey);let l=R.parse(await u.request("funnels",a));if(l.scope.projectId!==n.scope.projectId||l.scope.environment!==n.scope.environment)throw new s("SCOPE_MISMATCH","Campaign scope changed");return k(l,a.customer,e,(i,c)=>G({...n,timeoutMs:Math.min(n.timeoutMs??1e4,Math.max(1,c-Date.now()))}).read(i))},async start(t){let e=B.parse({...t,funnelId:n.funnelId,operation:"campaign_start"}),a=se.parse(await r.request("funnels",e));if(a.scope.projectId!==n.scope.projectId||a.scope.environment!==n.scope.environment)throw new s("SCOPE_MISMATCH","Campaign scope changed");if(!("suppressed"in a)&&(a.run.source.id!==n.funnelId||!a.customerId||e.customer.type==="id"&&a.customerId!==e.customer.value))throw new s("INVALID_RESPONSE","Campaign Funnel or Customer changed");return a}}}function xt(){if(typeof window<"u")throw new s("SERVER_ONLY","Guest identity is issued by your backend");let n=crypto.getRandomValues(new Uint8Array(32));return"gg_gc_"+btoa(String.fromCharCode(...n)).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function kt(n){if(typeof window<"u")throw new s("SERVER_ONLY","Secret API keys must stay on your backend");let r=q(n);return r.identify(n.apiKey),{async listInvoiceTemplates(t={}){let e=o.listInvoiceTemplates;return p(e.response,await r.request(e.path,e.request.parse(t)))},async previewInvoice(t){let e=o.previewInvoice;return p(e.response,await r.request(e.path,e.request.parse(t)))},async createInvoice(t){let e=o.createInvoice;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageInvoice(t){let e=o.manageInvoice;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readInvoiceOperation(t){let e=o.readInvoiceOperation;return p(e.response,await r.request(e.path,e.request.parse(t)))},async listInvoices(t){let e=o.listInvoices;return p(e.response,await r.request(e.path,e.request.parse(t)))},async getInvoice(t){let e=o.getInvoice;return p(e.response,await r.request(e.path,e.request.parse(t)))},async recordCouponRedemption(t){let e=o.recordCouponRedemption,a=e.request.safeParse(t);if(!a.success)throw new s("INVALID_REQUEST","Invalid Coupon redemption facts");return p(e.response,await r.request(e.path,a.data))},async getFeatures(t={}){let e=o.getFeatures;return p(e.response,await r.request(e.path,e.request.parse(t),e.method))},async evaluateFeatures(t){let e=o.evaluateFeatures;return p(e.response,await r.request(e.path,e.request.parse(t),e.method))},async trackEvents(t){let e=o.trackEvents;return p(e.response,await r.request(e.path,e.request.parse(t),e.method))},async resolvePaywall(t){let e=o.resolvePaywall;return p(e.response,await r.request(e.path,e.request.parse(t)))},async resolveOffering(t){let e=o.resolveOffering;return p(e.response,await r.request(e.path,e.request.parse(t)))},async checkEntitlement(t){let e=o.checkEntitlement;return p(e.response,await r.request(e.path,e.request.parse(t)))},async setupPayment(t){let e=o.setupPayment;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readPaymentSetup(t){let e=o.readPaymentSetup;return p(e.response,await r.request(e.path,e.request.parse(t)))},async previewSubscriptionBatch(t){let e=o.previewSubscriptionBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async confirmSubscriptionBatch(t){let e=o.confirmSubscriptionBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionBatch(t){let e=o.readSubscriptionBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async abandonSubscriptionBatch(t){let e=o.abandonSubscriptionBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageSubscriptionTrial(t){let e=o.manageSubscriptionTrial;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionTrial(t){let e=o.readSubscriptionTrial;return p(e.response,await r.request(e.path,e.request.parse(t)))},async listSubscriptions(t){let e=o.listSubscriptions;return p(e.response,await r.request(e.path,e.request.parse(t)))},async listPurchases(t){let e=o.listPurchases;return p(e.response,await r.request(e.path,e.request.parse(t)))},async listSubscriptionConflicts(t){let e=o.listSubscriptionConflicts;return p(e.response,await r.request(e.path,e.request.parse(t)))},async retrySubscriptionConflict(t){let e=o.retrySubscriptionConflict;return p(e.response,await r.request(e.path,e.request.parse(t)))},async previewRefund(t){let e=o.previewRefund;return p(e.response,await r.request(e.path,e.request.parse(t)))},async refund(t){let e=o.refund;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readRefund(t){let e=o.readRefund;return p(e.response,await r.request(e.path,e.request.parse(t)))},async previewUpdate(t){let e=o.previewUpdate;return p(e.response,await r.request(e.path,e.request.parse(t)))},async update(t){let e=o.update;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionUpdate(t){let e=o.readSubscriptionUpdate;return p(e.response,await r.request(e.path,e.request.parse(t)))},async restoreNativePurchase(t){let e=o.restoreNativePurchase;return p(e.response,await r.request(e.path,e.request.parse(t)))},async verifySubscriptions(t){let e=o.verifySubscriptions;return p(e.response,await r.request(e.path,e.request.parse(t)))},async previewAttach(t){let e=o.previewAttach;return p(e.response,await r.request(e.path,e.request.parse(t)))},async attach(t){let e=o.attach;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionOperation(t){let e=o.readSubscriptionOperation;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readAiPricing(t){let e=o.readAiPricing;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readUsage(t){let e=o.readUsage;return p(e.response,await r.request(e.path,e.request.parse(t)))},async setUsage(t){let e=o.setUsage;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageBalanceGrant(t){let e=o.manageBalanceGrant;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readBalanceSource(t){let e=o.readBalanceSource;return p(e.response,await r.request(e.path,e.request.parse(t)))},async adjustBalance(t){let e=o.adjustBalance;return p(e.response,await r.request(e.path,e.request.parse(t)))},async listBalanceGrants(t){let e=o.listBalanceGrants;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageBillingLimits(t){let e=o.manageBillingLimits;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSeats(t){let e=o.readSeats;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageSeat(t){let e=o.manageSeat;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageUsageEntity(t){let e=o.manageUsageEntity;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readUsageAnalytics(t){let e=o.readUsageAnalytics;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readCreditAnalytics(t){let e=o.readCreditAnalytics;return p(e.response,await r.request(e.path,e.request.parse(t)))},async submitUsageBatch(t){let e=o.submitUsageBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readUsageBatch(t){let e=o.readUsageBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readHoldings(t){let e=o.readHoldings;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readLedger(t){let e=o.readLedger;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readBillingInvoice(t){let e=o.readBillingInvoice;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readCreditStatement(t){let e=o.readCreditStatement;return p(e.response,await r.request(e.path,e.request.parse(t)))},async quoteBalance(t){let e=o.quoteBalance;return p(e.response,await r.request(e.path,e.request.parse(t)))},async trackUsage(t){let e=o.trackUsage;return p(e.response,await r.request(e.path,e.request.parse(t)))},async mutateBalance(t){let e=o.mutateBalance;return p(e.response,await r.request(e.path,e.request.parse(t)))},async getCustomer(t){let e=o.getCustomer,a=e.request.safeParse(t);if(!a.success)throw new s("INVALID_REQUEST","Invalid customer lookup");let u=e.response.safeParse(await r.request(e.path,a.data));if(!u.success)throw new s("INVALID_RESPONSE","Invalid customer response");return u.data},async listCustomers(t={}){let e=o.listCustomers,a=e.request.safeParse(t);if(!a.success)throw new s("INVALID_REQUEST","Invalid customer filters");let u=e.response.safeParse(await r.request(e.path,a.data));if(!u.success)throw new s("INVALID_RESPONSE","Invalid customer response");return u.data},async updateCustomer(t){let e=o.updateCustomer,a=e.request.safeParse(t);if(!a.success)throw new s("INVALID_REQUEST","Invalid customer patch");let u=e.response.safeParse(await r.request(e.path,a.data));if(!u.success)throw new s("INVALID_RESPONSE","Invalid customer response");return u.data},async createGuestCustomer(t){let e=o.createGuestCustomer;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async resumeGuestSession(t){let e=o.resumeGuestSession;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async claimGuestCustomer(t){let e=o.claimGuestCustomer;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async renewCustomerSession(t){let e=o.renewSession;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async revokeCustomerSessions(t){let e=o.revokeSessions;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async createCustomerSession(t){let e=o.createSession.request.safeParse({customerId:t});if(!e.success)throw new s("INVALID_REQUEST","A customer ID is required");let a=o.createSession.response.safeParse(await r.request("customer-sessions",e.data));if(!a.success)throw new s("INVALID_RESPONSE","Invalid customer session response");return a.data},async getOrCreateCustomer(t){let e=o.createCustomer.request.safeParse(t);if(!e.success)throw new s("INVALID_REQUEST","Invalid customer input");let a=o.createCustomer.response.safeParse(await r.request("customers",e.data));if(!a.success)throw new s("INVALID_RESPONSE","Invalid customer response");return a.data},async grantOffer(t){let e=o.grantOffer.request.safeParse({...t,requestId:t.requestId??crypto.randomUUID()});if(!e.success||!e.data.customerId)throw new s("INVALID_REQUEST","Invalid offer grant");let a=o.grantOffer.response.safeParse(await r.request("offers/grant",e.data));if(!a.success)throw new s("INVALID_RESPONSE","Invalid offer response");return a.data}}}async function Tt(n,r){if(typeof window<"u")throw new s("SERVER_ONLY","Renewal requires your backend");let{funnelCredentialCommandSchema:t,funnelCredentialResponseSchema:e}=await import("./src-VGIVVM27.js"),a=q(n);return a.identify(n.apiKey),e.parse(await a.request("funnels",t.parse({...r,operation:"renew_run"})))}export{F as FunnelDecisionTimeoutError,s as IndianaError,Ce as aiPriceSnapshotSchema,Re as aiTokenQuoteSchema,Fe as createAiPricing,ke as createAiUsageMiddleware,Ee as createConfigurationSync,Le as createConfiguredAiPricing,j as createFeatureClient,Pe as createFunnelCampaignClient,G as createFunnelDecisionClient,x as createFunnelLocalEvaluator,Te as createFunnelOrchestrationClient,qe as createFunnelStartClient,xt as createGuestToken,kt as createIndianaServer,Ae as createLocalFunnelClient,Ne as createNativeReceiptClient,_e as createPaywallStartClient,Oe as createSynchronizedFunnelLocalEvaluator,Se as evaluateFunnelNode,Tt as renewFunnelRun};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as Xa,$a as Xb,$b as Cd,$c as Ge,$d as kh,$e as ki,$f as wj,$g as Ck,$h as Cl,$i as Cm,$j as Dn,A as Q,Aa as wb,Ab as Lc,Ac as fe,Ad as nf,Ae as Lh,Af as Ri,Ag as Xj,Ah as bl,Ai as bm,Aj as bn,Ak as ko,B as R,Ba as xb,Bb as Mc,Bc as ge,Bd as of,Be as Mh,Bf as Si,Bg as Yj,Bh as cl,Bi as cm,Bj as cn,Bk as lo,C as S,Ca as yb,Cb as Nc,Cc as he,Cd as pf,Ce as Nh,Cf as Ti,Cg as Zj,Ch as dl,Ci as dm,Cj as dn,Ck as mo,D as T,Da as zb,Db as Oc,Dc as ie,Dd as qf,De as Oh,Df as Ui,Dg as _j,Dh as el,Di as em,Dj as en,Dk as no,E as U,Ea as Ab,Eb as Pc,Ec as je,Ed as rf,Ee as Ph,Ef as Vi,Eg as $j,Eh as fl,Ei as fm,Ej as fn,Ek as oo,F as V,Fa as Bb,Fb as Qc,Fc as ke,Fd as uf,Fe as Qh,Ff as Wi,Fg as ak,Fh as gl,Fi as gm,Fj as gn,Fk as po,G as W,Ga as Cb,Gb as Rc,Gc as le,Gd as vf,Ge as Rh,Gf as Xi,Gg as bk,Gh as hl,Gi as hm,Gj as hn,Gk as qo,H as Z,Ha as Db,Hb as Sc,Hc as me,Hd as Sg,He as Sh,Hf as Yi,Hg as ck,Hh as il,Hi as im,Hj as jn,Hk as ro,I as _,Ia as Eb,Ib as Tc,Ic as ne,Id as Tg,Ie as Th,If as Zi,Ig as dk,Ih as jl,Ii as jm,Ij as kn,Ik as so,J as $,Ja as Fb,Jb as ad,Jc as oe,Jd as Ug,Je as Uh,Jf as _i,Jg as ek,Jh as kl,Ji as km,Jj as ln,Jk as to,K as aa,Ka as Gb,Kb as bd,Kc as pe,Kd as Vg,Ke as Vh,Kf as $i,Kg as fk,Kh as ll,Ki as lm,Kj as mn,Kk as uo,L as ba,La as Hb,Lb as cd,Lc as qe,Ld as Wg,Le as Wh,Lf as aj,Lg as gk,Lh as ml,Li as mm,Lj as nn,Lk as vo,M as ca,Ma as Ib,Mb as dd,Mc as re,Md as Xg,Me as Xh,Mf as bj,Mg as hk,Mh as nl,Mi as nm,Mj as on,Mk as wo,N as da,Na as Jb,Nb as ed,Nc as se,Nd as Yg,Ne as Yh,Nf as cj,Ng as ik,Nh as ol,Ni as om,Nj as pn,Nk as xo,O as ea,Oa as Kb,Ob as fd,Oc as te,Od as Zg,Oe as Zh,Of as dj,Og as jk,Oh as pl,Oi as pm,Oj as qn,Ok as yo,P as fa,Pa as Lb,Pb as gd,Pc as ue,Pd as _g,Pe as _h,Pf as ej,Pg as kk,Ph as ql,Pi as qm,Pj as rn,Pk as zo,Q as ga,Qa as Mb,Qb as hd,Qc as ve,Qd as $g,Qe as $h,Qf as fj,Qg as rk,Qh as rl,Qi as rm,Qj as sn,Qk as Ao,R as ha,Ra as Nb,Rb as id,Rc as we,Rd as ah,Re as ai,Rf as gj,Rg as sk,Rh as sl,Ri as sm,Rj as tn,Rk as Bo,S as ia,Sa as Ob,Sb as jd,Sc as xe,Sd as bh,Se as bi,Sf as hj,Sg as tk,Sh as tl,Si as tm,Sj as un,Sk as Co,T as ja,Ta as Pb,Tb as kd,Tc as ye,Td as ch,Te as ci,Tf as ij,Tg as uk,Th as ul,Ti as um,Tj as vn,Tk as Do,U as ka,Ua as Qb,Ub as ld,Uc as ze,Ud as dh,Ue as di,Uf as jj,Ug as vk,Uh as vl,Ui as vm,Uj as wn,Uk as Eo,V as Ra,Va as Rb,Vb as md,Vc as Ae,Vd as eh,Ve as ei,Vf as kj,Vg as wk,Vh as wl,Vi as wm,Vj as xn,W as Sa,Wa as Sb,Wb as nd,Wc as Be,Wd as fh,We as fi,Wf as lj,Wg as xk,Wh as xl,Wi as xm,Wj as yn,X as Ta,Xa as Tb,Xb as yd,Xc as Ce,Xd as gh,Xe as gi,Xf as sj,Xg as yk,Xh as yl,Xi as ym,Xj as zn,Y as Ua,Ya as Ub,Yb as zd,Yc as De,Yd as hh,Ye as hi,Yf as tj,Yg as zk,Yh as zl,Yi as zm,Yj as An,Z as Va,Za as Vb,Zb as Ad,Zc as Ee,Zd as ih,Ze as ii,Zf as uj,Zg as Ak,Zh as Al,Zi as Am,Zj as Bn,_ as Wa,_a as Wb,_b as Bd,_c as Fe,_d as jh,_e as ji,_f as vj,_g as Bk,_h as Bl,_i as Bm,_j as Cn,a,aa as Ya,ab as Yb,ac as Dd,ad as He,ae as lh,af as li,ag as xj,ah as Dk,ai as Dl,aj as Dm,ak as En,b,ba as Za,bb as Zb,bc as Id,bd as Ie,be as mh,bf as mi,bg as yj,bh as Ek,bi as El,bj as Em,bk as Fn,c,ca as _a,cb as _b,cc as Jd,cd as Je,ce as nh,cf as ni,cg as zj,ch as Fk,ci as Fl,cj as Fm,ck as Gn,d,da as $a,db as $b,dc as Kd,dd as Ke,de as oh,df as oi,dg as Aj,dh as Gk,di as Gl,dj as Gm,dk as Hn,e,ea as ab,eb as ac,ec as Ld,ed as Le,ee as ph,ef as pi,eg as Bj,eh as Hk,ei as Hl,ej as Hm,ek as In,f,fa as bb,fb as bc,fc as Md,fd as Me,fe as qh,ff as qi,fg as Cj,fh as Ik,fi as Il,fj as Im,fk as Jn,g,ga as cb,gb as cc,gc as Nd,gd as Ne,ge as rh,gf as ri,gg as Dj,gh as Jk,gi as Jl,gj as Jm,gk as Kn,h,ha as db,hb as dc,hc as Od,hd as Oe,he as sh,hf as si,hg as Ej,hh as Kk,hi as Kl,hj as Km,hk as Ln,i,ia as eb,ib as ec,ic as Pd,id as Pe,ie as th,if as ti,ig as Fj,ih as Lk,ii as Ll,ij as Lm,ik as Mn,j,ja as fb,jb as fc,jc as Qd,jd as Xe,je as uh,jf as ui,jg as Gj,jh as Mk,ji as Ml,jj as Mm,jk as Nn,k,ka as gb,kb as vc,kc as Rd,kd as Ye,ke as vh,kf as vi,kg as Hj,kh as Nk,ki as Nl,kj as Nm,kk as On,l,la as hb,lb as wc,lc as Sd,ld as Ze,le as wh,lf as wi,lg as Ij,lh as Ok,li as Ol,lj as Om,lk as Pn,m,ma as ib,mb as xc,mc as Td,md as _e,me as xh,mf as xi,mg as Jj,mh as Pk,mi as Pl,mj as Pm,mk as Qn,n,na as jb,nb as yc,nc as Ud,nd as $e,ne as yh,nf as yi,ng as Kj,nh as Qk,ni as Ql,nj as Qm,nk as Rn,o,oa as kb,ob as zc,oc as Vd,od as af,oe as zh,of as zi,og as Lj,oh as Rk,oi as Rl,oj as Rm,ok as Sn,p,pa as lb,pb as Ac,pc as Wd,pd as bf,pe as Ah,pf as Ai,pg as Mj,ph as Sk,pi as Sl,pj as Sm,pk as Tn,q,qa as mb,qb as Bc,qc as Xd,qd as cf,qe as Bh,qf as Bi,qg as Nj,qh as Tk,qi as Tl,qj as Tm,qk as Un,r,ra as nb,rb as Cc,rc as Yd,rd as df,re as Ch,rf as Ci,rg as Oj,rh as Uk,ri as Ul,rj as Um,rk as Vn,s,sa as ob,sb as Dc,sc as Zd,sd as ef,se as Dh,sf as Di,sg as Pj,sh as Vk,si as Vl,sj as Vm,sk as Wn,t as z,ta as pb,tb as Ec,tc as _d,td as ff,te as Eh,tf as Ei,tg as Qj,th as Wk,ti as Wl,tj as Wm,tk as Xn,u as A,ua as qb,ub as Fc,uc as $d,ud as gf,ue as Fh,uf as Fi,ug as Rj,uh as Xk,ui as Xl,uj as Xm,uk as Yn,v as B,va as rb,vb as Gc,vc as ae,vd as hf,ve as Gh,vf as Gi,vg as Sj,vh as Yk,vi as Yl,vj as Ym,vk as Zn,w as C,wa as sb,wb as Hc,wc as be,wd as jf,we as Hh,wf as Hi,wg as Tj,wh as Zk,wi as Zl,wj as Zm,wk as _n,x as D,xa as tb,xb as Ic,xc as ce,xd as kf,xe as Ih,xf as Oi,xg as Uj,xh as _k,xi as _l,xj as _m,xk as ho,y as E,ya as ub,yb as Jc,yc as de,yd as lf,ye as Jh,yf as Pi,yg as Vj,yh as $k,yi as $l,yj as $m,yk as io,z as P,za as vb,zb as Kc,zc as ee,zd as mf,ze as Kh,zf as Qi,zg as Wj,zh as al,zi as am,zj as an,zk as jo}from"./chunk-HU2HIDVT.js";import{$ as xd,$a as ig,A as lc,Aa as Jf,Ab as Jg,B as mc,Ba as Kf,Bb as Kg,C as nc,Ca as Lf,Cb as Lg,D as oc,Da as Mf,Db as Mg,E as pc,Ea as Nf,Eb as Ng,F as qc,Fa as Of,Fb as Og,G as rc,Ga as Pf,Gb as Pg,H as sc,Ha as Qf,Hb as Qg,I as tc,Ia as Rf,Ib as Rg,J as uc,Ja as Sf,Jb as mj,K as Uc,Ka as Tf,Kb as nj,L as Vc,La as Uf,Lb as oj,M as Wc,Ma as Vf,Mb as pj,N as Xc,Na as Wf,Nb as qj,O as Yc,Oa as Xf,Ob as rj,P as Zc,Pa as Yf,Pb as lk,Q as _c,Qa as Zf,Qb as mk,R as $c,Ra as _f,Rb as nk,S as od,Sa as $f,Sb as ok,T as pd,Ta as ag,Tb as pk,U as qd,Ua as bg,Ub as qk,V as rd,Va as cg,W as sd,Wa as dg,X as td,Xa as eg,Y as ud,Ya as fg,Z as vd,Za as gg,_ as wd,_a as hg,a as t,aa as Ed,ab as jg,b as u,ba as Fd,bb as kg,c as v,ca as Gd,cb as lg,d as w,da as Hd,db as mg,e as x,ea as Qe,eb as ng,f as y,fa as Re,fb as og,g as F,ga as Se,gb as pg,h as G,ha as Te,hb as qg,i as H,ia as Ue,ib as rg,j as I,ja as Ve,jb as sg,k as J,ka as We,kb as tg,l as K,la as sf,lb as ug,m as L,ma as tf,mb as vg,n as M,na as wf,nb as wg,o as N,oa as xf,ob as xg,p as O,pa as yf,pb as yg,q as Ma,qa as zf,qb as zg,r as Na,ra as Af,rb as Ag,s as Oa,sa as Bf,sb as Bg,t as Pa,ta as Cf,tb as Cg,u as Qa,ua as Df,ub as Dg,v as gc,va as Ef,vb as Eg,w as hc,wa as Ff,wb as Fg,x as ic,xa as Gf,xb as Gg,y as jc,ya as Hf,yb as Hg,z as kc,za as If,zb as Ig}from"./chunk-RMJJOSVZ.js";import{a as X,b as Y,c as Ii,d as Ji,e as Ki,f as Li,g as Mi,h as Ni,i as $n,j as ao,k as bo,l as co,m as eo,n as fo,o as go}from"./chunk-OHDY27EI.js";import{A as Ia,B as Ja,C as Ka,D as La,a as la,b as ma,c as na,f as oa,g as pa,h as qa,i as ra,j as sa,l as ta,m as ua,n as va,o as wa,p as xa,q as ya,r as za,s as Aa,t as Ba,u as Ca,v as Da,w as Ea,x as Fa,y as Ga,z as Ha}from"./chunk-S2MSIA57.js";export{Yh as CODE_REFERENCE_LIMITS,Pa as COMMON_LOCALES,ho as CONFIGURATION_POLICY,Ra as COUPON_TERM_LOCALES,Hf as CUSTOMER_DATA_SOURCES,Td as CreateInvoiceParamsSchema,Sd as CreateInvoicePreviewSchema,Rm as DEFAULT_AUDIENCE_GROUP,Bk as DEFAULT_FUNNEL_EXECUTION_POLICY,dl as FUNNEL_API_CAPABILITIES,uj as FUNNEL_EXECUTION_LIMITS,sj as FUNNEL_LIMITS,km as FUNNEL_PREVIEW_LIMITS,Do as FUNNEL_READ_ONLY_OPERATIONS,vj as FUNNEL_RECORDING_LIMITS,to as FUNNEL_SEGMENT_BYTES,so as FUNNEL_SEGMENT_LIMIT,$l as FUNNEL_SERVER_KEY_HEADER,ql as FunnelCalculationError,Qd as InvoiceModeParamsSchema,Rd as InvoiceTemplateSchema,Ze as OFFERING_MAX_DEPTH,$e as OFFERING_MAX_ITEMS,_e as OFFERING_MAX_PRODUCTS,Bg as POPUP_WIDTHS,Pd as ReissueInvoiceParamsSchema,Sf as SCREEN_LIMITS,mj as SCREEN_RENDER_PATH,Rf as SCREEN_SCHEMA_VERSION,zj as SCREEN_TEMPLATES,vc as SDK_PROTOCOL_HEADER,xc as SDK_SUPPORT_HEADER,yc as SDK_SUPPORT_POLICY,wc as SDK_VERSION_HEADER,zg as SURFACE_PATHS,zf as SURFACE_VARIABLES,Ec as SdkProtocolError,tj as UNBOUND_PRODUCT_VERSION_ID,fo as VISUAL_EDITOR_PARAM,Cc as addSupportMonths,j as aiCreditSystemConfigSchema,lh as aiMarkupSchema,kh as aiModelIdSchema,mh as aiModelRatesSchema,nh as aiPricingConfigurationSchema,jh as aiTokenPools,w as amountToMinor,Fi as analyticsConfigSchema,Hi as analyticsEventEnabled,lc as apiErrorCatalog,mc as apiErrorCodeForStatus,gc as apiErrorCodeSchema,kj as apiOperations,dj as apiPermissionSchema,kn as appResultsSchema,jn as appRevenueSchema,tn as appendScreenTemplate,Rn as applyGrowthReleasePlan,_j as archiveSurfaceTemplateSchema,Um as audienceCustomerSchema,bn as audienceFunnelUsageSchema,cn as audienceFunnelUsagesSchema,Vm as audienceMembersSchema,Hc as audienceSchema,Tm as audienceWriteSchema,Mm as auditFieldSchema,Pm as auditHistoryCursorSchema,Qm as auditHistorySchema,Lm as auditResourceSchema,qb as autoTopupPurchaseLimitSchema,Cb as autoTopupStateSchema,Yn as autumnAmountToMinor,Am as autumnCustomerAutoTopupSchema,Fm as autumnCustomerControlsSchema,Hm as autumnCustomerMetadataSchema,Em as autumnCustomerOverageAllowedSchema,Jm as autumnCustomerProductSummarySchema,Im as autumnCustomerProfileRecordSchema,Bm as autumnCustomerSpendLimitSchema,Dm as autumnCustomerUsageAlertSchema,Cm as autumnCustomerUsageLimitSchema,Gm as autumnEntityControlsSchema,Zn as autumnMinorToAmount,_n as autumnUsageUnitAmountDecimal,eh as balanceAdjustmentCommandSchema,fh as balanceAdjustmentStateSchema,Yc as balanceAllocationSchema,Vc as balanceCommandSchema,bd as balanceGrantCommandSchema,ad as balanceGrantCreateSchema,ed as balanceGrantPageSchema,dd as balanceGrantReadSchema,cd as balanceGrantSchema,$c as balanceOperationSchema,Wc as balancePricingSegmentSchema,_c as balanceQuoteSchema,Xc as balanceReceiptUnitsSchema,Zc as balanceRejectionReasonSchema,zn as balanceSourceReasonSchema,gh as balanceSourceStateSchema,An as balanceSourceStatusSchema,Cn as balanceSourcesPageSchema,Bn as balanceSourcesQuerySchema,jb as billingAccruedMinorSchema,ib as billingAmountMinorSchema,tb as billingAuthorizationSchema,sb as billingAuthorizationTermsSchema,kb as billingBudgetMinorSchema,Db as billingControlInputSchema,Eb as billingControlsSchema,Mb as billingCouponsSchema,z as billingCurrencies,Fb as billingInvoiceLineSchema,Gb as billingInvoiceSchema,Jb as billingInvoicesSchema,xb as billingLimitSchema,Wj as billingPortalInputSchema,Xj as billingPortalSchema,D as billingSettingsMutationSchema,B as billingSettingsSchema,C as billingSettingsScopeSchema,Bb as billingUsageWindowSchema,eg as borderSchema,kg as buttonNodeSchema,rl as calculateFunnelNode,Kc as campaignInputSchema,Ic as campaignOfferSchema,Lc as campaignSchema,Na as canonicalLocale,Af as capabilityBindingSchema,ob as cashPriceSchema,mb as cashPricingSchema,lb as cashPricingTiersSchema,hb as cashUnitAmountMinorSchema,Oh as claimRewardProductRequestSchema,$h as codeReferenceBranchSchema,fi as codeReferenceConfigRequestSchema,ei as codeReferenceConfigureSchema,li as codeReferenceFeatureSummarySchema,Zh as codeReferenceKeySchema,ai as codeReferencePathSchema,ii as codeReferenceReceiptSchema,_h as codeReferenceRepoSchema,hi as codeReferenceReportSchema,ci as codeReferenceRepositoryInputSchema,di as codeReferenceRepositorySchema,gi as codeReferenceScanConfigSchema,ji as codeReferenceScanSchema,ki as codeReferenceSettingsSchema,mi as codeReferenceSummarySchema,Gd as commerceAccessSchema,Qe as commerceContextSchema,De as commerceCursorSchema,Ee as commerceListQuerySchema,Hd as commerceMoneySchema,vn as commerceProductKind,Fd as commerceProductKindSchema,Ed as commerceProviderSchema,Ea as compileGrowthFeatures,ko as configurationArtifactSchema,qo as configurationDependencies,jo as configurationDependenciesSchema,oo as configurationDigest,lo as configurationFunnelSchema,po as configurationGeneration,no as configurationJson,io as configurationScopeSchema,Hb as confirmBillingAdjustmentInputSchema,vb as confirmBillingAuthorizationInputSchema,ic as consoleErrorCodeSchema,tc as consoleErrorResponseSchema,Vn as consoleHasPermission,ne as consoleRefundRequestSchema,Tn as consoleResources,Un as consoleRolePermissions,Sn as consoleRoleSchema,rg as countdownNodeSchema,Ya as couponAppliesToSchema,bb as couponChangeErrors,qg as couponCodeNodeSchema,tl as couponContentDigestSchema,Wa as couponDiscountSchema,Wm as couponDisplaySchema,Ej as couponDistributionBatchSchema,Gj as couponDistributionDetailSchema,Dj as couponDistributionPreviewSchema,Fj as couponDistributionRecipientSchema,Hj as couponDistributionWriteSchema,Xa as couponDurationSchema,Za as couponEligibilitySchema,_a as couponInputSchema,Di as couponRedemptionCommandSchema,Ei as couponRedemptionReceiptSchema,Va as couponStatusSchema,zm as couponTemplateExample,xm as couponTemplateKey,eb as couponWindow,Zm as createAccountOverviewPage,Ym as createCreditCenterPage,$m as createCustomerPageTemplates,gj as createCustomerRequestSchema,hj as createCustomerResponseSchema,_m as createMembershipPage,Qh as createReferralCodeRequestSchema,F as creditAmountSchema,qh as creditAnalyticsFilterSchema,sh as creditAnalyticsPageSchema,rh as creditAnalyticsQuerySchema,oh as creditAnalyticsRangeSchema,ph as creditAnalyticsTimezoneSchema,L as creditDimensionSchema,M as creditMultiplierSchema,H as creditPriceAdjustmentSchema,N as creditPricingSchema,J as creditPropertiesSchema,G as creditQuantitySchema,O as creditRateSchema,Ob as creditResetCountSchema,Nb as creditResetSchema,I as creditResourceKeySchema,Pb as creditRolloverSchema,c as creditSchemaItemSchema,id as creditStatementInputSchema,jd as creditStatementSchema,i as creditSystemConfigSchema,K as creditTiersSchema,t as currencies,A as currencyAmountOptionsSchema,v as currencyDecimals,u as currencySchema,lj as currentApiOperations,kd as currentNotificationEventTypeSchema,og as customHtmlNodeSchema,ka as customerActivitySchema,oi as customerAttributesSchema,Sm as customerAudienceSchema,Jf as customerDataConfigSchema,Mf as customerDataIntentSchema,mg as customerDataNodeSchema,ui as customerDataReferenceMessage,ti as customerDataReferenced,si as customerDataSchema,If as customerDataSourceSchema,jj as customerEntitlementsSchema,Bi as customerFiltersSchema,pi as customerFingerprintSchema,ln as customerFunnelDecisionsSchema,zi as customerGetSchema,sd as customerHoldingsSchema,qi as customerInputSchema,wd as customerLedgerEntrySchema,xd as customerLedgerPageSchema,vd as customerLedgerQuerySchema,xi as customerLookupSchema,wi as customerMutationSchema,Lf as customerPageDataSchema,Kf as customerPageNodeStateSchema,Km as customerPageSampleData,Ci as customerPageSchema,yi as customerPatchSchema,ec as customerPlanCreateSchema,fc as customerPlanCreatedSchema,ja as customerPlanSchema,vi as customerProfileSchema,ri as customerReferenceSchema,Vj as customerScheduledChangeCancelSchema,Tj as customerScheduledChangeSchema,Uj as customerScheduledChangesSchema,Mc as customerSchema,ni as customerTagsSchema,Ai as customerUpdateRequestSchema,bi as defaultCodeReferenceMethods,yj as defaultScreenTheme,cb as describeCoupon,_b as diffProductVariant,lg as dividerNodeSchema,Nf as emptyCustomerPageNode,Se as entitlementCheckInputSchema,Te as entitlementCheckReasonSchema,Ve as entitlementCheckResultSchema,Re as entitlementRequirementSchema,ga as entitlementSnapshotSchema,ij as entitlementStatusSchema,X as environmentSchema,Cd as environmentSettingsSchema,oc as errorCodeMatchesStatus,uc as errorMetadata,qc as errorMetadataSchema,nc as errorPolicy,kc as errorReasonSchema,jc as errorRecoverySchema,rc as errorResponseSchema,Pf as escapeHtmlText,pa as evalCondition,sa as evalFeature,Qi as evaluateFeaturesRequestSchema,Si as evaluateFeaturesResultSchema,Yl as executionSourceSchema,Bo as expandFunnelSegment,Da as experimentConfigurationSchema,Ca as experimentPhaseSchema,Ha as experimentSnapshotSchema,n as featureCollectionSchema,g as featureConfigOverrideSchema,k as featureDefinitionSchema,Oi as featureDeliveryPayloadSchema,a as featureIdSchema,$ as featureInputSchema,f as featureMarkupsOverrideSchema,o as featureOptionsSchema,Ni as featurePayloadSchema,m as featureRecordSchema,aa as featureSchema,Wn as featureTypes,Xn as featureUpdateBlockers,l as featureUpdateRulesSchema,od as featureUsageReadSchema,pd as featureUsageSetSchema,qd as featureUsageStateSchema,b as featureUsageTypeSchema,p as featureWriteSchema,Hg as fieldValue,cg as fillSchema,rd as financialAmountSchema,ud as financialCursorSchema,td as financialEntryTypeSchema,Pg as findDocumentNode,Og as findNode,wm as formatCouponConditions,Ta as formatCouponDiscount,Sa as formatCouponMoney,Ua as formatCouponTerms,y as formatCurrencyMinor,yn as formatProductBillingPeriod,db as formatUsd,el as funnelApiBindingSchema,bl as funnelApiProjectionSchema,Wk as funnelBundleDefinitionSchema,_k as funnelBundleLiterals,Zk as funnelBundleResultSchema,Xk as funnelBundleSelectionSchema,cm as funnelCampaignCommandSchema,dm as funnelCampaignStartResponseSchema,fl as funnelCapabilitySchema,Tl as funnelCollectionSchema,Ql as funnelCommandSchema,fm as funnelConfigurationSchema,Cl as funnelConsumedVariables,Ao as funnelContextDelta,am as funnelCredentialCommandSchema,bm as funnelCredentialResponseSchema,Pl as funnelDataQueriesSchema,Sk as funnelDecideShape,Tk as funnelDecisionCommandSchema,Mk as funnelDecisionEvaluationSchema,Qk as funnelDecisionOutputSchema,Uk as funnelDecisionResponseSchema,Rk as funnelDecisionSchema,Pk as funnelDecisionSegmentEvaluationSchema,Vk as funnelDecisionUsedResponseSchema,Ll as funnelDocumentDraftSchema,Nl as funnelDocumentSchema,ik as funnelEvaluationAttributes,Lk as funnelEvaluationInstructionSchema,Jk as funnelEvaluationModeSchema,Kk as funnelEvaluationResultSchema,Ak as funnelExecutionPolicySchema,Il as funnelExecutionStateSchema,hl as funnelExternalPageUrlSchema,zk as funnelExternalTaskSchema,kl as funnelGraphDraftSchema,jl as funnelGraphNodeSchema,ll as funnelGraphSchema,ml as funnelGraphTargets,an as funnelGroupReferenceSchema,Xl as funnelInstructionSchema,sl as funnelInvocationId,gm as funnelLocalConfigurationSchema,vl as funnelLocalScreenCommandSchema,wl as funnelLocalScreenResponseSchema,Ok as funnelLocalSegmentStepSchema,Eo as funnelNodeAcceptsEffect,Gl as funnelNodeInputSchema,El as funnelNodeKindSchema,fk as funnelNodeProjections,Hl as funnelNodeResultSchema,ck as funnelNodeWritesSchema,il as funnelOpenInSchema,Fk as funnelOrchestrationCommandSchema,ok as funnelParametersFromUrl,Ol as funnelPresentationSubmissionSchema,lm as funnelPreviewCommandSchema,om as funnelPreviewDependencySchema,pm as funnelPreviewJournalSchema,mm as funnelPreviewOutcomeSchema,rm as funnelPreviewRequestSchema,sm as funnelPreviewResponseSchema,nm as funnelPreviewScenarioSchema,um as funnelPreviewShareWriteSchema,tm as funnelPreviewSnapshotSchema,qm as funnelPreviewSourceSchema,$k as funnelProjectionFilterValueSchema,al as funnelProjectionWhereSchema,Ml as funnelPublishableDraftSchema,uo as funnelPureNode,Sl as funnelRecordSchema,Fl as funnelResourceReferenceSchema,dn as funnelResultsCursorSchema,en as funnelResultsQuerySchema,Ik as funnelResultsResponseSchema,fn as funnelResultsSchema,Zl as funnelRunViewSchema,_l as funnelRuntimeResponseSchema,Wl as funnelRuntimeStatusSchema,zl as funnelScreenReads,yl as funnelScreenTokens,Al as funnelScreenValues,Co as funnelSegmentConfigurationSchema,Nk as funnelSegmentEvaluationInstructionSchema,zo as funnelSegmentHasDynamicHash,vo as funnelSegmentPositionSchema,xo as funnelSegmentSchema,wo as funnelSegmentStepSchema,Gk as funnelSignalResponseSchema,vm as funnelStatisticsSchema,yo as funnelStepId,yk as funnelTaskBindingSchema,wk as funnelTaskDataSchema,xk as funnelTaskOutputsSchema,Ck as funnelTaskResponseSchema,Hk as funnelTaskResultsSchema,sn as funnelTemplateDraft,qn as funnelTemplateSchema,hm as funnelTopology,em as funnelTopologySchema,Jl as funnelTraceEventSchema,sk as funnelValueBindingSchema,$j as funnelValueDeclarationSchema,dk as funnelValueMatches,rk as funnelValuePathSchema,hk as funnelValueSchema,ak as funnelVariableDeclarationSchema,bk as funnelVariableDeclarationsSchema,xl as funnelVariableRead,ek as funnelVariableValues,wj as funnelVisitAllowed,Dl as funnelWaitKindSchema,Ul as funnelWriteSchema,Ji as gbRuntimeExperimentResultSchema,Ii as gbRuntimeExperimentSchema,Ki as gbRuntimeFeatureRuleSchema,Li as gbRuntimeFeatureSchema,Mi as gbRuntimeSavedGroupsSchema,la as getQueryStringOverride,Qn as getRecommendedRolloutData,qa as getStickyBucketAttributes,In as growthAttributeSchema,ua as growthAttributesSchema,Kn as growthCatalogSchema,xa as growthConditionGroupIds,kk as growthConditionPaths,va as growthConditionSchema,Mn as growthDryRunSchema,Nn as growthExperimentInspectionSchema,Fa as growthExperimentStop,Ga as growthFeatureExpiry,za as growthFeatureRuleSchema,Aa as growthFeatureSchema,Ba as growthFeaturesSchema,On as growthGroupReferenceCursorSchema,Pn as growthGroupReferencesSchema,wa as growthGroupSchema,Jn as growthNamespaceSchema,Ln as growthResourceWriteSchema,Ka as growthRuleContextSchema,ya as growthSavedGroupsSchema,Ia as growthSnapshotSchema,La as growthSplitResultSchema,Of as htmlVariableErrors,Uf as identifierSchema,jg as imageNodeSchema,bg as imagePositionSchema,$f as insetsSchema,Zi as invoiceCommandSchema,fd as invoiceDetailInputSchema,hd as invoiceDetailSchema,aj as invoiceOperationSchema,gd as invoiceProductItemSchema,me as invoiceRefundsSchema,Yi as invoiceTemplateCommandSchema,Xi as invoiceTemplatePageSchema,Vi as invoiceTemplateValuesSchema,pb as isInvoiceCreditPrice,wf as isProductGroup,un as isRecurringMembership,Qg as isRtlLocale,Bc as isStableSdkProtocol,na as isURLTargeted,nb as itemBillingCycleSchema,xj as jsonStorageBytes,ta as jsonValueSchema,E as licenseOfferSchema,Ib as listBillingInvoicesInputSchema,Qa as localeLabel,Ma as localeSchema,Ig as localeStatuses,Ng as localizeScreen,zb as manageBillingLimitsInputSchema,yb as manageOveragePolicyInputSchema,$i as managedInvoiceDetailSchema,bj as managedInvoicePageSchema,_i as managedInvoiceSchema,Wi as managedInvoiceTemplateSchema,hc as managementErrorCodeSchema,sc as managementErrorResponseSchema,ag as marginSchema,Oa as matchLocale,jk as matchesGrowthCondition,T as membershipActionSchema,wn as membershipBillingCount,U as membershipChangeSchema,V as membershipHoldingSchema,R as membershipRulesSchema,W as membershipStateSchema,S as membershipTimingSchema,Nm as mergeAuditSchema,_ as metadataSchema,h as meteredConfigSchema,x as minorToAmount,e as modelMarkupsSchema,nn as nativeCompletionSchema,Id as nativeCouponStoreOfferLinkWriteSchema,Jd as nativeCouponStoreOfferLinksSchema,Rc as nativeProductBindingSchema,Tc as nativeProductBindingWriteSchema,Sc as nativeProductBindingsPageSchema,mn as nativeProofSchema,Od as nativePurchaseInstructionSchema,on as nativeReceiptCommandSchema,pn as nativeReceiptResponseSchema,Oe as nativeRestoreCommandSchema,Pe as nativeRestoreResultSchema,Md as nativeStoreOfferForProduct,Kd as nativeStoreOfferSelectionSchema,Ld as nativeStoreOfferSelectionsSchema,Nd as nativeStoreSelectionMatches,ee as nativeSubscriptionUpdatePreviewSchema,fe as nativeSubscriptionUpdateResultSchema,Cj as newBlankSurface,ab as newCouponInput,Gi as newEnvironmentAnalyticsConfig,Vl as newFunnelDocument,Aj as newScreenFromTemplate,Bj as newSurfaceFromTemplate,Tf as nodeIdSchema,Om as objectAuditSchema,gn as offerFlowInputSchema,hn as offerFlowResultSchema,fb as offerSchema,gb as offerUnavailableReasonSchema,ff as offeringAuthorSchema,kf as offeringCollectionSchema,ef as offeringDocumentSchema,af as offeringItemSchema,bf as offeringItemsSchema,Ye as offeringMetadataSchema,gf as offeringProductEvidenceSchema,Xe as offeringProductIdSchema,cf as offeringProductIds,of as offeringProductOptionSchema,df as offeringProductPaths,qf as offeringPublicationIssues,hf as offeringRecordSchema,nf as offeringSelectorSchema,rf as offeringValueSchema,jf as offeringVersionSchema,pf as offeringWorkspaceSchema,mf as offeringWriteResultSchema,lf as offeringWriteSchema,Uc as overageBehaviorSchema,Ab as overagePolicySchema,Kl as ownedFunnelScreenSchema,Fn as pageExperimentEventSchema,Gn as pageExperimentEventsRequestSchema,Hn as pageExperimentEventsResponseSchema,En as pageExperimentPayloadSchema,Dn as pageExperimentSchema,Zf as paintColorSchema,ro as parsePublicFunnel,pc as parseRetryAfter,qj as parseScreenRenderPath,xe as paymentSetupCommandSchema,ye as paymentSetupReadSchema,Ae as paymentSetupSchema,Ue as paywallCandidateSchema,Ug as paywallClientActionSchema,_g as paywallCollectionSchema,Vg as paywallDocumentDraftSchema,Wg as paywallDocumentSchema,Yg as paywallFlowIssues,bh as paywallLibrarySchema,Xg as paywallProductIssues,uf as paywallProductsSchema,Zg as paywallRecordSchema,We as paywallRequestSchema,dh as paywallResolutionSchema,ch as paywallResolveInputSchema,$g as paywallSummarySchema,ah as paywallWriteSchema,da as planConfigSchema,ea as planInputSchema,ca as planItemSchema,sg as planPickerNodeSchema,fa as planSchema,ha as planVersionSchema,Jc as popupSchema,dc as prepaidAllowanceAmount,r as prepaidPriceAmount,s as prepaidQuantityAmount,Nc as prepaidQuantitySchema,q as prepaidTierPricingSchema,rb as prepareBillingAuthorizationInputSchema,ym as prepareCouponTemplate,oa as prepareSavedGroups,ub as preparedBillingAuthorizationSchema,Ag as presentationSchema,pg as priceNodeSchema,ba as priceSchema,Sb as productAllowanceSchema,Oc as productBindingSchema,Qc as productBindingWriteSchema,Pc as productBindingsPageSchema,bc as productCollectionSchema,Vb as productConfigurationSchema,Yb as productDefinitionSchema,cc as productEditorOptionsSchema,tf as productGroupingMatches,sf as productGroupingSchema,Ub as productLicenseSchema,Ij as productMigrationBlockReasonSchema,Pj as productMigrationDetailSchema,Jj as productMigrationErrorCodeSchema,Oj as productMigrationItemSchema,Mj as productMigrationItemStatusSchema,Qj as productMigrationListSchema,Kj as productMigrationPreviewSchema,Sj as productMigrationQuerySchema,Lj as productMigrationRunStatusSchema,Nj as productMigrationSchema,Rj as productMigrationWriteSchema,$b as productOptionsSchema,Rb as productPrepaidPriceSchema,Qb as productPricesSchema,ac as productRecordSchema,Sg as productSelectionSchema,Tb as productTrialSchema,Wb as productVariantOverridesSchema,Xb as productVariantSchema,cl as projectFunnelApiOutputs,im as projectFunnelConfiguration,jm as projectFunnelLocalConfiguration,Bd as projectSettingsSchema,$a as promotionCodeInputSchema,Ac as protocolForSdkVersion,d as providerMarkupsSchema,ul as publicCouponScreenDataSchema,Pi as publicFeatureConfigurationSchema,Jg as publishChecks,Ge as purchaseListItemSchema,Me as purchaseListPageSchema,Wf as radiusSchema,tk as readFunnelValuePath,Nh as redeemRewardRequestSchema,Rh as referralCodeSchema,Th as referralProgramCollectionSchema,Gh as referralProgramInputSchema,Ih as referralProgramRecordSchema,Lh as referralProgramWriteSchema,Ri as remoteFeatureResultSchema,Bl as renameFunnelScreenVariable,Dg as replaceFirstPageRoot,Xm as resolveCouponDisplay,Yk as resolveFunnelBundle,gl as resolveFunnelCapabilityInputs,Ek as resolveFunnelTaskInputs,uk as resolveFunnelValueBinding,vk as resolveFunnelValueBindings,Zb as resolveProductVariant,Mg as resolveScreenLocale,Fc as resolveSdkProtocol,fj as responseMetaSchema,wb as revokeBillingAuthorizationInputSchema,Vh as rewardActivityRedemptionSchema,Wh as rewardActivitySchema,Fh as rewardCodeInputSchema,Uh as rewardCodeSchema,Xh as rewardCodeWriteSchema,Sh as rewardCollectionSchema,Ch as rewardConfigurationSchema,Ah as rewardGrantExpirySchema,Bh as rewardGrantSchema,Eh as rewardInputSchema,Dh as rewardKeySchema,Jh as rewardOptionSchema,Ph as rewardProductCheckoutSchema,Hh as rewardRecordSchema,Mh as rewardRedemptionSchema,zh as rewardStatusSchema,yh as rewardTypeSchema,Kh as rewardWriteSchema,ra as runExperiment,xn as sameMembershipBillingCycle,Zj as saveSurfaceTemplateSchema,Y as scopeSchema,wg as screenActionSchema,mk as screenAnswersSchema,lk as screenDataCursorSchema,Eg as screenDocumentSchema,Xf as screenImageSourceSchema,pk as screenInputBindingsSchema,vg as screenNodeSchema,nk as screenParametersSchema,Tg as screenPresentationSchema,xf as screenProductScopes,yf as screenProductSelections,pj as screenRenderPath,nj as screenRenderPathSchema,rj as screenRenderTags,oj as screenRenderUrlSchema,qk as screenRendererInputSchema,Rg as screenSelections,xg as screenStringsSchema,mo as sdkConfigurationManifestSchema,zc as sdkProtocolRegistry,Gc as sdkProtocolResponseHeaders,zd as seatCommandSchema,yd as seatReadSchema,Ad as seatsStateSchema,ol as selectFunnelCondition,vf as selectedPaywallProduct,Gf as selectedSurfaceValue,Lg as servableLocales,Lb as setBillingCouponsInputSchema,fg as shadowSchema,dg as shapeSchema,_f as sizeSchema,Vf as spaceSchema,ng as spacerNodeSchema,Z as stableKeySchema,tg as stackInteractionSchema,ug as stackNodeSchema,Ja as stickyAssignmentDocumentSchema,Xd as stripeAppendContextSchema,Wd as stripeCouponTermsSchema,Yd as stripePurchaseExecutionSchema,je as stripeRefundExecutionSchema,ze as stripeSetupExecutionSchema,be as stripeSubscriptionUpdateExecutionSchema,ce as stripeSubscriptionUpdatePreviewSchema,de as stripeSubscriptionUpdateResultSchema,ue as stripeTrialExecutionSchema,hg as styleSchema,Ud as subscriptionAttachCommandSchema,Zd as subscriptionAttachQuoteSchema,oe as subscriptionBatchCommandSchema,qe as subscriptionBatchGroupSchema,pe as subscriptionBatchReadSchema,re as subscriptionBatchSchema,$d as subscriptionCarryOptionsSchema,Ne as subscriptionConflictPageSchema,Ie as subscriptionConflictQuerySchema,Ke as subscriptionConflictRetryResultSchema,Je as subscriptionConflictRetrySchema,He as subscriptionConflictSchema,Kb as subscriptionCouponExecutionSchema,cj as subscriptionInvoiceModeSchema,Fe as subscriptionListItemSchema,Le as subscriptionListPageSchema,Vd as subscriptionOperationInputSchema,_d as subscriptionOperationSchema,ie as subscriptionRefundCommandSchema,ke as subscriptionRefundPreviewSchema,le as subscriptionRefundResultSchema,se as subscriptionTrialCommandSchema,we as subscriptionTrialPolicySchema,te as subscriptionTrialReadSchema,ve as subscriptionTrialResultSchema,ae as subscriptionUpdateCommandSchema,ge as subscriptionUpdatePreviewSchema,he as subscriptionUpdateResultSchema,Be as subscriptionVerificationInputSchema,Ce as subscriptionVerificationSchema,Qf as substituteHtmlVariables,Ff as substituteSurfaceVariables,Cf as surfaceDataSchema,yg as surfaceSchema,Yj as surfaceTemplateSchema,Bf as surfaceValueSchema,Df as surfaceVariableNames,Kg as templateChecks,rn as templateScreen,ig as textNodeSchema,gg as textStyleSchema,Yf as themeSchema,ma as toAttributeString,Ti as trackEventsRequestSchema,Ui as trackEventsResultSchema,pl as transitionFunnelGraph,Gg as translatableFields,P as trialPolicySchema,Q as trialRecordSchema,Ef as unknownSurfaceVariables,md as usageAlertNotificationDataSchema,nd as usageAllowanceNotificationDataSchema,uh as usageAnalyticsPageSchema,th as usageAnalyticsQuerySchema,xh as usageBatchPageSchema,wh as usageBatchReadSchema,vh as usageBatchSubmitSchema,hh as usageEntityCommandSchema,ih as usageEntitySchema,ld as usageLimitNotificationDataSchema,nl as validateFunnelGraph,gk as validateFunnelProjections,Dk as validateFunnelTaskData,Rl as validateScreenAnswers,Dc as validateSdkProtocolRegistry,ia as validitySchema,ej as verifiedPrincipalSchema,ao as visualChangeSchema,eo as visualExperimentPayloadSchema,co as visualExperimentSchema,$n as visualMutationSchema,go as visualSelectedElementSchema,bo as visualVariationSchema,Cg as walkDocument,Fg as walkScreen,Dd as workspaceSettingsSchema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as y,c as w}from"./chunk-
|
|
1
|
+
import{a as y,c as w}from"./chunk-BIFEEVQO.js";function f(r){return CSS.escape(r)}function b(r){for(let t of["id","data-indiana-id","data-testid"]){let a=r.getAttribute(t);if(!a)continue;let s=t==="id"?`#${f(a)}`:`[${t}="${f(a)}"]`;if(document.querySelectorAll(s).length===1)return s}let c=[];for(let t=r;t&&t!==document.documentElement;t=t.parentElement){let a=t.tagName.toLowerCase(),s=[...t.classList].filter(o=>o.length<80).slice(0,3);s.length&&(a+=s.map(o=>`.${f(o)}`).join(""));let m=t.parentElement?[...t.parentElement.children].filter(o=>o.tagName===t.tagName):[];m.length>1&&(a+=`:nth-of-type(${m.indexOf(t)+1})`),c.unshift(a);let d=c.join(" > ");if(document.querySelectorAll(d).length===1)return d}return c.join(" > ")}function L(r,c={}){let t=window.opener;if(!t||r.expiresAt<=Date.now())return()=>{};let a=!1,s=!1,m=!1,d,o=document.createElement("div");o.setAttribute("data-indiana-editor-highlight",""),o.style.cssText="position:fixed;pointer-events:none;z-index:2147483647;outline:2px solid #6655ee;background:rgba(102,85,238,.1);display:none",document.body.append(o);function l(n,e={}){t.postMessage({channel:"indiana-visual",nonce:r.nonce,type:n,...e},r.origin)}let g=n=>n.composedPath().find(e=>e instanceof Element&&e!==o),h=n=>{if(!s)return;let e=g(n);if(!e)return;let i=e.getBoundingClientRect();Object.assign(o.style,{display:"block",left:`${i.left}px`,top:`${i.top}px`,width:`${i.width}px`,height:`${i.height}px`})},E=n=>{if(!s)return;let e=g(n);if(!e)return;n.preventDefault(),n.stopImmediatePropagation(),s=!1,o.style.display="none";let i=b(e),u={selector:i,tag:e.tagName.toLowerCase(),text:(e.textContent??"").slice(0,1e3),href:e.getAttribute("href")??"",src:e.getAttribute("src")??"",matches:document.querySelectorAll(i).length};l("selected",{element:u})};function p(){m||(m=!0,d?.revert(),o.remove(),clearInterval(x),removeEventListener("message",v),removeEventListener("mousemove",h,!0),removeEventListener("click",E,!0),removeEventListener("pagehide",p))}function v(n){if(n.source!==t||n.origin!==r.origin||!n.data||typeof n.data!="object"||!("channel"in n.data)||!("nonce"in n.data)||n.data.channel!=="indiana-visual"||n.data.nonce!==r.nonce||r.expiresAt<=Date.now())return;let e=n.data;if(e.type==="connect"&&(a=!0,l("connected")),!!a){if(e.type==="disconnect"){p();return}if(e.type==="pick"&&(s=!0),e.type==="preview")try{let i=y(e.value);d?.revert(),d=w(i,{allowJs:c.allowJs===!0&&e.allowJs,nonce:c.nonce,onError:u=>l("error",{message:String(u)})}),l("previewed",{matches:i.domMutations.map(u=>({selector:u.selector,count:document.querySelectorAll(u.selector).length}))})}catch(i){l("error",{message:String(i)})}}}addEventListener("message",v),addEventListener("mousemove",h,!0),addEventListener("click",E,!0),addEventListener("pagehide",p);let x=setInterval(()=>{if(t.closed||r.expiresAt<=Date.now()){p();return}a||l("ready")},500);return l("ready"),p}export{L as startVisualEditorAgent,b as visualElementSelector};
|
package/dist/visual.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { J as JsonValue, R as Result } from './growth-rules-
|
|
1
|
+
import { J as JsonValue, R as Result } from './growth-rules-B4YYy64R.js';
|
|
2
|
+
import 'zod';
|
|
2
3
|
|
|
3
4
|
type VisualExperimentsOptions = {
|
|
4
5
|
environmentId: string;
|
|
5
|
-
|
|
6
|
+
/** Indiana API origin; defaults to https://api.tinker.cash. */
|
|
7
|
+
baseUrl?: string;
|
|
6
8
|
attributes?: Record<string, JsonValue>;
|
|
7
9
|
disableJsInjection?: boolean;
|
|
8
10
|
nonce?: string;
|
package/dist/visual.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as _,c as z}from"./chunk-
|
|
1
|
+
import{b as _,c as z}from"./chunk-BIFEEVQO.js";import{a as $,b as j,c as G,d as K,e as N,f as q,h as H}from"./chunk-4JBIKJMU.js";import"./chunk-S5TVMQRC.js";import"./chunk-OHDY27EI.js";import{f as F,i as L,k as p}from"./chunk-S2MSIA57.js";function ne(e){let E=G(e.baseUrl);if(!/^[0-9a-f-]{36}$/i.test(e.environmentId))throw new Error("Invalid App environment ID");let V=e.fetch??globalThis.fetch.bind(globalThis),b=`${E}/api/v1/visual-experiments/${e.environmentId}`,I=$(e.deviceIdCookie??"indiana_did"),w=j(),u=null,o=!1,k=!1,v="",T={...e.attributes??{}},S,m,y=0,s=new Map,J=new Map,R=new Set,h=[],x,C,d;function f(){clearTimeout(C),d?.remove(),d=void 0}function c(){clearTimeout(x),x=void 0;let t=h.splice(0,20);return t.length?V(`${b}/events`,{method:"POST",headers:{"Content-Type":"text/plain"},body:JSON.stringify({events:t}),credentials:"omit",keepalive:!0}).then(()=>{}).catch(i=>e.log?.("Visual exposure not sent",{error:i})):Promise.resolve()}function P(t,i){let l=p(t,i);R.has(l)||e.trackExposures===!1||u?.trackExposures===!1||o||(R.add(l),h.push({eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),deviceId:I,...w?{sessionId:w}:{},url:location.href,pageTitle:document.title.slice(0,512),experimentKey:t.key,variationKey:i.key}),h.length>=20?c():x??=setTimeout(()=>{c()},1e3))}function g(){if(!u||o)return;let t=new Set,i={onExperimentViewed:(n,a)=>{t.add(p(n,a))},url:location.href,attributes:{...H(I,location),...T},savedGroups:F(u.savedGroups),log:e.log},l=new Set;for(let n of u.experiments){let a=n;try{let r=L(a,i);if(J.set(n.changeId,r),!r.inExperiment)continue;l.add(n.changeId);let U=JSON.stringify([r.key,r.value]),A=s.get(n.changeId);if(A?.signature===U){A.applied()&&t.has(p(a,r))&&P(a,r);continue}s.get(n.changeId)?.revert(),s.delete(n.changeId);let D=z(r.value,{allowJs:e.disableJsInjection===!1,nonce:e.nonce,onApplied:()=>{t.has(p(a,r))&&P(a,r)},onError:Q=>e.log?.("Visual experiment stopped",{experiment:n.key,error:String(Q)})});s.set(n.changeId,{signature:U,revert:D.revert,applied:()=>D.applied})}catch(r){e.log?.("Skipping visual experiment",{experiment:n.key,error:String(r)})}}for(let[n,a]of s)l.has(n)||(a.revert(),s.delete(n));f()}async function O(){let t=++y,i=await V(b,{cache:"no-cache",credentials:"omit"});if(!i.ok)throw new Error(`Visual experiments unavailable (${i.status})`);let l=_(await i.json());if(l.environmentId.toLowerCase()!==e.environmentId.toLowerCase())throw new Error("Visual payload scope changed");!o&&t===y&&(u=l)}let B=()=>{v!==location.href&&(v=location.href,g())},M=()=>{c()};return{async start(){if(k||o)return;k=!0;let t=N(E,e.environmentId);if(t){q();let i=await import("./visual-editor-agent-WW65CMKW.js");o||(m=i.startVisualEditorAgent(t,{allowJs:e.disableJsInjection===!1,nonce:e.nonce}));return}e.antiFlicker&&(d=document.createElement("style"),e.nonce&&(d.nonce=e.nonce),d.textContent="body { visibility: hidden !important }",document.head.append(d),C=setTimeout(f,Math.min(3e3,Math.max(0,e.antiFlickerTimeout??1e3))));try{if(await O(),o)return;S=K(B),addEventListener("pagehide",M),v=location.href,g()}finally{f()}},async refresh(){o||m||(await O(),g())},setAttributes(t){T={...t},m||g()},flush:c,getResults(){return new Map(J)},get generation(){return u?.generation??null},destroy(){o=!0,y++,S?.(),m?.(),removeEventListener("pagehide",M),f();for(let t of s.values())t.revert();s.clear(),c()}}}export{ne as createVisualExperiments};
|
package/package.json
CHANGED
package/dist/chunk-3OSMEG44.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import{z as Q}from"zod";var st=Q.enum(["sandbox","live"]),we=Q.object({projectId:Q.string().min(1),environment:st}).strict();function X(e){let t=2166136261,n=e.length;for(let r=0;r<n;r++)t^=e.charCodeAt(r),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return t>>>0}function L(e,t,n){return n===2?X(X(e+t)+"")%1e4/1e4:null}function ve(e){return e<=0?[]:new Array(e).fill(1/e)}function H(e,t){return e>=t[0]&&e<t[1]}function Y(e,t){for(let[n,r]of t.entries())if(H(e,r))return n;return-1}function Z(e,t,n){t=t===void 0?1:t,t<0?t=0:t>1&&(t=1);let r=ve(e);n=n||r,n.length!==e&&(n=r);let o=n.reduce((u,l)=>l+u,0);(o<.99||o>1.01)&&(n=r);let s=0,i=t;return n.map(u=>{let l=s;return s+=u,[l,l+i*u]})}function ee(e,t,n){if(!t)return null;let r=t.split("?")[1];if(!r)return null;let s=r.replace(/#.*/,"").split("&").map(i=>i.split("=",2)).filter(([i])=>i===e).map(([,i])=>i===void 0?NaN:parseInt(i))[0];return s!==void 0&&s>=0&&s<n?s:null}function te(e){try{return e()}catch{return!1}}function _(e){return typeof e=="string"?e:JSON.stringify(e)}function w(e){typeof e=="number"&&(e=e+""),(!e||typeof e!="string")&&(e="0");let t=e.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return t.length===3&&t.push("~"),t.map(n=>n.match(/^[0-9]+$/)?n.padStart(5," "):n).join("-")}function Ae(e){try{let t=e.replace(/([^\\])\//g,"$1\\/");return new RegExp(t)}catch{return}}function ne(e,t){if(!t.length)return!1;let n=!1,r=!1;for(let o of t){let s=ct(e,o.type,o.pattern);if(o.include===!1){if(s)return!1}else n=!0,s&&(r=!0)}return r||!n}function at(e,t,n){try{let r=t.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return n&&(r="\\/?"+r.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+r+"$","i").test(e)}catch{return!1}}function ut(e,t){try{let n=new URL(t.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),r=[[e.host,n.host,!1],[e.pathname,n.pathname,!0]];return n.hash&&r.push([e.hash,n.hash,!1]),n.searchParams.forEach((o,s)=>{r.push([e.searchParams.get(s)||"",o,!1])}),!r.some(o=>!at(o[0],o[1],o[2]))}catch{return!1}}function ct(e,t,n){try{let r=new URL(e,"https://_");if(t==="regex"){let o=Ae(n);return o?o.test(r.href)||o.test(r.href.substring(r.origin.length)):!1}else if(t==="simple")return ut(r,n);return!1}catch{return!1}}function re(e){for(let n of["namespace","status","url","groups"])if(Object.hasOwn(e,n))throw new TypeError(`Retired experiment field: ${n}`);let t=e;if(t.hashVersion!==void 0&&t.hashVersion!==2)throw new TypeError("Only hash version 2 is supported");if(t.filters?.some(n=>n.hashVersion!==2))throw new TypeError("Only hash version 2 is supported")}function P(e){for(let t of Object.values(e)){if(Array.isArray(t))throw new TypeError("Saved groups require typed list or condition entries");if(t&&Object.hasOwn(t,"useEmptyListGroup"))throw new TypeError("Retired saved group field: useEmptyListGroup")}}function Ee(e){for(let t of["overrides","groups"])if(Object.hasOwn(e,t))throw new TypeError(`Retired evaluation context field: ${t}`);P(e.savedGroups??{})}var lt=e=>e/2**32|0,ft=e=>e>>>0;function Fe(e,t,n,r){let o=lt(n),s=ft(n);e.setUint32(t,r?s:o,r),e.setUint32(t+4,r?o:s,r)}function Oe(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}var oe=e=>e?`"${e}" `:"";function dt(e,t=""){if(typeof e!="number")throw new TypeError(oe(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(oe(t)+"expected integer >= 0, got "+e);return e}function K(e,t,n=""){if(Oe(e)&&(t===void 0||e.length===t))return e;t!==void 0&&dt(t,"length");let r=Oe(e),o=t!==void 0?` of length ${t}`:"",s=r?`length=${e.length}`:`type=${typeof e}`,i=oe(n)+"expected Uint8Array"+o+", got "+s;throw r?new RangeError(i):new TypeError(i)}var pt=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError((t==="object"?"":`"${t}" `)+"expected object, got type="+typeof e)},$e=(e,t)=>{pt(e,t);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,"__proto__"))throw new TypeError(`"${t}.__proto__" is not allowed`)};function ie(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function Ve(e,t){K(e,void 0,"output");let n=t.outputLen;if(!(e.length>=n))throw new RangeError('"output" expected length >= '+n)}function se(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function M(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function F(e,t){return e<<32-t|e>>>t}var ht=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",gt=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Re(e){if(K(e),ht)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=gt[e[n]];return t}function bt(e,t,n="opts"){return $e(e,"defaults"),t!==void 0&&$e(t,n),Object.assign(Object.create(null),e,t)}function Ce(e,t={}){if(typeof e!="function")throw new TypeError('"hashCons" expected function, got type='+typeof e);t=bt({},t,"info");let n=(o,s)=>e(s).update(o).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=o=>e(o),Object.assign(n,t),Object.freeze(n)}var Be=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function je(e,t,n){return e&t^~e&n}function Te(e,t,n){return e&t^e&n^t&n}var N=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,n,r,o){this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(t),this.view=M(this.buffer)}update(t){ie(this),K(t);let{view:n,buffer:r,blockLen:o}=this,s=t.length,i=!1;for(let u=0;u<s;){let l=Math.min(o-this.pos,s-u);if(l===o){let d=M(t);for(;o<=s-u;u+=o)this.process(d,u);i=!0;continue}r.set(u===0&&l===s?t:t.subarray(u,u+l),this.pos),this.pos+=l,u+=l,this.pos===o&&(this.process(n,0),this.pos=0,i=!0)}return this.length+=t.length,i&&this.roundClean(),this}digestInto(t){ie(this),Ve(t,this),this.finished=!0;let{buffer:n,view:r,blockLen:o,isLE:s}=this,{pos:i}=this;n[i++]=128,n.fill(0,i),this.padOffset>o-i&&(this.process(r,0),n.fill(0)),Fe(r,o-8,this.length*8,s),this.process(r,0),this.roundClean();let u=t===n?r:M(t),l=this.outputLen,d=l/4,p=this.get();if(l%4||d>p.length)throw new Error("invalid outputLen");for(let f=0;f<d;f++)u.setUint32(4*f,p[f],s)}digest(){let{buffer:t,outputLen:n}=this;this.digestInto(t);let r=t.slice(0,n);return this.destroy(),r}_cloneIntoMeta(t){let{buffer:n,length:r,finished:o,destroyed:s,pos:i}=this;return t.destroyed=s,t.finished=o,t.length=r,t.pos=i,i&&t.buffer.set(n),t}clone(){return this._cloneInto()}},De=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var mt=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),B=new Uint32Array(64),ae=class extends N{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(t,n){super(64,t,8,!1),this.A=n[0]|0,this.B=n[1]|0,this.C=n[2]|0,this.D=n[3]|0,this.E=n[4]|0,this.F=n[5]|0,this.G=n[6]|0,this.H=n[7]|0}get(){let{A:t,B:n,C:r,D:o,E:s,F:i,G:u,H:l}=this;return[t,n,r,o,s,i,u,l]}set(t,n,r,o,s,i,u,l){this.A=t|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=u|0,this.H=l|0}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,n){for(let f=0;f<16;f++,n+=4)B[f]=t.getUint32(n,!1);for(let f=16;f<64;f++){let m=B[f-15],k=B[f-2],A=F(m,7)^F(m,18)^m>>>3,E=F(k,17)^F(k,19)^k>>>10;B[f]=E+B[f-7]+A+B[f-16]|0}let{A:r,B:o,C:s,D:i,E:u,F:l,G:d,H:p}=this;for(let f=0;f<64;f++){let m=F(u,6)^F(u,11)^F(u,25),k=p+m+je(u,l,d)+mt[f]+B[f]|0,E=(F(r,2)^F(r,13)^F(r,22))+Te(r,o,s)|0;p=d,d=l,l=u,u=i+k|0,i=s,s=o,o=r,r=k+E|0}r=r+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,u=u+this.E|0,l=l+this.F|0,d=d+this.G|0,p=p+this.H|0,this.set(r,o,s,i,u,l,d,p)}roundClean(){se(B)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),se(this.buffer)}},ue=class extends ae{constructor(){super(32,De)}};var _e=Ce(()=>new ue,Be(1));var Ue=new Map,ce=32,Le=new WeakMap,He=new WeakMap;function xt(e){return Re(_e(new TextEncoder().encode(String(e))))}var q=e=>Array.isArray(e)?e.map(q):typeof e=="string"||typeof e=="number"?xt(e):null,z=e=>typeof e=="string"?e.toLowerCase():e;function Me(e){let t=Le.get(e);return t||(t=new Set(e),Le.set(e,t)),t}function yt(e){let t=He.get(e);return t||(t=new Set(e.map(z)),He.set(e,t)),t}function Ne(e){P(e);for(let t of Object.values(e)){let n=t?.type==="list"||t?.type==="hashed"?t.values:null;n&&n.length>=ce&&Me(n)}return e}function O(e,t,n,r){n=n||{},r||P(n),r=r||new Set;for(let[o,s]of Object.entries(t))switch(o){case"$or":if(!Ke(e,s,n,r))return!1;break;case"$nor":if(Ke(e,s,n,r))return!1;break;case"$and":if(!At(e,s,n,r))return!1;break;case"$not":if(O(e,s,n,r))return!1;break;case"$savedGroup":if(!kt(e,s,n,r))return!1;break;default:if(!I(s,ze(e,o),n,!1,r))return!1}return!0}function kt(e,t,n,r){if(!t||typeof t!="object"||Array.isArray(t))return!1;let{id:o,attributeKey:s}=t;if(typeof o!="string"||r.has(o)||s!==void 0&&typeof s!="string")return!1;let i=n[o];if(!i||Array.isArray(i)||typeof i!="object")return!1;let u=new Set(r).add(o);if(i.type==="list"||i.type==="hashed"){let l=s??i.attributeKey;if(typeof l!="string"||!Array.isArray(i.values))return!1;let d=ze(e,l);return U(i.type==="hashed"?q(d):d,i.values)}return i.type==="condition"?!i.condition||typeof i.condition!="object"?!1:O(e,i.condition,n,u):!1}function ze(e,t){let n=t.split("."),r=e;for(let o of n)if(r&&typeof r=="object"&&o in r)r=r[o];else return null;return r}function Ie(e,t=!1){let n=`${e}${t?"/i":""}`,r=Ue.get(n);return r||(r=new RegExp(e.replace(/([^\\])\//g,"$1\\/"),t?"i":void 0),Ue.set(n,r)),r}function I(e,t,n,r=!1,o=new Set){if(typeof e=="string")return r?String(t).toLowerCase()===e.toLowerCase():t+""===e;if(typeof e=="number")return t*1===e;if(typeof e=="boolean")return t!==null&&!!t===e;if(e===null)return t===null;if(Array.isArray(e)||!qe(e))return JSON.stringify(t)===JSON.stringify(e);let s=e;for(let i in s)if(!vt(i,t,s[i],n,o))return!1;return!0}function qe(e){let t=Object.keys(e);return t.length>0&&t.filter(n=>n[0]==="$").length===t.length}function St(e){if(e===null)return"null";if(Array.isArray(e))return"array";let t=typeof e;return["string","number","boolean","object","undefined"].includes(t)?t:"unknown"}function wt(e,t,n,r){if(!Array.isArray(e))return!1;let o=qe(t)?s=>I(t,s,n,!1,r):s=>O(s,t,n,r);for(let s=0;s<e.length;s++)if((e[s]??null)!==null&&o(e[s]))return!0;return!1}function U(e,t,n=!1){if(n){let o;if(t.length>=ce){let s=yt(t);o=i=>{let u=z(i);return!(typeof u=="number"&&Number.isNaN(u))&&s.has(u)}}else o=s=>t.some(i=>z(s)===z(i));return Array.isArray(e)?e.some(s=>o(s)):o(e)}let r=t.length>=ce?(o=>s=>o.has(s))(Me(t)):o=>t.includes(o);return Array.isArray(e)?e.some(o=>r(o)):r(e)}function Ge(e){return e===void 0?[]:e&&typeof e=="object"&&(e.type==="list"||e.type==="hashed")&&Array.isArray(e.values)?e.values:null}function Pe(e,t,n,r=!1,o=new Set){if(!Array.isArray(e))return!1;for(let s=0;s<t.length;s++){let i=!1;for(let u=0;u<e.length;u++)if(I(t[s],e[u],n,r,o)){i=!0;break}if(!i)return!1}return!0}function vt(e,t,n,r,o=new Set){let s=t,i=n;switch(e){case"$veq":return w(t)===w(n);case"$vne":return w(t)!==w(n);case"$vgt":return w(t)>w(n);case"$vgte":return w(t)>=w(n);case"$vlt":return w(t)<w(n);case"$vlte":return w(t)<=w(n);case"$eq":return t===n;case"$ne":return t!==n;case"$lt":return s<i;case"$lte":return s<=i;case"$gt":return s>i;case"$gte":return s>=i;case"$exists":return n?t!=null:t==null;case"$in":return Array.isArray(n)?U(t,n):!1;case"$ini":return Array.isArray(n)?U(t,n,!0):!1;case"$inGroup":{let u=r[n],l=Ge(u);return l===null?!1:U(u?.type==="hashed"?q(t):t,l)}case"$notInGroup":{let u=r[n],l=Ge(u);return l===null?!1:!U(u?.type==="hashed"?q(t):t,l)}case"$nin":return Array.isArray(n)?!U(t,n):!1;case"$nini":return Array.isArray(n)?!U(t,n,!0):!1;case"$not":return!I(n,t,r,!1,o);case"$size":return Array.isArray(t)?I(n,t.length,r,!1,o):!1;case"$elemMatch":return wt(t,n,r,o);case"$all":return Array.isArray(n)?Pe(t,n,r,!1,o):!1;case"$alli":return Array.isArray(n)?Pe(t,n,r,!0,o):!1;case"$regex":try{return Ie(n).test(t)}catch{return!1}case"$regexi":try{return Ie(n,!0).test(t)}catch{return!1}case"$type":return St(t)===n;default:return!1}}function Ke(e,t,n,r){if(!t.length)return!0;for(let o of t)if(O(e,o,n,r))return!0;return!1}function At(e,t,n,r){for(let o of t)if(!O(e,o,n,r))return!1;return!0}function le(e){return Ee(e),{context:e,stack:{evaluatedFeatures:new Set}}}function fe(e){return{...e.attributes,...e.attributeOverrides}}function R(e,t,n){let r=t||"id",o="",s=fe(e);return s[r]&&(o=s[r]),!o&&n&&(s[n]&&(o=s[n]),o&&(r=n)),{hashAttribute:r,hashValue:o}}function h(e,t,n){e.context.log?.(t,n)}function G(e,t){return t=t||0,`${e}__${t}`}function J(e,t){return`${e}||${t}`}function Et(e,t,n){let r=e.stickyBucketAssignmentDocs;if(!r)return{};let{hashAttribute:o,hashValue:s}=R(e,t),i=J(o,_(s)),{hashAttribute:u,hashValue:l}=R(e,n),d=l?J(u,_(l)):null,p={};return d&&r[d]&&Object.assign(p,r[d].assignments||{}),r[i]&&Object.assign(p,r[i].assignments||{}),p}function de({context:e,expKey:t,expBucketVersion:n,expHashAttribute:r,expFallbackAttribute:o,expMinBucketVersion:s,expMeta:i}){n=n||0,s=s||0,r=r||"id",i=i||[];let u=G(t,n),l=Et(e,r,o);if(s>0)for(let f=0;f<s;f++){let m=G(t,f);if(l[m]!==void 0)return{variation:-1,versionIsBlocked:!0}}let d=l[u];if(d===void 0)return{variation:-1};let p=i.findIndex(f=>f.key===d);return p<0?{variation:-1}:{variation:p}}function pe(e,t,n,r){let o=J(t,n),s=e.stickyBucketAssignmentDocs,i=s&&s[o]?s[o].assignments||{}:{},u={...i,...r},l=JSON.stringify(i)!==JSON.stringify(u);return{key:o,doc:{attributeName:t,attributeValue:n,assignments:u},changed:l}}function Ft(e){let t=new Set;return Object.values(e).forEach(n=>{if(n.rules)for(let r of n.rules)r.variations&&(t.add(r.hashAttribute||"id"),r.fallbackAttribute&&t.add(r.fallbackAttribute))}),Array.from(t)}function Ot(e,t=e.features||{}){let n={};return Ft(t).forEach(r=>{let{hashValue:o}=R(e,r);n[r]=_(o)}),n}function y(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function $t(e){return y({...e,parentConditions:e.parentConditions?.map(t=>y(t)),filters:e.filters?.map(t=>y(t)),meta:e.meta?.map(t=>y(t))})}function Je(e){return y({...e,parentConditions:e.parentConditions?.map(t=>y(t)),filters:e.filters?.map(t=>y(t)),meta:e.meta?.map(t=>y(t)),tracks:e.tracks?.map(t=>({experiment:$t(t.experiment),result:y(t.result)}))})}function We(e,t){let n=le(t),r=Ye(e,null,n);return t.onExperimentEval?.(e,r),r}function Qe(e,t){return ge(e,le(t))}function Vt(e){return e.forcedVariations||{}}function Xe(e,t,n){let{context:r}=e;if(r.trackedExperiments){let o=tt(t,n);if(r.trackedExperiments.has(o))return;r.trackedExperiments.add(o)}he(()=>r.onExperimentViewed?.(t,n))}function Rt(e,t,n){let{context:r}=e;if(r.trackedFeatureUsage){let o=JSON.stringify(n.value);if(r.trackedFeatureUsage[t]===o)return;r.trackedFeatureUsage[t]=o}he(()=>r.onFeatureUsage?.(t,n))}function he(e){try{let t=e();t&&typeof t.catch=="function"&&t.catch(()=>{})}catch{}}function ge(e,t){let{context:n}=t;if(t.stack.evaluatedFeatures.has(e))return h(t,`evalFeature: circular dependency detected: ${t.stack.id} -> ${e}`,{from:t.stack.id,to:e}),j(t,e,null,"cyclicPrerequisite");t.stack.evaluatedFeatures.add(e),t.stack.id=e;let r=n.features?.[e];for(let s of r?.rules??[])re(s);let o=n.forcedFeatureValues;if(o&&o.has(e))return h(t,"Global override",{id:e,value:o.get(e)}),j(t,e,o.get(e),"override");if(!r)return h(t,"Unknown feature",{id:e}),j(t,e,null,"unknownFeature");if(r.rules){let s=new Set(t.stack.evaluatedFeatures);e:for(let i of r.rules){if(i.parentConditions)for(let d of i.parentConditions){t.stack.evaluatedFeatures=new Set(s);let p=ge(d.id,t);if(p.source==="cyclicPrerequisite")return j(t,e,null,"cyclicPrerequisite");let f={value:p.value};if(!O(f,d.condition||{},n.savedGroups||{})){if(d.gate)return h(t,"Feature blocked by prerequisite",{id:e,rule:i}),j(t,e,null,"prerequisite");h(t,"Skip rule because prerequisite evaluation fails",{id:e,rule:i});continue e}}if(i.filters&&et(i.filters,t)){h(t,"Skip rule because of filters",{id:e,rule:i});continue}if("force"in i){if(i.condition&&!Ze(i.condition,t)){h(t,"Skip rule because of condition ff",{id:e,rule:i});continue}if(!Ct(t,i.seed||e,i.hashAttribute,n.saveStickyBucketAssignmentDoc&&!i.disableStickyBucketing?i.fallbackAttribute:void 0,i.range,i.coverage,i.hashVersion)){h(t,"Skip rule because user not included in rollout",{id:e,rule:i});continue}return h(t,"Force value from rule",{id:e,rule:i}),i.tracks&&i.tracks.forEach(d=>{Xe(t,d.experiment,d.result)}),j(t,e,i.force,"force",i.id)}if(!i.variations){h(t,"Skip invalid rule",{id:e,rule:i});continue}let u={variations:i.variations,key:i.key||e};"coverage"in i&&(u.coverage=i.coverage),i.weights&&(u.weights=i.weights),i.hashAttribute&&(u.hashAttribute=i.hashAttribute),i.fallbackAttribute&&(u.fallbackAttribute=i.fallbackAttribute),i.disableStickyBucketing&&(u.disableStickyBucketing=i.disableStickyBucketing),i.bucketVersion!==void 0&&(u.bucketVersion=i.bucketVersion),i.minBucketVersion!==void 0&&(u.minBucketVersion=i.minBucketVersion),i.meta&&(u.meta=i.meta),i.ranges&&(u.ranges=i.ranges),i.name&&(u.name=i.name),i.phase&&(u.phase=i.phase),i.seed&&(u.seed=i.seed),i.hashVersion&&(u.hashVersion=i.hashVersion),i.filters&&(u.filters=i.filters),i.condition&&(u.condition=i.condition);let l=Ye(u,e,t);if(n.onExperimentEval?.(u,l),l.inExperiment&&!l.passthrough)return j(t,e,l.value,"experiment",i.id,u,l)}}return h(t,"Use default value",{id:e,value:r.defaultValue}),j(t,e,r.defaultValue===void 0?null:r.defaultValue,"defaultValue")}function Ye(e,t,n){let{context:r}=n;re(e);let o=e.key,s=e.variations.length;if(s<2)return h(n,"Invalid experiment",{id:o}),x(n,e,-1,!1,t);if(r.enabled===!1)return h(n,"Context disabled",{id:o}),x(n,e,-1,!1,t);if(e.urlPatterns&&!ne(r.url||"",e.urlPatterns))return h(n,"Skip because of url targeting",{id:o}),x(n,e,-1,!1,t);let i=ee(o,r.url||"",s);if(i!==null)return h(n,"Force via querystring",{id:o,variation:i}),x(n,e,i,!1,t);let l=Vt(r)[o];if(l!==void 0)return h(n,"Force via dev tools",{id:o,variation:l}),x(n,e,l,!1,t);if(e.active===!1)return h(n,"Skip because inactive",{id:o}),x(n,e,-1,!1,t);let{hashAttribute:d,hashValue:p}=R(r,e.hashAttribute,r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0);if(!p)return h(n,"Skip because missing hashAttribute",{id:o}),x(n,e,-1,!1,t);let f=-1,m=!1,k=!1;if(r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing){let{variation:S,versionIsBlocked:$}=de(y({context:r,expKey:e.key,expBucketVersion:e.bucketVersion,expHashAttribute:e.hashAttribute,expFallbackAttribute:e.fallbackAttribute,expMinBucketVersion:e.minBucketVersion,expMeta:e.meta}));m=S>=0,f=S,k=!!$}if(!m){if(e.filters&&et(e.filters,n))return h(n,"Skip because of filters",{id:o}),x(n,e,-1,!1,t);if(e.include&&!te(e.include))return h(n,"Skip because of include function",{id:o}),x(n,e,-1,!1,t);if(e.condition&&!Ze(e.condition,n))return h(n,"Skip because of condition exp",{id:o}),x(n,e,-1,!1,t);if(e.parentConditions){let S=new Set(n.stack.evaluatedFeatures);for(let $ of e.parentConditions){n.stack.evaluatedFeatures=new Set(S);let V=ge($.id,n);if(V.source==="cyclicPrerequisite")return x(n,e,-1,!1,t);let D={value:V.value};if(!O(D,$.condition||{},r.savedGroups||{}))return h(n,"Skip because prerequisite evaluation fails",{id:o}),x(n,e,-1,!1,t)}}}let A=L(e.seed||o,p,e.hashVersion??2);if(A===null)return h(n,"Skip because of invalid hash version",{id:o}),x(n,e,-1,!1,t);if(!m){let S=e.ranges||Z(s,e.coverage===void 0?1:e.coverage,e.weights);f=Y(A,S)}if(k)return h(n,"Skip because sticky bucket version is blocked",{id:o}),x(n,e,-1,!1,t,void 0,!0);if(f<0)return h(n,"Skip because of coverage",{id:o}),x(n,e,-1,!1,t);if("force"in e)return h(n,"Force variation",{id:o,variation:e.force}),x(n,e,e.force===void 0?-1:e.force,!1,t);if(r.qaMode)return h(n,"Skip because QA mode",{id:o}),x(n,e,-1,!1,t);let E=x(n,e,f,!0,t,A,m);if(r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing){let{changed:S,key:$,doc:V}=pe(r,d,_(p),{[G(e.key,e.bucketVersion)]:E.key});if(S){r.stickyBucketAssignmentDocs=r.stickyBucketAssignmentDocs||{},r.stickyBucketAssignmentDocs[$]=V;let D=r.saveStickyBucketAssignmentDoc;he(()=>D(V))}}return Xe(n,e,E),h(n,"In experiment",{id:o,variation:E.variationId}),E}function j(e,t,n,r,o,s,i){let u={value:n,on:!!n,off:!n,source:r,ruleId:o||""};return s&&(u.experiment=s),i&&(u.experimentResult=i),r!=="override"&&Rt(e,t,u),u}function Ze(e,t){return O(fe(t.context),e,t.context.savedGroups||{})}function et(e,t){return e.some(n=>{let{hashValue:r}=R(t.context,n.attribute);if(!r)return!0;let o=L(n.seed,r,n.hashVersion||2);return o===null?!0:!n.ranges.some(s=>H(o,s))})}function Ct(e,t,n,r,o,s,i){if(!o&&s===void 0)return!0;if(!o&&s===0)return!1;let{hashValue:u}=R(e.context,n,r);if(!u)return!1;let l=L(t,u,i??2);return l===null?!1:o?H(l,o):s!==void 0?l<=s:!0}function x(e,t,n,r,o,s,i){let u=!0;(n<0||n>=t.variations.length)&&(n=0,u=!1);let{hashAttribute:l,hashValue:d}=R(e.context,t.hashAttribute,e.context.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing?t.fallbackAttribute:void 0),p=t.meta?.[n]??{},f=t.variations[0];for(let[k,A]of t.variations.entries())if(k===n){f=A;break}let m={key:p.key||""+n,featureId:o,inExperiment:u,hashUsed:r,variationId:n,value:f,hashAttribute:l,hashValue:d,stickyBucketUsed:!!i};return p.name&&(m.name=p.name),s!==void 0&&(m.bucket=s),p.passthrough&&(m.passthrough=p.passthrough),m}function tt(e,t){return t.hashAttribute+t.hashValue+e.key+t.variationId}/*!
|
|
2
|
-
Copyright (c) 2025 GrowthBook, Inc.
|
|
3
|
-
|
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
5
|
-
furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all
|
|
8
|
-
copies or substantial portions of the Software.
|
|
9
|
-
|
|
10
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
11
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
12
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
13
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
14
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
15
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
16
|
-
SOFTWARE.
|
|
17
|
-
*/import{z as a}from"zod";var v=a.json().superRefine((e,t)=>{let n=0;function r(o,s){if(++n>1e4||s>20){t.addIssue({code:"custom",message:"JSON exceeds its depth or node budget"});return}if(typeof o=="string"&&(o.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(o))&&t.addIssue({code:"custom",message:"JSON text must contain valid Unicode without NUL"}),Array.isArray(o))o.forEach(i=>r(i,s+1));else if(o&&typeof o=="object")for(let[i,u]of Object.entries(o))(i.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(i)||["__proto__","prototype","constructor"].includes(i))&&t.addIssue({code:"custom",message:"Reserved JSON property"}),r(u,s+1)}r(e,0),new TextEncoder().encode(JSON.stringify(e)).byteLength>65536&&t.addIssue({code:"custom",message:"JSON exceeds 64 KiB"})}),me=a.record(a.string().min(1).max(128),v).superRefine((e,t)=>{(!v.safeParse(e).success||Object.keys(e).length>128||new TextEncoder().encode(JSON.stringify(e)).byteLength>65536||["__proto__","constructor","prototype"].some(n=>Object.hasOwn(e,n)))&&t.addIssue({code:"custom",message:"Attribute document exceeds its budget or uses a reserved key"})}),Bt=new Set(["$in","$ini","$inGroup","$nin","$nini","$notInGroup","$gt","$gte","$lt","$lte","$regex","$regexi","$ne","$eq","$size","$elemMatch","$all","$alli","$not","$type","$exists","$vgt","$vgte","$vlt","$vlte","$vne","$veq","$and","$or","$nor","$savedGroup"]),T=me.superRefine((e,t)=>{function n(r){if(Array.isArray(r))r.forEach(n);else if(r&&typeof r=="object")for(let[o,s]of Object.entries(r)){if(o==="$savedGroup"&&!a.strictObject({id:a.uuid(),attributeKey:a.string().min(1).max(128).optional()}).safeParse(s).success&&t.addIssue({code:"custom",message:"Saved groups use v2 object references"}),!o.startsWith("$")&&o.split(".").some(i=>["__proto__","prototype","constructor"].includes(i))&&t.addIssue({code:"custom",message:"Reserved attribute path"}),o.startsWith("$")&&!Bt.has(o)&&t.addIssue({code:"custom",message:`Unknown GrowthBook operator: ${o}`}),["$regex","$regexi"].includes(o)&&typeof s=="string"){(/\(\?[<!=]|\\[0-9]|\\k</.test(s)||[...s.matchAll(/\{(\d+)(?:,(\d*))?\}/g)].some(i=>Number(i[1])>255||Number(i[2]||0)>255)||o==="$regexi"&&/[^\x00-\x7f]/.test(s.replace(/\\u([0-9a-f]{4})/gi,(i,u)=>String.fromCharCode(Number.parseInt(u,16)))))&&t.addIssue({code:"custom",message:"Regex is outside the shared TS/SQL subset"});try{new RegExp(s)}catch{t.addIssue({code:"custom",message:"Invalid regular expression"})}}n(s)}}typeof e.source=="string"&&["all","any","group","parameter","answer","attribute","result"].includes(e.source)&&("operator"in e||"predicates"in e||"groupId"in e)&&t.addIssue({code:"custom",message:"Obsolete condition protocol"}),n(e)}),jt=a.discriminatedUnion("type",[a.strictObject({type:a.literal("condition"),condition:T}),a.strictObject({type:a.literal("list"),attributeKey:a.string().min(1).max(128),values:a.array(a.union([a.string(),a.number().finite()])).max(1e5)})]).refine(e=>e.type!=="list"||new TextEncoder().encode(JSON.stringify(e.values)).byteLength<=1048576,"Saved group list exceeds 1 MiB");function Tt(e){let t=new Set;function n(r){if(Array.isArray(r))r.forEach(n);else if(r&&typeof r=="object")for(let[o,s]of Object.entries(r))o==="$savedGroup"&&s&&typeof s=="object"&&!Array.isArray(s)&&typeof s.id=="string"?t.add(s.id):["$inGroup","$notInGroup"].includes(o)&&typeof s=="string"?t.add(s):["$eq","$ne","$in","$nin","$ini","$nini"].includes(o)||n(s)}return n(e),[...t]}var Dt=a.record(a.uuid(),jt).superRefine((e,t)=>{let n=new Set,r=new Set;function o(s){if(n.has(s)){t.addIssue({code:"custom",message:"Cyclic saved group dependency"});return}if(r.has(s))return;let i=e[s];if(!i){t.addIssue({code:"custom",message:"Missing saved group dependency"});return}n.add(s),i.type==="condition"&&Tt(i.condition).forEach(o),n.delete(s),r.add(s)}Object.keys(e).forEach(o)}),xe=a.tuple([a.number().min(0).max(1),a.number().min(0).max(1)]).refine(([e,t])=>e<=t),nt=a.strictObject({attribute:a.string().optional(),seed:a.string().min(1),hashVersion:a.literal(2),ranges:a.array(xe).min(1).max(100)}),_t=a.strictObject({id:a.string().min(1).max(128),condition:T,gate:a.boolean().optional()}),be={id:a.string().max(128).optional(),condition:T.optional(),parentConditions:a.array(_t).max(50).optional(),filters:a.array(nt).max(20).optional()},Ut=a.union([a.strictObject({...be}),a.strictObject({...be,force:v,coverage:a.number().min(0).max(1).optional(),range:xe.optional(),seed:a.string().min(1).optional(),hashAttribute:a.string().optional(),hashVersion:a.literal(2).optional()}),a.strictObject({...be,type:a.literal("experiment-ref"),experimentId:a.uuid(),values:a.record(a.string().min(1),v),meta:a.record(a.string().min(1),a.strictObject({passthrough:a.boolean()})).optional()})]),Lt=a.strictObject({defaultValue:v,rules:a.array(Ut).max(100)}),Nn=a.record(a.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),Lt).superRefine((e,t)=>{Object.keys(e).length>100&&t.addIssue({code:"custom",message:"Too many Features"});let n=new Set,r=new Set;function o(s){if(n.has(s)){t.addIssue({code:"custom",message:`Cyclic Feature dependency: ${s}`});return}if(r.has(s))return;let i=e[s];if(!i){t.addIssue({code:"custom",message:`Unknown prerequisite Feature: ${s}`});return}n.add(s);for(let u of i.rules)for(let l of u.parentConditions??[])o(l.id);n.delete(s),r.add(s)}Object.keys(e).forEach(o)}),Ht=a.strictObject({name:a.string().max(80),reason:a.string().max(500),dateStarted:a.iso.datetime({offset:!0}),dateEnded:a.iso.datetime({offset:!0}).nullable(),coverage:a.number().min(0).max(1),variationWeights:a.array(a.number().min(0).max(1)).min(2).max(20).refine(e=>Math.abs(e.reduce((t,n)=>t+n,0)-1)<=.01),condition:T,savedGroups:a.array(a.strictObject({match:a.enum(["any","all","none"]),ids:a.array(a.uuid()).min(1)})).max(50),namespace:a.strictObject({id:a.uuid(),ranges:a.array(xe).min(1)}).nullable(),seed:a.string().min(1).max(128)}),It=a.strictObject({key:a.string().min(1).max(128),name:a.string().min(1).max(80),hypothesis:a.string().max(2e3),status:a.enum(["draft","running","stopped"]),hashAttribute:a.string().min(1).max(128),fallbackAttribute:a.string().max(128).nullable(),hashVersion:a.literal(2),disableStickyBucketing:a.boolean(),bucketVersion:a.number().int().min(0).max(1e3),minBucketVersion:a.number().int().min(0).max(1e3),variations:a.array(a.strictObject({id:a.string().min(1),key:a.string().min(1),name:a.string().max(80),description:a.string().max(500)})).min(2).max(20),phases:a.array(Ht).min(1).max(100),releasedVariationId:a.string().nullable(),excludeFromPayload:a.boolean(),statusSchedule:a.strictObject({startAt:a.iso.datetime({offset:!0}).nullable(),stopAt:a.iso.datetime({offset:!0}).nullable(),stopAfter:a.strictObject({value:a.number().int().positive().max(36500),unit:a.enum(["hours","days"])}).nullable().optional()}).nullable()}).superRefine((e,t)=>{(e.minBucketVersion>e.bucketVersion||e.statusSchedule?.stopAt&&e.statusSchedule?.stopAfter||e.phases.some((n,r)=>{if(r===0)return!1;let o=e.phases[r-1];return!o?.dateEnded||Date.parse(n.dateStarted)<Date.parse(o.dateStarted)||Date.parse(o.dateEnded)>Date.parse(n.dateStarted)})||new Set(e.variations.map(n=>n.key)).size!==e.variations.length||new Set(e.variations.map(n=>n.id)).size!==e.variations.length||e.releasedVariationId!==null&&!e.variations.some(n=>n.id===e.releasedVariationId)||e.statusSchedule?.startAt&&e.statusSchedule?.stopAt&&Date.parse(e.statusSchedule.startAt)>=Date.parse(e.statusSchedule.stopAt)||e.phases.some(n=>n.dateEnded&&Date.parse(n.dateStarted)>=Date.parse(n.dateEnded)||n.namespace?.ranges.some(([r,o],s,i)=>r>=o||i.some(([u,l],d)=>d!==s&&r<l&&u<o)))||e.phases.some(n=>n.variationWeights.length!==e.variations.length))&&t.addIssue({code:"custom",message:"Invalid experiment versions, variation keys or weights"})});function zn(e,t,n=Date.now()){return Object.fromEntries(Object.entries(e).map(([r,o])=>[r,{defaultValue:o.defaultValue,rules:o.rules.flatMap(s=>{if(!("experimentId"in s))return[Je({...s,hashVersion:2})];let i=t[s.experimentId];if(!i)throw new Error(`Missing experiment: ${s.experimentId}`);let u=i.phases.at(-1);if(!u)throw new Error("Experiment requires an active phase");let l=i.statusSchedule?.startAt?Date.parse(i.statusSchedule.startAt):null,d=rt(i),p=i.status!=="stopped"&&(i.status==="running"||l!==null&&n>=l)&&(l===null||n>=l)&&(d===null||n<d),{type:f,experimentId:m,values:k,meta:A,...E}=s,S=y({...E,parentConditions:E.parentConditions?.map(b=>y(b)),filters:E.filters?.map(b=>y(b))});if(i.variations.some(b=>!Object.hasOwn(k,b.key))||Object.keys(k).length!==i.variations.length||Object.keys(A??{}).some(b=>!i.variations.some(C=>C.key===b)))throw new Error("Every variation needs a Feature value");let $=b=>{let C=k[b];if(C===void 0)throw new Error("Every variation needs a Feature value");return C},V={$and:[u.condition,...S.condition?[S.condition]:[],...u.savedGroups.map(b=>{let C=b.ids.map(it=>({$savedGroup:{id:it}}));return b.match==="all"?{$and:C}:b.match==="none"?{$nor:C}:{$or:C}})]},D=i.variations.find(b=>b.id===i.releasedVariationId);return D&&!i.excludeFromPayload?A?.[D.key]?.passthrough?[{...S,condition:V}]:[{...S,condition:V,force:$(D.key)}]:[{...S,condition:V,key:i.key,variations:i.variations.map(b=>$(b.key)),meta:i.variations.map(b=>({key:b.key,name:b.name,...y(A?.[b.key]??{})})),weights:u.variationWeights,coverage:p?u.coverage:0,seed:u.seed,hashVersion:2,hashAttribute:i.hashAttribute,...i.fallbackAttribute===null?{}:{fallbackAttribute:i.fallbackAttribute},disableStickyBucketing:!p||i.disableStickyBucketing,bucketVersion:i.bucketVersion,minBucketVersion:i.minBucketVersion,filters:[...S.filters??[],...(i.filters??[]).map(b=>y(b))]}]})}]))}function rt(e){if(e.statusSchedule?.stopAt)return Date.parse(e.statusSchedule.stopAt);let t=e.statusSchedule?.stopAfter;if(!t||e.status==="draft"&&!e.statusSchedule?.startAt)return null;let n=e.statusSchedule?.startAt??e.phases.at(-1)?.dateStarted;if(!n)throw new Error("Experiment requires an active phase");return Date.parse(n)+t.value*(t.unit==="days"?864e5:36e5)}function qn(e,t=Date.now()){let n=Object.values(e).filter(r=>r.status!=="stopped"&&!(r.releasedVariationId&&!r.excludeFromPayload)).flatMap(r=>[r.statusSchedule?.startAt?Date.parse(r.statusSchedule.startAt):null,rt(r)]).filter(r=>r!==null&&r>t);return n.length?new Date(Math.min(...n)).toISOString():null}var Gt=It.safeExtend({filters:a.array(nt).optional()}),Pt=a.strictObject({experiments:a.record(a.uuid(),Gt),savedGroups:Dt}),Kt=a.strictObject({attributeName:a.string(),attributeValue:a.string(),assignments:a.record(a.string(),a.string())}),Jn=a.strictObject({snapshot:Pt,attributes:me,results:me,stickyBucketAssignmentDocs:a.record(a.string(),Kt)}),Wn=a.strictObject({variantKey:a.string().nullable(),bucketVersion:a.number().int().min(0),source:a.enum(["unknownFeature","defaultValue","force","override","experiment","prerequisite","cyclicPrerequisite"]),bucket:a.number().min(0).max(1).optional(),stickyBucketUsed:a.boolean().optional(),hashUsed:a.boolean().optional()});import{z as c}from"zod";var ye=c.tuple([c.number().min(0).max(1),c.number().min(0).max(1)]).refine(([e,t])=>e<=t),Mt=c.strictObject({attribute:c.string().optional(),seed:c.string(),hashVersion:c.literal(2),ranges:c.array(ye).max(100)}),Nt=c.strictObject({id:c.string().min(1).max(255),condition:T,gate:c.boolean().optional()}),zt=c.strictObject({key:c.string().optional(),name:c.string().optional(),passthrough:c.boolean().optional()}),ot={condition:T.optional(),parentConditions:c.array(Nt).max(100).optional(),weights:c.array(c.number().min(0).max(1)).max(20).optional(),coverage:c.number().min(0).max(1).optional(),hashAttribute:c.string().optional(),fallbackAttribute:c.string().optional(),hashVersion:c.literal(2).optional(),disableStickyBucketing:c.boolean().optional(),bucketVersion:c.number().int().nonnegative().optional(),minBucketVersion:c.number().int().nonnegative().optional(),filters:c.array(Mt).max(100).optional(),ranges:c.array(ye).max(20).optional(),meta:c.array(zt).max(20).optional(),seed:c.string().optional(),name:c.string().optional(),phase:c.string().optional()},W=c.strictObject({...ot,key:c.string().min(1).max(255),variations:c.tuple([v,v]).rest(v).refine(e=>e.length<=20),urlPatterns:c.array(c.strictObject({include:c.boolean(),type:c.enum(["regex","simple"]),pattern:c.string()})).max(100).optional(),force:c.number().int().nonnegative().optional(),active:c.boolean().optional(),persistQueryString:c.boolean().optional()}),qt=c.strictObject({value:v,variationId:c.number().int(),key:c.string(),name:c.string().optional(),bucket:c.number().optional(),passthrough:c.boolean().optional(),inExperiment:c.boolean(),hashUsed:c.boolean().optional(),hashAttribute:c.string(),hashValue:c.string(),featureId:c.string().nullable(),stickyBucketUsed:c.boolean().optional()}),Jt=c.strictObject({...ot,id:c.string().max(255).optional(),force:v.optional(),variations:c.array(v).min(2).max(20).optional(),key:c.string().optional(),range:ye.optional(),tracks:c.array(c.strictObject({experiment:W,result:qt})).max(100).optional()}),Wt=c.strictObject({defaultValue:v.optional(),rules:c.array(Jt).max(500).optional()}),ke=c.record(c.string(),c.union([c.strictObject({type:c.literal("hashed"),attributeKey:c.string(),values:c.array(c.string().regex(/^[a-f0-9]{64}$/))}),c.strictObject({type:c.literal("list"),attributeKey:c.string(),values:c.array(c.union([c.string(),c.number()]))}),c.strictObject({type:c.literal("condition"),condition:T})])),er=c.strictObject({scope:we,generation:c.string().regex(/^[a-f0-9]{64}$/),evaluatedAt:c.iso.datetime({offset:!0}),expiresAt:c.iso.datetime({offset:!0}).nullable(),features:c.record(c.string(),Wt),savedGroups:ke,experiments:c.record(c.uuid(),W)});import{z as g}from"zod";var Qt=g.strictObject({selector:g.string().min(1).max(2048),action:g.enum(["set","append","remove"]),attribute:g.string().min(1).max(128).refine(e=>["html","class","style","position","href","src","alt","title","id","role","hidden"].includes(e)||/^(aria|data)-[a-z0-9_-]+$/.test(e)),value:g.string().max(5e4).optional(),parentSelector:g.string().max(2048).optional(),insertBeforeSelector:g.string().max(2048).optional()}),Xt=g.strictObject({variation:g.string().min(1).max(128),description:g.string().max(2e3).default(""),css:g.string().max(1e5).default(""),js:g.string().max(1e5).default(""),domMutations:g.array(Qt).max(200).default([])}),Se=Xt.omit({variation:!0,description:!0}),Yt=W.omit({variations:!0,active:!0}).extend({changeId:g.string().regex(/^[a-f0-9]{64}$/),variations:g.tuple([Se,Se]).rest(Se).refine(e=>e.length<=20)}),or=g.strictObject({environmentId:g.uuid(),trackExposures:g.boolean(),generation:g.string().regex(/^[a-f0-9]{64}$/),experiments:g.array(Yt).max(100),savedGroups:ke}),ir="__indiana_visual_editor",sr=g.object({selector:g.string().max(2048),tag:g.string().max(64),text:g.string().max(1e3),href:g.string().max(2048),src:g.string().max(2048),matches:g.number().int().nonnegative()});export{st as a,we as b,ee as c,_ as d,ne as e,Ne as f,O as g,Ot as h,We as i,Qe as j,tt as k,v as l,me as m,T as n,jt as o,Tt as p,Dt as q,Ut as r,Lt as s,Nn as t,Ht as u,It as v,zn as w,rt as x,qn as y,Gt as z,Pt as A,Kt as B,Jn as C,Wn as D,W as E,qt as F,Jt as G,Wt as H,ke as I,er as J,Qt as K,Xt as L,Se as M,Yt as N,or as O,ir as P,sr as Q};
|
package/dist/chunk-GA6X57BO.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as c,b as x}from"./chunk-YNUVRZRQ.js";import{Bi as A,Bk as U,Mk as T,Sk as L,Te as k,ei as _,hi as q}from"./chunk-GTBD4BJ4.js";import{J as N,f as P,g as D,i as V,j as R,m as b}from"./chunk-3OSMEG44.js";function j(a){let e=null,u=null,l=0,r=0,s=new Set,n=null,i=null,y=new Set,v=()=>{for(let t of y)try{t()}catch{}},o={attributes:b.parse(a.attributes??{}),onFeatureUsage:a.onFeatureUsage?(t,f)=>{!s.has(t)&&(!e||!("analyticsConfig"in e)||e.analyticsConfig.featureUsageEnabled)&&a.onFeatureUsage(t,structuredClone(f))}:void 0,onExperimentViewed:a.onExperimentViewed?(t,f)=>(!e||!("analyticsConfig"in e)||e.analyticsConfig.experimentViewsEnabled)&&a.onExperimentViewed(structuredClone(t),structuredClone(f)):void 0,stickyBucketAssignmentDocs:structuredClone(a.stickyBucketAssignmentDocs),saveStickyBucketAssignmentDoc:a.saveStickyBucketAssignmentDoc?t=>a.saveStickyBucketAssignmentDoc(structuredClone(t)):void 0,trackedFeatureUsage:{},trackedExperiments:new Set},w=()=>({value:null,source:"unknownFeature",on:!1,off:!0,ruleId:""});function d(t,f=new Set){return s.has(t)?!n||!n.features[t]||["unknownFeature","cyclicPrerequisite"].includes(n.features[t].source):f.has(t)?!1:(f.add(t),(e?.features[t]?.rules??[]).some(p=>[...p.parentConditions??[],...(p.tracks??[]).flatMap(h=>h.experiment.parentConditions??[])].some(h=>d(h.id,f))))}let m=t=>{if(!e)throw new Error("Initialize the Feature client before evaluation");if(e.expiresAt&&Date.parse(e.expiresAt)<=Date.now())throw new Error("Feature configuration expired; refresh before evaluation");return n?.expiresAt&&Date.parse(n.expiresAt)<=Date.now()&&(n=null,o.features=e.features),s.has(t)?!n||n.expiresAt&&Date.parse(n.expiresAt)<=Date.now()?w():structuredClone(n.features[t]??w()):d(t)?w():structuredClone(R(t,o))};async function g(){if(!e||!s.size)return;if(!a.evaluateRemote)throw new Error("Remote Feature evaluation requires a server loader");let t=r;if(i?.revision===t)return i.loading;let f=l,p=e,h=[...s],I=(async()=>{let E=q.parse(await a.evaluateRemote({attributes:structuredClone(o.attributes),features:h}));if(!(f!==l||t!==r||p!==e)){if(E.generation!==p.generation)throw new Error("Feature configuration changed; refresh before evaluation");if(h.some(S=>!Object.hasOwn(E.features,S))||Object.keys(E.features).some(S=>!s.has(S)))throw new Error("Invalid remote Feature results");n=structuredClone(E),o.features={...p.features,...Object.fromEntries(Object.entries(n.features).map(([S,B])=>[S,{defaultValue:B.value}]))},v()}})();i={revision:t,loading:I};try{await I}finally{i?.loading===I&&(i=null)}}function C(){g().catch(t=>{try{a.onError?.(t)}catch{}})}async function F(){if(u)return u;let t=l,f=(async()=>{let p=await a.load(),h="remoteFeatures"in p?_.parse(p):null,I=h??N.parse(p);if(I.scope.projectId!==a.scope.projectId||I.scope.environment!==a.scope.environment)throw new Error("Feature payload scope changed");if(t!==l)throw new Error("Feature client was reset");let E=new Set(h?.remoteFeatures??[]);if([...E].some(S=>Object.hasOwn(I.features,S)))throw new Error("Remote Feature definitions must not be delivered locally");return e&&"analyticsConfig"in e&&"analyticsConfig"in I&&!e.analyticsConfig.experimentViewsEnabled&&h?.analyticsConfig.experimentViewsEnabled&&o.trackedExperiments?.clear(),e=structuredClone(I),s=E,n=null,i=null,r++,o.features=e.features,o.savedGroups=P(e.savedGroups),o.trackedFeatureUsage={},v(),C(),structuredClone(e)})();u=f;try{return await f}finally{u===f&&(u=null)}}return{init:F,refresh:F,refreshRemote:g,get generation(){return e?.generation??null},get expiresAt(){return e?.expiresAt??null},subscribe(t){return y.add(t),()=>{y.delete(t)}},setAttributes(t){o.attributes=b.parse(t),r++,n=null,i=null,o.features=e?.features??{},o.trackedFeatureUsage={},v(),C()},evalFeature:m,isOn(t){return m(t).on},isOff(t){return m(t).off},getFeatureValue(t,f){let p=m(t).value;return structuredClone(p===null?f:p)},reset(){l++,r++,u=null,i=null,e=null,n=null,s.clear(),o.features={},o.savedGroups={},o.stickyBucketAssignmentDocs={},o.attributes={},o.trackedFeatureUsage={},o.trackedExperiments?.clear(),v()}}}async function M(a,e){if(!/^gg_ct_[A-Za-z0-9_-]{43}$/.test(e.customerToken))throw new c("INVALID_TOKEN","A verified Customer credential is required");let u=x(a);u.identify(e.customerToken);let l=A.resolvePaywall.request.parse({selector:{type:"paywall",paywallId:e.paywallId},commerce:e.commerce,locale:e.locale,...e.requirement?{requirement:e.requirement}:{}}),r=null,s=null,n=null,i=null,y=null;async function v(){let d=A.resolvePaywall,m=d.response.parse(await u.request(d.path,d.request.parse({...l,selector:r?{type:"version",versionId:r.id}:l.selector})));if(m.paywall.paywallId!==e.paywallId)throw new c("INVALID_RESPONSE","The requested Paywall changed");if(r&&(m.paywall.id!==r.id||m.paywall.paywallId!==r.paywallId||m.paywall.offering.id!==r.offering.id))throw new c("INVALID_RESPONSE","The pinned Paywall or Offering Version changed");return r=m.paywall,structuredClone(r)}async function o(d){if(!s)throw new c("INVALID_REQUEST","A quoted purchase is required");let m=d==="read"?A.readSubscriptionOperation:A.attach,g=m.response.parse(await u.request(m.path,m.request.parse({operationId:s.operationId,...d==="read"?{}:{intent:d}})));if(g.operation.operationId!==s.operationId||g.operation.currency!==l.commerce.currency)throw new c("INVALID_RESPONSE","The purchase operation changed");return n?.status==="complete"&&g.operation.status!=="complete"||n&&n.status!=="pending"&&g.operation.status==="pending"||(n=g.operation),structuredClone(n)}let w={get view(){return r?structuredClone(r):null},get quote(){return s?structuredClone(s):null},get operation(){return n?structuredClone(n):null},get webViewUrl(){return u.webViewUrl()},refresh:v,async preview(d){if(!r)throw new c("INVALID_REQUEST","Load the Paywall first");let m=r.document.buttons[d.actionId];if(m?.type!=="checkout")throw new c("INVALID_REQUEST","Choose an authored purchase action");let g=k(m.product,d.selection,r.capabilities);if(!g)throw new c("PRODUCT_UNAVAILABLE","Choose an available Product");let C=A.previewAttach.request.parse({requestId:d.requestId,plans:[{productVersionId:g}],provider:l.commerce.provider,currency:l.commerce.currency,...d.offerId?{offerId:d.offerId}:{},...d.nativeOffer?{nativeOffer:d.nativeOffer}:{}}),F=JSON.stringify(C);if(i&&i!==F&&(!n||n.status==="pending"))throw new c("COMMAND_PENDING","Finish or cancel the original purchase before changing it");if(i===F){if(y)return y;if(s)return structuredClone(s)}i=F;let t=(async()=>{let f=A.previewAttach,p=f.response.parse(await u.request(f.path,C));if(p.quote.currency!==l.commerce.currency||p.quote.provider!==l.commerce.provider||p.quote.lines.length!==1||p.quote.lines[0].productVersionId!==g)throw new c("INVALID_RESPONSE","The purchase quote changed its selected Product or presentment");return s=p.quote,n=null,structuredClone(s)})();y=t;try{return await t}finally{y===t&&(y=null)}},confirm:()=>o("confirm"),cancel:()=>o("cancel"),read:()=>o("read"),destroy(){u.reset(),r=null,s=null,n=null,i=null}};return await v(),w}function X(a,e,u){let l=L.parse(a);if(l.evaluationMode!=="local")throw new c("EVALUATION_MODE","Remote nodes are evaluated by Grow");if(l.expiresAt&&Date.parse(l.expiresAt)<=Date.now())throw new c("CONFIGURATION_EXPIRED","Refresh local rules at the scheduled transition");let r=l.topology.nodes.find(o=>o.id===e);if(!r)throw new c("NOT_FOUND","Funnel node is unavailable");let s=b.parse(u.attributes??{}),n={attributes:s,saveStickyBucketAssignmentDoc:u.saveStickyBucketAssignmentDoc?o=>u.saveStickyBucketAssignmentDoc(structuredClone(o)):void 0,onFeatureUsage:u.onFeatureUsage?(o,w)=>u.onFeatureUsage(o,structuredClone(w)):void 0,onExperimentViewed:u.onExperimentViewed?(o,w)=>u.onExperimentViewed(structuredClone(o),structuredClone(w)):void 0,features:structuredClone(l.growth.features),savedGroups:P(l.growth.savedGroups),stickyBucketAssignmentDocs:structuredClone(u.stickyBucketAssignmentDocs)},i,y;if(r.type==="condition"){let o=l.conditions[r.id];if(!o)throw new c("INVALID_RESPONSE","Local condition rules are unavailable");i=o.find(w=>D(s,w.condition,n.savedGroups))?.port??"default"}else if(r.type==="feature"){if(!r.resources.featureKey)throw new c("INVALID_RESPONSE","Feature reference is unavailable");y=R(r.resources.featureKey,n).value,i="next"}else if(r.type==="split"){let o=r.resources.experimentId,w=o?l.growth.experiments[o]:null;if(!w||!o)throw new c("INVALID_RESPONSE","Experiment reference is unavailable");let d=V(w,n);y=d.value,i=d.inExperiment&&!d.passthrough&&typeof d.value=="string"?d.value:"notParticipating"}else throw new c("SERVER_REQUIRED","This node is driven by the authoritative Funnel runtime");let v=r.outputs[i];if(!v)throw new c("INVALID_RESPONSE","Evaluated node exit is unavailable");return{nodeId:e,port:i,target:v,...y===void 0?{}:{value:y}}}function H(a,e){return e.type==="id"?a.customerId===e.value:a.externalUserId===e.value}function O(a,e){if(a===e)return!0;if(Array.isArray(a)||Array.isArray(e))return Array.isArray(a)&&Array.isArray(e)&&a.length===e.length&&a.every((r,s)=>O(r,e[s]));if(!a||!e||typeof a!="object"||typeof e!="object")return!1;let u=Object.entries(a),l=Object.entries(e);return u.length===l.length&&u.every(([r,s])=>Object.hasOwn(e,r)&&O(s,Reflect.get(e,r)))}function ne(a){let e=/^gg_ct_[A-Za-z0-9_-]{32,128}$/.test(a.apiKey);if(typeof window<"u"&&!e)throw new c("SERVER_ONLY","Funnel starts are issued by your backend");if(!e&&!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(a.apiKey))throw new c("INVALID_TOKEN","A customer credential or server API key is required");let u=x({...a,timeoutMs:a.timeoutMs??35e3});return u.identify(a.apiKey),{async start(l){let r=U.safeParse({...l,operation:"start"});if(!r.success||r.data.operation!=="start"||(e?r.data.customer!==void 0:r.data.customer===void 0))throw new c("INVALID_REQUEST","Invalid current Funnel start");let s=r.data,n=T.safeParse(await u.request("funnels",s));if(!n.success||!n.data.runToken)throw new c("INVALID_RESPONSE","Funnel start credentials are missing");let i=n.data;if(i.run.source.id!==s.funnelId||i.run.locale!==(s.locale??"en")||!O(i.run.parameters,s.parameters??{})||(s.customer?!i.customerId||s.customer.type==="id"&&i.customerId!==s.customer.value:i.customerId!==void 0))throw new c("INVALID_RESPONSE","Funnel start contract changed");return{...i,runToken:i.runToken}}}}export{j as a,H as b,O as c,M as d,X as e,ne as f};
|